@tinycloud/sdk-core 2.1.0 → 2.2.0-beta.1
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 +191 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +90 -43
- package/dist/index.d.ts +90 -43
- package/dist/index.js +185 -63
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -206,8 +206,8 @@ interface IENSResolver {
|
|
|
206
206
|
interface PermissionEntry {
|
|
207
207
|
/** Service namespace, e.g. "tinycloud.kv", "tinycloud.sql", "tinycloud.duckdb", "tinycloud.capabilities". */
|
|
208
208
|
service: string;
|
|
209
|
-
/**
|
|
210
|
-
space
|
|
209
|
+
/** Space name or full space URI. Defaults to "applications" inside manifests. */
|
|
210
|
+
space?: string;
|
|
211
211
|
/**
|
|
212
212
|
* Service-specific path.
|
|
213
213
|
* - tinycloud.kv: hierarchical prefix. "/" = all, "foo/" = prefix match, "foo" = exact key
|
|
@@ -226,23 +226,8 @@ interface PermissionEntry {
|
|
|
226
226
|
skipPrefix?: boolean;
|
|
227
227
|
/** Per-entry expiry override, ms-format. */
|
|
228
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[];
|
|
229
|
+
/** User/agent-facing context for why this permission is requested. */
|
|
230
|
+
description?: string;
|
|
246
231
|
}
|
|
247
232
|
/**
|
|
248
233
|
* The valid values for `Manifest.defaults`.
|
|
@@ -261,22 +246,26 @@ type ManifestDefaults = boolean | "admin" | "all";
|
|
|
261
246
|
*/
|
|
262
247
|
interface Manifest {
|
|
263
248
|
/** Schema version. Optional, defaults to 1. */
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
|
|
249
|
+
manifest_version?: 1;
|
|
250
|
+
/** Application identifier / namespace prefix. Required. */
|
|
251
|
+
app_id: string;
|
|
267
252
|
/** Display name. Required. */
|
|
268
253
|
name: string;
|
|
269
|
-
/**
|
|
254
|
+
/** Description of what the app or delegate does. Optional. */
|
|
270
255
|
description?: string;
|
|
256
|
+
/** DID of this manifest's delegate target. Optional. Required only for delegation materialization. */
|
|
257
|
+
did?: string;
|
|
271
258
|
/** URL to app icon. Optional. */
|
|
272
259
|
icon?: string;
|
|
273
260
|
/** App version string. Optional. */
|
|
274
261
|
appVersion?: string;
|
|
275
262
|
/** Default expiry for permissions. ms-format ("30d", "2h", "1y"). Default "30d". */
|
|
276
263
|
expiry?: string;
|
|
264
|
+
/** Space name or full space URI. Optional, defaults to "applications". */
|
|
265
|
+
space?: string;
|
|
277
266
|
/**
|
|
278
267
|
* Path prefix auto-prepended to permission paths. Optional, defaults to
|
|
279
|
-
* `
|
|
268
|
+
* `app_id`. Set to `""` to disable entirely. Individual permissions can opt
|
|
280
269
|
* out with `skipPrefix: true`.
|
|
281
270
|
*/
|
|
282
271
|
prefix?: string;
|
|
@@ -292,8 +281,6 @@ interface Manifest {
|
|
|
292
281
|
* DuckDB (opt-in), or `skipPrefix: true` entries.
|
|
293
282
|
*/
|
|
294
283
|
permissions?: PermissionEntry[];
|
|
295
|
-
/** Pre-delegations to other DIDs at sign-in. */
|
|
296
|
-
delegations?: ManifestDelegation[];
|
|
297
284
|
}
|
|
298
285
|
/**
|
|
299
286
|
* A resolved permission entry with fully-expanded paths and action URNs.
|
|
@@ -303,7 +290,7 @@ interface Manifest {
|
|
|
303
290
|
interface ResourceCapability {
|
|
304
291
|
/** Long-form service, e.g. "tinycloud.kv". */
|
|
305
292
|
service: string;
|
|
306
|
-
/** Space
|
|
293
|
+
/** Space name or URI. Short names are resolved to full SpaceIds at sign-in time. */
|
|
307
294
|
space: string;
|
|
308
295
|
/** Path with the manifest prefix applied (or skipped per `skipPrefix`). */
|
|
309
296
|
path: string;
|
|
@@ -311,6 +298,8 @@ interface ResourceCapability {
|
|
|
311
298
|
actions: string[];
|
|
312
299
|
/** Per-entry expiry override in milliseconds. */
|
|
313
300
|
expiryMs?: number;
|
|
301
|
+
/** User/agent-facing context copied from the source permission entry. */
|
|
302
|
+
description?: string;
|
|
314
303
|
}
|
|
315
304
|
/**
|
|
316
305
|
* A resolved delegation entry with fully-expanded permissions.
|
|
@@ -330,17 +319,47 @@ interface ResolvedDelegate {
|
|
|
330
319
|
* ready to drive the SIWE recap.
|
|
331
320
|
*/
|
|
332
321
|
interface ResolvedCapabilities {
|
|
333
|
-
/**
|
|
334
|
-
|
|
322
|
+
/** Application identifier copied from manifest.app_id. */
|
|
323
|
+
app_id: string;
|
|
324
|
+
/** Delegate DID copied from manifest.did, when present. */
|
|
325
|
+
did?: string;
|
|
326
|
+
/** Effective default space for this manifest. */
|
|
327
|
+
space: string;
|
|
335
328
|
/** All session-key resources with paths fully resolved (prefix applied). */
|
|
336
329
|
resources: ResourceCapability[];
|
|
337
330
|
/** Default expiry for the session, in milliseconds. */
|
|
338
331
|
expiryMs: number;
|
|
339
332
|
/** Whether to include the public-space companion. */
|
|
340
333
|
includePublicSpace: boolean;
|
|
341
|
-
/**
|
|
334
|
+
/** Delegate targets derived from manifests that declare `did`. */
|
|
342
335
|
additionalDelegates: ResolvedDelegate[];
|
|
343
336
|
}
|
|
337
|
+
interface ManifestRegistryRecord {
|
|
338
|
+
/** KV key inside the account space. */
|
|
339
|
+
key: string;
|
|
340
|
+
/** App id this record describes. */
|
|
341
|
+
app_id: string;
|
|
342
|
+
/** Latest manifest payloads composed for this app id. */
|
|
343
|
+
manifests: Manifest[];
|
|
344
|
+
}
|
|
345
|
+
interface ComposeManifestOptions {
|
|
346
|
+
/** Include implicit account-space registry permissions. Default true. */
|
|
347
|
+
includeAccountRegistryPermissions?: boolean;
|
|
348
|
+
}
|
|
349
|
+
interface ComposedManifestRequest {
|
|
350
|
+
/** Validated manifests that were composed. */
|
|
351
|
+
manifests: Manifest[];
|
|
352
|
+
/** Full permission union requested from the user in one SIWE. */
|
|
353
|
+
resources: ResourceCapability[];
|
|
354
|
+
/** Delegations that can be materialized after sign-in. */
|
|
355
|
+
delegationTargets: ResolvedDelegate[];
|
|
356
|
+
/** Account-space registry records to write after successful sign-in. */
|
|
357
|
+
registryRecords: ManifestRegistryRecord[];
|
|
358
|
+
/** Effective session expiry, using the longest composed manifest expiry. */
|
|
359
|
+
expiryMs: number;
|
|
360
|
+
/** Whether to include the public-space companion behavior. */
|
|
361
|
+
includePublicSpace: boolean;
|
|
362
|
+
}
|
|
344
363
|
/**
|
|
345
364
|
* Thrown when the manifest fails validation (missing id/name, bad expiry,
|
|
346
365
|
* empty actions on a permission, etc).
|
|
@@ -357,6 +376,14 @@ declare const DEFAULT_EXPIRY = "30d";
|
|
|
357
376
|
* Default `defaults` value when the manifest omits it. Spec: standard tier.
|
|
358
377
|
*/
|
|
359
378
|
declare const DEFAULT_DEFAULTS: ManifestDefaults;
|
|
379
|
+
/** Default manifest schema version. */
|
|
380
|
+
declare const DEFAULT_MANIFEST_VERSION = 1;
|
|
381
|
+
/** Default space for manifest-declared app data. */
|
|
382
|
+
declare const DEFAULT_MANIFEST_SPACE = "applications";
|
|
383
|
+
/** Account-space name used for installed-application registry records. */
|
|
384
|
+
declare const ACCOUNT_REGISTRY_SPACE = "account";
|
|
385
|
+
/** Account-space KV prefix used for installed-application registry records. */
|
|
386
|
+
declare const ACCOUNT_REGISTRY_PATH = "applications/";
|
|
360
387
|
/**
|
|
361
388
|
* Known services and their short-form (recap URI) names. The TinyCloud
|
|
362
389
|
* node encodes the recap resource URI with the short service name, while
|
|
@@ -423,13 +450,19 @@ declare function normalizeDefaults(value: Manifest["defaults"] | undefined): Man
|
|
|
423
450
|
* expiries. Pure function — does no I/O.
|
|
424
451
|
*
|
|
425
452
|
* Resolution semantics (spec):
|
|
426
|
-
* - `prefix` defaults to `
|
|
453
|
+
* - `prefix` defaults to `app_id`; set to `""` to disable prefix application entirely.
|
|
454
|
+
* - `space` defaults to `applications`; per-permission `space` overrides it.
|
|
427
455
|
* - `defaults` defaults to `true` (standard tier); unknown string values fall back to `true`.
|
|
428
456
|
* - Per-entry expiry overrides per-delegation overrides manifest > `DEFAULT_EXPIRY`.
|
|
429
457
|
* - Default entries use `skipPrefix: false` so they inherit the manifest prefix.
|
|
430
|
-
* - Prefix inheritance applies identically to `permissions` and `delegations[*].permissions`.
|
|
431
458
|
*/
|
|
432
459
|
declare function resolveManifest(input: Manifest): ResolvedCapabilities;
|
|
460
|
+
/**
|
|
461
|
+
* Compose one or more manifests into the single capability request that should
|
|
462
|
+
* be signed. Fetching manifests is intentionally out of band; callers pass the
|
|
463
|
+
* already-loaded manifest objects.
|
|
464
|
+
*/
|
|
465
|
+
declare function composeManifestRequest(inputs: readonly Manifest[], options?: ComposeManifestOptions): ComposedManifestRequest;
|
|
433
466
|
/**
|
|
434
467
|
* The shape `prepareSession` and the multi-resource `createDelegation` WASM
|
|
435
468
|
* export both accept:
|
|
@@ -449,6 +482,14 @@ declare function resolveManifest(input: Manifest): ResolvedCapabilities;
|
|
|
449
482
|
* for both so one manifest drives both sides.
|
|
450
483
|
*/
|
|
451
484
|
type AbilitiesMap = Record<string, Record<string, string[]>>;
|
|
485
|
+
/**
|
|
486
|
+
* Per-space abilities map accepted by the newer WASM session config:
|
|
487
|
+
*
|
|
488
|
+
* ```
|
|
489
|
+
* { [spaceIdOrName]: { [shortService]: { [path]: [fullUrnAction, ...] } } }
|
|
490
|
+
* ```
|
|
491
|
+
*/
|
|
492
|
+
type SpaceAbilitiesMap = Record<string, AbilitiesMap>;
|
|
452
493
|
/**
|
|
453
494
|
* Convert a list of {@link ResourceCapability} entries (manifest
|
|
454
495
|
* long-form service, full-URN actions) into the {@link AbilitiesMap}
|
|
@@ -466,6 +507,12 @@ type AbilitiesMap = Record<string, Record<string, string[]>>;
|
|
|
466
507
|
* normalize before calling.
|
|
467
508
|
*/
|
|
468
509
|
declare function resourceCapabilitiesToAbilitiesMap(resources: readonly ResourceCapability[]): AbilitiesMap;
|
|
510
|
+
/**
|
|
511
|
+
* Group resolved capabilities by `space`, then convert each group into a WASM
|
|
512
|
+
* abilities map. Short space names are left as-is here; platform layers that
|
|
513
|
+
* know the wallet address and chain id turn them into full SpaceIds.
|
|
514
|
+
*/
|
|
515
|
+
declare function resourceCapabilitiesToSpaceAbilitiesMap(resources: readonly ResourceCapability[]): SpaceAbilitiesMap;
|
|
469
516
|
/**
|
|
470
517
|
* Build the {@link AbilitiesMap} that a session should be signed with,
|
|
471
518
|
* given a {@link ResolvedCapabilities} (i.e. the output of
|
|
@@ -1140,8 +1187,8 @@ declare const KeyInfoSchema: z.ZodObject<{
|
|
|
1140
1187
|
priority: z.ZodNumber;
|
|
1141
1188
|
}, "strip", z.ZodTypeAny, {
|
|
1142
1189
|
type: "session" | "main" | "ingested";
|
|
1143
|
-
id: string;
|
|
1144
1190
|
did: string;
|
|
1191
|
+
id: string;
|
|
1145
1192
|
priority: number;
|
|
1146
1193
|
jwk?: {
|
|
1147
1194
|
kty: string;
|
|
@@ -1158,8 +1205,8 @@ declare const KeyInfoSchema: z.ZodObject<{
|
|
|
1158
1205
|
} | undefined;
|
|
1159
1206
|
}, {
|
|
1160
1207
|
type: "session" | "main" | "ingested";
|
|
1161
|
-
id: string;
|
|
1162
1208
|
did: string;
|
|
1209
|
+
id: string;
|
|
1163
1210
|
priority: number;
|
|
1164
1211
|
jwk?: {
|
|
1165
1212
|
kty: string;
|
|
@@ -1351,8 +1398,8 @@ declare const CapabilityEntrySchema: z.ZodObject<{
|
|
|
1351
1398
|
priority: z.ZodNumber;
|
|
1352
1399
|
}, "strip", z.ZodTypeAny, {
|
|
1353
1400
|
type: "session" | "main" | "ingested";
|
|
1354
|
-
id: string;
|
|
1355
1401
|
did: string;
|
|
1402
|
+
id: string;
|
|
1356
1403
|
priority: number;
|
|
1357
1404
|
jwk?: {
|
|
1358
1405
|
kty: string;
|
|
@@ -1369,8 +1416,8 @@ declare const CapabilityEntrySchema: z.ZodObject<{
|
|
|
1369
1416
|
} | undefined;
|
|
1370
1417
|
}, {
|
|
1371
1418
|
type: "session" | "main" | "ingested";
|
|
1372
|
-
id: string;
|
|
1373
1419
|
did: string;
|
|
1420
|
+
id: string;
|
|
1374
1421
|
priority: number;
|
|
1375
1422
|
jwk?: {
|
|
1376
1423
|
kty: string;
|
|
@@ -1444,8 +1491,8 @@ declare const CapabilityEntrySchema: z.ZodObject<{
|
|
|
1444
1491
|
}, "strip", z.ZodTypeAny, {
|
|
1445
1492
|
keys: {
|
|
1446
1493
|
type: "session" | "main" | "ingested";
|
|
1447
|
-
id: string;
|
|
1448
1494
|
did: string;
|
|
1495
|
+
id: string;
|
|
1449
1496
|
priority: number;
|
|
1450
1497
|
jwk?: {
|
|
1451
1498
|
kty: string;
|
|
@@ -1481,8 +1528,8 @@ declare const CapabilityEntrySchema: z.ZodObject<{
|
|
|
1481
1528
|
}, {
|
|
1482
1529
|
keys: {
|
|
1483
1530
|
type: "session" | "main" | "ingested";
|
|
1484
|
-
id: string;
|
|
1485
1531
|
did: string;
|
|
1532
|
+
id: string;
|
|
1486
1533
|
priority: number;
|
|
1487
1534
|
jwk?: {
|
|
1488
1535
|
kty: string;
|
|
@@ -2088,8 +2135,8 @@ declare const ShareLinkSchema: z.ZodObject<{
|
|
|
2088
2135
|
};
|
|
2089
2136
|
token: string;
|
|
2090
2137
|
schema: "base64" | "compact" | "ipfs";
|
|
2091
|
-
expiresAt?: Date | undefined;
|
|
2092
2138
|
description?: string | undefined;
|
|
2139
|
+
expiresAt?: Date | undefined;
|
|
2093
2140
|
}, {
|
|
2094
2141
|
url: string;
|
|
2095
2142
|
delegation: {
|
|
@@ -2108,8 +2155,8 @@ declare const ShareLinkSchema: z.ZodObject<{
|
|
|
2108
2155
|
};
|
|
2109
2156
|
token: string;
|
|
2110
2157
|
schema: "base64" | "compact" | "ipfs";
|
|
2111
|
-
expiresAt?: Date | undefined;
|
|
2112
2158
|
description?: string | undefined;
|
|
2159
|
+
expiresAt?: Date | undefined;
|
|
2113
2160
|
}>;
|
|
2114
2161
|
type ShareLink = z.infer<typeof ShareLinkSchema>;
|
|
2115
2162
|
type ShareLinkData<T = unknown> = {
|
|
@@ -2166,15 +2213,15 @@ declare const GenerateShareParamsSchema: z.ZodObject<{
|
|
|
2166
2213
|
path: string;
|
|
2167
2214
|
actions?: string[] | undefined;
|
|
2168
2215
|
expiry?: Date | undefined;
|
|
2169
|
-
schema?: "base64" | "compact" | "ipfs" | undefined;
|
|
2170
2216
|
description?: string | undefined;
|
|
2217
|
+
schema?: "base64" | "compact" | "ipfs" | undefined;
|
|
2171
2218
|
baseUrl?: string | undefined;
|
|
2172
2219
|
}, {
|
|
2173
2220
|
path: string;
|
|
2174
2221
|
actions?: string[] | undefined;
|
|
2175
2222
|
expiry?: Date | undefined;
|
|
2176
|
-
schema?: "base64" | "compact" | "ipfs" | undefined;
|
|
2177
2223
|
description?: string | undefined;
|
|
2224
|
+
schema?: "base64" | "compact" | "ipfs" | undefined;
|
|
2178
2225
|
baseUrl?: string | undefined;
|
|
2179
2226
|
}>;
|
|
2180
2227
|
type GenerateShareParams = z.infer<typeof GenerateShareParamsSchema>;
|
|
@@ -4390,4 +4437,4 @@ interface NodeInfo {
|
|
|
4390
4437
|
}
|
|
4391
4438
|
declare function checkNodeInfo(host: string, sdkProtocol: number, fetchFn?: typeof globalThis.fetch): Promise<NodeInfo>;
|
|
4392
4439
|
|
|
4393
|
-
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
|
|
4440
|
+
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, type AbilitiesMap, AutoApproveSpaceCreationHandler, type AutoRejectStrategy, type AutoSignStrategy, type Bytes, type CallbackStrategy, type CapabilityEntry, CapabilityKeyRegistry, type CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, type ClientSession, ClientSessionSchema, type ComposeManifestOptions, type ComposedManifestRequest, type CreateDelegationFunction, type CreateDelegationParams, type CreateDelegationWasmParams, type CreateDelegationWasmResult, DEFAULT_DEFAULTS, DEFAULT_EXPIRY, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, 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 ManifestRegistryRecord, 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 SignInOptions, type SignRequest, type SignResponse, type SignStrategy, SilentNotificationHandler, type SiweConfig, SiweConfigSchema, Space, type SpaceAbilitiesMap, 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, composeManifestRequest, createCapabilityKeyRegistry, createSharingService, createSpaceService, defaultSignStrategy, defaultSpaceCreationHandler, expandActionShortNames, fetchPeerId, isCapabilitySubset, loadManifest, makePublicSpaceId, manifestAbilitiesUnion, normalizeDefaults, parseExpiry, parseRecapCapabilities, parseSpaceUri, resolveManifest, resourceCapabilitiesToAbilitiesMap, resourceCapabilitiesToSpaceAbilitiesMap, submitHostDelegation, validateClientSession, validateManifest, validatePersistedSessionData };
|
package/dist/index.d.ts
CHANGED
|
@@ -206,8 +206,8 @@ interface IENSResolver {
|
|
|
206
206
|
interface PermissionEntry {
|
|
207
207
|
/** Service namespace, e.g. "tinycloud.kv", "tinycloud.sql", "tinycloud.duckdb", "tinycloud.capabilities". */
|
|
208
208
|
service: string;
|
|
209
|
-
/**
|
|
210
|
-
space
|
|
209
|
+
/** Space name or full space URI. Defaults to "applications" inside manifests. */
|
|
210
|
+
space?: string;
|
|
211
211
|
/**
|
|
212
212
|
* Service-specific path.
|
|
213
213
|
* - tinycloud.kv: hierarchical prefix. "/" = all, "foo/" = prefix match, "foo" = exact key
|
|
@@ -226,23 +226,8 @@ interface PermissionEntry {
|
|
|
226
226
|
skipPrefix?: boolean;
|
|
227
227
|
/** Per-entry expiry override, ms-format. */
|
|
228
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[];
|
|
229
|
+
/** User/agent-facing context for why this permission is requested. */
|
|
230
|
+
description?: string;
|
|
246
231
|
}
|
|
247
232
|
/**
|
|
248
233
|
* The valid values for `Manifest.defaults`.
|
|
@@ -261,22 +246,26 @@ type ManifestDefaults = boolean | "admin" | "all";
|
|
|
261
246
|
*/
|
|
262
247
|
interface Manifest {
|
|
263
248
|
/** Schema version. Optional, defaults to 1. */
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
|
|
249
|
+
manifest_version?: 1;
|
|
250
|
+
/** Application identifier / namespace prefix. Required. */
|
|
251
|
+
app_id: string;
|
|
267
252
|
/** Display name. Required. */
|
|
268
253
|
name: string;
|
|
269
|
-
/**
|
|
254
|
+
/** Description of what the app or delegate does. Optional. */
|
|
270
255
|
description?: string;
|
|
256
|
+
/** DID of this manifest's delegate target. Optional. Required only for delegation materialization. */
|
|
257
|
+
did?: string;
|
|
271
258
|
/** URL to app icon. Optional. */
|
|
272
259
|
icon?: string;
|
|
273
260
|
/** App version string. Optional. */
|
|
274
261
|
appVersion?: string;
|
|
275
262
|
/** Default expiry for permissions. ms-format ("30d", "2h", "1y"). Default "30d". */
|
|
276
263
|
expiry?: string;
|
|
264
|
+
/** Space name or full space URI. Optional, defaults to "applications". */
|
|
265
|
+
space?: string;
|
|
277
266
|
/**
|
|
278
267
|
* Path prefix auto-prepended to permission paths. Optional, defaults to
|
|
279
|
-
* `
|
|
268
|
+
* `app_id`. Set to `""` to disable entirely. Individual permissions can opt
|
|
280
269
|
* out with `skipPrefix: true`.
|
|
281
270
|
*/
|
|
282
271
|
prefix?: string;
|
|
@@ -292,8 +281,6 @@ interface Manifest {
|
|
|
292
281
|
* DuckDB (opt-in), or `skipPrefix: true` entries.
|
|
293
282
|
*/
|
|
294
283
|
permissions?: PermissionEntry[];
|
|
295
|
-
/** Pre-delegations to other DIDs at sign-in. */
|
|
296
|
-
delegations?: ManifestDelegation[];
|
|
297
284
|
}
|
|
298
285
|
/**
|
|
299
286
|
* A resolved permission entry with fully-expanded paths and action URNs.
|
|
@@ -303,7 +290,7 @@ interface Manifest {
|
|
|
303
290
|
interface ResourceCapability {
|
|
304
291
|
/** Long-form service, e.g. "tinycloud.kv". */
|
|
305
292
|
service: string;
|
|
306
|
-
/** Space
|
|
293
|
+
/** Space name or URI. Short names are resolved to full SpaceIds at sign-in time. */
|
|
307
294
|
space: string;
|
|
308
295
|
/** Path with the manifest prefix applied (or skipped per `skipPrefix`). */
|
|
309
296
|
path: string;
|
|
@@ -311,6 +298,8 @@ interface ResourceCapability {
|
|
|
311
298
|
actions: string[];
|
|
312
299
|
/** Per-entry expiry override in milliseconds. */
|
|
313
300
|
expiryMs?: number;
|
|
301
|
+
/** User/agent-facing context copied from the source permission entry. */
|
|
302
|
+
description?: string;
|
|
314
303
|
}
|
|
315
304
|
/**
|
|
316
305
|
* A resolved delegation entry with fully-expanded permissions.
|
|
@@ -330,17 +319,47 @@ interface ResolvedDelegate {
|
|
|
330
319
|
* ready to drive the SIWE recap.
|
|
331
320
|
*/
|
|
332
321
|
interface ResolvedCapabilities {
|
|
333
|
-
/**
|
|
334
|
-
|
|
322
|
+
/** Application identifier copied from manifest.app_id. */
|
|
323
|
+
app_id: string;
|
|
324
|
+
/** Delegate DID copied from manifest.did, when present. */
|
|
325
|
+
did?: string;
|
|
326
|
+
/** Effective default space for this manifest. */
|
|
327
|
+
space: string;
|
|
335
328
|
/** All session-key resources with paths fully resolved (prefix applied). */
|
|
336
329
|
resources: ResourceCapability[];
|
|
337
330
|
/** Default expiry for the session, in milliseconds. */
|
|
338
331
|
expiryMs: number;
|
|
339
332
|
/** Whether to include the public-space companion. */
|
|
340
333
|
includePublicSpace: boolean;
|
|
341
|
-
/**
|
|
334
|
+
/** Delegate targets derived from manifests that declare `did`. */
|
|
342
335
|
additionalDelegates: ResolvedDelegate[];
|
|
343
336
|
}
|
|
337
|
+
interface ManifestRegistryRecord {
|
|
338
|
+
/** KV key inside the account space. */
|
|
339
|
+
key: string;
|
|
340
|
+
/** App id this record describes. */
|
|
341
|
+
app_id: string;
|
|
342
|
+
/** Latest manifest payloads composed for this app id. */
|
|
343
|
+
manifests: Manifest[];
|
|
344
|
+
}
|
|
345
|
+
interface ComposeManifestOptions {
|
|
346
|
+
/** Include implicit account-space registry permissions. Default true. */
|
|
347
|
+
includeAccountRegistryPermissions?: boolean;
|
|
348
|
+
}
|
|
349
|
+
interface ComposedManifestRequest {
|
|
350
|
+
/** Validated manifests that were composed. */
|
|
351
|
+
manifests: Manifest[];
|
|
352
|
+
/** Full permission union requested from the user in one SIWE. */
|
|
353
|
+
resources: ResourceCapability[];
|
|
354
|
+
/** Delegations that can be materialized after sign-in. */
|
|
355
|
+
delegationTargets: ResolvedDelegate[];
|
|
356
|
+
/** Account-space registry records to write after successful sign-in. */
|
|
357
|
+
registryRecords: ManifestRegistryRecord[];
|
|
358
|
+
/** Effective session expiry, using the longest composed manifest expiry. */
|
|
359
|
+
expiryMs: number;
|
|
360
|
+
/** Whether to include the public-space companion behavior. */
|
|
361
|
+
includePublicSpace: boolean;
|
|
362
|
+
}
|
|
344
363
|
/**
|
|
345
364
|
* Thrown when the manifest fails validation (missing id/name, bad expiry,
|
|
346
365
|
* empty actions on a permission, etc).
|
|
@@ -357,6 +376,14 @@ declare const DEFAULT_EXPIRY = "30d";
|
|
|
357
376
|
* Default `defaults` value when the manifest omits it. Spec: standard tier.
|
|
358
377
|
*/
|
|
359
378
|
declare const DEFAULT_DEFAULTS: ManifestDefaults;
|
|
379
|
+
/** Default manifest schema version. */
|
|
380
|
+
declare const DEFAULT_MANIFEST_VERSION = 1;
|
|
381
|
+
/** Default space for manifest-declared app data. */
|
|
382
|
+
declare const DEFAULT_MANIFEST_SPACE = "applications";
|
|
383
|
+
/** Account-space name used for installed-application registry records. */
|
|
384
|
+
declare const ACCOUNT_REGISTRY_SPACE = "account";
|
|
385
|
+
/** Account-space KV prefix used for installed-application registry records. */
|
|
386
|
+
declare const ACCOUNT_REGISTRY_PATH = "applications/";
|
|
360
387
|
/**
|
|
361
388
|
* Known services and their short-form (recap URI) names. The TinyCloud
|
|
362
389
|
* node encodes the recap resource URI with the short service name, while
|
|
@@ -423,13 +450,19 @@ declare function normalizeDefaults(value: Manifest["defaults"] | undefined): Man
|
|
|
423
450
|
* expiries. Pure function — does no I/O.
|
|
424
451
|
*
|
|
425
452
|
* Resolution semantics (spec):
|
|
426
|
-
* - `prefix` defaults to `
|
|
453
|
+
* - `prefix` defaults to `app_id`; set to `""` to disable prefix application entirely.
|
|
454
|
+
* - `space` defaults to `applications`; per-permission `space` overrides it.
|
|
427
455
|
* - `defaults` defaults to `true` (standard tier); unknown string values fall back to `true`.
|
|
428
456
|
* - Per-entry expiry overrides per-delegation overrides manifest > `DEFAULT_EXPIRY`.
|
|
429
457
|
* - Default entries use `skipPrefix: false` so they inherit the manifest prefix.
|
|
430
|
-
* - Prefix inheritance applies identically to `permissions` and `delegations[*].permissions`.
|
|
431
458
|
*/
|
|
432
459
|
declare function resolveManifest(input: Manifest): ResolvedCapabilities;
|
|
460
|
+
/**
|
|
461
|
+
* Compose one or more manifests into the single capability request that should
|
|
462
|
+
* be signed. Fetching manifests is intentionally out of band; callers pass the
|
|
463
|
+
* already-loaded manifest objects.
|
|
464
|
+
*/
|
|
465
|
+
declare function composeManifestRequest(inputs: readonly Manifest[], options?: ComposeManifestOptions): ComposedManifestRequest;
|
|
433
466
|
/**
|
|
434
467
|
* The shape `prepareSession` and the multi-resource `createDelegation` WASM
|
|
435
468
|
* export both accept:
|
|
@@ -449,6 +482,14 @@ declare function resolveManifest(input: Manifest): ResolvedCapabilities;
|
|
|
449
482
|
* for both so one manifest drives both sides.
|
|
450
483
|
*/
|
|
451
484
|
type AbilitiesMap = Record<string, Record<string, string[]>>;
|
|
485
|
+
/**
|
|
486
|
+
* Per-space abilities map accepted by the newer WASM session config:
|
|
487
|
+
*
|
|
488
|
+
* ```
|
|
489
|
+
* { [spaceIdOrName]: { [shortService]: { [path]: [fullUrnAction, ...] } } }
|
|
490
|
+
* ```
|
|
491
|
+
*/
|
|
492
|
+
type SpaceAbilitiesMap = Record<string, AbilitiesMap>;
|
|
452
493
|
/**
|
|
453
494
|
* Convert a list of {@link ResourceCapability} entries (manifest
|
|
454
495
|
* long-form service, full-URN actions) into the {@link AbilitiesMap}
|
|
@@ -466,6 +507,12 @@ type AbilitiesMap = Record<string, Record<string, string[]>>;
|
|
|
466
507
|
* normalize before calling.
|
|
467
508
|
*/
|
|
468
509
|
declare function resourceCapabilitiesToAbilitiesMap(resources: readonly ResourceCapability[]): AbilitiesMap;
|
|
510
|
+
/**
|
|
511
|
+
* Group resolved capabilities by `space`, then convert each group into a WASM
|
|
512
|
+
* abilities map. Short space names are left as-is here; platform layers that
|
|
513
|
+
* know the wallet address and chain id turn them into full SpaceIds.
|
|
514
|
+
*/
|
|
515
|
+
declare function resourceCapabilitiesToSpaceAbilitiesMap(resources: readonly ResourceCapability[]): SpaceAbilitiesMap;
|
|
469
516
|
/**
|
|
470
517
|
* Build the {@link AbilitiesMap} that a session should be signed with,
|
|
471
518
|
* given a {@link ResolvedCapabilities} (i.e. the output of
|
|
@@ -1140,8 +1187,8 @@ declare const KeyInfoSchema: z.ZodObject<{
|
|
|
1140
1187
|
priority: z.ZodNumber;
|
|
1141
1188
|
}, "strip", z.ZodTypeAny, {
|
|
1142
1189
|
type: "session" | "main" | "ingested";
|
|
1143
|
-
id: string;
|
|
1144
1190
|
did: string;
|
|
1191
|
+
id: string;
|
|
1145
1192
|
priority: number;
|
|
1146
1193
|
jwk?: {
|
|
1147
1194
|
kty: string;
|
|
@@ -1158,8 +1205,8 @@ declare const KeyInfoSchema: z.ZodObject<{
|
|
|
1158
1205
|
} | undefined;
|
|
1159
1206
|
}, {
|
|
1160
1207
|
type: "session" | "main" | "ingested";
|
|
1161
|
-
id: string;
|
|
1162
1208
|
did: string;
|
|
1209
|
+
id: string;
|
|
1163
1210
|
priority: number;
|
|
1164
1211
|
jwk?: {
|
|
1165
1212
|
kty: string;
|
|
@@ -1351,8 +1398,8 @@ declare const CapabilityEntrySchema: z.ZodObject<{
|
|
|
1351
1398
|
priority: z.ZodNumber;
|
|
1352
1399
|
}, "strip", z.ZodTypeAny, {
|
|
1353
1400
|
type: "session" | "main" | "ingested";
|
|
1354
|
-
id: string;
|
|
1355
1401
|
did: string;
|
|
1402
|
+
id: string;
|
|
1356
1403
|
priority: number;
|
|
1357
1404
|
jwk?: {
|
|
1358
1405
|
kty: string;
|
|
@@ -1369,8 +1416,8 @@ declare const CapabilityEntrySchema: z.ZodObject<{
|
|
|
1369
1416
|
} | undefined;
|
|
1370
1417
|
}, {
|
|
1371
1418
|
type: "session" | "main" | "ingested";
|
|
1372
|
-
id: string;
|
|
1373
1419
|
did: string;
|
|
1420
|
+
id: string;
|
|
1374
1421
|
priority: number;
|
|
1375
1422
|
jwk?: {
|
|
1376
1423
|
kty: string;
|
|
@@ -1444,8 +1491,8 @@ declare const CapabilityEntrySchema: z.ZodObject<{
|
|
|
1444
1491
|
}, "strip", z.ZodTypeAny, {
|
|
1445
1492
|
keys: {
|
|
1446
1493
|
type: "session" | "main" | "ingested";
|
|
1447
|
-
id: string;
|
|
1448
1494
|
did: string;
|
|
1495
|
+
id: string;
|
|
1449
1496
|
priority: number;
|
|
1450
1497
|
jwk?: {
|
|
1451
1498
|
kty: string;
|
|
@@ -1481,8 +1528,8 @@ declare const CapabilityEntrySchema: z.ZodObject<{
|
|
|
1481
1528
|
}, {
|
|
1482
1529
|
keys: {
|
|
1483
1530
|
type: "session" | "main" | "ingested";
|
|
1484
|
-
id: string;
|
|
1485
1531
|
did: string;
|
|
1532
|
+
id: string;
|
|
1486
1533
|
priority: number;
|
|
1487
1534
|
jwk?: {
|
|
1488
1535
|
kty: string;
|
|
@@ -2088,8 +2135,8 @@ declare const ShareLinkSchema: z.ZodObject<{
|
|
|
2088
2135
|
};
|
|
2089
2136
|
token: string;
|
|
2090
2137
|
schema: "base64" | "compact" | "ipfs";
|
|
2091
|
-
expiresAt?: Date | undefined;
|
|
2092
2138
|
description?: string | undefined;
|
|
2139
|
+
expiresAt?: Date | undefined;
|
|
2093
2140
|
}, {
|
|
2094
2141
|
url: string;
|
|
2095
2142
|
delegation: {
|
|
@@ -2108,8 +2155,8 @@ declare const ShareLinkSchema: z.ZodObject<{
|
|
|
2108
2155
|
};
|
|
2109
2156
|
token: string;
|
|
2110
2157
|
schema: "base64" | "compact" | "ipfs";
|
|
2111
|
-
expiresAt?: Date | undefined;
|
|
2112
2158
|
description?: string | undefined;
|
|
2159
|
+
expiresAt?: Date | undefined;
|
|
2113
2160
|
}>;
|
|
2114
2161
|
type ShareLink = z.infer<typeof ShareLinkSchema>;
|
|
2115
2162
|
type ShareLinkData<T = unknown> = {
|
|
@@ -2166,15 +2213,15 @@ declare const GenerateShareParamsSchema: z.ZodObject<{
|
|
|
2166
2213
|
path: string;
|
|
2167
2214
|
actions?: string[] | undefined;
|
|
2168
2215
|
expiry?: Date | undefined;
|
|
2169
|
-
schema?: "base64" | "compact" | "ipfs" | undefined;
|
|
2170
2216
|
description?: string | undefined;
|
|
2217
|
+
schema?: "base64" | "compact" | "ipfs" | undefined;
|
|
2171
2218
|
baseUrl?: string | undefined;
|
|
2172
2219
|
}, {
|
|
2173
2220
|
path: string;
|
|
2174
2221
|
actions?: string[] | undefined;
|
|
2175
2222
|
expiry?: Date | undefined;
|
|
2176
|
-
schema?: "base64" | "compact" | "ipfs" | undefined;
|
|
2177
2223
|
description?: string | undefined;
|
|
2224
|
+
schema?: "base64" | "compact" | "ipfs" | undefined;
|
|
2178
2225
|
baseUrl?: string | undefined;
|
|
2179
2226
|
}>;
|
|
2180
2227
|
type GenerateShareParams = z.infer<typeof GenerateShareParamsSchema>;
|
|
@@ -4390,4 +4437,4 @@ interface NodeInfo {
|
|
|
4390
4437
|
}
|
|
4391
4438
|
declare function checkNodeInfo(host: string, sdkProtocol: number, fetchFn?: typeof globalThis.fetch): Promise<NodeInfo>;
|
|
4392
4439
|
|
|
4393
|
-
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
|
|
4440
|
+
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, type AbilitiesMap, AutoApproveSpaceCreationHandler, type AutoRejectStrategy, type AutoSignStrategy, type Bytes, type CallbackStrategy, type CapabilityEntry, CapabilityKeyRegistry, type CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, type ClientSession, ClientSessionSchema, type ComposeManifestOptions, type ComposedManifestRequest, type CreateDelegationFunction, type CreateDelegationParams, type CreateDelegationWasmParams, type CreateDelegationWasmResult, DEFAULT_DEFAULTS, DEFAULT_EXPIRY, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, 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 ManifestRegistryRecord, 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 SignInOptions, type SignRequest, type SignResponse, type SignStrategy, SilentNotificationHandler, type SiweConfig, SiweConfigSchema, Space, type SpaceAbilitiesMap, 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, composeManifestRequest, createCapabilityKeyRegistry, createSharingService, createSpaceService, defaultSignStrategy, defaultSpaceCreationHandler, expandActionShortNames, fetchPeerId, isCapabilitySubset, loadManifest, makePublicSpaceId, manifestAbilitiesUnion, normalizeDefaults, parseExpiry, parseRecapCapabilities, parseSpaceUri, resolveManifest, resourceCapabilitiesToAbilitiesMap, resourceCapabilitiesToSpaceAbilitiesMap, submitHostDelegation, validateClientSession, validateManifest, validatePersistedSessionData };
|