@tinycloud/node-sdk 3.7.0-beta.1 → 3.7.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.d.cts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { ReplicationOptions, Manifest, PermissionEntry } from '@tinycloud/sdk-core';
2
2
  export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, AuthorityRefusal, 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, KVListPage, KVReadThrough, KVReplicaHandle, KVReplicaSpec, KVReplicaStorage, KVReplicationController, KVReplicationDeps, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, LocalGetResult, LocalListResult, LocalReadMeta, LocalReplicaStatus, LocalSyncResult, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, ParsedSecretCatalogKey, PendingWriteRecord, PendingWriteState, PendingWriteStore, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PinnedKey, PkhDidParts, PrefixedKVService, ProtocolMismatchError, PurgeTarget, QueryOptions, QueryResponse, ReceiveOptions, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ReplicaAuthorityState, ReplicaCoverage, ReplicaDevice, ReplicaGatedHandle, ReplicaGrantInfo, ReplicaInspectedStatus, ReplicaState, ReplicaStatusEntry, ReplicationAuthority, ReplicationControl, ReplicationEvent, ReplicationIdentity, ReplicationOptions, ReplicationPurgeReport, ReplicationReason, ReplicationScheduler, ResolvedCapabilities, ResolvedDelegate, ResolvedReplicationOptions, 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';
3
3
  import { _ as __gated_network } from './gated-network-BEF2XSTC.cjs';
4
- import { _ as __authority } from './authority-BVmX2vCi.cjs';
4
+ import { _ as __authority } from './authority-Ck5hZdBn.cjs';
5
5
  import { _ as __runtime } from './runtime-D1o9Eybt.cjs';
6
6
  import { ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
7
7
  export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider } from './WasmKeyProvider-5Ee7fcAw.cjs';
8
- export { B as BootstrapWarning, C as CreateOwnerDelegationParams, D as DelegateToOptions, a as DelegateToResult, b as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, N as NodeEventEmitterStrategy, c as NodeUserAuthorization, d as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, R as RuntimePermissionGrantOptions, S as SecretPermissionHint, e as SecretReadInput, f as SecretReadResult, g as SignStrategy, T as TinyCloudNode, h as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, i as UnifiedOwnerRootReceipt, j as UnsupportedSessionRestoreError, k as defaultSignStrategy } from './TinyCloudNode-DrLNh4bs.cjs';
8
+ export { B as BootstrapWarning, C as CreateOwnerDelegationParams, D as DelegateToOptions, a as DelegateToResult, b as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, N as NodeEventEmitterStrategy, c as NodeUserAuthorization, d as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, R as RuntimePermissionGrantOptions, S as SecretPermissionHint, e as SecretReadInput, f as SecretReadResult, g as SignStrategy, T as TinyCloudNode, h as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, i as UnifiedOwnerRootReceipt, j as UnsupportedSessionRestoreError, k as defaultSignStrategy } from './TinyCloudNode-DD7qjyLU.cjs';
9
9
  export { C as CompactRuntimeDelegationInput, P as PortableDelegation, V as ValidatedRuntimeDelegation, a as activateCompactRuntimeDelegation, d as deserializeDelegation, s as serializeDelegation } from './delegation-0LKZkmP2.cjs';
10
10
  import '@tinycloud/sdk-services';
11
11
  import 'events';
package/dist/core.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { ReplicationOptions, Manifest, PermissionEntry } from '@tinycloud/sdk-core';
2
2
  export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, AuthorityRefusal, 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, KVListPage, KVReadThrough, KVReplicaHandle, KVReplicaSpec, KVReplicaStorage, KVReplicationController, KVReplicationDeps, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, LocalGetResult, LocalListResult, LocalReadMeta, LocalReplicaStatus, LocalSyncResult, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, ParsedSecretCatalogKey, PendingWriteRecord, PendingWriteState, PendingWriteStore, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PinnedKey, PkhDidParts, PrefixedKVService, ProtocolMismatchError, PurgeTarget, QueryOptions, QueryResponse, ReceiveOptions, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ReplicaAuthorityState, ReplicaCoverage, ReplicaDevice, ReplicaGatedHandle, ReplicaGrantInfo, ReplicaInspectedStatus, ReplicaState, ReplicaStatusEntry, ReplicationAuthority, ReplicationControl, ReplicationEvent, ReplicationIdentity, ReplicationOptions, ReplicationPurgeReport, ReplicationReason, ReplicationScheduler, ResolvedCapabilities, ResolvedDelegate, ResolvedReplicationOptions, 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';
3
3
  import { _ as __gated_network } from './gated-network-BEF2XSTC.js';
4
- import { _ as __authority } from './authority-BHVqCPyl.js';
4
+ import { _ as __authority } from './authority-DXR6887E.js';
5
5
  import { _ as __runtime } from './runtime-v62FzQHz.js';
6
6
  import { ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
7
7
  export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider } from './WasmKeyProvider-5Ee7fcAw.js';
8
- export { B as BootstrapWarning, C as CreateOwnerDelegationParams, D as DelegateToOptions, a as DelegateToResult, b as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, N as NodeEventEmitterStrategy, c as NodeUserAuthorization, d as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, R as RuntimePermissionGrantOptions, S as SecretPermissionHint, e as SecretReadInput, f as SecretReadResult, g as SignStrategy, T as TinyCloudNode, h as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, i as UnifiedOwnerRootReceipt, j as UnsupportedSessionRestoreError, k as defaultSignStrategy } from './TinyCloudNode-BHiKCQ4W.js';
8
+ export { B as BootstrapWarning, C as CreateOwnerDelegationParams, D as DelegateToOptions, a as DelegateToResult, b as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, N as NodeEventEmitterStrategy, c as NodeUserAuthorization, d as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, R as RuntimePermissionGrantOptions, S as SecretPermissionHint, e as SecretReadInput, f as SecretReadResult, g as SignStrategy, T as TinyCloudNode, h as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, i as UnifiedOwnerRootReceipt, j as UnsupportedSessionRestoreError, k as defaultSignStrategy } from './TinyCloudNode-Cw00iiSP.js';
9
9
  export { C as CompactRuntimeDelegationInput, P as PortableDelegation, V as ValidatedRuntimeDelegation, a as activateCompactRuntimeDelegation, d as deserializeDelegation, s as serializeDelegation } from './delegation-0LKZkmP2.js';
10
10
  import '@tinycloud/sdk-services';
11
11
  import 'events';
package/dist/core.js CHANGED
@@ -3893,7 +3893,10 @@ var _TinyCloudNode = class _TinyCloudNode {
3893
3893
  * and remembers whose storage is full so sign-in and listing skip their
3894
3894
  * best-effort writes. Lives as long as this instance, across sign-ins.
3895
3895
  */
3896
- this.storageFull = new StorageFullMonitor((spaceId) => spaceOwnerKey(spaceId) ?? spaceId);
3896
+ this.storageFull = new StorageFullMonitor(
3897
+ (spaceId) => spaceOwnerKey(spaceId) ?? spaceId,
3898
+ () => this.currentStorageOwner()
3899
+ );
3897
3900
  this.invokeWithRuntimePermissions = (session, service, path, action, facts) => {
3898
3901
  const operation = {
3899
3902
  spaceId: session.spaceId,
@@ -3925,17 +3928,7 @@ var _TinyCloudNode = class _TinyCloudNode {
3925
3928
  throw new Error("WASM binding does not support invokeAny");
3926
3929
  }
3927
3930
  const routedEntries = entries;
3928
- const operations = routedEntries.flatMap((entry) => {
3929
- const operation = this.operationFromInvokeAnyEntry(entry);
3930
- return operation ? [operation] : [];
3931
- });
3932
- const authorityCid = routedEntries.length === 1 ? routedEntries[0]?.revokeAuthorityCid : void 0;
3933
- const explicitGrant = authorityCid === void 0 ? void 0 : this.runtimePermissionGrants.find((grant2) => grant2.delegation.cid === authorityCid);
3934
- if (authorityCid !== void 0 && !explicitGrant) {
3935
- throw new Error(`Explicit revocation authority ${authorityCid} is not installed.`);
3936
- }
3937
- const grant = explicitGrant ?? this.findGrantForOperations(operations);
3938
- const invocationSession = explicitGrant ? explicitGrant.session : !grant || grant.provenance === "primary" ? session : grant.session;
3931
+ const { session: invocationSession, grant } = this.selectInvokeAnySession(session, entries);
3939
3932
  const caveatPreservingEntries = routedEntries.map(({ revokeAuthorityCid: _cid, ...entry }) => {
3940
3933
  const requested = this.operationFromInvokeAnyEntry(entry);
3941
3934
  const granted = grant && requested && grant.operations.find(
@@ -4059,12 +4052,15 @@ var _TinyCloudNode = class _TinyCloudNode {
4059
4052
  return this._bootstrapStatus;
4060
4053
  }
4061
4054
  /**
4062
- * Subscribe to `storage.full`. It fires once, on the first write any
4063
- * service had rejected because the owner's TinyCloud storage is full
4055
+ * Subscribe to `storage.full`. It fires on the first write any service had
4056
+ * rejected because the owner's TinyCloud storage is full
4064
4057
  * (`STORAGE_QUOTA_EXCEEDED` or `STORAGE_LIMIT_REACHED`), so an app can show
4065
- * one read-only banner. Reads keep working. It fires again only after
4066
- * `storage.status()` has reported space again for every owner whose write
4067
- * was rejected. Returns the unsubscribe function.
4058
+ * one read-only banner. Reads keep working. For the signed-in account's own
4059
+ * storage it fires once per episode: the episode ends only when a write to
4060
+ * that storage succeeds, or on sign-out. A `storage.status()` read does not
4061
+ * end it. A rejection on another owner's delegated space fires once per
4062
+ * owner, until that owner's `storage.status()` reports space again. Returns
4063
+ * the unsubscribe function.
4068
4064
  */
4069
4065
  on(event, handler) {
4070
4066
  if (event !== "storage.full") {
@@ -4072,6 +4068,21 @@ var _TinyCloudNode = class _TinyCloudNode {
4072
4068
  }
4073
4069
  return this.storageFull.on(handler);
4074
4070
  }
4071
+ /**
4072
+ * Storage episode state for the UI mount. @internal
4073
+ *
4074
+ * `current()` returns the own-storage rejection that started the episode, or
4075
+ * undefined. `subscribe` calls its listener when the own episode starts or
4076
+ * ends; read `current()` inside it. `subscribeDelegated` calls its listener
4077
+ * once per delegated owner found full, until that owner is cleared.
4078
+ */
4079
+ get storageEpisode() {
4080
+ return {
4081
+ current: () => this.storageFull.rejection,
4082
+ subscribe: (listener) => this.storageFull.onEpisode(listener),
4083
+ subscribeDelegated: (listener) => this.storageFull.onDelegated(listener)
4084
+ };
4085
+ }
4075
4086
  /** Owner key of the account the current session's own storage belongs to. */
4076
4087
  currentStorageOwner() {
4077
4088
  return spaceOwnerKey(this._serviceContext?.session?.spaceId ?? this.currentTinyCloudSession()?.spaceId);
@@ -4173,6 +4184,27 @@ var _TinyCloudNode = class _TinyCloudNode {
4173
4184
  get siweDomain() {
4174
4185
  return this.config.domain ?? "app.tinycloud.xyz";
4175
4186
  }
4187
+ /**
4188
+ * The session (key, issuer, proof) that signs an invokeAny call for `entries`:
4189
+ * the explicit revocation authority, else the covering non-primary runtime
4190
+ * grant, else the caller's session. Everything that re-signs the resulting
4191
+ * invocation must use this session's key.
4192
+ */
4193
+ selectInvokeAnySession(session, entries) {
4194
+ const routedEntries = entries;
4195
+ const operations = routedEntries.flatMap((entry) => {
4196
+ const operation = this.operationFromInvokeAnyEntry(entry);
4197
+ return operation ? [operation] : [];
4198
+ });
4199
+ const authorityCid = routedEntries.length === 1 ? routedEntries[0]?.revokeAuthorityCid : void 0;
4200
+ const explicitGrant = authorityCid === void 0 ? void 0 : this.runtimePermissionGrants.find((grant2) => grant2.delegation.cid === authorityCid);
4201
+ if (authorityCid !== void 0 && !explicitGrant) {
4202
+ throw new Error(`Explicit revocation authority ${authorityCid} is not installed.`);
4203
+ }
4204
+ const grant = explicitGrant ?? this.findGrantForOperations(operations);
4205
+ const invocationSession = explicitGrant ? explicitGrant.session : !grant || grant.provenance === "primary" ? session : grant.session;
4206
+ return { session: invocationSession, grant };
4207
+ }
4176
4208
  /**
4177
4209
  * SharingService for receive-only access (no session required), bound to the
4178
4210
  * current service graph. This lets session-only users receive sharing links
@@ -6592,7 +6624,13 @@ var _TinyCloudNode = class _TinyCloudNode {
6592
6624
  async bindInvocationAudience(authorization, audience) {
6593
6625
  const session = this.currentTinyCloudSession() ?? this._activeServiceSession;
6594
6626
  if (session === void 0) throw new Error("Not signed in. Call signIn() first.");
6595
- return rewriteInvocationAudience(authorization, audience, session.jwk);
6627
+ const payload = JSON.parse(
6628
+ new TextDecoder().decode(base64UrlDecode(authorization.split(".")[1] ?? ""))
6629
+ );
6630
+ const did = (value) => String(value).split("#", 1)[0];
6631
+ const signer = [session, ...this.runtimePermissionGrants.map((grant) => grant.session)].find((candidate) => did(candidate.verificationMethod) === did(payload.iss));
6632
+ if (!signer) throw new Error("invocation issuer does not match a held session");
6633
+ return rewriteInvocationAudience(authorization, audience, signer.jwk);
6596
6634
  }
6597
6635
  /**
6598
6636
  * Connect a wallet to upgrade from session-only mode to wallet mode.
@@ -6927,23 +6965,25 @@ var _TinyCloudNode = class _TinyCloudNode {
6927
6965
  throw new Error("WASM binding does not support invocation CID computation");
6928
6966
  }
6929
6967
  const session = binding?.session ?? this.requireEncryptionSession();
6968
+ const entries = [
6969
+ {
6970
+ resource: input.networkId,
6971
+ service: "encryption",
6972
+ path: input.networkId,
6973
+ action: input.action
6974
+ }
6975
+ ];
6930
6976
  const headers = this.invokeAnyWithRuntimePermissions(
6931
6977
  session,
6932
- [
6933
- {
6934
- resource: input.networkId,
6935
- service: "encryption",
6936
- path: input.networkId,
6937
- action: input.action
6938
- }
6939
- ],
6978
+ entries,
6940
6979
  [input.facts]
6941
6980
  );
6981
+ const signingSession = this.selectInvokeAnySession(session, entries).session;
6942
6982
  const authorization = authorizationHeader(headers);
6943
6983
  const audienceBound = await rewriteInvocationAudience(
6944
6984
  authorization,
6945
6985
  input.targetNode,
6946
- session.jwk
6986
+ signingSession.jwk
6947
6987
  );
6948
6988
  binding?.graph.assertActive();
6949
6989
  return {
@@ -6996,7 +7036,11 @@ var _TinyCloudNode = class _TinyCloudNode {
6996
7036
  path: networkId,
6997
7037
  actions: ["tinycloud.encryption/decrypt"]
6998
7038
  }) : void 0;
6999
- throw new DecryptTransportResponseError(response.status, permissionHint);
7039
+ throw new DecryptTransportResponseError(
7040
+ response.status,
7041
+ permissionHint,
7042
+ response.status === 404 && networkId === this.getDefaultEncryptionNetworkId() && await response.text().catch(() => "") === "network not found" ? `Network not found: ${networkId}. Sign in again with a current SDK to create the account's encryption network.` : void 0
7043
+ );
7000
7044
  }
7001
7045
  return await response.json();
7002
7046
  }