@tinycloudlabs/node-sdk 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/DelegatedAccess.d.ts +33 -0
- package/dist/DelegatedAccess.d.ts.map +1 -0
- package/dist/DelegatedAccess.js +61 -0
- package/dist/DelegatedAccess.js.map +1 -0
- package/dist/TinyCloudNode.d.ts +441 -0
- package/dist/TinyCloudNode.d.ts.map +1 -0
- package/dist/TinyCloudNode.js +987 -0
- package/dist/TinyCloudNode.js.map +1 -0
- package/dist/authorization/NodeUserAuthorization.d.ts +200 -0
- package/dist/authorization/NodeUserAuthorization.d.ts.map +1 -0
- package/dist/authorization/NodeUserAuthorization.js +516 -0
- package/dist/authorization/NodeUserAuthorization.js.map +1 -0
- package/dist/authorization/strategies.d.ts +57 -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/delegation.d.ts +35 -0
- package/dist/delegation.d.ts.map +1 -0
- package/dist/delegation.js +21 -0
- package/dist/delegation.js.map +1 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/keys/WasmKeyProvider.d.ts +101 -0
- package/dist/keys/WasmKeyProvider.d.ts.map +1 -0
- package/dist/keys/WasmKeyProvider.js +113 -0
- package/dist/keys/WasmKeyProvider.js.map +1 -0
- package/dist/keys/index.d.ts +7 -0
- package/dist/keys/index.d.ts.map +1 -0
- package/dist/keys/index.js +7 -0
- package/dist/keys/index.js.map +1 -0
- package/dist/signers/PrivateKeySigner.d.ts +47 -0
- package/dist/signers/PrivateKeySigner.d.ts.map +1 -0
- package/dist/signers/PrivateKeySigner.js +89 -0
- package/dist/signers/PrivateKeySigner.js.map +1 -0
- package/dist/storage/FileSessionStorage.d.ts +59 -0
- package/dist/storage/FileSessionStorage.d.ts.map +1 -0
- package/dist/storage/FileSessionStorage.js +148 -0
- package/dist/storage/FileSessionStorage.js.map +1 -0
- package/dist/storage/MemorySessionStorage.d.ts +49 -0
- package/dist/storage/MemorySessionStorage.d.ts.map +1 -0
- package/dist/storage/MemorySessionStorage.js +88 -0
- package/dist/storage/MemorySessionStorage.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TinyCloudNode - High-level API for Node.js users.
|
|
3
|
+
*
|
|
4
|
+
* Each user has their own TinyCloudNode instance with their own key.
|
|
5
|
+
* This class provides a simplified interface for:
|
|
6
|
+
* - Signing in and managing sessions
|
|
7
|
+
* - Key-value storage operations on own space
|
|
8
|
+
* - Creating and using delegations
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const alice = new TinyCloudNode({
|
|
13
|
+
* privateKey: process.env.ALICE_PRIVATE_KEY,
|
|
14
|
+
* host: "https://node.tinycloud.xyz",
|
|
15
|
+
* prefix: "myapp",
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* await alice.signIn();
|
|
19
|
+
* await alice.kv.put("greeting", "Hello, world!");
|
|
20
|
+
*
|
|
21
|
+
* // Delegate access to Bob
|
|
22
|
+
* const delegation = await alice.createDelegation({
|
|
23
|
+
* path: "shared/",
|
|
24
|
+
* actions: ["tinycloud.kv/get", "tinycloud.kv/put"],
|
|
25
|
+
* delegateDID: bob.did,
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* // Bob uses the delegation
|
|
29
|
+
* const access = await bob.useDelegation(delegation);
|
|
30
|
+
* const data = await access.kv.get("shared/data");
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
import { TinyCloudSession, IKVService, DelegationManager, ISpaceService, ICapabilityKeyRegistry, ISharingService, Delegation, CreateDelegationParams, DelegationResult } from "@tinycloudlabs/sdk-core";
|
|
34
|
+
import { PortableDelegation } from "./delegation";
|
|
35
|
+
import { DelegatedAccess } from "./DelegatedAccess";
|
|
36
|
+
/**
|
|
37
|
+
* Configuration for TinyCloudNode.
|
|
38
|
+
* All fields are optional - TinyCloudNode can work with zero configuration.
|
|
39
|
+
*/
|
|
40
|
+
export interface TinyCloudNodeConfig {
|
|
41
|
+
/** Hex-encoded private key (with or without 0x prefix). Optional - only needed for wallet mode and signIn() */
|
|
42
|
+
privateKey?: string;
|
|
43
|
+
/** TinyCloud server URL (default: "https://node.tinycloud.xyz") */
|
|
44
|
+
host?: string;
|
|
45
|
+
/** Space prefix for this user's space. Optional - only needed for signIn() */
|
|
46
|
+
prefix?: string;
|
|
47
|
+
/** Domain for SIWE messages (default: derived from host) */
|
|
48
|
+
domain?: string;
|
|
49
|
+
/** Session expiration time in milliseconds (default: 1 hour) */
|
|
50
|
+
sessionExpirationMs?: number;
|
|
51
|
+
/** Whether to automatically create space if it doesn't exist (default: false) */
|
|
52
|
+
autoCreateSpace?: boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* High-level TinyCloud API for Node.js environments.
|
|
56
|
+
*
|
|
57
|
+
* Each user creates their own TinyCloudNode instance with their private key.
|
|
58
|
+
* The instance manages the user's session and provides access to their space.
|
|
59
|
+
*/
|
|
60
|
+
export declare class TinyCloudNode {
|
|
61
|
+
/** Flag to ensure WASM panic hook is only initialized once */
|
|
62
|
+
private static wasmInitialized;
|
|
63
|
+
private config;
|
|
64
|
+
private signer;
|
|
65
|
+
private auth;
|
|
66
|
+
private tc;
|
|
67
|
+
private _address?;
|
|
68
|
+
private _chainId;
|
|
69
|
+
private sessionManager;
|
|
70
|
+
private _serviceContext?;
|
|
71
|
+
private _kv?;
|
|
72
|
+
/** Session key ID - always available */
|
|
73
|
+
private sessionKeyId;
|
|
74
|
+
/** Session key JWK as object - always available */
|
|
75
|
+
private sessionKeyJwk;
|
|
76
|
+
private _capabilityRegistry;
|
|
77
|
+
private _keyProvider;
|
|
78
|
+
private _sharingService;
|
|
79
|
+
private _delegationManager?;
|
|
80
|
+
private _spaceService?;
|
|
81
|
+
/**
|
|
82
|
+
* Create a new TinyCloudNode instance.
|
|
83
|
+
*
|
|
84
|
+
* All configuration is optional. Without a privateKey, the instance operates
|
|
85
|
+
* in "session-only" mode where it can receive delegations but cannot create
|
|
86
|
+
* its own space via signIn().
|
|
87
|
+
*
|
|
88
|
+
* @param config - Configuration options (all optional)
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* // Session-only mode - can receive delegations
|
|
93
|
+
* const bob = new TinyCloudNode();
|
|
94
|
+
* console.log(bob.did); // did:key:z6Mk... - available immediately
|
|
95
|
+
*
|
|
96
|
+
* // Wallet mode - can create own space
|
|
97
|
+
* const alice = new TinyCloudNode({
|
|
98
|
+
* privateKey: process.env.ALICE_PRIVATE_KEY,
|
|
99
|
+
* prefix: "myapp",
|
|
100
|
+
* });
|
|
101
|
+
* await alice.signIn();
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
constructor(config?: TinyCloudNodeConfig);
|
|
105
|
+
/**
|
|
106
|
+
* Get the primary identity DID for this user.
|
|
107
|
+
* - If wallet connected and signed in: returns PKH DID (did:pkh:eip155:{chainId}:{address})
|
|
108
|
+
* - If session-only mode: returns session key DID (did:key:z6Mk...)
|
|
109
|
+
*
|
|
110
|
+
* Use this for delegations - it always returns the appropriate identity.
|
|
111
|
+
*/
|
|
112
|
+
get did(): string;
|
|
113
|
+
/**
|
|
114
|
+
* Get the session key DID. Always available.
|
|
115
|
+
* Format: did:key:z6Mk...#z6Mk...
|
|
116
|
+
*
|
|
117
|
+
* Use this when you specifically need the session key, not the user identity.
|
|
118
|
+
*/
|
|
119
|
+
get sessionDid(): string;
|
|
120
|
+
/**
|
|
121
|
+
* Get the Ethereum address for this user.
|
|
122
|
+
*/
|
|
123
|
+
get address(): string | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* Check if this instance is in session-only mode (no wallet).
|
|
126
|
+
* In session-only mode, the instance can receive delegations but cannot
|
|
127
|
+
* create its own space via signIn().
|
|
128
|
+
*/
|
|
129
|
+
get isSessionOnly(): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Get the space ID for this user.
|
|
132
|
+
* Available after signIn().
|
|
133
|
+
*/
|
|
134
|
+
get spaceId(): string | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* Get the current TinyCloud session.
|
|
137
|
+
* Available after signIn().
|
|
138
|
+
*/
|
|
139
|
+
get session(): TinyCloudSession | undefined;
|
|
140
|
+
/**
|
|
141
|
+
* Sign in and create a new session.
|
|
142
|
+
* This creates the user's space if it doesn't exist.
|
|
143
|
+
* Requires wallet mode (privateKey in config).
|
|
144
|
+
*/
|
|
145
|
+
signIn(): Promise<void>;
|
|
146
|
+
/**
|
|
147
|
+
* Connect a wallet to upgrade from session-only mode to wallet mode.
|
|
148
|
+
*
|
|
149
|
+
* This allows a user who started in session-only mode to later connect
|
|
150
|
+
* a wallet and gain the ability to create their own space.
|
|
151
|
+
*
|
|
152
|
+
* Note: This does NOT automatically sign in. Call signIn() after connecting
|
|
153
|
+
* the wallet to create your space.
|
|
154
|
+
*
|
|
155
|
+
* @param privateKey - The Ethereum private key (hex string, no 0x prefix)
|
|
156
|
+
* @param options - Optional configuration
|
|
157
|
+
* @param options.prefix - Space name prefix (defaults to "default")
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* // Start in session-only mode
|
|
162
|
+
* const node = new TinyCloudNode({ host: "https://node.tinycloud.xyz" });
|
|
163
|
+
* console.log(node.did); // did:key:z6Mk... (session key)
|
|
164
|
+
*
|
|
165
|
+
* // Later, connect a wallet
|
|
166
|
+
* node.connectWallet(privateKey);
|
|
167
|
+
* await node.signIn();
|
|
168
|
+
* console.log(node.did); // did:pkh:eip155:1:0x... (PKH)
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
connectWallet(privateKey: string, options?: {
|
|
172
|
+
prefix?: string;
|
|
173
|
+
}): void;
|
|
174
|
+
/**
|
|
175
|
+
* Initialize the service context and KV service after sign-in.
|
|
176
|
+
* @internal
|
|
177
|
+
*/
|
|
178
|
+
private initializeServices;
|
|
179
|
+
/**
|
|
180
|
+
* Initialize the v2 delegation system services.
|
|
181
|
+
* @internal
|
|
182
|
+
*/
|
|
183
|
+
private initializeV2Services;
|
|
184
|
+
/**
|
|
185
|
+
* Get the session expiry time.
|
|
186
|
+
* @internal
|
|
187
|
+
*/
|
|
188
|
+
private getSessionExpiry;
|
|
189
|
+
/**
|
|
190
|
+
* Wrapper for the WASM createDelegation function.
|
|
191
|
+
* Adapts the WASM interface to what SharingService expects.
|
|
192
|
+
* @internal
|
|
193
|
+
*/
|
|
194
|
+
private createDelegationWrapper;
|
|
195
|
+
/**
|
|
196
|
+
* Track a received delegation in the capability registry.
|
|
197
|
+
* @internal
|
|
198
|
+
*/
|
|
199
|
+
private trackReceivedDelegation;
|
|
200
|
+
/**
|
|
201
|
+
* Key-value storage operations on this user's space.
|
|
202
|
+
*/
|
|
203
|
+
get kv(): IKVService;
|
|
204
|
+
/**
|
|
205
|
+
* Get the CapabilityKeyRegistry for managing keys and their capabilities.
|
|
206
|
+
*
|
|
207
|
+
* The registry tracks keys (session, main, ingested) and their associated
|
|
208
|
+
* delegations, enabling automatic key selection for operations.
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* ```typescript
|
|
212
|
+
* const registry = alice.capabilityRegistry;
|
|
213
|
+
*
|
|
214
|
+
* // Get the best key for an operation
|
|
215
|
+
* const key = registry.getKeyForCapability(
|
|
216
|
+
* "tinycloud://my-space/kv/data",
|
|
217
|
+
* "tinycloud.kv/get"
|
|
218
|
+
* );
|
|
219
|
+
*
|
|
220
|
+
* // List all capabilities
|
|
221
|
+
* const capabilities = registry.getAllCapabilities();
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
get capabilityRegistry(): ICapabilityKeyRegistry;
|
|
225
|
+
/**
|
|
226
|
+
* Access received delegations (recipient view).
|
|
227
|
+
*
|
|
228
|
+
* Use this to see what delegations have been received via useDelegation().
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* ```typescript
|
|
232
|
+
* // List all received delegations
|
|
233
|
+
* const received = bob.delegations.list();
|
|
234
|
+
* console.log("I have access to:", received.length, "spaces");
|
|
235
|
+
*
|
|
236
|
+
* // Get a specific delegation by CID
|
|
237
|
+
* const delegation = bob.delegations.get(cid);
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
get delegations(): {
|
|
241
|
+
/** List all received delegations */
|
|
242
|
+
list: () => Delegation[];
|
|
243
|
+
/** Get a delegation by CID */
|
|
244
|
+
get: (cid: string) => Delegation | undefined;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* Get the DelegationManager for delegation CRUD operations.
|
|
248
|
+
*
|
|
249
|
+
* This is the v2 delegation service providing a cleaner API than
|
|
250
|
+
* the legacy createDelegation/useDelegation methods.
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```typescript
|
|
254
|
+
* const delegations = alice.delegationManager;
|
|
255
|
+
*
|
|
256
|
+
* // Create a delegation
|
|
257
|
+
* const result = await delegations.create({
|
|
258
|
+
* delegateDID: bob.did,
|
|
259
|
+
* path: "shared/",
|
|
260
|
+
* actions: ["tinycloud.kv/get", "tinycloud.kv/put"],
|
|
261
|
+
* expiry: new Date(Date.now() + 24 * 60 * 60 * 1000), // 24 hours
|
|
262
|
+
* });
|
|
263
|
+
*
|
|
264
|
+
* // List delegations
|
|
265
|
+
* const listResult = await delegations.list();
|
|
266
|
+
*
|
|
267
|
+
* // Revoke a delegation
|
|
268
|
+
* await delegations.revoke(delegationCid);
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
get delegationManager(): DelegationManager;
|
|
272
|
+
/**
|
|
273
|
+
* Get the SpaceService for managing spaces.
|
|
274
|
+
*
|
|
275
|
+
* The SpaceService provides access to owned and delegated spaces,
|
|
276
|
+
* including space creation, listing, and scoped operations.
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```typescript
|
|
280
|
+
* const spaces = alice.spaces;
|
|
281
|
+
*
|
|
282
|
+
* // List all accessible spaces
|
|
283
|
+
* const result = await spaces.list();
|
|
284
|
+
*
|
|
285
|
+
* // Create a new space
|
|
286
|
+
* const createResult = await spaces.create('photos');
|
|
287
|
+
*
|
|
288
|
+
* // Get a space object for operations
|
|
289
|
+
* const mySpace = spaces.get('default');
|
|
290
|
+
* await mySpace.kv.put('key', 'value');
|
|
291
|
+
*
|
|
292
|
+
* // Check if a space exists
|
|
293
|
+
* const exists = await spaces.exists('photos');
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
296
|
+
get spaces(): ISpaceService;
|
|
297
|
+
/**
|
|
298
|
+
* Alias for `spaces` - get the SpaceService.
|
|
299
|
+
* @see spaces
|
|
300
|
+
*/
|
|
301
|
+
get spaceService(): ISpaceService;
|
|
302
|
+
/**
|
|
303
|
+
* Get the SharingService for creating and receiving v2 sharing links.
|
|
304
|
+
*
|
|
305
|
+
* The SharingService creates sharing links with embedded private keys,
|
|
306
|
+
* allowing recipients to exercise delegations without prior session setup.
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* ```typescript
|
|
310
|
+
* const sharing = alice.sharing;
|
|
311
|
+
*
|
|
312
|
+
* // Generate a sharing link
|
|
313
|
+
* const result = await sharing.generate({
|
|
314
|
+
* path: "/kv/documents/report.pdf",
|
|
315
|
+
* actions: ["tinycloud.kv/get"],
|
|
316
|
+
* expiry: new Date(Date.now() + 24 * 60 * 60 * 1000),
|
|
317
|
+
* });
|
|
318
|
+
*
|
|
319
|
+
* if (result.ok) {
|
|
320
|
+
* console.log("Share URL:", result.data.url);
|
|
321
|
+
* // Send the URL to the recipient
|
|
322
|
+
* }
|
|
323
|
+
*
|
|
324
|
+
* // Receive a sharing link
|
|
325
|
+
* const receiveResult = await sharing.receive(shareUrl);
|
|
326
|
+
* if (receiveResult.ok) {
|
|
327
|
+
* // Use the pre-configured KV service
|
|
328
|
+
* const data = await receiveResult.data.kv.get("report.pdf");
|
|
329
|
+
* }
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
get sharing(): ISharingService;
|
|
333
|
+
/**
|
|
334
|
+
* Alias for `sharing` - get the SharingService.
|
|
335
|
+
* @see sharing
|
|
336
|
+
*/
|
|
337
|
+
get sharingService(): ISharingService;
|
|
338
|
+
/**
|
|
339
|
+
* Create a delegation using the v2 DelegationManager.
|
|
340
|
+
*
|
|
341
|
+
* This is a convenience method that wraps DelegationManager.create().
|
|
342
|
+
* For more control, use `this.delegationManager` directly.
|
|
343
|
+
*
|
|
344
|
+
* @param params - Delegation parameters
|
|
345
|
+
* @returns Result containing the created Delegation
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* ```typescript
|
|
349
|
+
* const result = await alice.delegate({
|
|
350
|
+
* delegateDID: bob.did,
|
|
351
|
+
* path: "shared/",
|
|
352
|
+
* actions: ["tinycloud.kv/get", "tinycloud.kv/put"],
|
|
353
|
+
* expiry: new Date(Date.now() + 24 * 60 * 60 * 1000),
|
|
354
|
+
* });
|
|
355
|
+
*
|
|
356
|
+
* if (result.ok) {
|
|
357
|
+
* console.log("Delegation created:", result.data.cid);
|
|
358
|
+
* }
|
|
359
|
+
* ```
|
|
360
|
+
*/
|
|
361
|
+
delegate(params: CreateDelegationParams): Promise<DelegationResult<Delegation>>;
|
|
362
|
+
/**
|
|
363
|
+
* Revoke a delegation using the v2 DelegationManager.
|
|
364
|
+
*
|
|
365
|
+
* @param cid - The CID of the delegation to revoke
|
|
366
|
+
* @returns Result indicating success or failure
|
|
367
|
+
*/
|
|
368
|
+
revokeDelegation(cid: string): Promise<DelegationResult<void>>;
|
|
369
|
+
/**
|
|
370
|
+
* List all delegations for the current session's space.
|
|
371
|
+
*
|
|
372
|
+
* @returns Result containing an array of Delegations
|
|
373
|
+
*/
|
|
374
|
+
listDelegations(): Promise<DelegationResult<Delegation[]>>;
|
|
375
|
+
/**
|
|
376
|
+
* Check if the current session has permission for a path and action.
|
|
377
|
+
*
|
|
378
|
+
* @param path - The resource path to check
|
|
379
|
+
* @param action - The action to check (e.g., "tinycloud.kv/get")
|
|
380
|
+
* @returns Result containing boolean permission status
|
|
381
|
+
*/
|
|
382
|
+
checkPermission(path: string, action: string): Promise<DelegationResult<boolean>>;
|
|
383
|
+
/**
|
|
384
|
+
* Create a delegation from this user to another user.
|
|
385
|
+
*
|
|
386
|
+
* The delegation grants the recipient access to a specific path and actions
|
|
387
|
+
* within this user's space.
|
|
388
|
+
*
|
|
389
|
+
* @param params - Delegation parameters
|
|
390
|
+
* @returns A portable delegation that can be sent to the recipient
|
|
391
|
+
*/
|
|
392
|
+
createDelegation(params: {
|
|
393
|
+
/** Path within the space to delegate access to */
|
|
394
|
+
path: string;
|
|
395
|
+
/** Actions to allow (e.g., ["tinycloud.kv/get", "tinycloud.kv/put"]) */
|
|
396
|
+
actions: string[];
|
|
397
|
+
/** DID of the recipient (from their TinyCloudNode.did) */
|
|
398
|
+
delegateDID: string;
|
|
399
|
+
/** Whether to prevent the recipient from creating sub-delegations (default: false) */
|
|
400
|
+
disableSubDelegation?: boolean;
|
|
401
|
+
/** Expiration time in milliseconds from now (default: 1 hour) */
|
|
402
|
+
expiryMs?: number;
|
|
403
|
+
}): Promise<PortableDelegation>;
|
|
404
|
+
/**
|
|
405
|
+
* Use a delegation received from another user.
|
|
406
|
+
*
|
|
407
|
+
* This creates a new session key for this user that chains from the
|
|
408
|
+
* received delegation, allowing operations on the delegator's space.
|
|
409
|
+
*
|
|
410
|
+
* Works in both modes:
|
|
411
|
+
* - **Wallet mode**: Creates a SIWE sub-delegation from PKH to session key
|
|
412
|
+
* - **Session-only mode**: Uses the delegation directly (must target session key DID)
|
|
413
|
+
*
|
|
414
|
+
* @param delegation - The PortableDelegation to use (from createDelegation or transport)
|
|
415
|
+
* @returns A DelegatedAccess instance for performing operations
|
|
416
|
+
*/
|
|
417
|
+
useDelegation(delegation: PortableDelegation): Promise<DelegatedAccess>;
|
|
418
|
+
/**
|
|
419
|
+
* Create a sub-delegation from a received delegation.
|
|
420
|
+
*
|
|
421
|
+
* This allows further delegating access that was received from another user,
|
|
422
|
+
* if the original delegation allows sub-delegation.
|
|
423
|
+
*
|
|
424
|
+
* @param parentDelegation - The delegation received from another user
|
|
425
|
+
* @param params - Sub-delegation parameters (must be within parent's scope)
|
|
426
|
+
* @returns A portable delegation for the sub-delegate
|
|
427
|
+
*/
|
|
428
|
+
createSubDelegation(parentDelegation: PortableDelegation, params: {
|
|
429
|
+
/** Path within the delegated path to sub-delegate */
|
|
430
|
+
path: string;
|
|
431
|
+
/** Actions to allow (must be subset of parent's actions) */
|
|
432
|
+
actions: string[];
|
|
433
|
+
/** DID of the recipient */
|
|
434
|
+
delegateDID: string;
|
|
435
|
+
/** Whether to prevent the recipient from creating further sub-delegations */
|
|
436
|
+
disableSubDelegation?: boolean;
|
|
437
|
+
/** Expiration time in milliseconds from now (must be before parent's expiry) */
|
|
438
|
+
expiryMs?: number;
|
|
439
|
+
}): Promise<PortableDelegation>;
|
|
440
|
+
}
|
|
441
|
+
//# sourceMappingURL=TinyCloudNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TinyCloudNode.d.ts","sourceRoot":"","sources":["../src/TinyCloudNode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAEL,gBAAgB,EAGhB,UAAU,EAIV,iBAAiB,EAEjB,aAAa,EAEb,sBAAsB,EAEtB,eAAe,EAEf,UAAU,EACV,sBAAsB,EAGtB,gBAAgB,EAGjB,MAAM,yBAAyB,CAAC;AAejC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAMpD;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