@breadstone/archipel-platform-authentication 0.0.1

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 (128) hide show
  1. package/README.md +47 -0
  2. package/package.json +67 -0
  3. package/src/AuthModule.d.ts +57 -0
  4. package/src/AuthModule.js +158 -0
  5. package/src/contracts/AuthSubjectPort.d.ts +33 -0
  6. package/src/contracts/AuthSubjectPort.js +15 -0
  7. package/src/contracts/IAuthSubject.d.ts +40 -0
  8. package/src/contracts/IAuthSubject.js +3 -0
  9. package/src/contracts/IMfaSubject.d.ts +48 -0
  10. package/src/contracts/IMfaSubject.js +3 -0
  11. package/src/contracts/IMfaSubjectUpdate.d.ts +16 -0
  12. package/src/contracts/IMfaSubjectUpdate.js +3 -0
  13. package/src/contracts/ISessionRecord.d.ts +22 -0
  14. package/src/contracts/ISessionRecord.js +3 -0
  15. package/src/contracts/ISocialProfile.d.ts +23 -0
  16. package/src/contracts/ISocialProfile.js +3 -0
  17. package/src/contracts/IStoreSessionArgs.d.ts +14 -0
  18. package/src/contracts/IStoreSessionArgs.js +4 -0
  19. package/src/contracts/IVerifiableSubject.d.ts +28 -0
  20. package/src/contracts/IVerifiableSubject.js +3 -0
  21. package/src/contracts/MfaSubjectPort.d.ts +26 -0
  22. package/src/contracts/MfaSubjectPort.js +15 -0
  23. package/src/contracts/SessionPersistencePort.d.ts +58 -0
  24. package/src/contracts/SessionPersistencePort.js +15 -0
  25. package/src/contracts/SocialAuthPort.d.ts +19 -0
  26. package/src/contracts/SocialAuthPort.js +15 -0
  27. package/src/contracts/TokenEnricherPort.d.ts +17 -0
  28. package/src/contracts/TokenEnricherPort.js +15 -0
  29. package/src/contracts/VerificationSubjectPort.d.ts +40 -0
  30. package/src/contracts/VerificationSubjectPort.js +15 -0
  31. package/src/contracts/index.d.ts +13 -0
  32. package/src/contracts/index.js +16 -0
  33. package/src/decorators/RolesDecorator.d.ts +12 -0
  34. package/src/decorators/RolesDecorator.js +23 -0
  35. package/src/decorators/TokenDecorator.d.ts +6 -0
  36. package/src/decorators/TokenDecorator.js +20 -0
  37. package/src/decorators/UserDecorator.d.ts +6 -0
  38. package/src/decorators/UserDecorator.js +16 -0
  39. package/src/decorators/index.d.ts +3 -0
  40. package/src/decorators/index.js +7 -0
  41. package/src/env.d.ts +57 -0
  42. package/src/env.js +179 -0
  43. package/src/guards/AnonymousAuthGuard.d.ts +9 -0
  44. package/src/guards/AnonymousAuthGuard.js +20 -0
  45. package/src/guards/GithubAuthGuard.d.ts +9 -0
  46. package/src/guards/GithubAuthGuard.js +20 -0
  47. package/src/guards/JwtAuthGuard.d.ts +9 -0
  48. package/src/guards/JwtAuthGuard.js +20 -0
  49. package/src/guards/LocalAuthGuard.d.ts +9 -0
  50. package/src/guards/LocalAuthGuard.js +20 -0
  51. package/src/guards/RolesGuard.d.ts +16 -0
  52. package/src/guards/RolesGuard.js +43 -0
  53. package/src/guards/SocialAuthGuard.d.ts +9 -0
  54. package/src/guards/SocialAuthGuard.js +35 -0
  55. package/src/guards/_RefreshTokenAuthGuard.d.ts +0 -0
  56. package/src/guards/_RefreshTokenAuthGuard.js +2 -0
  57. package/src/guards/_TwoFactorAuthGuard.d.ts +0 -0
  58. package/src/guards/_TwoFactorAuthGuard.js +2 -0
  59. package/src/guards/index.d.ts +6 -0
  60. package/src/guards/index.js +12 -0
  61. package/src/index.d.ts +9 -0
  62. package/src/index.js +13 -0
  63. package/src/mappers/SessionMappingProfile.d.ts +42 -0
  64. package/src/mappers/SessionMappingProfile.js +68 -0
  65. package/src/middlewares/LastActiveMiddleware.d.ts +29 -0
  66. package/src/middlewares/LastActiveMiddleware.js +55 -0
  67. package/src/middlewares/index.d.ts +1 -0
  68. package/src/middlewares/index.js +5 -0
  69. package/src/models/IMfaChallengePayload.d.ts +31 -0
  70. package/src/models/IMfaChallengePayload.js +3 -0
  71. package/src/models/IMfaConfirmation.d.ts +11 -0
  72. package/src/models/IMfaConfirmation.js +3 -0
  73. package/src/models/IMfaSetup.d.ts +23 -0
  74. package/src/models/IMfaSetup.js +3 -0
  75. package/src/models/ISignInResult.d.ts +31 -0
  76. package/src/models/ISignInResult.js +3 -0
  77. package/src/models/JwtPayloadBase.d.ts +44 -0
  78. package/src/models/JwtPayloadBase.js +55 -0
  79. package/src/models/index.d.ts +6 -0
  80. package/src/models/index.js +10 -0
  81. package/src/models/responses/SessionResponse.d.ts +20 -0
  82. package/src/models/responses/SessionResponse.js +164 -0
  83. package/src/models/responses/index.d.ts +1 -0
  84. package/src/models/responses/index.js +5 -0
  85. package/src/serializer/SessionSerializer.d.ts +5 -0
  86. package/src/serializer/SessionSerializer.js +23 -0
  87. package/src/services/AuthTokenService.d.ts +30 -0
  88. package/src/services/AuthTokenService.js +58 -0
  89. package/src/services/ChallengeService.d.ts +41 -0
  90. package/src/services/ChallengeService.js +89 -0
  91. package/src/services/MfaService.d.ts +60 -0
  92. package/src/services/MfaService.js +251 -0
  93. package/src/services/SessionService.d.ts +66 -0
  94. package/src/services/SessionService.js +108 -0
  95. package/src/services/VerificationService.d.ts +56 -0
  96. package/src/services/VerificationService.js +124 -0
  97. package/src/services/index.d.ts +5 -0
  98. package/src/services/index.js +9 -0
  99. package/src/services/mfa/IMfaChannel.d.ts +40 -0
  100. package/src/services/mfa/IMfaChannel.js +4 -0
  101. package/src/services/mfa/MfaEncryptionService.d.ts +23 -0
  102. package/src/services/mfa/MfaEncryptionService.js +59 -0
  103. package/src/services/mfa/MfaState.d.ts +38 -0
  104. package/src/services/mfa/MfaState.js +23 -0
  105. package/src/services/mfa/MfaTokens.d.ts +4 -0
  106. package/src/services/mfa/MfaTokens.js +8 -0
  107. package/src/services/mfa/channels/EmailOtpMfaChannel.d.ts +21 -0
  108. package/src/services/mfa/channels/EmailOtpMfaChannel.js +152 -0
  109. package/src/services/mfa/channels/PushMfaChannel.d.ts +25 -0
  110. package/src/services/mfa/channels/PushMfaChannel.js +150 -0
  111. package/src/services/mfa/channels/SmsMfaChannel.d.ts +21 -0
  112. package/src/services/mfa/channels/SmsMfaChannel.js +158 -0
  113. package/src/services/mfa/channels/TotpMfaChannel.d.ts +19 -0
  114. package/src/services/mfa/channels/TotpMfaChannel.js +100 -0
  115. package/src/strategies/AnonymousStrategy.d.ts +32 -0
  116. package/src/strategies/AnonymousStrategy.js +53 -0
  117. package/src/strategies/AppleStrategy.d.ts +38 -0
  118. package/src/strategies/AppleStrategy.js +79 -0
  119. package/src/strategies/GithubStrategy.d.ts +24 -0
  120. package/src/strategies/GithubStrategy.js +65 -0
  121. package/src/strategies/GoogleStrategy.d.ts +34 -0
  122. package/src/strategies/GoogleStrategy.js +74 -0
  123. package/src/strategies/JwtStrategy.d.ts +31 -0
  124. package/src/strategies/JwtStrategy.js +55 -0
  125. package/src/strategies/LocalStrategy.d.ts +31 -0
  126. package/src/strategies/LocalStrategy.js +56 -0
  127. package/src/strategies/MicrosoftStrategy.d.ts +35 -0
  128. package/src/strategies/MicrosoftStrategy.js +75 -0
@@ -0,0 +1,58 @@
1
+ import type { ISessionRecord } from './ISessionRecord';
2
+ import type { IStoreSessionArgs } from './IStoreSessionArgs';
3
+ /**
4
+ * Abstract port for persisting and querying sessions.
5
+ * Used by the SessionService and LastActiveMiddleware.
6
+ *
7
+ * @public
8
+ */
9
+ export declare abstract class SessionPersistencePort {
10
+ /**
11
+ * Store or update a session.
12
+ *
13
+ * @public
14
+ * @param args - The session data to store.
15
+ */
16
+ abstract store(args: IStoreSessionArgs): Promise<void>;
17
+ /**
18
+ * Find a session by its token.
19
+ *
20
+ * @public
21
+ * @param token - The session token.
22
+ * @returns The session record or `null`.
23
+ */
24
+ abstract findByToken(token: string): Promise<ISessionRecord | null>;
25
+ /**
26
+ * Find all sessions for a given user.
27
+ *
28
+ * @public
29
+ * @param userId - The user identifier.
30
+ * @returns Sessions ordered by last activity descending.
31
+ */
32
+ abstract findAllByUserId(userId: string): Promise<ReadonlyArray<ISessionRecord>>;
33
+ /**
34
+ * Update the last-active timestamp for a session.
35
+ *
36
+ * @public
37
+ * @param token - The session token.
38
+ * @param date - The new last-active date.
39
+ */
40
+ abstract updateLastActive(token: string, date: Date): Promise<void>;
41
+ /**
42
+ * Invalidate (delete) a session by its token.
43
+ *
44
+ * @public
45
+ * @param token - The session token.
46
+ * @returns `true` if a session was invalidated.
47
+ */
48
+ abstract invalidate(token: string): Promise<boolean>;
49
+ /**
50
+ * Invalidate (delete) a session by its record id and owning user id.
51
+ *
52
+ * @public
53
+ * @param id - The session record identifier.
54
+ * @param userId - The owning user identifier.
55
+ * @returns `true` if a session was invalidated.
56
+ */
57
+ abstract invalidateById(id: string, userId: string): Promise<boolean>;
58
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ // #region Imports
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.SessionPersistencePort = void 0;
5
+ // #endregion
6
+ /**
7
+ * Abstract port for persisting and querying sessions.
8
+ * Used by the SessionService and LastActiveMiddleware.
9
+ *
10
+ * @public
11
+ */
12
+ class SessionPersistencePort {
13
+ }
14
+ exports.SessionPersistencePort = SessionPersistencePort;
15
+ //# sourceMappingURL=SessionPersistencePort.js.map
@@ -0,0 +1,19 @@
1
+ import type { IAuthSubject } from './IAuthSubject';
2
+ import type { ISocialProfile } from './ISocialProfile';
3
+ /**
4
+ * Abstract port for resolving or creating subjects from social / OAuth profiles.
5
+ * Used by all social strategies (GitHub, Google, Microsoft, Apple).
6
+ *
7
+ * @public
8
+ */
9
+ export declare abstract class SocialAuthPort {
10
+ /**
11
+ * Find an existing subject matching the social profile,
12
+ * or create a new one if none exists.
13
+ *
14
+ * @public
15
+ * @param profile - The normalized social profile.
16
+ * @returns The existing or newly created subject.
17
+ */
18
+ abstract findOrCreateByProfile(profile: ISocialProfile): Promise<IAuthSubject>;
19
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ // #region Imports
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.SocialAuthPort = void 0;
5
+ // #endregion
6
+ /**
7
+ * Abstract port for resolving or creating subjects from social / OAuth profiles.
8
+ * Used by all social strategies (GitHub, Google, Microsoft, Apple).
9
+ *
10
+ * @public
11
+ */
12
+ class SocialAuthPort {
13
+ }
14
+ exports.SocialAuthPort = SocialAuthPort;
15
+ //# sourceMappingURL=SocialAuthPort.js.map
@@ -0,0 +1,17 @@
1
+ import type { IAuthSubject } from './IAuthSubject';
2
+ /**
3
+ * Abstract port for enriching JWT claims with product-specific data.
4
+ * This is an optional port: when not provided, the token contains only base claims.
5
+ *
6
+ * @public
7
+ */
8
+ export declare abstract class TokenEnricherPort {
9
+ /**
10
+ * Return additional claims to merge into the JWT payload.
11
+ *
12
+ * @public
13
+ * @param subject - The authenticated subject.
14
+ * @returns A record of additional claims.
15
+ */
16
+ abstract enrichClaims(subject: IAuthSubject): Promise<Record<string, unknown>>;
17
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ // #region Imports
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.TokenEnricherPort = void 0;
5
+ // #endregion
6
+ /**
7
+ * Abstract port for enriching JWT claims with product-specific data.
8
+ * This is an optional port: when not provided, the token contains only base claims.
9
+ *
10
+ * @public
11
+ */
12
+ class TokenEnricherPort {
13
+ }
14
+ exports.TokenEnricherPort = TokenEnricherPort;
15
+ //# sourceMappingURL=TokenEnricherPort.js.map
@@ -0,0 +1,40 @@
1
+ import type { IVerifiableSubject } from './IVerifiableSubject';
2
+ /**
3
+ * Abstract port for verifiable subject persistence.
4
+ * Used by the VerificationService to manage email/PIN verification.
5
+ *
6
+ * @public
7
+ */
8
+ export declare abstract class VerificationSubjectPort {
9
+ /**
10
+ * Find a subject by login (user name or email).
11
+ *
12
+ * @public
13
+ * @param login - The login identifier.
14
+ * @returns The verifiable subject or `null`.
15
+ */
16
+ abstract findByLogin(login: string): Promise<IVerifiableSubject | null>;
17
+ /**
18
+ * Find a subject by its current verification token.
19
+ *
20
+ * @public
21
+ * @param token - The verification token string.
22
+ * @returns The subject or `null`.
23
+ */
24
+ abstract findByVerificationToken(token: string): Promise<IVerifiableSubject | null>;
25
+ /**
26
+ * Store a verification token on the subject.
27
+ *
28
+ * @public
29
+ * @param id - The subject identifier.
30
+ * @param token - The verification token to store.
31
+ */
32
+ abstract setVerificationToken(id: string, token: string | null): Promise<void>;
33
+ /**
34
+ * Mark the subject as verified and clear the token.
35
+ *
36
+ * @public
37
+ * @param id - The subject identifier.
38
+ */
39
+ abstract markVerified(id: string): Promise<void>;
40
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ // #region Imports
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.VerificationSubjectPort = void 0;
5
+ // #endregion
6
+ /**
7
+ * Abstract port for verifiable subject persistence.
8
+ * Used by the VerificationService to manage email/PIN verification.
9
+ *
10
+ * @public
11
+ */
12
+ class VerificationSubjectPort {
13
+ }
14
+ exports.VerificationSubjectPort = VerificationSubjectPort;
15
+ //# sourceMappingURL=VerificationSubjectPort.js.map
@@ -0,0 +1,13 @@
1
+ export { AuthSubjectPort } from './AuthSubjectPort';
2
+ export type { IAuthSubject } from './IAuthSubject';
3
+ export type { IMfaSubject } from './IMfaSubject';
4
+ export type { IMfaSubjectUpdate } from './IMfaSubjectUpdate';
5
+ export type { ISessionRecord } from './ISessionRecord';
6
+ export type { ISocialProfile } from './ISocialProfile';
7
+ export type { IStoreSessionArgs } from './IStoreSessionArgs';
8
+ export type { IVerifiableSubject } from './IVerifiableSubject';
9
+ export { MfaSubjectPort } from './MfaSubjectPort';
10
+ export { SessionPersistencePort } from './SessionPersistencePort';
11
+ export { SocialAuthPort } from './SocialAuthPort';
12
+ export { TokenEnricherPort } from './TokenEnricherPort';
13
+ export { VerificationSubjectPort } from './VerificationSubjectPort';
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VerificationSubjectPort = exports.TokenEnricherPort = exports.SocialAuthPort = exports.SessionPersistencePort = exports.MfaSubjectPort = exports.AuthSubjectPort = void 0;
4
+ var AuthSubjectPort_1 = require("./AuthSubjectPort");
5
+ Object.defineProperty(exports, "AuthSubjectPort", { enumerable: true, get: function () { return AuthSubjectPort_1.AuthSubjectPort; } });
6
+ var MfaSubjectPort_1 = require("./MfaSubjectPort");
7
+ Object.defineProperty(exports, "MfaSubjectPort", { enumerable: true, get: function () { return MfaSubjectPort_1.MfaSubjectPort; } });
8
+ var SessionPersistencePort_1 = require("./SessionPersistencePort");
9
+ Object.defineProperty(exports, "SessionPersistencePort", { enumerable: true, get: function () { return SessionPersistencePort_1.SessionPersistencePort; } });
10
+ var SocialAuthPort_1 = require("./SocialAuthPort");
11
+ Object.defineProperty(exports, "SocialAuthPort", { enumerable: true, get: function () { return SocialAuthPort_1.SocialAuthPort; } });
12
+ var TokenEnricherPort_1 = require("./TokenEnricherPort");
13
+ Object.defineProperty(exports, "TokenEnricherPort", { enumerable: true, get: function () { return TokenEnricherPort_1.TokenEnricherPort; } });
14
+ var VerificationSubjectPort_1 = require("./VerificationSubjectPort");
15
+ Object.defineProperty(exports, "VerificationSubjectPort", { enumerable: true, get: function () { return VerificationSubjectPort_1.VerificationSubjectPort; } });
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Represents the key for the `UseRoles` decorator.
3
+ *
4
+ * @public
5
+ */
6
+ export declare const ROLES_KEY = "use_roles";
7
+ /**
8
+ * Represents the `UseRoles` decorator.
9
+ *
10
+ * @public
11
+ */
12
+ export declare function UseRoles(...roles: Array<string>): Function;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ // #region Imports
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ROLES_KEY = void 0;
5
+ exports.UseRoles = UseRoles;
6
+ const common_1 = require("@nestjs/common");
7
+ // #endregion
8
+ /**
9
+ * Represents the key for the `UseRoles` decorator.
10
+ *
11
+ * @public
12
+ */
13
+ exports.ROLES_KEY = 'use_roles';
14
+ /**
15
+ * Represents the `UseRoles` decorator.
16
+ *
17
+ * @public
18
+ */
19
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
20
+ function UseRoles(...roles) {
21
+ return (0, common_1.SetMetadata)(exports.ROLES_KEY, roles);
22
+ }
23
+ //# sourceMappingURL=RolesDecorator.js.map
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Represents the `Token` decorator.
3
+ *
4
+ * @public
5
+ */
6
+ export declare function Token(): Function;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ // #region Imports
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Token = Token;
5
+ const common_1 = require("@nestjs/common");
6
+ // #endregion
7
+ /**
8
+ * Represents the `Token` decorator.
9
+ *
10
+ * @public
11
+ */
12
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
13
+ function Token() {
14
+ return (0, common_1.createParamDecorator)((_, context) => {
15
+ const request = context.switchToHttp().getRequest();
16
+ const auth = request.headers.authorization?.split(' ')[1];
17
+ return auth;
18
+ })();
19
+ }
20
+ //# sourceMappingURL=TokenDecorator.js.map
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Represents the `User` decorator.
3
+ *
4
+ * @public
5
+ */
6
+ export declare const User: (...dataOrPipes: unknown[]) => ParameterDecorator;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ // #region Imports
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.User = void 0;
5
+ const common_1 = require("@nestjs/common");
6
+ // #endregion
7
+ /**
8
+ * Represents the `User` decorator.
9
+ *
10
+ * @public
11
+ */
12
+ exports.User = (0, common_1.createParamDecorator)((_data, context) => {
13
+ const request = context.switchToHttp().getRequest();
14
+ return request.user;
15
+ });
16
+ //# sourceMappingURL=UserDecorator.js.map
@@ -0,0 +1,3 @@
1
+ export * from './RolesDecorator';
2
+ export * from './TokenDecorator';
3
+ export * from './UserDecorator';
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./RolesDecorator"), exports);
5
+ tslib_1.__exportStar(require("./TokenDecorator"), exports);
6
+ tslib_1.__exportStar(require("./UserDecorator"), exports);
7
+ //# sourceMappingURL=index.js.map
package/src/env.d.ts ADDED
@@ -0,0 +1,57 @@
1
+ import { IConfigRegistryEntry } from '@breadstone/archipel-platform-core';
2
+ /** Secret used to sign JWTs. */
3
+ export declare const AUTH_JWT_SECRET: import("@breadstone/archipel-platform-core").IConfigKey<string>;
4
+ /** Lifetime of access tokens (e.g. `'15m'`, `'1h'`). */
5
+ export declare const AUTH_JWT_EXPIRES_IN: import("@breadstone/archipel-platform-core").IConfigKey<string>;
6
+ /** Lifetime of email-verification JWTs. */
7
+ export declare const AUTH_VERIFY_JWT_EXPIRES_IN: import("@breadstone/archipel-platform-core").IConfigKey<string>;
8
+ /** AES encryption key used to encrypt MFA secrets at rest. */
9
+ export declare const AUTH_MFA_ENCRYPTION_KEY: import("@breadstone/archipel-platform-core").IConfigKey<string>;
10
+ /** How long an MFA challenge stays valid (e.g. `'5m'`). */
11
+ export declare const AUTH_MFA_CHALLENGE_EXPIRES_IN: import("@breadstone/archipel-platform-core").IConfigKey<string>;
12
+ /** Maximum number of failed MFA attempts before lockout. */
13
+ export declare const AUTH_MFA_MAX_ATTEMPTS: import("@breadstone/archipel-platform-core").IConfigKey<string>;
14
+ /** Time-to-live for SMS OTP codes (e.g. `'10m'`). */
15
+ export declare const AUTH_MFA_SMS_CODE_TTL: import("@breadstone/archipel-platform-core").IConfigKey<string>;
16
+ /** Minimum interval between SMS resend requests (e.g. `'30s'`). */
17
+ export declare const AUTH_MFA_SMS_MIN_RESEND: import("@breadstone/archipel-platform-core").IConfigKey<string>;
18
+ /** Time-to-live for email OTP codes (e.g. `'10m'`). */
19
+ export declare const AUTH_MFA_EMAIL_CODE_TTL: import("@breadstone/archipel-platform-core").IConfigKey<string>;
20
+ /** Minimum interval between email OTP resend requests (e.g. `'30s'`). */
21
+ export declare const AUTH_MFA_EMAIL_MIN_RESEND: import("@breadstone/archipel-platform-core").IConfigKey<string>;
22
+ /** Time-to-live for push OTP codes (e.g. `'10m'`). */
23
+ export declare const AUTH_MFA_PUSH_CODE_TTL: import("@breadstone/archipel-platform-core").IConfigKey<string>;
24
+ /** Minimum interval between push OTP resend requests (e.g. `'30s'`). */
25
+ export declare const AUTH_MFA_PUSH_MIN_RESEND: import("@breadstone/archipel-platform-core").IConfigKey<string>;
26
+ /** Google OAuth2 client ID. */
27
+ export declare const AUTH_GOOGLE_CLIENT_ID: import("@breadstone/archipel-platform-core").IConfigKey<string>;
28
+ /** Google OAuth2 client secret. */
29
+ export declare const AUTH_GOOGLE_CLIENT_SECRET: import("@breadstone/archipel-platform-core").IConfigKey<string>;
30
+ /** Google OAuth2 callback URL. */
31
+ export declare const AUTH_GOOGLE_CALLBACK_URL: import("@breadstone/archipel-platform-core").IConfigKey<string>;
32
+ /** Microsoft OAuth2 client ID. */
33
+ export declare const AUTH_MICROSOFT_CLIENT_ID: import("@breadstone/archipel-platform-core").IConfigKey<string>;
34
+ /** Microsoft OAuth2 client secret. */
35
+ export declare const AUTH_MICROSOFT_CLIENT_SECRET: import("@breadstone/archipel-platform-core").IConfigKey<string>;
36
+ /** Microsoft OAuth2 callback URL. */
37
+ export declare const AUTH_MICROSOFT_CALLBACK_URL: import("@breadstone/archipel-platform-core").IConfigKey<string>;
38
+ /** Microsoft tenant ID or `'common'` for multi-tenant. */
39
+ export declare const AUTH_MICROSOFT_TENANT: import("@breadstone/archipel-platform-core").IConfigKey<string>;
40
+ /** Apple Sign-In private key (PEM string). */
41
+ export declare const AUTH_APPLE_PRIVATE_KEY: import("@breadstone/archipel-platform-core").IConfigKey<string>;
42
+ /** Apple Sign-In client (service) ID. */
43
+ export declare const AUTH_APPLE_CLIENT_ID: import("@breadstone/archipel-platform-core").IConfigKey<string>;
44
+ /** Apple developer team ID. */
45
+ export declare const AUTH_APPLE_TEAM_ID: import("@breadstone/archipel-platform-core").IConfigKey<string>;
46
+ /** Apple Sign-In key ID. */
47
+ export declare const AUTH_APPLE_KEY_ID: import("@breadstone/archipel-platform-core").IConfigKey<string>;
48
+ /** Apple Sign-In callback URL. */
49
+ export declare const AUTH_APPLE_CALLBACK_URL: import("@breadstone/archipel-platform-core").IConfigKey<string>;
50
+ /** GitHub OAuth client ID. */
51
+ export declare const AUTH_GITHUB_CLIENT_ID: import("@breadstone/archipel-platform-core").IConfigKey<string>;
52
+ /** GitHub OAuth client secret. */
53
+ export declare const AUTH_GITHUB_CLIENT_SECRET: import("@breadstone/archipel-platform-core").IConfigKey<string>;
54
+ /** Username used for the anonymous seed user. */
55
+ export declare const SEED_ANONYMOUS_USERNAME: import("@breadstone/archipel-platform-core").IConfigKey<string>;
56
+ /** All configuration entries required by `platform-authentication`. */
57
+ export declare const PLATFORM_AUTHENTICATION_CONFIG_ENTRIES: ReadonlyArray<Omit<IConfigRegistryEntry, 'module'>>;
package/src/env.js ADDED
@@ -0,0 +1,179 @@
1
+ "use strict";
2
+ // #region Imports
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.PLATFORM_AUTHENTICATION_CONFIG_ENTRIES = exports.SEED_ANONYMOUS_USERNAME = exports.AUTH_GITHUB_CLIENT_SECRET = exports.AUTH_GITHUB_CLIENT_ID = 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_TENANT = exports.AUTH_MICROSOFT_CALLBACK_URL = exports.AUTH_MICROSOFT_CLIENT_SECRET = exports.AUTH_MICROSOFT_CLIENT_ID = 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;
5
+ const archipel_platform_core_1 = require("@breadstone/archipel-platform-core");
6
+ // #endregion
7
+ // ──────────────────────────────────────────────────────────────
8
+ // JWT & Session
9
+ // ──────────────────────────────────────────────────────────────
10
+ /** Secret used to sign JWTs. */
11
+ exports.AUTH_JWT_SECRET = (0, archipel_platform_core_1.createConfigKey)('AUTH_JWT_SECRET');
12
+ /** Lifetime of access tokens (e.g. `'15m'`, `'1h'`). */
13
+ exports.AUTH_JWT_EXPIRES_IN = (0, archipel_platform_core_1.createConfigKey)('AUTH_JWT_EXPIRES_IN');
14
+ /** Lifetime of email-verification JWTs. */
15
+ exports.AUTH_VERIFY_JWT_EXPIRES_IN = (0, archipel_platform_core_1.createConfigKey)('AUTH_VERIFY_JWT_EXPIRES_IN');
16
+ // ──────────────────────────────────────────────────────────────
17
+ // MFA — General
18
+ // ──────────────────────────────────────────────────────────────
19
+ /** AES encryption key used to encrypt MFA secrets at rest. */
20
+ exports.AUTH_MFA_ENCRYPTION_KEY = (0, archipel_platform_core_1.createConfigKey)('AUTH_MFA_ENCRYPTION_KEY');
21
+ /** How long an MFA challenge stays valid (e.g. `'5m'`). */
22
+ exports.AUTH_MFA_CHALLENGE_EXPIRES_IN = (0, archipel_platform_core_1.createConfigKey)('AUTH_MFA_CHALLENGE_EXPIRES_IN');
23
+ /** Maximum number of failed MFA attempts before lockout. */
24
+ exports.AUTH_MFA_MAX_ATTEMPTS = (0, archipel_platform_core_1.createConfigKey)('AUTH_MFA_MAX_ATTEMPTS');
25
+ // ──────────────────────────────────────────────────────────────
26
+ // MFA — SMS Channel
27
+ // ──────────────────────────────────────────────────────────────
28
+ /** Time-to-live for SMS OTP codes (e.g. `'10m'`). */
29
+ exports.AUTH_MFA_SMS_CODE_TTL = (0, archipel_platform_core_1.createConfigKey)('AUTH_MFA_SMS_CODE_TTL');
30
+ /** Minimum interval between SMS resend requests (e.g. `'30s'`). */
31
+ exports.AUTH_MFA_SMS_MIN_RESEND = (0, archipel_platform_core_1.createConfigKey)('AUTH_MFA_SMS_MIN_RESEND');
32
+ // ──────────────────────────────────────────────────────────────
33
+ // MFA — Email Channel
34
+ // ──────────────────────────────────────────────────────────────
35
+ /** Time-to-live for email OTP codes (e.g. `'10m'`). */
36
+ exports.AUTH_MFA_EMAIL_CODE_TTL = (0, archipel_platform_core_1.createConfigKey)('AUTH_MFA_EMAIL_CODE_TTL');
37
+ /** Minimum interval between email OTP resend requests (e.g. `'30s'`). */
38
+ exports.AUTH_MFA_EMAIL_MIN_RESEND = (0, archipel_platform_core_1.createConfigKey)('AUTH_MFA_EMAIL_MIN_RESEND');
39
+ // ──────────────────────────────────────────────────────────────
40
+ // MFA — Push Channel
41
+ // ──────────────────────────────────────────────────────────────
42
+ /** Time-to-live for push OTP codes (e.g. `'10m'`). */
43
+ exports.AUTH_MFA_PUSH_CODE_TTL = (0, archipel_platform_core_1.createConfigKey)('AUTH_MFA_PUSH_CODE_TTL');
44
+ /** Minimum interval between push OTP resend requests (e.g. `'30s'`). */
45
+ exports.AUTH_MFA_PUSH_MIN_RESEND = (0, archipel_platform_core_1.createConfigKey)('AUTH_MFA_PUSH_MIN_RESEND');
46
+ // ──────────────────────────────────────────────────────────────
47
+ // OAuth — Google
48
+ // ──────────────────────────────────────────────────────────────
49
+ /** Google OAuth2 client ID. */
50
+ exports.AUTH_GOOGLE_CLIENT_ID = (0, archipel_platform_core_1.createConfigKey)('AUTH_GOOGLE_CLIENT_ID');
51
+ /** Google OAuth2 client secret. */
52
+ exports.AUTH_GOOGLE_CLIENT_SECRET = (0, archipel_platform_core_1.createConfigKey)('AUTH_GOOGLE_CLIENT_SECRET');
53
+ /** Google OAuth2 callback URL. */
54
+ exports.AUTH_GOOGLE_CALLBACK_URL = (0, archipel_platform_core_1.createConfigKey)('AUTH_GOOGLE_CALLBACK_URL');
55
+ // ──────────────────────────────────────────────────────────────
56
+ // OAuth — Microsoft
57
+ // ──────────────────────────────────────────────────────────────
58
+ /** Microsoft OAuth2 client ID. */
59
+ exports.AUTH_MICROSOFT_CLIENT_ID = (0, archipel_platform_core_1.createConfigKey)('AUTH_MICROSOFT_CLIENT_ID');
60
+ /** Microsoft OAuth2 client secret. */
61
+ exports.AUTH_MICROSOFT_CLIENT_SECRET = (0, archipel_platform_core_1.createConfigKey)('AUTH_MICROSOFT_CLIENT_SECRET');
62
+ /** Microsoft OAuth2 callback URL. */
63
+ exports.AUTH_MICROSOFT_CALLBACK_URL = (0, archipel_platform_core_1.createConfigKey)('AUTH_MICROSOFT_CALLBACK_URL');
64
+ /** Microsoft tenant ID or `'common'` for multi-tenant. */
65
+ exports.AUTH_MICROSOFT_TENANT = (0, archipel_platform_core_1.createConfigKey)('AUTH_MICROSOFT_TENANT');
66
+ // ──────────────────────────────────────────────────────────────
67
+ // OAuth — Apple
68
+ // ──────────────────────────────────────────────────────────────
69
+ /** Apple Sign-In private key (PEM string). */
70
+ exports.AUTH_APPLE_PRIVATE_KEY = (0, archipel_platform_core_1.createConfigKey)('AUTH_APPLE_PRIVATE_KEY');
71
+ /** Apple Sign-In client (service) ID. */
72
+ exports.AUTH_APPLE_CLIENT_ID = (0, archipel_platform_core_1.createConfigKey)('AUTH_APPLE_CLIENT_ID');
73
+ /** Apple developer team ID. */
74
+ exports.AUTH_APPLE_TEAM_ID = (0, archipel_platform_core_1.createConfigKey)('AUTH_APPLE_TEAM_ID');
75
+ /** Apple Sign-In key ID. */
76
+ exports.AUTH_APPLE_KEY_ID = (0, archipel_platform_core_1.createConfigKey)('AUTH_APPLE_KEY_ID');
77
+ /** Apple Sign-In callback URL. */
78
+ exports.AUTH_APPLE_CALLBACK_URL = (0, archipel_platform_core_1.createConfigKey)('AUTH_APPLE_CALLBACK_URL');
79
+ // ──────────────────────────────────────────────────────────────
80
+ // OAuth — GitHub
81
+ // ──────────────────────────────────────────────────────────────
82
+ /** GitHub OAuth client ID. */
83
+ exports.AUTH_GITHUB_CLIENT_ID = (0, archipel_platform_core_1.createConfigKey)('AUTH_GITHUB_CLIENT_ID');
84
+ /** GitHub OAuth client secret. */
85
+ exports.AUTH_GITHUB_CLIENT_SECRET = (0, archipel_platform_core_1.createConfigKey)('AUTH_GITHUB_CLIENT_SECRET');
86
+ // ──────────────────────────────────────────────────────────────
87
+ // Seed / Misc
88
+ // ──────────────────────────────────────────────────────────────
89
+ /** Username used for the anonymous seed user. */
90
+ exports.SEED_ANONYMOUS_USERNAME = (0, archipel_platform_core_1.createConfigKey)('SEED_ANONYMOUS_USERNAME');
91
+ // ──────────────────────────────────────────────────────────────
92
+ // Registry entries
93
+ // ──────────────────────────────────────────────────────────────
94
+ /** All configuration entries required by `platform-authentication`. */
95
+ exports.PLATFORM_AUTHENTICATION_CONFIG_ENTRIES = [
96
+ // JWT & Session
97
+ { key: exports.AUTH_JWT_SECRET, required: true, description: 'Secret used to sign JWTs.' },
98
+ { key: exports.AUTH_JWT_EXPIRES_IN, required: true, description: 'Lifetime of access tokens.' },
99
+ { key: exports.AUTH_VERIFY_JWT_EXPIRES_IN, required: true, description: 'Lifetime of email-verification JWTs.' },
100
+ // MFA — General
101
+ {
102
+ key: exports.AUTH_MFA_ENCRYPTION_KEY,
103
+ required: false,
104
+ defaultValue: '',
105
+ description: 'AES encryption key for MFA secrets.',
106
+ },
107
+ {
108
+ key: exports.AUTH_MFA_CHALLENGE_EXPIRES_IN,
109
+ required: false,
110
+ defaultValue: '5m',
111
+ description: 'MFA challenge validity period.',
112
+ },
113
+ {
114
+ key: exports.AUTH_MFA_MAX_ATTEMPTS,
115
+ required: false,
116
+ defaultValue: '5',
117
+ description: 'Max failed MFA attempts before lockout.',
118
+ },
119
+ // MFA — SMS
120
+ { key: exports.AUTH_MFA_SMS_CODE_TTL, required: false, defaultValue: '10m', description: 'TTL for SMS OTP codes.' },
121
+ {
122
+ key: exports.AUTH_MFA_SMS_MIN_RESEND,
123
+ required: false,
124
+ defaultValue: '30s',
125
+ description: 'Min interval between SMS resends.',
126
+ },
127
+ // MFA — Email
128
+ { key: exports.AUTH_MFA_EMAIL_CODE_TTL, required: false, defaultValue: '10m', description: 'TTL for email OTP codes.' },
129
+ {
130
+ key: exports.AUTH_MFA_EMAIL_MIN_RESEND,
131
+ required: false,
132
+ defaultValue: '30s',
133
+ description: 'Min interval between email resends.',
134
+ },
135
+ // MFA — Push
136
+ { key: exports.AUTH_MFA_PUSH_CODE_TTL, required: false, defaultValue: '10m', description: 'TTL for push OTP codes.' },
137
+ {
138
+ key: exports.AUTH_MFA_PUSH_MIN_RESEND,
139
+ required: false,
140
+ defaultValue: '30s',
141
+ description: 'Min interval between push resends.',
142
+ },
143
+ // OAuth — Google
144
+ { key: exports.AUTH_GOOGLE_CLIENT_ID, required: true, description: 'Google OAuth2 client ID.' },
145
+ { key: exports.AUTH_GOOGLE_CLIENT_SECRET, required: true, description: 'Google OAuth2 client secret.' },
146
+ {
147
+ key: exports.AUTH_GOOGLE_CALLBACK_URL,
148
+ required: false,
149
+ defaultValue: '/auth/google/callback',
150
+ description: 'Google OAuth2 callback URL.',
151
+ },
152
+ // OAuth — Microsoft
153
+ { key: exports.AUTH_MICROSOFT_CLIENT_ID, required: true, description: 'Microsoft OAuth2 client ID.' },
154
+ { key: exports.AUTH_MICROSOFT_CLIENT_SECRET, required: true, description: 'Microsoft OAuth2 client secret.' },
155
+ {
156
+ key: exports.AUTH_MICROSOFT_CALLBACK_URL,
157
+ required: false,
158
+ defaultValue: '/auth/microsoft/callback',
159
+ description: 'Microsoft OAuth2 callback URL.',
160
+ },
161
+ { key: exports.AUTH_MICROSOFT_TENANT, required: false, defaultValue: 'common', description: 'Microsoft tenant ID.' },
162
+ // OAuth — Apple
163
+ { key: exports.AUTH_APPLE_PRIVATE_KEY, required: true, description: 'Apple Sign-In private key (PEM).' },
164
+ { key: exports.AUTH_APPLE_CLIENT_ID, required: true, description: 'Apple Sign-In client ID.' },
165
+ { key: exports.AUTH_APPLE_TEAM_ID, required: true, description: 'Apple developer team ID.' },
166
+ { key: exports.AUTH_APPLE_KEY_ID, required: true, description: 'Apple Sign-In key ID.' },
167
+ {
168
+ key: exports.AUTH_APPLE_CALLBACK_URL,
169
+ required: false,
170
+ defaultValue: '/auth/apple/callback',
171
+ description: 'Apple Sign-In callback URL.',
172
+ },
173
+ // OAuth — GitHub
174
+ { key: exports.AUTH_GITHUB_CLIENT_ID, required: true, description: 'GitHub OAuth client ID.' },
175
+ { key: exports.AUTH_GITHUB_CLIENT_SECRET, required: true, description: 'GitHub OAuth client secret.' },
176
+ // Seed / Misc
177
+ { key: exports.SEED_ANONYMOUS_USERNAME, required: true, description: 'Username for the anonymous seed user.' },
178
+ ];
179
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1,9 @@
1
+ declare const AnonymousAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
2
+ /**
3
+ * The `AnonymousAuthGuard` protects routes using anonymous authentication.
4
+ *
5
+ * @public
6
+ */
7
+ export declare class AnonymousAuthGuard extends AnonymousAuthGuard_base {
8
+ }
9
+ export {};
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ // #region Imports
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.AnonymousAuthGuard = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const common_1 = require("@nestjs/common");
7
+ const passport_1 = require("@nestjs/passport");
8
+ // #endregion
9
+ /**
10
+ * The `AnonymousAuthGuard` protects routes using anonymous authentication.
11
+ *
12
+ * @public
13
+ */
14
+ let AnonymousAuthGuard = class AnonymousAuthGuard extends (0, passport_1.AuthGuard)('anonymous') {
15
+ };
16
+ exports.AnonymousAuthGuard = AnonymousAuthGuard;
17
+ exports.AnonymousAuthGuard = AnonymousAuthGuard = tslib_1.__decorate([
18
+ (0, common_1.Injectable)()
19
+ ], AnonymousAuthGuard);
20
+ //# sourceMappingURL=AnonymousAuthGuard.js.map
@@ -0,0 +1,9 @@
1
+ declare const GithubAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
2
+ /**
3
+ * The `GithubAuthGuard` protects routes using GitHub authentication.
4
+ *
5
+ * @public
6
+ */
7
+ export declare class GithubAuthGuard extends GithubAuthGuard_base {
8
+ }
9
+ export {};
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ // #region Imports
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.GithubAuthGuard = void 0;
5
+ const tslib_1 = require("tslib");
6
+ const common_1 = require("@nestjs/common");
7
+ const passport_1 = require("@nestjs/passport");
8
+ // #endregion
9
+ /**
10
+ * The `GithubAuthGuard` protects routes using GitHub authentication.
11
+ *
12
+ * @public
13
+ */
14
+ let GithubAuthGuard = class GithubAuthGuard extends (0, passport_1.AuthGuard)('github') {
15
+ };
16
+ exports.GithubAuthGuard = GithubAuthGuard;
17
+ exports.GithubAuthGuard = GithubAuthGuard = tslib_1.__decorate([
18
+ (0, common_1.Injectable)()
19
+ ], GithubAuthGuard);
20
+ //# sourceMappingURL=GithubAuthGuard.js.map