@dxos/echo-pipeline 0.6.1 → 0.6.2-main.000b1cc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{chunk-DMUP426Q.mjs → chunk-UJQ5VS5V.mjs} +383 -196
- package/dist/lib/browser/chunk-UJQ5VS5V.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +73 -573
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-NH5WJKOW.cjs → chunk-RH6TDRML.cjs} +438 -256
- package/dist/lib/node/chunk-RH6TDRML.cjs.map +7 -0
- package/dist/lib/node/index.cjs +94 -592
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +11 -11
- package/dist/types/src/automerge/automerge-host.d.ts +2 -17
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-network-adapter.d.ts +1 -1
- package/dist/types/src/automerge/index.d.ts +0 -2
- package/dist/types/src/automerge/index.d.ts.map +1 -1
- package/dist/types/src/automerge/mesh-echo-replicator.d.ts.map +1 -1
- package/dist/types/src/db-host/data-service.d.ts +10 -7
- package/dist/types/src/db-host/data-service.d.ts.map +1 -1
- package/dist/types/src/db-host/documents-synchronizer.d.ts +43 -0
- package/dist/types/src/db-host/documents-synchronizer.d.ts.map +1 -0
- package/dist/types/src/db-host/documents-synchronizer.test.d.ts +2 -0
- package/dist/types/src/db-host/documents-synchronizer.test.d.ts.map +1 -0
- package/dist/types/src/db-host/index.d.ts +1 -0
- package/dist/types/src/db-host/index.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/automerge/automerge-host.ts +6 -56
- package/src/automerge/automerge-repo.test.ts +124 -1
- package/src/automerge/echo-network-adapter.test.ts +11 -0
- package/src/automerge/echo-network-adapter.ts +1 -1
- package/src/automerge/index.ts +0 -2
- package/src/automerge/mesh-echo-replicator.ts +3 -0
- package/src/db-host/data-service.ts +49 -25
- package/src/db-host/documents-synchronizer.test.ts +40 -0
- package/src/db-host/documents-synchronizer.ts +156 -0
- package/src/db-host/index.ts +1 -0
- package/dist/lib/browser/chunk-DMUP426Q.mjs.map +0 -7
- package/dist/lib/node/chunk-NH5WJKOW.cjs.map +0 -7
- package/dist/types/src/automerge/automerge-doc-loader.d.ts +0 -71
- package/dist/types/src/automerge/automerge-doc-loader.d.ts.map +0 -1
- package/dist/types/src/automerge/automerge-doc-loader.test.d.ts +0 -2
- package/dist/types/src/automerge/automerge-doc-loader.test.d.ts.map +0 -1
- package/dist/types/src/automerge/local-host-network-adapter.d.ts +0 -30
- package/dist/types/src/automerge/local-host-network-adapter.d.ts.map +0 -1
- package/src/automerge/automerge-doc-loader.test.ts +0 -103
- package/src/automerge/automerge-doc-loader.ts +0 -267
- package/src/automerge/local-host-network-adapter.ts +0 -115
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
CredentialRetrieverExtension,
|
|
7
7
|
CredentialServerExtension,
|
|
8
8
|
DataServiceImpl,
|
|
9
|
+
DocumentsSynchronizer,
|
|
9
10
|
MOCK_AUTH_PROVIDER,
|
|
10
11
|
MOCK_AUTH_VERIFIER,
|
|
11
12
|
MetadataStore,
|
|
@@ -25,14 +26,14 @@ import {
|
|
|
25
26
|
mapTimeframeToFeedIndexes,
|
|
26
27
|
startAfter,
|
|
27
28
|
valueEncoding
|
|
28
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-UJQ5VS5V.mjs";
|
|
29
30
|
|
|
30
31
|
// packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts
|
|
31
32
|
import { Event, asyncTimeout } from "@dxos/async";
|
|
32
|
-
import { next as automerge, getBackend, getHeads, isAutomerge,
|
|
33
|
+
import { next as automerge, getBackend, getHeads, isAutomerge, equals as headsEquals, save } from "@dxos/automerge/automerge";
|
|
33
34
|
import { Repo } from "@dxos/automerge/automerge-repo";
|
|
34
35
|
import { Context, Resource as Resource2, cancelWithContext } from "@dxos/context";
|
|
35
|
-
import { invariant as
|
|
36
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
36
37
|
import { PublicKey } from "@dxos/keys";
|
|
37
38
|
import { log as log2 } from "@dxos/log";
|
|
38
39
|
import { objectPointerCodec } from "@dxos/protocols";
|
|
@@ -105,7 +106,7 @@ var EchoNetworkAdapter = class extends NetworkAdapter {
|
|
|
105
106
|
}
|
|
106
107
|
async close() {
|
|
107
108
|
if (this._lifecycleState === LifecycleState.CLOSED) {
|
|
108
|
-
return;
|
|
109
|
+
return this;
|
|
109
110
|
}
|
|
110
111
|
for (const replicator of this._replicators) {
|
|
111
112
|
await replicator.disconnect();
|
|
@@ -455,144 +456,6 @@ var encodingOptions = {
|
|
|
455
456
|
};
|
|
456
457
|
var isLevelDbNotFoundError = (err) => err.code === "LEVEL_NOT_FOUND";
|
|
457
458
|
|
|
458
|
-
// packages/core/echo/echo-pipeline/src/automerge/local-host-network-adapter.ts
|
|
459
|
-
import { Trigger as Trigger2 } from "@dxos/async";
|
|
460
|
-
import { NetworkAdapter as NetworkAdapter2, cbor } from "@dxos/automerge/automerge-repo";
|
|
461
|
-
import { Stream } from "@dxos/codec-protobuf";
|
|
462
|
-
import { invariant as invariant2 } from "@dxos/invariant";
|
|
463
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/local-host-network-adapter.ts";
|
|
464
|
-
var LocalHostNetworkAdapter = class extends NetworkAdapter2 {
|
|
465
|
-
constructor() {
|
|
466
|
-
super(...arguments);
|
|
467
|
-
this._peers = /* @__PURE__ */ new Map();
|
|
468
|
-
this._connected = new Trigger2();
|
|
469
|
-
this._isConnected = false;
|
|
470
|
-
}
|
|
471
|
-
/**
|
|
472
|
-
* Emits `ready` event. That signals to `Repo` that it can start using the adapter.
|
|
473
|
-
*/
|
|
474
|
-
ready() {
|
|
475
|
-
this.emit("ready", {
|
|
476
|
-
network: this
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
/**
|
|
480
|
-
* Called by `Repo` to connect to the network.
|
|
481
|
-
*
|
|
482
|
-
* @param peerId Our peer Id.
|
|
483
|
-
*/
|
|
484
|
-
connect(peerId) {
|
|
485
|
-
this.peerId = peerId;
|
|
486
|
-
this._isConnected = true;
|
|
487
|
-
this._connected.wake();
|
|
488
|
-
}
|
|
489
|
-
send(message) {
|
|
490
|
-
const peer = this._peers.get(message.targetId);
|
|
491
|
-
invariant2(peer, "Peer not found.", {
|
|
492
|
-
F: __dxlog_file2,
|
|
493
|
-
L: 51,
|
|
494
|
-
S: this,
|
|
495
|
-
A: [
|
|
496
|
-
"peer",
|
|
497
|
-
"'Peer not found.'"
|
|
498
|
-
]
|
|
499
|
-
});
|
|
500
|
-
peer.send(message);
|
|
501
|
-
}
|
|
502
|
-
async close() {
|
|
503
|
-
this._peers.forEach((peer) => peer.disconnect());
|
|
504
|
-
this.emit("close");
|
|
505
|
-
}
|
|
506
|
-
disconnect() {
|
|
507
|
-
}
|
|
508
|
-
async whenConnected() {
|
|
509
|
-
await this._connected.wait({
|
|
510
|
-
timeout: 1e4
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
syncRepo({ id, syncMessage }) {
|
|
514
|
-
const peerId = this._getPeerId(id);
|
|
515
|
-
return new Stream(({ next, close }) => {
|
|
516
|
-
invariant2(!this._peers.has(peerId), "Peer already connected.", {
|
|
517
|
-
F: __dxlog_file2,
|
|
518
|
-
L: 73,
|
|
519
|
-
S: this,
|
|
520
|
-
A: [
|
|
521
|
-
"!this._peers.has(peerId)",
|
|
522
|
-
"'Peer already connected.'"
|
|
523
|
-
]
|
|
524
|
-
});
|
|
525
|
-
this._peers.set(peerId, {
|
|
526
|
-
connected: true,
|
|
527
|
-
send: (message) => {
|
|
528
|
-
next({
|
|
529
|
-
syncMessage: cbor.encode(message)
|
|
530
|
-
});
|
|
531
|
-
},
|
|
532
|
-
disconnect: () => {
|
|
533
|
-
this._peers.delete(peerId);
|
|
534
|
-
close();
|
|
535
|
-
this.emit("peer-disconnected", {
|
|
536
|
-
peerId
|
|
537
|
-
});
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
|
-
invariant2(this._isConnected, void 0, {
|
|
541
|
-
F: __dxlog_file2,
|
|
542
|
-
L: 90,
|
|
543
|
-
S: this,
|
|
544
|
-
A: [
|
|
545
|
-
"this._isConnected",
|
|
546
|
-
""
|
|
547
|
-
]
|
|
548
|
-
});
|
|
549
|
-
this.emit("peer-candidate", {
|
|
550
|
-
peerMetadata: {},
|
|
551
|
-
peerId
|
|
552
|
-
});
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
async sendSyncMessage({ id, syncMessage }) {
|
|
556
|
-
invariant2(this._isConnected, void 0, {
|
|
557
|
-
F: __dxlog_file2,
|
|
558
|
-
L: 99,
|
|
559
|
-
S: this,
|
|
560
|
-
A: [
|
|
561
|
-
"this._isConnected",
|
|
562
|
-
""
|
|
563
|
-
]
|
|
564
|
-
});
|
|
565
|
-
const message = cbor.decode(syncMessage);
|
|
566
|
-
this.emit("message", message);
|
|
567
|
-
}
|
|
568
|
-
async getHostInfo() {
|
|
569
|
-
invariant2(this._isConnected, void 0, {
|
|
570
|
-
F: __dxlog_file2,
|
|
571
|
-
L: 105,
|
|
572
|
-
S: this,
|
|
573
|
-
A: [
|
|
574
|
-
"this._isConnected",
|
|
575
|
-
""
|
|
576
|
-
]
|
|
577
|
-
});
|
|
578
|
-
invariant2(this.peerId, "Peer id not set.", {
|
|
579
|
-
F: __dxlog_file2,
|
|
580
|
-
L: 106,
|
|
581
|
-
S: this,
|
|
582
|
-
A: [
|
|
583
|
-
"this.peerId",
|
|
584
|
-
"'Peer id not set.'"
|
|
585
|
-
]
|
|
586
|
-
});
|
|
587
|
-
return {
|
|
588
|
-
peerId: this.peerId
|
|
589
|
-
};
|
|
590
|
-
}
|
|
591
|
-
_getPeerId(id) {
|
|
592
|
-
return id;
|
|
593
|
-
}
|
|
594
|
-
};
|
|
595
|
-
|
|
596
459
|
// packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts
|
|
597
460
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
598
461
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -604,7 +467,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
604
467
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
605
468
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
606
469
|
}
|
|
607
|
-
var
|
|
470
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
|
|
608
471
|
var AutomergeHost = class extends Resource2 {
|
|
609
472
|
constructor({ db, indexMetadataStore }) {
|
|
610
473
|
super();
|
|
@@ -627,26 +490,20 @@ var AutomergeHost = class extends Resource2 {
|
|
|
627
490
|
async _open() {
|
|
628
491
|
this._peerId = `host-${PublicKey.random().toHex()}`;
|
|
629
492
|
await this._storage.open?.();
|
|
630
|
-
this._clientNetwork = new LocalHostNetworkAdapter();
|
|
631
493
|
this._repo = new Repo({
|
|
632
494
|
peerId: this._peerId,
|
|
633
495
|
sharePolicy: this._sharePolicy.bind(this),
|
|
634
496
|
storage: this._storage,
|
|
635
497
|
network: [
|
|
636
|
-
// Downstream client.
|
|
637
|
-
this._clientNetwork,
|
|
638
498
|
// Upstream swarm.
|
|
639
499
|
this._echoNetworkAdapter
|
|
640
500
|
]
|
|
641
501
|
});
|
|
642
|
-
this._clientNetwork.ready();
|
|
643
502
|
await this._echoNetworkAdapter.open();
|
|
644
|
-
await this._clientNetwork.whenConnected();
|
|
645
503
|
await this._echoNetworkAdapter.whenConnected();
|
|
646
504
|
}
|
|
647
505
|
async _close() {
|
|
648
506
|
await this._storage.close?.();
|
|
649
|
-
await this._clientNetwork.close();
|
|
650
507
|
await this._echoNetworkAdapter.close();
|
|
651
508
|
await this._ctx.dispose();
|
|
652
509
|
}
|
|
@@ -708,8 +565,8 @@ var AutomergeHost = class extends Resource2 {
|
|
|
708
565
|
return;
|
|
709
566
|
}
|
|
710
567
|
const handle = await this.loadDoc(Context.default(void 0, {
|
|
711
|
-
F:
|
|
712
|
-
L:
|
|
568
|
+
F: __dxlog_file2,
|
|
569
|
+
L: 189
|
|
713
570
|
}), documentId);
|
|
714
571
|
await waitForHeads(handle, heads2);
|
|
715
572
|
}) ?? []);
|
|
@@ -720,8 +577,8 @@ var AutomergeHost = class extends Resource2 {
|
|
|
720
577
|
log2.info("re-indexing heads for document", {
|
|
721
578
|
documentId
|
|
722
579
|
}, {
|
|
723
|
-
F:
|
|
724
|
-
L:
|
|
580
|
+
F: __dxlog_file2,
|
|
581
|
+
L: 200,
|
|
725
582
|
S: this,
|
|
726
583
|
C: (f, a) => f(...a)
|
|
727
584
|
});
|
|
@@ -736,17 +593,17 @@ var AutomergeHost = class extends Resource2 {
|
|
|
736
593
|
log2.warn("document is not available locally, skipping", {
|
|
737
594
|
documentId
|
|
738
595
|
}, {
|
|
739
|
-
F:
|
|
740
|
-
L:
|
|
596
|
+
F: __dxlog_file2,
|
|
597
|
+
L: 204,
|
|
741
598
|
S: this,
|
|
742
599
|
C: (f, a) => f(...a)
|
|
743
600
|
});
|
|
744
601
|
continue;
|
|
745
602
|
}
|
|
746
603
|
const doc = handle.docSync();
|
|
747
|
-
|
|
748
|
-
F:
|
|
749
|
-
L:
|
|
604
|
+
invariant2(doc, void 0, {
|
|
605
|
+
F: __dxlog_file2,
|
|
606
|
+
L: 209,
|
|
750
607
|
S: this,
|
|
751
608
|
A: [
|
|
752
609
|
"doc",
|
|
@@ -759,8 +616,8 @@ var AutomergeHost = class extends Resource2 {
|
|
|
759
616
|
await batch.write();
|
|
760
617
|
}
|
|
761
618
|
log2.info("done re-indexing heads", void 0, {
|
|
762
|
-
F:
|
|
763
|
-
L:
|
|
619
|
+
F: __dxlog_file2,
|
|
620
|
+
L: 216,
|
|
764
621
|
S: this,
|
|
765
622
|
C: (f, a) => f(...a)
|
|
766
623
|
});
|
|
@@ -853,17 +710,8 @@ var AutomergeHost = class extends Resource2 {
|
|
|
853
710
|
/**
|
|
854
711
|
* Flush documents to disk.
|
|
855
712
|
*/
|
|
856
|
-
async flush({
|
|
857
|
-
|
|
858
|
-
await Promise.all(states.map(async ({ heads, documentId }) => {
|
|
859
|
-
if (!heads) {
|
|
860
|
-
return;
|
|
861
|
-
}
|
|
862
|
-
const handle = this._repo.handles[documentId] ?? this._repo.find(documentId);
|
|
863
|
-
await waitForHeads(handle, heads);
|
|
864
|
-
}) ?? []);
|
|
865
|
-
}
|
|
866
|
-
await this._repo.flush(states?.map(({ documentId }) => documentId));
|
|
713
|
+
async flush({ documentIds } = {}) {
|
|
714
|
+
await this._repo.flush(documentIds);
|
|
867
715
|
}
|
|
868
716
|
async getHeads(documentId) {
|
|
869
717
|
const handle = this._repo.handles[documentId];
|
|
@@ -877,24 +725,6 @@ var AutomergeHost = class extends Resource2 {
|
|
|
877
725
|
return this._headsStore.getHeads(documentId);
|
|
878
726
|
}
|
|
879
727
|
}
|
|
880
|
-
/**
|
|
881
|
-
* Host <-> Client sync.
|
|
882
|
-
*/
|
|
883
|
-
syncRepo(request) {
|
|
884
|
-
return this._clientNetwork.syncRepo(request);
|
|
885
|
-
}
|
|
886
|
-
/**
|
|
887
|
-
* Host <-> Client sync.
|
|
888
|
-
*/
|
|
889
|
-
sendSyncMessage(request) {
|
|
890
|
-
return this._clientNetwork.sendSyncMessage(request);
|
|
891
|
-
}
|
|
892
|
-
/**
|
|
893
|
-
* Host <-> Client sync.
|
|
894
|
-
*/
|
|
895
|
-
async getHostInfo() {
|
|
896
|
-
return this._clientNetwork.getHostInfo();
|
|
897
|
-
}
|
|
898
728
|
};
|
|
899
729
|
_ts_decorate2([
|
|
900
730
|
trace.info()
|
|
@@ -940,351 +770,19 @@ var changeIsPresentInDoc = (doc, changeHash) => {
|
|
|
940
770
|
return !!getBackend(doc).getChangeByHash(changeHash);
|
|
941
771
|
};
|
|
942
772
|
|
|
943
|
-
// packages/core/echo/echo-pipeline/src/automerge/automerge-doc-loader.ts
|
|
944
|
-
import { Event as Event2 } from "@dxos/async";
|
|
945
|
-
import { interpretAsDocumentId } from "@dxos/automerge/automerge-repo";
|
|
946
|
-
import { cancelWithContext as cancelWithContext2 } from "@dxos/context";
|
|
947
|
-
import { warnAfterTimeout } from "@dxos/debug";
|
|
948
|
-
import { SpaceDocVersion } from "@dxos/echo-protocol";
|
|
949
|
-
import { invariant as invariant4 } from "@dxos/invariant";
|
|
950
|
-
import { log as log3 } from "@dxos/log";
|
|
951
|
-
import { trace as trace2 } from "@dxos/tracing";
|
|
952
|
-
function _ts_decorate3(decorators, target, key, desc) {
|
|
953
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
954
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
955
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
956
|
-
else
|
|
957
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
958
|
-
if (d = decorators[i])
|
|
959
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
960
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
961
|
-
}
|
|
962
|
-
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-doc-loader.ts";
|
|
963
|
-
var AutomergeDocumentLoaderImpl = class {
|
|
964
|
-
constructor(_spaceId, _repo, _spaceKey) {
|
|
965
|
-
this._spaceId = _spaceId;
|
|
966
|
-
this._repo = _repo;
|
|
967
|
-
this._spaceKey = _spaceKey;
|
|
968
|
-
this._spaceRootDocHandle = null;
|
|
969
|
-
this._objectDocumentHandles = /* @__PURE__ */ new Map();
|
|
970
|
-
this._objectsPendingDocumentLoad = /* @__PURE__ */ new Set();
|
|
971
|
-
this.onObjectDocumentLoaded = new Event2();
|
|
972
|
-
}
|
|
973
|
-
getAllHandles() {
|
|
974
|
-
return this._spaceRootDocHandle != null ? [
|
|
975
|
-
this._spaceRootDocHandle,
|
|
976
|
-
...new Set(this._objectDocumentHandles.values())
|
|
977
|
-
] : [];
|
|
978
|
-
}
|
|
979
|
-
async loadSpaceRootDocHandle(ctx, spaceState) {
|
|
980
|
-
if (this._spaceRootDocHandle != null) {
|
|
981
|
-
return;
|
|
982
|
-
}
|
|
983
|
-
if (!spaceState.rootUrl) {
|
|
984
|
-
throw new Error("Database opened with no rootUrl");
|
|
985
|
-
}
|
|
986
|
-
const existingDocHandle = await this._initDocHandle(ctx, spaceState.rootUrl);
|
|
987
|
-
const doc = existingDocHandle.docSync();
|
|
988
|
-
invariant4(doc, void 0, {
|
|
989
|
-
F: __dxlog_file4,
|
|
990
|
-
L: 84,
|
|
991
|
-
S: this,
|
|
992
|
-
A: [
|
|
993
|
-
"doc",
|
|
994
|
-
""
|
|
995
|
-
]
|
|
996
|
-
});
|
|
997
|
-
invariant4(doc.version === SpaceDocVersion.CURRENT, void 0, {
|
|
998
|
-
F: __dxlog_file4,
|
|
999
|
-
L: 85,
|
|
1000
|
-
S: this,
|
|
1001
|
-
A: [
|
|
1002
|
-
"doc.version === SpaceDocVersion.CURRENT",
|
|
1003
|
-
""
|
|
1004
|
-
]
|
|
1005
|
-
});
|
|
1006
|
-
if (doc.access == null) {
|
|
1007
|
-
this._initDocAccess(existingDocHandle);
|
|
1008
|
-
}
|
|
1009
|
-
this._spaceRootDocHandle = existingDocHandle;
|
|
1010
|
-
}
|
|
1011
|
-
loadObjectDocument(objectIdOrMany) {
|
|
1012
|
-
const objectIds = Array.isArray(objectIdOrMany) ? objectIdOrMany : [
|
|
1013
|
-
objectIdOrMany
|
|
1014
|
-
];
|
|
1015
|
-
let hasUrlsToLoad = false;
|
|
1016
|
-
const urlsToLoad = {};
|
|
1017
|
-
for (const objectId of objectIds) {
|
|
1018
|
-
invariant4(this._spaceRootDocHandle, void 0, {
|
|
1019
|
-
F: __dxlog_file4,
|
|
1020
|
-
L: 97,
|
|
1021
|
-
S: this,
|
|
1022
|
-
A: [
|
|
1023
|
-
"this._spaceRootDocHandle",
|
|
1024
|
-
""
|
|
1025
|
-
]
|
|
1026
|
-
});
|
|
1027
|
-
if (this._objectDocumentHandles.has(objectId) || this._objectsPendingDocumentLoad.has(objectId)) {
|
|
1028
|
-
continue;
|
|
1029
|
-
}
|
|
1030
|
-
const spaceRootDoc = this._spaceRootDocHandle.docSync();
|
|
1031
|
-
invariant4(spaceRootDoc, void 0, {
|
|
1032
|
-
F: __dxlog_file4,
|
|
1033
|
-
L: 102,
|
|
1034
|
-
S: this,
|
|
1035
|
-
A: [
|
|
1036
|
-
"spaceRootDoc",
|
|
1037
|
-
""
|
|
1038
|
-
]
|
|
1039
|
-
});
|
|
1040
|
-
const documentUrl = (spaceRootDoc.links ?? {})[objectId];
|
|
1041
|
-
if (documentUrl == null) {
|
|
1042
|
-
this._objectsPendingDocumentLoad.add(objectId);
|
|
1043
|
-
log3.info("loading delayed until object links are initialized", {
|
|
1044
|
-
objectId
|
|
1045
|
-
}, {
|
|
1046
|
-
F: __dxlog_file4,
|
|
1047
|
-
L: 106,
|
|
1048
|
-
S: this,
|
|
1049
|
-
C: (f, a) => f(...a)
|
|
1050
|
-
});
|
|
1051
|
-
} else {
|
|
1052
|
-
urlsToLoad[objectId] = documentUrl;
|
|
1053
|
-
hasUrlsToLoad = true;
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
if (hasUrlsToLoad) {
|
|
1057
|
-
this._loadLinkedObjects(urlsToLoad);
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
getObjectDocumentId(objectId) {
|
|
1061
|
-
invariant4(this._spaceRootDocHandle, void 0, {
|
|
1062
|
-
F: __dxlog_file4,
|
|
1063
|
-
L: 118,
|
|
1064
|
-
S: this,
|
|
1065
|
-
A: [
|
|
1066
|
-
"this._spaceRootDocHandle",
|
|
1067
|
-
""
|
|
1068
|
-
]
|
|
1069
|
-
});
|
|
1070
|
-
const spaceRootDoc = this._spaceRootDocHandle.docSync();
|
|
1071
|
-
invariant4(spaceRootDoc, void 0, {
|
|
1072
|
-
F: __dxlog_file4,
|
|
1073
|
-
L: 120,
|
|
1074
|
-
S: this,
|
|
1075
|
-
A: [
|
|
1076
|
-
"spaceRootDoc",
|
|
1077
|
-
""
|
|
1078
|
-
]
|
|
1079
|
-
});
|
|
1080
|
-
if (spaceRootDoc.objects?.[objectId]) {
|
|
1081
|
-
return this._spaceRootDocHandle.documentId;
|
|
1082
|
-
}
|
|
1083
|
-
const documentUrl = (spaceRootDoc.links ?? {})[objectId];
|
|
1084
|
-
return documentUrl && interpretAsDocumentId(documentUrl);
|
|
1085
|
-
}
|
|
1086
|
-
onObjectLinksUpdated(links) {
|
|
1087
|
-
if (!links) {
|
|
1088
|
-
return;
|
|
1089
|
-
}
|
|
1090
|
-
const linksAwaitingLoad = Object.entries(links).filter(([objectId]) => this._objectsPendingDocumentLoad.has(objectId));
|
|
1091
|
-
this._loadLinkedObjects(Object.fromEntries(linksAwaitingLoad));
|
|
1092
|
-
linksAwaitingLoad.forEach(([objectId]) => this._objectsPendingDocumentLoad.delete(objectId));
|
|
1093
|
-
}
|
|
1094
|
-
getSpaceRootDocHandle() {
|
|
1095
|
-
invariant4(this._spaceRootDocHandle, void 0, {
|
|
1096
|
-
F: __dxlog_file4,
|
|
1097
|
-
L: 140,
|
|
1098
|
-
S: this,
|
|
1099
|
-
A: [
|
|
1100
|
-
"this._spaceRootDocHandle",
|
|
1101
|
-
""
|
|
1102
|
-
]
|
|
1103
|
-
});
|
|
1104
|
-
return this._spaceRootDocHandle;
|
|
1105
|
-
}
|
|
1106
|
-
createDocumentForObject(objectId) {
|
|
1107
|
-
invariant4(this._spaceRootDocHandle, void 0, {
|
|
1108
|
-
F: __dxlog_file4,
|
|
1109
|
-
L: 145,
|
|
1110
|
-
S: this,
|
|
1111
|
-
A: [
|
|
1112
|
-
"this._spaceRootDocHandle",
|
|
1113
|
-
""
|
|
1114
|
-
]
|
|
1115
|
-
});
|
|
1116
|
-
const spaceDocHandle = this._repo.create({
|
|
1117
|
-
version: SpaceDocVersion.CURRENT
|
|
1118
|
-
});
|
|
1119
|
-
this._initDocAccess(spaceDocHandle);
|
|
1120
|
-
this.onObjectBoundToDocument(spaceDocHandle, objectId);
|
|
1121
|
-
this._spaceRootDocHandle.change((newDoc) => {
|
|
1122
|
-
newDoc.links ??= {};
|
|
1123
|
-
newDoc.links[objectId] = spaceDocHandle.url;
|
|
1124
|
-
});
|
|
1125
|
-
return spaceDocHandle;
|
|
1126
|
-
}
|
|
1127
|
-
onObjectBoundToDocument(handle, objectId) {
|
|
1128
|
-
this._objectDocumentHandles.set(objectId, handle);
|
|
1129
|
-
}
|
|
1130
|
-
clearHandleReferences() {
|
|
1131
|
-
const objectsWithHandles = [
|
|
1132
|
-
...this._objectDocumentHandles.keys()
|
|
1133
|
-
];
|
|
1134
|
-
this._objectDocumentHandles.clear();
|
|
1135
|
-
this._spaceRootDocHandle = null;
|
|
1136
|
-
return objectsWithHandles;
|
|
1137
|
-
}
|
|
1138
|
-
_loadLinkedObjects(links) {
|
|
1139
|
-
if (!links) {
|
|
1140
|
-
return;
|
|
1141
|
-
}
|
|
1142
|
-
for (const [objectId, automergeUrl] of Object.entries(links)) {
|
|
1143
|
-
const logMeta = {
|
|
1144
|
-
objectId,
|
|
1145
|
-
automergeUrl
|
|
1146
|
-
};
|
|
1147
|
-
const objectDocumentHandle = this._objectDocumentHandles.get(objectId);
|
|
1148
|
-
if (objectDocumentHandle != null && objectDocumentHandle.url !== automergeUrl) {
|
|
1149
|
-
log3.warn("object already inlined in a different document, ignoring the link", {
|
|
1150
|
-
...logMeta,
|
|
1151
|
-
actualDocumentUrl: objectDocumentHandle.url
|
|
1152
|
-
}, {
|
|
1153
|
-
F: __dxlog_file4,
|
|
1154
|
-
L: 177,
|
|
1155
|
-
S: this,
|
|
1156
|
-
C: (f, a) => f(...a)
|
|
1157
|
-
});
|
|
1158
|
-
continue;
|
|
1159
|
-
}
|
|
1160
|
-
if (objectDocumentHandle?.url === automergeUrl) {
|
|
1161
|
-
log3.warn("object document was already loaded", logMeta, {
|
|
1162
|
-
F: __dxlog_file4,
|
|
1163
|
-
L: 184,
|
|
1164
|
-
S: this,
|
|
1165
|
-
C: (f, a) => f(...a)
|
|
1166
|
-
});
|
|
1167
|
-
continue;
|
|
1168
|
-
}
|
|
1169
|
-
const handle = this._repo.find(automergeUrl);
|
|
1170
|
-
log3.debug("document loading triggered", logMeta, {
|
|
1171
|
-
F: __dxlog_file4,
|
|
1172
|
-
L: 188,
|
|
1173
|
-
S: this,
|
|
1174
|
-
C: (f, a) => f(...a)
|
|
1175
|
-
});
|
|
1176
|
-
this._objectDocumentHandles.set(objectId, handle);
|
|
1177
|
-
void this._createObjectOnDocumentLoad(handle, objectId);
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
async _initDocHandle(ctx, url) {
|
|
1181
|
-
const docHandle = this._repo.find(url);
|
|
1182
|
-
while (true) {
|
|
1183
|
-
try {
|
|
1184
|
-
await warnAfterTimeout(5e3, "Automerge root doc load timeout (CoreDatabase)", async () => {
|
|
1185
|
-
await cancelWithContext2(ctx, docHandle.whenReady());
|
|
1186
|
-
});
|
|
1187
|
-
break;
|
|
1188
|
-
} catch (err) {
|
|
1189
|
-
if (`${err}`.includes("Timeout")) {
|
|
1190
|
-
log3.info("wraparound", {
|
|
1191
|
-
id: docHandle.documentId,
|
|
1192
|
-
state: docHandle.state
|
|
1193
|
-
}, {
|
|
1194
|
-
F: __dxlog_file4,
|
|
1195
|
-
L: 204,
|
|
1196
|
-
S: this,
|
|
1197
|
-
C: (f, a) => f(...a)
|
|
1198
|
-
});
|
|
1199
|
-
continue;
|
|
1200
|
-
}
|
|
1201
|
-
throw err;
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1204
|
-
if (docHandle.state === "unavailable") {
|
|
1205
|
-
throw new Error("Automerge document is unavailable");
|
|
1206
|
-
}
|
|
1207
|
-
return docHandle;
|
|
1208
|
-
}
|
|
1209
|
-
_initDocAccess(handle) {
|
|
1210
|
-
handle.change((newDoc) => {
|
|
1211
|
-
newDoc.access ??= {
|
|
1212
|
-
spaceKey: this._spaceKey.toHex()
|
|
1213
|
-
};
|
|
1214
|
-
newDoc.access.spaceKey = this._spaceKey.toHex();
|
|
1215
|
-
});
|
|
1216
|
-
}
|
|
1217
|
-
async _createObjectOnDocumentLoad(handle, objectId) {
|
|
1218
|
-
try {
|
|
1219
|
-
await handle.whenReady();
|
|
1220
|
-
const logMeta = {
|
|
1221
|
-
objectId,
|
|
1222
|
-
docUrl: handle.url
|
|
1223
|
-
};
|
|
1224
|
-
if (this.onObjectDocumentLoaded.listenerCount() === 0) {
|
|
1225
|
-
log3.info("document loaded after all listeners were removed", logMeta, {
|
|
1226
|
-
F: __dxlog_file4,
|
|
1227
|
-
L: 231,
|
|
1228
|
-
S: this,
|
|
1229
|
-
C: (f, a) => f(...a)
|
|
1230
|
-
});
|
|
1231
|
-
return;
|
|
1232
|
-
}
|
|
1233
|
-
const objectDocHandle = this._objectDocumentHandles.get(objectId);
|
|
1234
|
-
if (objectDocHandle?.url !== handle.url) {
|
|
1235
|
-
log3.warn("object was rebound while a document was loading, discarding handle", logMeta, {
|
|
1236
|
-
F: __dxlog_file4,
|
|
1237
|
-
L: 236,
|
|
1238
|
-
S: this,
|
|
1239
|
-
C: (f, a) => f(...a)
|
|
1240
|
-
});
|
|
1241
|
-
return;
|
|
1242
|
-
}
|
|
1243
|
-
this.onObjectDocumentLoaded.emit({
|
|
1244
|
-
handle,
|
|
1245
|
-
objectId
|
|
1246
|
-
});
|
|
1247
|
-
} catch (err) {
|
|
1248
|
-
const shouldRetryLoading = this.onObjectDocumentLoaded.listenerCount() > 0;
|
|
1249
|
-
log3.warn("failed to load a document", {
|
|
1250
|
-
objectId,
|
|
1251
|
-
automergeUrl: handle.url,
|
|
1252
|
-
retryLoading: shouldRetryLoading,
|
|
1253
|
-
err
|
|
1254
|
-
}, {
|
|
1255
|
-
F: __dxlog_file4,
|
|
1256
|
-
L: 242,
|
|
1257
|
-
S: this,
|
|
1258
|
-
C: (f, a) => f(...a)
|
|
1259
|
-
});
|
|
1260
|
-
if (shouldRetryLoading) {
|
|
1261
|
-
await this._createObjectOnDocumentLoad(handle, objectId);
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
};
|
|
1266
|
-
_ts_decorate3([
|
|
1267
|
-
trace2.span({
|
|
1268
|
-
showInBrowserTimeline: true
|
|
1269
|
-
})
|
|
1270
|
-
], AutomergeDocumentLoaderImpl.prototype, "loadSpaceRootDocHandle", null);
|
|
1271
|
-
AutomergeDocumentLoaderImpl = _ts_decorate3([
|
|
1272
|
-
trace2.resource()
|
|
1273
|
-
], AutomergeDocumentLoaderImpl);
|
|
1274
|
-
|
|
1275
773
|
// packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator.ts
|
|
1276
|
-
import { invariant as
|
|
774
|
+
import { invariant as invariant4 } from "@dxos/invariant";
|
|
1277
775
|
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
1278
|
-
import { log as
|
|
776
|
+
import { log as log4 } from "@dxos/log";
|
|
1279
777
|
import { ComplexMap, ComplexSet, defaultMap } from "@dxos/util";
|
|
1280
778
|
|
|
1281
779
|
// packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator-connection.ts
|
|
1282
|
-
import { cbor
|
|
780
|
+
import { cbor } from "@dxos/automerge/automerge-repo";
|
|
1283
781
|
import { Resource as Resource3 } from "@dxos/context";
|
|
1284
|
-
import { invariant as
|
|
1285
|
-
import { log as
|
|
782
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
783
|
+
import { log as log3 } from "@dxos/log";
|
|
1286
784
|
import { AutomergeReplicator } from "@dxos/teleport-extension-automerge-replicator";
|
|
1287
|
-
var
|
|
785
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator-connection.ts";
|
|
1288
786
|
var DEFAULT_FACTORY = (params) => new AutomergeReplicator(...params);
|
|
1289
787
|
var MeshReplicatorConnection = class extends Resource3 {
|
|
1290
788
|
constructor(_params) {
|
|
@@ -1302,8 +800,8 @@ var MeshReplicatorConnection = class extends Resource3 {
|
|
|
1302
800
|
});
|
|
1303
801
|
this.writable = new WritableStream({
|
|
1304
802
|
write: async (message, controller) => {
|
|
1305
|
-
|
|
1306
|
-
F:
|
|
803
|
+
invariant3(this._isEnabled, "Writing to a disabled connection", {
|
|
804
|
+
F: __dxlog_file3,
|
|
1307
805
|
L: 47,
|
|
1308
806
|
S: this,
|
|
1309
807
|
A: [
|
|
@@ -1313,7 +811,7 @@ var MeshReplicatorConnection = class extends Resource3 {
|
|
|
1313
811
|
});
|
|
1314
812
|
try {
|
|
1315
813
|
await this.replicatorExtension.sendSyncMessage({
|
|
1316
|
-
payload:
|
|
814
|
+
payload: cbor.encode(message)
|
|
1317
815
|
});
|
|
1318
816
|
} catch (err) {
|
|
1319
817
|
controller.error(err);
|
|
@@ -1330,12 +828,12 @@ var MeshReplicatorConnection = class extends Resource3 {
|
|
|
1330
828
|
onStartReplication: async (info, remotePeerId) => {
|
|
1331
829
|
this.remoteDeviceKey = remotePeerId;
|
|
1332
830
|
this._remotePeerId = info.id;
|
|
1333
|
-
|
|
831
|
+
log3("onStartReplication", {
|
|
1334
832
|
id: info.id,
|
|
1335
833
|
thisPeerId: this.peerId,
|
|
1336
834
|
remotePeerId: remotePeerId.toHex()
|
|
1337
835
|
}, {
|
|
1338
|
-
F:
|
|
836
|
+
F: __dxlog_file3,
|
|
1339
837
|
L: 81,
|
|
1340
838
|
S: this,
|
|
1341
839
|
C: (f, a) => f(...a)
|
|
@@ -1346,7 +844,7 @@ var MeshReplicatorConnection = class extends Resource3 {
|
|
|
1346
844
|
if (!this._isEnabled) {
|
|
1347
845
|
return;
|
|
1348
846
|
}
|
|
1349
|
-
const message =
|
|
847
|
+
const message = cbor.decode(payload);
|
|
1350
848
|
readableStreamController.enqueue(message);
|
|
1351
849
|
},
|
|
1352
850
|
onClose: async () => {
|
|
@@ -1361,8 +859,8 @@ var MeshReplicatorConnection = class extends Resource3 {
|
|
|
1361
859
|
}
|
|
1362
860
|
}
|
|
1363
861
|
get peerId() {
|
|
1364
|
-
|
|
1365
|
-
F:
|
|
862
|
+
invariant3(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
863
|
+
F: __dxlog_file3,
|
|
1366
864
|
L: 107,
|
|
1367
865
|
S: this,
|
|
1368
866
|
A: [
|
|
@@ -1380,8 +878,8 @@ var MeshReplicatorConnection = class extends Resource3 {
|
|
|
1380
878
|
* Call after the remote peer has connected.
|
|
1381
879
|
*/
|
|
1382
880
|
enable() {
|
|
1383
|
-
|
|
1384
|
-
F:
|
|
881
|
+
invariant3(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
882
|
+
F: __dxlog_file3,
|
|
1385
883
|
L: 120,
|
|
1386
884
|
S: this,
|
|
1387
885
|
A: [
|
|
@@ -1400,7 +898,7 @@ var MeshReplicatorConnection = class extends Resource3 {
|
|
|
1400
898
|
};
|
|
1401
899
|
|
|
1402
900
|
// packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator.ts
|
|
1403
|
-
var
|
|
901
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator.ts";
|
|
1404
902
|
var MeshEchoReplicator = class {
|
|
1405
903
|
constructor() {
|
|
1406
904
|
this._connections = /* @__PURE__ */ new Set();
|
|
@@ -1418,6 +916,9 @@ var MeshEchoReplicator = class {
|
|
|
1418
916
|
this._context = context;
|
|
1419
917
|
}
|
|
1420
918
|
async disconnect() {
|
|
919
|
+
for (const connection of this._connectionsPerPeer.values()) {
|
|
920
|
+
this._context?.onConnectionClosed(connection);
|
|
921
|
+
}
|
|
1421
922
|
for (const connection of this._connections) {
|
|
1422
923
|
await connection.close();
|
|
1423
924
|
}
|
|
@@ -1426,9 +927,9 @@ var MeshEchoReplicator = class {
|
|
|
1426
927
|
this._context = null;
|
|
1427
928
|
}
|
|
1428
929
|
createExtension(extensionFactory) {
|
|
1429
|
-
|
|
1430
|
-
F:
|
|
1431
|
-
L:
|
|
930
|
+
invariant4(this._context, void 0, {
|
|
931
|
+
F: __dxlog_file4,
|
|
932
|
+
L: 54,
|
|
1432
933
|
S: this,
|
|
1433
934
|
A: [
|
|
1434
935
|
"this._context",
|
|
@@ -1439,17 +940,17 @@ var MeshEchoReplicator = class {
|
|
|
1439
940
|
ownPeerId: this._context.peerId,
|
|
1440
941
|
replicatorFactory: extensionFactory,
|
|
1441
942
|
onRemoteConnected: async () => {
|
|
1442
|
-
|
|
943
|
+
log4("onRemoteConnected", {
|
|
1443
944
|
peerId: connection.peerId
|
|
1444
945
|
}, {
|
|
1445
|
-
F:
|
|
1446
|
-
L:
|
|
946
|
+
F: __dxlog_file4,
|
|
947
|
+
L: 60,
|
|
1447
948
|
S: this,
|
|
1448
949
|
C: (f, a) => f(...a)
|
|
1449
950
|
});
|
|
1450
|
-
|
|
1451
|
-
F:
|
|
1452
|
-
L:
|
|
951
|
+
invariant4(this._context, void 0, {
|
|
952
|
+
F: __dxlog_file4,
|
|
953
|
+
L: 61,
|
|
1453
954
|
S: this,
|
|
1454
955
|
A: [
|
|
1455
956
|
"this._context",
|
|
@@ -1465,11 +966,11 @@ var MeshEchoReplicator = class {
|
|
|
1465
966
|
}
|
|
1466
967
|
},
|
|
1467
968
|
onRemoteDisconnected: async () => {
|
|
1468
|
-
|
|
969
|
+
log4("onRemoteDisconnected", {
|
|
1469
970
|
peerId: connection.peerId
|
|
1470
971
|
}, {
|
|
1471
|
-
F:
|
|
1472
|
-
L:
|
|
972
|
+
F: __dxlog_file4,
|
|
973
|
+
L: 72,
|
|
1473
974
|
S: this,
|
|
1474
975
|
C: (f, a) => f(...a)
|
|
1475
976
|
});
|
|
@@ -1479,18 +980,18 @@ var MeshEchoReplicator = class {
|
|
|
1479
980
|
this._connections.delete(connection);
|
|
1480
981
|
},
|
|
1481
982
|
shouldAdvertise: async (params) => {
|
|
1482
|
-
|
|
983
|
+
log4("shouldAdvertise", {
|
|
1483
984
|
peerId: connection.peerId,
|
|
1484
985
|
documentId: params.documentId
|
|
1485
986
|
}, {
|
|
1486
|
-
F:
|
|
1487
|
-
L:
|
|
987
|
+
F: __dxlog_file4,
|
|
988
|
+
L: 79,
|
|
1488
989
|
S: this,
|
|
1489
990
|
C: (f, a) => f(...a)
|
|
1490
991
|
});
|
|
1491
|
-
|
|
1492
|
-
F:
|
|
1493
|
-
L:
|
|
992
|
+
invariant4(this._context, void 0, {
|
|
993
|
+
F: __dxlog_file4,
|
|
994
|
+
L: 80,
|
|
1494
995
|
S: this,
|
|
1495
996
|
A: [
|
|
1496
997
|
"this._context",
|
|
@@ -1500,12 +1001,12 @@ var MeshEchoReplicator = class {
|
|
|
1500
1001
|
try {
|
|
1501
1002
|
const spaceKey = await this._context.getContainingSpaceForDocument(params.documentId);
|
|
1502
1003
|
if (!spaceKey) {
|
|
1503
|
-
|
|
1004
|
+
log4("space key not found for share policy check", {
|
|
1504
1005
|
peerId: connection.peerId,
|
|
1505
1006
|
documentId: params.documentId
|
|
1506
1007
|
}, {
|
|
1507
|
-
F:
|
|
1508
|
-
L:
|
|
1008
|
+
F: __dxlog_file4,
|
|
1009
|
+
L: 84,
|
|
1509
1010
|
S: this,
|
|
1510
1011
|
C: (f, a) => f(...a)
|
|
1511
1012
|
});
|
|
@@ -1513,19 +1014,19 @@ var MeshEchoReplicator = class {
|
|
|
1513
1014
|
}
|
|
1514
1015
|
const authorizedDevices = this._authorizedDevices.get(spaceKey);
|
|
1515
1016
|
if (!connection.remoteDeviceKey) {
|
|
1516
|
-
|
|
1017
|
+
log4("device key not found for share policy check", {
|
|
1517
1018
|
peerId: connection.peerId,
|
|
1518
1019
|
documentId: params.documentId
|
|
1519
1020
|
}, {
|
|
1520
|
-
F:
|
|
1521
|
-
L:
|
|
1021
|
+
F: __dxlog_file4,
|
|
1022
|
+
L: 94,
|
|
1522
1023
|
S: this,
|
|
1523
1024
|
C: (f, a) => f(...a)
|
|
1524
1025
|
});
|
|
1525
1026
|
return false;
|
|
1526
1027
|
}
|
|
1527
1028
|
const isAuthorized = authorizedDevices?.has(connection.remoteDeviceKey) ?? false;
|
|
1528
|
-
|
|
1029
|
+
log4("share policy check", {
|
|
1529
1030
|
localPeer: this._context.peerId,
|
|
1530
1031
|
remotePeer: connection.peerId,
|
|
1531
1032
|
documentId: params.documentId,
|
|
@@ -1533,16 +1034,16 @@ var MeshEchoReplicator = class {
|
|
|
1533
1034
|
spaceKey,
|
|
1534
1035
|
isAuthorized
|
|
1535
1036
|
}, {
|
|
1536
|
-
F:
|
|
1537
|
-
L:
|
|
1037
|
+
F: __dxlog_file4,
|
|
1038
|
+
L: 102,
|
|
1538
1039
|
S: this,
|
|
1539
1040
|
C: (f, a) => f(...a)
|
|
1540
1041
|
});
|
|
1541
1042
|
return isAuthorized;
|
|
1542
1043
|
} catch (err) {
|
|
1543
|
-
|
|
1544
|
-
F:
|
|
1545
|
-
L:
|
|
1044
|
+
log4.catch(err, void 0, {
|
|
1045
|
+
F: __dxlog_file4,
|
|
1046
|
+
L: 112,
|
|
1546
1047
|
S: this,
|
|
1547
1048
|
C: (f, a) => f(...a)
|
|
1548
1049
|
});
|
|
@@ -1554,12 +1055,12 @@ var MeshEchoReplicator = class {
|
|
|
1554
1055
|
return connection.replicatorExtension;
|
|
1555
1056
|
}
|
|
1556
1057
|
authorizeDevice(spaceKey, deviceKey) {
|
|
1557
|
-
|
|
1058
|
+
log4("authorizeDevice", {
|
|
1558
1059
|
spaceKey,
|
|
1559
1060
|
deviceKey
|
|
1560
1061
|
}, {
|
|
1561
|
-
F:
|
|
1562
|
-
L:
|
|
1062
|
+
F: __dxlog_file4,
|
|
1063
|
+
L: 123,
|
|
1563
1064
|
S: this,
|
|
1564
1065
|
C: (f, a) => f(...a)
|
|
1565
1066
|
});
|
|
@@ -1576,13 +1077,12 @@ var MeshEchoReplicator = class {
|
|
|
1576
1077
|
export {
|
|
1577
1078
|
AuthExtension,
|
|
1578
1079
|
AuthStatus,
|
|
1579
|
-
AutomergeDocumentLoaderImpl,
|
|
1580
1080
|
AutomergeHost,
|
|
1581
1081
|
CredentialRetrieverExtension,
|
|
1582
1082
|
CredentialServerExtension,
|
|
1583
1083
|
DataServiceImpl,
|
|
1084
|
+
DocumentsSynchronizer,
|
|
1584
1085
|
LevelDBStorageAdapter,
|
|
1585
|
-
LocalHostNetworkAdapter,
|
|
1586
1086
|
MOCK_AUTH_PROVIDER,
|
|
1587
1087
|
MOCK_AUTH_VERIFIER,
|
|
1588
1088
|
MeshEchoReplicator,
|