@breadstone/archipel-platform-authentication 0.0.8 → 0.0.9

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 (71) hide show
  1. package/package.json +35 -27
  2. package/src/AuthModule.d.ts +22 -8
  3. package/src/AuthModule.js +19 -24
  4. package/src/connectors/AnonymousConnector.d.ts +42 -0
  5. package/src/connectors/AnonymousConnector.js +54 -0
  6. package/src/{strategies/AppleStrategy.d.ts → connectors/AppleConnector.d.ts} +16 -5
  7. package/src/{strategies/AppleStrategy.js → connectors/AppleConnector.js} +16 -15
  8. package/src/connectors/ConnectorBase.d.ts +39 -0
  9. package/src/connectors/ConnectorBase.js +33 -0
  10. package/src/connectors/GithubConnector.d.ts +34 -0
  11. package/src/{strategies/GithubStrategy.js → connectors/GithubConnector.js} +13 -12
  12. package/src/{strategies/GoogleStrategy.d.ts → connectors/GoogleConnector.d.ts} +17 -6
  13. package/src/{strategies/GoogleStrategy.js → connectors/GoogleConnector.js} +14 -13
  14. package/src/{strategies/JwtStrategy.d.ts → connectors/JwtConnector.d.ts} +16 -6
  15. package/src/{strategies/JwtStrategy.js → connectors/JwtConnector.js} +11 -10
  16. package/src/{strategies/LocalStrategy.d.ts → connectors/LocalConnector.d.ts} +16 -6
  17. package/src/{strategies/LocalStrategy.js → connectors/LocalConnector.js} +9 -9
  18. package/src/{strategies/MicrosoftStrategy.d.ts → connectors/MicrosoftConnector.d.ts} +16 -6
  19. package/src/{strategies/MicrosoftStrategy.js → connectors/MicrosoftConnector.js} +15 -14
  20. package/src/{apple → connectors/apple}/env.js +1 -1
  21. package/src/connectors/apple/index.d.ts +2 -0
  22. package/src/connectors/apple/index.js +8 -0
  23. package/src/{github → connectors/github}/env.js +1 -1
  24. package/src/connectors/github/index.d.ts +2 -0
  25. package/src/connectors/github/index.js +8 -0
  26. package/src/{google → connectors/google}/env.js +1 -1
  27. package/src/connectors/google/index.d.ts +2 -0
  28. package/src/connectors/google/index.js +8 -0
  29. package/src/{microsoft → connectors/microsoft}/env.js +1 -1
  30. package/src/connectors/microsoft/index.d.ts +2 -0
  31. package/src/connectors/microsoft/index.js +8 -0
  32. package/src/env.d.ts +2 -0
  33. package/src/env.js +9 -3
  34. package/src/{services/mfa → mfa}/IMfaChannel.d.ts +1 -1
  35. package/src/{services/mfa → mfa}/MfaEncryptionService.js +4 -4
  36. package/src/{services → mfa}/MfaService.d.ts +3 -3
  37. package/src/{services → mfa}/MfaService.js +3 -3
  38. package/src/{services/mfa → mfa}/MfaState.js +2 -2
  39. package/src/{services/mfa → mfa}/channels/EmailOtpMfaChannel.d.ts +2 -2
  40. package/src/{services/mfa → mfa}/channels/EmailOtpMfaChannel.js +4 -3
  41. package/src/{services/mfa → mfa}/channels/PushMfaChannel.d.ts +2 -2
  42. package/src/{services/mfa → mfa}/channels/PushMfaChannel.js +4 -3
  43. package/src/{services/mfa → mfa}/channels/SmsMfaChannel.d.ts +2 -2
  44. package/src/{services/mfa → mfa}/channels/SmsMfaChannel.js +4 -3
  45. package/src/{services/mfa → mfa}/channels/TotpMfaChannel.d.ts +3 -3
  46. package/src/{services/mfa → mfa}/channels/TotpMfaChannel.js +5 -4
  47. package/src/mfa/totp/index.d.ts +22 -0
  48. package/src/mfa/totp/index.js +29 -0
  49. package/src/services/ChallengeService.js +4 -3
  50. package/src/services/VerificationService.js +2 -1
  51. package/src/services/index.d.ts +1 -1
  52. package/src/services/index.js +1 -1
  53. package/src/strategies/AnonymousStrategy.js +2 -1
  54. package/src/apple/index.d.ts +0 -2
  55. package/src/apple/index.js +0 -8
  56. package/src/github/index.d.ts +0 -2
  57. package/src/github/index.js +0 -8
  58. package/src/google/index.d.ts +0 -2
  59. package/src/google/index.js +0 -8
  60. package/src/microsoft/index.d.ts +0 -2
  61. package/src/microsoft/index.js +0 -8
  62. package/src/strategies/GithubStrategy.d.ts +0 -23
  63. /package/src/{apple → connectors/apple}/env.d.ts +0 -0
  64. /package/src/{github → connectors/github}/env.d.ts +0 -0
  65. /package/src/{google → connectors/google}/env.d.ts +0 -0
  66. /package/src/{microsoft → connectors/microsoft}/env.d.ts +0 -0
  67. /package/src/{services/mfa → mfa}/IMfaChannel.js +0 -0
  68. /package/src/{services/mfa → mfa}/MfaEncryptionService.d.ts +0 -0
  69. /package/src/{services/mfa → mfa}/MfaState.d.ts +0 -0
  70. /package/src/{services/mfa → mfa}/MfaTokens.d.ts +0 -0
  71. /package/src/{services/mfa → mfa}/MfaTokens.js +0 -0
@@ -1,24 +1,25 @@
1
1
  "use strict";
2
2
  // #region Imports
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.GoogleStrategy = void 0;
4
+ exports.GoogleConnector = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  const archipel_platform_core_1 = require("@breadstone/archipel-platform-core");
7
7
  const common_1 = require("@nestjs/common");
8
- const passport_1 = require("@nestjs/passport");
9
8
  const passport_google_oauth20_1 = require("passport-google-oauth20");
10
9
  const SocialAuthPort_1 = require("../contracts/SocialAuthPort");
10
+ const env_1 = require("../env");
11
+ const ConnectorBase_1 = require("./ConnectorBase");
11
12
  // #endregion
12
13
  /**
13
- * The `GoogleStrategy` integrates Google OAuth authentication.
14
+ * The `GoogleConnector` integrates Google OAuth authentication.
14
15
  *
15
16
  * @public
16
17
  */
17
- let GoogleStrategy = class GoogleStrategy extends (0, passport_1.PassportStrategy)(passport_google_oauth20_1.Strategy, 'google') {
18
+ let GoogleConnector = class GoogleConnector extends (0, ConnectorBase_1.ConnectorBase)(passport_google_oauth20_1.Strategy, 'google') {
18
19
  // #endregion
19
20
  // #region Ctor
20
21
  /**
21
- * Initializes a new instance of the `GoogleStrategy` class.
22
+ * Initializes a new instance of the `GoogleConnector` class.
22
23
  *
23
24
  * @public
24
25
  * @param socialAuth Social auth port instance.
@@ -26,14 +27,14 @@ let GoogleStrategy = class GoogleStrategy extends (0, passport_1.PassportStrateg
26
27
  */
27
28
  constructor(socialAuth, configService) {
28
29
  const scope = configService
29
- .tryGet('AUTH_GOOGLE_SCOPE', 'email,profile')
30
+ .tryGet(env_1.AUTH_GOOGLE_SCOPE.key, 'email,profile')
30
31
  .split(',')
31
32
  .map((s) => s.trim())
32
33
  .filter(Boolean);
33
34
  super({
34
- clientID: configService.get('AUTH_GOOGLE_CLIENT_ID'),
35
- clientSecret: configService.get('AUTH_GOOGLE_CLIENT_SECRET'),
36
- callbackURL: configService.tryGet('AUTH_GOOGLE_CALLBACK_URL', '/auth/google/callback'),
35
+ clientID: configService.get(env_1.AUTH_GOOGLE_CLIENT_ID.key),
36
+ clientSecret: configService.get(env_1.AUTH_GOOGLE_CLIENT_SECRET.key),
37
+ callbackURL: configService.tryGet(env_1.AUTH_GOOGLE_CALLBACK_URL.key, '/auth/google/callback'),
37
38
  scope,
38
39
  state: true,
39
40
  });
@@ -71,9 +72,9 @@ let GoogleStrategy = class GoogleStrategy extends (0, passport_1.PassportStrateg
71
72
  return user;
72
73
  }
73
74
  };
74
- exports.GoogleStrategy = GoogleStrategy;
75
- exports.GoogleStrategy = GoogleStrategy = tslib_1.__decorate([
75
+ exports.GoogleConnector = GoogleConnector;
76
+ exports.GoogleConnector = GoogleConnector = tslib_1.__decorate([
76
77
  (0, common_1.Injectable)(),
77
78
  tslib_1.__metadata("design:paramtypes", [SocialAuthPort_1.SocialAuthPort, archipel_platform_core_1.ConfigService])
78
- ], GoogleStrategy);
79
- //# sourceMappingURL=GoogleStrategy.js.map
79
+ ], GoogleConnector);
80
+ //# sourceMappingURL=GoogleConnector.js.map
@@ -1,18 +1,28 @@
1
1
  import { ConfigService } from '@breadstone/archipel-platform-core';
2
- import { Strategy } from 'passport-jwt';
3
2
  import { AuthSubjectPort } from '../contracts/AuthSubjectPort';
4
3
  import type { IAuthSubject } from '../contracts/IAuthSubject';
5
4
  import { JwtPayloadBase } from '../models/JwtPayloadBase';
6
- declare const JwtStrategy_base: new (...args: [opt: import("passport-jwt").StrategyOptionsWithRequest] | [opt: import("passport-jwt").StrategyOptionsWithoutRequest]) => Strategy & {
7
- validate(...args: any[]): unknown;
5
+ declare const JwtConnector_base: (abstract new (...args: any[]) => {
6
+ [x: string]: any;
7
+ validate(...args: unknown[]): Promise<unknown>;
8
+ }) & {
9
+ apply(this: Function, thisArg: any, argArray?: any): any;
10
+ call(this: Function, thisArg: any, ...argArray: any[]): any;
11
+ bind(this: Function, thisArg: any, ...argArray: any[]): any;
12
+ toString(): string;
13
+ readonly length: number;
14
+ arguments: any;
15
+ caller: Function;
16
+ readonly name: string;
17
+ [Symbol.hasInstance](value: any): boolean;
8
18
  };
9
19
  /**
10
- * JWT strategy for handling token validation.
20
+ * JWT connector for handling token validation.
11
21
  */
12
- export declare class JwtStrategy extends JwtStrategy_base {
22
+ export declare class JwtConnector extends JwtConnector_base {
13
23
  private readonly _authSubject;
14
24
  /**
15
- * Constructs a new instance of the `JwtStrategy` class.
25
+ * Constructs a new instance of the `JwtConnector` class.
16
26
  *
17
27
  * @public
18
28
  * @param authSubject Auth subject port instance.
@@ -1,22 +1,23 @@
1
1
  "use strict";
2
2
  // #region Imports
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.JwtStrategy = void 0;
4
+ exports.JwtConnector = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  const archipel_platform_core_1 = require("@breadstone/archipel-platform-core");
7
7
  const common_1 = require("@nestjs/common");
8
- const passport_1 = require("@nestjs/passport");
9
8
  const passport_jwt_1 = require("passport-jwt");
10
9
  const AuthSubjectPort_1 = require("../contracts/AuthSubjectPort");
10
+ const env_1 = require("../env");
11
+ const ConnectorBase_1 = require("./ConnectorBase");
11
12
  // #endregion
12
13
  /**
13
- * JWT strategy for handling token validation.
14
+ * JWT connector for handling token validation.
14
15
  */
15
- let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(passport_jwt_1.Strategy) {
16
+ let JwtConnector = class JwtConnector extends (0, ConnectorBase_1.ConnectorBase)(passport_jwt_1.Strategy) {
16
17
  // #endregion
17
18
  // #region Ctor
18
19
  /**
19
- * Constructs a new instance of the `JwtStrategy` class.
20
+ * Constructs a new instance of the `JwtConnector` class.
20
21
  *
21
22
  * @public
22
23
  * @param authSubject Auth subject port instance.
@@ -26,7 +27,7 @@ let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(pas
26
27
  super({
27
28
  jwtFromRequest: passport_jwt_1.ExtractJwt.fromAuthHeaderAsBearerToken(),
28
29
  ignoreExpiration: false, // Optional: Allow or disallow expired tokens
29
- secretOrKey: configService.get('AUTH_JWT_SECRET'), // The secret used for signing tokens
30
+ secretOrKey: configService.get(env_1.AUTH_JWT_SECRET.key), // The secret used for signing tokens
30
31
  });
31
32
  this._authSubject = authSubject;
32
33
  }
@@ -47,9 +48,9 @@ let JwtStrategy = class JwtStrategy extends (0, passport_1.PassportStrategy)(pas
47
48
  return user;
48
49
  }
49
50
  };
50
- exports.JwtStrategy = JwtStrategy;
51
- exports.JwtStrategy = JwtStrategy = tslib_1.__decorate([
51
+ exports.JwtConnector = JwtConnector;
52
+ exports.JwtConnector = JwtConnector = tslib_1.__decorate([
52
53
  (0, common_1.Injectable)(),
53
54
  tslib_1.__metadata("design:paramtypes", [AuthSubjectPort_1.AuthSubjectPort, archipel_platform_core_1.ConfigService])
54
- ], JwtStrategy);
55
- //# sourceMappingURL=JwtStrategy.js.map
55
+ ], JwtConnector);
56
+ //# sourceMappingURL=JwtConnector.js.map
@@ -1,20 +1,30 @@
1
1
  import { BcryptService } from '@breadstone/archipel-platform-cryptography';
2
- import { Strategy } from 'passport-local';
3
2
  import { AuthSubjectPort } from '../contracts/AuthSubjectPort';
4
3
  import type { IAuthSubject } from '../contracts/IAuthSubject';
5
- declare const LocalStrategy_base: new (...args: [] | [options: import("passport-local").IStrategyOptionsWithRequest] | [options: import("passport-local").IStrategyOptions]) => Strategy & {
6
- validate(...args: any[]): unknown;
4
+ declare const LocalConnector_base: (abstract new (...args: any[]) => {
5
+ [x: string]: any;
6
+ validate(...args: unknown[]): Promise<unknown>;
7
+ }) & {
8
+ apply(this: Function, thisArg: any, argArray?: any): any;
9
+ call(this: Function, thisArg: any, ...argArray: any[]): any;
10
+ bind(this: Function, thisArg: any, ...argArray: any[]): any;
11
+ toString(): string;
12
+ readonly length: number;
13
+ arguments: any;
14
+ caller: Function;
15
+ readonly name: string;
16
+ [Symbol.hasInstance](value: any): boolean;
7
17
  };
8
18
  /**
9
- * Local strategy for user name and password login.
19
+ * Local connector for user name and password login.
10
20
  *
11
21
  * @public
12
22
  */
13
- export declare class LocalStrategy extends LocalStrategy_base {
23
+ export declare class LocalConnector extends LocalConnector_base {
14
24
  private readonly _authSubject;
15
25
  private readonly _bcryptService;
16
26
  /**
17
- * Constructs a new instance of the `LocalStrategy` class.
27
+ * Constructs a new instance of the `LocalConnector` class.
18
28
  *
19
29
  * @public
20
30
  * @param authSubject Auth subject port instance.
@@ -1,24 +1,24 @@
1
1
  "use strict";
2
2
  // #region Imports
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.LocalStrategy = void 0;
4
+ exports.LocalConnector = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  const archipel_platform_cryptography_1 = require("@breadstone/archipel-platform-cryptography");
7
7
  const common_1 = require("@nestjs/common");
8
- const passport_1 = require("@nestjs/passport");
9
8
  const passport_local_1 = require("passport-local");
10
9
  const AuthSubjectPort_1 = require("../contracts/AuthSubjectPort");
10
+ const ConnectorBase_1 = require("./ConnectorBase");
11
11
  // #endregion
12
12
  /**
13
- * Local strategy for user name and password login.
13
+ * Local connector for user name and password login.
14
14
  *
15
15
  * @public
16
16
  */
17
- let LocalStrategy = class LocalStrategy extends (0, passport_1.PassportStrategy)(passport_local_1.Strategy) {
17
+ let LocalConnector = class LocalConnector extends (0, ConnectorBase_1.ConnectorBase)(passport_local_1.Strategy) {
18
18
  // #endregion
19
19
  // #region Ctor
20
20
  /**
21
- * Constructs a new instance of the `LocalStrategy` class.
21
+ * Constructs a new instance of the `LocalConnector` class.
22
22
  *
23
23
  * @public
24
24
  * @param authSubject Auth subject port instance.
@@ -51,9 +51,9 @@ let LocalStrategy = class LocalStrategy extends (0, passport_1.PassportStrategy)
51
51
  return user;
52
52
  }
53
53
  };
54
- exports.LocalStrategy = LocalStrategy;
55
- exports.LocalStrategy = LocalStrategy = tslib_1.__decorate([
54
+ exports.LocalConnector = LocalConnector;
55
+ exports.LocalConnector = LocalConnector = tslib_1.__decorate([
56
56
  (0, common_1.Injectable)(),
57
57
  tslib_1.__metadata("design:paramtypes", [AuthSubjectPort_1.AuthSubjectPort, archipel_platform_cryptography_1.BcryptService])
58
- ], LocalStrategy);
59
- //# sourceMappingURL=LocalStrategy.js.map
58
+ ], LocalConnector);
59
+ //# sourceMappingURL=LocalConnector.js.map
@@ -1,20 +1,30 @@
1
1
  import { ConfigService } from '@breadstone/archipel-platform-core';
2
2
  import type { Profile as PassportProfile } from 'passport';
3
- import { Strategy } from 'passport-microsoft';
4
3
  import type { IAuthSubject } from '../contracts/IAuthSubject';
5
4
  import { SocialAuthPort } from '../contracts/SocialAuthPort';
6
- declare const MicrosoftStrategy_base: new (...args: [options: import("passport-microsoft").MicrosoftStrategyOptionsWithRequest] | [options: import("passport-microsoft").MicrosoftStrategyOptions]) => Strategy & {
7
- validate(...args: any[]): unknown;
5
+ declare const MicrosoftConnector_base: (abstract new (...args: any[]) => {
6
+ [x: string]: any;
7
+ validate(...args: unknown[]): Promise<unknown>;
8
+ }) & {
9
+ apply(this: Function, thisArg: any, argArray?: any): any;
10
+ call(this: Function, thisArg: any, ...argArray: any[]): any;
11
+ bind(this: Function, thisArg: any, ...argArray: any[]): any;
12
+ toString(): string;
13
+ readonly length: number;
14
+ arguments: any;
15
+ caller: Function;
16
+ readonly name: string;
17
+ [Symbol.hasInstance](value: any): boolean;
8
18
  };
9
19
  /**
10
- * The `MicrosoftStrategy` integrates Microsoft OAuth authentication.
20
+ * The `MicrosoftConnector` integrates Microsoft OAuth authentication.
11
21
  *
12
22
  * @public
13
23
  */
14
- export declare class MicrosoftStrategy extends MicrosoftStrategy_base {
24
+ export declare class MicrosoftConnector extends MicrosoftConnector_base {
15
25
  private readonly _socialAuth;
16
26
  /**
17
- * Initializes a new instance of the `MicrosoftStrategy` class.
27
+ * Initializes a new instance of the `MicrosoftConnector` class.
18
28
  *
19
29
  * @public
20
30
  * @param socialAuth Social auth port instance.
@@ -1,24 +1,25 @@
1
1
  "use strict";
2
2
  // #region Imports
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.MicrosoftStrategy = void 0;
4
+ exports.MicrosoftConnector = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  const archipel_platform_core_1 = require("@breadstone/archipel-platform-core");
7
7
  const common_1 = require("@nestjs/common");
8
- const passport_1 = require("@nestjs/passport");
9
8
  const passport_microsoft_1 = require("passport-microsoft");
10
9
  const SocialAuthPort_1 = require("../contracts/SocialAuthPort");
10
+ const env_1 = require("../env");
11
+ const ConnectorBase_1 = require("./ConnectorBase");
11
12
  // #endregion
12
13
  /**
13
- * The `MicrosoftStrategy` integrates Microsoft OAuth authentication.
14
+ * The `MicrosoftConnector` integrates Microsoft OAuth authentication.
14
15
  *
15
16
  * @public
16
17
  */
17
- let MicrosoftStrategy = class MicrosoftStrategy extends (0, passport_1.PassportStrategy)(passport_microsoft_1.Strategy, 'microsoft') {
18
+ let MicrosoftConnector = class MicrosoftConnector extends (0, ConnectorBase_1.ConnectorBase)(passport_microsoft_1.Strategy, 'microsoft') {
18
19
  // #endregion
19
20
  // #region Ctor
20
21
  /**
21
- * Initializes a new instance of the `MicrosoftStrategy` class.
22
+ * Initializes a new instance of the `MicrosoftConnector` class.
22
23
  *
23
24
  * @public
24
25
  * @param socialAuth Social auth port instance.
@@ -26,15 +27,15 @@ let MicrosoftStrategy = class MicrosoftStrategy extends (0, passport_1.PassportS
26
27
  */
27
28
  constructor(socialAuth, configService) {
28
29
  const scope = configService
29
- .tryGet('AUTH_MICROSOFT_SCOPE', 'user.read')
30
+ .tryGet(env_1.AUTH_MICROSOFT_SCOPE.key, 'user.read')
30
31
  .split(',')
31
32
  .map((s) => s.trim())
32
33
  .filter(Boolean);
33
34
  super({
34
- clientID: configService.get('AUTH_MICROSOFT_CLIENT_ID'),
35
- clientSecret: configService.get('AUTH_MICROSOFT_CLIENT_SECRET'),
36
- callbackURL: configService.tryGet('AUTH_MICROSOFT_CALLBACK_URL', '/auth/microsoft/callback'),
37
- tenant: configService.tryGet('AUTH_MICROSOFT_TENANT', 'common'),
35
+ clientID: configService.get(env_1.AUTH_MICROSOFT_CLIENT_ID.key),
36
+ clientSecret: configService.get(env_1.AUTH_MICROSOFT_CLIENT_SECRET.key),
37
+ callbackURL: configService.tryGet(env_1.AUTH_MICROSOFT_CALLBACK_URL.key, '/auth/microsoft/callback'),
38
+ tenant: configService.tryGet(env_1.AUTH_MICROSOFT_TENANT.key, 'common'),
38
39
  scope,
39
40
  state: true,
40
41
  });
@@ -72,9 +73,9 @@ let MicrosoftStrategy = class MicrosoftStrategy extends (0, passport_1.PassportS
72
73
  return user;
73
74
  }
74
75
  };
75
- exports.MicrosoftStrategy = MicrosoftStrategy;
76
- exports.MicrosoftStrategy = MicrosoftStrategy = tslib_1.__decorate([
76
+ exports.MicrosoftConnector = MicrosoftConnector;
77
+ exports.MicrosoftConnector = MicrosoftConnector = tslib_1.__decorate([
77
78
  (0, common_1.Injectable)(),
78
79
  tslib_1.__metadata("design:paramtypes", [SocialAuthPort_1.SocialAuthPort, archipel_platform_core_1.ConfigService])
79
- ], MicrosoftStrategy);
80
- //# sourceMappingURL=MicrosoftStrategy.js.map
80
+ ], MicrosoftConnector);
81
+ //# sourceMappingURL=MicrosoftConnector.js.map
@@ -2,7 +2,7 @@
2
2
  // #region Imports
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.APPLE_AUTH_CONFIG_ENTRIES = void 0;
5
- const env_1 = require("../env");
5
+ const env_1 = require("../../env");
6
6
  // #endregion
7
7
  /** Configuration entries required by Apple Sign-In authentication. */
8
8
  exports.APPLE_AUTH_CONFIG_ENTRIES = [
@@ -0,0 +1,2 @@
1
+ export { AppleConnector } from '../AppleConnector';
2
+ export { APPLE_AUTH_CONFIG_ENTRIES } from './env';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.APPLE_AUTH_CONFIG_ENTRIES = exports.AppleConnector = void 0;
4
+ var AppleConnector_1 = require("../AppleConnector");
5
+ Object.defineProperty(exports, "AppleConnector", { enumerable: true, get: function () { return AppleConnector_1.AppleConnector; } });
6
+ var env_1 = require("./env");
7
+ Object.defineProperty(exports, "APPLE_AUTH_CONFIG_ENTRIES", { enumerable: true, get: function () { return env_1.APPLE_AUTH_CONFIG_ENTRIES; } });
8
+ //# sourceMappingURL=index.js.map
@@ -2,7 +2,7 @@
2
2
  // #region Imports
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.GITHUB_AUTH_CONFIG_ENTRIES = void 0;
5
- const env_1 = require("../env");
5
+ const env_1 = require("../../env");
6
6
  // #endregion
7
7
  /** Configuration entries required by GitHub OAuth authentication. */
8
8
  exports.GITHUB_AUTH_CONFIG_ENTRIES = [
@@ -0,0 +1,2 @@
1
+ export { GithubConnector } from '../GithubConnector';
2
+ export { GITHUB_AUTH_CONFIG_ENTRIES } from './env';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GITHUB_AUTH_CONFIG_ENTRIES = exports.GithubConnector = void 0;
4
+ var GithubConnector_1 = require("../GithubConnector");
5
+ Object.defineProperty(exports, "GithubConnector", { enumerable: true, get: function () { return GithubConnector_1.GithubConnector; } });
6
+ var env_1 = require("./env");
7
+ Object.defineProperty(exports, "GITHUB_AUTH_CONFIG_ENTRIES", { enumerable: true, get: function () { return env_1.GITHUB_AUTH_CONFIG_ENTRIES; } });
8
+ //# sourceMappingURL=index.js.map
@@ -2,7 +2,7 @@
2
2
  // #region Imports
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.GOOGLE_AUTH_CONFIG_ENTRIES = void 0;
5
- const env_1 = require("../env");
5
+ const env_1 = require("../../env");
6
6
  // #endregion
7
7
  /** Configuration entries required by Google OAuth authentication. */
8
8
  exports.GOOGLE_AUTH_CONFIG_ENTRIES = [
@@ -0,0 +1,2 @@
1
+ export { GoogleConnector } from '../GoogleConnector';
2
+ export { GOOGLE_AUTH_CONFIG_ENTRIES } from './env';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GOOGLE_AUTH_CONFIG_ENTRIES = exports.GoogleConnector = void 0;
4
+ var GoogleConnector_1 = require("../GoogleConnector");
5
+ Object.defineProperty(exports, "GoogleConnector", { enumerable: true, get: function () { return GoogleConnector_1.GoogleConnector; } });
6
+ var env_1 = require("./env");
7
+ Object.defineProperty(exports, "GOOGLE_AUTH_CONFIG_ENTRIES", { enumerable: true, get: function () { return env_1.GOOGLE_AUTH_CONFIG_ENTRIES; } });
8
+ //# sourceMappingURL=index.js.map
@@ -2,7 +2,7 @@
2
2
  // #region Imports
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.MICROSOFT_AUTH_CONFIG_ENTRIES = void 0;
5
- const env_1 = require("../env");
5
+ const env_1 = require("../../env");
6
6
  // #endregion
7
7
  /** Configuration entries required by Microsoft OAuth authentication. */
8
8
  exports.MICROSOFT_AUTH_CONFIG_ENTRIES = [
@@ -0,0 +1,2 @@
1
+ export { MicrosoftConnector } from '../MicrosoftConnector';
2
+ export { MICROSOFT_AUTH_CONFIG_ENTRIES } from './env';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MICROSOFT_AUTH_CONFIG_ENTRIES = exports.MicrosoftConnector = void 0;
4
+ var MicrosoftConnector_1 = require("../MicrosoftConnector");
5
+ Object.defineProperty(exports, "MicrosoftConnector", { enumerable: true, get: function () { return MicrosoftConnector_1.MicrosoftConnector; } });
6
+ var env_1 = require("./env");
7
+ Object.defineProperty(exports, "MICROSOFT_AUTH_CONFIG_ENTRIES", { enumerable: true, get: function () { return env_1.MICROSOFT_AUTH_CONFIG_ENTRIES; } });
8
+ //# sourceMappingURL=index.js.map
package/src/env.d.ts CHANGED
@@ -11,6 +11,8 @@ export declare const AUTH_MFA_ENCRYPTION_KEY: import("@breadstone/archipel-platf
11
11
  export declare const AUTH_MFA_CHALLENGE_EXPIRES_IN: import("@breadstone/archipel-platform-core").IConfigKey<string>;
12
12
  /** Maximum number of failed MFA attempts before lockout. */
13
13
  export declare const AUTH_MFA_MAX_ATTEMPTS: import("@breadstone/archipel-platform-core").IConfigKey<string>;
14
+ /** Issuer name shown in authenticator apps for TOTP MFA. */
15
+ export declare const AUTH_MFA_ISSUER: import("@breadstone/archipel-platform-core").IConfigKey<string>;
14
16
  /** Time-to-live for SMS OTP codes (e.g. `'10m'`). */
15
17
  export declare const AUTH_MFA_SMS_CODE_TTL: import("@breadstone/archipel-platform-core").IConfigKey<string>;
16
18
  /** Minimum interval between SMS resend requests (e.g. `'30s'`). */
package/src/env.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // #region Imports
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.PLATFORM_AUTHENTICATION_CONFIG_ENTRIES = exports.SEED_ANONYMOUS_USERNAME = exports.AUTH_GITHUB_SCOPE = exports.AUTH_GITHUB_CALLBACK_URL = exports.AUTH_GITHUB_CLIENT_SECRET = exports.AUTH_GITHUB_CLIENT_ID = exports.AUTH_APPLE_SCOPE = exports.AUTH_APPLE_CALLBACK_URL = exports.AUTH_APPLE_KEY_ID = exports.AUTH_APPLE_TEAM_ID = exports.AUTH_APPLE_CLIENT_ID = exports.AUTH_APPLE_PRIVATE_KEY = exports.AUTH_MICROSOFT_SCOPE = exports.AUTH_MICROSOFT_TENANT = exports.AUTH_MICROSOFT_CALLBACK_URL = exports.AUTH_MICROSOFT_CLIENT_SECRET = exports.AUTH_MICROSOFT_CLIENT_ID = exports.AUTH_GOOGLE_SCOPE = exports.AUTH_GOOGLE_CALLBACK_URL = exports.AUTH_GOOGLE_CLIENT_SECRET = exports.AUTH_GOOGLE_CLIENT_ID = exports.AUTH_MFA_PUSH_MIN_RESEND = exports.AUTH_MFA_PUSH_CODE_TTL = exports.AUTH_MFA_EMAIL_MIN_RESEND = exports.AUTH_MFA_EMAIL_CODE_TTL = exports.AUTH_MFA_SMS_MIN_RESEND = exports.AUTH_MFA_SMS_CODE_TTL = exports.AUTH_MFA_MAX_ATTEMPTS = exports.AUTH_MFA_CHALLENGE_EXPIRES_IN = exports.AUTH_MFA_ENCRYPTION_KEY = exports.AUTH_VERIFY_JWT_EXPIRES_IN = exports.AUTH_JWT_EXPIRES_IN = exports.AUTH_JWT_SECRET = void 0;
4
+ exports.PLATFORM_AUTHENTICATION_CONFIG_ENTRIES = exports.SEED_ANONYMOUS_USERNAME = exports.AUTH_GITHUB_SCOPE = exports.AUTH_GITHUB_CALLBACK_URL = exports.AUTH_GITHUB_CLIENT_SECRET = exports.AUTH_GITHUB_CLIENT_ID = exports.AUTH_APPLE_SCOPE = exports.AUTH_APPLE_CALLBACK_URL = exports.AUTH_APPLE_KEY_ID = exports.AUTH_APPLE_TEAM_ID = exports.AUTH_APPLE_CLIENT_ID = exports.AUTH_APPLE_PRIVATE_KEY = exports.AUTH_MICROSOFT_SCOPE = exports.AUTH_MICROSOFT_TENANT = exports.AUTH_MICROSOFT_CALLBACK_URL = exports.AUTH_MICROSOFT_CLIENT_SECRET = exports.AUTH_MICROSOFT_CLIENT_ID = exports.AUTH_GOOGLE_SCOPE = exports.AUTH_GOOGLE_CALLBACK_URL = exports.AUTH_GOOGLE_CLIENT_SECRET = exports.AUTH_GOOGLE_CLIENT_ID = exports.AUTH_MFA_PUSH_MIN_RESEND = exports.AUTH_MFA_PUSH_CODE_TTL = exports.AUTH_MFA_EMAIL_MIN_RESEND = exports.AUTH_MFA_EMAIL_CODE_TTL = exports.AUTH_MFA_SMS_MIN_RESEND = exports.AUTH_MFA_SMS_CODE_TTL = exports.AUTH_MFA_ISSUER = exports.AUTH_MFA_MAX_ATTEMPTS = exports.AUTH_MFA_CHALLENGE_EXPIRES_IN = exports.AUTH_MFA_ENCRYPTION_KEY = exports.AUTH_VERIFY_JWT_EXPIRES_IN = exports.AUTH_JWT_EXPIRES_IN = exports.AUTH_JWT_SECRET = void 0;
5
5
  const archipel_platform_core_1 = require("@breadstone/archipel-platform-core");
6
6
  // #endregion
7
7
  // ──────────────────────────────────────────────────────────────
@@ -22,6 +22,8 @@ exports.AUTH_MFA_ENCRYPTION_KEY = (0, archipel_platform_core_1.createConfigKey)(
22
22
  exports.AUTH_MFA_CHALLENGE_EXPIRES_IN = (0, archipel_platform_core_1.createConfigKey)('AUTH_MFA_CHALLENGE_EXPIRES_IN');
23
23
  /** Maximum number of failed MFA attempts before lockout. */
24
24
  exports.AUTH_MFA_MAX_ATTEMPTS = (0, archipel_platform_core_1.createConfigKey)('AUTH_MFA_MAX_ATTEMPTS');
25
+ /** Issuer name shown in authenticator apps for TOTP MFA. */
26
+ exports.AUTH_MFA_ISSUER = (0, archipel_platform_core_1.createConfigKey)('AUTH_MFA_ISSUER');
25
27
  // ──────────────────────────────────────────────────────────────
26
28
  // MFA — SMS Channel
27
29
  // ──────────────────────────────────────────────────────────────
@@ -110,8 +112,7 @@ exports.PLATFORM_AUTHENTICATION_CONFIG_ENTRIES = [
110
112
  // MFA — General
111
113
  {
112
114
  key: exports.AUTH_MFA_ENCRYPTION_KEY,
113
- required: false,
114
- defaultValue: '',
115
+ required: true,
115
116
  description: 'AES encryption key for MFA secrets.',
116
117
  },
117
118
  {
@@ -126,6 +127,11 @@ exports.PLATFORM_AUTHENTICATION_CONFIG_ENTRIES = [
126
127
  defaultValue: '5',
127
128
  description: 'Max failed MFA attempts before lockout.',
128
129
  },
130
+ {
131
+ key: exports.AUTH_MFA_ISSUER,
132
+ required: true,
133
+ description: 'Issuer name shown in authenticator apps for TOTP MFA.',
134
+ },
129
135
  // MFA — SMS
130
136
  { key: exports.AUTH_MFA_SMS_CODE_TTL, required: false, defaultValue: '10m', description: 'TTL for SMS OTP codes.' },
131
137
  {
@@ -1,4 +1,4 @@
1
- import { IMfaSetup } from '../../models';
1
+ import { IMfaSetup } from '../models';
2
2
  import { IMfaSetupContext } from './MfaState';
3
3
  /**
4
4
  * Defines the contract each MFA channel must implement.
@@ -3,9 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.MfaEncryptionService = void 0;
5
5
  const tslib_1 = require("tslib");
6
- const common_1 = require("@nestjs/common");
7
6
  const archipel_platform_core_1 = require("@breadstone/archipel-platform-core");
7
+ const common_1 = require("@nestjs/common");
8
8
  const node_crypto_1 = require("node:crypto");
9
+ const env_1 = require("../env");
9
10
  // #endregion
10
11
  /**
11
12
  * Provides AES-GCM encryption for MFA secrets.
@@ -16,9 +17,8 @@ let MfaEncryptionService = class MfaEncryptionService {
16
17
  // #endregion
17
18
  // #region Ctor
18
19
  constructor(configService) {
19
- const rawKey = configService.tryGet('AUTH_MFA_ENCRYPTION_KEY', '');
20
- const material = rawKey && rawKey.length > 0 ? rawKey : 'strivio-mfa-default-key';
21
- this._key = (0, node_crypto_1.createHash)('sha256').update(material).digest();
20
+ const rawKey = configService.get(env_1.AUTH_MFA_ENCRYPTION_KEY.key);
21
+ this._key = (0, node_crypto_1.createHash)('sha256').update(rawKey).digest();
22
22
  }
23
23
  // #endregion
24
24
  // #region Methods
@@ -1,9 +1,9 @@
1
1
  import { BcryptService } from '@breadstone/archipel-platform-cryptography';
2
2
  import { MfaSubjectPort } from '../contracts/MfaSubjectPort';
3
3
  import { IMfaConfirmation, IMfaSetup } from '../models';
4
- import { IMfaChannel } from './mfa/IMfaChannel';
5
- import { MfaEncryptionService } from './mfa/MfaEncryptionService';
6
- import { IMfaSetupContext } from './mfa/MfaState';
4
+ import { IMfaChannel } from './IMfaChannel';
5
+ import { MfaEncryptionService } from './MfaEncryptionService';
6
+ import { IMfaSetupContext } from './MfaState';
7
7
  /**
8
8
  * Orchestrates MFA channels, backup codes, and user preferences.
9
9
  *
@@ -7,9 +7,9 @@ const archipel_platform_cryptography_1 = require("@breadstone/archipel-platform-
7
7
  const common_1 = require("@nestjs/common");
8
8
  const node_crypto_1 = require("node:crypto");
9
9
  const MfaSubjectPort_1 = require("../contracts/MfaSubjectPort");
10
- const MfaEncryptionService_1 = require("./mfa/MfaEncryptionService");
11
- const MfaState_1 = require("./mfa/MfaState");
12
- const MfaTokens_1 = require("./mfa/MfaTokens");
10
+ const MfaEncryptionService_1 = require("./MfaEncryptionService");
11
+ const MfaState_1 = require("./MfaState");
12
+ const MfaTokens_1 = require("./MfaTokens");
13
13
  // #endregion
14
14
  /**
15
15
  * Orchestrates MFA channels, backup codes, and user preferences.
@@ -12,12 +12,12 @@ function resolveMfaState(raw) {
12
12
  return {
13
13
  preferredMethod: typed.preferredMethod,
14
14
  channels: typed.channels ?? {},
15
- trustedDevices: typed.trustedDevices ?? []
15
+ trustedDevices: typed.trustedDevices ?? [],
16
16
  };
17
17
  }
18
18
  return {
19
19
  channels: {},
20
- trustedDevices: []
20
+ trustedDevices: [],
21
21
  };
22
22
  }
23
23
  //# sourceMappingURL=MfaState.js.map
@@ -1,7 +1,7 @@
1
1
  import { ConfigService } from '@breadstone/archipel-platform-core';
2
2
  import { BcryptService } from '@breadstone/archipel-platform-cryptography';
3
- import { MfaSubjectPort } from '../../../contracts/MfaSubjectPort';
4
- import { IMfaSetup } from '../../../models';
3
+ import { MfaSubjectPort } from '../../contracts/MfaSubjectPort';
4
+ import { IMfaSetup } from '../../models';
5
5
  import { IMfaChannel } from '../IMfaChannel';
6
6
  import { IMfaSetupContext } from '../MfaState';
7
7
  export declare class EmailOtpMfaChannel implements IMfaChannel {
@@ -8,7 +8,8 @@ const archipel_platform_core_1 = require("@breadstone/archipel-platform-core");
8
8
  const archipel_platform_cryptography_1 = require("@breadstone/archipel-platform-cryptography");
9
9
  const common_1 = require("@nestjs/common");
10
10
  const node_crypto_1 = require("node:crypto");
11
- const MfaSubjectPort_1 = require("../../../contracts/MfaSubjectPort");
11
+ const MfaSubjectPort_1 = require("../../contracts/MfaSubjectPort");
12
+ const env_1 = require("../../env");
12
13
  const MfaState_1 = require("../MfaState");
13
14
  // #endregion
14
15
  let EmailOtpMfaChannel = EmailOtpMfaChannel_1 = class EmailOtpMfaChannel {
@@ -18,8 +19,8 @@ let EmailOtpMfaChannel = EmailOtpMfaChannel_1 = class EmailOtpMfaChannel {
18
19
  this._mfaSubject = mfaSubject;
19
20
  this._configService = configService;
20
21
  this._bcryptService = bcryptService;
21
- this._ttlMilliseconds = archipel_platform_core_1.DateTimeUtils.parse(this._configService.tryGet('AUTH_MFA_EMAIL_CODE_TTL', '10m'));
22
- this._minResendMilliseconds = archipel_platform_core_1.DateTimeUtils.parse(this._configService.tryGet('AUTH_MFA_EMAIL_MIN_RESEND', '30s'));
22
+ this._ttlMilliseconds = archipel_platform_core_1.DateTimeUtils.parse(this._configService.tryGet(env_1.AUTH_MFA_EMAIL_CODE_TTL.key, '10m'));
23
+ this._minResendMilliseconds = archipel_platform_core_1.DateTimeUtils.parse(this._configService.tryGet(env_1.AUTH_MFA_EMAIL_MIN_RESEND.key, '30s'));
23
24
  }
24
25
  async initSetup(userId, context) {
25
26
  const user = await this._mfaSubject.findById(userId);
@@ -1,7 +1,7 @@
1
1
  import { ConfigService } from '@breadstone/archipel-platform-core';
2
2
  import { BcryptService } from '@breadstone/archipel-platform-cryptography';
3
- import { MfaSubjectPort } from '../../../contracts/MfaSubjectPort';
4
- import { IMfaSetup } from '../../../models';
3
+ import { MfaSubjectPort } from '../../contracts/MfaSubjectPort';
4
+ import { IMfaSetup } from '../../models';
5
5
  import { IMfaChannel } from '../IMfaChannel';
6
6
  import { IMfaSetupContext } from '../MfaState';
7
7
  /**