@dxos/echo-pipeline 0.5.9-main.a50ff17 → 0.5.9-main.a75fa71

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 (33) hide show
  1. package/dist/lib/browser/{chunk-I2J5TTHJ.mjs → chunk-HS77A4I4.mjs} +174 -23
  2. package/dist/lib/browser/{chunk-I2J5TTHJ.mjs.map → chunk-HS77A4I4.mjs.map} +4 -4
  3. package/dist/lib/browser/index.mjs +119 -82
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +11 -7
  7. package/dist/lib/browser/testing/index.mjs.map +1 -1
  8. package/dist/lib/node/{chunk-QPCNQ4ZK.cjs → chunk-Y5U7UXEL.cjs} +185 -34
  9. package/dist/lib/node/{chunk-QPCNQ4ZK.cjs.map → chunk-Y5U7UXEL.cjs.map} +4 -4
  10. package/dist/lib/node/index.cjs +164 -127
  11. package/dist/lib/node/index.cjs.map +3 -3
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +21 -17
  14. package/dist/lib/node/testing/index.cjs.map +1 -1
  15. package/dist/types/src/automerge/automerge-host.d.ts +40 -3
  16. package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
  17. package/dist/types/src/automerge/echo-network-adapter.d.ts +2 -0
  18. package/dist/types/src/automerge/echo-network-adapter.d.ts.map +1 -1
  19. package/dist/types/src/automerge/mesh-echo-replicator.d.ts.map +1 -1
  20. package/dist/types/src/space/admission-discovery-extension.d.ts +30 -0
  21. package/dist/types/src/space/admission-discovery-extension.d.ts.map +1 -0
  22. package/dist/types/src/space/index.d.ts +1 -0
  23. package/dist/types/src/space/index.d.ts.map +1 -1
  24. package/dist/types/src/space/space-manager.d.ts +8 -0
  25. package/dist/types/src/space/space-manager.d.ts.map +1 -1
  26. package/package.json +33 -33
  27. package/src/automerge/automerge-doc-loader.test.ts +2 -3
  28. package/src/automerge/automerge-host.ts +96 -32
  29. package/src/automerge/echo-network-adapter.ts +10 -4
  30. package/src/automerge/mesh-echo-replicator.ts +6 -1
  31. package/src/space/admission-discovery-extension.ts +90 -0
  32. package/src/space/index.ts +1 -0
  33. package/src/space/space-manager.ts +46 -1
@@ -3,6 +3,8 @@ import {
3
3
  AuthExtension,
4
4
  AuthStatus,
5
5
  Buffer,
6
+ CredentialRetrieverExtension,
7
+ CredentialServerExtension,
6
8
  DataServiceImpl,
7
9
  MOCK_AUTH_PROVIDER,
8
10
  MOCK_AUTH_VERIFIER,
@@ -23,16 +25,14 @@ import {
23
25
  mapTimeframeToFeedIndexes,
24
26
  startAfter,
25
27
  valueEncoding
26
- } from "./chunk-I2J5TTHJ.mjs";
28
+ } from "./chunk-HS77A4I4.mjs";
27
29
 
28
30
  // packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts
29
- import { Event } from "@dxos/async";
30
- import { next as automerge, getBackend, getHeads } from "@dxos/automerge/automerge";
31
+ import { Event, asyncTimeout } from "@dxos/async";
32
+ import { next as automerge, getBackend, getHeads, isAutomerge, save } from "@dxos/automerge/automerge";
31
33
  import { Repo } from "@dxos/automerge/automerge-repo";
32
- import { Context } from "@dxos/context";
33
- import { invariant as invariant3 } from "@dxos/invariant";
34
+ import { Context, cancelWithContext } from "@dxos/context";
34
35
  import { PublicKey } from "@dxos/keys";
35
- import { log as log2 } from "@dxos/log";
36
36
  import { objectPointerCodec } from "@dxos/protocols";
37
37
  import { trace } from "@dxos/tracing";
38
38
  import { mapValues } from "@dxos/util";
@@ -319,10 +319,7 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
319
319
  _emitPeerCandidate(connection) {
320
320
  this.emit("peer-candidate", {
321
321
  peerId: connection.peerId,
322
- peerMetadata: {
323
- // TODO(dmaretskyi): Refactor this.
324
- dxos_peerSource: "EchoNetworkAdapter"
325
- }
322
+ peerMetadata: createEchoPeerMetadata()
326
323
  });
327
324
  }
328
325
  };
@@ -338,6 +335,11 @@ _ts_decorate([
338
335
  _ts_decorate([
339
336
  synchronized
340
337
  ], EchoNetworkAdapter.prototype, "removeReplicator", null);
338
+ var createEchoPeerMetadata = () => ({
339
+ // TODO(dmaretskyi): Refactor this.
340
+ dxos_peerSource: "EchoNetworkAdapter"
341
+ });
342
+ var isEchoPeerMetadata = (metadata) => metadata?.dxos_peerSource === "EchoNetworkAdapter";
341
343
 
342
344
  // packages/core/echo/echo-pipeline/src/automerge/leveldb-storage-adapter.ts
343
345
  import { LifecycleState as LifecycleState2, Resource } from "@dxos/context";
@@ -587,11 +589,13 @@ function _ts_decorate2(decorators, target, key, desc) {
587
589
  var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
588
590
  var AutomergeHost = class {
589
591
  constructor({ db, indexMetadataStore }) {
590
- this._ctx = new Context();
592
+ this._ctx = new Context(void 0, {
593
+ F: __dxlog_file3,
594
+ L: 71
595
+ });
591
596
  this._echoNetworkAdapter = new EchoNetworkAdapter({
592
597
  getContainingSpaceForDocument: this._getContainingSpaceForDocument.bind(this)
593
598
  });
594
- this._requestedDocs = /* @__PURE__ */ new Set();
595
599
  this._storage = new LevelDBStorageAdapter({
596
600
  db,
597
601
  callbacks: {
@@ -627,6 +631,9 @@ var AutomergeHost = class {
627
631
  await this._echoNetworkAdapter.close();
628
632
  await this._ctx.dispose();
629
633
  }
634
+ /**
635
+ * @deprecated To be abstracted away.
636
+ */
630
637
  get repo() {
631
638
  return this._repo;
632
639
  }
@@ -636,6 +643,39 @@ var AutomergeHost = class {
636
643
  async removeReplicator(replicator) {
637
644
  await this._echoNetworkAdapter.removeReplicator(replicator);
638
645
  }
646
+ /**
647
+ * Loads the document handle from the repo and waits for it to be ready.
648
+ */
649
+ async loadDoc(ctx, documentId, opts) {
650
+ let handle;
651
+ if (typeof documentId === "string") {
652
+ handle = this._repo.handles[documentId];
653
+ }
654
+ if (!handle) {
655
+ handle = this._repo.find(documentId);
656
+ }
657
+ if (!handle.isReady()) {
658
+ if (!opts?.timeout) {
659
+ await cancelWithContext(ctx, handle.whenReady());
660
+ } else {
661
+ await cancelWithContext(ctx, asyncTimeout(handle.whenReady(), opts.timeout));
662
+ }
663
+ }
664
+ return handle;
665
+ }
666
+ /**
667
+ * Create new persisted document.
668
+ */
669
+ createDoc(initialValue, opts) {
670
+ if (opts?.preserveHistory) {
671
+ if (!isAutomerge(initialValue)) {
672
+ throw new TypeError("Initial value must be an Automerge document");
673
+ }
674
+ return this._repo.import(save(initialValue));
675
+ } else {
676
+ return this._repo.create(initialValue);
677
+ }
678
+ }
639
679
  // TODO(dmaretskyi): Share based on HALO permissions and space affinity.
640
680
  // Hosts, running in the worker, don't share documents unless requested by other peers.
641
681
  // NOTE: If both peers return sharePolicy=false the replication will not happen
@@ -647,23 +687,8 @@ var AutomergeHost = class {
647
687
  if (!documentId) {
648
688
  return false;
649
689
  }
650
- const doc = this._repo.handles[documentId]?.docSync();
651
- if (!doc) {
652
- const isRequested = this._requestedDocs.has(`automerge:${documentId}`);
653
- log2("doc share policy check", {
654
- peerId,
655
- documentId,
656
- isRequested
657
- }, {
658
- F: __dxlog_file3,
659
- L: 143,
660
- S: this,
661
- C: (f, a) => f(...a)
662
- });
663
- return isRequested;
664
- }
665
690
  const peerMetadata = this.repo.peerMetadataByPeerId[peerId];
666
- if (peerMetadata?.dxos_peerSource === "EchoNetworkAdapter") {
691
+ if (isEchoPeerMetadata(peerMetadata)) {
667
692
  return this._echoNetworkAdapter.shouldAdvertize(peerId, {
668
693
  documentId
669
694
  });
@@ -735,31 +760,36 @@ var AutomergeHost = class {
735
760
  }
736
761
  return PublicKey.from(spaceKeyHex);
737
762
  }
738
- //
739
- // Methods for client-services.
740
- //
763
+ /**
764
+ * Flush documents to disk.
765
+ */
741
766
  async flush({ states }) {
742
- await Promise.all(states?.map(async ({ heads, documentId }) => {
743
- invariant3(heads, "heads are required for flush", {
744
- F: __dxlog_file3,
745
- L: 237,
746
- S: this,
747
- A: [
748
- "heads",
749
- "'heads are required for flush'"
750
- ]
751
- });
752
- const handle = this.repo.handles[documentId] ?? this._repo.find(documentId);
753
- await waitForHeads(handle, heads);
754
- }) ?? []);
767
+ if (states) {
768
+ await Promise.all(states.map(async ({ heads, documentId }) => {
769
+ if (!heads) {
770
+ return;
771
+ }
772
+ const handle = this.repo.handles[documentId] ?? this._repo.find(documentId);
773
+ await waitForHeads(handle, heads);
774
+ }) ?? []);
775
+ }
755
776
  await this._repo.flush(states?.map(({ documentId }) => documentId));
756
777
  }
778
+ /**
779
+ * Host <-> Client sync.
780
+ */
757
781
  syncRepo(request) {
758
782
  return this._clientNetwork.syncRepo(request);
759
783
  }
784
+ /**
785
+ * Host <-> Client sync.
786
+ */
760
787
  sendSyncMessage(request) {
761
788
  return this._clientNetwork.sendSyncMessage(request);
762
789
  }
790
+ /**
791
+ * Host <-> Client sync.
792
+ */
763
793
  async getHostInfo() {
764
794
  return this._clientNetwork.getHostInfo();
765
795
  }
@@ -813,11 +843,11 @@ var changeIsPresentInDoc = (doc, changeHash) => {
813
843
 
814
844
  // packages/core/echo/echo-pipeline/src/automerge/automerge-doc-loader.ts
815
845
  import { Event as Event2 } from "@dxos/async";
816
- import { cancelWithContext } from "@dxos/context";
846
+ import { cancelWithContext as cancelWithContext2 } from "@dxos/context";
817
847
  import { warnAfterTimeout } from "@dxos/debug";
818
848
  import { SpaceDocVersion } from "@dxos/echo-protocol";
819
- import { invariant as invariant4 } from "@dxos/invariant";
820
- import { log as log3 } from "@dxos/log";
849
+ import { invariant as invariant3 } from "@dxos/invariant";
850
+ import { log as log2 } from "@dxos/log";
821
851
  import { trace as trace2 } from "@dxos/tracing";
822
852
  function _ts_decorate3(decorators, target, key, desc) {
823
853
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -851,7 +881,7 @@ var AutomergeDocumentLoaderImpl = class {
851
881
  return;
852
882
  }
853
883
  if (!spaceState.rootUrl) {
854
- log3.error("Database opened with no rootUrl", {
884
+ log2.error("Database opened with no rootUrl", {
855
885
  spaceId: this._spaceId
856
886
  }, {
857
887
  F: __dxlog_file4,
@@ -863,7 +893,7 @@ var AutomergeDocumentLoaderImpl = class {
863
893
  } else {
864
894
  const existingDocHandle = await this._initDocHandle(ctx, spaceState.rootUrl);
865
895
  const doc = existingDocHandle.docSync();
866
- invariant4(doc, void 0, {
896
+ invariant3(doc, void 0, {
867
897
  F: __dxlog_file4,
868
898
  L: 77,
869
899
  S: this,
@@ -885,7 +915,7 @@ var AutomergeDocumentLoaderImpl = class {
885
915
  let hasUrlsToLoad = false;
886
916
  const urlsToLoad = {};
887
917
  for (const objectId of objectIds) {
888
- invariant4(this._spaceRootDocHandle, void 0, {
918
+ invariant3(this._spaceRootDocHandle, void 0, {
889
919
  F: __dxlog_file4,
890
920
  L: 90,
891
921
  S: this,
@@ -898,7 +928,7 @@ var AutomergeDocumentLoaderImpl = class {
898
928
  continue;
899
929
  }
900
930
  const spaceRootDoc = this._spaceRootDocHandle.docSync();
901
- invariant4(spaceRootDoc, void 0, {
931
+ invariant3(spaceRootDoc, void 0, {
902
932
  F: __dxlog_file4,
903
933
  L: 95,
904
934
  S: this,
@@ -910,7 +940,7 @@ var AutomergeDocumentLoaderImpl = class {
910
940
  const documentUrl = (spaceRootDoc.links ?? {})[objectId];
911
941
  if (documentUrl == null) {
912
942
  this._objectsPendingDocumentLoad.add(objectId);
913
- log3.info("loading delayed until object links are initialized", {
943
+ log2.info("loading delayed until object links are initialized", {
914
944
  objectId
915
945
  }, {
916
946
  F: __dxlog_file4,
@@ -936,7 +966,7 @@ var AutomergeDocumentLoaderImpl = class {
936
966
  linksAwaitingLoad.forEach(([objectId]) => this._objectsPendingDocumentLoad.delete(objectId));
937
967
  }
938
968
  getSpaceRootDocHandle() {
939
- invariant4(this._spaceRootDocHandle, void 0, {
969
+ invariant3(this._spaceRootDocHandle, void 0, {
940
970
  F: __dxlog_file4,
941
971
  L: 122,
942
972
  S: this,
@@ -948,7 +978,7 @@ var AutomergeDocumentLoaderImpl = class {
948
978
  return this._spaceRootDocHandle;
949
979
  }
950
980
  createDocumentForObject(objectId) {
951
- invariant4(this._spaceRootDocHandle, void 0, {
981
+ invariant3(this._spaceRootDocHandle, void 0, {
952
982
  F: __dxlog_file4,
953
983
  L: 127,
954
984
  S: this,
@@ -990,7 +1020,7 @@ var AutomergeDocumentLoaderImpl = class {
990
1020
  };
991
1021
  const objectDocumentHandle = this._objectDocumentHandles.get(objectId);
992
1022
  if (objectDocumentHandle != null && objectDocumentHandle.url !== automergeUrl) {
993
- log3.warn("object already inlined in a different document, ignoring the link", {
1023
+ log2.warn("object already inlined in a different document, ignoring the link", {
994
1024
  ...logMeta,
995
1025
  actualDocumentUrl: objectDocumentHandle.url
996
1026
  }, {
@@ -1002,7 +1032,7 @@ var AutomergeDocumentLoaderImpl = class {
1002
1032
  continue;
1003
1033
  }
1004
1034
  if (objectDocumentHandle?.url === automergeUrl) {
1005
- log3.warn("object document was already loaded", logMeta, {
1035
+ log2.warn("object document was already loaded", logMeta, {
1006
1036
  F: __dxlog_file4,
1007
1037
  L: 166,
1008
1038
  S: this,
@@ -1011,7 +1041,7 @@ var AutomergeDocumentLoaderImpl = class {
1011
1041
  continue;
1012
1042
  }
1013
1043
  const handle = this._repo.find(automergeUrl);
1014
- log3.debug("document loading triggered", logMeta, {
1044
+ log2.debug("document loading triggered", logMeta, {
1015
1045
  F: __dxlog_file4,
1016
1046
  L: 170,
1017
1047
  S: this,
@@ -1026,12 +1056,12 @@ var AutomergeDocumentLoaderImpl = class {
1026
1056
  while (true) {
1027
1057
  try {
1028
1058
  await warnAfterTimeout(5e3, "Automerge root doc load timeout (CoreDatabase)", async () => {
1029
- await cancelWithContext(ctx, docHandle.whenReady());
1059
+ await cancelWithContext2(ctx, docHandle.whenReady());
1030
1060
  });
1031
1061
  break;
1032
1062
  } catch (err) {
1033
1063
  if (`${err}`.includes("Timeout")) {
1034
- log3.info("wraparound", {
1064
+ log2.info("wraparound", {
1035
1065
  id: docHandle.documentId,
1036
1066
  state: docHandle.state
1037
1067
  }, {
@@ -1076,7 +1106,7 @@ var AutomergeDocumentLoaderImpl = class {
1076
1106
  docUrl: handle.url
1077
1107
  };
1078
1108
  if (this.onObjectDocumentLoaded.listenerCount() === 0) {
1079
- log3.info("document loaded after all listeners were removed", logMeta, {
1109
+ log2.info("document loaded after all listeners were removed", logMeta, {
1080
1110
  F: __dxlog_file4,
1081
1111
  L: 222,
1082
1112
  S: this,
@@ -1086,7 +1116,7 @@ var AutomergeDocumentLoaderImpl = class {
1086
1116
  }
1087
1117
  const objectDocHandle = this._objectDocumentHandles.get(objectId);
1088
1118
  if (objectDocHandle?.url !== handle.url) {
1089
- log3.warn("object was rebound while a document was loading, discarding handle", logMeta, {
1119
+ log2.warn("object was rebound while a document was loading, discarding handle", logMeta, {
1090
1120
  F: __dxlog_file4,
1091
1121
  L: 227,
1092
1122
  S: this,
@@ -1100,7 +1130,7 @@ var AutomergeDocumentLoaderImpl = class {
1100
1130
  });
1101
1131
  } catch (err) {
1102
1132
  const shouldRetryLoading = this.onObjectDocumentLoaded.listenerCount() > 0;
1103
- log3.warn("failed to load a document", {
1133
+ log2.warn("failed to load a document", {
1104
1134
  objectId,
1105
1135
  automergeUrl: handle.url,
1106
1136
  retryLoading: shouldRetryLoading,
@@ -1129,9 +1159,9 @@ AutomergeDocumentLoaderImpl = _ts_decorate3([
1129
1159
  // packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator.ts
1130
1160
  import { cbor as cbor2 } from "@dxos/automerge/automerge-repo";
1131
1161
  import { Resource as Resource2 } from "@dxos/context";
1132
- import { invariant as invariant5 } from "@dxos/invariant";
1162
+ import { invariant as invariant4 } from "@dxos/invariant";
1133
1163
  import { PublicKey as PublicKey2 } from "@dxos/keys";
1134
- import { log as log4 } from "@dxos/log";
1164
+ import { log as log3 } from "@dxos/log";
1135
1165
  import { AutomergeReplicator } from "@dxos/teleport-extension-automerge-replicator";
1136
1166
  import { ComplexMap, ComplexSet, defaultMap } from "@dxos/util";
1137
1167
  var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator.ts";
@@ -1160,7 +1190,7 @@ var MeshEchoReplicator = class {
1160
1190
  this._context = null;
1161
1191
  }
1162
1192
  createExtension() {
1163
- invariant5(this._context, void 0, {
1193
+ invariant4(this._context, void 0, {
1164
1194
  F: __dxlog_file5,
1165
1195
  L: 54,
1166
1196
  S: this,
@@ -1172,7 +1202,7 @@ var MeshEchoReplicator = class {
1172
1202
  const connection = new MeshReplicatorConnection({
1173
1203
  ownPeerId: this._context.peerId,
1174
1204
  onRemoteConnected: async () => {
1175
- log4("onRemoteConnected", {
1205
+ log3("onRemoteConnected", {
1176
1206
  peerId: connection.peerId
1177
1207
  }, {
1178
1208
  F: __dxlog_file5,
@@ -1180,7 +1210,7 @@ var MeshEchoReplicator = class {
1180
1210
  S: this,
1181
1211
  C: (f, a) => f(...a)
1182
1212
  });
1183
- invariant5(this._context, void 0, {
1213
+ invariant4(this._context, void 0, {
1184
1214
  F: __dxlog_file5,
1185
1215
  L: 60,
1186
1216
  S: this,
@@ -1198,7 +1228,7 @@ var MeshEchoReplicator = class {
1198
1228
  }
1199
1229
  },
1200
1230
  onRemoteDisconnected: async () => {
1201
- log4("onRemoteDisconnected", {
1231
+ log3("onRemoteDisconnected", {
1202
1232
  peerId: connection.peerId
1203
1233
  }, {
1204
1234
  F: __dxlog_file5,
@@ -1207,12 +1237,12 @@ var MeshEchoReplicator = class {
1207
1237
  C: (f, a) => f(...a)
1208
1238
  });
1209
1239
  this._context?.onConnectionClosed(connection);
1210
- await connection.disable();
1211
1240
  this._connectionsPerPeer.delete(connection.peerId);
1241
+ await connection.disable();
1212
1242
  this._connections.delete(connection);
1213
1243
  },
1214
1244
  shouldAdvertize: async (params) => {
1215
- log4("shouldAdvertize", {
1245
+ log3("shouldAdvertize", {
1216
1246
  peerId: connection.peerId,
1217
1247
  documentId: params.documentId
1218
1248
  }, {
@@ -1221,7 +1251,7 @@ var MeshEchoReplicator = class {
1221
1251
  S: this,
1222
1252
  C: (f, a) => f(...a)
1223
1253
  });
1224
- invariant5(this._context, void 0, {
1254
+ invariant4(this._context, void 0, {
1225
1255
  F: __dxlog_file5,
1226
1256
  L: 79,
1227
1257
  S: this,
@@ -1233,7 +1263,7 @@ var MeshEchoReplicator = class {
1233
1263
  try {
1234
1264
  const spaceKey = await this._context.getContainingSpaceForDocument(params.documentId);
1235
1265
  if (!spaceKey) {
1236
- log4("space key not found for share policy check", {
1266
+ log3("space key not found for share policy check", {
1237
1267
  peerId: connection.peerId,
1238
1268
  documentId: params.documentId
1239
1269
  }, {
@@ -1246,7 +1276,7 @@ var MeshEchoReplicator = class {
1246
1276
  }
1247
1277
  const authorizedDevices = this._authorizedDevices.get(spaceKey);
1248
1278
  if (!connection.remoteDeviceKey) {
1249
- log4("device key not found for share policy check", {
1279
+ log3("device key not found for share policy check", {
1250
1280
  peerId: connection.peerId,
1251
1281
  documentId: params.documentId
1252
1282
  }, {
@@ -1258,7 +1288,7 @@ var MeshEchoReplicator = class {
1258
1288
  return false;
1259
1289
  }
1260
1290
  const isAuthorized = authorizedDevices?.has(connection.remoteDeviceKey) ?? false;
1261
- log4("share policy check", {
1291
+ log3("share policy check", {
1262
1292
  localPeer: this._context.peerId,
1263
1293
  remotePeer: connection.peerId,
1264
1294
  documentId: params.documentId,
@@ -1273,7 +1303,7 @@ var MeshEchoReplicator = class {
1273
1303
  });
1274
1304
  return isAuthorized;
1275
1305
  } catch (err) {
1276
- log4.catch(err, void 0, {
1306
+ log3.catch(err, void 0, {
1277
1307
  F: __dxlog_file5,
1278
1308
  L: 111,
1279
1309
  S: this,
@@ -1287,7 +1317,7 @@ var MeshEchoReplicator = class {
1287
1317
  return connection.replicatorExtension;
1288
1318
  }
1289
1319
  authorizeDevice(spaceKey, deviceKey) {
1290
- log4("authorizeDevice", {
1320
+ log3("authorizeDevice", {
1291
1321
  spaceKey,
1292
1322
  deviceKey
1293
1323
  }, {
@@ -1297,6 +1327,11 @@ var MeshEchoReplicator = class {
1297
1327
  C: (f, a) => f(...a)
1298
1328
  });
1299
1329
  defaultMap(this._authorizedDevices, spaceKey, () => new ComplexSet(PublicKey2.hash)).add(deviceKey);
1330
+ for (const connection of this._connections) {
1331
+ if (connection.remoteDeviceKey && connection.remoteDeviceKey.equals(deviceKey)) {
1332
+ this._context?.onConnectionAuthScopeChanged(connection);
1333
+ }
1334
+ }
1300
1335
  }
1301
1336
  };
1302
1337
  var MeshReplicatorConnection = class extends Resource2 {
@@ -1328,13 +1363,13 @@ var MeshReplicatorConnection = class extends Resource2 {
1328
1363
  onStartReplication: async (info, remotePeerId) => {
1329
1364
  this.remoteDeviceKey = remotePeerId;
1330
1365
  this._remotePeerId = info.id;
1331
- log4("onStartReplication", {
1366
+ log3("onStartReplication", {
1332
1367
  id: info.id,
1333
1368
  thisPeerId: this.peerId,
1334
1369
  remotePeerId: remotePeerId.toHex()
1335
1370
  }, {
1336
1371
  F: __dxlog_file5,
1337
- L: 187,
1372
+ L: 192,
1338
1373
  S: this,
1339
1374
  C: (f, a) => f(...a)
1340
1375
  });
@@ -1356,9 +1391,9 @@ var MeshReplicatorConnection = class extends Resource2 {
1356
1391
  });
1357
1392
  }
1358
1393
  get peerId() {
1359
- invariant5(this._remotePeerId != null, "Remote peer has not connected yet.", {
1394
+ invariant4(this._remotePeerId != null, "Remote peer has not connected yet.", {
1360
1395
  F: __dxlog_file5,
1361
- L: 210,
1396
+ L: 215,
1362
1397
  S: this,
1363
1398
  A: [
1364
1399
  "this._remotePeerId != null",
@@ -1375,9 +1410,9 @@ var MeshReplicatorConnection = class extends Resource2 {
1375
1410
  * Call after the remote peer has connected.
1376
1411
  */
1377
1412
  async enable() {
1378
- invariant5(this._remotePeerId != null, "Remote peer has not connected yet.", {
1413
+ invariant4(this._remotePeerId != null, "Remote peer has not connected yet.", {
1379
1414
  F: __dxlog_file5,
1380
- L: 223,
1415
+ L: 228,
1381
1416
  S: this,
1382
1417
  A: [
1383
1418
  "this._remotePeerId != null",
@@ -1398,6 +1433,8 @@ export {
1398
1433
  AuthStatus,
1399
1434
  AutomergeDocumentLoaderImpl,
1400
1435
  AutomergeHost,
1436
+ CredentialRetrieverExtension,
1437
+ CredentialServerExtension,
1401
1438
  DataServiceImpl,
1402
1439
  LevelDBStorageAdapter,
1403
1440
  LocalHostNetworkAdapter,