payload 3.0.0-beta.65 → 3.0.0-beta.67
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/baseFields/accountLock.d.ts +1 -2
- package/dist/auth/baseFields/accountLock.d.ts.map +1 -1
- package/dist/auth/baseFields/accountLock.js +1 -1
- package/dist/auth/baseFields/accountLock.js.map +1 -1
- package/dist/auth/baseFields/apiKey.d.ts +1 -2
- package/dist/auth/baseFields/apiKey.d.ts.map +1 -1
- package/dist/auth/baseFields/apiKey.js +1 -2
- package/dist/auth/baseFields/apiKey.js.map +1 -1
- package/dist/auth/baseFields/auth.d.ts +1 -2
- package/dist/auth/baseFields/auth.d.ts.map +1 -1
- package/dist/auth/baseFields/auth.js +1 -2
- package/dist/auth/baseFields/auth.js.map +1 -1
- package/dist/auth/baseFields/email.d.ts +5 -0
- package/dist/auth/baseFields/email.d.ts.map +1 -0
- package/dist/auth/baseFields/email.js +25 -0
- package/dist/auth/baseFields/email.js.map +1 -0
- package/dist/auth/baseFields/username.d.ts +3 -0
- package/dist/auth/baseFields/username.d.ts.map +1 -0
- package/dist/auth/baseFields/username.js +25 -0
- package/dist/auth/baseFields/username.js.map +1 -0
- package/dist/auth/baseFields/verification.d.ts +1 -2
- package/dist/auth/baseFields/verification.d.ts.map +1 -1
- package/dist/auth/baseFields/verification.js +1 -1
- package/dist/auth/baseFields/verification.js.map +1 -1
- package/dist/auth/getAuthFields.d.ts +4 -0
- package/dist/auth/getAuthFields.d.ts.map +1 -0
- package/dist/auth/getAuthFields.js +35 -0
- package/dist/auth/getAuthFields.js.map +1 -0
- package/dist/auth/isLocked.d.ts.map +1 -1
- package/dist/auth/isLocked.js +4 -1
- package/dist/auth/isLocked.js.map +1 -1
- package/dist/auth/operations/forgotPassword.d.ts.map +1 -1
- package/dist/auth/operations/forgotPassword.js +25 -14
- package/dist/auth/operations/forgotPassword.js.map +1 -1
- package/dist/auth/operations/local/unlock.d.ts +5 -7
- package/dist/auth/operations/local/unlock.d.ts.map +1 -1
- package/dist/auth/operations/local/unlock.js.map +1 -1
- package/dist/auth/operations/login.d.ts.map +1 -1
- package/dist/auth/operations/login.js +70 -17
- package/dist/auth/operations/login.js.map +1 -1
- package/dist/auth/operations/resetPassword.d.ts +0 -1
- package/dist/auth/operations/resetPassword.d.ts.map +1 -1
- package/dist/auth/operations/resetPassword.js +0 -1
- package/dist/auth/operations/resetPassword.js.map +1 -1
- package/dist/auth/operations/unlock.d.ts +5 -7
- package/dist/auth/operations/unlock.d.ts.map +1 -1
- package/dist/auth/operations/unlock.js +22 -15
- package/dist/auth/operations/unlock.js.map +1 -1
- package/dist/auth/types.d.ts +7 -2
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/collections/config/defaults.d.ts +2 -0
- package/dist/collections/config/defaults.d.ts.map +1 -1
- package/dist/collections/config/defaults.js +4 -0
- package/dist/collections/config/defaults.js.map +1 -1
- package/dist/collections/config/sanitize.d.ts.map +1 -1
- package/dist/collections/config/sanitize.js +6 -22
- package/dist/collections/config/sanitize.js.map +1 -1
- package/dist/collections/config/schema.d.ts.map +1 -1
- package/dist/collections/config/schema.js +4 -1
- package/dist/collections/config/schema.js.map +1 -1
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js +1 -4
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/fields/config/client.d.ts +1 -1
- package/dist/fields/config/client.d.ts.map +1 -1
- package/dist/fields/config/client.js +3 -1
- package/dist/fields/config/client.js.map +1 -1
- package/dist/fields/config/schema.d.ts.map +1 -1
- package/dist/fields/config/schema.js +3 -0
- package/dist/fields/config/schema.js.map +1 -1
- package/dist/fields/config/types.d.ts +9 -0
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/validations.d.ts +1 -0
- package/dist/fields/validations.d.ts.map +1 -1
- package/dist/fields/validations.js +13 -0
- package/dist/fields/validations.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/uploads/cropImage.d.ts +19 -6
- package/dist/uploads/cropImage.d.ts.map +1 -1
- package/dist/uploads/cropImage.js +4 -4
- package/dist/uploads/cropImage.js.map +1 -1
- package/dist/uploads/generateFileData.d.ts.map +1 -1
- package/dist/uploads/generateFileData.js +3 -1
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/uploads/imageResizer.d.ts.map +1 -1
- package/dist/uploads/imageResizer.js +117 -101
- package/dist/uploads/imageResizer.js.map +1 -1
- package/dist/uploads/types.d.ts +16 -10
- package/dist/uploads/types.d.ts.map +1 -1
- package/dist/uploads/types.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +103 -42
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/telemetry/conf/envPaths.d.ts +23 -0
- package/dist/utilities/telemetry/conf/envPaths.d.ts.map +1 -0
- package/dist/utilities/telemetry/conf/envPaths.js +70 -0
- package/dist/utilities/telemetry/conf/envPaths.js.map +1 -0
- package/dist/utilities/telemetry/conf/index.d.ts +84 -0
- package/dist/utilities/telemetry/conf/index.d.ts.map +1 -0
- package/dist/utilities/telemetry/conf/index.js +144 -0
- package/dist/utilities/telemetry/conf/index.js.map +1 -0
- package/dist/utilities/telemetry/index.d.ts.map +1 -1
- package/dist/utilities/telemetry/index.js +1 -1
- package/dist/utilities/telemetry/index.js.map +1 -1
- package/package.json +2 -3
- package/dist/auth/baseFields/loginField.d.ts +0 -4
- package/dist/auth/baseFields/loginField.d.ts.map +0 -1
- package/dist/auth/baseFields/loginField.js +0 -35
- package/dist/auth/baseFields/loginField.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountLock.d.ts","sourceRoot":"","sources":["../../../src/auth/baseFields/accountLock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;
|
|
1
|
+
{"version":3,"file":"accountLock.d.ts","sourceRoot":"","sources":["../../../src/auth/baseFields/accountLock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAEzD,eAAO,MAAM,iBAAiB,EAAE,KAAK,EAYzB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/auth/baseFields/accountLock.ts"],"sourcesContent":["import type { Field } from '../../fields/config/types.js'\n\nexport
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/baseFields/accountLock.ts"],"sourcesContent":["import type { Field } from '../../fields/config/types.js'\n\nexport const accountLockFields: Field[] = [\n {\n name: 'loginAttempts',\n type: 'number',\n defaultValue: 0,\n hidden: true,\n },\n {\n name: 'lockUntil',\n type: 'date',\n hidden: true,\n },\n] as Field[]\n"],"names":["accountLockFields","name","type","defaultValue","hidden"],"mappings":"AAEA,OAAO,MAAMA,oBAA6B;IACxC;QACEC,MAAM;QACNC,MAAM;QACNC,cAAc;QACdC,QAAQ;IACV;IACA;QACEH,MAAM;QACNC,MAAM;QACNE,QAAQ;IACV;CACD,CAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiKey.d.ts","sourceRoot":"","sources":["../../../src/auth/baseFields/apiKey.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAa,MAAM,8BAA8B,CAAA;
|
|
1
|
+
{"version":3,"file":"apiKey.d.ts","sourceRoot":"","sources":["../../../src/auth/baseFields/apiKey.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAa,MAAM,8BAA8B,CAAA;AAOpE,eAAO,MAAM,YAAY,EAoDpB,KAAK,EAAE,CAAA"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import crypto from 'crypto';
|
|
2
2
|
const encryptKey = ({ req, value })=>value ? req.payload.encrypt(value) : null;
|
|
3
3
|
const decryptKey = ({ req, value })=>value ? req.payload.decrypt(value) : undefined;
|
|
4
|
-
|
|
5
|
-
export default [
|
|
4
|
+
export const apiKeyFields = [
|
|
6
5
|
{
|
|
7
6
|
name: 'enableAPIKey',
|
|
8
7
|
type: 'checkbox',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/auth/baseFields/apiKey.ts"],"sourcesContent":["import crypto from 'crypto'\n\nimport type { Field, FieldHook } from '../../fields/config/types.js'\n\nconst encryptKey: FieldHook = ({ req, value }) =>\n value ? req.payload.encrypt(value as string) : null\nconst decryptKey: FieldHook = ({ req, value }) =>\n value ? req.payload.decrypt(value as string) : undefined\n\
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/baseFields/apiKey.ts"],"sourcesContent":["import crypto from 'crypto'\n\nimport type { Field, FieldHook } from '../../fields/config/types.js'\n\nconst encryptKey: FieldHook = ({ req, value }) =>\n value ? req.payload.encrypt(value as string) : null\nconst decryptKey: FieldHook = ({ req, value }) =>\n value ? req.payload.decrypt(value as string) : undefined\n\nexport const apiKeyFields = [\n {\n name: 'enableAPIKey',\n type: 'checkbox',\n admin: {\n components: {\n Field: () => null,\n },\n },\n label: ({ t }) => t('authentication:enableAPIKey'),\n },\n {\n name: 'apiKey',\n type: 'text',\n admin: {\n components: {\n Field: () => null,\n },\n },\n hooks: {\n afterRead: [decryptKey],\n beforeChange: [encryptKey],\n },\n label: ({ t }) => t('authentication:apiKey'),\n },\n {\n name: 'apiKeyIndex',\n type: 'text',\n admin: {\n disabled: true,\n },\n hidden: true,\n hooks: {\n beforeValidate: [\n ({ data, req, value }) => {\n if (data.apiKey === false || data.apiKey === null) {\n return null\n }\n if (data.enableAPIKey === false || data.enableAPIKey === null) {\n return null\n }\n if (data.apiKey) {\n return crypto\n .createHmac('sha1', req.payload.secret)\n .update(data.apiKey as string)\n .digest('hex')\n }\n return value\n },\n ],\n },\n },\n] as Field[]\n"],"names":["crypto","encryptKey","req","value","payload","encrypt","decryptKey","decrypt","undefined","apiKeyFields","name","type","admin","components","Field","label","t","hooks","afterRead","beforeChange","disabled","hidden","beforeValidate","data","apiKey","enableAPIKey","createHmac","secret","update","digest"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAI3B,MAAMC,aAAwB,CAAC,EAAEC,GAAG,EAAEC,KAAK,EAAE,GAC3CA,QAAQD,IAAIE,OAAO,CAACC,OAAO,CAACF,SAAmB;AACjD,MAAMG,aAAwB,CAAC,EAAEJ,GAAG,EAAEC,KAAK,EAAE,GAC3CA,QAAQD,IAAIE,OAAO,CAACG,OAAO,CAACJ,SAAmBK;AAEjD,OAAO,MAAMC,eAAe;IAC1B;QACEC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,YAAY;gBACVC,OAAO,IAAM;YACf;QACF;QACAC,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;IACtB;IACA;QACEN,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,YAAY;gBACVC,OAAO,IAAM;YACf;QACF;QACAG,OAAO;YACLC,WAAW;gBAACZ;aAAW;YACvBa,cAAc;gBAAClB;aAAW;QAC5B;QACAc,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;IACtB;IACA;QACEN,MAAM;QACNC,MAAM;QACNC,OAAO;YACLQ,UAAU;QACZ;QACAC,QAAQ;QACRJ,OAAO;YACLK,gBAAgB;gBACd,CAAC,EAAEC,IAAI,EAAErB,GAAG,EAAEC,KAAK,EAAE;oBACnB,IAAIoB,KAAKC,MAAM,KAAK,SAASD,KAAKC,MAAM,KAAK,MAAM;wBACjD,OAAO;oBACT;oBACA,IAAID,KAAKE,YAAY,KAAK,SAASF,KAAKE,YAAY,KAAK,MAAM;wBAC7D,OAAO;oBACT;oBACA,IAAIF,KAAKC,MAAM,EAAE;wBACf,OAAOxB,OACJ0B,UAAU,CAAC,QAAQxB,IAAIE,OAAO,CAACuB,MAAM,EACrCC,MAAM,CAACL,KAAKC,MAAM,EAClBK,MAAM,CAAC;oBACZ;oBACA,OAAO1B;gBACT;aACD;QACH;IACF;CACD,CAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/auth/baseFields/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAEzD,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/auth/baseFields/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAEzD,eAAO,MAAM,cAAc,EAAE,KAAK,EAqBjC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/auth/baseFields/auth.ts"],"sourcesContent":["import type { Field } from '../../fields/config/types.js'\n\
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/baseFields/auth.ts"],"sourcesContent":["import type { Field } from '../../fields/config/types.js'\n\nexport const baseAuthFields: Field[] = [\n {\n name: 'resetPasswordToken',\n type: 'text',\n hidden: true,\n },\n {\n name: 'resetPasswordExpiration',\n type: 'date',\n hidden: true,\n },\n {\n name: 'salt',\n type: 'text',\n hidden: true,\n },\n {\n name: 'hash',\n type: 'text',\n hidden: true,\n },\n]\n"],"names":["baseAuthFields","name","type","hidden"],"mappings":"AAEA,OAAO,MAAMA,iBAA0B;IACrC;QACEC,MAAM;QACNC,MAAM;QACNC,QAAQ;IACV;IACA;QACEF,MAAM;QACNC,MAAM;QACNC,QAAQ;IACV;IACA;QACEF,MAAM;QACNC,MAAM;QACNC,QAAQ;IACV;IACA;QACEF,MAAM;QACNC,MAAM;QACNC,QAAQ;IACV;CACD,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../../src/auth/baseFields/email.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAIzD,eAAO,MAAM,UAAU,iBAAyB;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,KAAG,KAqBvE,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { email } from '../../fields/validations.js';
|
|
2
|
+
export const emailField = ({ required = true })=>({
|
|
3
|
+
name: 'email',
|
|
4
|
+
type: 'email',
|
|
5
|
+
admin: {
|
|
6
|
+
components: {
|
|
7
|
+
Field: required ? ()=>null : undefined
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
hooks: {
|
|
11
|
+
beforeChange: [
|
|
12
|
+
({ value })=>{
|
|
13
|
+
if (value) {
|
|
14
|
+
return value.toLowerCase().trim();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
label: ({ t })=>t('general:email'),
|
|
20
|
+
required,
|
|
21
|
+
unique: true,
|
|
22
|
+
validate: email
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=email.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/baseFields/email.ts"],"sourcesContent":["import type { Field } from '../../fields/config/types.js'\n\nimport { email } from '../../fields/validations.js'\n\nexport const emailField = ({ required = true }: { required?: boolean }): Field => ({\n name: 'email',\n type: 'email',\n admin: {\n components: {\n Field: required ? () => null : undefined,\n },\n },\n hooks: {\n beforeChange: [\n ({ value }) => {\n if (value) {\n return value.toLowerCase().trim()\n }\n },\n ],\n },\n label: ({ t }) => t('general:email'),\n required,\n unique: true,\n validate: email,\n})\n"],"names":["email","emailField","required","name","type","admin","components","Field","undefined","hooks","beforeChange","value","toLowerCase","trim","label","t","unique","validate"],"mappings":"AAEA,SAASA,KAAK,QAAQ,8BAA6B;AAEnD,OAAO,MAAMC,aAAa,CAAC,EAAEC,WAAW,IAAI,EAA0B,GAAa,CAAA;QACjFC,MAAM;QACNC,MAAM;QACNC,OAAO;YACLC,YAAY;gBACVC,OAAOL,WAAW,IAAM,OAAOM;YACjC;QACF;QACAC,OAAO;YACLC,cAAc;gBACZ,CAAC,EAAEC,KAAK,EAAE;oBACR,IAAIA,OAAO;wBACT,OAAOA,MAAMC,WAAW,GAAGC,IAAI;oBACjC;gBACF;aACD;QACH;QACAC,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;QACpBb;QACAc,QAAQ;QACRC,UAAUjB;IACZ,CAAA,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"username.d.ts","sourceRoot":"","sources":["../../../src/auth/baseFields/username.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAIzD,eAAO,MAAM,aAAa,EAAE,KAqB3B,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { username } from '../../fields/validations.js';
|
|
2
|
+
export const usernameField = {
|
|
3
|
+
name: 'username',
|
|
4
|
+
type: 'text',
|
|
5
|
+
admin: {
|
|
6
|
+
components: {
|
|
7
|
+
Field: ()=>null
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
hooks: {
|
|
11
|
+
beforeChange: [
|
|
12
|
+
({ value })=>{
|
|
13
|
+
if (value) {
|
|
14
|
+
return value.toLowerCase().trim();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
label: ({ t })=>t('authentication:username'),
|
|
20
|
+
required: true,
|
|
21
|
+
unique: true,
|
|
22
|
+
validate: username
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=username.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/baseFields/username.ts"],"sourcesContent":["import type { Field } from '../../fields/config/types.js'\n\nimport { username } from '../../fields/validations.js'\n\nexport const usernameField: Field = {\n name: 'username',\n type: 'text',\n admin: {\n components: {\n Field: () => null,\n },\n },\n hooks: {\n beforeChange: [\n ({ value }) => {\n if (value) {\n return value.toLowerCase().trim()\n }\n },\n ],\n },\n label: ({ t }) => t('authentication:username'),\n required: true,\n unique: true,\n validate: username,\n}\n"],"names":["username","usernameField","name","type","admin","components","Field","hooks","beforeChange","value","toLowerCase","trim","label","t","required","unique","validate"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,8BAA6B;AAEtD,OAAO,MAAMC,gBAAuB;IAClCC,MAAM;IACNC,MAAM;IACNC,OAAO;QACLC,YAAY;YACVC,OAAO,IAAM;QACf;IACF;IACAC,OAAO;QACLC,cAAc;YACZ,CAAC,EAAEC,KAAK,EAAE;gBACR,IAAIA,OAAO;oBACT,OAAOA,MAAMC,WAAW,GAAGC,IAAI;gBACjC;YACF;SACD;IACH;IACAC,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;IACpBC,UAAU;IACVC,QAAQ;IACRC,UAAUhB;AACZ,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verification.d.ts","sourceRoot":"","sources":["../../../src/auth/baseFields/verification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAa,MAAM,8BAA8B,CAAA;
|
|
1
|
+
{"version":3,"file":"verification.d.ts","sourceRoot":"","sources":["../../../src/auth/baseFields/verification.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAa,MAAM,8BAA8B,CAAA;AAiBpE,eAAO,MAAM,kBAAkB,EAAE,KAAK,EAwB1B,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/auth/baseFields/verification.ts"],"sourcesContent":["import type { Field, FieldHook } from '../../fields/config/types.js'\n\nconst autoRemoveVerificationToken: FieldHook = ({ data, operation, originalDoc, value }) => {\n // If a user manually sets `_verified` to true,\n // and it was `false`, set _verificationToken to `null`.\n // This is useful because the admin panel\n // allows users to set `_verified` to true manually\n\n if (operation === 'update') {\n if (data?._verified === true && originalDoc?._verified === false) {\n return null\n }\n }\n\n return value\n}\n\nexport
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/baseFields/verification.ts"],"sourcesContent":["import type { Field, FieldHook } from '../../fields/config/types.js'\n\nconst autoRemoveVerificationToken: FieldHook = ({ data, operation, originalDoc, value }) => {\n // If a user manually sets `_verified` to true,\n // and it was `false`, set _verificationToken to `null`.\n // This is useful because the admin panel\n // allows users to set `_verified` to true manually\n\n if (operation === 'update') {\n if (data?._verified === true && originalDoc?._verified === false) {\n return null\n }\n }\n\n return value\n}\n\nexport const verificationFields: Field[] = [\n {\n name: '_verified',\n type: 'checkbox',\n access: {\n create: ({ req: { user } }) => Boolean(user),\n read: ({ req: { user } }) => Boolean(user),\n update: ({ req: { user } }) => Boolean(user),\n },\n admin: {\n components: {\n Field: () => null,\n },\n },\n label: ({ t }) => t('authentication:verified'),\n },\n {\n name: '_verificationToken',\n type: 'text',\n hidden: true,\n hooks: {\n beforeChange: [autoRemoveVerificationToken],\n },\n },\n] as Field[]\n"],"names":["autoRemoveVerificationToken","data","operation","originalDoc","value","_verified","verificationFields","name","type","access","create","req","user","Boolean","read","update","admin","components","Field","label","t","hidden","hooks","beforeChange"],"mappings":"AAEA,MAAMA,8BAAyC,CAAC,EAAEC,IAAI,EAAEC,SAAS,EAAEC,WAAW,EAAEC,KAAK,EAAE;IACrF,+CAA+C;IAC/C,wDAAwD;IACxD,yCAAyC;IACzC,mDAAmD;IAEnD,IAAIF,cAAc,UAAU;QAC1B,IAAID,MAAMI,cAAc,QAAQF,aAAaE,cAAc,OAAO;YAChE,OAAO;QACT;IACF;IAEA,OAAOD;AACT;AAEA,OAAO,MAAME,qBAA8B;IACzC;QACEC,MAAM;QACNC,MAAM;QACNC,QAAQ;YACNC,QAAQ,CAAC,EAAEC,KAAK,EAAEC,IAAI,EAAE,EAAE,GAAKC,QAAQD;YACvCE,MAAM,CAAC,EAAEH,KAAK,EAAEC,IAAI,EAAE,EAAE,GAAKC,QAAQD;YACrCG,QAAQ,CAAC,EAAEJ,KAAK,EAAEC,IAAI,EAAE,EAAE,GAAKC,QAAQD;QACzC;QACAI,OAAO;YACLC,YAAY;gBACVC,OAAO,IAAM;YACf;QACF;QACAC,OAAO,CAAC,EAAEC,CAAC,EAAE,GAAKA,EAAE;IACtB;IACA;QACEb,MAAM;QACNC,MAAM;QACNa,QAAQ;QACRC,OAAO;YACLC,cAAc;gBAACvB;aAA4B;QAC7C;IACF;CACD,CAAW"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAuthFields.d.ts","sourceRoot":"","sources":["../../src/auth/getAuthFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AASlD,eAAO,MAAM,iBAAiB,eAAgB,gBAAgB,KAAG,KAAK,EAiCrE,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { accountLockFields } from './baseFields/accountLock.js';
|
|
2
|
+
import { apiKeyFields } from './baseFields/apiKey.js';
|
|
3
|
+
import { baseAuthFields } from './baseFields/auth.js';
|
|
4
|
+
import { emailField } from './baseFields/email.js';
|
|
5
|
+
import { usernameField } from './baseFields/username.js';
|
|
6
|
+
import { verificationFields } from './baseFields/verification.js';
|
|
7
|
+
export const getBaseAuthFields = (authConfig)=>{
|
|
8
|
+
const authFields = [];
|
|
9
|
+
if (authConfig.useAPIKey) {
|
|
10
|
+
authFields.push(...apiKeyFields);
|
|
11
|
+
}
|
|
12
|
+
if (!authConfig.disableLocalStrategy) {
|
|
13
|
+
const emailFieldIndex = authFields.push(emailField({
|
|
14
|
+
required: true
|
|
15
|
+
})) - 1;
|
|
16
|
+
if (authConfig.loginWithUsername) {
|
|
17
|
+
if (typeof authConfig.loginWithUsername === 'object' && authConfig.loginWithUsername.requireEmail === false) {
|
|
18
|
+
authFields[emailFieldIndex] = emailField({
|
|
19
|
+
required: false
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
authFields.push(usernameField);
|
|
23
|
+
}
|
|
24
|
+
authFields.push(...baseAuthFields);
|
|
25
|
+
if (authConfig.verify) {
|
|
26
|
+
authFields.push(...verificationFields);
|
|
27
|
+
}
|
|
28
|
+
if (authConfig.maxLoginAttempts > 0) {
|
|
29
|
+
authFields.push(...accountLockFields);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return authFields;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=getAuthFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/auth/getAuthFields.ts"],"sourcesContent":["import type { Field } from '../fields/config/types.js'\nimport type { IncomingAuthType } from './types.js'\n\nimport { accountLockFields } from './baseFields/accountLock.js'\nimport { apiKeyFields } from './baseFields/apiKey.js'\nimport { baseAuthFields } from './baseFields/auth.js'\nimport { emailField } from './baseFields/email.js'\nimport { usernameField } from './baseFields/username.js'\nimport { verificationFields } from './baseFields/verification.js'\n\nexport const getBaseAuthFields = (authConfig: IncomingAuthType): Field[] => {\n const authFields: Field[] = []\n\n if (authConfig.useAPIKey) {\n authFields.push(...apiKeyFields)\n }\n\n if (!authConfig.disableLocalStrategy) {\n const emailFieldIndex = authFields.push(emailField({ required: true })) - 1\n\n if (authConfig.loginWithUsername) {\n if (\n typeof authConfig.loginWithUsername === 'object' &&\n authConfig.loginWithUsername.requireEmail === false\n ) {\n authFields[emailFieldIndex] = emailField({ required: false })\n }\n\n authFields.push(usernameField)\n }\n\n authFields.push(...baseAuthFields)\n\n if (authConfig.verify) {\n authFields.push(...verificationFields)\n }\n\n if (authConfig.maxLoginAttempts > 0) {\n authFields.push(...accountLockFields)\n }\n }\n\n return authFields\n}\n"],"names":["accountLockFields","apiKeyFields","baseAuthFields","emailField","usernameField","verificationFields","getBaseAuthFields","authConfig","authFields","useAPIKey","push","disableLocalStrategy","emailFieldIndex","required","loginWithUsername","requireEmail","verify","maxLoginAttempts"],"mappings":"AAGA,SAASA,iBAAiB,QAAQ,8BAA6B;AAC/D,SAASC,YAAY,QAAQ,yBAAwB;AACrD,SAASC,cAAc,QAAQ,uBAAsB;AACrD,SAASC,UAAU,QAAQ,wBAAuB;AAClD,SAASC,aAAa,QAAQ,2BAA0B;AACxD,SAASC,kBAAkB,QAAQ,+BAA8B;AAEjE,OAAO,MAAMC,oBAAoB,CAACC;IAChC,MAAMC,aAAsB,EAAE;IAE9B,IAAID,WAAWE,SAAS,EAAE;QACxBD,WAAWE,IAAI,IAAIT;IACrB;IAEA,IAAI,CAACM,WAAWI,oBAAoB,EAAE;QACpC,MAAMC,kBAAkBJ,WAAWE,IAAI,CAACP,WAAW;YAAEU,UAAU;QAAK,MAAM;QAE1E,IAAIN,WAAWO,iBAAiB,EAAE;YAChC,IACE,OAAOP,WAAWO,iBAAiB,KAAK,YACxCP,WAAWO,iBAAiB,CAACC,YAAY,KAAK,OAC9C;gBACAP,UAAU,CAACI,gBAAgB,GAAGT,WAAW;oBAAEU,UAAU;gBAAM;YAC7D;YAEAL,WAAWE,IAAI,CAACN;QAClB;QAEAI,WAAWE,IAAI,IAAIR;QAEnB,IAAIK,WAAWS,MAAM,EAAE;YACrBR,WAAWE,IAAI,IAAIL;QACrB;QAEA,IAAIE,WAAWU,gBAAgB,GAAG,GAAG;YACnCT,WAAWE,IAAI,IAAIV;QACrB;IACF;IAEA,OAAOQ;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isLocked.d.ts","sourceRoot":"","sources":["../../src/auth/isLocked.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,QAAQ,SAAU,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"isLocked.d.ts","sourceRoot":"","sources":["../../src/auth/isLocked.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,QAAQ,SAAU,MAAM,KAAG,OAGhC,CAAA;AACD,eAAe,QAAQ,CAAA"}
|
package/dist/auth/isLocked.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/auth/isLocked.ts"],"sourcesContent":["const isLocked = (date: number): boolean =>
|
|
1
|
+
{"version":3,"sources":["../../src/auth/isLocked.ts"],"sourcesContent":["const isLocked = (date: number): boolean => {\n if (!date) return false\n return date > Date.now()\n}\nexport default isLocked\n"],"names":["isLocked","date","Date","now"],"mappings":"AAAA,MAAMA,WAAW,CAACC;IAChB,IAAI,CAACA,MAAM,OAAO;IAClB,OAAOA,OAAOC,KAAKC,GAAG;AACxB;AACA,eAAeH,SAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forgotPassword.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/forgotPassword.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gCAAgC,EAChC,UAAU,EACX,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"forgotPassword.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/forgotPassword.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,gCAAgC,EAChC,UAAU,EACX,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAS,MAAM,sBAAsB,CAAA;AAQjE,MAAM,MAAM,SAAS,CAAC,KAAK,SAAS,cAAc,IAAI;IACpD,UAAU,EAAE,UAAU,CAAA;IACtB,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KACvB,GAAG,gCAAgC,CAAC,KAAK,CAAC,CAAC,gBAAgB,CAAC,CAAA;IAC7D,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,MAAM,GAAG,MAAM,CAAA;AAE3B,eAAO,MAAM,uBAAuB,GAAU,KAAK,SAAS,cAAc,gBAC1D,SAAS,CAAC,KAAK,CAAC,KAC7B,OAAO,CAAC,IAAI,GAAG,MAAM,CA+KvB,CAAA"}
|
|
@@ -7,8 +7,13 @@ import { commitTransaction } from '../../utilities/commitTransaction.js';
|
|
|
7
7
|
import { initTransaction } from '../../utilities/initTransaction.js';
|
|
8
8
|
import { killTransaction } from '../../utilities/killTransaction.js';
|
|
9
9
|
export const forgotPasswordOperation = async (incomingArgs)=>{
|
|
10
|
-
const loginWithUsername = incomingArgs.collection
|
|
11
|
-
|
|
10
|
+
const loginWithUsername = incomingArgs.collection.config.auth.loginWithUsername;
|
|
11
|
+
const { data } = incomingArgs;
|
|
12
|
+
const canLoginWithUsername = Boolean(loginWithUsername);
|
|
13
|
+
const canLoginWithEmail = !loginWithUsername || loginWithUsername.allowEmailLogin;
|
|
14
|
+
const sanitizedEmail = canLoginWithEmail && (incomingArgs.data.email || '').toLowerCase().trim() || null;
|
|
15
|
+
const sanitizedUsername = 'username' in data && typeof data?.username === 'string' ? data.username.toLowerCase().trim() : null;
|
|
16
|
+
if (!sanitizedEmail && !sanitizedUsername) {
|
|
12
17
|
throw new APIError(`Missing ${loginWithUsername ? 'username' : 'email'}.`, httpStatus.BAD_REQUEST);
|
|
13
18
|
}
|
|
14
19
|
let args = incomingArgs;
|
|
@@ -32,21 +37,27 @@ export const forgotPasswordOperation = async (incomingArgs)=>{
|
|
|
32
37
|
// Forget password
|
|
33
38
|
// /////////////////////////////////////
|
|
34
39
|
let token = crypto.randomBytes(20).toString('hex');
|
|
35
|
-
if (!
|
|
40
|
+
if (!sanitizedEmail && !sanitizedUsername) {
|
|
36
41
|
throw new APIError(`Missing ${loginWithUsername ? 'username' : 'email'}.`, httpStatus.BAD_REQUEST);
|
|
37
42
|
}
|
|
43
|
+
let whereConstraint = {};
|
|
44
|
+
if (canLoginWithEmail && sanitizedEmail) {
|
|
45
|
+
whereConstraint = {
|
|
46
|
+
email: {
|
|
47
|
+
equals: sanitizedEmail
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
} else if (canLoginWithUsername && sanitizedUsername) {
|
|
51
|
+
whereConstraint = {
|
|
52
|
+
username: {
|
|
53
|
+
equals: sanitizedUsername
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
38
57
|
let user = await payload.db.findOne({
|
|
39
58
|
collection: collectionConfig.slug,
|
|
40
59
|
req,
|
|
41
|
-
where:
|
|
42
|
-
username: {
|
|
43
|
-
equals: data.username
|
|
44
|
-
}
|
|
45
|
-
} : {
|
|
46
|
-
email: {
|
|
47
|
-
equals: data.email.toLowerCase()
|
|
48
|
-
}
|
|
49
|
-
}
|
|
60
|
+
where: whereConstraint
|
|
50
61
|
});
|
|
51
62
|
// We don't want to indicate specifically that an email was not found,
|
|
52
63
|
// as doing so could lead to the exposure of registered emails.
|
|
@@ -61,7 +72,7 @@ export const forgotPasswordOperation = async (incomingArgs)=>{
|
|
|
61
72
|
data: user,
|
|
62
73
|
req
|
|
63
74
|
});
|
|
64
|
-
if (!disableEmail) {
|
|
75
|
+
if (!disableEmail && user.email) {
|
|
65
76
|
const protocol = new URL(req.url).protocol // includes the final :
|
|
66
77
|
;
|
|
67
78
|
const serverURL = config.serverURL !== null && config.serverURL !== '' ? config.serverURL : `${protocol}//${req.headers.get('host')}`;
|
|
@@ -87,7 +98,7 @@ export const forgotPasswordOperation = async (incomingArgs)=>{
|
|
|
87
98
|
from: `"${email.defaultFromName}" <${email.defaultFromAddress}>`,
|
|
88
99
|
html,
|
|
89
100
|
subject,
|
|
90
|
-
to:
|
|
101
|
+
to: user.email
|
|
91
102
|
});
|
|
92
103
|
}
|
|
93
104
|
// /////////////////////////////////////
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/auth/operations/forgotPassword.ts"],"sourcesContent":["import crypto from 'crypto'\nimport httpStatus from 'http-status'\nimport { URL } from 'url'\n\nimport type {\n AuthOperationsFromCollectionSlug,\n Collection,\n} from '../../collections/config/types.js'\nimport type { CollectionSlug } from '../../index.js'\nimport type { PayloadRequest } from '../../types/index.js'\n\nimport { buildAfterOperation } from '../../collections/operations/utils.js'\nimport { APIError } from '../../errors/index.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\n\nexport type Arguments<TSlug extends CollectionSlug> = {\n collection: Collection\n data: {\n [key: string]: unknown\n } & AuthOperationsFromCollectionSlug<TSlug>['forgotPassword']\n disableEmail?: boolean\n expiration?: number\n req: PayloadRequest\n}\n\nexport type Result = string\n\nexport const forgotPasswordOperation = async <TSlug extends CollectionSlug>(\n incomingArgs: Arguments<TSlug>,\n): Promise<null | string> => {\n const loginWithUsername = incomingArgs.collection?.config?.auth?.loginWithUsername\n\n if (!incomingArgs.data.email && !incomingArgs.data.username) {\n throw new APIError(\n `Missing ${loginWithUsername ? 'username' : 'email'}.`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n let args = incomingArgs\n\n try {\n const shouldCommit = await initTransaction(args.req)\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n await args.collection.config.hooks.beforeOperation.reduce(async (priorHook, hook) => {\n await priorHook\n\n args =\n (await hook({\n args,\n collection: args.collection?.config,\n context: args.req.context,\n operation: 'forgotPassword',\n req: args.req,\n })) || args\n }, Promise.resolve())\n\n const {\n collection: { config: collectionConfig },\n data,\n disableEmail,\n expiration,\n req: {\n payload: { config, email },\n payload,\n },\n req,\n } = args\n\n // /////////////////////////////////////\n // Forget password\n // /////////////////////////////////////\n\n let token: string = crypto.randomBytes(20).toString('hex')\n type UserDoc = {\n email?: string\n id: number | string\n resetPasswordExpiration?: string\n resetPasswordToken?: string\n }\n\n if (!data.email && !data.username) {\n throw new APIError(\n `Missing ${loginWithUsername ? 'username' : 'email'}.`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n let user = await payload.db.findOne<UserDoc>({\n collection: collectionConfig.slug,\n req,\n where:\n loginWithUsername && data?.username\n ? { username: { equals: data.username } }\n : { email: { equals: data.email.toLowerCase() } },\n })\n\n // We don't want to indicate specifically that an email was not found,\n // as doing so could lead to the exposure of registered emails.\n // Therefore, we prefer to fail silently.\n if (!user) return null\n\n user.resetPasswordToken = token\n user.resetPasswordExpiration = new Date(expiration || Date.now() + 3600000).toISOString() // 1 hour\n\n user = await payload.update({\n id: user.id,\n collection: collectionConfig.slug,\n data: user,\n req,\n })\n\n if (!disableEmail) {\n const protocol = new URL(req.url).protocol // includes the final :\n const serverURL =\n config.serverURL !== null && config.serverURL !== ''\n ? config.serverURL\n : `${protocol}//${req.headers.get('host')}`\n\n let html = `${req.t('authentication:youAreReceivingResetPassword')}\n <a href=\"${serverURL}${config.routes.admin}/${config.admin.routes.reset}/${token}\">${serverURL}${config.routes.admin}/${config.admin.routes.reset}/${token}</a>\n ${req.t('authentication:youDidNotRequestPassword')}`\n\n if (typeof collectionConfig.auth.forgotPassword.generateEmailHTML === 'function') {\n html = await collectionConfig.auth.forgotPassword.generateEmailHTML({\n req,\n token,\n user,\n })\n }\n\n let subject = req.t('authentication:resetYourPassword')\n\n if (typeof collectionConfig.auth.forgotPassword.generateEmailSubject === 'function') {\n subject = await collectionConfig.auth.forgotPassword.generateEmailSubject({\n req,\n token,\n user,\n })\n }\n\n await email.sendEmail({\n from: `\"${email.defaultFromName}\" <${email.defaultFromAddress}>`,\n html,\n subject,\n to: loginWithUsername ? user.email : data.email,\n })\n }\n\n // /////////////////////////////////////\n // afterForgotPassword - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterForgotPassword.reduce(async (priorHook, hook) => {\n await priorHook\n await hook({ args, collection: args.collection?.config, context: req.context })\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n token = await buildAfterOperation({\n args,\n collection: args.collection?.config,\n operation: 'forgotPassword',\n result: token,\n })\n\n if (shouldCommit) await commitTransaction(req)\n\n return token\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["crypto","httpStatus","URL","buildAfterOperation","APIError","commitTransaction","initTransaction","killTransaction","forgotPasswordOperation","incomingArgs","loginWithUsername","collection","config","auth","data","email","username","BAD_REQUEST","args","shouldCommit","req","hooks","beforeOperation","reduce","priorHook","hook","context","operation","Promise","resolve","collectionConfig","disableEmail","expiration","payload","token","randomBytes","toString","user","db","findOne","slug","where","equals","toLowerCase","resetPasswordToken","resetPasswordExpiration","Date","now","toISOString","update","id","protocol","url","serverURL","headers","get","html","t","routes","admin","reset","forgotPassword","generateEmailHTML","subject","generateEmailSubject","sendEmail","from","defaultFromName","defaultFromAddress","to","afterForgotPassword","result","error"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAC3B,OAAOC,gBAAgB,cAAa;AACpC,SAASC,GAAG,QAAQ,MAAK;AASzB,SAASC,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AAcpE,OAAO,MAAMC,0BAA0B,OACrCC;IAEA,MAAMC,oBAAoBD,aAAaE,UAAU,EAAEC,QAAQC,MAAMH;IAEjE,IAAI,CAACD,aAAaK,IAAI,CAACC,KAAK,IAAI,CAACN,aAAaK,IAAI,CAACE,QAAQ,EAAE;QAC3D,MAAM,IAAIZ,SACR,CAAC,QAAQ,EAAEM,oBAAoB,aAAa,QAAQ,CAAC,CAAC,EACtDT,WAAWgB,WAAW;IAE1B;IAEA,IAAIC,OAAOT;IAEX,IAAI;QACF,MAAMU,eAAe,MAAMb,gBAA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AU,MAAMjC,iBAAiBjB,IAAI,CAACgD,cAAc,CAACG,oBAAoB,CAAC;oBACxE5C;oBACAc;oBACAG;gBACF;YACF;YAEA,MAAMtB,MAAMkD,SAAS,CAAC;gBACpBC,MAAM,CAAC,CAAC,EAAEnD,MAAMoD,eAAe,CAAC,GAAG,EAAEpD,MAAMqD,kBAAkB,CAAC,CAAC,CAAC;gBAChEZ;gBACAO;gBACAM,IAAI3D,oBAAoB2B,KAAKtB,KAAK,GAAGD,KAAKC,KAAK;YACjD;QACF;QAEA,wCAAwC;QACxC,mCAAmC;QACnC,wCAAwC;QAExC,MAAMe,iBAAiBT,KAAK,CAACiD,mBAAmB,CAAC/C,MAAM,CAAC,OAAOC,WAAWC;YACxE,MAAMD;YACN,MAAMC,KAAK;gBAAEP;gBAAMP,YAAYO,KAAKP,UAAU,EAAEC;gBAAQc,SAASN,IAAIM,OAAO;YAAC;QAC/E,GAAGE,QAAQC,OAAO;QAElB,wCAAwC;QACxC,8BAA8B;QAC9B,wCAAwC;QAExCK,QAAQ,MAAM/B,oBAAoB;YAChCe;YACAP,YAAYO,KAAKP,UAAU,EAAEC;YAC7Be,WAAW;YACX4C,QAAQrC;QACV;QAEA,IAAIf,cAAc,MAAMd,kBAAkBe;QAE1C,OAAOc;IACT,EAAE,OAAOsC,OAAgB;QACvB,MAAMjE,gBAAgBW,KAAKE,GAAG;QAC9B,MAAMoD;IACR;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/auth/operations/forgotPassword.ts"],"sourcesContent":["import crypto from 'crypto'\nimport httpStatus from 'http-status'\nimport { URL } from 'url'\n\nimport type {\n AuthOperationsFromCollectionSlug,\n Collection,\n} from '../../collections/config/types.js'\nimport type { CollectionSlug } from '../../index.js'\nimport type { PayloadRequest, Where } from '../../types/index.js'\n\nimport { buildAfterOperation } from '../../collections/operations/utils.js'\nimport { APIError } from '../../errors/index.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\n\nexport type Arguments<TSlug extends CollectionSlug> = {\n collection: Collection\n data: {\n [key: string]: unknown\n } & AuthOperationsFromCollectionSlug<TSlug>['forgotPassword']\n disableEmail?: boolean\n expiration?: number\n req: PayloadRequest\n}\n\nexport type Result = string\n\nexport const forgotPasswordOperation = async <TSlug extends CollectionSlug>(\n incomingArgs: Arguments<TSlug>,\n): Promise<null | string> => {\n const loginWithUsername = incomingArgs.collection.config.auth.loginWithUsername\n const { data } = incomingArgs\n\n const canLoginWithUsername = Boolean(loginWithUsername)\n const canLoginWithEmail = !loginWithUsername || loginWithUsername.allowEmailLogin\n\n const sanitizedEmail =\n (canLoginWithEmail && (incomingArgs.data.email || '').toLowerCase().trim()) || null\n const sanitizedUsername =\n 'username' in data && typeof data?.username === 'string'\n ? data.username.toLowerCase().trim()\n : null\n\n if (!sanitizedEmail && !sanitizedUsername) {\n throw new APIError(\n `Missing ${loginWithUsername ? 'username' : 'email'}.`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n let args = incomingArgs\n\n try {\n const shouldCommit = await initTransaction(args.req)\n\n // /////////////////////////////////////\n // beforeOperation - Collection\n // /////////////////////////////////////\n\n await args.collection.config.hooks.beforeOperation.reduce(async (priorHook, hook) => {\n await priorHook\n\n args =\n (await hook({\n args,\n collection: args.collection?.config,\n context: args.req.context,\n operation: 'forgotPassword',\n req: args.req,\n })) || args\n }, Promise.resolve())\n\n const {\n collection: { config: collectionConfig },\n data,\n disableEmail,\n expiration,\n req: {\n payload: { config, email },\n payload,\n },\n req,\n } = args\n\n // /////////////////////////////////////\n // Forget password\n // /////////////////////////////////////\n\n let token: string = crypto.randomBytes(20).toString('hex')\n type UserDoc = {\n email?: string\n id: number | string\n resetPasswordExpiration?: string\n resetPasswordToken?: string\n }\n\n if (!sanitizedEmail && !sanitizedUsername) {\n throw new APIError(\n `Missing ${loginWithUsername ? 'username' : 'email'}.`,\n httpStatus.BAD_REQUEST,\n )\n }\n\n let whereConstraint: Where = {}\n\n if (canLoginWithEmail && sanitizedEmail) {\n whereConstraint = {\n email: {\n equals: sanitizedEmail,\n },\n }\n } else if (canLoginWithUsername && sanitizedUsername) {\n whereConstraint = {\n username: {\n equals: sanitizedUsername,\n },\n }\n }\n\n let user = await payload.db.findOne<UserDoc>({\n collection: collectionConfig.slug,\n req,\n where: whereConstraint,\n })\n\n // We don't want to indicate specifically that an email was not found,\n // as doing so could lead to the exposure of registered emails.\n // Therefore, we prefer to fail silently.\n if (!user) return null\n\n user.resetPasswordToken = token\n user.resetPasswordExpiration = new Date(expiration || Date.now() + 3600000).toISOString() // 1 hour\n\n user = await payload.update({\n id: user.id,\n collection: collectionConfig.slug,\n data: user,\n req,\n })\n\n if (!disableEmail && user.email) {\n const protocol = new URL(req.url).protocol // includes the final :\n const serverURL =\n config.serverURL !== null && config.serverURL !== ''\n ? config.serverURL\n : `${protocol}//${req.headers.get('host')}`\n\n let html = `${req.t('authentication:youAreReceivingResetPassword')}\n <a href=\"${serverURL}${config.routes.admin}/${config.admin.routes.reset}/${token}\">${serverURL}${config.routes.admin}/${config.admin.routes.reset}/${token}</a>\n ${req.t('authentication:youDidNotRequestPassword')}`\n\n if (typeof collectionConfig.auth.forgotPassword.generateEmailHTML === 'function') {\n html = await collectionConfig.auth.forgotPassword.generateEmailHTML({\n req,\n token,\n user,\n })\n }\n\n let subject = req.t('authentication:resetYourPassword')\n\n if (typeof collectionConfig.auth.forgotPassword.generateEmailSubject === 'function') {\n subject = await collectionConfig.auth.forgotPassword.generateEmailSubject({\n req,\n token,\n user,\n })\n }\n\n await email.sendEmail({\n from: `\"${email.defaultFromName}\" <${email.defaultFromAddress}>`,\n html,\n subject,\n to: user.email,\n })\n }\n\n // /////////////////////////////////////\n // afterForgotPassword - Collection\n // /////////////////////////////////////\n\n await collectionConfig.hooks.afterForgotPassword.reduce(async (priorHook, hook) => {\n await priorHook\n await hook({ args, collection: args.collection?.config, context: req.context })\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // afterOperation - Collection\n // /////////////////////////////////////\n\n token = await buildAfterOperation({\n args,\n collection: args.collection?.config,\n operation: 'forgotPassword',\n result: token,\n })\n\n if (shouldCommit) await commitTransaction(req)\n\n return token\n } catch (error: unknown) {\n await killTransaction(args.req)\n throw error\n }\n}\n"],"names":["crypto","httpStatus","URL","buildAfterOperation","APIError","commitTransaction","initTransaction","killTransaction","forgotPasswordOperation","incomingArgs","loginWithUsername","collection","config","auth","data","canLoginWithUsername","Boolean","canLoginWithEmail","allowEmailLogin","sanitizedEmail","email","toLowerCase","trim","sanitizedUsername","username","BAD_REQUEST","args","shouldCommit","req","hooks","beforeOperation","reduce","priorHook","hook","context","operation","Promise","resolve","collectionConfig","disableEmail","expiration","payload","token","randomBytes","toString","whereConstraint","equals","user","db","findOne","slug","where","resetPasswordToken","resetPasswordExpiration","Date","now","toISOString","update","id","protocol","url","serverURL","headers","get","html","t","routes","admin","reset","forgotPassword","generateEmailHTML","subject","generateEmailSubject","sendEmail","from","defaultFromName","defaultFromAddress","to","afterForgotPassword","result","error"],"mappings":"AAAA,OAAOA,YAAY,SAAQ;AAC3B,OAAOC,gBAAgB,cAAa;AACpC,SAASC,GAAG,QAAQ,MAAK;AASzB,SAASC,mBAAmB,QAAQ,wCAAuC;AAC3E,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AAcpE,OAAO,MAAMC,0BAA0B,OACrCC;IAEA,MAAMC,oBAAoBD,aAAaE,UAAU,CAACC,MAAM,CAACC,IAAI,CAACH,iBAAiB;IAC/E,MAAM,EAAEI,IAAI,EAAE,GAAGL;IAEjB,MAAMM,uBAAuBC,QAAQN;IACrC,MAAMO,oBAAoB,CAACP,qBAAqBA,kBAAkBQ,eAAe;IAEjF,MAAMC,iBACJ,AAACF,qBAAqB,AAACR,CAAAA,aA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AE,OAAOsC,OAAgB;QACvB,MAAMzE,gBAAgBmB,KAAKE,GAAG;QAC9B,MAAMoD;IACR;AACF,EAAC"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import type { CollectionSlug, Payload, RequestContext } from '../../../index.js';
|
|
1
|
+
import type { AuthOperationsFromCollectionSlug, CollectionSlug, Payload, RequestContext } from '../../../index.js';
|
|
2
2
|
import type { PayloadRequest } from '../../../types/index.js';
|
|
3
|
-
export type Options<
|
|
4
|
-
collection:
|
|
3
|
+
export type Options<TSlug extends CollectionSlug> = {
|
|
4
|
+
collection: TSlug;
|
|
5
5
|
context?: RequestContext;
|
|
6
|
-
data:
|
|
7
|
-
email: any;
|
|
8
|
-
};
|
|
6
|
+
data: AuthOperationsFromCollectionSlug<TSlug>['unlock'];
|
|
9
7
|
overrideAccess: boolean;
|
|
10
8
|
req?: PayloadRequest;
|
|
11
9
|
};
|
|
12
|
-
declare function localUnlock<
|
|
10
|
+
declare function localUnlock<TSlug extends CollectionSlug>(payload: Payload, options: Options<TSlug>): Promise<boolean>;
|
|
13
11
|
export default localUnlock;
|
|
14
12
|
//# sourceMappingURL=unlock.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlock.d.ts","sourceRoot":"","sources":["../../../../src/auth/operations/local/unlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"unlock.d.ts","sourceRoot":"","sources":["../../../../src/auth/operations/local/unlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gCAAgC,EAChC,cAAc,EACd,OAAO,EACP,cAAc,EACf,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAM7D,MAAM,MAAM,OAAO,CAAC,KAAK,SAAS,cAAc,IAAI;IAClD,UAAU,EAAE,KAAK,CAAA;IACjB,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB,IAAI,EAAE,gCAAgC,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAA;IACvD,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,CAAC,EAAE,cAAc,CAAA;CACrB,CAAA;AAED,iBAAe,WAAW,CAAC,KAAK,SAAS,cAAc,EACrD,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,GACtB,OAAO,CAAC,OAAO,CAAC,CAiBlB;AAED,eAAe,WAAW,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/auth/operations/local/unlock.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../../../src/auth/operations/local/unlock.ts"],"sourcesContent":["import type {\n AuthOperationsFromCollectionSlug,\n CollectionSlug,\n Payload,\n RequestContext,\n} from '../../../index.js'\nimport type { PayloadRequest } from '../../../types/index.js'\n\nimport { APIError } from '../../../errors/index.js'\nimport { createLocalReq } from '../../../utilities/createLocalReq.js'\nimport { unlockOperation } from '../unlock.js'\n\nexport type Options<TSlug extends CollectionSlug> = {\n collection: TSlug\n context?: RequestContext\n data: AuthOperationsFromCollectionSlug<TSlug>['unlock']\n overrideAccess: boolean\n req?: PayloadRequest\n}\n\nasync function localUnlock<TSlug extends CollectionSlug>(\n payload: Payload,\n options: Options<TSlug>,\n): Promise<boolean> {\n const { collection: collectionSlug, data, overrideAccess = true } = options\n\n const collection = payload.collections[collectionSlug]\n\n if (!collection) {\n throw new APIError(\n `The collection with slug ${String(collectionSlug)} can't be found. Unlock Operation.`,\n )\n }\n\n return unlockOperation<TSlug>({\n collection,\n data,\n overrideAccess,\n req: await createLocalReq(options, payload),\n })\n}\n\nexport default localUnlock\n"],"names":["APIError","createLocalReq","unlockOperation","localUnlock","payload","options","collection","collectionSlug","data","overrideAccess","collections","String","req"],"mappings":"AAQA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,eAAe,QAAQ,eAAc;AAU9C,eAAeC,YACbC,OAAgB,EAChBC,OAAuB;IAEvB,MAAM,EAAEC,YAAYC,cAAc,EAAEC,IAAI,EAAEC,iBAAiB,IAAI,EAAE,GAAGJ;IAEpE,MAAMC,aAAaF,QAAQM,WAAW,CAACH,eAAe;IAEtD,IAAI,CAACD,YAAY;QACf,MAAM,IAAIN,SACR,CAAC,yBAAyB,EAAEW,OAAOJ,gBAAgB,kCAAkC,CAAC;IAE1F;IAEA,OAAOL,gBAAuB;QAC5BI;QACAE;QACAC;QACAG,KAAK,MAAMX,eAAeI,SAASD;IACrC;AACF;AAEA,eAAeD,YAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/login.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gCAAgC,EAChC,UAAU,EACV,sBAAsB,EACvB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/auth/operations/login.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gCAAgC,EAChC,UAAU,EACV,sBAAsB,EACvB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,cAAc,EAAS,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAevC,MAAM,MAAM,MAAM,GAAG;IACnB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,IAAI,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,SAAS,CAAC,KAAK,SAAS,cAAc,IAAI;IACpD,UAAU,EAAE,UAAU,CAAA;IACtB,IAAI,EAAE,gCAAgC,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAA;IACtD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,EAAE,cAAc,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,cAAc,GAAU,KAAK,SAAS,cAAc,gBACjD,SAAS,CAAC,KAAK,CAAC,KAC7B,OAAO,CAAC;IAAE,IAAI,EAAE,sBAAsB,CAAC,KAAK,CAAC,CAAA;CAAE,GAAG,MAAM,CA4S1D,CAAA"}
|