@soapjs/soap-auth 0.4.4 → 1.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.
- package/README.md +286 -125
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/recipes/auth-config.recipes.d.ts +40 -0
- package/build/recipes/auth-config.recipes.js +135 -0
- package/build/recipes/http-context.helpers.d.ts +13 -0
- package/build/recipes/http-context.helpers.js +64 -0
- package/build/recipes/index.d.ts +3 -0
- package/build/recipes/index.js +19 -0
- package/build/recipes/oauth2-presets.d.ts +20 -0
- package/build/recipes/oauth2-presets.js +74 -0
- package/build/services/pkce.service.js +8 -6
- package/build/soap-auth.js +62 -0
- package/build/strategies/jwt/jwt.strategy.d.ts +2 -2
- package/build/strategies/jwt/jwt.strategy.js +6 -6
- package/build/strategies/oauth2/hybrid.oauth2.strategy.js +2 -2
- package/build/strategies/oauth2/oauth2.strategy.d.ts +1 -1
- package/build/strategies/oauth2/oauth2.strategy.js +12 -8
- package/build/strategies/oauth2/oauth2.types.d.ts +8 -3
- package/build/strategies/oauth2/providers/configurable-hybrid-oauth2.strategy.d.ts +19 -0
- package/build/strategies/oauth2/providers/configurable-hybrid-oauth2.strategy.js +85 -0
- package/build/strategies/oauth2/providers/configurable-oauth2.strategy.d.ts +11 -0
- package/build/strategies/oauth2/providers/configurable-oauth2.strategy.js +46 -0
- package/build/strategies/oauth2/providers/index.d.ts +2 -0
- package/build/strategies/oauth2/providers/index.js +2 -0
- package/build/strategies/oauth2/providers/provider.types.d.ts +3 -0
- package/build/strategies/token-auth.strategy.d.ts +2 -2
- package/build/strategies/token-auth.strategy.js +2 -2
- package/build/types.d.ts +22 -12
- package/package.json +137 -13
- package/.claude/settings.local.json +0 -20
- package/jest.config.unit.json +0 -10
|
@@ -15,6 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./http-oauth2.strategy"), exports);
|
|
18
|
+
__exportStar(require("./configurable-oauth2.strategy"), exports);
|
|
19
|
+
__exportStar(require("./configurable-hybrid-oauth2.strategy"), exports);
|
|
18
20
|
__exportStar(require("./google.strategy"), exports);
|
|
19
21
|
__exportStar(require("./github.strategy"), exports);
|
|
20
22
|
__exportStar(require("./facebook.strategy"), exports);
|
|
@@ -5,3 +5,6 @@ export interface SocialProviderConfig<TUser extends Soap.AuthUser = Soap.AuthUse
|
|
|
5
5
|
endpoints?: Partial<OAuth2Endpoints>;
|
|
6
6
|
routes?: OAuth2StrategyConfig<Soap.HttpContext, TUser>["routes"];
|
|
7
7
|
}
|
|
8
|
+
export interface ConfigurableOAuth2StrategyConfig<TUser extends Soap.AuthUser = Soap.AuthUser> extends OAuth2StrategyConfig<Soap.HttpContext, TUser> {
|
|
9
|
+
name: string;
|
|
10
|
+
}
|
|
@@ -13,8 +13,8 @@ export declare abstract class TokenAuthStrategy<TContext = Soap.HttpContext, TUs
|
|
|
13
13
|
protected abstract verifyRefreshToken(token: string): Promise<any>;
|
|
14
14
|
protected abstract generateAccessToken(data: TUser, context: TContext): Promise<string>;
|
|
15
15
|
protected abstract generateRefreshToken(data: TUser, context: TContext): Promise<string>;
|
|
16
|
-
protected abstract storeAccessToken(token: string): Promise<void>;
|
|
17
|
-
protected abstract storeRefreshToken(token: string): Promise<void>;
|
|
16
|
+
protected abstract storeAccessToken(token: string, context?: TContext): Promise<void>;
|
|
17
|
+
protected abstract storeRefreshToken(token: string, context?: TContext): Promise<void>;
|
|
18
18
|
protected abstract invalidateAccessToken(token: string, context?: TContext): Promise<void>;
|
|
19
19
|
protected abstract invalidateRefreshToken(token: string, context?: TContext): Promise<void>;
|
|
20
20
|
protected abstract embedAccessToken(token: string, context: TContext): void;
|
|
@@ -153,10 +153,10 @@ class TokenAuthStrategy extends base_auth_strategy_1.BaseAuthStrategy {
|
|
|
153
153
|
refreshToken = await this.generateRefreshToken(user, context);
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
await this.storeAccessToken(accessToken);
|
|
156
|
+
await this.storeAccessToken(accessToken, context);
|
|
157
157
|
this.embedAccessToken(accessToken, context);
|
|
158
158
|
if (refreshToken) {
|
|
159
|
-
await this.storeRefreshToken(refreshToken);
|
|
159
|
+
await this.storeRefreshToken(refreshToken, context);
|
|
160
160
|
this.embedRefreshToken(refreshToken, context);
|
|
161
161
|
}
|
|
162
162
|
this.logger?.info(`JWT issued successfully`);
|
package/build/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as Soap from "@soapjs/soap";
|
|
2
2
|
export type AuthResult<TUser extends Soap.AuthUser = Soap.AuthUser> = Soap.AuthResult<TUser>;
|
|
3
|
-
export type AuthStrategy<TUser extends Soap.AuthUser = Soap.AuthUser> = Soap.AuthStrategy<TUser>;
|
|
3
|
+
export type AuthStrategy<TUser extends Soap.AuthUser = Soap.AuthUser, TContext extends Soap.HttpContext = Soap.HttpContext> = Soap.AuthStrategy<TUser, TContext>;
|
|
4
4
|
import { LocalStrategyConfig } from "./strategies/local/local.types";
|
|
5
|
-
import {
|
|
5
|
+
import { OAuth2ProviderConfig } from "./strategies/oauth2/oauth2.types";
|
|
6
6
|
import { ApiKeyStrategyConfig } from "./strategies/api-key/api-key.types";
|
|
7
7
|
import { BasicStrategyConfig } from "./strategies/basic/basic.types";
|
|
8
8
|
import { JwtConfig } from "./strategies/jwt/jwt.types";
|
|
@@ -75,13 +75,13 @@ export interface MfaConfig<TUser = unknown, TContext = unknown> {
|
|
|
75
75
|
}
|
|
76
76
|
export type PasswordType = "default" | "one-time" | "temporary";
|
|
77
77
|
export type NewPasswordOptions = {
|
|
78
|
-
expiresIn?: number;
|
|
78
|
+
expiresIn?: string | number;
|
|
79
79
|
type: PasswordType;
|
|
80
80
|
additional?: Record<string, unknown>;
|
|
81
81
|
};
|
|
82
82
|
export type PasswordInfo = {
|
|
83
83
|
type: PasswordType;
|
|
84
|
-
expiresIn?: number;
|
|
84
|
+
expiresIn?: string | number;
|
|
85
85
|
lastChangeDate?: Date;
|
|
86
86
|
};
|
|
87
87
|
export interface PasswordPolicyConfig {
|
|
@@ -175,7 +175,10 @@ export interface SoapHttpAuthConfig<TContext = unknown, TUser extends Soap.AuthU
|
|
|
175
175
|
local?: LocalStrategyConfig<TContext, TUser>;
|
|
176
176
|
jwt?: JwtConfig<TContext, TUser>;
|
|
177
177
|
oauth2?: {
|
|
178
|
-
[provider: string]:
|
|
178
|
+
[provider: string]: OAuth2ProviderConfig<TContext, TUser>;
|
|
179
|
+
};
|
|
180
|
+
hybridOAuth2?: {
|
|
181
|
+
[provider: string]: OAuth2ProviderConfig<TContext, TUser>;
|
|
179
182
|
};
|
|
180
183
|
apiKey?: ApiKeyStrategyConfig<TContext, TUser>;
|
|
181
184
|
basic?: BasicStrategyConfig<TContext, TUser>;
|
|
@@ -256,10 +259,17 @@ export interface TokenVerifierConfig {
|
|
|
256
259
|
};
|
|
257
260
|
verify?: (token: string) => Promise<any>;
|
|
258
261
|
}
|
|
259
|
-
export interface
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
262
|
+
export interface PersistenceMetadata {
|
|
263
|
+
key?: string;
|
|
264
|
+
name?: string;
|
|
265
|
+
expiration?: number;
|
|
266
|
+
expiresIn?: string | number;
|
|
267
|
+
[key: string]: unknown;
|
|
268
|
+
}
|
|
269
|
+
export interface PersistenceConfig<T = any, TContext = any> {
|
|
270
|
+
store: (data: any, context?: TContext | null, metadata?: PersistenceMetadata, ...args: any[]) => Promise<void> | void;
|
|
271
|
+
read: (context?: TContext | null, key?: string, ...args: any[]) => Promise<T | null> | T | null;
|
|
272
|
+
remove: (context?: TContext | null, key?: string, ...args: any[]) => Promise<void> | void;
|
|
263
273
|
}
|
|
264
274
|
export interface ContextOperationConfig<TContext = any, TData = any> {
|
|
265
275
|
embed?: (context: TContext, data: TData) => void;
|
|
@@ -269,7 +279,7 @@ export interface TokenConfig<TContext = any, TUser = any> extends ContextOperati
|
|
|
269
279
|
rotation?: TokenRotationConfig<TContext, TUser>;
|
|
270
280
|
issuer?: TokenIssuerConfig<TContext>;
|
|
271
281
|
verifier?: TokenVerifierConfig;
|
|
272
|
-
persistence?: PersistenceConfig
|
|
282
|
+
persistence?: PersistenceConfig<string, TContext>;
|
|
273
283
|
additional?: Record<string, unknown>;
|
|
274
284
|
}
|
|
275
285
|
export interface RefreshTokenConfig<TContext = any, TUser = any> extends TokenConfig<TContext, TUser> {
|
|
@@ -295,13 +305,13 @@ export interface PKCEConfig<TContext> {
|
|
|
295
305
|
generate?: (codeVerifier: string) => string;
|
|
296
306
|
embed?: (context: TContext, challenge: string) => void;
|
|
297
307
|
extract?: (context: TContext) => string | null;
|
|
298
|
-
persistence?: PersistenceConfig
|
|
308
|
+
persistence?: PersistenceConfig<any, TContext>;
|
|
299
309
|
};
|
|
300
310
|
verifier: {
|
|
301
311
|
expiresIn?: number;
|
|
302
312
|
generate?: () => string;
|
|
303
313
|
embed?: (context: TContext, codeVerifier: string) => void;
|
|
304
314
|
extract?: (context: TContext) => string | null;
|
|
305
|
-
persistence?: PersistenceConfig
|
|
315
|
+
persistence?: PersistenceConfig<any, TContext>;
|
|
306
316
|
};
|
|
307
317
|
}
|
package/package.json
CHANGED
|
@@ -1,35 +1,159 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soapjs/soap-auth",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Authentication strategies, sessions, MFA, and token helpers for the SoapJS ecosystem.",
|
|
5
5
|
"homepage": "https://docs.soapjs.com",
|
|
6
|
-
"repository":
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/soapjs/soap-auth.git"
|
|
9
|
+
},
|
|
7
10
|
"main": "build/index.js",
|
|
8
11
|
"types": "build/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./build/index.d.ts",
|
|
15
|
+
"require": "./build/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./session": {
|
|
18
|
+
"types": "./build/session/index.d.ts",
|
|
19
|
+
"require": "./build/session/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./session/*": {
|
|
22
|
+
"types": "./build/session/*.d.ts",
|
|
23
|
+
"require": "./build/session/*.js"
|
|
24
|
+
},
|
|
25
|
+
"./services": {
|
|
26
|
+
"types": "./build/services/index.d.ts",
|
|
27
|
+
"require": "./build/services/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./services/*": {
|
|
30
|
+
"types": "./build/services/*.d.ts",
|
|
31
|
+
"require": "./build/services/*.js"
|
|
32
|
+
},
|
|
33
|
+
"./strategies": {
|
|
34
|
+
"types": "./build/strategies/index.d.ts",
|
|
35
|
+
"require": "./build/strategies/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./strategies/*": {
|
|
38
|
+
"types": "./build/strategies/*.d.ts",
|
|
39
|
+
"require": "./build/strategies/*.js"
|
|
40
|
+
},
|
|
41
|
+
"./tools": {
|
|
42
|
+
"types": "./build/tools/index.d.ts",
|
|
43
|
+
"require": "./build/tools/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./tools/*": {
|
|
46
|
+
"types": "./build/tools/*.d.ts",
|
|
47
|
+
"require": "./build/tools/*.js"
|
|
48
|
+
},
|
|
49
|
+
"./recipes": {
|
|
50
|
+
"types": "./build/recipes/index.d.ts",
|
|
51
|
+
"require": "./build/recipes/index.js"
|
|
52
|
+
},
|
|
53
|
+
"./recipes/*": {
|
|
54
|
+
"types": "./build/recipes/*.d.ts",
|
|
55
|
+
"require": "./build/recipes/*.js"
|
|
56
|
+
},
|
|
57
|
+
"./errors": {
|
|
58
|
+
"types": "./build/errors.d.ts",
|
|
59
|
+
"require": "./build/errors.js"
|
|
60
|
+
},
|
|
61
|
+
"./types": {
|
|
62
|
+
"types": "./build/types.d.ts",
|
|
63
|
+
"require": "./build/types.js"
|
|
64
|
+
},
|
|
65
|
+
"./soap-auth": {
|
|
66
|
+
"types": "./build/soap-auth.d.ts",
|
|
67
|
+
"require": "./build/soap-auth.js"
|
|
68
|
+
},
|
|
69
|
+
"./utils/validation": {
|
|
70
|
+
"types": "./build/utils/validation.d.ts",
|
|
71
|
+
"require": "./build/utils/validation.js"
|
|
72
|
+
},
|
|
73
|
+
"./package.json": "./package.json"
|
|
74
|
+
},
|
|
75
|
+
"typesVersions": {
|
|
76
|
+
"*": {
|
|
77
|
+
"session": [
|
|
78
|
+
"./build/session/index.d.ts"
|
|
79
|
+
],
|
|
80
|
+
"session/*": [
|
|
81
|
+
"./build/session/*"
|
|
82
|
+
],
|
|
83
|
+
"services": [
|
|
84
|
+
"./build/services/index.d.ts"
|
|
85
|
+
],
|
|
86
|
+
"services/*": [
|
|
87
|
+
"./build/services/*"
|
|
88
|
+
],
|
|
89
|
+
"strategies": [
|
|
90
|
+
"./build/strategies/index.d.ts"
|
|
91
|
+
],
|
|
92
|
+
"strategies/*": [
|
|
93
|
+
"./build/strategies/*"
|
|
94
|
+
],
|
|
95
|
+
"tools": [
|
|
96
|
+
"./build/tools/index.d.ts"
|
|
97
|
+
],
|
|
98
|
+
"tools/*": [
|
|
99
|
+
"./build/tools/*"
|
|
100
|
+
],
|
|
101
|
+
"recipes": [
|
|
102
|
+
"./build/recipes/index.d.ts"
|
|
103
|
+
],
|
|
104
|
+
"recipes/*": [
|
|
105
|
+
"./build/recipes/*"
|
|
106
|
+
],
|
|
107
|
+
"errors": [
|
|
108
|
+
"./build/errors.d.ts"
|
|
109
|
+
],
|
|
110
|
+
"types": [
|
|
111
|
+
"./build/types.d.ts"
|
|
112
|
+
],
|
|
113
|
+
"soap-auth": [
|
|
114
|
+
"./build/soap-auth.d.ts"
|
|
115
|
+
],
|
|
116
|
+
"utils/validation": [
|
|
117
|
+
"./build/utils/validation.d.ts"
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
"files": [
|
|
122
|
+
"build",
|
|
123
|
+
"README.md",
|
|
124
|
+
"LICENSE",
|
|
125
|
+
"ldap.md",
|
|
126
|
+
"saml.md"
|
|
127
|
+
],
|
|
128
|
+
"sideEffects": false,
|
|
9
129
|
"license": "MIT",
|
|
10
130
|
"author": "Radoslaw Kamysz",
|
|
11
131
|
"scripts": {
|
|
12
132
|
"test:unit": "jest --config=jest.config.unit.json",
|
|
13
133
|
"clean": "rm -rf ./build",
|
|
14
|
-
"build": "npm run clean && tsc
|
|
15
|
-
"
|
|
134
|
+
"build": "npm run clean && tsc --project tsconfig.build.json",
|
|
135
|
+
"prepack": "npm run build",
|
|
136
|
+
"prepublishOnly": "npm run test:unit && npm run build"
|
|
137
|
+
},
|
|
138
|
+
"publishConfig": {
|
|
139
|
+
"access": "public"
|
|
16
140
|
},
|
|
17
141
|
"devDependencies": {
|
|
18
|
-
"@soapjs/soap": "^0.
|
|
19
|
-
"@types/jest": "^
|
|
20
|
-
"jest": "^
|
|
21
|
-
"ts-jest": "^
|
|
142
|
+
"@soapjs/soap": "^0.14.0",
|
|
143
|
+
"@types/jest": "^29.5.14",
|
|
144
|
+
"jest": "^29.7.0",
|
|
145
|
+
"ts-jest": "^29.4.11",
|
|
22
146
|
"typescript": "^4.8.2"
|
|
23
147
|
},
|
|
24
148
|
"peerDependencies": {
|
|
25
|
-
"@soapjs/soap": ">=0.
|
|
149
|
+
"@soapjs/soap": ">=0.14.0"
|
|
26
150
|
},
|
|
27
151
|
"engines": {
|
|
28
|
-
"node": ">=
|
|
152
|
+
"node": ">=24.17.0"
|
|
29
153
|
},
|
|
30
154
|
"dependencies": {
|
|
31
155
|
"bcrypt": "^6.0.0",
|
|
32
|
-
"jsonwebtoken": "^9.0.
|
|
33
|
-
"jwks-rsa": "^3.
|
|
156
|
+
"jsonwebtoken": "^9.0.3",
|
|
157
|
+
"jwks-rsa": "^3.2.2"
|
|
34
158
|
}
|
|
35
159
|
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"permissions": {
|
|
3
|
-
"allow": [
|
|
4
|
-
"Bash(npm run *)",
|
|
5
|
-
"Bash(npx tsc *)",
|
|
6
|
-
"Bash(npm audit *)",
|
|
7
|
-
"Bash(npm uninstall *)",
|
|
8
|
-
"Bash(npm install *)",
|
|
9
|
-
"Bash(echo \"=== SOAP-EXPRESS src ===\" && find /Users/rad/git/soapjs/soap-express/src -type f -name \"*.ts\" | grep -v __tests__ | grep -v \".test.\" | sort && echo \"\" && echo \"=== SOAP-EXPRESS package.json ===\" && cat /Users/rad/git/soapjs/soap-express/package.json)",
|
|
10
|
-
"Bash(echo \"=== SOAP src \\(http + common\\) ===\" && find /Users/rad/git/soapjs/soap/src -type f -name \"*.ts\" | grep -v __tests__ | grep -v \".test.\" | grep -E \"\\(http|common|config\\)\" | sort)",
|
|
11
|
-
"Bash(cat /Users/rad/git/soapjs/soap/package.json | grep '\"version\"' | head -1)",
|
|
12
|
-
"Bash(grep -rln \"AuthStrategy\\\\|\\\\.configure\\(\\\\|\\\\.middleware\\(\\\\|serializeUser\\\\|AuthConfig\\\\b\" src --include=\"*.test.ts\")",
|
|
13
|
-
"Bash(grep -rln \"AuthStrategy\\\\|AuthConfig\" src/**/__tests__)",
|
|
14
|
-
"Bash(npm pack *)",
|
|
15
|
-
"Read(//Users/rad/git/soapjs/**)",
|
|
16
|
-
"Bash(npm view *)",
|
|
17
|
-
"Bash(grep -v \"^$\")"
|
|
18
|
-
]
|
|
19
|
-
}
|
|
20
|
-
}
|
package/jest.config.unit.json
DELETED