@workos-inc/node 7.54.0 → 7.56.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/common/interfaces/event.interface.d.ts +10 -2
- package/lib/common/serializers/event.serializer.js +1 -0
- package/lib/user-management/interfaces/authenticate-with-session-cookie.interface.d.ts +2 -0
- package/lib/user-management/session.js +4 -2
- package/lib/user-management/session.spec.js +2 -1
- package/lib/user-management/user-management.js +2 -1
- package/lib/user-management/user-management.spec.js +2 -1
- package/lib/workos.js +1 -1
- package/package.json +1 -1
|
@@ -402,6 +402,14 @@ export interface SessionCreatedEventResponse extends EventResponseBase {
|
|
|
402
402
|
event: 'session.created';
|
|
403
403
|
data: SessionResponse;
|
|
404
404
|
}
|
|
405
|
+
export interface SessionRevokedEvent extends EventBase {
|
|
406
|
+
event: 'session.revoked';
|
|
407
|
+
data: Session;
|
|
408
|
+
}
|
|
409
|
+
export interface SessionRevokedEventResponse extends EventResponseBase {
|
|
410
|
+
event: 'session.revoked';
|
|
411
|
+
data: SessionResponse;
|
|
412
|
+
}
|
|
405
413
|
export interface OrganizationDomainVerifiedEvent extends EventBase {
|
|
406
414
|
event: 'organization_domain.verified';
|
|
407
415
|
data: OrganizationDomain;
|
|
@@ -418,7 +426,7 @@ export interface OrganizationDomainVerificationFailedEventResponse extends Event
|
|
|
418
426
|
event: 'organization_domain.verification_failed';
|
|
419
427
|
data: OrganizationDomainResponse;
|
|
420
428
|
}
|
|
421
|
-
export type Event = AuthenticationEmailVerificationSucceededEvent | AuthenticationMfaSucceededEvent | AuthenticationOAuthFailedEvent | AuthenticationOAuthSucceededEvent | AuthenticationSSOFailedEvent | AuthenticationSSOSucceededEvent | AuthenticationPasswordFailedEvent | AuthenticationPasswordSucceededEvent | AuthenticationMagicAuthFailedEvent | AuthenticationMagicAuthSucceededEvent | AuthenticationRadarRiskDetectedEvent | ConnectionActivatedEvent | ConnectionDeactivatedEvent | ConnectionDeletedEvent | DsyncActivatedEvent | DsyncDeactivatedEvent | DsyncDeletedEvent | DsyncGroupCreatedEvent | DsyncGroupUpdatedEvent | DsyncGroupDeletedEvent | DsyncGroupUserAddedEvent | DsyncGroupUserRemovedEvent | DsyncUserCreatedEvent | DsyncUserUpdatedEvent | DsyncUserDeletedEvent | EmailVerificationCreatedEvent | InvitationCreatedEvent | MagicAuthCreatedEvent | PasswordResetCreatedEvent | PasswordResetSucceededEvent | UserCreatedEvent | UserUpdatedEvent | UserDeletedEvent | OrganizationMembershipAdded | OrganizationMembershipCreated | OrganizationMembershipDeleted | OrganizationMembershipUpdated | OrganizationMembershipRemoved | RoleCreatedEvent | RoleDeletedEvent | RoleUpdatedEvent | SessionCreatedEvent | OrganizationCreatedEvent | OrganizationUpdatedEvent | OrganizationDeletedEvent | OrganizationDomainVerifiedEvent | OrganizationDomainVerificationFailedEvent;
|
|
422
|
-
export type EventResponse = AuthenticationEmailVerificationSucceededEventResponse | AuthenticationMagicAuthFailedEventResponse | AuthenticationMagicAuthSucceededEventResponse | AuthenticationMfaSucceededEventResponse | AuthenticationOAuthFailedEventResponse | AuthenticationOAuthSucceededEventResponse | AuthenticationPasswordFailedEventResponse | AuthenticationPasswordSucceededEventResponse | AuthenticationSSOFailedEventResponse | AuthenticationSSOSucceededEventResponse | AuthenticationRadarRiskDetectedEventResponse | ConnectionActivatedEventResponse | ConnectionDeactivatedEventResponse | ConnectionDeletedEventResponse | DsyncActivatedEventResponse | DsyncDeactivatedEventResponse | DsyncDeletedEventResponse | DsyncGroupCreatedEventResponse | DsyncGroupUpdatedEventResponse | DsyncGroupDeletedEventResponse | DsyncGroupUserAddedEventResponse | DsyncGroupUserRemovedEventResponse | DsyncUserCreatedEventResponse | DsyncUserUpdatedEventResponse | DsyncUserDeletedEventResponse | EmailVerificationCreatedEventResponse | InvitationCreatedEventResponse | MagicAuthCreatedEventResponse | PasswordResetCreatedEventResponse | PasswordResetSucceededEventResponse | UserCreatedEventResponse | UserUpdatedEventResponse | UserDeletedEventResponse | OrganizationMembershipAddedResponse | OrganizationMembershipCreatedResponse | OrganizationMembershipDeletedResponse | OrganizationMembershipUpdatedResponse | OrganizationMembershipRemovedResponse | RoleCreatedEventResponse | RoleDeletedEventResponse | RoleUpdatedEventResponse | SessionCreatedEventResponse | OrganizationCreatedResponse | OrganizationUpdatedResponse | OrganizationDeletedResponse | OrganizationDomainVerifiedEventResponse | OrganizationDomainVerificationFailedEventResponse;
|
|
429
|
+
export type Event = AuthenticationEmailVerificationSucceededEvent | AuthenticationMfaSucceededEvent | AuthenticationOAuthFailedEvent | AuthenticationOAuthSucceededEvent | AuthenticationSSOFailedEvent | AuthenticationSSOSucceededEvent | AuthenticationPasswordFailedEvent | AuthenticationPasswordSucceededEvent | AuthenticationMagicAuthFailedEvent | AuthenticationMagicAuthSucceededEvent | AuthenticationRadarRiskDetectedEvent | ConnectionActivatedEvent | ConnectionDeactivatedEvent | ConnectionDeletedEvent | DsyncActivatedEvent | DsyncDeactivatedEvent | DsyncDeletedEvent | DsyncGroupCreatedEvent | DsyncGroupUpdatedEvent | DsyncGroupDeletedEvent | DsyncGroupUserAddedEvent | DsyncGroupUserRemovedEvent | DsyncUserCreatedEvent | DsyncUserUpdatedEvent | DsyncUserDeletedEvent | EmailVerificationCreatedEvent | InvitationCreatedEvent | MagicAuthCreatedEvent | PasswordResetCreatedEvent | PasswordResetSucceededEvent | UserCreatedEvent | UserUpdatedEvent | UserDeletedEvent | OrganizationMembershipAdded | OrganizationMembershipCreated | OrganizationMembershipDeleted | OrganizationMembershipUpdated | OrganizationMembershipRemoved | RoleCreatedEvent | RoleDeletedEvent | RoleUpdatedEvent | SessionCreatedEvent | SessionRevokedEvent | OrganizationCreatedEvent | OrganizationUpdatedEvent | OrganizationDeletedEvent | OrganizationDomainVerifiedEvent | OrganizationDomainVerificationFailedEvent;
|
|
430
|
+
export type EventResponse = AuthenticationEmailVerificationSucceededEventResponse | AuthenticationMagicAuthFailedEventResponse | AuthenticationMagicAuthSucceededEventResponse | AuthenticationMfaSucceededEventResponse | AuthenticationOAuthFailedEventResponse | AuthenticationOAuthSucceededEventResponse | AuthenticationPasswordFailedEventResponse | AuthenticationPasswordSucceededEventResponse | AuthenticationSSOFailedEventResponse | AuthenticationSSOSucceededEventResponse | AuthenticationRadarRiskDetectedEventResponse | ConnectionActivatedEventResponse | ConnectionDeactivatedEventResponse | ConnectionDeletedEventResponse | DsyncActivatedEventResponse | DsyncDeactivatedEventResponse | DsyncDeletedEventResponse | DsyncGroupCreatedEventResponse | DsyncGroupUpdatedEventResponse | DsyncGroupDeletedEventResponse | DsyncGroupUserAddedEventResponse | DsyncGroupUserRemovedEventResponse | DsyncUserCreatedEventResponse | DsyncUserUpdatedEventResponse | DsyncUserDeletedEventResponse | EmailVerificationCreatedEventResponse | InvitationCreatedEventResponse | MagicAuthCreatedEventResponse | PasswordResetCreatedEventResponse | PasswordResetSucceededEventResponse | UserCreatedEventResponse | UserUpdatedEventResponse | UserDeletedEventResponse | OrganizationMembershipAddedResponse | OrganizationMembershipCreatedResponse | OrganizationMembershipDeletedResponse | OrganizationMembershipUpdatedResponse | OrganizationMembershipRemovedResponse | RoleCreatedEventResponse | RoleDeletedEventResponse | RoleUpdatedEventResponse | SessionCreatedEventResponse | SessionRevokedEventResponse | OrganizationCreatedResponse | OrganizationUpdatedResponse | OrganizationDeletedResponse | OrganizationDomainVerifiedEventResponse | OrganizationDomainVerificationFailedEventResponse;
|
|
423
431
|
export type EventName = Event['event'];
|
|
424
432
|
export {};
|
|
@@ -79,6 +79,7 @@ const deserializeEvent = (event) => {
|
|
|
79
79
|
case 'role.updated':
|
|
80
80
|
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, role_serializer_1.deserializeRoleEvent)(event.data) });
|
|
81
81
|
case 'session.created':
|
|
82
|
+
case 'session.revoked':
|
|
82
83
|
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, session_serializer_1.deserializeSession)(event.data) });
|
|
83
84
|
case 'organization.created':
|
|
84
85
|
case 'organization.updated':
|
|
@@ -11,6 +11,7 @@ export interface AccessToken {
|
|
|
11
11
|
role?: string;
|
|
12
12
|
permissions?: string[];
|
|
13
13
|
entitlements?: string[];
|
|
14
|
+
feature_flags?: string[];
|
|
14
15
|
}
|
|
15
16
|
export type SessionCookieData = Pick<AuthenticationResponse, 'accessToken' | 'impersonator' | 'organizationId' | 'refreshToken' | 'user'>;
|
|
16
17
|
export declare enum AuthenticateWithSessionCookieFailureReason {
|
|
@@ -29,6 +30,7 @@ export type AuthenticateWithSessionCookieSuccessResponse = {
|
|
|
29
30
|
role?: string;
|
|
30
31
|
permissions?: string[];
|
|
31
32
|
entitlements?: string[];
|
|
33
|
+
featureFlags?: string[];
|
|
32
34
|
user: User;
|
|
33
35
|
impersonator?: Impersonator;
|
|
34
36
|
accessToken: string;
|
|
@@ -61,7 +61,7 @@ class Session {
|
|
|
61
61
|
reason: interfaces_1.AuthenticateWithSessionCookieFailureReason.INVALID_JWT,
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
const { sid: sessionId, org_id: organizationId, role, permissions, entitlements, } = (0, jose_1.decodeJwt)(session.accessToken);
|
|
64
|
+
const { sid: sessionId, org_id: organizationId, role, permissions, entitlements, feature_flags: featureFlags, } = (0, jose_1.decodeJwt)(session.accessToken);
|
|
65
65
|
return {
|
|
66
66
|
authenticated: true,
|
|
67
67
|
sessionId,
|
|
@@ -69,6 +69,7 @@ class Session {
|
|
|
69
69
|
role,
|
|
70
70
|
permissions,
|
|
71
71
|
entitlements,
|
|
72
|
+
featureFlags,
|
|
72
73
|
user: session.user,
|
|
73
74
|
impersonator: session.impersonator,
|
|
74
75
|
accessToken: session.accessToken,
|
|
@@ -113,7 +114,7 @@ class Session {
|
|
|
113
114
|
this.cookiePassword = options.cookiePassword;
|
|
114
115
|
}
|
|
115
116
|
this.sessionData = authenticationResponse.sealedSession;
|
|
116
|
-
const { sid: sessionId, org_id: organizationId, role, permissions, entitlements, } = (0, jose_1.decodeJwt)(authenticationResponse.accessToken);
|
|
117
|
+
const { sid: sessionId, org_id: organizationId, role, permissions, entitlements, feature_flags: featureFlags, } = (0, jose_1.decodeJwt)(authenticationResponse.accessToken);
|
|
117
118
|
// TODO: Returning `session` here means there's some duplicated data.
|
|
118
119
|
// Slim down the return type in a future major version.
|
|
119
120
|
return {
|
|
@@ -125,6 +126,7 @@ class Session {
|
|
|
125
126
|
role,
|
|
126
127
|
permissions,
|
|
127
128
|
entitlements,
|
|
129
|
+
featureFlags,
|
|
128
130
|
user: session.user,
|
|
129
131
|
impersonator: session.impersonator,
|
|
130
132
|
};
|
|
@@ -119,7 +119,7 @@ describe('Session', () => {
|
|
|
119
119
|
.spyOn(jose, 'jwtVerify')
|
|
120
120
|
.mockResolvedValue({});
|
|
121
121
|
const cookiePassword = 'alongcookiesecretmadefortestingsessions';
|
|
122
|
-
const accessToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.
|
|
122
|
+
const accessToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdXRoZW50aWNhdGVkIjp0cnVlLCJpbXBlcnNvbmF0b3IiOnsiZW1haWwiOiJhZG1pbkBleGFtcGxlLmNvbSIsInJlYXNvbiI6InRlc3QifSwic2lkIjoic2Vzc2lvbl8xMjMiLCJvcmdfaWQiOiJvcmdfMTIzIiwicm9sZSI6Im1lbWJlciIsInBlcm1pc3Npb25zIjpbInBvc3RzOmNyZWF0ZSIsInBvc3RzOmRlbGV0ZSJdLCJlbnRpdGxlbWVudHMiOlsiYXVkaXQtbG9ncyJdLCJmZWF0dXJlX2ZsYWdzIjpbImRhcmstbW9kZSIsImJldGEtZmVhdHVyZXMiXSwidXNlciI6eyJvYmplY3QiOiJ1c2VyIiwiaWQiOiJ1c2VyXzAxSDVKUURWN1I3QVRFWVpERUcwVzVQUllTIiwiZW1haWwiOiJ0ZXN0QGV4YW1wbGUuY29tIn19.YVNjR8S2xGn2jAoLuEcBQNJ1_xY3OzjRE1-BK0zjfQE';
|
|
123
123
|
const sessionData = yield (0, iron_session_1.sealData)({
|
|
124
124
|
accessToken,
|
|
125
125
|
refreshToken: 'def456',
|
|
@@ -148,6 +148,7 @@ describe('Session', () => {
|
|
|
148
148
|
role: 'member',
|
|
149
149
|
permissions: ['posts:create', 'posts:delete'],
|
|
150
150
|
entitlements: ['audit-logs'],
|
|
151
|
+
featureFlags: ['dark-mode', 'beta-features'],
|
|
151
152
|
user: {
|
|
152
153
|
object: 'user',
|
|
153
154
|
id: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
@@ -210,7 +210,7 @@ class UserManagement {
|
|
|
210
210
|
reason: authenticate_with_session_cookie_interface_1.AuthenticateWithSessionCookieFailureReason.INVALID_JWT,
|
|
211
211
|
};
|
|
212
212
|
}
|
|
213
|
-
const { sid: sessionId, org_id: organizationId, role, permissions, entitlements, } = (0, jose_1.decodeJwt)(session.accessToken);
|
|
213
|
+
const { sid: sessionId, org_id: organizationId, role, permissions, entitlements, feature_flags: featureFlags, } = (0, jose_1.decodeJwt)(session.accessToken);
|
|
214
214
|
return {
|
|
215
215
|
authenticated: true,
|
|
216
216
|
sessionId,
|
|
@@ -219,6 +219,7 @@ class UserManagement {
|
|
|
219
219
|
user: session.user,
|
|
220
220
|
permissions,
|
|
221
221
|
entitlements,
|
|
222
|
+
featureFlags,
|
|
222
223
|
accessToken: session.accessToken,
|
|
223
224
|
};
|
|
224
225
|
});
|
|
@@ -777,7 +777,7 @@ describe('UserManagement', () => {
|
|
|
777
777
|
.spyOn(jose, 'jwtVerify')
|
|
778
778
|
.mockResolvedValue({});
|
|
779
779
|
const cookiePassword = 'alongcookiesecretmadefortestingsessions';
|
|
780
|
-
const accessToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.
|
|
780
|
+
const accessToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdXRoZW50aWNhdGVkIjp0cnVlLCJpbXBlcnNvbmF0b3IiOnsiZW1haWwiOiJhZG1pbkBleGFtcGxlLmNvbSIsInJlYXNvbiI6InRlc3QifSwic2lkIjoic2Vzc2lvbl8xMjMiLCJvcmdfaWQiOiJvcmdfMTIzIiwicm9sZSI6Im1lbWJlciIsInBlcm1pc3Npb25zIjpbInBvc3RzOmNyZWF0ZSIsInBvc3RzOmRlbGV0ZSJdLCJlbnRpdGxlbWVudHMiOlsiYXVkaXQtbG9ncyJdLCJmZWF0dXJlX2ZsYWdzIjpbImRhcmstbW9kZSIsImJldGEtZmVhdHVyZXMiXSwidXNlciI6eyJvYmplY3QiOiJ1c2VyIiwiaWQiOiJ1c2VyXzAxSDVKUURWN1I3QVRFWVpERUcwVzVQUllTIiwiZW1haWwiOiJ0ZXN0QGV4YW1wbGUuY29tIn19.YVNjR8S2xGn2jAoLuEcBQNJ1_xY3OzjRE1-BK0zjfQE';
|
|
781
781
|
const sessionData = yield (0, iron_session_1.sealData)({
|
|
782
782
|
accessToken,
|
|
783
783
|
refreshToken: 'def456',
|
|
@@ -797,6 +797,7 @@ describe('UserManagement', () => {
|
|
|
797
797
|
role: 'member',
|
|
798
798
|
permissions: ['posts:create', 'posts:delete'],
|
|
799
799
|
entitlements: ['audit-logs'],
|
|
800
|
+
featureFlags: ['dark-mode', 'beta-features'],
|
|
800
801
|
user: expect.objectContaining({
|
|
801
802
|
email: 'test@example.com',
|
|
802
803
|
}),
|
package/lib/workos.js
CHANGED
|
@@ -31,7 +31,7 @@ const widgets_1 = require("./widgets/widgets");
|
|
|
31
31
|
const actions_1 = require("./actions/actions");
|
|
32
32
|
const vault_1 = require("./vault/vault");
|
|
33
33
|
const conflict_exception_1 = require("./common/exceptions/conflict.exception");
|
|
34
|
-
const VERSION = '7.
|
|
34
|
+
const VERSION = '7.56.0';
|
|
35
35
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
36
36
|
const HEADER_AUTHORIZATION = 'Authorization';
|
|
37
37
|
const HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
|
package/package.json
CHANGED