@workos-inc/node 7.5.0 → 7.7.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 +20 -4
- package/lib/common/serializers/event.serializer.js +4 -0
- package/lib/directory-sync/directory-sync.spec.js +61 -0
- package/lib/directory-sync/interfaces/directory-user.interface.d.ts +3 -0
- package/lib/directory-sync/serializers/directory-user.serializer.js +2 -0
- package/lib/events/events.spec.js +88 -0
- package/lib/roles/interfaces/index.d.ts +1 -0
- package/lib/roles/interfaces/index.js +17 -0
- package/lib/user-management/fixtures/email_verification.json +10 -0
- package/lib/user-management/fixtures/invitation.json +1 -1
- package/lib/user-management/fixtures/list-invitations.json +1 -1
- package/lib/user-management/fixtures/password_reset.json +10 -0
- package/lib/user-management/interfaces/create-password-reset-options.interface.d.ts +6 -0
- package/lib/user-management/interfaces/create-password-reset-options.interface.js +2 -0
- package/lib/user-management/interfaces/email-verification.interface.d.ts +38 -0
- package/lib/user-management/interfaces/email-verification.interface.js +2 -0
- package/lib/user-management/interfaces/enroll-auth-factor.interface.d.ts +2 -0
- package/lib/user-management/interfaces/index.d.ts +3 -2
- package/lib/user-management/interfaces/index.js +3 -2
- package/lib/user-management/interfaces/organization-membership.interface.d.ts +1 -1
- package/lib/user-management/interfaces/password-reset.interface.d.ts +36 -0
- package/lib/user-management/interfaces/password-reset.interface.js +2 -0
- package/lib/user-management/serializers/create-password-reset-options.serializer.d.ts +2 -0
- package/lib/user-management/serializers/create-password-reset-options.serializer.js +7 -0
- package/lib/user-management/serializers/email-verification.serializer.d.ts +3 -0
- package/lib/user-management/serializers/email-verification.serializer.js +24 -0
- package/lib/user-management/serializers/enroll-auth-factor-options.serializer.js +1 -0
- package/lib/user-management/serializers/index.d.ts +3 -0
- package/lib/user-management/serializers/index.js +3 -0
- package/lib/user-management/serializers/password-reset.serializer.d.ts +3 -0
- package/lib/user-management/serializers/password-reset.serializer.js +23 -0
- package/lib/user-management/serializers/role.serializer.d.ts +1 -1
- package/lib/user-management/user-management.d.ts +7 -1
- package/lib/user-management/user-management.js +21 -0
- package/lib/user-management/user-management.spec.js +58 -0
- package/lib/workos.js +1 -1
- package/package.json +2 -2
- /package/lib/{user-management → roles}/interfaces/role.interface.d.ts +0 -0
- /package/lib/{user-management → roles}/interfaces/role.interface.js +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DirectoryUser, DirectoryUserResponse, DirectoryGroup, DirectoryGroupResponse, EventDirectory, EventDirectoryResponse } from '../../directory-sync/interfaces';
|
|
2
2
|
import { Organization, OrganizationResponse } from '../../organizations/interfaces';
|
|
3
3
|
import { Connection, ConnectionResponse } from '../../sso/interfaces';
|
|
4
|
-
import { InvitationEvent, InvitationEventResponse, MagicAuthEvent, MagicAuthEventResponse, Session, SessionResponse, User, UserResponse } from '../../user-management/interfaces';
|
|
4
|
+
import { EmailVerificationEvent, EmailVerificationEventResponse, InvitationEvent, InvitationEventResponse, MagicAuthEvent, MagicAuthEventResponse, PasswordResetEvent, PasswordResetEventResponse, Session, SessionResponse, User, UserResponse } from '../../user-management/interfaces';
|
|
5
5
|
import { OrganizationMembership, OrganizationMembershipResponse } from '../../user-management/interfaces/organization-membership.interface';
|
|
6
|
-
import { RoleEvent, RoleEventResponse } from '../../
|
|
6
|
+
import { RoleEvent, RoleEventResponse } from '../../roles/interfaces/role.interface';
|
|
7
7
|
export interface EventBase {
|
|
8
8
|
id: string;
|
|
9
9
|
createdAt: string;
|
|
@@ -140,6 +140,14 @@ export interface DsyncUserUpdatedEventResponse extends EventResponseBase {
|
|
|
140
140
|
event: 'dsync.user.updated';
|
|
141
141
|
data: DirectoryUserResponse & Record<'previous_attributes', any>;
|
|
142
142
|
}
|
|
143
|
+
export interface EmailVerificationCreatedEvent extends EventBase {
|
|
144
|
+
event: 'email_verification.created';
|
|
145
|
+
data: EmailVerificationEvent;
|
|
146
|
+
}
|
|
147
|
+
export interface EmailVerificationCreatedEventResponse extends EventResponseBase {
|
|
148
|
+
event: 'email_verification.created';
|
|
149
|
+
data: EmailVerificationEventResponse;
|
|
150
|
+
}
|
|
143
151
|
export interface InvitationCreatedEvent extends EventBase {
|
|
144
152
|
event: 'invitation.created';
|
|
145
153
|
data: InvitationEvent;
|
|
@@ -156,6 +164,14 @@ export interface MagicAuthCreatedEventResponse extends EventResponseBase {
|
|
|
156
164
|
event: 'magic_auth.created';
|
|
157
165
|
data: MagicAuthEventResponse;
|
|
158
166
|
}
|
|
167
|
+
export interface PasswordResetCreatedEvent extends EventBase {
|
|
168
|
+
event: 'password_reset.created';
|
|
169
|
+
data: PasswordResetEvent;
|
|
170
|
+
}
|
|
171
|
+
export interface PasswordResetCreatedEventResponse extends EventResponseBase {
|
|
172
|
+
event: 'password_reset.created';
|
|
173
|
+
data: PasswordResetEventResponse;
|
|
174
|
+
}
|
|
159
175
|
export interface UserCreatedEvent extends EventBase {
|
|
160
176
|
event: 'user.created';
|
|
161
177
|
data: User;
|
|
@@ -280,7 +296,7 @@ export interface SessionCreatedEventResponse extends EventResponseBase {
|
|
|
280
296
|
event: 'session.created';
|
|
281
297
|
data: SessionResponse;
|
|
282
298
|
}
|
|
283
|
-
export type Event = ConnectionActivatedEvent | ConnectionDeactivatedEvent | ConnectionDeletedEvent | DsyncActivatedEvent | DsyncDeactivatedEvent | DsyncDeletedEvent | DsyncGroupCreatedEvent | DsyncGroupUpdatedEvent | DsyncGroupDeletedEvent | DsyncGroupUserAddedEvent | DsyncGroupUserRemovedEvent | DsyncUserCreatedEvent | DsyncUserUpdatedEvent | DsyncUserDeletedEvent | InvitationCreatedEvent | MagicAuthCreatedEvent | UserCreatedEvent | UserUpdatedEvent | UserDeletedEvent | OrganizationMembershipAdded | OrganizationMembershipCreated | OrganizationMembershipDeleted | OrganizationMembershipUpdated | OrganizationMembershipRemoved | RoleCreatedEvent | RoleDeletedEvent | SessionCreatedEvent | OrganizationCreatedEvent | OrganizationUpdatedEvent | OrganizationDeletedEvent;
|
|
284
|
-
export type EventResponse = ConnectionActivatedEventResponse | ConnectionDeactivatedEventResponse | ConnectionDeletedEventResponse | DsyncActivatedEventResponse | DsyncDeactivatedEventResponse | DsyncDeletedEventResponse | DsyncGroupCreatedEventResponse | DsyncGroupUpdatedEventResponse | DsyncGroupDeletedEventResponse | DsyncGroupUserAddedEventResponse | DsyncGroupUserRemovedEventResponse | DsyncUserCreatedEventResponse | DsyncUserUpdatedEventResponse | DsyncUserDeletedEventResponse | InvitationCreatedEventResponse | MagicAuthCreatedEventResponse | UserCreatedEventResponse | UserUpdatedEventResponse | UserDeletedEventResponse | OrganizationMembershipAddedResponse | OrganizationMembershipCreatedResponse | OrganizationMembershipDeletedResponse | OrganizationMembershipUpdatedResponse | OrganizationMembershipRemovedResponse | RoleCreatedEventResponse | RoleDeletedEventResponse | SessionCreatedEventResponse | OrganizationCreatedResponse | OrganizationUpdatedResponse | OrganizationDeletedResponse;
|
|
299
|
+
export type Event = ConnectionActivatedEvent | ConnectionDeactivatedEvent | ConnectionDeletedEvent | DsyncActivatedEvent | DsyncDeactivatedEvent | DsyncDeletedEvent | DsyncGroupCreatedEvent | DsyncGroupUpdatedEvent | DsyncGroupDeletedEvent | DsyncGroupUserAddedEvent | DsyncGroupUserRemovedEvent | DsyncUserCreatedEvent | DsyncUserUpdatedEvent | DsyncUserDeletedEvent | EmailVerificationCreatedEvent | InvitationCreatedEvent | MagicAuthCreatedEvent | PasswordResetCreatedEvent | UserCreatedEvent | UserUpdatedEvent | UserDeletedEvent | OrganizationMembershipAdded | OrganizationMembershipCreated | OrganizationMembershipDeleted | OrganizationMembershipUpdated | OrganizationMembershipRemoved | RoleCreatedEvent | RoleDeletedEvent | SessionCreatedEvent | OrganizationCreatedEvent | OrganizationUpdatedEvent | OrganizationDeletedEvent;
|
|
300
|
+
export type EventResponse = ConnectionActivatedEventResponse | ConnectionDeactivatedEventResponse | ConnectionDeletedEventResponse | DsyncActivatedEventResponse | DsyncDeactivatedEventResponse | DsyncDeletedEventResponse | DsyncGroupCreatedEventResponse | DsyncGroupUpdatedEventResponse | DsyncGroupDeletedEventResponse | DsyncGroupUserAddedEventResponse | DsyncGroupUserRemovedEventResponse | DsyncUserCreatedEventResponse | DsyncUserUpdatedEventResponse | DsyncUserDeletedEventResponse | EmailVerificationCreatedEventResponse | InvitationCreatedEventResponse | MagicAuthCreatedEventResponse | PasswordResetCreatedEventResponse | UserCreatedEventResponse | UserUpdatedEventResponse | UserDeletedEventResponse | OrganizationMembershipAddedResponse | OrganizationMembershipCreatedResponse | OrganizationMembershipDeletedResponse | OrganizationMembershipUpdatedResponse | OrganizationMembershipRemovedResponse | RoleCreatedEventResponse | RoleDeletedEventResponse | SessionCreatedEventResponse | OrganizationCreatedResponse | OrganizationUpdatedResponse | OrganizationDeletedResponse;
|
|
285
301
|
export type EventName = Event['event'];
|
|
286
302
|
export {};
|
|
@@ -40,10 +40,14 @@ const deserializeEvent = (event) => {
|
|
|
40
40
|
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, serializers_1.deserializeDirectoryUser)(event.data) });
|
|
41
41
|
case 'dsync.user.updated':
|
|
42
42
|
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, serializers_1.deserializeUpdatedEventDirectoryUser)(event.data) });
|
|
43
|
+
case 'email_verification.created':
|
|
44
|
+
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, serializers_4.deserializeEmailVerificationEvent)(event.data) });
|
|
43
45
|
case 'invitation.created':
|
|
44
46
|
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, serializers_4.deserializeInvitationEvent)(event.data) });
|
|
45
47
|
case 'magic_auth.created':
|
|
46
48
|
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, serializers_4.deserializeMagicAuthEvent)(event.data) });
|
|
49
|
+
case 'password_reset.created':
|
|
50
|
+
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, serializers_4.deserializePasswordResetEvent)(event.data) });
|
|
47
51
|
case 'user.created':
|
|
48
52
|
case 'user.updated':
|
|
49
53
|
case 'user.deleted':
|
|
@@ -118,6 +118,60 @@ describe('DirectorySync', () => {
|
|
|
118
118
|
created_at: '2021-10-27 15:21:50.640959',
|
|
119
119
|
updated_at: '2021-12-13 12:15:45.531847',
|
|
120
120
|
};
|
|
121
|
+
const userWithRole = {
|
|
122
|
+
object: 'directory_user',
|
|
123
|
+
id: 'directory_user_456',
|
|
124
|
+
customAttributes: {
|
|
125
|
+
custom: true,
|
|
126
|
+
},
|
|
127
|
+
directoryId: 'dir_123',
|
|
128
|
+
organizationId: 'org_123',
|
|
129
|
+
emails: [
|
|
130
|
+
{
|
|
131
|
+
primary: true,
|
|
132
|
+
type: 'type',
|
|
133
|
+
value: 'jonsnow@workos.com',
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
firstName: 'Jon',
|
|
137
|
+
groups: [group],
|
|
138
|
+
idpId: 'idp_foo',
|
|
139
|
+
lastName: 'Snow',
|
|
140
|
+
jobTitle: 'Knight of the Watch',
|
|
141
|
+
rawAttributes: {},
|
|
142
|
+
state: 'active',
|
|
143
|
+
username: 'jonsnow',
|
|
144
|
+
role: { slug: 'super_admin' },
|
|
145
|
+
createdAt: '2021-10-27 15:21:50.640959',
|
|
146
|
+
updatedAt: '2021-12-13 12:15:45.531847',
|
|
147
|
+
};
|
|
148
|
+
const userWithRoleResponse = {
|
|
149
|
+
object: 'directory_user',
|
|
150
|
+
id: 'directory_user_456',
|
|
151
|
+
custom_attributes: {
|
|
152
|
+
custom: true,
|
|
153
|
+
},
|
|
154
|
+
directory_id: 'dir_123',
|
|
155
|
+
organization_id: 'org_123',
|
|
156
|
+
emails: [
|
|
157
|
+
{
|
|
158
|
+
primary: true,
|
|
159
|
+
type: 'type',
|
|
160
|
+
value: 'jonsnow@workos.com',
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
first_name: 'Jon',
|
|
164
|
+
groups: [groupResponse],
|
|
165
|
+
idp_id: 'idp_foo',
|
|
166
|
+
last_name: 'Snow',
|
|
167
|
+
job_title: 'Knight of the Watch',
|
|
168
|
+
raw_attributes: {},
|
|
169
|
+
state: 'active',
|
|
170
|
+
username: 'jonsnow',
|
|
171
|
+
role: { slug: 'super_admin' },
|
|
172
|
+
created_at: '2021-10-27 15:21:50.640959',
|
|
173
|
+
updated_at: '2021-12-13 12:15:45.531847',
|
|
174
|
+
};
|
|
121
175
|
describe('listDirectories', () => {
|
|
122
176
|
describe('with options', () => {
|
|
123
177
|
it('requests Directories with query parameters', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -351,5 +405,12 @@ describe('DirectorySync', () => {
|
|
|
351
405
|
const subject = yield workos.directorySync.getUser('dir_usr_123');
|
|
352
406
|
expect(subject).toEqual(userWithGroup);
|
|
353
407
|
}));
|
|
408
|
+
describe('with a Role', () => {
|
|
409
|
+
it(`requests a Directory User`, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
410
|
+
(0, test_utils_1.fetchOnce)(userWithRoleResponse);
|
|
411
|
+
const subject = yield workos.directorySync.getUser('directory_user_456');
|
|
412
|
+
expect(subject).toEqual(userWithRole);
|
|
413
|
+
}));
|
|
414
|
+
});
|
|
354
415
|
});
|
|
355
416
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RoleResponse } from '../../roles/interfaces/';
|
|
1
2
|
import { DirectoryGroup, DirectoryGroupResponse } from './directory-group.interface';
|
|
2
3
|
export type DefaultCustomAttributes = Record<string, unknown>;
|
|
3
4
|
export interface DirectoryUser<TCustomAttributes extends object = DefaultCustomAttributes, TRawAttributes = any> {
|
|
@@ -18,6 +19,7 @@ export interface DirectoryUser<TCustomAttributes extends object = DefaultCustomA
|
|
|
18
19
|
lastName: string | null;
|
|
19
20
|
jobTitle: string | null;
|
|
20
21
|
state: 'active' | 'inactive';
|
|
22
|
+
role?: RoleResponse;
|
|
21
23
|
createdAt: string;
|
|
22
24
|
updatedAt: string;
|
|
23
25
|
}
|
|
@@ -39,6 +41,7 @@ export interface DirectoryUserResponse<TCustomAttributes extends object = Defaul
|
|
|
39
41
|
last_name: string | null;
|
|
40
42
|
job_title: string | null;
|
|
41
43
|
state: 'active' | 'inactive';
|
|
44
|
+
role?: RoleResponse;
|
|
42
45
|
created_at: string;
|
|
43
46
|
updated_at: string;
|
|
44
47
|
}
|
|
@@ -16,6 +16,7 @@ const deserializeDirectoryUser = (directoryUser) => ({
|
|
|
16
16
|
lastName: directoryUser.last_name,
|
|
17
17
|
jobTitle: directoryUser.job_title,
|
|
18
18
|
state: directoryUser.state,
|
|
19
|
+
role: directoryUser.role,
|
|
19
20
|
createdAt: directoryUser.created_at,
|
|
20
21
|
updatedAt: directoryUser.updated_at,
|
|
21
22
|
});
|
|
@@ -36,6 +37,7 @@ const deserializeUpdatedEventDirectoryUser = (directoryUser) => ({
|
|
|
36
37
|
lastName: directoryUser.last_name,
|
|
37
38
|
jobTitle: directoryUser.job_title,
|
|
38
39
|
state: directoryUser.state,
|
|
40
|
+
role: directoryUser.role,
|
|
39
41
|
createdAt: directoryUser.created_at,
|
|
40
42
|
updatedAt: directoryUser.updated_at,
|
|
41
43
|
previousAttributes: directoryUser.previous_attributes,
|
|
@@ -106,5 +106,93 @@ describe('Event', () => {
|
|
|
106
106
|
listMetadata: {},
|
|
107
107
|
});
|
|
108
108
|
}));
|
|
109
|
+
describe('directory user updated events', () => {
|
|
110
|
+
describe('with a role', () => {
|
|
111
|
+
const directoryUserUpdated = {
|
|
112
|
+
id: 'event_01234ABCD',
|
|
113
|
+
createdAt: '2020-05-06 04:21:48.649164',
|
|
114
|
+
event: 'dsync.user.updated',
|
|
115
|
+
data: {
|
|
116
|
+
object: 'directory_user',
|
|
117
|
+
id: 'directory_user_456',
|
|
118
|
+
customAttributes: {
|
|
119
|
+
custom: true,
|
|
120
|
+
},
|
|
121
|
+
directoryId: 'dir_123',
|
|
122
|
+
organizationId: 'org_123',
|
|
123
|
+
emails: [
|
|
124
|
+
{
|
|
125
|
+
primary: true,
|
|
126
|
+
type: 'type',
|
|
127
|
+
value: 'jonsnow@workos.com',
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
firstName: 'Jon',
|
|
131
|
+
idpId: 'idp_foo',
|
|
132
|
+
lastName: 'Snow',
|
|
133
|
+
jobTitle: 'Knight of the Watch',
|
|
134
|
+
rawAttributes: {},
|
|
135
|
+
state: 'active',
|
|
136
|
+
username: 'jonsnow',
|
|
137
|
+
role: { slug: 'super_admin' },
|
|
138
|
+
previousAttributes: {
|
|
139
|
+
role: { slug: 'member' },
|
|
140
|
+
},
|
|
141
|
+
createdAt: '2021-10-27 15:21:50.640959',
|
|
142
|
+
updatedAt: '2021-12-13 12:15:45.531847',
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
const directoryUserUpdatedResponse = {
|
|
146
|
+
id: 'event_01234ABCD',
|
|
147
|
+
created_at: '2020-05-06 04:21:48.649164',
|
|
148
|
+
event: 'dsync.user.updated',
|
|
149
|
+
data: {
|
|
150
|
+
object: 'directory_user',
|
|
151
|
+
id: 'directory_user_456',
|
|
152
|
+
custom_attributes: {
|
|
153
|
+
custom: true,
|
|
154
|
+
},
|
|
155
|
+
directory_id: 'dir_123',
|
|
156
|
+
organization_id: 'org_123',
|
|
157
|
+
emails: [
|
|
158
|
+
{
|
|
159
|
+
primary: true,
|
|
160
|
+
type: 'type',
|
|
161
|
+
value: 'jonsnow@workos.com',
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
first_name: 'Jon',
|
|
165
|
+
idp_id: 'idp_foo',
|
|
166
|
+
last_name: 'Snow',
|
|
167
|
+
job_title: 'Knight of the Watch',
|
|
168
|
+
raw_attributes: {},
|
|
169
|
+
state: 'active',
|
|
170
|
+
username: 'jonsnow',
|
|
171
|
+
role: { slug: 'super_admin' },
|
|
172
|
+
previous_attributes: {
|
|
173
|
+
role: { slug: 'member' },
|
|
174
|
+
},
|
|
175
|
+
created_at: '2021-10-27 15:21:50.640959',
|
|
176
|
+
updated_at: '2021-12-13 12:15:45.531847',
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
const directoryUserEventsListResponse = {
|
|
180
|
+
object: 'list',
|
|
181
|
+
data: [directoryUserUpdatedResponse],
|
|
182
|
+
list_metadata: {},
|
|
183
|
+
};
|
|
184
|
+
it(`returns the role`, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
185
|
+
(0, test_utils_1.fetchOnce)(directoryUserEventsListResponse);
|
|
186
|
+
const list = yield workos.events.listEvents({
|
|
187
|
+
events: ['dsync.user.updated'],
|
|
188
|
+
});
|
|
189
|
+
expect(list).toEqual({
|
|
190
|
+
object: 'list',
|
|
191
|
+
data: [directoryUserUpdated],
|
|
192
|
+
listMetadata: {},
|
|
193
|
+
});
|
|
194
|
+
}));
|
|
195
|
+
});
|
|
196
|
+
});
|
|
109
197
|
});
|
|
110
198
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './role.interface';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./role.interface"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"object": "email_verification",
|
|
3
|
+
"id": "email_verification_01H5JQDV7R7ATEYZDEG0W5PRYS",
|
|
4
|
+
"user_id": "user_01H5JQDV7R7ATEYZDEG0W5PRYS",
|
|
5
|
+
"email": "dane@workos.com",
|
|
6
|
+
"expires_at": "2023-07-18T02:07:19.911Z",
|
|
7
|
+
"code": "123456",
|
|
8
|
+
"created_at": "2023-07-18T02:07:19.911Z",
|
|
9
|
+
"updated_at": "2023-07-18T02:07:19.911Z"
|
|
10
|
+
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"organization_id": "org_01H5JQDV7R7ATEYZDEG0W5PRYS",
|
|
10
10
|
"inviter_user_id": null,
|
|
11
11
|
"token": "Z1uX3RbwcIl5fIGJJJCXXisdI",
|
|
12
|
-
"accept_invitation_url": "https://
|
|
12
|
+
"accept_invitation_url": "https://your-app.com/invite?invitation_token=Z1uX3RbwcIl5fIGJJJCXXisdI",
|
|
13
13
|
"created_at": "2023-07-18T02:07:19.911Z",
|
|
14
14
|
"updated_at": "2023-07-18T02:07:19.911Z"
|
|
15
15
|
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"organization_id": "org_01H5JQDV7R7ATEYZDEG0W5PRYS",
|
|
13
13
|
"inviter_user_id": null,
|
|
14
14
|
"token": "Z1uX3RbwcIl5fIGJJJCXXisdI",
|
|
15
|
-
"accept_invitation_url": "https://
|
|
15
|
+
"accept_invitation_url": "https://your-app.com/invite?invitation_token=Z1uX3RbwcIl5fIGJJJCXXisdI",
|
|
16
16
|
"created_at": "2023-07-18T02:07:19.911Z",
|
|
17
17
|
"updated_at": "2023-07-18T02:07:19.911Z"
|
|
18
18
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"object": "password_reset",
|
|
3
|
+
"id": "password_reset_01H5JQDV7R7ATEYZDEG0W5PRYS",
|
|
4
|
+
"user_id": "user_01H5JQDV7R7ATEYZDEG0W5PRYS",
|
|
5
|
+
"email": "dane@workos.com",
|
|
6
|
+
"password_reset_token": "Z1uX3RbwcIl5fIGJJJCXXisdI",
|
|
7
|
+
"password_reset_url": "https://your-app.com/reset-password?token=Z1uX3RbwcIl5fIGJJJCXXisdI",
|
|
8
|
+
"expires_at": "2023-07-18T02:07:19.911Z",
|
|
9
|
+
"created_at": "2023-07-18T02:07:19.911Z"
|
|
10
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface EmailVerification {
|
|
2
|
+
object: 'email_verification';
|
|
3
|
+
id: string;
|
|
4
|
+
userId: string;
|
|
5
|
+
email: string;
|
|
6
|
+
expiresAt: string;
|
|
7
|
+
code: string;
|
|
8
|
+
createdAt: string;
|
|
9
|
+
updatedAt: string;
|
|
10
|
+
}
|
|
11
|
+
export interface EmailVerificationEvent {
|
|
12
|
+
object: 'email_verification';
|
|
13
|
+
id: string;
|
|
14
|
+
userId: string;
|
|
15
|
+
email: string;
|
|
16
|
+
expiresAt: string;
|
|
17
|
+
createdAt: string;
|
|
18
|
+
updatedAt: string;
|
|
19
|
+
}
|
|
20
|
+
export interface EmailVerificationResponse {
|
|
21
|
+
object: 'email_verification';
|
|
22
|
+
id: string;
|
|
23
|
+
user_id: string;
|
|
24
|
+
email: string;
|
|
25
|
+
expires_at: string;
|
|
26
|
+
code: string;
|
|
27
|
+
created_at: string;
|
|
28
|
+
updated_at: string;
|
|
29
|
+
}
|
|
30
|
+
export interface EmailVerificationEventResponse {
|
|
31
|
+
object: 'email_verification';
|
|
32
|
+
id: string;
|
|
33
|
+
user_id: string;
|
|
34
|
+
email: string;
|
|
35
|
+
expires_at: string;
|
|
36
|
+
created_at: string;
|
|
37
|
+
updated_at: string;
|
|
38
|
+
}
|
|
@@ -3,9 +3,11 @@ export interface EnrollAuthFactorOptions {
|
|
|
3
3
|
type: 'totp';
|
|
4
4
|
totpIssuer?: string;
|
|
5
5
|
totpUser?: string;
|
|
6
|
+
totpSecret?: string;
|
|
6
7
|
}
|
|
7
8
|
export interface SerializedEnrollUserInMfaFactorOptions {
|
|
8
9
|
type: 'totp';
|
|
9
10
|
totp_issuer?: string;
|
|
10
11
|
totp_user?: string;
|
|
12
|
+
totp_secret?: string;
|
|
11
13
|
}
|
|
@@ -11,7 +11,9 @@ export * from './authenticate-with-totp-options.interface';
|
|
|
11
11
|
export * from './authentication-response.interface';
|
|
12
12
|
export * from './create-magic-auth-options.interface';
|
|
13
13
|
export * from './create-organization-membership-options.interface';
|
|
14
|
+
export * from './create-password-reset-options.interface';
|
|
14
15
|
export * from './create-user-options.interface';
|
|
16
|
+
export * from './email-verification.interface';
|
|
15
17
|
export * from './enroll-auth-factor.interface';
|
|
16
18
|
export * from './factor.interface';
|
|
17
19
|
export * from './impersonator.interface';
|
|
@@ -22,9 +24,9 @@ export * from './list-organization-memberships-options.interface';
|
|
|
22
24
|
export * from './list-users-options.interface';
|
|
23
25
|
export * from './magic-auth.interface';
|
|
24
26
|
export * from './organization-membership.interface';
|
|
27
|
+
export * from './password-reset.interface';
|
|
25
28
|
export * from './reset-password-options.interface';
|
|
26
29
|
export * from './revoke-session-options.interface';
|
|
27
|
-
export * from './role.interface';
|
|
28
30
|
export * from './send-invitation-options.interface';
|
|
29
31
|
export * from './send-magic-auth-code-options.interface';
|
|
30
32
|
export * from './send-password-reset-email-options.interface';
|
|
@@ -35,4 +37,3 @@ export * from './update-user-options.interface';
|
|
|
35
37
|
export * from './update-user-password-options.interface';
|
|
36
38
|
export * from './user.interface';
|
|
37
39
|
export * from './verify-email-options.interface';
|
|
38
|
-
export * from './role.interface';
|
|
@@ -27,7 +27,9 @@ __exportStar(require("./authenticate-with-totp-options.interface"), exports);
|
|
|
27
27
|
__exportStar(require("./authentication-response.interface"), exports);
|
|
28
28
|
__exportStar(require("./create-magic-auth-options.interface"), exports);
|
|
29
29
|
__exportStar(require("./create-organization-membership-options.interface"), exports);
|
|
30
|
+
__exportStar(require("./create-password-reset-options.interface"), exports);
|
|
30
31
|
__exportStar(require("./create-user-options.interface"), exports);
|
|
32
|
+
__exportStar(require("./email-verification.interface"), exports);
|
|
31
33
|
__exportStar(require("./enroll-auth-factor.interface"), exports);
|
|
32
34
|
__exportStar(require("./factor.interface"), exports);
|
|
33
35
|
__exportStar(require("./impersonator.interface"), exports);
|
|
@@ -38,9 +40,9 @@ __exportStar(require("./list-organization-memberships-options.interface"), expor
|
|
|
38
40
|
__exportStar(require("./list-users-options.interface"), exports);
|
|
39
41
|
__exportStar(require("./magic-auth.interface"), exports);
|
|
40
42
|
__exportStar(require("./organization-membership.interface"), exports);
|
|
43
|
+
__exportStar(require("./password-reset.interface"), exports);
|
|
41
44
|
__exportStar(require("./reset-password-options.interface"), exports);
|
|
42
45
|
__exportStar(require("./revoke-session-options.interface"), exports);
|
|
43
|
-
__exportStar(require("./role.interface"), exports);
|
|
44
46
|
__exportStar(require("./send-invitation-options.interface"), exports);
|
|
45
47
|
__exportStar(require("./send-magic-auth-code-options.interface"), exports);
|
|
46
48
|
__exportStar(require("./send-password-reset-email-options.interface"), exports);
|
|
@@ -51,4 +53,3 @@ __exportStar(require("./update-user-options.interface"), exports);
|
|
|
51
53
|
__exportStar(require("./update-user-password-options.interface"), exports);
|
|
52
54
|
__exportStar(require("./user.interface"), exports);
|
|
53
55
|
__exportStar(require("./verify-email-options.interface"), exports);
|
|
54
|
-
__exportStar(require("./role.interface"), exports);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface PasswordReset {
|
|
2
|
+
object: 'password_reset';
|
|
3
|
+
id: string;
|
|
4
|
+
userId: string;
|
|
5
|
+
email: string;
|
|
6
|
+
passwordResetToken: string;
|
|
7
|
+
passwordResetUrl: string;
|
|
8
|
+
expiresAt: string;
|
|
9
|
+
createdAt: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PasswordResetEvent {
|
|
12
|
+
object: 'password_reset';
|
|
13
|
+
id: string;
|
|
14
|
+
userId: string;
|
|
15
|
+
email: string;
|
|
16
|
+
expiresAt: string;
|
|
17
|
+
createdAt: string;
|
|
18
|
+
}
|
|
19
|
+
export interface PasswordResetResponse {
|
|
20
|
+
object: 'password_reset';
|
|
21
|
+
id: string;
|
|
22
|
+
user_id: string;
|
|
23
|
+
email: string;
|
|
24
|
+
password_reset_token: string;
|
|
25
|
+
password_reset_url: string;
|
|
26
|
+
expires_at: string;
|
|
27
|
+
created_at: string;
|
|
28
|
+
}
|
|
29
|
+
export interface PasswordResetEventResponse {
|
|
30
|
+
object: 'password_reset';
|
|
31
|
+
id: string;
|
|
32
|
+
user_id: string;
|
|
33
|
+
email: string;
|
|
34
|
+
expires_at: string;
|
|
35
|
+
created_at: string;
|
|
36
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serializeCreatePasswordResetOptions = void 0;
|
|
4
|
+
const serializeCreatePasswordResetOptions = (options) => ({
|
|
5
|
+
email: options.email,
|
|
6
|
+
});
|
|
7
|
+
exports.serializeCreatePasswordResetOptions = serializeCreatePasswordResetOptions;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { EmailVerification, EmailVerificationEvent, EmailVerificationEventResponse, EmailVerificationResponse } from '../interfaces';
|
|
2
|
+
export declare const deserializeEmailVerification: (emailVerification: EmailVerificationResponse) => EmailVerification;
|
|
3
|
+
export declare const deserializeEmailVerificationEvent: (emailVerification: EmailVerificationEventResponse) => EmailVerificationEvent;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deserializeEmailVerificationEvent = exports.deserializeEmailVerification = void 0;
|
|
4
|
+
const deserializeEmailVerification = (emailVerification) => ({
|
|
5
|
+
object: emailVerification.object,
|
|
6
|
+
id: emailVerification.id,
|
|
7
|
+
userId: emailVerification.user_id,
|
|
8
|
+
email: emailVerification.email,
|
|
9
|
+
expiresAt: emailVerification.expires_at,
|
|
10
|
+
code: emailVerification.code,
|
|
11
|
+
createdAt: emailVerification.created_at,
|
|
12
|
+
updatedAt: emailVerification.updated_at,
|
|
13
|
+
});
|
|
14
|
+
exports.deserializeEmailVerification = deserializeEmailVerification;
|
|
15
|
+
const deserializeEmailVerificationEvent = (emailVerification) => ({
|
|
16
|
+
object: emailVerification.object,
|
|
17
|
+
id: emailVerification.id,
|
|
18
|
+
userId: emailVerification.user_id,
|
|
19
|
+
email: emailVerification.email,
|
|
20
|
+
expiresAt: emailVerification.expires_at,
|
|
21
|
+
createdAt: emailVerification.created_at,
|
|
22
|
+
updatedAt: emailVerification.updated_at,
|
|
23
|
+
});
|
|
24
|
+
exports.deserializeEmailVerificationEvent = deserializeEmailVerificationEvent;
|
|
@@ -5,10 +5,13 @@ export * from './authenticate-with-refresh-token.options.serializer';
|
|
|
5
5
|
export * from './authenticate-with-totp-options.serializer';
|
|
6
6
|
export * from './authentication-response.serializer';
|
|
7
7
|
export * from './create-magic-auth-options.serializer';
|
|
8
|
+
export * from './create-password-reset-options.serializer';
|
|
9
|
+
export * from './email-verification.serializer';
|
|
8
10
|
export * from './enroll-auth-factor-options.serializer';
|
|
9
11
|
export * from './factor.serializer';
|
|
10
12
|
export * from './invitation.serializer';
|
|
11
13
|
export * from './magic-auth.serializer';
|
|
14
|
+
export * from './password-reset.serializer';
|
|
12
15
|
export * from './reset-password-options.serializer';
|
|
13
16
|
export * from './send-password-reset-email.serializer';
|
|
14
17
|
export * from './create-user-options.serializer';
|
|
@@ -21,10 +21,13 @@ __exportStar(require("./authenticate-with-refresh-token.options.serializer"), ex
|
|
|
21
21
|
__exportStar(require("./authenticate-with-totp-options.serializer"), exports);
|
|
22
22
|
__exportStar(require("./authentication-response.serializer"), exports);
|
|
23
23
|
__exportStar(require("./create-magic-auth-options.serializer"), exports);
|
|
24
|
+
__exportStar(require("./create-password-reset-options.serializer"), exports);
|
|
25
|
+
__exportStar(require("./email-verification.serializer"), exports);
|
|
24
26
|
__exportStar(require("./enroll-auth-factor-options.serializer"), exports);
|
|
25
27
|
__exportStar(require("./factor.serializer"), exports);
|
|
26
28
|
__exportStar(require("./invitation.serializer"), exports);
|
|
27
29
|
__exportStar(require("./magic-auth.serializer"), exports);
|
|
30
|
+
__exportStar(require("./password-reset.serializer"), exports);
|
|
28
31
|
__exportStar(require("./reset-password-options.serializer"), exports);
|
|
29
32
|
__exportStar(require("./send-password-reset-email.serializer"), exports);
|
|
30
33
|
__exportStar(require("./create-user-options.serializer"), exports);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { PasswordReset, PasswordResetEvent, PasswordResetEventResponse, PasswordResetResponse } from '../interfaces';
|
|
2
|
+
export declare const deserializePasswordReset: (passwordReset: PasswordResetResponse) => PasswordReset;
|
|
3
|
+
export declare const deserializePasswordResetEvent: (passwordReset: PasswordResetEventResponse) => PasswordResetEvent;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deserializePasswordResetEvent = exports.deserializePasswordReset = void 0;
|
|
4
|
+
const deserializePasswordReset = (passwordReset) => ({
|
|
5
|
+
object: passwordReset.object,
|
|
6
|
+
id: passwordReset.id,
|
|
7
|
+
userId: passwordReset.user_id,
|
|
8
|
+
email: passwordReset.email,
|
|
9
|
+
passwordResetToken: passwordReset.password_reset_token,
|
|
10
|
+
passwordResetUrl: passwordReset.password_reset_url,
|
|
11
|
+
expiresAt: passwordReset.expires_at,
|
|
12
|
+
createdAt: passwordReset.created_at,
|
|
13
|
+
});
|
|
14
|
+
exports.deserializePasswordReset = deserializePasswordReset;
|
|
15
|
+
const deserializePasswordResetEvent = (passwordReset) => ({
|
|
16
|
+
object: passwordReset.object,
|
|
17
|
+
id: passwordReset.id,
|
|
18
|
+
userId: passwordReset.user_id,
|
|
19
|
+
email: passwordReset.email,
|
|
20
|
+
expiresAt: passwordReset.expires_at,
|
|
21
|
+
createdAt: passwordReset.created_at,
|
|
22
|
+
});
|
|
23
|
+
exports.deserializePasswordResetEvent = deserializePasswordResetEvent;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { RoleEvent, RoleEventResponse } from '
|
|
1
|
+
import { RoleEvent, RoleEventResponse } from '../../roles/interfaces';
|
|
2
2
|
export declare const deserializeRole: (role: RoleEventResponse) => RoleEvent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WorkOS } from '../workos';
|
|
2
2
|
import { AutoPaginatable } from '../common/utils/pagination';
|
|
3
|
-
import { AuthenticateWithCodeOptions, AuthenticateWithMagicAuthOptions, AuthenticateWithPasswordOptions, AuthenticateWithTotpOptions, AuthenticationResponse, ResetPasswordOptions, SendPasswordResetEmailOptions, CreateUserOptions, EnrollAuthFactorOptions, ListAuthFactorsOptions, ListUsersOptions, SendMagicAuthCodeOptions, SendVerificationEmailOptions, UpdateUserOptions, User, VerifyEmailOptions, AuthenticateWithRefreshTokenOptions, RefreshAuthenticationResponse, MagicAuth, CreateMagicAuthOptions } from './interfaces';
|
|
3
|
+
import { AuthenticateWithCodeOptions, AuthenticateWithMagicAuthOptions, AuthenticateWithPasswordOptions, AuthenticateWithTotpOptions, AuthenticationResponse, ResetPasswordOptions, SendPasswordResetEmailOptions, CreateUserOptions, EnrollAuthFactorOptions, ListAuthFactorsOptions, ListUsersOptions, SendMagicAuthCodeOptions, SendVerificationEmailOptions, UpdateUserOptions, User, VerifyEmailOptions, AuthenticateWithRefreshTokenOptions, RefreshAuthenticationResponse, MagicAuth, CreateMagicAuthOptions, EmailVerification, PasswordReset, CreatePasswordResetOptions } from './interfaces';
|
|
4
4
|
import { Challenge } from '../mfa/interfaces';
|
|
5
5
|
import { OrganizationMembership } from './interfaces/organization-membership.interface';
|
|
6
6
|
import { ListOrganizationMembershipsOptions } from './interfaces/list-organization-memberships-options.interface';
|
|
@@ -27,6 +27,7 @@ export declare class UserManagement {
|
|
|
27
27
|
authenticateWithTotp(payload: AuthenticateWithTotpOptions): Promise<AuthenticationResponse>;
|
|
28
28
|
authenticateWithEmailVerification(payload: AuthenticateWithEmailVerificationOptions): Promise<AuthenticationResponse>;
|
|
29
29
|
authenticateWithOrganizationSelection(payload: AuthenticateWithOrganizationSelectionOptions): Promise<AuthenticationResponse>;
|
|
30
|
+
getEmailVerification(emailVerificationId: string): Promise<EmailVerification>;
|
|
30
31
|
sendVerificationEmail({ userId, }: SendVerificationEmailOptions): Promise<{
|
|
31
32
|
user: User;
|
|
32
33
|
}>;
|
|
@@ -39,6 +40,11 @@ export declare class UserManagement {
|
|
|
39
40
|
verifyEmail({ code, userId, }: VerifyEmailOptions): Promise<{
|
|
40
41
|
user: User;
|
|
41
42
|
}>;
|
|
43
|
+
getPasswordReset(passwordResetId: string): Promise<PasswordReset>;
|
|
44
|
+
createPasswordReset(options: CreatePasswordResetOptions): Promise<PasswordReset>;
|
|
45
|
+
/**
|
|
46
|
+
* @deprecated Please use `createPasswordReset` instead. This method will be removed in a future major version.
|
|
47
|
+
*/
|
|
42
48
|
sendPasswordResetEmail(payload: SendPasswordResetEmailOptions): Promise<void>;
|
|
43
49
|
resetPassword(payload: ResetPasswordOptions): Promise<{
|
|
44
50
|
user: User;
|
|
@@ -100,6 +100,12 @@ class UserManagement {
|
|
|
100
100
|
return (0, serializers_1.deserializeAuthenticationResponse)(data);
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
|
+
getEmailVerification(emailVerificationId) {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
const { data } = yield this.workos.get(`/user_management/email_verification/${emailVerificationId}`);
|
|
106
|
+
return (0, serializers_1.deserializeEmailVerification)(data);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
103
109
|
sendVerificationEmail({ userId, }) {
|
|
104
110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
105
111
|
const { data } = yield this.workos.post(`/user_management/users/${userId}/email_verification/send`, {});
|
|
@@ -134,6 +140,21 @@ class UserManagement {
|
|
|
134
140
|
return { user: (0, serializers_1.deserializeUser)(data.user) };
|
|
135
141
|
});
|
|
136
142
|
}
|
|
143
|
+
getPasswordReset(passwordResetId) {
|
|
144
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
const { data } = yield this.workos.get(`/user_management/password_reset/${passwordResetId}`);
|
|
146
|
+
return (0, serializers_1.deserializePasswordReset)(data);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
createPasswordReset(options) {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
+
const { data } = yield this.workos.post('/user_management/password_reset', (0, serializers_1.serializeCreatePasswordResetOptions)(Object.assign({}, options)));
|
|
152
|
+
return (0, serializers_1.deserializePasswordReset)(data);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* @deprecated Please use `createPasswordReset` instead. This method will be removed in a future major version.
|
|
157
|
+
*/
|
|
137
158
|
sendPasswordResetEmail(payload) {
|
|
138
159
|
return __awaiter(this, void 0, void 0, function* () {
|
|
139
160
|
yield this.workos.post('/user_management/password_reset/send', (0, serializers_1.serializeSendPasswordResetEmailOptions)(payload));
|
|
@@ -16,6 +16,7 @@ const jest_fetch_mock_1 = __importDefault(require("jest-fetch-mock"));
|
|
|
16
16
|
const test_utils_1 = require("../common/utils/test-utils");
|
|
17
17
|
const workos_1 = require("../workos");
|
|
18
18
|
const deactivate_organization_membership_json_1 = __importDefault(require("./fixtures/deactivate-organization-membership.json"));
|
|
19
|
+
const email_verification_json_1 = __importDefault(require("./fixtures/email_verification.json"));
|
|
19
20
|
const invitation_json_1 = __importDefault(require("./fixtures/invitation.json"));
|
|
20
21
|
const list_factors_json_1 = __importDefault(require("./fixtures/list-factors.json"));
|
|
21
22
|
const list_invitations_json_1 = __importDefault(require("./fixtures/list-invitations.json"));
|
|
@@ -23,12 +24,15 @@ const list_organization_memberships_json_1 = __importDefault(require("./fixtures
|
|
|
23
24
|
const list_users_json_1 = __importDefault(require("./fixtures/list-users.json"));
|
|
24
25
|
const magic_auth_json_1 = __importDefault(require("./fixtures/magic_auth.json"));
|
|
25
26
|
const organization_membership_json_1 = __importDefault(require("./fixtures/organization-membership.json"));
|
|
27
|
+
const password_reset_json_1 = __importDefault(require("./fixtures/password_reset.json"));
|
|
26
28
|
const user_json_1 = __importDefault(require("./fixtures/user.json"));
|
|
27
29
|
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
28
30
|
const userId = 'user_01H5JQDV7R7ATEYZDEG0W5PRYS';
|
|
29
31
|
const organizationMembershipId = 'om_01H5JQDV7R7ATEYZDEG0W5PRYS';
|
|
32
|
+
const emailVerificationId = 'email_verification_01H5JQDV7R7ATEYZDEG0W5PRYS';
|
|
30
33
|
const invitationId = 'invitation_01H5JQDV7R7ATEYZDEG0W5PRYS';
|
|
31
34
|
const magicAuthId = 'magic_auth_01H5JQDV7R7ATEYZDEG0W5PRYS';
|
|
35
|
+
const passwordResetId = 'password_reset_01H5JQDV7R7ATEYZDEG0W5PRYS';
|
|
32
36
|
describe('UserManagement', () => {
|
|
33
37
|
beforeEach(() => jest_fetch_mock_1.default.resetMocks());
|
|
34
38
|
describe('getUser', () => {
|
|
@@ -293,6 +297,22 @@ describe('UserManagement', () => {
|
|
|
293
297
|
});
|
|
294
298
|
}));
|
|
295
299
|
});
|
|
300
|
+
describe('getEmailVerification', () => {
|
|
301
|
+
it('sends a Get EmailVerification request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
302
|
+
(0, test_utils_1.fetchOnce)(email_verification_json_1.default);
|
|
303
|
+
const emailVerification = yield workos.userManagement.getEmailVerification(emailVerificationId);
|
|
304
|
+
expect((0, test_utils_1.fetchURL)()).toContain(`/user_management/email_verification/${emailVerificationId}`);
|
|
305
|
+
expect(emailVerification).toMatchObject({
|
|
306
|
+
id: 'email_verification_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
307
|
+
userId: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
308
|
+
email: 'dane@workos.com',
|
|
309
|
+
expiresAt: '2023-07-18T02:07:19.911Z',
|
|
310
|
+
code: '123456',
|
|
311
|
+
createdAt: '2023-07-18T02:07:19.911Z',
|
|
312
|
+
updatedAt: '2023-07-18T02:07:19.911Z',
|
|
313
|
+
});
|
|
314
|
+
}));
|
|
315
|
+
});
|
|
296
316
|
describe('sendVerificationEmail', () => {
|
|
297
317
|
it('sends a Create Email Verification Challenge request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
298
318
|
(0, test_utils_1.fetchOnce)({ user: user_json_1.default });
|
|
@@ -377,6 +397,43 @@ describe('UserManagement', () => {
|
|
|
377
397
|
expect(response).toBeUndefined();
|
|
378
398
|
}));
|
|
379
399
|
});
|
|
400
|
+
describe('getPasswordReset', () => {
|
|
401
|
+
it('sends a Get PaswordReset request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
402
|
+
(0, test_utils_1.fetchOnce)(password_reset_json_1.default);
|
|
403
|
+
const passwordReset = yield workos.userManagement.getPasswordReset(passwordResetId);
|
|
404
|
+
expect((0, test_utils_1.fetchURL)()).toContain(`/user_management/password_reset/${passwordResetId}`);
|
|
405
|
+
expect(passwordReset).toMatchObject({
|
|
406
|
+
id: 'password_reset_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
407
|
+
userId: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
408
|
+
email: 'dane@workos.com',
|
|
409
|
+
passwordResetToken: 'Z1uX3RbwcIl5fIGJJJCXXisdI',
|
|
410
|
+
passwordResetUrl: 'https://your-app.com/reset-password?token=Z1uX3RbwcIl5fIGJJJCXXisdI',
|
|
411
|
+
expiresAt: '2023-07-18T02:07:19.911Z',
|
|
412
|
+
createdAt: '2023-07-18T02:07:19.911Z',
|
|
413
|
+
});
|
|
414
|
+
}));
|
|
415
|
+
});
|
|
416
|
+
describe('createMagicAuth', () => {
|
|
417
|
+
it('sends a Create Magic Auth request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
418
|
+
(0, test_utils_1.fetchOnce)(password_reset_json_1.default);
|
|
419
|
+
const response = yield workos.userManagement.createPasswordReset({
|
|
420
|
+
email: 'dane@workos.com',
|
|
421
|
+
});
|
|
422
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/user_management/password_reset');
|
|
423
|
+
expect((0, test_utils_1.fetchBody)()).toEqual({
|
|
424
|
+
email: 'dane@workos.com',
|
|
425
|
+
});
|
|
426
|
+
expect(response).toMatchObject({
|
|
427
|
+
id: 'password_reset_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
428
|
+
userId: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
429
|
+
email: 'dane@workos.com',
|
|
430
|
+
passwordResetToken: 'Z1uX3RbwcIl5fIGJJJCXXisdI',
|
|
431
|
+
passwordResetUrl: 'https://your-app.com/reset-password?token=Z1uX3RbwcIl5fIGJJJCXXisdI',
|
|
432
|
+
expiresAt: '2023-07-18T02:07:19.911Z',
|
|
433
|
+
createdAt: '2023-07-18T02:07:19.911Z',
|
|
434
|
+
});
|
|
435
|
+
}));
|
|
436
|
+
});
|
|
380
437
|
describe('sendPasswordResetEmail', () => {
|
|
381
438
|
it('sends a Send Password Reset Email request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
382
439
|
(0, test_utils_1.fetchOnce)();
|
|
@@ -471,6 +528,7 @@ describe('UserManagement', () => {
|
|
|
471
528
|
type: 'totp',
|
|
472
529
|
totpIssuer: 'WorkOS',
|
|
473
530
|
totpUser: 'some_user',
|
|
531
|
+
totpSecret: 'secret-test',
|
|
474
532
|
});
|
|
475
533
|
expect((0, test_utils_1.fetchURL)()).toContain(`/user_management/users/${userId}/auth_factors`);
|
|
476
534
|
expect(resp).toMatchObject({
|
package/lib/workos.js
CHANGED
|
@@ -24,7 +24,7 @@ const audit_logs_1 = require("./audit-logs/audit-logs");
|
|
|
24
24
|
const user_management_1 = require("./user-management/user-management");
|
|
25
25
|
const bad_request_exception_1 = require("./common/exceptions/bad-request.exception");
|
|
26
26
|
const fetch_client_1 = require("./common/utils/fetch-client");
|
|
27
|
-
const VERSION = '7.
|
|
27
|
+
const VERSION = '7.7.0';
|
|
28
28
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
29
29
|
class WorkOS {
|
|
30
30
|
constructor(key, options = {}) {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "7.
|
|
2
|
+
"version": "7.7.0",
|
|
3
3
|
"name": "@workos-inc/node",
|
|
4
4
|
"author": "WorkOS",
|
|
5
5
|
"description": "A Node wrapper for the WorkOS API",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"jest-fetch-mock": "^3.0.3",
|
|
50
50
|
"prettier": "2.8.8",
|
|
51
51
|
"supertest": "6.3.3",
|
|
52
|
-
"ts-jest": "29.1.
|
|
52
|
+
"ts-jest": "29.1.3",
|
|
53
53
|
"tslint": "6.1.3",
|
|
54
54
|
"typescript": "5.1.6"
|
|
55
55
|
}
|
|
File without changes
|
|
File without changes
|