storemw-core-api 1.0.155 → 1.0.157

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.
@@ -8,12 +8,14 @@ exports.ResetPasswordHook = {
8
8
  // default
9
9
  const oneTimeCodeType = "otp";
10
10
  const resetPasswordMethod = "email";
11
+ const expiresInMinutes = 15;
11
12
  // testing only
12
13
  // const oneTimeCodeType: OneTimeCodeType = "token";
13
14
  // const resetPasswordMethod: ResetPasswordMethod = "sms";
14
15
  return {
15
16
  oneTimeCodeType,
16
- resetPasswordMethod
17
+ resetPasswordMethod,
18
+ expiresInMinutes
17
19
  };
18
20
  },
19
21
  onRequest: async (props) => {
@@ -1 +1 @@
1
- {"version":3,"file":"resetPasswordRegistry.js","sourceRoot":"","sources":["../../../src/features/reset_password/resetPasswordRegistry.ts"],"names":[],"mappings":";;;AAGA,mCAAoC;AAEpC,oCAAoC;AACvB,QAAA,iBAAiB,GAA8B;IACxD,OAAO,EAAE,GAAG,EAAE;QAEV,UAAU;QACV,MAAM,eAAe,GAAoB,KAAK,CAAC;QAC/C,MAAM,mBAAmB,GAAwB,OAAO,CAAC;QAEzD,eAAe;QACf,oDAAoD;QACpD,0DAA0D;QAE1D,OAAO;YACH,eAAe;YACf,mBAAmB;SACtB,CAAA;IAEL,CAAC;IACD,SAAS,EAAE,KAAK,EAAE,KAAuC,EAAE,EAAE;QACzD,6BAA6B;QAC7B,uFAAuF;QACvF,IAAA,kBAAU,EAAC,sDAAsD,CAAC,CAAA;IACtE,CAAC;IACD,SAAS,EAAE,KAAK,EAAE,KAAuC,EAAE,EAAE;QACzD,wBAAwB;QACxB,oFAAoF;QACpF,IAAA,kBAAU,EAAC,sDAAsD,CAAC,CAAA;IACtE,CAAC;CACJ,CAAA","sourcesContent":["import { FeatureResetPasswordProps, FeatureResetPasswordSuccessProps, FeatureResetPasswordRequestProps } from './resetPasswordType'\nimport { OneTimeCodeType, ResetPasswordMethod } from \"../../services\";\n\nimport { throwError } from '@/utils'\n\n// Runtime storage for injected hook\nexport const ResetPasswordHook: FeatureResetPasswordProps = {\n onSetup: () => {\n\n // default\n const oneTimeCodeType: OneTimeCodeType = \"otp\";\n const resetPasswordMethod: ResetPasswordMethod = \"email\";\n\n // testing only\n // const oneTimeCodeType: OneTimeCodeType = \"token\";\n // const resetPasswordMethod: ResetPasswordMethod = \"sms\";\n\n return {\n oneTimeCodeType,\n resetPasswordMethod\n }\n\n },\n onRequest: async (props: FeatureResetPasswordRequestProps) => {\n // Default behavior: just log\n // console.log(`[ResetPasswordService] Default onRequest called for ${JSON.stringify}`)\n throwError(`Invalid settings for onRequest in ResetPasswordHooks`)\n },\n onSuccess: async (props: FeatureResetPasswordSuccessProps) => {\n // Default behavior: log\n // console.log(`[ResetPasswordService] Default onSuccess called for user ${userId}`)\n throwError(`Invalid settings for onSuccess in ResetPasswordHooks`)\n }\n}"]}
1
+ {"version":3,"file":"resetPasswordRegistry.js","sourceRoot":"","sources":["../../../src/features/reset_password/resetPasswordRegistry.ts"],"names":[],"mappings":";;;AAGA,mCAAoC;AAEpC,oCAAoC;AACvB,QAAA,iBAAiB,GAA8B;IACxD,OAAO,EAAE,GAAG,EAAE;QAEV,UAAU;QACV,MAAM,eAAe,GAAoB,KAAK,CAAC;QAC/C,MAAM,mBAAmB,GAAwB,OAAO,CAAC;QACzD,MAAM,gBAAgB,GAAW,EAAE,CAAC;QAEpC,eAAe;QACf,oDAAoD;QACpD,0DAA0D;QAE1D,OAAO;YACH,eAAe;YACf,mBAAmB;YACnB,gBAAgB;SACnB,CAAA;IAEL,CAAC;IACD,SAAS,EAAE,KAAK,EAAE,KAAuC,EAAE,EAAE;QACzD,6BAA6B;QAC7B,uFAAuF;QACvF,IAAA,kBAAU,EAAC,sDAAsD,CAAC,CAAA;IACtE,CAAC;IACD,SAAS,EAAE,KAAK,EAAE,KAAuC,EAAE,EAAE;QACzD,wBAAwB;QACxB,oFAAoF;QACpF,IAAA,kBAAU,EAAC,sDAAsD,CAAC,CAAA;IACtE,CAAC;CACJ,CAAA","sourcesContent":["import { FeatureResetPasswordProps, FeatureResetPasswordSuccessProps, FeatureResetPasswordRequestProps } from './resetPasswordType'\nimport { OneTimeCodeType, ResetPasswordMethod } from \"../../services\";\n\nimport { throwError } from '@/utils'\n\n// Runtime storage for injected hook\nexport const ResetPasswordHook: FeatureResetPasswordProps = {\n onSetup: () => {\n\n // default\n const oneTimeCodeType: OneTimeCodeType = \"otp\";\n const resetPasswordMethod: ResetPasswordMethod = \"email\";\n const expiresInMinutes: Number = 15;\n\n // testing only\n // const oneTimeCodeType: OneTimeCodeType = \"token\";\n // const resetPasswordMethod: ResetPasswordMethod = \"sms\";\n\n return {\n oneTimeCodeType,\n resetPasswordMethod,\n expiresInMinutes\n }\n\n },\n onRequest: async (props: FeatureResetPasswordRequestProps) => {\n // Default behavior: just log\n // console.log(`[ResetPasswordService] Default onRequest called for ${JSON.stringify}`)\n throwError(`Invalid settings for onRequest in ResetPasswordHooks`)\n },\n onSuccess: async (props: FeatureResetPasswordSuccessProps) => {\n // Default behavior: log\n // console.log(`[ResetPasswordService] Default onSuccess called for user ${userId}`)\n throwError(`Invalid settings for onSuccess in ResetPasswordHooks`)\n }\n}"]}
@@ -20,6 +20,7 @@ export type FeatureResetPasswordProps = {
20
20
  onSetup: () => {
21
21
  oneTimeCodeType: OneTimeCodeType;
22
22
  resetPasswordMethod: ResetPasswordMethod;
23
+ expiresInMinutes?: Number;
23
24
  };
24
25
  onRequest: (props: FeatureResetPasswordRequestProps) => Promise<any>;
25
26
  onSuccess: (props: FeatureResetPasswordSuccessProps) => Promise<any>;
@@ -1 +1 @@
1
- {"version":3,"file":"resetPasswordType.js","sourceRoot":"","sources":["../../../src/features/reset_password/resetPasswordType.ts"],"names":[],"mappings":"","sourcesContent":["import { OneTimeCodeType, ResetPasswordMethod } from \"../../services\";\n\nimport { FeatureCallbackProps } from \"@/utils\"\n\nexport type FeatureResetPasswordRequestProps = FeatureCallbackProps<{\n userId: number\n userType: string\n resetPasswordMethod: ResetPasswordMethod,\n emailAddress: string\n mobileNumber: string\n oneTimeCode: string\n user: any\n}>\n\nexport type FeatureResetPasswordSuccessProps = FeatureCallbackProps<{\n userId: number\n userType: string\n resetPasswordMethod: ResetPasswordMethod\n oneTimeCode: string\n user: any\n}>\n\nexport type FeatureResetPasswordProps = {\n onSetup: () => {\n oneTimeCodeType: OneTimeCodeType;\n resetPasswordMethod: ResetPasswordMethod;\n },\n onRequest: (props: FeatureResetPasswordRequestProps) => Promise<any>\n onSuccess: (props: FeatureResetPasswordSuccessProps) => Promise<any>\n}"]}
1
+ {"version":3,"file":"resetPasswordType.js","sourceRoot":"","sources":["../../../src/features/reset_password/resetPasswordType.ts"],"names":[],"mappings":"","sourcesContent":["import { OneTimeCodeType, ResetPasswordMethod } from \"../../services\";\n\nimport { FeatureCallbackProps } from \"@/utils\"\n\nexport type FeatureResetPasswordRequestProps = FeatureCallbackProps<{\n userId: number\n userType: string\n resetPasswordMethod: ResetPasswordMethod,\n emailAddress: string\n mobileNumber: string\n oneTimeCode: string\n user: any\n}>\n\nexport type FeatureResetPasswordSuccessProps = FeatureCallbackProps<{\n userId: number\n userType: string\n resetPasswordMethod: ResetPasswordMethod\n oneTimeCode: string\n user: any\n}>\n\nexport type FeatureResetPasswordProps = {\n onSetup: () => {\n oneTimeCodeType: OneTimeCodeType;\n resetPasswordMethod: ResetPasswordMethod;\n expiresInMinutes?: Number\n },\n onRequest: (props: FeatureResetPasswordRequestProps) => Promise<any>\n onSuccess: (props: FeatureResetPasswordSuccessProps) => Promise<any>\n}"]}
@@ -1,23 +1,23 @@
1
1
  export type DefaultOmitFields = "createdatetime" | "createuserid" | "updatedatetime" | "updateuserid" | "isdelete" | "istrash" | "accountid";
2
2
  export declare const getDefaultCreateFields: (createUserId: number, accountId: number) => {
3
- createuserid: number;
3
+ createuserid: string | number;
4
4
  createdatetime: string;
5
- updateuserid: number;
5
+ updateuserid: string | number;
6
6
  updatedatetime: string;
7
7
  accountid: number;
8
8
  };
9
9
  export declare const getDefaultUpdateFields: (updateUserId: number) => {
10
- updateuserid: number;
10
+ updateuserid: string | number;
11
11
  updatedatetime: string;
12
12
  };
13
13
  export declare const getDefaultTrashFields: (updateUserId: number) => {
14
14
  istrash: boolean;
15
- updateuserid: number;
15
+ updateuserid: string | number;
16
16
  updatedatetime: string;
17
17
  };
18
18
  export declare const getDefaultRemoveFields: (updateUserId: number) => {
19
19
  isdelete: boolean;
20
- updateuserid: number;
20
+ updateuserid: string | number;
21
21
  updatedatetime: string;
22
22
  };
23
23
  export declare const getDefaultGetWhere: {
@@ -2,13 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.errorRecordNotFoundAfterRemoved = exports.errorRecordNotFoundAfterTrashed = exports.errorRecordNotFoundAfterUpdated = exports.errorRecordNotFoundAlreadyDeleted = exports.getDefaultRemoveWhere = exports.getDefaultTrashWhere = exports.getDefaultUpdateWhere = exports.getDefaultGetWhere = exports.getDefaultRemoveFields = exports.getDefaultTrashFields = exports.getDefaultUpdateFields = exports.getDefaultCreateFields = void 0;
4
4
  const utils_1 = require("../../utils");
5
+ const forceToZeroIfEmpty = (val) => {
6
+ return val === "" ? 0 : "";
7
+ };
5
8
  // insert into create - data fields
6
9
  const getDefaultCreateFields = (createUserId, accountId) => {
7
10
  const currentDatetimeISO = (0, utils_1.getCurrentDateTimeISO)();
8
11
  return {
9
- createuserid: createUserId,
12
+ createuserid: forceToZeroIfEmpty(createUserId),
10
13
  createdatetime: currentDatetimeISO,
11
- updateuserid: createUserId,
14
+ updateuserid: forceToZeroIfEmpty(createUserId),
12
15
  updatedatetime: currentDatetimeISO,
13
16
  accountid: accountId
14
17
  };
@@ -18,7 +21,7 @@ exports.getDefaultCreateFields = getDefaultCreateFields;
18
21
  const getDefaultUpdateFields = (updateUserId) => {
19
22
  const currentDatetimeISO = (0, utils_1.getCurrentDateTimeISO)();
20
23
  return {
21
- updateuserid: updateUserId,
24
+ updateuserid: forceToZeroIfEmpty(updateUserId),
22
25
  updatedatetime: currentDatetimeISO,
23
26
  };
24
27
  };
@@ -28,7 +31,7 @@ const getDefaultTrashFields = (updateUserId) => {
28
31
  const currentDatetimeISO = (0, utils_1.getCurrentDateTimeISO)();
29
32
  return {
30
33
  istrash: true,
31
- updateuserid: updateUserId,
34
+ updateuserid: forceToZeroIfEmpty(updateUserId),
32
35
  updatedatetime: currentDatetimeISO,
33
36
  };
34
37
  };
@@ -38,7 +41,7 @@ const getDefaultRemoveFields = (updateUserId) => {
38
41
  const currentDatetimeISO = (0, utils_1.getCurrentDateTimeISO)();
39
42
  return {
40
43
  isdelete: true,
41
- updateuserid: updateUserId,
44
+ updateuserid: forceToZeroIfEmpty(updateUserId),
42
45
  updatedatetime: currentDatetimeISO,
43
46
  };
44
47
  };
@@ -1 +1 @@
1
- {"version":3,"file":"default.js","sourceRoot":"","sources":["../../../src/lib/model_factory/default.ts"],"names":[],"mappings":";;;AAAA,mCAA+C;AAK/C,mCAAmC;AAC5B,MAAM,sBAAsB,GAAG,CAAC,YAAoB,EAAE,SAAiB,EAAE,EAAE;IAE9E,MAAM,kBAAkB,GAAG,IAAA,6BAAqB,GAAE,CAAA;IAElD,OAAO;QACH,YAAY,EAAE,YAAY;QAC1B,cAAc,EAAE,kBAAkB;QAClC,YAAY,EAAE,YAAY;QAC1B,cAAc,EAAE,kBAAkB;QAClC,SAAS,EAAE,SAAS;KACvB,CAAA;AACL,CAAC,CAAA;AAXY,QAAA,sBAAsB,0BAWlC;AAED,mCAAmC;AAC5B,MAAM,sBAAsB,GAAG,CAAC,YAAoB,EAAE,EAAE;IAE3D,MAAM,kBAAkB,GAAG,IAAA,6BAAqB,GAAE,CAAA;IAElD,OAAO;QACH,YAAY,EAAE,YAAY;QAC1B,cAAc,EAAE,kBAAkB;KACrC,CAAA;AACL,CAAC,CAAA;AARY,QAAA,sBAAsB,0BAQlC;AAED,kCAAkC;AAC3B,MAAM,qBAAqB,GAAG,CAAC,YAAoB,EAAE,EAAE;IAE1D,MAAM,kBAAkB,GAAG,IAAA,6BAAqB,GAAE,CAAA;IAElD,OAAO;QACH,OAAO,EAAE,IAAI;QACb,YAAY,EAAE,YAAY;QAC1B,cAAc,EAAE,kBAAkB;KACrC,CAAA;AACL,CAAC,CAAA;AATY,QAAA,qBAAqB,yBASjC;AAED,mCAAmC;AAC5B,MAAM,sBAAsB,GAAG,CAAC,YAAoB,EAAE,EAAE;IAE3D,MAAM,kBAAkB,GAAG,IAAA,6BAAqB,GAAE,CAAA;IAElD,OAAO;QACH,QAAQ,EAAE,IAAI;QACd,YAAY,EAAE,YAAY;QAC1B,cAAc,EAAE,kBAAkB;KACrC,CAAA;AACL,CAAC,CAAA;AATY,QAAA,sBAAsB,0BASlC;AAED,yCAAyC;AAC5B,QAAA,kBAAkB,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAA;AAErD,4CAA4C;AAC/B,QAAA,qBAAqB,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;AAExE,2CAA2C;AAC9B,QAAA,oBAAoB,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;AAEvE,4CAA4C;AAC/B,QAAA,qBAAqB,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;AAE3D,QAAA,iCAAiC,GAAG,qCAAqC,CAAA;AACzE,QAAA,+BAA+B,GAAG,+BAA+B,CAAA;AACjE,QAAA,+BAA+B,GAAG,8BAA8B,CAAA;AAChE,QAAA,+BAA+B,GAAG,+BAA+B,CAAA","sourcesContent":["import { getCurrentDateTimeISO } from \"@/utils\"\n\nexport type DefaultOmitFields = \"createdatetime\" | \"createuserid\" |\n \"updatedatetime\" | \"updateuserid\" | \"isdelete\" | \"istrash\" | \"accountid\"\n\n// insert into create - data fields\nexport const getDefaultCreateFields = (createUserId: number, accountId: number) => {\n\n const currentDatetimeISO = getCurrentDateTimeISO()\n\n return {\n createuserid: createUserId,\n createdatetime: currentDatetimeISO,\n updateuserid: createUserId,\n updatedatetime: currentDatetimeISO,\n accountid: accountId\n }\n}\n\n// insert into update - data fields\nexport const getDefaultUpdateFields = (updateUserId: number) => {\n\n const currentDatetimeISO = getCurrentDateTimeISO()\n\n return {\n updateuserid: updateUserId,\n updatedatetime: currentDatetimeISO,\n }\n}\n\n// insert into trash - data fields\nexport const getDefaultTrashFields = (updateUserId: number) => {\n\n const currentDatetimeISO = getCurrentDateTimeISO()\n\n return {\n istrash: true,\n updateuserid: updateUserId,\n updatedatetime: currentDatetimeISO,\n }\n}\n\n// insert into remove - data fields\nexport const getDefaultRemoveFields = (updateUserId: number) => {\n\n const currentDatetimeISO = getCurrentDateTimeISO()\n\n return {\n isdelete: true,\n updateuserid: updateUserId,\n updatedatetime: currentDatetimeISO,\n }\n}\n\n// insert into the get - where conditions\nexport const getDefaultGetWhere = { isdelete: false }\n\n// insert into the update - where conditions\nexport const getDefaultUpdateWhere = { isdelete: false, istrash: false }\n\n// insert into the trash - where conditions\nexport const getDefaultTrashWhere = { isdelete: false, istrash: false }\n\n// insert into the remove - where conditions\nexport const getDefaultRemoveWhere = { isdelete: false, istrash: false }\n\nexport const errorRecordNotFoundAlreadyDeleted = `Record not found or already deleted`\nexport const errorRecordNotFoundAfterUpdated = `Record not found after update`\nexport const errorRecordNotFoundAfterTrashed = `Record not found after trash`\nexport const errorRecordNotFoundAfterRemoved = `Record not found after remove`"]}
1
+ {"version":3,"file":"default.js","sourceRoot":"","sources":["../../../src/lib/model_factory/default.ts"],"names":[],"mappings":";;;AAAA,mCAA+C;AAK/C,MAAM,kBAAkB,GAAG,CAAC,GAAQ,EAAE,EAAE;IACpC,OAAO,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC/B,CAAC,CAAA;AAED,mCAAmC;AAC5B,MAAM,sBAAsB,GAAG,CAAC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,4CAA4C;AAC/B,QAAA,qBAAqB,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;AAExE,2CAA2C;AAC9B,QAAA,oBAAoB,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;AAEvE,4CAA4C;AAC/B,QAAA,qBAAqB,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;AAE3D,QAAA,iCAAiC,GAAG,qCAAqC,CAAA;AACzE,QAAA,+BAA+B,GAAG,+BAA+B,CAAA;AACjE,QAAA,+BAA+B,GAAG,8BAA8B,CAAA;AAChE,QAAA,+BAA+B,GAAG,+BAA+B,CAAA","sourcesContent":["import { getCurrentDateTimeISO } from \"@/utils\"\n\nexport type DefaultOmitFields = \"createdatetime\" | \"createuserid\" |\n \"updatedatetime\" | \"updateuserid\" | \"isdelete\" | \"istrash\" | \"accountid\"\n\nconst forceToZeroIfEmpty = (val: any) => {\n return val === \"\" ? 0 : \"\";\n}\n\n// insert into create - data fields\nexport const getDefaultCreateFields = (createUserId: number, accountId: number) => {\n\n const currentDatetimeISO = getCurrentDateTimeISO()\n\n return {\n createuserid: forceToZeroIfEmpty(createUserId),\n createdatetime: currentDatetimeISO,\n updateuserid: forceToZeroIfEmpty(createUserId),\n updatedatetime: currentDatetimeISO,\n accountid: accountId\n }\n}\n\n// insert into update - data fields\nexport const getDefaultUpdateFields = (updateUserId: number) => {\n\n const currentDatetimeISO = getCurrentDateTimeISO()\n\n return {\n updateuserid: forceToZeroIfEmpty(updateUserId),\n updatedatetime: currentDatetimeISO,\n }\n}\n\n// insert into trash - data fields\nexport const getDefaultTrashFields = (updateUserId: number) => {\n\n const currentDatetimeISO = getCurrentDateTimeISO()\n\n return {\n istrash: true,\n updateuserid: forceToZeroIfEmpty(updateUserId),\n updatedatetime: currentDatetimeISO,\n }\n}\n\n// insert into remove - data fields\nexport const getDefaultRemoveFields = (updateUserId: number) => {\n\n const currentDatetimeISO = getCurrentDateTimeISO()\n\n return {\n isdelete: true,\n updateuserid: forceToZeroIfEmpty(updateUserId),\n updatedatetime: currentDatetimeISO,\n }\n}\n\n// insert into the get - where conditions\nexport const getDefaultGetWhere = { isdelete: false }\n\n// insert into the update - where conditions\nexport const getDefaultUpdateWhere = { isdelete: false, istrash: false }\n\n// insert into the trash - where conditions\nexport const getDefaultTrashWhere = { isdelete: false, istrash: false }\n\n// insert into the remove - where conditions\nexport const getDefaultRemoveWhere = { isdelete: false, istrash: false }\n\nexport const errorRecordNotFoundAlreadyDeleted = `Record not found or already deleted`\nexport const errorRecordNotFoundAfterUpdated = `Record not found after update`\nexport const errorRecordNotFoundAfterTrashed = `Record not found after trash`\nexport const errorRecordNotFoundAfterRemoved = `Record not found after remove`"]}
@@ -239,7 +239,10 @@ const ResetPasswordService = (props) => {
239
239
  emailAddress,
240
240
  mobileNumber,
241
241
  userId,
242
- userType
242
+ userType,
243
+ ...(hookSetup?.expiresInMinutes ? {
244
+ expiredAt: (0, utils_2.dayjs)().add(Number(hookSetup.expiresInMinutes), "minute").toDate() // convert to JS Date
245
+ } : {})
243
246
  }
244
247
  };
245
248
  // generate the code
@@ -1 +1 @@
1
- {"version":3,"file":"ResetPasswordService.js","sourceRoot":"","sources":["../../../src/services/reset_password/ResetPasswordService.ts"],"names":[],"mappings":";;;AAAA,mCAA6I;AAE7I,yDAAyD;AAEzD,oIAAoI;AAEpI,mCAAgC;AAEhC,qCAAuF;AACvF,yCAAmL;AAEnL,yCAA8C;AAEjC,QAAA,oBAAoB,GAAG;IAChC,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,KAAK;IACV,QAAQ,EAAE,UAAU;CACd,CAAA;AAiCH,MAAM,oBAAoB,GAAG,CAAC,KAAgC,EAAE,EAAE;IAErE,MAAM,EACF,GAAG,IAAI,EACV,GAAG,KAAK,CAAA;IAET,MAAM,oBAAoB,GAAG,IAAA,yBAAc,EAAC,EA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AW,EAAE,gBAAgB;gBAC7B,MAAM;gBACN,QAAQ;aACX;SACJ,CAAC,CAAA;QAEF,2BAA2B;QAC3B,IAAI,iBAAiB,GAAG,MAAM,WAAW,CAAC,eAAe,CAAC;YACtD,EAAE,EAAE,MAAM;YACV,IAAI,EAAE;gBACF,mBAAmB,EAAE,WAAW;aACnC;YACD,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC;SAClC,CAAC,CAAA;QAEF,wCAAwC;QACxC,IAAI,4BAAiB,CAAC,SAAS,EAAE,CAAC;YAE9B,MAAM,kBAAkB,GAAG,MAAM,4BAAiB,CAAC,SAAS,CAAC,IAAA,iCAAyB,EAAC;gBACnF,mBAAmB,EAAE,IAAI;gBACzB,cAAc,EAAE;oBACZ,MAAM;oBACN,QAAQ;oBACR,mBAAmB;oBACnB,WAAW;oBACX,IAAI;iBACP;aACJ,CAAC,CAAC,CAAA;YAEH,iBAAiB,GAAG,EAAE,GAAG,iBAAiB,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAA;QAE5E,CAAC;QAED,OAAO;YACH,GAAG,iBAAiB;YACpB,kBAAkB,EAAE,eAAe;SACtC,CAAA;IACL,CAAC,CAAA;IAED,OAAO;QACH,oBAAoB;QACpB,yBAAyB;QACzB,oBAAoB;KACvB,CAAA;AAEL,CAAC,CAAA;AA5hBY,QAAA,oBAAoB,wBA4hBhC","sourcesContent":["import { DefaultServiceProps, validateFormatEmailAddress, validateFormatMobileNumber, throwError, buildFeatureCallbackProps } from \"@/utils\";\n\n// import { QueryList, QueryGet } from \"@/schema/common\";\n\n// import { buildSqlRelation, buildSqlRawSelect, buildSqlWhere, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy } from \"@/lib\";\n\nimport { dayjs } from \"@/utils\";\n\nimport { ModelAccountFields, ModelOneTimeCodeFields, ModelUserFields } from \"@/models\";\nimport { UserService, AccountService, OneTimeCodeService, OneTimeCodeType, OneTimeCodeCreateProps, oneTimeCodeStatus, oneTimeCodePurposeTypes, AccountListProps } from \"@/services\"\n\nimport { ResetPasswordHook } from \"@/features\"\n\nexport const resetPasswordMethods = {\n email: \"email\",\n sms: \"sms\",\n whatapps: \"whatapps\",\n} as const\n\nexport type ResetPasswordMethod = typeof resetPasswordMethods[keyof typeof resetPasswordMethods]\n\nexport type ResetPasswordServiceProps = DefaultServiceProps & {\n};\n\ntype defaultResetPasswordProps = {\n isOperator: boolean\n accountId: string\n accountCode: string\n}\n\nexport type ResetPasswordRequestProps = {\n data: defaultResetPasswordProps & {\n emailAddress?: string\n mobileNumber?: string\n }\n}\n\nexport type ResetPasswordValidateCodeProps = {\n data: defaultResetPasswordProps & {\n oneTimeCode: string\n }\n}\n\nexport type ResetPasswordPerformProps = {\n data: defaultResetPasswordProps & {\n oneTimeCode: string\n newPassword: string\n }\n}\n\nexport const ResetPasswordService = (props: ResetPasswordServiceProps) => {\n\n const {\n ...rest\n } = props\n\n const globalAccountService = AccountService({ ...rest, isOperator: true })\n\n const validateAccount = async ({ accountId, accountCode }: {\n accountId: string,\n accountCode: string\n }) => {\n\n if (!accountId && !accountCode) {\n throwError(`AccountId or AccountCode is required`)\n }\n\n let filters: AccountListProps[\"filters\"] = []\n\n if (accountId !== \"\") {\n filters = [{\n field: `${ModelAccountFields.account_id}`,\n operator: \"=\",\n value: `${accountId}`\n }]\n }\n\n if (accountCode !== \"\") {\n filters = [{\n field: `${ModelAccountFields.account_code}`,\n operator: \"=\",\n value: `${accountCode}`\n }]\n }\n\n const { data: dataAccounts } = await globalAccountService.listAccounts({\n limit: 1,\n offset: 0,\n filters,\n sortfield: `${ModelAccountFields.account_id}`,\n sortorder: \"ASC\",\n datatypes: []\n })\n\n const dataAccount = dataAccounts.length > 0 ? dataAccounts[0] : {}\n\n if (!dataAccount?.account_id) {\n throwError(`Unable to retrieve account`)\n }\n\n return {\n accountId: dataAccount?.account_id ?? \"\",\n accountCode: dataAccount?.account_code ?? \"\"\n }\n\n }\n\n // get the user by email (non operator)\n const getUserByEmailNonOperator = async (\n accountId: ResetPasswordRequestProps[\"data\"][\"accountId\"],\n emailAddress: ResetPasswordRequestProps[\"data\"][\"emailAddress\"]\n ) => {\n\n const globalUserService = UserService({\n ...rest,\n accountId: Number(accountId), // need to override the account id,\n isOperator: false,\n userType: \"administrator\"\n })\n\n // get the user by email\n let { data: dataUser } = await globalUserService.listUsers({\n limit: 1,\n offset: 0,\n filters: [\n {\n field: `${ModelUserFields.email}`,\n operator: \"=\",\n value: `${emailAddress}`\n }\n ],\n sortfield: `${ModelUserFields.user_id}`,\n sortorder: \"ASC\",\n includePassword: false,\n skipFilterUserType: true,\n datatypes: []\n })\n\n return dataUser.length > 0 ? dataUser[0] : {}\n }\n\n // get the user by email (operator)\n const getUserByEmailOperator = async (\n emailAddress: ResetPasswordRequestProps[\"data\"][\"emailAddress\"]\n ) => {\n\n const globalUserService = UserService({\n ...rest,\n accountId: 0, // not important\n isOperator: true,\n userType: \"operator\"\n })\n\n // get the user by email\n let { data: dataUser } = await globalUserService.listUsers({\n limit: 1,\n offset: 0,\n filters: [\n {\n field: `${ModelUserFields.email}`,\n operator: \"=\",\n value: `${emailAddress}`\n },\n {\n field: `${ModelUserFields.user_type}`,\n operator: \"=\",\n value: `operator`\n }\n ],\n sortfield: `${ModelUserFields.user_id}`,\n sortorder: \"ASC\",\n includePassword: false,\n // skipFilterUserType: true,\n datatypes: []\n })\n\n return dataUser.length > 0 ? dataUser[0] : {}\n }\n\n // get the user by mobile (non operator)\n const getUserByMobileNonOperator = async (\n accountId: ResetPasswordRequestProps[\"data\"][\"accountId\"],\n mobileNumber: ResetPasswordRequestProps[\"data\"][\"mobileNumber\"]\n ) => {\n\n const globalUserService = UserService({\n ...rest,\n accountId: Number(accountId), // need to override the account id,\n isOperator: false,\n userType: \"administrator\"\n })\n\n // get the user by contact\n let { data: dataUser } = await globalUserService.listUsers({\n limit: 1,\n offset: 0,\n filters: [\n {\n field: `contact`,\n operator: \"=\",\n value: `${mobileNumber}`\n }\n ],\n sortfield: `${ModelUserFields.user_id}`,\n sortorder: \"ASC\",\n includePassword: false,\n skipFilterUserType: true,\n datatypes: []\n })\n\n return dataUser.length > 0 ? dataUser[0] : {}\n\n }\n\n // get the user by mobile (operator)\n const getUserByMobileOperator = async (\n mobileNumber: ResetPasswordRequestProps[\"data\"][\"mobileNumber\"]\n ) => {\n\n const globalUserService = UserService({\n ...rest,\n accountId: 0, // not important\n isOperator: true,\n userType: \"operator\"\n })\n\n // get the user by contact\n let { data: dataUser } = await globalUserService.listUsers({\n limit: 1,\n offset: 0,\n filters: [\n {\n field: `contact`,\n operator: \"=\",\n value: `${mobileNumber}`\n },\n {\n field: `${ModelUserFields.user_type}`,\n operator: \"=\",\n value: `operator`\n }\n ],\n sortfield: `${ModelUserFields.user_id}`,\n sortorder: \"ASC\",\n includePassword: false,\n skipFilterUserType: true,\n datatypes: []\n })\n\n return dataUser.length > 0 ? dataUser[0] : {}\n\n }\n\n const requestResetPassword = async ({ data }: ResetPasswordRequestProps) => {\n\n const isOperator = Boolean(data.isOperator) // check if reset password for operator user or other users(account related)\n const accountId = data.accountId ?? \"\"\n const accountCode = data.accountCode ?? \"\"\n\n let validatedAccountId = ``\n\n // only non operator will check the account\n if (isOperator === false) {\n let acc = await validateAccount({ accountCode, accountId })\n validatedAccountId = acc.accountId\n }\n\n // get the onSetup from hook\n const hookSetup = ResetPasswordHook.onSetup()\n\n const codeType: OneTimeCodeType = hookSetup.oneTimeCodeType\n const resetPasswordMethod: ResetPasswordMethod = hookSetup.resetPasswordMethod\n const emailAddress = data?.emailAddress ?? \"\"\n const mobileNumber = data?.mobileNumber ?? \"\"\n\n let user: any = {}\n\n const oneTimeCodeService = OneTimeCodeService({\n ...rest,\n accountId: isOperator ? 0 : Number(validatedAccountId),\n isOperator,\n field_ref: \"user\",\n field_module: \"administrator\"\n })\n\n if (!resetPasswordMethod) {\n throw new Error(`Invalid reset password method: ${hookSetup?.resetPasswordMethod ?? \"\"}`);\n }\n\n if (resetPasswordMethod === \"email\") {\n if (validateFormatEmailAddress(emailAddress) === false) {\n throw new Error(`Invalid email address: ${emailAddress}`);\n }\n\n // get the user by email\n user = isOperator ?\n await getUserByEmailOperator(emailAddress)\n :\n await getUserByEmailNonOperator(validatedAccountId, emailAddress)\n\n }\n\n if (resetPasswordMethod === \"sms\" || resetPasswordMethod === \"whatapps\") {\n if (validateFormatMobileNumber(mobileNumber) === false) {\n throw new Error(`Invalid mobile number: ${mobileNumber}`);\n }\n\n // get the user by email\n user = isOperator ?\n await getUserByMobileOperator(mobileNumber)\n :\n await getUserByMobileNonOperator(validatedAccountId, mobileNumber)\n\n }\n\n if (emailAddress === \"\" && mobileNumber === \"\") {\n throw new Error(`Either email address or mobile number is required`);\n }\n\n // verify the user\n if (!user?.user_id) {\n throw new Error(`Cannot find the user by ${resetPasswordMethod}: ${emailAddress ? emailAddress : mobileNumber}`);\n }\n\n // verify the user active\n if (Boolean(user?.status) === false) {\n throw new Error(`User is invalid status: ${user?.user_id ?? 0}`);\n }\n\n const userId = Number(user?.user_id ?? 0)\n const userType = user?.user_type ?? \"\"\n\n const codePayload: OneTimeCodeCreateProps = {\n field_ref: \"user\",\n field_module: userType,\n data: {\n purposeType: \"reset_password\",\n codeType,\n emailAddress,\n mobileNumber,\n userId,\n userType\n }\n }\n\n // generate the code \n const oneTimeCode = await oneTimeCodeService.createOneTimeCode(codePayload)\n\n // console.log('oneTimeCode', oneTimeCode)\n\n let responseOneTimeCode = await oneTimeCodeService.getOneTimeCode({ id: Number(oneTimeCode?.one_time_code_id ?? 0), datatypes: [] })\n\n // Call the consumer hook, if registered\n if (ResetPasswordHook.onRequest) {\n\n const responseCustomHook = await ResetPasswordHook.onRequest(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n userId,\n userType,\n resetPasswordMethod,\n emailAddress,\n mobileNumber,\n oneTimeCode: oneTimeCode?.code ?? \"\",\n user\n }\n }))\n\n responseOneTimeCode = { ...responseOneTimeCode, custom: responseCustomHook }\n\n }\n\n return responseOneTimeCode\n }\n\n const validateResetPasscodeCode = async ({ data }: ResetPasswordValidateCodeProps) => {\n\n const isOperator = Boolean(data.isOperator) // check if reset password for operator user or other users(account related)\n const accountId = data.accountId ?? \"\"\n const accountCode = data.accountCode ?? \"\"\n\n let validatedAccountId = ``\n\n // only non operator will check the account\n if (isOperator === false) {\n let acc = await validateAccount({ accountCode, accountId })\n validatedAccountId = acc.accountId\n }\n\n const oneTimeCode = data.oneTimeCode ?? \"\"\n\n if (!oneTimeCode) {\n throw new Error(`Reset passcode code cannot be empty`);\n }\n\n const oneTimeCodeService = OneTimeCodeService({\n ...rest,\n accountId: isOperator ? 0 : Number(validatedAccountId),\n isOperator,\n field_ref: \"user\",\n field_module: \"administrator\"\n })\n\n // check code exist\n const { data: existOneTimeCodes } = await oneTimeCodeService.listOneTimeCodes({\n limit: 1,\n offset: 0,\n filters: [\n {\n field: `${ModelOneTimeCodeFields.code}`,\n operator: \"=\",\n value: `${oneTimeCode}`\n },\n {\n field: `${ModelOneTimeCodeFields.purpose_type}`,\n operator: \"=\",\n value: `${oneTimeCodePurposeTypes.reset_password}`\n },\n ],\n sortfield: `${ModelOneTimeCodeFields.one_time_code_id}`,\n sortorder: \"ASC\",\n datatypes: [],\n revealCode: true // return the code as well\n })\n\n if (existOneTimeCodes.length <= 0) {\n throw new Error(`Invalid reset password code: ${oneTimeCode}`);\n }\n\n const existOneTimeCode = existOneTimeCodes[0]\n\n // check is not used before\n if (existOneTimeCode?.code_status !== oneTimeCodeStatus.active) {\n throw new Error(`Reset password code is not active/used: ${oneTimeCode}`);\n }\n\n const expiresAt = dayjs(existOneTimeCode?.expires_at)\n const codeIsExpired = dayjs().isAfter(expiresAt)\n\n // check code is expired\n if (codeIsExpired) {\n throw new Error(`Reset password code is expired: ${oneTimeCode}`);\n }\n\n // console.log('existOneTimeCode', existOneTimeCode)\n\n return existOneTimeCode\n }\n\n const performResetPassword = async ({ data }: ResetPasswordPerformProps) => {\n\n const isOperator = Boolean(data.isOperator) // check if reset password for operator user or other users(account related)\n const accountId = data.accountId ?? \"\"\n const accountCode = data.accountCode ?? \"\"\n\n let validatedAccountId = ``\n let validatedAccountCode = ``\n\n // only non operator will check the account\n if (isOperator === false) {\n let acc = await validateAccount({ accountCode, accountId })\n validatedAccountId = acc.accountId\n validatedAccountCode = acc.accountCode\n }\n\n // get the onSetup from hook\n const hookSetup = ResetPasswordHook.onSetup()\n\n // const codeType: OneTimeCodeType = hookSetup.oneTimeCodeType\n const resetPasswordMethod: ResetPasswordMethod = hookSetup.resetPasswordMethod\n const oneTimeCode = data?.oneTimeCode ?? \"\"\n const newPassword = data?.newPassword ?? \"\"\n\n if (!oneTimeCode) {\n throw new Error(`One Time Code is required`);\n }\n\n if (!newPassword) {\n throw new Error(`New password is required`);\n }\n\n const oneTimeCodeService = OneTimeCodeService({\n ...rest,\n accountId: isOperator ? 0 : Number(validatedAccountId),\n isOperator,\n field_ref: \"user\",\n field_module: \"administrator\"\n })\n\n\n // validate the one time code\n const validateOneTimeCode = await validateResetPasscodeCode({\n data: {\n isOperator,\n accountCode: validatedAccountCode,\n accountId: `${validatedAccountId}`,\n oneTimeCode\n }\n })\n\n // retrieve the user by the one time code\n const oneTimeCodeUserId = validateOneTimeCode?.user_id ?? \"\"\n const oneTimeCodeUserType = validateOneTimeCode?.user_type ?? \"\"\n\n if (!oneTimeCodeUserId) {\n throw new Error(`Invalid one time code userId: ${oneTimeCode}`);\n }\n\n if (!oneTimeCodeUserType) {\n throw new Error(`Invalid one time code userId Type: ${oneTimeCode}`);\n }\n\n // retrive the user information\n const userService = UserService({\n ...rest,\n isOperator: true, // skip the account id\n accountId: Number(validatedAccountId),\n userType: oneTimeCodeUserType\n })\n\n const user = await userService.getUser({\n id: Number(oneTimeCodeUserId),\n datatypes: [],\n skipFilterUserType: true,\n })\n\n // verify the user\n if (!user?.user_id) {\n throw new Error(`Cannot find the userId: ${Number(oneTimeCodeUserId)}`);\n }\n\n // verify the user active\n if (Boolean(user?.status) === false) {\n throw new Error(`User is invalid status: ${user?.user_id ?? 0}`);\n }\n\n const userId = Number(user?.user_id ?? 0)\n const userType = user?.user_type ?? \"\"\n\n // consume the one time code\n let responseConsume = await oneTimeCodeService.consumeOneTimeCode({\n field_ref: \"user\",\n field_module: userType,\n data: {\n oneTimeCode,\n purposeType: \"reset_password\",\n userId,\n userType\n }\n })\n\n // change password for user\n let responseOnSuccess = await userService.replacePassword({\n id: userId,\n data: {\n unhashLoginPassword: newPassword\n },\n isOperator: Boolean(isOperator)\n })\n\n // Call the consumer hook, if registered\n if (ResetPasswordHook.onSuccess) {\n\n const responseCustomHook = await ResetPasswordHook.onSuccess(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n userId,\n userType,\n resetPasswordMethod,\n oneTimeCode,\n user\n }\n }))\n\n responseOnSuccess = { ...responseOnSuccess, custom: responseCustomHook }\n\n }\n\n return {\n ...responseOnSuccess,\n consumeOneTimeCode: responseConsume\n }\n }\n\n return {\n requestResetPassword,\n validateResetPasscodeCode,\n performResetPassword\n }\n\n}\n\n"]}
1
+ {"version":3,"file":"ResetPasswordService.js","sourceRoot":"","sources":["../../../src/services/reset_password/ResetPasswordService.ts"],"names":[],"mappings":";;;AAAA,mCAA6I;AAE7I,yDAAyD;AAEzD,oIAAoI;AAEpI,mCAAgC;AAEhC,qCAAuF;AACvF,yCAAmL;AAEnL,yCAA8C;AAEjC,QAAA,oBAAoB,GAAG;IAChC,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,KAAK;IACV,QAAQ,EAAE,UAAU;CACd,CAAA;AAiCH,MAAM,oBAAoB,GAAG,CAAC,KAAgC,EAAE,EAAE;IAErE,MAAM,EACF,GAAG,IAAI,EACV,GAAG,KAAK,CAAA;IAET,MAAM,oBAAoB,GAAG,IAAA,yBAAc,EAAC,EAAE,GAAG,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAA;IAE1E,MAAM,eAAe,GAAG,KAAK,EAAE,EAAE,SAAS,EAAE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AAG,MAAM,kBAAkB,CAAC,kBAAkB,CAAC;YAC9D,SAAS,EAAE,MAAM;YACjB,YAAY,EAAE,QAAQ;YACtB,IAAI,EAAE;gBACF,WAAW;gBACX,WAAW,EAAE,gBAAgB;gBAC7B,MAAM;gBACN,QAAQ;aACX;SACJ,CAAC,CAAA;QAEF,2BAA2B;QAC3B,IAAI,iBAAiB,GAAG,MAAM,WAAW,CAAC,eAAe,CAAC;YACtD,EAAE,EAAE,MAAM;YACV,IAAI,EAAE;gBACF,mBAAmB,EAAE,WAAW;aACnC;YACD,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC;SAClC,CAAC,CAAA;QAEF,wCAAwC;QACxC,IAAI,4BAAiB,CAAC,SAAS,EAAE,CAAC;YAE9B,MAAM,kBAAkB,GAAG,MAAM,4BAAiB,CAAC,SAAS,CAAC,IAAA,iCAAyB,EAAC;gBACnF,mBAAmB,EAAE,IAAI;gBACzB,cAAc,EAAE;oBACZ,MAAM;oBACN,QAAQ;oBACR,mBAAmB;oBACnB,WAAW;oBACX,IAAI;iBACP;aACJ,CAAC,CAAC,CAAA;YAEH,iBAAiB,GAAG,EAAE,GAAG,iBAAiB,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAA;QAE5E,CAAC;QAED,OAAO;YACH,GAAG,iBAAiB;YACpB,kBAAkB,EAAE,eAAe;SACtC,CAAA;IACL,CAAC,CAAA;IAED,OAAO;QACH,oBAAoB;QACpB,yBAAyB;QACzB,oBAAoB;KACvB,CAAA;AAEL,CAAC,CAAA;AA/hBY,QAAA,oBAAoB,wBA+hBhC","sourcesContent":["import { DefaultServiceProps, validateFormatEmailAddress, validateFormatMobileNumber, throwError, buildFeatureCallbackProps } from \"@/utils\";\n\n// import { QueryList, QueryGet } from \"@/schema/common\";\n\n// import { buildSqlRelation, buildSqlRawSelect, buildSqlWhere, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy } from \"@/lib\";\n\nimport { dayjs } from \"@/utils\";\n\nimport { ModelAccountFields, ModelOneTimeCodeFields, ModelUserFields } from \"@/models\";\nimport { UserService, AccountService, OneTimeCodeService, OneTimeCodeType, OneTimeCodeCreateProps, oneTimeCodeStatus, oneTimeCodePurposeTypes, AccountListProps } from \"@/services\"\n\nimport { ResetPasswordHook } from \"@/features\"\n\nexport const resetPasswordMethods = {\n email: \"email\",\n sms: \"sms\",\n whatapps: \"whatapps\",\n} as const\n\nexport type ResetPasswordMethod = typeof resetPasswordMethods[keyof typeof resetPasswordMethods]\n\nexport type ResetPasswordServiceProps = DefaultServiceProps & {\n};\n\ntype defaultResetPasswordProps = {\n isOperator: boolean\n accountId: string\n accountCode: string\n}\n\nexport type ResetPasswordRequestProps = {\n data: defaultResetPasswordProps & {\n emailAddress?: string\n mobileNumber?: string\n }\n}\n\nexport type ResetPasswordValidateCodeProps = {\n data: defaultResetPasswordProps & {\n oneTimeCode: string\n }\n}\n\nexport type ResetPasswordPerformProps = {\n data: defaultResetPasswordProps & {\n oneTimeCode: string\n newPassword: string\n }\n}\n\nexport const ResetPasswordService = (props: ResetPasswordServiceProps) => {\n\n const {\n ...rest\n } = props\n\n const globalAccountService = AccountService({ ...rest, isOperator: true })\n\n const validateAccount = async ({ accountId, accountCode }: {\n accountId: string,\n accountCode: string\n }) => {\n\n if (!accountId && !accountCode) {\n throwError(`AccountId or AccountCode is required`)\n }\n\n let filters: AccountListProps[\"filters\"] = []\n\n if (accountId !== \"\") {\n filters = [{\n field: `${ModelAccountFields.account_id}`,\n operator: \"=\",\n value: `${accountId}`\n }]\n }\n\n if (accountCode !== \"\") {\n filters = [{\n field: `${ModelAccountFields.account_code}`,\n operator: \"=\",\n value: `${accountCode}`\n }]\n }\n\n const { data: dataAccounts } = await globalAccountService.listAccounts({\n limit: 1,\n offset: 0,\n filters,\n sortfield: `${ModelAccountFields.account_id}`,\n sortorder: \"ASC\",\n datatypes: []\n })\n\n const dataAccount = dataAccounts.length > 0 ? dataAccounts[0] : {}\n\n if (!dataAccount?.account_id) {\n throwError(`Unable to retrieve account`)\n }\n\n return {\n accountId: dataAccount?.account_id ?? \"\",\n accountCode: dataAccount?.account_code ?? \"\"\n }\n\n }\n\n // get the user by email (non operator)\n const getUserByEmailNonOperator = async (\n accountId: ResetPasswordRequestProps[\"data\"][\"accountId\"],\n emailAddress: ResetPasswordRequestProps[\"data\"][\"emailAddress\"]\n ) => {\n\n const globalUserService = UserService({\n ...rest,\n accountId: Number(accountId), // need to override the account id,\n isOperator: false,\n userType: \"administrator\"\n })\n\n // get the user by email\n let { data: dataUser } = await globalUserService.listUsers({\n limit: 1,\n offset: 0,\n filters: [\n {\n field: `${ModelUserFields.email}`,\n operator: \"=\",\n value: `${emailAddress}`\n }\n ],\n sortfield: `${ModelUserFields.user_id}`,\n sortorder: \"ASC\",\n includePassword: false,\n skipFilterUserType: true,\n datatypes: []\n })\n\n return dataUser.length > 0 ? dataUser[0] : {}\n }\n\n // get the user by email (operator)\n const getUserByEmailOperator = async (\n emailAddress: ResetPasswordRequestProps[\"data\"][\"emailAddress\"]\n ) => {\n\n const globalUserService = UserService({\n ...rest,\n accountId: 0, // not important\n isOperator: true,\n userType: \"operator\"\n })\n\n // get the user by email\n let { data: dataUser } = await globalUserService.listUsers({\n limit: 1,\n offset: 0,\n filters: [\n {\n field: `${ModelUserFields.email}`,\n operator: \"=\",\n value: `${emailAddress}`\n },\n {\n field: `${ModelUserFields.user_type}`,\n operator: \"=\",\n value: `operator`\n }\n ],\n sortfield: `${ModelUserFields.user_id}`,\n sortorder: \"ASC\",\n includePassword: false,\n // skipFilterUserType: true,\n datatypes: []\n })\n\n return dataUser.length > 0 ? dataUser[0] : {}\n }\n\n // get the user by mobile (non operator)\n const getUserByMobileNonOperator = async (\n accountId: ResetPasswordRequestProps[\"data\"][\"accountId\"],\n mobileNumber: ResetPasswordRequestProps[\"data\"][\"mobileNumber\"]\n ) => {\n\n const globalUserService = UserService({\n ...rest,\n accountId: Number(accountId), // need to override the account id,\n isOperator: false,\n userType: \"administrator\"\n })\n\n // get the user by contact\n let { data: dataUser } = await globalUserService.listUsers({\n limit: 1,\n offset: 0,\n filters: [\n {\n field: `contact`,\n operator: \"=\",\n value: `${mobileNumber}`\n }\n ],\n sortfield: `${ModelUserFields.user_id}`,\n sortorder: \"ASC\",\n includePassword: false,\n skipFilterUserType: true,\n datatypes: []\n })\n\n return dataUser.length > 0 ? dataUser[0] : {}\n\n }\n\n // get the user by mobile (operator)\n const getUserByMobileOperator = async (\n mobileNumber: ResetPasswordRequestProps[\"data\"][\"mobileNumber\"]\n ) => {\n\n const globalUserService = UserService({\n ...rest,\n accountId: 0, // not important\n isOperator: true,\n userType: \"operator\"\n })\n\n // get the user by contact\n let { data: dataUser } = await globalUserService.listUsers({\n limit: 1,\n offset: 0,\n filters: [\n {\n field: `contact`,\n operator: \"=\",\n value: `${mobileNumber}`\n },\n {\n field: `${ModelUserFields.user_type}`,\n operator: \"=\",\n value: `operator`\n }\n ],\n sortfield: `${ModelUserFields.user_id}`,\n sortorder: \"ASC\",\n includePassword: false,\n skipFilterUserType: true,\n datatypes: []\n })\n\n return dataUser.length > 0 ? dataUser[0] : {}\n\n }\n\n const requestResetPassword = async ({ data }: ResetPasswordRequestProps) => {\n\n const isOperator = Boolean(data.isOperator) // check if reset password for operator user or other users(account related)\n const accountId = data.accountId ?? \"\"\n const accountCode = data.accountCode ?? \"\"\n\n let validatedAccountId = ``\n\n // only non operator will check the account\n if (isOperator === false) {\n let acc = await validateAccount({ accountCode, accountId })\n validatedAccountId = acc.accountId\n }\n\n // get the onSetup from hook\n const hookSetup = ResetPasswordHook.onSetup()\n\n const codeType: OneTimeCodeType = hookSetup.oneTimeCodeType\n const resetPasswordMethod: ResetPasswordMethod = hookSetup.resetPasswordMethod\n const emailAddress = data?.emailAddress ?? \"\"\n const mobileNumber = data?.mobileNumber ?? \"\"\n\n let user: any = {}\n\n const oneTimeCodeService = OneTimeCodeService({\n ...rest,\n accountId: isOperator ? 0 : Number(validatedAccountId),\n isOperator,\n field_ref: \"user\",\n field_module: \"administrator\"\n })\n\n if (!resetPasswordMethod) {\n throw new Error(`Invalid reset password method: ${hookSetup?.resetPasswordMethod ?? \"\"}`);\n }\n\n if (resetPasswordMethod === \"email\") {\n if (validateFormatEmailAddress(emailAddress) === false) {\n throw new Error(`Invalid email address: ${emailAddress}`);\n }\n\n // get the user by email\n user = isOperator ?\n await getUserByEmailOperator(emailAddress)\n :\n await getUserByEmailNonOperator(validatedAccountId, emailAddress)\n\n }\n\n if (resetPasswordMethod === \"sms\" || resetPasswordMethod === \"whatapps\") {\n if (validateFormatMobileNumber(mobileNumber) === false) {\n throw new Error(`Invalid mobile number: ${mobileNumber}`);\n }\n\n // get the user by email\n user = isOperator ?\n await getUserByMobileOperator(mobileNumber)\n :\n await getUserByMobileNonOperator(validatedAccountId, mobileNumber)\n\n }\n\n if (emailAddress === \"\" && mobileNumber === \"\") {\n throw new Error(`Either email address or mobile number is required`);\n }\n\n // verify the user\n if (!user?.user_id) {\n throw new Error(`Cannot find the user by ${resetPasswordMethod}: ${emailAddress ? emailAddress : mobileNumber}`);\n }\n\n // verify the user active\n if (Boolean(user?.status) === false) {\n throw new Error(`User is invalid status: ${user?.user_id ?? 0}`);\n }\n\n const userId = Number(user?.user_id ?? 0)\n const userType = user?.user_type ?? \"\"\n\n const codePayload: OneTimeCodeCreateProps = {\n field_ref: \"user\",\n field_module: userType,\n data: {\n purposeType: \"reset_password\",\n codeType,\n emailAddress,\n mobileNumber,\n userId,\n userType,\n ...(hookSetup?.expiresInMinutes ? {\n expiredAt: dayjs().add(Number(hookSetup.expiresInMinutes), \"minute\").toDate() // convert to JS Date\n } : {})\n }\n }\n\n // generate the code \n const oneTimeCode = await oneTimeCodeService.createOneTimeCode(codePayload)\n\n // console.log('oneTimeCode', oneTimeCode)\n\n let responseOneTimeCode = await oneTimeCodeService.getOneTimeCode({ id: Number(oneTimeCode?.one_time_code_id ?? 0), datatypes: [] })\n\n // Call the consumer hook, if registered\n if (ResetPasswordHook.onRequest) {\n\n const responseCustomHook = await ResetPasswordHook.onRequest(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n userId,\n userType,\n resetPasswordMethod,\n emailAddress,\n mobileNumber,\n oneTimeCode: oneTimeCode?.code ?? \"\",\n user\n }\n }))\n\n responseOneTimeCode = { ...responseOneTimeCode, custom: responseCustomHook }\n\n }\n\n return responseOneTimeCode\n }\n\n const validateResetPasscodeCode = async ({ data }: ResetPasswordValidateCodeProps) => {\n\n const isOperator = Boolean(data.isOperator) // check if reset password for operator user or other users(account related)\n const accountId = data.accountId ?? \"\"\n const accountCode = data.accountCode ?? \"\"\n\n let validatedAccountId = ``\n\n // only non operator will check the account\n if (isOperator === false) {\n let acc = await validateAccount({ accountCode, accountId })\n validatedAccountId = acc.accountId\n }\n\n const oneTimeCode = data.oneTimeCode ?? \"\"\n\n if (!oneTimeCode) {\n throw new Error(`Reset passcode code cannot be empty`);\n }\n\n const oneTimeCodeService = OneTimeCodeService({\n ...rest,\n accountId: isOperator ? 0 : Number(validatedAccountId),\n isOperator,\n field_ref: \"user\",\n field_module: \"administrator\"\n })\n\n // check code exist\n const { data: existOneTimeCodes } = await oneTimeCodeService.listOneTimeCodes({\n limit: 1,\n offset: 0,\n filters: [\n {\n field: `${ModelOneTimeCodeFields.code}`,\n operator: \"=\",\n value: `${oneTimeCode}`\n },\n {\n field: `${ModelOneTimeCodeFields.purpose_type}`,\n operator: \"=\",\n value: `${oneTimeCodePurposeTypes.reset_password}`\n },\n ],\n sortfield: `${ModelOneTimeCodeFields.one_time_code_id}`,\n sortorder: \"ASC\",\n datatypes: [],\n revealCode: true // return the code as well\n })\n\n if (existOneTimeCodes.length <= 0) {\n throw new Error(`Invalid reset password code: ${oneTimeCode}`);\n }\n\n const existOneTimeCode = existOneTimeCodes[0]\n\n // check is not used before\n if (existOneTimeCode?.code_status !== oneTimeCodeStatus.active) {\n throw new Error(`Reset password code is not active/used: ${oneTimeCode}`);\n }\n\n const expiresAt = dayjs(existOneTimeCode?.expires_at)\n const codeIsExpired = dayjs().isAfter(expiresAt)\n\n // check code is expired\n if (codeIsExpired) {\n throw new Error(`Reset password code is expired: ${oneTimeCode}`);\n }\n\n // console.log('existOneTimeCode', existOneTimeCode)\n\n return existOneTimeCode\n }\n\n const performResetPassword = async ({ data }: ResetPasswordPerformProps) => {\n\n const isOperator = Boolean(data.isOperator) // check if reset password for operator user or other users(account related)\n const accountId = data.accountId ?? \"\"\n const accountCode = data.accountCode ?? \"\"\n\n let validatedAccountId = ``\n let validatedAccountCode = ``\n\n // only non operator will check the account\n if (isOperator === false) {\n let acc = await validateAccount({ accountCode, accountId })\n validatedAccountId = acc.accountId\n validatedAccountCode = acc.accountCode\n }\n\n // get the onSetup from hook\n const hookSetup = ResetPasswordHook.onSetup()\n\n // const codeType: OneTimeCodeType = hookSetup.oneTimeCodeType\n const resetPasswordMethod: ResetPasswordMethod = hookSetup.resetPasswordMethod\n const oneTimeCode = data?.oneTimeCode ?? \"\"\n const newPassword = data?.newPassword ?? \"\"\n\n if (!oneTimeCode) {\n throw new Error(`One Time Code is required`);\n }\n\n if (!newPassword) {\n throw new Error(`New password is required`);\n }\n\n const oneTimeCodeService = OneTimeCodeService({\n ...rest,\n accountId: isOperator ? 0 : Number(validatedAccountId),\n isOperator,\n field_ref: \"user\",\n field_module: \"administrator\"\n })\n\n\n // validate the one time code\n const validateOneTimeCode = await validateResetPasscodeCode({\n data: {\n isOperator,\n accountCode: validatedAccountCode,\n accountId: `${validatedAccountId}`,\n oneTimeCode\n }\n })\n\n // retrieve the user by the one time code\n const oneTimeCodeUserId = validateOneTimeCode?.user_id ?? \"\"\n const oneTimeCodeUserType = validateOneTimeCode?.user_type ?? \"\"\n\n if (!oneTimeCodeUserId) {\n throw new Error(`Invalid one time code userId: ${oneTimeCode}`);\n }\n\n if (!oneTimeCodeUserType) {\n throw new Error(`Invalid one time code userId Type: ${oneTimeCode}`);\n }\n\n // retrive the user information\n const userService = UserService({\n ...rest,\n isOperator: true, // skip the account id\n accountId: Number(validatedAccountId),\n userType: oneTimeCodeUserType\n })\n\n const user = await userService.getUser({\n id: Number(oneTimeCodeUserId),\n datatypes: [],\n skipFilterUserType: true,\n })\n\n // verify the user\n if (!user?.user_id) {\n throw new Error(`Cannot find the userId: ${Number(oneTimeCodeUserId)}`);\n }\n\n // verify the user active\n if (Boolean(user?.status) === false) {\n throw new Error(`User is invalid status: ${user?.user_id ?? 0}`);\n }\n\n const userId = Number(user?.user_id ?? 0)\n const userType = user?.user_type ?? \"\"\n\n // consume the one time code\n let responseConsume = await oneTimeCodeService.consumeOneTimeCode({\n field_ref: \"user\",\n field_module: userType,\n data: {\n oneTimeCode,\n purposeType: \"reset_password\",\n userId,\n userType\n }\n })\n\n // change password for user\n let responseOnSuccess = await userService.replacePassword({\n id: userId,\n data: {\n unhashLoginPassword: newPassword\n },\n isOperator: Boolean(isOperator)\n })\n\n // Call the consumer hook, if registered\n if (ResetPasswordHook.onSuccess) {\n\n const responseCustomHook = await ResetPasswordHook.onSuccess(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n userId,\n userType,\n resetPasswordMethod,\n oneTimeCode,\n user\n }\n }))\n\n responseOnSuccess = { ...responseOnSuccess, custom: responseCustomHook }\n\n }\n\n return {\n ...responseOnSuccess,\n consumeOneTimeCode: responseConsume\n }\n }\n\n return {\n requestResetPassword,\n validateResetPasscodeCode,\n performResetPassword\n }\n\n}\n\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storemw-core-api",
3
- "version": "1.0.155",
3
+ "version": "1.0.157",
4
4
  "description": "STOREMW Core API",
5
5
  "main": "dist/app.js",
6
6
  "types": "dist/app.d.ts",
@@ -143,9 +143,6 @@
143
143
  "express": "^4.21.2"
144
144
  },
145
145
  "devDependencies": {
146
- "@types/jsonwebtoken": "^9.0.9",
147
- "@types/pg": "^8.11.11",
148
- "@types/uuid": "^10.0.0",
149
146
  "@types/basic-auth": "^1.1.8",
150
147
  "@types/bcrypt": "^6.0.0",
151
148
  "@types/cors": "^2.8.17",
@@ -153,13 +150,16 @@
153
150
  "@types/ffprobe-static": "^2.0.3",
154
151
  "@types/fluent-ffmpeg": "^2.1.28",
155
152
  "@types/google-cloud__storage": "^1.7.2",
153
+ "@types/jsonwebtoken": "^9.0.9",
156
154
  "@types/lodash": "^4.17.16",
157
155
  "@types/multer": "^2.0.0",
158
156
  "@types/node": "^22.17.2",
159
157
  "@types/nodemailer": "^7.0.9",
160
158
  "@types/nodemailer-express-handlebars": "^4.0.6",
159
+ "@types/pg": "^8.11.11",
161
160
  "@types/pino": "^7.0.4",
162
161
  "@types/tmp": "^0.2.6",
162
+ "@types/uuid": "^10.0.0",
163
163
  "nodemailer": "^6.9.4",
164
164
  "ts-node": "^10.9.2",
165
165
  "tsc-alias": "^1.8.16",
@@ -167,16 +167,16 @@
167
167
  "typescript": "^5.8.2"
168
168
  },
169
169
  "optionalDependencies": {
170
- "nodemailer": "^6.10.1",
171
- "nodemailer-express-handlebars": "^7.0.0",
172
170
  "@aws-sdk/client-s3": "^3.1000.0",
173
171
  "@aws-sdk/s3-request-presigner": "^3.1000.0",
174
172
  "@google-cloud/storage": "^7.17.2",
175
- "sharp": "^0.34.4",
176
- "tmp-promise": "^3.0.3",
177
173
  "ffmpeg-static": "^5.2.0",
178
174
  "ffprobe-static": "^3.1.0",
179
175
  "fluent-ffmpeg": "^2.1.3",
176
+ "nodemailer": "^6.10.1",
177
+ "nodemailer-express-handlebars": "^7.0.0",
178
+ "sharp": "^0.34.4",
179
+ "tmp-promise": "^3.0.3",
180
180
  "uuid": "^11.1.0"
181
181
  }
182
182
  }