@dxos/client-services 0.1.51 → 0.1.52-main.0e90c21
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/lib/node/index.cjs +78 -84
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +64 -70
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/locks/node.d.ts +2 -2
- package/dist/types/src/packlets/locks/node.d.ts.map +1 -1
- package/package.json +32 -33
- package/src/packlets/locks/node.ts +8 -13
|
@@ -61,13 +61,13 @@ var createMockCredential = async ({ signer, issuer }) => (0, import_credentials.
|
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
// packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
|
|
64
|
-
var
|
|
65
|
-
var
|
|
64
|
+
var import_node_assert14 = __toESM(require("node:assert"));
|
|
65
|
+
var import_async18 = require("@dxos/async");
|
|
66
66
|
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
67
67
|
|
|
68
68
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
69
|
-
var
|
|
70
|
-
var
|
|
69
|
+
var import_node_assert13 = __toESM(require("node:assert"));
|
|
70
|
+
var import_async17 = require("@dxos/async");
|
|
71
71
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
72
72
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
73
73
|
var import_keys12 = require("@dxos/keys");
|
|
@@ -2164,8 +2164,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2164
2164
|
};
|
|
2165
2165
|
|
|
2166
2166
|
// packages/sdk/client-services/src/packlets/locks/node.ts
|
|
2167
|
-
var
|
|
2168
|
-
var
|
|
2167
|
+
var import_node_assert9 = __toESM(require("node:assert"));
|
|
2168
|
+
var import_lock_file = require("@dxos/lock-file");
|
|
2169
2169
|
var import_log8 = require("@dxos/log");
|
|
2170
2170
|
var __decorate = function(decorators, target, key, desc) {
|
|
2171
2171
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -2179,7 +2179,6 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
2179
2179
|
};
|
|
2180
2180
|
var Lock = class {
|
|
2181
2181
|
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
2182
|
-
this._releaseTrigger = new import_async11.Trigger();
|
|
2183
2182
|
this._lockPath = lockPath;
|
|
2184
2183
|
this._onAcquire = onAcquire;
|
|
2185
2184
|
this._onRelease = onRelease;
|
|
@@ -2191,29 +2190,24 @@ var Lock = class {
|
|
|
2191
2190
|
var _a;
|
|
2192
2191
|
(0, import_log8.log)("acquiring lock...", {}, {
|
|
2193
2192
|
file: "node.ts",
|
|
2194
|
-
line:
|
|
2193
|
+
line: 32,
|
|
2195
2194
|
scope: this,
|
|
2196
2195
|
callSite: (f, a) => f(...a)
|
|
2197
2196
|
});
|
|
2198
|
-
|
|
2199
|
-
throw new Error(`Lock already acquired: ${this._lockPath}`);
|
|
2200
|
-
}
|
|
2201
|
-
import_lockfile.default.lockSync(this._lockPath);
|
|
2197
|
+
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
2202
2198
|
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
2203
2199
|
(0, import_log8.log)("acquired lock", {}, {
|
|
2204
2200
|
file: "node.ts",
|
|
2205
|
-
line:
|
|
2201
|
+
line: 37,
|
|
2206
2202
|
scope: this,
|
|
2207
2203
|
callSite: (f, a) => f(...a)
|
|
2208
2204
|
});
|
|
2209
2205
|
}
|
|
2210
2206
|
async release() {
|
|
2211
2207
|
var _a;
|
|
2212
|
-
if (!import_lockfile.default.checkSync(this._lockPath)) {
|
|
2213
|
-
throw new Error(`Lock already acquired: ${this._lockPath}`);
|
|
2214
|
-
}
|
|
2215
2208
|
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
2216
|
-
|
|
2209
|
+
(0, import_node_assert9.default)(this._fileHandle, "Lock is not acquired");
|
|
2210
|
+
await import_lock_file.LockFile.release(this._fileHandle);
|
|
2217
2211
|
}
|
|
2218
2212
|
};
|
|
2219
2213
|
__decorate([
|
|
@@ -2221,14 +2215,14 @@ __decorate([
|
|
|
2221
2215
|
], Lock.prototype, "lockKey", null);
|
|
2222
2216
|
|
|
2223
2217
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
2224
|
-
var
|
|
2218
|
+
var import_async11 = require("@dxos/async");
|
|
2225
2219
|
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
2226
2220
|
var import_log9 = require("@dxos/log");
|
|
2227
2221
|
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2228
2222
|
var import_util3 = require("@dxos/util");
|
|
2229
2223
|
var LoggingServiceImpl = class {
|
|
2230
2224
|
constructor() {
|
|
2231
|
-
this._logs = new
|
|
2225
|
+
this._logs = new import_async11.Event();
|
|
2232
2226
|
this._logProcessor = (_config, entry2) => {
|
|
2233
2227
|
this._logs.emit(entry2);
|
|
2234
2228
|
};
|
|
@@ -2329,8 +2323,8 @@ var NetworkServiceImpl = class {
|
|
|
2329
2323
|
};
|
|
2330
2324
|
|
|
2331
2325
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2332
|
-
var
|
|
2333
|
-
var
|
|
2326
|
+
var import_node_assert11 = __toESM(require("node:assert"));
|
|
2327
|
+
var import_async14 = require("@dxos/async");
|
|
2334
2328
|
var import_context7 = require("@dxos/context");
|
|
2335
2329
|
var import_credentials13 = require("@dxos/credentials");
|
|
2336
2330
|
var import_keys10 = require("@dxos/keys");
|
|
@@ -2341,7 +2335,7 @@ var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip"
|
|
|
2341
2335
|
var import_util6 = require("@dxos/util");
|
|
2342
2336
|
|
|
2343
2337
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2344
|
-
var
|
|
2338
|
+
var import_async13 = require("@dxos/async");
|
|
2345
2339
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
2346
2340
|
var import_context6 = require("@dxos/context");
|
|
2347
2341
|
var import_debug3 = require("@dxos/debug");
|
|
@@ -2355,8 +2349,8 @@ var import_timeframe = require("@dxos/timeframe");
|
|
|
2355
2349
|
var import_util5 = require("@dxos/util");
|
|
2356
2350
|
|
|
2357
2351
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2358
|
-
var
|
|
2359
|
-
var
|
|
2352
|
+
var import_node_assert10 = __toESM(require("node:assert"));
|
|
2353
|
+
var import_async12 = require("@dxos/async");
|
|
2360
2354
|
var import_context5 = require("@dxos/context");
|
|
2361
2355
|
var import_keys8 = require("@dxos/keys");
|
|
2362
2356
|
var import_log10 = require("@dxos/log");
|
|
@@ -2370,7 +2364,7 @@ var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
|
2370
2364
|
var NotarizationPlugin = class {
|
|
2371
2365
|
constructor() {
|
|
2372
2366
|
this._ctx = new import_context5.Context();
|
|
2373
|
-
this._extensionOpened = new
|
|
2367
|
+
this._extensionOpened = new import_async12.Event();
|
|
2374
2368
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2375
2369
|
this._processedCredentials = new import_util4.ComplexSet(import_keys8.PublicKey.hash);
|
|
2376
2370
|
this._processCredentialsTriggers = new import_util4.ComplexMap(import_keys8.PublicKey.hash);
|
|
@@ -2392,8 +2386,8 @@ var NotarizationPlugin = class {
|
|
|
2392
2386
|
scope: this,
|
|
2393
2387
|
callSite: (f, a) => f(...a)
|
|
2394
2388
|
});
|
|
2395
|
-
(0,
|
|
2396
|
-
const errors = new
|
|
2389
|
+
(0, import_node_assert10.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
|
|
2390
|
+
const errors = new import_async12.Trigger();
|
|
2397
2391
|
const ctx = this._ctx.derive({
|
|
2398
2392
|
onError: (err) => {
|
|
2399
2393
|
import_log10.log.warn("Notarization error", {
|
|
@@ -2410,7 +2404,7 @@ var NotarizationPlugin = class {
|
|
|
2410
2404
|
});
|
|
2411
2405
|
opCtx == null ? void 0 : opCtx.onDispose(() => ctx.dispose());
|
|
2412
2406
|
if (timeout !== 0) {
|
|
2413
|
-
(0,
|
|
2407
|
+
(0, import_async12.scheduleTask)(ctx, () => {
|
|
2414
2408
|
import_log10.log.warn("Notarization timeout", {
|
|
2415
2409
|
timeout,
|
|
2416
2410
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
@@ -2421,12 +2415,12 @@ var NotarizationPlugin = class {
|
|
|
2421
2415
|
callSite: (f, a) => f(...a)
|
|
2422
2416
|
});
|
|
2423
2417
|
void ctx.dispose();
|
|
2424
|
-
errors.throw(new
|
|
2418
|
+
errors.throw(new import_async12.TimeoutError(timeout, "Notarization timed out"));
|
|
2425
2419
|
}, timeout);
|
|
2426
2420
|
}
|
|
2427
2421
|
const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
|
|
2428
2422
|
const peersTried = /* @__PURE__ */ new Set();
|
|
2429
|
-
const notarizeTask = new
|
|
2423
|
+
const notarizeTask = new import_async12.DeferredTask(ctx, async () => {
|
|
2430
2424
|
try {
|
|
2431
2425
|
if (this._extensions.size === 0) {
|
|
2432
2426
|
return;
|
|
@@ -2444,7 +2438,7 @@ var NotarizationPlugin = class {
|
|
|
2444
2438
|
callSite: (f, a) => f(...a)
|
|
2445
2439
|
});
|
|
2446
2440
|
peersTried.clear();
|
|
2447
|
-
(0,
|
|
2441
|
+
(0, import_async12.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
2448
2442
|
return;
|
|
2449
2443
|
}
|
|
2450
2444
|
peersTried.add(peer);
|
|
@@ -2466,7 +2460,7 @@ var NotarizationPlugin = class {
|
|
|
2466
2460
|
scope: this,
|
|
2467
2461
|
callSite: (f, a) => f(...a)
|
|
2468
2462
|
});
|
|
2469
|
-
await (0,
|
|
2463
|
+
await (0, import_async12.sleep)(successDelay);
|
|
2470
2464
|
} catch (err) {
|
|
2471
2465
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
2472
2466
|
import_log10.log.warn("error notarizing (recoverable)", err, {
|
|
@@ -2510,14 +2504,14 @@ var NotarizationPlugin = class {
|
|
|
2510
2504
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2511
2505
|
}
|
|
2512
2506
|
setWriter(writer) {
|
|
2513
|
-
(0,
|
|
2507
|
+
(0, import_node_assert10.default)(!this._writer, "Writer already set.");
|
|
2514
2508
|
this._writer = writer;
|
|
2515
2509
|
}
|
|
2516
2510
|
async _waitUntilProcessed(id) {
|
|
2517
2511
|
if (this._processedCredentials.has(id)) {
|
|
2518
2512
|
return;
|
|
2519
2513
|
}
|
|
2520
|
-
await (0, import_util4.entry)(this._processCredentialsTriggers, id).orInsert(new
|
|
2514
|
+
await (0, import_util4.entry)(this._processCredentialsTriggers, id).orInsert(new import_async12.Trigger()).value.wait();
|
|
2521
2515
|
}
|
|
2522
2516
|
/**
|
|
2523
2517
|
* Requests from other peers to notarize credentials.
|
|
@@ -2528,7 +2522,7 @@ var NotarizationPlugin = class {
|
|
|
2528
2522
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2529
2523
|
}
|
|
2530
2524
|
for (const credential of (_a = request.credentials) != null ? _a : []) {
|
|
2531
|
-
(0,
|
|
2525
|
+
(0, import_node_assert10.default)(credential.id, "Credential must have an id");
|
|
2532
2526
|
if (this._processedCredentials.has(credential.id)) {
|
|
2533
2527
|
continue;
|
|
2534
2528
|
}
|
|
@@ -2615,7 +2609,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2615
2609
|
* Error for _state === SpaceState.ERROR.
|
|
2616
2610
|
*/
|
|
2617
2611
|
this.error = void 0;
|
|
2618
|
-
this.stateUpdate = new
|
|
2612
|
+
this.stateUpdate = new import_async13.Event();
|
|
2619
2613
|
this.metrics = {};
|
|
2620
2614
|
var _a;
|
|
2621
2615
|
this._inner = params.inner;
|
|
@@ -2686,7 +2680,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2686
2680
|
* Initialize the data pipeline in a separate task.
|
|
2687
2681
|
*/
|
|
2688
2682
|
initializeDataPipelineAsync() {
|
|
2689
|
-
(0,
|
|
2683
|
+
(0, import_async13.scheduleTask)(this._ctx, async () => {
|
|
2690
2684
|
try {
|
|
2691
2685
|
this.metrics.pipelineInitBegin = new Date();
|
|
2692
2686
|
await this.initializeDataPipeline();
|
|
@@ -2839,7 +2833,7 @@ __decorate2([
|
|
|
2839
2833
|
(0, import_debug3.timed)(1e4)
|
|
2840
2834
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2841
2835
|
DataSpace = __decorate2([
|
|
2842
|
-
(0,
|
|
2836
|
+
(0, import_async13.trackLeaks)("open", "close")
|
|
2843
2837
|
], DataSpace);
|
|
2844
2838
|
|
|
2845
2839
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
@@ -2932,7 +2926,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2932
2926
|
this._signingContext = _signingContext;
|
|
2933
2927
|
this._feedStore = _feedStore;
|
|
2934
2928
|
this._ctx = new import_context7.Context();
|
|
2935
|
-
this.updated = new
|
|
2929
|
+
this.updated = new import_async14.Event();
|
|
2936
2930
|
this._spaces = new import_util6.ComplexMap(import_keys10.PublicKey.hash);
|
|
2937
2931
|
this._isOpen = false;
|
|
2938
2932
|
this._instanceId = import_keys10.PublicKey.random().toHex();
|
|
@@ -3017,7 +3011,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3017
3011
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
3018
3012
|
*/
|
|
3019
3013
|
async createSpace() {
|
|
3020
|
-
(0,
|
|
3014
|
+
(0, import_node_assert11.default)(this._isOpen, "Not open.");
|
|
3021
3015
|
const spaceKey = await this._keyring.createKey();
|
|
3022
3016
|
const controlFeedKey = await this._keyring.createKey();
|
|
3023
3017
|
const dataFeedKey = await this._keyring.createKey();
|
|
@@ -3039,7 +3033,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3039
3033
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
3040
3034
|
await this._metadataStore.addSpace(metadata);
|
|
3041
3035
|
const memberCredential = credentials[1];
|
|
3042
|
-
(0,
|
|
3036
|
+
(0, import_node_assert11.default)((0, import_credentials13.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
3043
3037
|
await this._signingContext.recordCredential(memberCredential);
|
|
3044
3038
|
await space.initializeDataPipeline();
|
|
3045
3039
|
this.updated.emit();
|
|
@@ -3055,8 +3049,8 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3055
3049
|
scope: this,
|
|
3056
3050
|
callSite: (f, a) => f(...a)
|
|
3057
3051
|
});
|
|
3058
|
-
(0,
|
|
3059
|
-
(0,
|
|
3052
|
+
(0, import_node_assert11.default)(this._isOpen, "Not open.");
|
|
3053
|
+
(0, import_node_assert11.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
|
|
3060
3054
|
const metadata = {
|
|
3061
3055
|
key: opts.spaceKey,
|
|
3062
3056
|
genesisFeedKey: opts.genesisFeedKey,
|
|
@@ -3179,23 +3173,23 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3179
3173
|
}
|
|
3180
3174
|
};
|
|
3181
3175
|
__decorate3([
|
|
3182
|
-
|
|
3176
|
+
import_async14.synchronized
|
|
3183
3177
|
], DataSpaceManager.prototype, "open", null);
|
|
3184
3178
|
__decorate3([
|
|
3185
|
-
|
|
3179
|
+
import_async14.synchronized
|
|
3186
3180
|
], DataSpaceManager.prototype, "close", null);
|
|
3187
3181
|
__decorate3([
|
|
3188
|
-
|
|
3182
|
+
import_async14.synchronized
|
|
3189
3183
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
3190
3184
|
__decorate3([
|
|
3191
|
-
|
|
3185
|
+
import_async14.synchronized
|
|
3192
3186
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
3193
3187
|
DataSpaceManager = __decorate3([
|
|
3194
|
-
(0,
|
|
3188
|
+
(0, import_async14.trackLeaks)("open", "close")
|
|
3195
3189
|
], DataSpaceManager);
|
|
3196
3190
|
|
|
3197
3191
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
3198
|
-
var
|
|
3192
|
+
var import_async15 = require("@dxos/async");
|
|
3199
3193
|
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
3200
3194
|
var import_debug5 = require("@dxos/debug");
|
|
3201
3195
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
@@ -3239,9 +3233,9 @@ var SpacesServiceImpl = class {
|
|
|
3239
3233
|
spaces
|
|
3240
3234
|
});
|
|
3241
3235
|
};
|
|
3242
|
-
(0,
|
|
3236
|
+
(0, import_async15.scheduleTask)(ctx, async () => {
|
|
3243
3237
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3244
|
-
const subscriptions = new
|
|
3238
|
+
const subscriptions = new import_async15.EventSubscriptions();
|
|
3245
3239
|
ctx.onDispose(() => subscriptions.clear());
|
|
3246
3240
|
const subscribeSpaces = () => {
|
|
3247
3241
|
subscriptions.clear();
|
|
@@ -3277,7 +3271,7 @@ var SpacesServiceImpl = class {
|
|
|
3277
3271
|
}
|
|
3278
3272
|
subscribeMessages({ spaceKey, channel }) {
|
|
3279
3273
|
return new import_codec_protobuf12.Stream(({ ctx, next }) => {
|
|
3280
|
-
(0,
|
|
3274
|
+
(0, import_async15.scheduleTask)(ctx, async () => {
|
|
3281
3275
|
var _a;
|
|
3282
3276
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3283
3277
|
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
@@ -3298,7 +3292,7 @@ var SpacesServiceImpl = class {
|
|
|
3298
3292
|
}
|
|
3299
3293
|
});
|
|
3300
3294
|
ctx.onDispose(() => processor.close());
|
|
3301
|
-
(0,
|
|
3295
|
+
(0, import_async15.scheduleTask)(ctx, () => processor.open());
|
|
3302
3296
|
});
|
|
3303
3297
|
}
|
|
3304
3298
|
async writeCredentials({ spaceKey, credentials }) {
|
|
@@ -3445,8 +3439,8 @@ var SystemServiceImpl = class {
|
|
|
3445
3439
|
};
|
|
3446
3440
|
|
|
3447
3441
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3448
|
-
var
|
|
3449
|
-
var
|
|
3442
|
+
var import_node_assert12 = __toESM(require("node:assert"));
|
|
3443
|
+
var import_async16 = require("@dxos/async");
|
|
3450
3444
|
var import_credentials14 = require("@dxos/credentials");
|
|
3451
3445
|
var import_debug6 = require("@dxos/debug");
|
|
3452
3446
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
@@ -3464,7 +3458,7 @@ var ServiceContext = class {
|
|
|
3464
3458
|
this.networkManager = networkManager;
|
|
3465
3459
|
this.signalManager = signalManager;
|
|
3466
3460
|
this.modelFactory = modelFactory;
|
|
3467
|
-
this.initialized = new
|
|
3461
|
+
this.initialized = new import_async16.Trigger();
|
|
3468
3462
|
this.dataServiceSubscriptions = new import_echo_pipeline3.DataServiceSubscriptions();
|
|
3469
3463
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
3470
3464
|
this._instanceId = import_keys11.PublicKey.random().toHex();
|
|
@@ -3564,7 +3558,7 @@ var ServiceContext = class {
|
|
|
3564
3558
|
}
|
|
3565
3559
|
getInvitationHandler(invitation) {
|
|
3566
3560
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3567
|
-
(0,
|
|
3561
|
+
(0, import_node_assert12.default)(factory, `Unknown invitation kind: ${invitation.kind}`);
|
|
3568
3562
|
return factory(invitation);
|
|
3569
3563
|
}
|
|
3570
3564
|
async _acceptIdentity(params) {
|
|
@@ -3604,7 +3598,7 @@ var ServiceContext = class {
|
|
|
3604
3598
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
3605
3599
|
await this.dataSpaceManager.open();
|
|
3606
3600
|
this._handlerFactories.set(import_services11.Invitation.Kind.SPACE, (invitation) => {
|
|
3607
|
-
(0,
|
|
3601
|
+
(0, import_node_assert12.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
|
|
3608
3602
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
3609
3603
|
});
|
|
3610
3604
|
this.initialized.wake();
|
|
@@ -3703,7 +3697,7 @@ var ClientServicesHost = class {
|
|
|
3703
3697
|
// TODO(wittjosiah): Turn this on by default.
|
|
3704
3698
|
lockKey
|
|
3705
3699
|
} = {}) {
|
|
3706
|
-
this._statusUpdate = new
|
|
3700
|
+
this._statusUpdate = new import_async17.Event();
|
|
3707
3701
|
this._opening = false;
|
|
3708
3702
|
this._open = false;
|
|
3709
3703
|
this._storage = storage;
|
|
@@ -3766,9 +3760,9 @@ var ClientServicesHost = class {
|
|
|
3766
3760
|
*/
|
|
3767
3761
|
initialize({ config, ...options }) {
|
|
3768
3762
|
var _a, _b, _c;
|
|
3769
|
-
(0,
|
|
3763
|
+
(0, import_node_assert13.default)(!this._open, "service host is open");
|
|
3770
3764
|
if (config) {
|
|
3771
|
-
(0,
|
|
3765
|
+
(0, import_node_assert13.default)(!this._config, "config already set");
|
|
3772
3766
|
this._config = config;
|
|
3773
3767
|
if (!this._storage) {
|
|
3774
3768
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
@@ -3778,7 +3772,7 @@ var ClientServicesHost = class {
|
|
|
3778
3772
|
iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
|
|
3779
3773
|
}), signalManager = new import_messaging.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
|
|
3780
3774
|
this._signalManager = signalManager;
|
|
3781
|
-
(0,
|
|
3775
|
+
(0, import_node_assert13.default)(!this._networkManager, "network manager already set");
|
|
3782
3776
|
this._networkManager = new import_network_manager2.NetworkManager({
|
|
3783
3777
|
log: connectionLog,
|
|
3784
3778
|
transportFactory,
|
|
@@ -3799,10 +3793,10 @@ var ClientServicesHost = class {
|
|
|
3799
3793
|
scope: this,
|
|
3800
3794
|
callSite: (f, a) => f(...a)
|
|
3801
3795
|
});
|
|
3802
|
-
(0,
|
|
3803
|
-
(0,
|
|
3804
|
-
(0,
|
|
3805
|
-
(0,
|
|
3796
|
+
(0, import_node_assert13.default)(this._config, "config not set");
|
|
3797
|
+
(0, import_node_assert13.default)(this._storage, "storage not set");
|
|
3798
|
+
(0, import_node_assert13.default)(this._signalManager, "signal manager not set");
|
|
3799
|
+
(0, import_node_assert13.default)(this._networkManager, "network manager not set");
|
|
3806
3800
|
this._opening = true;
|
|
3807
3801
|
(0, import_log15.log)("opening...", {
|
|
3808
3802
|
lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
|
|
@@ -3935,9 +3929,9 @@ var sanitizeInvitation = (invitation) => {
|
|
|
3935
3929
|
};
|
|
3936
3930
|
};
|
|
3937
3931
|
var performInvitation = ({ host, guest, options, hooks }) => {
|
|
3938
|
-
const hostComplete = new
|
|
3939
|
-
const guestComplete = new
|
|
3940
|
-
const authCode = new
|
|
3932
|
+
const hostComplete = new import_async18.Trigger();
|
|
3933
|
+
const guestComplete = new import_async18.Trigger();
|
|
3934
|
+
const authCode = new import_async18.Trigger();
|
|
3941
3935
|
const hostObservable = createInvitation(host, options);
|
|
3942
3936
|
hostObservable.subscribe(async (hostInvitation) => {
|
|
3943
3937
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
@@ -3954,7 +3948,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
3954
3948
|
if ((_b2 = (_a2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _a2.onConnecting) == null ? void 0 : _b2.call(_a2, guestObservable)) {
|
|
3955
3949
|
break;
|
|
3956
3950
|
}
|
|
3957
|
-
(0,
|
|
3951
|
+
(0, import_node_assert14.default)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey));
|
|
3958
3952
|
break;
|
|
3959
3953
|
}
|
|
3960
3954
|
case import_services13.Invitation.State.CONNECTED: {
|