@tinycloud/node-sdk 3.6.2-beta.0 → 3.7.0-beta.2
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/{TinyCloudNode--OyL6lZh.d.ts → TinyCloudNode-CclYdOh4.d.ts} +15 -6
- package/dist/{TinyCloudNode-BMi72EIk.d.cts → TinyCloudNode-u_PobKS1.d.cts} +15 -6
- package/dist/{authority-U0m7P2TE.d.cts → authority-CI3qRIcu.d.cts} +1 -1
- package/dist/{authority-DSG538B7.d.ts → authority-OZr9meoT.d.ts} +1 -1
- package/dist/core.cjs +63 -30
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +67 -31
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +63 -30
- 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 +67 -31
- package/dist/index.js.map +1 -1
- package/dist/replication/authority.d.cts +2 -2
- package/dist/replication/authority.d.ts +2 -2
- package/package.json +4 -4
package/dist/core.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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-
|
|
4
|
+
import { _ as __authority } from './authority-CI3qRIcu.cjs';
|
|
5
5
|
import { _ as __runtime } from './runtime-D1o9Eybt.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-
|
|
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-u_PobKS1.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
11
|
import 'events';
|
package/dist/core.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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-
|
|
4
|
+
import { _ as __authority } from './authority-OZr9meoT.js';
|
|
5
5
|
import { _ as __runtime } from './runtime-v62FzQHz.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
|
|
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-CclYdOh4.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
11
|
import 'events';
|
package/dist/core.js
CHANGED
|
@@ -2786,7 +2786,10 @@ import {
|
|
|
2786
2786
|
resolveSecretPath as resolveSecretPath2,
|
|
2787
2787
|
registerPolicyV3,
|
|
2788
2788
|
CREDENTIAL_INVITATION_REQUEST_DOMAIN,
|
|
2789
|
-
|
|
2789
|
+
ShareDeliveryRefusedError,
|
|
2790
|
+
shortDeliveryLinkBodyCid,
|
|
2791
|
+
verifyShareDeliveryAuthorizationV3Bytes,
|
|
2792
|
+
withoutShareLink,
|
|
2790
2793
|
verifyEip191MessageSignature,
|
|
2791
2794
|
signCompactUcanRootAuthorization,
|
|
2792
2795
|
markDelegationTerminal,
|
|
@@ -3922,17 +3925,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3922
3925
|
throw new Error("WASM binding does not support invokeAny");
|
|
3923
3926
|
}
|
|
3924
3927
|
const routedEntries = entries;
|
|
3925
|
-
const
|
|
3926
|
-
const operation = this.operationFromInvokeAnyEntry(entry);
|
|
3927
|
-
return operation ? [operation] : [];
|
|
3928
|
-
});
|
|
3929
|
-
const authorityCid = routedEntries.length === 1 ? routedEntries[0]?.revokeAuthorityCid : void 0;
|
|
3930
|
-
const explicitGrant = authorityCid === void 0 ? void 0 : this.runtimePermissionGrants.find((grant2) => grant2.delegation.cid === authorityCid);
|
|
3931
|
-
if (authorityCid !== void 0 && !explicitGrant) {
|
|
3932
|
-
throw new Error(`Explicit revocation authority ${authorityCid} is not installed.`);
|
|
3933
|
-
}
|
|
3934
|
-
const grant = explicitGrant ?? this.findGrantForOperations(operations);
|
|
3935
|
-
const invocationSession = explicitGrant ? explicitGrant.session : !grant || grant.provenance === "primary" ? session : grant.session;
|
|
3928
|
+
const { session: invocationSession, grant } = this.selectInvokeAnySession(session, entries);
|
|
3936
3929
|
const caveatPreservingEntries = routedEntries.map(({ revokeAuthorityCid: _cid, ...entry }) => {
|
|
3937
3930
|
const requested = this.operationFromInvokeAnyEntry(entry);
|
|
3938
3931
|
const granted = grant && requested && grant.operations.find(
|
|
@@ -4170,6 +4163,27 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4170
4163
|
get siweDomain() {
|
|
4171
4164
|
return this.config.domain ?? "app.tinycloud.xyz";
|
|
4172
4165
|
}
|
|
4166
|
+
/**
|
|
4167
|
+
* The session (key, issuer, proof) that signs an invokeAny call for `entries`:
|
|
4168
|
+
* the explicit revocation authority, else the covering non-primary runtime
|
|
4169
|
+
* grant, else the caller's session. Everything that re-signs the resulting
|
|
4170
|
+
* invocation must use this session's key.
|
|
4171
|
+
*/
|
|
4172
|
+
selectInvokeAnySession(session, entries) {
|
|
4173
|
+
const routedEntries = entries;
|
|
4174
|
+
const operations = routedEntries.flatMap((entry) => {
|
|
4175
|
+
const operation = this.operationFromInvokeAnyEntry(entry);
|
|
4176
|
+
return operation ? [operation] : [];
|
|
4177
|
+
});
|
|
4178
|
+
const authorityCid = routedEntries.length === 1 ? routedEntries[0]?.revokeAuthorityCid : void 0;
|
|
4179
|
+
const explicitGrant = authorityCid === void 0 ? void 0 : this.runtimePermissionGrants.find((grant2) => grant2.delegation.cid === authorityCid);
|
|
4180
|
+
if (authorityCid !== void 0 && !explicitGrant) {
|
|
4181
|
+
throw new Error(`Explicit revocation authority ${authorityCid} is not installed.`);
|
|
4182
|
+
}
|
|
4183
|
+
const grant = explicitGrant ?? this.findGrantForOperations(operations);
|
|
4184
|
+
const invocationSession = explicitGrant ? explicitGrant.session : !grant || grant.provenance === "primary" ? session : grant.session;
|
|
4185
|
+
return { session: invocationSession, grant };
|
|
4186
|
+
}
|
|
4173
4187
|
/**
|
|
4174
4188
|
* SharingService for receive-only access (no session required), bound to the
|
|
4175
4189
|
* current service graph. This lets session-only users receive sharing links
|
|
@@ -6589,7 +6603,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6589
6603
|
async bindInvocationAudience(authorization, audience) {
|
|
6590
6604
|
const session = this.currentTinyCloudSession() ?? this._activeServiceSession;
|
|
6591
6605
|
if (session === void 0) throw new Error("Not signed in. Call signIn() first.");
|
|
6592
|
-
|
|
6606
|
+
const payload = JSON.parse(
|
|
6607
|
+
new TextDecoder().decode(base64UrlDecode(authorization.split(".")[1] ?? ""))
|
|
6608
|
+
);
|
|
6609
|
+
const did = (value) => String(value).split("#", 1)[0];
|
|
6610
|
+
const signer = [session, ...this.runtimePermissionGrants.map((grant) => grant.session)].find((candidate) => did(candidate.verificationMethod) === did(payload.iss));
|
|
6611
|
+
if (!signer) throw new Error("invocation issuer does not match a held session");
|
|
6612
|
+
return rewriteInvocationAudience(authorization, audience, signer.jwk);
|
|
6593
6613
|
}
|
|
6594
6614
|
/**
|
|
6595
6615
|
* Connect a wallet to upgrade from session-only mode to wallet mode.
|
|
@@ -6924,23 +6944,25 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6924
6944
|
throw new Error("WASM binding does not support invocation CID computation");
|
|
6925
6945
|
}
|
|
6926
6946
|
const session = binding?.session ?? this.requireEncryptionSession();
|
|
6947
|
+
const entries = [
|
|
6948
|
+
{
|
|
6949
|
+
resource: input.networkId,
|
|
6950
|
+
service: "encryption",
|
|
6951
|
+
path: input.networkId,
|
|
6952
|
+
action: input.action
|
|
6953
|
+
}
|
|
6954
|
+
];
|
|
6927
6955
|
const headers = this.invokeAnyWithRuntimePermissions(
|
|
6928
6956
|
session,
|
|
6929
|
-
|
|
6930
|
-
{
|
|
6931
|
-
resource: input.networkId,
|
|
6932
|
-
service: "encryption",
|
|
6933
|
-
path: input.networkId,
|
|
6934
|
-
action: input.action
|
|
6935
|
-
}
|
|
6936
|
-
],
|
|
6957
|
+
entries,
|
|
6937
6958
|
[input.facts]
|
|
6938
6959
|
);
|
|
6960
|
+
const signingSession = this.selectInvokeAnySession(session, entries).session;
|
|
6939
6961
|
const authorization = authorizationHeader(headers);
|
|
6940
6962
|
const audienceBound = await rewriteInvocationAudience(
|
|
6941
6963
|
authorization,
|
|
6942
6964
|
input.targetNode,
|
|
6943
|
-
|
|
6965
|
+
signingSession.jwk
|
|
6944
6966
|
);
|
|
6945
6967
|
binding?.graph.assertActive();
|
|
6946
6968
|
return {
|
|
@@ -6993,7 +7015,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6993
7015
|
path: networkId,
|
|
6994
7016
|
actions: ["tinycloud.encryption/decrypt"]
|
|
6995
7017
|
}) : void 0;
|
|
6996
|
-
throw new DecryptTransportResponseError(
|
|
7018
|
+
throw new DecryptTransportResponseError(
|
|
7019
|
+
response.status,
|
|
7020
|
+
permissionHint,
|
|
7021
|
+
response.status === 404 && networkId === this.getDefaultEncryptionNetworkId() && await response.text().catch(() => "") === "network not found" ? `Network not found: ${networkId}. Sign in again with a current SDK to create the account's encryption network.` : void 0
|
|
7022
|
+
);
|
|
6997
7023
|
}
|
|
6998
7024
|
return await response.json();
|
|
6999
7025
|
}
|
|
@@ -7458,8 +7484,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7458
7484
|
fetch: globalThis.fetch.bind(globalThis)
|
|
7459
7485
|
});
|
|
7460
7486
|
}
|
|
7461
|
-
/**
|
|
7487
|
+
/**
|
|
7488
|
+
* Authorize one short-lived v3 delivery. `shareUrl` is the short `/s/<id>#v=4&k=…&c=…` link: the node fetches the
|
|
7489
|
+
* sealed body by id and opens it with the link's key, so the body of the request carries the link and nothing else
|
|
7490
|
+
* of the share. `envelope` is the signed v3 envelope the sender holds; it checks the node's admission here and is
|
|
7491
|
+
* not sent.
|
|
7492
|
+
*/
|
|
7462
7493
|
async authorizeShareDeliveryV3(input) {
|
|
7494
|
+
const envelopeRef = await shortDeliveryLinkBodyCid(input.shareUrl, input.trustedOrigins);
|
|
7463
7495
|
const session = this.currentTinyCloudSession();
|
|
7464
7496
|
const serviceSession = this._serviceContext?.session;
|
|
7465
7497
|
if (!session || !serviceSession) throw new Error("Share delivery requires an authenticated session");
|
|
@@ -7469,15 +7501,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7469
7501
|
}
|
|
7470
7502
|
const jtiDigest = new Uint8Array(await crypto.subtle.digest("SHA-256", idempotencyBytes));
|
|
7471
7503
|
const body = {
|
|
7472
|
-
envelope: input.envelope,
|
|
7473
|
-
sealedEnvelope: input.sealedEnvelope,
|
|
7474
|
-
envelopeKey: input.envelopeKey,
|
|
7475
|
-
shareCid: input.shareCid,
|
|
7476
7504
|
recipientEmail: input.recipientEmail,
|
|
7477
7505
|
shareUrl: input.shareUrl,
|
|
7478
7506
|
documentName: input.documentName,
|
|
7479
7507
|
jti: base64UrlEncode(jtiDigest.slice(0, 16)),
|
|
7480
|
-
|
|
7508
|
+
// Re-normalised through Date, so the sent value is always `YYYY-MM-DDTHH:mm:ss.SSSZ` (UTC, three digits).
|
|
7509
|
+
expiresAt: new Date(input.expiresAt).toISOString()
|
|
7481
7510
|
};
|
|
7482
7511
|
const requestBodyDigest = base64UrlEncode(new Uint8Array(await crypto.subtle.digest("SHA-256", new TextEncoder().encode(canonicalizeEncryptionJson(body)))));
|
|
7483
7512
|
const request = { ...body, requestBodyDigest };
|
|
@@ -7487,9 +7516,16 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7487
7516
|
headers: { accept: "application/json", "content-type": "application/json", authorization },
|
|
7488
7517
|
body: canonicalizeEncryptionJson(request)
|
|
7489
7518
|
});
|
|
7490
|
-
if (
|
|
7491
|
-
|
|
7519
|
+
if (response.status === 400 || response.status === 422) throw new ShareDeliveryRefusedError();
|
|
7520
|
+
if (!response.ok) {
|
|
7521
|
+
const reply = await response.text().catch(() => response.statusText);
|
|
7522
|
+
const body2 = (await withoutShareLink(reply, input.shareUrl)).trim().slice(0, 512);
|
|
7523
|
+
throw Object.assign(new Error(`V3 share delivery authorization failed: HTTP ${response.status}${body2 ? ` - ${body2}` : ""}`), { status: response.status });
|
|
7524
|
+
}
|
|
7525
|
+
const verified = await verifyShareDeliveryAuthorizationV3Bytes(new Uint8Array(await response.arrayBuffer()), {
|
|
7492
7526
|
request,
|
|
7527
|
+
envelope: input.envelope,
|
|
7528
|
+
envelopeRef,
|
|
7493
7529
|
senderKeyDid: this.credentialHolderDid,
|
|
7494
7530
|
deliveryAudience: input.deliveryAudience
|
|
7495
7531
|
});
|