@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
@@ -28,8 +28,10 @@ describe('Organizations', () => {
28
28
  describe('without any options', () => {
29
29
  it('returns organizations and metadata', () => __awaiter(void 0, void 0, void 0, function* () {
30
30
  mock.onGet('/organizations').replyOnce(200, list_organizations_json_1.default);
31
- const { data, list_metadata: listMetadata } = yield workos.organizations.listOrganizations();
32
- expect(mock.history.get[0].params).toBeUndefined();
31
+ const { data, listMetadata } = yield workos.organizations.listOrganizations();
32
+ expect(mock.history.get[0].params).toEqual({
33
+ order: 'desc',
34
+ });
33
35
  expect(mock.history.get[0].url).toEqual('/organizations');
34
36
  expect(data).toHaveLength(7);
35
37
  expect(listMetadata).toEqual({
@@ -50,6 +52,7 @@ describe('Organizations', () => {
50
52
  });
51
53
  expect(mock.history.get[0].params).toEqual({
52
54
  domains: ['example.com'],
55
+ order: 'desc',
53
56
  });
54
57
  expect(mock.history.get[0].url).toEqual('/organizations');
55
58
  expect(data).toHaveLength(7);
@@ -67,6 +70,7 @@ describe('Organizations', () => {
67
70
  });
68
71
  expect(mock.history.get[0].params).toEqual({
69
72
  before: 'before-id',
73
+ order: 'desc',
70
74
  });
71
75
  expect(mock.history.get[0].url).toEqual('/organizations');
72
76
  expect(data).toHaveLength(7);
@@ -84,6 +88,7 @@ describe('Organizations', () => {
84
88
  });
85
89
  expect(mock.history.get[0].params).toEqual({
86
90
  after: 'after-id',
91
+ order: 'desc',
87
92
  });
88
93
  expect(mock.history.get[0].url).toEqual('/organizations');
89
94
  expect(data).toHaveLength(7);
@@ -101,6 +106,7 @@ describe('Organizations', () => {
101
106
  });
102
107
  expect(mock.history.get[0].params).toEqual({
103
108
  limit: 10,
109
+ order: 'desc',
104
110
  });
105
111
  expect(mock.history.get[0].url).toEqual('/organizations');
106
112
  expect(data).toHaveLength(7);
@@ -110,6 +116,7 @@ describe('Organizations', () => {
110
116
  describe('createOrganization', () => {
111
117
  describe('with an idempotency key', () => {
112
118
  it('includes an idempotency key with request', () => __awaiter(void 0, void 0, void 0, function* () {
119
+ var _a;
113
120
  mock
114
121
  .onPost('/organizations', {
115
122
  domains: ['example.com'],
@@ -122,7 +129,7 @@ describe('Organizations', () => {
122
129
  }, {
123
130
  idempotencyKey: 'the-idempotency-key',
124
131
  });
125
- expect(mock.history.post[0].headers['Idempotency-Key']).toEqual('the-idempotency-key');
132
+ expect((_a = mock.history.post[0].headers) === null || _a === void 0 ? void 0 : _a['Idempotency-Key']).toEqual('the-idempotency-key');
126
133
  }));
127
134
  });
128
135
  describe('with a valid payload', () => {
@@ -170,7 +177,7 @@ describe('Organizations', () => {
170
177
  expect(mock.history.get[0].url).toEqual('/organizations/org_01EHT88Z8J8795GZNQ4ZP1J81T');
171
178
  expect(subject.id).toEqual('org_01EHT88Z8J8795GZNQ4ZP1J81T');
172
179
  expect(subject.name).toEqual('Test Organization 3');
173
- expect(subject.allow_profiles_outside_organization).toEqual(false);
180
+ expect(subject.allowProfilesOutsideOrganization).toEqual(false);
174
181
  expect(subject.domains).toHaveLength(1);
175
182
  }));
176
183
  });
@@ -0,0 +1,2 @@
1
+ import { CreateOrganizationOptions, SerializedCreateOrganizationOptions } from '../interfaces';
2
+ export declare const serializeCreateOrganizationOptions: (options: CreateOrganizationOptions) => SerializedCreateOrganizationOptions;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeCreateOrganizationOptions = void 0;
4
+ const serializeCreateOrganizationOptions = (options) => ({
5
+ name: options.name,
6
+ allow_profiles_outside_organization: options.allowProfilesOutsideOrganization,
7
+ domains: options.domains,
8
+ });
9
+ exports.serializeCreateOrganizationOptions = serializeCreateOrganizationOptions;
@@ -0,0 +1,3 @@
1
+ export * from './create-organization-options.serializer';
2
+ export * from './organization.serializer';
3
+ export * from './update-organization-options.serializer';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./create-organization-options.serializer"), exports);
18
+ __exportStar(require("./organization.serializer"), exports);
19
+ __exportStar(require("./update-organization-options.serializer"), exports);
@@ -0,0 +1,2 @@
1
+ import { Organization, OrganizationResponse } from '../interfaces';
2
+ export declare const deserializeOrganization: (organization: OrganizationResponse) => Organization;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeOrganization = void 0;
4
+ const deserializeOrganization = (organization) => ({
5
+ object: organization.object,
6
+ id: organization.id,
7
+ name: organization.name,
8
+ allowProfilesOutsideOrganization: organization.allow_profiles_outside_organization,
9
+ domains: organization.domains,
10
+ createdAt: organization.created_at,
11
+ updatedAt: organization.updated_at,
12
+ });
13
+ exports.deserializeOrganization = deserializeOrganization;
@@ -0,0 +1,2 @@
1
+ import { SerializedUpdateOrganizationOptions, UpdateOrganizationOptions } from '../interfaces';
2
+ export declare const serializeUpdateOrganizationOptions: (options: Omit<UpdateOrganizationOptions, 'organization'>) => SerializedUpdateOrganizationOptions;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serializeUpdateOrganizationOptions = void 0;
4
+ const serializeUpdateOrganizationOptions = (options) => ({
5
+ name: options.name,
6
+ allow_profiles_outside_organization: options.allowProfilesOutsideOrganization,
7
+ domains: options.domains,
8
+ });
9
+ exports.serializeUpdateOrganizationOptions = serializeUpdateOrganizationOptions;
@@ -6,3 +6,11 @@ export interface CreatePasswordlessSessionOptions {
6
6
  connection?: string;
7
7
  expiresIn?: number;
8
8
  }
9
+ export interface SerializedCreatePasswordlessSessionOptions {
10
+ type: 'MagicLink';
11
+ email: string;
12
+ redirect_uri?: string;
13
+ state?: string;
14
+ connection?: string;
15
+ expires_in?: number;
16
+ }
@@ -1,3 +1,3 @@
1
- export { PasswordlessSession } from './passwordless-session.interface';
2
- export { CreatePasswordlessSessionOptions } from './create-passwordless-session-options.interface';
3
- export { SendSessionResponse } from './send-session-response.interface';
1
+ export * from './passwordless-session.interface';
2
+ export * from './create-passwordless-session-options.interface';
3
+ export * from './send-session-response.interface';
@@ -1,2 +1,19 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./passwordless-session.interface"), exports);
18
+ __exportStar(require("./create-passwordless-session-options.interface"), exports);
19
+ __exportStar(require("./send-session-response.interface"), exports);
@@ -1,4 +1,11 @@
1
1
  export interface PasswordlessSession {
2
+ id: string;
3
+ email: string;
4
+ expiresAt: Date;
5
+ link: string;
6
+ object: 'passwordless_session';
7
+ }
8
+ export interface PasswordlessSessionResponse {
2
9
  id: string;
3
10
  email: string;
4
11
  expires_at: Date;
@@ -1,7 +1,5 @@
1
1
  import { WorkOS } from '../workos';
2
- import { PasswordlessSession } from './interfaces/passwordless-session.interface';
3
- import { CreatePasswordlessSessionOptions } from './interfaces/create-passwordless-session-options.interface';
4
- import { SendSessionResponse } from './interfaces/send-session-response.interface';
2
+ import { CreatePasswordlessSessionOptions, PasswordlessSession, SendSessionResponse } from './interfaces';
5
3
  export declare class Passwordless {
6
4
  private readonly workos;
7
5
  constructor(workos: WorkOS);
@@ -21,6 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.Passwordless = void 0;
24
+ const passwordless_session_serializer_1 = require("./serializers/passwordless-session.serializer");
24
25
  class Passwordless {
25
26
  constructor(workos) {
26
27
  this.workos = workos;
@@ -29,7 +30,7 @@ class Passwordless {
29
30
  var { redirectURI, expiresIn } = _a, options = __rest(_a, ["redirectURI", "expiresIn"]);
30
31
  return __awaiter(this, void 0, void 0, function* () {
31
32
  const { data } = yield this.workos.post('/passwordless/sessions', Object.assign(Object.assign({}, options), { redirect_uri: redirectURI, expires_in: expiresIn }));
32
- return data;
33
+ return (0, passwordless_session_serializer_1.deserializePasswordlessSession)(data);
33
34
  });
34
35
  }
35
36
  sendSession(sessionId) {
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,2 @@
1
+ import { PasswordlessSession, PasswordlessSessionResponse } from '../interfaces';
2
+ export declare const deserializePasswordlessSession: (passwordlessSession: PasswordlessSessionResponse) => PasswordlessSession;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializePasswordlessSession = void 0;
4
+ const deserializePasswordlessSession = (passwordlessSession) => ({
5
+ id: passwordlessSession.id,
6
+ email: passwordlessSession.email,
7
+ expiresAt: passwordlessSession.expires_at,
8
+ link: passwordlessSession.link,
9
+ object: passwordlessSession.object,
10
+ });
11
+ exports.deserializePasswordlessSession = deserializePasswordlessSession;
@@ -7,4 +7,4 @@ var GeneratePortalLinkIntent;
7
7
  GeneratePortalLinkIntent["DSync"] = "dsync";
8
8
  GeneratePortalLinkIntent["LogStreams"] = "log_streams";
9
9
  GeneratePortalLinkIntent["SSO"] = "sso";
10
- })(GeneratePortalLinkIntent = exports.GeneratePortalLinkIntent || (exports.GeneratePortalLinkIntent = {}));
10
+ })(GeneratePortalLinkIntent || (exports.GeneratePortalLinkIntent = GeneratePortalLinkIntent = {}));
@@ -15,6 +15,7 @@ export declare enum ConnectionType {
15
15
  JumpCloudSAML = "JumpCloudSAML",
16
16
  KeycloakSAML = "KeycloakSAML",
17
17
  LastPassSAML = "LastPassSAML",
18
+ LoginGovOidc = "LoginGovOidc",
18
19
  MagicLink = "MagicLink",
19
20
  MicrosoftOAuth = "MicrosoftOAuth",
20
21
  MiniOrangeSAML = "MiniOrangeSAML",
@@ -19,6 +19,7 @@ var ConnectionType;
19
19
  ConnectionType["JumpCloudSAML"] = "JumpCloudSAML";
20
20
  ConnectionType["KeycloakSAML"] = "KeycloakSAML";
21
21
  ConnectionType["LastPassSAML"] = "LastPassSAML";
22
+ ConnectionType["LoginGovOidc"] = "LoginGovOidc";
22
23
  ConnectionType["MagicLink"] = "MagicLink";
23
24
  ConnectionType["MicrosoftOAuth"] = "MicrosoftOAuth";
24
25
  ConnectionType["MiniOrangeSAML"] = "MiniOrangeSAML";
@@ -34,4 +35,4 @@ var ConnectionType;
34
35
  ConnectionType["ShibbolethSAML"] = "ShibbolethSAML";
35
36
  ConnectionType["SimpleSamlPhpSAML"] = "SimpleSamlPhpSAML";
36
37
  ConnectionType["VMwareSAML"] = "VMwareSAML";
37
- })(ConnectionType = exports.ConnectionType || (exports.ConnectionType = {}));
38
+ })(ConnectionType || (exports.ConnectionType = ConnectionType = {}));
@@ -7,14 +7,25 @@ export interface ConnectionDomain {
7
7
  export interface Connection {
8
8
  object: 'connection';
9
9
  id: string;
10
- organization_id?: string;
10
+ organizationId?: string;
11
11
  name: string;
12
- connection_type: ConnectionType;
13
- state: 'draft' | 'active' | 'inactive';
14
12
  /**
15
- * @deprecated The status parameter has been deprecated. Please use state.
13
+ * @deprecated The connectionType parameter has been deprecated. Please use type.
16
14
  */
17
- status: 'linked' | 'unlinked';
15
+ connectionType: ConnectionType;
16
+ state: 'draft' | 'active' | 'inactive' | 'validating';
17
+ domains: ConnectionDomain[];
18
+ type: ConnectionType;
19
+ createdAt: string;
20
+ updatedAt: string;
21
+ }
22
+ export interface ConnectionResponse {
23
+ object: 'connection';
24
+ id: string;
25
+ organization_id?: string;
26
+ name: string;
27
+ connection_type: ConnectionType;
28
+ state: 'draft' | 'active' | 'inactive' | 'validating';
18
29
  domains: ConnectionDomain[];
19
30
  created_at: string;
20
31
  updated_at: string;
@@ -1,6 +1,8 @@
1
1
  export * from './authorization-url-options.interface';
2
2
  export * from './connection-type.enum';
3
3
  export * from './connection.interface';
4
+ export * from './get-profile-options.interface';
4
5
  export * from './get-profile-and-token-options.interface';
6
+ export * from './list-connections-options.interface';
5
7
  export * from './profile-and-token.interface';
6
8
  export * from './profile.interface';
@@ -17,6 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./authorization-url-options.interface"), exports);
18
18
  __exportStar(require("./connection-type.enum"), exports);
19
19
  __exportStar(require("./connection.interface"), exports);
20
+ __exportStar(require("./get-profile-options.interface"), exports);
20
21
  __exportStar(require("./get-profile-and-token-options.interface"), exports);
22
+ __exportStar(require("./list-connections-options.interface"), exports);
21
23
  __exportStar(require("./profile-and-token.interface"), exports);
22
24
  __exportStar(require("./profile.interface"), exports);
@@ -1,6 +1,11 @@
1
1
  import { PaginationOptions } from '../../common/interfaces/pagination-options.interface';
2
2
  import { ConnectionType } from './connection-type.enum';
3
3
  export interface ListConnectionsOptions extends PaginationOptions {
4
+ connectionType?: ConnectionType;
5
+ domain?: string;
6
+ organizationId?: string;
7
+ }
8
+ export interface SerializedListConnectionsOptions extends PaginationOptions {
4
9
  connection_type?: ConnectionType;
5
10
  domain?: string;
6
11
  organization_id?: string;
@@ -1,5 +1,9 @@
1
- import { Profile } from './profile.interface';
1
+ import { Profile, ProfileResponse } from './profile.interface';
2
2
  export interface ProfileAndToken {
3
- access_token: string;
3
+ accessToken: string;
4
4
  profile: Profile;
5
5
  }
6
+ export interface ProfileAndTokenResponse {
7
+ access_token: string;
8
+ profile: ProfileResponse;
9
+ }
@@ -1,5 +1,19 @@
1
1
  import { ConnectionType } from './connection-type.enum';
2
2
  export interface Profile {
3
+ id: string;
4
+ idpId: string;
5
+ organizationId?: string;
6
+ connectionId: string;
7
+ connectionType: ConnectionType;
8
+ email: string;
9
+ firstName?: string;
10
+ lastName?: string;
11
+ groups?: string[];
12
+ rawAttributes?: {
13
+ [key: string]: any;
14
+ };
15
+ }
16
+ export interface ProfileResponse {
3
17
  id: string;
4
18
  idp_id: string;
5
19
  organization_id?: string;
@@ -0,0 +1,2 @@
1
+ import { Connection, ConnectionResponse } from '../interfaces';
2
+ export declare const deserializeConnection: (connection: ConnectionResponse) => Connection;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeConnection = void 0;
4
+ const deserializeConnection = (connection) => ({
5
+ object: connection.object,
6
+ id: connection.id,
7
+ organizationId: connection.organization_id,
8
+ name: connection.name,
9
+ connectionType: connection.connection_type,
10
+ type: connection.connection_type,
11
+ state: connection.state,
12
+ domains: connection.domains,
13
+ createdAt: connection.created_at,
14
+ updatedAt: connection.updated_at,
15
+ });
16
+ exports.deserializeConnection = deserializeConnection;
@@ -0,0 +1,3 @@
1
+ export * from './connection.serializer';
2
+ export * from './profile-and-token.serializer';
3
+ export * from './profile.serializer';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./connection.serializer"), exports);
18
+ __exportStar(require("./profile-and-token.serializer"), exports);
19
+ __exportStar(require("./profile.serializer"), exports);
@@ -0,0 +1,2 @@
1
+ import { ProfileAndToken, ProfileAndTokenResponse } from '../interfaces';
2
+ export declare const deserializeProfileAndToken: (profileAndToken: ProfileAndTokenResponse) => ProfileAndToken;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeProfileAndToken = void 0;
4
+ const profile_serializer_1 = require("./profile.serializer");
5
+ const deserializeProfileAndToken = (profileAndToken) => ({
6
+ accessToken: profileAndToken.access_token,
7
+ profile: (0, profile_serializer_1.deserializeProfile)(profileAndToken.profile),
8
+ });
9
+ exports.deserializeProfileAndToken = deserializeProfileAndToken;
@@ -0,0 +1,2 @@
1
+ import { Profile, ProfileResponse } from '../interfaces';
2
+ export declare const deserializeProfile: (profile: ProfileResponse) => Profile;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeProfile = void 0;
4
+ const deserializeProfile = (profile) => ({
5
+ id: profile.id,
6
+ idpId: profile.idp_id,
7
+ organizationId: profile.organization_id,
8
+ connectionId: profile.connection_id,
9
+ connectionType: profile.connection_type,
10
+ email: profile.email,
11
+ firstName: profile.first_name,
12
+ lastName: profile.last_name,
13
+ groups: profile.groups,
14
+ rawAttributes: profile.raw_attributes,
15
+ });
16
+ exports.deserializeProfile = deserializeProfile;
package/lib/sso/sso.d.ts CHANGED
@@ -1,19 +1,13 @@
1
- import { List } from '../common/interfaces/list.interface';
1
+ import { AutoPaginatable } from '../common/utils/pagination';
2
2
  import { WorkOS } from '../workos';
3
- import { AuthorizationURLOptions } from './interfaces/authorization-url-options.interface';
4
- import { Connection } from './interfaces/connection.interface';
5
- import { GetProfileAndTokenOptions } from './interfaces/get-profile-and-token-options.interface';
6
- import { GetProfileOptions } from './interfaces/get-profile-options.interface';
7
- import { ListConnectionsOptions } from './interfaces/list-connections-options.interface';
8
- import { ProfileAndToken } from './interfaces/profile-and-token.interface';
9
- import { Profile } from './interfaces/profile.interface';
3
+ import { AuthorizationURLOptions, Connection, GetProfileAndTokenOptions, GetProfileOptions, ListConnectionsOptions, Profile, ProfileAndToken } from './interfaces';
10
4
  export declare class SSO {
11
5
  private readonly workos;
12
6
  constructor(workos: WorkOS);
7
+ listConnections(options?: ListConnectionsOptions): Promise<AutoPaginatable<Connection>>;
13
8
  deleteConnection(id: string): Promise<void>;
14
9
  getAuthorizationURL({ connection, clientID, domain, domainHint, loginHint, organization, provider, redirectURI, state, }: AuthorizationURLOptions): string;
15
10
  getConnection(id: string): Promise<Connection>;
16
11
  getProfileAndToken({ code, clientID, }: GetProfileAndTokenOptions): Promise<ProfileAndToken>;
17
12
  getProfile({ accessToken }: GetProfileOptions): Promise<Profile>;
18
- listConnections(options?: ListConnectionsOptions): Promise<List<Connection>>;
19
13
  }
package/lib/sso/sso.js CHANGED
@@ -8,16 +8,31 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
12
  exports.SSO = void 0;
16
- const query_string_1 = __importDefault(require("query-string"));
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 toQueryString = (options) => {
17
+ const searchParams = new URLSearchParams();
18
+ const keys = Object.keys(options).sort();
19
+ for (const key of keys) {
20
+ const value = options[key];
21
+ if (value) {
22
+ searchParams.append(key, value);
23
+ }
24
+ }
25
+ return searchParams.toString();
26
+ };
17
27
  class SSO {
18
28
  constructor(workos) {
19
29
  this.workos = workos;
20
30
  }
31
+ listConnections(options) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/connections', serializers_1.deserializeConnection, options), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, '/connections', serializers_1.deserializeConnection, params), options);
34
+ });
35
+ }
21
36
  deleteConnection(id) {
22
37
  return __awaiter(this, void 0, void 0, function* () {
23
38
  yield this.workos.delete(`/connections/${id}`);
@@ -30,7 +45,7 @@ class SSO {
30
45
  if (domain) {
31
46
  this.workos.emitWarning('The `domain` parameter for `getAuthorizationURL` is deprecated. Please use `organization` instead.');
32
47
  }
33
- const query = query_string_1.default.stringify({
48
+ const query = toQueryString({
34
49
  connection,
35
50
  organization,
36
51
  domain,
@@ -47,7 +62,7 @@ class SSO {
47
62
  getConnection(id) {
48
63
  return __awaiter(this, void 0, void 0, function* () {
49
64
  const { data } = yield this.workos.get(`/connections/${id}`);
50
- return data;
65
+ return (0, serializers_1.deserializeConnection)(data);
51
66
  });
52
67
  }
53
68
  getProfileAndToken({ code, clientID, }) {
@@ -59,7 +74,7 @@ class SSO {
59
74
  code,
60
75
  });
61
76
  const { data } = yield this.workos.post('/sso/token', form);
62
- return data;
77
+ return (0, serializers_1.deserializeProfileAndToken)(data);
63
78
  });
64
79
  }
65
80
  getProfile({ accessToken }) {
@@ -67,15 +82,7 @@ class SSO {
67
82
  const { data } = yield this.workos.get('/sso/profile', {
68
83
  accessToken,
69
84
  });
70
- return data;
71
- });
72
- }
73
- listConnections(options) {
74
- return __awaiter(this, void 0, void 0, function* () {
75
- const { data } = yield this.workos.get(`/connections`, {
76
- query: options,
77
- });
78
- return data;
85
+ return (0, serializers_1.deserializeProfile)(data);
79
86
  });
80
87
  }
81
88
  }