@breadstone/archipel-platform-authentication 0.0.13 → 0.0.14
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.
- package/README.md +27 -0
- package/package.json +4 -3
- package/src/AuthModule.d.ts +17 -1
- package/src/AuthModule.js +32 -5
- package/src/connectors/AnonymousConnector.d.ts +1 -1
- package/src/connectors/AnonymousConnector.js +2 -2
- package/src/connectors/AppleConnector.d.ts +1 -1
- package/src/connectors/AppleConnector.js +2 -2
- package/src/connectors/GithubConnector.d.ts +1 -1
- package/src/connectors/GithubConnector.js +3 -2
- package/src/connectors/GoogleConnector.d.ts +1 -1
- package/src/connectors/GoogleConnector.js +2 -2
- package/src/connectors/JwtConnector.d.ts +1 -1
- package/src/connectors/JwtConnector.js +2 -2
- package/src/connectors/MicrosoftConnector.d.ts +1 -1
- package/src/connectors/MicrosoftConnector.js +2 -2
- package/src/connectors/apple/env.d.ts +1 -1
- package/src/connectors/github/env.d.ts +1 -1
- package/src/connectors/google/env.d.ts +1 -1
- package/src/connectors/microsoft/env.d.ts +1 -1
- package/src/contracts/ChallengeStorePort.d.ts +32 -0
- package/src/contracts/ChallengeStorePort.js +16 -0
- package/src/contracts/index.d.ts +1 -0
- package/src/contracts/index.js +3 -1
- package/src/env.d.ts +34 -34
- package/src/env.js +34 -34
- package/src/guards/index.js +0 -2
- package/src/mfa/MfaEncryptionService.d.ts +1 -1
- package/src/mfa/MfaEncryptionService.js +2 -2
- package/src/mfa/MfaService.js +0 -3
- package/src/mfa/channels/EmailOtpMfaChannel.d.ts +10 -1
- package/src/mfa/channels/EmailOtpMfaChannel.js +12 -2
- package/src/mfa/channels/PushMfaChannel.d.ts +8 -3
- package/src/mfa/channels/PushMfaChannel.js +10 -4
- package/src/mfa/channels/SmsMfaChannel.d.ts +10 -1
- package/src/mfa/channels/SmsMfaChannel.js +12 -2
- package/src/mfa/channels/TotpMfaChannel.d.ts +1 -1
- package/src/mfa/channels/TotpMfaChannel.js +2 -2
- package/src/services/ChallengeService.d.ts +7 -3
- package/src/services/ChallengeService.js +14 -9
- package/src/services/InMemoryChallengeStore.d.ts +16 -0
- package/src/services/InMemoryChallengeStore.js +40 -0
- package/src/services/SessionService.d.ts +8 -0
- package/src/services/SessionService.js +15 -0
- package/src/services/VerificationService.d.ts +10 -1
- package/src/services/VerificationService.js +31 -9
- package/src/strategies/AnonymousStrategy.d.ts +0 -32
- package/src/strategies/AnonymousStrategy.js +0 -54
package/README.md
CHANGED
|
@@ -27,8 +27,35 @@ For the full list (including MFA/OAuth callback defaults), see [`../../ENVIRONME
|
|
|
27
27
|
|
|
28
28
|
```typescript
|
|
29
29
|
import { AuthModule } from '@breadstone/archipel-platform-authentication';
|
|
30
|
+
|
|
31
|
+
@Module({
|
|
32
|
+
imports: [
|
|
33
|
+
AuthModule.register({
|
|
34
|
+
authSubject: PrismaAuthSubjectAdapter,
|
|
35
|
+
mfaSubject: PrismaMfaSubjectAdapter,
|
|
36
|
+
sessionPersistence: PrismaSessionAdapter,
|
|
37
|
+
verificationSubject: PrismaVerificationAdapter,
|
|
38
|
+
challengeStore: RedisChallengeStore, // optional — defaults to in-memory
|
|
39
|
+
socialAuth: PrismaSocialAuthAdapter, // optional — enables OAuth
|
|
40
|
+
tokenEnricher: AppTokenEnricherAdapter, // optional — enriches JWT claims
|
|
41
|
+
}),
|
|
42
|
+
],
|
|
43
|
+
})
|
|
44
|
+
export class AppModule {}
|
|
30
45
|
```
|
|
31
46
|
|
|
47
|
+
## Ports
|
|
48
|
+
|
|
49
|
+
| Port | Required | Description |
|
|
50
|
+
| ------------------------- | -------- | ------------------------------------------------- |
|
|
51
|
+
| `AuthSubjectPort` | Yes | User lookup for JWT, Local, and Anonymous |
|
|
52
|
+
| `MfaSubjectPort` | Yes | MFA state persistence |
|
|
53
|
+
| `SessionPersistencePort` | Yes | Session storage and invalidation |
|
|
54
|
+
| `VerificationSubjectPort` | Yes | Email/PIN verification lifecycle |
|
|
55
|
+
| `ChallengeStorePort` | No | MFA challenge state. Defaults to in-memory store. |
|
|
56
|
+
| `SocialAuthPort` | No | OAuth user creation/linking |
|
|
57
|
+
| `TokenEnricherPort` | No | Custom JWT claim injection |
|
|
58
|
+
|
|
32
59
|
## Documentation
|
|
33
60
|
|
|
34
61
|
📖 **Auth Module:** [`docs/backend/modules/auth.md`](../../../docs/backend/modules/auth.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@breadstone/archipel-platform-authentication",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "JWT and OAuth authentication, MFA, session management, and email verification for NestJS applications.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -81,8 +81,9 @@
|
|
|
81
81
|
"README.md"
|
|
82
82
|
],
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@breadstone/archipel-platform-
|
|
85
|
-
"@breadstone/archipel-platform-
|
|
84
|
+
"@breadstone/archipel-platform-configuration": "0.0.14",
|
|
85
|
+
"@breadstone/archipel-platform-core": "0.0.14",
|
|
86
|
+
"@breadstone/archipel-platform-cryptography": "0.0.14",
|
|
86
87
|
"passport": "0.7.0",
|
|
87
88
|
"passport-custom": "1.1.1",
|
|
88
89
|
"passport-jwt": "4.0.1",
|
package/src/AuthModule.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { type IConfigRegistryEntry } from '@breadstone/archipel-platform-
|
|
1
|
+
import { type IConfigRegistryEntry } from '@breadstone/archipel-platform-configuration';
|
|
2
2
|
import { DynamicModule, MiddlewareConsumer, Type, type Provider } from '@nestjs/common';
|
|
3
3
|
import { AuthSubjectPort } from './contracts/AuthSubjectPort';
|
|
4
|
+
import { ChallengeStorePort } from './contracts/ChallengeStorePort';
|
|
4
5
|
import { MfaSubjectPort } from './contracts/MfaSubjectPort';
|
|
5
6
|
import { SessionPersistencePort } from './contracts/SessionPersistencePort';
|
|
6
7
|
import { SocialAuthPort } from './contracts/SocialAuthPort';
|
|
@@ -65,11 +66,26 @@ export interface IAuthModuleOptions {
|
|
|
65
66
|
* (e.g. `TOTP_MFA_PROVIDERS` from `@breadstone/archipel-platform-authentication/mfa/totp`).
|
|
66
67
|
*/
|
|
67
68
|
additionalProviders?: Array<Provider>;
|
|
69
|
+
/**
|
|
70
|
+
* Optional implementation of the challenge store port.
|
|
71
|
+
* Defaults to an in-memory store suitable for single-instance deployments.
|
|
72
|
+
* For multi-instance deployments, provide a Redis-backed implementation.
|
|
73
|
+
*/
|
|
74
|
+
challengeStore?: Type<ChallengeStorePort>;
|
|
68
75
|
}
|
|
69
76
|
/**
|
|
70
77
|
* The `AuthModule` handles JWT-based authentication,
|
|
71
78
|
* including token creation and validation.
|
|
72
79
|
*
|
|
80
|
+
* **Rate Limiting:** This library does not expose controllers. Consumers should
|
|
81
|
+
* apply `@nestjs/throttler` guards on their auth endpoints (login, MFA verify)
|
|
82
|
+
* to prevent brute-force attacks (recommended: 5 req/min per IP + username).
|
|
83
|
+
*
|
|
84
|
+
* **OAuth CSRF Protection:** All social connectors use `state: true` which requires
|
|
85
|
+
* a session middleware (e.g. `express-session`) to store and verify OAuth state
|
|
86
|
+
* parameters. Ensure your application configures session middleware before using
|
|
87
|
+
* social connectors.
|
|
88
|
+
*
|
|
73
89
|
* @public
|
|
74
90
|
*/
|
|
75
91
|
export declare class AuthModule {
|
package/src/AuthModule.js
CHANGED
|
@@ -4,6 +4,7 @@ var AuthModule_1;
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.AuthModule = void 0;
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
|
+
const archipel_platform_configuration_1 = require("@breadstone/archipel-platform-configuration");
|
|
7
8
|
const archipel_platform_core_1 = require("@breadstone/archipel-platform-core");
|
|
8
9
|
const archipel_platform_cryptography_1 = require("@breadstone/archipel-platform-cryptography");
|
|
9
10
|
const common_1 = require("@nestjs/common");
|
|
@@ -13,6 +14,7 @@ const AnonymousConnector_1 = require("./connectors/AnonymousConnector");
|
|
|
13
14
|
const JwtConnector_1 = require("./connectors/JwtConnector");
|
|
14
15
|
const LocalConnector_1 = require("./connectors/LocalConnector");
|
|
15
16
|
const AuthSubjectPort_1 = require("./contracts/AuthSubjectPort");
|
|
17
|
+
const ChallengeStorePort_1 = require("./contracts/ChallengeStorePort");
|
|
16
18
|
const MfaSubjectPort_1 = require("./contracts/MfaSubjectPort");
|
|
17
19
|
const SessionPersistencePort_1 = require("./contracts/SessionPersistencePort");
|
|
18
20
|
const SocialAuthPort_1 = require("./contracts/SocialAuthPort");
|
|
@@ -35,12 +37,22 @@ const middlewares_1 = require("./middlewares");
|
|
|
35
37
|
const SessionSerializer_1 = require("./serializer/SessionSerializer");
|
|
36
38
|
const AuthTokenService_1 = require("./services/AuthTokenService");
|
|
37
39
|
const ChallengeService_1 = require("./services/ChallengeService");
|
|
40
|
+
const InMemoryChallengeStore_1 = require("./services/InMemoryChallengeStore");
|
|
38
41
|
const SessionService_1 = require("./services/SessionService");
|
|
39
42
|
const VerificationService_1 = require("./services/VerificationService");
|
|
40
43
|
/**
|
|
41
44
|
* The `AuthModule` handles JWT-based authentication,
|
|
42
45
|
* including token creation and validation.
|
|
43
46
|
*
|
|
47
|
+
* **Rate Limiting:** This library does not expose controllers. Consumers should
|
|
48
|
+
* apply `@nestjs/throttler` guards on their auth endpoints (login, MFA verify)
|
|
49
|
+
* to prevent brute-force attacks (recommended: 5 req/min per IP + username).
|
|
50
|
+
*
|
|
51
|
+
* **OAuth CSRF Protection:** All social connectors use `state: true` which requires
|
|
52
|
+
* a session middleware (e.g. `express-session`) to store and verify OAuth state
|
|
53
|
+
* parameters. Ensure your application configures session middleware before using
|
|
54
|
+
* social connectors.
|
|
55
|
+
*
|
|
44
56
|
* @public
|
|
45
57
|
*/
|
|
46
58
|
let AuthModule = AuthModule_1 = class AuthModule {
|
|
@@ -65,6 +77,10 @@ let AuthModule = AuthModule_1 = class AuthModule {
|
|
|
65
77
|
if (options.tokenEnricher) {
|
|
66
78
|
portProviders.push({ provide: TokenEnricherPort_1.TokenEnricherPort, useClass: options.tokenEnricher });
|
|
67
79
|
}
|
|
80
|
+
portProviders.push({
|
|
81
|
+
provide: ChallengeStorePort_1.ChallengeStorePort,
|
|
82
|
+
useClass: options.challengeStore ?? InMemoryChallengeStore_1.InMemoryChallengeStore,
|
|
83
|
+
});
|
|
68
84
|
const connectors = [JwtConnector_1.JwtConnector, LocalConnector_1.LocalConnector, AnonymousConnector_1.AnonymousConnector];
|
|
69
85
|
if (options.socialConnectors) {
|
|
70
86
|
connectors.push(...options.socialConnectors);
|
|
@@ -78,7 +94,7 @@ let AuthModule = AuthModule_1 = class AuthModule {
|
|
|
78
94
|
return {
|
|
79
95
|
module: AuthModule_1,
|
|
80
96
|
imports: [
|
|
81
|
-
|
|
97
|
+
archipel_platform_configuration_1.ConfigModule.register('platform-authentication', configEntries),
|
|
82
98
|
archipel_platform_core_1.EventModule,
|
|
83
99
|
archipel_platform_core_1.IdentifierModule,
|
|
84
100
|
archipel_platform_core_1.HostModule,
|
|
@@ -86,10 +102,21 @@ let AuthModule = AuthModule_1 = class AuthModule {
|
|
|
86
102
|
defaultStrategy: 'jwt',
|
|
87
103
|
session: true,
|
|
88
104
|
}),
|
|
89
|
-
jwt_1.JwtModule.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
105
|
+
jwt_1.JwtModule.registerAsync({
|
|
106
|
+
imports: [archipel_platform_configuration_1.ConfigModule.register('platform-authentication', configEntries)],
|
|
107
|
+
inject: [archipel_platform_configuration_1.ConfigService],
|
|
108
|
+
useFactory: (configService) => {
|
|
109
|
+
const secret = configService.get(env_1.AUTH_JWT_SECRET.key);
|
|
110
|
+
const MIN_SECRET_LENGTH = 32;
|
|
111
|
+
if (secret.length < MIN_SECRET_LENGTH) {
|
|
112
|
+
throw new Error(`AUTH_JWT_SECRET must be at least ${MIN_SECRET_LENGTH} characters (256 bits). Current length: ${secret.length}`);
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
secret,
|
|
116
|
+
signOptions: {
|
|
117
|
+
expiresIn: archipel_platform_core_1.DateTimeUtils.parse(configService.get(env_1.AUTH_JWT_EXPIRES_IN.key)),
|
|
118
|
+
},
|
|
119
|
+
};
|
|
93
120
|
},
|
|
94
121
|
}),
|
|
95
122
|
archipel_platform_core_1.MappingModule.withProfiles([SessionMappingProfile_1.SessionMappingProfile]),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigService } from '@breadstone/archipel-platform-
|
|
1
|
+
import { ConfigService } from '@breadstone/archipel-platform-configuration';
|
|
2
2
|
import { AuthSubjectPort } from '../contracts/AuthSubjectPort';
|
|
3
3
|
import type { IAuthSubject } from '../contracts/IAuthSubject';
|
|
4
4
|
declare const AnonymousConnector_base: (abstract new (...args: any[]) => {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.AnonymousConnector = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
|
-
const
|
|
6
|
+
const archipel_platform_configuration_1 = require("@breadstone/archipel-platform-configuration");
|
|
7
7
|
const common_1 = require("@nestjs/common");
|
|
8
8
|
const passport_custom_1 = require("passport-custom");
|
|
9
9
|
const AuthSubjectPort_1 = require("../contracts/AuthSubjectPort");
|
|
@@ -49,6 +49,6 @@ let AnonymousConnector = class AnonymousConnector extends (0, ConnectorBase_1.Co
|
|
|
49
49
|
exports.AnonymousConnector = AnonymousConnector;
|
|
50
50
|
exports.AnonymousConnector = AnonymousConnector = tslib_1.__decorate([
|
|
51
51
|
(0, common_1.Injectable)(),
|
|
52
|
-
tslib_1.__metadata("design:paramtypes", [AuthSubjectPort_1.AuthSubjectPort,
|
|
52
|
+
tslib_1.__metadata("design:paramtypes", [AuthSubjectPort_1.AuthSubjectPort, archipel_platform_configuration_1.ConfigService])
|
|
53
53
|
], AnonymousConnector);
|
|
54
54
|
//# sourceMappingURL=AnonymousConnector.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigService } from '@breadstone/archipel-platform-
|
|
1
|
+
import { ConfigService } from '@breadstone/archipel-platform-configuration';
|
|
2
2
|
import type { Profile as PassportProfile } from 'passport';
|
|
3
3
|
import type { IAuthSubject } from '../contracts/IAuthSubject';
|
|
4
4
|
import { SocialAuthPort } from '../contracts/SocialAuthPort';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.AppleConnector = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
|
-
const
|
|
6
|
+
const archipel_platform_configuration_1 = require("@breadstone/archipel-platform-configuration");
|
|
7
7
|
const common_1 = require("@nestjs/common");
|
|
8
8
|
const passport_apple_1 = require("passport-apple");
|
|
9
9
|
const SocialAuthPort_1 = require("../contracts/SocialAuthPort");
|
|
@@ -80,6 +80,6 @@ let AppleConnector = class AppleConnector extends (0, ConnectorBase_1.ConnectorB
|
|
|
80
80
|
exports.AppleConnector = AppleConnector;
|
|
81
81
|
exports.AppleConnector = AppleConnector = tslib_1.__decorate([
|
|
82
82
|
(0, common_1.Injectable)(),
|
|
83
|
-
tslib_1.__metadata("design:paramtypes", [SocialAuthPort_1.SocialAuthPort,
|
|
83
|
+
tslib_1.__metadata("design:paramtypes", [SocialAuthPort_1.SocialAuthPort, archipel_platform_configuration_1.ConfigService])
|
|
84
84
|
], AppleConnector);
|
|
85
85
|
//# sourceMappingURL=AppleConnector.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigService } from '@breadstone/archipel-platform-
|
|
1
|
+
import { ConfigService } from '@breadstone/archipel-platform-configuration';
|
|
2
2
|
import { type Profile } from 'passport-github2';
|
|
3
3
|
import type { IAuthSubject } from '../contracts/IAuthSubject';
|
|
4
4
|
import { SocialAuthPort } from '../contracts/SocialAuthPort';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.GithubConnector = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
|
-
const
|
|
6
|
+
const archipel_platform_configuration_1 = require("@breadstone/archipel-platform-configuration");
|
|
7
7
|
const common_1 = require("@nestjs/common");
|
|
8
8
|
const passport_github2_1 = require("passport-github2");
|
|
9
9
|
const SocialAuthPort_1 = require("../contracts/SocialAuthPort");
|
|
@@ -31,6 +31,7 @@ let GithubConnector = class GithubConnector extends (0, ConnectorBase_1.Connecto
|
|
|
31
31
|
clientSecret: configService.get(env_1.AUTH_GITHUB_CLIENT_SECRET.key),
|
|
32
32
|
callbackURL: configService.tryGet(env_1.AUTH_GITHUB_CALLBACK_URL.key, '/auth/github/callback'),
|
|
33
33
|
scope,
|
|
34
|
+
state: true,
|
|
34
35
|
});
|
|
35
36
|
this._socialAuth = socialAuth;
|
|
36
37
|
}
|
|
@@ -60,6 +61,6 @@ let GithubConnector = class GithubConnector extends (0, ConnectorBase_1.Connecto
|
|
|
60
61
|
exports.GithubConnector = GithubConnector;
|
|
61
62
|
exports.GithubConnector = GithubConnector = tslib_1.__decorate([
|
|
62
63
|
(0, common_1.Injectable)(),
|
|
63
|
-
tslib_1.__metadata("design:paramtypes", [SocialAuthPort_1.SocialAuthPort,
|
|
64
|
+
tslib_1.__metadata("design:paramtypes", [SocialAuthPort_1.SocialAuthPort, archipel_platform_configuration_1.ConfigService])
|
|
64
65
|
], GithubConnector);
|
|
65
66
|
//# sourceMappingURL=GithubConnector.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigService } from '@breadstone/archipel-platform-
|
|
1
|
+
import { ConfigService } from '@breadstone/archipel-platform-configuration';
|
|
2
2
|
import { Profile } from 'passport-google-oauth20';
|
|
3
3
|
import type { IAuthSubject } from '../contracts/IAuthSubject';
|
|
4
4
|
import { SocialAuthPort } from '../contracts/SocialAuthPort';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.GoogleConnector = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
|
-
const
|
|
6
|
+
const archipel_platform_configuration_1 = require("@breadstone/archipel-platform-configuration");
|
|
7
7
|
const common_1 = require("@nestjs/common");
|
|
8
8
|
const passport_google_oauth20_1 = require("passport-google-oauth20");
|
|
9
9
|
const SocialAuthPort_1 = require("../contracts/SocialAuthPort");
|
|
@@ -75,6 +75,6 @@ let GoogleConnector = class GoogleConnector extends (0, ConnectorBase_1.Connecto
|
|
|
75
75
|
exports.GoogleConnector = GoogleConnector;
|
|
76
76
|
exports.GoogleConnector = GoogleConnector = tslib_1.__decorate([
|
|
77
77
|
(0, common_1.Injectable)(),
|
|
78
|
-
tslib_1.__metadata("design:paramtypes", [SocialAuthPort_1.SocialAuthPort,
|
|
78
|
+
tslib_1.__metadata("design:paramtypes", [SocialAuthPort_1.SocialAuthPort, archipel_platform_configuration_1.ConfigService])
|
|
79
79
|
], GoogleConnector);
|
|
80
80
|
//# sourceMappingURL=GoogleConnector.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigService } from '@breadstone/archipel-platform-
|
|
1
|
+
import { ConfigService } from '@breadstone/archipel-platform-configuration';
|
|
2
2
|
import { AuthSubjectPort } from '../contracts/AuthSubjectPort';
|
|
3
3
|
import type { IAuthSubject } from '../contracts/IAuthSubject';
|
|
4
4
|
import { JwtPayloadBase } from '../models/JwtPayloadBase';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.JwtConnector = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
|
-
const
|
|
6
|
+
const archipel_platform_configuration_1 = require("@breadstone/archipel-platform-configuration");
|
|
7
7
|
const common_1 = require("@nestjs/common");
|
|
8
8
|
const passport_jwt_1 = require("passport-jwt");
|
|
9
9
|
const AuthSubjectPort_1 = require("../contracts/AuthSubjectPort");
|
|
@@ -51,6 +51,6 @@ let JwtConnector = class JwtConnector extends (0, ConnectorBase_1.ConnectorBase)
|
|
|
51
51
|
exports.JwtConnector = JwtConnector;
|
|
52
52
|
exports.JwtConnector = JwtConnector = tslib_1.__decorate([
|
|
53
53
|
(0, common_1.Injectable)(),
|
|
54
|
-
tslib_1.__metadata("design:paramtypes", [AuthSubjectPort_1.AuthSubjectPort,
|
|
54
|
+
tslib_1.__metadata("design:paramtypes", [AuthSubjectPort_1.AuthSubjectPort, archipel_platform_configuration_1.ConfigService])
|
|
55
55
|
], JwtConnector);
|
|
56
56
|
//# sourceMappingURL=JwtConnector.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigService } from '@breadstone/archipel-platform-
|
|
1
|
+
import { ConfigService } from '@breadstone/archipel-platform-configuration';
|
|
2
2
|
import type { Profile as PassportProfile } from 'passport';
|
|
3
3
|
import type { IAuthSubject } from '../contracts/IAuthSubject';
|
|
4
4
|
import { SocialAuthPort } from '../contracts/SocialAuthPort';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.MicrosoftConnector = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
|
-
const
|
|
6
|
+
const archipel_platform_configuration_1 = require("@breadstone/archipel-platform-configuration");
|
|
7
7
|
const common_1 = require("@nestjs/common");
|
|
8
8
|
const passport_microsoft_1 = require("passport-microsoft");
|
|
9
9
|
const SocialAuthPort_1 = require("../contracts/SocialAuthPort");
|
|
@@ -76,6 +76,6 @@ let MicrosoftConnector = class MicrosoftConnector extends (0, ConnectorBase_1.Co
|
|
|
76
76
|
exports.MicrosoftConnector = MicrosoftConnector;
|
|
77
77
|
exports.MicrosoftConnector = MicrosoftConnector = tslib_1.__decorate([
|
|
78
78
|
(0, common_1.Injectable)(),
|
|
79
|
-
tslib_1.__metadata("design:paramtypes", [SocialAuthPort_1.SocialAuthPort,
|
|
79
|
+
tslib_1.__metadata("design:paramtypes", [SocialAuthPort_1.SocialAuthPort, archipel_platform_configuration_1.ConfigService])
|
|
80
80
|
], MicrosoftConnector);
|
|
81
81
|
//# sourceMappingURL=MicrosoftConnector.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type IConfigRegistryEntry } from '@breadstone/archipel-platform-
|
|
1
|
+
import { type IConfigRegistryEntry } from '@breadstone/archipel-platform-configuration';
|
|
2
2
|
/** Configuration entries required by Apple Sign-In authentication. */
|
|
3
3
|
export declare const APPLE_AUTH_CONFIG_ENTRIES: ReadonlyArray<Omit<IConfigRegistryEntry, 'module'>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type IConfigRegistryEntry } from '@breadstone/archipel-platform-
|
|
1
|
+
import { type IConfigRegistryEntry } from '@breadstone/archipel-platform-configuration';
|
|
2
2
|
/** Configuration entries required by GitHub OAuth authentication. */
|
|
3
3
|
export declare const GITHUB_AUTH_CONFIG_ENTRIES: ReadonlyArray<Omit<IConfigRegistryEntry, 'module'>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type IConfigRegistryEntry } from '@breadstone/archipel-platform-
|
|
1
|
+
import { type IConfigRegistryEntry } from '@breadstone/archipel-platform-configuration';
|
|
2
2
|
/** Configuration entries required by Google OAuth authentication. */
|
|
3
3
|
export declare const GOOGLE_AUTH_CONFIG_ENTRIES: ReadonlyArray<Omit<IConfigRegistryEntry, 'module'>>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type IConfigRegistryEntry } from '@breadstone/archipel-platform-
|
|
1
|
+
import { type IConfigRegistryEntry } from '@breadstone/archipel-platform-configuration';
|
|
2
2
|
/** Configuration entries required by Microsoft OAuth authentication. */
|
|
3
3
|
export declare const MICROSOFT_AUTH_CONFIG_ENTRIES: ReadonlyArray<Omit<IConfigRegistryEntry, 'module'>>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { IMfaChallengeState } from '../services/ChallengeService';
|
|
2
|
+
/**
|
|
3
|
+
* Abstract port for persisting MFA challenge state.
|
|
4
|
+
*
|
|
5
|
+
* The default implementation stores challenges in-memory (single instance only).
|
|
6
|
+
* For multi-instance deployments, provide a Redis-backed implementation
|
|
7
|
+
* via `IAuthModuleOptions.challengeStore`.
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export declare abstract class ChallengeStorePort {
|
|
12
|
+
/**
|
|
13
|
+
* Store a challenge.
|
|
14
|
+
*
|
|
15
|
+
* @param id - The challenge identifier.
|
|
16
|
+
* @param challenge - The challenge state to persist.
|
|
17
|
+
*/
|
|
18
|
+
abstract set(id: string, challenge: IMfaChallengeState): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Retrieve a challenge by its identifier.
|
|
21
|
+
*
|
|
22
|
+
* @param id - The challenge identifier.
|
|
23
|
+
* @returns The challenge state, or `undefined` if not found.
|
|
24
|
+
*/
|
|
25
|
+
abstract get(id: string): Promise<IMfaChallengeState | undefined>;
|
|
26
|
+
/**
|
|
27
|
+
* Remove a challenge by its identifier.
|
|
28
|
+
*
|
|
29
|
+
* @param id - The challenge identifier.
|
|
30
|
+
*/
|
|
31
|
+
abstract delete(id: string): Promise<void>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChallengeStorePort = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Abstract port for persisting MFA challenge state.
|
|
6
|
+
*
|
|
7
|
+
* The default implementation stores challenges in-memory (single instance only).
|
|
8
|
+
* For multi-instance deployments, provide a Redis-backed implementation
|
|
9
|
+
* via `IAuthModuleOptions.challengeStore`.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
class ChallengeStorePort {
|
|
14
|
+
}
|
|
15
|
+
exports.ChallengeStorePort = ChallengeStorePort;
|
|
16
|
+
//# sourceMappingURL=ChallengeStorePort.js.map
|
package/src/contracts/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { AuthSubjectPort } from './AuthSubjectPort';
|
|
2
|
+
export { ChallengeStorePort } from './ChallengeStorePort';
|
|
2
3
|
export type { IAuthSubject } from './IAuthSubject';
|
|
3
4
|
export type { IMfaSubject } from './IMfaSubject';
|
|
4
5
|
export type { IMfaSubjectUpdate } from './IMfaSubjectUpdate';
|
package/src/contracts/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VerificationSubjectPort = exports.TokenEnricherPort = exports.SocialAuthPort = exports.SessionPersistencePort = exports.MfaSubjectPort = exports.AuthSubjectPort = void 0;
|
|
3
|
+
exports.VerificationSubjectPort = exports.TokenEnricherPort = exports.SocialAuthPort = exports.SessionPersistencePort = exports.MfaSubjectPort = exports.ChallengeStorePort = exports.AuthSubjectPort = void 0;
|
|
4
4
|
var AuthSubjectPort_1 = require("./AuthSubjectPort");
|
|
5
5
|
Object.defineProperty(exports, "AuthSubjectPort", { enumerable: true, get: function () { return AuthSubjectPort_1.AuthSubjectPort; } });
|
|
6
|
+
var ChallengeStorePort_1 = require("./ChallengeStorePort");
|
|
7
|
+
Object.defineProperty(exports, "ChallengeStorePort", { enumerable: true, get: function () { return ChallengeStorePort_1.ChallengeStorePort; } });
|
|
6
8
|
var MfaSubjectPort_1 = require("./MfaSubjectPort");
|
|
7
9
|
Object.defineProperty(exports, "MfaSubjectPort", { enumerable: true, get: function () { return MfaSubjectPort_1.MfaSubjectPort; } });
|
|
8
10
|
var SessionPersistencePort_1 = require("./SessionPersistencePort");
|
package/src/env.d.ts
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
import { IConfigRegistryEntry } from '@breadstone/archipel-platform-
|
|
1
|
+
import { IConfigRegistryEntry } from '@breadstone/archipel-platform-configuration';
|
|
2
2
|
/** Secret used to sign JWTs. */
|
|
3
|
-
export declare const AUTH_JWT_SECRET: import("@breadstone/archipel-platform-
|
|
3
|
+
export declare const AUTH_JWT_SECRET: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
4
4
|
/** Lifetime of access tokens (e.g. `'15m'`, `'1h'`). */
|
|
5
|
-
export declare const AUTH_JWT_EXPIRES_IN: import("@breadstone/archipel-platform-
|
|
5
|
+
export declare const AUTH_JWT_EXPIRES_IN: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
6
6
|
/** Lifetime of email-verification JWTs. */
|
|
7
|
-
export declare const AUTH_VERIFY_JWT_EXPIRES_IN: import("@breadstone/archipel-platform-
|
|
7
|
+
export declare const AUTH_VERIFY_JWT_EXPIRES_IN: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
8
8
|
/** AES encryption key used to encrypt MFA secrets at rest. */
|
|
9
|
-
export declare const AUTH_MFA_ENCRYPTION_KEY: import("@breadstone/archipel-platform-
|
|
9
|
+
export declare const AUTH_MFA_ENCRYPTION_KEY: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
10
10
|
/** How long an MFA challenge stays valid (e.g. `'5m'`). */
|
|
11
|
-
export declare const AUTH_MFA_CHALLENGE_EXPIRES_IN: import("@breadstone/archipel-platform-
|
|
11
|
+
export declare const AUTH_MFA_CHALLENGE_EXPIRES_IN: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
12
12
|
/** Maximum number of failed MFA attempts before lockout. */
|
|
13
|
-
export declare const AUTH_MFA_MAX_ATTEMPTS: import("@breadstone/archipel-platform-
|
|
13
|
+
export declare const AUTH_MFA_MAX_ATTEMPTS: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
14
14
|
/** Issuer name shown in authenticator apps for TOTP MFA. */
|
|
15
|
-
export declare const AUTH_MFA_ISSUER: import("@breadstone/archipel-platform-
|
|
15
|
+
export declare const AUTH_MFA_ISSUER: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
16
16
|
/** Time-to-live for SMS OTP codes (e.g. `'10m'`). */
|
|
17
|
-
export declare const AUTH_MFA_SMS_CODE_TTL: import("@breadstone/archipel-platform-
|
|
17
|
+
export declare const AUTH_MFA_SMS_CODE_TTL: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
18
18
|
/** Minimum interval between SMS resend requests (e.g. `'30s'`). */
|
|
19
|
-
export declare const AUTH_MFA_SMS_MIN_RESEND: import("@breadstone/archipel-platform-
|
|
19
|
+
export declare const AUTH_MFA_SMS_MIN_RESEND: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
20
20
|
/** Time-to-live for email OTP codes (e.g. `'10m'`). */
|
|
21
|
-
export declare const AUTH_MFA_EMAIL_CODE_TTL: import("@breadstone/archipel-platform-
|
|
21
|
+
export declare const AUTH_MFA_EMAIL_CODE_TTL: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
22
22
|
/** Minimum interval between email OTP resend requests (e.g. `'30s'`). */
|
|
23
|
-
export declare const AUTH_MFA_EMAIL_MIN_RESEND: import("@breadstone/archipel-platform-
|
|
23
|
+
export declare const AUTH_MFA_EMAIL_MIN_RESEND: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
24
24
|
/** Time-to-live for push OTP codes (e.g. `'10m'`). */
|
|
25
|
-
export declare const AUTH_MFA_PUSH_CODE_TTL: import("@breadstone/archipel-platform-
|
|
25
|
+
export declare const AUTH_MFA_PUSH_CODE_TTL: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
26
26
|
/** Minimum interval between push OTP resend requests (e.g. `'30s'`). */
|
|
27
|
-
export declare const AUTH_MFA_PUSH_MIN_RESEND: import("@breadstone/archipel-platform-
|
|
27
|
+
export declare const AUTH_MFA_PUSH_MIN_RESEND: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
28
28
|
/** Google OAuth2 client ID. */
|
|
29
|
-
export declare const AUTH_GOOGLE_CLIENT_ID: import("@breadstone/archipel-platform-
|
|
29
|
+
export declare const AUTH_GOOGLE_CLIENT_ID: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
30
30
|
/** Google OAuth2 client secret. */
|
|
31
|
-
export declare const AUTH_GOOGLE_CLIENT_SECRET: import("@breadstone/archipel-platform-
|
|
31
|
+
export declare const AUTH_GOOGLE_CLIENT_SECRET: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
32
32
|
/** Google OAuth2 callback URL. */
|
|
33
|
-
export declare const AUTH_GOOGLE_CALLBACK_URL: import("@breadstone/archipel-platform-
|
|
33
|
+
export declare const AUTH_GOOGLE_CALLBACK_URL: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
34
34
|
/** Comma-separated list of Google OAuth scopes (e.g. `'email,profile'`). */
|
|
35
|
-
export declare const AUTH_GOOGLE_SCOPE: import("@breadstone/archipel-platform-
|
|
35
|
+
export declare const AUTH_GOOGLE_SCOPE: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
36
36
|
/** Microsoft OAuth2 client ID. */
|
|
37
|
-
export declare const AUTH_MICROSOFT_CLIENT_ID: import("@breadstone/archipel-platform-
|
|
37
|
+
export declare const AUTH_MICROSOFT_CLIENT_ID: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
38
38
|
/** Microsoft OAuth2 client secret. */
|
|
39
|
-
export declare const AUTH_MICROSOFT_CLIENT_SECRET: import("@breadstone/archipel-platform-
|
|
39
|
+
export declare const AUTH_MICROSOFT_CLIENT_SECRET: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
40
40
|
/** Microsoft OAuth2 callback URL. */
|
|
41
|
-
export declare const AUTH_MICROSOFT_CALLBACK_URL: import("@breadstone/archipel-platform-
|
|
41
|
+
export declare const AUTH_MICROSOFT_CALLBACK_URL: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
42
42
|
/** Microsoft tenant ID or `'common'` for multi-tenant. */
|
|
43
|
-
export declare const AUTH_MICROSOFT_TENANT: import("@breadstone/archipel-platform-
|
|
43
|
+
export declare const AUTH_MICROSOFT_TENANT: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
44
44
|
/** Comma-separated list of Microsoft OAuth scopes (e.g. `'user.read,mail.read'`). */
|
|
45
|
-
export declare const AUTH_MICROSOFT_SCOPE: import("@breadstone/archipel-platform-
|
|
45
|
+
export declare const AUTH_MICROSOFT_SCOPE: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
46
46
|
/** Apple Sign-In private key (PEM string). */
|
|
47
|
-
export declare const AUTH_APPLE_PRIVATE_KEY: import("@breadstone/archipel-platform-
|
|
47
|
+
export declare const AUTH_APPLE_PRIVATE_KEY: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
48
48
|
/** Apple Sign-In client (service) ID. */
|
|
49
|
-
export declare const AUTH_APPLE_CLIENT_ID: import("@breadstone/archipel-platform-
|
|
49
|
+
export declare const AUTH_APPLE_CLIENT_ID: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
50
50
|
/** Apple developer team ID. */
|
|
51
|
-
export declare const AUTH_APPLE_TEAM_ID: import("@breadstone/archipel-platform-
|
|
51
|
+
export declare const AUTH_APPLE_TEAM_ID: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
52
52
|
/** Apple Sign-In key ID. */
|
|
53
|
-
export declare const AUTH_APPLE_KEY_ID: import("@breadstone/archipel-platform-
|
|
53
|
+
export declare const AUTH_APPLE_KEY_ID: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
54
54
|
/** Apple Sign-In callback URL. */
|
|
55
|
-
export declare const AUTH_APPLE_CALLBACK_URL: import("@breadstone/archipel-platform-
|
|
55
|
+
export declare const AUTH_APPLE_CALLBACK_URL: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
56
56
|
/** Comma-separated list of Apple Sign-In scopes (e.g. `'name,email'`). */
|
|
57
|
-
export declare const AUTH_APPLE_SCOPE: import("@breadstone/archipel-platform-
|
|
57
|
+
export declare const AUTH_APPLE_SCOPE: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
58
58
|
/** GitHub OAuth client ID. */
|
|
59
|
-
export declare const AUTH_GITHUB_CLIENT_ID: import("@breadstone/archipel-platform-
|
|
59
|
+
export declare const AUTH_GITHUB_CLIENT_ID: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
60
60
|
/** GitHub OAuth client secret. */
|
|
61
|
-
export declare const AUTH_GITHUB_CLIENT_SECRET: import("@breadstone/archipel-platform-
|
|
61
|
+
export declare const AUTH_GITHUB_CLIENT_SECRET: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
62
62
|
/** GitHub OAuth callback URL. */
|
|
63
|
-
export declare const AUTH_GITHUB_CALLBACK_URL: import("@breadstone/archipel-platform-
|
|
63
|
+
export declare const AUTH_GITHUB_CALLBACK_URL: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
64
64
|
/** Comma-separated list of GitHub OAuth scopes (e.g. `'user:email,read:user'`). */
|
|
65
|
-
export declare const AUTH_GITHUB_SCOPE: import("@breadstone/archipel-platform-
|
|
65
|
+
export declare const AUTH_GITHUB_SCOPE: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
66
66
|
/** Username used for the anonymous seed user. */
|
|
67
|
-
export declare const SEED_ANONYMOUS_USERNAME: import("@breadstone/archipel-platform-
|
|
67
|
+
export declare const SEED_ANONYMOUS_USERNAME: import("@breadstone/archipel-platform-configuration").IConfigKey<string>;
|
|
68
68
|
/** Core configuration entries required by `platform-authentication`. */
|
|
69
69
|
export declare const PLATFORM_AUTHENTICATION_CONFIG_ENTRIES: ReadonlyArray<Omit<IConfigRegistryEntry, 'module'>>;
|