@tinycloud/node-sdk 3.1.0-beta.11 → 3.1.0-beta.13

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,4 +1,4 @@
1
1
  export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, 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, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, ParsedSecretCatalogKey, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PkhDidParts, PrefixedKVService, ProtocolMismatchError, QueryOptions, QueryResponse, ReceiveOptions, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ResolvedCapabilities, ResolvedDelegate, ResolvedSecretPath, ResourceCapability, SECRET_NAME_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, SecretCatalogEntry, SecretPayload, SecretScopeOptions, SecretsError, SecretsService, ServiceContext, ServiceContextConfig, ServiceSession, SessionExpiredError, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignInOptions, SignRequest, SignResponse, SilentNotificationHandler, Space, SpaceAbilitiesMap, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, TableInfo, TelemetryConfig, TelemetryEventHandler, TinyCloud, TinyCloudConfig, TinyCloudDebugEnableOptions, TinyCloudDebugEvent, TinyCloudDebugLevel, TinyCloudDebugLogger, TinyCloudDebugTimer, TinyCloudSession, UnsupportedFeatureError, VAULT_PERMISSION_SERVICE, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultNetworkReadResult, VaultPublicSpaceKVActions, VaultPutOptions, VersionCheckError, ViewInfo, WasmVaultFunctions, addressStorageKey, buildSpaceUri, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, canonicalizeSecretScope, checkNodeInfo, clearTinyCloudDebugLogs, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, createVaultCrypto, defaultSpaceCreationHandler, didCacheKey, didEquals, disableTinyCloudDebug, enableTinyCloudDebug, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, isCapabilitySubset, isEvmAddress, loadManifest, makePkhSpaceId, makePublicSpaceId, parseCanonicalNetworkId, parseExpiry, parsePkhDid, parseSecretCatalogKey, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, tinyCloudDebugLogger, validateManifest } from '@tinycloud/sdk-core';
2
- export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, F as FileSessionStorage, I as InvalidRestoredSessionError, M as MemorySessionStorage, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, k as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, P as PortableDelegation, p as RuntimePermissionGrantOptions, S as SecretPermissionHint, q as SecretReadInput, r as SecretReadResult, t as SignStrategy, T as TinyCloudNode, u as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, v as UnifiedOwnerRootReceipt, w as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, W as WasmKeyProvider, y as WasmKeyProviderConfig, z as activateCompactRuntimeDelegation, H as createWasmKeyProvider, J as defaultSignStrategy, K as deserializeDelegation, Q as serializeDelegation } from './core-CJiLya1s.cjs';
2
+ export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, F as FileSessionStorage, I as InvalidRestoredSessionError, M as MemorySessionStorage, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, k as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, P as PortableDelegation, p as RuntimePermissionGrantOptions, S as SecretPermissionHint, q as SecretReadInput, r as SecretReadResult, t as SignStrategy, T as TinyCloudNode, u as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, v as UnifiedOwnerRootReceipt, w as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, W as WasmKeyProvider, y as WasmKeyProviderConfig, z as activateCompactRuntimeDelegation, H as createWasmKeyProvider, J as defaultSignStrategy, K as deserializeDelegation, Q as serializeDelegation } from './core-CMDgVfBj.cjs';
3
3
  import 'events';
4
4
  import '@tinycloud/sdk-services';
package/dist/core.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, 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, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, ParsedSecretCatalogKey, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PkhDidParts, PrefixedKVService, ProtocolMismatchError, QueryOptions, QueryResponse, ReceiveOptions, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ResolvedCapabilities, ResolvedDelegate, ResolvedSecretPath, ResourceCapability, SECRET_NAME_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, SecretCatalogEntry, SecretPayload, SecretScopeOptions, SecretsError, SecretsService, ServiceContext, ServiceContextConfig, ServiceSession, SessionExpiredError, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignInOptions, SignRequest, SignResponse, SilentNotificationHandler, Space, SpaceAbilitiesMap, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, TableInfo, TelemetryConfig, TelemetryEventHandler, TinyCloud, TinyCloudConfig, TinyCloudDebugEnableOptions, TinyCloudDebugEvent, TinyCloudDebugLevel, TinyCloudDebugLogger, TinyCloudDebugTimer, TinyCloudSession, UnsupportedFeatureError, VAULT_PERMISSION_SERVICE, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultNetworkReadResult, VaultPublicSpaceKVActions, VaultPutOptions, VersionCheckError, ViewInfo, WasmVaultFunctions, addressStorageKey, buildSpaceUri, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, canonicalizeSecretScope, checkNodeInfo, clearTinyCloudDebugLogs, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, createVaultCrypto, defaultSpaceCreationHandler, didCacheKey, didEquals, disableTinyCloudDebug, enableTinyCloudDebug, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, isCapabilitySubset, isEvmAddress, loadManifest, makePkhSpaceId, makePublicSpaceId, parseCanonicalNetworkId, parseExpiry, parsePkhDid, parseSecretCatalogKey, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, tinyCloudDebugLogger, validateManifest } from '@tinycloud/sdk-core';
2
- export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, F as FileSessionStorage, I as InvalidRestoredSessionError, M as MemorySessionStorage, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, k as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, P as PortableDelegation, p as RuntimePermissionGrantOptions, S as SecretPermissionHint, q as SecretReadInput, r as SecretReadResult, t as SignStrategy, T as TinyCloudNode, u as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, v as UnifiedOwnerRootReceipt, w as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, W as WasmKeyProvider, y as WasmKeyProviderConfig, z as activateCompactRuntimeDelegation, H as createWasmKeyProvider, J as defaultSignStrategy, K as deserializeDelegation, Q as serializeDelegation } from './core-CJiLya1s.js';
2
+ export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, F as FileSessionStorage, I as InvalidRestoredSessionError, M as MemorySessionStorage, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, k as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, P as PortableDelegation, p as RuntimePermissionGrantOptions, S as SecretPermissionHint, q as SecretReadInput, r as SecretReadResult, t as SignStrategy, T as TinyCloudNode, u as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, v as UnifiedOwnerRootReceipt, w as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, W as WasmKeyProvider, y as WasmKeyProviderConfig, z as activateCompactRuntimeDelegation, H as createWasmKeyProvider, J as defaultSignStrategy, K as deserializeDelegation, Q as serializeDelegation } from './core-CMDgVfBj.js';
3
3
  import 'events';
4
4
  import '@tinycloud/sdk-services';
package/dist/core.js CHANGED
@@ -2708,15 +2708,21 @@ var _TinyCloudNode = class _TinyCloudNode {
2708
2708
  if (!this.wasmBindings.invokeAny) {
2709
2709
  throw new Error("WASM binding does not support invokeAny");
2710
2710
  }
2711
- const operations = entries.flatMap((entry) => {
2711
+ const routedEntries = entries;
2712
+ const operations = routedEntries.flatMap((entry) => {
2712
2713
  const operation = this.operationFromInvokeAnyEntry(entry);
2713
2714
  return operation ? [operation] : [];
2714
2715
  });
2715
- const grant = this.findGrantForOperations(operations);
2716
- const invocationSession = !grant || grant.provenance === "primary" ? session : grant.session;
2717
- const caveatPreservingEntries = grant ? entries.map((entry) => {
2716
+ const authorityCid = routedEntries.length === 1 ? routedEntries[0]?.revokeAuthorityCid : void 0;
2717
+ const explicitGrant = authorityCid === void 0 ? void 0 : this.runtimePermissionGrants.find((grant2) => grant2.delegation.cid === authorityCid);
2718
+ if (authorityCid !== void 0 && !explicitGrant) {
2719
+ throw new Error(`Explicit revocation authority ${authorityCid} is not installed.`);
2720
+ }
2721
+ const grant = explicitGrant ?? this.findGrantForOperations(operations);
2722
+ const invocationSession = explicitGrant ? explicitGrant.session : !grant || grant.provenance === "primary" ? session : grant.session;
2723
+ const caveatPreservingEntries = routedEntries.map(({ revokeAuthorityCid: _cid, ...entry }) => {
2718
2724
  const requested = this.operationFromInvokeAnyEntry(entry);
2719
- const granted = requested && grant.operations.find(
2725
+ const granted = grant && requested && grant.operations.find(
2720
2726
  (candidate) => this.operationCovers(candidate, requested)
2721
2727
  );
2722
2728
  if (!granted?.caveats?.length) {
@@ -2726,7 +2732,7 @@ var _TinyCloudNode = class _TinyCloudNode {
2726
2732
  throw new Error("Invocation caveats do not match signed ReCap authority.");
2727
2733
  }
2728
2734
  return { ...entry, caveats: cloneRecapCaveats(granted.caveats) };
2729
- }) : entries;
2735
+ });
2730
2736
  return this.wasmBindings.invokeAny(invocationSession, caveatPreservingEntries, facts);
2731
2737
  };
2732
2738
  this.explicitHost = config.host;
@@ -4072,6 +4078,7 @@ var _TinyCloudNode = class _TinyCloudNode {
4072
4078
  stagedSessionExpiry,
4073
4079
  stagedRecap
4074
4080
  );
4081
+ const stagedAccountSpaceId = stagedAddress ? this.wasmBindings.makeSpaceId(stagedAddress, stagedChainId, ACCOUNT_REGISTRY_SPACE2) : void 0;
4075
4082
  const stagedGraph = this.stageRestoredServiceGraph({
4076
4083
  host: stagedHost,
4077
4084
  manager: stagedManager,
@@ -4080,6 +4087,7 @@ var _TinyCloudNode = class _TinyCloudNode {
4080
4087
  nodeDid: stagedNodeDid,
4081
4088
  address: stagedAddress,
4082
4089
  chainId: stagedChainId,
4090
+ accountSpaceId: stagedAccountSpaceId,
4083
4091
  tinyCloudSession: stagedTcSession,
4084
4092
  sessionExpiry: stagedSessionExpiry,
4085
4093
  recap: stagedRecap
@@ -4245,6 +4253,7 @@ var _TinyCloudNode = class _TinyCloudNode {
4245
4253
  }
4246
4254
  const delegationManager = new DelegationManager({
4247
4255
  hosts: [input.host],
4256
+ accountSpaceId: input.accountSpaceId,
4248
4257
  session: input.serviceSession,
4249
4258
  invoke: graph.invoke,
4250
4259
  invokeAny: graph.invokeAny,
@@ -5949,6 +5958,14 @@ var _TinyCloudNode = class _TinyCloudNode {
5949
5958
  delegation.delegationHeader
5950
5959
  );
5951
5960
  if (!activateResult.success) {
5961
+ if (this.operationsFromDelegation(delegation).some(
5962
+ (operation) => operation.resource?.startsWith("urn:cid:") === true && operation.service === "delegation" && operation.action === "tinycloud.delegation/revoke"
5963
+ ) && activateResult.status === 401 && /Cannot find parent delegation/i.test(activateResult.error ?? "")) {
5964
+ throw Object.assign(
5965
+ new Error("The host cannot activate a root raw-CID revoke authority without a parent delegation."),
5966
+ { code: "RAW_RECAP_RESOURCE_UNSUPPORTED", cause: activateResult }
5967
+ );
5968
+ }
5952
5969
  throw Object.assign(
5953
5970
  new Error(`Failed to activate runtime permission delegation: ${describeHostFailure2(activateResult)}`),
5954
5971
  { cause: activateResult }
@@ -5996,10 +6013,10 @@ var _TinyCloudNode = class _TinyCloudNode {
5996
6013
  }
5997
6014
  this.assertDelegationCaveatsPreservable(expanded);
5998
6015
  const rawEntries = expanded.filter(
5999
- (entry) => this.isEncryptionPermissionEntry(entry)
6016
+ (entry) => this.isEncryptionPermissionEntry(entry) || this.isRawRevocationPermissionEntry(entry)
6000
6017
  );
6001
6018
  const spaceEntries = expanded.filter(
6002
- (entry) => !this.isEncryptionPermissionEntry(entry)
6019
+ (entry) => !this.isEncryptionPermissionEntry(entry) && !this.isRawRevocationPermissionEntry(entry)
6003
6020
  );
6004
6021
  const bySpace = /* @__PURE__ */ new Map();
6005
6022
  for (const entry of spaceEntries) {
@@ -6026,17 +6043,29 @@ var _TinyCloudNode = class _TinyCloudNode {
6026
6043
  }
6027
6044
  const delegatedEntries = [...entries, ...rawForDelegation];
6028
6045
  const abilities = this.permissionsToAbilities(entries);
6029
- const prepared = this.wasmBindings.prepareSession({
6030
- abilities,
6031
- ...rawForDelegation.length > 0 ? { rawAbilities: this.permissionsToRawAbilities(rawForDelegation) } : {},
6032
- address: this.wasmBindings.ensureEip55(session.address),
6033
- chainId: session.chainId,
6034
- domain: this.siweDomain,
6035
- issuedAt: now.toISOString(),
6036
- expirationTime: expiresAt.toISOString(),
6037
- spaceId,
6038
- jwk: session.jwk
6039
- });
6046
+ const prepared = (() => {
6047
+ try {
6048
+ return this.wasmBindings.prepareSession({
6049
+ abilities,
6050
+ ...rawForDelegation.length > 0 ? { rawAbilities: this.permissionsToRawAbilities(rawForDelegation) } : {},
6051
+ address: this.wasmBindings.ensureEip55(session.address),
6052
+ chainId: session.chainId,
6053
+ domain: this.siweDomain,
6054
+ issuedAt: now.toISOString(),
6055
+ expirationTime: expiresAt.toISOString(),
6056
+ spaceId,
6057
+ jwk: session.jwk
6058
+ });
6059
+ } catch (error) {
6060
+ if (rawForDelegation.some((entry) => this.isRawRevocationPermissionEntry(entry)) && /invalid ReCap resource URI/i.test(error instanceof Error ? error.message : String(error))) {
6061
+ throw Object.assign(
6062
+ new Error("This WASM build cannot encode raw urn:cid ReCap resources."),
6063
+ { code: "RAW_RECAP_RESOURCE_UNSUPPORTED", cause: error }
6064
+ );
6065
+ }
6066
+ throw error;
6067
+ }
6068
+ })();
6040
6069
  const signature = await this.signer.signMessage(prepared.siwe);
6041
6070
  const delegatedSession = this.wasmBindings.completeSessionSetup({
6042
6071
  ...prepared,
@@ -6047,6 +6076,12 @@ var _TinyCloudNode = class _TinyCloudNode {
6047
6076
  delegatedSession.delegationHeader
6048
6077
  );
6049
6078
  if (!activateResult.success) {
6079
+ if (rawForDelegation.some((entry) => this.isRawRevocationPermissionEntry(entry)) && activateResult.status === 401 && /Cannot find parent delegation/i.test(activateResult.error ?? "")) {
6080
+ throw Object.assign(
6081
+ new Error("The host cannot activate a root raw-CID revoke authority without a parent delegation."),
6082
+ { code: "RAW_RECAP_RESOURCE_UNSUPPORTED", cause: activateResult }
6083
+ );
6084
+ }
6050
6085
  throw Object.assign(
6051
6086
  new Error(`Failed to activate runtime permission delegation: ${describeHostFailure2(activateResult)}`),
6052
6087
  { cause: activateResult }
@@ -6748,6 +6783,7 @@ var _TinyCloudNode = class _TinyCloudNode {
6748
6783
  permissionsToAbilities(entries) {
6749
6784
  const abilities = {};
6750
6785
  for (const entry of entries) {
6786
+ if (this.isRawRevocationPermissionEntry(entry)) continue;
6751
6787
  const service = this.shortServiceName(entry.service);
6752
6788
  abilities[service] ?? (abilities[service] = {});
6753
6789
  const existing = abilities[service][entry.path] ?? [];
@@ -6765,9 +6801,16 @@ var _TinyCloudNode = class _TinyCloudNode {
6765
6801
  isEncryptionPermissionEntry(entry) {
6766
6802
  return entry.service === ENCRYPTION_PERMISSION_SERVICE2 && this.isEncryptionNetworkOperation("encryption", entry.path, entry.space);
6767
6803
  }
6804
+ isRawRevocationPermissionEntry(entry) {
6805
+ return entry.service === "tinycloud.delegation" && entry.path === "" && entry.space?.startsWith("urn:cid:") === true && entry.actions.includes("tinycloud.delegation/revoke");
6806
+ }
6768
6807
  permissionsToRawAbilities(entries) {
6769
6808
  const rawAbilities = {};
6770
6809
  for (const entry of entries) {
6810
+ if (this.isRawRevocationPermissionEntry(entry)) {
6811
+ rawAbilities[entry.space] = [...new Set(entry.actions)];
6812
+ continue;
6813
+ }
6771
6814
  if (!this.isEncryptionPermissionEntry(entry)) {
6772
6815
  continue;
6773
6816
  }
@@ -6787,7 +6830,7 @@ var _TinyCloudNode = class _TinyCloudNode {
6787
6830
  return entries.flatMap((entry) => {
6788
6831
  const service = this.shortServiceName(entry.service);
6789
6832
  return entry.actions.map((action) => ({
6790
- ...this.isEncryptionNetworkOperation(service, entry.path, entry.space) ? { resource: entry.path } : { spaceId },
6833
+ ...this.isRawRevocationPermissionEntry(entry) ? { resource: entry.space } : this.isEncryptionNetworkOperation(service, entry.path, entry.space) ? { resource: entry.path } : { spaceId },
6791
6834
  service,
6792
6835
  path: entry.path,
6793
6836
  action,
@@ -6797,11 +6840,13 @@ var _TinyCloudNode = class _TinyCloudNode {
6797
6840
  }
6798
6841
  /** Raw network authority cannot be covered by a nested encryption space. */
6799
6842
  signedCapabilitySubset(requested, granted) {
6800
- const rawGranted = granted.filter((entry) => this.isEncryptionPermissionEntry(entry)).map((entry) => ({ ...entry, space: "encryption" }));
6801
- const spaceGranted = granted.filter((entry) => !this.isEncryptionPermissionEntry(entry));
6843
+ const rawGranted = granted.filter((entry) => this.isEncryptionPermissionEntry(entry) || this.isRawRevocationPermissionEntry(entry)).map((entry) => this.isEncryptionPermissionEntry(entry) ? { ...entry, space: "encryption" } : entry);
6844
+ const spaceGranted = granted.filter(
6845
+ (entry) => !this.isEncryptionPermissionEntry(entry) && !this.isRawRevocationPermissionEntry(entry)
6846
+ );
6802
6847
  const missing = requested.filter((entry) => {
6803
- const raw = this.isEncryptionPermissionEntry(entry);
6804
- const comparable = raw ? { ...entry, space: "encryption" } : entry;
6848
+ const raw = this.isEncryptionPermissionEntry(entry) || this.isRawRevocationPermissionEntry(entry);
6849
+ const comparable = raw && this.isEncryptionPermissionEntry(entry) ? { ...entry, space: "encryption" } : entry;
6805
6850
  return !isCapabilitySubset([comparable], raw ? rawGranted : spaceGranted).subset;
6806
6851
  });
6807
6852
  return { subset: missing.length === 0, missing };
@@ -6816,10 +6861,11 @@ var _TinyCloudNode = class _TinyCloudNode {
6816
6861
  }
6817
6862
  permissionEntriesToOperations(entries, session) {
6818
6863
  return entries.flatMap((entry) => {
6819
- const spaceId = this.resolvePermissionSpace(entry.space, session);
6864
+ const rawRevocation = this.isRawRevocationPermissionEntry(entry);
6865
+ const spaceId = rawRevocation ? void 0 : this.resolvePermissionSpace(entry.space, session);
6820
6866
  const service = this.shortServiceName(entry.service);
6821
6867
  return entry.actions.map((action) => ({
6822
- ...this.isEncryptionNetworkOperation(service, entry.path, entry.space) ? { resource: entry.path } : { spaceId },
6868
+ ...rawRevocation ? { resource: entry.space } : this.isEncryptionNetworkOperation(service, entry.path, entry.space) ? { resource: entry.path } : { spaceId },
6823
6869
  service,
6824
6870
  path: entry.path,
6825
6871
  action,
@@ -6898,7 +6944,7 @@ var _TinyCloudNode = class _TinyCloudNode {
6898
6944
  delegatedResourcesForEntries(entries, spaceId) {
6899
6945
  return entries.map((entry) => ({
6900
6946
  service: this.shortServiceName(entry.service),
6901
- space: this.isEncryptionPermissionEntry(entry) ? "encryption" : spaceId,
6947
+ space: this.isRawRevocationPermissionEntry(entry) ? entry.space : this.isEncryptionPermissionEntry(entry) ? "encryption" : spaceId,
6902
6948
  path: entry.path,
6903
6949
  actions: [...entry.actions],
6904
6950
  ...entry.caveats === void 0 ? {} : { caveats: cloneRecapCaveats(entry.caveats) }
@@ -6908,8 +6954,9 @@ var _TinyCloudNode = class _TinyCloudNode {
6908
6954
  const resources = delegation.resources !== void 0 && delegation.resources.length > 0 ? delegation.resources : this.flatDelegationResources(delegation);
6909
6955
  return resources.flatMap((resource) => {
6910
6956
  const service = this.invocationServiceName(resource.service);
6957
+ const rawRevocation = service === "delegation" && resource.space.startsWith("urn:cid:") && resource.path === "";
6911
6958
  return resource.actions.map((action) => ({
6912
- ...this.isEncryptionNetworkOperation(service, resource.path, resource.space) ? { resource: resource.path } : { spaceId: resource.space },
6959
+ ...rawRevocation ? { resource: resource.space } : this.isEncryptionNetworkOperation(service, resource.path, resource.space) ? { resource: resource.path } : { spaceId: resource.space },
6913
6960
  service,
6914
6961
  path: resource.path,
6915
6962
  action,
@@ -6955,7 +7002,7 @@ var _TinyCloudNode = class _TinyCloudNode {
6955
7002
  * @internal
6956
7003
  */
6957
7004
  buildActivationAbilities(delegation) {
6958
- var _a, _b, _c;
7005
+ var _a, _b, _c, _d;
6959
7006
  const resources = delegation.resources !== void 0 && delegation.resources.length > 0 ? delegation.resources : this.flatDelegationResources(delegation);
6960
7007
  const abilities = {};
6961
7008
  const rawAbilities = {};
@@ -6975,13 +7022,18 @@ var _TinyCloudNode = class _TinyCloudNode {
6975
7022
  addActions(rawAbilities[resource.path], resource.actions);
6976
7023
  continue;
6977
7024
  }
7025
+ if (service === "delegation" && resource.space.startsWith("urn:cid:") && resource.path === "") {
7026
+ rawAbilities[_b = resource.space] ?? (rawAbilities[_b] = []);
7027
+ addActions(rawAbilities[resource.space], resource.actions);
7028
+ continue;
7029
+ }
6978
7030
  if (resource.space !== delegation.spaceId) {
6979
7031
  throw new Error(
6980
7032
  `useDelegation: resource targets space '${resource.space}' but the delegation activates space '${delegation.spaceId}'. Multi-space delegations cannot be activated in a single useDelegation call.`
6981
7033
  );
6982
7034
  }
6983
7035
  abilities[service] ?? (abilities[service] = {});
6984
- (_b = abilities[service])[_c = resource.path] ?? (_b[_c] = []);
7036
+ (_c = abilities[service])[_d = resource.path] ?? (_c[_d] = []);
6985
7037
  addActions(abilities[service][resource.path], resource.actions);
6986
7038
  }
6987
7039
  return { abilities, rawAbilities };