@workos-inc/node 7.46.0 → 7.48.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.
@@ -0,0 +1 @@
1
+ export type UnknownRecord = Record<string, unknown>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "object": "organization_domain",
3
3
  "id": "org_domain_01HD50K7EPWCMNPGMKXKKE14XT",
4
+ "organization_id": "org_01JR8C1EHCRPV4B4XP4W2B9X1M",
4
5
  "domain": "workos.com",
5
6
  "state": "pending",
6
7
  "verification_token": "F06PGMsZIO0shrveGWuGxgCj7",
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "object": "organization_domain",
3
3
  "id": "org_domain_01HCZRAP3TPQ0X0DKJHR32TATG",
4
+ "organization_id": "org_01JR8C1EHCRPV4B4XP4W2B9X1M",
4
5
  "domain": "workos.com",
5
6
  "state": "verified",
6
7
  "verification_token": null,
@@ -15,6 +15,7 @@ export interface OrganizationDomain {
15
15
  object: 'organization_domain';
16
16
  id: string;
17
17
  domain: string;
18
+ organizationId: string;
18
19
  state: OrganizationDomainState;
19
20
  verificationToken?: string;
20
21
  verificationStrategy: OrganizationDomainVerificationStrategy;
@@ -23,6 +24,7 @@ export interface OrganizationDomainResponse {
23
24
  object: 'organization_domain';
24
25
  id: string;
25
26
  domain: string;
27
+ organization_id: string;
26
28
  state: OrganizationDomainState;
27
29
  verification_token?: string;
28
30
  verification_strategy: OrganizationDomainVerificationStrategy;
@@ -28,6 +28,7 @@ describe('OrganizationDomains', () => {
28
28
  expect((0, test_utils_1.fetchURL)()).toContain('/organization_domains/org_domain_01HCZRAP3TPQ0X0DKJHR32TATG');
29
29
  expect(subject.id).toEqual('org_domain_01HCZRAP3TPQ0X0DKJHR32TATG');
30
30
  expect(subject.domain).toEqual('workos.com');
31
+ expect(subject.organizationId).toEqual('org_01JR8C1EHCRPV4B4XP4W2B9X1M');
31
32
  expect(subject.state).toEqual(interfaces_1.OrganizationDomainState.Verified);
32
33
  expect(subject.verificationToken).toBeNull();
33
34
  expect(subject.verificationStrategy).toEqual('manual');
@@ -38,6 +39,7 @@ describe('OrganizationDomains', () => {
38
39
  expect((0, test_utils_1.fetchURL)()).toContain('/organization_domains/org_domain_01HD50K7EPWCMNPGMKXKKE14XT');
39
40
  expect(subject.id).toEqual('org_domain_01HD50K7EPWCMNPGMKXKKE14XT');
40
41
  expect(subject.domain).toEqual('workos.com');
42
+ expect(subject.organizationId).toEqual('org_01JR8C1EHCRPV4B4XP4W2B9X1M');
41
43
  expect(subject.state).toEqual(interfaces_1.OrganizationDomainState.Pending);
42
44
  expect(subject.verificationToken).toEqual('F06PGMsZIO0shrveGWuGxgCj7');
43
45
  expect(subject.verificationStrategy).toEqual('dns');
@@ -50,6 +52,7 @@ describe('OrganizationDomains', () => {
50
52
  expect((0, test_utils_1.fetchURL)()).toContain('/organization_domains/org_domain_01HD50K7EPWCMNPGMKXKKE14XT/verify');
51
53
  expect(subject.id).toEqual('org_domain_01HD50K7EPWCMNPGMKXKKE14XT');
52
54
  expect(subject.domain).toEqual('workos.com');
55
+ expect(subject.organizationId).toEqual('org_01JR8C1EHCRPV4B4XP4W2B9X1M');
53
56
  expect(subject.state).toEqual(interfaces_1.OrganizationDomainState.Pending);
54
57
  expect(subject.verificationToken).toEqual('F06PGMsZIO0shrveGWuGxgCj7');
55
58
  expect(subject.verificationStrategy).toEqual('dns');
@@ -69,6 +72,7 @@ describe('OrganizationDomains', () => {
69
72
  });
70
73
  expect(subject.id).toEqual('org_domain_01HD50K7EPWCMNPGMKXKKE14XT');
71
74
  expect(subject.domain).toEqual('workos.com');
75
+ expect(subject.organizationId).toEqual('org_01JR8C1EHCRPV4B4XP4W2B9X1M');
72
76
  expect(subject.state).toEqual(interfaces_1.OrganizationDomainState.Pending);
73
77
  expect(subject.verificationToken).toEqual('F06PGMsZIO0shrveGWuGxgCj7');
74
78
  expect(subject.verificationStrategy).toEqual('dns');
@@ -5,6 +5,7 @@ const deserializeOrganizationDomain = (organizationDomain) => ({
5
5
  object: organizationDomain.object,
6
6
  id: organizationDomain.id,
7
7
  domain: organizationDomain.domain,
8
+ organizationId: organizationDomain.organization_id,
8
9
  state: organizationDomain.state,
9
10
  verificationToken: organizationDomain.verification_token,
10
11
  verificationStrategy: organizationDomain.verification_strategy,
@@ -1,9 +1,10 @@
1
+ import { UnknownRecord } from '../../common/interfaces/unknown-record.interface';
1
2
  import { Profile, ProfileResponse } from './profile.interface';
2
- export interface ProfileAndToken {
3
+ export interface ProfileAndToken<CustomAttributesType extends UnknownRecord> {
3
4
  accessToken: string;
4
- profile: Profile;
5
+ profile: Profile<CustomAttributesType>;
5
6
  }
6
- export interface ProfileAndTokenResponse {
7
+ export interface ProfileAndTokenResponse<CustomAttributesType extends UnknownRecord> {
7
8
  access_token: string;
8
- profile: ProfileResponse;
9
+ profile: ProfileResponse<CustomAttributesType>;
9
10
  }
@@ -1,6 +1,7 @@
1
+ import { UnknownRecord } from '../../common/interfaces/unknown-record.interface';
1
2
  import { RoleResponse } from '../../roles/interfaces';
2
3
  import { ConnectionType } from './connection-type.enum';
3
- export interface Profile {
4
+ export interface Profile<CustomAttributesType extends UnknownRecord> {
4
5
  id: string;
5
6
  idpId: string;
6
7
  organizationId?: string;
@@ -11,11 +12,12 @@ export interface Profile {
11
12
  lastName?: string;
12
13
  role?: RoleResponse;
13
14
  groups?: string[];
15
+ customAttributes?: CustomAttributesType;
14
16
  rawAttributes?: {
15
17
  [key: string]: any;
16
18
  };
17
19
  }
18
- export interface ProfileResponse {
20
+ export interface ProfileResponse<CustomAttributesType extends UnknownRecord> {
19
21
  id: string;
20
22
  idp_id: string;
21
23
  organization_id?: string;
@@ -26,6 +28,7 @@ export interface ProfileResponse {
26
28
  last_name?: string;
27
29
  role?: RoleResponse;
28
30
  groups?: string[];
31
+ custom_attributes?: CustomAttributesType;
29
32
  raw_attributes?: {
30
33
  [key: string]: any;
31
34
  };
@@ -1,2 +1,3 @@
1
+ import { UnknownRecord } from '../../common/interfaces/unknown-record.interface';
1
2
  import { ProfileAndToken, ProfileAndTokenResponse } from '../interfaces';
2
- export declare const deserializeProfileAndToken: (profileAndToken: ProfileAndTokenResponse) => ProfileAndToken;
3
+ export declare const deserializeProfileAndToken: <CustomAttributesType extends UnknownRecord>(profileAndToken: ProfileAndTokenResponse<CustomAttributesType>) => ProfileAndToken<CustomAttributesType>;
@@ -1,2 +1,3 @@
1
+ import { UnknownRecord } from '../../common/interfaces/unknown-record.interface';
1
2
  import { Profile, ProfileResponse } from '../interfaces';
2
- export declare const deserializeProfile: (profile: ProfileResponse) => Profile;
3
+ export declare const deserializeProfile: <CustomAttributesType extends UnknownRecord>(profile: ProfileResponse<CustomAttributesType>) => Profile<CustomAttributesType>;
@@ -12,6 +12,7 @@ const deserializeProfile = (profile) => ({
12
12
  lastName: profile.last_name,
13
13
  role: profile.role,
14
14
  groups: profile.groups,
15
+ customAttributes: profile.custom_attributes,
15
16
  rawAttributes: profile.raw_attributes,
16
17
  });
17
18
  exports.deserializeProfile = deserializeProfile;
package/lib/sso/sso.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { AutoPaginatable } from '../common/utils/pagination';
2
2
  import { WorkOS } from '../workos';
3
3
  import { AuthorizationURLOptions, Connection, GetProfileAndTokenOptions, GetProfileOptions, ListConnectionsOptions, Profile, ProfileAndToken } from './interfaces';
4
+ import { UnknownRecord } from '../common/interfaces/unknown-record.interface';
4
5
  export declare class SSO {
5
6
  private readonly workos;
6
7
  constructor(workos: WorkOS);
@@ -8,6 +9,6 @@ export declare class SSO {
8
9
  deleteConnection(id: string): Promise<void>;
9
10
  getAuthorizationUrl({ connection, clientId, domain, domainHint, loginHint, organization, provider, redirectUri, state, }: AuthorizationURLOptions): string;
10
11
  getConnection(id: string): Promise<Connection>;
11
- getProfileAndToken({ code, clientId, }: GetProfileAndTokenOptions): Promise<ProfileAndToken>;
12
- getProfile({ accessToken }: GetProfileOptions): Promise<Profile>;
12
+ getProfileAndToken<CustomAttributesType extends UnknownRecord = UnknownRecord>({ code, clientId, }: GetProfileAndTokenOptions): Promise<ProfileAndToken<CustomAttributesType>>;
13
+ getProfile<CustomAttributesType extends UnknownRecord = UnknownRecord>({ accessToken, }: GetProfileOptions): Promise<Profile<CustomAttributesType>>;
13
14
  }
package/lib/sso/sso.js CHANGED
@@ -77,7 +77,7 @@ class SSO {
77
77
  return (0, serializers_1.deserializeProfileAndToken)(data);
78
78
  });
79
79
  }
80
- getProfile({ accessToken }) {
80
+ getProfile({ accessToken, }) {
81
81
  return __awaiter(this, void 0, void 0, function* () {
82
82
  const { data } = yield this.workos.get('/sso/profile', {
83
83
  accessToken,
@@ -185,6 +185,10 @@ describe('SSO', () => {
185
185
  first_name: 'foo',
186
186
  last_name: 'bar',
187
187
  groups: ['Admins', 'Developers'],
188
+ license: 'professional',
189
+ },
190
+ custom_attributes: {
191
+ license: 'professional',
188
192
  },
189
193
  },
190
194
  });
@@ -221,6 +225,7 @@ describe('SSO', () => {
221
225
  first_name: 'foo',
222
226
  last_name: 'bar',
223
227
  },
228
+ custom_attributes: {},
224
229
  },
225
230
  });
226
231
  const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
@@ -257,6 +262,7 @@ describe('SSO', () => {
257
262
  last_name: 'bar',
258
263
  groups: ['Admins', 'Developers'],
259
264
  },
265
+ custom_attributes: {},
260
266
  });
261
267
  const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
262
268
  const profile = yield workos.sso.getProfile({
package/lib/workos.js CHANGED
@@ -31,7 +31,7 @@ const widgets_1 = require("./widgets/widgets");
31
31
  const actions_1 = require("./actions/actions");
32
32
  const vault_1 = require("./vault/vault");
33
33
  const conflict_exception_1 = require("./common/exceptions/conflict.exception");
34
- const VERSION = '7.46.0';
34
+ const VERSION = '7.48.0';
35
35
  const DEFAULT_HOSTNAME = 'api.workos.com';
36
36
  const HEADER_AUTHORIZATION = 'Authorization';
37
37
  const HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "7.46.0",
2
+ "version": "7.48.0",
3
3
  "name": "@workos-inc/node",
4
4
  "author": "WorkOS",
5
5
  "description": "A Node wrapper for the WorkOS API",