@hed-hog/core 0.0.65 → 0.0.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/auth/auth.controller.d.ts +1 -1
  2. package/dist/auth/auth.controller.d.ts.map +1 -1
  3. package/dist/auth/auth.controller.js +1 -1
  4. package/dist/auth/auth.controller.js.map +1 -1
  5. package/dist/auth/auth.service.d.ts +1 -1
  6. package/dist/core/system.controller.d.ts.map +1 -1
  7. package/dist/core/system.controller.js +2 -0
  8. package/dist/core/system.controller.js.map +1 -1
  9. package/dist/core.module.d.ts +6 -2
  10. package/dist/core.module.d.ts.map +1 -1
  11. package/dist/core.module.js +18 -1
  12. package/dist/core.module.js.map +1 -1
  13. package/dist/dashboard/dashboard/dashboard.controller.d.ts +1 -1
  14. package/dist/dashboard/dashboard/dashboard.controller.d.ts.map +1 -1
  15. package/dist/dashboard/dashboard/dashboard.controller.js +4 -3
  16. package/dist/dashboard/dashboard/dashboard.controller.js.map +1 -1
  17. package/dist/dashboard/dashboard-core/dashboard-core.controller.d.ts +1 -1
  18. package/dist/dashboard/dashboard-core/dashboard-core.controller.d.ts.map +1 -1
  19. package/dist/dashboard/dashboard-core/dashboard-core.controller.js +2 -0
  20. package/dist/dashboard/dashboard-core/dashboard-core.controller.js.map +1 -1
  21. package/dist/dashboard/dashboard-core/dashboard-core.service.d.ts +1 -1
  22. package/dist/dashboard/dashboard-user/dashboard-user.controller.d.ts +3 -3
  23. package/dist/dashboard/dashboard-user/dashboard-user.service.d.ts +3 -3
  24. package/dist/profile/profile.controller.d.ts.map +1 -1
  25. package/dist/profile/profile.controller.js +1 -0
  26. package/dist/profile/profile.controller.js.map +1 -1
  27. package/dist/role/guards/role.guard.d.ts.map +1 -1
  28. package/dist/role/guards/role.guard.js +2 -2
  29. package/dist/role/guards/role.guard.js.map +1 -1
  30. package/dist/session/session.controller.d.ts.map +1 -1
  31. package/dist/session/session.controller.js +1 -0
  32. package/dist/session/session.controller.js.map +1 -1
  33. package/dist/user/user.controller.d.ts +1 -1
  34. package/dist/user/user.service.d.ts +2 -2
  35. package/dist/validators/is-email-with-settings.validator.d.ts +2 -5
  36. package/dist/validators/is-email-with-settings.validator.d.ts.map +1 -1
  37. package/dist/validators/is-email-with-settings.validator.js +28 -28
  38. package/dist/validators/is-email-with-settings.validator.js.map +1 -1
  39. package/dist/validators/is-pin-code-with-setting.validator.d.ts +2 -5
  40. package/dist/validators/is-pin-code-with-setting.validator.d.ts.map +1 -1
  41. package/dist/validators/is-pin-code-with-setting.validator.js +15 -13
  42. package/dist/validators/is-pin-code-with-setting.validator.js.map +1 -1
  43. package/dist/validators/is-strong-password-with-settings.validator.d.ts +2 -5
  44. package/dist/validators/is-strong-password-with-settings.validator.d.ts.map +1 -1
  45. package/dist/validators/is-strong-password-with-settings.validator.js +42 -40
  46. package/dist/validators/is-strong-password-with-settings.validator.js.map +1 -1
  47. package/dist/validators/service-locator.d.ts +11 -0
  48. package/dist/validators/service-locator.d.ts.map +1 -0
  49. package/dist/validators/service-locator.js +20 -0
  50. package/dist/validators/service-locator.js.map +1 -0
  51. package/package.json +5 -5
  52. package/src/auth/auth.controller.ts +1 -2
  53. package/src/core/system.controller.ts +2 -1
  54. package/src/core.module.ts +14 -2
  55. package/src/dashboard/dashboard/dashboard.controller.ts +4 -4
  56. package/src/dashboard/dashboard-core/dashboard-core.controller.ts +2 -1
  57. package/src/profile/profile.controller.ts +2 -2
  58. package/src/role/guards/role.guard.ts +4 -1
  59. package/src/session/session.controller.ts +2 -3
  60. package/src/validators/is-email-with-settings.validator.ts +10 -4
  61. package/src/validators/is-pin-code-with-setting.validator.ts +17 -12
  62. package/src/validators/is-strong-password-with-settings.validator.ts +10 -5
  63. package/src/validators/service-locator.ts +20 -0
@@ -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;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E,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,OA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,EAClB,uBAAuB,EACvB,MAAM,EACN,wEAAwE,CACzE,CAAC;IACJ,CAAC;CACF,CAAA;AAvDY,wEAA8B;yCAA9B,8BAA8B;IAF1C,IAAA,qCAAmB,EAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACpC,IAAA,mBAAU,GAAE;qCAIkC,gCAAc;GAHhD,8BAA8B,CAuD1C;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
+ {"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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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;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AO,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,CAAC;QACjC,aAAQ,GAAQ,IAAI,CAAC;IAiG/B,CAAC;IA/FC,KAAK,CAAC,QAAQ,CAAC,QAAgB,EAAE,IAAyB;QACxD,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;YACH,MAAM,cAAc,GAAG,yCAAuB,CAAC,iBAAiB,EAAE,CAAC;YACnE,IAAI,CAAC,QAAQ,GAAG,MAAM,cAAc,CAAC,iBAAiB,EAAE,CAAC;YAC3D,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;YACpE,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;YAC1E,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,wBAAwB,CAAC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AM,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;AArGY,wFAAsC;iDAAtC,sCAAsC;IAFlD,IAAA,qCAAmB,EAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACpC,IAAA,mBAAU,GAAE;GACA,sCAAsC,CAqGlD;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"}
@@ -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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hed-hog/core",
3
- "version": "0.0.65",
3
+ "version": "0.0.67",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "dependencies": {
@@ -30,11 +30,11 @@
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
- "@hed-hog/api-pagination": "0.0.3",
35
- "@hed-hog/api-prisma": "0.0.4",
36
33
  "@hed-hog/api-locale": "0.0.10",
37
- "@hed-hog/api": "0.0.3"
34
+ "@hed-hog/api-mail": "0.0.7",
35
+ "@hed-hog/api-pagination": "0.0.4",
36
+ "@hed-hog/api": "0.0.3",
37
+ "@hed-hog/api-prisma": "0.0.4"
38
38
  },
39
39
  "exports": {
40
40
  ".": {
@@ -23,7 +23,7 @@ import { LoginWithRecoveryCodeDTO } from './dto/login-with-recovery-code';
23
23
  import { LoginDTO } from './dto/login.dto';
24
24
  import { ResendMfaCodeDTO } from './dto/resend-mfa-code.dto';
25
25
  import { ResetDTO } from './dto/reset.dto';
26
-
26
+ @Role()
27
27
  @Controller('auth')
28
28
  export class AuthController {
29
29
  constructor(
@@ -35,7 +35,6 @@ export class AuthController {
35
35
  private readonly user: UserService,
36
36
  ) { }
37
37
 
38
- @Role()
39
38
  @Get('verify')
40
39
  async verify(@User() { id }, @Locale() locale: string) {
41
40
  return this.service.verifyUser(locale, id);
@@ -1,6 +1,7 @@
1
+ import { Role } from '@hed-hog/api';
1
2
  import { Controller, forwardRef, Get, Inject } from '@nestjs/common';
2
3
  import { SystemService } from './system.service';
3
-
4
+ @Role()
4
5
  @Controller('system')
5
6
  export class SystemController {
6
7
  constructor(
@@ -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)
@@ -1,3 +1,6 @@
1
+ import { DeleteDTO, Role } from '@hed-hog/api';
2
+ import { Locale } from '@hed-hog/api-locale';
3
+ import { Pagination } from '@hed-hog/api-pagination';
1
4
  import {
2
5
  Body,
3
6
  Controller,
@@ -9,12 +12,9 @@ import {
9
12
  Post,
10
13
  } from '@nestjs/common';
11
14
  import { DashboardService } from './dashboard.service';
12
- import { Locale } from '@hed-hog/api-locale';
13
- import { Pagination } from '@hed-hog/api-pagination';
14
15
  import { CreateDTO } from './dto/create.dto';
15
16
  import { UpdateDTO } from './dto/update.dto';
16
- import { DeleteDTO } from '@hed-hog/api';
17
-
17
+ @Role()
18
18
  @Controller('/dashboard')
19
19
  export class DashboardController {
20
20
  constructor(private readonly dashboardService: DashboardService) {}
@@ -1,7 +1,8 @@
1
+ import { Role } from '@hed-hog/api';
1
2
  import { Locale } from '@hed-hog/api-locale';
2
3
  import { Controller, Get, Param } from '@nestjs/common';
3
4
  import { DashboardCoreService } from './dashboard-core.service';
4
-
5
+ @Role()
5
6
  @Controller('dashboard-core')
6
7
  export class DashboardCoreController {
7
8
  constructor(private readonly dashboardCoreService: DashboardCoreService) {}
@@ -1,4 +1,4 @@
1
- import { User } from '@hed-hog/api';
1
+ import { Role, User } from '@hed-hog/api';
2
2
  import { Locale } from '@hed-hog/api-locale';
3
3
  import { Body, Controller, Delete, Get, Param, ParseIntPipe, Post, Put, UploadedFile, UseInterceptors } from '@nestjs/common';
4
4
  import { FileInterceptor } from '@nestjs/platform-express';
@@ -18,7 +18,7 @@ import { VerifyMfaTotpDto } from './dto/verify-mfa-totp.dto';
18
18
  import { VerifyWebAuthnRegistrationDto } from './dto/verify-webauthn-registration.dto';
19
19
  import { VerifyWebAuthnDto } from './dto/verify-webauthn.dto';
20
20
  import { ProfileService } from './profile.service';
21
-
21
+ @Role()
22
22
  @Controller('profile')
23
23
  export class ProfileController {
24
24
 
@@ -63,7 +63,7 @@ export class RoleGuard implements CanActivate {
63
63
  throw new UnauthorizedException(`Token not provided`);
64
64
  }
65
65
 
66
- const userId = (request as any)?.auth?.user?.id;
66
+ const userId = (request as any)?.auth?.sub;
67
67
 
68
68
  let httpMethod: any;
69
69
  switch (requestMethod) {
@@ -93,6 +93,9 @@ export class RoleGuard implements CanActivate {
93
93
  break;
94
94
  }
95
95
 
96
+
97
+
98
+
96
99
  const route = await this.prisma.route.count({
97
100
  where: {
98
101
  method: httpMethod,
@@ -1,9 +1,8 @@
1
- import { User } from '@hed-hog/api';
1
+ import { Role, User } from '@hed-hog/api';
2
2
  import { Pagination, PaginationDTO } from '@hed-hog/api-pagination';
3
3
  import { Controller, Delete, Get, Param } from '@nestjs/common';
4
4
  import { SessionService } from './session.service';
5
-
6
-
5
+ @Role()
7
6
  @Controller('sessions')
8
7
  export class SessionController {
9
8
  constructor(
@@ -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 {