@tinycloud/node-sdk 2.0.4 → 2.1.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.cjs +428 -93
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +102 -3
- package/dist/core.d.ts +102 -3
- package/dist/core.js +363 -17
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +435 -95
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +380 -19
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/dist/core.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, IWasmBindings, SiweConfig, ClientSession, TinyCloudSession, Extension, Delegation, IKVService, ISQLService, IDuckDbService, INotificationHandler, IENSResolver, IDataVaultService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISharingService, CreateDelegationParams, DelegationResult, KeyProvider, ISessionManager, JWK } from '@tinycloud/sdk-core';
|
|
2
|
-
export { AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, CallbackStrategy, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, ClientSession, ColumnInfo, CreateDelegationParams, DataVaultConfig, DataVaultService, DatabaseHandle, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, 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, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IngestOptions, InvokeFunction, JWK, KVResponse, KVService, KVServiceConfig, KeyInfo, KeyProvider, KeyType, PersistedSessionData, PrefixedKVService, ProtocolMismatchError, QueryOptions, QueryResponse, ReceiveOptions, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, ServiceContext, ServiceContextConfig, ServiceSession, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignRequest, SignResponse, SilentNotificationHandler, Space, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, TableInfo, TinyCloud, TinyCloudConfig, TinyCloudSession, UnsupportedFeatureError, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultPublicSpaceKVActions, VaultPutOptions, VersionCheckError, ViewInfo, WasmVaultFunctions, buildSpaceUri, checkNodeInfo, createCapabilityKeyRegistry, createSharingService, createSpaceService, createVaultCrypto, defaultSpaceCreationHandler, makePublicSpaceId, parseSpaceUri } from '@tinycloud/sdk-core';
|
|
1
|
+
import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, IWasmBindings, SiweConfig, ClientSession, TinyCloudSession, Extension, Delegation, IKVService, ISQLService, IDuckDbService, IHooksService, INotificationHandler, IENSResolver, IDataVaultService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISharingService, CreateDelegationParams, DelegationResult, PermissionEntry, KeyProvider, ISessionManager, JWK } from '@tinycloud/sdk-core';
|
|
2
|
+
export { AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, CallbackStrategy, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, ClientSession, ColumnInfo, CreateDelegationParams, DataVaultConfig, DataVaultService, DatabaseHandle, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, 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, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IngestOptions, InvokeFunction, JWK, KVResponse, KVService, KVServiceConfig, KeyInfo, KeyProvider, KeyType, Manifest, ManifestDefaults, ManifestDelegation, ManifestValidationError, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PrefixedKVService, ProtocolMismatchError, QueryOptions, QueryResponse, ReceiveOptions, ResolvedCapabilities, ResolvedDelegate, ResourceCapability, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, ServiceContext, ServiceContextConfig, ServiceSession, SessionExpiredError, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignRequest, SignResponse, SilentNotificationHandler, Space, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, TableInfo, TinyCloud, TinyCloudConfig, TinyCloudSession, UnsupportedFeatureError, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultPublicSpaceKVActions, VaultPutOptions, VersionCheckError, ViewInfo, WasmVaultFunctions, buildSpaceUri, checkNodeInfo, createCapabilityKeyRegistry, createSharingService, createSpaceService, createVaultCrypto, defaultSpaceCreationHandler, expandActionShortNames, isCapabilitySubset, loadManifest, makePublicSpaceId, parseExpiry, parseSpaceUri, resolveManifest, validateManifest } from '@tinycloud/sdk-core';
|
|
3
3
|
import { EventEmitter } from 'events';
|
|
4
4
|
import { InvokeFunction } from '@tinycloud/sdk-services';
|
|
5
5
|
|
|
@@ -444,6 +444,7 @@ declare class DelegatedAccess {
|
|
|
444
444
|
private _kv;
|
|
445
445
|
private _sql;
|
|
446
446
|
private _duckdb;
|
|
447
|
+
private _hooks;
|
|
447
448
|
constructor(session: TinyCloudSession, delegation: PortableDelegation, host: string, invoke: InvokeFunction);
|
|
448
449
|
/**
|
|
449
450
|
* Get the delegation this access was created from.
|
|
@@ -469,6 +470,10 @@ declare class DelegatedAccess {
|
|
|
469
470
|
* DuckDB operations on the delegated space.
|
|
470
471
|
*/
|
|
471
472
|
get duckdb(): IDuckDbService;
|
|
473
|
+
/**
|
|
474
|
+
* Hooks write-stream subscriptions on the delegated space.
|
|
475
|
+
*/
|
|
476
|
+
get hooks(): IHooksService;
|
|
472
477
|
}
|
|
473
478
|
|
|
474
479
|
/**
|
|
@@ -545,6 +550,35 @@ interface TinyCloudNodeConfig {
|
|
|
545
550
|
/** Optional SIWE configuration overrides (e.g., nonce for server-provided nonces) */
|
|
546
551
|
siweConfig?: SiweConfig;
|
|
547
552
|
}
|
|
553
|
+
/**
|
|
554
|
+
* Options for {@link TinyCloudNode.delegateTo}.
|
|
555
|
+
*
|
|
556
|
+
* `expiry` accepts either an ms-format duration string (e.g. `"7d"`, `"1h"`)
|
|
557
|
+
* or a raw number of milliseconds. When omitted, the default is 1 hour.
|
|
558
|
+
*
|
|
559
|
+
* `forceWalletSign` bypasses the derivability check and sends the
|
|
560
|
+
* delegation through the legacy wallet-signed SIWE path, which always
|
|
561
|
+
* triggers a wallet prompt. Used for testing, for explicit wallet
|
|
562
|
+
* confirmation flows, and by the legacy `createDelegation` fallback.
|
|
563
|
+
*/
|
|
564
|
+
interface DelegateToOptions {
|
|
565
|
+
/** Override expiry. ms-format string ("7d", "1h") or raw milliseconds. */
|
|
566
|
+
expiry?: string | number;
|
|
567
|
+
/** Force the wallet-signed SIWE path even if the caps are derivable. Default false. */
|
|
568
|
+
forceWalletSign?: boolean;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Result of {@link TinyCloudNode.delegateTo}.
|
|
572
|
+
*
|
|
573
|
+
* `prompted` indicates whether a wallet prompt was shown — `true` for the
|
|
574
|
+
* legacy wallet path (always), `false` for the session-key UCAN path (never).
|
|
575
|
+
* Callers wiring single-prompt sign-in flows use this to assert that their
|
|
576
|
+
* capability chain was derivable.
|
|
577
|
+
*/
|
|
578
|
+
interface DelegateToResult {
|
|
579
|
+
delegation: PortableDelegation;
|
|
580
|
+
prompted: boolean;
|
|
581
|
+
}
|
|
548
582
|
/**
|
|
549
583
|
* High-level TinyCloud API for Node.js environments.
|
|
550
584
|
*
|
|
@@ -573,6 +607,7 @@ declare class TinyCloudNode {
|
|
|
573
607
|
private _kv?;
|
|
574
608
|
private _sql?;
|
|
575
609
|
private _duckdb?;
|
|
610
|
+
private _hooks?;
|
|
576
611
|
private _vault?;
|
|
577
612
|
/** Cached public KV with proper delegation (set by ensurePublicSpace) */
|
|
578
613
|
private _publicKV?;
|
|
@@ -776,6 +811,10 @@ declare class TinyCloudNode {
|
|
|
776
811
|
* Call `vault.unlock(signer)` after signIn() to derive encryption keys.
|
|
777
812
|
*/
|
|
778
813
|
get vault(): IDataVaultService;
|
|
814
|
+
/**
|
|
815
|
+
* Hooks write stream subscription API.
|
|
816
|
+
*/
|
|
817
|
+
get hooks(): IHooksService;
|
|
779
818
|
/**
|
|
780
819
|
* Get the CapabilityKeyRegistry for managing keys and their capabilities.
|
|
781
820
|
*
|
|
@@ -967,6 +1006,58 @@ declare class TinyCloudNode {
|
|
|
967
1006
|
* @returns Result containing boolean permission status
|
|
968
1007
|
*/
|
|
969
1008
|
checkPermission(path: string, action: string): Promise<DelegationResult<boolean>>;
|
|
1009
|
+
/**
|
|
1010
|
+
* Safety margin before the session's own expiry at which {@link delegateTo}
|
|
1011
|
+
* will refuse to issue a derived delegation. Prevents issuing sub-delegations
|
|
1012
|
+
* that would be invalid by the time the recipient used them. Spec: 60 seconds.
|
|
1013
|
+
*
|
|
1014
|
+
* @internal
|
|
1015
|
+
*/
|
|
1016
|
+
private static readonly SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
1017
|
+
/**
|
|
1018
|
+
* Issue a delegation using the capability-chain flow.
|
|
1019
|
+
*
|
|
1020
|
+
* When the requested permissions are a subset of the current session's
|
|
1021
|
+
* recap, the delegation is signed by the session key via WASM — no wallet
|
|
1022
|
+
* prompt. When they are not, a {@link PermissionNotInManifestError} is
|
|
1023
|
+
* raised so the caller can trigger an escalation flow (e.g.
|
|
1024
|
+
* `TinyCloudWeb.requestPermissions`). Passing `forceWalletSign: true`
|
|
1025
|
+
* bypasses the derivability check and always uses the wallet-signed SIWE
|
|
1026
|
+
* path — used by the legacy `createDelegation` fallback and by callers
|
|
1027
|
+
* that want explicit wallet confirmation.
|
|
1028
|
+
*
|
|
1029
|
+
* Current limitation: exactly one {@link PermissionEntry} per call. For
|
|
1030
|
+
* multi-resource delegation, call `delegateTo` multiple times. This keeps
|
|
1031
|
+
* each delegation a single `(spaceId, path)` grant, which matches the
|
|
1032
|
+
* underlying `PortableDelegation` shape.
|
|
1033
|
+
*
|
|
1034
|
+
* @throws {@link SessionExpiredError} when there is no session or the
|
|
1035
|
+
* current session has expired (or will within the 60s safety margin).
|
|
1036
|
+
* @throws {@link PermissionNotInManifestError} when the requested entries
|
|
1037
|
+
* are not a subset of the granted session capabilities and
|
|
1038
|
+
* `forceWalletSign` is not set.
|
|
1039
|
+
*/
|
|
1040
|
+
delegateTo(did: string, permissions: PermissionEntry[], options?: DelegateToOptions): Promise<DelegateToResult>;
|
|
1041
|
+
/**
|
|
1042
|
+
* Issue a delegation via the session-key UCAN WASM path.
|
|
1043
|
+
*
|
|
1044
|
+
* The caller has already verified the request is derivable from the
|
|
1045
|
+
* current session; we just need to shape the inputs for
|
|
1046
|
+
* {@link createDelegationWrapper}.
|
|
1047
|
+
*
|
|
1048
|
+
* @internal
|
|
1049
|
+
*/
|
|
1050
|
+
private createDelegationViaWasmPath;
|
|
1051
|
+
/**
|
|
1052
|
+
* Issue a delegation via the legacy wallet-signed SIWE path for a single
|
|
1053
|
+
* {@link PermissionEntry}. Shares the implementation with the public
|
|
1054
|
+
* `createDelegation` method via {@link createDelegationWalletPath} so
|
|
1055
|
+
* both entry points hit exactly the same SIWE / signer / public-space
|
|
1056
|
+
* logic without mutual recursion.
|
|
1057
|
+
*
|
|
1058
|
+
* @internal
|
|
1059
|
+
*/
|
|
1060
|
+
private createDelegationLegacyWalletPath;
|
|
970
1061
|
/**
|
|
971
1062
|
* Create a delegation from this user to another user.
|
|
972
1063
|
*
|
|
@@ -992,6 +1083,14 @@ declare class TinyCloudNode {
|
|
|
992
1083
|
/** Include a companion delegation for the user's public space (default: true) */
|
|
993
1084
|
includePublicSpace?: boolean;
|
|
994
1085
|
}): Promise<PortableDelegation>;
|
|
1086
|
+
/**
|
|
1087
|
+
* Legacy wallet-signed SIWE delegation path. Lifted from the original
|
|
1088
|
+
* `createDelegation` body verbatim so both the legacy public method and
|
|
1089
|
+
* `delegateTo({ forceWalletSign: true })` hit the same code.
|
|
1090
|
+
*
|
|
1091
|
+
* @internal
|
|
1092
|
+
*/
|
|
1093
|
+
private createDelegationWalletPath;
|
|
995
1094
|
/**
|
|
996
1095
|
* Use a delegation received from another user.
|
|
997
1096
|
*
|
|
@@ -1138,4 +1237,4 @@ declare class WasmKeyProvider implements KeyProvider {
|
|
|
1138
1237
|
*/
|
|
1139
1238
|
declare function createWasmKeyProvider(sessionManager: SessionManagerWithListing): WasmKeyProvider;
|
|
1140
1239
|
|
|
1141
|
-
export { DelegatedAccess, FileSessionStorage, MemorySessionStorage, type NodeEventEmitterStrategy, NodeUserAuthorization, type NodeUserAuthorizationConfig, type PortableDelegation, type SignStrategy, TinyCloudNode, type TinyCloudNodeConfig, WasmKeyProvider, type WasmKeyProviderConfig, createWasmKeyProvider, defaultSignStrategy, deserializeDelegation, serializeDelegation };
|
|
1240
|
+
export { type DelegateToOptions, type DelegateToResult, DelegatedAccess, FileSessionStorage, MemorySessionStorage, type NodeEventEmitterStrategy, NodeUserAuthorization, type NodeUserAuthorizationConfig, type PortableDelegation, type SignStrategy, TinyCloudNode, type TinyCloudNodeConfig, WasmKeyProvider, type WasmKeyProviderConfig, createWasmKeyProvider, defaultSignStrategy, deserializeDelegation, serializeDelegation };
|
package/dist/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, IWasmBindings, SiweConfig, ClientSession, TinyCloudSession, Extension, Delegation, IKVService, ISQLService, IDuckDbService, INotificationHandler, IENSResolver, IDataVaultService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISharingService, CreateDelegationParams, DelegationResult, KeyProvider, ISessionManager, JWK } from '@tinycloud/sdk-core';
|
|
2
|
-
export { AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, CallbackStrategy, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, ClientSession, ColumnInfo, CreateDelegationParams, DataVaultConfig, DataVaultService, DatabaseHandle, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, 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, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IngestOptions, InvokeFunction, JWK, KVResponse, KVService, KVServiceConfig, KeyInfo, KeyProvider, KeyType, PersistedSessionData, PrefixedKVService, ProtocolMismatchError, QueryOptions, QueryResponse, ReceiveOptions, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, ServiceContext, ServiceContextConfig, ServiceSession, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignRequest, SignResponse, SilentNotificationHandler, Space, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, TableInfo, TinyCloud, TinyCloudConfig, TinyCloudSession, UnsupportedFeatureError, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultPublicSpaceKVActions, VaultPutOptions, VersionCheckError, ViewInfo, WasmVaultFunctions, buildSpaceUri, checkNodeInfo, createCapabilityKeyRegistry, createSharingService, createSpaceService, createVaultCrypto, defaultSpaceCreationHandler, makePublicSpaceId, parseSpaceUri } from '@tinycloud/sdk-core';
|
|
1
|
+
import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, IWasmBindings, SiweConfig, ClientSession, TinyCloudSession, Extension, Delegation, IKVService, ISQLService, IDuckDbService, IHooksService, INotificationHandler, IENSResolver, IDataVaultService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISharingService, CreateDelegationParams, DelegationResult, PermissionEntry, KeyProvider, ISessionManager, JWK } from '@tinycloud/sdk-core';
|
|
2
|
+
export { AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, CallbackStrategy, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, ClientSession, ColumnInfo, CreateDelegationParams, DataVaultConfig, DataVaultService, DatabaseHandle, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, 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, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IngestOptions, InvokeFunction, JWK, KVResponse, KVService, KVServiceConfig, KeyInfo, KeyProvider, KeyType, Manifest, ManifestDefaults, ManifestDelegation, ManifestValidationError, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PrefixedKVService, ProtocolMismatchError, QueryOptions, QueryResponse, ReceiveOptions, ResolvedCapabilities, ResolvedDelegate, ResourceCapability, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, ServiceContext, ServiceContextConfig, ServiceSession, SessionExpiredError, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignRequest, SignResponse, SilentNotificationHandler, Space, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, TableInfo, TinyCloud, TinyCloudConfig, TinyCloudSession, UnsupportedFeatureError, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultPublicSpaceKVActions, VaultPutOptions, VersionCheckError, ViewInfo, WasmVaultFunctions, buildSpaceUri, checkNodeInfo, createCapabilityKeyRegistry, createSharingService, createSpaceService, createVaultCrypto, defaultSpaceCreationHandler, expandActionShortNames, isCapabilitySubset, loadManifest, makePublicSpaceId, parseExpiry, parseSpaceUri, resolveManifest, validateManifest } from '@tinycloud/sdk-core';
|
|
3
3
|
import { EventEmitter } from 'events';
|
|
4
4
|
import { InvokeFunction } from '@tinycloud/sdk-services';
|
|
5
5
|
|
|
@@ -444,6 +444,7 @@ declare class DelegatedAccess {
|
|
|
444
444
|
private _kv;
|
|
445
445
|
private _sql;
|
|
446
446
|
private _duckdb;
|
|
447
|
+
private _hooks;
|
|
447
448
|
constructor(session: TinyCloudSession, delegation: PortableDelegation, host: string, invoke: InvokeFunction);
|
|
448
449
|
/**
|
|
449
450
|
* Get the delegation this access was created from.
|
|
@@ -469,6 +470,10 @@ declare class DelegatedAccess {
|
|
|
469
470
|
* DuckDB operations on the delegated space.
|
|
470
471
|
*/
|
|
471
472
|
get duckdb(): IDuckDbService;
|
|
473
|
+
/**
|
|
474
|
+
* Hooks write-stream subscriptions on the delegated space.
|
|
475
|
+
*/
|
|
476
|
+
get hooks(): IHooksService;
|
|
472
477
|
}
|
|
473
478
|
|
|
474
479
|
/**
|
|
@@ -545,6 +550,35 @@ interface TinyCloudNodeConfig {
|
|
|
545
550
|
/** Optional SIWE configuration overrides (e.g., nonce for server-provided nonces) */
|
|
546
551
|
siweConfig?: SiweConfig;
|
|
547
552
|
}
|
|
553
|
+
/**
|
|
554
|
+
* Options for {@link TinyCloudNode.delegateTo}.
|
|
555
|
+
*
|
|
556
|
+
* `expiry` accepts either an ms-format duration string (e.g. `"7d"`, `"1h"`)
|
|
557
|
+
* or a raw number of milliseconds. When omitted, the default is 1 hour.
|
|
558
|
+
*
|
|
559
|
+
* `forceWalletSign` bypasses the derivability check and sends the
|
|
560
|
+
* delegation through the legacy wallet-signed SIWE path, which always
|
|
561
|
+
* triggers a wallet prompt. Used for testing, for explicit wallet
|
|
562
|
+
* confirmation flows, and by the legacy `createDelegation` fallback.
|
|
563
|
+
*/
|
|
564
|
+
interface DelegateToOptions {
|
|
565
|
+
/** Override expiry. ms-format string ("7d", "1h") or raw milliseconds. */
|
|
566
|
+
expiry?: string | number;
|
|
567
|
+
/** Force the wallet-signed SIWE path even if the caps are derivable. Default false. */
|
|
568
|
+
forceWalletSign?: boolean;
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Result of {@link TinyCloudNode.delegateTo}.
|
|
572
|
+
*
|
|
573
|
+
* `prompted` indicates whether a wallet prompt was shown — `true` for the
|
|
574
|
+
* legacy wallet path (always), `false` for the session-key UCAN path (never).
|
|
575
|
+
* Callers wiring single-prompt sign-in flows use this to assert that their
|
|
576
|
+
* capability chain was derivable.
|
|
577
|
+
*/
|
|
578
|
+
interface DelegateToResult {
|
|
579
|
+
delegation: PortableDelegation;
|
|
580
|
+
prompted: boolean;
|
|
581
|
+
}
|
|
548
582
|
/**
|
|
549
583
|
* High-level TinyCloud API for Node.js environments.
|
|
550
584
|
*
|
|
@@ -573,6 +607,7 @@ declare class TinyCloudNode {
|
|
|
573
607
|
private _kv?;
|
|
574
608
|
private _sql?;
|
|
575
609
|
private _duckdb?;
|
|
610
|
+
private _hooks?;
|
|
576
611
|
private _vault?;
|
|
577
612
|
/** Cached public KV with proper delegation (set by ensurePublicSpace) */
|
|
578
613
|
private _publicKV?;
|
|
@@ -776,6 +811,10 @@ declare class TinyCloudNode {
|
|
|
776
811
|
* Call `vault.unlock(signer)` after signIn() to derive encryption keys.
|
|
777
812
|
*/
|
|
778
813
|
get vault(): IDataVaultService;
|
|
814
|
+
/**
|
|
815
|
+
* Hooks write stream subscription API.
|
|
816
|
+
*/
|
|
817
|
+
get hooks(): IHooksService;
|
|
779
818
|
/**
|
|
780
819
|
* Get the CapabilityKeyRegistry for managing keys and their capabilities.
|
|
781
820
|
*
|
|
@@ -967,6 +1006,58 @@ declare class TinyCloudNode {
|
|
|
967
1006
|
* @returns Result containing boolean permission status
|
|
968
1007
|
*/
|
|
969
1008
|
checkPermission(path: string, action: string): Promise<DelegationResult<boolean>>;
|
|
1009
|
+
/**
|
|
1010
|
+
* Safety margin before the session's own expiry at which {@link delegateTo}
|
|
1011
|
+
* will refuse to issue a derived delegation. Prevents issuing sub-delegations
|
|
1012
|
+
* that would be invalid by the time the recipient used them. Spec: 60 seconds.
|
|
1013
|
+
*
|
|
1014
|
+
* @internal
|
|
1015
|
+
*/
|
|
1016
|
+
private static readonly SESSION_EXPIRY_SAFETY_MARGIN_MS;
|
|
1017
|
+
/**
|
|
1018
|
+
* Issue a delegation using the capability-chain flow.
|
|
1019
|
+
*
|
|
1020
|
+
* When the requested permissions are a subset of the current session's
|
|
1021
|
+
* recap, the delegation is signed by the session key via WASM — no wallet
|
|
1022
|
+
* prompt. When they are not, a {@link PermissionNotInManifestError} is
|
|
1023
|
+
* raised so the caller can trigger an escalation flow (e.g.
|
|
1024
|
+
* `TinyCloudWeb.requestPermissions`). Passing `forceWalletSign: true`
|
|
1025
|
+
* bypasses the derivability check and always uses the wallet-signed SIWE
|
|
1026
|
+
* path — used by the legacy `createDelegation` fallback and by callers
|
|
1027
|
+
* that want explicit wallet confirmation.
|
|
1028
|
+
*
|
|
1029
|
+
* Current limitation: exactly one {@link PermissionEntry} per call. For
|
|
1030
|
+
* multi-resource delegation, call `delegateTo` multiple times. This keeps
|
|
1031
|
+
* each delegation a single `(spaceId, path)` grant, which matches the
|
|
1032
|
+
* underlying `PortableDelegation` shape.
|
|
1033
|
+
*
|
|
1034
|
+
* @throws {@link SessionExpiredError} when there is no session or the
|
|
1035
|
+
* current session has expired (or will within the 60s safety margin).
|
|
1036
|
+
* @throws {@link PermissionNotInManifestError} when the requested entries
|
|
1037
|
+
* are not a subset of the granted session capabilities and
|
|
1038
|
+
* `forceWalletSign` is not set.
|
|
1039
|
+
*/
|
|
1040
|
+
delegateTo(did: string, permissions: PermissionEntry[], options?: DelegateToOptions): Promise<DelegateToResult>;
|
|
1041
|
+
/**
|
|
1042
|
+
* Issue a delegation via the session-key UCAN WASM path.
|
|
1043
|
+
*
|
|
1044
|
+
* The caller has already verified the request is derivable from the
|
|
1045
|
+
* current session; we just need to shape the inputs for
|
|
1046
|
+
* {@link createDelegationWrapper}.
|
|
1047
|
+
*
|
|
1048
|
+
* @internal
|
|
1049
|
+
*/
|
|
1050
|
+
private createDelegationViaWasmPath;
|
|
1051
|
+
/**
|
|
1052
|
+
* Issue a delegation via the legacy wallet-signed SIWE path for a single
|
|
1053
|
+
* {@link PermissionEntry}. Shares the implementation with the public
|
|
1054
|
+
* `createDelegation` method via {@link createDelegationWalletPath} so
|
|
1055
|
+
* both entry points hit exactly the same SIWE / signer / public-space
|
|
1056
|
+
* logic without mutual recursion.
|
|
1057
|
+
*
|
|
1058
|
+
* @internal
|
|
1059
|
+
*/
|
|
1060
|
+
private createDelegationLegacyWalletPath;
|
|
970
1061
|
/**
|
|
971
1062
|
* Create a delegation from this user to another user.
|
|
972
1063
|
*
|
|
@@ -992,6 +1083,14 @@ declare class TinyCloudNode {
|
|
|
992
1083
|
/** Include a companion delegation for the user's public space (default: true) */
|
|
993
1084
|
includePublicSpace?: boolean;
|
|
994
1085
|
}): Promise<PortableDelegation>;
|
|
1086
|
+
/**
|
|
1087
|
+
* Legacy wallet-signed SIWE delegation path. Lifted from the original
|
|
1088
|
+
* `createDelegation` body verbatim so both the legacy public method and
|
|
1089
|
+
* `delegateTo({ forceWalletSign: true })` hit the same code.
|
|
1090
|
+
*
|
|
1091
|
+
* @internal
|
|
1092
|
+
*/
|
|
1093
|
+
private createDelegationWalletPath;
|
|
995
1094
|
/**
|
|
996
1095
|
* Use a delegation received from another user.
|
|
997
1096
|
*
|
|
@@ -1138,4 +1237,4 @@ declare class WasmKeyProvider implements KeyProvider {
|
|
|
1138
1237
|
*/
|
|
1139
1238
|
declare function createWasmKeyProvider(sessionManager: SessionManagerWithListing): WasmKeyProvider;
|
|
1140
1239
|
|
|
1141
|
-
export { DelegatedAccess, FileSessionStorage, MemorySessionStorage, type NodeEventEmitterStrategy, NodeUserAuthorization, type NodeUserAuthorizationConfig, type PortableDelegation, type SignStrategy, TinyCloudNode, type TinyCloudNodeConfig, WasmKeyProvider, type WasmKeyProviderConfig, createWasmKeyProvider, defaultSignStrategy, deserializeDelegation, serializeDelegation };
|
|
1240
|
+
export { type DelegateToOptions, type DelegateToResult, DelegatedAccess, FileSessionStorage, MemorySessionStorage, type NodeEventEmitterStrategy, NodeUserAuthorization, type NodeUserAuthorizationConfig, type PortableDelegation, type SignStrategy, TinyCloudNode, type TinyCloudNodeConfig, WasmKeyProvider, type WasmKeyProviderConfig, createWasmKeyProvider, defaultSignStrategy, deserializeDelegation, serializeDelegation };
|