@dxos/echo-pipeline 0.5.9-main.e183eeb → 0.5.9-main.e9b9049
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 +39 -44
- 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 +71 -76
- 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-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-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",
|
|
@@ -817,7 +805,7 @@ import { cancelWithContext } from "@dxos/context";
|
|
|
817
805
|
import { warnAfterTimeout } from "@dxos/debug";
|
|
818
806
|
import { SpaceDocVersion } from "@dxos/echo-protocol";
|
|
819
807
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
820
|
-
import { log as
|
|
808
|
+
import { log as log2 } from "@dxos/log";
|
|
821
809
|
import { trace as trace2 } from "@dxos/tracing";
|
|
822
810
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
823
811
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -851,7 +839,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
851
839
|
return;
|
|
852
840
|
}
|
|
853
841
|
if (!spaceState.rootUrl) {
|
|
854
|
-
|
|
842
|
+
log2.error("Database opened with no rootUrl", {
|
|
855
843
|
spaceId: this._spaceId
|
|
856
844
|
}, {
|
|
857
845
|
F: __dxlog_file4,
|
|
@@ -910,7 +898,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
910
898
|
const documentUrl = (spaceRootDoc.links ?? {})[objectId];
|
|
911
899
|
if (documentUrl == null) {
|
|
912
900
|
this._objectsPendingDocumentLoad.add(objectId);
|
|
913
|
-
|
|
901
|
+
log2.info("loading delayed until object links are initialized", {
|
|
914
902
|
objectId
|
|
915
903
|
}, {
|
|
916
904
|
F: __dxlog_file4,
|
|
@@ -990,7 +978,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
990
978
|
};
|
|
991
979
|
const objectDocumentHandle = this._objectDocumentHandles.get(objectId);
|
|
992
980
|
if (objectDocumentHandle != null && objectDocumentHandle.url !== automergeUrl) {
|
|
993
|
-
|
|
981
|
+
log2.warn("object already inlined in a different document, ignoring the link", {
|
|
994
982
|
...logMeta,
|
|
995
983
|
actualDocumentUrl: objectDocumentHandle.url
|
|
996
984
|
}, {
|
|
@@ -1002,7 +990,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1002
990
|
continue;
|
|
1003
991
|
}
|
|
1004
992
|
if (objectDocumentHandle?.url === automergeUrl) {
|
|
1005
|
-
|
|
993
|
+
log2.warn("object document was already loaded", logMeta, {
|
|
1006
994
|
F: __dxlog_file4,
|
|
1007
995
|
L: 166,
|
|
1008
996
|
S: this,
|
|
@@ -1011,7 +999,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1011
999
|
continue;
|
|
1012
1000
|
}
|
|
1013
1001
|
const handle = this._repo.find(automergeUrl);
|
|
1014
|
-
|
|
1002
|
+
log2.debug("document loading triggered", logMeta, {
|
|
1015
1003
|
F: __dxlog_file4,
|
|
1016
1004
|
L: 170,
|
|
1017
1005
|
S: this,
|
|
@@ -1031,7 +1019,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1031
1019
|
break;
|
|
1032
1020
|
} catch (err) {
|
|
1033
1021
|
if (`${err}`.includes("Timeout")) {
|
|
1034
|
-
|
|
1022
|
+
log2.info("wraparound", {
|
|
1035
1023
|
id: docHandle.documentId,
|
|
1036
1024
|
state: docHandle.state
|
|
1037
1025
|
}, {
|
|
@@ -1076,7 +1064,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1076
1064
|
docUrl: handle.url
|
|
1077
1065
|
};
|
|
1078
1066
|
if (this.onObjectDocumentLoaded.listenerCount() === 0) {
|
|
1079
|
-
|
|
1067
|
+
log2.info("document loaded after all listeners were removed", logMeta, {
|
|
1080
1068
|
F: __dxlog_file4,
|
|
1081
1069
|
L: 222,
|
|
1082
1070
|
S: this,
|
|
@@ -1086,7 +1074,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1086
1074
|
}
|
|
1087
1075
|
const objectDocHandle = this._objectDocumentHandles.get(objectId);
|
|
1088
1076
|
if (objectDocHandle?.url !== handle.url) {
|
|
1089
|
-
|
|
1077
|
+
log2.warn("object was rebound while a document was loading, discarding handle", logMeta, {
|
|
1090
1078
|
F: __dxlog_file4,
|
|
1091
1079
|
L: 227,
|
|
1092
1080
|
S: this,
|
|
@@ -1100,7 +1088,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1100
1088
|
});
|
|
1101
1089
|
} catch (err) {
|
|
1102
1090
|
const shouldRetryLoading = this.onObjectDocumentLoaded.listenerCount() > 0;
|
|
1103
|
-
|
|
1091
|
+
log2.warn("failed to load a document", {
|
|
1104
1092
|
objectId,
|
|
1105
1093
|
automergeUrl: handle.url,
|
|
1106
1094
|
retryLoading: shouldRetryLoading,
|
|
@@ -1131,7 +1119,7 @@ import { cbor as cbor2 } from "@dxos/automerge/automerge-repo";
|
|
|
1131
1119
|
import { Resource as Resource2 } from "@dxos/context";
|
|
1132
1120
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1133
1121
|
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
1134
|
-
import { log as
|
|
1122
|
+
import { log as log3 } from "@dxos/log";
|
|
1135
1123
|
import { AutomergeReplicator } from "@dxos/teleport-extension-automerge-replicator";
|
|
1136
1124
|
import { ComplexMap, ComplexSet, defaultMap } from "@dxos/util";
|
|
1137
1125
|
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator.ts";
|
|
@@ -1172,7 +1160,7 @@ var MeshEchoReplicator = class {
|
|
|
1172
1160
|
const connection = new MeshReplicatorConnection({
|
|
1173
1161
|
ownPeerId: this._context.peerId,
|
|
1174
1162
|
onRemoteConnected: async () => {
|
|
1175
|
-
|
|
1163
|
+
log3("onRemoteConnected", {
|
|
1176
1164
|
peerId: connection.peerId
|
|
1177
1165
|
}, {
|
|
1178
1166
|
F: __dxlog_file5,
|
|
@@ -1198,7 +1186,7 @@ var MeshEchoReplicator = class {
|
|
|
1198
1186
|
}
|
|
1199
1187
|
},
|
|
1200
1188
|
onRemoteDisconnected: async () => {
|
|
1201
|
-
|
|
1189
|
+
log3("onRemoteDisconnected", {
|
|
1202
1190
|
peerId: connection.peerId
|
|
1203
1191
|
}, {
|
|
1204
1192
|
F: __dxlog_file5,
|
|
@@ -1207,12 +1195,12 @@ var MeshEchoReplicator = class {
|
|
|
1207
1195
|
C: (f, a) => f(...a)
|
|
1208
1196
|
});
|
|
1209
1197
|
this._context?.onConnectionClosed(connection);
|
|
1210
|
-
await connection.disable();
|
|
1211
1198
|
this._connectionsPerPeer.delete(connection.peerId);
|
|
1199
|
+
await connection.disable();
|
|
1212
1200
|
this._connections.delete(connection);
|
|
1213
1201
|
},
|
|
1214
1202
|
shouldAdvertize: async (params) => {
|
|
1215
|
-
|
|
1203
|
+
log3("shouldAdvertize", {
|
|
1216
1204
|
peerId: connection.peerId,
|
|
1217
1205
|
documentId: params.documentId
|
|
1218
1206
|
}, {
|
|
@@ -1233,7 +1221,7 @@ var MeshEchoReplicator = class {
|
|
|
1233
1221
|
try {
|
|
1234
1222
|
const spaceKey = await this._context.getContainingSpaceForDocument(params.documentId);
|
|
1235
1223
|
if (!spaceKey) {
|
|
1236
|
-
|
|
1224
|
+
log3("space key not found for share policy check", {
|
|
1237
1225
|
peerId: connection.peerId,
|
|
1238
1226
|
documentId: params.documentId
|
|
1239
1227
|
}, {
|
|
@@ -1246,7 +1234,7 @@ var MeshEchoReplicator = class {
|
|
|
1246
1234
|
}
|
|
1247
1235
|
const authorizedDevices = this._authorizedDevices.get(spaceKey);
|
|
1248
1236
|
if (!connection.remoteDeviceKey) {
|
|
1249
|
-
|
|
1237
|
+
log3("device key not found for share policy check", {
|
|
1250
1238
|
peerId: connection.peerId,
|
|
1251
1239
|
documentId: params.documentId
|
|
1252
1240
|
}, {
|
|
@@ -1258,7 +1246,7 @@ var MeshEchoReplicator = class {
|
|
|
1258
1246
|
return false;
|
|
1259
1247
|
}
|
|
1260
1248
|
const isAuthorized = authorizedDevices?.has(connection.remoteDeviceKey) ?? false;
|
|
1261
|
-
|
|
1249
|
+
log3("share policy check", {
|
|
1262
1250
|
localPeer: this._context.peerId,
|
|
1263
1251
|
remotePeer: connection.peerId,
|
|
1264
1252
|
documentId: params.documentId,
|
|
@@ -1273,7 +1261,7 @@ var MeshEchoReplicator = class {
|
|
|
1273
1261
|
});
|
|
1274
1262
|
return isAuthorized;
|
|
1275
1263
|
} catch (err) {
|
|
1276
|
-
|
|
1264
|
+
log3.catch(err, void 0, {
|
|
1277
1265
|
F: __dxlog_file5,
|
|
1278
1266
|
L: 111,
|
|
1279
1267
|
S: this,
|
|
@@ -1287,7 +1275,7 @@ var MeshEchoReplicator = class {
|
|
|
1287
1275
|
return connection.replicatorExtension;
|
|
1288
1276
|
}
|
|
1289
1277
|
authorizeDevice(spaceKey, deviceKey) {
|
|
1290
|
-
|
|
1278
|
+
log3("authorizeDevice", {
|
|
1291
1279
|
spaceKey,
|
|
1292
1280
|
deviceKey
|
|
1293
1281
|
}, {
|
|
@@ -1297,6 +1285,11 @@ var MeshEchoReplicator = class {
|
|
|
1297
1285
|
C: (f, a) => f(...a)
|
|
1298
1286
|
});
|
|
1299
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
|
+
}
|
|
1300
1293
|
}
|
|
1301
1294
|
};
|
|
1302
1295
|
var MeshReplicatorConnection = class extends Resource2 {
|
|
@@ -1328,13 +1321,13 @@ var MeshReplicatorConnection = class extends Resource2 {
|
|
|
1328
1321
|
onStartReplication: async (info, remotePeerId) => {
|
|
1329
1322
|
this.remoteDeviceKey = remotePeerId;
|
|
1330
1323
|
this._remotePeerId = info.id;
|
|
1331
|
-
|
|
1324
|
+
log3("onStartReplication", {
|
|
1332
1325
|
id: info.id,
|
|
1333
1326
|
thisPeerId: this.peerId,
|
|
1334
1327
|
remotePeerId: remotePeerId.toHex()
|
|
1335
1328
|
}, {
|
|
1336
1329
|
F: __dxlog_file5,
|
|
1337
|
-
L:
|
|
1330
|
+
L: 192,
|
|
1338
1331
|
S: this,
|
|
1339
1332
|
C: (f, a) => f(...a)
|
|
1340
1333
|
});
|
|
@@ -1358,7 +1351,7 @@ var MeshReplicatorConnection = class extends Resource2 {
|
|
|
1358
1351
|
get peerId() {
|
|
1359
1352
|
invariant5(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1360
1353
|
F: __dxlog_file5,
|
|
1361
|
-
L:
|
|
1354
|
+
L: 215,
|
|
1362
1355
|
S: this,
|
|
1363
1356
|
A: [
|
|
1364
1357
|
"this._remotePeerId != null",
|
|
@@ -1377,7 +1370,7 @@ var MeshReplicatorConnection = class extends Resource2 {
|
|
|
1377
1370
|
async enable() {
|
|
1378
1371
|
invariant5(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1379
1372
|
F: __dxlog_file5,
|
|
1380
|
-
L:
|
|
1373
|
+
L: 228,
|
|
1381
1374
|
S: this,
|
|
1382
1375
|
A: [
|
|
1383
1376
|
"this._remotePeerId != null",
|
|
@@ -1398,6 +1391,8 @@ export {
|
|
|
1398
1391
|
AuthStatus,
|
|
1399
1392
|
AutomergeDocumentLoaderImpl,
|
|
1400
1393
|
AutomergeHost,
|
|
1394
|
+
CredentialRetrieverExtension,
|
|
1395
|
+
CredentialServerExtension,
|
|
1401
1396
|
DataServiceImpl,
|
|
1402
1397
|
LevelDBStorageAdapter,
|
|
1403
1398
|
LocalHostNetworkAdapter,
|