@tinycloudlabs/sdk-core 1.0.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/LICENSE.md +320 -0
- package/dist/TinyCloud.d.ts +206 -0
- package/dist/TinyCloud.d.ts.map +1 -0
- package/dist/TinyCloud.js +244 -0
- package/dist/TinyCloud.js.map +1 -0
- package/dist/TinyCloud.schema.d.ts +173 -0
- package/dist/TinyCloud.schema.d.ts.map +1 -0
- package/dist/TinyCloud.schema.js +136 -0
- package/dist/TinyCloud.schema.js.map +1 -0
- package/dist/TinyCloud.schema.test.d.ts +5 -0
- package/dist/TinyCloud.schema.test.d.ts.map +1 -0
- package/dist/TinyCloud.schema.test.js +286 -0
- package/dist/TinyCloud.schema.test.js.map +1 -0
- package/dist/authorization/CapabilityKeyRegistry.d.ts +317 -0
- package/dist/authorization/CapabilityKeyRegistry.d.ts.map +1 -0
- package/dist/authorization/CapabilityKeyRegistry.js +509 -0
- package/dist/authorization/CapabilityKeyRegistry.js.map +1 -0
- package/dist/authorization/authorization.schema.d.ts +233 -0
- package/dist/authorization/authorization.schema.d.ts.map +1 -0
- package/dist/authorization/authorization.schema.js +220 -0
- package/dist/authorization/authorization.schema.js.map +1 -0
- package/dist/authorization/authorization.schema.test.d.ts +5 -0
- package/dist/authorization/authorization.schema.test.d.ts.map +1 -0
- package/dist/authorization/authorization.schema.test.js +618 -0
- package/dist/authorization/authorization.schema.test.js.map +1 -0
- package/dist/authorization/index.d.ts +38 -0
- package/dist/authorization/index.d.ts.map +1 -0
- package/dist/authorization/index.js +52 -0
- package/dist/authorization/index.js.map +1 -0
- package/dist/authorization/spaceCreation.d.ts +96 -0
- package/dist/authorization/spaceCreation.d.ts.map +1 -0
- package/dist/authorization/spaceCreation.js +35 -0
- package/dist/authorization/spaceCreation.js.map +1 -0
- package/dist/authorization/spaceCreation.schema.d.ts +67 -0
- package/dist/authorization/spaceCreation.schema.d.ts.map +1 -0
- package/dist/authorization/spaceCreation.schema.js +95 -0
- package/dist/authorization/spaceCreation.schema.js.map +1 -0
- package/dist/authorization/spaceCreation.schema.test.d.ts +5 -0
- package/dist/authorization/spaceCreation.schema.test.d.ts.map +1 -0
- package/dist/authorization/spaceCreation.schema.test.js +168 -0
- package/dist/authorization/spaceCreation.schema.test.js.map +1 -0
- package/dist/authorization/strategies.d.ts +134 -0
- package/dist/authorization/strategies.d.ts.map +1 -0
- package/dist/authorization/strategies.js +15 -0
- package/dist/authorization/strategies.js.map +1 -0
- package/dist/authorization/strategies.schema.d.ts +185 -0
- package/dist/authorization/strategies.schema.d.ts.map +1 -0
- package/dist/authorization/strategies.schema.js +147 -0
- package/dist/authorization/strategies.schema.js.map +1 -0
- package/dist/authorization/strategies.schema.test.d.ts +5 -0
- package/dist/authorization/strategies.schema.test.d.ts.map +1 -0
- package/dist/authorization/strategies.schema.test.js +253 -0
- package/dist/authorization/strategies.schema.test.js.map +1 -0
- package/dist/delegations/DelegationManager.d.ts +164 -0
- package/dist/delegations/DelegationManager.d.ts.map +1 -0
- package/dist/delegations/DelegationManager.js +428 -0
- package/dist/delegations/DelegationManager.js.map +1 -0
- package/dist/delegations/SharingService.d.ts +279 -0
- package/dist/delegations/SharingService.d.ts.map +1 -0
- package/dist/delegations/SharingService.js +558 -0
- package/dist/delegations/SharingService.js.map +1 -0
- package/dist/delegations/SharingService.schema.d.ts +401 -0
- package/dist/delegations/SharingService.schema.d.ts.map +1 -0
- package/dist/delegations/SharingService.schema.js +211 -0
- package/dist/delegations/SharingService.schema.js.map +1 -0
- package/dist/delegations/index.d.ts +38 -0
- package/dist/delegations/index.d.ts.map +1 -0
- package/dist/delegations/index.js +42 -0
- package/dist/delegations/index.js.map +1 -0
- package/dist/delegations/types.d.ts +13 -0
- package/dist/delegations/types.d.ts.map +1 -0
- package/dist/delegations/types.js +42 -0
- package/dist/delegations/types.js.map +1 -0
- package/dist/delegations/types.schema.d.ts +1641 -0
- package/dist/delegations/types.schema.d.ts.map +1 -0
- package/dist/delegations/types.schema.js +535 -0
- package/dist/delegations/types.schema.js.map +1 -0
- package/dist/delegations/types.schema.test.d.ts +5 -0
- package/dist/delegations/types.schema.test.d.ts.map +1 -0
- package/dist/delegations/types.schema.test.js +627 -0
- package/dist/delegations/types.schema.test.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/json-schema.d.ts +327 -0
- package/dist/json-schema.d.ts.map +1 -0
- package/dist/json-schema.js +703 -0
- package/dist/json-schema.js.map +1 -0
- package/dist/json-schema.test.d.ts +7 -0
- package/dist/json-schema.test.d.ts.map +1 -0
- package/dist/json-schema.test.js +365 -0
- package/dist/json-schema.test.js.map +1 -0
- package/dist/signer.d.ts +28 -0
- package/dist/signer.d.ts.map +1 -0
- package/dist/signer.js +2 -0
- package/dist/signer.js.map +1 -0
- package/dist/space.d.ts +53 -0
- package/dist/space.d.ts.map +1 -0
- package/dist/space.js +67 -0
- package/dist/space.js.map +1 -0
- package/dist/space.schema.d.ts +65 -0
- package/dist/space.schema.d.ts.map +1 -0
- package/dist/space.schema.js +65 -0
- package/dist/space.schema.js.map +1 -0
- package/dist/space.schema.test.d.ts +5 -0
- package/dist/space.schema.test.d.ts.map +1 -0
- package/dist/space.schema.test.js +148 -0
- package/dist/space.schema.test.js.map +1 -0
- package/dist/spaces/Space.d.ts +175 -0
- package/dist/spaces/Space.d.ts.map +1 -0
- package/dist/spaces/Space.js +84 -0
- package/dist/spaces/Space.js.map +1 -0
- package/dist/spaces/SpaceService.d.ts +271 -0
- package/dist/spaces/SpaceService.d.ts.map +1 -0
- package/dist/spaces/SpaceService.js +715 -0
- package/dist/spaces/SpaceService.js.map +1 -0
- package/dist/spaces/index.d.ts +11 -0
- package/dist/spaces/index.d.ts.map +1 -0
- package/dist/spaces/index.js +20 -0
- package/dist/spaces/index.js.map +1 -0
- package/dist/spaces/spaces.schema.d.ts +421 -0
- package/dist/spaces/spaces.schema.d.ts.map +1 -0
- package/dist/spaces/spaces.schema.js +342 -0
- package/dist/spaces/spaces.schema.js.map +1 -0
- package/dist/spaces/spaces.schema.test.d.ts +5 -0
- package/dist/spaces/spaces.schema.test.d.ts.map +1 -0
- package/dist/spaces/spaces.schema.test.js +471 -0
- package/dist/spaces/spaces.schema.test.js.map +1 -0
- package/dist/storage.d.ts +47 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +14 -0
- package/dist/storage.js.map +1 -0
- package/dist/storage.schema.d.ts +277 -0
- package/dist/storage.schema.d.ts.map +1 -0
- package/dist/storage.schema.js +185 -0
- package/dist/storage.schema.js.map +1 -0
- package/dist/storage.schema.test.d.ts +5 -0
- package/dist/storage.schema.test.d.ts.map +1 -0
- package/dist/storage.schema.test.js +346 -0
- package/dist/storage.schema.test.js.map +1 -0
- package/dist/userAuthorization.d.ts +99 -0
- package/dist/userAuthorization.d.ts.map +1 -0
- package/dist/userAuthorization.js +3 -0
- package/dist/userAuthorization.js.map +1 -0
- package/dist/userAuthorization.schema.d.ts +259 -0
- package/dist/userAuthorization.schema.d.ts.map +1 -0
- package/dist/userAuthorization.schema.js +175 -0
- package/dist/userAuthorization.schema.js.map +1 -0
- package/dist/userAuthorization.schema.test.d.ts +5 -0
- package/dist/userAuthorization.schema.test.d.ts.map +1 -0
- package/dist/userAuthorization.schema.test.js +356 -0
- package/dist/userAuthorization.schema.test.js.map +1 -0
- package/dist/version.d.ts +30 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +54 -0
- package/dist/version.js.map +1 -0
- package/dist/wasm-validation.d.ts +287 -0
- package/dist/wasm-validation.d.ts.map +1 -0
- package/dist/wasm-validation.js +219 -0
- package/dist/wasm-validation.js.map +1 -0
- package/dist/wasm-validation.test.d.ts +5 -0
- package/dist/wasm-validation.test.d.ts.map +1 -0
- package/dist/wasm-validation.test.js +233 -0
- package/dist/wasm-validation.test.js.map +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DelegationManager - Handles delegation CRUD operations.
|
|
3
|
+
*
|
|
4
|
+
* This class manages the creation, revocation, listing, and querying
|
|
5
|
+
* of delegations within TinyCloud. It extracts and improves upon the
|
|
6
|
+
* delegation functionality previously in ITinyCloudStorage.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
import { DelegationErrorCodes, } from "./types";
|
|
11
|
+
/**
|
|
12
|
+
* Delegation action constants.
|
|
13
|
+
*/
|
|
14
|
+
const DelegationAction = {
|
|
15
|
+
CREATE: "tinycloud.delegation/create",
|
|
16
|
+
REVOKE: "tinycloud.delegation/revoke",
|
|
17
|
+
LIST: "tinycloud.delegation/list",
|
|
18
|
+
GET: "tinycloud.delegation/get",
|
|
19
|
+
CHECK: "tinycloud.delegation/check",
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Creates a DelegationError with the given parameters.
|
|
23
|
+
*/
|
|
24
|
+
function createError(code, message, cause, meta) {
|
|
25
|
+
return {
|
|
26
|
+
code,
|
|
27
|
+
message,
|
|
28
|
+
service: "delegation",
|
|
29
|
+
cause,
|
|
30
|
+
meta,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* DelegationManager handles all delegation-related operations.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import { DelegationManager } from "@tinycloudlabs/sdk-core/delegations";
|
|
39
|
+
*
|
|
40
|
+
* const delegations = new DelegationManager({
|
|
41
|
+
* hosts: ["https://node.tinycloud.xyz"],
|
|
42
|
+
* session,
|
|
43
|
+
* invoke,
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* // Create a delegation
|
|
47
|
+
* const result = await delegations.create({
|
|
48
|
+
* delegateDID: "did:pkh:eip155:1:0x...",
|
|
49
|
+
* path: "shared/",
|
|
50
|
+
* actions: ["tinycloud.kv/get", "tinycloud.kv/list"],
|
|
51
|
+
* expiry: new Date(Date.now() + 24 * 60 * 60 * 1000), // 24 hours
|
|
52
|
+
* });
|
|
53
|
+
*
|
|
54
|
+
* if (result.ok) {
|
|
55
|
+
* console.log("Created delegation:", result.data.cid);
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export class DelegationManager {
|
|
60
|
+
/**
|
|
61
|
+
* Creates a new DelegationManager instance.
|
|
62
|
+
*
|
|
63
|
+
* @param config - Configuration including hosts, session, and invoke function
|
|
64
|
+
*/
|
|
65
|
+
constructor(config) {
|
|
66
|
+
this.hosts = config.hosts;
|
|
67
|
+
this.session = config.session;
|
|
68
|
+
this.invoke = config.invoke;
|
|
69
|
+
this.fetchFn = config.fetch ?? globalThis.fetch.bind(globalThis);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Updates the session (e.g., after re-authentication).
|
|
73
|
+
*
|
|
74
|
+
* @param session - New session to use for operations
|
|
75
|
+
*/
|
|
76
|
+
updateSession(session) {
|
|
77
|
+
this.session = session;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Gets the primary host URL.
|
|
81
|
+
*/
|
|
82
|
+
get host() {
|
|
83
|
+
return this.hosts[0];
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Executes an invoke operation against the delegation API.
|
|
87
|
+
*/
|
|
88
|
+
async invokeOperation(path, action, body) {
|
|
89
|
+
const headers = this.invoke(this.session, "delegation", path, action);
|
|
90
|
+
return this.fetchFn(`${this.host}/invoke`, {
|
|
91
|
+
method: "POST",
|
|
92
|
+
headers,
|
|
93
|
+
body,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Creates a new delegation.
|
|
98
|
+
*
|
|
99
|
+
* Delegates specific permissions to another DID for a given path.
|
|
100
|
+
* The delegatee can then use these permissions to access resources
|
|
101
|
+
* within the specified scope.
|
|
102
|
+
*
|
|
103
|
+
* @param params - Parameters for the delegation
|
|
104
|
+
* @returns Result containing the created Delegation or an error
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* const result = await manager.create({
|
|
109
|
+
* delegateDID: bob.did,
|
|
110
|
+
* path: "documents/shared/",
|
|
111
|
+
* actions: ["tinycloud.kv/get", "tinycloud.kv/put"],
|
|
112
|
+
* expiry: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000), // 7 days
|
|
113
|
+
* });
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
async create(params) {
|
|
117
|
+
// Validate inputs
|
|
118
|
+
if (!params.delegateDID) {
|
|
119
|
+
return {
|
|
120
|
+
ok: false,
|
|
121
|
+
error: createError(DelegationErrorCodes.INVALID_INPUT, "delegateDID is required"),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
if (!params.path) {
|
|
125
|
+
return {
|
|
126
|
+
ok: false,
|
|
127
|
+
error: createError(DelegationErrorCodes.INVALID_INPUT, "path is required"),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (!params.actions || params.actions.length === 0) {
|
|
131
|
+
return {
|
|
132
|
+
ok: false,
|
|
133
|
+
error: createError(DelegationErrorCodes.INVALID_INPUT, "at least one action is required"),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
const body = JSON.stringify({
|
|
138
|
+
delegateDID: params.delegateDID,
|
|
139
|
+
path: params.path,
|
|
140
|
+
actions: params.actions,
|
|
141
|
+
expiry: params.expiry?.toISOString(),
|
|
142
|
+
disableSubDelegation: params.disableSubDelegation ?? false,
|
|
143
|
+
statement: params.statement,
|
|
144
|
+
});
|
|
145
|
+
const response = await this.invokeOperation(params.path, DelegationAction.CREATE, body);
|
|
146
|
+
if (!response.ok) {
|
|
147
|
+
const errorText = await response.text();
|
|
148
|
+
return {
|
|
149
|
+
ok: false,
|
|
150
|
+
error: createError(DelegationErrorCodes.CREATION_FAILED, `Failed to create delegation: ${response.status} - ${errorText}`, undefined, { status: response.status, path: params.path }),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const apiResponse = (await response.json());
|
|
154
|
+
const delegation = {
|
|
155
|
+
cid: apiResponse.cid ?? "",
|
|
156
|
+
delegateDID: params.delegateDID,
|
|
157
|
+
spaceId: this.session.spaceId,
|
|
158
|
+
path: params.path,
|
|
159
|
+
actions: params.actions,
|
|
160
|
+
expiry: params.expiry ?? new Date(Date.now() + 24 * 60 * 60 * 1000),
|
|
161
|
+
isRevoked: false,
|
|
162
|
+
allowSubDelegation: !(params.disableSubDelegation ?? false),
|
|
163
|
+
createdAt: new Date(),
|
|
164
|
+
};
|
|
165
|
+
return { ok: true, data: delegation };
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
169
|
+
return {
|
|
170
|
+
ok: false,
|
|
171
|
+
error: createError(DelegationErrorCodes.ABORTED, "Request aborted", error),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
ok: false,
|
|
176
|
+
error: createError(DelegationErrorCodes.NETWORK_ERROR, `Network error during delegation creation: ${String(error)}`, error instanceof Error ? error : undefined),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Revokes an existing delegation.
|
|
182
|
+
*
|
|
183
|
+
* Once revoked, the delegation can no longer be used to access resources.
|
|
184
|
+
* This also invalidates any sub-delegations derived from this delegation.
|
|
185
|
+
*
|
|
186
|
+
* @param cid - The CID of the delegation to revoke
|
|
187
|
+
* @returns Result indicating success or an error
|
|
188
|
+
*
|
|
189
|
+
* @example
|
|
190
|
+
* ```typescript
|
|
191
|
+
* const result = await manager.revoke("bafy...");
|
|
192
|
+
* if (result.ok) {
|
|
193
|
+
* console.log("Delegation revoked successfully");
|
|
194
|
+
* }
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
async revoke(cid) {
|
|
198
|
+
if (!cid) {
|
|
199
|
+
return {
|
|
200
|
+
ok: false,
|
|
201
|
+
error: createError(DelegationErrorCodes.INVALID_INPUT, "cid is required"),
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
try {
|
|
205
|
+
const body = JSON.stringify({ cid });
|
|
206
|
+
const response = await this.invokeOperation(cid, DelegationAction.REVOKE, body);
|
|
207
|
+
if (!response.ok) {
|
|
208
|
+
const errorText = await response.text();
|
|
209
|
+
if (response.status === 404) {
|
|
210
|
+
return {
|
|
211
|
+
ok: false,
|
|
212
|
+
error: createError(DelegationErrorCodes.NOT_FOUND, `Delegation not found: ${cid}`),
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
ok: false,
|
|
217
|
+
error: createError(DelegationErrorCodes.REVOCATION_FAILED, `Failed to revoke delegation: ${response.status} - ${errorText}`, undefined, { status: response.status, cid }),
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
return { ok: true, data: undefined };
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
224
|
+
return {
|
|
225
|
+
ok: false,
|
|
226
|
+
error: createError(DelegationErrorCodes.ABORTED, "Request aborted", error),
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
ok: false,
|
|
231
|
+
error: createError(DelegationErrorCodes.NETWORK_ERROR, `Network error during delegation revocation: ${String(error)}`, error instanceof Error ? error : undefined),
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Lists all delegations for the current session's space.
|
|
237
|
+
*
|
|
238
|
+
* Returns both delegations created by the current user (as delegator)
|
|
239
|
+
* and delegations granted to the current user (as delegatee).
|
|
240
|
+
*
|
|
241
|
+
* @returns Result containing an array of Delegations or an error
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```typescript
|
|
245
|
+
* const result = await manager.list();
|
|
246
|
+
* if (result.ok) {
|
|
247
|
+
* for (const delegation of result.data) {
|
|
248
|
+
* console.log(`${delegation.cid}: ${delegation.path} -> ${delegation.delegateDID}`);
|
|
249
|
+
* }
|
|
250
|
+
* }
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
async list() {
|
|
254
|
+
try {
|
|
255
|
+
const response = await this.invokeOperation("", DelegationAction.LIST);
|
|
256
|
+
if (!response.ok) {
|
|
257
|
+
const errorText = await response.text();
|
|
258
|
+
return {
|
|
259
|
+
ok: false,
|
|
260
|
+
error: createError(DelegationErrorCodes.NETWORK_ERROR, `Failed to list delegations: ${response.status} - ${errorText}`, undefined, { status: response.status }),
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
const data = (await response.json());
|
|
264
|
+
const delegations = data.map((item) => ({
|
|
265
|
+
cid: item.cid,
|
|
266
|
+
delegateDID: item.delegateDID,
|
|
267
|
+
delegatorDID: item.delegatorDID,
|
|
268
|
+
spaceId: item.spaceId,
|
|
269
|
+
path: item.path,
|
|
270
|
+
actions: item.actions,
|
|
271
|
+
expiry: new Date(item.expiry),
|
|
272
|
+
isRevoked: item.isRevoked,
|
|
273
|
+
createdAt: item.createdAt ? new Date(item.createdAt) : undefined,
|
|
274
|
+
parentCid: item.parentCid,
|
|
275
|
+
allowSubDelegation: item.allowSubDelegation,
|
|
276
|
+
}));
|
|
277
|
+
return { ok: true, data: delegations };
|
|
278
|
+
}
|
|
279
|
+
catch (error) {
|
|
280
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
281
|
+
return {
|
|
282
|
+
ok: false,
|
|
283
|
+
error: createError(DelegationErrorCodes.ABORTED, "Request aborted", error),
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
ok: false,
|
|
288
|
+
error: createError(DelegationErrorCodes.NETWORK_ERROR, `Network error during delegation list: ${String(error)}`, error instanceof Error ? error : undefined),
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Gets the full delegation chain for a given delegation.
|
|
294
|
+
*
|
|
295
|
+
* Returns the chain of delegations from the root (original delegator)
|
|
296
|
+
* to the specified delegation, including all intermediate sub-delegations.
|
|
297
|
+
*
|
|
298
|
+
* @param cid - The CID of the delegation to get the chain for
|
|
299
|
+
* @returns Result containing the DelegationChain or an error
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```typescript
|
|
303
|
+
* const result = await manager.getChain("bafy...");
|
|
304
|
+
* if (result.ok) {
|
|
305
|
+
* console.log("Chain length:", result.data.length);
|
|
306
|
+
* for (const delegation of result.data) {
|
|
307
|
+
* console.log(`- ${delegation.delegatorDID} -> ${delegation.delegateDID}`);
|
|
308
|
+
* }
|
|
309
|
+
* }
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
async getChain(cid) {
|
|
313
|
+
if (!cid) {
|
|
314
|
+
return {
|
|
315
|
+
ok: false,
|
|
316
|
+
error: createError(DelegationErrorCodes.INVALID_INPUT, "cid is required"),
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
try {
|
|
320
|
+
const body = JSON.stringify({ cid, includeChain: true });
|
|
321
|
+
const response = await this.invokeOperation(cid, DelegationAction.GET, body);
|
|
322
|
+
if (!response.ok) {
|
|
323
|
+
const errorText = await response.text();
|
|
324
|
+
if (response.status === 404) {
|
|
325
|
+
return {
|
|
326
|
+
ok: false,
|
|
327
|
+
error: createError(DelegationErrorCodes.NOT_FOUND, `Delegation not found: ${cid}`),
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
return {
|
|
331
|
+
ok: false,
|
|
332
|
+
error: createError(DelegationErrorCodes.NETWORK_ERROR, `Failed to get delegation chain: ${response.status} - ${errorText}`, undefined, { status: response.status, cid }),
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
const data = (await response.json());
|
|
336
|
+
const chain = data.chain.map((item) => ({
|
|
337
|
+
cid: item.cid,
|
|
338
|
+
delegateDID: item.delegateDID,
|
|
339
|
+
delegatorDID: item.delegatorDID,
|
|
340
|
+
spaceId: item.spaceId,
|
|
341
|
+
path: item.path,
|
|
342
|
+
actions: item.actions,
|
|
343
|
+
expiry: new Date(item.expiry),
|
|
344
|
+
isRevoked: item.isRevoked,
|
|
345
|
+
createdAt: item.createdAt ? new Date(item.createdAt) : undefined,
|
|
346
|
+
parentCid: item.parentCid,
|
|
347
|
+
allowSubDelegation: item.allowSubDelegation,
|
|
348
|
+
}));
|
|
349
|
+
return { ok: true, data: chain };
|
|
350
|
+
}
|
|
351
|
+
catch (error) {
|
|
352
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
353
|
+
return {
|
|
354
|
+
ok: false,
|
|
355
|
+
error: createError(DelegationErrorCodes.ABORTED, "Request aborted", error),
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
return {
|
|
359
|
+
ok: false,
|
|
360
|
+
error: createError(DelegationErrorCodes.NETWORK_ERROR, `Network error during chain retrieval: ${String(error)}`, error instanceof Error ? error : undefined),
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Checks if the current session has permission for a given path and action.
|
|
366
|
+
*
|
|
367
|
+
* This can be used to verify permissions before attempting an operation,
|
|
368
|
+
* or to implement custom access control logic.
|
|
369
|
+
*
|
|
370
|
+
* @param path - The resource path to check
|
|
371
|
+
* @param action - The action to check (e.g., "tinycloud.kv/get")
|
|
372
|
+
* @returns Result containing a boolean indicating permission or an error
|
|
373
|
+
*
|
|
374
|
+
* @example
|
|
375
|
+
* ```typescript
|
|
376
|
+
* const result = await manager.checkPermission("documents/private/", "tinycloud.kv/put");
|
|
377
|
+
* if (result.ok && result.data) {
|
|
378
|
+
* console.log("Permission granted");
|
|
379
|
+
* } else {
|
|
380
|
+
* console.log("Permission denied");
|
|
381
|
+
* }
|
|
382
|
+
* ```
|
|
383
|
+
*/
|
|
384
|
+
async checkPermission(path, action) {
|
|
385
|
+
if (!path) {
|
|
386
|
+
return {
|
|
387
|
+
ok: false,
|
|
388
|
+
error: createError(DelegationErrorCodes.INVALID_INPUT, "path is required"),
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
if (!action) {
|
|
392
|
+
return {
|
|
393
|
+
ok: false,
|
|
394
|
+
error: createError(DelegationErrorCodes.INVALID_INPUT, "action is required"),
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
try {
|
|
398
|
+
const body = JSON.stringify({ path, action });
|
|
399
|
+
const response = await this.invokeOperation(path, DelegationAction.CHECK, body);
|
|
400
|
+
if (!response.ok) {
|
|
401
|
+
// 403 means permission denied, which is a valid result
|
|
402
|
+
if (response.status === 403) {
|
|
403
|
+
return { ok: true, data: false };
|
|
404
|
+
}
|
|
405
|
+
const errorText = await response.text();
|
|
406
|
+
return {
|
|
407
|
+
ok: false,
|
|
408
|
+
error: createError(DelegationErrorCodes.NETWORK_ERROR, `Failed to check permission: ${response.status} - ${errorText}`, undefined, { status: response.status, path, action }),
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
const data = (await response.json());
|
|
412
|
+
return { ok: true, data: data.allowed };
|
|
413
|
+
}
|
|
414
|
+
catch (error) {
|
|
415
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
416
|
+
return {
|
|
417
|
+
ok: false,
|
|
418
|
+
error: createError(DelegationErrorCodes.ABORTED, "Request aborted", error),
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
return {
|
|
422
|
+
ok: false,
|
|
423
|
+
error: createError(DelegationErrorCodes.NETWORK_ERROR, `Network error during permission check: ${String(error)}`, error instanceof Error ? error : undefined),
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
//# sourceMappingURL=DelegationManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DelegationManager.js","sourceRoot":"","sources":["../../src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