@tinycloud/sdk-core 2.1.0-beta.1 → 2.1.0-beta.3

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.d.cts CHANGED
@@ -430,6 +430,63 @@ declare function normalizeDefaults(value: Manifest["defaults"] | undefined): Man
430
430
  * - Prefix inheritance applies identically to `permissions` and `delegations[*].permissions`.
431
431
  */
432
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;
433
490
 
434
491
  /**
435
492
  * Capability subset checking and recap parsing.
@@ -2190,8 +2247,51 @@ declare const DelegationApiResponseSchema: z.ZodObject<{
2190
2247
  cid?: string | undefined;
2191
2248
  }>;
2192
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>;
2193
2284
  /**
2194
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.
2195
2295
  */
2196
2296
  declare const CreateDelegationWasmParamsSchema: z.ZodObject<{
2197
2297
  /** The session containing delegation credentials */
@@ -2200,27 +2300,38 @@ declare const CreateDelegationWasmParamsSchema: z.ZodObject<{
2200
2300
  delegateDID: z.ZodString;
2201
2301
  /** Space ID this delegation applies to */
2202
2302
  spaceId: z.ZodString;
2203
- /** Resource path this delegation grants access to */
2204
- path: z.ZodString;
2205
- /** Actions to authorize */
2206
- actions: z.ZodArray<z.ZodString, "many">;
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">>>;
2207
2320
  /** Expiration time in seconds since Unix epoch */
2208
2321
  expirationSecs: z.ZodNumber;
2209
2322
  /** Optional not-before time in seconds since Unix epoch */
2210
2323
  notBeforeSecs: z.ZodOptional<z.ZodNumber>;
2211
2324
  }, "strip", z.ZodTypeAny, {
2212
- path: string;
2213
- actions: string[];
2214
2325
  spaceId: string;
2215
2326
  session: ServiceSession;
2216
2327
  delegateDID: string;
2328
+ abilities: Record<string, Record<string, string[]>>;
2217
2329
  expirationSecs: number;
2218
2330
  notBeforeSecs?: number | undefined;
2219
2331
  }, {
2220
- path: string;
2221
- actions: string[];
2222
2332
  spaceId: string;
2223
2333
  delegateDID: string;
2334
+ abilities: Record<string, Record<string, string[]>>;
2224
2335
  expirationSecs: number;
2225
2336
  session?: unknown;
2226
2337
  notBeforeSecs?: number | undefined;
@@ -2228,6 +2339,11 @@ declare const CreateDelegationWasmParamsSchema: z.ZodObject<{
2228
2339
  type CreateDelegationWasmParams = z.infer<typeof CreateDelegationWasmParamsSchema>;
2229
2340
  /**
2230
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).
2231
2347
  */
2232
2348
  declare const CreateDelegationWasmResultSchema: z.ZodObject<{
2233
2349
  /** Base64url-encoded UCAN delegation */
@@ -2236,22 +2352,50 @@ declare const CreateDelegationWasmResultSchema: z.ZodObject<{
2236
2352
  cid: z.ZodString;
2237
2353
  /** DID of the delegate */
2238
2354
  delegateDID: z.ZodString;
2239
- /** Resource path the delegation grants access to */
2240
- path: z.ZodString;
2241
- /** Actions the delegation authorizes */
2242
- actions: z.ZodArray<z.ZodString, "many">;
2243
2355
  /** Expiration time */
2244
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">;
2245
2381
  }, "strip", z.ZodTypeAny, {
2246
- path: string;
2247
- actions: string[];
2382
+ resources: {
2383
+ path: string;
2384
+ service: string;
2385
+ space: string;
2386
+ actions: string[];
2387
+ }[];
2248
2388
  expiry: Date;
2249
2389
  delegation: string;
2250
2390
  cid: string;
2251
2391
  delegateDID: string;
2252
2392
  }, {
2253
- path: string;
2254
- actions: string[];
2393
+ resources: {
2394
+ path: string;
2395
+ service: string;
2396
+ space: string;
2397
+ actions: string[];
2398
+ }[];
2255
2399
  expiry: Date;
2256
2400
  delegation: string;
2257
2401
  cid: string;
@@ -4237,4 +4381,4 @@ interface NodeInfo {
4237
4381
  }
4238
4382
  declare function checkNodeInfo(host: string, sdkProtocol: number, fetchFn?: typeof globalThis.fetch): Promise<NodeInfo>;
4239
4383
 
4240
- 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, DEFAULT_DEFAULTS, DEFAULT_EXPIRY, 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, normalizeDefaults, parseExpiry, parseRecapCapabilities, parseSpaceUri, resolveManifest, submitHostDelegation, validateClientSession, validateManifest, 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 };
package/dist/index.d.ts CHANGED
@@ -430,6 +430,63 @@ declare function normalizeDefaults(value: Manifest["defaults"] | undefined): Man
430
430
  * - Prefix inheritance applies identically to `permissions` and `delegations[*].permissions`.
431
431
  */
432
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;
433
490
 
434
491
  /**
435
492
  * Capability subset checking and recap parsing.
@@ -2190,8 +2247,51 @@ declare const DelegationApiResponseSchema: z.ZodObject<{
2190
2247
  cid?: string | undefined;
2191
2248
  }>;
2192
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>;
2193
2284
  /**
2194
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.
2195
2295
  */
2196
2296
  declare const CreateDelegationWasmParamsSchema: z.ZodObject<{
2197
2297
  /** The session containing delegation credentials */
@@ -2200,27 +2300,38 @@ declare const CreateDelegationWasmParamsSchema: z.ZodObject<{
2200
2300
  delegateDID: z.ZodString;
2201
2301
  /** Space ID this delegation applies to */
2202
2302
  spaceId: z.ZodString;
2203
- /** Resource path this delegation grants access to */
2204
- path: z.ZodString;
2205
- /** Actions to authorize */
2206
- actions: z.ZodArray<z.ZodString, "many">;
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">>>;
2207
2320
  /** Expiration time in seconds since Unix epoch */
2208
2321
  expirationSecs: z.ZodNumber;
2209
2322
  /** Optional not-before time in seconds since Unix epoch */
2210
2323
  notBeforeSecs: z.ZodOptional<z.ZodNumber>;
2211
2324
  }, "strip", z.ZodTypeAny, {
2212
- path: string;
2213
- actions: string[];
2214
2325
  spaceId: string;
2215
2326
  session: ServiceSession;
2216
2327
  delegateDID: string;
2328
+ abilities: Record<string, Record<string, string[]>>;
2217
2329
  expirationSecs: number;
2218
2330
  notBeforeSecs?: number | undefined;
2219
2331
  }, {
2220
- path: string;
2221
- actions: string[];
2222
2332
  spaceId: string;
2223
2333
  delegateDID: string;
2334
+ abilities: Record<string, Record<string, string[]>>;
2224
2335
  expirationSecs: number;
2225
2336
  session?: unknown;
2226
2337
  notBeforeSecs?: number | undefined;
@@ -2228,6 +2339,11 @@ declare const CreateDelegationWasmParamsSchema: z.ZodObject<{
2228
2339
  type CreateDelegationWasmParams = z.infer<typeof CreateDelegationWasmParamsSchema>;
2229
2340
  /**
2230
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).
2231
2347
  */
2232
2348
  declare const CreateDelegationWasmResultSchema: z.ZodObject<{
2233
2349
  /** Base64url-encoded UCAN delegation */
@@ -2236,22 +2352,50 @@ declare const CreateDelegationWasmResultSchema: z.ZodObject<{
2236
2352
  cid: z.ZodString;
2237
2353
  /** DID of the delegate */
2238
2354
  delegateDID: z.ZodString;
2239
- /** Resource path the delegation grants access to */
2240
- path: z.ZodString;
2241
- /** Actions the delegation authorizes */
2242
- actions: z.ZodArray<z.ZodString, "many">;
2243
2355
  /** Expiration time */
2244
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">;
2245
2381
  }, "strip", z.ZodTypeAny, {
2246
- path: string;
2247
- actions: string[];
2382
+ resources: {
2383
+ path: string;
2384
+ service: string;
2385
+ space: string;
2386
+ actions: string[];
2387
+ }[];
2248
2388
  expiry: Date;
2249
2389
  delegation: string;
2250
2390
  cid: string;
2251
2391
  delegateDID: string;
2252
2392
  }, {
2253
- path: string;
2254
- actions: string[];
2393
+ resources: {
2394
+ path: string;
2395
+ service: string;
2396
+ space: string;
2397
+ actions: string[];
2398
+ }[];
2255
2399
  expiry: Date;
2256
2400
  delegation: string;
2257
2401
  cid: string;
@@ -4237,4 +4381,4 @@ interface NodeInfo {
4237
4381
  }
4238
4382
  declare function checkNodeInfo(host: string, sdkProtocol: number, fetchFn?: typeof globalThis.fetch): Promise<NodeInfo>;
4239
4383
 
4240
- 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, DEFAULT_DEFAULTS, DEFAULT_EXPIRY, 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, normalizeDefaults, parseExpiry, parseRecapCapabilities, parseSpaceUri, resolveManifest, submitHostDelegation, validateClientSession, validateManifest, 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 };