@tinycloud/node-sdk 3.8.0-beta.0 → 3.8.0-beta.10

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 (39) hide show
  1. package/dist/{TinyCloudNode-BtKzLDJX.d.ts → TinyCloudNode-DnD-SH6t.d.ts} +27 -4
  2. package/dist/{TinyCloudNode-ggmlnSfI.d.cts → TinyCloudNode-Dy65bxqs.d.cts} +27 -4
  3. package/dist/{authority-sJ6buHMj.d.ts → authority-BQnTX3fI.d.ts} +21 -5
  4. package/dist/{authority-_SYAE-uV.d.cts → authority-Rbye1U4o.d.cts} +21 -5
  5. package/dist/core.cjs +196 -29
  6. package/dist/core.cjs.map +1 -1
  7. package/dist/core.d.cts +5 -4
  8. package/dist/core.d.ts +5 -4
  9. package/dist/core.js +190 -25
  10. package/dist/core.js.map +1 -1
  11. package/dist/credentials-core.d.cts +1 -1
  12. package/dist/credentials-core.d.ts +1 -1
  13. package/dist/credentials.d.cts +1 -1
  14. package/dist/credentials.d.ts +1 -1
  15. package/dist/{delegation-0LKZkmP2.d.cts → delegation-Ckc3UETl.d.cts} +1 -1
  16. package/dist/{delegation-0LKZkmP2.d.ts → delegation-Ckc3UETl.d.ts} +1 -1
  17. package/dist/encryption-keys.d.cts +2 -2
  18. package/dist/encryption-keys.d.ts +2 -2
  19. package/dist/index.cjs +249 -41
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +4 -3
  22. package/dist/index.d.ts +4 -3
  23. package/dist/index.js +236 -28
  24. package/dist/index.js.map +1 -1
  25. package/dist/replication/authority.cjs +43 -1
  26. package/dist/replication/authority.cjs.map +1 -1
  27. package/dist/replication/authority.d.cts +4 -3
  28. package/dist/replication/authority.d.ts +4 -3
  29. package/dist/replication/authority.js +42 -1
  30. package/dist/replication/authority.js.map +1 -1
  31. package/dist/replication/runtime.cjs +1 -0
  32. package/dist/replication/runtime.cjs.map +1 -1
  33. package/dist/replication/runtime.d.cts +1 -1
  34. package/dist/replication/runtime.d.ts +1 -1
  35. package/dist/replication/runtime.js +1 -0
  36. package/dist/replication/runtime.js.map +1 -1
  37. package/dist/{runtime-v62FzQHz.d.ts → runtime-CO4VXnPq.d.ts} +2 -1
  38. package/dist/{runtime-D1o9Eybt.d.cts → runtime-mRhSu-vJ.d.cts} +2 -1
  39. package/package.json +4 -4
package/dist/core.d.cts CHANGED
@@ -1,13 +1,14 @@
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-_SYAE-uV.cjs';
5
- import { _ as __runtime } from './runtime-D1o9Eybt.cjs';
4
+ import { _ as __authority } from './authority-Rbye1U4o.cjs';
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 } from './WasmKeyProvider-5Ee7fcAw.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 OwnerDelegationReceipt, R as RuntimePermissionGrantOptions, S as SecretPermissionHint, e as SecretReadInput, f as SecretReadResult, g as SignStrategy, T as TinyCloudNode, h as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, i as UnifiedOwnerRootReceipt, j as UnsupportedSessionRestoreError, k as defaultSignStrategy } from './TinyCloudNode-ggmlnSfI.cjs';
9
- export { C as CompactRuntimeDelegationInput, P as PortableDelegation, V as ValidatedRuntimeDelegation, a as activateCompactRuntimeDelegation, d as deserializeDelegation, s as serializeDelegation } from './delegation-0LKZkmP2.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 OwnerDelegationReceipt, R as RuntimePermissionGrantOptions, S as SecretPermissionHint, e as SecretReadInput, f as SecretReadResult, g as SignStrategy, T as TinyCloudNode, h as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, i as UnifiedOwnerRootReceipt, j as UnsupportedSessionRestoreError, k as defaultSignStrategy } from './TinyCloudNode-Dy65bxqs.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';
10
10
  import '@tinycloud/sdk-services';
11
+ import '@tinycloud/sdk-services/encryption/named-keys';
11
12
  import 'events';
12
13
 
13
14
  /**
package/dist/core.d.ts CHANGED
@@ -1,13 +1,14 @@
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-sJ6buHMj.js';
5
- import { _ as __runtime } from './runtime-v62FzQHz.js';
4
+ import { _ as __authority } from './authority-BQnTX3fI.js';
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 } from './WasmKeyProvider-5Ee7fcAw.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 OwnerDelegationReceipt, R as RuntimePermissionGrantOptions, S as SecretPermissionHint, e as SecretReadInput, f as SecretReadResult, g as SignStrategy, T as TinyCloudNode, h as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, i as UnifiedOwnerRootReceipt, j as UnsupportedSessionRestoreError, k as defaultSignStrategy } from './TinyCloudNode-BtKzLDJX.js';
9
- export { C as CompactRuntimeDelegationInput, P as PortableDelegation, V as ValidatedRuntimeDelegation, a as activateCompactRuntimeDelegation, d as deserializeDelegation, s as serializeDelegation } from './delegation-0LKZkmP2.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 OwnerDelegationReceipt, R as RuntimePermissionGrantOptions, S as SecretPermissionHint, e as SecretReadInput, f as SecretReadResult, g as SignStrategy, T as TinyCloudNode, h as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, i as UnifiedOwnerRootReceipt, j as UnsupportedSessionRestoreError, k as defaultSignStrategy } from './TinyCloudNode-DnD-SH6t.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';
10
10
  import '@tinycloud/sdk-services';
11
+ import '@tinycloud/sdk-services/encryption/named-keys';
11
12
  import 'events';
12
13
 
13
14
  /**
package/dist/core.js CHANGED
@@ -242,10 +242,10 @@ import {
242
242
  activateSessionWithHost,
243
243
  checkNodeInfo,
244
244
  AutoApproveSpaceCreationHandler,
245
+ ManifestValidationError,
245
246
  DEFAULT_MANIFEST_SPACE,
246
247
  ENCRYPTION_PERMISSION_SERVICE,
247
248
  composeManifestRequest,
248
- parseNetworkId,
249
249
  principalDidEquals,
250
250
  resourceCapabilitiesToAbilitiesMap,
251
251
  resourceCapabilitiesToSpaceAbilitiesMap,
@@ -273,6 +273,32 @@ import {
273
273
  HOOKS,
274
274
  ENCRYPTION
275
275
  } from "@tinycloud/sdk-core";
276
+ import { parseEncryptionResource } from "@tinycloud/sdk-services/encryption/resource";
277
+ import { parseNetworkId } from "@tinycloud/sdk-services";
278
+
279
+ // src/authorization/appKeyHostBinding.ts
280
+ var DOMAIN_LABEL = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/;
281
+ var IPV4 = /^\d+\.\d+\.\d+\.\d+$/;
282
+ var APP_ID = /^[a-z0-9][a-z0-9._-]{0,63}$/;
283
+ function appKeyHostBinding(domain, appId) {
284
+ if (!APP_ID.test(appId)) return false;
285
+ if (domain.endsWith(":")) return false;
286
+ let url;
287
+ try {
288
+ url = new URL(`https://${domain}`);
289
+ } catch {
290
+ return false;
291
+ }
292
+ if (url.protocol !== "https:" || url.port !== "" || url.username !== "" || url.password !== "") return false;
293
+ if (url.pathname !== "/" || url.search !== "" || url.hash !== "") return false;
294
+ const host = url.hostname;
295
+ if (host.startsWith("[") || host.endsWith(".") || IPV4.test(host)) return false;
296
+ const labels = host.split(".");
297
+ if (labels.length < 2 || labels[labels.length - 1] === "localhost") return false;
298
+ if (!labels.every((label) => DOMAIN_LABEL.test(label))) return false;
299
+ const reversed = labels.reverse().join(".");
300
+ return appId === reversed || appId.startsWith(`${reversed}.`);
301
+ }
276
302
 
277
303
  // src/replication/authority-sign-in.ts
278
304
  import {
@@ -306,7 +332,7 @@ function augmentSignInEntriesWithReplication(input) {
306
332
  }
307
333
  eligiblePaths.push(path);
308
334
  }
309
- if (eligiblePaths.length === replication.prefixes.length && eligiblePaths.length > 0 && hasUnrestrictedGetCoverage(input.entries, input.primarySpaceId, "")) {
335
+ if (replication.syncScope !== "prefixes" && eligiblePaths.length === replication.prefixes.length && eligiblePaths.length > 0 && hasUnrestrictedGetCoverage(input.entries, input.primarySpaceId, "")) {
310
336
  return [{
311
337
  service: KV_SERVICE,
312
338
  space: input.primarySpaceId,
@@ -766,6 +792,23 @@ var NodeUserAuthorization = class {
766
792
  );
767
793
  return this._capabilityRequest;
768
794
  }
795
+ async refreshNamedKeyFeatureForSignIn(address, chainId) {
796
+ const request = this.getCapabilityRequest();
797
+ const siweDomain = this.siweConfig?.domain ?? this.domain;
798
+ const hasNamedKeys = request?.manifests.some((manifest) => manifest.keys?.length && appKeyHostBinding(siweDomain, manifest.keys_app_id ?? manifest.app_id));
799
+ if (hasNamedKeys) {
800
+ await this.resolveTinyCloudHostsForSignIn(address, chainId);
801
+ await this.refreshNodeInfo();
802
+ }
803
+ }
804
+ /** Manifest key paths that this sign-in cannot grant. */
805
+ get unavailableKeyPaths() {
806
+ const request = this.getCapabilityRequest();
807
+ const siweDomain = this.siweConfig?.domain ?? this.domain;
808
+ return (request?.manifests ?? []).flatMap(
809
+ (manifest) => this._nodeFeatures.includes("encryption-named-keys-v1") && appKeyHostBinding(siweDomain, manifest.keys_app_id ?? manifest.app_id) ? [] : (manifest.keys ?? []).map((entry) => "path" in entry ? entry.path : entry.prefix)
810
+ );
811
+ }
769
812
  resolveSpaceName(space, address, chainId) {
770
813
  if (space.startsWith("tinycloud:")) {
771
814
  return space;
@@ -957,15 +1000,31 @@ var NodeUserAuthorization = class {
957
1000
  }
958
1001
  const rawAbilities = {};
959
1002
  const currentDid = pkhDid(address, chainId);
1003
+ if (this._nodeFeatures.includes("encryption-named-keys-v1")) {
1004
+ const siweDomain = this.siweConfig?.domain ?? this.domain;
1005
+ for (const manifest of request.manifests) {
1006
+ if (!appKeyHostBinding(siweDomain, manifest.keys_app_id ?? manifest.app_id)) continue;
1007
+ for (const declaration of manifest.keys ?? []) {
1008
+ const path = "path" in declaration ? declaration.path : declaration.prefix;
1009
+ const resource = `urn:tinycloud:encryption:${currentDid}:default/${path}`;
1010
+ for (const ability of declaration.abilities) {
1011
+ addRawAbility(rawAbilities, resource, `tinycloud.encryption/${ability}`);
1012
+ }
1013
+ }
1014
+ }
1015
+ }
960
1016
  const spaceResources = request.resources.filter((entry) => {
961
1017
  if (entry.service !== ENCRYPTION_PERMISSION_SERVICE) {
962
1018
  return true;
963
1019
  }
1020
+ const parsed = entry.path.includes("/") ? parseEncryptionResource(entry.path) : { ...parseNetworkId(entry.path), kind: "network" };
1021
+ if (parsed.kind !== "network") {
1022
+ throw new ManifestValidationError("named keys go in manifest.keys");
1023
+ }
964
1024
  for (const action of entry.actions) {
965
1025
  addRawAbility(rawAbilities, entry.path, action);
966
1026
  }
967
- if (entry.actions.includes(DECRYPT_ACTION)) {
968
- const parsed = parseNetworkId(entry.path);
1027
+ if (entry.actions.includes(DECRYPT_ACTION) && parsed.kind === "network") {
969
1028
  if (didPrincipalMatches(parsed.ownerDid, currentDid)) {
970
1029
  addRawAbility(rawAbilities, entry.path, NETWORK_CREATE_ACTION);
971
1030
  }
@@ -1361,6 +1420,8 @@ var NodeUserAuthorization = class {
1361
1420
  this._chainId = chainId;
1362
1421
  await this.resolveTinyCloudHostsForSignIn(address, chainId);
1363
1422
  this.assertSignInCurrent(generation);
1423
+ await this.refreshNamedKeyFeatureForSignIn(address, chainId);
1424
+ this.assertSignInCurrent(generation);
1364
1425
  const keyId = `session-${Date.now()}`;
1365
1426
  this.sessionManager.renameSessionKeyId(this.activeSessionKeyId, keyId);
1366
1427
  this.activeSessionKeyId = keyId;
@@ -1507,6 +1568,7 @@ var NodeUserAuthorization = class {
1507
1568
  refuseCaveated(this.getCapabilityRequest()?.manifests);
1508
1569
  const address = canonicalizeAddress(await this.signer.getAddress());
1509
1570
  const chainId = await this.signer.getChainId();
1571
+ await this.refreshNamedKeyFeatureForSignIn(address, chainId);
1510
1572
  const keyId = `session-${Date.now()}`;
1511
1573
  this.sessionManager.renameSessionKeyId(this.activeSessionKeyId, keyId);
1512
1574
  this.activeSessionKeyId = keyId;
@@ -2819,6 +2881,7 @@ import {
2819
2881
  tinyCloudDebugLogger
2820
2882
  } from "@tinycloud/sdk-services";
2821
2883
  import { RequestLog, observeReplicaReads, readOnlyRequestLog } from "@tinycloud/sdk-services/telemetry/requestLog";
2884
+ import { parseEncryptionResource as parseEncryptionResource2 } from "@tinycloud/sdk-services/encryption/resource";
2822
2885
 
2823
2886
  // src/account/AccountService.ts
2824
2887
  import { AccountService } from "@tinycloud/sdk-core";
@@ -3310,6 +3373,7 @@ var ROOT_DELEGATION_ACTIONS = [
3310
3373
  DUCKDB2.ALL
3311
3374
  ];
3312
3375
  var DEFAULT_SESSION_EXPIRATION_MS = EXPIRY3.SESSION_MS;
3376
+ var OWNER_REVOCATION_WINDOW_MS = 10 * 6e4;
3313
3377
  function unifiedRootAttenuation(capabilities) {
3314
3378
  const attenuation = {};
3315
3379
  for (const capability of capabilities) {
@@ -3774,6 +3838,7 @@ function replicaRestoreRefusal(error) {
3774
3838
  case "purge_pending":
3775
3839
  case "logout_pending":
3776
3840
  case "gate_unavailable":
3841
+ case "wallet_provider_required":
3777
3842
  return error.gate;
3778
3843
  }
3779
3844
  }
@@ -3808,6 +3873,7 @@ var _TinyCloudNode = class _TinyCloudNode {
3808
3873
  this.auth = null;
3809
3874
  this.tc = null;
3810
3875
  this._chainId = 1;
3876
+ this.replicaPurgeFailedHandlers = /* @__PURE__ */ new Set();
3811
3877
  /** Mints the replica session stamp on each fresh sign-in (TC-858 §4.1). Undefined when replication is off. */
3812
3878
  this.establishReplicaStamp = async (session) => {
3813
3879
  const replication = this.config.replication;
@@ -3839,6 +3905,7 @@ var _TinyCloudNode = class _TinyCloudNode {
3839
3905
  return void 0;
3840
3906
  }
3841
3907
  };
3908
+ this._keysUnavailable = [];
3842
3909
  this._baseVaults = /* @__PURE__ */ new Map();
3843
3910
  this._baseSecrets = /* @__PURE__ */ new Map();
3844
3911
  this._secrets = /* @__PURE__ */ new Map();
@@ -4014,6 +4081,7 @@ var _TinyCloudNode = class _TinyCloudNode {
4014
4081
  return instance ? instance.control.purge(input) : runtime.then((ready) => ready.control.purge(input));
4015
4082
  },
4016
4083
  clearPending: async () => (await runtime).control.clearPending(),
4084
+ purgeLocalCopy: async () => (await this.eraseReplicaLocalCopy("purge_local_copy"))?.purge ?? { ok: false, retryNow: false },
4017
4085
  close: async () => (await runtime).control.close()
4018
4086
  };
4019
4087
  }
@@ -4068,18 +4136,14 @@ var _TinyCloudNode = class _TinyCloudNode {
4068
4136
  get freshEncryptionNetworkCreated() {
4069
4137
  return this._freshEncryptionNetworkCreated;
4070
4138
  }
4071
- /**
4072
- * Subscribe to `storage.full`. It fires on the first write any service had
4073
- * rejected because the owner's TinyCloud storage is full
4074
- * (`STORAGE_QUOTA_EXCEEDED` or `STORAGE_LIMIT_REACHED`), so an app can show
4075
- * one read-only banner. Reads keep working. For the signed-in account's own
4076
- * storage it fires once per episode: the episode ends only when a write to
4077
- * that storage succeeds, or on sign-out. A `storage.status()` read does not
4078
- * end it. A rejection on another owner's delegated space fires once per
4079
- * owner, until that owner's `storage.status()` reports space again. Returns
4080
- * the unsubscribe function.
4081
- */
4082
4139
  on(event, handler) {
4140
+ if (event === "replica.purge.failed") {
4141
+ const listener = handler;
4142
+ this.replicaPurgeFailedHandlers.add(listener);
4143
+ return () => {
4144
+ this.replicaPurgeFailedHandlers.delete(listener);
4145
+ };
4146
+ }
4083
4147
  if (event !== "storage.full") {
4084
4148
  throw new Error(`Unknown TinyCloud event: ${String(event)}`);
4085
4149
  }
@@ -4299,7 +4363,8 @@ var _TinyCloudNode = class _TinyCloudNode {
4299
4363
  replication: config.replication?.enabled === true ? {
4300
4364
  enabled: true,
4301
4365
  prefixes: config.replication.prefixes,
4302
- allowSecrets: config.replication.allowSecrets === true
4366
+ allowSecrets: config.replication.allowSecrets === true,
4367
+ syncScope: config.replication.syncScope
4303
4368
  } : void 0
4304
4369
  });
4305
4370
  this.tc = new TinyCloud(this.auth, {
@@ -4559,6 +4624,7 @@ var _TinyCloudNode = class _TinyCloudNode {
4559
4624
  const leavingAuth = this.auth;
4560
4625
  const leavingContext = this._serviceContext;
4561
4626
  let denied;
4627
+ let erased;
4562
4628
  try {
4563
4629
  this.teardownSession();
4564
4630
  } finally {
@@ -4569,6 +4635,7 @@ var _TinyCloudNode = class _TinyCloudNode {
4569
4635
  try {
4570
4636
  await this.accountRegistryTail;
4571
4637
  await this.quiesceReplicaRuntime();
4638
+ if (denied) erased = await this.eraseReplicaLocalCopy("sign_out", denied.status);
4572
4639
  } finally {
4573
4640
  if (leavingAddress) {
4574
4641
  await (leavingAuth ? leavingAuth.clearPersistedSession(leavingAddress) : this.config.sessionStorage?.clear(leavingAddress));
@@ -4576,8 +4643,37 @@ var _TinyCloudNode = class _TinyCloudNode {
4576
4643
  }
4577
4644
  }
4578
4645
  }
4579
- if (denied?.status === "unguarded") {
4580
- throw new Error(`Replica gate was not denied (${denied.code ?? "unknown"}); the replica may still be restorable.`);
4646
+ if (denied?.status === "unguarded" && erased?.outcome.status !== "erased") {
4647
+ throw Object.assign(
4648
+ new Error(`Replica gate was not denied (${denied.code ?? "unknown"}); the replica may still be restorable.`),
4649
+ {
4650
+ code: "REPLICA_PURGE_FAILED",
4651
+ reason: "gate_unavailable",
4652
+ retryNow: erased?.outcome.status === "failed"
4653
+ }
4654
+ );
4655
+ }
4656
+ }
4657
+ /**
4658
+ * Erases the browser local copy after a deny (retry, event and next-load marker live in the lazy
4659
+ * replication authority). Never rejects; `undefined` when replication is off or the storage keeps
4660
+ * no browser database.
4661
+ */
4662
+ async eraseReplicaLocalCopy(trigger, denyStatus) {
4663
+ const replication = this.config.replication;
4664
+ if (!replication?.enabled) return void 0;
4665
+ try {
4666
+ const { eraseReplicaLocalCopy } = await getNodeReplicationLoaders().authority();
4667
+ const erased = await eraseReplicaLocalCopy(
4668
+ replication.storage.lifecycle,
4669
+ trigger,
4670
+ denyStatus,
4671
+ this.replicaPurgeFailedHandlers
4672
+ );
4673
+ if (erased?.logoutPending) this.replicaRestoreGate = "logout_pending";
4674
+ return erased;
4675
+ } catch {
4676
+ return void 0;
4581
4677
  }
4582
4678
  }
4583
4679
  /**
@@ -4637,6 +4733,8 @@ var _TinyCloudNode = class _TinyCloudNode {
4637
4733
  this._hooks = void 0;
4638
4734
  this._vault = void 0;
4639
4735
  this._encryption = void 0;
4736
+ this._namedKeyClient = void 0;
4737
+ this._keysUnavailable = [];
4640
4738
  this._baseVaults.clear();
4641
4739
  this._baseSecrets.clear();
4642
4740
  this._secrets.clear();
@@ -4741,6 +4839,10 @@ var _TinyCloudNode = class _TinyCloudNode {
4741
4839
  const priorPrincipal = this.replicaSessionPrincipal ?? (this.address ? pkhDid2(this.address, this._chainId) : void 0);
4742
4840
  if (this.config.replication?.enabled && priorPrincipal && priorPrincipal !== nextPrincipal) {
4743
4841
  const denial = await this.denyReplicaGate({ reason: "account_switch", principal: priorPrincipal, next: nextPrincipal });
4842
+ if (denial) {
4843
+ await this.quiesceReplicaRuntime();
4844
+ await this.eraseReplicaLocalCopy("account_switch", denial.status);
4845
+ }
4744
4846
  this.replicaRestoreGate = denial?.status === "unguarded" ? "gate_unavailable" : "stamp_stale";
4745
4847
  }
4746
4848
  if (address !== this._address || chainId !== this._chainId) {
@@ -4755,6 +4857,8 @@ var _TinyCloudNode = class _TinyCloudNode {
4755
4857
  this._hooks = void 0;
4756
4858
  this._vault = void 0;
4757
4859
  this._encryption = void 0;
4860
+ this._namedKeyClient = void 0;
4861
+ this._keysUnavailable = [];
4758
4862
  this._baseVaults.clear();
4759
4863
  this._baseSecrets.clear();
4760
4864
  this._secrets.clear();
@@ -4807,6 +4911,26 @@ var _TinyCloudNode = class _TinyCloudNode {
4807
4911
  this.assertSessionEpoch(epoch, "Sign-in");
4808
4912
  await this.ensureRequestedEncryptionNetworks();
4809
4913
  this.assertSessionEpoch(epoch, "Sign-in");
4914
+ this._keysUnavailable = this.auth?.unavailableKeyPaths ?? [];
4915
+ if (this._keysUnavailable.length > 0) {
4916
+ this.notificationHandler.warning(`Named keys unavailable: ${this._keysUnavailable.join(", ")}`);
4917
+ }
4918
+ if (this.nodeFeatures.includes("encryption-named-keys-v1")) {
4919
+ for (const manifest of this.auth?.capabilityRequest?.manifests ?? []) {
4920
+ for (const declaration of manifest.keys ?? []) {
4921
+ if ("path" in declaration && declaration.abilities.includes("key.create") && !this._keysUnavailable.includes(declaration.path)) {
4922
+ try {
4923
+ await this.keys.ensureKey(declaration.path);
4924
+ } catch (error) {
4925
+ this._keysUnavailable.push(declaration.path);
4926
+ const code = error && typeof error === "object" && "code" in error && typeof error.code === "string" && /^[A-Z_]+$/.test(error.code) ? error.code : "UNKNOWN";
4927
+ this.notificationHandler.warning(`Named key unavailable: ${declaration.path} (${code})`);
4928
+ }
4929
+ this.assertSessionEpoch(epoch, "Sign-in");
4930
+ }
4931
+ }
4932
+ }
4933
+ }
4810
4934
  if (!bootstrapped && this.config.manifest === void 0 && this.config.capabilityRequest === void 0) {
4811
4935
  await this.ensureOwnedSpaceHostedById(this.ownedSpaceId(SECRETS_SPACE2));
4812
4936
  }
@@ -5594,7 +5718,8 @@ var _TinyCloudNode = class _TinyCloudNode {
5594
5718
  const networkIds = /* @__PURE__ */ new Set();
5595
5719
  for (const resource of request.resources) {
5596
5720
  if (resource.service === ENCRYPTION_PERMISSION_SERVICE2 && resource.path.startsWith("urn:tinycloud:encryption:") && resource.actions.includes(DECRYPT_ACTION2)) {
5597
- networkIds.add(resource.path);
5721
+ const parsed = resource.path.includes("/") ? parseEncryptionResource2(resource.path) : { ...parseNetworkId2(resource.path), kind: "network" };
5722
+ if (parsed.kind === "network") networkIds.add(resource.path);
5598
5723
  }
5599
5724
  }
5600
5725
  return [...networkIds];
@@ -6144,6 +6269,8 @@ var _TinyCloudNode = class _TinyCloudNode {
6144
6269
  this._hooks = stagedGraph.hooks;
6145
6270
  this._vault = stagedGraph.vault;
6146
6271
  this._encryption = stagedGraph.encryption;
6272
+ this._namedKeyClient = void 0;
6273
+ this._keysUnavailable = [];
6147
6274
  this._capabilityRegistry = stagedGraph.capabilityRegistry;
6148
6275
  this._keyProvider = stagedGraph.keyProvider;
6149
6276
  this._sharingService = stagedGraph.sharingService;
@@ -6721,7 +6848,8 @@ var _TinyCloudNode = class _TinyCloudNode {
6721
6848
  replication: this.config.replication?.enabled === true ? {
6722
6849
  enabled: true,
6723
6850
  prefixes: this.config.replication.prefixes,
6724
- allowSecrets: this.config.replication.allowSecrets === true
6851
+ allowSecrets: this.config.replication.allowSecrets === true,
6852
+ syncScope: this.config.replication.syncScope
6725
6853
  } : void 0
6726
6854
  });
6727
6855
  this.tc = new TinyCloud(this.auth, {
@@ -6783,7 +6911,8 @@ var _TinyCloudNode = class _TinyCloudNode {
6783
6911
  replication: this.config.replication?.enabled === true ? {
6784
6912
  enabled: true,
6785
6913
  prefixes: this.config.replication.prefixes,
6786
- allowSecrets: this.config.replication.allowSecrets === true
6914
+ allowSecrets: this.config.replication.allowSecrets === true,
6915
+ syncScope: this.config.replication.syncScope
6787
6916
  } : void 0
6788
6917
  });
6789
6918
  this.tc = new TinyCloud(this.auth, {
@@ -7495,7 +7624,7 @@ var _TinyCloudNode = class _TinyCloudNode {
7495
7624
  * Sign a wallet (CACAO) revocation of the delegation `cid` for the node's
7496
7625
  * `POST /revoke`, and return its Authorization header value. The node
7497
7626
  * accepts it when the owner delegated `cid` or owns a space its abilities
7498
- * target, whichever key issued it. Valid for 60 seconds. Requires the
7627
+ * target, whichever key issued it. Valid for 10 minutes. Requires the
7499
7628
  * owner wallet signer.
7500
7629
  */
7501
7630
  async signOwnerRevocation(cid) {
@@ -7511,7 +7640,7 @@ var _TinyCloudNode = class _TinyCloudNode {
7511
7640
  chainId: session.chainId,
7512
7641
  nonce: generateNonce(),
7513
7642
  issuedAt: issuedAt.toISOString(),
7514
- expirationTime: new Date(issuedAt.getTime() + 6e4).toISOString()
7643
+ expirationTime: new Date(issuedAt.getTime() + OWNER_REVOCATION_WINDOW_MS).toISOString()
7515
7644
  }).prepareMessage();
7516
7645
  const signature = await this.signer.signMessage(siwe);
7517
7646
  return this.wasmBindings.siweToDelegationHeaders({ siwe, signature }).Authorization;
@@ -7738,6 +7867,40 @@ var _TinyCloudNode = class _TinyCloudNode {
7738
7867
  get encryption() {
7739
7868
  return this.getEncryptionService();
7740
7869
  }
7870
+ /** Named keys bound to the current session. */
7871
+ get keys() {
7872
+ return new Proxy({}, {
7873
+ get: (_target, property) => {
7874
+ if (property === "refreshNodeInfo") {
7875
+ return () => {
7876
+ void this._namedKeyClient?.then((client) => client.refreshNodeInfo());
7877
+ };
7878
+ }
7879
+ if (typeof property !== "string" || ![
7880
+ "getPublicKey",
7881
+ "describeKey",
7882
+ "createKey",
7883
+ "blockKey",
7884
+ "unblockKey",
7885
+ "ensureKey",
7886
+ "encrypt",
7887
+ "decrypt",
7888
+ "decryptMany"
7889
+ ].includes(property)) return void 0;
7890
+ return (...args) => {
7891
+ this._namedKeyClient ?? (this._namedKeyClient = import("./encryption-keys.js").then(({ createNamedKeyClient }) => createNamedKeyClient(this)));
7892
+ return this._namedKeyClient.then((client) => {
7893
+ const method = client[property];
7894
+ return method.apply(client, args);
7895
+ });
7896
+ };
7897
+ }
7898
+ });
7899
+ }
7900
+ /** Manifest key paths unavailable during the latest `signIn()` attempt. */
7901
+ get keysUnavailable() {
7902
+ return this._keysUnavailable;
7903
+ }
7741
7904
  async getEncryptionNetwork(nameOrNetworkId = this.getDefaultEncryptionNetworkId()) {
7742
7905
  const networkId = nameOrNetworkId.startsWith("urn:tinycloud:encryption:") ? nameOrNetworkId : this.getDefaultEncryptionNetworkId(nameOrNetworkId);
7743
7906
  return this.fetchEncryptionNetworkAt(
@@ -10012,7 +10175,7 @@ import {
10012
10175
  CaveatedDelegationUnsupportedError as CaveatedDelegationUnsupportedError3,
10013
10176
  PermissionNotInManifestError as PermissionNotInManifestError2,
10014
10177
  SessionExpiredError as SessionExpiredError2,
10015
- ManifestValidationError,
10178
+ ManifestValidationError as ManifestValidationError2,
10016
10179
  composeManifestRequest as composeManifestRequest2,
10017
10180
  resolveManifest as resolveManifest2,
10018
10181
  validateManifest,
@@ -10097,12 +10260,13 @@ export {
10097
10260
  IdentityParseError,
10098
10261
  InvalidRestoredSessionError,
10099
10262
  KVService3 as KVService,
10100
- ManifestValidationError,
10263
+ ManifestValidationError2 as ManifestValidationError,
10101
10264
  MemorySessionStorage,
10102
10265
  NodeUserAuthorization,
10103
10266
  PermissionNotInManifestError2 as PermissionNotInManifestError,
10104
10267
  PrefixedKVService,
10105
10268
  ProtocolMismatchError2 as ProtocolMismatchError,
10269
+ RuntimeDelegationRejectedError,
10106
10270
  SECRET_NAME_RE,
10107
10271
  SQLAction,
10108
10272
  SQLService3 as SQLService,
@@ -10125,6 +10289,7 @@ export {
10125
10289
  VersionCheckError,
10126
10290
  WasmKeyProvider,
10127
10291
  activateCompactRuntimeDelegation,
10292
+ activateValidatedRuntimeDelegation,
10128
10293
  addressStorageKey,
10129
10294
  buildSpaceUri,
10130
10295
  canonicalizeAddress3 as canonicalizeAddress,