@dxos/client-services 0.5.9-main.8359215 → 0.5.9-main.bdf733d

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 (43) hide show
  1. package/dist/lib/browser/{chunk-QNCZI356.mjs → chunk-KNGR7BYM.mjs} +1109 -1109
  2. package/dist/lib/browser/chunk-KNGR7BYM.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +55 -363
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +1 -1
  7. package/dist/lib/node/{chunk-ELQ5XXZX.cjs → chunk-WWHTBQNR.cjs} +1126 -1126
  8. package/dist/lib/node/chunk-WWHTBQNR.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +93 -396
  10. package/dist/lib/node/index.cjs.map +4 -4
  11. package/dist/lib/node/meta.json +1 -1
  12. package/dist/lib/node/packlets/testing/index.cjs +8 -8
  13. package/dist/types/src/index.d.ts +3 -3
  14. package/dist/types/src/index.d.ts.map +1 -1
  15. package/dist/types/src/packlets/worker/index.d.ts +3 -0
  16. package/dist/types/src/packlets/worker/index.d.ts.map +1 -0
  17. package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -0
  18. package/dist/types/src/packlets/worker/worker-session.d.ts.map +1 -0
  19. package/dist/types/src/version.d.ts +1 -1
  20. package/package.json +36 -36
  21. package/src/index.ts +3 -3
  22. package/src/packlets/worker/index.ts +6 -0
  23. package/src/version.ts +1 -1
  24. package/dist/lib/browser/chunk-QNCZI356.mjs.map +0 -7
  25. package/dist/lib/node/chunk-ELQ5XXZX.cjs.map +0 -7
  26. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +0 -37
  27. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +0 -1
  28. package/dist/types/src/packlets/vault/index.d.ts +0 -6
  29. package/dist/types/src/packlets/vault/index.d.ts.map +0 -1
  30. package/dist/types/src/packlets/vault/shared-worker-connection.d.ts +0 -36
  31. package/dist/types/src/packlets/vault/shared-worker-connection.d.ts.map +0 -1
  32. package/dist/types/src/packlets/vault/shell-runtime.d.ts +0 -33
  33. package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +0 -1
  34. package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +0 -1
  35. package/dist/types/src/packlets/vault/worker-session.d.ts.map +0 -1
  36. package/src/packlets/vault/iframe-host-runtime.ts +0 -130
  37. package/src/packlets/vault/index.ts +0 -9
  38. package/src/packlets/vault/shared-worker-connection.ts +0 -115
  39. package/src/packlets/vault/shell-runtime.ts +0 -111
  40. /package/dist/types/src/packlets/{vault → worker}/worker-runtime.d.ts +0 -0
  41. /package/dist/types/src/packlets/{vault → worker}/worker-session.d.ts +0 -0
  42. /package/src/packlets/{vault → worker}/worker-runtime.ts +0 -0
  43. /package/src/packlets/{vault → worker}/worker-session.ts +0 -0
@@ -345,13 +345,349 @@ var DevtoolsServiceImpl = class {
345
345
  }
346
346
  };
347
347
 
348
- // packages/sdk/client-services/src/packlets/identity/authenticator.ts
348
+ // packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts
349
+ import { asyncTimeout } from "@dxos/async";
350
+ import { getFirstStreamValue } from "@dxos/codec-protobuf";
351
+ import { credentialTypeFilter } from "@dxos/credentials";
352
+ import { invariant } from "@dxos/invariant";
353
+ import { STORAGE_VERSION } from "@dxos/protocols";
354
+ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
355
+ import { TRACE_PROCESSOR } from "@dxos/tracing";
356
+
357
+ // packages/sdk/client-services/src/version.ts
358
+ var DXOS_VERSION = "0.5.9-main.bdf733d";
359
+
360
+ // packages/sdk/client-services/src/packlets/services/platform.ts
361
+ import { Platform } from "@dxos/protocols/proto/dxos/client/services";
362
+ var getPlatform = () => {
363
+ if (process.browser) {
364
+ if (typeof window !== "undefined") {
365
+ const { userAgent } = window.navigator;
366
+ return {
367
+ type: Platform.PLATFORM_TYPE.BROWSER,
368
+ userAgent,
369
+ uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
370
+ };
371
+ } else {
372
+ return {
373
+ type: Platform.PLATFORM_TYPE.SHARED_WORKER,
374
+ uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
375
+ };
376
+ }
377
+ } else {
378
+ const { platform: platform2, version, arch } = process;
379
+ return {
380
+ type: Platform.PLATFORM_TYPE.NODE,
381
+ platform: platform2,
382
+ arch,
383
+ runtime: version,
384
+ uptime: Math.floor(process.uptime()),
385
+ memory: process.memoryUsage()
386
+ };
387
+ }
388
+ };
389
+
390
+ // packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts
391
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
392
+ var DEFAULT_TIMEOUT = 1e3;
393
+ var createDiagnostics = async (clientServices, serviceContext, config) => {
394
+ const diagnostics = {
395
+ created: (/* @__PURE__ */ new Date()).toISOString(),
396
+ platform: getPlatform(),
397
+ client: {
398
+ version: DXOS_VERSION,
399
+ storage: {
400
+ version: STORAGE_VERSION
401
+ }
402
+ },
403
+ trace: TRACE_PROCESSOR.getDiagnostics()
404
+ };
405
+ await Promise.all([
406
+ (async () => {
407
+ invariant(clientServices.LoggingService, "SystemService is not available.", {
408
+ F: __dxlog_file,
409
+ L: 110,
410
+ S: void 0,
411
+ A: [
412
+ "clientServices.LoggingService",
413
+ "'SystemService is not available.'"
414
+ ]
415
+ });
416
+ diagnostics.metrics = await getFirstStreamValue(clientServices.LoggingService.queryMetrics({}), {
417
+ timeout: DEFAULT_TIMEOUT
418
+ }).catch(() => void 0);
419
+ })(),
420
+ (async () => {
421
+ diagnostics.storage = await asyncTimeout(getStorageDiagnostics(), DEFAULT_TIMEOUT).catch(() => void 0);
422
+ })(),
423
+ async () => {
424
+ const identity = serviceContext.identityManager.identity;
425
+ if (identity) {
426
+ diagnostics.identity = {
427
+ identityKey: identity.identityKey,
428
+ spaceKey: identity.space.key,
429
+ profile: identity.profileDocument
430
+ };
431
+ const { devices } = await getFirstStreamValue(clientServices.DevicesService.queryDevices(), {
432
+ timeout: DEFAULT_TIMEOUT
433
+ }).catch(() => void 0) ?? {};
434
+ diagnostics.devices = devices;
435
+ if (serviceContext.dataSpaceManager) {
436
+ diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
437
+ }
438
+ const { feeds = [] } = await getFirstStreamValue(clientServices.DevtoolsHost.subscribeToFeeds({}), {
439
+ timeout: DEFAULT_TIMEOUT
440
+ }).catch(() => void 0) ?? {};
441
+ diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
442
+ feedKey,
443
+ bytes,
444
+ length
445
+ }));
446
+ const status = await getFirstStreamValue(clientServices.NetworkService.queryStatus(), {
447
+ timeout: DEFAULT_TIMEOUT
448
+ }).catch(() => void 0);
449
+ diagnostics.networkStatus = status;
450
+ diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
451
+ }
452
+ }
453
+ ]);
454
+ diagnostics.config = config.values;
455
+ return diagnostics;
456
+ };
457
+ var getSpaceStats = async (space) => {
458
+ const stats = {
459
+ key: space.key,
460
+ metrics: space.metrics,
461
+ epochs: space.inner.spaceState.credentials.filter(credentialTypeFilter("dxos.halo.credentials.Epoch")).map((credential) => ({
462
+ ...credential.subject.assertion,
463
+ id: credential.id
464
+ })),
465
+ members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
466
+ role: member.role,
467
+ identity: {
468
+ identityKey: member.key,
469
+ profile: {
470
+ displayName: member.assertion.profile?.displayName
471
+ }
472
+ },
473
+ presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember.PresenceState.ONLINE : SpaceMember.PresenceState.OFFLINE
474
+ })),
475
+ pipeline: {
476
+ // TODO(burdon): Pick properties from credentials if needed.
477
+ currentEpoch: space.automergeSpaceState.lastEpoch,
478
+ appliedEpoch: space.automergeSpaceState.lastEpoch,
479
+ controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
480
+ currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
481
+ targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
482
+ totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
483
+ }
484
+ };
485
+ if (stats.metrics) {
486
+ const { open, ready } = stats.metrics;
487
+ stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
488
+ }
489
+ return stats;
490
+ };
491
+ var getStorageDiagnostics = async () => {
492
+ if (typeof navigator === "undefined" || !navigator.storage) {
493
+ return void 0;
494
+ }
495
+ const map = /* @__PURE__ */ new Map();
496
+ const dir = await navigator.storage.getDirectory();
497
+ for await (const filename of dir?.keys()) {
498
+ const idx = filename.indexOf("-", filename.indexOf("-") + 1);
499
+ if (idx === -1) {
500
+ continue;
501
+ }
502
+ map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
503
+ }
504
+ return Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
505
+ file,
506
+ count
507
+ }));
508
+ };
509
+
510
+ // packages/sdk/client-services/src/packlets/diagnostics/browser-diagnostics-broadcast.ts
349
511
  import { Trigger } from "@dxos/async";
512
+ import { log } from "@dxos/log";
513
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/browser-diagnostics-broadcast.ts";
514
+ var CHANNEL_NAME = "dxos.diagnostics.broadcast";
515
+ var MessageType;
516
+ (function(MessageType2) {
517
+ MessageType2["PROBE"] = "probe";
518
+ MessageType2["PROBE_ACK"] = "probe-ack";
519
+ MessageType2["REQUEST_DIAGNOSTICS"] = "request-diagnostics";
520
+ MessageType2["RECEIVE_DIAGNOSTICS"] = "receive-diagnostics";
521
+ })(MessageType || (MessageType = {}));
522
+ var createCollectDiagnosticsBroadcastSender = () => {
523
+ return {
524
+ broadcastDiagnosticsRequest: async () => {
525
+ let expectedResponse = "probe-ack";
526
+ let channel;
527
+ try {
528
+ const trigger = new Trigger();
529
+ channel = new BroadcastChannel(CHANNEL_NAME);
530
+ channel.onmessage = (msg) => {
531
+ if (expectedResponse === msg.data.type) {
532
+ trigger.wake(msg.data);
533
+ }
534
+ };
535
+ channel.postMessage({
536
+ type: "probe"
537
+ });
538
+ await trigger.wait({
539
+ timeout: 200
540
+ });
541
+ expectedResponse = "receive-diagnostics";
542
+ trigger.reset();
543
+ channel.postMessage({
544
+ type: "request-diagnostics"
545
+ });
546
+ const diagnostics = await trigger.wait({
547
+ timeout: 5e3
548
+ });
549
+ return diagnostics.payload;
550
+ } catch (e) {
551
+ const errorDescription = e instanceof Error ? e.message : JSON.stringify(e);
552
+ return {
553
+ expectedResponse,
554
+ errorDescription
555
+ };
556
+ } finally {
557
+ safeClose(channel);
558
+ }
559
+ }
560
+ };
561
+ };
562
+ var createCollectDiagnosticsBroadcastHandler = (systemService) => {
563
+ let channel;
564
+ return {
565
+ start: () => {
566
+ channel = new BroadcastChannel(CHANNEL_NAME);
567
+ channel.onmessage = async (message) => {
568
+ try {
569
+ if (message.data.type === "probe") {
570
+ channel?.postMessage({
571
+ type: "probe-ack"
572
+ });
573
+ } else if (message.data.type === "request-diagnostics") {
574
+ const diagnostics = await systemService.getDiagnostics({});
575
+ channel?.postMessage({
576
+ type: "receive-diagnostics",
577
+ payload: diagnostics
578
+ });
579
+ }
580
+ } catch (error) {
581
+ log.catch(error, void 0, {
582
+ F: __dxlog_file2,
583
+ L: 77,
584
+ S: void 0,
585
+ C: (f, a) => f(...a)
586
+ });
587
+ }
588
+ };
589
+ },
590
+ stop: () => {
591
+ safeClose(channel);
592
+ channel = void 0;
593
+ }
594
+ };
595
+ };
596
+ var safeClose = (channel) => {
597
+ try {
598
+ channel?.close();
599
+ } catch (e) {
600
+ }
601
+ };
602
+
603
+ // packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
604
+ import { Stream as Stream7 } from "@dxos/codec-protobuf";
605
+ import { raise } from "@dxos/debug";
606
+ import { parseMethodName, RpcPeer } from "@dxos/rpc";
607
+ import { MapCounter, trace } from "@dxos/tracing";
608
+ function _ts_decorate(decorators, target, key, desc) {
609
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
610
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
611
+ r = Reflect.decorate(decorators, target, key, desc);
612
+ else
613
+ for (var i = decorators.length - 1; i >= 0; i--)
614
+ if (d = decorators[i])
615
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
616
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
617
+ }
618
+ var ClientRpcServer = class {
619
+ constructor(params) {
620
+ this._handlerCache = /* @__PURE__ */ new Map();
621
+ this._callMetrics = new MapCounter();
622
+ const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
623
+ this._handleCall = handleCall;
624
+ this._handleStream = handleStream;
625
+ this._serviceRegistry = serviceRegistry;
626
+ this._rpcPeer = new RpcPeer({
627
+ ...rpcOptions,
628
+ callHandler: (method, params2) => {
629
+ const [serviceName, methodName] = parseMethodName(method);
630
+ const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
631
+ this._callMetrics.inc(`${serviceName}.${methodName} request`);
632
+ if (this._handleCall) {
633
+ return this._handleCall(methodName, params2, handler);
634
+ } else {
635
+ return handler(methodName, params2);
636
+ }
637
+ },
638
+ streamHandler: (method, params2) => {
639
+ const [serviceName, methodName] = parseMethodName(method);
640
+ const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
641
+ this._callMetrics.inc(`${serviceName}.${methodName} request stream`);
642
+ if (this._handleStream) {
643
+ return Stream7.map(Stream7.unwrapPromise(this._handleStream(methodName, params2, handler)), (data) => {
644
+ this._callMetrics.inc(`${serviceName}.${methodName} response stream`);
645
+ return data;
646
+ });
647
+ } else {
648
+ return handler(methodName, params2);
649
+ }
650
+ }
651
+ });
652
+ }
653
+ get _services() {
654
+ return Object.keys(this._serviceRegistry.services);
655
+ }
656
+ async open() {
657
+ await this._rpcPeer.open();
658
+ }
659
+ async close() {
660
+ await this._rpcPeer.close();
661
+ }
662
+ _getServiceHandler(serviceName) {
663
+ if (!this._handlerCache.has(serviceName)) {
664
+ const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? raise(new Error(`Service not available: ${serviceName}`));
665
+ const service = this._serviceRegistry.services[key];
666
+ if (!service) {
667
+ throw new Error(`Service not available: ${serviceName}`);
668
+ }
669
+ this._handlerCache.set(serviceName, descriptor.createServer(service));
670
+ }
671
+ return this._handlerCache.get(serviceName);
672
+ }
673
+ };
674
+ _ts_decorate([
675
+ trace.metricsCounter()
676
+ ], ClientRpcServer.prototype, "_callMetrics", void 0);
677
+ _ts_decorate([
678
+ trace.info()
679
+ ], ClientRpcServer.prototype, "_services", null);
680
+ ClientRpcServer = _ts_decorate([
681
+ trace.resource()
682
+ ], ClientRpcServer);
683
+
684
+ // packages/sdk/client-services/src/packlets/identity/authenticator.ts
685
+ import { Trigger as Trigger2 } from "@dxos/async";
350
686
  import { Context as Context2 } from "@dxos/context";
351
687
  import { verifyCredential } from "@dxos/credentials";
352
- import { log } from "@dxos/log";
688
+ import { log as log2 } from "@dxos/log";
353
689
  import { schema } from "@dxos/protocols";
354
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
690
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
355
691
  var Credential = schema.getCodecForType("dxos.halo.credentials.Credential");
356
692
  var createAuthProvider = (signer) => async (nonce) => {
357
693
  const credential = await signer.createCredential({
@@ -374,20 +710,20 @@ var TrustedKeySetAuthVerifier = class {
374
710
  get verifier() {
375
711
  return async (nonce, auth) => {
376
712
  const credential = Credential.decode(auth);
377
- log("authenticating...", {
713
+ log2("authenticating...", {
378
714
  credential
379
715
  }, {
380
- F: __dxlog_file,
716
+ F: __dxlog_file3,
381
717
  L: 56,
382
718
  S: this,
383
719
  C: (f, a) => f(...a)
384
720
  });
385
721
  const result = await verifyCredential(credential);
386
722
  if (result.kind === "fail") {
387
- log("Invalid credential", {
723
+ log2("Invalid credential", {
388
724
  result
389
725
  }, {
390
- F: __dxlog_file,
726
+ F: __dxlog_file3,
391
727
  L: 60,
392
728
  S: this,
393
729
  C: (f, a) => f(...a)
@@ -395,11 +731,11 @@ var TrustedKeySetAuthVerifier = class {
395
731
  return false;
396
732
  }
397
733
  if (!credential.proof.nonce || !Buffer.from(nonce).equals(credential.proof.nonce)) {
398
- log("Invalid nonce", {
734
+ log2("Invalid nonce", {
399
735
  nonce,
400
736
  credential
401
737
  }, {
402
- F: __dxlog_file,
738
+ F: __dxlog_file3,
403
739
  L: 65,
404
740
  S: this,
405
741
  C: (f, a) => f(...a)
@@ -407,36 +743,36 @@ var TrustedKeySetAuthVerifier = class {
407
743
  return false;
408
744
  }
409
745
  if (this._isTrustedKey(credential.issuer)) {
410
- log("key is not currently in trusted set, waiting...", {
746
+ log2("key is not currently in trusted set, waiting...", {
411
747
  key: credential.issuer
412
748
  }, {
413
- F: __dxlog_file,
749
+ F: __dxlog_file3,
414
750
  L: 70,
415
751
  S: this,
416
752
  C: (f, a) => f(...a)
417
753
  });
418
754
  return true;
419
755
  }
420
- const trigger = new Trigger();
756
+ const trigger = new Trigger2();
421
757
  this._ctx.onDispose(() => {
422
758
  trigger.wake(false);
423
759
  });
424
760
  const clear = this._params.update.on(this._ctx, () => {
425
761
  if (this._isTrustedKey(credential.issuer)) {
426
- log("auth success", {
762
+ log2("auth success", {
427
763
  key: credential.issuer
428
764
  }, {
429
- F: __dxlog_file,
765
+ F: __dxlog_file3,
430
766
  L: 81,
431
767
  S: this,
432
768
  C: (f, a) => f(...a)
433
769
  });
434
770
  trigger.wake(true);
435
771
  } else {
436
- log("key is not currently in trusted set, waiting...", {
772
+ log2("key is not currently in trusted set, waiting...", {
437
773
  key: credential.issuer
438
774
  }, {
439
- F: __dxlog_file,
775
+ F: __dxlog_file3,
440
776
  L: 84,
441
777
  S: this,
442
778
  C: (f, a) => f(...a)
@@ -465,13 +801,13 @@ import { Event } from "@dxos/async";
465
801
  import { AUTH_TIMEOUT, LOAD_CONTROL_FEEDS_TIMEOUT } from "@dxos/client-protocol";
466
802
  import { DeviceStateMachine, createCredentialSignerWithKey, createCredentialSignerWithChain, ProfileStateMachine } from "@dxos/credentials";
467
803
  import { writeMessages } from "@dxos/feed-store";
468
- import { invariant } from "@dxos/invariant";
804
+ import { invariant as invariant2 } from "@dxos/invariant";
469
805
  import { PublicKey as PublicKey3 } from "@dxos/keys";
470
- import { log as log2 } from "@dxos/log";
806
+ import { log as log3 } from "@dxos/log";
471
807
  import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
472
- import { trace } from "@dxos/tracing";
808
+ import { trace as trace2 } from "@dxos/tracing";
473
809
  import { ComplexSet } from "@dxos/util";
474
- function _ts_decorate(decorators, target, key, desc) {
810
+ function _ts_decorate2(decorators, target, key, desc) {
475
811
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
476
812
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
477
813
  r = Reflect.decorate(decorators, target, key, desc);
@@ -481,7 +817,7 @@ function _ts_decorate(decorators, target, key, desc) {
481
817
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
482
818
  return c > 3 && r && Object.defineProperty(target, key, r), r;
483
819
  }
484
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
820
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
485
821
  var Identity = class {
486
822
  constructor({ space, signer, identityKey, deviceKey, presence }) {
487
823
  this.stateUpdate = new Event();
@@ -490,10 +826,10 @@ var Identity = class {
490
826
  this._presence = presence;
491
827
  this.identityKey = identityKey;
492
828
  this.deviceKey = deviceKey;
493
- log2.trace("dxos.halo.device", {
829
+ log3.trace("dxos.halo.device", {
494
830
  deviceKey
495
831
  }, {
496
- F: __dxlog_file2,
832
+ F: __dxlog_file4,
497
833
  L: 67,
498
834
  S: this,
499
835
  C: (f, a) => f(...a)
@@ -561,8 +897,8 @@ var Identity = class {
561
897
  * Requires identity to be ready.
562
898
  */
563
899
  getIdentityCredentialSigner() {
564
- invariant(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
565
- F: __dxlog_file2,
900
+ invariant2(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
901
+ F: __dxlog_file4,
566
902
  L: 145,
567
903
  S: this,
568
904
  A: [
@@ -579,14 +915,14 @@ var Identity = class {
579
915
  return createCredentialSignerWithKey(this._signer, this.deviceKey);
580
916
  }
581
917
  async admitDevice({ deviceKey, controlFeedKey, dataFeedKey }) {
582
- log2("Admitting device:", {
918
+ log3("Admitting device:", {
583
919
  identityKey: this.identityKey,
584
920
  hostDevice: this.deviceKey,
585
921
  deviceKey,
586
922
  controlFeedKey,
587
923
  dataFeedKey
588
924
  }, {
589
- F: __dxlog_file2,
925
+ F: __dxlog_file4,
590
926
  L: 161,
591
927
  S: this,
592
928
  C: (f, a) => f(...a)
@@ -628,14 +964,14 @@ var Identity = class {
628
964
  })));
629
965
  }
630
966
  };
631
- _ts_decorate([
632
- trace.span()
967
+ _ts_decorate2([
968
+ trace2.span()
633
969
  ], Identity.prototype, "open", null);
634
- _ts_decorate([
635
- trace.span()
970
+ _ts_decorate2([
971
+ trace2.span()
636
972
  ], Identity.prototype, "close", null);
637
- Identity = _ts_decorate([
638
- trace.resource()
973
+ Identity = _ts_decorate2([
974
+ trace2.resource()
639
975
  ], Identity);
640
976
 
641
977
  // packages/sdk/client-services/src/packlets/identity/identity-manager.ts
@@ -643,17 +979,17 @@ import platform from "platform";
643
979
  import { Event as Event2 } from "@dxos/async";
644
980
  import { Context as Context3 } from "@dxos/context";
645
981
  import { createCredentialSignerWithKey as createCredentialSignerWithKey2, CredentialGenerator } from "@dxos/credentials";
646
- import { invariant as invariant2 } from "@dxos/invariant";
982
+ import { invariant as invariant3 } from "@dxos/invariant";
647
983
  import { PublicKey as PublicKey4 } from "@dxos/keys";
648
- import { log as log3 } from "@dxos/log";
649
- import { trace as trace2 } from "@dxos/protocols";
984
+ import { log as log4 } from "@dxos/log";
985
+ import { trace as trace3 } from "@dxos/protocols";
650
986
  import { Device, DeviceKind } from "@dxos/protocols/proto/dxos/client/services";
651
987
  import { AdmittedFeed as AdmittedFeed2, DeviceType } from "@dxos/protocols/proto/dxos/halo/credentials";
652
988
  import { Gossip, Presence } from "@dxos/teleport-extension-gossip";
653
989
  import { Timeframe } from "@dxos/timeframe";
654
990
  import { trace as Trace } from "@dxos/tracing";
655
991
  import { isNode, deferFunction } from "@dxos/util";
656
- function _ts_decorate2(decorators, target, key, desc) {
992
+ function _ts_decorate3(decorators, target, key, desc) {
657
993
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
658
994
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
659
995
  r = Reflect.decorate(decorators, target, key, desc);
@@ -663,7 +999,7 @@ function _ts_decorate2(decorators, target, key, desc) {
663
999
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
664
1000
  return c > 3 && r && Object.defineProperty(target, key, r), r;
665
1001
  }
666
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
1002
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
667
1003
  var DEVICE_PRESENCE_ANNOUNCE_INTERVAL = 1e4;
668
1004
  var DEVICE_PRESENCE_OFFLINE_TIMEOUT = 2e4;
669
1005
  var IdentityManager = class {
@@ -684,19 +1020,19 @@ var IdentityManager = class {
684
1020
  }
685
1021
  async open(ctx) {
686
1022
  const traceId = PublicKey4.random().toHex();
687
- log3.trace("dxos.halo.identity-manager.open", trace2.begin({
1023
+ log4.trace("dxos.halo.identity-manager.open", trace3.begin({
688
1024
  id: traceId
689
1025
  }), {
690
- F: __dxlog_file3,
1026
+ F: __dxlog_file5,
691
1027
  L: 104,
692
1028
  S: this,
693
1029
  C: (f, a) => f(...a)
694
1030
  });
695
1031
  const identityRecord = this._metadataStore.getIdentityRecord();
696
- log3("identity record", {
1032
+ log4("identity record", {
697
1033
  identityRecord
698
1034
  }, {
699
- F: __dxlog_file3,
1035
+ F: __dxlog_file5,
700
1036
  L: 107,
701
1037
  S: this,
702
1038
  C: (f, a) => f(...a)
@@ -705,21 +1041,21 @@ var IdentityManager = class {
705
1041
  this._identity = await this._constructIdentity(identityRecord);
706
1042
  await this._identity.open(ctx);
707
1043
  await this._identity.ready();
708
- log3.trace("dxos.halo.identity", {
1044
+ log4.trace("dxos.halo.identity", {
709
1045
  identityKey: identityRecord.identityKey,
710
1046
  displayName: this._identity.profileDocument?.displayName
711
1047
  }, {
712
- F: __dxlog_file3,
1048
+ F: __dxlog_file5,
713
1049
  L: 112,
714
1050
  S: this,
715
1051
  C: (f, a) => f(...a)
716
1052
  });
717
1053
  this.stateUpdate.emit();
718
1054
  }
719
- log3.trace("dxos.halo.identity-manager.open", trace2.end({
1055
+ log4.trace("dxos.halo.identity-manager.open", trace3.end({
720
1056
  id: traceId
721
1057
  }), {
722
- F: __dxlog_file3,
1058
+ F: __dxlog_file5,
723
1059
  L: 119,
724
1060
  S: this,
725
1061
  C: (f, a) => f(...a)
@@ -729,8 +1065,8 @@ var IdentityManager = class {
729
1065
  await this._identity?.close(new Context3());
730
1066
  }
731
1067
  async createIdentity({ displayName, deviceProfile } = {}) {
732
- invariant2(!this._identity, "Identity already exists.", {
733
- F: __dxlog_file3,
1068
+ invariant3(!this._identity, "Identity already exists.", {
1069
+ F: __dxlog_file5,
734
1070
  L: 128,
735
1071
  S: this,
736
1072
  A: [
@@ -738,8 +1074,8 @@ var IdentityManager = class {
738
1074
  "'Identity already exists.'"
739
1075
  ]
740
1076
  });
741
- log3("creating identity...", void 0, {
742
- F: __dxlog_file3,
1077
+ log4("creating identity...", void 0, {
1078
+ F: __dxlog_file5,
743
1079
  L: 129,
744
1080
  S: this,
745
1081
  C: (f, a) => f(...a)
@@ -759,8 +1095,8 @@ var IdentityManager = class {
759
1095
  await identity.open(new Context3());
760
1096
  {
761
1097
  const generator = new CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
762
- invariant2(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
763
- F: __dxlog_file3,
1098
+ invariant3(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
1099
+ F: __dxlog_file5,
764
1100
  L: 148,
765
1101
  S: this,
766
1102
  A: [
@@ -768,8 +1104,8 @@ var IdentityManager = class {
768
1104
  "'Genesis feed key is required.'"
769
1105
  ]
770
1106
  });
771
- invariant2(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
772
- F: __dxlog_file3,
1107
+ invariant3(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
1108
+ F: __dxlog_file5,
773
1109
  L: 149,
774
1110
  S: this,
775
1111
  A: [
@@ -804,22 +1140,22 @@ var IdentityManager = class {
804
1140
  await this._metadataStore.setIdentityRecord(identityRecord);
805
1141
  this._identity = identity;
806
1142
  await this._identity.ready();
807
- log3.trace("dxos.halo.identity", {
1143
+ log4.trace("dxos.halo.identity", {
808
1144
  identityKey: identityRecord.identityKey,
809
1145
  displayName: this._identity.profileDocument?.displayName
810
1146
  }, {
811
- F: __dxlog_file3,
1147
+ F: __dxlog_file5,
812
1148
  L: 191,
813
1149
  S: this,
814
1150
  C: (f, a) => f(...a)
815
1151
  });
816
1152
  this.stateUpdate.emit();
817
- log3("created identity", {
1153
+ log4("created identity", {
818
1154
  identityKey: identity.identityKey,
819
1155
  deviceKey: identity.deviceKey,
820
1156
  profile: identity.profileDocument
821
1157
  }, {
822
- F: __dxlog_file3,
1158
+ F: __dxlog_file5,
823
1159
  L: 197,
824
1160
  S: this,
825
1161
  C: (f, a) => f(...a)
@@ -853,16 +1189,16 @@ var IdentityManager = class {
853
1189
  * Accept an existing identity. Expects its device key to be authorized (now or later).
854
1190
  */
855
1191
  async acceptIdentity(params) {
856
- log3("accepting identity", {
1192
+ log4("accepting identity", {
857
1193
  params
858
1194
  }, {
859
- F: __dxlog_file3,
1195
+ F: __dxlog_file5,
860
1196
  L: 235,
861
1197
  S: this,
862
1198
  C: (f, a) => f(...a)
863
1199
  });
864
- invariant2(!this._identity, "Identity already exists.", {
865
- F: __dxlog_file3,
1200
+ invariant3(!this._identity, "Identity already exists.", {
1201
+ F: __dxlog_file5,
866
1202
  L: 236,
867
1203
  S: this,
868
1204
  A: [
@@ -886,11 +1222,11 @@ var IdentityManager = class {
886
1222
  this._identity = identity;
887
1223
  await this._metadataStore.setIdentityRecord(identityRecord);
888
1224
  await this._identity.ready();
889
- log3.trace("dxos.halo.identity", {
1225
+ log4.trace("dxos.halo.identity", {
890
1226
  identityKey: identityRecord.identityKey,
891
1227
  displayName: this._identity.profileDocument?.displayName
892
1228
  }, {
893
- F: __dxlog_file3,
1229
+ F: __dxlog_file5,
894
1230
  L: 255,
895
1231
  S: this,
896
1232
  C: (f, a) => f(...a)
@@ -900,11 +1236,11 @@ var IdentityManager = class {
900
1236
  ...params.deviceProfile
901
1237
  });
902
1238
  this.stateUpdate.emit();
903
- log3("accepted identity", {
1239
+ log4("accepted identity", {
904
1240
  identityKey: identity.identityKey,
905
1241
  deviceKey: identity.deviceKey
906
1242
  }, {
907
- F: __dxlog_file3,
1243
+ F: __dxlog_file5,
908
1244
  L: 265,
909
1245
  S: this,
910
1246
  C: (f, a) => f(...a)
@@ -915,8 +1251,8 @@ var IdentityManager = class {
915
1251
  * Update the profile document of an existing identity.
916
1252
  */
917
1253
  async updateProfile(profile) {
918
- invariant2(this._identity, "Identity not initialized.", {
919
- F: __dxlog_file3,
1254
+ invariant3(this._identity, "Identity not initialized.", {
1255
+ F: __dxlog_file5,
920
1256
  L: 273,
921
1257
  S: this,
922
1258
  A: [
@@ -946,8 +1282,8 @@ var IdentityManager = class {
946
1282
  return profile;
947
1283
  }
948
1284
  async updateDeviceProfile(profile) {
949
- invariant2(this._identity, "Identity not initialized.", {
950
- F: __dxlog_file3,
1285
+ invariant3(this._identity, "Identity not initialized.", {
1286
+ F: __dxlog_file5,
951
1287
  L: 290,
952
1288
  S: this,
953
1289
  A: [
@@ -982,8 +1318,8 @@ var IdentityManager = class {
982
1318
  };
983
1319
  }
984
1320
  async _constructIdentity(identityRecord) {
985
- invariant2(!this._identity, void 0, {
986
- F: __dxlog_file3,
1321
+ invariant3(!this._identity, void 0, {
1322
+ F: __dxlog_file5,
987
1323
  L: 316,
988
1324
  S: this,
989
1325
  A: [
@@ -991,10 +1327,10 @@ var IdentityManager = class {
991
1327
  ""
992
1328
  ]
993
1329
  });
994
- log3("constructing identity", {
1330
+ log4("constructing identity", {
995
1331
  identityRecord
996
1332
  }, {
997
- F: __dxlog_file3,
1333
+ F: __dxlog_file5,
998
1334
  L: 317,
999
1335
  S: this,
1000
1336
  C: (f, a) => f(...a)
@@ -1008,8 +1344,8 @@ var IdentityManager = class {
1008
1344
  identityKey: identityRecord.deviceKey,
1009
1345
  gossip
1010
1346
  });
1011
- invariant2(identityRecord.haloSpace.controlFeedKey, void 0, {
1012
- F: __dxlog_file3,
1347
+ invariant3(identityRecord.haloSpace.controlFeedKey, void 0, {
1348
+ F: __dxlog_file5,
1013
1349
  L: 330,
1014
1350
  S: this,
1015
1351
  A: [
@@ -1020,8 +1356,8 @@ var IdentityManager = class {
1020
1356
  const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
1021
1357
  writable: true
1022
1358
  });
1023
- invariant2(identityRecord.haloSpace.dataFeedKey, void 0, {
1024
- F: __dxlog_file3,
1359
+ invariant3(identityRecord.haloSpace.dataFeedKey, void 0, {
1360
+ F: __dxlog_file5,
1025
1361
  L: 334,
1026
1362
  S: this,
1027
1363
  A: [
@@ -1052,10 +1388,10 @@ var IdentityManager = class {
1052
1388
  identityKey: identityRecord.identityKey,
1053
1389
  deviceKey: identityRecord.deviceKey
1054
1390
  });
1055
- log3("done", {
1391
+ log4("done", {
1056
1392
  identityKey: identityRecord.identityKey
1057
1393
  }, {
1058
- F: __dxlog_file3,
1394
+ F: __dxlog_file5,
1059
1395
  L: 360,
1060
1396
  S: this,
1061
1397
  C: (f, a) => f(...a)
@@ -1079,8 +1415,8 @@ var IdentityManager = class {
1079
1415
  }));
1080
1416
  },
1081
1417
  onAuthFailure: () => {
1082
- log3.warn("auth failure", void 0, {
1083
- F: __dxlog_file3,
1418
+ log4.warn("auth failure", void 0, {
1419
+ F: __dxlog_file5,
1084
1420
  L: 385,
1085
1421
  S: this,
1086
1422
  C: (f, a) => f(...a)
@@ -1094,21 +1430,21 @@ var IdentityManager = class {
1094
1430
  });
1095
1431
  }
1096
1432
  };
1097
- _ts_decorate2([
1433
+ _ts_decorate3([
1098
1434
  Trace.span({
1099
1435
  showInBrowserTimeline: true
1100
1436
  })
1101
1437
  ], IdentityManager.prototype, "open", null);
1102
- IdentityManager = _ts_decorate2([
1438
+ IdentityManager = _ts_decorate3([
1103
1439
  Trace.resource()
1104
1440
  ], IdentityManager);
1105
1441
 
1106
1442
  // packages/sdk/client-services/src/packlets/identity/identity-service.ts
1107
- import { Stream as Stream7 } from "@dxos/codec-protobuf";
1443
+ import { Stream as Stream8 } from "@dxos/codec-protobuf";
1108
1444
  import { signPresentation } from "@dxos/credentials";
1109
1445
  import { todo } from "@dxos/debug";
1110
- import { invariant as invariant3 } from "@dxos/invariant";
1111
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
1446
+ import { invariant as invariant4 } from "@dxos/invariant";
1447
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
1112
1448
  var IdentityServiceImpl = class {
1113
1449
  constructor(_createIdentity, _identityManager, _keyring, _onProfileUpdate) {
1114
1450
  this._createIdentity = _createIdentity;
@@ -1127,7 +1463,7 @@ var IdentityServiceImpl = class {
1127
1463
  return todo();
1128
1464
  }
1129
1465
  queryIdentity() {
1130
- return new Stream7(({ next }) => {
1466
+ return new Stream8(({ next }) => {
1131
1467
  const emitNext = () => next({
1132
1468
  identity: this._getIdentity()
1133
1469
  });
@@ -1146,8 +1482,8 @@ var IdentityServiceImpl = class {
1146
1482
  };
1147
1483
  }
1148
1484
  async updateProfile(profile) {
1149
- invariant3(this._identityManager.identity, "Identity not initialized.", {
1150
- F: __dxlog_file4,
1485
+ invariant4(this._identityManager.identity, "Identity not initialized.", {
1486
+ F: __dxlog_file6,
1151
1487
  L: 61,
1152
1488
  S: this,
1153
1489
  A: [
@@ -1160,8 +1496,8 @@ var IdentityServiceImpl = class {
1160
1496
  return this._getIdentity();
1161
1497
  }
1162
1498
  async signPresentation({ presentation, nonce }) {
1163
- invariant3(this._identityManager.identity, "Identity not initialized.", {
1164
- F: __dxlog_file4,
1499
+ invariant4(this._identityManager.identity, "Identity not initialized.", {
1500
+ F: __dxlog_file6,
1165
1501
  L: 68,
1166
1502
  S: this,
1167
1503
  A: [
@@ -1180,10 +1516,10 @@ var IdentityServiceImpl = class {
1180
1516
  };
1181
1517
 
1182
1518
  // packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
1183
- import { invariant as invariant4 } from "@dxos/invariant";
1519
+ import { invariant as invariant5 } from "@dxos/invariant";
1184
1520
  import { AlreadyJoinedError } from "@dxos/protocols";
1185
1521
  import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
1186
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
1522
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
1187
1523
  var DeviceInvitationProtocol = class {
1188
1524
  constructor(_keyring, _getIdentity, _acceptIdentity) {
1189
1525
  this._keyring = _keyring;
@@ -1208,8 +1544,8 @@ var DeviceInvitationProtocol = class {
1208
1544
  throw new Error("delegation not supported");
1209
1545
  }
1210
1546
  async admit(_, request) {
1211
- invariant4(request.device, void 0, {
1212
- F: __dxlog_file5,
1547
+ invariant5(request.device, void 0, {
1548
+ F: __dxlog_file7,
1213
1549
  L: 50,
1214
1550
  S: this,
1215
1551
  A: [
@@ -1254,8 +1590,8 @@ var DeviceInvitationProtocol = class {
1254
1590
  };
1255
1591
  }
1256
1592
  async accept(response, request) {
1257
- invariant4(response.device, void 0, {
1258
- F: __dxlog_file5,
1593
+ invariant5(response.device, void 0, {
1594
+ F: __dxlog_file7,
1259
1595
  L: 95,
1260
1596
  S: this,
1261
1597
  A: [
@@ -1264,8 +1600,8 @@ var DeviceInvitationProtocol = class {
1264
1600
  ]
1265
1601
  });
1266
1602
  const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
1267
- invariant4(request.device, void 0, {
1268
- F: __dxlog_file5,
1603
+ invariant5(request.device, void 0, {
1604
+ F: __dxlog_file7,
1269
1605
  L: 98,
1270
1606
  S: this,
1271
1607
  A: [
@@ -1295,21 +1631,21 @@ import { Mutex, scheduleTask as scheduleTask3, TimeoutError } from "@dxos/async"
1295
1631
  import { INVITATION_TIMEOUT } from "@dxos/client-protocol";
1296
1632
  import { ContextDisposedError as ContextDisposedError2 } from "@dxos/context";
1297
1633
  import { createKeyPair, sign } from "@dxos/crypto";
1298
- import { invariant as invariant8 } from "@dxos/invariant";
1634
+ import { invariant as invariant9 } from "@dxos/invariant";
1299
1635
  import { PublicKey as PublicKey7 } from "@dxos/keys";
1300
- import { log as log7 } from "@dxos/log";
1636
+ import { log as log8 } from "@dxos/log";
1301
1637
  import { createTeleportProtocolFactory } from "@dxos/network-manager";
1302
- import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace4 } from "@dxos/protocols";
1638
+ import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError3, trace as trace5 } from "@dxos/protocols";
1303
1639
  import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
1304
1640
  import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
1305
1641
  import { Options as Options4 } from "@dxos/protocols/proto/dxos/halo/invitations";
1306
1642
  import { ComplexSet as ComplexSet3 } from "@dxos/util";
1307
1643
 
1308
1644
  // packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts
1309
- import { Trigger as Trigger2 } from "@dxos/async";
1645
+ import { Trigger as Trigger3 } from "@dxos/async";
1310
1646
  import { cancelWithContext as cancelWithContext2, Context as Context4 } from "@dxos/context";
1311
- import { invariant as invariant5 } from "@dxos/invariant";
1312
- import { log as log4 } from "@dxos/log";
1647
+ import { invariant as invariant6 } from "@dxos/invariant";
1648
+ import { log as log5 } from "@dxos/log";
1313
1649
  import { InvalidInvitationExtensionRoleError, schema as schema2 } from "@dxos/protocols";
1314
1650
  import { Options } from "@dxos/protocols/proto/dxos/halo/invitations";
1315
1651
  import { RpcExtension } from "@dxos/teleport";
@@ -1334,7 +1670,7 @@ var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
1334
1670
  };
1335
1671
 
1336
1672
  // packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts
1337
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
1673
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
1338
1674
  var OPTIONS_TIMEOUT = 1e4;
1339
1675
  var InvitationGuestExtension = class extends RpcExtension {
1340
1676
  constructor(_invitationFlowMutex, _callbacks) {
@@ -1349,7 +1685,7 @@ var InvitationGuestExtension = class extends RpcExtension {
1349
1685
  this._invitationFlowMutex = _invitationFlowMutex;
1350
1686
  this._callbacks = _callbacks;
1351
1687
  this._ctx = new Context4();
1352
- this._remoteOptionsTrigger = new Trigger2();
1688
+ this._remoteOptionsTrigger = new Trigger3();
1353
1689
  this._invitationFlowLock = null;
1354
1690
  }
1355
1691
  hasFlowLock() {
@@ -1359,8 +1695,8 @@ var InvitationGuestExtension = class extends RpcExtension {
1359
1695
  return {
1360
1696
  InvitationHostService: {
1361
1697
  options: async (options) => {
1362
- invariant5(!this._remoteOptions, "Remote options already set.", {
1363
- F: __dxlog_file6,
1698
+ invariant6(!this._remoteOptions, "Remote options already set.", {
1699
+ F: __dxlog_file8,
1364
1700
  L: 63,
1365
1701
  S: this,
1366
1702
  A: [
@@ -1386,15 +1722,15 @@ var InvitationGuestExtension = class extends RpcExtension {
1386
1722
  async onOpen(context) {
1387
1723
  await super.onOpen(context);
1388
1724
  try {
1389
- log4("guest acquire lock", void 0, {
1390
- F: __dxlog_file6,
1725
+ log5("guest acquire lock", void 0, {
1726
+ F: __dxlog_file8,
1391
1727
  L: 84,
1392
1728
  S: this,
1393
1729
  C: (f, a) => f(...a)
1394
1730
  });
1395
1731
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
1396
- log4("guest lock acquired", void 0, {
1397
- F: __dxlog_file6,
1732
+ log5("guest lock acquired", void 0, {
1733
+ F: __dxlog_file8,
1398
1734
  L: 86,
1399
1735
  S: this,
1400
1736
  C: (f, a) => f(...a)
@@ -1402,8 +1738,8 @@ var InvitationGuestExtension = class extends RpcExtension {
1402
1738
  await cancelWithContext2(this._ctx, this.rpc.InvitationHostService.options({
1403
1739
  role: Options.Role.GUEST
1404
1740
  }));
1405
- log4("options sent", void 0, {
1406
- F: __dxlog_file6,
1741
+ log5("options sent", void 0, {
1742
+ F: __dxlog_file8,
1407
1743
  L: 88,
1408
1744
  S: this,
1409
1745
  C: (f, a) => f(...a)
@@ -1411,8 +1747,8 @@ var InvitationGuestExtension = class extends RpcExtension {
1411
1747
  await cancelWithContext2(this._ctx, this._remoteOptionsTrigger.wait({
1412
1748
  timeout: OPTIONS_TIMEOUT
1413
1749
  }));
1414
- log4("options received", void 0, {
1415
- F: __dxlog_file6,
1750
+ log5("options received", void 0, {
1751
+ F: __dxlog_file8,
1416
1752
  L: 90,
1417
1753
  S: this,
1418
1754
  C: (f, a) => f(...a)
@@ -1445,8 +1781,8 @@ var InvitationGuestExtension = class extends RpcExtension {
1445
1781
  if (this._invitationFlowLock != null) {
1446
1782
  this._invitationFlowLock.release();
1447
1783
  this._invitationFlowLock = null;
1448
- log4("invitation flow lock released", void 0, {
1449
- F: __dxlog_file6,
1784
+ log5("invitation flow lock released", void 0, {
1785
+ F: __dxlog_file8,
1450
1786
  L: 123,
1451
1787
  S: this,
1452
1788
  C: (f, a) => f(...a)
@@ -1456,17 +1792,17 @@ var InvitationGuestExtension = class extends RpcExtension {
1456
1792
  };
1457
1793
 
1458
1794
  // packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts
1459
- import { Trigger as Trigger3, scheduleTask as scheduleTask2 } from "@dxos/async";
1795
+ import { Trigger as Trigger4, scheduleTask as scheduleTask2 } from "@dxos/async";
1460
1796
  import { cancelWithContext as cancelWithContext3, Context as Context5 } from "@dxos/context";
1461
1797
  import { randomBytes, verify } from "@dxos/crypto";
1462
- import { invariant as invariant6, InvariantViolation } from "@dxos/invariant";
1798
+ import { invariant as invariant7, InvariantViolation } from "@dxos/invariant";
1463
1799
  import { PublicKey as PublicKey5 } from "@dxos/keys";
1464
- import { log as log5 } from "@dxos/log";
1465
- import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2, schema as schema3, trace as trace3 } from "@dxos/protocols";
1800
+ import { log as log6 } from "@dxos/log";
1801
+ import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2, schema as schema3, trace as trace4 } from "@dxos/protocols";
1466
1802
  import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/services";
1467
1803
  import { AuthenticationResponse, Options as Options2 } from "@dxos/protocols/proto/dxos/halo/invitations";
1468
1804
  import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
1469
- var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
1805
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
1470
1806
  var OPTIONS_TIMEOUT2 = 1e4;
1471
1807
  var MAX_OTP_ATTEMPTS = 3;
1472
1808
  var InvitationHostExtension = class extends RpcExtension2 {
@@ -1482,12 +1818,12 @@ var InvitationHostExtension = class extends RpcExtension2 {
1482
1818
  this._invitationFlowMutex = _invitationFlowMutex;
1483
1819
  this._callbacks = _callbacks;
1484
1820
  this._ctx = new Context5();
1485
- this._remoteOptionsTrigger = new Trigger3();
1821
+ this._remoteOptionsTrigger = new Trigger4();
1486
1822
  this._challenge = void 0;
1487
1823
  this.guestProfile = void 0;
1488
1824
  this.authenticationPassed = false;
1489
1825
  this.authenticationRetry = 0;
1490
- this.completedTrigger = new Trigger3();
1826
+ this.completedTrigger = new Trigger4();
1491
1827
  this._invitationFlowLock = null;
1492
1828
  }
1493
1829
  hasFlowLock() {
@@ -1499,8 +1835,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
1499
1835
  // Perhaps in the future we will have more complex logic here.
1500
1836
  InvitationHostService: {
1501
1837
  options: async (options) => {
1502
- invariant6(!this._remoteOptions, "Remote options already set.", {
1503
- F: __dxlog_file7,
1838
+ invariant7(!this._remoteOptions, "Remote options already set.", {
1839
+ F: __dxlog_file9,
1504
1840
  L: 101,
1505
1841
  S: this,
1506
1842
  A: [
@@ -1514,10 +1850,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
1514
1850
  introduce: async (request) => {
1515
1851
  const { profile, invitationId } = request;
1516
1852
  const traceId = PublicKey5.random().toHex();
1517
- log5.trace("dxos.sdk.invitation-handler.host.introduce", trace3.begin({
1853
+ log6.trace("dxos.sdk.invitation-handler.host.introduce", trace4.begin({
1518
1854
  id: traceId
1519
1855
  }), {
1520
- F: __dxlog_file7,
1856
+ F: __dxlog_file9,
1521
1857
  L: 110,
1522
1858
  S: this,
1523
1859
  C: (f, a) => f(...a)
@@ -1525,11 +1861,11 @@ var InvitationHostExtension = class extends RpcExtension2 {
1525
1861
  const invitation = this._requireActiveInvitation();
1526
1862
  this._assertInvitationState(Invitation3.State.CONNECTED);
1527
1863
  if (invitationId !== invitation?.invitationId) {
1528
- log5.warn("incorrect invitationId", {
1864
+ log6.warn("incorrect invitationId", {
1529
1865
  expected: invitation.invitationId,
1530
1866
  actual: invitationId
1531
1867
  }, {
1532
- F: __dxlog_file7,
1868
+ F: __dxlog_file9,
1533
1869
  L: 116,
1534
1870
  S: this,
1535
1871
  C: (f, a) => f(...a)
@@ -1540,10 +1876,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
1540
1876
  authMethod: Invitation3.AuthMethod.NONE
1541
1877
  };
1542
1878
  }
1543
- log5("guest introduced themselves", {
1879
+ log6("guest introduced themselves", {
1544
1880
  guestProfile: profile
1545
1881
  }, {
1546
- F: __dxlog_file7,
1882
+ F: __dxlog_file9,
1547
1883
  L: 125,
1548
1884
  S: this,
1549
1885
  C: (f, a) => f(...a)
@@ -1551,10 +1887,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
1551
1887
  this.guestProfile = profile;
1552
1888
  this._callbacks.onStateUpdate(Invitation3.State.READY_FOR_AUTHENTICATION);
1553
1889
  this._challenge = invitation.authMethod === Invitation3.AuthMethod.KNOWN_PUBLIC_KEY ? randomBytes(32) : void 0;
1554
- log5.trace("dxos.sdk.invitation-handler.host.introduce", trace3.end({
1890
+ log6.trace("dxos.sdk.invitation-handler.host.introduce", trace4.end({
1555
1891
  id: traceId
1556
1892
  }), {
1557
- F: __dxlog_file7,
1893
+ F: __dxlog_file9,
1558
1894
  L: 132,
1559
1895
  S: this,
1560
1896
  C: (f, a) => f(...a)
@@ -1566,19 +1902,19 @@ var InvitationHostExtension = class extends RpcExtension2 {
1566
1902
  },
1567
1903
  authenticate: async ({ authCode: code, signedChallenge }) => {
1568
1904
  const traceId = PublicKey5.random().toHex();
1569
- log5.trace("dxos.sdk.invitation-handler.host.authenticate", trace3.begin({
1905
+ log6.trace("dxos.sdk.invitation-handler.host.authenticate", trace4.begin({
1570
1906
  id: traceId
1571
1907
  }), {
1572
- F: __dxlog_file7,
1908
+ F: __dxlog_file9,
1573
1909
  L: 141,
1574
1910
  S: this,
1575
1911
  C: (f, a) => f(...a)
1576
1912
  });
1577
1913
  const invitation = this._requireActiveInvitation();
1578
- log5("received authentication request", {
1914
+ log6("received authentication request", {
1579
1915
  authCode: code
1580
1916
  }, {
1581
- F: __dxlog_file7,
1917
+ F: __dxlog_file9,
1582
1918
  L: 144,
1583
1919
  S: this,
1584
1920
  C: (f, a) => f(...a)
@@ -1591,8 +1927,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
1591
1927
  this._callbacks.onStateUpdate(Invitation3.State.AUTHENTICATING);
1592
1928
  switch (invitation.authMethod) {
1593
1929
  case Invitation3.AuthMethod.NONE: {
1594
- log5("authentication not required", void 0, {
1595
- F: __dxlog_file7,
1930
+ log6("authentication not required", void 0, {
1931
+ F: __dxlog_file9,
1596
1932
  L: 152,
1597
1933
  S: this,
1598
1934
  C: (f, a) => f(...a)
@@ -1627,10 +1963,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
1627
1963
  break;
1628
1964
  }
1629
1965
  default: {
1630
- log5.error("invalid authentication method", {
1966
+ log6.error("invalid authentication method", {
1631
1967
  authMethod: invitation.authMethod
1632
1968
  }, {
1633
- F: __dxlog_file7,
1969
+ F: __dxlog_file9,
1634
1970
  L: 190,
1635
1971
  S: this,
1636
1972
  C: (f, a) => f(...a)
@@ -1649,13 +1985,13 @@ var InvitationHostExtension = class extends RpcExtension2 {
1649
1985
  status
1650
1986
  };
1651
1987
  }
1652
- log5.trace("dxos.sdk.invitation-handler.host.authenticate", trace3.end({
1988
+ log6.trace("dxos.sdk.invitation-handler.host.authenticate", trace4.end({
1653
1989
  id: traceId,
1654
1990
  data: {
1655
1991
  status
1656
1992
  }
1657
1993
  }), {
1658
- F: __dxlog_file7,
1994
+ F: __dxlog_file9,
1659
1995
  L: 202,
1660
1996
  S: this,
1661
1997
  C: (f, a) => f(...a)
@@ -1666,10 +2002,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
1666
2002
  },
1667
2003
  admit: async (request) => {
1668
2004
  const traceId = PublicKey5.random().toHex();
1669
- log5.trace("dxos.sdk.invitation-handler.host.admit", trace3.begin({
2005
+ log6.trace("dxos.sdk.invitation-handler.host.admit", trace4.begin({
1670
2006
  id: traceId
1671
2007
  }), {
1672
- F: __dxlog_file7,
2008
+ F: __dxlog_file9,
1673
2009
  L: 208,
1674
2010
  S: this,
1675
2011
  C: (f, a) => f(...a)
@@ -1683,10 +2019,10 @@ var InvitationHostExtension = class extends RpcExtension2 {
1683
2019
  }
1684
2020
  }
1685
2021
  const response = await this._callbacks.admit(request);
1686
- log5.trace("dxos.sdk.invitation-handler.host.admit", trace3.end({
2022
+ log6.trace("dxos.sdk.invitation-handler.host.admit", trace4.end({
1687
2023
  id: traceId
1688
2024
  }), {
1689
- F: __dxlog_file7,
2025
+ F: __dxlog_file9,
1690
2026
  L: 222,
1691
2027
  S: this,
1692
2028
  C: (f, a) => f(...a)
@@ -1703,15 +2039,15 @@ var InvitationHostExtension = class extends RpcExtension2 {
1703
2039
  async onOpen(context) {
1704
2040
  await super.onOpen(context);
1705
2041
  try {
1706
- log5("host acquire lock", void 0, {
1707
- F: __dxlog_file7,
2042
+ log6("host acquire lock", void 0, {
2043
+ F: __dxlog_file9,
1708
2044
  L: 237,
1709
2045
  S: this,
1710
2046
  C: (f, a) => f(...a)
1711
2047
  });
1712
2048
  this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
1713
- log5("host lock acquired", void 0, {
1714
- F: __dxlog_file7,
2049
+ log6("host lock acquired", void 0, {
2050
+ F: __dxlog_file9,
1715
2051
  L: 239,
1716
2052
  S: this,
1717
2053
  C: (f, a) => f(...a)
@@ -1721,8 +2057,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
1721
2057
  await this.rpc.InvitationHostService.options({
1722
2058
  role: Options2.Role.HOST
1723
2059
  });
1724
- log5("options sent", void 0, {
1725
- F: __dxlog_file7,
2060
+ log6("options sent", void 0, {
2061
+ F: __dxlog_file9,
1726
2062
  L: 243,
1727
2063
  S: this,
1728
2064
  C: (f, a) => f(...a)
@@ -1730,8 +2066,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
1730
2066
  await cancelWithContext3(this._ctx, this._remoteOptionsTrigger.wait({
1731
2067
  timeout: OPTIONS_TIMEOUT2
1732
2068
  }));
1733
- log5("options received", void 0, {
1734
- F: __dxlog_file7,
2069
+ log6("options received", void 0, {
2070
+ F: __dxlog_file9,
1735
2071
  L: 245,
1736
2072
  S: this,
1737
2073
  C: (f, a) => f(...a)
@@ -1784,8 +2120,8 @@ var InvitationHostExtension = class extends RpcExtension2 {
1784
2120
  if (this._invitationFlowLock != null) {
1785
2121
  this._invitationFlowLock?.release();
1786
2122
  this._invitationFlowLock = null;
1787
- log5("invitation flow lock released", void 0, {
1788
- F: __dxlog_file7,
2123
+ log6("invitation flow lock released", void 0, {
2124
+ F: __dxlog_file9,
1789
2125
  L: 300,
1790
2126
  S: this,
1791
2127
  C: (f, a) => f(...a)
@@ -1796,20 +2132,20 @@ var InvitationHostExtension = class extends RpcExtension2 {
1796
2132
  var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitation3.AuthMethod.NONE;
1797
2133
 
1798
2134
  // packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts
1799
- import { invariant as invariant7 } from "@dxos/invariant";
2135
+ import { invariant as invariant8 } from "@dxos/invariant";
1800
2136
  import { PublicKey as PublicKey6 } from "@dxos/keys";
1801
- import { log as log6 } from "@dxos/log";
2137
+ import { log as log7 } from "@dxos/log";
1802
2138
  import { Options as Options3 } from "@dxos/protocols/proto/dxos/halo/invitations";
1803
2139
  import { ComplexSet as ComplexSet2 } from "@dxos/util";
1804
- var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
2140
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
1805
2141
  var InvitationTopology = class {
1806
2142
  constructor(_role) {
1807
2143
  this._role = _role;
1808
2144
  this._seenPeers = new ComplexSet2(PublicKey6.hash);
1809
2145
  }
1810
2146
  init(controller) {
1811
- invariant7(!this._controller, "Already initialized.", {
1812
- F: __dxlog_file8,
2147
+ invariant8(!this._controller, "Already initialized.", {
2148
+ F: __dxlog_file10,
1813
2149
  L: 42,
1814
2150
  S: this,
1815
2151
  A: [
@@ -1820,8 +2156,8 @@ var InvitationTopology = class {
1820
2156
  this._controller = controller;
1821
2157
  }
1822
2158
  update() {
1823
- invariant7(this._controller, "Not initialized.", {
1824
- F: __dxlog_file8,
2159
+ invariant8(this._controller, "Not initialized.", {
2160
+ F: __dxlog_file10,
1825
2161
  L: 47,
1826
2162
  S: this,
1827
2163
  A: [
@@ -1840,11 +2176,11 @@ var InvitationTopology = class {
1840
2176
  const firstUnknownPeer = candidates.find((peerId) => !this._seenPeers.has(peerId));
1841
2177
  this._seenPeers = new ComplexSet2(PublicKey6.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
1842
2178
  if (firstUnknownPeer != null) {
1843
- log6("invitation connect", {
2179
+ log7("invitation connect", {
1844
2180
  ownPeerId,
1845
2181
  remotePeerId: firstUnknownPeer
1846
2182
  }, {
1847
- F: __dxlog_file8,
2183
+ F: __dxlog_file10,
1848
2184
  L: 69,
1849
2185
  S: this,
1850
2186
  C: (f, a) => f(...a)
@@ -1854,8 +2190,8 @@ var InvitationTopology = class {
1854
2190
  }
1855
2191
  }
1856
2192
  async onOffer(peer) {
1857
- invariant7(this._controller, "Not initialized.", {
1858
- F: __dxlog_file8,
2193
+ invariant8(this._controller, "Not initialized.", {
2194
+ F: __dxlog_file10,
1859
2195
  L: 76,
1860
2196
  S: this,
1861
2197
  A: [
@@ -1874,7 +2210,7 @@ var InvitationTopology = class {
1874
2210
  };
1875
2211
 
1876
2212
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
1877
- var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
2213
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
1878
2214
  var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
1879
2215
  var InvitationsHandler = class {
1880
2216
  /**
@@ -1898,8 +2234,8 @@ var InvitationsHandler = class {
1898
2234
  admit: async (admissionRequest) => {
1899
2235
  try {
1900
2236
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
1901
- invariant8(deviceKey, void 0, {
1902
- F: __dxlog_file9,
2237
+ invariant9(deviceKey, void 0, {
2238
+ F: __dxlog_file11,
1903
2239
  L: 90,
1904
2240
  S: this,
1905
2241
  A: [
@@ -1925,18 +2261,18 @@ var InvitationsHandler = class {
1925
2261
  scheduleTask3(connectionCtx, async () => {
1926
2262
  const traceId = PublicKey7.random().toHex();
1927
2263
  try {
1928
- log7.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.begin({
2264
+ log8.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.begin({
1929
2265
  id: traceId
1930
2266
  }), {
1931
- F: __dxlog_file9,
2267
+ F: __dxlog_file11,
1932
2268
  L: 115,
1933
2269
  S: this,
1934
2270
  C: (f, a) => f(...a)
1935
2271
  });
1936
- log7("connected", {
2272
+ log8("connected", {
1937
2273
  ...protocol.toJSON()
1938
2274
  }, {
1939
- F: __dxlog_file9,
2275
+ F: __dxlog_file11,
1940
2276
  L: 116,
1941
2277
  S: this,
1942
2278
  C: (f, a) => f(...a)
@@ -1944,20 +2280,20 @@ var InvitationsHandler = class {
1944
2280
  const deviceKey = await extension.completedTrigger.wait({
1945
2281
  timeout: invitation.timeout
1946
2282
  });
1947
- log7("admitted guest", {
2283
+ log8("admitted guest", {
1948
2284
  guest: deviceKey,
1949
2285
  ...protocol.toJSON()
1950
2286
  }, {
1951
- F: __dxlog_file9,
2287
+ F: __dxlog_file11,
1952
2288
  L: 118,
1953
2289
  S: this,
1954
2290
  C: (f, a) => f(...a)
1955
2291
  });
1956
2292
  guardedState.set(extension, Invitation4.State.SUCCESS);
1957
- log7.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.end({
2293
+ log8.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.end({
1958
2294
  id: traceId
1959
2295
  }), {
1960
- F: __dxlog_file9,
2296
+ F: __dxlog_file11,
1961
2297
  L: 120,
1962
2298
  S: this,
1963
2299
  C: (f, a) => f(...a)
@@ -1969,10 +2305,10 @@ var InvitationsHandler = class {
1969
2305
  } catch (err) {
1970
2306
  if (err instanceof TimeoutError) {
1971
2307
  if (guardedState.set(extension, Invitation4.State.TIMEOUT)) {
1972
- log7("timeout", {
2308
+ log8("timeout", {
1973
2309
  ...protocol.toJSON()
1974
2310
  }, {
1975
- F: __dxlog_file9,
2311
+ F: __dxlog_file11,
1976
2312
  L: 129,
1977
2313
  S: this,
1978
2314
  C: (f, a) => f(...a)
@@ -1980,19 +2316,19 @@ var InvitationsHandler = class {
1980
2316
  }
1981
2317
  } else {
1982
2318
  if (guardedState.error(extension, err)) {
1983
- log7.error("failed", err, {
1984
- F: __dxlog_file9,
2319
+ log8.error("failed", err, {
2320
+ F: __dxlog_file11,
1985
2321
  L: 133,
1986
2322
  S: this,
1987
2323
  C: (f, a) => f(...a)
1988
2324
  });
1989
2325
  }
1990
2326
  }
1991
- log7.trace("dxos.sdk.invitations-handler.host.onOpen", trace4.error({
2327
+ log8.trace("dxos.sdk.invitations-handler.host.onOpen", trace5.error({
1992
2328
  id: traceId,
1993
2329
  error: err
1994
2330
  }), {
1995
- F: __dxlog_file9,
2331
+ F: __dxlog_file11,
1996
2332
  L: 136,
1997
2333
  S: this,
1998
2334
  C: (f, a) => f(...a)
@@ -2003,10 +2339,10 @@ var InvitationsHandler = class {
2003
2339
  },
2004
2340
  onError: (err) => {
2005
2341
  if (err instanceof InvalidInvitationExtensionRoleError3) {
2006
- log7("invalid role", {
2342
+ log8("invalid role", {
2007
2343
  ...err.context
2008
2344
  }, {
2009
- F: __dxlog_file9,
2345
+ F: __dxlog_file11,
2010
2346
  L: 144,
2011
2347
  S: this,
2012
2348
  C: (f, a) => f(...a)
@@ -2015,10 +2351,10 @@ var InvitationsHandler = class {
2015
2351
  }
2016
2352
  if (err instanceof TimeoutError) {
2017
2353
  if (guardedState.set(extension, Invitation4.State.TIMEOUT)) {
2018
- log7("timeout", {
2354
+ log8("timeout", {
2019
2355
  err
2020
2356
  }, {
2021
- F: __dxlog_file9,
2357
+ F: __dxlog_file11,
2022
2358
  L: 149,
2023
2359
  S: this,
2024
2360
  C: (f, a) => f(...a)
@@ -2026,8 +2362,8 @@ var InvitationsHandler = class {
2026
2362
  }
2027
2363
  } else {
2028
2364
  if (guardedState.error(extension, err)) {
2029
- log7.error("failed", err, {
2030
- F: __dxlog_file9,
2365
+ log8.error("failed", err, {
2366
+ F: __dxlog_file11,
2031
2367
  L: 153,
2032
2368
  S: this,
2033
2369
  C: (f, a) => f(...a)
@@ -2040,8 +2376,8 @@ var InvitationsHandler = class {
2040
2376
  };
2041
2377
  if (invitation.lifetime && invitation.created) {
2042
2378
  if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
2043
- log7.warn("invitation has already expired", void 0, {
2044
- F: __dxlog_file9,
2379
+ log8.warn("invitation has already expired", void 0, {
2380
+ F: __dxlog_file11,
2045
2381
  L: 164,
2046
2382
  S: this,
2047
2383
  C: (f, a) => f(...a)
@@ -2063,8 +2399,8 @@ var InvitationsHandler = class {
2063
2399
  acceptInvitation(ctx, stream, protocol, invitation, otpEnteredTrigger, deviceProfile) {
2064
2400
  const { timeout = INVITATION_TIMEOUT } = invitation;
2065
2401
  if (deviceProfile) {
2066
- invariant8(invitation.kind === Invitation4.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
2067
- F: __dxlog_file9,
2402
+ invariant9(invitation.kind === Invitation4.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
2403
+ F: __dxlog_file11,
2068
2404
  L: 197,
2069
2405
  S: this,
2070
2406
  A: [
@@ -2077,12 +2413,12 @@ var InvitationsHandler = class {
2077
2413
  const guardedState = this._createGuardedState(ctx, invitation, stream);
2078
2414
  const shouldCancelInvitationFlow = (extension) => {
2079
2415
  const isLockedByAnotherConnection = guardedState.mutex.isLocked() && !extension.hasFlowLock();
2080
- log7("should cancel invitation flow", {
2416
+ log8("should cancel invitation flow", {
2081
2417
  isLockedByAnotherConnection,
2082
2418
  invitationType: Invitation4.Type.DELEGATED,
2083
2419
  triedPeers: triedPeersIds.size
2084
2420
  }, {
2085
- F: __dxlog_file9,
2421
+ F: __dxlog_file11,
2086
2422
  L: 205,
2087
2423
  S: this,
2088
2424
  C: (f, a) => f(...a)
@@ -2105,11 +2441,11 @@ var InvitationsHandler = class {
2105
2441
  return;
2106
2442
  }
2107
2443
  connectionCtx.onDispose(async () => {
2108
- log7("extension disposed", {
2444
+ log8("extension disposed", {
2109
2445
  admitted,
2110
2446
  currentState: guardedState.current.state
2111
2447
  }, {
2112
- F: __dxlog_file9,
2448
+ F: __dxlog_file11,
2113
2449
  L: 233,
2114
2450
  S: this,
2115
2451
  C: (f, a) => f(...a)
@@ -2124,10 +2460,10 @@ var InvitationsHandler = class {
2124
2460
  scheduleTask3(connectionCtx, async () => {
2125
2461
  const traceId = PublicKey7.random().toHex();
2126
2462
  try {
2127
- log7.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.begin({
2463
+ log8.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.begin({
2128
2464
  id: traceId
2129
2465
  }), {
2130
- F: __dxlog_file9,
2466
+ F: __dxlog_file11,
2131
2467
  L: 245,
2132
2468
  S: this,
2133
2469
  C: (f, a) => f(...a)
@@ -2136,19 +2472,19 @@ var InvitationsHandler = class {
2136
2472
  guardedState.set(extension, Invitation4.State.TIMEOUT);
2137
2473
  extensionCtx.close();
2138
2474
  }, timeout);
2139
- log7("connected", {
2475
+ log8("connected", {
2140
2476
  ...protocol.toJSON()
2141
2477
  }, {
2142
- F: __dxlog_file9,
2478
+ F: __dxlog_file11,
2143
2479
  L: 256,
2144
2480
  S: this,
2145
2481
  C: (f, a) => f(...a)
2146
2482
  });
2147
2483
  guardedState.set(extension, Invitation4.State.CONNECTED);
2148
- log7("introduce", {
2484
+ log8("introduce", {
2149
2485
  ...protocol.toJSON()
2150
2486
  }, {
2151
- F: __dxlog_file9,
2487
+ F: __dxlog_file11,
2152
2488
  L: 260,
2153
2489
  S: this,
2154
2490
  C: (f, a) => f(...a)
@@ -2157,11 +2493,11 @@ var InvitationsHandler = class {
2157
2493
  invitationId: invitation.invitationId,
2158
2494
  ...protocol.createIntroduction()
2159
2495
  });
2160
- log7("introduce response", {
2496
+ log8("introduce response", {
2161
2497
  ...protocol.toJSON(),
2162
2498
  response: introductionResponse
2163
2499
  }, {
2164
- F: __dxlog_file9,
2500
+ F: __dxlog_file11,
2165
2501
  L: 265,
2166
2502
  S: this,
2167
2503
  C: (f, a) => f(...a)
@@ -2179,10 +2515,10 @@ var InvitationsHandler = class {
2179
2515
  break;
2180
2516
  }
2181
2517
  }
2182
- log7("request admission", {
2518
+ log8("request admission", {
2183
2519
  ...protocol.toJSON()
2184
2520
  }, {
2185
- F: __dxlog_file9,
2521
+ F: __dxlog_file11,
2186
2522
  L: 291,
2187
2523
  S: this,
2188
2524
  C: (f, a) => f(...a)
@@ -2191,10 +2527,10 @@ var InvitationsHandler = class {
2191
2527
  const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
2192
2528
  admitted = true;
2193
2529
  const result = await protocol.accept(admissionResponse, admissionRequest);
2194
- log7("admitted by host", {
2530
+ log8("admitted by host", {
2195
2531
  ...protocol.toJSON()
2196
2532
  }, {
2197
- F: __dxlog_file9,
2533
+ F: __dxlog_file11,
2198
2534
  L: 302,
2199
2535
  S: this,
2200
2536
  C: (f, a) => f(...a)
@@ -2204,28 +2540,28 @@ var InvitationsHandler = class {
2204
2540
  ...result,
2205
2541
  state: Invitation4.State.SUCCESS
2206
2542
  });
2207
- log7.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.end({
2543
+ log8.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.end({
2208
2544
  id: traceId
2209
2545
  }), {
2210
- F: __dxlog_file9,
2546
+ F: __dxlog_file11,
2211
2547
  L: 308,
2212
2548
  S: this,
2213
2549
  C: (f, a) => f(...a)
2214
2550
  });
2215
2551
  } catch (err) {
2216
2552
  if (err instanceof TimeoutError) {
2217
- log7("timeout", {
2553
+ log8("timeout", {
2218
2554
  ...protocol.toJSON()
2219
2555
  }, {
2220
- F: __dxlog_file9,
2556
+ F: __dxlog_file11,
2221
2557
  L: 311,
2222
2558
  S: this,
2223
2559
  C: (f, a) => f(...a)
2224
2560
  });
2225
2561
  guardedState.set(extension, Invitation4.State.TIMEOUT);
2226
2562
  } else {
2227
- log7("auth failed", err, {
2228
- F: __dxlog_file9,
2563
+ log8("auth failed", err, {
2564
+ F: __dxlog_file11,
2229
2565
  L: 314,
2230
2566
  S: this,
2231
2567
  C: (f, a) => f(...a)
@@ -2233,11 +2569,11 @@ var InvitationsHandler = class {
2233
2569
  guardedState.error(extension, err);
2234
2570
  }
2235
2571
  extensionCtx.close(err);
2236
- log7.trace("dxos.sdk.invitations-handler.guest.onOpen", trace4.error({
2572
+ log8.trace("dxos.sdk.invitations-handler.guest.onOpen", trace5.error({
2237
2573
  id: traceId,
2238
2574
  error: err
2239
2575
  }), {
2240
- F: __dxlog_file9,
2576
+ F: __dxlog_file11,
2241
2577
  L: 318,
2242
2578
  S: this,
2243
2579
  C: (f, a) => f(...a)
@@ -2250,18 +2586,18 @@ var InvitationsHandler = class {
2250
2586
  return;
2251
2587
  }
2252
2588
  if (err instanceof TimeoutError) {
2253
- log7("timeout", {
2589
+ log8("timeout", {
2254
2590
  ...protocol.toJSON()
2255
2591
  }, {
2256
- F: __dxlog_file9,
2592
+ F: __dxlog_file11,
2257
2593
  L: 327,
2258
2594
  S: this,
2259
2595
  C: (f, a) => f(...a)
2260
2596
  });
2261
2597
  guardedState.set(extension, Invitation4.State.TIMEOUT);
2262
2598
  } else {
2263
- log7("auth failed", err, {
2264
- F: __dxlog_file9,
2599
+ log8("auth failed", err, {
2600
+ F: __dxlog_file11,
2265
2601
  L: 330,
2266
2602
  S: this,
2267
2603
  C: (f, a) => f(...a)
@@ -2278,8 +2614,8 @@ var InvitationsHandler = class {
2278
2614
  stream.error(error);
2279
2615
  await ctx.dispose();
2280
2616
  } else {
2281
- invariant8(invitation.swarmKey, void 0, {
2282
- F: __dxlog_file9,
2617
+ invariant9(invitation.swarmKey, void 0, {
2618
+ F: __dxlog_file11,
2283
2619
  L: 345,
2284
2620
  S: this,
2285
2621
  A: [
@@ -2373,12 +2709,12 @@ var InvitationsHandler = class {
2373
2709
  };
2374
2710
  }
2375
2711
  _logStateUpdate(invitation, actor, newState) {
2376
- log7("invitation state update", {
2712
+ log8("invitation state update", {
2377
2713
  actor: actor?.constructor.name,
2378
2714
  newState: stateToString(newState),
2379
2715
  oldState: stateToString(invitation.state)
2380
2716
  }, {
2381
- F: __dxlog_file9,
2717
+ F: __dxlog_file11,
2382
2718
  L: 438,
2383
2719
  S: this,
2384
2720
  C: (f, a) => f(...a)
@@ -2395,16 +2731,16 @@ var InvitationsHandler = class {
2395
2731
  }
2396
2732
  async _handleGuestOtpAuth(extension, setState, authenticated, options) {
2397
2733
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2398
- log7("guest waiting for authentication code...", void 0, {
2399
- F: __dxlog_file9,
2734
+ log8("guest waiting for authentication code...", void 0, {
2735
+ F: __dxlog_file11,
2400
2736
  L: 462,
2401
2737
  S: this,
2402
2738
  C: (f, a) => f(...a)
2403
2739
  });
2404
2740
  setState(Invitation4.State.READY_FOR_AUTHENTICATION);
2405
2741
  const authCode = await authenticated.wait(options);
2406
- log7("sending authentication request", void 0, {
2407
- F: __dxlog_file9,
2742
+ log8("sending authentication request", void 0, {
2743
+ F: __dxlog_file11,
2408
2744
  L: 466,
2409
2745
  S: this,
2410
2746
  C: (f, a) => f(...a)
@@ -2420,10 +2756,10 @@ var InvitationsHandler = class {
2420
2756
  if (attempt === MAX_OTP_ATTEMPTS) {
2421
2757
  throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
2422
2758
  } else {
2423
- log7("retrying invalid code", {
2759
+ log8("retrying invalid code", {
2424
2760
  attempt
2425
2761
  }, {
2426
- F: __dxlog_file9,
2762
+ F: __dxlog_file11,
2427
2763
  L: 477,
2428
2764
  S: this,
2429
2765
  C: (f, a) => f(...a)
@@ -2440,8 +2776,8 @@ var InvitationsHandler = class {
2440
2776
  if (introductionResponse.challenge == null) {
2441
2777
  throw new Error("challenge missing in the introduction");
2442
2778
  }
2443
- log7("sending authentication request", void 0, {
2444
- F: __dxlog_file9,
2779
+ log8("sending authentication request", void 0, {
2780
+ F: __dxlog_file11,
2445
2781
  L: 496,
2446
2782
  S: this,
2447
2783
  C: (f, a) => f(...a)
@@ -2465,7 +2801,7 @@ var createAdmissionKeypair = () => {
2465
2801
  };
2466
2802
 
2467
2803
  // packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
2468
- import { Stream as Stream8 } from "@dxos/codec-protobuf";
2804
+ import { Stream as Stream9 } from "@dxos/codec-protobuf";
2469
2805
  import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
2470
2806
  var InvitationsServiceImpl = class {
2471
2807
  constructor(_invitationsManager) {
@@ -2476,13 +2812,13 @@ var InvitationsServiceImpl = class {
2476
2812
  return {};
2477
2813
  }
2478
2814
  createInvitation(options) {
2479
- return new Stream8(({ next, close }) => {
2815
+ return new Stream9(({ next, close }) => {
2480
2816
  void this._invitationsManager.createInvitation(options).then((invitation) => invitation.subscribe(next, close, close)).catch(close);
2481
2817
  });
2482
2818
  }
2483
2819
  acceptInvitation(request) {
2484
2820
  const invitation = this._invitationsManager.acceptInvitation(request);
2485
- return new Stream8(({ next, close }) => {
2821
+ return new Stream9(({ next, close }) => {
2486
2822
  invitation.subscribe(next, close, close);
2487
2823
  });
2488
2824
  }
@@ -2493,7 +2829,7 @@ var InvitationsServiceImpl = class {
2493
2829
  return this._invitationsManager.cancelInvitation(request);
2494
2830
  }
2495
2831
  queryInvitations() {
2496
- return new Stream8(({ next, ctx }) => {
2832
+ return new Stream9(({ next, ctx }) => {
2497
2833
  this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
2498
2834
  next({
2499
2835
  action: QueryInvitationsResponse.Action.ADDED,
@@ -2564,12 +2900,12 @@ var InvitationsServiceImpl = class {
2564
2900
  // packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
2565
2901
  import { createAdmissionCredentials, createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInvitationCredential, getCredentialAssertion } from "@dxos/credentials";
2566
2902
  import { writeMessages as writeMessages2 } from "@dxos/feed-store";
2567
- import { invariant as invariant9 } from "@dxos/invariant";
2568
- import { log as log8 } from "@dxos/log";
2903
+ import { invariant as invariant10 } from "@dxos/invariant";
2904
+ import { log as log9 } from "@dxos/log";
2569
2905
  import { AlreadyJoinedError as AlreadyJoinedError2, AuthorizationError, InvalidInvitationError, SpaceNotFoundError } from "@dxos/protocols";
2570
2906
  import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
2571
- import { SpaceMember } from "@dxos/protocols/proto/dxos/halo/credentials";
2572
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
2907
+ import { SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
2908
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
2573
2909
  var SpaceInvitationProtocol = class {
2574
2910
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
2575
2911
  this._spaceManager = _spaceManager;
@@ -2603,8 +2939,8 @@ var SpaceInvitationProtocol = class {
2603
2939
  };
2604
2940
  }
2605
2941
  async admit(invitation, request, guestProfile) {
2606
- invariant9(this._spaceKey, void 0, {
2607
- F: __dxlog_file10,
2942
+ invariant10(this._spaceKey, void 0, {
2943
+ F: __dxlog_file12,
2608
2944
  L: 76,
2609
2945
  S: this,
2610
2946
  A: [
@@ -2613,8 +2949,8 @@ var SpaceInvitationProtocol = class {
2613
2949
  ]
2614
2950
  });
2615
2951
  const space = this._spaceManager.spaces.get(this._spaceKey);
2616
- invariant9(space, void 0, {
2617
- F: __dxlog_file10,
2952
+ invariant10(space, void 0, {
2953
+ F: __dxlog_file12,
2618
2954
  L: 78,
2619
2955
  S: this,
2620
2956
  A: [
@@ -2622,8 +2958,8 @@ var SpaceInvitationProtocol = class {
2622
2958
  ""
2623
2959
  ]
2624
2960
  });
2625
- invariant9(request.space, void 0, {
2626
- F: __dxlog_file10,
2961
+ invariant10(request.space, void 0, {
2962
+ F: __dxlog_file12,
2627
2963
  L: 80,
2628
2964
  S: this,
2629
2965
  A: [
@@ -2632,21 +2968,21 @@ var SpaceInvitationProtocol = class {
2632
2968
  ]
2633
2969
  });
2634
2970
  const { identityKey, deviceKey } = request.space;
2635
- if (space.inner.spaceState.getMemberRole(identityKey) !== SpaceMember.Role.REMOVED) {
2971
+ if (space.inner.spaceState.getMemberRole(identityKey) !== SpaceMember2.Role.REMOVED) {
2636
2972
  throw new AlreadyJoinedError2();
2637
2973
  }
2638
- log8("writing guest credentials", {
2974
+ log9("writing guest credentials", {
2639
2975
  host: this._signingContext.deviceKey,
2640
2976
  guest: deviceKey
2641
2977
  }, {
2642
- F: __dxlog_file10,
2978
+ F: __dxlog_file12,
2643
2979
  L: 87,
2644
2980
  S: this,
2645
2981
  C: (f, a) => f(...a)
2646
2982
  });
2647
- const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, invitation.role ?? SpaceMember.Role.ADMIN, space.inner.spaceState.membershipChainHeads, guestProfile, invitation.delegationCredentialId);
2648
- invariant9(credentials[0].credential, void 0, {
2649
- F: __dxlog_file10,
2983
+ const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, invitation.role ?? SpaceMember2.Role.ADMIN, space.inner.spaceState.membershipChainHeads, guestProfile, invitation.delegationCredentialId);
2984
+ invariant10(credentials[0].credential, void 0, {
2985
+ F: __dxlog_file12,
2650
2986
  L: 101,
2651
2987
  S: this,
2652
2988
  A: [
@@ -2655,8 +2991,8 @@ var SpaceInvitationProtocol = class {
2655
2991
  ]
2656
2992
  });
2657
2993
  const spaceMemberCredential = credentials[0].credential.credential;
2658
- invariant9(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2659
- F: __dxlog_file10,
2994
+ invariant10(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2995
+ F: __dxlog_file12,
2660
2996
  L: 103,
2661
2997
  S: this,
2662
2998
  A: [
@@ -2673,8 +3009,8 @@ var SpaceInvitationProtocol = class {
2673
3009
  };
2674
3010
  }
2675
3011
  async delegate(invitation) {
2676
- invariant9(this._spaceKey, void 0, {
2677
- F: __dxlog_file10,
3012
+ invariant10(this._spaceKey, void 0, {
3013
+ F: __dxlog_file12,
2678
3014
  L: 116,
2679
3015
  S: this,
2680
3016
  A: [
@@ -2683,8 +3019,8 @@ var SpaceInvitationProtocol = class {
2683
3019
  ]
2684
3020
  });
2685
3021
  const space = this._spaceManager.spaces.get(this._spaceKey);
2686
- invariant9(space, void 0, {
2687
- F: __dxlog_file10,
3022
+ invariant10(space, void 0, {
3023
+ F: __dxlog_file12,
2688
3024
  L: 118,
2689
3025
  S: this,
2690
3026
  A: [
@@ -2693,8 +3029,8 @@ var SpaceInvitationProtocol = class {
2693
3029
  ]
2694
3030
  });
2695
3031
  if (invitation.authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY) {
2696
- invariant9(invitation.guestKeypair?.publicKey, void 0, {
2697
- F: __dxlog_file10,
3032
+ invariant10(invitation.guestKeypair?.publicKey, void 0, {
3033
+ F: __dxlog_file12,
2698
3034
  L: 120,
2699
3035
  S: this,
2700
3036
  A: [
@@ -2703,11 +3039,11 @@ var SpaceInvitationProtocol = class {
2703
3039
  ]
2704
3040
  });
2705
3041
  }
2706
- log8("writing delegate space invitation", {
3042
+ log9("writing delegate space invitation", {
2707
3043
  host: this._signingContext.deviceKey,
2708
3044
  id: invitation.invitationId
2709
3045
  }, {
2710
- F: __dxlog_file10,
3046
+ F: __dxlog_file12,
2711
3047
  L: 123,
2712
3048
  S: this,
2713
3049
  C: (f, a) => f(...a)
@@ -2716,13 +3052,13 @@ var SpaceInvitationProtocol = class {
2716
3052
  invitationId: invitation.invitationId,
2717
3053
  authMethod: invitation.authMethod,
2718
3054
  swarmKey: invitation.swarmKey,
2719
- role: invitation.role ?? SpaceMember.Role.ADMIN,
3055
+ role: invitation.role ?? SpaceMember2.Role.ADMIN,
2720
3056
  expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
2721
3057
  multiUse: invitation.multiUse ?? false,
2722
3058
  guestKey: invitation.authMethod === Invitation5.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
2723
3059
  });
2724
- invariant9(credential.credential, void 0, {
2725
- F: __dxlog_file10,
3060
+ invariant10(credential.credential, void 0, {
3061
+ F: __dxlog_file12,
2726
3062
  L: 143,
2727
3063
  S: this,
2728
3064
  A: [
@@ -2736,8 +3072,8 @@ var SpaceInvitationProtocol = class {
2736
3072
  return credential.credential.credential.id;
2737
3073
  }
2738
3074
  async cancelDelegation(invitation) {
2739
- invariant9(this._spaceKey, void 0, {
2740
- F: __dxlog_file10,
3075
+ invariant10(this._spaceKey, void 0, {
3076
+ F: __dxlog_file12,
2741
3077
  L: 149,
2742
3078
  S: this,
2743
3079
  A: [
@@ -2745,8 +3081,8 @@ var SpaceInvitationProtocol = class {
2745
3081
  ""
2746
3082
  ]
2747
3083
  });
2748
- invariant9(invitation.type === Invitation5.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
2749
- F: __dxlog_file10,
3084
+ invariant10(invitation.type === Invitation5.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
3085
+ F: __dxlog_file12,
2750
3086
  L: 150,
2751
3087
  S: this,
2752
3088
  A: [
@@ -2755,8 +3091,8 @@ var SpaceInvitationProtocol = class {
2755
3091
  ]
2756
3092
  });
2757
3093
  const space = this._spaceManager.spaces.get(this._spaceKey);
2758
- invariant9(space, void 0, {
2759
- F: __dxlog_file10,
3094
+ invariant10(space, void 0, {
3095
+ F: __dxlog_file12,
2760
3096
  L: 152,
2761
3097
  S: this,
2762
3098
  A: [
@@ -2764,18 +3100,18 @@ var SpaceInvitationProtocol = class {
2764
3100
  ""
2765
3101
  ]
2766
3102
  });
2767
- log8("cancelling delegated space invitation", {
3103
+ log9("cancelling delegated space invitation", {
2768
3104
  host: this._signingContext.deviceKey,
2769
3105
  id: invitation.invitationId
2770
3106
  }, {
2771
- F: __dxlog_file10,
3107
+ F: __dxlog_file12,
2772
3108
  L: 154,
2773
3109
  S: this,
2774
3110
  C: (f, a) => f(...a)
2775
3111
  });
2776
3112
  const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
2777
- invariant9(credential.credential, void 0, {
2778
- F: __dxlog_file10,
3113
+ invariant10(credential.credential, void 0, {
3114
+ F: __dxlog_file12,
2779
3115
  L: 161,
2780
3116
  S: this,
2781
3117
  A: [
@@ -2813,8 +3149,8 @@ var SpaceInvitationProtocol = class {
2813
3149
  };
2814
3150
  }
2815
3151
  async accept(response) {
2816
- invariant9(response.space, void 0, {
2817
- F: __dxlog_file10,
3152
+ invariant10(response.space, void 0, {
3153
+ F: __dxlog_file12,
2818
3154
  L: 196,
2819
3155
  S: this,
2820
3156
  A: [
@@ -2824,8 +3160,8 @@ var SpaceInvitationProtocol = class {
2824
3160
  });
2825
3161
  const { credential, controlTimeframe, dataTimeframe } = response.space;
2826
3162
  const assertion = getCredentialAssertion(credential);
2827
- invariant9(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
2828
- F: __dxlog_file10,
3163
+ invariant10(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
3164
+ F: __dxlog_file12,
2829
3165
  L: 199,
2830
3166
  S: this,
2831
3167
  A: [
@@ -2833,8 +3169,8 @@ var SpaceInvitationProtocol = class {
2833
3169
  "'Invalid credential'"
2834
3170
  ]
2835
3171
  });
2836
- invariant9(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
2837
- F: __dxlog_file10,
3172
+ invariant10(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
3173
+ F: __dxlog_file12,
2838
3174
  L: 200,
2839
3175
  S: this,
2840
3176
  A: [
@@ -2859,17 +3195,17 @@ var SpaceInvitationProtocol = class {
2859
3195
  };
2860
3196
 
2861
3197
  // packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts
2862
- import { Event as Event3, PushStream, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
3198
+ import { Event as Event3, PushStream, TimeoutError as TimeoutError2, Trigger as Trigger5 } from "@dxos/async";
2863
3199
  import { AuthenticatingInvitation, AUTHENTICATION_CODE_LENGTH, CancellableInvitation, INVITATION_TIMEOUT as INVITATION_TIMEOUT2 } from "@dxos/client-protocol";
2864
3200
  import { Context as Context6 } from "@dxos/context";
2865
3201
  import { generatePasscode } from "@dxos/credentials";
2866
3202
  import { hasInvitationExpired } from "@dxos/echo-pipeline";
2867
- import { invariant as invariant10 } from "@dxos/invariant";
3203
+ import { invariant as invariant11 } from "@dxos/invariant";
2868
3204
  import { PublicKey as PublicKey8 } from "@dxos/keys";
2869
- import { log as log9 } from "@dxos/log";
3205
+ import { log as log10 } from "@dxos/log";
2870
3206
  import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
2871
- import { SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/halo/credentials";
2872
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
3207
+ import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/halo/credentials";
3208
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
2873
3209
  var InvitationsManager = class {
2874
3210
  constructor(_invitationsHandler, _getHandler, _metadataStore) {
2875
3211
  this._invitationsHandler = _invitationsHandler;
@@ -2911,8 +3247,8 @@ var InvitationsManager = class {
2911
3247
  try {
2912
3248
  await this._persistIfRequired(handler, stream, invitation);
2913
3249
  } catch (err) {
2914
- log9.catch(err, void 0, {
2915
- F: __dxlog_file11,
3250
+ log10.catch(err, void 0, {
3251
+ F: __dxlog_file13,
2916
3252
  L: 82,
2917
3253
  S: this,
2918
3254
  C: (f, a) => f(...a)
@@ -2934,8 +3270,8 @@ var InvitationsManager = class {
2934
3270
  const persistentInvitations = this._metadataStore.getInvitations();
2935
3271
  const freshInvitations = persistentInvitations.filter((invitation) => !hasInvitationExpired(invitation));
2936
3272
  const loadTasks = freshInvitations.map((persistentInvitation) => {
2937
- invariant10(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
2938
- F: __dxlog_file11,
3273
+ invariant11(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
3274
+ F: __dxlog_file13,
2939
3275
  L: 103,
2940
3276
  S: this,
2941
3277
  A: [
@@ -2953,8 +3289,8 @@ var InvitationsManager = class {
2953
3289
  invitations: cInvitations.map((invitation) => invitation.get())
2954
3290
  };
2955
3291
  } catch (err) {
2956
- log9.catch(err, void 0, {
2957
- F: __dxlog_file11,
3292
+ log10.catch(err, void 0, {
3293
+ F: __dxlog_file13,
2958
3294
  L: 110,
2959
3295
  S: this,
2960
3296
  C: (f, a) => f(...a)
@@ -2985,14 +3321,14 @@ var InvitationsManager = class {
2985
3321
  return invitation;
2986
3322
  }
2987
3323
  async authenticate({ invitationId, authCode }) {
2988
- log9("authenticating...", void 0, {
2989
- F: __dxlog_file11,
3324
+ log10("authenticating...", void 0, {
3325
+ F: __dxlog_file13,
2990
3326
  L: 140,
2991
3327
  S: this,
2992
3328
  C: (f, a) => f(...a)
2993
3329
  });
2994
- invariant10(invitationId, void 0, {
2995
- F: __dxlog_file11,
3330
+ invariant11(invitationId, void 0, {
3331
+ F: __dxlog_file13,
2996
3332
  L: 141,
2997
3333
  S: this,
2998
3334
  A: [
@@ -3002,10 +3338,10 @@ var InvitationsManager = class {
3002
3338
  });
3003
3339
  const observable = this._acceptInvitations.get(invitationId);
3004
3340
  if (!observable) {
3005
- log9.warn("invalid invitation", {
3341
+ log10.warn("invalid invitation", {
3006
3342
  invitationId
3007
3343
  }, {
3008
- F: __dxlog_file11,
3344
+ F: __dxlog_file13,
3009
3345
  L: 144,
3010
3346
  S: this,
3011
3347
  C: (f, a) => f(...a)
@@ -3015,16 +3351,16 @@ var InvitationsManager = class {
3015
3351
  }
3016
3352
  }
3017
3353
  async cancelInvitation({ invitationId }) {
3018
- log9("cancelInvitation...", {
3354
+ log10("cancelInvitation...", {
3019
3355
  invitationId
3020
3356
  }, {
3021
- F: __dxlog_file11,
3357
+ F: __dxlog_file13,
3022
3358
  L: 151,
3023
3359
  S: this,
3024
3360
  C: (f, a) => f(...a)
3025
3361
  });
3026
- invariant10(invitationId, void 0, {
3027
- F: __dxlog_file11,
3362
+ invariant11(invitationId, void 0, {
3363
+ F: __dxlog_file13,
3028
3364
  L: 152,
3029
3365
  S: this,
3030
3366
  A: [
@@ -3071,7 +3407,7 @@ var InvitationsManager = class {
3071
3407
  }
3072
3408
  }
3073
3409
  _createInvitation(protocol, options) {
3074
- const { invitationId = PublicKey8.random().toHex(), type = Invitation6.Type.INTERACTIVE, authMethod = Invitation6.AuthMethod.SHARED_SECRET, state = Invitation6.State.INIT, timeout = INVITATION_TIMEOUT2, swarmKey = PublicKey8.random(), persistent = options?.authMethod !== Invitation6.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = SpaceMember2.Role.ADMIN, lifetime = 86400, multiUse = false } = options ?? {};
3410
+ const { invitationId = PublicKey8.random().toHex(), type = Invitation6.Type.INTERACTIVE, authMethod = Invitation6.AuthMethod.SHARED_SECRET, state = Invitation6.State.INIT, timeout = INVITATION_TIMEOUT2, swarmKey = PublicKey8.random(), persistent = options?.authMethod !== Invitation6.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = SpaceMember3.Role.ADMIN, lifetime = 86400, multiUse = false } = options ?? {};
3075
3411
  const authCode = options?.authCode ?? (authMethod === Invitation6.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
3076
3412
  return {
3077
3413
  invitationId,
@@ -3100,10 +3436,10 @@ var InvitationsManager = class {
3100
3436
  }
3101
3437
  });
3102
3438
  ctx.onDispose(() => {
3103
- log9("complete", {
3439
+ log10("complete", {
3104
3440
  ...handler.toJSON()
3105
3441
  }, {
3106
- F: __dxlog_file11,
3442
+ F: __dxlog_file13,
3107
3443
  L: 241,
3108
3444
  S: this,
3109
3445
  C: (f, a) => f(...a)
@@ -3128,15 +3464,15 @@ var InvitationsManager = class {
3128
3464
  };
3129
3465
  }
3130
3466
  _createObservableAcceptingInvitation(handler, initialState) {
3131
- const otpEnteredTrigger = new Trigger4();
3467
+ const otpEnteredTrigger = new Trigger5();
3132
3468
  const stream = new PushStream();
3133
3469
  const ctx = new Context6({
3134
3470
  onError: (err) => {
3135
3471
  if (err instanceof TimeoutError2) {
3136
- log9("timeout", {
3472
+ log10("timeout", {
3137
3473
  ...handler.toJSON()
3138
3474
  }, {
3139
- F: __dxlog_file11,
3475
+ F: __dxlog_file13,
3140
3476
  L: 261,
3141
3477
  S: this,
3142
3478
  C: (f, a) => f(...a)
@@ -3146,8 +3482,8 @@ var InvitationsManager = class {
3146
3482
  state: Invitation6.State.TIMEOUT
3147
3483
  });
3148
3484
  } else {
3149
- log9.warn("auth failed", err, {
3150
- F: __dxlog_file11,
3485
+ log10.warn("auth failed", err, {
3486
+ F: __dxlog_file13,
3151
3487
  L: 264,
3152
3488
  S: this,
3153
3489
  C: (f, a) => f(...a)
@@ -3161,10 +3497,10 @@ var InvitationsManager = class {
3161
3497
  }
3162
3498
  });
3163
3499
  ctx.onDispose(() => {
3164
- log9("complete", {
3500
+ log10("complete", {
3165
3501
  ...handler.toJSON()
3166
3502
  }, {
3167
- F: __dxlog_file11,
3503
+ F: __dxlog_file13,
3168
3504
  L: 271,
3169
3505
  S: this,
3170
3506
  C: (f, a) => f(...a)
@@ -3208,8 +3544,8 @@ var InvitationsManager = class {
3208
3544
  try {
3209
3545
  await this._metadataStore.removeInvitation(invitation.invitationId);
3210
3546
  } catch (err) {
3211
- log9.catch(err, void 0, {
3212
- F: __dxlog_file11,
3547
+ log10.catch(err, void 0, {
3548
+ F: __dxlog_file13,
3213
3549
  L: 307,
3214
3550
  S: this,
3215
3551
  C: (f, a) => f(...a)
@@ -3223,100 +3559,19 @@ var InvitationsManager = class {
3223
3559
  }
3224
3560
  };
3225
3561
 
3226
- // packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
3227
- import { Stream as Stream9 } from "@dxos/codec-protobuf";
3228
- import { raise } from "@dxos/debug";
3229
- import { parseMethodName, RpcPeer } from "@dxos/rpc";
3230
- import { MapCounter, trace as trace5 } from "@dxos/tracing";
3231
- function _ts_decorate3(decorators, target, key, desc) {
3232
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3233
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3234
- r = Reflect.decorate(decorators, target, key, desc);
3235
- else
3236
- for (var i = decorators.length - 1; i >= 0; i--)
3237
- if (d = decorators[i])
3238
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3239
- return c > 3 && r && Object.defineProperty(target, key, r), r;
3240
- }
3241
- var ClientRpcServer = class {
3242
- constructor(params) {
3243
- this._handlerCache = /* @__PURE__ */ new Map();
3244
- this._callMetrics = new MapCounter();
3245
- const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
3246
- this._handleCall = handleCall;
3247
- this._handleStream = handleStream;
3248
- this._serviceRegistry = serviceRegistry;
3249
- this._rpcPeer = new RpcPeer({
3250
- ...rpcOptions,
3251
- callHandler: (method, params2) => {
3252
- const [serviceName, methodName] = parseMethodName(method);
3253
- const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
3254
- this._callMetrics.inc(`${serviceName}.${methodName} request`);
3255
- if (this._handleCall) {
3256
- return this._handleCall(methodName, params2, handler);
3257
- } else {
3258
- return handler(methodName, params2);
3259
- }
3260
- },
3261
- streamHandler: (method, params2) => {
3262
- const [serviceName, methodName] = parseMethodName(method);
3263
- const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
3264
- this._callMetrics.inc(`${serviceName}.${methodName} request stream`);
3265
- if (this._handleStream) {
3266
- return Stream9.map(Stream9.unwrapPromise(this._handleStream(methodName, params2, handler)), (data) => {
3267
- this._callMetrics.inc(`${serviceName}.${methodName} response stream`);
3268
- return data;
3269
- });
3270
- } else {
3271
- return handler(methodName, params2);
3272
- }
3273
- }
3274
- });
3275
- }
3276
- get _services() {
3277
- return Object.keys(this._serviceRegistry.services);
3278
- }
3279
- async open() {
3280
- await this._rpcPeer.open();
3281
- }
3282
- async close() {
3283
- await this._rpcPeer.close();
3284
- }
3285
- _getServiceHandler(serviceName) {
3286
- if (!this._handlerCache.has(serviceName)) {
3287
- const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? raise(new Error(`Service not available: ${serviceName}`));
3288
- const service = this._serviceRegistry.services[key];
3289
- if (!service) {
3290
- throw new Error(`Service not available: ${serviceName}`);
3291
- }
3292
- this._handlerCache.set(serviceName, descriptor.createServer(service));
3293
- }
3294
- return this._handlerCache.get(serviceName);
3295
- }
3296
- };
3297
- _ts_decorate3([
3298
- trace5.metricsCounter()
3299
- ], ClientRpcServer.prototype, "_callMetrics", void 0);
3300
- _ts_decorate3([
3301
- trace5.info()
3302
- ], ClientRpcServer.prototype, "_services", null);
3303
- ClientRpcServer = _ts_decorate3([
3304
- trace5.resource()
3305
- ], ClientRpcServer);
3306
-
3307
3562
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
3308
- import { Event as Event6, asyncTimeout, scheduleTask as scheduleTask5, sleep as sleep2, synchronized, trackLeaks } from "@dxos/async";
3563
+ import { Event as Event6, asyncTimeout as asyncTimeout2, scheduleTask as scheduleTask5, sleep as sleep2, synchronized, trackLeaks } from "@dxos/async";
3309
3564
  import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
3310
3565
  import { Context as Context8, ContextDisposedError as ContextDisposedError3, cancelWithContext as cancelWithContext4 } from "@dxos/context";
3311
3566
  import { timed, warnAfterTimeout } from "@dxos/debug";
3312
3567
  import { AutomergeDocumentLoaderImpl, createIdFromSpaceKey, createMappedFeedWriter } from "@dxos/echo-pipeline";
3313
3568
  import { TYPE_PROPERTIES } from "@dxos/echo-schema";
3314
- import { failedInvariant, invariant as invariant12 } from "@dxos/invariant";
3569
+ import { failedInvariant, invariant as invariant13 } from "@dxos/invariant";
3315
3570
  import { PublicKey as PublicKey10 } from "@dxos/keys";
3316
- import { log as log11 } from "@dxos/log";
3571
+ import { log as log12 } from "@dxos/log";
3317
3572
  import { CancelledError, SystemError } from "@dxos/protocols";
3318
3573
  import { CreateEpochRequest, SpaceState } from "@dxos/protocols/proto/dxos/client/services";
3319
- import { AdmittedFeed as AdmittedFeed3, SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/halo/credentials";
3574
+ import { AdmittedFeed as AdmittedFeed3, SpaceMember as SpaceMember4 } from "@dxos/protocols/proto/dxos/halo/credentials";
3320
3575
  import { Timeframe as Timeframe2 } from "@dxos/timeframe";
3321
3576
  import { trace as trace6 } from "@dxos/tracing";
3322
3577
  import { ComplexSet as ComplexSet5, assignDeep } from "@dxos/util";
@@ -3360,15 +3615,15 @@ var AutomergeSpaceState = class {
3360
3615
  };
3361
3616
 
3362
3617
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
3363
- import { DeferredTask, Event as Event5, scheduleTask as scheduleTask4, sleep, TimeoutError as TimeoutError3, Trigger as Trigger5 } from "@dxos/async";
3618
+ import { DeferredTask, Event as Event5, scheduleTask as scheduleTask4, sleep, TimeoutError as TimeoutError3, Trigger as Trigger6 } from "@dxos/async";
3364
3619
  import { Context as Context7, rejectOnDispose } from "@dxos/context";
3365
- import { invariant as invariant11 } from "@dxos/invariant";
3620
+ import { invariant as invariant12 } from "@dxos/invariant";
3366
3621
  import { PublicKey as PublicKey9 } from "@dxos/keys";
3367
- import { log as log10 } from "@dxos/log";
3622
+ import { log as log11 } from "@dxos/log";
3368
3623
  import { schema as schema4 } from "@dxos/protocols";
3369
3624
  import { RpcExtension as RpcExtension3 } from "@dxos/teleport";
3370
3625
  import { ComplexMap as ComplexMap2, ComplexSet as ComplexSet4, entry } from "@dxos/util";
3371
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
3626
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
3372
3627
  var DEFAULT_RETRY_TIMEOUT = 1e3;
3373
3628
  var DEFAULT_SUCCESS_DELAY = 1e3;
3374
3629
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
@@ -3393,16 +3648,16 @@ var NotarizationPlugin = class {
3393
3648
  * Request credentials to be notarized.
3394
3649
  */
3395
3650
  async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
3396
- log10("notarize", {
3651
+ log11("notarize", {
3397
3652
  credentials
3398
3653
  }, {
3399
- F: __dxlog_file12,
3654
+ F: __dxlog_file14,
3400
3655
  L: 90,
3401
3656
  S: this,
3402
3657
  C: (f, a) => f(...a)
3403
3658
  });
3404
- invariant11(credentials.every((credential) => credential.id), "Credentials must have an id", {
3405
- F: __dxlog_file12,
3659
+ invariant12(credentials.every((credential) => credential.id), "Credentials must have an id", {
3660
+ F: __dxlog_file14,
3406
3661
  L: 91,
3407
3662
  S: this,
3408
3663
  A: [
@@ -3410,13 +3665,13 @@ var NotarizationPlugin = class {
3410
3665
  "'Credentials must have an id'"
3411
3666
  ]
3412
3667
  });
3413
- const errors = new Trigger5();
3668
+ const errors = new Trigger6();
3414
3669
  const ctx = this._ctx.derive({
3415
3670
  onError: (err) => {
3416
- log10.warn("Notarization error", {
3671
+ log11.warn("Notarization error", {
3417
3672
  err
3418
3673
  }, {
3419
- F: __dxlog_file12,
3674
+ F: __dxlog_file14,
3420
3675
  L: 99,
3421
3676
  S: this,
3422
3677
  C: (f, a) => f(...a)
@@ -3428,11 +3683,11 @@ var NotarizationPlugin = class {
3428
3683
  opCtx?.onDispose(() => ctx.dispose());
3429
3684
  if (timeout !== 0) {
3430
3685
  scheduleTask4(ctx, () => {
3431
- log10.warn("Notarization timeout", {
3686
+ log11.warn("Notarization timeout", {
3432
3687
  timeout,
3433
3688
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
3434
3689
  }, {
3435
- F: __dxlog_file12,
3690
+ F: __dxlog_file14,
3436
3691
  L: 111,
3437
3692
  S: this,
3438
3693
  C: (f, a) => f(...a)
@@ -3452,10 +3707,10 @@ var NotarizationPlugin = class {
3452
3707
  ...this._extensions
3453
3708
  ].find((peer2) => !peersTried.has(peer2));
3454
3709
  if (!peer) {
3455
- log10.info("Exhausted all peers to notarize with", {
3710
+ log11.info("Exhausted all peers to notarize with", {
3456
3711
  retryIn: retryTimeout
3457
3712
  }, {
3458
- F: __dxlog_file12,
3713
+ F: __dxlog_file14,
3459
3714
  L: 136,
3460
3715
  S: this,
3461
3716
  C: (f, a) => f(...a)
@@ -3465,11 +3720,11 @@ var NotarizationPlugin = class {
3465
3720
  return;
3466
3721
  }
3467
3722
  peersTried.add(peer);
3468
- log10("try notarizing", {
3723
+ log11("try notarizing", {
3469
3724
  peer: peer.localPeerId,
3470
3725
  credentialId: credentials.map((credential) => credential.id)
3471
3726
  }, {
3472
- F: __dxlog_file12,
3727
+ F: __dxlog_file14,
3473
3728
  L: 143,
3474
3729
  S: this,
3475
3730
  C: (f, a) => f(...a)
@@ -3477,8 +3732,8 @@ var NotarizationPlugin = class {
3477
3732
  await peer.rpc.NotarizationService.notarize({
3478
3733
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
3479
3734
  });
3480
- log10("success", void 0, {
3481
- F: __dxlog_file12,
3735
+ log11("success", void 0, {
3736
+ F: __dxlog_file14,
3482
3737
  L: 147,
3483
3738
  S: this,
3484
3739
  C: (f, a) => f(...a)
@@ -3486,8 +3741,8 @@ var NotarizationPlugin = class {
3486
3741
  await sleep(successDelay);
3487
3742
  } catch (err) {
3488
3743
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
3489
- log10.info("error notarizing (recoverable)", err, {
3490
- F: __dxlog_file12,
3744
+ log11.info("error notarizing (recoverable)", err, {
3745
+ F: __dxlog_file14,
3491
3746
  L: 151,
3492
3747
  S: this,
3493
3748
  C: (f, a) => f(...a)
@@ -3504,8 +3759,8 @@ var NotarizationPlugin = class {
3504
3759
  allNotarized,
3505
3760
  errors.wait()
3506
3761
  ]);
3507
- log10("done", void 0, {
3508
- F: __dxlog_file12,
3762
+ log11("done", void 0, {
3763
+ F: __dxlog_file14,
3509
3764
  L: 162,
3510
3765
  S: this,
3511
3766
  C: (f, a) => f(...a)
@@ -3526,8 +3781,8 @@ var NotarizationPlugin = class {
3526
3781
  this._processCredentialsTriggers.delete(credential.id);
3527
3782
  }
3528
3783
  setWriter(writer) {
3529
- invariant11(!this._writer, "Writer already set.", {
3530
- F: __dxlog_file12,
3784
+ invariant12(!this._writer, "Writer already set.", {
3785
+ F: __dxlog_file14,
3531
3786
  L: 181,
3532
3787
  S: this,
3533
3788
  A: [
@@ -3541,7 +3796,7 @@ var NotarizationPlugin = class {
3541
3796
  if (this._processedCredentials.has(id)) {
3542
3797
  return;
3543
3798
  }
3544
- await entry(this._processCredentialsTriggers, id).orInsert(new Trigger5()).value.wait();
3799
+ await entry(this._processCredentialsTriggers, id).orInsert(new Trigger6()).value.wait();
3545
3800
  }
3546
3801
  /**
3547
3802
  * Requests from other peers to notarize credentials.
@@ -3551,8 +3806,8 @@ var NotarizationPlugin = class {
3551
3806
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
3552
3807
  }
3553
3808
  for (const credential of request.credentials ?? []) {
3554
- invariant11(credential.id, "Credential must have an id", {
3555
- F: __dxlog_file12,
3809
+ invariant12(credential.id, "Credential must have an id", {
3810
+ F: __dxlog_file14,
3556
3811
  L: 200,
3557
3812
  S: this,
3558
3813
  A: [
@@ -3569,10 +3824,10 @@ var NotarizationPlugin = class {
3569
3824
  createExtension() {
3570
3825
  const extension = new NotarizationTeleportExtension({
3571
3826
  onOpen: async () => {
3572
- log10("extension opened", {
3827
+ log11("extension opened", {
3573
3828
  peer: extension.localPeerId
3574
3829
  }, {
3575
- F: __dxlog_file12,
3830
+ F: __dxlog_file14,
3576
3831
  L: 211,
3577
3832
  S: this,
3578
3833
  C: (f, a) => f(...a)
@@ -3581,10 +3836,10 @@ var NotarizationPlugin = class {
3581
3836
  this._extensionOpened.emit();
3582
3837
  },
3583
3838
  onClose: async () => {
3584
- log10("extension closed", {
3839
+ log11("extension closed", {
3585
3840
  peer: extension.localPeerId
3586
3841
  }, {
3587
- F: __dxlog_file12,
3842
+ F: __dxlog_file14,
3588
3843
  L: 216,
3589
3844
  S: this,
3590
3845
  C: (f, a) => f(...a)
@@ -3638,7 +3893,7 @@ function _ts_decorate4(decorators, target, key, desc) {
3638
3893
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3639
3894
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3640
3895
  }
3641
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
3896
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
3642
3897
  var DataSpace = class {
3643
3898
  constructor(params) {
3644
3899
  this._ctx = new Context8();
@@ -3664,16 +3919,16 @@ var DataSpace = class {
3664
3919
  this._callbacks = params.callbacks ?? {};
3665
3920
  this._echoHost = params.echoHost;
3666
3921
  this.authVerifier = new TrustedKeySetAuthVerifier({
3667
- trustedKeysProvider: () => new ComplexSet5(PublicKey10.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== SpaceMember3.Role.REMOVED).map((member) => member.key)),
3922
+ trustedKeysProvider: () => new ComplexSet5(PublicKey10.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== SpaceMember4.Role.REMOVED).map((member) => member.key)),
3668
3923
  update: this._inner.stateUpdate,
3669
3924
  authTimeout: AUTH_TIMEOUT2
3670
3925
  });
3671
3926
  this._cache = params.cache;
3672
3927
  this._state = params.initialState;
3673
- log11("new state", {
3928
+ log12("new state", {
3674
3929
  state: SpaceState[this._state]
3675
3930
  }, {
3676
- F: __dxlog_file13,
3931
+ F: __dxlog_file15,
3677
3932
  L: 142,
3678
3933
  S: this,
3679
3934
  C: (f, a) => f(...a)
@@ -3723,10 +3978,10 @@ var DataSpace = class {
3723
3978
  await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
3724
3979
  await this._inner.open(new Context8());
3725
3980
  this._state = SpaceState.CONTROL_ONLY;
3726
- log11("new state", {
3981
+ log12("new state", {
3727
3982
  state: SpaceState[this._state]
3728
3983
  }, {
3729
- F: __dxlog_file13,
3984
+ F: __dxlog_file15,
3730
3985
  L: 205,
3731
3986
  S: this,
3732
3987
  C: (f, a) => f(...a)
@@ -3741,10 +3996,10 @@ var DataSpace = class {
3741
3996
  async _close() {
3742
3997
  await this._callbacks.beforeClose?.();
3743
3998
  this._state = SpaceState.CLOSED;
3744
- log11("new state", {
3999
+ log12("new state", {
3745
4000
  state: SpaceState[this._state]
3746
4001
  }, {
3747
- F: __dxlog_file13,
4002
+ F: __dxlog_file15,
3748
4003
  L: 219,
3749
4004
  S: this,
3750
4005
  C: (f, a) => f(...a)
@@ -3775,25 +4030,25 @@ var DataSpace = class {
3775
4030
  await this.initializeDataPipeline();
3776
4031
  } catch (err) {
3777
4032
  if (err instanceof CancelledError || err instanceof ContextDisposedError3) {
3778
- log11("data pipeline initialization cancelled", err, {
3779
- F: __dxlog_file13,
4033
+ log12("data pipeline initialization cancelled", err, {
4034
+ F: __dxlog_file15,
3780
4035
  L: 252,
3781
4036
  S: this,
3782
4037
  C: (f, a) => f(...a)
3783
4038
  });
3784
4039
  return;
3785
4040
  }
3786
- log11.error("Error initializing data pipeline", err, {
3787
- F: __dxlog_file13,
4041
+ log12.error("Error initializing data pipeline", err, {
4042
+ F: __dxlog_file15,
3788
4043
  L: 256,
3789
4044
  S: this,
3790
4045
  C: (f, a) => f(...a)
3791
4046
  });
3792
4047
  this._state = SpaceState.ERROR;
3793
- log11("new state", {
4048
+ log12("new state", {
3794
4049
  state: SpaceState[this._state]
3795
4050
  }, {
3796
- F: __dxlog_file13,
4051
+ F: __dxlog_file15,
3797
4052
  L: 258,
3798
4053
  S: this,
3799
4054
  C: (f, a) => f(...a)
@@ -3810,10 +4065,10 @@ var DataSpace = class {
3810
4065
  throw new SystemError("Invalid operation");
3811
4066
  }
3812
4067
  this._state = SpaceState.INITIALIZING;
3813
- log11("new state", {
4068
+ log12("new state", {
3814
4069
  state: SpaceState[this._state]
3815
4070
  }, {
3816
- F: __dxlog_file13,
4071
+ F: __dxlog_file15,
3817
4072
  L: 274,
3818
4073
  S: this,
3819
4074
  C: (f, a) => f(...a)
@@ -3822,18 +4077,18 @@ var DataSpace = class {
3822
4077
  await sleep2(1);
3823
4078
  this._automergeSpaceState.startProcessingRootDocs();
3824
4079
  await cancelWithContext4(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
3825
- log11("data pipeline ready", void 0, {
3826
- F: __dxlog_file13,
4080
+ log12("data pipeline ready", void 0, {
4081
+ F: __dxlog_file15,
3827
4082
  L: 286,
3828
4083
  S: this,
3829
4084
  C: (f, a) => f(...a)
3830
4085
  });
3831
4086
  await this._callbacks.beforeReady?.();
3832
4087
  this._state = SpaceState.READY;
3833
- log11("new state", {
4088
+ log12("new state", {
3834
4089
  state: SpaceState[this._state]
3835
4090
  }, {
3836
- F: __dxlog_file13,
4091
+ F: __dxlog_file15,
3837
4092
  L: 290,
3838
4093
  S: this,
3839
4094
  C: (f, a) => f(...a)
@@ -3848,8 +4103,8 @@ var DataSpace = class {
3848
4103
  });
3849
4104
  this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
3850
4105
  await this._createWritableFeeds();
3851
- log11("writable feeds created", void 0, {
3852
- F: __dxlog_file13,
4106
+ log12("writable feeds created", void 0, {
4107
+ F: __dxlog_file15,
3853
4108
  L: 306,
3854
4109
  S: this,
3855
4110
  C: (f, a) => f(...a)
@@ -3908,11 +4163,11 @@ var DataSpace = class {
3908
4163
  }
3909
4164
  }
3910
4165
  _onNewAutomergeRoot(rootUrl) {
3911
- log11("loading automerge root doc for space", {
4166
+ log12("loading automerge root doc for space", {
3912
4167
  space: this.key,
3913
4168
  rootUrl
3914
4169
  }, {
3915
- F: __dxlog_file13,
4170
+ F: __dxlog_file15,
3916
4171
  L: 372,
3917
4172
  S: this,
3918
4173
  C: (f, a) => f(...a)
@@ -3938,11 +4193,11 @@ var DataSpace = class {
3938
4193
  if (!this._echoHost.roots.has(handle.documentId)) {
3939
4194
  await this._echoHost.openSpaceRoot(handle.url);
3940
4195
  } else {
3941
- log11.warn("echo database root already exists", {
4196
+ log12.warn("echo database root already exists", {
3942
4197
  space: this.key,
3943
4198
  rootUrl
3944
4199
  }, {
3945
- F: __dxlog_file13,
4200
+ F: __dxlog_file15,
3946
4201
  L: 399,
3947
4202
  S: this,
3948
4203
  C: (f, a) => f(...a)
@@ -3952,12 +4207,12 @@ var DataSpace = class {
3952
4207
  if (err instanceof ContextDisposedError3) {
3953
4208
  return;
3954
4209
  }
3955
- log11.warn("error loading automerge root doc", {
4210
+ log12.warn("error loading automerge root doc", {
3956
4211
  space: this.key,
3957
4212
  rootUrl,
3958
4213
  err
3959
4214
  }, {
3960
- F: __dxlog_file13,
4215
+ F: __dxlog_file15,
3961
4216
  L: 405,
3962
4217
  S: this,
3963
4218
  C: (f, a) => f(...a)
@@ -4009,10 +4264,10 @@ var DataSpace = class {
4009
4264
  {
4010
4265
  const currentRootUrl = this._automergeSpaceState.rootUrl;
4011
4266
  const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
4012
- await cancelWithContext4(this._ctx, asyncTimeout(rootHandle.whenReady(), 1e4));
4267
+ await cancelWithContext4(this._ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
4013
4268
  const newRoot = this._echoHost.automergeRepo.create(rootHandle.docSync());
4014
- invariant12(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
4015
- F: __dxlog_file13,
4269
+ invariant13(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
4270
+ F: __dxlog_file15,
4016
4271
  L: 455,
4017
4272
  S: this,
4018
4273
  A: [
@@ -4030,20 +4285,20 @@ var DataSpace = class {
4030
4285
  break;
4031
4286
  case CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
4032
4287
  {
4033
- log11.info("Fragmenting", void 0, {
4034
- F: __dxlog_file13,
4288
+ log12.info("Fragmenting", void 0, {
4289
+ F: __dxlog_file15,
4035
4290
  L: 467,
4036
4291
  S: this,
4037
4292
  C: (f, a) => f(...a)
4038
4293
  });
4039
4294
  const currentRootUrl = this._automergeSpaceState.rootUrl;
4040
4295
  const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
4041
- await cancelWithContext4(this._ctx, asyncTimeout(rootHandle.whenReady(), 1e4));
4296
+ await cancelWithContext4(this._ctx, asyncTimeout2(rootHandle.whenReady(), 1e4));
4042
4297
  const objects = Object.entries(rootHandle.docSync().objects);
4043
4298
  const properties = findPropertiesObject(rootHandle.docSync());
4044
4299
  const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
4045
- invariant12(properties, "Properties not found", {
4046
- F: __dxlog_file13,
4300
+ invariant13(properties, "Properties not found", {
4301
+ F: __dxlog_file15,
4047
4302
  L: 477,
4048
4303
  S: this,
4049
4304
  A: [
@@ -4058,8 +4313,8 @@ var DataSpace = class {
4058
4313
  ])
4059
4314
  };
4060
4315
  const newRoot = this._echoHost.automergeRepo.create(newSpaceDoc);
4061
- invariant12(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
4062
- F: __dxlog_file13,
4316
+ invariant13(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
4317
+ F: __dxlog_file15,
4063
4318
  L: 482,
4064
4319
  S: this,
4065
4320
  A: [
@@ -4125,10 +4380,10 @@ var DataSpace = class {
4125
4380
  await this._metadataStore.setSpaceState(this.key, SpaceState.INACTIVE);
4126
4381
  await this._close();
4127
4382
  this._state = SpaceState.INACTIVE;
4128
- log11("new state", {
4383
+ log12("new state", {
4129
4384
  state: SpaceState[this._state]
4130
4385
  }, {
4131
- F: __dxlog_file13,
4386
+ F: __dxlog_file15,
4132
4387
  L: 552,
4133
4388
  S: this,
4134
4389
  C: (f, a) => f(...a)
@@ -4202,12 +4457,12 @@ import { Event as Event7, synchronized as synchronized2, trackLeaks as trackLeak
4202
4457
  import { cancelWithContext as cancelWithContext5, Context as Context9 } from "@dxos/context";
4203
4458
  import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
4204
4459
  import { AuthStatus } from "@dxos/echo-pipeline";
4205
- import { invariant as invariant13 } from "@dxos/invariant";
4460
+ import { invariant as invariant14 } from "@dxos/invariant";
4206
4461
  import { PublicKey as PublicKey11 } from "@dxos/keys";
4207
- import { log as log12 } from "@dxos/log";
4462
+ import { log as log13 } from "@dxos/log";
4208
4463
  import { trace as Trace2 } from "@dxos/protocols";
4209
4464
  import { Invitation as Invitation7, SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
4210
- import { SpaceMember as SpaceMember5 } from "@dxos/protocols/proto/dxos/halo/credentials";
4465
+ import { SpaceMember as SpaceMember6 } from "@dxos/protocols/proto/dxos/halo/credentials";
4211
4466
  import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extension-gossip";
4212
4467
  import { trace as trace7 } from "@dxos/tracing";
4213
4468
  import { ComplexMap as ComplexMap3, deferFunction as deferFunction2, forEachAsync } from "@dxos/util";
@@ -4215,7 +4470,7 @@ import { ComplexMap as ComplexMap3, deferFunction as deferFunction2, forEachAsyn
4215
4470
  // packages/sdk/client-services/src/packlets/spaces/genesis.ts
4216
4471
  import { createCredential } from "@dxos/credentials";
4217
4472
  import { failUndefined } from "@dxos/debug";
4218
- import { AdmittedFeed as AdmittedFeed4, SpaceMember as SpaceMember4 } from "@dxos/protocols/proto/dxos/halo/credentials";
4473
+ import { AdmittedFeed as AdmittedFeed4, SpaceMember as SpaceMember5 } from "@dxos/protocols/proto/dxos/halo/credentials";
4219
4474
  import { Timeframe as Timeframe3 } from "@dxos/timeframe";
4220
4475
  var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
4221
4476
  const credentials = [
@@ -4235,7 +4490,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
4235
4490
  assertion: {
4236
4491
  "@type": "dxos.halo.credentials.SpaceMember",
4237
4492
  spaceKey: space.key,
4238
- role: SpaceMember4.Role.OWNER,
4493
+ role: SpaceMember5.Role.OWNER,
4239
4494
  profile: signingContext.getProfile(),
4240
4495
  genesisFeedKey: space.controlFeedKey ?? failUndefined()
4241
4496
  }
@@ -4293,7 +4548,7 @@ function _ts_decorate5(decorators, target, key, desc) {
4293
4548
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4294
4549
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4295
4550
  }
4296
- var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
4551
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
4297
4552
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
4298
4553
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
4299
4554
  var DataSpaceManager = class {
@@ -4341,45 +4596,45 @@ var DataSpaceManager = class {
4341
4596
  return this._spaces;
4342
4597
  }
4343
4598
  async open() {
4344
- log12("open", void 0, {
4345
- F: __dxlog_file14,
4599
+ log13("open", void 0, {
4600
+ F: __dxlog_file16,
4346
4601
  L: 144,
4347
4602
  S: this,
4348
4603
  C: (f, a) => f(...a)
4349
4604
  });
4350
- log12.trace("dxos.echo.data-space-manager.open", Trace2.begin({
4605
+ log13.trace("dxos.echo.data-space-manager.open", Trace2.begin({
4351
4606
  id: this._instanceId
4352
4607
  }), {
4353
- F: __dxlog_file14,
4608
+ F: __dxlog_file16,
4354
4609
  L: 145,
4355
4610
  S: this,
4356
4611
  C: (f, a) => f(...a)
4357
4612
  });
4358
- log12("metadata loaded", {
4613
+ log13("metadata loaded", {
4359
4614
  spaces: this._metadataStore.spaces.length
4360
4615
  }, {
4361
- F: __dxlog_file14,
4616
+ F: __dxlog_file16,
4362
4617
  L: 146,
4363
4618
  S: this,
4364
4619
  C: (f, a) => f(...a)
4365
4620
  });
4366
4621
  await forEachAsync(this._metadataStore.spaces, async (spaceMetadata) => {
4367
4622
  try {
4368
- log12("load space", {
4623
+ log13("load space", {
4369
4624
  spaceMetadata
4370
4625
  }, {
4371
- F: __dxlog_file14,
4626
+ F: __dxlog_file16,
4372
4627
  L: 150,
4373
4628
  S: this,
4374
4629
  C: (f, a) => f(...a)
4375
4630
  });
4376
4631
  await this._constructSpace(spaceMetadata);
4377
4632
  } catch (err) {
4378
- log12.error("Error loading space", {
4633
+ log13.error("Error loading space", {
4379
4634
  spaceMetadata,
4380
4635
  err
4381
4636
  }, {
4382
- F: __dxlog_file14,
4637
+ F: __dxlog_file16,
4383
4638
  L: 153,
4384
4639
  S: this,
4385
4640
  C: (f, a) => f(...a)
@@ -4393,18 +4648,18 @@ var DataSpaceManager = class {
4393
4648
  space.initializeDataPipelineAsync();
4394
4649
  }
4395
4650
  }
4396
- log12.trace("dxos.echo.data-space-manager.open", Trace2.end({
4651
+ log13.trace("dxos.echo.data-space-manager.open", Trace2.end({
4397
4652
  id: this._instanceId
4398
4653
  }), {
4399
- F: __dxlog_file14,
4654
+ F: __dxlog_file16,
4400
4655
  L: 166,
4401
4656
  S: this,
4402
4657
  C: (f, a) => f(...a)
4403
4658
  });
4404
4659
  }
4405
4660
  async close() {
4406
- log12("close", void 0, {
4407
- F: __dxlog_file14,
4661
+ log13("close", void 0, {
4662
+ F: __dxlog_file16,
4408
4663
  L: 171,
4409
4664
  S: this,
4410
4665
  C: (f, a) => f(...a)
@@ -4419,8 +4674,8 @@ var DataSpaceManager = class {
4419
4674
  * Creates a new space writing the genesis credentials to the control feed.
4420
4675
  */
4421
4676
  async createSpace() {
4422
- invariant13(this._isOpen, "Not open.", {
4423
- F: __dxlog_file14,
4677
+ invariant14(this._isOpen, "Not open.", {
4678
+ F: __dxlog_file16,
4424
4679
  L: 184,
4425
4680
  S: this,
4426
4681
  A: [
@@ -4438,10 +4693,10 @@ var DataSpaceManager = class {
4438
4693
  dataFeedKey,
4439
4694
  state: SpaceState2.ACTIVE
4440
4695
  };
4441
- log12("creating space...", {
4696
+ log13("creating space...", {
4442
4697
  spaceKey
4443
4698
  }, {
4444
- F: __dxlog_file14,
4699
+ F: __dxlog_file16,
4445
4700
  L: 196,
4446
4701
  S: this,
4447
4702
  C: (f, a) => f(...a)
@@ -4451,8 +4706,8 @@ var DataSpaceManager = class {
4451
4706
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, root.url);
4452
4707
  await this._metadataStore.addSpace(metadata);
4453
4708
  const memberCredential = credentials[1];
4454
- invariant13(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
4455
- F: __dxlog_file14,
4709
+ invariant14(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
4710
+ F: __dxlog_file16,
4456
4711
  L: 205,
4457
4712
  S: this,
4458
4713
  A: [
@@ -4467,16 +4722,16 @@ var DataSpaceManager = class {
4467
4722
  }
4468
4723
  // TODO(burdon): Rename join space.
4469
4724
  async acceptSpace(opts) {
4470
- log12("accept space", {
4725
+ log13("accept space", {
4471
4726
  opts
4472
4727
  }, {
4473
- F: __dxlog_file14,
4728
+ F: __dxlog_file16,
4474
4729
  L: 217,
4475
4730
  S: this,
4476
4731
  C: (f, a) => f(...a)
4477
4732
  });
4478
- invariant13(this._isOpen, "Not open.", {
4479
- F: __dxlog_file14,
4733
+ invariant14(this._isOpen, "Not open.", {
4734
+ F: __dxlog_file16,
4480
4735
  L: 218,
4481
4736
  S: this,
4482
4737
  A: [
@@ -4484,8 +4739,8 @@ var DataSpaceManager = class {
4484
4739
  "'Not open.'"
4485
4740
  ]
4486
4741
  });
4487
- invariant13(!this._spaces.has(opts.spaceKey), "Space already exists.", {
4488
- F: __dxlog_file14,
4742
+ invariant14(!this._spaces.has(opts.spaceKey), "Space already exists.", {
4743
+ F: __dxlog_file16,
4489
4744
  L: 219,
4490
4745
  S: this,
4491
4746
  A: [
@@ -4517,10 +4772,10 @@ var DataSpaceManager = class {
4517
4772
  }));
4518
4773
  }
4519
4774
  async _constructSpace(metadata) {
4520
- log12("construct space", {
4775
+ log13("construct space", {
4521
4776
  metadata
4522
4777
  }, {
4523
- F: __dxlog_file14,
4778
+ F: __dxlog_file16,
4524
4779
  L: 252,
4525
4780
  S: this,
4526
4781
  C: (f, a) => f(...a)
@@ -4557,8 +4812,8 @@ var DataSpaceManager = class {
4557
4812
  session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
4558
4813
  },
4559
4814
  onAuthFailure: () => {
4560
- log12.warn("auth failure", void 0, {
4561
- F: __dxlog_file14,
4815
+ log13.warn("auth failure", void 0, {
4816
+ F: __dxlog_file16,
4562
4817
  L: 289,
4563
4818
  S: this,
4564
4819
  C: (f, a) => f(...a)
@@ -4588,21 +4843,21 @@ var DataSpaceManager = class {
4588
4843
  signingContext: this._signingContext,
4589
4844
  callbacks: {
4590
4845
  beforeReady: async () => {
4591
- log12("before space ready", {
4846
+ log13("before space ready", {
4592
4847
  space: space.key
4593
4848
  }, {
4594
- F: __dxlog_file14,
4849
+ F: __dxlog_file16,
4595
4850
  L: 316,
4596
4851
  S: this,
4597
4852
  C: (f, a) => f(...a)
4598
4853
  });
4599
4854
  },
4600
4855
  afterReady: async () => {
4601
- log12("after space ready", {
4856
+ log13("after space ready", {
4602
4857
  space: space.key,
4603
4858
  open: this._isOpen
4604
4859
  }, {
4605
- F: __dxlog_file14,
4860
+ F: __dxlog_file16,
4606
4861
  L: 319,
4607
4862
  S: this,
4608
4863
  C: (f, a) => f(...a)
@@ -4618,10 +4873,10 @@ var DataSpaceManager = class {
4618
4873
  }
4619
4874
  },
4620
4875
  beforeClose: async () => {
4621
- log12("before space close", {
4876
+ log13("before space close", {
4622
4877
  space: space.key
4623
4878
  }, {
4624
- F: __dxlog_file14,
4879
+ F: __dxlog_file16,
4625
4880
  L: 327,
4626
4881
  S: this,
4627
4882
  C: (f, a) => f(...a)
@@ -4653,19 +4908,19 @@ var DataSpaceManager = class {
4653
4908
  const peers = presence.getPeersByIdentityKey(member.key);
4654
4909
  const sessions = peers.map((p) => p.peerId && spaceProtocol.sessions.get(p.peerId));
4655
4910
  const sessionsToClose = sessions.filter((s) => {
4656
- return (s && member.role === SpaceMember5.Role.REMOVED !== (s.authStatus === AuthStatus.FAILURE)) ?? false;
4911
+ return (s && member.role === SpaceMember6.Role.REMOVED !== (s.authStatus === AuthStatus.FAILURE)) ?? false;
4657
4912
  });
4658
4913
  sessionsToClose.forEach((session) => {
4659
- void session.close().catch(log12.error);
4914
+ void session.close().catch(log13.error);
4660
4915
  });
4661
4916
  closedSessions += sessionsToClose.length;
4662
4917
  }
4663
- log12("processed member role changes", {
4918
+ log13("processed member role changes", {
4664
4919
  roleChangeCount: memberInfo.length,
4665
4920
  peersOnline: presence.getPeersOnline().length,
4666
4921
  closedSessions
4667
4922
  }, {
4668
- F: __dxlog_file14,
4923
+ F: __dxlog_file16,
4669
4924
  L: 367,
4670
4925
  S: this,
4671
4926
  C: (f, a) => f(...a)
@@ -4674,18 +4929,18 @@ var DataSpaceManager = class {
4674
4929
  }
4675
4930
  _handleNewPeerConnected(space, peerState) {
4676
4931
  const role = space.spaceState.getMemberRole(peerState.identityKey);
4677
- if (role === SpaceMember5.Role.REMOVED) {
4932
+ if (role === SpaceMember6.Role.REMOVED) {
4678
4933
  const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
4679
4934
  if (session != null) {
4680
- log12("closing a session with a removed peer", {
4935
+ log13("closing a session with a removed peer", {
4681
4936
  peerId: peerState.peerId
4682
4937
  }, {
4683
- F: __dxlog_file14,
4938
+ F: __dxlog_file16,
4684
4939
  L: 381,
4685
4940
  S: this,
4686
4941
  C: (f, a) => f(...a)
4687
4942
  });
4688
- void session.close().catch(log12.error);
4943
+ void session.close().catch(log13.error);
4689
4944
  }
4690
4945
  }
4691
4946
  }
@@ -4747,12 +5002,12 @@ import { Stream as Stream10 } from "@dxos/codec-protobuf";
4747
5002
  import { createAdmissionCredentials as createAdmissionCredentials2, getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
4748
5003
  import { raise as raise2 } from "@dxos/debug";
4749
5004
  import { writeMessages as writeMessages3 } from "@dxos/feed-store";
4750
- import { invariant as invariant14 } from "@dxos/invariant";
4751
- import { log as log13 } from "@dxos/log";
5005
+ import { invariant as invariant15 } from "@dxos/invariant";
5006
+ import { log as log14 } from "@dxos/log";
4752
5007
  import { ApiError, SpaceNotFoundError as SpaceNotFoundError2, encodeError, IdentityNotInitializedError, AuthorizationError as AuthorizationError2 } from "@dxos/protocols";
4753
- import { SpaceMember as SpaceMember6, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
5008
+ import { SpaceMember as SpaceMember7, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
4754
5009
  import { trace as trace8 } from "@dxos/tracing";
4755
- var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
5010
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
4756
5011
  var SpacesServiceImpl = class {
4757
5012
  constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
4758
5013
  this._identityManager = _identityManager;
@@ -4795,8 +5050,8 @@ var SpacesServiceImpl = class {
4795
5050
  });
4796
5051
  }
4797
5052
  const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
4798
- invariant14(credentials[0].credential, void 0, {
4799
- F: __dxlog_file15,
5053
+ invariant15(credentials[0].credential, void 0, {
5054
+ F: __dxlog_file17,
4800
5055
  L: 97,
4801
5056
  S: this,
4802
5057
  A: [
@@ -4805,8 +5060,8 @@ var SpacesServiceImpl = class {
4805
5060
  ]
4806
5061
  });
4807
5062
  const spaceMemberCredential = credentials[0].credential.credential;
4808
- invariant14(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
4809
- F: __dxlog_file15,
5063
+ invariant15(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
5064
+ F: __dxlog_file17,
4810
5065
  L: 99,
4811
5066
  S: this,
4812
5067
  A: [
@@ -4821,10 +5076,10 @@ var SpacesServiceImpl = class {
4821
5076
  const scheduler = new UpdateScheduler(ctx, async () => {
4822
5077
  const dataSpaceManager = await this._getDataSpaceManager();
4823
5078
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
4824
- log13("update", {
5079
+ log14("update", {
4825
5080
  spaces
4826
5081
  }, {
4827
- F: __dxlog_file15,
5082
+ F: __dxlog_file17,
4828
5083
  L: 110,
4829
5084
  S: this,
4830
5085
  C: (f, a) => f(...a)
@@ -4907,8 +5162,8 @@ var SpacesServiceImpl = class {
4907
5162
  }
4908
5163
  });
4909
5164
  } else {
4910
- invariant14(!credential.id, "Id on unsigned credentials is not allowed", {
4911
- F: __dxlog_file15,
5165
+ invariant15(!credential.id, "Id on unsigned credentials is not allowed", {
5166
+ F: __dxlog_file17,
4912
5167
  L: 198,
4913
5168
  S: this,
4914
5169
  A: [
@@ -4916,8 +5171,8 @@ var SpacesServiceImpl = class {
4916
5171
  "'Id on unsigned credentials is not allowed'"
4917
5172
  ]
4918
5173
  });
4919
- invariant14(this._identityManager.identity, "Identity is not available", {
4920
- F: __dxlog_file15,
5174
+ invariant15(this._identityManager.identity, "Identity is not available", {
5175
+ F: __dxlog_file17,
4921
5176
  L: 199,
4922
5177
  S: this,
4923
5178
  A: [
@@ -4926,8 +5181,8 @@ var SpacesServiceImpl = class {
4926
5181
  ]
4927
5182
  });
4928
5183
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
4929
- invariant14(credential.issuer.equals(signer.getIssuer()), void 0, {
4930
- F: __dxlog_file15,
5184
+ invariant15(credential.issuer.equals(signer.getIssuer()), void 0, {
5185
+ F: __dxlog_file17,
4931
5186
  L: 201,
4932
5187
  S: this,
4933
5188
  A: [
@@ -4985,7 +5240,7 @@ var SpacesServiceImpl = class {
4985
5240
  profile: member.profile ?? {}
4986
5241
  },
4987
5242
  role: member.role,
4988
- presence: peers.length > 0 ? SpaceMember6.PresenceState.ONLINE : SpaceMember6.PresenceState.OFFLINE,
5243
+ presence: peers.length > 0 ? SpaceMember7.PresenceState.ONLINE : SpaceMember7.PresenceState.OFFLINE,
4989
5244
  peerStates: peers
4990
5245
  };
4991
5246
  }),
@@ -5015,18 +5270,18 @@ var SpacesServiceImpl = class {
5015
5270
  var getChannelId = (channel) => `user-channel/${channel}`;
5016
5271
 
5017
5272
  // packages/sdk/client-services/src/packlets/services/service-context.ts
5018
- import { Trigger as Trigger6 } from "@dxos/async";
5273
+ import { Trigger as Trigger7 } from "@dxos/async";
5019
5274
  import { Context as Context10, Resource } from "@dxos/context";
5020
5275
  import { getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credentials";
5021
5276
  import { failUndefined as failUndefined2 } from "@dxos/debug";
5022
5277
  import { EchoHost } from "@dxos/echo-db";
5023
5278
  import { MetadataStore, SnapshotStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
5024
5279
  import { FeedFactory, FeedStore } from "@dxos/feed-store";
5025
- import { invariant as invariant15 } from "@dxos/invariant";
5280
+ import { invariant as invariant16 } from "@dxos/invariant";
5026
5281
  import { Keyring } from "@dxos/keyring";
5027
5282
  import { PublicKey as PublicKey12 } from "@dxos/keys";
5028
- import { log as log14 } from "@dxos/log";
5029
- import { InvalidStorageVersionError, STORAGE_VERSION, trace as trace9 } from "@dxos/protocols";
5283
+ import { log as log15 } from "@dxos/log";
5284
+ import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace9 } from "@dxos/protocols";
5030
5285
  import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
5031
5286
  import { BlobStore } from "@dxos/teleport-extension-object-sync";
5032
5287
  import { trace as Trace3 } from "@dxos/tracing";
@@ -5041,7 +5296,7 @@ function _ts_decorate6(decorators, target, key, desc) {
5041
5296
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5042
5297
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5043
5298
  }
5044
- var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
5299
+ var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
5045
5300
  var ServiceContext = class extends Resource {
5046
5301
  constructor(storage, level, networkManager, signalManager, _runtimeParams) {
5047
5302
  super();
@@ -5050,7 +5305,7 @@ var ServiceContext = class extends Resource {
5050
5305
  this.networkManager = networkManager;
5051
5306
  this.signalManager = signalManager;
5052
5307
  this._runtimeParams = _runtimeParams;
5053
- this.initialized = new Trigger6();
5308
+ this.initialized = new Trigger7();
5054
5309
  this._handlerFactories = /* @__PURE__ */ new Map();
5055
5310
  this._instanceId = PublicKey12.random().toHex();
5056
5311
  this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
@@ -5085,16 +5340,16 @@ var ServiceContext = class extends Resource {
5085
5340
  }
5086
5341
  async _open(ctx) {
5087
5342
  await this._checkStorageVersion();
5088
- log14("opening...", void 0, {
5089
- F: __dxlog_file16,
5343
+ log15("opening...", void 0, {
5344
+ F: __dxlog_file18,
5090
5345
  L: 152,
5091
5346
  S: this,
5092
5347
  C: (f, a) => f(...a)
5093
5348
  });
5094
- log14.trace("dxos.sdk.service-context.open", trace9.begin({
5349
+ log15.trace("dxos.sdk.service-context.open", trace9.begin({
5095
5350
  id: this._instanceId
5096
5351
  }), {
5097
- F: __dxlog_file16,
5352
+ F: __dxlog_file18,
5098
5353
  L: 153,
5099
5354
  S: this,
5100
5355
  C: (f, a) => f(...a)
@@ -5109,32 +5364,32 @@ var ServiceContext = class extends Resource {
5109
5364
  await this._initialize(ctx);
5110
5365
  }
5111
5366
  const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
5112
- log14("loaded persistent invitations", {
5367
+ log15("loaded persistent invitations", {
5113
5368
  count: loadedInvitations.invitations?.length
5114
5369
  }, {
5115
- F: __dxlog_file16,
5370
+ F: __dxlog_file18,
5116
5371
  L: 166,
5117
5372
  S: this,
5118
5373
  C: (f, a) => f(...a)
5119
5374
  });
5120
- log14.trace("dxos.sdk.service-context.open", trace9.end({
5375
+ log15.trace("dxos.sdk.service-context.open", trace9.end({
5121
5376
  id: this._instanceId
5122
5377
  }), {
5123
- F: __dxlog_file16,
5378
+ F: __dxlog_file18,
5124
5379
  L: 168,
5125
5380
  S: this,
5126
5381
  C: (f, a) => f(...a)
5127
5382
  });
5128
- log14("opened", void 0, {
5129
- F: __dxlog_file16,
5383
+ log15("opened", void 0, {
5384
+ F: __dxlog_file18,
5130
5385
  L: 169,
5131
5386
  S: this,
5132
5387
  C: (f, a) => f(...a)
5133
5388
  });
5134
5389
  }
5135
5390
  async _close(ctx) {
5136
- log14("closing...", void 0, {
5137
- F: __dxlog_file16,
5391
+ log15("closing...", void 0, {
5392
+ F: __dxlog_file18,
5138
5393
  L: 173,
5139
5394
  S: this,
5140
5395
  C: (f, a) => f(...a)
@@ -5150,8 +5405,8 @@ var ServiceContext = class extends Resource {
5150
5405
  await this.echoHost.close(ctx);
5151
5406
  await this.networkManager.close();
5152
5407
  await this.signalManager.close();
5153
- log14("closed", void 0, {
5154
- F: __dxlog_file16,
5408
+ log15("closed", void 0, {
5409
+ F: __dxlog_file18,
5155
5410
  L: 185,
5156
5411
  S: this,
5157
5412
  C: (f, a) => f(...a)
@@ -5164,8 +5419,8 @@ var ServiceContext = class extends Resource {
5164
5419
  }
5165
5420
  getInvitationHandler(invitation) {
5166
5421
  const factory = this._handlerFactories.get(invitation.kind);
5167
- invariant15(factory, `Unknown invitation kind: ${invitation.kind}`, {
5168
- F: __dxlog_file16,
5422
+ invariant16(factory, `Unknown invitation kind: ${invitation.kind}`, {
5423
+ F: __dxlog_file18,
5169
5424
  L: 196,
5170
5425
  S: this,
5171
5426
  A: [
@@ -5190,14 +5445,14 @@ var ServiceContext = class extends Resource {
5190
5445
  }
5191
5446
  async _checkStorageVersion() {
5192
5447
  await this.metadataStore.load();
5193
- if (this.metadataStore.version !== STORAGE_VERSION) {
5194
- throw new InvalidStorageVersionError(STORAGE_VERSION, this.metadataStore.version);
5448
+ if (this.metadataStore.version !== STORAGE_VERSION2) {
5449
+ throw new InvalidStorageVersionError(STORAGE_VERSION2, this.metadataStore.version);
5195
5450
  }
5196
5451
  }
5197
5452
  // Called when identity is created.
5198
5453
  async _initialize(ctx) {
5199
- log14("initializing spaces...", void 0, {
5200
- F: __dxlog_file16,
5454
+ log15("initializing spaces...", void 0, {
5455
+ F: __dxlog_file18,
5201
5456
  L: 227,
5202
5457
  S: this,
5203
5458
  C: (f, a) => f(...a)
@@ -5219,8 +5474,8 @@ var ServiceContext = class extends Resource {
5219
5474
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.echoHost, this.invitationsManager, this._runtimeParams);
5220
5475
  await this.dataSpaceManager.open();
5221
5476
  this._handlerFactories.set(Invitation8.Kind.SPACE, (invitation) => {
5222
- invariant15(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
5223
- F: __dxlog_file16,
5477
+ invariant16(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
5478
+ F: __dxlog_file18,
5224
5479
  L: 252,
5225
5480
  S: this,
5226
5481
  A: [
@@ -5241,10 +5496,10 @@ var ServiceContext = class extends Resource {
5241
5496
  return;
5242
5497
  }
5243
5498
  if (!this.dataSpaceManager) {
5244
- log14("dataSpaceManager not initialized yet, ignoring space admission", {
5499
+ log15("dataSpaceManager not initialized yet, ignoring space admission", {
5245
5500
  details: assertion
5246
5501
  }, {
5247
- F: __dxlog_file16,
5502
+ F: __dxlog_file18,
5248
5503
  L: 268,
5249
5504
  S: this,
5250
5505
  C: (f, a) => f(...a)
@@ -5252,10 +5507,10 @@ var ServiceContext = class extends Resource {
5252
5507
  return;
5253
5508
  }
5254
5509
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
5255
- log14("space already exists, ignoring space admission", {
5510
+ log15("space already exists, ignoring space admission", {
5256
5511
  details: assertion
5257
5512
  }, {
5258
- F: __dxlog_file16,
5513
+ F: __dxlog_file18,
5259
5514
  L: 272,
5260
5515
  S: this,
5261
5516
  C: (f, a) => f(...a)
@@ -5263,10 +5518,10 @@ var ServiceContext = class extends Resource {
5263
5518
  return;
5264
5519
  }
5265
5520
  try {
5266
- log14("accepting space recorded in halo", {
5521
+ log15("accepting space recorded in halo", {
5267
5522
  details: assertion
5268
5523
  }, {
5269
- F: __dxlog_file16,
5524
+ F: __dxlog_file18,
5270
5525
  L: 277,
5271
5526
  S: this,
5272
5527
  C: (f, a) => f(...a)
@@ -5276,8 +5531,8 @@ var ServiceContext = class extends Resource {
5276
5531
  genesisFeedKey: assertion.genesisFeedKey
5277
5532
  });
5278
5533
  } catch (err) {
5279
- log14.catch(err, void 0, {
5280
- F: __dxlog_file16,
5534
+ log15.catch(err, void 0, {
5535
+ F: __dxlog_file18,
5281
5536
  L: 283,
5282
5537
  S: this,
5283
5538
  C: (f, a) => f(...a)
@@ -5323,266 +5578,203 @@ var ServiceRegistry = class {
5323
5578
  }
5324
5579
  };
5325
5580
 
5326
- // packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts
5327
- import { asyncTimeout as asyncTimeout2 } from "@dxos/async";
5328
- import { getFirstStreamValue } from "@dxos/codec-protobuf";
5329
- import { credentialTypeFilter } from "@dxos/credentials";
5330
- import { invariant as invariant16 } from "@dxos/invariant";
5331
- import { STORAGE_VERSION as STORAGE_VERSION2 } from "@dxos/protocols";
5332
- import { SpaceMember as SpaceMember7 } from "@dxos/protocols/proto/dxos/client/services";
5333
- import { TRACE_PROCESSOR } from "@dxos/tracing";
5334
-
5335
- // packages/sdk/client-services/src/version.ts
5336
- var DXOS_VERSION = "0.5.9-main.8359215";
5337
-
5338
- // packages/sdk/client-services/src/packlets/services/platform.ts
5339
- import { Platform } from "@dxos/protocols/proto/dxos/client/services";
5340
- var getPlatform = () => {
5341
- if (process.browser) {
5342
- if (typeof window !== "undefined") {
5343
- const { userAgent } = window.navigator;
5344
- return {
5345
- type: Platform.PLATFORM_TYPE.BROWSER,
5346
- userAgent,
5347
- uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
5348
- };
5349
- } else {
5350
- return {
5351
- type: Platform.PLATFORM_TYPE.SHARED_WORKER,
5352
- uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
5353
- };
5354
- }
5355
- } else {
5356
- const { platform: platform2, version, arch } = process;
5357
- return {
5358
- type: Platform.PLATFORM_TYPE.NODE,
5359
- platform: platform2,
5360
- arch,
5361
- runtime: version,
5362
- uptime: Math.floor(process.uptime()),
5363
- memory: process.memoryUsage()
5364
- };
5581
+ // packages/sdk/client-services/src/packlets/locks/browser.ts
5582
+ import { asyncTimeout as asyncTimeout3, Trigger as Trigger8 } from "@dxos/async";
5583
+ import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
5584
+ import { log as log16, logInfo } from "@dxos/log";
5585
+ function _ts_decorate7(decorators, target, key, desc) {
5586
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5587
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
5588
+ r = Reflect.decorate(decorators, target, key, desc);
5589
+ else
5590
+ for (var i = decorators.length - 1; i >= 0; i--)
5591
+ if (d = decorators[i])
5592
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5593
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
5594
+ }
5595
+ var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
5596
+ var Message;
5597
+ (function(Message2) {
5598
+ Message2["ACQUIRING"] = "acquiring";
5599
+ })(Message || (Message = {}));
5600
+ var Lock = class {
5601
+ constructor({ lockKey, onAcquire, onRelease }) {
5602
+ this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
5603
+ this._releaseTrigger = new Trigger8();
5604
+ this._lockKey = lockKey;
5605
+ this._onAcquire = onAcquire;
5606
+ this._onRelease = onRelease;
5607
+ this._broadcastChannel.onmessage = this._onMessage.bind(this);
5365
5608
  }
5366
- };
5367
-
5368
- // packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts
5369
- var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
5370
- var DEFAULT_TIMEOUT = 1e3;
5371
- var createDiagnostics = async (clientServices, serviceContext, config) => {
5372
- const diagnostics = {
5373
- created: (/* @__PURE__ */ new Date()).toISOString(),
5374
- platform: getPlatform(),
5375
- client: {
5376
- version: DXOS_VERSION,
5377
- storage: {
5378
- version: STORAGE_VERSION2
5379
- }
5380
- },
5381
- trace: TRACE_PROCESSOR.getDiagnostics()
5382
- };
5383
- await Promise.all([
5384
- (async () => {
5385
- invariant16(clientServices.LoggingService, "SystemService is not available.", {
5386
- F: __dxlog_file17,
5387
- L: 110,
5388
- S: void 0,
5389
- A: [
5390
- "clientServices.LoggingService",
5391
- "'SystemService is not available.'"
5392
- ]
5609
+ get lockKey() {
5610
+ return this._lockKey;
5611
+ }
5612
+ async acquire() {
5613
+ this._broadcastChannel.postMessage({
5614
+ message: "acquiring"
5615
+ });
5616
+ try {
5617
+ log16("aquiring lock...", void 0, {
5618
+ F: __dxlog_file19,
5619
+ L: 42,
5620
+ S: this,
5621
+ C: (f, a) => f(...a)
5622
+ });
5623
+ await asyncTimeout3(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
5624
+ log16("acquired lock", void 0, {
5625
+ F: __dxlog_file19,
5626
+ L: 44,
5627
+ S: this,
5628
+ C: (f, a) => f(...a)
5629
+ });
5630
+ } catch {
5631
+ log16("stealing lock...", void 0, {
5632
+ F: __dxlog_file19,
5633
+ L: 46,
5634
+ S: this,
5635
+ C: (f, a) => f(...a)
5636
+ });
5637
+ await this._requestLock(true);
5638
+ log16("stolen lock", void 0, {
5639
+ F: __dxlog_file19,
5640
+ L: 48,
5641
+ S: this,
5642
+ C: (f, a) => f(...a)
5393
5643
  });
5394
- diagnostics.metrics = await getFirstStreamValue(clientServices.LoggingService.queryMetrics({}), {
5395
- timeout: DEFAULT_TIMEOUT
5396
- }).catch(() => void 0);
5397
- })(),
5398
- (async () => {
5399
- diagnostics.storage = await asyncTimeout2(getStorageDiagnostics(), DEFAULT_TIMEOUT).catch(() => void 0);
5400
- })(),
5401
- async () => {
5402
- const identity = serviceContext.identityManager.identity;
5403
- if (identity) {
5404
- diagnostics.identity = {
5405
- identityKey: identity.identityKey,
5406
- spaceKey: identity.space.key,
5407
- profile: identity.profileDocument
5408
- };
5409
- const { devices } = await getFirstStreamValue(clientServices.DevicesService.queryDevices(), {
5410
- timeout: DEFAULT_TIMEOUT
5411
- }).catch(() => void 0) ?? {};
5412
- diagnostics.devices = devices;
5413
- if (serviceContext.dataSpaceManager) {
5414
- diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
5415
- }
5416
- const { feeds = [] } = await getFirstStreamValue(clientServices.DevtoolsHost.subscribeToFeeds({}), {
5417
- timeout: DEFAULT_TIMEOUT
5418
- }).catch(() => void 0) ?? {};
5419
- diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
5420
- feedKey,
5421
- bytes,
5422
- length
5423
- }));
5424
- const status = await getFirstStreamValue(clientServices.NetworkService.queryStatus(), {
5425
- timeout: DEFAULT_TIMEOUT
5426
- }).catch(() => void 0);
5427
- diagnostics.networkStatus = status;
5428
- diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
5429
- }
5430
5644
  }
5431
- ]);
5432
- diagnostics.config = config.values;
5433
- return diagnostics;
5434
- };
5435
- var getSpaceStats = async (space) => {
5436
- const stats = {
5437
- key: space.key,
5438
- metrics: space.metrics,
5439
- epochs: space.inner.spaceState.credentials.filter(credentialTypeFilter("dxos.halo.credentials.Epoch")).map((credential) => ({
5440
- ...credential.subject.assertion,
5441
- id: credential.id
5442
- })),
5443
- members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
5444
- role: member.role,
5445
- identity: {
5446
- identityKey: member.key,
5447
- profile: {
5448
- displayName: member.assertion.profile?.displayName
5449
- }
5450
- },
5451
- presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? SpaceMember7.PresenceState.ONLINE : SpaceMember7.PresenceState.OFFLINE
5452
- })),
5453
- pipeline: {
5454
- // TODO(burdon): Pick properties from credentials if needed.
5455
- currentEpoch: space.automergeSpaceState.lastEpoch,
5456
- appliedEpoch: space.automergeSpaceState.lastEpoch,
5457
- controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
5458
- currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
5459
- targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
5460
- totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
5645
+ }
5646
+ async release() {
5647
+ this._releaseTrigger.wake();
5648
+ }
5649
+ _onMessage(event) {
5650
+ if (event.data.message === "acquiring") {
5651
+ this._releaseTrigger.wake();
5461
5652
  }
5462
- };
5463
- if (stats.metrics) {
5464
- const { open, ready } = stats.metrics;
5465
- stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
5466
5653
  }
5467
- return stats;
5654
+ async _requestLock(steal = false) {
5655
+ log16("requesting lock...", {
5656
+ steal
5657
+ }, {
5658
+ F: __dxlog_file19,
5659
+ L: 63,
5660
+ S: this,
5661
+ C: (f, a) => f(...a)
5662
+ });
5663
+ const acquired = new Trigger8();
5664
+ void navigator.locks.request(this._lockKey, {
5665
+ steal
5666
+ }, async () => {
5667
+ await this._onAcquire?.();
5668
+ acquired.wake();
5669
+ this._releaseTrigger = new Trigger8();
5670
+ await this._releaseTrigger.wait();
5671
+ log16("releasing lock...", void 0, {
5672
+ F: __dxlog_file19,
5673
+ L: 72,
5674
+ S: this,
5675
+ C: (f, a) => f(...a)
5676
+ });
5677
+ await this._onRelease?.();
5678
+ log16("released lock", void 0, {
5679
+ F: __dxlog_file19,
5680
+ L: 74,
5681
+ S: this,
5682
+ C: (f, a) => f(...a)
5683
+ });
5684
+ }).catch(async () => {
5685
+ await this._onRelease?.();
5686
+ });
5687
+ await acquired.wait();
5688
+ log16("recieved lock", {
5689
+ steal
5690
+ }, {
5691
+ F: __dxlog_file19,
5692
+ L: 81,
5693
+ S: this,
5694
+ C: (f, a) => f(...a)
5695
+ });
5696
+ }
5468
5697
  };
5469
- var getStorageDiagnostics = async () => {
5470
- if (typeof navigator === "undefined" || !navigator.storage) {
5471
- return void 0;
5472
- }
5473
- const map = /* @__PURE__ */ new Map();
5474
- const dir = await navigator.storage.getDirectory();
5475
- for await (const filename of dir?.keys()) {
5476
- const idx = filename.indexOf("-", filename.indexOf("-") + 1);
5477
- if (idx === -1) {
5478
- continue;
5479
- }
5480
- map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
5481
- }
5482
- return Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
5483
- file,
5484
- count
5485
- }));
5698
+ _ts_decorate7([
5699
+ logInfo
5700
+ ], Lock.prototype, "lockKey", null);
5701
+ var isLocked = (lockPath) => {
5702
+ throw new Error("Not implemented");
5486
5703
  };
5487
5704
 
5488
- // packages/sdk/client-services/src/packlets/diagnostics/browser-diagnostics-broadcast.ts
5489
- import { Trigger as Trigger7 } from "@dxos/async";
5490
- import { log as log15 } from "@dxos/log";
5491
- var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/browser-diagnostics-broadcast.ts";
5492
- var CHANNEL_NAME = "dxos.diagnostics.broadcast";
5493
- var MessageType;
5494
- (function(MessageType2) {
5495
- MessageType2["PROBE"] = "probe";
5496
- MessageType2["PROBE_ACK"] = "probe-ack";
5497
- MessageType2["REQUEST_DIAGNOSTICS"] = "request-diagnostics";
5498
- MessageType2["RECEIVE_DIAGNOSTICS"] = "receive-diagnostics";
5499
- })(MessageType || (MessageType = {}));
5500
- var createCollectDiagnosticsBroadcastSender = () => {
5501
- return {
5502
- broadcastDiagnosticsRequest: async () => {
5503
- let expectedResponse = "probe-ack";
5504
- let channel;
5505
- try {
5506
- const trigger = new Trigger7();
5507
- channel = new BroadcastChannel(CHANNEL_NAME);
5508
- channel.onmessage = (msg) => {
5509
- if (expectedResponse === msg.data.type) {
5510
- trigger.wake(msg.data);
5511
- }
5512
- };
5513
- channel.postMessage({
5514
- type: "probe"
5515
- });
5516
- await trigger.wait({
5517
- timeout: 200
5518
- });
5519
- expectedResponse = "receive-diagnostics";
5520
- trigger.reset();
5521
- channel.postMessage({
5522
- type: "request-diagnostics"
5523
- });
5524
- const diagnostics = await trigger.wait({
5525
- timeout: 5e3
5526
- });
5527
- return diagnostics.payload;
5528
- } catch (e) {
5529
- const errorDescription = e instanceof Error ? e.message : JSON.stringify(e);
5530
- return {
5531
- expectedResponse,
5532
- errorDescription
5533
- };
5534
- } finally {
5535
- safeClose(channel);
5536
- }
5537
- }
5538
- };
5705
+ // packages/sdk/client-services/src/packlets/storage/storage.ts
5706
+ import { InvalidConfigError } from "@dxos/protocols";
5707
+ import { Runtime as Runtime2 } from "@dxos/protocols/proto/dxos/config";
5708
+ import { createStorage, StorageType } from "@dxos/random-access-storage";
5709
+
5710
+ // packages/sdk/client-services/src/packlets/storage/util.ts
5711
+ import { DX_DATA } from "@dxos/client-protocol";
5712
+ import { Runtime } from "@dxos/protocols/proto/dxos/config";
5713
+ import { isNode as isNode2 } from "@dxos/util";
5714
+ var getRootPath = (config) => {
5715
+ const { dataRoot = isNode2() ? DX_DATA : "dxos/storage" } = config ?? {};
5716
+ return `${dataRoot}/`;
5539
5717
  };
5540
- var createCollectDiagnosticsBroadcastHandler = (systemService) => {
5541
- let channel;
5718
+ var isPersistent = (config) => {
5719
+ const { persistent = false } = config ?? {};
5720
+ return config.dataStore !== void 0 && config.dataStore !== Runtime.Client.Storage.StorageDriver.RAM || persistent;
5721
+ };
5722
+
5723
+ // packages/sdk/client-services/src/packlets/storage/storage.ts
5724
+ var StorageDriver = Runtime2.Client.Storage.StorageDriver;
5725
+ var createStorageObjects = (config) => {
5726
+ const { persistent = false, keyStore, dataStore } = config ?? {};
5727
+ if (persistent && dataStore === StorageDriver.RAM) {
5728
+ throw new InvalidConfigError("RAM storage cannot be used in persistent mode.");
5729
+ }
5730
+ if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
5731
+ throw new InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
5732
+ }
5733
+ if (persistent && keyStore === StorageDriver.RAM) {
5734
+ throw new InvalidConfigError("RAM key storage cannot be used in persistent mode.");
5735
+ }
5736
+ if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
5737
+ throw new InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
5738
+ }
5542
5739
  return {
5543
- start: () => {
5544
- channel = new BroadcastChannel(CHANNEL_NAME);
5545
- channel.onmessage = async (message) => {
5546
- try {
5547
- if (message.data.type === "probe") {
5548
- channel?.postMessage({
5549
- type: "probe-ack"
5550
- });
5551
- } else if (message.data.type === "request-diagnostics") {
5552
- const diagnostics = await systemService.getDiagnostics({});
5553
- channel?.postMessage({
5554
- type: "receive-diagnostics",
5555
- payload: diagnostics
5556
- });
5557
- }
5558
- } catch (error) {
5559
- log15.catch(error, void 0, {
5560
- F: __dxlog_file18,
5561
- L: 77,
5562
- S: void 0,
5563
- C: (f, a) => f(...a)
5564
- });
5565
- }
5566
- };
5567
- },
5568
- stop: () => {
5569
- safeClose(channel);
5570
- channel = void 0;
5571
- }
5740
+ storage: createStorage({
5741
+ type: persistent ? toStorageType(dataStore) : StorageType.RAM,
5742
+ root: getRootPath(config)
5743
+ })
5572
5744
  };
5573
5745
  };
5574
- var safeClose = (channel) => {
5575
- try {
5576
- channel?.close();
5577
- } catch (e) {
5746
+ var toStorageType = (type) => {
5747
+ switch (type) {
5748
+ case void 0:
5749
+ return void 0;
5750
+ case StorageDriver.RAM:
5751
+ return StorageType.RAM;
5752
+ case StorageDriver.CHROME:
5753
+ return StorageType.CHROME;
5754
+ case StorageDriver.FIREFOX:
5755
+ return StorageType.FIREFOX;
5756
+ case StorageDriver.IDB:
5757
+ return StorageType.IDB;
5758
+ case StorageDriver.NODE:
5759
+ return StorageType.NODE;
5760
+ case StorageDriver.WEBFS:
5761
+ return StorageType.WEBFS;
5762
+ default:
5763
+ throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
5578
5764
  }
5579
5765
  };
5580
5766
 
5581
- // packages/sdk/client-services/src/packlets/diagnostics/diagnostics-collector.ts
5582
- import { ConfigResource } from "@dxos/config";
5583
- import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
5584
- import { TRACE_PROCESSOR as TRACE_PROCESSOR3 } from "@dxos/tracing";
5585
- import { jsonKeyReplacer as jsonKeyReplacer2, nonNullable } from "@dxos/util";
5767
+ // packages/sdk/client-services/src/packlets/storage/level.ts
5768
+ import path from "@dxos/node-std/path";
5769
+ import { PublicKey as PublicKey13 } from "@dxos/keys";
5770
+ import { createLevel as createKV } from "@dxos/kv-store";
5771
+ var createLevel = async (config) => {
5772
+ const persistent = isPersistent(config);
5773
+ const storagePath = persistent ? path.join(getRootPath(config), "level") : `/tmp/dxos-${PublicKey13.random().toHex()}`;
5774
+ const level = createKV(storagePath);
5775
+ await level.open();
5776
+ return level;
5777
+ };
5586
5778
 
5587
5779
  // packages/sdk/client-services/src/packlets/services/service-host.ts
5588
5780
  import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
@@ -5591,13 +5783,13 @@ import { Context as Context11 } from "@dxos/context";
5591
5783
  import { encodeReference } from "@dxos/echo-protocol";
5592
5784
  import { getTypeReference } from "@dxos/echo-schema";
5593
5785
  import { invariant as invariant18 } from "@dxos/invariant";
5594
- import { PublicKey as PublicKey15 } from "@dxos/keys";
5786
+ import { PublicKey as PublicKey16 } from "@dxos/keys";
5595
5787
  import { log as log18 } from "@dxos/log";
5596
5788
  import { WebsocketSignalManager } from "@dxos/messaging";
5597
5789
  import { SwarmNetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
5598
5790
  import { trace as trace10 } from "@dxos/protocols";
5599
5791
  import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
5600
- import { TRACE_PROCESSOR as TRACE_PROCESSOR2, trace as Trace4 } from "@dxos/tracing";
5792
+ import { TRACE_PROCESSOR as TRACE_PROCESSOR3, trace as Trace4 } from "@dxos/tracing";
5601
5793
  import { assignDeep as assignDeep2 } from "@dxos/util";
5602
5794
  import { WebsocketRpcClient } from "@dxos/websocket-rpc";
5603
5795
 
@@ -5606,7 +5798,7 @@ import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
5606
5798
  import { Stream as Stream11 } from "@dxos/codec-protobuf";
5607
5799
  import { invariant as invariant17 } from "@dxos/invariant";
5608
5800
  import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
5609
- var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
5801
+ var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
5610
5802
  var DevicesServiceImpl = class {
5611
5803
  constructor(_identityManager) {
5612
5804
  this._identityManager = _identityManager;
@@ -5624,7 +5816,7 @@ var DevicesServiceImpl = class {
5624
5816
  });
5625
5817
  } else {
5626
5818
  invariant17(this._identityManager.identity?.presence, "presence not present", {
5627
- F: __dxlog_file19,
5819
+ F: __dxlog_file20,
5628
5820
  L: 32,
5629
5821
  S: this,
5630
5822
  A: [
@@ -5652,165 +5844,88 @@ var DevicesServiceImpl = class {
5652
5844
  const subscribeIdentity = () => {
5653
5845
  if (!identitySubscribed) {
5654
5846
  this._identityManager.identity?.stateUpdate.on(() => {
5655
- update();
5656
- });
5657
- identitySubscribed = true;
5658
- }
5659
- };
5660
- const subscribePresence = () => {
5661
- if (!presenceSubscribed) {
5662
- this._identityManager.identity?.presence?.updated.on(() => {
5663
- update();
5664
- });
5665
- presenceSubscribed = true;
5666
- }
5667
- };
5668
- const subscriptions = new EventSubscriptions3();
5669
- if (this._identityManager.identity) {
5670
- subscribeIdentity();
5671
- subscribePresence();
5672
- }
5673
- subscriptions.add(this._identityManager.stateUpdate.on(() => {
5674
- update();
5675
- if (this._identityManager.identity) {
5676
- subscribeIdentity();
5677
- subscribePresence();
5678
- }
5679
- }));
5680
- update();
5681
- return () => subscriptions.clear();
5682
- });
5683
- }
5684
- };
5685
-
5686
- // packages/sdk/client-services/src/packlets/locks/browser.ts
5687
- import { asyncTimeout as asyncTimeout3, Trigger as Trigger8 } from "@dxos/async";
5688
- import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
5689
- import { log as log16, logInfo } from "@dxos/log";
5690
- function _ts_decorate7(decorators, target, key, desc) {
5691
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5692
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
5693
- r = Reflect.decorate(decorators, target, key, desc);
5694
- else
5695
- for (var i = decorators.length - 1; i >= 0; i--)
5696
- if (d = decorators[i])
5697
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5698
- return c > 3 && r && Object.defineProperty(target, key, r), r;
5699
- }
5700
- var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
5701
- var Message;
5702
- (function(Message2) {
5703
- Message2["ACQUIRING"] = "acquiring";
5704
- })(Message || (Message = {}));
5705
- var Lock = class {
5706
- constructor({ lockKey, onAcquire, onRelease }) {
5707
- this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
5708
- this._releaseTrigger = new Trigger8();
5709
- this._lockKey = lockKey;
5710
- this._onAcquire = onAcquire;
5711
- this._onRelease = onRelease;
5712
- this._broadcastChannel.onmessage = this._onMessage.bind(this);
5713
- }
5714
- get lockKey() {
5715
- return this._lockKey;
5716
- }
5717
- async acquire() {
5718
- this._broadcastChannel.postMessage({
5719
- message: "acquiring"
5847
+ update();
5848
+ });
5849
+ identitySubscribed = true;
5850
+ }
5851
+ };
5852
+ const subscribePresence = () => {
5853
+ if (!presenceSubscribed) {
5854
+ this._identityManager.identity?.presence?.updated.on(() => {
5855
+ update();
5856
+ });
5857
+ presenceSubscribed = true;
5858
+ }
5859
+ };
5860
+ const subscriptions = new EventSubscriptions3();
5861
+ if (this._identityManager.identity) {
5862
+ subscribeIdentity();
5863
+ subscribePresence();
5864
+ }
5865
+ subscriptions.add(this._identityManager.stateUpdate.on(() => {
5866
+ update();
5867
+ if (this._identityManager.identity) {
5868
+ subscribeIdentity();
5869
+ subscribePresence();
5870
+ }
5871
+ }));
5872
+ update();
5873
+ return () => subscriptions.clear();
5720
5874
  });
5721
- try {
5722
- log16("aquiring lock...", void 0, {
5723
- F: __dxlog_file20,
5724
- L: 42,
5725
- S: this,
5726
- C: (f, a) => f(...a)
5727
- });
5728
- await asyncTimeout3(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
5729
- log16("acquired lock", void 0, {
5730
- F: __dxlog_file20,
5731
- L: 44,
5732
- S: this,
5733
- C: (f, a) => f(...a)
5734
- });
5735
- } catch {
5736
- log16("stealing lock...", void 0, {
5737
- F: __dxlog_file20,
5738
- L: 46,
5739
- S: this,
5740
- C: (f, a) => f(...a)
5741
- });
5742
- await this._requestLock(true);
5743
- log16("stolen lock", void 0, {
5744
- F: __dxlog_file20,
5745
- L: 48,
5746
- S: this,
5747
- C: (f, a) => f(...a)
5748
- });
5749
- }
5750
5875
  }
5751
- async release() {
5752
- this._releaseTrigger.wake();
5753
- }
5754
- _onMessage(event) {
5755
- if (event.data.message === "acquiring") {
5756
- this._releaseTrigger.wake();
5757
- }
5876
+ };
5877
+
5878
+ // packages/sdk/client-services/src/packlets/diagnostics/diagnostics-collector.ts
5879
+ import { ConfigResource } from "@dxos/config";
5880
+ import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
5881
+ import { TRACE_PROCESSOR as TRACE_PROCESSOR2 } from "@dxos/tracing";
5882
+ import { jsonKeyReplacer, nonNullable } from "@dxos/util";
5883
+
5884
+ // packages/sdk/client-services/src/packlets/services/util.ts
5885
+ import { PublicKey as PublicKey14 } from "@dxos/keys";
5886
+ import { humanize } from "@dxos/util";
5887
+ var ClientServicesProviderResource = Symbol.for("dxos.resource.ClientServices");
5888
+
5889
+ // packages/sdk/client-services/src/packlets/diagnostics/diagnostics-collector.ts
5890
+ var GET_DIAGNOSTICS_RPC_TIMEOUT = 1e4;
5891
+ var DiagnosticsCollector = class {
5892
+ static {
5893
+ this.broadcastSender = createCollectDiagnosticsBroadcastSender();
5758
5894
  }
5759
- async _requestLock(steal = false) {
5760
- log16("requesting lock...", {
5761
- steal
5762
- }, {
5763
- F: __dxlog_file20,
5764
- L: 63,
5765
- S: this,
5766
- C: (f, a) => f(...a)
5767
- });
5768
- const acquired = new Trigger8();
5769
- void navigator.locks.request(this._lockKey, {
5770
- steal
5771
- }, async () => {
5772
- await this._onAcquire?.();
5773
- acquired.wake();
5774
- this._releaseTrigger = new Trigger8();
5775
- await this._releaseTrigger.wait();
5776
- log16("releasing lock...", void 0, {
5777
- F: __dxlog_file20,
5778
- L: 72,
5779
- S: this,
5780
- C: (f, a) => f(...a)
5781
- });
5782
- await this._onRelease?.();
5783
- log16("released lock", void 0, {
5784
- F: __dxlog_file20,
5785
- L: 74,
5786
- S: this,
5787
- C: (f, a) => f(...a)
5788
- });
5789
- }).catch(async () => {
5790
- await this._onRelease?.();
5791
- });
5792
- await acquired.wait();
5793
- log16("recieved lock", {
5794
- steal
5895
+ static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
5896
+ const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
5897
+ keys: options.humanize ? GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
5795
5898
  }, {
5796
- F: __dxlog_file20,
5797
- L: 81,
5798
- S: this,
5799
- C: (f, a) => f(...a)
5899
+ timeout: GET_DIAGNOSTICS_RPC_TIMEOUT
5800
5900
  });
5901
+ const clientDiagnostics = {
5902
+ config,
5903
+ trace: TRACE_PROCESSOR2.getDiagnostics()
5904
+ };
5905
+ const diagnostics = serviceDiagnostics != null ? {
5906
+ client: clientDiagnostics,
5907
+ services: serviceDiagnostics
5908
+ } : {
5909
+ client: clientDiagnostics,
5910
+ broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
5911
+ };
5912
+ return JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer(options)));
5801
5913
  }
5802
5914
  };
5803
- _ts_decorate7([
5804
- logInfo
5805
- ], Lock.prototype, "lockKey", null);
5806
- var isLocked = (lockPath) => {
5807
- throw new Error("Not implemented");
5915
+ var findSystemServiceProvider = () => {
5916
+ const serviceProviders = TRACE_PROCESSOR2.findResourcesByAnnotation(ClientServicesProviderResource);
5917
+ const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
5918
+ return providerResource?.instance?.deref() ?? null;
5919
+ };
5920
+ var findConfigs = () => {
5921
+ const configs = TRACE_PROCESSOR2.findResourcesByAnnotation(ConfigResource);
5922
+ return configs.map((r) => r.instance.deref()).filter(nonNullable);
5808
5923
  };
5809
5924
 
5810
5925
  // packages/sdk/client-services/src/packlets/logging/logging-service.ts
5811
5926
  import { Event as Event8 } from "@dxos/async";
5812
5927
  import { Stream as Stream12 } from "@dxos/codec-protobuf";
5813
- import { PublicKey as PublicKey13 } from "@dxos/keys";
5928
+ import { PublicKey as PublicKey15 } from "@dxos/keys";
5814
5929
  import { getContextFromEntry, log as log17 } from "@dxos/log";
5815
5930
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
5816
5931
  import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
@@ -5818,7 +5933,7 @@ var LoggingServiceImpl = class {
5818
5933
  constructor() {
5819
5934
  this._logs = new Event8();
5820
5935
  this._started = Date.now();
5821
- this._sessionId = PublicKey13.random().toHex();
5936
+ this._sessionId = PublicKey15.random().toHex();
5822
5937
  this._logProcessor = (_config, entry2) => {
5823
5938
  this._logs.emit(entry2);
5824
5939
  };
@@ -5964,84 +6079,10 @@ var NetworkServiceImpl = class {
5964
6079
  }
5965
6080
  };
5966
6081
 
5967
- // packages/sdk/client-services/src/packlets/storage/storage.ts
5968
- import { InvalidConfigError } from "@dxos/protocols";
5969
- import { Runtime as Runtime2 } from "@dxos/protocols/proto/dxos/config";
5970
- import { createStorage, StorageType } from "@dxos/random-access-storage";
5971
-
5972
- // packages/sdk/client-services/src/packlets/storage/util.ts
5973
- import { DX_DATA } from "@dxos/client-protocol";
5974
- import { Runtime } from "@dxos/protocols/proto/dxos/config";
5975
- import { isNode as isNode2 } from "@dxos/util";
5976
- var getRootPath = (config) => {
5977
- const { dataRoot = isNode2() ? DX_DATA : "dxos/storage" } = config ?? {};
5978
- return `${dataRoot}/`;
5979
- };
5980
- var isPersistent = (config) => {
5981
- const { persistent = false } = config ?? {};
5982
- return config.dataStore !== void 0 && config.dataStore !== Runtime.Client.Storage.StorageDriver.RAM || persistent;
5983
- };
5984
-
5985
- // packages/sdk/client-services/src/packlets/storage/storage.ts
5986
- var StorageDriver = Runtime2.Client.Storage.StorageDriver;
5987
- var createStorageObjects = (config) => {
5988
- const { persistent = false, keyStore, dataStore } = config ?? {};
5989
- if (persistent && dataStore === StorageDriver.RAM) {
5990
- throw new InvalidConfigError("RAM storage cannot be used in persistent mode.");
5991
- }
5992
- if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
5993
- throw new InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
5994
- }
5995
- if (persistent && keyStore === StorageDriver.RAM) {
5996
- throw new InvalidConfigError("RAM key storage cannot be used in persistent mode.");
5997
- }
5998
- if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
5999
- throw new InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
6000
- }
6001
- return {
6002
- storage: createStorage({
6003
- type: persistent ? toStorageType(dataStore) : StorageType.RAM,
6004
- root: getRootPath(config)
6005
- })
6006
- };
6007
- };
6008
- var toStorageType = (type) => {
6009
- switch (type) {
6010
- case void 0:
6011
- return void 0;
6012
- case StorageDriver.RAM:
6013
- return StorageType.RAM;
6014
- case StorageDriver.CHROME:
6015
- return StorageType.CHROME;
6016
- case StorageDriver.FIREFOX:
6017
- return StorageType.FIREFOX;
6018
- case StorageDriver.IDB:
6019
- return StorageType.IDB;
6020
- case StorageDriver.NODE:
6021
- return StorageType.NODE;
6022
- case StorageDriver.WEBFS:
6023
- return StorageType.WEBFS;
6024
- default:
6025
- throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
6026
- }
6027
- };
6028
-
6029
- // packages/sdk/client-services/src/packlets/storage/level.ts
6030
- import path from "@dxos/node-std/path";
6031
- import { PublicKey as PublicKey14 } from "@dxos/keys";
6032
- import { createLevel as createKV } from "@dxos/kv-store";
6033
- var createLevel = async (config) => {
6034
- const persistent = isPersistent(config);
6035
- const storagePath = persistent ? path.join(getRootPath(config), "level") : `/tmp/dxos-${PublicKey14.random().toHex()}`;
6036
- const level = createKV(storagePath);
6037
- await level.open();
6038
- return level;
6039
- };
6040
-
6041
6082
  // packages/sdk/client-services/src/packlets/system/system-service.ts
6042
6083
  import { Stream as Stream14 } from "@dxos/codec-protobuf";
6043
- import { GetDiagnosticsRequest } from "@dxos/protocols/proto/dxos/client/services";
6044
- import { jsonKeyReplacer } from "@dxos/util";
6084
+ import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
6085
+ import { jsonKeyReplacer as jsonKeyReplacer2 } from "@dxos/util";
6045
6086
  var SystemServiceImpl = class {
6046
6087
  constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
6047
6088
  this._config = config;
@@ -6061,9 +6102,9 @@ var SystemServiceImpl = class {
6061
6102
  const diagnostics = await this._getDiagnostics();
6062
6103
  return {
6063
6104
  timestamp: /* @__PURE__ */ new Date(),
6064
- diagnostics: JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer({
6065
- truncate: keys === GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
6066
- humanize: keys === GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
6105
+ diagnostics: JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer2({
6106
+ truncate: keys === GetDiagnosticsRequest2.KEY_OPTION.TRUNCATE,
6107
+ humanize: keys === GetDiagnosticsRequest2.KEY_OPTION.HUMANIZE
6067
6108
  })))
6068
6109
  };
6069
6110
  }
@@ -6119,7 +6160,7 @@ var ClientServicesHost = class {
6119
6160
  callbacks,
6120
6161
  runtimeParams
6121
6162
  } = {}) {
6122
- this._tracingService = TRACE_PROCESSOR2.createTraceSender();
6163
+ this._tracingService = TRACE_PROCESSOR3.createTraceSender();
6123
6164
  this._statusUpdate = new Event9();
6124
6165
  this._opening = false;
6125
6166
  this._open = false;
@@ -6261,7 +6302,7 @@ var ClientServicesHost = class {
6261
6302
  if (this._open) {
6262
6303
  return;
6263
6304
  }
6264
- const traceId = PublicKey15.random().toHex();
6305
+ const traceId = PublicKey16.random().toHex();
6265
6306
  log18.trace("dxos.client-services.host.open", trace10.begin({
6266
6307
  id: traceId
6267
6308
  }), {
@@ -6409,7 +6450,7 @@ var ClientServicesHost = class {
6409
6450
  });
6410
6451
  }
6411
6452
  async reset() {
6412
- const traceId = PublicKey15.random().toHex();
6453
+ const traceId = PublicKey16.random().toHex();
6413
6454
  log18.trace("dxos.sdk.client-services-host.reset", trace10.begin({
6414
6455
  id: traceId
6415
6456
  }), {
@@ -6469,7 +6510,7 @@ var ClientServicesHost = class {
6469
6510
  keys: []
6470
6511
  }
6471
6512
  };
6472
- const propertiesId = PublicKey15.random().toHex();
6513
+ const propertiesId = PublicKey16.random().toHex();
6473
6514
  document.change((doc) => {
6474
6515
  assignDeep2(doc, [
6475
6516
  "objects",
@@ -6498,47 +6539,6 @@ ClientServicesHost = _ts_decorate8([
6498
6539
  Trace4.resource()
6499
6540
  ], ClientServicesHost);
6500
6541
 
6501
- // packages/sdk/client-services/src/packlets/services/util.ts
6502
- import { PublicKey as PublicKey16 } from "@dxos/keys";
6503
- import { humanize } from "@dxos/util";
6504
- var ClientServicesProviderResource = Symbol.for("dxos.resource.ClientServices");
6505
-
6506
- // packages/sdk/client-services/src/packlets/diagnostics/diagnostics-collector.ts
6507
- var GET_DIAGNOSTICS_RPC_TIMEOUT = 1e4;
6508
- var DiagnosticsCollector = class {
6509
- static {
6510
- this.broadcastSender = createCollectDiagnosticsBroadcastSender();
6511
- }
6512
- static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
6513
- const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
6514
- keys: options.humanize ? GetDiagnosticsRequest2.KEY_OPTION.HUMANIZE : options.truncate ? GetDiagnosticsRequest2.KEY_OPTION.TRUNCATE : void 0
6515
- }, {
6516
- timeout: GET_DIAGNOSTICS_RPC_TIMEOUT
6517
- });
6518
- const clientDiagnostics = {
6519
- config,
6520
- trace: TRACE_PROCESSOR3.getDiagnostics()
6521
- };
6522
- const diagnostics = serviceDiagnostics != null ? {
6523
- client: clientDiagnostics,
6524
- services: serviceDiagnostics
6525
- } : {
6526
- client: clientDiagnostics,
6527
- broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
6528
- };
6529
- return JSON.parse(JSON.stringify(diagnostics, jsonKeyReplacer2(options)));
6530
- }
6531
- };
6532
- var findSystemServiceProvider = () => {
6533
- const serviceProviders = TRACE_PROCESSOR3.findResourcesByAnnotation(ClientServicesProviderResource);
6534
- const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
6535
- return providerResource?.instance?.deref() ?? null;
6536
- };
6537
- var findConfigs = () => {
6538
- const configs = TRACE_PROCESSOR3.findResourcesByAnnotation(ConfigResource);
6539
- return configs.map((r) => r.instance.deref()).filter(nonNullable);
6540
- };
6541
-
6542
6542
  export {
6543
6543
  Buffer,
6544
6544
  subscribeToFeeds,
@@ -6551,6 +6551,10 @@ export {
6551
6551
  subscribeToSpaces,
6552
6552
  DevtoolsHostEvents,
6553
6553
  DevtoolsServiceImpl,
6554
+ createDiagnostics,
6555
+ createCollectDiagnosticsBroadcastSender,
6556
+ createCollectDiagnosticsBroadcastHandler,
6557
+ ClientRpcServer,
6554
6558
  createAuthProvider,
6555
6559
  TrustedKeySetAuthVerifier,
6556
6560
  Identity,
@@ -6562,22 +6566,18 @@ export {
6562
6566
  InvitationsServiceImpl,
6563
6567
  SpaceInvitationProtocol,
6564
6568
  InvitationsManager,
6565
- ClientRpcServer,
6566
6569
  DataSpace,
6567
6570
  findPropertiesObject,
6568
6571
  DataSpaceManager,
6569
6572
  SpacesServiceImpl,
6570
6573
  ServiceContext,
6571
6574
  ServiceRegistry,
6572
- createDiagnostics,
6573
- createCollectDiagnosticsBroadcastSender,
6574
- createCollectDiagnosticsBroadcastHandler,
6575
- DiagnosticsCollector,
6576
6575
  Lock,
6577
6576
  isLocked,
6578
6577
  createStorageObjects,
6579
6578
  createLevel,
6580
6579
  ClientServicesHost,
6581
- ClientServicesProviderResource
6580
+ ClientServicesProviderResource,
6581
+ DiagnosticsCollector
6582
6582
  };
6583
- //# sourceMappingURL=chunk-QNCZI356.mjs.map
6583
+ //# sourceMappingURL=chunk-KNGR7BYM.mjs.map