@dxos/echo-pipeline 0.5.9-main.1c1903d → 0.5.9-main.1cc8373
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-I2J5TTHJ.mjs → chunk-HS77A4I4.mjs} +174 -23
- package/dist/lib/browser/{chunk-I2J5TTHJ.mjs.map → chunk-HS77A4I4.mjs.map} +4 -4
- package/dist/lib/browser/index.mjs +50 -52
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +11 -7
- package/dist/lib/browser/testing/index.mjs.map +1 -1
- package/dist/lib/node/{chunk-QPCNQ4ZK.cjs → chunk-Y5U7UXEL.cjs} +185 -34
- package/dist/lib/node/{chunk-QPCNQ4ZK.cjs.map → chunk-Y5U7UXEL.cjs.map} +4 -4
- package/dist/lib/node/index.cjs +82 -84
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +21 -17
- package/dist/lib/node/testing/index.cjs.map +1 -1
- package/dist/types/src/automerge/automerge-doc-loader.d.ts.map +1 -1
- package/dist/types/src/automerge/automerge-host.d.ts +0 -1
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/mesh-echo-replicator.d.ts.map +1 -1
- package/dist/types/src/space/admission-discovery-extension.d.ts +30 -0
- package/dist/types/src/space/admission-discovery-extension.d.ts.map +1 -0
- package/dist/types/src/space/index.d.ts +1 -0
- package/dist/types/src/space/index.d.ts.map +1 -1
- package/dist/types/src/space/space-manager.d.ts +8 -0
- package/dist/types/src/space/space-manager.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/automerge/automerge-doc-loader.test.ts +2 -3
- package/src/automerge/automerge-doc-loader.ts +4 -2
- package/src/automerge/automerge-host.ts +0 -14
- package/src/automerge/mesh-echo-replicator.ts +6 -1
- package/src/space/admission-discovery-extension.ts +90 -0
- package/src/space/index.ts +1 -0
- 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,7 +25,7 @@ import {
|
|
|
23
25
|
mapTimeframeToFeedIndexes,
|
|
24
26
|
startAfter,
|
|
25
27
|
valueEncoding
|
|
26
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-HS77A4I4.mjs";
|
|
27
29
|
|
|
28
30
|
// packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts
|
|
29
31
|
import { Event } from "@dxos/async";
|
|
@@ -32,7 +34,6 @@ import { Repo } from "@dxos/automerge/automerge-repo";
|
|
|
32
34
|
import { Context } from "@dxos/context";
|
|
33
35
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
34
36
|
import { PublicKey } from "@dxos/keys";
|
|
35
|
-
import { log as log2 } from "@dxos/log";
|
|
36
37
|
import { objectPointerCodec } from "@dxos/protocols";
|
|
37
38
|
import { trace } from "@dxos/tracing";
|
|
38
39
|
import { mapValues } from "@dxos/util";
|
|
@@ -587,11 +588,13 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
587
588
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
|
|
588
589
|
var AutomergeHost = class {
|
|
589
590
|
constructor({ db, indexMetadataStore }) {
|
|
590
|
-
this._ctx = new Context(
|
|
591
|
+
this._ctx = new Context(void 0, {
|
|
592
|
+
F: __dxlog_file3,
|
|
593
|
+
L: 49
|
|
594
|
+
});
|
|
591
595
|
this._echoNetworkAdapter = new EchoNetworkAdapter({
|
|
592
596
|
getContainingSpaceForDocument: this._getContainingSpaceForDocument.bind(this)
|
|
593
597
|
});
|
|
594
|
-
this._requestedDocs = /* @__PURE__ */ new Set();
|
|
595
598
|
this._storage = new LevelDBStorageAdapter({
|
|
596
599
|
db,
|
|
597
600
|
callbacks: {
|
|
@@ -647,21 +650,6 @@ var AutomergeHost = class {
|
|
|
647
650
|
if (!documentId) {
|
|
648
651
|
return false;
|
|
649
652
|
}
|
|
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
653
|
const peerMetadata = this.repo.peerMetadataByPeerId[peerId];
|
|
666
654
|
if (peerMetadata?.dxos_peerSource === "EchoNetworkAdapter") {
|
|
667
655
|
return this._echoNetworkAdapter.shouldAdvertize(peerId, {
|
|
@@ -742,7 +730,7 @@ var AutomergeHost = class {
|
|
|
742
730
|
await Promise.all(states?.map(async ({ heads, documentId }) => {
|
|
743
731
|
invariant3(heads, "heads are required for flush", {
|
|
744
732
|
F: __dxlog_file3,
|
|
745
|
-
L:
|
|
733
|
+
L: 223,
|
|
746
734
|
S: this,
|
|
747
735
|
A: [
|
|
748
736
|
"heads",
|
|
@@ -815,8 +803,9 @@ var changeIsPresentInDoc = (doc, changeHash) => {
|
|
|
815
803
|
import { Event as Event2 } from "@dxos/async";
|
|
816
804
|
import { cancelWithContext } from "@dxos/context";
|
|
817
805
|
import { warnAfterTimeout } from "@dxos/debug";
|
|
806
|
+
import { SpaceDocVersion } from "@dxos/echo-protocol";
|
|
818
807
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
819
|
-
import { log as
|
|
808
|
+
import { log as log2 } from "@dxos/log";
|
|
820
809
|
import { trace as trace2 } from "@dxos/tracing";
|
|
821
810
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
822
811
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -850,7 +839,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
850
839
|
return;
|
|
851
840
|
}
|
|
852
841
|
if (!spaceState.rootUrl) {
|
|
853
|
-
|
|
842
|
+
log2.error("Database opened with no rootUrl", {
|
|
854
843
|
spaceId: this._spaceId
|
|
855
844
|
}, {
|
|
856
845
|
F: __dxlog_file4,
|
|
@@ -909,7 +898,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
909
898
|
const documentUrl = (spaceRootDoc.links ?? {})[objectId];
|
|
910
899
|
if (documentUrl == null) {
|
|
911
900
|
this._objectsPendingDocumentLoad.add(objectId);
|
|
912
|
-
|
|
901
|
+
log2.info("loading delayed until object links are initialized", {
|
|
913
902
|
objectId
|
|
914
903
|
}, {
|
|
915
904
|
F: __dxlog_file4,
|
|
@@ -956,7 +945,9 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
956
945
|
""
|
|
957
946
|
]
|
|
958
947
|
});
|
|
959
|
-
const spaceDocHandle = this._repo.create(
|
|
948
|
+
const spaceDocHandle = this._repo.create({
|
|
949
|
+
version: SpaceDocVersion.CURRENT
|
|
950
|
+
});
|
|
960
951
|
this._initDocAccess(spaceDocHandle);
|
|
961
952
|
this.onObjectBoundToDocument(spaceDocHandle, objectId);
|
|
962
953
|
this._spaceRootDocHandle.change((newDoc) => {
|
|
@@ -987,30 +978,30 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
987
978
|
};
|
|
988
979
|
const objectDocumentHandle = this._objectDocumentHandles.get(objectId);
|
|
989
980
|
if (objectDocumentHandle != null && objectDocumentHandle.url !== automergeUrl) {
|
|
990
|
-
|
|
981
|
+
log2.warn("object already inlined in a different document, ignoring the link", {
|
|
991
982
|
...logMeta,
|
|
992
983
|
actualDocumentUrl: objectDocumentHandle.url
|
|
993
984
|
}, {
|
|
994
985
|
F: __dxlog_file4,
|
|
995
|
-
L:
|
|
986
|
+
L: 159,
|
|
996
987
|
S: this,
|
|
997
988
|
C: (f, a) => f(...a)
|
|
998
989
|
});
|
|
999
990
|
continue;
|
|
1000
991
|
}
|
|
1001
992
|
if (objectDocumentHandle?.url === automergeUrl) {
|
|
1002
|
-
|
|
993
|
+
log2.warn("object document was already loaded", logMeta, {
|
|
1003
994
|
F: __dxlog_file4,
|
|
1004
|
-
L:
|
|
995
|
+
L: 166,
|
|
1005
996
|
S: this,
|
|
1006
997
|
C: (f, a) => f(...a)
|
|
1007
998
|
});
|
|
1008
999
|
continue;
|
|
1009
1000
|
}
|
|
1010
1001
|
const handle = this._repo.find(automergeUrl);
|
|
1011
|
-
|
|
1002
|
+
log2.debug("document loading triggered", logMeta, {
|
|
1012
1003
|
F: __dxlog_file4,
|
|
1013
|
-
L:
|
|
1004
|
+
L: 170,
|
|
1014
1005
|
S: this,
|
|
1015
1006
|
C: (f, a) => f(...a)
|
|
1016
1007
|
});
|
|
@@ -1028,12 +1019,12 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1028
1019
|
break;
|
|
1029
1020
|
} catch (err) {
|
|
1030
1021
|
if (`${err}`.includes("Timeout")) {
|
|
1031
|
-
|
|
1022
|
+
log2.info("wraparound", {
|
|
1032
1023
|
id: docHandle.documentId,
|
|
1033
1024
|
state: docHandle.state
|
|
1034
1025
|
}, {
|
|
1035
1026
|
F: __dxlog_file4,
|
|
1036
|
-
L:
|
|
1027
|
+
L: 186,
|
|
1037
1028
|
S: this,
|
|
1038
1029
|
C: (f, a) => f(...a)
|
|
1039
1030
|
});
|
|
@@ -1073,9 +1064,9 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1073
1064
|
docUrl: handle.url
|
|
1074
1065
|
};
|
|
1075
1066
|
if (this.onObjectDocumentLoaded.listenerCount() === 0) {
|
|
1076
|
-
|
|
1067
|
+
log2.info("document loaded after all listeners were removed", logMeta, {
|
|
1077
1068
|
F: __dxlog_file4,
|
|
1078
|
-
L:
|
|
1069
|
+
L: 222,
|
|
1079
1070
|
S: this,
|
|
1080
1071
|
C: (f, a) => f(...a)
|
|
1081
1072
|
});
|
|
@@ -1083,9 +1074,9 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1083
1074
|
}
|
|
1084
1075
|
const objectDocHandle = this._objectDocumentHandles.get(objectId);
|
|
1085
1076
|
if (objectDocHandle?.url !== handle.url) {
|
|
1086
|
-
|
|
1077
|
+
log2.warn("object was rebound while a document was loading, discarding handle", logMeta, {
|
|
1087
1078
|
F: __dxlog_file4,
|
|
1088
|
-
L:
|
|
1079
|
+
L: 227,
|
|
1089
1080
|
S: this,
|
|
1090
1081
|
C: (f, a) => f(...a)
|
|
1091
1082
|
});
|
|
@@ -1097,14 +1088,14 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1097
1088
|
});
|
|
1098
1089
|
} catch (err) {
|
|
1099
1090
|
const shouldRetryLoading = this.onObjectDocumentLoaded.listenerCount() > 0;
|
|
1100
|
-
|
|
1091
|
+
log2.warn("failed to load a document", {
|
|
1101
1092
|
objectId,
|
|
1102
1093
|
automergeUrl: handle.url,
|
|
1103
1094
|
retryLoading: shouldRetryLoading,
|
|
1104
1095
|
err
|
|
1105
1096
|
}, {
|
|
1106
1097
|
F: __dxlog_file4,
|
|
1107
|
-
L:
|
|
1098
|
+
L: 233,
|
|
1108
1099
|
S: this,
|
|
1109
1100
|
C: (f, a) => f(...a)
|
|
1110
1101
|
});
|
|
@@ -1128,7 +1119,7 @@ import { cbor as cbor2 } from "@dxos/automerge/automerge-repo";
|
|
|
1128
1119
|
import { Resource as Resource2 } from "@dxos/context";
|
|
1129
1120
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1130
1121
|
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
1131
|
-
import { log as
|
|
1122
|
+
import { log as log3 } from "@dxos/log";
|
|
1132
1123
|
import { AutomergeReplicator } from "@dxos/teleport-extension-automerge-replicator";
|
|
1133
1124
|
import { ComplexMap, ComplexSet, defaultMap } from "@dxos/util";
|
|
1134
1125
|
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator.ts";
|
|
@@ -1169,7 +1160,7 @@ var MeshEchoReplicator = class {
|
|
|
1169
1160
|
const connection = new MeshReplicatorConnection({
|
|
1170
1161
|
ownPeerId: this._context.peerId,
|
|
1171
1162
|
onRemoteConnected: async () => {
|
|
1172
|
-
|
|
1163
|
+
log3("onRemoteConnected", {
|
|
1173
1164
|
peerId: connection.peerId
|
|
1174
1165
|
}, {
|
|
1175
1166
|
F: __dxlog_file5,
|
|
@@ -1195,7 +1186,7 @@ var MeshEchoReplicator = class {
|
|
|
1195
1186
|
}
|
|
1196
1187
|
},
|
|
1197
1188
|
onRemoteDisconnected: async () => {
|
|
1198
|
-
|
|
1189
|
+
log3("onRemoteDisconnected", {
|
|
1199
1190
|
peerId: connection.peerId
|
|
1200
1191
|
}, {
|
|
1201
1192
|
F: __dxlog_file5,
|
|
@@ -1204,12 +1195,12 @@ var MeshEchoReplicator = class {
|
|
|
1204
1195
|
C: (f, a) => f(...a)
|
|
1205
1196
|
});
|
|
1206
1197
|
this._context?.onConnectionClosed(connection);
|
|
1207
|
-
await connection.disable();
|
|
1208
1198
|
this._connectionsPerPeer.delete(connection.peerId);
|
|
1199
|
+
await connection.disable();
|
|
1209
1200
|
this._connections.delete(connection);
|
|
1210
1201
|
},
|
|
1211
1202
|
shouldAdvertize: async (params) => {
|
|
1212
|
-
|
|
1203
|
+
log3("shouldAdvertize", {
|
|
1213
1204
|
peerId: connection.peerId,
|
|
1214
1205
|
documentId: params.documentId
|
|
1215
1206
|
}, {
|
|
@@ -1230,7 +1221,7 @@ var MeshEchoReplicator = class {
|
|
|
1230
1221
|
try {
|
|
1231
1222
|
const spaceKey = await this._context.getContainingSpaceForDocument(params.documentId);
|
|
1232
1223
|
if (!spaceKey) {
|
|
1233
|
-
|
|
1224
|
+
log3("space key not found for share policy check", {
|
|
1234
1225
|
peerId: connection.peerId,
|
|
1235
1226
|
documentId: params.documentId
|
|
1236
1227
|
}, {
|
|
@@ -1243,7 +1234,7 @@ var MeshEchoReplicator = class {
|
|
|
1243
1234
|
}
|
|
1244
1235
|
const authorizedDevices = this._authorizedDevices.get(spaceKey);
|
|
1245
1236
|
if (!connection.remoteDeviceKey) {
|
|
1246
|
-
|
|
1237
|
+
log3("device key not found for share policy check", {
|
|
1247
1238
|
peerId: connection.peerId,
|
|
1248
1239
|
documentId: params.documentId
|
|
1249
1240
|
}, {
|
|
@@ -1255,7 +1246,7 @@ var MeshEchoReplicator = class {
|
|
|
1255
1246
|
return false;
|
|
1256
1247
|
}
|
|
1257
1248
|
const isAuthorized = authorizedDevices?.has(connection.remoteDeviceKey) ?? false;
|
|
1258
|
-
|
|
1249
|
+
log3("share policy check", {
|
|
1259
1250
|
localPeer: this._context.peerId,
|
|
1260
1251
|
remotePeer: connection.peerId,
|
|
1261
1252
|
documentId: params.documentId,
|
|
@@ -1270,7 +1261,7 @@ var MeshEchoReplicator = class {
|
|
|
1270
1261
|
});
|
|
1271
1262
|
return isAuthorized;
|
|
1272
1263
|
} catch (err) {
|
|
1273
|
-
|
|
1264
|
+
log3.catch(err, void 0, {
|
|
1274
1265
|
F: __dxlog_file5,
|
|
1275
1266
|
L: 111,
|
|
1276
1267
|
S: this,
|
|
@@ -1284,7 +1275,7 @@ var MeshEchoReplicator = class {
|
|
|
1284
1275
|
return connection.replicatorExtension;
|
|
1285
1276
|
}
|
|
1286
1277
|
authorizeDevice(spaceKey, deviceKey) {
|
|
1287
|
-
|
|
1278
|
+
log3("authorizeDevice", {
|
|
1288
1279
|
spaceKey,
|
|
1289
1280
|
deviceKey
|
|
1290
1281
|
}, {
|
|
@@ -1294,6 +1285,11 @@ var MeshEchoReplicator = class {
|
|
|
1294
1285
|
C: (f, a) => f(...a)
|
|
1295
1286
|
});
|
|
1296
1287
|
defaultMap(this._authorizedDevices, spaceKey, () => new ComplexSet(PublicKey2.hash)).add(deviceKey);
|
|
1288
|
+
for (const connection of this._connections) {
|
|
1289
|
+
if (connection.remoteDeviceKey && connection.remoteDeviceKey.equals(deviceKey)) {
|
|
1290
|
+
this._context?.onConnectionAuthScopeChanged(connection);
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1297
1293
|
}
|
|
1298
1294
|
};
|
|
1299
1295
|
var MeshReplicatorConnection = class extends Resource2 {
|
|
@@ -1325,13 +1321,13 @@ var MeshReplicatorConnection = class extends Resource2 {
|
|
|
1325
1321
|
onStartReplication: async (info, remotePeerId) => {
|
|
1326
1322
|
this.remoteDeviceKey = remotePeerId;
|
|
1327
1323
|
this._remotePeerId = info.id;
|
|
1328
|
-
|
|
1324
|
+
log3("onStartReplication", {
|
|
1329
1325
|
id: info.id,
|
|
1330
1326
|
thisPeerId: this.peerId,
|
|
1331
1327
|
remotePeerId: remotePeerId.toHex()
|
|
1332
1328
|
}, {
|
|
1333
1329
|
F: __dxlog_file5,
|
|
1334
|
-
L:
|
|
1330
|
+
L: 192,
|
|
1335
1331
|
S: this,
|
|
1336
1332
|
C: (f, a) => f(...a)
|
|
1337
1333
|
});
|
|
@@ -1355,7 +1351,7 @@ var MeshReplicatorConnection = class extends Resource2 {
|
|
|
1355
1351
|
get peerId() {
|
|
1356
1352
|
invariant5(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1357
1353
|
F: __dxlog_file5,
|
|
1358
|
-
L:
|
|
1354
|
+
L: 215,
|
|
1359
1355
|
S: this,
|
|
1360
1356
|
A: [
|
|
1361
1357
|
"this._remotePeerId != null",
|
|
@@ -1374,7 +1370,7 @@ var MeshReplicatorConnection = class extends Resource2 {
|
|
|
1374
1370
|
async enable() {
|
|
1375
1371
|
invariant5(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1376
1372
|
F: __dxlog_file5,
|
|
1377
|
-
L:
|
|
1373
|
+
L: 228,
|
|
1378
1374
|
S: this,
|
|
1379
1375
|
A: [
|
|
1380
1376
|
"this._remotePeerId != null",
|
|
@@ -1395,6 +1391,8 @@ export {
|
|
|
1395
1391
|
AuthStatus,
|
|
1396
1392
|
AutomergeDocumentLoaderImpl,
|
|
1397
1393
|
AutomergeHost,
|
|
1394
|
+
CredentialRetrieverExtension,
|
|
1395
|
+
CredentialServerExtension,
|
|
1398
1396
|
DataServiceImpl,
|
|
1399
1397
|
LevelDBStorageAdapter,
|
|
1400
1398
|
LocalHostNetworkAdapter,
|