@workos-inc/node 7.25.1 → 7.27.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/fga/fga.d.ts +2 -1
- package/lib/fga/fga.js +6 -0
- package/lib/fga/fga.spec.js +126 -0
- package/lib/fga/interfaces/check-op.enum.d.ts +1 -2
- package/lib/fga/interfaces/check-op.enum.js +0 -1
- package/lib/fga/interfaces/check.interface.d.ts +5 -0
- package/lib/fga/interfaces/index.d.ts +1 -0
- package/lib/fga/interfaces/index.js +1 -0
- package/lib/fga/interfaces/resource-op.enum.d.ts +4 -0
- package/lib/fga/interfaces/resource-op.enum.js +8 -0
- package/lib/fga/interfaces/resource.interface.d.ts +8 -0
- package/lib/fga/serializers/check-options.serializer.d.ts +2 -2
- package/lib/fga/serializers/check-options.serializer.js +1 -2
- package/lib/fga/serializers/resource.serializer.d.ts +2 -1
- package/lib/fga/serializers/resource.serializer.js +5 -1
- package/lib/user-management/interfaces/authorization-url-options.interface.d.ts +1 -0
- package/lib/user-management/user-management.d.ts +1 -1
- package/lib/user-management/user-management.js +2 -1
- package/lib/workos.js +1 -1
- package/package.json +1 -1
package/lib/fga/fga.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WorkOS } from '../workos';
|
|
2
|
-
import { Resource, CheckBatchOptions, CheckOptions, CheckRequestOptions, CheckResult, CreateResourceOptions, DeleteResourceOptions, ListResourcesOptions, ListWarrantsRequestOptions, ListWarrantsOptions, QueryOptions, QueryRequestOptions, QueryResult, ResourceInterface, ResourceOptions, UpdateResourceOptions, WriteWarrantOptions, Warrant, WarrantToken } from './interfaces';
|
|
2
|
+
import { Resource, CheckBatchOptions, CheckOptions, CheckRequestOptions, CheckResult, CreateResourceOptions, DeleteResourceOptions, ListResourcesOptions, ListWarrantsRequestOptions, ListWarrantsOptions, QueryOptions, QueryRequestOptions, QueryResult, ResourceInterface, ResourceOptions, UpdateResourceOptions, WriteWarrantOptions, Warrant, WarrantToken, BatchWriteResourcesOptions } from './interfaces';
|
|
3
3
|
import { AutoPaginatable } from '../common/utils/pagination';
|
|
4
4
|
export declare class FGA {
|
|
5
5
|
private readonly workos;
|
|
@@ -11,6 +11,7 @@ export declare class FGA {
|
|
|
11
11
|
listResources(options?: ListResourcesOptions): Promise<AutoPaginatable<Resource>>;
|
|
12
12
|
updateResource(options: UpdateResourceOptions): Promise<Resource>;
|
|
13
13
|
deleteResource(resource: DeleteResourceOptions): Promise<void>;
|
|
14
|
+
batchWriteResources(options: BatchWriteResourcesOptions): Promise<Resource[]>;
|
|
14
15
|
writeWarrant(options: WriteWarrantOptions): Promise<WarrantToken>;
|
|
15
16
|
batchWriteWarrants(options: WriteWarrantOptions[]): Promise<WarrantToken>;
|
|
16
17
|
listWarrants(options?: ListWarrantsOptions, requestOptions?: ListWarrantsRequestOptions): Promise<AutoPaginatable<Warrant>>;
|
package/lib/fga/fga.js
CHANGED
|
@@ -79,6 +79,12 @@ class FGA {
|
|
|
79
79
|
yield this.workos.delete(`/fga/v1/resources/${resourceType}/${resourceId}`);
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
|
+
batchWriteResources(options) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
const { data } = yield this.workos.post('/fga/v1/resources/batch', options);
|
|
85
|
+
return (0, serializers_1.deserializeBatchWriteResourcesResponse)(data);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
82
88
|
writeWarrant(options) {
|
|
83
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
84
90
|
const { data } = yield this.workos.post('/fga/v1/warrants', (0, serializers_1.serializeWriteWarrantOptions)(options));
|
package/lib/fga/fga.spec.js
CHANGED
|
@@ -178,6 +178,132 @@ describe('FGA', () => {
|
|
|
178
178
|
expect(response).toBeUndefined();
|
|
179
179
|
}));
|
|
180
180
|
});
|
|
181
|
+
describe('batchWriteResources', () => {
|
|
182
|
+
it('batch create resources', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
183
|
+
(0, test_utils_1.fetchOnce)({
|
|
184
|
+
data: [
|
|
185
|
+
{
|
|
186
|
+
resource_type: 'role',
|
|
187
|
+
resource_id: 'admin',
|
|
188
|
+
meta: {
|
|
189
|
+
description: 'The admin role',
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
resource_type: 'role',
|
|
194
|
+
resource_id: 'manager',
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
resource_type: 'role',
|
|
198
|
+
resource_id: 'employee',
|
|
199
|
+
},
|
|
200
|
+
],
|
|
201
|
+
});
|
|
202
|
+
const createdResources = yield workos.fga.batchWriteResources({
|
|
203
|
+
op: interfaces_1.ResourceOp.Create,
|
|
204
|
+
resources: [
|
|
205
|
+
{
|
|
206
|
+
resource: {
|
|
207
|
+
resourceType: 'role',
|
|
208
|
+
resourceId: 'admin',
|
|
209
|
+
},
|
|
210
|
+
meta: {
|
|
211
|
+
description: 'The admin role',
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
resource: {
|
|
216
|
+
resourceType: 'role',
|
|
217
|
+
resourceId: 'manager',
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
resource: {
|
|
222
|
+
resourceType: 'role',
|
|
223
|
+
resourceId: 'employee',
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
});
|
|
228
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/fga/v1/resources/batch');
|
|
229
|
+
expect(createdResources).toMatchObject([
|
|
230
|
+
{
|
|
231
|
+
resourceType: 'role',
|
|
232
|
+
resourceId: 'admin',
|
|
233
|
+
meta: {
|
|
234
|
+
description: 'The admin role',
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
resourceType: 'role',
|
|
239
|
+
resourceId: 'manager',
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
resourceType: 'role',
|
|
243
|
+
resourceId: 'employee',
|
|
244
|
+
},
|
|
245
|
+
]);
|
|
246
|
+
}));
|
|
247
|
+
it('batch delete resources', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
248
|
+
(0, test_utils_1.fetchOnce)({
|
|
249
|
+
data: [
|
|
250
|
+
{
|
|
251
|
+
resource_type: 'role',
|
|
252
|
+
resource_id: 'admin',
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
resource_type: 'role',
|
|
256
|
+
resource_id: 'manager',
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
resource_type: 'role',
|
|
260
|
+
resource_id: 'employee',
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
});
|
|
264
|
+
const deletedResources = yield workos.fga.batchWriteResources({
|
|
265
|
+
op: interfaces_1.ResourceOp.Delete,
|
|
266
|
+
resources: [
|
|
267
|
+
{
|
|
268
|
+
resource: {
|
|
269
|
+
resourceType: 'role',
|
|
270
|
+
resourceId: 'admin',
|
|
271
|
+
},
|
|
272
|
+
meta: {
|
|
273
|
+
description: 'The admin role',
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
resource: {
|
|
278
|
+
resourceType: 'role',
|
|
279
|
+
resourceId: 'manager',
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
resource: {
|
|
284
|
+
resourceType: 'role',
|
|
285
|
+
resourceId: 'employee',
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
],
|
|
289
|
+
});
|
|
290
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/fga/v1/resources/batch');
|
|
291
|
+
expect(deletedResources).toMatchObject([
|
|
292
|
+
{
|
|
293
|
+
resourceType: 'role',
|
|
294
|
+
resourceId: 'admin',
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
resourceType: 'role',
|
|
298
|
+
resourceId: 'manager',
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
resourceType: 'role',
|
|
302
|
+
resourceId: 'employee',
|
|
303
|
+
},
|
|
304
|
+
]);
|
|
305
|
+
}));
|
|
306
|
+
});
|
|
181
307
|
describe('writeWarrant', () => {
|
|
182
308
|
it('should create warrant with no op', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
183
309
|
(0, test_utils_1.fetchOnce)({
|
|
@@ -29,6 +29,11 @@ export interface SerializedCheckOptions {
|
|
|
29
29
|
checks: SerializedCheckWarrantOptions[];
|
|
30
30
|
debug?: boolean;
|
|
31
31
|
}
|
|
32
|
+
export interface SerializedCheckBatchOptions {
|
|
33
|
+
op: 'batch';
|
|
34
|
+
checks: SerializedCheckWarrantOptions[];
|
|
35
|
+
debug?: boolean;
|
|
36
|
+
}
|
|
32
37
|
export interface CheckResultResponse {
|
|
33
38
|
result: string;
|
|
34
39
|
is_implicit: boolean;
|
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./check-op.enum"), exports);
|
|
18
18
|
__exportStar(require("./check.interface"), exports);
|
|
19
19
|
__exportStar(require("./query.interface"), exports);
|
|
20
|
+
__exportStar(require("./resource-op.enum"), exports);
|
|
20
21
|
__exportStar(require("./resource.interface"), exports);
|
|
21
22
|
__exportStar(require("./warrant-op.enum"), exports);
|
|
22
23
|
__exportStar(require("./warrant-token.interface"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResourceOp = void 0;
|
|
4
|
+
var ResourceOp;
|
|
5
|
+
(function (ResourceOp) {
|
|
6
|
+
ResourceOp["Create"] = "create";
|
|
7
|
+
ResourceOp["Delete"] = "delete";
|
|
8
|
+
})(ResourceOp || (exports.ResourceOp = ResourceOp = {}));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PaginationOptions } from '../../common/interfaces/pagination-options.interface';
|
|
2
|
+
import { ResourceOp } from './resource-op.enum';
|
|
2
3
|
export interface ResourceInterface {
|
|
3
4
|
getResourceType(): string;
|
|
4
5
|
getResourceId(): string;
|
|
@@ -58,3 +59,10 @@ export interface ResourceResponse {
|
|
|
58
59
|
[key: string]: any;
|
|
59
60
|
};
|
|
60
61
|
}
|
|
62
|
+
export interface BatchWriteResourcesOptions {
|
|
63
|
+
op: ResourceOp;
|
|
64
|
+
resources: CreateResourceOptions[] | DeleteResourceOptions[];
|
|
65
|
+
}
|
|
66
|
+
export interface BatchWriteResourcesResponse {
|
|
67
|
+
data: ResourceResponse[];
|
|
68
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CheckBatchOptions, CheckOptions, DecisionTreeNode, DecisionTreeNodeResponse, SerializedCheckOptions } from '../interfaces';
|
|
1
|
+
import { CheckBatchOptions, CheckOptions, DecisionTreeNode, DecisionTreeNodeResponse, SerializedCheckBatchOptions, SerializedCheckOptions } from '../interfaces';
|
|
2
2
|
export declare const serializeCheckOptions: (options: CheckOptions) => SerializedCheckOptions;
|
|
3
|
-
export declare const serializeCheckBatchOptions: (options: CheckBatchOptions) =>
|
|
3
|
+
export declare const serializeCheckBatchOptions: (options: CheckBatchOptions) => SerializedCheckBatchOptions;
|
|
4
4
|
export declare const deserializeDecisionTreeNode: (response: DecisionTreeNodeResponse) => DecisionTreeNode;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.deserializeDecisionTreeNode = exports.serializeCheckBatchOptions = exports.serializeCheckOptions = void 0;
|
|
4
|
-
const interfaces_1 = require("../interfaces");
|
|
5
4
|
const interface_check_1 = require("../utils/interface-check");
|
|
6
5
|
const serializeCheckOptions = (options) => ({
|
|
7
6
|
op: options.op,
|
|
@@ -10,7 +9,7 @@ const serializeCheckOptions = (options) => ({
|
|
|
10
9
|
});
|
|
11
10
|
exports.serializeCheckOptions = serializeCheckOptions;
|
|
12
11
|
const serializeCheckBatchOptions = (options) => ({
|
|
13
|
-
op:
|
|
12
|
+
op: 'batch',
|
|
14
13
|
checks: options.checks.map(serializeCheckWarrantOptions),
|
|
15
14
|
debug: options.debug,
|
|
16
15
|
});
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { Resource, ResourceResponse } from '../interfaces';
|
|
1
|
+
import { BatchWriteResourcesResponse, Resource, ResourceResponse } from '../interfaces';
|
|
2
2
|
export declare const deserializeResource: (response: ResourceResponse) => Resource;
|
|
3
|
+
export declare const deserializeBatchWriteResourcesResponse: (response: BatchWriteResourcesResponse) => Resource[];
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deserializeResource = void 0;
|
|
3
|
+
exports.deserializeBatchWriteResourcesResponse = exports.deserializeResource = void 0;
|
|
4
4
|
const deserializeResource = (response) => ({
|
|
5
5
|
resourceType: response.resource_type,
|
|
6
6
|
resourceId: response.resource_id,
|
|
7
7
|
meta: response.meta,
|
|
8
8
|
});
|
|
9
9
|
exports.deserializeResource = deserializeResource;
|
|
10
|
+
const deserializeBatchWriteResourcesResponse = (response) => {
|
|
11
|
+
return response.data.map((resource) => (0, exports.deserializeResource)(resource));
|
|
12
|
+
};
|
|
13
|
+
exports.deserializeBatchWriteResourcesResponse = deserializeBatchWriteResourcesResponse;
|
|
@@ -102,7 +102,7 @@ export declare class UserManagement {
|
|
|
102
102
|
sendInvitation(payload: SendInvitationOptions): Promise<Invitation>;
|
|
103
103
|
revokeInvitation(invitationId: string): Promise<Invitation>;
|
|
104
104
|
revokeSession(payload: RevokeSessionOptions): Promise<void>;
|
|
105
|
-
getAuthorizationUrl({ connectionId, codeChallenge, codeChallengeMethod, clientId, domainHint, loginHint, organizationId, provider, redirectUri, state, screenHint, }: AuthorizationURLOptions): string;
|
|
105
|
+
getAuthorizationUrl({ connectionId, codeChallenge, codeChallengeMethod, context, clientId, domainHint, loginHint, organizationId, provider, redirectUri, state, screenHint, }: AuthorizationURLOptions): string;
|
|
106
106
|
getLogoutUrl({ sessionId }: {
|
|
107
107
|
sessionId: string;
|
|
108
108
|
}): string;
|
|
@@ -498,7 +498,7 @@ class UserManagement {
|
|
|
498
498
|
yield this.workos.post('/user_management/sessions/revoke', (0, revoke_session_options_interface_1.serializeRevokeSessionOptions)(payload));
|
|
499
499
|
});
|
|
500
500
|
}
|
|
501
|
-
getAuthorizationUrl({ connectionId, codeChallenge, codeChallengeMethod, clientId, domainHint, loginHint, organizationId, provider, redirectUri, state, screenHint, }) {
|
|
501
|
+
getAuthorizationUrl({ connectionId, codeChallenge, codeChallengeMethod, context, clientId, domainHint, loginHint, organizationId, provider, redirectUri, state, screenHint, }) {
|
|
502
502
|
if (!provider && !connectionId && !organizationId) {
|
|
503
503
|
throw new TypeError(`Incomplete arguments. Need to specify either a 'connectionId', 'organizationId', or 'provider'.`);
|
|
504
504
|
}
|
|
@@ -509,6 +509,7 @@ class UserManagement {
|
|
|
509
509
|
connection_id: connectionId,
|
|
510
510
|
code_challenge: codeChallenge,
|
|
511
511
|
code_challenge_method: codeChallengeMethod,
|
|
512
|
+
context,
|
|
512
513
|
organization_id: organizationId,
|
|
513
514
|
domain_hint: domainHint,
|
|
514
515
|
login_hint: loginHint,
|
package/lib/workos.js
CHANGED
|
@@ -27,7 +27,7 @@ const bad_request_exception_1 = require("./common/exceptions/bad-request.excepti
|
|
|
27
27
|
const http_client_1 = require("./common/net/http-client");
|
|
28
28
|
const subtle_crypto_provider_1 = require("./common/crypto/subtle-crypto-provider");
|
|
29
29
|
const fetch_client_1 = require("./common/net/fetch-client");
|
|
30
|
-
const VERSION = '7.
|
|
30
|
+
const VERSION = '7.27.0';
|
|
31
31
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
32
32
|
const HEADER_AUTHORIZATION = 'Authorization';
|
|
33
33
|
const HEADER_IDEMPOTENCY_KEY = 'Idempotency-Key';
|
package/package.json
CHANGED