@dxos/client-services 0.1.50 → 0.1.51-main.04d9478
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-BAHSFG33.mjs → chunk-QUJROKKU.mjs} +100 -58
- package/dist/lib/browser/chunk-QUJROKKU.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +1 -1
- package/dist/lib/node/index.cjs +113 -71
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +130 -88
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts +1 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/package.json +30 -30
- package/src/packlets/identity/identity.test.ts +9 -3
- package/src/packlets/invitations/invitations-handler.ts +14 -6
- package/src/packlets/invitations/space-invitation-protocol.test.ts +8 -1
- package/src/packlets/logging/logging-service.ts +58 -15
- package/src/packlets/spaces/data-space-manager.test.ts +64 -1
- package/src/packlets/spaces/data-space.ts +4 -2
- package/src/packlets/spaces/spaces-service.ts +4 -0
- package/dist/lib/browser/chunk-BAHSFG33.mjs.map +0 -7
|
@@ -63,7 +63,7 @@ var createMockCredential = async ({ signer, issuer }) => (0, import_credentials.
|
|
|
63
63
|
// packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
|
|
64
64
|
var import_node_assert13 = __toESM(require("node:assert"));
|
|
65
65
|
var import_async19 = require("@dxos/async");
|
|
66
|
-
var
|
|
66
|
+
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
67
67
|
|
|
68
68
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
69
69
|
var import_node_assert12 = __toESM(require("node:assert"));
|
|
@@ -75,7 +75,7 @@ var import_log15 = require("@dxos/log");
|
|
|
75
75
|
var import_messaging = require("@dxos/messaging");
|
|
76
76
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
77
77
|
var import_protocols9 = require("@dxos/protocols");
|
|
78
|
-
var
|
|
78
|
+
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
79
79
|
|
|
80
80
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
81
81
|
var import_async = require("@dxos/async");
|
|
@@ -1417,7 +1417,7 @@ var InvitationsHandler = class {
|
|
|
1417
1417
|
...protocol.toJSON()
|
|
1418
1418
|
}, {
|
|
1419
1419
|
file: "invitations-handler.ts",
|
|
1420
|
-
line:
|
|
1420
|
+
line: 99,
|
|
1421
1421
|
scope: this,
|
|
1422
1422
|
callSite: (f, a) => f(...a)
|
|
1423
1423
|
});
|
|
@@ -1458,7 +1458,7 @@ var InvitationsHandler = class {
|
|
|
1458
1458
|
id: traceId
|
|
1459
1459
|
}), {
|
|
1460
1460
|
file: "invitations-handler.ts",
|
|
1461
|
-
line:
|
|
1461
|
+
line: 138,
|
|
1462
1462
|
scope: this,
|
|
1463
1463
|
callSite: (f, a) => f(...a)
|
|
1464
1464
|
});
|
|
@@ -1466,7 +1466,7 @@ var InvitationsHandler = class {
|
|
|
1466
1466
|
...protocol.toJSON()
|
|
1467
1467
|
}, {
|
|
1468
1468
|
file: "invitations-handler.ts",
|
|
1469
|
-
line:
|
|
1469
|
+
line: 139,
|
|
1470
1470
|
scope: this,
|
|
1471
1471
|
callSite: (f, a) => f(...a)
|
|
1472
1472
|
});
|
|
@@ -1482,7 +1482,7 @@ var InvitationsHandler = class {
|
|
|
1482
1482
|
...protocol.toJSON()
|
|
1483
1483
|
}, {
|
|
1484
1484
|
file: "invitations-handler.ts",
|
|
1485
|
-
line:
|
|
1485
|
+
line: 142,
|
|
1486
1486
|
scope: this,
|
|
1487
1487
|
callSite: (f, a) => f(...a)
|
|
1488
1488
|
});
|
|
@@ -1494,7 +1494,7 @@ var InvitationsHandler = class {
|
|
|
1494
1494
|
id: traceId
|
|
1495
1495
|
}), {
|
|
1496
1496
|
file: "invitations-handler.ts",
|
|
1497
|
-
line:
|
|
1497
|
+
line: 144,
|
|
1498
1498
|
scope: this,
|
|
1499
1499
|
callSite: (f, a) => f(...a)
|
|
1500
1500
|
});
|
|
@@ -1504,7 +1504,7 @@ var InvitationsHandler = class {
|
|
|
1504
1504
|
...protocol.toJSON()
|
|
1505
1505
|
}, {
|
|
1506
1506
|
file: "invitations-handler.ts",
|
|
1507
|
-
line:
|
|
1507
|
+
line: 147,
|
|
1508
1508
|
scope: this,
|
|
1509
1509
|
callSite: (f, a) => f(...a)
|
|
1510
1510
|
});
|
|
@@ -1515,7 +1515,7 @@ var InvitationsHandler = class {
|
|
|
1515
1515
|
} else {
|
|
1516
1516
|
import_log5.log.error("failed", err, {
|
|
1517
1517
|
file: "invitations-handler.ts",
|
|
1518
|
-
line:
|
|
1518
|
+
line: 150,
|
|
1519
1519
|
scope: this,
|
|
1520
1520
|
callSite: (f, a) => f(...a)
|
|
1521
1521
|
});
|
|
@@ -1526,13 +1526,13 @@ var InvitationsHandler = class {
|
|
|
1526
1526
|
error: err
|
|
1527
1527
|
}), {
|
|
1528
1528
|
file: "invitations-handler.ts",
|
|
1529
|
-
line:
|
|
1529
|
+
line: 153,
|
|
1530
1530
|
scope: this,
|
|
1531
1531
|
callSite: (f, a) => f(...a)
|
|
1532
1532
|
});
|
|
1533
1533
|
} finally {
|
|
1534
1534
|
if (type !== import_services4.Invitation.Type.MULTIUSE) {
|
|
1535
|
-
await
|
|
1535
|
+
await swarmConnection.close();
|
|
1536
1536
|
await ctx.dispose();
|
|
1537
1537
|
}
|
|
1538
1538
|
}
|
|
@@ -1568,9 +1568,10 @@ var InvitationsHandler = class {
|
|
|
1568
1568
|
});
|
|
1569
1569
|
return extension;
|
|
1570
1570
|
};
|
|
1571
|
+
let swarmConnection;
|
|
1571
1572
|
(0, import_async9.scheduleTask)(ctx, async () => {
|
|
1572
1573
|
const topic = invitation.swarmKey;
|
|
1573
|
-
|
|
1574
|
+
swarmConnection = await this._networkManager.joinSwarm({
|
|
1574
1575
|
topic,
|
|
1575
1576
|
peerId: topic,
|
|
1576
1577
|
protocolProvider: (0, import_network_manager.createTeleportProtocolFactory)(async (teleport) => {
|
|
@@ -1601,6 +1602,7 @@ var InvitationsHandler = class {
|
|
|
1601
1602
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
1602
1603
|
(0, import_node_assert6.default)(protocol);
|
|
1603
1604
|
const authenticated = new import_async9.Trigger();
|
|
1605
|
+
let admitted = false;
|
|
1604
1606
|
let currentState;
|
|
1605
1607
|
const stream = new import_async9.PushStream();
|
|
1606
1608
|
const setState = (newData) => {
|
|
@@ -1618,7 +1620,7 @@ var InvitationsHandler = class {
|
|
|
1618
1620
|
...protocol.toJSON()
|
|
1619
1621
|
}, {
|
|
1620
1622
|
file: "invitations-handler.ts",
|
|
1621
|
-
line:
|
|
1623
|
+
line: 230,
|
|
1622
1624
|
scope: this,
|
|
1623
1625
|
callSite: (f, a) => f(...a)
|
|
1624
1626
|
});
|
|
@@ -1628,7 +1630,7 @@ var InvitationsHandler = class {
|
|
|
1628
1630
|
} else {
|
|
1629
1631
|
import_log5.log.warn("auth failed", err, {
|
|
1630
1632
|
file: "invitations-handler.ts",
|
|
1631
|
-
line:
|
|
1633
|
+
line: 233,
|
|
1632
1634
|
scope: this,
|
|
1633
1635
|
callSite: (f, a) => f(...a)
|
|
1634
1636
|
});
|
|
@@ -1642,7 +1644,7 @@ var InvitationsHandler = class {
|
|
|
1642
1644
|
...protocol.toJSON()
|
|
1643
1645
|
}, {
|
|
1644
1646
|
file: "invitations-handler.ts",
|
|
1645
|
-
line:
|
|
1647
|
+
line: 241,
|
|
1646
1648
|
scope: this,
|
|
1647
1649
|
callSite: (f, a) => f(...a)
|
|
1648
1650
|
});
|
|
@@ -1657,11 +1659,11 @@ var InvitationsHandler = class {
|
|
|
1657
1659
|
currentState
|
|
1658
1660
|
}, {
|
|
1659
1661
|
file: "invitations-handler.ts",
|
|
1660
|
-
line:
|
|
1662
|
+
line: 251,
|
|
1661
1663
|
scope: this,
|
|
1662
1664
|
callSite: (f, a) => f(...a)
|
|
1663
1665
|
});
|
|
1664
|
-
if (
|
|
1666
|
+
if (!admitted) {
|
|
1665
1667
|
stream.error(new Error("Remote peer disconnected."));
|
|
1666
1668
|
}
|
|
1667
1669
|
});
|
|
@@ -1672,7 +1674,7 @@ var InvitationsHandler = class {
|
|
|
1672
1674
|
id: traceId
|
|
1673
1675
|
}), {
|
|
1674
1676
|
file: "invitations-handler.ts",
|
|
1675
|
-
line:
|
|
1677
|
+
line: 260,
|
|
1676
1678
|
scope: this,
|
|
1677
1679
|
callSite: (f, a) => f(...a)
|
|
1678
1680
|
});
|
|
@@ -1684,7 +1686,7 @@ var InvitationsHandler = class {
|
|
|
1684
1686
|
...protocol.toJSON()
|
|
1685
1687
|
}, {
|
|
1686
1688
|
file: "invitations-handler.ts",
|
|
1687
|
-
line:
|
|
1689
|
+
line: 268,
|
|
1688
1690
|
scope: this,
|
|
1689
1691
|
callSite: (f, a) => f(...a)
|
|
1690
1692
|
});
|
|
@@ -1695,7 +1697,7 @@ var InvitationsHandler = class {
|
|
|
1695
1697
|
...protocol.toJSON()
|
|
1696
1698
|
}, {
|
|
1697
1699
|
file: "invitations-handler.ts",
|
|
1698
|
-
line:
|
|
1700
|
+
line: 272,
|
|
1699
1701
|
scope: this,
|
|
1700
1702
|
callSite: (f, a) => f(...a)
|
|
1701
1703
|
});
|
|
@@ -1705,7 +1707,7 @@ var InvitationsHandler = class {
|
|
|
1705
1707
|
response: introductionResponse
|
|
1706
1708
|
}, {
|
|
1707
1709
|
file: "invitations-handler.ts",
|
|
1708
|
-
line:
|
|
1710
|
+
line: 276,
|
|
1709
1711
|
scope: this,
|
|
1710
1712
|
callSite: (f, a) => f(...a)
|
|
1711
1713
|
});
|
|
@@ -1717,7 +1719,7 @@ var InvitationsHandler = class {
|
|
|
1717
1719
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1718
1720
|
(0, import_log5.log)("guest waiting for authentication code...", {}, {
|
|
1719
1721
|
file: "invitations-handler.ts",
|
|
1720
|
-
line:
|
|
1722
|
+
line: 285,
|
|
1721
1723
|
scope: this,
|
|
1722
1724
|
callSite: (f, a) => f(...a)
|
|
1723
1725
|
});
|
|
@@ -1729,7 +1731,7 @@ var InvitationsHandler = class {
|
|
|
1729
1731
|
});
|
|
1730
1732
|
(0, import_log5.log)("sending authentication request", {}, {
|
|
1731
1733
|
file: "invitations-handler.ts",
|
|
1732
|
-
line:
|
|
1734
|
+
line: 289,
|
|
1733
1735
|
scope: this,
|
|
1734
1736
|
callSite: (f, a) => f(...a)
|
|
1735
1737
|
});
|
|
@@ -1750,7 +1752,7 @@ var InvitationsHandler = class {
|
|
|
1750
1752
|
attempt
|
|
1751
1753
|
}, {
|
|
1752
1754
|
file: "invitations-handler.ts",
|
|
1753
|
-
line:
|
|
1755
|
+
line: 300,
|
|
1754
1756
|
scope: this,
|
|
1755
1757
|
callSite: (f, a) => f(...a)
|
|
1756
1758
|
});
|
|
@@ -1767,18 +1769,19 @@ var InvitationsHandler = class {
|
|
|
1767
1769
|
...protocol.toJSON()
|
|
1768
1770
|
}, {
|
|
1769
1771
|
file: "invitations-handler.ts",
|
|
1770
|
-
line:
|
|
1772
|
+
line: 311,
|
|
1771
1773
|
scope: this,
|
|
1772
1774
|
callSite: (f, a) => f(...a)
|
|
1773
1775
|
});
|
|
1774
1776
|
const admissionRequest = await protocol.createAdmissionRequest();
|
|
1775
1777
|
const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
|
|
1778
|
+
admitted = true;
|
|
1776
1779
|
const result = await protocol.accept(admissionResponse, admissionRequest);
|
|
1777
1780
|
(0, import_log5.log)("admitted by host", {
|
|
1778
1781
|
...protocol.toJSON()
|
|
1779
1782
|
}, {
|
|
1780
1783
|
file: "invitations-handler.ts",
|
|
1781
|
-
line:
|
|
1784
|
+
line: 322,
|
|
1782
1785
|
scope: this,
|
|
1783
1786
|
callSite: (f, a) => f(...a)
|
|
1784
1787
|
});
|
|
@@ -1790,7 +1793,7 @@ var InvitationsHandler = class {
|
|
|
1790
1793
|
id: traceId
|
|
1791
1794
|
}), {
|
|
1792
1795
|
file: "invitations-handler.ts",
|
|
1793
|
-
line:
|
|
1796
|
+
line: 324,
|
|
1794
1797
|
scope: this,
|
|
1795
1798
|
callSite: (f, a) => f(...a)
|
|
1796
1799
|
});
|
|
@@ -1800,7 +1803,7 @@ var InvitationsHandler = class {
|
|
|
1800
1803
|
...protocol.toJSON()
|
|
1801
1804
|
}, {
|
|
1802
1805
|
file: "invitations-handler.ts",
|
|
1803
|
-
line:
|
|
1806
|
+
line: 327,
|
|
1804
1807
|
scope: this,
|
|
1805
1808
|
callSite: (f, a) => f(...a)
|
|
1806
1809
|
});
|
|
@@ -1810,7 +1813,7 @@ var InvitationsHandler = class {
|
|
|
1810
1813
|
} else {
|
|
1811
1814
|
(0, import_log5.log)("auth failed", err, {
|
|
1812
1815
|
file: "invitations-handler.ts",
|
|
1813
|
-
line:
|
|
1816
|
+
line: 330,
|
|
1814
1817
|
scope: this,
|
|
1815
1818
|
callSite: (f, a) => f(...a)
|
|
1816
1819
|
});
|
|
@@ -1821,7 +1824,7 @@ var InvitationsHandler = class {
|
|
|
1821
1824
|
error: err
|
|
1822
1825
|
}), {
|
|
1823
1826
|
file: "invitations-handler.ts",
|
|
1824
|
-
line:
|
|
1827
|
+
line: 333,
|
|
1825
1828
|
scope: this,
|
|
1826
1829
|
callSite: (f, a) => f(...a)
|
|
1827
1830
|
});
|
|
@@ -1839,7 +1842,7 @@ var InvitationsHandler = class {
|
|
|
1839
1842
|
...protocol.toJSON()
|
|
1840
1843
|
}, {
|
|
1841
1844
|
file: "invitations-handler.ts",
|
|
1842
|
-
line:
|
|
1845
|
+
line: 344,
|
|
1843
1846
|
scope: this,
|
|
1844
1847
|
callSite: (f, a) => f(...a)
|
|
1845
1848
|
});
|
|
@@ -1849,7 +1852,7 @@ var InvitationsHandler = class {
|
|
|
1849
1852
|
} else {
|
|
1850
1853
|
(0, import_log5.log)("auth failed", err, {
|
|
1851
1854
|
file: "invitations-handler.ts",
|
|
1852
|
-
line:
|
|
1855
|
+
line: 347,
|
|
1853
1856
|
scope: this,
|
|
1854
1857
|
callSite: (f, a) => f(...a)
|
|
1855
1858
|
});
|
|
@@ -2211,6 +2214,7 @@ __decorate([
|
|
|
2211
2214
|
var import_async12 = require("@dxos/async");
|
|
2212
2215
|
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
2213
2216
|
var import_log9 = require("@dxos/log");
|
|
2217
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2214
2218
|
var import_util3 = require("@dxos/util");
|
|
2215
2219
|
var LoggingServiceImpl = class {
|
|
2216
2220
|
constructor() {
|
|
@@ -2227,31 +2231,60 @@ var LoggingServiceImpl = class {
|
|
|
2227
2231
|
import_log9.log.runtimeConfig.processors.splice(index, 1);
|
|
2228
2232
|
}
|
|
2229
2233
|
queryLogs(request) {
|
|
2230
|
-
var _a;
|
|
2231
|
-
const filters = ((_a = request.filters) == null ? void 0 : _a.length) ? request.filters : void 0;
|
|
2232
2234
|
return new import_codec_protobuf10.Stream(({ ctx, next }) => {
|
|
2233
2235
|
const handler = (entry2) => {
|
|
2234
|
-
var
|
|
2235
|
-
if (
|
|
2236
|
+
var _a, _b, _c, _d, _e;
|
|
2237
|
+
if (LOG_PROCESSING > 0) {
|
|
2236
2238
|
return;
|
|
2237
2239
|
}
|
|
2238
|
-
if ((0
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2240
|
+
if (((_a = entry2.meta) == null ? void 0 : _a.file.includes("logging-service")) || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
|
|
2241
|
+
return;
|
|
2242
|
+
}
|
|
2243
|
+
if (!shouldLog(entry2, request)) {
|
|
2244
|
+
return;
|
|
2245
|
+
}
|
|
2246
|
+
const record = {
|
|
2247
|
+
...entry2,
|
|
2248
|
+
context: (0, import_util3.jsonify)((0, import_log9.getContextFromEntry)(entry2)),
|
|
2249
|
+
timestamp: new Date(),
|
|
2250
|
+
meta: {
|
|
2251
|
+
// TODO(dmaretskyi): Fix proto.
|
|
2252
|
+
file: (_c = (_b = entry2.meta) == null ? void 0 : _b.file) != null ? _c : "",
|
|
2253
|
+
line: (_e = (_d = entry2.meta) == null ? void 0 : _d.line) != null ? _e : 0
|
|
2254
|
+
}
|
|
2255
|
+
};
|
|
2256
|
+
try {
|
|
2257
|
+
LOG_PROCESSING++;
|
|
2245
2258
|
next(record);
|
|
2259
|
+
} finally {
|
|
2260
|
+
LOG_PROCESSING--;
|
|
2246
2261
|
}
|
|
2247
2262
|
};
|
|
2248
|
-
|
|
2249
|
-
this._logs.off(handler);
|
|
2250
|
-
});
|
|
2251
|
-
this._logs.on(handler);
|
|
2263
|
+
this._logs.on(ctx, handler);
|
|
2252
2264
|
});
|
|
2253
2265
|
}
|
|
2254
2266
|
};
|
|
2267
|
+
var matchFilter = (filter, level, path, options) => {
|
|
2268
|
+
switch (options) {
|
|
2269
|
+
case import_services7.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
2270
|
+
return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
|
|
2271
|
+
case import_services7.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
2272
|
+
return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
|
|
2273
|
+
}
|
|
2274
|
+
};
|
|
2275
|
+
var shouldLog = (entry2, request) => {
|
|
2276
|
+
var _a;
|
|
2277
|
+
const options = (_a = request.options) != null ? _a : import_services7.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
2278
|
+
if (request.filters === void 0) {
|
|
2279
|
+
return options === import_services7.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
2280
|
+
} else {
|
|
2281
|
+
return request.filters.some((filter) => {
|
|
2282
|
+
var _a2, _b;
|
|
2283
|
+
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.file) != null ? _b : "", options);
|
|
2284
|
+
});
|
|
2285
|
+
}
|
|
2286
|
+
};
|
|
2287
|
+
var LOG_PROCESSING = 0;
|
|
2255
2288
|
|
|
2256
2289
|
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
2257
2290
|
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
@@ -2293,7 +2326,7 @@ var import_credentials13 = require("@dxos/credentials");
|
|
|
2293
2326
|
var import_keys10 = require("@dxos/keys");
|
|
2294
2327
|
var import_log12 = require("@dxos/log");
|
|
2295
2328
|
var import_protocols6 = require("@dxos/protocols");
|
|
2296
|
-
var
|
|
2329
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2297
2330
|
var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
|
|
2298
2331
|
var import_util6 = require("@dxos/util");
|
|
2299
2332
|
|
|
@@ -2306,8 +2339,9 @@ var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
|
2306
2339
|
var import_errors3 = require("@dxos/errors");
|
|
2307
2340
|
var import_keys9 = require("@dxos/keys");
|
|
2308
2341
|
var import_log11 = require("@dxos/log");
|
|
2309
|
-
var
|
|
2342
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2310
2343
|
var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2344
|
+
var import_timeframe = require("@dxos/timeframe");
|
|
2311
2345
|
var import_util5 = require("@dxos/util");
|
|
2312
2346
|
|
|
2313
2347
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
@@ -2566,7 +2600,7 @@ var __decorate2 = function(decorators, target, key, desc) {
|
|
|
2566
2600
|
var DataSpace = class DataSpace2 {
|
|
2567
2601
|
constructor(params) {
|
|
2568
2602
|
this._ctx = new import_context6.Context();
|
|
2569
|
-
this._state =
|
|
2603
|
+
this._state = import_services8.SpaceState.CLOSED;
|
|
2570
2604
|
/**
|
|
2571
2605
|
* Error for _state === SpaceState.ERROR.
|
|
2572
2606
|
*/
|
|
@@ -2620,11 +2654,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2620
2654
|
await this.notarizationPlugin.open();
|
|
2621
2655
|
await this._notarizationPluginConsumer.open();
|
|
2622
2656
|
await this._inner.open();
|
|
2623
|
-
this._state =
|
|
2657
|
+
this._state = import_services8.SpaceState.INACTIVE;
|
|
2624
2658
|
this.metrics.open = new Date();
|
|
2625
2659
|
}
|
|
2626
2660
|
async close() {
|
|
2627
|
-
this._state =
|
|
2661
|
+
this._state = import_services8.SpaceState.CLOSED;
|
|
2628
2662
|
await this._ctx.dispose();
|
|
2629
2663
|
await this.authVerifier.close();
|
|
2630
2664
|
await this._inner.close();
|
|
@@ -2650,7 +2684,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2650
2684
|
if (err instanceof import_errors3.CancelledError) {
|
|
2651
2685
|
(0, import_log11.log)("Data pipeline initialization cancelled", err, {
|
|
2652
2686
|
file: "data-space.ts",
|
|
2653
|
-
line:
|
|
2687
|
+
line: 173,
|
|
2654
2688
|
scope: this,
|
|
2655
2689
|
callSite: (f, a) => f(...a)
|
|
2656
2690
|
});
|
|
@@ -2658,11 +2692,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2658
2692
|
}
|
|
2659
2693
|
import_log11.log.error("Error initializing data pipeline", err, {
|
|
2660
2694
|
file: "data-space.ts",
|
|
2661
|
-
line:
|
|
2695
|
+
line: 177,
|
|
2662
2696
|
scope: this,
|
|
2663
2697
|
callSite: (f, a) => f(...a)
|
|
2664
2698
|
});
|
|
2665
|
-
this._state =
|
|
2699
|
+
this._state = import_services8.SpaceState.ERROR;
|
|
2666
2700
|
this.error = err;
|
|
2667
2701
|
this.stateUpdate.emit();
|
|
2668
2702
|
} finally {
|
|
@@ -2672,10 +2706,10 @@ var DataSpace = class DataSpace2 {
|
|
|
2672
2706
|
}
|
|
2673
2707
|
async initializeDataPipeline() {
|
|
2674
2708
|
var _a, _b, _c, _d;
|
|
2675
|
-
if (this._state !==
|
|
2709
|
+
if (this._state !== import_services8.SpaceState.INACTIVE) {
|
|
2676
2710
|
throw new import_errors3.SystemError("Invalid operation");
|
|
2677
2711
|
}
|
|
2678
|
-
this._state =
|
|
2712
|
+
this._state = import_services8.SpaceState.INITIALIZING;
|
|
2679
2713
|
await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
2680
2714
|
ctx: this._ctx,
|
|
2681
2715
|
breakOnStall: false
|
|
@@ -2715,7 +2749,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2715
2749
|
callSite: (f, a) => f(...a)
|
|
2716
2750
|
});
|
|
2717
2751
|
await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
|
|
2718
|
-
this._state =
|
|
2752
|
+
this._state = import_services8.SpaceState.READY;
|
|
2719
2753
|
this.stateUpdate.emit();
|
|
2720
2754
|
await ((_d = (_c = this._callbacks).afterReady) == null ? void 0 : _d.call(_c));
|
|
2721
2755
|
}
|
|
@@ -2765,7 +2799,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2765
2799
|
async createEpoch() {
|
|
2766
2800
|
var _a, _b;
|
|
2767
2801
|
const epoch = await this.dataPipeline.createEpoch();
|
|
2768
|
-
await this.inner.controlPipeline.writer.write({
|
|
2802
|
+
const receipt = await this.inner.controlPipeline.writer.write({
|
|
2769
2803
|
credential: {
|
|
2770
2804
|
credential: await this._signingContext.credentialSigner.createCredential({
|
|
2771
2805
|
subject: this.key,
|
|
@@ -2776,6 +2810,12 @@ var DataSpace = class DataSpace2 {
|
|
|
2776
2810
|
})
|
|
2777
2811
|
}
|
|
2778
2812
|
});
|
|
2813
|
+
await this.inner.controlPipeline.state.waitUntilTimeframe(new import_timeframe.Timeframe([
|
|
2814
|
+
[
|
|
2815
|
+
receipt.feedKey,
|
|
2816
|
+
receipt.seq
|
|
2817
|
+
]
|
|
2818
|
+
]));
|
|
2779
2819
|
for (const feed of (_b = (_a = this.inner.dataPipeline.pipelineState) == null ? void 0 : _a.feeds) != null ? _b : []) {
|
|
2780
2820
|
const indexBeforeEpoch = epoch.timeframe.get(feed.key);
|
|
2781
2821
|
if (indexBeforeEpoch) {
|
|
@@ -2795,7 +2835,7 @@ DataSpace = __decorate2([
|
|
|
2795
2835
|
var import_credentials11 = require("@dxos/credentials");
|
|
2796
2836
|
var import_debug4 = require("@dxos/debug");
|
|
2797
2837
|
var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2798
|
-
var
|
|
2838
|
+
var import_timeframe2 = require("@dxos/timeframe");
|
|
2799
2839
|
var spaceGenesis = async (keyring, signingContext, space) => {
|
|
2800
2840
|
var _a, _b, _c, _d;
|
|
2801
2841
|
const credentials = [
|
|
@@ -2846,7 +2886,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2846
2886
|
"@type": "dxos.halo.credentials.Epoch",
|
|
2847
2887
|
number: 0,
|
|
2848
2888
|
previousId: void 0,
|
|
2849
|
-
timeframe: new
|
|
2889
|
+
timeframe: new import_timeframe2.Timeframe(),
|
|
2850
2890
|
snapshotCid: void 0
|
|
2851
2891
|
}
|
|
2852
2892
|
})
|
|
@@ -3026,7 +3066,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3026
3066
|
async waitUntilSpaceReady(spaceKey) {
|
|
3027
3067
|
await (0, import_context7.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
3028
3068
|
const space = this._spaces.get(spaceKey);
|
|
3029
|
-
return !!space && space.state ===
|
|
3069
|
+
return !!space && space.state === import_services9.SpaceState.READY;
|
|
3030
3070
|
}));
|
|
3031
3071
|
}
|
|
3032
3072
|
async _constructSpace(metadata) {
|
|
@@ -3150,7 +3190,7 @@ var import_debug5 = require("@dxos/debug");
|
|
|
3150
3190
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
3151
3191
|
var import_log13 = require("@dxos/log");
|
|
3152
3192
|
var import_protocols7 = require("@dxos/protocols");
|
|
3153
|
-
var
|
|
3193
|
+
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3154
3194
|
var import_util7 = require("@dxos/util");
|
|
3155
3195
|
var TIMEFRAME_UPDATE_DEBOUNCE_TIME = 500;
|
|
3156
3196
|
var SpacesServiceImpl = class {
|
|
@@ -3180,7 +3220,7 @@ var SpacesServiceImpl = class {
|
|
|
3180
3220
|
spaces
|
|
3181
3221
|
}, {
|
|
3182
3222
|
file: "spaces-service.ts",
|
|
3183
|
-
line:
|
|
3223
|
+
line: 60,
|
|
3184
3224
|
scope: this,
|
|
3185
3225
|
callSite: (f, a) => f(...a)
|
|
3186
3226
|
});
|
|
@@ -3267,12 +3307,13 @@ var SpacesServiceImpl = class {
|
|
|
3267
3307
|
await space.createEpoch();
|
|
3268
3308
|
}
|
|
3269
3309
|
_transformSpace(space) {
|
|
3270
|
-
var _a, _b, _c, _d, _e;
|
|
3310
|
+
var _a, _b, _c, _d, _e, _f;
|
|
3271
3311
|
return {
|
|
3272
3312
|
spaceKey: space.key,
|
|
3273
3313
|
state: space.state,
|
|
3274
3314
|
error: space.error ? (0, import_protocols7.encodeError)(space.error) : void 0,
|
|
3275
3315
|
pipeline: {
|
|
3316
|
+
currentEpoch: space.dataPipeline.currentEpoch,
|
|
3276
3317
|
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
3277
3318
|
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
3278
3319
|
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
@@ -3291,9 +3332,10 @@ var SpacesServiceImpl = class {
|
|
|
3291
3332
|
displayName: (_b2 = (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName) != null ? _b2 : (0, import_util7.humanize)(member.key)
|
|
3292
3333
|
}
|
|
3293
3334
|
},
|
|
3294
|
-
presence: ((_c2 = this._identityManager.identity) == null ? void 0 : _c2.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ?
|
|
3335
|
+
presence: ((_c2 = this._identityManager.identity) == null ? void 0 : _c2.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services10.SpaceMember.PresenceState.ONLINE : import_services10.SpaceMember.PresenceState.OFFLINE
|
|
3295
3336
|
};
|
|
3296
3337
|
}),
|
|
3338
|
+
creator: (_f = space.inner.spaceState.creator) == null ? void 0 : _f.key,
|
|
3297
3339
|
cache: space.cache,
|
|
3298
3340
|
metrics: space.metrics
|
|
3299
3341
|
};
|
|
@@ -3399,7 +3441,7 @@ var import_keyring = require("@dxos/keyring");
|
|
|
3399
3441
|
var import_keys11 = require("@dxos/keys");
|
|
3400
3442
|
var import_log14 = require("@dxos/log");
|
|
3401
3443
|
var import_protocols8 = require("@dxos/protocols");
|
|
3402
|
-
var
|
|
3444
|
+
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3403
3445
|
var ServiceContext = class {
|
|
3404
3446
|
// prettier-ignore
|
|
3405
3447
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
@@ -3432,7 +3474,7 @@ var ServiceContext = class {
|
|
|
3432
3474
|
});
|
|
3433
3475
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
3434
3476
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
3435
|
-
this._handlerFactories.set(
|
|
3477
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
|
|
3436
3478
|
var _a;
|
|
3437
3479
|
return (_a = this.identityManager.identity) != null ? _a : (0, import_debug6.failUndefined)();
|
|
3438
3480
|
}, this._acceptIdentity.bind(this)));
|
|
@@ -3544,7 +3586,7 @@ var ServiceContext = class {
|
|
|
3544
3586
|
};
|
|
3545
3587
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
3546
3588
|
await this.dataSpaceManager.open();
|
|
3547
|
-
this._handlerFactories.set(
|
|
3589
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.SPACE, (invitation) => {
|
|
3548
3590
|
(0, import_node_assert11.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
|
|
3549
3591
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
3550
3592
|
});
|
|
@@ -3670,12 +3712,12 @@ var ClientServicesHost = class {
|
|
|
3670
3712
|
this._systemService = new SystemServiceImpl({
|
|
3671
3713
|
config: this._config,
|
|
3672
3714
|
statusUpdate: this._statusUpdate,
|
|
3673
|
-
getCurrentStatus: () => this.isOpen ?
|
|
3715
|
+
getCurrentStatus: () => this.isOpen ? import_services12.SystemStatus.ACTIVE : import_services12.SystemStatus.INACTIVE,
|
|
3674
3716
|
onUpdateStatus: async (status) => {
|
|
3675
3717
|
var _a, _b;
|
|
3676
|
-
if (!this.isOpen && status ===
|
|
3718
|
+
if (!this.isOpen && status === import_services12.SystemStatus.ACTIVE) {
|
|
3677
3719
|
await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
|
|
3678
|
-
} else if (this.isOpen && status ===
|
|
3720
|
+
} else if (this.isOpen && status === import_services12.SystemStatus.INACTIVE) {
|
|
3679
3721
|
await ((_b = this._resourceLock) == null ? void 0 : _b.release());
|
|
3680
3722
|
}
|
|
3681
3723
|
},
|
|
@@ -3883,7 +3925,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
3883
3925
|
hostObservable.subscribe(async (hostInvitation) => {
|
|
3884
3926
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
3885
3927
|
switch (hostInvitation.state) {
|
|
3886
|
-
case
|
|
3928
|
+
case import_services13.Invitation.State.CONNECTING: {
|
|
3887
3929
|
if ((_b = (_a = hooks == null ? void 0 : hooks.host) == null ? void 0 : _a.onConnecting) == null ? void 0 : _b.call(_a, hostObservable)) {
|
|
3888
3930
|
break;
|
|
3889
3931
|
}
|
|
@@ -3891,29 +3933,29 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
3891
3933
|
guestObservable.subscribe(async (guestInvitation) => {
|
|
3892
3934
|
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2;
|
|
3893
3935
|
switch (guestInvitation.state) {
|
|
3894
|
-
case
|
|
3936
|
+
case import_services13.Invitation.State.CONNECTING: {
|
|
3895
3937
|
if ((_b2 = (_a2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _a2.onConnecting) == null ? void 0 : _b2.call(_a2, guestObservable)) {
|
|
3896
3938
|
break;
|
|
3897
3939
|
}
|
|
3898
3940
|
(0, import_node_assert13.default)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey));
|
|
3899
3941
|
break;
|
|
3900
3942
|
}
|
|
3901
|
-
case
|
|
3943
|
+
case import_services13.Invitation.State.CONNECTED: {
|
|
3902
3944
|
(_d2 = (_c2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _c2.onConnected) == null ? void 0 : _d2.call(_c2, guestObservable);
|
|
3903
3945
|
break;
|
|
3904
3946
|
}
|
|
3905
|
-
case
|
|
3947
|
+
case import_services13.Invitation.State.READY_FOR_AUTHENTICATION: {
|
|
3906
3948
|
if ((_f2 = (_e2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _e2.onReady) == null ? void 0 : _f2.call(_e2, guestObservable)) {
|
|
3907
3949
|
break;
|
|
3908
3950
|
}
|
|
3909
3951
|
await guestObservable.authenticate(await authCode.wait());
|
|
3910
3952
|
break;
|
|
3911
3953
|
}
|
|
3912
|
-
case
|
|
3954
|
+
case import_services13.Invitation.State.AUTHENTICATING: {
|
|
3913
3955
|
(_h2 = (_g2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _g2.onAuthenticating) == null ? void 0 : _h2.call(_g2, guestObservable);
|
|
3914
3956
|
break;
|
|
3915
3957
|
}
|
|
3916
|
-
case
|
|
3958
|
+
case import_services13.Invitation.State.SUCCESS: {
|
|
3917
3959
|
if ((_j2 = (_i2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _i2.onSuccess) == null ? void 0 : _j2.call(_i2, guestObservable)) {
|
|
3918
3960
|
break;
|
|
3919
3961
|
}
|
|
@@ -3922,7 +3964,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
3922
3964
|
});
|
|
3923
3965
|
break;
|
|
3924
3966
|
}
|
|
3925
|
-
case
|
|
3967
|
+
case import_services13.Invitation.State.CANCELLED: {
|
|
3926
3968
|
if ((_l2 = (_k2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _k2.onCancelled) == null ? void 0 : _l2.call(_k2, guestObservable)) {
|
|
3927
3969
|
break;
|
|
3928
3970
|
}
|
|
@@ -3931,7 +3973,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
3931
3973
|
});
|
|
3932
3974
|
break;
|
|
3933
3975
|
}
|
|
3934
|
-
case
|
|
3976
|
+
case import_services13.Invitation.State.TIMEOUT: {
|
|
3935
3977
|
if ((_n2 = (_m2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _m2.onTimeout) == null ? void 0 : _n2.call(_m2, guestObservable)) {
|
|
3936
3978
|
return;
|
|
3937
3979
|
}
|
|
@@ -3951,11 +3993,11 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
3951
3993
|
});
|
|
3952
3994
|
break;
|
|
3953
3995
|
}
|
|
3954
|
-
case
|
|
3996
|
+
case import_services13.Invitation.State.CONNECTED: {
|
|
3955
3997
|
(_d = (_c = hooks == null ? void 0 : hooks.host) == null ? void 0 : _c.onConnected) == null ? void 0 : _d.call(_c, hostObservable);
|
|
3956
3998
|
break;
|
|
3957
3999
|
}
|
|
3958
|
-
case
|
|
4000
|
+
case import_services13.Invitation.State.READY_FOR_AUTHENTICATION: {
|
|
3959
4001
|
if ((_f = (_e = hooks == null ? void 0 : hooks.host) == null ? void 0 : _e.onReady) == null ? void 0 : _f.call(_e, hostObservable)) {
|
|
3960
4002
|
break;
|
|
3961
4003
|
}
|
|
@@ -3964,11 +4006,11 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
3964
4006
|
}
|
|
3965
4007
|
break;
|
|
3966
4008
|
}
|
|
3967
|
-
case
|
|
4009
|
+
case import_services13.Invitation.State.AUTHENTICATING: {
|
|
3968
4010
|
(_h = (_g = hooks == null ? void 0 : hooks.host) == null ? void 0 : _g.onAuthenticating) == null ? void 0 : _h.call(_g, hostObservable);
|
|
3969
4011
|
break;
|
|
3970
4012
|
}
|
|
3971
|
-
case
|
|
4013
|
+
case import_services13.Invitation.State.SUCCESS: {
|
|
3972
4014
|
if ((_j = (_i = hooks == null ? void 0 : hooks.host) == null ? void 0 : _i.onSuccess) == null ? void 0 : _j.call(_i, hostObservable)) {
|
|
3973
4015
|
break;
|
|
3974
4016
|
}
|
|
@@ -3977,7 +4019,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
3977
4019
|
});
|
|
3978
4020
|
break;
|
|
3979
4021
|
}
|
|
3980
|
-
case
|
|
4022
|
+
case import_services13.Invitation.State.CANCELLED: {
|
|
3981
4023
|
if ((_l = (_k = hooks == null ? void 0 : hooks.host) == null ? void 0 : _k.onCancelled) == null ? void 0 : _l.call(_k, hostObservable)) {
|
|
3982
4024
|
break;
|
|
3983
4025
|
}
|
|
@@ -3986,7 +4028,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
3986
4028
|
});
|
|
3987
4029
|
break;
|
|
3988
4030
|
}
|
|
3989
|
-
case
|
|
4031
|
+
case import_services13.Invitation.State.TIMEOUT: {
|
|
3990
4032
|
if ((_n = (_m = hooks == null ? void 0 : hooks.host) == null ? void 0 : _m.onTimeout) == null ? void 0 : _n.call(_m, hostObservable)) {
|
|
3991
4033
|
break;
|
|
3992
4034
|
}
|
|
@@ -4012,12 +4054,12 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
4012
4054
|
};
|
|
4013
4055
|
var createInvitation = (host, options) => {
|
|
4014
4056
|
options != null ? options : options = {
|
|
4015
|
-
authMethod:
|
|
4057
|
+
authMethod: import_services13.Invitation.AuthMethod.NONE,
|
|
4016
4058
|
...options != null ? options : {}
|
|
4017
4059
|
};
|
|
4018
4060
|
if (host instanceof ServiceContext) {
|
|
4019
4061
|
const hostHandler = host.getInvitationHandler({
|
|
4020
|
-
kind:
|
|
4062
|
+
kind: import_services13.Invitation.Kind.SPACE,
|
|
4021
4063
|
...options
|
|
4022
4064
|
});
|
|
4023
4065
|
return host.invitations.createInvitation(hostHandler, options);
|