@workos-inc/node 3.9.2 → 4.0.1

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.
Files changed (153) hide show
  1. package/lib/common/interfaces/event.interface.d.ts +45 -3
  2. package/lib/common/serializers/event.serializer.js +9 -0
  3. package/lib/directory-sync/interfaces/directory-user.interface.d.ts +12 -12
  4. package/lib/index.d.ts +1 -2
  5. package/lib/index.js +1 -2
  6. package/lib/mfa/interfaces/challenge.interface.d.ts +2 -2
  7. package/lib/mfa/interfaces/factor.interface.d.ts +6 -2
  8. package/lib/mfa/interfaces/totp.interface.d.ts +7 -2
  9. package/lib/mfa/serializers/factor.serializer.js +1 -1
  10. package/lib/mfa/serializers/totp.serializer.js +17 -7
  11. package/lib/sso/interfaces/authorization-url-options.interface.d.ts +1 -1
  12. package/lib/sso/interfaces/get-profile-and-token-options.interface.d.ts +1 -1
  13. package/lib/sso/sso.d.ts +2 -2
  14. package/lib/sso/sso.js +4 -4
  15. package/lib/sso/sso.spec.js +21 -21
  16. package/lib/user-management/fixtures/invitation.json +13 -0
  17. package/lib/user-management/fixtures/list-invitations.json +22 -0
  18. package/lib/user-management/fixtures/list-organization-memberships.json +17 -0
  19. package/lib/user-management/fixtures/organization-membership.json +8 -0
  20. package/lib/user-management/interfaces/authenticate-with-code-options.interface.d.ts +11 -0
  21. package/lib/user-management/interfaces/authenticate-with-email-verification-options.interface.d.ts +13 -0
  22. package/lib/user-management/interfaces/authenticate-with-magic-auth-options.interface.d.ts +15 -0
  23. package/lib/user-management/interfaces/authenticate-with-options-base.interface.d.ts +11 -0
  24. package/lib/user-management/interfaces/authenticate-with-organization-selection.interface.d.ts +13 -0
  25. package/lib/user-management/interfaces/authenticate-with-password-options.interface.d.ts +13 -0
  26. package/lib/{users → user-management}/interfaces/authenticate-with-totp-options.interface.d.ts +3 -9
  27. package/lib/{users → user-management}/interfaces/authentication-response.interface.d.ts +2 -0
  28. package/lib/user-management/interfaces/authorization-url-options.interface.d.ts +10 -0
  29. package/lib/user-management/interfaces/create-organization-membership-options.interface.d.ts +8 -0
  30. package/lib/{users → user-management}/interfaces/enroll-auth-factor.interface.d.ts +4 -4
  31. package/lib/{users → user-management}/interfaces/index.d.ts +2 -5
  32. package/lib/{users → user-management}/interfaces/index.js +2 -5
  33. package/lib/user-management/interfaces/invitation.interface.d.ts +26 -0
  34. package/lib/user-management/interfaces/list-invitations-options.interface.d.ts +9 -0
  35. package/lib/user-management/interfaces/list-organization-memberships-options.interface.d.ts +9 -0
  36. package/lib/{users → user-management}/interfaces/list-users-options.interface.d.ts +5 -1
  37. package/lib/user-management/interfaces/organization-membership.interface.d.ts +16 -0
  38. package/lib/user-management/interfaces/send-invitation-options.interface.d.ts +12 -0
  39. package/lib/user-management/interfaces/send-password-reset-email-options.interface.d.ts +8 -0
  40. package/lib/{users → user-management}/interfaces/update-user-options.interface.d.ts +6 -0
  41. package/lib/user-management/interfaces/user.interface.js +2 -0
  42. package/lib/user-management/interfaces/verify-email-options.interface.d.ts +7 -0
  43. package/lib/user-management/interfaces/verify-email-options.interface.js +2 -0
  44. package/lib/user-management/serializers/authenticate-with-email-verification.serializer.d.ts +2 -0
  45. package/lib/user-management/serializers/authenticate-with-email-verification.serializer.js +13 -0
  46. package/lib/{users → user-management}/serializers/authenticate-with-magic-auth-options.serializer.js +2 -1
  47. package/lib/user-management/serializers/authenticate-with-organization-selection-options.serializer.d.ts +2 -0
  48. package/lib/user-management/serializers/authenticate-with-organization-selection-options.serializer.js +13 -0
  49. package/lib/{users → user-management}/serializers/authentication-response.serializer.js +1 -0
  50. package/lib/user-management/serializers/create-organization-membership-options.serializer.d.ts +2 -0
  51. package/lib/user-management/serializers/create-organization-membership-options.serializer.js +8 -0
  52. package/lib/user-management/serializers/invitation.serializer.d.ts +2 -0
  53. package/lib/user-management/serializers/invitation.serializer.js +17 -0
  54. package/lib/user-management/serializers/list-invitations-options.serializer.d.ts +2 -0
  55. package/lib/user-management/serializers/list-invitations-options.serializer.js +12 -0
  56. package/lib/user-management/serializers/list-organization-memberships-options.serializer.d.ts +2 -0
  57. package/lib/user-management/serializers/list-organization-memberships-options.serializer.js +12 -0
  58. package/lib/user-management/serializers/list-users-options.serializer.d.ts +2 -0
  59. package/lib/user-management/serializers/list-users-options.serializer.js +12 -0
  60. package/lib/user-management/serializers/organization-membership.serializer.d.ts +2 -0
  61. package/lib/user-management/serializers/organization-membership.serializer.js +12 -0
  62. package/lib/user-management/serializers/send-invitation-options.serializer.d.ts +2 -0
  63. package/lib/user-management/serializers/send-invitation-options.serializer.js +10 -0
  64. package/lib/user-management/serializers/send-password-reset-email.serializer.d.ts +2 -0
  65. package/lib/user-management/serializers/send-password-reset-email.serializer.js +8 -0
  66. package/lib/{users → user-management}/serializers/update-user-options.serializer.js +3 -0
  67. package/lib/user-management/user-management.d.ts +53 -0
  68. package/lib/user-management/user-management.js +214 -0
  69. package/lib/user-management/user-management.spec.js +748 -0
  70. package/lib/workos.d.ts +2 -4
  71. package/lib/workos.js +3 -5
  72. package/package.json +1 -1
  73. package/lib/audit-trail/audit-trail.d.ts +0 -12
  74. package/lib/audit-trail/audit-trail.js +0 -31
  75. package/lib/audit-trail/audit-trail.spec.js +0 -183
  76. package/lib/audit-trail/interfaces/create-event-options.interface.d.ts +0 -3
  77. package/lib/audit-trail/interfaces/event-options.interface.d.ts +0 -14
  78. package/lib/audit-trail/interfaces/event.interface.d.ts +0 -23
  79. package/lib/audit-trail/interfaces/index.d.ts +0 -4
  80. package/lib/audit-trail/interfaces/list-events-options.interface.d.ts +0 -16
  81. package/lib/users/interfaces/add-user-to-organization-options.interface.d.ts +0 -7
  82. package/lib/users/interfaces/authenticate-with-code-options.interface.d.ts +0 -17
  83. package/lib/users/interfaces/authenticate-with-magic-auth-options.interface.d.ts +0 -19
  84. package/lib/users/interfaces/authenticate-with-password-options.interface.d.ts +0 -19
  85. package/lib/users/interfaces/delete-user-options.interface.d.ts +0 -3
  86. package/lib/users/interfaces/remove-user-from-organization-options.interface.d.ts +0 -4
  87. package/lib/users/interfaces/send-password-reset-options.interface.d.ts +0 -17
  88. package/lib/users/interfaces/verify-email-code-options.interface.d.ts +0 -7
  89. package/lib/users/serializers/send-password-reset-email.serializer.d.ts +0 -3
  90. package/lib/users/serializers/send-password-reset-email.serializer.js +0 -14
  91. package/lib/users/users.d.ts +0 -38
  92. package/lib/users/users.js +0 -140
  93. package/lib/users/users.spec.d.ts +0 -1
  94. package/lib/users/users.spec.js +0 -462
  95. /package/lib/{users → user-management}/fixtures/list-factors.json +0 -0
  96. /package/lib/{users → user-management}/fixtures/list-users.json +0 -0
  97. /package/lib/{users → user-management}/fixtures/user.json +0 -0
  98. /package/lib/{users → user-management}/interfaces/authenticate-with-code-options.interface.js +0 -0
  99. /package/lib/{audit-trail/interfaces/create-event-options.interface.js → user-management/interfaces/authenticate-with-email-verification-options.interface.js} +0 -0
  100. /package/lib/{users → user-management}/interfaces/authenticate-with-magic-auth-options.interface.js +0 -0
  101. /package/lib/{audit-trail/interfaces/event-options.interface.js → user-management/interfaces/authenticate-with-options-base.interface.js} +0 -0
  102. /package/lib/{audit-trail/interfaces/event.interface.js → user-management/interfaces/authenticate-with-organization-selection.interface.js} +0 -0
  103. /package/lib/{users → user-management}/interfaces/authenticate-with-password-options.interface.js +0 -0
  104. /package/lib/{users → user-management}/interfaces/authenticate-with-totp-options.interface.js +0 -0
  105. /package/lib/{users → user-management}/interfaces/authentication-response.interface.js +0 -0
  106. /package/lib/{audit-trail/interfaces/index.js → user-management/interfaces/authorization-url-options.interface.js} +0 -0
  107. /package/lib/{audit-trail/interfaces/list-events-options.interface.js → user-management/interfaces/create-organization-membership-options.interface.js} +0 -0
  108. /package/lib/{users → user-management}/interfaces/create-user-options.interface.d.ts +0 -0
  109. /package/lib/{users → user-management}/interfaces/create-user-options.interface.js +0 -0
  110. /package/lib/{users → user-management}/interfaces/enroll-auth-factor.interface.js +0 -0
  111. /package/lib/{users/interfaces/add-user-to-organization-options.interface.js → user-management/interfaces/invitation.interface.js} +0 -0
  112. /package/lib/{users → user-management}/interfaces/list-auth-factors-options.interface.d.ts +0 -0
  113. /package/lib/{users → user-management}/interfaces/list-auth-factors-options.interface.js +0 -0
  114. /package/lib/{users/interfaces/delete-user-options.interface.js → user-management/interfaces/list-invitations-options.interface.js} +0 -0
  115. /package/lib/{users/interfaces/list-users-options.interface.js → user-management/interfaces/list-organization-memberships-options.interface.js} +0 -0
  116. /package/lib/{users/interfaces/remove-user-from-organization-options.interface.js → user-management/interfaces/list-users-options.interface.js} +0 -0
  117. /package/lib/{users/interfaces/reset-password-options.interface.js → user-management/interfaces/organization-membership.interface.js} +0 -0
  118. /package/lib/{users → user-management}/interfaces/reset-password-options.interface.d.ts +0 -0
  119. /package/lib/{users/interfaces/send-magic-auth-code-options.interface.js → user-management/interfaces/reset-password-options.interface.js} +0 -0
  120. /package/lib/{users/interfaces/send-password-reset-options.interface.js → user-management/interfaces/send-invitation-options.interface.js} +0 -0
  121. /package/lib/{users → user-management}/interfaces/send-magic-auth-code-options.interface.d.ts +0 -0
  122. /package/lib/{users/interfaces/send-verification-email-options.js → user-management/interfaces/send-magic-auth-code-options.interface.js} +0 -0
  123. /package/lib/{users/interfaces/update-user-options.interface.js → user-management/interfaces/send-password-reset-email-options.interface.js} +0 -0
  124. /package/lib/{users → user-management}/interfaces/send-verification-email-options.d.ts +0 -0
  125. /package/lib/{users/interfaces/update-user-password-options.interface.js → user-management/interfaces/send-verification-email-options.js} +0 -0
  126. /package/lib/{users/interfaces/user.interface.js → user-management/interfaces/update-user-options.interface.js} +0 -0
  127. /package/lib/{users → user-management}/interfaces/update-user-password-options.interface.d.ts +0 -0
  128. /package/lib/{users/interfaces/verify-email-code-options.interface.js → user-management/interfaces/update-user-password-options.interface.js} +0 -0
  129. /package/lib/{users → user-management}/interfaces/user.interface.d.ts +0 -0
  130. /package/lib/{users → user-management}/serializers/authenticate-with-code-options.serializer.d.ts +0 -0
  131. /package/lib/{users → user-management}/serializers/authenticate-with-code-options.serializer.js +0 -0
  132. /package/lib/{users → user-management}/serializers/authenticate-with-magic-auth-options.serializer.d.ts +0 -0
  133. /package/lib/{users → user-management}/serializers/authenticate-with-password-options.serializer.d.ts +0 -0
  134. /package/lib/{users → user-management}/serializers/authenticate-with-password-options.serializer.js +0 -0
  135. /package/lib/{users → user-management}/serializers/authenticate-with-totp-options.serializer.d.ts +0 -0
  136. /package/lib/{users → user-management}/serializers/authenticate-with-totp-options.serializer.js +0 -0
  137. /package/lib/{users → user-management}/serializers/authentication-response.serializer.d.ts +0 -0
  138. /package/lib/{users → user-management}/serializers/create-user-options.serializer.d.ts +0 -0
  139. /package/lib/{users → user-management}/serializers/create-user-options.serializer.js +0 -0
  140. /package/lib/{users → user-management}/serializers/enroll-auth-factor-options.serializer.d.ts +0 -0
  141. /package/lib/{users → user-management}/serializers/enroll-auth-factor-options.serializer.js +0 -0
  142. /package/lib/{users → user-management}/serializers/index.d.ts +0 -0
  143. /package/lib/{users → user-management}/serializers/index.js +0 -0
  144. /package/lib/{users → user-management}/serializers/reset-password-options.serializer.d.ts +0 -0
  145. /package/lib/{users → user-management}/serializers/reset-password-options.serializer.js +0 -0
  146. /package/lib/{users → user-management}/serializers/send-magic-auth-code-options.serializer.d.ts +0 -0
  147. /package/lib/{users → user-management}/serializers/send-magic-auth-code-options.serializer.js +0 -0
  148. /package/lib/{users → user-management}/serializers/update-user-options.serializer.d.ts +0 -0
  149. /package/lib/{users → user-management}/serializers/update-user-password-options.serializer.d.ts +0 -0
  150. /package/lib/{users → user-management}/serializers/update-user-password-options.serializer.js +0 -0
  151. /package/lib/{users → user-management}/serializers/user.serializer.d.ts +0 -0
  152. /package/lib/{users → user-management}/serializers/user.serializer.js +0 -0
  153. /package/lib/{audit-trail/audit-trail.spec.d.ts → user-management/user-management.spec.d.ts} +0 -0
@@ -0,0 +1,748 @@
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 organization_membership_json_1 = __importDefault(require("./fixtures/organization-membership.json"));
22
+ const list_organization_memberships_json_1 = __importDefault(require("./fixtures/list-organization-memberships.json"));
23
+ const invitation_json_1 = __importDefault(require("./fixtures/invitation.json"));
24
+ const list_invitations_json_1 = __importDefault(require("./fixtures/list-invitations.json"));
25
+ const mock = new axios_mock_adapter_1.default(axios_1.default);
26
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
27
+ const userId = 'user_01H5JQDV7R7ATEYZDEG0W5PRYS';
28
+ const organizationMembershipId = 'om_01H5JQDV7R7ATEYZDEG0W5PRYS';
29
+ const invitationId = 'invitation_01H5JQDV7R7ATEYZDEG0W5PRYS';
30
+ describe('UserManagement', () => {
31
+ afterEach(() => mock.resetHistory());
32
+ describe('getUser', () => {
33
+ it('sends a Get User request', () => __awaiter(void 0, void 0, void 0, function* () {
34
+ mock.onGet(`/user_management/users/${userId}`).reply(200, user_json_1.default);
35
+ const user = yield workos.userManagement.getUser(userId);
36
+ expect(mock.history.get[0].url).toEqual(`/user_management/users/${userId}`);
37
+ expect(user).toMatchObject({
38
+ object: 'user',
39
+ id: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
40
+ email: 'test01@example.com',
41
+ firstName: 'Test 01',
42
+ lastName: 'User',
43
+ emailVerified: true,
44
+ });
45
+ }));
46
+ });
47
+ describe('listUsers', () => {
48
+ it('lists users', () => __awaiter(void 0, void 0, void 0, function* () {
49
+ mock.onGet('/user_management/users').reply(200, list_users_json_1.default);
50
+ const userList = yield workos.userManagement.listUsers();
51
+ expect(mock.history.get[0].url).toEqual('/user_management/users');
52
+ expect(userList).toMatchObject({
53
+ object: 'list',
54
+ data: [
55
+ {
56
+ object: 'user',
57
+ email: 'test01@example.com',
58
+ },
59
+ ],
60
+ listMetadata: {
61
+ before: null,
62
+ after: null,
63
+ },
64
+ });
65
+ }));
66
+ it('sends the correct params when filtering', () => __awaiter(void 0, void 0, void 0, function* () {
67
+ mock.onGet('/user_management/users').reply(200, list_users_json_1.default);
68
+ yield workos.userManagement.listUsers({
69
+ email: 'foo@example.com',
70
+ organizationId: 'org_someorg',
71
+ after: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
72
+ limit: 10,
73
+ });
74
+ expect(mock.history.get[0].params).toEqual({
75
+ email: 'foo@example.com',
76
+ organization_id: 'org_someorg',
77
+ after: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
78
+ limit: 10,
79
+ order: 'desc',
80
+ });
81
+ }));
82
+ });
83
+ describe('createUser', () => {
84
+ it('sends a Create User request', () => __awaiter(void 0, void 0, void 0, function* () {
85
+ mock.onPost('/user_management/users').reply(200, user_json_1.default);
86
+ const user = yield workos.userManagement.createUser({
87
+ email: 'test01@example.com',
88
+ password: 'extra-secure',
89
+ firstName: 'Test 01',
90
+ lastName: 'User',
91
+ emailVerified: true,
92
+ });
93
+ expect(mock.history.post[0].url).toEqual('/user_management/users');
94
+ expect(user).toMatchObject({
95
+ object: 'user',
96
+ email: 'test01@example.com',
97
+ firstName: 'Test 01',
98
+ lastName: 'User',
99
+ emailVerified: true,
100
+ createdAt: '2023-07-18T02:07:19.911Z',
101
+ updatedAt: '2023-07-18T02:07:19.911Z',
102
+ });
103
+ }));
104
+ });
105
+ describe('authenticateUserWithMagicAuth', () => {
106
+ it('sends a magic auth authentication request', () => __awaiter(void 0, void 0, void 0, function* () {
107
+ mock.onPost('/user_management/authenticate').reply(200, {
108
+ user: user_json_1.default,
109
+ });
110
+ const resp = yield workos.userManagement.authenticateWithMagicAuth({
111
+ clientId: 'proj_whatever',
112
+ code: '123456',
113
+ email: user_json_1.default.email,
114
+ });
115
+ expect(mock.history.post[0].url).toEqual('/user_management/authenticate');
116
+ expect(resp).toMatchObject({
117
+ user: {
118
+ email: 'test01@example.com',
119
+ },
120
+ });
121
+ }));
122
+ });
123
+ describe('authenticateUserWithPassword', () => {
124
+ it('sends an password authentication request', () => __awaiter(void 0, void 0, void 0, function* () {
125
+ mock.onPost('/user_management/authenticate').reply(200, {
126
+ user: user_json_1.default,
127
+ });
128
+ const resp = yield workos.userManagement.authenticateWithPassword({
129
+ clientId: 'proj_whatever',
130
+ email: 'test01@example.com',
131
+ password: 'extra-secure',
132
+ });
133
+ expect(mock.history.post[0].url).toEqual('/user_management/authenticate');
134
+ expect(resp).toMatchObject({
135
+ user: {
136
+ email: 'test01@example.com',
137
+ },
138
+ });
139
+ }));
140
+ });
141
+ describe('authenticateUserWithCode', () => {
142
+ it('sends a token authentication request', () => __awaiter(void 0, void 0, void 0, function* () {
143
+ mock
144
+ .onPost('/user_management/authenticate')
145
+ .reply(200, { user: user_json_1.default });
146
+ const resp = yield workos.userManagement.authenticateWithCode({
147
+ clientId: 'proj_whatever',
148
+ code: 'or this',
149
+ });
150
+ expect(mock.history.post[0].url).toEqual('/user_management/authenticate');
151
+ expect(JSON.parse(mock.history.post[0].data)).toMatchObject({
152
+ client_secret: 'sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU',
153
+ grant_type: 'authorization_code',
154
+ });
155
+ expect(resp).toMatchObject({
156
+ user: {
157
+ email: 'test01@example.com',
158
+ },
159
+ });
160
+ }));
161
+ });
162
+ describe('authenticateUserWithTotp', () => {
163
+ it('sends a token authentication request', () => __awaiter(void 0, void 0, void 0, function* () {
164
+ mock
165
+ .onPost('/user_management/authenticate')
166
+ .reply(200, { user: user_json_1.default });
167
+ const resp = yield workos.userManagement.authenticateWithTotp({
168
+ clientId: 'proj_whatever',
169
+ code: 'or this',
170
+ authenticationChallengeId: 'auth_challenge_01H96FETXGTW1QMBSBT2T36PW0',
171
+ pendingAuthenticationToken: 'cTDQJTTkTkkVYxQUlKBIxEsFs',
172
+ });
173
+ expect(mock.history.post[0].url).toEqual('/user_management/authenticate');
174
+ expect(JSON.parse(mock.history.post[0].data)).toMatchObject({
175
+ client_id: 'proj_whatever',
176
+ code: 'or this',
177
+ client_secret: 'sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU',
178
+ grant_type: 'urn:workos:oauth:grant-type:mfa-totp',
179
+ authentication_challenge_id: 'auth_challenge_01H96FETXGTW1QMBSBT2T36PW0',
180
+ pending_authentication_token: 'cTDQJTTkTkkVYxQUlKBIxEsFs',
181
+ });
182
+ expect(resp).toMatchObject({
183
+ user: {
184
+ email: 'test01@example.com',
185
+ },
186
+ });
187
+ }));
188
+ });
189
+ describe('authenticateUserWithEmailVerification', () => {
190
+ it('sends an email verification authentication request', () => __awaiter(void 0, void 0, void 0, function* () {
191
+ mock
192
+ .onPost('/user_management/authenticate')
193
+ .reply(200, { user: user_json_1.default });
194
+ const resp = yield workos.userManagement.authenticateWithEmailVerification({
195
+ clientId: 'proj_whatever',
196
+ code: 'or this',
197
+ pendingAuthenticationToken: 'cTDQJTTkTkkVYxQUlKBIxEsFs',
198
+ });
199
+ expect(mock.history.post[0].url).toEqual('/user_management/authenticate');
200
+ expect(JSON.parse(mock.history.post[0].data)).toMatchObject({
201
+ client_id: 'proj_whatever',
202
+ code: 'or this',
203
+ client_secret: 'sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU',
204
+ grant_type: 'urn:workos:oauth:grant-type:email-verification:code',
205
+ pending_authentication_token: 'cTDQJTTkTkkVYxQUlKBIxEsFs',
206
+ });
207
+ expect(resp).toMatchObject({
208
+ user: {
209
+ email: 'test01@example.com',
210
+ },
211
+ });
212
+ }));
213
+ });
214
+ describe('authenticateWithOrganizationSelection', () => {
215
+ it('sends an Organization Selection Authentication request', () => __awaiter(void 0, void 0, void 0, function* () {
216
+ mock
217
+ .onPost('/user_management/authenticate')
218
+ .reply(200, { user: user_json_1.default });
219
+ const resp = yield workos.userManagement.authenticateWithOrganizationSelection({
220
+ clientId: 'proj_whatever',
221
+ pendingAuthenticationToken: 'cTDQJTTkTkkVYxQUlKBIxEsFs',
222
+ organizationId: 'org_01H5JQDV7R7ATEYZDEG0W5PRYS',
223
+ });
224
+ expect(mock.history.post[0].url).toEqual('/user_management/authenticate');
225
+ expect(JSON.parse(mock.history.post[0].data)).toMatchObject({
226
+ client_id: 'proj_whatever',
227
+ client_secret: 'sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU',
228
+ grant_type: 'urn:workos:oauth:grant-type:organization-selection',
229
+ pending_authentication_token: 'cTDQJTTkTkkVYxQUlKBIxEsFs',
230
+ organization_id: 'org_01H5JQDV7R7ATEYZDEG0W5PRYS',
231
+ });
232
+ expect(resp).toMatchObject({
233
+ user: {
234
+ email: 'test01@example.com',
235
+ },
236
+ });
237
+ }));
238
+ });
239
+ describe('sendVerificationEmail', () => {
240
+ it('sends a Create Email Verification Challenge request', () => __awaiter(void 0, void 0, void 0, function* () {
241
+ mock
242
+ .onPost(`/user_management/users/${userId}/email_verification/send`)
243
+ .reply(200, { user: user_json_1.default });
244
+ const resp = yield workos.userManagement.sendVerificationEmail({
245
+ userId,
246
+ });
247
+ expect(mock.history.post[0].url).toEqual(`/user_management/users/${userId}/email_verification/send`);
248
+ expect(resp).toMatchObject({
249
+ user: {
250
+ createdAt: '2023-07-18T02:07:19.911Z',
251
+ email: 'test01@example.com',
252
+ emailVerified: true,
253
+ firstName: 'Test 01',
254
+ id: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
255
+ lastName: 'User',
256
+ object: 'user',
257
+ updatedAt: '2023-07-18T02:07:19.911Z',
258
+ },
259
+ });
260
+ }));
261
+ describe('verifyEmail', () => {
262
+ it('sends a Complete Email Verification request', () => __awaiter(void 0, void 0, void 0, function* () {
263
+ mock
264
+ .onPost(`/user_management/users/${userId}/email_verification/confirm`)
265
+ .reply(200, { user: user_json_1.default });
266
+ const resp = yield workos.userManagement.verifyEmail({
267
+ userId,
268
+ code: '123456',
269
+ });
270
+ expect(mock.history.post[0].url).toEqual(`/user_management/users/${userId}/email_verification/confirm`);
271
+ expect(resp.user).toMatchObject({
272
+ email: 'test01@example.com',
273
+ });
274
+ }));
275
+ });
276
+ });
277
+ describe('sendMagicAuthCode', () => {
278
+ it('sends a Send Magic Auth Code request', () => __awaiter(void 0, void 0, void 0, function* () {
279
+ mock
280
+ .onPost('/user_management/magic_auth/send', {
281
+ email: 'bob.loblaw@example.com',
282
+ })
283
+ .reply(200);
284
+ const response = yield workos.userManagement.sendMagicAuthCode({
285
+ email: 'bob.loblaw@example.com',
286
+ });
287
+ expect(mock.history.post[0].url).toEqual('/user_management/magic_auth/send');
288
+ expect(response).toBeUndefined();
289
+ }));
290
+ });
291
+ describe('sendPasswordResetEmail', () => {
292
+ it('sends a Send Password Reset Email request', () => __awaiter(void 0, void 0, void 0, function* () {
293
+ mock.onPost(`/user_management/password_reset/send`).reply(200);
294
+ const resp = yield workos.userManagement.sendPasswordResetEmail({
295
+ email: 'test01@example.com',
296
+ passwordResetUrl: 'https://example.com/forgot-password',
297
+ });
298
+ expect(mock.history.post[0].url).toEqual(`/user_management/password_reset/send`);
299
+ expect(resp).toBeUndefined();
300
+ }));
301
+ });
302
+ describe('resetPassword', () => {
303
+ it('sends a Reset Password request', () => __awaiter(void 0, void 0, void 0, function* () {
304
+ mock
305
+ .onPost(`/user_management/password_reset/confirm`)
306
+ .reply(200, { user: user_json_1.default });
307
+ const resp = yield workos.userManagement.resetPassword({
308
+ token: '',
309
+ newPassword: 'correct horse battery staple',
310
+ });
311
+ expect(mock.history.post[0].url).toEqual(`/user_management/password_reset/confirm`);
312
+ expect(resp.user).toMatchObject({
313
+ email: 'test01@example.com',
314
+ });
315
+ }));
316
+ });
317
+ describe('updateUser', () => {
318
+ it('sends a updateUser request', () => __awaiter(void 0, void 0, void 0, function* () {
319
+ mock.onPut(`/user_management/users/${userId}`).reply(200, user_json_1.default);
320
+ const resp = yield workos.userManagement.updateUser({
321
+ userId,
322
+ firstName: 'Dane',
323
+ lastName: 'Williams',
324
+ emailVerified: true,
325
+ });
326
+ expect(mock.history.put[0].url).toEqual(`/user_management/users/${userId}`);
327
+ expect(JSON.parse(mock.history.put[0].data)).toEqual({
328
+ first_name: 'Dane',
329
+ last_name: 'Williams',
330
+ email_verified: true,
331
+ });
332
+ expect(resp).toMatchObject({
333
+ email: 'test01@example.com',
334
+ });
335
+ }));
336
+ describe('when only one property is provided', () => {
337
+ it('sends a updateUser request', () => __awaiter(void 0, void 0, void 0, function* () {
338
+ mock.onPut(`/user_management/users/${userId}`).reply(200, user_json_1.default);
339
+ const resp = yield workos.userManagement.updateUser({
340
+ userId,
341
+ firstName: 'Dane',
342
+ });
343
+ expect(mock.history.put[0].url).toEqual(`/user_management/users/${userId}`);
344
+ expect(JSON.parse(mock.history.put[0].data)).toEqual({
345
+ first_name: 'Dane',
346
+ });
347
+ expect(resp).toMatchObject({
348
+ email: 'test01@example.com',
349
+ });
350
+ }));
351
+ });
352
+ });
353
+ describe('enrollAuthFactor', () => {
354
+ it('sends an enrollAuthFactor request', () => __awaiter(void 0, void 0, void 0, function* () {
355
+ mock.onPost(`/user_management/users/${userId}/auth_factors`).reply(200, {
356
+ authentication_factor: {
357
+ object: 'authentication_factor',
358
+ id: 'auth_factor_1234',
359
+ created_at: '2022-03-15T20:39:19.892Z',
360
+ updated_at: '2022-03-15T20:39:19.892Z',
361
+ type: 'totp',
362
+ totp: {
363
+ issuer: 'WorkOS',
364
+ qr_code: 'qr-code-test',
365
+ secret: 'secret-test',
366
+ uri: 'uri-test',
367
+ user: 'some_user',
368
+ },
369
+ },
370
+ authentication_challenge: {
371
+ object: 'authentication_challenge',
372
+ id: 'auth_challenge_1234',
373
+ created_at: '2022-03-15T20:39:19.892Z',
374
+ updated_at: '2022-03-15T20:39:19.892Z',
375
+ expires_at: '2022-03-15T21:39:19.892Z',
376
+ code: '12345',
377
+ authentication_factor_id: 'auth_factor_1234',
378
+ },
379
+ });
380
+ const resp = yield workos.userManagement.enrollAuthFactor({
381
+ userId,
382
+ type: 'totp',
383
+ totpIssuer: 'WorkOS',
384
+ totpUser: 'some_user',
385
+ });
386
+ expect(mock.history.post[0].url).toEqual(`/user_management/users/${userId}/auth_factors`);
387
+ expect(resp).toMatchObject({
388
+ authenticationFactor: {
389
+ object: 'authentication_factor',
390
+ id: 'auth_factor_1234',
391
+ createdAt: '2022-03-15T20:39:19.892Z',
392
+ updatedAt: '2022-03-15T20:39:19.892Z',
393
+ type: 'totp',
394
+ totp: {
395
+ issuer: 'WorkOS',
396
+ qrCode: 'qr-code-test',
397
+ secret: 'secret-test',
398
+ uri: 'uri-test',
399
+ user: 'some_user',
400
+ },
401
+ },
402
+ authenticationChallenge: {
403
+ object: 'authentication_challenge',
404
+ id: 'auth_challenge_1234',
405
+ createdAt: '2022-03-15T20:39:19.892Z',
406
+ updatedAt: '2022-03-15T20:39:19.892Z',
407
+ expiresAt: '2022-03-15T21:39:19.892Z',
408
+ code: '12345',
409
+ authenticationFactorId: 'auth_factor_1234',
410
+ },
411
+ });
412
+ }));
413
+ });
414
+ describe('listAuthFactors', () => {
415
+ it('sends a listAuthFactors request', () => __awaiter(void 0, void 0, void 0, function* () {
416
+ mock
417
+ .onGet(`/user_management/users/${userId}/auth_factors`)
418
+ .reply(200, list_factors_json_1.default);
419
+ const resp = yield workos.userManagement.listAuthFactors({ userId });
420
+ expect(mock.history.get[0].url).toEqual(`/user_management/users/${userId}/auth_factors`);
421
+ expect(resp).toMatchObject({
422
+ object: 'list',
423
+ data: [
424
+ {
425
+ object: 'authentication_factor',
426
+ id: 'auth_factor_1234',
427
+ createdAt: '2022-03-15T20:39:19.892Z',
428
+ updatedAt: '2022-03-15T20:39:19.892Z',
429
+ type: 'totp',
430
+ totp: {
431
+ issuer: 'WorkOS',
432
+ qrCode: 'qr-code-test',
433
+ secret: 'secret-test',
434
+ uri: 'uri-test',
435
+ user: 'some_user',
436
+ },
437
+ },
438
+ ],
439
+ listMetadata: {
440
+ before: null,
441
+ after: null,
442
+ },
443
+ });
444
+ }));
445
+ });
446
+ describe('deleteUser', () => {
447
+ it('sends a deleteUser request', () => __awaiter(void 0, void 0, void 0, function* () {
448
+ mock.onDelete(`/user_management/users/${userId}`).reply(200);
449
+ const resp = yield workos.userManagement.deleteUser(userId);
450
+ expect(mock.history.delete[0].url).toEqual(`/user_management/users/${userId}`);
451
+ expect(resp).toBeUndefined();
452
+ }));
453
+ });
454
+ describe('getOrganizationMembership', () => {
455
+ it('sends a Get OrganizationMembership request', () => __awaiter(void 0, void 0, void 0, function* () {
456
+ mock
457
+ .onGet(`/user_management/organization_memberships/${organizationMembershipId}`)
458
+ .reply(200, organization_membership_json_1.default);
459
+ const organizationMembership = yield workos.userManagement.getOrganizationMembership(organizationMembershipId);
460
+ expect(mock.history.get[0].url).toEqual(`/user_management/organization_memberships/${organizationMembershipId}`);
461
+ expect(organizationMembership).toMatchObject({
462
+ object: 'organization_membership',
463
+ id: 'om_01H5JQDV7R7ATEYZDEG0W5PRYS',
464
+ userId: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
465
+ organizationId: 'organization_01H5JQDV7R7ATEYZDEG0W5PRYS',
466
+ });
467
+ }));
468
+ });
469
+ describe('listOrganizationMemberships', () => {
470
+ it('lists organization memberships', () => __awaiter(void 0, void 0, void 0, function* () {
471
+ mock
472
+ .onGet('/user_management/organization_memberships')
473
+ .reply(200, list_organization_memberships_json_1.default);
474
+ const organizationMembershipsList = yield workos.userManagement.listOrganizationMemberships({
475
+ organizationId: 'organization_01H5JQDV7R7ATEYZDEG0W5PRYS',
476
+ userId: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
477
+ });
478
+ expect(mock.history.get[0].url).toEqual('/user_management/organization_memberships');
479
+ expect(organizationMembershipsList).toMatchObject({
480
+ object: 'list',
481
+ data: [
482
+ {
483
+ object: 'organization_membership',
484
+ organizationId: 'organization_01H5JQDV7R7ATEYZDEG0W5PRYS',
485
+ userId: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
486
+ },
487
+ ],
488
+ listMetadata: {
489
+ before: null,
490
+ after: null,
491
+ },
492
+ });
493
+ }));
494
+ it('sends the correct params when filtering', () => __awaiter(void 0, void 0, void 0, function* () {
495
+ mock
496
+ .onGet('/user_management/organization_memberships')
497
+ .reply(200, list_organization_memberships_json_1.default);
498
+ yield workos.userManagement.listOrganizationMemberships({
499
+ userId: 'user_someuser',
500
+ organizationId: 'org_someorg',
501
+ after: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
502
+ limit: 10,
503
+ });
504
+ expect(mock.history.get[0].params).toEqual({
505
+ user_id: 'user_someuser',
506
+ organization_id: 'org_someorg',
507
+ before: undefined,
508
+ after: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
509
+ limit: 10,
510
+ order: 'desc',
511
+ });
512
+ }));
513
+ });
514
+ describe('createOrganizationMembership', () => {
515
+ it('sends a create organization membership request', () => __awaiter(void 0, void 0, void 0, function* () {
516
+ mock
517
+ .onPost('/user_management/organization_memberships')
518
+ .reply(200, organization_membership_json_1.default);
519
+ const organizationMembership = yield workos.userManagement.createOrganizationMembership({
520
+ organizationId: 'org_01H5JQDV7R7ATEYZDEG0W5PRYS',
521
+ userId: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
522
+ });
523
+ expect(mock.history.post[0].url).toEqual('/user_management/organization_memberships');
524
+ expect(organizationMembership).toMatchObject({
525
+ object: 'organization_membership',
526
+ organizationId: 'organization_01H5JQDV7R7ATEYZDEG0W5PRYS',
527
+ userId: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
528
+ });
529
+ }));
530
+ });
531
+ describe('deleteOrganizationMembership', () => {
532
+ it('sends a deleteOrganizationMembership request', () => __awaiter(void 0, void 0, void 0, function* () {
533
+ mock
534
+ .onDelete(`/user_management/organization_memberships/${organizationMembershipId}`)
535
+ .reply(200);
536
+ const resp = yield workos.userManagement.deleteOrganizationMembership(organizationMembershipId);
537
+ expect(mock.history.delete[0].url).toEqual(`/user_management/organization_memberships/${organizationMembershipId}`);
538
+ expect(resp).toBeUndefined();
539
+ }));
540
+ });
541
+ describe('getInvitation', () => {
542
+ it('sends a Get Invitation request', () => __awaiter(void 0, void 0, void 0, function* () {
543
+ mock
544
+ .onGet(`/user_management/invitations/${invitationId}`)
545
+ .reply(200, invitation_json_1.default);
546
+ const invitation = yield workos.userManagement.getInvitation(invitationId);
547
+ expect(mock.history.get[0].url).toEqual(`/user_management/invitations/${invitationId}`);
548
+ expect(invitation).toMatchObject({});
549
+ }));
550
+ });
551
+ describe('listInvitations', () => {
552
+ it('lists invitations', () => __awaiter(void 0, void 0, void 0, function* () {
553
+ mock
554
+ .onGet('/user_management/invitations')
555
+ .reply(200, list_invitations_json_1.default);
556
+ const invitationsList = yield workos.userManagement.listInvitations({
557
+ organizationId: 'org_01H5JQDV7R7ATEYZDEG0W5PRYS',
558
+ email: 'dane@workos.com',
559
+ });
560
+ expect(mock.history.get[0].url).toEqual('/user_management/invitations');
561
+ expect(invitationsList).toMatchObject({
562
+ object: 'list',
563
+ data: [
564
+ {
565
+ object: 'invitation',
566
+ id: 'invitation_01H5JQDV7R7ATEYZDEG0W5PRYS',
567
+ organizationId: 'org_01H5JQDV7R7ATEYZDEG0W5PRYS',
568
+ email: 'dane@workos.com',
569
+ },
570
+ ],
571
+ listMetadata: {
572
+ before: null,
573
+ after: null,
574
+ },
575
+ });
576
+ }));
577
+ it('sends the correct params when filtering', () => __awaiter(void 0, void 0, void 0, function* () {
578
+ mock
579
+ .onGet('/user_management/invitations')
580
+ .reply(200, list_invitations_json_1.default);
581
+ yield workos.userManagement.listInvitations({
582
+ organizationId: 'org_someorg',
583
+ after: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
584
+ limit: 10,
585
+ });
586
+ expect(mock.history.get[0].params).toEqual({
587
+ organization_id: 'org_someorg',
588
+ before: undefined,
589
+ after: 'user_01H5JQDV7R7ATEYZDEG0W5PRYS',
590
+ limit: 10,
591
+ order: 'desc',
592
+ });
593
+ }));
594
+ });
595
+ describe('sendInvitation', () => {
596
+ it('sends a Send Invitation request', () => __awaiter(void 0, void 0, void 0, function* () {
597
+ mock
598
+ .onPost('/user_management/invitations', {
599
+ email: 'dane@workos.com',
600
+ })
601
+ .reply(200, invitation_json_1.default);
602
+ const response = yield workos.userManagement.sendInvitation({
603
+ email: 'dane@workos.com',
604
+ });
605
+ expect(mock.history.post[0].url).toEqual('/user_management/invitations');
606
+ expect(response).toMatchObject({
607
+ object: 'invitation',
608
+ email: 'dane@workos.com',
609
+ });
610
+ }));
611
+ it('sends the correct params when provided', () => __awaiter(void 0, void 0, void 0, function* () {
612
+ mock.onPost('/user_management/invitations').reply(200, invitation_json_1.default);
613
+ yield workos.userManagement.sendInvitation({
614
+ email: 'dane@workos.com',
615
+ organizationId: 'org_someorg',
616
+ expiresInDays: 4,
617
+ inviterUserId: 'user_someuser',
618
+ });
619
+ expect(JSON.parse(mock.history.post[0].data)).toEqual({
620
+ email: 'dane@workos.com',
621
+ organization_id: 'org_someorg',
622
+ expires_in_days: 4,
623
+ inviter_user_id: 'user_someuser',
624
+ });
625
+ }));
626
+ });
627
+ describe('revokeInvitation', () => {
628
+ it('send a Revoke Invitation request', () => __awaiter(void 0, void 0, void 0, function* () {
629
+ const invitationId = 'invitation_01H5JQDV7R7ATEYZDEG0W5PRYS';
630
+ mock
631
+ .onPost(`/user_management/invitations/${invitationId}/revoke`)
632
+ .reply(200, invitation_json_1.default);
633
+ const response = yield workos.userManagement.revokeInvitation(invitationId);
634
+ expect(mock.history.post[0].url).toEqual(`/user_management/invitations/${invitationId}/revoke`);
635
+ expect(response).toMatchObject({
636
+ object: 'invitation',
637
+ email: 'dane@workos.com',
638
+ });
639
+ }));
640
+ });
641
+ describe('getAuthorizationUrl', () => {
642
+ describe('with no custom api hostname', () => {
643
+ it('generates an authorize url with the default api hostname', () => {
644
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
645
+ const url = workos.userManagement.getAuthorizationUrl({
646
+ provider: 'Google',
647
+ clientId: 'proj_123',
648
+ redirectURI: 'example.com/auth/workos/callback',
649
+ });
650
+ expect(url).toMatchSnapshot();
651
+ });
652
+ });
653
+ describe('with no domain or provider', () => {
654
+ it('throws an error for incomplete arguments', () => {
655
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
656
+ const urlFn = () => workos.userManagement.getAuthorizationUrl({
657
+ clientId: 'proj_123',
658
+ redirectURI: 'example.com/auth/workos/callback',
659
+ });
660
+ expect(urlFn).toThrowErrorMatchingSnapshot();
661
+ });
662
+ });
663
+ describe('with a provider', () => {
664
+ it('generates an authorize url with the provider', () => {
665
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
666
+ const url = workos.userManagement.getAuthorizationUrl({
667
+ provider: 'Google',
668
+ clientId: 'proj_123',
669
+ redirectURI: 'example.com/auth/workos/callback',
670
+ });
671
+ expect(url).toMatchSnapshot();
672
+ });
673
+ });
674
+ describe('with a connectionId', () => {
675
+ it('generates an authorize url with the connection', () => {
676
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
677
+ const url = workos.userManagement.getAuthorizationUrl({
678
+ connectionId: 'connection_123',
679
+ clientId: 'proj_123',
680
+ redirectURI: 'example.com/auth/workos/callback',
681
+ });
682
+ expect(url).toMatchSnapshot();
683
+ });
684
+ });
685
+ describe('with an organizationId', () => {
686
+ it('generates an authorization URL with the organization', () => {
687
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
688
+ const url = workos.userManagement.getAuthorizationUrl({
689
+ organizationId: 'organization_123',
690
+ clientId: 'proj_123',
691
+ redirectURI: 'example.com/auth/workos/callback',
692
+ });
693
+ expect(url).toMatchSnapshot();
694
+ });
695
+ });
696
+ describe('with a custom api hostname', () => {
697
+ it('generates an authorize url with the custom api hostname', () => {
698
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU', {
699
+ apiHostname: 'api.workos.dev',
700
+ });
701
+ const url = workos.userManagement.getAuthorizationUrl({
702
+ organizationId: 'organization_123',
703
+ clientId: 'proj_123',
704
+ redirectURI: 'example.com/auth/workos/callback',
705
+ });
706
+ expect(url).toMatchSnapshot();
707
+ });
708
+ });
709
+ describe('with state', () => {
710
+ it('generates an authorize url with the provided state', () => {
711
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
712
+ const url = workos.userManagement.getAuthorizationUrl({
713
+ organizationId: 'organization_123',
714
+ clientId: 'proj_123',
715
+ redirectURI: 'example.com/auth/workos/callback',
716
+ state: 'custom state',
717
+ });
718
+ expect(url).toMatchSnapshot();
719
+ });
720
+ });
721
+ describe('with domainHint', () => {
722
+ it('generates an authorize url with the provided domain hint', () => {
723
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
724
+ const url = workos.userManagement.getAuthorizationUrl({
725
+ domainHint: 'example.com',
726
+ connectionId: 'connection_123',
727
+ clientId: 'proj_123',
728
+ redirectURI: 'example.com/auth/workos/callback',
729
+ state: 'custom state',
730
+ });
731
+ expect(url).toMatchInlineSnapshot(`"https://api.workos.com/user_management/authorize?client_id=proj_123&connection_id=connection_123&domain_hint=example.com&redirect_uri=example.com%2Fauth%2Fworkos%2Fcallback&response_type=code&state=custom+state"`);
732
+ });
733
+ });
734
+ describe('with loginHint', () => {
735
+ it('generates an authorize url with the provided login hint', () => {
736
+ const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
737
+ const url = workos.userManagement.getAuthorizationUrl({
738
+ loginHint: 'foo@workos.com',
739
+ connectionId: 'connection_123',
740
+ clientId: 'proj_123',
741
+ redirectURI: 'example.com/auth/workos/callback',
742
+ state: 'custom state',
743
+ });
744
+ expect(url).toMatchInlineSnapshot(`"https://api.workos.com/user_management/authorize?client_id=proj_123&connection_id=connection_123&login_hint=foo%40workos.com&redirect_uri=example.com%2Fauth%2Fworkos%2Fcallback&response_type=code&state=custom+state"`);
745
+ });
746
+ });
747
+ });
748
+ });