@workos-inc/node 7.70.0 → 7.72.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/api-keys/api-keys.d.ts +7 -0
- package/lib/api-keys/api-keys.js +25 -0
- package/lib/api-keys/api-keys.spec.d.ts +1 -0
- package/lib/api-keys/api-keys.spec.js +61 -0
- package/lib/api-keys/fixtures/validate-api-key.json +16 -0
- package/lib/api-keys/interfaces/api-key.interface.d.ts +28 -0
- package/lib/api-keys/interfaces/validate-api-key.interface.d.ts +10 -0
- package/lib/api-keys/interfaces/validate-api-key.interface.js +2 -0
- package/lib/api-keys/serializers/api-key.serializer.d.ts +2 -0
- package/lib/api-keys/serializers/api-key.serializer.js +17 -0
- package/lib/api-keys/serializers/validate-api-key.serializer.d.ts +2 -0
- package/lib/api-keys/serializers/validate-api-key.serializer.js +10 -0
- package/lib/feature-flags/interfaces/feature-flag.interface.js +2 -0
- package/lib/organizations/interfaces/index.d.ts +0 -1
- package/lib/organizations/interfaces/index.js +0 -1
- package/lib/organizations/organizations.d.ts +1 -1
- package/lib/organizations/organizations.js +1 -1
- package/lib/sso/interfaces/connection-type.enum.d.ts +1 -0
- package/lib/sso/interfaces/connection-type.enum.js +1 -0
- package/lib/user-management/fixtures/list-user-feature-flags.json +33 -0
- package/lib/user-management/fixtures/list-users.json +2 -1
- package/lib/user-management/fixtures/user.json +1 -0
- package/lib/user-management/interfaces/authentication-response.interface.d.ts +1 -1
- package/lib/user-management/interfaces/identity.interface.d.ts +2 -2
- package/lib/user-management/interfaces/index.d.ts +1 -0
- package/lib/user-management/interfaces/index.js +1 -0
- package/lib/user-management/interfaces/list-user-feature-flags-options.interface.d.ts +4 -0
- package/lib/user-management/interfaces/list-user-feature-flags-options.interface.js +2 -0
- package/lib/user-management/interfaces/update-user-options.interface.d.ts +2 -0
- package/lib/user-management/interfaces/user.interface.d.ts +2 -0
- package/lib/user-management/serializers/update-user-options.serializer.js +1 -0
- package/lib/user-management/serializers/user.serializer.js +1 -0
- package/lib/user-management/user-management.d.ts +3 -1
- package/lib/user-management/user-management.js +7 -0
- package/lib/user-management/user-management.spec.js +102 -0
- package/lib/workos.d.ts +2 -0
- package/lib/workos.js +3 -1
- package/package.json +5 -1
- /package/lib/{organizations/interfaces/feature-flag.interface.js → api-keys/interfaces/api-key.interface.js} +0 -0
- /package/lib/{organizations → feature-flags}/interfaces/feature-flag.interface.d.ts +0 -0
- /package/lib/{organizations → feature-flags}/serializers/feature-flag.serializer.d.ts +0 -0
- /package/lib/{organizations → feature-flags}/serializers/feature-flag.serializer.js +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { WorkOS } from '../workos';
|
|
2
|
+
import { ValidateApiKeyOptions, ValidateApiKeyResponse } from './interfaces/validate-api-key.interface';
|
|
3
|
+
export declare class ApiKeys {
|
|
4
|
+
private readonly workos;
|
|
5
|
+
constructor(workos: WorkOS);
|
|
6
|
+
validateApiKey(payload: ValidateApiKeyOptions): Promise<ValidateApiKeyResponse>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ApiKeys = void 0;
|
|
13
|
+
const validate_api_key_serializer_1 = require("./serializers/validate-api-key.serializer");
|
|
14
|
+
class ApiKeys {
|
|
15
|
+
constructor(workos) {
|
|
16
|
+
this.workos = workos;
|
|
17
|
+
}
|
|
18
|
+
validateApiKey(payload) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const { data } = yield this.workos.post('/api_keys/validations', payload);
|
|
21
|
+
return (0, validate_api_key_serializer_1.deserializeValidateApiKeyResponse)(data);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.ApiKeys = ApiKeys;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const jest_fetch_mock_1 = __importDefault(require("jest-fetch-mock"));
|
|
16
|
+
const test_utils_1 = require("../common/utils/test-utils");
|
|
17
|
+
const workos_1 = require("../workos");
|
|
18
|
+
const validate_api_key_json_1 = __importDefault(require("./fixtures/validate-api-key.json"));
|
|
19
|
+
describe('ApiKeys', () => {
|
|
20
|
+
let workos;
|
|
21
|
+
beforeAll(() => {
|
|
22
|
+
workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU', {
|
|
23
|
+
apiHostname: 'api.workos.test',
|
|
24
|
+
clientId: 'proj_123',
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
beforeEach(() => jest_fetch_mock_1.default.resetMocks());
|
|
28
|
+
describe('validateApiKey', () => {
|
|
29
|
+
it('sends a validate API key request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
(0, test_utils_1.fetchOnce)(validate_api_key_json_1.default);
|
|
31
|
+
const response = yield workos.apiKeys.validateApiKey({
|
|
32
|
+
value: 'sk_123',
|
|
33
|
+
});
|
|
34
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/api_keys/validations');
|
|
35
|
+
expect(response).toEqual({
|
|
36
|
+
apiKey: {
|
|
37
|
+
object: 'api_key',
|
|
38
|
+
id: 'api_key_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
39
|
+
owner: {
|
|
40
|
+
type: 'organization',
|
|
41
|
+
id: 'org_01H5JQDV7R7ATEYZDEG0W5PRYS',
|
|
42
|
+
},
|
|
43
|
+
name: 'Test Api Key',
|
|
44
|
+
obfuscatedValue: 'sk_…PRYS',
|
|
45
|
+
lastUsedAt: null,
|
|
46
|
+
permissions: ['read', 'write'],
|
|
47
|
+
createdAt: '2023-07-18T02:07:19.911Z',
|
|
48
|
+
updatedAt: '2023-07-18T02:07:19.911Z',
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}));
|
|
52
|
+
it('returns null if key is invalid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
(0, test_utils_1.fetchOnce)({ api_key: null });
|
|
54
|
+
const response = yield workos.apiKeys.validateApiKey({
|
|
55
|
+
value: 'invalid',
|
|
56
|
+
});
|
|
57
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/api_keys/validations');
|
|
58
|
+
expect(response).toEqual({ apiKey: null });
|
|
59
|
+
}));
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"api_key": {
|
|
3
|
+
"object": "api_key",
|
|
4
|
+
"id": "api_key_01H5JQDV7R7ATEYZDEG0W5PRYS",
|
|
5
|
+
"owner": {
|
|
6
|
+
"type": "organization",
|
|
7
|
+
"id": "org_01H5JQDV7R7ATEYZDEG0W5PRYS"
|
|
8
|
+
},
|
|
9
|
+
"name": "Test Api Key",
|
|
10
|
+
"obfuscated_value": "sk_…PRYS",
|
|
11
|
+
"last_used_at": null,
|
|
12
|
+
"permissions": ["read", "write"],
|
|
13
|
+
"created_at": "2023-07-18T02:07:19.911Z",
|
|
14
|
+
"updated_at": "2023-07-18T02:07:19.911Z"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface ApiKey {
|
|
2
|
+
object: 'api_key';
|
|
3
|
+
id: string;
|
|
4
|
+
owner: {
|
|
5
|
+
type: 'organization';
|
|
6
|
+
id: string;
|
|
7
|
+
};
|
|
8
|
+
name: string;
|
|
9
|
+
obfuscatedValue: string;
|
|
10
|
+
lastUsedAt: string | null;
|
|
11
|
+
permissions: string[];
|
|
12
|
+
createdAt: string;
|
|
13
|
+
updatedAt: string;
|
|
14
|
+
}
|
|
15
|
+
export interface SerializedApiKey {
|
|
16
|
+
object: 'api_key';
|
|
17
|
+
id: string;
|
|
18
|
+
owner: {
|
|
19
|
+
type: 'organization';
|
|
20
|
+
id: string;
|
|
21
|
+
};
|
|
22
|
+
name: string;
|
|
23
|
+
obfuscated_value: string;
|
|
24
|
+
last_used_at: string | null;
|
|
25
|
+
permissions: string[];
|
|
26
|
+
created_at: string;
|
|
27
|
+
updated_at: string;
|
|
28
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ApiKey, SerializedApiKey } from './api-key.interface';
|
|
2
|
+
export interface ValidateApiKeyOptions {
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
export interface ValidateApiKeyResponse {
|
|
6
|
+
apiKey: ApiKey | null;
|
|
7
|
+
}
|
|
8
|
+
export interface SerializedValidateApiKeyResponse {
|
|
9
|
+
api_key: SerializedApiKey | null;
|
|
10
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deserializeApiKey = void 0;
|
|
4
|
+
function deserializeApiKey(apiKey) {
|
|
5
|
+
return {
|
|
6
|
+
object: apiKey.object,
|
|
7
|
+
id: apiKey.id,
|
|
8
|
+
owner: apiKey.owner,
|
|
9
|
+
name: apiKey.name,
|
|
10
|
+
obfuscatedValue: apiKey.obfuscated_value,
|
|
11
|
+
lastUsedAt: apiKey.last_used_at,
|
|
12
|
+
permissions: apiKey.permissions,
|
|
13
|
+
createdAt: apiKey.created_at,
|
|
14
|
+
updatedAt: apiKey.updated_at,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
exports.deserializeApiKey = deserializeApiKey;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deserializeValidateApiKeyResponse = void 0;
|
|
4
|
+
const api_key_serializer_1 = require("./api-key.serializer");
|
|
5
|
+
function deserializeValidateApiKeyResponse(response) {
|
|
6
|
+
return {
|
|
7
|
+
apiKey: response.api_key ? (0, api_key_serializer_1.deserializeApiKey)(response.api_key) : null,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
exports.deserializeValidateApiKeyResponse = deserializeValidateApiKeyResponse;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from './create-organization-options.interface';
|
|
2
2
|
export * from './domain-data.interface';
|
|
3
|
-
export * from './feature-flag.interface';
|
|
4
3
|
export * from './list-organization-feature-flags-options.interface';
|
|
5
4
|
export * from './list-organizations-options.interface';
|
|
6
5
|
export * from './organization.interface';
|
|
@@ -16,7 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./create-organization-options.interface"), exports);
|
|
18
18
|
__exportStar(require("./domain-data.interface"), exports);
|
|
19
|
-
__exportStar(require("./feature-flag.interface"), exports);
|
|
20
19
|
__exportStar(require("./list-organization-feature-flags-options.interface"), exports);
|
|
21
20
|
__exportStar(require("./list-organizations-options.interface"), exports);
|
|
22
21
|
__exportStar(require("./organization.interface"), exports);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AutoPaginatable } from '../common/utils/pagination';
|
|
2
2
|
import { WorkOS } from '../workos';
|
|
3
3
|
import { CreateOrganizationOptions, CreateOrganizationRequestOptions, ListOrganizationsOptions, Organization, UpdateOrganizationOptions } from './interfaces';
|
|
4
|
-
import { FeatureFlag } from '
|
|
4
|
+
import { FeatureFlag } from '../feature-flags/interfaces/feature-flag.interface';
|
|
5
5
|
import { RoleList } from '../roles/interfaces';
|
|
6
6
|
import { ListOrganizationRolesOptions } from './interfaces/list-organization-roles-options.interface';
|
|
7
7
|
import { ListOrganizationFeatureFlagsOptions } from './interfaces/list-organization-feature-flags-options.interface';
|
|
@@ -25,7 +25,7 @@ const pagination_1 = require("../common/utils/pagination");
|
|
|
25
25
|
const serializers_1 = require("./serializers");
|
|
26
26
|
const fetch_and_deserialize_1 = require("../common/utils/fetch-and-deserialize");
|
|
27
27
|
const role_serializer_1 = require("../roles/serializers/role.serializer");
|
|
28
|
-
const feature_flag_serializer_1 = require("
|
|
28
|
+
const feature_flag_serializer_1 = require("../feature-flags/serializers/feature-flag.serializer");
|
|
29
29
|
class Organizations {
|
|
30
30
|
constructor(workos) {
|
|
31
31
|
this.workos = workos;
|
|
@@ -28,6 +28,7 @@ export declare enum ConnectionType {
|
|
|
28
28
|
PingFederateSAML = "PingFederateSAML",
|
|
29
29
|
PingOneSAML = "PingOneSAML",
|
|
30
30
|
RipplingSAML = "RipplingSAML",
|
|
31
|
+
SalesforceOAuth = "SalesforceOAuth",
|
|
31
32
|
SalesforceSAML = "SalesforceSAML",
|
|
32
33
|
ShibbolethGenericSAML = "ShibbolethGenericSAML",
|
|
33
34
|
ShibbolethSAML = "ShibbolethSAML",
|
|
@@ -32,6 +32,7 @@ var ConnectionType;
|
|
|
32
32
|
ConnectionType["PingFederateSAML"] = "PingFederateSAML";
|
|
33
33
|
ConnectionType["PingOneSAML"] = "PingOneSAML";
|
|
34
34
|
ConnectionType["RipplingSAML"] = "RipplingSAML";
|
|
35
|
+
ConnectionType["SalesforceOAuth"] = "SalesforceOAuth";
|
|
35
36
|
ConnectionType["SalesforceSAML"] = "SalesforceSAML";
|
|
36
37
|
ConnectionType["ShibbolethGenericSAML"] = "ShibbolethGenericSAML";
|
|
37
38
|
ConnectionType["ShibbolethSAML"] = "ShibbolethSAML";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"object": "list",
|
|
3
|
+
"data": [
|
|
4
|
+
{
|
|
5
|
+
"object": "feature_flag",
|
|
6
|
+
"id": "flag_01EHQMYV6MBK39QC5PZXHY59C5",
|
|
7
|
+
"name": "Advanced Dashboard",
|
|
8
|
+
"slug": "advanced-dashboard",
|
|
9
|
+
"description": "Enable advanced dashboard features",
|
|
10
|
+
"created_at": "2024-01-01T00:00:00.000Z",
|
|
11
|
+
"updated_at": "2024-01-01T00:00:00.000Z"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"object": "feature_flag",
|
|
15
|
+
"id": "flag_01EHQMYV6MBK39QC5PZXHY59C6",
|
|
16
|
+
"name": "Beta Features",
|
|
17
|
+
"slug": "beta-features",
|
|
18
|
+
"description": null,
|
|
19
|
+
"created_at": "2024-01-01T00:00:00.000Z",
|
|
20
|
+
"updated_at": "2024-01-01T00:00:00.000Z"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"object": "feature_flag",
|
|
24
|
+
"id": "flag_01EHQMYV6MBK39QC5PZXHY59C7",
|
|
25
|
+
"name": "Premium Support",
|
|
26
|
+
"slug": "premium-support",
|
|
27
|
+
"description": "Access to premium support features",
|
|
28
|
+
"created_at": "2024-01-01T00:00:00.000Z",
|
|
29
|
+
"updated_at": "2024-01-01T00:00:00.000Z"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"list_metadata": {}
|
|
33
|
+
}
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"updated_at": "2023-07-18T02:07:19.911Z",
|
|
12
12
|
"email_verified": true,
|
|
13
13
|
"profile_picture_url": "https://example.com/profile_picture.jpg",
|
|
14
|
-
"last_sign_in_at": "2023-07-18T02:07:19.911Z"
|
|
14
|
+
"last_sign_in_at": "2023-07-18T02:07:19.911Z",
|
|
15
|
+
"locale": "en-US"
|
|
15
16
|
}
|
|
16
17
|
],
|
|
17
18
|
"list_metadata": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Impersonator, ImpersonatorResponse } from './impersonator.interface';
|
|
2
2
|
import { OauthTokens, OauthTokensResponse } from './oauth-tokens.interface';
|
|
3
3
|
import { User, UserResponse } from './user.interface';
|
|
4
|
-
type AuthenticationMethod = 'SSO' | 'Password' | 'Passkey' | 'AppleOAuth' | 'GitHubOAuth' | 'GoogleOAuth' | 'MicrosoftOAuth' | 'MagicAuth' | 'Impersonation';
|
|
4
|
+
type AuthenticationMethod = 'SSO' | 'Password' | 'Passkey' | 'AppleOAuth' | 'GitHubOAuth' | 'GoogleOAuth' | 'MicrosoftOAuth' | 'SalesforceOAuth' | 'MagicAuth' | 'Impersonation';
|
|
5
5
|
export interface AuthenticationResponse {
|
|
6
6
|
user: User;
|
|
7
7
|
organizationId?: string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export interface Identity {
|
|
2
2
|
idpId: string;
|
|
3
3
|
type: 'OAuth';
|
|
4
|
-
provider: 'AppleOAuth' | 'GoogleOAuth' | 'GitHubOAuth' | 'MicrosoftOAuth';
|
|
4
|
+
provider: 'AppleOAuth' | 'GoogleOAuth' | 'GitHubOAuth' | 'MicrosoftOAuth' | 'SalesforceOAuth';
|
|
5
5
|
}
|
|
6
6
|
export interface IdentityResponse {
|
|
7
7
|
idp_id: string;
|
|
8
8
|
type: 'OAuth';
|
|
9
|
-
provider: 'AppleOAuth' | 'GoogleOAuth' | 'GitHubOAuth' | 'MicrosoftOAuth';
|
|
9
|
+
provider: 'AppleOAuth' | 'GoogleOAuth' | 'GitHubOAuth' | 'MicrosoftOAuth' | 'SalesforceOAuth';
|
|
10
10
|
}
|
|
@@ -26,6 +26,7 @@ export * from './list-auth-factors-options.interface';
|
|
|
26
26
|
export * from './list-invitations-options.interface';
|
|
27
27
|
export * from './list-organization-memberships-options.interface';
|
|
28
28
|
export * from './list-sessions-options.interface';
|
|
29
|
+
export * from './list-user-feature-flags-options.interface';
|
|
29
30
|
export * from './list-users-options.interface';
|
|
30
31
|
export * from './magic-auth.interface';
|
|
31
32
|
export * from './oauth-tokens.interface';
|
|
@@ -42,6 +42,7 @@ __exportStar(require("./list-auth-factors-options.interface"), exports);
|
|
|
42
42
|
__exportStar(require("./list-invitations-options.interface"), exports);
|
|
43
43
|
__exportStar(require("./list-organization-memberships-options.interface"), exports);
|
|
44
44
|
__exportStar(require("./list-sessions-options.interface"), exports);
|
|
45
|
+
__exportStar(require("./list-user-feature-flags-options.interface"), exports);
|
|
45
46
|
__exportStar(require("./list-users-options.interface"), exports);
|
|
46
47
|
__exportStar(require("./magic-auth.interface"), exports);
|
|
47
48
|
__exportStar(require("./oauth-tokens.interface"), exports);
|
|
@@ -9,6 +9,7 @@ export interface UpdateUserOptions {
|
|
|
9
9
|
passwordHash?: string;
|
|
10
10
|
passwordHashType?: PasswordHashType;
|
|
11
11
|
externalId?: string;
|
|
12
|
+
locale?: string;
|
|
12
13
|
metadata?: Record<string, string | null>;
|
|
13
14
|
}
|
|
14
15
|
export interface SerializedUpdateUserOptions {
|
|
@@ -20,5 +21,6 @@ export interface SerializedUpdateUserOptions {
|
|
|
20
21
|
password_hash?: string;
|
|
21
22
|
password_hash_type?: PasswordHashType;
|
|
22
23
|
external_id?: string;
|
|
24
|
+
locale?: string;
|
|
23
25
|
metadata?: Record<string, string | null>;
|
|
24
26
|
}
|
|
@@ -7,6 +7,7 @@ export interface User {
|
|
|
7
7
|
firstName: string | null;
|
|
8
8
|
lastName: string | null;
|
|
9
9
|
lastSignInAt: string | null;
|
|
10
|
+
locale: string | null;
|
|
10
11
|
createdAt: string;
|
|
11
12
|
updatedAt: string;
|
|
12
13
|
externalId: string | null;
|
|
@@ -21,6 +22,7 @@ export interface UserResponse {
|
|
|
21
22
|
first_name: string | null;
|
|
22
23
|
last_name: string | null;
|
|
23
24
|
last_sign_in_at: string | null;
|
|
25
|
+
locale: string | null;
|
|
24
26
|
created_at: string;
|
|
25
27
|
updated_at: string;
|
|
26
28
|
external_id?: string;
|
|
@@ -10,6 +10,7 @@ const serializeUpdateUserOptions = (options) => ({
|
|
|
10
10
|
password_hash: options.passwordHash,
|
|
11
11
|
password_hash_type: options.passwordHashType,
|
|
12
12
|
external_id: options.externalId,
|
|
13
|
+
locale: options.locale,
|
|
13
14
|
metadata: options.metadata,
|
|
14
15
|
});
|
|
15
16
|
exports.serializeUpdateUserOptions = serializeUpdateUserOptions;
|
|
@@ -12,6 +12,7 @@ const deserializeUser = (user) => {
|
|
|
12
12
|
profilePictureUrl: user.profile_picture_url,
|
|
13
13
|
lastName: user.last_name,
|
|
14
14
|
lastSignInAt: user.last_sign_in_at,
|
|
15
|
+
locale: user.locale,
|
|
15
16
|
createdAt: user.created_at,
|
|
16
17
|
updatedAt: user.updated_at,
|
|
17
18
|
externalId: (_a = user.external_id) !== null && _a !== void 0 ? _a : null,
|
|
@@ -2,8 +2,9 @@ import { createRemoteJWKSet } from 'jose';
|
|
|
2
2
|
import { IronSessionProvider } from '../common/iron-session/iron-session-provider';
|
|
3
3
|
import { AutoPaginatable } from '../common/utils/pagination';
|
|
4
4
|
import { Challenge } from '../mfa/interfaces';
|
|
5
|
+
import { FeatureFlag } from '../feature-flags/interfaces/feature-flag.interface';
|
|
5
6
|
import { WorkOS } from '../workos';
|
|
6
|
-
import { AuthenticateWithCodeOptions, AuthenticateWithCodeAndVerifierOptions, AuthenticateWithMagicAuthOptions, AuthenticateWithPasswordOptions, AuthenticateWithRefreshTokenOptions, AuthenticateWithTotpOptions, AuthenticationResponse, CreateMagicAuthOptions, CreatePasswordResetOptions, CreateUserOptions, EmailVerification, EnrollAuthFactorOptions, ListAuthFactorsOptions, ListSessionsOptions, ListUsersOptions, MagicAuth, PasswordReset, ResetPasswordOptions, SendMagicAuthCodeOptions, SendPasswordResetEmailOptions, SendVerificationEmailOptions, Session, UpdateUserOptions, User, VerifyEmailOptions } from './interfaces';
|
|
7
|
+
import { AuthenticateWithCodeOptions, AuthenticateWithCodeAndVerifierOptions, AuthenticateWithMagicAuthOptions, AuthenticateWithPasswordOptions, AuthenticateWithRefreshTokenOptions, AuthenticateWithTotpOptions, AuthenticationResponse, CreateMagicAuthOptions, CreatePasswordResetOptions, CreateUserOptions, EmailVerification, EnrollAuthFactorOptions, ListAuthFactorsOptions, ListSessionsOptions, ListUsersOptions, ListUserFeatureFlagsOptions, MagicAuth, PasswordReset, ResetPasswordOptions, SendMagicAuthCodeOptions, SendPasswordResetEmailOptions, SendVerificationEmailOptions, Session, UpdateUserOptions, User, VerifyEmailOptions } from './interfaces';
|
|
7
8
|
import { AuthenticateWithEmailVerificationOptions } from './interfaces/authenticate-with-email-verification-options.interface';
|
|
8
9
|
import { AuthenticateWithOrganizationSelectionOptions } from './interfaces/authenticate-with-organization-selection.interface';
|
|
9
10
|
import { AuthenticateWithSessionCookieFailedResponse, AuthenticateWithSessionCookieOptions, AuthenticateWithSessionCookieSuccessResponse, SessionCookieData } from './interfaces/authenticate-with-session-cookie.interface';
|
|
@@ -91,6 +92,7 @@ export declare class UserManagement {
|
|
|
91
92
|
authenticationChallenge: Challenge;
|
|
92
93
|
}>;
|
|
93
94
|
listAuthFactors(options: ListAuthFactorsOptions): Promise<AutoPaginatable<Factor>>;
|
|
95
|
+
listUserFeatureFlags(options: ListUserFeatureFlagsOptions): Promise<AutoPaginatable<FeatureFlag>>;
|
|
94
96
|
listSessions(userId: string, options?: ListSessionsOptions): Promise<AutoPaginatable<Session>>;
|
|
95
97
|
deleteUser(userId: string): Promise<void>;
|
|
96
98
|
getUserIdentities(userId: string): Promise<Identity[]>;
|
|
@@ -30,6 +30,7 @@ const oauth_exception_1 = require("../common/exceptions/oauth.exception");
|
|
|
30
30
|
const fetch_and_deserialize_1 = require("../common/utils/fetch-and-deserialize");
|
|
31
31
|
const pagination_1 = require("../common/utils/pagination");
|
|
32
32
|
const serializers_1 = require("../mfa/serializers");
|
|
33
|
+
const feature_flag_serializer_1 = require("../feature-flags/serializers/feature-flag.serializer");
|
|
33
34
|
const authenticate_with_session_cookie_interface_1 = require("./interfaces/authenticate-with-session-cookie.interface");
|
|
34
35
|
const refresh_and_seal_session_data_interface_1 = require("./interfaces/refresh-and-seal-session-data.interface");
|
|
35
36
|
const revoke_session_options_interface_1 = require("./interfaces/revoke-session-options.interface");
|
|
@@ -435,6 +436,12 @@ class UserManagement {
|
|
|
435
436
|
return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/user_management/users/${userId}/auth_factors`, factor_serializer_1.deserializeFactor, restOfOptions), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/user_management/users/${userId}/auth_factors`, factor_serializer_1.deserializeFactor, params), restOfOptions);
|
|
436
437
|
});
|
|
437
438
|
}
|
|
439
|
+
listUserFeatureFlags(options) {
|
|
440
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
441
|
+
const { userId } = options, paginationOptions = __rest(options, ["userId"]);
|
|
442
|
+
return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/user_management/users/${userId}/feature-flags`, feature_flag_serializer_1.deserializeFeatureFlag, paginationOptions), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/user_management/users/${userId}/feature-flags`, feature_flag_serializer_1.deserializeFeatureFlag, params), paginationOptions);
|
|
443
|
+
});
|
|
444
|
+
}
|
|
438
445
|
listSessions(userId, options) {
|
|
439
446
|
return __awaiter(this, void 0, void 0, function* () {
|
|
440
447
|
return new pagination_1.AutoPaginatable(yield (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/user_management/users/${userId}/sessions`, serializers_2.deserializeSession, options ? (0, serializers_2.serializeListSessionsOptions)(options) : undefined), (params) => (0, fetch_and_deserialize_1.fetchAndDeserialize)(this.workos, `/user_management/users/${userId}/sessions`, serializers_2.deserializeSession, params), options ? (0, serializers_2.serializeListSessionsOptions)(options) : undefined);
|
|
@@ -45,6 +45,7 @@ const list_factors_json_1 = __importDefault(require("./fixtures/list-factors.jso
|
|
|
45
45
|
const list_invitations_json_1 = __importDefault(require("./fixtures/list-invitations.json"));
|
|
46
46
|
const list_organization_memberships_json_1 = __importDefault(require("./fixtures/list-organization-memberships.json"));
|
|
47
47
|
const list_sessions_json_1 = __importDefault(require("./fixtures/list-sessions.json"));
|
|
48
|
+
const list_user_feature_flags_json_1 = __importDefault(require("./fixtures/list-user-feature-flags.json"));
|
|
48
49
|
const list_users_json_1 = __importDefault(require("./fixtures/list-users.json"));
|
|
49
50
|
const magic_auth_json_1 = __importDefault(require("./fixtures/magic_auth.json"));
|
|
50
51
|
const organization_membership_json_1 = __importDefault(require("./fixtures/organization-membership.json"));
|
|
@@ -83,6 +84,7 @@ describe('UserManagement', () => {
|
|
|
83
84
|
lastName: 'User',
|
|
84
85
|
emailVerified: true,
|
|
85
86
|
lastSignInAt: '2023-07-18T02:07:19.911Z',
|
|
87
|
+
locale: 'en-US',
|
|
86
88
|
});
|
|
87
89
|
}));
|
|
88
90
|
});
|
|
@@ -101,6 +103,7 @@ describe('UserManagement', () => {
|
|
|
101
103
|
lastName: 'User',
|
|
102
104
|
emailVerified: true,
|
|
103
105
|
lastSignInAt: '2023-07-18T02:07:19.911Z',
|
|
106
|
+
locale: 'en-US',
|
|
104
107
|
externalId,
|
|
105
108
|
});
|
|
106
109
|
}));
|
|
@@ -1241,6 +1244,21 @@ describe('UserManagement', () => {
|
|
|
1241
1244
|
metadata: {},
|
|
1242
1245
|
});
|
|
1243
1246
|
}));
|
|
1247
|
+
it('updates user locale', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1248
|
+
(0, test_utils_1.fetchOnce)(user_json_1.default);
|
|
1249
|
+
const resp = yield workos.userManagement.updateUser({
|
|
1250
|
+
userId,
|
|
1251
|
+
locale: 'en-US',
|
|
1252
|
+
});
|
|
1253
|
+
expect((0, test_utils_1.fetchURL)()).toContain(`/user_management/users/${userId}`);
|
|
1254
|
+
expect((0, test_utils_1.fetchBody)()).toEqual({
|
|
1255
|
+
locale: 'en-US',
|
|
1256
|
+
});
|
|
1257
|
+
expect(resp).toMatchObject({
|
|
1258
|
+
id: userId,
|
|
1259
|
+
locale: 'en-US',
|
|
1260
|
+
});
|
|
1261
|
+
}));
|
|
1244
1262
|
});
|
|
1245
1263
|
describe('enrollAuthFactor', () => {
|
|
1246
1264
|
it('sends an enrollAuthFactor request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1331,6 +1349,90 @@ describe('UserManagement', () => {
|
|
|
1331
1349
|
});
|
|
1332
1350
|
}));
|
|
1333
1351
|
});
|
|
1352
|
+
describe('listUserFeatureFlags', () => {
|
|
1353
|
+
it('returns feature flags for the user', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1354
|
+
(0, test_utils_1.fetchOnce)(list_user_feature_flags_json_1.default);
|
|
1355
|
+
const { data, object, listMetadata } = yield workos.userManagement.listUserFeatureFlags({ userId });
|
|
1356
|
+
expect((0, test_utils_1.fetchURL)()).toContain(`/user_management/users/${userId}/feature-flags`);
|
|
1357
|
+
expect(object).toEqual('list');
|
|
1358
|
+
expect(listMetadata).toEqual({});
|
|
1359
|
+
expect(data).toHaveLength(3);
|
|
1360
|
+
expect(data).toEqual([
|
|
1361
|
+
{
|
|
1362
|
+
object: 'feature_flag',
|
|
1363
|
+
id: 'flag_01EHQMYV6MBK39QC5PZXHY59C5',
|
|
1364
|
+
name: 'Advanced Dashboard',
|
|
1365
|
+
slug: 'advanced-dashboard',
|
|
1366
|
+
description: 'Enable advanced dashboard features',
|
|
1367
|
+
createdAt: '2024-01-01T00:00:00.000Z',
|
|
1368
|
+
updatedAt: '2024-01-01T00:00:00.000Z',
|
|
1369
|
+
},
|
|
1370
|
+
{
|
|
1371
|
+
object: 'feature_flag',
|
|
1372
|
+
id: 'flag_01EHQMYV6MBK39QC5PZXHY59C6',
|
|
1373
|
+
name: 'Beta Features',
|
|
1374
|
+
slug: 'beta-features',
|
|
1375
|
+
description: null,
|
|
1376
|
+
createdAt: '2024-01-01T00:00:00.000Z',
|
|
1377
|
+
updatedAt: '2024-01-01T00:00:00.000Z',
|
|
1378
|
+
},
|
|
1379
|
+
{
|
|
1380
|
+
object: 'feature_flag',
|
|
1381
|
+
id: 'flag_01EHQMYV6MBK39QC5PZXHY59C7',
|
|
1382
|
+
name: 'Premium Support',
|
|
1383
|
+
slug: 'premium-support',
|
|
1384
|
+
description: 'Access to premium support features',
|
|
1385
|
+
createdAt: '2024-01-01T00:00:00.000Z',
|
|
1386
|
+
updatedAt: '2024-01-01T00:00:00.000Z',
|
|
1387
|
+
},
|
|
1388
|
+
]);
|
|
1389
|
+
}));
|
|
1390
|
+
describe('with the before option', () => {
|
|
1391
|
+
it('forms the proper request to the API', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1392
|
+
(0, test_utils_1.fetchOnce)(list_user_feature_flags_json_1.default);
|
|
1393
|
+
const { data } = yield workos.userManagement.listUserFeatureFlags({
|
|
1394
|
+
userId,
|
|
1395
|
+
before: 'flag_before_id',
|
|
1396
|
+
});
|
|
1397
|
+
expect((0, test_utils_1.fetchSearchParams)()).toEqual({
|
|
1398
|
+
before: 'flag_before_id',
|
|
1399
|
+
order: 'desc',
|
|
1400
|
+
});
|
|
1401
|
+
expect((0, test_utils_1.fetchURL)()).toContain(`/user_management/users/${userId}/feature-flags`);
|
|
1402
|
+
expect(data).toHaveLength(3);
|
|
1403
|
+
}));
|
|
1404
|
+
});
|
|
1405
|
+
describe('with the after option', () => {
|
|
1406
|
+
it('forms the proper request to the API', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1407
|
+
(0, test_utils_1.fetchOnce)(list_user_feature_flags_json_1.default);
|
|
1408
|
+
const { data } = yield workos.userManagement.listUserFeatureFlags({
|
|
1409
|
+
userId,
|
|
1410
|
+
after: 'flag_after_id',
|
|
1411
|
+
});
|
|
1412
|
+
expect((0, test_utils_1.fetchSearchParams)()).toEqual({
|
|
1413
|
+
after: 'flag_after_id',
|
|
1414
|
+
order: 'desc',
|
|
1415
|
+
});
|
|
1416
|
+
expect((0, test_utils_1.fetchURL)()).toContain(`/user_management/users/${userId}/feature-flags`);
|
|
1417
|
+
expect(data).toHaveLength(3);
|
|
1418
|
+
}));
|
|
1419
|
+
});
|
|
1420
|
+
describe('with the limit option', () => {
|
|
1421
|
+
it('forms the proper request to the API', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1422
|
+
(0, test_utils_1.fetchOnce)(list_user_feature_flags_json_1.default);
|
|
1423
|
+
const { data } = yield workos.userManagement.listUserFeatureFlags({
|
|
1424
|
+
userId,
|
|
1425
|
+
limit: 3,
|
|
1426
|
+
});
|
|
1427
|
+
expect((0, test_utils_1.fetchSearchParams)()).toEqual({
|
|
1428
|
+
limit: '3',
|
|
1429
|
+
order: 'desc',
|
|
1430
|
+
});
|
|
1431
|
+
expect((0, test_utils_1.fetchURL)()).toContain(`/user_management/users/${userId}/feature-flags`);
|
|
1432
|
+
expect(data).toHaveLength(3);
|
|
1433
|
+
}));
|
|
1434
|
+
});
|
|
1435
|
+
});
|
|
1334
1436
|
describe('listSessions', () => {
|
|
1335
1437
|
it('sends a listSessions request', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1336
1438
|
(0, test_utils_1.fetchOnce)(list_sessions_json_1.default);
|
package/lib/workos.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GetOptions, PostOptions, PutOptions, WorkOSOptions } from './common/interfaces';
|
|
2
|
+
import { ApiKeys } from './api-keys/api-keys';
|
|
2
3
|
import { DirectorySync } from './directory-sync/directory-sync';
|
|
3
4
|
import { Events } from './events/events';
|
|
4
5
|
import { Organizations } from './organizations/organizations';
|
|
@@ -24,6 +25,7 @@ export declare class WorkOS {
|
|
|
24
25
|
readonly client: HttpClient;
|
|
25
26
|
readonly clientId?: string;
|
|
26
27
|
readonly actions: Actions;
|
|
28
|
+
readonly apiKeys: ApiKeys;
|
|
27
29
|
readonly auditLogs: AuditLogs;
|
|
28
30
|
readonly directorySync: DirectorySync;
|
|
29
31
|
readonly organizations: Organizations;
|
package/lib/workos.js
CHANGED
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.WorkOS = void 0;
|
|
13
13
|
const exceptions_1 = require("./common/exceptions");
|
|
14
|
+
const api_keys_1 = require("./api-keys/api-keys");
|
|
14
15
|
const directory_sync_1 = require("./directory-sync/directory-sync");
|
|
15
16
|
const events_1 = require("./events/events");
|
|
16
17
|
const organizations_1 = require("./organizations/organizations");
|
|
@@ -32,7 +33,7 @@ const actions_1 = require("./actions/actions");
|
|
|
32
33
|
const vault_1 = require("./vault/vault");
|
|
33
34
|
const conflict_exception_1 = require("./common/exceptions/conflict.exception");
|
|
34
35
|
const parse_error_1 = require("./common/exceptions/parse-error");
|
|
35
|
-
const VERSION = '7.
|
|
36
|
+
const VERSION = '7.72.0';
|
|
36
37
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
37
38
|
const HEADER_AUTHORIZATION = 'Authorization';
|
|
38
39
|
const HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
|
|
@@ -41,6 +42,7 @@ class WorkOS {
|
|
|
41
42
|
constructor(key, options = {}) {
|
|
42
43
|
this.key = key;
|
|
43
44
|
this.options = options;
|
|
45
|
+
this.apiKeys = new api_keys_1.ApiKeys(this);
|
|
44
46
|
this.auditLogs = new audit_logs_1.AuditLogs(this);
|
|
45
47
|
this.directorySync = new directory_sync_1.DirectorySync(this);
|
|
46
48
|
this.organizations = new organizations_1.Organizations(this);
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "7.
|
|
2
|
+
"version": "7.72.0",
|
|
3
3
|
"name": "@workos-inc/node",
|
|
4
4
|
"author": "WorkOS",
|
|
5
5
|
"description": "A Node wrapper for the WorkOS API",
|
|
@@ -65,6 +65,10 @@
|
|
|
65
65
|
"import": "./lib/index.worker.js",
|
|
66
66
|
"default": "./lib/index.worker.js"
|
|
67
67
|
},
|
|
68
|
+
"convex": {
|
|
69
|
+
"import": "./lib/index.worker.js",
|
|
70
|
+
"default": "./lib/index.worker.js"
|
|
71
|
+
},
|
|
68
72
|
"default": {
|
|
69
73
|
"import": "./lib/index.js",
|
|
70
74
|
"default": "./lib/index.js"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|