@dxos/echo-pipeline 0.5.9-next.a50ff17 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{chunk-I2J5TTHJ.mjs → chunk-HS77A4I4.mjs} +174 -23
- package/dist/lib/browser/{chunk-I2J5TTHJ.mjs.map → chunk-HS77A4I4.mjs.map} +4 -4
- package/dist/lib/browser/index.mjs +182 -126
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +11 -7
- package/dist/lib/browser/testing/index.mjs.map +1 -1
- package/dist/lib/node/{chunk-QPCNQ4ZK.cjs → chunk-Y5U7UXEL.cjs} +185 -34
- package/dist/lib/node/{chunk-QPCNQ4ZK.cjs.map → chunk-Y5U7UXEL.cjs.map} +4 -4
- package/dist/lib/node/index.cjs +230 -174
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +21 -17
- package/dist/lib/node/testing/index.cjs.map +1 -1
- package/dist/types/src/automerge/automerge-doc-loader.d.ts +2 -1
- package/dist/types/src/automerge/automerge-doc-loader.d.ts.map +1 -1
- package/dist/types/src/automerge/automerge-host.d.ts +40 -3
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/echo-network-adapter.d.ts +2 -0
- package/dist/types/src/automerge/echo-network-adapter.d.ts.map +1 -1
- package/dist/types/src/automerge/mesh-echo-replicator.d.ts.map +1 -1
- package/dist/types/src/space/admission-discovery-extension.d.ts +30 -0
- package/dist/types/src/space/admission-discovery-extension.d.ts.map +1 -0
- package/dist/types/src/space/index.d.ts +1 -0
- package/dist/types/src/space/index.d.ts.map +1 -1
- package/dist/types/src/space/space-manager.d.ts +8 -0
- package/dist/types/src/space/space-manager.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/automerge/automerge-doc-loader.test.ts +8 -5
- package/src/automerge/automerge-doc-loader.ts +29 -20
- package/src/automerge/automerge-host.ts +96 -32
- package/src/automerge/echo-network-adapter.ts +10 -4
- package/src/automerge/mesh-echo-replicator.ts +7 -2
- package/src/space/admission-discovery-extension.ts +90 -0
- package/src/space/index.ts +1 -0
- package/src/space/space-manager.ts +46 -1
|
@@ -184,7 +184,10 @@ var MetadataStore = class {
|
|
|
184
184
|
this._spaceLargeMetadata = new ComplexMap(PublicKey2.hash);
|
|
185
185
|
this._metadataFile = void 0;
|
|
186
186
|
this.update = new Event();
|
|
187
|
-
this._invitationCleanupCtx = new Context(
|
|
187
|
+
this._invitationCleanupCtx = new Context(void 0, {
|
|
188
|
+
F: __dxlog_file2,
|
|
189
|
+
L: 53
|
|
190
|
+
});
|
|
188
191
|
this._directory = directory;
|
|
189
192
|
}
|
|
190
193
|
get metadata() {
|
|
@@ -641,7 +644,10 @@ var PipelineState = class {
|
|
|
641
644
|
constructor(_feeds, _timeframeClock) {
|
|
642
645
|
this._feeds = _feeds;
|
|
643
646
|
this._timeframeClock = _timeframeClock;
|
|
644
|
-
this._ctx = new Context2(
|
|
647
|
+
this._ctx = new Context2(void 0, {
|
|
648
|
+
F: __dxlog_file5,
|
|
649
|
+
L: 41
|
|
650
|
+
});
|
|
645
651
|
this.timeframeUpdate = this._timeframeClock.update;
|
|
646
652
|
this.stalled = new Event3();
|
|
647
653
|
this._startTimeframe = new Timeframe2();
|
|
@@ -689,7 +695,10 @@ var PipelineState = class {
|
|
|
689
695
|
*
|
|
690
696
|
* @param timeout Timeout in milliseconds to specify the maximum wait time.
|
|
691
697
|
*/
|
|
692
|
-
async waitUntilReachedTargetTimeframe({ ctx = new Context2(
|
|
698
|
+
async waitUntilReachedTargetTimeframe({ ctx = new Context2(void 0, {
|
|
699
|
+
F: __dxlog_file5,
|
|
700
|
+
L: 129
|
|
701
|
+
}), timeout, breakOnStall = true } = {}) {
|
|
693
702
|
log4("waitUntilReachedTargetTimeframe", {
|
|
694
703
|
timeout,
|
|
695
704
|
current: this.timeframe,
|
|
@@ -857,7 +866,10 @@ var Pipeline = class {
|
|
|
857
866
|
await this._feedSetIterator?.close();
|
|
858
867
|
await this._processingTrigger.wait();
|
|
859
868
|
await this._state._ctx.dispose();
|
|
860
|
-
this._state._ctx = new Context2(
|
|
869
|
+
this._state._ctx = new Context2(void 0, {
|
|
870
|
+
F: __dxlog_file5,
|
|
871
|
+
L: 309
|
|
872
|
+
});
|
|
861
873
|
this._state._reachedTargetPromise = void 0;
|
|
862
874
|
this._state._reachedTarget = false;
|
|
863
875
|
this._isStarted = false;
|
|
@@ -1070,6 +1082,9 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1070
1082
|
C: (f, a) => f(...a)
|
|
1071
1083
|
});
|
|
1072
1084
|
}
|
|
1085
|
+
}, {
|
|
1086
|
+
F: __dxlog_file6,
|
|
1087
|
+
L: 26
|
|
1073
1088
|
});
|
|
1074
1089
|
}
|
|
1075
1090
|
async getHandlers() {
|
|
@@ -1184,7 +1199,10 @@ var CONTROL_PIPELINE_SNAPSHOT_DELAY = 1e4;
|
|
|
1184
1199
|
var USE_SNAPSHOTS = true;
|
|
1185
1200
|
var ControlPipeline = class {
|
|
1186
1201
|
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
1187
|
-
this._ctx = new Context4(
|
|
1202
|
+
this._ctx = new Context4(void 0, {
|
|
1203
|
+
F: __dxlog_file7,
|
|
1204
|
+
L: 47
|
|
1205
|
+
});
|
|
1188
1206
|
this._lastTimeframeSaveTime = Date.now();
|
|
1189
1207
|
this.onFeedAdmitted = new Callback();
|
|
1190
1208
|
this._usage = new TimeUsageCounter();
|
|
@@ -1263,7 +1281,10 @@ var ControlPipeline = class {
|
|
|
1263
1281
|
C: (f, a) => f(...a)
|
|
1264
1282
|
});
|
|
1265
1283
|
setTimeout(async () => {
|
|
1266
|
-
void this._consumePipeline(new Context4(
|
|
1284
|
+
void this._consumePipeline(new Context4(void 0, {
|
|
1285
|
+
F: __dxlog_file7,
|
|
1286
|
+
L: 130
|
|
1287
|
+
}));
|
|
1267
1288
|
});
|
|
1268
1289
|
await this._pipeline.start();
|
|
1269
1290
|
log6("started", void 0, {
|
|
@@ -1655,6 +1676,73 @@ var createIdFromSpaceKey = async (spaceKey) => {
|
|
|
1655
1676
|
return spaceId;
|
|
1656
1677
|
};
|
|
1657
1678
|
|
|
1679
|
+
// packages/core/echo/echo-pipeline/src/space/admission-discovery-extension.ts
|
|
1680
|
+
import { scheduleTask as scheduleTask2 } from "@dxos/async";
|
|
1681
|
+
import { Context as Context5 } from "@dxos/context";
|
|
1682
|
+
import { ProtocolError, schema as schema6 } from "@dxos/protocols";
|
|
1683
|
+
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
1684
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/admission-discovery-extension.ts";
|
|
1685
|
+
var CredentialRetrieverExtension = class extends RpcExtension2 {
|
|
1686
|
+
constructor(_request, _onResult) {
|
|
1687
|
+
super({
|
|
1688
|
+
requested: {
|
|
1689
|
+
AdmissionDiscoveryService: schema6.getService("dxos.mesh.teleport.AdmissionDiscoveryService")
|
|
1690
|
+
}
|
|
1691
|
+
});
|
|
1692
|
+
this._request = _request;
|
|
1693
|
+
this._onResult = _onResult;
|
|
1694
|
+
this._ctx = new Context5(void 0, {
|
|
1695
|
+
F: __dxlog_file9,
|
|
1696
|
+
L: 25
|
|
1697
|
+
});
|
|
1698
|
+
}
|
|
1699
|
+
async getHandlers() {
|
|
1700
|
+
return {};
|
|
1701
|
+
}
|
|
1702
|
+
async onOpen(context) {
|
|
1703
|
+
await super.onOpen(context);
|
|
1704
|
+
scheduleTask2(this._ctx, async () => {
|
|
1705
|
+
try {
|
|
1706
|
+
const result = await this.rpc.AdmissionDiscoveryService.getAdmissionCredential(this._request);
|
|
1707
|
+
this._onResult.wake(result.admissionCredential);
|
|
1708
|
+
} catch (err) {
|
|
1709
|
+
context.close(err);
|
|
1710
|
+
}
|
|
1711
|
+
});
|
|
1712
|
+
}
|
|
1713
|
+
async onClose() {
|
|
1714
|
+
await this._ctx.dispose();
|
|
1715
|
+
}
|
|
1716
|
+
async onAbort() {
|
|
1717
|
+
await this._ctx.dispose();
|
|
1718
|
+
}
|
|
1719
|
+
};
|
|
1720
|
+
var CredentialServerExtension = class extends RpcExtension2 {
|
|
1721
|
+
constructor(_space) {
|
|
1722
|
+
super({
|
|
1723
|
+
exposed: {
|
|
1724
|
+
AdmissionDiscoveryService: schema6.getService("dxos.mesh.teleport.AdmissionDiscoveryService")
|
|
1725
|
+
}
|
|
1726
|
+
});
|
|
1727
|
+
this._space = _space;
|
|
1728
|
+
}
|
|
1729
|
+
async getHandlers() {
|
|
1730
|
+
return {
|
|
1731
|
+
AdmissionDiscoveryService: {
|
|
1732
|
+
getAdmissionCredential: async (request) => {
|
|
1733
|
+
const memberInfo = this._space.spaceState.members.get(request.memberKey);
|
|
1734
|
+
if (!memberInfo?.credential) {
|
|
1735
|
+
throw new ProtocolError("Space member not found.", request);
|
|
1736
|
+
}
|
|
1737
|
+
return {
|
|
1738
|
+
admissionCredential: memberInfo.credential
|
|
1739
|
+
};
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
};
|
|
1743
|
+
}
|
|
1744
|
+
};
|
|
1745
|
+
|
|
1658
1746
|
// packages/core/echo/echo-pipeline/src/space/space-protocol.ts
|
|
1659
1747
|
import { discoveryKey, subtleCrypto as subtleCrypto3 } from "@dxos/crypto";
|
|
1660
1748
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
@@ -1675,7 +1763,7 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
1675
1763
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1676
1764
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1677
1765
|
}
|
|
1678
|
-
var
|
|
1766
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
|
|
1679
1767
|
var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
|
|
1680
1768
|
var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
|
|
1681
1769
|
var SpaceProtocol = class {
|
|
@@ -1712,7 +1800,7 @@ var SpaceProtocol = class {
|
|
|
1712
1800
|
log8("addFeed", {
|
|
1713
1801
|
key: feed.key
|
|
1714
1802
|
}, {
|
|
1715
|
-
F:
|
|
1803
|
+
F: __dxlog_file10,
|
|
1716
1804
|
L: 109,
|
|
1717
1805
|
S: this,
|
|
1718
1806
|
C: (f, a) => f(...a)
|
|
@@ -1730,7 +1818,7 @@ var SpaceProtocol = class {
|
|
|
1730
1818
|
const credentials = await this._swarmIdentity.credentialProvider(Buffer.from(""));
|
|
1731
1819
|
await this.blobSync.open();
|
|
1732
1820
|
log8("starting...", void 0, {
|
|
1733
|
-
F:
|
|
1821
|
+
F: __dxlog_file10,
|
|
1734
1822
|
L: 128,
|
|
1735
1823
|
S: this,
|
|
1736
1824
|
C: (f, a) => f(...a)
|
|
@@ -1744,7 +1832,7 @@ var SpaceProtocol = class {
|
|
|
1744
1832
|
label: `swarm ${topic.truncate()} for space ${this._spaceKey.truncate()}`
|
|
1745
1833
|
});
|
|
1746
1834
|
log8("started", void 0, {
|
|
1747
|
-
F:
|
|
1835
|
+
F: __dxlog_file10,
|
|
1748
1836
|
L: 138,
|
|
1749
1837
|
S: this,
|
|
1750
1838
|
C: (f, a) => f(...a)
|
|
@@ -1757,14 +1845,14 @@ var SpaceProtocol = class {
|
|
|
1757
1845
|
await this.blobSync.close();
|
|
1758
1846
|
if (this._connection) {
|
|
1759
1847
|
log8("stopping...", void 0, {
|
|
1760
|
-
F:
|
|
1848
|
+
F: __dxlog_file10,
|
|
1761
1849
|
L: 149,
|
|
1762
1850
|
S: this,
|
|
1763
1851
|
C: (f, a) => f(...a)
|
|
1764
1852
|
});
|
|
1765
1853
|
await this._connection.close();
|
|
1766
1854
|
log8("stopped", void 0, {
|
|
1767
|
-
F:
|
|
1855
|
+
F: __dxlog_file10,
|
|
1768
1856
|
L: 151,
|
|
1769
1857
|
S: this,
|
|
1770
1858
|
C: (f, a) => f(...a)
|
|
@@ -1838,7 +1926,7 @@ var SpaceProtocolSession = class {
|
|
|
1838
1926
|
verifier: this._swarmIdentity.credentialAuthenticator,
|
|
1839
1927
|
onAuthSuccess: () => {
|
|
1840
1928
|
log8("Peer authenticated", void 0, {
|
|
1841
|
-
F:
|
|
1929
|
+
F: __dxlog_file10,
|
|
1842
1930
|
L: 248,
|
|
1843
1931
|
S: this,
|
|
1844
1932
|
C: (f, a) => f(...a)
|
|
@@ -1856,7 +1944,7 @@ var SpaceProtocolSession = class {
|
|
|
1856
1944
|
}
|
|
1857
1945
|
async close() {
|
|
1858
1946
|
log8("close", void 0, {
|
|
1859
|
-
F:
|
|
1947
|
+
F: __dxlog_file10,
|
|
1860
1948
|
L: 264,
|
|
1861
1949
|
S: this,
|
|
1862
1950
|
C: (f, a) => f(...a)
|
|
@@ -1875,7 +1963,7 @@ _ts_decorate6([
|
|
|
1875
1963
|
], SpaceProtocolSession.prototype, "authStatus", null);
|
|
1876
1964
|
|
|
1877
1965
|
// packages/core/echo/echo-pipeline/src/space/space-manager.ts
|
|
1878
|
-
import { synchronized as synchronized4, trackLeaks as trackLeaks3 } from "@dxos/async";
|
|
1966
|
+
import { synchronized as synchronized4, trackLeaks as trackLeaks3, Trigger as Trigger2 } from "@dxos/async";
|
|
1879
1967
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
1880
1968
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
1881
1969
|
import { log as log9 } from "@dxos/log";
|
|
@@ -1891,7 +1979,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
1891
1979
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1892
1980
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1893
1981
|
}
|
|
1894
|
-
var
|
|
1982
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
|
|
1895
1983
|
var SpaceManager = class {
|
|
1896
1984
|
constructor({ feedStore, networkManager, metadataStore, snapshotStore, blobStore }) {
|
|
1897
1985
|
this._spaces = new ComplexMap5(PublicKey7.hash);
|
|
@@ -1917,16 +2005,16 @@ var SpaceManager = class {
|
|
|
1917
2005
|
log9.trace("dxos.echo.space-manager.construct-space", trace4.begin({
|
|
1918
2006
|
id: this._instanceId
|
|
1919
2007
|
}), {
|
|
1920
|
-
F:
|
|
1921
|
-
L:
|
|
2008
|
+
F: __dxlog_file11,
|
|
2009
|
+
L: 103,
|
|
1922
2010
|
S: this,
|
|
1923
2011
|
C: (f, a) => f(...a)
|
|
1924
2012
|
});
|
|
1925
2013
|
log9("constructing space...", {
|
|
1926
2014
|
spaceKey: metadata.genesisFeedKey
|
|
1927
2015
|
}, {
|
|
1928
|
-
F:
|
|
1929
|
-
L:
|
|
2016
|
+
F: __dxlog_file11,
|
|
2017
|
+
L: 104,
|
|
1930
2018
|
S: this,
|
|
1931
2019
|
C: (f, a) => f(...a)
|
|
1932
2020
|
});
|
|
@@ -1958,13 +2046,74 @@ var SpaceManager = class {
|
|
|
1958
2046
|
log9.trace("dxos.echo.space-manager.construct-space", trace4.end({
|
|
1959
2047
|
id: this._instanceId
|
|
1960
2048
|
}), {
|
|
1961
|
-
F:
|
|
1962
|
-
L:
|
|
2049
|
+
F: __dxlog_file11,
|
|
2050
|
+
L: 135,
|
|
1963
2051
|
S: this,
|
|
1964
2052
|
C: (f, a) => f(...a)
|
|
1965
2053
|
});
|
|
1966
2054
|
return space;
|
|
1967
2055
|
}
|
|
2056
|
+
async requestSpaceAdmissionCredential(params) {
|
|
2057
|
+
const traceKey = "dxos.echo.space-manager.request-space-admission";
|
|
2058
|
+
log9.trace(traceKey, trace4.begin({
|
|
2059
|
+
id: this._instanceId
|
|
2060
|
+
}), {
|
|
2061
|
+
F: __dxlog_file11,
|
|
2062
|
+
L: 141,
|
|
2063
|
+
S: this,
|
|
2064
|
+
C: (f, a) => f(...a)
|
|
2065
|
+
});
|
|
2066
|
+
log9("requesting space admission credential...", {
|
|
2067
|
+
spaceKey: params.spaceKey
|
|
2068
|
+
}, {
|
|
2069
|
+
F: __dxlog_file11,
|
|
2070
|
+
L: 142,
|
|
2071
|
+
S: this,
|
|
2072
|
+
C: (f, a) => f(...a)
|
|
2073
|
+
});
|
|
2074
|
+
const onCredentialResolved = new Trigger2();
|
|
2075
|
+
const protocol = new SpaceProtocol({
|
|
2076
|
+
topic: params.spaceKey,
|
|
2077
|
+
swarmIdentity: params.swarmIdentity,
|
|
2078
|
+
networkManager: this._networkManager,
|
|
2079
|
+
onSessionAuth: (session) => {
|
|
2080
|
+
session.addExtension("dxos.mesh.teleport.admission-discovery", new CredentialRetrieverExtension({
|
|
2081
|
+
spaceKey: params.spaceKey,
|
|
2082
|
+
memberKey: params.identityKey
|
|
2083
|
+
}, onCredentialResolved));
|
|
2084
|
+
},
|
|
2085
|
+
onAuthFailure: (session) => session.close(),
|
|
2086
|
+
blobStore: this._blobStore
|
|
2087
|
+
});
|
|
2088
|
+
try {
|
|
2089
|
+
await protocol.start();
|
|
2090
|
+
const credential = await onCredentialResolved.wait({
|
|
2091
|
+
timeout: params.timeout
|
|
2092
|
+
});
|
|
2093
|
+
log9.trace(traceKey, trace4.end({
|
|
2094
|
+
id: this._instanceId
|
|
2095
|
+
}), {
|
|
2096
|
+
F: __dxlog_file11,
|
|
2097
|
+
L: 165,
|
|
2098
|
+
S: this,
|
|
2099
|
+
C: (f, a) => f(...a)
|
|
2100
|
+
});
|
|
2101
|
+
return credential;
|
|
2102
|
+
} catch (err) {
|
|
2103
|
+
log9.trace(traceKey, trace4.error({
|
|
2104
|
+
id: this._instanceId,
|
|
2105
|
+
error: err
|
|
2106
|
+
}), {
|
|
2107
|
+
F: __dxlog_file11,
|
|
2108
|
+
L: 168,
|
|
2109
|
+
S: this,
|
|
2110
|
+
C: (f, a) => f(...a)
|
|
2111
|
+
});
|
|
2112
|
+
throw err;
|
|
2113
|
+
} finally {
|
|
2114
|
+
await protocol.stop();
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
1968
2117
|
};
|
|
1969
2118
|
_ts_decorate7([
|
|
1970
2119
|
synchronized4
|
|
@@ -1994,6 +2143,8 @@ export {
|
|
|
1994
2143
|
AuthExtension,
|
|
1995
2144
|
Space,
|
|
1996
2145
|
createIdFromSpaceKey,
|
|
2146
|
+
CredentialRetrieverExtension,
|
|
2147
|
+
CredentialServerExtension,
|
|
1997
2148
|
MOCK_AUTH_PROVIDER,
|
|
1998
2149
|
MOCK_AUTH_VERIFIER,
|
|
1999
2150
|
SpaceProtocol,
|
|
@@ -2001,4 +2152,4 @@ export {
|
|
|
2001
2152
|
SpaceProtocolSession,
|
|
2002
2153
|
SpaceManager
|
|
2003
2154
|
};
|
|
2004
|
-
//# sourceMappingURL=chunk-
|
|
2155
|
+
//# sourceMappingURL=chunk-HS77A4I4.mjs.map
|