@dxos/client-services 0.1.56-main.5ff23aa → 0.1.56-main.6293c6e
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-MM7EFAUT.mjs → chunk-BD23GURE.mjs} +428 -366
- package/dist/lib/browser/chunk-BD23GURE.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +20 -23
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +31 -46
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +443 -384
- 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 +443 -392
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/identity/identity-manager.d.ts +7 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +7 -3
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +3 -2
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +2 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +3 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +34 -33
- package/src/packlets/devices/devices-service.test.ts +2 -1
- package/src/packlets/identity/identity-manager.test.ts +15 -3
- package/src/packlets/identity/identity-manager.ts +27 -6
- package/src/packlets/identity/identity-service.test.ts +17 -2
- package/src/packlets/identity/identity-service.ts +23 -14
- package/src/packlets/identity/identity.test.ts +7 -6
- package/src/packlets/identity/identity.ts +8 -3
- package/src/packlets/invitations/device-invitation-protocol.test.ts +2 -1
- package/src/packlets/network/network-service.test.ts +2 -1
- package/src/packlets/services/client-rpc-server.ts +4 -4
- package/src/packlets/services/service-context.test.ts +59 -0
- package/src/packlets/services/service-context.ts +14 -6
- package/src/packlets/services/service-host.test.ts +6 -5
- package/src/packlets/services/service-host.ts +26 -10
- package/src/packlets/services/service-registry.test.ts +2 -1
- package/src/packlets/spaces/data-space.ts +17 -5
- package/src/packlets/spaces/spaces-service.test.ts +2 -1
- package/src/packlets/testing/test-builder.ts +1 -1
- package/src/packlets/vault/iframe-host-runtime.ts +2 -1
- package/src/packlets/vault/worker-runtime.ts +2 -1
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-MM7EFAUT.mjs.map +0 -7
|
@@ -70,7 +70,7 @@ var import_protocols = require("@dxos/protocols");
|
|
|
70
70
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
71
71
|
|
|
72
72
|
// packages/sdk/client-services/src/version.ts
|
|
73
|
-
var DXOS_VERSION = "0.1.56-main.
|
|
73
|
+
var DXOS_VERSION = "0.1.56-main.6293c6e";
|
|
74
74
|
|
|
75
75
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
76
76
|
var getPlatform = () => {
|
|
@@ -104,9 +104,8 @@ var getPlatform = () => {
|
|
|
104
104
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
105
105
|
var DEFAULT_TIMEOUT = 1e3;
|
|
106
106
|
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
107
|
-
var _a, _b, _c;
|
|
108
107
|
const diagnostics = {
|
|
109
|
-
created: new Date().toISOString(),
|
|
108
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
110
109
|
platform: getPlatform(),
|
|
111
110
|
client: {
|
|
112
111
|
version: DXOS_VERSION,
|
|
@@ -136,16 +135,16 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
136
135
|
spaceKey: identity.space.key,
|
|
137
136
|
profile: identity.profileDocument
|
|
138
137
|
};
|
|
139
|
-
const { devices } =
|
|
138
|
+
const { devices } = await (0, import_codec_protobuf2.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
|
|
140
139
|
timeout: DEFAULT_TIMEOUT
|
|
141
|
-
}).catch(() => void 0)
|
|
140
|
+
}).catch(() => void 0) ?? {};
|
|
142
141
|
diagnostics.devices = devices;
|
|
143
142
|
if (serviceContext.dataSpaceManager) {
|
|
144
|
-
diagnostics.spaces = await Promise.all(
|
|
143
|
+
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
145
144
|
}
|
|
146
|
-
const { feeds = [] } =
|
|
145
|
+
const { feeds = [] } = await (0, import_codec_protobuf2.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
147
146
|
timeout: DEFAULT_TIMEOUT
|
|
148
|
-
}).catch(() => void 0)
|
|
147
|
+
}).catch(() => void 0) ?? {};
|
|
149
148
|
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
150
149
|
feedKey,
|
|
151
150
|
bytes,
|
|
@@ -158,12 +157,9 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
158
157
|
var getProperties = (space) => {
|
|
159
158
|
let properties = {};
|
|
160
159
|
try {
|
|
161
|
-
const propertiesItem = space.dataPipeline.itemManager.items.find((item) =>
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
});
|
|
165
|
-
const state = propertiesItem == null ? void 0 : propertiesItem.state;
|
|
166
|
-
properties = state == null ? void 0 : state.data;
|
|
160
|
+
const propertiesItem = space.dataPipeline.itemManager.items.find((item) => item.modelMeta?.type === import_document_model.DocumentModel.meta.type && item.state?.type === "dxos.sdk.client.Properties");
|
|
161
|
+
const state = propertiesItem?.state;
|
|
162
|
+
properties = state?.data;
|
|
167
163
|
} catch (err) {
|
|
168
164
|
import_log.log.warn(err.message, void 0, {
|
|
169
165
|
F: __dxlog_file,
|
|
@@ -175,7 +171,6 @@ var getProperties = (space) => {
|
|
|
175
171
|
return properties;
|
|
176
172
|
};
|
|
177
173
|
var getSpaceStats = async (space) => {
|
|
178
|
-
var _a, _b, _c, _d, _e, _f;
|
|
179
174
|
const stats = {
|
|
180
175
|
key: space.key,
|
|
181
176
|
metrics: space.metrics,
|
|
@@ -183,18 +178,15 @@ var getSpaceStats = async (space) => {
|
|
|
183
178
|
...credential.subject.assertion,
|
|
184
179
|
id: credential.id
|
|
185
180
|
})),
|
|
186
|
-
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services.SpaceMember.PresenceState.ONLINE : import_services.SpaceMember.PresenceState.OFFLINE
|
|
196
|
-
};
|
|
197
|
-
}),
|
|
181
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
182
|
+
identity: {
|
|
183
|
+
identityKey: member.key,
|
|
184
|
+
profile: {
|
|
185
|
+
displayName: member.assertion.profile?.displayName
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services.SpaceMember.PresenceState.ONLINE : import_services.SpaceMember.PresenceState.OFFLINE
|
|
189
|
+
})),
|
|
198
190
|
pipeline: {
|
|
199
191
|
// TODO(burdon): Pick properties from credentials if needed.
|
|
200
192
|
// currentEpoch: space.dataPipeline.currentEpoch,
|
|
@@ -204,11 +196,11 @@ var getSpaceStats = async (space) => {
|
|
|
204
196
|
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
205
197
|
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
206
198
|
// TODO(burdon): Empty?
|
|
207
|
-
dataFeeds:
|
|
208
|
-
startDataTimeframe:
|
|
209
|
-
currentDataTimeframe:
|
|
210
|
-
targetDataTimeframe:
|
|
211
|
-
totalDataTimeframe:
|
|
199
|
+
dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
|
|
200
|
+
startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
|
|
201
|
+
currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
|
|
202
|
+
targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
|
|
203
|
+
totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
|
|
212
204
|
}
|
|
213
205
|
};
|
|
214
206
|
if (space.dataPipeline.itemManager) {
|
|
@@ -228,6 +220,7 @@ var getSpaceStats = async (space) => {
|
|
|
228
220
|
|
|
229
221
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
230
222
|
var import_async11 = require("@dxos/async");
|
|
223
|
+
var import_context8 = require("@dxos/context");
|
|
231
224
|
var import_credentials15 = require("@dxos/credentials");
|
|
232
225
|
var import_debug7 = require("@dxos/debug");
|
|
233
226
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
@@ -239,6 +232,8 @@ var import_log13 = require("@dxos/log");
|
|
|
239
232
|
var import_protocols9 = require("@dxos/protocols");
|
|
240
233
|
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
241
234
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
235
|
+
var import_tracing3 = require("@dxos/tracing");
|
|
236
|
+
var import_util6 = require("@dxos/util");
|
|
242
237
|
|
|
243
238
|
// packages/sdk/client-services/src/packlets/identity/authenticator.ts
|
|
244
239
|
var import_async = require("@dxos/async");
|
|
@@ -343,7 +338,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
343
338
|
return await trigger.wait({
|
|
344
339
|
timeout: this._params.authTimeout
|
|
345
340
|
});
|
|
346
|
-
} catch
|
|
341
|
+
} catch {
|
|
347
342
|
return false;
|
|
348
343
|
} finally {
|
|
349
344
|
clear();
|
|
@@ -365,8 +360,19 @@ var import_feed_store = require("@dxos/feed-store");
|
|
|
365
360
|
var import_invariant2 = require("@dxos/invariant");
|
|
366
361
|
var import_log3 = require("@dxos/log");
|
|
367
362
|
var import_credentials5 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
363
|
+
var import_tracing = require("@dxos/tracing");
|
|
364
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
365
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
366
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
367
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
368
|
+
else
|
|
369
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
370
|
+
if (d = decorators[i])
|
|
371
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
372
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
373
|
+
}
|
|
368
374
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
369
|
-
var Identity = class {
|
|
375
|
+
var Identity = class Identity2 {
|
|
370
376
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
371
377
|
this.stateUpdate = new import_async2.Event();
|
|
372
378
|
this.space = space;
|
|
@@ -392,12 +398,12 @@ var Identity = class {
|
|
|
392
398
|
get authorizedDeviceKeys() {
|
|
393
399
|
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
394
400
|
}
|
|
395
|
-
async open() {
|
|
401
|
+
async open(ctx) {
|
|
396
402
|
await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
|
|
397
403
|
await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
|
|
398
|
-
await this.space.open();
|
|
404
|
+
await this.space.open(ctx);
|
|
399
405
|
}
|
|
400
|
-
async close() {
|
|
406
|
+
async close(ctx) {
|
|
401
407
|
await this.authVerifier.close();
|
|
402
408
|
await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
|
|
403
409
|
await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
|
|
@@ -428,11 +434,10 @@ var Identity = class {
|
|
|
428
434
|
return this._deviceStateMachine.deviceCredentialChain;
|
|
429
435
|
}
|
|
430
436
|
getAdmissionCredentials() {
|
|
431
|
-
var _a, _b;
|
|
432
437
|
return {
|
|
433
438
|
deviceKey: this.deviceKey,
|
|
434
|
-
controlFeedKey:
|
|
435
|
-
dataFeedKey:
|
|
439
|
+
controlFeedKey: this.space.controlFeedKey ?? (0, import_debug2.failUndefined)(),
|
|
440
|
+
dataFeedKey: this.space.dataFeedKey ?? (0, import_debug2.failUndefined)()
|
|
436
441
|
};
|
|
437
442
|
}
|
|
438
443
|
/**
|
|
@@ -442,7 +447,7 @@ var Identity = class {
|
|
|
442
447
|
getIdentityCredentialSigner() {
|
|
443
448
|
(0, import_invariant2.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
|
|
444
449
|
F: __dxlog_file3,
|
|
445
|
-
L:
|
|
450
|
+
L: 139,
|
|
446
451
|
S: this,
|
|
447
452
|
A: [
|
|
448
453
|
"this._deviceStateMachine.deviceCredentialChain",
|
|
@@ -466,7 +471,7 @@ var Identity = class {
|
|
|
466
471
|
dataFeedKey
|
|
467
472
|
}, {
|
|
468
473
|
F: __dxlog_file3,
|
|
469
|
-
L:
|
|
474
|
+
L: 155,
|
|
470
475
|
S: this,
|
|
471
476
|
C: (f, a) => f(...a)
|
|
472
477
|
});
|
|
@@ -507,18 +512,40 @@ var Identity = class {
|
|
|
507
512
|
})));
|
|
508
513
|
}
|
|
509
514
|
};
|
|
515
|
+
_ts_decorate([
|
|
516
|
+
import_tracing.trace.span()
|
|
517
|
+
], Identity.prototype, "open", null);
|
|
518
|
+
_ts_decorate([
|
|
519
|
+
import_tracing.trace.span()
|
|
520
|
+
], Identity.prototype, "close", null);
|
|
521
|
+
Identity = _ts_decorate([
|
|
522
|
+
import_tracing.trace.resource()
|
|
523
|
+
], Identity);
|
|
510
524
|
|
|
511
525
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
512
526
|
var import_async3 = require("@dxos/async");
|
|
527
|
+
var import_context2 = require("@dxos/context");
|
|
513
528
|
var import_credentials6 = require("@dxos/credentials");
|
|
514
529
|
var import_invariant3 = require("@dxos/invariant");
|
|
515
530
|
var import_keys2 = require("@dxos/keys");
|
|
516
531
|
var import_log4 = require("@dxos/log");
|
|
517
532
|
var import_protocols3 = require("@dxos/protocols");
|
|
518
533
|
var import_credentials7 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
534
|
+
var import_timeframe = require("@dxos/timeframe");
|
|
535
|
+
var import_tracing2 = require("@dxos/tracing");
|
|
519
536
|
var import_util = require("@dxos/util");
|
|
537
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
538
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
539
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
540
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
541
|
+
else
|
|
542
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
543
|
+
if (d = decorators[i])
|
|
544
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
545
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
546
|
+
}
|
|
520
547
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
521
|
-
var IdentityManager = class {
|
|
548
|
+
var IdentityManager = class IdentityManager2 {
|
|
522
549
|
// TODO(burdon): IdentityManagerParams.
|
|
523
550
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
524
551
|
constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
|
|
@@ -531,14 +558,13 @@ var IdentityManager = class {
|
|
|
531
558
|
get identity() {
|
|
532
559
|
return this._identity;
|
|
533
560
|
}
|
|
534
|
-
async open() {
|
|
535
|
-
var _a;
|
|
561
|
+
async open(ctx) {
|
|
536
562
|
const traceId = import_keys2.PublicKey.random().toHex();
|
|
537
563
|
import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.begin({
|
|
538
564
|
id: traceId
|
|
539
565
|
}), {
|
|
540
566
|
F: __dxlog_file4,
|
|
541
|
-
L:
|
|
567
|
+
L: 73,
|
|
542
568
|
S: this,
|
|
543
569
|
C: (f, a) => f(...a)
|
|
544
570
|
});
|
|
@@ -548,20 +574,20 @@ var IdentityManager = class {
|
|
|
548
574
|
identityRecord
|
|
549
575
|
}, {
|
|
550
576
|
F: __dxlog_file4,
|
|
551
|
-
L:
|
|
577
|
+
L: 77,
|
|
552
578
|
S: this,
|
|
553
579
|
C: (f, a) => f(...a)
|
|
554
580
|
});
|
|
555
581
|
if (identityRecord) {
|
|
556
582
|
this._identity = await this._constructIdentity(identityRecord);
|
|
557
|
-
await this._identity.open();
|
|
583
|
+
await this._identity.open(ctx);
|
|
558
584
|
await this._identity.ready();
|
|
559
585
|
import_log4.log.trace("dxos.halo.identity", {
|
|
560
586
|
identityKey: identityRecord.identityKey,
|
|
561
|
-
displayName:
|
|
587
|
+
displayName: this._identity.profileDocument?.displayName
|
|
562
588
|
}, {
|
|
563
589
|
F: __dxlog_file4,
|
|
564
|
-
L:
|
|
590
|
+
L: 82,
|
|
565
591
|
S: this,
|
|
566
592
|
C: (f, a) => f(...a)
|
|
567
593
|
});
|
|
@@ -571,20 +597,18 @@ var IdentityManager = class {
|
|
|
571
597
|
id: traceId
|
|
572
598
|
}), {
|
|
573
599
|
F: __dxlog_file4,
|
|
574
|
-
L:
|
|
600
|
+
L: 88,
|
|
575
601
|
S: this,
|
|
576
602
|
C: (f, a) => f(...a)
|
|
577
603
|
});
|
|
578
604
|
}
|
|
579
605
|
async close() {
|
|
580
|
-
|
|
581
|
-
await ((_a = this._identity) == null ? void 0 : _a.close());
|
|
606
|
+
await this._identity?.close(new import_context2.Context());
|
|
582
607
|
}
|
|
583
608
|
async createIdentity({ displayName } = {}) {
|
|
584
|
-
var _a;
|
|
585
609
|
(0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
|
|
586
610
|
F: __dxlog_file4,
|
|
587
|
-
L:
|
|
611
|
+
L: 96,
|
|
588
612
|
S: this,
|
|
589
613
|
A: [
|
|
590
614
|
"!this._identity",
|
|
@@ -593,7 +617,7 @@ var IdentityManager = class {
|
|
|
593
617
|
});
|
|
594
618
|
(0, import_log4.log)("creating identity...", void 0, {
|
|
595
619
|
F: __dxlog_file4,
|
|
596
|
-
L:
|
|
620
|
+
L: 97,
|
|
597
621
|
S: this,
|
|
598
622
|
C: (f, a) => f(...a)
|
|
599
623
|
});
|
|
@@ -609,12 +633,12 @@ var IdentityManager = class {
|
|
|
609
633
|
}
|
|
610
634
|
};
|
|
611
635
|
const identity = await this._constructIdentity(identityRecord);
|
|
612
|
-
await identity.open();
|
|
636
|
+
await identity.open(new import_context2.Context());
|
|
613
637
|
{
|
|
614
638
|
const generator = new import_credentials6.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
615
639
|
(0, import_invariant3.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
|
|
616
640
|
F: __dxlog_file4,
|
|
617
|
-
L:
|
|
641
|
+
L: 116,
|
|
618
642
|
S: this,
|
|
619
643
|
A: [
|
|
620
644
|
"identityRecord.haloSpace.genesisFeedKey",
|
|
@@ -623,7 +647,7 @@ var IdentityManager = class {
|
|
|
623
647
|
});
|
|
624
648
|
(0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
|
|
625
649
|
F: __dxlog_file4,
|
|
626
|
-
L:
|
|
650
|
+
L: 117,
|
|
627
651
|
S: this,
|
|
628
652
|
A: [
|
|
629
653
|
"identityRecord.haloSpace.dataFeedKey",
|
|
@@ -655,10 +679,10 @@ var IdentityManager = class {
|
|
|
655
679
|
await this._identity.ready();
|
|
656
680
|
import_log4.log.trace("dxos.halo.identity", {
|
|
657
681
|
identityKey: identityRecord.identityKey,
|
|
658
|
-
displayName:
|
|
682
|
+
displayName: this._identity.profileDocument?.displayName
|
|
659
683
|
}, {
|
|
660
684
|
F: __dxlog_file4,
|
|
661
|
-
L:
|
|
685
|
+
L: 152,
|
|
662
686
|
S: this,
|
|
663
687
|
C: (f, a) => f(...a)
|
|
664
688
|
});
|
|
@@ -668,7 +692,7 @@ var IdentityManager = class {
|
|
|
668
692
|
deviceKey: identity.deviceKey
|
|
669
693
|
}, {
|
|
670
694
|
F: __dxlog_file4,
|
|
671
|
-
L:
|
|
695
|
+
L: 158,
|
|
672
696
|
S: this,
|
|
673
697
|
C: (f, a) => f(...a)
|
|
674
698
|
});
|
|
@@ -678,18 +702,17 @@ var IdentityManager = class {
|
|
|
678
702
|
* Accept an existing identity. Expects it's device key to be authorized (now or later).
|
|
679
703
|
*/
|
|
680
704
|
async acceptIdentity(params) {
|
|
681
|
-
var _a;
|
|
682
705
|
(0, import_log4.log)("accepting identity", {
|
|
683
706
|
params
|
|
684
707
|
}, {
|
|
685
708
|
F: __dxlog_file4,
|
|
686
|
-
L:
|
|
709
|
+
L: 166,
|
|
687
710
|
S: this,
|
|
688
711
|
C: (f, a) => f(...a)
|
|
689
712
|
});
|
|
690
713
|
(0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
|
|
691
714
|
F: __dxlog_file4,
|
|
692
|
-
L:
|
|
715
|
+
L: 167,
|
|
693
716
|
S: this,
|
|
694
717
|
A: [
|
|
695
718
|
"!this._identity",
|
|
@@ -708,16 +731,16 @@ var IdentityManager = class {
|
|
|
708
731
|
}
|
|
709
732
|
};
|
|
710
733
|
const identity = await this._constructIdentity(identityRecord);
|
|
711
|
-
await identity.open();
|
|
734
|
+
await identity.open(new import_context2.Context());
|
|
712
735
|
this._identity = identity;
|
|
713
736
|
await this._metadataStore.setIdentityRecord(identityRecord);
|
|
714
737
|
await this._identity.ready();
|
|
715
738
|
import_log4.log.trace("dxos.halo.identity", {
|
|
716
739
|
identityKey: identityRecord.identityKey,
|
|
717
|
-
displayName:
|
|
740
|
+
displayName: this._identity.profileDocument?.displayName
|
|
718
741
|
}, {
|
|
719
742
|
F: __dxlog_file4,
|
|
720
|
-
L:
|
|
743
|
+
L: 186,
|
|
721
744
|
S: this,
|
|
722
745
|
C: (f, a) => f(...a)
|
|
723
746
|
});
|
|
@@ -727,16 +750,48 @@ var IdentityManager = class {
|
|
|
727
750
|
deviceKey: identity.deviceKey
|
|
728
751
|
}, {
|
|
729
752
|
F: __dxlog_file4,
|
|
730
|
-
L:
|
|
753
|
+
L: 192,
|
|
731
754
|
S: this,
|
|
732
755
|
C: (f, a) => f(...a)
|
|
733
756
|
});
|
|
734
757
|
return identity;
|
|
735
758
|
}
|
|
759
|
+
/**
|
|
760
|
+
* Update the profile document of an existing identity.
|
|
761
|
+
*/
|
|
762
|
+
async updateProfile(profile) {
|
|
763
|
+
(0, import_invariant3.invariant)(this._identity, "Identity not initialized.", {
|
|
764
|
+
F: __dxlog_file4,
|
|
765
|
+
L: 200,
|
|
766
|
+
S: this,
|
|
767
|
+
A: [
|
|
768
|
+
"this._identity",
|
|
769
|
+
"'Identity not initialized.'"
|
|
770
|
+
]
|
|
771
|
+
});
|
|
772
|
+
const credential = await this._identity.getIdentityCredentialSigner().createCredential({
|
|
773
|
+
subject: this._identity.identityKey,
|
|
774
|
+
assertion: {
|
|
775
|
+
"@type": "dxos.halo.credentials.IdentityProfile",
|
|
776
|
+
profile
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
const receipt = await this._identity.controlPipeline.writer.write({
|
|
780
|
+
credential: {
|
|
781
|
+
credential
|
|
782
|
+
}
|
|
783
|
+
});
|
|
784
|
+
await this._identity.controlPipeline.state.waitUntilTimeframe(new import_timeframe.Timeframe([
|
|
785
|
+
[
|
|
786
|
+
receipt.feedKey,
|
|
787
|
+
receipt.seq
|
|
788
|
+
]
|
|
789
|
+
]));
|
|
790
|
+
}
|
|
736
791
|
async _constructIdentity(identityRecord) {
|
|
737
792
|
(0, import_invariant3.invariant)(!this._identity, void 0, {
|
|
738
793
|
F: __dxlog_file4,
|
|
739
|
-
L:
|
|
794
|
+
L: 214,
|
|
740
795
|
S: this,
|
|
741
796
|
A: [
|
|
742
797
|
"!this._identity",
|
|
@@ -747,13 +802,13 @@ var IdentityManager = class {
|
|
|
747
802
|
identityRecord
|
|
748
803
|
}, {
|
|
749
804
|
F: __dxlog_file4,
|
|
750
|
-
L:
|
|
805
|
+
L: 215,
|
|
751
806
|
S: this,
|
|
752
807
|
C: (f, a) => f(...a)
|
|
753
808
|
});
|
|
754
809
|
(0, import_invariant3.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
|
|
755
810
|
F: __dxlog_file4,
|
|
756
|
-
L:
|
|
811
|
+
L: 218,
|
|
757
812
|
S: this,
|
|
758
813
|
A: [
|
|
759
814
|
"identityRecord.haloSpace.controlFeedKey",
|
|
@@ -765,7 +820,7 @@ var IdentityManager = class {
|
|
|
765
820
|
});
|
|
766
821
|
(0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
|
|
767
822
|
F: __dxlog_file4,
|
|
768
|
-
L:
|
|
823
|
+
L: 222,
|
|
769
824
|
S: this,
|
|
770
825
|
A: [
|
|
771
826
|
"identityRecord.haloSpace.dataFeedKey",
|
|
@@ -797,7 +852,7 @@ var IdentityManager = class {
|
|
|
797
852
|
identityKey: identityRecord.identityKey
|
|
798
853
|
}, {
|
|
799
854
|
F: __dxlog_file4,
|
|
800
|
-
L:
|
|
855
|
+
L: 246,
|
|
801
856
|
S: this,
|
|
802
857
|
C: (f, a) => f(...a)
|
|
803
858
|
});
|
|
@@ -818,7 +873,7 @@ var IdentityManager = class {
|
|
|
818
873
|
onAuthFailure: () => {
|
|
819
874
|
import_log4.log.warn("auth failure", void 0, {
|
|
820
875
|
F: __dxlog_file4,
|
|
821
|
-
L:
|
|
876
|
+
L: 265,
|
|
822
877
|
S: this,
|
|
823
878
|
C: (f, a) => f(...a)
|
|
824
879
|
});
|
|
@@ -827,6 +882,12 @@ var IdentityManager = class {
|
|
|
827
882
|
});
|
|
828
883
|
}
|
|
829
884
|
};
|
|
885
|
+
_ts_decorate2([
|
|
886
|
+
import_tracing2.trace.span()
|
|
887
|
+
], IdentityManager.prototype, "open", null);
|
|
888
|
+
IdentityManager = _ts_decorate2([
|
|
889
|
+
import_tracing2.trace.resource()
|
|
890
|
+
], IdentityManager);
|
|
830
891
|
|
|
831
892
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
832
893
|
var import_codec_protobuf3 = require("@dxos/codec-protobuf");
|
|
@@ -835,12 +896,13 @@ var import_debug3 = require("@dxos/debug");
|
|
|
835
896
|
var import_invariant4 = require("@dxos/invariant");
|
|
836
897
|
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
837
898
|
var IdentityServiceImpl = class {
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
this.
|
|
899
|
+
constructor(_createIdentity, _identityManager, _keyring) {
|
|
900
|
+
this._createIdentity = _createIdentity;
|
|
901
|
+
this._identityManager = _identityManager;
|
|
902
|
+
this._keyring = _keyring;
|
|
841
903
|
}
|
|
842
904
|
async createIdentity(request) {
|
|
843
|
-
await this.
|
|
905
|
+
await this._createIdentity(request);
|
|
844
906
|
return this._getIdentity();
|
|
845
907
|
}
|
|
846
908
|
async recoverIdentity(request) {
|
|
@@ -852,34 +914,47 @@ var IdentityServiceImpl = class {
|
|
|
852
914
|
identity: this._getIdentity()
|
|
853
915
|
});
|
|
854
916
|
emitNext();
|
|
855
|
-
return this.
|
|
917
|
+
return this._identityManager.stateUpdate.on(emitNext);
|
|
856
918
|
});
|
|
857
919
|
}
|
|
858
920
|
_getIdentity() {
|
|
859
|
-
if (!this.
|
|
921
|
+
if (!this._identityManager.identity) {
|
|
860
922
|
return void 0;
|
|
861
923
|
}
|
|
862
924
|
return {
|
|
863
|
-
identityKey: this.
|
|
864
|
-
spaceKey: this.
|
|
865
|
-
profile: this.
|
|
925
|
+
identityKey: this._identityManager.identity.identityKey,
|
|
926
|
+
spaceKey: this._identityManager.identity.space.key,
|
|
927
|
+
profile: this._identityManager.identity.profileDocument
|
|
866
928
|
};
|
|
867
929
|
}
|
|
930
|
+
async updateProfile(profile) {
|
|
931
|
+
(0, import_invariant4.invariant)(this._identityManager.identity, "Identity not initialized.", {
|
|
932
|
+
F: __dxlog_file5,
|
|
933
|
+
L: 59,
|
|
934
|
+
S: this,
|
|
935
|
+
A: [
|
|
936
|
+
"this._identityManager.identity",
|
|
937
|
+
"'Identity not initialized.'"
|
|
938
|
+
]
|
|
939
|
+
});
|
|
940
|
+
await this._identityManager.updateProfile(profile);
|
|
941
|
+
return this._getIdentity();
|
|
942
|
+
}
|
|
868
943
|
async signPresentation({ presentation, nonce }) {
|
|
869
|
-
(0, import_invariant4.invariant)(this.
|
|
944
|
+
(0, import_invariant4.invariant)(this._identityManager.identity, "Identity not initialized.", {
|
|
870
945
|
F: __dxlog_file5,
|
|
871
|
-
L:
|
|
946
|
+
L: 65,
|
|
872
947
|
S: this,
|
|
873
948
|
A: [
|
|
874
|
-
"this.
|
|
949
|
+
"this._identityManager.identity",
|
|
875
950
|
"'Identity not initialized.'"
|
|
876
951
|
]
|
|
877
952
|
});
|
|
878
953
|
return await (0, import_credentials8.signPresentation)({
|
|
879
954
|
presentation,
|
|
880
|
-
signer: this.
|
|
881
|
-
signerKey: this.
|
|
882
|
-
chain: this.
|
|
955
|
+
signer: this._keyring,
|
|
956
|
+
signerKey: this._identityManager.identity.deviceKey,
|
|
957
|
+
chain: this._identityManager.identity.deviceCredentialChain,
|
|
883
958
|
nonce
|
|
884
959
|
});
|
|
885
960
|
}
|
|
@@ -978,7 +1053,7 @@ var DeviceInvitationProtocol = class {
|
|
|
978
1053
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
979
1054
|
var import_async5 = require("@dxos/async");
|
|
980
1055
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
981
|
-
var
|
|
1056
|
+
var import_context4 = require("@dxos/context");
|
|
982
1057
|
var import_credentials9 = require("@dxos/credentials");
|
|
983
1058
|
var import_errors2 = require("@dxos/errors");
|
|
984
1059
|
var import_invariant7 = require("@dxos/invariant");
|
|
@@ -991,7 +1066,7 @@ var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations")
|
|
|
991
1066
|
|
|
992
1067
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
993
1068
|
var import_async4 = require("@dxos/async");
|
|
994
|
-
var
|
|
1069
|
+
var import_context3 = require("@dxos/context");
|
|
995
1070
|
var import_errors = require("@dxos/errors");
|
|
996
1071
|
var import_invariant6 = require("@dxos/invariant");
|
|
997
1072
|
var import_keys3 = require("@dxos/keys");
|
|
@@ -1014,7 +1089,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1014
1089
|
}
|
|
1015
1090
|
});
|
|
1016
1091
|
this._callbacks = _callbacks;
|
|
1017
|
-
this._ctx = new
|
|
1092
|
+
this._ctx = new import_context3.Context();
|
|
1018
1093
|
this._remoteOptionsTrigger = new import_async4.Trigger();
|
|
1019
1094
|
this.invitation = void 0;
|
|
1020
1095
|
this.guestProfile = void 0;
|
|
@@ -1215,16 +1290,15 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1215
1290
|
};
|
|
1216
1291
|
}
|
|
1217
1292
|
async onOpen(context) {
|
|
1218
|
-
var _a;
|
|
1219
1293
|
await super.onOpen(context);
|
|
1220
1294
|
try {
|
|
1221
1295
|
await this.rpc.InvitationHostService.options({
|
|
1222
1296
|
role: import_invitations.Options.Role.HOST
|
|
1223
1297
|
});
|
|
1224
|
-
await (0,
|
|
1298
|
+
await (0, import_context3.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1225
1299
|
timeout: OPTIONS_TIMEOUT
|
|
1226
1300
|
}));
|
|
1227
|
-
if (
|
|
1301
|
+
if (this._remoteOptions?.role !== import_invitations.Options.Role.GUEST) {
|
|
1228
1302
|
throw new import_errors.InvalidInvitationExtensionRoleError(void 0, {
|
|
1229
1303
|
expected: import_invitations.Options.Role.GUEST,
|
|
1230
1304
|
remoteOptions: this._remoteOptions
|
|
@@ -1250,7 +1324,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1250
1324
|
}
|
|
1251
1325
|
});
|
|
1252
1326
|
this._callbacks = _callbacks;
|
|
1253
|
-
this._ctx = new
|
|
1327
|
+
this._ctx = new import_context3.Context();
|
|
1254
1328
|
this._remoteOptionsTrigger = new import_async4.Trigger();
|
|
1255
1329
|
}
|
|
1256
1330
|
async getHandlers() {
|
|
@@ -1282,7 +1356,6 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1282
1356
|
};
|
|
1283
1357
|
}
|
|
1284
1358
|
async onOpen(context) {
|
|
1285
|
-
var _a;
|
|
1286
1359
|
await super.onOpen(context);
|
|
1287
1360
|
try {
|
|
1288
1361
|
(0, import_log5.log)("begin options", void 0, {
|
|
@@ -1291,10 +1364,10 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1291
1364
|
S: this,
|
|
1292
1365
|
C: (f, a) => f(...a)
|
|
1293
1366
|
});
|
|
1294
|
-
await (0,
|
|
1367
|
+
await (0, import_context3.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
|
|
1295
1368
|
role: import_invitations.Options.Role.GUEST
|
|
1296
1369
|
}));
|
|
1297
|
-
await (0,
|
|
1370
|
+
await (0, import_context3.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1298
1371
|
timeout: OPTIONS_TIMEOUT
|
|
1299
1372
|
}));
|
|
1300
1373
|
(0, import_log5.log)("end options", void 0, {
|
|
@@ -1303,7 +1376,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1303
1376
|
S: this,
|
|
1304
1377
|
C: (f, a) => f(...a)
|
|
1305
1378
|
});
|
|
1306
|
-
if (
|
|
1379
|
+
if (this._remoteOptions?.role !== import_invitations.Options.Role.HOST) {
|
|
1307
1380
|
throw new import_errors.InvalidInvitationExtensionRoleError(void 0, {
|
|
1308
1381
|
expected: import_invitations.Options.Role.HOST,
|
|
1309
1382
|
remoteOptions: this._remoteOptions
|
|
@@ -1342,9 +1415,8 @@ var InvitationsHandler = class {
|
|
|
1342
1415
|
this._networkManager = _networkManager;
|
|
1343
1416
|
}
|
|
1344
1417
|
createInvitation(protocol, options) {
|
|
1345
|
-
|
|
1346
|
-
const
|
|
1347
|
-
const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services4.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials9.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0;
|
|
1418
|
+
const { invitationId = import_keys4.PublicKey.random().toHex(), type = import_services4.Invitation.Type.INTERACTIVE, authMethod = import_services4.Invitation.AuthMethod.SHARED_SECRET, state = import_services4.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys4.PublicKey.random() } = options ?? {};
|
|
1419
|
+
const authCode = options?.authCode ?? (authMethod === import_services4.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials9.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1348
1420
|
(0, import_invariant7.invariant)(protocol, void 0, {
|
|
1349
1421
|
F: __dxlog_file8,
|
|
1350
1422
|
L: 76,
|
|
@@ -1365,7 +1437,7 @@ var InvitationsHandler = class {
|
|
|
1365
1437
|
...protocol.getInvitationContext()
|
|
1366
1438
|
};
|
|
1367
1439
|
const stream = new import_async5.PushStream();
|
|
1368
|
-
const ctx = new
|
|
1440
|
+
const ctx = new import_context4.Context({
|
|
1369
1441
|
onError: (err) => {
|
|
1370
1442
|
void ctx.dispose();
|
|
1371
1443
|
stream.error(err);
|
|
@@ -1397,9 +1469,8 @@ var InvitationsHandler = class {
|
|
|
1397
1469
|
return invitation;
|
|
1398
1470
|
},
|
|
1399
1471
|
admit: async (admissionRequest) => {
|
|
1400
|
-
var _a2, _b, _c;
|
|
1401
1472
|
try {
|
|
1402
|
-
const deviceKey =
|
|
1473
|
+
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1403
1474
|
(0, import_invariant7.invariant)(deviceKey, void 0, {
|
|
1404
1475
|
F: __dxlog_file8,
|
|
1405
1476
|
L: 119,
|
|
@@ -1596,7 +1667,7 @@ var InvitationsHandler = class {
|
|
|
1596
1667
|
...newData
|
|
1597
1668
|
});
|
|
1598
1669
|
};
|
|
1599
|
-
const ctx = new
|
|
1670
|
+
const ctx = new import_context4.Context({
|
|
1600
1671
|
onError: (err) => {
|
|
1601
1672
|
if (err instanceof import_async5.TimeoutError) {
|
|
1602
1673
|
(0, import_log6.log)("timeout", {
|
|
@@ -2098,7 +2169,6 @@ var SpaceInvitationProtocol = class {
|
|
|
2098
2169
|
};
|
|
2099
2170
|
}
|
|
2100
2171
|
async admit(request, guestProfile) {
|
|
2101
|
-
var _a;
|
|
2102
2172
|
(0, import_invariant9.invariant)(this._spaceKey, void 0, {
|
|
2103
2173
|
F: __dxlog_file10,
|
|
2104
2174
|
L: 42,
|
|
@@ -2162,7 +2232,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2162
2232
|
space: {
|
|
2163
2233
|
credential: spaceMemberCredential,
|
|
2164
2234
|
controlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2165
|
-
dataTimeframe:
|
|
2235
|
+
dataTimeframe: space.dataPipeline.pipelineState?.timeframe
|
|
2166
2236
|
}
|
|
2167
2237
|
};
|
|
2168
2238
|
}
|
|
@@ -2228,7 +2298,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2228
2298
|
|
|
2229
2299
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2230
2300
|
var import_async9 = require("@dxos/async");
|
|
2231
|
-
var
|
|
2301
|
+
var import_context7 = require("@dxos/context");
|
|
2232
2302
|
var import_credentials14 = require("@dxos/credentials");
|
|
2233
2303
|
var import_invariant11 = require("@dxos/invariant");
|
|
2234
2304
|
var import_keys7 = require("@dxos/keys");
|
|
@@ -2241,7 +2311,7 @@ var import_util4 = require("@dxos/util");
|
|
|
2241
2311
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2242
2312
|
var import_async8 = require("@dxos/async");
|
|
2243
2313
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
2244
|
-
var
|
|
2314
|
+
var import_context6 = require("@dxos/context");
|
|
2245
2315
|
var import_debug4 = require("@dxos/debug");
|
|
2246
2316
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
2247
2317
|
var import_errors3 = require("@dxos/errors");
|
|
@@ -2249,12 +2319,12 @@ var import_keys6 = require("@dxos/keys");
|
|
|
2249
2319
|
var import_log10 = require("@dxos/log");
|
|
2250
2320
|
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2251
2321
|
var import_credentials11 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2252
|
-
var
|
|
2322
|
+
var import_timeframe2 = require("@dxos/timeframe");
|
|
2253
2323
|
var import_util3 = require("@dxos/util");
|
|
2254
2324
|
|
|
2255
2325
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2256
2326
|
var import_async7 = require("@dxos/async");
|
|
2257
|
-
var
|
|
2327
|
+
var import_context5 = require("@dxos/context");
|
|
2258
2328
|
var import_invariant10 = require("@dxos/invariant");
|
|
2259
2329
|
var import_keys5 = require("@dxos/keys");
|
|
2260
2330
|
var import_log9 = require("@dxos/log");
|
|
@@ -2268,7 +2338,7 @@ var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
|
2268
2338
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
2269
2339
|
var NotarizationPlugin = class {
|
|
2270
2340
|
constructor() {
|
|
2271
|
-
this._ctx = new
|
|
2341
|
+
this._ctx = new import_context5.Context();
|
|
2272
2342
|
this._extensionOpened = new import_async7.Event();
|
|
2273
2343
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2274
2344
|
this._processedCredentials = new import_util2.ComplexSet(import_keys5.PublicKey.hash);
|
|
@@ -2318,7 +2388,7 @@ var NotarizationPlugin = class {
|
|
|
2318
2388
|
errors.throw(err);
|
|
2319
2389
|
}
|
|
2320
2390
|
});
|
|
2321
|
-
opCtx
|
|
2391
|
+
opCtx?.onDispose(() => ctx.dispose());
|
|
2322
2392
|
if (timeout !== 0) {
|
|
2323
2393
|
(0, import_async7.scheduleTask)(ctx, () => {
|
|
2324
2394
|
import_log9.log.warn("Notarization timeout", {
|
|
@@ -2393,7 +2463,7 @@ var NotarizationPlugin = class {
|
|
|
2393
2463
|
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
2394
2464
|
try {
|
|
2395
2465
|
await Promise.race([
|
|
2396
|
-
(0,
|
|
2466
|
+
(0, import_context5.rejectOnDispose)(ctx),
|
|
2397
2467
|
allNotarized,
|
|
2398
2468
|
errors.wait()
|
|
2399
2469
|
]);
|
|
@@ -2411,11 +2481,10 @@ var NotarizationPlugin = class {
|
|
|
2411
2481
|
* Called with credentials arriving from the control pipeline.
|
|
2412
2482
|
*/
|
|
2413
2483
|
async processCredential(credential) {
|
|
2414
|
-
var _a;
|
|
2415
2484
|
if (!credential.id) {
|
|
2416
2485
|
return;
|
|
2417
2486
|
}
|
|
2418
|
-
|
|
2487
|
+
this._processCredentialsTriggers.get(credential.id)?.wake();
|
|
2419
2488
|
this._processedCredentials.add(credential.id);
|
|
2420
2489
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2421
2490
|
}
|
|
@@ -2441,11 +2510,10 @@ var NotarizationPlugin = class {
|
|
|
2441
2510
|
* Requests from other peers to notarize credentials.
|
|
2442
2511
|
*/
|
|
2443
2512
|
async _onNotarize(request) {
|
|
2444
|
-
var _a;
|
|
2445
2513
|
if (!this._writer) {
|
|
2446
2514
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2447
2515
|
}
|
|
2448
|
-
for (const credential of
|
|
2516
|
+
for (const credential of request.credentials ?? []) {
|
|
2449
2517
|
(0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
|
|
2450
2518
|
F: __dxlog_file11,
|
|
2451
2519
|
L: 200,
|
|
@@ -2523,7 +2591,7 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
2523
2591
|
};
|
|
2524
2592
|
|
|
2525
2593
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2526
|
-
function
|
|
2594
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
2527
2595
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2528
2596
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2529
2597
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2534,9 +2602,10 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
2534
2602
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2535
2603
|
}
|
|
2536
2604
|
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2605
|
+
var ENABLE_FEED_PURGE = false;
|
|
2537
2606
|
var DataSpace = class DataSpace2 {
|
|
2538
2607
|
constructor(params) {
|
|
2539
|
-
this._ctx = new
|
|
2608
|
+
this._ctx = new import_context6.Context();
|
|
2540
2609
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
2541
2610
|
this._state = import_services7.SpaceState.CLOSED;
|
|
2542
2611
|
/**
|
|
@@ -2545,7 +2614,6 @@ var DataSpace = class DataSpace2 {
|
|
|
2545
2614
|
this.error = void 0;
|
|
2546
2615
|
this.stateUpdate = new import_async8.Event();
|
|
2547
2616
|
this.metrics = {};
|
|
2548
|
-
var _a;
|
|
2549
2617
|
this._inner = params.inner;
|
|
2550
2618
|
this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
|
|
2551
2619
|
this._gossip = params.gossip;
|
|
@@ -2554,7 +2622,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2554
2622
|
this._feedStore = params.feedStore;
|
|
2555
2623
|
this._metadataStore = params.metadataStore;
|
|
2556
2624
|
this._signingContext = params.signingContext;
|
|
2557
|
-
this._callbacks =
|
|
2625
|
+
this._callbacks = params.callbacks ?? {};
|
|
2558
2626
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
2559
2627
|
trustedKeysProvider: () => new import_util3.ComplexSet(import_keys6.PublicKey.hash, Array.from(this._inner.spaceState.members.keys())),
|
|
2560
2628
|
update: this._inner.stateUpdate,
|
|
@@ -2594,21 +2662,20 @@ var DataSpace = class DataSpace2 {
|
|
|
2594
2662
|
async _open() {
|
|
2595
2663
|
await this._notarizationPlugin.open();
|
|
2596
2664
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
2597
|
-
await this._inner.open();
|
|
2665
|
+
await this._inner.open(new import_context6.Context());
|
|
2598
2666
|
this._state = import_services7.SpaceState.CONTROL_ONLY;
|
|
2599
2667
|
this.stateUpdate.emit();
|
|
2600
2668
|
this.metrics = {};
|
|
2601
|
-
this.metrics.open = new Date();
|
|
2669
|
+
this.metrics.open = /* @__PURE__ */ new Date();
|
|
2602
2670
|
}
|
|
2603
2671
|
async close() {
|
|
2604
2672
|
await this._close();
|
|
2605
2673
|
}
|
|
2606
2674
|
async _close() {
|
|
2607
|
-
|
|
2608
|
-
await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
|
|
2675
|
+
await this._callbacks.beforeClose?.();
|
|
2609
2676
|
this._state = import_services7.SpaceState.CLOSED;
|
|
2610
2677
|
await this._ctx.dispose();
|
|
2611
|
-
this._ctx = new
|
|
2678
|
+
this._ctx = new import_context6.Context();
|
|
2612
2679
|
await this.authVerifier.close();
|
|
2613
2680
|
await this._inner.close();
|
|
2614
2681
|
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
@@ -2627,13 +2694,13 @@ var DataSpace = class DataSpace2 {
|
|
|
2627
2694
|
initializeDataPipelineAsync() {
|
|
2628
2695
|
(0, import_async8.scheduleTask)(this._ctx, async () => {
|
|
2629
2696
|
try {
|
|
2630
|
-
this.metrics.pipelineInitBegin = new Date();
|
|
2697
|
+
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
2631
2698
|
await this.initializeDataPipeline();
|
|
2632
2699
|
} catch (err) {
|
|
2633
2700
|
if (err instanceof import_errors3.CancelledError) {
|
|
2634
2701
|
(0, import_log10.log)("data pipeline initialization cancelled", err, {
|
|
2635
2702
|
F: __dxlog_file12,
|
|
2636
|
-
L:
|
|
2703
|
+
L: 199,
|
|
2637
2704
|
S: this,
|
|
2638
2705
|
C: (f, a) => f(...a)
|
|
2639
2706
|
});
|
|
@@ -2641,7 +2708,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2641
2708
|
}
|
|
2642
2709
|
import_log10.log.error("Error initializing data pipeline", err, {
|
|
2643
2710
|
F: __dxlog_file12,
|
|
2644
|
-
L:
|
|
2711
|
+
L: 203,
|
|
2645
2712
|
S: this,
|
|
2646
2713
|
C: (f, a) => f(...a)
|
|
2647
2714
|
});
|
|
@@ -2649,12 +2716,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2649
2716
|
this.error = err;
|
|
2650
2717
|
this.stateUpdate.emit();
|
|
2651
2718
|
} finally {
|
|
2652
|
-
this.metrics.ready = new Date();
|
|
2719
|
+
this.metrics.ready = /* @__PURE__ */ new Date();
|
|
2653
2720
|
}
|
|
2654
2721
|
});
|
|
2655
2722
|
}
|
|
2656
2723
|
async initializeDataPipeline() {
|
|
2657
|
-
var _a, _b, _c, _d;
|
|
2658
2724
|
if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
|
|
2659
2725
|
throw new import_errors3.SystemError("Invalid operation");
|
|
2660
2726
|
}
|
|
@@ -2663,11 +2729,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2663
2729
|
ctx: this._ctx,
|
|
2664
2730
|
breakOnStall: false
|
|
2665
2731
|
});
|
|
2666
|
-
this.metrics.controlPipelineReady = new Date();
|
|
2732
|
+
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
2667
2733
|
await this._createWritableFeeds();
|
|
2668
2734
|
(0, import_log10.log)("writable feeds created", void 0, {
|
|
2669
2735
|
F: __dxlog_file12,
|
|
2670
|
-
L:
|
|
2736
|
+
L: 227,
|
|
2671
2737
|
S: this,
|
|
2672
2738
|
C: (f, a) => f(...a)
|
|
2673
2739
|
});
|
|
@@ -2680,11 +2746,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2680
2746
|
}), this._inner.controlPipeline.writer));
|
|
2681
2747
|
}
|
|
2682
2748
|
await this._inner.initializeDataPipeline();
|
|
2683
|
-
this.metrics.dataPipelineOpen = new Date();
|
|
2684
|
-
await (0,
|
|
2749
|
+
this.metrics.dataPipelineOpen = /* @__PURE__ */ new Date();
|
|
2750
|
+
await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
2685
2751
|
(0, import_log10.log)("waiting for data pipeline to reach target timeframe", void 0, {
|
|
2686
2752
|
F: __dxlog_file12,
|
|
2687
|
-
L:
|
|
2753
|
+
L: 248,
|
|
2688
2754
|
S: this,
|
|
2689
2755
|
C: (f, a) => f(...a)
|
|
2690
2756
|
});
|
|
@@ -2692,17 +2758,17 @@ var DataSpace = class DataSpace2 {
|
|
|
2692
2758
|
ctx: this._ctx,
|
|
2693
2759
|
breakOnStall: false
|
|
2694
2760
|
});
|
|
2695
|
-
this.metrics.dataPipelineReady = new Date();
|
|
2761
|
+
this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
|
|
2696
2762
|
(0, import_log10.log)("data pipeline ready", void 0, {
|
|
2697
2763
|
F: __dxlog_file12,
|
|
2698
|
-
L:
|
|
2764
|
+
L: 257,
|
|
2699
2765
|
S: this,
|
|
2700
2766
|
C: (f, a) => f(...a)
|
|
2701
2767
|
});
|
|
2702
|
-
await
|
|
2768
|
+
await this._callbacks.beforeReady?.();
|
|
2703
2769
|
this._state = import_services7.SpaceState.READY;
|
|
2704
2770
|
this.stateUpdate.emit();
|
|
2705
|
-
await
|
|
2771
|
+
await this._callbacks.afterReady?.();
|
|
2706
2772
|
}
|
|
2707
2773
|
async _createWritableFeeds() {
|
|
2708
2774
|
const credentials = [];
|
|
@@ -2749,7 +2815,6 @@ var DataSpace = class DataSpace2 {
|
|
|
2749
2815
|
await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
|
|
2750
2816
|
}
|
|
2751
2817
|
async createEpoch() {
|
|
2752
|
-
var _a, _b;
|
|
2753
2818
|
const epoch = await this.dataPipeline.createEpoch();
|
|
2754
2819
|
const receipt = await this.inner.controlPipeline.writer.write({
|
|
2755
2820
|
credential: {
|
|
@@ -2762,16 +2827,19 @@ var DataSpace = class DataSpace2 {
|
|
|
2762
2827
|
})
|
|
2763
2828
|
}
|
|
2764
2829
|
});
|
|
2765
|
-
await this.inner.controlPipeline.state.waitUntilTimeframe(new
|
|
2830
|
+
await this.inner.controlPipeline.state.waitUntilTimeframe(new import_timeframe2.Timeframe([
|
|
2766
2831
|
[
|
|
2767
2832
|
receipt.feedKey,
|
|
2768
2833
|
receipt.seq
|
|
2769
2834
|
]
|
|
2770
2835
|
]));
|
|
2771
|
-
|
|
2772
|
-
const
|
|
2773
|
-
|
|
2774
|
-
|
|
2836
|
+
if (ENABLE_FEED_PURGE) {
|
|
2837
|
+
for (const feed of this.inner.dataPipeline.pipelineState?.feeds ?? []) {
|
|
2838
|
+
const indexBeforeEpoch = epoch.timeframe.get(feed.key);
|
|
2839
|
+
if (indexBeforeEpoch === void 0) {
|
|
2840
|
+
continue;
|
|
2841
|
+
}
|
|
2842
|
+
await feed.safeClear(0, indexBeforeEpoch + 1);
|
|
2775
2843
|
}
|
|
2776
2844
|
}
|
|
2777
2845
|
}
|
|
@@ -2793,22 +2861,22 @@ var DataSpace = class DataSpace2 {
|
|
|
2793
2861
|
this.stateUpdate.emit();
|
|
2794
2862
|
}
|
|
2795
2863
|
};
|
|
2796
|
-
|
|
2864
|
+
_ts_decorate3([
|
|
2797
2865
|
import_async8.synchronized
|
|
2798
2866
|
], DataSpace.prototype, "open", null);
|
|
2799
|
-
|
|
2867
|
+
_ts_decorate3([
|
|
2800
2868
|
import_async8.synchronized
|
|
2801
2869
|
], DataSpace.prototype, "close", null);
|
|
2802
|
-
|
|
2870
|
+
_ts_decorate3([
|
|
2803
2871
|
(0, import_debug4.timed)(1e4)
|
|
2804
2872
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2805
|
-
|
|
2873
|
+
_ts_decorate3([
|
|
2806
2874
|
import_async8.synchronized
|
|
2807
2875
|
], DataSpace.prototype, "activate", null);
|
|
2808
|
-
|
|
2876
|
+
_ts_decorate3([
|
|
2809
2877
|
import_async8.synchronized
|
|
2810
2878
|
], DataSpace.prototype, "deactivate", null);
|
|
2811
|
-
DataSpace =
|
|
2879
|
+
DataSpace = _ts_decorate3([
|
|
2812
2880
|
(0, import_async8.trackLeaks)("open", "close")
|
|
2813
2881
|
], DataSpace);
|
|
2814
2882
|
|
|
@@ -2816,9 +2884,8 @@ DataSpace = _ts_decorate([
|
|
|
2816
2884
|
var import_credentials12 = require("@dxos/credentials");
|
|
2817
2885
|
var import_debug5 = require("@dxos/debug");
|
|
2818
2886
|
var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2819
|
-
var
|
|
2887
|
+
var import_timeframe3 = require("@dxos/timeframe");
|
|
2820
2888
|
var spaceGenesis = async (keyring, signingContext, space) => {
|
|
2821
|
-
var _a, _b, _c, _d;
|
|
2822
2889
|
const credentials = [
|
|
2823
2890
|
await (0, import_credentials12.createCredential)({
|
|
2824
2891
|
signer: keyring,
|
|
@@ -2838,11 +2905,11 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2838
2905
|
spaceKey: space.key,
|
|
2839
2906
|
role: import_credentials13.SpaceMember.Role.ADMIN,
|
|
2840
2907
|
profile: signingContext.profile,
|
|
2841
|
-
genesisFeedKey:
|
|
2908
|
+
genesisFeedKey: space.controlFeedKey ?? (0, import_debug5.failUndefined)()
|
|
2842
2909
|
}
|
|
2843
2910
|
}),
|
|
2844
2911
|
await signingContext.credentialSigner.createCredential({
|
|
2845
|
-
subject:
|
|
2912
|
+
subject: space.controlFeedKey ?? (0, import_debug5.failUndefined)(),
|
|
2846
2913
|
assertion: {
|
|
2847
2914
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
2848
2915
|
spaceKey: space.key,
|
|
@@ -2852,7 +2919,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2852
2919
|
}
|
|
2853
2920
|
}),
|
|
2854
2921
|
await signingContext.credentialSigner.createCredential({
|
|
2855
|
-
subject:
|
|
2922
|
+
subject: space.dataFeedKey ?? (0, import_debug5.failUndefined)(),
|
|
2856
2923
|
assertion: {
|
|
2857
2924
|
"@type": "dxos.halo.credentials.AdmittedFeed",
|
|
2858
2925
|
spaceKey: space.key,
|
|
@@ -2862,12 +2929,12 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2862
2929
|
}
|
|
2863
2930
|
}),
|
|
2864
2931
|
await signingContext.credentialSigner.createCredential({
|
|
2865
|
-
subject:
|
|
2932
|
+
subject: space.key ?? (0, import_debug5.failUndefined)(),
|
|
2866
2933
|
assertion: {
|
|
2867
2934
|
"@type": "dxos.halo.credentials.Epoch",
|
|
2868
2935
|
number: 0,
|
|
2869
2936
|
previousId: void 0,
|
|
2870
|
-
timeframe: new
|
|
2937
|
+
timeframe: new import_timeframe3.Timeframe(),
|
|
2871
2938
|
snapshotCid: void 0
|
|
2872
2939
|
}
|
|
2873
2940
|
})
|
|
@@ -2883,7 +2950,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2883
2950
|
};
|
|
2884
2951
|
|
|
2885
2952
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2886
|
-
function
|
|
2953
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
2887
2954
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2888
2955
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2889
2956
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2902,7 +2969,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2902
2969
|
this._keyring = _keyring;
|
|
2903
2970
|
this._signingContext = _signingContext;
|
|
2904
2971
|
this._feedStore = _feedStore;
|
|
2905
|
-
this._ctx = new
|
|
2972
|
+
this._ctx = new import_context7.Context();
|
|
2906
2973
|
this.updated = new import_async9.Event();
|
|
2907
2974
|
this._spaces = new import_util4.ComplexMap(import_keys7.PublicKey.hash);
|
|
2908
2975
|
this._isOpen = false;
|
|
@@ -3081,7 +3148,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3081
3148
|
* TODO(dmaretskyi): Consider removing.
|
|
3082
3149
|
*/
|
|
3083
3150
|
async waitUntilSpaceReady(spaceKey) {
|
|
3084
|
-
await (0,
|
|
3151
|
+
await (0, import_context7.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
3085
3152
|
const space = this._spaces.get(spaceKey);
|
|
3086
3153
|
return !!space && space.state === import_services8.SpaceState.READY;
|
|
3087
3154
|
}));
|
|
@@ -3198,19 +3265,19 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3198
3265
|
return dataSpace;
|
|
3199
3266
|
}
|
|
3200
3267
|
};
|
|
3201
|
-
|
|
3268
|
+
_ts_decorate4([
|
|
3202
3269
|
import_async9.synchronized
|
|
3203
3270
|
], DataSpaceManager.prototype, "open", null);
|
|
3204
|
-
|
|
3271
|
+
_ts_decorate4([
|
|
3205
3272
|
import_async9.synchronized
|
|
3206
3273
|
], DataSpaceManager.prototype, "close", null);
|
|
3207
|
-
|
|
3274
|
+
_ts_decorate4([
|
|
3208
3275
|
import_async9.synchronized
|
|
3209
3276
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
3210
|
-
|
|
3277
|
+
_ts_decorate4([
|
|
3211
3278
|
import_async9.synchronized
|
|
3212
3279
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
3213
|
-
DataSpaceManager =
|
|
3280
|
+
DataSpaceManager = _ts_decorate4([
|
|
3214
3281
|
(0, import_async9.trackLeaks)("open", "close")
|
|
3215
3282
|
], DataSpaceManager);
|
|
3216
3283
|
|
|
@@ -3241,9 +3308,8 @@ var SpacesServiceImpl = class {
|
|
|
3241
3308
|
return this._serializeSpace(space);
|
|
3242
3309
|
}
|
|
3243
3310
|
async updateSpace({ spaceKey, state }) {
|
|
3244
|
-
var _a;
|
|
3245
3311
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3246
|
-
const space =
|
|
3312
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3247
3313
|
if (state) {
|
|
3248
3314
|
switch (state) {
|
|
3249
3315
|
case import_services9.SpaceState.ACTIVE:
|
|
@@ -3307,17 +3373,15 @@ var SpacesServiceImpl = class {
|
|
|
3307
3373
|
});
|
|
3308
3374
|
}
|
|
3309
3375
|
async postMessage({ spaceKey, channel, message }) {
|
|
3310
|
-
var _a;
|
|
3311
3376
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3312
|
-
const space =
|
|
3377
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3313
3378
|
await space.postMessage(getChannelId(channel), message);
|
|
3314
3379
|
}
|
|
3315
3380
|
subscribeMessages({ spaceKey, channel }) {
|
|
3316
3381
|
return new import_codec_protobuf5.Stream(({ ctx, next }) => {
|
|
3317
3382
|
(0, import_async10.scheduleTask)(ctx, async () => {
|
|
3318
|
-
var _a;
|
|
3319
3383
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3320
|
-
const space =
|
|
3384
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3321
3385
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
3322
3386
|
next(message);
|
|
3323
3387
|
});
|
|
@@ -3327,8 +3391,7 @@ var SpacesServiceImpl = class {
|
|
|
3327
3391
|
}
|
|
3328
3392
|
queryCredentials({ spaceKey }) {
|
|
3329
3393
|
return new import_codec_protobuf5.Stream(({ ctx, next }) => {
|
|
3330
|
-
|
|
3331
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3394
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3332
3395
|
const processor = {
|
|
3333
3396
|
processCredential: async (credential) => {
|
|
3334
3397
|
next(credential);
|
|
@@ -3339,9 +3402,8 @@ var SpacesServiceImpl = class {
|
|
|
3339
3402
|
});
|
|
3340
3403
|
}
|
|
3341
3404
|
async writeCredentials({ spaceKey, credentials }) {
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
for (const credential of credentials != null ? credentials : []) {
|
|
3405
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3406
|
+
for (const credential of credentials ?? []) {
|
|
3345
3407
|
await space.controlPipeline.writer.write({
|
|
3346
3408
|
credential: {
|
|
3347
3409
|
credential
|
|
@@ -3350,13 +3412,11 @@ var SpacesServiceImpl = class {
|
|
|
3350
3412
|
}
|
|
3351
3413
|
}
|
|
3352
3414
|
async createEpoch({ spaceKey }) {
|
|
3353
|
-
var _a;
|
|
3354
3415
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3355
|
-
const space =
|
|
3416
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3356
3417
|
await space.createEpoch();
|
|
3357
3418
|
}
|
|
3358
3419
|
_serializeSpace(space) {
|
|
3359
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
3360
3420
|
return {
|
|
3361
3421
|
spaceKey: space.key,
|
|
3362
3422
|
state: space.state,
|
|
@@ -3368,16 +3428,15 @@ var SpacesServiceImpl = class {
|
|
|
3368
3428
|
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
3369
3429
|
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
3370
3430
|
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
3371
|
-
dataFeeds:
|
|
3372
|
-
startDataTimeframe:
|
|
3373
|
-
currentDataTimeframe:
|
|
3374
|
-
targetDataTimeframe:
|
|
3375
|
-
totalDataTimeframe:
|
|
3431
|
+
dataFeeds: space.dataPipeline.pipelineState?.feeds.map((feed) => feed.key) ?? [],
|
|
3432
|
+
startDataTimeframe: space.dataPipeline.pipelineState?.startTimeframe,
|
|
3433
|
+
currentDataTimeframe: space.dataPipeline.pipelineState?.timeframe,
|
|
3434
|
+
targetDataTimeframe: space.dataPipeline.pipelineState?.targetTimeframe,
|
|
3435
|
+
totalDataTimeframe: space.dataPipeline.pipelineState?.endTimeframe
|
|
3376
3436
|
},
|
|
3377
3437
|
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
3378
|
-
var _a2, _b2, _c2;
|
|
3379
3438
|
const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
|
|
3380
|
-
const isMe =
|
|
3439
|
+
const isMe = this._identityManager.identity?.identityKey.equals(member.key);
|
|
3381
3440
|
if (isMe) {
|
|
3382
3441
|
peers.push(space.presence.getLocalState());
|
|
3383
3442
|
}
|
|
@@ -3385,14 +3444,14 @@ var SpacesServiceImpl = class {
|
|
|
3385
3444
|
identity: {
|
|
3386
3445
|
identityKey: member.key,
|
|
3387
3446
|
profile: {
|
|
3388
|
-
displayName:
|
|
3447
|
+
displayName: member.assertion.profile?.displayName ?? (0, import_util5.humanize)(member.key)
|
|
3389
3448
|
}
|
|
3390
3449
|
},
|
|
3391
3450
|
presence: isMe || peers.length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE,
|
|
3392
3451
|
peerStates: peers
|
|
3393
3452
|
};
|
|
3394
3453
|
}),
|
|
3395
|
-
creator:
|
|
3454
|
+
creator: space.inner.spaceState.creator?.key,
|
|
3396
3455
|
cache: space.cache,
|
|
3397
3456
|
metrics: space.metrics
|
|
3398
3457
|
};
|
|
@@ -3401,8 +3460,18 @@ var SpacesServiceImpl = class {
|
|
|
3401
3460
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
3402
3461
|
|
|
3403
3462
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3463
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
3464
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3465
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3466
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3467
|
+
else
|
|
3468
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3469
|
+
if (d = decorators[i])
|
|
3470
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3471
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3472
|
+
}
|
|
3404
3473
|
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
3405
|
-
var ServiceContext = class {
|
|
3474
|
+
var ServiceContext = class ServiceContext2 {
|
|
3406
3475
|
// prettier-ignore
|
|
3407
3476
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
3408
3477
|
this.storage = storage;
|
|
@@ -3436,16 +3505,13 @@ var ServiceContext = class {
|
|
|
3436
3505
|
});
|
|
3437
3506
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
3438
3507
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
3439
|
-
this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () =>
|
|
3440
|
-
var _a;
|
|
3441
|
-
return (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
|
|
3442
|
-
}, this._acceptIdentity.bind(this)));
|
|
3508
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug7.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
3443
3509
|
}
|
|
3444
|
-
async open() {
|
|
3510
|
+
async open(ctx) {
|
|
3445
3511
|
await this._checkStorageVersion();
|
|
3446
3512
|
(0, import_log13.log)("opening...", void 0, {
|
|
3447
3513
|
F: __dxlog_file15,
|
|
3448
|
-
L:
|
|
3514
|
+
L: 134,
|
|
3449
3515
|
S: this,
|
|
3450
3516
|
C: (f, a) => f(...a)
|
|
3451
3517
|
});
|
|
@@ -3453,44 +3519,43 @@ var ServiceContext = class {
|
|
|
3453
3519
|
id: this._instanceId
|
|
3454
3520
|
}), {
|
|
3455
3521
|
F: __dxlog_file15,
|
|
3456
|
-
L:
|
|
3522
|
+
L: 135,
|
|
3457
3523
|
S: this,
|
|
3458
3524
|
C: (f, a) => f(...a)
|
|
3459
3525
|
});
|
|
3460
3526
|
await this.signalManager.open();
|
|
3461
3527
|
await this.networkManager.open();
|
|
3462
3528
|
await this.spaceManager.open();
|
|
3463
|
-
await this.identityManager.open();
|
|
3529
|
+
await this.identityManager.open(ctx);
|
|
3464
3530
|
if (this.identityManager.identity) {
|
|
3465
|
-
await this._initialize();
|
|
3531
|
+
await this._initialize(ctx);
|
|
3466
3532
|
}
|
|
3467
3533
|
import_log13.log.trace("dxos.sdk.service-context.open", import_protocols9.trace.end({
|
|
3468
3534
|
id: this._instanceId
|
|
3469
3535
|
}), {
|
|
3470
3536
|
F: __dxlog_file15,
|
|
3471
|
-
L:
|
|
3537
|
+
L: 143,
|
|
3472
3538
|
S: this,
|
|
3473
3539
|
C: (f, a) => f(...a)
|
|
3474
3540
|
});
|
|
3475
3541
|
(0, import_log13.log)("opened", void 0, {
|
|
3476
3542
|
F: __dxlog_file15,
|
|
3477
|
-
L:
|
|
3543
|
+
L: 144,
|
|
3478
3544
|
S: this,
|
|
3479
3545
|
C: (f, a) => f(...a)
|
|
3480
3546
|
});
|
|
3481
3547
|
}
|
|
3482
3548
|
async close() {
|
|
3483
|
-
var _a;
|
|
3484
3549
|
(0, import_log13.log)("closing...", void 0, {
|
|
3485
3550
|
F: __dxlog_file15,
|
|
3486
|
-
L:
|
|
3551
|
+
L: 148,
|
|
3487
3552
|
S: this,
|
|
3488
3553
|
C: (f, a) => f(...a)
|
|
3489
3554
|
});
|
|
3490
3555
|
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
3491
3556
|
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
3492
3557
|
}
|
|
3493
|
-
await
|
|
3558
|
+
await this.dataSpaceManager?.close();
|
|
3494
3559
|
await this.identityManager.close();
|
|
3495
3560
|
await this.spaceManager.close();
|
|
3496
3561
|
await this.feedStore.close();
|
|
@@ -3499,21 +3564,21 @@ var ServiceContext = class {
|
|
|
3499
3564
|
this.dataServiceSubscriptions.clear();
|
|
3500
3565
|
(0, import_log13.log)("closed", void 0, {
|
|
3501
3566
|
F: __dxlog_file15,
|
|
3502
|
-
L:
|
|
3567
|
+
L: 159,
|
|
3503
3568
|
S: this,
|
|
3504
3569
|
C: (f, a) => f(...a)
|
|
3505
3570
|
});
|
|
3506
3571
|
}
|
|
3507
3572
|
async createIdentity(params = {}) {
|
|
3508
3573
|
const identity = await this.identityManager.createIdentity(params);
|
|
3509
|
-
await this._initialize();
|
|
3574
|
+
await this._initialize(new import_context8.Context());
|
|
3510
3575
|
return identity;
|
|
3511
3576
|
}
|
|
3512
3577
|
getInvitationHandler(invitation) {
|
|
3513
3578
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3514
3579
|
(0, import_invariant12.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
3515
3580
|
F: __dxlog_file15,
|
|
3516
|
-
L:
|
|
3581
|
+
L: 171,
|
|
3517
3582
|
S: this,
|
|
3518
3583
|
A: [
|
|
3519
3584
|
"factory",
|
|
@@ -3524,7 +3589,7 @@ var ServiceContext = class {
|
|
|
3524
3589
|
}
|
|
3525
3590
|
async _acceptIdentity(params) {
|
|
3526
3591
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
3527
|
-
await this._initialize();
|
|
3592
|
+
await this._initialize(new import_context8.Context());
|
|
3528
3593
|
return identity;
|
|
3529
3594
|
}
|
|
3530
3595
|
async _checkStorageVersion() {
|
|
@@ -3534,15 +3599,14 @@ var ServiceContext = class {
|
|
|
3534
3599
|
}
|
|
3535
3600
|
}
|
|
3536
3601
|
// Called when identity is created.
|
|
3537
|
-
async _initialize() {
|
|
3538
|
-
var _a;
|
|
3602
|
+
async _initialize(ctx) {
|
|
3539
3603
|
(0, import_log13.log)("initializing spaces...", void 0, {
|
|
3540
3604
|
F: __dxlog_file15,
|
|
3541
|
-
L:
|
|
3605
|
+
L: 193,
|
|
3542
3606
|
S: this,
|
|
3543
3607
|
C: (f, a) => f(...a)
|
|
3544
3608
|
});
|
|
3545
|
-
const identity =
|
|
3609
|
+
const identity = this.identityManager.identity ?? (0, import_debug7.failUndefined)();
|
|
3546
3610
|
const signingContext = {
|
|
3547
3611
|
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
3548
3612
|
identityKey: identity.identityKey,
|
|
@@ -3561,7 +3625,7 @@ var ServiceContext = class {
|
|
|
3561
3625
|
this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
|
|
3562
3626
|
(0, import_invariant12.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
3563
3627
|
F: __dxlog_file15,
|
|
3564
|
-
L:
|
|
3628
|
+
L: 216,
|
|
3565
3629
|
S: this,
|
|
3566
3630
|
A: [
|
|
3567
3631
|
"this.dataSpaceManager",
|
|
@@ -3585,7 +3649,7 @@ var ServiceContext = class {
|
|
|
3585
3649
|
details: assertion
|
|
3586
3650
|
}, {
|
|
3587
3651
|
F: __dxlog_file15,
|
|
3588
|
-
L:
|
|
3652
|
+
L: 232,
|
|
3589
3653
|
S: this,
|
|
3590
3654
|
C: (f, a) => f(...a)
|
|
3591
3655
|
});
|
|
@@ -3596,7 +3660,7 @@ var ServiceContext = class {
|
|
|
3596
3660
|
details: assertion
|
|
3597
3661
|
}, {
|
|
3598
3662
|
F: __dxlog_file15,
|
|
3599
|
-
L:
|
|
3663
|
+
L: 236,
|
|
3600
3664
|
S: this,
|
|
3601
3665
|
C: (f, a) => f(...a)
|
|
3602
3666
|
});
|
|
@@ -3607,7 +3671,7 @@ var ServiceContext = class {
|
|
|
3607
3671
|
details: assertion
|
|
3608
3672
|
}, {
|
|
3609
3673
|
F: __dxlog_file15,
|
|
3610
|
-
L:
|
|
3674
|
+
L: 241,
|
|
3611
3675
|
S: this,
|
|
3612
3676
|
C: (f, a) => f(...a)
|
|
3613
3677
|
});
|
|
@@ -3618,7 +3682,7 @@ var ServiceContext = class {
|
|
|
3618
3682
|
} catch (err) {
|
|
3619
3683
|
import_log13.log.catch(err, void 0, {
|
|
3620
3684
|
F: __dxlog_file15,
|
|
3621
|
-
L:
|
|
3685
|
+
L: 247,
|
|
3622
3686
|
S: this,
|
|
3623
3687
|
C: (f, a) => f(...a)
|
|
3624
3688
|
});
|
|
@@ -3628,10 +3692,21 @@ var ServiceContext = class {
|
|
|
3628
3692
|
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
3629
3693
|
}
|
|
3630
3694
|
};
|
|
3695
|
+
_ts_decorate5([
|
|
3696
|
+
import_tracing3.trace.span()
|
|
3697
|
+
], ServiceContext.prototype, "open", null);
|
|
3698
|
+
_ts_decorate5([
|
|
3699
|
+
import_tracing3.trace.span()
|
|
3700
|
+
], ServiceContext.prototype, "_initialize", null);
|
|
3701
|
+
ServiceContext = _ts_decorate5([
|
|
3702
|
+
(0, import_util6.safeInstanceof)("dxos.client-services.ServiceContext"),
|
|
3703
|
+
import_tracing3.trace.resource()
|
|
3704
|
+
], ServiceContext);
|
|
3631
3705
|
|
|
3632
3706
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3633
3707
|
var import_async17 = require("@dxos/async");
|
|
3634
3708
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
3709
|
+
var import_context10 = require("@dxos/context");
|
|
3635
3710
|
var import_document_model2 = require("@dxos/document-model");
|
|
3636
3711
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
3637
3712
|
var import_invariant14 = require("@dxos/invariant");
|
|
@@ -3643,6 +3718,7 @@ var import_network_manager2 = require("@dxos/network-manager");
|
|
|
3643
3718
|
var import_protocols10 = require("@dxos/protocols");
|
|
3644
3719
|
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3645
3720
|
var import_text_model = require("@dxos/text-model");
|
|
3721
|
+
var import_tracing4 = require("@dxos/tracing");
|
|
3646
3722
|
|
|
3647
3723
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3648
3724
|
var import_async12 = require("@dxos/async");
|
|
@@ -3658,21 +3734,17 @@ var DevicesServiceImpl = class {
|
|
|
3658
3734
|
queryDevices() {
|
|
3659
3735
|
return new import_codec_protobuf6.Stream(({ next }) => {
|
|
3660
3736
|
const update = () => {
|
|
3661
|
-
|
|
3662
|
-
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
3737
|
+
const deviceKeys = this._identityManager.identity?.authorizedDeviceKeys;
|
|
3663
3738
|
if (!deviceKeys) {
|
|
3664
3739
|
next({
|
|
3665
3740
|
devices: []
|
|
3666
3741
|
});
|
|
3667
3742
|
} else {
|
|
3668
3743
|
next({
|
|
3669
|
-
devices: Array.from(deviceKeys.values()).map((key) => {
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services11.DeviceKind.CURRENT : import_services11.DeviceKind.TRUSTED
|
|
3674
|
-
};
|
|
3675
|
-
})
|
|
3744
|
+
devices: Array.from(deviceKeys.values()).map((key) => ({
|
|
3745
|
+
deviceKey: key,
|
|
3746
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services11.DeviceKind.CURRENT : import_services11.DeviceKind.TRUSTED
|
|
3747
|
+
}))
|
|
3676
3748
|
});
|
|
3677
3749
|
}
|
|
3678
3750
|
};
|
|
@@ -3700,14 +3772,14 @@ var import_async13 = require("@dxos/async");
|
|
|
3700
3772
|
var import_codec_protobuf7 = require("@dxos/codec-protobuf");
|
|
3701
3773
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
3702
3774
|
var import_keys9 = require("@dxos/keys");
|
|
3703
|
-
var
|
|
3775
|
+
var import_util7 = require("@dxos/util");
|
|
3704
3776
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
3705
3777
|
return new import_codec_protobuf7.Stream(({ next }) => {
|
|
3706
3778
|
const subscriptions = new import_async13.EventSubscriptions();
|
|
3707
|
-
const feedMap = new
|
|
3779
|
+
const feedMap = new import_util7.ComplexMap(import_keys9.PublicKey.hash);
|
|
3708
3780
|
const update = () => {
|
|
3709
3781
|
const { feeds } = feedStore;
|
|
3710
|
-
feeds.filter((feed) => !
|
|
3782
|
+
feeds.filter((feed) => !feedKeys?.length || feedKeys.some((feedKey) => feedKey.equals(feed.key))).forEach((feed) => {
|
|
3711
3783
|
if (!feedMap.has(feed.key)) {
|
|
3712
3784
|
feedMap.set(feed.key, feed);
|
|
3713
3785
|
feed.on("close", update);
|
|
@@ -3715,15 +3787,12 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
|
3715
3787
|
}
|
|
3716
3788
|
});
|
|
3717
3789
|
next({
|
|
3718
|
-
feeds: Array.from(feedMap.values()).map((feed) => {
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
downloaded: (_b = (_a = feed.core.bitfield) == null ? void 0 : _a.data.toBuffer()) != null ? _b : new Uint8Array()
|
|
3725
|
-
};
|
|
3726
|
-
})
|
|
3790
|
+
feeds: Array.from(feedMap.values()).map((feed) => ({
|
|
3791
|
+
feedKey: feed.key,
|
|
3792
|
+
length: feed.properties.length,
|
|
3793
|
+
bytes: feed.core.byteLength,
|
|
3794
|
+
downloaded: feed.core.bitfield?.data.toBuffer() ?? new Uint8Array()
|
|
3795
|
+
}))
|
|
3727
3796
|
});
|
|
3728
3797
|
};
|
|
3729
3798
|
subscriptions.add(feedStore.feedOpened.on(update));
|
|
@@ -3798,7 +3867,7 @@ var subscribeToMetadata = ({ context }) => new import_codec_protobuf9.Stream(({
|
|
|
3798
3867
|
|
|
3799
3868
|
// packages/sdk/client-services/src/packlets/devtools/network.ts
|
|
3800
3869
|
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
3801
|
-
var
|
|
3870
|
+
var import_context9 = require("@dxos/context");
|
|
3802
3871
|
var import_keys10 = require("@dxos/keys");
|
|
3803
3872
|
var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf10.Stream(({ next, close }) => {
|
|
3804
3873
|
const update = () => {
|
|
@@ -3815,7 +3884,7 @@ var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf1
|
|
|
3815
3884
|
update();
|
|
3816
3885
|
});
|
|
3817
3886
|
var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf10.Stream(({ next }) => {
|
|
3818
|
-
const ctx = new
|
|
3887
|
+
const ctx = new import_context9.Context();
|
|
3819
3888
|
signalManager.onMessage.on(ctx, (message) => {
|
|
3820
3889
|
next({
|
|
3821
3890
|
message: {
|
|
@@ -3823,13 +3892,13 @@ var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf10.Strea
|
|
|
3823
3892
|
recipient: message.recipient.asUint8Array(),
|
|
3824
3893
|
payload: message.payload
|
|
3825
3894
|
},
|
|
3826
|
-
receivedAt: new Date()
|
|
3895
|
+
receivedAt: /* @__PURE__ */ new Date()
|
|
3827
3896
|
});
|
|
3828
3897
|
});
|
|
3829
3898
|
signalManager.swarmEvent.on(ctx, (swarmEvent) => {
|
|
3830
3899
|
next({
|
|
3831
3900
|
swarmEvent: swarmEvent.swarmEvent,
|
|
3832
|
-
receivedAt: new Date()
|
|
3901
|
+
receivedAt: /* @__PURE__ */ new Date()
|
|
3833
3902
|
});
|
|
3834
3903
|
});
|
|
3835
3904
|
return () => {
|
|
@@ -3837,17 +3906,15 @@ var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf10.Strea
|
|
|
3837
3906
|
};
|
|
3838
3907
|
});
|
|
3839
3908
|
var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf10.Stream(({ next }) => {
|
|
3840
|
-
var _a;
|
|
3841
3909
|
const update = () => {
|
|
3842
|
-
|
|
3843
|
-
const info = (_a2 = networkManager.connectionLog) == null ? void 0 : _a2.swarms;
|
|
3910
|
+
const info = networkManager.connectionLog?.swarms;
|
|
3844
3911
|
if (info) {
|
|
3845
3912
|
next({
|
|
3846
3913
|
data: info
|
|
3847
3914
|
});
|
|
3848
3915
|
}
|
|
3849
3916
|
};
|
|
3850
|
-
|
|
3917
|
+
networkManager.connectionLog?.update.on(update);
|
|
3851
3918
|
update();
|
|
3852
3919
|
});
|
|
3853
3920
|
|
|
@@ -3860,14 +3927,14 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
|
3860
3927
|
const spaces = [
|
|
3861
3928
|
...context.spaceManager.spaces.values()
|
|
3862
3929
|
];
|
|
3863
|
-
const filteredSpaces = spaces.filter((space) => !
|
|
3930
|
+
const filteredSpaces = spaces.filter((space) => !spaceKeys?.length || spaceKeys.some((spaceKey) => spaceKey.equals(space.key)));
|
|
3864
3931
|
next({
|
|
3865
3932
|
spaces: filteredSpaces.map((space) => {
|
|
3866
3933
|
const spaceMetadata = context.metadataStore.spaces.find((spaceMetadata2) => spaceMetadata2.key.equals(space.key));
|
|
3867
3934
|
return {
|
|
3868
3935
|
key: space.key,
|
|
3869
3936
|
isOpen: space.isOpen,
|
|
3870
|
-
timeframe: spaceMetadata
|
|
3937
|
+
timeframe: spaceMetadata?.dataTimeframe,
|
|
3871
3938
|
genesisFeed: space.genesisFeedKey,
|
|
3872
3939
|
controlFeed: space.controlFeedKey,
|
|
3873
3940
|
dataFeed: space.dataFeedKey
|
|
@@ -3881,7 +3948,7 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
|
3881
3948
|
await update();
|
|
3882
3949
|
});
|
|
3883
3950
|
return () => {
|
|
3884
|
-
unsubscribe
|
|
3951
|
+
unsubscribe?.();
|
|
3885
3952
|
clearTimeout(timeout);
|
|
3886
3953
|
};
|
|
3887
3954
|
});
|
|
@@ -3912,16 +3979,15 @@ var DevtoolsServiceImpl = class {
|
|
|
3912
3979
|
};
|
|
3913
3980
|
}
|
|
3914
3981
|
async getStorageInfo() {
|
|
3915
|
-
|
|
3916
|
-
const storageUsage = (_c = await ((_b = (_a = this.params.context.storage).getDiskInfo) == null ? void 0 : _b.call(_a))) != null ? _c : {
|
|
3982
|
+
const storageUsage = await this.params.context.storage.getDiskInfo?.() ?? {
|
|
3917
3983
|
used: 0
|
|
3918
3984
|
};
|
|
3919
3985
|
const navigatorInfo = typeof navigator === "object" ? await navigator.storage.estimate() : void 0;
|
|
3920
3986
|
return {
|
|
3921
3987
|
type: this.params.context.storage.type,
|
|
3922
3988
|
storageUsage: storageUsage.used,
|
|
3923
|
-
originUsage:
|
|
3924
|
-
usageQuota:
|
|
3989
|
+
originUsage: navigatorInfo?.usage ?? 0,
|
|
3990
|
+
usageQuota: navigatorInfo?.quota ?? 0
|
|
3925
3991
|
};
|
|
3926
3992
|
}
|
|
3927
3993
|
async getBlobs() {
|
|
@@ -4008,7 +4074,7 @@ var DevtoolsServiceImpl = class {
|
|
|
4008
4074
|
var import_invariant13 = require("@dxos/invariant");
|
|
4009
4075
|
var import_lock_file = require("@dxos/lock-file");
|
|
4010
4076
|
var import_log14 = require("@dxos/log");
|
|
4011
|
-
function
|
|
4077
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
4012
4078
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4013
4079
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4014
4080
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4029,7 +4095,6 @@ var Lock = class {
|
|
|
4029
4095
|
return this._lockPath;
|
|
4030
4096
|
}
|
|
4031
4097
|
async acquire() {
|
|
4032
|
-
var _a;
|
|
4033
4098
|
(0, import_log14.log)("acquiring lock...", void 0, {
|
|
4034
4099
|
F: __dxlog_file16,
|
|
4035
4100
|
L: 32,
|
|
@@ -4037,7 +4102,7 @@ var Lock = class {
|
|
|
4037
4102
|
C: (f, a) => f(...a)
|
|
4038
4103
|
});
|
|
4039
4104
|
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
4040
|
-
await
|
|
4105
|
+
await this._onAcquire?.();
|
|
4041
4106
|
(0, import_log14.log)("acquired lock", void 0, {
|
|
4042
4107
|
F: __dxlog_file16,
|
|
4043
4108
|
L: 37,
|
|
@@ -4046,8 +4111,7 @@ var Lock = class {
|
|
|
4046
4111
|
});
|
|
4047
4112
|
}
|
|
4048
4113
|
async release() {
|
|
4049
|
-
|
|
4050
|
-
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
4114
|
+
await this._onRelease?.();
|
|
4051
4115
|
(0, import_invariant13.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
4052
4116
|
F: __dxlog_file16,
|
|
4053
4117
|
L: 42,
|
|
@@ -4060,7 +4124,7 @@ var Lock = class {
|
|
|
4060
4124
|
await import_lock_file.LockFile.release(this._fileHandle);
|
|
4061
4125
|
}
|
|
4062
4126
|
};
|
|
4063
|
-
|
|
4127
|
+
_ts_decorate6([
|
|
4064
4128
|
import_log14.logInfo
|
|
4065
4129
|
], Lock.prototype, "lockKey", null);
|
|
4066
4130
|
|
|
@@ -4069,11 +4133,11 @@ var import_async16 = require("@dxos/async");
|
|
|
4069
4133
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
4070
4134
|
var import_log15 = require("@dxos/log");
|
|
4071
4135
|
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
4072
|
-
var
|
|
4136
|
+
var import_util8 = require("@dxos/util");
|
|
4073
4137
|
var LoggingServiceImpl = class {
|
|
4074
4138
|
constructor() {
|
|
4075
4139
|
this._logs = new import_async16.Event();
|
|
4076
|
-
this._started = new Date();
|
|
4140
|
+
this._started = /* @__PURE__ */ new Date();
|
|
4077
4141
|
this._logProcessor = (_config, entry2) => {
|
|
4078
4142
|
this._logs.emit(entry2);
|
|
4079
4143
|
};
|
|
@@ -4087,15 +4151,15 @@ var LoggingServiceImpl = class {
|
|
|
4087
4151
|
}
|
|
4088
4152
|
async controlMetrics({ reset, record }) {
|
|
4089
4153
|
if (reset) {
|
|
4090
|
-
|
|
4154
|
+
import_util8.tracer.clear();
|
|
4091
4155
|
}
|
|
4092
4156
|
if (record === true) {
|
|
4093
|
-
|
|
4157
|
+
import_util8.tracer.start();
|
|
4094
4158
|
} else if (record === false) {
|
|
4095
|
-
|
|
4159
|
+
import_util8.tracer.stop();
|
|
4096
4160
|
}
|
|
4097
4161
|
return {
|
|
4098
|
-
recording:
|
|
4162
|
+
recording: import_util8.tracer.recording
|
|
4099
4163
|
};
|
|
4100
4164
|
}
|
|
4101
4165
|
/**
|
|
@@ -4103,24 +4167,23 @@ var LoggingServiceImpl = class {
|
|
|
4103
4167
|
*/
|
|
4104
4168
|
queryMetrics({ interval = 5e3 }) {
|
|
4105
4169
|
const getNumericalValues = (key) => {
|
|
4106
|
-
|
|
4107
|
-
const events = (_a = import_util7.tracer.get(key)) != null ? _a : [];
|
|
4170
|
+
const events = import_util8.tracer.get(key) ?? [];
|
|
4108
4171
|
return {
|
|
4109
4172
|
key,
|
|
4110
|
-
stats: (0,
|
|
4173
|
+
stats: (0, import_util8.numericalValues)(events, "duration")
|
|
4111
4174
|
};
|
|
4112
4175
|
};
|
|
4113
4176
|
return new import_codec_protobuf13.Stream(({ next }) => {
|
|
4114
4177
|
const update = () => {
|
|
4115
4178
|
const metrics = {
|
|
4116
|
-
timestamp: new Date(),
|
|
4179
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4117
4180
|
values: [
|
|
4118
4181
|
getNumericalValues("dxos.echo.pipeline.control"),
|
|
4119
4182
|
getNumericalValues("dxos.echo.pipeline.data")
|
|
4120
4183
|
].filter(Boolean)
|
|
4121
4184
|
};
|
|
4122
4185
|
next({
|
|
4123
|
-
timestamp: new Date(),
|
|
4186
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4124
4187
|
metrics
|
|
4125
4188
|
});
|
|
4126
4189
|
};
|
|
@@ -4134,11 +4197,10 @@ var LoggingServiceImpl = class {
|
|
|
4134
4197
|
queryLogs(request) {
|
|
4135
4198
|
return new import_codec_protobuf13.Stream(({ ctx, next }) => {
|
|
4136
4199
|
const handler = (entry2) => {
|
|
4137
|
-
var _a, _b, _c, _d, _e;
|
|
4138
4200
|
if (LOG_PROCESSING > 0) {
|
|
4139
4201
|
return;
|
|
4140
4202
|
}
|
|
4141
|
-
if (
|
|
4203
|
+
if (entry2.meta?.F.includes("logging-service") || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
|
|
4142
4204
|
return;
|
|
4143
4205
|
}
|
|
4144
4206
|
if (!shouldLog(entry2, request)) {
|
|
@@ -4146,12 +4208,12 @@ var LoggingServiceImpl = class {
|
|
|
4146
4208
|
}
|
|
4147
4209
|
const record = {
|
|
4148
4210
|
...entry2,
|
|
4149
|
-
context: (0,
|
|
4150
|
-
timestamp: new Date(),
|
|
4211
|
+
context: (0, import_util8.jsonify)((0, import_log15.getContextFromEntry)(entry2)),
|
|
4212
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4151
4213
|
meta: {
|
|
4152
4214
|
// TODO(dmaretskyi): Fix proto.
|
|
4153
|
-
file:
|
|
4154
|
-
line:
|
|
4215
|
+
file: entry2.meta?.F ?? "",
|
|
4216
|
+
line: entry2.meta?.L ?? 0
|
|
4155
4217
|
}
|
|
4156
4218
|
};
|
|
4157
4219
|
try {
|
|
@@ -4174,15 +4236,11 @@ var matchFilter = (filter, level, path, options) => {
|
|
|
4174
4236
|
}
|
|
4175
4237
|
};
|
|
4176
4238
|
var shouldLog = (entry2, request) => {
|
|
4177
|
-
|
|
4178
|
-
const options = (_a = request.options) != null ? _a : import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4239
|
+
const options = request.options ?? import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4179
4240
|
if (request.filters === void 0) {
|
|
4180
4241
|
return options === import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
4181
4242
|
} else {
|
|
4182
|
-
return request.filters.some((filter) =>
|
|
4183
|
-
var _a2, _b;
|
|
4184
|
-
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
|
|
4185
|
-
});
|
|
4243
|
+
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
4186
4244
|
}
|
|
4187
4245
|
};
|
|
4188
4246
|
var LOG_PROCESSING = 0;
|
|
@@ -4224,10 +4282,10 @@ var import_client_protocol4 = require("@dxos/client-protocol");
|
|
|
4224
4282
|
var import_errors5 = require("@dxos/errors");
|
|
4225
4283
|
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
4226
4284
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
4227
|
-
var
|
|
4285
|
+
var import_util9 = require("@dxos/util");
|
|
4228
4286
|
var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
4229
4287
|
var createStorageObjects = (config) => {
|
|
4230
|
-
const { path = (0,
|
|
4288
|
+
const { path = (0, import_util9.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config ?? {};
|
|
4231
4289
|
if (persistent && storageType === StorageDriver.RAM) {
|
|
4232
4290
|
throw new import_errors5.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
4233
4291
|
}
|
|
@@ -4271,7 +4329,7 @@ var toStorageType = (type) => {
|
|
|
4271
4329
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
4272
4330
|
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
4273
4331
|
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
4274
|
-
var
|
|
4332
|
+
var import_util10 = require("@dxos/util");
|
|
4275
4333
|
var SystemServiceImpl = class {
|
|
4276
4334
|
constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
4277
4335
|
this._config = config;
|
|
@@ -4282,8 +4340,7 @@ var SystemServiceImpl = class {
|
|
|
4282
4340
|
this._onReset = onReset;
|
|
4283
4341
|
}
|
|
4284
4342
|
async getConfig() {
|
|
4285
|
-
|
|
4286
|
-
return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
|
|
4343
|
+
return this._config?.values ?? {};
|
|
4287
4344
|
}
|
|
4288
4345
|
/**
|
|
4289
4346
|
* NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
|
|
@@ -4291,8 +4348,8 @@ var SystemServiceImpl = class {
|
|
|
4291
4348
|
async getDiagnostics({ keys } = {}) {
|
|
4292
4349
|
const diagnostics = await this._getDiagnostics();
|
|
4293
4350
|
return {
|
|
4294
|
-
timestamp: new Date(),
|
|
4295
|
-
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0,
|
|
4351
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
4352
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util10.jsonKeyReplacer)({
|
|
4296
4353
|
truncate: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
4297
4354
|
humanize: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
4298
4355
|
})))
|
|
@@ -4348,7 +4405,7 @@ var ServiceRegistry = class {
|
|
|
4348
4405
|
};
|
|
4349
4406
|
|
|
4350
4407
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
4351
|
-
function
|
|
4408
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
4352
4409
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4353
4410
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4354
4411
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4362,7 +4419,7 @@ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
|
|
|
4362
4419
|
var createDefaultModelFactory = () => {
|
|
4363
4420
|
return new import_model_factory.ModelFactory().registerModel(import_document_model2.DocumentModel).registerModel(import_text_model.TextModel);
|
|
4364
4421
|
};
|
|
4365
|
-
var ClientServicesHost = class {
|
|
4422
|
+
var ClientServicesHost = class ClientServicesHost2 {
|
|
4366
4423
|
constructor({
|
|
4367
4424
|
config,
|
|
4368
4425
|
modelFactory = createDefaultModelFactory(),
|
|
@@ -4373,6 +4430,7 @@ var ClientServicesHost = class {
|
|
|
4373
4430
|
lockKey,
|
|
4374
4431
|
callbacks
|
|
4375
4432
|
} = {}) {
|
|
4433
|
+
this._tracingService = import_tracing4.TRACE_PROCESSOR.createTraceSender();
|
|
4376
4434
|
this._statusUpdate = new import_async17.Event();
|
|
4377
4435
|
this._opening = false;
|
|
4378
4436
|
this._open = false;
|
|
@@ -4391,7 +4449,7 @@ var ClientServicesHost = class {
|
|
|
4391
4449
|
lockKey,
|
|
4392
4450
|
onAcquire: () => {
|
|
4393
4451
|
if (!this._opening) {
|
|
4394
|
-
void this.open();
|
|
4452
|
+
void this.open(new import_context10.Context());
|
|
4395
4453
|
}
|
|
4396
4454
|
},
|
|
4397
4455
|
onRelease: () => this.close()
|
|
@@ -4405,11 +4463,10 @@ var ClientServicesHost = class {
|
|
|
4405
4463
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
4406
4464
|
},
|
|
4407
4465
|
onUpdateStatus: async (status) => {
|
|
4408
|
-
var _a, _b;
|
|
4409
4466
|
if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
|
|
4410
|
-
await
|
|
4467
|
+
await this._resourceLock?.acquire();
|
|
4411
4468
|
} else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
|
|
4412
|
-
await
|
|
4469
|
+
await this._resourceLock?.release();
|
|
4413
4470
|
}
|
|
4414
4471
|
},
|
|
4415
4472
|
onReset: async () => {
|
|
@@ -4418,7 +4475,8 @@ var ClientServicesHost = class {
|
|
|
4418
4475
|
});
|
|
4419
4476
|
this._loggingService = new LoggingServiceImpl();
|
|
4420
4477
|
this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
|
|
4421
|
-
SystemService: this._systemService
|
|
4478
|
+
SystemService: this._systemService,
|
|
4479
|
+
TracingService: this._tracingService
|
|
4422
4480
|
});
|
|
4423
4481
|
}
|
|
4424
4482
|
get isOpen() {
|
|
@@ -4445,26 +4503,25 @@ var ClientServicesHost = class {
|
|
|
4445
4503
|
* Can only be called once.
|
|
4446
4504
|
*/
|
|
4447
4505
|
initialize({ config, ...options }) {
|
|
4448
|
-
var _a, _b, _c;
|
|
4449
4506
|
(0, import_invariant14.invariant)(!this._open, "service host is open", {
|
|
4450
4507
|
F: __dxlog_file17,
|
|
4451
|
-
L:
|
|
4508
|
+
L: 181,
|
|
4452
4509
|
S: this,
|
|
4453
4510
|
A: [
|
|
4454
4511
|
"!this._open",
|
|
4455
4512
|
"'service host is open'"
|
|
4456
4513
|
]
|
|
4457
4514
|
});
|
|
4458
|
-
import_log16.log
|
|
4515
|
+
(0, import_log16.log)("initializing...", void 0, {
|
|
4459
4516
|
F: __dxlog_file17,
|
|
4460
|
-
L:
|
|
4517
|
+
L: 182,
|
|
4461
4518
|
S: this,
|
|
4462
4519
|
C: (f, a) => f(...a)
|
|
4463
4520
|
});
|
|
4464
4521
|
if (config) {
|
|
4465
4522
|
(0, import_invariant14.invariant)(!this._config, "config already set", {
|
|
4466
4523
|
F: __dxlog_file17,
|
|
4467
|
-
L:
|
|
4524
|
+
L: 185,
|
|
4468
4525
|
S: this,
|
|
4469
4526
|
A: [
|
|
4470
4527
|
"!this._config",
|
|
@@ -4477,12 +4534,12 @@ var ClientServicesHost = class {
|
|
|
4477
4534
|
}
|
|
4478
4535
|
}
|
|
4479
4536
|
const { connectionLog = true, transportFactory = (0, import_network_manager2.createWebRTCTransportFactory)({
|
|
4480
|
-
iceServers:
|
|
4481
|
-
}), signalManager = new import_messaging.WebsocketSignalManager(
|
|
4537
|
+
iceServers: this._config?.get("runtime.services.ice")
|
|
4538
|
+
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
4482
4539
|
this._signalManager = signalManager;
|
|
4483
4540
|
(0, import_invariant14.invariant)(!this._networkManager, "network manager already set", {
|
|
4484
4541
|
F: __dxlog_file17,
|
|
4485
|
-
L:
|
|
4542
|
+
L: 201,
|
|
4486
4543
|
S: this,
|
|
4487
4544
|
A: [
|
|
4488
4545
|
"!this._networkManager",
|
|
@@ -4494,15 +4551,14 @@ var ClientServicesHost = class {
|
|
|
4494
4551
|
transportFactory,
|
|
4495
4552
|
signalManager
|
|
4496
4553
|
});
|
|
4497
|
-
import_log16.log
|
|
4554
|
+
(0, import_log16.log)("initialized", void 0, {
|
|
4498
4555
|
F: __dxlog_file17,
|
|
4499
|
-
L:
|
|
4556
|
+
L: 208,
|
|
4500
4557
|
S: this,
|
|
4501
4558
|
C: (f, a) => f(...a)
|
|
4502
4559
|
});
|
|
4503
4560
|
}
|
|
4504
|
-
async open() {
|
|
4505
|
-
var _a, _b, _c;
|
|
4561
|
+
async open(ctx) {
|
|
4506
4562
|
if (this._open) {
|
|
4507
4563
|
return;
|
|
4508
4564
|
}
|
|
@@ -4511,13 +4567,13 @@ var ClientServicesHost = class {
|
|
|
4511
4567
|
id: traceId
|
|
4512
4568
|
}), {
|
|
4513
4569
|
F: __dxlog_file17,
|
|
4514
|
-
L:
|
|
4570
|
+
L: 219,
|
|
4515
4571
|
S: this,
|
|
4516
4572
|
C: (f, a) => f(...a)
|
|
4517
4573
|
});
|
|
4518
4574
|
(0, import_invariant14.invariant)(this._config, "config not set", {
|
|
4519
4575
|
F: __dxlog_file17,
|
|
4520
|
-
L:
|
|
4576
|
+
L: 221,
|
|
4521
4577
|
S: this,
|
|
4522
4578
|
A: [
|
|
4523
4579
|
"this._config",
|
|
@@ -4526,7 +4582,7 @@ var ClientServicesHost = class {
|
|
|
4526
4582
|
});
|
|
4527
4583
|
(0, import_invariant14.invariant)(this._storage, "storage not set", {
|
|
4528
4584
|
F: __dxlog_file17,
|
|
4529
|
-
L:
|
|
4585
|
+
L: 222,
|
|
4530
4586
|
S: this,
|
|
4531
4587
|
A: [
|
|
4532
4588
|
"this._storage",
|
|
@@ -4535,7 +4591,7 @@ var ClientServicesHost = class {
|
|
|
4535
4591
|
});
|
|
4536
4592
|
(0, import_invariant14.invariant)(this._signalManager, "signal manager not set", {
|
|
4537
4593
|
F: __dxlog_file17,
|
|
4538
|
-
L:
|
|
4594
|
+
L: 223,
|
|
4539
4595
|
S: this,
|
|
4540
4596
|
A: [
|
|
4541
4597
|
"this._signalManager",
|
|
@@ -4544,7 +4600,7 @@ var ClientServicesHost = class {
|
|
|
4544
4600
|
});
|
|
4545
4601
|
(0, import_invariant14.invariant)(this._networkManager, "network manager not set", {
|
|
4546
4602
|
F: __dxlog_file17,
|
|
4547
|
-
L:
|
|
4603
|
+
L: 224,
|
|
4548
4604
|
S: this,
|
|
4549
4605
|
A: [
|
|
4550
4606
|
"this._networkManager",
|
|
@@ -4552,20 +4608,20 @@ var ClientServicesHost = class {
|
|
|
4552
4608
|
]
|
|
4553
4609
|
});
|
|
4554
4610
|
this._opening = true;
|
|
4555
|
-
import_log16.log
|
|
4556
|
-
lockKey:
|
|
4611
|
+
(0, import_log16.log)("opening...", {
|
|
4612
|
+
lockKey: this._resourceLock?.lockKey
|
|
4557
4613
|
}, {
|
|
4558
4614
|
F: __dxlog_file17,
|
|
4559
|
-
L:
|
|
4615
|
+
L: 227,
|
|
4560
4616
|
S: this,
|
|
4561
4617
|
C: (f, a) => f(...a)
|
|
4562
4618
|
});
|
|
4563
|
-
await
|
|
4619
|
+
await this._resourceLock?.acquire();
|
|
4564
4620
|
await this._loggingService.open();
|
|
4565
4621
|
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._modelFactory);
|
|
4566
4622
|
this._serviceRegistry.setServices({
|
|
4567
4623
|
SystemService: this._systemService,
|
|
4568
|
-
IdentityService: new IdentityServiceImpl(this._serviceContext),
|
|
4624
|
+
IdentityService: new IdentityServiceImpl((params) => this._serviceContext.createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring),
|
|
4569
4625
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
|
|
4570
4626
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
4571
4627
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
@@ -4575,6 +4631,7 @@ var ClientServicesHost = class {
|
|
|
4575
4631
|
DataService: new import_echo_pipeline4.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
|
|
4576
4632
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
4577
4633
|
LoggingService: this._loggingService,
|
|
4634
|
+
TracingService: this._tracingService,
|
|
4578
4635
|
// TODO(burdon): Move to new protobuf definitions.
|
|
4579
4636
|
DevtoolsHost: new DevtoolsServiceImpl({
|
|
4580
4637
|
events: new DevtoolsHostEvents(),
|
|
@@ -4582,16 +4639,16 @@ var ClientServicesHost = class {
|
|
|
4582
4639
|
context: this._serviceContext
|
|
4583
4640
|
})
|
|
4584
4641
|
});
|
|
4585
|
-
await this._serviceContext.open();
|
|
4642
|
+
await this._serviceContext.open(ctx);
|
|
4586
4643
|
this._opening = false;
|
|
4587
4644
|
this._open = true;
|
|
4588
4645
|
this._statusUpdate.emit();
|
|
4589
|
-
const deviceKey =
|
|
4590
|
-
import_log16.log
|
|
4646
|
+
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
4647
|
+
(0, import_log16.log)("opened", {
|
|
4591
4648
|
deviceKey
|
|
4592
4649
|
}, {
|
|
4593
4650
|
F: __dxlog_file17,
|
|
4594
|
-
L:
|
|
4651
|
+
L: 284,
|
|
4595
4652
|
S: this,
|
|
4596
4653
|
C: (f, a) => f(...a)
|
|
4597
4654
|
});
|
|
@@ -4599,22 +4656,21 @@ var ClientServicesHost = class {
|
|
|
4599
4656
|
id: traceId
|
|
4600
4657
|
}), {
|
|
4601
4658
|
F: __dxlog_file17,
|
|
4602
|
-
L:
|
|
4659
|
+
L: 285,
|
|
4603
4660
|
S: this,
|
|
4604
4661
|
C: (f, a) => f(...a)
|
|
4605
4662
|
});
|
|
4606
4663
|
}
|
|
4607
4664
|
async close() {
|
|
4608
|
-
var _a;
|
|
4609
4665
|
if (!this._open) {
|
|
4610
4666
|
return;
|
|
4611
4667
|
}
|
|
4612
|
-
const deviceKey =
|
|
4613
|
-
import_log16.log
|
|
4668
|
+
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
4669
|
+
(0, import_log16.log)("closing...", {
|
|
4614
4670
|
deviceKey
|
|
4615
4671
|
}, {
|
|
4616
4672
|
F: __dxlog_file17,
|
|
4617
|
-
L:
|
|
4673
|
+
L: 296,
|
|
4618
4674
|
S: this,
|
|
4619
4675
|
C: (f, a) => f(...a)
|
|
4620
4676
|
});
|
|
@@ -4625,37 +4681,36 @@ var ClientServicesHost = class {
|
|
|
4625
4681
|
await this._serviceContext.close();
|
|
4626
4682
|
this._open = false;
|
|
4627
4683
|
this._statusUpdate.emit();
|
|
4628
|
-
import_log16.log
|
|
4684
|
+
(0, import_log16.log)("closed", {
|
|
4629
4685
|
deviceKey
|
|
4630
4686
|
}, {
|
|
4631
4687
|
F: __dxlog_file17,
|
|
4632
|
-
L:
|
|
4688
|
+
L: 302,
|
|
4633
4689
|
S: this,
|
|
4634
4690
|
C: (f, a) => f(...a)
|
|
4635
4691
|
});
|
|
4636
4692
|
}
|
|
4637
4693
|
async reset() {
|
|
4638
|
-
var _a, _b, _c;
|
|
4639
4694
|
const traceId = import_keys12.PublicKey.random().toHex();
|
|
4640
4695
|
import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.begin({
|
|
4641
4696
|
id: traceId
|
|
4642
4697
|
}), {
|
|
4643
4698
|
F: __dxlog_file17,
|
|
4644
|
-
L:
|
|
4699
|
+
L: 307,
|
|
4645
4700
|
S: this,
|
|
4646
4701
|
C: (f, a) => f(...a)
|
|
4647
4702
|
});
|
|
4648
4703
|
(0, import_log16.log)("resetting...", void 0, {
|
|
4649
4704
|
F: __dxlog_file17,
|
|
4650
|
-
L:
|
|
4705
|
+
L: 309,
|
|
4651
4706
|
S: this,
|
|
4652
4707
|
C: (f, a) => f(...a)
|
|
4653
4708
|
});
|
|
4654
|
-
await
|
|
4709
|
+
await this._serviceContext?.close();
|
|
4655
4710
|
await this._storage.reset();
|
|
4656
4711
|
(0, import_log16.log)("reset", void 0, {
|
|
4657
4712
|
F: __dxlog_file17,
|
|
4658
|
-
L:
|
|
4713
|
+
L: 312,
|
|
4659
4714
|
S: this,
|
|
4660
4715
|
C: (f, a) => f(...a)
|
|
4661
4716
|
});
|
|
@@ -4663,19 +4718,30 @@ var ClientServicesHost = class {
|
|
|
4663
4718
|
id: traceId
|
|
4664
4719
|
}), {
|
|
4665
4720
|
F: __dxlog_file17,
|
|
4666
|
-
L:
|
|
4721
|
+
L: 313,
|
|
4667
4722
|
S: this,
|
|
4668
4723
|
C: (f, a) => f(...a)
|
|
4669
4724
|
});
|
|
4670
|
-
await
|
|
4725
|
+
await this._callbacks?.onReset?.();
|
|
4671
4726
|
}
|
|
4672
4727
|
};
|
|
4673
|
-
|
|
4674
|
-
|
|
4728
|
+
_ts_decorate7([
|
|
4729
|
+
import_tracing4.trace.info()
|
|
4730
|
+
], ClientServicesHost.prototype, "_opening", void 0);
|
|
4731
|
+
_ts_decorate7([
|
|
4732
|
+
import_tracing4.trace.info()
|
|
4733
|
+
], ClientServicesHost.prototype, "_open", void 0);
|
|
4734
|
+
_ts_decorate7([
|
|
4735
|
+
import_async17.synchronized,
|
|
4736
|
+
import_tracing4.trace.span()
|
|
4675
4737
|
], ClientServicesHost.prototype, "open", null);
|
|
4676
|
-
|
|
4677
|
-
import_async17.synchronized
|
|
4738
|
+
_ts_decorate7([
|
|
4739
|
+
import_async17.synchronized,
|
|
4740
|
+
import_tracing4.trace.span()
|
|
4678
4741
|
], ClientServicesHost.prototype, "close", null);
|
|
4742
|
+
ClientServicesHost = _ts_decorate7([
|
|
4743
|
+
import_tracing4.trace.resource()
|
|
4744
|
+
], ClientServicesHost);
|
|
4679
4745
|
|
|
4680
4746
|
// packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
|
|
4681
4747
|
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/testing/invitation-utils.ts";
|
|
@@ -4696,18 +4762,16 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4696
4762
|
const authCode = new import_async18.Trigger();
|
|
4697
4763
|
const hostObservable = createInvitation(host, options);
|
|
4698
4764
|
hostObservable.subscribe(async (hostInvitation) => {
|
|
4699
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
4700
4765
|
switch (hostInvitation.state) {
|
|
4701
4766
|
case import_services15.Invitation.State.CONNECTING: {
|
|
4702
|
-
if (
|
|
4767
|
+
if (hooks?.host?.onConnecting?.(hostObservable)) {
|
|
4703
4768
|
break;
|
|
4704
4769
|
}
|
|
4705
4770
|
const guestObservable = acceptInvitation(guest, hostInvitation);
|
|
4706
4771
|
guestObservable.subscribe(async (guestInvitation) => {
|
|
4707
|
-
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2;
|
|
4708
4772
|
switch (guestInvitation.state) {
|
|
4709
4773
|
case import_services15.Invitation.State.CONNECTING: {
|
|
4710
|
-
if (
|
|
4774
|
+
if (hooks?.guest?.onConnecting?.(guestObservable)) {
|
|
4711
4775
|
break;
|
|
4712
4776
|
}
|
|
4713
4777
|
(0, import_invariant15.invariant)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey), void 0, {
|
|
@@ -4722,22 +4786,22 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4722
4786
|
break;
|
|
4723
4787
|
}
|
|
4724
4788
|
case import_services15.Invitation.State.CONNECTED: {
|
|
4725
|
-
|
|
4789
|
+
hooks?.guest?.onConnected?.(guestObservable);
|
|
4726
4790
|
break;
|
|
4727
4791
|
}
|
|
4728
4792
|
case import_services15.Invitation.State.READY_FOR_AUTHENTICATION: {
|
|
4729
|
-
if (
|
|
4793
|
+
if (hooks?.guest?.onReady?.(guestObservable)) {
|
|
4730
4794
|
break;
|
|
4731
4795
|
}
|
|
4732
4796
|
await guestObservable.authenticate(await authCode.wait());
|
|
4733
4797
|
break;
|
|
4734
4798
|
}
|
|
4735
4799
|
case import_services15.Invitation.State.AUTHENTICATING: {
|
|
4736
|
-
|
|
4800
|
+
hooks?.guest?.onAuthenticating?.(guestObservable);
|
|
4737
4801
|
break;
|
|
4738
4802
|
}
|
|
4739
4803
|
case import_services15.Invitation.State.SUCCESS: {
|
|
4740
|
-
if (
|
|
4804
|
+
if (hooks?.guest?.onSuccess?.(guestObservable)) {
|
|
4741
4805
|
break;
|
|
4742
4806
|
}
|
|
4743
4807
|
guestComplete.wake({
|
|
@@ -4746,7 +4810,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4746
4810
|
break;
|
|
4747
4811
|
}
|
|
4748
4812
|
case import_services15.Invitation.State.CANCELLED: {
|
|
4749
|
-
if (
|
|
4813
|
+
if (hooks?.guest?.onCancelled?.(guestObservable)) {
|
|
4750
4814
|
break;
|
|
4751
4815
|
}
|
|
4752
4816
|
guestComplete.wake({
|
|
@@ -4755,7 +4819,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4755
4819
|
break;
|
|
4756
4820
|
}
|
|
4757
4821
|
case import_services15.Invitation.State.TIMEOUT: {
|
|
4758
|
-
if (
|
|
4822
|
+
if (hooks?.guest?.onTimeout?.(guestObservable)) {
|
|
4759
4823
|
return;
|
|
4760
4824
|
}
|
|
4761
4825
|
guestComplete.wake({
|
|
@@ -4764,8 +4828,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4764
4828
|
}
|
|
4765
4829
|
}
|
|
4766
4830
|
}, (error) => {
|
|
4767
|
-
|
|
4768
|
-
if ((_b2 = (_a2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _a2.onError) == null ? void 0 : _b2.call(_a2, guestObservable)) {
|
|
4831
|
+
if (hooks?.guest?.onError?.(guestObservable)) {
|
|
4769
4832
|
return;
|
|
4770
4833
|
}
|
|
4771
4834
|
guestComplete.wake({
|
|
@@ -4775,11 +4838,11 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4775
4838
|
break;
|
|
4776
4839
|
}
|
|
4777
4840
|
case import_services15.Invitation.State.CONNECTED: {
|
|
4778
|
-
|
|
4841
|
+
hooks?.host?.onConnected?.(hostObservable);
|
|
4779
4842
|
break;
|
|
4780
4843
|
}
|
|
4781
4844
|
case import_services15.Invitation.State.READY_FOR_AUTHENTICATION: {
|
|
4782
|
-
if (
|
|
4845
|
+
if (hooks?.host?.onReady?.(hostObservable)) {
|
|
4783
4846
|
break;
|
|
4784
4847
|
}
|
|
4785
4848
|
if (hostInvitation.authCode) {
|
|
@@ -4788,11 +4851,11 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4788
4851
|
break;
|
|
4789
4852
|
}
|
|
4790
4853
|
case import_services15.Invitation.State.AUTHENTICATING: {
|
|
4791
|
-
|
|
4854
|
+
hooks?.host?.onAuthenticating?.(hostObservable);
|
|
4792
4855
|
break;
|
|
4793
4856
|
}
|
|
4794
4857
|
case import_services15.Invitation.State.SUCCESS: {
|
|
4795
|
-
if (
|
|
4858
|
+
if (hooks?.host?.onSuccess?.(hostObservable)) {
|
|
4796
4859
|
break;
|
|
4797
4860
|
}
|
|
4798
4861
|
hostComplete.wake({
|
|
@@ -4801,7 +4864,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4801
4864
|
break;
|
|
4802
4865
|
}
|
|
4803
4866
|
case import_services15.Invitation.State.CANCELLED: {
|
|
4804
|
-
if (
|
|
4867
|
+
if (hooks?.host?.onCancelled?.(hostObservable)) {
|
|
4805
4868
|
break;
|
|
4806
4869
|
}
|
|
4807
4870
|
hostComplete.wake({
|
|
@@ -4810,7 +4873,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4810
4873
|
break;
|
|
4811
4874
|
}
|
|
4812
4875
|
case import_services15.Invitation.State.TIMEOUT: {
|
|
4813
|
-
if (
|
|
4876
|
+
if (hooks?.host?.onTimeout?.(hostObservable)) {
|
|
4814
4877
|
break;
|
|
4815
4878
|
}
|
|
4816
4879
|
hostComplete.wake({
|
|
@@ -4820,8 +4883,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4820
4883
|
}
|
|
4821
4884
|
}
|
|
4822
4885
|
}, (error) => {
|
|
4823
|
-
|
|
4824
|
-
if ((_b = (_a = hooks == null ? void 0 : hooks.host) == null ? void 0 : _a.onError) == null ? void 0 : _b.call(_a, hostObservable)) {
|
|
4886
|
+
if (hooks?.host?.onError?.(hostObservable)) {
|
|
4825
4887
|
return;
|
|
4826
4888
|
}
|
|
4827
4889
|
hostComplete.wake({
|
|
@@ -4834,9 +4896,9 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4834
4896
|
];
|
|
4835
4897
|
};
|
|
4836
4898
|
var createInvitation = (host, options) => {
|
|
4837
|
-
options
|
|
4899
|
+
options ??= {
|
|
4838
4900
|
authMethod: import_services15.Invitation.AuthMethod.NONE,
|
|
4839
|
-
...options
|
|
4901
|
+
...options ?? {}
|
|
4840
4902
|
};
|
|
4841
4903
|
if (host instanceof ServiceContext) {
|
|
4842
4904
|
const hostHandler = host.getInvitationHandler({
|
|
@@ -4859,7 +4921,7 @@ var acceptInvitation = (guest, invitation) => {
|
|
|
4859
4921
|
};
|
|
4860
4922
|
|
|
4861
4923
|
// packages/sdk/client-services/src/packlets/testing/test-builder.ts
|
|
4862
|
-
var
|
|
4924
|
+
var import_context11 = require("@dxos/context");
|
|
4863
4925
|
var import_credentials16 = require("@dxos/credentials");
|
|
4864
4926
|
var import_debug8 = require("@dxos/debug");
|
|
4865
4927
|
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
@@ -4894,7 +4956,7 @@ var createPeers = async (numPeers) => {
|
|
|
4894
4956
|
const peer = createServiceContext({
|
|
4895
4957
|
signalContext
|
|
4896
4958
|
});
|
|
4897
|
-
await peer.open();
|
|
4959
|
+
await peer.open(new import_context11.Context());
|
|
4898
4960
|
return peer;
|
|
4899
4961
|
}));
|
|
4900
4962
|
};
|
|
@@ -4909,7 +4971,7 @@ var syncItemsLocal = async (db1, db2) => {
|
|
|
4909
4971
|
var TestBuilder = class {
|
|
4910
4972
|
constructor() {
|
|
4911
4973
|
this.signalContext = new import_messaging2.MemorySignalManagerContext();
|
|
4912
|
-
this._ctx = new
|
|
4974
|
+
this._ctx = new import_context11.Context();
|
|
4913
4975
|
}
|
|
4914
4976
|
createPeer(peerOptions) {
|
|
4915
4977
|
const peer = new TestPeer(this.signalContext, peerOptions);
|
|
@@ -4932,18 +4994,15 @@ var TestPeer = class {
|
|
|
4932
4994
|
return this._props;
|
|
4933
4995
|
}
|
|
4934
4996
|
get storage() {
|
|
4935
|
-
|
|
4936
|
-
return (_b = (_a = this._props).storage) != null ? _b : _a.storage = (0, import_random_access_storage2.createStorage)({
|
|
4997
|
+
return this._props.storage ??= (0, import_random_access_storage2.createStorage)({
|
|
4937
4998
|
type: this.opts.storageType
|
|
4938
4999
|
});
|
|
4939
5000
|
}
|
|
4940
5001
|
get keyring() {
|
|
4941
|
-
|
|
4942
|
-
return (_b = (_a = this._props).keyring) != null ? _b : _a.keyring = new import_keyring2.Keyring(this.storage.createDirectory("keyring"));
|
|
5002
|
+
return this._props.keyring ??= new import_keyring2.Keyring(this.storage.createDirectory("keyring"));
|
|
4943
5003
|
}
|
|
4944
5004
|
get feedStore() {
|
|
4945
|
-
|
|
4946
|
-
return (_b = (_a = this._props).feedStore) != null ? _b : _a.feedStore = new import_feed_store5.FeedStore({
|
|
5005
|
+
return this._props.feedStore ??= new import_feed_store5.FeedStore({
|
|
4947
5006
|
factory: new import_feed_store5.FeedFactory({
|
|
4948
5007
|
root: this.storage.createDirectory("feeds"),
|
|
4949
5008
|
signer: this.keyring,
|
|
@@ -4954,27 +5013,22 @@ var TestPeer = class {
|
|
|
4954
5013
|
});
|
|
4955
5014
|
}
|
|
4956
5015
|
get metadataStore() {
|
|
4957
|
-
|
|
4958
|
-
return (_b = (_a = this._props).metadataStore) != null ? _b : _a.metadataStore = new import_echo_pipeline5.MetadataStore(this.storage.createDirectory("metadata"));
|
|
5016
|
+
return this._props.metadataStore ??= new import_echo_pipeline5.MetadataStore(this.storage.createDirectory("metadata"));
|
|
4959
5017
|
}
|
|
4960
5018
|
get blobStore() {
|
|
4961
|
-
|
|
4962
|
-
return (_b = (_a = this._props).blobStore) != null ? _b : _a.blobStore = new import_teleport_extension_object_sync2.BlobStore(this.storage.createDirectory("blobs"));
|
|
5019
|
+
return this._props.blobStore ??= new import_teleport_extension_object_sync2.BlobStore(this.storage.createDirectory("blobs"));
|
|
4963
5020
|
}
|
|
4964
5021
|
get snapshotStore() {
|
|
4965
|
-
|
|
4966
|
-
return (_b = (_a = this._props).snapshotStore) != null ? _b : _a.snapshotStore = new import_echo_pipeline5.SnapshotStore(this.storage.createDirectory("snapshots"));
|
|
5022
|
+
return this._props.snapshotStore ??= new import_echo_pipeline5.SnapshotStore(this.storage.createDirectory("snapshots"));
|
|
4967
5023
|
}
|
|
4968
5024
|
get networkManager() {
|
|
4969
|
-
|
|
4970
|
-
return (_b = (_a = this._props).networkManager) != null ? _b : _a.networkManager = new import_network_manager3.NetworkManager({
|
|
5025
|
+
return this._props.networkManager ??= new import_network_manager3.NetworkManager({
|
|
4971
5026
|
signalManager: new import_messaging2.MemorySignalManager(this.signalContext),
|
|
4972
5027
|
transportFactory: import_network_manager3.MemoryTransportFactory
|
|
4973
5028
|
});
|
|
4974
5029
|
}
|
|
4975
5030
|
get spaceManager() {
|
|
4976
|
-
|
|
4977
|
-
return (_b = (_a = this._props).spaceManager) != null ? _b : _a.spaceManager = new import_echo_pipeline5.SpaceManager({
|
|
5031
|
+
return this._props.spaceManager ??= new import_echo_pipeline5.SpaceManager({
|
|
4978
5032
|
feedStore: this.feedStore,
|
|
4979
5033
|
networkManager: this.networkManager,
|
|
4980
5034
|
metadataStore: this.metadataStore,
|
|
@@ -4984,16 +5038,13 @@ var TestPeer = class {
|
|
|
4984
5038
|
});
|
|
4985
5039
|
}
|
|
4986
5040
|
get identity() {
|
|
4987
|
-
|
|
4988
|
-
return (_a = this._props.signingContext) != null ? _a : (0, import_debug8.failUndefined)();
|
|
5041
|
+
return this._props.signingContext ?? (0, import_debug8.failUndefined)();
|
|
4989
5042
|
}
|
|
4990
5043
|
get dataSpaceManager() {
|
|
4991
|
-
|
|
4992
|
-
return (_b = (_a = this._props).dataSpaceManager) != null ? _b : _a.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, new import_echo_pipeline5.DataServiceSubscriptions(), this.keyring, this.identity, this.feedStore);
|
|
5044
|
+
return this._props.dataSpaceManager ??= new DataSpaceManager(this.spaceManager, this.metadataStore, new import_echo_pipeline5.DataServiceSubscriptions(), this.keyring, this.identity, this.feedStore);
|
|
4993
5045
|
}
|
|
4994
5046
|
async createIdentity() {
|
|
4995
|
-
|
|
4996
|
-
(_b = (_a = this._props).signingContext) != null ? _b : _a.signingContext = await createSigningContext(this.keyring);
|
|
5047
|
+
this._props.signingContext ??= await createSigningContext(this.keyring);
|
|
4997
5048
|
}
|
|
4998
5049
|
async destroy() {
|
|
4999
5050
|
await this.storage.reset();
|