@tinycloud/node-sdk 3.11.1-beta.0 → 3.12.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/NodeUserAuthorization-B05Wjjpb.d.cts +900 -0
  2. package/dist/NodeUserAuthorization-B05Wjjpb.d.ts +900 -0
  3. package/dist/{TinyCloudNode-AUotFGzy.d.ts → TinyCloudNode-6_IumWu0.d.cts} +32 -875
  4. package/dist/{TinyCloudNode-BmpjkpWR.d.cts → TinyCloudNode-CEFGtSWn.d.ts} +32 -875
  5. package/dist/{authority-BYSEyjDI.d.cts → authority-DODDXxoP.d.cts} +1 -1
  6. package/dist/{authority-dRnJD4iL.d.ts → authority-DXpnuId1.d.ts} +1 -1
  7. package/dist/core.cjs +182 -109
  8. package/dist/core.cjs.map +1 -1
  9. package/dist/core.d.cts +5 -4
  10. package/dist/core.d.ts +5 -4
  11. package/dist/core.js +182 -109
  12. package/dist/core.js.map +1 -1
  13. package/dist/credentials-core.d.cts +1 -1
  14. package/dist/credentials-core.d.ts +1 -1
  15. package/dist/credentials.d.cts +1 -1
  16. package/dist/credentials.d.ts +1 -1
  17. package/dist/{delegation-Ckc3UETl.d.cts → delegation-BQbAuKad.d.cts} +1 -1
  18. package/dist/{delegation-Ckc3UETl.d.ts → delegation-BQbAuKad.d.ts} +1 -1
  19. package/dist/encryption-keys.d.cts +3 -2
  20. package/dist/encryption-keys.d.ts +3 -2
  21. package/dist/index.cjs +182 -109
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +4 -3
  24. package/dist/index.d.ts +4 -3
  25. package/dist/index.js +182 -109
  26. package/dist/index.js.map +1 -1
  27. package/dist/replication/authority.d.cts +4 -3
  28. package/dist/replication/authority.d.ts +4 -3
  29. package/dist/space-hosting.cjs +183 -0
  30. package/dist/space-hosting.cjs.map +1 -0
  31. package/dist/space-hosting.d.cts +84 -0
  32. package/dist/space-hosting.d.ts +84 -0
  33. package/dist/space-hosting.js +157 -0
  34. package/dist/space-hosting.js.map +1 -0
  35. package/package.json +11 -1
package/dist/core.d.cts CHANGED
@@ -1,15 +1,16 @@
1
1
  import { ReplicationOptions, Manifest, PermissionEntry } from '@tinycloud/sdk-core';
2
2
  export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, AuthorityRefusal, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, CallbackStrategy, CanonicalAddress, CanonicalParsedNetworkId, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, CaveatedDelegationUnsupportedError, ClientSession, ColumnInfo, ComposeManifestOptions, ComposedManifestRequest, CreateDelegationParams, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DataVaultConfig, DataVaultService, DatabaseHandle, DelegateReceivedShareParams, DelegatedShareAccess, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DidCacheKeyOptions, DidEqualsOptions, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, EncodedShareData, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISecretsService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IdentityParseError, IngestOptions, InvokeFunction, JWK, KVBatchReadResponse, KVCreateSignedReadUrlOptions, KVListPage, KVReadThrough, KVReplicaHandle, KVReplicaSpec, KVReplicaStorage, KVReplicationController, KVReplicationDeps, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, LocalGetResult, LocalListResult, LocalReadMeta, LocalReplicaStatus, LocalSyncResult, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, ParsedSecretCatalogKey, PendingWriteRecord, PendingWriteState, PendingWriteStore, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PinnedKey, PkhDidParts, PrefixedKVService, ProtocolMismatchError, PurgeTarget, QueryOptions, QueryResponse, ReceiveOptions, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ReplicaAuthorityState, ReplicaCoverage, ReplicaDevice, ReplicaGatedHandle, ReplicaGrantInfo, ReplicaInspectedStatus, ReplicaState, ReplicaStatusEntry, ReplicationAuthority, ReplicationControl, ReplicationEvent, ReplicationIdentity, ReplicationOptions, ReplicationPurgeReport, ReplicationReason, ReplicationScheduler, ResolvedCapabilities, ResolvedDelegate, ResolvedReplicationOptions, ResolvedSecretPath, ResourceCapability, SECRET_NAME_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, SecretCatalogEntry, SecretPayload, SecretScopeOptions, SecretsError, SecretsService, ServiceContext, ServiceContextConfig, ServiceSession, SessionExpiredError, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignInOptions, SignRequest, SignResponse, SilentNotificationHandler, Space, SpaceAbilitiesMap, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, TableInfo, TelemetryConfig, TelemetryEventHandler, TinyCloud, TinyCloudConfig, TinyCloudDebugEnableOptions, TinyCloudDebugEvent, TinyCloudDebugLevel, TinyCloudDebugLogger, TinyCloudDebugTimer, TinyCloudSession, UnsupportedFeatureError, VAULT_PERMISSION_SERVICE, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultNetworkReadResult, VaultPublicSpaceKVActions, VaultPutOptions, VersionCheckError, ViewInfo, WasmVaultFunctions, addressStorageKey, buildSpaceUri, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, canonicalizeSecretScope, checkNodeInfo, clearTinyCloudDebugLogs, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, createVaultCrypto, defaultSpaceCreationHandler, didCacheKey, didEquals, disableTinyCloudDebug, enableTinyCloudDebug, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, isCapabilitySubset, isEvmAddress, loadManifest, makePkhSpaceId, makePublicSpaceId, parseCanonicalNetworkId, parseExpiry, parsePkhDid, parseSecretCatalogKey, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, tinyCloudDebugLogger, validateManifest } from '@tinycloud/sdk-core';
3
3
  import { _ as __gated_network } from './gated-network-BEF2XSTC.cjs';
4
- import { _ as __authority } from './authority-BYSEyjDI.cjs';
4
+ import { _ as __authority } from './authority-DODDXxoP.cjs';
5
5
  import { _ as __runtime } from './runtime-mRhSu-vJ.cjs';
6
6
  import { ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
7
7
  export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider, i as isAppKeyHostBound } from './WasmKeyProvider-OA0LqmTg.cjs';
8
- export { B as BootstrapWarning, C as CreateOwnerDelegationParams, D as DelegateToOptions, a as DelegateToResult, b as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, N as NodeEventEmitterStrategy, c as NodeUserAuthorization, d as NodeUserAuthorizationConfig, O as OpenKeyAuthorizeTinyCloud, e as OwnerDelegationReceipt, P as PreparedOpenKeyAuthorization, 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-BmpjkpWR.cjs';
9
- export { C as CompactRuntimeDelegationInput, P as PortableDelegation, R as RuntimeDelegationRejectedError, a as RuntimeDelegationRejection, V as ValidatedRuntimeDelegation, b as activateCompactRuntimeDelegation, c as activateValidatedRuntimeDelegation, d as deserializeDelegation, s as serializeDelegation } from './delegation-Ckc3UETl.cjs';
8
+ export { N as NodeEventEmitterStrategy, a as NodeUserAuthorization, b as NodeUserAuthorizationConfig, O as OpenKeyAuthorizeTinyCloud, P as PreparedOpenKeyAuthorization, c as SignStrategy, S as SpaceHosting, d as defaultSignStrategy, w as wireOpenKeyAuthorize } from './NodeUserAuthorization-B05Wjjpb.cjs';
9
+ export { B as BootstrapWarning, C as CreateOwnerDelegationParams, D as DelegateToOptions, a as DelegateToResult, b as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, O as OwnerDelegationReceipt, 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-6_IumWu0.cjs';
10
+ export { C as CompactRuntimeDelegationInput, P as PortableDelegation, R as RuntimeDelegationRejectedError, a as RuntimeDelegationRejection, V as ValidatedRuntimeDelegation, b as activateCompactRuntimeDelegation, c as activateValidatedRuntimeDelegation, d as deserializeDelegation, s as serializeDelegation } from './delegation-BQbAuKad.cjs';
10
11
  import '@tinycloud/sdk-services';
11
- import '@tinycloud/sdk-services/encryption/named-keys';
12
12
  import 'events';
13
+ import '@tinycloud/sdk-services/encryption/named-keys';
13
14
 
14
15
  /**
15
16
  * The `@tinycloud/replica/profile-gate` members the node adapter uses, typed structurally: node-sdk
package/dist/core.d.ts CHANGED
@@ -1,15 +1,16 @@
1
1
  import { ReplicationOptions, Manifest, PermissionEntry } from '@tinycloud/sdk-core';
2
2
  export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, AuthorityRefusal, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, CallbackStrategy, CanonicalAddress, CanonicalParsedNetworkId, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, CaveatedDelegationUnsupportedError, ClientSession, ColumnInfo, ComposeManifestOptions, ComposedManifestRequest, CreateDelegationParams, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DataVaultConfig, DataVaultService, DatabaseHandle, DelegateReceivedShareParams, DelegatedShareAccess, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DidCacheKeyOptions, DidEqualsOptions, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, EncodedShareData, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISecretsService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IdentityParseError, IngestOptions, InvokeFunction, JWK, KVBatchReadResponse, KVCreateSignedReadUrlOptions, KVListPage, KVReadThrough, KVReplicaHandle, KVReplicaSpec, KVReplicaStorage, KVReplicationController, KVReplicationDeps, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, LocalGetResult, LocalListResult, LocalReadMeta, LocalReplicaStatus, LocalSyncResult, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, ParsedSecretCatalogKey, PendingWriteRecord, PendingWriteState, PendingWriteStore, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PinnedKey, PkhDidParts, PrefixedKVService, ProtocolMismatchError, PurgeTarget, QueryOptions, QueryResponse, ReceiveOptions, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ReplicaAuthorityState, ReplicaCoverage, ReplicaDevice, ReplicaGatedHandle, ReplicaGrantInfo, ReplicaInspectedStatus, ReplicaState, ReplicaStatusEntry, ReplicationAuthority, ReplicationControl, ReplicationEvent, ReplicationIdentity, ReplicationOptions, ReplicationPurgeReport, ReplicationReason, ReplicationScheduler, ResolvedCapabilities, ResolvedDelegate, ResolvedReplicationOptions, ResolvedSecretPath, ResourceCapability, SECRET_NAME_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, SecretCatalogEntry, SecretPayload, SecretScopeOptions, SecretsError, SecretsService, ServiceContext, ServiceContextConfig, ServiceSession, SessionExpiredError, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignInOptions, SignRequest, SignResponse, SilentNotificationHandler, Space, SpaceAbilitiesMap, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, TableInfo, TelemetryConfig, TelemetryEventHandler, TinyCloud, TinyCloudConfig, TinyCloudDebugEnableOptions, TinyCloudDebugEvent, TinyCloudDebugLevel, TinyCloudDebugLogger, TinyCloudDebugTimer, TinyCloudSession, UnsupportedFeatureError, VAULT_PERMISSION_SERVICE, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultNetworkReadResult, VaultPublicSpaceKVActions, VaultPutOptions, VersionCheckError, ViewInfo, WasmVaultFunctions, addressStorageKey, buildSpaceUri, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, canonicalizeSecretScope, checkNodeInfo, clearTinyCloudDebugLogs, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, createVaultCrypto, defaultSpaceCreationHandler, didCacheKey, didEquals, disableTinyCloudDebug, enableTinyCloudDebug, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, isCapabilitySubset, isEvmAddress, loadManifest, makePkhSpaceId, makePublicSpaceId, parseCanonicalNetworkId, parseExpiry, parsePkhDid, parseSecretCatalogKey, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, tinyCloudDebugLogger, validateManifest } from '@tinycloud/sdk-core';
3
3
  import { _ as __gated_network } from './gated-network-BEF2XSTC.js';
4
- import { _ as __authority } from './authority-dRnJD4iL.js';
4
+ import { _ as __authority } from './authority-DXpnuId1.js';
5
5
  import { _ as __runtime } from './runtime-CO4VXnPq.js';
6
6
  import { ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
7
7
  export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider, i as isAppKeyHostBound } from './WasmKeyProvider-OA0LqmTg.js';
8
- export { B as BootstrapWarning, C as CreateOwnerDelegationParams, D as DelegateToOptions, a as DelegateToResult, b as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, N as NodeEventEmitterStrategy, c as NodeUserAuthorization, d as NodeUserAuthorizationConfig, O as OpenKeyAuthorizeTinyCloud, e as OwnerDelegationReceipt, P as PreparedOpenKeyAuthorization, 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-AUotFGzy.js';
9
- export { C as CompactRuntimeDelegationInput, P as PortableDelegation, R as RuntimeDelegationRejectedError, a as RuntimeDelegationRejection, V as ValidatedRuntimeDelegation, b as activateCompactRuntimeDelegation, c as activateValidatedRuntimeDelegation, d as deserializeDelegation, s as serializeDelegation } from './delegation-Ckc3UETl.js';
8
+ export { N as NodeEventEmitterStrategy, a as NodeUserAuthorization, b as NodeUserAuthorizationConfig, O as OpenKeyAuthorizeTinyCloud, P as PreparedOpenKeyAuthorization, c as SignStrategy, S as SpaceHosting, d as defaultSignStrategy, w as wireOpenKeyAuthorize } from './NodeUserAuthorization-B05Wjjpb.js';
9
+ export { B as BootstrapWarning, C as CreateOwnerDelegationParams, D as DelegateToOptions, a as DelegateToResult, b as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, O as OwnerDelegationReceipt, 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-CEFGtSWn.js';
10
+ export { C as CompactRuntimeDelegationInput, P as PortableDelegation, R as RuntimeDelegationRejectedError, a as RuntimeDelegationRejection, V as ValidatedRuntimeDelegation, b as activateCompactRuntimeDelegation, c as activateValidatedRuntimeDelegation, d as deserializeDelegation, s as serializeDelegation } from './delegation-BQbAuKad.js';
10
11
  import '@tinycloud/sdk-services';
11
- import '@tinycloud/sdk-services/encryption/named-keys';
12
12
  import 'events';
13
+ import '@tinycloud/sdk-services/encryption/named-keys';
13
14
 
14
15
  /**
15
16
  * The `@tinycloud/replica/profile-gate` members the node adapter uses, typed structurally: node-sdk
package/dist/core.js CHANGED
@@ -500,6 +500,8 @@ var NodeUserAuthorization = class {
500
500
  * delegation lists them: the node answers a repeat with empty lists.
501
501
  */
502
502
  this._lastActivationActivatedSpaceIds = [];
503
+ /** See {@link spaceHosting}. Written only from node answers. */
504
+ this._spaceHosting = "unknown";
503
505
  this.wasm = config.wasmBindings;
504
506
  this.signer = config.signer;
505
507
  this.signStrategy = config.signStrategy ?? defaultSignStrategy;
@@ -659,6 +661,7 @@ var NodeUserAuthorization = class {
659
661
  this.registryVerdict = void 0;
660
662
  this._lastActivationSkippedSpaceIds = [];
661
663
  this._lastActivationActivatedSpaceIds = [];
664
+ this._spaceHosting = "unknown";
662
665
  if (!session) {
663
666
  this._session = void 0;
664
667
  this._tinyCloudSession = void 0;
@@ -799,6 +802,18 @@ var NodeUserAuthorization = class {
799
802
  get lastActivationActivatedSpaceIds() {
800
803
  return [...this._lastActivationActivatedSpaceIds];
801
804
  }
805
+ /**
806
+ * The node's last answer for whether this session's primary space is hosted:
807
+ * recorded from the sign-in activation, or by {@link noteSpaceHosting}.
808
+ * `unknown` until one of them answers, and after a restore.
809
+ */
810
+ get spaceHosting() {
811
+ return this._spaceHosting;
812
+ }
813
+ /** @internal Record the hosting probe's answer for the primary space. */
814
+ noteSpaceHosting(hosting) {
815
+ this._spaceHosting = hosting;
816
+ }
802
817
  /**
803
818
  * Compute the `abilities` map the WASM `prepareSession` call should
804
819
  * see at sign-in time.
@@ -1178,23 +1193,35 @@ var NodeUserAuthorization = class {
1178
1193
  * Create the space on the TinyCloud server (host delegation).
1179
1194
  * This registers the user as the owner of the space.
1180
1195
  */
1181
- async hostSpace(targetSpaceId, purpose, signal) {
1182
- if (!this._tinyCloudSession || !this._address || !this._chainId) {
1196
+ async hostSpace(targetSpaceId, purpose, signal, assertCurrent, siweParameters) {
1197
+ const context = typeof targetSpaceId === "object" ? targetSpaceId : void 0;
1198
+ const address = context?.address ?? this._address;
1199
+ const chainId = context?.chainId ?? this._chainId;
1200
+ if (!address || chainId === void 0 || !this._tinyCloudSession) {
1183
1201
  throw new Error("Must be signed in to host space");
1184
1202
  }
1203
+ const checkCurrent = () => {
1204
+ signal?.throwIfAborted();
1205
+ assertCurrent?.();
1206
+ };
1207
+ checkCurrent();
1185
1208
  await this.ensureTinyCloudHosts();
1186
- const host = this.primaryTinyCloudHost;
1187
- const spaceId = targetSpaceId ?? this._tinyCloudSession.spaceId;
1209
+ checkCurrent();
1210
+ const host = context?.host ?? this.primaryTinyCloudHost;
1211
+ const spaceId = context?.spaceId ?? (typeof targetSpaceId === "string" ? targetSpaceId : this._tinyCloudSession.spaceId);
1188
1212
  const peerId = await fetchPeerId(host, spaceId, signal);
1189
- const siwe = this.wasm.generateHostSIWEMessage({
1190
- address: this._address,
1191
- chainId: this._chainId,
1192
- domain: this.domain,
1193
- issuedAt: (/* @__PURE__ */ new Date()).toISOString(),
1194
- spaceId,
1195
- peerId
1196
- });
1197
- if (signal?.aborted) throw signal.reason;
1213
+ checkCurrent();
1214
+ const siwe = this.wasm.generateHostSIWEMessage(
1215
+ context && siweParameters ? siweParameters(peerId) : {
1216
+ address,
1217
+ chainId,
1218
+ domain: this.domain,
1219
+ issuedAt: (/* @__PURE__ */ new Date()).toISOString(),
1220
+ spaceId,
1221
+ peerId
1222
+ }
1223
+ );
1224
+ checkCurrent();
1198
1225
  const signing = this.signMessage(siwe, purpose);
1199
1226
  let signature;
1200
1227
  if (!signal) {
@@ -1213,8 +1240,9 @@ var NodeUserAuthorization = class {
1213
1240
  signal.removeEventListener("abort", onAbort);
1214
1241
  }
1215
1242
  }
1216
- if (signal?.aborted) throw signal.reason;
1243
+ checkCurrent();
1217
1244
  const headers = this.wasm.siweToDelegationHeaders({ siwe, signature });
1245
+ checkCurrent();
1218
1246
  return submitHostDelegation(host, headers, signal);
1219
1247
  }
1220
1248
  /**
@@ -1259,103 +1287,48 @@ var NodeUserAuthorization = class {
1259
1287
  this._tinyCloudSession.delegationHeader
1260
1288
  );
1261
1289
  this.recordActivationSkippedSpaces(result, primarySpaceId);
1262
- const handler = this.spaceCreationHandler ?? (this.autoCreateSpace ? new AutoApproveSpaceCreationHandler() : void 0);
1263
- const creationContext = {
1264
- spaceId: primarySpaceId,
1265
- address: this._address,
1266
- chainId: this._chainId,
1267
- host
1268
- };
1269
- if (result.success) {
1270
- const primarySkipped = result.skipped?.includes(primarySpaceId);
1271
- if (!primarySkipped) {
1272
- return;
1273
- }
1274
- if (!handler) {
1275
- return;
1276
- }
1277
- await this.guardSpaceCreation(handler, creationContext);
1278
- const confirmed = await handler.confirmSpaceCreation(creationContext);
1279
- if (!confirmed) {
1280
- return;
1281
- }
1282
- try {
1283
- const created = await this.hostSpace();
1284
- if (!created.success) {
1285
- const err2 = Object.assign(
1286
- new Error(`Failed to create space ${primarySpaceId}: ${describeHostFailure(created)}`),
1287
- { cause: created }
1288
- );
1289
- throw err2;
1290
- }
1291
- } catch (error) {
1292
- handler.onSpaceCreationFailed?.(
1293
- creationContext,
1294
- error instanceof Error ? error : new Error(String(error))
1295
- );
1296
- throw error;
1297
- }
1298
- await new Promise((resolve) => setTimeout(resolve, 100));
1299
- const retryResult = await activateSessionWithHost(
1300
- host,
1301
- this._tinyCloudSession.delegationHeader
1302
- );
1303
- if (!retryResult.success) {
1304
- const err2 = Object.assign(
1305
- new Error(`Failed to activate session after creating space: ${describeHostFailure(retryResult)}`),
1306
- { cause: retryResult }
1307
- );
1308
- handler.onSpaceCreationFailed?.(creationContext, err2);
1309
- throw err2;
1310
- }
1311
- handler.onSpaceCreated?.(creationContext);
1312
- return;
1313
- }
1314
- if (result.status === 404) {
1315
- if (!handler) {
1316
- return;
1317
- }
1318
- await this.guardSpaceCreation(handler, creationContext);
1319
- const confirmed = await handler.confirmSpaceCreation(creationContext);
1320
- if (!confirmed) {
1321
- return;
1322
- }
1323
- try {
1324
- const created = await this.hostSpace();
1325
- if (!created.success) {
1326
- const err2 = Object.assign(
1327
- new Error(`Failed to create space ${primarySpaceId}: ${describeHostFailure(created)}`),
1328
- { cause: created }
1329
- );
1330
- throw err2;
1331
- }
1332
- } catch (error) {
1333
- handler.onSpaceCreationFailed?.(
1334
- creationContext,
1335
- error instanceof Error ? error : new Error(String(error))
1336
- );
1337
- throw error;
1338
- }
1339
- await new Promise((resolve) => setTimeout(resolve, 100));
1340
- const retryResult = await activateSessionWithHost(
1341
- host,
1342
- this._tinyCloudSession.delegationHeader
1290
+ if (!result.success && result.status !== 404) {
1291
+ throw Object.assign(
1292
+ new Error(`Failed to activate session: ${describeHostFailure(result)}`),
1293
+ { cause: result }
1343
1294
  );
1344
- if (!retryResult.success) {
1345
- const err2 = Object.assign(
1346
- new Error(`Failed to activate session after creating space: ${describeHostFailure(retryResult)}`),
1347
- { cause: retryResult }
1348
- );
1349
- handler.onSpaceCreationFailed?.(creationContext, err2);
1350
- throw err2;
1351
- }
1352
- handler.onSpaceCreated?.(creationContext);
1353
- return;
1354
1295
  }
1355
- throw Object.assign(
1356
- new Error(`Failed to activate session: ${describeHostFailure(result)}`),
1357
- { cause: result }
1358
- );
1296
+ await this.ensurePrimarySpaceHosted(this._spaceHosting);
1297
+ }
1298
+ /**
1299
+ * The create step of {@link ensureSpaceExists}: given the node's answer for
1300
+ * the primary space, host it through the space creation handler when it is
1301
+ * `not-hosted`. Any other answer, and a missing handler, change nothing. The
1302
+ * caller supplies the answer (sign-in's activation, or the hosting probe);
1303
+ * an empty activation list is never one.
1304
+ *
1305
+ * @throws Error if the creation handler fails or times out, or hosting fails
1306
+ */
1307
+ async ensurePrimarySpaceHosted(hosting, signal) {
1308
+ const session = this._tinyCloudSession;
1309
+ if (hosting !== "not-hosted") return;
1310
+ if (!session) throw new Error("Must be signed in to host the primary space");
1311
+ const handler = this.spaceCreationHandler ?? (this.autoCreateSpace ? new AutoApproveSpaceCreationHandler() : void 0);
1312
+ if (!handler) return;
1313
+ const { createPrimarySpace } = await import("./space-hosting.js");
1314
+ await createPrimarySpace({
1315
+ handler,
1316
+ session,
1317
+ currentSession: () => this._tinyCloudSession,
1318
+ signerAddress: () => this.signer.getAddress(),
1319
+ resolveHost: async () => {
1320
+ await this.ensureTinyCloudHosts();
1321
+ return this.primaryTinyCloudHost;
1322
+ },
1323
+ domain: this.domain,
1324
+ guard: (context) => this.guardSpaceCreation(handler, context),
1325
+ host: (context, assertCurrent, siweParameters) => this.hostSpace(context, void 0, signal, assertCurrent, siweParameters),
1326
+ onHosted: () => {
1327
+ this._spaceHosting = "hosted";
1328
+ },
1329
+ activate: (context) => activateSessionWithHost(context.host, session.delegationHeader),
1330
+ signal
1331
+ });
1359
1332
  }
1360
1333
  /** {@link assertMayCreateSpace}, reporting a refusal to the creation handler before rethrowing it. */
1361
1334
  async guardSpaceCreation(handler, context) {
@@ -1371,10 +1344,12 @@ var NodeUserAuthorization = class {
1371
1344
  if (result.success) {
1372
1345
  this._lastActivationSkippedSpaceIds = result.skipped ?? [];
1373
1346
  this._lastActivationActivatedSpaceIds = result.activated ?? [];
1347
+ this._spaceHosting = this._lastActivationSkippedSpaceIds.includes(primarySpaceId) ? "not-hosted" : this._lastActivationActivatedSpaceIds.includes(primarySpaceId) ? "hosted" : "unknown";
1374
1348
  return;
1375
1349
  }
1376
1350
  this._lastActivationActivatedSpaceIds = [];
1377
1351
  this._lastActivationSkippedSpaceIds = result.status === 404 ? [primarySpaceId] : [];
1352
+ this._spaceHosting = result.status === 404 ? "not-hosted" : "unknown";
1378
1353
  }
1379
1354
  async createBootstrapSession(options) {
1380
1355
  refuseCaveated(options.capabilityRequest.manifests);
@@ -4116,6 +4091,8 @@ var _TinyCloudNode = class _TinyCloudNode {
4116
4091
  * hosting is confirmed against the session that was active at the time.
4117
4092
  */
4118
4093
  this.confirmedHostedSpaceIds = /* @__PURE__ */ new Set();
4094
+ /** The primary space's hosting answer when no authorization layer holds it (a session-only restore). */
4095
+ this._restoredSpaceHosting = "unknown";
4119
4096
  /**
4120
4097
  * Owned space ids known to be hosted for the current session: the sign-in
4121
4098
  * activation listed them as `activated`, or this session hosted them. Unlike
@@ -4454,6 +4431,96 @@ var _TinyCloudNode = class _TinyCloudNode {
4454
4431
  ));
4455
4432
  }
4456
4433
  }
4434
+ /**
4435
+ * Whether the TinyCloud node hosts the primary space (the default) or a named
4436
+ * or full-id space: `"hosted"`, `"not-hosted"`, or `"unknown"` when the node
4437
+ * cannot say.
4438
+ *
4439
+ * Sends one authorized read the session already holds on that space (a kv
4440
+ * list under a granted prefix, else kv metadata, `tinycloud.space/info`, or
4441
+ * a kv get of a key that does not exist), signed for that space. A session
4442
+ * with no such read sends nothing and answers `unknown`. A 401/403 registers
4443
+ * the session delegation with the node once and asks again once. Network
4444
+ * failures, 5xx and a 5 s timeout answer `unknown`; this never throws.
4445
+ *
4446
+ * `hosted` is remembered for the session and `not-hosted` never is. The
4447
+ * answer for the primary space is also what {@link spaceHosting} reports; a
4448
+ * `unknown` answer leaves the previous one in place.
4449
+ */
4450
+ async checkSpaceHosting(space) {
4451
+ try {
4452
+ return await this.probeSpaceHosting(space);
4453
+ } catch {
4454
+ return "unknown";
4455
+ }
4456
+ }
4457
+ /** Run the existing primary-space creation flow for the restored session. */
4458
+ async ensurePrimarySpaceHosted(hosting) {
4459
+ const graph = this._serviceGraph;
4460
+ const epoch = this.sessionEpoch;
4461
+ graph.assertActive();
4462
+ this.assertSessionEpoch(epoch, "Space hosting");
4463
+ const auth = this.auth;
4464
+ if (!auth || !this.session) return;
4465
+ await auth.ensurePrimarySpaceHosted(hosting, graph.signal);
4466
+ graph.assertActive();
4467
+ this.assertSessionEpoch(epoch, "Space hosting");
4468
+ }
4469
+ /**
4470
+ * The node's last answer for the primary space: recorded at sign-in from the
4471
+ * activation, or by {@link checkSpaceHosting}. `unknown` after a restore until
4472
+ * something asks.
4473
+ */
4474
+ get spaceHosting() {
4475
+ return this.auth ? this.auth.spaceHosting : this._restoredSpaceHosting;
4476
+ }
4477
+ async probeSpaceHosting(space) {
4478
+ const context = this._serviceContext;
4479
+ const session = context?.session;
4480
+ const host = context?.hosts[0];
4481
+ if (!context || !session || !host) {
4482
+ return "unknown";
4483
+ }
4484
+ const spaceId = space === void 0 ? session.spaceId : space.startsWith("tinycloud:") ? space : this.ownedSpaceId(space);
4485
+ const graph = this._serviceGraph;
4486
+ const epoch = this.sessionEpoch;
4487
+ const assertCurrent = () => {
4488
+ graph.assertActive();
4489
+ if (epoch !== this.sessionEpoch || graph !== this._serviceGraph || this._serviceContext !== context) {
4490
+ throw new Error("The session changed during the hosting check.");
4491
+ }
4492
+ };
4493
+ const { askSpaceHosting } = await import("./space-hosting.js");
4494
+ assertCurrent();
4495
+ this.pruneExpiredRuntimePermissionGrants();
4496
+ const primary = this.currentTinyCloudSession();
4497
+ const answer = await askSpaceHosting({
4498
+ spaceId,
4499
+ operations: [
4500
+ ...this.runtimePermissionGrants.flatMap((grant) => grant.operations),
4501
+ ...primary ? this.recapOperationsFromSession(primary) : []
4502
+ ],
4503
+ covers: (granted, requested) => this.operationCovers(granted, requested),
4504
+ scope: context,
4505
+ host,
4506
+ fetch: unrecordedFetchOf(context),
4507
+ sign: (entries) => {
4508
+ assertCurrent();
4509
+ return graph.invokeAny({ ...session, spaceId }, entries);
4510
+ },
4511
+ // A session saved but never registered on this node is refused: it registers once.
4512
+ activate: (signal) => {
4513
+ assertCurrent();
4514
+ return activateSessionWithHost2(host, session.delegationHeader, AbortSignal.any([signal, graph.signal]));
4515
+ }
4516
+ });
4517
+ assertCurrent();
4518
+ if (answer !== "unknown" && this.spaceIdsEqual(spaceId, session.spaceId)) {
4519
+ if (this.auth) this.auth.noteSpaceHosting(answer);
4520
+ else this._restoredSpaceHosting = answer;
4521
+ }
4522
+ return answer;
4523
+ }
4457
4524
  get nodeFeatures() {
4458
4525
  return this.auth?.nodeFeatures ?? this._restoredNodeFeatures ?? [];
4459
4526
  }
@@ -4945,6 +5012,7 @@ var _TinyCloudNode = class _TinyCloudNode {
4945
5012
  this._spaceService = void 0;
4946
5013
  this.runtimePermissionGrants = [];
4947
5014
  this._recapOperationsCache = void 0;
5015
+ this._restoredSpaceHosting = "unknown";
4948
5016
  this.confirmedHostedSpaceIds.clear();
4949
5017
  this.hostedOwnedSpaceIds.clear();
4950
5018
  this.cancelOwnedSpaceHosts();
@@ -5138,6 +5206,10 @@ var _TinyCloudNode = class _TinyCloudNode {
5138
5206
  const primarySession = this.currentTinyCloudSession();
5139
5207
  if (primarySession) {
5140
5208
  this.registerPrimarySessionGrant(primarySession);
5209
+ if (this.auth?.spaceHosting === "unknown") {
5210
+ await this.checkSpaceHosting();
5211
+ this.assertSessionEpoch(epoch, "Sign-in");
5212
+ }
5141
5213
  }
5142
5214
  const bootstrapped = await this.bootstrapAccountIfNeeded();
5143
5215
  this.assertSessionEpoch(epoch, "Sign-in");
@@ -6517,6 +6589,7 @@ var _TinyCloudNode = class _TinyCloudNode {
6517
6589
  this.tc = stagedGraph.core;
6518
6590
  this._recapOperationsCache = stagedPrimary.cache;
6519
6591
  this.runtimePermissionGrants = stagedPrimary.grants;
6592
+ this._restoredSpaceHosting = "unknown";
6520
6593
  this.confirmedHostedSpaceIds.clear();
6521
6594
  this.hostedOwnedSpaceIds.clear();
6522
6595
  this.cancelOwnedSpaceHosts();