payload 3.0.0-beta.46 → 3.0.0-beta.48
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.
- package/dist/admin/LanguageOptions.d.ts +2 -1
- package/dist/admin/LanguageOptions.d.ts.map +1 -1
- package/dist/admin/LanguageOptions.js.map +1 -1
- package/dist/admin/forms/Label.d.ts +1 -0
- package/dist/admin/forms/Label.d.ts.map +1 -1
- package/dist/admin/forms/Label.js.map +1 -1
- package/dist/admin/views/types.d.ts +1 -1
- package/dist/admin/views/types.d.ts.map +1 -1
- package/dist/admin/views/types.js.map +1 -1
- package/dist/auth/operations/forgotPassword.js +1 -1
- package/dist/auth/operations/forgotPassword.js.map +1 -1
- package/dist/auth/operations/local/login.d.ts +1 -2
- package/dist/auth/operations/local/login.d.ts.map +1 -1
- package/dist/auth/operations/local/login.js.map +1 -1
- package/dist/auth/operations/local/resetPassword.d.ts +1 -2
- package/dist/auth/operations/local/resetPassword.d.ts.map +1 -1
- package/dist/auth/operations/local/resetPassword.js.map +1 -1
- package/dist/auth/operations/local/unlock.d.ts +1 -2
- package/dist/auth/operations/local/unlock.d.ts.map +1 -1
- package/dist/auth/operations/local/unlock.js.map +1 -1
- package/dist/auth/operations/local/verifyEmail.d.ts +1 -2
- package/dist/auth/operations/local/verifyEmail.d.ts.map +1 -1
- package/dist/auth/operations/local/verifyEmail.js.map +1 -1
- package/dist/auth/operations/refresh.d.ts +1 -2
- package/dist/auth/operations/refresh.d.ts.map +1 -1
- package/dist/auth/operations/refresh.js.map +1 -1
- package/dist/bin/loader/index.d.ts.map +1 -1
- package/dist/bin/loader/index.js +2 -1
- package/dist/bin/loader/index.js.map +1 -1
- package/dist/bin/loader/resolveOriginalPath.d.ts.map +1 -1
- package/dist/bin/loader/resolveOriginalPath.js +6 -2
- package/dist/bin/loader/resolveOriginalPath.js.map +1 -1
- package/dist/collections/operations/local/create.d.ts +1 -2
- package/dist/collections/operations/local/create.d.ts.map +1 -1
- package/dist/collections/operations/local/create.js.map +1 -1
- package/dist/collections/operations/local/delete.d.ts +2 -4
- package/dist/collections/operations/local/delete.d.ts.map +1 -1
- package/dist/collections/operations/local/delete.js.map +1 -1
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/defaults.js +2 -1
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +10 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/config/shared/openGraphSchema.js +2 -2
- package/dist/config/shared/openGraphSchema.js.map +1 -1
- package/dist/config/types.d.ts +3 -1
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/globals/config/types.d.ts +1 -2
- package/dist/globals/config/types.d.ts.map +1 -1
- package/dist/globals/config/types.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/uploads/cropImage.js +2 -2
- package/dist/uploads/cropImage.js.map +1 -1
- package/dist/uploads/generateFileData.js +4 -4
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/uploads/getBaseFields.js +1 -1
- package/dist/uploads/getBaseFields.js.map +1 -1
- package/dist/uploads/imageResizer.d.ts.map +1 -1
- package/dist/uploads/imageResizer.js +21 -11
- package/dist/uploads/imageResizer.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LanguageOptions.d.ts","sourceRoot":"","sources":["../../src/admin/LanguageOptions.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"LanguageOptions.d.ts","sourceRoot":"","sources":["../../src/admin/LanguageOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAEjE,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,iBAAiB,CAAA;CACzB,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/admin/LanguageOptions.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/admin/LanguageOptions.ts"],"sourcesContent":["import type { AcceptedLanguages } from '@payloadcms/translations'\n\nexport type LanguageOptions = {\n label: string\n value: AcceptedLanguages\n}[]\n"],"names":[],"rangeMappings":"","mappings":"AAEA,WAGG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Label.d.ts","sourceRoot":"","sources":["../../../src/admin/forms/Label.ts"],"names":[],"mappings":";AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC7B,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAA;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"Label.d.ts","sourceRoot":"","sources":["../../../src/admin/forms/Label.ts"],"names":[],"mappings":";AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC7B,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAA;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/admin/forms/Label.ts"],"sourcesContent":["export type LabelProps = {\n CustomLabel?: React.ReactNode\n as?: 'label' | 'span'\n htmlFor?: string\n label?: Record<string, string> | string\n required?: boolean\n unstyled?: boolean\n}\n\nexport type SanitizedLabelProps = Omit<LabelProps, 'label' | 'required'>\n"],"names":[],"rangeMappings":"","mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/admin/forms/Label.ts"],"sourcesContent":["export type LabelProps = {\n CustomLabel?: React.ReactNode\n as?: 'label' | 'span'\n htmlFor?: string\n label?: Record<string, string> | string\n required?: boolean\n schemaPath?: string\n unstyled?: boolean\n}\n\nexport type SanitizedLabelProps = Omit<LabelProps, 'label' | 'required'>\n"],"names":[],"rangeMappings":"","mappings":"AAUA,WAAwE"}
|
|
@@ -39,7 +39,7 @@ export type InitPageResult = {
|
|
|
39
39
|
docID?: string;
|
|
40
40
|
globalConfig?: SanitizedGlobalConfig;
|
|
41
41
|
languageOptions: LanguageOptions;
|
|
42
|
-
locale
|
|
42
|
+
locale?: Locale;
|
|
43
43
|
permissions: Permissions;
|
|
44
44
|
req: PayloadRequestWithData;
|
|
45
45
|
translations: ClientTranslationsObject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/admin/views/types.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AAExE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAA;AAClF,OAAO,KAAK,EAAE,MAAM,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CAAC,cAAc,CAAC,CAAA;AAEpE,MAAM,MAAM,SAAS,GAAG,kBAAkB,GAAG,eAAe,CAAA;AAE5D,MAAM,MAAM,aAAa,GAAG;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,yBAAyB,CAAC,MAAM,CAAC,EAAE,CAAA;IAChD,OAAO,EAAE,qBAAqB,CAAC,MAAM,CAAC,EAAE,CAAA;CACzC,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,gBAAgB,CAAC,EAAE,yBAAyB,CAAA;IAC5C,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,qBAAqB,CAAA;IACpC,eAAe,EAAE,eAAe,CAAA;IAChC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,WAAW,CAAA;IACxB,GAAG,EAAE,sBAAsB,CAAA;IAC3B,YAAY,EAAE,wBAAwB,CAAA;IACtC,eAAe,EAAE,eAAe,CAAA;CACjC,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,cAAc,EAAE,cAAc,CAAA;IAC9B,MAAM,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAA;KAAE,CAAA;IACxD,aAAa,EAAE,MAAM,EAAE,CAAA;IACvB,YAAY,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAA;KAAE,CAAA;CAC/D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/admin/views/types.ts"],"sourcesContent":["import type { ClientTranslationsObject } from '@payloadcms/translations'\n\nimport type { Permissions } from '../../auth/index.js'\nimport type { SanitizedCollectionConfig } from '../../collections/config/types.js'\nimport type { Locale } from '../../config/types.js'\nimport type { SanitizedGlobalConfig } from '../../globals/config/types.js'\nimport type { PayloadRequestWithData } from '../../types/index.js'\nimport type { LanguageOptions } from '../LanguageOptions.js'\n\nexport type AdminViewConfig = {\n Component: AdminViewComponent\n /** Whether the path should be matched exactly or as a prefix */\n exact?: boolean\n path: string\n sensitive?: boolean\n strict?: boolean\n}\n\nexport type AdminViewProps = {\n initPageResult: InitPageResult\n params?: { [key: string]: string | string[] | undefined }\n searchParams: { [key: string]: string | string[] | undefined }\n}\n\nexport type AdminViewComponent = React.ComponentType<AdminViewProps>\n\nexport type AdminView = AdminViewComponent | AdminViewConfig\n\nexport type EditViewProps = {\n collectionSlug?: string\n globalSlug?: string\n}\n\nexport type VisibleEntities = {\n collections: SanitizedCollectionConfig['slug'][]\n globals: SanitizedGlobalConfig['slug'][]\n}\n\nexport type InitPageResult = {\n collectionConfig?: SanitizedCollectionConfig\n cookies: Map<string, string>\n docID?: string\n globalConfig?: SanitizedGlobalConfig\n languageOptions: LanguageOptions\n locale
|
|
1
|
+
{"version":3,"sources":["../../../src/admin/views/types.ts"],"sourcesContent":["import type { ClientTranslationsObject } from '@payloadcms/translations'\n\nimport type { Permissions } from '../../auth/index.js'\nimport type { SanitizedCollectionConfig } from '../../collections/config/types.js'\nimport type { Locale } from '../../config/types.js'\nimport type { SanitizedGlobalConfig } from '../../globals/config/types.js'\nimport type { PayloadRequestWithData } from '../../types/index.js'\nimport type { LanguageOptions } from '../LanguageOptions.js'\n\nexport type AdminViewConfig = {\n Component: AdminViewComponent\n /** Whether the path should be matched exactly or as a prefix */\n exact?: boolean\n path: string\n sensitive?: boolean\n strict?: boolean\n}\n\nexport type AdminViewProps = {\n initPageResult: InitPageResult\n params?: { [key: string]: string | string[] | undefined }\n searchParams: { [key: string]: string | string[] | undefined }\n}\n\nexport type AdminViewComponent = React.ComponentType<AdminViewProps>\n\nexport type AdminView = AdminViewComponent | AdminViewConfig\n\nexport type EditViewProps = {\n collectionSlug?: string\n globalSlug?: string\n}\n\nexport type VisibleEntities = {\n collections: SanitizedCollectionConfig['slug'][]\n globals: SanitizedGlobalConfig['slug'][]\n}\n\nexport type InitPageResult = {\n collectionConfig?: SanitizedCollectionConfig\n cookies: Map<string, string>\n docID?: string\n globalConfig?: SanitizedGlobalConfig\n languageOptions: LanguageOptions\n locale?: Locale\n permissions: Permissions\n req: PayloadRequestWithData\n translations: ClientTranslationsObject\n visibleEntities: VisibleEntities\n}\n\nexport type ServerSideEditViewProps = {\n initPageResult: InitPageResult\n params: { [key: string]: string | string[] | undefined }\n routeSegments: string[]\n searchParams: { [key: string]: string | string[] | undefined }\n}\n"],"names":[],"rangeMappings":"","mappings":"AAmDA,WAKC"}
|
|
@@ -61,7 +61,7 @@ export const forgotPasswordOperation = async (incomingArgs)=>{
|
|
|
61
61
|
;
|
|
62
62
|
const serverURL = config.serverURL !== null && config.serverURL !== '' ? config.serverURL : `${protocol}//${req.headers.get('host')}`;
|
|
63
63
|
let html = `${req.t('authentication:youAreReceivingResetPassword')}
|
|
64
|
-
<a href="${serverURL}${config.routes.admin}
|
|
64
|
+
<a href="${serverURL}${config.routes.admin}/${config.admin.routes.reset}/${token}">${serverURL}${config.routes.admin}/${config.admin.routes.reset}/${token}</a>
|
|
65
65
|
${req.t('authentication:youDidNotRequestPassword')}`;
|
|
66
66
|
if (typeof collectionConfig.auth.forgotPassword.generateEmailHTML === 'function') {
|
|
67
67
|
html = await collectionConfig.auth.forgotPassword.generateEmailHTML({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/auth/operations/forgotPassword.ts"],"sourcesContent":["import crypto from 'crypto'\nimport httpStatus from 'http-status'\nimport { URL } from 'url'\n\nimport type { Collection } from '../../collections/config/types.js'\nimport type { PayloadRequestWithData } from '../../types/index.js'\n\nimport { buildAfterOperation } from '../../collections/operations/utils.js'\nimport { APIError } from '../../errors/index.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\n\nexport type Arguments = {\n collection: Collection\n data: {\n [key: string]: unknown\n email: string\n }\n disableEmail?: boolean\n expiration?: number\n req: PayloadRequestWithData\n}\n\nexport type Result = string\n\nexport const forgotPasswordOperation = async (incomingArgs: Arguments): Promise<null | string> => {\n if (!Object.prototype.hasOwnProperty.call(incomingArgs.data, 'email')) {\n throw new APIError('Missing email.', httpStatus.BAD_REQUEST)\n }\n\n let args = incomingArgs\n\n try {\n const shouldCommit = await initTransaction(args.req)\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n await args.collection.config.hooks.beforeOperation.reduce(async (priorHook, hook) => {\n await priorHook\n\n args =\n (await hook({\n args,\n collection: args.collection?.config,\n context: args.req.context,\n operation: 'forgotPassword',\n req: args.req,\n })) || args\n }, Promise.resolve())\n\n const {\n collection: { config: collectionConfig },\n data,\n disableEmail,\n expiration,\n req: {\n payload: { config, email },\n payload,\n },\n req,\n } = args\n\n // /////////////////////////////////////\n // Forget password\n // /////////////////////////////////////\n\n let token: string = crypto.randomBytes(20).toString('hex')\n\n type UserDoc = {\n id: number | string\n resetPasswordExpiration?: string\n resetPasswordToken?: string\n }\n\n if (!data.email) {\n throw new APIError('Missing email.', httpStatus.BAD_REQUEST)\n }\n\n let user = await payload.db.findOne<UserDoc>({\n collection: collectionConfig.slug,\n req,\n where: { email: { equals: data.email.toLowerCase() } },\n })\n\n // We don't want to indicate specifically that an email was not found,\n // as doing so could lead to the exposure of registered emails.\n // Therefore, we prefer to fail silently.\n if (!user) return null\n\n user.resetPasswordToken = token\n user.resetPasswordExpiration = new Date(expiration || Date.now() + 3600000).toISOString() // 1 hour\n\n user = await payload.update({\n id: user.id,\n collection: collectionConfig.slug,\n data: user,\n req,\n })\n\n if (!disableEmail) {\n const protocol = new URL(req.url).protocol // includes the final :\n const serverURL =\n config.serverURL !== null && config.serverURL !== ''\n ? config.serverURL\n : `${protocol}//${req.headers.get('host')}`\n\n let html = `${req.t('authentication:youAreReceivingResetPassword')}\n <a href=\"${serverURL}${config.routes.admin}
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/operations/forgotPassword.ts"],"sourcesContent":["import crypto from 'crypto'\nimport httpStatus from 'http-status'\nimport { URL } from 'url'\n\nimport type { Collection } from '../../collections/config/types.js'\nimport type { PayloadRequestWithData } from '../../types/index.js'\n\nimport { buildAfterOperation } from '../../collections/operations/utils.js'\nimport { APIError } from '../../errors/index.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\n\nexport type Arguments = {\n collection: Collection\n data: {\n [key: string]: unknown\n email: string\n }\n disableEmail?: boolean\n expiration?: number\n req: PayloadRequestWithData\n}\n\nexport type Result = string\n\nexport const forgotPasswordOperation = async (incomingArgs: Arguments): Promise<null | string> => {\n if (!Object.prototype.hasOwnProperty.call(incomingArgs.data, 'email')) {\n throw new APIError('Missing email.', httpStatus.BAD_REQUEST)\n }\n\n let args = incomingArgs\n\n try {\n const shouldCommit = await initTransaction(args.req)\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n await args.collection.config.hooks.beforeOperation.reduce(async (priorHook, hook) => {\n await priorHook\n\n args =\n (await hook({\n args,\n collection: args.collection?.config,\n context: args.req.context,\n operation: 'forgotPassword',\n req: args.req,\n })) || args\n }, Promise.resolve())\n\n const {\n collection: { config: collectionConfig },\n data,\n disableEmail,\n expiration,\n req: {\n payload: { config, email },\n payload,\n },\n req,\n } = args\n\n // /////////////////////////////////////\n // Forget password\n // /////////////////////////////////////\n\n let token: string = crypto.randomBytes(20).toString('hex')\n\n type UserDoc = {\n id: number | string\n resetPasswordExpiration?: string\n resetPasswordToken?: string\n }\n\n if (!data.email) {\n throw new APIError('Missing email.', httpStatus.BAD_REQUEST)\n }\n\n let user = await payload.db.findOne<UserDoc>({\n collection: collectionConfig.slug,\n req,\n where: { email: { equals: data.email.toLowerCase() } },\n })\n\n // We don't want to indicate specifically that an email was not found,\n // as doing so could lead to the exposure of registered emails.\n // Therefore, we prefer to fail silently.\n if (!user) return null\n\n user.resetPasswordToken = token\n user.resetPasswordExpiration = new Date(expiration || Date.now() + 3600000).toISOString() // 1 hour\n\n user = await payload.update({\n id: user.id,\n collection: collectionConfig.slug,\n data: user,\n req,\n })\n\n if (!disableEmail) {\n const protocol = new URL(req.url).protocol // includes the final :\n const serverURL =\n config.serverURL !== null && config.serverURL !== ''\n ? config.serverURL\n : `${protocol}//${req.headers.get('host')}`\n\n let html = `${req.t('authentication:youAreReceivingResetPassword')}\n <a href=\"${serverURL}${config.routes.admin}/${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: data.email,\n })\n }\n\n // /////////////////////////////////////\n // afterForgotPassword - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterForgotPassword.reduce(async (priorHook, hook) => {\n await priorHook\n await hook({ args, collection: args.collection?.config, context: req.context })\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n token = await buildAfterOperation({\n args,\n collection: args.collection?.config,\n operation: 'forgotPassword',\n result: token,\n })\n\n if (shouldCommit) await commitTransaction(req)\n\n return token\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["crypto","httpStatus","URL","buildAfterOperation","APIError","commitTransaction","initTransaction","killTransaction","forgotPasswordOperation","incomingArgs","Object","prototype","hasOwnProperty","call","data","BAD_REQUEST","args","shouldCommit","req","collection","config","hooks","beforeOperation","reduce","priorHook","hook","context","operation","Promise","resolve","collectionConfig","disableEmail","expiration","payload","email","token","randomBytes","toString","user","db","findOne","slug","where","equals","toLowerCase","resetPasswordToken","resetPasswordExpiration","Date","now","toISOString","update","id","protocol","url","serverURL","headers","get","html","t","routes","admin","reset","auth","forgotPassword","generateEmailHTML","subject","generateEmailSubject","sendEmail","from","defaultFromName","defaultFromAddress","to","afterForgotPassword","result","error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,YAAY,SAAQ;AAC3B,OAAOC,gBAAgB,cAAa;AACpC,SAASC,GAAG,QAAQ,MAAK;AAKzB,SAASC,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AAepE,OAAO,MAAMC,0BAA0B,OAAOC;IAC5C,IAAI,CAACC,OAAOC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACJ,aAAaK,IAAI,EAAE,UAAU;QACrE,MAAM,IAAIV,SAAS,kBAAkBH,WAAWc,WAAW;IAC7D;IAEA,IAAIC,OAAOP;IAEX,IAAI;QACF,MAAMQ,eAAe,MAAMX,gBAAgBU,KAAKE,GAAG;QAEnD,wCAAwC;QACxC,+BAA+B;QAC/B,wCAAwC;QAExC,MAAMF,KAAKG,UAAU,CAACC,MAAM,CAACC,KAAK,CAACC,eAAe,CAACC,MA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CAAwC;QAExC,MAAMJ,iBAAiBT,KAAK,CAACmD,mBAAmB,CAACjD,MAAM,CAAC,OAAOC,WAAWC;YACxE,MAAMD;YACN,MAAMC,KAAK;gBAAET;gBAAMG,YAAYH,KAAKG,UAAU,EAAEC;gBAAQM,SAASR,IAAIQ,OAAO;YAAC;QAC/E,GAAGE,QAAQC,OAAO;QAElB,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExCM,QAAQ,MAAMhC,oBAAoB;YAChCa;YACAG,YAAYH,KAAKG,UAAU,EAAEC;YAC7BO,WAAW;YACX8C,QAAQtC;QACV;QAEA,IAAIlB,cAAc,MAAMZ,kBAAkBa;QAE1C,OAAOiB;IACT,EAAE,OAAOuC,OAAgB;QACvB,MAAMnE,gBAAgBS,KAAKE,GAAG;QAC9B,MAAMwD;IACR;AACF,EAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { Payload, RequestContext } from '../../../index.js';
|
|
2
|
-
import type { GeneratedTypes } from '../../../index.js';
|
|
1
|
+
import type { GeneratedTypes, Payload, RequestContext } from '../../../index.js';
|
|
3
2
|
import type { PayloadRequestWithData } from '../../../types/index.js';
|
|
4
3
|
import type { Result } from '../login.js';
|
|
5
4
|
export type Options<TSlug extends keyof GeneratedTypes['collections']> = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../../src/auth/operations/local/login.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../../src/auth/operations/local/login.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAG,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACjF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAMzC,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,IAAI;IACvE,UAAU,EAAE,KAAK,CAAA;IACjB,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAA;QACb,QAAQ,EAAE,MAAM,CAAA;KACjB,CAAA;IACD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,CAAC,EAAE,sBAAsB,CAAA;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,iBAAe,UAAU,CAAC,KAAK,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,EACzE,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,GACtB,OAAO,CAAC,MAAM,GAAG;IAAE,IAAI,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,CAAA;CAAE,CAAC,CAiClE;AAED,eAAe,UAAU,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/auth/operations/local/login.ts"],"sourcesContent":["import type { Payload, RequestContext } from '../../../index.js'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../../src/auth/operations/local/login.ts"],"sourcesContent":["import type { GeneratedTypes, Payload , RequestContext } from '../../../index.js'\nimport type { PayloadRequestWithData } from '../../../types/index.js'\nimport type { Result } from '../login.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { loginOperation } from '../login.js'\n\nexport type Options<TSlug extends keyof GeneratedTypes['collections']> = {\n collection: TSlug\n context?: RequestContext\n data: {\n email: string\n password: string\n }\n depth?: number\n fallbackLocale?: string\n locale?: string\n overrideAccess?: boolean\n req?: PayloadRequestWithData\n showHiddenFields?: boolean\n}\n\nasync function localLogin<TSlug extends keyof GeneratedTypes['collections']>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<Result & { user: GeneratedTypes['collections'][TSlug] }> {\n const {\n collection: collectionSlug,\n data,\n depth,\n overrideAccess = true,\n showHiddenFields,\n } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} can't be found. Login Operation.`,\n )\n }\n\n const args = {\n collection,\n data,\n depth,\n overrideAccess,\n req: await createLocalReq(options, payload),\n showHiddenFields,\n }\n\n const result = await loginOperation<TSlug>(args)\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return result\n}\n\nexport default localLogin\n"],"names":["APIError","createLocalReq","loginOperation","localLogin","payload","options","collection","collectionSlug","data","depth","overrideAccess","showHiddenFields","collections","String","args","req","result","config","auth","removeTokenFromResponses","token"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,cAAa;AAiB5C,eAAeC,WACbC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EACJC,YAAYC,cAAc,EAC1BC,IAAI,EACJC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,gBAAgB,EACjB,GAAGN;IAEJ,MAAMC,aAAaF,QAAQQ,WAAW,CAACL,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEa,OAAON,gBAAgB,iCAAiC,CAAC;IAEzF;IAEA,MAAMO,OAAO;QACXR;QACAE;QACAC;QACAC;QACAK,KAAK,MAAMd,eAAeI,SAASD;QACnCO;IACF;IAEA,MAAMK,SAAS,MAAMd,eAAsBY;IAE3C,IAAIR,WAAWW,MAAM,CAACC,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOH,OAAOI,KAAK;IACrB;IAEA,OAAOJ;AACT;AAEA,eAAeb,WAAU"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { Payload, RequestContext } from '../../../index.js';
|
|
2
|
-
import type { GeneratedTypes } from '../../../index.js';
|
|
1
|
+
import type { GeneratedTypes, Payload, RequestContext } from '../../../index.js';
|
|
3
2
|
import type { PayloadRequestWithData } from '../../../types/index.js';
|
|
4
3
|
import type { Result } from '../resetPassword.js';
|
|
5
4
|
export type Options<T extends keyof GeneratedTypes['collections']> = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resetPassword.d.ts","sourceRoot":"","sources":["../../../../src/auth/operations/local/resetPassword.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"resetPassword.d.ts","sourceRoot":"","sources":["../../../../src/auth/operations/local/resetPassword.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAG,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACjF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAMjD,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,IAAI;IACnE,UAAU,EAAE,CAAC,CAAA;IACb,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,IAAI,EAAE;QACJ,QAAQ,EAAE,MAAM,CAAA;QAChB,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,CAAC,EAAE,sBAAsB,CAAA;CAC7B,CAAA;AAED,iBAAe,kBAAkB,CAAC,CAAC,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,EAC7E,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAClB,OAAO,CAAC,MAAM,CAAC,CAyBjB;AAED,eAAe,kBAAkB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/auth/operations/local/resetPassword.ts"],"sourcesContent":["import type { Payload, RequestContext } from '../../../index.js'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../../src/auth/operations/local/resetPassword.ts"],"sourcesContent":["import type { GeneratedTypes, Payload , RequestContext } from '../../../index.js'\nimport type { PayloadRequestWithData } from '../../../types/index.js'\nimport type { Result } from '../resetPassword.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { resetPasswordOperation } from '../resetPassword.js'\n\nexport type Options<T extends keyof GeneratedTypes['collections']> = {\n collection: T\n context?: RequestContext\n data: {\n password: string\n token: string\n }\n overrideAccess: boolean\n req?: PayloadRequestWithData\n}\n\nasync function localResetPassword<T extends keyof GeneratedTypes['collections']>(\n payload: Payload,\n options: Options<T>,\n): Promise<Result> {\n const { collection: collectionSlug, data, overrideAccess } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(\n collectionSlug,\n )} can't be found. Reset Password Operation.`,\n )\n }\n\n const result = await resetPasswordOperation({\n collection,\n data,\n overrideAccess,\n req: await createLocalReq(options, payload),\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return result\n}\n\nexport default localResetPassword\n"],"names":["APIError","createLocalReq","resetPasswordOperation","localResetPassword","payload","options","collection","collectionSlug","data","overrideAccess","collections","String","result","req","config","auth","removeTokenFromResponses","token"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,sBAAsB,QAAQ,sBAAqB;AAa5D,eAAeC,mBACbC,OAAgB,EAChBC,OAAmB;IAEnB,MAAM,EAAEC,YAAYC,cAAc,EAAEC,IAAI,EAAEC,cAAc,EAAE,GAAGJ;IAE7D,MAAMC,aAAaF,QAAQM,WAAW,CAACH,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEW,OAC1BJ,gBACA,0CAA0C,CAAC;IAEjD;IAEA,MAAMK,SAAS,MAAMV,uBAAuB;QAC1CI;QACAE;QACAC;QACAI,KAAK,MAAMZ,eAAeI,SAASD;IACrC;IAEA,IAAIE,WAAWQ,MAAM,CAACC,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOJ,OAAOK,KAAK;IACrB;IAEA,OAAOL;AACT;AAEA,eAAeT,mBAAkB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { Payload, RequestContext } from '../../../index.js';
|
|
2
|
-
import type { GeneratedTypes } from '../../../index.js';
|
|
1
|
+
import type { GeneratedTypes, Payload, RequestContext } from '../../../index.js';
|
|
3
2
|
import type { PayloadRequestWithData } from '../../../types/index.js';
|
|
4
3
|
export type Options<T extends keyof GeneratedTypes['collections']> = {
|
|
5
4
|
collection: T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlock.d.ts","sourceRoot":"","sources":["../../../../src/auth/operations/local/unlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"unlock.d.ts","sourceRoot":"","sources":["../../../../src/auth/operations/local/unlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAG,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACjF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAMrE,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,IAAI;IACnE,UAAU,EAAE,CAAC,CAAA;IACb,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,IAAI,EAAE;QACJ,KAAK,MAAA;KACN,CAAA;IACD,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,CAAC,EAAE,sBAAsB,CAAA;CAC7B,CAAA;AAED,iBAAe,WAAW,CAAC,CAAC,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,EACtE,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAClB,OAAO,CAAC,OAAO,CAAC,CAiBlB;AAED,eAAe,WAAW,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/auth/operations/local/unlock.ts"],"sourcesContent":["import type { Payload, RequestContext } from '../../../index.js'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../../src/auth/operations/local/unlock.ts"],"sourcesContent":["import type { GeneratedTypes, Payload , RequestContext } from '../../../index.js'\nimport type { PayloadRequestWithData } from '../../../types/index.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { unlockOperation } from '../unlock.js'\n\nexport type Options<T extends keyof GeneratedTypes['collections']> = {\n collection: T\n context?: RequestContext\n data: {\n email\n }\n overrideAccess: boolean\n req?: PayloadRequestWithData\n}\n\nasync function localUnlock<T extends keyof GeneratedTypes['collections']>(\n payload: Payload,\n options: Options<T>,\n): Promise<boolean> {\n const { collection: collectionSlug, data, overrideAccess = true } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} can't be found. Unlock Operation.`,\n )\n }\n\n return unlockOperation({\n collection,\n data,\n overrideAccess,\n req: await createLocalReq(options, payload),\n })\n}\n\nexport default localUnlock\n"],"names":["APIError","createLocalReq","unlockOperation","localUnlock","payload","options","collection","collectionSlug","data","overrideAccess","collections","String","req"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,eAAe,QAAQ,eAAc;AAY9C,eAAeC,YACbC,OAAgB,EAChBC,OAAmB;IAEnB,MAAM,EAAEC,YAAYC,cAAc,EAAEC,IAAI,EAAEC,iBAAiB,IAAI,EAAE,GAAGJ;IAEpE,MAAMC,aAAaF,QAAQM,WAAW,CAACH,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEW,OAAOJ,gBAAgB,kCAAkC,CAAC;IAE1F;IAEA,OAAOL,gBAAgB;QACrBI;QACAE;QACAC;QACAG,KAAK,MAAMX,eAAeI,SAASD;IACrC;AACF;AAEA,eAAeD,YAAW"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { Payload, RequestContext } from '../../../index.js';
|
|
2
|
-
import type { GeneratedTypes } from '../../../index.js';
|
|
1
|
+
import type { GeneratedTypes, Payload, RequestContext } from '../../../index.js';
|
|
3
2
|
import type { PayloadRequestWithData } from '../../../types/index.js';
|
|
4
3
|
export type Options<T extends keyof GeneratedTypes['collections']> = {
|
|
5
4
|
collection: T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyEmail.d.ts","sourceRoot":"","sources":["../../../../src/auth/operations/local/verifyEmail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"verifyEmail.d.ts","sourceRoot":"","sources":["../../../../src/auth/operations/local/verifyEmail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAG,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACjF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAMrE,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,IAAI;IACnE,UAAU,EAAE,CAAC,CAAA;IACb,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,GAAG,CAAC,EAAE,sBAAsB,CAAA;IAC5B,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,iBAAe,gBAAgB,CAAC,CAAC,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,EAC3E,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAClB,OAAO,CAAC,OAAO,CAAC,CAgBlB;AAED,eAAe,gBAAgB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/auth/operations/local/verifyEmail.ts"],"sourcesContent":["import type { Payload, RequestContext } from '../../../index.js'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../../src/auth/operations/local/verifyEmail.ts"],"sourcesContent":["import type { GeneratedTypes, Payload , RequestContext } from '../../../index.js'\nimport type { PayloadRequestWithData } from '../../../types/index.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { verifyEmailOperation } from '../verifyEmail.js'\n\nexport type Options<T extends keyof GeneratedTypes['collections']> = {\n collection: T\n context?: RequestContext\n req?: PayloadRequestWithData\n token: string\n}\n\nasync function localVerifyEmail<T extends keyof GeneratedTypes['collections']>(\n payload: Payload,\n options: Options<T>,\n): Promise<boolean> {\n const { collection: collectionSlug, token } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} can't be found. Verify Email Operation.`,\n )\n }\n\n return verifyEmailOperation({\n collection,\n req: await createLocalReq(options, payload),\n token,\n })\n}\n\nexport default localVerifyEmail\n"],"names":["APIError","createLocalReq","verifyEmailOperation","localVerifyEmail","payload","options","collection","collectionSlug","token","collections","String","req"],"rangeMappings":";;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,oBAAoB,QAAQ,oBAAmB;AASxD,eAAeC,iBACbC,OAAgB,EAChBC,OAAmB;IAEnB,MAAM,EAAEC,YAAYC,cAAc,EAAEC,KAAK,EAAE,GAAGH;IAE9C,MAAMC,aAAaF,QAAQK,WAAW,CAACF,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEU,OAAOH,gBAAgB,wCAAwC,CAAC;IAEhG;IAEA,OAAOL,qBAAqB;QAC1BI;QACAK,KAAK,MAAMV,eAAeI,SAASD;QACnCI;IACF;AACF;AAEA,eAAeL,iBAAgB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Collection } from '../../collections/config/types.js';
|
|
2
|
-
import type { PayloadRequestWithData } from '../../types/index.js';
|
|
3
|
-
import type { Document } from '../../types/index.js';
|
|
2
|
+
import type { Document, PayloadRequestWithData } from '../../types/index.js';
|
|
4
3
|
export type Result = {
|
|
5
4
|
exp: number;
|
|
6
5
|
refreshedToken: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/refresh.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAuB,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACxF,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/refresh.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAuB,UAAU,EAAE,MAAM,mCAAmC,CAAA;AACxF,OAAO,KAAK,EAAE,QAAQ,EAAG,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAS7E,MAAM,MAAM,MAAM,GAAG;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,cAAc,EAAE,MAAM,CAAA;IACtB,IAAI,EAAE,QAAQ,CAAA;CACf,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,UAAU,EAAE,UAAU,CAAA;IACtB,GAAG,EAAE,sBAAsB,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,eAAO,MAAM,gBAAgB,iBAAwB,SAAS,KAAG,QAAQ,MAAM,CA2G9E,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/auth/operations/refresh.ts"],"sourcesContent":["import jwt from 'jsonwebtoken'\nimport url from 'url'\n\nimport type { BeforeOperationHook, Collection } from '../../collections/config/types.js'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/operations/refresh.ts"],"sourcesContent":["import jwt from 'jsonwebtoken'\nimport url from 'url'\n\nimport type { BeforeOperationHook, Collection } from '../../collections/config/types.js'\nimport type { Document , PayloadRequestWithData } from '../../types/index.js'\n\nimport { buildAfterOperation } from '../../collections/operations/utils.js'\nimport { Forbidden } from '../../errors/index.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { getFieldsToSign } from '../getFieldsToSign.js'\n\nexport type Result = {\n exp: number\n refreshedToken: string\n user: Document\n}\n\nexport type Arguments = {\n collection: Collection\n req: PayloadRequestWithData\n token: string\n}\n\nexport const refreshOperation = async (incomingArgs: Arguments): Promise<Result> => {\n let args = incomingArgs\n\n try {\n const shouldCommit = await initTransaction(args.req)\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n await args.collection.config.hooks.beforeOperation.reduce(\n async (priorHook: BeforeOperationHook | Promise<void>, hook: BeforeOperationHook) => {\n await priorHook\n\n args =\n (await hook({\n args,\n collection: args.collection?.config,\n context: args.req.context,\n operation: 'refresh',\n req: args.req,\n })) || args\n },\n Promise.resolve(),\n )\n\n // /////////////////////////////////////\n // Refresh\n // /////////////////////////////////////\n\n const {\n collection: { config: collectionConfig },\n req,\n req: {\n payload: { config, secret },\n },\n } = args\n\n if (typeof args.token !== 'string' || !args.req.user) throw new Forbidden(args.req.t)\n\n const parsedURL = url.parse(args.req.url)\n const isGraphQL = parsedURL.pathname === config.routes.graphQL\n\n const user = await args.req.payload.findByID({\n id: args.req.user.id,\n collection: args.req.user.collection,\n depth: isGraphQL ? 0 : args.collection.config.auth.depth,\n req: args.req,\n })\n\n const fieldsToSign = getFieldsToSign({\n collectionConfig,\n email: user?.email as string,\n user: args?.req?.user,\n })\n\n const refreshedToken = jwt.sign(fieldsToSign, secret, {\n expiresIn: collectionConfig.auth.tokenExpiration,\n })\n\n const exp = (jwt.decode(refreshedToken) as Record<string, unknown>).exp as number\n\n let result: Result = {\n exp,\n refreshedToken,\n user,\n }\n\n // /////////////////////////////////////\n // After Refresh - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterRefresh.reduce(async (priorHook, hook) => {\n await priorHook\n\n result =\n (await hook({\n collection: args.collection?.config,\n context: args.req.context,\n exp,\n req: args.req,\n token: refreshedToken,\n })) || result\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n result = await buildAfterOperation({\n args,\n collection: args.collection?.config,\n operation: 'refresh',\n result,\n })\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n if (shouldCommit) await commitTransaction(req)\n\n return result\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["jwt","url","buildAfterOperation","Forbidden","commitTransaction","initTransaction","killTransaction","getFieldsToSign","refreshOperation","incomingArgs","args","shouldCommit","req","collection","config","hooks","beforeOperation","reduce","priorHook","hook","context","operation","Promise","resolve","collectionConfig","payload","secret","token","user","t","parsedURL","parse","isGraphQL","pathname","routes","graphQL","findByID","id","depth","auth","fieldsToSign","email","refreshedToken","sign","expiresIn","tokenExpiration","exp","decode","result","afterRefresh","error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,SAAS,eAAc;AAC9B,OAAOC,SAAS,MAAK;AAKrB,SAASC,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,SAAS,QAAQ,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B,IAAI,CAACf,UAAU;YACpCyB,OAAON,YAAY,IAAItB,KAAKG,UAAU,CAACC,MAAM,CAACyB,IAAI,CAACD,KAAK;YACxD1B,KAAKF,KAAKE,GAAG;QACf;QAEA,MAAM4B,eAAejC,gBAAgB;YACnCiB;YACAiB,OAAOb,MAAMa;YACbb,MAAMlB,MAAME,KAAKgB;QACnB;QAEA,MAAMc,iBAAiB1C,IAAI2C,IAAI,CAACH,cAAcd,QAAQ;YACpDkB,WAAWpB,iBAAiBe,IAAI,CAACM,eAAe;QAClD;QAEA,MAAMC,MAAM,AAAC9C,IAAI+C,MAAM,CAACL,gBAA4CI,GAAG;QAEvE,IAAIE,SAAiB;YACnBF;YACAJ;YACAd;QACF;QAEA,wCAAwC;QACxC,6BAA6B;QAC7B,wCAAwC;QAExC,MAAMJ,iBAAiBT,KAAK,CAACkC,YAAY,CAAChC,MAAM,CAAC,OAAOC,WAAWC;YACjE,MAAMD;YAEN8B,SACE,AAAC,MAAM7B,KAAK;gBACVN,YAAYH,KAAKG,UAAU,EAAEC;gBAC7BM,SAASV,KAAKE,GAAG,CAACQ,OAAO;gBACzB0B;gBACAlC,KAAKF,KAAKE,GAAG;gBACbe,OAAOe;YACT,MAAOM;QACX,GAAG1B,QAAQC,OAAO;QAElB,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExCyB,SAAS,MAAM9C,oBAAoB;YACjCQ;YACAG,YAAYH,KAAKG,UAAU,EAAEC;YAC7BO,WAAW;YACX2B;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,IAAIrC,cAAc,MAAMP,kBAAkBQ;QAE1C,OAAOoC;IACT,EAAE,OAAOE,OAAgB;QACvB,MAAM5C,gBAAgBI,KAAKE,GAAG;QAC9B,MAAMsC;IACR;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bin/loader/index.ts"],"names":[],"mappings":"AAUA,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pB,MAAM,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAAA;CAClC;AACD,UAAU,UAAU;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,MAAM,EAAE,WAAW,GAAG,iBAAiB,GAAG,UAAU,GAAG,MAAM,CAAA;CAC9D;AACD,KAAK,QAAQ,GAAG;IACd,GAAG,EAAE,MAAM;IACX,OAAO,EAAE,WAAW;IACpB,QAAQ,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC,UAAU,CAAC;CACtD,CAAA;AACD,KAAK,MAAM,GAAG,CAAC,GAAG,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;AAOlE,eAAO,MAAM,IAAI,EAAE,MAuBlB,CAAA"}
|
package/dist/bin/loader/index.js
CHANGED
|
@@ -73,10 +73,11 @@ export const resolve = async (specifier, context, nextResolve)=>{
|
|
|
73
73
|
const { resolvedModule } = ts.resolveModuleName(specifier, fileURLToPath(context.parentURL), tsconfig, host, moduleResolutionCache);
|
|
74
74
|
if (resolvedModule) {
|
|
75
75
|
const resolvedIsTS = TS_EXTENSIONS.includes(resolvedModule.extension);
|
|
76
|
+
const resolvedPath = await resolveOriginalPath(resolvedModule.resolvedFileName);
|
|
76
77
|
return {
|
|
77
78
|
format: resolvedIsTS ? 'ts' : undefined,
|
|
78
79
|
shortCircuit: true,
|
|
79
|
-
url: pathToFileURL(
|
|
80
|
+
url: pathToFileURL(resolvedPath ?? resolvedModule.resolvedFileName).href
|
|
80
81
|
};
|
|
81
82
|
}
|
|
82
83
|
// import from local project to either:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/bin/loader/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/unbound-method */\nimport { getTsconfig } from 'get-tsconfig'\nimport ts from 'typescript'\nimport { fileURLToPath, pathToFileURL } from 'url'\n\nimport { CLIENT_EXTENSIONS } from './clientExtensions.js'\nimport { compile } from './compile.js'\nimport { specifiersToIgnore } from './ignores.js'\nimport { resolveOriginalPath } from './resolveOriginalPath.js'\n\ninterface ResolveContext {\n conditions: string[]\n parentURL: string | undefined\n}\ninterface ResolveResult {\n format?: string\n shortCircuit?: boolean\n url: string\n}\ntype ResolveArgs = [\n specifier: string,\n context?: ResolveContext,\n nextResolve?: (...args: ResolveArgs) => Promise<ResolveResult>,\n]\ntype ResolveFn = (...args: Required<ResolveArgs>) => Promise<ResolveResult>\n\nconst locatedConfig = getTsconfig()\nconst tsconfig = locatedConfig.config.compilerOptions as unknown as ts.CompilerOptions\n\n// Ensure baseUrl is set in order to support paths\nif (!tsconfig.baseUrl) {\n tsconfig.baseUrl = '.'\n}\n\n// Don't resolve d.ts files, because we aren't type-checking\ntsconfig.noDtsResolution = true\ntsconfig.module = ts.ModuleKind.ESNext\ntsconfig.moduleResolution = ts.ModuleResolutionKind.NodeNext\n\nconst moduleResolutionCache = ts.createModuleResolutionCache(\n ts.sys.getCurrentDirectory(),\n (x) => x,\n tsconfig,\n)\nconst host: ts.ModuleResolutionHost = {\n fileExists: ts.sys.fileExists,\n readFile: ts.sys.readFile,\n}\nconst TS_EXTENSIONS: string[] = [\n ts.Extension.Ts,\n ts.Extension.Tsx,\n ts.Extension.Dts,\n ts.Extension.Mts,\n]\n\nexport const resolve: ResolveFn = async (specifier, context, nextResolve) => {\n const isTS = TS_EXTENSIONS.some((ext) => specifier.endsWith(ext))\n const isClient = CLIENT_EXTENSIONS.some((ext) => specifier.endsWith(ext))\n const shouldIgnore = specifiersToIgnore.includes(specifier)\n\n // If it's a client file, or a file to be ignored is resolved,\n // we'll set `format: 'ignore'`\n // and short circuit, so the load step\n // will return source code of empty object\n if (isClient || shouldIgnore) {\n return {\n format: 'ignore',\n shortCircuit: true,\n // No need to resolve the URL using nextResolve. We ignore client files anyway.\n // Additionally, nextResolve throws an error if the URL is a TS path, so we'd have to use TypeScript's resolveModuleName to resolve the URL, which is unnecessary\n url: 'file:///',\n }\n }\n\n // entrypoint\n if (!context.parentURL) {\n return {\n format: isTS ? 'ts' : undefined,\n shortCircuit: true,\n url: specifier,\n }\n }\n\n // Try and resolve normally\n // This could fail, so we need to swallow that error\n // and keep going\n let nextResult: ResolveResult\n\n if (!isTS) {\n try {\n nextResult = await nextResolve(specifier, context, nextResolve)\n } catch (_) {\n // swallow error\n }\n }\n\n if (nextResult) {\n const nextResultIsTS = TS_EXTENSIONS.some((ext) => nextResult.url.endsWith(ext))\n\n return {\n ...nextResult,\n format: nextResultIsTS ? 'ts' : nextResult.format,\n shortCircuit: true,\n }\n }\n\n const { resolvedModule } = ts.resolveModuleName(\n specifier,\n fileURLToPath(context.parentURL),\n tsconfig,\n host,\n moduleResolutionCache,\n )\n\n if (resolvedModule) {\n const resolvedIsTS = TS_EXTENSIONS.includes(resolvedModule.extension)\n\n return {\n format: resolvedIsTS ? 'ts' : undefined,\n shortCircuit: true,\n url: pathToFileURL(
|
|
1
|
+
{"version":3,"sources":["../../../src/bin/loader/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/unbound-method */\nimport { getTsconfig } from 'get-tsconfig'\nimport ts from 'typescript'\nimport { fileURLToPath, pathToFileURL } from 'url'\n\nimport { CLIENT_EXTENSIONS } from './clientExtensions.js'\nimport { compile } from './compile.js'\nimport { specifiersToIgnore } from './ignores.js'\nimport { resolveOriginalPath } from './resolveOriginalPath.js'\n\ninterface ResolveContext {\n conditions: string[]\n parentURL: string | undefined\n}\ninterface ResolveResult {\n format?: string\n shortCircuit?: boolean\n url: string\n}\ntype ResolveArgs = [\n specifier: string,\n context?: ResolveContext,\n nextResolve?: (...args: ResolveArgs) => Promise<ResolveResult>,\n]\ntype ResolveFn = (...args: Required<ResolveArgs>) => Promise<ResolveResult>\n\nconst locatedConfig = getTsconfig()\nconst tsconfig = locatedConfig.config.compilerOptions as unknown as ts.CompilerOptions\n\n// Ensure baseUrl is set in order to support paths\nif (!tsconfig.baseUrl) {\n tsconfig.baseUrl = '.'\n}\n\n// Don't resolve d.ts files, because we aren't type-checking\ntsconfig.noDtsResolution = true\ntsconfig.module = ts.ModuleKind.ESNext\ntsconfig.moduleResolution = ts.ModuleResolutionKind.NodeNext\n\nconst moduleResolutionCache = ts.createModuleResolutionCache(\n ts.sys.getCurrentDirectory(),\n (x) => x,\n tsconfig,\n)\nconst host: ts.ModuleResolutionHost = {\n fileExists: ts.sys.fileExists,\n readFile: ts.sys.readFile,\n}\nconst TS_EXTENSIONS: string[] = [\n ts.Extension.Ts,\n ts.Extension.Tsx,\n ts.Extension.Dts,\n ts.Extension.Mts,\n]\n\nexport const resolve: ResolveFn = async (specifier, context, nextResolve) => {\n const isTS = TS_EXTENSIONS.some((ext) => specifier.endsWith(ext))\n const isClient = CLIENT_EXTENSIONS.some((ext) => specifier.endsWith(ext))\n const shouldIgnore = specifiersToIgnore.includes(specifier)\n\n // If it's a client file, or a file to be ignored is resolved,\n // we'll set `format: 'ignore'`\n // and short circuit, so the load step\n // will return source code of empty object\n if (isClient || shouldIgnore) {\n return {\n format: 'ignore',\n shortCircuit: true,\n // No need to resolve the URL using nextResolve. We ignore client files anyway.\n // Additionally, nextResolve throws an error if the URL is a TS path, so we'd have to use TypeScript's resolveModuleName to resolve the URL, which is unnecessary\n url: 'file:///',\n }\n }\n\n // entrypoint\n if (!context.parentURL) {\n return {\n format: isTS ? 'ts' : undefined,\n shortCircuit: true,\n url: specifier,\n }\n }\n\n // Try and resolve normally\n // This could fail, so we need to swallow that error\n // and keep going\n let nextResult: ResolveResult\n\n if (!isTS) {\n try {\n nextResult = await nextResolve(specifier, context, nextResolve)\n } catch (_) {\n // swallow error\n }\n }\n\n if (nextResult) {\n const nextResultIsTS = TS_EXTENSIONS.some((ext) => nextResult.url.endsWith(ext))\n\n return {\n ...nextResult,\n format: nextResultIsTS ? 'ts' : nextResult.format,\n shortCircuit: true,\n }\n }\n\n const { resolvedModule } = ts.resolveModuleName(\n specifier,\n fileURLToPath(context.parentURL),\n tsconfig,\n host,\n moduleResolutionCache,\n )\n\n if (resolvedModule) {\n const resolvedIsTS = TS_EXTENSIONS.includes(resolvedModule.extension)\n const resolvedPath = await resolveOriginalPath(resolvedModule.resolvedFileName)\n\n return {\n format: resolvedIsTS ? 'ts' : undefined,\n shortCircuit: true,\n url: pathToFileURL(resolvedPath ?? resolvedModule.resolvedFileName).href, // The typescript module resolver does not resolve to the original path, but to the symlinked path, if present. This can cause issues\n }\n }\n\n // import from local project to either:\n // - something TS couldn't resolve\n // - local project non-TS file\n return nextResolve(specifier, context, nextResolve)\n}\n\ninterface LoadContext {\n conditions: string[]\n format: null | string | undefined\n}\ninterface LoadResult {\n format: string\n shortCircuit?: boolean\n source: ArrayBuffer | SharedArrayBuffer | Uint8Array | string\n}\ntype LoadArgs = [\n url: string,\n context: LoadContext,\n nextLoad?: (...args: LoadArgs) => Promise<LoadResult>,\n]\ntype LoadFn = (...args: Required<LoadArgs>) => Promise<LoadResult>\n\nconst swcOptions = {\n ...tsconfig,\n baseUrl: undefined,\n paths: undefined,\n}\nexport const load: LoadFn = async (url, context, nextLoad) => {\n if (context.format === 'ignore') {\n const rawSource = 'export default {}'\n\n return {\n format: 'module',\n shortCircuit: true,\n source: rawSource,\n }\n }\n\n if (context.format === 'ts') {\n const { source } = await nextLoad(url, context)\n const code = typeof source === 'string' ? source : Buffer.from(source).toString()\n const compiled = await compile(code, fileURLToPath(url), swcOptions)\n return {\n format: 'module',\n shortCircuit: true,\n source: compiled,\n }\n } else {\n return nextLoad(url, context)\n }\n}\n"],"names":["getTsconfig","ts","fileURLToPath","pathToFileURL","CLIENT_EXTENSIONS","compile","specifiersToIgnore","resolveOriginalPath","locatedConfig","tsconfig","config","compilerOptions","baseUrl","noDtsResolution","module","ModuleKind","ESNext","moduleResolution","ModuleResolutionKind","NodeNext","moduleResolutionCache","createModuleResolutionCache","sys","getCurrentDirectory","x","host","fileExists","readFile","TS_EXTENSIONS","Extension","Ts","Tsx","Dts","Mts","resolve","specifier","context","nextResolve","isTS","some","ext","endsWith","isClient","shouldIgnore","includes","format","shortCircuit","url","parentURL","undefined","nextResult","_","nextResultIsTS","resolvedModule","resolveModuleName","resolvedIsTS","extension","resolvedPath","resolvedFileName","href","swcOptions","paths","load","nextLoad","rawSource","source","code","Buffer","from","toString","compiled"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oDAAoD,GACpD,SAASA,WAAW,QAAQ,eAAc;AAC1C,OAAOC,QAAQ,aAAY;AAC3B,SAASC,aAAa,EAAEC,aAAa,QAAQ,MAAK;AAElD,SAASC,iBAAiB,QAAQ,wBAAuB;AACzD,SAASC,OAAO,QAAQ,eAAc;AACtC,SAASC,kBAAkB,QAAQ,eAAc;AACjD,SAASC,mBAAmB,QAAQ,2BAA0B;AAkB9D,MAAMC,gBAAgBR;AACtB,MAAMS,WAAWD,cAAcE,MAAM,CAACC,eAAe;AAErD,kDAAkD;AAClD,IAAI,CAACF,SAASG,OAAO,EAAE;IACrBH,SAASG,OAAO,GAAG;AACrB;AAEA,4DAA4D;AAC5DH,SAASI,eAAe,GAAG;AAC3BJ,SAASK,MAAM,GAAGb,GAAGc,UAAU,CAACC,MAAM;AACtCP,SAASQ,gBAAgB,GAAGhB,GAAGiB,oBAAoB,CAACC,QAAQ;AAE5D,MAAMC,wBAAwBnB,GAAGoB,2BAA2B,CAC1DpB,GAAGqB,GAAG,CAACC,mBAAmB,IAC1B,CAACC,IAAMA,GACPf;AAEF,MAAMgB,OAAgC;IACpCC,YAAYzB,GAAGqB,GAAG,CAACI,UAAU;IAC7BC,UAAU1B,GAAGqB,GAAG,CAACK,QAAQ;AAC3B;AACA,MAAMC,gBAA0B;IAC9B3B,GAAG4B,SAAS,CAACC,EAAE;IACf7B,GAAG4B,SAA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AAe,MAAMlD,oBAAoB8C,eAAeK,gBAAgB;QAE9E,OAAO;YACLb,QAAQU,eAAe,OAAON;YAC9BH,cAAc;YACdC,KAAK5C,cAAcsD,gBAAgBJ,eAAeK,gBAAgB,EAAEC,IAAI;QAC1E;IACF;IAEA,uCAAuC;IACvC,kCAAkC;IAClC,8BAA8B;IAC9B,OAAOtB,YAAYF,WAAWC,SAASC;AACzC,EAAC;AAkBD,MAAMuB,aAAa;IACjB,GAAGnD,QAAQ;IACXG,SAASqC;IACTY,OAAOZ;AACT;AACA,OAAO,MAAMa,OAAe,OAAOf,KAAKX,SAAS2B;IAC/C,IAAI3B,QAAQS,MAAM,KAAK,UAAU;QAC/B,MAAMmB,YAAY;QAElB,OAAO;YACLnB,QAAQ;YACRC,cAAc;YACdmB,QAAQD;QACV;IACF;IAEA,IAAI5B,QAAQS,MAAM,KAAK,MAAM;QAC3B,MAAM,EAAEoB,MAAM,EAAE,GAAG,MAAMF,SAAShB,KAAKX;QACvC,MAAM8B,OAAO,OAAOD,WAAW,WAAWA,SAASE,OAAOC,IAAI,CAACH,QAAQI,QAAQ;QAC/E,MAAMC,WAAW,MAAMjE,QAAQ6D,MAAMhE,cAAc6C,MAAMa;QACzD,OAAO;YACLf,QAAQ;YACRC,cAAc;YACdmB,QAAQK;QACV;IACF,OAAO;QACL,OAAOP,SAAShB,KAAKX;IACvB;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveOriginalPath.d.ts","sourceRoot":"","sources":["../../../src/bin/loader/resolveOriginalPath.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"resolveOriginalPath.d.ts","sourceRoot":"","sources":["../../../src/bin/loader/resolveOriginalPath.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,mBAwBzD"}
|
|
@@ -11,7 +11,7 @@ import path from 'path';
|
|
|
11
11
|
try {
|
|
12
12
|
// Normalize and split the path
|
|
13
13
|
const parts = path.resolve(filePath).split(path.sep);
|
|
14
|
-
let currentPath = '/';
|
|
14
|
+
let currentPath = parts[0] || '/';
|
|
15
15
|
// skip the first slash
|
|
16
16
|
for (const part of parts.slice(1)){
|
|
17
17
|
currentPath = path.join(currentPath, part);
|
|
@@ -20,7 +20,11 @@ import path from 'path';
|
|
|
20
20
|
if (stats.isSymbolicLink()) {
|
|
21
21
|
// Resolve the symlink
|
|
22
22
|
const resolvedLink = await fs.readlink(currentPath);
|
|
23
|
-
|
|
23
|
+
if (!path.isAbsolute(resolvedLink)) {
|
|
24
|
+
currentPath = path.join(path.dirname(currentPath), resolvedLink);
|
|
25
|
+
} else {
|
|
26
|
+
currentPath = resolvedLink;
|
|
27
|
+
}
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
return currentPath;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/bin/loader/resolveOriginalPath.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport path from 'path'\n\n/**\n * In case any directory in the path contains symlinks, this function attempts to detect that resolves the original path.\n *\n * Example Input: /Users/alessio/Documents/GitHub/payload-3.0-alpha-demo/node_modules/tailwindcss/resolveConfig.js\n * The \"tailwindcss\" in this example is a symlinked directory.\n *\n * Example Output: /Users/alessio/Documents/GitHub/payload-3.0-alpha-demo/node_modules/.pnpm/tailwindcss@3.4.3/node_modules/tailwindcss/resolveConfig.js\n */\nexport async function resolveOriginalPath(filePath: string) {\n try {\n // Normalize and split the path\n const parts = path.resolve(filePath).split(path.sep)\n
|
|
1
|
+
{"version":3,"sources":["../../../src/bin/loader/resolveOriginalPath.ts"],"sourcesContent":["import fs from 'fs/promises'\nimport path from 'path'\n\n/**\n * In case any directory in the path contains symlinks, this function attempts to detect that resolves the original path.\n *\n * Example Input: /Users/alessio/Documents/GitHub/payload-3.0-alpha-demo/node_modules/tailwindcss/resolveConfig.js\n * The \"tailwindcss\" in this example is a symlinked directory.\n *\n * Example Output: /Users/alessio/Documents/GitHub/payload-3.0-alpha-demo/node_modules/.pnpm/tailwindcss@3.4.3/node_modules/tailwindcss/resolveConfig.js\n */\nexport async function resolveOriginalPath(filePath: string) {\n try {\n // Normalize and split the path\n const parts = path.resolve(filePath).split(path.sep)\n let currentPath = parts[0] || '/'\n // skip the first slash\n for (const part of parts.slice(1)) {\n currentPath = path.join(currentPath, part)\n // Check if the current path component is a symlink\n const stats = await fs.lstat(currentPath)\n if (stats.isSymbolicLink()) {\n // Resolve the symlink\n const resolvedLink = await fs.readlink(currentPath)\n if (!path.isAbsolute(resolvedLink)) {\n currentPath = path.join(path.dirname(currentPath), resolvedLink)\n } else {\n currentPath = resolvedLink\n }\n }\n }\n return currentPath\n } catch (error) {\n console.error('Error resolving path:', error)\n }\n}\n"],"names":["fs","path","resolveOriginalPath","filePath","parts","resolve","split","sep","currentPath","part","slice","join","stats","lstat","isSymbolicLink","resolvedLink","readlink","isAbsolute","dirname","error","console"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,QAAQ,cAAa;AAC5B,OAAOC,UAAU,OAAM;AAEvB;;;;;;;CAOC,GACD,OAAO,eAAeC,oBAAoBC,QAAgB;IACxD,IAAI;QACF,+BAA+B;QAC/B,MAAMC,QAAQH,KAAKI,OAAO,CAACF,UAAUG,KAAK,CAACL,KAAKM,GAAG;QACnD,IAAIC,cAAcJ,KAAK,CAAC,EAAE,IAAI;QAC9B,uBAAuB;QACvB,KAAK,MAAMK,QAAQL,MAAMM,KAAK,CAAC,GAAI;YACjCF,cAAcP,KAAKU,IAAI,CAACH,aAAaC;YACrC,mDAAmD;YACnD,MAAMG,QAAQ,MAAMZ,GAAGa,KAAK,CAACL;YAC7B,IAAII,MAAME,cAAc,IAAI;gBAC1B,sBAAsB;gBACtB,MAAMC,eAAe,MAAMf,GAAGgB,QAAQ,CAACR;gBACvC,IAAI,CAACP,KAAKgB,UAAU,CAACF,eAAe;oBAClCP,cAAcP,KAAKU,IAAI,CAACV,KAAKiB,OAAO,CAACV,cAAcO;gBACrD,OAAO;oBACLP,cAAcO;gBAChB;YACF;QACF;QACA,OAAOP;IACT,EAAE,OAAOW,OAAO;QACdC,QAAQD,KAAK,CAAC,yBAAyBA;IACzC;AACF"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { MarkOptional } from 'ts-essentials';
|
|
2
|
-
import type { GeneratedTypes } from '../../../index.js';
|
|
3
|
-
import type { Payload } from '../../../index.js';
|
|
2
|
+
import type { GeneratedTypes, Payload } from '../../../index.js';
|
|
4
3
|
import type { Document, PayloadRequestWithData, RequestContext } from '../../../types/index.js';
|
|
5
4
|
import type { File } from '../../../uploads/types.js';
|
|
6
5
|
export type Options<TSlug extends keyof GeneratedTypes['collections']> = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,KAAK,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,KAAK,EAAE,cAAc,EAAG,OAAO,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC/F,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAA;AAOrD,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,IAAI;IACvE,UAAU,EAAE,KAAK,CAAA;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,IAAI,EAAE,YAAY,CAChB,cAAc,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,EACpC,WAAW,GAAG,IAAI,GAAG,OAAO,GAAG,WAAW,CAC3C,CAAA;IACD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,cAAc,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAA;IACzC,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAA;IACjC,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,GAAG,CAAC,EAAE,sBAAsB,CAAA;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,CAAC,EAAE,QAAQ,CAAA;CAChB,CAAA;AAGD,wBAA8B,WAAW,CAAC,KAAK,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,EACzF,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,GACtB,OAAO,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,CAAC,CAmC/C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/operations/local/create.ts"],"sourcesContent":["import type { MarkOptional } from 'ts-essentials'\n\nimport type { GeneratedTypes
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/create.ts"],"sourcesContent":["import type { MarkOptional } from 'ts-essentials'\n\nimport type { GeneratedTypes , Payload } from '../../../index.js'\nimport type { Document, PayloadRequestWithData, RequestContext } from '../../../types/index.js'\nimport type { File } from '../../../uploads/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { getFileByPath } from '../../../uploads/getFileByPath.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { createOperation } from '../create.js'\n\nexport type Options<TSlug extends keyof GeneratedTypes['collections']> = {\n collection: TSlug\n /**\n * context, which will then be passed to req.context, which can be read by hooks\n */\n context?: RequestContext\n data: MarkOptional<\n GeneratedTypes['collections'][TSlug],\n 'createdAt' | 'id' | 'sizes' | 'updatedAt'\n >\n depth?: number\n disableVerificationEmail?: boolean\n draft?: boolean\n fallbackLocale?: GeneratedTypes['locale']\n file?: File\n filePath?: string\n locale?: GeneratedTypes['locale']\n overrideAccess?: boolean\n overwriteExistingFiles?: boolean\n req?: PayloadRequestWithData\n showHiddenFields?: boolean\n user?: Document\n}\n\n// eslint-disable-next-line no-restricted-exports\nexport default async function createLocal<TSlug extends keyof GeneratedTypes['collections']>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<GeneratedTypes['collections'][TSlug]> {\n const {\n collection: collectionSlug,\n data,\n depth,\n disableVerificationEmail,\n draft,\n file,\n filePath,\n overrideAccess = true,\n overwriteExistingFiles = false,\n showHiddenFields,\n } = options\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} can't be found. Create Operation.`,\n )\n }\n\n const req = await createLocalReq(options, payload)\n req.file = file ?? (await getFileByPath(filePath))\n\n return createOperation<TSlug>({\n collection,\n data,\n depth,\n disableVerificationEmail,\n draft,\n overrideAccess,\n overwriteExistingFiles,\n req,\n showHiddenFields,\n })\n}\n"],"names":["APIError","getFileByPath","createLocalReq","createOperation","createLocal","payload","options","collection","collectionSlug","data","depth","disableVerificationEmail","draft","file","filePath","overrideAccess","overwriteExistingFiles","showHiddenFields","collections","String","req"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAMA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,aAAa,QAAQ,oCAAmC;AACjE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,eAAe,QAAQ,eAAc;AA0B9C,iDAAiD;AACjD,eAAe,eAAeC,YAC5BC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EACJC,YAAYC,cAAc,EAC1BC,IAAI,EACJC,KAAK,EACLC,wBAAwB,EACxBC,KAAK,EACLC,IAAI,EACJC,QAAQ,EACRC,iBAAiB,IAAI,EACrBC,yBAAyB,KAAK,EAC9BC,gBAAgB,EACjB,GAAGX;IACJ,MAAMC,aAAaF,QAAQa,WAAW,CAACV,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIP,SACR,CAAC,yBAAyB,EAAEmB,OAAOX,gBAAgB,kCAAkC,CAAC;IAE1F;IAEA,MAAMY,MAAM,MAAMlB,eAAeI,SAASD;IAC1Ce,IAAIP,IAAI,GAAGA,QAAS,MAAMZ,cAAca;IAExC,OAAOX,gBAAuB;QAC5BI;QACAE;QACAC;QACAC;QACAC;QACAG;QACAC;QACAI;QACAH;IACF;AACF"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type { Payload } from '../../../index.js';
|
|
2
|
-
import type {
|
|
3
|
-
import type { PayloadRequestWithData, RequestContext } from '../../../types/index.js';
|
|
4
|
-
import type { Document, Where } from '../../../types/index.js';
|
|
1
|
+
import type { GeneratedTypes, Payload } from '../../../index.js';
|
|
2
|
+
import type { Document, PayloadRequestWithData, RequestContext, Where } from '../../../types/index.js';
|
|
5
3
|
import type { BulkOperationResult } from '../../config/types.js';
|
|
6
4
|
export type BaseOptions<T extends keyof GeneratedTypes['collections']> = {
|
|
7
5
|
collection: T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/delete.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../../src/collections/operations/local/delete.ts"],"names":[],"mappings":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C,KAAK,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,EAC1E,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,GAC1B,OAAO,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;AAChD,iBAAe,WAAW,CAAC,KAAK,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,EAC1E,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,GAC1B,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAA;AACtC,iBAAe,WAAW,CAAC,KAAK,SAAS,MAAM,cAAc,CAAC,aAAa,CAAC,EAC1E,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,GACtB,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;AAsC7E,eAAe,WAAW,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/collections/operations/local/delete.ts"],"sourcesContent":["import type { Payload } from '../../../index.js'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../../src/collections/operations/local/delete.ts"],"sourcesContent":["import type { GeneratedTypes , Payload } from '../../../index.js'\nimport type { Document, PayloadRequestWithData , RequestContext, Where } from '../../../types/index.js'\nimport type { BulkOperationResult } from '../../config/types.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { deleteOperation } from '../delete.js'\nimport { deleteByIDOperation } from '../deleteByID.js'\n\nexport type BaseOptions<T extends keyof GeneratedTypes['collections']> = {\n collection: T\n /**\n * context, which will then be passed to req.context, which can be read by hooks\n */\n context?: RequestContext\n depth?: number\n fallbackLocale?: GeneratedTypes['locale']\n locale?: GeneratedTypes['locale']\n overrideAccess?: boolean\n req?: PayloadRequestWithData\n showHiddenFields?: boolean\n user?: Document\n}\n\nexport type ByIDOptions<T extends keyof GeneratedTypes['collections']> = BaseOptions<T> & {\n id: number | string\n where?: never\n}\n\nexport type ManyOptions<T extends keyof GeneratedTypes['collections']> = BaseOptions<T> & {\n id?: never\n where: Where\n}\n\nexport type Options<TSlug extends keyof GeneratedTypes['collections']> =\n | ByIDOptions<TSlug>\n | ManyOptions<TSlug>\n\nasync function deleteLocal<TSlug extends keyof GeneratedTypes['collections']>(\n payload: Payload,\n options: ByIDOptions<TSlug>,\n): Promise<GeneratedTypes['collections'][TSlug]>\nasync function deleteLocal<TSlug extends keyof GeneratedTypes['collections']>(\n payload: Payload,\n options: ManyOptions<TSlug>,\n): Promise<BulkOperationResult<TSlug>>\nasync function deleteLocal<TSlug extends keyof GeneratedTypes['collections']>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<BulkOperationResult<TSlug> | GeneratedTypes['collections'][TSlug]>\nasync function deleteLocal<TSlug extends keyof GeneratedTypes['collections']>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<BulkOperationResult<TSlug> | GeneratedTypes['collections'][TSlug]> {\n const {\n id,\n collection: collectionSlug,\n depth,\n overrideAccess = true,\n showHiddenFields,\n where,\n } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} can't be found. Delete Operation.`,\n )\n }\n\n const args = {\n id,\n collection,\n depth,\n overrideAccess,\n req: await createLocalReq(options, payload),\n showHiddenFields,\n where,\n }\n\n if (options.id) {\n return deleteByIDOperation<TSlug>(args)\n }\n return deleteOperation<TSlug>(args)\n}\n\nexport default deleteLocal\n"],"names":["APIError","createLocalReq","deleteOperation","deleteByIDOperation","deleteLocal","payload","options","id","collection","collectionSlug","depth","overrideAccess","showHiddenFields","where","collections","String","args","req"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,eAAe,QAAQ,eAAc;AAC9C,SAASC,mBAAmB,QAAQ,mBAAkB;AA2CtD,eAAeC,YACbC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EACJC,EAAE,EACFC,YAAYC,cAAc,EAC1BC,KAAK,EACLC,iBAAiB,IAAI,EACrBC,gBAAgB,EAChBC,KAAK,EACN,GAAGP;IAEJ,MAAME,aAAaH,QAAQS,WAAW,CAACL,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIR,SACR,CAAC,yBAAyB,EAAEe,OAAON,gBAAgB,kCAAkC,CAAC;IAE1F;IAEA,MAAMO,OAAO;QACXT;QACAC;QACAE;QACAC;QACAM,KAAK,MAAMhB,eAAeK,SAASD;QACnCO;QACAC;IACF;IAEA,IAAIP,QAAQC,EAAE,EAAE;QACd,OAAOJ,oBAA2Ba;IACpC;IACA,OAAOd,gBAAuBc;AAChC;AAEA,eAAeZ,YAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAExC,eAAO,MAAM,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,QAAQ,GAAG,QAAQ,
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAExC,eAAO,MAAM,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,QAAQ,GAAG,QAAQ,CAsD7D,CAAA"}
|
package/dist/config/defaults.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const defaults = {
|
|
2
2
|
admin: {
|
|
3
|
-
avatar: '
|
|
3
|
+
avatar: 'gravatar',
|
|
4
4
|
components: {},
|
|
5
5
|
custom: {},
|
|
6
6
|
dateFormat: 'MMMM do yyyy, h:mm a',
|
|
@@ -16,6 +16,7 @@ export const defaults = {
|
|
|
16
16
|
inactivity: '/logout-inactivity',
|
|
17
17
|
login: '/login',
|
|
18
18
|
logout: '/logout',
|
|
19
|
+
reset: '/reset',
|
|
19
20
|
unauthorized: '/unauthorized'
|
|
20
21
|
}
|
|
21
22
|
},
|