@dfns/sdk 0.2.5 → 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.
@@ -3,11 +3,10 @@ import { AssetsClient } from './codegen/Assets';
3
3
  import { AuthClient } from './codegen/Auth';
4
4
  import { BlockchainsClient } from './codegen/Blockchains';
5
5
  import { CallbacksClient } from './codegen/Callbacks';
6
- import { PermissionsClient } from './codegen/Permissions';
7
6
  import { PolicyExecutionClient } from './codegen/PolicyExecution';
8
7
  import { PolicyManagementClient } from './codegen/PolicyManagement';
9
8
  import { PublicKeysClient } from './codegen/PublicKeys';
10
- import { PermissionsClient as PermissionsV2Client } from './generated/permissions';
9
+ import { PermissionsClient } from './generated/permissions';
11
10
  import { PoliciesClient } from './generated/policies';
12
11
  import { SignersClient } from './generated/signers';
13
12
  import { WalletsClient } from './generated/wallets';
@@ -23,11 +22,7 @@ export declare class DfnsApiClient {
23
22
  get auth(): AuthClient;
24
23
  get blockchains(): BlockchainsClient;
25
24
  get callbacks(): CallbacksClient;
26
- /**
27
- * @deprecated use permissions v2 instead
28
- */
29
25
  get permissions(): PermissionsClient;
30
- get permissionsV2(): PermissionsV2Client;
31
26
  get policies(): PoliciesClient;
32
27
  /**
33
28
  * @deprecated use the new policy engine instead
package/dfnsApiClient.js CHANGED
@@ -5,7 +5,6 @@ const Assets_1 = require("./codegen/Assets");
5
5
  const Auth_1 = require("./codegen/Auth");
6
6
  const Blockchains_1 = require("./codegen/Blockchains");
7
7
  const Callbacks_1 = require("./codegen/Callbacks");
8
- const Permissions_1 = require("./codegen/Permissions");
9
8
  const PolicyExecution_1 = require("./codegen/PolicyExecution");
10
9
  const PolicyManagement_1 = require("./codegen/PolicyManagement");
11
10
  const PublicKeys_1 = require("./codegen/PublicKeys");
@@ -30,13 +29,7 @@ class DfnsApiClient {
30
29
  get callbacks() {
31
30
  return new Callbacks_1.CallbacksClient(this.apiOptions);
32
31
  }
33
- /**
34
- * @deprecated use permissions v2 instead
35
- */
36
32
  get permissions() {
37
- return new Permissions_1.PermissionsClient(this.apiOptions);
38
- }
39
- get permissionsV2() {
40
33
  return new permissions_1.PermissionsClient(this.apiOptions);
41
34
  }
42
35
  get policies() {
@@ -3,11 +3,10 @@ import { DelegatedAssetsClient } from './codegen/Assets';
3
3
  import { DelegatedAuthClient } from './codegen/Auth';
4
4
  import { DelegatedBlockchainsClient } from './codegen/Blockchains';
5
5
  import { DelegatedCallbacksClient } from './codegen/Callbacks';
6
- import { DelegatedPermissionsClient } from './codegen/Permissions';
7
6
  import { DelegatedPolicyExecutionClient } from './codegen/PolicyExecution';
8
7
  import { DelegatedPolicyManagementClient } from './codegen/PolicyManagement';
9
8
  import { DelegatedPublicKeysClient } from './codegen/PublicKeys';
10
- import { DelegatedPermissionsClient as DelegatedPermissionsV2Client } from './generated/permissions';
9
+ import { DelegatedPermissionsClient } from './generated/permissions';
11
10
  import { DelegatedPoliciesClient } from './generated/policies';
12
11
  import { DelegatedSignersClient } from './generated/signers';
13
12
  import { DelegatedWalletsClient } from './generated/wallets';
@@ -22,11 +21,7 @@ export declare class DfnsDelegatedApiClient {
22
21
  get auth(): DelegatedAuthClient;
23
22
  get blockchains(): DelegatedBlockchainsClient;
24
23
  get callbacks(): DelegatedCallbacksClient;
25
- /**
26
- * @deprecated use permissions v2 instead
27
- */
28
24
  get permissions(): DelegatedPermissionsClient;
29
- get permissionsV2(): DelegatedPermissionsV2Client;
30
25
  get policies(): DelegatedPoliciesClient;
31
26
  /**
32
27
  * @deprecated use the new policy engine instead
@@ -5,7 +5,6 @@ const Assets_1 = require("./codegen/Assets");
5
5
  const Auth_1 = require("./codegen/Auth");
6
6
  const Blockchains_1 = require("./codegen/Blockchains");
7
7
  const Callbacks_1 = require("./codegen/Callbacks");
8
- const Permissions_1 = require("./codegen/Permissions");
9
8
  const PolicyExecution_1 = require("./codegen/PolicyExecution");
10
9
  const PolicyManagement_1 = require("./codegen/PolicyManagement");
11
10
  const PublicKeys_1 = require("./codegen/PublicKeys");
@@ -30,13 +29,7 @@ class DfnsDelegatedApiClient {
30
29
  get callbacks() {
31
30
  return new Callbacks_1.DelegatedCallbacksClient(this.apiOptions);
32
31
  }
33
- /**
34
- * @deprecated use permissions v2 instead
35
- */
36
32
  get permissions() {
37
- return new Permissions_1.DelegatedPermissionsClient(this.apiOptions);
38
- }
39
- get permissionsV2() {
40
33
  return new permissions_1.DelegatedPermissionsClient(this.apiOptions);
41
34
  }
42
35
  get policies() {
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)('/v2/permissions/:permissionId/archive', {
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)('/v2/permissions/:permissionId/assignments', {
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)('/v2/permissions', {
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)('/v2/permissions/:permissionId/assignments/:assignmentId', {
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)('/v2/permissions/:permissionId', {
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)('/v2/permissions/:permissionId/assignments', {
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)('/v2/permissions', {
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)('/v2/permissions/:permissionId', {
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)('/v2/permissions/:permissionId/archive', {
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)('/v2/permissions/:permissionId/archive', {
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)('/v2/permissions/:permissionId/assignments', {
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)('/v2/permissions/:permissionId/assignments', {
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)('/v2/permissions', {
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)('/v2/permissions', {
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)('/v2/permissions/:permissionId/assignments/:assignmentId', {
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)('/v2/permissions/:permissionId/assignments/:assignmentId', {
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)('/v2/permissions/:permissionId', {
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)('/v2/permissions/:permissionId/assignments', {
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)('/v2/permissions', {
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)('/v2/permissions/:permissionId', {
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)('/v2/permissions/:permissionId', {
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
- orgId: string;
10
- requester: {
11
- userId: string;
12
- tokenId: string;
13
- appId: string;
14
- };
15
- kind: "Assignment" | "Permission";
16
- operationKind: "Create" | "Update" | "Delete";
17
- status: "Applied" | "Failed" | "Pending" | "Rejected";
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
- orgId: string;
47
- requester: {
48
- userId: string;
49
- tokenId: string;
50
- appId: string;
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
- orgId: string;
77
- requester: {
78
- userId: string;
79
- tokenId: string;
80
- appId: string;
81
- };
82
- kind: "Assignment" | "Permission";
83
- operationKind: "Create" | "Update" | "Delete";
84
- status: "Applied" | "Failed" | "Pending" | "Rejected";
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
- orgId: string;
198
- requester: {
199
- userId: string;
200
- tokenId: string;
201
- appId: string;
202
- };
203
- kind: "Assignment" | "Permission";
204
- operationKind: "Create" | "Update" | "Delete";
205
- status: "Applied" | "Failed" | "Pending" | "Rejected";
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;