@tinycloud/sdk-core 2.1.0-beta.0 → 2.1.0-beta.2
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/dist/index.cjs +559 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +579 -73
- package/dist/index.d.ts +579 -73
- package/dist/index.js +531 -13
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
package/dist/index.d.ts
CHANGED
|
@@ -179,6 +179,416 @@ interface IENSResolver {
|
|
|
179
179
|
resolveAvatar?(ensName: string): Promise<string | null>;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
+
/**
|
|
183
|
+
* TinyCloud App Manifest
|
|
184
|
+
*
|
|
185
|
+
* A declarative description of an app's identity and the capabilities it
|
|
186
|
+
* needs. The manifest drives the SIWE recap at sign-in time, enabling a
|
|
187
|
+
* single wallet prompt that covers the app's own permissions plus any
|
|
188
|
+
* pre-declared delegations.
|
|
189
|
+
*
|
|
190
|
+
* The SDK does NOT fetch external manifests. Apps compose their own manifest
|
|
191
|
+
* (optionally including backend or agent addenda) before handing it to the
|
|
192
|
+
* SDK.
|
|
193
|
+
*
|
|
194
|
+
* Canonical spec: `.claude/specs/manifest.md`.
|
|
195
|
+
*
|
|
196
|
+
* @packageDocumentation
|
|
197
|
+
*/
|
|
198
|
+
/**
|
|
199
|
+
* A single permission entry inside a manifest. This is the shape apps write
|
|
200
|
+
* in their `manifest.json` and the shape we compare against when performing
|
|
201
|
+
* the capability-subset derivability check in the delegation flow.
|
|
202
|
+
*
|
|
203
|
+
* `service` uses the long form (e.g. `"tinycloud.kv"`, `"tinycloud.sql"`)
|
|
204
|
+
* which matches the ability-namespace half of the full action URN.
|
|
205
|
+
*/
|
|
206
|
+
interface PermissionEntry {
|
|
207
|
+
/** Service namespace, e.g. "tinycloud.kv", "tinycloud.sql", "tinycloud.duckdb", "tinycloud.capabilities". */
|
|
208
|
+
service: string;
|
|
209
|
+
/** "default" for the user's personal space, or a specific space id. */
|
|
210
|
+
space: string;
|
|
211
|
+
/**
|
|
212
|
+
* Service-specific path.
|
|
213
|
+
* - tinycloud.kv: hierarchical prefix. "/" = all, "foo/" = prefix match, "foo" = exact key
|
|
214
|
+
* - tinycloud.sql: database name/file (e.g. "data.sqlite") or "/" for all
|
|
215
|
+
* - tinycloud.duckdb: database name/file
|
|
216
|
+
* - tinycloud.capabilities: capability key URI or "/" for all
|
|
217
|
+
*/
|
|
218
|
+
path: string;
|
|
219
|
+
/**
|
|
220
|
+
* Short action names (e.g. "get", "put", "read", "ddl"). The SDK expands
|
|
221
|
+
* these to full URNs (e.g. `tinycloud.kv/get`) during resolution.
|
|
222
|
+
* Already-expanded URNs are passed through unchanged.
|
|
223
|
+
*/
|
|
224
|
+
actions: string[];
|
|
225
|
+
/** When true, the manifest prefix is NOT prepended to `path`. Default false. */
|
|
226
|
+
skipPrefix?: boolean;
|
|
227
|
+
/** Per-entry expiry override, ms-format. */
|
|
228
|
+
expiry?: string;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* A pre-declared delegation that will be included in the main SIWE recap as
|
|
232
|
+
* an additional audience.
|
|
233
|
+
*/
|
|
234
|
+
interface ManifestDelegation {
|
|
235
|
+
/** DID of the delegate (e.g. a backend's wallet DID). */
|
|
236
|
+
to: string;
|
|
237
|
+
/** Informational display name. Optional. */
|
|
238
|
+
name?: string;
|
|
239
|
+
/** Expiry override for this delegation, ms-format. Optional. */
|
|
240
|
+
expiry?: string;
|
|
241
|
+
/**
|
|
242
|
+
* Permissions to delegate. Same shape as the top-level `permissions`, and
|
|
243
|
+
* the manifest prefix is inherited identically (unless `skipPrefix: true`).
|
|
244
|
+
*/
|
|
245
|
+
permissions: PermissionEntry[];
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* The valid values for `Manifest.defaults`.
|
|
249
|
+
*
|
|
250
|
+
* - `false` → no auto-included permissions
|
|
251
|
+
* - `true` → standard tier (KV + SQL read/write + capabilities:read)
|
|
252
|
+
* - `"admin"` → standard + SQL ddl + capabilities:admin
|
|
253
|
+
* - `"all"` → everything the SDK supports (including DuckDB)
|
|
254
|
+
*
|
|
255
|
+
* Unknown string values silently fall back to `true`. Values are normalized
|
|
256
|
+
* (lowercase + trim) before matching.
|
|
257
|
+
*/
|
|
258
|
+
type ManifestDefaults = boolean | "admin" | "all";
|
|
259
|
+
/**
|
|
260
|
+
* The raw manifest shape an app declares. See `.claude/specs/manifest.md`.
|
|
261
|
+
*/
|
|
262
|
+
interface Manifest {
|
|
263
|
+
/** Schema version. Optional, defaults to 1. */
|
|
264
|
+
version?: number;
|
|
265
|
+
/** Bundle identifier — reverse DNS. Required. */
|
|
266
|
+
id: string;
|
|
267
|
+
/** Display name. Required. */
|
|
268
|
+
name: string;
|
|
269
|
+
/** One-line description. Optional. */
|
|
270
|
+
description?: string;
|
|
271
|
+
/** URL to app icon. Optional. */
|
|
272
|
+
icon?: string;
|
|
273
|
+
/** App version string. Optional. */
|
|
274
|
+
appVersion?: string;
|
|
275
|
+
/** Default expiry for permissions. ms-format ("30d", "2h", "1y"). Default "30d". */
|
|
276
|
+
expiry?: string;
|
|
277
|
+
/**
|
|
278
|
+
* Path prefix auto-prepended to permission paths. Optional, defaults to
|
|
279
|
+
* `id`. Set to `""` to disable entirely. Individual permissions can opt
|
|
280
|
+
* out with `skipPrefix: true`.
|
|
281
|
+
*/
|
|
282
|
+
prefix?: string;
|
|
283
|
+
/**
|
|
284
|
+
* Default permission set to auto-include. Optional, defaults to `true`.
|
|
285
|
+
* See {@link ManifestDefaults}.
|
|
286
|
+
*/
|
|
287
|
+
defaults?: ManifestDefaults | string;
|
|
288
|
+
/** Whether to include the public-space companion delegation. Default `true`. */
|
|
289
|
+
includePublicSpace?: boolean;
|
|
290
|
+
/**
|
|
291
|
+
* Additional permissions beyond the defaults. Use for cross-space access,
|
|
292
|
+
* DuckDB (opt-in), or `skipPrefix: true` entries.
|
|
293
|
+
*/
|
|
294
|
+
permissions?: PermissionEntry[];
|
|
295
|
+
/** Pre-delegations to other DIDs at sign-in. */
|
|
296
|
+
delegations?: ManifestDelegation[];
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* A resolved permission entry with fully-expanded paths and action URNs.
|
|
300
|
+
* This is the shape the delegation flow compares against parsed recap
|
|
301
|
+
* capabilities, and the shape the session-key delegation path actually uses.
|
|
302
|
+
*/
|
|
303
|
+
interface ResourceCapability {
|
|
304
|
+
/** Long-form service, e.g. "tinycloud.kv". */
|
|
305
|
+
service: string;
|
|
306
|
+
/** Space id — "default" stays as-is here; the caller resolves it to a full SpaceId at sign-in time. */
|
|
307
|
+
space: string;
|
|
308
|
+
/** Path with the manifest prefix applied (or skipped per `skipPrefix`). */
|
|
309
|
+
path: string;
|
|
310
|
+
/** Full-URN actions, e.g. ["tinycloud.kv/get", "tinycloud.kv/put"]. */
|
|
311
|
+
actions: string[];
|
|
312
|
+
/** Per-entry expiry override in milliseconds. */
|
|
313
|
+
expiryMs?: number;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* A resolved delegation entry with fully-expanded permissions.
|
|
317
|
+
*/
|
|
318
|
+
interface ResolvedDelegate {
|
|
319
|
+
/** DID of the delegate. */
|
|
320
|
+
did: string;
|
|
321
|
+
/** Informational display name. Optional. */
|
|
322
|
+
name?: string;
|
|
323
|
+
/** Expiry in milliseconds (per-delegation > manifest default > 30 days). */
|
|
324
|
+
expiryMs: number;
|
|
325
|
+
/** Fully resolved permissions. */
|
|
326
|
+
permissions: ResourceCapability[];
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* The output of {@link resolveManifest}: a fully-expanded capability set
|
|
330
|
+
* ready to drive the SIWE recap.
|
|
331
|
+
*/
|
|
332
|
+
interface ResolvedCapabilities {
|
|
333
|
+
/** Bundle identifier copied from manifest.id. */
|
|
334
|
+
id: string;
|
|
335
|
+
/** All session-key resources with paths fully resolved (prefix applied). */
|
|
336
|
+
resources: ResourceCapability[];
|
|
337
|
+
/** Default expiry for the session, in milliseconds. */
|
|
338
|
+
expiryMs: number;
|
|
339
|
+
/** Whether to include the public-space companion. */
|
|
340
|
+
includePublicSpace: boolean;
|
|
341
|
+
/** Additional delegate targets with resolved paths. */
|
|
342
|
+
additionalDelegates: ResolvedDelegate[];
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Thrown when the manifest fails validation (missing id/name, bad expiry,
|
|
346
|
+
* empty actions on a permission, etc).
|
|
347
|
+
*/
|
|
348
|
+
declare class ManifestValidationError extends Error {
|
|
349
|
+
constructor(message: string);
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Default expiry when neither the manifest, delegation, nor permission
|
|
353
|
+
* specifies one. Spec: 30 days.
|
|
354
|
+
*/
|
|
355
|
+
declare const DEFAULT_EXPIRY = "30d";
|
|
356
|
+
/**
|
|
357
|
+
* Default `defaults` value when the manifest omits it. Spec: standard tier.
|
|
358
|
+
*/
|
|
359
|
+
declare const DEFAULT_DEFAULTS: ManifestDefaults;
|
|
360
|
+
/**
|
|
361
|
+
* Known services and their short-form (recap URI) names. The TinyCloud
|
|
362
|
+
* node encodes the recap resource URI with the short service name, while
|
|
363
|
+
* action URNs and manifest entries use the long `tinycloud.<short>` form.
|
|
364
|
+
* This table is the canonical bridge between the two.
|
|
365
|
+
*/
|
|
366
|
+
declare const SERVICE_SHORT_TO_LONG: Readonly<Record<string, string>>;
|
|
367
|
+
/**
|
|
368
|
+
* Inverse of {@link SERVICE_SHORT_TO_LONG}.
|
|
369
|
+
*/
|
|
370
|
+
declare const SERVICE_LONG_TO_SHORT: Readonly<Record<string, string>>;
|
|
371
|
+
/**
|
|
372
|
+
* Parse an ms-format duration string (e.g. "30d", "2h", "1y") into
|
|
373
|
+
* milliseconds.
|
|
374
|
+
*
|
|
375
|
+
* @throws {ManifestValidationError} on empty string, non-string input, or
|
|
376
|
+
* any input `ms()` cannot parse.
|
|
377
|
+
*/
|
|
378
|
+
declare function parseExpiry(duration: string): number;
|
|
379
|
+
/**
|
|
380
|
+
* Expand a list of action short names (or already-expanded URNs) into full
|
|
381
|
+
* ability URNs of the form `<service>/<action>`.
|
|
382
|
+
*
|
|
383
|
+
* Examples:
|
|
384
|
+
* `expandActionShortNames("tinycloud.kv", ["get", "put"])`
|
|
385
|
+
* → `["tinycloud.kv/get", "tinycloud.kv/put"]`
|
|
386
|
+
* `expandActionShortNames("tinycloud.kv", ["tinycloud.kv/get"])`
|
|
387
|
+
* → `["tinycloud.kv/get"]` (passed through unchanged)
|
|
388
|
+
*/
|
|
389
|
+
declare function expandActionShortNames(service: string, actions: readonly string[]): string[];
|
|
390
|
+
/**
|
|
391
|
+
* Apply the manifest prefix to a permission path per the spec rules.
|
|
392
|
+
*
|
|
393
|
+
* - `skipPrefix: true` → path is returned as-is
|
|
394
|
+
* - `prefix === ""` → path is returned as-is
|
|
395
|
+
* - path starts with "/" → `prefix + path` (e.g. "com.listen.app" + "/" → "com.listen.app/")
|
|
396
|
+
* - otherwise → `prefix + "/" + path` (e.g. "com.listen.app" + "data.sqlite" → "com.listen.app/data.sqlite")
|
|
397
|
+
*/
|
|
398
|
+
declare function applyPrefix(prefix: string, path: string, skipPrefix: boolean): string;
|
|
399
|
+
/**
|
|
400
|
+
* Fetch and parse a manifest from a URL (browser) or file path (node).
|
|
401
|
+
* The runtime decides the fetch strategy via `globalThis.fetch`; this is
|
|
402
|
+
* platform-agnostic. Callers that want custom loading should JSON.parse a
|
|
403
|
+
* Manifest themselves and skip this helper.
|
|
404
|
+
*
|
|
405
|
+
* @throws if the fetch fails, the JSON is invalid, or the manifest fails
|
|
406
|
+
* validation.
|
|
407
|
+
*/
|
|
408
|
+
declare function loadManifest(url: string): Promise<Manifest>;
|
|
409
|
+
/**
|
|
410
|
+
* Validate a manifest-shaped object and return it strongly-typed.
|
|
411
|
+
* Throws {@link ManifestValidationError} on any hard failure.
|
|
412
|
+
*/
|
|
413
|
+
declare function validateManifest(input: unknown): Manifest;
|
|
414
|
+
/**
|
|
415
|
+
* Normalize a `defaults` value: lowercase + trim, then match against known
|
|
416
|
+
* tiers. Unknown string values silently fall back to `true` (standard).
|
|
417
|
+
* Boolean values pass through.
|
|
418
|
+
*/
|
|
419
|
+
declare function normalizeDefaults(value: Manifest["defaults"] | undefined): ManifestDefaults;
|
|
420
|
+
/**
|
|
421
|
+
* Resolve a raw manifest into a {@link ResolvedCapabilities} object: expand
|
|
422
|
+
* shortform actions, apply the prefix, merge defaults, and compute effective
|
|
423
|
+
* expiries. Pure function — does no I/O.
|
|
424
|
+
*
|
|
425
|
+
* Resolution semantics (spec):
|
|
426
|
+
* - `prefix` defaults to `id`; set to `""` to disable prefix application entirely.
|
|
427
|
+
* - `defaults` defaults to `true` (standard tier); unknown string values fall back to `true`.
|
|
428
|
+
* - Per-entry expiry overrides per-delegation overrides manifest > `DEFAULT_EXPIRY`.
|
|
429
|
+
* - Default entries use `skipPrefix: false` so they inherit the manifest prefix.
|
|
430
|
+
* - Prefix inheritance applies identically to `permissions` and `delegations[*].permissions`.
|
|
431
|
+
*/
|
|
432
|
+
declare function resolveManifest(input: Manifest): ResolvedCapabilities;
|
|
433
|
+
/**
|
|
434
|
+
* The shape `prepareSession` and the multi-resource `createDelegation` WASM
|
|
435
|
+
* export both accept:
|
|
436
|
+
*
|
|
437
|
+
* ```
|
|
438
|
+
* { [shortService]: { [path]: [fullUrnAction, ...] } }
|
|
439
|
+
* ```
|
|
440
|
+
*
|
|
441
|
+
* - `shortService` is the recap-level service segment (`"kv"`, `"sql"`,
|
|
442
|
+
* `"duckdb"`, `"capabilities"`, `"hooks"`) — not the manifest long form.
|
|
443
|
+
* - `path` is the fully-resolved path (prefix already applied). An empty
|
|
444
|
+
* string means "no path segment" on the resource URI.
|
|
445
|
+
* - Action strings are full URNs like `"tinycloud.kv/get"`.
|
|
446
|
+
*
|
|
447
|
+
* This is a single source of truth for both the session's own recap (at
|
|
448
|
+
* sign-in) and the delegations it can derive (post sign-in). We re-use it
|
|
449
|
+
* for both so one manifest drives both sides.
|
|
450
|
+
*/
|
|
451
|
+
type AbilitiesMap = Record<string, Record<string, string[]>>;
|
|
452
|
+
/**
|
|
453
|
+
* Convert a list of {@link ResourceCapability} entries (manifest
|
|
454
|
+
* long-form service, full-URN actions) into the {@link AbilitiesMap}
|
|
455
|
+
* shape the WASM layer expects.
|
|
456
|
+
*
|
|
457
|
+
* When multiple entries target the same `(service, path)` pair, their
|
|
458
|
+
* action lists are merged and deduped. Entries whose service has no
|
|
459
|
+
* short-form mapping in {@link SERVICE_LONG_TO_SHORT} are rejected with
|
|
460
|
+
* a {@link ManifestValidationError} — the SDK does not silently drop
|
|
461
|
+
* unknown services because the recap encoding would lose them.
|
|
462
|
+
*
|
|
463
|
+
* Paths are kept verbatim: this function does NOT collapse
|
|
464
|
+
* `"com.listen.app/"` and `"com.listen.app"` or reinterpret empty /
|
|
465
|
+
* slash strings. Callers that care about path canonicalization should
|
|
466
|
+
* normalize before calling.
|
|
467
|
+
*/
|
|
468
|
+
declare function resourceCapabilitiesToAbilitiesMap(resources: readonly ResourceCapability[]): AbilitiesMap;
|
|
469
|
+
/**
|
|
470
|
+
* Build the {@link AbilitiesMap} that a session should be signed with,
|
|
471
|
+
* given a {@link ResolvedCapabilities} (i.e. the output of
|
|
472
|
+
* {@link resolveManifest}).
|
|
473
|
+
*
|
|
474
|
+
* The resulting map is the **union** of:
|
|
475
|
+
* 1. the app's own resources (`resolved.resources`), and
|
|
476
|
+
* 2. every permission declared in every `additionalDelegates[*]` entry.
|
|
477
|
+
*
|
|
478
|
+
* The union is what makes the manifest's delegations ergonomic: at
|
|
479
|
+
* sign-in, the session key acquires recap coverage for both the app's
|
|
480
|
+
* runtime needs and every downstream delegation target. Post sign-in,
|
|
481
|
+
* `delegateTo(backendDID, backendPermissions)` can then issue the
|
|
482
|
+
* sub-delegation via the session key (no wallet prompt) because the
|
|
483
|
+
* caps are already part of the granted set.
|
|
484
|
+
*
|
|
485
|
+
* Duplicate `(service, path, action)` triples across resources and
|
|
486
|
+
* delegations are merged and deduped — the session SIWE doesn't need
|
|
487
|
+
* them repeated.
|
|
488
|
+
*/
|
|
489
|
+
declare function manifestAbilitiesUnion(resolved: ResolvedCapabilities): AbilitiesMap;
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Capability subset checking and recap parsing.
|
|
493
|
+
*
|
|
494
|
+
* This module powers the capability-chain delegation flow. The key decision
|
|
495
|
+
* a `delegateTo` call has to make is: "are the requested capabilities a
|
|
496
|
+
* subset of what the current session already grants?"
|
|
497
|
+
*
|
|
498
|
+
* - If yes → issue the delegation via the session-key UCAN path (no wallet prompt).
|
|
499
|
+
* - If no → raise {@link PermissionNotInManifestError} so the caller can
|
|
500
|
+
* trigger an escalation flow via `requestPermissions`.
|
|
501
|
+
*
|
|
502
|
+
* Canonical spec: `.claude/specs/capability-chain.md`.
|
|
503
|
+
*
|
|
504
|
+
* @packageDocumentation
|
|
505
|
+
*/
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Thrown when a `delegateTo` call requests capabilities that the current
|
|
509
|
+
* session does not already grant. The caller can catch this and trigger
|
|
510
|
+
* `requestPermissions(missing)` to show an escalation modal.
|
|
511
|
+
*/
|
|
512
|
+
declare class PermissionNotInManifestError extends Error {
|
|
513
|
+
readonly missing: PermissionEntry[];
|
|
514
|
+
readonly granted: PermissionEntry[];
|
|
515
|
+
constructor(missing: PermissionEntry[], granted: PermissionEntry[]);
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Thrown when the current session has expired (or will expire within the
|
|
519
|
+
* safety margin). The caller should trigger a fresh sign-in.
|
|
520
|
+
*/
|
|
521
|
+
declare class SessionExpiredError extends Error {
|
|
522
|
+
readonly expiredAt: Date;
|
|
523
|
+
constructor(expiredAt: Date);
|
|
524
|
+
}
|
|
525
|
+
interface SubsetCheckResult {
|
|
526
|
+
/** True when every requested entry is covered by a granted entry. */
|
|
527
|
+
subset: boolean;
|
|
528
|
+
/** Entries the granted set does not cover (empty when `subset` is true). */
|
|
529
|
+
missing: PermissionEntry[];
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Check whether `requested` is a strict subset of `granted`.
|
|
533
|
+
*
|
|
534
|
+
* Matching rules for each `requested[i]`:
|
|
535
|
+
* - `service` matches exactly.
|
|
536
|
+
* - `space` matches exactly.
|
|
537
|
+
* - Path containment:
|
|
538
|
+
* - If `granted.path` ends with `/`, it covers any `requested.path` that
|
|
539
|
+
* starts with `granted.path`.
|
|
540
|
+
* - Otherwise, the paths must match exactly.
|
|
541
|
+
* - Action containment: every URN in `requested.actions` must appear in
|
|
542
|
+
* `granted.actions` (set subset).
|
|
543
|
+
*
|
|
544
|
+
* Any `requested` entry that does not find a matching `granted` entry is
|
|
545
|
+
* added to `missing` and the overall result is non-subset.
|
|
546
|
+
*
|
|
547
|
+
* Both sides are expected to be in the canonical long-form shape (service
|
|
548
|
+
* starts with `tinycloud.`, actions are full URNs). Use {@link parseRecapCapabilities}
|
|
549
|
+
* or `expandActionShortNames` to normalize inputs first.
|
|
550
|
+
*/
|
|
551
|
+
declare function isCapabilitySubset(requested: readonly PermissionEntry[], granted: readonly PermissionEntry[]): SubsetCheckResult;
|
|
552
|
+
/**
|
|
553
|
+
* The raw shape returned from the WASM `parseRecapFromSiwe` export. The
|
|
554
|
+
* Rust layer encodes the service in the short form (e.g. `"kv"`) because
|
|
555
|
+
* that is what the SIWE recap resource URI actually contains. We normalize
|
|
556
|
+
* to the manifest long form (`"tinycloud.kv"`) in {@link parseRecapCapabilities}.
|
|
557
|
+
*
|
|
558
|
+
* @internal
|
|
559
|
+
*/
|
|
560
|
+
interface WasmRecapEntry {
|
|
561
|
+
service: string;
|
|
562
|
+
space: string;
|
|
563
|
+
path: string;
|
|
564
|
+
actions: string[];
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Signature of the WASM `parseRecapFromSiwe` export. Accepts the signed
|
|
568
|
+
* SIWE message string and returns an array of raw recap entries. Throws if
|
|
569
|
+
* the SIWE is malformed or the recap statement has been tampered.
|
|
570
|
+
*
|
|
571
|
+
* Exposed as an interface so the SDK can inject the web or node binding
|
|
572
|
+
* without `capabilities.ts` needing to know which.
|
|
573
|
+
*/
|
|
574
|
+
type ParseRecapFromSiwe = (siweString: string) => WasmRecapEntry[];
|
|
575
|
+
/**
|
|
576
|
+
* Parse a signed SIWE message into an array of {@link PermissionEntry}
|
|
577
|
+
* objects in the canonical long-form manifest shape.
|
|
578
|
+
*
|
|
579
|
+
* This is a thin wrapper around the WASM `parseRecapFromSiwe` export that:
|
|
580
|
+
* 1. Normalizes short-form services (`"kv"`) to long-form (`"tinycloud.kv"`).
|
|
581
|
+
* 2. Returns entries in a deterministic order (sorted by space, then service,
|
|
582
|
+
* then path) so downstream equality checks are stable.
|
|
583
|
+
*
|
|
584
|
+
* Returns an empty array when the SIWE has no recap resource (plain auth
|
|
585
|
+
* SIWE); this matches the WASM function's behavior and the spec.
|
|
586
|
+
*
|
|
587
|
+
* @param parseWasm The WASM `parseRecapFromSiwe` binding.
|
|
588
|
+
* @param siwe The signed SIWE message string (exactly what `session.siwe` stores).
|
|
589
|
+
*/
|
|
590
|
+
declare function parseRecapCapabilities(parseWasm: ParseRecapFromSiwe, siwe: string): PermissionEntry[];
|
|
591
|
+
|
|
182
592
|
/**
|
|
183
593
|
* WASM binding abstraction for TinyCloud SDK.
|
|
184
594
|
*
|
|
@@ -210,6 +620,15 @@ interface IWasmBindings {
|
|
|
210
620
|
makeSpaceId: (address: string, chainId: number, prefix: string) => string;
|
|
211
621
|
/** Create a delegation */
|
|
212
622
|
createDelegation: (...args: any[]) => any;
|
|
623
|
+
/**
|
|
624
|
+
* Parse the recap resource of a signed SIWE message into structured
|
|
625
|
+
* permission entries. Used by the capability-chain delegation flow to
|
|
626
|
+
* decide whether a requested delegation is derivable from the current
|
|
627
|
+
* session without a fresh wallet prompt.
|
|
628
|
+
*
|
|
629
|
+
* Returns an empty array when the SIWE has no recap resource.
|
|
630
|
+
*/
|
|
631
|
+
parseRecapFromSiwe: (siweString: string) => WasmRecapEntry[];
|
|
213
632
|
/** Generate a host SIWE message for space activation */
|
|
214
633
|
generateHostSIWEMessage: (params: any) => string;
|
|
215
634
|
/** Convert a signed SIWE message to delegation headers */
|
|
@@ -837,11 +1256,11 @@ declare const DelegationSchema: z.ZodObject<{
|
|
|
837
1256
|
authHeader: z.ZodOptional<z.ZodString>;
|
|
838
1257
|
}, "strip", z.ZodTypeAny, {
|
|
839
1258
|
path: string;
|
|
1259
|
+
actions: string[];
|
|
1260
|
+
expiry: Date;
|
|
840
1261
|
spaceId: string;
|
|
841
1262
|
cid: string;
|
|
842
1263
|
delegateDID: string;
|
|
843
|
-
actions: string[];
|
|
844
|
-
expiry: Date;
|
|
845
1264
|
isRevoked: boolean;
|
|
846
1265
|
createdAt?: Date | undefined;
|
|
847
1266
|
delegatorDID?: string | undefined;
|
|
@@ -850,11 +1269,11 @@ declare const DelegationSchema: z.ZodObject<{
|
|
|
850
1269
|
authHeader?: string | undefined;
|
|
851
1270
|
}, {
|
|
852
1271
|
path: string;
|
|
1272
|
+
actions: string[];
|
|
1273
|
+
expiry: Date;
|
|
853
1274
|
spaceId: string;
|
|
854
1275
|
cid: string;
|
|
855
1276
|
delegateDID: string;
|
|
856
|
-
actions: string[];
|
|
857
|
-
expiry: Date;
|
|
858
1277
|
isRevoked: boolean;
|
|
859
1278
|
createdAt?: Date | undefined;
|
|
860
1279
|
delegatorDID?: string | undefined;
|
|
@@ -995,11 +1414,11 @@ declare const CapabilityEntrySchema: z.ZodObject<{
|
|
|
995
1414
|
authHeader: z.ZodOptional<z.ZodString>;
|
|
996
1415
|
}, "strip", z.ZodTypeAny, {
|
|
997
1416
|
path: string;
|
|
1417
|
+
actions: string[];
|
|
1418
|
+
expiry: Date;
|
|
998
1419
|
spaceId: string;
|
|
999
1420
|
cid: string;
|
|
1000
1421
|
delegateDID: string;
|
|
1001
|
-
actions: string[];
|
|
1002
|
-
expiry: Date;
|
|
1003
1422
|
isRevoked: boolean;
|
|
1004
1423
|
createdAt?: Date | undefined;
|
|
1005
1424
|
delegatorDID?: string | undefined;
|
|
@@ -1008,11 +1427,11 @@ declare const CapabilityEntrySchema: z.ZodObject<{
|
|
|
1008
1427
|
authHeader?: string | undefined;
|
|
1009
1428
|
}, {
|
|
1010
1429
|
path: string;
|
|
1430
|
+
actions: string[];
|
|
1431
|
+
expiry: Date;
|
|
1011
1432
|
spaceId: string;
|
|
1012
1433
|
cid: string;
|
|
1013
1434
|
delegateDID: string;
|
|
1014
|
-
actions: string[];
|
|
1015
|
-
expiry: Date;
|
|
1016
1435
|
isRevoked: boolean;
|
|
1017
1436
|
createdAt?: Date | undefined;
|
|
1018
1437
|
delegatorDID?: string | undefined;
|
|
@@ -1044,11 +1463,11 @@ declare const CapabilityEntrySchema: z.ZodObject<{
|
|
|
1044
1463
|
}[];
|
|
1045
1464
|
delegation: {
|
|
1046
1465
|
path: string;
|
|
1466
|
+
actions: string[];
|
|
1467
|
+
expiry: Date;
|
|
1047
1468
|
spaceId: string;
|
|
1048
1469
|
cid: string;
|
|
1049
1470
|
delegateDID: string;
|
|
1050
|
-
actions: string[];
|
|
1051
|
-
expiry: Date;
|
|
1052
1471
|
isRevoked: boolean;
|
|
1053
1472
|
createdAt?: Date | undefined;
|
|
1054
1473
|
delegatorDID?: string | undefined;
|
|
@@ -1081,11 +1500,11 @@ declare const CapabilityEntrySchema: z.ZodObject<{
|
|
|
1081
1500
|
}[];
|
|
1082
1501
|
delegation: {
|
|
1083
1502
|
path: string;
|
|
1503
|
+
actions: string[];
|
|
1504
|
+
expiry: Date;
|
|
1084
1505
|
spaceId: string;
|
|
1085
1506
|
cid: string;
|
|
1086
1507
|
delegateDID: string;
|
|
1087
|
-
actions: string[];
|
|
1088
|
-
expiry: Date;
|
|
1089
1508
|
isRevoked: boolean;
|
|
1090
1509
|
createdAt?: Date | undefined;
|
|
1091
1510
|
delegatorDID?: string | undefined;
|
|
@@ -1128,10 +1547,10 @@ declare const DelegationRecordSchema: z.ZodObject<{
|
|
|
1128
1547
|
parentCid: z.ZodOptional<z.ZodString>;
|
|
1129
1548
|
}, "strip", z.ZodTypeAny, {
|
|
1130
1549
|
path: string;
|
|
1550
|
+
actions: string[];
|
|
1131
1551
|
spaceId: string;
|
|
1132
1552
|
createdAt: Date;
|
|
1133
1553
|
cid: string;
|
|
1134
|
-
actions: string[];
|
|
1135
1554
|
isRevoked: boolean;
|
|
1136
1555
|
delegator: string;
|
|
1137
1556
|
delegatee: string;
|
|
@@ -1141,10 +1560,10 @@ declare const DelegationRecordSchema: z.ZodObject<{
|
|
|
1141
1560
|
keyId?: string | undefined;
|
|
1142
1561
|
}, {
|
|
1143
1562
|
path: string;
|
|
1563
|
+
actions: string[];
|
|
1144
1564
|
spaceId: string;
|
|
1145
1565
|
createdAt: Date;
|
|
1146
1566
|
cid: string;
|
|
1147
|
-
actions: string[];
|
|
1148
1567
|
isRevoked: boolean;
|
|
1149
1568
|
delegator: string;
|
|
1150
1569
|
delegatee: string;
|
|
@@ -1172,15 +1591,15 @@ declare const CreateDelegationParamsSchema: z.ZodObject<{
|
|
|
1172
1591
|
statement: z.ZodOptional<z.ZodString>;
|
|
1173
1592
|
}, "strip", z.ZodTypeAny, {
|
|
1174
1593
|
path: string;
|
|
1175
|
-
delegateDID: string;
|
|
1176
1594
|
actions: string[];
|
|
1595
|
+
delegateDID: string;
|
|
1177
1596
|
statement?: string | undefined;
|
|
1178
1597
|
expiry?: Date | undefined;
|
|
1179
1598
|
disableSubDelegation?: boolean | undefined;
|
|
1180
1599
|
}, {
|
|
1181
1600
|
path: string;
|
|
1182
|
-
delegateDID: string;
|
|
1183
1601
|
actions: string[];
|
|
1602
|
+
delegateDID: string;
|
|
1184
1603
|
statement?: string | undefined;
|
|
1185
1604
|
expiry?: Date | undefined;
|
|
1186
1605
|
disableSubDelegation?: boolean | undefined;
|
|
@@ -1216,11 +1635,11 @@ declare const DelegationChainSchema: z.ZodArray<z.ZodObject<{
|
|
|
1216
1635
|
authHeader: z.ZodOptional<z.ZodString>;
|
|
1217
1636
|
}, "strip", z.ZodTypeAny, {
|
|
1218
1637
|
path: string;
|
|
1638
|
+
actions: string[];
|
|
1639
|
+
expiry: Date;
|
|
1219
1640
|
spaceId: string;
|
|
1220
1641
|
cid: string;
|
|
1221
1642
|
delegateDID: string;
|
|
1222
|
-
actions: string[];
|
|
1223
|
-
expiry: Date;
|
|
1224
1643
|
isRevoked: boolean;
|
|
1225
1644
|
createdAt?: Date | undefined;
|
|
1226
1645
|
delegatorDID?: string | undefined;
|
|
@@ -1229,11 +1648,11 @@ declare const DelegationChainSchema: z.ZodArray<z.ZodObject<{
|
|
|
1229
1648
|
authHeader?: string | undefined;
|
|
1230
1649
|
}, {
|
|
1231
1650
|
path: string;
|
|
1651
|
+
actions: string[];
|
|
1652
|
+
expiry: Date;
|
|
1232
1653
|
spaceId: string;
|
|
1233
1654
|
cid: string;
|
|
1234
1655
|
delegateDID: string;
|
|
1235
|
-
actions: string[];
|
|
1236
|
-
expiry: Date;
|
|
1237
1656
|
isRevoked: boolean;
|
|
1238
1657
|
createdAt?: Date | undefined;
|
|
1239
1658
|
delegatorDID?: string | undefined;
|
|
@@ -1274,11 +1693,11 @@ declare const DelegationChainV2Schema: z.ZodObject<{
|
|
|
1274
1693
|
authHeader: z.ZodOptional<z.ZodString>;
|
|
1275
1694
|
}, "strip", z.ZodTypeAny, {
|
|
1276
1695
|
path: string;
|
|
1696
|
+
actions: string[];
|
|
1697
|
+
expiry: Date;
|
|
1277
1698
|
spaceId: string;
|
|
1278
1699
|
cid: string;
|
|
1279
1700
|
delegateDID: string;
|
|
1280
|
-
actions: string[];
|
|
1281
|
-
expiry: Date;
|
|
1282
1701
|
isRevoked: boolean;
|
|
1283
1702
|
createdAt?: Date | undefined;
|
|
1284
1703
|
delegatorDID?: string | undefined;
|
|
@@ -1287,11 +1706,11 @@ declare const DelegationChainV2Schema: z.ZodObject<{
|
|
|
1287
1706
|
authHeader?: string | undefined;
|
|
1288
1707
|
}, {
|
|
1289
1708
|
path: string;
|
|
1709
|
+
actions: string[];
|
|
1710
|
+
expiry: Date;
|
|
1290
1711
|
spaceId: string;
|
|
1291
1712
|
cid: string;
|
|
1292
1713
|
delegateDID: string;
|
|
1293
|
-
actions: string[];
|
|
1294
|
-
expiry: Date;
|
|
1295
1714
|
isRevoked: boolean;
|
|
1296
1715
|
createdAt?: Date | undefined;
|
|
1297
1716
|
delegatorDID?: string | undefined;
|
|
@@ -1327,11 +1746,11 @@ declare const DelegationChainV2Schema: z.ZodObject<{
|
|
|
1327
1746
|
authHeader: z.ZodOptional<z.ZodString>;
|
|
1328
1747
|
}, "strip", z.ZodTypeAny, {
|
|
1329
1748
|
path: string;
|
|
1749
|
+
actions: string[];
|
|
1750
|
+
expiry: Date;
|
|
1330
1751
|
spaceId: string;
|
|
1331
1752
|
cid: string;
|
|
1332
1753
|
delegateDID: string;
|
|
1333
|
-
actions: string[];
|
|
1334
|
-
expiry: Date;
|
|
1335
1754
|
isRevoked: boolean;
|
|
1336
1755
|
createdAt?: Date | undefined;
|
|
1337
1756
|
delegatorDID?: string | undefined;
|
|
@@ -1340,11 +1759,11 @@ declare const DelegationChainV2Schema: z.ZodObject<{
|
|
|
1340
1759
|
authHeader?: string | undefined;
|
|
1341
1760
|
}, {
|
|
1342
1761
|
path: string;
|
|
1762
|
+
actions: string[];
|
|
1763
|
+
expiry: Date;
|
|
1343
1764
|
spaceId: string;
|
|
1344
1765
|
cid: string;
|
|
1345
1766
|
delegateDID: string;
|
|
1346
|
-
actions: string[];
|
|
1347
|
-
expiry: Date;
|
|
1348
1767
|
isRevoked: boolean;
|
|
1349
1768
|
createdAt?: Date | undefined;
|
|
1350
1769
|
delegatorDID?: string | undefined;
|
|
@@ -1380,11 +1799,11 @@ declare const DelegationChainV2Schema: z.ZodObject<{
|
|
|
1380
1799
|
authHeader: z.ZodOptional<z.ZodString>;
|
|
1381
1800
|
}, "strip", z.ZodTypeAny, {
|
|
1382
1801
|
path: string;
|
|
1802
|
+
actions: string[];
|
|
1803
|
+
expiry: Date;
|
|
1383
1804
|
spaceId: string;
|
|
1384
1805
|
cid: string;
|
|
1385
1806
|
delegateDID: string;
|
|
1386
|
-
actions: string[];
|
|
1387
|
-
expiry: Date;
|
|
1388
1807
|
isRevoked: boolean;
|
|
1389
1808
|
createdAt?: Date | undefined;
|
|
1390
1809
|
delegatorDID?: string | undefined;
|
|
@@ -1393,11 +1812,11 @@ declare const DelegationChainV2Schema: z.ZodObject<{
|
|
|
1393
1812
|
authHeader?: string | undefined;
|
|
1394
1813
|
}, {
|
|
1395
1814
|
path: string;
|
|
1815
|
+
actions: string[];
|
|
1816
|
+
expiry: Date;
|
|
1396
1817
|
spaceId: string;
|
|
1397
1818
|
cid: string;
|
|
1398
1819
|
delegateDID: string;
|
|
1399
|
-
actions: string[];
|
|
1400
|
-
expiry: Date;
|
|
1401
1820
|
isRevoked: boolean;
|
|
1402
1821
|
createdAt?: Date | undefined;
|
|
1403
1822
|
delegatorDID?: string | undefined;
|
|
@@ -1408,11 +1827,11 @@ declare const DelegationChainV2Schema: z.ZodObject<{
|
|
|
1408
1827
|
}, "strip", z.ZodTypeAny, {
|
|
1409
1828
|
root: {
|
|
1410
1829
|
path: string;
|
|
1830
|
+
actions: string[];
|
|
1831
|
+
expiry: Date;
|
|
1411
1832
|
spaceId: string;
|
|
1412
1833
|
cid: string;
|
|
1413
1834
|
delegateDID: string;
|
|
1414
|
-
actions: string[];
|
|
1415
|
-
expiry: Date;
|
|
1416
1835
|
isRevoked: boolean;
|
|
1417
1836
|
createdAt?: Date | undefined;
|
|
1418
1837
|
delegatorDID?: string | undefined;
|
|
@@ -1422,11 +1841,11 @@ declare const DelegationChainV2Schema: z.ZodObject<{
|
|
|
1422
1841
|
};
|
|
1423
1842
|
chain: {
|
|
1424
1843
|
path: string;
|
|
1844
|
+
actions: string[];
|
|
1845
|
+
expiry: Date;
|
|
1425
1846
|
spaceId: string;
|
|
1426
1847
|
cid: string;
|
|
1427
1848
|
delegateDID: string;
|
|
1428
|
-
actions: string[];
|
|
1429
|
-
expiry: Date;
|
|
1430
1849
|
isRevoked: boolean;
|
|
1431
1850
|
createdAt?: Date | undefined;
|
|
1432
1851
|
delegatorDID?: string | undefined;
|
|
@@ -1436,11 +1855,11 @@ declare const DelegationChainV2Schema: z.ZodObject<{
|
|
|
1436
1855
|
}[];
|
|
1437
1856
|
leaf: {
|
|
1438
1857
|
path: string;
|
|
1858
|
+
actions: string[];
|
|
1859
|
+
expiry: Date;
|
|
1439
1860
|
spaceId: string;
|
|
1440
1861
|
cid: string;
|
|
1441
1862
|
delegateDID: string;
|
|
1442
|
-
actions: string[];
|
|
1443
|
-
expiry: Date;
|
|
1444
1863
|
isRevoked: boolean;
|
|
1445
1864
|
createdAt?: Date | undefined;
|
|
1446
1865
|
delegatorDID?: string | undefined;
|
|
@@ -1451,11 +1870,11 @@ declare const DelegationChainV2Schema: z.ZodObject<{
|
|
|
1451
1870
|
}, {
|
|
1452
1871
|
root: {
|
|
1453
1872
|
path: string;
|
|
1873
|
+
actions: string[];
|
|
1874
|
+
expiry: Date;
|
|
1454
1875
|
spaceId: string;
|
|
1455
1876
|
cid: string;
|
|
1456
1877
|
delegateDID: string;
|
|
1457
|
-
actions: string[];
|
|
1458
|
-
expiry: Date;
|
|
1459
1878
|
isRevoked: boolean;
|
|
1460
1879
|
createdAt?: Date | undefined;
|
|
1461
1880
|
delegatorDID?: string | undefined;
|
|
@@ -1465,11 +1884,11 @@ declare const DelegationChainV2Schema: z.ZodObject<{
|
|
|
1465
1884
|
};
|
|
1466
1885
|
chain: {
|
|
1467
1886
|
path: string;
|
|
1887
|
+
actions: string[];
|
|
1888
|
+
expiry: Date;
|
|
1468
1889
|
spaceId: string;
|
|
1469
1890
|
cid: string;
|
|
1470
1891
|
delegateDID: string;
|
|
1471
|
-
actions: string[];
|
|
1472
|
-
expiry: Date;
|
|
1473
1892
|
isRevoked: boolean;
|
|
1474
1893
|
createdAt?: Date | undefined;
|
|
1475
1894
|
delegatorDID?: string | undefined;
|
|
@@ -1479,11 +1898,11 @@ declare const DelegationChainV2Schema: z.ZodObject<{
|
|
|
1479
1898
|
}[];
|
|
1480
1899
|
leaf: {
|
|
1481
1900
|
path: string;
|
|
1901
|
+
actions: string[];
|
|
1902
|
+
expiry: Date;
|
|
1482
1903
|
spaceId: string;
|
|
1483
1904
|
cid: string;
|
|
1484
1905
|
delegateDID: string;
|
|
1485
|
-
actions: string[];
|
|
1486
|
-
expiry: Date;
|
|
1487
1906
|
isRevoked: boolean;
|
|
1488
1907
|
createdAt?: Date | undefined;
|
|
1489
1908
|
delegatorDID?: string | undefined;
|
|
@@ -1525,7 +1944,7 @@ declare const DelegationFiltersSchema: z.ZodObject<{
|
|
|
1525
1944
|
actions?: string[] | undefined;
|
|
1526
1945
|
delegator?: string | undefined;
|
|
1527
1946
|
delegatee?: string | undefined;
|
|
1528
|
-
direction?: "received" | "
|
|
1947
|
+
direction?: "received" | "all" | "granted" | undefined;
|
|
1529
1948
|
includeRevoked?: boolean | undefined;
|
|
1530
1949
|
validAt?: Date | undefined;
|
|
1531
1950
|
limit?: number | undefined;
|
|
@@ -1535,7 +1954,7 @@ declare const DelegationFiltersSchema: z.ZodObject<{
|
|
|
1535
1954
|
actions?: string[] | undefined;
|
|
1536
1955
|
delegator?: string | undefined;
|
|
1537
1956
|
delegatee?: string | undefined;
|
|
1538
|
-
direction?: "received" | "
|
|
1957
|
+
direction?: "received" | "all" | "granted" | undefined;
|
|
1539
1958
|
includeRevoked?: boolean | undefined;
|
|
1540
1959
|
validAt?: Date | undefined;
|
|
1541
1960
|
limit?: number | undefined;
|
|
@@ -1620,11 +2039,11 @@ declare const ShareLinkSchema: z.ZodObject<{
|
|
|
1620
2039
|
authHeader: z.ZodOptional<z.ZodString>;
|
|
1621
2040
|
}, "strip", z.ZodTypeAny, {
|
|
1622
2041
|
path: string;
|
|
2042
|
+
actions: string[];
|
|
2043
|
+
expiry: Date;
|
|
1623
2044
|
spaceId: string;
|
|
1624
2045
|
cid: string;
|
|
1625
2046
|
delegateDID: string;
|
|
1626
|
-
actions: string[];
|
|
1627
|
-
expiry: Date;
|
|
1628
2047
|
isRevoked: boolean;
|
|
1629
2048
|
createdAt?: Date | undefined;
|
|
1630
2049
|
delegatorDID?: string | undefined;
|
|
@@ -1633,11 +2052,11 @@ declare const ShareLinkSchema: z.ZodObject<{
|
|
|
1633
2052
|
authHeader?: string | undefined;
|
|
1634
2053
|
}, {
|
|
1635
2054
|
path: string;
|
|
2055
|
+
actions: string[];
|
|
2056
|
+
expiry: Date;
|
|
1636
2057
|
spaceId: string;
|
|
1637
2058
|
cid: string;
|
|
1638
2059
|
delegateDID: string;
|
|
1639
|
-
actions: string[];
|
|
1640
|
-
expiry: Date;
|
|
1641
2060
|
isRevoked: boolean;
|
|
1642
2061
|
createdAt?: Date | undefined;
|
|
1643
2062
|
delegatorDID?: string | undefined;
|
|
@@ -1655,11 +2074,11 @@ declare const ShareLinkSchema: z.ZodObject<{
|
|
|
1655
2074
|
url: string;
|
|
1656
2075
|
delegation: {
|
|
1657
2076
|
path: string;
|
|
2077
|
+
actions: string[];
|
|
2078
|
+
expiry: Date;
|
|
1658
2079
|
spaceId: string;
|
|
1659
2080
|
cid: string;
|
|
1660
2081
|
delegateDID: string;
|
|
1661
|
-
actions: string[];
|
|
1662
|
-
expiry: Date;
|
|
1663
2082
|
isRevoked: boolean;
|
|
1664
2083
|
createdAt?: Date | undefined;
|
|
1665
2084
|
delegatorDID?: string | undefined;
|
|
@@ -1675,11 +2094,11 @@ declare const ShareLinkSchema: z.ZodObject<{
|
|
|
1675
2094
|
url: string;
|
|
1676
2095
|
delegation: {
|
|
1677
2096
|
path: string;
|
|
2097
|
+
actions: string[];
|
|
2098
|
+
expiry: Date;
|
|
1678
2099
|
spaceId: string;
|
|
1679
2100
|
cid: string;
|
|
1680
2101
|
delegateDID: string;
|
|
1681
|
-
actions: string[];
|
|
1682
|
-
expiry: Date;
|
|
1683
2102
|
isRevoked: boolean;
|
|
1684
2103
|
createdAt?: Date | undefined;
|
|
1685
2104
|
delegatorDID?: string | undefined;
|
|
@@ -1828,8 +2247,51 @@ declare const DelegationApiResponseSchema: z.ZodObject<{
|
|
|
1828
2247
|
cid?: string | undefined;
|
|
1829
2248
|
}>;
|
|
1830
2249
|
type DelegationApiResponse = z.infer<typeof DelegationApiResponseSchema>;
|
|
2250
|
+
/**
|
|
2251
|
+
* A single (service, space, path, actions) entry inside a
|
|
2252
|
+
* createDelegation WASM result.
|
|
2253
|
+
*
|
|
2254
|
+
* Mirrors the Rust `DelegatedResource` struct in
|
|
2255
|
+
* `tinycloud-sdk-wasm/src/session.rs`. Field names match the manifest
|
|
2256
|
+
* {@link PermissionEntry} shape so callers can reconstruct what they sent
|
|
2257
|
+
* without having to re-parse the UCAN.
|
|
2258
|
+
*
|
|
2259
|
+
* `service` is the short form (e.g. `"kv"`, `"sql"`) as returned by the
|
|
2260
|
+
* Rust layer. The SDK layer translates to the long form
|
|
2261
|
+
* (`"tinycloud.kv"`) when comparing against manifests.
|
|
2262
|
+
*/
|
|
2263
|
+
declare const DelegatedResourceSchema: z.ZodObject<{
|
|
2264
|
+
/** Short-form service name, e.g. "kv", "sql", "duckdb", "capabilities", "hooks". */
|
|
2265
|
+
service: z.ZodString;
|
|
2266
|
+
/** Full space id string, e.g. "tinycloud:pkh:eip155:1:0x....:default". */
|
|
2267
|
+
space: z.ZodString;
|
|
2268
|
+
/** Resource path; empty string when the resource URI had no path segment. */
|
|
2269
|
+
path: z.ZodString;
|
|
2270
|
+
/** Full-URN ability strings, e.g. ["tinycloud.kv/get", "tinycloud.kv/put"]. */
|
|
2271
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
2272
|
+
}, "strip", z.ZodTypeAny, {
|
|
2273
|
+
path: string;
|
|
2274
|
+
service: string;
|
|
2275
|
+
space: string;
|
|
2276
|
+
actions: string[];
|
|
2277
|
+
}, {
|
|
2278
|
+
path: string;
|
|
2279
|
+
service: string;
|
|
2280
|
+
space: string;
|
|
2281
|
+
actions: string[];
|
|
2282
|
+
}>;
|
|
2283
|
+
type DelegatedResource = z.infer<typeof DelegatedResourceSchema>;
|
|
1831
2284
|
/**
|
|
1832
2285
|
* Input parameters for the createDelegation WASM function.
|
|
2286
|
+
*
|
|
2287
|
+
* A single call may encode multiple `(service, path, actions)` entries
|
|
2288
|
+
* via the `abilities` map — the underlying UCAN will contain one
|
|
2289
|
+
* attenuation entry per `(service, path)` pair, all signed by the same
|
|
2290
|
+
* session key in one blob.
|
|
2291
|
+
*
|
|
2292
|
+
* The `abilities` shape is identical to what `prepareSession` accepts
|
|
2293
|
+
* (`Record<shortService, Record<path, actionURNs[]>>`), so manifest
|
|
2294
|
+
* resolution can feed both sides from one data structure.
|
|
1833
2295
|
*/
|
|
1834
2296
|
declare const CreateDelegationWasmParamsSchema: z.ZodObject<{
|
|
1835
2297
|
/** The session containing delegation credentials */
|
|
@@ -1838,27 +2300,38 @@ declare const CreateDelegationWasmParamsSchema: z.ZodObject<{
|
|
|
1838
2300
|
delegateDID: z.ZodString;
|
|
1839
2301
|
/** Space ID this delegation applies to */
|
|
1840
2302
|
spaceId: z.ZodString;
|
|
1841
|
-
/**
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
2303
|
+
/**
|
|
2304
|
+
* Multi-resource abilities map: short-service → path → full-URN actions.
|
|
2305
|
+
* Matches the shape accepted by `prepareSession`.
|
|
2306
|
+
*
|
|
2307
|
+
* Example:
|
|
2308
|
+
* ```
|
|
2309
|
+
* {
|
|
2310
|
+
* kv: {
|
|
2311
|
+
* "com.listen.app/": ["tinycloud.kv/get", "tinycloud.kv/put"]
|
|
2312
|
+
* },
|
|
2313
|
+
* sql: {
|
|
2314
|
+
* "com.listen.app/data.sqlite": ["tinycloud.sql/read"]
|
|
2315
|
+
* }
|
|
2316
|
+
* }
|
|
2317
|
+
* ```
|
|
2318
|
+
*/
|
|
2319
|
+
abilities: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
|
|
1845
2320
|
/** Expiration time in seconds since Unix epoch */
|
|
1846
2321
|
expirationSecs: z.ZodNumber;
|
|
1847
2322
|
/** Optional not-before time in seconds since Unix epoch */
|
|
1848
2323
|
notBeforeSecs: z.ZodOptional<z.ZodNumber>;
|
|
1849
2324
|
}, "strip", z.ZodTypeAny, {
|
|
1850
|
-
path: string;
|
|
1851
2325
|
spaceId: string;
|
|
1852
2326
|
session: ServiceSession;
|
|
1853
2327
|
delegateDID: string;
|
|
1854
|
-
|
|
2328
|
+
abilities: Record<string, Record<string, string[]>>;
|
|
1855
2329
|
expirationSecs: number;
|
|
1856
2330
|
notBeforeSecs?: number | undefined;
|
|
1857
2331
|
}, {
|
|
1858
|
-
path: string;
|
|
1859
2332
|
spaceId: string;
|
|
1860
2333
|
delegateDID: string;
|
|
1861
|
-
|
|
2334
|
+
abilities: Record<string, Record<string, string[]>>;
|
|
1862
2335
|
expirationSecs: number;
|
|
1863
2336
|
session?: unknown;
|
|
1864
2337
|
notBeforeSecs?: number | undefined;
|
|
@@ -1866,6 +2339,11 @@ declare const CreateDelegationWasmParamsSchema: z.ZodObject<{
|
|
|
1866
2339
|
type CreateDelegationWasmParams = z.infer<typeof CreateDelegationWasmParamsSchema>;
|
|
1867
2340
|
/**
|
|
1868
2341
|
* Result from the createDelegation WASM function.
|
|
2342
|
+
*
|
|
2343
|
+
* A single UCAN may cover multiple resources. The `resources` array
|
|
2344
|
+
* describes every `(service, space, path, actions)` entry granted, in
|
|
2345
|
+
* deterministic (service, path) lexicographic order (the Rust side sorts
|
|
2346
|
+
* the HashMap entries before signing).
|
|
1869
2347
|
*/
|
|
1870
2348
|
declare const CreateDelegationWasmResultSchema: z.ZodObject<{
|
|
1871
2349
|
/** Base64url-encoded UCAN delegation */
|
|
@@ -1874,26 +2352,54 @@ declare const CreateDelegationWasmResultSchema: z.ZodObject<{
|
|
|
1874
2352
|
cid: z.ZodString;
|
|
1875
2353
|
/** DID of the delegate */
|
|
1876
2354
|
delegateDID: z.ZodString;
|
|
1877
|
-
/** Resource path the delegation grants access to */
|
|
1878
|
-
path: z.ZodString;
|
|
1879
|
-
/** Actions the delegation authorizes */
|
|
1880
|
-
actions: z.ZodArray<z.ZodString, "many">;
|
|
1881
2355
|
/** Expiration time */
|
|
1882
2356
|
expiry: z.ZodDate;
|
|
2357
|
+
/**
|
|
2358
|
+
* All (service, space, path, actions) entries granted by this delegation.
|
|
2359
|
+
* Always non-empty on success.
|
|
2360
|
+
*/
|
|
2361
|
+
resources: z.ZodArray<z.ZodObject<{
|
|
2362
|
+
/** Short-form service name, e.g. "kv", "sql", "duckdb", "capabilities", "hooks". */
|
|
2363
|
+
service: z.ZodString;
|
|
2364
|
+
/** Full space id string, e.g. "tinycloud:pkh:eip155:1:0x....:default". */
|
|
2365
|
+
space: z.ZodString;
|
|
2366
|
+
/** Resource path; empty string when the resource URI had no path segment. */
|
|
2367
|
+
path: z.ZodString;
|
|
2368
|
+
/** Full-URN ability strings, e.g. ["tinycloud.kv/get", "tinycloud.kv/put"]. */
|
|
2369
|
+
actions: z.ZodArray<z.ZodString, "many">;
|
|
2370
|
+
}, "strip", z.ZodTypeAny, {
|
|
2371
|
+
path: string;
|
|
2372
|
+
service: string;
|
|
2373
|
+
space: string;
|
|
2374
|
+
actions: string[];
|
|
2375
|
+
}, {
|
|
2376
|
+
path: string;
|
|
2377
|
+
service: string;
|
|
2378
|
+
space: string;
|
|
2379
|
+
actions: string[];
|
|
2380
|
+
}>, "many">;
|
|
1883
2381
|
}, "strip", z.ZodTypeAny, {
|
|
1884
|
-
|
|
2382
|
+
resources: {
|
|
2383
|
+
path: string;
|
|
2384
|
+
service: string;
|
|
2385
|
+
space: string;
|
|
2386
|
+
actions: string[];
|
|
2387
|
+
}[];
|
|
2388
|
+
expiry: Date;
|
|
1885
2389
|
delegation: string;
|
|
1886
2390
|
cid: string;
|
|
1887
2391
|
delegateDID: string;
|
|
1888
|
-
actions: string[];
|
|
1889
|
-
expiry: Date;
|
|
1890
2392
|
}, {
|
|
1891
|
-
|
|
2393
|
+
resources: {
|
|
2394
|
+
path: string;
|
|
2395
|
+
service: string;
|
|
2396
|
+
space: string;
|
|
2397
|
+
actions: string[];
|
|
2398
|
+
}[];
|
|
2399
|
+
expiry: Date;
|
|
1892
2400
|
delegation: string;
|
|
1893
2401
|
cid: string;
|
|
1894
2402
|
delegateDID: string;
|
|
1895
|
-
actions: string[];
|
|
1896
|
-
expiry: Date;
|
|
1897
2403
|
}>;
|
|
1898
2404
|
type CreateDelegationWasmResult = z.infer<typeof CreateDelegationWasmResultSchema>;
|
|
1899
2405
|
|
|
@@ -3875,4 +4381,4 @@ interface NodeInfo {
|
|
|
3875
4381
|
}
|
|
3876
4382
|
declare function checkNodeInfo(host: string, sdkProtocol: number, fetchFn?: typeof globalThis.fetch): Promise<NodeInfo>;
|
|
3877
4383
|
|
|
3878
|
-
export { AutoApproveSpaceCreationHandler, type AutoRejectStrategy, type AutoSignStrategy, type Bytes, type CallbackStrategy, type CapabilityEntry, CapabilityKeyRegistry, type CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, type ClientSession, ClientSessionSchema, type CreateDelegationFunction, type CreateDelegationParams, type CreateDelegationWasmParams, type CreateDelegationWasmResult, type Delegation, type DelegationApiResponse, type DelegationChain, type DelegationChainV2, type DelegationDirection, type DelegationError, type DelegationErrorCode, DelegationErrorCodes, type DelegationFilters, DelegationManager, type DelegationManagerConfig, type DelegationRecord, type Result as DelegationResult, type EncodedShareData, type EnsData, EnsDataSchema, type EventEmitterStrategy, type Extension, type GenerateShareParams, type ICapabilityKeyRegistry, type IENSResolver, type INotificationHandler, type ISessionManager, type ISessionStorage, type ISharingService, type ISigner, type ISpace, type ISpaceCreationHandler, type ISpaceScopedDelegations, type ISpaceScopedSharing, type ISpaceService, type IUserAuthorization, type IWasmBindings, type IngestOptions, type JWK, type KeyInfo, type KeyProvider, type KeyType, type NodeInfo, type PartialSiweMessage, type PersistedSessionData, type PersistedTinyCloudSession, ProtocolMismatchError, type ReceiveOptions, type ServerHost, type ShareAccess, type ShareLink, type ShareLinkData, type ShareSchema, SharingService, type SharingServiceConfig, type SignCallback, type SignRequest, type SignResponse, type SignStrategy, SilentNotificationHandler, type SiweConfig, SiweConfigSchema, Space, type SpaceConfig, type SpaceCreationContext, type SpaceDelegationParams, type SpaceErrorCode, SpaceErrorCodes, type SpaceHostResult, type SpaceInfo, type SpaceOwnership, SpaceService, type SpaceServiceConfig, type StoredDelegationChain, TinyCloud, type TinyCloudConfig, type TinyCloudSession, UnsupportedFeatureError, type UserAuthorizationConfig, type ValidationError, VersionCheckError, activateSessionWithHost, buildSpaceUri, checkNodeInfo, createCapabilityKeyRegistry, createSharingService, createSpaceService, defaultSignStrategy, defaultSpaceCreationHandler, fetchPeerId, makePublicSpaceId, parseSpaceUri, submitHostDelegation, validateClientSession, validatePersistedSessionData };
|
|
4384
|
+
export { type AbilitiesMap, AutoApproveSpaceCreationHandler, type AutoRejectStrategy, type AutoSignStrategy, type Bytes, type CallbackStrategy, type CapabilityEntry, CapabilityKeyRegistry, type CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, type ClientSession, ClientSessionSchema, type CreateDelegationFunction, type CreateDelegationParams, type CreateDelegationWasmParams, type CreateDelegationWasmResult, DEFAULT_DEFAULTS, DEFAULT_EXPIRY, type DelegatedResource, type Delegation, type DelegationApiResponse, type DelegationChain, type DelegationChainV2, type DelegationDirection, type DelegationError, type DelegationErrorCode, DelegationErrorCodes, type DelegationFilters, DelegationManager, type DelegationManagerConfig, type DelegationRecord, type Result as DelegationResult, type EncodedShareData, type EnsData, EnsDataSchema, type EventEmitterStrategy, type Extension, type GenerateShareParams, type ICapabilityKeyRegistry, type IENSResolver, type INotificationHandler, type ISessionManager, type ISessionStorage, type ISharingService, type ISigner, type ISpace, type ISpaceCreationHandler, type ISpaceScopedDelegations, type ISpaceScopedSharing, type ISpaceService, type IUserAuthorization, type IWasmBindings, type IngestOptions, type JWK, type KeyInfo, type KeyProvider, type KeyType, type Manifest, type ManifestDefaults, type ManifestDelegation, ManifestValidationError, type NodeInfo, type ParseRecapFromSiwe, type PartialSiweMessage, type PermissionEntry, PermissionNotInManifestError, type PersistedSessionData, type PersistedTinyCloudSession, ProtocolMismatchError, type ReceiveOptions, type ResolvedCapabilities, type ResolvedDelegate, type ResourceCapability, SERVICE_LONG_TO_SHORT, SERVICE_SHORT_TO_LONG, type ServerHost, SessionExpiredError, type ShareAccess, type ShareLink, type ShareLinkData, type ShareSchema, SharingService, type SharingServiceConfig, type SignCallback, type SignRequest, type SignResponse, type SignStrategy, SilentNotificationHandler, type SiweConfig, SiweConfigSchema, Space, type SpaceConfig, type SpaceCreationContext, type SpaceDelegationParams, type SpaceErrorCode, SpaceErrorCodes, type SpaceHostResult, type SpaceInfo, type SpaceOwnership, SpaceService, type SpaceServiceConfig, type StoredDelegationChain, type SubsetCheckResult, TinyCloud, type TinyCloudConfig, type TinyCloudSession, UnsupportedFeatureError, type UserAuthorizationConfig, type ValidationError, VersionCheckError, type WasmRecapEntry, activateSessionWithHost, applyPrefix, buildSpaceUri, checkNodeInfo, createCapabilityKeyRegistry, createSharingService, createSpaceService, defaultSignStrategy, defaultSpaceCreationHandler, expandActionShortNames, fetchPeerId, isCapabilitySubset, loadManifest, makePublicSpaceId, manifestAbilitiesUnion, normalizeDefaults, parseExpiry, parseRecapCapabilities, parseSpaceUri, resolveManifest, resourceCapabilitiesToAbilitiesMap, submitHostDelegation, validateClientSession, validateManifest, validatePersistedSessionData };
|