payload 4.0.0-internal.a6582c6 → 4.0.0-internal.b6f3b9a

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 (113) hide show
  1. package/dist/auth/endpoints/login.d.ts.map +1 -1
  2. package/dist/auth/endpoints/login.js +2 -11
  3. package/dist/auth/endpoints/login.js.map +1 -1
  4. package/dist/auth/loginWithCookie.d.ts +33 -0
  5. package/dist/auth/loginWithCookie.d.ts.map +1 -0
  6. package/dist/auth/loginWithCookie.js +34 -0
  7. package/dist/auth/loginWithCookie.js.map +1 -0
  8. package/dist/auth/serverFunctions/cookies.d.ts +47 -0
  9. package/dist/auth/serverFunctions/cookies.d.ts.map +1 -0
  10. package/dist/auth/serverFunctions/cookies.js +52 -0
  11. package/dist/auth/serverFunctions/cookies.js.map +1 -0
  12. package/dist/auth/serverFunctions/login.d.ts +29 -0
  13. package/dist/auth/serverFunctions/login.d.ts.map +1 -0
  14. package/dist/auth/serverFunctions/login.js +63 -0
  15. package/dist/auth/serverFunctions/login.js.map +1 -0
  16. package/dist/auth/serverFunctions/logout.d.ts +17 -0
  17. package/dist/auth/serverFunctions/logout.d.ts.map +1 -0
  18. package/dist/auth/serverFunctions/logout.js +58 -0
  19. package/dist/auth/serverFunctions/logout.js.map +1 -0
  20. package/dist/auth/serverFunctions/refresh.d.ts +17 -0
  21. package/dist/auth/serverFunctions/refresh.d.ts.map +1 -0
  22. package/dist/auth/serverFunctions/refresh.js +61 -0
  23. package/dist/auth/serverFunctions/refresh.js.map +1 -0
  24. package/dist/collections/config/defaults.d.ts.map +1 -1
  25. package/dist/collections/config/defaults.js +1 -0
  26. package/dist/collections/config/defaults.js.map +1 -1
  27. package/dist/collections/operations/updateByID.js +1 -0
  28. package/dist/collections/operations/updateByID.js.map +1 -1
  29. package/dist/config/defaults.d.ts.map +1 -1
  30. package/dist/config/defaults.js +1 -1
  31. package/dist/config/defaults.js.map +1 -1
  32. package/dist/config/sanitize.d.ts.map +1 -1
  33. package/dist/config/sanitize.js +1 -0
  34. package/dist/config/sanitize.js.map +1 -1
  35. package/dist/config/types.d.ts +1 -1
  36. package/dist/config/types.js.map +1 -1
  37. package/dist/exports/auth.d.ts +5 -0
  38. package/dist/exports/auth.d.ts.map +1 -0
  39. package/dist/exports/auth.js +6 -0
  40. package/dist/exports/auth.js.map +1 -0
  41. package/dist/fields/config/types.d.ts +1 -1
  42. package/dist/fields/config/types.d.ts.map +1 -1
  43. package/dist/fields/config/types.js.map +1 -1
  44. package/dist/fields/validations.js +2 -2
  45. package/dist/fields/validations.js.map +1 -1
  46. package/dist/fields/validations.spec.js +61 -37
  47. package/dist/fields/validations.spec.js.map +1 -1
  48. package/dist/globals/operations/countGlobalVersions.d.ts.map +1 -1
  49. package/dist/globals/operations/countGlobalVersions.js +1 -0
  50. package/dist/globals/operations/countGlobalVersions.js.map +1 -1
  51. package/dist/index.bundled.d.ts +26 -52
  52. package/dist/index.d.ts +3 -3
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js.map +1 -1
  55. package/dist/query-presets/constraints.js +1 -1
  56. package/dist/query-presets/constraints.js.map +1 -1
  57. package/dist/queues/config/collection.d.ts.map +1 -1
  58. package/dist/queues/config/collection.js +17 -31
  59. package/dist/queues/config/collection.js.map +1 -1
  60. package/dist/queues/config/global.d.ts +4 -4
  61. package/dist/queues/config/global.d.ts.map +1 -1
  62. package/dist/queues/config/global.js.map +1 -1
  63. package/dist/queues/config/types/index.d.ts +5 -19
  64. package/dist/queues/config/types/index.d.ts.map +1 -1
  65. package/dist/queues/config/types/index.js.map +1 -1
  66. package/dist/queues/config/types/taskTypes.d.ts +2 -5
  67. package/dist/queues/config/types/taskTypes.d.ts.map +1 -1
  68. package/dist/queues/config/types/taskTypes.js.map +1 -1
  69. package/dist/queues/config/types/workflowJSONTypes.d.ts +4 -3
  70. package/dist/queues/config/types/workflowJSONTypes.d.ts.map +1 -1
  71. package/dist/queues/config/types/workflowJSONTypes.js.map +1 -1
  72. package/dist/queues/config/types/workflowTypes.d.ts +7 -23
  73. package/dist/queues/config/types/workflowTypes.d.ts.map +1 -1
  74. package/dist/queues/config/types/workflowTypes.js.map +1 -1
  75. package/dist/queues/errors/handleTaskError.js +2 -2
  76. package/dist/queues/errors/handleTaskError.js.map +1 -1
  77. package/dist/queues/localAPI.d.ts +2 -2
  78. package/dist/queues/localAPI.d.ts.map +1 -1
  79. package/dist/queues/localAPI.js +61 -64
  80. package/dist/queues/localAPI.js.map +1 -1
  81. package/dist/queues/operations/handleSchedules/countRunnableOrActiveJobsForQueue.d.ts +4 -4
  82. package/dist/queues/operations/handleSchedules/countRunnableOrActiveJobsForQueue.d.ts.map +1 -1
  83. package/dist/queues/operations/handleSchedules/countRunnableOrActiveJobsForQueue.js.map +1 -1
  84. package/dist/queues/operations/runJobs/index.d.ts.map +1 -1
  85. package/dist/queues/operations/runJobs/index.js +12 -14
  86. package/dist/queues/operations/runJobs/index.js.map +1 -1
  87. package/dist/queues/operations/runJobs/runJSONJob/index.d.ts.map +1 -1
  88. package/dist/queues/operations/runJobs/runJSONJob/index.js.map +1 -1
  89. package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js +2 -2
  90. package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js.map +1 -1
  91. package/dist/queues/operations/runJobs/runJob/importHandlerPath.js.map +1 -1
  92. package/dist/types/index.d.ts +1 -1
  93. package/dist/types/index.d.ts.map +1 -1
  94. package/dist/types/index.js.map +1 -1
  95. package/dist/uploads/generateFileData.js +4 -1
  96. package/dist/uploads/generateFileData.js.map +1 -1
  97. package/dist/uploads/getImageSize.d.ts +12 -1
  98. package/dist/uploads/getImageSize.d.ts.map +1 -1
  99. package/dist/uploads/getImageSize.js +20 -18
  100. package/dist/uploads/getImageSize.js.map +1 -1
  101. package/dist/uploads/getImageSize.spec.js +298 -0
  102. package/dist/uploads/getImageSize.spec.js.map +1 -0
  103. package/dist/uploads/probeImageSize.d.ts +39 -0
  104. package/dist/uploads/probeImageSize.d.ts.map +1 -0
  105. package/dist/uploads/probeImageSize.js +374 -0
  106. package/dist/uploads/probeImageSize.js.map +1 -0
  107. package/dist/uploads/probeImageSize.spec.js +366 -0
  108. package/dist/uploads/probeImageSize.spec.js.map +1 -0
  109. package/package.json +8 -3
  110. package/dist/uploads/tempFile.d.ts +0 -7
  111. package/dist/uploads/tempFile.d.ts.map +0 -1
  112. package/dist/uploads/tempFile.js +0 -39
  113. package/dist/uploads/tempFile.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/login.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAQ3D,eAAO,MAAM,YAAY,EAAE,cAgD1B,CAAA"}
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/login.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAO3D,eAAO,MAAM,YAAY,EAAE,cAsC1B,CAAA"}
@@ -2,8 +2,7 @@ import { status as httpStatus } from 'http-status';
2
2
  import { getRequestCollection } from '../../utilities/getRequestEntity.js';
3
3
  import { headersWithCors } from '../../utilities/headersWithCors.js';
4
4
  import { isNumber } from '../../utilities/isNumber.js';
5
- import { generatePayloadCookie } from '../cookies.js';
6
- import { loginOperation } from '../operations/login.js';
5
+ import { loginWithCookie } from '../loginWithCookie.js';
7
6
  export const loginHandler = async (req)=>{
8
7
  const collection = getRequestCollection(req);
9
8
  const { searchParams, t } = req;
@@ -16,20 +15,12 @@ export const loginHandler = async (req)=>{
16
15
  email: typeof req.data?.email === 'string' ? req.data.email : '',
17
16
  password: typeof req.data?.password === 'string' ? req.data.password : ''
18
17
  };
19
- const result = await loginOperation({
18
+ const { cookie, result } = await loginWithCookie({
20
19
  collection,
21
20
  data: authData,
22
21
  depth: isNumber(depth) ? Number(depth) : undefined,
23
22
  req
24
23
  });
25
- const cookie = generatePayloadCookie({
26
- collectionAuthConfig: collection.config.auth,
27
- cookiePrefix: req.payload.config.cookiePrefix,
28
- token: result.token
29
- });
30
- if (collection.config.auth.removeTokenFromResponses) {
31
- delete result.token;
32
- }
33
24
  return Response.json({
34
25
  message: t('authentication:passed'),
35
26
  ...result
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/auth/endpoints/login.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { generatePayloadCookie } from '../cookies.js'\nimport { loginOperation } from '../operations/login.js'\n\nexport const loginHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { searchParams, t } = req\n const depth = searchParams.get('depth')\n const authData =\n collection.config.auth?.loginWithUsername !== false\n ? {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n username: typeof req.data?.username === 'string' ? req.data.username : '',\n }\n : {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n }\n\n const result = await loginOperation({\n collection,\n data: authData,\n depth: isNumber(depth) ? Number(depth) : undefined,\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionAuthConfig: collection.config.auth,\n cookiePrefix: req.payload.config.cookiePrefix,\n token: result.token!,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return Response.json(\n {\n message: t('authentication:passed'),\n ...result,\n },\n {\n headers: headersWithCors({\n headers: new Headers({\n 'Set-Cookie': cookie,\n }),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["status","httpStatus","getRequestCollection","headersWithCors","isNumber","generatePayloadCookie","loginOperation","loginHandler","req","collection","searchParams","t","depth","get","authData","config","auth","loginWithUsername","email","data","password","username","result","Number","undefined","cookie","collectionAuthConfig","cookiePrefix","payload","token","removeTokenFromResponses","Response","json","message","headers","Headers","OK"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAIlD,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,QAAQ,QAAQ,8BAA6B;AACtD,SAASC,qBAAqB,QAAQ,gBAAe;AACrD,SAASC,cAAc,QAAQ,yBAAwB;AAEvD,OAAO,MAAMC,eAA+B,OAAOC;IACjD,MAAMC,aAAaP,qBAAqBM;IACxC,MAAM,EAAEE,YAAY,EAAEC,CAAC,EAAE,GAAGH;IAC5B,MAAMI,QAAQF,aAAaG,GAAG,CAAC;IAC/B,MAAMC,WACJL,WAAWM,MAAM,CAACC,IAAI,EAAEC,sBAAsB,QAC1C;QACEC,OAAO,OAAOV,IAAIW,IAAI,EAAED,UAAU,WAAWV,IAAIW,IAAI,CAACD,KAAK,GAAG;QAC9DE,UAAU,OAAOZ,IAAIW,IAAI,EAAEC,aAAa,WAAWZ,IAAIW,IAAI,CAACC,QAAQ,GAAG;QACvEC,UAAU,OAAOb,IAAIW,IAAI,EAAEE,aAAa,WAAWb,IAAIW,IAAI,CAACE,QAAQ,GAAG;IACzE,IACA;QACEH,OAAO,OAAOV,IAAIW,IAAI,EAAED,UAAU,WAAWV,IAAIW,IAAI,CAACD,KAAK,GAAG;QAC9DE,UAAU,OAAOZ,IAAIW,IAAI,EAAEC,aAAa,WAAWZ,IAAIW,IAAI,CAACC,QAAQ,GAAG;IACzE;IAEN,MAAME,SAAS,MAAMhB,eAAe;QAClCG;QACAU,MAAML;QACNF,OAAOR,SAASQ,SAASW,OAAOX,SAASY;QACzChB;IACF;IAEA,MAAMiB,SAASpB,sBAAsB;QACnCqB,sBAAsBjB,WAAWM,MAAM,CAACC,IAAI;QAC5CW,cAAcnB,IAAIoB,OAAO,CAACb,MAAM,CAACY,YAAY;QAC7CE,OAAOP,OAAOO,KAAK;IACrB;IAEA,IAAIpB,WAAWM,MAAM,CAACC,IAAI,CAACc,wBAAwB,EAAE;QACnD,OAAOR,OAAOO,KAAK;IACrB;IAEA,OAAOE,SAASC,IAAI,CAClB;QACEC,SAAStB,EAAE;QACX,GAAGW,MAAM;IACX,GACA;QACEY,SAAS/B,gBAAgB;YACvB+B,SAAS,IAAIC,QAAQ;gBACnB,cAAcV;YAChB;YACAjB;QACF;QACAR,QAAQC,WAAWmC,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../src/auth/endpoints/login.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { isNumber } from '../../utilities/isNumber.js'\nimport { loginWithCookie } from '../loginWithCookie.js'\n\nexport const loginHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { searchParams, t } = req\n const depth = searchParams.get('depth')\n const authData =\n collection.config.auth?.loginWithUsername !== false\n ? {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n username: typeof req.data?.username === 'string' ? req.data.username : '',\n }\n : {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n }\n\n const { cookie, result } = await loginWithCookie({\n collection,\n data: authData,\n depth: isNumber(depth) ? Number(depth) : undefined,\n req,\n })\n\n return Response.json(\n {\n message: t('authentication:passed'),\n ...result,\n },\n {\n headers: headersWithCors({\n headers: new Headers({\n 'Set-Cookie': cookie,\n }),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["status","httpStatus","getRequestCollection","headersWithCors","isNumber","loginWithCookie","loginHandler","req","collection","searchParams","t","depth","get","authData","config","auth","loginWithUsername","email","data","password","username","cookie","result","Number","undefined","Response","json","message","headers","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+1,33 @@
1
+ import type { Collection } from '../collections/config/types.js';
2
+ import type { AuthCollectionSlug } from '../index.js';
3
+ import type { PayloadRequest } from '../types/index.js';
4
+ import type { generateCookie } from './cookies.js';
5
+ import type { LoginResult } from './operations/login.js';
6
+ import { loginOperation } from './operations/login.js';
7
+ type CookieObject = Extract<ReturnType<typeof generateCookie<true>>, {
8
+ name: string;
9
+ }>;
10
+ type LoginWithCookieArgs<TReturnCookieAsObject extends boolean> = {
11
+ collection: Collection;
12
+ data: Parameters<typeof loginOperation>[0]['data'];
13
+ depth?: number;
14
+ overrideAccess?: boolean;
15
+ req: PayloadRequest;
16
+ /** Return the cookie as parts rather than a serialized header string. */
17
+ returnCookieAsObject?: TReturnCookieAsObject;
18
+ };
19
+ /**
20
+ * Runs the login operation and builds the auth cookie from its token, then
21
+ * applies `auth.removeTokenFromResponses` to the returned result.
22
+ *
23
+ * The order matters: the token has to be read before the flag strips it, or the
24
+ * caller ends up returning a user with no way to establish a session. Shared by
25
+ * the REST login handler and the framework adapters' `login` server function so
26
+ * that ordering only exists in one place.
27
+ */
28
+ export declare const loginWithCookie: <TSlug extends AuthCollectionSlug, TReturnCookieAsObject extends boolean = false>({ collection, data, depth, overrideAccess, req, returnCookieAsObject, }: LoginWithCookieArgs<TReturnCookieAsObject>) => Promise<{
29
+ cookie: TReturnCookieAsObject extends true ? CookieObject : string;
30
+ result: LoginResult<TSlug>;
31
+ }>;
32
+ export {};
33
+ //# sourceMappingURL=loginWithCookie.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loginWithCookie.d.ts","sourceRoot":"","sources":["../../src/auth/loginWithCookie.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAGxD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,KAAK,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAEtF,KAAK,mBAAmB,CAAC,qBAAqB,SAAS,OAAO,IAAI;IAChE,UAAU,EAAE,UAAU,CAAA;IACtB,IAAI,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IAClD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,EAAE,cAAc,CAAA;IACnB,yEAAyE;IACzE,oBAAoB,CAAC,EAAE,qBAAqB,CAAA;CAC7C,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAC1B,KAAK,SAAS,kBAAkB,EAChC,qBAAqB,SAAS,OAAO,GAAG,KAAK,2EAQ5C,mBAAmB,CAAC,qBAAqB,CAAC,KAAG,OAAO,CAAC;IACtD,MAAM,EAAE,qBAAqB,SAAS,IAAI,GAAG,YAAY,GAAG,MAAM,CAAA;IAClE,MAAM,EAAE,WAAW,CAAC,KAAK,CAAC,CAAA;CAC3B,CAqBA,CAAA"}
@@ -0,0 +1,34 @@
1
+ import { generatePayloadCookie } from './cookies.js';
2
+ import { loginOperation } from './operations/login.js';
3
+ /**
4
+ * Runs the login operation and builds the auth cookie from its token, then
5
+ * applies `auth.removeTokenFromResponses` to the returned result.
6
+ *
7
+ * The order matters: the token has to be read before the flag strips it, or the
8
+ * caller ends up returning a user with no way to establish a session. Shared by
9
+ * the REST login handler and the framework adapters' `login` server function so
10
+ * that ordering only exists in one place.
11
+ */ export const loginWithCookie = async ({ collection, data, depth, overrideAccess, req, returnCookieAsObject })=>{
12
+ const result = await loginOperation({
13
+ collection,
14
+ data,
15
+ depth,
16
+ overrideAccess,
17
+ req
18
+ });
19
+ const cookie = generatePayloadCookie({
20
+ collectionAuthConfig: collection.config.auth,
21
+ cookiePrefix: req.payload.config.cookiePrefix,
22
+ returnCookieAsObject: returnCookieAsObject ?? false,
23
+ token: result.token
24
+ });
25
+ if (collection.config.auth.removeTokenFromResponses) {
26
+ delete result.token;
27
+ }
28
+ return {
29
+ cookie,
30
+ result
31
+ };
32
+ };
33
+
34
+ //# sourceMappingURL=loginWithCookie.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/auth/loginWithCookie.ts"],"sourcesContent":["import type { Collection } from '../collections/config/types.js'\nimport type { AuthCollectionSlug } from '../index.js'\nimport type { PayloadRequest } from '../types/index.js'\nimport type { generateCookie } from './cookies.js'\nimport type { LoginResult } from './operations/login.js'\n\nimport { generatePayloadCookie } from './cookies.js'\nimport { loginOperation } from './operations/login.js'\n\ntype CookieObject = Extract<ReturnType<typeof generateCookie<true>>, { name: string }>\n\ntype LoginWithCookieArgs<TReturnCookieAsObject extends boolean> = {\n collection: Collection\n data: Parameters<typeof loginOperation>[0]['data']\n depth?: number\n overrideAccess?: boolean\n req: PayloadRequest\n /** Return the cookie as parts rather than a serialized header string. */\n returnCookieAsObject?: TReturnCookieAsObject\n}\n\n/**\n * Runs the login operation and builds the auth cookie from its token, then\n * applies `auth.removeTokenFromResponses` to the returned result.\n *\n * The order matters: the token has to be read before the flag strips it, or the\n * caller ends up returning a user with no way to establish a session. Shared by\n * the REST login handler and the framework adapters' `login` server function so\n * that ordering only exists in one place.\n */\nexport const loginWithCookie = async <\n TSlug extends AuthCollectionSlug,\n TReturnCookieAsObject extends boolean = false,\n>({\n collection,\n data,\n depth,\n overrideAccess,\n req,\n returnCookieAsObject,\n}: LoginWithCookieArgs<TReturnCookieAsObject>): Promise<{\n cookie: TReturnCookieAsObject extends true ? CookieObject : string\n result: LoginResult<TSlug>\n}> => {\n const result = await loginOperation({\n collection,\n data,\n depth,\n overrideAccess,\n req,\n })\n\n const cookie = generatePayloadCookie({\n collectionAuthConfig: collection.config.auth,\n cookiePrefix: req.payload.config.cookiePrefix,\n returnCookieAsObject: returnCookieAsObject ?? false,\n token: result.token!,\n }) as TReturnCookieAsObject extends true ? CookieObject : string\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return { cookie, result }\n}\n"],"names":["generatePayloadCookie","loginOperation","loginWithCookie","collection","data","depth","overrideAccess","req","returnCookieAsObject","result","cookie","collectionAuthConfig","config","auth","cookiePrefix","payload","token","removeTokenFromResponses"],"mappings":"AAMA,SAASA,qBAAqB,QAAQ,eAAc;AACpD,SAASC,cAAc,QAAQ,wBAAuB;AActD;;;;;;;;CAQC,GACD,OAAO,MAAMC,kBAAkB,OAG7B,EACAC,UAAU,EACVC,IAAI,EACJC,KAAK,EACLC,cAAc,EACdC,GAAG,EACHC,oBAAoB,EACuB;IAI3C,MAAMC,SAAS,MAAMR,eAAe;QAClCE;QACAC;QACAC;QACAC;QACAC;IACF;IAEA,MAAMG,SAASV,sBAAsB;QACnCW,sBAAsBR,WAAWS,MAAM,CAACC,IAAI;QAC5CC,cAAcP,IAAIQ,OAAO,CAACH,MAAM,CAACE,YAAY;QAC7CN,sBAAsBA,wBAAwB;QAC9CQ,OAAOP,OAAOO,KAAK;IACrB;IAEA,IAAIb,WAAWS,MAAM,CAACC,IAAI,CAACI,wBAAwB,EAAE;QACnD,OAAOR,OAAOO,KAAK;IACrB;IAEA,OAAO;QAAEN;QAAQD;IAAO;AAC1B,EAAC"}
@@ -0,0 +1,47 @@
1
+ import type { ServerAdapter } from '../../admin/adapters/server.js';
2
+ import type { Auth } from '../types.js';
3
+ /**
4
+ * Object form returned by `generatePayloadCookie`/`generateExpiredPayloadCookie`
5
+ * when `returnCookieAsObject` is `true`.
6
+ */
7
+ export type GeneratedCookie = {
8
+ domain?: string;
9
+ expires?: string;
10
+ httpOnly?: boolean;
11
+ maxAge?: number;
12
+ name: string;
13
+ path?: string;
14
+ sameSite?: 'Lax' | 'None' | 'Strict';
15
+ secure?: boolean;
16
+ value: string | undefined;
17
+ };
18
+ type AuthCookieArgs = {
19
+ authConfig: Auth;
20
+ cookiePrefix: string;
21
+ serverAdapter: ServerAdapter;
22
+ };
23
+ /** Writes an already-generated cookie through the framework's cookie API. */
24
+ export declare function applyAuthCookie({ cookie, serverAdapter, }: {
25
+ cookie: GeneratedCookie;
26
+ serverAdapter: ServerAdapter;
27
+ }): Promise<void>;
28
+ /** Writes the Payload auth cookie for `token` through the framework's cookie API. */
29
+ export declare function setAuthCookie({ authConfig, cookiePrefix, serverAdapter, token, }: {
30
+ token: string;
31
+ } & AuthCookieArgs): Promise<void>;
32
+ /**
33
+ * Expires the Payload auth cookie. Written with the same `domain`/`path`/`secure`
34
+ * attributes it was set with — a mismatched `domain` leaves the original cookie
35
+ * in place.
36
+ */
37
+ export declare function clearAuthCookie({ authConfig, cookiePrefix, serverAdapter, }: AuthCookieArgs): Promise<void>;
38
+ /** Reads the request's existing Payload auth cookie, if any. */
39
+ export declare function getExistingAuthToken({ cookiePrefix, serverAdapter, }: {
40
+ cookiePrefix: string;
41
+ serverAdapter: ServerAdapter;
42
+ }): Promise<{
43
+ name: string;
44
+ value: string;
45
+ } | undefined>;
46
+ export {};
47
+ //# sourceMappingURL=cookies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cookies.d.ts","sourceRoot":"","sources":["../../../src/auth/serverFunctions/cookies.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAIvC;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAA;IACpC,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;CAC1B,CAAA;AAcD,KAAK,cAAc,GAAG;IACpB,UAAU,EAAE,IAAI,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,aAAa,CAAA;CAC7B,CAAA;AAED,6EAA6E;AAC7E,wBAAsB,eAAe,CAAC,EACpC,MAAM,EACN,aAAa,GACd,EAAE;IACD,MAAM,EAAE,eAAe,CAAA;IACvB,aAAa,EAAE,aAAa,CAAA;CAC7B,GAAG,OAAO,CAAC,IAAI,CAAC,CAMhB;AAED,qFAAqF;AACrF,wBAAsB,aAAa,CAAC,EAClC,UAAU,EACV,YAAY,EACZ,aAAa,EACb,KAAK,GACN,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CASpD;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,EACpC,UAAU,EACV,YAAY,EACZ,aAAa,GACd,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAQhC;AAED,gEAAgE;AAChE,wBAAsB,oBAAoB,CAAC,EACzC,YAAY,EACZ,aAAa,GACd,EAAE;IACD,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,aAAa,CAAA;CAC7B,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAAC,CASvD"}
@@ -0,0 +1,52 @@
1
+ import { generateExpiredPayloadCookie, generatePayloadCookie } from '../cookies.js';
2
+ // `generateCookie` emits capitalized `SameSite` values (as they appear in the
3
+ // header); `CookieOptions` takes the lowercase form.
4
+ const toCookieOptions = (cookie)=>({
5
+ domain: cookie.domain,
6
+ expires: cookie.expires ? new Date(cookie.expires) : undefined,
7
+ httpOnly: cookie.httpOnly,
8
+ maxAge: cookie.maxAge,
9
+ path: cookie.path,
10
+ sameSite: cookie.sameSite?.toLowerCase(),
11
+ secure: cookie.secure
12
+ });
13
+ /** Writes an already-generated cookie through the framework's cookie API. */ export async function applyAuthCookie({ cookie, serverAdapter }) {
14
+ if (!cookie.value) {
15
+ return;
16
+ }
17
+ await serverAdapter.setCookie(cookie.name, cookie.value, toCookieOptions(cookie));
18
+ }
19
+ /** Writes the Payload auth cookie for `token` through the framework's cookie API. */ export async function setAuthCookie({ authConfig, cookiePrefix, serverAdapter, token }) {
20
+ const cookie = generatePayloadCookie({
21
+ collectionAuthConfig: authConfig,
22
+ cookiePrefix,
23
+ returnCookieAsObject: true,
24
+ token
25
+ });
26
+ await applyAuthCookie({
27
+ cookie,
28
+ serverAdapter
29
+ });
30
+ }
31
+ /**
32
+ * Expires the Payload auth cookie. Written with the same `domain`/`path`/`secure`
33
+ * attributes it was set with — a mismatched `domain` leaves the original cookie
34
+ * in place.
35
+ */ export async function clearAuthCookie({ authConfig, cookiePrefix, serverAdapter }) {
36
+ const cookie = generateExpiredPayloadCookie({
37
+ collectionAuthConfig: authConfig,
38
+ cookiePrefix,
39
+ returnCookieAsObject: true
40
+ });
41
+ await serverAdapter.setCookie(cookie.name, '', toCookieOptions(cookie));
42
+ }
43
+ /** Reads the request's existing Payload auth cookie, if any. */ export async function getExistingAuthToken({ cookiePrefix, serverAdapter }) {
44
+ const store = await serverAdapter.getCookies();
45
+ const allCookies = store.getAll?.();
46
+ if (allCookies) {
47
+ return allCookies.find((cookie)=>cookie.name.startsWith(cookiePrefix));
48
+ }
49
+ return store.get(`${cookiePrefix}-token`) ?? undefined;
50
+ }
51
+
52
+ //# sourceMappingURL=cookies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/auth/serverFunctions/cookies.ts"],"sourcesContent":["import type { CookieOptions } from '../../admin/adapters/cookies.js'\nimport type { ServerAdapter } from '../../admin/adapters/server.js'\nimport type { Auth } from '../types.js'\n\nimport { generateExpiredPayloadCookie, generatePayloadCookie } from '../cookies.js'\n\n/**\n * Object form returned by `generatePayloadCookie`/`generateExpiredPayloadCookie`\n * when `returnCookieAsObject` is `true`.\n */\nexport type GeneratedCookie = {\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\n// `generateCookie` emits capitalized `SameSite` values (as they appear in the\n// header); `CookieOptions` takes the lowercase form.\nconst toCookieOptions = (cookie: GeneratedCookie): CookieOptions => ({\n domain: cookie.domain,\n expires: cookie.expires ? new Date(cookie.expires) : undefined,\n httpOnly: cookie.httpOnly,\n maxAge: cookie.maxAge,\n path: cookie.path,\n sameSite: cookie.sameSite?.toLowerCase() as CookieOptions['sameSite'],\n secure: cookie.secure,\n})\n\ntype AuthCookieArgs = {\n authConfig: Auth\n cookiePrefix: string\n serverAdapter: ServerAdapter\n}\n\n/** Writes an already-generated cookie through the framework's cookie API. */\nexport async function applyAuthCookie({\n cookie,\n serverAdapter,\n}: {\n cookie: GeneratedCookie\n serverAdapter: ServerAdapter\n}): Promise<void> {\n if (!cookie.value) {\n return\n }\n\n await serverAdapter.setCookie(cookie.name, cookie.value, toCookieOptions(cookie))\n}\n\n/** Writes the Payload auth cookie for `token` through the framework's cookie API. */\nexport async function setAuthCookie({\n authConfig,\n cookiePrefix,\n serverAdapter,\n token,\n}: { token: string } & AuthCookieArgs): Promise<void> {\n const cookie = generatePayloadCookie({\n collectionAuthConfig: authConfig,\n cookiePrefix,\n returnCookieAsObject: true,\n token,\n }) as GeneratedCookie\n\n await applyAuthCookie({ cookie, serverAdapter })\n}\n\n/**\n * Expires the Payload auth cookie. Written with the same `domain`/`path`/`secure`\n * attributes it was set with — a mismatched `domain` leaves the original cookie\n * in place.\n */\nexport async function clearAuthCookie({\n authConfig,\n cookiePrefix,\n serverAdapter,\n}: AuthCookieArgs): Promise<void> {\n const cookie = generateExpiredPayloadCookie({\n collectionAuthConfig: authConfig,\n cookiePrefix,\n returnCookieAsObject: true,\n }) as GeneratedCookie\n\n await serverAdapter.setCookie(cookie.name, '', toCookieOptions(cookie))\n}\n\n/** Reads the request's existing Payload auth cookie, if any. */\nexport async function getExistingAuthToken({\n cookiePrefix,\n serverAdapter,\n}: {\n cookiePrefix: string\n serverAdapter: ServerAdapter\n}): Promise<{ name: string; value: string } | undefined> {\n const store = await serverAdapter.getCookies()\n const allCookies = store.getAll?.()\n\n if (allCookies) {\n return allCookies.find((cookie) => cookie.name.startsWith(cookiePrefix))\n }\n\n return store.get(`${cookiePrefix}-token`) ?? undefined\n}\n"],"names":["generateExpiredPayloadCookie","generatePayloadCookie","toCookieOptions","cookie","domain","expires","Date","undefined","httpOnly","maxAge","path","sameSite","toLowerCase","secure","applyAuthCookie","serverAdapter","value","setCookie","name","setAuthCookie","authConfig","cookiePrefix","token","collectionAuthConfig","returnCookieAsObject","clearAuthCookie","getExistingAuthToken","store","getCookies","allCookies","getAll","find","startsWith","get"],"mappings":"AAIA,SAASA,4BAA4B,EAAEC,qBAAqB,QAAQ,gBAAe;AAkBnF,8EAA8E;AAC9E,qDAAqD;AACrD,MAAMC,kBAAkB,CAACC,SAA4C,CAAA;QACnEC,QAAQD,OAAOC,MAAM;QACrBC,SAASF,OAAOE,OAAO,GAAG,IAAIC,KAAKH,OAAOE,OAAO,IAAIE;QACrDC,UAAUL,OAAOK,QAAQ;QACzBC,QAAQN,OAAOM,MAAM;QACrBC,MAAMP,OAAOO,IAAI;QACjBC,UAAUR,OAAOQ,QAAQ,EAAEC;QAC3BC,QAAQV,OAAOU,MAAM;IACvB,CAAA;AAQA,2EAA2E,GAC3E,OAAO,eAAeC,gBAAgB,EACpCX,MAAM,EACNY,aAAa,EAId;IACC,IAAI,CAACZ,OAAOa,KAAK,EAAE;QACjB;IACF;IAEA,MAAMD,cAAcE,SAAS,CAACd,OAAOe,IAAI,EAAEf,OAAOa,KAAK,EAAEd,gBAAgBC;AAC3E;AAEA,mFAAmF,GACnF,OAAO,eAAegB,cAAc,EAClCC,UAAU,EACVC,YAAY,EACZN,aAAa,EACbO,KAAK,EAC8B;IACnC,MAAMnB,SAASF,sBAAsB;QACnCsB,sBAAsBH;QACtBC;QACAG,sBAAsB;QACtBF;IACF;IAEA,MAAMR,gBAAgB;QAAEX;QAAQY;IAAc;AAChD;AAEA;;;;CAIC,GACD,OAAO,eAAeU,gBAAgB,EACpCL,UAAU,EACVC,YAAY,EACZN,aAAa,EACE;IACf,MAAMZ,SAASH,6BAA6B;QAC1CuB,sBAAsBH;QACtBC;QACAG,sBAAsB;IACxB;IAEA,MAAMT,cAAcE,SAAS,CAACd,OAAOe,IAAI,EAAE,IAAIhB,gBAAgBC;AACjE;AAEA,8DAA8D,GAC9D,OAAO,eAAeuB,qBAAqB,EACzCL,YAAY,EACZN,aAAa,EAId;IACC,MAAMY,QAAQ,MAAMZ,cAAca,UAAU;IAC5C,MAAMC,aAAaF,MAAMG,MAAM;IAE/B,IAAID,YAAY;QACd,OAAOA,WAAWE,IAAI,CAAC,CAAC5B,SAAWA,OAAOe,IAAI,CAACc,UAAU,CAACX;IAC5D;IAEA,OAAOM,MAAMM,GAAG,CAAC,GAAGZ,aAAa,MAAM,CAAC,KAAKd;AAC/C"}
@@ -0,0 +1,29 @@
1
+ import type { ServerAdapter } from '../../admin/adapters/server.js';
2
+ import type { SanitizedConfig } from '../../config/types.js';
3
+ import type { AuthCollectionSlug } from '../../index.js';
4
+ import type { MaybePromise } from '../../types/index.js';
5
+ import type { LoginResult } from '../operations/login.js';
6
+ export type LoginArgs<TSlug extends AuthCollectionSlug> = {
7
+ collection: TSlug;
8
+ config: MaybePromise<SanitizedConfig>;
9
+ password: string;
10
+ serverAdapter: ServerAdapter;
11
+ } & ({
12
+ email: string;
13
+ username?: never;
14
+ } | {
15
+ email?: never;
16
+ username: string;
17
+ });
18
+ /**
19
+ * `LoginArgs` as the adapters expose it — they bind `serverAdapter` themselves.
20
+ * Distributes over the email/username union so the either-or survives; a plain
21
+ * `Omit` collapses the union and accepts both keys at once.
22
+ */
23
+ export type LoginArgsWithoutServerAdapter<TSlug extends AuthCollectionSlug> = LoginArgs<TSlug> extends infer TArgs ? TArgs extends unknown ? Omit<TArgs, 'serverAdapter'> : never : never;
24
+ /**
25
+ * Logs a user in and writes the auth cookie through the supplied `serverAdapter`,
26
+ * so the function is framework-agnostic; each adapter binds its own.
27
+ */
28
+ export declare function login<TSlug extends AuthCollectionSlug>({ collection, config, email, password, serverAdapter, username, }: LoginArgs<TSlug>): Promise<LoginResult<TSlug>>;
29
+ //# sourceMappingURL=login.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/auth/serverFunctions/login.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAOzD,MAAM,MAAM,SAAS,CAAC,KAAK,SAAS,kBAAkB,IAAI;IACxD,UAAU,EAAE,KAAK,CAAA;IACjB,MAAM,EAAE,YAAY,CAAC,eAAe,CAAC,CAAA;IACrC,QAAQ,EAAE,MAAM,CAAA;IAChB,aAAa,EAAE,aAAa,CAAA;CAC7B,GAAG,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,KAAK,CAAC,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAE/E;;;;GAIG;AACH,MAAM,MAAM,6BAA6B,CAAC,KAAK,SAAS,kBAAkB,IACxE,SAAS,CAAC,KAAK,CAAC,SAAS,MAAM,KAAK,GAChC,KAAK,SAAS,OAAO,GACnB,IAAI,CAAC,KAAK,EAAE,eAAe,CAAC,GAC5B,KAAK,GACP,KAAK,CAAA;AAEX;;;GAGG;AACH,wBAAsB,KAAK,CAAC,KAAK,SAAS,kBAAkB,EAAE,EAC5D,UAAU,EACV,MAAM,EACN,KAAK,EACL,QAAQ,EACR,aAAa,EACb,QAAQ,GACT,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAgDhD"}
@@ -0,0 +1,63 @@
1
+ import { getPayload } from '../../index.js';
2
+ import { createLocalReq } from '../../utilities/createLocalReq.js';
3
+ import { loginWithCookie } from '../loginWithCookie.js';
4
+ import { applyAuthCookie } from './cookies.js';
5
+ /**
6
+ * Logs a user in and writes the auth cookie through the supplied `serverAdapter`,
7
+ * so the function is framework-agnostic; each adapter binds its own.
8
+ */ export async function login({ collection, config, email, password, serverAdapter, username }) {
9
+ const payload = await getPayload({
10
+ config,
11
+ cron: true
12
+ });
13
+ const authConfig = payload.collections[collection]?.config.auth;
14
+ if (!authConfig) {
15
+ throw new Error(`No auth config found for collection: ${collection}`);
16
+ }
17
+ const loginWithUsername = authConfig.loginWithUsername ?? false;
18
+ if (loginWithUsername) {
19
+ if (loginWithUsername.allowEmailLogin) {
20
+ if (!email && !username) {
21
+ throw new Error('Email or username is required.');
22
+ }
23
+ } else {
24
+ if (!username) {
25
+ throw new Error('Username is required.');
26
+ }
27
+ }
28
+ } else {
29
+ if (!email) {
30
+ throw new Error('Email is required.');
31
+ }
32
+ }
33
+ let loginData;
34
+ if (loginWithUsername) {
35
+ loginData = username ? {
36
+ password,
37
+ username
38
+ } : {
39
+ email,
40
+ password
41
+ };
42
+ } else {
43
+ loginData = {
44
+ email,
45
+ password
46
+ };
47
+ }
48
+ const collectionConfig = payload.collections[collection];
49
+ const { cookie, result } = await loginWithCookie({
50
+ collection: collectionConfig,
51
+ data: loginData,
52
+ overrideAccess: true,
53
+ req: await createLocalReq({}, payload),
54
+ returnCookieAsObject: true
55
+ });
56
+ await applyAuthCookie({
57
+ cookie,
58
+ serverAdapter
59
+ });
60
+ return result;
61
+ }
62
+
63
+ //# sourceMappingURL=login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/auth/serverFunctions/login.ts"],"sourcesContent":["import type { ServerAdapter } from '../../admin/adapters/server.js'\nimport type { SanitizedConfig } from '../../config/types.js'\nimport type { AuthCollectionSlug } from '../../index.js'\nimport type { MaybePromise } from '../../types/index.js'\nimport type { LoginResult } from '../operations/login.js'\n\nimport { getPayload } from '../../index.js'\nimport { createLocalReq } from '../../utilities/createLocalReq.js'\nimport { loginWithCookie } from '../loginWithCookie.js'\nimport { applyAuthCookie } from './cookies.js'\n\nexport type LoginArgs<TSlug extends AuthCollectionSlug> = {\n collection: TSlug\n config: MaybePromise<SanitizedConfig>\n password: string\n serverAdapter: ServerAdapter\n} & ({ email: string; username?: never } | { email?: never; username: string })\n\n/**\n * `LoginArgs` as the adapters expose it — they bind `serverAdapter` themselves.\n * Distributes over the email/username union so the either-or survives; a plain\n * `Omit` collapses the union and accepts both keys at once.\n */\nexport type LoginArgsWithoutServerAdapter<TSlug extends AuthCollectionSlug> =\n LoginArgs<TSlug> extends infer TArgs\n ? TArgs extends unknown\n ? Omit<TArgs, 'serverAdapter'>\n : never\n : never\n\n/**\n * Logs a user in and writes the auth cookie through the supplied `serverAdapter`,\n * so the function is framework-agnostic; each adapter binds its own.\n */\nexport async function login<TSlug extends AuthCollectionSlug>({\n collection,\n config,\n email,\n password,\n serverAdapter,\n username,\n}: LoginArgs<TSlug>): Promise<LoginResult<TSlug>> {\n const payload = await getPayload({ config, cron: true })\n\n const authConfig = payload.collections[collection]?.config.auth\n\n if (!authConfig) {\n throw new Error(`No auth config found for collection: ${collection}`)\n }\n\n const loginWithUsername = authConfig.loginWithUsername ?? false\n\n if (loginWithUsername) {\n if (loginWithUsername.allowEmailLogin) {\n if (!email && !username) {\n throw new Error('Email or username is required.')\n }\n } else {\n if (!username) {\n throw new Error('Username is required.')\n }\n }\n } else {\n if (!email) {\n throw new Error('Email is required.')\n }\n }\n\n let loginData\n\n if (loginWithUsername) {\n loginData = username ? { password, username } : { email, password }\n } else {\n loginData = { email, password }\n }\n\n const collectionConfig = payload.collections[collection]!\n\n const { cookie, result } = await loginWithCookie({\n collection: collectionConfig,\n data: loginData as Parameters<typeof loginWithCookie>[0]['data'],\n overrideAccess: true,\n req: await createLocalReq({}, payload),\n returnCookieAsObject: true,\n })\n\n await applyAuthCookie({ cookie, serverAdapter })\n\n return result as LoginResult<TSlug>\n}\n"],"names":["getPayload","createLocalReq","loginWithCookie","applyAuthCookie","login","collection","config","email","password","serverAdapter","username","payload","cron","authConfig","collections","auth","Error","loginWithUsername","allowEmailLogin","loginData","collectionConfig","cookie","result","data","overrideAccess","req","returnCookieAsObject"],"mappings":"AAMA,SAASA,UAAU,QAAQ,iBAAgB;AAC3C,SAASC,cAAc,QAAQ,oCAAmC;AAClE,SAASC,eAAe,QAAQ,wBAAuB;AACvD,SAASC,eAAe,QAAQ,eAAc;AAqB9C;;;CAGC,GACD,OAAO,eAAeC,MAAwC,EAC5DC,UAAU,EACVC,MAAM,EACNC,KAAK,EACLC,QAAQ,EACRC,aAAa,EACbC,QAAQ,EACS;IACjB,MAAMC,UAAU,MAAMX,WAAW;QAAEM;QAAQM,MAAM;IAAK;IAEtD,MAAMC,aAAaF,QAAQG,WAAW,CAACT,WAAW,EAAEC,OAAOS;IAE3D,IAAI,CAACF,YAAY;QACf,MAAM,IAAIG,MAAM,CAAC,qCAAqC,EAAEX,YAAY;IACtE;IAEA,MAAMY,oBAAoBJ,WAAWI,iBAAiB,IAAI;IAE1D,IAAIA,mBAAmB;QACrB,IAAIA,kBAAkBC,eAAe,EAAE;YACrC,IAAI,CAACX,SAAS,CAACG,UAAU;gBACvB,MAAM,IAAIM,MAAM;YAClB;QACF,OAAO;YACL,IAAI,CAACN,UAAU;gBACb,MAAM,IAAIM,MAAM;YAClB;QACF;IACF,OAAO;QACL,IAAI,CAACT,OAAO;YACV,MAAM,IAAIS,MAAM;QAClB;IACF;IAEA,IAAIG;IAEJ,IAAIF,mBAAmB;QACrBE,YAAYT,WAAW;YAAEF;YAAUE;QAAS,IAAI;YAAEH;YAAOC;QAAS;IACpE,OAAO;QACLW,YAAY;YAAEZ;YAAOC;QAAS;IAChC;IAEA,MAAMY,mBAAmBT,QAAQG,WAAW,CAACT,WAAW;IAExD,MAAM,EAAEgB,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAMpB,gBAAgB;QAC/CG,YAAYe;QACZG,MAAMJ;QACNK,gBAAgB;QAChBC,KAAK,MAAMxB,eAAe,CAAC,GAAGU;QAC9Be,sBAAsB;IACxB;IAEA,MAAMvB,gBAAgB;QAAEkB;QAAQZ;IAAc;IAE9C,OAAOa;AACT"}
@@ -0,0 +1,17 @@
1
+ import type { ServerAdapter } from '../../admin/adapters/server.js';
2
+ import type { SanitizedConfig } from '../../config/types.js';
3
+ import type { MaybePromise } from '../../types/index.js';
4
+ export type LogoutArgs = {
5
+ allSessions?: boolean;
6
+ config: MaybePromise<SanitizedConfig>;
7
+ serverAdapter: ServerAdapter;
8
+ };
9
+ /**
10
+ * Logs the current user out and expires the auth cookie through the supplied
11
+ * `serverAdapter`, so the function is framework-agnostic; each adapter binds its own.
12
+ */
13
+ export declare function logout({ allSessions, config, serverAdapter, }: LogoutArgs): Promise<{
14
+ message: string;
15
+ success: boolean;
16
+ }>;
17
+ //# sourceMappingURL=logout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/auth/serverFunctions/logout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAOxD,MAAM,MAAM,UAAU,GAAG;IACvB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,EAAE,YAAY,CAAC,eAAe,CAAC,CAAA;IACrC,aAAa,EAAE,aAAa,CAAA;CAC7B,CAAA;AAED;;;GAGG;AACH,wBAAsB,MAAM,CAAC,EAC3B,WAAmB,EACnB,MAAM,EACN,aAAa,GACd,EAAE,UAAU,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAoC7D"}
@@ -0,0 +1,58 @@
1
+ import { getPayload } from '../../index.js';
2
+ import { createLocalReq } from '../../utilities/createLocalReq.js';
3
+ import { logoutOperation } from '../operations/logout.js';
4
+ import { clearAuthCookie } from './cookies.js';
5
+ /**
6
+ * Logs the current user out and expires the auth cookie through the supplied
7
+ * `serverAdapter`, so the function is framework-agnostic; each adapter binds its own.
8
+ */ export async function logout({ allSessions = false, config, serverAdapter }) {
9
+ const payload = await getPayload({
10
+ config,
11
+ cron: true
12
+ });
13
+ const headers = await serverAdapter.getHeaders();
14
+ const authResult = await payload.auth({
15
+ headers
16
+ });
17
+ if (!authResult.user) {
18
+ return {
19
+ message: 'User already logged out',
20
+ success: true
21
+ };
22
+ }
23
+ const { user } = authResult;
24
+ const req = await createLocalReq({
25
+ user
26
+ }, payload);
27
+ const collection = payload.collections[user.collection];
28
+ if (!collection) {
29
+ return {
30
+ message: 'Collection not found',
31
+ success: false
32
+ };
33
+ }
34
+ const logoutResult = await logoutOperation({
35
+ allSessions,
36
+ collection,
37
+ req
38
+ });
39
+ if (!logoutResult) {
40
+ return {
41
+ message: 'Logout failed',
42
+ success: false
43
+ };
44
+ }
45
+ if (collection.config.auth) {
46
+ await clearAuthCookie({
47
+ authConfig: collection.config.auth,
48
+ cookiePrefix: payload.config.cookiePrefix,
49
+ serverAdapter
50
+ });
51
+ }
52
+ return {
53
+ message: 'User logged out successfully',
54
+ success: true
55
+ };
56
+ }
57
+
58
+ //# sourceMappingURL=logout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/auth/serverFunctions/logout.ts"],"sourcesContent":["import type { ServerAdapter } from '../../admin/adapters/server.js'\nimport type { SanitizedConfig } from '../../config/types.js'\nimport type { MaybePromise } from '../../types/index.js'\n\nimport { getPayload } from '../../index.js'\nimport { createLocalReq } from '../../utilities/createLocalReq.js'\nimport { logoutOperation } from '../operations/logout.js'\nimport { clearAuthCookie } from './cookies.js'\n\nexport type LogoutArgs = {\n allSessions?: boolean\n config: MaybePromise<SanitizedConfig>\n serverAdapter: ServerAdapter\n}\n\n/**\n * Logs the current user out and expires the auth cookie through the supplied\n * `serverAdapter`, so the function is framework-agnostic; each adapter binds its own.\n */\nexport async function logout({\n allSessions = false,\n config,\n serverAdapter,\n}: LogoutArgs): Promise<{ message: string; success: boolean }> {\n const payload = await getPayload({ config, cron: true })\n const headers = await serverAdapter.getHeaders()\n const authResult = await payload.auth({ headers })\n\n if (!authResult.user) {\n return { message: 'User already logged out', success: true }\n }\n\n const { user } = authResult\n const req = await createLocalReq({ user }, payload)\n const collection = payload.collections[user.collection]\n\n if (!collection) {\n return { message: 'Collection not found', success: false }\n }\n\n const logoutResult = await logoutOperation({\n allSessions,\n collection,\n req,\n })\n\n if (!logoutResult) {\n return { message: 'Logout failed', success: false }\n }\n\n if (collection.config.auth) {\n await clearAuthCookie({\n authConfig: collection.config.auth,\n cookiePrefix: payload.config.cookiePrefix,\n serverAdapter,\n })\n }\n\n return { message: 'User logged out successfully', success: true }\n}\n"],"names":["getPayload","createLocalReq","logoutOperation","clearAuthCookie","logout","allSessions","config","serverAdapter","payload","cron","headers","getHeaders","authResult","auth","user","message","success","req","collection","collections","logoutResult","authConfig","cookiePrefix"],"mappings":"AAIA,SAASA,UAAU,QAAQ,iBAAgB;AAC3C,SAASC,cAAc,QAAQ,oCAAmC;AAClE,SAASC,eAAe,QAAQ,0BAAyB;AACzD,SAASC,eAAe,QAAQ,eAAc;AAQ9C;;;CAGC,GACD,OAAO,eAAeC,OAAO,EAC3BC,cAAc,KAAK,EACnBC,MAAM,EACNC,aAAa,EACF;IACX,MAAMC,UAAU,MAAMR,WAAW;QAAEM;QAAQG,MAAM;IAAK;IACtD,MAAMC,UAAU,MAAMH,cAAcI,UAAU;IAC9C,MAAMC,aAAa,MAAMJ,QAAQK,IAAI,CAAC;QAAEH;IAAQ;IAEhD,IAAI,CAACE,WAAWE,IAAI,EAAE;QACpB,OAAO;YAAEC,SAAS;YAA2BC,SAAS;QAAK;IAC7D;IAEA,MAAM,EAAEF,IAAI,EAAE,GAAGF;IACjB,MAAMK,MAAM,MAAMhB,eAAe;QAAEa;IAAK,GAAGN;IAC3C,MAAMU,aAAaV,QAAQW,WAAW,CAACL,KAAKI,UAAU,CAAC;IAEvD,IAAI,CAACA,YAAY;QACf,OAAO;YAAEH,SAAS;YAAwBC,SAAS;QAAM;IAC3D;IAEA,MAAMI,eAAe,MAAMlB,gBAAgB;QACzCG;QACAa;QACAD;IACF;IAEA,IAAI,CAACG,cAAc;QACjB,OAAO;YAAEL,SAAS;YAAiBC,SAAS;QAAM;IACpD;IAEA,IAAIE,WAAWZ,MAAM,CAACO,IAAI,EAAE;QAC1B,MAAMV,gBAAgB;YACpBkB,YAAYH,WAAWZ,MAAM,CAACO,IAAI;YAClCS,cAAcd,QAAQF,MAAM,CAACgB,YAAY;YACzCf;QACF;IACF;IAEA,OAAO;QAAEQ,SAAS;QAAgCC,SAAS;IAAK;AAClE"}
@@ -0,0 +1,17 @@
1
+ import type { ServerAdapter } from '../../admin/adapters/server.js';
2
+ import type { SanitizedConfig } from '../../config/types.js';
3
+ import type { MaybePromise } from '../../types/index.js';
4
+ export type RefreshArgs = {
5
+ config: MaybePromise<SanitizedConfig>;
6
+ serverAdapter: ServerAdapter;
7
+ };
8
+ /**
9
+ * Refreshes the current user's auth token and rewrites the cookie through the
10
+ * supplied `serverAdapter`, so the function is framework-agnostic; each adapter
11
+ * binds its own.
12
+ */
13
+ export declare function refresh({ config, serverAdapter, }: RefreshArgs): Promise<{
14
+ message: string;
15
+ success: boolean;
16
+ }>;
17
+ //# sourceMappingURL=refresh.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../../src/auth/serverFunctions/refresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAE5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAOxD,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,YAAY,CAAC,eAAe,CAAC,CAAA;IACrC,aAAa,EAAE,aAAa,CAAA;CAC7B,CAAA;AAED;;;;GAIG;AACH,wBAAsB,OAAO,CAAC,EAC5B,MAAM,EACN,aAAa,GACd,EAAE,WAAW,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CA4C9D"}
@@ -0,0 +1,61 @@
1
+ import { getPayload } from '../../index.js';
2
+ import { createLocalReq } from '../../utilities/createLocalReq.js';
3
+ import { refreshOperation } from '../operations/refresh.js';
4
+ import { getExistingAuthToken, setAuthCookie } from './cookies.js';
5
+ /**
6
+ * Refreshes the current user's auth token and rewrites the cookie through the
7
+ * supplied `serverAdapter`, so the function is framework-agnostic; each adapter
8
+ * binds its own.
9
+ */ export async function refresh({ config, serverAdapter }) {
10
+ const payload = await getPayload({
11
+ config,
12
+ cron: true
13
+ });
14
+ const headers = await serverAdapter.getHeaders();
15
+ const result = await payload.auth({
16
+ headers
17
+ });
18
+ if (!result.user) {
19
+ throw new Error('Cannot refresh token: user not authenticated');
20
+ }
21
+ const existingCookie = await getExistingAuthToken({
22
+ cookiePrefix: payload.config.cookiePrefix,
23
+ serverAdapter
24
+ });
25
+ if (!existingCookie) {
26
+ return {
27
+ message: 'No valid token found to refresh',
28
+ success: false
29
+ };
30
+ }
31
+ const collection = result.user.collection;
32
+ const collectionConfig = payload.collections[collection];
33
+ if (!collectionConfig?.config.auth) {
34
+ throw new Error(`No auth config found for collection: ${collection}`);
35
+ }
36
+ const req = await createLocalReq({
37
+ user: result.user
38
+ }, payload);
39
+ const refreshResult = await refreshOperation({
40
+ collection: collectionConfig,
41
+ req
42
+ });
43
+ if (!refreshResult) {
44
+ return {
45
+ message: 'Token refresh failed',
46
+ success: false
47
+ };
48
+ }
49
+ await setAuthCookie({
50
+ authConfig: collectionConfig.config.auth,
51
+ cookiePrefix: payload.config.cookiePrefix,
52
+ serverAdapter,
53
+ token: refreshResult.refreshedToken
54
+ });
55
+ return {
56
+ message: 'Token refreshed successfully',
57
+ success: true
58
+ };
59
+ }
60
+
61
+ //# sourceMappingURL=refresh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/auth/serverFunctions/refresh.ts"],"sourcesContent":["import type { ServerAdapter } from '../../admin/adapters/server.js'\nimport type { SanitizedConfig } from '../../config/types.js'\nimport type { CollectionSlug } from '../../index.js'\nimport type { MaybePromise } from '../../types/index.js'\n\nimport { getPayload } from '../../index.js'\nimport { createLocalReq } from '../../utilities/createLocalReq.js'\nimport { refreshOperation } from '../operations/refresh.js'\nimport { getExistingAuthToken, setAuthCookie } from './cookies.js'\n\nexport type RefreshArgs = {\n config: MaybePromise<SanitizedConfig>\n serverAdapter: ServerAdapter\n}\n\n/**\n * Refreshes the current user's auth token and rewrites the cookie through the\n * supplied `serverAdapter`, so the function is framework-agnostic; each adapter\n * binds its own.\n */\nexport async function refresh({\n config,\n serverAdapter,\n}: RefreshArgs): Promise<{ message: string; success: boolean }> {\n const payload = await getPayload({ config, cron: true })\n const headers = await serverAdapter.getHeaders()\n const result = await payload.auth({ headers })\n\n if (!result.user) {\n throw new Error('Cannot refresh token: user not authenticated')\n }\n\n const existingCookie = await getExistingAuthToken({\n cookiePrefix: payload.config.cookiePrefix,\n serverAdapter,\n })\n\n if (!existingCookie) {\n return { message: 'No valid token found to refresh', success: false }\n }\n\n const collection: CollectionSlug | undefined = result.user.collection\n const collectionConfig = payload.collections[collection]\n\n if (!collectionConfig?.config.auth) {\n throw new Error(`No auth config found for collection: ${collection}`)\n }\n\n const req = await createLocalReq({ user: result.user }, payload)\n\n const refreshResult = await refreshOperation({\n collection: collectionConfig,\n req,\n })\n\n if (!refreshResult) {\n return { message: 'Token refresh failed', success: false }\n }\n\n await setAuthCookie({\n authConfig: collectionConfig.config.auth,\n cookiePrefix: payload.config.cookiePrefix,\n serverAdapter,\n token: refreshResult.refreshedToken,\n })\n\n return { message: 'Token refreshed successfully', success: true }\n}\n"],"names":["getPayload","createLocalReq","refreshOperation","getExistingAuthToken","setAuthCookie","refresh","config","serverAdapter","payload","cron","headers","getHeaders","result","auth","user","Error","existingCookie","cookiePrefix","message","success","collection","collectionConfig","collections","req","refreshResult","authConfig","token","refreshedToken"],"mappings":"AAKA,SAASA,UAAU,QAAQ,iBAAgB;AAC3C,SAASC,cAAc,QAAQ,oCAAmC;AAClE,SAASC,gBAAgB,QAAQ,2BAA0B;AAC3D,SAASC,oBAAoB,EAAEC,aAAa,QAAQ,eAAc;AAOlE;;;;CAIC,GACD,OAAO,eAAeC,QAAQ,EAC5BC,MAAM,EACNC,aAAa,EACD;IACZ,MAAMC,UAAU,MAAMR,WAAW;QAAEM;QAAQG,MAAM;IAAK;IACtD,MAAMC,UAAU,MAAMH,cAAcI,UAAU;IAC9C,MAAMC,SAAS,MAAMJ,QAAQK,IAAI,CAAC;QAAEH;IAAQ;IAE5C,IAAI,CAACE,OAAOE,IAAI,EAAE;QAChB,MAAM,IAAIC,MAAM;IAClB;IAEA,MAAMC,iBAAiB,MAAMb,qBAAqB;QAChDc,cAAcT,QAAQF,MAAM,CAACW,YAAY;QACzCV;IACF;IAEA,IAAI,CAACS,gBAAgB;QACnB,OAAO;YAAEE,SAAS;YAAmCC,SAAS;QAAM;IACtE;IAEA,MAAMC,aAAyCR,OAAOE,IAAI,CAACM,UAAU;IACrE,MAAMC,mBAAmBb,QAAQc,WAAW,CAACF,WAAW;IAExD,IAAI,CAACC,kBAAkBf,OAAOO,MAAM;QAClC,MAAM,IAAIE,MAAM,CAAC,qCAAqC,EAAEK,YAAY;IACtE;IAEA,MAAMG,MAAM,MAAMtB,eAAe;QAAEa,MAAMF,OAAOE,IAAI;IAAC,GAAGN;IAExD,MAAMgB,gBAAgB,MAAMtB,iBAAiB;QAC3CkB,YAAYC;QACZE;IACF;IAEA,IAAI,CAACC,eAAe;QAClB,OAAO;YAAEN,SAAS;YAAwBC,SAAS;QAAM;IAC3D;IAEA,MAAMf,cAAc;QAClBqB,YAAYJ,iBAAiBf,MAAM,CAACO,IAAI;QACxCI,cAAcT,QAAQF,MAAM,CAACW,YAAY;QACzCV;QACAmB,OAAOF,cAAcG,cAAc;IACrC;IAEA,OAAO;QAAET,SAAS;QAAgCC,SAAS;IAAK;AAClE"}
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../src/collections/config/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AACrF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAIlD;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,OAAO,CAAC,gBAAgB,CA8C9C,CAAA;AAED,eAAO,MAAM,6BAA6B,eAAgB,gBAAgB,KAAG,gBA0D5E,CAAA;AAED,eAAO,MAAM,uBAAuB,SAAU,gBAAgB,KAAG,gBAqBhE,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,wBAIvC,CAAA;AAED,eAAO,MAAM,oCAAoC,sBAC5B,wBAAwB,KAC1C,wBAM6B,CAAA"}
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../src/collections/config/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AACrF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAIlD;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,OAAO,CAAC,gBAAgB,CA8C9C,CAAA;AAED,eAAO,MAAM,6BAA6B,eAAgB,gBAAgB,KAAG,gBA0D5E,CAAA;AAED,eAAO,MAAM,uBAAuB,SAAU,gBAAgB,KAAG,gBAsBhE,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,wBAIvC,CAAA;AAED,eAAO,MAAM,oCAAoC,sBAC5B,wBAAwB,KAC1C,wBAM6B,CAAA"}
@@ -119,6 +119,7 @@ export const addDefaultsToAuthConfig = (auth)=>{
119
119
  secure: false,
120
120
  ...auth.cookies || {}
121
121
  };
122
+ auth.depth = auth.depth ?? 0;
122
123
  auth.forgotPassword = auth.forgotPassword ?? {};
123
124
  auth.lockTime = auth.lockTime ?? 600000; // 10 minutes
124
125
  auth.loginWithUsername = auth.loginWithUsername ?? false;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/collections/config/defaults.ts"],"sourcesContent":["import type { IncomingAuthType, LoginWithUsernameOptions } from '../../auth/types.js'\nimport type { CollectionConfig } from './types.js'\n\nimport { defaultAccess } from '../../auth/defaultAccess.js'\n\n/**\n * @deprecated - remove in 4.0. This is error-prone, as mutating this object will affect any objects that use the defaults as a base.\n */\nexport const defaults: Partial<CollectionConfig> = {\n access: {\n create: defaultAccess,\n delete: defaultAccess,\n read: defaultAccess,\n unlock: defaultAccess,\n update: defaultAccess,\n },\n admin: {\n components: {},\n custom: {},\n enableRichTextLink: true,\n enableRichTextRelationship: true,\n pagination: {\n defaultLimit: 10,\n limits: [5, 10, 25, 50, 100],\n },\n useAsTitle: 'id',\n },\n auth: false,\n custom: {},\n endpoints: [],\n fields: [],\n hooks: {\n afterChange: [],\n afterDelete: [],\n afterForgotPassword: [],\n afterLogin: [],\n afterLogout: [],\n afterMe: [],\n afterOperation: [],\n afterRead: [],\n afterRefresh: [],\n beforeChange: [],\n beforeDelete: [],\n beforeLogin: [],\n beforeOperation: [],\n beforeRead: [],\n beforeValidate: [],\n me: [],\n refresh: [],\n },\n indexes: [],\n timestamps: true,\n upload: false,\n versions: true,\n}\n\nexport const addDefaultsToCollectionConfig = (collection: CollectionConfig): CollectionConfig => {\n collection.access = {\n create: defaultAccess,\n delete: defaultAccess,\n read: defaultAccess,\n unlock: defaultAccess,\n update: defaultAccess,\n ...(collection.access || {}),\n }\n\n collection.admin = {\n components: {},\n custom: {},\n enableRichTextLink: true,\n enableRichTextRelationship: true,\n useAsTitle: 'id',\n ...(collection.admin || {}),\n pagination: {\n defaultLimit: 10,\n limits: [5, 10, 25, 50, 100],\n ...(collection.admin?.pagination || {}),\n },\n }\n\n collection.auth = collection.auth ?? false\n collection.custom = collection.custom ?? {}\n collection.endpoints = collection.endpoints ?? []\n collection.fields = collection.fields ?? []\n collection.hierarchy = collection.hierarchy ?? false\n\n collection.hooks = {\n afterChange: [],\n afterDelete: [],\n afterForgotPassword: [],\n afterLogin: [],\n afterLogout: [],\n afterMe: [],\n afterOperation: [],\n afterRead: [],\n afterRefresh: [],\n beforeChange: [],\n beforeDelete: [],\n beforeLogin: [],\n beforeOperation: [],\n beforeRead: [],\n beforeValidate: [],\n me: [],\n refresh: [],\n ...(collection.hooks || {}),\n }\n\n collection.timestamps = collection.timestamps ?? true\n collection.upload = collection.upload ?? false\n collection.versions = collection.versions ?? true\n\n collection.indexes = collection.indexes ?? []\n\n return collection\n}\n\nexport const addDefaultsToAuthConfig = (auth: IncomingAuthType): IncomingAuthType => {\n auth.cookies = {\n sameSite: 'Lax',\n secure: false,\n ...(auth.cookies || {}),\n }\n\n auth.forgotPassword = auth.forgotPassword ?? {}\n auth.lockTime = auth.lockTime ?? 600000 // 10 minutes\n auth.loginWithUsername = auth.loginWithUsername ?? false\n auth.maxLoginAttempts = auth.maxLoginAttempts ?? 5\n auth.tokenExpiration = auth.tokenExpiration ?? 7200\n auth.useSessions = auth.useSessions ?? true\n auth.verify = auth.verify ?? false\n auth.strategies = auth.strategies ?? []\n\n if (!auth.disableLocalStrategy && auth.verify === true) {\n auth.verify = {}\n }\n\n return auth\n}\n\n/**\n * @deprecated - remove in 4.0. This is error-prone, as mutating this object will affect any objects that use the defaults as a base.\n */\nexport const loginWithUsernameDefaults: LoginWithUsernameOptions = {\n allowEmailLogin: false,\n requireEmail: false,\n requireUsername: true,\n}\n\nexport const addDefaultsToLoginWithUsernameConfig = (\n loginWithUsername: LoginWithUsernameOptions,\n): LoginWithUsernameOptions =>\n ({\n allowEmailLogin: false,\n requireEmail: false,\n requireUsername: true,\n ...(loginWithUsername || {}),\n }) as LoginWithUsernameOptions\n"],"names":["defaultAccess","defaults","access","create","delete","read","unlock","update","admin","components","custom","enableRichTextLink","enableRichTextRelationship","pagination","defaultLimit","limits","useAsTitle","auth","endpoints","fields","hooks","afterChange","afterDelete","afterForgotPassword","afterLogin","afterLogout","afterMe","afterOperation","afterRead","afterRefresh","beforeChange","beforeDelete","beforeLogin","beforeOperation","beforeRead","beforeValidate","me","refresh","indexes","timestamps","upload","versions","addDefaultsToCollectionConfig","collection","hierarchy","addDefaultsToAuthConfig","cookies","sameSite","secure","forgotPassword","lockTime","loginWithUsername","maxLoginAttempts","tokenExpiration","useSessions","verify","strategies","disableLocalStrategy","loginWithUsernameDefaults","allowEmailLogin","requireEmail","requireUsername","addDefaultsToLoginWithUsernameConfig"],"mappings":"AAGA,SAASA,aAAa,QAAQ,8BAA6B;AAE3D;;CAEC,GACD,OAAO,MAAMC,WA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B,IAAI;IACnDlC,KAAKmC,gBAAgB,GAAGnC,KAAKmC,gBAAgB,IAAI;IACjDnC,KAAKoC,eAAe,GAAGpC,KAAKoC,eAAe,IAAI;IAC/CpC,KAAKqC,WAAW,GAAGrC,KAAKqC,WAAW,IAAI;IACvCrC,KAAKsC,MAAM,GAAGtC,KAAKsC,MAAM,IAAI;IAC7BtC,KAAKuC,UAAU,GAAGvC,KAAKuC,UAAU,IAAI,EAAE;IAEvC,IAAI,CAACvC,KAAKwC,oBAAoB,IAAIxC,KAAKsC,MAAM,KAAK,MAAM;QACtDtC,KAAKsC,MAAM,GAAG,CAAC;IACjB;IAEA,OAAOtC;AACT,EAAC;AAED;;CAEC,GACD,OAAO,MAAMyC,4BAAsD;IACjEC,iBAAiB;IACjBC,cAAc;IACdC,iBAAiB;AACnB,EAAC;AAED,OAAO,MAAMC,uCAAuC,CAClDX,oBAEC,CAAA;QACCQ,iBAAiB;QACjBC,cAAc;QACdC,iBAAiB;QACjB,GAAIV,qBAAqB,CAAC,CAAC;IAC7B,CAAA,EAA8B"}
1
+ {"version":3,"sources":["../../../src/collections/config/defaults.ts"],"sourcesContent":["import type { IncomingAuthType, LoginWithUsernameOptions } from '../../auth/types.js'\nimport type { CollectionConfig } from './types.js'\n\nimport { defaultAccess } from '../../auth/defaultAccess.js'\n\n/**\n * @deprecated - remove in 4.0. This is error-prone, as mutating this object will affect any objects that use the defaults as a base.\n */\nexport const defaults: Partial<CollectionConfig> = {\n access: {\n create: defaultAccess,\n delete: defaultAccess,\n read: defaultAccess,\n unlock: defaultAccess,\n update: defaultAccess,\n },\n admin: {\n components: {},\n custom: {},\n enableRichTextLink: true,\n enableRichTextRelationship: true,\n pagination: {\n defaultLimit: 10,\n limits: [5, 10, 25, 50, 100],\n },\n useAsTitle: 'id',\n },\n auth: false,\n custom: {},\n endpoints: [],\n fields: [],\n hooks: {\n afterChange: [],\n afterDelete: [],\n afterForgotPassword: [],\n afterLogin: [],\n afterLogout: [],\n afterMe: [],\n afterOperation: [],\n afterRead: [],\n afterRefresh: [],\n beforeChange: [],\n beforeDelete: [],\n beforeLogin: [],\n beforeOperation: [],\n beforeRead: [],\n beforeValidate: [],\n me: [],\n refresh: [],\n },\n indexes: [],\n timestamps: true,\n upload: false,\n versions: true,\n}\n\nexport const addDefaultsToCollectionConfig = (collection: CollectionConfig): CollectionConfig => {\n collection.access = {\n create: defaultAccess,\n delete: defaultAccess,\n read: defaultAccess,\n unlock: defaultAccess,\n update: defaultAccess,\n ...(collection.access || {}),\n }\n\n collection.admin = {\n components: {},\n custom: {},\n enableRichTextLink: true,\n enableRichTextRelationship: true,\n useAsTitle: 'id',\n ...(collection.admin || {}),\n pagination: {\n defaultLimit: 10,\n limits: [5, 10, 25, 50, 100],\n ...(collection.admin?.pagination || {}),\n },\n }\n\n collection.auth = collection.auth ?? false\n collection.custom = collection.custom ?? {}\n collection.endpoints = collection.endpoints ?? []\n collection.fields = collection.fields ?? []\n collection.hierarchy = collection.hierarchy ?? false\n\n collection.hooks = {\n afterChange: [],\n afterDelete: [],\n afterForgotPassword: [],\n afterLogin: [],\n afterLogout: [],\n afterMe: [],\n afterOperation: [],\n afterRead: [],\n afterRefresh: [],\n beforeChange: [],\n beforeDelete: [],\n beforeLogin: [],\n beforeOperation: [],\n beforeRead: [],\n beforeValidate: [],\n me: [],\n refresh: [],\n ...(collection.hooks || {}),\n }\n\n collection.timestamps = collection.timestamps ?? true\n collection.upload = collection.upload ?? false\n collection.versions = collection.versions ?? true\n\n collection.indexes = collection.indexes ?? []\n\n return collection\n}\n\nexport const addDefaultsToAuthConfig = (auth: IncomingAuthType): IncomingAuthType => {\n auth.cookies = {\n sameSite: 'Lax',\n secure: false,\n ...(auth.cookies || {}),\n }\n\n auth.depth = auth.depth ?? 0\n auth.forgotPassword = auth.forgotPassword ?? {}\n auth.lockTime = auth.lockTime ?? 600000 // 10 minutes\n auth.loginWithUsername = auth.loginWithUsername ?? false\n auth.maxLoginAttempts = auth.maxLoginAttempts ?? 5\n auth.tokenExpiration = auth.tokenExpiration ?? 7200\n auth.useSessions = auth.useSessions ?? true\n auth.verify = auth.verify ?? false\n auth.strategies = auth.strategies ?? []\n\n if (!auth.disableLocalStrategy && auth.verify === true) {\n auth.verify = {}\n }\n\n return auth\n}\n\n/**\n * @deprecated - remove in 4.0. This is error-prone, as mutating this object will affect any objects that use the defaults as a base.\n */\nexport const loginWithUsernameDefaults: LoginWithUsernameOptions = {\n allowEmailLogin: false,\n requireEmail: false,\n requireUsername: true,\n}\n\nexport const addDefaultsToLoginWithUsernameConfig = (\n loginWithUsername: LoginWithUsernameOptions,\n): LoginWithUsernameOptions =>\n ({\n allowEmailLogin: false,\n requireEmail: false,\n requireUsername: true,\n ...(loginWithUsername || {}),\n }) as LoginWithUsernameOptions\n"],"names":["defaultAccess","defaults","access","create","delete","read","unlock","update","admin","components","custom","enableRichTextLink","enableRichTextRelationship","pagination","defaultLimit","limits","useAsTitle","auth","endpoints","fields","hooks","afterChange","afterDelete","afterForgotPassword","afterLogin","afterLogout","afterMe","afterOperation","afterRead","afterRefresh","beforeChange","beforeDelete","beforeLogin","beforeOperation","beforeRead","beforeValidate","me","refresh","indexes","timestamps","upload","versions","addDefaultsToCollectionConfig","collection","hierarchy","addDefaultsToAuthConfig","cookies","sameSite","secure","depth","forgotPassword","lockTime","loginWithUsername","maxLoginAttempts","tokenExpiration","useSessions","verify","strategies","disableLocalStrategy","loginWithUsernameDefaults","allowEmailLogin","requireEmail","requireUsername","addDefaultsToLoginWithUsernameConfig"],"mappings":"AAGA,SAASA,aAAa,QAAQ,8BAA6B;AAE3D;;CAEC,GACD,OAAO,MAAMC,WAAsC;IACjDC,QAAQ;QACNC,QAAQH;QACRI,QAAQJ;QACRK,MAAML;QACNM,QAAQN;QACRO,QAAQP;IACV;IACAQ,OAAO;QACLC,YAAY,CAAC;QACbC,QAAQ,CAAC;QACTC,oBAAoB;QACpBC,4BAA4B;QAC5BC,YAAY;YACVC,cAAc;YACdC,QAAQ;gBA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