@dxos/client-services 0.5.9-main.2d0a5e6 → 0.5.9-main.8359215

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