@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
|
@@ -670,7 +670,7 @@ declare class NodeUserAuthorization implements IUserAuthorization {
|
|
|
670
670
|
*
|
|
671
671
|
* @throws Error if the creation handler fails or times out, or hosting fails
|
|
672
672
|
*/
|
|
673
|
-
ensurePrimarySpaceHosted(hosting: SpaceHosting): Promise<void>;
|
|
673
|
+
ensurePrimarySpaceHosted(hosting: SpaceHosting, signal?: AbortSignal): Promise<void>;
|
|
674
674
|
/** {@link assertMayCreateSpace}, reporting a refusal to the creation handler before rethrowing it. */
|
|
675
675
|
private guardSpaceCreation;
|
|
676
676
|
private recordActivationSkippedSpaces;
|
|
@@ -670,7 +670,7 @@ declare class NodeUserAuthorization implements IUserAuthorization {
|
|
|
670
670
|
*
|
|
671
671
|
* @throws Error if the creation handler fails or times out, or hosting fails
|
|
672
672
|
*/
|
|
673
|
-
ensurePrimarySpaceHosted(hosting: SpaceHosting): Promise<void>;
|
|
673
|
+
ensurePrimarySpaceHosted(hosting: SpaceHosting, signal?: AbortSignal): Promise<void>;
|
|
674
674
|
/** {@link assertMayCreateSpace}, reporting a refusal to the creation handler before rethrowing it. */
|
|
675
675
|
private guardSpaceCreation;
|
|
676
676
|
private recordActivationSkippedSpaces;
|
|
@@ -3,7 +3,7 @@ import { TinyCloudSession, TelemetryConfig, ServiceContext, IKVService, ISQLServ
|
|
|
3
3
|
import { ReplicaPurgeFailedEvent, ReplicaSessionStamp } from '@tinycloud/sdk-services/kv/replication';
|
|
4
4
|
import { InvokeFunction, InvokeAnyFunction, FetchFunction, RequestSink, RequestLogReader } from '@tinycloud/sdk-services';
|
|
5
5
|
import { NamedKeyClient } from '@tinycloud/sdk-services/encryption/named-keys';
|
|
6
|
-
import { S as SpaceHosting, c as SignStrategy, a as NodeUserAuthorization, P as PreparedOpenKeyAuthorization } from './NodeUserAuthorization-
|
|
6
|
+
import { S as SpaceHosting, c as SignStrategy, a as NodeUserAuthorization, P as PreparedOpenKeyAuthorization } from './NodeUserAuthorization-B05Wjjpb.cjs';
|
|
7
7
|
import { P as PortableDelegation, S as SessionGrantProof, e as VerifiedSessionGrant } from './delegation-BQbAuKad.cjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -698,6 +698,8 @@ declare class TinyCloudNode {
|
|
|
698
698
|
* `unknown` answer leaves the previous one in place.
|
|
699
699
|
*/
|
|
700
700
|
checkSpaceHosting(space?: string): Promise<SpaceHosting>;
|
|
701
|
+
/** Run the existing primary-space creation flow for the restored session. */
|
|
702
|
+
ensurePrimarySpaceHosted(hosting: SpaceHosting): Promise<void>;
|
|
701
703
|
/**
|
|
702
704
|
* The node's last answer for the primary space: recorded at sign-in from the
|
|
703
705
|
* activation, or by {@link checkSpaceHosting}. `unknown` after a restore until
|
|
@@ -3,7 +3,7 @@ import { TinyCloudSession, TelemetryConfig, ServiceContext, IKVService, ISQLServ
|
|
|
3
3
|
import { ReplicaPurgeFailedEvent, ReplicaSessionStamp } from '@tinycloud/sdk-services/kv/replication';
|
|
4
4
|
import { InvokeFunction, InvokeAnyFunction, FetchFunction, RequestSink, RequestLogReader } from '@tinycloud/sdk-services';
|
|
5
5
|
import { NamedKeyClient } from '@tinycloud/sdk-services/encryption/named-keys';
|
|
6
|
-
import { S as SpaceHosting, c as SignStrategy, a as NodeUserAuthorization, P as PreparedOpenKeyAuthorization } from './NodeUserAuthorization-
|
|
6
|
+
import { S as SpaceHosting, c as SignStrategy, a as NodeUserAuthorization, P as PreparedOpenKeyAuthorization } from './NodeUserAuthorization-B05Wjjpb.js';
|
|
7
7
|
import { P as PortableDelegation, S as SessionGrantProof, e as VerifiedSessionGrant } from './delegation-BQbAuKad.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -698,6 +698,8 @@ declare class TinyCloudNode {
|
|
|
698
698
|
* `unknown` answer leaves the previous one in place.
|
|
699
699
|
*/
|
|
700
700
|
checkSpaceHosting(space?: string): Promise<SpaceHosting>;
|
|
701
|
+
/** Run the existing primary-space creation flow for the restored session. */
|
|
702
|
+
ensurePrimarySpaceHosted(hosting: SpaceHosting): Promise<void>;
|
|
701
703
|
/**
|
|
702
704
|
* The node's last answer for the primary space: recorded at sign-in from the
|
|
703
705
|
* activation, or by {@link checkSpaceHosting}. `unknown` after a restore until
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReplicationOptions, PermissionEntry, TinyCloudSession, KVReplicaStorage, ServiceContext, IWasmBindings, WasmRecapEntry } from '@tinycloud/sdk-core';
|
|
2
2
|
import { ReplicaConsentAnchor, AuthorityRefusal, ReplicationAuthority } from '@tinycloud/sdk-services';
|
|
3
3
|
import { ReplicaLocalEraseOutcome, ReplicaPurgeLocalCopyResult, ReplicaPurgeTrigger, ReplicaPurgeFailedEvent, ReplicaSessionStamp, ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
|
|
4
|
-
import { T as TinyCloudNode } from './TinyCloudNode-
|
|
4
|
+
import { T as TinyCloudNode } from './TinyCloudNode-6_IumWu0.cjs';
|
|
5
5
|
|
|
6
6
|
/** Constructor-time validation; the space-dependent secrets check runs at sign-in and open. */
|
|
7
7
|
declare function assertValidReplicationConfig(replication: (ReplicationOptions & {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReplicationOptions, PermissionEntry, TinyCloudSession, KVReplicaStorage, ServiceContext, IWasmBindings, WasmRecapEntry } from '@tinycloud/sdk-core';
|
|
2
2
|
import { ReplicaConsentAnchor, AuthorityRefusal, ReplicationAuthority } from '@tinycloud/sdk-services';
|
|
3
3
|
import { ReplicaLocalEraseOutcome, ReplicaPurgeLocalCopyResult, ReplicaPurgeTrigger, ReplicaPurgeFailedEvent, ReplicaSessionStamp, ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
|
|
4
|
-
import { T as TinyCloudNode } from './TinyCloudNode-
|
|
4
|
+
import { T as TinyCloudNode } from './TinyCloudNode-CEFGtSWn.js';
|
|
5
5
|
|
|
6
6
|
/** Constructor-time validation; the space-dependent secrets check runs at sign-in and open. */
|
|
7
7
|
declare function assertValidReplicationConfig(replication: (ReplicationOptions & {
|
package/dist/core.cjs
CHANGED
|
@@ -1261,23 +1261,35 @@ var NodeUserAuthorization = class {
|
|
|
1261
1261
|
* Create the space on the TinyCloud server (host delegation).
|
|
1262
1262
|
* This registers the user as the owner of the space.
|
|
1263
1263
|
*/
|
|
1264
|
-
async hostSpace(targetSpaceId, purpose, signal) {
|
|
1265
|
-
|
|
1264
|
+
async hostSpace(targetSpaceId, purpose, signal, assertCurrent, siweParameters) {
|
|
1265
|
+
const context = typeof targetSpaceId === "object" ? targetSpaceId : void 0;
|
|
1266
|
+
const address = context?.address ?? this._address;
|
|
1267
|
+
const chainId = context?.chainId ?? this._chainId;
|
|
1268
|
+
if (!address || chainId === void 0 || !this._tinyCloudSession) {
|
|
1266
1269
|
throw new Error("Must be signed in to host space");
|
|
1267
1270
|
}
|
|
1271
|
+
const checkCurrent = () => {
|
|
1272
|
+
signal?.throwIfAborted();
|
|
1273
|
+
assertCurrent?.();
|
|
1274
|
+
};
|
|
1275
|
+
checkCurrent();
|
|
1268
1276
|
await this.ensureTinyCloudHosts();
|
|
1269
|
-
|
|
1270
|
-
const
|
|
1277
|
+
checkCurrent();
|
|
1278
|
+
const host = context?.host ?? this.primaryTinyCloudHost;
|
|
1279
|
+
const spaceId = context?.spaceId ?? (typeof targetSpaceId === "string" ? targetSpaceId : this._tinyCloudSession.spaceId);
|
|
1271
1280
|
const peerId = await (0, import_sdk_core5.fetchPeerId)(host, spaceId, signal);
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
+
checkCurrent();
|
|
1282
|
+
const siwe = this.wasm.generateHostSIWEMessage(
|
|
1283
|
+
context && siweParameters ? siweParameters(peerId) : {
|
|
1284
|
+
address,
|
|
1285
|
+
chainId,
|
|
1286
|
+
domain: this.domain,
|
|
1287
|
+
issuedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1288
|
+
spaceId,
|
|
1289
|
+
peerId
|
|
1290
|
+
}
|
|
1291
|
+
);
|
|
1292
|
+
checkCurrent();
|
|
1281
1293
|
const signing = this.signMessage(siwe, purpose);
|
|
1282
1294
|
let signature;
|
|
1283
1295
|
if (!signal) {
|
|
@@ -1296,8 +1308,9 @@ var NodeUserAuthorization = class {
|
|
|
1296
1308
|
signal.removeEventListener("abort", onAbort);
|
|
1297
1309
|
}
|
|
1298
1310
|
}
|
|
1299
|
-
|
|
1311
|
+
checkCurrent();
|
|
1300
1312
|
const headers = this.wasm.siweToDelegationHeaders({ siwe, signature });
|
|
1313
|
+
checkCurrent();
|
|
1301
1314
|
return (0, import_sdk_core5.submitHostDelegation)(host, headers, signal);
|
|
1302
1315
|
}
|
|
1303
1316
|
/**
|
|
@@ -1359,37 +1372,30 @@ var NodeUserAuthorization = class {
|
|
|
1359
1372
|
*
|
|
1360
1373
|
* @throws Error if the creation handler fails or times out, or hosting fails
|
|
1361
1374
|
*/
|
|
1362
|
-
async ensurePrimarySpaceHosted(hosting) {
|
|
1363
|
-
if (hosting !== "not-hosted") {
|
|
1364
|
-
return;
|
|
1365
|
-
}
|
|
1375
|
+
async ensurePrimarySpaceHosted(hosting, signal) {
|
|
1366
1376
|
const session = this._tinyCloudSession;
|
|
1367
|
-
if (
|
|
1368
|
-
|
|
1369
|
-
}
|
|
1377
|
+
if (hosting !== "not-hosted") return;
|
|
1378
|
+
if (!session) throw new Error("Must be signed in to host the primary space");
|
|
1370
1379
|
const handler = this.spaceCreationHandler ?? (this.autoCreateSpace ? new import_sdk_core5.AutoApproveSpaceCreationHandler() : void 0);
|
|
1371
|
-
if (!handler)
|
|
1372
|
-
return;
|
|
1373
|
-
}
|
|
1374
|
-
await this.ensureTinyCloudHosts();
|
|
1375
|
-
const host = this.primaryTinyCloudHost;
|
|
1376
|
-
const primarySpaceId = session.spaceId;
|
|
1377
|
-
const creationContext = {
|
|
1378
|
-
spaceId: primarySpaceId,
|
|
1379
|
-
address: this._address,
|
|
1380
|
-
chainId: this._chainId,
|
|
1381
|
-
host
|
|
1382
|
-
};
|
|
1380
|
+
if (!handler) return;
|
|
1383
1381
|
const { createPrimarySpace } = await import("./space-hosting.cjs");
|
|
1384
1382
|
await createPrimarySpace({
|
|
1385
1383
|
handler,
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1384
|
+
session,
|
|
1385
|
+
currentSession: () => this._tinyCloudSession,
|
|
1386
|
+
signerAddress: () => this.signer.getAddress(),
|
|
1387
|
+
resolveHost: async () => {
|
|
1388
|
+
await this.ensureTinyCloudHosts();
|
|
1389
|
+
return this.primaryTinyCloudHost;
|
|
1390
|
+
},
|
|
1391
|
+
domain: this.domain,
|
|
1392
|
+
guard: (context) => this.guardSpaceCreation(handler, context),
|
|
1393
|
+
host: (context, assertCurrent, siweParameters) => this.hostSpace(context, void 0, signal, assertCurrent, siweParameters),
|
|
1389
1394
|
onHosted: () => {
|
|
1390
1395
|
this._spaceHosting = "hosted";
|
|
1391
1396
|
},
|
|
1392
|
-
activate: () => (0, import_sdk_core5.activateSessionWithHost)(host, session.delegationHeader)
|
|
1397
|
+
activate: (context) => (0, import_sdk_core5.activateSessionWithHost)(context.host, session.delegationHeader),
|
|
1398
|
+
signal
|
|
1393
1399
|
});
|
|
1394
1400
|
}
|
|
1395
1401
|
/** {@link assertMayCreateSpace}, reporting a refusal to the creation handler before rethrowing it. */
|
|
@@ -4406,6 +4412,18 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4406
4412
|
return "unknown";
|
|
4407
4413
|
}
|
|
4408
4414
|
}
|
|
4415
|
+
/** Run the existing primary-space creation flow for the restored session. */
|
|
4416
|
+
async ensurePrimarySpaceHosted(hosting) {
|
|
4417
|
+
const graph = this._serviceGraph;
|
|
4418
|
+
const epoch = this.sessionEpoch;
|
|
4419
|
+
graph.assertActive();
|
|
4420
|
+
this.assertSessionEpoch(epoch, "Space hosting");
|
|
4421
|
+
const auth = this.auth;
|
|
4422
|
+
if (!auth || !this.session) return;
|
|
4423
|
+
await auth.ensurePrimarySpaceHosted(hosting, graph.signal);
|
|
4424
|
+
graph.assertActive();
|
|
4425
|
+
this.assertSessionEpoch(epoch, "Space hosting");
|
|
4426
|
+
}
|
|
4409
4427
|
/**
|
|
4410
4428
|
* The node's last answer for the primary space: recorded at sign-in from the
|
|
4411
4429
|
* activation, or by {@link checkSpaceHosting}. `unknown` after a restore until
|