@tinycloud/node-sdk 2.0.4-beta.0 → 2.1.0-beta.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/core.cjs +67 -9
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +11 -1
- package/dist/core.d.ts +11 -1
- package/dist/core.js +69 -9
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +90 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +84 -11
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -17026,51 +17026,52 @@ var require_utils2 = __commonJS({
|
|
|
17026
17026
|
var index_exports = {};
|
|
17027
17027
|
__export(index_exports, {
|
|
17028
17028
|
AutoApproveSpaceCreationHandler: () => import_sdk_core6.AutoApproveSpaceCreationHandler,
|
|
17029
|
-
CapabilityKeyRegistry: () =>
|
|
17030
|
-
CapabilityKeyRegistryErrorCodes: () =>
|
|
17029
|
+
CapabilityKeyRegistry: () => import_sdk_core13.CapabilityKeyRegistry,
|
|
17030
|
+
CapabilityKeyRegistryErrorCodes: () => import_sdk_core13.CapabilityKeyRegistryErrorCodes,
|
|
17031
17031
|
DataVaultService: () => import_sdk_core10.DataVaultService,
|
|
17032
17032
|
DatabaseHandle: () => import_sdk_core8.DatabaseHandle,
|
|
17033
17033
|
DelegatedAccess: () => DelegatedAccess,
|
|
17034
|
-
DelegationErrorCodes: () =>
|
|
17035
|
-
DelegationManager: () =>
|
|
17034
|
+
DelegationErrorCodes: () => import_sdk_core12.DelegationErrorCodes,
|
|
17035
|
+
DelegationManager: () => import_sdk_core12.DelegationManager,
|
|
17036
17036
|
DuckDbAction: () => import_sdk_core9.DuckDbAction,
|
|
17037
17037
|
DuckDbDatabaseHandle: () => import_sdk_core9.DuckDbDatabaseHandle,
|
|
17038
17038
|
DuckDbService: () => import_sdk_core9.DuckDbService,
|
|
17039
17039
|
FileSessionStorage: () => FileSessionStorage,
|
|
17040
|
+
HooksService: () => import_sdk_core11.HooksService,
|
|
17040
17041
|
KVService: () => import_sdk_core7.KVService,
|
|
17041
17042
|
MemorySessionStorage: () => MemorySessionStorage,
|
|
17042
17043
|
NodeUserAuthorization: () => NodeUserAuthorization,
|
|
17043
17044
|
NodeWasmBindings: () => NodeWasmBindings,
|
|
17044
17045
|
PrefixedKVService: () => import_sdk_core7.PrefixedKVService,
|
|
17045
17046
|
PrivateKeySigner: () => PrivateKeySigner,
|
|
17046
|
-
ProtocolMismatchError: () =>
|
|
17047
|
+
ProtocolMismatchError: () => import_sdk_core15.ProtocolMismatchError,
|
|
17047
17048
|
SQLAction: () => import_sdk_core8.SQLAction,
|
|
17048
17049
|
SQLService: () => import_sdk_core8.SQLService,
|
|
17049
|
-
ServiceContext: () =>
|
|
17050
|
-
SharingService: () =>
|
|
17050
|
+
ServiceContext: () => import_sdk_core16.ServiceContext,
|
|
17051
|
+
SharingService: () => import_sdk_core12.SharingService,
|
|
17051
17052
|
SilentNotificationHandler: () => import_sdk_core6.SilentNotificationHandler,
|
|
17052
|
-
Space: () =>
|
|
17053
|
-
SpaceErrorCodes: () =>
|
|
17054
|
-
SpaceService: () =>
|
|
17053
|
+
Space: () => import_sdk_core14.Space,
|
|
17054
|
+
SpaceErrorCodes: () => import_sdk_core14.SpaceErrorCodes,
|
|
17055
|
+
SpaceService: () => import_sdk_core14.SpaceService,
|
|
17055
17056
|
TinyCloud: () => import_sdk_core5.TinyCloud,
|
|
17056
17057
|
TinyCloudNode: () => TinyCloudNode,
|
|
17057
|
-
UnsupportedFeatureError: () =>
|
|
17058
|
+
UnsupportedFeatureError: () => import_sdk_core15.UnsupportedFeatureError,
|
|
17058
17059
|
VaultHeaders: () => import_sdk_core10.VaultHeaders,
|
|
17059
17060
|
VaultPublicSpaceKVActions: () => import_sdk_core10.VaultPublicSpaceKVActions,
|
|
17060
|
-
VersionCheckError: () =>
|
|
17061
|
+
VersionCheckError: () => import_sdk_core15.VersionCheckError,
|
|
17061
17062
|
WasmKeyProvider: () => WasmKeyProvider,
|
|
17062
|
-
buildSpaceUri: () =>
|
|
17063
|
-
checkNodeInfo: () =>
|
|
17064
|
-
createCapabilityKeyRegistry: () =>
|
|
17065
|
-
createSharingService: () =>
|
|
17066
|
-
createSpaceService: () =>
|
|
17063
|
+
buildSpaceUri: () => import_sdk_core14.buildSpaceUri,
|
|
17064
|
+
checkNodeInfo: () => import_sdk_core15.checkNodeInfo,
|
|
17065
|
+
createCapabilityKeyRegistry: () => import_sdk_core13.createCapabilityKeyRegistry,
|
|
17066
|
+
createSharingService: () => import_sdk_core12.createSharingService,
|
|
17067
|
+
createSpaceService: () => import_sdk_core14.createSpaceService,
|
|
17067
17068
|
createVaultCrypto: () => import_sdk_core10.createVaultCrypto,
|
|
17068
17069
|
createWasmKeyProvider: () => createWasmKeyProvider,
|
|
17069
17070
|
defaultSignStrategy: () => defaultSignStrategy,
|
|
17070
17071
|
defaultSpaceCreationHandler: () => import_sdk_core6.defaultSpaceCreationHandler,
|
|
17071
17072
|
deserializeDelegation: () => deserializeDelegation,
|
|
17072
|
-
makePublicSpaceId: () =>
|
|
17073
|
-
parseSpaceUri: () =>
|
|
17073
|
+
makePublicSpaceId: () => import_sdk_core14.makePublicSpaceId,
|
|
17074
|
+
parseSpaceUri: () => import_sdk_core14.parseSpaceUri,
|
|
17074
17075
|
serializeDelegation: () => serializeDelegation
|
|
17075
17076
|
});
|
|
17076
17077
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -17080,6 +17081,7 @@ var import_node_sdk_wasm = require("@tinycloud/node-sdk-wasm");
|
|
|
17080
17081
|
var _NodeWasmBindings = class _NodeWasmBindings {
|
|
17081
17082
|
constructor() {
|
|
17082
17083
|
this.invoke = import_node_sdk_wasm.invoke;
|
|
17084
|
+
this.invokeAny = import_node_sdk_wasm.invokeAny;
|
|
17083
17085
|
this.prepareSession = import_node_sdk_wasm.prepareSession;
|
|
17084
17086
|
this.completeSessionSetup = import_node_sdk_wasm.completeSessionSetup;
|
|
17085
17087
|
this.ensureEip55 = import_node_sdk_wasm.ensureEip55;
|
|
@@ -17296,12 +17298,22 @@ var NodeUserAuthorization = class {
|
|
|
17296
17298
|
},
|
|
17297
17299
|
capabilities: {
|
|
17298
17300
|
"": ["tinycloud.capabilities/read"]
|
|
17301
|
+
},
|
|
17302
|
+
hooks: {
|
|
17303
|
+
"": [
|
|
17304
|
+
"tinycloud.hooks/subscribe",
|
|
17305
|
+
"tinycloud.hooks/register",
|
|
17306
|
+
"tinycloud.hooks/list",
|
|
17307
|
+
"tinycloud.hooks/unregister"
|
|
17308
|
+
]
|
|
17299
17309
|
}
|
|
17300
17310
|
};
|
|
17301
17311
|
this.sessionExpirationMs = config.sessionExpirationMs ?? 60 * 60 * 1e3;
|
|
17302
17312
|
this.autoCreateSpace = config.autoCreateSpace ?? false;
|
|
17303
17313
|
this.spaceCreationHandler = config.spaceCreationHandler;
|
|
17304
|
-
this.tinycloudHosts = config.tinycloudHosts ?? [
|
|
17314
|
+
this.tinycloudHosts = config.tinycloudHosts ?? [
|
|
17315
|
+
"https://node.tinycloud.xyz"
|
|
17316
|
+
];
|
|
17305
17317
|
this.enablePublicSpace = config.enablePublicSpace ?? true;
|
|
17306
17318
|
this.nonce = config.nonce;
|
|
17307
17319
|
this.siweConfig = config.siweConfig;
|
|
@@ -17441,7 +17453,10 @@ var NodeUserAuthorization = class {
|
|
|
17441
17453
|
throw err;
|
|
17442
17454
|
}
|
|
17443
17455
|
} catch (error) {
|
|
17444
|
-
handler.onSpaceCreationFailed?.(
|
|
17456
|
+
handler.onSpaceCreationFailed?.(
|
|
17457
|
+
creationContext,
|
|
17458
|
+
error instanceof Error ? error : new Error(String(error))
|
|
17459
|
+
);
|
|
17445
17460
|
throw error;
|
|
17446
17461
|
}
|
|
17447
17462
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
@@ -17475,7 +17490,10 @@ var NodeUserAuthorization = class {
|
|
|
17475
17490
|
throw err;
|
|
17476
17491
|
}
|
|
17477
17492
|
} catch (error) {
|
|
17478
|
-
handler.onSpaceCreationFailed?.(
|
|
17493
|
+
handler.onSpaceCreationFailed?.(
|
|
17494
|
+
creationContext,
|
|
17495
|
+
error instanceof Error ? error : new Error(String(error))
|
|
17496
|
+
);
|
|
17479
17497
|
throw error;
|
|
17480
17498
|
}
|
|
17481
17499
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
@@ -17584,7 +17602,10 @@ var NodeUserAuthorization = class {
|
|
|
17584
17602
|
this._tinyCloudSession = tinyCloudSession;
|
|
17585
17603
|
this._address = address;
|
|
17586
17604
|
this._chainId = chainId;
|
|
17587
|
-
const nodeInfo = await (0, import_sdk_core.checkNodeInfo)(
|
|
17605
|
+
const nodeInfo = await (0, import_sdk_core.checkNodeInfo)(
|
|
17606
|
+
this.tinycloudHosts[0],
|
|
17607
|
+
this.wasm.protocolVersion()
|
|
17608
|
+
);
|
|
17588
17609
|
this._nodeFeatures = nodeInfo.features;
|
|
17589
17610
|
for (const ext of this.extensions) {
|
|
17590
17611
|
if (ext.afterSignIn) {
|
|
@@ -17744,7 +17765,10 @@ var NodeUserAuthorization = class {
|
|
|
17744
17765
|
this._tinyCloudSession = tinyCloudSession;
|
|
17745
17766
|
this._address = address;
|
|
17746
17767
|
this._chainId = chainId;
|
|
17747
|
-
const nodeInfo = await (0, import_sdk_core.checkNodeInfo)(
|
|
17768
|
+
const nodeInfo = await (0, import_sdk_core.checkNodeInfo)(
|
|
17769
|
+
this.tinycloudHosts[0],
|
|
17770
|
+
this.wasm.protocolVersion()
|
|
17771
|
+
);
|
|
17748
17772
|
this._nodeFeatures = nodeInfo.features;
|
|
17749
17773
|
for (const ext of this.extensions) {
|
|
17750
17774
|
if (ext.afterSignIn) {
|
|
@@ -17795,7 +17819,9 @@ var NodeUserAuthorization = class {
|
|
|
17795
17819
|
);
|
|
17796
17820
|
}
|
|
17797
17821
|
default:
|
|
17798
|
-
throw new Error(
|
|
17822
|
+
throw new Error(
|
|
17823
|
+
`Unknown sign strategy: ${this.signStrategy.type}`
|
|
17824
|
+
);
|
|
17799
17825
|
}
|
|
17800
17826
|
}
|
|
17801
17827
|
/**
|
|
@@ -17844,6 +17870,9 @@ var DelegatedAccess = class {
|
|
|
17844
17870
|
this._duckdb = new import_sdk_core2.DuckDbService({});
|
|
17845
17871
|
this._duckdb.initialize(this._serviceContext);
|
|
17846
17872
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
17873
|
+
this._hooks = new import_sdk_core2.HooksService({});
|
|
17874
|
+
this._hooks.initialize(this._serviceContext);
|
|
17875
|
+
this._serviceContext.registerService("hooks", this._hooks);
|
|
17847
17876
|
const serviceSession = {
|
|
17848
17877
|
delegationHeader: session.delegationHeader,
|
|
17849
17878
|
delegationCid: session.delegationCid,
|
|
@@ -17889,6 +17918,12 @@ var DelegatedAccess = class {
|
|
|
17889
17918
|
get duckdb() {
|
|
17890
17919
|
return this._duckdb;
|
|
17891
17920
|
}
|
|
17921
|
+
/**
|
|
17922
|
+
* Hooks write-stream subscriptions on the delegated space.
|
|
17923
|
+
*/
|
|
17924
|
+
get hooks() {
|
|
17925
|
+
return this._hooks;
|
|
17926
|
+
}
|
|
17892
17927
|
};
|
|
17893
17928
|
|
|
17894
17929
|
// src/keys/WasmKeyProvider.ts
|
|
@@ -18094,7 +18129,9 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18094
18129
|
nonce: config.nonce,
|
|
18095
18130
|
siweConfig: config.siweConfig
|
|
18096
18131
|
});
|
|
18097
|
-
this.tc = new import_sdk_core3.TinyCloud(this.auth
|
|
18132
|
+
this.tc = new import_sdk_core3.TinyCloud(this.auth, {
|
|
18133
|
+
invokeAny: this.wasmBindings.invokeAny
|
|
18134
|
+
});
|
|
18098
18135
|
}
|
|
18099
18136
|
/**
|
|
18100
18137
|
* Get the primary identity DID for this user.
|
|
@@ -18163,6 +18200,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18163
18200
|
this._kv = void 0;
|
|
18164
18201
|
this._sql = void 0;
|
|
18165
18202
|
this._duckdb = void 0;
|
|
18203
|
+
this._hooks = void 0;
|
|
18166
18204
|
this._serviceContext = void 0;
|
|
18167
18205
|
await this.tc.signIn();
|
|
18168
18206
|
this.initializeServices();
|
|
@@ -18182,6 +18220,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18182
18220
|
this._kv = void 0;
|
|
18183
18221
|
this._sql = void 0;
|
|
18184
18222
|
this._duckdb = void 0;
|
|
18223
|
+
this._hooks = void 0;
|
|
18185
18224
|
this._serviceContext = void 0;
|
|
18186
18225
|
if (sessionData.address) {
|
|
18187
18226
|
this._address = sessionData.address;
|
|
@@ -18191,6 +18230,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18191
18230
|
}
|
|
18192
18231
|
this._serviceContext = new import_sdk_core3.ServiceContext({
|
|
18193
18232
|
invoke: this.wasmBindings.invoke,
|
|
18233
|
+
invokeAny: this.wasmBindings.invokeAny,
|
|
18194
18234
|
fetch: globalThis.fetch.bind(globalThis),
|
|
18195
18235
|
hosts: [this.config.host]
|
|
18196
18236
|
});
|
|
@@ -18203,6 +18243,9 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18203
18243
|
this._duckdb = new import_sdk_core3.DuckDbService({});
|
|
18204
18244
|
this._duckdb.initialize(this._serviceContext);
|
|
18205
18245
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
18246
|
+
this._hooks = new import_sdk_core3.HooksService({});
|
|
18247
|
+
this._hooks.initialize(this._serviceContext);
|
|
18248
|
+
this._serviceContext.registerService("hooks", this._hooks);
|
|
18206
18249
|
const serviceSession = {
|
|
18207
18250
|
delegationHeader: sessionData.delegationHeader,
|
|
18208
18251
|
delegationCid: sessionData.delegationCid,
|
|
@@ -18302,7 +18345,9 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18302
18345
|
nonce: this.config.nonce,
|
|
18303
18346
|
siweConfig: this.config.siweConfig
|
|
18304
18347
|
});
|
|
18305
|
-
this.tc = new import_sdk_core3.TinyCloud(this.auth
|
|
18348
|
+
this.tc = new import_sdk_core3.TinyCloud(this.auth, {
|
|
18349
|
+
invokeAny: this.wasmBindings.invokeAny
|
|
18350
|
+
});
|
|
18306
18351
|
this.config.prefix = prefix;
|
|
18307
18352
|
}
|
|
18308
18353
|
/**
|
|
@@ -18340,7 +18385,9 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18340
18385
|
nonce: this.config.nonce,
|
|
18341
18386
|
siweConfig: this.config.siweConfig
|
|
18342
18387
|
});
|
|
18343
|
-
this.tc = new import_sdk_core3.TinyCloud(this.auth
|
|
18388
|
+
this.tc = new import_sdk_core3.TinyCloud(this.auth, {
|
|
18389
|
+
invokeAny: this.wasmBindings.invokeAny
|
|
18390
|
+
});
|
|
18344
18391
|
this.config.prefix = prefix;
|
|
18345
18392
|
}
|
|
18346
18393
|
/**
|
|
@@ -18355,6 +18402,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18355
18402
|
this.tc.initializeServices(this.wasmBindings.invoke, [this.config.host]);
|
|
18356
18403
|
this._serviceContext = new import_sdk_core3.ServiceContext({
|
|
18357
18404
|
invoke: this.wasmBindings.invoke,
|
|
18405
|
+
invokeAny: this.wasmBindings.invokeAny,
|
|
18358
18406
|
fetch: globalThis.fetch.bind(globalThis),
|
|
18359
18407
|
hosts: [this.config.host]
|
|
18360
18408
|
});
|
|
@@ -18372,6 +18420,9 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18372
18420
|
this._duckdb.initialize(this._serviceContext);
|
|
18373
18421
|
this._serviceContext.registerService("duckdb", this._duckdb);
|
|
18374
18422
|
}
|
|
18423
|
+
this._hooks = new import_sdk_core3.HooksService({});
|
|
18424
|
+
this._hooks.initialize(this._serviceContext);
|
|
18425
|
+
this._serviceContext.registerService("hooks", this._hooks);
|
|
18375
18426
|
const serviceSession = {
|
|
18376
18427
|
delegationHeader: session.delegationHeader,
|
|
18377
18428
|
delegationCid: session.delegationCid,
|
|
@@ -18750,6 +18801,15 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
18750
18801
|
}
|
|
18751
18802
|
return this._vault;
|
|
18752
18803
|
}
|
|
18804
|
+
/**
|
|
18805
|
+
* Hooks write stream subscription API.
|
|
18806
|
+
*/
|
|
18807
|
+
get hooks() {
|
|
18808
|
+
if (!this._hooks) {
|
|
18809
|
+
throw new Error("Not signed in. Call signIn() first.");
|
|
18810
|
+
}
|
|
18811
|
+
return this._hooks;
|
|
18812
|
+
}
|
|
18753
18813
|
// ===========================================================================
|
|
18754
18814
|
// v2 Service Accessors
|
|
18755
18815
|
// ===========================================================================
|
|
@@ -19543,6 +19603,7 @@ var import_sdk_core12 = require("@tinycloud/sdk-core");
|
|
|
19543
19603
|
var import_sdk_core13 = require("@tinycloud/sdk-core");
|
|
19544
19604
|
var import_sdk_core14 = require("@tinycloud/sdk-core");
|
|
19545
19605
|
var import_sdk_core15 = require("@tinycloud/sdk-core");
|
|
19606
|
+
var import_sdk_core16 = require("@tinycloud/sdk-core");
|
|
19546
19607
|
// Annotate the CommonJS export names for ESM import in node:
|
|
19547
19608
|
0 && (module.exports = {
|
|
19548
19609
|
AutoApproveSpaceCreationHandler,
|
|
@@ -19557,6 +19618,7 @@ var import_sdk_core15 = require("@tinycloud/sdk-core");
|
|
|
19557
19618
|
DuckDbDatabaseHandle,
|
|
19558
19619
|
DuckDbService,
|
|
19559
19620
|
FileSessionStorage,
|
|
19621
|
+
HooksService,
|
|
19560
19622
|
KVService,
|
|
19561
19623
|
MemorySessionStorage,
|
|
19562
19624
|
NodeUserAuthorization,
|