payload 3.15.1 → 3.15.2-canary.595a742
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/auth/endpoints/access.d.ts +3 -0
- package/dist/auth/endpoints/access.d.ts.map +1 -0
- package/dist/auth/endpoints/access.js +27 -0
- package/dist/auth/endpoints/access.js.map +1 -0
- package/dist/auth/endpoints/forgotPassword.d.ts +3 -0
- package/dist/auth/endpoints/forgotPassword.d.ts.map +1 -0
- package/dist/auth/endpoints/forgotPassword.js +32 -0
- package/dist/auth/endpoints/forgotPassword.js.map +1 -0
- package/dist/auth/endpoints/index.d.ts +4 -0
- package/dist/auth/endpoints/index.d.ts.map +1 -0
- package/dist/auth/endpoints/index.js +73 -0
- package/dist/auth/endpoints/index.js.map +1 -0
- package/dist/auth/endpoints/init.d.ts +3 -0
- package/dist/auth/endpoints/init.d.ts.map +1 -0
- package/dist/auth/endpoints/init.js +19 -0
- package/dist/auth/endpoints/init.js.map +1 -0
- package/dist/auth/endpoints/login.d.ts +3 -0
- package/dist/auth/endpoints/login.d.ts.map +1 -0
- package/dist/auth/endpoints/login.js +47 -0
- package/dist/auth/endpoints/login.js.map +1 -0
- package/dist/auth/endpoints/logout.d.ts +3 -0
- package/dist/auth/endpoints/logout.d.ts.map +1 -0
- package/dist/auth/endpoints/logout.js +39 -0
- package/dist/auth/endpoints/logout.js.map +1 -0
- package/dist/auth/endpoints/me.d.ts +3 -0
- package/dist/auth/endpoints/me.d.ts.map +1 -0
- package/dist/auth/endpoints/me.js +29 -0
- package/dist/auth/endpoints/me.js.map +1 -0
- package/dist/auth/endpoints/refresh.d.ts +3 -0
- package/dist/auth/endpoints/refresh.d.ts.map +1 -0
- package/dist/auth/endpoints/refresh.js +37 -0
- package/dist/auth/endpoints/refresh.js.map +1 -0
- package/dist/auth/endpoints/registerFirstUser.d.ts +3 -0
- package/dist/auth/endpoints/registerFirstUser.d.ts.map +1 -0
- package/dist/auth/endpoints/registerFirstUser.js +46 -0
- package/dist/auth/endpoints/registerFirstUser.js.map +1 -0
- package/dist/auth/endpoints/resetPassword.d.ts +3 -0
- package/dist/auth/endpoints/resetPassword.d.ts.map +1 -0
- package/dist/auth/endpoints/resetPassword.js +41 -0
- package/dist/auth/endpoints/resetPassword.js.map +1 -0
- package/dist/auth/endpoints/unlock.d.ts +3 -0
- package/dist/auth/endpoints/unlock.d.ts.map +1 -0
- package/dist/auth/endpoints/unlock.js +30 -0
- package/dist/auth/endpoints/unlock.js.map +1 -0
- package/dist/auth/endpoints/verifyEmail.d.ts +3 -0
- package/dist/auth/endpoints/verifyEmail.d.ts.map +1 -0
- package/dist/auth/endpoints/verifyEmail.js +26 -0
- package/dist/auth/endpoints/verifyEmail.js.map +1 -0
- package/dist/auth/executeAuthStrategies.d.ts.map +1 -1
- package/dist/auth/executeAuthStrategies.js +2 -0
- package/dist/auth/executeAuthStrategies.js.map +1 -1
- package/dist/auth/extractJWT.d.ts +1 -1
- package/dist/auth/extractJWT.d.ts.map +1 -1
- package/dist/auth/extractJWT.js.map +1 -1
- package/dist/auth/strategies/jwt.d.ts +3 -0
- package/dist/auth/strategies/jwt.d.ts.map +1 -1
- package/dist/auth/strategies/jwt.js +12 -7
- package/dist/auth/strategies/jwt.js.map +1 -1
- package/dist/auth/types.d.ts +4 -0
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/collections/config/sanitize.d.ts.map +1 -1
- package/dist/collections/config/sanitize.js +9 -0
- package/dist/collections/config/sanitize.js.map +1 -1
- package/dist/collections/endpoints/count.d.ts +3 -0
- package/dist/collections/endpoints/count.d.ts.map +1 -0
- package/dist/collections/endpoints/count.js +17 -0
- package/dist/collections/endpoints/count.js.map +1 -0
- package/dist/collections/endpoints/create.d.ts +3 -0
- package/dist/collections/endpoints/create.d.ts.map +1 -0
- package/dist/collections/endpoints/create.js +39 -0
- package/dist/collections/endpoints/create.js.map +1 -0
- package/dist/collections/endpoints/delete.d.ts +3 -0
- package/dist/collections/endpoints/delete.d.ts.map +1 -0
- package/dist/collections/endpoints/delete.js +53 -0
- package/dist/collections/endpoints/delete.js.map +1 -0
- package/dist/collections/endpoints/deleteByID.d.ts +3 -0
- package/dist/collections/endpoints/deleteByID.d.ts.map +1 -0
- package/dist/collections/endpoints/deleteByID.js +43 -0
- package/dist/collections/endpoints/deleteByID.js.map +1 -0
- package/dist/collections/endpoints/docAccess.d.ts +3 -0
- package/dist/collections/endpoints/docAccess.d.ts.map +1 -0
- package/dist/collections/endpoints/docAccess.js +21 -0
- package/dist/collections/endpoints/docAccess.js.map +1 -0
- package/dist/collections/endpoints/duplicate.d.ts +3 -0
- package/dist/collections/endpoints/duplicate.d.ts.map +1 -0
- package/dist/collections/endpoints/duplicate.js +40 -0
- package/dist/collections/endpoints/duplicate.js.map +1 -0
- package/dist/collections/endpoints/find.d.ts +3 -0
- package/dist/collections/endpoints/find.d.ts.map +1 -0
- package/dist/collections/endpoints/find.js +35 -0
- package/dist/collections/endpoints/find.js.map +1 -0
- package/dist/collections/endpoints/findByID.d.ts +3 -0
- package/dist/collections/endpoints/findByID.d.ts.map +1 -0
- package/dist/collections/endpoints/findByID.js +32 -0
- package/dist/collections/endpoints/findByID.js.map +1 -0
- package/dist/collections/endpoints/findVersionByID.d.ts +3 -0
- package/dist/collections/endpoints/findVersionByID.d.ts.map +1 -0
- package/dist/collections/endpoints/findVersionByID.js +29 -0
- package/dist/collections/endpoints/findVersionByID.js.map +1 -0
- package/dist/collections/endpoints/findVersions.d.ts +3 -0
- package/dist/collections/endpoints/findVersions.d.ts.map +1 -0
- package/dist/collections/endpoints/findVersions.js +32 -0
- package/dist/collections/endpoints/findVersions.js.map +1 -0
- package/dist/collections/endpoints/getFile.d.ts +3 -0
- package/dist/collections/endpoints/getFile.d.ts.map +1 -0
- package/dist/collections/endpoints/getFile.js +60 -0
- package/dist/collections/endpoints/getFile.js.map +1 -0
- package/dist/collections/endpoints/index.d.ts +3 -0
- package/dist/collections/endpoints/index.d.ts.map +1 -0
- package/dist/collections/endpoints/index.js +93 -0
- package/dist/collections/endpoints/index.js.map +1 -0
- package/dist/collections/endpoints/preview.d.ts +3 -0
- package/dist/collections/endpoints/preview.d.ts.map +1 -0
- package/dist/collections/endpoints/preview.js +37 -0
- package/dist/collections/endpoints/preview.js.map +1 -0
- package/dist/collections/endpoints/restoreVersion.d.ts +3 -0
- package/dist/collections/endpoints/restoreVersion.d.ts.map +1 -0
- package/dist/collections/endpoints/restoreVersion.js +32 -0
- package/dist/collections/endpoints/restoreVersion.js.map +1 -0
- package/dist/collections/endpoints/update.d.ts +3 -0
- package/dist/collections/endpoints/update.d.ts.map +1 -0
- package/dist/collections/endpoints/update.js +56 -0
- package/dist/collections/endpoints/update.js.map +1 -0
- package/dist/collections/endpoints/updateByID.d.ts +3 -0
- package/dist/collections/endpoints/updateByID.d.ts.map +1 -0
- package/dist/collections/endpoints/updateByID.js +48 -0
- package/dist/collections/endpoints/updateByID.js.map +1 -0
- package/dist/collections/operations/docAccess.d.ts +1 -1
- package/dist/collections/operations/docAccess.d.ts.map +1 -1
- package/dist/collections/operations/docAccess.js.map +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sanitize.js +7 -0
- package/dist/config/sanitize.js.map +1 -1
- package/dist/exports/shared.d.ts +1 -0
- package/dist/exports/shared.d.ts.map +1 -1
- package/dist/exports/shared.js +1 -0
- package/dist/exports/shared.js.map +1 -1
- package/dist/globals/config/sanitize.d.ts.map +1 -1
- package/dist/globals/config/sanitize.js +9 -0
- package/dist/globals/config/sanitize.js.map +1 -1
- package/dist/globals/endpoints/docAccess.d.ts +3 -0
- package/dist/globals/endpoints/docAccess.d.ts.map +1 -0
- package/dist/globals/endpoints/docAccess.js +20 -0
- package/dist/globals/endpoints/docAccess.js.map +1 -0
- package/dist/globals/endpoints/findOne.d.ts +3 -0
- package/dist/globals/endpoints/findOne.d.ts.map +1 -0
- package/dist/globals/endpoints/findOne.js +30 -0
- package/dist/globals/endpoints/findOne.js.map +1 -0
- package/dist/globals/endpoints/findVersionByID.d.ts +3 -0
- package/dist/globals/endpoints/findVersionByID.d.ts.map +1 -0
- package/dist/globals/endpoints/findVersionByID.js +29 -0
- package/dist/globals/endpoints/findVersionByID.js.map +1 -0
- package/dist/globals/endpoints/findVersions.d.ts +3 -0
- package/dist/globals/endpoints/findVersions.d.ts.map +1 -0
- package/dist/globals/endpoints/findVersions.js +32 -0
- package/dist/globals/endpoints/findVersions.js.map +1 -0
- package/dist/globals/endpoints/index.d.ts +3 -0
- package/dist/globals/endpoints/index.d.ts.map +1 -0
- package/dist/globals/endpoints/index.js +47 -0
- package/dist/globals/endpoints/index.js.map +1 -0
- package/dist/globals/endpoints/preview.d.ts +3 -0
- package/dist/globals/endpoints/preview.d.ts.map +1 -0
- package/dist/globals/endpoints/preview.js +37 -0
- package/dist/globals/endpoints/preview.js.map +1 -0
- package/dist/globals/endpoints/restoreVersion.d.ts +3 -0
- package/dist/globals/endpoints/restoreVersion.d.ts.map +1 -0
- package/dist/globals/endpoints/restoreVersion.js +31 -0
- package/dist/globals/endpoints/restoreVersion.js.map +1 -0
- package/dist/globals/endpoints/update.d.ts +3 -0
- package/dist/globals/endpoints/update.d.ts.map +1 -0
- package/dist/globals/endpoints/update.js +46 -0
- package/dist/globals/endpoints/update.js.map +1 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -1
- package/dist/preferences/preferencesCollection.d.ts.map +1 -1
- package/dist/preferences/preferencesCollection.js +14 -2
- package/dist/preferences/preferencesCollection.js.map +1 -1
- package/dist/preferences/requestHandlers/update.js +1 -1
- package/dist/preferences/requestHandlers/update.js.map +1 -1
- package/dist/preferences/types.d.ts +8 -0
- package/dist/preferences/types.d.ts.map +1 -1
- package/dist/preferences/types.js.map +1 -1
- package/dist/queues/config/types/index.d.ts +36 -3
- package/dist/queues/config/types/index.d.ts.map +1 -1
- package/dist/queues/config/types/index.js.map +1 -1
- package/dist/uploads/checkFileAccess.d.ts +8 -0
- package/dist/uploads/checkFileAccess.d.ts.map +1 -0
- package/dist/uploads/checkFileAccess.js +48 -0
- package/dist/uploads/checkFileAccess.js.map +1 -0
- package/dist/uploads/fetchAPI-multipart/fileFactory.d.ts +16 -0
- package/dist/uploads/fetchAPI-multipart/fileFactory.d.ts.map +1 -0
- package/dist/uploads/fetchAPI-multipart/fileFactory.js +43 -0
- package/dist/uploads/fetchAPI-multipart/fileFactory.js.map +1 -0
- package/dist/uploads/fetchAPI-multipart/handlers.d.ts +14 -0
- package/dist/uploads/fetchAPI-multipart/handlers.d.ts.map +1 -0
- package/dist/uploads/fetchAPI-multipart/handlers.js +88 -0
- package/dist/uploads/fetchAPI-multipart/handlers.js.map +1 -0
- package/dist/uploads/fetchAPI-multipart/index.d.ts +32 -0
- package/dist/uploads/fetchAPI-multipart/index.d.ts.map +1 -0
- package/dist/uploads/fetchAPI-multipart/index.js +41 -0
- package/dist/uploads/fetchAPI-multipart/index.js.map +1 -0
- package/dist/uploads/fetchAPI-multipart/isEligibleRequest.d.ts +2 -0
- package/dist/uploads/fetchAPI-multipart/isEligibleRequest.d.ts.map +1 -0
- package/dist/uploads/fetchAPI-multipart/isEligibleRequest.js +27 -0
- package/dist/uploads/fetchAPI-multipart/isEligibleRequest.js.map +1 -0
- package/dist/uploads/fetchAPI-multipart/processMultipart.d.ts +9 -0
- package/dist/uploads/fetchAPI-multipart/processMultipart.d.ts.map +1 -0
- package/dist/uploads/fetchAPI-multipart/processMultipart.js +161 -0
- package/dist/uploads/fetchAPI-multipart/processMultipart.js.map +1 -0
- package/dist/uploads/fetchAPI-multipart/processNested.d.ts +2 -0
- package/dist/uploads/fetchAPI-multipart/processNested.d.ts.map +1 -0
- package/dist/uploads/fetchAPI-multipart/processNested.js +29 -0
- package/dist/uploads/fetchAPI-multipart/processNested.js.map +1 -0
- package/dist/uploads/fetchAPI-multipart/uploadTimer.d.ts +7 -0
- package/dist/uploads/fetchAPI-multipart/uploadTimer.d.ts.map +1 -0
- package/dist/uploads/fetchAPI-multipart/uploadTimer.js +21 -0
- package/dist/uploads/fetchAPI-multipart/uploadTimer.js.map +1 -0
- package/dist/uploads/fetchAPI-multipart/utilities.d.ts +65 -0
- package/dist/uploads/fetchAPI-multipart/utilities.d.ts.map +1 -0
- package/dist/uploads/fetchAPI-multipart/utilities.js +227 -0
- package/dist/uploads/fetchAPI-multipart/utilities.js.map +1 -0
- package/dist/uploads/fetchAPI-stream-file/index.d.ts +5 -0
- package/dist/uploads/fetchAPI-stream-file/index.d.ts.map +1 -0
- package/dist/uploads/fetchAPI-stream-file/index.js +25 -0
- package/dist/uploads/fetchAPI-stream-file/index.js.map +1 -0
- package/dist/uploads/getFileTypeFallback.d.ts +7 -0
- package/dist/uploads/getFileTypeFallback.d.ts.map +1 -0
- package/dist/uploads/getFileTypeFallback.js +21 -0
- package/dist/uploads/getFileTypeFallback.js.map +1 -0
- package/dist/utilities/addDataAndFileToRequest.d.ts +8 -0
- package/dist/utilities/addDataAndFileToRequest.d.ts.map +1 -0
- package/dist/utilities/addDataAndFileToRequest.js +42 -0
- package/dist/utilities/addDataAndFileToRequest.js.map +1 -0
- package/dist/utilities/addLocalesToRequest.d.ts +18 -0
- package/dist/utilities/addLocalesToRequest.d.ts.map +1 -0
- package/dist/utilities/addLocalesToRequest.js +53 -0
- package/dist/utilities/addLocalesToRequest.js.map +1 -0
- package/dist/utilities/createPayloadRequest.d.ts +12 -0
- package/dist/utilities/createPayloadRequest.d.ts.map +1 -0
- package/dist/utilities/createPayloadRequest.js +94 -0
- package/dist/utilities/createPayloadRequest.js.map +1 -0
- package/dist/utilities/getRequestEntity.d.ts +12 -0
- package/dist/utilities/getRequestEntity.d.ts.map +1 -0
- package/dist/utilities/getRequestEntity.js +54 -0
- package/dist/utilities/getRequestEntity.js.map +1 -0
- package/dist/utilities/getRequestLanguage.d.ts +12 -0
- package/dist/utilities/getRequestLanguage.d.ts.map +1 -0
- package/dist/utilities/getRequestLanguage.js +16 -0
- package/dist/utilities/getRequestLanguage.js.map +1 -0
- package/dist/utilities/handleEndpoints.d.ts +38 -0
- package/dist/utilities/handleEndpoints.d.ts.map +1 -0
- package/dist/utilities/handleEndpoints.js +179 -0
- package/dist/utilities/handleEndpoints.js.map +1 -0
- package/dist/utilities/headersWithCors.d.ts +8 -0
- package/dist/utilities/headersWithCors.d.ts.map +1 -0
- package/dist/utilities/headersWithCors.js +33 -0
- package/dist/utilities/headersWithCors.js.map +1 -0
- package/dist/utilities/isNextBuild.d.ts +5 -0
- package/dist/utilities/isNextBuild.d.ts.map +1 -0
- package/dist/utilities/isNextBuild.js +7 -0
- package/dist/utilities/isNextBuild.js.map +1 -0
- package/dist/utilities/mergeHeaders.d.ts +2 -0
- package/dist/utilities/mergeHeaders.d.ts.map +1 -0
- package/dist/utilities/mergeHeaders.js +11 -0
- package/dist/utilities/mergeHeaders.js.map +1 -0
- package/dist/utilities/routeError.d.ts +11 -0
- package/dist/utilities/routeError.d.ts.map +1 -0
- package/dist/utilities/routeError.js +80 -0
- package/dist/utilities/routeError.js.map +1 -0
- package/dist/utilities/wrapInternalEndpoints.d.ts +3 -0
- package/dist/utilities/wrapInternalEndpoints.d.ts.map +1 -0
- package/dist/utilities/wrapInternalEndpoints.js +20 -0
- package/dist/utilities/wrapInternalEndpoints.js.map +1 -0
- package/package.json +5 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/access.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAK3D,eAAO,MAAM,aAAa,EAAE,cA0B3B,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import httpStatus from 'http-status';
|
|
2
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
3
|
+
import { accessOperation } from '../operations/access.js';
|
|
4
|
+
export const accessHandler = async (req)=>{
|
|
5
|
+
const headers = headersWithCors({
|
|
6
|
+
headers: new Headers(),
|
|
7
|
+
req
|
|
8
|
+
});
|
|
9
|
+
try {
|
|
10
|
+
const results = await accessOperation({
|
|
11
|
+
req
|
|
12
|
+
});
|
|
13
|
+
return Response.json(results, {
|
|
14
|
+
headers,
|
|
15
|
+
status: httpStatus.OK
|
|
16
|
+
});
|
|
17
|
+
} catch (e) {
|
|
18
|
+
return Response.json({
|
|
19
|
+
error: e
|
|
20
|
+
}, {
|
|
21
|
+
headers,
|
|
22
|
+
status: httpStatus.INTERNAL_SERVER_ERROR
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=access.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/endpoints/access.ts"],"sourcesContent":["import httpStatus from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { accessOperation } from '../operations/access.js'\n\nexport const accessHandler: PayloadHandler = async (req) => {\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n try {\n const results = await accessOperation({\n req,\n })\n\n return Response.json(results, {\n headers,\n status: httpStatus.OK,\n })\n } catch (e: unknown) {\n return Response.json(\n {\n error: e,\n },\n {\n headers,\n status: httpStatus.INTERNAL_SERVER_ERROR,\n },\n )\n }\n}\n"],"names":["httpStatus","headersWithCors","accessOperation","accessHandler","req","headers","Headers","results","Response","json","status","OK","e","error","INTERNAL_SERVER_ERROR"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AAIpC,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,0BAAyB;AAEzD,OAAO,MAAMC,gBAAgC,OAAOC;IAClD,MAAMC,UAAUJ,gBAAgB;QAC9BI,SAAS,IAAIC;QACbF;IACF;IAEA,IAAI;QACF,MAAMG,UAAU,MAAML,gBAAgB;YACpCE;QACF;QAEA,OAAOI,SAASC,IAAI,CAACF,SAAS;YAC5BF;YACAK,QAAQV,WAAWW,EAAE;QACvB;IACF,EAAE,OAAOC,GAAY;QACnB,OAAOJ,SAASC,IAAI,CAClB;YACEI,OAAOD;QACT,GACA;YACEP;YACAK,QAAQV,WAAWc,qBAAqB;QAC1C;IAEJ;AACF,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forgotPassword.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/forgotPassword.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAM3D,eAAO,MAAM,qBAAqB,EAAE,cAkCnC,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import httpStatus from 'http-status';
|
|
2
|
+
import { getRequestCollection } from '../../utilities/getRequestEntity.js';
|
|
3
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
4
|
+
import { forgotPasswordOperation } from '../operations/forgotPassword.js';
|
|
5
|
+
export const forgotPasswordHandler = async (req)=>{
|
|
6
|
+
const { t } = req;
|
|
7
|
+
const collection = getRequestCollection(req);
|
|
8
|
+
const authData = collection.config.auth?.loginWithUsername ? {
|
|
9
|
+
email: typeof req.data?.email === 'string' ? req.data.email : '',
|
|
10
|
+
username: typeof req.data?.username === 'string' ? req.data.username : ''
|
|
11
|
+
} : {
|
|
12
|
+
email: typeof req.data?.email === 'string' ? req.data.email : ''
|
|
13
|
+
};
|
|
14
|
+
await forgotPasswordOperation({
|
|
15
|
+
collection,
|
|
16
|
+
data: authData,
|
|
17
|
+
disableEmail: Boolean(req.data?.disableEmail),
|
|
18
|
+
expiration: typeof req.data.expiration === 'number' ? req.data.expiration : undefined,
|
|
19
|
+
req
|
|
20
|
+
});
|
|
21
|
+
return Response.json({
|
|
22
|
+
message: t('general:success')
|
|
23
|
+
}, {
|
|
24
|
+
headers: headersWithCors({
|
|
25
|
+
headers: new Headers(),
|
|
26
|
+
req
|
|
27
|
+
}),
|
|
28
|
+
status: httpStatus.OK
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=forgotPassword.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/endpoints/forgotPassword.ts"],"sourcesContent":["import 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 { forgotPasswordOperation } from '../operations/forgotPassword.js'\n\nexport const forgotPasswordHandler: PayloadHandler = async (req) => {\n const { t } = req\n\n const collection = getRequestCollection(req)\n\n const authData = collection.config.auth?.loginWithUsername\n ? {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n username: typeof req.data?.username === 'string' ? req.data.username : '',\n }\n : {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n }\n\n await forgotPasswordOperation({\n collection,\n data: authData,\n disableEmail: Boolean(req.data?.disableEmail),\n expiration: typeof req.data.expiration === 'number' ? req.data.expiration : undefined,\n req,\n })\n\n return Response.json(\n {\n message: t('general:success'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","getRequestCollection","headersWithCors","forgotPasswordOperation","forgotPasswordHandler","req","t","collection","authData","config","auth","loginWithUsername","email","data","username","disableEmail","Boolean","expiration","undefined","Response","json","message","headers","Headers","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AAIpC,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,uBAAuB,QAAQ,kCAAiC;AAEzE,OAAO,MAAMC,wBAAwC,OAAOC;IAC1D,MAAM,EAAEC,CAAC,EAAE,GAAGD;IAEd,MAAME,aAAaN,qBAAqBI;IAExC,MAAMG,WAAWD,WAAWE,MAAM,CAACC,IAAI,EAAEC,oBACrC;QACEC,OAAO,OAAOP,IAAIQ,IAAI,EAAED,UAAU,WAAWP,IAAIQ,IAAI,CAACD,KAAK,GAAG;QAC9DE,UAAU,OAAOT,IAAIQ,IAAI,EAAEC,aAAa,WAAWT,IAAIQ,IAAI,CAACC,QAAQ,GAAG;IACzE,IACA;QACEF,OAAO,OAAOP,IAAIQ,IAAI,EAAED,UAAU,WAAWP,IAAIQ,IAAI,CAACD,KAAK,GAAG;IAChE;IAEJ,MAAMT,wBAAwB;QAC5BI;QACAM,MAAML;QACNO,cAAcC,QAAQX,IAAIQ,IAAI,EAAEE;QAChCE,YAAY,OAAOZ,IAAIQ,IAAI,CAACI,UAAU,KAAK,WAAWZ,IAAIQ,IAAI,CAACI,UAAU,GAAGC;QAC5Eb;IACF;IAEA,OAAOc,SAASC,IAAI,CAClB;QACEC,SAASf,EAAE;IACb,GACA;QACEgB,SAASpB,gBAAgB;YACvBoB,SAAS,IAAIC;YACblB;QACF;QACAmB,QAAQxB,WAAWyB,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAerD,eAAO,MAAM,iBAAiB,EAAE,QAAQ,EAMtC,CAAA;AAEF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,EAmD5C,CAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { wrapInternalEndpoints } from '../../utilities/wrapInternalEndpoints.js';
|
|
2
|
+
import { accessHandler } from './access.js';
|
|
3
|
+
import { forgotPasswordHandler } from './forgotPassword.js';
|
|
4
|
+
import { initHandler } from './init.js';
|
|
5
|
+
import { loginHandler } from './login.js';
|
|
6
|
+
import { logoutHandler } from './logout.js';
|
|
7
|
+
import { meHandler } from './me.js';
|
|
8
|
+
import { refreshHandler } from './refresh.js';
|
|
9
|
+
import { registerFirstUserHandler } from './registerFirstUser.js';
|
|
10
|
+
import { resetPasswordHandler } from './resetPassword.js';
|
|
11
|
+
import { unlockHandler } from './unlock.js';
|
|
12
|
+
import { verifyEmailHandler } from './verifyEmail.js';
|
|
13
|
+
export const authRootEndpoints = wrapInternalEndpoints([
|
|
14
|
+
{
|
|
15
|
+
handler: accessHandler,
|
|
16
|
+
method: 'get',
|
|
17
|
+
path: '/access'
|
|
18
|
+
}
|
|
19
|
+
]);
|
|
20
|
+
export const authCollectionEndpoints = wrapInternalEndpoints([
|
|
21
|
+
{
|
|
22
|
+
handler: forgotPasswordHandler,
|
|
23
|
+
method: 'post',
|
|
24
|
+
path: '/forgot-password'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
handler: initHandler,
|
|
28
|
+
method: 'get',
|
|
29
|
+
path: '/init'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
handler: loginHandler,
|
|
33
|
+
method: 'post',
|
|
34
|
+
path: '/login'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
handler: logoutHandler,
|
|
38
|
+
method: 'post',
|
|
39
|
+
path: '/logout'
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
handler: meHandler,
|
|
43
|
+
method: 'get',
|
|
44
|
+
path: '/me'
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
handler: refreshHandler,
|
|
48
|
+
method: 'post',
|
|
49
|
+
path: '/refresh-token'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
handler: registerFirstUserHandler,
|
|
53
|
+
method: 'post',
|
|
54
|
+
path: '/first-register'
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
handler: resetPasswordHandler,
|
|
58
|
+
method: 'post',
|
|
59
|
+
path: '/reset-password'
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
handler: unlockHandler,
|
|
63
|
+
method: 'post',
|
|
64
|
+
path: '/unlock'
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
handler: verifyEmailHandler,
|
|
68
|
+
method: 'post',
|
|
69
|
+
path: '/verify/:id'
|
|
70
|
+
}
|
|
71
|
+
]);
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/endpoints/index.ts"],"sourcesContent":["import type { Endpoint } from '../../config/types.js'\n\nimport { wrapInternalEndpoints } from '../../utilities/wrapInternalEndpoints.js'\nimport { accessHandler } from './access.js'\nimport { forgotPasswordHandler } from './forgotPassword.js'\nimport { initHandler } from './init.js'\nimport { loginHandler } from './login.js'\nimport { logoutHandler } from './logout.js'\nimport { meHandler } from './me.js'\nimport { refreshHandler } from './refresh.js'\nimport { registerFirstUserHandler } from './registerFirstUser.js'\nimport { resetPasswordHandler } from './resetPassword.js'\nimport { unlockHandler } from './unlock.js'\nimport { verifyEmailHandler } from './verifyEmail.js'\n\nexport const authRootEndpoints: Endpoint[] = wrapInternalEndpoints([\n {\n handler: accessHandler,\n method: 'get',\n path: '/access',\n },\n])\n\nexport const authCollectionEndpoints: Endpoint[] = wrapInternalEndpoints([\n {\n handler: forgotPasswordHandler,\n method: 'post',\n path: '/forgot-password',\n },\n {\n handler: initHandler,\n method: 'get',\n path: '/init',\n },\n {\n handler: loginHandler,\n method: 'post',\n path: '/login',\n },\n {\n handler: logoutHandler,\n method: 'post',\n path: '/logout',\n },\n {\n handler: meHandler,\n method: 'get',\n path: '/me',\n },\n {\n handler: refreshHandler,\n method: 'post',\n path: '/refresh-token',\n },\n {\n handler: registerFirstUserHandler,\n method: 'post',\n path: '/first-register',\n },\n {\n handler: resetPasswordHandler,\n method: 'post',\n path: '/reset-password',\n },\n {\n handler: unlockHandler,\n method: 'post',\n path: '/unlock',\n },\n {\n handler: verifyEmailHandler,\n method: 'post',\n path: '/verify/:id',\n },\n])\n"],"names":["wrapInternalEndpoints","accessHandler","forgotPasswordHandler","initHandler","loginHandler","logoutHandler","meHandler","refreshHandler","registerFirstUserHandler","resetPasswordHandler","unlockHandler","verifyEmailHandler","authRootEndpoints","handler","method","path","authCollectionEndpoints"],"mappings":"AAEA,SAASA,qBAAqB,QAAQ,2CAA0C;AAChF,SAASC,aAAa,QAAQ,cAAa;AAC3C,SAASC,qBAAqB,QAAQ,sBAAqB;AAC3D,SAASC,WAAW,QAAQ,YAAW;AACvC,SAASC,YAAY,QAAQ,aAAY;AACzC,SAASC,aAAa,QAAQ,cAAa;AAC3C,SAASC,SAAS,QAAQ,UAAS;AACnC,SAASC,cAAc,QAAQ,eAAc;AAC7C,SAASC,wBAAwB,QAAQ,yBAAwB;AACjE,SAASC,oBAAoB,QAAQ,qBAAoB;AACzD,SAASC,aAAa,QAAQ,cAAa;AAC3C,SAASC,kBAAkB,QAAQ,mBAAkB;AAErD,OAAO,MAAMC,oBAAgCZ,sBAAsB;IACjE;QACEa,SAASZ;QACTa,QAAQ;QACRC,MAAM;IACR;CACD,EAAC;AAEF,OAAO,MAAMC,0BAAsChB,sBAAsB;IACvE;QACEa,SAASX;QACTY,QAAQ;QACRC,MAAM;IACR;IACA;QACEF,SAASV;QACTW,QAAQ;QACRC,MAAM;IACR;IACA;QACEF,SAAST;QACTU,QAAQ;QACRC,MAAM;IACR;IACA;QACEF,SAASR;QACTS,QAAQ;QACRC,MAAM;IACR;IACA;QACEF,SAASP;QACTQ,QAAQ;QACRC,MAAM;IACR;IACA;QACEF,SAASN;QACTO,QAAQ;QACRC,MAAM;IACR;IACA;QACEF,SAASL;QACTM,QAAQ;QACRC,MAAM;IACR;IACA;QACEF,SAASJ;QACTK,QAAQ;QACRC,MAAM;IACR;IACA;QACEF,SAASH;QACTI,QAAQ;QACRC,MAAM;IACR;IACA;QACEF,SAASF;QACTG,QAAQ;QACRC,MAAM;IACR;CACD,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAM3D,eAAO,MAAM,WAAW,EAAE,cAezB,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getRequestCollection } from '../../utilities/getRequestEntity.js';
|
|
2
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
3
|
+
import { initOperation } from '../operations/init.js';
|
|
4
|
+
export const initHandler = async (req)=>{
|
|
5
|
+
const initialized = await initOperation({
|
|
6
|
+
collection: getRequestCollection(req).config.slug,
|
|
7
|
+
req
|
|
8
|
+
});
|
|
9
|
+
return Response.json({
|
|
10
|
+
initialized
|
|
11
|
+
}, {
|
|
12
|
+
headers: headersWithCors({
|
|
13
|
+
headers: new Headers(),
|
|
14
|
+
req
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/endpoints/init.ts"],"sourcesContent":["import type { PayloadHandler } from '../../config/types.js'\n\nimport { getRequestCollection } from '../../utilities/getRequestEntity.js'\nimport { headersWithCors } from '../../utilities/headersWithCors.js'\nimport { initOperation } from '../operations/init.js'\n\nexport const initHandler: PayloadHandler = async (req) => {\n const initialized = await initOperation({\n collection: getRequestCollection(req).config.slug,\n req,\n })\n\n return Response.json(\n { initialized },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n },\n )\n}\n"],"names":["getRequestCollection","headersWithCors","initOperation","initHandler","req","initialized","collection","config","slug","Response","json","headers","Headers"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,aAAa,QAAQ,wBAAuB;AAErD,OAAO,MAAMC,cAA8B,OAAOC;IAChD,MAAMC,cAAc,MAAMH,cAAc;QACtCI,YAAYN,qBAAqBI,KAAKG,MAAM,CAACC,IAAI;QACjDJ;IACF;IAEA,OAAOK,SAASC,IAAI,CAClB;QAAEL;IAAY,GACd;QACEM,SAASV,gBAAgB;YACvBU,SAAS,IAAIC;YACbR;QACF;IACF;AAEJ,EAAC"}
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import httpStatus from 'http-status';
|
|
2
|
+
import { getRequestCollection } from '../../utilities/getRequestEntity.js';
|
|
3
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
4
|
+
import { isNumber } from '../../utilities/isNumber.js';
|
|
5
|
+
import { generatePayloadCookie } from '../cookies.js';
|
|
6
|
+
import { loginOperation } from '../operations/login.js';
|
|
7
|
+
export const loginHandler = async (req)=>{
|
|
8
|
+
const collection = getRequestCollection(req);
|
|
9
|
+
const { searchParams, t } = req;
|
|
10
|
+
const depth = searchParams.get('depth');
|
|
11
|
+
const authData = collection.config.auth?.loginWithUsername !== false ? {
|
|
12
|
+
email: typeof req.data?.email === 'string' ? req.data.email : '',
|
|
13
|
+
password: typeof req.data?.password === 'string' ? req.data.password : '',
|
|
14
|
+
username: typeof req.data?.username === 'string' ? req.data.username : ''
|
|
15
|
+
} : {
|
|
16
|
+
email: typeof req.data?.email === 'string' ? req.data.email : '',
|
|
17
|
+
password: typeof req.data?.password === 'string' ? req.data.password : ''
|
|
18
|
+
};
|
|
19
|
+
const result = await loginOperation({
|
|
20
|
+
collection,
|
|
21
|
+
data: authData,
|
|
22
|
+
depth: isNumber(depth) ? Number(depth) : undefined,
|
|
23
|
+
req
|
|
24
|
+
});
|
|
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
|
+
return Response.json({
|
|
34
|
+
message: t('authentication:passed'),
|
|
35
|
+
...result
|
|
36
|
+
}, {
|
|
37
|
+
headers: headersWithCors({
|
|
38
|
+
headers: new Headers({
|
|
39
|
+
'Set-Cookie': cookie
|
|
40
|
+
}),
|
|
41
|
+
req
|
|
42
|
+
}),
|
|
43
|
+
status: httpStatus.OK
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/endpoints/login.ts"],"sourcesContent":["import 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":["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","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AAIpC,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;QACA4B,QAAQnC,WAAWoC,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/logout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAO3D,eAAO,MAAM,aAAa,EAAE,cA0C3B,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import httpStatus from 'http-status';
|
|
2
|
+
import { getRequestCollection } from '../../utilities/getRequestEntity.js';
|
|
3
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
4
|
+
import { generateExpiredPayloadCookie } from '../cookies.js';
|
|
5
|
+
import { logoutOperation } from '../operations/logout.js';
|
|
6
|
+
export const logoutHandler = async (req)=>{
|
|
7
|
+
const collection = getRequestCollection(req);
|
|
8
|
+
const { t } = req;
|
|
9
|
+
const result = await logoutOperation({
|
|
10
|
+
collection,
|
|
11
|
+
req
|
|
12
|
+
});
|
|
13
|
+
const headers = headersWithCors({
|
|
14
|
+
headers: new Headers(),
|
|
15
|
+
req
|
|
16
|
+
});
|
|
17
|
+
if (!result) {
|
|
18
|
+
return Response.json({
|
|
19
|
+
message: t('error:logoutFailed')
|
|
20
|
+
}, {
|
|
21
|
+
headers,
|
|
22
|
+
status: httpStatus.BAD_REQUEST
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
const expiredCookie = generateExpiredPayloadCookie({
|
|
26
|
+
collectionAuthConfig: collection.config.auth,
|
|
27
|
+
config: req.payload.config,
|
|
28
|
+
cookiePrefix: req.payload.config.cookiePrefix
|
|
29
|
+
});
|
|
30
|
+
headers.set('Set-Cookie', expiredCookie);
|
|
31
|
+
return Response.json({
|
|
32
|
+
message: t('authentication:logoutSuccessful')
|
|
33
|
+
}, {
|
|
34
|
+
headers,
|
|
35
|
+
status: httpStatus.OK
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=logout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/endpoints/logout.ts"],"sourcesContent":["import 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 { generateExpiredPayloadCookie } from '../cookies.js'\nimport { logoutOperation } from '../operations/logout.js'\n\nexport const logoutHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { t } = req\n const result = await logoutOperation({\n collection,\n req,\n })\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n if (!result) {\n return Response.json(\n {\n message: t('error:logoutFailed'),\n },\n {\n headers,\n status: httpStatus.BAD_REQUEST,\n },\n )\n }\n\n const expiredCookie = generateExpiredPayloadCookie({\n collectionAuthConfig: collection.config.auth,\n config: req.payload.config,\n cookiePrefix: req.payload.config.cookiePrefix,\n })\n\n headers.set('Set-Cookie', expiredCookie)\n\n return Response.json(\n {\n message: t('authentication:logoutSuccessful'),\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","getRequestCollection","headersWithCors","generateExpiredPayloadCookie","logoutOperation","logoutHandler","req","collection","t","result","headers","Headers","Response","json","message","status","BAD_REQUEST","expiredCookie","collectionAuthConfig","config","auth","payload","cookiePrefix","set","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AAIpC,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,4BAA4B,QAAQ,gBAAe;AAC5D,SAASC,eAAe,QAAQ,0BAAyB;AAEzD,OAAO,MAAMC,gBAAgC,OAAOC;IAClD,MAAMC,aAAaN,qBAAqBK;IACxC,MAAM,EAAEE,CAAC,EAAE,GAAGF;IACd,MAAMG,SAAS,MAAML,gBAAgB;QACnCG;QACAD;IACF;IAEA,MAAMI,UAAUR,gBAAgB;QAC9BQ,SAAS,IAAIC;QACbL;IACF;IAEA,IAAI,CAACG,QAAQ;QACX,OAAOG,SAASC,IAAI,CAClB;YACEC,SAASN,EAAE;QACb,GACA;YACEE;YACAK,QAAQf,WAAWgB,WAAW;QAChC;IAEJ;IAEA,MAAMC,gBAAgBd,6BAA6B;QACjDe,sBAAsBX,WAAWY,MAAM,CAACC,IAAI;QAC5CD,QAAQb,IAAIe,OAAO,CAACF,MAAM;QAC1BG,cAAchB,IAAIe,OAAO,CAACF,MAAM,CAACG,YAAY;IAC/C;IAEAZ,QAAQa,GAAG,CAAC,cAAcN;IAE1B,OAAOL,SAASC,IAAI,CAClB;QACEC,SAASN,EAAE;IACb,GACA;QACEE;QACAK,QAAQf,WAAWwB,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/me.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAO3D,eAAO,MAAM,SAAS,EAAE,cA2BvB,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import httpStatus from 'http-status';
|
|
2
|
+
import { getRequestCollection } from '../../utilities/getRequestEntity.js';
|
|
3
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
4
|
+
import { extractJWT } from '../extractJWT.js';
|
|
5
|
+
import { meOperation } from '../operations/me.js';
|
|
6
|
+
export const meHandler = async (req)=>{
|
|
7
|
+
const collection = getRequestCollection(req);
|
|
8
|
+
const currentToken = extractJWT(req);
|
|
9
|
+
const result = await meOperation({
|
|
10
|
+
collection,
|
|
11
|
+
currentToken,
|
|
12
|
+
req
|
|
13
|
+
});
|
|
14
|
+
if (collection.config.auth.removeTokenFromResponses) {
|
|
15
|
+
delete result.token;
|
|
16
|
+
}
|
|
17
|
+
return Response.json({
|
|
18
|
+
...result,
|
|
19
|
+
message: req.t('authentication:account')
|
|
20
|
+
}, {
|
|
21
|
+
headers: headersWithCors({
|
|
22
|
+
headers: new Headers(),
|
|
23
|
+
req
|
|
24
|
+
}),
|
|
25
|
+
status: httpStatus.OK
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=me.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/endpoints/me.ts"],"sourcesContent":["import 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 { extractJWT } from '../extractJWT.js'\nimport { meOperation } from '../operations/me.js'\n\nexport const meHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const currentToken = extractJWT(req)\n\n const result = await meOperation({\n collection,\n currentToken,\n req,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.token\n }\n\n return Response.json(\n {\n ...result,\n message: req.t('authentication:account'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","getRequestCollection","headersWithCors","extractJWT","meOperation","meHandler","req","collection","currentToken","result","config","auth","removeTokenFromResponses","token","Response","json","message","t","headers","Headers","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AAIpC,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,UAAU,QAAQ,mBAAkB;AAC7C,SAASC,WAAW,QAAQ,sBAAqB;AAEjD,OAAO,MAAMC,YAA4B,OAAOC;IAC9C,MAAMC,aAAaN,qBAAqBK;IACxC,MAAME,eAAeL,WAAWG;IAEhC,MAAMG,SAAS,MAAML,YAAY;QAC/BG;QACAC;QACAF;IACF;IAEA,IAAIC,WAAWG,MAAM,CAACC,IAAI,CAACC,wBAAwB,EAAE;QACnD,OAAOH,OAAOI,KAAK;IACrB;IAEA,OAAOC,SAASC,IAAI,CAClB;QACE,GAAGN,MAAM;QACTO,SAASV,IAAIW,CAAC,CAAC;IACjB,GACA;QACEC,SAAShB,gBAAgB;YACvBgB,SAAS,IAAIC;YACbb;QACF;QACAc,QAAQpB,WAAWqB,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/refresh.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAO3D,eAAO,MAAM,cAAc,EAAE,cAsC5B,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import httpStatus from 'http-status';
|
|
2
|
+
import { getRequestCollection } from '../../utilities/getRequestEntity.js';
|
|
3
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
4
|
+
import { generatePayloadCookie } from '../cookies.js';
|
|
5
|
+
import { refreshOperation } from '../operations/refresh.js';
|
|
6
|
+
export const refreshHandler = async (req)=>{
|
|
7
|
+
const collection = getRequestCollection(req);
|
|
8
|
+
const { t } = req;
|
|
9
|
+
const headers = headersWithCors({
|
|
10
|
+
headers: new Headers(),
|
|
11
|
+
req
|
|
12
|
+
});
|
|
13
|
+
const result = await refreshOperation({
|
|
14
|
+
collection,
|
|
15
|
+
req
|
|
16
|
+
});
|
|
17
|
+
if (result.setCookie) {
|
|
18
|
+
const cookie = generatePayloadCookie({
|
|
19
|
+
collectionAuthConfig: collection.config.auth,
|
|
20
|
+
cookiePrefix: req.payload.config.cookiePrefix,
|
|
21
|
+
token: result.refreshedToken
|
|
22
|
+
});
|
|
23
|
+
if (collection.config.auth.removeTokenFromResponses) {
|
|
24
|
+
delete result.refreshedToken;
|
|
25
|
+
}
|
|
26
|
+
headers.set('Set-Cookie', cookie);
|
|
27
|
+
}
|
|
28
|
+
return Response.json({
|
|
29
|
+
message: t('authentication:tokenRefreshSuccessful'),
|
|
30
|
+
...result
|
|
31
|
+
}, {
|
|
32
|
+
headers,
|
|
33
|
+
status: httpStatus.OK
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=refresh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/endpoints/refresh.ts"],"sourcesContent":["import 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 { generatePayloadCookie } from '../cookies.js'\nimport { refreshOperation } from '../operations/refresh.js'\n\nexport const refreshHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { t } = req\n\n const headers = headersWithCors({\n headers: new Headers(),\n req,\n })\n\n const result = await refreshOperation({\n collection,\n req,\n })\n\n if (result.setCookie) {\n const cookie = generatePayloadCookie({\n collectionAuthConfig: collection.config.auth,\n cookiePrefix: req.payload.config.cookiePrefix,\n token: result.refreshedToken,\n })\n\n if (collection.config.auth.removeTokenFromResponses) {\n delete result.refreshedToken\n }\n\n headers.set('Set-Cookie', cookie)\n }\n\n return Response.json(\n {\n message: t('authentication:tokenRefreshSuccessful'),\n ...result,\n },\n {\n headers,\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","getRequestCollection","headersWithCors","generatePayloadCookie","refreshOperation","refreshHandler","req","collection","t","headers","Headers","result","setCookie","cookie","collectionAuthConfig","config","auth","cookiePrefix","payload","token","refreshedToken","removeTokenFromResponses","set","Response","json","message","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AAIpC,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,qBAAqB,QAAQ,gBAAe;AACrD,SAASC,gBAAgB,QAAQ,2BAA0B;AAE3D,OAAO,MAAMC,iBAAiC,OAAOC;IACnD,MAAMC,aAAaN,qBAAqBK;IACxC,MAAM,EAAEE,CAAC,EAAE,GAAGF;IAEd,MAAMG,UAAUP,gBAAgB;QAC9BO,SAAS,IAAIC;QACbJ;IACF;IAEA,MAAMK,SAAS,MAAMP,iBAAiB;QACpCG;QACAD;IACF;IAEA,IAAIK,OAAOC,SAAS,EAAE;QACpB,MAAMC,SAASV,sBAAsB;YACnCW,sBAAsBP,WAAWQ,MAAM,CAACC,IAAI;YAC5CC,cAAcX,IAAIY,OAAO,CAACH,MAAM,CAACE,YAAY;YAC7CE,OAAOR,OAAOS,cAAc;QAC9B;QAEA,IAAIb,WAAWQ,MAAM,CAACC,IAAI,CAACK,wBAAwB,EAAE;YACnD,OAAOV,OAAOS,cAAc;QAC9B;QAEAX,QAAQa,GAAG,CAAC,cAAcT;IAC5B;IAEA,OAAOU,SAASC,IAAI,CAClB;QACEC,SAASjB,EAAE;QACX,GAAGG,MAAM;IACX,GACA;QACEF;QACAiB,QAAQ1B,WAAW2B,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerFirstUser.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/registerFirstUser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAO3D,eAAO,MAAM,wBAAwB,EAAE,cA8CtC,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import httpStatus from 'http-status';
|
|
2
|
+
import { getRequestCollection } from '../../utilities/getRequestEntity.js';
|
|
3
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
4
|
+
import { generatePayloadCookie } from '../cookies.js';
|
|
5
|
+
import { registerFirstUserOperation } from '../operations/registerFirstUser.js';
|
|
6
|
+
export const registerFirstUserHandler = async (req)=>{
|
|
7
|
+
const collection = getRequestCollection(req);
|
|
8
|
+
const { data, t } = req;
|
|
9
|
+
const authData = collection.config.auth?.loginWithUsername ? {
|
|
10
|
+
email: typeof req.data?.email === 'string' ? req.data.email : '',
|
|
11
|
+
password: typeof req.data?.password === 'string' ? req.data.password : '',
|
|
12
|
+
username: typeof req.data?.username === 'string' ? req.data.username : ''
|
|
13
|
+
} : {
|
|
14
|
+
email: typeof req.data?.email === 'string' ? req.data.email : '',
|
|
15
|
+
password: typeof req.data?.password === 'string' ? req.data.password : ''
|
|
16
|
+
};
|
|
17
|
+
const result = await registerFirstUserOperation({
|
|
18
|
+
collection,
|
|
19
|
+
data: {
|
|
20
|
+
...data,
|
|
21
|
+
...authData
|
|
22
|
+
},
|
|
23
|
+
req
|
|
24
|
+
});
|
|
25
|
+
const cookie = generatePayloadCookie({
|
|
26
|
+
collectionAuthConfig: collection.config.auth,
|
|
27
|
+
cookiePrefix: req.payload.config.cookiePrefix,
|
|
28
|
+
token: result.token
|
|
29
|
+
});
|
|
30
|
+
return Response.json({
|
|
31
|
+
exp: result.exp,
|
|
32
|
+
message: t('authentication:successfullyRegisteredFirstUser'),
|
|
33
|
+
token: result.token,
|
|
34
|
+
user: result.user
|
|
35
|
+
}, {
|
|
36
|
+
headers: headersWithCors({
|
|
37
|
+
headers: new Headers({
|
|
38
|
+
'Set-Cookie': cookie
|
|
39
|
+
}),
|
|
40
|
+
req
|
|
41
|
+
}),
|
|
42
|
+
status: httpStatus.OK
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=registerFirstUser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/endpoints/registerFirstUser.ts"],"sourcesContent":["import 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 { generatePayloadCookie } from '../cookies.js'\nimport { registerFirstUserOperation } from '../operations/registerFirstUser.js'\n\nexport const registerFirstUserHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { data, t } = req\n const authData = collection.config.auth?.loginWithUsername\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 registerFirstUserOperation({\n collection,\n data: {\n ...data,\n ...authData,\n },\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 return Response.json(\n {\n exp: result.exp,\n message: t('authentication:successfullyRegisteredFirstUser'),\n token: result.token,\n user: result.user,\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":["httpStatus","getRequestCollection","headersWithCors","generatePayloadCookie","registerFirstUserOperation","registerFirstUserHandler","req","collection","data","t","authData","config","auth","loginWithUsername","email","password","username","result","cookie","collectionAuthConfig","cookiePrefix","payload","token","Response","json","exp","message","user","headers","Headers","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AAIpC,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,qBAAqB,QAAQ,gBAAe;AACrD,SAASC,0BAA0B,QAAQ,qCAAoC;AAE/E,OAAO,MAAMC,2BAA2C,OAAOC;IAC7D,MAAMC,aAAaN,qBAAqBK;IACxC,MAAM,EAAEE,IAAI,EAAEC,CAAC,EAAE,GAAGH;IACpB,MAAMI,WAAWH,WAAWI,MAAM,CAACC,IAAI,EAAEC,oBACrC;QACEC,OAAO,OAAOR,IAAIE,IAAI,EAAEM,UAAU,WAAWR,IAAIE,IAAI,CAACM,KAAK,GAAG;QAC9DC,UAAU,OAAOT,IAAIE,IAAI,EAAEO,aAAa,WAAWT,IAAIE,IAAI,CAACO,QAAQ,GAAG;QACvEC,UAAU,OAAOV,IAAIE,IAAI,EAAEQ,aAAa,WAAWV,IAAIE,IAAI,CAACQ,QAAQ,GAAG;IACzE,IACA;QACEF,OAAO,OAAOR,IAAIE,IAAI,EAAEM,UAAU,WAAWR,IAAIE,IAAI,CAACM,KAAK,GAAG;QAC9DC,UAAU,OAAOT,IAAIE,IAAI,EAAEO,aAAa,WAAWT,IAAIE,IAAI,CAACO,QAAQ,GAAG;IACzE;IAEJ,MAAME,SAAS,MAAMb,2BAA2B;QAC9CG;QACAC,MAAM;YACJ,GAAGA,IAAI;YACP,GAAGE,QAAQ;QACb;QACAJ;IACF;IAEA,MAAMY,SAASf,sBAAsB;QACnCgB,sBAAsBZ,WAAWI,MAAM,CAACC,IAAI;QAC5CQ,cAAcd,IAAIe,OAAO,CAACV,MAAM,CAACS,YAAY;QAC7CE,OAAOL,OAAOK,KAAK;IACrB;IAEA,OAAOC,SAASC,IAAI,CAClB;QACEC,KAAKR,OAAOQ,GAAG;QACfC,SAASjB,EAAE;QACXa,OAAOL,OAAOK,KAAK;QACnBK,MAAMV,OAAOU,IAAI;IACnB,GACA;QACEC,SAAS1B,gBAAgB;YACvB0B,SAAS,IAAIC,QAAQ;gBACnB,cAAcX;YAChB;YACAZ;QACF;QACAwB,QAAQ9B,WAAW+B,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resetPassword.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/resetPassword.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAO3D,eAAO,MAAM,oBAAoB,EAAE,cAwClC,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import httpStatus from 'http-status';
|
|
2
|
+
import { getRequestCollection } from '../../utilities/getRequestEntity.js';
|
|
3
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
4
|
+
import { generatePayloadCookie } from '../cookies.js';
|
|
5
|
+
import { resetPasswordOperation } from '../operations/resetPassword.js';
|
|
6
|
+
export const resetPasswordHandler = async (req)=>{
|
|
7
|
+
const collection = getRequestCollection(req);
|
|
8
|
+
const { searchParams, t } = req;
|
|
9
|
+
const depth = searchParams.get('depth');
|
|
10
|
+
const result = await resetPasswordOperation({
|
|
11
|
+
collection,
|
|
12
|
+
data: {
|
|
13
|
+
password: typeof req.data?.password === 'string' ? req.data.password : '',
|
|
14
|
+
token: typeof req.data?.token === 'string' ? req.data.token : ''
|
|
15
|
+
},
|
|
16
|
+
depth: depth ? Number(depth) : undefined,
|
|
17
|
+
req
|
|
18
|
+
});
|
|
19
|
+
const cookie = generatePayloadCookie({
|
|
20
|
+
collectionAuthConfig: collection.config.auth,
|
|
21
|
+
cookiePrefix: req.payload.config.cookiePrefix,
|
|
22
|
+
token: result.token
|
|
23
|
+
});
|
|
24
|
+
if (collection.config.auth.removeTokenFromResponses) {
|
|
25
|
+
delete result.token;
|
|
26
|
+
}
|
|
27
|
+
return Response.json({
|
|
28
|
+
message: t('authentication:passwordResetSuccessfully'),
|
|
29
|
+
...result
|
|
30
|
+
}, {
|
|
31
|
+
headers: headersWithCors({
|
|
32
|
+
headers: new Headers({
|
|
33
|
+
'Set-Cookie': cookie
|
|
34
|
+
}),
|
|
35
|
+
req
|
|
36
|
+
}),
|
|
37
|
+
status: httpStatus.OK
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=resetPassword.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/endpoints/resetPassword.ts"],"sourcesContent":["import 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 { generatePayloadCookie } from '../cookies.js'\nimport { resetPasswordOperation } from '../operations/resetPassword.js'\n\nexport const resetPasswordHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { searchParams, t } = req\n const depth = searchParams.get('depth')\n\n const result = await resetPasswordOperation({\n collection,\n data: {\n password: typeof req.data?.password === 'string' ? req.data.password : '',\n token: typeof req.data?.token === 'string' ? req.data.token : '',\n },\n depth: 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:passwordResetSuccessfully'),\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":["httpStatus","getRequestCollection","headersWithCors","generatePayloadCookie","resetPasswordOperation","resetPasswordHandler","req","collection","searchParams","t","depth","get","result","data","password","token","Number","undefined","cookie","collectionAuthConfig","config","auth","cookiePrefix","payload","removeTokenFromResponses","Response","json","message","headers","Headers","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AAIpC,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,qBAAqB,QAAQ,gBAAe;AACrD,SAASC,sBAAsB,QAAQ,iCAAgC;AAEvE,OAAO,MAAMC,uBAAuC,OAAOC;IACzD,MAAMC,aAAaN,qBAAqBK;IACxC,MAAM,EAAEE,YAAY,EAAEC,CAAC,EAAE,GAAGH;IAC5B,MAAMI,QAAQF,aAAaG,GAAG,CAAC;IAE/B,MAAMC,SAAS,MAAMR,uBAAuB;QAC1CG;QACAM,MAAM;YACJC,UAAU,OAAOR,IAAIO,IAAI,EAAEC,aAAa,WAAWR,IAAIO,IAAI,CAACC,QAAQ,GAAG;YACvEC,OAAO,OAAOT,IAAIO,IAAI,EAAEE,UAAU,WAAWT,IAAIO,IAAI,CAACE,KAAK,GAAG;QAChE;QACAL,OAAOA,QAAQM,OAAON,SAASO;QAC/BX;IACF;IAEA,MAAMY,SAASf,sBAAsB;QACnCgB,sBAAsBZ,WAAWa,MAAM,CAACC,IAAI;QAC5CC,cAAchB,IAAIiB,OAAO,CAACH,MAAM,CAACE,YAAY;QAC7CP,OAAOH,OAAOG,KAAK;IACrB;IAEA,IAAIR,WAAWa,MAAM,CAACC,IAAI,CAACG,wBAAwB,EAAE;QACnD,OAAOZ,OAAOG,KAAK;IACrB;IAEA,OAAOU,SAASC,IAAI,CAClB;QACEC,SAASlB,EAAE;QACX,GAAGG,MAAM;IACX,GACA;QACEgB,SAAS1B,gBAAgB;YACvB0B,SAAS,IAAIC,QAAQ;gBACnB,cAAcX;YAChB;YACAZ;QACF;QACAwB,QAAQ9B,WAAW+B,EAAE;IACvB;AAEJ,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unlock.d.ts","sourceRoot":"","sources":["../../../src/auth/endpoints/unlock.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAM3D,eAAO,MAAM,aAAa,EAAE,cAgC3B,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import httpStatus from 'http-status';
|
|
2
|
+
import { getRequestCollection } from '../../utilities/getRequestEntity.js';
|
|
3
|
+
import { headersWithCors } from '../../utilities/headersWithCors.js';
|
|
4
|
+
import { unlockOperation } from '../operations/unlock.js';
|
|
5
|
+
export const unlockHandler = async (req)=>{
|
|
6
|
+
const collection = getRequestCollection(req);
|
|
7
|
+
const { t } = req;
|
|
8
|
+
const authData = collection.config.auth?.loginWithUsername !== false ? {
|
|
9
|
+
email: typeof req.data?.email === 'string' ? req.data.email : '',
|
|
10
|
+
username: typeof req.data?.username === 'string' ? req.data.username : ''
|
|
11
|
+
} : {
|
|
12
|
+
email: typeof req.data?.email === 'string' ? req.data.email : ''
|
|
13
|
+
};
|
|
14
|
+
await unlockOperation({
|
|
15
|
+
collection,
|
|
16
|
+
data: authData,
|
|
17
|
+
req
|
|
18
|
+
});
|
|
19
|
+
return Response.json({
|
|
20
|
+
message: t('general:success')
|
|
21
|
+
}, {
|
|
22
|
+
headers: headersWithCors({
|
|
23
|
+
headers: new Headers(),
|
|
24
|
+
req
|
|
25
|
+
}),
|
|
26
|
+
status: httpStatus.OK
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=unlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/endpoints/unlock.ts"],"sourcesContent":["import 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 { unlockOperation } from '../operations/unlock.js'\n\nexport const unlockHandler: PayloadHandler = async (req) => {\n const collection = getRequestCollection(req)\n const { t } = req\n\n const authData =\n collection.config.auth?.loginWithUsername !== false\n ? {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n username: typeof req.data?.username === 'string' ? req.data.username : '',\n }\n : {\n email: typeof req.data?.email === 'string' ? req.data.email : '',\n }\n\n await unlockOperation({\n collection,\n data: authData,\n req,\n })\n\n return Response.json(\n {\n message: t('general:success'),\n },\n {\n headers: headersWithCors({\n headers: new Headers(),\n req,\n }),\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","getRequestCollection","headersWithCors","unlockOperation","unlockHandler","req","collection","t","authData","config","auth","loginWithUsername","email","data","username","Response","json","message","headers","Headers","status","OK"],"mappings":"AAAA,OAAOA,gBAAgB,cAAa;AAIpC,SAASC,oBAAoB,QAAQ,sCAAqC;AAC1E,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,0BAAyB;AAEzD,OAAO,MAAMC,gBAAgC,OAAOC;IAClD,MAAMC,aAAaL,qBAAqBI;IACxC,MAAM,EAAEE,CAAC,EAAE,GAAGF;IAEd,MAAMG,WACJF,WAAWG,MAAM,CAACC,IAAI,EAAEC,sBAAsB,QAC1C;QACEC,OAAO,OAAOP,IAAIQ,IAAI,EAAED,UAAU,WAAWP,IAAIQ,IAAI,CAACD,KAAK,GAAG;QAC9DE,UAAU,OAAOT,IAAIQ,IAAI,EAAEC,aAAa,WAAWT,IAAIQ,IAAI,CAACC,QAAQ,GAAG;IACzE,IACA;QACEF,OAAO,OAAOP,IAAIQ,IAAI,EAAED,UAAU,WAAWP,IAAIQ,IAAI,CAACD,KAAK,GAAG;IAChE;IAEN,MAAMT,gBAAgB;QACpBG;QACAO,MAAML;QACNH;IACF;IAEA,OAAOU,SAASC,IAAI,CAClB;QACEC,SAASV,EAAE;IACb,GACA;QACEW,SAAShB,gBAAgB;YACvBgB,SAAS,IAAIC;YACbd;QACF;QACAe,QAAQpB,WAAWqB,EAAE;IACvB;AAEJ,EAAC"}
|