@tinycloud/node-sdk 3.8.0-beta.9 → 3.8.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/README.md +6 -0
- package/dist/{TinyCloudNode-jPL2UqH5.d.ts → TinyCloudNode-DaD5vJhL.d.cts} +38 -5
- package/dist/{TinyCloudNode-C0LgPzzJ.d.cts → TinyCloudNode-k3TbBwwj.d.ts} +38 -5
- package/dist/{WasmKeyProvider-5Ee7fcAw.d.cts → WasmKeyProvider-BKCPRC-c.d.cts} +21 -1
- package/dist/{WasmKeyProvider-5Ee7fcAw.d.ts → WasmKeyProvider-BKCPRC-c.d.ts} +21 -1
- package/dist/{authority-DvHTgPC4.d.ts → authority-C_fWaxAu.d.ts} +1 -1
- package/dist/{authority-Dkhr6n-f.d.cts → authority-DJdbZM6k.d.cts} +1 -1
- package/dist/core.cjs +238 -29
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +4 -4
- package/dist/core.d.ts +4 -4
- package/dist/core.js +239 -30
- package/dist/core.js.map +1 -1
- package/dist/credentials-core.d.cts +1 -1
- package/dist/credentials-core.d.ts +1 -1
- package/dist/credentials.d.cts +1 -1
- package/dist/credentials.d.ts +1 -1
- package/dist/{delegation-0LKZkmP2.d.cts → delegation-Ckc3UETl.d.cts} +1 -1
- package/dist/{delegation-0LKZkmP2.d.ts → delegation-Ckc3UETl.d.ts} +1 -1
- package/dist/encryption-keys.d.cts +2 -2
- package/dist/encryption-keys.d.ts +2 -2
- package/dist/index.cjs +188 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +193 -31
- package/dist/index.js.map +1 -1
- package/dist/replication/authority.d.cts +3 -3
- package/dist/replication/authority.d.ts +3 -3
- package/dist/share-receive.cjs +775 -0
- package/dist/share-receive.cjs.map +1 -0
- package/dist/share-receive.d.cts +32 -0
- package/dist/share-receive.d.ts +32 -0
- package/dist/share-receive.js +777 -0
- package/dist/share-receive.js.map +1 -0
- package/package.json +11 -4
package/dist/core.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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-DJdbZM6k.cjs';
|
|
5
5
|
import { _ as __runtime } from './runtime-mRhSu-vJ.cjs';
|
|
6
6
|
import { ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
|
|
7
|
-
export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider } from './WasmKeyProvider-
|
|
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,
|
|
9
|
-
export { C as CompactRuntimeDelegationInput, P as PortableDelegation, V as ValidatedRuntimeDelegation,
|
|
7
|
+
export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider, i as isAppKeyHostBound } from './WasmKeyProvider-BKCPRC-c.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 OpenKeyAuthorizeTinyCloud, e as OwnerDelegationReceipt, P as PreparedOpenKeyAuthorization, R as RuntimePermissionGrantOptions, S as SecretPermissionHint, f as SecretReadInput, g as SecretReadResult, h as SignStrategy, T as TinyCloudNode, i as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, j as UnifiedOwnerRootReceipt, k as UnsupportedSessionRestoreError, l as defaultSignStrategy, w as wireOpenKeyAuthorize } from './TinyCloudNode-DaD5vJhL.cjs';
|
|
9
|
+
export { C as CompactRuntimeDelegationInput, P as PortableDelegation, R as RuntimeDelegationRejectedError, a as RuntimeDelegationRejection, V as ValidatedRuntimeDelegation, b as activateCompactRuntimeDelegation, c as activateValidatedRuntimeDelegation, d as deserializeDelegation, s as serializeDelegation } from './delegation-Ckc3UETl.cjs';
|
|
10
10
|
import '@tinycloud/sdk-services';
|
|
11
11
|
import '@tinycloud/sdk-services/encryption/named-keys';
|
|
12
12
|
import 'events';
|
package/dist/core.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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-C_fWaxAu.js';
|
|
5
5
|
import { _ as __runtime } from './runtime-CO4VXnPq.js';
|
|
6
6
|
import { ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
|
|
7
|
-
export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider } from './WasmKeyProvider-
|
|
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,
|
|
9
|
-
export { C as CompactRuntimeDelegationInput, P as PortableDelegation, V as ValidatedRuntimeDelegation,
|
|
7
|
+
export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider, i as isAppKeyHostBound } from './WasmKeyProvider-BKCPRC-c.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 OpenKeyAuthorizeTinyCloud, e as OwnerDelegationReceipt, P as PreparedOpenKeyAuthorization, R as RuntimePermissionGrantOptions, S as SecretPermissionHint, f as SecretReadInput, g as SecretReadResult, h as SignStrategy, T as TinyCloudNode, i as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, j as UnifiedOwnerRootReceipt, k as UnsupportedSessionRestoreError, l as defaultSignStrategy, w as wireOpenKeyAuthorize } from './TinyCloudNode-k3TbBwwj.js';
|
|
9
|
+
export { C as CompactRuntimeDelegationInput, P as PortableDelegation, R as RuntimeDelegationRejectedError, a as RuntimeDelegationRejection, V as ValidatedRuntimeDelegation, b as activateCompactRuntimeDelegation, c as activateValidatedRuntimeDelegation, d as deserializeDelegation, s as serializeDelegation } from './delegation-Ckc3UETl.js';
|
|
10
10
|
import '@tinycloud/sdk-services';
|
|
11
11
|
import '@tinycloud/sdk-services/encryption/named-keys';
|
|
12
12
|
import 'events';
|
package/dist/core.js
CHANGED
|
@@ -299,6 +299,18 @@ function appKeyHostBinding(domain, appId) {
|
|
|
299
299
|
const reversed = labels.reverse().join(".");
|
|
300
300
|
return appId === reversed || appId.startsWith(`${reversed}.`);
|
|
301
301
|
}
|
|
302
|
+
function isAppKeyHostBound(keysAppId, origin) {
|
|
303
|
+
if (typeof origin === "string" && !origin.includes("://")) {
|
|
304
|
+
return appKeyHostBinding(origin, keysAppId);
|
|
305
|
+
}
|
|
306
|
+
let url;
|
|
307
|
+
try {
|
|
308
|
+
url = typeof origin === "string" ? new URL(origin) : origin;
|
|
309
|
+
} catch {
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
return appKeyHostBinding(url.host, keysAppId);
|
|
313
|
+
}
|
|
302
314
|
|
|
303
315
|
// src/replication/authority-sign-in.ts
|
|
304
316
|
import {
|
|
@@ -436,6 +448,7 @@ function cloneAbilitiesMap(actions) {
|
|
|
436
448
|
var NodeUserAuthorization = class {
|
|
437
449
|
constructor(config) {
|
|
438
450
|
this.activeSessionKeyId = "default";
|
|
451
|
+
this.preparedSessionCounter = 0;
|
|
439
452
|
/** Incremented by resetSession; a sign-in started earlier publishes nothing. */
|
|
440
453
|
this.sessionGeneration = 0;
|
|
441
454
|
/**
|
|
@@ -1018,7 +1031,8 @@ var NodeUserAuthorization = class {
|
|
|
1018
1031
|
return true;
|
|
1019
1032
|
}
|
|
1020
1033
|
const parsed = entry.path.includes("/") ? parseEncryptionResource(entry.path) : { ...parseNetworkId(entry.path), kind: "network" };
|
|
1021
|
-
|
|
1034
|
+
const sharePrefix = parsed.kind === "prefix" && parsed.network === "default" && parsed.prefix === "share" && entry.actions.length === 1 && entry.actions[0] === DECRYPT_ACTION && didPrincipalMatches(parsed.ownerDid, currentDid);
|
|
1035
|
+
if (parsed.kind !== "network" && !sharePrefix) {
|
|
1022
1036
|
throw new ManifestValidationError("named keys go in manifest.keys");
|
|
1023
1037
|
}
|
|
1024
1038
|
for (const action of entry.actions) {
|
|
@@ -1061,8 +1075,7 @@ var NodeUserAuthorization = class {
|
|
|
1061
1075
|
/**
|
|
1062
1076
|
* Build SIWE overrides from the top-level nonce and siweConfig.
|
|
1063
1077
|
* - Top-level `nonce` is seeded first so `siweConfig.nonce` wins if both are set.
|
|
1064
|
-
* -
|
|
1065
|
-
* - resources are appended to the default resources
|
|
1078
|
+
* - resources are inserted after WASM preparation, before the final ReCap
|
|
1066
1079
|
* - uri triggers a warning (overwriting delegation target)
|
|
1067
1080
|
* - all other fields override directly
|
|
1068
1081
|
* - per-call nonce overrides siweConfig.nonce when provided
|
|
@@ -1080,9 +1093,6 @@ var NodeUserAuthorization = class {
|
|
|
1080
1093
|
if (statement) {
|
|
1081
1094
|
overrides.statement = this.statement ? `${statement} ${this.statement}` : statement;
|
|
1082
1095
|
}
|
|
1083
|
-
if (resources && resources.length > 0) {
|
|
1084
|
-
overrides.resources = resources;
|
|
1085
|
-
}
|
|
1086
1096
|
if (uri) {
|
|
1087
1097
|
console.warn(
|
|
1088
1098
|
"[tinycloud] siweConfig.uri is overwriting the delegation target URI. This may break delegation chain validation if the URI does not match the session key DID."
|
|
@@ -1094,6 +1104,29 @@ var NodeUserAuthorization = class {
|
|
|
1094
1104
|
}
|
|
1095
1105
|
return overrides;
|
|
1096
1106
|
}
|
|
1107
|
+
prepareSessionWithResources(params) {
|
|
1108
|
+
const resources = this.siweConfig?.resources;
|
|
1109
|
+
if (resources?.some((resource) => typeof resource !== "string" || !/^urn:tinycloud:recipients:[A-Za-z0-9_-]+$/.test(resource))) {
|
|
1110
|
+
throw new Error("SIWE metadata resources must be base64url recipients URIs");
|
|
1111
|
+
}
|
|
1112
|
+
const prepared = this.wasm.prepareSession(params);
|
|
1113
|
+
if (!resources?.length) return prepared;
|
|
1114
|
+
const recapLines = /^- urn:recap:[^\r\n]+$/gim;
|
|
1115
|
+
const recaps = prepared.siwe.match(recapLines);
|
|
1116
|
+
const recap = recaps?.[0];
|
|
1117
|
+
if (recaps?.length !== 1 || !prepared.siwe.endsWith(recap)) {
|
|
1118
|
+
throw new Error("Prepared SIWE must end with exactly one ReCap");
|
|
1119
|
+
}
|
|
1120
|
+
const insertedLines = resources.map((resource) => `- ${resource}`);
|
|
1121
|
+
const siwe = prepared.siwe.slice(0, -recap.length) + insertedLines.join("\n") + "\n" + recap;
|
|
1122
|
+
const expectedFields = extractImmutableSiweFields(prepared.siwe);
|
|
1123
|
+
expectedFields.nonRecapResources = [expectedFields.nonRecapResources, ...insertedLines].filter(Boolean).join("\n");
|
|
1124
|
+
const actualRecaps = siwe.match(recapLines);
|
|
1125
|
+
if (actualRecaps?.length !== 1 || actualRecaps[0] !== recap || diffImmutableSiweFields(expectedFields, extractImmutableSiweFields(siwe)).length) {
|
|
1126
|
+
throw new Error("SIWE metadata insertion changed the prepared message");
|
|
1127
|
+
}
|
|
1128
|
+
return { ...prepared, siwe };
|
|
1129
|
+
}
|
|
1097
1130
|
/**
|
|
1098
1131
|
* Add an extension to the authorization flow.
|
|
1099
1132
|
*/
|
|
@@ -1341,7 +1374,7 @@ var NodeUserAuthorization = class {
|
|
|
1341
1374
|
spaceAbilities[spaceId] = resourceCapabilitiesToAbilitiesMap(resources);
|
|
1342
1375
|
}
|
|
1343
1376
|
const abilities = spaceAbilities[options.spaceId] ?? resourceCapabilitiesToAbilitiesMap([]);
|
|
1344
|
-
const prepared = this.
|
|
1377
|
+
const prepared = this.prepareSessionWithResources({
|
|
1345
1378
|
abilities,
|
|
1346
1379
|
spaceAbilities,
|
|
1347
1380
|
...options.rawAbilities !== void 0 ? { rawAbilities: options.rawAbilities } : {},
|
|
@@ -1422,8 +1455,8 @@ var NodeUserAuthorization = class {
|
|
|
1422
1455
|
this.assertSignInCurrent(generation);
|
|
1423
1456
|
await this.refreshNamedKeyFeatureForSignIn(address, chainId);
|
|
1424
1457
|
this.assertSignInCurrent(generation);
|
|
1425
|
-
const keyId = `session-${Date.now()}`;
|
|
1426
|
-
this.sessionManager.
|
|
1458
|
+
const keyId = `session-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
1459
|
+
this.sessionManager.createSessionKey(keyId);
|
|
1427
1460
|
this.activeSessionKeyId = keyId;
|
|
1428
1461
|
const jwkString = this.sessionManager.jwk(keyId);
|
|
1429
1462
|
if (!jwkString) {
|
|
@@ -1434,7 +1467,7 @@ var NodeUserAuthorization = class {
|
|
|
1434
1467
|
const spaceId = capabilityPlan.spaceId;
|
|
1435
1468
|
const now = /* @__PURE__ */ new Date();
|
|
1436
1469
|
const expirationTime = new Date(now.getTime() + this.sessionExpirationMs);
|
|
1437
|
-
const prepared = this.
|
|
1470
|
+
const prepared = this.prepareSessionWithResources({
|
|
1438
1471
|
abilities: capabilityPlan.abilities,
|
|
1439
1472
|
...capabilityPlan.spaceAbilities !== void 0 ? { spaceAbilities: capabilityPlan.spaceAbilities } : {},
|
|
1440
1473
|
...capabilityPlan.rawAbilities !== void 0 ? { rawAbilities: capabilityPlan.rawAbilities } : {},
|
|
@@ -1569,9 +1602,8 @@ var NodeUserAuthorization = class {
|
|
|
1569
1602
|
const address = canonicalizeAddress(await this.signer.getAddress());
|
|
1570
1603
|
const chainId = await this.signer.getChainId();
|
|
1571
1604
|
await this.refreshNamedKeyFeatureForSignIn(address, chainId);
|
|
1572
|
-
const keyId = `session-${Date.now()}`;
|
|
1573
|
-
this.sessionManager.
|
|
1574
|
-
this.activeSessionKeyId = keyId;
|
|
1605
|
+
const keyId = `openkey-session-${Date.now()}-${++this.preparedSessionCounter}`;
|
|
1606
|
+
this.sessionManager.createSessionKey(keyId);
|
|
1575
1607
|
const jwkString = this.sessionManager.jwk(keyId);
|
|
1576
1608
|
if (!jwkString) {
|
|
1577
1609
|
throw new Error("Failed to create session key");
|
|
@@ -1581,7 +1613,7 @@ var NodeUserAuthorization = class {
|
|
|
1581
1613
|
const spaceId = capabilityPlan.spaceId;
|
|
1582
1614
|
const now = /* @__PURE__ */ new Date();
|
|
1583
1615
|
const expirationTime = new Date(now.getTime() + this.sessionExpirationMs);
|
|
1584
|
-
const prepared = this.
|
|
1616
|
+
const prepared = this.prepareSessionWithResources({
|
|
1585
1617
|
abilities: capabilityPlan.abilities,
|
|
1586
1618
|
...capabilityPlan.spaceAbilities !== void 0 ? { spaceAbilities: capabilityPlan.spaceAbilities } : {},
|
|
1587
1619
|
...capabilityPlan.rawAbilities !== void 0 ? { rawAbilities: capabilityPlan.rawAbilities } : {},
|
|
@@ -1652,6 +1684,7 @@ var NodeUserAuthorization = class {
|
|
|
1652
1684
|
await this.sessionStorage.save(address, persistedData);
|
|
1653
1685
|
this._session = clientSession;
|
|
1654
1686
|
this._tinyCloudSession = tinyCloudSession;
|
|
1687
|
+
this.activeSessionKeyId = keyId;
|
|
1655
1688
|
this._address = address;
|
|
1656
1689
|
this._chainId = chainId;
|
|
1657
1690
|
await this.refreshNodeInfo();
|
|
@@ -1698,6 +1731,11 @@ var NodeUserAuthorization = class {
|
|
|
1698
1731
|
* @param options Optional overrides for the OpenKey request.
|
|
1699
1732
|
*/
|
|
1700
1733
|
async signInWithOpenKey(authorizeFn, options) {
|
|
1734
|
+
const pending = await this.prepareOpenKeySignIn(options);
|
|
1735
|
+
return this.completeOpenKeySignIn(pending, authorizeFn(pending.request), options);
|
|
1736
|
+
}
|
|
1737
|
+
/** Finish address, host and SIWE preparation before an approval click. */
|
|
1738
|
+
async prepareOpenKeySignIn(options) {
|
|
1701
1739
|
refuseCaveated(this.getCapabilityRequest()?.manifests);
|
|
1702
1740
|
if (options?.host !== void 0) {
|
|
1703
1741
|
const overrideHost = options.host.trim();
|
|
@@ -1709,7 +1747,7 @@ var NodeUserAuthorization = class {
|
|
|
1709
1747
|
const signingAddress = canonicalizeAddress(await this.signer.getAddress());
|
|
1710
1748
|
const signingChainId = await this.signer.getChainId();
|
|
1711
1749
|
await this.resolveTinyCloudHostsForSignIn(signingAddress, signingChainId);
|
|
1712
|
-
const { prepared, keyId, jwk } = await this.prepareSessionForSigning();
|
|
1750
|
+
const { prepared, keyId, jwk, address, chainId } = await this.prepareSessionForSigning();
|
|
1713
1751
|
const presentation = this.buildPresentationEnvelope(options?.reason);
|
|
1714
1752
|
const hostHint = this.primaryTinyCloudHost;
|
|
1715
1753
|
const originalRequest = {
|
|
@@ -1721,12 +1759,32 @@ var NodeUserAuthorization = class {
|
|
|
1721
1759
|
keyId: options?.openkeyKeyId,
|
|
1722
1760
|
presentation
|
|
1723
1761
|
};
|
|
1762
|
+
return {
|
|
1763
|
+
request: originalRequest,
|
|
1764
|
+
prepared,
|
|
1765
|
+
keyId,
|
|
1766
|
+
jwk,
|
|
1767
|
+
address,
|
|
1768
|
+
chainId,
|
|
1769
|
+
generation: this.sessionGeneration,
|
|
1770
|
+
createdAt: Date.now()
|
|
1771
|
+
};
|
|
1772
|
+
}
|
|
1773
|
+
/** Complete a prepared approval. The caller starts authorization before awaiting this method. */
|
|
1774
|
+
async completeOpenKeySignIn(pending, authorization, options) {
|
|
1775
|
+
if (Date.now() - pending.createdAt > 5 * 6e4) {
|
|
1776
|
+
throw new Error("Prepared OpenKey sign-in expired; prepare again");
|
|
1777
|
+
}
|
|
1778
|
+
if (pending.generation !== this.sessionGeneration) {
|
|
1779
|
+
throw new Error("Prepared OpenKey sign-in expired after sign-out");
|
|
1780
|
+
}
|
|
1781
|
+
const { request: originalRequest, prepared, keyId, jwk } = pending;
|
|
1724
1782
|
let result;
|
|
1725
1783
|
let signed;
|
|
1726
1784
|
let signature;
|
|
1727
1785
|
for (let attempt = 0; ; ) {
|
|
1728
1786
|
try {
|
|
1729
|
-
result ?? (result = await
|
|
1787
|
+
result ?? (result = await authorization);
|
|
1730
1788
|
signed = await this.verifyOpenKeyResult(result, prepared);
|
|
1731
1789
|
signature = result.signature;
|
|
1732
1790
|
break;
|
|
@@ -2147,6 +2205,50 @@ var NodeUserAuthorization = class {
|
|
|
2147
2205
|
}
|
|
2148
2206
|
};
|
|
2149
2207
|
|
|
2208
|
+
// src/authorization/openKeyBridge.ts
|
|
2209
|
+
function wireOpenKeyAuthorize(openkey, opts) {
|
|
2210
|
+
return async (input) => {
|
|
2211
|
+
const result = await openkey.authorizeTinyCloud({
|
|
2212
|
+
protocolVersion: 1,
|
|
2213
|
+
siwe: input.siwe,
|
|
2214
|
+
keyId: input.keyId,
|
|
2215
|
+
jwk: input.jwk,
|
|
2216
|
+
host: input.host,
|
|
2217
|
+
// Forward the presentation envelope verbatim — the OpenKey SDK
|
|
2218
|
+
// validates and size-bounds it before use.
|
|
2219
|
+
presentation: input.presentation
|
|
2220
|
+
}, opts);
|
|
2221
|
+
if (result.protocolVersion !== 1) {
|
|
2222
|
+
throw new Error(
|
|
2223
|
+
`wireOpenKeyAuthorize: OpenKey returned unsupported protocolVersion ${result.protocolVersion}`
|
|
2224
|
+
);
|
|
2225
|
+
}
|
|
2226
|
+
if (typeof result.signedMessage !== "string" || !result.signedMessage) {
|
|
2227
|
+
throw new Error(
|
|
2228
|
+
"wireOpenKeyAuthorize: OpenKey returned no signedMessage \u2014 cannot complete a TinyCloud session"
|
|
2229
|
+
);
|
|
2230
|
+
}
|
|
2231
|
+
if (!Array.isArray(result.selectedActionKeys)) {
|
|
2232
|
+
throw new Error(
|
|
2233
|
+
"wireOpenKeyAuthorize: OpenKey returned no selectedActionKeys"
|
|
2234
|
+
);
|
|
2235
|
+
}
|
|
2236
|
+
if (!Array.isArray(result.permissions)) {
|
|
2237
|
+
throw new Error(
|
|
2238
|
+
"wireOpenKeyAuthorize: OpenKey returned no permissions"
|
|
2239
|
+
);
|
|
2240
|
+
}
|
|
2241
|
+
return {
|
|
2242
|
+
protocolVersion: 1,
|
|
2243
|
+
address: result.address,
|
|
2244
|
+
signature: result.signature,
|
|
2245
|
+
signedMessage: result.signedMessage,
|
|
2246
|
+
selectedActionKeys: result.selectedActionKeys,
|
|
2247
|
+
permissions: result.permissions
|
|
2248
|
+
};
|
|
2249
|
+
};
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2150
2252
|
// src/recordingServiceContext.ts
|
|
2151
2253
|
import {
|
|
2152
2254
|
ServiceContext
|
|
@@ -2798,6 +2900,7 @@ function deserializeDelegation(data) {
|
|
|
2798
2900
|
|
|
2799
2901
|
// src/TinyCloudNode.ts
|
|
2800
2902
|
import { generateNonce, SiweMessage as SiweMessage3 } from "siwe";
|
|
2903
|
+
import { didKeyFromEd25519PublicKey } from "@tinycloud/share-envelope";
|
|
2801
2904
|
import {
|
|
2802
2905
|
TinyCloud,
|
|
2803
2906
|
checkNodeInfo as checkNodeInfo2,
|
|
@@ -2832,10 +2935,13 @@ import {
|
|
|
2832
2935
|
ENCRYPTION_PERMISSION_SERVICE as ENCRYPTION_PERMISSION_SERVICE2,
|
|
2833
2936
|
CaveatedDelegationUnsupportedError as CaveatedDelegationUnsupportedError2,
|
|
2834
2937
|
PermissionNotInManifestError,
|
|
2938
|
+
ManifestValidationError as ManifestValidationError2,
|
|
2835
2939
|
SessionExpiredError,
|
|
2836
2940
|
canonicalizeRecapCaveats as canonicalizeRecapCaveats2,
|
|
2837
2941
|
recapCaveatsEqual as recapCaveatsEqual2,
|
|
2838
2942
|
expandPermissionEntries as expandPermissionEntriesCore,
|
|
2943
|
+
expandRuntimePermissionEntries,
|
|
2944
|
+
expandDelegationPermissionEntries,
|
|
2839
2945
|
isCapabilitySubset as isCapabilitySubset2,
|
|
2840
2946
|
isExplicitOnlyAction,
|
|
2841
2947
|
parseRecapCapabilities,
|
|
@@ -2866,6 +2972,7 @@ import {
|
|
|
2866
2972
|
withoutShareLink,
|
|
2867
2973
|
verifyEip191MessageSignature,
|
|
2868
2974
|
signCompactUcanRootAuthorization,
|
|
2975
|
+
signCompactUcanAuthorization,
|
|
2869
2976
|
markDelegationTerminal,
|
|
2870
2977
|
isStorageFullError,
|
|
2871
2978
|
STORAGE_FULL_MESSAGE,
|
|
@@ -3871,6 +3978,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3871
3978
|
constructor(config = {}) {
|
|
3872
3979
|
this.signer = null;
|
|
3873
3980
|
this.auth = null;
|
|
3981
|
+
this.consumedOpenKeyPendings = /* @__PURE__ */ new WeakSet();
|
|
3874
3982
|
this.tc = null;
|
|
3875
3983
|
this._chainId = 1;
|
|
3876
3984
|
this.replicaPurgeFailedHandlers = /* @__PURE__ */ new Set();
|
|
@@ -4811,6 +4919,37 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4811
4919
|
}
|
|
4812
4920
|
await this.signInWith(() => this.auth.signInWithOpenKey(authorizeFn, options));
|
|
4813
4921
|
}
|
|
4922
|
+
/** Prepare the OpenKey request before the approval click. */
|
|
4923
|
+
async prepareOpenKeySignIn() {
|
|
4924
|
+
if (!this.signer || !this.tc || !this.auth) {
|
|
4925
|
+
throw new Error("Cannot prepare OpenKey sign-in in session-only mode. Provide a signer in config.");
|
|
4926
|
+
}
|
|
4927
|
+
await this.signOutInFlight;
|
|
4928
|
+
await this.accountRegistryTail;
|
|
4929
|
+
await this.wasmBindings.ensureInitialized?.();
|
|
4930
|
+
return this.auth.prepareOpenKeySignIn();
|
|
4931
|
+
}
|
|
4932
|
+
/** Start OpenKey authorization synchronously, then complete normal session setup. */
|
|
4933
|
+
signInWithPreparedOpenKey(pending, authorizeFn) {
|
|
4934
|
+
if (!this.signer || !this.tc || !this.auth || this.signOutInFlight) {
|
|
4935
|
+
throw new Error("Prepared OpenKey sign-in is unavailable");
|
|
4936
|
+
}
|
|
4937
|
+
if (this.consumedOpenKeyPendings.has(pending)) {
|
|
4938
|
+
throw new Error("Prepared OpenKey sign-in was already used");
|
|
4939
|
+
}
|
|
4940
|
+
if (Date.now() - pending.createdAt > 5 * 6e4) {
|
|
4941
|
+
throw new Error("Prepared OpenKey sign-in expired; prepare again");
|
|
4942
|
+
}
|
|
4943
|
+
this.consumedOpenKeyPendings.add(pending);
|
|
4944
|
+
const authorization = authorizeFn(pending.request);
|
|
4945
|
+
void authorization.catch(() => void 0);
|
|
4946
|
+
return this.signInWith(() => {
|
|
4947
|
+
if (this._address !== pending.address || this._chainId !== pending.chainId) {
|
|
4948
|
+
throw new Error("OpenKey account changed after sign-in preparation");
|
|
4949
|
+
}
|
|
4950
|
+
return this.auth.completeOpenKeySignIn(pending, authorization);
|
|
4951
|
+
});
|
|
4952
|
+
}
|
|
4814
4953
|
async signInWith(performSignIn) {
|
|
4815
4954
|
refuseCaveated(this.auth?.capabilityRequest?.manifests);
|
|
4816
4955
|
const epoch = this.sessionEpoch;
|
|
@@ -6452,6 +6591,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6452
6591
|
invoke: graph.invoke,
|
|
6453
6592
|
invokeAny: graph.invokeAny,
|
|
6454
6593
|
signOwnerRevocation: this.signer ? (cid) => this.signOwnerRevocation(cid) : void 0,
|
|
6594
|
+
sessionInvocationSigner: this.sessionInvocationSignerFor(input.serviceSession),
|
|
6455
6595
|
fetch: graph.fetch
|
|
6456
6596
|
});
|
|
6457
6597
|
const keyProvider = new WasmKeyProvider({ sessionManager: input.manager });
|
|
@@ -6667,6 +6807,31 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6667
6807
|
if (session === void 0) throw new Error("Not signed in. Call signIn() first.");
|
|
6668
6808
|
return signBytesWithJwk(bytes, session.jwk);
|
|
6669
6809
|
}
|
|
6810
|
+
/**
|
|
6811
|
+
* Signs proofless invocations with `session`'s own did:key, for the node's
|
|
6812
|
+
* issued-delegation list and revocation by the delegator. The audience is
|
|
6813
|
+
* this Node's DID; each invocation lives 60 seconds.
|
|
6814
|
+
*/
|
|
6815
|
+
sessionInvocationSignerFor(session) {
|
|
6816
|
+
return {
|
|
6817
|
+
did: () => session.verificationMethod.split("#", 1)[0],
|
|
6818
|
+
sign: async (attenuation) => {
|
|
6819
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
6820
|
+
const invocation = await signCompactUcanAuthorization({
|
|
6821
|
+
issuerDid: session.verificationMethod.split("#", 1)[0],
|
|
6822
|
+
audienceDid: await this.fetchNodeId(),
|
|
6823
|
+
attenuation,
|
|
6824
|
+
facts: [{}],
|
|
6825
|
+
proofs: [],
|
|
6826
|
+
notBefore: now,
|
|
6827
|
+
expiresAt: now + 60,
|
|
6828
|
+
nonce: `urn:uuid:${crypto.randomUUID()}`,
|
|
6829
|
+
sign: (bytes) => signBytesWithJwk(bytes, session.jwk)
|
|
6830
|
+
});
|
|
6831
|
+
return invocation.authorization;
|
|
6832
|
+
}
|
|
6833
|
+
};
|
|
6834
|
+
}
|
|
6670
6835
|
/** Author a proofless Policy/v3 owner root with the authenticated holder key. */
|
|
6671
6836
|
async createUnifiedOwnerRoot(input) {
|
|
6672
6837
|
const ownerDid = this.credentialHolderDid;
|
|
@@ -7201,7 +7366,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7201
7366
|
graph.assertActive();
|
|
7202
7367
|
const signed = await this.signRawNetworkAuthorization({
|
|
7203
7368
|
targetNode: input.targetNode,
|
|
7204
|
-
networkId: input.networkId
|
|
7369
|
+
networkId: input.body.keyPath === void 0 ? input.networkId : `${input.networkId}/${input.body.keyPath}`,
|
|
7205
7370
|
action: DECRYPT_ACTION2,
|
|
7206
7371
|
facts: input.facts
|
|
7207
7372
|
}, { graph, session });
|
|
@@ -7374,6 +7539,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
7374
7539
|
invoke: graph.invoke,
|
|
7375
7540
|
invokeAny: graph.invokeAny,
|
|
7376
7541
|
signOwnerRevocation: this.signer ? (cid) => this.signOwnerRevocation(cid) : void 0,
|
|
7542
|
+
sessionInvocationSigner: this.sessionInvocationSignerFor(serviceSession),
|
|
7377
7543
|
fetch: graph.fetch
|
|
7378
7544
|
});
|
|
7379
7545
|
this._spaceService = new SpaceService({
|
|
@@ -8157,7 +8323,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8157
8323
|
if (!session || !Array.isArray(permissions) || permissions.length === 0) {
|
|
8158
8324
|
return false;
|
|
8159
8325
|
}
|
|
8160
|
-
const expanded =
|
|
8326
|
+
const expanded = expandRuntimePermissionEntries(permissions, pkhDid2(session.address, session.chainId));
|
|
8161
8327
|
if (this.sessionCoversPermissionEntries(session, expanded)) {
|
|
8162
8328
|
return true;
|
|
8163
8329
|
}
|
|
@@ -8177,7 +8343,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8177
8343
|
if (!session || !Array.isArray(permissions) || permissions.length === 0) {
|
|
8178
8344
|
return [];
|
|
8179
8345
|
}
|
|
8180
|
-
const expanded =
|
|
8346
|
+
const expanded = expandRuntimePermissionEntries(permissions, pkhDid2(session.address, session.chainId));
|
|
8181
8347
|
return this.findRuntimeGrantsForPermissionEntries(expanded, session).map(
|
|
8182
8348
|
(grant) => grant.delegation
|
|
8183
8349
|
);
|
|
@@ -8352,7 +8518,28 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8352
8518
|
throw new SessionExpiredError(sessionExpiry);
|
|
8353
8519
|
}
|
|
8354
8520
|
}
|
|
8355
|
-
const expanded =
|
|
8521
|
+
const expanded = expandRuntimePermissionEntries(permissions, pkhDid2(session.address, session.chainId));
|
|
8522
|
+
const bindsShareKey = expanded.some((entry) => entry.service === ENCRYPTION_PERMISSION_SERVICE2 && entry.actions.includes("tinycloud.encryption/key.create"));
|
|
8523
|
+
const captured = bindsShareKey ? { ...session, jwk: { ...options?.expectedSessionKey ?? session.jwk } } : session;
|
|
8524
|
+
const assertCapturedKey = bindsShareKey ? () => {
|
|
8525
|
+
const live = session.jwk;
|
|
8526
|
+
const key = captured.jwk;
|
|
8527
|
+
if (this.currentTinyCloudSession() !== session || session.verificationMethod !== captured.verificationMethod || session.delegationCid !== captured.delegationCid || session.spaceId !== captured.spaceId || session.address !== captured.address || session.chainId !== captured.chainId || live?.kty !== key.kty || live?.crv !== key.crv || live?.x !== key.x || live?.y !== key.y || live?.d !== key.d) {
|
|
8528
|
+
throw new Error("Runtime permission request cancelled because the session key changed.");
|
|
8529
|
+
}
|
|
8530
|
+
} : void 0;
|
|
8531
|
+
const sessionKeyDid = bindsShareKey ? this.sessionDid : void 0;
|
|
8532
|
+
if (bindsShareKey) {
|
|
8533
|
+
const key = captured.jwk;
|
|
8534
|
+
if (key.kty !== "OKP" || key.crv !== "Ed25519" || typeof key.x !== "string") {
|
|
8535
|
+
throw new Error("Runtime permission session key does not match its signed identity.");
|
|
8536
|
+
}
|
|
8537
|
+
const keyDid = didKeyFromEd25519PublicKey(base64UrlDecode(key.x));
|
|
8538
|
+
if (!didPrincipalMatches2(keyDid, sessionKeyDid) || !didPrincipalMatches2(keyDid, captured.verificationMethod) || !didPrincipalMatches2(keyDid, new SiweMessage3(session.siwe).uri)) {
|
|
8539
|
+
throw new Error("Runtime permission session key does not match its signed identity.");
|
|
8540
|
+
}
|
|
8541
|
+
assertCapturedKey();
|
|
8542
|
+
}
|
|
8356
8543
|
if (this.sessionCoversPermissionEntries(session, expanded)) {
|
|
8357
8544
|
return [];
|
|
8358
8545
|
}
|
|
@@ -8402,13 +8589,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8402
8589
|
return this.wasmBindings.prepareSession({
|
|
8403
8590
|
abilities,
|
|
8404
8591
|
...rawForDelegation.length > 0 ? { rawAbilities: this.permissionsToRawAbilities(rawForDelegation) } : {},
|
|
8405
|
-
address: this.wasmBindings.ensureEip55(
|
|
8406
|
-
chainId:
|
|
8592
|
+
address: this.wasmBindings.ensureEip55(captured.address),
|
|
8593
|
+
chainId: captured.chainId,
|
|
8407
8594
|
domain: this.siweDomain,
|
|
8408
8595
|
issuedAt: now.toISOString(),
|
|
8409
8596
|
expirationTime: expiresAt.toISOString(),
|
|
8410
8597
|
spaceId,
|
|
8411
|
-
jwk:
|
|
8598
|
+
jwk: captured.jwk
|
|
8412
8599
|
});
|
|
8413
8600
|
} catch (error) {
|
|
8414
8601
|
if (rawForDelegation.some((entry) => this.isRawRevocationPermissionEntry(entry)) && /invalid ReCap resource URI/i.test(error instanceof Error ? error.message : String(error))) {
|
|
@@ -8420,8 +8607,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8420
8607
|
throw error;
|
|
8421
8608
|
}
|
|
8422
8609
|
})();
|
|
8610
|
+
if (bindsShareKey && !didPrincipalMatches2(new SiweMessage3(prepared.siwe).uri, sessionKeyDid)) {
|
|
8611
|
+
throw new Error("Prepared runtime permission targets a different session key.");
|
|
8612
|
+
}
|
|
8613
|
+
assertCapturedKey?.();
|
|
8423
8614
|
const signature = await this.signer.signMessage(prepared.siwe);
|
|
8424
8615
|
graph.assertActive();
|
|
8616
|
+
assertCapturedKey?.();
|
|
8425
8617
|
const delegatedSession = this.wasmBindings.completeSessionSetup({
|
|
8426
8618
|
...prepared,
|
|
8427
8619
|
signature
|
|
@@ -8450,18 +8642,19 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8450
8642
|
delegatedSession,
|
|
8451
8643
|
delegatedEntries,
|
|
8452
8644
|
spaceId,
|
|
8453
|
-
|
|
8645
|
+
captured,
|
|
8454
8646
|
expiresAt,
|
|
8455
8647
|
{ siwe: prepared.siwe, signature }
|
|
8456
8648
|
);
|
|
8457
8649
|
graph.assertActive();
|
|
8650
|
+
assertCapturedKey?.();
|
|
8458
8651
|
this.runtimePermissionGrants.push({
|
|
8459
8652
|
session: {
|
|
8460
8653
|
delegationHeader: delegatedSession.delegationHeader,
|
|
8461
8654
|
delegationCid: delegatedSession.delegationCid,
|
|
8462
8655
|
spaceId,
|
|
8463
|
-
verificationMethod:
|
|
8464
|
-
jwk:
|
|
8656
|
+
verificationMethod: captured.verificationMethod,
|
|
8657
|
+
jwk: captured.jwk
|
|
8465
8658
|
},
|
|
8466
8659
|
delegation,
|
|
8467
8660
|
operations: this.permissionOperations(delegatedEntries, spaceId),
|
|
@@ -8790,7 +8983,19 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
8790
8983
|
"delegateTo requires a non-empty permissions array"
|
|
8791
8984
|
);
|
|
8792
8985
|
}
|
|
8793
|
-
const expandedEntries =
|
|
8986
|
+
const expandedEntries = expandDelegationPermissionEntries(permissions);
|
|
8987
|
+
const namedKeyEntries = expandedEntries.filter((entry) => entry.service === ENCRYPTION_PERMISSION_SERVICE2 && entry.path.includes("/"));
|
|
8988
|
+
if (namedKeyEntries.length > 0) {
|
|
8989
|
+
if (expandedEntries.some((entry) => entry.service === ENCRYPTION_PERMISSION_SERVICE2 && !entry.path.includes("/"))) {
|
|
8990
|
+
throw new ManifestValidationError2("named-key delegation cannot include bare-network permissions");
|
|
8991
|
+
}
|
|
8992
|
+
if (options?.forceWalletSign) {
|
|
8993
|
+
throw new ManifestValidationError2("named-key delegation requires a signed session grant");
|
|
8994
|
+
}
|
|
8995
|
+
const granted = this.projectSignedRecapCapabilities(session.siwe);
|
|
8996
|
+
const { subset, missing } = this.signedCapabilitySubset(namedKeyEntries, granted);
|
|
8997
|
+
if (!subset) throw new PermissionNotInManifestError(missing, granted);
|
|
8998
|
+
}
|
|
8794
8999
|
const now = /* @__PURE__ */ new Date();
|
|
8795
9000
|
const expiryMs = resolveExpiryMs(options?.expiry);
|
|
8796
9001
|
const expirationTime = new Date(now.getTime() + expiryMs);
|
|
@@ -10175,7 +10380,7 @@ import {
|
|
|
10175
10380
|
CaveatedDelegationUnsupportedError as CaveatedDelegationUnsupportedError3,
|
|
10176
10381
|
PermissionNotInManifestError as PermissionNotInManifestError2,
|
|
10177
10382
|
SessionExpiredError as SessionExpiredError2,
|
|
10178
|
-
ManifestValidationError as
|
|
10383
|
+
ManifestValidationError as ManifestValidationError3,
|
|
10179
10384
|
composeManifestRequest as composeManifestRequest2,
|
|
10180
10385
|
resolveManifest as resolveManifest2,
|
|
10181
10386
|
validateManifest,
|
|
@@ -10260,12 +10465,13 @@ export {
|
|
|
10260
10465
|
IdentityParseError,
|
|
10261
10466
|
InvalidRestoredSessionError,
|
|
10262
10467
|
KVService3 as KVService,
|
|
10263
|
-
|
|
10468
|
+
ManifestValidationError3 as ManifestValidationError,
|
|
10264
10469
|
MemorySessionStorage,
|
|
10265
10470
|
NodeUserAuthorization,
|
|
10266
10471
|
PermissionNotInManifestError2 as PermissionNotInManifestError,
|
|
10267
10472
|
PrefixedKVService,
|
|
10268
10473
|
ProtocolMismatchError2 as ProtocolMismatchError,
|
|
10474
|
+
RuntimeDelegationRejectedError,
|
|
10269
10475
|
SECRET_NAME_RE,
|
|
10270
10476
|
SQLAction,
|
|
10271
10477
|
SQLService3 as SQLService,
|
|
@@ -10288,6 +10494,7 @@ export {
|
|
|
10288
10494
|
VersionCheckError,
|
|
10289
10495
|
WasmKeyProvider,
|
|
10290
10496
|
activateCompactRuntimeDelegation,
|
|
10497
|
+
activateValidatedRuntimeDelegation,
|
|
10291
10498
|
addressStorageKey,
|
|
10292
10499
|
buildSpaceUri,
|
|
10293
10500
|
canonicalizeAddress3 as canonicalizeAddress,
|
|
@@ -10317,6 +10524,7 @@ export {
|
|
|
10317
10524
|
getNodeReplicationLoaders,
|
|
10318
10525
|
getTinyCloudDebugLogs,
|
|
10319
10526
|
installTinyCloudDebugGlobals,
|
|
10527
|
+
isAppKeyHostBound,
|
|
10320
10528
|
isCapabilitySubset3 as isCapabilitySubset,
|
|
10321
10529
|
isEvmAddress,
|
|
10322
10530
|
loadManifest,
|
|
@@ -10338,6 +10546,7 @@ export {
|
|
|
10338
10546
|
resourceCapabilitiesToSpaceAbilitiesMap2 as resourceCapabilitiesToSpaceAbilitiesMap,
|
|
10339
10547
|
serializeDelegation,
|
|
10340
10548
|
tinyCloudDebugLogger2 as tinyCloudDebugLogger,
|
|
10341
|
-
validateManifest
|
|
10549
|
+
validateManifest,
|
|
10550
|
+
wireOpenKeyAuthorize
|
|
10342
10551
|
};
|
|
10343
10552
|
//# sourceMappingURL=core.js.map
|