@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.
- package/package.json +35 -27
- package/src/AuthModule.d.ts +22 -8
- package/src/AuthModule.js +19 -24
- package/src/connectors/AnonymousConnector.d.ts +42 -0
- package/src/connectors/AnonymousConnector.js +54 -0
- package/src/{strategies/AppleStrategy.d.ts → connectors/AppleConnector.d.ts} +16 -5
- package/src/{strategies/AppleStrategy.js → connectors/AppleConnector.js} +16 -15
- package/src/connectors/ConnectorBase.d.ts +39 -0
- package/src/connectors/ConnectorBase.js +33 -0
- package/src/connectors/GithubConnector.d.ts +34 -0
- package/src/{strategies/GithubStrategy.js → connectors/GithubConnector.js} +13 -12
- package/src/{strategies/GoogleStrategy.d.ts → connectors/GoogleConnector.d.ts} +17 -6
- package/src/{strategies/GoogleStrategy.js → connectors/GoogleConnector.js} +14 -13
- package/src/{strategies/JwtStrategy.d.ts → connectors/JwtConnector.d.ts} +16 -6
- package/src/{strategies/JwtStrategy.js → connectors/JwtConnector.js} +11 -10
- package/src/{strategies/LocalStrategy.d.ts → connectors/LocalConnector.d.ts} +16 -6
- package/src/{strategies/LocalStrategy.js → connectors/LocalConnector.js} +9 -9
- package/src/{strategies/MicrosoftStrategy.d.ts → connectors/MicrosoftConnector.d.ts} +16 -6
- package/src/{strategies/MicrosoftStrategy.js → connectors/MicrosoftConnector.js} +15 -14
- package/src/{apple → connectors/apple}/env.js +1 -1
- package/src/connectors/apple/index.d.ts +2 -0
- package/src/connectors/apple/index.js +8 -0
- package/src/{github → connectors/github}/env.js +1 -1
- package/src/connectors/github/index.d.ts +2 -0
- package/src/connectors/github/index.js +8 -0
- package/src/{google → connectors/google}/env.js +1 -1
- package/src/connectors/google/index.d.ts +2 -0
- package/src/connectors/google/index.js +8 -0
- package/src/{microsoft → connectors/microsoft}/env.js +1 -1
- package/src/connectors/microsoft/index.d.ts +2 -0
- package/src/connectors/microsoft/index.js +8 -0
- package/src/env.d.ts +2 -0
- package/src/env.js +9 -3
- package/src/{services/mfa → mfa}/IMfaChannel.d.ts +1 -1
- package/src/{services/mfa → mfa}/MfaEncryptionService.js +4 -4
- package/src/{services → mfa}/MfaService.d.ts +3 -3
- package/src/{services → mfa}/MfaService.js +3 -3
- package/src/{services/mfa → mfa}/MfaState.js +2 -2
- package/src/{services/mfa → mfa}/channels/EmailOtpMfaChannel.d.ts +2 -2
- package/src/{services/mfa → mfa}/channels/EmailOtpMfaChannel.js +4 -3
- package/src/{services/mfa → mfa}/channels/PushMfaChannel.d.ts +2 -2
- package/src/{services/mfa → mfa}/channels/PushMfaChannel.js +4 -3
- package/src/{services/mfa → mfa}/channels/SmsMfaChannel.d.ts +2 -2
- package/src/{services/mfa → mfa}/channels/SmsMfaChannel.js +4 -3
- package/src/{services/mfa → mfa}/channels/TotpMfaChannel.d.ts +3 -3
- package/src/{services/mfa → mfa}/channels/TotpMfaChannel.js +5 -4
- package/src/mfa/totp/index.d.ts +22 -0
- package/src/mfa/totp/index.js +29 -0
- package/src/services/ChallengeService.js +4 -3
- package/src/services/VerificationService.js +2 -1
- package/src/services/index.d.ts +1 -1
- package/src/services/index.js +1 -1
- package/src/strategies/AnonymousStrategy.js +2 -1
- package/src/apple/index.d.ts +0 -2
- package/src/apple/index.js +0 -8
- package/src/github/index.d.ts +0 -2
- package/src/github/index.js +0 -8
- package/src/google/index.d.ts +0 -2
- package/src/google/index.js +0 -8
- package/src/microsoft/index.d.ts +0 -2
- package/src/microsoft/index.js +0 -8
- package/src/strategies/GithubStrategy.d.ts +0 -23
- /package/src/{apple → connectors/apple}/env.d.ts +0 -0
- /package/src/{github → connectors/github}/env.d.ts +0 -0
- /package/src/{google → connectors/google}/env.d.ts +0 -0
- /package/src/{microsoft → connectors/microsoft}/env.d.ts +0 -0
- /package/src/{services/mfa → mfa}/IMfaChannel.js +0 -0
- /package/src/{services/mfa → mfa}/MfaEncryptionService.d.ts +0 -0
- /package/src/{services/mfa → mfa}/MfaState.d.ts +0 -0
- /package/src/{services/mfa → mfa}/MfaTokens.d.ts +0 -0
- /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.
|
|
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 `
|
|
14
|
+
* The `GoogleConnector` integrates Google OAuth authentication.
|
|
14
15
|
*
|
|
15
16
|
* @public
|
|
16
17
|
*/
|
|
17
|
-
let
|
|
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 `
|
|
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(
|
|
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(
|
|
35
|
-
clientSecret: configService.get(
|
|
36
|
-
callbackURL: configService.tryGet(
|
|
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.
|
|
75
|
-
exports.
|
|
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
|
-
],
|
|
79
|
-
//# sourceMappingURL=
|
|
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
|
|
7
|
-
|
|
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
|
|
20
|
+
* JWT connector for handling token validation.
|
|
11
21
|
*/
|
|
12
|
-
export declare class
|
|
22
|
+
export declare class JwtConnector extends JwtConnector_base {
|
|
13
23
|
private readonly _authSubject;
|
|
14
24
|
/**
|
|
15
|
-
* Constructs a new instance of the `
|
|
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.
|
|
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
|
|
14
|
+
* JWT connector for handling token validation.
|
|
14
15
|
*/
|
|
15
|
-
let
|
|
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 `
|
|
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(
|
|
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.
|
|
51
|
-
exports.
|
|
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
|
-
],
|
|
55
|
-
//# sourceMappingURL=
|
|
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
|
|
6
|
-
|
|
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
|
|
19
|
+
* Local connector for user name and password login.
|
|
10
20
|
*
|
|
11
21
|
* @public
|
|
12
22
|
*/
|
|
13
|
-
export declare class
|
|
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 `
|
|
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.
|
|
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
|
|
13
|
+
* Local connector for user name and password login.
|
|
14
14
|
*
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
|
-
let
|
|
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 `
|
|
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.
|
|
55
|
-
exports.
|
|
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
|
-
],
|
|
59
|
-
//# sourceMappingURL=
|
|
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
|
|
7
|
-
|
|
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 `
|
|
20
|
+
* The `MicrosoftConnector` integrates Microsoft OAuth authentication.
|
|
11
21
|
*
|
|
12
22
|
* @public
|
|
13
23
|
*/
|
|
14
|
-
export declare class
|
|
24
|
+
export declare class MicrosoftConnector extends MicrosoftConnector_base {
|
|
15
25
|
private readonly _socialAuth;
|
|
16
26
|
/**
|
|
17
|
-
* Initializes a new instance of the `
|
|
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.
|
|
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 `
|
|
14
|
+
* The `MicrosoftConnector` integrates Microsoft OAuth authentication.
|
|
14
15
|
*
|
|
15
16
|
* @public
|
|
16
17
|
*/
|
|
17
|
-
let
|
|
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 `
|
|
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(
|
|
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(
|
|
35
|
-
clientSecret: configService.get(
|
|
36
|
-
callbackURL: configService.tryGet(
|
|
37
|
-
tenant: configService.tryGet(
|
|
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.
|
|
76
|
-
exports.
|
|
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
|
-
],
|
|
80
|
-
//# sourceMappingURL=
|
|
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("
|
|
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,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("
|
|
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,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("
|
|
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,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("
|
|
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,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:
|
|
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
|
{
|
|
@@ -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.
|
|
20
|
-
|
|
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 './
|
|
5
|
-
import { MfaEncryptionService } from './
|
|
6
|
-
import { IMfaSetupContext } from './
|
|
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("./
|
|
11
|
-
const MfaState_1 = require("./
|
|
12
|
-
const MfaTokens_1 = require("./
|
|
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 '
|
|
4
|
-
import { IMfaSetup } from '
|
|
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("
|
|
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(
|
|
22
|
-
this._minResendMilliseconds = archipel_platform_core_1.DateTimeUtils.parse(this._configService.tryGet(
|
|
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 '
|
|
4
|
-
import { IMfaSetup } from '
|
|
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
|
/**
|