@workos-inc/node 7.37.2 → 7.39.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/lib/fga/fga.spec.js +2 -0
- package/lib/fga/interfaces/check.interface.d.ts +3 -0
- package/lib/fga/interfaces/check.interface.js +1 -0
- package/lib/organizations/fixtures/list-organization-roles.json +8 -0
- package/lib/organizations/organizations.spec.js +35 -0
- package/lib/roles/interfaces/role.interface.d.ts +8 -0
- package/lib/roles/serializers/role.serializer.js +1 -0
- package/lib/user-management/fixtures/list-users.json +3 -1
- package/lib/user-management/fixtures/user.json +2 -1
- package/lib/user-management/interfaces/refresh-and-seal-session-data.interface.d.ts +12 -2
- package/lib/user-management/interfaces/user.interface.d.ts +2 -0
- package/lib/user-management/serializers/role.serializer.js +3 -0
- package/lib/user-management/serializers/user.serializer.js +1 -0
- package/lib/user-management/session.d.ts +2 -2
- package/lib/user-management/session.js +10 -0
- package/lib/user-management/session.spec.js +14 -5
- package/lib/user-management/user-management.spec.js +1 -0
- package/lib/workos.js +1 -1
- package/package.json +1 -1
package/lib/fga/fga.spec.js
CHANGED
|
@@ -24,6 +24,7 @@ describe('FGA', () => {
|
|
|
24
24
|
(0, test_utils_1.fetchOnce)({
|
|
25
25
|
result: 'authorized',
|
|
26
26
|
is_implicit: false,
|
|
27
|
+
warrant_token: 'abc',
|
|
27
28
|
});
|
|
28
29
|
const checkResult = yield workos.fga.check({
|
|
29
30
|
checks: [
|
|
@@ -44,6 +45,7 @@ describe('FGA', () => {
|
|
|
44
45
|
expect(checkResult).toMatchObject({
|
|
45
46
|
result: 'authorized',
|
|
46
47
|
isImplicit: false,
|
|
48
|
+
warrantToken: 'abc',
|
|
47
49
|
});
|
|
48
50
|
}));
|
|
49
51
|
});
|
|
@@ -37,6 +37,7 @@ export interface SerializedCheckBatchOptions {
|
|
|
37
37
|
export interface CheckResultResponse {
|
|
38
38
|
result: string;
|
|
39
39
|
is_implicit: boolean;
|
|
40
|
+
warrant_token: string;
|
|
40
41
|
debug_info?: DebugInfoResponse;
|
|
41
42
|
}
|
|
42
43
|
export interface DebugInfo {
|
|
@@ -64,11 +65,13 @@ export interface DecisionTreeNodeResponse {
|
|
|
64
65
|
export interface CheckResultInterface {
|
|
65
66
|
result: string;
|
|
66
67
|
isImplicit: boolean;
|
|
68
|
+
warrantToken: string;
|
|
67
69
|
debugInfo?: DebugInfo;
|
|
68
70
|
}
|
|
69
71
|
export declare class CheckResult implements CheckResultInterface {
|
|
70
72
|
result: string;
|
|
71
73
|
isImplicit: boolean;
|
|
74
|
+
warrantToken: string;
|
|
72
75
|
debugInfo?: DebugInfo;
|
|
73
76
|
constructor(json: CheckResultResponse);
|
|
74
77
|
isAuthorized(): boolean;
|
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
"name": "Admin",
|
|
8
8
|
"slug": "admin",
|
|
9
9
|
"description": null,
|
|
10
|
+
"permissions": [
|
|
11
|
+
"posts:create",
|
|
12
|
+
"posts:delete"
|
|
13
|
+
],
|
|
10
14
|
"type": "EnvironmentRole",
|
|
11
15
|
"created_at": "2024-01-01T00:00:00.000Z",
|
|
12
16
|
"updated_at": "2024-01-01T00:00:00.000Z"
|
|
@@ -17,6 +21,7 @@
|
|
|
17
21
|
"name": "Member",
|
|
18
22
|
"slug": "member",
|
|
19
23
|
"description": null,
|
|
24
|
+
"permissions": [],
|
|
20
25
|
"type": "EnvironmentRole",
|
|
21
26
|
"created_at": "2024-01-01T00:00:00.000Z",
|
|
22
27
|
"updated_at": "2024-01-01T00:00:00.000Z"
|
|
@@ -27,6 +32,9 @@
|
|
|
27
32
|
"name": "OrganizationMember",
|
|
28
33
|
"slug": "org-member",
|
|
29
34
|
"description": null,
|
|
35
|
+
"permissions": [
|
|
36
|
+
"posts:read"
|
|
37
|
+
],
|
|
30
38
|
"type": "OrganizationRole",
|
|
31
39
|
"created_at": "2024-01-01T00:00:00.000Z",
|
|
32
40
|
"updated_at": "2024-01-01T00:00:00.000Z"
|
|
@@ -285,6 +285,41 @@ describe('Organizations', () => {
|
|
|
285
285
|
expect((0, test_utils_1.fetchURL)()).toContain('/organizations/org_01EHT88Z8J8795GZNQ4ZP1J81T/roles');
|
|
286
286
|
expect(object).toEqual('list');
|
|
287
287
|
expect(data).toHaveLength(3);
|
|
288
|
+
expect(data).toEqual([
|
|
289
|
+
{
|
|
290
|
+
object: 'role',
|
|
291
|
+
id: 'role_01EHQMYV6MBK39QC5PZXHY59C5',
|
|
292
|
+
name: 'Admin',
|
|
293
|
+
slug: 'admin',
|
|
294
|
+
description: null,
|
|
295
|
+
permissions: ['posts:create', 'posts:delete'],
|
|
296
|
+
type: 'EnvironmentRole',
|
|
297
|
+
createdAt: '2024-01-01T00:00:00.000Z',
|
|
298
|
+
updatedAt: '2024-01-01T00:00:00.000Z',
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
object: 'role',
|
|
302
|
+
id: 'role_01EHQMYV6MBK39QC5PZXHY59C3',
|
|
303
|
+
name: 'Member',
|
|
304
|
+
slug: 'member',
|
|
305
|
+
description: null,
|
|
306
|
+
permissions: [],
|
|
307
|
+
type: 'EnvironmentRole',
|
|
308
|
+
createdAt: '2024-01-01T00:00:00.000Z',
|
|
309
|
+
updatedAt: '2024-01-01T00:00:00.000Z',
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
object: 'role',
|
|
313
|
+
id: 'role_01EHQMYV6MBK39QC5PZXHY59C3',
|
|
314
|
+
name: 'OrganizationMember',
|
|
315
|
+
slug: 'org-member',
|
|
316
|
+
description: null,
|
|
317
|
+
permissions: ['posts:read'],
|
|
318
|
+
type: 'OrganizationRole',
|
|
319
|
+
createdAt: '2024-01-01T00:00:00.000Z',
|
|
320
|
+
updatedAt: '2024-01-01T00:00:00.000Z',
|
|
321
|
+
},
|
|
322
|
+
]);
|
|
288
323
|
}));
|
|
289
324
|
});
|
|
290
325
|
});
|
|
@@ -4,10 +4,16 @@ export interface RoleResponse {
|
|
|
4
4
|
export interface RoleEvent {
|
|
5
5
|
object: 'role';
|
|
6
6
|
slug: string;
|
|
7
|
+
permissions: string[];
|
|
8
|
+
createdAt: string;
|
|
9
|
+
updatedAt: string;
|
|
7
10
|
}
|
|
8
11
|
export interface RoleEventResponse {
|
|
9
12
|
object: 'role';
|
|
10
13
|
slug: string;
|
|
14
|
+
permissions: string[];
|
|
15
|
+
created_at: string;
|
|
16
|
+
updated_at: string;
|
|
11
17
|
}
|
|
12
18
|
export interface ListOrganizationRolesResponse {
|
|
13
19
|
object: 'list';
|
|
@@ -19,6 +25,7 @@ export interface OrganizationRoleResponse {
|
|
|
19
25
|
name: string;
|
|
20
26
|
slug: string;
|
|
21
27
|
description: string | null;
|
|
28
|
+
permissions: string[];
|
|
22
29
|
type: 'EnvironmentRole' | 'OrganizationRole';
|
|
23
30
|
created_at: string;
|
|
24
31
|
updated_at: string;
|
|
@@ -29,6 +36,7 @@ export interface Role {
|
|
|
29
36
|
name: string;
|
|
30
37
|
slug: string;
|
|
31
38
|
description: string | null;
|
|
39
|
+
permissions: string[];
|
|
32
40
|
type: 'EnvironmentRole' | 'OrganizationRole';
|
|
33
41
|
createdAt: string;
|
|
34
42
|
updatedAt: string;
|
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
"last_name": "User",
|
|
10
10
|
"created_at": "2023-07-18T02:07:19.911Z",
|
|
11
11
|
"updated_at": "2023-07-18T02:07:19.911Z",
|
|
12
|
-
"
|
|
12
|
+
"email_verified": true,
|
|
13
|
+
"profile_picture_url": "https://example.com/profile_picture.jpg",
|
|
14
|
+
"last_sign_in_at": "2023-07-18T02:07:19.911Z"
|
|
13
15
|
}
|
|
14
16
|
],
|
|
15
17
|
"list_metadata": {
|
|
@@ -7,5 +7,6 @@
|
|
|
7
7
|
"created_at": "2023-07-18T02:07:19.911Z",
|
|
8
8
|
"updated_at": "2023-07-18T02:07:19.911Z",
|
|
9
9
|
"email_verified": true,
|
|
10
|
-
"profile_picture_url": "https://example.com/profile_picture.jpg"
|
|
10
|
+
"profile_picture_url": "https://example.com/profile_picture.jpg",
|
|
11
|
+
"last_sign_in_at": "2023-07-18T02:07:19.911Z"
|
|
11
12
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AuthenticateWithSessionCookieSuccessResponse } from './authenticate-with-session-cookie.interface';
|
|
1
2
|
import { AuthenticationResponse } from './authentication-response.interface';
|
|
2
3
|
export declare enum RefreshAndSealSessionDataFailureReason {
|
|
3
4
|
/**
|
|
@@ -14,14 +15,23 @@ export declare enum RefreshAndSealSessionDataFailureReason {
|
|
|
14
15
|
*/
|
|
15
16
|
ORGANIZATION_NOT_AUTHORIZED = "organization_not_authorized"
|
|
16
17
|
}
|
|
17
|
-
type
|
|
18
|
+
type RefreshSessionFailedResponse = {
|
|
18
19
|
authenticated: false;
|
|
19
20
|
reason: RefreshAndSealSessionDataFailureReason;
|
|
20
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated To be removed in a future major version along with `refreshAndSealSessionData`.
|
|
24
|
+
*/
|
|
21
25
|
type RefreshAndSealSessionDataSuccessResponse = {
|
|
22
26
|
authenticated: true;
|
|
23
27
|
session?: AuthenticationResponse;
|
|
24
28
|
sealedSession?: string;
|
|
25
29
|
};
|
|
26
|
-
export type RefreshAndSealSessionDataResponse =
|
|
30
|
+
export type RefreshAndSealSessionDataResponse = RefreshSessionFailedResponse | RefreshAndSealSessionDataSuccessResponse;
|
|
31
|
+
type RefreshSessionSuccessResponse = Omit<AuthenticateWithSessionCookieSuccessResponse, 'accessToken'> & {
|
|
32
|
+
authenticated: true;
|
|
33
|
+
session?: AuthenticationResponse;
|
|
34
|
+
sealedSession?: string;
|
|
35
|
+
};
|
|
36
|
+
export type RefreshSessionResponse = RefreshSessionFailedResponse | RefreshSessionSuccessResponse;
|
|
27
37
|
export {};
|
|
@@ -6,6 +6,7 @@ export interface User {
|
|
|
6
6
|
profilePictureUrl: string | null;
|
|
7
7
|
firstName: string | null;
|
|
8
8
|
lastName: string | null;
|
|
9
|
+
lastSignInAt: string | null;
|
|
9
10
|
createdAt: string;
|
|
10
11
|
updatedAt: string;
|
|
11
12
|
}
|
|
@@ -17,6 +18,7 @@ export interface UserResponse {
|
|
|
17
18
|
profile_picture_url: string | null;
|
|
18
19
|
first_name: string | null;
|
|
19
20
|
last_name: string | null;
|
|
21
|
+
last_sign_in_at: string | null;
|
|
20
22
|
created_at: string;
|
|
21
23
|
updated_at: string;
|
|
22
24
|
}
|
|
@@ -4,5 +4,8 @@ exports.deserializeRoleEvent = void 0;
|
|
|
4
4
|
const deserializeRoleEvent = (role) => ({
|
|
5
5
|
object: 'role',
|
|
6
6
|
slug: role.slug,
|
|
7
|
+
permissions: role.permissions,
|
|
8
|
+
createdAt: role.created_at,
|
|
9
|
+
updatedAt: role.updated_at,
|
|
7
10
|
});
|
|
8
11
|
exports.deserializeRoleEvent = deserializeRoleEvent;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { AuthenticateWithSessionCookieFailedResponse, AuthenticateWithSessionCookieSuccessResponse, RefreshSessionResponse } from './interfaces';
|
|
1
2
|
import { UserManagement } from './user-management';
|
|
2
|
-
import { AuthenticateWithSessionCookieFailedResponse, AuthenticateWithSessionCookieSuccessResponse, RefreshAndSealSessionDataResponse } from './interfaces';
|
|
3
3
|
type RefreshOptions = {
|
|
4
4
|
cookiePassword?: string;
|
|
5
5
|
organizationId?: string;
|
|
@@ -25,7 +25,7 @@ export declare class Session {
|
|
|
25
25
|
* @param options.organizationId - The organization ID to use for the new session cookie.
|
|
26
26
|
* @returns An object indicating whether the refresh was successful or not. If successful, it will include the new sealed session data.
|
|
27
27
|
*/
|
|
28
|
-
refresh(options?: RefreshOptions): Promise<
|
|
28
|
+
refresh(options?: RefreshOptions): Promise<RefreshSessionResponse>;
|
|
29
29
|
/**
|
|
30
30
|
* Gets the URL to redirect the user to for logging out.
|
|
31
31
|
*
|
|
@@ -116,10 +116,20 @@ class Session {
|
|
|
116
116
|
this.cookiePassword = options.cookiePassword;
|
|
117
117
|
}
|
|
118
118
|
this.sessionData = authenticationResponse.sealedSession;
|
|
119
|
+
const { sid: sessionId, org_id: organizationId, role, permissions, entitlements, } = (0, jose_1.decodeJwt)(authenticationResponse.accessToken);
|
|
120
|
+
// TODO: Returning `session` here means there's some duplicated data.
|
|
121
|
+
// Slim down the return type in a future major version.
|
|
119
122
|
return {
|
|
120
123
|
authenticated: true,
|
|
121
124
|
sealedSession: authenticationResponse.sealedSession,
|
|
122
125
|
session: authenticationResponse,
|
|
126
|
+
sessionId,
|
|
127
|
+
organizationId,
|
|
128
|
+
role,
|
|
129
|
+
permissions,
|
|
130
|
+
entitlements,
|
|
131
|
+
user: session.user,
|
|
132
|
+
impersonator: session.impersonator,
|
|
123
133
|
};
|
|
124
134
|
}
|
|
125
135
|
catch (error) {
|
|
@@ -200,11 +200,11 @@ describe('Session', () => {
|
|
|
200
200
|
const response = yield session.refresh();
|
|
201
201
|
expect(response).toEqual({
|
|
202
202
|
authenticated: true,
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
203
|
+
impersonator: {
|
|
204
|
+
email: 'admin@example.com',
|
|
205
|
+
reason: 'test',
|
|
206
|
+
},
|
|
207
|
+
organizationId: 'org_123',
|
|
208
208
|
sealedSession: expect.any(String),
|
|
209
209
|
session: expect.objectContaining({
|
|
210
210
|
sealedSession: expect.any(String),
|
|
@@ -212,6 +212,15 @@ describe('Session', () => {
|
|
|
212
212
|
email: 'test01@example.com',
|
|
213
213
|
}),
|
|
214
214
|
}),
|
|
215
|
+
entitlements: undefined,
|
|
216
|
+
permissions: ['posts:create', 'posts:delete'],
|
|
217
|
+
role: 'member',
|
|
218
|
+
sessionId: 'session_123',
|
|
219
|
+
user: expect.objectContaining({
|
|
220
|
+
email: 'test01@example.com',
|
|
221
|
+
id: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
222
|
+
object: 'user',
|
|
223
|
+
}),
|
|
215
224
|
});
|
|
216
225
|
}));
|
|
217
226
|
it('overwrites the cookie password if a new one is provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
package/lib/workos.js
CHANGED
|
@@ -29,7 +29,7 @@ const subtle_crypto_provider_1 = require("./common/crypto/subtle-crypto-provider
|
|
|
29
29
|
const fetch_client_1 = require("./common/net/fetch-client");
|
|
30
30
|
const widgets_1 = require("./widgets/widgets");
|
|
31
31
|
const actions_1 = require("./actions/actions");
|
|
32
|
-
const VERSION = '7.
|
|
32
|
+
const VERSION = '7.39.0';
|
|
33
33
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
34
34
|
const HEADER_AUTHORIZATION = 'Authorization';
|
|
35
35
|
const HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
|
package/package.json
CHANGED