@tinycloud/sdk-core 2.1.0-beta.5 → 2.2.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +173 -57
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +82 -39
- package/dist/index.d.ts +82 -39
- package/dist/index.js +167 -57
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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
|
|
@@ -227,23 +227,6 @@ interface PermissionEntry {
|
|
|
227
227
|
/** Per-entry expiry override, ms-format. */
|
|
228
228
|
expiry?: string;
|
|
229
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
230
|
/**
|
|
248
231
|
* The valid values for `Manifest.defaults`.
|
|
249
232
|
*
|
|
@@ -261,22 +244,26 @@ type ManifestDefaults = boolean | "admin" | "all";
|
|
|
261
244
|
*/
|
|
262
245
|
interface Manifest {
|
|
263
246
|
/** Schema version. Optional, defaults to 1. */
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
|
|
247
|
+
manifest_version?: 1;
|
|
248
|
+
/** Application identifier / namespace prefix. Required. */
|
|
249
|
+
app_id: string;
|
|
267
250
|
/** Display name. Required. */
|
|
268
251
|
name: string;
|
|
269
|
-
/**
|
|
252
|
+
/** Description of what the app or delegate does. Optional. */
|
|
270
253
|
description?: string;
|
|
254
|
+
/** DID of this manifest's delegate target. Optional. Required only for delegation materialization. */
|
|
255
|
+
did?: string;
|
|
271
256
|
/** URL to app icon. Optional. */
|
|
272
257
|
icon?: string;
|
|
273
258
|
/** App version string. Optional. */
|
|
274
259
|
appVersion?: string;
|
|
275
260
|
/** Default expiry for permissions. ms-format ("30d", "2h", "1y"). Default "30d". */
|
|
276
261
|
expiry?: string;
|
|
262
|
+
/** Space name or full space URI. Optional, defaults to "applications". */
|
|
263
|
+
space?: string;
|
|
277
264
|
/**
|
|
278
265
|
* Path prefix auto-prepended to permission paths. Optional, defaults to
|
|
279
|
-
* `
|
|
266
|
+
* `app_id`. Set to `""` to disable entirely. Individual permissions can opt
|
|
280
267
|
* out with `skipPrefix: true`.
|
|
281
268
|
*/
|
|
282
269
|
prefix?: string;
|
|
@@ -292,8 +279,6 @@ interface Manifest {
|
|
|
292
279
|
* DuckDB (opt-in), or `skipPrefix: true` entries.
|
|
293
280
|
*/
|
|
294
281
|
permissions?: PermissionEntry[];
|
|
295
|
-
/** Pre-delegations to other DIDs at sign-in. */
|
|
296
|
-
delegations?: ManifestDelegation[];
|
|
297
282
|
}
|
|
298
283
|
/**
|
|
299
284
|
* A resolved permission entry with fully-expanded paths and action URNs.
|
|
@@ -303,7 +288,7 @@ interface Manifest {
|
|
|
303
288
|
interface ResourceCapability {
|
|
304
289
|
/** Long-form service, e.g. "tinycloud.kv". */
|
|
305
290
|
service: string;
|
|
306
|
-
/** Space
|
|
291
|
+
/** Space name or URI. Short names are resolved to full SpaceIds at sign-in time. */
|
|
307
292
|
space: string;
|
|
308
293
|
/** Path with the manifest prefix applied (or skipped per `skipPrefix`). */
|
|
309
294
|
path: string;
|
|
@@ -330,17 +315,47 @@ interface ResolvedDelegate {
|
|
|
330
315
|
* ready to drive the SIWE recap.
|
|
331
316
|
*/
|
|
332
317
|
interface ResolvedCapabilities {
|
|
333
|
-
/**
|
|
334
|
-
|
|
318
|
+
/** Application identifier copied from manifest.app_id. */
|
|
319
|
+
app_id: string;
|
|
320
|
+
/** Delegate DID copied from manifest.did, when present. */
|
|
321
|
+
did?: string;
|
|
322
|
+
/** Effective default space for this manifest. */
|
|
323
|
+
space: string;
|
|
335
324
|
/** All session-key resources with paths fully resolved (prefix applied). */
|
|
336
325
|
resources: ResourceCapability[];
|
|
337
326
|
/** Default expiry for the session, in milliseconds. */
|
|
338
327
|
expiryMs: number;
|
|
339
328
|
/** Whether to include the public-space companion. */
|
|
340
329
|
includePublicSpace: boolean;
|
|
341
|
-
/**
|
|
330
|
+
/** Delegate targets derived from manifests that declare `did`. */
|
|
342
331
|
additionalDelegates: ResolvedDelegate[];
|
|
343
332
|
}
|
|
333
|
+
interface ManifestRegistryRecord {
|
|
334
|
+
/** KV key inside the account space. */
|
|
335
|
+
key: string;
|
|
336
|
+
/** App id this record describes. */
|
|
337
|
+
app_id: string;
|
|
338
|
+
/** Latest manifest payloads composed for this app id. */
|
|
339
|
+
manifests: Manifest[];
|
|
340
|
+
}
|
|
341
|
+
interface ComposeManifestOptions {
|
|
342
|
+
/** Include implicit account-space registry permissions. Default true. */
|
|
343
|
+
includeAccountRegistryPermissions?: boolean;
|
|
344
|
+
}
|
|
345
|
+
interface ComposedManifestRequest {
|
|
346
|
+
/** Validated manifests that were composed. */
|
|
347
|
+
manifests: Manifest[];
|
|
348
|
+
/** Full permission union requested from the user in one SIWE. */
|
|
349
|
+
resources: ResourceCapability[];
|
|
350
|
+
/** Delegations that can be materialized after sign-in. */
|
|
351
|
+
delegationTargets: ResolvedDelegate[];
|
|
352
|
+
/** Account-space registry records to write after successful sign-in. */
|
|
353
|
+
registryRecords: ManifestRegistryRecord[];
|
|
354
|
+
/** Effective session expiry, using the longest composed manifest expiry. */
|
|
355
|
+
expiryMs: number;
|
|
356
|
+
/** Whether to include the public-space companion behavior. */
|
|
357
|
+
includePublicSpace: boolean;
|
|
358
|
+
}
|
|
344
359
|
/**
|
|
345
360
|
* Thrown when the manifest fails validation (missing id/name, bad expiry,
|
|
346
361
|
* empty actions on a permission, etc).
|
|
@@ -357,6 +372,14 @@ declare const DEFAULT_EXPIRY = "30d";
|
|
|
357
372
|
* Default `defaults` value when the manifest omits it. Spec: standard tier.
|
|
358
373
|
*/
|
|
359
374
|
declare const DEFAULT_DEFAULTS: ManifestDefaults;
|
|
375
|
+
/** Default manifest schema version. */
|
|
376
|
+
declare const DEFAULT_MANIFEST_VERSION = 1;
|
|
377
|
+
/** Default space for manifest-declared app data. */
|
|
378
|
+
declare const DEFAULT_MANIFEST_SPACE = "applications";
|
|
379
|
+
/** Account-space name used for installed-application registry records. */
|
|
380
|
+
declare const ACCOUNT_REGISTRY_SPACE = "account";
|
|
381
|
+
/** Account-space KV prefix used for installed-application registry records. */
|
|
382
|
+
declare const ACCOUNT_REGISTRY_PATH = "applications/";
|
|
360
383
|
/**
|
|
361
384
|
* Known services and their short-form (recap URI) names. The TinyCloud
|
|
362
385
|
* node encodes the recap resource URI with the short service name, while
|
|
@@ -423,13 +446,19 @@ declare function normalizeDefaults(value: Manifest["defaults"] | undefined): Man
|
|
|
423
446
|
* expiries. Pure function — does no I/O.
|
|
424
447
|
*
|
|
425
448
|
* Resolution semantics (spec):
|
|
426
|
-
* - `prefix` defaults to `
|
|
449
|
+
* - `prefix` defaults to `app_id`; set to `""` to disable prefix application entirely.
|
|
450
|
+
* - `space` defaults to `applications`; per-permission `space` overrides it.
|
|
427
451
|
* - `defaults` defaults to `true` (standard tier); unknown string values fall back to `true`.
|
|
428
452
|
* - Per-entry expiry overrides per-delegation overrides manifest > `DEFAULT_EXPIRY`.
|
|
429
453
|
* - Default entries use `skipPrefix: false` so they inherit the manifest prefix.
|
|
430
|
-
* - Prefix inheritance applies identically to `permissions` and `delegations[*].permissions`.
|
|
431
454
|
*/
|
|
432
455
|
declare function resolveManifest(input: Manifest): ResolvedCapabilities;
|
|
456
|
+
/**
|
|
457
|
+
* Compose one or more manifests into the single capability request that should
|
|
458
|
+
* be signed. Fetching manifests is intentionally out of band; callers pass the
|
|
459
|
+
* already-loaded manifest objects.
|
|
460
|
+
*/
|
|
461
|
+
declare function composeManifestRequest(inputs: readonly Manifest[], options?: ComposeManifestOptions): ComposedManifestRequest;
|
|
433
462
|
/**
|
|
434
463
|
* The shape `prepareSession` and the multi-resource `createDelegation` WASM
|
|
435
464
|
* export both accept:
|
|
@@ -449,6 +478,14 @@ declare function resolveManifest(input: Manifest): ResolvedCapabilities;
|
|
|
449
478
|
* for both so one manifest drives both sides.
|
|
450
479
|
*/
|
|
451
480
|
type AbilitiesMap = Record<string, Record<string, string[]>>;
|
|
481
|
+
/**
|
|
482
|
+
* Per-space abilities map accepted by the newer WASM session config:
|
|
483
|
+
*
|
|
484
|
+
* ```
|
|
485
|
+
* { [spaceIdOrName]: { [shortService]: { [path]: [fullUrnAction, ...] } } }
|
|
486
|
+
* ```
|
|
487
|
+
*/
|
|
488
|
+
type SpaceAbilitiesMap = Record<string, AbilitiesMap>;
|
|
452
489
|
/**
|
|
453
490
|
* Convert a list of {@link ResourceCapability} entries (manifest
|
|
454
491
|
* long-form service, full-URN actions) into the {@link AbilitiesMap}
|
|
@@ -466,6 +503,12 @@ type AbilitiesMap = Record<string, Record<string, string[]>>;
|
|
|
466
503
|
* normalize before calling.
|
|
467
504
|
*/
|
|
468
505
|
declare function resourceCapabilitiesToAbilitiesMap(resources: readonly ResourceCapability[]): AbilitiesMap;
|
|
506
|
+
/**
|
|
507
|
+
* Group resolved capabilities by `space`, then convert each group into a WASM
|
|
508
|
+
* abilities map. Short space names are left as-is here; platform layers that
|
|
509
|
+
* know the wallet address and chain id turn them into full SpaceIds.
|
|
510
|
+
*/
|
|
511
|
+
declare function resourceCapabilitiesToSpaceAbilitiesMap(resources: readonly ResourceCapability[]): SpaceAbilitiesMap;
|
|
469
512
|
/**
|
|
470
513
|
* Build the {@link AbilitiesMap} that a session should be signed with,
|
|
471
514
|
* given a {@link ResolvedCapabilities} (i.e. the output of
|
|
@@ -1140,8 +1183,8 @@ declare const KeyInfoSchema: z.ZodObject<{
|
|
|
1140
1183
|
priority: z.ZodNumber;
|
|
1141
1184
|
}, "strip", z.ZodTypeAny, {
|
|
1142
1185
|
type: "session" | "main" | "ingested";
|
|
1143
|
-
id: string;
|
|
1144
1186
|
did: string;
|
|
1187
|
+
id: string;
|
|
1145
1188
|
priority: number;
|
|
1146
1189
|
jwk?: {
|
|
1147
1190
|
kty: string;
|
|
@@ -1158,8 +1201,8 @@ declare const KeyInfoSchema: z.ZodObject<{
|
|
|
1158
1201
|
} | undefined;
|
|
1159
1202
|
}, {
|
|
1160
1203
|
type: "session" | "main" | "ingested";
|
|
1161
|
-
id: string;
|
|
1162
1204
|
did: string;
|
|
1205
|
+
id: string;
|
|
1163
1206
|
priority: number;
|
|
1164
1207
|
jwk?: {
|
|
1165
1208
|
kty: string;
|
|
@@ -1351,8 +1394,8 @@ declare const CapabilityEntrySchema: z.ZodObject<{
|
|
|
1351
1394
|
priority: z.ZodNumber;
|
|
1352
1395
|
}, "strip", z.ZodTypeAny, {
|
|
1353
1396
|
type: "session" | "main" | "ingested";
|
|
1354
|
-
id: string;
|
|
1355
1397
|
did: string;
|
|
1398
|
+
id: string;
|
|
1356
1399
|
priority: number;
|
|
1357
1400
|
jwk?: {
|
|
1358
1401
|
kty: string;
|
|
@@ -1369,8 +1412,8 @@ declare const CapabilityEntrySchema: z.ZodObject<{
|
|
|
1369
1412
|
} | undefined;
|
|
1370
1413
|
}, {
|
|
1371
1414
|
type: "session" | "main" | "ingested";
|
|
1372
|
-
id: string;
|
|
1373
1415
|
did: string;
|
|
1416
|
+
id: string;
|
|
1374
1417
|
priority: number;
|
|
1375
1418
|
jwk?: {
|
|
1376
1419
|
kty: string;
|
|
@@ -1444,8 +1487,8 @@ declare const CapabilityEntrySchema: z.ZodObject<{
|
|
|
1444
1487
|
}, "strip", z.ZodTypeAny, {
|
|
1445
1488
|
keys: {
|
|
1446
1489
|
type: "session" | "main" | "ingested";
|
|
1447
|
-
id: string;
|
|
1448
1490
|
did: string;
|
|
1491
|
+
id: string;
|
|
1449
1492
|
priority: number;
|
|
1450
1493
|
jwk?: {
|
|
1451
1494
|
kty: string;
|
|
@@ -1481,8 +1524,8 @@ declare const CapabilityEntrySchema: z.ZodObject<{
|
|
|
1481
1524
|
}, {
|
|
1482
1525
|
keys: {
|
|
1483
1526
|
type: "session" | "main" | "ingested";
|
|
1484
|
-
id: string;
|
|
1485
1527
|
did: string;
|
|
1528
|
+
id: string;
|
|
1486
1529
|
priority: number;
|
|
1487
1530
|
jwk?: {
|
|
1488
1531
|
kty: string;
|
|
@@ -4390,4 +4433,4 @@ interface NodeInfo {
|
|
|
4390
4433
|
}
|
|
4391
4434
|
declare function checkNodeInfo(host: string, sdkProtocol: number, fetchFn?: typeof globalThis.fetch): Promise<NodeInfo>;
|
|
4392
4435
|
|
|
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
|
|
4436
|
+
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
|
|
@@ -227,23 +227,6 @@ interface PermissionEntry {
|
|
|
227
227
|
/** Per-entry expiry override, ms-format. */
|
|
228
228
|
expiry?: string;
|
|
229
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
230
|
/**
|
|
248
231
|
* The valid values for `Manifest.defaults`.
|
|
249
232
|
*
|
|
@@ -261,22 +244,26 @@ type ManifestDefaults = boolean | "admin" | "all";
|
|
|
261
244
|
*/
|
|
262
245
|
interface Manifest {
|
|
263
246
|
/** Schema version. Optional, defaults to 1. */
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
|
|
247
|
+
manifest_version?: 1;
|
|
248
|
+
/** Application identifier / namespace prefix. Required. */
|
|
249
|
+
app_id: string;
|
|
267
250
|
/** Display name. Required. */
|
|
268
251
|
name: string;
|
|
269
|
-
/**
|
|
252
|
+
/** Description of what the app or delegate does. Optional. */
|
|
270
253
|
description?: string;
|
|
254
|
+
/** DID of this manifest's delegate target. Optional. Required only for delegation materialization. */
|
|
255
|
+
did?: string;
|
|
271
256
|
/** URL to app icon. Optional. */
|
|
272
257
|
icon?: string;
|
|
273
258
|
/** App version string. Optional. */
|
|
274
259
|
appVersion?: string;
|
|
275
260
|
/** Default expiry for permissions. ms-format ("30d", "2h", "1y"). Default "30d". */
|
|
276
261
|
expiry?: string;
|
|
262
|
+
/** Space name or full space URI. Optional, defaults to "applications". */
|
|
263
|
+
space?: string;
|
|
277
264
|
/**
|
|
278
265
|
* Path prefix auto-prepended to permission paths. Optional, defaults to
|
|
279
|
-
* `
|
|
266
|
+
* `app_id`. Set to `""` to disable entirely. Individual permissions can opt
|
|
280
267
|
* out with `skipPrefix: true`.
|
|
281
268
|
*/
|
|
282
269
|
prefix?: string;
|
|
@@ -292,8 +279,6 @@ interface Manifest {
|
|
|
292
279
|
* DuckDB (opt-in), or `skipPrefix: true` entries.
|
|
293
280
|
*/
|
|
294
281
|
permissions?: PermissionEntry[];
|
|
295
|
-
/** Pre-delegations to other DIDs at sign-in. */
|
|
296
|
-
delegations?: ManifestDelegation[];
|
|
297
282
|
}
|
|
298
283
|
/**
|
|
299
284
|
* A resolved permission entry with fully-expanded paths and action URNs.
|
|
@@ -303,7 +288,7 @@ interface Manifest {
|
|
|
303
288
|
interface ResourceCapability {
|
|
304
289
|
/** Long-form service, e.g. "tinycloud.kv". */
|
|
305
290
|
service: string;
|
|
306
|
-
/** Space
|
|
291
|
+
/** Space name or URI. Short names are resolved to full SpaceIds at sign-in time. */
|
|
307
292
|
space: string;
|
|
308
293
|
/** Path with the manifest prefix applied (or skipped per `skipPrefix`). */
|
|
309
294
|
path: string;
|
|
@@ -330,17 +315,47 @@ interface ResolvedDelegate {
|
|
|
330
315
|
* ready to drive the SIWE recap.
|
|
331
316
|
*/
|
|
332
317
|
interface ResolvedCapabilities {
|
|
333
|
-
/**
|
|
334
|
-
|
|
318
|
+
/** Application identifier copied from manifest.app_id. */
|
|
319
|
+
app_id: string;
|
|
320
|
+
/** Delegate DID copied from manifest.did, when present. */
|
|
321
|
+
did?: string;
|
|
322
|
+
/** Effective default space for this manifest. */
|
|
323
|
+
space: string;
|
|
335
324
|
/** All session-key resources with paths fully resolved (prefix applied). */
|
|
336
325
|
resources: ResourceCapability[];
|
|
337
326
|
/** Default expiry for the session, in milliseconds. */
|
|
338
327
|
expiryMs: number;
|
|
339
328
|
/** Whether to include the public-space companion. */
|
|
340
329
|
includePublicSpace: boolean;
|
|
341
|
-
/**
|
|
330
|
+
/** Delegate targets derived from manifests that declare `did`. */
|
|
342
331
|
additionalDelegates: ResolvedDelegate[];
|
|
343
332
|
}
|
|
333
|
+
interface ManifestRegistryRecord {
|
|
334
|
+
/** KV key inside the account space. */
|
|
335
|
+
key: string;
|
|
336
|
+
/** App id this record describes. */
|
|
337
|
+
app_id: string;
|
|
338
|
+
/** Latest manifest payloads composed for this app id. */
|
|
339
|
+
manifests: Manifest[];
|
|
340
|
+
}
|
|
341
|
+
interface ComposeManifestOptions {
|
|
342
|
+
/** Include implicit account-space registry permissions. Default true. */
|
|
343
|
+
includeAccountRegistryPermissions?: boolean;
|
|
344
|
+
}
|
|
345
|
+
interface ComposedManifestRequest {
|
|
346
|
+
/** Validated manifests that were composed. */
|
|
347
|
+
manifests: Manifest[];
|
|
348
|
+
/** Full permission union requested from the user in one SIWE. */
|
|
349
|
+
resources: ResourceCapability[];
|
|
350
|
+
/** Delegations that can be materialized after sign-in. */
|
|
351
|
+
delegationTargets: ResolvedDelegate[];
|
|
352
|
+
/** Account-space registry records to write after successful sign-in. */
|
|
353
|
+
registryRecords: ManifestRegistryRecord[];
|
|
354
|
+
/** Effective session expiry, using the longest composed manifest expiry. */
|
|
355
|
+
expiryMs: number;
|
|
356
|
+
/** Whether to include the public-space companion behavior. */
|
|
357
|
+
includePublicSpace: boolean;
|
|
358
|
+
}
|
|
344
359
|
/**
|
|
345
360
|
* Thrown when the manifest fails validation (missing id/name, bad expiry,
|
|
346
361
|
* empty actions on a permission, etc).
|
|
@@ -357,6 +372,14 @@ declare const DEFAULT_EXPIRY = "30d";
|
|
|
357
372
|
* Default `defaults` value when the manifest omits it. Spec: standard tier.
|
|
358
373
|
*/
|
|
359
374
|
declare const DEFAULT_DEFAULTS: ManifestDefaults;
|
|
375
|
+
/** Default manifest schema version. */
|
|
376
|
+
declare const DEFAULT_MANIFEST_VERSION = 1;
|
|
377
|
+
/** Default space for manifest-declared app data. */
|
|
378
|
+
declare const DEFAULT_MANIFEST_SPACE = "applications";
|
|
379
|
+
/** Account-space name used for installed-application registry records. */
|
|
380
|
+
declare const ACCOUNT_REGISTRY_SPACE = "account";
|
|
381
|
+
/** Account-space KV prefix used for installed-application registry records. */
|
|
382
|
+
declare const ACCOUNT_REGISTRY_PATH = "applications/";
|
|
360
383
|
/**
|
|
361
384
|
* Known services and their short-form (recap URI) names. The TinyCloud
|
|
362
385
|
* node encodes the recap resource URI with the short service name, while
|
|
@@ -423,13 +446,19 @@ declare function normalizeDefaults(value: Manifest["defaults"] | undefined): Man
|
|
|
423
446
|
* expiries. Pure function — does no I/O.
|
|
424
447
|
*
|
|
425
448
|
* Resolution semantics (spec):
|
|
426
|
-
* - `prefix` defaults to `
|
|
449
|
+
* - `prefix` defaults to `app_id`; set to `""` to disable prefix application entirely.
|
|
450
|
+
* - `space` defaults to `applications`; per-permission `space` overrides it.
|
|
427
451
|
* - `defaults` defaults to `true` (standard tier); unknown string values fall back to `true`.
|
|
428
452
|
* - Per-entry expiry overrides per-delegation overrides manifest > `DEFAULT_EXPIRY`.
|
|
429
453
|
* - Default entries use `skipPrefix: false` so they inherit the manifest prefix.
|
|
430
|
-
* - Prefix inheritance applies identically to `permissions` and `delegations[*].permissions`.
|
|
431
454
|
*/
|
|
432
455
|
declare function resolveManifest(input: Manifest): ResolvedCapabilities;
|
|
456
|
+
/**
|
|
457
|
+
* Compose one or more manifests into the single capability request that should
|
|
458
|
+
* be signed. Fetching manifests is intentionally out of band; callers pass the
|
|
459
|
+
* already-loaded manifest objects.
|
|
460
|
+
*/
|
|
461
|
+
declare function composeManifestRequest(inputs: readonly Manifest[], options?: ComposeManifestOptions): ComposedManifestRequest;
|
|
433
462
|
/**
|
|
434
463
|
* The shape `prepareSession` and the multi-resource `createDelegation` WASM
|
|
435
464
|
* export both accept:
|
|
@@ -449,6 +478,14 @@ declare function resolveManifest(input: Manifest): ResolvedCapabilities;
|
|
|
449
478
|
* for both so one manifest drives both sides.
|
|
450
479
|
*/
|
|
451
480
|
type AbilitiesMap = Record<string, Record<string, string[]>>;
|
|
481
|
+
/**
|
|
482
|
+
* Per-space abilities map accepted by the newer WASM session config:
|
|
483
|
+
*
|
|
484
|
+
* ```
|
|
485
|
+
* { [spaceIdOrName]: { [shortService]: { [path]: [fullUrnAction, ...] } } }
|
|
486
|
+
* ```
|
|
487
|
+
*/
|
|
488
|
+
type SpaceAbilitiesMap = Record<string, AbilitiesMap>;
|
|
452
489
|
/**
|
|
453
490
|
* Convert a list of {@link ResourceCapability} entries (manifest
|
|
454
491
|
* long-form service, full-URN actions) into the {@link AbilitiesMap}
|
|
@@ -466,6 +503,12 @@ type AbilitiesMap = Record<string, Record<string, string[]>>;
|
|
|
466
503
|
* normalize before calling.
|
|
467
504
|
*/
|
|
468
505
|
declare function resourceCapabilitiesToAbilitiesMap(resources: readonly ResourceCapability[]): AbilitiesMap;
|
|
506
|
+
/**
|
|
507
|
+
* Group resolved capabilities by `space`, then convert each group into a WASM
|
|
508
|
+
* abilities map. Short space names are left as-is here; platform layers that
|
|
509
|
+
* know the wallet address and chain id turn them into full SpaceIds.
|
|
510
|
+
*/
|
|
511
|
+
declare function resourceCapabilitiesToSpaceAbilitiesMap(resources: readonly ResourceCapability[]): SpaceAbilitiesMap;
|
|
469
512
|
/**
|
|
470
513
|
* Build the {@link AbilitiesMap} that a session should be signed with,
|
|
471
514
|
* given a {@link ResolvedCapabilities} (i.e. the output of
|
|
@@ -1140,8 +1183,8 @@ declare const KeyInfoSchema: z.ZodObject<{
|
|
|
1140
1183
|
priority: z.ZodNumber;
|
|
1141
1184
|
}, "strip", z.ZodTypeAny, {
|
|
1142
1185
|
type: "session" | "main" | "ingested";
|
|
1143
|
-
id: string;
|
|
1144
1186
|
did: string;
|
|
1187
|
+
id: string;
|
|
1145
1188
|
priority: number;
|
|
1146
1189
|
jwk?: {
|
|
1147
1190
|
kty: string;
|
|
@@ -1158,8 +1201,8 @@ declare const KeyInfoSchema: z.ZodObject<{
|
|
|
1158
1201
|
} | undefined;
|
|
1159
1202
|
}, {
|
|
1160
1203
|
type: "session" | "main" | "ingested";
|
|
1161
|
-
id: string;
|
|
1162
1204
|
did: string;
|
|
1205
|
+
id: string;
|
|
1163
1206
|
priority: number;
|
|
1164
1207
|
jwk?: {
|
|
1165
1208
|
kty: string;
|
|
@@ -1351,8 +1394,8 @@ declare const CapabilityEntrySchema: z.ZodObject<{
|
|
|
1351
1394
|
priority: z.ZodNumber;
|
|
1352
1395
|
}, "strip", z.ZodTypeAny, {
|
|
1353
1396
|
type: "session" | "main" | "ingested";
|
|
1354
|
-
id: string;
|
|
1355
1397
|
did: string;
|
|
1398
|
+
id: string;
|
|
1356
1399
|
priority: number;
|
|
1357
1400
|
jwk?: {
|
|
1358
1401
|
kty: string;
|
|
@@ -1369,8 +1412,8 @@ declare const CapabilityEntrySchema: z.ZodObject<{
|
|
|
1369
1412
|
} | undefined;
|
|
1370
1413
|
}, {
|
|
1371
1414
|
type: "session" | "main" | "ingested";
|
|
1372
|
-
id: string;
|
|
1373
1415
|
did: string;
|
|
1416
|
+
id: string;
|
|
1374
1417
|
priority: number;
|
|
1375
1418
|
jwk?: {
|
|
1376
1419
|
kty: string;
|
|
@@ -1444,8 +1487,8 @@ declare const CapabilityEntrySchema: z.ZodObject<{
|
|
|
1444
1487
|
}, "strip", z.ZodTypeAny, {
|
|
1445
1488
|
keys: {
|
|
1446
1489
|
type: "session" | "main" | "ingested";
|
|
1447
|
-
id: string;
|
|
1448
1490
|
did: string;
|
|
1491
|
+
id: string;
|
|
1449
1492
|
priority: number;
|
|
1450
1493
|
jwk?: {
|
|
1451
1494
|
kty: string;
|
|
@@ -1481,8 +1524,8 @@ declare const CapabilityEntrySchema: z.ZodObject<{
|
|
|
1481
1524
|
}, {
|
|
1482
1525
|
keys: {
|
|
1483
1526
|
type: "session" | "main" | "ingested";
|
|
1484
|
-
id: string;
|
|
1485
1527
|
did: string;
|
|
1528
|
+
id: string;
|
|
1486
1529
|
priority: number;
|
|
1487
1530
|
jwk?: {
|
|
1488
1531
|
kty: string;
|
|
@@ -4390,4 +4433,4 @@ interface NodeInfo {
|
|
|
4390
4433
|
}
|
|
4391
4434
|
declare function checkNodeInfo(host: string, sdkProtocol: number, fetchFn?: typeof globalThis.fetch): Promise<NodeInfo>;
|
|
4392
4435
|
|
|
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
|
|
4436
|
+
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 };
|