@tinycloud/node-sdk 3.8.0-beta.9 → 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.
- package/README.md +6 -0
- package/dist/{TinyCloudNode-jPL2UqH5.d.ts → TinyCloudNode-DaD5vJhL.d.cts} +38 -5
- package/dist/{TinyCloudNode-C0LgPzzJ.d.cts → TinyCloudNode-k3TbBwwj.d.ts} +38 -5
- package/dist/{WasmKeyProvider-5Ee7fcAw.d.cts → WasmKeyProvider-BKCPRC-c.d.cts} +21 -1
- package/dist/{WasmKeyProvider-5Ee7fcAw.d.ts → WasmKeyProvider-BKCPRC-c.d.ts} +21 -1
- package/dist/{authority-DvHTgPC4.d.ts → authority-C_fWaxAu.d.ts} +1 -1
- package/dist/{authority-Dkhr6n-f.d.cts → authority-DJdbZM6k.d.cts} +1 -1
- package/dist/core.cjs +238 -29
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +4 -4
- package/dist/core.d.ts +4 -4
- package/dist/core.js +239 -30
- package/dist/core.js.map +1 -1
- package/dist/credentials-core.d.cts +1 -1
- package/dist/credentials-core.d.ts +1 -1
- package/dist/credentials.d.cts +1 -1
- package/dist/credentials.d.ts +1 -1
- package/dist/{delegation-0LKZkmP2.d.cts → delegation-Ckc3UETl.d.cts} +1 -1
- package/dist/{delegation-0LKZkmP2.d.ts → delegation-Ckc3UETl.d.ts} +1 -1
- package/dist/encryption-keys.d.cts +2 -2
- package/dist/encryption-keys.d.ts +2 -2
- package/dist/index.cjs +188 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +193 -31
- package/dist/index.js.map +1 -1
- package/dist/replication/authority.d.cts +3 -3
- package/dist/replication/authority.d.ts +3 -3
- package/dist/share-receive.cjs +775 -0
- package/dist/share-receive.cjs.map +1 -0
- package/dist/share-receive.d.cts +32 -0
- package/dist/share-receive.d.ts +32 -0
- package/dist/share-receive.js +777 -0
- package/dist/share-receive.js.map +1 -0
- 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-
|
|
4
|
-
export { A as ACCEPTED_MARKER_VERSIONS,
|
|
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,
|
|
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-
|
|
4
|
-
export { A as ACCEPTED_MARKER_VERSIONS,
|
|
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,
|
|
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
|
@@ -18690,6 +18690,7 @@ function deserializeDelegation(data) {
|
|
|
18690
18690
|
|
|
18691
18691
|
// src/TinyCloudNode.ts
|
|
18692
18692
|
import { generateNonce, SiweMessage as SiweMessage3 } from "siwe";
|
|
18693
|
+
import { didKeyFromEd25519PublicKey } from "@tinycloud/share-envelope";
|
|
18693
18694
|
|
|
18694
18695
|
// src/replication/module-registry.ts
|
|
18695
18696
|
var nodeLoaders;
|
|
@@ -18738,10 +18739,13 @@ import {
|
|
|
18738
18739
|
ENCRYPTION_PERMISSION_SERVICE as ENCRYPTION_PERMISSION_SERVICE2,
|
|
18739
18740
|
CaveatedDelegationUnsupportedError as CaveatedDelegationUnsupportedError2,
|
|
18740
18741
|
PermissionNotInManifestError,
|
|
18742
|
+
ManifestValidationError as ManifestValidationError2,
|
|
18741
18743
|
SessionExpiredError,
|
|
18742
18744
|
canonicalizeRecapCaveats as canonicalizeRecapCaveats2,
|
|
18743
18745
|
recapCaveatsEqual as recapCaveatsEqual2,
|
|
18744
18746
|
expandPermissionEntries as expandPermissionEntriesCore,
|
|
18747
|
+
expandRuntimePermissionEntries,
|
|
18748
|
+
expandDelegationPermissionEntries,
|
|
18745
18749
|
isCapabilitySubset as isCapabilitySubset2,
|
|
18746
18750
|
isExplicitOnlyAction,
|
|
18747
18751
|
parseRecapCapabilities,
|
|
@@ -18772,6 +18776,7 @@ import {
|
|
|
18772
18776
|
withoutShareLink,
|
|
18773
18777
|
verifyEip191MessageSignature,
|
|
18774
18778
|
signCompactUcanRootAuthorization,
|
|
18779
|
+
signCompactUcanAuthorization,
|
|
18775
18780
|
markDelegationTerminal,
|
|
18776
18781
|
isStorageFullError,
|
|
18777
18782
|
STORAGE_FULL_MESSAGE,
|
|
@@ -18855,6 +18860,18 @@ function appKeyHostBinding(domain, appId) {
|
|
|
18855
18860
|
const reversed = labels.reverse().join(".");
|
|
18856
18861
|
return appId === reversed || appId.startsWith(`${reversed}.`);
|
|
18857
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
|
+
}
|
|
18858
18875
|
|
|
18859
18876
|
// src/authorization/NodeUserAuthorization.ts
|
|
18860
18877
|
init_authority_sign_in();
|
|
@@ -19015,6 +19032,7 @@ function cloneAbilitiesMap(actions) {
|
|
|
19015
19032
|
var NodeUserAuthorization = class {
|
|
19016
19033
|
constructor(config) {
|
|
19017
19034
|
this.activeSessionKeyId = "default";
|
|
19035
|
+
this.preparedSessionCounter = 0;
|
|
19018
19036
|
/** Incremented by resetSession; a sign-in started earlier publishes nothing. */
|
|
19019
19037
|
this.sessionGeneration = 0;
|
|
19020
19038
|
/**
|
|
@@ -19597,7 +19615,8 @@ var NodeUserAuthorization = class {
|
|
|
19597
19615
|
return true;
|
|
19598
19616
|
}
|
|
19599
19617
|
const parsed = entry.path.includes("/") ? parseEncryptionResource(entry.path) : { ...parseNetworkId(entry.path), kind: "network" };
|
|
19600
|
-
|
|
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) {
|
|
19601
19620
|
throw new ManifestValidationError("named keys go in manifest.keys");
|
|
19602
19621
|
}
|
|
19603
19622
|
for (const action of entry.actions) {
|
|
@@ -19640,8 +19659,7 @@ var NodeUserAuthorization = class {
|
|
|
19640
19659
|
/**
|
|
19641
19660
|
* Build SIWE overrides from the top-level nonce and siweConfig.
|
|
19642
19661
|
* - Top-level `nonce` is seeded first so `siweConfig.nonce` wins if both are set.
|
|
19643
|
-
* -
|
|
19644
|
-
* - resources are appended to the default resources
|
|
19662
|
+
* - resources are inserted after WASM preparation, before the final ReCap
|
|
19645
19663
|
* - uri triggers a warning (overwriting delegation target)
|
|
19646
19664
|
* - all other fields override directly
|
|
19647
19665
|
* - per-call nonce overrides siweConfig.nonce when provided
|
|
@@ -19659,9 +19677,6 @@ var NodeUserAuthorization = class {
|
|
|
19659
19677
|
if (statement) {
|
|
19660
19678
|
overrides.statement = this.statement ? `${statement} ${this.statement}` : statement;
|
|
19661
19679
|
}
|
|
19662
|
-
if (resources && resources.length > 0) {
|
|
19663
|
-
overrides.resources = resources;
|
|
19664
|
-
}
|
|
19665
19680
|
if (uri) {
|
|
19666
19681
|
console.warn(
|
|
19667
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."
|
|
@@ -19673,6 +19688,29 @@ var NodeUserAuthorization = class {
|
|
|
19673
19688
|
}
|
|
19674
19689
|
return overrides;
|
|
19675
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
|
+
}
|
|
19676
19714
|
/**
|
|
19677
19715
|
* Add an extension to the authorization flow.
|
|
19678
19716
|
*/
|
|
@@ -19920,7 +19958,7 @@ var NodeUserAuthorization = class {
|
|
|
19920
19958
|
spaceAbilities[spaceId] = resourceCapabilitiesToAbilitiesMap(resources);
|
|
19921
19959
|
}
|
|
19922
19960
|
const abilities = spaceAbilities[options.spaceId] ?? resourceCapabilitiesToAbilitiesMap([]);
|
|
19923
|
-
const prepared = this.
|
|
19961
|
+
const prepared = this.prepareSessionWithResources({
|
|
19924
19962
|
abilities,
|
|
19925
19963
|
spaceAbilities,
|
|
19926
19964
|
...options.rawAbilities !== void 0 ? { rawAbilities: options.rawAbilities } : {},
|
|
@@ -20001,8 +20039,8 @@ var NodeUserAuthorization = class {
|
|
|
20001
20039
|
this.assertSignInCurrent(generation);
|
|
20002
20040
|
await this.refreshNamedKeyFeatureForSignIn(address, chainId);
|
|
20003
20041
|
this.assertSignInCurrent(generation);
|
|
20004
|
-
const keyId = `session-${Date.now()}`;
|
|
20005
|
-
this.sessionManager.
|
|
20042
|
+
const keyId = `session-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
20043
|
+
this.sessionManager.createSessionKey(keyId);
|
|
20006
20044
|
this.activeSessionKeyId = keyId;
|
|
20007
20045
|
const jwkString = this.sessionManager.jwk(keyId);
|
|
20008
20046
|
if (!jwkString) {
|
|
@@ -20013,7 +20051,7 @@ var NodeUserAuthorization = class {
|
|
|
20013
20051
|
const spaceId = capabilityPlan.spaceId;
|
|
20014
20052
|
const now = /* @__PURE__ */ new Date();
|
|
20015
20053
|
const expirationTime = new Date(now.getTime() + this.sessionExpirationMs);
|
|
20016
|
-
const prepared = this.
|
|
20054
|
+
const prepared = this.prepareSessionWithResources({
|
|
20017
20055
|
abilities: capabilityPlan.abilities,
|
|
20018
20056
|
...capabilityPlan.spaceAbilities !== void 0 ? { spaceAbilities: capabilityPlan.spaceAbilities } : {},
|
|
20019
20057
|
...capabilityPlan.rawAbilities !== void 0 ? { rawAbilities: capabilityPlan.rawAbilities } : {},
|
|
@@ -20148,9 +20186,8 @@ var NodeUserAuthorization = class {
|
|
|
20148
20186
|
const address = canonicalizeAddress(await this.signer.getAddress());
|
|
20149
20187
|
const chainId = await this.signer.getChainId();
|
|
20150
20188
|
await this.refreshNamedKeyFeatureForSignIn(address, chainId);
|
|
20151
|
-
const keyId = `session-${Date.now()}`;
|
|
20152
|
-
this.sessionManager.
|
|
20153
|
-
this.activeSessionKeyId = keyId;
|
|
20189
|
+
const keyId = `openkey-session-${Date.now()}-${++this.preparedSessionCounter}`;
|
|
20190
|
+
this.sessionManager.createSessionKey(keyId);
|
|
20154
20191
|
const jwkString = this.sessionManager.jwk(keyId);
|
|
20155
20192
|
if (!jwkString) {
|
|
20156
20193
|
throw new Error("Failed to create session key");
|
|
@@ -20160,7 +20197,7 @@ var NodeUserAuthorization = class {
|
|
|
20160
20197
|
const spaceId = capabilityPlan.spaceId;
|
|
20161
20198
|
const now = /* @__PURE__ */ new Date();
|
|
20162
20199
|
const expirationTime = new Date(now.getTime() + this.sessionExpirationMs);
|
|
20163
|
-
const prepared = this.
|
|
20200
|
+
const prepared = this.prepareSessionWithResources({
|
|
20164
20201
|
abilities: capabilityPlan.abilities,
|
|
20165
20202
|
...capabilityPlan.spaceAbilities !== void 0 ? { spaceAbilities: capabilityPlan.spaceAbilities } : {},
|
|
20166
20203
|
...capabilityPlan.rawAbilities !== void 0 ? { rawAbilities: capabilityPlan.rawAbilities } : {},
|
|
@@ -20231,6 +20268,7 @@ var NodeUserAuthorization = class {
|
|
|
20231
20268
|
await this.sessionStorage.save(address, persistedData);
|
|
20232
20269
|
this._session = clientSession;
|
|
20233
20270
|
this._tinyCloudSession = tinyCloudSession;
|
|
20271
|
+
this.activeSessionKeyId = keyId;
|
|
20234
20272
|
this._address = address;
|
|
20235
20273
|
this._chainId = chainId;
|
|
20236
20274
|
await this.refreshNodeInfo();
|
|
@@ -20277,6 +20315,11 @@ var NodeUserAuthorization = class {
|
|
|
20277
20315
|
* @param options Optional overrides for the OpenKey request.
|
|
20278
20316
|
*/
|
|
20279
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) {
|
|
20280
20323
|
refuseCaveated(this.getCapabilityRequest()?.manifests);
|
|
20281
20324
|
if (options?.host !== void 0) {
|
|
20282
20325
|
const overrideHost = options.host.trim();
|
|
@@ -20288,7 +20331,7 @@ var NodeUserAuthorization = class {
|
|
|
20288
20331
|
const signingAddress = canonicalizeAddress(await this.signer.getAddress());
|
|
20289
20332
|
const signingChainId = await this.signer.getChainId();
|
|
20290
20333
|
await this.resolveTinyCloudHostsForSignIn(signingAddress, signingChainId);
|
|
20291
|
-
const { prepared, keyId, jwk } = await this.prepareSessionForSigning();
|
|
20334
|
+
const { prepared, keyId, jwk, address, chainId } = await this.prepareSessionForSigning();
|
|
20292
20335
|
const presentation = this.buildPresentationEnvelope(options?.reason);
|
|
20293
20336
|
const hostHint = this.primaryTinyCloudHost;
|
|
20294
20337
|
const originalRequest = {
|
|
@@ -20300,12 +20343,32 @@ var NodeUserAuthorization = class {
|
|
|
20300
20343
|
keyId: options?.openkeyKeyId,
|
|
20301
20344
|
presentation
|
|
20302
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;
|
|
20303
20366
|
let result;
|
|
20304
20367
|
let signed2;
|
|
20305
20368
|
let signature2;
|
|
20306
20369
|
for (let attempt = 0; ; ) {
|
|
20307
20370
|
try {
|
|
20308
|
-
result ?? (result = await
|
|
20371
|
+
result ?? (result = await authorization);
|
|
20309
20372
|
signed2 = await this.verifyOpenKeyResult(result, prepared);
|
|
20310
20373
|
signature2 = result.signature;
|
|
20311
20374
|
break;
|
|
@@ -21714,6 +21777,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21714
21777
|
constructor(config = {}) {
|
|
21715
21778
|
this.signer = null;
|
|
21716
21779
|
this.auth = null;
|
|
21780
|
+
this.consumedOpenKeyPendings = /* @__PURE__ */ new WeakSet();
|
|
21717
21781
|
this.tc = null;
|
|
21718
21782
|
this._chainId = 1;
|
|
21719
21783
|
this.replicaPurgeFailedHandlers = /* @__PURE__ */ new Set();
|
|
@@ -22654,6 +22718,37 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22654
22718
|
}
|
|
22655
22719
|
await this.signInWith(() => this.auth.signInWithOpenKey(authorizeFn, options));
|
|
22656
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
|
+
}
|
|
22657
22752
|
async signInWith(performSignIn) {
|
|
22658
22753
|
refuseCaveated(this.auth?.capabilityRequest?.manifests);
|
|
22659
22754
|
const epoch = this.sessionEpoch;
|
|
@@ -24295,6 +24390,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24295
24390
|
invoke: graph.invoke,
|
|
24296
24391
|
invokeAny: graph.invokeAny,
|
|
24297
24392
|
signOwnerRevocation: this.signer ? (cid) => this.signOwnerRevocation(cid) : void 0,
|
|
24393
|
+
sessionInvocationSigner: this.sessionInvocationSignerFor(input.serviceSession),
|
|
24298
24394
|
fetch: graph.fetch
|
|
24299
24395
|
});
|
|
24300
24396
|
const keyProvider = new WasmKeyProvider({ sessionManager: input.manager });
|
|
@@ -24510,6 +24606,31 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24510
24606
|
if (session === void 0) throw new Error("Not signed in. Call signIn() first.");
|
|
24511
24607
|
return signBytesWithJwk(bytes, session.jwk);
|
|
24512
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
|
+
}
|
|
24513
24634
|
/** Author a proofless Policy/v3 owner root with the authenticated holder key. */
|
|
24514
24635
|
async createUnifiedOwnerRoot(input) {
|
|
24515
24636
|
const ownerDid = this.credentialHolderDid;
|
|
@@ -25044,7 +25165,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25044
25165
|
graph.assertActive();
|
|
25045
25166
|
const signed2 = await this.signRawNetworkAuthorization({
|
|
25046
25167
|
targetNode: input.targetNode,
|
|
25047
|
-
networkId: input.networkId
|
|
25168
|
+
networkId: input.body.keyPath === void 0 ? input.networkId : `${input.networkId}/${input.body.keyPath}`,
|
|
25048
25169
|
action: DECRYPT_ACTION2,
|
|
25049
25170
|
facts: input.facts
|
|
25050
25171
|
}, { graph, session });
|
|
@@ -25217,6 +25338,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
25217
25338
|
invoke: graph.invoke,
|
|
25218
25339
|
invokeAny: graph.invokeAny,
|
|
25219
25340
|
signOwnerRevocation: this.signer ? (cid) => this.signOwnerRevocation(cid) : void 0,
|
|
25341
|
+
sessionInvocationSigner: this.sessionInvocationSignerFor(serviceSession),
|
|
25220
25342
|
fetch: graph.fetch
|
|
25221
25343
|
});
|
|
25222
25344
|
this._spaceService = new SpaceService({
|
|
@@ -26000,7 +26122,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26000
26122
|
if (!session || !Array.isArray(permissions) || permissions.length === 0) {
|
|
26001
26123
|
return false;
|
|
26002
26124
|
}
|
|
26003
|
-
const expanded =
|
|
26125
|
+
const expanded = expandRuntimePermissionEntries(permissions, pkhDid2(session.address, session.chainId));
|
|
26004
26126
|
if (this.sessionCoversPermissionEntries(session, expanded)) {
|
|
26005
26127
|
return true;
|
|
26006
26128
|
}
|
|
@@ -26020,7 +26142,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26020
26142
|
if (!session || !Array.isArray(permissions) || permissions.length === 0) {
|
|
26021
26143
|
return [];
|
|
26022
26144
|
}
|
|
26023
|
-
const expanded =
|
|
26145
|
+
const expanded = expandRuntimePermissionEntries(permissions, pkhDid2(session.address, session.chainId));
|
|
26024
26146
|
return this.findRuntimeGrantsForPermissionEntries(expanded, session).map(
|
|
26025
26147
|
(grant) => grant.delegation
|
|
26026
26148
|
);
|
|
@@ -26195,7 +26317,28 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26195
26317
|
throw new SessionExpiredError(sessionExpiry);
|
|
26196
26318
|
}
|
|
26197
26319
|
}
|
|
26198
|
-
const expanded =
|
|
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
|
+
}
|
|
26199
26342
|
if (this.sessionCoversPermissionEntries(session, expanded)) {
|
|
26200
26343
|
return [];
|
|
26201
26344
|
}
|
|
@@ -26245,13 +26388,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26245
26388
|
return this.wasmBindings.prepareSession({
|
|
26246
26389
|
abilities,
|
|
26247
26390
|
...rawForDelegation.length > 0 ? { rawAbilities: this.permissionsToRawAbilities(rawForDelegation) } : {},
|
|
26248
|
-
address: this.wasmBindings.ensureEip55(
|
|
26249
|
-
chainId:
|
|
26391
|
+
address: this.wasmBindings.ensureEip55(captured.address),
|
|
26392
|
+
chainId: captured.chainId,
|
|
26250
26393
|
domain: this.siweDomain,
|
|
26251
26394
|
issuedAt: now.toISOString(),
|
|
26252
26395
|
expirationTime: expiresAt.toISOString(),
|
|
26253
26396
|
spaceId,
|
|
26254
|
-
jwk:
|
|
26397
|
+
jwk: captured.jwk
|
|
26255
26398
|
});
|
|
26256
26399
|
} catch (error) {
|
|
26257
26400
|
if (rawForDelegation.some((entry) => this.isRawRevocationPermissionEntry(entry)) && /invalid ReCap resource URI/i.test(error instanceof Error ? error.message : String(error))) {
|
|
@@ -26263,8 +26406,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26263
26406
|
throw error;
|
|
26264
26407
|
}
|
|
26265
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?.();
|
|
26266
26413
|
const signature2 = await this.signer.signMessage(prepared.siwe);
|
|
26267
26414
|
graph.assertActive();
|
|
26415
|
+
assertCapturedKey?.();
|
|
26268
26416
|
const delegatedSession = this.wasmBindings.completeSessionSetup({
|
|
26269
26417
|
...prepared,
|
|
26270
26418
|
signature: signature2
|
|
@@ -26293,18 +26441,19 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26293
26441
|
delegatedSession,
|
|
26294
26442
|
delegatedEntries,
|
|
26295
26443
|
spaceId,
|
|
26296
|
-
|
|
26444
|
+
captured,
|
|
26297
26445
|
expiresAt,
|
|
26298
26446
|
{ siwe: prepared.siwe, signature: signature2 }
|
|
26299
26447
|
);
|
|
26300
26448
|
graph.assertActive();
|
|
26449
|
+
assertCapturedKey?.();
|
|
26301
26450
|
this.runtimePermissionGrants.push({
|
|
26302
26451
|
session: {
|
|
26303
26452
|
delegationHeader: delegatedSession.delegationHeader,
|
|
26304
26453
|
delegationCid: delegatedSession.delegationCid,
|
|
26305
26454
|
spaceId,
|
|
26306
|
-
verificationMethod:
|
|
26307
|
-
jwk:
|
|
26455
|
+
verificationMethod: captured.verificationMethod,
|
|
26456
|
+
jwk: captured.jwk
|
|
26308
26457
|
},
|
|
26309
26458
|
delegation,
|
|
26310
26459
|
operations: this.permissionOperations(delegatedEntries, spaceId),
|
|
@@ -26633,7 +26782,19 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26633
26782
|
"delegateTo requires a non-empty permissions array"
|
|
26634
26783
|
);
|
|
26635
26784
|
}
|
|
26636
|
-
const expandedEntries =
|
|
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
|
+
}
|
|
26637
26798
|
const now = /* @__PURE__ */ new Date();
|
|
26638
26799
|
const expiryMs = resolveExpiryMs(options?.expiry);
|
|
26639
26800
|
const expirationTime = new Date(now.getTime() + expiryMs);
|
|
@@ -28183,7 +28344,7 @@ var FileSessionStorage = class {
|
|
|
28183
28344
|
};
|
|
28184
28345
|
|
|
28185
28346
|
// src/authorization/openKeyBridge.ts
|
|
28186
|
-
function wireOpenKeyAuthorize(openkey) {
|
|
28347
|
+
function wireOpenKeyAuthorize(openkey, opts) {
|
|
28187
28348
|
return async (input) => {
|
|
28188
28349
|
const result = await openkey.authorizeTinyCloud({
|
|
28189
28350
|
protocolVersion: 1,
|
|
@@ -28194,7 +28355,7 @@ function wireOpenKeyAuthorize(openkey) {
|
|
|
28194
28355
|
// Forward the presentation envelope verbatim — the OpenKey SDK
|
|
28195
28356
|
// validates and size-bounds it before use.
|
|
28196
28357
|
presentation: input.presentation
|
|
28197
|
-
});
|
|
28358
|
+
}, opts);
|
|
28198
28359
|
if (result.protocolVersion !== 1) {
|
|
28199
28360
|
throw new Error(
|
|
28200
28361
|
`wireOpenKeyAuthorize: OpenKey returned unsupported protocolVersion ${result.protocolVersion}`
|
|
@@ -28236,7 +28397,7 @@ import {
|
|
|
28236
28397
|
CaveatedDelegationUnsupportedError as CaveatedDelegationUnsupportedError3,
|
|
28237
28398
|
PermissionNotInManifestError as PermissionNotInManifestError2,
|
|
28238
28399
|
SessionExpiredError as SessionExpiredError2,
|
|
28239
|
-
ManifestValidationError as
|
|
28400
|
+
ManifestValidationError as ManifestValidationError3,
|
|
28240
28401
|
composeManifestRequest as composeManifestRequest2,
|
|
28241
28402
|
resolveManifest as resolveManifest2,
|
|
28242
28403
|
validateManifest,
|
|
@@ -30901,7 +31062,7 @@ export {
|
|
|
30901
31062
|
InvalidRestoredSessionError,
|
|
30902
31063
|
KVService4 as KVService,
|
|
30903
31064
|
MAX_SECRET_SCOPE_LENGTH,
|
|
30904
|
-
|
|
31065
|
+
ManifestValidationError3 as ManifestValidationError,
|
|
30905
31066
|
MemorySessionStorage,
|
|
30906
31067
|
NETWORK_NAME_PATTERN,
|
|
30907
31068
|
NetworkIdError,
|
|
@@ -30998,6 +31159,7 @@ export {
|
|
|
30998
31159
|
hexDecode,
|
|
30999
31160
|
hexEncode,
|
|
31000
31161
|
installTinyCloudDebugGlobals,
|
|
31162
|
+
isAppKeyHostBound,
|
|
31001
31163
|
isCapabilitySubset4 as isCapabilitySubset,
|
|
31002
31164
|
isEvmAddress,
|
|
31003
31165
|
isNetworkId,
|