@tinycloud/node-sdk 3.8.0-beta.1 → 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-Ckqu_fqH.d.ts → TinyCloudNode-DnD-SH6t.d.ts} +26 -3
  2. package/dist/{TinyCloudNode-DDfx8Fx5.d.cts → TinyCloudNode-Dy65bxqs.d.cts} +26 -3
  3. package/dist/{authority-DcyJpajL.d.ts → authority-BQnTX3fI.d.ts} +20 -4
  4. package/dist/{authority-BwM_s3Ya.d.cts → authority-Rbye1U4o.d.cts} +20 -4
  5. package/dist/core.cjs +189 -25
  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 +183 -21
  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 +239 -37
  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 +226 -24
  24. package/dist/index.js.map +1 -1
  25. package/dist/replication/authority.cjs +39 -0
  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 +38 -0
  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-BwM_s3Ya.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-DDfx8Fx5.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-DcyJpajL.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-Ckqu_fqH.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 {
@@ -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
  }
@@ -4560,6 +4624,7 @@ var _TinyCloudNode = class _TinyCloudNode {
4560
4624
  const leavingAuth = this.auth;
4561
4625
  const leavingContext = this._serviceContext;
4562
4626
  let denied;
4627
+ let erased;
4563
4628
  try {
4564
4629
  this.teardownSession();
4565
4630
  } finally {
@@ -4570,6 +4635,7 @@ var _TinyCloudNode = class _TinyCloudNode {
4570
4635
  try {
4571
4636
  await this.accountRegistryTail;
4572
4637
  await this.quiesceReplicaRuntime();
4638
+ if (denied) erased = await this.eraseReplicaLocalCopy("sign_out", denied.status);
4573
4639
  } finally {
4574
4640
  if (leavingAddress) {
4575
4641
  await (leavingAuth ? leavingAuth.clearPersistedSession(leavingAddress) : this.config.sessionStorage?.clear(leavingAddress));
@@ -4577,8 +4643,37 @@ var _TinyCloudNode = class _TinyCloudNode {
4577
4643
  }
4578
4644
  }
4579
4645
  }
4580
- if (denied?.status === "unguarded") {
4581
- 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;
4582
4677
  }
4583
4678
  }
4584
4679
  /**
@@ -4638,6 +4733,8 @@ var _TinyCloudNode = class _TinyCloudNode {
4638
4733
  this._hooks = void 0;
4639
4734
  this._vault = void 0;
4640
4735
  this._encryption = void 0;
4736
+ this._namedKeyClient = void 0;
4737
+ this._keysUnavailable = [];
4641
4738
  this._baseVaults.clear();
4642
4739
  this._baseSecrets.clear();
4643
4740
  this._secrets.clear();
@@ -4742,6 +4839,10 @@ var _TinyCloudNode = class _TinyCloudNode {
4742
4839
  const priorPrincipal = this.replicaSessionPrincipal ?? (this.address ? pkhDid2(this.address, this._chainId) : void 0);
4743
4840
  if (this.config.replication?.enabled && priorPrincipal && priorPrincipal !== nextPrincipal) {
4744
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
+ }
4745
4846
  this.replicaRestoreGate = denial?.status === "unguarded" ? "gate_unavailable" : "stamp_stale";
4746
4847
  }
4747
4848
  if (address !== this._address || chainId !== this._chainId) {
@@ -4756,6 +4857,8 @@ var _TinyCloudNode = class _TinyCloudNode {
4756
4857
  this._hooks = void 0;
4757
4858
  this._vault = void 0;
4758
4859
  this._encryption = void 0;
4860
+ this._namedKeyClient = void 0;
4861
+ this._keysUnavailable = [];
4759
4862
  this._baseVaults.clear();
4760
4863
  this._baseSecrets.clear();
4761
4864
  this._secrets.clear();
@@ -4808,6 +4911,26 @@ var _TinyCloudNode = class _TinyCloudNode {
4808
4911
  this.assertSessionEpoch(epoch, "Sign-in");
4809
4912
  await this.ensureRequestedEncryptionNetworks();
4810
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
+ }
4811
4934
  if (!bootstrapped && this.config.manifest === void 0 && this.config.capabilityRequest === void 0) {
4812
4935
  await this.ensureOwnedSpaceHostedById(this.ownedSpaceId(SECRETS_SPACE2));
4813
4936
  }
@@ -5595,7 +5718,8 @@ var _TinyCloudNode = class _TinyCloudNode {
5595
5718
  const networkIds = /* @__PURE__ */ new Set();
5596
5719
  for (const resource of request.resources) {
5597
5720
  if (resource.service === ENCRYPTION_PERMISSION_SERVICE2 && resource.path.startsWith("urn:tinycloud:encryption:") && resource.actions.includes(DECRYPT_ACTION2)) {
5598
- 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);
5599
5723
  }
5600
5724
  }
5601
5725
  return [...networkIds];
@@ -6145,6 +6269,8 @@ var _TinyCloudNode = class _TinyCloudNode {
6145
6269
  this._hooks = stagedGraph.hooks;
6146
6270
  this._vault = stagedGraph.vault;
6147
6271
  this._encryption = stagedGraph.encryption;
6272
+ this._namedKeyClient = void 0;
6273
+ this._keysUnavailable = [];
6148
6274
  this._capabilityRegistry = stagedGraph.capabilityRegistry;
6149
6275
  this._keyProvider = stagedGraph.keyProvider;
6150
6276
  this._sharingService = stagedGraph.sharingService;
@@ -7498,7 +7624,7 @@ var _TinyCloudNode = class _TinyCloudNode {
7498
7624
  * Sign a wallet (CACAO) revocation of the delegation `cid` for the node's
7499
7625
  * `POST /revoke`, and return its Authorization header value. The node
7500
7626
  * accepts it when the owner delegated `cid` or owns a space its abilities
7501
- * target, whichever key issued it. Valid for 60 seconds. Requires the
7627
+ * target, whichever key issued it. Valid for 10 minutes. Requires the
7502
7628
  * owner wallet signer.
7503
7629
  */
7504
7630
  async signOwnerRevocation(cid) {
@@ -7514,7 +7640,7 @@ var _TinyCloudNode = class _TinyCloudNode {
7514
7640
  chainId: session.chainId,
7515
7641
  nonce: generateNonce(),
7516
7642
  issuedAt: issuedAt.toISOString(),
7517
- expirationTime: new Date(issuedAt.getTime() + 6e4).toISOString()
7643
+ expirationTime: new Date(issuedAt.getTime() + OWNER_REVOCATION_WINDOW_MS).toISOString()
7518
7644
  }).prepareMessage();
7519
7645
  const signature = await this.signer.signMessage(siwe);
7520
7646
  return this.wasmBindings.siweToDelegationHeaders({ siwe, signature }).Authorization;
@@ -7741,6 +7867,40 @@ var _TinyCloudNode = class _TinyCloudNode {
7741
7867
  get encryption() {
7742
7868
  return this.getEncryptionService();
7743
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
+ }
7744
7904
  async getEncryptionNetwork(nameOrNetworkId = this.getDefaultEncryptionNetworkId()) {
7745
7905
  const networkId = nameOrNetworkId.startsWith("urn:tinycloud:encryption:") ? nameOrNetworkId : this.getDefaultEncryptionNetworkId(nameOrNetworkId);
7746
7906
  return this.fetchEncryptionNetworkAt(
@@ -10015,7 +10175,7 @@ import {
10015
10175
  CaveatedDelegationUnsupportedError as CaveatedDelegationUnsupportedError3,
10016
10176
  PermissionNotInManifestError as PermissionNotInManifestError2,
10017
10177
  SessionExpiredError as SessionExpiredError2,
10018
- ManifestValidationError,
10178
+ ManifestValidationError as ManifestValidationError2,
10019
10179
  composeManifestRequest as composeManifestRequest2,
10020
10180
  resolveManifest as resolveManifest2,
10021
10181
  validateManifest,
@@ -10100,12 +10260,13 @@ export {
10100
10260
  IdentityParseError,
10101
10261
  InvalidRestoredSessionError,
10102
10262
  KVService3 as KVService,
10103
- ManifestValidationError,
10263
+ ManifestValidationError2 as ManifestValidationError,
10104
10264
  MemorySessionStorage,
10105
10265
  NodeUserAuthorization,
10106
10266
  PermissionNotInManifestError2 as PermissionNotInManifestError,
10107
10267
  PrefixedKVService,
10108
10268
  ProtocolMismatchError2 as ProtocolMismatchError,
10269
+ RuntimeDelegationRejectedError,
10109
10270
  SECRET_NAME_RE,
10110
10271
  SQLAction,
10111
10272
  SQLService3 as SQLService,
@@ -10128,6 +10289,7 @@ export {
10128
10289
  VersionCheckError,
10129
10290
  WasmKeyProvider,
10130
10291
  activateCompactRuntimeDelegation,
10292
+ activateValidatedRuntimeDelegation,
10131
10293
  addressStorageKey,
10132
10294
  buildSpaceUri,
10133
10295
  canonicalizeAddress3 as canonicalizeAddress,