@hed-hog/core 0.0.64 → 0.0.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/core.module.d.ts +6 -2
  2. package/dist/core.module.d.ts.map +1 -1
  3. package/dist/core.module.js +18 -1
  4. package/dist/core.module.js.map +1 -1
  5. package/dist/validators/is-email-with-settings.validator.d.ts +2 -5
  6. package/dist/validators/is-email-with-settings.validator.d.ts.map +1 -1
  7. package/dist/validators/is-email-with-settings.validator.js +28 -28
  8. package/dist/validators/is-email-with-settings.validator.js.map +1 -1
  9. package/dist/validators/is-pin-code-with-setting.validator.d.ts +2 -5
  10. package/dist/validators/is-pin-code-with-setting.validator.d.ts.map +1 -1
  11. package/dist/validators/is-pin-code-with-setting.validator.js +15 -13
  12. package/dist/validators/is-pin-code-with-setting.validator.js.map +1 -1
  13. package/dist/validators/is-strong-password-with-settings.validator.d.ts +2 -5
  14. package/dist/validators/is-strong-password-with-settings.validator.d.ts.map +1 -1
  15. package/dist/validators/is-strong-password-with-settings.validator.js +42 -40
  16. package/dist/validators/is-strong-password-with-settings.validator.js.map +1 -1
  17. package/dist/validators/service-locator.d.ts +11 -0
  18. package/dist/validators/service-locator.d.ts.map +1 -0
  19. package/dist/validators/service-locator.js +20 -0
  20. package/dist/validators/service-locator.js.map +1 -0
  21. package/hedhog/data/setting_group.yaml +1 -1
  22. package/package.json +2 -2
  23. package/src/core.module.ts +14 -2
  24. package/src/validators/is-email-with-settings.validator.ts +10 -4
  25. package/src/validators/is-pin-code-with-setting.validator.ts +17 -12
  26. package/src/validators/is-strong-password-with-settings.validator.ts +10 -5
  27. package/src/validators/service-locator.ts +20 -0
@@ -1,5 +1,9 @@
1
- import { MiddlewareConsumer, NestModule } from '@nestjs/common';
2
- export declare class CoreModule implements NestModule {
1
+ import { MiddlewareConsumer, NestModule, OnModuleInit } from '@nestjs/common';
2
+ import { SettingService } from './setting/setting.service';
3
+ export declare class CoreModule implements NestModule, OnModuleInit {
4
+ private readonly settingService;
5
+ constructor(settingService: SettingService);
6
+ onModuleInit(): void;
3
7
  configure(consumer: MiddlewareConsumer): void;
4
8
  }
5
9
  //# sourceMappingURL=core.module.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"core.module.d.ts","sourceRoot":"","sources":["../src/core.module.ts"],"names":[],"mappings":"AAMA,OAAO,EAAsB,kBAAkB,EAAU,UAAU,EAAE,MAAM,gBAAgB,CAAC;AA2B5F,qBA2Da,UAAW,YAAW,UAAU;IAC3C,SAAS,CAAC,QAAQ,EAAE,kBAAkB;CAKvC"}
1
+ {"version":3,"file":"core.module.d.ts","sourceRoot":"","sources":["../src/core.module.ts"],"names":[],"mappings":"AAMA,OAAO,EAA8B,kBAAkB,EAAU,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAqBlH,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAQ3D,qBA2Da,UAAW,YAAW,UAAU,EAAE,YAAY;IAGvD,OAAO,CAAC,QAAQ,CAAC,cAAc;gBAAd,cAAc,EAAE,cAAc;IAGjD,YAAY;IAKZ,SAAS,CAAC,QAAQ,EAAE,kBAAkB;CAKvC"}
@@ -5,6 +5,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
8
14
  Object.defineProperty(exports, "__esModule", { value: true });
9
15
  exports.CoreModule = void 0;
10
16
  const api_1 = require("@hed-hog/api");
@@ -34,12 +40,21 @@ const screen_module_1 = require("./screen/screen.module");
34
40
  const security_module_1 = require("./security/security.module");
35
41
  const session_module_1 = require("./session/session.module");
36
42
  const setting_module_1 = require("./setting/setting.module");
43
+ const setting_service_1 = require("./setting/setting.service");
37
44
  const task_module_1 = require("./task/task.module");
38
45
  const user_module_1 = require("./user/user.module");
39
46
  const is_email_with_settings_validator_1 = require("./validators/is-email-with-settings.validator");
40
47
  const is_pin_code_with_setting_validator_1 = require("./validators/is-pin-code-with-setting.validator");
41
48
  const is_strong_password_with_settings_validator_1 = require("./validators/is-strong-password-with-settings.validator");
49
+ const service_locator_1 = require("./validators/service-locator");
42
50
  let CoreModule = class CoreModule {
51
+ constructor(settingService) {
52
+ this.settingService = settingService;
53
+ }
54
+ onModuleInit() {
55
+ // Initialize the service locator for validators
56
+ service_locator_1.ValidatorServiceLocator.setSettingService(this.settingService);
57
+ }
43
58
  configure(consumer) {
44
59
  consumer
45
60
  .apply(locale_injection_middleware_1.LocaleInjectionMiddleware)
@@ -106,6 +121,8 @@ exports.CoreModule = CoreModule = __decorate([
106
121
  inject: [core_1.Reflector, api_prisma_1.PrismaService],
107
122
  },
108
123
  ]
109
- })
124
+ }),
125
+ __param(0, (0, common_1.Inject)((0, common_1.forwardRef)(() => setting_service_1.SettingService))),
126
+ __metadata("design:paramtypes", [setting_service_1.SettingService])
110
127
  ], CoreModule);
111
128
  //# sourceMappingURL=core.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"core.module.js","sourceRoot":"","sources":["../src/core.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,sCAA8C;AAC9C,oDAAmD;AACnD,gDAAiE;AACjE,4DAA2D;AAC3D,oDAAkE;AAClE,yCAA2C;AAC3C,2CAA4F;AAC5F,2CAA8C;AAC9C,uCAA0D;AAC1D,oDAAgD;AAChD,wDAAoD;AACpD,mEAA+D;AAC/D,oDAAgD;AAChD,6DAAyD;AACzD,mEAA8D;AAC9D,gEAA2D;AAC3D,oDAAgD;AAChD,o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sC;YACtC,gEAA6B;YAC7B,mEAA8B;SAC/B;QACD,SAAS,EAAE;YACT,gBAAS;YACT,mFAAsC;YACtC,gEAA6B;YAC7B,mEAA8B;YAC9B;gBACE,OAAO,EAAE,sBAAe;gBACxB,UAAU,EAAE,CAAC,SAAoB,EAAE,aAA4B,EAAE,EAAE;oBACjE,OAAO,IAAI,oBAAc,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;gBACtD,CAAC;gBACD,MAAM,EAAE,CAAC,gBAAS,EAAE,0BAAa,CAAC;aACnC;SACF;KACF,CAAC;IAGG,WAAA,IAAA,eAAM,EAAC,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,gCAAc,CAAC,CAAC,CAAA;qCACR,gCAAc;GAHtC,UAAU,CAgBtB"}
@@ -1,9 +1,6 @@
1
- import { ValidationOptions, ValidatorConstraintInterface } from 'class-validator';
2
- import { SettingService } from '../setting/setting.service';
1
+ import { ValidationArguments, ValidationOptions, ValidatorConstraintInterface } from 'class-validator';
3
2
  export declare class IsEmailWithSettingsConstraint implements ValidatorConstraintInterface {
4
- private readonly settingService;
5
- constructor(settingService: SettingService);
6
- validate(email: string): Promise<boolean>;
3
+ validate(email: string, args: ValidationArguments): Promise<boolean>;
7
4
  defaultMessage(): string;
8
5
  }
9
6
  export declare function IsEmailWithSettings(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"is-email-with-settings.validator.d.ts","sourceRoot":"","sources":["../../src/validators/is-email-with-settings.validator.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,iBAAiB,EAEjB,4BAA4B,EAC7B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D,qBAEa,6BACX,YAAW,4BAA4B;IAE3B,OAAO,CAAC,QAAQ,CAAC,cAAc;gBAAd,cAAc,EAAE,cAAc;IAErD,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA4C/C,cAAc,IAAI,MAAM;CAOzB;AAED,wBAAgB,mBAAmB,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,IACtD,QAAQ,MAAM,EAAE,cAAc,MAAM,UAStD"}
1
+ {"version":3,"file":"is-email-with-settings.validator.d.ts","sourceRoot":"","sources":["../../src/validators/is-email-with-settings.validator.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,mBAAmB,EACnB,iBAAiB,EAEjB,4BAA4B,EAC7B,MAAM,iBAAiB,CAAC;AAIzB,qBAEa,6BACX,YAAW,4BAA4B;IAGjC,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAkD1E,cAAc,IAAI,MAAM;CAOzB;AAED,wBAAgB,mBAAmB,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,IACtD,QAAQ,MAAM,EAAE,cAAc,MAAM,UAStD"}
@@ -5,22 +5,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
8
  Object.defineProperty(exports, "__esModule", { value: true });
12
9
  exports.IsEmailWithSettingsConstraint = void 0;
13
10
  exports.IsEmailWithSettings = IsEmailWithSettings;
14
11
  const api_locale_1 = require("@hed-hog/api-locale");
15
12
  const common_1 = require("@nestjs/common");
16
13
  const class_validator_1 = require("class-validator");
17
- const setting_service_1 = require("../setting/setting.service");
18
14
  const locale_context_1 = require("../utils/locale-context");
15
+ const service_locator_1 = require("./service-locator");
19
16
  let IsEmailWithSettingsConstraint = class IsEmailWithSettingsConstraint {
20
- constructor(settingService) {
21
- this.settingService = settingService;
22
- }
23
- async validate(email) {
17
+ async validate(email, args) {
24
18
  var _a;
25
19
  if (!email) {
26
20
  return false;
@@ -35,26 +29,33 @@ let IsEmailWithSettingsConstraint = class IsEmailWithSettingsConstraint {
35
29
  if (!domain) {
36
30
  return false;
37
31
  }
38
- const settings = await this.settingService.getSystemSettings();
39
- const blacklist = settings.setting['email-host-blacklist'] || [];
40
- const whitelist = settings.setting['email-host-whitelist'] || [];
41
- // blacklist e whitelist são arrays
42
- const blacklistHosts = Array.isArray(blacklist)
43
- ? blacklist.map((host) => host.trim().toLowerCase()).filter((host) => host.length > 0)
44
- : [];
45
- const whitelistHosts = Array.isArray(whitelist)
46
- ? whitelist.map((host) => host.trim().toLowerCase()).filter((host) => host.length > 0)
47
- : [];
48
- // If whitelist is defined and not empty, domain must be in whitelist
49
- if (whitelistHosts.length > 0) {
50
- return whitelistHosts.includes(domain);
32
+ try {
33
+ const settingService = service_locator_1.ValidatorServiceLocator.getSettingService();
34
+ const settings = await settingService.getSystemSettings();
35
+ const blacklist = settings.setting['email-host-blacklist'] || [];
36
+ const whitelist = settings.setting['email-host-whitelist'] || [];
37
+ // blacklist e whitelist são arrays
38
+ const blacklistHosts = Array.isArray(blacklist)
39
+ ? blacklist.map((host) => host.trim().toLowerCase()).filter((host) => host.length > 0)
40
+ : [];
41
+ const whitelistHosts = Array.isArray(whitelist)
42
+ ? whitelist.map((host) => host.trim().toLowerCase()).filter((host) => host.length > 0)
43
+ : [];
44
+ // If whitelist is defined and not empty, domain must be in whitelist
45
+ if (whitelistHosts.length > 0) {
46
+ return whitelistHosts.includes(domain);
47
+ }
48
+ // If blacklist is defined, domain must not be in blacklist
49
+ if (blacklistHosts.length > 0) {
50
+ return !blacklistHosts.includes(domain);
51
+ }
52
+ // No restrictions, email is valid
53
+ return true;
51
54
  }
52
- // If blacklist is defined, domain must not be in blacklist
53
- if (blacklistHosts.length > 0) {
54
- return !blacklistHosts.includes(domain);
55
+ catch (error) {
56
+ console.warn('[IsEmailWithSettingsConstraint] Error getting SettingService:', error);
57
+ return true; // Allow if service is not available
55
58
  }
56
- // No restrictions, email is valid
57
- return true;
58
59
  }
59
60
  defaultMessage() {
60
61
  return (0, api_locale_1.getLocaleText)('email.invalidEmail', (0, locale_context_1.getLocaleFromContext)(), 'Email does not meet the security requirements defined in system settings.');
@@ -63,8 +64,7 @@ let IsEmailWithSettingsConstraint = class IsEmailWithSettingsConstraint {
63
64
  exports.IsEmailWithSettingsConstraint = IsEmailWithSettingsConstraint;
64
65
  exports.IsEmailWithSettingsConstraint = IsEmailWithSettingsConstraint = __decorate([
65
66
  (0, class_validator_1.ValidatorConstraint)({ async: true }),
66
- (0, common_1.Injectable)(),
67
- __metadata("design:paramtypes", [setting_service_1.SettingService])
67
+ (0, common_1.Injectable)()
68
68
  ], IsEmailWithSettingsConstraint);
69
69
  function IsEmailWithSettings(validationOptions) {
70
70
  return function (object, propertyName) {
@@ -1 +1 @@
1
- {"version":3,"file":"is-email-with-settings.validator.js","sourceRoot":"","sources":["../../src/validators/is-email-with-settings.validator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAuEA,kDAUC;AAjFD,oDAAoD;AACpD,2CAA4C;AAC5C,qDAKyB;AACzB,gEAA4D;AAC5D,4DAA+D;AAIxD,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IAGxC,YAA6B,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;IAAG,CAAC;IAE/D,KAAK,CAAC,QAAQ,CAAC,KAAa;;QAC1B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,KAAK,CAAC;QACf,CAAC;QAED,sCAAsC;QACtC,MAAM,UAAU,GAAG,4BAA4B,CAAC;QAChD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC;QACf,CAAC;QAED,4BAA4B;QAC5B,MAAM,MAAM,GAAG,MAAA,KAAK,CAAC,KAAK,CAA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CAAC,CAAC;QAC1C,CAAC;QAED,kCAAkC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,cAAc;QACZ,OAAO,IAAA,0BAAa,EAClB,oBAAoB,EACpB,IAAA,qCAAoB,GAAE,EACtB,2EAA2E,CAC5E,CAAC;IACJ,CAAC;CACF,CAAA;AAxDY,sEAA6B;wCAA7B,6BAA6B;IAFzC,IAAA,qCAAmB,EAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACpC,IAAA,mBAAU,GAAE;qCAIkC,gCAAc;GAHhD,6BAA6B,CAwDzC;AAED,SAAgB,mBAAmB,CAAC,iBAAqC;IACvE,OAAO,UAAU,MAAc,EAAE,YAAoB;QACnD,IAAA,mCAAiB,EAAC;YAChB,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,OAAO,EAAE,iBAAiB;YAC1B,WAAW,EAAE,EAAE;YACf,SAAS,EAAE,6BAA6B;SACzC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"is-email-with-settings.validator.js","sourceRoot":"","sources":["../../src/validators/is-email-with-settings.validator.ts"],"names":[],"mappings":";;;;;;;;;AA6EA,kDAUC;AAvFD,oDAAoD;AACpD,2CAA4C;AAC5C,qDAMyB;AACzB,4DAA+D;AAC/D,uDAA4D;AAIrD,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;IAIxC,KAAK,CAAC,QAAQ,CAAC,KAAa,EAAE,IAAyB;;QACrD,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,KAAK,CAAC;QACf,CAAC;QAED,sCAAsC;QACtC,MAAM,UAAU,GAAG,4BAA4B,CAAC;QAChD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5B,OAAO,KAAK,CAAC;QACf,CAAC;QAED,4BAA4B;QAC5B,MAAM,MAAM,GAAG,MAAA,KAAK,CAAC,KAAK,CAAC,GAA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,EAAE,CAAC;gBAC9B,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC1C,CAAC;YAED,kCAAkC;YAClC,OAAO,IAAI,CAAC;QACZ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,+DAA+D,EAAE,KAAK,CAAC,CAAC;YACrF,OAAO,IAAI,CAAC,CAAC,oCAAoC;QACnD,CAAC;IACH,CAAC;IAED,cAAc;QACZ,OAAO,IAAA,0BAAa,EAClB,oBAAoB,EACpB,IAAA,qCAAoB,GAAE,EACtB,2EAA2E,CAC5E,CAAC;IACJ,CAAC;CACF,CAAA;AA7DY,sEAA6B;wCAA7B,6BAA6B;IAFzC,IAAA,qCAAmB,EAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACpC,IAAA,mBAAU,GAAE;GACA,6BAA6B,CA6DzC;AAED,SAAgB,mBAAmB,CAAC,iBAAqC;IACvE,OAAO,UAAU,MAAc,EAAE,YAAoB;QACnD,IAAA,mCAAiB,EAAC;YAChB,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,OAAO,EAAE,iBAAiB;YAC1B,WAAW,EAAE,EAAE;YACf,SAAS,EAAE,6BAA6B;SACzC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
@@ -1,10 +1,7 @@
1
- import { ValidationOptions, ValidatorConstraintInterface } from 'class-validator';
2
- import { SettingService } from '../setting/setting.service';
1
+ import { ValidationArguments, ValidationOptions, ValidatorConstraintInterface } from 'class-validator';
3
2
  export declare class IsPinCodeWithSettingConstraint implements ValidatorConstraintInterface {
4
- private readonly settingService;
5
3
  private settings;
6
- constructor(settingService: SettingService);
7
- validate(pinCode: string): Promise<boolean>;
4
+ validate(pinCode: string, args: ValidationArguments): Promise<boolean>;
8
5
  defaultMessage(): string;
9
6
  }
10
7
  export declare function IsPinCodeWithSetting(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"is-pin-code-with-setting.validator.d.ts","sourceRoot":"","sources":["../../src/validators/is-pin-code-with-setting.validator.ts"],"names":[],"mappings":"AAEA,OAAO,EAEH,iBAAiB,EAEjB,4BAA4B,EAC/B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D,qBAEa,8BAA+B,YAAW,4BAA4B;IAGrE,OAAO,CAAC,QAAQ,CAAC,cAAc;IAF3C,OAAO,CAAC,QAAQ,CAAa;gBAEA,cAAc,EAAE,cAAc;IAErD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAoBjD,cAAc,IAAI,MAAM;CA8BzB;AAED,wBAAgB,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,IACvD,QAAQ,MAAM,EAAE,cAAc,MAAM,UAStD"}
1
+ {"version":3,"file":"is-pin-code-with-setting.validator.d.ts","sourceRoot":"","sources":["../../src/validators/is-pin-code-with-setting.validator.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,mBAAmB,EACnB,iBAAiB,EAEjB,4BAA4B,EAC7B,MAAM,iBAAiB,CAAC;AAIzB,qBAEa,8BAA+B,YAAW,4BAA4B;IACjF,OAAO,CAAC,QAAQ,CAAa;IAEvB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IA0B5E,cAAc,IAAI,MAAM;CA8BzB;AAED,wBAAgB,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,IACvD,QAAQ,MAAM,EAAE,cAAc,MAAM,UAStD"}
@@ -5,23 +5,19 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
8
  Object.defineProperty(exports, "__esModule", { value: true });
12
9
  exports.IsPinCodeWithSettingConstraint = void 0;
13
10
  exports.IsPinCodeWithSetting = IsPinCodeWithSetting;
14
11
  const api_locale_1 = require("@hed-hog/api-locale");
15
12
  const common_1 = require("@nestjs/common");
16
13
  const class_validator_1 = require("class-validator");
17
- const setting_service_1 = require("../setting/setting.service");
18
14
  const locale_context_1 = require("../utils/locale-context");
15
+ const service_locator_1 = require("./service-locator");
19
16
  let IsPinCodeWithSettingConstraint = class IsPinCodeWithSettingConstraint {
20
- constructor(settingService) {
21
- this.settingService = settingService;
17
+ constructor() {
22
18
  this.settings = null;
23
19
  }
24
- async validate(pinCode) {
20
+ async validate(pinCode, args) {
25
21
  this.settings = null;
26
22
  if (!pinCode) {
27
23
  return false;
@@ -31,10 +27,17 @@ let IsPinCodeWithSettingConstraint = class IsPinCodeWithSettingConstraint {
31
27
  if (!digitRegex.test(pinCode)) {
32
28
  return false;
33
29
  }
34
- this.settings = await this.settingService.getSystemSettings();
35
- const codeLength = this.settings.setting['mfa-email-code-length'] || 6;
36
- // Validate pin code length matches the configured length
37
- return pinCode.length === Number(codeLength);
30
+ try {
31
+ const settingService = service_locator_1.ValidatorServiceLocator.getSettingService();
32
+ this.settings = await settingService.getSystemSettings();
33
+ const codeLength = this.settings.setting['mfa-email-code-length'] || 6;
34
+ // Validate pin code length matches the configured length
35
+ return pinCode.length === Number(codeLength);
36
+ }
37
+ catch (error) {
38
+ console.warn('[IsPinCodeWithSettingConstraint] Error getting SettingService:', error);
39
+ return true; // Allow if service is not available
40
+ }
38
41
  }
39
42
  defaultMessage() {
40
43
  const locale = (0, locale_context_1.getLocaleFromContext)();
@@ -56,8 +59,7 @@ let IsPinCodeWithSettingConstraint = class IsPinCodeWithSettingConstraint {
56
59
  exports.IsPinCodeWithSettingConstraint = IsPinCodeWithSettingConstraint;
57
60
  exports.IsPinCodeWithSettingConstraint = IsPinCodeWithSettingConstraint = __decorate([
58
61
  (0, class_validator_1.ValidatorConstraint)({ async: true }),
59
- (0, common_1.Injectable)(),
60
- __metadata("design:paramtypes", [setting_service_1.SettingService])
62
+ (0, common_1.Injectable)()
61
63
  ], IsPinCodeWithSettingConstraint);
62
64
  function IsPinCodeWithSetting(validationOptions) {
63
65
  return function (object, propertyName) {
@@ -1 +1 @@
1
- {"version":3,"file":"is-pin-code-with-setting.validator.js","sourceRoot":"","sources":["../../src/validators/is-pin-code-with-setting.validator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAsEA,oDAUC;AAhFD,oDAAoD;AACpD,2CAA4C;AAC5C,qDAKyB;AACzB,gEAA4D;AAC5D,4DAA+D;AAIxD,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAGzC,YAA6B,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;QAFnD,aAAQ,GAAQ,IAAI,CAAC;IAEiC,CAAC;IAE/D,KAAK,CAAC,QAAQ,CAAC,OAAe;QAC5B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAErB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,KAAK,CAAC;QACf,CAAC;QAED,6CAA6C;QAC7C,MAAM,UAAU,GAAG,OAAO,CAAC;QAC3B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,iBAAiB,EAAE,CAAC;QAC9D,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC;QAEvE,yDAAyD;QACzD,OAAO,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC,UAAU,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CAAC"}
1
+ {"version":3,"file":"is-pin-code-with-setting.validator.js","sourceRoot":"","sources":["../../src/validators/is-pin-code-with-setting.validator.ts"],"names":[],"mappings":";;;;;;;;;AA2EA,oDAUC;AArFD,oDAAoD;AACpD,2CAA4C;AAC5C,qDAMyB;AACzB,4DAA+D;AAC/D,uDAA4D;AAIrD,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAApC;QACG,aAAQ,GAAQ,IAAI,CAAC;IA0D/B,CAAC;IAxDC,KAAK,CAAC,QAAQ,CAAC,OAAe,EAAE,IAAyB;QACvD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAErB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,KAAK,CAAC;QACf,CAAC;QAED,6CAA6C;QAC7C,MAAM,UAAU,GAAG,OAAO,CAAC;QAC3B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9B,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC;YACH,MAAM,cAAc,GAAG,yCAAuB,CAAC,iBAAiB,EAAE,CAAC;YACnE,IAAI,CAAC,QAAQ,GAAG,MAAM,cAAc,CAAC,iBAAiB,EAAE,CAAC;YACzD,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC;YAEvE,yDAAyD;YACzD,OAAO,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC,UAAU,CAAC,CAAC;QAC/C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,gEAAgE,EAAE,KAAK,CAAC,CAAC;YACtF,OAAO,IAAI,CAAC,CAAC,oCAAoC;QACnD,CAAC;IACH,CAAC;IAED,cAAc;QACZ,MAAM,MAAM,GAAG,IAAA,qCAAoB,GAAE,CAAC;QAEtC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,uBAAuB,CAAC,IAAI,CAAC,CAAC;YAEvE,MAAM,YAAY,GAA2B;gBAC3C,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC;aAC/B,CAAC;YAEF,IAAI,OAAO,GAAG,IAAA,0BAAa,EACzB,uBAAuB,EACvB,MAAM,EACN,wEAAwE,CACzE,CAAC;YAEF,uBAAuB;YACvB,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,CAAC,EAAE,EAAE;gBAC5D,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;YACjE,CAAC,CAAC,CAAC;YAEH,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,OAAO,IAAA,0BAAa,EAClB,uBAAuB,EACvB,MAAM,EACN,wEAAwE,CACzE,CAAC;IACJ,CAAC;CACF,CAAA;AA3DY,wEAA8B;yCAA9B,8BAA8B;IAF1C,IAAA,qCAAmB,EAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACpC,IAAA,mBAAU,GAAE;GACA,8BAA8B,CA2D1C;AAED,SAAgB,oBAAoB,CAAC,iBAAqC;IACxE,OAAO,UAAU,MAAc,EAAE,YAAoB;QACnD,IAAA,mCAAiB,EAAC;YAChB,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,OAAO,EAAE,iBAAiB;YAC1B,WAAW,EAAE,EAAE;YACf,SAAS,EAAE,8BAA8B;SAC1C,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
@@ -1,11 +1,8 @@
1
- import { ValidationOptions, ValidatorConstraintInterface } from 'class-validator';
2
- import { SettingService } from '../setting/setting.service';
1
+ import { ValidationArguments, ValidationOptions, ValidatorConstraintInterface } from 'class-validator';
3
2
  export declare class IsStrongPasswordWithSettingsConstraint implements ValidatorConstraintInterface {
4
- private readonly settingService;
5
3
  private failedRule;
6
4
  private settings;
7
- constructor(settingService: SettingService);
8
- validate(password: string): Promise<boolean>;
5
+ validate(password: string, args: ValidationArguments): Promise<boolean>;
9
6
  defaultMessage(): string;
10
7
  }
11
8
  export declare function IsStrongPasswordWithSettings(validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"is-strong-password-with-settings.validator.d.ts","sourceRoot":"","sources":["../../src/validators/is-strong-password-with-settings.validator.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,iBAAiB,EAEjB,4BAA4B,EAC7B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D,qBAEa,sCACX,YAAW,4BAA4B;IAK3B,OAAO,CAAC,QAAQ,CAAC,cAAc;IAH3C,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,QAAQ,CAAa;gBAEA,cAAc,EAAE,cAAc;IAErD,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAmDlD,cAAc,IAAI,MAAM;CAsCzB;AAED,wBAAgB,4BAA4B,CAC1C,iBAAiB,CAAC,EAAE,iBAAiB,IAEpB,QAAQ,MAAM,EAAE,cAAc,MAAM,UAStD"}
1
+ {"version":3,"file":"is-strong-password-with-settings.validator.d.ts","sourceRoot":"","sources":["../../src/validators/is-strong-password-with-settings.validator.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,mBAAmB,EACnB,iBAAiB,EAEjB,4BAA4B,EAC7B,MAAM,iBAAiB,CAAC;AAIzB,qBAEa,sCACX,YAAW,4BAA4B;IAEvC,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,QAAQ,CAAa;IAEvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC;IAyD7E,cAAc,IAAI,MAAM;CAsCzB;AAED,wBAAgB,4BAA4B,CAC1C,iBAAiB,CAAC,EAAE,iBAAiB,IAEpB,QAAQ,MAAM,EAAE,cAAc,MAAM,UAStD"}
@@ -5,63 +5,66 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
8
  Object.defineProperty(exports, "__esModule", { value: true });
12
9
  exports.IsStrongPasswordWithSettingsConstraint = void 0;
13
10
  exports.IsStrongPasswordWithSettings = IsStrongPasswordWithSettings;
14
11
  const api_locale_1 = require("@hed-hog/api-locale");
15
12
  const common_1 = require("@nestjs/common");
16
13
  const class_validator_1 = require("class-validator");
17
- const setting_service_1 = require("../setting/setting.service");
18
14
  const locale_context_1 = require("../utils/locale-context");
15
+ const service_locator_1 = require("./service-locator");
19
16
  let IsStrongPasswordWithSettingsConstraint = class IsStrongPasswordWithSettingsConstraint {
20
- constructor(settingService) {
21
- this.settingService = settingService;
17
+ constructor() {
22
18
  this.failedRule = null;
23
19
  this.settings = null;
24
20
  }
25
- async validate(password) {
21
+ async validate(password, args) {
26
22
  this.failedRule = null;
27
23
  this.settings = null;
28
24
  if (!password) {
29
25
  this.failedRule = 'password.required';
30
26
  return false;
31
27
  }
32
- this.settings = await this.settingService.getSystemSettings();
33
- const minLength = this.settings.setting['password-min-length'] || 6;
34
- const minLowercase = this.settings.setting['password-min-lowercase'] || 0;
35
- const minUppercase = this.settings.setting['password-min-uppercase'] || 0;
36
- const minNumbers = this.settings.setting['password-min-numbers'] || 0;
37
- const minSymbols = this.settings.setting['password-min-symbols'] || 0;
38
- // Validate length
39
- if (password.length < minLength) {
40
- this.failedRule = 'password.minLength';
41
- return false;
42
- }
43
- // Count character types
44
- const lowercase = (password.match(/[a-z]/g) || []).length;
45
- const uppercase = (password.match(/[A-Z]/g) || []).length;
46
- const numbers = (password.match(/[0-9]/g) || []).length;
47
- const symbols = (password.match(/[^a-zA-Z0-9]/g) || []).length;
48
- if (lowercase < minLowercase) {
49
- this.failedRule = 'password.minLowercase';
50
- return false;
51
- }
52
- if (uppercase < minUppercase) {
53
- this.failedRule = 'password.minUppercase';
54
- return false;
55
- }
56
- if (numbers < minNumbers) {
57
- this.failedRule = 'password.minNumbers';
58
- return false;
28
+ try {
29
+ const settingService = service_locator_1.ValidatorServiceLocator.getSettingService();
30
+ this.settings = await settingService.getSystemSettings();
31
+ const minLength = this.settings.setting['password-min-length'] || 6;
32
+ const minLowercase = this.settings.setting['password-min-lowercase'] || 0;
33
+ const minUppercase = this.settings.setting['password-min-uppercase'] || 0;
34
+ const minNumbers = this.settings.setting['password-min-numbers'] || 0;
35
+ const minSymbols = this.settings.setting['password-min-symbols'] || 0;
36
+ // Validate length
37
+ if (password.length < minLength) {
38
+ this.failedRule = 'password.minLength';
39
+ return false;
40
+ }
41
+ // Count character types
42
+ const lowercase = (password.match(/[a-z]/g) || []).length;
43
+ const uppercase = (password.match(/[A-Z]/g) || []).length;
44
+ const numbers = (password.match(/[0-9]/g) || []).length;
45
+ const symbols = (password.match(/[^a-zA-Z0-9]/g) || []).length;
46
+ if (lowercase < minLowercase) {
47
+ this.failedRule = 'password.minLowercase';
48
+ return false;
49
+ }
50
+ if (uppercase < minUppercase) {
51
+ this.failedRule = 'password.minUppercase';
52
+ return false;
53
+ }
54
+ if (numbers < minNumbers) {
55
+ this.failedRule = 'password.minNumbers';
56
+ return false;
57
+ }
58
+ if (symbols < minSymbols) {
59
+ this.failedRule = 'password.minSymbols';
60
+ return false;
61
+ }
62
+ return true;
59
63
  }
60
- if (symbols < minSymbols) {
61
- this.failedRule = 'password.minSymbols';
62
- return false;
64
+ catch (error) {
65
+ console.warn('[IsStrongPasswordWithSettingsConstraint] Error getting SettingService:', error);
66
+ return true; // Allow if service is not available
63
67
  }
64
- return true;
65
68
  }
66
69
  defaultMessage() {
67
70
  const locale = (0, locale_context_1.getLocaleFromContext)();
@@ -91,8 +94,7 @@ let IsStrongPasswordWithSettingsConstraint = class IsStrongPasswordWithSettingsC
91
94
  exports.IsStrongPasswordWithSettingsConstraint = IsStrongPasswordWithSettingsConstraint;
92
95
  exports.IsStrongPasswordWithSettingsConstraint = IsStrongPasswordWithSettingsConstraint = __decorate([
93
96
  (0, class_validator_1.ValidatorConstraint)({ async: true }),
94
- (0, common_1.Injectable)(),
95
- __metadata("design:paramtypes", [setting_service_1.SettingService])
97
+ (0, common_1.Injectable)()
96
98
  ], IsStrongPasswordWithSettingsConstraint);
97
99
  function IsStrongPasswordWithSettings(validationOptions) {
98
100
  return function (object, propertyName) {
@@ -1 +1 @@
1
- {"version":3,"file":"is-strong-password-with-settings.validator.js","sourceRoot":"","sources":["../../src/validators/is-strong-password-with-settings.validator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAgHA,oEAYC;AA5HD,oDAAoD;AACpD,2CAA4C;AAC5C,qDAKyB;AACzB,gEAA4D;AAC5D,4DAA+D;AAIxD,IAAM,sCAAsC,GAA5C,MAAM,sCAAsC;IAMjD,YAA6B,cAA8B;QAA9B,mBAAc,GAAd,cAAc,CAAgB;QAHnD,eAAU,GAAkB,IAAI,CAAC;QACjC,aAAQ,GAAQ,IAAI,CAAC;IAEiC,CAAC;IAE/D,KAAK,CAAC,QAAQ,CAAC,QAAgB;QAC7B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAErB,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,IAAI,CAAC,UAAU,GAAG,mBAAmB,CAAC;YACtC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,IAAI,CAAC,QAAQ,GAAG,MAAM,IA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,CAAC;aACnC,CAAC;YAEF,IAAI,OAAO,GAAG,IAAA,0BAAa,EACzB,IAAI,CAAC,UAAU,EACf,MAAM,EACN,mDAAmD,CACpD,CAAC;YAEF,uBAAuB;YACvB,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,CAAC,EAAE,EAAE;gBAC5D,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;YACjE,CAAC,CAAC,CAAC;YAEH,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,OAAO,IAAA,0BAAa,EAClB,uBAAuB,EACvB,MAAM,EACN,8EAA8E,CAC/E,CAAC;IACJ,CAAC;CACF,CAAA;AAjGY,wFAAsC;iDAAtC,sCAAsC;IAFlD,IAAA,qCAAmB,EAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACpC,IAAA,mBAAU,GAAE;qCAOkC,gCAAc;GANhD,sCAAsC,CAiGlD;AAED,SAAgB,4BAA4B,CAC1C,iBAAqC;IAErC,OAAO,UAAU,MAAc,EAAE,YAAoB;QACnD,IAAA,mCAAiB,EAAC;YAChB,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,OAAO,EAAE,iBAAiB;YAC1B,WAAW,EAAE,EAAE;YACf,SAAS,EAAE,sCAAsC;SAClD,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"is-strong-password-with-settings.validator.js","sourceRoot":"","sources":["../../src/validators/is-strong-password-with-settings.validator.ts"],"names":[],"mappings":";;;;;;;;;AAqHA,oEAYC;AAjID,oDAAoD;AACpD,2CAA4C;AAC5C,qDAMyB;AACzB,4DAA+D;AAC/D,uDAA4D;AAIrD,IAAM,sCAAsC,GAA5C,MAAM,sCAAsC;IAA5C;QAGG,eAAU,GAAkB,IAAI,C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SAAgB,4BAA4B,CAC1C,iBAAqC;IAErC,OAAO,UAAU,MAAc,EAAE,YAAoB;QACnD,IAAA,mCAAiB,EAAC;YAChB,MAAM,EAAE,MAAM,CAAC,WAAW;YAC1B,YAAY,EAAE,YAAY;YAC1B,OAAO,EAAE,iBAAiB;YAC1B,WAAW,EAAE,EAAE;YACf,SAAS,EAAE,sCAAsC;SAClD,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { SettingService } from '../setting/setting.service';
2
+ /**
3
+ * Service locator for validators that can't use dependency injection
4
+ * This is set up during application bootstrap
5
+ */
6
+ export declare class ValidatorServiceLocator {
7
+ private static settingService;
8
+ static setSettingService(service: SettingService): void;
9
+ static getSettingService(): SettingService;
10
+ }
11
+ //# sourceMappingURL=service-locator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-locator.d.ts","sourceRoot":"","sources":["../../src/validators/service-locator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D;;;GAGG;AACH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAiB;IAE9C,MAAM,CAAC,iBAAiB,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAIvD,MAAM,CAAC,iBAAiB,IAAI,cAAc;CAM3C"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValidatorServiceLocator = void 0;
4
+ /**
5
+ * Service locator for validators that can't use dependency injection
6
+ * This is set up during application bootstrap
7
+ */
8
+ class ValidatorServiceLocator {
9
+ static setSettingService(service) {
10
+ this.settingService = service;
11
+ }
12
+ static getSettingService() {
13
+ if (!this.settingService) {
14
+ throw new Error('SettingService not initialized in ValidatorServiceLocator');
15
+ }
16
+ return this.settingService;
17
+ }
18
+ }
19
+ exports.ValidatorServiceLocator = ValidatorServiceLocator;
20
+ //# sourceMappingURL=service-locator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-locator.js","sourceRoot":"","sources":["../../src/validators/service-locator.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH,MAAa,uBAAuB;IAGlC,MAAM,CAAC,iBAAiB,CAAC,OAAuB;QAC9C,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;IAChC,CAAC;IAED,MAAM,CAAC,iBAAiB;QACtB,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;QAC/E,CAAC;QACD,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;CACF;AAbD,0DAaC"}
@@ -240,7 +240,7 @@
240
240
  en: How dates will be displayed
241
241
  pt: Como as datas serão exibidas
242
242
  value: dd/MM/yyyy
243
- user_override: false
243
+ user_override: true
244
244
  relations:
245
245
  setting_list:
246
246
  - value: dd/MM/yyyy
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hed-hog/core",
3
- "version": "0.0.64",
3
+ "version": "0.0.66",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "dependencies": {
@@ -30,8 +30,8 @@
30
30
  "speakeasy": "^2.0.0",
31
31
  "uuid": "^11.1.0",
32
32
  "@hed-hog/types": "0.0.1",
33
- "@hed-hog/api-mail": "0.0.7",
34
33
  "@hed-hog/api-pagination": "0.0.3",
34
+ "@hed-hog/api-mail": "0.0.7",
35
35
  "@hed-hog/api-prisma": "0.0.4",
36
36
  "@hed-hog/api-locale": "0.0.10",
37
37
  "@hed-hog/api": "0.0.3"
@@ -4,7 +4,7 @@ import { MailModule as MailSendModule } from '@hed-hog/api-mail';
4
4
  import { PaginationModule } from '@hed-hog/api-pagination';
5
5
  import { PrismaModule, PrismaService } from '@hed-hog/api-prisma';
6
6
  import { HttpModule } from '@nestjs/axios';
7
- import { forwardRef, Global, MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
7
+ import { forwardRef, Global, Inject, MiddlewareConsumer, Module, NestModule, OnModuleInit } from '@nestjs/common';
8
8
  import { ConfigModule } from '@nestjs/config';
9
9
  import { APP_INTERCEPTOR, Reflector } from '@nestjs/core';
10
10
  import { AuthModule } from './auth/auth.module';
@@ -25,11 +25,13 @@ import { ScreenModule } from './screen/screen.module';
25
25
  import { SecurityModule } from './security/security.module';
26
26
  import { SessionModule } from './session/session.module';
27
27
  import { SettingModule } from './setting/setting.module';
28
+ import { SettingService } from './setting/setting.service';
28
29
  import { TaskModule } from './task/task.module';
29
30
  import { UserModule } from './user/user.module';
30
31
  import { IsEmailWithSettingsConstraint } from './validators/is-email-with-settings.validator';
31
32
  import { IsPinCodeWithSettingConstraint } from './validators/is-pin-code-with-setting.validator';
32
33
  import { IsStrongPasswordWithSettingsConstraint } from './validators/is-strong-password-with-settings.validator';
34
+ import { ValidatorServiceLocator } from './validators/service-locator';
33
35
 
34
36
  @Global()
35
37
  @Module({
@@ -90,7 +92,17 @@ import { IsStrongPasswordWithSettingsConstraint } from './validators/is-strong-p
90
92
  },
91
93
  ]
92
94
  })
93
- export class CoreModule implements NestModule {
95
+ export class CoreModule implements NestModule, OnModuleInit {
96
+ constructor(
97
+ @Inject(forwardRef(() => SettingService))
98
+ private readonly settingService: SettingService
99
+ ) {}
100
+
101
+ onModuleInit() {
102
+ // Initialize the service locator for validators
103
+ ValidatorServiceLocator.setSettingService(this.settingService);
104
+ }
105
+
94
106
  configure(consumer: MiddlewareConsumer) {
95
107
  consumer
96
108
  .apply(LocaleInjectionMiddleware)
@@ -2,21 +2,21 @@ import { getLocaleText } from '@hed-hog/api-locale';
2
2
  import { Injectable } from '@nestjs/common';
3
3
  import {
4
4
  registerDecorator,
5
+ ValidationArguments,
5
6
  ValidationOptions,
6
7
  ValidatorConstraint,
7
8
  ValidatorConstraintInterface
8
9
  } from 'class-validator';
9
- import { SettingService } from '../setting/setting.service';
10
10
  import { getLocaleFromContext } from '../utils/locale-context';
11
+ import { ValidatorServiceLocator } from './service-locator';
11
12
 
12
13
  @ValidatorConstraint({ async: true })
13
14
  @Injectable()
14
15
  export class IsEmailWithSettingsConstraint
15
16
  implements ValidatorConstraintInterface
16
17
  {
17
- constructor(private readonly settingService: SettingService) {}
18
18
 
19
- async validate(email: string): Promise<boolean> {
19
+ async validate(email: string, args: ValidationArguments): Promise<boolean> {
20
20
  if (!email) {
21
21
  return false;
22
22
  }
@@ -33,7 +33,9 @@ export class IsEmailWithSettingsConstraint
33
33
  return false;
34
34
  }
35
35
 
36
- const settings = await this.settingService.getSystemSettings();
36
+ try {
37
+ const settingService = ValidatorServiceLocator.getSettingService();
38
+ const settings = await settingService.getSystemSettings();
37
39
  const blacklist = settings.setting['email-host-blacklist'] || [];
38
40
  const whitelist = settings.setting['email-host-whitelist'] || [];
39
41
 
@@ -58,6 +60,10 @@ export class IsEmailWithSettingsConstraint
58
60
 
59
61
  // No restrictions, email is valid
60
62
  return true;
63
+ } catch (error) {
64
+ console.warn('[IsEmailWithSettingsConstraint] Error getting SettingService:', error);
65
+ return true; // Allow if service is not available
66
+ }
61
67
  }
62
68
 
63
69
  defaultMessage(): string {
@@ -1,22 +1,21 @@
1
1
  import { getLocaleText } from '@hed-hog/api-locale';
2
2
  import { Injectable } from '@nestjs/common';
3
3
  import {
4
- registerDecorator,
5
- ValidationOptions,
6
- ValidatorConstraint,
7
- ValidatorConstraintInterface
4
+ registerDecorator,
5
+ ValidationArguments,
6
+ ValidationOptions,
7
+ ValidatorConstraint,
8
+ ValidatorConstraintInterface
8
9
  } from 'class-validator';
9
- import { SettingService } from '../setting/setting.service';
10
10
  import { getLocaleFromContext } from '../utils/locale-context';
11
+ import { ValidatorServiceLocator } from './service-locator';
11
12
 
12
13
  @ValidatorConstraint({ async: true })
13
14
  @Injectable()
14
15
  export class IsPinCodeWithSettingConstraint implements ValidatorConstraintInterface {
15
16
  private settings: any = null;
16
17
 
17
- constructor(private readonly settingService: SettingService) {}
18
-
19
- async validate(pinCode: string): Promise<boolean> {
18
+ async validate(pinCode: string, args: ValidationArguments): Promise<boolean> {
20
19
  this.settings = null;
21
20
 
22
21
  if (!pinCode) {
@@ -29,11 +28,17 @@ export class IsPinCodeWithSettingConstraint implements ValidatorConstraintInterf
29
28
  return false;
30
29
  }
31
30
 
32
- this.settings = await this.settingService.getSystemSettings();
33
- const codeLength = this.settings.setting['mfa-email-code-length'] || 6;
31
+ try {
32
+ const settingService = ValidatorServiceLocator.getSettingService();
33
+ this.settings = await settingService.getSystemSettings();
34
+ const codeLength = this.settings.setting['mfa-email-code-length'] || 6;
34
35
 
35
- // Validate pin code length matches the configured length
36
- return pinCode.length === Number(codeLength);
36
+ // Validate pin code length matches the configured length
37
+ return pinCode.length === Number(codeLength);
38
+ } catch (error) {
39
+ console.warn('[IsPinCodeWithSettingConstraint] Error getting SettingService:', error);
40
+ return true; // Allow if service is not available
41
+ }
37
42
  }
38
43
 
39
44
  defaultMessage(): string {
@@ -2,12 +2,13 @@ import { getLocaleText } from '@hed-hog/api-locale';
2
2
  import { Injectable } from '@nestjs/common';
3
3
  import {
4
4
  registerDecorator,
5
+ ValidationArguments,
5
6
  ValidationOptions,
6
7
  ValidatorConstraint,
7
8
  ValidatorConstraintInterface
8
9
  } from 'class-validator';
9
- import { SettingService } from '../setting/setting.service';
10
10
  import { getLocaleFromContext } from '../utils/locale-context';
11
+ import { ValidatorServiceLocator } from './service-locator';
11
12
 
12
13
  @ValidatorConstraint({ async: true })
13
14
  @Injectable()
@@ -17,9 +18,7 @@ export class IsStrongPasswordWithSettingsConstraint
17
18
  private failedRule: string | null = null;
18
19
  private settings: any = null;
19
20
 
20
- constructor(private readonly settingService: SettingService) {}
21
-
22
- async validate(password: string): Promise<boolean> {
21
+ async validate(password: string, args: ValidationArguments): Promise<boolean> {
23
22
  this.failedRule = null;
24
23
  this.settings = null;
25
24
 
@@ -28,7 +27,9 @@ export class IsStrongPasswordWithSettingsConstraint
28
27
  return false;
29
28
  }
30
29
 
31
- this.settings = await this.settingService.getSystemSettings();
30
+ try {
31
+ const settingService = ValidatorServiceLocator.getSettingService();
32
+ this.settings = await settingService.getSystemSettings();
32
33
  const minLength = this.settings.setting['password-min-length'] || 6;
33
34
  const minLowercase = this.settings.setting['password-min-lowercase'] || 0;
34
35
  const minUppercase = this.settings.setting['password-min-uppercase'] || 0;
@@ -68,6 +69,10 @@ export class IsStrongPasswordWithSettingsConstraint
68
69
  }
69
70
 
70
71
  return true;
72
+ } catch (error) {
73
+ console.warn('[IsStrongPasswordWithSettingsConstraint] Error getting SettingService:', error);
74
+ return true; // Allow if service is not available
75
+ }
71
76
  }
72
77
 
73
78
  defaultMessage(): string {
@@ -0,0 +1,20 @@
1
+ import { SettingService } from '../setting/setting.service';
2
+
3
+ /**
4
+ * Service locator for validators that can't use dependency injection
5
+ * This is set up during application bootstrap
6
+ */
7
+ export class ValidatorServiceLocator {
8
+ private static settingService: SettingService;
9
+
10
+ static setSettingService(service: SettingService): void {
11
+ this.settingService = service;
12
+ }
13
+
14
+ static getSettingService(): SettingService {
15
+ if (!this.settingService) {
16
+ throw new Error('SettingService not initialized in ValidatorServiceLocator');
17
+ }
18
+ return this.settingService;
19
+ }
20
+ }