@tinycloud/node-sdk 3.8.0-beta.2 → 3.8.0-beta.4

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,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-DgVV80bI.cjs';
4
+ import { _ as __authority } from './authority-gdjLIlC3.cjs';
5
5
  import { _ as __runtime } from './runtime-mRhSu-vJ.cjs';
6
6
  import { ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
7
7
  export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider } 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-CVO41O12.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-CxRHpusk.cjs';
9
9
  export { C as CompactRuntimeDelegationInput, P as PortableDelegation, V as ValidatedRuntimeDelegation, a as activateCompactRuntimeDelegation, d as deserializeDelegation, s as serializeDelegation } from './delegation-0LKZkmP2.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-DGi1hIMK.js';
4
+ import { _ as __authority } from './authority-BV9Nwh8x.js';
5
5
  import { _ as __runtime } from './runtime-CO4VXnPq.js';
6
6
  import { ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
7
7
  export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider } 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-B6VOBrCb.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-BKFo3t4u.js';
9
9
  export { C as CompactRuntimeDelegationInput, P as PortableDelegation, V as ValidatedRuntimeDelegation, a as activateCompactRuntimeDelegation, d as deserializeDelegation, s as serializeDelegation } from './delegation-0LKZkmP2.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";
@@ -3841,6 +3904,7 @@ var _TinyCloudNode = class _TinyCloudNode {
3841
3904
  return void 0;
3842
3905
  }
3843
3906
  };
3907
+ this._keysUnavailable = [];
3844
3908
  this._baseVaults = /* @__PURE__ */ new Map();
3845
3909
  this._baseSecrets = /* @__PURE__ */ new Map();
3846
3910
  this._secrets = /* @__PURE__ */ new Map();
@@ -4668,6 +4732,8 @@ var _TinyCloudNode = class _TinyCloudNode {
4668
4732
  this._hooks = void 0;
4669
4733
  this._vault = void 0;
4670
4734
  this._encryption = void 0;
4735
+ this._namedKeyClient = void 0;
4736
+ this._keysUnavailable = [];
4671
4737
  this._baseVaults.clear();
4672
4738
  this._baseSecrets.clear();
4673
4739
  this._secrets.clear();
@@ -4790,6 +4856,8 @@ var _TinyCloudNode = class _TinyCloudNode {
4790
4856
  this._hooks = void 0;
4791
4857
  this._vault = void 0;
4792
4858
  this._encryption = void 0;
4859
+ this._namedKeyClient = void 0;
4860
+ this._keysUnavailable = [];
4793
4861
  this._baseVaults.clear();
4794
4862
  this._baseSecrets.clear();
4795
4863
  this._secrets.clear();
@@ -4842,6 +4910,26 @@ var _TinyCloudNode = class _TinyCloudNode {
4842
4910
  this.assertSessionEpoch(epoch, "Sign-in");
4843
4911
  await this.ensureRequestedEncryptionNetworks();
4844
4912
  this.assertSessionEpoch(epoch, "Sign-in");
4913
+ this._keysUnavailable = this.auth?.unavailableKeyPaths ?? [];
4914
+ if (this._keysUnavailable.length > 0) {
4915
+ this.notificationHandler.warning(`Named keys unavailable: ${this._keysUnavailable.join(", ")}`);
4916
+ }
4917
+ if (this.nodeFeatures.includes("encryption-named-keys-v1")) {
4918
+ for (const manifest of this.auth?.capabilityRequest?.manifests ?? []) {
4919
+ for (const declaration of manifest.keys ?? []) {
4920
+ if ("path" in declaration && declaration.abilities.includes("key.create") && !this._keysUnavailable.includes(declaration.path)) {
4921
+ try {
4922
+ await this.keys.ensureKey(declaration.path);
4923
+ } catch (error) {
4924
+ this._keysUnavailable.push(declaration.path);
4925
+ const code = error && typeof error === "object" && "code" in error && typeof error.code === "string" && /^[A-Z_]+$/.test(error.code) ? error.code : "UNKNOWN";
4926
+ this.notificationHandler.warning(`Named key unavailable: ${declaration.path} (${code})`);
4927
+ }
4928
+ this.assertSessionEpoch(epoch, "Sign-in");
4929
+ }
4930
+ }
4931
+ }
4932
+ }
4845
4933
  if (!bootstrapped && this.config.manifest === void 0 && this.config.capabilityRequest === void 0) {
4846
4934
  await this.ensureOwnedSpaceHostedById(this.ownedSpaceId(SECRETS_SPACE2));
4847
4935
  }
@@ -5629,7 +5717,8 @@ var _TinyCloudNode = class _TinyCloudNode {
5629
5717
  const networkIds = /* @__PURE__ */ new Set();
5630
5718
  for (const resource of request.resources) {
5631
5719
  if (resource.service === ENCRYPTION_PERMISSION_SERVICE2 && resource.path.startsWith("urn:tinycloud:encryption:") && resource.actions.includes(DECRYPT_ACTION2)) {
5632
- networkIds.add(resource.path);
5720
+ const parsed = resource.path.includes("/") ? parseEncryptionResource2(resource.path) : { ...parseNetworkId2(resource.path), kind: "network" };
5721
+ if (parsed.kind === "network") networkIds.add(resource.path);
5633
5722
  }
5634
5723
  }
5635
5724
  return [...networkIds];
@@ -6179,6 +6268,8 @@ var _TinyCloudNode = class _TinyCloudNode {
6179
6268
  this._hooks = stagedGraph.hooks;
6180
6269
  this._vault = stagedGraph.vault;
6181
6270
  this._encryption = stagedGraph.encryption;
6271
+ this._namedKeyClient = void 0;
6272
+ this._keysUnavailable = [];
6182
6273
  this._capabilityRegistry = stagedGraph.capabilityRegistry;
6183
6274
  this._keyProvider = stagedGraph.keyProvider;
6184
6275
  this._sharingService = stagedGraph.sharingService;
@@ -7775,6 +7866,40 @@ var _TinyCloudNode = class _TinyCloudNode {
7775
7866
  get encryption() {
7776
7867
  return this.getEncryptionService();
7777
7868
  }
7869
+ /** Named keys bound to the current session. */
7870
+ get keys() {
7871
+ return new Proxy({}, {
7872
+ get: (_target, property) => {
7873
+ if (property === "refreshNodeInfo") {
7874
+ return () => {
7875
+ void this._namedKeyClient?.then((client) => client.refreshNodeInfo());
7876
+ };
7877
+ }
7878
+ if (typeof property !== "string" || ![
7879
+ "getPublicKey",
7880
+ "describeKey",
7881
+ "createKey",
7882
+ "blockKey",
7883
+ "unblockKey",
7884
+ "ensureKey",
7885
+ "encrypt",
7886
+ "decrypt",
7887
+ "decryptMany"
7888
+ ].includes(property)) return void 0;
7889
+ return (...args) => {
7890
+ this._namedKeyClient ?? (this._namedKeyClient = import("./encryption-keys.js").then(({ createNamedKeyClient }) => createNamedKeyClient(this)));
7891
+ return this._namedKeyClient.then((client) => {
7892
+ const method = client[property];
7893
+ return method.apply(client, args);
7894
+ });
7895
+ };
7896
+ }
7897
+ });
7898
+ }
7899
+ /** Manifest key paths unavailable during the latest `signIn()` attempt. */
7900
+ get keysUnavailable() {
7901
+ return this._keysUnavailable;
7902
+ }
7778
7903
  async getEncryptionNetwork(nameOrNetworkId = this.getDefaultEncryptionNetworkId()) {
7779
7904
  const networkId = nameOrNetworkId.startsWith("urn:tinycloud:encryption:") ? nameOrNetworkId : this.getDefaultEncryptionNetworkId(nameOrNetworkId);
7780
7905
  return this.fetchEncryptionNetworkAt(
@@ -10049,7 +10174,7 @@ import {
10049
10174
  CaveatedDelegationUnsupportedError as CaveatedDelegationUnsupportedError3,
10050
10175
  PermissionNotInManifestError as PermissionNotInManifestError2,
10051
10176
  SessionExpiredError as SessionExpiredError2,
10052
- ManifestValidationError,
10177
+ ManifestValidationError as ManifestValidationError2,
10053
10178
  composeManifestRequest as composeManifestRequest2,
10054
10179
  resolveManifest as resolveManifest2,
10055
10180
  validateManifest,
@@ -10134,7 +10259,7 @@ export {
10134
10259
  IdentityParseError,
10135
10260
  InvalidRestoredSessionError,
10136
10261
  KVService3 as KVService,
10137
- ManifestValidationError,
10262
+ ManifestValidationError2 as ManifestValidationError,
10138
10263
  MemorySessionStorage,
10139
10264
  NodeUserAuthorization,
10140
10265
  PermissionNotInManifestError2 as PermissionNotInManifestError,