@workos-inc/node 3.3.0 → 3.4.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/users/fixtures/list-users.json +0 -1
- package/lib/users/fixtures/user.json +1 -2
- package/lib/users/interfaces/delete-user-options.interface.d.ts +3 -0
- package/lib/users/interfaces/index.d.ts +2 -3
- package/lib/users/interfaces/index.js +2 -3
- package/lib/users/interfaces/list-users-options.interface.d.ts +0 -1
- package/lib/users/interfaces/update-user-options.interface.d.ts +2 -2
- package/lib/users/interfaces/user.interface.d.ts +4 -25
- package/lib/users/interfaces/verify-email-options.interface.d.ts +7 -0
- package/lib/users/serializers/index.d.ts +0 -2
- package/lib/users/serializers/index.js +0 -2
- package/lib/users/serializers/update-user-options.serializer.js +1 -1
- package/lib/users/serializers/user.serializer.js +10 -20
- package/lib/users/users.d.ts +3 -5
- package/lib/users/users.js +8 -21
- package/lib/users/users.spec.js +21 -60
- package/lib/workos.js +1 -1
- package/package.json +1 -1
- package/lib/users/exceptions/index.d.ts +0 -4
- package/lib/users/exceptions/index.js +0 -10
- package/lib/users/interfaces/revoke-all-sessions-for-user-options.interface.d.ts +0 -3
- package/lib/users/interfaces/revoke-session-options.interface.d.ts +0 -15
- package/lib/users/interfaces/verify-session.interface.d.ts +0 -18
- package/lib/users/interfaces/verify-session.interface.js +0 -2
- package/lib/users/serializers/revoke-session-options.serializer.d.ts +0 -2
- package/lib/users/serializers/revoke-session-options.serializer.js +0 -14
- package/lib/users/serializers/verify-session.serializer.d.ts +0 -3
- package/lib/users/serializers/verify-session.serializer.js +0 -15
- /package/lib/users/interfaces/{revoke-all-sessions-for-user-options.interface.js → delete-user-options.interface.js} +0 -0
- /package/lib/users/interfaces/{revoke-session-options.interface.js → verify-email-options.interface.js} +0 -0
|
@@ -7,15 +7,14 @@ export * from './complete-password-reset-options.interface';
|
|
|
7
7
|
export * from './create-email-verification-challenge-options.interface';
|
|
8
8
|
export * from './create-password-reset-challenge-options.interface';
|
|
9
9
|
export * from './create-user-options.interface';
|
|
10
|
+
export * from './delete-user-options.interface';
|
|
10
11
|
export * from './enroll-user-in-mfa-factor.interface';
|
|
11
12
|
export * from './list-users-options.interface';
|
|
12
13
|
export * from './magic-auth-challenge.interface';
|
|
13
14
|
export * from './remove-user-from-organization-options.interface';
|
|
14
|
-
export * from './revoke-all-sessions-for-user-options.interface';
|
|
15
|
-
export * from './revoke-session-options.interface';
|
|
16
15
|
export * from './send-magic-auth-code-options.interface';
|
|
17
16
|
export * from './session.interface';
|
|
18
17
|
export * from './update-user-options.interface';
|
|
19
18
|
export * from './update-user-password-options.interface';
|
|
20
19
|
export * from './user.interface';
|
|
21
|
-
export * from './verify-
|
|
20
|
+
export * from './verify-email-options.interface';
|
|
@@ -23,15 +23,14 @@ __exportStar(require("./complete-password-reset-options.interface"), exports);
|
|
|
23
23
|
__exportStar(require("./create-email-verification-challenge-options.interface"), exports);
|
|
24
24
|
__exportStar(require("./create-password-reset-challenge-options.interface"), exports);
|
|
25
25
|
__exportStar(require("./create-user-options.interface"), exports);
|
|
26
|
+
__exportStar(require("./delete-user-options.interface"), exports);
|
|
26
27
|
__exportStar(require("./enroll-user-in-mfa-factor.interface"), exports);
|
|
27
28
|
__exportStar(require("./list-users-options.interface"), exports);
|
|
28
29
|
__exportStar(require("./magic-auth-challenge.interface"), exports);
|
|
29
30
|
__exportStar(require("./remove-user-from-organization-options.interface"), exports);
|
|
30
|
-
__exportStar(require("./revoke-all-sessions-for-user-options.interface"), exports);
|
|
31
|
-
__exportStar(require("./revoke-session-options.interface"), exports);
|
|
32
31
|
__exportStar(require("./send-magic-auth-code-options.interface"), exports);
|
|
33
32
|
__exportStar(require("./session.interface"), exports);
|
|
34
33
|
__exportStar(require("./update-user-options.interface"), exports);
|
|
35
34
|
__exportStar(require("./update-user-password-options.interface"), exports);
|
|
36
35
|
__exportStar(require("./user.interface"), exports);
|
|
37
|
-
__exportStar(require("./verify-
|
|
36
|
+
__exportStar(require("./verify-email-options.interface"), exports);
|
|
@@ -2,10 +2,10 @@ export interface UpdateUserOptions {
|
|
|
2
2
|
userId: string;
|
|
3
3
|
firstName?: string;
|
|
4
4
|
lastName?: string;
|
|
5
|
-
|
|
5
|
+
emailVerified?: boolean;
|
|
6
6
|
}
|
|
7
7
|
export interface SerializedUpdateUserOptions {
|
|
8
8
|
first_name?: string;
|
|
9
9
|
last_name?: string;
|
|
10
|
-
|
|
10
|
+
email_verified?: boolean;
|
|
11
11
|
}
|
|
@@ -1,41 +1,20 @@
|
|
|
1
|
-
export
|
|
2
|
-
export type UserResponse = ManagedUserResponse | UnmanagedUserResponse;
|
|
3
|
-
interface ManagedUser extends BaseUser {
|
|
4
|
-
userType: 'managed';
|
|
5
|
-
ssoProfileId: string | null;
|
|
6
|
-
}
|
|
7
|
-
interface ManagedUserResponse extends BaseUserResponse {
|
|
8
|
-
user_type: 'managed';
|
|
9
|
-
sso_profile_id: string | null;
|
|
10
|
-
}
|
|
11
|
-
interface UnmanagedUser extends BaseUser {
|
|
12
|
-
userType: 'unmanaged';
|
|
13
|
-
emailVerifiedAt: string | null;
|
|
14
|
-
googleOauthProfileId: string | null;
|
|
15
|
-
microsoftOauthProfileId: string | null;
|
|
16
|
-
}
|
|
17
|
-
interface UnmanagedUserResponse extends BaseUserResponse {
|
|
18
|
-
user_type: 'unmanaged';
|
|
19
|
-
email_verified_at: string | null;
|
|
20
|
-
google_oauth_profile_id: string | null;
|
|
21
|
-
microsoft_oauth_profile_id: string | null;
|
|
22
|
-
}
|
|
23
|
-
export interface BaseUser {
|
|
1
|
+
export interface User {
|
|
24
2
|
object: 'user';
|
|
25
3
|
id: string;
|
|
26
4
|
email: string;
|
|
5
|
+
emailVerified: boolean;
|
|
27
6
|
firstName: string | null;
|
|
28
7
|
lastName: string | null;
|
|
29
8
|
createdAt: string;
|
|
30
9
|
updatedAt: string;
|
|
31
10
|
}
|
|
32
|
-
interface
|
|
11
|
+
export interface UserResponse {
|
|
33
12
|
object: 'user';
|
|
34
13
|
id: string;
|
|
35
14
|
email: string;
|
|
15
|
+
email_verified: boolean;
|
|
36
16
|
first_name: string | null;
|
|
37
17
|
last_name: string | null;
|
|
38
18
|
created_at: string;
|
|
39
19
|
updated_at: string;
|
|
40
20
|
}
|
|
41
|
-
export {};
|
|
@@ -6,10 +6,8 @@ export * from './complete-password-reset-options.serializer';
|
|
|
6
6
|
export * from './create-email-verification-challenge.serializer';
|
|
7
7
|
export * from './create-password-reset-challenge.serializer';
|
|
8
8
|
export * from './create-user-options.serializer';
|
|
9
|
-
export * from './revoke-session-options.serializer';
|
|
10
9
|
export * from './send-magic-auth-code-options.serializer';
|
|
11
10
|
export * from './session.serializer';
|
|
12
11
|
export * from './update-user-options.serializer';
|
|
13
12
|
export * from './update-user-password-options.serializer';
|
|
14
13
|
export * from './user.serializer';
|
|
15
|
-
export * from './verify-session.serializer';
|
|
@@ -22,10 +22,8 @@ __exportStar(require("./complete-password-reset-options.serializer"), exports);
|
|
|
22
22
|
__exportStar(require("./create-email-verification-challenge.serializer"), exports);
|
|
23
23
|
__exportStar(require("./create-password-reset-challenge.serializer"), exports);
|
|
24
24
|
__exportStar(require("./create-user-options.serializer"), exports);
|
|
25
|
-
__exportStar(require("./revoke-session-options.serializer"), exports);
|
|
26
25
|
__exportStar(require("./send-magic-auth-code-options.serializer"), exports);
|
|
27
26
|
__exportStar(require("./session.serializer"), exports);
|
|
28
27
|
__exportStar(require("./update-user-options.serializer"), exports);
|
|
29
28
|
__exportStar(require("./update-user-password-options.serializer"), exports);
|
|
30
29
|
__exportStar(require("./user.serializer"), exports);
|
|
31
|
-
__exportStar(require("./verify-session.serializer"), exports);
|
|
@@ -4,6 +4,6 @@ exports.serializeUpdateUserOptions = void 0;
|
|
|
4
4
|
const serializeUpdateUserOptions = (options) => ({
|
|
5
5
|
first_name: options.firstName,
|
|
6
6
|
last_name: options.lastName,
|
|
7
|
-
|
|
7
|
+
email_verified: options.emailVerified,
|
|
8
8
|
});
|
|
9
9
|
exports.serializeUpdateUserOptions = serializeUpdateUserOptions;
|
|
@@ -1,24 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deserializeUser = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
switch (user.user_type) {
|
|
16
|
-
case 'managed':
|
|
17
|
-
return Object.assign(Object.assign({}, baseUser), { userType: user.user_type, ssoProfileId: user.sso_profile_id });
|
|
18
|
-
case 'unmanaged':
|
|
19
|
-
return Object.assign(Object.assign({}, baseUser), { userType: user.user_type, emailVerifiedAt: user.email_verified_at, googleOauthProfileId: user.google_oauth_profile_id, microsoftOauthProfileId: user.microsoft_oauth_profile_id });
|
|
20
|
-
default:
|
|
21
|
-
throw new exceptions_1.UnexpectedUserTypeException(user);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
4
|
+
const deserializeUser = (user) => ({
|
|
5
|
+
object: user.object,
|
|
6
|
+
id: user.id,
|
|
7
|
+
email: user.email,
|
|
8
|
+
emailVerified: user.email_verified,
|
|
9
|
+
firstName: user.first_name,
|
|
10
|
+
lastName: user.last_name,
|
|
11
|
+
createdAt: user.created_at,
|
|
12
|
+
updatedAt: user.updated_at,
|
|
13
|
+
});
|
|
24
14
|
exports.deserializeUser = deserializeUser;
|
package/lib/users/users.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WorkOS } from '../workos';
|
|
2
2
|
import { AutoPaginatable } from '../common/utils/pagination';
|
|
3
|
-
import { AddUserToOrganizationOptions, AuthenticateUserWithMagicAuthOptions, AuthenticateUserWithPasswordOptions,
|
|
3
|
+
import { AddUserToOrganizationOptions, AuthenticateUserWithCodeOptions, AuthenticateUserWithMagicAuthOptions, AuthenticateUserWithPasswordOptions, AuthenticationResponse, CompletePasswordResetOptions, CreateEmailVerificationChallengeOptions, CreateEmailVerificationChallengeResponse, CreatePasswordResetChallengeOptions, CreatePasswordResetChallengeResponse, CreateUserOptions, DeleteUserOptions, EnrollUserInMfaFactorOptions, ListUsersOptions, MagicAuthChallenge, RemoveUserFromOrganizationOptions, SendMagicAuthCodeOptions, UpdateUserOptions, UpdateUserPasswordOptions, User, VerifyEmailOptions } from './interfaces';
|
|
4
4
|
import { Challenge, Factor } from '../mfa/interfaces';
|
|
5
5
|
export declare class Users {
|
|
6
6
|
private readonly workos;
|
|
@@ -11,12 +11,9 @@ export declare class Users {
|
|
|
11
11
|
authenticateUserWithMagicAuth(payload: AuthenticateUserWithMagicAuthOptions): Promise<AuthenticationResponse>;
|
|
12
12
|
authenticateUserWithPassword(payload: AuthenticateUserWithPasswordOptions): Promise<AuthenticationResponse>;
|
|
13
13
|
authenticateUserWithCode(payload: AuthenticateUserWithCodeOptions): Promise<AuthenticationResponse>;
|
|
14
|
-
verifySession(payload: VerifySessionOptions): Promise<VerifySessionResponse>;
|
|
15
|
-
revokeSession(payload: RevokeSessionOptions): Promise<boolean>;
|
|
16
|
-
revokeAllSessionsForUser({ userId, }: RevokeAllSessionsForUserOptions): Promise<boolean>;
|
|
17
14
|
createEmailVerificationChallenge({ userId, verificationUrl, }: CreateEmailVerificationChallengeOptions): Promise<CreateEmailVerificationChallengeResponse>;
|
|
18
15
|
sendMagicAuthCode(options: SendMagicAuthCodeOptions): Promise<MagicAuthChallenge>;
|
|
19
|
-
|
|
16
|
+
verifyEmail({ code, userId }: VerifyEmailOptions): Promise<User>;
|
|
20
17
|
createPasswordResetChallenge(payload: CreatePasswordResetChallengeOptions): Promise<CreatePasswordResetChallengeResponse>;
|
|
21
18
|
completePasswordReset(payload: CompletePasswordResetOptions): Promise<User>;
|
|
22
19
|
addUserToOrganization({ userId, organizationId, }: AddUserToOrganizationOptions): Promise<User>;
|
|
@@ -27,4 +24,5 @@ export declare class Users {
|
|
|
27
24
|
authenticationFactor: Factor;
|
|
28
25
|
authenticationChallenge: Challenge;
|
|
29
26
|
}>;
|
|
27
|
+
deleteUser(payload: DeleteUserOptions): Promise<void>;
|
|
30
28
|
}
|
package/lib/users/users.js
CHANGED
|
@@ -54,24 +54,6 @@ class Users {
|
|
|
54
54
|
return (0, serializers_1.deserializeAuthenticationResponse)(data);
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
verifySession(payload) {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
const { data } = yield this.workos.post('/users/sessions/verify', (0, serializers_1.serializeVerifySessionOptions)(payload));
|
|
60
|
-
return (0, serializers_1.deserializeVerifySessionResponse)(data);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
revokeSession(payload) {
|
|
64
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
const { data } = yield this.workos.post('/users/sessions/revocations', (0, serializers_1.serializeRevokeSessionOptions)(payload));
|
|
66
|
-
return data;
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
revokeAllSessionsForUser({ userId, }) {
|
|
70
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
const { data } = yield this.workos.delete(`/users/${userId}/sessions`);
|
|
72
|
-
return data;
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
57
|
createEmailVerificationChallenge({ userId, verificationUrl, }) {
|
|
76
58
|
return __awaiter(this, void 0, void 0, function* () {
|
|
77
59
|
const { data } = yield this.workos.post(`/users/${userId}/email_verification_challenge`, {
|
|
@@ -86,10 +68,10 @@ class Users {
|
|
|
86
68
|
return data;
|
|
87
69
|
});
|
|
88
70
|
}
|
|
89
|
-
|
|
71
|
+
verifyEmail({ code, userId }) {
|
|
90
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
-
const { data } = yield this.workos.post(
|
|
92
|
-
|
|
73
|
+
const { data } = yield this.workos.post(`/users/${userId}/verify_email`, {
|
|
74
|
+
code,
|
|
93
75
|
});
|
|
94
76
|
return (0, serializers_1.deserializeUser)(data);
|
|
95
77
|
});
|
|
@@ -141,5 +123,10 @@ class Users {
|
|
|
141
123
|
};
|
|
142
124
|
});
|
|
143
125
|
}
|
|
126
|
+
deleteUser(payload) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
yield this.workos.delete(`/users/${payload.userId}`);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
144
131
|
}
|
|
145
132
|
exports.Users = Users;
|
package/lib/users/users.spec.js
CHANGED
|
@@ -34,8 +34,7 @@ describe('UserManagement', () => {
|
|
|
34
34
|
email: 'test01@example.com',
|
|
35
35
|
firstName: 'Test 01',
|
|
36
36
|
lastName: 'User',
|
|
37
|
-
|
|
38
|
-
emailVerifiedAt: '2023-07-17T20:07:20.055Z',
|
|
37
|
+
emailVerified: true,
|
|
39
38
|
});
|
|
40
39
|
}));
|
|
41
40
|
});
|
|
@@ -63,14 +62,12 @@ describe('UserManagement', () => {
|
|
|
63
62
|
yield workos.users.listUsers({
|
|
64
63
|
email: 'foo@example.com',
|
|
65
64
|
organization: 'org_someorg',
|
|
66
|
-
type: 'managed',
|
|
67
65
|
after: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
68
66
|
limit: 10,
|
|
69
67
|
});
|
|
70
68
|
expect(mock.history.get[0].params).toEqual({
|
|
71
69
|
email: 'foo@example.com',
|
|
72
70
|
organization: 'org_someorg',
|
|
73
|
-
type: 'managed',
|
|
74
71
|
after: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
75
72
|
limit: 10,
|
|
76
73
|
order: 'desc',
|
|
@@ -93,8 +90,7 @@ describe('UserManagement', () => {
|
|
|
93
90
|
email: 'test01@example.com',
|
|
94
91
|
firstName: 'Test 01',
|
|
95
92
|
lastName: 'User',
|
|
96
|
-
|
|
97
|
-
emailVerifiedAt: '2023-07-17T20:07:20.055Z',
|
|
93
|
+
emailVerified: true,
|
|
98
94
|
createdAt: '2023-07-18T02:07:19.911Z',
|
|
99
95
|
updatedAt: '2023-07-18T02:07:19.911Z',
|
|
100
96
|
});
|
|
@@ -172,54 +168,6 @@ describe('UserManagement', () => {
|
|
|
172
168
|
});
|
|
173
169
|
}));
|
|
174
170
|
});
|
|
175
|
-
describe('verifySession', () => {
|
|
176
|
-
it('sends a request to verify the session', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
177
|
-
mock.onPost('/users/sessions/verify').reply(200, {
|
|
178
|
-
user: user_json_1.default,
|
|
179
|
-
session: session_json_1.default,
|
|
180
|
-
});
|
|
181
|
-
const resp = yield workos.users.verifySession({
|
|
182
|
-
clientId: 'proj_something',
|
|
183
|
-
token: 'really-long-token',
|
|
184
|
-
});
|
|
185
|
-
expect(mock.history.post[0].url).toEqual('/users/sessions/verify');
|
|
186
|
-
expect(resp).toMatchObject({
|
|
187
|
-
user: {
|
|
188
|
-
email: 'test01@example.com',
|
|
189
|
-
},
|
|
190
|
-
session: {
|
|
191
|
-
id: 'session_01H5K05VP5CPCXJA5Z7G191GS4',
|
|
192
|
-
token: 'really-long-token',
|
|
193
|
-
},
|
|
194
|
-
});
|
|
195
|
-
}));
|
|
196
|
-
});
|
|
197
|
-
describe('revokeSession', () => {
|
|
198
|
-
it('can revoke with the session_id', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
199
|
-
mock.onPost('/users/sessions/revocations').reply(200, true);
|
|
200
|
-
const revoked = yield workos.users.revokeSession({
|
|
201
|
-
sessionId: 'session_01H5K05VP5CPCXJA5Z7G191GS4',
|
|
202
|
-
});
|
|
203
|
-
expect(mock.history.post[0].url).toEqual('/users/sessions/revocations');
|
|
204
|
-
expect(revoked).toEqual(true);
|
|
205
|
-
}));
|
|
206
|
-
it('can revoke with the session_token', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
207
|
-
mock.onPost('/users/sessions/revocations').reply(200, true);
|
|
208
|
-
const revoked = yield workos.users.revokeSession({
|
|
209
|
-
sessionToken: 'really-long-token',
|
|
210
|
-
});
|
|
211
|
-
expect(mock.history.post[0].url).toEqual('/users/sessions/revocations');
|
|
212
|
-
expect(revoked).toEqual(true);
|
|
213
|
-
}));
|
|
214
|
-
});
|
|
215
|
-
describe('revokeAllSessionsForUser', () => {
|
|
216
|
-
it('sends a revokeAllSessionsForUser request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
217
|
-
mock.onDelete(`/users/${userId}/sessions`).reply(200, true);
|
|
218
|
-
const revoked = yield workos.users.revokeAllSessionsForUser({ userId });
|
|
219
|
-
expect(mock.history.delete[0].url).toEqual(`/users/${userId}/sessions`);
|
|
220
|
-
expect(revoked).toEqual(true);
|
|
221
|
-
}));
|
|
222
|
-
});
|
|
223
171
|
describe('createEmailVerificationChallenge', () => {
|
|
224
172
|
it('sends a Create Email Verification Challenge request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
225
173
|
mock.onPost(`/users/${userId}/email_verification_challenge`).reply(200, {
|
|
@@ -238,11 +186,14 @@ describe('UserManagement', () => {
|
|
|
238
186
|
},
|
|
239
187
|
});
|
|
240
188
|
}));
|
|
241
|
-
describe('
|
|
189
|
+
describe('verifyEmail', () => {
|
|
242
190
|
it('sends a Complete Email Verification request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
243
|
-
mock.onPost(`/users/
|
|
244
|
-
const resp = yield workos.users.
|
|
245
|
-
|
|
191
|
+
mock.onPost(`/users/user_123/verify_email`).reply(200, user_json_1.default);
|
|
192
|
+
const resp = yield workos.users.verifyEmail({
|
|
193
|
+
userId: 'user_123',
|
|
194
|
+
code: '123456',
|
|
195
|
+
});
|
|
196
|
+
expect(mock.history.post[0].url).toEqual(`/users/user_123/verify_email`);
|
|
246
197
|
expect(resp).toMatchObject({
|
|
247
198
|
email: 'test01@example.com',
|
|
248
199
|
});
|
|
@@ -335,13 +286,13 @@ describe('UserManagement', () => {
|
|
|
335
286
|
userId,
|
|
336
287
|
firstName: 'Dane',
|
|
337
288
|
lastName: 'Williams',
|
|
338
|
-
|
|
289
|
+
emailVerified: true,
|
|
339
290
|
});
|
|
340
291
|
expect(mock.history.put[0].url).toEqual(`/users/${userId}`);
|
|
341
292
|
expect(JSON.parse(mock.history.put[0].data)).toEqual({
|
|
342
293
|
first_name: 'Dane',
|
|
343
294
|
last_name: 'Williams',
|
|
344
|
-
|
|
295
|
+
email_verified: true,
|
|
345
296
|
});
|
|
346
297
|
expect(resp).toMatchObject({
|
|
347
298
|
email: 'test01@example.com',
|
|
@@ -438,4 +389,14 @@ describe('UserManagement', () => {
|
|
|
438
389
|
});
|
|
439
390
|
}));
|
|
440
391
|
});
|
|
392
|
+
describe('deleteUser', () => {
|
|
393
|
+
it('sends a deleteUser request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
394
|
+
mock.onDelete(`/users/${userId}`).reply(200);
|
|
395
|
+
const resp = yield workos.users.deleteUser({
|
|
396
|
+
userId,
|
|
397
|
+
});
|
|
398
|
+
expect(mock.history.delete[0].url).toEqual(`/users/${userId}`);
|
|
399
|
+
expect(resp).toBeUndefined();
|
|
400
|
+
}));
|
|
401
|
+
});
|
|
441
402
|
});
|
package/lib/workos.js
CHANGED
|
@@ -27,7 +27,7 @@ const mfa_1 = require("./mfa/mfa");
|
|
|
27
27
|
const audit_logs_1 = require("./audit-logs/audit-logs");
|
|
28
28
|
const users_1 = require("./users/users");
|
|
29
29
|
const bad_request_exception_1 = require("./common/exceptions/bad-request.exception");
|
|
30
|
-
const VERSION = '3.
|
|
30
|
+
const VERSION = '3.4.0';
|
|
31
31
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
32
32
|
class WorkOS {
|
|
33
33
|
constructor(key, options = {}) {
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnexpectedUserTypeException = void 0;
|
|
4
|
-
class UnexpectedUserTypeException extends Error {
|
|
5
|
-
constructor(user) {
|
|
6
|
-
super();
|
|
7
|
-
this.message = `Unsupported user type: ${user.user_type} received from API.`;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.UnexpectedUserTypeException = UnexpectedUserTypeException;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type RevokeSessionOptions = SessionId | SessionToken;
|
|
2
|
-
export type SerializedRevokeSessionOptions = SerializedSessionId | SerializedSessionToken;
|
|
3
|
-
interface SessionId {
|
|
4
|
-
sessionId: string;
|
|
5
|
-
}
|
|
6
|
-
interface SerializedSessionId {
|
|
7
|
-
session_id: string;
|
|
8
|
-
}
|
|
9
|
-
interface SessionToken {
|
|
10
|
-
sessionToken: string;
|
|
11
|
-
}
|
|
12
|
-
interface SerializedSessionToken {
|
|
13
|
-
session_token: string;
|
|
14
|
-
}
|
|
15
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { User, UserResponse } from './user.interface';
|
|
2
|
-
import { Session, SessionResponse } from './session.interface';
|
|
3
|
-
export interface VerifySessionOptions {
|
|
4
|
-
token: string;
|
|
5
|
-
clientId: string;
|
|
6
|
-
}
|
|
7
|
-
export interface SerializedVerifySessionOptions {
|
|
8
|
-
token: string;
|
|
9
|
-
client_id: string;
|
|
10
|
-
}
|
|
11
|
-
export interface VerifySessionResponse {
|
|
12
|
-
session: Session;
|
|
13
|
-
user: User;
|
|
14
|
-
}
|
|
15
|
-
export interface VerifySessionResponseResponse {
|
|
16
|
-
session: SessionResponse;
|
|
17
|
-
user: UserResponse;
|
|
18
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serializeRevokeSessionOptions = void 0;
|
|
4
|
-
const serializeRevokeSessionOptions = (options) => {
|
|
5
|
-
if ('sessionId' in options) {
|
|
6
|
-
return {
|
|
7
|
-
session_id: options.sessionId,
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
return {
|
|
11
|
-
session_token: options.sessionToken,
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
exports.serializeRevokeSessionOptions = serializeRevokeSessionOptions;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { SerializedVerifySessionOptions, VerifySessionOptions, VerifySessionResponse, VerifySessionResponseResponse } from '../interfaces';
|
|
2
|
-
export declare const deserializeVerifySessionResponse: (verifySessionResponse: VerifySessionResponseResponse) => VerifySessionResponse;
|
|
3
|
-
export declare const serializeVerifySessionOptions: (options: VerifySessionOptions) => SerializedVerifySessionOptions;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serializeVerifySessionOptions = exports.deserializeVerifySessionResponse = void 0;
|
|
4
|
-
const session_serializer_1 = require("./session.serializer");
|
|
5
|
-
const user_serializer_1 = require("./user.serializer");
|
|
6
|
-
const deserializeVerifySessionResponse = (verifySessionResponse) => ({
|
|
7
|
-
session: (0, session_serializer_1.deserializeSession)(verifySessionResponse.session),
|
|
8
|
-
user: (0, user_serializer_1.deserializeUser)(verifySessionResponse.user),
|
|
9
|
-
});
|
|
10
|
-
exports.deserializeVerifySessionResponse = deserializeVerifySessionResponse;
|
|
11
|
-
const serializeVerifySessionOptions = (options) => ({
|
|
12
|
-
token: options.token,
|
|
13
|
-
client_id: options.clientId,
|
|
14
|
-
});
|
|
15
|
-
exports.serializeVerifySessionOptions = serializeVerifySessionOptions;
|
|
File without changes
|
|
File without changes
|