@workos-inc/node 3.9.1 → 5.0.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 +45 -3
- package/lib/common/serializers/event.serializer.js +9 -0
- package/lib/directory-sync/directory-sync.spec.js +2 -2
- package/lib/directory-sync/interfaces/directory-user.interface.d.ts +14 -14
- package/lib/directory-sync/interfaces/directory.interface.d.ts +1 -1
- package/lib/index.d.ts +1 -2
- package/lib/index.js +1 -2
- package/lib/mfa/interfaces/challenge.interface.d.ts +2 -2
- package/lib/mfa/interfaces/factor.interface.d.ts +23 -3
- package/lib/mfa/interfaces/totp.interface.d.ts +4 -0
- package/lib/mfa/mfa.d.ts +2 -2
- package/lib/mfa/mfa.js +1 -1
- package/lib/mfa/mfa.spec.js +0 -6
- package/lib/mfa/serializers/factor.serializer.d.ts +2 -1
- package/lib/mfa/serializers/factor.serializer.js +3 -1
- package/lib/mfa/serializers/totp.serializer.d.ts +2 -1
- package/lib/mfa/serializers/totp.serializer.js +17 -8
- package/lib/sso/interfaces/authorization-url-options.interface.d.ts +2 -2
- package/lib/sso/interfaces/get-profile-and-token-options.interface.d.ts +1 -1
- package/lib/sso/sso.d.ts +2 -2
- package/lib/sso/sso.js +5 -5
- package/lib/sso/sso.spec.js +30 -30
- package/lib/user-management/fixtures/invitation.json +13 -0
- package/lib/{users → user-management}/fixtures/list-factors.json +0 -3
- package/lib/user-management/fixtures/list-invitations.json +22 -0
- package/lib/user-management/fixtures/list-organization-memberships.json +17 -0
- package/lib/user-management/fixtures/organization-membership.json +8 -0
- package/lib/user-management/interfaces/authenticate-with-code-options.interface.d.ts +11 -0
- package/lib/user-management/interfaces/authenticate-with-email-verification-options.interface.d.ts +13 -0
- package/lib/user-management/interfaces/authenticate-with-magic-auth-options.interface.d.ts +15 -0
- package/lib/user-management/interfaces/authenticate-with-options-base.interface.d.ts +11 -0
- package/lib/user-management/interfaces/authenticate-with-organization-selection.interface.d.ts +13 -0
- package/lib/user-management/interfaces/authenticate-with-password-options.interface.d.ts +13 -0
- package/lib/{users → user-management}/interfaces/authenticate-with-totp-options.interface.d.ts +3 -9
- package/lib/{users → user-management}/interfaces/authentication-response.interface.d.ts +2 -0
- package/lib/user-management/interfaces/authorization-url-options.interface.d.ts +10 -0
- package/lib/user-management/interfaces/create-organization-membership-options.interface.d.ts +8 -0
- package/lib/{users → user-management}/interfaces/enroll-auth-factor.interface.d.ts +4 -4
- package/lib/user-management/interfaces/factor.interface.d.ts +37 -0
- package/lib/{users → user-management}/interfaces/index.d.ts +2 -5
- package/lib/{users → user-management}/interfaces/index.js +2 -5
- package/lib/user-management/interfaces/invitation.interface.d.ts +26 -0
- package/lib/user-management/interfaces/list-invitations-options.interface.d.ts +9 -0
- package/lib/user-management/interfaces/list-organization-memberships-options.interface.d.ts +9 -0
- package/lib/{users → user-management}/interfaces/list-users-options.interface.d.ts +5 -1
- package/lib/user-management/interfaces/organization-membership.interface.d.ts +16 -0
- package/lib/user-management/interfaces/send-invitation-options.interface.d.ts +12 -0
- package/lib/user-management/interfaces/send-password-reset-email-options.interface.d.ts +8 -0
- package/lib/{users → user-management}/interfaces/update-user-options.interface.d.ts +6 -0
- package/lib/user-management/interfaces/update-user-password-options.interface.js +2 -0
- package/lib/user-management/interfaces/user.interface.js +2 -0
- package/lib/user-management/interfaces/verify-email-options.interface.d.ts +7 -0
- package/lib/user-management/interfaces/verify-email-options.interface.js +2 -0
- package/lib/user-management/serializers/authenticate-with-email-verification.serializer.d.ts +2 -0
- package/lib/user-management/serializers/authenticate-with-email-verification.serializer.js +13 -0
- package/lib/{users → user-management}/serializers/authenticate-with-magic-auth-options.serializer.js +2 -1
- package/lib/user-management/serializers/authenticate-with-organization-selection-options.serializer.d.ts +2 -0
- package/lib/user-management/serializers/authenticate-with-organization-selection-options.serializer.js +13 -0
- package/lib/{users → user-management}/serializers/authentication-response.serializer.js +1 -0
- package/lib/user-management/serializers/create-organization-membership-options.serializer.d.ts +2 -0
- package/lib/user-management/serializers/create-organization-membership-options.serializer.js +8 -0
- package/lib/user-management/serializers/factor.serializer.d.ts +3 -0
- package/lib/user-management/serializers/factor.serializer.js +24 -0
- package/lib/{users → user-management}/serializers/index.d.ts +1 -0
- package/lib/{users → user-management}/serializers/index.js +1 -0
- package/lib/user-management/serializers/invitation.serializer.d.ts +2 -0
- package/lib/user-management/serializers/invitation.serializer.js +17 -0
- package/lib/user-management/serializers/list-invitations-options.serializer.d.ts +2 -0
- package/lib/user-management/serializers/list-invitations-options.serializer.js +12 -0
- package/lib/user-management/serializers/list-organization-memberships-options.serializer.d.ts +2 -0
- package/lib/user-management/serializers/list-organization-memberships-options.serializer.js +12 -0
- package/lib/user-management/serializers/list-users-options.serializer.d.ts +2 -0
- package/lib/user-management/serializers/list-users-options.serializer.js +12 -0
- package/lib/user-management/serializers/organization-membership.serializer.d.ts +2 -0
- package/lib/user-management/serializers/organization-membership.serializer.js +12 -0
- package/lib/user-management/serializers/send-invitation-options.serializer.d.ts +2 -0
- package/lib/user-management/serializers/send-invitation-options.serializer.js +10 -0
- package/lib/user-management/serializers/send-password-reset-email.serializer.d.ts +2 -0
- package/lib/user-management/serializers/send-password-reset-email.serializer.js +8 -0
- package/lib/{users → user-management}/serializers/update-user-options.serializer.js +3 -0
- package/lib/user-management/user-management.d.ts +54 -0
- package/lib/user-management/user-management.js +215 -0
- package/lib/user-management/user-management.spec.js +745 -0
- package/lib/workos.d.ts +2 -4
- package/lib/workos.js +3 -5
- package/package.json +1 -1
- package/lib/audit-trail/audit-trail.d.ts +0 -12
- package/lib/audit-trail/audit-trail.js +0 -31
- package/lib/audit-trail/audit-trail.spec.js +0 -183
- package/lib/audit-trail/interfaces/create-event-options.interface.d.ts +0 -3
- package/lib/audit-trail/interfaces/event-options.interface.d.ts +0 -14
- package/lib/audit-trail/interfaces/event.interface.d.ts +0 -23
- package/lib/audit-trail/interfaces/index.d.ts +0 -4
- package/lib/audit-trail/interfaces/list-events-options.interface.d.ts +0 -16
- package/lib/users/interfaces/add-user-to-organization-options.interface.d.ts +0 -7
- package/lib/users/interfaces/authenticate-with-code-options.interface.d.ts +0 -17
- package/lib/users/interfaces/authenticate-with-magic-auth-options.interface.d.ts +0 -19
- package/lib/users/interfaces/authenticate-with-password-options.interface.d.ts +0 -19
- package/lib/users/interfaces/delete-user-options.interface.d.ts +0 -3
- package/lib/users/interfaces/remove-user-from-organization-options.interface.d.ts +0 -4
- package/lib/users/interfaces/send-password-reset-options.interface.d.ts +0 -17
- package/lib/users/interfaces/verify-email-code-options.interface.d.ts +0 -7
- package/lib/users/serializers/send-password-reset-email.serializer.d.ts +0 -3
- package/lib/users/serializers/send-password-reset-email.serializer.js +0 -14
- package/lib/users/users.d.ts +0 -38
- package/lib/users/users.js +0 -140
- package/lib/users/users.spec.d.ts +0 -1
- package/lib/users/users.spec.js +0 -462
- /package/lib/{users → user-management}/fixtures/list-users.json +0 -0
- /package/lib/{users → user-management}/fixtures/user.json +0 -0
- /package/lib/{users → user-management}/interfaces/authenticate-with-code-options.interface.js +0 -0
- /package/lib/{audit-trail/interfaces/create-event-options.interface.js → user-management/interfaces/authenticate-with-email-verification-options.interface.js} +0 -0
- /package/lib/{users → user-management}/interfaces/authenticate-with-magic-auth-options.interface.js +0 -0
- /package/lib/{audit-trail/interfaces/event-options.interface.js → user-management/interfaces/authenticate-with-options-base.interface.js} +0 -0
- /package/lib/{audit-trail/interfaces/event.interface.js → user-management/interfaces/authenticate-with-organization-selection.interface.js} +0 -0
- /package/lib/{users → user-management}/interfaces/authenticate-with-password-options.interface.js +0 -0
- /package/lib/{users → user-management}/interfaces/authenticate-with-totp-options.interface.js +0 -0
- /package/lib/{users → user-management}/interfaces/authentication-response.interface.js +0 -0
- /package/lib/{audit-trail/interfaces/index.js → user-management/interfaces/authorization-url-options.interface.js} +0 -0
- /package/lib/{audit-trail/interfaces/list-events-options.interface.js → user-management/interfaces/create-organization-membership-options.interface.js} +0 -0
- /package/lib/{users → user-management}/interfaces/create-user-options.interface.d.ts +0 -0
- /package/lib/{users → user-management}/interfaces/create-user-options.interface.js +0 -0
- /package/lib/{users → user-management}/interfaces/enroll-auth-factor.interface.js +0 -0
- /package/lib/{users/interfaces/add-user-to-organization-options.interface.js → user-management/interfaces/factor.interface.js} +0 -0
- /package/lib/{users/interfaces/delete-user-options.interface.js → user-management/interfaces/invitation.interface.js} +0 -0
- /package/lib/{users → user-management}/interfaces/list-auth-factors-options.interface.d.ts +0 -0
- /package/lib/{users → user-management}/interfaces/list-auth-factors-options.interface.js +0 -0
- /package/lib/{users/interfaces/list-users-options.interface.js → user-management/interfaces/list-invitations-options.interface.js} +0 -0
- /package/lib/{users/interfaces/remove-user-from-organization-options.interface.js → user-management/interfaces/list-organization-memberships-options.interface.js} +0 -0
- /package/lib/{users/interfaces/reset-password-options.interface.js → user-management/interfaces/list-users-options.interface.js} +0 -0
- /package/lib/{users/interfaces/send-magic-auth-code-options.interface.js → user-management/interfaces/organization-membership.interface.js} +0 -0
- /package/lib/{users → user-management}/interfaces/reset-password-options.interface.d.ts +0 -0
- /package/lib/{users/interfaces/send-password-reset-options.interface.js → user-management/interfaces/reset-password-options.interface.js} +0 -0
- /package/lib/{users/interfaces/send-verification-email-options.js → user-management/interfaces/send-invitation-options.interface.js} +0 -0
- /package/lib/{users → user-management}/interfaces/send-magic-auth-code-options.interface.d.ts +0 -0
- /package/lib/{users/interfaces/update-user-options.interface.js → user-management/interfaces/send-magic-auth-code-options.interface.js} +0 -0
- /package/lib/{users/interfaces/update-user-password-options.interface.js → user-management/interfaces/send-password-reset-email-options.interface.js} +0 -0
- /package/lib/{users → user-management}/interfaces/send-verification-email-options.d.ts +0 -0
- /package/lib/{users/interfaces/user.interface.js → user-management/interfaces/send-verification-email-options.js} +0 -0
- /package/lib/{users/interfaces/verify-email-code-options.interface.js → user-management/interfaces/update-user-options.interface.js} +0 -0
- /package/lib/{users → user-management}/interfaces/update-user-password-options.interface.d.ts +0 -0
- /package/lib/{users → user-management}/interfaces/user.interface.d.ts +0 -0
- /package/lib/{users → user-management}/serializers/authenticate-with-code-options.serializer.d.ts +0 -0
- /package/lib/{users → user-management}/serializers/authenticate-with-code-options.serializer.js +0 -0
- /package/lib/{users → user-management}/serializers/authenticate-with-magic-auth-options.serializer.d.ts +0 -0
- /package/lib/{users → user-management}/serializers/authenticate-with-password-options.serializer.d.ts +0 -0
- /package/lib/{users → user-management}/serializers/authenticate-with-password-options.serializer.js +0 -0
- /package/lib/{users → user-management}/serializers/authenticate-with-totp-options.serializer.d.ts +0 -0
- /package/lib/{users → user-management}/serializers/authenticate-with-totp-options.serializer.js +0 -0
- /package/lib/{users → user-management}/serializers/authentication-response.serializer.d.ts +0 -0
- /package/lib/{users → user-management}/serializers/create-user-options.serializer.d.ts +0 -0
- /package/lib/{users → user-management}/serializers/create-user-options.serializer.js +0 -0
- /package/lib/{users → user-management}/serializers/enroll-auth-factor-options.serializer.d.ts +0 -0
- /package/lib/{users → user-management}/serializers/enroll-auth-factor-options.serializer.js +0 -0
- /package/lib/{users → user-management}/serializers/reset-password-options.serializer.d.ts +0 -0
- /package/lib/{users → user-management}/serializers/reset-password-options.serializer.js +0 -0
- /package/lib/{users → user-management}/serializers/send-magic-auth-code-options.serializer.d.ts +0 -0
- /package/lib/{users → user-management}/serializers/send-magic-auth-code-options.serializer.js +0 -0
- /package/lib/{users → user-management}/serializers/update-user-options.serializer.d.ts +0 -0
- /package/lib/{users → user-management}/serializers/update-user-password-options.serializer.d.ts +0 -0
- /package/lib/{users → user-management}/serializers/update-user-password-options.serializer.js +0 -0
- /package/lib/{users → user-management}/serializers/user.serializer.d.ts +0 -0
- /package/lib/{users → user-management}/serializers/user.serializer.js +0 -0
- /package/lib/{audit-trail/audit-trail.spec.d.ts → user-management/user-management.spec.d.ts} +0 -0
package/lib/users/users.js
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Users = void 0;
|
|
13
|
-
const pagination_1 = require("../common/utils/pagination");
|
|
14
|
-
const serializers_1 = require("./serializers");
|
|
15
|
-
const fetch_and_deserialize_1 = require("../common/utils/fetch-and-deserialize");
|
|
16
|
-
const serializers_2 = require("../mfa/serializers");
|
|
17
|
-
class Users {
|
|
18
|
-
constructor(workos) {
|
|
19
|
-
this.workos = workos;
|
|
20
|
-
}
|
|
21
|
-
getUser(userId) {
|
|
22
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const { data } = yield this.workos.get(`/users/${userId}`);
|
|
24
|
-
return (0, serializers_1.deserializeUser)(data);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
listUsers(options) {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/users', serializers_1.deserializeUser, options), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/users', serializers_1.deserializeUser, params), options);
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
createUser(payload) {
|
|
33
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
const { data } = yield this.workos.post('/users', (0, serializers_1.serializeCreateUserOptions)(payload));
|
|
35
|
-
return (0, serializers_1.deserializeUser)(data);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
authenticateWithMagicAuth(payload) {
|
|
39
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
const { data } = yield this.workos.post('/users/authenticate', (0, serializers_1.serializeAuthenticateWithMagicAuthOptions)(Object.assign(Object.assign({}, payload), { clientSecret: this.workos.key })));
|
|
41
|
-
return (0, serializers_1.deserializeAuthenticationResponse)(data);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
authenticateWithPassword(payload) {
|
|
45
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
const { data } = yield this.workos.post('/users/authenticate', (0, serializers_1.serializeAuthenticateWithPasswordOptions)(Object.assign(Object.assign({}, payload), { clientSecret: this.workos.key })));
|
|
47
|
-
return (0, serializers_1.deserializeAuthenticationResponse)(data);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
authenticateWithCode(payload) {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
const { data } = yield this.workos.post('/users/authenticate', (0, serializers_1.serializeAuthenticateWithCodeOptions)(Object.assign(Object.assign({}, payload), { clientSecret: this.workos.key })));
|
|
53
|
-
return (0, serializers_1.deserializeAuthenticationResponse)(data);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
authenticateWithTotp(payload) {
|
|
57
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
const { data } = yield this.workos.post('/users/authenticate', (0, serializers_1.serializeAuthenticateWithTotpOptions)(Object.assign(Object.assign({}, payload), { clientSecret: this.workos.key })));
|
|
59
|
-
return (0, serializers_1.deserializeAuthenticationResponse)(data);
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
sendVerificationEmail({ userId, }) {
|
|
63
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
const { data } = yield this.workos.post(`/users/${userId}/send_verification_email`, {});
|
|
65
|
-
return { user: (0, serializers_1.deserializeUser)(data.user) };
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
sendMagicAuthCode(options) {
|
|
69
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
const { data } = yield this.workos.post('/users/magic_auth/send', (0, serializers_1.serializeSendMagicAuthCodeOptions)(options));
|
|
71
|
-
return { user: (0, serializers_1.deserializeUser)(data.user) };
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
verifyEmailCode({ code, userId, }) {
|
|
75
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
const { data } = yield this.workos.post(`/users/${userId}/verify_email_code`, {
|
|
77
|
-
code,
|
|
78
|
-
});
|
|
79
|
-
return { user: (0, serializers_1.deserializeUser)(data.user) };
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
sendPasswordResetEmail(payload) {
|
|
83
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
const { data } = yield this.workos.post('/users/send_password_reset_email', (0, serializers_1.serializeSendPasswordResetEmailOptions)(payload));
|
|
85
|
-
return (0, serializers_1.deserializeSendPasswordResetEmailResponse)(data);
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
resetPassword(payload) {
|
|
89
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
const { data } = yield this.workos.post('/users/password_reset', (0, serializers_1.serializeResetPasswordOptions)(payload));
|
|
91
|
-
return { user: (0, serializers_1.deserializeUser)(data.user) };
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
addUserToOrganization({ userId, organizationId, }) {
|
|
95
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
-
const { data } = yield this.workos.post(`/users/${userId}/organizations`, {
|
|
97
|
-
organization_id: organizationId,
|
|
98
|
-
});
|
|
99
|
-
return (0, serializers_1.deserializeUser)(data);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
removeUserFromOrganization({ userId, organizationId, }) {
|
|
103
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
-
const { data } = yield this.workos.delete(`/users/${userId}/organizations/${organizationId}`);
|
|
105
|
-
return (0, serializers_1.deserializeUser)(data);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
updateUser(payload) {
|
|
109
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
-
const { data } = yield this.workos.put(`/users/${payload.userId}`, (0, serializers_1.serializeUpdateUserOptions)(payload));
|
|
111
|
-
return (0, serializers_1.deserializeUser)(data);
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
updateUserPassword(payload) {
|
|
115
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
-
const { data } = yield this.workos.put(`/users/${payload.userId}/password`, (0, serializers_1.serializeUpdateUserPasswordOptions)(payload));
|
|
117
|
-
return (0, serializers_1.deserializeUser)(data);
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
enrollAuthFactor(payload) {
|
|
121
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
-
const { data } = yield this.workos.post(`/users/${payload.userId}/auth/factors`, (0, serializers_1.serializeEnrollAuthFactorOptions)(payload));
|
|
123
|
-
return {
|
|
124
|
-
authenticationFactor: (0, serializers_2.deserializeFactor)(data.authentication_factor),
|
|
125
|
-
authenticationChallenge: (0, serializers_2.deserializeChallenge)(data.authentication_challenge),
|
|
126
|
-
};
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
listAuthFactors(options) {
|
|
130
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
-
return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/users/${options.userId}/auth/factors`, serializers_2.deserializeFactor, options), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/users/${options.userId}/auth/factors`, serializers_2.deserializeFactor, params), options);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
deleteUser(payload) {
|
|
135
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
yield this.workos.delete(`/users/${payload.userId}`);
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
exports.Users = Users;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/users/users.spec.js
DELETED
|
@@ -1,462 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const axios_1 = __importDefault(require("axios"));
|
|
16
|
-
const axios_mock_adapter_1 = __importDefault(require("axios-mock-adapter"));
|
|
17
|
-
const workos_1 = require("../workos");
|
|
18
|
-
const user_json_1 = __importDefault(require("./fixtures/user.json"));
|
|
19
|
-
const list_users_json_1 = __importDefault(require("./fixtures/list-users.json"));
|
|
20
|
-
const list_factors_json_1 = __importDefault(require("./fixtures/list-factors.json"));
|
|
21
|
-
const mock = new axios_mock_adapter_1.default(axios_1.default);
|
|
22
|
-
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
23
|
-
const userId = 'user_01H5JQDV7R7ATEYZDEG0W5PRYS';
|
|
24
|
-
describe('UserManagement', () => {
|
|
25
|
-
afterEach(() => mock.resetHistory());
|
|
26
|
-
describe('getUser', () => {
|
|
27
|
-
it('sends a Get User request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
-
mock.onGet(`/users/${userId}`).reply(200, user_json_1.default);
|
|
29
|
-
const user = yield workos.users.getUser(userId);
|
|
30
|
-
expect(mock.history.get[0].url).toEqual(`/users/${userId}`);
|
|
31
|
-
expect(user).toMatchObject({
|
|
32
|
-
object: 'user',
|
|
33
|
-
id: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
34
|
-
email: 'test01@example.com',
|
|
35
|
-
firstName: 'Test 01',
|
|
36
|
-
lastName: 'User',
|
|
37
|
-
emailVerified: true,
|
|
38
|
-
});
|
|
39
|
-
}));
|
|
40
|
-
});
|
|
41
|
-
describe('listUsers', () => {
|
|
42
|
-
it('lists users', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
-
mock.onGet('/users').reply(200, list_users_json_1.default);
|
|
44
|
-
const userList = yield workos.users.listUsers();
|
|
45
|
-
expect(mock.history.get[0].url).toEqual('/users');
|
|
46
|
-
expect(userList).toMatchObject({
|
|
47
|
-
object: 'list',
|
|
48
|
-
data: [
|
|
49
|
-
{
|
|
50
|
-
object: 'user',
|
|
51
|
-
email: 'test01@example.com',
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
listMetadata: {
|
|
55
|
-
before: null,
|
|
56
|
-
after: null,
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
}));
|
|
60
|
-
it('sends the correct params when filtering', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
-
mock.onGet('/users').reply(200, list_users_json_1.default);
|
|
62
|
-
yield workos.users.listUsers({
|
|
63
|
-
email: 'foo@example.com',
|
|
64
|
-
organization: 'org_someorg',
|
|
65
|
-
after: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
66
|
-
limit: 10,
|
|
67
|
-
});
|
|
68
|
-
expect(mock.history.get[0].params).toEqual({
|
|
69
|
-
email: 'foo@example.com',
|
|
70
|
-
organization: 'org_someorg',
|
|
71
|
-
after: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
72
|
-
limit: 10,
|
|
73
|
-
order: 'desc',
|
|
74
|
-
});
|
|
75
|
-
}));
|
|
76
|
-
});
|
|
77
|
-
describe('createUser', () => {
|
|
78
|
-
it('sends a Create User request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
-
mock.onPost('/users').reply(200, user_json_1.default);
|
|
80
|
-
const user = yield workos.users.createUser({
|
|
81
|
-
email: 'test01@example.com',
|
|
82
|
-
password: 'extra-secure',
|
|
83
|
-
firstName: 'Test 01',
|
|
84
|
-
lastName: 'User',
|
|
85
|
-
emailVerified: true,
|
|
86
|
-
});
|
|
87
|
-
expect(mock.history.post[0].url).toEqual('/users');
|
|
88
|
-
expect(user).toMatchObject({
|
|
89
|
-
object: 'user',
|
|
90
|
-
email: 'test01@example.com',
|
|
91
|
-
firstName: 'Test 01',
|
|
92
|
-
lastName: 'User',
|
|
93
|
-
emailVerified: true,
|
|
94
|
-
createdAt: '2023-07-18T02:07:19.911Z',
|
|
95
|
-
updatedAt: '2023-07-18T02:07:19.911Z',
|
|
96
|
-
});
|
|
97
|
-
}));
|
|
98
|
-
});
|
|
99
|
-
describe('authenticateUserWithMagicAuth', () => {
|
|
100
|
-
it('sends a magic auth authentication request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
101
|
-
mock.onPost('/users/authenticate').reply(200, {
|
|
102
|
-
user: user_json_1.default,
|
|
103
|
-
});
|
|
104
|
-
const resp = yield workos.users.authenticateWithMagicAuth({
|
|
105
|
-
clientId: 'proj_whatever',
|
|
106
|
-
code: '123456',
|
|
107
|
-
userId: user_json_1.default.id,
|
|
108
|
-
});
|
|
109
|
-
expect(mock.history.post[0].url).toEqual('/users/authenticate');
|
|
110
|
-
expect(resp).toMatchObject({
|
|
111
|
-
user: {
|
|
112
|
-
email: 'test01@example.com',
|
|
113
|
-
},
|
|
114
|
-
});
|
|
115
|
-
}));
|
|
116
|
-
});
|
|
117
|
-
describe('authenticateUserWithPassword', () => {
|
|
118
|
-
it('sends an password authentication request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
119
|
-
mock.onPost('/users/authenticate').reply(200, {
|
|
120
|
-
user: user_json_1.default,
|
|
121
|
-
});
|
|
122
|
-
const resp = yield workos.users.authenticateWithPassword({
|
|
123
|
-
clientId: 'proj_whatever',
|
|
124
|
-
email: 'test01@example.com',
|
|
125
|
-
password: 'extra-secure',
|
|
126
|
-
});
|
|
127
|
-
expect(mock.history.post[0].url).toEqual('/users/authenticate');
|
|
128
|
-
expect(resp).toMatchObject({
|
|
129
|
-
user: {
|
|
130
|
-
email: 'test01@example.com',
|
|
131
|
-
},
|
|
132
|
-
});
|
|
133
|
-
}));
|
|
134
|
-
});
|
|
135
|
-
describe('authenticateUserWithCode', () => {
|
|
136
|
-
it('sends a token authentication request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
137
|
-
mock.onPost('/users/authenticate').reply(200, { user: user_json_1.default });
|
|
138
|
-
const resp = yield workos.users.authenticateWithCode({
|
|
139
|
-
clientId: 'proj_whatever',
|
|
140
|
-
code: 'or this',
|
|
141
|
-
});
|
|
142
|
-
expect(mock.history.post[0].url).toEqual('/users/authenticate');
|
|
143
|
-
expect(JSON.parse(mock.history.post[0].data)).toMatchObject({
|
|
144
|
-
client_secret: 'sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU',
|
|
145
|
-
grant_type: 'authorization_code',
|
|
146
|
-
});
|
|
147
|
-
expect(resp).toMatchObject({
|
|
148
|
-
user: {
|
|
149
|
-
email: 'test01@example.com',
|
|
150
|
-
},
|
|
151
|
-
});
|
|
152
|
-
}));
|
|
153
|
-
});
|
|
154
|
-
describe('authenticateUserWithTotp', () => {
|
|
155
|
-
it('sends a token authentication request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
156
|
-
mock.onPost('/users/authenticate').reply(200, { user: user_json_1.default });
|
|
157
|
-
const resp = yield workos.users.authenticateWithTotp({
|
|
158
|
-
clientId: 'proj_whatever',
|
|
159
|
-
code: 'or this',
|
|
160
|
-
authenticationChallengeId: 'auth_challenge_01H96FETXGTW1QMBSBT2T36PW0',
|
|
161
|
-
pendingAuthenticationToken: 'cTDQJTTkTkkVYxQUlKBIxEsFs',
|
|
162
|
-
});
|
|
163
|
-
expect(mock.history.post[0].url).toEqual('/users/authenticate');
|
|
164
|
-
expect(JSON.parse(mock.history.post[0].data)).toMatchObject({
|
|
165
|
-
client_id: 'proj_whatever',
|
|
166
|
-
code: 'or this',
|
|
167
|
-
client_secret: 'sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU',
|
|
168
|
-
grant_type: 'urn:workos:oauth:grant-type:mfa-totp',
|
|
169
|
-
authentication_challenge_id: 'auth_challenge_01H96FETXGTW1QMBSBT2T36PW0',
|
|
170
|
-
pending_authentication_token: 'cTDQJTTkTkkVYxQUlKBIxEsFs',
|
|
171
|
-
});
|
|
172
|
-
expect(resp).toMatchObject({
|
|
173
|
-
user: {
|
|
174
|
-
email: 'test01@example.com',
|
|
175
|
-
},
|
|
176
|
-
});
|
|
177
|
-
}));
|
|
178
|
-
});
|
|
179
|
-
describe('sendVerificationEmail', () => {
|
|
180
|
-
it('sends a Create Email Verification Challenge request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
181
|
-
mock
|
|
182
|
-
.onPost(`/users/${userId}/send_verification_email`)
|
|
183
|
-
.reply(200, { user: user_json_1.default });
|
|
184
|
-
const resp = yield workos.users.sendVerificationEmail({
|
|
185
|
-
userId,
|
|
186
|
-
});
|
|
187
|
-
expect(mock.history.post[0].url).toEqual(`/users/${userId}/send_verification_email`);
|
|
188
|
-
expect(resp).toMatchObject({
|
|
189
|
-
user: {
|
|
190
|
-
createdAt: '2023-07-18T02:07:19.911Z',
|
|
191
|
-
email: 'test01@example.com',
|
|
192
|
-
emailVerified: true,
|
|
193
|
-
firstName: 'Test 01',
|
|
194
|
-
id: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
195
|
-
lastName: 'User',
|
|
196
|
-
object: 'user',
|
|
197
|
-
updatedAt: '2023-07-18T02:07:19.911Z',
|
|
198
|
-
},
|
|
199
|
-
});
|
|
200
|
-
}));
|
|
201
|
-
describe('verifyEmailCode', () => {
|
|
202
|
-
it('sends a Complete Email Verification request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
203
|
-
mock
|
|
204
|
-
.onPost(`/users/user_123/verify_email_code`)
|
|
205
|
-
.reply(200, { user: user_json_1.default });
|
|
206
|
-
const resp = yield workos.users.verifyEmailCode({
|
|
207
|
-
userId: 'user_123',
|
|
208
|
-
code: '123456',
|
|
209
|
-
});
|
|
210
|
-
expect(mock.history.post[0].url).toEqual(`/users/user_123/verify_email_code`);
|
|
211
|
-
expect(resp.user).toMatchObject({
|
|
212
|
-
email: 'test01@example.com',
|
|
213
|
-
});
|
|
214
|
-
}));
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
describe('sendMagicAuthCode', () => {
|
|
218
|
-
it('sends a Send Magic Auth Code request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
219
|
-
mock
|
|
220
|
-
.onPost('/users/magic_auth/send', {
|
|
221
|
-
email: 'bob.loblaw@example.com',
|
|
222
|
-
})
|
|
223
|
-
.reply(200, {
|
|
224
|
-
user: {
|
|
225
|
-
object: 'user',
|
|
226
|
-
email: 'test01@example.com',
|
|
227
|
-
first_name: 'Test 01',
|
|
228
|
-
last_name: 'User',
|
|
229
|
-
email_verified: true,
|
|
230
|
-
created_at: '2023-07-18T02:07:19.911Z',
|
|
231
|
-
updated_at: '2023-07-18T02:07:19.911Z',
|
|
232
|
-
},
|
|
233
|
-
});
|
|
234
|
-
const response = yield workos.users.sendMagicAuthCode({
|
|
235
|
-
email: 'bob.loblaw@example.com',
|
|
236
|
-
});
|
|
237
|
-
expect(mock.history.post[0].url).toEqual('/users/magic_auth/send');
|
|
238
|
-
expect(response).toMatchObject({
|
|
239
|
-
user: {
|
|
240
|
-
object: 'user',
|
|
241
|
-
email: 'test01@example.com',
|
|
242
|
-
firstName: 'Test 01',
|
|
243
|
-
lastName: 'User',
|
|
244
|
-
emailVerified: true,
|
|
245
|
-
createdAt: '2023-07-18T02:07:19.911Z',
|
|
246
|
-
updatedAt: '2023-07-18T02:07:19.911Z',
|
|
247
|
-
},
|
|
248
|
-
});
|
|
249
|
-
}));
|
|
250
|
-
});
|
|
251
|
-
describe('createPasswordResetChallenge', () => {
|
|
252
|
-
it('sends a Create Password Reset Challenge request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
253
|
-
mock.onPost(`/users/send_password_reset_email`).reply(200, {
|
|
254
|
-
token: 'password-reset-token',
|
|
255
|
-
user: user_json_1.default,
|
|
256
|
-
});
|
|
257
|
-
const resp = yield workos.users.sendPasswordResetEmail({
|
|
258
|
-
email: 'test01@example.com',
|
|
259
|
-
passwordResetUrl: 'https://example.com/forgot-password',
|
|
260
|
-
});
|
|
261
|
-
expect(mock.history.post[0].url).toEqual(`/users/send_password_reset_email`);
|
|
262
|
-
expect(resp).toMatchObject({
|
|
263
|
-
token: 'password-reset-token',
|
|
264
|
-
user: {
|
|
265
|
-
email: 'test01@example.com',
|
|
266
|
-
},
|
|
267
|
-
});
|
|
268
|
-
}));
|
|
269
|
-
});
|
|
270
|
-
describe('completePasswordReset', () => {
|
|
271
|
-
it('sends a completePasswordReset request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
272
|
-
mock.onPost(`/users/password_reset`).reply(200, { user: user_json_1.default });
|
|
273
|
-
const resp = yield workos.users.resetPassword({
|
|
274
|
-
token: '',
|
|
275
|
-
newPassword: 'correct horse battery staple',
|
|
276
|
-
});
|
|
277
|
-
expect(mock.history.post[0].url).toEqual(`/users/password_reset`);
|
|
278
|
-
expect(resp.user).toMatchObject({
|
|
279
|
-
email: 'test01@example.com',
|
|
280
|
-
});
|
|
281
|
-
}));
|
|
282
|
-
});
|
|
283
|
-
describe('addUserToOrganization', () => {
|
|
284
|
-
it('sends a addUserToOrganization request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
285
|
-
mock.onPost(`/users/${userId}/organizations`).reply(200, user_json_1.default);
|
|
286
|
-
const resp = yield workos.users.addUserToOrganization({
|
|
287
|
-
userId,
|
|
288
|
-
organizationId: 'org_coolorg',
|
|
289
|
-
});
|
|
290
|
-
expect(mock.history.post[0].url).toEqual(`/users/${userId}/organizations`);
|
|
291
|
-
expect(resp).toMatchObject({
|
|
292
|
-
email: 'test01@example.com',
|
|
293
|
-
});
|
|
294
|
-
}));
|
|
295
|
-
});
|
|
296
|
-
describe('removeUserFromOrganization', () => {
|
|
297
|
-
it('sends a removeUserFromOrganization request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
298
|
-
const orgId = 'org_coolorg';
|
|
299
|
-
mock
|
|
300
|
-
.onDelete(`/users/${userId}/organizations/${orgId}`)
|
|
301
|
-
.reply(200, user_json_1.default);
|
|
302
|
-
const resp = yield workos.users.removeUserFromOrganization({
|
|
303
|
-
userId,
|
|
304
|
-
organizationId: orgId,
|
|
305
|
-
});
|
|
306
|
-
expect(mock.history.delete[0].url).toEqual(`/users/${userId}/organizations/${orgId}`);
|
|
307
|
-
expect(resp).toMatchObject({
|
|
308
|
-
email: 'test01@example.com',
|
|
309
|
-
});
|
|
310
|
-
}));
|
|
311
|
-
});
|
|
312
|
-
describe('updateUser', () => {
|
|
313
|
-
it('sends a updateUser request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
314
|
-
mock.onPut(`/users/${userId}`).reply(200, user_json_1.default);
|
|
315
|
-
const resp = yield workos.users.updateUser({
|
|
316
|
-
userId,
|
|
317
|
-
firstName: 'Dane',
|
|
318
|
-
lastName: 'Williams',
|
|
319
|
-
emailVerified: true,
|
|
320
|
-
});
|
|
321
|
-
expect(mock.history.put[0].url).toEqual(`/users/${userId}`);
|
|
322
|
-
expect(JSON.parse(mock.history.put[0].data)).toEqual({
|
|
323
|
-
first_name: 'Dane',
|
|
324
|
-
last_name: 'Williams',
|
|
325
|
-
email_verified: true,
|
|
326
|
-
});
|
|
327
|
-
expect(resp).toMatchObject({
|
|
328
|
-
email: 'test01@example.com',
|
|
329
|
-
});
|
|
330
|
-
}));
|
|
331
|
-
describe('when only one property is provided', () => {
|
|
332
|
-
it('sends a updateUser request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
333
|
-
mock.onPut(`/users/${userId}`).reply(200, user_json_1.default);
|
|
334
|
-
const resp = yield workos.users.updateUser({
|
|
335
|
-
userId,
|
|
336
|
-
firstName: 'Dane',
|
|
337
|
-
});
|
|
338
|
-
expect(mock.history.put[0].url).toEqual(`/users/${userId}`);
|
|
339
|
-
expect(JSON.parse(mock.history.put[0].data)).toEqual({
|
|
340
|
-
first_name: 'Dane',
|
|
341
|
-
});
|
|
342
|
-
expect(resp).toMatchObject({
|
|
343
|
-
email: 'test01@example.com',
|
|
344
|
-
});
|
|
345
|
-
}));
|
|
346
|
-
});
|
|
347
|
-
});
|
|
348
|
-
describe('updateUserPassword', () => {
|
|
349
|
-
it('sends a updateUserPassword request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
350
|
-
mock.onPut(`/users/${userId}/password`).reply(200, user_json_1.default);
|
|
351
|
-
const resp = yield workos.users.updateUserPassword({
|
|
352
|
-
userId,
|
|
353
|
-
password: 'secure',
|
|
354
|
-
});
|
|
355
|
-
expect(mock.history.put[0].url).toEqual(`/users/${userId}/password`);
|
|
356
|
-
expect(resp).toMatchObject({
|
|
357
|
-
email: 'test01@example.com',
|
|
358
|
-
});
|
|
359
|
-
}));
|
|
360
|
-
});
|
|
361
|
-
describe('enrollAuthFactor', () => {
|
|
362
|
-
it('sends an enrollAuthFactor request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
363
|
-
mock.onPost(`/users/${userId}/auth/factors`).reply(200, {
|
|
364
|
-
authentication_factor: {
|
|
365
|
-
object: 'authentication_factor',
|
|
366
|
-
id: 'auth_factor_1234',
|
|
367
|
-
created_at: '2022-03-15T20:39:19.892Z',
|
|
368
|
-
updated_at: '2022-03-15T20:39:19.892Z',
|
|
369
|
-
type: 'totp',
|
|
370
|
-
totp: {
|
|
371
|
-
issuer: 'WorkOS',
|
|
372
|
-
qr_code: 'qr-code-test',
|
|
373
|
-
secret: 'secret-test',
|
|
374
|
-
uri: 'uri-test',
|
|
375
|
-
user: 'some_user',
|
|
376
|
-
},
|
|
377
|
-
},
|
|
378
|
-
authentication_challenge: {
|
|
379
|
-
object: 'authentication_challenge',
|
|
380
|
-
id: 'auth_challenge_1234',
|
|
381
|
-
created_at: '2022-03-15T20:39:19.892Z',
|
|
382
|
-
updated_at: '2022-03-15T20:39:19.892Z',
|
|
383
|
-
expires_at: '2022-03-15T21:39:19.892Z',
|
|
384
|
-
code: '12345',
|
|
385
|
-
authentication_factor_id: 'auth_factor_1234',
|
|
386
|
-
},
|
|
387
|
-
});
|
|
388
|
-
const resp = yield workos.users.enrollAuthFactor({
|
|
389
|
-
userId,
|
|
390
|
-
type: 'totp',
|
|
391
|
-
totpIssuer: 'WorkOS',
|
|
392
|
-
totpUser: 'some_user',
|
|
393
|
-
});
|
|
394
|
-
expect(mock.history.post[0].url).toEqual(`/users/${userId}/auth/factors`);
|
|
395
|
-
expect(resp).toMatchObject({
|
|
396
|
-
authenticationFactor: {
|
|
397
|
-
object: 'authentication_factor',
|
|
398
|
-
id: 'auth_factor_1234',
|
|
399
|
-
createdAt: '2022-03-15T20:39:19.892Z',
|
|
400
|
-
updatedAt: '2022-03-15T20:39:19.892Z',
|
|
401
|
-
type: 'totp',
|
|
402
|
-
totp: {
|
|
403
|
-
issuer: 'WorkOS',
|
|
404
|
-
qrCode: 'qr-code-test',
|
|
405
|
-
secret: 'secret-test',
|
|
406
|
-
uri: 'uri-test',
|
|
407
|
-
user: 'some_user',
|
|
408
|
-
},
|
|
409
|
-
},
|
|
410
|
-
authenticationChallenge: {
|
|
411
|
-
object: 'authentication_challenge',
|
|
412
|
-
id: 'auth_challenge_1234',
|
|
413
|
-
createdAt: '2022-03-15T20:39:19.892Z',
|
|
414
|
-
updatedAt: '2022-03-15T20:39:19.892Z',
|
|
415
|
-
expiresAt: '2022-03-15T21:39:19.892Z',
|
|
416
|
-
code: '12345',
|
|
417
|
-
authenticationFactorId: 'auth_factor_1234',
|
|
418
|
-
},
|
|
419
|
-
});
|
|
420
|
-
}));
|
|
421
|
-
});
|
|
422
|
-
describe('listAuthFactors', () => {
|
|
423
|
-
it('sends a listAuthFactors request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
424
|
-
mock.onGet(`/users/${userId}/auth/factors`).reply(200, list_factors_json_1.default);
|
|
425
|
-
const resp = yield workos.users.listAuthFactors({ userId });
|
|
426
|
-
expect(mock.history.get[0].url).toEqual(`/users/${userId}/auth/factors`);
|
|
427
|
-
expect(resp).toMatchObject({
|
|
428
|
-
object: 'list',
|
|
429
|
-
data: [
|
|
430
|
-
{
|
|
431
|
-
object: 'authentication_factor',
|
|
432
|
-
id: 'auth_factor_1234',
|
|
433
|
-
createdAt: '2022-03-15T20:39:19.892Z',
|
|
434
|
-
updatedAt: '2022-03-15T20:39:19.892Z',
|
|
435
|
-
type: 'totp',
|
|
436
|
-
totp: {
|
|
437
|
-
issuer: 'WorkOS',
|
|
438
|
-
qrCode: 'qr-code-test',
|
|
439
|
-
secret: 'secret-test',
|
|
440
|
-
uri: 'uri-test',
|
|
441
|
-
user: 'some_user',
|
|
442
|
-
},
|
|
443
|
-
},
|
|
444
|
-
],
|
|
445
|
-
listMetadata: {
|
|
446
|
-
before: null,
|
|
447
|
-
after: null,
|
|
448
|
-
},
|
|
449
|
-
});
|
|
450
|
-
}));
|
|
451
|
-
});
|
|
452
|
-
describe('deleteUser', () => {
|
|
453
|
-
it('sends a deleteUser request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
454
|
-
mock.onDelete(`/users/${userId}`).reply(200);
|
|
455
|
-
const resp = yield workos.users.deleteUser({
|
|
456
|
-
userId,
|
|
457
|
-
});
|
|
458
|
-
expect(mock.history.delete[0].url).toEqual(`/users/${userId}`);
|
|
459
|
-
expect(resp).toBeUndefined();
|
|
460
|
-
}));
|
|
461
|
-
});
|
|
462
|
-
});
|
|
File without changes
|
|
File without changes
|
/package/lib/{users → user-management}/interfaces/authenticate-with-code-options.interface.js
RENAMED
|
File without changes
|
|
File without changes
|
/package/lib/{users → user-management}/interfaces/authenticate-with-magic-auth-options.interface.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/lib/{users → user-management}/interfaces/authenticate-with-password-options.interface.js
RENAMED
|
File without changes
|
/package/lib/{users → user-management}/interfaces/authenticate-with-totp-options.interface.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|