payload 3.0.0-beta.45 → 3.0.0-beta.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/dist/admin/RichText.d.ts +117 -17
  2. package/dist/admin/RichText.d.ts.map +1 -1
  3. package/dist/admin/RichText.js.map +1 -1
  4. package/dist/admin/views/types.d.ts +1 -1
  5. package/dist/admin/views/types.d.ts.map +1 -1
  6. package/dist/admin/views/types.js.map +1 -1
  7. package/dist/auth/operations/forgotPassword.d.ts.map +1 -1
  8. package/dist/auth/operations/forgotPassword.js +1 -2
  9. package/dist/auth/operations/forgotPassword.js.map +1 -1
  10. package/dist/auth/operations/local/login.d.ts +1 -2
  11. package/dist/auth/operations/local/login.d.ts.map +1 -1
  12. package/dist/auth/operations/local/login.js.map +1 -1
  13. package/dist/auth/operations/local/resetPassword.d.ts +1 -2
  14. package/dist/auth/operations/local/resetPassword.d.ts.map +1 -1
  15. package/dist/auth/operations/local/resetPassword.js.map +1 -1
  16. package/dist/auth/operations/local/unlock.d.ts +1 -2
  17. package/dist/auth/operations/local/unlock.d.ts.map +1 -1
  18. package/dist/auth/operations/local/unlock.js.map +1 -1
  19. package/dist/auth/operations/local/verifyEmail.d.ts +1 -2
  20. package/dist/auth/operations/local/verifyEmail.d.ts.map +1 -1
  21. package/dist/auth/operations/local/verifyEmail.js.map +1 -1
  22. package/dist/auth/operations/refresh.d.ts +1 -2
  23. package/dist/auth/operations/refresh.d.ts.map +1 -1
  24. package/dist/auth/operations/refresh.js.map +1 -1
  25. package/dist/auth/sendVerificationEmail.d.ts.map +1 -1
  26. package/dist/auth/sendVerificationEmail.js +1 -2
  27. package/dist/auth/sendVerificationEmail.js.map +1 -1
  28. package/dist/bin/generateTypes.d.ts.map +1 -1
  29. package/dist/bin/generateTypes.js +9 -0
  30. package/dist/bin/generateTypes.js.map +1 -1
  31. package/dist/collections/operations/create.d.ts.map +1 -1
  32. package/dist/collections/operations/create.js +1 -2
  33. package/dist/collections/operations/create.js.map +1 -1
  34. package/dist/collections/operations/local/create.d.ts +1 -2
  35. package/dist/collections/operations/local/create.d.ts.map +1 -1
  36. package/dist/collections/operations/local/create.js.map +1 -1
  37. package/dist/collections/operations/local/delete.d.ts +2 -4
  38. package/dist/collections/operations/local/delete.d.ts.map +1 -1
  39. package/dist/collections/operations/local/delete.js.map +1 -1
  40. package/dist/config/defaults.js +1 -1
  41. package/dist/config/defaults.js.map +1 -1
  42. package/dist/config/schema.d.ts.map +1 -1
  43. package/dist/config/schema.js +9 -1
  44. package/dist/config/schema.js.map +1 -1
  45. package/dist/config/shared/openGraphSchema.js +2 -2
  46. package/dist/config/shared/openGraphSchema.js.map +1 -1
  47. package/dist/config/types.d.ts +1 -1
  48. package/dist/config/types.d.ts.map +1 -1
  49. package/dist/config/types.js.map +1 -1
  50. package/dist/fields/config/sanitize.d.ts.map +1 -1
  51. package/dist/fields/config/sanitize.js +0 -15
  52. package/dist/fields/config/sanitize.js.map +1 -1
  53. package/dist/fields/config/schema.js +1 -1
  54. package/dist/fields/config/schema.js.map +1 -1
  55. package/dist/fields/config/types.d.ts +14 -2
  56. package/dist/fields/config/types.d.ts.map +1 -1
  57. package/dist/fields/config/types.js.map +1 -1
  58. package/dist/fields/getFieldPaths.d.ts +10 -0
  59. package/dist/fields/getFieldPaths.d.ts.map +1 -0
  60. package/dist/fields/getFieldPaths.js +45 -0
  61. package/dist/fields/getFieldPaths.js.map +1 -0
  62. package/dist/fields/hooks/afterChange/index.d.ts +6 -0
  63. package/dist/fields/hooks/afterChange/index.d.ts.map +1 -1
  64. package/dist/fields/hooks/afterChange/index.js +2 -0
  65. package/dist/fields/hooks/afterChange/index.js.map +1 -1
  66. package/dist/fields/hooks/afterChange/promise.d.ts +9 -1
  67. package/dist/fields/hooks/afterChange/promise.d.ts.map +1 -1
  68. package/dist/fields/hooks/afterChange/promise.js +67 -3
  69. package/dist/fields/hooks/afterChange/promise.js.map +1 -1
  70. package/dist/fields/hooks/afterChange/traverseFields.d.ts +3 -1
  71. package/dist/fields/hooks/afterChange/traverseFields.d.ts.map +1 -1
  72. package/dist/fields/hooks/afterChange/traverseFields.js +3 -1
  73. package/dist/fields/hooks/afterChange/traverseFields.js.map +1 -1
  74. package/dist/fields/hooks/afterRead/index.d.ts +1 -1
  75. package/dist/fields/hooks/afterRead/index.d.ts.map +1 -1
  76. package/dist/fields/hooks/afterRead/index.js +3 -1
  77. package/dist/fields/hooks/afterRead/index.js.map +1 -1
  78. package/dist/fields/hooks/afterRead/promise.d.ts +9 -1
  79. package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
  80. package/dist/fields/hooks/afterRead/promise.js +129 -25
  81. package/dist/fields/hooks/afterRead/promise.js.map +1 -1
  82. package/dist/fields/hooks/afterRead/traverseFields.d.ts +3 -1
  83. package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
  84. package/dist/fields/hooks/afterRead/traverseFields.js +3 -1
  85. package/dist/fields/hooks/afterRead/traverseFields.js.map +1 -1
  86. package/dist/fields/hooks/beforeChange/index.d.ts +1 -1
  87. package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
  88. package/dist/fields/hooks/beforeChange/index.js +3 -2
  89. package/dist/fields/hooks/beforeChange/index.js.map +1 -1
  90. package/dist/fields/hooks/beforeChange/promise.d.ts +9 -2
  91. package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
  92. package/dist/fields/hooks/beforeChange/promise.js +77 -10
  93. package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
  94. package/dist/fields/hooks/beforeChange/traverseFields.d.ts +4 -3
  95. package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
  96. package/dist/fields/hooks/beforeChange/traverseFields.js +4 -3
  97. package/dist/fields/hooks/beforeChange/traverseFields.js.map +1 -1
  98. package/dist/fields/hooks/beforeValidate/index.d.ts.map +1 -1
  99. package/dist/fields/hooks/beforeValidate/index.js +2 -0
  100. package/dist/fields/hooks/beforeValidate/index.js.map +1 -1
  101. package/dist/fields/hooks/beforeValidate/promise.d.ts +3 -1
  102. package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
  103. package/dist/fields/hooks/beforeValidate/promise.js +69 -4
  104. package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
  105. package/dist/fields/hooks/beforeValidate/traverseFields.d.ts +3 -1
  106. package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
  107. package/dist/fields/hooks/beforeValidate/traverseFields.js +3 -1
  108. package/dist/fields/hooks/beforeValidate/traverseFields.js.map +1 -1
  109. package/dist/globals/config/types.d.ts +1 -2
  110. package/dist/globals/config/types.d.ts.map +1 -1
  111. package/dist/globals/config/types.js.map +1 -1
  112. package/dist/index.d.ts.map +1 -1
  113. package/dist/index.js +4 -0
  114. package/dist/index.js.map +1 -1
  115. package/dist/uploads/cropImage.js +2 -2
  116. package/dist/uploads/cropImage.js.map +1 -1
  117. package/dist/uploads/generateFileData.js +4 -4
  118. package/dist/uploads/generateFileData.js.map +1 -1
  119. package/dist/uploads/getBaseFields.js +1 -1
  120. package/dist/uploads/getBaseFields.js.map +1 -1
  121. package/dist/uploads/imageResizer.d.ts.map +1 -1
  122. package/dist/uploads/imageResizer.js +21 -11
  123. package/dist/uploads/imageResizer.js.map +1 -1
  124. package/package.json +2 -2
@@ -1,13 +1,113 @@
1
1
  import type { GenericLanguages, I18n, I18nClient } from '@payloadcms/translations';
2
2
  import type { JSONSchema4 } from 'json-schema';
3
3
  import type React from 'react';
4
+ import type { SanitizedCollectionConfig, TypeWithID } from '../collections/config/types.js';
4
5
  import type { SanitizedConfig } from '../config/types.js';
5
- import type { Field, FieldBase, RichTextField, Validate } from '../fields/config/types.js';
6
+ import type { Field, FieldAffectingData, RichTextField, Validate } from '../fields/config/types.js';
7
+ import type { SanitizedGlobalConfig } from '../globals/config/types.js';
6
8
  import type { PayloadRequestWithData, RequestContext } from '../types/index.js';
7
9
  import type { WithServerSidePropsComponentProps } from './elements/WithServerSideProps.js';
8
10
  export type RichTextFieldProps<Value extends object, AdapterProps, ExtraFieldProperties = {}> = Omit<RichTextField<Value, AdapterProps, ExtraFieldProperties>, 'type'> & {
9
11
  path?: string;
10
12
  };
13
+ export type AfterReadRichTextHookArgs<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = {
14
+ currentDepth?: number;
15
+ depth?: number;
16
+ draft?: boolean;
17
+ fallbackLocale?: string;
18
+ fieldPromises?: Promise<void>[];
19
+ /** Boolean to denote if this hook is running against finding one, or finding many within the afterRead hook. */
20
+ findMany?: boolean;
21
+ flattenLocales?: boolean;
22
+ locale?: string;
23
+ /** A string relating to which operation the field type is currently executing within. */
24
+ operation?: 'create' | 'delete' | 'read' | 'update';
25
+ overrideAccess?: boolean;
26
+ populationPromises?: Promise<void>[];
27
+ showHiddenFields?: boolean;
28
+ triggerAccessControl?: boolean;
29
+ triggerHooks?: boolean;
30
+ };
31
+ export type AfterChangeRichTextHookArgs<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = {
32
+ /** A string relating to which operation the field type is currently executing within. */
33
+ operation: 'create' | 'update';
34
+ /** The document before changes were applied. */
35
+ previousDoc?: TData;
36
+ /** The sibling data of the document before changes being applied. */
37
+ previousSiblingDoc?: TData;
38
+ /** The previous value of the field, before changes */
39
+ previousValue?: TValue;
40
+ };
41
+ export type BeforeValidateRichTextHookArgs<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = {
42
+ /** A string relating to which operation the field type is currently executing within. */
43
+ operation: 'create' | 'update';
44
+ overrideAccess?: boolean;
45
+ /** The sibling data of the document before changes being applied. */
46
+ previousSiblingDoc?: TData;
47
+ /** The previous value of the field, before changes */
48
+ previousValue?: TValue;
49
+ };
50
+ export type BeforeChangeRichTextHookArgs<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = {
51
+ /**
52
+ * The original data with locales (not modified by any hooks). Only available in `beforeChange` and `beforeDuplicate` field hooks.
53
+ */
54
+ docWithLocales?: Record<string, unknown>;
55
+ duplicate?: boolean;
56
+ errors?: {
57
+ field: string;
58
+ message: string;
59
+ }[];
60
+ /** Only available in `beforeChange` field hooks */
61
+ mergeLocaleActions?: (() => Promise<void>)[];
62
+ /** A string relating to which operation the field type is currently executing within. */
63
+ operation?: 'create' | 'delete' | 'read' | 'update';
64
+ /** The sibling data of the document before changes being applied. */
65
+ previousSiblingDoc?: TData;
66
+ /** The previous value of the field, before changes */
67
+ previousValue?: TValue;
68
+ /**
69
+ * The original siblingData with locales (not modified by any hooks).
70
+ */
71
+ siblingDocWithLocales?: Record<string, unknown>;
72
+ skipValidation?: boolean;
73
+ };
74
+ export type BaseRichTextHookArgs<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = {
75
+ /** The collection which the field belongs to. If the field belongs to a global, this will be null. */
76
+ collection: SanitizedCollectionConfig | null;
77
+ context: RequestContext;
78
+ /** The data passed to update the document within create and update operations, and the full document itself in the afterRead hook. */
79
+ data?: Partial<TData>;
80
+ /** The field which the hook is running against. */
81
+ field: FieldAffectingData;
82
+ /** The global which the field belongs to. If the field belongs to a collection, this will be null. */
83
+ global: SanitizedGlobalConfig | null;
84
+ /** The full original document in `update` operations. In the `afterChange` hook, this is the resulting document of the operation. */
85
+ originalDoc?: TData;
86
+ /**
87
+ * The path of the field, e.g. ["group", "myArray", 1, "textField"]. The path is the schemaPath but with indexes and would be used in the context of field data, not field schemas.
88
+ */
89
+ path: (number | string)[];
90
+ /** The Express request object. It is mocked for Local API operations. */
91
+ req: PayloadRequestWithData;
92
+ /**
93
+ * The schemaPath of the field, e.g. ["group", "myArray", "textField"]. The schemaPath is the path but without indexes and would be used in the context of field schemas, not field data.
94
+ */
95
+ schemaPath: string[];
96
+ /** The sibling data passed to a field that the hook is running against. */
97
+ siblingData: Partial<TSiblingData>;
98
+ /** The value of the field. */
99
+ value?: TValue;
100
+ };
101
+ export type AfterReadRichTextHook<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = (args: BaseRichTextHookArgs<TData, TValue, TSiblingData> & AfterReadRichTextHookArgs<TData, TValue, TSiblingData>) => Promise<TValue> | TValue;
102
+ export type AfterChangeRichTextHook<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = (args: BaseRichTextHookArgs<TData, TValue, TSiblingData> & AfterChangeRichTextHookArgs<TData, TValue, TSiblingData>) => Promise<TValue> | TValue;
103
+ export type BeforeChangeRichTextHook<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = (args: BaseRichTextHookArgs<TData, TValue, TSiblingData> & BeforeChangeRichTextHookArgs<TData, TValue, TSiblingData>) => Promise<TValue> | TValue;
104
+ export type BeforeValidateRichTextHook<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = (args: BaseRichTextHookArgs<TData, TValue, TSiblingData> & BeforeValidateRichTextHookArgs<TData, TValue, TSiblingData>) => Promise<TValue> | TValue;
105
+ export type RichTextHooks = {
106
+ afterChange?: AfterChangeRichTextHook[];
107
+ afterRead?: AfterReadRichTextHook[];
108
+ beforeChange?: BeforeChangeRichTextHook[];
109
+ beforeValidate?: BeforeValidateRichTextHook[];
110
+ };
11
111
  type RichTextAdapterBase<Value extends object = object, AdapterProps = any, ExtraFieldProperties = {}> = {
12
112
  generateComponentMap: (args: {
13
113
  WithServerSideProps: React.FC<Omit<WithServerSidePropsComponentProps, 'serverOnlyProps'>>;
@@ -21,27 +121,13 @@ type RichTextAdapterBase<Value extends object = object, AdapterProps = any, Extr
21
121
  schemaMap: Map<string, Field[]>;
22
122
  schemaPath: string;
23
123
  }) => Map<string, Field[]>;
24
- hooks?: FieldBase['hooks'];
25
- i18n?: Partial<GenericLanguages>;
26
- outputSchema?: ({ collectionIDFieldTypes, config, field, interfaceNameDefinitions, isRequired, }: {
27
- collectionIDFieldTypes: {
28
- [key: string]: 'number' | 'string';
29
- };
30
- config?: SanitizedConfig;
31
- field: RichTextField<Value, AdapterProps, ExtraFieldProperties>;
32
- /**
33
- * Allows you to define new top-level interfaces that can be re-used in the output schema.
34
- */
35
- interfaceNameDefinitions: Map<string, JSONSchema4>;
36
- isRequired: boolean;
37
- }) => JSONSchema4;
38
124
  /**
39
- * Like an afterRead hook, but runs for both afterRead AND in the GraphQL resolver. For populating data, this should be used.
125
+ * Like an afterRead hook, but runs only for the GraphQL resolver. For populating data, this should be used, as afterRead hooks do not have a depth in graphQL.
40
126
  *
41
127
  * To populate stuff / resolve field hooks, mutate the incoming populationPromises or fieldPromises array. They will then be awaited in the correct order within payload itself.
42
128
  * @param data
43
129
  */
44
- populationPromises?: (data: {
130
+ graphQLPopulationPromises?: (data: {
45
131
  context: RequestContext;
46
132
  currentDepth?: number;
47
133
  depth: number;
@@ -56,6 +142,20 @@ type RichTextAdapterBase<Value extends object = object, AdapterProps = any, Extr
56
142
  showHiddenFields: boolean;
57
143
  siblingDoc: Record<string, unknown>;
58
144
  }) => void;
145
+ hooks?: RichTextHooks;
146
+ i18n?: Partial<GenericLanguages>;
147
+ outputSchema?: ({ collectionIDFieldTypes, config, field, interfaceNameDefinitions, isRequired, }: {
148
+ collectionIDFieldTypes: {
149
+ [key: string]: 'number' | 'string';
150
+ };
151
+ config?: SanitizedConfig;
152
+ field: RichTextField<Value, AdapterProps, ExtraFieldProperties>;
153
+ /**
154
+ * Allows you to define new top-level interfaces that can be re-used in the output schema.
155
+ */
156
+ interfaceNameDefinitions: Map<string, JSONSchema4>;
157
+ isRequired: boolean;
158
+ }) => JSONSchema4;
59
159
  validate: Validate<Value, Value, unknown, RichTextField<Value, AdapterProps, ExtraFieldProperties>>;
60
160
  };
61
161
  export type RichTextAdapter<Value extends object = object, AdapterProps = any, ExtraFieldProperties = {}> = RichTextAdapterBase<Value, AdapterProps, ExtraFieldProperties> & {
@@ -1 +1 @@
1
- {"version":3,"file":"RichText.d.ts","sourceRoot":"","sources":["../../src/admin/RichText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAClF,OAAO,KAAK,EAAE,WAAW,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,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,KACG,OAAO,CAAC,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,oBAAoB,CAAC,CAAC,GACnE,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,oBAAoB,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/admin/RichText.ts"],"sourcesContent":["import type { GenericLanguages, I18n, I18nClient } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\nimport type React from 'react'\n\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { Field, FieldBase, RichTextField, Validate } from '../fields/config/types.js'\nimport type { PayloadRequestWithData, RequestContext } from '../types/index.js'\nimport type { WithServerSidePropsComponentProps } from './elements/WithServerSideProps.js'\n\nexport type RichTextFieldProps<\n Value extends object,\n AdapterProps,\n ExtraFieldProperties = {},\n> = Omit<RichTextField<Value, AdapterProps, ExtraFieldProperties>, 'type'> & {\n path?: string\n}\n\ntype RichTextAdapterBase<\n Value extends object = object,\n AdapterProps = any,\n ExtraFieldProperties = {},\n> = {\n generateComponentMap: (args: {\n WithServerSideProps: React.FC<Omit<WithServerSidePropsComponentProps, 'serverOnlyProps'>>\n config: SanitizedConfig\n i18n: I18nClient\n schemaPath: string\n }) => Map<string, React.ReactNode>\n generateSchemaMap?: (args: {\n config: SanitizedConfig\n i18n: I18n<any, any>\n schemaMap: Map<string, Field[]>\n schemaPath: string\n }) => Map<string, Field[]>\n hooks?: FieldBase['hooks']\n i18n?: Partial<GenericLanguages>\n outputSchema?: ({\n collectionIDFieldTypes,\n config,\n field,\n interfaceNameDefinitions,\n isRequired,\n }: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n field: RichTextField<Value, AdapterProps, ExtraFieldProperties>\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n /**\n * Like an afterRead hook, but runs for both afterRead AND in the GraphQL resolver. For populating data, this should be used.\n *\n * To populate stuff / resolve field hooks, mutate the incoming populationPromises or fieldPromises array. They will then be awaited in the correct order within payload itself.\n * @param data\n */\n populationPromises?: (data: {\n context: RequestContext\n currentDepth?: number\n depth: number\n draft: boolean\n field: RichTextField<Value, AdapterProps, ExtraFieldProperties>\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n overrideAccess?: boolean\n populationPromises: Promise<void>[]\n req: PayloadRequestWithData\n showHiddenFields: boolean\n siblingDoc: Record<string, unknown>\n }) => void\n validate: Validate<\n Value,\n Value,\n unknown,\n RichTextField<Value, AdapterProps, ExtraFieldProperties>\n >\n}\n\nexport type RichTextAdapter<\n Value extends object = object,\n AdapterProps = any,\n ExtraFieldProperties = {},\n> = RichTextAdapterBase<Value, AdapterProps, ExtraFieldProperties> & {\n CellComponent: React.FC<any>\n FieldComponent: React.FC<RichTextFieldProps<Value, AdapterProps, ExtraFieldProperties>>\n}\n\nexport type RichTextAdapterProvider<\n Value extends object = object,\n AdapterProps = any,\n ExtraFieldProperties = {},\n> = ({\n config,\n isRoot,\n}: {\n config: SanitizedConfig\n /**\n * Whether or not this is the root richText editor, defined in the payload.config.ts.\n *\n * @default false\n */\n isRoot?: boolean\n}) =>\n | Promise<RichTextAdapter<Value, AdapterProps, ExtraFieldProperties>>\n | RichTextAdapter<Value, AdapterProps, ExtraFieldProperties>\n"],"names":[],"rangeMappings":"","mappings":"AA0FA,WAiB8D"}
1
+ {"version":3,"sources":["../../src/admin/RichText.ts"],"sourcesContent":["import type { GenericLanguages, I18n, I18nClient } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\nimport type React from 'react'\n\nimport type { SanitizedCollectionConfig, TypeWithID } from '../collections/config/types.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { Field, FieldAffectingData, RichTextField, Validate } from '../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\nimport type { PayloadRequestWithData, RequestContext } from '../types/index.js'\nimport type { WithServerSidePropsComponentProps } from './elements/WithServerSideProps.js'\n\nexport type RichTextFieldProps<\n Value extends object,\n AdapterProps,\n ExtraFieldProperties = {},\n> = Omit<RichTextField<Value, AdapterProps, ExtraFieldProperties>, 'type'> & {\n path?: string\n}\n\nexport type AfterReadRichTextHookArgs<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = {\n currentDepth?: number\n\n depth?: number\n\n draft?: boolean\n\n fallbackLocale?: string\n\n fieldPromises?: Promise<void>[]\n\n /** Boolean to denote if this hook is running against finding one, or finding many within the afterRead hook. */\n findMany?: boolean\n\n flattenLocales?: boolean\n\n locale?: string\n\n /** A string relating to which operation the field type is currently executing within. */\n operation?: 'create' | 'delete' | 'read' | 'update'\n\n overrideAccess?: boolean\n\n populationPromises?: Promise<void>[]\n showHiddenFields?: boolean\n triggerAccessControl?: boolean\n triggerHooks?: boolean\n}\n\nexport type AfterChangeRichTextHookArgs<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = {\n /** A string relating to which operation the field type is currently executing within. */\n operation: 'create' | 'update'\n /** The document before changes were applied. */\n previousDoc?: TData\n /** The sibling data of the document before changes being applied. */\n previousSiblingDoc?: TData\n /** The previous value of the field, before changes */\n previousValue?: TValue\n}\nexport type BeforeValidateRichTextHookArgs<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = {\n /** A string relating to which operation the field type is currently executing within. */\n operation: 'create' | 'update'\n overrideAccess?: boolean\n /** The sibling data of the document before changes being applied. */\n previousSiblingDoc?: TData\n /** The previous value of the field, before changes */\n previousValue?: TValue\n}\n\nexport type BeforeChangeRichTextHookArgs<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = {\n /**\n * The original data with locales (not modified by any hooks). Only available in `beforeChange` and `beforeDuplicate` field hooks.\n */\n docWithLocales?: Record<string, unknown>\n\n duplicate?: boolean\n\n errors?: { field: string; message: string }[]\n /** Only available in `beforeChange` field hooks */\n mergeLocaleActions?: (() => Promise<void>)[]\n /** A string relating to which operation the field type is currently executing within. */\n operation?: 'create' | 'delete' | 'read' | 'update'\n /** The sibling data of the document before changes being applied. */\n previousSiblingDoc?: TData\n /** The previous value of the field, before changes */\n previousValue?: TValue\n /**\n * The original siblingData with locales (not modified by any hooks).\n */\n siblingDocWithLocales?: Record<string, unknown>\n\n skipValidation?: boolean\n}\n\nexport type BaseRichTextHookArgs<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = {\n /** The collection which the field belongs to. If the field belongs to a global, this will be null. */\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n /** The data passed to update the document within create and update operations, and the full document itself in the afterRead hook. */\n data?: Partial<TData>\n /** The field which the hook is running against. */\n field: FieldAffectingData\n /** The global which the field belongs to. If the field belongs to a collection, this will be null. */\n global: SanitizedGlobalConfig | null\n\n /** The full original document in `update` operations. In the `afterChange` hook, this is the resulting document of the operation. */\n originalDoc?: TData\n /**\n * The path of the field, e.g. [\"group\", \"myArray\", 1, \"textField\"]. The path is the schemaPath but with indexes and would be used in the context of field data, not field schemas.\n */\n path: (number | string)[]\n\n /** The Express request object. It is mocked for Local API operations. */\n req: PayloadRequestWithData\n /**\n * The schemaPath of the field, e.g. [\"group\", \"myArray\", \"textField\"]. The schemaPath is the path but without indexes and would be used in the context of field schemas, not field data.\n */\n schemaPath: string[]\n /** The sibling data passed to a field that the hook is running against. */\n siblingData: Partial<TSiblingData>\n /** The value of the field. */\n value?: TValue\n}\n\nexport type AfterReadRichTextHook<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = (\n args: BaseRichTextHookArgs<TData, TValue, TSiblingData> &\n AfterReadRichTextHookArgs<TData, TValue, TSiblingData>,\n) => Promise<TValue> | TValue\n\nexport type AfterChangeRichTextHook<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = (\n args: BaseRichTextHookArgs<TData, TValue, TSiblingData> &\n AfterChangeRichTextHookArgs<TData, TValue, TSiblingData>,\n) => Promise<TValue> | TValue\n\nexport type BeforeChangeRichTextHook<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = (\n args: BaseRichTextHookArgs<TData, TValue, TSiblingData> &\n BeforeChangeRichTextHookArgs<TData, TValue, TSiblingData>,\n) => Promise<TValue> | TValue\n\nexport type BeforeValidateRichTextHook<\n TData extends TypeWithID = any,\n TValue = any,\n TSiblingData = any,\n> = (\n args: BaseRichTextHookArgs<TData, TValue, TSiblingData> &\n BeforeValidateRichTextHookArgs<TData, TValue, TSiblingData>,\n) => Promise<TValue> | TValue\n\nexport type RichTextHooks = {\n afterChange?: AfterChangeRichTextHook[]\n afterRead?: AfterReadRichTextHook[]\n beforeChange?: BeforeChangeRichTextHook[]\n beforeValidate?: BeforeValidateRichTextHook[]\n}\n\ntype RichTextAdapterBase<\n Value extends object = object,\n AdapterProps = any,\n ExtraFieldProperties = {},\n> = {\n generateComponentMap: (args: {\n WithServerSideProps: React.FC<Omit<WithServerSidePropsComponentProps, 'serverOnlyProps'>>\n config: SanitizedConfig\n i18n: I18nClient\n schemaPath: string\n }) => Map<string, React.ReactNode>\n generateSchemaMap?: (args: {\n config: SanitizedConfig\n i18n: I18n<any, any>\n schemaMap: Map<string, Field[]>\n schemaPath: string\n }) => Map<string, Field[]>\n /**\n * Like an afterRead hook, but runs only for the GraphQL resolver. For populating data, this should be used, as afterRead hooks do not have a depth in graphQL.\n *\n * To populate stuff / resolve field hooks, mutate the incoming populationPromises or fieldPromises array. They will then be awaited in the correct order within payload itself.\n * @param data\n */\n graphQLPopulationPromises?: (data: {\n context: RequestContext\n currentDepth?: number\n depth: number\n draft: boolean\n field: RichTextField<Value, AdapterProps, ExtraFieldProperties>\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n overrideAccess?: boolean\n populationPromises: Promise<void>[]\n req: PayloadRequestWithData\n showHiddenFields: boolean\n siblingDoc: Record<string, unknown>\n }) => void\n hooks?: RichTextHooks\n i18n?: Partial<GenericLanguages>\n outputSchema?: ({\n collectionIDFieldTypes,\n config,\n field,\n interfaceNameDefinitions,\n isRequired,\n }: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n field: RichTextField<Value, AdapterProps, ExtraFieldProperties>\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n validate: Validate<\n Value,\n Value,\n unknown,\n RichTextField<Value, AdapterProps, ExtraFieldProperties>\n >\n}\n\nexport type RichTextAdapter<\n Value extends object = object,\n AdapterProps = any,\n ExtraFieldProperties = {},\n> = RichTextAdapterBase<Value, AdapterProps, ExtraFieldProperties> & {\n CellComponent: React.FC<any>\n FieldComponent: React.FC<RichTextFieldProps<Value, AdapterProps, ExtraFieldProperties>>\n}\n\nexport type RichTextAdapterProvider<\n Value extends object = object,\n AdapterProps = any,\n ExtraFieldProperties = {},\n> = ({\n config,\n isRoot,\n}: {\n config: SanitizedConfig\n /**\n * Whether or not this is the root richText editor, defined in the payload.config.ts.\n *\n * @default false\n */\n isRoot?: boolean\n}) =>\n | Promise<RichTextAdapter<Value, AdapterProps, ExtraFieldProperties>>\n | RichTextAdapter<Value, AdapterProps, ExtraFieldProperties>\n"],"names":[],"rangeMappings":"","mappings":"AAmQA,WAiB8D"}
@@ -39,7 +39,7 @@ export type InitPageResult = {
39
39
  docID?: string;
40
40
  globalConfig?: SanitizedGlobalConfig;
41
41
  languageOptions: LanguageOptions;
42
- locale: Locale;
42
+ locale?: Locale;
43
43
  permissions: Permissions;
44
44
  req: PayloadRequestWithData;
45
45
  translations: ClientTranslationsObject;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/admin/views/types.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AAExE,OAAO,KAAK,EAA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,CAAA;IACxB,GAAG,EAAE,sBAAsB,CAAA;IAC3B,YAAY,EAAE,wBAAwB,CAAA;IACtC,eAAe,EAAE,eAAe,CAAA;CACjC,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,cAAc,EAAE,cAAc,CAAA;IAC9B,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAA;KAAE,CAAA;IACxD,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,YAAY,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAA;KAAE,CAAA;CAC/D,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/admin/views/types.ts"],"sourcesContent":["import type { ClientTranslationsObject } from '@payloadcms/translations'\n\nimport type { Permissions } from '../../auth/index.js'\nimport type { SanitizedCollectionConfig } from '../../collections/config/types.js'\nimport type { Locale } from '../../config/types.js'\nimport type { SanitizedGlobalConfig } from '../../globals/config/types.js'\nimport type { PayloadRequestWithData } from '../../types/index.js'\nimport type { LanguageOptions } from '../LanguageOptions.js'\n\nexport type AdminViewConfig = {\n Component: AdminViewComponent\n /** Whether the path should be matched exactly or as a prefix */\n exact?: boolean\n path: string\n sensitive?: boolean\n strict?: boolean\n}\n\nexport type AdminViewProps = {\n initPageResult: InitPageResult\n params?: { [key: string]: string | string[] | undefined }\n searchParams: { [key: string]: string | string[] | undefined }\n}\n\nexport type AdminViewComponent = React.ComponentType<AdminViewProps>\n\nexport type AdminView = AdminViewComponent | AdminViewConfig\n\nexport type EditViewProps = {\n collectionSlug?: string\n globalSlug?: string\n}\n\nexport type VisibleEntities = {\n collections: SanitizedCollectionConfig['slug'][]\n globals: SanitizedGlobalConfig['slug'][]\n}\n\nexport type InitPageResult = {\n collectionConfig?: SanitizedCollectionConfig\n cookies: Map<string, string>\n docID?: string\n globalConfig?: SanitizedGlobalConfig\n languageOptions: LanguageOptions\n locale: Locale\n permissions: Permissions\n req: PayloadRequestWithData\n translations: ClientTranslationsObject\n visibleEntities: VisibleEntities\n}\n\nexport type ServerSideEditViewProps = {\n initPageResult: InitPageResult\n params: { [key: string]: string | string[] | undefined }\n routeSegments: string[]\n searchParams: { [key: string]: string | string[] | undefined }\n}\n"],"names":[],"rangeMappings":"","mappings":"AAmDA,WAKC"}
1
+ {"version":3,"sources":["../../../src/admin/views/types.ts"],"sourcesContent":["import type { ClientTranslationsObject } from '@payloadcms/translations'\n\nimport type { Permissions } from '../../auth/index.js'\nimport type { SanitizedCollectionConfig } from '../../collections/config/types.js'\nimport type { Locale } from '../../config/types.js'\nimport type { SanitizedGlobalConfig } from '../../globals/config/types.js'\nimport type { PayloadRequestWithData } from '../../types/index.js'\nimport type { LanguageOptions } from '../LanguageOptions.js'\n\nexport type AdminViewConfig = {\n Component: AdminViewComponent\n /** Whether the path should be matched exactly or as a prefix */\n exact?: boolean\n path: string\n sensitive?: boolean\n strict?: boolean\n}\n\nexport type AdminViewProps = {\n initPageResult: InitPageResult\n params?: { [key: string]: string | string[] | undefined }\n searchParams: { [key: string]: string | string[] | undefined }\n}\n\nexport type AdminViewComponent = React.ComponentType<AdminViewProps>\n\nexport type AdminView = AdminViewComponent | AdminViewConfig\n\nexport type EditViewProps = {\n collectionSlug?: string\n globalSlug?: string\n}\n\nexport type VisibleEntities = {\n collections: SanitizedCollectionConfig['slug'][]\n globals: SanitizedGlobalConfig['slug'][]\n}\n\nexport type InitPageResult = {\n collectionConfig?: SanitizedCollectionConfig\n cookies: Map<string, string>\n docID?: string\n globalConfig?: SanitizedGlobalConfig\n languageOptions: LanguageOptions\n locale?: Locale\n permissions: Permissions\n req: PayloadRequestWithData\n translations: ClientTranslationsObject\n visibleEntities: VisibleEntities\n}\n\nexport type ServerSideEditViewProps = {\n initPageResult: InitPageResult\n params: { [key: string]: string | string[] | undefined }\n routeSegments: string[]\n searchParams: { [key: string]: string | string[] | undefined }\n}\n"],"names":[],"rangeMappings":"","mappings":"AAmDA,WAKC"}
@@ -1 +1 @@
1
- {"version":3,"file":"forgotPassword.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/forgotPassword.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAQlE,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;QACtB,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,sBAAsB,CAAA;CAC5B,CAAA;AAED,MAAM,MAAM,MAAM,GAAG,MAAM,CAAA;AAE3B,eAAO,MAAM,uBAAuB,iBAAwB,SAAS,KAAG,QAAQ,IAAI,GAAG,MAAM,CA6I5F,CAAA"}
1
+ {"version":3,"file":"forgotPassword.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/forgotPassword.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAQlE,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;QACtB,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,sBAAsB,CAAA;CAC5B,CAAA;AAED,MAAM,MAAM,MAAM,GAAG,MAAM,CAAA;AAE3B,eAAO,MAAM,uBAAuB,iBAAwB,SAAS,KAAG,QAAQ,IAAI,GAAG,MAAM,CA4I5F,CAAA"}
@@ -78,8 +78,7 @@ export const forgotPasswordOperation = async (incomingArgs)=>{
78
78
  user
79
79
  });
80
80
  }
81
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
82
- email.sendEmail({
81
+ await email.sendEmail({
83
82
  from: `"${email.defaultFromName}" <${email.defaultFromAddress}>`,
84
83
  html,
85
84
  subject,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/auth/operations/forgotPassword.ts"],"sourcesContent":["import crypto from 'crypto'\nimport httpStatus from 'http-status'\nimport { URL } from 'url'\n\nimport type { Collection } from '../../collections/config/types.js'\nimport type { PayloadRequestWithData } from '../../types/index.js'\n\nimport { buildAfterOperation } from '../../collections/operations/utils.js'\nimport { APIError } from '../../errors/index.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\n\nexport type Arguments = {\n collection: Collection\n data: {\n [key: string]: unknown\n email: string\n }\n disableEmail?: boolean\n expiration?: number\n req: PayloadRequestWithData\n}\n\nexport type Result = string\n\nexport const forgotPasswordOperation = async (incomingArgs: Arguments): Promise<null | string> => {\n if (!Object.prototype.hasOwnProperty.call(incomingArgs.data, 'email')) {\n throw new APIError('Missing email.', httpStatus.BAD_REQUEST)\n }\n\n let args = incomingArgs\n\n try {\n const shouldCommit = await initTransaction(args.req)\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n await args.collection.config.hooks.beforeOperation.reduce(async (priorHook, hook) => {\n await priorHook\n\n args =\n (await hook({\n args,\n collection: args.collection?.config,\n context: args.req.context,\n operation: 'forgotPassword',\n req: args.req,\n })) || args\n }, Promise.resolve())\n\n const {\n collection: { config: collectionConfig },\n data,\n disableEmail,\n expiration,\n req: {\n payload: { config, email },\n payload,\n },\n req,\n } = args\n\n // /////////////////////////////////////\n // Forget password\n // /////////////////////////////////////\n\n let token: string = crypto.randomBytes(20).toString('hex')\n\n type UserDoc = {\n id: number | string\n resetPasswordExpiration?: string\n resetPasswordToken?: string\n }\n\n if (!data.email) {\n throw new APIError('Missing email.', httpStatus.BAD_REQUEST)\n }\n\n let user = await payload.db.findOne<UserDoc>({\n collection: collectionConfig.slug,\n req,\n where: { email: { equals: data.email.toLowerCase() } },\n })\n\n // We don't want to indicate specifically that an email was not found,\n // as doing so could lead to the exposure of registered emails.\n // Therefore, we prefer to fail silently.\n if (!user) return null\n\n user.resetPasswordToken = token\n user.resetPasswordExpiration = new Date(expiration || Date.now() + 3600000).toISOString() // 1 hour\n\n user = await payload.update({\n id: user.id,\n collection: collectionConfig.slug,\n data: user,\n req,\n })\n\n if (!disableEmail) {\n const protocol = new URL(req.url).protocol // includes the final :\n const serverURL =\n config.serverURL !== null && config.serverURL !== ''\n ? config.serverURL\n : `${protocol}//${req.headers.get('host')}`\n\n let html = `${req.t('authentication:youAreReceivingResetPassword')}\n <a href=\"${serverURL}${config.routes.admin}/reset/${token}\">${serverURL}${config.routes.admin}/reset/${token}</a>\n ${req.t('authentication:youDidNotRequestPassword')}`\n\n if (typeof collectionConfig.auth.forgotPassword.generateEmailHTML === 'function') {\n html = await collectionConfig.auth.forgotPassword.generateEmailHTML({\n req,\n token,\n user,\n })\n }\n\n let subject = req.t('authentication:resetYourPassword')\n\n if (typeof collectionConfig.auth.forgotPassword.generateEmailSubject === 'function') {\n subject = await collectionConfig.auth.forgotPassword.generateEmailSubject({\n req,\n token,\n user,\n })\n }\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n email.sendEmail({\n from: `\"${email.defaultFromName}\" <${email.defaultFromAddress}>`,\n html,\n subject,\n to: data.email,\n })\n }\n\n // /////////////////////////////////////\n // afterForgotPassword - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterForgotPassword.reduce(async (priorHook, hook) => {\n await priorHook\n await hook({ args, collection: args.collection?.config, context: req.context })\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n token = await buildAfterOperation({\n args,\n collection: args.collection?.config,\n operation: 'forgotPassword',\n result: token,\n })\n\n if (shouldCommit) await commitTransaction(req)\n\n return token\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["crypto","httpStatus","URL","buildAfterOperation","APIError","commitTransaction","initTransaction","killTransaction","forgotPasswordOperation","incomingArgs","Object","prototype","hasOwnProperty","call","data","BAD_REQUEST","args","shouldCommit","req","collection","config","hooks","beforeOperation","reduce","priorHook","hook","context","operation","Promise","resolve","collectionConfig","disableEmail","expiration","payload","email","token","randomBytes","toString","user","db","findOne","slug","where","equals","toLowerCase","resetPasswordToken","resetPasswordExpiration","Date","now","toISOString","update","id","protocol","url","serverURL","headers","get","html","t","routes","admin","auth","forgotPassword","generateEmailHTML","subject","generateEmailSubject","sendEmail","from","defaultFromName","defaultFromAddress","to","afterForgotPassword","result","error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,YAAY,SAAQ;AAC3B,OAAOC,gBAAgB,cAAa;AACpC,SAASC,GAAG,QAAQ,MAAK;AAKzB,SAASC,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AAepE,OAAO,MAAMC,0BAA0B,OAAOC;IAC5C,IAAI,CAACC,OAAOC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACJ,aAAaK,IAAI,EAAE,UAAU;QACrE,MAAM,IAAIV,SAAS,kBAAkBH,WAAWc,WAAW;IAC7D;IAEA,IAAIC,OAAOP;IAEX,IAAI;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KoB,KAAK;YAChB;QACF;QAEA,wCAAwC;QACxC,mCAAmC;QACnC,wCAAwC;QAExC,MAAMJ,iBAAiBT,KAAK,CAACkD,mBAAmB,CAAChD,MAAM,CAAC,OAAOC,WAAWC;YACxE,MAAMD;YACN,MAAMC,KAAK;gBAAET;gBAAMG,YAAYH,KAAKG,UAAU,EAAEC;gBAAQM,SAASR,IAAIQ,OAAO;YAAC;QAC/E,GAAGE,QAAQC,OAAO;QAElB,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExCM,QAAQ,MAAMhC,oBAAoB;YAChCa;YACAG,YAAYH,KAAKG,UAAU,EAAEC;YAC7BO,WAAW;YACX6C,QAAQrC;QACV;QAEA,IAAIlB,cAAc,MAAMZ,kBAAkBa;QAE1C,OAAOiB;IACT,EAAE,OAAOsC,OAAgB;QACvB,MAAMlE,gBAAgBS,KAAKE,GAAG;QAC9B,MAAMuD;IACR;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/auth/operations/forgotPassword.ts"],"sourcesContent":["import crypto from 'crypto'\nimport httpStatus from 'http-status'\nimport { URL } from 'url'\n\nimport type { Collection } from '../../collections/config/types.js'\nimport type { PayloadRequestWithData } from '../../types/index.js'\n\nimport { buildAfterOperation } from '../../collections/operations/utils.js'\nimport { APIError } from '../../errors/index.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\n\nexport type Arguments = {\n collection: Collection\n data: {\n [key: string]: unknown\n email: string\n }\n disableEmail?: boolean\n expiration?: number\n req: PayloadRequestWithData\n}\n\nexport type Result = string\n\nexport const forgotPasswordOperation = async (incomingArgs: Arguments): Promise<null | string> => {\n if (!Object.prototype.hasOwnProperty.call(incomingArgs.data, 'email')) {\n throw new APIError('Missing email.', httpStatus.BAD_REQUEST)\n }\n\n let args = incomingArgs\n\n try {\n const shouldCommit = await initTransaction(args.req)\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n await args.collection.config.hooks.beforeOperation.reduce(async (priorHook, hook) => {\n await priorHook\n\n args =\n (await hook({\n args,\n collection: args.collection?.config,\n context: args.req.context,\n operation: 'forgotPassword',\n req: args.req,\n })) || args\n }, Promise.resolve())\n\n const {\n collection: { config: collectionConfig },\n data,\n disableEmail,\n expiration,\n req: {\n payload: { config, email },\n payload,\n },\n req,\n } = args\n\n // /////////////////////////////////////\n // Forget password\n // /////////////////////////////////////\n\n let token: string = crypto.randomBytes(20).toString('hex')\n\n type UserDoc = {\n id: number | string\n resetPasswordExpiration?: string\n resetPasswordToken?: string\n }\n\n if (!data.email) {\n throw new APIError('Missing email.', httpStatus.BAD_REQUEST)\n }\n\n let user = await payload.db.findOne<UserDoc>({\n collection: collectionConfig.slug,\n req,\n where: { email: { equals: data.email.toLowerCase() } },\n })\n\n // We don't want to indicate specifically that an email was not found,\n // as doing so could lead to the exposure of registered emails.\n // Therefore, we prefer to fail silently.\n if (!user) return null\n\n user.resetPasswordToken = token\n user.resetPasswordExpiration = new Date(expiration || Date.now() + 3600000).toISOString() // 1 hour\n\n user = await payload.update({\n id: user.id,\n collection: collectionConfig.slug,\n data: user,\n req,\n })\n\n if (!disableEmail) {\n const protocol = new URL(req.url).protocol // includes the final :\n const serverURL =\n config.serverURL !== null && config.serverURL !== ''\n ? config.serverURL\n : `${protocol}//${req.headers.get('host')}`\n\n let html = `${req.t('authentication:youAreReceivingResetPassword')}\n <a href=\"${serverURL}${config.routes.admin}/reset/${token}\">${serverURL}${config.routes.admin}/reset/${token}</a>\n ${req.t('authentication:youDidNotRequestPassword')}`\n\n if (typeof collectionConfig.auth.forgotPassword.generateEmailHTML === 'function') {\n html = await collectionConfig.auth.forgotPassword.generateEmailHTML({\n req,\n token,\n user,\n })\n }\n\n let subject = req.t('authentication:resetYourPassword')\n\n if (typeof collectionConfig.auth.forgotPassword.generateEmailSubject === 'function') {\n subject = await collectionConfig.auth.forgotPassword.generateEmailSubject({\n req,\n token,\n user,\n })\n }\n\n await email.sendEmail({\n from: `\"${email.defaultFromName}\" <${email.defaultFromAddress}>`,\n html,\n subject,\n to: data.email,\n })\n }\n\n // /////////////////////////////////////\n // afterForgotPassword - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterForgotPassword.reduce(async (priorHook, hook) => {\n await priorHook\n await hook({ args, collection: args.collection?.config, context: req.context })\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n token = await buildAfterOperation({\n args,\n collection: args.collection?.config,\n operation: 'forgotPassword',\n result: token,\n })\n\n if (shouldCommit) await commitTransaction(req)\n\n return token\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["crypto","httpStatus","URL","buildAfterOperation","APIError","commitTransaction","initTransaction","killTransaction","forgotPasswordOperation","incomingArgs","Object","prototype","hasOwnProperty","call","data","BAD_REQUEST","args","shouldCommit","req","collection","config","hooks","beforeOperation","reduce","priorHook","hook","context","operation","Promise","resolve","collectionConfig","disableEmail","expiration","payload","email","token","randomBytes","toString","user","db","findOne","slug","where","equals","toLowerCase","resetPasswordToken","resetPasswordExpiration","Date","now","toISOString","update","id","protocol","url","serverURL","headers","get","html","t","routes","admin","auth","forgotPassword","generateEmailHTML","subject","generateEmailSubject","sendEmail","from","defaultFromName","defaultFromAddress","to","afterForgotPassword","result","error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,YAAY,SAAQ;AAC3B,OAAOC,gBAAgB,cAAa;AACpC,SAASC,GAAG,QAAQ,MAAK;AAKzB,SAASC,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eA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AAiB+B,IAAI,CAACC,cAAc,CAACG,oBAAoB,CAAC;oBACxE/C;oBACAiB;oBACAG;gBACF;YACF;YAEA,MAAMJ,MAAMgC,SAAS,CAAC;gBACpBC,MAAM,CAAC,CAAC,EAAEjC,MAAMkC,eAAe,CAAC,GAAG,EAAElC,MAAMmC,kBAAkB,CAAC,CAAC,CAAC;gBAChEZ;gBACAO;gBACAM,IAAIxD,KAAKoB,KAAK;YAChB;QACF;QAEA,wCAAwC;QACxC,mCAAmC;QACnC,wCAAwC;QAExC,MAAMJ,iBAAiBT,KAAK,CAACkD,mBAAmB,CAAChD,MAAM,CAAC,OAAOC,WAAWC;YACxE,MAAMD;YACN,MAAMC,KAAK;gBAAET;gBAAMG,YAAYH,KAAKG,UAAU,EAAEC;gBAAQM,SAASR,IAAIQ,OAAO;YAAC;QAC/E,GAAGE,QAAQC,OAAO;QAElB,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExCM,QAAQ,MAAMhC,oBAAoB;YAChCa;YACAG,YAAYH,KAAKG,UAAU,EAAEC;YAC7BO,WAAW;YACX6C,QAAQrC;QACV;QAEA,IAAIlB,cAAc,MAAMZ,kBAAkBa;QAE1C,OAAOiB;IACT,EAAE,OAAOsC,OAAgB;QACvB,MAAMlE,gBAAgBS,KAAKE,GAAG;QAC9B,MAAMuD;IACR;AACF,EAAC"}
@@ -1,5 +1,4 @@
1
- import type { Payload, RequestContext } from '../../../index.js';
2
- import type { GeneratedTypes } from '../../../index.js';
1
+ import type { GeneratedTypes, Payload, RequestContext } from '../../../index.js';
3
2
  import type { PayloadRequestWithData } from '../../../types/index.js';
4
3
  import type { Result } from '../login.js';
5
4
  export type Options<TSlug extends keyof GeneratedTypes['collections']> = {
@@ -1 +1 @@
1
- {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../../src/auth/operations/local/login.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACh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c,CAAC,aAAa,CAAC,IAAI;IACvE,UAAU,EAAE,KAAK,CAAA;IACjB,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAA;QACb,QAAQ,EAAE,MAAM,CAAA;KACjB,CAAA;IACD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,CAAC,EAAE,sBAAsB,CAAA;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,iBAAe,UAAU,CAAC,KAAK,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,EACzE,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,GACtB,OAAO,CAAC,MAAM,GAAG;IAAE,IAAI,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,CAAA;CAAE,CAAC,CAiClE;AAED,eAAe,UAAU,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/auth/operations/local/login.ts"],"sourcesContent":["import type { Payload, RequestContext } from '../../../index.js'\nimport type { GeneratedTypes } from '../../../index.js'\nimport type { PayloadRequestWithData } from '../../../types/index.js'\nimport type { Result } from '../login.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { loginOperation } from '../login.js'\n\nexport type Options<TSlug extends keyof GeneratedTypes['collections']> = {\n collection: TSlug\n context?: RequestContext\n data: {\n email: string\n password: string\n }\n depth?: number\n fallbackLocale?: string\n locale?: string\n overrideAccess?: boolean\n req?: PayloadRequestWithData\n showHiddenFields?: boolean\n}\n\nasync function localLogin<TSlug extends keyof GeneratedTypes['collections']>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<Result & { user: GeneratedTypes['collections'][TSlug] }> {\n const {\n collection: collectionSlug,\n data,\n depth,\n overrideAccess = true,\n showHiddenFields,\n } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} can't be found. Login Operation.`,\n )\n }\n\n const args = {\n collection,\n data,\n depth,\n overrideAccess,\n req: await createLocalReq(options, payload),\n showHiddenFields,\n }\n\n const result = await loginOperation<TSlug>(args)\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return result\n}\n\nexport default localLogin\n"],"names":["APIError","createLocalReq","loginOperation","localLogin","payload","options","collection","collectionSlug","data","depth","overrideAccess","showHiddenFields","collections","String","args","req","result","config","auth","removeTokenFromResponses","token"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,cAAa;AAiB5C,eAAeC,WACbC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EACJC,YAAYC,cAAc,EAC1BC,IAAI,EACJC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,gBAAgB,EACjB,GAAGN;IAEJ,MAAMC,aAAaF,QAAQQ,WAAW,CAACL,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEa,OAAON,gBAAgB,iCAAiC,CAAC;IAEzF;IAEA,MAAMO,OAAO;QACXR;QACAE;QACAC;QACAC;QACAK,KAAK,MAAMd,eAAeI,SAASD;QACnCO;IACF;IAEA,MAAMK,SAAS,MAAMd,eAAsBY;IAE3C,IAAIR,WAAWW,MAAM,CAACC,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOH,OAAOI,KAAK;IACrB;IAEA,OAAOJ;AACT;AAEA,eAAeb,WAAU"}
1
+ {"version":3,"sources":["../../../../src/auth/operations/local/login.ts"],"sourcesContent":["import type { GeneratedTypes, Payload , RequestContext } from '../../../index.js'\nimport type { PayloadRequestWithData } from '../../../types/index.js'\nimport type { Result } from '../login.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { loginOperation } from '../login.js'\n\nexport type Options<TSlug extends keyof GeneratedTypes['collections']> = {\n collection: TSlug\n context?: RequestContext\n data: {\n email: string\n password: string\n }\n depth?: number\n fallbackLocale?: string\n locale?: string\n overrideAccess?: boolean\n req?: PayloadRequestWithData\n showHiddenFields?: boolean\n}\n\nasync function localLogin<TSlug extends keyof GeneratedTypes['collections']>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<Result & { user: GeneratedTypes['collections'][TSlug] }> {\n const {\n collection: collectionSlug,\n data,\n depth,\n overrideAccess = true,\n showHiddenFields,\n } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} can't be found. Login Operation.`,\n )\n }\n\n const args = {\n collection,\n data,\n depth,\n overrideAccess,\n req: await createLocalReq(options, payload),\n showHiddenFields,\n }\n\n const result = await loginOperation<TSlug>(args)\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return result\n}\n\nexport default localLogin\n"],"names":["APIError","createLocalReq","loginOperation","localLogin","payload","options","collection","collectionSlug","data","depth","overrideAccess","showHiddenFields","collections","String","args","req","result","config","auth","removeTokenFromResponses","token"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,cAAa;AAiB5C,eAAeC,WACbC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EACJC,YAAYC,cAAc,EAC1BC,IAAI,EACJC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,gBAAgB,EACjB,GAAGN;IAEJ,MAAMC,aAAaF,QAAQQ,WAAW,CAACL,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEa,OAAON,gBAAgB,iCAAiC,CAAC;IAEzF;IAEA,MAAMO,OAAO;QACXR;QACAE;QACAC;QACAC;QACAK,KAAK,MAAMd,eAAeI,SAASD;QACnCO;IACF;IAEA,MAAMK,SAAS,MAAMd,eAAsBY;IAE3C,IAAIR,WAAWW,MAAM,CAACC,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOH,OAAOI,KAAK;IACrB;IAEA,OAAOJ;AACT;AAEA,eAAeb,WAAU"}
@@ -1,5 +1,4 @@
1
- import type { Payload, RequestContext } from '../../../index.js';
2
- import type { GeneratedTypes } from '../../../index.js';
1
+ import type { GeneratedTypes, Payload, RequestContext } from '../../../index.js';
3
2
  import type { PayloadRequestWithData } from '../../../types/index.js';
4
3
  import type { Result } from '../resetPassword.js';
5
4
  export type Options<T extends keyof GeneratedTypes['collections']> = {
@@ -1 +1 @@
1
- {"version":3,"file":"resetPassword.d.ts","sourceRoot":"","sources":["../../../../src/auth/operations/local/resetPassword.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAMjD,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,IAAI;IACnE,UAAU,EAAE,CAAC,CAAA;IACb,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,IAAI,EAAE;QACJ,QAAQ,EAAE,MAAM,CAAA;QAChB,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,CAAC,EAAE,sBAAsB,CAAA;CAC7B,CAAA;AAED,iBAAe,kBAAkB,CAAC,CAAC,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,EAC7E,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAClB,OAAO,CAAC,MAAM,CAAC,CAyBjB;AAED,eAAe,kBAAkB,CAAA"}
1
+ {"version":3,"file":"resetPassword.d.ts","sourceRoot":"","sources":["../../../../src/auth/operations/local/resetPassword.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAG,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACjF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAMjD,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,IAAI;IACnE,UAAU,EAAE,CAAC,CAAA;IACb,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,IAAI,EAAE;QACJ,QAAQ,EAAE,MAAM,CAAA;QAChB,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,CAAC,EAAE,sBAAsB,CAAA;CAC7B,CAAA;AAED,iBAAe,kBAAkB,CAAC,CAAC,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,EAC7E,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAClB,OAAO,CAAC,MAAM,CAAC,CAyBjB;AAED,eAAe,kBAAkB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/auth/operations/local/resetPassword.ts"],"sourcesContent":["import type { Payload, RequestContext } from '../../../index.js'\nimport type { GeneratedTypes } from '../../../index.js'\nimport type { PayloadRequestWithData } from '../../../types/index.js'\nimport type { Result } from '../resetPassword.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { resetPasswordOperation } from '../resetPassword.js'\n\nexport type Options<T extends keyof GeneratedTypes['collections']> = {\n collection: T\n context?: RequestContext\n data: {\n password: string\n token: string\n }\n overrideAccess: boolean\n req?: PayloadRequestWithData\n}\n\nasync function localResetPassword<T extends keyof GeneratedTypes['collections']>(\n payload: Payload,\n options: Options<T>,\n): Promise<Result> {\n const { collection: collectionSlug, data, overrideAccess } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(\n collectionSlug,\n )} can't be found. Reset Password Operation.`,\n )\n }\n\n const result = await resetPasswordOperation({\n collection,\n data,\n overrideAccess,\n req: await createLocalReq(options, payload),\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return result\n}\n\nexport default localResetPassword\n"],"names":["APIError","createLocalReq","resetPasswordOperation","localResetPassword","payload","options","collection","collectionSlug","data","overrideAccess","collections","String","result","req","config","auth","removeTokenFromResponses","token"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,sBAAsB,QAAQ,sBAAqB;AAa5D,eAAeC,mBACbC,OAAgB,EAChBC,OAAmB;IAEnB,MAAM,EAAEC,YAAYC,cAAc,EAAEC,IAAI,EAAEC,cAAc,EAAE,GAAGJ;IAE7D,MAAMC,aAAaF,QAAQM,WAAW,CAACH,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEW,OAC1BJ,gBACA,0CAA0C,CAAC;IAEjD;IAEA,MAAMK,SAAS,MAAMV,uBAAuB;QAC1CI;QACAE;QACAC;QACAI,KAAK,MAAMZ,eAAeI,SAASD;IACrC;IAEA,IAAIE,WAAWQ,MAAM,CAACC,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOJ,OAAOK,KAAK;IACrB;IAEA,OAAOL;AACT;AAEA,eAAeT,mBAAkB"}
1
+ {"version":3,"sources":["../../../../src/auth/operations/local/resetPassword.ts"],"sourcesContent":["import type { GeneratedTypes, Payload , RequestContext } from '../../../index.js'\nimport type { PayloadRequestWithData } from '../../../types/index.js'\nimport type { Result } from '../resetPassword.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { resetPasswordOperation } from '../resetPassword.js'\n\nexport type Options<T extends keyof GeneratedTypes['collections']> = {\n collection: T\n context?: RequestContext\n data: {\n password: string\n token: string\n }\n overrideAccess: boolean\n req?: PayloadRequestWithData\n}\n\nasync function localResetPassword<T extends keyof GeneratedTypes['collections']>(\n payload: Payload,\n options: Options<T>,\n): Promise<Result> {\n const { collection: collectionSlug, data, overrideAccess } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(\n collectionSlug,\n )} can't be found. Reset Password Operation.`,\n )\n }\n\n const result = await resetPasswordOperation({\n collection,\n data,\n overrideAccess,\n req: await createLocalReq(options, payload),\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return result\n}\n\nexport default localResetPassword\n"],"names":["APIError","createLocalReq","resetPasswordOperation","localResetPassword","payload","options","collection","collectionSlug","data","overrideAccess","collections","String","result","req","config","auth","removeTokenFromResponses","token"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,sBAAsB,QAAQ,sBAAqB;AAa5D,eAAeC,mBACbC,OAAgB,EAChBC,OAAmB;IAEnB,MAAM,EAAEC,YAAYC,cAAc,EAAEC,IAAI,EAAEC,cAAc,EAAE,GAAGJ;IAE7D,MAAMC,aAAaF,QAAQM,WAAW,CAACH,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEW,OAC1BJ,gBACA,0CAA0C,CAAC;IAEjD;IAEA,MAAMK,SAAS,MAAMV,uBAAuB;QAC1CI;QACAE;QACAC;QACAI,KAAK,MAAMZ,eAAeI,SAASD;IACrC;IAEA,IAAIE,WAAWQ,MAAM,CAACC,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOJ,OAAOK,KAAK;IACrB;IAEA,OAAOL;AACT;AAEA,eAAeT,mBAAkB"}
@@ -1,5 +1,4 @@
1
- import type { Payload, RequestContext } from '../../../index.js';
2
- import type { GeneratedTypes } from '../../../index.js';
1
+ import type { GeneratedTypes, Payload, RequestContext } from '../../../index.js';
3
2
  import type { PayloadRequestWithData } from '../../../types/index.js';
4
3
  export type Options<T extends keyof GeneratedTypes['collections']> = {
5
4
  collection: T;
@@ -1 +1 @@
1
- {"version":3,"file":"unlock.d.ts","sourceRoot":"","sources":["../../../../src/auth/operations/local/unlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAMrE,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,IAAI;IACnE,UAAU,EAAE,CAAC,CAAA;IACb,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,IAAI,EAAE;QACJ,KAAK,MAAA;KACN,CAAA;IACD,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,CAAC,EAAE,sBAAsB,CAAA;CAC7B,CAAA;AAED,iBAAe,WAAW,CAAC,CAAC,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,EACtE,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAClB,OAAO,CAAC,OAAO,CAAC,CAiBlB;AAED,eAAe,WAAW,CAAA"}
1
+ {"version":3,"file":"unlock.d.ts","sourceRoot":"","sources":["../../../../src/auth/operations/local/unlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAG,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACjF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAMrE,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,IAAI;IACnE,UAAU,EAAE,CAAC,CAAA;IACb,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,IAAI,EAAE;QACJ,KAAK,MAAA;KACN,CAAA;IACD,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,CAAC,EAAE,sBAAsB,CAAA;CAC7B,CAAA;AAED,iBAAe,WAAW,CAAC,CAAC,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,EACtE,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAClB,OAAO,CAAC,OAAO,CAAC,CAiBlB;AAED,eAAe,WAAW,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/auth/operations/local/unlock.ts"],"sourcesContent":["import type { Payload, RequestContext } from '../../../index.js'\nimport type { GeneratedTypes } from '../../../index.js'\nimport type { PayloadRequestWithData } from '../../../types/index.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { unlockOperation } from '../unlock.js'\n\nexport type Options<T extends keyof GeneratedTypes['collections']> = {\n collection: T\n context?: RequestContext\n data: {\n email\n }\n overrideAccess: boolean\n req?: PayloadRequestWithData\n}\n\nasync function localUnlock<T extends keyof GeneratedTypes['collections']>(\n payload: Payload,\n options: Options<T>,\n): Promise<boolean> {\n const { collection: collectionSlug, data, overrideAccess = true } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} can't be found. Unlock Operation.`,\n )\n }\n\n return unlockOperation({\n collection,\n data,\n overrideAccess,\n req: await createLocalReq(options, payload),\n })\n}\n\nexport default localUnlock\n"],"names":["APIError","createLocalReq","unlockOperation","localUnlock","payload","options","collection","collectionSlug","data","overrideAccess","collections","String","req"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,eAAe,QAAQ,eAAc;AAY9C,eAAeC,YACbC,OAAgB,EAChBC,OAAmB;IAEnB,MAAM,EAAEC,YAAYC,cAAc,EAAEC,IAAI,EAAEC,iBAAiB,IAAI,EAAE,GAAGJ;IAEpE,MAAMC,aAAaF,QAAQM,WAAW,CAACH,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEW,OAAOJ,gBAAgB,kCAAkC,CAAC;IAE1F;IAEA,OAAOL,gBAAgB;QACrBI;QACAE;QACAC;QACAG,KAAK,MAAMX,eAAeI,SAASD;IACrC;AACF;AAEA,eAAeD,YAAW"}
1
+ {"version":3,"sources":["../../../../src/auth/operations/local/unlock.ts"],"sourcesContent":["import type { GeneratedTypes, Payload , RequestContext } from '../../../index.js'\nimport type { PayloadRequestWithData } from '../../../types/index.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { unlockOperation } from '../unlock.js'\n\nexport type Options<T extends keyof GeneratedTypes['collections']> = {\n collection: T\n context?: RequestContext\n data: {\n email\n }\n overrideAccess: boolean\n req?: PayloadRequestWithData\n}\n\nasync function localUnlock<T extends keyof GeneratedTypes['collections']>(\n payload: Payload,\n options: Options<T>,\n): Promise<boolean> {\n const { collection: collectionSlug, data, overrideAccess = true } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} can't be found. Unlock Operation.`,\n )\n }\n\n return unlockOperation({\n collection,\n data,\n overrideAccess,\n req: await createLocalReq(options, payload),\n })\n}\n\nexport default localUnlock\n"],"names":["APIError","createLocalReq","unlockOperation","localUnlock","payload","options","collection","collectionSlug","data","overrideAccess","collections","String","req"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,eAAe,QAAQ,eAAc;AAY9C,eAAeC,YACbC,OAAgB,EAChBC,OAAmB;IAEnB,MAAM,EAAEC,YAAYC,cAAc,EAAEC,IAAI,EAAEC,iBAAiB,IAAI,EAAE,GAAGJ;IAEpE,MAAMC,aAAaF,QAAQM,WAAW,CAACH,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEW,OAAOJ,gBAAgB,kCAAkC,CAAC;IAE1F;IAEA,OAAOL,gBAAgB;QACrBI;QACAE;QACAC;QACAG,KAAK,MAAMX,eAAeI,SAASD;IACrC;AACF;AAEA,eAAeD,YAAW"}
@@ -1,5 +1,4 @@
1
- import type { Payload, RequestContext } from '../../../index.js';
2
- import type { GeneratedTypes } from '../../../index.js';
1
+ import type { GeneratedTypes, Payload, RequestContext } from '../../../index.js';
3
2
  import type { PayloadRequestWithData } from '../../../types/index.js';
4
3
  export type Options<T extends keyof GeneratedTypes['collections']> = {
5
4
  collection: T;
@@ -1 +1 @@
1
- {"version":3,"file":"verifyEmail.d.ts","sourceRoot":"","sources":["../../../../src/auth/operations/local/verifyEmail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAMrE,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,IAAI;IACnE,UAAU,EAAE,CAAC,CAAA;IACb,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,GAAG,CAAC,EAAE,sBAAsB,CAAA;IAC5B,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,iBAAe,gBAAgB,CAAC,CAAC,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,EAC3E,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAClB,OAAO,CAAC,OAAO,CAAC,CAgBlB;AAED,eAAe,gBAAgB,CAAA"}
1
+ {"version":3,"file":"verifyEmail.d.ts","sourceRoot":"","sources":["../../../../src/auth/operations/local/verifyEmail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAG,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACjF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAMrE,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,IAAI;IACnE,UAAU,EAAE,CAAC,CAAA;IACb,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,GAAG,CAAC,EAAE,sBAAsB,CAAA;IAC5B,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,iBAAe,gBAAgB,CAAC,CAAC,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,EAC3E,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAClB,OAAO,CAAC,OAAO,CAAC,CAgBlB;AAED,eAAe,gBAAgB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/auth/operations/local/verifyEmail.ts"],"sourcesContent":["import type { Payload, RequestContext } from '../../../index.js'\nimport type { GeneratedTypes } from '../../../index.js'\nimport type { PayloadRequestWithData } from '../../../types/index.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { verifyEmailOperation } from '../verifyEmail.js'\n\nexport type Options<T extends keyof GeneratedTypes['collections']> = {\n collection: T\n context?: RequestContext\n req?: PayloadRequestWithData\n token: string\n}\n\nasync function localVerifyEmail<T extends keyof GeneratedTypes['collections']>(\n payload: Payload,\n options: Options<T>,\n): Promise<boolean> {\n const { collection: collectionSlug, token } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} can't be found. Verify Email Operation.`,\n )\n }\n\n return verifyEmailOperation({\n collection,\n req: await createLocalReq(options, payload),\n token,\n })\n}\n\nexport default localVerifyEmail\n"],"names":["APIError","createLocalReq","verifyEmailOperation","localVerifyEmail","payload","options","collection","collectionSlug","token","collections","String","req"],"rangeMappings":";;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,oBAAoB,QAAQ,oBAAmB;AASxD,eAAeC,iBACbC,OAAgB,EAChBC,OAAmB;IAEnB,MAAM,EAAEC,YAAYC,cAAc,EAAEC,KAAK,EAAE,GAAGH;IAE9C,MAAMC,aAAaF,QAAQK,WAAW,CAACF,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEU,OAAOH,gBAAgB,wCAAwC,CAAC;IAEhG;IAEA,OAAOL,qBAAqB;QAC1BI;QACAK,KAAK,MAAMV,eAAeI,SAASD;QACnCI;IACF;AACF;AAEA,eAAeL,iBAAgB"}
1
+ {"version":3,"sources":["../../../../src/auth/operations/local/verifyEmail.ts"],"sourcesContent":["import type { GeneratedTypes, Payload , RequestContext } from '../../../index.js'\nimport type { PayloadRequestWithData } from '../../../types/index.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { verifyEmailOperation } from '../verifyEmail.js'\n\nexport type Options<T extends keyof GeneratedTypes['collections']> = {\n collection: T\n context?: RequestContext\n req?: PayloadRequestWithData\n token: string\n}\n\nasync function localVerifyEmail<T extends keyof GeneratedTypes['collections']>(\n payload: Payload,\n options: Options<T>,\n): Promise<boolean> {\n const { collection: collectionSlug, token } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} can't be found. Verify Email Operation.`,\n )\n }\n\n return verifyEmailOperation({\n collection,\n req: await createLocalReq(options, payload),\n token,\n })\n}\n\nexport default localVerifyEmail\n"],"names":["APIError","createLocalReq","verifyEmailOperation","localVerifyEmail","payload","options","collection","collectionSlug","token","collections","String","req"],"rangeMappings":";;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,oBAAoB,QAAQ,oBAAmB;AASxD,eAAeC,iBACbC,OAAgB,EAChBC,OAAmB;IAEnB,MAAM,EAAEC,YAAYC,cAAc,EAAEC,KAAK,EAAE,GAAGH;IAE9C,MAAMC,aAAaF,QAAQK,WAAW,CAACF,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEU,OAAOH,gBAAgB,wCAAwC,CAAC;IAEhG;IAEA,OAAOL,qBAAqB;QAC1BI;QACAK,KAAK,MAAMV,eAAeI,SAASD;QACnCI;IACF;AACF;AAEA,eAAeL,iBAAgB"}
@@ -1,6 +1,5 @@
1
1
  import type { Collection } from '../../collections/config/types.js';
2
- import type { PayloadRequestWithData } from '../../types/index.js';
3
- import type { Document } from '../../types/index.js';
2
+ import type { Document, PayloadRequestWithData } from '../../types/index.js';
4
3
  export type Result = {
5
4
  exp: number;
6
5
  refreshedToken: string;
@@ -1 +1 @@
1
- {"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/refresh.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAuB,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACxF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AASpD,MAAM,MAAM,MAAM,GAAG;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,cAAc,EAAE,MAAM,CAAA;IACtB,IAAI,EAAE,QAAQ,CAAA;CACf,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,GAAG,EAAE,sBAAsB,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,gBAAgB,iBAAwB,SAAS,KAAG,QAAQ,MAAM,CA2G9E,CAAA"}
1
+ {"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/refresh.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAuB,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACxF,OAAO,KAAK,EAAE,QAAQ,EAAG,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAS7E,MAAM,MAAM,MAAM,GAAG;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,cAAc,EAAE,MAAM,CAAA;IACtB,IAAI,EAAE,QAAQ,CAAA;CACf,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,GAAG,EAAE,sBAAsB,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,gBAAgB,iBAAwB,SAAS,KAAG,QAAQ,MAAM,CA2G9E,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/auth/operations/refresh.ts"],"sourcesContent":["import jwt from 'jsonwebtoken'\nimport url from 'url'\n\nimport type { BeforeOperationHook, Collection } from '../../collections/config/types.js'\nimport type { PayloadRequestWithData } from '../../types/index.js'\nimport type { Document } from '../../types/index.js'\n\nimport { buildAfterOperation } from '../../collections/operations/utils.js'\nimport { Forbidden } from '../../errors/index.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { getFieldsToSign } from '../getFieldsToSign.js'\n\nexport type Result = {\n exp: number\n refreshedToken: string\n user: Document\n}\n\nexport type Arguments = {\n collection: Collection\n req: PayloadRequestWithData\n token: string\n}\n\nexport const refreshOperation = async (incomingArgs: Arguments): Promise<Result> => {\n let args = incomingArgs\n\n try {\n const shouldCommit = await initTransaction(args.req)\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n await args.collection.config.hooks.beforeOperation.reduce(\n async (priorHook: BeforeOperationHook | Promise<void>, hook: BeforeOperationHook) => {\n await priorHook\n\n args =\n (await hook({\n args,\n collection: args.collection?.config,\n context: args.req.context,\n operation: 'refresh',\n req: args.req,\n })) || args\n },\n Promise.resolve(),\n )\n\n // /////////////////////////////////////\n // Refresh\n // /////////////////////////////////////\n\n const {\n collection: { config: collectionConfig },\n req,\n req: {\n payload: { config, secret },\n },\n } = args\n\n if (typeof args.token !== 'string' || !args.req.user) throw new Forbidden(args.req.t)\n\n const parsedURL = url.parse(args.req.url)\n const isGraphQL = parsedURL.pathname === config.routes.graphQL\n\n const user = await args.req.payload.findByID({\n id: args.req.user.id,\n collection: args.req.user.collection,\n depth: isGraphQL ? 0 : args.collection.config.auth.depth,\n req: args.req,\n })\n\n const fieldsToSign = getFieldsToSign({\n collectionConfig,\n email: user?.email as string,\n user: args?.req?.user,\n })\n\n const refreshedToken = jwt.sign(fieldsToSign, secret, {\n expiresIn: collectionConfig.auth.tokenExpiration,\n })\n\n const exp = (jwt.decode(refreshedToken) as Record<string, unknown>).exp as number\n\n let result: Result = {\n exp,\n refreshedToken,\n user,\n }\n\n // /////////////////////////////////////\n // After Refresh - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterRefresh.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n collection: args.collection?.config,\n context: args.req.context,\n exp,\n req: args.req,\n token: refreshedToken,\n })) || result\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: args.collection?.config,\n operation: 'refresh',\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n if (shouldCommit) await commitTransaction(req)\n\n return result\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["jwt","url","buildAfterOperation","Forbidden","commitTransaction","initTransaction","killTransaction","getFieldsToSign","refreshOperation","incomingArgs","args","shouldCommit","req","collection","config","hooks","beforeOperation","reduce","priorHook","hook","context","operation","Promise","resolve","collectionConfig","payload","secret","token","user","t","parsedURL","parse","isGraphQL","pathname","routes","graphQL","findByID","id","depth","auth","fieldsToSign","email","refreshedToken","sign","expiresIn","tokenExpiration","exp","decode","result","afterRefresh","error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,SAAS,eAAc;AAC9B,OAAOC,SAAS,MAAK;AAMrB,SAASC,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,SAAS,QAAQ,wBAAuB;AACjD,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,wBAAuB;AAcvD,OAAO,MAAMC,mBAAmB,OAAOC;IACrC,IAAIC,OAAOD;IAEX,IAAI;QACF,MAAME,eAAe,MAAMN,gBAAgBK,KAAKE,GAAG;QAEnD,wCAAwC;QACxC,+BAA+B;QAC/B,wCAAwC;QAExC,MAAMF,KAAKG,UAAU,CAACC,MAAM,CAACC,KAAK,CAACC,eAAe,C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C,MAAM,CAACL,gBAA4CI,GAAG;QAEvE,IAAIE,SAAiB;YACnBF;YACAJ;YACAd;QACF;QAEA,wCAAwC;QACxC,6BAA6B;QAC7B,wCAAwC;QAExC,MAAMJ,iBAAiBT,KAAK,CAACkC,YAAY,CAAChC,MAAM,CAAC,OAAOC,WAAWC;YACjE,MAAMD;YAEN8B,SACE,AAAC,MAAM7B,KAAK;gBACVN,YAAYH,KAAKG,UAAU,EAAEC;gBAC7BM,SAASV,KAAKE,GAAG,CAACQ,OAAO;gBACzB0B;gBACAlC,KAAKF,KAAKE,GAAG;gBACbe,OAAOe;YACT,MAAOM;QACX,GAAG1B,QAAQC,OAAO;QAElB,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExCyB,SAAS,MAAM9C,oBAAoB;YACjCQ;YACAG,YAAYH,KAAKG,UAAU,EAAEC;YAC7BO,WAAW;YACX2B;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,IAAIrC,cAAc,MAAMP,kBAAkBQ;QAE1C,OAAOoC;IACT,EAAE,OAAOE,OAAgB;QACvB,MAAM5C,gBAAgBI,KAAKE,GAAG;QAC9B,MAAMsC;IACR;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/auth/operations/refresh.ts"],"sourcesContent":["import jwt from 'jsonwebtoken'\nimport url from 'url'\n\nimport type { BeforeOperationHook, Collection } from '../../collections/config/types.js'\nimport type { Document , PayloadRequestWithData } from '../../types/index.js'\n\nimport { buildAfterOperation } from '../../collections/operations/utils.js'\nimport { Forbidden } from '../../errors/index.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { getFieldsToSign } from '../getFieldsToSign.js'\n\nexport type Result = {\n exp: number\n refreshedToken: string\n user: Document\n}\n\nexport type Arguments = {\n collection: Collection\n req: PayloadRequestWithData\n token: string\n}\n\nexport const refreshOperation = async (incomingArgs: Arguments): Promise<Result> => {\n let args = incomingArgs\n\n try {\n const shouldCommit = await initTransaction(args.req)\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n await args.collection.config.hooks.beforeOperation.reduce(\n async (priorHook: BeforeOperationHook | Promise<void>, hook: BeforeOperationHook) => {\n await priorHook\n\n args =\n (await hook({\n args,\n collection: args.collection?.config,\n context: args.req.context,\n operation: 'refresh',\n req: args.req,\n })) || args\n },\n Promise.resolve(),\n )\n\n // /////////////////////////////////////\n // Refresh\n // /////////////////////////////////////\n\n const {\n collection: { config: collectionConfig },\n req,\n req: {\n payload: { config, secret },\n },\n } = args\n\n if (typeof args.token !== 'string' || !args.req.user) throw new Forbidden(args.req.t)\n\n const parsedURL = url.parse(args.req.url)\n const isGraphQL = parsedURL.pathname === config.routes.graphQL\n\n const user = await args.req.payload.findByID({\n id: args.req.user.id,\n collection: args.req.user.collection,\n depth: isGraphQL ? 0 : args.collection.config.auth.depth,\n req: args.req,\n })\n\n const fieldsToSign = getFieldsToSign({\n collectionConfig,\n email: user?.email as string,\n user: args?.req?.user,\n })\n\n const refreshedToken = jwt.sign(fieldsToSign, secret, {\n expiresIn: collectionConfig.auth.tokenExpiration,\n })\n\n const exp = (jwt.decode(refreshedToken) as Record<string, unknown>).exp as number\n\n let result: Result = {\n exp,\n refreshedToken,\n user,\n }\n\n // /////////////////////////////////////\n // After Refresh - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterRefresh.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n collection: args.collection?.config,\n context: args.req.context,\n exp,\n req: args.req,\n token: refreshedToken,\n })) || result\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: args.collection?.config,\n operation: 'refresh',\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n if (shouldCommit) await commitTransaction(req)\n\n return result\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["jwt","url","buildAfterOperation","Forbidden","commitTransaction","initTransaction","killTransaction","getFieldsToSign","refreshOperation","incomingArgs","args","shouldCommit","req","collection","config","hooks","beforeOperation","reduce","priorHook","hook","context","operation","Promise","resolve","collectionConfig","payload","secret","token","user","t","parsedURL","parse","isGraphQL","pathname","routes","graphQL","findByID","id","depth","auth","fieldsToSign","email","refreshedToken","sign","expiresIn","tokenExpiration","exp","decode","result","afterRefresh","error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,SAAS,eAAc;AAC9B,OAAOC,SAAS,MAAK;AAKrB,SAASC,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,SAAS,QAAQ,wBAAuB;AACjD,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,wBAAuB;AAcvD,OAAO,MAAMC,mBAAmB,OAAOC;IACrC,IAAIC,OAAOD;IAEX,IAAI;QACF,MAAME,eAAe,MAAMN,gBAAgBK,KAAKE,GAAG;QAEnD,wCAAwC;QACxC,+BAA+B;QAC/B,wCAAwC;QAExC,MAAMF,KAAKG,UAAU,CAACC,MAAM,CAACC,KAAK,CAACC,eAAe,CAACC,MAAM,CACvD,OAAOC,WAAgDC;YACrD,MAAMD;YAENR,OACE,AAAC,MAAMS,KAAK;gBACVT;gBACAG,YAAYH,KAAKG,UAAU,EAAEC;gBAC7BM,SAASV,KAAKE,GAAG,CAACQ,OAAO;gBACzBC,WAAW;gBACXT,KAAKF,KAAKE,GAAG;YACf,MAAOF;QACX,GACAY,QAAQC,OAAO;QAGjB,wCAAwC;QACxC,UAAU;QACV,wCAAwC;QAExC,MAAM,EACJV,YAAY,EAAEC,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AACQ,OAAO;gBACzB0B;gBACAlC,KAAKF,KAAKE,GAAG;gBACbe,OAAOe;YACT,MAAOM;QACX,GAAG1B,QAAQC,OAAO;QAElB,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExCyB,SAAS,MAAM9C,oBAAoB;YACjCQ;YACAG,YAAYH,KAAKG,UAAU,EAAEC;YAC7BO,WAAW;YACX2B;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,IAAIrC,cAAc,MAAMP,kBAAkBQ;QAE1C,OAAOoC;IACT,EAAE,OAAOE,OAAgB;QACvB,MAAM5C,gBAAgBI,KAAKE,GAAG;QAC9B,MAAMsC;IACR;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sendVerificationEmail.d.ts","sourceRoot":"","sources":["../../src/auth/sendVerificationEmail.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,KAAK,EAAE,IAAI,EAAgB,MAAM,YAAY,CAAA;AAEpD,KAAK,IAAI,GAAG;IACV,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,EAAE,eAAe,CAAA;IACvB,YAAY,EAAE,OAAO,CAAA;IACrB,KAAK,EAAE,uBAAuB,CAAA;IAC9B,GAAG,EAAE,sBAAsB,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAwDrE"}
1
+ {"version":3,"file":"sendVerificationEmail.d.ts","sourceRoot":"","sources":["../../src/auth/sendVerificationEmail.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,KAAK,EAAE,IAAI,EAAgB,MAAM,YAAY,CAAA;AAEpD,KAAK,IAAI,GAAG;IACV,UAAU,EAAE,UAAU,CAAA;IACtB,MAAM,EAAE,eAAe,CAAA;IACvB,YAAY,EAAE,OAAO,CAAA;IACrB,KAAK,EAAE,uBAAuB,CAAA;IAC9B,GAAG,EAAE,sBAAsB,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,IAAI,CAAA;CACX,CAAA;AAED,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAuDrE"}
@@ -29,8 +29,7 @@ export async function sendVerificationEmail(args) {
29
29
  user
30
30
  });
31
31
  }
32
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
33
- email.sendEmail({
32
+ await email.sendEmail({
34
33
  from: `"${email.defaultFromName}" <${email.defaultFromAddress}>`,
35
34
  html,
36
35
  subject,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/auth/sendVerificationEmail.ts"],"sourcesContent":["import { URL } from 'url'\n\nimport type { Collection } from '../collections/config/types.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { InitializedEmailAdapter } from '../email/types.js'\nimport type { PayloadRequestWithData } from '../types/index.js'\nimport type { User, VerifyConfig } from './types.js'\n\ntype Args = {\n collection: Collection\n config: SanitizedConfig\n disableEmail: boolean\n email: InitializedEmailAdapter\n req: PayloadRequestWithData\n token: string\n user: User\n}\n\nexport async function sendVerificationEmail(args: Args): Promise<void> {\n // Verify token from e-mail\n const {\n collection: { config: collectionConfig },\n config,\n disableEmail,\n email,\n req,\n token,\n user,\n } = args\n\n if (!disableEmail) {\n const protocol = new URL(req.url).protocol // includes the final :\n const serverURL =\n config.serverURL !== null && config.serverURL !== ''\n ? config.serverURL\n : `${protocol}//${req.headers.get('host')}`\n\n const verificationURL = `${serverURL}${config.routes.admin}/${collectionConfig.slug}/verify/${token}`\n\n let html = `${req.t('authentication:newAccountCreated', {\n serverURL: config.serverURL,\n verificationURL,\n })}`\n\n const verify = collectionConfig.auth.verify as VerifyConfig\n\n // Allow config to override email content\n if (typeof verify.generateEmailHTML === 'function') {\n html = await verify.generateEmailHTML({\n req,\n token,\n user,\n })\n }\n\n let subject = req.t('authentication:verifyYourEmail')\n\n // Allow config to override email subject\n if (typeof verify.generateEmailSubject === 'function') {\n subject = await verify.generateEmailSubject({\n req,\n token,\n user,\n })\n }\n\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n email.sendEmail({\n from: `\"${email.defaultFromName}\" <${email.defaultFromAddress}>`,\n html,\n subject,\n to: user.email,\n })\n }\n}\n"],"names":["URL","sendVerificationEmail","args","collection","config","collectionConfig","disableEmail","email","req","token","user","protocol","url","serverURL","headers","get","verificationURL","routes","admin","slug","html","t","verify","auth","generateEmailHTML","subject","generateEmailSubject","sendEmail","from","defaultFromName","defaultFromAddress","to"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,GAAG,QAAQ,MAAK;AAkBzB,OAAO,eAAeC,sBAAsBC,IAAU;IACpD,2BAA2B;IAC3B,MAAM,EACJC,YAAY,EAAEC,QAAQC,gBAAgB,EAAE,EACxCD,MAAM,EACNE,YAAY,EACZC,KAAK,EACLC,GAAG,EACHC,KAAK,EACLC,IAAI,EACL,GAAGR;IAEJ,IAAI,CAACI,cAAc;QACjB,MAAMK,WAAW,IAAIX,IAAIQ,IAAII,GAAG,EAAED,QAAQ,CAAC,uBAAuB;;QAClE,MAAME,YACJT,OAAOS,SAAS,KAAK,QAAQT,OAAOS,SAAS,KAAK,KAC9CT,OAAOS,SAAS,GAChB,CAAC,EAAEF,SAAS,EAAE,EAAEH,IAAIM,OAAO,CAACC,GAAG,CAAC,QAAQ,CAAC;QAE/C,MAAMC,kBAAkB,CAAC,EAAEH,UAAU,EAAET,OAAOa,MAAM,CAACC,KAAK,CAAC,CAAC,EAAEb,iBAAiBc,IAAI,CAAC,QAAQ,EAAEV,MAAM,CAAC;QAErG,IAAIW,OAAO,CAAC,EAAEZ,IAAIa,CAAC,CAAC,oCAAoC;YACtDR,WAAWT,OAAOS,SAAS;YAC3BG;QACF,GAAG,CAAC;QAEJ,MAAMM,SAASjB,iBAAiBkB,IAAI,CAACD,MAAM;QAE3C,yCAAyC;QACzC,IAAI,OAAOA,OAAOE,iBAAiB,KAAK,YAAY;YAClDJ,OAAO,MAAME,OAAOE,iBAAiB,CAAC;gBACpChB;gBACAC;gBACAC;YACF;QACF;QAEA,IAAIe,UAAUjB,IAAIa,CAAC,CAAC;QAEpB,yCAAyC;QACzC,IAAI,OAAOC,OAAOI,oBAAoB,KAAK,YAAY;YACrDD,UAAU,MAAMH,OAAOI,oBAAoB,CAAC;gBAC1ClB;gBACAC;gBACAC;YACF;QACF;QAEA,mEAAmE;QACnEH,MAAMoB,SAAS,CAAC;YACdC,MAAM,CAAC,CAAC,EAAErB,MAAMsB,eAAe,CAAC,GAAG,EAAEtB,MAAMuB,kBAAkB,CAAC,CAAC,CAAC;YAChEV;YACAK;YACAM,IAAIrB,KAAKH,KAAK;QAChB;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/auth/sendVerificationEmail.ts"],"sourcesContent":["import { URL } from 'url'\n\nimport type { Collection } from '../collections/config/types.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { InitializedEmailAdapter } from '../email/types.js'\nimport type { PayloadRequestWithData } from '../types/index.js'\nimport type { User, VerifyConfig } from './types.js'\n\ntype Args = {\n collection: Collection\n config: SanitizedConfig\n disableEmail: boolean\n email: InitializedEmailAdapter\n req: PayloadRequestWithData\n token: string\n user: User\n}\n\nexport async function sendVerificationEmail(args: Args): Promise<void> {\n // Verify token from e-mail\n const {\n collection: { config: collectionConfig },\n config,\n disableEmail,\n email,\n req,\n token,\n user,\n } = args\n\n if (!disableEmail) {\n const protocol = new URL(req.url).protocol // includes the final :\n const serverURL =\n config.serverURL !== null && config.serverURL !== ''\n ? config.serverURL\n : `${protocol}//${req.headers.get('host')}`\n\n const verificationURL = `${serverURL}${config.routes.admin}/${collectionConfig.slug}/verify/${token}`\n\n let html = `${req.t('authentication:newAccountCreated', {\n serverURL: config.serverURL,\n verificationURL,\n })}`\n\n const verify = collectionConfig.auth.verify as VerifyConfig\n\n // Allow config to override email content\n if (typeof verify.generateEmailHTML === 'function') {\n html = await verify.generateEmailHTML({\n req,\n token,\n user,\n })\n }\n\n let subject = req.t('authentication:verifyYourEmail')\n\n // Allow config to override email subject\n if (typeof verify.generateEmailSubject === 'function') {\n subject = await verify.generateEmailSubject({\n req,\n token,\n user,\n })\n }\n\n await email.sendEmail({\n from: `\"${email.defaultFromName}\" <${email.defaultFromAddress}>`,\n html,\n subject,\n to: user.email,\n })\n }\n}\n"],"names":["URL","sendVerificationEmail","args","collection","config","collectionConfig","disableEmail","email","req","token","user","protocol","url","serverURL","headers","get","verificationURL","routes","admin","slug","html","t","verify","auth","generateEmailHTML","subject","generateEmailSubject","sendEmail","from","defaultFromName","defaultFromAddress","to"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAASA,GAAG,QAAQ,MAAK;AAkBzB,OAAO,eAAeC,sBAAsBC,IAAU;IACpD,2BAA2B;IAC3B,MAAM,EACJC,YAAY,EAAEC,QAAQC,gBAAgB,EAAE,EACxCD,MAAM,EACNE,YAAY,EACZC,KAAK,EACLC,GAAG,EACHC,KAAK,EACLC,IAAI,EACL,GAAGR;IAEJ,IAAI,CAACI,cAAc;QACjB,MAAMK,W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AAE,eAAe,EACvB,OAAO,CAAC,EAAE;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,GACzB,OAAO,CAAC,IAAI,CAAC,CAkCf"}
1
+ {"version":3,"file":"generateTypes.d.ts","sourceRoot":"","sources":["../../src/bin/generateTypes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAKzD,wBAAsB,aAAa,CACjC,MAAM,EAAE,eAAe,EACvB,OAAO,CAAC,EAAE;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,GACzB,OAAO,CAAC,IAAI,CAAC,CA8Cf"}