@dxos/client-services 0.1.53-main.52ca4e9 → 0.1.53-main.5bcfb84
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/browser/{chunk-PWZ2J6KS.mjs → chunk-EYXOVYW5.mjs} +170 -90
- package/dist/lib/browser/chunk-EYXOVYW5.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +19 -2
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +165 -85
- 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 +179 -83
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +11 -2
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +2 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +7 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/package.json +32 -32
- package/src/packlets/identity/identity.ts +21 -26
- package/src/packlets/services/service-context.ts +9 -7
- package/src/packlets/spaces/data-space-manager.test.ts +72 -118
- package/src/packlets/spaces/data-space-manager.ts +13 -3
- package/src/packlets/spaces/data-space.ts +66 -20
- package/src/packlets/spaces/notarization-plugin.test.ts +1 -1
- package/src/packlets/spaces/notarization-plugin.ts +5 -1
- package/src/packlets/spaces/spaces-service.ts +26 -8
- package/src/packlets/testing/test-builder.ts +35 -2
- package/dist/lib/browser/chunk-PWZ2J6KS.mjs.map +0 -7
package/dist/lib/node/index.cjs
CHANGED
|
@@ -545,15 +545,15 @@ var Identity = class {
|
|
|
545
545
|
this._signer = signer;
|
|
546
546
|
this.identityKey = identityKey;
|
|
547
547
|
this.deviceKey = deviceKey;
|
|
548
|
-
this._deviceStateMachine =
|
|
548
|
+
this._deviceStateMachine = new import_credentials2.DeviceStateMachine({
|
|
549
549
|
identityKey: this.identityKey,
|
|
550
550
|
deviceKey: this.deviceKey,
|
|
551
551
|
onUpdate: () => this.stateUpdate.emit()
|
|
552
|
-
})
|
|
553
|
-
this._profileStateMachine =
|
|
552
|
+
});
|
|
553
|
+
this._profileStateMachine = new import_credentials2.ProfileStateMachine({
|
|
554
554
|
identityKey: this.identityKey,
|
|
555
555
|
onUpdate: () => this.stateUpdate.emit()
|
|
556
|
-
})
|
|
556
|
+
});
|
|
557
557
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
558
558
|
trustedKeysProvider: () => this.authorizedDeviceKeys,
|
|
559
559
|
update: this.stateUpdate,
|
|
@@ -562,27 +562,27 @@ var Identity = class {
|
|
|
562
562
|
}
|
|
563
563
|
// TODO(burdon): Expose state object?
|
|
564
564
|
get authorizedDeviceKeys() {
|
|
565
|
-
return this._deviceStateMachine.
|
|
565
|
+
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
566
566
|
}
|
|
567
567
|
async open() {
|
|
568
|
-
await this.
|
|
569
|
-
await this.
|
|
568
|
+
await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
|
|
569
|
+
await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
|
|
570
570
|
await this.space.open();
|
|
571
571
|
}
|
|
572
572
|
async close() {
|
|
573
573
|
await this.authVerifier.close();
|
|
574
|
-
await this.
|
|
575
|
-
await this.
|
|
574
|
+
await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
|
|
575
|
+
await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
|
|
576
576
|
await this.space.close();
|
|
577
577
|
}
|
|
578
578
|
async ready() {
|
|
579
|
-
await this._deviceStateMachine.
|
|
579
|
+
await this._deviceStateMachine.deviceChainReady.wait();
|
|
580
580
|
await this.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
581
581
|
timeout: import_client_protocol.LOAD_CONTROL_FEEDS_TIMEOUT
|
|
582
582
|
});
|
|
583
583
|
}
|
|
584
584
|
get profileDocument() {
|
|
585
|
-
return this._profileStateMachine.
|
|
585
|
+
return this._profileStateMachine.profile;
|
|
586
586
|
}
|
|
587
587
|
/**
|
|
588
588
|
* @test-only
|
|
@@ -597,7 +597,7 @@ var Identity = class {
|
|
|
597
597
|
return this.space.genesisFeedKey;
|
|
598
598
|
}
|
|
599
599
|
get deviceCredentialChain() {
|
|
600
|
-
return this._deviceStateMachine.
|
|
600
|
+
return this._deviceStateMachine.deviceCredentialChain;
|
|
601
601
|
}
|
|
602
602
|
getAdmissionCredentials() {
|
|
603
603
|
var _a, _b;
|
|
@@ -612,8 +612,8 @@ var Identity = class {
|
|
|
612
612
|
* Requires identity to be ready.
|
|
613
613
|
*/
|
|
614
614
|
getIdentityCredentialSigner() {
|
|
615
|
-
(0, import_tiny_invariant.default)(this._deviceStateMachine.
|
|
616
|
-
return (0, import_credentials2.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.
|
|
615
|
+
(0, import_tiny_invariant.default)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.");
|
|
616
|
+
return (0, import_credentials2.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
|
|
617
617
|
}
|
|
618
618
|
/**
|
|
619
619
|
* Issues credentials as device.
|
|
@@ -630,7 +630,7 @@ var Identity = class {
|
|
|
630
630
|
dataFeedKey
|
|
631
631
|
}, {
|
|
632
632
|
F: __dxlog_file2,
|
|
633
|
-
L:
|
|
633
|
+
L: 151,
|
|
634
634
|
S: this,
|
|
635
635
|
C: (f, a) => f(...a)
|
|
636
636
|
});
|
|
@@ -2210,6 +2210,9 @@ var NotarizationPlugin = class {
|
|
|
2210
2210
|
this._processedCredentials = new import_util3.ComplexSet(import_keys7.PublicKey.hash);
|
|
2211
2211
|
this._processCredentialsTriggers = new import_util3.ComplexMap(import_keys7.PublicKey.hash);
|
|
2212
2212
|
}
|
|
2213
|
+
get hasWriter() {
|
|
2214
|
+
return !!this._writer;
|
|
2215
|
+
}
|
|
2213
2216
|
async open() {
|
|
2214
2217
|
}
|
|
2215
2218
|
async close() {
|
|
@@ -2223,7 +2226,7 @@ var NotarizationPlugin = class {
|
|
|
2223
2226
|
credentials
|
|
2224
2227
|
}, {
|
|
2225
2228
|
F: __dxlog_file8,
|
|
2226
|
-
L:
|
|
2229
|
+
L: 91,
|
|
2227
2230
|
S: this,
|
|
2228
2231
|
C: (f, a) => f(...a)
|
|
2229
2232
|
});
|
|
@@ -2235,7 +2238,7 @@ var NotarizationPlugin = class {
|
|
|
2235
2238
|
err
|
|
2236
2239
|
}, {
|
|
2237
2240
|
F: __dxlog_file8,
|
|
2238
|
-
L:
|
|
2241
|
+
L: 100,
|
|
2239
2242
|
S: this,
|
|
2240
2243
|
C: (f, a) => f(...a)
|
|
2241
2244
|
});
|
|
@@ -2251,7 +2254,7 @@ var NotarizationPlugin = class {
|
|
|
2251
2254
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
2252
2255
|
}, {
|
|
2253
2256
|
F: __dxlog_file8,
|
|
2254
|
-
L:
|
|
2257
|
+
L: 112,
|
|
2255
2258
|
S: this,
|
|
2256
2259
|
C: (f, a) => f(...a)
|
|
2257
2260
|
});
|
|
@@ -2274,7 +2277,7 @@ var NotarizationPlugin = class {
|
|
|
2274
2277
|
retryIn: retryTimeout
|
|
2275
2278
|
}, {
|
|
2276
2279
|
F: __dxlog_file8,
|
|
2277
|
-
L:
|
|
2280
|
+
L: 137,
|
|
2278
2281
|
S: this,
|
|
2279
2282
|
C: (f, a) => f(...a)
|
|
2280
2283
|
});
|
|
@@ -2288,7 +2291,7 @@ var NotarizationPlugin = class {
|
|
|
2288
2291
|
credentialId: credentials.map((credential) => credential.id)
|
|
2289
2292
|
}, {
|
|
2290
2293
|
F: __dxlog_file8,
|
|
2291
|
-
L:
|
|
2294
|
+
L: 144,
|
|
2292
2295
|
S: this,
|
|
2293
2296
|
C: (f, a) => f(...a)
|
|
2294
2297
|
});
|
|
@@ -2297,7 +2300,7 @@ var NotarizationPlugin = class {
|
|
|
2297
2300
|
});
|
|
2298
2301
|
(0, import_log8.log)("success", void 0, {
|
|
2299
2302
|
F: __dxlog_file8,
|
|
2300
|
-
L:
|
|
2303
|
+
L: 148,
|
|
2301
2304
|
S: this,
|
|
2302
2305
|
C: (f, a) => f(...a)
|
|
2303
2306
|
});
|
|
@@ -2306,7 +2309,7 @@ var NotarizationPlugin = class {
|
|
|
2306
2309
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
2307
2310
|
import_log8.log.warn("error notarizing (recoverable)", err, {
|
|
2308
2311
|
F: __dxlog_file8,
|
|
2309
|
-
L:
|
|
2312
|
+
L: 152,
|
|
2310
2313
|
S: this,
|
|
2311
2314
|
C: (f, a) => f(...a)
|
|
2312
2315
|
});
|
|
@@ -2324,7 +2327,7 @@ var NotarizationPlugin = class {
|
|
|
2324
2327
|
]);
|
|
2325
2328
|
(0, import_log8.log)("done", void 0, {
|
|
2326
2329
|
F: __dxlog_file8,
|
|
2327
|
-
L:
|
|
2330
|
+
L: 163,
|
|
2328
2331
|
S: this,
|
|
2329
2332
|
C: (f, a) => f(...a)
|
|
2330
2333
|
});
|
|
@@ -2335,7 +2338,7 @@ var NotarizationPlugin = class {
|
|
|
2335
2338
|
/**
|
|
2336
2339
|
* Called with credentials arriving from the control pipeline.
|
|
2337
2340
|
*/
|
|
2338
|
-
async
|
|
2341
|
+
async processCredential(credential) {
|
|
2339
2342
|
var _a;
|
|
2340
2343
|
if (!credential.id) {
|
|
2341
2344
|
return;
|
|
@@ -2377,7 +2380,7 @@ var NotarizationPlugin = class {
|
|
|
2377
2380
|
peer: extension.localPeerId
|
|
2378
2381
|
}, {
|
|
2379
2382
|
F: __dxlog_file8,
|
|
2380
|
-
L:
|
|
2383
|
+
L: 212,
|
|
2381
2384
|
S: this,
|
|
2382
2385
|
C: (f, a) => f(...a)
|
|
2383
2386
|
});
|
|
@@ -2389,7 +2392,7 @@ var NotarizationPlugin = class {
|
|
|
2389
2392
|
peer: extension.localPeerId
|
|
2390
2393
|
}, {
|
|
2391
2394
|
F: __dxlog_file8,
|
|
2392
|
-
L:
|
|
2395
|
+
L: 217,
|
|
2393
2396
|
S: this,
|
|
2394
2397
|
C: (f, a) => f(...a)
|
|
2395
2398
|
});
|
|
@@ -2446,6 +2449,7 @@ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/sr
|
|
|
2446
2449
|
var DataSpace = class DataSpace2 {
|
|
2447
2450
|
constructor(params) {
|
|
2448
2451
|
this._ctx = new import_context6.Context();
|
|
2452
|
+
this._notarizationPlugin = new NotarizationPlugin();
|
|
2449
2453
|
this._state = import_services6.SpaceState.CLOSED;
|
|
2450
2454
|
/**
|
|
2451
2455
|
* Error for _state === SpaceState.ERROR.
|
|
@@ -2468,8 +2472,8 @@ var DataSpace = class DataSpace2 {
|
|
|
2468
2472
|
update: this._inner.stateUpdate,
|
|
2469
2473
|
authTimeout: import_client_protocol3.AUTH_TIMEOUT
|
|
2470
2474
|
});
|
|
2471
|
-
this._notarizationPluginConsumer = this._inner.spaceState.registerProcessor(new NotarizationPlugin());
|
|
2472
2475
|
this._cache = params.cache;
|
|
2476
|
+
this._state = params.initialState;
|
|
2473
2477
|
}
|
|
2474
2478
|
get key() {
|
|
2475
2479
|
return this._inner.key;
|
|
@@ -2491,25 +2495,36 @@ var DataSpace = class DataSpace2 {
|
|
|
2491
2495
|
return this._presence;
|
|
2492
2496
|
}
|
|
2493
2497
|
get notarizationPlugin() {
|
|
2494
|
-
return this.
|
|
2498
|
+
return this._notarizationPlugin;
|
|
2495
2499
|
}
|
|
2496
2500
|
get cache() {
|
|
2497
2501
|
return this._cache;
|
|
2498
2502
|
}
|
|
2499
2503
|
async open() {
|
|
2500
|
-
await this.
|
|
2501
|
-
|
|
2504
|
+
await this._open();
|
|
2505
|
+
}
|
|
2506
|
+
async _open() {
|
|
2507
|
+
await this._notarizationPlugin.open();
|
|
2508
|
+
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
2502
2509
|
await this._inner.open();
|
|
2503
|
-
this._state = import_services6.SpaceState.
|
|
2510
|
+
this._state = import_services6.SpaceState.CONTROL_ONLY;
|
|
2511
|
+
this.stateUpdate.emit();
|
|
2512
|
+
this.metrics = {};
|
|
2504
2513
|
this.metrics.open = new Date();
|
|
2505
2514
|
}
|
|
2506
2515
|
async close() {
|
|
2516
|
+
await this._close();
|
|
2517
|
+
}
|
|
2518
|
+
async _close() {
|
|
2519
|
+
var _a, _b;
|
|
2520
|
+
await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
|
|
2507
2521
|
this._state = import_services6.SpaceState.CLOSED;
|
|
2508
2522
|
await this._ctx.dispose();
|
|
2523
|
+
this._ctx = new import_context6.Context();
|
|
2509
2524
|
await this.authVerifier.close();
|
|
2510
2525
|
await this._inner.close();
|
|
2511
|
-
await this.
|
|
2512
|
-
await this.
|
|
2526
|
+
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
2527
|
+
await this._notarizationPlugin.close();
|
|
2513
2528
|
await this._presence.destroy();
|
|
2514
2529
|
}
|
|
2515
2530
|
async postMessage(channel, message) {
|
|
@@ -2530,7 +2545,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2530
2545
|
if (err instanceof import_errors3.CancelledError) {
|
|
2531
2546
|
(0, import_log9.log)("Data pipeline initialization cancelled", err, {
|
|
2532
2547
|
F: __dxlog_file9,
|
|
2533
|
-
L:
|
|
2548
|
+
L: 193,
|
|
2534
2549
|
S: this,
|
|
2535
2550
|
C: (f, a) => f(...a)
|
|
2536
2551
|
});
|
|
@@ -2538,7 +2553,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2538
2553
|
}
|
|
2539
2554
|
import_log9.log.error("Error initializing data pipeline", err, {
|
|
2540
2555
|
F: __dxlog_file9,
|
|
2541
|
-
L:
|
|
2556
|
+
L: 197,
|
|
2542
2557
|
S: this,
|
|
2543
2558
|
C: (f, a) => f(...a)
|
|
2544
2559
|
});
|
|
@@ -2552,7 +2567,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2552
2567
|
}
|
|
2553
2568
|
async initializeDataPipeline() {
|
|
2554
2569
|
var _a, _b, _c, _d;
|
|
2555
|
-
if (this._state !== import_services6.SpaceState.
|
|
2570
|
+
if (this._state !== import_services6.SpaceState.CONTROL_ONLY) {
|
|
2556
2571
|
throw new import_errors3.SystemError("Invalid operation");
|
|
2557
2572
|
}
|
|
2558
2573
|
this._state = import_services6.SpaceState.INITIALIZING;
|
|
@@ -2564,22 +2579,24 @@ var DataSpace = class DataSpace2 {
|
|
|
2564
2579
|
await this._createWritableFeeds();
|
|
2565
2580
|
(0, import_log9.log)("Writable feeds created", void 0, {
|
|
2566
2581
|
F: __dxlog_file9,
|
|
2567
|
-
L:
|
|
2582
|
+
L: 221,
|
|
2568
2583
|
S: this,
|
|
2569
2584
|
C: (f, a) => f(...a)
|
|
2570
2585
|
});
|
|
2571
2586
|
this.stateUpdate.emit();
|
|
2572
|
-
this.notarizationPlugin.
|
|
2573
|
-
credential
|
|
2574
|
-
credential
|
|
2575
|
-
|
|
2576
|
-
|
|
2587
|
+
if (!this.notarizationPlugin.hasWriter) {
|
|
2588
|
+
this.notarizationPlugin.setWriter((0, import_echo_pipeline.createMappedFeedWriter)((credential) => ({
|
|
2589
|
+
credential: {
|
|
2590
|
+
credential
|
|
2591
|
+
}
|
|
2592
|
+
}), this._inner.controlPipeline.writer));
|
|
2593
|
+
}
|
|
2577
2594
|
await this._inner.initializeDataPipeline();
|
|
2578
2595
|
this.metrics.dataPipelineOpen = new Date();
|
|
2579
2596
|
await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
2580
2597
|
(0, import_log9.log)("waiting for data pipeline to reach target timeframe", void 0, {
|
|
2581
2598
|
F: __dxlog_file9,
|
|
2582
|
-
L:
|
|
2599
|
+
L: 242,
|
|
2583
2600
|
S: this,
|
|
2584
2601
|
C: (f, a) => f(...a)
|
|
2585
2602
|
});
|
|
@@ -2590,7 +2607,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2590
2607
|
this.metrics.dataPipelineReady = new Date();
|
|
2591
2608
|
(0, import_log9.log)("data pipeline ready", void 0, {
|
|
2592
2609
|
F: __dxlog_file9,
|
|
2593
|
-
L:
|
|
2610
|
+
L: 251,
|
|
2594
2611
|
S: this,
|
|
2595
2612
|
C: (f, a) => f(...a)
|
|
2596
2613
|
});
|
|
@@ -2670,10 +2687,39 @@ var DataSpace = class DataSpace2 {
|
|
|
2670
2687
|
}
|
|
2671
2688
|
}
|
|
2672
2689
|
}
|
|
2690
|
+
async activate() {
|
|
2691
|
+
if (this._state !== import_services6.SpaceState.INACTIVE) {
|
|
2692
|
+
throw new import_errors3.SystemError("Invalid operation");
|
|
2693
|
+
}
|
|
2694
|
+
await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.ACTIVE);
|
|
2695
|
+
await this._open();
|
|
2696
|
+
this.initializeDataPipelineAsync();
|
|
2697
|
+
}
|
|
2698
|
+
async deactivate() {
|
|
2699
|
+
if (this._state === import_services6.SpaceState.INACTIVE) {
|
|
2700
|
+
throw new import_errors3.SystemError("Invalid operation");
|
|
2701
|
+
}
|
|
2702
|
+
await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.INACTIVE);
|
|
2703
|
+
await this._close();
|
|
2704
|
+
this._state = import_services6.SpaceState.INACTIVE;
|
|
2705
|
+
this.stateUpdate.emit();
|
|
2706
|
+
}
|
|
2673
2707
|
};
|
|
2708
|
+
_ts_decorate([
|
|
2709
|
+
import_async11.synchronized
|
|
2710
|
+
], DataSpace.prototype, "open", null);
|
|
2711
|
+
_ts_decorate([
|
|
2712
|
+
import_async11.synchronized
|
|
2713
|
+
], DataSpace.prototype, "close", null);
|
|
2674
2714
|
_ts_decorate([
|
|
2675
2715
|
(0, import_debug3.timed)(1e4)
|
|
2676
2716
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2717
|
+
_ts_decorate([
|
|
2718
|
+
import_async11.synchronized
|
|
2719
|
+
], DataSpace.prototype, "activate", null);
|
|
2720
|
+
_ts_decorate([
|
|
2721
|
+
import_async11.synchronized
|
|
2722
|
+
], DataSpace.prototype, "deactivate", null);
|
|
2677
2723
|
DataSpace = _ts_decorate([
|
|
2678
2724
|
(0, import_async11.trackLeaks)("open", "close")
|
|
2679
2725
|
], DataSpace);
|
|
@@ -2813,14 +2859,16 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2813
2859
|
C: (f, a) => f(...a)
|
|
2814
2860
|
});
|
|
2815
2861
|
const space = await this._constructSpace(spaceMetadata);
|
|
2816
|
-
|
|
2862
|
+
if (spaceMetadata.state !== import_services7.SpaceState.INACTIVE) {
|
|
2863
|
+
space.initializeDataPipelineAsync();
|
|
2864
|
+
}
|
|
2817
2865
|
} catch (err) {
|
|
2818
2866
|
import_log10.log.error("Error loading space", {
|
|
2819
2867
|
spaceMetadata,
|
|
2820
2868
|
err
|
|
2821
2869
|
}, {
|
|
2822
2870
|
F: __dxlog_file10,
|
|
2823
|
-
L:
|
|
2871
|
+
L: 93,
|
|
2824
2872
|
S: this,
|
|
2825
2873
|
C: (f, a) => f(...a)
|
|
2826
2874
|
});
|
|
@@ -2832,7 +2880,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2832
2880
|
id: this._instanceId
|
|
2833
2881
|
}), {
|
|
2834
2882
|
F: __dxlog_file10,
|
|
2835
|
-
L:
|
|
2883
|
+
L: 99,
|
|
2836
2884
|
S: this,
|
|
2837
2885
|
C: (f, a) => f(...a)
|
|
2838
2886
|
});
|
|
@@ -2840,7 +2888,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2840
2888
|
async close() {
|
|
2841
2889
|
(0, import_log10.log)("close", void 0, {
|
|
2842
2890
|
F: __dxlog_file10,
|
|
2843
|
-
L:
|
|
2891
|
+
L: 104,
|
|
2844
2892
|
S: this,
|
|
2845
2893
|
C: (f, a) => f(...a)
|
|
2846
2894
|
});
|
|
@@ -2862,13 +2910,14 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2862
2910
|
key: spaceKey,
|
|
2863
2911
|
genesisFeedKey: controlFeedKey,
|
|
2864
2912
|
controlFeedKey,
|
|
2865
|
-
dataFeedKey
|
|
2913
|
+
dataFeedKey,
|
|
2914
|
+
state: import_services7.SpaceState.ACTIVE
|
|
2866
2915
|
};
|
|
2867
2916
|
(0, import_log10.log)("creating space...", {
|
|
2868
2917
|
spaceKey
|
|
2869
2918
|
}, {
|
|
2870
2919
|
F: __dxlog_file10,
|
|
2871
|
-
L:
|
|
2920
|
+
L: 129,
|
|
2872
2921
|
S: this,
|
|
2873
2922
|
C: (f, a) => f(...a)
|
|
2874
2923
|
});
|
|
@@ -2888,7 +2937,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2888
2937
|
opts
|
|
2889
2938
|
}, {
|
|
2890
2939
|
F: __dxlog_file10,
|
|
2891
|
-
L:
|
|
2940
|
+
L: 148,
|
|
2892
2941
|
S: this,
|
|
2893
2942
|
C: (f, a) => f(...a)
|
|
2894
2943
|
});
|
|
@@ -2922,7 +2971,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2922
2971
|
metadata
|
|
2923
2972
|
}, {
|
|
2924
2973
|
F: __dxlog_file10,
|
|
2925
|
-
L:
|
|
2974
|
+
L: 183,
|
|
2926
2975
|
S: this,
|
|
2927
2976
|
C: (f, a) => f(...a)
|
|
2928
2977
|
});
|
|
@@ -2958,7 +3007,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2958
3007
|
onAuthFailure: () => {
|
|
2959
3008
|
import_log10.log.warn("auth failure", void 0, {
|
|
2960
3009
|
F: __dxlog_file10,
|
|
2961
|
-
L:
|
|
3010
|
+
L: 214,
|
|
2962
3011
|
S: this,
|
|
2963
3012
|
C: (f, a) => f(...a)
|
|
2964
3013
|
});
|
|
@@ -2969,6 +3018,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2969
3018
|
dataFeed && space.setDataFeed(dataFeed);
|
|
2970
3019
|
const dataSpace = new DataSpace({
|
|
2971
3020
|
inner: space,
|
|
3021
|
+
initialState: metadata.state === import_services7.SpaceState.INACTIVE ? import_services7.SpaceState.INACTIVE : import_services7.SpaceState.CLOSED,
|
|
2972
3022
|
metadataStore: this._metadataStore,
|
|
2973
3023
|
gossip,
|
|
2974
3024
|
presence,
|
|
@@ -2981,11 +3031,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2981
3031
|
space: space.key
|
|
2982
3032
|
}, {
|
|
2983
3033
|
F: __dxlog_file10,
|
|
2984
|
-
L:
|
|
3034
|
+
L: 232,
|
|
2985
3035
|
S: this,
|
|
2986
3036
|
C: (f, a) => f(...a)
|
|
2987
3037
|
});
|
|
2988
|
-
this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
3038
|
+
await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2989
3039
|
},
|
|
2990
3040
|
afterReady: async () => {
|
|
2991
3041
|
(0, import_log10.log)("after space ready", {
|
|
@@ -2993,18 +3043,31 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2993
3043
|
open: this._isOpen
|
|
2994
3044
|
}, {
|
|
2995
3045
|
F: __dxlog_file10,
|
|
2996
|
-
L:
|
|
3046
|
+
L: 239,
|
|
2997
3047
|
S: this,
|
|
2998
3048
|
C: (f, a) => f(...a)
|
|
2999
3049
|
});
|
|
3000
3050
|
if (this._isOpen) {
|
|
3001
3051
|
this.updated.emit();
|
|
3002
3052
|
}
|
|
3053
|
+
},
|
|
3054
|
+
beforeClose: async () => {
|
|
3055
|
+
(0, import_log10.log)("before space close", {
|
|
3056
|
+
space: space.key
|
|
3057
|
+
}, {
|
|
3058
|
+
F: __dxlog_file10,
|
|
3059
|
+
L: 245,
|
|
3060
|
+
S: this,
|
|
3061
|
+
C: (f, a) => f(...a)
|
|
3062
|
+
});
|
|
3063
|
+
await this._dataServiceSubscriptions.unregisterSpace(space.key);
|
|
3003
3064
|
}
|
|
3004
3065
|
},
|
|
3005
3066
|
cache: metadata.cache
|
|
3006
3067
|
});
|
|
3007
|
-
|
|
3068
|
+
if (metadata.state !== import_services7.SpaceState.INACTIVE) {
|
|
3069
|
+
await dataSpace.open();
|
|
3070
|
+
}
|
|
3008
3071
|
if (metadata.controlTimeframe) {
|
|
3009
3072
|
dataSpace.inner.controlPipeline.state.setTargetTimeframe(metadata.controlTimeframe);
|
|
3010
3073
|
}
|
|
@@ -3036,6 +3099,7 @@ var import_async13 = require("@dxos/async");
|
|
|
3036
3099
|
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
3037
3100
|
var import_debug5 = require("@dxos/debug");
|
|
3038
3101
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
3102
|
+
var import_errors4 = require("@dxos/errors");
|
|
3039
3103
|
var import_log11 = require("@dxos/log");
|
|
3040
3104
|
var import_protocols7 = require("@dxos/protocols");
|
|
3041
3105
|
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
@@ -3056,8 +3120,22 @@ var SpacesServiceImpl = class {
|
|
|
3056
3120
|
const space = await dataSpaceManager.createSpace();
|
|
3057
3121
|
return this._serializeSpace(space);
|
|
3058
3122
|
}
|
|
3059
|
-
async updateSpace(
|
|
3060
|
-
|
|
3123
|
+
async updateSpace({ spaceKey, state }) {
|
|
3124
|
+
var _a;
|
|
3125
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3126
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3127
|
+
if (state) {
|
|
3128
|
+
switch (state) {
|
|
3129
|
+
case import_services8.SpaceState.ACTIVE:
|
|
3130
|
+
await space.activate();
|
|
3131
|
+
break;
|
|
3132
|
+
case import_services8.SpaceState.INACTIVE:
|
|
3133
|
+
await space.deactivate();
|
|
3134
|
+
break;
|
|
3135
|
+
default:
|
|
3136
|
+
throw new import_errors4.ApiError("Invalid space state");
|
|
3137
|
+
}
|
|
3138
|
+
}
|
|
3061
3139
|
}
|
|
3062
3140
|
querySpaces() {
|
|
3063
3141
|
return new import_codec_protobuf9.Stream(({ next, ctx }) => {
|
|
@@ -3068,7 +3146,7 @@ var SpacesServiceImpl = class {
|
|
|
3068
3146
|
spaces
|
|
3069
3147
|
}, {
|
|
3070
3148
|
F: __dxlog_file11,
|
|
3071
|
-
L:
|
|
3149
|
+
L: 78,
|
|
3072
3150
|
S: this,
|
|
3073
3151
|
C: (f, a) => f(...a)
|
|
3074
3152
|
});
|
|
@@ -3131,13 +3209,13 @@ var SpacesServiceImpl = class {
|
|
|
3131
3209
|
return new import_codec_protobuf9.Stream(({ ctx, next }) => {
|
|
3132
3210
|
var _a;
|
|
3133
3211
|
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3134
|
-
const processor =
|
|
3135
|
-
|
|
3212
|
+
const processor = {
|
|
3213
|
+
processCredential: async (credential) => {
|
|
3136
3214
|
next(credential);
|
|
3137
3215
|
}
|
|
3138
|
-
}
|
|
3139
|
-
ctx.onDispose(() =>
|
|
3140
|
-
(0, import_async13.scheduleTask)(ctx, () =>
|
|
3216
|
+
};
|
|
3217
|
+
ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
|
|
3218
|
+
(0, import_async13.scheduleTask)(ctx, () => space.spaceState.addCredentialProcessor(processor));
|
|
3141
3219
|
});
|
|
3142
3220
|
}
|
|
3143
3221
|
async writeCredentials({ spaceKey, credentials }) {
|
|
@@ -3276,15 +3354,17 @@ var ServiceContext = class {
|
|
|
3276
3354
|
});
|
|
3277
3355
|
}
|
|
3278
3356
|
async close() {
|
|
3279
|
-
var _a
|
|
3357
|
+
var _a;
|
|
3280
3358
|
(0, import_log12.log)("closing...", void 0, {
|
|
3281
3359
|
F: __dxlog_file12,
|
|
3282
3360
|
L: 143,
|
|
3283
3361
|
S: this,
|
|
3284
3362
|
C: (f, a) => f(...a)
|
|
3285
3363
|
});
|
|
3286
|
-
|
|
3287
|
-
|
|
3364
|
+
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
3365
|
+
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
3366
|
+
}
|
|
3367
|
+
await ((_a = this.dataSpaceManager) == null ? void 0 : _a.close());
|
|
3288
3368
|
await this.identityManager.close();
|
|
3289
3369
|
await this.spaceManager.close();
|
|
3290
3370
|
await this.feedStore.close();
|
|
@@ -3293,7 +3373,7 @@ var ServiceContext = class {
|
|
|
3293
3373
|
this.dataServiceSubscriptions.clear();
|
|
3294
3374
|
(0, import_log12.log)("closed", void 0, {
|
|
3295
3375
|
F: __dxlog_file12,
|
|
3296
|
-
L:
|
|
3376
|
+
L: 154,
|
|
3297
3377
|
S: this,
|
|
3298
3378
|
C: (f, a) => f(...a)
|
|
3299
3379
|
});
|
|
@@ -3324,7 +3404,7 @@ var ServiceContext = class {
|
|
|
3324
3404
|
var _a;
|
|
3325
3405
|
(0, import_log12.log)("initializing spaces...", void 0, {
|
|
3326
3406
|
F: __dxlog_file12,
|
|
3327
|
-
L:
|
|
3407
|
+
L: 187,
|
|
3328
3408
|
S: this,
|
|
3329
3409
|
C: (f, a) => f(...a)
|
|
3330
3410
|
});
|
|
@@ -3349,8 +3429,8 @@ var ServiceContext = class {
|
|
|
3349
3429
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
3350
3430
|
});
|
|
3351
3431
|
this.initialized.wake();
|
|
3352
|
-
this._deviceSpaceSync =
|
|
3353
|
-
|
|
3432
|
+
this._deviceSpaceSync = {
|
|
3433
|
+
processCredential: async (credential) => {
|
|
3354
3434
|
const assertion = (0, import_credentials13.getCredentialAssertion)(credential);
|
|
3355
3435
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
3356
3436
|
return;
|
|
@@ -3363,7 +3443,7 @@ var ServiceContext = class {
|
|
|
3363
3443
|
details: assertion
|
|
3364
3444
|
}, {
|
|
3365
3445
|
F: __dxlog_file12,
|
|
3366
|
-
L:
|
|
3446
|
+
L: 226,
|
|
3367
3447
|
S: this,
|
|
3368
3448
|
C: (f, a) => f(...a)
|
|
3369
3449
|
});
|
|
@@ -3374,7 +3454,7 @@ var ServiceContext = class {
|
|
|
3374
3454
|
details: assertion
|
|
3375
3455
|
}, {
|
|
3376
3456
|
F: __dxlog_file12,
|
|
3377
|
-
L:
|
|
3457
|
+
L: 230,
|
|
3378
3458
|
S: this,
|
|
3379
3459
|
C: (f, a) => f(...a)
|
|
3380
3460
|
});
|
|
@@ -3385,7 +3465,7 @@ var ServiceContext = class {
|
|
|
3385
3465
|
details: assertion
|
|
3386
3466
|
}, {
|
|
3387
3467
|
F: __dxlog_file12,
|
|
3388
|
-
L:
|
|
3468
|
+
L: 235,
|
|
3389
3469
|
S: this,
|
|
3390
3470
|
C: (f, a) => f(...a)
|
|
3391
3471
|
});
|
|
@@ -3396,14 +3476,14 @@ var ServiceContext = class {
|
|
|
3396
3476
|
} catch (err) {
|
|
3397
3477
|
import_log12.log.catch(err, void 0, {
|
|
3398
3478
|
F: __dxlog_file12,
|
|
3399
|
-
L:
|
|
3479
|
+
L: 241,
|
|
3400
3480
|
S: this,
|
|
3401
3481
|
C: (f, a) => f(...a)
|
|
3402
3482
|
});
|
|
3403
3483
|
}
|
|
3404
3484
|
}
|
|
3405
|
-
}
|
|
3406
|
-
await this._deviceSpaceSync
|
|
3485
|
+
};
|
|
3486
|
+
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
3407
3487
|
}
|
|
3408
3488
|
};
|
|
3409
3489
|
|
|
@@ -3632,7 +3712,7 @@ var NetworkServiceImpl = class {
|
|
|
3632
3712
|
|
|
3633
3713
|
// packages/sdk/client-services/src/packlets/storage/storage.ts
|
|
3634
3714
|
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
3635
|
-
var
|
|
3715
|
+
var import_errors5 = require("@dxos/errors");
|
|
3636
3716
|
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
3637
3717
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
3638
3718
|
var import_util8 = require("@dxos/util");
|
|
@@ -3640,16 +3720,16 @@ var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
|
3640
3720
|
var createStorageObjects = (config) => {
|
|
3641
3721
|
const { path = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config != null ? config : {};
|
|
3642
3722
|
if (persistent && storageType === StorageDriver.RAM) {
|
|
3643
|
-
throw new
|
|
3723
|
+
throw new import_errors5.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
3644
3724
|
}
|
|
3645
3725
|
if (!persistent && storageType !== void 0 && storageType !== StorageDriver.RAM) {
|
|
3646
|
-
throw new
|
|
3726
|
+
throw new import_errors5.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
3647
3727
|
}
|
|
3648
3728
|
if (persistent && keyStorage === StorageDriver.RAM) {
|
|
3649
|
-
throw new
|
|
3729
|
+
throw new import_errors5.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
3650
3730
|
}
|
|
3651
3731
|
if (!persistent && keyStorage !== StorageDriver.RAM && keyStorage !== void 0) {
|
|
3652
|
-
throw new
|
|
3732
|
+
throw new import_errors5.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
3653
3733
|
}
|
|
3654
3734
|
return {
|
|
3655
3735
|
storage: (0, import_random_access_storage.createStorage)({
|
|
@@ -4239,7 +4319,7 @@ _ts_decorate5([
|
|
|
4239
4319
|
// packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
|
|
4240
4320
|
var import_async20 = require("@dxos/async");
|
|
4241
4321
|
var import_client_protocol8 = require("@dxos/client-protocol");
|
|
4242
|
-
var
|
|
4322
|
+
var import_errors6 = require("@dxos/errors");
|
|
4243
4323
|
var import_log17 = require("@dxos/log");
|
|
4244
4324
|
var import_network_manager4 = require("@dxos/network-manager");
|
|
4245
4325
|
var import_rpc3 = require("@dxos/rpc");
|
|
@@ -4298,7 +4378,7 @@ var IFrameProxyRuntime = class {
|
|
|
4298
4378
|
S: this,
|
|
4299
4379
|
C: (f, a) => f(...a)
|
|
4300
4380
|
});
|
|
4301
|
-
throw new
|
|
4381
|
+
throw new import_errors6.RemoteServiceConnectionError("Failed to connect to worker");
|
|
4302
4382
|
}
|
|
4303
4383
|
await ((_a = this._shellRuntime) == null ? void 0 : _a.open());
|
|
4304
4384
|
}
|