@tinycloud/node-sdk 3.11.0 → 3.12.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NodeUserAuthorization-BtoDI9in.d.cts +900 -0
- package/dist/NodeUserAuthorization-BtoDI9in.d.ts +900 -0
- package/dist/{TinyCloudNode-BlNcvo1c.d.ts → TinyCloudNode-C24728N_.d.cts} +30 -874
- package/dist/{TinyCloudNode-CnVaWnAX.d.cts → TinyCloudNode-DLrINr98.d.ts} +30 -874
- package/dist/{WasmKeyProvider-BKCPRC-c.d.cts → WasmKeyProvider-OA0LqmTg.d.cts} +2 -0
- package/dist/{WasmKeyProvider-BKCPRC-c.d.ts → WasmKeyProvider-OA0LqmTg.d.ts} +2 -0
- package/dist/{authority-DHIk5QvV.d.ts → authority-BQN2Z3st.d.ts} +1 -1
- package/dist/{authority-B2SLx27M.d.cts → authority-DDdheOL6.d.cts} +1 -1
- package/dist/core.cjs +179 -100
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +6 -5
- package/dist/core.d.ts +6 -5
- package/dist/core.js +180 -101
- 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-Ckc3UETl.d.cts → delegation-BQbAuKad.d.cts} +1 -1
- package/dist/{delegation-Ckc3UETl.d.ts → delegation-BQbAuKad.d.ts} +1 -1
- package/dist/encryption-keys.d.cts +3 -2
- package/dist/encryption-keys.d.ts +3 -2
- package/dist/index.cjs +179 -100
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +180 -101
- package/dist/index.js.map +1 -1
- package/dist/replication/authority.d.cts +4 -3
- package/dist/replication/authority.d.ts +4 -3
- package/dist/space-hosting.cjs +141 -0
- package/dist/space-hosting.cjs.map +1 -0
- package/dist/space-hosting.d.cts +69 -0
- package/dist/space-hosting.d.ts +69 -0
- package/dist/space-hosting.js +115 -0
- package/dist/space-hosting.js.map +1 -0
- package/package.json +11 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
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, i as isAppKeyHostBound } from './WasmKeyProvider-
|
|
4
|
-
export {
|
|
3
|
+
export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider, i as isAppKeyHostBound } from './WasmKeyProvider-OA0LqmTg.cjs';
|
|
4
|
+
export { N as NodeEventEmitterStrategy, a as NodeUserAuthorization, e as NodeUserAuthorizationAuthorizeFn, b as NodeUserAuthorizationConfig, f as OpenKeyAuthorizationResultV1, g as OpenKeyAuthorizeInput, O as OpenKeyAuthorizeTinyCloud, h as OpenKeyBridgeInput, P as PreparedOpenKeyAuthorization, c as SignStrategy, S as SpaceHosting, d as defaultSignStrategy, w as wireOpenKeyAuthorize } from './NodeUserAuthorization-BtoDI9in.cjs';
|
|
5
|
+
export { A as ACCEPTED_MARKER_VERSIONS, h as BOOTSTRAP_COMPLETION_MARKER_KEY, i as BOOTSTRAP_COMPLETION_MARKER_VERSION, j as BootstrapCompletionMarker, B as BootstrapWarning, C as CreateOwnerDelegationParams, D as DelegateToOptions, a as DelegateToResult, b as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, O as OwnerDelegationReceipt, k as RestorableSession, R as RuntimePermissionGrantOptions, S as SecretPermissionHint, c as SecretReadInput, d as SecretReadResult, T as TinyCloudNode, e as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, f as UnifiedOwnerRootReceipt, g as UnsupportedSessionRestoreError } from './TinyCloudNode-C24728N_.cjs';
|
|
5
6
|
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,
|
|
7
|
+
export { A as AuthDelegationArtifact, f as AuthRequestArtifact, C as CompactRuntimeDelegationInput, D as DelegationAuthority, P as PortableDelegation, g as RUNTIME_DELEGATION_REJECTIONS, h as RuntimeDelegationActivator, R as RuntimeDelegationRejectedError, a as RuntimeDelegationRejection, S as SessionGrantProof, V as ValidatedRuntimeDelegation, e 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-BQbAuKad.cjs';
|
|
7
8
|
import { KVReplicaStorage } from '@tinycloud/sdk-services';
|
|
8
9
|
import { ProfileReplicaPurge } from '@tinycloud/sdk-services/kv/replication';
|
|
9
10
|
export { ProfileReplicaDeferredToken, ProfileReplicaPurge } from '@tinycloud/sdk-services/kv/replication';
|
|
10
|
-
import '@tinycloud/sdk-services/encryption/named-keys';
|
|
11
11
|
import 'events';
|
|
12
|
+
import '@tinycloud/sdk-services/encryption/named-keys';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Private key signer for Node.js environments.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
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, i as isAppKeyHostBound } from './WasmKeyProvider-
|
|
4
|
-
export {
|
|
3
|
+
export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider, i as isAppKeyHostBound } from './WasmKeyProvider-OA0LqmTg.js';
|
|
4
|
+
export { N as NodeEventEmitterStrategy, a as NodeUserAuthorization, e as NodeUserAuthorizationAuthorizeFn, b as NodeUserAuthorizationConfig, f as OpenKeyAuthorizationResultV1, g as OpenKeyAuthorizeInput, O as OpenKeyAuthorizeTinyCloud, h as OpenKeyBridgeInput, P as PreparedOpenKeyAuthorization, c as SignStrategy, S as SpaceHosting, d as defaultSignStrategy, w as wireOpenKeyAuthorize } from './NodeUserAuthorization-BtoDI9in.js';
|
|
5
|
+
export { A as ACCEPTED_MARKER_VERSIONS, h as BOOTSTRAP_COMPLETION_MARKER_KEY, i as BOOTSTRAP_COMPLETION_MARKER_VERSION, j as BootstrapCompletionMarker, B as BootstrapWarning, C as CreateOwnerDelegationParams, D as DelegateToOptions, a as DelegateToResult, b as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, O as OwnerDelegationReceipt, k as RestorableSession, R as RuntimePermissionGrantOptions, S as SecretPermissionHint, c as SecretReadInput, d as SecretReadResult, T as TinyCloudNode, e as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, f as UnifiedOwnerRootReceipt, g as UnsupportedSessionRestoreError } from './TinyCloudNode-DLrINr98.js';
|
|
5
6
|
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,
|
|
7
|
+
export { A as AuthDelegationArtifact, f as AuthRequestArtifact, C as CompactRuntimeDelegationInput, D as DelegationAuthority, P as PortableDelegation, g as RUNTIME_DELEGATION_REJECTIONS, h as RuntimeDelegationActivator, R as RuntimeDelegationRejectedError, a as RuntimeDelegationRejection, S as SessionGrantProof, V as ValidatedRuntimeDelegation, e 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-BQbAuKad.js';
|
|
7
8
|
import { KVReplicaStorage } from '@tinycloud/sdk-services';
|
|
8
9
|
import { ProfileReplicaPurge } from '@tinycloud/sdk-services/kv/replication';
|
|
9
10
|
export { ProfileReplicaDeferredToken, ProfileReplicaPurge } from '@tinycloud/sdk-services/kv/replication';
|
|
10
|
-
import '@tinycloud/sdk-services/encryption/named-keys';
|
|
11
11
|
import 'events';
|
|
12
|
+
import '@tinycloud/sdk-services/encryption/named-keys';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Private key signer for Node.js environments.
|
package/dist/index.js
CHANGED
|
@@ -18970,6 +18970,18 @@ var MemorySessionStorage = class {
|
|
|
18970
18970
|
}
|
|
18971
18971
|
};
|
|
18972
18972
|
|
|
18973
|
+
// src/storage/clearPersistedSessionIfOwn.ts
|
|
18974
|
+
async function clearPersistedSessionIfOwn(storage, address, ownSignature) {
|
|
18975
|
+
if (ownSignature !== void 0) {
|
|
18976
|
+
try {
|
|
18977
|
+
const stored = await storage.load(address);
|
|
18978
|
+
if (stored !== null && stored.signature !== ownSignature) return;
|
|
18979
|
+
} catch {
|
|
18980
|
+
}
|
|
18981
|
+
}
|
|
18982
|
+
await storage.clear(address);
|
|
18983
|
+
}
|
|
18984
|
+
|
|
18973
18985
|
// src/authorization/NodeUserAuthorization.ts
|
|
18974
18986
|
function assertMaxExpiresAt(value) {
|
|
18975
18987
|
if (value === void 0 || typeof value === "function") return;
|
|
@@ -19063,6 +19075,8 @@ var NodeUserAuthorization = class {
|
|
|
19063
19075
|
* delegation lists them: the node answers a repeat with empty lists.
|
|
19064
19076
|
*/
|
|
19065
19077
|
this._lastActivationActivatedSpaceIds = [];
|
|
19078
|
+
/** See {@link spaceHosting}. Written only from node answers. */
|
|
19079
|
+
this._spaceHosting = "unknown";
|
|
19066
19080
|
this.wasm = config.wasmBindings;
|
|
19067
19081
|
this.signer = config.signer;
|
|
19068
19082
|
this.signStrategy = config.signStrategy ?? defaultSignStrategy;
|
|
@@ -19222,6 +19236,7 @@ var NodeUserAuthorization = class {
|
|
|
19222
19236
|
this.registryVerdict = void 0;
|
|
19223
19237
|
this._lastActivationSkippedSpaceIds = [];
|
|
19224
19238
|
this._lastActivationActivatedSpaceIds = [];
|
|
19239
|
+
this._spaceHosting = "unknown";
|
|
19225
19240
|
if (!session) {
|
|
19226
19241
|
this._session = void 0;
|
|
19227
19242
|
this._tinyCloudSession = void 0;
|
|
@@ -19362,6 +19377,18 @@ var NodeUserAuthorization = class {
|
|
|
19362
19377
|
get lastActivationActivatedSpaceIds() {
|
|
19363
19378
|
return [...this._lastActivationActivatedSpaceIds];
|
|
19364
19379
|
}
|
|
19380
|
+
/**
|
|
19381
|
+
* The node's last answer for whether this session's primary space is hosted:
|
|
19382
|
+
* recorded from the sign-in activation, or by {@link noteSpaceHosting}.
|
|
19383
|
+
* `unknown` until one of them answers, and after a restore.
|
|
19384
|
+
*/
|
|
19385
|
+
get spaceHosting() {
|
|
19386
|
+
return this._spaceHosting;
|
|
19387
|
+
}
|
|
19388
|
+
/** @internal Record the hosting probe's answer for the primary space. */
|
|
19389
|
+
noteSpaceHosting(hosting) {
|
|
19390
|
+
this._spaceHosting = hosting;
|
|
19391
|
+
}
|
|
19365
19392
|
/**
|
|
19366
19393
|
* Compute the `abilities` map the WASM `prepareSession` call should
|
|
19367
19394
|
* see at sign-in time.
|
|
@@ -19822,103 +19849,55 @@ var NodeUserAuthorization = class {
|
|
|
19822
19849
|
this._tinyCloudSession.delegationHeader
|
|
19823
19850
|
);
|
|
19824
19851
|
this.recordActivationSkippedSpaces(result, primarySpaceId);
|
|
19852
|
+
if (!result.success && result.status !== 404) {
|
|
19853
|
+
throw Object.assign(
|
|
19854
|
+
new Error(`Failed to activate session: ${describeHostFailure(result)}`),
|
|
19855
|
+
{ cause: result }
|
|
19856
|
+
);
|
|
19857
|
+
}
|
|
19858
|
+
await this.ensurePrimarySpaceHosted(this._spaceHosting);
|
|
19859
|
+
}
|
|
19860
|
+
/**
|
|
19861
|
+
* The create step of {@link ensureSpaceExists}: given the node's answer for
|
|
19862
|
+
* the primary space, host it through the space creation handler when it is
|
|
19863
|
+
* `not-hosted`. Any other answer, and a missing handler, change nothing. The
|
|
19864
|
+
* caller supplies the answer (sign-in's activation, or the hosting probe);
|
|
19865
|
+
* an empty activation list is never one.
|
|
19866
|
+
*
|
|
19867
|
+
* @throws Error if the creation handler fails or times out, or hosting fails
|
|
19868
|
+
*/
|
|
19869
|
+
async ensurePrimarySpaceHosted(hosting) {
|
|
19870
|
+
if (hosting !== "not-hosted") {
|
|
19871
|
+
return;
|
|
19872
|
+
}
|
|
19873
|
+
const session = this._tinyCloudSession;
|
|
19874
|
+
if (!session) {
|
|
19875
|
+
throw new Error("Must be signed in to host the primary space");
|
|
19876
|
+
}
|
|
19825
19877
|
const handler = this.spaceCreationHandler ?? (this.autoCreateSpace ? new AutoApproveSpaceCreationHandler() : void 0);
|
|
19878
|
+
if (!handler) {
|
|
19879
|
+
return;
|
|
19880
|
+
}
|
|
19881
|
+
await this.ensureTinyCloudHosts();
|
|
19882
|
+
const host = this.primaryTinyCloudHost;
|
|
19883
|
+
const primarySpaceId = session.spaceId;
|
|
19826
19884
|
const creationContext = {
|
|
19827
19885
|
spaceId: primarySpaceId,
|
|
19828
19886
|
address: this._address,
|
|
19829
19887
|
chainId: this._chainId,
|
|
19830
19888
|
host
|
|
19831
19889
|
};
|
|
19832
|
-
|
|
19833
|
-
|
|
19834
|
-
|
|
19835
|
-
|
|
19836
|
-
|
|
19837
|
-
|
|
19838
|
-
|
|
19839
|
-
|
|
19840
|
-
|
|
19841
|
-
|
|
19842
|
-
|
|
19843
|
-
return;
|
|
19844
|
-
}
|
|
19845
|
-
try {
|
|
19846
|
-
const created = await this.hostSpace();
|
|
19847
|
-
if (!created.success) {
|
|
19848
|
-
const err2 = Object.assign(
|
|
19849
|
-
new Error(`Failed to create space ${primarySpaceId}: ${describeHostFailure(created)}`),
|
|
19850
|
-
{ cause: created }
|
|
19851
|
-
);
|
|
19852
|
-
throw err2;
|
|
19853
|
-
}
|
|
19854
|
-
} catch (error) {
|
|
19855
|
-
handler.onSpaceCreationFailed?.(
|
|
19856
|
-
creationContext,
|
|
19857
|
-
error instanceof Error ? error : new Error(String(error))
|
|
19858
|
-
);
|
|
19859
|
-
throw error;
|
|
19860
|
-
}
|
|
19861
|
-
await new Promise((resolve2) => setTimeout(resolve2, 100));
|
|
19862
|
-
const retryResult = await activateSessionWithHost(
|
|
19863
|
-
host,
|
|
19864
|
-
this._tinyCloudSession.delegationHeader
|
|
19865
|
-
);
|
|
19866
|
-
if (!retryResult.success) {
|
|
19867
|
-
const err2 = Object.assign(
|
|
19868
|
-
new Error(`Failed to activate session after creating space: ${describeHostFailure(retryResult)}`),
|
|
19869
|
-
{ cause: retryResult }
|
|
19870
|
-
);
|
|
19871
|
-
handler.onSpaceCreationFailed?.(creationContext, err2);
|
|
19872
|
-
throw err2;
|
|
19873
|
-
}
|
|
19874
|
-
handler.onSpaceCreated?.(creationContext);
|
|
19875
|
-
return;
|
|
19876
|
-
}
|
|
19877
|
-
if (result.status === 404) {
|
|
19878
|
-
if (!handler) {
|
|
19879
|
-
return;
|
|
19880
|
-
}
|
|
19881
|
-
await this.guardSpaceCreation(handler, creationContext);
|
|
19882
|
-
const confirmed = await handler.confirmSpaceCreation(creationContext);
|
|
19883
|
-
if (!confirmed) {
|
|
19884
|
-
return;
|
|
19885
|
-
}
|
|
19886
|
-
try {
|
|
19887
|
-
const created = await this.hostSpace();
|
|
19888
|
-
if (!created.success) {
|
|
19889
|
-
const err2 = Object.assign(
|
|
19890
|
-
new Error(`Failed to create space ${primarySpaceId}: ${describeHostFailure(created)}`),
|
|
19891
|
-
{ cause: created }
|
|
19892
|
-
);
|
|
19893
|
-
throw err2;
|
|
19894
|
-
}
|
|
19895
|
-
} catch (error) {
|
|
19896
|
-
handler.onSpaceCreationFailed?.(
|
|
19897
|
-
creationContext,
|
|
19898
|
-
error instanceof Error ? error : new Error(String(error))
|
|
19899
|
-
);
|
|
19900
|
-
throw error;
|
|
19901
|
-
}
|
|
19902
|
-
await new Promise((resolve2) => setTimeout(resolve2, 100));
|
|
19903
|
-
const retryResult = await activateSessionWithHost(
|
|
19904
|
-
host,
|
|
19905
|
-
this._tinyCloudSession.delegationHeader
|
|
19906
|
-
);
|
|
19907
|
-
if (!retryResult.success) {
|
|
19908
|
-
const err2 = Object.assign(
|
|
19909
|
-
new Error(`Failed to activate session after creating space: ${describeHostFailure(retryResult)}`),
|
|
19910
|
-
{ cause: retryResult }
|
|
19911
|
-
);
|
|
19912
|
-
handler.onSpaceCreationFailed?.(creationContext, err2);
|
|
19913
|
-
throw err2;
|
|
19914
|
-
}
|
|
19915
|
-
handler.onSpaceCreated?.(creationContext);
|
|
19916
|
-
return;
|
|
19917
|
-
}
|
|
19918
|
-
throw Object.assign(
|
|
19919
|
-
new Error(`Failed to activate session: ${describeHostFailure(result)}`),
|
|
19920
|
-
{ cause: result }
|
|
19921
|
-
);
|
|
19890
|
+
const { createPrimarySpace } = await import("./space-hosting.js");
|
|
19891
|
+
await createPrimarySpace({
|
|
19892
|
+
handler,
|
|
19893
|
+
context: creationContext,
|
|
19894
|
+
guard: () => this.guardSpaceCreation(handler, creationContext),
|
|
19895
|
+
host: () => this.hostSpace(primarySpaceId),
|
|
19896
|
+
onHosted: () => {
|
|
19897
|
+
this._spaceHosting = "hosted";
|
|
19898
|
+
},
|
|
19899
|
+
activate: () => activateSessionWithHost(host, session.delegationHeader)
|
|
19900
|
+
});
|
|
19922
19901
|
}
|
|
19923
19902
|
/** {@link assertMayCreateSpace}, reporting a refusal to the creation handler before rethrowing it. */
|
|
19924
19903
|
async guardSpaceCreation(handler, context) {
|
|
@@ -19934,10 +19913,12 @@ var NodeUserAuthorization = class {
|
|
|
19934
19913
|
if (result.success) {
|
|
19935
19914
|
this._lastActivationSkippedSpaceIds = result.skipped ?? [];
|
|
19936
19915
|
this._lastActivationActivatedSpaceIds = result.activated ?? [];
|
|
19916
|
+
this._spaceHosting = this._lastActivationSkippedSpaceIds.includes(primarySpaceId) ? "not-hosted" : this._lastActivationActivatedSpaceIds.includes(primarySpaceId) ? "hosted" : "unknown";
|
|
19937
19917
|
return;
|
|
19938
19918
|
}
|
|
19939
19919
|
this._lastActivationActivatedSpaceIds = [];
|
|
19940
19920
|
this._lastActivationSkippedSpaceIds = result.status === 404 ? [primarySpaceId] : [];
|
|
19921
|
+
this._spaceHosting = result.status === 404 ? "not-hosted" : "unknown";
|
|
19941
19922
|
}
|
|
19942
19923
|
async createBootstrapSession(options) {
|
|
19943
19924
|
refuseCaveated(options.capabilityRequest.manifests);
|
|
@@ -20786,12 +20767,13 @@ var NodeUserAuthorization = class {
|
|
|
20786
20767
|
};
|
|
20787
20768
|
}
|
|
20788
20769
|
/**
|
|
20789
|
-
* Clear persisted session data.
|
|
20770
|
+
* Clear persisted session data. With `ownSignature`, a stored session that provably has a different
|
|
20771
|
+
* signature (a newer sign-in for the same address) is left alone.
|
|
20790
20772
|
*/
|
|
20791
|
-
async clearPersistedSession(address) {
|
|
20773
|
+
async clearPersistedSession(address, ownSignature) {
|
|
20792
20774
|
const targetAddress = address ?? this._address;
|
|
20793
20775
|
if (targetAddress) {
|
|
20794
|
-
await this.sessionStorage
|
|
20776
|
+
await clearPersistedSessionIfOwn(this.sessionStorage, targetAddress, ownSignature);
|
|
20795
20777
|
}
|
|
20796
20778
|
}
|
|
20797
20779
|
/**
|
|
@@ -21890,6 +21872,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21890
21872
|
* hosting is confirmed against the session that was active at the time.
|
|
21891
21873
|
*/
|
|
21892
21874
|
this.confirmedHostedSpaceIds = /* @__PURE__ */ new Set();
|
|
21875
|
+
/** The primary space's hosting answer when no authorization layer holds it (a session-only restore). */
|
|
21876
|
+
this._restoredSpaceHosting = "unknown";
|
|
21893
21877
|
/**
|
|
21894
21878
|
* Owned space ids known to be hosted for the current session: the sign-in
|
|
21895
21879
|
* activation listed them as `activated`, or this session hosted them. Unlike
|
|
@@ -22228,6 +22212,84 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22228
22212
|
));
|
|
22229
22213
|
}
|
|
22230
22214
|
}
|
|
22215
|
+
/**
|
|
22216
|
+
* Whether the TinyCloud node hosts the primary space (the default) or a named
|
|
22217
|
+
* or full-id space: `"hosted"`, `"not-hosted"`, or `"unknown"` when the node
|
|
22218
|
+
* cannot say.
|
|
22219
|
+
*
|
|
22220
|
+
* Sends one authorized read the session already holds on that space (a kv
|
|
22221
|
+
* list under a granted prefix, else kv metadata, `tinycloud.space/info`, or
|
|
22222
|
+
* a kv get of a key that does not exist), signed for that space. A session
|
|
22223
|
+
* with no such read sends nothing and answers `unknown`. A 401/403 registers
|
|
22224
|
+
* the session delegation with the node once and asks again once. Network
|
|
22225
|
+
* failures, 5xx and a 5 s timeout answer `unknown`; this never throws.
|
|
22226
|
+
*
|
|
22227
|
+
* `hosted` is remembered for the session and `not-hosted` never is. The
|
|
22228
|
+
* answer for the primary space is also what {@link spaceHosting} reports; a
|
|
22229
|
+
* `unknown` answer leaves the previous one in place.
|
|
22230
|
+
*/
|
|
22231
|
+
async checkSpaceHosting(space) {
|
|
22232
|
+
try {
|
|
22233
|
+
return await this.probeSpaceHosting(space);
|
|
22234
|
+
} catch {
|
|
22235
|
+
return "unknown";
|
|
22236
|
+
}
|
|
22237
|
+
}
|
|
22238
|
+
/**
|
|
22239
|
+
* The node's last answer for the primary space: recorded at sign-in from the
|
|
22240
|
+
* activation, or by {@link checkSpaceHosting}. `unknown` after a restore until
|
|
22241
|
+
* something asks.
|
|
22242
|
+
*/
|
|
22243
|
+
get spaceHosting() {
|
|
22244
|
+
return this.auth ? this.auth.spaceHosting : this._restoredSpaceHosting;
|
|
22245
|
+
}
|
|
22246
|
+
async probeSpaceHosting(space) {
|
|
22247
|
+
const context = this._serviceContext;
|
|
22248
|
+
const session = context?.session;
|
|
22249
|
+
const host = context?.hosts[0];
|
|
22250
|
+
if (!context || !session || !host) {
|
|
22251
|
+
return "unknown";
|
|
22252
|
+
}
|
|
22253
|
+
const spaceId = space === void 0 ? session.spaceId : space.startsWith("tinycloud:") ? space : this.ownedSpaceId(space);
|
|
22254
|
+
const graph = this._serviceGraph;
|
|
22255
|
+
const epoch = this.sessionEpoch;
|
|
22256
|
+
const assertCurrent = () => {
|
|
22257
|
+
graph.assertActive();
|
|
22258
|
+
if (epoch !== this.sessionEpoch || graph !== this._serviceGraph || this._serviceContext !== context) {
|
|
22259
|
+
throw new Error("The session changed during the hosting check.");
|
|
22260
|
+
}
|
|
22261
|
+
};
|
|
22262
|
+
const { askSpaceHosting } = await import("./space-hosting.js");
|
|
22263
|
+
assertCurrent();
|
|
22264
|
+
this.pruneExpiredRuntimePermissionGrants();
|
|
22265
|
+
const primary = this.currentTinyCloudSession();
|
|
22266
|
+
const answer = await askSpaceHosting({
|
|
22267
|
+
spaceId,
|
|
22268
|
+
operations: [
|
|
22269
|
+
...this.runtimePermissionGrants.flatMap((grant) => grant.operations),
|
|
22270
|
+
...primary ? this.recapOperationsFromSession(primary) : []
|
|
22271
|
+
],
|
|
22272
|
+
covers: (granted, requested) => this.operationCovers(granted, requested),
|
|
22273
|
+
scope: context,
|
|
22274
|
+
host,
|
|
22275
|
+
fetch: unrecordedFetchOf(context),
|
|
22276
|
+
sign: (entries) => {
|
|
22277
|
+
assertCurrent();
|
|
22278
|
+
return graph.invokeAny({ ...session, spaceId }, entries);
|
|
22279
|
+
},
|
|
22280
|
+
// A session saved but never registered on this node is refused: it registers once.
|
|
22281
|
+
activate: (signal) => {
|
|
22282
|
+
assertCurrent();
|
|
22283
|
+
return activateSessionWithHost2(host, session.delegationHeader, AbortSignal.any([signal, graph.signal]));
|
|
22284
|
+
}
|
|
22285
|
+
});
|
|
22286
|
+
assertCurrent();
|
|
22287
|
+
if (answer !== "unknown" && this.spaceIdsEqual(spaceId, session.spaceId)) {
|
|
22288
|
+
if (this.auth) this.auth.noteSpaceHosting(answer);
|
|
22289
|
+
else this._restoredSpaceHosting = answer;
|
|
22290
|
+
}
|
|
22291
|
+
return answer;
|
|
22292
|
+
}
|
|
22231
22293
|
get nodeFeatures() {
|
|
22232
22294
|
return this.auth?.nodeFeatures ?? this._restoredNodeFeatures ?? [];
|
|
22233
22295
|
}
|
|
@@ -22596,6 +22658,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22596
22658
|
const leavingChainId = this._chainId;
|
|
22597
22659
|
const leavingPrincipal = this.replicaSessionPrincipal ?? (leavingAddress ? pkhDid2(leavingAddress, leavingChainId) : void 0);
|
|
22598
22660
|
const leavingAuth = this.auth;
|
|
22661
|
+
const leavingSignature = leavingAuth?.tinyCloudSession?.signature ?? this._restoredTcSession?.signature;
|
|
22599
22662
|
const leavingContext = this._serviceContext;
|
|
22600
22663
|
let denied;
|
|
22601
22664
|
let erased;
|
|
@@ -22612,7 +22675,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22612
22675
|
if (denied) erased = await this.eraseReplicaLocalCopy("sign_out", denied.status);
|
|
22613
22676
|
} finally {
|
|
22614
22677
|
if (leavingAddress) {
|
|
22615
|
-
await (leavingAuth ? leavingAuth.clearPersistedSession(leavingAddress) : this.config.sessionStorage
|
|
22678
|
+
await (leavingAuth ? leavingAuth.clearPersistedSession(leavingAddress, leavingSignature) : this.config.sessionStorage && clearPersistedSessionIfOwn(this.config.sessionStorage, leavingAddress, leavingSignature));
|
|
22616
22679
|
}
|
|
22617
22680
|
}
|
|
22618
22681
|
}
|
|
@@ -22718,6 +22781,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22718
22781
|
this._spaceService = void 0;
|
|
22719
22782
|
this.runtimePermissionGrants = [];
|
|
22720
22783
|
this._recapOperationsCache = void 0;
|
|
22784
|
+
this._restoredSpaceHosting = "unknown";
|
|
22721
22785
|
this.confirmedHostedSpaceIds.clear();
|
|
22722
22786
|
this.hostedOwnedSpaceIds.clear();
|
|
22723
22787
|
this.cancelOwnedSpaceHosts();
|
|
@@ -22911,6 +22975,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22911
22975
|
const primarySession = this.currentTinyCloudSession();
|
|
22912
22976
|
if (primarySession) {
|
|
22913
22977
|
this.registerPrimarySessionGrant(primarySession);
|
|
22978
|
+
if (this.auth?.spaceHosting === "unknown") {
|
|
22979
|
+
await this.checkSpaceHosting();
|
|
22980
|
+
this.assertSessionEpoch(epoch, "Sign-in");
|
|
22981
|
+
}
|
|
22914
22982
|
}
|
|
22915
22983
|
const bootstrapped = await this.bootstrapAccountIfNeeded();
|
|
22916
22984
|
this.assertSessionEpoch(epoch, "Sign-in");
|
|
@@ -24290,6 +24358,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
24290
24358
|
this.tc = stagedGraph.core;
|
|
24291
24359
|
this._recapOperationsCache = stagedPrimary.cache;
|
|
24292
24360
|
this.runtimePermissionGrants = stagedPrimary.grants;
|
|
24361
|
+
this._restoredSpaceHosting = "unknown";
|
|
24293
24362
|
this.confirmedHostedSpaceIds.clear();
|
|
24294
24363
|
this.hostedOwnedSpaceIds.clear();
|
|
24295
24364
|
this.cancelOwnedSpaceHosts();
|
|
@@ -28348,7 +28417,7 @@ import {
|
|
|
28348
28417
|
|
|
28349
28418
|
// src/storage/FileSessionStorage.ts
|
|
28350
28419
|
import { validatePersistedSessionData } from "@tinycloud/sdk-core";
|
|
28351
|
-
import { readFileSync, writeFileSync, existsSync, mkdirSync, unlinkSync } from "fs";
|
|
28420
|
+
import { readFileSync, writeFileSync, existsSync, mkdirSync, renameSync, unlinkSync } from "fs";
|
|
28352
28421
|
import { join } from "path";
|
|
28353
28422
|
var FileSessionStorage = class {
|
|
28354
28423
|
/**
|
|
@@ -28389,10 +28458,22 @@ var FileSessionStorage = class {
|
|
|
28389
28458
|
async save(address, session) {
|
|
28390
28459
|
const filePath = this.getFilePath(address);
|
|
28391
28460
|
const data = JSON.stringify(session, null, 2);
|
|
28392
|
-
|
|
28461
|
+
const tempPath = `${filePath}.${process.pid}.${process.hrtime.bigint()}.tmp`;
|
|
28462
|
+
try {
|
|
28463
|
+
writeFileSync(tempPath, data, { mode: 384, flag: "wx" });
|
|
28464
|
+
renameSync(tempPath, filePath);
|
|
28465
|
+
} catch (error) {
|
|
28466
|
+
try {
|
|
28467
|
+
unlinkSync(tempPath);
|
|
28468
|
+
} catch {
|
|
28469
|
+
}
|
|
28470
|
+
throw error;
|
|
28471
|
+
}
|
|
28393
28472
|
}
|
|
28394
28473
|
/**
|
|
28395
28474
|
* Load a session for an address.
|
|
28475
|
+
*
|
|
28476
|
+
* Rejects when the file exists but cannot be read or parsed; the file is left in place.
|
|
28396
28477
|
*/
|
|
28397
28478
|
async load(address) {
|
|
28398
28479
|
const filePath = this.getFilePath(address);
|
|
@@ -28416,11 +28497,9 @@ var FileSessionStorage = class {
|
|
|
28416
28497
|
}
|
|
28417
28498
|
return session;
|
|
28418
28499
|
} catch (error) {
|
|
28419
|
-
|
|
28420
|
-
|
|
28421
|
-
|
|
28422
|
-
}
|
|
28423
|
-
return null;
|
|
28500
|
+
throw new Error(
|
|
28501
|
+
`Could not read session file ${filePath}: ${error}`
|
|
28502
|
+
);
|
|
28424
28503
|
}
|
|
28425
28504
|
}
|
|
28426
28505
|
/**
|