@tinycloud/node-sdk 3.12.0-beta.1 → 3.12.0-beta.2
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/{NodeUserAuthorization-BtoDI9in.d.cts → NodeUserAuthorization-B05Wjjpb.d.cts} +1 -1
- package/dist/{NodeUserAuthorization-BtoDI9in.d.ts → NodeUserAuthorization-B05Wjjpb.d.ts} +1 -1
- package/dist/{TinyCloudNode-C24728N_.d.cts → TinyCloudNode-6_IumWu0.d.cts} +3 -1
- package/dist/{TinyCloudNode-DLrINr98.d.ts → TinyCloudNode-CEFGtSWn.d.ts} +3 -1
- package/dist/{authority-DDdheOL6.d.cts → authority-DODDXxoP.d.cts} +1 -1
- package/dist/{authority-BQN2Z3st.d.ts → authority-DXpnuId1.d.ts} +1 -1
- package/dist/core.cjs +55 -37
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +3 -3
- package/dist/core.d.ts +3 -3
- package/dist/core.js +55 -37
- package/dist/core.js.map +1 -1
- package/dist/encryption-keys.d.cts +2 -2
- package/dist/encryption-keys.d.ts +2 -2
- package/dist/index.cjs +55 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +55 -37
- package/dist/index.js.map +1 -1
- package/dist/replication/authority.d.cts +3 -3
- package/dist/replication/authority.d.ts +3 -3
- package/dist/space-hosting.cjs +48 -6
- package/dist/space-hosting.cjs.map +1 -1
- package/dist/space-hosting.d.cts +23 -8
- package/dist/space-hosting.d.ts +23 -8
- package/dist/space-hosting.js +48 -6
- package/dist/space-hosting.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { NamedKeyClient } from '@tinycloud/sdk-services/encryption/named-keys';
|
|
2
2
|
export { DecryptManyResult, KeyCallOptions, KeyDescriptor, KeyEncryptOptions, NamedKeyClient, NamedKeyEnvelope, NamedKeyError, NamedKeyErrorCode, PublicKeyDescriptor, buildKeyAdminFacts, buildKeyDescribeFacts } from '@tinycloud/sdk-services/encryption/named-keys';
|
|
3
|
-
import { T as TinyCloudNode } from './TinyCloudNode-
|
|
3
|
+
import { T as TinyCloudNode } from './TinyCloudNode-6_IumWu0.cjs';
|
|
4
4
|
import '@tinycloud/sdk-core';
|
|
5
5
|
import '@tinycloud/sdk-services/kv/replication';
|
|
6
6
|
import '@tinycloud/sdk-services';
|
|
7
|
-
import './NodeUserAuthorization-
|
|
7
|
+
import './NodeUserAuthorization-B05Wjjpb.cjs';
|
|
8
8
|
import 'events';
|
|
9
9
|
import './delegation-BQbAuKad.cjs';
|
|
10
10
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { NamedKeyClient } from '@tinycloud/sdk-services/encryption/named-keys';
|
|
2
2
|
export { DecryptManyResult, KeyCallOptions, KeyDescriptor, KeyEncryptOptions, NamedKeyClient, NamedKeyEnvelope, NamedKeyError, NamedKeyErrorCode, PublicKeyDescriptor, buildKeyAdminFacts, buildKeyDescribeFacts } from '@tinycloud/sdk-services/encryption/named-keys';
|
|
3
|
-
import { T as TinyCloudNode } from './TinyCloudNode-
|
|
3
|
+
import { T as TinyCloudNode } from './TinyCloudNode-CEFGtSWn.js';
|
|
4
4
|
import '@tinycloud/sdk-core';
|
|
5
5
|
import '@tinycloud/sdk-services/kv/replication';
|
|
6
6
|
import '@tinycloud/sdk-services';
|
|
7
|
-
import './NodeUserAuthorization-
|
|
7
|
+
import './NodeUserAuthorization-B05Wjjpb.js';
|
|
8
8
|
import 'events';
|
|
9
9
|
import './delegation-BQbAuKad.js';
|
|
10
10
|
|
package/dist/index.cjs
CHANGED
|
@@ -19766,23 +19766,35 @@ var NodeUserAuthorization = class {
|
|
|
19766
19766
|
* Create the space on the TinyCloud server (host delegation).
|
|
19767
19767
|
* This registers the user as the owner of the space.
|
|
19768
19768
|
*/
|
|
19769
|
-
async hostSpace(targetSpaceId, purpose, signal) {
|
|
19770
|
-
|
|
19769
|
+
async hostSpace(targetSpaceId, purpose, signal, assertCurrent, siweParameters) {
|
|
19770
|
+
const context = typeof targetSpaceId === "object" ? targetSpaceId : void 0;
|
|
19771
|
+
const address = context?.address ?? this._address;
|
|
19772
|
+
const chainId = context?.chainId ?? this._chainId;
|
|
19773
|
+
if (!address || chainId === void 0 || !this._tinyCloudSession) {
|
|
19771
19774
|
throw new Error("Must be signed in to host space");
|
|
19772
19775
|
}
|
|
19776
|
+
const checkCurrent = () => {
|
|
19777
|
+
signal?.throwIfAborted();
|
|
19778
|
+
assertCurrent?.();
|
|
19779
|
+
};
|
|
19780
|
+
checkCurrent();
|
|
19773
19781
|
await this.ensureTinyCloudHosts();
|
|
19774
|
-
|
|
19775
|
-
const
|
|
19782
|
+
checkCurrent();
|
|
19783
|
+
const host = context?.host ?? this.primaryTinyCloudHost;
|
|
19784
|
+
const spaceId = context?.spaceId ?? (typeof targetSpaceId === "string" ? targetSpaceId : this._tinyCloudSession.spaceId);
|
|
19776
19785
|
const peerId = await (0, import_sdk_core5.fetchPeerId)(host, spaceId, signal);
|
|
19777
|
-
|
|
19778
|
-
|
|
19779
|
-
|
|
19780
|
-
|
|
19781
|
-
|
|
19782
|
-
|
|
19783
|
-
|
|
19784
|
-
|
|
19785
|
-
|
|
19786
|
+
checkCurrent();
|
|
19787
|
+
const siwe = this.wasm.generateHostSIWEMessage(
|
|
19788
|
+
context && siweParameters ? siweParameters(peerId) : {
|
|
19789
|
+
address,
|
|
19790
|
+
chainId,
|
|
19791
|
+
domain: this.domain,
|
|
19792
|
+
issuedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
19793
|
+
spaceId,
|
|
19794
|
+
peerId
|
|
19795
|
+
}
|
|
19796
|
+
);
|
|
19797
|
+
checkCurrent();
|
|
19786
19798
|
const signing = this.signMessage(siwe, purpose);
|
|
19787
19799
|
let signature2;
|
|
19788
19800
|
if (!signal) {
|
|
@@ -19801,8 +19813,9 @@ var NodeUserAuthorization = class {
|
|
|
19801
19813
|
signal.removeEventListener("abort", onAbort);
|
|
19802
19814
|
}
|
|
19803
19815
|
}
|
|
19804
|
-
|
|
19816
|
+
checkCurrent();
|
|
19805
19817
|
const headers = this.wasm.siweToDelegationHeaders({ siwe, signature: signature2 });
|
|
19818
|
+
checkCurrent();
|
|
19806
19819
|
return (0, import_sdk_core5.submitHostDelegation)(host, headers, signal);
|
|
19807
19820
|
}
|
|
19808
19821
|
/**
|
|
@@ -19864,37 +19877,30 @@ var NodeUserAuthorization = class {
|
|
|
19864
19877
|
*
|
|
19865
19878
|
* @throws Error if the creation handler fails or times out, or hosting fails
|
|
19866
19879
|
*/
|
|
19867
|
-
async ensurePrimarySpaceHosted(hosting) {
|
|
19868
|
-
if (hosting !== "not-hosted") {
|
|
19869
|
-
return;
|
|
19870
|
-
}
|
|
19880
|
+
async ensurePrimarySpaceHosted(hosting, signal) {
|
|
19871
19881
|
const session = this._tinyCloudSession;
|
|
19872
|
-
if (
|
|
19873
|
-
|
|
19874
|
-
}
|
|
19882
|
+
if (hosting !== "not-hosted") return;
|
|
19883
|
+
if (!session) throw new Error("Must be signed in to host the primary space");
|
|
19875
19884
|
const handler = this.spaceCreationHandler ?? (this.autoCreateSpace ? new import_sdk_core5.AutoApproveSpaceCreationHandler() : void 0);
|
|
19876
|
-
if (!handler)
|
|
19877
|
-
return;
|
|
19878
|
-
}
|
|
19879
|
-
await this.ensureTinyCloudHosts();
|
|
19880
|
-
const host = this.primaryTinyCloudHost;
|
|
19881
|
-
const primarySpaceId = session.spaceId;
|
|
19882
|
-
const creationContext = {
|
|
19883
|
-
spaceId: primarySpaceId,
|
|
19884
|
-
address: this._address,
|
|
19885
|
-
chainId: this._chainId,
|
|
19886
|
-
host
|
|
19887
|
-
};
|
|
19885
|
+
if (!handler) return;
|
|
19888
19886
|
const { createPrimarySpace } = await import("./space-hosting.cjs");
|
|
19889
19887
|
await createPrimarySpace({
|
|
19890
19888
|
handler,
|
|
19891
|
-
|
|
19892
|
-
|
|
19893
|
-
|
|
19889
|
+
session,
|
|
19890
|
+
currentSession: () => this._tinyCloudSession,
|
|
19891
|
+
signerAddress: () => this.signer.getAddress(),
|
|
19892
|
+
resolveHost: async () => {
|
|
19893
|
+
await this.ensureTinyCloudHosts();
|
|
19894
|
+
return this.primaryTinyCloudHost;
|
|
19895
|
+
},
|
|
19896
|
+
domain: this.domain,
|
|
19897
|
+
guard: (context) => this.guardSpaceCreation(handler, context),
|
|
19898
|
+
host: (context, assertCurrent, siweParameters) => this.hostSpace(context, void 0, signal, assertCurrent, siweParameters),
|
|
19894
19899
|
onHosted: () => {
|
|
19895
19900
|
this._spaceHosting = "hosted";
|
|
19896
19901
|
},
|
|
19897
|
-
activate: () => (0, import_sdk_core5.activateSessionWithHost)(host, session.delegationHeader)
|
|
19902
|
+
activate: (context) => (0, import_sdk_core5.activateSessionWithHost)(context.host, session.delegationHeader),
|
|
19903
|
+
signal
|
|
19898
19904
|
});
|
|
19899
19905
|
}
|
|
19900
19906
|
/** {@link assertMayCreateSpace}, reporting a refusal to the creation handler before rethrowing it. */
|
|
@@ -22218,6 +22224,18 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22218
22224
|
return "unknown";
|
|
22219
22225
|
}
|
|
22220
22226
|
}
|
|
22227
|
+
/** Run the existing primary-space creation flow for the restored session. */
|
|
22228
|
+
async ensurePrimarySpaceHosted(hosting) {
|
|
22229
|
+
const graph = this._serviceGraph;
|
|
22230
|
+
const epoch = this.sessionEpoch;
|
|
22231
|
+
graph.assertActive();
|
|
22232
|
+
this.assertSessionEpoch(epoch, "Space hosting");
|
|
22233
|
+
const auth = this.auth;
|
|
22234
|
+
if (!auth || !this.session) return;
|
|
22235
|
+
await auth.ensurePrimarySpaceHosted(hosting, graph.signal);
|
|
22236
|
+
graph.assertActive();
|
|
22237
|
+
this.assertSessionEpoch(epoch, "Space hosting");
|
|
22238
|
+
}
|
|
22221
22239
|
/**
|
|
22222
22240
|
* The node's last answer for the primary space: recorded at sign-in from the
|
|
22223
22241
|
* activation, or by {@link checkSpaceHosting}. `unknown` after a restore until
|