@dfns/sdk 0.2.4 → 0.3.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/dfnsError.d.ts +5 -0
- package/dfnsError.js +15 -1
- package/generated/permissions/client.js +8 -8
- package/generated/permissions/delegatedClient.js +13 -13
- package/generated/permissions/types.d.ts +33 -120
- package/generated/policies/types.d.ts +322 -369
- package/generated/wallets/types.d.ts +100 -3
- package/package.json +1 -1
- package/types/permissions.d.ts +1 -0
- package/types/permissions.js +17 -0
- package/utils/fetch.js +14 -2
package/dfnsError.d.ts
CHANGED
|
@@ -2,4 +2,9 @@ export declare class DfnsError extends Error {
|
|
|
2
2
|
httpStatus: number;
|
|
3
3
|
context?: unknown;
|
|
4
4
|
constructor(httpStatus: number, message: string, context?: unknown);
|
|
5
|
+
toString(): string;
|
|
6
|
+
}
|
|
7
|
+
export declare class PolicyPendingError extends DfnsError {
|
|
8
|
+
static HTTP_ACCEPTED: number;
|
|
9
|
+
constructor(context: unknown);
|
|
5
10
|
}
|
package/dfnsError.js
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DfnsError = void 0;
|
|
3
|
+
exports.PolicyPendingError = exports.DfnsError = void 0;
|
|
4
4
|
class DfnsError extends Error {
|
|
5
5
|
constructor(httpStatus, message, context) {
|
|
6
6
|
super(message);
|
|
7
7
|
this.httpStatus = httpStatus;
|
|
8
8
|
this.context = context;
|
|
9
9
|
}
|
|
10
|
+
toString() {
|
|
11
|
+
return JSON.stringify({
|
|
12
|
+
httpStatus: this.httpStatus,
|
|
13
|
+
message: this.message,
|
|
14
|
+
...(this.context && this.context),
|
|
15
|
+
}, null, 2);
|
|
16
|
+
}
|
|
10
17
|
}
|
|
11
18
|
exports.DfnsError = DfnsError;
|
|
19
|
+
class PolicyPendingError extends DfnsError {
|
|
20
|
+
constructor(context) {
|
|
21
|
+
super(PolicyPendingError.HTTP_ACCEPTED, 'Operation triggered a policy pending approval', context);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.PolicyPendingError = PolicyPendingError;
|
|
25
|
+
PolicyPendingError.HTTP_ACCEPTED = 202;
|
|
@@ -8,7 +8,7 @@ class PermissionsClient {
|
|
|
8
8
|
this.apiOptions = apiOptions;
|
|
9
9
|
}
|
|
10
10
|
async archivePermission(request) {
|
|
11
|
-
const path = (0, url_1.buildPathAndQuery)('/
|
|
11
|
+
const path = (0, url_1.buildPathAndQuery)('/permissions/:permissionId/archive', {
|
|
12
12
|
path: request ?? {},
|
|
13
13
|
query: {},
|
|
14
14
|
});
|
|
@@ -20,7 +20,7 @@ class PermissionsClient {
|
|
|
20
20
|
return response.json();
|
|
21
21
|
}
|
|
22
22
|
async createAssignment(request) {
|
|
23
|
-
const path = (0, url_1.buildPathAndQuery)('/
|
|
23
|
+
const path = (0, url_1.buildPathAndQuery)('/permissions/:permissionId/assignments', {
|
|
24
24
|
path: request ?? {},
|
|
25
25
|
query: {},
|
|
26
26
|
});
|
|
@@ -32,7 +32,7 @@ class PermissionsClient {
|
|
|
32
32
|
return response.json();
|
|
33
33
|
}
|
|
34
34
|
async createPermission(request) {
|
|
35
|
-
const path = (0, url_1.buildPathAndQuery)('/
|
|
35
|
+
const path = (0, url_1.buildPathAndQuery)('/permissions', {
|
|
36
36
|
path: request ?? {},
|
|
37
37
|
query: {},
|
|
38
38
|
});
|
|
@@ -44,7 +44,7 @@ class PermissionsClient {
|
|
|
44
44
|
return response.json();
|
|
45
45
|
}
|
|
46
46
|
async deleteAssignment(request) {
|
|
47
|
-
const path = (0, url_1.buildPathAndQuery)('/
|
|
47
|
+
const path = (0, url_1.buildPathAndQuery)('/permissions/:permissionId/assignments/:assignmentId', {
|
|
48
48
|
path: request ?? {},
|
|
49
49
|
query: {},
|
|
50
50
|
});
|
|
@@ -56,7 +56,7 @@ class PermissionsClient {
|
|
|
56
56
|
return response.json();
|
|
57
57
|
}
|
|
58
58
|
async getPermission(request) {
|
|
59
|
-
const path = (0, url_1.buildPathAndQuery)('/
|
|
59
|
+
const path = (0, url_1.buildPathAndQuery)('/permissions/:permissionId', {
|
|
60
60
|
path: request ?? {},
|
|
61
61
|
query: {},
|
|
62
62
|
});
|
|
@@ -67,7 +67,7 @@ class PermissionsClient {
|
|
|
67
67
|
return response.json();
|
|
68
68
|
}
|
|
69
69
|
async listAssignments(request) {
|
|
70
|
-
const path = (0, url_1.buildPathAndQuery)('/
|
|
70
|
+
const path = (0, url_1.buildPathAndQuery)('/permissions/:permissionId/assignments', {
|
|
71
71
|
path: request ?? {},
|
|
72
72
|
query: {},
|
|
73
73
|
});
|
|
@@ -78,7 +78,7 @@ class PermissionsClient {
|
|
|
78
78
|
return response.json();
|
|
79
79
|
}
|
|
80
80
|
async listPermissions(request) {
|
|
81
|
-
const path = (0, url_1.buildPathAndQuery)('/
|
|
81
|
+
const path = (0, url_1.buildPathAndQuery)('/permissions', {
|
|
82
82
|
path: request ?? {},
|
|
83
83
|
query: request?.query ?? {},
|
|
84
84
|
});
|
|
@@ -89,7 +89,7 @@ class PermissionsClient {
|
|
|
89
89
|
return response.json();
|
|
90
90
|
}
|
|
91
91
|
async updatePermission(request) {
|
|
92
|
-
const path = (0, url_1.buildPathAndQuery)('/
|
|
92
|
+
const path = (0, url_1.buildPathAndQuery)('/permissions/:permissionId', {
|
|
93
93
|
path: request ?? {},
|
|
94
94
|
query: {},
|
|
95
95
|
});
|
|
@@ -9,7 +9,7 @@ class DelegatedPermissionsClient {
|
|
|
9
9
|
this.apiOptions = apiOptions;
|
|
10
10
|
}
|
|
11
11
|
async archivePermissionInit(request) {
|
|
12
|
-
const path = (0, url_1.buildPathAndQuery)('/
|
|
12
|
+
const path = (0, url_1.buildPathAndQuery)('/permissions/:permissionId/archive', {
|
|
13
13
|
path: request ?? {},
|
|
14
14
|
query: {},
|
|
15
15
|
});
|
|
@@ -22,7 +22,7 @@ class DelegatedPermissionsClient {
|
|
|
22
22
|
return challenge;
|
|
23
23
|
}
|
|
24
24
|
async archivePermissionComplete(request, signedChallenge) {
|
|
25
|
-
const path = (0, url_1.buildPathAndQuery)('/
|
|
25
|
+
const path = (0, url_1.buildPathAndQuery)('/permissions/:permissionId/archive', {
|
|
26
26
|
path: request ?? {},
|
|
27
27
|
query: {},
|
|
28
28
|
});
|
|
@@ -36,7 +36,7 @@ class DelegatedPermissionsClient {
|
|
|
36
36
|
return response.json();
|
|
37
37
|
}
|
|
38
38
|
async createAssignmentInit(request) {
|
|
39
|
-
const path = (0, url_1.buildPathAndQuery)('/
|
|
39
|
+
const path = (0, url_1.buildPathAndQuery)('/permissions/:permissionId/assignments', {
|
|
40
40
|
path: request ?? {},
|
|
41
41
|
query: {},
|
|
42
42
|
});
|
|
@@ -49,7 +49,7 @@ class DelegatedPermissionsClient {
|
|
|
49
49
|
return challenge;
|
|
50
50
|
}
|
|
51
51
|
async createAssignmentComplete(request, signedChallenge) {
|
|
52
|
-
const path = (0, url_1.buildPathAndQuery)('/
|
|
52
|
+
const path = (0, url_1.buildPathAndQuery)('/permissions/:permissionId/assignments', {
|
|
53
53
|
path: request ?? {},
|
|
54
54
|
query: {},
|
|
55
55
|
});
|
|
@@ -63,7 +63,7 @@ class DelegatedPermissionsClient {
|
|
|
63
63
|
return response.json();
|
|
64
64
|
}
|
|
65
65
|
async createPermissionInit(request) {
|
|
66
|
-
const path = (0, url_1.buildPathAndQuery)('/
|
|
66
|
+
const path = (0, url_1.buildPathAndQuery)('/permissions', {
|
|
67
67
|
path: request ?? {},
|
|
68
68
|
query: {},
|
|
69
69
|
});
|
|
@@ -76,7 +76,7 @@ class DelegatedPermissionsClient {
|
|
|
76
76
|
return challenge;
|
|
77
77
|
}
|
|
78
78
|
async createPermissionComplete(request, signedChallenge) {
|
|
79
|
-
const path = (0, url_1.buildPathAndQuery)('/
|
|
79
|
+
const path = (0, url_1.buildPathAndQuery)('/permissions', {
|
|
80
80
|
path: request ?? {},
|
|
81
81
|
query: {},
|
|
82
82
|
});
|
|
@@ -90,7 +90,7 @@ class DelegatedPermissionsClient {
|
|
|
90
90
|
return response.json();
|
|
91
91
|
}
|
|
92
92
|
async deleteAssignmentInit(request) {
|
|
93
|
-
const path = (0, url_1.buildPathAndQuery)('/
|
|
93
|
+
const path = (0, url_1.buildPathAndQuery)('/permissions/:permissionId/assignments/:assignmentId', {
|
|
94
94
|
path: request ?? {},
|
|
95
95
|
query: {},
|
|
96
96
|
});
|
|
@@ -103,7 +103,7 @@ class DelegatedPermissionsClient {
|
|
|
103
103
|
return challenge;
|
|
104
104
|
}
|
|
105
105
|
async deleteAssignmentComplete(request, signedChallenge) {
|
|
106
|
-
const path = (0, url_1.buildPathAndQuery)('/
|
|
106
|
+
const path = (0, url_1.buildPathAndQuery)('/permissions/:permissionId/assignments/:assignmentId', {
|
|
107
107
|
path: request ?? {},
|
|
108
108
|
query: {},
|
|
109
109
|
});
|
|
@@ -117,7 +117,7 @@ class DelegatedPermissionsClient {
|
|
|
117
117
|
return response.json();
|
|
118
118
|
}
|
|
119
119
|
async getPermission(request) {
|
|
120
|
-
const path = (0, url_1.buildPathAndQuery)('/
|
|
120
|
+
const path = (0, url_1.buildPathAndQuery)('/permissions/:permissionId', {
|
|
121
121
|
path: request ?? {},
|
|
122
122
|
query: {},
|
|
123
123
|
});
|
|
@@ -128,7 +128,7 @@ class DelegatedPermissionsClient {
|
|
|
128
128
|
return response.json();
|
|
129
129
|
}
|
|
130
130
|
async listAssignments(request) {
|
|
131
|
-
const path = (0, url_1.buildPathAndQuery)('/
|
|
131
|
+
const path = (0, url_1.buildPathAndQuery)('/permissions/:permissionId/assignments', {
|
|
132
132
|
path: request ?? {},
|
|
133
133
|
query: {},
|
|
134
134
|
});
|
|
@@ -139,7 +139,7 @@ class DelegatedPermissionsClient {
|
|
|
139
139
|
return response.json();
|
|
140
140
|
}
|
|
141
141
|
async listPermissions(request) {
|
|
142
|
-
const path = (0, url_1.buildPathAndQuery)('/
|
|
142
|
+
const path = (0, url_1.buildPathAndQuery)('/permissions', {
|
|
143
143
|
path: request ?? {},
|
|
144
144
|
query: request?.query ?? {},
|
|
145
145
|
});
|
|
@@ -150,7 +150,7 @@ class DelegatedPermissionsClient {
|
|
|
150
150
|
return response.json();
|
|
151
151
|
}
|
|
152
152
|
async updatePermissionInit(request) {
|
|
153
|
-
const path = (0, url_1.buildPathAndQuery)('/
|
|
153
|
+
const path = (0, url_1.buildPathAndQuery)('/permissions/:permissionId', {
|
|
154
154
|
path: request ?? {},
|
|
155
155
|
query: {},
|
|
156
156
|
});
|
|
@@ -163,7 +163,7 @@ class DelegatedPermissionsClient {
|
|
|
163
163
|
return challenge;
|
|
164
164
|
}
|
|
165
165
|
async updatePermissionComplete(request, signedChallenge) {
|
|
166
|
-
const path = (0, url_1.buildPathAndQuery)('/
|
|
166
|
+
const path = (0, url_1.buildPathAndQuery)('/permissions/:permissionId', {
|
|
167
167
|
path: request ?? {},
|
|
168
168
|
query: {},
|
|
169
169
|
});
|
|
@@ -6,31 +6,15 @@ export type ArchivePermissionParams = {
|
|
|
6
6
|
};
|
|
7
7
|
export type ArchivePermissionResponse = {
|
|
8
8
|
id: string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
entityId: string;
|
|
19
|
-
dateCreated: Date;
|
|
20
|
-
dateResolved: Date;
|
|
21
|
-
body: {
|
|
22
|
-
id: string;
|
|
23
|
-
orgId: string;
|
|
24
|
-
name: string;
|
|
25
|
-
operations: string[];
|
|
26
|
-
resourceId?: (string | undefined) | null;
|
|
27
|
-
status: "Active";
|
|
28
|
-
predicateIds?: string[] | undefined;
|
|
29
|
-
isImmutable: boolean;
|
|
30
|
-
dateCreated?: string | undefined;
|
|
31
|
-
dateUpdated?: string | undefined;
|
|
32
|
-
isArchived: boolean;
|
|
33
|
-
};
|
|
9
|
+
name: string;
|
|
10
|
+
operations: string[];
|
|
11
|
+
resourceId?: (string | undefined) | null;
|
|
12
|
+
status: "Active";
|
|
13
|
+
predicateIds?: string[] | undefined;
|
|
14
|
+
isImmutable: boolean;
|
|
15
|
+
dateCreated?: string | undefined;
|
|
16
|
+
dateUpdated?: string | undefined;
|
|
17
|
+
isArchived: boolean;
|
|
34
18
|
};
|
|
35
19
|
export type ArchivePermissionRequest = ArchivePermissionParams & {
|
|
36
20
|
body: ArchivePermissionBody;
|
|
@@ -43,26 +27,11 @@ export type CreateAssignmentParams = {
|
|
|
43
27
|
};
|
|
44
28
|
export type CreateAssignmentResponse = {
|
|
45
29
|
id: string;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
52
|
-
kind: "Assignment" | "Permission";
|
|
53
|
-
operationKind: "Create" | "Update" | "Delete";
|
|
54
|
-
status: "Applied" | "Failed" | "Pending" | "Rejected";
|
|
55
|
-
entityId: string;
|
|
56
|
-
dateCreated: Date;
|
|
57
|
-
dateResolved: Date;
|
|
58
|
-
body: {
|
|
59
|
-
id: string;
|
|
60
|
-
permissionId: string;
|
|
61
|
-
identityId: string;
|
|
62
|
-
isImmutable: boolean;
|
|
63
|
-
dateCreated?: string | undefined;
|
|
64
|
-
dateUpdated?: string | undefined;
|
|
65
|
-
};
|
|
30
|
+
permissionId: string;
|
|
31
|
+
identityId: string;
|
|
32
|
+
isImmutable: boolean;
|
|
33
|
+
dateCreated?: string | undefined;
|
|
34
|
+
dateUpdated?: string | undefined;
|
|
66
35
|
};
|
|
67
36
|
export type CreateAssignmentRequest = CreateAssignmentParams & {
|
|
68
37
|
body: CreateAssignmentBody;
|
|
@@ -73,31 +42,15 @@ export type CreatePermissionBody = {
|
|
|
73
42
|
};
|
|
74
43
|
export type CreatePermissionResponse = {
|
|
75
44
|
id: string;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
entityId: string;
|
|
86
|
-
dateCreated: Date;
|
|
87
|
-
dateResolved: Date;
|
|
88
|
-
body: {
|
|
89
|
-
id: string;
|
|
90
|
-
orgId: string;
|
|
91
|
-
name: string;
|
|
92
|
-
operations: string[];
|
|
93
|
-
resourceId?: (string | undefined) | null;
|
|
94
|
-
status: "Active";
|
|
95
|
-
predicateIds?: string[] | undefined;
|
|
96
|
-
isImmutable: boolean;
|
|
97
|
-
dateCreated?: string | undefined;
|
|
98
|
-
dateUpdated?: string | undefined;
|
|
99
|
-
isArchived: boolean;
|
|
100
|
-
};
|
|
45
|
+
name: string;
|
|
46
|
+
operations: string[];
|
|
47
|
+
resourceId?: (string | undefined) | null;
|
|
48
|
+
status: "Active";
|
|
49
|
+
predicateIds?: string[] | undefined;
|
|
50
|
+
isImmutable: boolean;
|
|
51
|
+
dateCreated?: string | undefined;
|
|
52
|
+
dateUpdated?: string | undefined;
|
|
53
|
+
isArchived: boolean;
|
|
101
54
|
};
|
|
102
55
|
export type CreatePermissionRequest = {
|
|
103
56
|
body: CreatePermissionBody;
|
|
@@ -106,36 +59,13 @@ export type DeleteAssignmentParams = {
|
|
|
106
59
|
permissionId: string;
|
|
107
60
|
assignmentId: string;
|
|
108
61
|
};
|
|
109
|
-
export type DeleteAssignmentResponse =
|
|
110
|
-
id: string;
|
|
111
|
-
orgId: string;
|
|
112
|
-
requester: {
|
|
113
|
-
userId: string;
|
|
114
|
-
tokenId: string;
|
|
115
|
-
appId: string;
|
|
116
|
-
};
|
|
117
|
-
kind: "Assignment" | "Permission";
|
|
118
|
-
operationKind: "Create" | "Update" | "Delete";
|
|
119
|
-
status: "Applied" | "Failed" | "Pending" | "Rejected";
|
|
120
|
-
entityId: string;
|
|
121
|
-
dateCreated: Date;
|
|
122
|
-
dateResolved: Date;
|
|
123
|
-
body: {
|
|
124
|
-
id: string;
|
|
125
|
-
permissionId: string;
|
|
126
|
-
identityId: string;
|
|
127
|
-
isImmutable: boolean;
|
|
128
|
-
dateCreated?: string | undefined;
|
|
129
|
-
dateUpdated?: string | undefined;
|
|
130
|
-
};
|
|
131
|
-
};
|
|
62
|
+
export type DeleteAssignmentResponse = void | undefined;
|
|
132
63
|
export type DeleteAssignmentRequest = DeleteAssignmentParams;
|
|
133
64
|
export type GetPermissionParams = {
|
|
134
65
|
permissionId: string;
|
|
135
66
|
};
|
|
136
67
|
export type GetPermissionResponse = {
|
|
137
68
|
id: string;
|
|
138
|
-
orgId: string;
|
|
139
69
|
name: string;
|
|
140
70
|
operations: string[];
|
|
141
71
|
resourceId?: (string | undefined) | null;
|
|
@@ -169,7 +99,6 @@ export type ListPermissionsQuery = {
|
|
|
169
99
|
export type ListPermissionsResponse = {
|
|
170
100
|
items: {
|
|
171
101
|
id: string;
|
|
172
|
-
orgId: string;
|
|
173
102
|
name: string;
|
|
174
103
|
operations: string[];
|
|
175
104
|
resourceId?: (string | undefined) | null;
|
|
@@ -194,31 +123,15 @@ export type UpdatePermissionParams = {
|
|
|
194
123
|
};
|
|
195
124
|
export type UpdatePermissionResponse = {
|
|
196
125
|
id: string;
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
entityId: string;
|
|
207
|
-
dateCreated: Date;
|
|
208
|
-
dateResolved: Date;
|
|
209
|
-
body: {
|
|
210
|
-
id: string;
|
|
211
|
-
orgId: string;
|
|
212
|
-
name: string;
|
|
213
|
-
operations: string[];
|
|
214
|
-
resourceId?: (string | undefined) | null;
|
|
215
|
-
status: "Active";
|
|
216
|
-
predicateIds?: string[] | undefined;
|
|
217
|
-
isImmutable: boolean;
|
|
218
|
-
dateCreated?: string | undefined;
|
|
219
|
-
dateUpdated?: string | undefined;
|
|
220
|
-
isArchived: boolean;
|
|
221
|
-
};
|
|
126
|
+
name: string;
|
|
127
|
+
operations: string[];
|
|
128
|
+
resourceId?: (string | undefined) | null;
|
|
129
|
+
status: "Active";
|
|
130
|
+
predicateIds?: string[] | undefined;
|
|
131
|
+
isImmutable: boolean;
|
|
132
|
+
dateCreated?: string | undefined;
|
|
133
|
+
dateUpdated?: string | undefined;
|
|
134
|
+
isArchived: boolean;
|
|
222
135
|
};
|
|
223
136
|
export type UpdatePermissionRequest = UpdatePermissionParams & {
|
|
224
137
|
body: UpdatePermissionBody;
|