@tinycloud/node-sdk 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +55 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +60 -11
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ISigner, Bytes, ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ClientSession, TinyCloudSession, Extension, Delegation, IKVService, ISQLService, IDuckDbService, IDataVaultService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISharingService, CreateDelegationParams, DelegationResult, KeyProvider, JWK } from '@tinycloud/sdk-core';
|
|
2
|
-
export { 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, IKVService, IPrefixedKVService, ISQLService, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, 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, Space, SpaceConfig, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, TableInfo, TinyCloud, TinyCloudConfig, TinyCloudSession, UnsupportedFeatureError,
|
|
2
|
+
export { 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, IKVService, IPrefixedKVService, ISQLService, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, 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, Space, SpaceConfig, 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, makePublicSpaceId, parseSpaceUri } from '@tinycloud/sdk-core';
|
|
3
3
|
import { EventEmitter } from 'events';
|
|
4
4
|
import { TCWSessionManager } from '@tinycloud/node-sdk-wasm';
|
|
5
5
|
|
|
@@ -442,6 +442,8 @@ interface PortableDelegation extends Omit<Delegation, "isRevoked"> {
|
|
|
442
442
|
host?: string;
|
|
443
443
|
/** Whether the recipient is prevented from creating sub-delegations */
|
|
444
444
|
disableSubDelegation?: boolean;
|
|
445
|
+
/** Companion delegation for the user's public space (auto-created when includePublicSpace is true) */
|
|
446
|
+
publicDelegation?: PortableDelegation;
|
|
445
447
|
}
|
|
446
448
|
/**
|
|
447
449
|
* Serialize a PortableDelegation for transport (e.g., over network).
|
|
@@ -953,6 +955,8 @@ declare class TinyCloudNode {
|
|
|
953
955
|
expiryMs?: number;
|
|
954
956
|
/** Override space ID (for creating delegations to non-primary spaces like public) */
|
|
955
957
|
spaceIdOverride?: string;
|
|
958
|
+
/** Include a companion delegation for the user's public space (default: true) */
|
|
959
|
+
includePublicSpace?: boolean;
|
|
956
960
|
}): Promise<PortableDelegation>;
|
|
957
961
|
/**
|
|
958
962
|
* Use a delegation received from another user.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ISigner, Bytes, ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ClientSession, TinyCloudSession, Extension, Delegation, IKVService, ISQLService, IDuckDbService, IDataVaultService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISharingService, CreateDelegationParams, DelegationResult, KeyProvider, JWK } from '@tinycloud/sdk-core';
|
|
2
|
-
export { 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, IKVService, IPrefixedKVService, ISQLService, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, 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, Space, SpaceConfig, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, TableInfo, TinyCloud, TinyCloudConfig, TinyCloudSession, UnsupportedFeatureError,
|
|
2
|
+
export { 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, IKVService, IPrefixedKVService, ISQLService, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, 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, Space, SpaceConfig, 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, makePublicSpaceId, parseSpaceUri } from '@tinycloud/sdk-core';
|
|
3
3
|
import { EventEmitter } from 'events';
|
|
4
4
|
import { TCWSessionManager } from '@tinycloud/node-sdk-wasm';
|
|
5
5
|
|
|
@@ -442,6 +442,8 @@ interface PortableDelegation extends Omit<Delegation, "isRevoked"> {
|
|
|
442
442
|
host?: string;
|
|
443
443
|
/** Whether the recipient is prevented from creating sub-delegations */
|
|
444
444
|
disableSubDelegation?: boolean;
|
|
445
|
+
/** Companion delegation for the user's public space (auto-created when includePublicSpace is true) */
|
|
446
|
+
publicDelegation?: PortableDelegation;
|
|
445
447
|
}
|
|
446
448
|
/**
|
|
447
449
|
* Serialize a PortableDelegation for transport (e.g., over network).
|
|
@@ -953,6 +955,8 @@ declare class TinyCloudNode {
|
|
|
953
955
|
expiryMs?: number;
|
|
954
956
|
/** Override space ID (for creating delegations to non-primary spaces like public) */
|
|
955
957
|
spaceIdOverride?: string;
|
|
958
|
+
/** Include a companion delegation for the user's public space (default: true) */
|
|
959
|
+
includePublicSpace?: boolean;
|
|
956
960
|
}): Promise<PortableDelegation>;
|
|
957
961
|
/**
|
|
958
962
|
* Use a delegation received from another user.
|
package/dist/index.js
CHANGED
|
@@ -17292,7 +17292,7 @@ import {
|
|
|
17292
17292
|
fetchPeerId,
|
|
17293
17293
|
submitHostDelegation,
|
|
17294
17294
|
activateSessionWithHost,
|
|
17295
|
-
|
|
17295
|
+
checkNodeInfo
|
|
17296
17296
|
} from "@tinycloud/sdk-core";
|
|
17297
17297
|
import {
|
|
17298
17298
|
TCWSessionManager as SessionManager,
|
|
@@ -17575,7 +17575,8 @@ var _NodeUserAuthorization = class _NodeUserAuthorization {
|
|
|
17575
17575
|
this._tinyCloudSession = tinyCloudSession;
|
|
17576
17576
|
this._address = address;
|
|
17577
17577
|
this._chainId = chainId;
|
|
17578
|
-
|
|
17578
|
+
const nodeInfo = await checkNodeInfo(this.tinycloudHosts[0], protocolVersion());
|
|
17579
|
+
this._nodeFeatures = nodeInfo.features;
|
|
17579
17580
|
for (const ext of this.extensions) {
|
|
17580
17581
|
if (ext.afterSignIn) {
|
|
17581
17582
|
await ext.afterSignIn(clientSession);
|
|
@@ -17733,7 +17734,8 @@ var _NodeUserAuthorization = class _NodeUserAuthorization {
|
|
|
17733
17734
|
this._tinyCloudSession = tinyCloudSession;
|
|
17734
17735
|
this._address = address;
|
|
17735
17736
|
this._chainId = chainId;
|
|
17736
|
-
|
|
17737
|
+
const nodeInfo = await checkNodeInfo(this.tinycloudHosts[0], protocolVersion());
|
|
17738
|
+
this._nodeFeatures = nodeInfo.features;
|
|
17737
17739
|
for (const ext of this.extensions) {
|
|
17738
17740
|
if (ext.afterSignIn) {
|
|
17739
17741
|
await ext.afterSignIn(clientSession);
|
|
@@ -17827,7 +17829,8 @@ import {
|
|
|
17827
17829
|
SpaceService,
|
|
17828
17830
|
CapabilityKeyRegistry,
|
|
17829
17831
|
SharingService,
|
|
17830
|
-
UnsupportedFeatureError
|
|
17832
|
+
UnsupportedFeatureError,
|
|
17833
|
+
makePublicSpaceId
|
|
17831
17834
|
} from "@tinycloud/sdk-core";
|
|
17832
17835
|
import {
|
|
17833
17836
|
TCWSessionManager as SessionManager2,
|
|
@@ -18980,7 +18983,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18980
18983
|
if (!activateResult.success) {
|
|
18981
18984
|
throw new Error(`Failed to activate delegation: ${activateResult.error}`);
|
|
18982
18985
|
}
|
|
18983
|
-
|
|
18986
|
+
const result = {
|
|
18984
18987
|
cid: delegationSession.delegationCid,
|
|
18985
18988
|
delegationHeader: delegationSession.delegationHeader,
|
|
18986
18989
|
spaceId: params.spaceIdOverride ?? session.spaceId,
|
|
@@ -18993,6 +18996,52 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18993
18996
|
chainId: session.chainId,
|
|
18994
18997
|
host: this.config.host
|
|
18995
18998
|
};
|
|
18999
|
+
const hasKvActions = params.actions.some((a) => a.startsWith("tinycloud.kv/"));
|
|
19000
|
+
if (hasKvActions && params.includePublicSpace !== false) {
|
|
19001
|
+
const publicSpaceId = makePublicSpaceId(
|
|
19002
|
+
ensureEip553(session.address),
|
|
19003
|
+
session.chainId
|
|
19004
|
+
);
|
|
19005
|
+
const publicAbilities = {
|
|
19006
|
+
kv: { "": ["tinycloud.kv/get", "tinycloud.kv/put", "tinycloud.kv/metadata"] }
|
|
19007
|
+
};
|
|
19008
|
+
const publicPrepared = prepareSession2({
|
|
19009
|
+
abilities: publicAbilities,
|
|
19010
|
+
address: ensureEip553(session.address),
|
|
19011
|
+
chainId: session.chainId,
|
|
19012
|
+
domain: new URL(this.config.host).hostname,
|
|
19013
|
+
issuedAt: now.toISOString(),
|
|
19014
|
+
expirationTime: expirationTime.toISOString(),
|
|
19015
|
+
spaceId: publicSpaceId,
|
|
19016
|
+
delegateUri: params.delegateDID,
|
|
19017
|
+
parents: [session.delegationCid]
|
|
19018
|
+
});
|
|
19019
|
+
const publicSignature = await this.signer.signMessage(publicPrepared.siwe);
|
|
19020
|
+
const publicSession = completeSessionSetup2({
|
|
19021
|
+
...publicPrepared,
|
|
19022
|
+
signature: publicSignature
|
|
19023
|
+
});
|
|
19024
|
+
const publicActivateResult = await activateSessionWithHost2(
|
|
19025
|
+
this.config.host,
|
|
19026
|
+
publicSession.delegationHeader
|
|
19027
|
+
);
|
|
19028
|
+
if (publicActivateResult.success) {
|
|
19029
|
+
result.publicDelegation = {
|
|
19030
|
+
cid: publicSession.delegationCid,
|
|
19031
|
+
delegationHeader: publicSession.delegationHeader,
|
|
19032
|
+
spaceId: publicSpaceId,
|
|
19033
|
+
path: "",
|
|
19034
|
+
actions: ["tinycloud.kv/get", "tinycloud.kv/put", "tinycloud.kv/metadata"],
|
|
19035
|
+
disableSubDelegation: params.disableSubDelegation ?? false,
|
|
19036
|
+
expiry: expirationTime,
|
|
19037
|
+
delegateDID: params.delegateDID,
|
|
19038
|
+
ownerAddress: session.address,
|
|
19039
|
+
chainId: session.chainId,
|
|
19040
|
+
host: this.config.host
|
|
19041
|
+
};
|
|
19042
|
+
}
|
|
19043
|
+
}
|
|
19044
|
+
return result;
|
|
18996
19045
|
}
|
|
18997
19046
|
/**
|
|
18998
19047
|
* Use a delegation received from another user.
|
|
@@ -19206,7 +19255,7 @@ function deserializeDelegation(data) {
|
|
|
19206
19255
|
import { KVService as KVService3, PrefixedKVService } from "@tinycloud/sdk-core";
|
|
19207
19256
|
import { SQLService as SQLService3, SQLAction, DatabaseHandle } from "@tinycloud/sdk-core";
|
|
19208
19257
|
import { DuckDbService as DuckDbService3, DuckDbDatabaseHandle, DuckDbAction } from "@tinycloud/sdk-core";
|
|
19209
|
-
import { DataVaultService as DataVaultService2,
|
|
19258
|
+
import { DataVaultService as DataVaultService2, VaultHeaders, VaultPublicSpaceKVActions, createVaultCrypto as createVaultCrypto2 } from "@tinycloud/sdk-core";
|
|
19210
19259
|
import {
|
|
19211
19260
|
DelegationManager as DelegationManager2,
|
|
19212
19261
|
SharingService as SharingService2,
|
|
@@ -19224,14 +19273,14 @@ import {
|
|
|
19224
19273
|
createSpaceService,
|
|
19225
19274
|
parseSpaceUri,
|
|
19226
19275
|
buildSpaceUri,
|
|
19227
|
-
makePublicSpaceId,
|
|
19276
|
+
makePublicSpaceId as makePublicSpaceId2,
|
|
19228
19277
|
Space
|
|
19229
19278
|
} from "@tinycloud/sdk-core";
|
|
19230
19279
|
import {
|
|
19231
19280
|
ProtocolMismatchError,
|
|
19232
19281
|
VersionCheckError,
|
|
19233
19282
|
UnsupportedFeatureError as UnsupportedFeatureError2,
|
|
19234
|
-
|
|
19283
|
+
checkNodeInfo as checkNodeInfo2
|
|
19235
19284
|
} from "@tinycloud/sdk-core";
|
|
19236
19285
|
import { ServiceContext as ServiceContext3 } from "@tinycloud/sdk-core";
|
|
19237
19286
|
export {
|
|
@@ -19262,12 +19311,12 @@ export {
|
|
|
19262
19311
|
TinyCloud2 as TinyCloud,
|
|
19263
19312
|
TinyCloudNode,
|
|
19264
19313
|
UnsupportedFeatureError2 as UnsupportedFeatureError,
|
|
19265
|
-
VaultAction,
|
|
19266
19314
|
VaultHeaders,
|
|
19315
|
+
VaultPublicSpaceKVActions,
|
|
19267
19316
|
VersionCheckError,
|
|
19268
19317
|
WasmKeyProvider,
|
|
19269
19318
|
buildSpaceUri,
|
|
19270
|
-
|
|
19319
|
+
checkNodeInfo2 as checkNodeInfo,
|
|
19271
19320
|
createCapabilityKeyRegistry,
|
|
19272
19321
|
createSharingService,
|
|
19273
19322
|
createSpaceService,
|
|
@@ -19275,7 +19324,7 @@ export {
|
|
|
19275
19324
|
createWasmKeyProvider,
|
|
19276
19325
|
defaultSignStrategy,
|
|
19277
19326
|
deserializeDelegation,
|
|
19278
|
-
makePublicSpaceId,
|
|
19327
|
+
makePublicSpaceId2 as makePublicSpaceId,
|
|
19279
19328
|
parseSpaceUri,
|
|
19280
19329
|
serializeDelegation
|
|
19281
19330
|
};
|