@tinycloud/node-sdk 3.0.0-beta.8 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.d.cts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, CallbackStrategy, CanonicalAddress, CanonicalParsedNetworkId, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, CaveatedDelegationUnsupportedError, ClientSession, ColumnInfo, ComposeManifestOptions, ComposedManifestRequest, CreateDelegationParams, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DataVaultConfig, DataVaultService, DatabaseHandle, DelegateReceivedShareParams, DelegatedShareAccess, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DidCacheKeyOptions, DidEqualsOptions, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, EncodedShareData, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISecretsService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IdentityParseError, IngestOptions, InvokeFunction, JWK, KVBatchReadResponse, KVCreateSignedReadUrlOptions, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, ParsedSecretCatalogKey, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PkhDidParts, PrefixedKVService, ProtocolMismatchError, QueryOptions, QueryResponse, ReceiveOptions, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ResolvedCapabilities, ResolvedDelegate, ResolvedSecretPath, ResourceCapability, SECRET_NAME_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, SecretCatalogEntry, SecretPayload, SecretScopeOptions, SecretsError, SecretsService, ServiceContext, ServiceContextConfig, ServiceSession, SessionExpiredError, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignInOptions, SignRequest, SignResponse, SilentNotificationHandler, Space, SpaceAbilitiesMap, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, TableInfo, TelemetryConfig, TelemetryEventHandler, TinyCloud, TinyCloudConfig, TinyCloudDebugEnableOptions, TinyCloudDebugEvent, TinyCloudDebugLevel, TinyCloudDebugLogger, TinyCloudDebugTimer, TinyCloudSession, UnsupportedFeatureError, VAULT_PERMISSION_SERVICE, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultNetworkReadResult, VaultPublicSpaceKVActions, VaultPutOptions, VersionCheckError, ViewInfo, WasmVaultFunctions, addressStorageKey, buildSpaceUri, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, canonicalizeSecretScope, checkNodeInfo, clearTinyCloudDebugLogs, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, createVaultCrypto, defaultSpaceCreationHandler, didCacheKey, didEquals, disableTinyCloudDebug, enableTinyCloudDebug, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, isCapabilitySubset, isEvmAddress, loadManifest, makePkhSpaceId, makePublicSpaceId, parseCanonicalNetworkId, parseExpiry, parsePkhDid, parseSecretCatalogKey, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, tinyCloudDebugLogger, validateManifest } from '@tinycloud/sdk-core';
2
- export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, F as FileSessionStorage, M as MemorySessionStorage, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, k as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, P as PortableDelegation, m as RuntimePermissionGrantOptions, S as SecretPermissionHint, n as SecretReadInput, o as SecretReadResult, p as SignStrategy, T as TinyCloudNode, q as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, r as UnifiedOwnerRootReceipt, s as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, W as WasmKeyProvider, t as WasmKeyProviderConfig, u as activateCompactRuntimeDelegation, w as createWasmKeyProvider, x as defaultSignStrategy, y as deserializeDelegation, G as serializeDelegation } from './core-WJQ9KiSD.cjs';
2
+ export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, F as FileSessionStorage, I as InvalidRestoredSessionError, M as MemorySessionStorage, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, k as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, P as PortableDelegation, m as RuntimePermissionGrantOptions, S as SecretPermissionHint, n as SecretReadInput, o as SecretReadResult, p as SignStrategy, T as TinyCloudNode, q as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, r as UnifiedOwnerRootReceipt, s as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, W as WasmKeyProvider, t as WasmKeyProviderConfig, u as activateCompactRuntimeDelegation, w as createWasmKeyProvider, x as defaultSignStrategy, y as deserializeDelegation, G as serializeDelegation } from './core-DufYfxi-.cjs';
3
3
  import 'events';
4
4
  import '@tinycloud/sdk-services';
package/dist/core.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, CallbackStrategy, CanonicalAddress, CanonicalParsedNetworkId, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, CaveatedDelegationUnsupportedError, ClientSession, ColumnInfo, ComposeManifestOptions, ComposedManifestRequest, CreateDelegationParams, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DataVaultConfig, DataVaultService, DatabaseHandle, DelegateReceivedShareParams, DelegatedShareAccess, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DidCacheKeyOptions, DidEqualsOptions, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, EncodedShareData, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISecretsService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IdentityParseError, IngestOptions, InvokeFunction, JWK, KVBatchReadResponse, KVCreateSignedReadUrlOptions, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, ParsedSecretCatalogKey, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PkhDidParts, PrefixedKVService, ProtocolMismatchError, QueryOptions, QueryResponse, ReceiveOptions, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ResolvedCapabilities, ResolvedDelegate, ResolvedSecretPath, ResourceCapability, SECRET_NAME_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, SecretCatalogEntry, SecretPayload, SecretScopeOptions, SecretsError, SecretsService, ServiceContext, ServiceContextConfig, ServiceSession, SessionExpiredError, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignInOptions, SignRequest, SignResponse, SilentNotificationHandler, Space, SpaceAbilitiesMap, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, TableInfo, TelemetryConfig, TelemetryEventHandler, TinyCloud, TinyCloudConfig, TinyCloudDebugEnableOptions, TinyCloudDebugEvent, TinyCloudDebugLevel, TinyCloudDebugLogger, TinyCloudDebugTimer, TinyCloudSession, UnsupportedFeatureError, VAULT_PERMISSION_SERVICE, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultNetworkReadResult, VaultPublicSpaceKVActions, VaultPutOptions, VersionCheckError, ViewInfo, WasmVaultFunctions, addressStorageKey, buildSpaceUri, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, canonicalizeSecretScope, checkNodeInfo, clearTinyCloudDebugLogs, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, createVaultCrypto, defaultSpaceCreationHandler, didCacheKey, didEquals, disableTinyCloudDebug, enableTinyCloudDebug, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, isCapabilitySubset, isEvmAddress, loadManifest, makePkhSpaceId, makePublicSpaceId, parseCanonicalNetworkId, parseExpiry, parsePkhDid, parseSecretCatalogKey, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, tinyCloudDebugLogger, validateManifest } from '@tinycloud/sdk-core';
2
- export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, F as FileSessionStorage, M as MemorySessionStorage, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, k as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, P as PortableDelegation, m as RuntimePermissionGrantOptions, S as SecretPermissionHint, n as SecretReadInput, o as SecretReadResult, p as SignStrategy, T as TinyCloudNode, q as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, r as UnifiedOwnerRootReceipt, s as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, W as WasmKeyProvider, t as WasmKeyProviderConfig, u as activateCompactRuntimeDelegation, w as createWasmKeyProvider, x as defaultSignStrategy, y as deserializeDelegation, G as serializeDelegation } from './core-WJQ9KiSD.js';
2
+ export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, F as FileSessionStorage, I as InvalidRestoredSessionError, M as MemorySessionStorage, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, k as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, P as PortableDelegation, m as RuntimePermissionGrantOptions, S as SecretPermissionHint, n as SecretReadInput, o as SecretReadResult, p as SignStrategy, T as TinyCloudNode, q as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, r as UnifiedOwnerRootReceipt, s as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, W as WasmKeyProvider, t as WasmKeyProviderConfig, u as activateCompactRuntimeDelegation, w as createWasmKeyProvider, x as defaultSignStrategy, y as deserializeDelegation, G as serializeDelegation } from './core-DufYfxi-.js';
3
3
  import 'events';
4
4
  import '@tinycloud/sdk-services';
package/dist/core.js CHANGED
@@ -1709,6 +1709,7 @@ import {
1709
1709
  canonicalizeAddress as canonicalizeAddress2,
1710
1710
  pkhDid as pkhDid2,
1711
1711
  resolveTinyCloudHosts as resolveTinyCloudHosts2,
1712
+ publishLocationRecord,
1712
1713
  principalDidEquals as principalDidEquals2,
1713
1714
  parseNetworkId as parseNetworkId2,
1714
1715
  resolveSecretPath as resolveSecretPath2,
@@ -2288,6 +2289,22 @@ function cloneRecapCaveats(caveats) {
2288
2289
  throw new Error("Verified persisted session ReCap contains invalid caveats.");
2289
2290
  }
2290
2291
  }
2292
+ function jsonFromVerifier(value) {
2293
+ if (value === void 0) return null;
2294
+ if (Array.isArray(value)) return value.map(jsonFromVerifier);
2295
+ if (value instanceof Map) {
2296
+ const entries = [...value.entries()];
2297
+ if (!entries.every(([key]) => typeof key === "string")) return value;
2298
+ return Object.fromEntries(entries.map(([key, nested]) => [key, jsonFromVerifier(nested)]));
2299
+ }
2300
+ if (value !== null && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype) {
2301
+ return Object.fromEntries(Object.entries(value).map(([key, nested]) => [key, jsonFromVerifier(nested)]));
2302
+ }
2303
+ return value;
2304
+ }
2305
+ function verifierRecapEntries(entries) {
2306
+ return entries.map((entry) => Array.isArray(entry.caveats) ? { ...entry, caveats: entry.caveats.map((caveat) => jsonFromVerifier(caveat)) } : entry);
2307
+ }
2291
2308
  var ServiceGraphLifetime = class {
2292
2309
  constructor(invokeFn, invokeAnyFn, fetchFn) {
2293
2310
  this.invokeFn = invokeFn;
@@ -2360,18 +2377,23 @@ var UnsupportedSessionRestoreError = class extends Error {
2360
2377
  this.name = "UnsupportedSessionRestoreError";
2361
2378
  }
2362
2379
  };
2380
+ var InvalidRestoredSessionError = class extends Error {
2381
+ constructor(message = "Persisted session authority is invalid or expired.") {
2382
+ super(message);
2383
+ this.code = "AUTH_EXPIRED";
2384
+ this.name = "InvalidRestoredSessionError";
2385
+ }
2386
+ };
2363
2387
  function canonicalRestoredVerificationMethod(canonicalVerificationMethod, persistedVerificationMethod) {
2364
2388
  if (typeof persistedVerificationMethod !== "string") return void 0;
2365
2389
  const principal = canonicalVerificationMethod.split("#", 1)[0];
2366
2390
  return persistedVerificationMethod === principal || persistedVerificationMethod === canonicalVerificationMethod ? canonicalVerificationMethod : void 0;
2367
2391
  }
2368
2392
  function persistedExpiry(value) {
2369
- if (typeof value !== "string") {
2370
- throw new Error("Persisted session without a SIWE expiration must include expiresAt.");
2371
- }
2393
+ if (typeof value !== "string") throw new InvalidRestoredSessionError("Persisted session must include expiresAt.");
2372
2394
  const expiry = new Date(value);
2373
2395
  if (!Number.isFinite(expiry.getTime()) || expiry.getTime() <= Date.now()) {
2374
- throw new Error("Persisted session expiry is invalid or expired.");
2396
+ throw new InvalidRestoredSessionError();
2375
2397
  }
2376
2398
  return expiry;
2377
2399
  }
@@ -2850,6 +2872,29 @@ var _TinyCloudNode = class _TinyCloudNode {
2850
2872
  const authHosts = this.auth?.hosts ?? [];
2851
2873
  return authHosts.length > 0 ? authHosts : [this.config.host];
2852
2874
  }
2875
+ /** The registry-resolved Node endpoint and the identity returned by that exact Node. */
2876
+ async activeNodeIdentity() {
2877
+ const host = this.hosts[0];
2878
+ if (host === void 0) throw new Error("TinyCloud node host has not been resolved");
2879
+ const parsed = new URL(host);
2880
+ if (parsed.protocol !== "https:" && !(parsed.protocol === "http:" && (parsed.hostname === "127.0.0.1" || parsed.hostname === "localhost")) || parsed.origin !== host) {
2881
+ throw new Error("TinyCloud node host is not a canonical origin");
2882
+ }
2883
+ const nodeDid = await this.fetchNodeId();
2884
+ if (!nodeDid.startsWith("did:key:z")) throw new Error("TinyCloud node identity is not a did:key");
2885
+ return Object.freeze({ origin: parsed.origin, nodeDid });
2886
+ }
2887
+ /** Publish the active owner Node as a session-signed registry record. */
2888
+ async publishActiveNodeLocation(registryUrl, fetchFn = globalThis.fetch.bind(globalThis)) {
2889
+ const node = await this.activeNodeIdentity();
2890
+ return publishLocationRecord({
2891
+ registryUrl,
2892
+ subject: this.credentialHolderDid,
2893
+ nodeOrigin: node.origin,
2894
+ signer: { type: "did:key", signBytes: (bytes) => this.signSessionBytes(bytes) },
2895
+ fetch: fetchFn
2896
+ });
2897
+ }
2853
2898
  /**
2854
2899
  * Get the primary identity DID for this user.
2855
2900
  * - If wallet connected and signed in: returns PKH DID (did:pkh:eip155:{chainId}:{address})
@@ -2891,16 +2936,26 @@ var _TinyCloudNode = class _TinyCloudNode {
2891
2936
  */
2892
2937
  getVerifiedSessionCapabilities() {
2893
2938
  const session = this.currentTinyCloudSession();
2894
- if (!session || !session.siwe) return [];
2895
- return parseRecapCapabilities(
2896
- (siwe) => this.parseRecapWithCaveats(siwe),
2897
- session.siwe
2898
- ).map((entry) => entry.service === "tinycloud.encryption" ? {
2899
- service: entry.service,
2900
- path: entry.path,
2901
- actions: [...entry.actions],
2902
- ...entry.caveats === void 0 ? {} : { caveats: entry.caveats }
2903
- } : entry);
2939
+ return session?.siwe ? this.projectSignedRecapCapabilities(session.siwe) : [];
2940
+ }
2941
+ /** Normalize signed capabilities without collapsing nested encryption into raw authority. */
2942
+ projectSignedRecapCapabilities(siwe) {
2943
+ const projected = this.parseRecapWithCaveats(siwe).map((entry) => {
2944
+ const normalized = parseRecapCapabilities(() => [entry], siwe)[0];
2945
+ if (normalized.service !== "tinycloud.encryption") return normalized;
2946
+ if (!this.isEncryptionNetworkOperation("encryption", entry.path, entry.space)) {
2947
+ return { ...normalized, space: entry.space };
2948
+ }
2949
+ return {
2950
+ service: normalized.service,
2951
+ path: normalized.path,
2952
+ actions: normalized.actions,
2953
+ ...normalized.caveats === void 0 ? {} : { caveats: normalized.caveats }
2954
+ };
2955
+ });
2956
+ return projected.sort(
2957
+ (left, right) => (left.space ?? "").localeCompare(right.space ?? "") || left.service.localeCompare(right.service) || left.path.localeCompare(right.path)
2958
+ );
2904
2959
  }
2905
2960
  /**
2906
2961
  * Get the Ethereum address for this user.
@@ -3355,9 +3410,9 @@ var _TinyCloudNode = class _TinyCloudNode {
3355
3410
  * We must keep the full owner-scoped URI so a synthetic primary grant can
3356
3411
  * never cover an operation on a different owner's space.
3357
3412
  *
3358
- * Mirrors {@link operationsFromDelegation}'s op shape: encryption network
3359
- * entries (`urn:tinycloud:encryption:` paths) become `resource` ops; every
3360
- * other entry becomes a `spaceId` op carrying the raw recap `space` URI.
3413
+ * Only top-level encryption network entries (`space: "encryption"` or
3414
+ * absent) become `resource` ops. A network-shaped path nested under a
3415
+ * data space remains a `spaceId` op, not raw network authority.
3361
3416
  * One op per action.
3362
3417
  *
3363
3418
  * Returns `[]` for session-only / restored-without-siwe modes and for any
@@ -3378,7 +3433,7 @@ var _TinyCloudNode = class _TinyCloudNode {
3378
3433
  operations = entries.flatMap((entry) => {
3379
3434
  const service = this.invocationServiceName(entry.service);
3380
3435
  return entry.actions.map((action) => ({
3381
- ...this.isEncryptionNetworkOperation(service, entry.path) ? { resource: entry.path } : { spaceId: entry.space },
3436
+ ...this.isEncryptionNetworkOperation(service, entry.path, entry.space) ? { resource: entry.path } : { spaceId: entry.space },
3382
3437
  service,
3383
3438
  path: entry.path,
3384
3439
  action,
@@ -3540,7 +3595,7 @@ var _TinyCloudNode = class _TinyCloudNode {
3540
3595
  return;
3541
3596
  } catch (error) {
3542
3597
  const message = error instanceof Error ? error.message : String(error);
3543
- if (/Unauthorized Action|\b401\b/.test(message)) {
3598
+ if (/Unauthorized Action|\b(?:401|403)\b/.test(message)) {
3544
3599
  console.warn(
3545
3600
  "TinyCloud account registry sync stopped: authorization verdict is not retryable",
3546
3601
  error
@@ -3790,9 +3845,14 @@ var _TinyCloudNode = class _TinyCloudNode {
3790
3845
  */
3791
3846
  async restoreSession(sessionData) {
3792
3847
  await this.wasmBindings.ensureInitialized?.();
3793
- const restoredJwk = clonePersistedSessionJwk(sessionData.jwk);
3848
+ let restoredJwk;
3849
+ try {
3850
+ restoredJwk = clonePersistedSessionJwk(sessionData.jwk);
3851
+ } catch {
3852
+ throw new InvalidRestoredSessionError("Persisted session has an invalid private Ed25519 session key.");
3853
+ }
3794
3854
  if (sessionData.chainId !== void 0 && (!Number.isSafeInteger(sessionData.chainId) || sessionData.chainId <= 0)) {
3795
- throw new Error("Persisted session chain ID must be a positive safe integer.");
3855
+ throw new InvalidRestoredSessionError("Persisted session chain ID must be a positive safe integer.");
3796
3856
  }
3797
3857
  const stagedManager = this.wasmBindings.createSessionManager();
3798
3858
  const stagedReplace = stagedManager.replaceSessionKey;
@@ -3804,32 +3864,31 @@ var _TinyCloudNode = class _TinyCloudNode {
3804
3864
  let stagedKeyId;
3805
3865
  let stagedJwk;
3806
3866
  let canonicalVerificationMethod;
3867
+ const keyIds = liveKeys.call(this.sessionManager);
3868
+ if (!Array.isArray(keyIds) || !keyIds.every((keyId) => typeof keyId === "string")) {
3869
+ throw new UnsupportedSessionRestoreError("it cannot reliably enumerate every live session signer");
3870
+ }
3871
+ for (const keyId of keyIds) {
3872
+ if (keyId === this.sessionKeyId) continue;
3873
+ const jwk = this.sessionManager.jwk(keyId);
3874
+ if (!jwk) throw new Error("missing live session key");
3875
+ stagedReplace.call(stagedManager, clonePersistedSessionJwk(JSON.parse(jwk)), keyId);
3876
+ }
3807
3877
  try {
3808
- const keyIds = liveKeys.call(this.sessionManager);
3809
- if (!Array.isArray(keyIds) || !keyIds.every((keyId) => typeof keyId === "string")) {
3810
- throw new UnsupportedSessionRestoreError("it cannot reliably enumerate every live session signer");
3811
- }
3812
- for (const keyId of keyIds) {
3813
- if (keyId === this.sessionKeyId) continue;
3814
- const jwk = this.sessionManager.jwk(keyId);
3815
- if (!jwk) throw new Error("missing live session key");
3816
- stagedReplace.call(stagedManager, clonePersistedSessionJwk(JSON.parse(jwk)), keyId);
3817
- }
3818
3878
  stagedKeyId = stagedReplace.call(stagedManager, restoredJwk, this.sessionKeyId);
3819
- const stagedJwkJson = stagedManager.jwk(stagedKeyId);
3820
- if (!stagedJwkJson) throw new Error("missing restored session key");
3821
- stagedJwk = clonePersistedSessionJwk(JSON.parse(stagedJwkJson));
3822
- canonicalVerificationMethod = stagedManager.getDID(stagedKeyId);
3823
- } catch (error) {
3824
- if (error instanceof UnsupportedSessionRestoreError) throw error;
3825
- throw new Error("Persisted session has an invalid private Ed25519 session key.");
3879
+ } catch {
3880
+ throw new InvalidRestoredSessionError("Persisted session has an invalid private Ed25519 session key.");
3826
3881
  }
3882
+ const stagedJwkJson = stagedManager.jwk(stagedKeyId);
3883
+ if (!stagedJwkJson) throw new Error("missing restored session key");
3884
+ stagedJwk = clonePersistedSessionJwk(JSON.parse(stagedJwkJson));
3885
+ canonicalVerificationMethod = stagedManager.getDID(stagedKeyId);
3827
3886
  const restoredVerificationMethod = canonicalRestoredVerificationMethod(
3828
3887
  canonicalVerificationMethod,
3829
3888
  sessionData.verificationMethod
3830
3889
  );
3831
3890
  if (!restoredVerificationMethod) {
3832
- throw new Error(
3891
+ throw new InvalidRestoredSessionError(
3833
3892
  "Persisted session verification method does not match its private Ed25519 session key."
3834
3893
  );
3835
3894
  }
@@ -3841,26 +3900,37 @@ var _TinyCloudNode = class _TinyCloudNode {
3841
3900
  ];
3842
3901
  const hasPersistedProof = proofValues.every((value) => value !== void 0);
3843
3902
  if (!hasPersistedProof && (proofValues.some((value) => value !== void 0) || sessionData.expiresAt !== void 0)) {
3844
- throw new Error("Persisted session authority metadata is incomplete.");
3903
+ throw new InvalidRestoredSessionError("Persisted session authority metadata is incomplete.");
3904
+ }
3905
+ let restoredAddress;
3906
+ try {
3907
+ restoredAddress = hasPersistedProof ? canonicalizeAddress2(sessionData.address) : void 0;
3908
+ } catch {
3909
+ throw new InvalidRestoredSessionError("Persisted session has an invalid wallet address.");
3845
3910
  }
3846
- const restoredAddress = hasPersistedProof ? canonicalizeAddress2(sessionData.address) : void 0;
3847
3911
  let stagedSessionExpiry = /* @__PURE__ */ new Date(0);
3848
3912
  let stagedRecap = [];
3849
3913
  if (hasPersistedProof) {
3850
3914
  if (typeof this.wasmBindings.validatePersistedSession !== "function") {
3851
3915
  throw new UnsupportedSessionRestoreError("it cannot verify persisted SIWE authority");
3852
3916
  }
3853
- const verified = this.wasmBindings.validatePersistedSession({
3854
- delegationHeader: sessionData.delegationHeader,
3855
- delegationCid: sessionData.delegationCid,
3856
- spaceId: sessionData.spaceId,
3857
- jwk: stagedJwk,
3858
- address: restoredAddress,
3859
- chainId: sessionData.chainId,
3860
- siwe: sessionData.siwe,
3861
- signature: sessionData.signature
3862
- });
3863
- const exactRecap = verified.verifiedRecap;
3917
+ const verified = (() => {
3918
+ try {
3919
+ return this.wasmBindings.validatePersistedSession({
3920
+ delegationHeader: sessionData.delegationHeader,
3921
+ delegationCid: sessionData.delegationCid,
3922
+ spaceId: sessionData.spaceId,
3923
+ jwk: stagedJwk,
3924
+ address: restoredAddress,
3925
+ chainId: sessionData.chainId,
3926
+ siwe: sessionData.siwe,
3927
+ signature: sessionData.signature
3928
+ });
3929
+ } catch (error) {
3930
+ throw new InvalidRestoredSessionError(error instanceof Error ? error.message : String(error));
3931
+ }
3932
+ })();
3933
+ const exactRecap = Array.isArray(verified.verifiedRecap) ? verifierRecapEntries(verified.verifiedRecap) : verified.verifiedRecap;
3864
3934
  if (!Array.isArray(exactRecap) || !exactRecap.every(
3865
3935
  (entry) => entry !== null && typeof entry === "object" && typeof entry.service === "string" && typeof entry.space === "string" && typeof entry.path === "string" && Array.isArray(entry.actions) && entry.actions.every((action) => typeof action === "string") && Array.isArray(entry.caveats) && entry.caveats.every(
3866
3936
  (caveat) => caveat !== null && typeof caveat === "object" && !Array.isArray(caveat)
@@ -3880,7 +3950,7 @@ var _TinyCloudNode = class _TinyCloudNode {
3880
3950
  const signedExpiry = verified.expiresAt === void 0 ? void 0 : persistedExpiry(verified.expiresAt);
3881
3951
  const persistedPolicyExpiry = sessionData.expiresAt === void 0 ? void 0 : persistedExpiry(sessionData.expiresAt);
3882
3952
  if (signedExpiry && persistedPolicyExpiry && !sameInstant(signedExpiry, persistedPolicyExpiry)) {
3883
- throw new Error("Persisted session expiry does not match its signed SIWE authority.");
3953
+ throw new InvalidRestoredSessionError("Persisted session expiry does not match its signed SIWE authority.");
3884
3954
  }
3885
3955
  stagedSessionExpiry = signedExpiry ?? persistedPolicyExpiry ?? persistedExpiry(void 0);
3886
3956
  }
@@ -3977,7 +4047,7 @@ var _TinyCloudNode = class _TinyCloudNode {
3977
4047
  operations = recap.flatMap((entry) => {
3978
4048
  const service = this.invocationServiceName(entry.service);
3979
4049
  return entry.actions.map((action) => ({
3980
- ...this.isEncryptionNetworkOperation(service, entry.path) ? { resource: entry.path } : { spaceId: entry.space },
4050
+ ...this.isEncryptionNetworkOperation(service, entry.path, entry.space) ? { resource: entry.path } : { spaceId: entry.space },
3981
4051
  service,
3982
4052
  path: entry.path,
3983
4053
  action,
@@ -4073,7 +4143,7 @@ var _TinyCloudNode = class _TinyCloudNode {
4073
4143
  const delegations = input.recap.map((entry) => ({
4074
4144
  cid: session.delegationCid,
4075
4145
  delegateDID: session.verificationMethod,
4076
- spaceId: entry.space,
4146
+ spaceId: this.spaceIdsEqual(entry.space, session.spaceId) ? session.spaceId : entry.space,
4077
4147
  path: entry.path,
4078
4148
  actions: [...entry.actions],
4079
4149
  caveats: cloneRecapCaveats(entry.caveats),
@@ -4763,16 +4833,11 @@ var _TinyCloudNode = class _TinyCloudNode {
4763
4833
  );
4764
4834
  graph.assertActive();
4765
4835
  if (!response.ok) {
4766
- let permissionHint;
4767
- if (response.status === 401 || response.status === 403) {
4768
- try {
4769
- const body = await response.json();
4770
- const record = typeof body === "object" && body !== null ? body : void 0;
4771
- const nested = typeof record?.error === "object" && record.error !== null ? record.error : void 0;
4772
- permissionHint = parsePermissionHint(record?.permissionHint) ?? parsePermissionHint(nested?.permissionHint);
4773
- } catch {
4774
- }
4775
- }
4836
+ const permissionHint = response.status === 401 || response.status === 403 ? parsePermissionHint({
4837
+ service: "tinycloud.encryption",
4838
+ path: networkId,
4839
+ actions: ["tinycloud.encryption/decrypt"]
4840
+ }) : void 0;
4776
4841
  throw new DecryptTransportResponseError(response.status, permissionHint);
4777
4842
  }
4778
4843
  return await response.json();
@@ -5206,16 +5271,16 @@ var _TinyCloudNode = class _TinyCloudNode {
5206
5271
  fetch: globalThis.fetch.bind(globalThis)
5207
5272
  });
5208
5273
  }
5209
- /** @deprecated Policy/v2 delivery transport is retired. Use authorizeShareDeliveryV3. */
5210
- async authorizeShareDelivery(input) {
5211
- void input;
5212
- throw new Error("Policy/v2 share delivery is retired; use authorizeShareDeliveryV3");
5213
- }
5214
5274
  /** Authorize one short-lived v3 delivery against the signed v3 envelope and registered roots. */
5215
5275
  async authorizeShareDeliveryV3(input) {
5216
5276
  const session = this.currentTinyCloudSession();
5217
5277
  const serviceSession = this._serviceContext?.session;
5218
5278
  if (!session || !serviceSession) throw new Error("Share delivery requires an authenticated session");
5279
+ const idempotencyBytes = new TextEncoder().encode(input.idempotencyKey);
5280
+ if (idempotencyBytes.byteLength === 0 || idempotencyBytes.byteLength > 512) {
5281
+ throw new Error("Share delivery idempotency key is invalid");
5282
+ }
5283
+ const jtiDigest = new Uint8Array(await crypto.subtle.digest("SHA-256", idempotencyBytes));
5219
5284
  const body = {
5220
5285
  envelope: input.envelope,
5221
5286
  sealedEnvelope: input.sealedEnvelope,
@@ -5224,7 +5289,7 @@ var _TinyCloudNode = class _TinyCloudNode {
5224
5289
  recipientEmail: input.recipientEmail,
5225
5290
  shareUrl: input.shareUrl,
5226
5291
  documentName: input.documentName,
5227
- jti: base64UrlEncode(crypto.getRandomValues(new Uint8Array(16))),
5292
+ jti: base64UrlEncode(jtiDigest.slice(0, 16)),
5228
5293
  expiresAt: new Date(input.expiresAt).toISOString().replace(/\.\d{3}Z$/, "Z")
5229
5294
  };
5230
5295
  const requestBodyDigest = base64UrlEncode(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(canonicalizeEncryptionJson(body)))));
@@ -5239,9 +5304,8 @@ var _TinyCloudNode = class _TinyCloudNode {
5239
5304
  const verified = validateShareDeliveryAuthorizationV3Bytes(new Uint8Array(await response.arrayBuffer()), {
5240
5305
  request,
5241
5306
  senderKeyDid: this.credentialHolderDid,
5242
- credentialsAudience: input.credentialsAudience
5307
+ deliveryAudience: input.deliveryAudience
5243
5308
  });
5244
- void input.nodeProof;
5245
5309
  const requestDigest = new Uint8Array(await crypto.subtle.digest(
5246
5310
  "SHA-256",
5247
5311
  new TextEncoder().encode(`${CREDENTIAL_INVITATION_REQUEST_DOMAIN}${canonicalizeEncryptionJson(verified.request)}`)
@@ -5708,7 +5772,7 @@ var _TinyCloudNode = class _TinyCloudNode {
5708
5772
  continue;
5709
5773
  }
5710
5774
  let space;
5711
- if (service !== "tinycloud.encryption") {
5775
+ if (service !== "tinycloud.encryption" || operation.resource === void 0) {
5712
5776
  if (typeof operation.spaceId !== "string") continue;
5713
5777
  try {
5714
5778
  space = this.resolvePermissionSpace(operation.spaceId, session);
@@ -6253,11 +6317,8 @@ var _TinyCloudNode = class _TinyCloudNode {
6253
6317
  );
6254
6318
  return { delegation: delegation2, prompted: true };
6255
6319
  }
6256
- const granted = parseRecapCapabilities(
6257
- (siwe) => this.parseRecapWithCaveats(siwe),
6258
- session.siwe
6259
- );
6260
- const { subset, missing } = isCapabilitySubset(expandedEntries, granted);
6320
+ const granted = this.projectSignedRecapCapabilities(session.siwe);
6321
+ const { subset, missing } = this.signedCapabilitySubset(expandedEntries, granted);
6261
6322
  if (!subset) {
6262
6323
  const runtimeOperations = this.permissionEntriesToOperations(expandedEntries, session);
6263
6324
  const runtimeGrant = this.findGrantForOperations(
@@ -6577,7 +6638,7 @@ var _TinyCloudNode = class _TinyCloudNode {
6577
6638
  return abilities;
6578
6639
  }
6579
6640
  isEncryptionPermissionEntry(entry) {
6580
- return entry.service === ENCRYPTION_PERMISSION_SERVICE2 && entry.path.startsWith("urn:tinycloud:encryption:");
6641
+ return entry.service === ENCRYPTION_PERMISSION_SERVICE2 && this.isEncryptionNetworkOperation("encryption", entry.path, entry.space);
6581
6642
  }
6582
6643
  permissionsToRawAbilities(entries) {
6583
6644
  const rawAbilities = {};
@@ -6601,7 +6662,7 @@ var _TinyCloudNode = class _TinyCloudNode {
6601
6662
  return entries.flatMap((entry) => {
6602
6663
  const service = this.shortServiceName(entry.service);
6603
6664
  return entry.actions.map((action) => ({
6604
- ...this.isEncryptionNetworkOperation(service, entry.path) ? { resource: entry.path } : { spaceId },
6665
+ ...this.isEncryptionNetworkOperation(service, entry.path, entry.space) ? { resource: entry.path } : { spaceId },
6605
6666
  service,
6606
6667
  path: entry.path,
6607
6668
  action,
@@ -6609,13 +6670,21 @@ var _TinyCloudNode = class _TinyCloudNode {
6609
6670
  }));
6610
6671
  });
6611
6672
  }
6673
+ /** Raw network authority cannot be covered by a nested encryption space. */
6674
+ signedCapabilitySubset(requested, granted) {
6675
+ const rawGranted = granted.filter((entry) => this.isEncryptionPermissionEntry(entry)).map((entry) => ({ ...entry, space: "encryption" }));
6676
+ const spaceGranted = granted.filter((entry) => !this.isEncryptionPermissionEntry(entry));
6677
+ const missing = requested.filter((entry) => {
6678
+ const raw = this.isEncryptionPermissionEntry(entry);
6679
+ const comparable = raw ? { ...entry, space: "encryption" } : entry;
6680
+ return !isCapabilitySubset([comparable], raw ? rawGranted : spaceGranted).subset;
6681
+ });
6682
+ return { subset: missing.length === 0, missing };
6683
+ }
6612
6684
  sessionCoversPermissionEntries(session, entries) {
6613
6685
  try {
6614
- const granted = parseRecapCapabilities(
6615
- (siwe) => this.parseRecapWithCaveats(siwe),
6616
- session.siwe
6617
- );
6618
- return isCapabilitySubset(entries, granted).subset;
6686
+ const granted = this.projectSignedRecapCapabilities(session.siwe);
6687
+ return this.signedCapabilitySubset(entries, granted).subset;
6619
6688
  } catch {
6620
6689
  return false;
6621
6690
  }
@@ -6625,7 +6694,7 @@ var _TinyCloudNode = class _TinyCloudNode {
6625
6694
  const spaceId = this.resolvePermissionSpace(entry.space, session);
6626
6695
  const service = this.shortServiceName(entry.service);
6627
6696
  return entry.actions.map((action) => ({
6628
- ...this.isEncryptionNetworkOperation(service, entry.path) ? { resource: entry.path } : { spaceId },
6697
+ ...this.isEncryptionNetworkOperation(service, entry.path, entry.space) ? { resource: entry.path } : { spaceId },
6629
6698
  service,
6630
6699
  path: entry.path,
6631
6700
  action,
@@ -6714,7 +6783,7 @@ var _TinyCloudNode = class _TinyCloudNode {
6714
6783
  return resources.flatMap((resource) => {
6715
6784
  const service = this.invocationServiceName(resource.service);
6716
6785
  return resource.actions.map((action) => ({
6717
- ...this.isEncryptionNetworkOperation(service, resource.path) ? { resource: resource.path } : { spaceId: resource.space },
6786
+ ...this.isEncryptionNetworkOperation(service, resource.path, resource.space) ? { resource: resource.path } : { spaceId: resource.space },
6718
6787
  service,
6719
6788
  path: resource.path,
6720
6789
  action,
@@ -6775,7 +6844,7 @@ var _TinyCloudNode = class _TinyCloudNode {
6775
6844
  };
6776
6845
  for (const resource of resources) {
6777
6846
  const service = this.invocationServiceName(resource.service);
6778
- if (this.isEncryptionNetworkOperation(service, resource.path)) {
6847
+ if (this.isEncryptionNetworkOperation(service, resource.path, resource.space)) {
6779
6848
  rawAbilities[_a = resource.path] ?? (rawAbilities[_a] = []);
6780
6849
  addActions(rawAbilities[resource.path], resource.actions);
6781
6850
  continue;
@@ -6844,21 +6913,15 @@ var _TinyCloudNode = class _TinyCloudNode {
6844
6913
  }
6845
6914
  return granted.spaceId !== void 0 && requested.spaceId !== void 0 && this.spaceIdsEqual(granted.spaceId, requested.spaceId) && this.pathContains(granted.path, requested.path);
6846
6915
  }
6847
- // Space IDs are `tinycloud:pkh:eip155:<chain>:<0xADDR>:<name>`. The embedded
6848
- // EIP-155 address is case-insensitive, but the CLI canonicalizes it to
6849
- // lowercase when building a space URI while stored runtime delegations keep
6850
- // the EIP-55 checksummed form — so a byte-for-byte compare spuriously rejects
6851
- // an otherwise-valid grant. Lowercase ONLY the `eip155:<chain>:0x<addr>`
6852
- // segment and leave everything else (crucially the case-sensitive space NAME)
6853
- // byte-exact. Mirrors the CLI's `normalizeSpaceForCompare` (OPENKEY_SCOPE_MISMATCH fix).
6916
+ // Space IDs are `tinycloud:pkh:eip155:<chain>:<0xADDR>:<name>`. Compare
6917
+ // only the embedded EIP-155 address without case sensitivity; chain, name,
6918
+ // and all non-PKH space identifiers remain byte-exact.
6854
6919
  spaceIdsEqual(a, b) {
6855
6920
  return this.normalizeSpaceAddress(a) === this.normalizeSpaceAddress(b);
6856
6921
  }
6857
6922
  normalizeSpaceAddress(space) {
6858
- return space.replace(
6859
- /(eip155:\d+:)(0x[0-9a-fA-F]{40})/,
6860
- (_match, prefix, addr) => prefix + addr.toLowerCase()
6861
- );
6923
+ const match = /^(tinycloud:pkh:eip155:\d+:)(0x[0-9a-fA-F]{40})(:.+)$/.exec(space);
6924
+ return match === null ? space : `${match[1]}${match[2].toLowerCase()}${match[3]}`;
6862
6925
  }
6863
6926
  actionContains(grantedAction, requestedAction) {
6864
6927
  if (grantedAction === requestedAction) {
@@ -6875,10 +6938,11 @@ var _TinyCloudNode = class _TinyCloudNode {
6875
6938
  }
6876
6939
  /** Prefer the v2 caveat-preserving parser while retaining old custom WASM. */
6877
6940
  parseRecapWithCaveats(siwe) {
6878
- return this.wasmBindings.parseVerifiedRecapFromSiwe?.(siwe) ?? this.wasmBindings.parseRecapFromSiwe(siwe);
6941
+ const verified = this.wasmBindings.parseVerifiedRecapFromSiwe?.(siwe);
6942
+ return verified == null ? this.wasmBindings.parseRecapFromSiwe(siwe) : verifierRecapEntries(verified);
6879
6943
  }
6880
- isEncryptionNetworkOperation(service, path) {
6881
- return service === "encryption" && path.startsWith("urn:tinycloud:encryption:");
6944
+ isEncryptionNetworkOperation(service, path, space) {
6945
+ return service === "encryption" && (space === void 0 || space === "encryption") && path.startsWith("urn:tinycloud:encryption:");
6882
6946
  }
6883
6947
  operationFromInvokeAnyEntry(entry) {
6884
6948
  const service = this.invocationServiceName(entry.service);
@@ -6891,7 +6955,7 @@ var _TinyCloudNode = class _TinyCloudNode {
6891
6955
  ...entry.caveats === void 0 ? {} : { caveats: cloneRecapCaveats(entry.caveats) }
6892
6956
  };
6893
6957
  }
6894
- if (this.isEncryptionNetworkOperation(service, entry.path)) {
6958
+ if (entry.spaceId === void 0 && this.isEncryptionNetworkOperation(service, entry.path)) {
6895
6959
  return {
6896
6960
  resource: entry.path,
6897
6961
  service,
@@ -7176,8 +7240,7 @@ var _TinyCloudNode = class _TinyCloudNode {
7176
7240
  const jwk = mySession.jwk;
7177
7241
  const { abilities, rawAbilities } = this.buildActivationAbilities(delegation);
7178
7242
  const now = /* @__PURE__ */ new Date();
7179
- const maxExpiry = new Date(now.getTime() + 60 * 60 * 1e3);
7180
- const expirationTime = delegation.expiry < maxExpiry ? delegation.expiry : maxExpiry;
7243
+ const expirationTime = delegation.expiry;
7181
7244
  const prepared = this.wasmBindings.prepareSession({
7182
7245
  abilities,
7183
7246
  address: this.wasmBindings.ensureEip55(mySession.address),
@@ -7281,8 +7344,7 @@ var _TinyCloudNode = class _TinyCloudNode {
7281
7344
  );
7282
7345
  }
7283
7346
  const now = /* @__PURE__ */ new Date();
7284
- const expiryMs = params.expiryMs ?? 60 * 60 * 1e3;
7285
- const requestedExpiry = new Date(now.getTime() + expiryMs);
7347
+ const requestedExpiry = params.expiryMs === void 0 ? parentDelegation.expiry : new Date(now.getTime() + params.expiryMs);
7286
7348
  const actualExpiry = requestedExpiry > parentDelegation.expiry ? parentDelegation.expiry : requestedExpiry;
7287
7349
  const abilities = {};
7288
7350
  const rawAbilities = {};
@@ -7802,6 +7864,7 @@ export {
7802
7864
  DuckDbService3 as DuckDbService,
7803
7865
  FileSessionStorage,
7804
7866
  IdentityParseError,
7867
+ InvalidRestoredSessionError,
7805
7868
  KVService3 as KVService,
7806
7869
  ManifestValidationError,
7807
7870
  MemorySessionStorage,