@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.cjs
CHANGED
|
@@ -17052,12 +17052,12 @@ __export(index_exports, {
|
|
|
17052
17052
|
TinyCloud: () => import_sdk_core5.TinyCloud,
|
|
17053
17053
|
TinyCloudNode: () => TinyCloudNode,
|
|
17054
17054
|
UnsupportedFeatureError: () => import_sdk_core13.UnsupportedFeatureError,
|
|
17055
|
-
VaultAction: () => import_sdk_core9.VaultAction,
|
|
17056
17055
|
VaultHeaders: () => import_sdk_core9.VaultHeaders,
|
|
17056
|
+
VaultPublicSpaceKVActions: () => import_sdk_core9.VaultPublicSpaceKVActions,
|
|
17057
17057
|
VersionCheckError: () => import_sdk_core13.VersionCheckError,
|
|
17058
17058
|
WasmKeyProvider: () => WasmKeyProvider,
|
|
17059
17059
|
buildSpaceUri: () => import_sdk_core12.buildSpaceUri,
|
|
17060
|
-
|
|
17060
|
+
checkNodeInfo: () => import_sdk_core13.checkNodeInfo,
|
|
17061
17061
|
createCapabilityKeyRegistry: () => import_sdk_core11.createCapabilityKeyRegistry,
|
|
17062
17062
|
createSharingService: () => import_sdk_core10.createSharingService,
|
|
17063
17063
|
createSpaceService: () => import_sdk_core12.createSpaceService,
|
|
@@ -17599,7 +17599,8 @@ var _NodeUserAuthorization = class _NodeUserAuthorization {
|
|
|
17599
17599
|
this._tinyCloudSession = tinyCloudSession;
|
|
17600
17600
|
this._address = address;
|
|
17601
17601
|
this._chainId = chainId;
|
|
17602
|
-
|
|
17602
|
+
const nodeInfo = await (0, import_sdk_core2.checkNodeInfo)(this.tinycloudHosts[0], (0, import_node_sdk_wasm2.protocolVersion)());
|
|
17603
|
+
this._nodeFeatures = nodeInfo.features;
|
|
17603
17604
|
for (const ext of this.extensions) {
|
|
17604
17605
|
if (ext.afterSignIn) {
|
|
17605
17606
|
await ext.afterSignIn(clientSession);
|
|
@@ -17757,7 +17758,8 @@ var _NodeUserAuthorization = class _NodeUserAuthorization {
|
|
|
17757
17758
|
this._tinyCloudSession = tinyCloudSession;
|
|
17758
17759
|
this._address = address;
|
|
17759
17760
|
this._chainId = chainId;
|
|
17760
|
-
|
|
17761
|
+
const nodeInfo = await (0, import_sdk_core2.checkNodeInfo)(this.tinycloudHosts[0], (0, import_node_sdk_wasm2.protocolVersion)());
|
|
17762
|
+
this._nodeFeatures = nodeInfo.features;
|
|
17761
17763
|
for (const ext of this.extensions) {
|
|
17762
17764
|
if (ext.afterSignIn) {
|
|
17763
17765
|
await ext.afterSignIn(clientSession);
|
|
@@ -18970,7 +18972,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18970
18972
|
if (!activateResult.success) {
|
|
18971
18973
|
throw new Error(`Failed to activate delegation: ${activateResult.error}`);
|
|
18972
18974
|
}
|
|
18973
|
-
|
|
18975
|
+
const result = {
|
|
18974
18976
|
cid: delegationSession.delegationCid,
|
|
18975
18977
|
delegationHeader: delegationSession.delegationHeader,
|
|
18976
18978
|
spaceId: params.spaceIdOverride ?? session.spaceId,
|
|
@@ -18983,6 +18985,52 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18983
18985
|
chainId: session.chainId,
|
|
18984
18986
|
host: this.config.host
|
|
18985
18987
|
};
|
|
18988
|
+
const hasKvActions = params.actions.some((a) => a.startsWith("tinycloud.kv/"));
|
|
18989
|
+
if (hasKvActions && params.includePublicSpace !== false) {
|
|
18990
|
+
const publicSpaceId = (0, import_sdk_core4.makePublicSpaceId)(
|
|
18991
|
+
(0, import_node_sdk_wasm4.ensureEip55)(session.address),
|
|
18992
|
+
session.chainId
|
|
18993
|
+
);
|
|
18994
|
+
const publicAbilities = {
|
|
18995
|
+
kv: { "": ["tinycloud.kv/get", "tinycloud.kv/put", "tinycloud.kv/metadata"] }
|
|
18996
|
+
};
|
|
18997
|
+
const publicPrepared = (0, import_node_sdk_wasm4.prepareSession)({
|
|
18998
|
+
abilities: publicAbilities,
|
|
18999
|
+
address: (0, import_node_sdk_wasm4.ensureEip55)(session.address),
|
|
19000
|
+
chainId: session.chainId,
|
|
19001
|
+
domain: new URL(this.config.host).hostname,
|
|
19002
|
+
issuedAt: now.toISOString(),
|
|
19003
|
+
expirationTime: expirationTime.toISOString(),
|
|
19004
|
+
spaceId: publicSpaceId,
|
|
19005
|
+
delegateUri: params.delegateDID,
|
|
19006
|
+
parents: [session.delegationCid]
|
|
19007
|
+
});
|
|
19008
|
+
const publicSignature = await this.signer.signMessage(publicPrepared.siwe);
|
|
19009
|
+
const publicSession = (0, import_node_sdk_wasm4.completeSessionSetup)({
|
|
19010
|
+
...publicPrepared,
|
|
19011
|
+
signature: publicSignature
|
|
19012
|
+
});
|
|
19013
|
+
const publicActivateResult = await (0, import_sdk_core4.activateSessionWithHost)(
|
|
19014
|
+
this.config.host,
|
|
19015
|
+
publicSession.delegationHeader
|
|
19016
|
+
);
|
|
19017
|
+
if (publicActivateResult.success) {
|
|
19018
|
+
result.publicDelegation = {
|
|
19019
|
+
cid: publicSession.delegationCid,
|
|
19020
|
+
delegationHeader: publicSession.delegationHeader,
|
|
19021
|
+
spaceId: publicSpaceId,
|
|
19022
|
+
path: "",
|
|
19023
|
+
actions: ["tinycloud.kv/get", "tinycloud.kv/put", "tinycloud.kv/metadata"],
|
|
19024
|
+
disableSubDelegation: params.disableSubDelegation ?? false,
|
|
19025
|
+
expiry: expirationTime,
|
|
19026
|
+
delegateDID: params.delegateDID,
|
|
19027
|
+
ownerAddress: session.address,
|
|
19028
|
+
chainId: session.chainId,
|
|
19029
|
+
host: this.config.host
|
|
19030
|
+
};
|
|
19031
|
+
}
|
|
19032
|
+
}
|
|
19033
|
+
return result;
|
|
18986
19034
|
}
|
|
18987
19035
|
/**
|
|
18988
19036
|
* Use a delegation received from another user.
|
|
@@ -19231,12 +19279,12 @@ var import_sdk_core14 = require("@tinycloud/sdk-core");
|
|
|
19231
19279
|
TinyCloud,
|
|
19232
19280
|
TinyCloudNode,
|
|
19233
19281
|
UnsupportedFeatureError,
|
|
19234
|
-
VaultAction,
|
|
19235
19282
|
VaultHeaders,
|
|
19283
|
+
VaultPublicSpaceKVActions,
|
|
19236
19284
|
VersionCheckError,
|
|
19237
19285
|
WasmKeyProvider,
|
|
19238
19286
|
buildSpaceUri,
|
|
19239
|
-
|
|
19287
|
+
checkNodeInfo,
|
|
19240
19288
|
createCapabilityKeyRegistry,
|
|
19241
19289
|
createSharingService,
|
|
19242
19290
|
createSpaceService,
|