@workos/authkit-session 0.1.3 → 0.2.0
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 +144 -554
- package/dist/core/AuthKitCore.d.ts +109 -0
- package/dist/core/AuthKitCore.d.ts.map +1 -0
- package/dist/core/AuthKitCore.js +190 -0
- package/dist/core/AuthKitCore.js.map +1 -0
- package/dist/core/session/CookieSessionStorage.d.ts +2 -3
- package/dist/core/session/CookieSessionStorage.d.ts.map +1 -1
- package/dist/core/session/CookieSessionStorage.js +22 -9
- package/dist/core/session/CookieSessionStorage.js.map +1 -1
- package/dist/core/session/types.d.ts +35 -7
- package/dist/core/session/types.d.ts.map +1 -1
- package/dist/index.d.ts +28 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -4
- package/dist/index.js.map +1 -1
- package/dist/operations/AuthOperations.d.ts +83 -0
- package/dist/operations/AuthOperations.d.ts.map +1 -0
- package/dist/operations/AuthOperations.js +137 -0
- package/dist/operations/AuthOperations.js.map +1 -0
- package/dist/service/AuthService.d.ts +137 -0
- package/dist/service/AuthService.d.ts.map +1 -0
- package/dist/service/AuthService.js +224 -0
- package/dist/service/AuthService.js.map +1 -0
- package/dist/service/factory.d.ts +37 -0
- package/dist/service/factory.d.ts.map +1 -0
- package/dist/service/factory.js +60 -0
- package/dist/service/factory.js.map +1 -0
- package/package.json +6 -6
- package/src/core/AuthKitCore.spec.ts +262 -0
- package/src/core/AuthKitCore.ts +243 -0
- package/src/core/config/ConfigurationProvider.spec.ts +1 -0
- package/src/core/session/CookieSessionStorage.spec.ts +64 -58
- package/src/core/session/CookieSessionStorage.ts +27 -10
- package/src/core/session/types.ts +38 -8
- package/src/index.ts +56 -4
- package/src/operations/AuthOperations.spec.ts +299 -0
- package/src/operations/AuthOperations.ts +179 -0
- package/src/service/AuthService.spec.ts +267 -0
- package/src/service/AuthService.ts +288 -0
- package/src/service/factory.spec.ts +120 -0
- package/src/service/factory.ts +82 -0
- package/dist/core/createAuthKitFactory.d.ts +0 -64
- package/dist/core/createAuthKitFactory.d.ts.map +0 -1
- package/dist/core/createAuthKitFactory.js +0 -95
- package/dist/core/createAuthKitFactory.js.map +0 -1
- package/dist/core/session/SessionManager.d.ts +0 -51
- package/dist/core/session/SessionManager.d.ts.map +0 -1
- package/dist/core/session/SessionManager.js +0 -238
- package/dist/core/session/SessionManager.js.map +0 -1
- package/src/core/createAuthKitFactory.spec.ts +0 -161
- package/src/core/createAuthKitFactory.ts +0 -195
- package/src/core/session/SessionManager.spec.ts +0 -357
- package/src/core/session/SessionManager.ts +0 -357
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import type { WorkOS } from '@workos-inc/node';
|
|
2
|
+
import { AuthKitCore } from '../core/AuthKitCore.js';
|
|
3
|
+
import type { AuthKitConfig } from '../core/config/types.js';
|
|
4
|
+
import { AuthOperations } from '../operations/AuthOperations.js';
|
|
5
|
+
import type {
|
|
6
|
+
AuthResult,
|
|
7
|
+
CustomClaims,
|
|
8
|
+
GetAuthorizationUrlOptions,
|
|
9
|
+
HeadersBag,
|
|
10
|
+
Session,
|
|
11
|
+
SessionEncryption,
|
|
12
|
+
SessionStorage,
|
|
13
|
+
} from '../core/session/types.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Framework-agnostic authentication service.
|
|
17
|
+
*
|
|
18
|
+
* Coordinates between:
|
|
19
|
+
* - AuthKitCore (pure business logic: crypto, JWT, refresh)
|
|
20
|
+
* - AuthOperations (WorkOS API operations: signOut, refreshSession, URLs)
|
|
21
|
+
* - SessionStorage<TRequest, TResponse> (framework-specific storage)
|
|
22
|
+
*
|
|
23
|
+
* Provides common patterns:
|
|
24
|
+
* - `withAuth()` - Validate session with auto-refresh
|
|
25
|
+
* - `handleCallback()` - Process OAuth callback
|
|
26
|
+
* - `signOut()`, `getSignInUrl()`, etc. - Delegate to AuthOperations
|
|
27
|
+
*
|
|
28
|
+
* **Used by:** @workos/authkit-tanstack-react-start
|
|
29
|
+
*/
|
|
30
|
+
export class AuthService<TRequest, TResponse> {
|
|
31
|
+
private readonly core: AuthKitCore;
|
|
32
|
+
private readonly operations: AuthOperations;
|
|
33
|
+
private readonly storage: SessionStorage<TRequest, TResponse>;
|
|
34
|
+
private readonly config: AuthKitConfig;
|
|
35
|
+
private readonly client: WorkOS;
|
|
36
|
+
|
|
37
|
+
constructor(
|
|
38
|
+
config: AuthKitConfig,
|
|
39
|
+
storage: SessionStorage<TRequest, TResponse>,
|
|
40
|
+
client: WorkOS,
|
|
41
|
+
encryption: SessionEncryption,
|
|
42
|
+
) {
|
|
43
|
+
this.config = config;
|
|
44
|
+
this.storage = storage;
|
|
45
|
+
this.client = client;
|
|
46
|
+
this.core = new AuthKitCore(config, client, encryption);
|
|
47
|
+
this.operations = new AuthOperations(this.core, client, config);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Main authentication check method.
|
|
52
|
+
*
|
|
53
|
+
* This method:
|
|
54
|
+
* 1. Reads encrypted session from request (via storage)
|
|
55
|
+
* 2. Validates and potentially refreshes the session (via core)
|
|
56
|
+
* 3. Returns auth result + optionally refreshed session data
|
|
57
|
+
*
|
|
58
|
+
* @param request - Framework-specific request object
|
|
59
|
+
* @returns Auth result and optional refreshed session data
|
|
60
|
+
*/
|
|
61
|
+
async withAuth<TCustomClaims = CustomClaims>(
|
|
62
|
+
request: TRequest,
|
|
63
|
+
): Promise<{
|
|
64
|
+
auth: AuthResult<TCustomClaims>;
|
|
65
|
+
refreshedSessionData?: string;
|
|
66
|
+
}> {
|
|
67
|
+
try {
|
|
68
|
+
const encryptedSession = await this.storage.getSession(request);
|
|
69
|
+
if (!encryptedSession) {
|
|
70
|
+
return { auth: { user: null } };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const { claims, session, refreshed } =
|
|
74
|
+
await this.core.validateAndRefresh<TCustomClaims>(
|
|
75
|
+
await this.core.decryptSession(encryptedSession),
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
const auth: AuthResult<TCustomClaims> = {
|
|
79
|
+
refreshToken: session.refreshToken,
|
|
80
|
+
user: session.user,
|
|
81
|
+
claims,
|
|
82
|
+
impersonator: session.impersonator,
|
|
83
|
+
accessToken: session.accessToken,
|
|
84
|
+
sessionId: claims.sid,
|
|
85
|
+
organizationId: claims.org_id,
|
|
86
|
+
role: claims.role,
|
|
87
|
+
roles: claims.roles,
|
|
88
|
+
permissions: claims.permissions,
|
|
89
|
+
entitlements: claims.entitlements,
|
|
90
|
+
featureFlags: claims.feature_flags,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
if (refreshed) {
|
|
94
|
+
const refreshedSessionData = await this.core.encryptSession(session);
|
|
95
|
+
return { auth, refreshedSessionData };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return { auth };
|
|
99
|
+
} catch {
|
|
100
|
+
return { auth: { user: null } };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Get a session from a request.
|
|
106
|
+
*
|
|
107
|
+
* @param request - Framework-specific request object
|
|
108
|
+
* @returns Decrypted session or null
|
|
109
|
+
*/
|
|
110
|
+
async getSession(request: TRequest): Promise<Session | null> {
|
|
111
|
+
const encryptedSession = await this.storage.getSession(request);
|
|
112
|
+
if (!encryptedSession) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
return this.core.decryptSession(encryptedSession);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Save a session to storage.
|
|
120
|
+
*
|
|
121
|
+
* @param response - Framework-specific response object (may be undefined)
|
|
122
|
+
* @param sessionData - Encrypted session string
|
|
123
|
+
* @returns Updated response and/or headers
|
|
124
|
+
*/
|
|
125
|
+
async saveSession(
|
|
126
|
+
response: TResponse | undefined,
|
|
127
|
+
sessionData: string,
|
|
128
|
+
): Promise<{ response?: TResponse; headers?: HeadersBag }> {
|
|
129
|
+
return this.storage.saveSession(response, sessionData);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Clear a session from storage.
|
|
134
|
+
*
|
|
135
|
+
* @param response - Framework-specific response object
|
|
136
|
+
* @returns Updated response and/or headers
|
|
137
|
+
*/
|
|
138
|
+
async clearSession(
|
|
139
|
+
response: TResponse,
|
|
140
|
+
): Promise<{ response?: TResponse; headers?: HeadersBag }> {
|
|
141
|
+
return this.storage.clearSession(response);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Sign out operation.
|
|
146
|
+
*
|
|
147
|
+
* Gets the WorkOS logout URL and clears the session via storage.
|
|
148
|
+
* Returns the URL plus whatever the storage returns (headers and/or response).
|
|
149
|
+
*
|
|
150
|
+
* @param sessionId - The session ID to terminate
|
|
151
|
+
* @param options - Optional return URL
|
|
152
|
+
* @returns Logout URL and storage clear result (headers and/or response)
|
|
153
|
+
*/
|
|
154
|
+
async signOut(
|
|
155
|
+
sessionId: string,
|
|
156
|
+
options?: { returnTo?: string },
|
|
157
|
+
): Promise<{
|
|
158
|
+
logoutUrl: string;
|
|
159
|
+
response?: TResponse;
|
|
160
|
+
headers?: HeadersBag;
|
|
161
|
+
}> {
|
|
162
|
+
const logoutUrl = this.operations.getLogoutUrl(sessionId, options);
|
|
163
|
+
const clearResult = await this.storage.clearSession(undefined);
|
|
164
|
+
return { logoutUrl, ...clearResult };
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Switch organization - delegates to AuthOperations.
|
|
169
|
+
*/
|
|
170
|
+
async switchOrganization(session: Session, organizationId: string) {
|
|
171
|
+
return this.operations.switchOrganization(session, organizationId);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Refresh session - delegates to AuthOperations.
|
|
176
|
+
*/
|
|
177
|
+
async refreshSession(session: Session, organizationId?: string) {
|
|
178
|
+
return this.operations.refreshSession(session, organizationId);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Get authorization URL - delegates to AuthOperations.
|
|
183
|
+
*/
|
|
184
|
+
async getAuthorizationUrl(options: GetAuthorizationUrlOptions = {}) {
|
|
185
|
+
return this.operations.getAuthorizationUrl(options);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Convenience: Get sign-in URL.
|
|
190
|
+
*/
|
|
191
|
+
async getSignInUrl(
|
|
192
|
+
options: Omit<GetAuthorizationUrlOptions, 'screenHint'> = {},
|
|
193
|
+
) {
|
|
194
|
+
return this.operations.getSignInUrl(options);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Convenience: Get sign-up URL.
|
|
199
|
+
*/
|
|
200
|
+
async getSignUpUrl(
|
|
201
|
+
options: Omit<GetAuthorizationUrlOptions, 'screenHint'> = {},
|
|
202
|
+
) {
|
|
203
|
+
return this.operations.getSignUpUrl(options);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Get the WorkOS client instance.
|
|
208
|
+
* Useful for direct API calls not covered by AuthKit.
|
|
209
|
+
*/
|
|
210
|
+
getWorkOS(): WorkOS {
|
|
211
|
+
return this.client;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Handle OAuth callback.
|
|
216
|
+
* This creates a new session after successful authentication.
|
|
217
|
+
*
|
|
218
|
+
* @param request - Framework-specific request (not currently used)
|
|
219
|
+
* @param response - Framework-specific response
|
|
220
|
+
* @param options - OAuth callback options (code, state)
|
|
221
|
+
* @returns Updated response, return pathname, and auth response
|
|
222
|
+
*/
|
|
223
|
+
async handleCallback(
|
|
224
|
+
_request: TRequest,
|
|
225
|
+
response: TResponse,
|
|
226
|
+
options: { code: string; state?: string },
|
|
227
|
+
) {
|
|
228
|
+
// Authenticate with WorkOS using the OAuth code
|
|
229
|
+
const authResponse = await this.client.userManagement.authenticateWithCode({
|
|
230
|
+
code: options.code,
|
|
231
|
+
clientId: this.config.clientId,
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// Create and save the new session
|
|
235
|
+
const session: Session = {
|
|
236
|
+
accessToken: authResponse.accessToken,
|
|
237
|
+
refreshToken: authResponse.refreshToken,
|
|
238
|
+
user: authResponse.user,
|
|
239
|
+
impersonator: authResponse.impersonator,
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
const encryptedSession = await this.core.encryptSession(session);
|
|
243
|
+
const { response: updatedResponse, headers } = await this.saveSession(
|
|
244
|
+
response,
|
|
245
|
+
encryptedSession,
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
// Parse state: format is `{internal}.{userState}` or legacy `{base64JSON}`
|
|
249
|
+
let returnPathname = '/';
|
|
250
|
+
let customState: string | undefined;
|
|
251
|
+
|
|
252
|
+
if (options.state) {
|
|
253
|
+
if (options.state.includes('.')) {
|
|
254
|
+
const [internal, ...rest] = options.state.split('.');
|
|
255
|
+
customState = rest.join('.'); // Rejoin in case userState contains dots
|
|
256
|
+
try {
|
|
257
|
+
// Reverse URL-safe base64 encoding and decode
|
|
258
|
+
const decoded = (internal ?? '')
|
|
259
|
+
.replace(/-/g, '+')
|
|
260
|
+
.replace(/_/g, '/');
|
|
261
|
+
const parsed = JSON.parse(atob(decoded));
|
|
262
|
+
returnPathname = parsed.returnPathname || '/';
|
|
263
|
+
} catch {
|
|
264
|
+
// Malformed internal state, use default
|
|
265
|
+
}
|
|
266
|
+
} else {
|
|
267
|
+
try {
|
|
268
|
+
const parsed = JSON.parse(atob(options.state));
|
|
269
|
+
if (parsed.returnPathname) {
|
|
270
|
+
returnPathname = parsed.returnPathname;
|
|
271
|
+
} else {
|
|
272
|
+
customState = options.state;
|
|
273
|
+
}
|
|
274
|
+
} catch {
|
|
275
|
+
customState = options.state;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
return {
|
|
281
|
+
response: updatedResponse,
|
|
282
|
+
headers,
|
|
283
|
+
returnPathname,
|
|
284
|
+
state: customState,
|
|
285
|
+
authResponse,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { createAuthService } from './factory.js';
|
|
2
|
+
|
|
3
|
+
const mockConfig = {
|
|
4
|
+
clientId: 'test-client-id',
|
|
5
|
+
apiKey: 'test-api-key',
|
|
6
|
+
redirectUri: 'http://localhost:3000/callback',
|
|
7
|
+
cookiePassword: 'test-password-that-is-32-chars-long!!',
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const mockStorage = {
|
|
11
|
+
getSession: async () => null,
|
|
12
|
+
saveSession: async (response: any) => ({ response }),
|
|
13
|
+
clearSession: async (response: any) => ({ response }),
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
describe('createAuthService', () => {
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
process.env.WORKOS_CLIENT_ID = mockConfig.clientId;
|
|
19
|
+
process.env.WORKOS_API_KEY = mockConfig.apiKey;
|
|
20
|
+
process.env.WORKOS_REDIRECT_URI = mockConfig.redirectUri;
|
|
21
|
+
process.env.WORKOS_COOKIE_PASSWORD = mockConfig.cookiePassword;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
delete process.env.WORKOS_CLIENT_ID;
|
|
26
|
+
delete process.env.WORKOS_API_KEY;
|
|
27
|
+
delete process.env.WORKOS_REDIRECT_URI;
|
|
28
|
+
delete process.env.WORKOS_COOKIE_PASSWORD;
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('factory creation', () => {
|
|
32
|
+
it('creates AuthService-compatible interface', () => {
|
|
33
|
+
const service = createAuthService({
|
|
34
|
+
sessionStorageFactory: () => mockStorage as any,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Verify the proxy has all expected methods
|
|
38
|
+
expect(typeof service.withAuth).toBe('function');
|
|
39
|
+
expect(typeof service.getSession).toBe('function');
|
|
40
|
+
expect(typeof service.saveSession).toBe('function');
|
|
41
|
+
expect(typeof service.clearSession).toBe('function');
|
|
42
|
+
expect(typeof service.signOut).toBe('function');
|
|
43
|
+
expect(typeof service.getAuthorizationUrl).toBe('function');
|
|
44
|
+
expect(typeof service.getSignInUrl).toBe('function');
|
|
45
|
+
expect(typeof service.getSignUpUrl).toBe('function');
|
|
46
|
+
expect(typeof service.getWorkOS).toBe('function');
|
|
47
|
+
expect(typeof service.handleCallback).toBe('function');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('accepts custom client factory', async () => {
|
|
51
|
+
const customClient = {
|
|
52
|
+
userManagement: {
|
|
53
|
+
getJwksUrl: () => 'https://custom.example.com/jwks',
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const service = createAuthService({
|
|
58
|
+
sessionStorageFactory: () => mockStorage as any,
|
|
59
|
+
clientFactory: () => customClient as any,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
expect(service.getWorkOS()).toBe(customClient);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('accepts custom encryption factory', () => {
|
|
66
|
+
const customEncryption = {
|
|
67
|
+
sealData: async () => 'custom-encrypted',
|
|
68
|
+
unsealData: async () => ({}),
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const service = createAuthService({
|
|
72
|
+
sessionStorageFactory: () => mockStorage as any,
|
|
73
|
+
encryptionFactory: () => customEncryption as any,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Factory accepts the custom encryption - verify by checking the interface exists
|
|
77
|
+
expect(typeof service.withAuth).toBe('function');
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe('lazy initialization', () => {
|
|
82
|
+
it('defers service creation until first use', async () => {
|
|
83
|
+
let storageCreated = false;
|
|
84
|
+
const storageFactory = () => {
|
|
85
|
+
storageCreated = true;
|
|
86
|
+
return mockStorage as any;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const service = createAuthService({
|
|
90
|
+
sessionStorageFactory: storageFactory,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Service created, but underlying AuthService not yet instantiated
|
|
94
|
+
expect(storageCreated).toBe(false);
|
|
95
|
+
|
|
96
|
+
// First use triggers lazy init
|
|
97
|
+
await service.getSession('request');
|
|
98
|
+
|
|
99
|
+
expect(storageCreated).toBe(true);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('creates service only once', async () => {
|
|
103
|
+
let creationCount = 0;
|
|
104
|
+
const storageFactory = () => {
|
|
105
|
+
creationCount++;
|
|
106
|
+
return mockStorage as any;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const service = createAuthService({
|
|
110
|
+
sessionStorageFactory: storageFactory,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
await service.getSession('request');
|
|
114
|
+
await service.getSession('request');
|
|
115
|
+
await service.getSession('request');
|
|
116
|
+
|
|
117
|
+
expect(creationCount).toBe(1);
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
});
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { WorkOS } from '@workos-inc/node';
|
|
2
|
+
import { once } from '../utils.js';
|
|
3
|
+
import { getFullConfig } from '../core/config.js';
|
|
4
|
+
import type { AuthKitConfig } from '../core/config/types.js';
|
|
5
|
+
import { getWorkOS } from '../core/client/workos.js';
|
|
6
|
+
import sessionEncryption from '../core/encryption/ironWebcryptoEncryption.js';
|
|
7
|
+
import type {
|
|
8
|
+
SessionEncryption,
|
|
9
|
+
SessionStorage,
|
|
10
|
+
} from '../core/session/types.js';
|
|
11
|
+
import { AuthService } from './AuthService.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Creates an AuthService instance with lazy initialization support.
|
|
15
|
+
*
|
|
16
|
+
* This factory function provides ergonomic AuthService creation with sensible defaults.
|
|
17
|
+
* The returned service uses lazy initialization, allowing configure() to be called
|
|
18
|
+
* after instantiation but before first use.
|
|
19
|
+
*
|
|
20
|
+
* @param options - Configuration options
|
|
21
|
+
* @param options.sessionStorageFactory - Factory function to create storage adapter
|
|
22
|
+
* @param options.clientFactory - Optional factory for WorkOS client (defaults to getWorkOS)
|
|
23
|
+
* @param options.encryptionFactory - Optional factory for encryption (defaults to iron-webcrypto)
|
|
24
|
+
* @returns AuthService instance with lazy initialization
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // Create service (config not needed yet)
|
|
29
|
+
* export const authService = createAuthService({
|
|
30
|
+
* sessionStorageFactory: (config) => new MyFrameworkStorage(config),
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* // Configure later
|
|
34
|
+
* configure({ clientId: '...' });
|
|
35
|
+
*
|
|
36
|
+
* // Use (triggers lazy init)
|
|
37
|
+
* await authService.withAuth(request);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export function createAuthService<TRequest, TResponse>(options: {
|
|
41
|
+
sessionStorageFactory: (
|
|
42
|
+
config: AuthKitConfig,
|
|
43
|
+
) => SessionStorage<TRequest, TResponse>;
|
|
44
|
+
clientFactory?: (config: AuthKitConfig) => WorkOS;
|
|
45
|
+
encryptionFactory?: (config: AuthKitConfig) => SessionEncryption;
|
|
46
|
+
}): AuthService<TRequest, TResponse> {
|
|
47
|
+
const {
|
|
48
|
+
sessionStorageFactory,
|
|
49
|
+
clientFactory = () => getWorkOS(),
|
|
50
|
+
encryptionFactory = () => sessionEncryption,
|
|
51
|
+
} = options;
|
|
52
|
+
|
|
53
|
+
// Lazily create the real AuthService with resolved config
|
|
54
|
+
const getService = once(() => {
|
|
55
|
+
const config = getFullConfig();
|
|
56
|
+
const storage = sessionStorageFactory(config);
|
|
57
|
+
const client = clientFactory(config);
|
|
58
|
+
const encryption = encryptionFactory(config);
|
|
59
|
+
return new AuthService(config, storage, client, encryption);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Return proxy that lazily delegates to the real service
|
|
63
|
+
// This allows configure() to be called after createAuthService() but before first use
|
|
64
|
+
return {
|
|
65
|
+
withAuth: request => getService().withAuth(request),
|
|
66
|
+
getSession: request => getService().getSession(request),
|
|
67
|
+
saveSession: (response, sessionData) =>
|
|
68
|
+
getService().saveSession(response, sessionData),
|
|
69
|
+
clearSession: response => getService().clearSession(response),
|
|
70
|
+
signOut: (sessionId, opts) => getService().signOut(sessionId, opts),
|
|
71
|
+
switchOrganization: (session, organizationId) =>
|
|
72
|
+
getService().switchOrganization(session, organizationId),
|
|
73
|
+
refreshSession: (session, organizationId) =>
|
|
74
|
+
getService().refreshSession(session, organizationId),
|
|
75
|
+
getAuthorizationUrl: opts => getService().getAuthorizationUrl(opts),
|
|
76
|
+
getSignInUrl: opts => getService().getSignInUrl(opts),
|
|
77
|
+
getSignUpUrl: opts => getService().getSignUpUrl(opts),
|
|
78
|
+
getWorkOS: () => getService().getWorkOS(),
|
|
79
|
+
handleCallback: (request, response, opts) =>
|
|
80
|
+
getService().handleCallback(request, response, opts),
|
|
81
|
+
} as AuthService<TRequest, TResponse>;
|
|
82
|
+
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { WorkOS } from '@workos-inc/node';
|
|
2
|
-
import type { AuthKitConfig } from './config/types.js';
|
|
3
|
-
import type { AuthUrlOptions, BaseTokenClaims, CustomClaims, SessionEncryption, SessionStorage } from './session/types.js';
|
|
4
|
-
export declare const createAuthKitFactory: <TRequest, TResponse>(options: {
|
|
5
|
-
sessionStorageFactory: (config: AuthKitConfig) => SessionStorage<TRequest, TResponse>;
|
|
6
|
-
sessionEncryptionFactory?: (confg: AuthKitConfig) => SessionEncryption;
|
|
7
|
-
clientFactory?: (config: AuthKitConfig) => WorkOS;
|
|
8
|
-
}) => {
|
|
9
|
-
withAuth: (request: any) => Promise<import("./session/types.js").AuthResult<CustomClaims>>;
|
|
10
|
-
getAuthorizationUrl: (args_0?: import("./session/types.js").GetAuthorizationUrlOptions | undefined) => Promise<string>;
|
|
11
|
-
refreshSession: (session: import("./session/types.js").Session, organizationId?: string | undefined) => Promise<{
|
|
12
|
-
user: import("@workos-inc/node").User;
|
|
13
|
-
sessionId: string;
|
|
14
|
-
organizationId: string | undefined;
|
|
15
|
-
role: string | undefined;
|
|
16
|
-
roles: string[] | undefined;
|
|
17
|
-
permissions: string[] | undefined;
|
|
18
|
-
entitlements: string[] | undefined;
|
|
19
|
-
impersonator: import("@workos-inc/node").Impersonator | undefined;
|
|
20
|
-
accessToken: string;
|
|
21
|
-
claims: BaseTokenClaims & CustomClaims;
|
|
22
|
-
sessionData: string;
|
|
23
|
-
session: import("./session/types.js").Session;
|
|
24
|
-
}>;
|
|
25
|
-
saveSession: (response: TResponse | undefined, sessionData: string, options?: unknown) => Promise<{
|
|
26
|
-
response?: TResponse | undefined;
|
|
27
|
-
headers?: import("./session/types.js").HeadersBag;
|
|
28
|
-
}>;
|
|
29
|
-
getSignInUrl: (options?: AuthUrlOptions) => Promise<string>;
|
|
30
|
-
getSignUpUrl: (options?: AuthUrlOptions) => Promise<string>;
|
|
31
|
-
getWorkOS: () => WorkOS;
|
|
32
|
-
getSession: (request: TRequest) => Promise<import("./session/types.js").Session | null>;
|
|
33
|
-
terminateSession: (session: import("./session/types.js").Session, response: any, options?: {
|
|
34
|
-
returnTo?: string;
|
|
35
|
-
} | undefined) => Promise<{
|
|
36
|
-
response?: TResponse | undefined;
|
|
37
|
-
headers?: import("./session/types.js").HeadersBag;
|
|
38
|
-
logoutUrl: string;
|
|
39
|
-
}>;
|
|
40
|
-
signOut: (request: TRequest, response: TResponse, options?: {
|
|
41
|
-
returnTo?: string;
|
|
42
|
-
}) => Promise<TResponse | {
|
|
43
|
-
response?: TResponse | undefined;
|
|
44
|
-
headers?: import("./session/types.js").HeadersBag;
|
|
45
|
-
} | undefined>;
|
|
46
|
-
switchToOrganization: (request: any, response: any, organizationId: string) => Promise<{
|
|
47
|
-
response?: TResponse | undefined;
|
|
48
|
-
headers?: import("./session/types.js").HeadersBag;
|
|
49
|
-
authResult: import("./session/types.js").AuthResult<CustomClaims>;
|
|
50
|
-
}>;
|
|
51
|
-
handleCallback: (_request: TRequest, response: TResponse, options: {
|
|
52
|
-
code: string;
|
|
53
|
-
state?: string;
|
|
54
|
-
}) => Promise<{
|
|
55
|
-
response: {
|
|
56
|
-
response?: TResponse | undefined;
|
|
57
|
-
headers?: import("./session/types.js").HeadersBag;
|
|
58
|
-
};
|
|
59
|
-
returnPathname: string;
|
|
60
|
-
authResponse: import("@workos-inc/node").AuthenticationResponse;
|
|
61
|
-
}>;
|
|
62
|
-
getTokenClaims: <TCustomClaims = CustomClaims>(request: TRequest, accessToken?: string) => Promise<Partial<BaseTokenClaims & TCustomClaims>>;
|
|
63
|
-
};
|
|
64
|
-
//# sourceMappingURL=createAuthKitFactory.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createAuthKitFactory.d.ts","sourceRoot":"","sources":["../../src/core/createAuthKitFactory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAQ/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAIvD,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACf,MAAM,oBAAoB,CAAC;AAE5B,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,EACR,SAAS;2BAEc,CACrB,MAAM,EAAE,aAAa,KAClB,cAAc,CAAC,QAAQ,EAAE,SAAS,CAAC;+BACb,CAAC,KAAK,EAAE,aAAa,KAAK,iBAAiB;oBACtD,CAAC,MAAM,EAAE,aAAa,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;;;6BA2CtB,cAAc;6BAMd,cAAc;;0BAUjB,QAAQ;;;;;;;;uBAQnB,QAAQ,YACP,SAAS,YACT;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;;+BAuCrB,QAAQ,YACR,SAAS,WACV;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;;qBAoCpB,aAAa,0BACzB,QAAQ,gBACH,MAAM,KACnB,OAAO,CAAC,OAAO,CAAC,eAAe,GAAG,aAAa,CAAC,CAAC;CAiBtD,CAAC"}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { once } from '../utils.js';
|
|
2
|
-
import { getWorkOS } from './client/workos.js';
|
|
3
|
-
import { getConfig, getConfigurationProvider, getFullConfig, } from './config.js';
|
|
4
|
-
import sessionEncryption from './encryption/ironWebcryptoEncryption.js';
|
|
5
|
-
import { SessionManager } from './session/SessionManager.js';
|
|
6
|
-
import TokenManager from './session/TokenManager.js';
|
|
7
|
-
export const createAuthKitFactory = once(function createAuthKit(options) {
|
|
8
|
-
const { sessionStorageFactory, clientFactory = () => getWorkOS(), sessionEncryptionFactory = () => sessionEncryption, } = options;
|
|
9
|
-
const getTokenManager = once(() => new TokenManager(getConfig('clientId'), clientFactory(getFullConfig())));
|
|
10
|
-
const getSessionManager = once(() => new SessionManager(getConfigurationProvider(), sessionStorageFactory(getFullConfig()), getTokenManager(), clientFactory(getFullConfig()), sessionEncryptionFactory(getFullConfig())));
|
|
11
|
-
return {
|
|
12
|
-
withAuth: (...args) => getSessionManager().withAuth(...args),
|
|
13
|
-
getAuthorizationUrl: (...args) => getSessionManager().getAuthorizationUrl(...args),
|
|
14
|
-
refreshSession: (...args) => getSessionManager().refreshSession(...args),
|
|
15
|
-
saveSession: (...args) => sessionStorageFactory(getFullConfig()).saveSession(...args),
|
|
16
|
-
getSignInUrl: (options) => getSessionManager().getAuthorizationUrl({
|
|
17
|
-
...options,
|
|
18
|
-
screenHint: 'sign-in',
|
|
19
|
-
}),
|
|
20
|
-
getSignUpUrl: (options) => getSessionManager().getAuthorizationUrl({
|
|
21
|
-
...options,
|
|
22
|
-
screenHint: 'sign-up',
|
|
23
|
-
}),
|
|
24
|
-
// Expose getWorkOS for direct client access
|
|
25
|
-
getWorkOS: () => clientFactory(getFullConfig()),
|
|
26
|
-
// Expose SessionManager's getSession directly
|
|
27
|
-
getSession: (request) => getSessionManager().getSession(request),
|
|
28
|
-
// terminateSession uses the standard SessionManager signature
|
|
29
|
-
terminateSession: (...args) => getSessionManager().terminateSession(...args),
|
|
30
|
-
signOut: async (request, response, options) => {
|
|
31
|
-
// Get the current session
|
|
32
|
-
const authResult = await getSessionManager().withAuth(request);
|
|
33
|
-
if (!authResult.user ||
|
|
34
|
-
!authResult.accessToken ||
|
|
35
|
-
!authResult.refreshToken) {
|
|
36
|
-
// No session to terminate, just clear cookies
|
|
37
|
-
return sessionStorageFactory(getFullConfig()).clearSession(response);
|
|
38
|
-
}
|
|
39
|
-
// Create session object for termination
|
|
40
|
-
const session = {
|
|
41
|
-
accessToken: authResult.accessToken,
|
|
42
|
-
refreshToken: authResult.refreshToken,
|
|
43
|
-
user: authResult.user,
|
|
44
|
-
impersonator: authResult.impersonator,
|
|
45
|
-
};
|
|
46
|
-
// Terminate the session (this clears cookies and returns logout URL)
|
|
47
|
-
const result = await getSessionManager().terminateSession(session, response, options);
|
|
48
|
-
return result.response;
|
|
49
|
-
},
|
|
50
|
-
switchToOrganization: (...args) => getSessionManager().switchToOrganization(...args),
|
|
51
|
-
handleCallback: async (_request, response, options) => {
|
|
52
|
-
const config = getFullConfig();
|
|
53
|
-
const clientId = config.clientId;
|
|
54
|
-
const client = clientFactory(config);
|
|
55
|
-
// Authenticate with the OAuth code
|
|
56
|
-
const authResponse = await client.userManagement.authenticateWithCode({
|
|
57
|
-
code: options.code,
|
|
58
|
-
clientId,
|
|
59
|
-
});
|
|
60
|
-
// Create session using SessionManager
|
|
61
|
-
const updatedResponse = await getSessionManager().createSession(authResponse, response);
|
|
62
|
-
// Decode state if provided
|
|
63
|
-
let returnPathname = '/';
|
|
64
|
-
if (options.state) {
|
|
65
|
-
try {
|
|
66
|
-
const decoded = JSON.parse(atob(options.state));
|
|
67
|
-
returnPathname = decoded.returnPathname || '/';
|
|
68
|
-
}
|
|
69
|
-
catch {
|
|
70
|
-
// Invalid state, use default
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
response: updatedResponse,
|
|
75
|
-
returnPathname,
|
|
76
|
-
authResponse,
|
|
77
|
-
};
|
|
78
|
-
},
|
|
79
|
-
getTokenClaims: async (request, accessToken) => {
|
|
80
|
-
const tokenToUse = accessToken ||
|
|
81
|
-
(await getSessionManager().withAuth(request))
|
|
82
|
-
.accessToken;
|
|
83
|
-
if (!tokenToUse) {
|
|
84
|
-
return {};
|
|
85
|
-
}
|
|
86
|
-
try {
|
|
87
|
-
return getTokenManager().parseTokenClaims(tokenToUse);
|
|
88
|
-
}
|
|
89
|
-
catch {
|
|
90
|
-
return {};
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
});
|
|
95
|
-
//# sourceMappingURL=createAuthKitFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createAuthKitFactory.js","sourceRoot":"","sources":["../../src/core/createAuthKitFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EACL,SAAS,EACT,wBAAwB,EACxB,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,OAAO,iBAAiB,MAAM,yCAAyC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,YAAY,MAAM,2BAA2B,CAAC;AASrD,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC,SAAS,aAAa,CAG7D,OAMD;IACC,MAAM,EACJ,qBAAqB,EACrB,aAAa,GAAG,GAAG,EAAE,CAAC,SAAS,EAAE,EACj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