@workos-inc/node 7.0.0 → 7.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 +13 -0
- package/lib/audit-logs/audit-logs.spec.js +15 -12
- package/lib/common/interfaces/event.interface.d.ts +72 -2
- package/lib/common/serializers/event.serializer.js +15 -4
- package/lib/events/events.spec.js +12 -0
- package/lib/events/interfaces/list-events-options.interface.d.ts +2 -0
- package/lib/events/serializers/list-event-options.serializer.js +1 -0
- package/lib/organizations/interfaces/create-organization-options.interface.d.ts +9 -0
- package/lib/organizations/interfaces/domain-data.interface.d.ts +8 -0
- package/lib/organizations/interfaces/domain-data.interface.js +9 -0
- package/lib/organizations/interfaces/index.d.ts +1 -0
- package/lib/organizations/interfaces/index.js +1 -0
- package/lib/organizations/interfaces/update-organization-options.interface.d.ts +9 -0
- package/lib/organizations/organizations.spec.js +71 -29
- package/lib/organizations/serializers/create-organization-options.serializer.js +1 -0
- package/lib/organizations/serializers/update-organization-options.serializer.js +1 -0
- package/lib/user-management/interfaces/authentication-response.interface.d.ts +4 -0
- package/lib/user-management/interfaces/index.d.ts +1 -0
- package/lib/user-management/interfaces/index.js +1 -0
- package/lib/user-management/interfaces/role.interface.d.ts +8 -0
- package/lib/user-management/serializers/authentication-response.serializer.js +2 -2
- package/lib/user-management/serializers/role.serializer.d.ts +2 -0
- package/lib/user-management/serializers/role.serializer.js +8 -0
- package/lib/user-management/user-management.spec.js +16 -0
- package/lib/workos.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -37,6 +37,19 @@ const workos = new WorkOS('sk_1234');
|
|
|
37
37
|
|
|
38
38
|
For our SDKs WorkOS follows a Semantic Versioning ([SemVer](https://semver.org/)) process where all releases will have a version X.Y.Z (like 1.0.0) pattern wherein Z would be a bug fix (e.g., 1.0.1), Y would be a minor release (1.1.0) and X would be a major release (2.0.0). We permit any breaking changes to only be released in major versions and strongly recommend reading changelogs before making any major version upgrades.
|
|
39
39
|
|
|
40
|
+
## Beta Releases
|
|
41
|
+
|
|
42
|
+
WorkOS has features in Beta that can be accessed via Beta releases. We would love for you to try these
|
|
43
|
+
and share feedback with us before these features reach general availability (GA). To install a Beta version,
|
|
44
|
+
please follow the [installation steps](#installation) above using the Beta release version.
|
|
45
|
+
|
|
46
|
+
> Note: there can be breaking changes between Beta versions. Therefore, we recommend pinning the package version to a
|
|
47
|
+
> specific version. This way you can install the same version each time without breaking changes unless you are
|
|
48
|
+
> intentionally looking for the latest Beta version.
|
|
49
|
+
|
|
50
|
+
We highly recommend keeping an eye on when the Beta feature you are interested in goes from Beta to stable so that you
|
|
51
|
+
can move to using the stable version.
|
|
52
|
+
|
|
40
53
|
## More Information
|
|
41
54
|
|
|
42
55
|
- [Single Sign-On Guide](https://workos.com/docs/sso/guide)
|
|
@@ -114,21 +114,22 @@ describe('AuditLogs', () => {
|
|
|
114
114
|
rangeStart: new Date(),
|
|
115
115
|
rangeEnd: new Date(),
|
|
116
116
|
};
|
|
117
|
+
const timestamp = new Date().toISOString();
|
|
117
118
|
const auditLogExport = {
|
|
118
119
|
object: 'audit_log_export',
|
|
119
120
|
id: 'audit_log_export_1234',
|
|
120
121
|
state: 'pending',
|
|
121
122
|
url: undefined,
|
|
122
|
-
createdAt:
|
|
123
|
-
updatedAt:
|
|
123
|
+
createdAt: timestamp,
|
|
124
|
+
updatedAt: timestamp,
|
|
124
125
|
};
|
|
125
126
|
const auditLogExportResponse = {
|
|
126
127
|
object: 'audit_log_export',
|
|
127
128
|
id: 'audit_log_export_1234',
|
|
128
129
|
state: 'pending',
|
|
129
130
|
url: undefined,
|
|
130
|
-
created_at:
|
|
131
|
-
updated_at:
|
|
131
|
+
created_at: timestamp,
|
|
132
|
+
updated_at: timestamp,
|
|
132
133
|
};
|
|
133
134
|
workosSpy.mockResolvedValueOnce((0, workos_mock_response_1.mockWorkOsResponse)(201, auditLogExportResponse));
|
|
134
135
|
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
@@ -149,21 +150,22 @@ describe('AuditLogs', () => {
|
|
|
149
150
|
rangeStart: new Date(),
|
|
150
151
|
targets: ['user', 'team'],
|
|
151
152
|
};
|
|
153
|
+
const timestamp = new Date().toISOString();
|
|
152
154
|
const auditLogExport = {
|
|
153
155
|
object: 'audit_log_export',
|
|
154
156
|
id: 'audit_log_export_1234',
|
|
155
157
|
state: 'pending',
|
|
156
158
|
url: undefined,
|
|
157
|
-
createdAt:
|
|
158
|
-
updatedAt:
|
|
159
|
+
createdAt: timestamp,
|
|
160
|
+
updatedAt: timestamp,
|
|
159
161
|
};
|
|
160
162
|
const auditLogExportResponse = {
|
|
161
163
|
object: 'audit_log_export',
|
|
162
164
|
id: 'audit_log_export_1234',
|
|
163
165
|
state: 'pending',
|
|
164
166
|
url: undefined,
|
|
165
|
-
created_at:
|
|
166
|
-
updated_at:
|
|
167
|
+
created_at: timestamp,
|
|
168
|
+
updated_at: timestamp,
|
|
167
169
|
};
|
|
168
170
|
workosSpy.mockResolvedValueOnce((0, workos_mock_response_1.mockWorkOsResponse)(201, auditLogExportResponse));
|
|
169
171
|
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
@@ -194,21 +196,22 @@ describe('AuditLogs', () => {
|
|
|
194
196
|
describe('when the api responds with a 201', () => {
|
|
195
197
|
it('returns `audit_log_export`', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
196
198
|
const workosSpy = jest.spyOn(workos_1.WorkOS.prototype, 'get');
|
|
199
|
+
const timestamp = new Date().toISOString();
|
|
197
200
|
const auditLogExport = {
|
|
198
201
|
object: 'audit_log_export',
|
|
199
202
|
id: 'audit_log_export_1234',
|
|
200
203
|
state: 'pending',
|
|
201
204
|
url: undefined,
|
|
202
|
-
createdAt:
|
|
203
|
-
updatedAt:
|
|
205
|
+
createdAt: timestamp,
|
|
206
|
+
updatedAt: timestamp,
|
|
204
207
|
};
|
|
205
208
|
const auditLogExportResponse = {
|
|
206
209
|
object: 'audit_log_export',
|
|
207
210
|
id: 'audit_log_export_1234',
|
|
208
211
|
state: 'pending',
|
|
209
212
|
url: undefined,
|
|
210
|
-
created_at:
|
|
211
|
-
updated_at:
|
|
213
|
+
created_at: timestamp,
|
|
214
|
+
updated_at: timestamp,
|
|
212
215
|
};
|
|
213
216
|
workosSpy.mockResolvedValueOnce((0, workos_mock_response_1.mockWorkOsResponse)(201, auditLogExportResponse));
|
|
214
217
|
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { DirectoryUser, DirectoryUserResponse, DirectoryGroup, DirectoryGroupResponse, EventDirectory, EventDirectoryResponse } from '../../directory-sync/interfaces';
|
|
2
|
+
import { Organization, OrganizationResponse } from '../../organizations/interfaces';
|
|
2
3
|
import { Connection, ConnectionResponse } from '../../sso/interfaces';
|
|
3
4
|
import { Session, SessionResponse, User, UserResponse } from '../../user-management/interfaces';
|
|
4
5
|
import { OrganizationMembership, OrganizationMembershipResponse } from '../../user-management/interfaces/organization-membership.interface';
|
|
6
|
+
import { RoleEvent, RoleEventResponse } from '../../user-management/interfaces/role.interface';
|
|
5
7
|
export interface EventBase {
|
|
6
8
|
id: string;
|
|
7
9
|
createdAt: string;
|
|
@@ -162,14 +164,36 @@ export interface UserDeletedEventResponse extends EventResponseBase {
|
|
|
162
164
|
event: 'user.deleted';
|
|
163
165
|
data: UserResponse;
|
|
164
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* @deprecated Use OrganizationMembershipCreated instead. Will be removed in a future major version.
|
|
169
|
+
*/
|
|
165
170
|
export interface OrganizationMembershipAdded extends EventBase {
|
|
166
171
|
event: 'organization_membership.added';
|
|
167
172
|
data: OrganizationMembership;
|
|
168
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* @deprecated Use OrganizationMembershipCreatedResponse instead. Will be removed in a future major version.
|
|
176
|
+
*/
|
|
169
177
|
export interface OrganizationMembershipAddedResponse extends EventResponseBase {
|
|
170
178
|
event: 'organization_membership.added';
|
|
171
179
|
data: OrganizationMembershipResponse;
|
|
172
180
|
}
|
|
181
|
+
export interface OrganizationMembershipCreated extends EventBase {
|
|
182
|
+
event: 'organization_membership.created';
|
|
183
|
+
data: OrganizationMembership;
|
|
184
|
+
}
|
|
185
|
+
export interface OrganizationMembershipCreatedResponse extends EventResponseBase {
|
|
186
|
+
event: 'organization_membership.created';
|
|
187
|
+
data: OrganizationMembershipResponse;
|
|
188
|
+
}
|
|
189
|
+
export interface OrganizationMembershipDeleted extends EventBase {
|
|
190
|
+
event: 'organization_membership.deleted';
|
|
191
|
+
data: OrganizationMembership;
|
|
192
|
+
}
|
|
193
|
+
export interface OrganizationMembershipDeletedResponse extends EventResponseBase {
|
|
194
|
+
event: 'organization_membership.deleted';
|
|
195
|
+
data: OrganizationMembershipResponse;
|
|
196
|
+
}
|
|
173
197
|
export interface OrganizationMembershipUpdated extends EventBase {
|
|
174
198
|
event: 'organization_membership.updated';
|
|
175
199
|
data: OrganizationMembership;
|
|
@@ -178,14 +202,60 @@ export interface OrganizationMembershipUpdatedResponse extends EventResponseBase
|
|
|
178
202
|
event: 'organization_membership.updated';
|
|
179
203
|
data: OrganizationMembershipResponse;
|
|
180
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* @deprecated Use OrganizationMembershipDeleted instead. Will be removed in a future major version.
|
|
207
|
+
*/
|
|
181
208
|
export interface OrganizationMembershipRemoved extends EventBase {
|
|
182
209
|
event: 'organization_membership.removed';
|
|
183
210
|
data: OrganizationMembership;
|
|
184
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* @deprecated Use OrganizationMembershipDeletedResponse instead. Will be removed in a future major version.
|
|
214
|
+
*/
|
|
185
215
|
export interface OrganizationMembershipRemovedResponse extends EventResponseBase {
|
|
186
216
|
event: 'organization_membership.removed';
|
|
187
217
|
data: OrganizationMembershipResponse;
|
|
188
218
|
}
|
|
219
|
+
export interface OrganizationCreatedEvent extends EventBase {
|
|
220
|
+
event: 'organization.created';
|
|
221
|
+
data: Organization;
|
|
222
|
+
}
|
|
223
|
+
export interface OrganizationCreatedResponse extends EventResponseBase {
|
|
224
|
+
event: 'organization.created';
|
|
225
|
+
data: OrganizationResponse;
|
|
226
|
+
}
|
|
227
|
+
export interface OrganizationUpdatedEvent extends EventBase {
|
|
228
|
+
event: 'organization.updated';
|
|
229
|
+
data: Organization;
|
|
230
|
+
}
|
|
231
|
+
export interface OrganizationUpdatedResponse extends EventResponseBase {
|
|
232
|
+
event: 'organization.updated';
|
|
233
|
+
data: OrganizationResponse;
|
|
234
|
+
}
|
|
235
|
+
export interface OrganizationDeletedEvent extends EventBase {
|
|
236
|
+
event: 'organization.deleted';
|
|
237
|
+
data: Organization;
|
|
238
|
+
}
|
|
239
|
+
export interface OrganizationDeletedResponse extends EventResponseBase {
|
|
240
|
+
event: 'organization.deleted';
|
|
241
|
+
data: OrganizationResponse;
|
|
242
|
+
}
|
|
243
|
+
export interface RoleCreatedEvent extends EventBase {
|
|
244
|
+
event: 'role.created';
|
|
245
|
+
data: RoleEvent;
|
|
246
|
+
}
|
|
247
|
+
export interface RoleCreatedEventResponse extends EventResponseBase {
|
|
248
|
+
event: 'role.created';
|
|
249
|
+
data: RoleEventResponse;
|
|
250
|
+
}
|
|
251
|
+
export interface RoleDeletedEvent extends EventBase {
|
|
252
|
+
event: 'role.deleted';
|
|
253
|
+
data: RoleEvent;
|
|
254
|
+
}
|
|
255
|
+
export interface RoleDeletedEventResponse extends EventResponseBase {
|
|
256
|
+
event: 'role.deleted';
|
|
257
|
+
data: RoleEventResponse;
|
|
258
|
+
}
|
|
189
259
|
export interface SessionCreatedEvent extends EventBase {
|
|
190
260
|
event: 'session.created';
|
|
191
261
|
data: Session;
|
|
@@ -194,7 +264,7 @@ export interface SessionCreatedEventResponse extends EventResponseBase {
|
|
|
194
264
|
event: 'session.created';
|
|
195
265
|
data: SessionResponse;
|
|
196
266
|
}
|
|
197
|
-
export type Event = ConnectionActivatedEvent | ConnectionDeactivatedEvent | ConnectionDeletedEvent | DsyncActivatedEvent | DsyncDeactivatedEvent | DsyncDeletedEvent | DsyncGroupCreatedEvent | DsyncGroupUpdatedEvent | DsyncGroupDeletedEvent | DsyncGroupUserAddedEvent | DsyncGroupUserRemovedEvent | DsyncUserCreatedEvent | DsyncUserUpdatedEvent | DsyncUserDeletedEvent | UserCreatedEvent | UserUpdatedEvent | UserDeletedEvent | OrganizationMembershipAdded | OrganizationMembershipUpdated | OrganizationMembershipRemoved | SessionCreatedEvent;
|
|
198
|
-
export type EventResponse = ConnectionActivatedEventResponse | ConnectionDeactivatedEventResponse | ConnectionDeletedEventResponse | DsyncActivatedEventResponse | DsyncDeactivatedEventResponse | DsyncDeletedEventResponse | DsyncGroupCreatedEventResponse | DsyncGroupUpdatedEventResponse | DsyncGroupDeletedEventResponse | DsyncGroupUserAddedEventResponse | DsyncGroupUserRemovedEventResponse | DsyncUserCreatedEventResponse | DsyncUserUpdatedEventResponse | DsyncUserDeletedEventResponse | UserCreatedEventResponse | UserUpdatedEventResponse | UserDeletedEventResponse | OrganizationMembershipAddedResponse | OrganizationMembershipUpdatedResponse | OrganizationMembershipRemovedResponse | SessionCreatedEventResponse;
|
|
267
|
+
export type Event = ConnectionActivatedEvent | ConnectionDeactivatedEvent | ConnectionDeletedEvent | DsyncActivatedEvent | DsyncDeactivatedEvent | DsyncDeletedEvent | DsyncGroupCreatedEvent | DsyncGroupUpdatedEvent | DsyncGroupDeletedEvent | DsyncGroupUserAddedEvent | DsyncGroupUserRemovedEvent | DsyncUserCreatedEvent | DsyncUserUpdatedEvent | DsyncUserDeletedEvent | UserCreatedEvent | UserUpdatedEvent | UserDeletedEvent | OrganizationMembershipAdded | OrganizationMembershipCreated | OrganizationMembershipDeleted | OrganizationMembershipUpdated | OrganizationMembershipRemoved | RoleCreatedEvent | RoleDeletedEvent | SessionCreatedEvent | OrganizationCreatedEvent | OrganizationUpdatedEvent | OrganizationDeletedEvent;
|
|
268
|
+
export type EventResponse = ConnectionActivatedEventResponse | ConnectionDeactivatedEventResponse | ConnectionDeletedEventResponse | DsyncActivatedEventResponse | DsyncDeactivatedEventResponse | DsyncDeletedEventResponse | DsyncGroupCreatedEventResponse | DsyncGroupUpdatedEventResponse | DsyncGroupDeletedEventResponse | DsyncGroupUserAddedEventResponse | DsyncGroupUserRemovedEventResponse | DsyncUserCreatedEventResponse | DsyncUserUpdatedEventResponse | DsyncUserDeletedEventResponse | UserCreatedEventResponse | UserUpdatedEventResponse | UserDeletedEventResponse | OrganizationMembershipAddedResponse | OrganizationMembershipCreatedResponse | OrganizationMembershipDeletedResponse | OrganizationMembershipUpdatedResponse | OrganizationMembershipRemovedResponse | RoleCreatedEventResponse | RoleDeletedEventResponse | SessionCreatedEventResponse | OrganizationCreatedResponse | OrganizationUpdatedResponse | OrganizationDeletedResponse;
|
|
199
269
|
export type EventName = Event['event'];
|
|
200
270
|
export {};
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deserializeEvent = void 0;
|
|
4
4
|
const serializers_1 = require("../../directory-sync/serializers");
|
|
5
|
-
const serializers_2 = require("../../
|
|
6
|
-
const serializers_3 = require("../../
|
|
5
|
+
const serializers_2 = require("../../organizations/serializers");
|
|
6
|
+
const serializers_3 = require("../../sso/serializers");
|
|
7
|
+
const serializers_4 = require("../../user-management/serializers");
|
|
7
8
|
const organization_membership_serializer_1 = require("../../user-management/serializers/organization-membership.serializer");
|
|
9
|
+
const role_serializer_1 = require("../../user-management/serializers/role.serializer");
|
|
8
10
|
const session_serializer_1 = require("../../user-management/serializers/session.serializer");
|
|
9
11
|
const deserializeEvent = (event) => {
|
|
10
12
|
const eventBase = {
|
|
@@ -15,7 +17,7 @@ const deserializeEvent = (event) => {
|
|
|
15
17
|
case 'connection.activated':
|
|
16
18
|
case 'connection.deactivated':
|
|
17
19
|
case 'connection.deleted':
|
|
18
|
-
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0,
|
|
20
|
+
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, serializers_3.deserializeConnection)(event.data) });
|
|
19
21
|
case 'dsync.activated':
|
|
20
22
|
case 'dsync.deactivated':
|
|
21
23
|
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, serializers_1.deserializeEventDirectory)(event.data) });
|
|
@@ -41,13 +43,22 @@ const deserializeEvent = (event) => {
|
|
|
41
43
|
case 'user.created':
|
|
42
44
|
case 'user.updated':
|
|
43
45
|
case 'user.deleted':
|
|
44
|
-
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0,
|
|
46
|
+
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, serializers_4.deserializeUser)(event.data) });
|
|
45
47
|
case 'organization_membership.added':
|
|
48
|
+
case 'organization_membership.created':
|
|
49
|
+
case 'organization_membership.deleted':
|
|
46
50
|
case 'organization_membership.updated':
|
|
47
51
|
case 'organization_membership.removed':
|
|
48
52
|
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, organization_membership_serializer_1.deserializeOrganizationMembership)(event.data) });
|
|
53
|
+
case 'role.created':
|
|
54
|
+
case 'role.deleted':
|
|
55
|
+
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, role_serializer_1.deserializeRole)(event.data) });
|
|
49
56
|
case 'session.created':
|
|
50
57
|
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, session_serializer_1.deserializeSession)(event.data) });
|
|
58
|
+
case 'organization.created':
|
|
59
|
+
case 'organization.updated':
|
|
60
|
+
case 'organization.deleted':
|
|
61
|
+
return Object.assign(Object.assign({}, eventBase), { event: event.event, data: (0, serializers_2.deserializeOrganization)(event.data) });
|
|
51
62
|
}
|
|
52
63
|
};
|
|
53
64
|
exports.deserializeEvent = deserializeEvent;
|
|
@@ -94,5 +94,17 @@ describe('Event', () => {
|
|
|
94
94
|
listMetadata: {},
|
|
95
95
|
});
|
|
96
96
|
}));
|
|
97
|
+
it(`requests Events with a valid organization id`, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
98
|
+
(0, test_utils_1.fetchOnce)(eventsListResponse);
|
|
99
|
+
const list = yield workos.events.listEvents({
|
|
100
|
+
events: ['connection.activated'],
|
|
101
|
+
organizationId: 'org_1234',
|
|
102
|
+
});
|
|
103
|
+
expect(list).toEqual({
|
|
104
|
+
object: 'list',
|
|
105
|
+
data: [event],
|
|
106
|
+
listMetadata: {},
|
|
107
|
+
});
|
|
108
|
+
}));
|
|
97
109
|
});
|
|
98
110
|
});
|
|
@@ -5,6 +5,7 @@ export interface ListEventOptions {
|
|
|
5
5
|
rangeEnd?: string;
|
|
6
6
|
limit?: number;
|
|
7
7
|
after?: string;
|
|
8
|
+
organizationId?: string;
|
|
8
9
|
}
|
|
9
10
|
export interface SerializedListEventOptions {
|
|
10
11
|
events: EventName[];
|
|
@@ -12,4 +13,5 @@ export interface SerializedListEventOptions {
|
|
|
12
13
|
range_end?: string;
|
|
13
14
|
limit?: number;
|
|
14
15
|
after?: string;
|
|
16
|
+
organization_id?: string;
|
|
15
17
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.serializeListEventOptions = void 0;
|
|
4
4
|
const serializeListEventOptions = (options) => ({
|
|
5
5
|
events: options.events,
|
|
6
|
+
organization_id: options.organizationId,
|
|
6
7
|
range_start: options.rangeStart,
|
|
7
8
|
range_end: options.rangeEnd,
|
|
8
9
|
limit: options.limit,
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import { PostOptions } from '../../common/interfaces';
|
|
2
|
+
import { DomainData } from './domain-data.interface';
|
|
2
3
|
export interface CreateOrganizationOptions {
|
|
3
4
|
name: string;
|
|
4
5
|
allowProfilesOutsideOrganization?: boolean;
|
|
6
|
+
domainData?: DomainData[];
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use `domain_data` instead.
|
|
9
|
+
*/
|
|
5
10
|
domains?: string[];
|
|
6
11
|
}
|
|
7
12
|
export interface SerializedCreateOrganizationOptions {
|
|
8
13
|
name: string;
|
|
9
14
|
allow_profiles_outside_organization?: boolean;
|
|
15
|
+
domain_data?: DomainData[];
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use `domain_data` instead.
|
|
18
|
+
*/
|
|
10
19
|
domains?: string[];
|
|
11
20
|
}
|
|
12
21
|
export interface CreateOrganizationRequestOptions extends Pick<PostOptions, 'idempotencyKey'> {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DomainDataState = void 0;
|
|
4
|
+
// These are the only possible states to create an organization domain with
|
|
5
|
+
var DomainDataState;
|
|
6
|
+
(function (DomainDataState) {
|
|
7
|
+
DomainDataState["Verified"] = "verified";
|
|
8
|
+
DomainDataState["Pending"] = "pending";
|
|
9
|
+
})(DomainDataState || (exports.DomainDataState = DomainDataState = {}));
|
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./create-organization-options.interface"), exports);
|
|
18
|
+
__exportStar(require("./domain-data.interface"), exports);
|
|
18
19
|
__exportStar(require("./list-organizations-options.interface"), exports);
|
|
19
20
|
__exportStar(require("./organization-domain.interface"), exports);
|
|
20
21
|
__exportStar(require("./organization.interface"), exports);
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
+
import { DomainData } from './domain-data.interface';
|
|
1
2
|
export interface UpdateOrganizationOptions {
|
|
2
3
|
organization: string;
|
|
3
4
|
name: string;
|
|
4
5
|
allowProfilesOutsideOrganization?: boolean;
|
|
6
|
+
domainData?: DomainData[];
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use `domain_data` instead.
|
|
9
|
+
*/
|
|
5
10
|
domains?: string[];
|
|
6
11
|
}
|
|
7
12
|
export interface SerializedUpdateOrganizationOptions {
|
|
8
13
|
name: string;
|
|
9
14
|
allow_profiles_outside_organization?: boolean;
|
|
15
|
+
domain_data?: DomainData[];
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use `domain_data` instead.
|
|
18
|
+
*/
|
|
10
19
|
domains?: string[];
|
|
11
20
|
}
|
|
@@ -20,6 +20,7 @@ const create_organization_json_1 = __importDefault(require("./fixtures/create-or
|
|
|
20
20
|
const get_organization_json_1 = __importDefault(require("./fixtures/get-organization.json"));
|
|
21
21
|
const list_organizations_json_1 = __importDefault(require("./fixtures/list-organizations.json"));
|
|
22
22
|
const update_organization_json_1 = __importDefault(require("./fixtures/update-organization.json"));
|
|
23
|
+
const interfaces_1 = require("./interfaces");
|
|
23
24
|
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
24
25
|
describe('Organizations', () => {
|
|
25
26
|
beforeEach(() => jest_fetch_mock_1.default.resetMocks());
|
|
@@ -116,20 +117,40 @@ describe('Organizations', () => {
|
|
|
116
117
|
}));
|
|
117
118
|
});
|
|
118
119
|
describe('with a valid payload', () => {
|
|
119
|
-
|
|
120
|
-
(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
120
|
+
describe('with `domains`', () => {
|
|
121
|
+
it('creates an organization', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
122
|
+
(0, test_utils_1.fetchOnce)(create_organization_json_1.default, { status: 201 });
|
|
123
|
+
const subject = yield workos.organizations.createOrganization({
|
|
124
|
+
domains: ['example.com'],
|
|
125
|
+
name: 'Test Organization',
|
|
126
|
+
});
|
|
127
|
+
expect((0, test_utils_1.fetchBody)()).toEqual({
|
|
128
|
+
domains: ['example.com'],
|
|
129
|
+
name: 'Test Organization',
|
|
130
|
+
});
|
|
131
|
+
expect(subject.id).toEqual('org_01EHT88Z8J8795GZNQ4ZP1J81T');
|
|
132
|
+
expect(subject.name).toEqual('Test Organization');
|
|
133
|
+
expect(subject.domains).toHaveLength(1);
|
|
134
|
+
}));
|
|
135
|
+
});
|
|
136
|
+
describe('with `domain_data`', () => {
|
|
137
|
+
it('creates an organization', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
138
|
+
(0, test_utils_1.fetchOnce)(create_organization_json_1.default, { status: 201 });
|
|
139
|
+
const subject = yield workos.organizations.createOrganization({
|
|
140
|
+
domainData: [
|
|
141
|
+
{ domain: 'example.com', state: interfaces_1.DomainDataState.Verified },
|
|
142
|
+
],
|
|
143
|
+
name: 'Test Organization',
|
|
144
|
+
});
|
|
145
|
+
expect((0, test_utils_1.fetchBody)()).toEqual({
|
|
146
|
+
domain_data: [{ domain: 'example.com', state: 'verified' }],
|
|
147
|
+
name: 'Test Organization',
|
|
148
|
+
});
|
|
149
|
+
expect(subject.id).toEqual('org_01EHT88Z8J8795GZNQ4ZP1J81T');
|
|
150
|
+
expect(subject.name).toEqual('Test Organization');
|
|
151
|
+
expect(subject.domains).toHaveLength(1);
|
|
152
|
+
}));
|
|
153
|
+
});
|
|
133
154
|
});
|
|
134
155
|
describe('with an invalid payload', () => {
|
|
135
156
|
it('returns an error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -170,21 +191,42 @@ describe('Organizations', () => {
|
|
|
170
191
|
});
|
|
171
192
|
describe('updateOrganization', () => {
|
|
172
193
|
describe('with a valid payload', () => {
|
|
173
|
-
|
|
174
|
-
(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
194
|
+
describe('with `domains', () => {
|
|
195
|
+
it('updates an organization', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
196
|
+
(0, test_utils_1.fetchOnce)(update_organization_json_1.default, { status: 201 });
|
|
197
|
+
const subject = yield workos.organizations.updateOrganization({
|
|
198
|
+
organization: 'org_01EHT88Z8J8795GZNQ4ZP1J81T',
|
|
199
|
+
domains: ['example.com'],
|
|
200
|
+
name: 'Test Organization 2',
|
|
201
|
+
});
|
|
202
|
+
expect((0, test_utils_1.fetchBody)()).toEqual({
|
|
203
|
+
domains: ['example.com'],
|
|
204
|
+
name: 'Test Organization 2',
|
|
205
|
+
});
|
|
206
|
+
expect(subject.id).toEqual('org_01EHT88Z8J8795GZNQ4ZP1J81T');
|
|
207
|
+
expect(subject.name).toEqual('Test Organization 2');
|
|
208
|
+
expect(subject.domains).toHaveLength(1);
|
|
209
|
+
}));
|
|
210
|
+
});
|
|
211
|
+
describe('with `domain_data`', () => {
|
|
212
|
+
it('updates an organization', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
213
|
+
(0, test_utils_1.fetchOnce)(update_organization_json_1.default, { status: 201 });
|
|
214
|
+
const subject = yield workos.organizations.updateOrganization({
|
|
215
|
+
organization: 'org_01EHT88Z8J8795GZNQ4ZP1J81T',
|
|
216
|
+
domainData: [
|
|
217
|
+
{ domain: 'example.com', state: interfaces_1.DomainDataState.Verified },
|
|
218
|
+
],
|
|
219
|
+
name: 'Test Organization 2',
|
|
220
|
+
});
|
|
221
|
+
expect((0, test_utils_1.fetchBody)()).toEqual({
|
|
222
|
+
domain_data: [{ domain: 'example.com', state: 'verified' }],
|
|
223
|
+
name: 'Test Organization 2',
|
|
224
|
+
});
|
|
225
|
+
expect(subject.id).toEqual('org_01EHT88Z8J8795GZNQ4ZP1J81T');
|
|
226
|
+
expect(subject.name).toEqual('Test Organization 2');
|
|
227
|
+
expect(subject.domains).toHaveLength(1);
|
|
228
|
+
}));
|
|
229
|
+
});
|
|
188
230
|
});
|
|
189
231
|
});
|
|
190
232
|
});
|
|
@@ -4,6 +4,7 @@ exports.serializeCreateOrganizationOptions = void 0;
|
|
|
4
4
|
const serializeCreateOrganizationOptions = (options) => ({
|
|
5
5
|
name: options.name,
|
|
6
6
|
allow_profiles_outside_organization: options.allowProfilesOutsideOrganization,
|
|
7
|
+
domain_data: options.domainData,
|
|
7
8
|
domains: options.domains,
|
|
8
9
|
});
|
|
9
10
|
exports.serializeCreateOrganizationOptions = serializeCreateOrganizationOptions;
|
|
@@ -4,6 +4,7 @@ exports.serializeUpdateOrganizationOptions = void 0;
|
|
|
4
4
|
const serializeUpdateOrganizationOptions = (options) => ({
|
|
5
5
|
name: options.name,
|
|
6
6
|
allow_profiles_outside_organization: options.allowProfilesOutsideOrganization,
|
|
7
|
+
domain_data: options.domainData,
|
|
7
8
|
domains: options.domains,
|
|
8
9
|
});
|
|
9
10
|
exports.serializeUpdateOrganizationOptions = serializeUpdateOrganizationOptions;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Impersonator, ImpersonatorResponse } from './impersonator.interface';
|
|
2
2
|
import { User, UserResponse } from './user.interface';
|
|
3
|
+
type AuthenticationMethod = 'SSO' | 'Password' | 'GitHubOAuth' | 'GoogleOAuth' | 'MicrosoftOAuth' | 'MagicAuth' | 'Impersonation';
|
|
3
4
|
export interface AuthenticationResponse {
|
|
4
5
|
user: User;
|
|
5
6
|
organizationId?: string;
|
|
6
7
|
accessToken: string;
|
|
7
8
|
refreshToken: string;
|
|
8
9
|
impersonator?: Impersonator;
|
|
10
|
+
authenticationMethod?: AuthenticationMethod;
|
|
9
11
|
}
|
|
10
12
|
export interface AuthenticationResponseResponse {
|
|
11
13
|
user: UserResponse;
|
|
@@ -13,6 +15,7 @@ export interface AuthenticationResponseResponse {
|
|
|
13
15
|
access_token: string;
|
|
14
16
|
refresh_token: string;
|
|
15
17
|
impersonator?: ImpersonatorResponse;
|
|
18
|
+
authentication_method?: AuthenticationMethod;
|
|
16
19
|
}
|
|
17
20
|
export interface RefreshAuthenticationResponse {
|
|
18
21
|
accessToken: string;
|
|
@@ -22,3 +25,4 @@ export interface RefreshAuthenticationResponseResponse {
|
|
|
22
25
|
access_token: string;
|
|
23
26
|
refresh_token: string;
|
|
24
27
|
}
|
|
28
|
+
export {};
|
|
@@ -49,3 +49,4 @@ __exportStar(require("./update-user-options.interface"), exports);
|
|
|
49
49
|
__exportStar(require("./update-user-password-options.interface"), exports);
|
|
50
50
|
__exportStar(require("./user.interface"), exports);
|
|
51
51
|
__exportStar(require("./verify-email-options.interface"), exports);
|
|
52
|
+
__exportStar(require("./role.interface"), exports);
|
|
@@ -14,8 +14,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
exports.deserializeRefreshAuthenticationResponse = exports.deserializeAuthenticationResponse = void 0;
|
|
15
15
|
const user_serializer_1 = require("./user.serializer");
|
|
16
16
|
const deserializeAuthenticationResponse = (authenticationResponse) => {
|
|
17
|
-
const { user, organization_id, access_token, refresh_token, impersonator } = authenticationResponse, rest = __rest(authenticationResponse, ["user", "organization_id", "access_token", "refresh_token", "impersonator"]);
|
|
18
|
-
return Object.assign({ user: (0, user_serializer_1.deserializeUser)(user), organizationId: organization_id, accessToken: access_token, refreshToken: refresh_token, impersonator }, rest);
|
|
17
|
+
const { user, organization_id, access_token, refresh_token, authentication_method, impersonator } = authenticationResponse, rest = __rest(authenticationResponse, ["user", "organization_id", "access_token", "refresh_token", "authentication_method", "impersonator"]);
|
|
18
|
+
return Object.assign({ user: (0, user_serializer_1.deserializeUser)(user), organizationId: organization_id, accessToken: access_token, refreshToken: refresh_token, impersonator, authenticationMethod: authentication_method }, rest);
|
|
19
19
|
};
|
|
20
20
|
exports.deserializeAuthenticationResponse = deserializeAuthenticationResponse;
|
|
21
21
|
const deserializeRefreshAuthenticationResponse = (refreshAuthenticationResponse) => {
|
|
@@ -155,6 +155,22 @@ describe('UserManagement', () => {
|
|
|
155
155
|
},
|
|
156
156
|
});
|
|
157
157
|
}));
|
|
158
|
+
it('deserializes authentication_method', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
159
|
+
(0, test_utils_1.fetchOnce)({
|
|
160
|
+
user: user_json_1.default,
|
|
161
|
+
authentication_method: 'Password',
|
|
162
|
+
});
|
|
163
|
+
const resp = yield workos.userManagement.authenticateWithCode({
|
|
164
|
+
clientId: 'proj_whatever',
|
|
165
|
+
code: 'or this',
|
|
166
|
+
});
|
|
167
|
+
expect(resp).toMatchObject({
|
|
168
|
+
user: {
|
|
169
|
+
email: 'test01@example.com',
|
|
170
|
+
},
|
|
171
|
+
authenticationMethod: 'Password',
|
|
172
|
+
});
|
|
173
|
+
}));
|
|
158
174
|
describe('when the code is for an impersonator', () => {
|
|
159
175
|
it('deserializes the impersonator metadata', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
160
176
|
(0, test_utils_1.fetchOnce)({
|
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.2.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.2.0",
|
|
3
3
|
"name": "@workos-inc/node",
|
|
4
4
|
"author": "WorkOS",
|
|
5
5
|
"description": "A Node wrapper for the WorkOS API",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"workos"
|
|
10
10
|
],
|
|
11
11
|
"volta": {
|
|
12
|
-
"node": "
|
|
12
|
+
"node": "19.9.0",
|
|
13
13
|
"yarn": "1.22.19"
|
|
14
14
|
},
|
|
15
15
|
"engines": {
|