@workos-inc/node 3.0.0-user-management.2 → 3.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.
Files changed (217) hide show
  1. package/lib/audit-logs/audit-logs.js +5 -4
  2. package/lib/audit-logs/audit-logs.spec.js +87 -87
  3. package/lib/audit-logs/interfaces/audit-log-export-options.interface.d.ts +13 -3
  4. package/lib/audit-logs/interfaces/audit-log-export.interface.d.ts +8 -0
  5. package/lib/audit-logs/interfaces/create-audit-log-event-options.interface.d.ts +13 -1
  6. package/lib/audit-logs/serializers/audit-log-export-options.serializer.d.ts +2 -0
  7. package/lib/audit-logs/serializers/audit-log-export-options.serializer.js +14 -0
  8. package/lib/audit-logs/serializers/audit-log-export.serializer.d.ts +2 -0
  9. package/lib/audit-logs/serializers/audit-log-export.serializer.js +12 -0
  10. package/lib/audit-logs/serializers/create-audit-log-event-options.serializer.d.ts +2 -0
  11. package/lib/audit-logs/serializers/create-audit-log-event-options.serializer.js +16 -0
  12. package/lib/audit-logs/serializers/index.d.ts +3 -0
  13. package/lib/audit-logs/serializers/index.js +19 -0
  14. package/lib/audit-trail/audit-trail.d.ts +2 -2
  15. package/lib/audit-trail/audit-trail.spec.js +2 -1
  16. package/lib/common/interfaces/at-least-one-property-of.interface.d.ts +7 -0
  17. package/lib/common/interfaces/event.interface.d.ts +142 -0
  18. package/lib/common/interfaces/index.d.ts +5 -0
  19. package/lib/common/interfaces/index.js +5 -0
  20. package/lib/common/interfaces/list.interface.d.ts +9 -1
  21. package/lib/common/interfaces/workos-response-error.interface.d.ts +8 -0
  22. package/lib/common/serializers/event.serializer.d.ts +2 -0
  23. package/lib/common/serializers/event.serializer.js +40 -0
  24. package/lib/common/serializers/index.d.ts +2 -0
  25. package/lib/common/serializers/index.js +18 -0
  26. package/lib/common/serializers/list.serializer.d.ts +2 -0
  27. package/lib/common/serializers/list.serializer.js +9 -0
  28. package/lib/common/utils/fetch-and-deserialize.d.ts +3 -0
  29. package/lib/common/utils/fetch-and-deserialize.js +23 -0
  30. package/lib/common/utils/pagination.d.ts +15 -0
  31. package/lib/common/utils/pagination.js +90 -0
  32. package/lib/common/utils/workos-mock-response.d.ts +7 -0
  33. package/lib/common/utils/workos-mock-response.js +11 -0
  34. package/lib/directory-sync/directory-sync.d.ts +8 -12
  35. package/lib/directory-sync/directory-sync.js +9 -15
  36. package/lib/directory-sync/directory-sync.spec.js +132 -20
  37. package/lib/directory-sync/interfaces/directory-group.interface.d.ts +40 -0
  38. package/lib/directory-sync/interfaces/directory-user.interface.d.ts +50 -0
  39. package/lib/directory-sync/interfaces/directory.interface.d.ts +47 -2
  40. package/lib/directory-sync/interfaces/index.d.ts +6 -6
  41. package/lib/directory-sync/interfaces/index.js +20 -0
  42. package/lib/directory-sync/interfaces/list-directories-options.interface.d.ts +1 -1
  43. package/lib/directory-sync/interfaces/{list-users-options.interface.d.ts → list-directory-users-options.interface.d.ts} +1 -1
  44. package/lib/directory-sync/interfaces/list-groups-options.interface.d.ts +1 -1
  45. package/lib/directory-sync/serializers/directory-group.serializer.d.ts +4 -0
  46. package/lib/directory-sync/serializers/directory-group.serializer.js +37 -0
  47. package/lib/directory-sync/serializers/directory-user.serializer.d.ts +4 -0
  48. package/lib/directory-sync/serializers/directory-user.serializer.js +43 -0
  49. package/lib/directory-sync/serializers/directory.serializer.d.ts +5 -0
  50. package/lib/directory-sync/serializers/directory.serializer.js +50 -0
  51. package/lib/directory-sync/serializers/index.d.ts +3 -0
  52. package/lib/directory-sync/serializers/index.js +19 -0
  53. package/lib/directory-sync/utils/get-primary-email.d.ts +2 -2
  54. package/lib/directory-sync/utils/get-primary-email.spec.js +11 -8
  55. package/lib/events/events.d.ts +1 -2
  56. package/lib/events/events.js +2 -1
  57. package/lib/events/events.spec.js +39 -5
  58. package/lib/events/interfaces/index.d.ts +0 -1
  59. package/lib/events/interfaces/index.js +0 -1
  60. package/lib/events/interfaces/list-events-options.interface.d.ts +4 -4
  61. package/lib/index.d.ts +1 -1
  62. package/lib/index.js +1 -1
  63. package/lib/mfa/interfaces/challenge.interface.d.ts +9 -0
  64. package/lib/mfa/interfaces/factor.interface.d.ts +13 -4
  65. package/lib/mfa/interfaces/index.d.ts +9 -0
  66. package/lib/mfa/interfaces/index.js +25 -0
  67. package/lib/mfa/interfaces/sms.interface.d.ts +3 -0
  68. package/lib/mfa/interfaces/totp.interface.d.ts +7 -0
  69. package/lib/mfa/interfaces/verify-challenge-response.d.ts +5 -1
  70. package/lib/mfa/mfa.d.ts +2 -8
  71. package/lib/mfa/mfa.js +5 -4
  72. package/lib/mfa/mfa.spec.js +134 -115
  73. package/lib/mfa/serializers/challenge.serializer.d.ts +2 -0
  74. package/lib/mfa/serializers/challenge.serializer.js +13 -0
  75. package/lib/mfa/serializers/factor.serializer.d.ts +2 -0
  76. package/lib/mfa/serializers/factor.serializer.js +7 -0
  77. package/lib/mfa/serializers/index.d.ts +3 -0
  78. package/lib/{webhooks/interfaces → mfa/serializers}/index.js +3 -4
  79. package/lib/mfa/serializers/sms.serializer.d.ts +2 -0
  80. package/lib/mfa/serializers/sms.serializer.js +7 -0
  81. package/lib/mfa/serializers/totp.serializer.d.ts +2 -0
  82. package/lib/mfa/serializers/totp.serializer.js +11 -0
  83. package/lib/mfa/serializers/verify-response.serializer.d.ts +2 -0
  84. package/lib/mfa/serializers/verify-response.serializer.js +9 -0
  85. package/lib/organizations/interfaces/create-organization-options.interface.d.ts +5 -0
  86. package/lib/organizations/interfaces/organization.interface.d.ts +9 -0
  87. package/lib/organizations/interfaces/update-organization-options.interface.d.ts +5 -0
  88. package/lib/organizations/organizations.d.ts +2 -2
  89. package/lib/organizations/organizations.js +9 -9
  90. package/lib/organizations/organizations.spec.js +11 -4
  91. package/lib/organizations/serializers/create-organization-options.serializer.d.ts +2 -0
  92. package/lib/organizations/serializers/create-organization-options.serializer.js +9 -0
  93. package/lib/organizations/serializers/index.d.ts +3 -0
  94. package/lib/organizations/serializers/index.js +19 -0
  95. package/lib/organizations/serializers/organization.serializer.d.ts +2 -0
  96. package/lib/organizations/serializers/organization.serializer.js +13 -0
  97. package/lib/organizations/serializers/update-organization-options.serializer.d.ts +2 -0
  98. package/lib/organizations/serializers/update-organization-options.serializer.js +9 -0
  99. package/lib/passwordless/interfaces/create-passwordless-session-options.interface.d.ts +8 -0
  100. package/lib/passwordless/interfaces/index.d.ts +3 -3
  101. package/lib/passwordless/interfaces/index.js +17 -0
  102. package/lib/passwordless/interfaces/passwordless-session.interface.d.ts +7 -0
  103. package/lib/passwordless/passwordless.d.ts +1 -3
  104. package/lib/passwordless/passwordless.js +2 -1
  105. package/lib/passwordless/serializers/index.d.ts +0 -0
  106. package/lib/passwordless/serializers/index.js +1 -0
  107. package/lib/passwordless/serializers/passwordless-session.serializer.d.ts +2 -0
  108. package/lib/passwordless/serializers/passwordless-session.serializer.js +11 -0
  109. package/lib/portal/interfaces/generate-portal-link-intent.interface.js +1 -1
  110. package/lib/sso/interfaces/connection-type.enum.d.ts +1 -0
  111. package/lib/sso/interfaces/connection-type.enum.js +2 -1
  112. package/lib/sso/interfaces/connection.interface.d.ts +16 -5
  113. package/lib/sso/interfaces/index.d.ts +2 -0
  114. package/lib/sso/interfaces/index.js +2 -0
  115. package/lib/sso/interfaces/list-connections-options.interface.d.ts +5 -0
  116. package/lib/sso/interfaces/profile-and-token.interface.d.ts +6 -2
  117. package/lib/sso/interfaces/profile.interface.d.ts +14 -0
  118. package/lib/sso/serializers/connection.serializer.d.ts +2 -0
  119. package/lib/sso/serializers/connection.serializer.js +16 -0
  120. package/lib/sso/serializers/index.d.ts +3 -0
  121. package/lib/sso/serializers/index.js +19 -0
  122. package/lib/sso/serializers/profile-and-token.serializer.d.ts +2 -0
  123. package/lib/sso/serializers/profile-and-token.serializer.js +9 -0
  124. package/lib/sso/serializers/profile.serializer.d.ts +2 -0
  125. package/lib/sso/serializers/profile.serializer.js +16 -0
  126. package/lib/sso/sso.d.ts +3 -9
  127. package/lib/sso/sso.js +23 -16
  128. package/lib/sso/sso.spec.js +26 -9
  129. package/lib/users/exceptions/index.d.ts +4 -0
  130. package/lib/users/exceptions/index.js +10 -0
  131. package/lib/users/fixtures/list-users.json +0 -1
  132. package/lib/users/fixtures/session.json +2 -0
  133. package/lib/users/fixtures/user.json +0 -1
  134. package/lib/users/interfaces/add-user-to-organization-options.interface.d.ts +4 -1
  135. package/lib/users/interfaces/authenticate-user-with-magic-auth-options.interface.d.ts +21 -0
  136. package/lib/users/interfaces/authenticate-user-with-password-options.interface.d.ts +14 -1
  137. package/lib/users/interfaces/authenticate-user-with-token-options.interface.d.ts +10 -1
  138. package/lib/users/interfaces/authentication-response.interface.d.ts +7 -3
  139. package/lib/users/interfaces/complete-password-reset-options.interface.d.ts +4 -0
  140. package/lib/users/interfaces/create-email-verification-challenge-options.interface.d.ts +9 -2
  141. package/lib/users/interfaces/create-password-reset-challenge-options.interface.d.ts +9 -1
  142. package/lib/users/interfaces/create-user-options.interface.d.ts +8 -1
  143. package/lib/users/interfaces/index.d.ts +7 -0
  144. package/lib/users/interfaces/index.js +7 -0
  145. package/lib/users/interfaces/magic-auth-challenge.interface.d.ts +3 -0
  146. package/lib/users/interfaces/remove-user-from-organization-options.interface.d.ts +2 -2
  147. package/lib/users/interfaces/revoke-all-sessions-for-user-options.interface.d.ts +3 -0
  148. package/lib/users/interfaces/revoke-all-sessions-for-user-options.interface.js +2 -0
  149. package/lib/users/interfaces/revoke-session-options.interface.d.ts +7 -0
  150. package/lib/users/interfaces/send-magic-auth-code-options.interface.d.ts +6 -0
  151. package/lib/users/interfaces/send-magic-auth-code-options.interface.js +2 -0
  152. package/lib/users/interfaces/session.interface.d.ts +35 -0
  153. package/lib/users/interfaces/update-user-options.interface.d.ts +14 -0
  154. package/lib/users/interfaces/update-user-options.interface.js +2 -0
  155. package/lib/users/interfaces/update-user-password-options.interface.d.ts +7 -0
  156. package/lib/users/interfaces/update-user-password-options.interface.js +2 -0
  157. package/lib/users/interfaces/user.interface.d.ts +28 -18
  158. package/lib/users/interfaces/verify-session.interface.d.ts +10 -2
  159. package/lib/users/serializers/authenticate-user-with-magic-auth-options.serializer.d.ts +2 -0
  160. package/lib/users/serializers/authenticate-user-with-magic-auth-options.serializer.js +14 -0
  161. package/lib/users/serializers/authenticate-user-with-password-options.serializer.d.ts +2 -0
  162. package/lib/users/serializers/authenticate-user-with-password-options.serializer.js +14 -0
  163. package/lib/users/serializers/authenticate-user-with-token-options.serializer.d.ts +2 -0
  164. package/lib/users/serializers/authenticate-user-with-token-options.serializer.js +11 -0
  165. package/lib/users/serializers/authentication-response.serializer.d.ts +2 -0
  166. package/lib/users/serializers/authentication-response.serializer.js +10 -0
  167. package/lib/users/serializers/complete-password-reset-options.serializer.d.ts +2 -0
  168. package/lib/users/serializers/complete-password-reset-options.serializer.js +8 -0
  169. package/lib/users/serializers/create-email-verification-challenge.serializer.d.ts +2 -0
  170. package/lib/users/serializers/create-email-verification-challenge.serializer.js +9 -0
  171. package/lib/users/serializers/create-password-reset-challenge.serializer.d.ts +3 -0
  172. package/lib/users/serializers/create-password-reset-challenge.serializer.js +14 -0
  173. package/lib/users/serializers/create-user-options.serializer.d.ts +2 -0
  174. package/lib/users/serializers/create-user-options.serializer.js +11 -0
  175. package/lib/users/serializers/index.d.ts +15 -0
  176. package/lib/users/serializers/index.js +31 -0
  177. package/lib/users/serializers/revoke-session-options.serializer.d.ts +2 -0
  178. package/lib/users/serializers/revoke-session-options.serializer.js +14 -0
  179. package/lib/users/serializers/send-magic-auth-code-options.serializer.d.ts +2 -0
  180. package/lib/users/serializers/send-magic-auth-code-options.serializer.js +7 -0
  181. package/lib/users/serializers/session.serializer.d.ts +4 -0
  182. package/lib/users/serializers/session.serializer.js +22 -0
  183. package/lib/users/serializers/update-user-options.serializer.d.ts +2 -0
  184. package/lib/users/serializers/update-user-options.serializer.js +8 -0
  185. package/lib/users/serializers/update-user-password-options.serializer.d.ts +2 -0
  186. package/lib/users/serializers/update-user-password-options.serializer.js +7 -0
  187. package/lib/users/serializers/user.serializer.d.ts +2 -0
  188. package/lib/users/serializers/user.serializer.js +24 -0
  189. package/lib/users/serializers/verify-session.serializer.d.ts +3 -0
  190. package/lib/users/serializers/verify-session.serializer.js +15 -0
  191. package/lib/users/users.d.ts +11 -7
  192. package/lib/users/users.js +54 -30
  193. package/lib/users/users.spec.js +133 -49
  194. package/lib/webhooks/fixtures/webhook.json +67 -1
  195. package/lib/webhooks/webhooks.d.ts +2 -2
  196. package/lib/webhooks/webhooks.js +2 -1
  197. package/lib/webhooks/webhooks.spec.js +8 -6
  198. package/lib/workos.d.ts +5 -4
  199. package/lib/workos.js +4 -1
  200. package/lib/workos.spec.js +11 -1
  201. package/package.json +14 -15
  202. package/lib/directory-sync/interfaces/group.interface.d.ts +0 -10
  203. package/lib/directory-sync/interfaces/user.interface.d.ts +0 -23
  204. package/lib/events/interfaces/event.interface.d.ts +0 -63
  205. package/lib/webhooks/interfaces/index.d.ts +0 -4
  206. package/lib/webhooks/interfaces/webhook-directory-group.interface.d.ts +0 -10
  207. package/lib/webhooks/interfaces/webhook-directory-user.interface.d.ts +0 -5
  208. package/lib/webhooks/interfaces/webhook-directory.interface.d.ts +0 -20
  209. package/lib/webhooks/interfaces/webhook.interface.d.ts +0 -73
  210. /package/lib/{directory-sync/interfaces/group.interface.js → common/interfaces/at-least-one-property-of.interface.js} +0 -0
  211. /package/lib/{events → common}/interfaces/event.interface.js +0 -0
  212. /package/lib/{directory-sync/interfaces/list-users-options.interface.js → common/interfaces/workos-response-error.interface.js} +0 -0
  213. /package/lib/directory-sync/interfaces/{user.interface.js → directory-group.interface.js} +0 -0
  214. /package/lib/{webhooks/interfaces/webhook-directory-group.interface.js → directory-sync/interfaces/directory-user.interface.js} +0 -0
  215. /package/lib/{webhooks/interfaces/webhook-directory-user.interface.js → directory-sync/interfaces/list-directory-users-options.interface.js} +0 -0
  216. /package/lib/{webhooks/interfaces/webhook-directory.interface.js → users/interfaces/authenticate-user-with-magic-auth-options.interface.js} +0 -0
  217. /package/lib/{webhooks/interfaces/webhook.interface.js → users/interfaces/magic-auth-challenge.interface.js} +0 -0
@@ -15,7 +15,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const axios_1 = __importDefault(require("axios"));
16
16
  const axios_mock_adapter_1 = __importDefault(require("axios-mock-adapter"));
17
17
  const workos_1 = require("../workos");
18
+ const interfaces_1 = require("./interfaces");
18
19
  describe('SSO', () => {
20
+ const connectionResponse = {
21
+ object: 'connection',
22
+ id: 'conn_123',
23
+ organization_id: 'org_123',
24
+ name: 'Connection',
25
+ connection_type: interfaces_1.ConnectionType.OktaSAML,
26
+ state: 'active',
27
+ domains: [],
28
+ created_at: '2023-07-17T20:07:20.055Z',
29
+ updated_at: '2023-07-17T20:07:20.055Z',
30
+ };
19
31
  describe('SSO', () => {
20
32
  describe('getAuthorizationURL', () => {
21
33
  describe('with no custom api hostname', () => {
@@ -113,7 +125,7 @@ describe('SSO', () => {
113
125
  redirectURI: 'example.com/sso/workos/callback',
114
126
  state: 'custom state',
115
127
  });
116
- expect(url).toMatchInlineSnapshot(`"https://api.workos.com/sso/authorize?client_id=proj_123&connection=connection_123&domain_hint=lyft.com&redirect_uri=example.com%2Fsso%2Fworkos%2Fcallback&response_type=code&state=custom%20state"`);
128
+ expect(url).toMatchInlineSnapshot(`"https://api.workos.com/sso/authorize?client_id=proj_123&connection=connection_123&domain_hint=lyft.com&redirect_uri=example.com%2Fsso%2Fworkos%2Fcallback&response_type=code&state=custom+state"`);
117
129
  });
118
130
  });
119
131
  describe('with loginHint', () => {
@@ -126,7 +138,7 @@ describe('SSO', () => {
126
138
  redirectURI: 'example.com/sso/workos/callback',
127
139
  state: 'custom state',
128
140
  });
129
- expect(url).toMatchInlineSnapshot(`"https://api.workos.com/sso/authorize?client_id=proj_123&connection=connection_123&login_hint=foo%40workos.com&redirect_uri=example.com%2Fsso%2Fworkos%2Fcallback&response_type=code&state=custom%20state"`);
141
+ expect(url).toMatchInlineSnapshot(`"https://api.workos.com/sso/authorize?client_id=proj_123&connection=connection_123&login_hint=foo%40workos.com&redirect_uri=example.com%2Fsso%2Fworkos%2Fcallback&response_type=code&state=custom+state"`);
130
142
  });
131
143
  });
132
144
  });
@@ -172,7 +184,7 @@ describe('SSO', () => {
172
184
  return [404];
173
185
  });
174
186
  const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
175
- const { access_token: accessToken, profile } = yield workos.sso.getProfileAndToken({
187
+ const { accessToken, profile } = yield workos.sso.getProfileAndToken({
176
188
  code: 'authorization_code',
177
189
  clientID: 'proj_123',
178
190
  });
@@ -223,7 +235,7 @@ describe('SSO', () => {
223
235
  return [404];
224
236
  });
225
237
  const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
226
- const { access_token: accessToken, profile } = yield workos.sso.getProfileAndToken({
238
+ const { accessToken, profile } = yield workos.sso.getProfileAndToken({
227
239
  code: 'authorization_code',
228
240
  clientID: 'proj_123',
229
241
  });
@@ -266,7 +278,7 @@ describe('SSO', () => {
266
278
  });
267
279
  expect(mock.history.get.length).toBe(1);
268
280
  const { headers } = mock.history.get[0];
269
- expect(headers.Authorization).toBe(`Bearer access_token`);
281
+ expect(headers === null || headers === void 0 ? void 0 : headers.Authorization).toBe(`Bearer access_token`);
270
282
  expect(profile.id).toBe('prof_123');
271
283
  }));
272
284
  });
@@ -282,19 +294,24 @@ describe('SSO', () => {
282
294
  describe('getConnection', () => {
283
295
  it(`requests a Connection`, () => __awaiter(void 0, void 0, void 0, function* () {
284
296
  const mock = new axios_mock_adapter_1.default(axios_1.default);
285
- mock.onGet('/connections/conn_123').replyOnce(200, {});
297
+ mock.onGet('/connections/conn_123').replyOnce(200, connectionResponse);
286
298
  const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
287
- yield workos.sso.getConnection('conn_123');
299
+ const subject = yield workos.sso.getConnection('conn_123');
288
300
  expect(mock.history.get[0].url).toEqual('/connections/conn_123');
301
+ expect(subject.connectionType).toEqual('OktaSAML');
289
302
  }));
290
303
  });
291
304
  describe('listConnections', () => {
292
305
  it(`requests a list of Connections`, () => __awaiter(void 0, void 0, void 0, function* () {
293
306
  const mock = new axios_mock_adapter_1.default(axios_1.default);
294
- mock.onGet('/connections').replyOnce(200, {});
307
+ mock.onGet('/connections').replyOnce(200, {
308
+ data: [connectionResponse],
309
+ list_metadata: {},
310
+ });
295
311
  const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
296
- yield workos.sso.listConnections();
312
+ const subject = yield workos.sso.listConnections();
297
313
  expect(mock.history.get[0].url).toEqual('/connections');
314
+ expect(subject.data).toHaveLength(1);
298
315
  }));
299
316
  });
300
317
  });
@@ -0,0 +1,4 @@
1
+ import { UserResponse } from '../interfaces';
2
+ export declare class UnexpectedUserTypeException extends Error {
3
+ constructor(user: UserResponse);
4
+ }
@@ -0,0 +1,10 @@
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;
@@ -7,7 +7,6 @@
7
7
  "email": "test01@example.com",
8
8
  "first_name": "Test 01",
9
9
  "last_name": "User",
10
- "organization_memberships": [],
11
10
  "created_at": "2023-07-18T02:07:19.911Z",
12
11
  "updated_at": "2023-07-18T02:07:19.911Z",
13
12
  "user_type": "unmanaged",
@@ -2,5 +2,7 @@
2
2
  "id": "session_01H5K05VP5CPCXJA5Z7G191GS4",
3
3
  "created_at": "2023-07-18T04:40:14.954Z",
4
4
  "expires_at": "2023-07-18T22:40:15.555Z",
5
+ "authorized_organizations": [],
6
+ "unauthorized_organizations": [],
5
7
  "token": "really-long-token"
6
8
  }
@@ -4,7 +4,6 @@
4
4
  "email": "test01@example.com",
5
5
  "first_name": "Test 01",
6
6
  "last_name": "User",
7
- "organization_memberships": [],
8
7
  "created_at": "2023-07-18T02:07:19.911Z",
9
8
  "updated_at": "2023-07-18T02:07:19.911Z",
10
9
  "user_type": "unmanaged",
@@ -1,4 +1,7 @@
1
1
  export interface AddUserToOrganizationOptions {
2
- user_id: string;
2
+ userId: string;
3
+ organizationId: string;
4
+ }
5
+ export interface SerializedAddUserToOrganizationOptions {
3
6
  organization_id: string;
4
7
  }
@@ -0,0 +1,21 @@
1
+ export interface AuthenticateUserWithMagicAuthOptions {
2
+ clientId: string;
3
+ code: string;
4
+ magicAuthChallengeId: string;
5
+ ipAddress?: string;
6
+ userAgent?: string;
7
+ expiresIn?: number;
8
+ }
9
+ export interface AuthenticateUserWithMagicAuthCredentials {
10
+ clientSecret: string | undefined;
11
+ }
12
+ export interface SerializedAuthenticateUserWithMagicAuthOptions {
13
+ grant_type: 'urn:workos:oauth:grant-type:magic-auth:code';
14
+ client_id: string;
15
+ client_secret: string | undefined;
16
+ code: string;
17
+ magic_auth_challenge_id: string;
18
+ ip_address?: string;
19
+ user_agent?: string;
20
+ expires_in?: number;
21
+ }
@@ -1,8 +1,21 @@
1
1
  export interface AuthenticateUserWithPasswordOptions {
2
+ clientId: string;
3
+ email: string;
4
+ password: string;
5
+ ipAddress?: string;
6
+ userAgent?: string;
7
+ expiresIn?: number;
8
+ }
9
+ export interface AuthenticateUserWithPasswordCredentials {
10
+ clientSecret: string | undefined;
11
+ }
12
+ export interface SerializedAuthenticateUserWithPasswordOptions {
13
+ grant_type: 'password';
14
+ client_id: string;
15
+ client_secret: string | undefined;
2
16
  email: string;
3
17
  password: string;
4
18
  ip_address?: string;
5
19
  user_agent?: string;
6
- start_session?: boolean;
7
20
  expires_in?: number;
8
21
  }
@@ -1,6 +1,15 @@
1
1
  export interface AuthenticateUserWithTokenOptions {
2
+ clientId: string;
3
+ code: string;
4
+ expiresIn?: number;
5
+ }
6
+ export interface AuthenticateUserWithTokenCredentials {
7
+ clientSecret: string | undefined;
8
+ }
9
+ export interface SerializedAuthenticateUserWithTokenOptions {
10
+ grant_type: 'authorization_code';
2
11
  client_id: string;
12
+ client_secret: string | undefined;
3
13
  code: string;
4
- start_session?: boolean;
5
14
  expires_in?: number;
6
15
  }
@@ -1,6 +1,10 @@
1
- import { User } from './user.interface';
2
- import { Session } from './session.interface';
1
+ import { User, UserResponse } from './user.interface';
2
+ import { Session, SessionResponse } from './session.interface';
3
3
  export interface AuthenticationResponse {
4
- session?: Session;
4
+ session: Session;
5
5
  user: User;
6
6
  }
7
+ export interface AuthenticationResponseResponse {
8
+ session: SessionResponse;
9
+ user: UserResponse;
10
+ }
@@ -1,4 +1,8 @@
1
1
  export interface CompletePasswordResetOptions {
2
+ token: string;
3
+ newPassword: string;
4
+ }
5
+ export interface SerializedCompletePasswordResetOptions {
2
6
  token: string;
3
7
  new_password: string;
4
8
  }
@@ -1,9 +1,16 @@
1
- import { User } from './user.interface';
1
+ import { User, UserResponse } from './user.interface';
2
2
  export interface CreateEmailVerificationChallengeOptions {
3
- user_id: string;
3
+ userId: string;
4
+ verificationUrl: string;
5
+ }
6
+ export interface SerializedCreateEmailVerificationChallengeOptions {
4
7
  verification_url: string;
5
8
  }
6
9
  export interface CreateEmailVerificationChallengeResponse {
7
10
  token: string;
8
11
  user: User;
9
12
  }
13
+ export interface CreateEmailVerificationChallengeResponseResponse {
14
+ token: string;
15
+ user: UserResponse;
16
+ }
@@ -1,5 +1,9 @@
1
- import { User } from './user.interface';
1
+ import { User, UserResponse } from './user.interface';
2
2
  export interface CreatePasswordResetChallengeOptions {
3
+ email: string;
4
+ passwordResetUrl: string;
5
+ }
6
+ export interface SerializedCreatePasswordResetChallengeOptions {
3
7
  email: string;
4
8
  password_reset_url: string;
5
9
  }
@@ -7,3 +11,7 @@ export interface CreatePasswordResetChallengeResponse {
7
11
  token: string;
8
12
  user: User;
9
13
  }
14
+ export interface CreatePasswordResetChallengeResponseResponse {
15
+ token: string;
16
+ user: UserResponse;
17
+ }
@@ -1,6 +1,13 @@
1
1
  export interface CreateUserOptions {
2
2
  email: string;
3
- password: string;
3
+ password?: string;
4
+ firstName?: string;
5
+ lastName?: string;
6
+ emailVerified?: boolean;
7
+ }
8
+ export interface SerializedCreateUserOptions {
9
+ email: string;
10
+ password?: string;
4
11
  first_name?: string;
5
12
  last_name?: string;
6
13
  email_verified?: boolean;
@@ -1,4 +1,5 @@
1
1
  export * from './add-user-to-organization-options.interface';
2
+ export * from './authenticate-user-with-magic-auth-options.interface';
2
3
  export * from './authenticate-user-with-password-options.interface';
3
4
  export * from './authenticate-user-with-token-options.interface';
4
5
  export * from './authentication-response.interface';
@@ -7,7 +8,13 @@ export * from './create-email-verification-challenge-options.interface';
7
8
  export * from './create-password-reset-challenge-options.interface';
8
9
  export * from './create-user-options.interface';
9
10
  export * from './list-users-options.interface';
11
+ export * from './magic-auth-challenge.interface';
10
12
  export * from './remove-user-from-organization-options.interface';
13
+ export * from './revoke-all-sessions-for-user-options.interface';
11
14
  export * from './revoke-session-options.interface';
15
+ export * from './send-magic-auth-code-options.interface';
16
+ export * from './session.interface';
17
+ export * from './update-user-options.interface';
18
+ export * from './update-user-password-options.interface';
12
19
  export * from './user.interface';
13
20
  export * from './verify-session.interface';
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./add-user-to-organization-options.interface"), exports);
18
+ __exportStar(require("./authenticate-user-with-magic-auth-options.interface"), exports);
18
19
  __exportStar(require("./authenticate-user-with-password-options.interface"), exports);
19
20
  __exportStar(require("./authenticate-user-with-token-options.interface"), exports);
20
21
  __exportStar(require("./authentication-response.interface"), exports);
@@ -23,7 +24,13 @@ __exportStar(require("./create-email-verification-challenge-options.interface"),
23
24
  __exportStar(require("./create-password-reset-challenge-options.interface"), exports);
24
25
  __exportStar(require("./create-user-options.interface"), exports);
25
26
  __exportStar(require("./list-users-options.interface"), exports);
27
+ __exportStar(require("./magic-auth-challenge.interface"), exports);
26
28
  __exportStar(require("./remove-user-from-organization-options.interface"), exports);
29
+ __exportStar(require("./revoke-all-sessions-for-user-options.interface"), exports);
27
30
  __exportStar(require("./revoke-session-options.interface"), exports);
31
+ __exportStar(require("./send-magic-auth-code-options.interface"), exports);
32
+ __exportStar(require("./session.interface"), exports);
33
+ __exportStar(require("./update-user-options.interface"), exports);
34
+ __exportStar(require("./update-user-password-options.interface"), exports);
28
35
  __exportStar(require("./user.interface"), exports);
29
36
  __exportStar(require("./verify-session.interface"), exports);
@@ -0,0 +1,3 @@
1
+ export interface MagicAuthChallenge {
2
+ id: string;
3
+ }
@@ -1,4 +1,4 @@
1
1
  export interface RemoveUserFromOrganizationOptions {
2
- user_id: string;
3
- organization_id: string;
2
+ userId: string;
3
+ organizationId: string;
4
4
  }
@@ -0,0 +1,3 @@
1
+ export interface RevokeAllSessionsForUserOptions {
2
+ userId: string;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,8 +1,15 @@
1
1
  export type RevokeSessionOptions = SessionId | SessionToken;
2
+ export type SerializedRevokeSessionOptions = SerializedSessionId | SerializedSessionToken;
2
3
  interface SessionId {
4
+ sessionId: string;
5
+ }
6
+ interface SerializedSessionId {
3
7
  session_id: string;
4
8
  }
5
9
  interface SessionToken {
10
+ sessionToken: string;
11
+ }
12
+ interface SerializedSessionToken {
6
13
  session_token: string;
7
14
  }
8
15
  export {};
@@ -0,0 +1,6 @@
1
+ export interface SendMagicAuthCodeOptions {
2
+ emailAddress: string;
3
+ }
4
+ export interface SerializedSendMagicAuthCodeOptions {
5
+ email_address: string;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,41 @@
1
1
  export interface Session {
2
+ id: string;
3
+ createdAt: string;
4
+ expiresAt: string;
5
+ authorizedOrganizations: AuthorizedOrganization[];
6
+ unauthorizedOrganizations: UnauthorizedOrganization[];
7
+ token: string;
8
+ }
9
+ interface OrganizationSummary {
10
+ id: string;
11
+ name: string;
12
+ }
13
+ interface AuthorizedOrganization {
14
+ organization: OrganizationSummary;
15
+ }
16
+ type SessionAuthenticationMethod = 'GoogleOauth' | 'MagicAuth' | 'MicrosoftOauth' | 'Password';
17
+ export type UnauthorizedOrganizationReason = {
18
+ type: 'authentication_method_required';
19
+ allowedAuthenticationMethods: SessionAuthenticationMethod[];
20
+ };
21
+ export type UnauthorizedOrganizationReasonResponse = {
22
+ type: 'authentication_method_required';
23
+ allowed_authentication_methods: SessionAuthenticationMethod[];
24
+ };
25
+ export interface UnauthorizedOrganization {
26
+ organization: OrganizationSummary;
27
+ reasons: UnauthorizedOrganizationReason[];
28
+ }
29
+ export interface UnauthorizedOrganizationResponse {
30
+ organization: OrganizationSummary;
31
+ reasons: UnauthorizedOrganizationReasonResponse[];
32
+ }
33
+ export interface SessionResponse {
2
34
  id: string;
3
35
  created_at: string;
4
36
  expires_at: string;
37
+ authorized_organizations: AuthorizedOrganization[];
38
+ unauthorized_organizations: UnauthorizedOrganizationResponse[];
5
39
  token: string;
6
40
  }
41
+ export {};
@@ -0,0 +1,14 @@
1
+ import { AtLeastOnePropertyOf } from '../../common/interfaces';
2
+ interface BaseUpdateUserOptions {
3
+ userId: string;
4
+ }
5
+ interface UpdateUserOptionsProperties {
6
+ firstName: string;
7
+ lastName: string;
8
+ }
9
+ export type UpdateUserOptions = BaseUpdateUserOptions & AtLeastOnePropertyOf<UpdateUserOptionsProperties>;
10
+ export interface SerializedUpdateUserOptions {
11
+ first_name?: string;
12
+ last_name?: string;
13
+ }
14
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ export interface UpdateUserPasswordOptions {
2
+ userId: string;
3
+ password: string;
4
+ }
5
+ export interface SerializedUpdateUserPasswordOptions {
6
+ password: string;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,31 +1,41 @@
1
- export type User = ManagedUser | UnmanangedUser;
1
+ export type User = ManagedUser | UnmanagedUser;
2
+ export type UserResponse = ManagedUserResponse | UnmanagedUserResponse;
2
3
  interface ManagedUser extends BaseUser {
4
+ userType: 'managed';
5
+ ssoProfileId: string | null;
6
+ }
7
+ interface ManagedUserResponse extends BaseUserResponse {
3
8
  user_type: 'managed';
4
- organization_memberships: [OrganizationMembership];
5
- sso_profile_id: string;
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;
6
16
  }
7
- interface UnmanangedUser extends BaseUser {
17
+ interface UnmanagedUserResponse extends BaseUserResponse {
8
18
  user_type: 'unmanaged';
9
- organization_memberships: OrganizationMembership[];
10
- email_verified_at?: string;
11
- google_oauth_profile_id?: string;
19
+ email_verified_at: string | null;
20
+ google_oauth_profile_id: string | null;
21
+ microsoft_oauth_profile_id: string | null;
12
22
  }
13
- interface BaseUser {
23
+ export interface BaseUser {
14
24
  object: 'user';
15
25
  id: string;
16
26
  email: string;
17
- first_name?: string;
18
- last_name?: string;
19
- created_at: string;
20
- updated_at: string;
27
+ firstName: string | null;
28
+ lastName: string | null;
29
+ createdAt: string;
30
+ updatedAt: string;
21
31
  }
22
- interface OrganizationMembership {
23
- organization: OrganizationSummary;
32
+ interface BaseUserResponse {
33
+ object: 'user';
34
+ id: string;
35
+ email: string;
36
+ first_name: string | null;
37
+ last_name: string | null;
24
38
  created_at: string;
25
39
  updated_at: string;
26
40
  }
27
- interface OrganizationSummary {
28
- id: string;
29
- name: string;
30
- }
31
41
  export {};
@@ -1,6 +1,10 @@
1
- import { User } from './user.interface';
2
- import { Session } from './session.interface';
1
+ import { User, UserResponse } from './user.interface';
2
+ import { Session, SessionResponse } from './session.interface';
3
3
  export interface VerifySessionOptions {
4
+ token: string;
5
+ clientId: string;
6
+ }
7
+ export interface SerializedVerifySessionOptions {
4
8
  token: string;
5
9
  client_id: string;
6
10
  }
@@ -8,3 +12,7 @@ export interface VerifySessionResponse {
8
12
  session: Session;
9
13
  user: User;
10
14
  }
15
+ export interface VerifySessionResponseResponse {
16
+ session: SessionResponse;
17
+ user: UserResponse;
18
+ }
@@ -0,0 +1,2 @@
1
+ import { AuthenticateUserWithMagicAuthCredentials, AuthenticateUserWithMagicAuthOptions, SerializedAuthenticateUserWithMagicAuthOptions } from '../interfaces';
2
+ export declare const serializeAuthenticateUserWithMagicAuthOptions: (options: AuthenticateUserWithMagicAuthOptions & AuthenticateUserWithMagicAuthCredentials) => SerializedAuthenticateUserWithMagicAuthOptions;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeAuthenticateUserWithMagicAuthOptions = void 0;
4
+ const serializeAuthenticateUserWithMagicAuthOptions = (options) => ({
5
+ grant_type: 'urn:workos:oauth:grant-type:magic-auth:code',
6
+ client_id: options.clientId,
7
+ client_secret: options.clientSecret,
8
+ code: options.code,
9
+ magic_auth_challenge_id: options.magicAuthChallengeId,
10
+ ip_address: options.ipAddress,
11
+ user_agent: options.userAgent,
12
+ expires_in: options.expiresIn,
13
+ });
14
+ exports.serializeAuthenticateUserWithMagicAuthOptions = serializeAuthenticateUserWithMagicAuthOptions;
@@ -0,0 +1,2 @@
1
+ import { AuthenticateUserWithPasswordCredentials, AuthenticateUserWithPasswordOptions, SerializedAuthenticateUserWithPasswordOptions } from '../interfaces';
2
+ export declare const serializeAuthenticateUserWithPasswordOptions: (options: AuthenticateUserWithPasswordOptions & AuthenticateUserWithPasswordCredentials) => SerializedAuthenticateUserWithPasswordOptions;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeAuthenticateUserWithPasswordOptions = void 0;
4
+ const serializeAuthenticateUserWithPasswordOptions = (options) => ({
5
+ grant_type: 'password',
6
+ client_id: options.clientId,
7
+ client_secret: options.clientSecret,
8
+ email: options.email,
9
+ password: options.password,
10
+ ip_address: options.ipAddress,
11
+ user_agent: options.userAgent,
12
+ expires_in: options.expiresIn,
13
+ });
14
+ exports.serializeAuthenticateUserWithPasswordOptions = serializeAuthenticateUserWithPasswordOptions;
@@ -0,0 +1,2 @@
1
+ import { AuthenticateUserWithTokenCredentials, AuthenticateUserWithTokenOptions, SerializedAuthenticateUserWithTokenOptions } from '../interfaces';
2
+ export declare const serializeAuthenticateUserWithTokenOptions: (options: AuthenticateUserWithTokenOptions & AuthenticateUserWithTokenCredentials) => SerializedAuthenticateUserWithTokenOptions;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeAuthenticateUserWithTokenOptions = void 0;
4
+ const serializeAuthenticateUserWithTokenOptions = (options) => ({
5
+ grant_type: 'authorization_code',
6
+ client_id: options.clientId,
7
+ client_secret: options.clientSecret,
8
+ code: options.code,
9
+ expires_in: options.expiresIn,
10
+ });
11
+ exports.serializeAuthenticateUserWithTokenOptions = serializeAuthenticateUserWithTokenOptions;
@@ -0,0 +1,2 @@
1
+ import { AuthenticationResponse, AuthenticationResponseResponse } from '../interfaces';
2
+ export declare const deserializeAuthenticationResponse: (authenticationResponse: AuthenticationResponseResponse) => AuthenticationResponse;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeAuthenticationResponse = void 0;
4
+ const session_serializer_1 = require("./session.serializer");
5
+ const user_serializer_1 = require("./user.serializer");
6
+ const deserializeAuthenticationResponse = (authenticationResponse) => ({
7
+ session: (0, session_serializer_1.deserializeSession)(authenticationResponse.session),
8
+ user: (0, user_serializer_1.deserializeUser)(authenticationResponse.user),
9
+ });
10
+ exports.deserializeAuthenticationResponse = deserializeAuthenticationResponse;
@@ -0,0 +1,2 @@
1
+ import { CompletePasswordResetOptions, SerializedCompletePasswordResetOptions } from '../interfaces';
2
+ export declare const serializeCompletePasswordResetOptions: (options: CompletePasswordResetOptions) => SerializedCompletePasswordResetOptions;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeCompletePasswordResetOptions = void 0;
4
+ const serializeCompletePasswordResetOptions = (options) => ({
5
+ token: options.token,
6
+ new_password: options.newPassword,
7
+ });
8
+ exports.serializeCompletePasswordResetOptions = serializeCompletePasswordResetOptions;
@@ -0,0 +1,2 @@
1
+ import { CreateEmailVerificationChallengeResponse, CreateEmailVerificationChallengeResponseResponse } from '../interfaces';
2
+ export declare const deserializeCreateEmailVerificationChallengeResponse: (createEmailVerificationChallengeResponse: CreateEmailVerificationChallengeResponseResponse) => CreateEmailVerificationChallengeResponse;