@tinycloud/node-sdk 3.8.0-beta.7 → 3.8.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.
Files changed (44) hide show
  1. package/README.md +6 -0
  2. package/dist/{TinyCloudNode-jPL2UqH5.d.ts → TinyCloudNode-DaD5vJhL.d.cts} +38 -5
  3. package/dist/{TinyCloudNode-C0LgPzzJ.d.cts → TinyCloudNode-k3TbBwwj.d.ts} +38 -5
  4. package/dist/{WasmKeyProvider-5Ee7fcAw.d.cts → WasmKeyProvider-BKCPRC-c.d.cts} +21 -1
  5. package/dist/{WasmKeyProvider-5Ee7fcAw.d.ts → WasmKeyProvider-BKCPRC-c.d.ts} +21 -1
  6. package/dist/{authority-DvHTgPC4.d.ts → authority-C_fWaxAu.d.ts} +1 -1
  7. package/dist/{authority-Dkhr6n-f.d.cts → authority-DJdbZM6k.d.cts} +1 -1
  8. package/dist/core.cjs +238 -29
  9. package/dist/core.cjs.map +1 -1
  10. package/dist/core.d.cts +4 -4
  11. package/dist/core.d.ts +4 -4
  12. package/dist/core.js +239 -30
  13. package/dist/core.js.map +1 -1
  14. package/dist/credentials-core.d.cts +1 -1
  15. package/dist/credentials-core.d.ts +1 -1
  16. package/dist/credentials.d.cts +1 -1
  17. package/dist/credentials.d.ts +1 -1
  18. package/dist/{delegation-0LKZkmP2.d.cts → delegation-Ckc3UETl.d.cts} +1 -1
  19. package/dist/{delegation-0LKZkmP2.d.ts → delegation-Ckc3UETl.d.ts} +1 -1
  20. package/dist/encryption-keys.d.cts +2 -2
  21. package/dist/encryption-keys.d.ts +2 -2
  22. package/dist/index.cjs +194 -30
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +3 -3
  25. package/dist/index.d.ts +3 -3
  26. package/dist/index.js +199 -32
  27. package/dist/index.js.map +1 -1
  28. package/dist/replication/authority.cjs +3 -0
  29. package/dist/replication/authority.cjs.map +1 -1
  30. package/dist/replication/authority.d.cts +3 -3
  31. package/dist/replication/authority.d.ts +3 -3
  32. package/dist/replication/authority.js +3 -0
  33. package/dist/replication/authority.js.map +1 -1
  34. package/dist/replication/runtime.cjs +1 -0
  35. package/dist/replication/runtime.cjs.map +1 -1
  36. package/dist/replication/runtime.js +1 -0
  37. package/dist/replication/runtime.js.map +1 -1
  38. package/dist/share-receive.cjs +775 -0
  39. package/dist/share-receive.cjs.map +1 -0
  40. package/dist/share-receive.d.cts +32 -0
  41. package/dist/share-receive.d.ts +32 -0
  42. package/dist/share-receive.js +777 -0
  43. package/dist/share-receive.js.map +1 -0
  44. package/package.json +11 -4
package/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { ISigner, Bytes, IWasmBindings, PersistedSessionProof, ISessionManager } from '@tinycloud/sdk-core';
2
2
  export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationPage, AccountDelegationQueryOptions, AccountDelegationRecord, AccountDelegationResource, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, AuthorityRefusal, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, BuildCanonicalDecryptRequestInput, BuildDecryptFactsInput, BuildDecryptInvocationInput, BuiltDecryptInvocation, CallbackStrategy, CanonicalAddress, CanonicalDecryptRequest, CanonicalJson, CanonicalParsedNetworkId, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, CaveatedDelegationUnsupportedError, ClientSession, ColumnInfo, ComposeManifestOptions, ComposedManifestRequest, CreateDelegationParams, DECRYPT_ACTION, DECRYPT_FACT_TYPE, DECRYPT_RESULT_TYPE, DEFAULT_ENCRYPTION_ALG, DEFAULT_KEY_VERSION, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DataVaultConfig, DataVaultService, DatabaseHandle, DecryptCapabilityProof, DecryptEnvelopeOptions, DecryptInvocationFact, DecryptInvocationSigner, DecryptRequestBody, DecryptResponseBody, DecryptTransport, DecryptTransportResponseError, DelegateReceivedShareParams, DelegatedShareAccess, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DelegationRevocationReceipt, DidCacheKeyOptions, DidEqualsOptions, DiscoverNetworkInput, DiscoveredNetwork, DiscoverySource, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, ENCRYPTION_NETWORK_URN_PREFIX, ENCRYPTION_SERVICE, ENCRYPTION_SERVICE_SHORT, ENVELOPE_VERSION, EncodedShareData, EncryptToNetworkInput, EncryptToNetworkOptions, EncryptToNetworkResult, EncryptionCrypto, EncryptionError, EncryptionErrorInput, EncryptionService, EncryptionServiceConfig, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, HookEvent, HookServiceName, HookStreamEvent, HookSubscription, HookWebhookListOptions, HookWebhookRecord, HookWebhookRegistration, HookWebhookScope, HookWebhookUnregisterOptions, HooksService, HooksServiceConfig, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IEncryptionService, IHooksService, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISecretsService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IStorageService, IUserAuthorization, IWasmBindings, IdentityParseError, IngestOptions, InlineEncryptedEnvelope, InvokeFunction, JWK, KVBatchReadResponse, KVCreateSignedReadUrlOptions, KVListPage, KVReadThrough, KVReplicaHandle, KVReplicaSpec, KVReplicaStorage, KVReplicationController, KVReplicationDeps, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, LocalGetResult, LocalListResult, LocalReadMeta, LocalReplicaStatus, LocalSyncResult, MAX_SECRET_SCOPE_LENGTH, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, NETWORK_NAME_PATTERN, NetworkDescriptor, NetworkIdError, NodeDescriptorFetcher, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, OwnerDelegationPermission, ParsedNetworkId, ParsedSecretCatalogKey, PendingWriteRecord, PendingWriteState, PendingWriteStore, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PinnedKey, PkhDidParts, PrefixedKVService, ProtocolMismatchError, PurgeTarget, QueryOptions, QueryResponse, RandomReceiverKeyInput, ReceiveOptions, ReceiverKeyPair, ReceiverKeySigner, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ReplicaAuthorityState, ReplicaCoverage, ReplicaDevice, ReplicaGatedHandle, ReplicaGrantInfo, ReplicaInspectedStatus, ReplicaLocalEraseOutcome, ReplicaPurgeError, ReplicaPurgeFailedEvent, ReplicaPurgeLocalCopyResult, ReplicaPurgeTrigger, ReplicaState, ReplicaStatusEntry, ReplicationAuthority, ReplicationControl, ReplicationEvent, ReplicationIdentity, ReplicationOptions, ReplicationPurgeReport, ReplicationReason, ReplicationScheduler, ResolvedCapabilities, ResolvedDelegate, ResolvedReplicationOptions, ResolvedSecretPath, ResourceCapability, SECRET_NAME_RE, SECRET_SCOPE_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, STORAGE_FULL_MESSAGE, STORAGE_MANAGE_URL, STORAGE_WRITE_TOO_LARGE_MESSAGE, SchemaInfo, SecretCatalogEntry, SecretPayload, SecretPutOptions, SecretScopeOptions, SecretsError, SecretsService, ServiceContext, ServiceContextConfig, ServiceSession, SessionExpiredError, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignInOptions, SignRequest, SignResponse, SignedReceiverKeyInput, SilentNotificationHandler, Space, SpaceAbilitiesMap, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StorageAccountUsage, StorageFullEvent, StorageStatus, StorageStatusOptions, StorageUsage, StorageUsageState, StoredDelegationChain, SubscribeOptions, TC832_RESERVED_SCOPES, 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, VerifyDecryptResponseInput, VersionCheckError, ViewInfo, WasmVaultFunctions, WellKnownDescriptorFetcher, addressStorageKey, appSecretScope, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, buildSpaceUri, canonicalHashHex, canonicalSignedResponse, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeEncryptionJson, canonicalizeNetworkId, canonicalizeSecretScope, checkDecryptInvocationInput, checkNodeInfo, clearTinyCloudDebugLogs, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, createVaultCrypto, decryptEnvelopeWithKey, defaultSpaceCreationHandler, deriveSignedReceiverKey, didCacheKey, didEquals, disableTinyCloudDebug, discoverNetwork, enableTinyCloudDebug, encryptToNetwork, encryptionBase64Decode, encryptionBase64Encode, encryptionError, encryptionUtf8Decode, encryptionUtf8Encode, ensureNetworkUsableForDecrypt, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, generateRandomReceiverKey, getTinyCloudDebugLogs, hexDecode, hexEncode, installTinyCloudDebugGlobals, isCapabilitySubset, isEvmAddress, isNetworkId, isStorageFullError, loadManifest, makePkhSpaceId, makePublicSpaceId, networkDiscoveryKey, openWrappedKey, parseCanonicalNetworkId, parseExpiry, parseNetworkId, parsePkhDid, parseSecretCatalogKey, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, storageUsageState, tinyCloudDebugLogger, validateEnvelope, validateManifest, verifyDecryptResponse } from '@tinycloud/sdk-core';
3
- export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider } from './WasmKeyProvider-5Ee7fcAw.cjs';
4
- export { A as ACCEPTED_MARKER_VERSIONS, l as BOOTSTRAP_COMPLETION_MARKER_KEY, m as BOOTSTRAP_COMPLETION_MARKER_VERSION, n as BootstrapCompletionMarker, 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, o as NodeUserAuthorizationAuthorizeFn, d as NodeUserAuthorizationConfig, p as OpenKeyAuthorizationResultV1, q as OpenKeyAuthorizeInput, r as OpenKeyAuthorizeTinyCloud, s as OpenKeyBridgeInput, O as OwnerDelegationReceipt, t as RestorableSession, 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, w as wireOpenKeyAuthorize } from './TinyCloudNode-C0LgPzzJ.cjs';
3
+ export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider, i as isAppKeyHostBound } from './WasmKeyProvider-BKCPRC-c.cjs';
4
+ export { A as ACCEPTED_MARKER_VERSIONS, m as BOOTSTRAP_COMPLETION_MARKER_KEY, n as BOOTSTRAP_COMPLETION_MARKER_VERSION, o as BootstrapCompletionMarker, 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, p as NodeUserAuthorizationAuthorizeFn, d as NodeUserAuthorizationConfig, q as OpenKeyAuthorizationResultV1, r as OpenKeyAuthorizeInput, O as OpenKeyAuthorizeTinyCloud, s as OpenKeyBridgeInput, e as OwnerDelegationReceipt, P as PreparedOpenKeyAuthorization, t as RestorableSession, R as RuntimePermissionGrantOptions, S as SecretPermissionHint, f as SecretReadInput, g as SecretReadResult, h as SignStrategy, T as TinyCloudNode, i as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, j as UnifiedOwnerRootReceipt, k as UnsupportedSessionRestoreError, l as defaultSignStrategy, w as wireOpenKeyAuthorize } from './TinyCloudNode-DaD5vJhL.cjs';
5
5
  import { invoke, invokeAny, computeCid, prepareSession, completeSessionSetup, ensureEip55, makeSpaceId, createDelegation, parseRecapFromSiwe, parseVerifiedRecapFromSiwe, generateHostSIWEMessage, siweToDelegationHeaders, protocolVersion, vault_encrypt, vault_decrypt, vault_derive_key, vault_x25519_from_seed, vault_x25519_dh, vault_random_bytes, vault_sha256 } from '@tinycloud/node-sdk-wasm';
6
- export { A as AuthDelegationArtifact, b as AuthRequestArtifact, C as CompactRuntimeDelegationInput, D as DelegationAuthority, P as PortableDelegation, R as RUNTIME_DELEGATION_REJECTIONS, c as RuntimeDelegationActivator, e as RuntimeDelegationRejectedError, f as RuntimeDelegationRejection, S as SessionGrantProof, V as ValidatedRuntimeDelegation, g as VerifiedSessionGrant, a as activateCompactRuntimeDelegation, h as activateValidatedRuntimeDelegation, d as deserializeDelegation, i as grantAuthRequest, s as serializeDelegation, j as signedCompactUcanExpiry, k as siweRuntimeDelegation } from './delegation-0LKZkmP2.cjs';
6
+ export { A as AuthDelegationArtifact, e as AuthRequestArtifact, C as CompactRuntimeDelegationInput, D as DelegationAuthority, P as PortableDelegation, f as RUNTIME_DELEGATION_REJECTIONS, g as RuntimeDelegationActivator, R as RuntimeDelegationRejectedError, a as RuntimeDelegationRejection, S as SessionGrantProof, V as ValidatedRuntimeDelegation, h as VerifiedSessionGrant, b as activateCompactRuntimeDelegation, c as activateValidatedRuntimeDelegation, d as deserializeDelegation, i as grantAuthRequest, s as serializeDelegation, j as signedCompactUcanExpiry, k as siweRuntimeDelegation } from './delegation-Ckc3UETl.cjs';
7
7
  import { KVReplicaStorage } from '@tinycloud/sdk-services';
8
8
  import { ProfileReplicaPurge } from '@tinycloud/sdk-services/kv/replication';
9
9
  export { ProfileReplicaDeferredToken, ProfileReplicaPurge } from '@tinycloud/sdk-services/kv/replication';
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { ISigner, Bytes, IWasmBindings, PersistedSessionProof, ISessionManager } from '@tinycloud/sdk-core';
2
2
  export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationPage, AccountDelegationQueryOptions, AccountDelegationRecord, AccountDelegationResource, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, AuthorityRefusal, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, BuildCanonicalDecryptRequestInput, BuildDecryptFactsInput, BuildDecryptInvocationInput, BuiltDecryptInvocation, CallbackStrategy, CanonicalAddress, CanonicalDecryptRequest, CanonicalJson, CanonicalParsedNetworkId, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, CaveatedDelegationUnsupportedError, ClientSession, ColumnInfo, ComposeManifestOptions, ComposedManifestRequest, CreateDelegationParams, DECRYPT_ACTION, DECRYPT_FACT_TYPE, DECRYPT_RESULT_TYPE, DEFAULT_ENCRYPTION_ALG, DEFAULT_KEY_VERSION, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DataVaultConfig, DataVaultService, DatabaseHandle, DecryptCapabilityProof, DecryptEnvelopeOptions, DecryptInvocationFact, DecryptInvocationSigner, DecryptRequestBody, DecryptResponseBody, DecryptTransport, DecryptTransportResponseError, DelegateReceivedShareParams, DelegatedShareAccess, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DelegationRevocationReceipt, DidCacheKeyOptions, DidEqualsOptions, DiscoverNetworkInput, DiscoveredNetwork, DiscoverySource, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, ENCRYPTION_NETWORK_URN_PREFIX, ENCRYPTION_SERVICE, ENCRYPTION_SERVICE_SHORT, ENVELOPE_VERSION, EncodedShareData, EncryptToNetworkInput, EncryptToNetworkOptions, EncryptToNetworkResult, EncryptionCrypto, EncryptionError, EncryptionErrorInput, EncryptionService, EncryptionServiceConfig, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, HookEvent, HookServiceName, HookStreamEvent, HookSubscription, HookWebhookListOptions, HookWebhookRecord, HookWebhookRegistration, HookWebhookScope, HookWebhookUnregisterOptions, HooksService, HooksServiceConfig, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IEncryptionService, IHooksService, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISecretsService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IStorageService, IUserAuthorization, IWasmBindings, IdentityParseError, IngestOptions, InlineEncryptedEnvelope, InvokeFunction, JWK, KVBatchReadResponse, KVCreateSignedReadUrlOptions, KVListPage, KVReadThrough, KVReplicaHandle, KVReplicaSpec, KVReplicaStorage, KVReplicationController, KVReplicationDeps, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, LocalGetResult, LocalListResult, LocalReadMeta, LocalReplicaStatus, LocalSyncResult, MAX_SECRET_SCOPE_LENGTH, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, NETWORK_NAME_PATTERN, NetworkDescriptor, NetworkIdError, NodeDescriptorFetcher, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, OwnerDelegationPermission, ParsedNetworkId, ParsedSecretCatalogKey, PendingWriteRecord, PendingWriteState, PendingWriteStore, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PinnedKey, PkhDidParts, PrefixedKVService, ProtocolMismatchError, PurgeTarget, QueryOptions, QueryResponse, RandomReceiverKeyInput, ReceiveOptions, ReceiverKeyPair, ReceiverKeySigner, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ReplicaAuthorityState, ReplicaCoverage, ReplicaDevice, ReplicaGatedHandle, ReplicaGrantInfo, ReplicaInspectedStatus, ReplicaLocalEraseOutcome, ReplicaPurgeError, ReplicaPurgeFailedEvent, ReplicaPurgeLocalCopyResult, ReplicaPurgeTrigger, ReplicaState, ReplicaStatusEntry, ReplicationAuthority, ReplicationControl, ReplicationEvent, ReplicationIdentity, ReplicationOptions, ReplicationPurgeReport, ReplicationReason, ReplicationScheduler, ResolvedCapabilities, ResolvedDelegate, ResolvedReplicationOptions, ResolvedSecretPath, ResourceCapability, SECRET_NAME_RE, SECRET_SCOPE_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, STORAGE_FULL_MESSAGE, STORAGE_MANAGE_URL, STORAGE_WRITE_TOO_LARGE_MESSAGE, SchemaInfo, SecretCatalogEntry, SecretPayload, SecretPutOptions, SecretScopeOptions, SecretsError, SecretsService, ServiceContext, ServiceContextConfig, ServiceSession, SessionExpiredError, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignInOptions, SignRequest, SignResponse, SignedReceiverKeyInput, SilentNotificationHandler, Space, SpaceAbilitiesMap, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StorageAccountUsage, StorageFullEvent, StorageStatus, StorageStatusOptions, StorageUsage, StorageUsageState, StoredDelegationChain, SubscribeOptions, TC832_RESERVED_SCOPES, 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, VerifyDecryptResponseInput, VersionCheckError, ViewInfo, WasmVaultFunctions, WellKnownDescriptorFetcher, addressStorageKey, appSecretScope, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, buildSpaceUri, canonicalHashHex, canonicalSignedResponse, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeEncryptionJson, canonicalizeNetworkId, canonicalizeSecretScope, checkDecryptInvocationInput, checkNodeInfo, clearTinyCloudDebugLogs, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, createVaultCrypto, decryptEnvelopeWithKey, defaultSpaceCreationHandler, deriveSignedReceiverKey, didCacheKey, didEquals, disableTinyCloudDebug, discoverNetwork, enableTinyCloudDebug, encryptToNetwork, encryptionBase64Decode, encryptionBase64Encode, encryptionError, encryptionUtf8Decode, encryptionUtf8Encode, ensureNetworkUsableForDecrypt, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, generateRandomReceiverKey, getTinyCloudDebugLogs, hexDecode, hexEncode, installTinyCloudDebugGlobals, isCapabilitySubset, isEvmAddress, isNetworkId, isStorageFullError, loadManifest, makePkhSpaceId, makePublicSpaceId, networkDiscoveryKey, openWrappedKey, parseCanonicalNetworkId, parseExpiry, parseNetworkId, parsePkhDid, parseSecretCatalogKey, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, storageUsageState, tinyCloudDebugLogger, validateEnvelope, validateManifest, verifyDecryptResponse } from '@tinycloud/sdk-core';
3
- export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider } from './WasmKeyProvider-5Ee7fcAw.js';
4
- export { A as ACCEPTED_MARKER_VERSIONS, l as BOOTSTRAP_COMPLETION_MARKER_KEY, m as BOOTSTRAP_COMPLETION_MARKER_VERSION, n as BootstrapCompletionMarker, 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, o as NodeUserAuthorizationAuthorizeFn, d as NodeUserAuthorizationConfig, p as OpenKeyAuthorizationResultV1, q as OpenKeyAuthorizeInput, r as OpenKeyAuthorizeTinyCloud, s as OpenKeyBridgeInput, O as OwnerDelegationReceipt, t as RestorableSession, 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, w as wireOpenKeyAuthorize } from './TinyCloudNode-jPL2UqH5.js';
3
+ export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider, i as isAppKeyHostBound } from './WasmKeyProvider-BKCPRC-c.js';
4
+ export { A as ACCEPTED_MARKER_VERSIONS, m as BOOTSTRAP_COMPLETION_MARKER_KEY, n as BOOTSTRAP_COMPLETION_MARKER_VERSION, o as BootstrapCompletionMarker, 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, p as NodeUserAuthorizationAuthorizeFn, d as NodeUserAuthorizationConfig, q as OpenKeyAuthorizationResultV1, r as OpenKeyAuthorizeInput, O as OpenKeyAuthorizeTinyCloud, s as OpenKeyBridgeInput, e as OwnerDelegationReceipt, P as PreparedOpenKeyAuthorization, t as RestorableSession, R as RuntimePermissionGrantOptions, S as SecretPermissionHint, f as SecretReadInput, g as SecretReadResult, h as SignStrategy, T as TinyCloudNode, i as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, j as UnifiedOwnerRootReceipt, k as UnsupportedSessionRestoreError, l as defaultSignStrategy, w as wireOpenKeyAuthorize } from './TinyCloudNode-k3TbBwwj.js';
5
5
  import { invoke, invokeAny, computeCid, prepareSession, completeSessionSetup, ensureEip55, makeSpaceId, createDelegation, parseRecapFromSiwe, parseVerifiedRecapFromSiwe, generateHostSIWEMessage, siweToDelegationHeaders, protocolVersion, vault_encrypt, vault_decrypt, vault_derive_key, vault_x25519_from_seed, vault_x25519_dh, vault_random_bytes, vault_sha256 } from '@tinycloud/node-sdk-wasm';
6
- export { A as AuthDelegationArtifact, b as AuthRequestArtifact, C as CompactRuntimeDelegationInput, D as DelegationAuthority, P as PortableDelegation, R as RUNTIME_DELEGATION_REJECTIONS, c as RuntimeDelegationActivator, e as RuntimeDelegationRejectedError, f as RuntimeDelegationRejection, S as SessionGrantProof, V as ValidatedRuntimeDelegation, g as VerifiedSessionGrant, a as activateCompactRuntimeDelegation, h as activateValidatedRuntimeDelegation, d as deserializeDelegation, i as grantAuthRequest, s as serializeDelegation, j as signedCompactUcanExpiry, k as siweRuntimeDelegation } from './delegation-0LKZkmP2.js';
6
+ export { A as AuthDelegationArtifact, e as AuthRequestArtifact, C as CompactRuntimeDelegationInput, D as DelegationAuthority, P as PortableDelegation, f as RUNTIME_DELEGATION_REJECTIONS, g as RuntimeDelegationActivator, R as RuntimeDelegationRejectedError, a as RuntimeDelegationRejection, S as SessionGrantProof, V as ValidatedRuntimeDelegation, h as VerifiedSessionGrant, b as activateCompactRuntimeDelegation, c as activateValidatedRuntimeDelegation, d as deserializeDelegation, i as grantAuthRequest, s as serializeDelegation, j as signedCompactUcanExpiry, k as siweRuntimeDelegation } from './delegation-Ckc3UETl.js';
7
7
  import { KVReplicaStorage } from '@tinycloud/sdk-services';
8
8
  import { ProfileReplicaPurge } from '@tinycloud/sdk-services/kv/replication';
9
9
  export { ProfileReplicaDeferredToken, ProfileReplicaPurge } from '@tinycloud/sdk-services/kv/replication';
package/dist/index.js CHANGED
@@ -17099,6 +17099,9 @@ function assertValidReplicationConfig(replication) {
17099
17099
  if (replication?.syncScope !== void 0 && replication.syncScope !== "prefixes") {
17100
17100
  throw new TypeError('replication.syncScope must be "prefixes"');
17101
17101
  }
17102
+ if (replication?.contentFetch !== void 0 && replication.contentFetch !== "eager" && replication.contentFetch !== "lazy") {
17103
+ throw new TypeError('replication.contentFetch must be "eager" or "lazy"');
17104
+ }
17102
17105
  if (replication === void 0 || !replication.enabled) return;
17103
17106
  if (replication.storage === void 0 || replication.storage === null) {
17104
17107
  throw new TypeError("replication.enabled requires replication.storage");
@@ -17151,6 +17154,7 @@ function resolvedOptions(options) {
17151
17154
  maxStalenessMs: options.maxStalenessMs ?? 12e4,
17152
17155
  staleSyncTimeoutMs: options.staleSyncTimeoutMs ?? 5e3,
17153
17156
  allowSecrets: options.allowSecrets === true,
17157
+ contentFetch: options.contentFetch ?? "eager",
17154
17158
  verify: options.verify === true
17155
17159
  };
17156
17160
  }
@@ -18686,6 +18690,7 @@ function deserializeDelegation(data) {
18686
18690
 
18687
18691
  // src/TinyCloudNode.ts
18688
18692
  import { generateNonce, SiweMessage as SiweMessage3 } from "siwe";
18693
+ import { didKeyFromEd25519PublicKey } from "@tinycloud/share-envelope";
18689
18694
 
18690
18695
  // src/replication/module-registry.ts
18691
18696
  var nodeLoaders;
@@ -18734,10 +18739,13 @@ import {
18734
18739
  ENCRYPTION_PERMISSION_SERVICE as ENCRYPTION_PERMISSION_SERVICE2,
18735
18740
  CaveatedDelegationUnsupportedError as CaveatedDelegationUnsupportedError2,
18736
18741
  PermissionNotInManifestError,
18742
+ ManifestValidationError as ManifestValidationError2,
18737
18743
  SessionExpiredError,
18738
18744
  canonicalizeRecapCaveats as canonicalizeRecapCaveats2,
18739
18745
  recapCaveatsEqual as recapCaveatsEqual2,
18740
18746
  expandPermissionEntries as expandPermissionEntriesCore,
18747
+ expandRuntimePermissionEntries,
18748
+ expandDelegationPermissionEntries,
18741
18749
  isCapabilitySubset as isCapabilitySubset2,
18742
18750
  isExplicitOnlyAction,
18743
18751
  parseRecapCapabilities,
@@ -18768,6 +18776,7 @@ import {
18768
18776
  withoutShareLink,
18769
18777
  verifyEip191MessageSignature,
18770
18778
  signCompactUcanRootAuthorization,
18779
+ signCompactUcanAuthorization,
18771
18780
  markDelegationTerminal,
18772
18781
  isStorageFullError,
18773
18782
  STORAGE_FULL_MESSAGE,
@@ -18851,6 +18860,18 @@ function appKeyHostBinding(domain, appId) {
18851
18860
  const reversed = labels.reverse().join(".");
18852
18861
  return appId === reversed || appId.startsWith(`${reversed}.`);
18853
18862
  }
18863
+ function isAppKeyHostBound(keysAppId, origin) {
18864
+ if (typeof origin === "string" && !origin.includes("://")) {
18865
+ return appKeyHostBinding(origin, keysAppId);
18866
+ }
18867
+ let url;
18868
+ try {
18869
+ url = typeof origin === "string" ? new URL(origin) : origin;
18870
+ } catch {
18871
+ return false;
18872
+ }
18873
+ return appKeyHostBinding(url.host, keysAppId);
18874
+ }
18854
18875
 
18855
18876
  // src/authorization/NodeUserAuthorization.ts
18856
18877
  init_authority_sign_in();
@@ -19011,6 +19032,7 @@ function cloneAbilitiesMap(actions) {
19011
19032
  var NodeUserAuthorization = class {
19012
19033
  constructor(config) {
19013
19034
  this.activeSessionKeyId = "default";
19035
+ this.preparedSessionCounter = 0;
19014
19036
  /** Incremented by resetSession; a sign-in started earlier publishes nothing. */
19015
19037
  this.sessionGeneration = 0;
19016
19038
  /**
@@ -19593,7 +19615,8 @@ var NodeUserAuthorization = class {
19593
19615
  return true;
19594
19616
  }
19595
19617
  const parsed = entry.path.includes("/") ? parseEncryptionResource(entry.path) : { ...parseNetworkId(entry.path), kind: "network" };
19596
- if (parsed.kind !== "network") {
19618
+ const sharePrefix = parsed.kind === "prefix" && parsed.network === "default" && parsed.prefix === "share" && entry.actions.length === 1 && entry.actions[0] === DECRYPT_ACTION && didPrincipalMatches(parsed.ownerDid, currentDid);
19619
+ if (parsed.kind !== "network" && !sharePrefix) {
19597
19620
  throw new ManifestValidationError("named keys go in manifest.keys");
19598
19621
  }
19599
19622
  for (const action of entry.actions) {
@@ -19636,8 +19659,7 @@ var NodeUserAuthorization = class {
19636
19659
  /**
19637
19660
  * Build SIWE overrides from the top-level nonce and siweConfig.
19638
19661
  * - Top-level `nonce` is seeded first so `siweConfig.nonce` wins if both are set.
19639
- * - statement is prepended to the default statement
19640
- * - resources are appended to the default resources
19662
+ * - resources are inserted after WASM preparation, before the final ReCap
19641
19663
  * - uri triggers a warning (overwriting delegation target)
19642
19664
  * - all other fields override directly
19643
19665
  * - per-call nonce overrides siweConfig.nonce when provided
@@ -19655,9 +19677,6 @@ var NodeUserAuthorization = class {
19655
19677
  if (statement) {
19656
19678
  overrides.statement = this.statement ? `${statement} ${this.statement}` : statement;
19657
19679
  }
19658
- if (resources && resources.length > 0) {
19659
- overrides.resources = resources;
19660
- }
19661
19680
  if (uri) {
19662
19681
  console.warn(
19663
19682
  "[tinycloud] siweConfig.uri is overwriting the delegation target URI. This may break delegation chain validation if the URI does not match the session key DID."
@@ -19669,6 +19688,29 @@ var NodeUserAuthorization = class {
19669
19688
  }
19670
19689
  return overrides;
19671
19690
  }
19691
+ prepareSessionWithResources(params) {
19692
+ const resources = this.siweConfig?.resources;
19693
+ if (resources?.some((resource) => typeof resource !== "string" || !/^urn:tinycloud:recipients:[A-Za-z0-9_-]+$/.test(resource))) {
19694
+ throw new Error("SIWE metadata resources must be base64url recipients URIs");
19695
+ }
19696
+ const prepared = this.wasm.prepareSession(params);
19697
+ if (!resources?.length) return prepared;
19698
+ const recapLines = /^- urn:recap:[^\r\n]+$/gim;
19699
+ const recaps = prepared.siwe.match(recapLines);
19700
+ const recap = recaps?.[0];
19701
+ if (recaps?.length !== 1 || !prepared.siwe.endsWith(recap)) {
19702
+ throw new Error("Prepared SIWE must end with exactly one ReCap");
19703
+ }
19704
+ const insertedLines = resources.map((resource) => `- ${resource}`);
19705
+ const siwe = prepared.siwe.slice(0, -recap.length) + insertedLines.join("\n") + "\n" + recap;
19706
+ const expectedFields = extractImmutableSiweFields(prepared.siwe);
19707
+ expectedFields.nonRecapResources = [expectedFields.nonRecapResources, ...insertedLines].filter(Boolean).join("\n");
19708
+ const actualRecaps = siwe.match(recapLines);
19709
+ if (actualRecaps?.length !== 1 || actualRecaps[0] !== recap || diffImmutableSiweFields(expectedFields, extractImmutableSiweFields(siwe)).length) {
19710
+ throw new Error("SIWE metadata insertion changed the prepared message");
19711
+ }
19712
+ return { ...prepared, siwe };
19713
+ }
19672
19714
  /**
19673
19715
  * Add an extension to the authorization flow.
19674
19716
  */
@@ -19916,7 +19958,7 @@ var NodeUserAuthorization = class {
19916
19958
  spaceAbilities[spaceId] = resourceCapabilitiesToAbilitiesMap(resources);
19917
19959
  }
19918
19960
  const abilities = spaceAbilities[options.spaceId] ?? resourceCapabilitiesToAbilitiesMap([]);
19919
- const prepared = this.wasm.prepareSession({
19961
+ const prepared = this.prepareSessionWithResources({
19920
19962
  abilities,
19921
19963
  spaceAbilities,
19922
19964
  ...options.rawAbilities !== void 0 ? { rawAbilities: options.rawAbilities } : {},
@@ -19997,8 +20039,8 @@ var NodeUserAuthorization = class {
19997
20039
  this.assertSignInCurrent(generation);
19998
20040
  await this.refreshNamedKeyFeatureForSignIn(address, chainId);
19999
20041
  this.assertSignInCurrent(generation);
20000
- const keyId = `session-${Date.now()}`;
20001
- this.sessionManager.renameSessionKeyId(this.activeSessionKeyId, keyId);
20042
+ const keyId = `session-${Date.now()}-${Math.random().toString(36).slice(2)}`;
20043
+ this.sessionManager.createSessionKey(keyId);
20002
20044
  this.activeSessionKeyId = keyId;
20003
20045
  const jwkString = this.sessionManager.jwk(keyId);
20004
20046
  if (!jwkString) {
@@ -20009,7 +20051,7 @@ var NodeUserAuthorization = class {
20009
20051
  const spaceId = capabilityPlan.spaceId;
20010
20052
  const now = /* @__PURE__ */ new Date();
20011
20053
  const expirationTime = new Date(now.getTime() + this.sessionExpirationMs);
20012
- const prepared = this.wasm.prepareSession({
20054
+ const prepared = this.prepareSessionWithResources({
20013
20055
  abilities: capabilityPlan.abilities,
20014
20056
  ...capabilityPlan.spaceAbilities !== void 0 ? { spaceAbilities: capabilityPlan.spaceAbilities } : {},
20015
20057
  ...capabilityPlan.rawAbilities !== void 0 ? { rawAbilities: capabilityPlan.rawAbilities } : {},
@@ -20144,9 +20186,8 @@ var NodeUserAuthorization = class {
20144
20186
  const address = canonicalizeAddress(await this.signer.getAddress());
20145
20187
  const chainId = await this.signer.getChainId();
20146
20188
  await this.refreshNamedKeyFeatureForSignIn(address, chainId);
20147
- const keyId = `session-${Date.now()}`;
20148
- this.sessionManager.renameSessionKeyId(this.activeSessionKeyId, keyId);
20149
- this.activeSessionKeyId = keyId;
20189
+ const keyId = `openkey-session-${Date.now()}-${++this.preparedSessionCounter}`;
20190
+ this.sessionManager.createSessionKey(keyId);
20150
20191
  const jwkString = this.sessionManager.jwk(keyId);
20151
20192
  if (!jwkString) {
20152
20193
  throw new Error("Failed to create session key");
@@ -20156,7 +20197,7 @@ var NodeUserAuthorization = class {
20156
20197
  const spaceId = capabilityPlan.spaceId;
20157
20198
  const now = /* @__PURE__ */ new Date();
20158
20199
  const expirationTime = new Date(now.getTime() + this.sessionExpirationMs);
20159
- const prepared = this.wasm.prepareSession({
20200
+ const prepared = this.prepareSessionWithResources({
20160
20201
  abilities: capabilityPlan.abilities,
20161
20202
  ...capabilityPlan.spaceAbilities !== void 0 ? { spaceAbilities: capabilityPlan.spaceAbilities } : {},
20162
20203
  ...capabilityPlan.rawAbilities !== void 0 ? { rawAbilities: capabilityPlan.rawAbilities } : {},
@@ -20227,6 +20268,7 @@ var NodeUserAuthorization = class {
20227
20268
  await this.sessionStorage.save(address, persistedData);
20228
20269
  this._session = clientSession;
20229
20270
  this._tinyCloudSession = tinyCloudSession;
20271
+ this.activeSessionKeyId = keyId;
20230
20272
  this._address = address;
20231
20273
  this._chainId = chainId;
20232
20274
  await this.refreshNodeInfo();
@@ -20273,6 +20315,11 @@ var NodeUserAuthorization = class {
20273
20315
  * @param options Optional overrides for the OpenKey request.
20274
20316
  */
20275
20317
  async signInWithOpenKey(authorizeFn, options) {
20318
+ const pending = await this.prepareOpenKeySignIn(options);
20319
+ return this.completeOpenKeySignIn(pending, authorizeFn(pending.request), options);
20320
+ }
20321
+ /** Finish address, host and SIWE preparation before an approval click. */
20322
+ async prepareOpenKeySignIn(options) {
20276
20323
  refuseCaveated(this.getCapabilityRequest()?.manifests);
20277
20324
  if (options?.host !== void 0) {
20278
20325
  const overrideHost = options.host.trim();
@@ -20284,7 +20331,7 @@ var NodeUserAuthorization = class {
20284
20331
  const signingAddress = canonicalizeAddress(await this.signer.getAddress());
20285
20332
  const signingChainId = await this.signer.getChainId();
20286
20333
  await this.resolveTinyCloudHostsForSignIn(signingAddress, signingChainId);
20287
- const { prepared, keyId, jwk } = await this.prepareSessionForSigning();
20334
+ const { prepared, keyId, jwk, address, chainId } = await this.prepareSessionForSigning();
20288
20335
  const presentation = this.buildPresentationEnvelope(options?.reason);
20289
20336
  const hostHint = this.primaryTinyCloudHost;
20290
20337
  const originalRequest = {
@@ -20296,12 +20343,32 @@ var NodeUserAuthorization = class {
20296
20343
  keyId: options?.openkeyKeyId,
20297
20344
  presentation
20298
20345
  };
20346
+ return {
20347
+ request: originalRequest,
20348
+ prepared,
20349
+ keyId,
20350
+ jwk,
20351
+ address,
20352
+ chainId,
20353
+ generation: this.sessionGeneration,
20354
+ createdAt: Date.now()
20355
+ };
20356
+ }
20357
+ /** Complete a prepared approval. The caller starts authorization before awaiting this method. */
20358
+ async completeOpenKeySignIn(pending, authorization, options) {
20359
+ if (Date.now() - pending.createdAt > 5 * 6e4) {
20360
+ throw new Error("Prepared OpenKey sign-in expired; prepare again");
20361
+ }
20362
+ if (pending.generation !== this.sessionGeneration) {
20363
+ throw new Error("Prepared OpenKey sign-in expired after sign-out");
20364
+ }
20365
+ const { request: originalRequest, prepared, keyId, jwk } = pending;
20299
20366
  let result;
20300
20367
  let signed2;
20301
20368
  let signature2;
20302
20369
  for (let attempt = 0; ; ) {
20303
20370
  try {
20304
- result ?? (result = await authorizeFn(originalRequest));
20371
+ result ?? (result = await authorization);
20305
20372
  signed2 = await this.verifyOpenKeyResult(result, prepared);
20306
20373
  signature2 = result.signature;
20307
20374
  break;
@@ -21710,6 +21777,7 @@ var _TinyCloudNode = class _TinyCloudNode {
21710
21777
  constructor(config = {}) {
21711
21778
  this.signer = null;
21712
21779
  this.auth = null;
21780
+ this.consumedOpenKeyPendings = /* @__PURE__ */ new WeakSet();
21713
21781
  this.tc = null;
21714
21782
  this._chainId = 1;
21715
21783
  this.replicaPurgeFailedHandlers = /* @__PURE__ */ new Set();
@@ -22650,6 +22718,37 @@ var _TinyCloudNode = class _TinyCloudNode {
22650
22718
  }
22651
22719
  await this.signInWith(() => this.auth.signInWithOpenKey(authorizeFn, options));
22652
22720
  }
22721
+ /** Prepare the OpenKey request before the approval click. */
22722
+ async prepareOpenKeySignIn() {
22723
+ if (!this.signer || !this.tc || !this.auth) {
22724
+ throw new Error("Cannot prepare OpenKey sign-in in session-only mode. Provide a signer in config.");
22725
+ }
22726
+ await this.signOutInFlight;
22727
+ await this.accountRegistryTail;
22728
+ await this.wasmBindings.ensureInitialized?.();
22729
+ return this.auth.prepareOpenKeySignIn();
22730
+ }
22731
+ /** Start OpenKey authorization synchronously, then complete normal session setup. */
22732
+ signInWithPreparedOpenKey(pending, authorizeFn) {
22733
+ if (!this.signer || !this.tc || !this.auth || this.signOutInFlight) {
22734
+ throw new Error("Prepared OpenKey sign-in is unavailable");
22735
+ }
22736
+ if (this.consumedOpenKeyPendings.has(pending)) {
22737
+ throw new Error("Prepared OpenKey sign-in was already used");
22738
+ }
22739
+ if (Date.now() - pending.createdAt > 5 * 6e4) {
22740
+ throw new Error("Prepared OpenKey sign-in expired; prepare again");
22741
+ }
22742
+ this.consumedOpenKeyPendings.add(pending);
22743
+ const authorization = authorizeFn(pending.request);
22744
+ void authorization.catch(() => void 0);
22745
+ return this.signInWith(() => {
22746
+ if (this._address !== pending.address || this._chainId !== pending.chainId) {
22747
+ throw new Error("OpenKey account changed after sign-in preparation");
22748
+ }
22749
+ return this.auth.completeOpenKeySignIn(pending, authorization);
22750
+ });
22751
+ }
22653
22752
  async signInWith(performSignIn) {
22654
22753
  refuseCaveated(this.auth?.capabilityRequest?.manifests);
22655
22754
  const epoch = this.sessionEpoch;
@@ -24291,6 +24390,7 @@ var _TinyCloudNode = class _TinyCloudNode {
24291
24390
  invoke: graph.invoke,
24292
24391
  invokeAny: graph.invokeAny,
24293
24392
  signOwnerRevocation: this.signer ? (cid) => this.signOwnerRevocation(cid) : void 0,
24393
+ sessionInvocationSigner: this.sessionInvocationSignerFor(input.serviceSession),
24294
24394
  fetch: graph.fetch
24295
24395
  });
24296
24396
  const keyProvider = new WasmKeyProvider({ sessionManager: input.manager });
@@ -24506,6 +24606,31 @@ var _TinyCloudNode = class _TinyCloudNode {
24506
24606
  if (session === void 0) throw new Error("Not signed in. Call signIn() first.");
24507
24607
  return signBytesWithJwk(bytes, session.jwk);
24508
24608
  }
24609
+ /**
24610
+ * Signs proofless invocations with `session`'s own did:key, for the node's
24611
+ * issued-delegation list and revocation by the delegator. The audience is
24612
+ * this Node's DID; each invocation lives 60 seconds.
24613
+ */
24614
+ sessionInvocationSignerFor(session) {
24615
+ return {
24616
+ did: () => session.verificationMethod.split("#", 1)[0],
24617
+ sign: async (attenuation) => {
24618
+ const now = Math.floor(Date.now() / 1e3);
24619
+ const invocation = await signCompactUcanAuthorization({
24620
+ issuerDid: session.verificationMethod.split("#", 1)[0],
24621
+ audienceDid: await this.fetchNodeId(),
24622
+ attenuation,
24623
+ facts: [{}],
24624
+ proofs: [],
24625
+ notBefore: now,
24626
+ expiresAt: now + 60,
24627
+ nonce: `urn:uuid:${crypto.randomUUID()}`,
24628
+ sign: (bytes) => signBytesWithJwk(bytes, session.jwk)
24629
+ });
24630
+ return invocation.authorization;
24631
+ }
24632
+ };
24633
+ }
24509
24634
  /** Author a proofless Policy/v3 owner root with the authenticated holder key. */
24510
24635
  async createUnifiedOwnerRoot(input) {
24511
24636
  const ownerDid = this.credentialHolderDid;
@@ -25040,7 +25165,7 @@ var _TinyCloudNode = class _TinyCloudNode {
25040
25165
  graph.assertActive();
25041
25166
  const signed2 = await this.signRawNetworkAuthorization({
25042
25167
  targetNode: input.targetNode,
25043
- networkId: input.networkId,
25168
+ networkId: input.body.keyPath === void 0 ? input.networkId : `${input.networkId}/${input.body.keyPath}`,
25044
25169
  action: DECRYPT_ACTION2,
25045
25170
  facts: input.facts
25046
25171
  }, { graph, session });
@@ -25213,6 +25338,7 @@ var _TinyCloudNode = class _TinyCloudNode {
25213
25338
  invoke: graph.invoke,
25214
25339
  invokeAny: graph.invokeAny,
25215
25340
  signOwnerRevocation: this.signer ? (cid) => this.signOwnerRevocation(cid) : void 0,
25341
+ sessionInvocationSigner: this.sessionInvocationSignerFor(serviceSession),
25216
25342
  fetch: graph.fetch
25217
25343
  });
25218
25344
  this._spaceService = new SpaceService({
@@ -25996,7 +26122,7 @@ var _TinyCloudNode = class _TinyCloudNode {
25996
26122
  if (!session || !Array.isArray(permissions) || permissions.length === 0) {
25997
26123
  return false;
25998
26124
  }
25999
- const expanded = this.expandPermissionEntries(permissions);
26125
+ const expanded = expandRuntimePermissionEntries(permissions, pkhDid2(session.address, session.chainId));
26000
26126
  if (this.sessionCoversPermissionEntries(session, expanded)) {
26001
26127
  return true;
26002
26128
  }
@@ -26016,7 +26142,7 @@ var _TinyCloudNode = class _TinyCloudNode {
26016
26142
  if (!session || !Array.isArray(permissions) || permissions.length === 0) {
26017
26143
  return [];
26018
26144
  }
26019
- const expanded = this.expandPermissionEntries(permissions);
26145
+ const expanded = expandRuntimePermissionEntries(permissions, pkhDid2(session.address, session.chainId));
26020
26146
  return this.findRuntimeGrantsForPermissionEntries(expanded, session).map(
26021
26147
  (grant) => grant.delegation
26022
26148
  );
@@ -26191,7 +26317,28 @@ var _TinyCloudNode = class _TinyCloudNode {
26191
26317
  throw new SessionExpiredError(sessionExpiry);
26192
26318
  }
26193
26319
  }
26194
- const expanded = this.expandPermissionEntries(permissions);
26320
+ const expanded = expandRuntimePermissionEntries(permissions, pkhDid2(session.address, session.chainId));
26321
+ const bindsShareKey = expanded.some((entry) => entry.service === ENCRYPTION_PERMISSION_SERVICE2 && entry.actions.includes("tinycloud.encryption/key.create"));
26322
+ const captured = bindsShareKey ? { ...session, jwk: { ...options?.expectedSessionKey ?? session.jwk } } : session;
26323
+ const assertCapturedKey = bindsShareKey ? () => {
26324
+ const live = session.jwk;
26325
+ const key2 = captured.jwk;
26326
+ if (this.currentTinyCloudSession() !== session || session.verificationMethod !== captured.verificationMethod || session.delegationCid !== captured.delegationCid || session.spaceId !== captured.spaceId || session.address !== captured.address || session.chainId !== captured.chainId || live?.kty !== key2.kty || live?.crv !== key2.crv || live?.x !== key2.x || live?.y !== key2.y || live?.d !== key2.d) {
26327
+ throw new Error("Runtime permission request cancelled because the session key changed.");
26328
+ }
26329
+ } : void 0;
26330
+ const sessionKeyDid = bindsShareKey ? this.sessionDid : void 0;
26331
+ if (bindsShareKey) {
26332
+ const key2 = captured.jwk;
26333
+ if (key2.kty !== "OKP" || key2.crv !== "Ed25519" || typeof key2.x !== "string") {
26334
+ throw new Error("Runtime permission session key does not match its signed identity.");
26335
+ }
26336
+ const keyDid = didKeyFromEd25519PublicKey(base64UrlDecode(key2.x));
26337
+ if (!didPrincipalMatches2(keyDid, sessionKeyDid) || !didPrincipalMatches2(keyDid, captured.verificationMethod) || !didPrincipalMatches2(keyDid, new SiweMessage3(session.siwe).uri)) {
26338
+ throw new Error("Runtime permission session key does not match its signed identity.");
26339
+ }
26340
+ assertCapturedKey();
26341
+ }
26195
26342
  if (this.sessionCoversPermissionEntries(session, expanded)) {
26196
26343
  return [];
26197
26344
  }
@@ -26241,13 +26388,13 @@ var _TinyCloudNode = class _TinyCloudNode {
26241
26388
  return this.wasmBindings.prepareSession({
26242
26389
  abilities,
26243
26390
  ...rawForDelegation.length > 0 ? { rawAbilities: this.permissionsToRawAbilities(rawForDelegation) } : {},
26244
- address: this.wasmBindings.ensureEip55(session.address),
26245
- chainId: session.chainId,
26391
+ address: this.wasmBindings.ensureEip55(captured.address),
26392
+ chainId: captured.chainId,
26246
26393
  domain: this.siweDomain,
26247
26394
  issuedAt: now.toISOString(),
26248
26395
  expirationTime: expiresAt.toISOString(),
26249
26396
  spaceId,
26250
- jwk: session.jwk
26397
+ jwk: captured.jwk
26251
26398
  });
26252
26399
  } catch (error) {
26253
26400
  if (rawForDelegation.some((entry) => this.isRawRevocationPermissionEntry(entry)) && /invalid ReCap resource URI/i.test(error instanceof Error ? error.message : String(error))) {
@@ -26259,8 +26406,13 @@ var _TinyCloudNode = class _TinyCloudNode {
26259
26406
  throw error;
26260
26407
  }
26261
26408
  })();
26409
+ if (bindsShareKey && !didPrincipalMatches2(new SiweMessage3(prepared.siwe).uri, sessionKeyDid)) {
26410
+ throw new Error("Prepared runtime permission targets a different session key.");
26411
+ }
26412
+ assertCapturedKey?.();
26262
26413
  const signature2 = await this.signer.signMessage(prepared.siwe);
26263
26414
  graph.assertActive();
26415
+ assertCapturedKey?.();
26264
26416
  const delegatedSession = this.wasmBindings.completeSessionSetup({
26265
26417
  ...prepared,
26266
26418
  signature: signature2
@@ -26289,18 +26441,19 @@ var _TinyCloudNode = class _TinyCloudNode {
26289
26441
  delegatedSession,
26290
26442
  delegatedEntries,
26291
26443
  spaceId,
26292
- session,
26444
+ captured,
26293
26445
  expiresAt,
26294
26446
  { siwe: prepared.siwe, signature: signature2 }
26295
26447
  );
26296
26448
  graph.assertActive();
26449
+ assertCapturedKey?.();
26297
26450
  this.runtimePermissionGrants.push({
26298
26451
  session: {
26299
26452
  delegationHeader: delegatedSession.delegationHeader,
26300
26453
  delegationCid: delegatedSession.delegationCid,
26301
26454
  spaceId,
26302
- verificationMethod: session.verificationMethod,
26303
- jwk: session.jwk
26455
+ verificationMethod: captured.verificationMethod,
26456
+ jwk: captured.jwk
26304
26457
  },
26305
26458
  delegation,
26306
26459
  operations: this.permissionOperations(delegatedEntries, spaceId),
@@ -26629,7 +26782,19 @@ var _TinyCloudNode = class _TinyCloudNode {
26629
26782
  "delegateTo requires a non-empty permissions array"
26630
26783
  );
26631
26784
  }
26632
- const expandedEntries = this.expandPermissionEntries(permissions);
26785
+ const expandedEntries = expandDelegationPermissionEntries(permissions);
26786
+ const namedKeyEntries = expandedEntries.filter((entry) => entry.service === ENCRYPTION_PERMISSION_SERVICE2 && entry.path.includes("/"));
26787
+ if (namedKeyEntries.length > 0) {
26788
+ if (expandedEntries.some((entry) => entry.service === ENCRYPTION_PERMISSION_SERVICE2 && !entry.path.includes("/"))) {
26789
+ throw new ManifestValidationError2("named-key delegation cannot include bare-network permissions");
26790
+ }
26791
+ if (options?.forceWalletSign) {
26792
+ throw new ManifestValidationError2("named-key delegation requires a signed session grant");
26793
+ }
26794
+ const granted = this.projectSignedRecapCapabilities(session.siwe);
26795
+ const { subset, missing } = this.signedCapabilitySubset(namedKeyEntries, granted);
26796
+ if (!subset) throw new PermissionNotInManifestError(missing, granted);
26797
+ }
26633
26798
  const now = /* @__PURE__ */ new Date();
26634
26799
  const expiryMs = resolveExpiryMs(options?.expiry);
26635
26800
  const expirationTime = new Date(now.getTime() + expiryMs);
@@ -28179,7 +28344,7 @@ var FileSessionStorage = class {
28179
28344
  };
28180
28345
 
28181
28346
  // src/authorization/openKeyBridge.ts
28182
- function wireOpenKeyAuthorize(openkey) {
28347
+ function wireOpenKeyAuthorize(openkey, opts) {
28183
28348
  return async (input) => {
28184
28349
  const result = await openkey.authorizeTinyCloud({
28185
28350
  protocolVersion: 1,
@@ -28190,7 +28355,7 @@ function wireOpenKeyAuthorize(openkey) {
28190
28355
  // Forward the presentation envelope verbatim — the OpenKey SDK
28191
28356
  // validates and size-bounds it before use.
28192
28357
  presentation: input.presentation
28193
- });
28358
+ }, opts);
28194
28359
  if (result.protocolVersion !== 1) {
28195
28360
  throw new Error(
28196
28361
  `wireOpenKeyAuthorize: OpenKey returned unsupported protocolVersion ${result.protocolVersion}`
@@ -28232,7 +28397,7 @@ import {
28232
28397
  CaveatedDelegationUnsupportedError as CaveatedDelegationUnsupportedError3,
28233
28398
  PermissionNotInManifestError as PermissionNotInManifestError2,
28234
28399
  SessionExpiredError as SessionExpiredError2,
28235
- ManifestValidationError as ManifestValidationError2,
28400
+ ManifestValidationError as ManifestValidationError3,
28236
28401
  composeManifestRequest as composeManifestRequest2,
28237
28402
  resolveManifest as resolveManifest2,
28238
28403
  validateManifest,
@@ -29377,7 +29542,8 @@ var SqliteReplicaHandle = class {
29377
29542
  options.signal.addEventListener("abort", onAbort, { once: true });
29378
29543
  const engine = new (__privateGet(this, _replica)).Replica({
29379
29544
  store: __privateGet(this, _store),
29380
- transportFor
29545
+ transportFor,
29546
+ ...this.spec.contentFetch === void 0 ? {} : { contentFetch: this.spec.contentFetch }
29381
29547
  });
29382
29548
  const running = engine.sync({ signal: abort.signal });
29383
29549
  const registration = { promise: running, abort: () => abort.abort() };
@@ -30896,7 +31062,7 @@ export {
30896
31062
  InvalidRestoredSessionError,
30897
31063
  KVService4 as KVService,
30898
31064
  MAX_SECRET_SCOPE_LENGTH,
30899
- ManifestValidationError2 as ManifestValidationError,
31065
+ ManifestValidationError3 as ManifestValidationError,
30900
31066
  MemorySessionStorage,
30901
31067
  NETWORK_NAME_PATTERN,
30902
31068
  NetworkIdError,
@@ -30993,6 +31159,7 @@ export {
30993
31159
  hexDecode,
30994
31160
  hexEncode,
30995
31161
  installTinyCloudDebugGlobals,
31162
+ isAppKeyHostBound,
30996
31163
  isCapabilitySubset4 as isCapabilitySubset,
30997
31164
  isEvmAddress,
30998
31165
  isNetworkId,