@tinycloud/node-sdk 3.1.0-beta.9 → 3.2.0-beta.0
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-CC7uDKZP.d.cts → core-AEx5vAa8.d.cts} +21 -0
- package/dist/{core-CC7uDKZP.d.ts → core-AEx5vAa8.d.ts} +21 -0
- package/dist/core.cjs +171 -85
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +171 -85
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +171 -85
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +171 -85
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ISigner, Bytes, CapabilityPresentationEnvelopeV1, IWasmBindings, PersistedSessionProof, ISessionManager } from '@tinycloud/sdk-core';
|
|
2
2
|
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationPage, AccountDelegationQueryOptions, AccountDelegationRecord, AccountDelegationResource, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, BuildCanonicalDecryptRequestInput, BuildDecryptFactsInput, BuildDecryptInvocationInput, BuiltDecryptInvocation, CallbackStrategy, CanonicalAddress, CanonicalDecryptRequest, CanonicalJson, CanonicalParsedNetworkId, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, CaveatedDelegationUnsupportedError, ClientSession, ColumnInfo, ComposeManifestOptions, ComposedManifestRequest, CreateDelegationParams, DECRYPT_ACTION, DECRYPT_FACT_TYPE, DECRYPT_RESULT_TYPE, DEFAULT_ENCRYPTION_ALG, DEFAULT_KEY_VERSION, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DataVaultConfig, DataVaultService, DatabaseHandle, DecryptCapabilityProof, DecryptEnvelopeOptions, DecryptInvocationFact, DecryptInvocationSigner, DecryptRequestBody, DecryptResponseBody, DecryptTransport, DecryptTransportResponseError, DelegateReceivedShareParams, DelegatedShareAccess, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DelegationRevocationReceipt, DidCacheKeyOptions, DidEqualsOptions, DiscoverNetworkInput, DiscoveredNetwork, DiscoverySource, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, ENCRYPTION_NETWORK_URN_PREFIX, ENCRYPTION_SERVICE, ENCRYPTION_SERVICE_SHORT, ENVELOPE_VERSION, EncodedShareData, EncryptToNetworkInput, EncryptToNetworkOptions, EncryptToNetworkResult, EncryptionCrypto, EncryptionError, EncryptionErrorInput, EncryptionService, EncryptionServiceConfig, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, HookEvent, HookServiceName, HookStreamEvent, HookSubscription, HookWebhookListOptions, HookWebhookRecord, HookWebhookRegistration, HookWebhookScope, HookWebhookUnregisterOptions, HooksService, HooksServiceConfig, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IEncryptionService, IHooksService, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISecretsService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IdentityParseError, IngestOptions, InlineEncryptedEnvelope, InvokeFunction, JWK, KVBatchReadResponse, KVCreateSignedReadUrlOptions, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, NETWORK_NAME_PATTERN, NetworkDescriptor, NetworkIdError, NodeDescriptorFetcher, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, OwnerDelegationPermission, ParsedNetworkId, ParsedSecretCatalogKey, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PkhDidParts, PrefixedKVService, ProtocolMismatchError, QueryOptions, QueryResponse, RandomReceiverKeyInput, ReceiveOptions, ReceiverKeyPair, ReceiverKeySigner, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ResolvedCapabilities, ResolvedDelegate, ResolvedSecretPath, ResourceCapability, SECRET_NAME_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, STORAGE_FULL_MESSAGE, STORAGE_WRITE_TOO_LARGE_MESSAGE, SchemaInfo, SecretCatalogEntry, SecretPayload, SecretScopeOptions, SecretsError, SecretsService, ServiceContext, ServiceContextConfig, ServiceSession, SessionExpiredError, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignInOptions, SignRequest, SignResponse, SignedReceiverKeyInput, SilentNotificationHandler, Space, SpaceAbilitiesMap, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, SubscribeOptions, 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, VerifyDecryptResponseInput, VersionCheckError, ViewInfo, WasmVaultFunctions, WellKnownDescriptorFetcher, addressStorageKey, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, buildSpaceUri, canonicalHashHex, canonicalSignedResponse, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeEncryptionJson, canonicalizeNetworkId, canonicalizeSecretScope, checkDecryptInvocationInput, checkNodeInfo, clearTinyCloudDebugLogs, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, createVaultCrypto, decryptEnvelopeWithKey, defaultSpaceCreationHandler, deriveSignedReceiverKey, didCacheKey, didEquals, disableTinyCloudDebug, discoverNetwork, enableTinyCloudDebug, encryptToNetwork, encryptionBase64Decode, encryptionBase64Encode, encryptionError, encryptionUtf8Decode, encryptionUtf8Encode, ensureNetworkUsableForDecrypt, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, generateRandomReceiverKey, getTinyCloudDebugLogs, hexDecode, hexEncode, installTinyCloudDebugGlobals, isCapabilitySubset, isEvmAddress, isNetworkId, isStorageFullError, loadManifest, makePkhSpaceId, makePublicSpaceId, networkDiscoveryKey, openWrappedKey, parseCanonicalNetworkId, parseExpiry, parseNetworkId, parsePkhDid, parseSecretCatalogKey, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, tinyCloudDebugLogger, validateEnvelope, validateManifest, verifyDecryptResponse } from '@tinycloud/sdk-core';
|
|
3
|
-
export { A as ACCEPTED_MARKER_VERSIONS, a as AuthDelegationArtifact, b as AuthRequestArtifact, B as BOOTSTRAP_COMPLETION_MARKER_KEY, c as BOOTSTRAP_COMPLETION_MARKER_VERSION, d as BootstrapCompletionMarker, e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, i as DelegationAuthority, 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, R as RUNTIME_DELEGATION_REJECTIONS, l as RestorableSession, m as RuntimeDelegationActivator, n as RuntimeDelegationRejectedError, o as RuntimeDelegationRejection, p as RuntimePermissionGrantOptions, S as SecretPermissionHint, q as SecretReadInput, r as SecretReadResult, s as SessionGrantProof, t as SignStrategy, T as TinyCloudNode, u as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, v as UnifiedOwnerRootReceipt, w as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, x as VerifiedSessionGrant, W as WasmKeyProvider, y as WasmKeyProviderConfig, z as activateCompactRuntimeDelegation, G as activateValidatedRuntimeDelegation, H as createWasmKeyProvider, J as defaultSignStrategy, K as deserializeDelegation, L as grantAuthRequest, Q as serializeDelegation } from './core-
|
|
3
|
+
export { A as ACCEPTED_MARKER_VERSIONS, a as AuthDelegationArtifact, b as AuthRequestArtifact, B as BOOTSTRAP_COMPLETION_MARKER_KEY, c as BOOTSTRAP_COMPLETION_MARKER_VERSION, d as BootstrapCompletionMarker, e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, i as DelegationAuthority, 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, R as RUNTIME_DELEGATION_REJECTIONS, l as RestorableSession, m as RuntimeDelegationActivator, n as RuntimeDelegationRejectedError, o as RuntimeDelegationRejection, p as RuntimePermissionGrantOptions, S as SecretPermissionHint, q as SecretReadInput, r as SecretReadResult, s as SessionGrantProof, t as SignStrategy, T as TinyCloudNode, u as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, v as UnifiedOwnerRootReceipt, w as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, x as VerifiedSessionGrant, W as WasmKeyProvider, y as WasmKeyProviderConfig, z as activateCompactRuntimeDelegation, G as activateValidatedRuntimeDelegation, H as createWasmKeyProvider, J as defaultSignStrategy, K as deserializeDelegation, L as grantAuthRequest, Q as serializeDelegation } from './core-AEx5vAa8.cjs';
|
|
4
4
|
import { invoke, invokeAny, computeCid, prepareSession, completeSessionSetup, ensureEip55, makeSpaceId, createDelegation, parseRecapFromSiwe, parseVerifiedRecapFromSiwe, generateHostSIWEMessage, siweToDelegationHeaders, protocolVersion, vault_encrypt, vault_decrypt, vault_derive_key, vault_x25519_from_seed, vault_x25519_dh, vault_random_bytes, vault_sha256 } from '@tinycloud/node-sdk-wasm';
|
|
5
5
|
import 'events';
|
|
6
6
|
import '@tinycloud/sdk-services';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ISigner, Bytes, CapabilityPresentationEnvelopeV1, IWasmBindings, PersistedSessionProof, ISessionManager } from '@tinycloud/sdk-core';
|
|
2
2
|
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationPage, AccountDelegationQueryOptions, AccountDelegationRecord, AccountDelegationResource, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, BuildCanonicalDecryptRequestInput, BuildDecryptFactsInput, BuildDecryptInvocationInput, BuiltDecryptInvocation, CallbackStrategy, CanonicalAddress, CanonicalDecryptRequest, CanonicalJson, CanonicalParsedNetworkId, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, CaveatedDelegationUnsupportedError, ClientSession, ColumnInfo, ComposeManifestOptions, ComposedManifestRequest, CreateDelegationParams, DECRYPT_ACTION, DECRYPT_FACT_TYPE, DECRYPT_RESULT_TYPE, DEFAULT_ENCRYPTION_ALG, DEFAULT_KEY_VERSION, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DataVaultConfig, DataVaultService, DatabaseHandle, DecryptCapabilityProof, DecryptEnvelopeOptions, DecryptInvocationFact, DecryptInvocationSigner, DecryptRequestBody, DecryptResponseBody, DecryptTransport, DecryptTransportResponseError, DelegateReceivedShareParams, DelegatedShareAccess, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DelegationRevocationReceipt, DidCacheKeyOptions, DidEqualsOptions, DiscoverNetworkInput, DiscoveredNetwork, DiscoverySource, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, ENCRYPTION_NETWORK_URN_PREFIX, ENCRYPTION_SERVICE, ENCRYPTION_SERVICE_SHORT, ENVELOPE_VERSION, EncodedShareData, EncryptToNetworkInput, EncryptToNetworkOptions, EncryptToNetworkResult, EncryptionCrypto, EncryptionError, EncryptionErrorInput, EncryptionService, EncryptionServiceConfig, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, HookEvent, HookServiceName, HookStreamEvent, HookSubscription, HookWebhookListOptions, HookWebhookRecord, HookWebhookRegistration, HookWebhookScope, HookWebhookUnregisterOptions, HooksService, HooksServiceConfig, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IEncryptionService, IHooksService, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISecretsService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IdentityParseError, IngestOptions, InlineEncryptedEnvelope, InvokeFunction, JWK, KVBatchReadResponse, KVCreateSignedReadUrlOptions, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, NETWORK_NAME_PATTERN, NetworkDescriptor, NetworkIdError, NodeDescriptorFetcher, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, OwnerDelegationPermission, ParsedNetworkId, ParsedSecretCatalogKey, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PkhDidParts, PrefixedKVService, ProtocolMismatchError, QueryOptions, QueryResponse, RandomReceiverKeyInput, ReceiveOptions, ReceiverKeyPair, ReceiverKeySigner, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ResolvedCapabilities, ResolvedDelegate, ResolvedSecretPath, ResourceCapability, SECRET_NAME_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, STORAGE_FULL_MESSAGE, STORAGE_WRITE_TOO_LARGE_MESSAGE, SchemaInfo, SecretCatalogEntry, SecretPayload, SecretScopeOptions, SecretsError, SecretsService, ServiceContext, ServiceContextConfig, ServiceSession, SessionExpiredError, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignInOptions, SignRequest, SignResponse, SignedReceiverKeyInput, SilentNotificationHandler, Space, SpaceAbilitiesMap, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, SubscribeOptions, 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, VerifyDecryptResponseInput, VersionCheckError, ViewInfo, WasmVaultFunctions, WellKnownDescriptorFetcher, addressStorageKey, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, buildSpaceUri, canonicalHashHex, canonicalSignedResponse, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeEncryptionJson, canonicalizeNetworkId, canonicalizeSecretScope, checkDecryptInvocationInput, checkNodeInfo, clearTinyCloudDebugLogs, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, createVaultCrypto, decryptEnvelopeWithKey, defaultSpaceCreationHandler, deriveSignedReceiverKey, didCacheKey, didEquals, disableTinyCloudDebug, discoverNetwork, enableTinyCloudDebug, encryptToNetwork, encryptionBase64Decode, encryptionBase64Encode, encryptionError, encryptionUtf8Decode, encryptionUtf8Encode, ensureNetworkUsableForDecrypt, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, generateRandomReceiverKey, getTinyCloudDebugLogs, hexDecode, hexEncode, installTinyCloudDebugGlobals, isCapabilitySubset, isEvmAddress, isNetworkId, isStorageFullError, loadManifest, makePkhSpaceId, makePublicSpaceId, networkDiscoveryKey, openWrappedKey, parseCanonicalNetworkId, parseExpiry, parseNetworkId, parsePkhDid, parseSecretCatalogKey, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, tinyCloudDebugLogger, validateEnvelope, validateManifest, verifyDecryptResponse } from '@tinycloud/sdk-core';
|
|
3
|
-
export { A as ACCEPTED_MARKER_VERSIONS, a as AuthDelegationArtifact, b as AuthRequestArtifact, B as BOOTSTRAP_COMPLETION_MARKER_KEY, c as BOOTSTRAP_COMPLETION_MARKER_VERSION, d as BootstrapCompletionMarker, e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, i as DelegationAuthority, 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, R as RUNTIME_DELEGATION_REJECTIONS, l as RestorableSession, m as RuntimeDelegationActivator, n as RuntimeDelegationRejectedError, o as RuntimeDelegationRejection, p as RuntimePermissionGrantOptions, S as SecretPermissionHint, q as SecretReadInput, r as SecretReadResult, s as SessionGrantProof, t as SignStrategy, T as TinyCloudNode, u as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, v as UnifiedOwnerRootReceipt, w as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, x as VerifiedSessionGrant, W as WasmKeyProvider, y as WasmKeyProviderConfig, z as activateCompactRuntimeDelegation, G as activateValidatedRuntimeDelegation, H as createWasmKeyProvider, J as defaultSignStrategy, K as deserializeDelegation, L as grantAuthRequest, Q as serializeDelegation } from './core-
|
|
3
|
+
export { A as ACCEPTED_MARKER_VERSIONS, a as AuthDelegationArtifact, b as AuthRequestArtifact, B as BOOTSTRAP_COMPLETION_MARKER_KEY, c as BOOTSTRAP_COMPLETION_MARKER_VERSION, d as BootstrapCompletionMarker, e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, i as DelegationAuthority, 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, R as RUNTIME_DELEGATION_REJECTIONS, l as RestorableSession, m as RuntimeDelegationActivator, n as RuntimeDelegationRejectedError, o as RuntimeDelegationRejection, p as RuntimePermissionGrantOptions, S as SecretPermissionHint, q as SecretReadInput, r as SecretReadResult, s as SessionGrantProof, t as SignStrategy, T as TinyCloudNode, u as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, v as UnifiedOwnerRootReceipt, w as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, x as VerifiedSessionGrant, W as WasmKeyProvider, y as WasmKeyProviderConfig, z as activateCompactRuntimeDelegation, G as activateValidatedRuntimeDelegation, H as createWasmKeyProvider, J as defaultSignStrategy, K as deserializeDelegation, L as grantAuthRequest, Q as serializeDelegation } from './core-AEx5vAa8.js';
|
|
4
4
|
import { invoke, invokeAny, computeCid, prepareSession, completeSessionSetup, ensureEip55, makeSpaceId, createDelegation, parseRecapFromSiwe, parseVerifiedRecapFromSiwe, generateHostSIWEMessage, siweToDelegationHeaders, protocolVersion, vault_encrypt, vault_decrypt, vault_derive_key, vault_x25519_from_seed, vault_x25519_dh, vault_random_bytes, vault_sha256 } from '@tinycloud/node-sdk-wasm';
|
|
5
5
|
import 'events';
|
|
6
6
|
import '@tinycloud/sdk-services';
|
package/dist/index.js
CHANGED
|
@@ -19722,15 +19722,21 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19722
19722
|
if (!this.wasmBindings.invokeAny) {
|
|
19723
19723
|
throw new Error("WASM binding does not support invokeAny");
|
|
19724
19724
|
}
|
|
19725
|
-
const
|
|
19725
|
+
const routedEntries = entries;
|
|
19726
|
+
const operations = routedEntries.flatMap((entry) => {
|
|
19726
19727
|
const operation = this.operationFromInvokeAnyEntry(entry);
|
|
19727
19728
|
return operation ? [operation] : [];
|
|
19728
19729
|
});
|
|
19729
|
-
const
|
|
19730
|
-
const
|
|
19731
|
-
|
|
19730
|
+
const authorityCid = routedEntries.length === 1 ? routedEntries[0]?.revokeAuthorityCid : void 0;
|
|
19731
|
+
const explicitGrant = authorityCid === void 0 ? void 0 : this.runtimePermissionGrants.find((grant2) => grant2.delegation.cid === authorityCid);
|
|
19732
|
+
if (authorityCid !== void 0 && !explicitGrant) {
|
|
19733
|
+
throw new Error(`Explicit revocation authority ${authorityCid} is not installed.`);
|
|
19734
|
+
}
|
|
19735
|
+
const grant = explicitGrant ?? this.findGrantForOperations(operations);
|
|
19736
|
+
const invocationSession = explicitGrant ? explicitGrant.session : !grant || grant.provenance === "primary" ? session : grant.session;
|
|
19737
|
+
const caveatPreservingEntries = routedEntries.map(({ revokeAuthorityCid: _cid, ...entry }) => {
|
|
19732
19738
|
const requested = this.operationFromInvokeAnyEntry(entry);
|
|
19733
|
-
const granted = requested && grant.operations.find(
|
|
19739
|
+
const granted = grant && requested && grant.operations.find(
|
|
19734
19740
|
(candidate) => this.operationCovers(candidate, requested)
|
|
19735
19741
|
);
|
|
19736
19742
|
if (!granted?.caveats?.length) {
|
|
@@ -19740,7 +19746,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19740
19746
|
throw new Error("Invocation caveats do not match signed ReCap authority.");
|
|
19741
19747
|
}
|
|
19742
19748
|
return { ...entry, caveats: cloneRecapCaveats(granted.caveats) };
|
|
19743
|
-
})
|
|
19749
|
+
});
|
|
19744
19750
|
return this.wasmBindings.invokeAny(invocationSession, caveatPreservingEntries, facts);
|
|
19745
19751
|
};
|
|
19746
19752
|
this.explicitHost = config.host;
|
|
@@ -20205,12 +20211,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20205
20211
|
if (!auth) {
|
|
20206
20212
|
throw new Error("Account bootstrap requires an active wallet session");
|
|
20207
20213
|
}
|
|
20214
|
+
const accountSpaceId = this.ownedSpaceId(ACCOUNT_REGISTRY_SPACE2);
|
|
20208
20215
|
const skipped = auth.lastActivationSkippedSpaceIds;
|
|
20216
|
+
if (skipped.includes(accountSpaceId)) return { action: "run", mode: "fresh" };
|
|
20209
20217
|
if (skipped.some((spaceId) => enshrinedSpaceIds.has(spaceId))) {
|
|
20210
|
-
return { action: "run", mode: "
|
|
20218
|
+
return { action: "run", mode: "repair" };
|
|
20211
20219
|
}
|
|
20212
20220
|
try {
|
|
20213
|
-
const accountSpaceId = this.ownedSpaceId(ACCOUNT_REGISTRY_SPACE2);
|
|
20214
20221
|
const markerPermission = {
|
|
20215
20222
|
service: "tinycloud.kv",
|
|
20216
20223
|
space: accountSpaceId,
|
|
@@ -20222,7 +20229,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20222
20229
|
}
|
|
20223
20230
|
const marker = await this.readBootstrapCompletionMarker();
|
|
20224
20231
|
if (marker.ok) {
|
|
20225
|
-
if (this.isAcceptedBootstrapCompletionMarker(marker.data.data)) {
|
|
20232
|
+
if (this.isAcceptedBootstrapCompletionMarker(marker.data.data, steps.map((step) => step.id))) {
|
|
20226
20233
|
return { action: "skip" };
|
|
20227
20234
|
}
|
|
20228
20235
|
return { action: "run", mode: "repair" };
|
|
@@ -20272,12 +20279,16 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20272
20279
|
);
|
|
20273
20280
|
}
|
|
20274
20281
|
}
|
|
20275
|
-
|
|
20282
|
+
/**
|
|
20283
|
+
* A marker written before a canonical space was added triggers one bounded repair.
|
|
20284
|
+
*/
|
|
20285
|
+
isAcceptedBootstrapCompletionMarker(value, canonicalStepIds) {
|
|
20276
20286
|
if (typeof value !== "object" || value === null) return false;
|
|
20277
20287
|
const entries = Object.entries(value);
|
|
20278
20288
|
const markerValue = (name) => entries.find(([key2]) => key2 === name)?.[1];
|
|
20279
20289
|
const version23 = markerValue("v");
|
|
20280
|
-
|
|
20290
|
+
const stepIds = markerValue("stepIds");
|
|
20291
|
+
return typeof version23 === "number" && Number.isInteger(version23) && ACCEPTED_MARKER_VERSIONS.some((acceptedVersion) => acceptedVersion === version23) && Array.isArray(stepIds) && canonicalStepIds.every((stepId) => stepIds.includes(stepId));
|
|
20281
20292
|
}
|
|
20282
20293
|
markerReadIsUnhostedSpace(meta) {
|
|
20283
20294
|
return meta?.status === 404;
|
|
@@ -20364,30 +20375,39 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20364
20375
|
}
|
|
20365
20376
|
}
|
|
20366
20377
|
if (step.kind === "seed-spaces") {
|
|
20367
|
-
const
|
|
20368
|
-
|
|
20369
|
-
|
|
20370
|
-
|
|
20371
|
-
|
|
20372
|
-
|
|
20373
|
-
|
|
20374
|
-
|
|
20375
|
-
|
|
20376
|
-
|
|
20377
|
-
|
|
20378
|
-
|
|
20379
|
-
|
|
20380
|
-
|
|
20381
|
-
|
|
20382
|
-
|
|
20383
|
-
|
|
20384
|
-
|
|
20385
|
-
|
|
20386
|
-
|
|
20387
|
-
|
|
20388
|
-
|
|
20389
|
-
|
|
20390
|
-
|
|
20378
|
+
const inputs = step.spaces.map((space) => ({
|
|
20379
|
+
spaceId: space.spaceId,
|
|
20380
|
+
name: space.name,
|
|
20381
|
+
ownerDid: this.did,
|
|
20382
|
+
type: "owned",
|
|
20383
|
+
permissions: ["*"],
|
|
20384
|
+
status: "active"
|
|
20385
|
+
}));
|
|
20386
|
+
if (mode === "fresh") {
|
|
20387
|
+
const registered = await this.account.spaces.registerBatch(inputs);
|
|
20388
|
+
if (!registered.ok) {
|
|
20389
|
+
throw Object.assign(
|
|
20390
|
+
new Error(`Failed to seed account spaces: ${registered.error.message}`),
|
|
20391
|
+
{ cause: registered.error }
|
|
20392
|
+
);
|
|
20393
|
+
}
|
|
20394
|
+
const batchError = registered.data.recoveredFromBatchError;
|
|
20395
|
+
if (batchError) {
|
|
20396
|
+
warnings.push({
|
|
20397
|
+
stepId: step.id,
|
|
20398
|
+
kind: "batch-write-reconciled",
|
|
20399
|
+
code: batchError.code,
|
|
20400
|
+
message: batchError.message
|
|
20401
|
+
});
|
|
20402
|
+
}
|
|
20403
|
+
} else {
|
|
20404
|
+
const ensured = await this.account.spaces.registerMissing(inputs);
|
|
20405
|
+
if (!ensured.ok) {
|
|
20406
|
+
throw Object.assign(
|
|
20407
|
+
new Error(`Failed to seed account spaces: ${ensured.error.message}`),
|
|
20408
|
+
{ cause: ensured.error }
|
|
20409
|
+
);
|
|
20410
|
+
}
|
|
20391
20411
|
}
|
|
20392
20412
|
}
|
|
20393
20413
|
if (step.kind === "seed-applications") {
|
|
@@ -21072,6 +21092,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21072
21092
|
stagedSessionExpiry,
|
|
21073
21093
|
stagedRecap
|
|
21074
21094
|
);
|
|
21095
|
+
const stagedAccountSpaceId = stagedAddress ? this.wasmBindings.makeSpaceId(stagedAddress, stagedChainId, ACCOUNT_REGISTRY_SPACE2) : void 0;
|
|
21075
21096
|
const stagedGraph = this.stageRestoredServiceGraph({
|
|
21076
21097
|
host: stagedHost,
|
|
21077
21098
|
manager: stagedManager,
|
|
@@ -21080,6 +21101,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21080
21101
|
nodeDid: stagedNodeDid,
|
|
21081
21102
|
address: stagedAddress,
|
|
21082
21103
|
chainId: stagedChainId,
|
|
21104
|
+
accountSpaceId: stagedAccountSpaceId,
|
|
21083
21105
|
tinyCloudSession: stagedTcSession,
|
|
21084
21106
|
sessionExpiry: stagedSessionExpiry,
|
|
21085
21107
|
recap: stagedRecap
|
|
@@ -21245,6 +21267,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21245
21267
|
}
|
|
21246
21268
|
const delegationManager = new DelegationManager({
|
|
21247
21269
|
hosts: [input.host],
|
|
21270
|
+
accountSpaceId: input.accountSpaceId,
|
|
21248
21271
|
session: input.serviceSession,
|
|
21249
21272
|
invoke: graph.invoke,
|
|
21250
21273
|
invokeAny: graph.invokeAny,
|
|
@@ -22949,6 +22972,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22949
22972
|
delegation.delegationHeader
|
|
22950
22973
|
);
|
|
22951
22974
|
if (!activateResult.success) {
|
|
22975
|
+
if (this.operationsFromDelegation(delegation).some(
|
|
22976
|
+
(operation) => operation.resource?.startsWith("urn:cid:") === true && operation.service === "delegation" && operation.action === "tinycloud.delegation/revoke"
|
|
22977
|
+
) && activateResult.status === 401 && /Cannot find parent delegation/i.test(activateResult.error ?? "")) {
|
|
22978
|
+
throw Object.assign(
|
|
22979
|
+
new Error("The host cannot activate a root raw-CID revoke authority without a parent delegation."),
|
|
22980
|
+
{ code: "RAW_RECAP_RESOURCE_UNSUPPORTED", cause: activateResult }
|
|
22981
|
+
);
|
|
22982
|
+
}
|
|
22952
22983
|
throw Object.assign(
|
|
22953
22984
|
new Error(`Failed to activate runtime permission delegation: ${describeHostFailure2(activateResult)}`),
|
|
22954
22985
|
{ cause: activateResult }
|
|
@@ -22996,10 +23027,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22996
23027
|
}
|
|
22997
23028
|
this.assertDelegationCaveatsPreservable(expanded);
|
|
22998
23029
|
const rawEntries = expanded.filter(
|
|
22999
|
-
(entry) => this.isEncryptionPermissionEntry(entry)
|
|
23030
|
+
(entry) => this.isEncryptionPermissionEntry(entry) || this.isRawRevocationPermissionEntry(entry)
|
|
23000
23031
|
);
|
|
23001
23032
|
const spaceEntries = expanded.filter(
|
|
23002
|
-
(entry) => !this.isEncryptionPermissionEntry(entry)
|
|
23033
|
+
(entry) => !this.isEncryptionPermissionEntry(entry) && !this.isRawRevocationPermissionEntry(entry)
|
|
23003
23034
|
);
|
|
23004
23035
|
const bySpace = /* @__PURE__ */ new Map();
|
|
23005
23036
|
for (const entry of spaceEntries) {
|
|
@@ -23026,17 +23057,29 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23026
23057
|
}
|
|
23027
23058
|
const delegatedEntries = [...entries, ...rawForDelegation];
|
|
23028
23059
|
const abilities = this.permissionsToAbilities(entries);
|
|
23029
|
-
const prepared =
|
|
23030
|
-
|
|
23031
|
-
|
|
23032
|
-
|
|
23033
|
-
|
|
23034
|
-
|
|
23035
|
-
|
|
23036
|
-
|
|
23037
|
-
|
|
23038
|
-
|
|
23039
|
-
|
|
23060
|
+
const prepared = (() => {
|
|
23061
|
+
try {
|
|
23062
|
+
return this.wasmBindings.prepareSession({
|
|
23063
|
+
abilities,
|
|
23064
|
+
...rawForDelegation.length > 0 ? { rawAbilities: this.permissionsToRawAbilities(rawForDelegation) } : {},
|
|
23065
|
+
address: this.wasmBindings.ensureEip55(session.address),
|
|
23066
|
+
chainId: session.chainId,
|
|
23067
|
+
domain: this.siweDomain,
|
|
23068
|
+
issuedAt: now.toISOString(),
|
|
23069
|
+
expirationTime: expiresAt.toISOString(),
|
|
23070
|
+
spaceId,
|
|
23071
|
+
jwk: session.jwk
|
|
23072
|
+
});
|
|
23073
|
+
} catch (error) {
|
|
23074
|
+
if (rawForDelegation.some((entry) => this.isRawRevocationPermissionEntry(entry)) && /invalid ReCap resource URI/i.test(error instanceof Error ? error.message : String(error))) {
|
|
23075
|
+
throw Object.assign(
|
|
23076
|
+
new Error("This WASM build cannot encode raw urn:cid ReCap resources."),
|
|
23077
|
+
{ code: "RAW_RECAP_RESOURCE_UNSUPPORTED", cause: error }
|
|
23078
|
+
);
|
|
23079
|
+
}
|
|
23080
|
+
throw error;
|
|
23081
|
+
}
|
|
23082
|
+
})();
|
|
23040
23083
|
const signature2 = await this.signer.signMessage(prepared.siwe);
|
|
23041
23084
|
const delegatedSession = this.wasmBindings.completeSessionSetup({
|
|
23042
23085
|
...prepared,
|
|
@@ -23047,6 +23090,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23047
23090
|
delegatedSession.delegationHeader
|
|
23048
23091
|
);
|
|
23049
23092
|
if (!activateResult.success) {
|
|
23093
|
+
if (rawForDelegation.some((entry) => this.isRawRevocationPermissionEntry(entry)) && activateResult.status === 401 && /Cannot find parent delegation/i.test(activateResult.error ?? "")) {
|
|
23094
|
+
throw Object.assign(
|
|
23095
|
+
new Error("The host cannot activate a root raw-CID revoke authority without a parent delegation."),
|
|
23096
|
+
{ code: "RAW_RECAP_RESOURCE_UNSUPPORTED", cause: activateResult }
|
|
23097
|
+
);
|
|
23098
|
+
}
|
|
23050
23099
|
throw Object.assign(
|
|
23051
23100
|
new Error(`Failed to activate runtime permission delegation: ${describeHostFailure2(activateResult)}`),
|
|
23052
23101
|
{ cause: activateResult }
|
|
@@ -23399,8 +23448,18 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23399
23448
|
* @throws {@link PermissionNotInManifestError} when any requested
|
|
23400
23449
|
* entry is not a subset of the granted session capabilities and
|
|
23401
23450
|
* `forceWalletSign` is not set.
|
|
23451
|
+
* @throws when `onPrepared` is combined with `forceWalletSign: true`,
|
|
23452
|
+
* before anything is signed.
|
|
23453
|
+
* @throws the `onPrepared` rejection, unchanged, without activating the
|
|
23454
|
+
* delegation.
|
|
23402
23455
|
*/
|
|
23403
23456
|
async delegateTo(did, permissions, options) {
|
|
23457
|
+
const onPrepared = options?.onPrepared;
|
|
23458
|
+
if (onPrepared && options?.forceWalletSign) {
|
|
23459
|
+
throw new Error(
|
|
23460
|
+
"delegateTo: onPrepared cannot be combined with forceWalletSign=true; the wallet-signed path activates the delegation before it could be handed to onPrepared."
|
|
23461
|
+
);
|
|
23462
|
+
}
|
|
23404
23463
|
const session = this.currentTinyCloudSession();
|
|
23405
23464
|
if (!session) {
|
|
23406
23465
|
throw new SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
@@ -23459,7 +23518,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23459
23518
|
expandedEntries,
|
|
23460
23519
|
runtimeExpiration,
|
|
23461
23520
|
runtimeGrant,
|
|
23462
|
-
runtimeOperations
|
|
23521
|
+
runtimeOperations,
|
|
23522
|
+
onPrepared
|
|
23463
23523
|
);
|
|
23464
23524
|
return { delegation: delegation2, prompted: false };
|
|
23465
23525
|
}
|
|
@@ -23469,7 +23529,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23469
23529
|
did,
|
|
23470
23530
|
expandedEntries,
|
|
23471
23531
|
effectiveExpiration,
|
|
23472
|
-
session
|
|
23532
|
+
session,
|
|
23533
|
+
onPrepared
|
|
23473
23534
|
);
|
|
23474
23535
|
return { delegation, prompted: false };
|
|
23475
23536
|
}
|
|
@@ -23523,7 +23584,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23523
23584
|
*
|
|
23524
23585
|
* @internal
|
|
23525
23586
|
*/
|
|
23526
|
-
async createDelegationViaWasmPath(did, entries, expirationTime, session) {
|
|
23587
|
+
async createDelegationViaWasmPath(did, entries, expirationTime, session, onPrepared) {
|
|
23527
23588
|
if (entries.length === 0) {
|
|
23528
23589
|
throw new Error(
|
|
23529
23590
|
"createDelegationViaWasmPath requires a non-empty entries array"
|
|
@@ -23586,17 +23647,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23586
23647
|
});
|
|
23587
23648
|
const primary = result.resources[0];
|
|
23588
23649
|
const delegationHeader = { Authorization: result.delegation };
|
|
23589
|
-
const
|
|
23590
|
-
this.config.host,
|
|
23591
|
-
delegationHeader
|
|
23592
|
-
);
|
|
23593
|
-
if (!activateResult.success) {
|
|
23594
|
-
throw Object.assign(
|
|
23595
|
-
new Error(`Failed to activate delegation with host: ${describeHostFailure2(activateResult)}`),
|
|
23596
|
-
{ cause: activateResult }
|
|
23597
|
-
);
|
|
23598
|
-
}
|
|
23599
|
-
return {
|
|
23650
|
+
const delegation = {
|
|
23600
23651
|
cid: result.cid,
|
|
23601
23652
|
delegationHeader,
|
|
23602
23653
|
spaceId,
|
|
@@ -23610,8 +23661,22 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23610
23661
|
chainId: session.chainId,
|
|
23611
23662
|
host: this.config.host
|
|
23612
23663
|
};
|
|
23664
|
+
if (onPrepared) {
|
|
23665
|
+
await onPrepared(delegation);
|
|
23666
|
+
}
|
|
23667
|
+
const activateResult = await activateSessionWithHost2(
|
|
23668
|
+
this.config.host,
|
|
23669
|
+
delegationHeader
|
|
23670
|
+
);
|
|
23671
|
+
if (!activateResult.success) {
|
|
23672
|
+
throw Object.assign(
|
|
23673
|
+
new Error(`Failed to activate delegation with host: ${describeHostFailure2(activateResult)}`),
|
|
23674
|
+
{ cause: activateResult }
|
|
23675
|
+
);
|
|
23676
|
+
}
|
|
23677
|
+
return delegation;
|
|
23613
23678
|
}
|
|
23614
|
-
async createDelegationViaRuntimeGrant(did, entries, expirationTime, grant, requestedOperations) {
|
|
23679
|
+
async createDelegationViaRuntimeGrant(did, entries, expirationTime, grant, requestedOperations, onPrepared) {
|
|
23615
23680
|
this.assertRuntimeGrantCaveatsPreservable(entries, requestedOperations, grant);
|
|
23616
23681
|
this.assertDelegationCaveatsPreservable(entries);
|
|
23617
23682
|
const result = this.createDelegationWrapper({
|
|
@@ -23624,17 +23689,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23624
23689
|
const primary = result.resources[0];
|
|
23625
23690
|
const delegationHeader = { Authorization: result.delegation };
|
|
23626
23691
|
const targetHost = grant.delegation.host ?? this.config.host;
|
|
23627
|
-
const
|
|
23628
|
-
targetHost,
|
|
23629
|
-
delegationHeader
|
|
23630
|
-
);
|
|
23631
|
-
if (!activateResult.success) {
|
|
23632
|
-
throw Object.assign(
|
|
23633
|
-
new Error(`Failed to activate delegation with host: ${describeHostFailure2(activateResult)}`),
|
|
23634
|
-
{ cause: activateResult }
|
|
23635
|
-
);
|
|
23636
|
-
}
|
|
23637
|
-
return {
|
|
23692
|
+
const delegation = {
|
|
23638
23693
|
cid: result.cid,
|
|
23639
23694
|
delegationHeader,
|
|
23640
23695
|
spaceId: grant.session.spaceId,
|
|
@@ -23648,6 +23703,20 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23648
23703
|
chainId: grant.delegation.chainId,
|
|
23649
23704
|
host: targetHost
|
|
23650
23705
|
};
|
|
23706
|
+
if (onPrepared) {
|
|
23707
|
+
await onPrepared(delegation);
|
|
23708
|
+
}
|
|
23709
|
+
const activateResult = await activateSessionWithHost2(
|
|
23710
|
+
targetHost,
|
|
23711
|
+
delegationHeader
|
|
23712
|
+
);
|
|
23713
|
+
if (!activateResult.success) {
|
|
23714
|
+
throw Object.assign(
|
|
23715
|
+
new Error(`Failed to activate delegation with host: ${describeHostFailure2(activateResult)}`),
|
|
23716
|
+
{ cause: activateResult }
|
|
23717
|
+
);
|
|
23718
|
+
}
|
|
23719
|
+
return delegation;
|
|
23651
23720
|
}
|
|
23652
23721
|
resolvePermissionSpace(space, session) {
|
|
23653
23722
|
if (space === void 0) {
|
|
@@ -23748,6 +23817,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23748
23817
|
permissionsToAbilities(entries) {
|
|
23749
23818
|
const abilities = {};
|
|
23750
23819
|
for (const entry of entries) {
|
|
23820
|
+
if (this.isRawRevocationPermissionEntry(entry)) continue;
|
|
23751
23821
|
const service = this.shortServiceName(entry.service);
|
|
23752
23822
|
abilities[service] ?? (abilities[service] = {});
|
|
23753
23823
|
const existing = abilities[service][entry.path] ?? [];
|
|
@@ -23765,9 +23835,16 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23765
23835
|
isEncryptionPermissionEntry(entry) {
|
|
23766
23836
|
return entry.service === ENCRYPTION_PERMISSION_SERVICE2 && this.isEncryptionNetworkOperation("encryption", entry.path, entry.space);
|
|
23767
23837
|
}
|
|
23838
|
+
isRawRevocationPermissionEntry(entry) {
|
|
23839
|
+
return entry.service === "tinycloud.delegation" && entry.path === "" && entry.space?.startsWith("urn:cid:") === true && entry.actions.includes("tinycloud.delegation/revoke");
|
|
23840
|
+
}
|
|
23768
23841
|
permissionsToRawAbilities(entries) {
|
|
23769
23842
|
const rawAbilities = {};
|
|
23770
23843
|
for (const entry of entries) {
|
|
23844
|
+
if (this.isRawRevocationPermissionEntry(entry)) {
|
|
23845
|
+
rawAbilities[entry.space] = [...new Set(entry.actions)];
|
|
23846
|
+
continue;
|
|
23847
|
+
}
|
|
23771
23848
|
if (!this.isEncryptionPermissionEntry(entry)) {
|
|
23772
23849
|
continue;
|
|
23773
23850
|
}
|
|
@@ -23787,7 +23864,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23787
23864
|
return entries.flatMap((entry) => {
|
|
23788
23865
|
const service = this.shortServiceName(entry.service);
|
|
23789
23866
|
return entry.actions.map((action) => ({
|
|
23790
|
-
...this.isEncryptionNetworkOperation(service, entry.path, entry.space) ? { resource: entry.path } : { spaceId },
|
|
23867
|
+
...this.isRawRevocationPermissionEntry(entry) ? { resource: entry.space } : this.isEncryptionNetworkOperation(service, entry.path, entry.space) ? { resource: entry.path } : { spaceId },
|
|
23791
23868
|
service,
|
|
23792
23869
|
path: entry.path,
|
|
23793
23870
|
action,
|
|
@@ -23797,11 +23874,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23797
23874
|
}
|
|
23798
23875
|
/** Raw network authority cannot be covered by a nested encryption space. */
|
|
23799
23876
|
signedCapabilitySubset(requested, granted) {
|
|
23800
|
-
const rawGranted = granted.filter((entry) => this.isEncryptionPermissionEntry(entry)).map((entry) => ({ ...entry, space: "encryption" })
|
|
23801
|
-
const spaceGranted = granted.filter(
|
|
23877
|
+
const rawGranted = granted.filter((entry) => this.isEncryptionPermissionEntry(entry) || this.isRawRevocationPermissionEntry(entry)).map((entry) => this.isEncryptionPermissionEntry(entry) ? { ...entry, space: "encryption" } : entry);
|
|
23878
|
+
const spaceGranted = granted.filter(
|
|
23879
|
+
(entry) => !this.isEncryptionPermissionEntry(entry) && !this.isRawRevocationPermissionEntry(entry)
|
|
23880
|
+
);
|
|
23802
23881
|
const missing = requested.filter((entry) => {
|
|
23803
|
-
const raw = this.isEncryptionPermissionEntry(entry);
|
|
23804
|
-
const comparable = raw ? { ...entry, space: "encryption" } : entry;
|
|
23882
|
+
const raw = this.isEncryptionPermissionEntry(entry) || this.isRawRevocationPermissionEntry(entry);
|
|
23883
|
+
const comparable = raw && this.isEncryptionPermissionEntry(entry) ? { ...entry, space: "encryption" } : entry;
|
|
23805
23884
|
return !isCapabilitySubset([comparable], raw ? rawGranted : spaceGranted).subset;
|
|
23806
23885
|
});
|
|
23807
23886
|
return { subset: missing.length === 0, missing };
|
|
@@ -23816,10 +23895,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23816
23895
|
}
|
|
23817
23896
|
permissionEntriesToOperations(entries, session) {
|
|
23818
23897
|
return entries.flatMap((entry) => {
|
|
23819
|
-
const
|
|
23898
|
+
const rawRevocation = this.isRawRevocationPermissionEntry(entry);
|
|
23899
|
+
const spaceId = rawRevocation ? void 0 : this.resolvePermissionSpace(entry.space, session);
|
|
23820
23900
|
const service = this.shortServiceName(entry.service);
|
|
23821
23901
|
return entry.actions.map((action) => ({
|
|
23822
|
-
...this.isEncryptionNetworkOperation(service, entry.path, entry.space) ? { resource: entry.path } : { spaceId },
|
|
23902
|
+
...rawRevocation ? { resource: entry.space } : this.isEncryptionNetworkOperation(service, entry.path, entry.space) ? { resource: entry.path } : { spaceId },
|
|
23823
23903
|
service,
|
|
23824
23904
|
path: entry.path,
|
|
23825
23905
|
action,
|
|
@@ -23898,7 +23978,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23898
23978
|
delegatedResourcesForEntries(entries, spaceId) {
|
|
23899
23979
|
return entries.map((entry) => ({
|
|
23900
23980
|
service: this.shortServiceName(entry.service),
|
|
23901
|
-
space: this.isEncryptionPermissionEntry(entry) ? "encryption" : spaceId,
|
|
23981
|
+
space: this.isRawRevocationPermissionEntry(entry) ? entry.space : this.isEncryptionPermissionEntry(entry) ? "encryption" : spaceId,
|
|
23902
23982
|
path: entry.path,
|
|
23903
23983
|
actions: [...entry.actions],
|
|
23904
23984
|
...entry.caveats === void 0 ? {} : { caveats: cloneRecapCaveats(entry.caveats) }
|
|
@@ -23908,8 +23988,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23908
23988
|
const resources = delegation.resources !== void 0 && delegation.resources.length > 0 ? delegation.resources : this.flatDelegationResources(delegation);
|
|
23909
23989
|
return resources.flatMap((resource) => {
|
|
23910
23990
|
const service = this.invocationServiceName(resource.service);
|
|
23991
|
+
const rawRevocation = service === "delegation" && resource.space.startsWith("urn:cid:") && resource.path === "";
|
|
23911
23992
|
return resource.actions.map((action) => ({
|
|
23912
|
-
...this.isEncryptionNetworkOperation(service, resource.path, resource.space) ? { resource: resource.path } : { spaceId: resource.space },
|
|
23993
|
+
...rawRevocation ? { resource: resource.space } : this.isEncryptionNetworkOperation(service, resource.path, resource.space) ? { resource: resource.path } : { spaceId: resource.space },
|
|
23913
23994
|
service,
|
|
23914
23995
|
path: resource.path,
|
|
23915
23996
|
action,
|
|
@@ -23955,7 +24036,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23955
24036
|
* @internal
|
|
23956
24037
|
*/
|
|
23957
24038
|
buildActivationAbilities(delegation) {
|
|
23958
|
-
var _a, _b, _c;
|
|
24039
|
+
var _a, _b, _c, _d;
|
|
23959
24040
|
const resources = delegation.resources !== void 0 && delegation.resources.length > 0 ? delegation.resources : this.flatDelegationResources(delegation);
|
|
23960
24041
|
const abilities = {};
|
|
23961
24042
|
const rawAbilities = {};
|
|
@@ -23975,13 +24056,18 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23975
24056
|
addActions(rawAbilities[resource.path], resource.actions);
|
|
23976
24057
|
continue;
|
|
23977
24058
|
}
|
|
24059
|
+
if (service === "delegation" && resource.space.startsWith("urn:cid:") && resource.path === "") {
|
|
24060
|
+
rawAbilities[_b = resource.space] ?? (rawAbilities[_b] = []);
|
|
24061
|
+
addActions(rawAbilities[resource.space], resource.actions);
|
|
24062
|
+
continue;
|
|
24063
|
+
}
|
|
23978
24064
|
if (resource.space !== delegation.spaceId) {
|
|
23979
24065
|
throw new Error(
|
|
23980
24066
|
`useDelegation: resource targets space '${resource.space}' but the delegation activates space '${delegation.spaceId}'. Multi-space delegations cannot be activated in a single useDelegation call.`
|
|
23981
24067
|
);
|
|
23982
24068
|
}
|
|
23983
24069
|
abilities[service] ?? (abilities[service] = {});
|
|
23984
|
-
(
|
|
24070
|
+
(_c = abilities[service])[_d = resource.path] ?? (_c[_d] = []);
|
|
23985
24071
|
addActions(abilities[service][resource.path], resource.actions);
|
|
23986
24072
|
}
|
|
23987
24073
|
return { abilities, rawAbilities };
|