@tinycloud/node-sdk 3.2.0-beta.4 → 3.2.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  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, ReplicaGrantInfo, 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';
2
- import { _ as __authority } from './authority-mTQEgN56.cjs';
3
- import { _ as __runtime } from './runtime-DyYwHW8j.cjs';
4
- export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, F as FileSessionStorage, I as InvalidRestoredSessionError, M as MemorySessionStorage, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, k as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, P as PortableDelegation, p as RuntimePermissionGrantOptions, S as SecretPermissionHint, q as SecretReadInput, r as SecretReadResult, t as SignStrategy, T as TinyCloudNode, u as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, v as UnifiedOwnerRootReceipt, w as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, W as WasmKeyProvider, y as WasmKeyProviderConfig, z as activateCompactRuntimeDelegation, H as createWasmKeyProvider, J as defaultSignStrategy, K as deserializeDelegation, Q as serializeDelegation } from './WasmKeyProvider-DjfRu9aL.cjs';
2
+ import { _ as __authority } from './authority-DDGtccBK.cjs';
3
+ import { _ as __runtime } from './runtime-B5P5SRpC.cjs';
4
+ export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, F as FileSessionStorage, I as InvalidRestoredSessionError, M as MemorySessionStorage, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, k as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, P as PortableDelegation, p as RuntimePermissionGrantOptions, S as SecretPermissionHint, q as SecretReadInput, r as SecretReadResult, t as SignStrategy, T as TinyCloudNode, u as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, v as UnifiedOwnerRootReceipt, w as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, W as WasmKeyProvider, y as WasmKeyProviderConfig, z as activateCompactRuntimeDelegation, H as createWasmKeyProvider, J as defaultSignStrategy, K as deserializeDelegation, Q as serializeDelegation } from './WasmKeyProvider-C3NFgOmv.cjs';
5
5
  import '@tinycloud/sdk-services';
6
6
  import 'events';
7
7
 
package/dist/core.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  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, ReplicaGrantInfo, 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';
2
- import { _ as __authority } from './authority-mTQEgN56.js';
3
- import { _ as __runtime } from './runtime-DyYwHW8j.js';
4
- export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, F as FileSessionStorage, I as InvalidRestoredSessionError, M as MemorySessionStorage, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, k as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, P as PortableDelegation, p as RuntimePermissionGrantOptions, S as SecretPermissionHint, q as SecretReadInput, r as SecretReadResult, t as SignStrategy, T as TinyCloudNode, u as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, v as UnifiedOwnerRootReceipt, w as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, W as WasmKeyProvider, y as WasmKeyProviderConfig, z as activateCompactRuntimeDelegation, H as createWasmKeyProvider, J as defaultSignStrategy, K as deserializeDelegation, Q as serializeDelegation } from './WasmKeyProvider-DjfRu9aL.js';
2
+ import { _ as __authority } from './authority-DDGtccBK.js';
3
+ import { _ as __runtime } from './runtime-B5P5SRpC.js';
4
+ export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, F as FileSessionStorage, I as InvalidRestoredSessionError, M as MemorySessionStorage, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, k as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, P as PortableDelegation, p as RuntimePermissionGrantOptions, S as SecretPermissionHint, q as SecretReadInput, r as SecretReadResult, t as SignStrategy, T as TinyCloudNode, u as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, v as UnifiedOwnerRootReceipt, w as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, W as WasmKeyProvider, y as WasmKeyProviderConfig, z as activateCompactRuntimeDelegation, H as createWasmKeyProvider, J as defaultSignStrategy, K as deserializeDelegation, Q as serializeDelegation } from './WasmKeyProvider-C3NFgOmv.js';
5
5
  import '@tinycloud/sdk-services';
6
6
  import 'events';
7
7
 
package/dist/core.js CHANGED
@@ -271,18 +271,17 @@ import {
271
271
 
272
272
  // src/replication/authority-sign-in.ts
273
273
  import {
274
- grantPathsForSelector,
275
274
  KV,
276
275
  isCapabilitySubset
277
276
  } from "@tinycloud/sdk-core";
278
277
  import { requiresSecretsOptIn } from "@tinycloud/sdk-services";
278
+ import { assertFolderPrefix } from "@tinycloud/sdk-services/kv/replication/prefix";
279
279
  var KV_GET = KV.GET;
280
280
  var KV_SYNC = KV.SYNC;
281
281
  var KV_SERVICE = "tinycloud.kv";
282
282
  function hasUnrestrictedGetCoverage(entries, spaceId, prefix) {
283
- const requiredPaths = grantPathsForSelector(prefix);
284
283
  return isCapabilitySubset(
285
- requiredPaths.map((path) => ({ service: KV_SERVICE, space: spaceId, path, actions: [KV_GET] })),
284
+ [{ service: KV_SERVICE, space: spaceId, path: prefix, actions: [KV_GET] }],
286
285
  [...entries]
287
286
  ).subset;
288
287
  }
@@ -290,21 +289,33 @@ function augmentSignInEntriesWithReplication(input) {
290
289
  const out = [];
291
290
  const replication = input.replication;
292
291
  if (replication === void 0) return out;
292
+ const eligiblePaths = [];
293
293
  for (const prefix of replication.prefixes) {
294
+ assertFolderPrefix(prefix);
295
+ const path = prefix === "/" ? "" : prefix;
294
296
  if (requiresSecretsOptIn(input.primarySpaceId, prefix) && replication.allowSecrets !== true) {
295
297
  continue;
296
298
  }
297
- if (!hasUnrestrictedGetCoverage(input.entries, input.primarySpaceId, prefix)) {
299
+ if (!hasUnrestrictedGetCoverage(input.entries, input.primarySpaceId, path)) {
298
300
  continue;
299
301
  }
300
- for (const path of grantPathsForSelector(prefix)) {
301
- out.push({
302
- service: KV_SERVICE,
303
- space: input.primarySpaceId,
304
- path,
305
- actions: [KV_GET, KV_SYNC]
306
- });
307
- }
302
+ eligiblePaths.push(path);
303
+ }
304
+ if (eligiblePaths.length === replication.prefixes.length && eligiblePaths.length > 0 && hasUnrestrictedGetCoverage(input.entries, input.primarySpaceId, "")) {
305
+ return [{
306
+ service: KV_SERVICE,
307
+ space: input.primarySpaceId,
308
+ path: "",
309
+ actions: [KV_GET, KV_SYNC]
310
+ }];
311
+ }
312
+ for (const path of eligiblePaths) {
313
+ out.push({
314
+ service: KV_SERVICE,
315
+ space: input.primarySpaceId,
316
+ path,
317
+ actions: [KV_GET, KV_SYNC]
318
+ });
308
319
  }
309
320
  return out;
310
321
  }
@@ -373,6 +384,7 @@ var NodeUserAuthorization = class {
373
384
  this.activeSessionKeyId = "default";
374
385
  this.extensions = [];
375
386
  this._nodeFeatures = [];
387
+ this._nodeFeaturesKnown = false;
376
388
  this._lastActivationSkippedSpaceIds = [];
377
389
  this.wasm = config.wasmBindings;
378
390
  this.signer = config.signer;
@@ -496,8 +508,11 @@ var NodeUserAuthorization = class {
496
508
  }
497
509
  }
498
510
  /** @internal Atomically adopt the state staged by TinyCloudNode.restoreSession. */
499
- installRestoredSession(sessionManager, session, hosts) {
511
+ installRestoredSession(sessionManager, session, hosts, nodeFeatures) {
500
512
  this.sessionManager = sessionManager;
513
+ this._nodeFeatures = nodeFeatures === void 0 ? [] : [...nodeFeatures];
514
+ this._nodeFeaturesKnown = nodeFeatures !== void 0;
515
+ this._nodeInfoIdentity = void 0;
501
516
  this.tinycloudHosts = hosts && hosts.length > 0 ? [...hosts] : void 0;
502
517
  this._lastActivationSkippedSpaceIds = [];
503
518
  if (!session) {
@@ -572,6 +587,16 @@ var NodeUserAuthorization = class {
572
587
  get nodeFeatures() {
573
588
  return this._nodeFeatures;
574
589
  }
590
+ get nodeFeaturesKnown() {
591
+ return this._nodeFeaturesKnown;
592
+ }
593
+ async refreshNodeInfo() {
594
+ const infoHost = this.primaryTinyCloudHost;
595
+ const nodeInfo = await checkNodeInfo(infoHost, this.wasm.protocolVersion());
596
+ this._nodeFeatures = nodeInfo.features;
597
+ this._nodeFeaturesKnown = true;
598
+ this._nodeInfoIdentity = nodeInfo.nodeId ? { host: infoHost, nodeId: nodeInfo.nodeId } : void 0;
599
+ }
575
600
  /**
576
601
  * The node DID reported by `GET /info` for `host`, if the sign-in (or
577
602
  * restore) that populated it targeted that same host. Returns `undefined`
@@ -1235,13 +1260,7 @@ var NodeUserAuthorization = class {
1235
1260
  this._tinyCloudSession = tinyCloudSession;
1236
1261
  this._address = address;
1237
1262
  this._chainId = chainId;
1238
- const infoHost = this.primaryTinyCloudHost;
1239
- const nodeInfo = await checkNodeInfo(
1240
- infoHost,
1241
- this.wasm.protocolVersion()
1242
- );
1243
- this._nodeFeatures = nodeInfo.features;
1244
- this._nodeInfoIdentity = nodeInfo.nodeId ? { host: infoHost, nodeId: nodeInfo.nodeId } : void 0;
1263
+ await this.refreshNodeInfo();
1245
1264
  for (const ext of this.extensions) {
1246
1265
  if (ext.afterSignIn) {
1247
1266
  await ext.afterSignIn(clientSession);
@@ -1407,13 +1426,7 @@ var NodeUserAuthorization = class {
1407
1426
  this._tinyCloudSession = tinyCloudSession;
1408
1427
  this._address = address;
1409
1428
  this._chainId = chainId;
1410
- const infoHost = this.primaryTinyCloudHost;
1411
- const nodeInfo = await checkNodeInfo(
1412
- infoHost,
1413
- this.wasm.protocolVersion()
1414
- );
1415
- this._nodeFeatures = nodeInfo.features;
1416
- this._nodeInfoIdentity = nodeInfo.nodeId ? { host: infoHost, nodeId: nodeInfo.nodeId } : void 0;
1429
+ await this.refreshNodeInfo();
1417
1430
  for (const ext of this.extensions) {
1418
1431
  if (ext.afterSignIn) {
1419
1432
  await ext.afterSignIn(clientSession);
@@ -2327,18 +2340,25 @@ async function activateCompactRuntimeDelegation(node, input) {
2327
2340
  throw new Error("Compact runtime delegation CID does not match authorization bytes.");
2328
2341
  }
2329
2342
  const signed = signedAuthorityFromCompactUcan(authorization);
2343
+ return activateValidatedRuntimeDelegation(
2344
+ node,
2345
+ portableFromSignedAuthority(cid, authorization, signed, input),
2346
+ { host: input.host }
2347
+ );
2348
+ }
2349
+ function portableFromSignedAuthority(cid, authorization, signed, transport) {
2330
2350
  const primary = signed.resources[0];
2331
2351
  const signedSpace = signed.permissions.find(
2332
2352
  (permission) => permission.service !== "tinycloud.encryption"
2333
2353
  )?.space;
2334
- const delegation = {
2354
+ return {
2335
2355
  cid,
2336
2356
  delegationHeader: { Authorization: authorization },
2337
- ownerAddress: input.ownerAddress,
2338
- chainId: input.chainId,
2357
+ ownerAddress: transport.ownerAddress,
2358
+ chainId: transport.chainId,
2339
2359
  delegatorDID: signed.issuer,
2340
2360
  authHeader: authorization,
2341
- spaceId: signedSpace ?? primary.space,
2361
+ spaceId: signedSpace ?? transport.spaceId ?? primary.space,
2342
2362
  path: primary.path,
2343
2363
  actions: [...primary.actions],
2344
2364
  ...primary.caveats === void 0 ? {} : { caveats: primary.caveats },
@@ -2348,11 +2368,8 @@ async function activateCompactRuntimeDelegation(node, input) {
2348
2368
  })),
2349
2369
  expiry: new Date(signed.expiry),
2350
2370
  delegateDID: signed.audience,
2351
- host: normalizedHost(input.host)
2371
+ host: normalizedHost(transport.host)
2352
2372
  };
2353
- return activateValidatedRuntimeDelegation(node, delegation, {
2354
- host: input.host
2355
- });
2356
2373
  }
2357
2374
  function serializeDelegation(delegation) {
2358
2375
  return JSON.stringify({
@@ -2370,7 +2387,7 @@ function deserializeDelegation(data) {
2370
2387
  }
2371
2388
 
2372
2389
  // src/replication/config.ts
2373
- import { kvPrefixCovers } from "@tinycloud/sdk-services";
2390
+ import { assertFolderPrefix as assertPureFolderPrefix, kvPrefixCovers } from "@tinycloud/sdk-services/kv/replication/prefix";
2374
2391
  function assertValidReplicationConfig(replication) {
2375
2392
  if (replication === void 0 || replication.enabled !== true) return;
2376
2393
  if (replication.storage === void 0 || replication.storage === null) {
@@ -2380,8 +2397,10 @@ function assertValidReplicationConfig(replication) {
2380
2397
  throw new TypeError("replication.prefixes must be a non-empty array");
2381
2398
  }
2382
2399
  for (const prefix of replication.prefixes) {
2383
- if (typeof prefix !== "string" || prefix === "") {
2384
- throw new TypeError("replication.prefixes must not contain an empty prefix");
2400
+ try {
2401
+ assertPureFolderPrefix(prefix);
2402
+ } catch (error) {
2403
+ throw new TypeError(error instanceof Error ? error.message : String(error));
2385
2404
  }
2386
2405
  }
2387
2406
  for (const [index, prefix] of replication.prefixes.entries()) {
@@ -2392,7 +2411,7 @@ function assertValidReplicationConfig(replication) {
2392
2411
  );
2393
2412
  }
2394
2413
  }
2395
- if (prefix.split("/", 1)[0] === "vault" && replication.allowSecrets !== true) {
2414
+ if ((prefix === "/" || prefix.split("/", 1)[0] === "vault") && replication.allowSecrets !== true) {
2396
2415
  throw new TypeError(
2397
2416
  `replication prefix ${JSON.stringify(prefix)} overlaps the vault namespace; pass allowSecrets to opt in`
2398
2417
  );
@@ -2403,6 +2422,8 @@ function assertValidReplicationConfig(replication) {
2403
2422
  // src/TinyCloudNode.ts
2404
2423
  import {
2405
2424
  TinyCloud,
2425
+ checkNodeInfo as checkNodeInfo2,
2426
+ VersionCheckError,
2406
2427
  activateSessionWithHost as activateSessionWithHost2,
2407
2428
  authorizationVerdictOf,
2408
2429
  httpResponseError,
@@ -3584,7 +3605,11 @@ var _TinyCloudNode = class _TinyCloudNode {
3584
3605
  return this._bootstrapStatus;
3585
3606
  }
3586
3607
  get nodeFeatures() {
3587
- return this.auth?.nodeFeatures ?? [];
3608
+ return this.auth?.nodeFeatures ?? this._restoredNodeFeatures ?? [];
3609
+ }
3610
+ get replicationNodeFeatures() {
3611
+ if (this.auth) return this.auth.nodeFeaturesKnown ? this.auth.nodeFeatures : void 0;
3612
+ return this._restoredNodeFeatures;
3588
3613
  }
3589
3614
  /** SIWE domain — uses config override or defaults to app.tinycloud.xyz */
3590
3615
  get siweDomain() {
@@ -4937,6 +4962,14 @@ var _TinyCloudNode = class _TinyCloudNode {
4937
4962
  sessionData.chainId
4938
4963
  );
4939
4964
  const stagedHost = resolvedHost ?? this.config.host;
4965
+ let restoredNodeFeatures;
4966
+ if (this.config.replication?.enabled) {
4967
+ try {
4968
+ restoredNodeFeatures = (await checkNodeInfo2(stagedHost, this.wasmBindings.protocolVersion())).features;
4969
+ } catch (error) {
4970
+ if (!(error instanceof VersionCheckError)) throw error;
4971
+ }
4972
+ }
4940
4973
  const stagedAddress = restoredAddress;
4941
4974
  const stagedChainId = sessionData.chainId ?? 1;
4942
4975
  let replicationPrincipal;
@@ -5039,8 +5072,9 @@ var _TinyCloudNode = class _TinyCloudNode {
5039
5072
  this._recapOperationsCache = stagedPrimary.cache;
5040
5073
  this.runtimePermissionGrants = stagedPrimary.grants;
5041
5074
  this.confirmedHostedSpaceIds.clear();
5075
+ this._restoredNodeFeatures = restoredNodeFeatures;
5042
5076
  if (this.auth) {
5043
- this.auth.installRestoredSession(stagedManager, stagedTcSession, [stagedHost]);
5077
+ this.auth.installRestoredSession(stagedManager, stagedTcSession, [stagedHost], restoredNodeFeatures);
5044
5078
  this._restoredTcSession = void 0;
5045
5079
  } else {
5046
5080
  this._restoredTcSession = stagedTcSession;
@@ -7614,6 +7648,7 @@ var _TinyCloudNode = class _TinyCloudNode {
7614
7648
  session,
7615
7649
  principal: identityPrincipal,
7616
7650
  authority,
7651
+ nodeFeatures: this.replicationNodeFeatures,
7617
7652
  primaryKV: [{ space: session.spaceId, kv }]
7618
7653
  });
7619
7654
  }
@@ -8804,9 +8839,9 @@ import {
8804
8839
  } from "@tinycloud/sdk-core";
8805
8840
  import {
8806
8841
  ProtocolMismatchError,
8807
- VersionCheckError,
8842
+ VersionCheckError as VersionCheckError2,
8808
8843
  UnsupportedFeatureError as UnsupportedFeatureError2,
8809
- checkNodeInfo as checkNodeInfo2
8844
+ checkNodeInfo as checkNodeInfo3
8810
8845
  } from "@tinycloud/sdk-core";
8811
8846
  import { ServiceContext as ServiceContext3 } from "@tinycloud/sdk-core";
8812
8847
  export {
@@ -8857,7 +8892,7 @@ export {
8857
8892
  VAULT_PERMISSION_SERVICE,
8858
8893
  VaultHeaders,
8859
8894
  VaultPublicSpaceKVActions,
8860
- VersionCheckError,
8895
+ VersionCheckError2 as VersionCheckError,
8861
8896
  WasmKeyProvider,
8862
8897
  activateCompactRuntimeDelegation,
8863
8898
  addressStorageKey,
@@ -8867,7 +8902,7 @@ export {
8867
8902
  canonicalizeDidUrl,
8868
8903
  canonicalizeNetworkId,
8869
8904
  canonicalizeSecretScope,
8870
- checkNodeInfo2 as checkNodeInfo,
8905
+ checkNodeInfo3 as checkNodeInfo,
8871
8906
  clearTinyCloudDebugLogs,
8872
8907
  composeManifestRequest2 as composeManifestRequest,
8873
8908
  createCapabilityKeyRegistry,