@workos-inc/node 7.12.0 → 7.13.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.
- package/lib/user-management/fixtures/identity.json +12 -0
- package/lib/user-management/interfaces/identity.interface.d.ts +10 -0
- package/lib/user-management/interfaces/identity.interface.js +2 -0
- package/lib/user-management/serializers/identity.serializer.d.ts +2 -0
- package/lib/user-management/serializers/identity.serializer.js +13 -0
- package/lib/user-management/user-management.d.ts +2 -0
- package/lib/user-management/user-management.js +10 -0
- package/lib/user-management/user-management.spec.js +20 -0
- package/lib/workos.js +1 -1
- package/package.json +1 -1
|
@@ -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,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.
|
|
29
|
+
const VERSION = '7.13.0';
|
|
30
30
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
31
31
|
class WorkOS {
|
|
32
32
|
constructor(key, options = {}) {
|
package/package.json
CHANGED