storemw-core-api 1.0.101 → 1.0.102

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.
@@ -5,6 +5,7 @@ const utils_1 = require("../../utils");
5
5
  // import { QueryList } from "../../schema/middleware/route";
6
6
  const services_1 = require("../../services");
7
7
  const payload_1 = require("../../schema/payload");
8
+ const utils_2 = require("../../utils");
8
9
  const getRootName = (toSingular) => {
9
10
  let rootName = toSingular ? "resetPassword" : "resetPasswords";
10
11
  return rootName;
@@ -17,13 +18,10 @@ const requestResetPassword = async (req, res, next) => {
17
18
  ...defaultServiceProps,
18
19
  });
19
20
  let response = {};
20
- let reqScope = req.body.scope;
21
+ // let reqScope = req.body.scope
21
22
  let reqPayload = req.body.payload;
22
23
  let request = payload_1.schemaResetPasswordRequestPayload.parse({
23
- scope: {
24
- target: reqScope.target,
25
- action: reqScope.action
26
- },
24
+ scope: (0, utils_2.normalizePublicScopeFromBody)(req.body),
27
25
  payload: {
28
26
  resetPassword: {
29
27
  userType: reqPayload?.reset_password?.user_type,
@@ -35,7 +33,9 @@ const requestResetPassword = async (req, res, next) => {
35
33
  });
36
34
  let payload = {
37
35
  data: {
38
- // userType: request.payload?.resetPassword?.userType as UserType,
36
+ isOperator: request.scope.isOperator,
37
+ accountId: request.scope.accountId ?? "",
38
+ accountCode: request.scope.accountCode ?? "",
39
39
  ...(request.payload?.resetPassword?.emailAddress ? { emailAddress: request.payload.resetPassword.emailAddress } : {}),
40
40
  ...(request.payload?.resetPassword?.mobileNumber ? { mobileNumber: request.payload.resetPassword.mobileNumber } : {}),
41
41
  // userId: request.payload.resetPassword.userId
@@ -62,10 +62,7 @@ const validateResetPasswordCode = async (req, res, next) => {
62
62
  let reqScope = req.body.scope;
63
63
  let reqPayload = req.body.payload;
64
64
  let request = payload_1.schemaResetPasswordValidateCodePayload.parse({
65
- scope: {
66
- target: reqScope.target,
67
- action: reqScope.action
68
- },
65
+ scope: (0, utils_2.normalizePublicScopeFromBody)(req.body),
69
66
  payload: {
70
67
  resetPassword: {
71
68
  oneTimeCode: reqPayload?.reset_password?.one_time_code ?? "",
@@ -74,6 +71,9 @@ const validateResetPasswordCode = async (req, res, next) => {
74
71
  });
75
72
  let payload = {
76
73
  data: {
74
+ isOperator: request.scope.isOperator,
75
+ accountId: request.scope.accountId ?? "",
76
+ accountCode: request.scope.accountCode ?? "",
77
77
  oneTimeCode: request.payload?.resetPassword?.oneTimeCode
78
78
  }
79
79
  };
@@ -98,10 +98,7 @@ const performResetPassword = async (req, res, next) => {
98
98
  let reqScope = req.body.scope;
99
99
  let reqPayload = req.body.payload;
100
100
  let request = payload_1.schemaResetPasswordPerformPayload.parse({
101
- scope: {
102
- target: reqScope.target,
103
- action: reqScope.action
104
- },
101
+ scope: (0, utils_2.normalizePublicScopeFromBody)(req.body),
105
102
  payload: {
106
103
  resetPassword: {
107
104
  oneTimeCode: reqPayload?.reset_password?.one_time_code,
@@ -111,6 +108,9 @@ const performResetPassword = async (req, res, next) => {
111
108
  });
112
109
  let payload = {
113
110
  data: {
111
+ isOperator: request.scope.isOperator,
112
+ accountId: request.scope.accountId ?? "",
113
+ accountCode: request.scope.accountCode ?? "",
114
114
  oneTimeCode: request.payload.resetPassword.oneTimeCode,
115
115
  newPassword: request.payload.resetPassword.newPassword
116
116
  }
@@ -1 +1 @@
1
- {"version":3,"file":"resetPasswordController.js","sourceRoot":"","sources":["../../../src/controllers/reset_password/resetPasswordController.ts"],"names":[],"mappings":";;;AAEA,mCAAqF;AAErF,yDAAyD;AAEzD,yCAAiJ;AACjJ,8CAAgJ;AAEhJ,MAAM,WAAW,GAAG,CAAC,UAAmB,EAAE,EAAE;IAExC,IAAI,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAE/D,OAAO,QAAQ,CAAA;AACnB,CAAC,CAAA;AAED,0DAA0D;AACnD,MAAM,oBAAoB,GAAG,KAAK,EAAE,GAAY,E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YACrC,IAAI,EAAE;gBACF,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,WAAW;gBACtD,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,WAAW;aACzD;SACJ,CAAA;QAED,QAAQ,GAAG;YACP,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAC,oBAAoB,CAAC,OAAO,CAAC;SACrF,CAAA;QAED,IAAA,mBAAW,EAAC,GAAG,EAAE,QAAQ,EAAE,uCAAuC,CAAC,CAAA;IAEvE,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QAClB,IAAI,CAAC,KAAK,CAAC,CAAA;IACf,CAAC;AACL,CAAC,CAAA;AA3CY,QAAA,oBAAoB,wBA2ChC","sourcesContent":["import { NextFunction, Request, Response } from \"express\";\n\nimport { getDefaultServiceProps, sendSuccess, sendError, HTTP_STATUS } from \"@/utils\"\n\n// import { QueryList } from \"@/schema/middleware/route\";\n\nimport { ResetPasswordService, UserType, ResetPasswordRequestProps, ResetPasswordValidateCodeProps, ResetPasswordPerformProps } from \"@/services\"\nimport { schemaResetPasswordRequestPayload, schemaResetPasswordValidateCodePayload, schemaResetPasswordPerformPayload } from \"@/schema/payload\";\n\nconst getRootName = (toSingular: boolean) => {\n\n let rootName = toSingular ? \"resetPassword\" : \"resetPasswords\";\n\n return rootName\n}\n\n/** reset_password/request : request for reset password */\nexport const requestResetPassword = async (req: Request, res: Response, next: NextFunction): Promise<any> => {\n try {\n\n const defaultServiceProps = getDefaultServiceProps(req)\n\n const resetPasswordService = ResetPasswordService({\n ...defaultServiceProps,\n })\n\n let response: any = {}\n\n let reqScope = req.body.scope\n let reqPayload = req.body.payload\n\n let request = schemaResetPasswordRequestPayload.parse({\n scope: {\n target: reqScope.target,\n action: reqScope.action\n },\n payload: {\n resetPassword: {\n userType: reqPayload?.reset_password?.user_type,\n ...(reqPayload?.reset_password?.email_address ? { emailAddress: reqPayload?.reset_password?.email_address } : {}),\n ...(reqPayload?.reset_password?.mobile_number ? { mobileNumber: reqPayload?.reset_password?.mobile_number } : {}),\n // userId: Number(reqPayload?.access_key?.user_id ?? 0),\n }\n }\n })\n\n let payload: ResetPasswordRequestProps = {\n data: {\n // userType: request.payload?.resetPassword?.userType as UserType,\n ...(request.payload?.resetPassword?.emailAddress ? { emailAddress: request.payload.resetPassword.emailAddress } : {}),\n ...(request.payload?.resetPassword?.mobileNumber ? { mobileNumber: request.payload.resetPassword.mobileNumber } : {}),\n // userId: request.payload.resetPassword.userId\n }\n }\n\n response = {\n [`${getRootName(true)}`]: await resetPasswordService.requestResetPassword(payload)\n }\n\n sendSuccess(res, response, `Reset password requested successfully`)\n\n } catch (error: any) {\n next(error)\n }\n}\n\n/** reset_password/validate_code : validate reset password code */\nexport const validateResetPasswordCode = async (req: Request, res: Response, next: NextFunction): Promise<any> => {\n try {\n\n const defaultServiceProps = getDefaultServiceProps(req)\n\n const resetPasswordService = ResetPasswordService({\n ...defaultServiceProps,\n })\n\n let response: any = {}\n\n let reqScope = req.body.scope\n let reqPayload = req.body.payload\n\n let request = schemaResetPasswordValidateCodePayload.parse({\n scope: {\n target: reqScope.target,\n action: reqScope.action\n },\n payload: {\n resetPassword: {\n oneTimeCode: reqPayload?.reset_password?.one_time_code ?? \"\",\n }\n }\n })\n\n let payload: ResetPasswordValidateCodeProps = {\n data: {\n oneTimeCode: request.payload?.resetPassword?.oneTimeCode\n }\n }\n\n response = {\n [`${getRootName(true)}`]: await resetPasswordService.validateResetPasscodeCode(payload)\n }\n\n sendSuccess(res, response, `Reset password code validated successfully`)\n\n } catch (error: any) {\n next(error)\n }\n}\n\n/** reset_password/perform : perform for reset password */\nexport const performResetPassword = async (req: Request, res: Response, next: NextFunction): Promise<any> => {\n try {\n\n const defaultServiceProps = getDefaultServiceProps(req)\n\n const resetPasswordService = ResetPasswordService({\n ...defaultServiceProps,\n })\n\n let response: any = {}\n\n let reqScope = req.body.scope\n let reqPayload = req.body.payload\n\n let request = schemaResetPasswordPerformPayload.parse({\n scope: {\n target: reqScope.target,\n action: reqScope.action\n },\n payload: {\n resetPassword: {\n oneTimeCode: reqPayload?.reset_password?.one_time_code,\n newPassword: reqPayload?.reset_password?.new_password,\n }\n }\n })\n\n let payload: ResetPasswordPerformProps = {\n data: {\n oneTimeCode: request.payload.resetPassword.oneTimeCode,\n newPassword: request.payload.resetPassword.newPassword\n }\n }\n\n response = {\n [`${getRootName(true)}`]: await resetPasswordService.performResetPassword(payload)\n }\n\n sendSuccess(res, response, `Reset password performed successfully`)\n\n } catch (error: any) {\n next(error)\n }\n}\n"]}
1
+ {"version":3,"file":"resetPasswordController.js","sourceRoot":"","sources":["../../../src/controllers/reset_password/resetPasswordController.ts"],"names":[],"mappings":";;;AAEA,mCAAqF;AAErF,yDAAyD;AAEzD,yCAAiJ;AACjJ,8CAAgJ;AAEhJ,mCAAuD;AAEvD,MAAM,WAAW,GAAG,CAAC,UAAmB,EAAE,EAAE;IAExC,IAAI,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,gBAAgB,CAAC;IAE/D,OAAO,QAAQ,CAAA;AACnB,CAAC,CAAA;AAED,0DAA0D;AACnD,MAAM,oBAAoB,GAAG,KAAK,EAAE,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAgB,EAAE;IACxG,IAAI,CAAC;QAED,MAAM,mBAAmB,GAAG,IAAA,8BAAsB,EAAC,GAAG,CAAC,CAAA;QAEvD,MAAM,oBAAoB,GAAG,IAAA,+BAAoB,EAAC;YAC9C,GAAG,mBAAmB;SACzB,CAAC,CAAA;QAEF,IAAI,QAAQ,GAAQ,EAAE,CAAA;QAEtB,gCAAgC;QAChC,IAAI,UAAU,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,CAAA;QAEjC,IAAI,OAAO,GAAG,2CAAiC,CAAC,KAAK,CAAC;YAClD,KAAK,EAAE,IAAA,oCAA4B,EAAC,GAAG,CAAC,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W;gBACtD,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,WAAW;aACzD;SACJ,CAAA;QAED,QAAQ,GAAG;YACP,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAC,oBAAoB,CAAC,OAAO,CAAC;SACrF,CAAA;QAED,IAAA,mBAAW,EAAC,GAAG,EAAE,QAAQ,EAAE,uCAAuC,CAAC,CAAA;IAEvE,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QAClB,IAAI,CAAC,KAAK,CAAC,CAAA;IACf,CAAC;AACL,CAAC,CAAA;AA3CY,QAAA,oBAAoB,wBA2ChC","sourcesContent":["import { NextFunction, Request, Response } from \"express\";\n\nimport { getDefaultServiceProps, sendSuccess, sendError, HTTP_STATUS } from \"@/utils\"\n\n// import { QueryList } from \"@/schema/middleware/route\";\n\nimport { ResetPasswordService, UserType, ResetPasswordRequestProps, ResetPasswordValidateCodeProps, ResetPasswordPerformProps } from \"@/services\"\nimport { schemaResetPasswordRequestPayload, schemaResetPasswordValidateCodePayload, schemaResetPasswordPerformPayload } from \"@/schema/payload\";\n\nimport { normalizePublicScopeFromBody } from \"@/utils\";\n\nconst getRootName = (toSingular: boolean) => {\n\n let rootName = toSingular ? \"resetPassword\" : \"resetPasswords\";\n\n return rootName\n}\n\n/** reset_password/request : request for reset password */\nexport const requestResetPassword = async (req: Request, res: Response, next: NextFunction): Promise<any> => {\n try {\n\n const defaultServiceProps = getDefaultServiceProps(req)\n\n const resetPasswordService = ResetPasswordService({\n ...defaultServiceProps,\n })\n\n let response: any = {}\n\n // let reqScope = req.body.scope\n let reqPayload = req.body.payload\n\n let request = schemaResetPasswordRequestPayload.parse({\n scope: normalizePublicScopeFromBody(req.body),\n payload: {\n resetPassword: {\n userType: reqPayload?.reset_password?.user_type,\n ...(reqPayload?.reset_password?.email_address ? { emailAddress: reqPayload?.reset_password?.email_address } : {}),\n ...(reqPayload?.reset_password?.mobile_number ? { mobileNumber: reqPayload?.reset_password?.mobile_number } : {}),\n // userId: Number(reqPayload?.access_key?.user_id ?? 0),\n }\n }\n })\n\n let payload: ResetPasswordRequestProps = {\n data: {\n isOperator: request.scope.isOperator,\n accountId: request.scope.accountId ?? \"\",\n accountCode: request.scope.accountCode ?? \"\",\n ...(request.payload?.resetPassword?.emailAddress ? { emailAddress: request.payload.resetPassword.emailAddress } : {}),\n ...(request.payload?.resetPassword?.mobileNumber ? { mobileNumber: request.payload.resetPassword.mobileNumber } : {}),\n // userId: request.payload.resetPassword.userId\n }\n }\n\n response = {\n [`${getRootName(true)}`]: await resetPasswordService.requestResetPassword(payload)\n }\n\n sendSuccess(res, response, `Reset password requested successfully`)\n\n } catch (error: any) {\n next(error)\n }\n}\n\n/** reset_password/validate_code : validate reset password code */\nexport const validateResetPasswordCode = async (req: Request, res: Response, next: NextFunction): Promise<any> => {\n try {\n\n const defaultServiceProps = getDefaultServiceProps(req)\n\n const resetPasswordService = ResetPasswordService({\n ...defaultServiceProps,\n })\n\n let response: any = {}\n\n let reqScope = req.body.scope\n let reqPayload = req.body.payload\n\n let request = schemaResetPasswordValidateCodePayload.parse({\n scope: normalizePublicScopeFromBody(req.body),\n payload: {\n resetPassword: {\n oneTimeCode: reqPayload?.reset_password?.one_time_code ?? \"\",\n }\n }\n })\n\n let payload: ResetPasswordValidateCodeProps = {\n data: {\n isOperator: request.scope.isOperator,\n accountId: request.scope.accountId ?? \"\",\n accountCode: request.scope.accountCode ?? \"\",\n oneTimeCode: request.payload?.resetPassword?.oneTimeCode\n }\n }\n\n response = {\n [`${getRootName(true)}`]: await resetPasswordService.validateResetPasscodeCode(payload)\n }\n\n sendSuccess(res, response, `Reset password code validated successfully`)\n\n } catch (error: any) {\n next(error)\n }\n}\n\n/** reset_password/perform : perform for reset password */\nexport const performResetPassword = async (req: Request, res: Response, next: NextFunction): Promise<any> => {\n try {\n\n const defaultServiceProps = getDefaultServiceProps(req)\n\n const resetPasswordService = ResetPasswordService({\n ...defaultServiceProps,\n })\n\n let response: any = {}\n\n let reqScope = req.body.scope\n let reqPayload = req.body.payload\n\n let request = schemaResetPasswordPerformPayload.parse({\n scope: normalizePublicScopeFromBody(req.body),\n payload: {\n resetPassword: {\n oneTimeCode: reqPayload?.reset_password?.one_time_code,\n newPassword: reqPayload?.reset_password?.new_password,\n }\n }\n })\n\n let payload: ResetPasswordPerformProps = {\n data: {\n isOperator: request.scope.isOperator,\n accountId: request.scope.accountId ?? \"\",\n accountCode: request.scope.accountCode ?? \"\",\n oneTimeCode: request.payload.resetPassword.oneTimeCode,\n newPassword: request.payload.resetPassword.newPassword\n }\n }\n\n response = {\n [`${getRootName(true)}`]: await resetPasswordService.performResetPassword(payload)\n }\n\n sendSuccess(res, response, `Reset password performed successfully`)\n\n } catch (error: any) {\n next(error)\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  export { initialPrisma, RequestAuthContext } from "./initialPrisma";
2
- export { validateHeader } from "./validateHeader";
2
+ export { validateHeader, defaultAuthExcludedRoutes } from "./validateHeader";
3
3
  export { validateAuthorization, AuthorizeRequest } from "./validateAuthorization";
4
4
  export { validateCors } from "./validateCors";
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateCors = exports.validateAuthorization = exports.validateHeader = exports.initialPrisma = void 0;
3
+ exports.validateCors = exports.validateAuthorization = exports.defaultAuthExcludedRoutes = exports.validateHeader = exports.initialPrisma = void 0;
4
4
  var initialPrisma_1 = require("./initialPrisma");
5
5
  Object.defineProperty(exports, "initialPrisma", { enumerable: true, get: function () { return initialPrisma_1.initialPrisma; } });
6
6
  var validateHeader_1 = require("./validateHeader");
7
7
  Object.defineProperty(exports, "validateHeader", { enumerable: true, get: function () { return validateHeader_1.validateHeader; } });
8
+ Object.defineProperty(exports, "defaultAuthExcludedRoutes", { enumerable: true, get: function () { return validateHeader_1.defaultAuthExcludedRoutes; } });
8
9
  // export { validateSignature } from "./validateSignature"
9
10
  var validateAuthorization_1 = require("./validateAuthorization");
10
11
  Object.defineProperty(exports, "validateAuthorization", { enumerable: true, get: function () { return validateAuthorization_1.validateAuthorization; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/middlewares/request/index.ts"],"names":[],"mappings":";;;AAAA,iDAAmE;AAA1D,8GAAA,aAAa,OAAA;AACtB,mDAAiD;AAAxC,gHAAA,cAAc,OAAA;AACvB,0DAA0D;AAC1D,iEAAiF;AAAxE,8HAAA,qBAAqB,OAAA;AAC9B,+CAA6C;AAApC,4GAAA,YAAY,OAAA","sourcesContent":["export { initialPrisma, RequestAuthContext } from \"./initialPrisma\"\nexport { validateHeader } from \"./validateHeader\"\n// export { validateSignature } from \"./validateSignature\"\nexport { validateAuthorization, AuthorizeRequest } from \"./validateAuthorization\"\nexport { validateCors } from \"./validateCors\"\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/middlewares/request/index.ts"],"names":[],"mappings":";;;AAAA,iDAAmE;AAA1D,8GAAA,aAAa,OAAA;AACtB,mDAA4E;AAAnE,gHAAA,cAAc,OAAA;AAAE,2HAAA,yBAAyB,OAAA;AAClD,0DAA0D;AAC1D,iEAAiF;AAAxE,8HAAA,qBAAqB,OAAA;AAC9B,+CAA6C;AAApC,4GAAA,YAAY,OAAA","sourcesContent":["export { initialPrisma, RequestAuthContext } from \"./initialPrisma\"\nexport { validateHeader, defaultAuthExcludedRoutes } from \"./validateHeader\"\n// export { validateSignature } from \"./validateSignature\"\nexport { validateAuthorization, AuthorizeRequest } from \"./validateAuthorization\"\nexport { validateCors } from \"./validateCors\"\n"]}
@@ -10,22 +10,16 @@ const path_to_regexp_1 = require("path-to-regexp");
10
10
  const utils_1 = require("../../utils");
11
11
  const utils_2 = require("../../utils");
12
12
  const services_1 = require("../../services");
13
+ const validateHeader_1 = require("./validateHeader");
13
14
  // retrive core configuration
14
15
  const coreConfig = (0, utils_1.getCoreConfiguration)();
15
- // import { AuthJwtToken } from "../../services";
16
- const defaultExcludedRoutes = [
17
- '/auth/token',
18
- // '/api/tools/generatesignature',
19
- // '/api/tools/generatetoken',
20
- // add more defaults if needed
21
- ];
22
16
  /**
23
17
  * Combined middleware: JWT or Access Key
24
18
  */
25
19
  const validateAuthorization = (options = {
26
20
  excludedRoutes: []
27
21
  }) => {
28
- const excludedRoutes = [...defaultExcludedRoutes, ...(options.excludedRoutes || [])];
22
+ const excludedRoutes = [...validateHeader_1.defaultAuthExcludedRoutes, ...(options.excludedRoutes || [])];
29
23
  const matchers = excludedRoutes.map((route) => (0, path_to_regexp_1.match)(route, { decode: decodeURIComponent }));
30
24
  // const matchers = excludedRoutes.map((route) => {
31
25
  // const regex = pathToRegexp(route); // works for all versions
@@ -162,7 +156,7 @@ const validateJWT = (token, req, res, next) => {
162
156
  // export const validateAuthorization = (options: ValidateAuthOptions) => {
163
157
  // // Merge default excluded routes with any custom ones
164
158
  // const excludedRoutes = [
165
- // ...defaultExcludedRoutes,
159
+ // ...defaultAuthExcludedRoutes,
166
160
  // ...(options.excludedRoutes || [])
167
161
  // ];
168
162
  // // precompile matchers for performance
@@ -1 +1 @@
1
- {"version":3,"file":"validateAuthorization.js","sourceRoot":"","sources":["../../../src/middlewares/request/validateAuthorization.ts"],"names":[],"mappings":";;;AAEA,kDAAkD;AAElD,mDAAuC;AACvC,6CAA6C;AAC7C,kDAAkD;AAElD,8CAA8C;AAE9C,6CAA6C;AAC7C,mCAAmF;AACnF,mCAAyC;AACzC,yCAAkD;AAElD,6BAA6B;AAC7B,MAAM,UAAU,GAAG,IAAA,4BAAoB,GAAE,CAAA;AAEzC,6CAA6C;AAE7C,MAAM,qBAAqB,GAAG;IAC1B,aAAa;IACb,kCAAkC;IAClC,8BAA8B;IAC9B,8BAA8B;CACjC,CAAC;AA4BF;;GAEG;AACI,MAAM,qBAAqB,GAAG,CAAC,UAA+B;IACjE,cAAc,EAAE,EAAE;CACrB,EAAE,EAAE;IACD,MAAM,c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WAAW;AACX,2EAA2E;AAE3E,4DAA4D;AAC5D,+BAA+B;AAC/B,oCAAoC;AACpC,4CAA4C;AAC5C,SAAS;AAET,6CAA6C;AAC7C,oGAAoG;AAEpG,0EAA0E;AAE1E,sDAAsD;AACtD,uEAAuE;AACvE,eAAe;AAEf,gEAAgE;AAEhE,gFAAgF;AAEhF,uDAAuD;AAEvD,wDAAwD;AAExD,mEAAmE;AACnE,6DAA6D;AAE7D,iDAAiD;AACjD,gEAAgE;AAEhE,gBAAgB;AAEhB,4BAA4B;AAC5B,6BAA6B;AAC7B,2BAA2B;AAC3B,sCAAsC;AACtC,qDAAqD;AACrD,0BAA0B;AAC1B,0BAA0B;AAC1B,+CAA+C;AAC/C,qBAAqB;AAErB,yBAAyB;AACzB,gBAAgB;AAEhB,uGAAuG;AACvG,yFAAyF;AAEzF,gCAAgC;AAChC,wDAAwD;AACxD,wDAAwD;AACxD,4DAA4D;AAE5D,iCAAiC;AACjC,yFAAyF;AACzF,gFAAgF;AAEhF,kDAAkD;AAClD,6CAA6C;AAC7C,gEAAgE;AAChE,uBAAuB;AACvB,qJAAqJ;AACrJ,gBAAgB;AAEhB,uJAAuJ;AAEvJ,uEAAuE;AACvE,6EAA6E;AAE7E,iDAAiD;AACjD,gDAAgD;AAChD,sDAAsD;AACtD,oCAAoC;AACpC,+DAA+D;AAC/D,gBAAgB;AAChB,2CAA2C;AAC3C,6EAA6E;AAE7E,wDAAwD;AAExD,4BAA4B;AAE5B,yBAAyB;AACzB,uBAAuB;AACvB,kCAAkC;AAClC,8CAA8C;AAC9C,sBAAsB;AACtB,sBAAsB;AACtB,2CAA2C;AAC3C,iBAAiB;AAEjB,qBAAqB;AACrB,YAAY;AAEZ,QAAQ;AAER,KAAK","sourcesContent":["import { Request, Response, NextFunction } from \"express\";\n\n// import jwt, { JwtPayload } from \"jsonwebtoken\";\n\nimport { match } from \"path-to-regexp\";\n// Library-safe import (CJS + ESM compatible)\n// const pathToRegexp = require(\"path-to-regexp\");\n\n// import { storeJwtInMemory } from \"@/utils\";\n\n// import { config } from \"@/configs/config\";\nimport { sendError, HTTP_STATUS, getCoreConfiguration, throwError } from \"@/utils\";\nimport { verifyAuthToken } from \"@/utils\"\nimport { AccessKeyUtilService } from \"@/services\";\n\n// retrive core configuration\nconst coreConfig = getCoreConfiguration()\n\n// import { AuthJwtToken } from \"@/services\";\n\nconst defaultExcludedRoutes = [\n '/auth/token',\n // '/api/tools/generatesignature',\n // '/api/tools/generatetoken',\n // add more defaults if needed\n];\n\n// const excludedRoutes = [\n// '/auth/token'\n// ]; // List of excluded routes\n\ntype ValidateAuthOptions = {\n excludedRoutes: string[];\n}\n\n// interface AuthJwtPayload extends JwtPayload {\n// user?: { id: number, user_id: number, user_type: AuthType };\n// account?: { id: number, account_id: number };\n// }\n\nexport type AuthorizeRequest = Request & {\n accountId: number\n actionUserId: number,\n auth: {\n accountId: number,\n actionUserId: number,\n authToken: string,\n isOperator: boolean\n accessKey?: string\n accessKeyId?: string\n }\n}\n\n/**\n * Combined middleware: JWT or Access Key\n */\nexport const validateAuthorization = (options: ValidateAuthOptions = {\n excludedRoutes: []\n}) => {\n const excludedRoutes = [...defaultExcludedRoutes, ...(options.excludedRoutes || [])];\n\n const matchers = excludedRoutes.map((route) => match(route, { decode: decodeURIComponent }));\n\n // const matchers = excludedRoutes.map((route) => {\n // const regex = pathToRegexp(route); // works for all versions\n // return (path: string) => regex.test(path); // returns boolean\n // });\n\n return async (req: Request, res: Response, next: NextFunction) => {\n try {\n const isExcluded = matchers.some((m) => m(req.path));\n if (isExcluded) return next();\n\n const authHeader = req.headers.authorization;\n const accessKeyHeader = req.headers[\"x-access-key\"] as string;\n\n const reqTyped = req as AuthorizeRequest;\n\n // Try Access Key first\n if (accessKeyHeader) {\n const valid = await validateAccessKeyMiddleware(accessKeyHeader, reqTyped, res);\n // console.log('reqTyped', reqTyped)\n if (valid) return next();\n\n throwError(`Invalid access key`)\n // return sendError(res, \"UNAUTHORIZED\", \"Invalid access key\", \"\", \"\", HTTP_STATUS.UNAUTHORIZED);\n }\n\n // Fallback: JWT\n if (!authHeader) {\n throwError(`Missing authorization token or access key`)\n // return sendError(res, \"UNAUTHORIZED\", \"\", \"\", \"Missing authorization token or access key\", HTTP_STATUS.UNAUTHORIZED);\n }\n\n const token = authHeader.split(\" \")[1];\n\n if (!token) {\n throwError(`Invalid authorization token format`)\n // return sendError(res, \"UNAUTHORIZED\", \"Invalid authorization token format\", \"\", \"\", HTTP_STATUS.UNAUTHORIZED);\n }\n\n const valid = validateJWT(token, reqTyped, res, next);\n\n if (valid) return next();\n\n } catch (err: any) {\n // console.error(\"Authorization error:\", err);\n // throwError(`Unauthorized: ${err}`)\n // sendError(res, \"UNAUTHORIZED\", \"Unauthorized\", \"\", \"\", HTTP_STATUS.UNAUTHORIZED);\n\n sendError(\n res,\n \"UNAUTHORIZED\",\n `${err?.message ?? err}`,\n \"\",\n \"\",\n HTTP_STATUS.UNAUTHORIZED\n );\n\n return\n }\n };\n};\n\n/**\n * Validate Access Key\n */\nexport const validateAccessKeyMiddleware = async (accessKey: string, req: AuthorizeRequest, res: Response) => {\n try {\n\n const accessKeyUtilService = AccessKeyUtilService({\n accessKeyUserType: \"administrator\",\n accountId: 0,\n actionUserId: 0,\n authToken: \"\",\n isOperator: true,\n prisma: (req as any).prisma\n })\n\n const accessKeyData = await accessKeyUtilService.validateAccessKey({ data: { accessKey } });\n\n // console.log('ac', accessKeyData)\n\n req.accountId = Number(accessKeyData.accountid);\n req.actionUserId = Number(accessKeyData.user_id);\n req.auth = {\n accountId: Number(accessKeyData.accountid),\n actionUserId: Number(accessKeyData.user_id),\n authToken: \"\",\n isOperator: Boolean(accessKeyData.user_type === \"operator\"),\n accessKeyId: `${accessKeyData?.key_id}`,\n accessKey: `${accessKey}`\n // isAccessKey: true,\n // accessKeyId: accessKeyData.access_key_id,\n };\n\n return true;\n } catch (err: any) {\n // sendError(res, \"UNAUTHORIZED\", err.message || \"Invalid access key\", \"\", \"\", HTTP_STATUS.UNAUTHORIZED);\n return false;\n }\n};\n\n/**\n * Validate JWT token\n */\nconst validateJWT = (token: string, req: AuthorizeRequest, res: Response, next: NextFunction) => {\n\n try {\n\n if (!token) {\n sendError(\n res,\n \"UNAUTHORIZED\",\n \"Invalid authorization token\",\n \"\",\n \"\",\n HTTP_STATUS.UNAUTHORIZED\n );\n\n return\n }\n\n // const authSecretKey = config.AUTH_SECRET_KEY\n const authSecretKey = coreConfig.authSecretKey\n\n // const jwtData = jwt.verify(token, authSecretKey) as AuthJwtToken; // Verify JWT token\n const jwtData = verifyAuthToken(token, authSecretKey); // Verify JWT token\n\n // for old format\n let accountId = jwtData?.account?.id ?? 0\n let actionUserId = jwtData?.user?.id ?? 0\n let userType = jwtData?.user?.user_type ?? \"\"\n\n // for new format \n if (jwtData?.account?.account_id) accountId = jwtData?.account?.account_id\n if (jwtData?.user?.user_id) actionUserId = jwtData?.user?.user_id\n\n // only check if not operator token\n if (userType === \"operator\") {\n accountId = 0; // always 0 for operator login\n } else {\n if (accountId === 0) throw sendError(res, \"UNAUTHORIZED\", \"Missing accountId in authorization\", \"\", \"\", HTTP_STATUS.UNAUTHORIZED);\n }\n\n if (actionUserId === 0) throw sendError(res, \"UNAUTHORIZED\", \"Missing actionUserId in authorization\", \"\", \"\", HTTP_STATUS.UNAUTHORIZED);\n\n (req as AuthorizeRequest).accountId = Number(accountId);\n (req as AuthorizeRequest).actionUserId = Number(actionUserId);\n\n (req as AuthorizeRequest).auth = {\n accountId: Number(accountId),\n actionUserId: Number(actionUserId),\n authToken: token,\n isOperator: Boolean(userType === \"operator\")\n }\n // storeJwtInMemory(jwtData)\n // req.jwtUser = jwtData; // Attach decoded payload to request\n\n // next(); // Proceed to the next middleware\n\n return true;\n\n } catch (error) {\n\n sendError(\n res,\n \"UNAUTHORIZED\",\n \"Invalid or expired token\",\n \"\",\n \"\",\n HTTP_STATUS.UNAUTHORIZED\n );\n\n // return\n return false;\n }\n}\n\n// original\n// export const validateAuthorization = (options: ValidateAuthOptions) => {\n\n// // Merge default excluded routes with any custom ones\n// const excludedRoutes = [\n// ...defaultExcludedRoutes,\n// ...(options.excludedRoutes || [])\n// ];\n\n// // precompile matchers for performance\n// const matchers = excludedRoutes.map((route) => match(route, { decode: decodeURIComponent }));\n\n// return (req: Request, res: Response, next: NextFunction): void => {\n\n// // if (excludedRoutes.includes(req.path)) {\n// // return next(); // Skip middleware for excluded routes\n// // }\n\n// const isExcluded = matchers.some((m) => m(req.path));\n\n// if (isExcluded) return next(); // Skip middleware for excluded routes\n\n// const authSecretKey = config.AUTH_SECRET_KEY\n\n// const authHeader = req.headers.authorization;\n\n// // console.log('in core - authSecretKey', authSecretKey)\n// // console.log('in core - authHeader', authHeader)\n\n// // Extract token from \"Bearer <token>\"\n// const token = authHeader && authHeader.split(\" \")[1];\n\n// try {\n\n// if (!token) {\n// sendError(\n// res,\n// \"UNAUTHORIZED\",\n// \"Invalid authorization token\",\n// \"\",\n// \"\",\n// HTTP_STATUS.UNAUTHORIZED\n// );\n\n// return\n// }\n\n// // const jwtData = jwt.verify(token, authSecretKey) as AuthJwtToken; // Verify JWT token\n// const jwtData = verifyAuthToken(token, authSecretKey); // Verify JWT token\n\n// // for old format\n// let accountId = jwtData?.account?.id ?? 0\n// let actionUserId = jwtData?.user?.id ?? 0\n// let userType = jwtData?.user?.user_type ?? \"\"\n\n// // for new format \n// if (jwtData?.account?.account_id) accountId = jwtData?.account?.account_id\n// if (jwtData?.user?.user_id) actionUserId = jwtData?.user?.user_id\n\n// // only check if not operator token\n// if (userType === \"operator\") {\n// accountId = 0; // always 0 for operator login\n// } else {\n// if (accountId === 0) throw sendError(res, \"UNAUTHORIZED\", \"Missing accountId in authorization\", \"\", \"\", HTTP_STATUS.UNAUTHORIZED);\n// }\n\n// if (actionUserId === 0) throw sendError(res, \"UNAUTHORIZED\", \"Missing actionUserId in authorization\", \"\", \"\", HTTP_STATUS.UNAUTHORIZED);\n\n// (req as AuthorizeRequest).accountId = Number(accountId);\n// (req as AuthorizeRequest).actionUserId = Number(actionUserId);\n\n// (req as AuthorizeRequest).auth = {\n// accountId: Number(accountId),\n// actionUserId: Number(actionUserId),\n// authToken: token,\n// isOperator: Boolean(userType === \"operator\")\n// }\n// // storeJwtInMemory(jwtData)\n// // req.jwtUser = jwtData; // Attach decoded payload to request\n\n// next(); // Proceed to the next middleware\n\n// } catch (error) {\n\n// sendError(\n// res,\n// \"UNAUTHORIZED\",\n// \"Invalid or expired token\",\n// \"\",\n// \"\",\n// HTTP_STATUS.UNAUTHORIZED\n// );\n\n// return\n// }\n\n// }\n\n// };"]}
1
+ {"version":3,"file":"validateAuthorization.js","sourceRoot":"","sources":["../../../src/middlewares/request/validateAuthorization.ts"],"names":[],"mappings":";;;AAEA,kDAAkD;AAElD,mDAAuC;AACvC,6CAA6C;AAC7C,kDAAkD;AAElD,8CAA8C;AAE9C,6CAA6C;AAC7C,mCAAmF;AACnF,mCAAyC;AACzC,yCAAkD;AAClD,qDAA6D;AAE7D,6BAA6B;AAC7B,MAAM,UAAU,GAAG,IAAA,4BAAoB,GAAE,CAAA;AAwCzC;;GAEG;AACI,MAAM,qBAAqB,GAAG,CAAC,UAA+B;IACjE,cAAc,EAAE,EAAE;CACrB,EAAE,EAAE;IACD,MAAM,cAAc,GAAG,CAAC,GAAG,0CAAyB,EAAE,GAAG,CAAC,OAAO,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,CAAC;IAEzF,MAAM,QAAQ,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,sBAAK,EAAC,KAAK,EAAE,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC;IAE7F,mDAAmD;IACnD,mEAAmE;IACnE,oEAAoE;IACpE,MAAM;IAEN,OAAO,KAAK,EAAE,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAE,EAAE;QAC7D,IAAI,CAAC;YACD,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,C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,qBAAqB;AAErB,yBAAyB;AACzB,gBAAgB;AAEhB,uGAAuG;AACvG,yFAAyF;AAEzF,gCAAgC;AAChC,wDAAwD;AACxD,wDAAwD;AACxD,4DAA4D;AAE5D,iCAAiC;AACjC,yFAAyF;AACzF,gFAAgF;AAEhF,kDAAkD;AAClD,6CAA6C;AAC7C,gEAAgE;AAChE,uBAAuB;AACvB,qJAAqJ;AACrJ,gBAAgB;AAEhB,uJAAuJ;AAEvJ,uEAAuE;AACvE,6EAA6E;AAE7E,iDAAiD;AACjD,gDAAgD;AAChD,sDAAsD;AACtD,oCAAoC;AACpC,+DAA+D;AAC/D,gBAAgB;AAChB,2CAA2C;AAC3C,6EAA6E;AAE7E,wDAAwD;AAExD,4BAA4B;AAE5B,yBAAyB;AACzB,uBAAuB;AACvB,kCAAkC;AAClC,8CAA8C;AAC9C,sBAAsB;AACtB,sBAAsB;AACtB,2CAA2C;AAC3C,iBAAiB;AAEjB,qBAAqB;AACrB,YAAY;AAEZ,QAAQ;AAER,KAAK","sourcesContent":["import { Request, Response, NextFunction } from \"express\";\n\n// import jwt, { JwtPayload } from \"jsonwebtoken\";\n\nimport { match } from \"path-to-regexp\";\n// Library-safe import (CJS + ESM compatible)\n// const pathToRegexp = require(\"path-to-regexp\");\n\n// import { storeJwtInMemory } from \"@/utils\";\n\n// import { config } from \"@/configs/config\";\nimport { sendError, HTTP_STATUS, getCoreConfiguration, throwError } from \"@/utils\";\nimport { verifyAuthToken } from \"@/utils\"\nimport { AccessKeyUtilService } from \"@/services\";\nimport { defaultAuthExcludedRoutes } from \"./validateHeader\";\n\n// retrive core configuration\nconst coreConfig = getCoreConfiguration()\n\n// import { AuthJwtToken } from \"@/services\";\n\n// const defaultAuthExcludedRoutes = [\n// '/auth/token',\n// '/reset_password/request',\n// '/reset_password/validate_code',\n// '/reset_password/perform',\n// // '/api/tools/generatesignature',\n// // '/api/tools/generatetoken',\n// // add more defaults if needed\n// ];\n\n// const excludedRoutes = [\n// '/auth/token'\n// ]; // List of excluded routes\n\ntype ValidateAuthOptions = {\n excludedRoutes: string[];\n}\n\n// interface AuthJwtPayload extends JwtPayload {\n// user?: { id: number, user_id: number, user_type: AuthType };\n// account?: { id: number, account_id: number };\n// }\n\nexport type AuthorizeRequest = Request & {\n accountId: number\n actionUserId: number,\n auth: {\n accountId: number,\n actionUserId: number,\n authToken: string,\n isOperator: boolean\n accessKey?: string\n accessKeyId?: string\n }\n}\n\n/**\n * Combined middleware: JWT or Access Key\n */\nexport const validateAuthorization = (options: ValidateAuthOptions = {\n excludedRoutes: []\n}) => {\n const excludedRoutes = [...defaultAuthExcludedRoutes, ...(options.excludedRoutes || [])];\n\n const matchers = excludedRoutes.map((route) => match(route, { decode: decodeURIComponent }));\n\n // const matchers = excludedRoutes.map((route) => {\n // const regex = pathToRegexp(route); // works for all versions\n // return (path: string) => regex.test(path); // returns boolean\n // });\n\n return async (req: Request, res: Response, next: NextFunction) => {\n try {\n const isExcluded = matchers.some((m) => m(req.path));\n if (isExcluded) return next();\n\n const authHeader = req.headers.authorization;\n const accessKeyHeader = req.headers[\"x-access-key\"] as string;\n\n const reqTyped = req as AuthorizeRequest;\n\n // Try Access Key first\n if (accessKeyHeader) {\n const valid = await validateAccessKeyMiddleware(accessKeyHeader, reqTyped, res);\n // console.log('reqTyped', reqTyped)\n if (valid) return next();\n\n throwError(`Invalid access key`)\n // return sendError(res, \"UNAUTHORIZED\", \"Invalid access key\", \"\", \"\", HTTP_STATUS.UNAUTHORIZED);\n }\n\n // Fallback: JWT\n if (!authHeader) {\n throwError(`Missing authorization token or access key`)\n // return sendError(res, \"UNAUTHORIZED\", \"\", \"\", \"Missing authorization token or access key\", HTTP_STATUS.UNAUTHORIZED);\n }\n\n const token = authHeader.split(\" \")[1];\n\n if (!token) {\n throwError(`Invalid authorization token format`)\n // return sendError(res, \"UNAUTHORIZED\", \"Invalid authorization token format\", \"\", \"\", HTTP_STATUS.UNAUTHORIZED);\n }\n\n const valid = validateJWT(token, reqTyped, res, next);\n\n if (valid) return next();\n\n } catch (err: any) {\n // console.error(\"Authorization error:\", err);\n // throwError(`Unauthorized: ${err}`)\n // sendError(res, \"UNAUTHORIZED\", \"Unauthorized\", \"\", \"\", HTTP_STATUS.UNAUTHORIZED);\n\n sendError(\n res,\n \"UNAUTHORIZED\",\n `${err?.message ?? err}`,\n \"\",\n \"\",\n HTTP_STATUS.UNAUTHORIZED\n );\n\n return\n }\n };\n};\n\n/**\n * Validate Access Key\n */\nexport const validateAccessKeyMiddleware = async (accessKey: string, req: AuthorizeRequest, res: Response) => {\n try {\n\n const accessKeyUtilService = AccessKeyUtilService({\n accessKeyUserType: \"administrator\",\n accountId: 0,\n actionUserId: 0,\n authToken: \"\",\n isOperator: true,\n prisma: (req as any).prisma\n })\n\n const accessKeyData = await accessKeyUtilService.validateAccessKey({ data: { accessKey } });\n\n // console.log('ac', accessKeyData)\n\n req.accountId = Number(accessKeyData.accountid);\n req.actionUserId = Number(accessKeyData.user_id);\n req.auth = {\n accountId: Number(accessKeyData.accountid),\n actionUserId: Number(accessKeyData.user_id),\n authToken: \"\",\n isOperator: Boolean(accessKeyData.user_type === \"operator\"),\n accessKeyId: `${accessKeyData?.key_id}`,\n accessKey: `${accessKey}`\n // isAccessKey: true,\n // accessKeyId: accessKeyData.access_key_id,\n };\n\n return true;\n } catch (err: any) {\n // sendError(res, \"UNAUTHORIZED\", err.message || \"Invalid access key\", \"\", \"\", HTTP_STATUS.UNAUTHORIZED);\n return false;\n }\n};\n\n/**\n * Validate JWT token\n */\nconst validateJWT = (token: string, req: AuthorizeRequest, res: Response, next: NextFunction) => {\n\n try {\n\n if (!token) {\n sendError(\n res,\n \"UNAUTHORIZED\",\n \"Invalid authorization token\",\n \"\",\n \"\",\n HTTP_STATUS.UNAUTHORIZED\n );\n\n return\n }\n\n // const authSecretKey = config.AUTH_SECRET_KEY\n const authSecretKey = coreConfig.authSecretKey\n\n // const jwtData = jwt.verify(token, authSecretKey) as AuthJwtToken; // Verify JWT token\n const jwtData = verifyAuthToken(token, authSecretKey); // Verify JWT token\n\n // for old format\n let accountId = jwtData?.account?.id ?? 0\n let actionUserId = jwtData?.user?.id ?? 0\n let userType = jwtData?.user?.user_type ?? \"\"\n\n // for new format \n if (jwtData?.account?.account_id) accountId = jwtData?.account?.account_id\n if (jwtData?.user?.user_id) actionUserId = jwtData?.user?.user_id\n\n // only check if not operator token\n if (userType === \"operator\") {\n accountId = 0; // always 0 for operator login\n } else {\n if (accountId === 0) throw sendError(res, \"UNAUTHORIZED\", \"Missing accountId in authorization\", \"\", \"\", HTTP_STATUS.UNAUTHORIZED);\n }\n\n if (actionUserId === 0) throw sendError(res, \"UNAUTHORIZED\", \"Missing actionUserId in authorization\", \"\", \"\", HTTP_STATUS.UNAUTHORIZED);\n\n (req as AuthorizeRequest).accountId = Number(accountId);\n (req as AuthorizeRequest).actionUserId = Number(actionUserId);\n\n (req as AuthorizeRequest).auth = {\n accountId: Number(accountId),\n actionUserId: Number(actionUserId),\n authToken: token,\n isOperator: Boolean(userType === \"operator\")\n }\n // storeJwtInMemory(jwtData)\n // req.jwtUser = jwtData; // Attach decoded payload to request\n\n // next(); // Proceed to the next middleware\n\n return true;\n\n } catch (error) {\n\n sendError(\n res,\n \"UNAUTHORIZED\",\n \"Invalid or expired token\",\n \"\",\n \"\",\n HTTP_STATUS.UNAUTHORIZED\n );\n\n // return\n return false;\n }\n}\n\n// original\n// export const validateAuthorization = (options: ValidateAuthOptions) => {\n\n// // Merge default excluded routes with any custom ones\n// const excludedRoutes = [\n// ...defaultAuthExcludedRoutes,\n// ...(options.excludedRoutes || [])\n// ];\n\n// // precompile matchers for performance\n// const matchers = excludedRoutes.map((route) => match(route, { decode: decodeURIComponent }));\n\n// return (req: Request, res: Response, next: NextFunction): void => {\n\n// // if (excludedRoutes.includes(req.path)) {\n// // return next(); // Skip middleware for excluded routes\n// // }\n\n// const isExcluded = matchers.some((m) => m(req.path));\n\n// if (isExcluded) return next(); // Skip middleware for excluded routes\n\n// const authSecretKey = config.AUTH_SECRET_KEY\n\n// const authHeader = req.headers.authorization;\n\n// // console.log('in core - authSecretKey', authSecretKey)\n// // console.log('in core - authHeader', authHeader)\n\n// // Extract token from \"Bearer <token>\"\n// const token = authHeader && authHeader.split(\" \")[1];\n\n// try {\n\n// if (!token) {\n// sendError(\n// res,\n// \"UNAUTHORIZED\",\n// \"Invalid authorization token\",\n// \"\",\n// \"\",\n// HTTP_STATUS.UNAUTHORIZED\n// );\n\n// return\n// }\n\n// // const jwtData = jwt.verify(token, authSecretKey) as AuthJwtToken; // Verify JWT token\n// const jwtData = verifyAuthToken(token, authSecretKey); // Verify JWT token\n\n// // for old format\n// let accountId = jwtData?.account?.id ?? 0\n// let actionUserId = jwtData?.user?.id ?? 0\n// let userType = jwtData?.user?.user_type ?? \"\"\n\n// // for new format \n// if (jwtData?.account?.account_id) accountId = jwtData?.account?.account_id\n// if (jwtData?.user?.user_id) actionUserId = jwtData?.user?.user_id\n\n// // only check if not operator token\n// if (userType === \"operator\") {\n// accountId = 0; // always 0 for operator login\n// } else {\n// if (accountId === 0) throw sendError(res, \"UNAUTHORIZED\", \"Missing accountId in authorization\", \"\", \"\", HTTP_STATUS.UNAUTHORIZED);\n// }\n\n// if (actionUserId === 0) throw sendError(res, \"UNAUTHORIZED\", \"Missing actionUserId in authorization\", \"\", \"\", HTTP_STATUS.UNAUTHORIZED);\n\n// (req as AuthorizeRequest).accountId = Number(accountId);\n// (req as AuthorizeRequest).actionUserId = Number(actionUserId);\n\n// (req as AuthorizeRequest).auth = {\n// accountId: Number(accountId),\n// actionUserId: Number(actionUserId),\n// authToken: token,\n// isOperator: Boolean(userType === \"operator\")\n// }\n// // storeJwtInMemory(jwtData)\n// // req.jwtUser = jwtData; // Attach decoded payload to request\n\n// next(); // Proceed to the next middleware\n\n// } catch (error) {\n\n// sendError(\n// res,\n// \"UNAUTHORIZED\",\n// \"Invalid or expired token\",\n// \"\",\n// \"\",\n// HTTP_STATUS.UNAUTHORIZED\n// );\n\n// return\n// }\n\n// }\n\n// };"]}
@@ -1,2 +1,3 @@
1
1
  import { Request, Response, NextFunction } from "express";
2
+ export declare const defaultAuthExcludedRoutes: string[];
2
3
  export declare const validateHeader: (req: Request, res: Response, next: NextFunction) => void;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.validateHeader = void 0;
6
+ exports.validateHeader = exports.defaultAuthExcludedRoutes = void 0;
7
7
  const utils_1 = require("../../utils");
8
8
  // import { schemaRequestHeader } from "../../schema/middleware/request";
9
9
  const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
@@ -12,14 +12,23 @@ const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
12
12
  const coreConfig = (0, utils_1.getCoreConfiguration)();
13
13
  // const authSecretKey = config.AUTH_SECRET_KEY
14
14
  const authSecretKey = coreConfig.authSecretKey;
15
- const excludedRoutes = [
15
+ exports.defaultAuthExcludedRoutes = [
16
+ '/auth/token',
17
+ '/reset_password/request',
18
+ '/reset_password/validate_code',
19
+ '/reset_password/perform',
16
20
  // '/api/tools/generatesignature',
17
21
  // '/api/tools/generatetoken',
18
- // '/api/auth/token'
19
- '/auth/token'
20
- ]; // List of excluded routes
22
+ // add more defaults if needed
23
+ ];
24
+ // const defaultAuthExcludedRoutes = [
25
+ // // '/api/tools/generatesignature',
26
+ // // '/api/tools/generatetoken',
27
+ // // '/api/auth/token'
28
+ // '/auth/token'
29
+ // ]; // List of excluded routes
21
30
  const validateHeader = (req, res, next) => {
22
- if (excludedRoutes.includes(req.path)) {
31
+ if (exports.defaultAuthExcludedRoutes.includes(req.path)) {
23
32
  return next(); // Skip middleware for excluded routes
24
33
  }
25
34
  // const result = schemaRequestHeader.safeParse(req.headers)
@@ -1 +1 @@
1
- {"version":3,"file":"validateHeader.js","sourceRoot":"","sources":["../../../src/middlewares/request/validate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ormattedZodErrors, getCoreConfiguration } from \"@/utils\";\n\n// import { schemaRequestHeader } from \"../../schema/middleware/request\";\n\nimport jwt from \"jsonwebtoken\";\n\n// import { config } from \"@/configs\";\n\n// retrive core configuration\nconst coreConfig = getCoreConfiguration()\n\n// const authSecretKey = config.AUTH_SECRET_KEY\nconst authSecretKey = coreConfig.authSecretKey\n\nconst excludedRoutes = [\n // '/api/tools/generatesignature',\n // '/api/tools/generatetoken',\n // '/api/auth/token'\n '/auth/token'\n]; // List of excluded routes\n\nexport const validateHeader = (req: Request, res: Response, next: NextFunction): void => {\n\n if (excludedRoutes.includes(req.path)) {\n return next(); // Skip middleware for excluded routes\n }\n\n // const result = schemaRequestHeader.safeParse(req.headers)\n\n // // console.log('result', result)\n\n // if (!result.success) {\n\n // const formattedErrors = getFormattedZodErrors(result.error)\n\n // sendError(\n // res,\n // \"UNAUTHORIZED\",\n // \"Missing or invalid headers\",\n // \"\",\n // // `${JSON.stringify(formattedErrors)}`,\n // ``,\n // HTTP_STATUS.UNAUTHORIZED\n // );\n // return\n\n // }\n\n\n // Get Authorization: Bearer <token>\n const authHeader = req.headers[\"authorization\"];\n // Get Access Key header\n const accessKeyHeader = req.headers[\"x-access-key\"] as string | undefined;\n\n // if (!authHeader && !accessKeyHeader) {\n // sendError(\n // res,\n // \"UNAUTHORIZED\",\n // \"Missing authorization token or access key\",\n // \"\",\n // \"\",\n // HTTP_STATUS.UNAUTHORIZED\n // );\n // return;\n // }\n\n if (authHeader && !authHeader.startsWith(\"Bearer \")) {\n sendError(\n res,\n \"UNAUTHORIZED\",\n \"Authorization header missing or malformed\",\n \"\",\n \"\",\n HTTP_STATUS.UNAUTHORIZED\n );\n return;\n }\n\n // If Access Key exists, just ensure it has a key.secret format\n if (accessKeyHeader && !accessKeyHeader.includes(\".\")) {\n sendError(\n res,\n \"UNAUTHORIZED\",\n \"Access key malformed. Must be keyId.keySecret\",\n \"\",\n \"\",\n HTTP_STATUS.UNAUTHORIZED\n );\n return;\n }\n\n // JWT exists and well-formed\n if (authHeader && authHeader.startsWith(\"Bearer \")) {\n\n const token = authHeader.split(\" \")[1];\n\n try {\n // Verify token using secret from .env\n const decoded = jwt.verify(token, authSecretKey);\n\n // Attach decoded payload to request for later use\n (req as any).user = decoded;\n return next();\n } catch (err: any) {\n sendError(\n res,\n \"UNAUTHORIZED\",\n \"Invalid or expired token\",\n \"\",\n err.message,\n HTTP_STATUS.UNAUTHORIZED\n );\n return;\n }\n\n // return next(); // Let the next middleware handle actual JWT verification\n }\n\n // Access Key exists and looks correct\n if (accessKeyHeader && accessKeyHeader.includes(\".\")) {\n return next(); // Let the next middleware handle access key validation\n }\n\n // If neither valid, reject\n sendError(\n res,\n \"UNAUTHORIZED\",\n \"Authorization header missing or malformed, or access key invalid\",\n \"\",\n \"\",\n HTTP_STATUS.UNAUTHORIZED\n );\n\n\n};"]}
1
+ {"version":3,"file":"validateHeader.js","sourceRoot":"","sources":["../../../src/middlewares/request/validateHeader.ts"],"names":[],"mappings":";;;;;;AAEA,mCAA8F;AAE9F,yEAAyE;AAEzE,gEAA+B;AAE/B,sCAAsC;AAEtC,6BAA6B;AAC7B,MAAM,UAAU,GAAG,IAAA,4BAAoB,GAAE,CAAA;AAEzC,+CAA+C;AAC/C,MAAM,aAAa,GAAG,UAAU,CAAC,aAAa,CAAA;AAEjC,QAAA,yBAAyB,GAAG;IACrC,aAAa;IACb,yBAAyB;IACzB,+BAA+B;IAC/B,yBAAyB;IACzB,kCAAkC;IAClC,8BAA8B;IAC9B,8BAA8B;CACjC,CAAC;AAEF,sCAAsC;AACtC,yCAAyC;AACzC,qCAAqC;AACrC,2BAA2B;AAC3B,oBAAoB;AACpB,gCAAgC;AAEzB,MAAM,cAAc,GAAG,CAAC,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAQ,EAAE;IAEpF,IAAI,iCAAyB,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/C,OAAO,IAAI,EAAE,CAAC,C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KAAK,EAAE,aAAa,CAAC,CAAC;YAEjD,kDAAkD;YACjD,GAAW,CAAC,IAAI,GAAG,OAAO,CAAC;YAC5B,OAAO,IAAI,EAAE,CAAC;QAClB,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAChB,IAAA,iBAAS,EACL,GAAG,EACH,cAAc,EACd,0BAA0B,EAC1B,EAAE,EACF,GAAG,CAAC,OAAO,EACX,mBAAW,CAAC,YAAY,CAC3B,CAAC;YACF,OAAO;QACX,CAAC;QAED,2EAA2E;IAC/E,CAAC;IAED,sCAAsC;IACtC,IAAI,eAAe,IAAI,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACnD,OAAO,IAAI,EAAE,CAAC,CAAC,uDAAuD;IAC1E,CAAC;IAED,2BAA2B;IAC3B,IAAA,iBAAS,EACL,GAAG,EACH,cAAc,EACd,kEAAkE,EAClE,EAAE,EACF,EAAE,EACF,mBAAW,CAAC,YAAY,CAC3B,CAAC;AAGN,CAAC,CAAC;AAjHW,QAAA,cAAc,kBAiHzB","sourcesContent":["import { Request, Response, NextFunction } from \"express\";\n\nimport { sendError, HTTP_STATUS, getFormattedZodErrors, getCoreConfiguration } from \"@/utils\";\n\n// import { schemaRequestHeader } from \"../../schema/middleware/request\";\n\nimport jwt from \"jsonwebtoken\";\n\n// import { config } from \"@/configs\";\n\n// retrive core configuration\nconst coreConfig = getCoreConfiguration()\n\n// const authSecretKey = config.AUTH_SECRET_KEY\nconst authSecretKey = coreConfig.authSecretKey\n\nexport const defaultAuthExcludedRoutes = [\n '/auth/token',\n '/reset_password/request',\n '/reset_password/validate_code',\n '/reset_password/perform',\n // '/api/tools/generatesignature',\n // '/api/tools/generatetoken',\n // add more defaults if needed\n];\n\n// const defaultAuthExcludedRoutes = [\n// // '/api/tools/generatesignature',\n// // '/api/tools/generatetoken',\n// // '/api/auth/token'\n// '/auth/token'\n// ]; // List of excluded routes\n\nexport const validateHeader = (req: Request, res: Response, next: NextFunction): void => {\n\n if (defaultAuthExcludedRoutes.includes(req.path)) {\n return next(); // Skip middleware for excluded routes\n }\n\n // const result = schemaRequestHeader.safeParse(req.headers)\n\n // // console.log('result', result)\n\n // if (!result.success) {\n\n // const formattedErrors = getFormattedZodErrors(result.error)\n\n // sendError(\n // res,\n // \"UNAUTHORIZED\",\n // \"Missing or invalid headers\",\n // \"\",\n // // `${JSON.stringify(formattedErrors)}`,\n // ``,\n // HTTP_STATUS.UNAUTHORIZED\n // );\n // return\n\n // }\n\n\n // Get Authorization: Bearer <token>\n const authHeader = req.headers[\"authorization\"];\n // Get Access Key header\n const accessKeyHeader = req.headers[\"x-access-key\"] as string | undefined;\n\n // if (!authHeader && !accessKeyHeader) {\n // sendError(\n // res,\n // \"UNAUTHORIZED\",\n // \"Missing authorization token or access key\",\n // \"\",\n // \"\",\n // HTTP_STATUS.UNAUTHORIZED\n // );\n // return;\n // }\n\n if (authHeader && !authHeader.startsWith(\"Bearer \")) {\n sendError(\n res,\n \"UNAUTHORIZED\",\n \"Authorization header missing or malformed\",\n \"\",\n \"\",\n HTTP_STATUS.UNAUTHORIZED\n );\n return;\n }\n\n // If Access Key exists, just ensure it has a key.secret format\n if (accessKeyHeader && !accessKeyHeader.includes(\".\")) {\n sendError(\n res,\n \"UNAUTHORIZED\",\n \"Access key malformed. Must be keyId.keySecret\",\n \"\",\n \"\",\n HTTP_STATUS.UNAUTHORIZED\n );\n return;\n }\n\n // JWT exists and well-formed\n if (authHeader && authHeader.startsWith(\"Bearer \")) {\n\n const token = authHeader.split(\" \")[1];\n\n try {\n // Verify token using secret from .env\n const decoded = jwt.verify(token, authSecretKey);\n\n // Attach decoded payload to request for later use\n (req as any).user = decoded;\n return next();\n } catch (err: any) {\n sendError(\n res,\n \"UNAUTHORIZED\",\n \"Invalid or expired token\",\n \"\",\n err.message,\n HTTP_STATUS.UNAUTHORIZED\n );\n return;\n }\n\n // return next(); // Let the next middleware handle actual JWT verification\n }\n\n // Access Key exists and looks correct\n if (accessKeyHeader && accessKeyHeader.includes(\".\")) {\n return next(); // Let the next middleware handle access key validation\n }\n\n // If neither valid, reject\n sendError(\n res,\n \"UNAUTHORIZED\",\n \"Authorization header missing or malformed, or access key invalid\",\n \"\",\n \"\",\n HTTP_STATUS.UNAUTHORIZED\n );\n\n\n};"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/schema/payload/index.ts"],"names":[],"mappings":";;;;AACA,yEAA+G;AAAtG,yHAAA,sBAAsB,OAAA;AAAE,iIAAA,8BAA8B,OAAA;AAG/D,+EAAyH;AAAhH,+HAAA,4BAA4B,OAAA;AAAE,+HAAA,4BAA4B,OAAA;AAGnE,2FAAmL;AAA1K,wIAAA,iCAAiC,OAAA;AAAE,6IAAA,sCAAsC,OAAA;AAAE,wIAAA,iCAAiC,OAAA;AAGrH,wEAA4I;AAAnI,2HAAA,0BAA0B,OAAA;AAAE,2HAAA,0BAA0B,OAAA;AAAE,2HAAA,0BAA0B,OAAA;AAG3F,2EAAiK;AAAxJ,6HAAA,2BAA2B,OAAA;AAAE,gHAAA,cAAc,OAAA;AAAE,6HAAA,2BAA2B,OAAA;AAAE,6HAAA,2BAA2B,OAAA;AAG9G,+DAAiG;AAAxF,qHAAA,uBAAuB,OAAA;AAAE,kHAAA,oBAAoB,OAAA;AAEtD,+EAA4H;AAAnH,qIAAA,+BAA+B,OAAA;AAAE,qIAAA,+BAA+B,OAAA;AAEzE,+EAA4H;AAAnH,qIAAA,+BAA+B,OAAA;AAAE,qIAAA,+BAA+B,OAAA;AAEzE,+EAA4H;AAAnH,qIAAA,+BAA+B,OAAA;AAAE,qIAAA,+BAA+B,OAAA;AAEzE,yFAA2I;AAAlI,+IAAA,oCAAoC,OAAA;AAAE,+IAAA,oCAAoC,OAAA;AAEnF,2EAAsH;AAA7G,iIAAA,6BAA6B,OAAA;AAAE,iIAAA,6BAA6B,OAAA;AAErE,2EAAsH;AAA7G,iIAAA,6BAA6B,OAAA;AAAE,iIAAA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+B,OAAA;AAAE,qIAAA,+BAA+B,OAAA;AAAE,qIAAA,+BAA+B,OAAA;AAE1G,mFAA6K;AAApK,qIAAA,+BAA+B,OAAA;AAAE,qIAAA,+BAA+B,OAAA;AAAE,qIAAA,+BAA+B,OAAA;AAAE,gHAAA,UAAU,OAAA;AAGtH,8FAAiL;AAAxK,0IAAA,kCAAkC,OAAA;AAAE,yIAAA,iCAAiC,OAAA;AAAE,yIAAA,iCAAiC,OAAA;AAGjH,mFAAmK;AAA1J,uIAAA,gCAAgC,OAAA;AAAE,uIAAA,gCAAgC,OAAA;AAAE,uIAAA,gCAAgC,OAAA;AAE7G,+EAA2J;AAAlJ,mIAAA,8BAA8B,OAAA;AAAE,mIAAA,8BAA8B,OAAA;AAAE,mIAAA,8BAA8B,OAAA;AAEvG,6EAAwJ;AAA/I,iIAAA,6BAA6B,OAAA;AAAE,iIAAA,6BAA6B,OAAA;AAAE,iIAAA,6BAA6B,OAAA;AAGpG,4FAAkG;AAAzF,2IAAA,+BAA+B,OAAA;AAExC,kFAAwI;AAA/H,yIAAA,kCAAkC,OAAA;AAAE,6IAAA,sCAAsC,OAAA","sourcesContent":["\nexport { schemaAuthTokenPayload, schemaAuthTokenOperatorPayload } from \"@/schema/payload/auth/schemaAuthToken\";\nexport type { SchemaAuthTokenPayload, SchemaAuthTokenOperatorPayload } from \"@/schema/payload/auth/schemaAuthToken\";\n\nexport { schemaAccessKeyCreatePayload, schemaAccessKeyRevokePayload } from \"@/schema/payload/access_key/schemaAccessKey\";\nexport type { SchemaAccessKeyCreatePayload, SchemaAccessKeyRevokePayload } from \"@/schema/payload/access_key/schemaAccessKey\";\n\nexport { schemaResetPasswordRequestPayload, schemaResetPasswordValidateCodePayload, schemaResetPasswordPerformPayload } from \"@/schema/payload/reset_password/schemaResetPassword\";\nexport type { SchemaResetPasswordRequestPayload, SchemaResetPasswordValidateCodePayload, SchemaResetPasswordPerformPayload } from \"@/schema/payload/reset_password/schemaResetPassword\";\n\nexport { schemaAccountCreatePayload, schemaAccountUpdatePayload, schemaAccountDeletePayload } from \"@/schema/payload/account/schemaAccount\";\nexport type { SchemaAccountCreatePayload, SchemaAccountUpdatePayload, SchemaAccountDeletePayload } from \"@/schema/payload/account/schemaAccount\";\n\nexport { schemaBusinessCreatePayload, schemaBusiness, schemaBusinessUpdatePayload, schemaBusinessDeletePayload } from \"@/schema/payload/business/schemaBusiness\";\nexport type { SchemaBusinessCreatePayload, SchemaBusinessUpdatePayload, SchemaBusinessDeletePayload } from \"@/schema/payload/business/schemaBusiness\";\n\nexport { schemaUserDeletePayload, schemaUserCredential } from \"@/schema/payload/user/schemaUser\";\nexport type { SchemaUserDeletePayload } from \"@/schema/payload/user/schemaUser\";\nexport { schemaUserOperatorCreatePayload, schemaUserOperatorUpdatePayload } from \"@/schema/payload/user/schemaUserOperator\";\nexport type { SchemaUserOperatorCreatePayload, SchemaUserOperatorUpdatePayload } from \"@/schema/payload/user/schemaUserOperator\";\nexport { schemaUserCustomerCreatePayload, schemaUserCustomerUpdatePayload } from \"@/schema/payload/user/schemaUserCustomer\";\nexport type { SchemaUserCustomerCreatePayload, SchemaUserCustomerUpdatePayload } from \"@/schema/payload/user/schemaUserCustomer\";\nexport { schemaUserRetailerCreatePayload, schemaUserRetailerUpdatePayload } from \"@/schema/payload/user/schemaUserRetailer\";\nexport type { SchemaUserRetailerCreatePayload, SchemaUserRetailerUpdatePayload } from \"@/schema/payload/user/schemaUserRetailer\";\nexport { schemaUserAdministratorCreatePayload, schemaUserAdministratorUpdatePayload } from \"@/schema/payload/user/schemaUserAdministrator\";\nexport type { SchemaUserAdministratorCreatePayload, SchemaUserAdministratorUpdatePayload } from \"@/schema/payload/user/schemaUserAdministrator\";\nexport { schemaUserWorkerCreatePayload, schemaUserWorkerUpdatePayload } from \"@/schema/payload/user/schemaUserWorker\";\nexport type { SchemaUserWorkerCreatePayload, SchemaUserWorkerUpdatePayload } from \"@/schema/payload/user/schemaUserWorker\";\nexport { schemaUserDriverCreatePayload, schemaUserDriverUpdatePayload } from \"@/schema/payload/user/schemaUserDriver\";\nexport type { SchemaUserDriverCreatePayload, SchemaUserDriverUpdatePayload } from \"@/schema/payload/user/schemaUserDriver\";\nexport { schemaUserMemberCreatePayload, schemaUserMemberUpdatePayload } from \"@/schema/payload/user/schemaUserMember\";\nexport type { SchemaUserMemberCreatePayload, SchemaUserMemberUpdatePayload } from \"@/schema/payload/user/schemaUserMember\";\n\nexport { schemaFileUploadPayload, schemaFileDeletePayload } from \"@/schema/payload/file/schemaFile\";\nexport type { SchemaFileUploadPayload, SchemaFileDeletePayload } from \"@/schema/payload/file/schemaFile\";\n\nexport { schemaDocumentDeletePayload, eNumDocumentTypes } from \"@/schema/payload/document/schemaDocument\";\nexport type { SchemaDocumentDeletePayload } from \"@/schema/payload/document/schemaDocument\";\nexport { schemaDocumentSalesOrderCreatePayload, schemaDocumentSalesOrderUpdatePayload } from \"@/schema/payload/document/schemaDocumentSalesOrder\";\nexport type { SchemaDocumentSalesOrderCreatePayload, SchemaDocumentSalesOrderUpdatePayload } from \"@/schema/payload/document/schemaDocumentSalesOrder\";\nexport { schemaDocumentProformaSalesCreatePayload, schemaDocumentProformaSalesUpdatePayload } from \"@/schema/payload/document/schemaDocumentProformaSales\";\nexport type { SchemaDocumentProformaSalesCreatePayload, SchemaDocumentProformaSalesUpdatePayload } from \"@/schema/payload/document/schemaDocumentProformaSales\";\nexport { schemaDocumentDeliveryOrderCreatePayload, schemaDocumentDeliveryOrderUpdatePayload } from \"@/schema/payload/document/schemaDocumentDeliveryOrder\";\nexport type { SchemaDocumentDeliveryOrderCreatePayload, SchemaDocumentDeliveryOrderUpdatePayload } from \"@/schema/payload/document/schemaDocumentDeliveryOrder\";\nexport { schemaDocumentReplacementDeliveryOrderCreatePayload, schemaDocumentReplacementDeliveryOrderUpdatePayload } from \"@/schema/payload/document/schemaDocumentReplacementDeliveryOrder\";\nexport type { SchemaDocumentReplacementDeliveryOrderCreatePayload, SchemaDocumentReplacementDeliveryOrderUpdatePayload } from \"@/schema/payload/document/schemaDocumentReplacementDeliveryOrder\";\nexport { schemaDocumentCashSalesCreatePayload, schemaDocumentCashSalesUpdatePayload } from \"@/schema/payload/document/schemaDocumentCashSales\";\nexport type { SchemaDocumentCashSalesCreatePayload, SchemaDocumentCashSalesUpdatePayload } from \"@/schema/payload/document/schemaDocumentCashSales\";\nexport { schemaDocumentTripOrderCreatePayload, schemaDocumentTripOrderUpdatePayload } from \"@/schema/payload/document/schemaDocumentTripOrder\";\nexport type { SchemaDocumentTripOrderCreatePayload, SchemaDocumentTripOrderUpdatePayload } from \"@/schema/payload/document/schemaDocumentTripOrder\";\n\nexport { schemaItemDeletePayload } from \"@/schema/payload/item/schemaItem\";\nexport type { SchemaItemDeletePayload } from \"@/schema/payload/item/schemaItem\";\nexport { schemaItemProductCreatePayload, schemaItemProductUpdatePayload } from \"@/schema/payload/item/schemaItemProduct\";\nexport type { SchemaItemProductCreatePayload, SchemaItemProductUpdatePayload } from \"@/schema/payload/item/schemaItemProduct\";\nexport { schemaItemItemCreatePayload, schemaItemItemUpdatePayload, schemaItemItem } from \"@/schema/payload/item/schemaItemItem\";\nexport type { SchemaItemItemCreatePayload, SchemaItemItemUpdatePayload } from \"@/schema/payload/item/schemaItemItem\";\nexport { schemaItemCategoryCreatePayload, schemaItemCategoryUpdatePayload } from \"@/schema/payload/item/schemaItemCategory\";\nexport type { SchemaItemCategoryCreatePayload, SchemaItemCategoryUpdatePayload } from \"@/schema/payload/item/schemaItemCategory\";\nexport { schemaItemBrandCreatePayload, schemaItemBrandUpdatePayload } from \"@/schema/payload/item/schemaItemBrand\";\nexport type { SchemaItemBrandCreatePayload, SchemaItemBrandUpdatePayload } from \"@/schema/payload/item/schemaItemBrand\";\nexport { schemaItemUomCreatePayload, schemaItemUomUpdatePayload } from \"@/schema/payload/item/schemaItemUom\";\nexport type { SchemaItemUomCreatePayload, SchemaItemUomUpdatePayload } from \"@/schema/payload/item/schemaItemUom\";\n\nexport { schemaLocationLocationCreatePayload, schemaLocationLocationUpdatePayload, schemaLocationLocationDeletePayload, } from \"@/schema/payload/location/schemaLocationLocation\";\nexport type { SchemaLocationLocationCreatePayload, SchemaLocationLocationUpdatePayload, SchemaLocationLocationDeletePayload } from \"@/schema/payload/location/schemaLocationLocation\";\nexport { schemaLocationRackCreatePayload, schemaLocationRackUpdatePayload, schemaLocationRackDeletePayload, } from \"@/schema/payload/location/schemaLocationRack\";\nexport type { SchemaLocationRackCreatePayload, SchemaLocationRackUpdatePayload, SchemaLocationRackDeletePayload } from \"@/schema/payload/location/schemaLocationRack\";\nexport { schemaLocationSlotCreatePayload, schemaLocationSlotUpdatePayload, schemaLocationSlotDeletePayload, schemaSlot } from \"@/schema/payload/location/schemaLocationSlot\";\nexport type { SchemaLocationSlotCreatePayload, SchemaLocationSlotUpdatePayload, SchemaLocationSlotDeletePayload } from \"@/schema/payload/location/schemaLocationSlot\";\n\nexport { schemaInjectionFieldReplacePayload, schemaInjectionFieldCreatePayload, schemaInjectionFieldDeletePayload } from \"@/schema/payload/injection_field/schemaInjectionField\";\nexport type { SchemaInjectionFieldReplacePayload, SchemaInjectionFieldCreatePayload, SchemaInjectionFieldDeletePayload } from \"@/schema/payload/injection_field/schemaInjectionField\";\n\nexport { schemaRegionCountryCreatePayload, schemaRegionCountryUpdatePayload, schemaRegionCountryDeletePayload } from \"@/schema/payload/region/schemaRegionCountry\";\nexport type { SchemaRegionCountryCreatePayload, SchemaRegionCountryDeletePayload } from \"@/schema/payload/region/schemaRegionCountry\";\nexport { schemaRegionStateCreatePayload, schemaRegionStateDeletePayload, schemaRegionStateUpdatePayload } from \"@/schema/payload/region/schemaRegionState\";\nexport type { SchemaRegionStateCreatePayload, SchemaRegionStateDeletePayload } from \"@/schema/payload/region/schemaRegionState\";\nexport { schemaRegionAreaCreatePayload, schemaRegionAreaDeletePayload, schemaRegionAreaUpdatePayload, } from \"@/schema/payload/region/schemaRegionArea\";\nexport type { SchemaRegionAreaCreatePayload, SchemaRegionAreaDeletePayload, SchemaRegionAreaUpdatePayload } from \"@/schema/payload/region/schemaRegionArea\";\n\nexport { schemaChangePasswordUtilPayload } from \"@/schema/payload/utils/schemaChangePasswordUtil\";\nexport type { SchemaChangePasswordUtilPayload } from \"@/schema/payload/utils/schemaChangePasswordUtil\";\nexport { schemaAccessKeyUtilValidatePayload, schemaAccessKeyUtilAccountOwnerPayload } from \"@/schema/payload/utils/schemaAccessKeyUtil\";\nexport type { SchemaAccessKeyUtilValidatePayload, SchemaAccessKeyUtilAccountOwnerPayload } from \"@/schema/payload/utils/schemaAccessKeyUtil\";"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/schema/payload/index.ts"],"names":[],"mappings":";;;;AAAA,yEAA+G;AAAtG,yHAAA,sBAAsB,OAAA;AAAE,iIAAA,8BAA8B,OAAA;AAG/D,+EAAyH;AAAhH,+HAAA,4BAA4B,OAAA;AAAE,+HAAA,4BAA4B,OAAA;AAGnE,2FAAmL;AAA1K,wIAAA,iCAAiC,OAAA;AAAE,6IAAA,sCAAsC,OAAA;AAAE,wIAAA,iCAAiC,OAAA;AAGrH,wEAA4I;AAAnI,2HAAA,0BAA0B,OAAA;AAAE,2HAAA,0BAA0B,OAAA;AAAE,2HAAA,0BAA0B,OAAA;AAG3F,2EAAiK;AAAxJ,6HAAA,2BAA2B,OAAA;AAAE,gHAAA,cAAc,OAAA;AAAE,6HAAA,2BAA2B,OAAA;AAAE,6HAAA,2BAA2B,OAAA;AAG9G,+DAAiG;AAAxF,qHAAA,uBAAuB,OAAA;AAAE,kHAAA,oBAAoB,OAAA;AAEtD,+EAA4H;AAAnH,qIAAA,+BAA+B,OAAA;AAAE,qIAAA,+BAA+B,OAAA;AAEzE,+EAA4H;AAAnH,qIAAA,+BAA+B,OAAA;AAAE,qIAAA,+BAA+B,OAAA;AAEzE,+EAA4H;AAAnH,qIAAA,+BAA+B,OAAA;AAAE,qIAAA,+BAA+B,OAAA;AAEzE,yFAA2I;AAAlI,+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AA0B,OAAA;AAAE,2HAAA,0BAA0B,OAAA;AAG/D,2FAAkL;AAAzK,6IAAA,mCAAmC,OAAA;AAAE,6IAAA,mCAAmC,OAAA;AAAE,6IAAA,mCAAmC,OAAA;AAEtH,mFAAkK;AAAzJ,qIAAA,+BAA+B,OAAA;AAAE,qIAAA,+BAA+B,OAAA;AAAE,qIAAA,+BAA+B,OAAA;AAE1G,mFAA6K;AAApK,qIAAA,+BAA+B,OAAA;AAAE,qIAAA,+BAA+B,OAAA;AAAE,qIAAA,+BAA+B,OAAA;AAAE,gHAAA,UAAU,OAAA;AAGtH,8FAAiL;AAAxK,0IAAA,kCAAkC,OAAA;AAAE,yIAAA,iCAAiC,OAAA;AAAE,yIAAA,iCAAiC,OAAA;AAGjH,mFAAmK;AAA1J,uIAAA,gCAAgC,OAAA;AAAE,uIAAA,gCAAgC,OAAA;AAAE,uIAAA,gCAAgC,OAAA;AAE7G,+EAA2J;AAAlJ,mIAAA,8BAA8B,OAAA;AAAE,mIAAA,8BAA8B,OAAA;AAAE,mIAAA,8BAA8B,OAAA;AAEvG,6EAAwJ;AAA/I,iIAAA,6BAA6B,OAAA;AAAE,iIAAA,6BAA6B,OAAA;AAAE,iIAAA,6BAA6B,OAAA;AAGpG,4FAAkG;AAAzF,2IAAA,+BAA+B,OAAA;AAExC,kFAAwI;AAA/H,yIAAA,kCAAkC,OAAA;AAAE,6IAAA,sCAAsC,OAAA","sourcesContent":["export { schemaAuthTokenPayload, schemaAuthTokenOperatorPayload } from \"@/schema/payload/auth/schemaAuthToken\";\nexport type { SchemaAuthTokenPayload, SchemaAuthTokenOperatorPayload } from \"@/schema/payload/auth/schemaAuthToken\";\n\nexport { schemaAccessKeyCreatePayload, schemaAccessKeyRevokePayload } from \"@/schema/payload/access_key/schemaAccessKey\";\nexport type { SchemaAccessKeyCreatePayload, SchemaAccessKeyRevokePayload } from \"@/schema/payload/access_key/schemaAccessKey\";\n\nexport { schemaResetPasswordRequestPayload, schemaResetPasswordValidateCodePayload, schemaResetPasswordPerformPayload } from \"@/schema/payload/reset_password/schemaResetPassword\";\nexport type { SchemaResetPasswordRequestPayload, SchemaResetPasswordValidateCodePayload, SchemaResetPasswordPerformPayload } from \"@/schema/payload/reset_password/schemaResetPassword\";\n\nexport { schemaAccountCreatePayload, schemaAccountUpdatePayload, schemaAccountDeletePayload } from \"@/schema/payload/account/schemaAccount\";\nexport type { SchemaAccountCreatePayload, SchemaAccountUpdatePayload, SchemaAccountDeletePayload } from \"@/schema/payload/account/schemaAccount\";\n\nexport { schemaBusinessCreatePayload, schemaBusiness, schemaBusinessUpdatePayload, schemaBusinessDeletePayload } from \"@/schema/payload/business/schemaBusiness\";\nexport type { SchemaBusinessCreatePayload, SchemaBusinessUpdatePayload, SchemaBusinessDeletePayload } from \"@/schema/payload/business/schemaBusiness\";\n\nexport { schemaUserDeletePayload, schemaUserCredential } from \"@/schema/payload/user/schemaUser\";\nexport type { SchemaUserDeletePayload } from \"@/schema/payload/user/schemaUser\";\nexport { schemaUserOperatorCreatePayload, schemaUserOperatorUpdatePayload } from \"@/schema/payload/user/schemaUserOperator\";\nexport type { SchemaUserOperatorCreatePayload, SchemaUserOperatorUpdatePayload } from \"@/schema/payload/user/schemaUserOperator\";\nexport { schemaUserCustomerCreatePayload, schemaUserCustomerUpdatePayload } from \"@/schema/payload/user/schemaUserCustomer\";\nexport type { SchemaUserCustomerCreatePayload, SchemaUserCustomerUpdatePayload } from \"@/schema/payload/user/schemaUserCustomer\";\nexport { schemaUserRetailerCreatePayload, schemaUserRetailerUpdatePayload } from \"@/schema/payload/user/schemaUserRetailer\";\nexport type { SchemaUserRetailerCreatePayload, SchemaUserRetailerUpdatePayload } from \"@/schema/payload/user/schemaUserRetailer\";\nexport { schemaUserAdministratorCreatePayload, schemaUserAdministratorUpdatePayload } from \"@/schema/payload/user/schemaUserAdministrator\";\nexport type { SchemaUserAdministratorCreatePayload, SchemaUserAdministratorUpdatePayload } from \"@/schema/payload/user/schemaUserAdministrator\";\nexport { schemaUserWorkerCreatePayload, schemaUserWorkerUpdatePayload } from \"@/schema/payload/user/schemaUserWorker\";\nexport type { SchemaUserWorkerCreatePayload, SchemaUserWorkerUpdatePayload } from \"@/schema/payload/user/schemaUserWorker\";\nexport { schemaUserDriverCreatePayload, schemaUserDriverUpdatePayload } from \"@/schema/payload/user/schemaUserDriver\";\nexport type { SchemaUserDriverCreatePayload, SchemaUserDriverUpdatePayload } from \"@/schema/payload/user/schemaUserDriver\";\nexport { schemaUserMemberCreatePayload, schemaUserMemberUpdatePayload } from \"@/schema/payload/user/schemaUserMember\";\nexport type { SchemaUserMemberCreatePayload, SchemaUserMemberUpdatePayload } from \"@/schema/payload/user/schemaUserMember\";\n\nexport { schemaFileUploadPayload, schemaFileDeletePayload } from \"@/schema/payload/file/schemaFile\";\nexport type { SchemaFileUploadPayload, SchemaFileDeletePayload } from \"@/schema/payload/file/schemaFile\";\n\nexport { schemaDocumentDeletePayload, eNumDocumentTypes } from \"@/schema/payload/document/schemaDocument\";\nexport type { SchemaDocumentDeletePayload } from \"@/schema/payload/document/schemaDocument\";\nexport { schemaDocumentSalesOrderCreatePayload, schemaDocumentSalesOrderUpdatePayload } from \"@/schema/payload/document/schemaDocumentSalesOrder\";\nexport type { SchemaDocumentSalesOrderCreatePayload, SchemaDocumentSalesOrderUpdatePayload } from \"@/schema/payload/document/schemaDocumentSalesOrder\";\nexport { schemaDocumentProformaSalesCreatePayload, schemaDocumentProformaSalesUpdatePayload } from \"@/schema/payload/document/schemaDocumentProformaSales\";\nexport type { SchemaDocumentProformaSalesCreatePayload, SchemaDocumentProformaSalesUpdatePayload } from \"@/schema/payload/document/schemaDocumentProformaSales\";\nexport { schemaDocumentDeliveryOrderCreatePayload, schemaDocumentDeliveryOrderUpdatePayload } from \"@/schema/payload/document/schemaDocumentDeliveryOrder\";\nexport type { SchemaDocumentDeliveryOrderCreatePayload, SchemaDocumentDeliveryOrderUpdatePayload } from \"@/schema/payload/document/schemaDocumentDeliveryOrder\";\nexport { schemaDocumentReplacementDeliveryOrderCreatePayload, schemaDocumentReplacementDeliveryOrderUpdatePayload } from \"@/schema/payload/document/schemaDocumentReplacementDeliveryOrder\";\nexport type { SchemaDocumentReplacementDeliveryOrderCreatePayload, SchemaDocumentReplacementDeliveryOrderUpdatePayload } from \"@/schema/payload/document/schemaDocumentReplacementDeliveryOrder\";\nexport { schemaDocumentCashSalesCreatePayload, schemaDocumentCashSalesUpdatePayload } from \"@/schema/payload/document/schemaDocumentCashSales\";\nexport type { SchemaDocumentCashSalesCreatePayload, SchemaDocumentCashSalesUpdatePayload } from \"@/schema/payload/document/schemaDocumentCashSales\";\nexport { schemaDocumentTripOrderCreatePayload, schemaDocumentTripOrderUpdatePayload } from \"@/schema/payload/document/schemaDocumentTripOrder\";\nexport type { SchemaDocumentTripOrderCreatePayload, SchemaDocumentTripOrderUpdatePayload } from \"@/schema/payload/document/schemaDocumentTripOrder\";\n\nexport { schemaItemDeletePayload } from \"@/schema/payload/item/schemaItem\";\nexport type { SchemaItemDeletePayload } from \"@/schema/payload/item/schemaItem\";\nexport { schemaItemProductCreatePayload, schemaItemProductUpdatePayload } from \"@/schema/payload/item/schemaItemProduct\";\nexport type { SchemaItemProductCreatePayload, SchemaItemProductUpdatePayload } from \"@/schema/payload/item/schemaItemProduct\";\nexport { schemaItemItemCreatePayload, schemaItemItemUpdatePayload, schemaItemItem } from \"@/schema/payload/item/schemaItemItem\";\nexport type { SchemaItemItemCreatePayload, SchemaItemItemUpdatePayload } from \"@/schema/payload/item/schemaItemItem\";\nexport { schemaItemCategoryCreatePayload, schemaItemCategoryUpdatePayload } from \"@/schema/payload/item/schemaItemCategory\";\nexport type { SchemaItemCategoryCreatePayload, SchemaItemCategoryUpdatePayload } from \"@/schema/payload/item/schemaItemCategory\";\nexport { schemaItemBrandCreatePayload, schemaItemBrandUpdatePayload } from \"@/schema/payload/item/schemaItemBrand\";\nexport type { SchemaItemBrandCreatePayload, SchemaItemBrandUpdatePayload } from \"@/schema/payload/item/schemaItemBrand\";\nexport { schemaItemUomCreatePayload, schemaItemUomUpdatePayload } from \"@/schema/payload/item/schemaItemUom\";\nexport type { SchemaItemUomCreatePayload, SchemaItemUomUpdatePayload } from \"@/schema/payload/item/schemaItemUom\";\n\nexport { schemaLocationLocationCreatePayload, schemaLocationLocationUpdatePayload, schemaLocationLocationDeletePayload, } from \"@/schema/payload/location/schemaLocationLocation\";\nexport type { SchemaLocationLocationCreatePayload, SchemaLocationLocationUpdatePayload, SchemaLocationLocationDeletePayload } from \"@/schema/payload/location/schemaLocationLocation\";\nexport { schemaLocationRackCreatePayload, schemaLocationRackUpdatePayload, schemaLocationRackDeletePayload, } from \"@/schema/payload/location/schemaLocationRack\";\nexport type { SchemaLocationRackCreatePayload, SchemaLocationRackUpdatePayload, SchemaLocationRackDeletePayload } from \"@/schema/payload/location/schemaLocationRack\";\nexport { schemaLocationSlotCreatePayload, schemaLocationSlotUpdatePayload, schemaLocationSlotDeletePayload, schemaSlot } from \"@/schema/payload/location/schemaLocationSlot\";\nexport type { SchemaLocationSlotCreatePayload, SchemaLocationSlotUpdatePayload, SchemaLocationSlotDeletePayload } from \"@/schema/payload/location/schemaLocationSlot\";\n\nexport { schemaInjectionFieldReplacePayload, schemaInjectionFieldCreatePayload, schemaInjectionFieldDeletePayload } from \"@/schema/payload/injection_field/schemaInjectionField\";\nexport type { SchemaInjectionFieldReplacePayload, SchemaInjectionFieldCreatePayload, SchemaInjectionFieldDeletePayload } from \"@/schema/payload/injection_field/schemaInjectionField\";\n\nexport { schemaRegionCountryCreatePayload, schemaRegionCountryUpdatePayload, schemaRegionCountryDeletePayload } from \"@/schema/payload/region/schemaRegionCountry\";\nexport type { SchemaRegionCountryCreatePayload, SchemaRegionCountryDeletePayload } from \"@/schema/payload/region/schemaRegionCountry\";\nexport { schemaRegionStateCreatePayload, schemaRegionStateDeletePayload, schemaRegionStateUpdatePayload } from \"@/schema/payload/region/schemaRegionState\";\nexport type { SchemaRegionStateCreatePayload, SchemaRegionStateDeletePayload } from \"@/schema/payload/region/schemaRegionState\";\nexport { schemaRegionAreaCreatePayload, schemaRegionAreaDeletePayload, schemaRegionAreaUpdatePayload, } from \"@/schema/payload/region/schemaRegionArea\";\nexport type { SchemaRegionAreaCreatePayload, SchemaRegionAreaDeletePayload, SchemaRegionAreaUpdatePayload } from \"@/schema/payload/region/schemaRegionArea\";\n\nexport { schemaChangePasswordUtilPayload } from \"@/schema/payload/utils/schemaChangePasswordUtil\";\nexport type { SchemaChangePasswordUtilPayload } from \"@/schema/payload/utils/schemaChangePasswordUtil\";\nexport { schemaAccessKeyUtilValidatePayload, schemaAccessKeyUtilAccountOwnerPayload } from \"@/schema/payload/utils/schemaAccessKeyUtil\";\nexport type { SchemaAccessKeyUtilValidatePayload, SchemaAccessKeyUtilAccountOwnerPayload } from \"@/schema/payload/utils/schemaAccessKeyUtil\";"]}