@breadstone/archipel-platform-authentication 0.0.5 → 0.0.7
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 +18 -2
- package/src/apple/env.js +6 -0
- package/src/env.d.ts +8 -0
- package/src/env.js +9 -1
- package/src/github/env.js +6 -0
- package/src/google/env.js +6 -0
- package/src/microsoft/env.js +6 -0
- package/src/strategies/AppleStrategy.js +6 -1
- package/src/strategies/GithubStrategy.js +6 -0
- package/src/strategies/GoogleStrategy.js +6 -1
- package/src/strategies/MicrosoftStrategy.js +6 -1
package/package.json
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@breadstone/archipel-platform-authentication",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
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",
|
|
7
7
|
"types": "./src/index.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
"*": {
|
|
10
|
+
"apple": [
|
|
11
|
+
"./src/apple/index.d.ts"
|
|
12
|
+
],
|
|
13
|
+
"github": [
|
|
14
|
+
"./src/github/index.d.ts"
|
|
15
|
+
],
|
|
16
|
+
"google": [
|
|
17
|
+
"./src/google/index.d.ts"
|
|
18
|
+
],
|
|
19
|
+
"microsoft": [
|
|
20
|
+
"./src/microsoft/index.d.ts"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
8
24
|
"exports": {
|
|
9
25
|
".": {
|
|
10
26
|
"types": "./src/index.d.ts",
|
|
@@ -57,7 +73,7 @@
|
|
|
57
73
|
"README.md"
|
|
58
74
|
],
|
|
59
75
|
"dependencies": {
|
|
60
|
-
"@breadstone/archipel-platform-core": "0.0.
|
|
76
|
+
"@breadstone/archipel-platform-core": "0.0.7",
|
|
61
77
|
"passport": "0.7.0",
|
|
62
78
|
"passport-custom": "1.1.1",
|
|
63
79
|
"passport-jwt": "4.0.1",
|
package/src/apple/env.js
CHANGED
|
@@ -16,5 +16,11 @@ exports.APPLE_AUTH_CONFIG_ENTRIES = [
|
|
|
16
16
|
defaultValue: '/auth/apple/callback',
|
|
17
17
|
description: 'Apple Sign-In callback URL.',
|
|
18
18
|
},
|
|
19
|
+
{
|
|
20
|
+
key: env_1.AUTH_APPLE_SCOPE,
|
|
21
|
+
required: false,
|
|
22
|
+
defaultValue: 'name,email',
|
|
23
|
+
description: 'Comma-separated list of Apple Sign-In scopes.',
|
|
24
|
+
},
|
|
19
25
|
];
|
|
20
26
|
//# sourceMappingURL=env.js.map
|
package/src/env.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export declare const AUTH_GOOGLE_CLIENT_ID: import("@breadstone/archipel-platfor
|
|
|
29
29
|
export declare const AUTH_GOOGLE_CLIENT_SECRET: import("@breadstone/archipel-platform-core").IConfigKey<string>;
|
|
30
30
|
/** Google OAuth2 callback URL. */
|
|
31
31
|
export declare const AUTH_GOOGLE_CALLBACK_URL: import("@breadstone/archipel-platform-core").IConfigKey<string>;
|
|
32
|
+
/** Comma-separated list of Google OAuth scopes (e.g. `'email,profile'`). */
|
|
33
|
+
export declare const AUTH_GOOGLE_SCOPE: import("@breadstone/archipel-platform-core").IConfigKey<string>;
|
|
32
34
|
/** Microsoft OAuth2 client ID. */
|
|
33
35
|
export declare const AUTH_MICROSOFT_CLIENT_ID: import("@breadstone/archipel-platform-core").IConfigKey<string>;
|
|
34
36
|
/** Microsoft OAuth2 client secret. */
|
|
@@ -37,6 +39,8 @@ export declare const AUTH_MICROSOFT_CLIENT_SECRET: import("@breadstone/archipel-
|
|
|
37
39
|
export declare const AUTH_MICROSOFT_CALLBACK_URL: import("@breadstone/archipel-platform-core").IConfigKey<string>;
|
|
38
40
|
/** Microsoft tenant ID or `'common'` for multi-tenant. */
|
|
39
41
|
export declare const AUTH_MICROSOFT_TENANT: import("@breadstone/archipel-platform-core").IConfigKey<string>;
|
|
42
|
+
/** Comma-separated list of Microsoft OAuth scopes (e.g. `'user.read,mail.read'`). */
|
|
43
|
+
export declare const AUTH_MICROSOFT_SCOPE: import("@breadstone/archipel-platform-core").IConfigKey<string>;
|
|
40
44
|
/** Apple Sign-In private key (PEM string). */
|
|
41
45
|
export declare const AUTH_APPLE_PRIVATE_KEY: import("@breadstone/archipel-platform-core").IConfigKey<string>;
|
|
42
46
|
/** Apple Sign-In client (service) ID. */
|
|
@@ -47,12 +51,16 @@ export declare const AUTH_APPLE_TEAM_ID: import("@breadstone/archipel-platform-c
|
|
|
47
51
|
export declare const AUTH_APPLE_KEY_ID: import("@breadstone/archipel-platform-core").IConfigKey<string>;
|
|
48
52
|
/** Apple Sign-In callback URL. */
|
|
49
53
|
export declare const AUTH_APPLE_CALLBACK_URL: import("@breadstone/archipel-platform-core").IConfigKey<string>;
|
|
54
|
+
/** Comma-separated list of Apple Sign-In scopes (e.g. `'name,email'`). */
|
|
55
|
+
export declare const AUTH_APPLE_SCOPE: import("@breadstone/archipel-platform-core").IConfigKey<string>;
|
|
50
56
|
/** GitHub OAuth client ID. */
|
|
51
57
|
export declare const AUTH_GITHUB_CLIENT_ID: import("@breadstone/archipel-platform-core").IConfigKey<string>;
|
|
52
58
|
/** GitHub OAuth client secret. */
|
|
53
59
|
export declare const AUTH_GITHUB_CLIENT_SECRET: import("@breadstone/archipel-platform-core").IConfigKey<string>;
|
|
54
60
|
/** GitHub OAuth callback URL. */
|
|
55
61
|
export declare const AUTH_GITHUB_CALLBACK_URL: import("@breadstone/archipel-platform-core").IConfigKey<string>;
|
|
62
|
+
/** Comma-separated list of GitHub OAuth scopes (e.g. `'user:email,read:user'`). */
|
|
63
|
+
export declare const AUTH_GITHUB_SCOPE: import("@breadstone/archipel-platform-core").IConfigKey<string>;
|
|
56
64
|
/** Username used for the anonymous seed user. */
|
|
57
65
|
export declare const SEED_ANONYMOUS_USERNAME: import("@breadstone/archipel-platform-core").IConfigKey<string>;
|
|
58
66
|
/** Core configuration entries required by `platform-authentication`. */
|
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_CALLBACK_URL = 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;
|
|
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;
|
|
5
5
|
const archipel_platform_core_1 = require("@breadstone/archipel-platform-core");
|
|
6
6
|
// #endregion
|
|
7
7
|
// ──────────────────────────────────────────────────────────────
|
|
@@ -52,6 +52,8 @@ exports.AUTH_GOOGLE_CLIENT_ID = (0, archipel_platform_core_1.createConfigKey)('A
|
|
|
52
52
|
exports.AUTH_GOOGLE_CLIENT_SECRET = (0, archipel_platform_core_1.createConfigKey)('AUTH_GOOGLE_CLIENT_SECRET');
|
|
53
53
|
/** Google OAuth2 callback URL. */
|
|
54
54
|
exports.AUTH_GOOGLE_CALLBACK_URL = (0, archipel_platform_core_1.createConfigKey)('AUTH_GOOGLE_CALLBACK_URL');
|
|
55
|
+
/** Comma-separated list of Google OAuth scopes (e.g. `'email,profile'`). */
|
|
56
|
+
exports.AUTH_GOOGLE_SCOPE = (0, archipel_platform_core_1.createConfigKey)('AUTH_GOOGLE_SCOPE');
|
|
55
57
|
// ──────────────────────────────────────────────────────────────
|
|
56
58
|
// OAuth — Microsoft
|
|
57
59
|
// ──────────────────────────────────────────────────────────────
|
|
@@ -63,6 +65,8 @@ exports.AUTH_MICROSOFT_CLIENT_SECRET = (0, archipel_platform_core_1.createConfig
|
|
|
63
65
|
exports.AUTH_MICROSOFT_CALLBACK_URL = (0, archipel_platform_core_1.createConfigKey)('AUTH_MICROSOFT_CALLBACK_URL');
|
|
64
66
|
/** Microsoft tenant ID or `'common'` for multi-tenant. */
|
|
65
67
|
exports.AUTH_MICROSOFT_TENANT = (0, archipel_platform_core_1.createConfigKey)('AUTH_MICROSOFT_TENANT');
|
|
68
|
+
/** Comma-separated list of Microsoft OAuth scopes (e.g. `'user.read,mail.read'`). */
|
|
69
|
+
exports.AUTH_MICROSOFT_SCOPE = (0, archipel_platform_core_1.createConfigKey)('AUTH_MICROSOFT_SCOPE');
|
|
66
70
|
// ──────────────────────────────────────────────────────────────
|
|
67
71
|
// OAuth — Apple
|
|
68
72
|
// ──────────────────────────────────────────────────────────────
|
|
@@ -76,6 +80,8 @@ exports.AUTH_APPLE_TEAM_ID = (0, archipel_platform_core_1.createConfigKey)('AUTH
|
|
|
76
80
|
exports.AUTH_APPLE_KEY_ID = (0, archipel_platform_core_1.createConfigKey)('AUTH_APPLE_KEY_ID');
|
|
77
81
|
/** Apple Sign-In callback URL. */
|
|
78
82
|
exports.AUTH_APPLE_CALLBACK_URL = (0, archipel_platform_core_1.createConfigKey)('AUTH_APPLE_CALLBACK_URL');
|
|
83
|
+
/** Comma-separated list of Apple Sign-In scopes (e.g. `'name,email'`). */
|
|
84
|
+
exports.AUTH_APPLE_SCOPE = (0, archipel_platform_core_1.createConfigKey)('AUTH_APPLE_SCOPE');
|
|
79
85
|
// ──────────────────────────────────────────────────────────────
|
|
80
86
|
// OAuth — GitHub
|
|
81
87
|
// ──────────────────────────────────────────────────────────────
|
|
@@ -85,6 +91,8 @@ exports.AUTH_GITHUB_CLIENT_ID = (0, archipel_platform_core_1.createConfigKey)('A
|
|
|
85
91
|
exports.AUTH_GITHUB_CLIENT_SECRET = (0, archipel_platform_core_1.createConfigKey)('AUTH_GITHUB_CLIENT_SECRET');
|
|
86
92
|
/** GitHub OAuth callback URL. */
|
|
87
93
|
exports.AUTH_GITHUB_CALLBACK_URL = (0, archipel_platform_core_1.createConfigKey)('AUTH_GITHUB_CALLBACK_URL');
|
|
94
|
+
/** Comma-separated list of GitHub OAuth scopes (e.g. `'user:email,read:user'`). */
|
|
95
|
+
exports.AUTH_GITHUB_SCOPE = (0, archipel_platform_core_1.createConfigKey)('AUTH_GITHUB_SCOPE');
|
|
88
96
|
// ──────────────────────────────────────────────────────────────
|
|
89
97
|
// Seed / Misc
|
|
90
98
|
// ──────────────────────────────────────────────────────────────
|
package/src/github/env.js
CHANGED
|
@@ -14,5 +14,11 @@ exports.GITHUB_AUTH_CONFIG_ENTRIES = [
|
|
|
14
14
|
defaultValue: '/auth/github/callback',
|
|
15
15
|
description: 'GitHub OAuth callback URL.',
|
|
16
16
|
},
|
|
17
|
+
{
|
|
18
|
+
key: env_1.AUTH_GITHUB_SCOPE,
|
|
19
|
+
required: false,
|
|
20
|
+
defaultValue: 'user:email',
|
|
21
|
+
description: 'Comma-separated list of GitHub OAuth scopes.',
|
|
22
|
+
},
|
|
17
23
|
];
|
|
18
24
|
//# sourceMappingURL=env.js.map
|
package/src/google/env.js
CHANGED
|
@@ -14,5 +14,11 @@ exports.GOOGLE_AUTH_CONFIG_ENTRIES = [
|
|
|
14
14
|
defaultValue: '/auth/google/callback',
|
|
15
15
|
description: 'Google OAuth2 callback URL.',
|
|
16
16
|
},
|
|
17
|
+
{
|
|
18
|
+
key: env_1.AUTH_GOOGLE_SCOPE,
|
|
19
|
+
required: false,
|
|
20
|
+
defaultValue: 'email,profile',
|
|
21
|
+
description: 'Comma-separated list of Google OAuth scopes.',
|
|
22
|
+
},
|
|
17
23
|
];
|
|
18
24
|
//# sourceMappingURL=env.js.map
|
package/src/microsoft/env.js
CHANGED
|
@@ -15,5 +15,11 @@ exports.MICROSOFT_AUTH_CONFIG_ENTRIES = [
|
|
|
15
15
|
description: 'Microsoft OAuth2 callback URL.',
|
|
16
16
|
},
|
|
17
17
|
{ key: env_1.AUTH_MICROSOFT_TENANT, required: false, defaultValue: 'common', description: 'Microsoft tenant ID.' },
|
|
18
|
+
{
|
|
19
|
+
key: env_1.AUTH_MICROSOFT_SCOPE,
|
|
20
|
+
required: false,
|
|
21
|
+
defaultValue: 'user.read',
|
|
22
|
+
description: 'Comma-separated list of Microsoft OAuth scopes.',
|
|
23
|
+
},
|
|
18
24
|
];
|
|
19
25
|
//# sourceMappingURL=env.js.map
|
|
@@ -26,13 +26,18 @@ let AppleStrategy = class AppleStrategy extends (0, passport_1.PassportStrategy)
|
|
|
26
26
|
constructor(socialAuth, configService) {
|
|
27
27
|
const rawPrivateKey = configService.get('AUTH_APPLE_PRIVATE_KEY');
|
|
28
28
|
const normalizedPrivateKey = rawPrivateKey.replace(/\r/g, '').replace(/\\n/g, '\n');
|
|
29
|
+
const scope = configService
|
|
30
|
+
.tryGet('AUTH_APPLE_SCOPE', 'name,email')
|
|
31
|
+
.split(',')
|
|
32
|
+
.map((s) => s.trim())
|
|
33
|
+
.filter(Boolean);
|
|
29
34
|
super({
|
|
30
35
|
clientID: configService.get('AUTH_APPLE_CLIENT_ID'),
|
|
31
36
|
teamID: configService.get('AUTH_APPLE_TEAM_ID'),
|
|
32
37
|
keyID: configService.get('AUTH_APPLE_KEY_ID'),
|
|
33
38
|
callbackURL: configService.tryGet('AUTH_APPLE_CALLBACK_URL', '/auth/apple/callback'),
|
|
34
39
|
privateKeyString: normalizedPrivateKey,
|
|
35
|
-
scope
|
|
40
|
+
scope,
|
|
36
41
|
state: true,
|
|
37
42
|
});
|
|
38
43
|
this._socialAuth = socialAuth;
|
|
@@ -20,10 +20,16 @@ let GithubStrategy = class GithubStrategy extends (0, passport_1.PassportStrateg
|
|
|
20
20
|
* @param configService Configuration service instance.
|
|
21
21
|
*/
|
|
22
22
|
constructor(socialAuth, configService) {
|
|
23
|
+
const scope = configService
|
|
24
|
+
.tryGet('AUTH_GITHUB_SCOPE', 'user:email')
|
|
25
|
+
.split(',')
|
|
26
|
+
.map((s) => s.trim())
|
|
27
|
+
.filter(Boolean);
|
|
23
28
|
super({
|
|
24
29
|
clientID: configService.get('AUTH_GITHUB_CLIENT_ID'),
|
|
25
30
|
clientSecret: configService.get('AUTH_GITHUB_CLIENT_SECRET'),
|
|
26
31
|
callbackURL: configService.tryGet('AUTH_GITHUB_CALLBACK_URL', '/auth/github/callback'),
|
|
32
|
+
scope,
|
|
27
33
|
});
|
|
28
34
|
this._socialAuth = socialAuth;
|
|
29
35
|
}
|
|
@@ -25,11 +25,16 @@ let GoogleStrategy = class GoogleStrategy extends (0, passport_1.PassportStrateg
|
|
|
25
25
|
* @param configService Configuration service instance.
|
|
26
26
|
*/
|
|
27
27
|
constructor(socialAuth, configService) {
|
|
28
|
+
const scope = configService
|
|
29
|
+
.tryGet('AUTH_GOOGLE_SCOPE', 'email,profile')
|
|
30
|
+
.split(',')
|
|
31
|
+
.map((s) => s.trim())
|
|
32
|
+
.filter(Boolean);
|
|
28
33
|
super({
|
|
29
34
|
clientID: configService.get('AUTH_GOOGLE_CLIENT_ID'),
|
|
30
35
|
clientSecret: configService.get('AUTH_GOOGLE_CLIENT_SECRET'),
|
|
31
36
|
callbackURL: configService.tryGet('AUTH_GOOGLE_CALLBACK_URL', '/auth/google/callback'),
|
|
32
|
-
scope
|
|
37
|
+
scope,
|
|
33
38
|
state: true,
|
|
34
39
|
});
|
|
35
40
|
this._socialAuth = socialAuth;
|
|
@@ -25,12 +25,17 @@ let MicrosoftStrategy = class MicrosoftStrategy extends (0, passport_1.PassportS
|
|
|
25
25
|
* @param configService Configuration service instance.
|
|
26
26
|
*/
|
|
27
27
|
constructor(socialAuth, configService) {
|
|
28
|
+
const scope = configService
|
|
29
|
+
.tryGet('AUTH_MICROSOFT_SCOPE', 'user.read')
|
|
30
|
+
.split(',')
|
|
31
|
+
.map((s) => s.trim())
|
|
32
|
+
.filter(Boolean);
|
|
28
33
|
super({
|
|
29
34
|
clientID: configService.get('AUTH_MICROSOFT_CLIENT_ID'),
|
|
30
35
|
clientSecret: configService.get('AUTH_MICROSOFT_CLIENT_SECRET'),
|
|
31
36
|
callbackURL: configService.tryGet('AUTH_MICROSOFT_CALLBACK_URL', '/auth/microsoft/callback'),
|
|
32
37
|
tenant: configService.tryGet('AUTH_MICROSOFT_TENANT', 'common'),
|
|
33
|
-
scope
|
|
38
|
+
scope,
|
|
34
39
|
state: true,
|
|
35
40
|
});
|
|
36
41
|
this._socialAuth = socialAuth;
|