@workos-inc/node 7.50.1 → 7.51.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/common/utils/pagination.d.ts +1 -1
- package/lib/fga/fga.d.ts +2 -1
- package/lib/fga/fga.js +3 -1
- package/lib/fga/fga.spec.js +144 -0
- package/lib/fga/interfaces/check.interface.d.ts +4 -0
- package/lib/fga/interfaces/check.interface.js +1 -0
- package/lib/fga/interfaces/list.interface.d.ts +8 -0
- package/lib/fga/interfaces/list.interface.js +2 -0
- package/lib/fga/interfaces/warning.interface.d.ts +9 -0
- package/lib/fga/interfaces/warning.interface.js +2 -0
- package/lib/fga/serializers/index.d.ts +1 -0
- package/lib/fga/serializers/index.js +1 -0
- package/lib/fga/serializers/list.serializer.d.ts +5 -0
- package/lib/fga/serializers/list.serializer.js +10 -0
- package/lib/fga/serializers/query-result.serializer.d.ts +5 -0
- package/lib/fga/utils/fetch-and-deserialize-list.d.ts +5 -0
- package/lib/fga/utils/fetch-and-deserialize-list.js +18 -0
- package/lib/fga/utils/fga-paginatable.d.ts +9 -0
- package/lib/fga/utils/fga-paginatable.js +13 -0
- package/lib/user-management/interfaces/update-user-options.interface.d.ts +2 -0
- package/lib/user-management/serializers/update-user-options.serializer.js +2 -1
- package/lib/workos.js +1 -1
- package/package.json +1 -1
package/lib/fga/fga.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { WorkOS } from '../workos';
|
|
2
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
|
+
import { FgaPaginatable } from './utils/fga-paginatable';
|
|
4
5
|
export declare class FGA {
|
|
5
6
|
private readonly workos;
|
|
6
7
|
constructor(workos: WorkOS);
|
|
@@ -15,5 +16,5 @@ export declare class FGA {
|
|
|
15
16
|
writeWarrant(options: WriteWarrantOptions): Promise<WarrantToken>;
|
|
16
17
|
batchWriteWarrants(options: WriteWarrantOptions[]): Promise<WarrantToken>;
|
|
17
18
|
listWarrants(options?: ListWarrantsOptions, requestOptions?: ListWarrantsRequestOptions): Promise<AutoPaginatable<Warrant>>;
|
|
18
|
-
query(options: QueryOptions, requestOptions?: QueryRequestOptions): Promise<
|
|
19
|
+
query(options: QueryOptions, requestOptions?: QueryRequestOptions): Promise<FgaPaginatable<QueryResult>>;
|
|
19
20
|
}
|
package/lib/fga/fga.js
CHANGED
|
@@ -15,6 +15,8 @@ const serializers_1 = require("./serializers");
|
|
|
15
15
|
const interface_check_1 = require("./utils/interface-check");
|
|
16
16
|
const pagination_1 = require("../common/utils/pagination");
|
|
17
17
|
const fetch_and_deserialize_1 = require("../common/utils/fetch-and-deserialize");
|
|
18
|
+
const fga_paginatable_1 = require("./utils/fga-paginatable");
|
|
19
|
+
const fetch_and_deserialize_list_1 = require("./utils/fetch-and-deserialize-list");
|
|
18
20
|
class FGA {
|
|
19
21
|
constructor(workos) {
|
|
20
22
|
this.workos = workos;
|
|
@@ -104,7 +106,7 @@ class FGA {
|
|
|
104
106
|
}
|
|
105
107
|
query(options, requestOptions = {}) {
|
|
106
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
-
return new
|
|
109
|
+
return new fga_paginatable_1.FgaPaginatable(yield (0, fetch_and_deserialize_list_1.fetchAndDeserializeFGAList)(this.workos, '/fga/v1/query', serializers_1.deserializeQueryResult, (0, serializers_1.serializeQueryOptions)(options), requestOptions), (params) => (0, fetch_and_deserialize_list_1.fetchAndDeserializeFGAList)(this.workos, '/fga/v1/query', serializers_1.deserializeQueryResult, params, requestOptions), (0, serializers_1.serializeQueryOptions)(options));
|
|
108
110
|
});
|
|
109
111
|
}
|
|
110
112
|
}
|
package/lib/fga/fga.spec.js
CHANGED
|
@@ -48,6 +48,56 @@ describe('FGA', () => {
|
|
|
48
48
|
warrantToken: 'abc',
|
|
49
49
|
});
|
|
50
50
|
}));
|
|
51
|
+
it('deserializes warnings in check response', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
+
(0, test_utils_1.fetchOnce)({
|
|
53
|
+
result: 'authorized',
|
|
54
|
+
is_implicit: false,
|
|
55
|
+
warrant_token: 'abc',
|
|
56
|
+
warnings: [
|
|
57
|
+
{
|
|
58
|
+
code: 'missing_context_keys',
|
|
59
|
+
message: 'Missing required context keys',
|
|
60
|
+
keys: ['tenant_id', 'region'],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
code: 'some_other_warning',
|
|
64
|
+
message: 'Some other warning message',
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
const checkResult = yield workos.fga.check({
|
|
69
|
+
checks: [
|
|
70
|
+
{
|
|
71
|
+
resource: {
|
|
72
|
+
resourceType: 'role',
|
|
73
|
+
resourceId: 'admin',
|
|
74
|
+
},
|
|
75
|
+
relation: 'member',
|
|
76
|
+
subject: {
|
|
77
|
+
resourceType: 'user',
|
|
78
|
+
resourceId: 'user_123',
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
});
|
|
83
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/fga/v1/check');
|
|
84
|
+
expect(checkResult).toMatchObject({
|
|
85
|
+
result: 'authorized',
|
|
86
|
+
isImplicit: false,
|
|
87
|
+
warrantToken: 'abc',
|
|
88
|
+
warnings: [
|
|
89
|
+
{
|
|
90
|
+
code: 'missing_context_keys',
|
|
91
|
+
message: 'Missing required context keys',
|
|
92
|
+
keys: ['tenant_id', 'region'],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
code: 'some_other_warning',
|
|
96
|
+
message: 'Some other warning message',
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
});
|
|
100
|
+
}));
|
|
51
101
|
});
|
|
52
102
|
describe('createResource', () => {
|
|
53
103
|
it('creates resource', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -606,6 +656,100 @@ describe('FGA', () => {
|
|
|
606
656
|
},
|
|
607
657
|
]);
|
|
608
658
|
}));
|
|
659
|
+
it('deserializes warnings in query response', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
660
|
+
(0, test_utils_1.fetchOnce)({
|
|
661
|
+
data: [
|
|
662
|
+
{
|
|
663
|
+
resource_type: 'role',
|
|
664
|
+
resource_id: 'admin',
|
|
665
|
+
warrant: {
|
|
666
|
+
resource_type: 'role',
|
|
667
|
+
resource_id: 'admin',
|
|
668
|
+
relation: 'member',
|
|
669
|
+
subject: {
|
|
670
|
+
resource_type: 'user',
|
|
671
|
+
resource_id: 'user_123',
|
|
672
|
+
},
|
|
673
|
+
},
|
|
674
|
+
is_implicit: false,
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
resource_type: 'role',
|
|
678
|
+
resource_id: 'manager',
|
|
679
|
+
warrant: {
|
|
680
|
+
resource_type: 'role',
|
|
681
|
+
resource_id: 'manager',
|
|
682
|
+
relation: 'member',
|
|
683
|
+
subject: {
|
|
684
|
+
resource_type: 'user',
|
|
685
|
+
resource_id: 'user_123',
|
|
686
|
+
},
|
|
687
|
+
},
|
|
688
|
+
is_implicit: true,
|
|
689
|
+
},
|
|
690
|
+
],
|
|
691
|
+
list_metadata: {
|
|
692
|
+
before: null,
|
|
693
|
+
after: null,
|
|
694
|
+
},
|
|
695
|
+
warnings: [
|
|
696
|
+
{
|
|
697
|
+
code: 'missing_context_keys',
|
|
698
|
+
message: 'Missing required context keys',
|
|
699
|
+
keys: ['tenant_id'],
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
code: 'some_other_warning',
|
|
703
|
+
message: 'Some other warning message',
|
|
704
|
+
},
|
|
705
|
+
],
|
|
706
|
+
});
|
|
707
|
+
const result = yield workos.fga.query({
|
|
708
|
+
q: 'select role where user:user_123 is member',
|
|
709
|
+
});
|
|
710
|
+
expect((0, test_utils_1.fetchURL)()).toContain('/fga/v1/query');
|
|
711
|
+
expect(result.data).toMatchObject([
|
|
712
|
+
{
|
|
713
|
+
resourceType: 'role',
|
|
714
|
+
resourceId: 'admin',
|
|
715
|
+
warrant: {
|
|
716
|
+
resourceType: 'role',
|
|
717
|
+
resourceId: 'admin',
|
|
718
|
+
relation: 'member',
|
|
719
|
+
subject: {
|
|
720
|
+
resourceType: 'user',
|
|
721
|
+
resourceId: 'user_123',
|
|
722
|
+
},
|
|
723
|
+
},
|
|
724
|
+
isImplicit: false,
|
|
725
|
+
},
|
|
726
|
+
{
|
|
727
|
+
resourceType: 'role',
|
|
728
|
+
resourceId: 'manager',
|
|
729
|
+
warrant: {
|
|
730
|
+
resourceType: 'role',
|
|
731
|
+
resourceId: 'manager',
|
|
732
|
+
relation: 'member',
|
|
733
|
+
subject: {
|
|
734
|
+
resourceType: 'user',
|
|
735
|
+
resourceId: 'user_123',
|
|
736
|
+
},
|
|
737
|
+
},
|
|
738
|
+
isImplicit: true,
|
|
739
|
+
},
|
|
740
|
+
]);
|
|
741
|
+
expect(result.warnings).toMatchObject([
|
|
742
|
+
{
|
|
743
|
+
code: 'missing_context_keys',
|
|
744
|
+
message: 'Missing required context keys',
|
|
745
|
+
keys: ['tenant_id'],
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
code: 'some_other_warning',
|
|
749
|
+
message: 'Some other warning message',
|
|
750
|
+
},
|
|
751
|
+
]);
|
|
752
|
+
}));
|
|
609
753
|
it('sends correct params and options', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
610
754
|
(0, test_utils_1.fetchOnce)({
|
|
611
755
|
data: [
|
|
@@ -2,6 +2,7 @@ import { ResourceInterface, ResourceOptions } from './resource.interface';
|
|
|
2
2
|
import { PolicyContext, SerializedSubject, Subject } from './warrant.interface';
|
|
3
3
|
import { CheckOp } from './check-op.enum';
|
|
4
4
|
import { PostOptions } from '../../common/interfaces';
|
|
5
|
+
import { Warning } from './warning.interface';
|
|
5
6
|
export interface CheckWarrantOptions {
|
|
6
7
|
resource: ResourceInterface | ResourceOptions;
|
|
7
8
|
relation: string;
|
|
@@ -39,6 +40,7 @@ export interface CheckResultResponse {
|
|
|
39
40
|
is_implicit: boolean;
|
|
40
41
|
warrant_token: string;
|
|
41
42
|
debug_info?: DebugInfoResponse;
|
|
43
|
+
warnings?: Warning[];
|
|
42
44
|
}
|
|
43
45
|
export interface DebugInfo {
|
|
44
46
|
processingTime: number;
|
|
@@ -67,12 +69,14 @@ export interface CheckResultInterface {
|
|
|
67
69
|
isImplicit: boolean;
|
|
68
70
|
warrantToken: string;
|
|
69
71
|
debugInfo?: DebugInfo;
|
|
72
|
+
warnings?: Warning[];
|
|
70
73
|
}
|
|
71
74
|
export declare class CheckResult implements CheckResultInterface {
|
|
72
75
|
result: string;
|
|
73
76
|
isImplicit: boolean;
|
|
74
77
|
warrantToken: string;
|
|
75
78
|
debugInfo?: DebugInfo;
|
|
79
|
+
warnings?: Warning[];
|
|
76
80
|
constructor(json: CheckResultResponse);
|
|
77
81
|
isAuthorized(): boolean;
|
|
78
82
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { List, ListResponse } from '../../common/interfaces';
|
|
2
|
+
import { Warning } from './warning.interface';
|
|
3
|
+
export interface FGAListResponse<T> extends ListResponse<T> {
|
|
4
|
+
warnings?: Warning[];
|
|
5
|
+
}
|
|
6
|
+
export interface FGAList<T> extends List<T> {
|
|
7
|
+
warnings?: Warning[];
|
|
8
|
+
}
|
|
@@ -26,3 +26,4 @@ __exportStar(require("./resource.serializer"), exports);
|
|
|
26
26
|
__exportStar(require("./warrant-token.serializer"), exports);
|
|
27
27
|
__exportStar(require("./warrant.serializer"), exports);
|
|
28
28
|
__exportStar(require("./write-warrant-options.serializer"), exports);
|
|
29
|
+
__exportStar(require("./list.serializer"), exports);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FGAList } from '../interfaces/list.interface';
|
|
2
|
+
import { ListResponse } from '../../common/interfaces';
|
|
3
|
+
export declare const deserializeFGAList: <T, U>(response: ListResponse<T> & {
|
|
4
|
+
warnings?: any[] | undefined;
|
|
5
|
+
}, deserializeFn: (data: T) => U) => FGAList<U>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deserializeFGAList = void 0;
|
|
4
|
+
const deserializeFGAList = (response, deserializeFn) => ({
|
|
5
|
+
object: 'list',
|
|
6
|
+
data: response.data.map(deserializeFn),
|
|
7
|
+
listMetadata: response.list_metadata,
|
|
8
|
+
warnings: response.warnings,
|
|
9
|
+
});
|
|
10
|
+
exports.deserializeFGAList = deserializeFGAList;
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import { QueryResult, QueryResultResponse } from '../interfaces';
|
|
2
|
+
import { Warning } from '../interfaces/warning.interface';
|
|
3
|
+
import { ListResponse } from '../../common/interfaces';
|
|
4
|
+
export interface QueryResultListResponse extends ListResponse<QueryResultResponse> {
|
|
5
|
+
warnings?: Warning[];
|
|
6
|
+
}
|
|
2
7
|
export declare const deserializeQueryResult: (queryResult: QueryResultResponse) => QueryResult;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { WorkOS } from '../../workos';
|
|
2
|
+
import { FGAList } from '../interfaces/list.interface';
|
|
3
|
+
import { QueryRequestOptions } from '../interfaces';
|
|
4
|
+
import { PaginationOptions } from '../../common/interfaces';
|
|
5
|
+
export declare const fetchAndDeserializeFGAList: <T, U>(workos: WorkOS, endpoint: string, deserializeFn: (data: T) => U, options?: PaginationOptions, requestOptions?: QueryRequestOptions) => Promise<FGAList<U>>;
|
|
@@ -0,0 +1,18 @@
|
|
|
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.fetchAndDeserializeFGAList = void 0;
|
|
13
|
+
const list_serializer_1 = require("../serializers/list.serializer");
|
|
14
|
+
const fetchAndDeserializeFGAList = (workos, endpoint, deserializeFn, options, requestOptions) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
const { data: response } = yield workos.get(endpoint, Object.assign({ query: options }, requestOptions));
|
|
16
|
+
return (0, list_serializer_1.deserializeFGAList)(response, deserializeFn);
|
|
17
|
+
});
|
|
18
|
+
exports.fetchAndDeserializeFGAList = fetchAndDeserializeFGAList;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AutoPaginatable } from '../../common/utils/pagination';
|
|
2
|
+
import { FGAList } from '../interfaces/list.interface';
|
|
3
|
+
import { Warning } from '../interfaces/warning.interface';
|
|
4
|
+
import { PaginationOptions } from '../../common/interfaces';
|
|
5
|
+
export declare class FgaPaginatable<T> extends AutoPaginatable<T> {
|
|
6
|
+
protected list: FGAList<T>;
|
|
7
|
+
constructor(list: FGAList<T>, apiCall: (params: PaginationOptions) => Promise<FGAList<T>>, options?: PaginationOptions);
|
|
8
|
+
get warnings(): Warning[] | undefined;
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FgaPaginatable = void 0;
|
|
4
|
+
const pagination_1 = require("../../common/utils/pagination");
|
|
5
|
+
class FgaPaginatable extends pagination_1.AutoPaginatable {
|
|
6
|
+
constructor(list, apiCall, options) {
|
|
7
|
+
super(list, apiCall, options);
|
|
8
|
+
}
|
|
9
|
+
get warnings() {
|
|
10
|
+
return this.list.warnings;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.FgaPaginatable = FgaPaginatable;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PasswordHashType } from './password-hash-type.interface';
|
|
2
2
|
export interface UpdateUserOptions {
|
|
3
3
|
userId: string;
|
|
4
|
+
email?: string;
|
|
4
5
|
firstName?: string;
|
|
5
6
|
lastName?: string;
|
|
6
7
|
emailVerified?: boolean;
|
|
@@ -11,6 +12,7 @@ export interface UpdateUserOptions {
|
|
|
11
12
|
metadata?: Record<string, string | null>;
|
|
12
13
|
}
|
|
13
14
|
export interface SerializedUpdateUserOptions {
|
|
15
|
+
email?: string;
|
|
14
16
|
first_name?: string;
|
|
15
17
|
last_name?: string;
|
|
16
18
|
email_verified?: boolean;
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.serializeUpdateUserOptions = void 0;
|
|
4
4
|
const serializeUpdateUserOptions = (options) => ({
|
|
5
|
+
email: options.email,
|
|
6
|
+
email_verified: options.emailVerified,
|
|
5
7
|
first_name: options.firstName,
|
|
6
8
|
last_name: options.lastName,
|
|
7
|
-
email_verified: options.emailVerified,
|
|
8
9
|
password: options.password,
|
|
9
10
|
password_hash: options.passwordHash,
|
|
10
11
|
password_hash_type: options.passwordHashType,
|
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.
|
|
34
|
+
const VERSION = '7.51.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