payload 3.2.2 → 3.2.3-canary.3e78927

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 (131) hide show
  1. package/dist/admin/elements/DatePicker.d.ts +2 -2
  2. package/dist/admin/elements/DatePicker.d.ts.map +1 -1
  3. package/dist/admin/elements/DatePicker.js.map +1 -1
  4. package/dist/admin/types.js +3 -3
  5. package/dist/admin/types.js.map +1 -1
  6. package/dist/auth/cookies.js.map +1 -1
  7. package/dist/auth/crypto.js.map +1 -1
  8. package/dist/auth/extractJWT.js.map +1 -1
  9. package/dist/auth/operations/forgotPassword.js.map +1 -1
  10. package/dist/auth/operations/login.d.ts.map +1 -1
  11. package/dist/auth/operations/login.js +0 -12
  12. package/dist/auth/operations/login.js.map +1 -1
  13. package/dist/auth/operations/me.js.map +1 -1
  14. package/dist/auth/sendVerificationEmail.js.map +1 -1
  15. package/dist/auth/strategies/apiKey.js.map +1 -1
  16. package/dist/bin/generateImportMap/index.js.map +1 -1
  17. package/dist/bin/generateImportMap/parsePayloadComponent.js +1 -0
  18. package/dist/bin/generateImportMap/parsePayloadComponent.js.map +1 -1
  19. package/dist/bin/generateTypes.js.map +1 -1
  20. package/dist/bin/index.js.map +1 -1
  21. package/dist/bin/info.js.map +1 -1
  22. package/dist/bin/migrate.js.map +1 -1
  23. package/dist/collections/operations/findVersionByID.js +2 -0
  24. package/dist/collections/operations/findVersionByID.js.map +1 -1
  25. package/dist/collections/operations/findVersions.js +1 -0
  26. package/dist/collections/operations/findVersions.js.map +1 -1
  27. package/dist/config/client.js +2 -0
  28. package/dist/config/client.js.map +1 -1
  29. package/dist/config/defaults.js.map +1 -1
  30. package/dist/config/find.js.map +1 -1
  31. package/dist/config/sanitize.js.map +1 -1
  32. package/dist/database/getLocalizedPaths.js.map +1 -1
  33. package/dist/database/migrations/createMigration.js.map +1 -1
  34. package/dist/database/migrations/getPredefinedMigration.js.map +1 -1
  35. package/dist/database/migrations/migrate.js.map +1 -1
  36. package/dist/database/migrations/migrateDown.js.map +1 -1
  37. package/dist/database/migrations/migrateRefresh.js.map +1 -1
  38. package/dist/database/migrations/migrateReset.js.map +1 -1
  39. package/dist/database/migrations/readMigrationFiles.js.map +1 -1
  40. package/dist/database/migrations/writeMigrationIndex.js.map +1 -1
  41. package/dist/database/queryValidation/validateSearchParams.js.map +1 -1
  42. package/dist/email/sendEmail.js.map +1 -1
  43. package/dist/errors/AuthenticationError.js.map +1 -1
  44. package/dist/errors/FileRetrievalError.js.map +1 -1
  45. package/dist/errors/QueryError.js.map +1 -1
  46. package/dist/errors/ValidationError.js.map +1 -1
  47. package/dist/fields/config/client.js +1 -0
  48. package/dist/fields/config/client.js.map +1 -1
  49. package/dist/fields/config/sanitize.js +1 -1
  50. package/dist/fields/config/sanitize.js.map +1 -1
  51. package/dist/fields/config/sanitizeJoinField.js.map +1 -1
  52. package/dist/fields/config/types.d.ts +14 -0
  53. package/dist/fields/config/types.d.ts.map +1 -1
  54. package/dist/fields/config/types.js.map +1 -1
  55. package/dist/fields/getFieldPaths.js.map +1 -1
  56. package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js +1 -0
  57. package/dist/fields/hooks/afterRead/relationshipPopulationPromise.js.map +1 -1
  58. package/dist/fields/hooks/beforeDuplicate/promise.js +1 -0
  59. package/dist/fields/hooks/beforeDuplicate/promise.js.map +1 -1
  60. package/dist/fields/hooks/beforeValidate/promise.js +1 -0
  61. package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
  62. package/dist/fields/mergeBaseFields.js +1 -0
  63. package/dist/fields/mergeBaseFields.js.map +1 -1
  64. package/dist/fields/setDefaultBeforeDuplicate.js.map +1 -1
  65. package/dist/fields/validations.d.ts +6 -2
  66. package/dist/fields/validations.d.ts.map +1 -1
  67. package/dist/fields/validations.js +5 -1
  68. package/dist/fields/validations.js.map +1 -1
  69. package/dist/globals/config/sanitize.js +1 -0
  70. package/dist/globals/config/sanitize.js.map +1 -1
  71. package/dist/globals/operations/findVersions.js +2 -0
  72. package/dist/globals/operations/findVersions.js.map +1 -1
  73. package/dist/index.d.ts +3 -1
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +2 -0
  76. package/dist/index.js.map +1 -1
  77. package/dist/preferences/deleteUserPreferences.js.map +1 -1
  78. package/dist/queues/config/generateJobsJSONSchemas.js.map +1 -1
  79. package/dist/queues/config/types/taskTypes.d.ts +23 -4
  80. package/dist/queues/config/types/taskTypes.d.ts.map +1 -1
  81. package/dist/queues/config/types/taskTypes.js.map +1 -1
  82. package/dist/queues/config/types/workflowJSONTypes.d.ts +5 -0
  83. package/dist/queues/config/types/workflowJSONTypes.d.ts.map +1 -1
  84. package/dist/queues/config/types/workflowJSONTypes.js.map +1 -1
  85. package/dist/queues/config/types/workflowTypes.d.ts +13 -5
  86. package/dist/queues/config/types/workflowTypes.d.ts.map +1 -1
  87. package/dist/queues/config/types/workflowTypes.js.map +1 -1
  88. package/dist/queues/operations/runJobs/index.d.ts.map +1 -1
  89. package/dist/queues/operations/runJobs/index.js +2 -1
  90. package/dist/queues/operations/runJobs/index.js.map +1 -1
  91. package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.d.ts.map +1 -1
  92. package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js +18 -5
  93. package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js.map +1 -1
  94. package/dist/queues/operations/runJobs/runJob/handleWorkflowError.d.ts.map +1 -1
  95. package/dist/queues/operations/runJobs/runJob/handleWorkflowError.js +16 -16
  96. package/dist/queues/operations/runJobs/runJob/handleWorkflowError.js.map +1 -1
  97. package/dist/queues/operations/runJobs/runJob/importHandlerPath.d.ts.map +1 -1
  98. package/dist/queues/operations/runJobs/runJob/importHandlerPath.js +8 -1
  99. package/dist/queues/operations/runJobs/runJob/importHandlerPath.js.map +1 -1
  100. package/dist/queues/operations/runJobs/runJob/index.d.ts.map +1 -1
  101. package/dist/queues/operations/runJobs/runJob/index.js +6 -1
  102. package/dist/queues/operations/runJobs/runJob/index.js.map +1 -1
  103. package/dist/queues/utilities/getJobTaskStatus.d.ts.map +1 -1
  104. package/dist/queues/utilities/getJobTaskStatus.js +5 -0
  105. package/dist/queues/utilities/getJobTaskStatus.js.map +1 -1
  106. package/dist/uploads/deleteAssociatedFiles.js.map +1 -1
  107. package/dist/uploads/formatFilesize.js.map +1 -1
  108. package/dist/uploads/generateFileData.js.map +1 -1
  109. package/dist/uploads/getBaseFields.js.map +1 -1
  110. package/dist/uploads/getExternalFile.js.map +1 -1
  111. package/dist/uploads/getSafeFilename.js.map +1 -1
  112. package/dist/uploads/imageResizer.js.map +1 -1
  113. package/dist/utilities/addSelectGenericsToGeneretedTypes.js.map +1 -1
  114. package/dist/utilities/configToJSONSchema.js +1 -0
  115. package/dist/utilities/configToJSONSchema.js.map +1 -1
  116. package/dist/utilities/dependencies/dependencyChecker.js.map +1 -1
  117. package/dist/utilities/getDataByPath.js.map +1 -1
  118. package/dist/utilities/getSiblingData.js.map +1 -1
  119. package/dist/utilities/parseCookies.js.map +1 -1
  120. package/dist/utilities/sanitizePermissions.js +4 -0
  121. package/dist/utilities/sanitizePermissions.js.map +1 -1
  122. package/dist/utilities/telemetry/conf/envPaths.js.map +1 -1
  123. package/dist/utilities/telemetry/conf/index.js.map +1 -1
  124. package/dist/utilities/timestamp.js.map +1 -1
  125. package/dist/utilities/wordBoundariesRegex.js.map +1 -1
  126. package/dist/versions/drafts/appendVersionToQueryKey.js.map +1 -1
  127. package/dist/versions/drafts/getQueryDraftsSort.js.map +1 -1
  128. package/dist/versions/enforceMaxVersions.js.map +1 -1
  129. package/dist/versions/saveVersion.js +2 -0
  130. package/dist/versions/saveVersion.js.map +1 -1
  131. package/package.json +4 -4
@@ -1,7 +1,7 @@
1
- import type { ReactDatePickerProps } from 'react-datepicker';
1
+ import type { DatePickerProps } from 'react-datepicker';
2
2
  export type SharedProps = {
3
3
  displayFormat?: string;
4
- overrides?: ReactDatePickerProps;
4
+ overrides?: DatePickerProps;
5
5
  pickerAppearance?: 'dayAndTime' | 'dayOnly' | 'default' | 'monthOnly' | 'timeOnly';
6
6
  };
7
7
  export type TimePickerProps = {
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../src/admin/elements/DatePicker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAE5D,MAAM,MAAM,WAAW,GAAG;IACxB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,oBAAoB,CAAA;IAChC,gBAAgB,CAAC,EAAE,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,CAAA;CACnF,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,OAAO,CAAC,EAAE,IAAI,CAAA;CACf,CAAA;AAED,MAAM,MAAM,oBAAoB,GAC5B,CAAC;IACC,gBAAgB,EAAE,SAAS,CAAA;CAC5B,GAAG,cAAc,GAChB,WAAW,CAAC,GACd,CAAC;IACC,gBAAgB,EAAE,WAAW,CAAA;CAC9B,GAAG,gBAAgB,GAClB,WAAW,CAAC,GACd,CAAC;IACC,gBAAgB,EAAE,UAAU,CAAA;CAC7B,GAAG,WAAW,GACb,eAAe,CAAC,GAClB,CAAC;IACC,gBAAgB,CAAC,EAAE,YAA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,CAAC,EAAE,YAAY,CAAA;CAChC,GAAG,cAAc,GAChB,WAAW,GACX,eAAe,CAAC,GAClB,CAAC;IACC,gBAAgB,CAAC,EAAE,SAAS,CAAA;CAC7B,GAAG,WAAW,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/admin/elements/DatePicker.ts"],"sourcesContent":["import type { ReactDatePickerProps } from 'react-datepicker'\n\nexport type SharedProps = {\n displayFormat?: string\n overrides?: ReactDatePickerProps\n pickerAppearance?: 'dayAndTime' | 'dayOnly' | 'default' | 'monthOnly' | 'timeOnly'\n}\n\nexport type TimePickerProps = {\n maxTime?: Date\n minTime?: Date\n timeFormat?: string\n timeIntervals?: number\n}\n\nexport type DayPickerProps = {\n maxDate?: Date\n minDate?: Date\n monthsToShow?: 1 | 2\n}\n\nexport type MonthPickerProps = {\n maxDate?: Date\n minDate?: Date\n}\n\nexport type ConditionalDateProps =\n | ({\n pickerAppearance: 'dayOnly'\n } & DayPickerProps &\n SharedProps)\n | ({\n pickerAppearance: 'monthOnly'\n } & MonthPickerProps &\n SharedProps)\n | ({\n pickerAppearance: 'timeOnly'\n } & SharedProps &\n TimePickerProps)\n | ({\n pickerAppearance?: 'dayAndTime'\n } & DayPickerProps &\n SharedProps &\n TimePickerProps)\n | ({\n pickerAppearance?: 'default'\n } & SharedProps)\n"],"names":[],"mappings":"AA0BA,WAoBoB"}
1
+ {"version":3,"sources":["../../../src/admin/elements/DatePicker.ts"],"sourcesContent":["import type { DatePickerProps } from 'react-datepicker'\n\nexport type SharedProps = {\n displayFormat?: string\n overrides?: DatePickerProps\n pickerAppearance?: 'dayAndTime' | 'dayOnly' | 'default' | 'monthOnly' | 'timeOnly'\n}\n\nexport type TimePickerProps = {\n maxTime?: Date\n minTime?: Date\n timeFormat?: string\n timeIntervals?: number\n}\n\nexport type DayPickerProps = {\n maxDate?: Date\n minDate?: Date\n monthsToShow?: 1 | 2\n}\n\nexport type MonthPickerProps = {\n maxDate?: Date\n minDate?: Date\n}\n\nexport type ConditionalDateProps =\n | ({\n pickerAppearance: 'dayOnly'\n } & DayPickerProps &\n SharedProps)\n | ({\n pickerAppearance: 'monthOnly'\n } & MonthPickerProps &\n SharedProps)\n | ({\n pickerAppearance: 'timeOnly'\n } & SharedProps &\n TimePickerProps)\n | ({\n pickerAppearance?: 'dayAndTime'\n } & DayPickerProps &\n SharedProps &\n TimePickerProps)\n | ({\n pickerAppearance?: 'default'\n } & SharedProps)\n"],"names":[],"mappings":"AA0BA,WAoBoB"}
@@ -1,6 +1,6 @@
1
- export var Action;
2
- (function(Action) {
1
+ export var Action = /*#__PURE__*/ function(Action) {
3
2
  Action["RenderConfig"] = "render-config";
4
- })(Action || (Action = {}));
3
+ return Action;
4
+ }({});
5
5
 
6
6
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/admin/types.ts"],"sourcesContent":["import type { AcceptedLanguages, I18nClient } from '@payloadcms/translations'\nimport type React from 'react'\n\nimport type { ImportMap } from '../bin/generateImportMap/index.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type {\n Block,\n ClientBlock,\n ClientField,\n Field,\n FieldTypes,\n Tab,\n} from '../fields/config/types.js'\nimport type { JsonObject } from '../types/index.js'\nimport type { ClientTab } from './fields/Tabs.js'\nimport type {\n BuildFormStateArgs,\n Data,\n FieldState,\n FieldStateWithoutComponents,\n FilterOptionsResult,\n FormState,\n FormStateWithoutComponents,\n Row,\n} from './forms/Form.js'\n\nexport type { DefaultCellComponentProps, DefaultServerCellComponentProps } from './elements/Cell.js'\nexport type { ConditionalDateProps } from './elements/DatePicker.js'\nexport type { DayPickerProps, SharedProps, TimePickerProps } from './elements/DatePicker.js'\nexport type { NavGroupPreferences, NavPreferences } from './elements/Nav.js'\nexport type { CustomPreviewButton } from './elements/PreviewButton.js'\nexport type { CustomPublishButton } from './elements/PublishButton.js'\nexport type { CustomSaveButton } from './elements/SaveButton.js'\nexport type { CustomSaveDraftButton } from './elements/SaveDraftButton.js'\nexport type {\n DocumentTabComponent,\n DocumentTabCondition,\n DocumentTabConfig,\n DocumentTabProps,\n} from './elements/Tab.js'\n\nexport type { CustomUpload } from './elements/Upload.js'\n\nexport type {\n WithServerSidePropsComponent,\n WithServerSidePropsComponentProps,\n} from './elements/WithServerSideProps.js'\n\nexport type {\n ArrayFieldClientComponent,\n ArrayFieldClientProps,\n ArrayFieldDescriptionClientComponent,\n ArrayFieldDescriptionServerComponent,\n ArrayFieldErrorClientComponent,\n ArrayFieldErrorServerComponent,\n ArrayFieldLabelClientComponent,\n ArrayFieldLabelServerComponent,\n ArrayFieldServerComponent,\n ArrayFieldServerProps,\n} from './fields/Array.js'\n\nexport type {\n BlocksFieldClientComponent,\n BlocksFieldClientProps,\n BlocksFieldDescriptionClientComponent,\n BlocksFieldDescriptionServerComponent,\n BlocksFieldErrorClientComponent,\n BlocksFieldErrorServerComponent,\n BlocksFieldLabelClientComponent,\n BlocksFieldLabelServerComponent,\n BlocksFieldServerComponent,\n BlocksFieldServerProps,\n} from './fields/Blocks.js'\n\nexport type {\n CheckboxFieldClientComponent,\n CheckboxFieldClientProps,\n CheckboxFieldDescriptionClientComponent,\n CheckboxFieldDescriptionServerComponent,\n CheckboxFieldErrorClientComponent,\n CheckboxFieldErrorServerComponent,\n CheckboxFieldLabelClientComponent,\n CheckboxFieldLabelServerComponent,\n CheckboxFieldServerComponent,\n CheckboxFieldServerProps,\n} from './fields/Checkbox.js'\n\nexport type {\n CodeFieldClientComponent,\n CodeFieldClientProps,\n CodeFieldDescriptionClientComponent,\n CodeFieldDescriptionServerComponent,\n CodeFieldErrorClientComponent,\n CodeFieldErrorServerComponent,\n CodeFieldLabelClientComponent,\n CodeFieldLabelServerComponent,\n CodeFieldServerComponent,\n CodeFieldServerProps,\n} from './fields/Code.js'\n\nexport type {\n CollapsibleFieldClientComponent,\n CollapsibleFieldClientProps,\n CollapsibleFieldDescriptionClientComponent,\n CollapsibleFieldDescriptionServerComponent,\n CollapsibleFieldErrorClientComponent,\n CollapsibleFieldErrorServerComponent,\n CollapsibleFieldLabelClientComponent,\n CollapsibleFieldLabelServerComponent,\n CollapsibleFieldServerComponent,\n CollapsibleFieldServerProps,\n} from './fields/Collapsible.js'\n\nexport type {\n DateFieldClientComponent,\n DateFieldClientProps,\n DateFieldDescriptionClientComponent,\n DateFieldDescriptionServerComponent,\n DateFieldErrorClientComponent,\n DateFieldErrorServerComponent,\n DateFieldLabelClientComponent,\n DateFieldLabelServerComponent,\n DateFieldServerComponent,\n DateFieldServerProps,\n} from './fields/Date.js'\n\nexport type {\n EmailFieldClientComponent,\n EmailFieldClientProps,\n EmailFieldDescriptionClientComponent,\n EmailFieldDescriptionServerComponent,\n EmailFieldErrorClientComponent,\n EmailFieldErrorServerComponent,\n EmailFieldLabelClientComponent,\n EmailFieldLabelServerComponent,\n EmailFieldServerComponent,\n EmailFieldServerProps,\n} from './fields/Email.js'\n\nexport type {\n GroupFieldClientComponent,\n GroupFieldClientProps,\n GroupFieldDescriptionClientComponent,\n GroupFieldDescriptionServerComponent,\n GroupFieldErrorClientComponent,\n GroupFieldErrorServerComponent,\n GroupFieldLabelClientComponent,\n GroupFieldLabelServerComponent,\n GroupFieldServerComponent,\n GroupFieldServerProps,\n} from './fields/Group.js'\n\nexport type { HiddenFieldProps } from './fields/Hidden.js'\n\nexport type {\n JoinFieldClientComponent,\n JoinFieldClientProps,\n JoinFieldDescriptionClientComponent,\n JoinFieldDescriptionServerComponent,\n JoinFieldErrorClientComponent,\n JoinFieldErrorServerComponent,\n JoinFieldLabelClientComponent,\n JoinFieldLabelServerComponent,\n JoinFieldServerComponent,\n JoinFieldServerProps,\n} from './fields/Join.js'\n\nexport type {\n JSONFieldClientComponent,\n JSONFieldClientProps,\n JSONFieldDescriptionClientComponent,\n JSONFieldDescriptionServerComponent,\n JSONFieldErrorClientComponent,\n JSONFieldErrorServerComponent,\n JSONFieldLabelClientComponent,\n JSONFieldLabelServerComponent,\n JSONFieldServerComponent,\n JSONFieldServerProps,\n} from './fields/JSON.js'\n\nexport type {\n NumberFieldClientComponent,\n NumberFieldClientProps,\n NumberFieldDescriptionClientComponent,\n NumberFieldDescriptionServerComponent,\n NumberFieldErrorClientComponent,\n NumberFieldErrorServerComponent,\n NumberFieldLabelClientComponent,\n NumberFieldLabelServerComponent,\n NumberFieldServerComponent,\n NumberFieldServerProps,\n} from './fields/Number.js'\n\nexport type {\n PointFieldClientComponent,\n PointFieldClientProps,\n PointFieldDescriptionClientComponent,\n PointFieldDescriptionServerComponent,\n PointFieldErrorClientComponent,\n PointFieldErrorServerComponent,\n PointFieldLabelClientComponent,\n PointFieldLabelServerComponent,\n PointFieldServerComponent,\n PointFieldServerProps,\n} from './fields/Point.js'\n\nexport type {\n RadioFieldClientComponent,\n RadioFieldClientProps,\n RadioFieldDescriptionClientComponent,\n RadioFieldDescriptionServerComponent,\n RadioFieldErrorClientComponent,\n RadioFieldErrorServerComponent,\n RadioFieldLabelClientComponent,\n RadioFieldLabelServerComponent,\n RadioFieldServerComponent,\n RadioFieldServerProps,\n} from './fields/Radio.js'\n\nexport type {\n RelationshipFieldClientComponent,\n RelationshipFieldClientProps,\n RelationshipFieldDescriptionClientComponent,\n RelationshipFieldDescriptionServerComponent,\n RelationshipFieldErrorClientComponent,\n RelationshipFieldErrorServerComponent,\n RelationshipFieldLabelClientComponent,\n RelationshipFieldLabelServerComponent,\n RelationshipFieldServerComponent,\n RelationshipFieldServerProps,\n} from './fields/Relationship.js'\n\nexport type {\n RichTextFieldClientComponent,\n RichTextFieldClientProps,\n RichTextFieldDescriptionClientComponent,\n RichTextFieldDescriptionServerComponent,\n RichTextFieldErrorClientComponent,\n RichTextFieldErrorServerComponent,\n RichTextFieldLabelClientComponent,\n RichTextFieldLabelServerComponent,\n RichTextFieldServerComponent,\n RichTextFieldServerProps,\n} from './fields/RichText.js'\n\nexport type {\n RowFieldClientComponent,\n RowFieldClientProps,\n RowFieldDescriptionClientComponent,\n RowFieldDescriptionServerComponent,\n RowFieldErrorClientComponent,\n RowFieldErrorServerComponent,\n RowFieldLabelClientComponent,\n RowFieldLabelServerComponent,\n RowFieldServerComponent,\n RowFieldServerProps,\n} from './fields/Row.js'\n\nexport type {\n SelectFieldClientComponent,\n SelectFieldClientProps,\n SelectFieldDescriptionClientComponent,\n SelectFieldDescriptionServerComponent,\n SelectFieldErrorClientComponent,\n SelectFieldErrorServerComponent,\n SelectFieldLabelClientComponent,\n SelectFieldLabelServerComponent,\n SelectFieldServerComponent,\n SelectFieldServerProps,\n} from './fields/Select.js'\n\nexport type {\n ClientTab,\n TabsFieldClientComponent,\n TabsFieldClientProps,\n TabsFieldDescriptionClientComponent,\n TabsFieldDescriptionServerComponent,\n TabsFieldErrorClientComponent,\n TabsFieldErrorServerComponent,\n TabsFieldLabelClientComponent,\n TabsFieldLabelServerComponent,\n TabsFieldServerComponent,\n TabsFieldServerProps,\n} from './fields/Tabs.js'\n\nexport type {\n TextFieldClientComponent,\n TextFieldClientProps,\n TextFieldDescriptionClientComponent,\n TextFieldDescriptionServerComponent,\n TextFieldErrorClientComponent,\n TextFieldErrorServerComponent,\n TextFieldLabelClientComponent,\n TextFieldLabelServerComponent,\n TextFieldServerComponent,\n TextFieldServerProps,\n} from './fields/Text.js'\n\nexport type {\n TextareaFieldClientComponent,\n TextareaFieldClientProps,\n TextareaFieldDescriptionClientComponent,\n TextareaFieldDescriptionServerComponent,\n TextareaFieldErrorClientComponent,\n TextareaFieldErrorServerComponent,\n TextareaFieldLabelClientComponent,\n TextareaFieldLabelServerComponent,\n TextareaFieldServerComponent,\n TextareaFieldServerProps,\n} from './fields/Textarea.js'\n\nexport type {\n UIFieldClientComponent,\n UIFieldClientProps,\n UIFieldServerComponent,\n UIFieldServerProps,\n} from './fields/UI.js'\n\nexport type {\n UploadFieldClientComponent,\n UploadFieldClientProps,\n UploadFieldDescriptionClientComponent,\n UploadFieldDescriptionServerComponent,\n UploadFieldErrorClientComponent,\n UploadFieldErrorServerComponent,\n UploadFieldLabelClientComponent,\n UploadFieldLabelServerComponent,\n UploadFieldServerComponent,\n UploadFieldServerProps,\n} from './fields/Upload.js'\n\nexport type {\n Description,\n DescriptionFunction,\n FieldDescriptionClientComponent,\n FieldDescriptionClientProps,\n FieldDescriptionServerComponent,\n FieldDescriptionServerProps,\n GenericDescriptionProps,\n StaticDescription,\n} from './forms/Description.js'\n\nexport type {\n FieldErrorClientComponent,\n FieldErrorClientProps,\n FieldErrorServerComponent,\n FieldErrorServerProps,\n GenericErrorProps,\n} from './forms/Error.js'\n\nexport type {\n BuildFormStateArgs,\n Data,\n FieldState as FormField,\n FieldStateWithoutComponents as FormFieldWithoutComponents,\n FilterOptionsResult,\n FormState,\n FormStateWithoutComponents,\n Row,\n}\n\nexport type {\n ClientComponentProps,\n ClientFieldBase,\n ClientFieldWithOptionalType,\n FieldClientComponent,\n FieldPaths,\n FieldServerComponent,\n ServerComponentProps,\n ServerFieldBase,\n} from './forms/Field.js'\n\nexport type {\n FieldLabelClientComponent,\n FieldLabelClientProps,\n FieldLabelServerComponent,\n FieldLabelServerProps,\n GenericLabelProps,\n SanitizedLabelProps,\n} from './forms/Label.js'\n\nexport type { RowLabel, RowLabelComponent } from './forms/RowLabel.js'\n\nexport type {\n BuildTableStateArgs,\n DefaultServerFunctionArgs,\n ListQuery,\n ServerFunction,\n ServerFunctionArgs,\n ServerFunctionClient,\n ServerFunctionClientArgs,\n ServerFunctionConfig,\n ServerFunctionHandler,\n} from './functions/index.js'\n\nexport type MappedServerComponent<TComponentClientProps extends JsonObject = JsonObject> = {\n Component?: React.ComponentType<TComponentClientProps>\n props?: Partial<any>\n RenderedComponent: React.ReactNode\n type: 'server'\n}\n\nexport type MappedClientComponent<TComponentClientProps extends JsonObject = JsonObject> = {\n Component?: React.ComponentType<TComponentClientProps>\n props?: Partial<TComponentClientProps>\n RenderedComponent?: React.ReactNode\n type: 'client'\n}\n\nexport type MappedEmptyComponent = {\n type: 'empty'\n}\n\nexport enum Action {\n RenderConfig = 'render-config',\n}\n\nexport type RenderEntityConfigArgs = {\n collectionSlug?: string\n data?: Data\n globalSlug?: string\n}\n\nexport type RenderRootConfigArgs = {}\n\nexport type RenderFieldConfigArgs = {\n collectionSlug?: string\n formState?: FormState\n globalSlug?: string\n schemaPath: string\n}\n\nexport type RenderConfigArgs = {\n action: Action.RenderConfig\n config: Promise<SanitizedConfig> | SanitizedConfig\n i18n: I18nClient\n importMap: ImportMap\n languageCode: AcceptedLanguages\n serverProps?: any\n} & (RenderEntityConfigArgs | RenderFieldConfigArgs | RenderRootConfigArgs)\n\nexport type PayloadServerAction = (\n args:\n | {\n [key: string]: any\n action: Action\n i18n: I18nClient\n }\n | RenderConfigArgs,\n) => Promise<string>\n\nexport type RenderedField = {\n Field: React.ReactNode\n indexPath?: string\n initialSchemaPath?: string\n isSidebar: boolean\n path: string\n schemaPath: string\n type: FieldTypes\n}\n\nexport type FieldRow = {\n RowLabel?: React.ReactNode\n}\n\nexport type DocumentSlots = {\n Description?: React.ReactNode\n PreviewButton?: React.ReactNode\n PublishButton?: React.ReactNode\n SaveButton?: React.ReactNode\n SaveDraftButton?: React.ReactNode\n Upload?: React.ReactNode\n}\n\nexport type { LanguageOptions } from './LanguageOptions.js'\n\nexport type { RichTextAdapter, RichTextAdapterProvider, RichTextHooks } from './RichText.js'\n\nexport type {\n AdminViewComponent,\n AdminViewConfig,\n AdminViewProps,\n ClientSideEditViewProps,\n EditViewProps,\n InitPageResult,\n ServerSideEditViewProps,\n VisibleEntities,\n} from './views/types.js'\n\ntype SchemaPath = {} & string\nexport type FieldSchemaMap = Map<\n SchemaPath,\n | {\n fields: Field[]\n }\n | Block\n | Field\n | Tab\n>\n\nexport type ClientFieldSchemaMap = Map<\n SchemaPath,\n | {\n fields: ClientField[]\n }\n | ClientBlock\n | ClientField\n | ClientTab\n>\n"],"names":["Action"],"mappings":";UA6ZYA;;GAAAA,WAAAA"}
1
+ {"version":3,"sources":["../../src/admin/types.ts"],"sourcesContent":["import type { AcceptedLanguages, I18nClient } from '@payloadcms/translations'\nimport type React from 'react'\n\nimport type { ImportMap } from '../bin/generateImportMap/index.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type {\n Block,\n ClientBlock,\n ClientField,\n Field,\n FieldTypes,\n Tab,\n} from '../fields/config/types.js'\nimport type { JsonObject } from '../types/index.js'\nimport type { ClientTab } from './fields/Tabs.js'\nimport type {\n BuildFormStateArgs,\n Data,\n FieldState,\n FieldStateWithoutComponents,\n FilterOptionsResult,\n FormState,\n FormStateWithoutComponents,\n Row,\n} from './forms/Form.js'\n\nexport type { DefaultCellComponentProps, DefaultServerCellComponentProps } from './elements/Cell.js'\nexport type { ConditionalDateProps } from './elements/DatePicker.js'\nexport type { DayPickerProps, SharedProps, TimePickerProps } from './elements/DatePicker.js'\nexport type { NavGroupPreferences, NavPreferences } from './elements/Nav.js'\nexport type { CustomPreviewButton } from './elements/PreviewButton.js'\nexport type { CustomPublishButton } from './elements/PublishButton.js'\nexport type { CustomSaveButton } from './elements/SaveButton.js'\nexport type { CustomSaveDraftButton } from './elements/SaveDraftButton.js'\nexport type {\n DocumentTabComponent,\n DocumentTabCondition,\n DocumentTabConfig,\n DocumentTabProps,\n} from './elements/Tab.js'\n\nexport type { CustomUpload } from './elements/Upload.js'\n\nexport type {\n WithServerSidePropsComponent,\n WithServerSidePropsComponentProps,\n} from './elements/WithServerSideProps.js'\n\nexport type {\n ArrayFieldClientComponent,\n ArrayFieldClientProps,\n ArrayFieldDescriptionClientComponent,\n ArrayFieldDescriptionServerComponent,\n ArrayFieldErrorClientComponent,\n ArrayFieldErrorServerComponent,\n ArrayFieldLabelClientComponent,\n ArrayFieldLabelServerComponent,\n ArrayFieldServerComponent,\n ArrayFieldServerProps,\n} from './fields/Array.js'\n\nexport type {\n BlocksFieldClientComponent,\n BlocksFieldClientProps,\n BlocksFieldDescriptionClientComponent,\n BlocksFieldDescriptionServerComponent,\n BlocksFieldErrorClientComponent,\n BlocksFieldErrorServerComponent,\n BlocksFieldLabelClientComponent,\n BlocksFieldLabelServerComponent,\n BlocksFieldServerComponent,\n BlocksFieldServerProps,\n} from './fields/Blocks.js'\n\nexport type {\n CheckboxFieldClientComponent,\n CheckboxFieldClientProps,\n CheckboxFieldDescriptionClientComponent,\n CheckboxFieldDescriptionServerComponent,\n CheckboxFieldErrorClientComponent,\n CheckboxFieldErrorServerComponent,\n CheckboxFieldLabelClientComponent,\n CheckboxFieldLabelServerComponent,\n CheckboxFieldServerComponent,\n CheckboxFieldServerProps,\n} from './fields/Checkbox.js'\n\nexport type {\n CodeFieldClientComponent,\n CodeFieldClientProps,\n CodeFieldDescriptionClientComponent,\n CodeFieldDescriptionServerComponent,\n CodeFieldErrorClientComponent,\n CodeFieldErrorServerComponent,\n CodeFieldLabelClientComponent,\n CodeFieldLabelServerComponent,\n CodeFieldServerComponent,\n CodeFieldServerProps,\n} from './fields/Code.js'\n\nexport type {\n CollapsibleFieldClientComponent,\n CollapsibleFieldClientProps,\n CollapsibleFieldDescriptionClientComponent,\n CollapsibleFieldDescriptionServerComponent,\n CollapsibleFieldErrorClientComponent,\n CollapsibleFieldErrorServerComponent,\n CollapsibleFieldLabelClientComponent,\n CollapsibleFieldLabelServerComponent,\n CollapsibleFieldServerComponent,\n CollapsibleFieldServerProps,\n} from './fields/Collapsible.js'\n\nexport type {\n DateFieldClientComponent,\n DateFieldClientProps,\n DateFieldDescriptionClientComponent,\n DateFieldDescriptionServerComponent,\n DateFieldErrorClientComponent,\n DateFieldErrorServerComponent,\n DateFieldLabelClientComponent,\n DateFieldLabelServerComponent,\n DateFieldServerComponent,\n DateFieldServerProps,\n} from './fields/Date.js'\n\nexport type {\n EmailFieldClientComponent,\n EmailFieldClientProps,\n EmailFieldDescriptionClientComponent,\n EmailFieldDescriptionServerComponent,\n EmailFieldErrorClientComponent,\n EmailFieldErrorServerComponent,\n EmailFieldLabelClientComponent,\n EmailFieldLabelServerComponent,\n EmailFieldServerComponent,\n EmailFieldServerProps,\n} from './fields/Email.js'\n\nexport type {\n GroupFieldClientComponent,\n GroupFieldClientProps,\n GroupFieldDescriptionClientComponent,\n GroupFieldDescriptionServerComponent,\n GroupFieldErrorClientComponent,\n GroupFieldErrorServerComponent,\n GroupFieldLabelClientComponent,\n GroupFieldLabelServerComponent,\n GroupFieldServerComponent,\n GroupFieldServerProps,\n} from './fields/Group.js'\n\nexport type { HiddenFieldProps } from './fields/Hidden.js'\n\nexport type {\n JoinFieldClientComponent,\n JoinFieldClientProps,\n JoinFieldDescriptionClientComponent,\n JoinFieldDescriptionServerComponent,\n JoinFieldErrorClientComponent,\n JoinFieldErrorServerComponent,\n JoinFieldLabelClientComponent,\n JoinFieldLabelServerComponent,\n JoinFieldServerComponent,\n JoinFieldServerProps,\n} from './fields/Join.js'\n\nexport type {\n JSONFieldClientComponent,\n JSONFieldClientProps,\n JSONFieldDescriptionClientComponent,\n JSONFieldDescriptionServerComponent,\n JSONFieldErrorClientComponent,\n JSONFieldErrorServerComponent,\n JSONFieldLabelClientComponent,\n JSONFieldLabelServerComponent,\n JSONFieldServerComponent,\n JSONFieldServerProps,\n} from './fields/JSON.js'\n\nexport type {\n NumberFieldClientComponent,\n NumberFieldClientProps,\n NumberFieldDescriptionClientComponent,\n NumberFieldDescriptionServerComponent,\n NumberFieldErrorClientComponent,\n NumberFieldErrorServerComponent,\n NumberFieldLabelClientComponent,\n NumberFieldLabelServerComponent,\n NumberFieldServerComponent,\n NumberFieldServerProps,\n} from './fields/Number.js'\n\nexport type {\n PointFieldClientComponent,\n PointFieldClientProps,\n PointFieldDescriptionClientComponent,\n PointFieldDescriptionServerComponent,\n PointFieldErrorClientComponent,\n PointFieldErrorServerComponent,\n PointFieldLabelClientComponent,\n PointFieldLabelServerComponent,\n PointFieldServerComponent,\n PointFieldServerProps,\n} from './fields/Point.js'\n\nexport type {\n RadioFieldClientComponent,\n RadioFieldClientProps,\n RadioFieldDescriptionClientComponent,\n RadioFieldDescriptionServerComponent,\n RadioFieldErrorClientComponent,\n RadioFieldErrorServerComponent,\n RadioFieldLabelClientComponent,\n RadioFieldLabelServerComponent,\n RadioFieldServerComponent,\n RadioFieldServerProps,\n} from './fields/Radio.js'\n\nexport type {\n RelationshipFieldClientComponent,\n RelationshipFieldClientProps,\n RelationshipFieldDescriptionClientComponent,\n RelationshipFieldDescriptionServerComponent,\n RelationshipFieldErrorClientComponent,\n RelationshipFieldErrorServerComponent,\n RelationshipFieldLabelClientComponent,\n RelationshipFieldLabelServerComponent,\n RelationshipFieldServerComponent,\n RelationshipFieldServerProps,\n} from './fields/Relationship.js'\n\nexport type {\n RichTextFieldClientComponent,\n RichTextFieldClientProps,\n RichTextFieldDescriptionClientComponent,\n RichTextFieldDescriptionServerComponent,\n RichTextFieldErrorClientComponent,\n RichTextFieldErrorServerComponent,\n RichTextFieldLabelClientComponent,\n RichTextFieldLabelServerComponent,\n RichTextFieldServerComponent,\n RichTextFieldServerProps,\n} from './fields/RichText.js'\n\nexport type {\n RowFieldClientComponent,\n RowFieldClientProps,\n RowFieldDescriptionClientComponent,\n RowFieldDescriptionServerComponent,\n RowFieldErrorClientComponent,\n RowFieldErrorServerComponent,\n RowFieldLabelClientComponent,\n RowFieldLabelServerComponent,\n RowFieldServerComponent,\n RowFieldServerProps,\n} from './fields/Row.js'\n\nexport type {\n SelectFieldClientComponent,\n SelectFieldClientProps,\n SelectFieldDescriptionClientComponent,\n SelectFieldDescriptionServerComponent,\n SelectFieldErrorClientComponent,\n SelectFieldErrorServerComponent,\n SelectFieldLabelClientComponent,\n SelectFieldLabelServerComponent,\n SelectFieldServerComponent,\n SelectFieldServerProps,\n} from './fields/Select.js'\n\nexport type {\n ClientTab,\n TabsFieldClientComponent,\n TabsFieldClientProps,\n TabsFieldDescriptionClientComponent,\n TabsFieldDescriptionServerComponent,\n TabsFieldErrorClientComponent,\n TabsFieldErrorServerComponent,\n TabsFieldLabelClientComponent,\n TabsFieldLabelServerComponent,\n TabsFieldServerComponent,\n TabsFieldServerProps,\n} from './fields/Tabs.js'\n\nexport type {\n TextFieldClientComponent,\n TextFieldClientProps,\n TextFieldDescriptionClientComponent,\n TextFieldDescriptionServerComponent,\n TextFieldErrorClientComponent,\n TextFieldErrorServerComponent,\n TextFieldLabelClientComponent,\n TextFieldLabelServerComponent,\n TextFieldServerComponent,\n TextFieldServerProps,\n} from './fields/Text.js'\n\nexport type {\n TextareaFieldClientComponent,\n TextareaFieldClientProps,\n TextareaFieldDescriptionClientComponent,\n TextareaFieldDescriptionServerComponent,\n TextareaFieldErrorClientComponent,\n TextareaFieldErrorServerComponent,\n TextareaFieldLabelClientComponent,\n TextareaFieldLabelServerComponent,\n TextareaFieldServerComponent,\n TextareaFieldServerProps,\n} from './fields/Textarea.js'\n\nexport type {\n UIFieldClientComponent,\n UIFieldClientProps,\n UIFieldServerComponent,\n UIFieldServerProps,\n} from './fields/UI.js'\n\nexport type {\n UploadFieldClientComponent,\n UploadFieldClientProps,\n UploadFieldDescriptionClientComponent,\n UploadFieldDescriptionServerComponent,\n UploadFieldErrorClientComponent,\n UploadFieldErrorServerComponent,\n UploadFieldLabelClientComponent,\n UploadFieldLabelServerComponent,\n UploadFieldServerComponent,\n UploadFieldServerProps,\n} from './fields/Upload.js'\n\nexport type {\n Description,\n DescriptionFunction,\n FieldDescriptionClientComponent,\n FieldDescriptionClientProps,\n FieldDescriptionServerComponent,\n FieldDescriptionServerProps,\n GenericDescriptionProps,\n StaticDescription,\n} from './forms/Description.js'\n\nexport type {\n FieldErrorClientComponent,\n FieldErrorClientProps,\n FieldErrorServerComponent,\n FieldErrorServerProps,\n GenericErrorProps,\n} from './forms/Error.js'\n\nexport type {\n BuildFormStateArgs,\n Data,\n FieldState as FormField,\n FieldStateWithoutComponents as FormFieldWithoutComponents,\n FilterOptionsResult,\n FormState,\n FormStateWithoutComponents,\n Row,\n}\n\nexport type {\n ClientComponentProps,\n ClientFieldBase,\n ClientFieldWithOptionalType,\n FieldClientComponent,\n FieldPaths,\n FieldServerComponent,\n ServerComponentProps,\n ServerFieldBase,\n} from './forms/Field.js'\n\nexport type {\n FieldLabelClientComponent,\n FieldLabelClientProps,\n FieldLabelServerComponent,\n FieldLabelServerProps,\n GenericLabelProps,\n SanitizedLabelProps,\n} from './forms/Label.js'\n\nexport type { RowLabel, RowLabelComponent } from './forms/RowLabel.js'\n\nexport type {\n BuildTableStateArgs,\n DefaultServerFunctionArgs,\n ListQuery,\n ServerFunction,\n ServerFunctionArgs,\n ServerFunctionClient,\n ServerFunctionClientArgs,\n ServerFunctionConfig,\n ServerFunctionHandler,\n} from './functions/index.js'\n\nexport type MappedServerComponent<TComponentClientProps extends JsonObject = JsonObject> = {\n Component?: React.ComponentType<TComponentClientProps>\n props?: Partial<any>\n RenderedComponent: React.ReactNode\n type: 'server'\n}\n\nexport type MappedClientComponent<TComponentClientProps extends JsonObject = JsonObject> = {\n Component?: React.ComponentType<TComponentClientProps>\n props?: Partial<TComponentClientProps>\n RenderedComponent?: React.ReactNode\n type: 'client'\n}\n\nexport type MappedEmptyComponent = {\n type: 'empty'\n}\n\nexport enum Action {\n RenderConfig = 'render-config',\n}\n\nexport type RenderEntityConfigArgs = {\n collectionSlug?: string\n data?: Data\n globalSlug?: string\n}\n\nexport type RenderRootConfigArgs = {}\n\nexport type RenderFieldConfigArgs = {\n collectionSlug?: string\n formState?: FormState\n globalSlug?: string\n schemaPath: string\n}\n\nexport type RenderConfigArgs = {\n action: Action.RenderConfig\n config: Promise<SanitizedConfig> | SanitizedConfig\n i18n: I18nClient\n importMap: ImportMap\n languageCode: AcceptedLanguages\n serverProps?: any\n} & (RenderEntityConfigArgs | RenderFieldConfigArgs | RenderRootConfigArgs)\n\nexport type PayloadServerAction = (\n args:\n | {\n [key: string]: any\n action: Action\n i18n: I18nClient\n }\n | RenderConfigArgs,\n) => Promise<string>\n\nexport type RenderedField = {\n Field: React.ReactNode\n indexPath?: string\n initialSchemaPath?: string\n isSidebar: boolean\n path: string\n schemaPath: string\n type: FieldTypes\n}\n\nexport type FieldRow = {\n RowLabel?: React.ReactNode\n}\n\nexport type DocumentSlots = {\n Description?: React.ReactNode\n PreviewButton?: React.ReactNode\n PublishButton?: React.ReactNode\n SaveButton?: React.ReactNode\n SaveDraftButton?: React.ReactNode\n Upload?: React.ReactNode\n}\n\nexport type { LanguageOptions } from './LanguageOptions.js'\n\nexport type { RichTextAdapter, RichTextAdapterProvider, RichTextHooks } from './RichText.js'\n\nexport type {\n AdminViewComponent,\n AdminViewConfig,\n AdminViewProps,\n ClientSideEditViewProps,\n EditViewProps,\n InitPageResult,\n ServerSideEditViewProps,\n VisibleEntities,\n} from './views/types.js'\n\ntype SchemaPath = {} & string\nexport type FieldSchemaMap = Map<\n SchemaPath,\n | {\n fields: Field[]\n }\n | Block\n | Field\n | Tab\n>\n\nexport type ClientFieldSchemaMap = Map<\n SchemaPath,\n | {\n fields: ClientField[]\n }\n | ClientBlock\n | ClientField\n | ClientTab\n>\n"],"names":["Action"],"mappings":"AA6ZA,OAAO,IAAA,AAAKA,gCAAAA;;WAAAA;MAEX"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/auth/cookies.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from './../collections/config/types.js'\n\ntype CookieOptions = {\n domain?: string\n expires?: Date\n httpOnly?: boolean\n maxAge?: number\n name: string\n path?: string\n returnCookieAsObject: boolean\n sameSite?: 'Lax' | 'None' | 'Strict'\n secure?: boolean\n value?: string\n}\n\ntype CookieObject = {\n domain?: string\n expires?: string\n httpOnly?: boolean\n maxAge?: number\n name: string\n path?: string\n sameSite?: 'Lax' | 'None' | 'Strict'\n secure?: boolean\n value: string | undefined\n}\n\nexport const generateCookie = <ReturnCookieAsObject = boolean>(\n args: CookieOptions,\n): ReturnCookieAsObject extends true ? CookieObject : string => {\n const {\n name,\n domain,\n expires,\n httpOnly,\n maxAge,\n path,\n returnCookieAsObject,\n sameSite,\n secure: secureArg,\n value,\n } = args\n\n let cookieString = `${name}=${value || ''}`\n const cookieObject: CookieObject = {\n name,\n value,\n }\n\n const secure = secureArg || sameSite === 'None'\n\n if (expires) {\n if (returnCookieAsObject) {\n cookieObject.expires = expires.toUTCString()\n } else {\n cookieString += `; Expires=${expires.toUTCString()}`\n }\n }\n\n if (maxAge) {\n if (returnCookieAsObject) {\n cookieObject.maxAge = maxAge\n } else {\n cookieString += `; Max-Age=${maxAge.toString()}`\n }\n }\n\n if (domain) {\n if (returnCookieAsObject) {\n cookieObject.domain = domain\n } else {\n cookieString += `; Domain=${domain}`\n }\n }\n\n if (path) {\n if (returnCookieAsObject) {\n cookieObject.path = path\n } else {\n cookieString += `; Path=${path}`\n }\n }\n\n if (secure) {\n if (returnCookieAsObject) {\n cookieObject.secure = secure\n } else {\n cookieString += `; Secure=${secure}`\n }\n }\n\n if (httpOnly) {\n if (returnCookieAsObject) {\n cookieObject.httpOnly = httpOnly\n } else {\n cookieString += `; HttpOnly=${httpOnly}`\n }\n }\n\n if (sameSite) {\n if (returnCookieAsObject) {\n cookieObject.sameSite = sameSite\n } else {\n cookieString += `; SameSite=${sameSite}`\n }\n }\n\n return (returnCookieAsObject ? cookieObject : cookieString) as ReturnCookieAsObject extends true\n ? CookieObject\n : string\n}\ntype GetCookieExpirationArgs = {\n /*\n The number of seconds until the cookie expires\n @default 7200 seconds (2 hours)\n */\n seconds: number\n}\nexport const getCookieExpiration = ({ seconds = 7200 }: GetCookieExpirationArgs) => {\n const currentTime = new Date()\n currentTime.setSeconds(currentTime.getSeconds() + seconds)\n return currentTime\n}\n\ntype GeneratePayloadCookieArgs = {\n /* The auth collection config */\n collectionAuthConfig: SanitizedCollectionConfig['auth']\n /* Prefix to scope the cookie */\n cookiePrefix: string\n /* The returnAs value */\n returnCookieAsObject?: boolean\n /* The token to be stored in the cookie */\n token: string\n}\nexport const generatePayloadCookie = <T extends GeneratePayloadCookieArgs>({\n collectionAuthConfig,\n cookiePrefix,\n returnCookieAsObject = false,\n token,\n}: T): T['returnCookieAsObject'] extends true ? CookieObject : string => {\n const sameSite =\n typeof collectionAuthConfig.cookies.sameSite === 'string'\n ? collectionAuthConfig.cookies.sameSite\n : collectionAuthConfig.cookies.sameSite\n ? 'Strict'\n : undefined\n\n return generateCookie<T['returnCookieAsObject']>({\n name: `${cookiePrefix}-token`,\n domain: collectionAuthConfig.cookies.domain ?? undefined,\n expires: getCookieExpiration({ seconds: collectionAuthConfig.tokenExpiration }),\n httpOnly: true,\n path: '/',\n returnCookieAsObject,\n sameSite,\n secure: collectionAuthConfig.cookies.secure,\n value: token,\n })\n}\n\nexport const generateExpiredPayloadCookie = <T extends Omit<GeneratePayloadCookieArgs, 'token'>>({\n collectionAuthConfig,\n cookiePrefix,\n returnCookieAsObject = false,\n}: T): T['returnCookieAsObject'] extends true ? CookieObject : string => {\n const sameSite =\n typeof collectionAuthConfig.cookies.sameSite === 'string'\n ? collectionAuthConfig.cookies.sameSite\n : collectionAuthConfig.cookies.sameSite\n ? 'Strict'\n : undefined\n\n const expires = new Date(Date.now() - 1000)\n\n return generateCookie<T['returnCookieAsObject']>({\n name: `${cookiePrefix}-token`,\n domain: collectionAuthConfig.cookies.domain ?? undefined,\n expires,\n httpOnly: true,\n path: '/',\n returnCookieAsObject,\n sameSite,\n secure: collectionAuthConfig.cookies.secure,\n })\n}\n\nexport const parseCookies = (headers: Request['headers']): Map<string, string> => {\n const cookieMap = new Map<string, string>()\n const cookie = headers.get('Cookie')\n\n if (cookie) {\n cookie.split(';').forEach((cookie) => {\n const parts = cookie.split('=')\n const key = parts.shift()?.trim()\n const encodedValue = parts.join('=')\n\n try {\n const decodedValue = decodeURI(encodedValue)\n cookieMap.set(key, decodedValue)\n } catch (ignore) {\n return null\n }\n })\n }\n\n return cookieMap\n}\n"],"names":["generateCookie","args","name","domain","expires","httpOnly","maxAge","path","returnCookieAsObject","sameSite","secure","secureArg","value","cookieString","cookieObject","toUTCString","toString","getCookieExpiration","seconds","currentTime","Date","setSeconds","getSeconds","generatePayloadCookie","collectionAuthConfig","cookiePrefix","token","cookies","undefined","tokenExpiration","generateExpiredPayloadCookie","now","parseCookies","headers","cookieMap","Map","cookie","get","split","forEach","parts","key","shift","trim","encodedValue","join","decodedValue","decodeURI","set","ignore"],"mappings":"AA2BA,OAAO,MAAMA,iBAAiB,CAC5BC;IAEA,MAAM,EACJC,IAAI,EACJC,MAAM,EACNC,OAAO,EACPC,QAAQ,EACRC,MAAM,EACNC,IAAI,EACJC,oBAAoB,EACpBC,QAAQ,EACRC,QAAQC,SAAS,EACjBC,KAAK,EACN,GAAGX;IAEJ,IAAIY,eAAe,CAAC,EAAEX,KAAK,CAAC,EAAEU,SAAS,GAAG,CAAC;IAC3C,MAAME,eAA6B;QACjCZ;QACAU;IACF;IAEA,MAAMF,SAASC,aAAaF,aAAa;IAEzC,IAAIL,SAAS;QACX,IAAII,sBAAsB;YACxBM,aAAaV,OAAO,GAAGA,QAAQW,WAAW;QAC5C,OAAO;YACLF,gBAAgB,CAAC,UAAU,EAAET,QAAQW,WAAW,GAAG,CAAC;QACtD;IACF;IAEA,IAAIT,QAAQ;QACV,IAAIE,sBAAsB;YACxBM,aAAaR,MAAM,GAAGA;QACxB,OAAO;YACLO,gBAAgB,CAAC,UAAU,EAAEP,OAAOU,QAAQ,GAAG,CAAC;QAClD;IACF;IAEA,IAAIb,QAAQ;QACV,IAAIK,sBAAsB;YACxBM,aAAaX,MAAM,GAAGA;QACxB,OAAO;YACLU,gBAAgB,CAAC,SAAS,EAAEV,OAAO,CAAC;QACtC;IACF;IAEA,IAAII,MAAM;QACR,IAAIC,sBAAsB;YACxBM,aAAaP,IAAI,GAAGA;QACtB,OAAO;YACLM,gBAAgB,CAAC,OAAO,EAAEN,KAAK,CAAC;QAClC;IACF;IAEA,IAAIG,QAAQ;QACV,IAAIF,sBAAsB;YACxBM,aAAaJ,MAAM,GAAGA;QACxB,OAAO;YACLG,gBAAgB,CAAC,SAAS,EAAEH,OAAO,CAAC;QACtC;IACF;IAEA,IAAIL,UAAU;QACZ,IAAIG,sBAAsB;YACxBM,aAAaT,QAAQ,GAAGA;QAC1B,OAAO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A,KAAKW,GAAG,KAAK;IAEtC,OAAO/B,eAA0C;QAC/CE,MAAM,CAAC,EAAEuB,aAAa,MAAM,CAAC;QAC7BtB,QAAQqB,qBAAqBG,OAAO,CAACxB,MAAM,IAAIyB;QAC/CxB;QACAC,UAAU;QACVE,MAAM;QACNC;QACAC;QACAC,QAAQc,qBAAqBG,OAAO,CAACjB,MAAM;IAC7C;AACF,EAAC;AAED,OAAO,MAAMsB,eAAe,CAACC;IAC3B,MAAMC,YAAY,IAAIC;IACtB,MAAMC,SAASH,QAAQI,GAAG,CAAC;IAE3B,IAAID,QAAQ;QACVA,OAAOE,KAAK,CAAC,KAAKC,OAAO,CAAC,CAACH;YACzB,MAAMI,QAAQJ,OAAOE,KAAK,CAAC;YAC3B,MAAMG,MAAMD,MAAME,KAAK,IAAIC;YAC3B,MAAMC,eAAeJ,MAAMK,IAAI,CAAC;YAEhC,IAAI;gBACF,MAAMC,eAAeC,UAAUH;gBAC/BV,UAAUc,GAAG,CAACP,KAAKK;YACrB,EAAE,OAAOG,QAAQ;gBACf,OAAO;YACT;QACF;IACF;IAEA,OAAOf;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/auth/cookies.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from './../collections/config/types.js'\n\ntype CookieOptions = {\n domain?: string\n expires?: Date\n httpOnly?: boolean\n maxAge?: number\n name: string\n path?: string\n returnCookieAsObject: boolean\n sameSite?: 'Lax' | 'None' | 'Strict'\n secure?: boolean\n value?: string\n}\n\ntype CookieObject = {\n domain?: string\n expires?: string\n httpOnly?: boolean\n maxAge?: number\n name: string\n path?: string\n sameSite?: 'Lax' | 'None' | 'Strict'\n secure?: boolean\n value: string | undefined\n}\n\nexport const generateCookie = <ReturnCookieAsObject = boolean>(\n args: CookieOptions,\n): ReturnCookieAsObject extends true ? CookieObject : string => {\n const {\n name,\n domain,\n expires,\n httpOnly,\n maxAge,\n path,\n returnCookieAsObject,\n sameSite,\n secure: secureArg,\n value,\n } = args\n\n let cookieString = `${name}=${value || ''}`\n const cookieObject: CookieObject = {\n name,\n value,\n }\n\n const secure = secureArg || sameSite === 'None'\n\n if (expires) {\n if (returnCookieAsObject) {\n cookieObject.expires = expires.toUTCString()\n } else {\n cookieString += `; Expires=${expires.toUTCString()}`\n }\n }\n\n if (maxAge) {\n if (returnCookieAsObject) {\n cookieObject.maxAge = maxAge\n } else {\n cookieString += `; Max-Age=${maxAge.toString()}`\n }\n }\n\n if (domain) {\n if (returnCookieAsObject) {\n cookieObject.domain = domain\n } else {\n cookieString += `; Domain=${domain}`\n }\n }\n\n if (path) {\n if (returnCookieAsObject) {\n cookieObject.path = path\n } else {\n cookieString += `; Path=${path}`\n }\n }\n\n if (secure) {\n if (returnCookieAsObject) {\n cookieObject.secure = secure\n } else {\n cookieString += `; Secure=${secure}`\n }\n }\n\n if (httpOnly) {\n if (returnCookieAsObject) {\n cookieObject.httpOnly = httpOnly\n } else {\n cookieString += `; HttpOnly=${httpOnly}`\n }\n }\n\n if (sameSite) {\n if (returnCookieAsObject) {\n cookieObject.sameSite = sameSite\n } else {\n cookieString += `; SameSite=${sameSite}`\n }\n }\n\n return (returnCookieAsObject ? cookieObject : cookieString) as ReturnCookieAsObject extends true\n ? CookieObject\n : string\n}\ntype GetCookieExpirationArgs = {\n /*\n The number of seconds until the cookie expires\n @default 7200 seconds (2 hours)\n */\n seconds: number\n}\nexport const getCookieExpiration = ({ seconds = 7200 }: GetCookieExpirationArgs) => {\n const currentTime = new Date()\n currentTime.setSeconds(currentTime.getSeconds() + seconds)\n return currentTime\n}\n\ntype GeneratePayloadCookieArgs = {\n /* The auth collection config */\n collectionAuthConfig: SanitizedCollectionConfig['auth']\n /* Prefix to scope the cookie */\n cookiePrefix: string\n /* The returnAs value */\n returnCookieAsObject?: boolean\n /* The token to be stored in the cookie */\n token: string\n}\nexport const generatePayloadCookie = <T extends GeneratePayloadCookieArgs>({\n collectionAuthConfig,\n cookiePrefix,\n returnCookieAsObject = false,\n token,\n}: T): T['returnCookieAsObject'] extends true ? CookieObject : string => {\n const sameSite =\n typeof collectionAuthConfig.cookies.sameSite === 'string'\n ? collectionAuthConfig.cookies.sameSite\n : collectionAuthConfig.cookies.sameSite\n ? 'Strict'\n : undefined\n\n return generateCookie<T['returnCookieAsObject']>({\n name: `${cookiePrefix}-token`,\n domain: collectionAuthConfig.cookies.domain ?? undefined,\n expires: getCookieExpiration({ seconds: collectionAuthConfig.tokenExpiration }),\n httpOnly: true,\n path: '/',\n returnCookieAsObject,\n sameSite,\n secure: collectionAuthConfig.cookies.secure,\n value: token,\n })\n}\n\nexport const generateExpiredPayloadCookie = <T extends Omit<GeneratePayloadCookieArgs, 'token'>>({\n collectionAuthConfig,\n cookiePrefix,\n returnCookieAsObject = false,\n}: T): T['returnCookieAsObject'] extends true ? CookieObject : string => {\n const sameSite =\n typeof collectionAuthConfig.cookies.sameSite === 'string'\n ? collectionAuthConfig.cookies.sameSite\n : collectionAuthConfig.cookies.sameSite\n ? 'Strict'\n : undefined\n\n const expires = new Date(Date.now() - 1000)\n\n return generateCookie<T['returnCookieAsObject']>({\n name: `${cookiePrefix}-token`,\n domain: collectionAuthConfig.cookies.domain ?? undefined,\n expires,\n httpOnly: true,\n path: '/',\n returnCookieAsObject,\n sameSite,\n secure: collectionAuthConfig.cookies.secure,\n })\n}\n\nexport const parseCookies = (headers: Request['headers']): Map<string, string> => {\n const cookieMap = new Map<string, string>()\n const cookie = headers.get('Cookie')\n\n if (cookie) {\n cookie.split(';').forEach((cookie) => {\n const parts = cookie.split('=')\n const key = parts.shift()?.trim()\n const encodedValue = parts.join('=')\n\n try {\n const decodedValue = decodeURI(encodedValue)\n cookieMap.set(key, decodedValue)\n } catch (ignore) {\n return null\n }\n })\n }\n\n return cookieMap\n}\n"],"names":["generateCookie","args","name","domain","expires","httpOnly","maxAge","path","returnCookieAsObject","sameSite","secure","secureArg","value","cookieString","cookieObject","toUTCString","toString","getCookieExpiration","seconds","currentTime","Date","setSeconds","getSeconds","generatePayloadCookie","collectionAuthConfig","cookiePrefix","token","cookies","undefined","tokenExpiration","generateExpiredPayloadCookie","now","parseCookies","headers","cookieMap","Map","cookie","get","split","forEach","parts","key","shift","trim","encodedValue","join","decodedValue","decodeURI","set","ignore"],"mappings":"AA2BA,OAAO,MAAMA,iBAAiB,CAC5BC;IAEA,MAAM,EACJC,IAAI,EACJC,MAAM,EACNC,OAAO,EACPC,QAAQ,EACRC,MAAM,EACNC,IAAI,EACJC,oBAAoB,EACpBC,QAAQ,EACRC,QAAQC,SAAS,EACjBC,KAAK,EACN,GAAGX;IAEJ,IAAIY,eAAe,GAAGX,KAAK,CAAC,EAAEU,SAAS,IAAI;IAC3C,MAAME,eAA6B;QACjCZ;QACAU;IACF;IAEA,MAAMF,SAASC,aAAaF,aAAa;IAEzC,IAAIL,SAAS;QACX,IAAII,sBAAsB;YACxBM,aAAaV,OAAO,GAAGA,QAAQW,WAAW;QAC5C,OAAO;YACLF,gBAAgB,CAAC,UAAU,EAAET,QAAQW,WAAW,IAAI;QACtD;IACF;IAEA,IAAIT,QAAQ;QACV,IAAIE,sBAAsB;YACxBM,aAAaR,MAAM,GAAGA;QACxB,OAAO;YACLO,gBAAgB,CAAC,UAAU,EAAEP,OAAOU,QAAQ,IAAI;QAClD;IACF;IAEA,IAAIb,QAAQ;QACV,IAAIK,sBAAsB;YACxBM,aAAaX,MAAM,GAAGA;QACxB,OAAO;YACLU,gBAAgB,CAAC,SAAS,EAAEV,QAAQ;QACtC;IACF;IAEA,IAAII,MAAM;QACR,IAAIC,sBAAsB;YACxBM,aAAaP,IAAI,GAAGA;QACtB,OAAO;YACLM,gBAAgB,CAAC,OAAO,EAAEN,MAAM;QAClC;IACF;IAEA,IAAIG,QAAQ;QACV,IAAIF,sBAAsB;YACxBM,aAAaJ,MAAM,GAAGA;QACxB,OAAO;YACLG,gBAAgB,CAAC,SAAS,EAAEH,QAAQ;QACtC;IACF;IAEA,IAAIL,UAAU;QACZ,IAAIG,sBAAsB;YACxBM,aA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IAAIgB,KAAKA,KAAKW,GAAG,KAAK;IAEtC,OAAO/B,eAA0C;QAC/CE,MAAM,GAAGuB,aAAa,MAAM,CAAC;QAC7BtB,QAAQqB,qBAAqBG,OAAO,CAACxB,MAAM,IAAIyB;QAC/CxB;QACAC,UAAU;QACVE,MAAM;QACNC;QACAC;QACAC,QAAQc,qBAAqBG,OAAO,CAACjB,MAAM;IAC7C;AACF,EAAC;AAED,OAAO,MAAMsB,eAAe,CAACC;IAC3B,MAAMC,YAAY,IAAIC;IACtB,MAAMC,SAASH,QAAQI,GAAG,CAAC;IAE3B,IAAID,QAAQ;QACVA,OAAOE,KAAK,CAAC,KAAKC,OAAO,CAAC,CAACH;YACzB,MAAMI,QAAQJ,OAAOE,KAAK,CAAC;YAC3B,MAAMG,MAAMD,MAAME,KAAK,IAAIC;YAC3B,MAAMC,eAAeJ,MAAMK,IAAI,CAAC;YAEhC,IAAI;gBACF,MAAMC,eAAeC,UAAUH;gBAC/BV,UAAUc,GAAG,CAACP,KAAKK;YACrB,EAAE,OAAOG,QAAQ;gBACf,OAAO;YACT;QACF;IACF;IAEA,OAAOf;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/auth/crypto.ts"],"sourcesContent":["import crypto from 'crypto'\n\nconst algorithm = 'aes-256-ctr'\n\nexport function encrypt(text: string): string {\n const iv = crypto.randomBytes(16)\n const cipher = crypto.createCipheriv(algorithm, this.secret, iv)\n\n const encrypted = Buffer.concat([cipher.update(text), cipher.final()])\n\n const ivString = iv.toString('hex')\n const encryptedString = encrypted.toString('hex')\n\n return `${ivString}${encryptedString}`\n}\n\nexport function decrypt(hash: string): string {\n const iv = hash.slice(0, 32)\n const content = hash.slice(32)\n\n const decipher = crypto.createDecipheriv(algorithm, this.secret, Buffer.from(iv, 'hex'))\n\n const decrypted = Buffer.concat([decipher.update(Buffer.from(content, 'hex')), decipher.final()])\n\n return decrypted.toString()\n}\n"],"names":["crypto","algorithm","encrypt","text","iv","randomBytes","cipher","createCipheriv","secret","encrypted","Buffer","concat","update","final","ivString","toString","encryptedString","decrypt","hash","slice","content","decipher","createDecipheriv","from","decrypted"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAE3B,MAAMC,YAAY;AAElB,OAAO,SAASC,QAAQC,IAAY;IAClC,MAAMC,KAAKJ,OAAOK,WAAW,CAAC;IAC9B,MAAMC,SAASN,OAAOO,cAAc,CAACN,WAAW,IAAI,CAACO,MAAM,EAAEJ;IAE7D,MAAMK,YAAYC,OAAOC,MAAM,CAAC;QAACL,OAAOM,MAAM,CAACT;QAAOG,OAAOO,KAAK;KAAG;IAErE,MAAMC,WAAWV,GAAGW,QAAQ,CAAC;IAC7B,MAAMC,kBAAkBP,UAAUM,QAAQ,CAAC;IAE3C,OAAO,CAAC,EAAED,SAAS,EAAEE,gBAAgB,CAAC;AACxC;AAEA,OAAO,SAASC,QAAQC,IAAY;IAClC,MAAMd,KAAKc,KAAKC,KAAK,CAAC,GAAG;IACzB,MAAMC,UAAUF,KAAKC,KAAK,CAAC;IAE3B,MAAME,WAAWrB,OAAOsB,gBAAgB,CAACrB,WAAW,IAAI,CAACO,MAAM,EAAEE,OAAOa,IAAI,CAACnB,IAAI;IAEjF,MAAMoB,YAAYd,OAAOC,MAAM,CAAC;QAACU,SAAST,MAAM,CAACF,OAAOa,IAAI,CAACH,SAAS;QAASC,SAASR,KAAK;KAAG;IAEhG,OAAOW,UAAUT,QAAQ;AAC3B"}
1
+ {"version":3,"sources":["../../src/auth/crypto.ts"],"sourcesContent":["import crypto from 'crypto'\n\nconst algorithm = 'aes-256-ctr'\n\nexport function encrypt(text: string): string {\n const iv = crypto.randomBytes(16)\n const cipher = crypto.createCipheriv(algorithm, this.secret, iv)\n\n const encrypted = Buffer.concat([cipher.update(text), cipher.final()])\n\n const ivString = iv.toString('hex')\n const encryptedString = encrypted.toString('hex')\n\n return `${ivString}${encryptedString}`\n}\n\nexport function decrypt(hash: string): string {\n const iv = hash.slice(0, 32)\n const content = hash.slice(32)\n\n const decipher = crypto.createDecipheriv(algorithm, this.secret, Buffer.from(iv, 'hex'))\n\n const decrypted = Buffer.concat([decipher.update(Buffer.from(content, 'hex')), decipher.final()])\n\n return decrypted.toString()\n}\n"],"names":["crypto","algorithm","encrypt","text","iv","randomBytes","cipher","createCipheriv","secret","encrypted","Buffer","concat","update","final","ivString","toString","encryptedString","decrypt","hash","slice","content","decipher","createDecipheriv","from","decrypted"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAE3B,MAAMC,YAAY;AAElB,OAAO,SAASC,QAAQC,IAAY;IAClC,MAAMC,KAAKJ,OAAOK,WAAW,CAAC;IAC9B,MAAMC,SAASN,OAAOO,cAAc,CAACN,WAAW,IAAI,CAACO,MAAM,EAAEJ;IAE7D,MAAMK,YAAYC,OAAOC,MAAM,CAAC;QAACL,OAAOM,MAAM,CAACT;QAAOG,OAAOO,KAAK;KAAG;IAErE,MAAMC,WAAWV,GAAGW,QAAQ,CAAC;IAC7B,MAAMC,kBAAkBP,UAAUM,QAAQ,CAAC;IAE3C,OAAO,GAAGD,WAAWE,iBAAiB;AACxC;AAEA,OAAO,SAASC,QAAQC,IAAY;IAClC,MAAMd,KAAKc,KAAKC,KAAK,CAAC,GAAG;IACzB,MAAMC,UAAUF,KAAKC,KAAK,CAAC;IAE3B,MAAME,WAAWrB,OAAOsB,gBAAgB,CAACrB,WAAW,IAAI,CAACO,MAAM,EAAEE,OAAOa,IAAI,CAACnB,IAAI;IAEjF,MAAMoB,YAAYd,OAAOC,MAAM,CAAC;QAACU,SAAST,MAAM,CAACF,OAAOa,IAAI,CAACH,SAAS;QAASC,SAASR,KAAK;KAAG;IAEhG,OAAOW,UAAUT,QAAQ;AAC3B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/auth/extractJWT.ts"],"sourcesContent":["import type { AuthStrategyFunctionArgs } from './index.js'\n\nimport { parseCookies } from '../utilities/parseCookies.js'\n\nexport const extractJWT = (args: AuthStrategyFunctionArgs): null | string => {\n const { headers, payload } = args\n\n const jwtFromHeader = headers.get('Authorization')\n const origin = headers.get('Origin')\n\n if (jwtFromHeader?.startsWith('JWT ')) {\n return jwtFromHeader.replace('JWT ', '')\n }\n // allow RFC6750 OAuth 2.0 compliant Bearer tokens\n // in addition to the payload default JWT format\n if (jwtFromHeader?.startsWith('Bearer ')) {\n return jwtFromHeader.replace('Bearer ', '')\n }\n\n const cookies = parseCookies(headers)\n const tokenCookieName = `${payload.config.cookiePrefix}-token`\n const cookieToken = cookies.get(tokenCookieName)\n\n if (!cookieToken) {\n return null\n }\n\n if (!origin || payload.config.csrf.length === 0 || payload.config.csrf.indexOf(origin) > -1) {\n return cookieToken\n }\n\n return null\n}\n"],"names":["parseCookies","extractJWT","args","headers","payload","jwtFromHeader","get","origin","startsWith","replace","cookies","tokenCookieName","config","cookiePrefix","cookieToken","csrf","length","indexOf"],"mappings":"AAEA,SAASA,YAAY,QAAQ,+BAA8B;AAE3D,OAAO,MAAMC,aAAa,CAACC;IACzB,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAE,GAAGF;IAE7B,MAAMG,gBAAgBF,QAAQG,GAAG,CAAC;IAClC,MAAMC,SAASJ,QAAQG,GAAG,CAAC;IAE3B,IAAID,eAAeG,WAAW,SAAS;QACrC,OAAOH,cAAcI,OAAO,CAAC,QAAQ;IACvC;IACA,kDAAkD;IAClD,gDAAgD;IAChD,IAAIJ,eAAeG,WAAW,YAAY;QACxC,OAAOH,cAAcI,OAAO,CAAC,WAAW;IAC1C;IAEA,MAAMC,UAAUV,aAAaG;IAC7B,MAAMQ,kBAAkB,CAAC,EAAEP,QAAQQ,MAAM,CAACC,YAAY,CAAC,MAAM,CAAC;IAC9D,MAAMC,cAAcJ,QAAQJ,GAAG,CAACK;IAEhC,IAAI,CAACG,aAAa;QAChB,OAAO;IACT;IAEA,IAAI,CAACP,UAAUH,QAAQQ,MAAM,CAACG,IAAI,CAACC,MAAM,KAAK,KAAKZ,QAAQQ,MAAM,CAACG,IAAI,CAACE,OAAO,CAACV,UAAU,CAAC,GAAG;QAC3F,OAAOO;IACT;IAEA,OAAO;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/auth/extractJWT.ts"],"sourcesContent":["import type { AuthStrategyFunctionArgs } from './index.js'\n\nimport { parseCookies } from '../utilities/parseCookies.js'\n\nexport const extractJWT = (args: AuthStrategyFunctionArgs): null | string => {\n const { headers, payload } = args\n\n const jwtFromHeader = headers.get('Authorization')\n const origin = headers.get('Origin')\n\n if (jwtFromHeader?.startsWith('JWT ')) {\n return jwtFromHeader.replace('JWT ', '')\n }\n // allow RFC6750 OAuth 2.0 compliant Bearer tokens\n // in addition to the payload default JWT format\n if (jwtFromHeader?.startsWith('Bearer ')) {\n return jwtFromHeader.replace('Bearer ', '')\n }\n\n const cookies = parseCookies(headers)\n const tokenCookieName = `${payload.config.cookiePrefix}-token`\n const cookieToken = cookies.get(tokenCookieName)\n\n if (!cookieToken) {\n return null\n }\n\n if (!origin || payload.config.csrf.length === 0 || payload.config.csrf.indexOf(origin) > -1) {\n return cookieToken\n }\n\n return null\n}\n"],"names":["parseCookies","extractJWT","args","headers","payload","jwtFromHeader","get","origin","startsWith","replace","cookies","tokenCookieName","config","cookiePrefix","cookieToken","csrf","length","indexOf"],"mappings":"AAEA,SAASA,YAAY,QAAQ,+BAA8B;AAE3D,OAAO,MAAMC,aAAa,CAACC;IACzB,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAE,GAAGF;IAE7B,MAAMG,gBAAgBF,QAAQG,GAAG,CAAC;IAClC,MAAMC,SAASJ,QAAQG,GAAG,CAAC;IAE3B,IAAID,eAAeG,WAAW,SAAS;QACrC,OAAOH,cAAcI,OAAO,CAAC,QAAQ;IACvC;IACA,kDAAkD;IAClD,gDAAgD;IAChD,IAAIJ,eAAeG,WAAW,YAAY;QACxC,OAAOH,cAAcI,OAAO,CAAC,WAAW;IAC1C;IAEA,MAAMC,UAAUV,aAAaG;IAC7B,MAAMQ,kBAAkB,GAAGP,QAAQQ,MAAM,CAACC,YAAY,CAAC,MAAM,CAAC;IAC9D,MAAMC,cAAcJ,QAAQJ,GAAG,CAACK;IAEhC,IAAI,CAACG,aAAa;QAChB,OAAO;IACT;IAEA,IAAI,CAACP,UAAUH,QAAQQ,MAAM,CAACG,IAAI,CAACC,MAAM,KAAK,KAAKZ,QAAQQ,MAAM,CAACG,IAAI,CAACE,OAAO,CAACV,UAAU,CAAC,GAAG;QAC3F,OAAOO;IACT;IAEA,OAAO;AACT,EAAC"}
@@ -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 {\n AuthOperationsFromCollectionSlug,\n Collection,\n} from '../../collections/config/types.js'\nimport type { CollectionSlug } from '../../index.js'\nimport type { PayloadRequest, Where } 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'\nimport { getLoginOptions } from '../getLoginOptions.js'\n\nexport type Arguments<TSlug extends CollectionSlug> = {\n collection: Collection\n data: {\n [key: string]: unknown\n } & AuthOperationsFromCollectionSlug<TSlug>['forgotPassword']\n disableEmail?: boolean\n expiration?: number\n req: PayloadRequest\n}\n\nexport type Result = string\n\nexport const forgotPasswordOperation = async <TSlug extends CollectionSlug>(\n incomingArgs: Arguments<TSlug>,\n): Promise<null | string> => {\n const loginWithUsername = incomingArgs.collection.config.auth.loginWithUsername\n const { data } = incomingArgs\n\n const { canLoginWithEmail, canLoginWithUsername } = getLoginOptions(loginWithUsername)\n\n const sanitizedEmail =\n (canLoginWithEmail && (incomingArgs.data.email || '').toLowerCase().trim()) || null\n const sanitizedUsername =\n 'username' in data && typeof data?.username === 'string'\n ? data.username.toLowerCase().trim()\n : null\n\n if (!sanitizedEmail && !sanitizedUsername) {\n throw new APIError(\n `Missing ${loginWithUsername ? 'username' : 'email'}.`,\n httpStatus.BAD_REQUEST,\n )\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 type UserDoc = {\n email?: string\n id: number | string\n resetPasswordExpiration?: string\n resetPasswordToken?: string\n }\n\n if (!sanitizedEmail && !sanitizedUsername) {\n throw new APIError(\n `Missing ${loginWithUsername ? 'username' : 'email'}.`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n let whereConstraint: Where = {}\n\n if (canLoginWithEmail && sanitizedEmail) {\n whereConstraint = {\n email: {\n equals: sanitizedEmail,\n },\n }\n } else if (canLoginWithUsername && sanitizedUsername) {\n whereConstraint = {\n username: {\n equals: sanitizedUsername,\n },\n }\n }\n\n let user = await payload.db.findOne<UserDoc>({\n collection: collectionConfig.slug,\n req,\n where: whereConstraint,\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) {\n return null\n }\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 && user.email) {\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}${config.admin.routes.reset}/${token}\">${serverURL}${config.routes.admin}${config.admin.routes.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: user.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) {\n await commitTransaction(req)\n }\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","getLoginOptions","forgotPasswordOperation","incomingArgs","loginWithUsername","collection","config","auth","data","canLoginWithEmail","canLoginWithUsername","sanitizedEmail","email","toLowerCase","trim","sanitizedUsername","username","BAD_REQUEST","args","shouldCommit","req","hooks","beforeOperation","reduce","priorHook","hook","context","operation","Promise","resolve","collectionConfig","disableEmail","expiration","payload","token","randomBytes","toString","whereConstraint","equals","user","db","findOne","slug","where","resetPasswordToken","resetPasswordExpiration","Date","now","toISOString","update","id","protocol","url","serverURL","headers","get","html","t","routes","admin","reset","forgotPassword","generateEmailHTML","subject","generateEmailSubject","sendEmail","from","defaultFromName","defaultFromAddress","to","afterForgotPassword","result","error"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAC3B,OAAOC,gBAAgB,cAAa;AACpC,SAASC,GAAG,QAAQ,MAAK;AASzB,SAASC,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,wBAAuB;AAcvD,OAAO,MAAMC,0BAA0B,OACrCC;IAEA,MAAMC,oBAAoBD,aAAaE,UAAU,CAACC,MAAM,CAACC,IAAI,CAACH,iBAAiB;IAC/E,MAAM,EAAEI,IAAI,EAAE,GAAGL;IAEjB,MAAM,EAAEM,iBAAiB,EAAEC,oBAAoB,EAAE,GAAGT,gBAAgBG;IAEpE,MAAMO,iBACJ,AAACF,qBAAqB,AAACN,CAAAA,aAAaK,IAAI,CAACI,KAAK,IAAI,EAAC,EAAGC,WAAW,GAAGC,IAAI,MAAO;IACjF,MAAMC,oBACJ,cAAcP,QAAQ,OAAOA,MAAMQ,aAAa,WAC5CR,KAAKQ,QAAQ,CAACH,WAAW,GAAGC,IAAI,KAChC;IAEN,IAAI,CAACH,kBAAkB,CAACI,mBAAmB;QACzC,MAAM,IAAIlB,SACR,CAAC,QAAQ,EAAEO,oBAAoB,aAAa,QAAQ,CAAC,CAAC,EACtDV,WAAWuB,WAAW;IAE1B;IAEA,IAAIC,OAAOf;IAEX,IAAI;QACF,MAAMgB,eAAe,MAAMpB,gBAAgBmB,KAAKE,GAAG;QAEnD,wCAAwC;QACxC,+BAA+B;QAC/B,wCAAwC;QAExC,MAAMF,KAAKb,UAAU,CAACC,MAAM,CAACe,KAAK,CAACC,eAAe,CAACC,MAAM,CAAC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F;YAEA,MAAM3B,MAAMqD,SAAS,CAAC;gBACpBC,MAAM,CAAC,CAAC,EAAEtD,MAAMuD,eAAe,CAAC,GAAG,EAAEvD,MAAMwD,kBAAkB,CAAC,CAAC,CAAC;gBAChEZ;gBACAO;gBACAM,IAAI9B,KAAK3B,KAAK;YAChB;QACF;QAEA,wCAAwC;QACxC,mCAAmC;QACnC,wCAAwC;QAExC,MAAMkB,iBAAiBT,KAAK,CAACiD,mBAAmB,CAAC/C,MAAM,CAAC,OAAOC,WAAWC;YACxE,MAAMD;YACN,MAAMC,KAAK;gBAAEP;gBAAMb,YAAYa,KAAKb,UAAU,EAAEC;gBAAQoB,SAASN,IAAIM,OAAO;YAAC;QAC/E,GAAGE,QAAQC,OAAO;QAElB,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExCK,QAAQ,MAAMtC,oBAAoB;YAChCsB;YACAb,YAAYa,KAAKb,UAAU,EAAEC;YAC7BqB,WAAW;YACX4C,QAAQrC;QACV;QAEA,IAAIf,cAAc;YAChB,MAAMrB,kBAAkBsB;QAC1B;QAEA,OAAOc;IACT,EAAE,OAAOsC,OAAgB;QACvB,MAAMxE,gBAAgBkB,KAAKE,GAAG;QAC9B,MAAMoD;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 {\n AuthOperationsFromCollectionSlug,\n Collection,\n} from '../../collections/config/types.js'\nimport type { CollectionSlug } from '../../index.js'\nimport type { PayloadRequest, Where } 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'\nimport { getLoginOptions } from '../getLoginOptions.js'\n\nexport type Arguments<TSlug extends CollectionSlug> = {\n collection: Collection\n data: {\n [key: string]: unknown\n } & AuthOperationsFromCollectionSlug<TSlug>['forgotPassword']\n disableEmail?: boolean\n expiration?: number\n req: PayloadRequest\n}\n\nexport type Result = string\n\nexport const forgotPasswordOperation = async <TSlug extends CollectionSlug>(\n incomingArgs: Arguments<TSlug>,\n): Promise<null | string> => {\n const loginWithUsername = incomingArgs.collection.config.auth.loginWithUsername\n const { data } = incomingArgs\n\n const { canLoginWithEmail, canLoginWithUsername } = getLoginOptions(loginWithUsername)\n\n const sanitizedEmail =\n (canLoginWithEmail && (incomingArgs.data.email || '').toLowerCase().trim()) || null\n const sanitizedUsername =\n 'username' in data && typeof data?.username === 'string'\n ? data.username.toLowerCase().trim()\n : null\n\n if (!sanitizedEmail && !sanitizedUsername) {\n throw new APIError(\n `Missing ${loginWithUsername ? 'username' : 'email'}.`,\n httpStatus.BAD_REQUEST,\n )\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 type UserDoc = {\n email?: string\n id: number | string\n resetPasswordExpiration?: string\n resetPasswordToken?: string\n }\n\n if (!sanitizedEmail && !sanitizedUsername) {\n throw new APIError(\n `Missing ${loginWithUsername ? 'username' : 'email'}.`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n let whereConstraint: Where = {}\n\n if (canLoginWithEmail && sanitizedEmail) {\n whereConstraint = {\n email: {\n equals: sanitizedEmail,\n },\n }\n } else if (canLoginWithUsername && sanitizedUsername) {\n whereConstraint = {\n username: {\n equals: sanitizedUsername,\n },\n }\n }\n\n let user = await payload.db.findOne<UserDoc>({\n collection: collectionConfig.slug,\n req,\n where: whereConstraint,\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) {\n return null\n }\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 && user.email) {\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}${config.admin.routes.reset}/${token}\">${serverURL}${config.routes.admin}${config.admin.routes.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: user.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) {\n await commitTransaction(req)\n }\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","getLoginOptions","forgotPasswordOperation","incomingArgs","loginWithUsername","collection","config","auth","data","canLoginWithEmail","canLoginWithUsername","sanitizedEmail","email","toLowerCase","trim","sanitizedUsername","username","BAD_REQUEST","args","shouldCommit","req","hooks","beforeOperation","reduce","priorHook","hook","context","operation","Promise","resolve","collectionConfig","disableEmail","expiration","payload","token","randomBytes","toString","whereConstraint","equals","user","db","findOne","slug","where","resetPasswordToken","resetPasswordExpiration","Date","now","toISOString","update","id","protocol","url","serverURL","headers","get","html","t","routes","admin","reset","forgotPassword","generateEmailHTML","subject","generateEmailSubject","sendEmail","from","defaultFromName","defaultFromAddress","to","afterForgotPassword","result","error"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAC3B,OAAOC,gBAAgB,cAAa;AACpC,SAASC,GAAG,QAAQ,MAAK;AASzB,SAASC,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,wBAAuB;AAcvD,OAAO,MAAMC,0BAA0B,OACrCC;IAEA,MAAMC,oBAAoBD,aAAaE,UAAU,CAACC,MAAM,CAACC,IAAI,CAACH,iBAAiB;IAC/E,MAAM,EAAEI,IAAI,EAAE,GAAGL;IAEjB,MAAM,EAAEM,iBAAiB,EAAEC,oBAAoB,EAAE,GAAGT,gBAAgBG;IAEpE,MAAMO,iBACJ,AAACF,qBAAqB,AAACN,CAAAA,aAAaK,IAAI,CAACI,KAAK,IAAI,EAAC,EAAGC,WAAW,GAAGC,IAAI,MAAO;IACjF,MAAMC,oBACJ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","sources":["../../../src/auth/operations/login.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gCAAgC,EAChC,UAAU,EACV,sBAAsB,EACvB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAS,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAevC,MAAM,MAAM,MAAM,GAAG;IACnB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,IAAI,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,SAAS,CAAC,KAAK,SAAS,cAAc,IAAI;IACpD,UAAU,EAAE,UAAU,CAAA;IACtB,IAAI,EAAE,gCAAgC,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAA;IACtD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,EAAE,cAAc,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,cAAc,GAAU,KAAK,SAAS,cAAc,gBACjD,SAAS,CAAC,KAAK,CAAC,KAC7B,OAAO,CAAC;IAAE,IAAI,EAAE,sBAAsB,CAAC,KAAK,CAAC,CAAA;CAAE,GAAG,MAAM,CAyS1D,CAAA"}
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/login.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gCAAgC,EAChC,UAAU,EACV,sBAAsB,EACvB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAS,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAevC,MAAM,MAAM,MAAM,GAAG;IACnB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,IAAI,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,SAAS,CAAC,KAAK,SAAS,cAAc,IAAI;IACpD,UAAU,EAAE,UAAU,CAAA;IACtB,IAAI,EAAE,gCAAgC,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAA;IACtD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,EAAE,cAAc,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,cAAc,GAAU,KAAK,SAAS,cAAc,gBACjD,SAAS,CAAC,KAAK,CAAC,KAC7B,OAAO,CAAC;IAAE,IAAI,EAAE,sBAAsB,CAAC,KAAK,CAAC,CAAA;CAAE,GAAG,MAAM,CAyR1D,CAAA"}
@@ -229,18 +229,6 @@ export const loginOperation = async (incomingArgs)=>{
229
229
  req
230
230
  }) || user;
231
231
  }, Promise.resolve());
232
- // /////////////////////////////////////
233
- // afterRead - Collection
234
- // /////////////////////////////////////
235
- await collectionConfig.hooks.afterRead.reduce(async (priorHook, hook)=>{
236
- await priorHook;
237
- user = await hook({
238
- collection: args.collection?.config,
239
- context: req.context,
240
- doc: user,
241
- req
242
- }) || user;
243
- }, Promise.resolve());
244
232
  let result = {
245
233
  exp,
246
234
  token,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/auth/operations/login.ts"],"sourcesContent":["import type {\n AuthOperationsFromCollectionSlug,\n Collection,\n DataFromCollectionSlug,\n} from '../../collections/config/types.js'\nimport type { CollectionSlug } from '../../index.js'\nimport type { PayloadRequest, Where } from '../../types/index.js'\nimport type { User } from '../types.js'\n\nimport { buildAfterOperation } from '../../collections/operations/utils.js'\nimport { AuthenticationError, LockedAuth, ValidationError } from '../../errors/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport sanitizeInternalFields from '../../utilities/sanitizeInternalFields.js'\nimport { getFieldsToSign } from '../getFieldsToSign.js'\nimport { getLoginOptions } from '../getLoginOptions.js'\nimport isLocked from '../isLocked.js'\nimport { jwtSign } from '../jwt.js'\nimport { authenticateLocalStrategy } from '../strategies/local/authenticate.js'\nimport { incrementLoginAttempts } from '../strategies/local/incrementLoginAttempts.js'\nimport { resetLoginAttempts } from '../strategies/local/resetLoginAttempts.js'\n\nexport type Result = {\n exp?: number\n token?: string\n user?: User\n}\n\nexport type Arguments<TSlug extends CollectionSlug> = {\n collection: Collection\n data: AuthOperationsFromCollectionSlug<TSlug>['login']\n depth?: number\n overrideAccess?: boolean\n req: PayloadRequest\n showHiddenFields?: boolean\n}\n\nexport const loginOperation = async <TSlug extends CollectionSlug>(\n incomingArgs: Arguments<TSlug>,\n): Promise<{ user: DataFromCollectionSlug<TSlug> } & Result> => {\n let args = incomingArgs\n\n try {\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: 'login',\n req: args.req,\n })) || args\n }, Promise.resolve())\n\n const {\n collection: { config: collectionConfig },\n data,\n depth,\n overrideAccess,\n req,\n req: {\n fallbackLocale,\n locale,\n payload,\n payload: { secret },\n },\n showHiddenFields,\n } = args\n\n // /////////////////////////////////////\n // Login\n // /////////////////////////////////////\n\n let user\n const { email: unsanitizedEmail, password } = data\n const loginWithUsername = collectionConfig.auth.loginWithUsername\n\n const sanitizedEmail =\n typeof unsanitizedEmail === 'string' ? unsanitizedEmail.toLowerCase().trim() : null\n const sanitizedUsername =\n 'username' in data && typeof data?.username === 'string'\n ? data.username.toLowerCase().trim()\n : null\n\n const { canLoginWithEmail, canLoginWithUsername } = getLoginOptions(loginWithUsername)\n\n // cannot login with email, did not provide username\n if (!canLoginWithEmail && !sanitizedUsername) {\n throw new ValidationError({\n collection: collectionConfig.slug,\n errors: [{ message: req.i18n.t('validation:required'), path: 'username' }],\n })\n }\n\n // cannot login with username, did not provide email\n if (!canLoginWithUsername && !sanitizedEmail) {\n throw new ValidationError({\n collection: collectionConfig.slug,\n errors: [{ message: req.i18n.t('validation:required'), path: 'email' }],\n })\n }\n\n // can login with either email or username, did not provide either\n if (!sanitizedUsername && !sanitizedEmail) {\n throw new ValidationError({\n collection: collectionConfig.slug,\n errors: [\n { message: req.i18n.t('validation:required'), path: 'email' },\n { message: req.i18n.t('validation:required'), path: 'username' },\n ],\n })\n }\n\n // did not provide password for login\n if (typeof password !== 'string' || password.trim() === '') {\n throw new ValidationError({\n collection: collectionConfig.slug,\n errors: [{ message: req.i18n.t('validation:required'), path: 'password' }],\n })\n }\n\n let whereConstraint: Where = {}\n const emailConstraint: Where = {\n email: {\n equals: sanitizedEmail,\n },\n }\n const usernameConstraint: Where = {\n username: {\n equals: sanitizedUsername,\n },\n }\n\n if (canLoginWithEmail && canLoginWithUsername && (sanitizedUsername || sanitizedEmail)) {\n if (sanitizedUsername) {\n whereConstraint = {\n or: [\n usernameConstraint,\n {\n email: {\n equals: sanitizedUsername,\n },\n },\n ],\n }\n } else {\n whereConstraint = {\n or: [\n emailConstraint,\n {\n username: {\n equals: sanitizedEmail,\n },\n },\n ],\n }\n }\n } else if (canLoginWithEmail && sanitizedEmail) {\n whereConstraint = emailConstraint\n } else if (canLoginWithUsername && sanitizedUsername) {\n whereConstraint = usernameConstraint\n }\n\n user = await payload.db.findOne<any>({\n collection: collectionConfig.slug,\n req,\n where: whereConstraint,\n })\n\n if (!user || (args.collection.config.auth.verify && user._verified === false)) {\n throw new AuthenticationError(req.t, Boolean(canLoginWithUsername && sanitizedUsername))\n }\n\n user.collection = collectionConfig.slug\n\n if (isLocked(new Date(user.lockUntil).getTime())) {\n throw new LockedAuth(req.t)\n }\n\n const authResult = await authenticateLocalStrategy({ doc: user, password })\n\n user = sanitizeInternalFields(user)\n\n const maxLoginAttemptsEnabled = args.collection.config.auth.maxLoginAttempts > 0\n\n if (!authResult) {\n if (maxLoginAttemptsEnabled) {\n await incrementLoginAttempts({\n collection: collectionConfig,\n doc: user,\n payload: req.payload,\n req,\n })\n }\n\n throw new AuthenticationError(req.t)\n }\n\n if (maxLoginAttemptsEnabled) {\n await resetLoginAttempts({\n collection: collectionConfig,\n doc: user,\n payload: req.payload,\n req,\n })\n }\n\n const fieldsToSign = getFieldsToSign({\n collectionConfig,\n email: sanitizedEmail,\n user,\n })\n\n // /////////////////////////////////////\n // beforeLogin - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.beforeLogin.reduce(async (priorHook, hook) => {\n await priorHook\n\n user =\n (await hook({\n collection: args.collection?.config,\n context: args.req.context,\n req: args.req,\n user,\n })) || user\n }, Promise.resolve())\n\n const { exp, token } = await jwtSign({\n fieldsToSign,\n secret,\n tokenExpiration: collectionConfig.auth.tokenExpiration,\n })\n\n req.user = user\n\n // /////////////////////////////////////\n // afterLogin - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterLogin.reduce(async (priorHook, hook) => {\n await priorHook\n\n user =\n (await hook({\n collection: args.collection?.config,\n context: args.req.context,\n req: args.req,\n token,\n user,\n })) || user\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n user = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth,\n doc: user,\n draft: undefined,\n fallbackLocale,\n global: null,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n user =\n (await hook({\n collection: args.collection?.config,\n context: req.context,\n doc: user,\n req,\n })) || user\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n user =\n (await hook({\n collection: args.collection?.config,\n context: req.context,\n doc: user,\n req,\n })) || user\n }, Promise.resolve())\n\n let result: { user: DataFromCollectionSlug<TSlug> } & Result = {\n exp,\n token,\n user,\n }\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: args.collection?.config,\n operation: 'login',\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["buildAfterOperation","AuthenticationError","LockedAuth","ValidationError","afterRead","killTransaction","sanitizeInternalFields","getFieldsToSign","getLoginOptions","isLocked","jwtSign","authenticateLocalStrategy","incrementLoginAttempts","resetLoginAttempts","loginOperation","incomingArgs","args","collection","config","hooks","beforeOperation","reduce","priorHook","hook","context","req","operation","Promise","resolve","collectionConfig","data","depth","overrideAccess","fallbackLocale","locale","payload","secret","showHiddenFields","user","email","unsanitizedEmail","password","loginWithUsername","auth","sanitizedEmail","toLowerCase","trim","sanitizedUsername","username","canLoginWithEmail","canLoginWithUsername","slug","errors","message","i18n","t","path","whereConstraint","emailConstraint","equals","usernameConstraint","or","db","findOne","where","verify","_verified","Boolean","Date","lockUntil","getTime","authResult","doc","maxLoginAttemptsEnabled","maxLoginAttempts","fieldsToSign","beforeLogin","exp","token","tokenExpiration","afterLogin","draft","undefined","global","result","error"],"mappings":"AASA,SAASA,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,mBAAmB,EAAEC,UAAU,EAAEC,eAAe,QAAQ,wBAAuB;AACxF,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,OAAOC,4BAA4B,4CAA2C;AAC9E,SAASC,eAAe,QAAQ,wBAAuB;AACvD,SAASC,eAAe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CAAwC;QAExC,MAAMR,iBAAiBV,KAAK,CAACf,SAAS,CAACiB,MAAM,CAAC,OAAOC,WAAWC;YAC9D,MAAMD;YAENgB,OACE,AAAC,MAAMf,KAAK;gBACVN,YAAYD,KAAKC,UAAU,EAAEC;gBAC7BM,SAASC,IAAID,OAAO;gBACpBgD,KAAKlC;gBACLb;YACF,MAAOa;QACX,GAAGX,QAAQC,OAAO;QAElB,wCAAwC;QACxC,yBAAyB;QACzB,wCAAwC;QAExC,MAAMC,iBAAiBV,KAAK,CAACf,SAAS,CAACiB,MAAM,CAAC,OAAOC,WAAWC;YAC9D,MAAMD;YAENgB,OACE,AAAC,MAAMf,KAAK;gBACVN,YAAYD,KAAKC,UAAU,EAAEC;gBAC7BM,SAASC,IAAID,OAAO;gBACpBgD,KAAKlC;gBACLb;YACF,MAAOa;QACX,GAAGX,QAAQC,OAAO;QAElB,IAAIwD,SAA2D;YAC7DP;YACAC;YACAxC;QACF;QAEA,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExC8C,SAAS,MAAMpF,oBAAoB;YACjCgB;YACAC,YAAYD,KAAKC,UAAU,EAAEC;YAC7BQ,WAAW;YACX0D;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,OAAOA;IACT,EAAE,OAAOC,OAAgB;QACvB,MAAMhF,gBAAgBW,KAAKS,GAAG;QAC9B,MAAM4D;IACR;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/auth/operations/login.ts"],"sourcesContent":["import type {\n AuthOperationsFromCollectionSlug,\n Collection,\n DataFromCollectionSlug,\n} from '../../collections/config/types.js'\nimport type { CollectionSlug } from '../../index.js'\nimport type { PayloadRequest, Where } from '../../types/index.js'\nimport type { User } from '../types.js'\n\nimport { buildAfterOperation } from '../../collections/operations/utils.js'\nimport { AuthenticationError, LockedAuth, ValidationError } from '../../errors/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport sanitizeInternalFields from '../../utilities/sanitizeInternalFields.js'\nimport { getFieldsToSign } from '../getFieldsToSign.js'\nimport { getLoginOptions } from '../getLoginOptions.js'\nimport isLocked from '../isLocked.js'\nimport { jwtSign } from '../jwt.js'\nimport { authenticateLocalStrategy } from '../strategies/local/authenticate.js'\nimport { incrementLoginAttempts } from '../strategies/local/incrementLoginAttempts.js'\nimport { resetLoginAttempts } from '../strategies/local/resetLoginAttempts.js'\n\nexport type Result = {\n exp?: number\n token?: string\n user?: User\n}\n\nexport type Arguments<TSlug extends CollectionSlug> = {\n collection: Collection\n data: AuthOperationsFromCollectionSlug<TSlug>['login']\n depth?: number\n overrideAccess?: boolean\n req: PayloadRequest\n showHiddenFields?: boolean\n}\n\nexport const loginOperation = async <TSlug extends CollectionSlug>(\n incomingArgs: Arguments<TSlug>,\n): Promise<{ user: DataFromCollectionSlug<TSlug> } & Result> => {\n let args = incomingArgs\n\n try {\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: 'login',\n req: args.req,\n })) || args\n }, Promise.resolve())\n\n const {\n collection: { config: collectionConfig },\n data,\n depth,\n overrideAccess,\n req,\n req: {\n fallbackLocale,\n locale,\n payload,\n payload: { secret },\n },\n showHiddenFields,\n } = args\n\n // /////////////////////////////////////\n // Login\n // /////////////////////////////////////\n\n let user\n const { email: unsanitizedEmail, password } = data\n const loginWithUsername = collectionConfig.auth.loginWithUsername\n\n const sanitizedEmail =\n typeof unsanitizedEmail === 'string' ? unsanitizedEmail.toLowerCase().trim() : null\n const sanitizedUsername =\n 'username' in data && typeof data?.username === 'string'\n ? data.username.toLowerCase().trim()\n : null\n\n const { canLoginWithEmail, canLoginWithUsername } = getLoginOptions(loginWithUsername)\n\n // cannot login with email, did not provide username\n if (!canLoginWithEmail && !sanitizedUsername) {\n throw new ValidationError({\n collection: collectionConfig.slug,\n errors: [{ message: req.i18n.t('validation:required'), path: 'username' }],\n })\n }\n\n // cannot login with username, did not provide email\n if (!canLoginWithUsername && !sanitizedEmail) {\n throw new ValidationError({\n collection: collectionConfig.slug,\n errors: [{ message: req.i18n.t('validation:required'), path: 'email' }],\n })\n }\n\n // can login with either email or username, did not provide either\n if (!sanitizedUsername && !sanitizedEmail) {\n throw new ValidationError({\n collection: collectionConfig.slug,\n errors: [\n { message: req.i18n.t('validation:required'), path: 'email' },\n { message: req.i18n.t('validation:required'), path: 'username' },\n ],\n })\n }\n\n // did not provide password for login\n if (typeof password !== 'string' || password.trim() === '') {\n throw new ValidationError({\n collection: collectionConfig.slug,\n errors: [{ message: req.i18n.t('validation:required'), path: 'password' }],\n })\n }\n\n let whereConstraint: Where = {}\n const emailConstraint: Where = {\n email: {\n equals: sanitizedEmail,\n },\n }\n const usernameConstraint: Where = {\n username: {\n equals: sanitizedUsername,\n },\n }\n\n if (canLoginWithEmail && canLoginWithUsername && (sanitizedUsername || sanitizedEmail)) {\n if (sanitizedUsername) {\n whereConstraint = {\n or: [\n usernameConstraint,\n {\n email: {\n equals: sanitizedUsername,\n },\n },\n ],\n }\n } else {\n whereConstraint = {\n or: [\n emailConstraint,\n {\n username: {\n equals: sanitizedEmail,\n },\n },\n ],\n }\n }\n } else if (canLoginWithEmail && sanitizedEmail) {\n whereConstraint = emailConstraint\n } else if (canLoginWithUsername && sanitizedUsername) {\n whereConstraint = usernameConstraint\n }\n\n user = await payload.db.findOne<any>({\n collection: collectionConfig.slug,\n req,\n where: whereConstraint,\n })\n\n if (!user || (args.collection.config.auth.verify && user._verified === false)) {\n throw new AuthenticationError(req.t, Boolean(canLoginWithUsername && sanitizedUsername))\n }\n\n user.collection = collectionConfig.slug\n\n if (isLocked(new Date(user.lockUntil).getTime())) {\n throw new LockedAuth(req.t)\n }\n\n const authResult = await authenticateLocalStrategy({ doc: user, password })\n\n user = sanitizeInternalFields(user)\n\n const maxLoginAttemptsEnabled = args.collection.config.auth.maxLoginAttempts > 0\n\n if (!authResult) {\n if (maxLoginAttemptsEnabled) {\n await incrementLoginAttempts({\n collection: collectionConfig,\n doc: user,\n payload: req.payload,\n req,\n })\n }\n\n throw new AuthenticationError(req.t)\n }\n\n if (maxLoginAttemptsEnabled) {\n await resetLoginAttempts({\n collection: collectionConfig,\n doc: user,\n payload: req.payload,\n req,\n })\n }\n\n const fieldsToSign = getFieldsToSign({\n collectionConfig,\n email: sanitizedEmail,\n user,\n })\n\n // /////////////////////////////////////\n // beforeLogin - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.beforeLogin.reduce(async (priorHook, hook) => {\n await priorHook\n\n user =\n (await hook({\n collection: args.collection?.config,\n context: args.req.context,\n req: args.req,\n user,\n })) || user\n }, Promise.resolve())\n\n const { exp, token } = await jwtSign({\n fieldsToSign,\n secret,\n tokenExpiration: collectionConfig.auth.tokenExpiration,\n })\n\n req.user = user\n\n // /////////////////////////////////////\n // afterLogin - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterLogin.reduce(async (priorHook, hook) => {\n await priorHook\n\n user =\n (await hook({\n collection: args.collection?.config,\n context: args.req.context,\n req: args.req,\n token,\n user,\n })) || user\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n user = await afterRead({\n collection: collectionConfig,\n context: req.context,\n depth,\n doc: user,\n draft: undefined,\n fallbackLocale,\n global: null,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // afterRead - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n user =\n (await hook({\n collection: args.collection?.config,\n context: req.context,\n doc: user,\n req,\n })) || user\n }, Promise.resolve())\n\n let result: { user: DataFromCollectionSlug<TSlug> } & Result = {\n exp,\n token,\n user,\n }\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: args.collection?.config,\n operation: 'login',\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return result\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["buildAfterOperation","AuthenticationError","LockedAuth","ValidationError","afterRead","killTransaction","sanitizeInternalFields","getFieldsToSign","getLoginOptions","isLocked","jwtSign","authenticateLocalStrategy","incrementLoginAttempts","resetLoginAttempts","loginOperation","incomingArgs","args","collection","config","hooks","beforeOperation","reduce","priorHook","hook","context","req","operation","Promise","resolve","collectionConfig","data","depth","overrideAccess","fallbackLocale","locale","payload","secret","showHiddenFields","user","email","unsanitizedEmail","password","loginWithUsername","auth","sanitizedEmail","toLowerCase","trim","sanitizedUsername","username","canLoginWithEmail","canLoginWithUsername","slug","errors","message","i18n","t","path","whereConstraint","emailConstraint","equals","usernameConstraint","or","db","findOne","where","verify","_verified","Boolean","Date","lockUntil","getTime","authResult","doc","maxLoginAttemptsEnabled","maxLoginAttempts","fieldsToSign","beforeLogin","exp","token","tokenExpiration","afterLogin","draft","undefined","global","result","error"],"mappings":"AASA,SAASA,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,mBAAmB,EAAEC,UAAU,EAAEC,eAAe,QAAQ,wBAAuB;AACxF,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,OAAOC,4BAA4B,4CAA2C;AAC9E,SAASC,eAAe,QAAQ,wBAAuB;AACvD,SAASC,eAAe,QAAQ,wBAAuB;AACvD,OAAOC,cAAc,iBAAgB;AACrC,SAASC,OAAO,QAAQ,YAAW;AACnC,SAASC,yBAAyB,QAAQ,sCAAqC;AAC/E,SAASC,sBAAsB,QAAQ,gDAA+C;AACtF,SAASC,kBAAkB,QAAQ,4CAA2C;AAiB9E,OAAO,MAAMC,iBAAiB,OAC5BC;IAEA,IAAIC,OAAOD;IAEX,IAAI;QACF,wCAAwC;QACx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;YAC7DP;YACAC;YACAxC;QACF;QAEA,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExC8C,SAAS,MAAMpF,oBAAoB;YACjCgB;YACAC,YAAYD,KAAKC,UAAU,EAAEC;YAC7BQ,WAAW;YACX0D;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,OAAOA;IACT,EAAE,OAAOC,OAAgB;QACvB,MAAMhF,gBAAgBW,KAAKS,GAAG;QAC9B,MAAM4D;IACR;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/auth/operations/me.ts"],"sourcesContent":["import { decodeJwt } from 'jose'\n\nimport type { Collection } from '../../collections/config/types.js'\nimport type { PayloadRequest } from '../../types/index.js'\nimport type { ClientUser, User } from '../types.js'\n\nexport type MeOperationResult = {\n collection?: string\n exp?: number\n strategy?: string\n token?: string\n user?: ClientUser\n}\n\nexport type Arguments = {\n collection: Collection\n currentToken?: string\n req: PayloadRequest\n}\n\nexport const meOperation = async (args: Arguments): Promise<MeOperationResult> => {\n const { collection, currentToken, req } = args\n\n let result: MeOperationResult = {\n user: null,\n }\n\n if (req.user) {\n const { pathname } = req\n const isGraphQL = pathname === `/api${req.payload.config.routes.graphQL}`\n\n const user = (await req.payload.findByID({\n id: req.user.id,\n collection: collection.config.slug,\n depth: isGraphQL ? 0 : collection.config.auth.depth,\n overrideAccess: false,\n req,\n showHiddenFields: false,\n })) as User\n\n if (user) {\n user.collection = collection.config.slug\n }\n\n if (req.user.collection !== collection.config.slug) {\n return {\n user: null,\n }\n }\n\n // /////////////////////////////////////\n // me hook - Collection\n // /////////////////////////////////////\n\n for (const meHook of collection.config.hooks.me) {\n const hookResult = await meHook({ args, user })\n\n if (hookResult) {\n result.user = hookResult.user\n result.exp = hookResult.exp\n\n break\n }\n }\n\n result.collection = req.user.collection\n result.strategy = req.user._strategy\n\n if (!result.user) {\n result.user = user\n\n if (currentToken) {\n const decoded = decodeJwt(currentToken)\n if (decoded) {\n result.exp = decoded.exp\n }\n if (!collection.config.auth.removeTokenFromResponses) {\n result.token = currentToken\n }\n }\n }\n }\n\n // /////////////////////////////////////\n // After Me - Collection\n // /////////////////////////////////////\n\n await collection.config.hooks.afterMe.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n collection: collection?.config,\n context: req.context,\n req,\n response: result,\n })) || result\n }, Promise.resolve())\n\n return result\n}\n"],"names":["decodeJwt","meOperation","args","collection","currentToken","req","result","user","pathname","isGraphQL","payload","config","routes","graphQL","findByID","id","slug","depth","auth","overrideAccess","showHiddenFields","meHook","hooks","me","hookResult","exp","strategy","_strategy","decoded","removeTokenFromResponses","token","afterMe","reduce","priorHook","hook","context","response","Promise","resolve"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAM;AAoBhC,OAAO,MAAMC,cAAc,OAAOC;IAChC,MAAM,EAAEC,UAAU,EAAEC,YAAY,EAAEC,GAAG,EAAE,GAAGH;IAE1C,IAAII,SAA4B;QAC9BC,MAAM;IACR;IAEA,IAAIF,IAAIE,IAAI,EAAE;QACZ,MAAM,EAAEC,QAAQ,EAAE,GAAGH;QACrB,MAAMI,YAAYD,aAAa,CAAC,IAAI,EAAEH,IAAIK,OAAO,CAACC,MAAM,CAACC,MAAM,CAACC,OAAO,CAAC,CAAC;QAEzE,MAAMN,OAAQ,MAAMF,IAAIK,OAAO,CAACI,QAAQ,CAAC;YACvCC,IAAIV,IAAIE,IAAI,CAACQ,EAAE;YACfZ,YAAYA,WAAWQ,MAAM,CAACK,IAAI;YAClCC,OAAOR,YAAY,IAAIN,WAAWQ,MAAM,CAACO,IAAI,CAACD,KAAK;YACnDE,gBAAgB;YAChBd;YACAe,kBAAkB;QACpB;QAEA,IAAIb,MAAM;YACRA,KAAKJ,UAAU,GAAGA,WAAWQ,MAAM,CAACK,IAAI;QAC1C;QAEA,IAAIX,IAAIE,IAAI,CAACJ,UAAU,KAAKA,WAAWQ,MAAM,CAACK,IAAI,EAAE;YAClD,OAAO;gBACLT,MAAM;YACR;QACF;QAEA,wCAAwC;QACxC,uBAAuB;QACvB,wCAAwC;QAExC,KAAK,MAAMc,UAAUlB,WAAWQ,MAAM,CAACW,KAAK,CAACC,EAAE,CAAE;YAC/C,MAAMC,aAAa,MAAMH,OAAO;gBAAEnB;gBAAMK;YAAK;YAE7C,IAAIiB,YAAY;gBACdlB,OAAOC,IAAI,GAAGiB,WAAWjB,IAAI;gBAC7BD,OAAOmB,GAAG,GAAGD,WAAWC,GAAG;gBAE3B;YACF;QACF;QAEAnB,OAAOH,UAAU,GAAGE,IAAIE,IAAI,CAACJ,UAAU;QACvCG,OAAOoB,QAAQ,GAAGrB,IAAIE,IAAI,CAACoB,SAAS;QAEpC,IAAI,CAACrB,OAAOC,IAAI,EAAE;YAChBD,OAAOC,IAAI,GAAGA;YAEd,IAAIH,cAAc;gBAChB,MAAMwB,UAAU5B,UAAUI;gBAC1B,IAAIwB,SAAS;oBACXtB,OAAOmB,GAAG,GAAGG,QAAQH,GAAG;gBAC1B;gBACA,IAAI,CAACtB,WAAWQ,MAAM,CAACO,IAAI,CAACW,wBAAwB,EAAE;oBACpDvB,OAAOwB,KAAK,GAAG1B;gBACjB;YACF;QACF;IACF;IAEA,wCAAwC;IACxC,wBAAwB;IACxB,wCAAwC;IAExC,MAAMD,WAAWQ,MAAM,CAACW,KAAK,CAACS,OAAO,CAACC,MAAM,CAAC,OAAOC,WAAWC;QAC7D,MAAMD;QAEN3B,SACE,AAAC,MAAM4B,KAAK;YACV/B,YAAYA,YAAYQ;YACxBwB,SAAS9B,IAAI8B,OAAO;YACpB9B;YACA+B,UAAU9B;QACZ,MAAOA;IACX,GAAG+B,QAAQC,OAAO;IAElB,OAAOhC;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../src/auth/operations/me.ts"],"sourcesContent":["import { decodeJwt } from 'jose'\n\nimport type { Collection } from '../../collections/config/types.js'\nimport type { PayloadRequest } from '../../types/index.js'\nimport type { ClientUser, User } from '../types.js'\n\nexport type MeOperationResult = {\n collection?: string\n exp?: number\n strategy?: string\n token?: string\n user?: ClientUser\n}\n\nexport type Arguments = {\n collection: Collection\n currentToken?: string\n req: PayloadRequest\n}\n\nexport const meOperation = async (args: Arguments): Promise<MeOperationResult> => {\n const { collection, currentToken, req } = args\n\n let result: MeOperationResult = {\n user: null,\n }\n\n if (req.user) {\n const { pathname } = req\n const isGraphQL = pathname === `/api${req.payload.config.routes.graphQL}`\n\n const user = (await req.payload.findByID({\n id: req.user.id,\n collection: collection.config.slug,\n depth: isGraphQL ? 0 : collection.config.auth.depth,\n overrideAccess: false,\n req,\n showHiddenFields: false,\n })) as User\n\n if (user) {\n user.collection = collection.config.slug\n }\n\n if (req.user.collection !== collection.config.slug) {\n return {\n user: null,\n }\n }\n\n // /////////////////////////////////////\n // me hook - Collection\n // /////////////////////////////////////\n\n for (const meHook of collection.config.hooks.me) {\n const hookResult = await meHook({ args, user })\n\n if (hookResult) {\n result.user = hookResult.user\n result.exp = hookResult.exp\n\n break\n }\n }\n\n result.collection = req.user.collection\n result.strategy = req.user._strategy\n\n if (!result.user) {\n result.user = user\n\n if (currentToken) {\n const decoded = decodeJwt(currentToken)\n if (decoded) {\n result.exp = decoded.exp\n }\n if (!collection.config.auth.removeTokenFromResponses) {\n result.token = currentToken\n }\n }\n }\n }\n\n // /////////////////////////////////////\n // After Me - Collection\n // /////////////////////////////////////\n\n await collection.config.hooks.afterMe.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n collection: collection?.config,\n context: req.context,\n req,\n response: result,\n })) || result\n }, Promise.resolve())\n\n return result\n}\n"],"names":["decodeJwt","meOperation","args","collection","currentToken","req","result","user","pathname","isGraphQL","payload","config","routes","graphQL","findByID","id","slug","depth","auth","overrideAccess","showHiddenFields","meHook","hooks","me","hookResult","exp","strategy","_strategy","decoded","removeTokenFromResponses","token","afterMe","reduce","priorHook","hook","context","response","Promise","resolve"],"mappings":"AAAA,SAASA,SAAS,QAAQ,OAAM;AAoBh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AGA;YAEd,IAAIH,cAAc;gBAChB,MAAMwB,UAAU5B,UAAUI;gBAC1B,IAAIwB,SAAS;oBACXtB,OAAOmB,GAAG,GAAGG,QAAQH,GAAG;gBAC1B;gBACA,IAAI,CAACtB,WAAWQ,MAAM,CAACO,IAAI,CAACW,wBAAwB,EAAE;oBACpDvB,OAAOwB,KAAK,GAAG1B;gBACjB;YACF;QACF;IACF;IAEA,wCAAwC;IACxC,wBAAwB;IACxB,wCAAwC;IAExC,MAAMD,WAAWQ,MAAM,CAACW,KAAK,CAACS,OAAO,CAACC,MAAM,CAAC,OAAOC,WAAWC;QAC7D,MAAMD;QAEN3B,SACE,AAAC,MAAM4B,KAAK;YACV/B,YAAYA,YAAYQ;YACxBwB,SAAS9B,IAAI8B,OAAO;YACpB9B;YACA+B,UAAU9B;QACZ,MAAOA;IACX,GAAG+B,QAAQC,OAAO;IAElB,OAAOhC;AACT,EAAC"}
@@ -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 { PayloadRequest } 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: PayloadRequest\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"],"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,MAAMH,MAAMoB,SAAS,CAAC;YACpBC,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 { PayloadRequest } 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: PayloadRequest\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"],"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,GAAGF,SAAS,EAAE,EAAEH,IAAIM,OAAO,CAACC,GAAG,CAAC,SAAS;QAE/C,MAAMC,kBAAkB,GAAGH,YAAYT,OAAOa,MAAM,CAACC,KAAK,CAAC,CAAC,EAAEb,iBAAiBc,IAAI,CAAC,QAAQ,EAAEV,OAAO;QAErG,IAAIW,OAAO,GAAGZ,IAAIa,CAAC,CAAC,oCAAoC;YACtDR,WAAWT,OAAOS,SAAS;YAC3BG;QACF,IAAI;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,MAAMH,MAAMoB,SAAS,CAAC;YACpBC,MAAM,CAAC,CAAC,EAAErB,MAAMsB,eAAe,CAAC,GAAG,EAAEtB,MAAMuB,kBAAkB,CAAC,CAAC,CAAC;YAChEV;YACAK;YACAM,IAAIrB,KAAKH,KAAK;QAChB;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/auth/strategies/apiKey.ts"],"sourcesContent":["import crypto from 'crypto'\n\nimport type { SanitizedCollectionConfig } from '../../collections/config/types.js'\nimport type { Where } from '../../types/index.js'\nimport type { AuthStrategyFunction, User } from '../index.js'\n\nexport const APIKeyAuthentication =\n (collectionConfig: SanitizedCollectionConfig): AuthStrategyFunction =>\n async ({ headers, payload }) => {\n const authHeader = headers.get('Authorization')\n\n if (authHeader?.startsWith(`${collectionConfig.slug} API-Key `)) {\n const apiKey = authHeader.replace(`${collectionConfig.slug} API-Key `, '')\n const apiKeyIndex = crypto.createHmac('sha1', payload.secret).update(apiKey).digest('hex')\n\n try {\n const where: Where = {}\n if (collectionConfig.auth?.verify) {\n where.and = [\n {\n apiKeyIndex: {\n equals: apiKeyIndex,\n },\n },\n {\n _verified: {\n not_equals: false,\n },\n },\n ]\n } else {\n where.apiKeyIndex = {\n equals: apiKeyIndex,\n }\n }\n\n const userQuery = await payload.find({\n collection: collectionConfig.slug,\n depth: collectionConfig.auth.depth,\n limit: 1,\n overrideAccess: true,\n pagination: false,\n where,\n })\n\n if (userQuery.docs && userQuery.docs.length > 0) {\n const user = userQuery.docs[0]\n user.collection = collectionConfig.slug\n user._strategy = 'api-key'\n\n return {\n user: user as User,\n }\n }\n } catch (err) {\n return { user: null }\n }\n }\n\n return { user: null }\n }\n"],"names":["crypto","APIKeyAuthentication","collectionConfig","headers","payload","authHeader","get","startsWith","slug","apiKey","replace","apiKeyIndex","createHmac","secret","update","digest","where","auth","verify","and","equals","_verified","not_equals","userQuery","find","collection","depth","limit","overrideAccess","pagination","docs","length","user","_strategy","err"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAM3B,OAAO,MAAMC,uBACX,CAACC,mBACD,OAAO,EAAEC,OAAO,EAAEC,OAAO,EAAE;QACzB,MAAMC,aAAaF,QAAQG,GAAG,CAAC;QAE/B,IAAID,YAAYE,WAAW,CAAC,EAAEL,iBAAiBM,IAAI,CAAC,SAAS,CAAC,GAAG;YAC/D,MAAMC,SAASJ,WAAWK,OAAO,CAAC,CAAC,EAAER,iBAAiBM,IAAI,CAAC,SAAS,CAAC,EAAE;YACvE,MAAMG,cAAcX,OAAOY,UAAU,CAAC,QAAQR,QAAQS,MAAM,EAAEC,MAAM,CAACL,QAAQM,MAAM,CAAC;YAEpF,IAAI;gBACF,MAAMC,QAAe,CAAC;gBACtB,IAAId,iBAAiBe,IAAI,EAAEC,QAAQ;oBACjCF,MAAMG,GAAG,GAAG;wBACV;4BACER,aAAa;gCACXS,QAAQT;4BACV;wBACF;wBACA;4BACEU,WAAW;gCACTC,YAAY;4BACd;wBACF;qBACD;gBACH,OAAO;oBACLN,MAAML,WAAW,GAAG;wBAClBS,QAAQT;oBACV;gBACF;gBAEA,MAAMY,YAAY,MAAMnB,QAAQoB,IAAI,CAAC;oBACnCC,YAAYvB,iBAAiBM,IAAI;oBACjCkB,OAAOxB,iBAAiBe,IAAI,CAACS,KAAK;oBAClCC,OAAO;oBACPC,gBAAgB;oBAChBC,YAAY;oBACZb;gBACF;gBAEA,IAAIO,UAAUO,IAAI,IAAIP,UAAUO,IAAI,CAACC,MAAM,GAAG,GAAG;oBAC/C,MAAMC,OAAOT,UAAUO,IAAI,CAAC,EAAE;oBAC9BE,KAAKP,UAAU,GAAGvB,iBAAiBM,IAAI;oBACvCwB,KAAKC,SAAS,GAAG;oBAEjB,OAAO;wBACLD,MAAMA;oBACR;gBACF;YACF,EAAE,OAAOE,KAAK;gBACZ,OAAO;oBAAEF,MAAM;gBAAK;YACtB;QACF;QAEA,OAAO;YAAEA,MAAM;QAAK;IACtB,EAAC"}
1
+ {"version":3,"sources":["../../../src/auth/strategies/apiKey.ts"],"sourcesContent":["import crypto from 'crypto'\n\nimport type { SanitizedCollectionConfig } from '../../collections/config/types.js'\nimport type { Where } from '../../types/index.js'\nimport type { AuthStrategyFunction, User } from '../index.js'\n\nexport const APIKeyAuthentication =\n (collectionConfig: SanitizedCollectionConfig): AuthStrategyFunction =>\n async ({ headers, payload }) => {\n const authHeader = headers.get('Authorization')\n\n if (authHeader?.startsWith(`${collectionConfig.slug} API-Key `)) {\n const apiKey = authHeader.replace(`${collectionConfig.slug} API-Key `, '')\n const apiKeyIndex = crypto.createHmac('sha1', payload.secret).update(apiKey).digest('hex')\n\n try {\n const where: Where = {}\n if (collectionConfig.auth?.verify) {\n where.and = [\n {\n apiKeyIndex: {\n equals: apiKeyIndex,\n },\n },\n {\n _verified: {\n not_equals: false,\n },\n },\n ]\n } else {\n where.apiKeyIndex = {\n equals: apiKeyIndex,\n }\n }\n\n const userQuery = await payload.find({\n collection: collectionConfig.slug,\n depth: collectionConfig.auth.depth,\n limit: 1,\n overrideAccess: true,\n pagination: false,\n where,\n })\n\n if (userQuery.docs && userQuery.docs.length > 0) {\n const user = userQuery.docs[0]\n user.collection = collectionConfig.slug\n user._strategy = 'api-key'\n\n return {\n user: user as User,\n }\n }\n } catch (err) {\n return { user: null }\n }\n }\n\n return { user: null }\n }\n"],"names":["crypto","APIKeyAuthentication","collectionConfig","headers","payload","authHeader","get","startsWith","slug","apiKey","replace","apiKeyIndex","createHmac","secret","update","digest","where","auth","verify","and","equals","_verified","not_equals","userQuery","find","collection","depth","limit","overrideAccess","pagination","docs","length","user","_strategy","err"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAM3B,OAAO,MAAMC,uBACX,CAACC,mBACD,OAAO,EAAEC,OAAO,EAAEC,OAAO,EAAE;QACzB,MAAMC,aAAaF,QAAQG,GAAG,CAAC;QAE/B,IAAID,YAAYE,WAAW,GAAGL,iBAAiBM,IAAI,CAAC,SAAS,CAAC,GAAG;YAC/D,MAAMC,SAASJ,WAAWK,OAAO,CAAC,GAAGR,iBAAiBM,IAAI,CAAC,SAAS,CAAC,EAAE;YACvE,MAAMG,cAAcX,OAAOY,UAAU,CAAC,QAAQR,QAAQS,MAAM,EAAEC,MAAM,CAACL,QAAQM,MAAM,CAAC;YAEpF,IAAI;gBACF,MAAMC,QAAe,CAAC;gBACtB,IAAId,iBAAiBe,IAAI,EAAEC,QAAQ;oBACjCF,MAAMG,GAAG,GAAG;wBACV;4BACER,aAAa;gCACXS,QAAQT;4BACV;wBACF;wBACA;4BACEU,WAAW;gCACTC,YAAY;4BACd;wBACF;qBACD;gBACH,OAAO;oBACLN,MAAML,WAAW,GAAG;wBAClBS,QAAQT;oBACV;gBACF;gBAEA,MAAMY,YAAY,MAAMnB,QAAQoB,IAAI,CAAC;oBACnCC,YAAYvB,iBAAiBM,IAAI;oBACjCkB,OAAOxB,iBAAiBe,IAAI,CAACS,KAAK;oBAClCC,OAAO;oBACPC,gBAAgB;oBAChBC,YAAY;oBACZb;gBACF;gBAEA,IAAIO,UAAUO,IAAI,IAAIP,UAAUO,IAAI,CAACC,MAAM,GAAG,GAAG;oBAC/C,MAAMC,OAAOT,UAAUO,IAAI,CAAC,EAAE;oBAC9BE,KAAKP,UAAU,GAAGvB,iBAAiBM,IAAI;oBACvCwB,KAAKC,SAAS,GAAG;oBAEjB,OAAO;wBACLD,MAAMA;oBACR;gBACF;YACF,EAAE,OAAOE,KAAK;gBACZ,OAAO;oBAAEF,MAAM;gBAAK;YACtB;QACF;QAEA,OAAO;YAAEA,MAAM;QAAK;IACtB,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/bin/generateImportMap/index.ts"],"sourcesContent":["import crypto from 'crypto'\nimport fs from 'fs'\nimport process from 'node:process'\nimport path from 'path'\n\nimport type { PayloadComponent, SanitizedConfig } from '../../config/types.js'\n\nimport { iterateConfig } from './iterateConfig.js'\nimport { parsePayloadComponent } from './parsePayloadComponent.js'\n\ntype ImportIdentifier = string\ntype ImportSpecifier = string\ntype ImportPath = string\ntype UserImportPath = string\n\n/**\n * Import Map before being written to the file. Only contains all paths\n */\nexport type InternalImportMap = {\n [path: UserImportPath]: ImportIdentifier\n}\n\n/**\n * Imports of the import map.\n */\nexport type Imports = {\n [identifier: ImportIdentifier]: {\n path: ImportPath\n specifier: ImportSpecifier\n }\n}\n\n/**\n * Import Map after being imported from the actual import map. Contains all the actual imported components\n */\nexport type ImportMap = {\n [path: UserImportPath]: any\n}\n\nexport function addPayloadComponentToImportMap({\n baseDir,\n importMap,\n imports,\n payloadComponent,\n}: {\n baseDir: string\n importMap: InternalImportMap\n imports: Imports\n payloadComponent: PayloadComponent\n}) {\n if (!payloadComponent) {\n return\n }\n const { exportName, path: componentPath } = parsePayloadComponent(payloadComponent)\n\n if (importMap[componentPath + '#' + exportName]) {\n return\n }\n\n const importIdentifier =\n exportName + '_' + crypto.createHash('md5').update(componentPath).digest('hex')\n\n // e.g. if baseDir is /test/fields and componentPath is /components/Field.tsx\n // then path needs to be /test/fields/components/Field.tsx NOT /users/username/project/test/fields/components/Field.tsx\n // so we need to append baseDir to componentPath\n\n if (componentPath.startsWith('.') || componentPath.startsWith('/')) {\n const normalizedBaseDir = baseDir.replace(/\\\\/g, '/')\n\n const finalPath = normalizedBaseDir.startsWith('/../')\n ? `${normalizedBaseDir}${componentPath.slice(1)}`\n : path.posix.join(normalizedBaseDir, componentPath.slice(1))\n\n imports[importIdentifier] = {\n path:\n componentPath.startsWith('.') || componentPath.startsWith('/') ? finalPath : componentPath,\n specifier: exportName,\n }\n } else {\n imports[importIdentifier] = {\n path: componentPath,\n specifier: exportName,\n }\n }\n importMap[componentPath + '#' + exportName] = importIdentifier\n}\n\nexport type AddToImportMap = (payloadComponent: PayloadComponent | PayloadComponent[]) => void\n\nexport async function generateImportMap(\n config: SanitizedConfig,\n options?: { force?: boolean; log: boolean },\n): Promise<void> {\n const shouldLog = options?.log ?? true\n\n if (shouldLog) {\n console.log('Generating import map')\n }\n\n const importMap: InternalImportMap = {}\n const imports: Imports = {}\n\n const rootDir = process.env.ROOT_DIR ?? process.cwd()\n\n // get componentsBaseDir.\n // E.g.:\n // config.admin.importMap.baseDir = /test/fields/\n // rootDir: /\n // componentsBaseDir = /test/fields/\n\n // or\n\n // E.g.:\n // config.admin.importMap.baseDir = /test/fields/\n // rootDir: /test\n // componentsBaseDir = /fields/\n\n // or\n // config.admin.importMap.baseDir = /\n // rootDir: /\n // componentsBaseDir = /\n\n // E.g.:\n // config.admin.importMap.baseDir = /test/fields/\n // rootDir: /test/fields/prod\n // componentsBaseDir = ../\n\n // Check if rootDir is a subdirectory of baseDir\n const baseDir = config.admin.importMap.baseDir\n const isSubdirectory = path.relative(baseDir, rootDir).startsWith('..')\n\n let componentsBaseDir\n\n if (isSubdirectory) {\n // Get the relative path from rootDir to baseDir\n componentsBaseDir = path.relative(rootDir, baseDir)\n } else {\n // If rootDir is not a subdirectory, just return baseDir relative to rootDir\n componentsBaseDir = `/${path.relative(rootDir, baseDir)}`\n }\n\n // Ensure result has a trailing slash\n if (!componentsBaseDir.endsWith('/')) {\n componentsBaseDir += '/'\n }\n\n const addToImportMap: AddToImportMap = (payloadComponent) => {\n if (!payloadComponent) {\n return\n }\n\n if (typeof payloadComponent !== 'object' && typeof payloadComponent !== 'string') {\n console.error(payloadComponent)\n throw new Error('addToImportMap > Payload component must be an object or a string')\n }\n\n if (Array.isArray(payloadComponent)) {\n for (const component of payloadComponent) {\n addPayloadComponentToImportMap({\n baseDir: componentsBaseDir,\n importMap,\n imports,\n payloadComponent: component,\n })\n }\n } else {\n addPayloadComponentToImportMap({\n baseDir: componentsBaseDir,\n importMap,\n imports,\n payloadComponent,\n })\n }\n }\n\n iterateConfig({\n addToImportMap,\n baseDir: config.admin.importMap.baseDir,\n config,\n importMap,\n imports,\n })\n\n await writeImportMap({\n componentMap: importMap,\n config,\n fileName: 'importMap.js',\n force: options?.force,\n importMap: imports,\n log: shouldLog,\n rootDir,\n })\n}\n\nexport async function writeImportMap({\n componentMap,\n config,\n fileName,\n force,\n importMap,\n log,\n rootDir,\n}: {\n componentMap: InternalImportMap\n config: SanitizedConfig\n fileName: string\n force?: boolean\n importMap: Imports\n log?: boolean\n rootDir: string\n}) {\n let importMapFolderPath = ''\n if (fs.existsSync(path.resolve(rootDir, `app/(payload)${config.routes.admin}/`))) {\n importMapFolderPath = path.resolve(rootDir, `app/(payload)${config.routes.admin}/`)\n } else if (fs.existsSync(path.resolve(rootDir, `src/app/(payload)${config.routes.admin}/`))) {\n importMapFolderPath = path.resolve(rootDir, `src/app/(payload)${config.routes.admin}/`)\n } else {\n throw new Error(\n `Could not find the payload admin directory. Looked in ${path.resolve(rootDir, `app/(payload)${config.routes.admin}/`)} and ${path.resolve(rootDir, `src/app/(payload)${config.routes.admin}/`)}`,\n )\n }\n\n const imports: string[] = []\n for (const [identifier, { path, specifier }] of Object.entries(importMap)) {\n imports.push(`import { ${specifier} as ${identifier} } from '${path}'`)\n }\n\n const mapKeys: string[] = []\n for (const [userPath, identifier] of Object.entries(componentMap)) {\n mapKeys.push(` \"${userPath}\": ${identifier}`)\n }\n\n const importMapOutputFile = `${imports.join('\\n')}\n\nexport const importMap = {\n${mapKeys.join(',\\n')}\n}\n`\n\n const importMapFilePath = path.resolve(importMapFolderPath, fileName)\n\n if (!force) {\n // Read current import map and check in the IMPORTS if there are any new imports. If not, don't write the file.\n const currentImportMap = await fs.promises.readFile(importMapFilePath, 'utf-8')\n\n if (currentImportMap?.trim() === importMapOutputFile?.trim()) {\n if (log) {\n console.log('No new imports found, skipping writing import map')\n }\n return\n }\n }\n\n if (log) {\n console.log('Writing import map to', importMapFilePath)\n }\n\n await fs.promises.writeFile(importMapFilePath, importMapOutputFile)\n}\n"],"names":["crypto","fs","process","path","iterateConfig","parsePayloadComponent","addPayloadComponentToImportMap","baseDir","importMap","imports","payloadComponent","exportName","componentPath","importIdentifier","createHash","update","digest","startsWith","normalizedBaseDir","replace","finalPath","slice","posix","join","specifier","generateImportMap","config","options","shouldLog","log","console","rootDir","env","ROOT_DIR","cwd","admin","isSubdirectory","relative","componentsBaseDir","endsWith","addToImportMap","error","Error","Array","isArray","component","writeImportMap","componentMap","fileName","force","importMapFolderPath","existsSync","resolve","routes","identifier","Object","entries","push","mapKeys","userPath","importMapOutputFile","importMapFilePath","currentImportMap","promises","readFile","trim","writeFile"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAC3B,OAAOC,QAAQ,KAAI;AACnB,OAAOC,aAAa,eAAc;AAClC,OAAOC,UAAU,OAAM;AAIvB,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,qBAAqB,QAAQ,6BAA4B;AA+BlE,OAAO,SAASC,+BAA+B,EAC7CC,OAAO,EACPC,SAAS,EACTC,OAAO,EACPC,gBAAgB,EAMjB;IACC,IAAI,CAACA,kBAAkB;QACrB;IACF;IACA,MAAM,EAAEC,UAAU,EAAER,MAAMS,aAAa,EAAE,GAAGP,sBAAsBK;IAElE,IAAIF,SAAS,CAACI,gBAAgB,MAAMD,WAAW,EAAE;QAC/C;IACF;IAEA,MAAME,mBACJF,aAAa,MAAMX,OAAOc,UAAU,CAAC,OAAOC,MAAM,CAACH,eAAeI,MAAM,CAAC;IAE3E,6EAA6E;IAC7E,uHAAuH;IACvH,gDAAgD;IAEhD,IAAIJ,cAAcK,UAAU,CAAC,QAAQL,cAAcK,UAAU,CAAC,MAAM;QAClE,M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AM7D,GAAG8D,QAAQ,CAACC,QAAQ,CAACH,mBAAmB;QAEvE,IAAIC,kBAAkBG,WAAWL,qBAAqBK,QAAQ;YAC5D,IAAIpC,KAAK;gBACPC,QAAQD,GAAG,CAAC;YACd;YACA;QACF;IACF;IAEA,IAAIA,KAAK;QACPC,QAAQD,GAAG,CAAC,yBAAyBgC;IACvC;IAEA,MAAM5D,GAAG8D,QAAQ,CAACG,SAAS,CAACL,mBAAmBD;AACjD"}
1
+ {"version":3,"sources":["../../../src/bin/generateImportMap/index.ts"],"sourcesContent":["import crypto from 'crypto'\nimport fs from 'fs'\nimport process from 'node:process'\nimport path from 'path'\n\nimport type { PayloadComponent, SanitizedConfig } from '../../config/types.js'\n\nimport { iterateConfig } from './iterateConfig.js'\nimport { parsePayloadComponent } from './parsePayloadComponent.js'\n\ntype ImportIdentifier = string\ntype ImportSpecifier = string\ntype ImportPath = string\ntype UserImportPath = string\n\n/**\n * Import Map before being written to the file. Only contains all paths\n */\nexport type InternalImportMap = {\n [path: UserImportPath]: ImportIdentifier\n}\n\n/**\n * Imports of the import map.\n */\nexport type Imports = {\n [identifier: ImportIdentifier]: {\n path: ImportPath\n specifier: ImportSpecifier\n }\n}\n\n/**\n * Import Map after being imported from the actual import map. Contains all the actual imported components\n */\nexport type ImportMap = {\n [path: UserImportPath]: any\n}\n\nexport function addPayloadComponentToImportMap({\n baseDir,\n importMap,\n imports,\n payloadComponent,\n}: {\n baseDir: string\n importMap: InternalImportMap\n imports: Imports\n payloadComponent: PayloadComponent\n}) {\n if (!payloadComponent) {\n return\n }\n const { exportName, path: componentPath } = parsePayloadComponent(payloadComponent)\n\n if (importMap[componentPath + '#' + exportName]) {\n return\n }\n\n const importIdentifier =\n exportName + '_' + crypto.createHash('md5').update(componentPath).digest('hex')\n\n // e.g. if baseDir is /test/fields and componentPath is /components/Field.tsx\n // then path needs to be /test/fields/components/Field.tsx NOT /users/username/project/test/fields/components/Field.tsx\n // so we need to append baseDir to componentPath\n\n if (componentPath.startsWith('.') || componentPath.startsWith('/')) {\n const normalizedBaseDir = baseDir.replace(/\\\\/g, '/')\n\n const finalPath = normalizedBaseDir.startsWith('/../')\n ? `${normalizedBaseDir}${componentPath.slice(1)}`\n : path.posix.join(normalizedBaseDir, componentPath.slice(1))\n\n imports[importIdentifier] = {\n path:\n componentPath.startsWith('.') || componentPath.startsWith('/') ? finalPath : componentPath,\n specifier: exportName,\n }\n } else {\n imports[importIdentifier] = {\n path: componentPath,\n specifier: exportName,\n }\n }\n importMap[componentPath + '#' + exportName] = importIdentifier\n}\n\nexport type AddToImportMap = (payloadComponent: PayloadComponent | PayloadComponent[]) => void\n\nexport async function generateImportMap(\n config: SanitizedConfig,\n options?: { force?: boolean; log: boolean },\n): Promise<void> {\n const shouldLog = options?.log ?? true\n\n if (shouldLog) {\n console.log('Generating import map')\n }\n\n const importMap: InternalImportMap = {}\n const imports: Imports = {}\n\n const rootDir = process.env.ROOT_DIR ?? process.cwd()\n\n // get componentsBaseDir.\n // E.g.:\n // config.admin.importMap.baseDir = /test/fields/\n // rootDir: /\n // componentsBaseDir = /test/fields/\n\n // or\n\n // E.g.:\n // config.admin.importMap.baseDir = /test/fields/\n // rootDir: /test\n // componentsBaseDir = /fields/\n\n // or\n // config.admin.importMap.baseDir = /\n // rootDir: /\n // componentsBaseDir = /\n\n // E.g.:\n // config.admin.importMap.baseDir = /test/fields/\n // rootDir: /test/fields/prod\n // componentsBaseDir = ../\n\n // Check if rootDir is a subdirectory of baseDir\n const baseDir = config.admin.importMap.baseDir\n const isSubdirectory = path.relative(baseDir, rootDir).startsWith('..')\n\n let componentsBaseDir\n\n if (isSubdirectory) {\n // Get the relative path from rootDir to baseDir\n componentsBaseDir = path.relative(rootDir, baseDir)\n } else {\n // If rootDir is not a subdirectory, just return baseDir relative to rootDir\n componentsBaseDir = `/${path.relative(rootDir, baseDir)}`\n }\n\n // Ensure result has a trailing slash\n if (!componentsBaseDir.endsWith('/')) {\n componentsBaseDir += '/'\n }\n\n const addToImportMap: AddToImportMap = (payloadComponent) => {\n if (!payloadComponent) {\n return\n }\n\n if (typeof payloadComponent !== 'object' && typeof payloadComponent !== 'string') {\n console.error(payloadComponent)\n throw new Error('addToImportMap > Payload component must be an object or a string')\n }\n\n if (Array.isArray(payloadComponent)) {\n for (const component of payloadComponent) {\n addPayloadComponentToImportMap({\n baseDir: componentsBaseDir,\n importMap,\n imports,\n payloadComponent: component,\n })\n }\n } else {\n addPayloadComponentToImportMap({\n baseDir: componentsBaseDir,\n importMap,\n imports,\n payloadComponent,\n })\n }\n }\n\n iterateConfig({\n addToImportMap,\n baseDir: config.admin.importMap.baseDir,\n config,\n importMap,\n imports,\n })\n\n await writeImportMap({\n componentMap: importMap,\n config,\n fileName: 'importMap.js',\n force: options?.force,\n importMap: imports,\n log: shouldLog,\n rootDir,\n })\n}\n\nexport async function writeImportMap({\n componentMap,\n config,\n fileName,\n force,\n importMap,\n log,\n rootDir,\n}: {\n componentMap: InternalImportMap\n config: SanitizedConfig\n fileName: string\n force?: boolean\n importMap: Imports\n log?: boolean\n rootDir: string\n}) {\n let importMapFolderPath = ''\n if (fs.existsSync(path.resolve(rootDir, `app/(payload)${config.routes.admin}/`))) {\n importMapFolderPath = path.resolve(rootDir, `app/(payload)${config.routes.admin}/`)\n } else if (fs.existsSync(path.resolve(rootDir, `src/app/(payload)${config.routes.admin}/`))) {\n importMapFolderPath = path.resolve(rootDir, `src/app/(payload)${config.routes.admin}/`)\n } else {\n throw new Error(\n `Could not find the payload admin directory. Looked in ${path.resolve(rootDir, `app/(payload)${config.routes.admin}/`)} and ${path.resolve(rootDir, `src/app/(payload)${config.routes.admin}/`)}`,\n )\n }\n\n const imports: string[] = []\n for (const [identifier, { path, specifier }] of Object.entries(importMap)) {\n imports.push(`import { ${specifier} as ${identifier} } from '${path}'`)\n }\n\n const mapKeys: string[] = []\n for (const [userPath, identifier] of Object.entries(componentMap)) {\n mapKeys.push(` \"${userPath}\": ${identifier}`)\n }\n\n const importMapOutputFile = `${imports.join('\\n')}\n\nexport const importMap = {\n${mapKeys.join(',\\n')}\n}\n`\n\n const importMapFilePath = path.resolve(importMapFolderPath, fileName)\n\n if (!force) {\n // Read current import map and check in the IMPORTS if there are any new imports. If not, don't write the file.\n const currentImportMap = await fs.promises.readFile(importMapFilePath, 'utf-8')\n\n if (currentImportMap?.trim() === importMapOutputFile?.trim()) {\n if (log) {\n console.log('No new imports found, skipping writing import map')\n }\n return\n }\n }\n\n if (log) {\n console.log('Writing import map to', importMapFilePath)\n }\n\n await fs.promises.writeFile(importMapFilePath, importMapOutputFile)\n}\n"],"names":["crypto","fs","process","path","iterateConfig","parsePayloadComponent","addPayloadComponentToImportMap","baseDir","importMap","imports","payloadComponent","exportName","componentPath","importIdentifier","createHash","update","digest","startsWith","normalizedBaseDir","replace","finalPath","slice","posix","join","specifier","generateImportMap","config","options","shouldLog","log","console","rootDir","env","ROOT_DIR","cwd","admin","isSubdirectory","relative","componentsBaseDir","endsWith","addToImportMap","error","Error","Array","isArray","component","writeImportMap","componentMap","fileName","force","importMapFolderPath","existsSync","resolve","routes","identifier","Object","entries","push","mapKeys","userPath","importMapOutputFile","importMapFilePath","currentImportMap","promises","readFile","trim","writeFile"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAC3B,OAAOC,QAAQ,KAAI;AACnB,OAAOC,aAAa,eAAc;AAClC,OAAOC,UAAU,OAAM;AAIvB,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,qBAAqB,QAAQ,6BAA4B;AA+BlE,OAAO,SAASC,+BAA+B,EAC7CC,OAAO,EACPC,SAAS,EACTC,OAAO,EACPC,gBAAgB,EAMjB;IACC,IAAI,CAACA,kBAAkB;QACrB;IACF;IACA,MAAM,EAAEC,UAAU,EAAER,MAAMS,aAAa,EAAE,GAAGP,sBAAsBK;IAElE,IAAIF,SAAS,CAACI,gBAAgB,MAAMD,WAAW,EAAE;QAC/C;IACF;IAEA,MAAME,mBACJF,aAAa,MAAMX,OAAOc,UAA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CAAC;IAEC,MAAMsC,oBAAoB1D,KAAKiD,OAAO,CAACF,qBAAqBF;IAE5D,IAAI,CAACC,OAAO;QACV,+GAA+G;QAC/G,MAAMa,mBAAmB,MAAM7D,GAAG8D,QAAQ,CAACC,QAAQ,CAACH,mBAAmB;QAEvE,IAAIC,kBAAkBG,WAAWL,qBAAqBK,QAAQ;YAC5D,IAAIpC,KAAK;gBACPC,QAAQD,GAAG,CAAC;YACd;YACA;QACF;IACF;IAEA,IAAIA,KAAK;QACPC,QAAQD,GAAG,CAAC,yBAAyBgC;IACvC;IAEA,MAAM5D,GAAG8D,QAAQ,CAACG,SAAS,CAACL,mBAAmBD;AACjD"}
@@ -6,6 +6,7 @@ export function parsePayloadComponent(PayloadComponent) {
6
6
  let path = '';
7
7
  let exportName = 'default';
8
8
  if (pathAndMaybeExport?.includes('#')) {
9
+ ;
9
10
  [path, exportName] = pathAndMaybeExport.split('#');
10
11
  } else {
11
12
  path = pathAndMaybeExport;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/bin/generateImportMap/parsePayloadComponent.ts"],"sourcesContent":["import type { PayloadComponent } from '../../config/types.js'\n\nexport function parsePayloadComponent(PayloadComponent: PayloadComponent): {\n exportName: string\n path: string\n} {\n if (!PayloadComponent) {\n return null\n }\n\n const pathAndMaybeExport =\n typeof PayloadComponent === 'string' ? PayloadComponent : PayloadComponent.path\n\n let path = ''\n let exportName = 'default'\n\n if (pathAndMaybeExport?.includes('#')) {\n ;[path, exportName] = pathAndMaybeExport.split('#')\n } else {\n path = pathAndMaybeExport\n }\n\n if (typeof PayloadComponent === 'object' && PayloadComponent.exportName) {\n exportName = PayloadComponent.exportName\n }\n\n return { exportName, path }\n}\n"],"names":["parsePayloadComponent","PayloadComponent","pathAndMaybeExport","path","exportName","includes","split"],"mappings":"AAEA,OAAO,SAASA,sBAAsBC,gBAAkC;IAItE,IAAI,CAACA,kBAAkB;QACrB,OAAO;IACT;IAEA,MAAMC,qBACJ,OAAOD,qBAAqB,WAAWA,mBAAmBA,iBAAiBE,IAAI;IAEjF,IAAIA,OAAO;IACX,IAAIC,aAAa;IAEjB,IAAIF,oBAAoBG,SAAS,MAAM;QACpC,CAACF,MAAMC,WAAW,GAAGF,mBAAmBI,KAAK,CAAC;IACjD,OAAO;QACLH,OAAOD;IACT;IAEA,IAAI,OAAOD,qBAAqB,YAAYA,iBAAiBG,UAAU,EAAE;QACvEA,aAAaH,iBAAiBG,UAAU;IAC1C;IAEA,OAAO;QAAEA;QAAYD;IAAK;AAC5B"}
1
+ {"version":3,"sources":["../../../src/bin/generateImportMap/parsePayloadComponent.ts"],"sourcesContent":["import type { PayloadComponent } from '../../config/types.js'\n\nexport function parsePayloadComponent(PayloadComponent: PayloadComponent): {\n exportName: string\n path: string\n} {\n if (!PayloadComponent) {\n return null\n }\n\n const pathAndMaybeExport =\n typeof PayloadComponent === 'string' ? PayloadComponent : PayloadComponent.path\n\n let path = ''\n let exportName = 'default'\n\n if (pathAndMaybeExport?.includes('#')) {\n ;[path, exportName] = pathAndMaybeExport.split('#')\n } else {\n path = pathAndMaybeExport\n }\n\n if (typeof PayloadComponent === 'object' && PayloadComponent.exportName) {\n exportName = PayloadComponent.exportName\n }\n\n return { exportName, path }\n}\n"],"names":["parsePayloadComponent","PayloadComponent","pathAndMaybeExport","path","exportName","includes","split"],"mappings":"AAEA,OAAO,SAASA,sBAAsBC,gBAAkC;IAItE,IAAI,CAACA,kBAAkB;QACrB,OAAO;IACT;IAEA,MAAMC,qBACJ,OAAOD,qBAAqB,WAAWA,mBAAmBA,iBAAiBE,IAAI;IAEjF,IAAIA,OAAO;IACX,IAAIC,aAAa;IAEjB,IAAIF,oBAAoBG,SAAS,MAAM;;QACpC,CAACF,MAAMC,WAAW,GAAGF,mBAAmBI,KAAK,CAAC;IACjD,OAAO;QACLH,OAAOD;IACT;IAEA,IAAI,OAAOD,qBAAqB,YAAYA,iBAAiBG,UAAU,EAAE;QACvEA,aAAaH,iBAAiBG,UAAU;IAC1C;IAEA,OAAO;QAAEA;QAAYD;IAAK;AAC5B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/bin/generateTypes.ts"],"sourcesContent":["import fs from 'fs'\nimport { compile } from 'json-schema-to-typescript'\n\nimport type { SanitizedConfig } from '../config/types.js'\n\nimport { addSelectGenericsToGeneratedTypes } from '../utilities/addSelectGenericsToGeneretedTypes.js'\nimport { configToJSONSchema } from '../utilities/configToJSONSchema.js'\nimport { getLogger } from '../utilities/logger.js'\n\nexport async function generateTypes(\n config: SanitizedConfig,\n options?: { log: boolean },\n): Promise<void> {\n const logger = getLogger('payload', 'sync')\n const outputFile = process.env.PAYLOAD_TS_OUTPUT_PATH || config.typescript.outputFile\n\n const shouldLog = options?.log ?? true\n\n if (shouldLog) {\n logger.info('Compiling TS types for Collections and Globals...')\n }\n\n const jsonSchema = configToJSONSchema(config, config.db.defaultIDType)\n\n const declare = `declare module 'payload' {\\n export interface GeneratedTypes extends Config {}\\n}`\n const declareWithTSIgnoreError = `declare module 'payload' {\\n // @ts-ignore \\n export interface GeneratedTypes extends Config {}\\n}`\n\n let compiled = await compile(jsonSchema, 'Config', {\n bannerComment:\n '/* tslint:disable */\\n/* eslint-disable */\\n/**\\n* This file was automatically generated by Payload.\\n* DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config,\\n* and re-run `payload generate:types` to regenerate this file.\\n*/',\n style: {\n singleQuote: true,\n },\n // Generates code for $defs that aren't referenced by the schema. Reason:\n // If a field defines an interfaceName, it should be included in the generated types\n // even if it's not used by another type. Reason: the user might want to use it in their own code.\n unreachableDefinitions: true,\n })\n\n compiled = addSelectGenericsToGeneratedTypes({ compiledGeneratedTypes: compiled })\n\n if (config.typescript.declare !== false) {\n if (config.typescript.declare?.ignoreTSError) {\n compiled += `\\n\\n${declareWithTSIgnoreError}`\n } else {\n compiled += `\\n\\n${declare}`\n }\n }\n\n // Diff the compiled types against the existing types file\n try {\n const existingTypes = fs.readFileSync(outputFile, 'utf-8')\n\n if (compiled === existingTypes) {\n return\n }\n } catch (_) {\n // swallow err\n }\n\n fs.writeFileSync(outputFile, compiled)\n if (shouldLog) {\n logger.info(`Types written to ${outputFile}`)\n }\n}\n"],"names":["fs","compile","addSelectGenericsToGeneratedTypes","configToJSONSchema","getLogger","generateTypes","config","options","logger","outputFile","process","env","PAYLOAD_TS_OUTPUT_PATH","typescript","shouldLog","log","info","jsonSchema","db","defaultIDType","declare","declareWithTSIgnoreError","compiled","bannerComment","style","singleQuote","unreachableDefinitions","compiledGeneratedTypes","ignoreTSError","existingTypes","readFileSync","_","writeFileSync"],"mappings":"AAAA,OAAOA,QAAQ,KAAI;AACnB,SAASC,OAAO,QAAQ,4BAA2B;AAInD,SAASC,iCAAiC,QAAQ,oDAAmD;AACrG,SAASC,kBAAkB,QAAQ,qCAAoC;AACvE,SAASC,SAAS,QAAQ,yBAAwB;AAElD,OAAO,eAAeC,cACpBC,MAAuB,EACvBC,OAA0B;IAE1B,MAAMC,SAASJ,UAAU,WAAW;IACpC,MAAMK,aAAaC,QAAQC,GAAG,CAACC,sBAAsB,IAAIN,OAAOO,UAAU,CAACJ,UAAU;IAErF,MAAMK,YAAYP,SAASQ,OAAO;IAElC,IAAID,WAAW;QACbN,OAAOQ,IAAI,CAAC;IACd;IAEA,MAAMC,aAAad,mBAAmBG,QAAQA,OAAOY,EAAE,CAACC,aAAa;IAErE,MAAMC,UAAU,CAAC,kFAAkF,CAAC;IACpG,MAAMC,2BAA2B,CAAC,oGAAoG,CAAC;IAEvI,IAAIC,WAAW,MAAMrB,QAAQgB,YAAY,UAAU;QACjDM,eACE;QACFC,OAAO;YACLC,aAAa;QACf;QACA,yEAAyE;QACzE,oFAAoF;QACpF,kGAAkG;QAClGC,wBAAwB;IAC1B;IAEAJ,WAAWpB,kCAAkC;QAAEyB,wBAAwBL;IAAS;IAEhF,IAAIhB,OAAOO,UAAU,CAACO,OAAO,KAAK,OAAO;QACvC,IAAId,OAAOO,UAAU,CAACO,OAAO,EAAEQ,eAAe;YAC5CN,YAAY,CAAC,IAAI,EAAED,yBAAyB,CAAC;QAC/C,OAAO;YACLC,YAAY,CAAC,IAAI,EAAEF,QAAQ,CAAC;QAC9B;IACF;IAEA,0DAA0D;IAC1D,IAAI;QACF,MAAMS,gBAAgB7B,GAAG8B,YAAY,CAACrB,YAAY;QAElD,IAAIa,aAAaO,eAAe;YAC9B;QACF;IACF,EAAE,OAAOE,GAAG;IACV,cAAc;IAChB;IAEA/B,GAAGgC,aAAa,CAACvB,YAAYa;IAC7B,IAAIR,WAAW;QACbN,OAAOQ,IAAI,CAAC,CAAC,iBAAiB,EAAEP,WAAW,CAAC;IAC9C;AACF"}
1
+ {"version":3,"sources":["../../src/bin/generateTypes.ts"],"sourcesContent":["import fs from 'fs'\nimport { compile } from 'json-schema-to-typescript'\n\nimport type { SanitizedConfig } from '../config/types.js'\n\nimport { addSelectGenericsToGeneratedTypes } from '../utilities/addSelectGenericsToGeneretedTypes.js'\nimport { configToJSONSchema } from '../utilities/configToJSONSchema.js'\nimport { getLogger } from '../utilities/logger.js'\n\nexport async function generateTypes(\n config: SanitizedConfig,\n options?: { log: boolean },\n): Promise<void> {\n const logger = getLogger('payload', 'sync')\n const outputFile = process.env.PAYLOAD_TS_OUTPUT_PATH || config.typescript.outputFile\n\n const shouldLog = options?.log ?? true\n\n if (shouldLog) {\n logger.info('Compiling TS types for Collections and Globals...')\n }\n\n const jsonSchema = configToJSONSchema(config, config.db.defaultIDType)\n\n const declare = `declare module 'payload' {\\n export interface GeneratedTypes extends Config {}\\n}`\n const declareWithTSIgnoreError = `declare module 'payload' {\\n // @ts-ignore \\n export interface GeneratedTypes extends Config {}\\n}`\n\n let compiled = await compile(jsonSchema, 'Config', {\n bannerComment:\n '/* tslint:disable */\\n/* eslint-disable */\\n/**\\n* This file was automatically generated by Payload.\\n* DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config,\\n* and re-run `payload generate:types` to regenerate this file.\\n*/',\n style: {\n singleQuote: true,\n },\n // Generates code for $defs that aren't referenced by the schema. Reason:\n // If a field defines an interfaceName, it should be included in the generated types\n // even if it's not used by another type. Reason: the user might want to use it in their own code.\n unreachableDefinitions: true,\n })\n\n compiled = addSelectGenericsToGeneratedTypes({ compiledGeneratedTypes: compiled })\n\n if (config.typescript.declare !== false) {\n if (config.typescript.declare?.ignoreTSError) {\n compiled += `\\n\\n${declareWithTSIgnoreError}`\n } else {\n compiled += `\\n\\n${declare}`\n }\n }\n\n // Diff the compiled types against the existing types file\n try {\n const existingTypes = fs.readFileSync(outputFile, 'utf-8')\n\n if (compiled === existingTypes) {\n return\n }\n } catch (_) {\n // swallow err\n }\n\n fs.writeFileSync(outputFile, compiled)\n if (shouldLog) {\n logger.info(`Types written to ${outputFile}`)\n }\n}\n"],"names":["fs","compile","addSelectGenericsToGeneratedTypes","configToJSONSchema","getLogger","generateTypes","config","options","logger","outputFile","process","env","PAYLOAD_TS_OUTPUT_PATH","typescript","shouldLog","log","info","jsonSchema","db","defaultIDType","declare","declareWithTSIgnoreError","compiled","bannerComment","style","singleQuote","unreachableDefinitions","compiledGeneratedTypes","ignoreTSError","existingTypes","readFileSync","_","writeFileSync"],"mappings":"AAAA,OAAOA,QAAQ,KAAI;AACnB,SAASC,OAAO,QAAQ,4BAA2B;AAInD,SAASC,iCAAiC,QAAQ,oDAAmD;AACrG,SAASC,kBAAkB,QAAQ,qCAAoC;AACvE,SAASC,SAAS,QAAQ,yBAAwB;AAElD,OAAO,eAAeC,cACpBC,MAAuB,EACvBC,OAA0B;IAE1B,MAAMC,SAASJ,UAAU,WAAW;IACpC,MAAMK,aAAaC,QAAQC,GAAG,CAACC,sBAAsB,IAAIN,OAAOO,UAAU,CAACJ,UAAU;IAErF,MAAMK,YAAYP,SAASQ,OAAO;IAElC,IAAID,WAAW;QACbN,OAAOQ,IAAI,CAAC;IACd;IAEA,MAAMC,aAAad,mBAAmBG,QAAQA,OAAOY,EAAE,CAACC,aAAa;IAErE,MAAMC,UAAU,CAAC,kFAAkF,CAAC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