@dxos/echo-pipeline 0.5.9-main.bf0ae3e → 0.5.9-main.bf3bb8f
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 +186 -127
- 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 +234 -175
- 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 +2 -1
- package/dist/types/src/automerge/automerge-doc-loader.d.ts.map +1 -1
- package/dist/types/src/automerge/automerge-host.d.ts +40 -3
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-network-adapter.d.ts +2 -0
- package/dist/types/src/automerge/echo-network-adapter.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 +8 -5
- package/src/automerge/automerge-doc-loader.ts +33 -22
- package/src/automerge/automerge-host.ts +96 -32
- package/src/automerge/echo-network-adapter.ts +10 -4
- package/src/automerge/mesh-echo-replicator.ts +7 -2
- package/src/space/admission-discovery-extension.ts +90 -0
- package/src/space/index.ts +1 -0
- package/src/space/space-manager.ts +46 -1
package/dist/lib/node/index.cjs
CHANGED
|
@@ -18,69 +18,71 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var node_exports = {};
|
|
20
20
|
__export(node_exports, {
|
|
21
|
-
AuthExtension: () =>
|
|
22
|
-
AuthStatus: () =>
|
|
21
|
+
AuthExtension: () => import_chunk_Y5U7UXEL.AuthExtension,
|
|
22
|
+
AuthStatus: () => import_chunk_Y5U7UXEL.AuthStatus,
|
|
23
23
|
AutomergeDocumentLoaderImpl: () => AutomergeDocumentLoaderImpl,
|
|
24
24
|
AutomergeHost: () => AutomergeHost,
|
|
25
|
-
|
|
25
|
+
CredentialRetrieverExtension: () => import_chunk_Y5U7UXEL.CredentialRetrieverExtension,
|
|
26
|
+
CredentialServerExtension: () => import_chunk_Y5U7UXEL.CredentialServerExtension,
|
|
27
|
+
DataServiceImpl: () => import_chunk_Y5U7UXEL.DataServiceImpl,
|
|
26
28
|
LevelDBStorageAdapter: () => LevelDBStorageAdapter,
|
|
27
29
|
LocalHostNetworkAdapter: () => LocalHostNetworkAdapter,
|
|
28
|
-
MOCK_AUTH_PROVIDER: () =>
|
|
29
|
-
MOCK_AUTH_VERIFIER: () =>
|
|
30
|
+
MOCK_AUTH_PROVIDER: () => import_chunk_Y5U7UXEL.MOCK_AUTH_PROVIDER,
|
|
31
|
+
MOCK_AUTH_VERIFIER: () => import_chunk_Y5U7UXEL.MOCK_AUTH_VERIFIER,
|
|
30
32
|
MeshEchoReplicator: () => MeshEchoReplicator,
|
|
31
|
-
MetadataStore: () =>
|
|
32
|
-
Pipeline: () =>
|
|
33
|
-
SnapshotManager: () =>
|
|
34
|
-
SnapshotStore: () =>
|
|
35
|
-
Space: () =>
|
|
36
|
-
SpaceManager: () =>
|
|
37
|
-
SpaceProtocol: () =>
|
|
38
|
-
SpaceProtocolSession: () =>
|
|
39
|
-
TimeframeClock: () =>
|
|
40
|
-
codec: () =>
|
|
41
|
-
createIdFromSpaceKey: () =>
|
|
42
|
-
createMappedFeedWriter: () =>
|
|
33
|
+
MetadataStore: () => import_chunk_Y5U7UXEL.MetadataStore,
|
|
34
|
+
Pipeline: () => import_chunk_Y5U7UXEL.Pipeline,
|
|
35
|
+
SnapshotManager: () => import_chunk_Y5U7UXEL.SnapshotManager,
|
|
36
|
+
SnapshotStore: () => import_chunk_Y5U7UXEL.SnapshotStore,
|
|
37
|
+
Space: () => import_chunk_Y5U7UXEL.Space,
|
|
38
|
+
SpaceManager: () => import_chunk_Y5U7UXEL.SpaceManager,
|
|
39
|
+
SpaceProtocol: () => import_chunk_Y5U7UXEL.SpaceProtocol,
|
|
40
|
+
SpaceProtocolSession: () => import_chunk_Y5U7UXEL.SpaceProtocolSession,
|
|
41
|
+
TimeframeClock: () => import_chunk_Y5U7UXEL.TimeframeClock,
|
|
42
|
+
codec: () => import_chunk_Y5U7UXEL.codec,
|
|
43
|
+
createIdFromSpaceKey: () => import_chunk_Y5U7UXEL.createIdFromSpaceKey,
|
|
44
|
+
createMappedFeedWriter: () => import_chunk_Y5U7UXEL.createMappedFeedWriter,
|
|
43
45
|
encodingOptions: () => encodingOptions,
|
|
44
46
|
getSpaceKeyFromDoc: () => getSpaceKeyFromDoc,
|
|
45
|
-
hasInvitationExpired: () =>
|
|
46
|
-
mapFeedIndexesToTimeframe: () =>
|
|
47
|
-
mapTimeframeToFeedIndexes: () =>
|
|
48
|
-
startAfter: () =>
|
|
49
|
-
valueEncoding: () =>
|
|
47
|
+
hasInvitationExpired: () => import_chunk_Y5U7UXEL.hasInvitationExpired,
|
|
48
|
+
mapFeedIndexesToTimeframe: () => import_chunk_Y5U7UXEL.mapFeedIndexesToTimeframe,
|
|
49
|
+
mapTimeframeToFeedIndexes: () => import_chunk_Y5U7UXEL.mapTimeframeToFeedIndexes,
|
|
50
|
+
startAfter: () => import_chunk_Y5U7UXEL.startAfter,
|
|
51
|
+
valueEncoding: () => import_chunk_Y5U7UXEL.valueEncoding
|
|
50
52
|
});
|
|
51
53
|
module.exports = __toCommonJS(node_exports);
|
|
52
|
-
var
|
|
54
|
+
var import_chunk_Y5U7UXEL = require("./chunk-Y5U7UXEL.cjs");
|
|
53
55
|
var import_async = require("@dxos/async");
|
|
54
56
|
var import_automerge = require("@dxos/automerge/automerge");
|
|
55
57
|
var import_automerge_repo = require("@dxos/automerge/automerge-repo");
|
|
56
58
|
var import_context = require("@dxos/context");
|
|
57
|
-
var import_invariant = require("@dxos/invariant");
|
|
58
59
|
var import_keys = require("@dxos/keys");
|
|
59
|
-
var import_log = require("@dxos/log");
|
|
60
60
|
var import_protocols = require("@dxos/protocols");
|
|
61
61
|
var import_tracing = require("@dxos/tracing");
|
|
62
62
|
var import_util = require("@dxos/util");
|
|
63
63
|
var import_async2 = require("@dxos/async");
|
|
64
64
|
var import_automerge_repo2 = require("@dxos/automerge/automerge-repo");
|
|
65
65
|
var import_context2 = require("@dxos/context");
|
|
66
|
-
var
|
|
67
|
-
var
|
|
66
|
+
var import_invariant = require("@dxos/invariant");
|
|
67
|
+
var import_log = require("@dxos/log");
|
|
68
68
|
var import_context3 = require("@dxos/context");
|
|
69
69
|
var import_async3 = require("@dxos/async");
|
|
70
70
|
var import_automerge_repo3 = require("@dxos/automerge/automerge-repo");
|
|
71
71
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
72
|
-
var
|
|
72
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
73
73
|
var import_async4 = require("@dxos/async");
|
|
74
|
+
var import_automerge_repo4 = require("@dxos/automerge/automerge-repo");
|
|
74
75
|
var import_context4 = require("@dxos/context");
|
|
75
76
|
var import_debug = require("@dxos/debug");
|
|
76
|
-
var
|
|
77
|
-
var
|
|
77
|
+
var import_echo_protocol = require("@dxos/echo-protocol");
|
|
78
|
+
var import_invariant3 = require("@dxos/invariant");
|
|
79
|
+
var import_log2 = require("@dxos/log");
|
|
78
80
|
var import_tracing2 = require("@dxos/tracing");
|
|
79
|
-
var
|
|
81
|
+
var import_automerge_repo5 = require("@dxos/automerge/automerge-repo");
|
|
80
82
|
var import_context5 = require("@dxos/context");
|
|
81
|
-
var
|
|
83
|
+
var import_invariant4 = require("@dxos/invariant");
|
|
82
84
|
var import_keys2 = require("@dxos/keys");
|
|
83
|
-
var
|
|
85
|
+
var import_log3 = require("@dxos/log");
|
|
84
86
|
var import_teleport_extension_automerge_replicator = require("@dxos/teleport-extension-automerge-replicator");
|
|
85
87
|
var import_util2 = require("@dxos/util");
|
|
86
88
|
function _ts_decorate(decorators, target, key, desc) {
|
|
@@ -115,7 +117,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
115
117
|
}
|
|
116
118
|
connectionEntry.writer.write(message).catch((err) => {
|
|
117
119
|
if (connectionEntry.isOpen) {
|
|
118
|
-
|
|
120
|
+
import_log.log.catch(err, void 0, {
|
|
119
121
|
F: __dxlog_file,
|
|
120
122
|
L: 49,
|
|
121
123
|
S: this,
|
|
@@ -127,7 +129,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
127
129
|
disconnect() {
|
|
128
130
|
}
|
|
129
131
|
async open() {
|
|
130
|
-
(0,
|
|
132
|
+
(0, import_invariant.invariant)(this._lifecycleState === import_context2.LifecycleState.CLOSED, void 0, {
|
|
131
133
|
F: __dxlog_file,
|
|
132
134
|
L: 60,
|
|
133
135
|
S: this,
|
|
@@ -137,7 +139,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
137
139
|
]
|
|
138
140
|
});
|
|
139
141
|
this._lifecycleState = import_context2.LifecycleState.OPEN;
|
|
140
|
-
(0,
|
|
142
|
+
(0, import_log.log)("emit ready", void 0, {
|
|
141
143
|
F: __dxlog_file,
|
|
142
144
|
L: 63,
|
|
143
145
|
S: this,
|
|
@@ -148,7 +150,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
148
150
|
});
|
|
149
151
|
}
|
|
150
152
|
async close() {
|
|
151
|
-
(0,
|
|
153
|
+
(0, import_invariant.invariant)(this._lifecycleState === import_context2.LifecycleState.OPEN, void 0, {
|
|
152
154
|
F: __dxlog_file,
|
|
153
155
|
L: 71,
|
|
154
156
|
S: this,
|
|
@@ -169,7 +171,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
169
171
|
});
|
|
170
172
|
}
|
|
171
173
|
async addReplicator(replicator) {
|
|
172
|
-
(0,
|
|
174
|
+
(0, import_invariant.invariant)(this._lifecycleState === import_context2.LifecycleState.OPEN, void 0, {
|
|
173
175
|
F: __dxlog_file,
|
|
174
176
|
L: 87,
|
|
175
177
|
S: this,
|
|
@@ -178,7 +180,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
178
180
|
""
|
|
179
181
|
]
|
|
180
182
|
});
|
|
181
|
-
(0,
|
|
183
|
+
(0, import_invariant.invariant)(this.peerId, void 0, {
|
|
182
184
|
F: __dxlog_file,
|
|
183
185
|
L: 88,
|
|
184
186
|
S: this,
|
|
@@ -187,7 +189,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
187
189
|
""
|
|
188
190
|
]
|
|
189
191
|
});
|
|
190
|
-
(0,
|
|
192
|
+
(0, import_invariant.invariant)(!this._replicators.has(replicator), void 0, {
|
|
191
193
|
F: __dxlog_file,
|
|
192
194
|
L: 89,
|
|
193
195
|
S: this,
|
|
@@ -206,7 +208,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
206
208
|
});
|
|
207
209
|
}
|
|
208
210
|
async removeReplicator(replicator) {
|
|
209
|
-
(0,
|
|
211
|
+
(0, import_invariant.invariant)(this._lifecycleState === import_context2.LifecycleState.OPEN, void 0, {
|
|
210
212
|
F: __dxlog_file,
|
|
211
213
|
L: 103,
|
|
212
214
|
S: this,
|
|
@@ -215,7 +217,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
215
217
|
""
|
|
216
218
|
]
|
|
217
219
|
});
|
|
218
|
-
(0,
|
|
220
|
+
(0, import_invariant.invariant)(this._replicators.has(replicator), void 0, {
|
|
219
221
|
F: __dxlog_file,
|
|
220
222
|
L: 104,
|
|
221
223
|
S: this,
|
|
@@ -235,7 +237,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
235
237
|
return connection.connection.shouldAdvertize(params);
|
|
236
238
|
}
|
|
237
239
|
_onConnectionOpen(connection) {
|
|
238
|
-
(0,
|
|
240
|
+
(0, import_log.log)("Connection opened", {
|
|
239
241
|
peerId: connection.peerId
|
|
240
242
|
}, {
|
|
241
243
|
F: __dxlog_file,
|
|
@@ -243,7 +245,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
243
245
|
S: this,
|
|
244
246
|
C: (f, a) => f(...a)
|
|
245
247
|
});
|
|
246
|
-
(0,
|
|
248
|
+
(0, import_invariant.invariant)(!this._connections.has(connection.peerId), void 0, {
|
|
247
249
|
F: __dxlog_file,
|
|
248
250
|
L: 120,
|
|
249
251
|
S: this,
|
|
@@ -272,7 +274,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
272
274
|
}
|
|
273
275
|
} catch (err) {
|
|
274
276
|
if (connectionEntry.isOpen) {
|
|
275
|
-
|
|
277
|
+
import_log.log.catch(err, void 0, {
|
|
276
278
|
F: __dxlog_file,
|
|
277
279
|
L: 139,
|
|
278
280
|
S: this,
|
|
@@ -281,7 +283,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
281
283
|
}
|
|
282
284
|
}
|
|
283
285
|
});
|
|
284
|
-
(0,
|
|
286
|
+
(0, import_log.log)("emit peer-candidate", {
|
|
285
287
|
peerId: connection.peerId
|
|
286
288
|
}, {
|
|
287
289
|
F: __dxlog_file,
|
|
@@ -296,7 +298,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
296
298
|
* TODO(y): replace with a proper API call when sharePolicy update becomes supported by automerge-repo
|
|
297
299
|
*/
|
|
298
300
|
_onConnectionAuthScopeChanged(connection) {
|
|
299
|
-
(0,
|
|
301
|
+
(0, import_log.log)("Connection auth scope changed", {
|
|
300
302
|
peerId: connection.peerId
|
|
301
303
|
}, {
|
|
302
304
|
F: __dxlog_file,
|
|
@@ -305,7 +307,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
305
307
|
C: (f, a) => f(...a)
|
|
306
308
|
});
|
|
307
309
|
const entry = this._connections.get(connection.peerId);
|
|
308
|
-
(0,
|
|
310
|
+
(0, import_invariant.invariant)(entry, void 0, {
|
|
309
311
|
F: __dxlog_file,
|
|
310
312
|
L: 155,
|
|
311
313
|
S: this,
|
|
@@ -320,7 +322,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
320
322
|
this._emitPeerCandidate(connection);
|
|
321
323
|
}
|
|
322
324
|
_onConnectionClosed(connection) {
|
|
323
|
-
(0,
|
|
325
|
+
(0, import_log.log)("Connection closed", {
|
|
324
326
|
peerId: connection.peerId
|
|
325
327
|
}, {
|
|
326
328
|
F: __dxlog_file,
|
|
@@ -329,7 +331,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
329
331
|
C: (f, a) => f(...a)
|
|
330
332
|
});
|
|
331
333
|
const entry = this._connections.get(connection.peerId);
|
|
332
|
-
(0,
|
|
334
|
+
(0, import_invariant.invariant)(entry, void 0, {
|
|
333
335
|
F: __dxlog_file,
|
|
334
336
|
L: 163,
|
|
335
337
|
S: this,
|
|
@@ -342,13 +344,13 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
342
344
|
this.emit("peer-disconnected", {
|
|
343
345
|
peerId: connection.peerId
|
|
344
346
|
});
|
|
345
|
-
void entry.reader.cancel().catch((err) =>
|
|
347
|
+
void entry.reader.cancel().catch((err) => import_log.log.catch(err, void 0, {
|
|
346
348
|
F: __dxlog_file,
|
|
347
349
|
L: 168,
|
|
348
350
|
S: this,
|
|
349
351
|
C: (f, a) => f(...a)
|
|
350
352
|
}));
|
|
351
|
-
void entry.writer.abort().catch((err) =>
|
|
353
|
+
void entry.writer.abort().catch((err) => import_log.log.catch(err, void 0, {
|
|
352
354
|
F: __dxlog_file,
|
|
353
355
|
L: 169,
|
|
354
356
|
S: this,
|
|
@@ -359,10 +361,7 @@ var EchoNetworkAdapter = class extends import_automerge_repo2.NetworkAdapter {
|
|
|
359
361
|
_emitPeerCandidate(connection) {
|
|
360
362
|
this.emit("peer-candidate", {
|
|
361
363
|
peerId: connection.peerId,
|
|
362
|
-
peerMetadata:
|
|
363
|
-
// TODO(dmaretskyi): Refactor this.
|
|
364
|
-
dxos_peerSource: "EchoNetworkAdapter"
|
|
365
|
-
}
|
|
364
|
+
peerMetadata: createEchoPeerMetadata()
|
|
366
365
|
});
|
|
367
366
|
}
|
|
368
367
|
};
|
|
@@ -378,6 +377,11 @@ _ts_decorate([
|
|
|
378
377
|
_ts_decorate([
|
|
379
378
|
import_async2.synchronized
|
|
380
379
|
], EchoNetworkAdapter.prototype, "removeReplicator", null);
|
|
380
|
+
var createEchoPeerMetadata = () => ({
|
|
381
|
+
// TODO(dmaretskyi): Refactor this.
|
|
382
|
+
dxos_peerSource: "EchoNetworkAdapter"
|
|
383
|
+
});
|
|
384
|
+
var isEchoPeerMetadata = (metadata) => metadata?.dxos_peerSource === "EchoNetworkAdapter";
|
|
381
385
|
var LevelDBStorageAdapter = class extends import_context3.Resource {
|
|
382
386
|
constructor(_params) {
|
|
383
387
|
super();
|
|
@@ -499,7 +503,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapte
|
|
|
499
503
|
}
|
|
500
504
|
send(message) {
|
|
501
505
|
const peer = this._peers.get(message.targetId);
|
|
502
|
-
(0,
|
|
506
|
+
(0, import_invariant2.invariant)(peer, "Peer not found.", {
|
|
503
507
|
F: __dxlog_file2,
|
|
504
508
|
L: 51,
|
|
505
509
|
S: this,
|
|
@@ -524,7 +528,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapte
|
|
|
524
528
|
syncRepo({ id, syncMessage }) {
|
|
525
529
|
const peerId = this._getPeerId(id);
|
|
526
530
|
return new import_codec_protobuf.Stream(({ next, close }) => {
|
|
527
|
-
(0,
|
|
531
|
+
(0, import_invariant2.invariant)(!this._peers.has(peerId), "Peer already connected.", {
|
|
528
532
|
F: __dxlog_file2,
|
|
529
533
|
L: 73,
|
|
530
534
|
S: this,
|
|
@@ -548,7 +552,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapte
|
|
|
548
552
|
});
|
|
549
553
|
}
|
|
550
554
|
});
|
|
551
|
-
(0,
|
|
555
|
+
(0, import_invariant2.invariant)(this._isConnected, void 0, {
|
|
552
556
|
F: __dxlog_file2,
|
|
553
557
|
L: 90,
|
|
554
558
|
S: this,
|
|
@@ -564,7 +568,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapte
|
|
|
564
568
|
});
|
|
565
569
|
}
|
|
566
570
|
async sendSyncMessage({ id, syncMessage }) {
|
|
567
|
-
(0,
|
|
571
|
+
(0, import_invariant2.invariant)(this._isConnected, void 0, {
|
|
568
572
|
F: __dxlog_file2,
|
|
569
573
|
L: 99,
|
|
570
574
|
S: this,
|
|
@@ -577,7 +581,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapte
|
|
|
577
581
|
this.emit("message", message);
|
|
578
582
|
}
|
|
579
583
|
async getHostInfo() {
|
|
580
|
-
(0,
|
|
584
|
+
(0, import_invariant2.invariant)(this._isConnected, void 0, {
|
|
581
585
|
F: __dxlog_file2,
|
|
582
586
|
L: 105,
|
|
583
587
|
S: this,
|
|
@@ -586,7 +590,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapte
|
|
|
586
590
|
""
|
|
587
591
|
]
|
|
588
592
|
});
|
|
589
|
-
(0,
|
|
593
|
+
(0, import_invariant2.invariant)(this.peerId, "Peer id not set.", {
|
|
590
594
|
F: __dxlog_file2,
|
|
591
595
|
L: 106,
|
|
592
596
|
S: this,
|
|
@@ -616,11 +620,13 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
616
620
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
|
|
617
621
|
var AutomergeHost = class {
|
|
618
622
|
constructor({ db, indexMetadataStore }) {
|
|
619
|
-
this._ctx = new import_context.Context(
|
|
623
|
+
this._ctx = new import_context.Context(void 0, {
|
|
624
|
+
F: __dxlog_file3,
|
|
625
|
+
L: 71
|
|
626
|
+
});
|
|
620
627
|
this._echoNetworkAdapter = new EchoNetworkAdapter({
|
|
621
628
|
getContainingSpaceForDocument: this._getContainingSpaceForDocument.bind(this)
|
|
622
629
|
});
|
|
623
|
-
this._requestedDocs = /* @__PURE__ */ new Set();
|
|
624
630
|
this._storage = new LevelDBStorageAdapter({
|
|
625
631
|
db,
|
|
626
632
|
callbacks: {
|
|
@@ -656,6 +662,9 @@ var AutomergeHost = class {
|
|
|
656
662
|
await this._echoNetworkAdapter.close();
|
|
657
663
|
await this._ctx.dispose();
|
|
658
664
|
}
|
|
665
|
+
/**
|
|
666
|
+
* @deprecated To be abstracted away.
|
|
667
|
+
*/
|
|
659
668
|
get repo() {
|
|
660
669
|
return this._repo;
|
|
661
670
|
}
|
|
@@ -665,6 +674,39 @@ var AutomergeHost = class {
|
|
|
665
674
|
async removeReplicator(replicator) {
|
|
666
675
|
await this._echoNetworkAdapter.removeReplicator(replicator);
|
|
667
676
|
}
|
|
677
|
+
/**
|
|
678
|
+
* Loads the document handle from the repo and waits for it to be ready.
|
|
679
|
+
*/
|
|
680
|
+
async loadDoc(ctx, documentId, opts) {
|
|
681
|
+
let handle;
|
|
682
|
+
if (typeof documentId === "string") {
|
|
683
|
+
handle = this._repo.handles[documentId];
|
|
684
|
+
}
|
|
685
|
+
if (!handle) {
|
|
686
|
+
handle = this._repo.find(documentId);
|
|
687
|
+
}
|
|
688
|
+
if (!handle.isReady()) {
|
|
689
|
+
if (!opts?.timeout) {
|
|
690
|
+
await (0, import_context.cancelWithContext)(ctx, handle.whenReady());
|
|
691
|
+
} else {
|
|
692
|
+
await (0, import_context.cancelWithContext)(ctx, (0, import_async.asyncTimeout)(handle.whenReady(), opts.timeout));
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
return handle;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Create new persisted document.
|
|
699
|
+
*/
|
|
700
|
+
createDoc(initialValue, opts) {
|
|
701
|
+
if (opts?.preserveHistory) {
|
|
702
|
+
if (!(0, import_automerge.isAutomerge)(initialValue)) {
|
|
703
|
+
throw new TypeError("Initial value must be an Automerge document");
|
|
704
|
+
}
|
|
705
|
+
return this._repo.import((0, import_automerge.save)(initialValue));
|
|
706
|
+
} else {
|
|
707
|
+
return this._repo.create(initialValue);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
668
710
|
// TODO(dmaretskyi): Share based on HALO permissions and space affinity.
|
|
669
711
|
// Hosts, running in the worker, don't share documents unless requested by other peers.
|
|
670
712
|
// NOTE: If both peers return sharePolicy=false the replication will not happen
|
|
@@ -676,23 +718,8 @@ var AutomergeHost = class {
|
|
|
676
718
|
if (!documentId) {
|
|
677
719
|
return false;
|
|
678
720
|
}
|
|
679
|
-
const doc = this._repo.handles[documentId]?.docSync();
|
|
680
|
-
if (!doc) {
|
|
681
|
-
const isRequested = this._requestedDocs.has(`automerge:${documentId}`);
|
|
682
|
-
(0, import_log.log)("doc share policy check", {
|
|
683
|
-
peerId,
|
|
684
|
-
documentId,
|
|
685
|
-
isRequested
|
|
686
|
-
}, {
|
|
687
|
-
F: __dxlog_file3,
|
|
688
|
-
L: 143,
|
|
689
|
-
S: this,
|
|
690
|
-
C: (f, a) => f(...a)
|
|
691
|
-
});
|
|
692
|
-
return isRequested;
|
|
693
|
-
}
|
|
694
721
|
const peerMetadata = this.repo.peerMetadataByPeerId[peerId];
|
|
695
|
-
if (peerMetadata
|
|
722
|
+
if (isEchoPeerMetadata(peerMetadata)) {
|
|
696
723
|
return this._echoNetworkAdapter.shouldAdvertize(peerId, {
|
|
697
724
|
documentId
|
|
698
725
|
});
|
|
@@ -764,31 +791,36 @@ var AutomergeHost = class {
|
|
|
764
791
|
}
|
|
765
792
|
return import_keys.PublicKey.from(spaceKeyHex);
|
|
766
793
|
}
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
794
|
+
/**
|
|
795
|
+
* Flush documents to disk.
|
|
796
|
+
*/
|
|
770
797
|
async flush({ states }) {
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
});
|
|
781
|
-
const handle = this.repo.handles[documentId] ?? this._repo.find(documentId);
|
|
782
|
-
await waitForHeads(handle, heads);
|
|
783
|
-
}) ?? []);
|
|
798
|
+
if (states) {
|
|
799
|
+
await Promise.all(states.map(async ({ heads, documentId }) => {
|
|
800
|
+
if (!heads) {
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
803
|
+
const handle = this.repo.handles[documentId] ?? this._repo.find(documentId);
|
|
804
|
+
await waitForHeads(handle, heads);
|
|
805
|
+
}) ?? []);
|
|
806
|
+
}
|
|
784
807
|
await this._repo.flush(states?.map(({ documentId }) => documentId));
|
|
785
808
|
}
|
|
809
|
+
/**
|
|
810
|
+
* Host <-> Client sync.
|
|
811
|
+
*/
|
|
786
812
|
syncRepo(request) {
|
|
787
813
|
return this._clientNetwork.syncRepo(request);
|
|
788
814
|
}
|
|
815
|
+
/**
|
|
816
|
+
* Host <-> Client sync.
|
|
817
|
+
*/
|
|
789
818
|
sendSyncMessage(request) {
|
|
790
819
|
return this._clientNetwork.sendSyncMessage(request);
|
|
791
820
|
}
|
|
821
|
+
/**
|
|
822
|
+
* Host <-> Client sync.
|
|
823
|
+
*/
|
|
792
824
|
async getHostInfo() {
|
|
793
825
|
return this._clientNetwork.getHostInfo();
|
|
794
826
|
}
|
|
@@ -871,32 +903,32 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
871
903
|
return;
|
|
872
904
|
}
|
|
873
905
|
if (!spaceState.rootUrl) {
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
this._spaceRootDocHandle = existingDocHandle;
|
|
906
|
+
throw new Error("Database opened with no rootUrl");
|
|
907
|
+
}
|
|
908
|
+
const existingDocHandle = await this._initDocHandle(ctx, spaceState.rootUrl);
|
|
909
|
+
const doc = existingDocHandle.docSync();
|
|
910
|
+
(0, import_invariant3.invariant)(doc, void 0, {
|
|
911
|
+
F: __dxlog_file4,
|
|
912
|
+
L: 84,
|
|
913
|
+
S: this,
|
|
914
|
+
A: [
|
|
915
|
+
"doc",
|
|
916
|
+
""
|
|
917
|
+
]
|
|
918
|
+
});
|
|
919
|
+
(0, import_invariant3.invariant)(doc.version === import_echo_protocol.SpaceDocVersion.CURRENT, void 0, {
|
|
920
|
+
F: __dxlog_file4,
|
|
921
|
+
L: 85,
|
|
922
|
+
S: this,
|
|
923
|
+
A: [
|
|
924
|
+
"doc.version === SpaceDocVersion.CURRENT",
|
|
925
|
+
""
|
|
926
|
+
]
|
|
927
|
+
});
|
|
928
|
+
if (doc.access == null) {
|
|
929
|
+
this._initDocAccess(existingDocHandle);
|
|
899
930
|
}
|
|
931
|
+
this._spaceRootDocHandle = existingDocHandle;
|
|
900
932
|
}
|
|
901
933
|
loadObjectDocument(objectIdOrMany) {
|
|
902
934
|
const objectIds = Array.isArray(objectIdOrMany) ? objectIdOrMany : [
|
|
@@ -905,9 +937,9 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
905
937
|
let hasUrlsToLoad = false;
|
|
906
938
|
const urlsToLoad = {};
|
|
907
939
|
for (const objectId of objectIds) {
|
|
908
|
-
(0,
|
|
940
|
+
(0, import_invariant3.invariant)(this._spaceRootDocHandle, void 0, {
|
|
909
941
|
F: __dxlog_file4,
|
|
910
|
-
L:
|
|
942
|
+
L: 97,
|
|
911
943
|
S: this,
|
|
912
944
|
A: [
|
|
913
945
|
"this._spaceRootDocHandle",
|
|
@@ -918,9 +950,9 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
918
950
|
continue;
|
|
919
951
|
}
|
|
920
952
|
const spaceRootDoc = this._spaceRootDocHandle.docSync();
|
|
921
|
-
(0,
|
|
953
|
+
(0, import_invariant3.invariant)(spaceRootDoc, void 0, {
|
|
922
954
|
F: __dxlog_file4,
|
|
923
|
-
L:
|
|
955
|
+
L: 102,
|
|
924
956
|
S: this,
|
|
925
957
|
A: [
|
|
926
958
|
"spaceRootDoc",
|
|
@@ -930,11 +962,11 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
930
962
|
const documentUrl = (spaceRootDoc.links ?? {})[objectId];
|
|
931
963
|
if (documentUrl == null) {
|
|
932
964
|
this._objectsPendingDocumentLoad.add(objectId);
|
|
933
|
-
|
|
965
|
+
import_log2.log.info("loading delayed until object links are initialized", {
|
|
934
966
|
objectId
|
|
935
967
|
}, {
|
|
936
968
|
F: __dxlog_file4,
|
|
937
|
-
L:
|
|
969
|
+
L: 106,
|
|
938
970
|
S: this,
|
|
939
971
|
C: (f, a) => f(...a)
|
|
940
972
|
});
|
|
@@ -947,6 +979,32 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
947
979
|
this._loadLinkedObjects(urlsToLoad);
|
|
948
980
|
}
|
|
949
981
|
}
|
|
982
|
+
getObjectDocumentId(objectId) {
|
|
983
|
+
(0, import_invariant3.invariant)(this._spaceRootDocHandle, void 0, {
|
|
984
|
+
F: __dxlog_file4,
|
|
985
|
+
L: 118,
|
|
986
|
+
S: this,
|
|
987
|
+
A: [
|
|
988
|
+
"this._spaceRootDocHandle",
|
|
989
|
+
""
|
|
990
|
+
]
|
|
991
|
+
});
|
|
992
|
+
const spaceRootDoc = this._spaceRootDocHandle.docSync();
|
|
993
|
+
(0, import_invariant3.invariant)(spaceRootDoc, void 0, {
|
|
994
|
+
F: __dxlog_file4,
|
|
995
|
+
L: 120,
|
|
996
|
+
S: this,
|
|
997
|
+
A: [
|
|
998
|
+
"spaceRootDoc",
|
|
999
|
+
""
|
|
1000
|
+
]
|
|
1001
|
+
});
|
|
1002
|
+
if (spaceRootDoc.objects?.[objectId]) {
|
|
1003
|
+
return this._spaceRootDocHandle.documentId;
|
|
1004
|
+
}
|
|
1005
|
+
const documentUrl = (spaceRootDoc.links ?? {})[objectId];
|
|
1006
|
+
return documentUrl && (0, import_automerge_repo4.interpretAsDocumentId)(documentUrl);
|
|
1007
|
+
}
|
|
950
1008
|
onObjectLinksUpdated(links) {
|
|
951
1009
|
if (!links) {
|
|
952
1010
|
return;
|
|
@@ -956,9 +1014,9 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
956
1014
|
linksAwaitingLoad.forEach(([objectId]) => this._objectsPendingDocumentLoad.delete(objectId));
|
|
957
1015
|
}
|
|
958
1016
|
getSpaceRootDocHandle() {
|
|
959
|
-
(0,
|
|
1017
|
+
(0, import_invariant3.invariant)(this._spaceRootDocHandle, void 0, {
|
|
960
1018
|
F: __dxlog_file4,
|
|
961
|
-
L:
|
|
1019
|
+
L: 140,
|
|
962
1020
|
S: this,
|
|
963
1021
|
A: [
|
|
964
1022
|
"this._spaceRootDocHandle",
|
|
@@ -968,16 +1026,18 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
968
1026
|
return this._spaceRootDocHandle;
|
|
969
1027
|
}
|
|
970
1028
|
createDocumentForObject(objectId) {
|
|
971
|
-
(0,
|
|
1029
|
+
(0, import_invariant3.invariant)(this._spaceRootDocHandle, void 0, {
|
|
972
1030
|
F: __dxlog_file4,
|
|
973
|
-
L:
|
|
1031
|
+
L: 145,
|
|
974
1032
|
S: this,
|
|
975
1033
|
A: [
|
|
976
1034
|
"this._spaceRootDocHandle",
|
|
977
1035
|
""
|
|
978
1036
|
]
|
|
979
1037
|
});
|
|
980
|
-
const spaceDocHandle = this._repo.create(
|
|
1038
|
+
const spaceDocHandle = this._repo.create({
|
|
1039
|
+
version: import_echo_protocol.SpaceDocVersion.CURRENT
|
|
1040
|
+
});
|
|
981
1041
|
this._initDocAccess(spaceDocHandle);
|
|
982
1042
|
this.onObjectBoundToDocument(spaceDocHandle, objectId);
|
|
983
1043
|
this._spaceRootDocHandle.change((newDoc) => {
|
|
@@ -1008,30 +1068,30 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1008
1068
|
};
|
|
1009
1069
|
const objectDocumentHandle = this._objectDocumentHandles.get(objectId);
|
|
1010
1070
|
if (objectDocumentHandle != null && objectDocumentHandle.url !== automergeUrl) {
|
|
1011
|
-
|
|
1071
|
+
import_log2.log.warn("object already inlined in a different document, ignoring the link", {
|
|
1012
1072
|
...logMeta,
|
|
1013
1073
|
actualDocumentUrl: objectDocumentHandle.url
|
|
1014
1074
|
}, {
|
|
1015
1075
|
F: __dxlog_file4,
|
|
1016
|
-
L:
|
|
1076
|
+
L: 177,
|
|
1017
1077
|
S: this,
|
|
1018
1078
|
C: (f, a) => f(...a)
|
|
1019
1079
|
});
|
|
1020
1080
|
continue;
|
|
1021
1081
|
}
|
|
1022
1082
|
if (objectDocumentHandle?.url === automergeUrl) {
|
|
1023
|
-
|
|
1083
|
+
import_log2.log.warn("object document was already loaded", logMeta, {
|
|
1024
1084
|
F: __dxlog_file4,
|
|
1025
|
-
L:
|
|
1085
|
+
L: 184,
|
|
1026
1086
|
S: this,
|
|
1027
1087
|
C: (f, a) => f(...a)
|
|
1028
1088
|
});
|
|
1029
1089
|
continue;
|
|
1030
1090
|
}
|
|
1031
1091
|
const handle = this._repo.find(automergeUrl);
|
|
1032
|
-
|
|
1092
|
+
import_log2.log.debug("document loading triggered", logMeta, {
|
|
1033
1093
|
F: __dxlog_file4,
|
|
1034
|
-
L:
|
|
1094
|
+
L: 188,
|
|
1035
1095
|
S: this,
|
|
1036
1096
|
C: (f, a) => f(...a)
|
|
1037
1097
|
});
|
|
@@ -1049,12 +1109,12 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1049
1109
|
break;
|
|
1050
1110
|
} catch (err) {
|
|
1051
1111
|
if (`${err}`.includes("Timeout")) {
|
|
1052
|
-
|
|
1112
|
+
import_log2.log.info("wraparound", {
|
|
1053
1113
|
id: docHandle.documentId,
|
|
1054
1114
|
state: docHandle.state
|
|
1055
1115
|
}, {
|
|
1056
1116
|
F: __dxlog_file4,
|
|
1057
|
-
L:
|
|
1117
|
+
L: 204,
|
|
1058
1118
|
S: this,
|
|
1059
1119
|
C: (f, a) => f(...a)
|
|
1060
1120
|
});
|
|
@@ -1068,14 +1128,6 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1068
1128
|
}
|
|
1069
1129
|
return docHandle;
|
|
1070
1130
|
}
|
|
1071
|
-
_createContextBoundSpaceRootDocument(ctx) {
|
|
1072
|
-
const docHandle = this._repo.create();
|
|
1073
|
-
this._spaceRootDocHandle = docHandle;
|
|
1074
|
-
ctx.onDispose(() => {
|
|
1075
|
-
docHandle.delete();
|
|
1076
|
-
this._spaceRootDocHandle = null;
|
|
1077
|
-
});
|
|
1078
|
-
}
|
|
1079
1131
|
_initDocAccess(handle) {
|
|
1080
1132
|
handle.change((newDoc) => {
|
|
1081
1133
|
newDoc.access ??= {
|
|
@@ -1094,9 +1146,9 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1094
1146
|
docUrl: handle.url
|
|
1095
1147
|
};
|
|
1096
1148
|
if (this.onObjectDocumentLoaded.listenerCount() === 0) {
|
|
1097
|
-
|
|
1149
|
+
import_log2.log.info("document loaded after all listeners were removed", logMeta, {
|
|
1098
1150
|
F: __dxlog_file4,
|
|
1099
|
-
L:
|
|
1151
|
+
L: 231,
|
|
1100
1152
|
S: this,
|
|
1101
1153
|
C: (f, a) => f(...a)
|
|
1102
1154
|
});
|
|
@@ -1104,9 +1156,9 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1104
1156
|
}
|
|
1105
1157
|
const objectDocHandle = this._objectDocumentHandles.get(objectId);
|
|
1106
1158
|
if (objectDocHandle?.url !== handle.url) {
|
|
1107
|
-
|
|
1159
|
+
import_log2.log.warn("object was rebound while a document was loading, discarding handle", logMeta, {
|
|
1108
1160
|
F: __dxlog_file4,
|
|
1109
|
-
L:
|
|
1161
|
+
L: 236,
|
|
1110
1162
|
S: this,
|
|
1111
1163
|
C: (f, a) => f(...a)
|
|
1112
1164
|
});
|
|
@@ -1118,14 +1170,14 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1118
1170
|
});
|
|
1119
1171
|
} catch (err) {
|
|
1120
1172
|
const shouldRetryLoading = this.onObjectDocumentLoaded.listenerCount() > 0;
|
|
1121
|
-
|
|
1173
|
+
import_log2.log.warn("failed to load a document", {
|
|
1122
1174
|
objectId,
|
|
1123
1175
|
automergeUrl: handle.url,
|
|
1124
1176
|
retryLoading: shouldRetryLoading,
|
|
1125
1177
|
err
|
|
1126
1178
|
}, {
|
|
1127
1179
|
F: __dxlog_file4,
|
|
1128
|
-
L:
|
|
1180
|
+
L: 242,
|
|
1129
1181
|
S: this,
|
|
1130
1182
|
C: (f, a) => f(...a)
|
|
1131
1183
|
});
|
|
@@ -1163,7 +1215,7 @@ var MeshEchoReplicator = class {
|
|
|
1163
1215
|
this._context = null;
|
|
1164
1216
|
}
|
|
1165
1217
|
createExtension() {
|
|
1166
|
-
(0,
|
|
1218
|
+
(0, import_invariant4.invariant)(this._context, void 0, {
|
|
1167
1219
|
F: __dxlog_file5,
|
|
1168
1220
|
L: 54,
|
|
1169
1221
|
S: this,
|
|
@@ -1175,7 +1227,7 @@ var MeshEchoReplicator = class {
|
|
|
1175
1227
|
const connection = new MeshReplicatorConnection({
|
|
1176
1228
|
ownPeerId: this._context.peerId,
|
|
1177
1229
|
onRemoteConnected: async () => {
|
|
1178
|
-
(0,
|
|
1230
|
+
(0, import_log3.log)("onRemoteConnected", {
|
|
1179
1231
|
peerId: connection.peerId
|
|
1180
1232
|
}, {
|
|
1181
1233
|
F: __dxlog_file5,
|
|
@@ -1183,7 +1235,7 @@ var MeshEchoReplicator = class {
|
|
|
1183
1235
|
S: this,
|
|
1184
1236
|
C: (f, a) => f(...a)
|
|
1185
1237
|
});
|
|
1186
|
-
(0,
|
|
1238
|
+
(0, import_invariant4.invariant)(this._context, void 0, {
|
|
1187
1239
|
F: __dxlog_file5,
|
|
1188
1240
|
L: 60,
|
|
1189
1241
|
S: this,
|
|
@@ -1196,12 +1248,12 @@ var MeshEchoReplicator = class {
|
|
|
1196
1248
|
this._context.onConnectionAuthScopeChanged(connection);
|
|
1197
1249
|
} else {
|
|
1198
1250
|
this._connectionsPerPeer.set(connection.peerId, connection);
|
|
1199
|
-
await connection.enable();
|
|
1200
1251
|
this._context.onConnectionOpen(connection);
|
|
1252
|
+
await connection.enable();
|
|
1201
1253
|
}
|
|
1202
1254
|
},
|
|
1203
1255
|
onRemoteDisconnected: async () => {
|
|
1204
|
-
(0,
|
|
1256
|
+
(0, import_log3.log)("onRemoteDisconnected", {
|
|
1205
1257
|
peerId: connection.peerId
|
|
1206
1258
|
}, {
|
|
1207
1259
|
F: __dxlog_file5,
|
|
@@ -1210,12 +1262,12 @@ var MeshEchoReplicator = class {
|
|
|
1210
1262
|
C: (f, a) => f(...a)
|
|
1211
1263
|
});
|
|
1212
1264
|
this._context?.onConnectionClosed(connection);
|
|
1213
|
-
await connection.disable();
|
|
1214
1265
|
this._connectionsPerPeer.delete(connection.peerId);
|
|
1266
|
+
await connection.disable();
|
|
1215
1267
|
this._connections.delete(connection);
|
|
1216
1268
|
},
|
|
1217
1269
|
shouldAdvertize: async (params) => {
|
|
1218
|
-
(0,
|
|
1270
|
+
(0, import_log3.log)("shouldAdvertize", {
|
|
1219
1271
|
peerId: connection.peerId,
|
|
1220
1272
|
documentId: params.documentId
|
|
1221
1273
|
}, {
|
|
@@ -1224,7 +1276,7 @@ var MeshEchoReplicator = class {
|
|
|
1224
1276
|
S: this,
|
|
1225
1277
|
C: (f, a) => f(...a)
|
|
1226
1278
|
});
|
|
1227
|
-
(0,
|
|
1279
|
+
(0, import_invariant4.invariant)(this._context, void 0, {
|
|
1228
1280
|
F: __dxlog_file5,
|
|
1229
1281
|
L: 79,
|
|
1230
1282
|
S: this,
|
|
@@ -1236,7 +1288,7 @@ var MeshEchoReplicator = class {
|
|
|
1236
1288
|
try {
|
|
1237
1289
|
const spaceKey = await this._context.getContainingSpaceForDocument(params.documentId);
|
|
1238
1290
|
if (!spaceKey) {
|
|
1239
|
-
(0,
|
|
1291
|
+
(0, import_log3.log)("space key not found for share policy check", {
|
|
1240
1292
|
peerId: connection.peerId,
|
|
1241
1293
|
documentId: params.documentId
|
|
1242
1294
|
}, {
|
|
@@ -1249,7 +1301,7 @@ var MeshEchoReplicator = class {
|
|
|
1249
1301
|
}
|
|
1250
1302
|
const authorizedDevices = this._authorizedDevices.get(spaceKey);
|
|
1251
1303
|
if (!connection.remoteDeviceKey) {
|
|
1252
|
-
(0,
|
|
1304
|
+
(0, import_log3.log)("device key not found for share policy check", {
|
|
1253
1305
|
peerId: connection.peerId,
|
|
1254
1306
|
documentId: params.documentId
|
|
1255
1307
|
}, {
|
|
@@ -1261,7 +1313,7 @@ var MeshEchoReplicator = class {
|
|
|
1261
1313
|
return false;
|
|
1262
1314
|
}
|
|
1263
1315
|
const isAuthorized = authorizedDevices?.has(connection.remoteDeviceKey) ?? false;
|
|
1264
|
-
(0,
|
|
1316
|
+
(0, import_log3.log)("share policy check", {
|
|
1265
1317
|
localPeer: this._context.peerId,
|
|
1266
1318
|
remotePeer: connection.peerId,
|
|
1267
1319
|
documentId: params.documentId,
|
|
@@ -1276,7 +1328,7 @@ var MeshEchoReplicator = class {
|
|
|
1276
1328
|
});
|
|
1277
1329
|
return isAuthorized;
|
|
1278
1330
|
} catch (err) {
|
|
1279
|
-
|
|
1331
|
+
import_log3.log.catch(err, void 0, {
|
|
1280
1332
|
F: __dxlog_file5,
|
|
1281
1333
|
L: 111,
|
|
1282
1334
|
S: this,
|
|
@@ -1290,7 +1342,7 @@ var MeshEchoReplicator = class {
|
|
|
1290
1342
|
return connection.replicatorExtension;
|
|
1291
1343
|
}
|
|
1292
1344
|
authorizeDevice(spaceKey, deviceKey) {
|
|
1293
|
-
(0,
|
|
1345
|
+
(0, import_log3.log)("authorizeDevice", {
|
|
1294
1346
|
spaceKey,
|
|
1295
1347
|
deviceKey
|
|
1296
1348
|
}, {
|
|
@@ -1300,6 +1352,11 @@ var MeshEchoReplicator = class {
|
|
|
1300
1352
|
C: (f, a) => f(...a)
|
|
1301
1353
|
});
|
|
1302
1354
|
(0, import_util2.defaultMap)(this._authorizedDevices, spaceKey, () => new import_util2.ComplexSet(import_keys2.PublicKey.hash)).add(deviceKey);
|
|
1355
|
+
for (const connection of this._connections) {
|
|
1356
|
+
if (connection.remoteDeviceKey && connection.remoteDeviceKey.equals(deviceKey)) {
|
|
1357
|
+
this._context?.onConnectionAuthScopeChanged(connection);
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1303
1360
|
}
|
|
1304
1361
|
};
|
|
1305
1362
|
var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
@@ -1319,7 +1376,7 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1319
1376
|
this.writable = new WritableStream({
|
|
1320
1377
|
write: async (message, controller) => {
|
|
1321
1378
|
this.replicatorExtension.sendSyncMessage({
|
|
1322
|
-
payload:
|
|
1379
|
+
payload: import_automerge_repo5.cbor.encode(message)
|
|
1323
1380
|
}).catch((err) => {
|
|
1324
1381
|
controller.error(err);
|
|
1325
1382
|
});
|
|
@@ -1331,13 +1388,13 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1331
1388
|
onStartReplication: async (info, remotePeerId) => {
|
|
1332
1389
|
this.remoteDeviceKey = remotePeerId;
|
|
1333
1390
|
this._remotePeerId = info.id;
|
|
1334
|
-
(0,
|
|
1391
|
+
(0, import_log3.log)("onStartReplication", {
|
|
1335
1392
|
id: info.id,
|
|
1336
1393
|
thisPeerId: this.peerId,
|
|
1337
1394
|
remotePeerId: remotePeerId.toHex()
|
|
1338
1395
|
}, {
|
|
1339
1396
|
F: __dxlog_file5,
|
|
1340
|
-
L:
|
|
1397
|
+
L: 192,
|
|
1341
1398
|
S: this,
|
|
1342
1399
|
C: (f, a) => f(...a)
|
|
1343
1400
|
});
|
|
@@ -1347,7 +1404,7 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1347
1404
|
if (!this._isEnabled) {
|
|
1348
1405
|
return;
|
|
1349
1406
|
}
|
|
1350
|
-
const message =
|
|
1407
|
+
const message = import_automerge_repo5.cbor.decode(payload);
|
|
1351
1408
|
readableStreamController.enqueue(message);
|
|
1352
1409
|
},
|
|
1353
1410
|
onClose: async () => {
|
|
@@ -1359,9 +1416,9 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1359
1416
|
});
|
|
1360
1417
|
}
|
|
1361
1418
|
get peerId() {
|
|
1362
|
-
(0,
|
|
1419
|
+
(0, import_invariant4.invariant)(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1363
1420
|
F: __dxlog_file5,
|
|
1364
|
-
L:
|
|
1421
|
+
L: 215,
|
|
1365
1422
|
S: this,
|
|
1366
1423
|
A: [
|
|
1367
1424
|
"this._remotePeerId != null",
|
|
@@ -1378,9 +1435,9 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1378
1435
|
* Call after the remote peer has connected.
|
|
1379
1436
|
*/
|
|
1380
1437
|
async enable() {
|
|
1381
|
-
(0,
|
|
1438
|
+
(0, import_invariant4.invariant)(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1382
1439
|
F: __dxlog_file5,
|
|
1383
|
-
L:
|
|
1440
|
+
L: 228,
|
|
1384
1441
|
S: this,
|
|
1385
1442
|
A: [
|
|
1386
1443
|
"this._remotePeerId != null",
|
|
@@ -1402,6 +1459,8 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1402
1459
|
AuthStatus,
|
|
1403
1460
|
AutomergeDocumentLoaderImpl,
|
|
1404
1461
|
AutomergeHost,
|
|
1462
|
+
CredentialRetrieverExtension,
|
|
1463
|
+
CredentialServerExtension,
|
|
1405
1464
|
DataServiceImpl,
|
|
1406
1465
|
LevelDBStorageAdapter,
|
|
1407
1466
|
LocalHostNetworkAdapter,
|