@workos-inc/node 2.19.0 → 3.0.0-alpha.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 (169) 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.spec.js +2 -1
  15. package/lib/common/interfaces/index.d.ts +2 -0
  16. package/lib/common/interfaces/index.js +2 -0
  17. package/lib/common/interfaces/list.interface.d.ts +8 -0
  18. package/lib/common/interfaces/workos-response-error.interface.d.ts +8 -0
  19. package/lib/common/serializers/index.d.ts +1 -0
  20. package/lib/common/serializers/index.js +17 -0
  21. package/lib/common/serializers/list.serializer.d.ts +2 -0
  22. package/lib/common/serializers/list.serializer.js +9 -0
  23. package/lib/common/utils/workos-mock-response.d.ts +7 -0
  24. package/lib/common/utils/workos-mock-response.js +11 -0
  25. package/lib/directory-sync/directory-sync.d.ts +7 -12
  26. package/lib/directory-sync/directory-sync.js +8 -6
  27. package/lib/directory-sync/directory-sync.spec.js +95 -20
  28. package/lib/directory-sync/interfaces/directory-group.interface.d.ts +20 -0
  29. package/lib/directory-sync/interfaces/directory-user.interface.d.ts +48 -0
  30. package/lib/directory-sync/interfaces/directory.interface.d.ts +12 -0
  31. package/lib/directory-sync/interfaces/index.d.ts +6 -6
  32. package/lib/directory-sync/interfaces/index.js +20 -0
  33. package/lib/directory-sync/interfaces/list-directories-options.interface.d.ts +1 -1
  34. package/lib/directory-sync/interfaces/{list-users-options.interface.d.ts → list-directory-users-options.interface.d.ts} +1 -1
  35. package/lib/directory-sync/interfaces/list-directory-users-options.interface.js +2 -0
  36. package/lib/directory-sync/serializers/directory-group.serializer.d.ts +2 -0
  37. package/lib/directory-sync/serializers/directory-group.serializer.js +14 -0
  38. package/lib/directory-sync/serializers/directory-user.serializer.d.ts +3 -0
  39. package/lib/directory-sync/serializers/directory-user.serializer.js +23 -0
  40. package/lib/directory-sync/serializers/directory.serializer.d.ts +2 -0
  41. package/lib/directory-sync/serializers/directory.serializer.js +16 -0
  42. package/lib/directory-sync/serializers/index.d.ts +3 -0
  43. package/lib/directory-sync/serializers/index.js +19 -0
  44. package/lib/directory-sync/utils/get-primary-email.d.ts +2 -2
  45. package/lib/directory-sync/utils/get-primary-email.spec.js +10 -8
  46. package/lib/events/events.d.ts +3 -3
  47. package/lib/events/events.js +3 -1
  48. package/lib/events/events.spec.js +19 -3
  49. package/lib/events/interfaces/event.interface.d.ts +4 -1
  50. package/lib/events/serializers/event.serializer.d.ts +2 -0
  51. package/lib/events/serializers/event.serializer.js +10 -0
  52. package/lib/index.d.ts +1 -0
  53. package/lib/index.js +1 -0
  54. package/lib/mfa/interfaces/challenge.interface.d.ts +9 -0
  55. package/lib/mfa/interfaces/factor.interface.d.ts +13 -4
  56. package/lib/mfa/interfaces/index.d.ts +9 -0
  57. package/lib/mfa/interfaces/index.js +25 -0
  58. package/lib/mfa/interfaces/sms.interface.d.ts +3 -0
  59. package/lib/mfa/interfaces/totp.interface.d.ts +7 -0
  60. package/lib/mfa/interfaces/verify-challenge-response.d.ts +5 -1
  61. package/lib/mfa/mfa.d.ts +2 -8
  62. package/lib/mfa/mfa.js +5 -4
  63. package/lib/mfa/mfa.spec.js +134 -115
  64. package/lib/mfa/serializers/challenge.serializer.d.ts +2 -0
  65. package/lib/mfa/serializers/challenge.serializer.js +13 -0
  66. package/lib/mfa/serializers/factor.serializer.d.ts +2 -0
  67. package/lib/mfa/serializers/factor.serializer.js +7 -0
  68. package/lib/mfa/serializers/index.d.ts +3 -0
  69. package/lib/mfa/serializers/index.js +19 -0
  70. package/lib/mfa/serializers/sms.serializer.d.ts +2 -0
  71. package/lib/mfa/serializers/sms.serializer.js +7 -0
  72. package/lib/mfa/serializers/totp.serializer.d.ts +2 -0
  73. package/lib/mfa/serializers/totp.serializer.js +11 -0
  74. package/lib/mfa/serializers/verify-response.serializer.d.ts +2 -0
  75. package/lib/mfa/serializers/verify-response.serializer.js +9 -0
  76. package/lib/organizations/interfaces/create-organization-options.interface.d.ts +5 -0
  77. package/lib/organizations/interfaces/organization.interface.d.ts +9 -0
  78. package/lib/organizations/interfaces/update-organization-options.interface.d.ts +5 -0
  79. package/lib/organizations/organizations.d.ts +2 -2
  80. package/lib/organizations/organizations.js +8 -6
  81. package/lib/organizations/organizations.spec.js +4 -3
  82. package/lib/organizations/serializers/create-organization-options.serializer.d.ts +2 -0
  83. package/lib/organizations/serializers/create-organization-options.serializer.js +9 -0
  84. package/lib/organizations/serializers/index.d.ts +3 -0
  85. package/lib/organizations/serializers/index.js +19 -0
  86. package/lib/organizations/serializers/organization.serializer.d.ts +2 -0
  87. package/lib/organizations/serializers/organization.serializer.js +13 -0
  88. package/lib/organizations/serializers/update-organization-options.serializer.d.ts +2 -0
  89. package/lib/organizations/serializers/update-organization-options.serializer.js +9 -0
  90. package/lib/portal/interfaces/generate-portal-link-intent.interface.js +1 -1
  91. package/lib/sso/interfaces/connection-type.enum.d.ts +1 -0
  92. package/lib/sso/interfaces/connection-type.enum.js +2 -1
  93. package/lib/sso/interfaces/connection.interface.d.ts +1 -1
  94. package/lib/sso/sso.js +12 -5
  95. package/lib/sso/sso.spec.js +3 -3
  96. package/lib/users/exceptions/index.d.ts +4 -0
  97. package/lib/users/exceptions/index.js +10 -0
  98. package/lib/users/fixtures/list-users.json +21 -0
  99. package/lib/users/fixtures/session.json +6 -0
  100. package/lib/users/fixtures/user.json +12 -0
  101. package/lib/users/interfaces/add-user-to-organization-options.interface.d.ts +7 -0
  102. package/lib/users/interfaces/add-user-to-organization-options.interface.js +2 -0
  103. package/lib/users/interfaces/authenticate-user-with-password-options.interface.d.ts +16 -0
  104. package/lib/users/interfaces/authenticate-user-with-password-options.interface.js +2 -0
  105. package/lib/users/interfaces/authenticate-user-with-token-options.interface.d.ts +18 -0
  106. package/lib/users/interfaces/authenticate-user-with-token-options.interface.js +2 -0
  107. package/lib/users/interfaces/authentication-response.interface.d.ts +10 -0
  108. package/lib/users/interfaces/authentication-response.interface.js +2 -0
  109. package/lib/users/interfaces/complete-password-reset-options.interface.d.ts +8 -0
  110. package/lib/users/interfaces/complete-password-reset-options.interface.js +2 -0
  111. package/lib/users/interfaces/create-email-verification-challenge-options.interface.d.ts +16 -0
  112. package/lib/users/interfaces/create-email-verification-challenge-options.interface.js +2 -0
  113. package/lib/users/interfaces/create-password-reset-challenge-options.interface.d.ts +17 -0
  114. package/lib/users/interfaces/create-password-reset-challenge-options.interface.js +2 -0
  115. package/lib/users/interfaces/create-user-options.interface.d.ts +14 -0
  116. package/lib/users/interfaces/create-user-options.interface.js +2 -0
  117. package/lib/users/interfaces/index.d.ts +13 -0
  118. package/lib/users/interfaces/index.js +29 -0
  119. package/lib/users/interfaces/list-users-options.interface.d.ts +6 -0
  120. package/lib/users/interfaces/list-users-options.interface.js +2 -0
  121. package/lib/users/interfaces/remove-user-from-organization-options.interface.d.ts +4 -0
  122. package/lib/users/interfaces/remove-user-from-organization-options.interface.js +2 -0
  123. package/lib/users/interfaces/revoke-session-options.interface.d.ts +15 -0
  124. package/lib/users/interfaces/revoke-session-options.interface.js +2 -0
  125. package/lib/users/interfaces/session.interface.d.ts +12 -0
  126. package/lib/users/interfaces/session.interface.js +2 -0
  127. package/lib/users/interfaces/user.interface.d.ts +59 -0
  128. package/lib/users/interfaces/user.interface.js +2 -0
  129. package/lib/users/interfaces/verify-session.interface.d.ts +18 -0
  130. package/lib/users/interfaces/verify-session.interface.js +2 -0
  131. package/lib/users/serializers/authenticate-user-with-password-options.serializer.d.ts +2 -0
  132. package/lib/users/serializers/authenticate-user-with-password-options.serializer.js +12 -0
  133. package/lib/users/serializers/authenticate-user-with-token-options.serializer.d.ts +2 -0
  134. package/lib/users/serializers/authenticate-user-with-token-options.serializer.js +12 -0
  135. package/lib/users/serializers/authentication-response.serializer.d.ts +2 -0
  136. package/lib/users/serializers/authentication-response.serializer.js +12 -0
  137. package/lib/users/serializers/complete-password-reset-options.serializer.d.ts +2 -0
  138. package/lib/users/serializers/complete-password-reset-options.serializer.js +8 -0
  139. package/lib/users/serializers/create-email-verification-challenge.serializer.d.ts +2 -0
  140. package/lib/users/serializers/create-email-verification-challenge.serializer.js +9 -0
  141. package/lib/users/serializers/create-password-reset-challenge.serializer.d.ts +3 -0
  142. package/lib/users/serializers/create-password-reset-challenge.serializer.js +14 -0
  143. package/lib/users/serializers/create-user-options.serializer.d.ts +2 -0
  144. package/lib/users/serializers/create-user-options.serializer.js +11 -0
  145. package/lib/users/serializers/index.d.ts +11 -0
  146. package/lib/users/serializers/index.js +27 -0
  147. package/lib/users/serializers/revoke-session-options.serializer.d.ts +2 -0
  148. package/lib/users/serializers/revoke-session-options.serializer.js +14 -0
  149. package/lib/users/serializers/session.serializer.d.ts +2 -0
  150. package/lib/users/serializers/session.serializer.js +10 -0
  151. package/lib/users/serializers/user.serializer.d.ts +2 -0
  152. package/lib/users/serializers/user.serializer.js +31 -0
  153. package/lib/users/serializers/verify-session.serializer.d.ts +3 -0
  154. package/lib/users/serializers/verify-session.serializer.js +15 -0
  155. package/lib/users/users.d.ts +21 -0
  156. package/lib/users/users.js +112 -0
  157. package/lib/users/users.spec.d.ts +1 -0
  158. package/lib/users/users.spec.js +290 -0
  159. package/lib/webhooks/fixtures/webhook.json +1 -1
  160. package/lib/webhooks/interfaces/webhook-directory-user.interface.d.ts +2 -2
  161. package/lib/webhooks/interfaces/webhook.interface.d.ts +1 -0
  162. package/lib/workos.d.ts +6 -4
  163. package/lib/workos.js +3 -1
  164. package/package.json +13 -14
  165. package/lib/directory-sync/interfaces/group.interface.d.ts +0 -10
  166. package/lib/directory-sync/interfaces/user.interface.d.ts +0 -23
  167. /package/lib/{directory-sync/interfaces/group.interface.js → common/interfaces/workos-response-error.interface.js} +0 -0
  168. /package/lib/directory-sync/interfaces/{list-users-options.interface.js → directory-group.interface.js} +0 -0
  169. /package/lib/directory-sync/interfaces/{user.interface.js → directory-user.interface.js} +0 -0
@@ -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("./challenge.serializer"), exports);
18
+ __exportStar(require("./factor.serializer"), exports);
19
+ __exportStar(require("./verify-response.serializer"), exports);
@@ -0,0 +1,2 @@
1
+ import { Sms, SmsResponse } from '../interfaces';
2
+ export declare const deserializeSms: (sms: SmsResponse) => Sms;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeSms = void 0;
4
+ const deserializeSms = (sms) => ({
5
+ phoneNumber: sms.phone_number,
6
+ });
7
+ exports.deserializeSms = deserializeSms;
@@ -0,0 +1,2 @@
1
+ import { Totp, TotpResponse } from '../interfaces';
2
+ export declare const deserializeTotp: (totp: TotpResponse) => Totp;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeTotp = void 0;
4
+ const deserializeTotp = (totp) => ({
5
+ issuer: totp.issuer,
6
+ user: totp.user,
7
+ qrCode: totp.qr_code,
8
+ secret: totp.secret,
9
+ uri: totp.uri,
10
+ });
11
+ exports.deserializeTotp = deserializeTotp;
@@ -0,0 +1,2 @@
1
+ import { VerifyResponse, VerifyResponseResponse } from '../interfaces';
2
+ export declare const deserializeVerifyResponse: (verifyResponse: VerifyResponseResponse) => VerifyResponse;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeVerifyResponse = void 0;
4
+ const challenge_serializer_1 = require("./challenge.serializer");
5
+ const deserializeVerifyResponse = (verifyResponse) => ({
6
+ challenge: (0, challenge_serializer_1.deserializeChallenge)(verifyResponse.challenge),
7
+ valid: verifyResponse.valid,
8
+ });
9
+ exports.deserializeVerifyResponse = deserializeVerifyResponse;
@@ -1,5 +1,10 @@
1
1
  import { PostOptions } from '../../common/interfaces';
2
2
  export interface CreateOrganizationOptions {
3
+ name: string;
4
+ allowProfilesOutsideOrganization?: boolean;
5
+ domains?: string[];
6
+ }
7
+ export interface SerializedCreateOrganizationOptions {
3
8
  name: string;
4
9
  allow_profiles_outside_organization?: boolean;
5
10
  domains?: string[];
@@ -1,5 +1,14 @@
1
1
  import { OrganizationDomain } from './organization-domain.interface';
2
2
  export interface Organization {
3
+ object: 'organization';
4
+ id: string;
5
+ name: string;
6
+ allowProfilesOutsideOrganization: boolean;
7
+ domains: OrganizationDomain[];
8
+ createdAt: string;
9
+ updatedAt: string;
10
+ }
11
+ export interface OrganizationResponse {
3
12
  object: 'organization';
4
13
  id: string;
5
14
  name: string;
@@ -1,5 +1,10 @@
1
1
  export interface UpdateOrganizationOptions {
2
2
  organization: string;
3
+ name: string;
4
+ allowProfilesOutsideOrganization?: boolean;
5
+ domains?: string[];
6
+ }
7
+ export interface SerializedUpdateOrganizationOptions {
3
8
  name: string;
4
9
  allow_profiles_outside_organization?: boolean;
5
10
  domains?: string[];
@@ -1,10 +1,10 @@
1
- import { List } from '../common/interfaces/list.interface';
1
+ import { DeserializedList } from '../common/interfaces';
2
2
  import { WorkOS } from '../workos';
3
3
  import { CreateOrganizationOptions, CreateOrganizationRequestOptions, ListOrganizationsOptions, Organization, UpdateOrganizationOptions } from './interfaces';
4
4
  export declare class Organizations {
5
5
  private readonly workos;
6
6
  constructor(workos: WorkOS);
7
- listOrganizations(options?: ListOrganizationsOptions): Promise<List<Organization>>;
7
+ listOrganizations(options?: ListOrganizationsOptions): Promise<DeserializedList<Organization>>;
8
8
  createOrganization(payload: CreateOrganizationOptions, requestOptions?: CreateOrganizationRequestOptions): Promise<Organization>;
9
9
  deleteOrganization(id: string): Promise<void>;
10
10
  getOrganization(id: string): Promise<Organization>;
@@ -21,6 +21,8 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.Organizations = void 0;
24
+ const serializers_1 = require("../common/serializers");
25
+ const serializers_2 = require("./serializers");
24
26
  class Organizations {
25
27
  constructor(workos) {
26
28
  this.workos = workos;
@@ -30,13 +32,13 @@ class Organizations {
30
32
  const { data } = yield this.workos.get('/organizations', {
31
33
  query: options,
32
34
  });
33
- return data;
35
+ return (0, serializers_1.deserializeList)(data, serializers_2.deserializeOrganization);
34
36
  });
35
37
  }
36
38
  createOrganization(payload, requestOptions = {}) {
37
39
  return __awaiter(this, void 0, void 0, function* () {
38
- const { data } = yield this.workos.post('/organizations', payload, requestOptions);
39
- return data;
40
+ const { data } = yield this.workos.post('/organizations', (0, serializers_2.serializeCreateOrganizationOptions)(payload), requestOptions);
41
+ return (0, serializers_2.deserializeOrganization)(data);
40
42
  });
41
43
  }
42
44
  deleteOrganization(id) {
@@ -47,14 +49,14 @@ class Organizations {
47
49
  getOrganization(id) {
48
50
  return __awaiter(this, void 0, void 0, function* () {
49
51
  const { data } = yield this.workos.get(`/organizations/${id}`);
50
- return data;
52
+ return (0, serializers_2.deserializeOrganization)(data);
51
53
  });
52
54
  }
53
55
  updateOrganization(options) {
54
56
  return __awaiter(this, void 0, void 0, function* () {
55
57
  const { organization: organizationId } = options, payload = __rest(options, ["organization"]);
56
- const { data } = yield this.workos.put(`/organizations/${organizationId}`, payload);
57
- return data;
58
+ const { data } = yield this.workos.put(`/organizations/${organizationId}`, (0, serializers_2.serializeUpdateOrganizationOptions)(payload));
59
+ return (0, serializers_2.deserializeOrganization)(data);
58
60
  });
59
61
  }
60
62
  }
@@ -28,7 +28,7 @@ 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();
31
+ const { data, listMetadata } = yield workos.organizations.listOrganizations();
32
32
  expect(mock.history.get[0].params).toBeUndefined();
33
33
  expect(mock.history.get[0].url).toEqual('/organizations');
34
34
  expect(data).toHaveLength(7);
@@ -110,6 +110,7 @@ describe('Organizations', () => {
110
110
  describe('createOrganization', () => {
111
111
  describe('with an idempotency key', () => {
112
112
  it('includes an idempotency key with request', () => __awaiter(void 0, void 0, void 0, function* () {
113
+ var _a;
113
114
  mock
114
115
  .onPost('/organizations', {
115
116
  domains: ['example.com'],
@@ -122,7 +123,7 @@ describe('Organizations', () => {
122
123
  }, {
123
124
  idempotencyKey: 'the-idempotency-key',
124
125
  });
125
- expect(mock.history.post[0].headers['Idempotency-Key']).toEqual('the-idempotency-key');
126
+ expect((_a = mock.history.post[0].headers) === null || _a === void 0 ? void 0 : _a['Idempotency-Key']).toEqual('the-idempotency-key');
126
127
  }));
127
128
  });
128
129
  describe('with a valid payload', () => {
@@ -170,7 +171,7 @@ describe('Organizations', () => {
170
171
  expect(mock.history.get[0].url).toEqual('/organizations/org_01EHT88Z8J8795GZNQ4ZP1J81T');
171
172
  expect(subject.id).toEqual('org_01EHT88Z8J8795GZNQ4ZP1J81T');
172
173
  expect(subject.name).toEqual('Test Organization 3');
173
- expect(subject.allow_profiles_outside_organization).toEqual(false);
174
+ expect(subject.allowProfilesOutsideOrganization).toEqual(false);
174
175
  expect(subject.domains).toHaveLength(1);
175
176
  }));
176
177
  });
@@ -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;
@@ -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 = {}));
@@ -10,7 +10,7 @@ export interface Connection {
10
10
  organization_id?: string;
11
11
  name: string;
12
12
  connection_type: ConnectionType;
13
- state: 'draft' | 'active' | 'inactive';
13
+ state: 'draft' | 'active' | 'inactive' | 'validating';
14
14
  /**
15
15
  * @deprecated The status parameter has been deprecated. Please use state.
16
16
  */
package/lib/sso/sso.js CHANGED
@@ -8,12 +8,19 @@ 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 toQueryString = (options) => {
14
+ const searchParams = new URLSearchParams();
15
+ const keys = Object.keys(options).sort();
16
+ for (const key of keys) {
17
+ const value = options[key];
18
+ if (value) {
19
+ searchParams.append(key, value);
20
+ }
21
+ }
22
+ return searchParams.toString();
23
+ };
17
24
  class SSO {
18
25
  constructor(workos) {
19
26
  this.workos = workos;
@@ -30,7 +37,7 @@ class SSO {
30
37
  if (domain) {
31
38
  this.workos.emitWarning('The `domain` parameter for `getAuthorizationURL` is deprecated. Please use `organization` instead.');
32
39
  }
33
- const query = query_string_1.default.stringify({
40
+ const query = toQueryString({
34
41
  connection,
35
42
  organization,
36
43
  domain,
@@ -113,7 +113,7 @@ describe('SSO', () => {
113
113
  redirectURI: 'example.com/sso/workos/callback',
114
114
  state: 'custom state',
115
115
  });
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"`);
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+state"`);
117
117
  });
118
118
  });
119
119
  describe('with loginHint', () => {
@@ -126,7 +126,7 @@ describe('SSO', () => {
126
126
  redirectURI: 'example.com/sso/workos/callback',
127
127
  state: 'custom state',
128
128
  });
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"`);
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+state"`);
130
130
  });
131
131
  });
132
132
  });
@@ -266,7 +266,7 @@ describe('SSO', () => {
266
266
  });
267
267
  expect(mock.history.get.length).toBe(1);
268
268
  const { headers } = mock.history.get[0];
269
- expect(headers.Authorization).toBe(`Bearer access_token`);
269
+ expect(headers === null || headers === void 0 ? void 0 : headers.Authorization).toBe(`Bearer access_token`);
270
270
  expect(profile.id).toBe('prof_123');
271
271
  }));
272
272
  });
@@ -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;
@@ -0,0 +1,21 @@
1
+ {
2
+ "object": "list",
3
+ "data": [
4
+ {
5
+ "object": "user",
6
+ "id": "user_01H5JQDV7R7ATEYZDEG0W5PRYS",
7
+ "email": "test01@example.com",
8
+ "first_name": "Test 01",
9
+ "last_name": "User",
10
+ "organization_memberships": [],
11
+ "created_at": "2023-07-18T02:07:19.911Z",
12
+ "updated_at": "2023-07-18T02:07:19.911Z",
13
+ "user_type": "unmanaged",
14
+ "email_verified_at": "2023-07-17T20:07:20.055Z"
15
+ }
16
+ ],
17
+ "list_metadata": {
18
+ "before": null,
19
+ "after": null
20
+ }
21
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "id": "session_01H5K05VP5CPCXJA5Z7G191GS4",
3
+ "created_at": "2023-07-18T04:40:14.954Z",
4
+ "expires_at": "2023-07-18T22:40:15.555Z",
5
+ "token": "really-long-token"
6
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "object": "user",
3
+ "id": "user_01H5JQDV7R7ATEYZDEG0W5PRYS",
4
+ "email": "test01@example.com",
5
+ "first_name": "Test 01",
6
+ "last_name": "User",
7
+ "organization_memberships": [],
8
+ "created_at": "2023-07-18T02:07:19.911Z",
9
+ "updated_at": "2023-07-18T02:07:19.911Z",
10
+ "user_type": "unmanaged",
11
+ "email_verified_at": "2023-07-17T20:07:20.055Z"
12
+ }
@@ -0,0 +1,7 @@
1
+ export interface AddUserToOrganizationOptions {
2
+ userId: string;
3
+ organizationId: string;
4
+ }
5
+ export interface SerializedAddUserToOrganizationOptions {
6
+ organization_id: string;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,16 @@
1
+ export interface AuthenticateUserWithPasswordOptions {
2
+ email: string;
3
+ password: string;
4
+ ipAddress?: string;
5
+ userAgent?: string;
6
+ startSession?: boolean;
7
+ expiresIn?: number;
8
+ }
9
+ export interface SerializedAuthenticateUserWithPasswordOptions {
10
+ email: string;
11
+ password: string;
12
+ ip_address?: string;
13
+ user_agent?: string;
14
+ start_session?: boolean;
15
+ expires_in?: number;
16
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,18 @@
1
+ export interface AuthenticateUserWithTokenOptions {
2
+ clientId: string;
3
+ code: string;
4
+ startSession?: boolean;
5
+ expiresIn?: number;
6
+ }
7
+ export interface AuthenticateUserWithTokenCredentials {
8
+ clientSecret: string | undefined;
9
+ grantType: string;
10
+ }
11
+ export interface SerializedAuthenticateUserWithTokenOptions {
12
+ client_id: string;
13
+ client_secret: string | undefined;
14
+ code: string;
15
+ grant_type: string;
16
+ start_session?: boolean;
17
+ expires_in?: number;
18
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ import { User, UserResponse } from './user.interface';
2
+ import { Session, SessionResponse } from './session.interface';
3
+ export interface AuthenticationResponse {
4
+ session?: Session;
5
+ user: User;
6
+ }
7
+ export interface AuthenticationResponseResponse {
8
+ session?: SessionResponse;
9
+ user: UserResponse;
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ export interface CompletePasswordResetOptions {
2
+ token: string;
3
+ newPassword: string;
4
+ }
5
+ export interface SerializedCompletePasswordResetOptions {
6
+ token: string;
7
+ new_password: string;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,16 @@
1
+ import { User, UserResponse } from './user.interface';
2
+ export interface CreateEmailVerificationChallengeOptions {
3
+ userId: string;
4
+ verificationUrl: string;
5
+ }
6
+ export interface SerializedCreateEmailVerificationChallengeOptions {
7
+ verification_url: string;
8
+ }
9
+ export interface CreateEmailVerificationChallengeResponse {
10
+ token: string;
11
+ user: User;
12
+ }
13
+ export interface CreateEmailVerificationChallengeResponseResponse {
14
+ token: string;
15
+ user: UserResponse;
16
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,17 @@
1
+ import { User, UserResponse } from './user.interface';
2
+ export interface CreatePasswordResetChallengeOptions {
3
+ email: string;
4
+ passwordResetUrl: string;
5
+ }
6
+ export interface SerializedCreatePasswordResetChallengeOptions {
7
+ email: string;
8
+ password_reset_url: string;
9
+ }
10
+ export interface CreatePasswordResetChallengeResponse {
11
+ token: string;
12
+ user: User;
13
+ }
14
+ export interface CreatePasswordResetChallengeResponseResponse {
15
+ token: string;
16
+ user: UserResponse;
17
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ export interface CreateUserOptions {
2
+ email: string;
3
+ password: string;
4
+ firstName?: string;
5
+ lastName?: string;
6
+ emailVerified?: boolean;
7
+ }
8
+ export interface SerializedCreateUserOptions {
9
+ email: string;
10
+ password: string;
11
+ first_name?: string;
12
+ last_name?: string;
13
+ email_verified?: boolean;
14
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ export * from './add-user-to-organization-options.interface';
2
+ export * from './authenticate-user-with-password-options.interface';
3
+ export * from './authenticate-user-with-token-options.interface';
4
+ export * from './authentication-response.interface';
5
+ export * from './complete-password-reset-options.interface';
6
+ export * from './create-email-verification-challenge-options.interface';
7
+ export * from './create-password-reset-challenge-options.interface';
8
+ export * from './create-user-options.interface';
9
+ export * from './list-users-options.interface';
10
+ export * from './remove-user-from-organization-options.interface';
11
+ export * from './revoke-session-options.interface';
12
+ export * from './user.interface';
13
+ export * from './verify-session.interface';