@dxos/client-services 0.1.56-main.738e1fa → 0.1.56-main.76a8709

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