@tinycloud/node-sdk 2.3.0 → 2.4.0-beta.1
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-BdlIWB-K.d.cts → core-Dbzm1kA_.d.cts} +43 -0
- package/dist/{core-BdlIWB-K.d.ts → core-Dbzm1kA_.d.ts} +43 -0
- package/dist/core.cjs +100 -20
- 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 +100 -20
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +100 -20
- 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 +100 -20
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ISigner, Bytes, IWasmBindings, ISessionManager } from '@tinycloud/sdk-core';
|
|
2
2
|
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, BuildCanonicalDecryptRequestInput, BuildDecryptFactsInput, BuildDecryptInvocationInput, BuiltDecryptInvocation, CallbackStrategy, CanonicalAddress, CanonicalDecryptRequest, CanonicalJson, CanonicalParsedNetworkId, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, 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, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, 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, KVCreateSignedReadUrlOptions, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, NETWORK_NAME_PATTERN, NetworkDescriptor, NetworkIdError, NodeDescriptorFetcher, ParsedNetworkId, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PkhDidParts, PrefixedKVService, ProtocolMismatchError, QueryOptions, QueryResponse, RandomReceiverKeyInput, ReceiveOptions, ReceiverKeyPair, ReceiverKeySigner, ResolvedCapabilities, ResolvedDelegate, ResolvedSecretPath, ResourceCapability, SECRET_NAME_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, 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, TinyCloudSession, UnsupportedFeatureError, VAULT_PERMISSION_SERVICE, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultPublicSpaceKVActions, VaultPutOptions, VerifyDecryptResponseInput, VersionCheckError, ViewInfo, WasmVaultFunctions, WellKnownDescriptorFetcher, addressStorageKey, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, buildSpaceUri, canonicalHashHex, canonicalSignedResponse, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeEncryptionJson, canonicalizeNetworkId, canonicalizeSecretScope, checkDecryptInvocationInput, checkNodeInfo, composeManifestRequest, createCapabilityKeyRegistry, createSharingService, createSpaceService, createVaultCrypto, decryptEnvelopeWithKey, defaultSpaceCreationHandler, deriveSignedReceiverKey, didCacheKey, didEquals, discoverNetwork, encryptToNetwork, encryptionBase64Decode, encryptionBase64Encode, encryptionError, encryptionUtf8Decode, encryptionUtf8Encode, ensureNetworkUsableForDecrypt, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, generateRandomReceiverKey, hexDecode, hexEncode, isCapabilitySubset, isEvmAddress, isNetworkId, loadManifest, makePkhSpaceId, makePublicSpaceId, networkDiscoveryKey, openWrappedKey, parseCanonicalNetworkId, parseExpiry, parseNetworkId, parsePkhDid, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, validateEnvelope, validateManifest, verifyDecryptResponse } from '@tinycloud/sdk-core';
|
|
3
|
-
export { D as DelegateToOptions, a as DelegateToResult, b as DelegatedAccess, F as FileSessionStorage, M as MemorySessionStorage, N as NodeEventEmitterStrategy, c as NodeUserAuthorization, d as NodeUserAuthorizationConfig, P as PortableDelegation, R as RestorableSession, e as RuntimePermissionGrantOptions, S as SignStrategy, T as TinyCloudNode, f as TinyCloudNodeConfig, W as WasmKeyProvider, g as WasmKeyProviderConfig, h as createWasmKeyProvider, i as defaultSignStrategy, j as deserializeDelegation, s as serializeDelegation } from './core-
|
|
3
|
+
export { D as DelegateToOptions, a as DelegateToResult, b as DelegatedAccess, F as FileSessionStorage, M as MemorySessionStorage, N as NodeEventEmitterStrategy, c as NodeUserAuthorization, d as NodeUserAuthorizationConfig, P as PortableDelegation, R as RestorableSession, e as RuntimePermissionGrantOptions, S as SignStrategy, T as TinyCloudNode, f as TinyCloudNodeConfig, W as WasmKeyProvider, g as WasmKeyProviderConfig, h as createWasmKeyProvider, i as defaultSignStrategy, j as deserializeDelegation, s as serializeDelegation } from './core-Dbzm1kA_.cjs';
|
|
4
4
|
import { invoke, invokeAny, computeCid, prepareSession, completeSessionSetup, ensureEip55, makeSpaceId, createDelegation, parseRecapFromSiwe, 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, IWasmBindings, ISessionManager } from '@tinycloud/sdk-core';
|
|
2
2
|
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, BuildCanonicalDecryptRequestInput, BuildDecryptFactsInput, BuildDecryptInvocationInput, BuiltDecryptInvocation, CallbackStrategy, CanonicalAddress, CanonicalDecryptRequest, CanonicalJson, CanonicalParsedNetworkId, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, 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, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, 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, KVCreateSignedReadUrlOptions, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, NETWORK_NAME_PATTERN, NetworkDescriptor, NetworkIdError, NodeDescriptorFetcher, ParsedNetworkId, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PkhDidParts, PrefixedKVService, ProtocolMismatchError, QueryOptions, QueryResponse, RandomReceiverKeyInput, ReceiveOptions, ReceiverKeyPair, ReceiverKeySigner, ResolvedCapabilities, ResolvedDelegate, ResolvedSecretPath, ResourceCapability, SECRET_NAME_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, 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, TinyCloudSession, UnsupportedFeatureError, VAULT_PERMISSION_SERVICE, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultPublicSpaceKVActions, VaultPutOptions, VerifyDecryptResponseInput, VersionCheckError, ViewInfo, WasmVaultFunctions, WellKnownDescriptorFetcher, addressStorageKey, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, buildSpaceUri, canonicalHashHex, canonicalSignedResponse, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeEncryptionJson, canonicalizeNetworkId, canonicalizeSecretScope, checkDecryptInvocationInput, checkNodeInfo, composeManifestRequest, createCapabilityKeyRegistry, createSharingService, createSpaceService, createVaultCrypto, decryptEnvelopeWithKey, defaultSpaceCreationHandler, deriveSignedReceiverKey, didCacheKey, didEquals, discoverNetwork, encryptToNetwork, encryptionBase64Decode, encryptionBase64Encode, encryptionError, encryptionUtf8Decode, encryptionUtf8Encode, ensureNetworkUsableForDecrypt, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, generateRandomReceiverKey, hexDecode, hexEncode, isCapabilitySubset, isEvmAddress, isNetworkId, loadManifest, makePkhSpaceId, makePublicSpaceId, networkDiscoveryKey, openWrappedKey, parseCanonicalNetworkId, parseExpiry, parseNetworkId, parsePkhDid, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, validateEnvelope, validateManifest, verifyDecryptResponse } from '@tinycloud/sdk-core';
|
|
3
|
-
export { D as DelegateToOptions, a as DelegateToResult, b as DelegatedAccess, F as FileSessionStorage, M as MemorySessionStorage, N as NodeEventEmitterStrategy, c as NodeUserAuthorization, d as NodeUserAuthorizationConfig, P as PortableDelegation, R as RestorableSession, e as RuntimePermissionGrantOptions, S as SignStrategy, T as TinyCloudNode, f as TinyCloudNodeConfig, W as WasmKeyProvider, g as WasmKeyProviderConfig, h as createWasmKeyProvider, i as defaultSignStrategy, j as deserializeDelegation, s as serializeDelegation } from './core-
|
|
3
|
+
export { D as DelegateToOptions, a as DelegateToResult, b as DelegatedAccess, F as FileSessionStorage, M as MemorySessionStorage, N as NodeEventEmitterStrategy, c as NodeUserAuthorization, d as NodeUserAuthorizationConfig, P as PortableDelegation, R as RestorableSession, e as RuntimePermissionGrantOptions, S as SignStrategy, T as TinyCloudNode, f as TinyCloudNodeConfig, W as WasmKeyProvider, g as WasmKeyProviderConfig, h as createWasmKeyProvider, i as defaultSignStrategy, j as deserializeDelegation, s as serializeDelegation } from './core-Dbzm1kA_.js';
|
|
4
4
|
import { invoke, invokeAny, computeCid, prepareSession, completeSessionSetup, ensureEip55, makeSpaceId, createDelegation, parseRecapFromSiwe, 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
|
@@ -18950,6 +18950,52 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18950
18950
|
);
|
|
18951
18951
|
}
|
|
18952
18952
|
}
|
|
18953
|
+
/**
|
|
18954
|
+
* Host one of this user's owned spaces by name (e.g. `"applications"`).
|
|
18955
|
+
*
|
|
18956
|
+
* Resolves the name to the owned space URI
|
|
18957
|
+
* (`tinycloud:pkh:eip155:<chain>:<addr>:<name>`) and registers it on the
|
|
18958
|
+
* server via the host-SIWE delegation flow, so subsequent KV/SQL writes to
|
|
18959
|
+
* that space succeed instead of returning `404 - Space not found`. The
|
|
18960
|
+
* caller is the root authority of their own owned spaces, so no additional
|
|
18961
|
+
* delegation is required.
|
|
18962
|
+
*
|
|
18963
|
+
* Unlike {@link ensureOwnedSpaceHosted}, this always submits the host
|
|
18964
|
+
* delegation rather than inferring hosting from session activation: a space
|
|
18965
|
+
* the current session has never referenced is reported neither as
|
|
18966
|
+
* `activated` nor `skipped`, so activation-based detection would wrongly
|
|
18967
|
+
* skip the host. The host SIWE is idempotent server-side, so re-hosting an
|
|
18968
|
+
* existing space is a safe no-op. Must be called after {@link signIn}.
|
|
18969
|
+
*
|
|
18970
|
+
* @param name - The owned space name (e.g. `"applications"`).
|
|
18971
|
+
* @returns The hosted space URI.
|
|
18972
|
+
*/
|
|
18973
|
+
async hostOwnedSpace(name) {
|
|
18974
|
+
if (!this.auth || !this.auth.tinyCloudSession) {
|
|
18975
|
+
throw new Error("Not signed in. Call signIn() first.");
|
|
18976
|
+
}
|
|
18977
|
+
const spaceId = this.ownedSpaceId(name);
|
|
18978
|
+
const host = this.hosts[0] ?? this.config.host;
|
|
18979
|
+
if (!host) {
|
|
18980
|
+
throw new Error("Owned space hosting requires a TinyCloud host");
|
|
18981
|
+
}
|
|
18982
|
+
const hosted = await this.auth.hostOwnedSpace(
|
|
18983
|
+
spaceId
|
|
18984
|
+
);
|
|
18985
|
+
if (!hosted) {
|
|
18986
|
+
throw new Error(`Failed to host owned space: ${spaceId}`);
|
|
18987
|
+
}
|
|
18988
|
+
const activation = await activateSessionWithHost2(
|
|
18989
|
+
host,
|
|
18990
|
+
this.auth.tinyCloudSession.delegationHeader
|
|
18991
|
+
);
|
|
18992
|
+
if (!activation.success || activation.skipped?.includes(spaceId)) {
|
|
18993
|
+
throw new Error(
|
|
18994
|
+
`Failed to activate session for owned space ${spaceId}: ${activation.error ?? "space was skipped"}`
|
|
18995
|
+
);
|
|
18996
|
+
}
|
|
18997
|
+
return spaceId;
|
|
18998
|
+
}
|
|
18953
18999
|
/**
|
|
18954
19000
|
* Restore a previously established session from stored delegation data.
|
|
18955
19001
|
*
|
|
@@ -20930,6 +20976,59 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20930
20976
|
actions
|
|
20931
20977
|
}));
|
|
20932
20978
|
}
|
|
20979
|
+
/**
|
|
20980
|
+
* Build the abilities/rawAbilities maps for a wallet-mode activation
|
|
20981
|
+
* sub-delegation from the FULL resource set of a received delegation.
|
|
20982
|
+
*
|
|
20983
|
+
* Each entry in `delegation.resources[]` is one `(service, space, path,
|
|
20984
|
+
* actions)` grant; the flat top-level `path`/`actions` mirror only the
|
|
20985
|
+
* first resource. We must reconstruct every grant so the activated
|
|
20986
|
+
* session carries all of them (e.g. both `tinycloud.kv/get` and
|
|
20987
|
+
* `tinycloud.encryption/decrypt`) — not just the primary one.
|
|
20988
|
+
*
|
|
20989
|
+
* Encryption resources are raw network URNs (space-independent) and go
|
|
20990
|
+
* into `rawAbilities`. All other resources are space-scoped and go into
|
|
20991
|
+
* `abilities` keyed by short service name. The activation `prepareSession`
|
|
20992
|
+
* call uses a single `spaceId` (`delegation.spaceId`), so every
|
|
20993
|
+
* non-encryption resource must target that same space — which is exactly
|
|
20994
|
+
* what the multi-resource issuance path enforces. A resource targeting a
|
|
20995
|
+
* different space cannot be activated in one call, so we fail loudly
|
|
20996
|
+
* rather than silently dropping it.
|
|
20997
|
+
*
|
|
20998
|
+
* @internal
|
|
20999
|
+
*/
|
|
21000
|
+
buildActivationAbilities(delegation) {
|
|
21001
|
+
var _a, _b, _c;
|
|
21002
|
+
const resources = delegation.resources !== void 0 && delegation.resources.length > 0 ? delegation.resources : this.flatDelegationResources(delegation);
|
|
21003
|
+
const abilities = {};
|
|
21004
|
+
const rawAbilities = {};
|
|
21005
|
+
const addActions = (target, actions) => {
|
|
21006
|
+
const seen = new Set(target);
|
|
21007
|
+
for (const action of actions) {
|
|
21008
|
+
if (!seen.has(action)) {
|
|
21009
|
+
target.push(action);
|
|
21010
|
+
seen.add(action);
|
|
21011
|
+
}
|
|
21012
|
+
}
|
|
21013
|
+
};
|
|
21014
|
+
for (const resource of resources) {
|
|
21015
|
+
const service = this.invocationServiceName(resource.service);
|
|
21016
|
+
if (this.isEncryptionNetworkOperation(service, resource.path)) {
|
|
21017
|
+
rawAbilities[_a = resource.path] ?? (rawAbilities[_a] = []);
|
|
21018
|
+
addActions(rawAbilities[resource.path], resource.actions);
|
|
21019
|
+
continue;
|
|
21020
|
+
}
|
|
21021
|
+
if (resource.space !== delegation.spaceId) {
|
|
21022
|
+
throw new Error(
|
|
21023
|
+
`useDelegation: resource targets space '${resource.space}' but the delegation activates space '${delegation.spaceId}'. Multi-space delegations cannot be activated in a single useDelegation call.`
|
|
21024
|
+
);
|
|
21025
|
+
}
|
|
21026
|
+
abilities[service] ?? (abilities[service] = {});
|
|
21027
|
+
(_b = abilities[service])[_c = resource.path] ?? (_b[_c] = []);
|
|
21028
|
+
addActions(abilities[service][resource.path], resource.actions);
|
|
21029
|
+
}
|
|
21030
|
+
return { abilities, rawAbilities };
|
|
21031
|
+
}
|
|
20933
21032
|
selectInvocationSession(fallback, service, path, action) {
|
|
20934
21033
|
const grant = this.findGrantForOperation({
|
|
20935
21034
|
spaceId: fallback.spaceId,
|
|
@@ -21276,26 +21375,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21276
21375
|
throw new Error("Not signed in. Call signIn() first.");
|
|
21277
21376
|
}
|
|
21278
21377
|
const jwk = mySession.jwk;
|
|
21279
|
-
const abilities =
|
|
21280
|
-
const kvActions = delegation.actions.filter((a) => a.startsWith("tinycloud.kv/"));
|
|
21281
|
-
const sqlActions = delegation.actions.filter((a) => a.startsWith("tinycloud.sql/"));
|
|
21282
|
-
const duckdbActions = delegation.actions.filter((a) => a.startsWith("tinycloud.duckdb/"));
|
|
21283
|
-
const encryptionActions = delegation.actions.filter(
|
|
21284
|
-
(a) => a.startsWith("tinycloud.encryption/")
|
|
21285
|
-
);
|
|
21286
|
-
const rawAbilities = {};
|
|
21287
|
-
if (kvActions.length > 0) {
|
|
21288
|
-
abilities.kv = { [delegation.path]: kvActions };
|
|
21289
|
-
}
|
|
21290
|
-
if (sqlActions.length > 0) {
|
|
21291
|
-
abilities.sql = { [delegation.path]: sqlActions };
|
|
21292
|
-
}
|
|
21293
|
-
if (duckdbActions.length > 0) {
|
|
21294
|
-
abilities.duckdb = { [delegation.path]: duckdbActions };
|
|
21295
|
-
}
|
|
21296
|
-
if (encryptionActions.length > 0 && delegation.path.startsWith("urn:tinycloud:encryption:")) {
|
|
21297
|
-
rawAbilities[delegation.path] = encryptionActions;
|
|
21298
|
-
}
|
|
21378
|
+
const { abilities, rawAbilities } = this.buildActivationAbilities(delegation);
|
|
21299
21379
|
const now = /* @__PURE__ */ new Date();
|
|
21300
21380
|
const maxExpiry = new Date(now.getTime() + 60 * 60 * 1e3);
|
|
21301
21381
|
const expirationTime = delegation.expiry < maxExpiry ? delegation.expiry : maxExpiry;
|