@dxos/echo-pipeline 0.6.12-main.5cc132e → 0.6.12-main.7907542
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/{node-esm/chunk-ZWS5AMHO.mjs → browser/chunk-PESZVYAN.mjs} +83 -33
- package/dist/lib/browser/chunk-PESZVYAN.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +3401 -17
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +3 -4
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-7HHYCGUR.cjs → chunk-6EZVIJNE.cjs} +89 -47
- package/dist/lib/node/chunk-6EZVIJNE.cjs.map +7 -0
- package/dist/lib/node/index.cjs +3378 -35
- 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 -12
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/lib/{browser/chunk-UKXIJW43.mjs → node-esm/chunk-4LW7MDPZ.mjs} +76 -36
- package/dist/lib/node-esm/chunk-4LW7MDPZ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +3401 -17
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +4 -4
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/automerge/automerge-host.d.ts +24 -1
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/collection-synchronizer.d.ts +2 -0
- package/dist/types/src/automerge/collection-synchronizer.d.ts.map +1 -1
- package/dist/types/src/automerge/mesh-echo-replicator.d.ts.map +1 -1
- package/dist/types/src/automerge/space-collection.d.ts +3 -2
- package/dist/types/src/automerge/space-collection.d.ts.map +1 -1
- package/dist/types/src/db-host/automerge-metrics.d.ts +11 -0
- package/dist/types/src/db-host/automerge-metrics.d.ts.map +1 -0
- package/dist/types/src/db-host/data-service.d.ts +3 -2
- package/dist/types/src/db-host/data-service.d.ts.map +1 -1
- package/dist/types/src/db-host/database-root.d.ts +20 -0
- package/dist/types/src/db-host/database-root.d.ts.map +1 -0
- package/dist/types/src/db-host/documents-iterator.d.ts +7 -0
- package/dist/types/src/db-host/documents-iterator.d.ts.map +1 -0
- package/dist/types/src/db-host/echo-host.d.ts +73 -0
- package/dist/types/src/db-host/echo-host.d.ts.map +1 -0
- package/dist/types/src/db-host/index.d.ts +5 -0
- package/dist/types/src/db-host/index.d.ts.map +1 -1
- package/dist/types/src/db-host/migration.d.ts +8 -0
- package/dist/types/src/db-host/migration.d.ts.map +1 -0
- package/dist/types/src/db-host/query-service.d.ts +25 -0
- package/dist/types/src/db-host/query-service.d.ts.map +1 -0
- package/dist/types/src/db-host/query-state.d.ts +41 -0
- package/dist/types/src/db-host/query-state.d.ts.map +1 -0
- package/dist/types/src/db-host/space-state-manager.d.ts +23 -0
- package/dist/types/src/db-host/space-state-manager.d.ts.map +1 -0
- package/dist/types/src/edge/echo-edge-replicator.d.ts +23 -0
- package/dist/types/src/edge/echo-edge-replicator.d.ts.map +1 -0
- package/dist/types/src/edge/index.d.ts +2 -0
- package/dist/types/src/edge/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/metadata/metadata-store.d.ts +4 -1
- package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
- package/dist/types/src/testing/test-agent-builder.d.ts.map +1 -1
- package/package.json +36 -43
- package/src/automerge/automerge-host.ts +42 -6
- package/src/automerge/collection-synchronizer.test.ts +3 -1
- package/src/automerge/collection-synchronizer.ts +17 -6
- package/src/automerge/mesh-echo-replicator.ts +2 -1
- package/src/automerge/space-collection.ts +3 -2
- package/src/db-host/automerge-metrics.ts +38 -0
- package/src/db-host/data-service.ts +29 -14
- package/src/db-host/database-root.ts +86 -0
- package/src/db-host/documents-iterator.ts +73 -0
- package/src/db-host/echo-host.ts +257 -0
- package/src/db-host/index.ts +6 -1
- package/src/db-host/migration.ts +57 -0
- package/src/db-host/query-service.ts +208 -0
- package/src/db-host/query-state.ts +200 -0
- package/src/db-host/space-state-manager.ts +90 -0
- package/src/edge/echo-edge-replicator.ts +286 -0
- package/src/edge/index.ts +5 -0
- package/src/index.ts +1 -0
- package/src/metadata/metadata-store.ts +20 -0
- package/src/space/control-pipeline.ts +10 -1
- package/src/testing/test-agent-builder.ts +2 -2
- package/dist/lib/browser/chunk-MPWFDDQK.mjs +0 -2152
- package/dist/lib/browser/chunk-MPWFDDQK.mjs.map +0 -7
- package/dist/lib/browser/chunk-UKXIJW43.mjs.map +0 -7
- package/dist/lib/browser/chunk-XPCF2V5U.mjs +0 -31
- package/dist/lib/browser/chunk-XPCF2V5U.mjs.map +0 -7
- package/dist/lib/browser/light.mjs +0 -32
- package/dist/lib/browser/light.mjs.map +0 -7
- package/dist/lib/node/chunk-5DH4KR2S.cjs +0 -2148
- package/dist/lib/node/chunk-5DH4KR2S.cjs.map +0 -7
- package/dist/lib/node/chunk-7HHYCGUR.cjs.map +0 -7
- package/dist/lib/node/chunk-DZVH7HDD.cjs +0 -43
- package/dist/lib/node/chunk-DZVH7HDD.cjs.map +0 -7
- package/dist/lib/node/light.cjs +0 -52
- package/dist/lib/node/light.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-BZ3FKMCP.mjs +0 -21
- package/dist/lib/node-esm/chunk-BZ3FKMCP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HH4RB7HI.mjs +0 -2150
- package/dist/lib/node-esm/chunk-HH4RB7HI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZWS5AMHO.mjs.map +0 -7
- package/dist/lib/node-esm/light.mjs +0 -31
- package/dist/lib/node-esm/light.mjs.map +0 -7
- package/dist/types/src/light.d.ts +0 -4
- package/dist/types/src/light.d.ts.map +0 -1
- package/src/light.ts +0 -7
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import "@dxos/node-std/globals";
|
|
2
|
+
|
|
3
|
+
// inject-globals:@inject-globals
|
|
1
4
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
5
|
+
global,
|
|
6
|
+
Buffer,
|
|
7
|
+
process
|
|
8
|
+
} from "@dxos/node-std/inject-globals";
|
|
4
9
|
|
|
5
10
|
// packages/core/echo/echo-pipeline/src/common/codec.ts
|
|
6
11
|
import { createCodecEncoding } from "@dxos/hypercore";
|
|
@@ -35,17 +40,34 @@ var createMappedFeedWriter = (mapper, writer) => {
|
|
|
35
40
|
};
|
|
36
41
|
};
|
|
37
42
|
|
|
43
|
+
// packages/core/echo/echo-pipeline/src/common/space-id.ts
|
|
44
|
+
import { subtleCrypto } from "@dxos/crypto";
|
|
45
|
+
import { PublicKey, SpaceId } from "@dxos/keys";
|
|
46
|
+
import { ComplexMap } from "@dxos/util";
|
|
47
|
+
var SPACE_IDS_CACHE = new ComplexMap(PublicKey.hash);
|
|
48
|
+
var createIdFromSpaceKey = async (spaceKey) => {
|
|
49
|
+
const cachedValue = SPACE_IDS_CACHE.get(spaceKey);
|
|
50
|
+
if (cachedValue !== void 0) {
|
|
51
|
+
return cachedValue;
|
|
52
|
+
}
|
|
53
|
+
const digest = await subtleCrypto.digest("SHA-256", spaceKey.asUint8Array());
|
|
54
|
+
const bytes = new Uint8Array(digest).slice(0, SpaceId.byteLength);
|
|
55
|
+
const spaceId = SpaceId.encode(bytes);
|
|
56
|
+
SPACE_IDS_CACHE.set(spaceKey, spaceId);
|
|
57
|
+
return spaceId;
|
|
58
|
+
};
|
|
59
|
+
|
|
38
60
|
// packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts
|
|
39
61
|
import CRC32 from "crc-32";
|
|
40
62
|
import { Event, scheduleTaskInterval, synchronized } from "@dxos/async";
|
|
41
63
|
import { Context } from "@dxos/context";
|
|
42
64
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
43
|
-
import { PublicKey } from "@dxos/keys";
|
|
65
|
+
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
44
66
|
import { log } from "@dxos/log";
|
|
45
67
|
import { DataCorruptionError, STORAGE_VERSION } from "@dxos/protocols";
|
|
46
68
|
import { schema as schema2 } from "@dxos/protocols/proto";
|
|
47
69
|
import { Invitation, SpaceState } from "@dxos/protocols/proto/dxos/client/services";
|
|
48
|
-
import { ComplexMap, arrayToBuffer, forEachAsync, isNotNullOrUndefined } from "@dxos/util";
|
|
70
|
+
import { ComplexMap as ComplexMap2, arrayToBuffer, forEachAsync, isNotNullOrUndefined } from "@dxos/util";
|
|
49
71
|
function _ts_decorate(decorators, target, key, desc) {
|
|
50
72
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
51
73
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -66,12 +88,12 @@ var LargeSpaceMetadata = schema2.getCodecForType("dxos.echo.metadata.LargeSpaceM
|
|
|
66
88
|
var MetadataStore = class {
|
|
67
89
|
constructor(directory) {
|
|
68
90
|
this._metadata = emptyEchoMetadata();
|
|
69
|
-
this._spaceLargeMetadata = new
|
|
91
|
+
this._spaceLargeMetadata = new ComplexMap2(PublicKey2.hash);
|
|
70
92
|
this._metadataFile = void 0;
|
|
71
93
|
this.update = new Event();
|
|
72
94
|
this._invitationCleanupCtx = new Context(void 0, {
|
|
73
95
|
F: __dxlog_file2,
|
|
74
|
-
L:
|
|
96
|
+
L: 55
|
|
75
97
|
});
|
|
76
98
|
this._directory = directory;
|
|
77
99
|
}
|
|
@@ -102,7 +124,7 @@ var MetadataStore = class {
|
|
|
102
124
|
name: file.filename
|
|
103
125
|
}, {
|
|
104
126
|
F: __dxlog_file2,
|
|
105
|
-
L:
|
|
127
|
+
L: 91,
|
|
106
128
|
S: this,
|
|
107
129
|
C: (f, a) => f(...a)
|
|
108
130
|
});
|
|
@@ -138,7 +160,7 @@ var MetadataStore = class {
|
|
|
138
160
|
checksum
|
|
139
161
|
}, {
|
|
140
162
|
F: __dxlog_file2,
|
|
141
|
-
L:
|
|
163
|
+
L: 126,
|
|
142
164
|
S: this,
|
|
143
165
|
C: (f, a) => f(...a)
|
|
144
166
|
});
|
|
@@ -171,7 +193,7 @@ var MetadataStore = class {
|
|
|
171
193
|
err
|
|
172
194
|
}, {
|
|
173
195
|
F: __dxlog_file2,
|
|
174
|
-
L:
|
|
196
|
+
L: 158,
|
|
175
197
|
S: this,
|
|
176
198
|
C: (f, a) => f(...a)
|
|
177
199
|
});
|
|
@@ -188,7 +210,7 @@ var MetadataStore = class {
|
|
|
188
210
|
err
|
|
189
211
|
}, {
|
|
190
212
|
F: __dxlog_file2,
|
|
191
|
-
L:
|
|
213
|
+
L: 170,
|
|
192
214
|
S: this,
|
|
193
215
|
C: (f, a) => f(...a)
|
|
194
216
|
});
|
|
@@ -225,7 +247,7 @@ var MetadataStore = class {
|
|
|
225
247
|
err
|
|
226
248
|
}, {
|
|
227
249
|
F: __dxlog_file2,
|
|
228
|
-
L:
|
|
250
|
+
L: 212,
|
|
229
251
|
S: this,
|
|
230
252
|
C: (f, a) => f(...a)
|
|
231
253
|
});
|
|
@@ -246,7 +268,7 @@ var MetadataStore = class {
|
|
|
246
268
|
const space = this.spaces.find((space2) => space2.key === spaceKey);
|
|
247
269
|
invariant2(space, "Space not found", {
|
|
248
270
|
F: __dxlog_file2,
|
|
249
|
-
L:
|
|
271
|
+
L: 234,
|
|
250
272
|
S: this,
|
|
251
273
|
A: [
|
|
252
274
|
"space",
|
|
@@ -255,6 +277,12 @@ var MetadataStore = class {
|
|
|
255
277
|
});
|
|
256
278
|
return space;
|
|
257
279
|
}
|
|
280
|
+
hasSpace(spaceKey) {
|
|
281
|
+
if (this._metadata.identity?.haloSpace.key.equals(spaceKey)) {
|
|
282
|
+
return true;
|
|
283
|
+
}
|
|
284
|
+
return !!this.spaces.find((space) => space.key === spaceKey);
|
|
285
|
+
}
|
|
258
286
|
_getLargeSpaceMetadata(key) {
|
|
259
287
|
let entry = this._spaceLargeMetadata.get(key);
|
|
260
288
|
if (entry) {
|
|
@@ -270,7 +298,7 @@ var MetadataStore = class {
|
|
|
270
298
|
async clear() {
|
|
271
299
|
log("clearing all metadata", void 0, {
|
|
272
300
|
F: __dxlog_file2,
|
|
273
|
-
L:
|
|
301
|
+
L: 262,
|
|
274
302
|
S: this,
|
|
275
303
|
C: (f, a) => f(...a)
|
|
276
304
|
});
|
|
@@ -283,7 +311,7 @@ var MetadataStore = class {
|
|
|
283
311
|
async setIdentityRecord(record) {
|
|
284
312
|
invariant2(!this._metadata.identity, "Cannot overwrite existing identity in metadata", {
|
|
285
313
|
F: __dxlog_file2,
|
|
286
|
-
L:
|
|
314
|
+
L: 272,
|
|
287
315
|
S: this,
|
|
288
316
|
A: [
|
|
289
317
|
"!this._metadata.identity",
|
|
@@ -313,7 +341,7 @@ var MetadataStore = class {
|
|
|
313
341
|
async addSpace(record) {
|
|
314
342
|
invariant2(!(this._metadata.spaces ?? []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
|
|
315
343
|
F: __dxlog_file2,
|
|
316
|
-
L:
|
|
344
|
+
L: 300,
|
|
317
345
|
S: this,
|
|
318
346
|
A: [
|
|
319
347
|
"!(this._metadata.spaces ?? []).find((space) => space.key === record.key)",
|
|
@@ -357,6 +385,14 @@ var MetadataStore = class {
|
|
|
357
385
|
await this._saveSpaceLargeMetadata(spaceKey);
|
|
358
386
|
await this.flush();
|
|
359
387
|
}
|
|
388
|
+
getSpaceEdgeReplicationSetting(spaceKey) {
|
|
389
|
+
return this.hasSpace(spaceKey) ? this._getSpace(spaceKey).edgeReplication : void 0;
|
|
390
|
+
}
|
|
391
|
+
async setSpaceEdgeReplicationSetting(spaceKey, setting) {
|
|
392
|
+
this._getSpace(spaceKey).edgeReplication = setting;
|
|
393
|
+
await this._save();
|
|
394
|
+
await this.flush();
|
|
395
|
+
}
|
|
360
396
|
};
|
|
361
397
|
_ts_decorate([
|
|
362
398
|
synchronized
|
|
@@ -474,10 +510,10 @@ import { Context as Context2, rejectOnDispose } from "@dxos/context";
|
|
|
474
510
|
import { failUndefined } from "@dxos/debug";
|
|
475
511
|
import { FeedSetIterator } from "@dxos/feed-store";
|
|
476
512
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
477
|
-
import { PublicKey as
|
|
513
|
+
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
478
514
|
import { log as log4 } from "@dxos/log";
|
|
479
515
|
import { Timeframe as Timeframe2 } from "@dxos/timeframe";
|
|
480
|
-
import { ComplexMap as
|
|
516
|
+
import { ComplexMap as ComplexMap3 } from "@dxos/util";
|
|
481
517
|
|
|
482
518
|
// packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
|
|
483
519
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
@@ -628,14 +664,14 @@ var PipelineState = class {
|
|
|
628
664
|
var Pipeline = class {
|
|
629
665
|
constructor() {
|
|
630
666
|
this._timeframeClock = new TimeframeClock(new Timeframe2());
|
|
631
|
-
this._feeds = new
|
|
667
|
+
this._feeds = new ComplexMap3(PublicKey3.hash);
|
|
632
668
|
// External state accessor.
|
|
633
669
|
this._state = new PipelineState(this._feeds, this._timeframeClock);
|
|
634
670
|
// Waits for the message consumer to process the message and yield control back to the pipeline.
|
|
635
671
|
this._processingTrigger = new Trigger().wake();
|
|
636
672
|
this._pauseTrigger = new Trigger().wake();
|
|
637
673
|
// Pending downloads.
|
|
638
|
-
this._downloads = new
|
|
674
|
+
this._downloads = new ComplexMap3((value) => PublicKey3.hash(value.key));
|
|
639
675
|
this._isStopping = false;
|
|
640
676
|
this._isStarted = false;
|
|
641
677
|
this._isBeingConsumed = false;
|
|
@@ -851,7 +887,7 @@ var Pipeline = class {
|
|
|
851
887
|
if (!done) {
|
|
852
888
|
const block = value ?? failUndefined();
|
|
853
889
|
this._processingTrigger.reset();
|
|
854
|
-
this._timeframeClock.updatePendingTimeframe(
|
|
890
|
+
this._timeframeClock.updatePendingTimeframe(PublicKey3.from(block.feedKey), block.seq);
|
|
855
891
|
yield block;
|
|
856
892
|
this._processingTrigger.wake();
|
|
857
893
|
this._timeframeClock.updateTimeframe();
|
|
@@ -1052,7 +1088,7 @@ import { Callback as Callback2 } from "@dxos/util";
|
|
|
1052
1088
|
import { DeferredTask, sleepWithContext as sleepWithContext2, trackLeaks } from "@dxos/async";
|
|
1053
1089
|
import { Context as Context4 } from "@dxos/context";
|
|
1054
1090
|
import { SpaceStateMachine } from "@dxos/credentials";
|
|
1055
|
-
import { PublicKey as
|
|
1091
|
+
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
1056
1092
|
import { log as log6 } from "@dxos/log";
|
|
1057
1093
|
import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1058
1094
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
@@ -1196,7 +1232,7 @@ var ControlPipeline = class {
|
|
|
1196
1232
|
await this._pipeline.unpause();
|
|
1197
1233
|
log6("save snapshot", {
|
|
1198
1234
|
key: this._spaceKey,
|
|
1199
|
-
snapshot
|
|
1235
|
+
snapshot: getSnapshotLoggerContext(snapshot)
|
|
1200
1236
|
}, {
|
|
1201
1237
|
F: __dxlog_file7,
|
|
1202
1238
|
L: 163,
|
|
@@ -1235,7 +1271,7 @@ var ControlPipeline = class {
|
|
|
1235
1271
|
if (msg.data.payload.credential) {
|
|
1236
1272
|
const timer = tracer.mark("dxos.echo.pipeline.control");
|
|
1237
1273
|
const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, {
|
|
1238
|
-
sourceFeed:
|
|
1274
|
+
sourceFeed: PublicKey4.from(msg.feedKey)
|
|
1239
1275
|
});
|
|
1240
1276
|
timer.end();
|
|
1241
1277
|
if (!result) {
|
|
@@ -1312,6 +1348,18 @@ ControlPipeline = _ts_decorate4([
|
|
|
1312
1348
|
trace.resource(),
|
|
1313
1349
|
trackLeaks("start", "stop")
|
|
1314
1350
|
], ControlPipeline);
|
|
1351
|
+
var getSnapshotLoggerContext = (snapshot) => {
|
|
1352
|
+
return snapshot.messages?.map((msg) => {
|
|
1353
|
+
const issuer = msg.credential.issuer;
|
|
1354
|
+
const subject = msg.credential.subject.id;
|
|
1355
|
+
const type = msg.credential.subject.assertion["@type"];
|
|
1356
|
+
return {
|
|
1357
|
+
issuer,
|
|
1358
|
+
subject,
|
|
1359
|
+
type
|
|
1360
|
+
};
|
|
1361
|
+
});
|
|
1362
|
+
};
|
|
1315
1363
|
|
|
1316
1364
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1317
1365
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
@@ -1592,15 +1640,15 @@ var CredentialServerExtension = class extends RpcExtension2 {
|
|
|
1592
1640
|
};
|
|
1593
1641
|
|
|
1594
1642
|
// packages/core/echo/echo-pipeline/src/space/space-protocol.ts
|
|
1595
|
-
import { discoveryKey, subtleCrypto } from "@dxos/crypto";
|
|
1596
|
-
import { PublicKey as
|
|
1643
|
+
import { discoveryKey, subtleCrypto as subtleCrypto2 } from "@dxos/crypto";
|
|
1644
|
+
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1597
1645
|
import { log as log8, logInfo as logInfo2 } from "@dxos/log";
|
|
1598
1646
|
import { MMSTTopology } from "@dxos/network-manager";
|
|
1599
1647
|
import { Teleport } from "@dxos/teleport";
|
|
1600
1648
|
import { BlobSync } from "@dxos/teleport-extension-object-sync";
|
|
1601
1649
|
import { ReplicatorExtension } from "@dxos/teleport-extension-replicator";
|
|
1602
1650
|
import { trace as trace3 } from "@dxos/tracing";
|
|
1603
|
-
import { CallbackCollection, ComplexMap as
|
|
1651
|
+
import { CallbackCollection, ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
1604
1652
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
1605
1653
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1606
1654
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1613,7 +1661,7 @@ var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
|
|
|
1613
1661
|
var SpaceProtocol = class {
|
|
1614
1662
|
constructor({ topic, swarmIdentity, networkManager, onSessionAuth, onAuthFailure, blobStore, disableP2pReplication }) {
|
|
1615
1663
|
this._feeds = /* @__PURE__ */ new Set();
|
|
1616
|
-
this._sessions = new
|
|
1664
|
+
this._sessions = new ComplexMap4(PublicKey5.hash);
|
|
1617
1665
|
// TODO(burdon): Move to config (with sensible defaults).
|
|
1618
1666
|
this._topology = new MMSTTopology({
|
|
1619
1667
|
originateConnections: 4,
|
|
@@ -1629,7 +1677,7 @@ var SpaceProtocol = class {
|
|
|
1629
1677
|
this.blobSync = new BlobSync({
|
|
1630
1678
|
blobStore
|
|
1631
1679
|
});
|
|
1632
|
-
this._topic =
|
|
1680
|
+
this._topic = subtleCrypto2.digest("SHA-256", topic.asBuffer()).then(discoveryKey).then(PublicKey5.from);
|
|
1633
1681
|
this._disableP2pReplication = disableP2pReplication ?? false;
|
|
1634
1682
|
}
|
|
1635
1683
|
get sessions() {
|
|
@@ -1819,10 +1867,10 @@ _ts_decorate6([
|
|
|
1819
1867
|
// packages/core/echo/echo-pipeline/src/space/space-manager.ts
|
|
1820
1868
|
import { synchronized as synchronized4, trackLeaks as trackLeaks3, Trigger as Trigger2 } from "@dxos/async";
|
|
1821
1869
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
1822
|
-
import { PublicKey as
|
|
1870
|
+
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
1823
1871
|
import { log as log9 } from "@dxos/log";
|
|
1824
1872
|
import { trace as trace4 } from "@dxos/protocols";
|
|
1825
|
-
import { ComplexMap as
|
|
1873
|
+
import { ComplexMap as ComplexMap5 } from "@dxos/util";
|
|
1826
1874
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
1827
1875
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1828
1876
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1832,8 +1880,8 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
1832
1880
|
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
|
|
1833
1881
|
var SpaceManager = class {
|
|
1834
1882
|
constructor({ feedStore, networkManager, metadataStore, blobStore, disableP2pReplication }) {
|
|
1835
|
-
this._spaces = new
|
|
1836
|
-
this._instanceId =
|
|
1883
|
+
this._spaces = new ComplexMap5(PublicKey6.hash);
|
|
1884
|
+
this._instanceId = PublicKey6.random().toHex();
|
|
1837
1885
|
this._feedStore = feedStore;
|
|
1838
1886
|
this._networkManager = networkManager;
|
|
1839
1887
|
this._metadataStore = metadataStore;
|
|
@@ -1976,9 +2024,11 @@ SpaceManager = _ts_decorate7([
|
|
|
1976
2024
|
], SpaceManager);
|
|
1977
2025
|
|
|
1978
2026
|
export {
|
|
2027
|
+
Buffer,
|
|
1979
2028
|
codec,
|
|
1980
2029
|
valueEncoding,
|
|
1981
2030
|
createMappedFeedWriter,
|
|
2031
|
+
createIdFromSpaceKey,
|
|
1982
2032
|
MetadataStore,
|
|
1983
2033
|
hasInvitationExpired,
|
|
1984
2034
|
mapTimeframeToFeedIndexes,
|
|
@@ -1997,4 +2047,4 @@ export {
|
|
|
1997
2047
|
SpaceProtocolSession,
|
|
1998
2048
|
SpaceManager
|
|
1999
2049
|
};
|
|
2000
|
-
//# sourceMappingURL=chunk-
|
|
2050
|
+
//# sourceMappingURL=chunk-PESZVYAN.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/common/codec.ts", "../../../src/common/feeds.ts", "../../../src/common/space-id.ts", "../../../src/metadata/metadata-store.ts", "../../../src/pipeline/timeframe-clock.ts", "../../../src/pipeline/pipeline.ts", "../../../src/pipeline/message-selector.ts", "../../../src/space/auth.ts", "../../../src/space/space.ts", "../../../src/space/control-pipeline.ts", "../../../src/space/admission-discovery-extension.ts", "../../../src/space/space-protocol.ts", "../../../src/space/space-manager.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2022 DXOS.org\n//\n\nimport { type Codec } from '@dxos/codec-protobuf';\nimport { createCodecEncoding } from '@dxos/hypercore';\nimport { schema } from '@dxos/protocols/proto';\nimport type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';\n\n/**\n * Codec for feed messages.\n */\nexport const codec: Codec<FeedMessage> = schema.getCodecForType('dxos.echo.feed.FeedMessage');\n\n/**\n * Value encoding used by feed store.\n */\nexport const valueEncoding = createCodecEncoding(codec);\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type FeedWriter } from '@dxos/feed-store';\nimport { invariant } from '@dxos/invariant';\nimport { type MaybePromise } from '@dxos/util';\n\n/**\n * Maps the written arguments onto a different message type.\n */\nexport const createMappedFeedWriter = <Source extends {}, Target extends {}>(\n mapper: (arg: Source) => MaybePromise<Target>,\n writer: FeedWriter<Target>,\n): FeedWriter<Source> => {\n invariant(mapper);\n invariant(writer);\n\n return {\n write: async (data: Source, options) => await writer.write(await mapper(data), options),\n };\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { subtleCrypto } from '@dxos/crypto';\nimport { PublicKey, SpaceId } from '@dxos/keys';\nimport { ComplexMap } from '@dxos/util';\n\nconst SPACE_IDS_CACHE = new ComplexMap<PublicKey, SpaceId>(PublicKey.hash);\n\n/**\n * Space keys are generated by creating a keypair, and then taking the first 20 bytes of the SHA-256 hash of the public key and encoding them to multibase RFC4648 base-32 format (prefixed with B, see Multibase Table).\n * Inspired by how ethereum addresses are derived.\n */\nexport const createIdFromSpaceKey = async (spaceKey: PublicKey): Promise<SpaceId> => {\n const cachedValue = SPACE_IDS_CACHE.get(spaceKey);\n if (cachedValue !== undefined) {\n return cachedValue;\n }\n\n const digest = await subtleCrypto.digest('SHA-256', spaceKey.asUint8Array());\n\n const bytes = new Uint8Array(digest).slice(0, SpaceId.byteLength);\n const spaceId = SpaceId.encode(bytes);\n SPACE_IDS_CACHE.set(spaceKey, spaceId);\n return spaceId;\n};\n", "//\n// Copyright 2021 DXOS.org\n//\n\nimport CRC32 from 'crc-32';\n\nimport { Event, scheduleTaskInterval, synchronized } from '@dxos/async';\nimport { type Codec } from '@dxos/codec-protobuf';\nimport { Context } from '@dxos/context';\nimport { invariant } from '@dxos/invariant';\nimport { PublicKey } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { DataCorruptionError, STORAGE_VERSION } from '@dxos/protocols';\nimport { schema } from '@dxos/protocols/proto';\nimport { Invitation, SpaceState } from '@dxos/protocols/proto/dxos/client/services';\nimport {\n type ControlPipelineSnapshot,\n type EchoMetadata,\n type SpaceMetadata,\n type IdentityRecord,\n type SpaceCache,\n type LargeSpaceMetadata,\n type EdgeReplicationSetting,\n} from '@dxos/protocols/proto/dxos/echo/metadata';\nimport { type Directory, type File } from '@dxos/random-access-storage';\nimport { type Timeframe } from '@dxos/timeframe';\nimport { ComplexMap, arrayToBuffer, forEachAsync, isNotNullOrUndefined } from '@dxos/util';\n\nconst EXPIRED_INVITATION_CLEANUP_INTERVAL = 60 * 60 * 1000; // 1 hour\n\nexport interface AddSpaceOptions {\n key: PublicKey;\n genesisFeed: PublicKey;\n}\n\nconst emptyEchoMetadata = (): EchoMetadata => ({\n version: STORAGE_VERSION,\n spaces: [],\n created: new Date(),\n updated: new Date(),\n});\n\nconst emptyLargeSpaceMetadata = (): LargeSpaceMetadata => ({});\n\nconst EchoMetadata = schema.getCodecForType('dxos.echo.metadata.EchoMetadata');\nconst LargeSpaceMetadata = schema.getCodecForType('dxos.echo.metadata.LargeSpaceMetadata');\n\nexport class MetadataStore {\n private _metadata: EchoMetadata = emptyEchoMetadata();\n private _spaceLargeMetadata = new ComplexMap<PublicKey, LargeSpaceMetadata>(PublicKey.hash);\n\n private _metadataFile?: File = undefined;\n\n public readonly update = new Event<EchoMetadata>();\n private readonly _invitationCleanupCtx = new Context();\n\n /**\n * @internal\n */\n readonly _directory: Directory;\n\n constructor(directory: Directory) {\n this._directory = directory;\n }\n\n get metadata(): EchoMetadata {\n return this._metadata;\n }\n\n get version(): number {\n return this._metadata.version ?? 0;\n }\n\n /**\n * Returns a list of currently saved spaces. The list and objects in it can be modified addSpace and\n * addSpaceFeed functions.\n */\n get spaces(): SpaceMetadata[] {\n return this._metadata.spaces ?? [];\n }\n\n private async _readFile<T>(file: File, codec: Codec<T>): Promise<T | undefined> {\n try {\n const { size: fileLength } = await file.stat();\n if (fileLength < 8) {\n return;\n }\n // Loading file size from first 4 bytes.\n const dataSize = fromBytesInt32(await file.read(0, 4));\n const checksum = fromBytesInt32(await file.read(4, 4));\n log('loaded', { size: dataSize, checksum, name: file.filename });\n\n if (fileLength < dataSize + 8) {\n throw new DataCorruptionError('Metadata size is smaller than expected.', { fileLength, dataSize });\n }\n\n const data = await file.read(8, dataSize);\n\n const calculatedChecksum = CRC32.buf(data);\n if (calculatedChecksum !== checksum) {\n throw new DataCorruptionError('Metadata checksum is invalid.');\n }\n\n return codec.decode(data);\n } finally {\n await file.close();\n }\n }\n\n /**\n * @internal\n */\n async _writeFile<T>(file: File, codec: Codec<T>, data: T): Promise<void> {\n const encoded = arrayToBuffer(codec.encode(data));\n const checksum = CRC32.buf(encoded);\n\n const result = Buffer.alloc(8 + encoded.length);\n\n result.writeInt32LE(encoded.length, 0);\n result.writeInt32LE(checksum, 4);\n encoded.copy(result, 8);\n\n // NOTE: This must be done in one write operation, otherwise the file can be corrupted.\n await file.write(0, result);\n\n log('saved', { size: encoded.length, checksum });\n }\n\n async close() {\n await this._invitationCleanupCtx.dispose();\n await this.flush();\n await this._metadataFile?.close();\n this._metadataFile = undefined;\n this._metadata = emptyEchoMetadata();\n this._spaceLargeMetadata.clear();\n }\n\n /**\n * Loads metadata from persistent storage.\n */\n @synchronized\n async load(): Promise<void> {\n if (!this._metadataFile || this._metadataFile.closed) {\n this._metadataFile = this._directory.getOrCreateFile('EchoMetadata');\n }\n\n try {\n const metadata = await this._readFile(this._metadataFile, EchoMetadata);\n if (metadata) {\n this._metadata = metadata;\n }\n\n // post-processing\n this._metadata.spaces?.forEach((space) => {\n space.state ??= SpaceState.SPACE_ACTIVE;\n });\n } catch (err: any) {\n log.error('failed to load metadata', { err });\n this._metadata = emptyEchoMetadata();\n }\n\n await forEachAsync(\n [this._metadata.identity?.haloSpace.key, ...(this._metadata.spaces?.map((space) => space.key) ?? [])].filter(\n isNotNullOrUndefined,\n ),\n async (key) => {\n try {\n await this._loadSpaceLargeMetadata(key);\n } catch (err: any) {\n log.error('failed to load space large metadata', { err });\n }\n },\n );\n\n // Cleanup expired persistent invitations.\n scheduleTaskInterval(\n this._invitationCleanupCtx,\n async () => {\n for (const invitation of this._metadata.invitations ?? []) {\n if (hasInvitationExpired(invitation) || isLegacyInvitationFormat(invitation)) {\n await this.removeInvitation(invitation.invitationId);\n }\n }\n },\n EXPIRED_INVITATION_CLEANUP_INTERVAL,\n );\n }\n\n @synchronized\n private async _save(): Promise<void> {\n const data: EchoMetadata = {\n ...this._metadata,\n version: STORAGE_VERSION,\n created: this._metadata.created ?? new Date(),\n updated: new Date(),\n };\n this.update.emit(data);\n\n const file = this._directory.getOrCreateFile('EchoMetadata');\n\n await this._writeFile(file, EchoMetadata, data);\n }\n\n private async _loadSpaceLargeMetadata(key: PublicKey): Promise<void> {\n const file = this._directory.getOrCreateFile(`space_${key.toHex()}_large`);\n try {\n const metadata = await this._readFile(file, LargeSpaceMetadata);\n if (metadata) {\n this._spaceLargeMetadata.set(key, metadata);\n }\n } catch (err: any) {\n log.error('failed to load space large metadata', { err });\n }\n }\n\n @synchronized\n private async _saveSpaceLargeMetadata(key: PublicKey): Promise<void> {\n const data = this._getLargeSpaceMetadata(key);\n const file = this._directory.getOrCreateFile(`space_${key.toHex()}_large`);\n await this._writeFile(file, LargeSpaceMetadata, data);\n }\n\n async flush() {\n await this._directory.flush();\n }\n\n _getSpace(spaceKey: PublicKey): SpaceMetadata {\n if (this._metadata.identity?.haloSpace.key.equals(spaceKey)) {\n // Check if the space is the identity space.\n return this._metadata.identity.haloSpace;\n }\n\n const space = this.spaces.find((space) => space.key === spaceKey);\n invariant(space, 'Space not found');\n return space;\n }\n\n hasSpace(spaceKey: PublicKey): boolean {\n if (this._metadata.identity?.haloSpace.key.equals(spaceKey)) {\n // Check if the space is the identity space.\n return true;\n }\n\n return !!this.spaces.find((space) => space.key === spaceKey);\n }\n\n private _getLargeSpaceMetadata(key: PublicKey): LargeSpaceMetadata {\n let entry = this._spaceLargeMetadata.get(key);\n if (entry) {\n return entry;\n }\n\n entry = emptyLargeSpaceMetadata();\n this._spaceLargeMetadata.set(key, entry);\n return entry;\n }\n\n /**\n * Clears storage - doesn't work for now.\n */\n async clear(): Promise<void> {\n log('clearing all metadata');\n await this._directory.delete();\n this._metadata = emptyEchoMetadata();\n }\n\n getIdentityRecord(): IdentityRecord | undefined {\n return this._metadata.identity;\n }\n\n async setIdentityRecord(record: IdentityRecord) {\n invariant(!this._metadata.identity, 'Cannot overwrite existing identity in metadata');\n\n this._metadata.identity = record;\n await this._save();\n await this.flush();\n }\n\n getInvitations(): Invitation[] {\n return this._metadata.invitations ?? [];\n }\n\n async addInvitation(invitation: Invitation) {\n if (this._metadata.invitations?.find((i) => i.invitationId === invitation.invitationId)) {\n return;\n }\n\n (this._metadata.invitations ??= []).push(invitation);\n await this._save();\n await this.flush();\n }\n\n async removeInvitation(invitationId: string) {\n this._metadata.invitations = (this._metadata.invitations ?? []).filter((i) => i.invitationId !== invitationId);\n await this._save();\n await this.flush();\n }\n\n async addSpace(record: SpaceMetadata) {\n invariant(\n !(this._metadata.spaces ?? []).find((space) => space.key === record.key),\n 'Cannot overwrite existing space in metadata',\n );\n\n (this._metadata.spaces ??= []).push(record);\n await this._save();\n await this.flush();\n }\n\n async setSpaceDataLatestTimeframe(spaceKey: PublicKey, timeframe: Timeframe) {\n this._getSpace(spaceKey).dataTimeframe = timeframe;\n await this._save();\n }\n\n async setSpaceControlLatestTimeframe(spaceKey: PublicKey, timeframe: Timeframe) {\n this._getSpace(spaceKey).controlTimeframe = timeframe;\n await this._save();\n await this.flush();\n }\n\n async setCache(spaceKey: PublicKey, cache: SpaceCache) {\n this._getSpace(spaceKey).cache = cache;\n await this._save();\n }\n\n async setWritableFeedKeys(spaceKey: PublicKey, controlFeedKey: PublicKey, dataFeedKey: PublicKey) {\n const space = this._getSpace(spaceKey);\n space.controlFeedKey = controlFeedKey;\n space.dataFeedKey = dataFeedKey;\n await this._save();\n await this.flush();\n }\n\n async setSpaceState(spaceKey: PublicKey, state: SpaceState) {\n this._getSpace(spaceKey).state = state;\n await this._save();\n await this.flush();\n }\n\n getSpaceControlPipelineSnapshot(spaceKey: PublicKey): ControlPipelineSnapshot | undefined {\n return this._getLargeSpaceMetadata(spaceKey).controlPipelineSnapshot;\n }\n\n async setSpaceControlPipelineSnapshot(spaceKey: PublicKey, snapshot: ControlPipelineSnapshot) {\n this._getLargeSpaceMetadata(spaceKey).controlPipelineSnapshot = snapshot;\n await this._saveSpaceLargeMetadata(spaceKey);\n await this.flush();\n }\n\n getSpaceEdgeReplicationSetting(spaceKey: PublicKey): EdgeReplicationSetting | undefined {\n return this.hasSpace(spaceKey) ? this._getSpace(spaceKey).edgeReplication : undefined;\n }\n\n async setSpaceEdgeReplicationSetting(spaceKey: PublicKey, setting: EdgeReplicationSetting) {\n this._getSpace(spaceKey).edgeReplication = setting;\n await this._save();\n await this.flush();\n }\n}\n\nconst fromBytesInt32 = (buf: Buffer) => buf.readInt32LE(0);\n\nexport const hasInvitationExpired = (invitation: Invitation): boolean => {\n return Boolean(\n invitation.created &&\n invitation.lifetime &&\n invitation.lifetime !== 0 &&\n invitation.created.getTime() + invitation.lifetime * 1000 < Date.now(),\n );\n};\n\n// TODO: remove once \"multiuse\" type invitations get removed from local metadata of existing profiles\nconst isLegacyInvitationFormat = (invitation: Invitation): boolean => {\n return invitation.type === Invitation.Type.MULTIUSE;\n};\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { Event } from '@dxos/async';\nimport { timed } from '@dxos/debug';\nimport { type FeedIndex } from '@dxos/feed-store';\nimport { type PublicKey } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { Timeframe } from '@dxos/timeframe';\n\nexport const mapTimeframeToFeedIndexes = (timeframe: Timeframe): FeedIndex[] =>\n timeframe.frames().map(([feedKey, index]) => ({ feedKey, index }));\n\nexport const mapFeedIndexesToTimeframe = (indexes: FeedIndex[]): Timeframe =>\n new Timeframe(indexes.map(({ feedKey, index }) => [feedKey, index]));\n\nexport const startAfter = (timeframe: Timeframe): FeedIndex[] =>\n timeframe.frames().map(([feedKey, index]) => ({ feedKey, index: index + 1 }));\n\n/**\n * Keeps state of the last timeframe that was processed by ECHO.\n */\nexport class TimeframeClock {\n readonly update = new Event<Timeframe>();\n\n private _pendingTimeframe: Timeframe;\n\n constructor(private _timeframe = new Timeframe()) {\n this._pendingTimeframe = _timeframe;\n }\n\n /**\n * Timeframe that was processed by ECHO.\n */\n get timeframe() {\n return this._timeframe;\n }\n\n /**\n * Timeframe that is currently being processed by ECHO.\n * Will be equal to `timeframe` after the processing is complete.\n */\n get pendingTimeframe() {\n return this._pendingTimeframe;\n }\n\n setTimeframe(timeframe: Timeframe) {\n this._timeframe = timeframe;\n this._pendingTimeframe = timeframe;\n this.update.emit(this._timeframe);\n }\n\n updatePendingTimeframe(key: PublicKey, seq: number) {\n this._pendingTimeframe = Timeframe.merge(this._pendingTimeframe, new Timeframe([[key, seq]]));\n }\n\n updateTimeframe() {\n this._timeframe = this._pendingTimeframe;\n this.update.emit(this._timeframe);\n }\n\n hasGaps(timeframe: Timeframe) {\n const gaps = Timeframe.dependencies(timeframe, this._timeframe);\n return !gaps.isEmpty();\n }\n\n @timed(5_000)\n async waitUntilReached(target: Timeframe) {\n log('waitUntilReached', { target, current: this._timeframe });\n await this.update.waitForCondition(() => {\n log('check if reached', {\n target,\n current: this._timeframe,\n deps: Timeframe.dependencies(target, this._timeframe),\n });\n\n return Timeframe.dependencies(target, this._timeframe).isEmpty();\n });\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { Event, sleepWithContext, synchronized, Trigger } from '@dxos/async';\nimport { Context, rejectOnDispose } from '@dxos/context';\nimport { failUndefined } from '@dxos/debug';\nimport { FeedSetIterator, type FeedWrapper, type FeedWriter } from '@dxos/feed-store';\nimport { invariant } from '@dxos/invariant';\nimport { PublicKey } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { type FeedMessageBlock } from '@dxos/protocols';\nimport type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';\nimport { Timeframe } from '@dxos/timeframe';\nimport { ComplexMap } from '@dxos/util';\n\nimport { createMessageSelector } from './message-selector';\nimport { mapFeedIndexesToTimeframe, startAfter, TimeframeClock } from './timeframe-clock';\nimport { createMappedFeedWriter } from '../common';\n\nexport type WaitUntilReachedTargetParams = {\n /**\n * For cancellation.\n */\n ctx?: Context;\n timeout?: number;\n\n /**\n * @default true\n */\n breakOnStall?: boolean;\n};\n\n/**\n * External state accessor.\n */\nexport class PipelineState {\n /**\n * @internal\n */\n _ctx = new Context();\n\n // TODO(dmaretskyi): Remove?.\n public readonly timeframeUpdate = this._timeframeClock.update;\n\n public readonly stalled = new Event();\n\n /**\n * @internal\n */\n _startTimeframe: Timeframe = new Timeframe();\n\n /**\n * Target timeframe we are waiting to reach.\n */\n private _targetTimeframe: Timeframe | undefined;\n\n /**\n * @internal\n */\n _reachedTargetPromise: Promise<void> | undefined;\n\n /**\n * @internal\n */\n _reachedTarget: boolean = false;\n\n constructor(\n private _feeds: ComplexMap<PublicKey, FeedWrapper<FeedMessage>>,\n private _timeframeClock: TimeframeClock,\n ) {}\n\n /**\n * Latest theoretical timeframe based on the last mutation in each feed.\n * NOTE: This might never be reached if the mutation dependencies\n */\n // TODO(dmaretskyi): Rename `totalTimeframe`? or `lastTimeframe`.\n get endTimeframe() {\n return mapFeedIndexesToTimeframe(\n Array.from(this._feeds.values())\n .filter((feed) => feed.length > 0)\n .map((feed) => ({\n feedKey: feed.key,\n index: feed.length - 1,\n })),\n );\n }\n\n get startTimeframe() {\n return this._startTimeframe;\n }\n\n get timeframe() {\n return this._timeframeClock.timeframe;\n }\n\n get pendingTimeframe() {\n return this._timeframeClock.pendingTimeframe;\n }\n\n get targetTimeframe() {\n return this._targetTimeframe ? this._targetTimeframe : new Timeframe();\n }\n\n get reachedTarget() {\n return this._reachedTarget;\n }\n\n get feeds() {\n return Array.from(this._feeds.values());\n }\n\n async waitUntilTimeframe(target: Timeframe) {\n await this._timeframeClock.waitUntilReached(target);\n }\n\n setTargetTimeframe(target: Timeframe) {\n this._targetTimeframe = target;\n }\n\n /**\n * Wait until the pipeline processes all messages in the feed and reaches the target timeframe if that is set.\n *\n * This function will resolve immediately if the pipeline is stalled.\n *\n * @param timeout Timeout in milliseconds to specify the maximum wait time.\n */\n async waitUntilReachedTargetTimeframe({\n ctx = new Context(),\n timeout,\n breakOnStall = true,\n }: WaitUntilReachedTargetParams = {}) {\n log('waitUntilReachedTargetTimeframe', {\n timeout,\n current: this.timeframe,\n target: this.targetTimeframe,\n });\n\n this._reachedTargetPromise ??= Promise.race([\n this._timeframeClock.update.waitForCondition(() => {\n return Timeframe.dependencies(this.targetTimeframe, this.timeframe).isEmpty();\n }),\n ...(breakOnStall ? [this.stalled.discardParameter().waitForCount(1)] : []),\n ]);\n\n let done = false;\n\n if (timeout) {\n return Promise.race([\n rejectOnDispose(ctx),\n rejectOnDispose(this._ctx),\n this._reachedTargetPromise.then(() => {\n done = true;\n this._reachedTarget = true;\n }),\n sleepWithContext(this._ctx, timeout).then(() => {\n if (done) {\n return;\n }\n\n log.warn('waitUntilReachedTargetTimeframe timed out', {\n timeout,\n current: this.timeframe,\n target: this.targetTimeframe,\n dependencies: Timeframe.dependencies(this.targetTimeframe, this.timeframe),\n });\n }),\n ]);\n } else {\n return this._reachedTargetPromise;\n }\n }\n}\n\n// TODO(mykola): Extract to `@dxos/echo-protocol`\nexport interface PipelineAccessor {\n state: PipelineState;\n writer: FeedWriter<FeedMessage.Payload>;\n}\n\n/**\n * A multi-reader pipeline that operates on feeds.\n * Might have a single writable feed.\n * Has a timeframe clock to handle message ordering.\n *\n * NOTE:\n * - Feeds passed in must have value encoding consistent with the type expected by the iterator/writer.\n *\n * # Usage examples\n *\n * ## Create a new space.\n *\n * 1. Generate space key, genesis feed key.\n * 2. Create and open pipeline reading from {}.\n * 3. Create and add the writable genesis feed.\n * 4. Write the initial sequence of control and credential messages.\n *\n * ## Load an existing space from storage\n *\n * 1. Load space key, genesis feed key, get starting timeframe from saved snapshot.\n * 2. Create and open pipeline reading from the initial timeframe.\n * 3. Open and add the genesis feed.\n * 4. Once the writable feed is added, the pipeline becomes writable.\n *\n * ## Join an existing space created by another agent/device.\n *\n * 1. Get the space key, genesis feed key from another agent.\n * 2. (optionally) Download the snapshot from another agent.\n * 3. Create and open pipeline.\n * 4. Generate the writable feed key.\n * 5. Wait for the writable feed to be added.\n */\nexport class Pipeline implements PipelineAccessor {\n private readonly _timeframeClock = new TimeframeClock(new Timeframe());\n private readonly _feeds = new ComplexMap<PublicKey, FeedWrapper<FeedMessage>>(PublicKey.hash);\n\n // External state accessor.\n private readonly _state: PipelineState = new PipelineState(this._feeds, this._timeframeClock);\n\n // Waits for the message consumer to process the message and yield control back to the pipeline.\n private readonly _processingTrigger = new Trigger().wake();\n private readonly _pauseTrigger = new Trigger().wake();\n\n // Pending downloads.\n private readonly _downloads = new ComplexMap<FeedWrapper<FeedMessage>, any>((value) => PublicKey.hash(value.key));\n\n // Inbound feed stream.\n private _feedSetIterator?: FeedSetIterator<FeedMessage>;\n\n // Outbound feed writer.\n private _writer: FeedWriter<FeedMessage.Payload> | undefined;\n\n private _isStopping = false;\n private _isStarted = false;\n private _isBeingConsumed = false;\n private _isPaused = false;\n\n get state() {\n return this._state;\n }\n\n get writer(): FeedWriter<FeedMessage.Payload> {\n invariant(this._writer, 'Writer not set.');\n return this._writer;\n }\n\n hasFeed(feedKey: PublicKey) {\n return this._feeds.has(feedKey);\n }\n\n getFeeds(): FeedWrapper<FeedMessage>[] {\n return this._feedSetIterator!.feeds;\n }\n\n // NOTE: This cannot be synchronized with `stop` because stop waits for the mutation processing to complete,\n // which might be opening feeds during the mutation processing, which w\n async addFeed(feed: FeedWrapper<FeedMessage>) {\n this._feeds.set(feed.key, feed);\n\n if (this._feedSetIterator) {\n await this._feedSetIterator.addFeed(feed);\n }\n\n if (this._isStarted && !this._isPaused) {\n this._setFeedDownloadState(feed);\n }\n }\n\n setWriteFeed(feed: FeedWrapper<FeedMessage>) {\n invariant(!this._writer, 'Writer already set.');\n invariant(feed.properties.writable, 'Feed must be writable.');\n\n this._writer = createMappedFeedWriter<FeedMessage.Payload, FeedMessage>(\n (payload: FeedMessage.Payload) => ({\n timeframe: this._timeframeClock.timeframe,\n payload,\n }),\n feed.createFeedWriter(),\n );\n }\n\n @synchronized\n async start() {\n invariant(!this._isStarted, 'Pipeline is already started.');\n log('starting...');\n await this._initIterator();\n await this._feedSetIterator!.open();\n this._isStarted = true;\n log('started');\n\n if (!this._isPaused) {\n for (const feed of this._feeds.values()) {\n this._setFeedDownloadState(feed);\n }\n }\n }\n\n @synchronized\n async stop() {\n log('stopping...');\n this._isStopping = true;\n for (const [feed, handle] of this._downloads.entries()) {\n feed.undownload(handle);\n }\n this._downloads.clear();\n await this._feedSetIterator?.close();\n await this._processingTrigger.wait(); // Wait for the in-flight message to be processed.\n await this._state._ctx.dispose();\n this._state._ctx = new Context();\n this._state._reachedTargetPromise = undefined;\n this._state._reachedTarget = false;\n this._isStarted = false;\n log('stopped');\n }\n\n /**\n * @param timeframe Timeframe of already processed messages.\n * The pipeline will start processing messages AFTER this timeframe.\n */\n @synchronized\n async setCursor(timeframe: Timeframe) {\n invariant(!this._isStarted || this._isPaused, 'Invalid state.');\n\n this._state._startTimeframe = timeframe;\n this._timeframeClock.setTimeframe(timeframe);\n\n // Cancel downloads of mutations before the cursor.\n if (this._feedSetIterator) {\n await this._feedSetIterator.close();\n await this._initIterator();\n await this._feedSetIterator.open();\n }\n }\n\n /**\n * Calling pause while processing will cause a deadlock.\n */\n @synchronized\n async pause() {\n if (this._isPaused) {\n return;\n }\n\n this._pauseTrigger.reset();\n await this._processingTrigger.wait();\n this._isPaused = true;\n }\n\n @synchronized\n async unpause() {\n invariant(this._isPaused, 'Pipeline is not paused.');\n\n this._pauseTrigger.wake();\n this._isPaused = false;\n\n for (const feed of this._feeds.values()) {\n this._setFeedDownloadState(feed);\n }\n }\n\n /**\n * Starts to iterate over the ordered messages from the added feeds.\n * Updates the timeframe clock after the message has bee processed.\n */\n async *consume(): AsyncIterable<FeedMessageBlock> {\n invariant(!this._isBeingConsumed, 'Pipeline is already being consumed.');\n this._isBeingConsumed = true;\n\n invariant(this._feedSetIterator, 'Iterator not initialized.');\n let lastFeedSetIterator = this._feedSetIterator;\n let iterable = lastFeedSetIterator[Symbol.asyncIterator]();\n\n while (!this._isStopping) {\n await this._pauseTrigger.wait();\n\n // Iterator might have been changed while we were waiting for the processing to complete.\n if (lastFeedSetIterator !== this._feedSetIterator) {\n invariant(this._feedSetIterator, 'Iterator not initialized.');\n lastFeedSetIterator = this._feedSetIterator;\n iterable = lastFeedSetIterator[Symbol.asyncIterator]();\n }\n\n // Will be canceled when the iterator gets closed.\n const { done, value } = await iterable.next();\n if (!done) {\n const block = value ?? failUndefined();\n this._processingTrigger.reset();\n this._timeframeClock.updatePendingTimeframe(PublicKey.from(block.feedKey), block.seq);\n yield block;\n this._processingTrigger.wake();\n this._timeframeClock.updateTimeframe();\n }\n }\n\n // TODO(burdon): Test re-entrant?\n this._isBeingConsumed = false;\n }\n\n private _setFeedDownloadState(feed: FeedWrapper<FeedMessage>) {\n let handle = this._downloads.get(feed); // TODO(burdon): Always undefined?\n if (handle) {\n feed.undownload(handle);\n }\n\n const timeframe = this._state._startTimeframe;\n const seq = timeframe.get(feed.key) ?? -1;\n log('download', { feed: feed.key.truncate(), seq, length: feed.length });\n handle = feed.download({ start: seq + 1, linear: true }, (err: any, data: any) => {\n if (err) {\n // log.warn(err); // TODO(burdon): Feed is closed/Download was cancelled.\n } else {\n log.info('downloaded', { data }); // TODO(burdon): Never called.\n }\n });\n\n this._downloads.set(feed, handle);\n }\n\n private async _initIterator() {\n this._feedSetIterator = new FeedSetIterator<FeedMessage>(createMessageSelector(this._timeframeClock), {\n start: startAfter(this._timeframeClock.timeframe),\n stallTimeout: 1000,\n });\n\n this._feedSetIterator.stalled.on((iterator) => {\n log.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`);\n this._state.stalled.emit();\n });\n\n for (const feed of this._feeds.values()) {\n await this._feedSetIterator.addFeed(feed);\n }\n }\n}\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { type FeedBlock, type FeedBlockSelector } from '@dxos/feed-store';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';\n\nimport { type TimeframeClock } from './timeframe-clock';\n\n/**\n * The MessageSelector makes sure that we read in a trusted order.\n * The first message we wish to process is the SpaceGenesis, which will admit a Feed.\n * As we encounter and process FeedAdmit messages those are added to the Space's trust,\n * and we begin processing messages from them as well.\n */\nexport const createMessageSelector = (timeframeClock: TimeframeClock): FeedBlockSelector<FeedMessage> => {\n return (messages: FeedBlock<FeedMessage>[]) => {\n // Pick the first candidate with a valid timeframe that has no gaps.\n for (let i = 0; i < messages.length; i++) {\n const {\n data: { timeframe },\n } = messages[i];\n invariant(timeframe);\n\n if (!timeframeClock.hasGaps(timeframe)) {\n return i;\n }\n }\n\n // Not ready for this message yet.\n log('Skipping...');\n };\n};\n", "//\n// Copyright 2019 DXOS.org\n//\n\nimport { runInContext, scheduleTask } from '@dxos/async';\nimport { Context } from '@dxos/context';\nimport { randomBytes } from '@dxos/crypto';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\nimport { schema } from '@dxos/protocols/proto';\nimport { type AuthService } from '@dxos/protocols/proto/dxos/mesh/teleport/auth';\nimport { type ExtensionContext, RpcExtension } from '@dxos/teleport';\n\nexport type AuthProvider = (nonce: Uint8Array) => Promise<Uint8Array | undefined>;\n\nexport type AuthVerifier = (nonce: Uint8Array, credential: Uint8Array) => Promise<boolean>;\n\nexport type AuthExtensionParams = {\n provider: AuthProvider;\n verifier: AuthVerifier;\n onAuthSuccess: () => void;\n onAuthFailure: () => void;\n};\n\nexport class AuthExtension extends RpcExtension<Services, Services> {\n private readonly _ctx = new Context({\n onError: (err) => {\n log.catch(err);\n },\n });\n\n constructor(private readonly _authParams: AuthExtensionParams) {\n super({\n requested: {\n AuthService: schema.getService('dxos.mesh.teleport.auth.AuthService'),\n },\n exposed: {\n AuthService: schema.getService('dxos.mesh.teleport.auth.AuthService'),\n },\n timeout: 60 * 1000, // Long timeout because auth can wait for sync in certain cases.\n });\n }\n\n protected async getHandlers(): Promise<Services> {\n return {\n AuthService: {\n authenticate: async ({ challenge }) => {\n try {\n const credential = await this._authParams.provider(challenge);\n if (!credential) {\n throw new Error('auth rejected');\n }\n return { credential };\n } catch (err) {\n log.error('failed to generate auth credentials', err);\n throw new Error('auth rejected');\n }\n },\n },\n };\n }\n\n override async onOpen(context: ExtensionContext): Promise<void> {\n await super.onOpen(context);\n scheduleTask(this._ctx, async () => {\n try {\n const challenge = randomBytes(32);\n const { credential } = await this.rpc.AuthService.authenticate({ challenge });\n invariant(credential?.length > 0, 'invalid credential');\n const success = await this._authParams.verifier(challenge, credential);\n invariant(success, 'credential not verified');\n runInContext(this._ctx, () => this._authParams.onAuthSuccess());\n } catch (err) {\n log('auth failed', err);\n this.close();\n this._authParams.onAuthFailure();\n }\n });\n }\n\n override async onClose(): Promise<void> {\n await this._ctx.dispose();\n await super.onClose();\n }\n\n override async onAbort(): Promise<void> {\n await this._ctx.dispose();\n await super.onAbort();\n }\n}\n\ntype Services = { AuthService: AuthService };\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { Event, scheduleMicroTask, synchronized, trackLeaks } from '@dxos/async';\nimport { type Context, Resource } from '@dxos/context';\nimport { type DelegateInvitationCredential, type FeedInfo, type MemberInfo } from '@dxos/credentials';\nimport { type FeedOptions, type FeedWrapper } from '@dxos/feed-store';\nimport { invariant } from '@dxos/invariant';\nimport { type PublicKey, type SpaceId } from '@dxos/keys';\nimport { log, logInfo } from '@dxos/log';\nimport type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';\nimport { AdmittedFeed, type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';\nimport { type Timeframe } from '@dxos/timeframe';\nimport { trace } from '@dxos/tracing';\nimport { type AsyncCallback, Callback } from '@dxos/util';\n\nimport { ControlPipeline } from './control-pipeline';\nimport { type SpaceProtocol } from './space-protocol';\nimport { type MetadataStore } from '../metadata';\nimport { type PipelineAccessor } from '../pipeline';\n\n// TODO(burdon): Factor out?\ntype FeedProvider = (feedKey: PublicKey, opts?: FeedOptions) => Promise<FeedWrapper<FeedMessage>>;\n\nexport type SpaceParams = {\n id: SpaceId;\n spaceKey: PublicKey;\n protocol: SpaceProtocol;\n genesisFeed: FeedWrapper<FeedMessage>;\n feedProvider: FeedProvider;\n metadataStore: MetadataStore;\n memberKey: PublicKey;\n\n // TODO(dmaretskyi): Superseded by epochs.\n snapshotId?: string | undefined;\n\n onDelegatedInvitationStatusChange: (invitation: DelegateInvitationCredential, isActive: boolean) => Promise<void>;\n onMemberRolesChanged: (member: MemberInfo[]) => Promise<void>;\n};\n\nexport type CreatePipelineParams = {\n start: Timeframe;\n // designation: AdmittedFeed.Designation;\n};\n\n/**\n * Spaces are globally addressable databases with access control.\n */\n// TODO(dmaretskyi): Extract database stuff.\n@trackLeaks('open', 'close')\n@trace.resource()\nexport class Space extends Resource {\n public readonly onCredentialProcessed = new Callback<AsyncCallback<Credential>>();\n public readonly stateUpdate = new Event();\n @trace.info()\n public readonly protocol: SpaceProtocol;\n\n private readonly _id: SpaceId;\n private readonly _key: PublicKey;\n private readonly _genesisFeedKey: PublicKey;\n private readonly _feedProvider: FeedProvider;\n @trace.info()\n private readonly _controlPipeline: ControlPipeline;\n\n private _controlFeed?: FeedWrapper<FeedMessage>;\n private _dataFeed?: FeedWrapper<FeedMessage>;\n\n constructor(params: SpaceParams) {\n super();\n invariant(params.spaceKey && params.feedProvider);\n this._id = params.id;\n this._key = params.spaceKey;\n this._genesisFeedKey = params.genesisFeed.key;\n this._feedProvider = params.feedProvider;\n\n this._controlPipeline = new ControlPipeline({\n spaceKey: params.spaceKey,\n genesisFeed: params.genesisFeed,\n feedProvider: params.feedProvider,\n metadataStore: params.metadataStore,\n });\n\n // TODO(dmaretskyi): Feed set abstraction.\n this._controlPipeline.onFeedAdmitted.set(async (info) => {\n // Enable sparse replication to not download mutations covered by prior epochs.\n const sparse = info.assertion.designation === AdmittedFeed.Designation.DATA;\n\n if (!info.key.equals(params.genesisFeed.key)) {\n scheduleMicroTask(this._ctx, async () => {\n await this.protocol.addFeed(await params.feedProvider(info.key, { sparse }));\n });\n }\n });\n\n this._controlPipeline.onCredentialProcessed.set(async (credential) => {\n await this.onCredentialProcessed.callIfSet(credential);\n log('onCredentialProcessed', { credential });\n this.stateUpdate.emit();\n });\n this._controlPipeline.onDelegatedInvitation.set(async (invitation) => {\n log('onDelegatedInvitation', { invitation });\n await params.onDelegatedInvitationStatusChange(invitation, true);\n });\n this._controlPipeline.onDelegatedInvitationRemoved.set(async (invitation) => {\n log('onDelegatedInvitationRemoved', { invitation });\n await params.onDelegatedInvitationStatusChange(invitation, false);\n });\n this._controlPipeline.onMemberRoleChanged.set(async (changedMembers) => {\n log('onMemberRoleChanged', () => ({ changedMembers: changedMembers.map((m) => [m.key, m.role]) }));\n await params.onMemberRolesChanged(changedMembers);\n });\n\n // Start replicating the genesis feed.\n this.protocol = params.protocol;\n }\n\n @logInfo\n @trace.info()\n get id() {\n return this._id;\n }\n\n @logInfo\n @trace.info()\n get key() {\n return this._key;\n }\n\n get genesisFeedKey(): PublicKey {\n return this._genesisFeedKey;\n }\n\n get controlFeedKey() {\n return this._controlFeed?.key;\n }\n\n get dataFeedKey() {\n return this._dataFeed?.key;\n }\n\n get spaceState() {\n return this._controlPipeline.spaceState;\n }\n\n /**\n * @test-only\n */\n get controlPipeline(): PipelineAccessor {\n return this._controlPipeline.pipeline;\n }\n\n async setControlFeed(feed: FeedWrapper<FeedMessage>) {\n invariant(!this._controlFeed, 'Control feed already set.');\n this._controlFeed = feed;\n await this._controlPipeline.setWriteFeed(feed);\n return this;\n }\n\n async setDataFeed(feed: FeedWrapper<FeedMessage>) {\n invariant(!this._dataFeed, 'Data feed already set.');\n this._dataFeed = feed;\n return this;\n }\n\n /**\n * Use for diagnostics.\n */\n getControlFeeds(): FeedInfo[] {\n return Array.from(this._controlPipeline.spaceState.feeds.values());\n }\n\n @trace.span()\n protected override async _open(ctx: Context) {\n log('opening...');\n\n // Order is important.\n await this._controlPipeline.start();\n await this.protocol.start();\n await this.protocol.addFeed(await this._feedProvider(this._genesisFeedKey));\n\n log('opened');\n }\n\n @synchronized\n protected override async _close() {\n log('closing...', { key: this._key });\n\n // Closes in reverse order to open.\n await this.protocol.stop();\n await this._controlPipeline.stop();\n\n log('closed');\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { DeferredTask, sleepWithContext, trackLeaks } from '@dxos/async';\nimport { Context } from '@dxos/context';\nimport {\n SpaceStateMachine,\n type SpaceState,\n type MemberInfo,\n type FeedInfo,\n type DelegateInvitationCredential,\n} from '@dxos/credentials';\nimport { type FeedWrapper } from '@dxos/feed-store';\nimport { PublicKey } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { type FeedMessageBlock } from '@dxos/protocols';\nimport type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';\nimport { type ControlPipelineSnapshot } from '@dxos/protocols/proto/dxos/echo/metadata';\nimport { AdmittedFeed, type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';\nimport { Timeframe } from '@dxos/timeframe';\nimport { TimeSeriesCounter, TimeUsageCounter, trace } from '@dxos/tracing';\nimport { type AsyncCallback, Callback, tracer } from '@dxos/util';\n\nimport { type MetadataStore } from '../metadata';\nimport { Pipeline, type PipelineAccessor } from '../pipeline';\n\nexport type ControlPipelineParams = {\n spaceKey: PublicKey;\n genesisFeed: FeedWrapper<FeedMessage>;\n feedProvider: (feedKey: PublicKey) => Promise<FeedWrapper<FeedMessage>>;\n metadataStore: MetadataStore;\n};\n\nconst TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;\n\nconst CONTROL_PIPELINE_SNAPSHOT_DELAY = 10_000;\n\nconst USE_SNAPSHOTS = true;\n\n/**\n * Processes HALO credentials, which include genesis and invitations.\n */\n@trace.resource()\n@trackLeaks('start', 'stop')\nexport class ControlPipeline {\n private readonly _ctx = new Context();\n private readonly _pipeline: Pipeline;\n private readonly _spaceStateMachine: SpaceStateMachine;\n\n private readonly _spaceKey: PublicKey;\n private readonly _metadata: MetadataStore;\n private _targetTimeframe?: Timeframe;\n private _lastTimeframeSaveTime: number = Date.now();\n\n public readonly onFeedAdmitted = new Callback<AsyncCallback<FeedInfo>>();\n public readonly onMemberRoleChanged: Callback<AsyncCallback<MemberInfo[]>>;\n public readonly onCredentialProcessed: Callback<AsyncCallback<Credential>>;\n public readonly onDelegatedInvitation: Callback<AsyncCallback<DelegateInvitationCredential>>;\n public readonly onDelegatedInvitationRemoved: Callback<AsyncCallback<DelegateInvitationCredential>>;\n\n @trace.metricsCounter()\n private _usage = new TimeUsageCounter();\n\n @trace.metricsCounter()\n private _mutations = new TimeSeriesCounter();\n\n private _snapshotTask = new DeferredTask(this._ctx, async () => {\n await sleepWithContext(this._ctx, CONTROL_PIPELINE_SNAPSHOT_DELAY);\n await this._saveSnapshot();\n });\n\n constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }: ControlPipelineParams) {\n this._spaceKey = spaceKey;\n this._metadata = metadataStore;\n this._pipeline = new Pipeline();\n void this._pipeline.addFeed(genesisFeed); // TODO(burdon): Require async open/close?\n\n this._spaceStateMachine = new SpaceStateMachine(spaceKey);\n this._spaceStateMachine.onFeedAdmitted.set(async (info) => {\n // log('feed admitted', { info });\n log('feed admitted', { key: info.key });\n\n // TODO(burdon): Check not stopping.\n if (info.assertion.designation === AdmittedFeed.Designation.CONTROL && !info.key.equals(genesisFeed.key)) {\n queueMicrotask(async () => {\n try {\n const feed = await feedProvider(info.key);\n if (!this._pipeline.hasFeed(feed.key)) {\n await this._pipeline.addFeed(feed);\n }\n } catch (err: any) {\n log.catch(err);\n }\n });\n }\n\n await this.onFeedAdmitted.callIfSet(info);\n });\n\n this.onMemberRoleChanged = this._spaceStateMachine.onMemberRoleChanged;\n this.onCredentialProcessed = this._spaceStateMachine.onCredentialProcessed;\n this.onDelegatedInvitation = this._spaceStateMachine.onDelegatedInvitation;\n this.onDelegatedInvitationRemoved = this._spaceStateMachine.onDelegatedInvitationRemoved;\n }\n\n get spaceState(): SpaceState {\n return this._spaceStateMachine;\n }\n\n get pipeline(): PipelineAccessor {\n return this._pipeline;\n }\n\n async setWriteFeed(feed: FeedWrapper<FeedMessage>) {\n await this._pipeline.addFeed(feed);\n this._pipeline.setWriteFeed(feed);\n }\n\n @trace.span({ showInBrowserTimeline: true })\n async start() {\n const snapshot = this._metadata.getSpaceControlPipelineSnapshot(this._spaceKey);\n log('load snapshot', { key: this._spaceKey, present: !!snapshot, tf: snapshot?.timeframe });\n if (USE_SNAPSHOTS && snapshot) {\n await this._processSnapshot(snapshot);\n }\n\n log('starting...');\n setTimeout(async () => {\n void this._consumePipeline(new Context());\n });\n\n await this._pipeline.start();\n log('started');\n }\n\n private async _processSnapshot(snapshot: ControlPipelineSnapshot) {\n await this._pipeline.setCursor(snapshot.timeframe);\n\n for (const message of snapshot.messages ?? []) {\n const result = await this._spaceStateMachine.process(message.credential, {\n sourceFeed: message.feedKey,\n skipVerification: true,\n });\n\n if (!result) {\n log.warn('credential processing failed from snapshot', { message });\n }\n }\n }\n\n private async _saveSnapshot() {\n await this._pipeline.pause();\n const snapshot: ControlPipelineSnapshot = {\n timeframe: this._pipeline.state.timeframe,\n messages: this._spaceStateMachine.credentialEntries.map((entry) => ({\n feedKey: entry.sourceFeed,\n credential: entry.credential,\n })),\n };\n await this._pipeline.unpause();\n\n log('save snapshot', { key: this._spaceKey, snapshot: getSnapshotLoggerContext(snapshot) });\n await this._metadata.setSpaceControlPipelineSnapshot(this._spaceKey, snapshot);\n }\n\n @trace.span()\n private async _consumePipeline(ctx: Context) {\n for await (const msg of this._pipeline.consume()) {\n const span = this._usage.beginRecording();\n this._mutations.inc();\n\n try {\n await this._processMessage(ctx, msg);\n } catch (err: any) {\n log.catch(err);\n }\n\n span.end();\n }\n }\n\n @trace.span()\n private async _processMessage(ctx: Context, msg: FeedMessageBlock) {\n // log('processing', { msg });\n log('processing', { key: msg.feedKey, seq: msg.seq });\n if (msg.data.payload.credential) {\n const timer = tracer.mark('dxos.echo.pipeline.control');\n const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, {\n sourceFeed: PublicKey.from(msg.feedKey),\n });\n\n timer.end();\n if (!result) {\n log.warn('processing failed', { msg });\n } else {\n await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);\n }\n\n this._snapshotTask.schedule();\n }\n }\n\n private async _noteTargetStateIfNeeded(timeframe: Timeframe) {\n // TODO(dmaretskyi): Replace this with a proper debounce/throttle.\n\n if (Date.now() - this._lastTimeframeSaveTime > TIMEFRAME_SAVE_DEBOUNCE_INTERVAL) {\n this._lastTimeframeSaveTime = Date.now();\n\n await this._saveTargetTimeframe(timeframe);\n }\n }\n\n async stop() {\n log('stopping...');\n await this._ctx.dispose();\n await this._pipeline.stop();\n await this._saveTargetTimeframe(this._pipeline.state.timeframe);\n log('stopped');\n }\n\n private async _saveTargetTimeframe(timeframe: Timeframe) {\n try {\n const newTimeframe = Timeframe.merge(this._targetTimeframe ?? new Timeframe(), timeframe);\n await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);\n this._targetTimeframe = newTimeframe;\n } catch (err: any) {\n log(err);\n }\n }\n}\n\nconst getSnapshotLoggerContext = (snapshot: ControlPipelineSnapshot) => {\n return snapshot.messages?.map((msg) => {\n const issuer = msg.credential.issuer;\n const subject = msg.credential.subject.id;\n const type = msg.credential.subject.assertion['@type'];\n return { issuer, subject, type };\n });\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { scheduleTask, type Trigger } from '@dxos/async';\nimport { Context } from '@dxos/context';\nimport { ProtocolError } from '@dxos/protocols';\nimport { schema } from '@dxos/protocols/proto';\nimport { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';\nimport {\n type AdmissionDiscoveryService,\n type GetAdmissionCredentialResponse,\n type GetAdmissionCredentialRequest,\n} from '@dxos/protocols/proto/dxos/mesh/teleport';\nimport { type ExtensionContext, RpcExtension } from '@dxos/teleport';\n\nimport { type Space } from './space';\n\n/**\n * Guest's side for a connection to a concrete peer in p2p network during invitation.\n */\nexport class CredentialRetrieverExtension extends RpcExtension<\n { AdmissionDiscoveryService: AdmissionDiscoveryService },\n {}\n> {\n private _ctx = new Context();\n\n constructor(\n private readonly _request: GetAdmissionCredentialRequest,\n private readonly _onResult: Trigger<Credential>,\n ) {\n super({\n requested: {\n AdmissionDiscoveryService: schema.getService('dxos.mesh.teleport.AdmissionDiscoveryService'),\n },\n });\n }\n\n protected override async getHandlers(): Promise<{}> {\n return {};\n }\n\n override async onOpen(context: ExtensionContext) {\n await super.onOpen(context);\n scheduleTask(this._ctx, async () => {\n try {\n const result = await this.rpc.AdmissionDiscoveryService.getAdmissionCredential(this._request);\n this._onResult.wake(result.admissionCredential);\n } catch (err: any) {\n context.close(err);\n }\n });\n }\n\n override async onClose() {\n await this._ctx.dispose();\n }\n\n override async onAbort(): Promise<void> {\n await this._ctx.dispose();\n }\n}\n\nexport class CredentialServerExtension extends RpcExtension<\n {},\n { AdmissionDiscoveryService: AdmissionDiscoveryService }\n> {\n constructor(private readonly _space: Space) {\n super({\n exposed: {\n AdmissionDiscoveryService: schema.getService('dxos.mesh.teleport.AdmissionDiscoveryService'),\n },\n });\n }\n\n protected override async getHandlers(): Promise<{ AdmissionDiscoveryService: AdmissionDiscoveryService }> {\n return {\n AdmissionDiscoveryService: {\n getAdmissionCredential: async (\n request: GetAdmissionCredentialRequest,\n ): Promise<GetAdmissionCredentialResponse> => {\n const memberInfo = this._space.spaceState.members.get(request.memberKey);\n if (!memberInfo?.credential) {\n throw new ProtocolError('Space member not found.', request);\n }\n return { admissionCredential: memberInfo.credential };\n },\n },\n };\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type Event } from '@dxos/async';\nimport { discoveryKey, subtleCrypto } from '@dxos/crypto';\nimport { type FeedWrapper } from '@dxos/feed-store';\nimport { PublicKey } from '@dxos/keys';\nimport { log, logInfo } from '@dxos/log';\nimport {\n MMSTTopology,\n type SwarmNetworkManager,\n type SwarmConnection,\n type WireProtocol,\n type WireProtocolParams,\n type WireProtocolProvider,\n} from '@dxos/network-manager';\nimport type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';\nimport { type MuxerStats, Teleport } from '@dxos/teleport';\nimport { type BlobStore, BlobSync } from '@dxos/teleport-extension-object-sync';\nimport { ReplicatorExtension } from '@dxos/teleport-extension-replicator';\nimport { trace } from '@dxos/tracing';\nimport { CallbackCollection, ComplexMap, type AsyncCallback } from '@dxos/util';\n\nimport { AuthExtension, type AuthProvider, type AuthVerifier } from './auth';\n\nexport const MOCK_AUTH_PROVIDER: AuthProvider = async (nonce: Uint8Array) => Buffer.from('mock');\nexport const MOCK_AUTH_VERIFIER: AuthVerifier = async (nonce: Uint8Array, credential: Uint8Array) => true;\n\n// TODO(burdon): Reconcile with SigningContext (define types together).\nexport interface SwarmIdentity {\n peerKey: PublicKey;\n identityKey: PublicKey;\n credentialProvider: AuthProvider;\n credentialAuthenticator: AuthVerifier;\n}\n\nexport type SpaceProtocolOptions = {\n topic: PublicKey; // TODO(burdon): Rename?\n swarmIdentity: SwarmIdentity;\n networkManager: SwarmNetworkManager;\n\n blobStore: BlobStore;\n\n onFeed?: (feed: FeedWrapper<FeedMessage>) => Promise<void>;\n\n /**\n * Called when new session is authenticated.\n * Additional extensions can be added here.\n */\n onSessionAuth?: (session: Teleport) => void;\n onAuthFailure?: (session: Teleport) => void;\n\n disableP2pReplication?: boolean;\n};\n\n/**\n * Manages Teleport protocol stream creation and joining swarms with replication and presence extensions.\n */\n@trace.resource()\nexport class SpaceProtocol {\n private readonly _networkManager: SwarmNetworkManager;\n private readonly _swarmIdentity: SwarmIdentity;\n private readonly _onSessionAuth?: (session: Teleport) => void;\n private readonly _onAuthFailure?: (session: Teleport) => void;\n\n public readonly blobSync: BlobSync;\n\n private readonly _disableP2pReplication: boolean;\n\n @logInfo\n @trace.info()\n private readonly _topic: Promise<PublicKey>;\n\n @trace.info()\n private readonly _spaceKey: PublicKey;\n\n private readonly _feeds = new Set<FeedWrapper<FeedMessage>>();\n private readonly _sessions = new ComplexMap<PublicKey, SpaceProtocolSession>(PublicKey.hash);\n // TODO(burdon): Move to config (with sensible defaults).\n private readonly _topology = new MMSTTopology({\n originateConnections: 4,\n maxPeers: 10,\n sampleSize: 20,\n });\n\n private _connection?: SwarmConnection;\n\n public readonly feedAdded = new CallbackCollection<AsyncCallback<FeedWrapper<FeedMessage>>>();\n\n get sessions(): ReadonlyMap<PublicKey, SpaceProtocolSession> {\n return this._sessions;\n }\n\n get feeds(): ReadonlySet<FeedWrapper<FeedMessage>> {\n return this._feeds;\n }\n\n @logInfo\n private get _ownPeerKey() {\n return this._swarmIdentity.peerKey;\n }\n\n constructor({\n topic,\n swarmIdentity,\n networkManager,\n onSessionAuth,\n onAuthFailure,\n blobStore,\n disableP2pReplication,\n }: SpaceProtocolOptions) {\n this._spaceKey = topic;\n this._networkManager = networkManager;\n this._swarmIdentity = swarmIdentity;\n this._onSessionAuth = onSessionAuth;\n this._onAuthFailure = onAuthFailure;\n this.blobSync = new BlobSync({ blobStore });\n\n // TODO(burdon): Async race condition? Move to start?\n this._topic = subtleCrypto.digest('SHA-256', topic.asBuffer()).then(discoveryKey).then(PublicKey.from);\n\n this._disableP2pReplication = disableP2pReplication ?? false;\n }\n\n // TODO(burdon): Create abstraction for Space (e.g., add keys and have provider).\n async addFeed(feed: FeedWrapper<FeedMessage>) {\n log('addFeed', { key: feed.key });\n\n this._feeds.add(feed);\n for (const session of this._sessions.values()) {\n session.replicator.addFeed(feed);\n }\n\n await this.feedAdded.callSerial(feed);\n }\n\n // TODO(burdon): Rename open? Common open/close interfaces for all services?\n async start() {\n if (this._connection) {\n return;\n }\n\n // TODO(burdon): Document why empty buffer.\n const credentials = await this._swarmIdentity.credentialProvider(Buffer.from(''));\n\n await this.blobSync.open();\n\n log('starting...');\n const topic = await this._topic;\n this._connection = await this._networkManager.joinSwarm({\n protocolProvider: this._createProtocolProvider(credentials),\n peerInfo: {\n peerKey: this._swarmIdentity.peerKey.toHex(),\n identityKey: this._swarmIdentity.identityKey.toHex(),\n },\n topic,\n topology: this._topology,\n label: `swarm ${topic.truncate()} for space ${this._spaceKey.truncate()}`,\n });\n\n log('started');\n }\n\n public updateTopology() {\n this._topology.forceUpdate();\n }\n\n async stop() {\n await this.blobSync.close();\n\n if (this._connection) {\n log('stopping...');\n await this._connection.close();\n log('stopped');\n }\n }\n\n private _createProtocolProvider(credentials: Uint8Array | undefined): WireProtocolProvider {\n return (wireParams) => {\n const session = new SpaceProtocolSession({\n wireParams,\n swarmIdentity: this._swarmIdentity,\n onSessionAuth: this._onSessionAuth,\n onAuthFailure: this._onAuthFailure,\n blobSync: this.blobSync,\n disableP2pReplication: this._disableP2pReplication,\n });\n this._sessions.set(wireParams.remotePeerId, session);\n\n for (const feed of this._feeds) {\n session.replicator.addFeed(feed);\n }\n\n return session;\n };\n }\n}\n\nexport type SpaceProtocolSessionParams = {\n wireParams: WireProtocolParams;\n swarmIdentity: SwarmIdentity;\n\n blobSync: BlobSync;\n\n /**\n * Called when new session is authenticated.\n * Additional extensions can be added here.\n */\n onSessionAuth?: (session: Teleport) => void;\n\n onAuthFailure?: (session: Teleport) => void;\n\n disableP2pReplication?: boolean;\n};\n\nexport enum AuthStatus {\n INITIAL = 'INITIAL',\n SUCCESS = 'SUCCESS',\n FAILURE = 'FAILURE',\n}\n\n// TODO(dmaretskyi): Move to a separate file.\n/**\n * Represents a single connection to a remote peer\n */\nexport class SpaceProtocolSession implements WireProtocol {\n @logInfo\n private readonly _wireParams: WireProtocolParams;\n\n private readonly _disableP2pReplication: boolean;\n\n private readonly _onSessionAuth?: (session: Teleport) => void;\n private readonly _onAuthFailure?: (session: Teleport) => void;\n private readonly _swarmIdentity: SwarmIdentity;\n private readonly _blobSync: BlobSync;\n\n private readonly _teleport: Teleport;\n\n // TODO(dmaretskyi): Start with upload=false when switching it on the fly works.\n public readonly replicator = new ReplicatorExtension().setOptions({ upload: true });\n\n private _authStatus = AuthStatus.INITIAL;\n\n @logInfo\n get authStatus() {\n return this._authStatus;\n }\n\n get stats(): Event<MuxerStats> {\n return this._teleport.stats;\n }\n\n // TODO(dmaretskyi): Allow to pass in extra extensions.\n constructor({\n wireParams,\n swarmIdentity,\n onSessionAuth,\n onAuthFailure,\n blobSync,\n disableP2pReplication,\n }: SpaceProtocolSessionParams) {\n this._wireParams = wireParams;\n this._swarmIdentity = swarmIdentity;\n this._onSessionAuth = onSessionAuth;\n this._onAuthFailure = onAuthFailure;\n this._blobSync = blobSync;\n\n this._teleport = new Teleport(wireParams);\n\n this._disableP2pReplication = disableP2pReplication ?? false;\n }\n\n get stream() {\n return this._teleport.stream;\n }\n\n async open(sessionId?: PublicKey): Promise<void> {\n await this._teleport.open(sessionId);\n this._teleport.addExtension(\n 'dxos.mesh.teleport.auth',\n new AuthExtension({\n provider: this._swarmIdentity.credentialProvider,\n verifier: this._swarmIdentity.credentialAuthenticator,\n onAuthSuccess: () => {\n log('Peer authenticated');\n this._authStatus = AuthStatus.SUCCESS;\n this._onSessionAuth?.(this._teleport);\n // TODO(dmaretskyi): Configure replicator to upload.\n },\n onAuthFailure: () => {\n this._authStatus = AuthStatus.FAILURE;\n this._onAuthFailure?.(this._teleport);\n },\n }),\n );\n\n if (!this._disableP2pReplication) {\n this._teleport.addExtension('dxos.mesh.teleport.replicator', this.replicator);\n }\n this._teleport.addExtension('dxos.mesh.teleport.blobsync', this._blobSync.createExtension());\n }\n\n async close(): Promise<void> {\n log('close');\n await this._teleport.close();\n }\n\n async abort(): Promise<void> {\n await this._teleport.abort();\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { synchronized, trackLeaks, Trigger } from '@dxos/async';\nimport { type DelegateInvitationCredential, type MemberInfo } from '@dxos/credentials';\nimport { failUndefined } from '@dxos/debug';\nimport { type FeedStore } from '@dxos/feed-store';\nimport { PublicKey } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { type SwarmNetworkManager } from '@dxos/network-manager';\nimport { trace } from '@dxos/protocols';\nimport type { FeedMessage } from '@dxos/protocols/proto/dxos/echo/feed';\nimport { type SpaceMetadata } from '@dxos/protocols/proto/dxos/echo/metadata';\nimport type { Credential } from '@dxos/protocols/proto/dxos/halo/credentials';\nimport { type Teleport } from '@dxos/teleport';\nimport { type BlobStore } from '@dxos/teleport-extension-object-sync';\nimport { ComplexMap } from '@dxos/util';\n\nimport { CredentialRetrieverExtension } from './admission-discovery-extension';\nimport { Space } from './space';\nimport { SpaceProtocol, type SwarmIdentity } from './space-protocol';\nimport { createIdFromSpaceKey } from '../common/space-id';\nimport { type MetadataStore } from '../metadata';\n\nexport type SpaceManagerParams = {\n feedStore: FeedStore<FeedMessage>;\n networkManager: SwarmNetworkManager;\n metadataStore: MetadataStore;\n\n blobStore: BlobStore;\n\n disableP2pReplication?: boolean;\n};\n\nexport type ConstructSpaceParams = {\n metadata: SpaceMetadata;\n swarmIdentity: SwarmIdentity;\n memberKey: PublicKey;\n /**\n * Called when connection auth passed successful.\n */\n onAuthorizedConnection: (session: Teleport) => void;\n onAuthFailure?: (session: Teleport) => void;\n onDelegatedInvitationStatusChange: (invitation: DelegateInvitationCredential, isActive: boolean) => Promise<void>;\n onMemberRolesChanged: (member: MemberInfo[]) => Promise<void>;\n};\n\nexport type RequestSpaceAdmissionCredentialParams = {\n spaceKey: PublicKey;\n identityKey: PublicKey;\n swarmIdentity: SwarmIdentity;\n timeout: number;\n};\n\n/**\n * Manages a collection of ECHO (Data) Spaces.\n */\n@trackLeaks('open', 'close')\nexport class SpaceManager {\n private readonly _spaces = new ComplexMap<PublicKey, Space>(PublicKey.hash);\n private readonly _feedStore: FeedStore<FeedMessage>;\n private readonly _networkManager: SwarmNetworkManager;\n private readonly _metadataStore: MetadataStore;\n private readonly _blobStore: BlobStore;\n private readonly _instanceId = PublicKey.random().toHex();\n private readonly _disableP2pReplication: boolean;\n\n constructor({ feedStore, networkManager, metadataStore, blobStore, disableP2pReplication }: SpaceManagerParams) {\n // TODO(burdon): Assert.\n this._feedStore = feedStore;\n this._networkManager = networkManager;\n this._metadataStore = metadataStore;\n this._blobStore = blobStore;\n this._disableP2pReplication = disableP2pReplication ?? false;\n }\n\n // TODO(burdon): Remove.\n get spaces() {\n return this._spaces;\n }\n\n @synchronized\n async open() {}\n\n @synchronized\n async close() {\n await Promise.all([...this._spaces.values()].map((space) => space.close()));\n }\n\n async constructSpace({\n metadata,\n swarmIdentity,\n onAuthorizedConnection,\n onAuthFailure,\n onDelegatedInvitationStatusChange,\n onMemberRolesChanged,\n memberKey,\n }: ConstructSpaceParams) {\n log.trace('dxos.echo.space-manager.construct-space', trace.begin({ id: this._instanceId }));\n log('constructing space...', { spaceKey: metadata.genesisFeedKey });\n\n // The genesis feed will be the same as the control feed if the space was created by the local agent.\n const genesisFeed = await this._feedStore.openFeed(metadata.genesisFeedKey ?? failUndefined());\n\n const spaceKey = metadata.key;\n const spaceId = await createIdFromSpaceKey(spaceKey);\n const protocol = new SpaceProtocol({\n topic: spaceKey,\n swarmIdentity,\n networkManager: this._networkManager,\n onSessionAuth: onAuthorizedConnection,\n onAuthFailure,\n blobStore: this._blobStore,\n disableP2pReplication: this._disableP2pReplication,\n });\n\n const space = new Space({\n id: spaceId,\n spaceKey,\n protocol,\n genesisFeed,\n feedProvider: (feedKey, opts) => this._feedStore.openFeed(feedKey, opts),\n metadataStore: this._metadataStore,\n memberKey,\n onDelegatedInvitationStatusChange,\n onMemberRolesChanged,\n });\n this._spaces.set(space.key, space);\n\n log.trace('dxos.echo.space-manager.construct-space', trace.end({ id: this._instanceId }));\n return space;\n }\n\n public async requestSpaceAdmissionCredential(params: RequestSpaceAdmissionCredentialParams): Promise<Credential> {\n const traceKey = 'dxos.echo.space-manager.request-space-admission';\n log.trace(traceKey, trace.begin({ id: this._instanceId }));\n log('requesting space admission credential...', { spaceKey: params.spaceKey });\n\n const onCredentialResolved = new Trigger<Credential>();\n const protocol = new SpaceProtocol({\n topic: params.spaceKey,\n swarmIdentity: params.swarmIdentity,\n networkManager: this._networkManager,\n onSessionAuth: (session: Teleport) => {\n session.addExtension(\n 'dxos.mesh.teleport.admission-discovery',\n new CredentialRetrieverExtension(\n { spaceKey: params.spaceKey, memberKey: params.identityKey },\n onCredentialResolved,\n ),\n );\n },\n onAuthFailure: (session: Teleport) => session.close(),\n blobStore: this._blobStore,\n disableP2pReplication: this._disableP2pReplication,\n });\n\n try {\n await protocol.start();\n const credential = await onCredentialResolved.wait({ timeout: params.timeout });\n log.trace(traceKey, trace.end({ id: this._instanceId }));\n return credential;\n } catch (err: any) {\n log.trace(traceKey, trace.error({ id: this._instanceId, error: err }));\n throw err;\n } finally {\n await protocol.stop();\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;AAKA,SAASA,2BAA2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AI;IACrB;EACF;AACF;;EAxFGC;GAvBUzE,aAAAA,WAAAA,QAAAA,IAAAA;;EA0BVyE;GA1BUzE,aAAAA,WAAAA,SAAAA,IAAAA;AAAAA,eAAAA,cAAAA;EADZ0E,YAAW,QAAQ,OAAA;GACP1E,YAAAA;",
|
|
6
|
+
"names": ["createCodecEncoding", "schema", "codec", "schema", "getCodecForType", "valueEncoding", "createCodecEncoding", "invariant", "createMappedFeedWriter", "mapper", "writer", "write", "data", "options", "subtleCrypto", "PublicKey", "SpaceId", "ComplexMap", "SPACE_IDS_CACHE", "ComplexMap", "PublicKey", "hash", "createIdFromSpaceKey", "spaceKey", "cachedValue", "get", "undefined", "digest", "subtleCrypto", "asUint8Array", "bytes", "Uint8Array", "slice", "SpaceId", "byteLength", "spaceId", "encode", "set", "CRC32", "Event", "scheduleTaskInterval", "synchronized", "Context", "invariant", "PublicKey", "log", "DataCorruptionError", "STORAGE_VERSION", "schema", "Invitation", "SpaceState", "ComplexMap", "arrayToBuffer", "forEachAsync", "isNotNullOrUndefined", "EXPIRED_INVITATION_CLEANUP_INTERVAL", "emptyEchoMetadata", "version", "spaces", "created", "Date", "updated", "emptyLargeSpaceMetadata", "EchoMetadata", "getCodecForType", "LargeSpaceMetadata", "MetadataStore", "constructor", "directory", "_metadata", "_spaceLargeMetadata", "hash", "_metadataFile", "undefined", "update", "_invitationCleanupCtx", "_directory", "metadata", "_readFile", "file", "codec", "size", "fileLength", "stat", "dataSize", "fromBytesInt32", "read", "checksum", "name", "filename", "data", "calculatedChecksum", "buf", "decode", "close", "_writeFile", "encoded", "encode", "result", "Buffer", "alloc", "length", "writeInt32LE", "copy", "write", "dispose", "flush", "clear", "load", "closed", "getOrCreateFile", "forEach", "space", "state", "SPACE_ACTIVE", "err", "error", "identity", "haloSpace", "key", "map", "filter", "_loadSpaceLargeMetadata", "invitation", "invitations", "hasInvitationExpired", "isLegacyInvitationFormat", "removeInvitation", "invitationId", "_save", "emit", "toHex", "set", "_saveSpaceLargeMetadata", "_getLargeSpaceMetadata", "_getSpace", "spaceKey", "equals", "find", "hasSpace", "entry", "get", "delete", "getIdentityRecord", "setIdentityRecord", "record", "getInvitations", "addInvitation", "i", "push", "addSpace", "setSpaceDataLatestTimeframe", "timeframe", "dataTimeframe", "setSpaceControlLatestTimeframe", "controlTimeframe", "setCache", "cache", "setWritableFeedKeys", "controlFeedKey", "dataFeedKey", "setSpaceState", "getSpaceControlPipelineSnapshot", "controlPipelineSnapshot", "setSpaceControlPipelineSnapshot", "snapshot", "getSpaceEdgeReplicationSetting", "edgeReplication", "setSpaceEdgeReplicationSetting", "setting", "readInt32LE", "Boolean", "lifetime", "getTime", "now", "type", "Type", "MULTIUSE", "Event", "timed", "log", "Timeframe", "mapTimeframeToFeedIndexes", "timeframe", "frames", "map", "feedKey", "index", "mapFeedIndexesToTimeframe", "indexes", "startAfter", "TimeframeClock", "constructor", "_timeframe", "update", "_pendingTimeframe", "pendingTimeframe", "setTimeframe", "emit", "updatePendingTimeframe", "key", "seq", "merge", "updateTimeframe", "hasGaps", "gaps", "dependencies", "isEmpty", "waitUntilReached", "target", "current", "waitForCondition", "deps", "Event", "sleepWithContext", "synchronized", "Trigger", "Context", "rejectOnDispose", "failUndefined", "FeedSetIterator", "invariant", "PublicKey", "log", "Timeframe", "ComplexMap", "invariant", "log", "createMessageSelector", "timeframeClock", "messages", "i", "length", "data", "timeframe", "hasGaps", "PipelineState", "constructor", "_feeds", "_timeframeClock", "_ctx", "Context", "timeframeUpdate", "update", "stalled", "Event", "_startTimeframe", "Timeframe", "_reachedTarget", "endTimeframe", "mapFeedIndexesToTimeframe", "Array", "from", "values", "filter", "feed", "length", "map", "feedKey", "key", "index", "startTimeframe", "timeframe", "pendingTimeframe", "targetTimeframe", "_targetTimeframe", "reachedTarget", "feeds", "waitUntilTimeframe", "target", "waitUntilReached", "setTargetTimeframe", "waitUntilReachedTargetTimeframe", "ctx", "timeout", "breakOnStall", "log", "current", "_reachedTargetPromise", "Promise", "race", "waitForCondition", "dependencies", "isEmpty", "discardParameter", "waitForCount", "done", "rejectOnDispose", "then", "sleepWithContext", "warn", "Pipeline", "TimeframeClock", "ComplexMap", "PublicKey", "hash", "_state", "_processingTrigger", "Trigger", "wake", "_pauseTrigger", "_downloads", "value", "_isStopping", "_isStarted", "_isBeingConsumed", "_isPaused", "state", "writer", "invariant", "_writer", "hasFeed", "has", "getFeeds", "_feedSetIterator", "addFeed", "set", "_setFeedDownloadState", "setWriteFeed", "properties", "writable", "createMappedFeedWriter", "payload", "createFeedWriter", "start", "_initIterator", "open", "stop", "handle", "entries", "undownload", "clear", "close", "wait", "dispose", "undefined", "setCursor", "setTimeframe", "pause", "reset", "unpause", "consume", "lastFeedSetIterator", "iterable", "Symbol", "asyncIterator", "next", "block", "failUndefined", "updatePendingTimeframe", "seq", "updateTimeframe", "get", "truncate", "download", "linear", "err", "data", "info", "FeedSetIterator", "createMessageSelector", "startAfter", "stallTimeout", "on", "iterator", "options", "size", "emit", "synchronized", "runInContext", "scheduleTask", "Context", "randomBytes", "invariant", "log", "schema", "RpcExtension", "AuthExtension", "constructor", "_authParams", "requested", "AuthService", "getService", "exposed", "timeout", "_ctx", "onError", "err", "catch", "getHandlers", "authenticate", "challenge", "credential", "provider", "Error", "error", "onOpen", "context", "rpc", "length", "success", "verifier", "onAuthSuccess", "close", "onAuthFailure", "onClose", "dispose", "onAbort", "Event", "scheduleMicroTask", "synchronized", "trackLeaks", "Resource", "invariant", "log", "logInfo", "AdmittedFeed", "trace", "Callback", "DeferredTask", "sleepWithContext", "trackLeaks", "Context", "SpaceStateMachine", "PublicKey", "log", "AdmittedFeed", "Timeframe", "TimeSeriesCounter", "TimeUsageCounter", "trace", "Callback", "tracer", "TIMEFRAME_SAVE_DEBOUNCE_INTERVAL", "CONTROL_PIPELINE_SNAPSHOT_DELAY", "USE_SNAPSHOTS", "ControlPipeline", "constructor", "spaceKey", "genesisFeed", "feedProvider", "metadataStore", "_ctx", "Context", "_lastTimeframeSaveTime", "Date", "now", "onFeedAdmitted", "Callback", "_usage", "TimeUsageCounter", "_mutations", "TimeSeriesCounter", "_snapshotTask", "DeferredTask", "sleepWithContext", "_saveSnapshot", "_spaceKey", "_metadata", "_pipeline", "Pipeline", "addFeed", "_spaceStateMachine", "SpaceStateMachine", "set", "info", "log", "key", "assertion", "designation", "AdmittedFeed", "Designation", "CONTROL", "equals", "queueMicrotask", "feed", "hasFeed", "err", "catch", "callIfSet", "onMemberRoleChanged", "onCredentialProcessed", "onDelegatedInvitation", "onDelegatedInvitationRemoved", "spaceState", "pipeline", "setWriteFeed", "start", "snapshot", "getSpaceControlPipelineSnapshot", "present", "tf", "timeframe", "_processSnapshot", "setTimeout", "_consumePipeline", "setCursor", "message", "messages", "result", "process", "credential", "sourceFeed", "feedKey", "skipVerification", "warn", "pause", "state", "credentialEntries", "map", "entry", "unpause", "getSnapshotLoggerContext", "setSpaceControlPipelineSnapshot", "ctx", "msg", "consume", "span", "beginRecording", "inc", "_processMessage", "end", "seq", "data", "payload", "timer", "tracer", "mark", "PublicKey", "from", "_noteTargetStateIfNeeded", "pendingTimeframe", "schedule", "_saveTargetTimeframe", "stop", "dispose", "newTimeframe", "Timeframe", "merge", "_targetTimeframe", "setSpaceControlLatestTimeframe", "trace", "metricsCounter", "showInBrowserTimeline", "resource", "trackLeaks", "issuer", "subject", "id", "type", "Space", "Resource", "constructor", "params", "onCredentialProcessed", "Callback", "stateUpdate", "Event", "invariant", "spaceKey", "feedProvider", "_id", "id", "_key", "_genesisFeedKey", "genesisFeed", "key", "_feedProvider", "_controlPipeline", "ControlPipeline", "metadataStore", "onFeedAdmitted", "set", "info", "sparse", "assertion", "designation", "AdmittedFeed", "Designation", "DATA", "equals", "scheduleMicroTask", "_ctx", "protocol", "addFeed", "credential", "callIfSet", "log", "emit", "onDelegatedInvitation", "invitation", "onDelegatedInvitationStatusChange", "onDelegatedInvitationRemoved", "onMemberRoleChanged", "changedMembers", "map", "m", "role", "onMemberRolesChanged", "genesisFeedKey", "controlFeedKey", "_controlFeed", "dataFeedKey", "_dataFeed", "spaceState", "controlPipeline", "pipeline", "setControlFeed", "feed", "setWriteFeed", "setDataFeed", "getControlFeeds", "Array", "from", "feeds", "values", "_open", "ctx", "start", "_close", "stop", "trace", "logInfo", "span", "synchronized", "trackLeaks", "resource", "scheduleTask", "Context", "ProtocolError", "schema", "RpcExtension", "CredentialRetrieverExtension", "constructor", "_request", "_onResult", "requested", "AdmissionDiscoveryService", "getService", "_ctx", "getHandlers", "onOpen", "context", "result", "rpc", "getAdmissionCredential", "wake", "admissionCredential", "err", "close", "onClose", "dispose", "onAbort", "CredentialServerExtension", "_space", "exposed", "request", "memberInfo", "spaceState", "members", "get", "memberKey", "credential", "discoveryKey", "subtleCrypto", "PublicKey", "log", "logInfo", "MMSTTopology", "Teleport", "BlobSync", "ReplicatorExtension", "trace", "CallbackCollection", "ComplexMap", "MOCK_AUTH_PROVIDER", "nonce", "Buffer", "from", "MOCK_AUTH_VERIFIER", "credential", "SpaceProtocol", "constructor", "topic", "swarmIdentity", "networkManager", "onSessionAuth", "onAuthFailure", "blobStore", "disableP2pReplication", "_feeds", "Set", "_sessions", "ComplexMap", "PublicKey", "hash", "_topology", "MMSTTopology", "originateConnections", "maxPeers", "sampleSize", "feedAdded", "CallbackCollection", "_spaceKey", "_networkManager", "_swarmIdentity", "_onSessionAuth", "_onAuthFailure", "blobSync", "BlobSync", "_topic", "subtleCrypto", "digest", "asBuffer", "then", "discoveryKey", "_disableP2pReplication", "sessions", "feeds", "_ownPeerKey", "peerKey", "addFeed", "feed", "log", "key", "add", "session", "values", "replicator", "callSerial", "start", "_connection", "credentials", "credentialProvider", "open", "joinSwarm", "protocolProvider", "_createProtocolProvider", "peerInfo", "toHex", "identityKey", "topology", "label", "truncate", "updateTopology", "forceUpdate", "stop", "close", "wireParams", "SpaceProtocolSession", "set", "remotePeerId", "logInfo", "trace", "info", "resource", "AuthStatus", "ReplicatorExtension", "setOptions", "upload", "_authStatus", "_wireParams", "_blobSync", "_teleport", "Teleport", "authStatus", "stats", "stream", "sessionId", "addExtension", "AuthExtension", "provider", "verifier", "credentialAuthenticator", "onAuthSuccess", "createExtension", "abort", "synchronized", "trackLeaks", "Trigger", "failUndefined", "PublicKey", "log", "trace", "ComplexMap", "SpaceManager", "constructor", "feedStore", "networkManager", "metadataStore", "blobStore", "disableP2pReplication", "_spaces", "ComplexMap", "PublicKey", "hash", "_instanceId", "random", "toHex", "_feedStore", "_networkManager", "_metadataStore", "_blobStore", "_disableP2pReplication", "spaces", "open", "close", "Promise", "all", "values", "map", "space", "constructSpace", "metadata", "swarmIdentity", "onAuthorizedConnection", "onAuthFailure", "onDelegatedInvitationStatusChange", "onMemberRolesChanged", "memberKey", "log", "trace", "begin", "id", "spaceKey", "genesisFeedKey", "genesisFeed", "openFeed", "failUndefined", "key", "spaceId", "createIdFromSpaceKey", "protocol", "SpaceProtocol", "topic", "onSessionAuth", "Space", "feedProvider", "feedKey", "opts", "set", "end", "requestSpaceAdmissionCredential", "params", "traceKey", "onCredentialResolved", "Trigger", "session", "addExtension", "CredentialRetrieverExtension", "identityKey", "start", "credential", "wait", "timeout", "err", "error", "stop", "synchronized", "trackLeaks"]
|
|
7
|
+
}
|