@workos-inc/node 7.12.0 → 7.14.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.
@@ -1,6 +1,7 @@
1
1
  export declare enum ConnectionType {
2
2
  ADFSSAML = "ADFSSAML",
3
3
  AdpOidc = "AdpOidc",
4
+ AppleOAuth = "AppleOAuth",
4
5
  Auth0SAML = "Auth0SAML",
5
6
  AzureSAML = "AzureSAML",
6
7
  CasSAML = "CasSAML",
@@ -10,6 +11,7 @@ export declare enum ConnectionType {
10
11
  DuoSAML = "DuoSAML",
11
12
  GenericOIDC = "GenericOIDC",
12
13
  GenericSAML = "GenericSAML",
14
+ GitHubOAuth = "GitHubOAuth",
13
15
  GoogleOAuth = "GoogleOAuth",
14
16
  GoogleSAML = "GoogleSAML",
15
17
  JumpCloudSAML = "JumpCloudSAML",
@@ -5,6 +5,7 @@ var ConnectionType;
5
5
  (function (ConnectionType) {
6
6
  ConnectionType["ADFSSAML"] = "ADFSSAML";
7
7
  ConnectionType["AdpOidc"] = "AdpOidc";
8
+ ConnectionType["AppleOAuth"] = "AppleOAuth";
8
9
  ConnectionType["Auth0SAML"] = "Auth0SAML";
9
10
  ConnectionType["AzureSAML"] = "AzureSAML";
10
11
  ConnectionType["CasSAML"] = "CasSAML";
@@ -14,6 +15,7 @@ var ConnectionType;
14
15
  ConnectionType["DuoSAML"] = "DuoSAML";
15
16
  ConnectionType["GenericOIDC"] = "GenericOIDC";
16
17
  ConnectionType["GenericSAML"] = "GenericSAML";
18
+ ConnectionType["GitHubOAuth"] = "GitHubOAuth";
17
19
  ConnectionType["GoogleOAuth"] = "GoogleOAuth";
18
20
  ConnectionType["GoogleSAML"] = "GoogleSAML";
19
21
  ConnectionType["JumpCloudSAML"] = "JumpCloudSAML";
@@ -0,0 +1,12 @@
1
+ [
2
+ {
3
+ "idp_id": "108872335",
4
+ "type": "OAuth",
5
+ "provider": "GithubOAuth"
6
+ },
7
+ {
8
+ "idp_id": "111966195055680542408",
9
+ "type": "OAuth",
10
+ "provider": "GoogleOAuth"
11
+ }
12
+ ]
@@ -1,6 +1,6 @@
1
1
  import { Impersonator, ImpersonatorResponse } from './impersonator.interface';
2
2
  import { User, UserResponse } from './user.interface';
3
- type AuthenticationMethod = 'SSO' | 'Password' | 'GitHubOAuth' | 'GoogleOAuth' | 'MicrosoftOAuth' | 'MagicAuth' | 'Impersonation';
3
+ type AuthenticationMethod = 'SSO' | 'Password' | 'AppleOAuth' | 'GitHubOAuth' | 'GoogleOAuth' | 'MicrosoftOAuth' | 'MagicAuth' | 'Impersonation';
4
4
  export interface AuthenticationResponse {
5
5
  user: User;
6
6
  organizationId?: string;
@@ -0,0 +1,10 @@
1
+ export interface Identity {
2
+ idpId: string;
3
+ type: 'OAuth';
4
+ provider: 'AppleOAuth' | 'GoogleOAuth' | 'GitHubOAuth' | 'MicrosoftOAuth';
5
+ }
6
+ export interface IdentityResponse {
7
+ idp_id: string;
8
+ type: 'OAuth';
9
+ provider: 'AppleOAuth' | 'GoogleOAuth' | 'GitHubOAuth' | 'MicrosoftOAuth';
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ import { Identity, IdentityResponse } from '../interfaces/identity.interface';
2
+ export declare const deserializeIdentities: (identities: IdentityResponse[]) => Identity[];
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deserializeIdentities = void 0;
4
+ const deserializeIdentities = (identities) => {
5
+ return identities.map((identity) => {
6
+ return {
7
+ idpId: identity.idp_id,
8
+ type: identity.type,
9
+ provider: identity.provider,
10
+ };
11
+ });
12
+ };
13
+ exports.deserializeIdentities = deserializeIdentities;
@@ -14,6 +14,7 @@ import { AuthenticateWithOrganizationSelectionOptions } from './interfaces/authe
14
14
  import { Factor, FactorWithSecrets } from './interfaces/factor.interface';
15
15
  import { RevokeSessionOptions } from './interfaces/revoke-session-options.interface';
16
16
  import { UpdateOrganizationMembershipOptions } from './interfaces/update-organization-membership-options.interface';
17
+ import { Identity } from './interfaces/identity.interface';
17
18
  export declare class UserManagement {
18
19
  private readonly workos;
19
20
  constructor(workos: WorkOS);
@@ -56,6 +57,7 @@ export declare class UserManagement {
56
57
  }>;
57
58
  listAuthFactors(options: ListAuthFactorsOptions): Promise<AutoPaginatable<Factor>>;
58
59
  deleteUser(userId: string): Promise<void>;
60
+ getUserIdentities(userId: string): Promise<Identity[]>;
59
61
  getOrganizationMembership(organizationMembershipId: string): Promise<OrganizationMembership>;
60
62
  listOrganizationMemberships(options: ListOrganizationMembershipsOptions): Promise<AutoPaginatable<OrganizationMembership>>;
61
63
  createOrganizationMembership(options: CreateOrganizationMembershipOptions): Promise<OrganizationMembership>;
@@ -37,6 +37,7 @@ const authenticate_with_organization_selection_options_serializer_1 = require(".
37
37
  const factor_serializer_1 = require("./serializers/factor.serializer");
38
38
  const revoke_session_options_interface_1 = require("./interfaces/revoke-session-options.interface");
39
39
  const update_organization_membership_options_serializer_1 = require("./serializers/update-organization-membership-options.serializer");
40
+ const identity_serializer_1 = require("./serializers/identity.serializer");
40
41
  const toQueryString = (options) => {
41
42
  const searchParams = new URLSearchParams();
42
43
  const keys = Object.keys(options).sort();
@@ -203,6 +204,15 @@ class UserManagement {
203
204
  yield this.workos.delete(`/user_management/users/${userId}`);
204
205
  });
205
206
  }
207
+ getUserIdentities(userId) {
208
+ return __awaiter(this, void 0, void 0, function* () {
209
+ if (!userId) {
210
+ throw new TypeError(`Incomplete arguments. Need to specify 'userId'.`);
211
+ }
212
+ const { data } = yield this.workos.get(`/user_management/users/${userId}/identities`);
213
+ return (0, identity_serializer_1.deserializeIdentities)(data);
214
+ });
215
+ }
206
216
  getOrganizationMembership(organizationMembershipId) {
207
217
  return __awaiter(this, void 0, void 0, function* () {
208
218
  const { data } = yield this.workos.get(`/user_management/organization_memberships/${organizationMembershipId}`);
@@ -26,6 +26,7 @@ const magic_auth_json_1 = __importDefault(require("./fixtures/magic_auth.json"))
26
26
  const organization_membership_json_1 = __importDefault(require("./fixtures/organization-membership.json"));
27
27
  const password_reset_json_1 = __importDefault(require("./fixtures/password_reset.json"));
28
28
  const user_json_1 = __importDefault(require("./fixtures/user.json"));
29
+ const identity_json_1 = __importDefault(require("./fixtures/identity.json"));
29
30
  const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
30
31
  const userId = 'user_01H5JQDV7R7ATEYZDEG0W5PRYS';
31
32
  const organizationMembershipId = 'om_01H5JQDV7R7ATEYZDEG0W5PRYS';
@@ -616,6 +617,25 @@ describe('UserManagement', () => {
616
617
  expect(resp).toBeUndefined();
617
618
  }));
618
619
  });
620
+ describe('getUserIdentities', () => {
621
+ it('sends a Get User Identities request', () => __awaiter(void 0, void 0, void 0, function* () {
622
+ (0, test_utils_1.fetchOnce)(identity_json_1.default);
623
+ const resp = yield workos.userManagement.getUserIdentities(userId);
624
+ expect((0, test_utils_1.fetchURL)()).toContain(`/user_management/users/${userId}/identities`);
625
+ expect(resp).toMatchObject([
626
+ {
627
+ idpId: '108872335',
628
+ type: 'OAuth',
629
+ provider: 'GithubOAuth',
630
+ },
631
+ {
632
+ idpId: '111966195055680542408',
633
+ type: 'OAuth',
634
+ provider: 'GoogleOAuth',
635
+ },
636
+ ]);
637
+ }));
638
+ });
619
639
  describe('getOrganizationMembership', () => {
620
640
  it('sends a Get OrganizationMembership request', () => __awaiter(void 0, void 0, void 0, function* () {
621
641
  (0, test_utils_1.fetchOnce)(organization_membership_json_1.default, {
package/lib/workos.js CHANGED
@@ -26,7 +26,7 @@ const bad_request_exception_1 = require("./common/exceptions/bad-request.excepti
26
26
  const http_client_1 = require("./common/net/http-client");
27
27
  const subtle_crypto_provider_1 = require("./common/crypto/subtle-crypto-provider");
28
28
  const fetch_client_1 = require("./common/net/fetch-client");
29
- const VERSION = '7.12.0';
29
+ const VERSION = '7.14.0';
30
30
  const DEFAULT_HOSTNAME = 'api.workos.com';
31
31
  class WorkOS {
32
32
  constructor(key, options = {}) {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "7.12.0",
2
+ "version": "7.14.0",
3
3
  "name": "@workos-inc/node",
4
4
  "author": "WorkOS",
5
5
  "description": "A Node wrapper for the WorkOS API",