@dxos/client-services 0.4.7 → 0.4.8-main.0602afb
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-NI6XJLUJ.mjs → chunk-WAR4XN64.mjs} +348 -160
- package/dist/lib/browser/chunk-WAR4XN64.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +3 -1
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-RH65IX2V.cjs → chunk-S4SHWFEU.cjs} +323 -134
- package/dist/lib/node/chunk-S4SHWFEU.cjs.map +7 -0
- package/dist/lib/node/index.cjs +39 -37
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +8 -8
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +1 -0
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts +9 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +2 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +2 -0
- package/dist/types/src/packlets/spaces/automerge-space-state.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 +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/package.json +37 -35
- package/src/packlets/identity/identity-manager.ts +1 -1
- package/src/packlets/invitations/invitations-handler.ts +37 -2
- package/src/packlets/invitations/invitations-service.ts +83 -5
- package/src/packlets/services/service-context.ts +26 -4
- package/src/packlets/services/service-host.ts +15 -2
- package/src/packlets/spaces/automerge-space-state.ts +15 -0
- package/src/packlets/spaces/data-space.ts +33 -11
- package/src/packlets/spaces/spaces-service.ts +2 -2
- package/src/version.ts +1 -5
- package/dist/lib/browser/chunk-NI6XJLUJ.mjs.map +0 -7
- package/dist/lib/node/chunk-RH65IX2V.cjs.map +0 -7
|
@@ -1043,7 +1043,7 @@ var IdentityManager = class {
|
|
|
1043
1043
|
identityKey: identityRecord.identityKey
|
|
1044
1044
|
});
|
|
1045
1045
|
await space.setControlFeed(controlFeed);
|
|
1046
|
-
|
|
1046
|
+
await space.setDataFeed(dataFeed);
|
|
1047
1047
|
const identity = new Identity({
|
|
1048
1048
|
space,
|
|
1049
1049
|
presence,
|
|
@@ -1638,11 +1638,11 @@ var InvitationsHandler = class {
|
|
|
1638
1638
|
this._networkManager = _networkManager;
|
|
1639
1639
|
}
|
|
1640
1640
|
createInvitation(protocol, options) {
|
|
1641
|
-
const { invitationId = PublicKey6.random().toHex(), type = Invitation3.Type.INTERACTIVE, authMethod = Invitation3.AuthMethod.SHARED_SECRET, state = Invitation3.State.INIT, timeout = INVITATION_TIMEOUT, swarmKey = PublicKey6.random() } = options ?? {};
|
|
1641
|
+
const { invitationId = PublicKey6.random().toHex(), type = Invitation3.Type.INTERACTIVE, authMethod = Invitation3.AuthMethod.SHARED_SECRET, state = Invitation3.State.INIT, timeout = INVITATION_TIMEOUT, swarmKey = PublicKey6.random(), persistent = true, created = /* @__PURE__ */ new Date(), lifetime = 86400 } = options ?? {};
|
|
1642
1642
|
const authCode = options?.authCode ?? (authMethod === Invitation3.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1643
1643
|
invariant6(protocol, void 0, {
|
|
1644
1644
|
F: __dxlog_file7,
|
|
1645
|
-
L:
|
|
1645
|
+
L: 84,
|
|
1646
1646
|
S: this,
|
|
1647
1647
|
A: [
|
|
1648
1648
|
"protocol",
|
|
@@ -1657,13 +1657,16 @@ var InvitationsHandler = class {
|
|
|
1657
1657
|
swarmKey,
|
|
1658
1658
|
authCode,
|
|
1659
1659
|
timeout,
|
|
1660
|
+
persistent,
|
|
1661
|
+
created,
|
|
1662
|
+
lifetime,
|
|
1660
1663
|
...protocol.getInvitationContext()
|
|
1661
1664
|
};
|
|
1662
1665
|
const stream = new PushStream();
|
|
1663
1666
|
const ctx = new Context5({
|
|
1664
1667
|
onError: (err) => {
|
|
1665
|
-
void ctx.dispose();
|
|
1666
1668
|
stream.error(err);
|
|
1669
|
+
void ctx.dispose();
|
|
1667
1670
|
}
|
|
1668
1671
|
});
|
|
1669
1672
|
ctx.onDispose(() => {
|
|
@@ -1671,7 +1674,7 @@ var InvitationsHandler = class {
|
|
|
1671
1674
|
...protocol.toJSON()
|
|
1672
1675
|
}, {
|
|
1673
1676
|
F: __dxlog_file7,
|
|
1674
|
-
L:
|
|
1677
|
+
L: 109,
|
|
1675
1678
|
S: this,
|
|
1676
1679
|
C: (f, a) => f(...a)
|
|
1677
1680
|
});
|
|
@@ -1696,7 +1699,7 @@ var InvitationsHandler = class {
|
|
|
1696
1699
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1697
1700
|
invariant6(deviceKey, void 0, {
|
|
1698
1701
|
F: __dxlog_file7,
|
|
1699
|
-
L:
|
|
1702
|
+
L: 130,
|
|
1700
1703
|
S: this,
|
|
1701
1704
|
A: [
|
|
1702
1705
|
"deviceKey",
|
|
@@ -1719,7 +1722,7 @@ var InvitationsHandler = class {
|
|
|
1719
1722
|
id: traceId
|
|
1720
1723
|
}), {
|
|
1721
1724
|
F: __dxlog_file7,
|
|
1722
|
-
L:
|
|
1725
|
+
L: 148,
|
|
1723
1726
|
S: this,
|
|
1724
1727
|
C: (f, a) => f(...a)
|
|
1725
1728
|
});
|
|
@@ -1727,7 +1730,7 @@ var InvitationsHandler = class {
|
|
|
1727
1730
|
...protocol.toJSON()
|
|
1728
1731
|
}, {
|
|
1729
1732
|
F: __dxlog_file7,
|
|
1730
|
-
L:
|
|
1733
|
+
L: 149,
|
|
1731
1734
|
S: this,
|
|
1732
1735
|
C: (f, a) => f(...a)
|
|
1733
1736
|
});
|
|
@@ -1743,7 +1746,7 @@ var InvitationsHandler = class {
|
|
|
1743
1746
|
...protocol.toJSON()
|
|
1744
1747
|
}, {
|
|
1745
1748
|
F: __dxlog_file7,
|
|
1746
|
-
L:
|
|
1749
|
+
L: 152,
|
|
1747
1750
|
S: this,
|
|
1748
1751
|
C: (f, a) => f(...a)
|
|
1749
1752
|
});
|
|
@@ -1755,7 +1758,7 @@ var InvitationsHandler = class {
|
|
|
1755
1758
|
id: traceId
|
|
1756
1759
|
}), {
|
|
1757
1760
|
F: __dxlog_file7,
|
|
1758
|
-
L:
|
|
1761
|
+
L: 154,
|
|
1759
1762
|
S: this,
|
|
1760
1763
|
C: (f, a) => f(...a)
|
|
1761
1764
|
});
|
|
@@ -1765,7 +1768,7 @@ var InvitationsHandler = class {
|
|
|
1765
1768
|
...protocol.toJSON()
|
|
1766
1769
|
}, {
|
|
1767
1770
|
F: __dxlog_file7,
|
|
1768
|
-
L:
|
|
1771
|
+
L: 157,
|
|
1769
1772
|
S: this,
|
|
1770
1773
|
C: (f, a) => f(...a)
|
|
1771
1774
|
});
|
|
@@ -1776,7 +1779,7 @@ var InvitationsHandler = class {
|
|
|
1776
1779
|
} else {
|
|
1777
1780
|
log5.error("failed", err, {
|
|
1778
1781
|
F: __dxlog_file7,
|
|
1779
|
-
L:
|
|
1782
|
+
L: 160,
|
|
1780
1783
|
S: this,
|
|
1781
1784
|
C: (f, a) => f(...a)
|
|
1782
1785
|
});
|
|
@@ -1787,7 +1790,7 @@ var InvitationsHandler = class {
|
|
|
1787
1790
|
error: err
|
|
1788
1791
|
}), {
|
|
1789
1792
|
F: __dxlog_file7,
|
|
1790
|
-
L:
|
|
1793
|
+
L: 163,
|
|
1791
1794
|
S: this,
|
|
1792
1795
|
C: (f, a) => f(...a)
|
|
1793
1796
|
});
|
|
@@ -1808,7 +1811,7 @@ var InvitationsHandler = class {
|
|
|
1808
1811
|
...protocol.toJSON()
|
|
1809
1812
|
}, {
|
|
1810
1813
|
F: __dxlog_file7,
|
|
1811
|
-
L:
|
|
1814
|
+
L: 178,
|
|
1812
1815
|
S: this,
|
|
1813
1816
|
C: (f, a) => f(...a)
|
|
1814
1817
|
});
|
|
@@ -1819,7 +1822,7 @@ var InvitationsHandler = class {
|
|
|
1819
1822
|
} else {
|
|
1820
1823
|
log5.error("failed", err, {
|
|
1821
1824
|
F: __dxlog_file7,
|
|
1822
|
-
L:
|
|
1825
|
+
L: 181,
|
|
1823
1826
|
S: this,
|
|
1824
1827
|
C: (f, a) => f(...a)
|
|
1825
1828
|
});
|
|
@@ -1829,7 +1832,27 @@ var InvitationsHandler = class {
|
|
|
1829
1832
|
});
|
|
1830
1833
|
return extension;
|
|
1831
1834
|
};
|
|
1835
|
+
if (invitation.lifetime && invitation.created && invitation.lifetime !== 0) {
|
|
1836
|
+
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
1837
|
+
log5.warn("invitation has already expired", void 0, {
|
|
1838
|
+
F: __dxlog_file7,
|
|
1839
|
+
L: 192,
|
|
1840
|
+
S: this,
|
|
1841
|
+
C: (f, a) => f(...a)
|
|
1842
|
+
});
|
|
1843
|
+
} else {
|
|
1844
|
+
scheduleTask2(ctx, async () => {
|
|
1845
|
+
await swarmConnection.close();
|
|
1846
|
+
stream.next({
|
|
1847
|
+
...invitation,
|
|
1848
|
+
state: Invitation3.State.EXPIRED
|
|
1849
|
+
});
|
|
1850
|
+
await ctx.dispose();
|
|
1851
|
+
}, invitation.created.getTime() + invitation.lifetime * 1e3 - Date.now());
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1832
1854
|
let swarmConnection;
|
|
1855
|
+
const invitationLabel = "invitation host for " + (invitation.kind === Invitation3.Kind.DEVICE ? "device" : `space ${invitation.spaceKey?.truncate()}`);
|
|
1833
1856
|
scheduleTask2(ctx, async () => {
|
|
1834
1857
|
const topic = invitation.swarmKey;
|
|
1835
1858
|
swarmConnection = await this._networkManager.joinSwarm({
|
|
@@ -1839,7 +1862,7 @@ var InvitationsHandler = class {
|
|
|
1839
1862
|
teleport.addExtension("dxos.halo.invitations", createExtension());
|
|
1840
1863
|
}),
|
|
1841
1864
|
topology: new StarTopology(topic),
|
|
1842
|
-
label:
|
|
1865
|
+
label: invitationLabel
|
|
1843
1866
|
});
|
|
1844
1867
|
ctx.onDispose(() => swarmConnection.close());
|
|
1845
1868
|
stream.next({
|
|
@@ -1864,7 +1887,7 @@ var InvitationsHandler = class {
|
|
|
1864
1887
|
const { timeout = INVITATION_TIMEOUT } = invitation;
|
|
1865
1888
|
invariant6(protocol, void 0, {
|
|
1866
1889
|
F: __dxlog_file7,
|
|
1867
|
-
L:
|
|
1890
|
+
L: 246,
|
|
1868
1891
|
S: this,
|
|
1869
1892
|
A: [
|
|
1870
1893
|
"protocol",
|
|
@@ -1874,7 +1897,7 @@ var InvitationsHandler = class {
|
|
|
1874
1897
|
if (deviceProfile) {
|
|
1875
1898
|
invariant6(invitation.kind === Invitation3.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
1876
1899
|
F: __dxlog_file7,
|
|
1877
|
-
L:
|
|
1900
|
+
L: 250,
|
|
1878
1901
|
S: this,
|
|
1879
1902
|
A: [
|
|
1880
1903
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -1889,7 +1912,7 @@ var InvitationsHandler = class {
|
|
|
1889
1912
|
const setState = (newData) => {
|
|
1890
1913
|
invariant6(newData.state !== void 0, void 0, {
|
|
1891
1914
|
F: __dxlog_file7,
|
|
1892
|
-
L:
|
|
1915
|
+
L: 261,
|
|
1893
1916
|
S: this,
|
|
1894
1917
|
A: [
|
|
1895
1918
|
"newData.state !== undefined",
|
|
@@ -1909,7 +1932,7 @@ var InvitationsHandler = class {
|
|
|
1909
1932
|
...protocol.toJSON()
|
|
1910
1933
|
}, {
|
|
1911
1934
|
F: __dxlog_file7,
|
|
1912
|
-
L:
|
|
1935
|
+
L: 269,
|
|
1913
1936
|
S: this,
|
|
1914
1937
|
C: (f, a) => f(...a)
|
|
1915
1938
|
});
|
|
@@ -1919,7 +1942,7 @@ var InvitationsHandler = class {
|
|
|
1919
1942
|
} else {
|
|
1920
1943
|
log5.warn("auth failed", err, {
|
|
1921
1944
|
F: __dxlog_file7,
|
|
1922
|
-
L:
|
|
1945
|
+
L: 272,
|
|
1923
1946
|
S: this,
|
|
1924
1947
|
C: (f, a) => f(...a)
|
|
1925
1948
|
});
|
|
@@ -1933,7 +1956,7 @@ var InvitationsHandler = class {
|
|
|
1933
1956
|
...protocol.toJSON()
|
|
1934
1957
|
}, {
|
|
1935
1958
|
F: __dxlog_file7,
|
|
1936
|
-
L:
|
|
1959
|
+
L: 280,
|
|
1937
1960
|
S: this,
|
|
1938
1961
|
C: (f, a) => f(...a)
|
|
1939
1962
|
});
|
|
@@ -1948,7 +1971,7 @@ var InvitationsHandler = class {
|
|
|
1948
1971
|
currentState
|
|
1949
1972
|
}, {
|
|
1950
1973
|
F: __dxlog_file7,
|
|
1951
|
-
L:
|
|
1974
|
+
L: 290,
|
|
1952
1975
|
S: this,
|
|
1953
1976
|
C: (f, a) => f(...a)
|
|
1954
1977
|
});
|
|
@@ -1963,7 +1986,7 @@ var InvitationsHandler = class {
|
|
|
1963
1986
|
id: traceId
|
|
1964
1987
|
}), {
|
|
1965
1988
|
F: __dxlog_file7,
|
|
1966
|
-
L:
|
|
1989
|
+
L: 299,
|
|
1967
1990
|
S: this,
|
|
1968
1991
|
C: (f, a) => f(...a)
|
|
1969
1992
|
});
|
|
@@ -1975,7 +1998,7 @@ var InvitationsHandler = class {
|
|
|
1975
1998
|
...protocol.toJSON()
|
|
1976
1999
|
}, {
|
|
1977
2000
|
F: __dxlog_file7,
|
|
1978
|
-
L:
|
|
2001
|
+
L: 307,
|
|
1979
2002
|
S: this,
|
|
1980
2003
|
C: (f, a) => f(...a)
|
|
1981
2004
|
});
|
|
@@ -1986,7 +2009,7 @@ var InvitationsHandler = class {
|
|
|
1986
2009
|
...protocol.toJSON()
|
|
1987
2010
|
}, {
|
|
1988
2011
|
F: __dxlog_file7,
|
|
1989
|
-
L:
|
|
2012
|
+
L: 311,
|
|
1990
2013
|
S: this,
|
|
1991
2014
|
C: (f, a) => f(...a)
|
|
1992
2015
|
});
|
|
@@ -1996,7 +2019,7 @@ var InvitationsHandler = class {
|
|
|
1996
2019
|
response: introductionResponse
|
|
1997
2020
|
}, {
|
|
1998
2021
|
F: __dxlog_file7,
|
|
1999
|
-
L:
|
|
2022
|
+
L: 315,
|
|
2000
2023
|
S: this,
|
|
2001
2024
|
C: (f, a) => f(...a)
|
|
2002
2025
|
});
|
|
@@ -2005,7 +2028,7 @@ var InvitationsHandler = class {
|
|
|
2005
2028
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2006
2029
|
log5("guest waiting for authentication code...", void 0, {
|
|
2007
2030
|
F: __dxlog_file7,
|
|
2008
|
-
L:
|
|
2031
|
+
L: 321,
|
|
2009
2032
|
S: this,
|
|
2010
2033
|
C: (f, a) => f(...a)
|
|
2011
2034
|
});
|
|
@@ -2017,7 +2040,7 @@ var InvitationsHandler = class {
|
|
|
2017
2040
|
});
|
|
2018
2041
|
log5("sending authentication request", void 0, {
|
|
2019
2042
|
F: __dxlog_file7,
|
|
2020
|
-
L:
|
|
2043
|
+
L: 325,
|
|
2021
2044
|
S: this,
|
|
2022
2045
|
C: (f, a) => f(...a)
|
|
2023
2046
|
});
|
|
@@ -2038,7 +2061,7 @@ var InvitationsHandler = class {
|
|
|
2038
2061
|
attempt
|
|
2039
2062
|
}, {
|
|
2040
2063
|
F: __dxlog_file7,
|
|
2041
|
-
L:
|
|
2064
|
+
L: 336,
|
|
2042
2065
|
S: this,
|
|
2043
2066
|
C: (f, a) => f(...a)
|
|
2044
2067
|
});
|
|
@@ -2051,7 +2074,7 @@ var InvitationsHandler = class {
|
|
|
2051
2074
|
...protocol.toJSON()
|
|
2052
2075
|
}, {
|
|
2053
2076
|
F: __dxlog_file7,
|
|
2054
|
-
L:
|
|
2077
|
+
L: 344,
|
|
2055
2078
|
S: this,
|
|
2056
2079
|
C: (f, a) => f(...a)
|
|
2057
2080
|
});
|
|
@@ -2063,7 +2086,7 @@ var InvitationsHandler = class {
|
|
|
2063
2086
|
...protocol.toJSON()
|
|
2064
2087
|
}, {
|
|
2065
2088
|
F: __dxlog_file7,
|
|
2066
|
-
L:
|
|
2089
|
+
L: 355,
|
|
2067
2090
|
S: this,
|
|
2068
2091
|
C: (f, a) => f(...a)
|
|
2069
2092
|
});
|
|
@@ -2076,7 +2099,7 @@ var InvitationsHandler = class {
|
|
|
2076
2099
|
id: traceId
|
|
2077
2100
|
}), {
|
|
2078
2101
|
F: __dxlog_file7,
|
|
2079
|
-
L:
|
|
2102
|
+
L: 357,
|
|
2080
2103
|
S: this,
|
|
2081
2104
|
C: (f, a) => f(...a)
|
|
2082
2105
|
});
|
|
@@ -2086,7 +2109,7 @@ var InvitationsHandler = class {
|
|
|
2086
2109
|
...protocol.toJSON()
|
|
2087
2110
|
}, {
|
|
2088
2111
|
F: __dxlog_file7,
|
|
2089
|
-
L:
|
|
2112
|
+
L: 360,
|
|
2090
2113
|
S: this,
|
|
2091
2114
|
C: (f, a) => f(...a)
|
|
2092
2115
|
});
|
|
@@ -2096,7 +2119,7 @@ var InvitationsHandler = class {
|
|
|
2096
2119
|
} else {
|
|
2097
2120
|
log5("auth failed", err, {
|
|
2098
2121
|
F: __dxlog_file7,
|
|
2099
|
-
L:
|
|
2122
|
+
L: 363,
|
|
2100
2123
|
S: this,
|
|
2101
2124
|
C: (f, a) => f(...a)
|
|
2102
2125
|
});
|
|
@@ -2107,7 +2130,7 @@ var InvitationsHandler = class {
|
|
|
2107
2130
|
error: err
|
|
2108
2131
|
}), {
|
|
2109
2132
|
F: __dxlog_file7,
|
|
2110
|
-
L:
|
|
2133
|
+
L: 366,
|
|
2111
2134
|
S: this,
|
|
2112
2135
|
C: (f, a) => f(...a)
|
|
2113
2136
|
});
|
|
@@ -2125,7 +2148,7 @@ var InvitationsHandler = class {
|
|
|
2125
2148
|
...protocol.toJSON()
|
|
2126
2149
|
}, {
|
|
2127
2150
|
F: __dxlog_file7,
|
|
2128
|
-
L:
|
|
2151
|
+
L: 377,
|
|
2129
2152
|
S: this,
|
|
2130
2153
|
C: (f, a) => f(...a)
|
|
2131
2154
|
});
|
|
@@ -2135,7 +2158,7 @@ var InvitationsHandler = class {
|
|
|
2135
2158
|
} else {
|
|
2136
2159
|
log5("auth failed", err, {
|
|
2137
2160
|
F: __dxlog_file7,
|
|
2138
|
-
L:
|
|
2161
|
+
L: 380,
|
|
2139
2162
|
S: this,
|
|
2140
2163
|
C: (f, a) => f(...a)
|
|
2141
2164
|
});
|
|
@@ -2152,7 +2175,7 @@ var InvitationsHandler = class {
|
|
|
2152
2175
|
} else {
|
|
2153
2176
|
invariant6(invitation.swarmKey, void 0, {
|
|
2154
2177
|
F: __dxlog_file7,
|
|
2155
|
-
L:
|
|
2178
|
+
L: 394,
|
|
2156
2179
|
S: this,
|
|
2157
2180
|
A: [
|
|
2158
2181
|
"invitation.swarmKey",
|
|
@@ -2191,24 +2214,32 @@ var InvitationsHandler = class {
|
|
|
2191
2214
|
return observable;
|
|
2192
2215
|
}
|
|
2193
2216
|
};
|
|
2217
|
+
var invitationExpired = (invitation) => {
|
|
2218
|
+
return invitation.created && invitation.lifetime && invitation.lifetime !== 0 && invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now();
|
|
2219
|
+
};
|
|
2194
2220
|
|
|
2195
2221
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
2196
|
-
import { Event as Event3 } from "@dxos/async";
|
|
2222
|
+
import { Event as Event3, scheduleTask as scheduleTask3 } from "@dxos/async";
|
|
2197
2223
|
import { Stream as Stream8 } from "@dxos/codec-protobuf";
|
|
2224
|
+
import { Context as Context6 } from "@dxos/context";
|
|
2198
2225
|
import { invariant as invariant7 } from "@dxos/invariant";
|
|
2199
2226
|
import { log as log6 } from "@dxos/log";
|
|
2200
2227
|
import { Invitation as Invitation4, QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
|
|
2201
2228
|
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
2202
2229
|
var InvitationsServiceImpl = class {
|
|
2203
|
-
constructor(_invitationsHandler, _getHandler) {
|
|
2230
|
+
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
2204
2231
|
this._invitationsHandler = _invitationsHandler;
|
|
2205
2232
|
this._getHandler = _getHandler;
|
|
2233
|
+
this._metadataStore = _metadataStore;
|
|
2206
2234
|
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2207
2235
|
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2208
2236
|
this._invitationCreated = new Event3();
|
|
2209
2237
|
this._invitationAccepted = new Event3();
|
|
2210
2238
|
this._removedCreated = new Event3();
|
|
2211
2239
|
this._removedAccepted = new Event3();
|
|
2240
|
+
this._saved = new Event3();
|
|
2241
|
+
this._persistentInvitationsLoadedEvent = new Event3();
|
|
2242
|
+
this._persistentInvitationsLoaded = false;
|
|
2212
2243
|
}
|
|
2213
2244
|
// TODO(burdon): Guest/host label.
|
|
2214
2245
|
getLoggingContext() {
|
|
@@ -2216,6 +2247,7 @@ var InvitationsServiceImpl = class {
|
|
|
2216
2247
|
}
|
|
2217
2248
|
createInvitation(options) {
|
|
2218
2249
|
let invitation;
|
|
2250
|
+
const savePersistentInvitationCtx = new Context6();
|
|
2219
2251
|
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2220
2252
|
if (existingInvitation) {
|
|
2221
2253
|
invitation = existingInvitation;
|
|
@@ -2226,12 +2258,27 @@ var InvitationsServiceImpl = class {
|
|
|
2226
2258
|
this._invitationCreated.emit(invitation.get());
|
|
2227
2259
|
}
|
|
2228
2260
|
return new Stream8(({ next, close }) => {
|
|
2261
|
+
if (invitation.get().persistent) {
|
|
2262
|
+
scheduleTask3(savePersistentInvitationCtx, async () => {
|
|
2263
|
+
try {
|
|
2264
|
+
await this._metadataStore.addInvitation(invitation.get());
|
|
2265
|
+
this._saved.emit(invitation.get());
|
|
2266
|
+
} catch (err) {
|
|
2267
|
+
close(err);
|
|
2268
|
+
}
|
|
2269
|
+
});
|
|
2270
|
+
}
|
|
2229
2271
|
invitation.subscribe((invitation2) => {
|
|
2230
2272
|
next(invitation2);
|
|
2231
|
-
}, (err) => {
|
|
2273
|
+
}, async (err) => {
|
|
2274
|
+
await savePersistentInvitationCtx.dispose();
|
|
2232
2275
|
close(err);
|
|
2233
|
-
}, () => {
|
|
2276
|
+
}, async () => {
|
|
2234
2277
|
close();
|
|
2278
|
+
if (invitation.get().persistent) {
|
|
2279
|
+
await savePersistentInvitationCtx.dispose();
|
|
2280
|
+
await this._metadataStore.removeInvitation(invitation.get().invitationId);
|
|
2281
|
+
}
|
|
2235
2282
|
this._createInvitations.delete(invitation.get().invitationId);
|
|
2236
2283
|
if (invitation.get().type !== Invitation4.Type.MULTIUSE) {
|
|
2237
2284
|
this._removedCreated.emit(invitation.get());
|
|
@@ -2239,12 +2286,37 @@ var InvitationsServiceImpl = class {
|
|
|
2239
2286
|
});
|
|
2240
2287
|
});
|
|
2241
2288
|
}
|
|
2289
|
+
async loadPersistentInvitations() {
|
|
2290
|
+
const persistentInvitations = this._metadataStore.getInvitations();
|
|
2291
|
+
const freshInvitations = persistentInvitations.filter(async (invitation) => !invitationExpired(invitation));
|
|
2292
|
+
const cInvitations = freshInvitations.map((persistentInvitation) => {
|
|
2293
|
+
invariant7(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2294
|
+
F: __dxlog_file8,
|
|
2295
|
+
L: 109,
|
|
2296
|
+
S: this,
|
|
2297
|
+
A: [
|
|
2298
|
+
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2299
|
+
"'invitation already exists'"
|
|
2300
|
+
]
|
|
2301
|
+
});
|
|
2302
|
+
const handler = this._getHandler(persistentInvitation);
|
|
2303
|
+
const invitation = this._invitationsHandler.createInvitation(handler, persistentInvitation);
|
|
2304
|
+
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2305
|
+
this._invitationCreated.emit(invitation.get());
|
|
2306
|
+
return persistentInvitation;
|
|
2307
|
+
});
|
|
2308
|
+
this._persistentInvitationsLoadedEvent.emit();
|
|
2309
|
+
this._persistentInvitationsLoaded = true;
|
|
2310
|
+
return {
|
|
2311
|
+
invitations: cInvitations
|
|
2312
|
+
};
|
|
2313
|
+
}
|
|
2242
2314
|
acceptInvitation({ invitation: options, deviceProfile }) {
|
|
2243
2315
|
let invitation;
|
|
2244
2316
|
if (deviceProfile) {
|
|
2245
2317
|
invariant7(options.kind === Invitation4.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2246
2318
|
F: __dxlog_file8,
|
|
2247
|
-
L:
|
|
2319
|
+
L: 127,
|
|
2248
2320
|
S: this,
|
|
2249
2321
|
A: [
|
|
2250
2322
|
"options.kind === Invitation.Kind.DEVICE",
|
|
@@ -2278,13 +2350,13 @@ var InvitationsServiceImpl = class {
|
|
|
2278
2350
|
async authenticate({ invitationId, authCode }) {
|
|
2279
2351
|
log6("authenticating...", void 0, {
|
|
2280
2352
|
F: __dxlog_file8,
|
|
2281
|
-
L:
|
|
2353
|
+
L: 160,
|
|
2282
2354
|
S: this,
|
|
2283
2355
|
C: (f, a) => f(...a)
|
|
2284
2356
|
});
|
|
2285
2357
|
invariant7(invitationId, void 0, {
|
|
2286
2358
|
F: __dxlog_file8,
|
|
2287
|
-
L:
|
|
2359
|
+
L: 161,
|
|
2288
2360
|
S: this,
|
|
2289
2361
|
A: [
|
|
2290
2362
|
"invitationId",
|
|
@@ -2297,7 +2369,7 @@ var InvitationsServiceImpl = class {
|
|
|
2297
2369
|
invitationId
|
|
2298
2370
|
}, {
|
|
2299
2371
|
F: __dxlog_file8,
|
|
2300
|
-
L:
|
|
2372
|
+
L: 164,
|
|
2301
2373
|
S: this,
|
|
2302
2374
|
C: (f, a) => f(...a)
|
|
2303
2375
|
});
|
|
@@ -2306,15 +2378,17 @@ var InvitationsServiceImpl = class {
|
|
|
2306
2378
|
}
|
|
2307
2379
|
}
|
|
2308
2380
|
async cancelInvitation({ invitationId }) {
|
|
2309
|
-
log6("
|
|
2381
|
+
log6("cancelInvitation...", {
|
|
2382
|
+
invitationId
|
|
2383
|
+
}, {
|
|
2310
2384
|
F: __dxlog_file8,
|
|
2311
|
-
L:
|
|
2385
|
+
L: 171,
|
|
2312
2386
|
S: this,
|
|
2313
2387
|
C: (f, a) => f(...a)
|
|
2314
2388
|
});
|
|
2315
2389
|
invariant7(invitationId, void 0, {
|
|
2316
2390
|
F: __dxlog_file8,
|
|
2317
|
-
L:
|
|
2391
|
+
L: 172,
|
|
2318
2392
|
S: this,
|
|
2319
2393
|
A: [
|
|
2320
2394
|
"invitationId",
|
|
@@ -2327,6 +2401,9 @@ var InvitationsServiceImpl = class {
|
|
|
2327
2401
|
await created.cancel();
|
|
2328
2402
|
this._createInvitations.delete(invitationId);
|
|
2329
2403
|
this._removedCreated.emit(created.get());
|
|
2404
|
+
if (created.get().persistent) {
|
|
2405
|
+
await this._metadataStore.removeInvitation(created.get().invitationId);
|
|
2406
|
+
}
|
|
2330
2407
|
} else if (accepted) {
|
|
2331
2408
|
await accepted.cancel();
|
|
2332
2409
|
this._acceptInvitations.delete(invitationId);
|
|
@@ -2371,16 +2448,40 @@ var InvitationsServiceImpl = class {
|
|
|
2371
2448
|
]
|
|
2372
2449
|
});
|
|
2373
2450
|
});
|
|
2451
|
+
this._saved.on(ctx, (invitation) => {
|
|
2452
|
+
next({
|
|
2453
|
+
action: QueryInvitationsResponse.Action.SAVED,
|
|
2454
|
+
type: QueryInvitationsResponse.Type.CREATED,
|
|
2455
|
+
invitations: [
|
|
2456
|
+
invitation
|
|
2457
|
+
]
|
|
2458
|
+
});
|
|
2459
|
+
});
|
|
2374
2460
|
next({
|
|
2375
2461
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2376
2462
|
type: QueryInvitationsResponse.Type.CREATED,
|
|
2377
|
-
invitations: Array.from(this._createInvitations.values()).map((invitation) => invitation.get())
|
|
2463
|
+
invitations: Array.from(this._createInvitations.values()).map((invitation) => invitation.get()),
|
|
2464
|
+
existing: true
|
|
2378
2465
|
});
|
|
2379
2466
|
next({
|
|
2380
2467
|
action: QueryInvitationsResponse.Action.ADDED,
|
|
2381
2468
|
type: QueryInvitationsResponse.Type.ACCEPTED,
|
|
2382
|
-
invitations: Array.from(this._acceptInvitations.values()).map((invitation) => invitation.get())
|
|
2469
|
+
invitations: Array.from(this._acceptInvitations.values()).map((invitation) => invitation.get()),
|
|
2470
|
+
existing: true
|
|
2383
2471
|
});
|
|
2472
|
+
if (this._persistentInvitationsLoaded) {
|
|
2473
|
+
next({
|
|
2474
|
+
action: QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2475
|
+
type: QueryInvitationsResponse.Type.CREATED
|
|
2476
|
+
});
|
|
2477
|
+
} else {
|
|
2478
|
+
this._persistentInvitationsLoadedEvent.on(ctx, () => {
|
|
2479
|
+
next({
|
|
2480
|
+
action: QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2481
|
+
type: QueryInvitationsResponse.Type.CREATED
|
|
2482
|
+
});
|
|
2483
|
+
});
|
|
2484
|
+
}
|
|
2384
2485
|
});
|
|
2385
2486
|
}
|
|
2386
2487
|
};
|
|
@@ -2671,7 +2772,7 @@ var getPlatform = () => {
|
|
|
2671
2772
|
};
|
|
2672
2773
|
|
|
2673
2774
|
// packages/sdk/client-services/src/version.ts
|
|
2674
|
-
var DXOS_VERSION = "0.4.
|
|
2775
|
+
var DXOS_VERSION = "0.4.8-main.0602afb";
|
|
2675
2776
|
|
|
2676
2777
|
// packages/sdk/client-services/src/packlets/services/diagnostics.ts
|
|
2677
2778
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
@@ -2813,12 +2914,12 @@ var getSpaceStats = async (space) => {
|
|
|
2813
2914
|
};
|
|
2814
2915
|
|
|
2815
2916
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2816
|
-
import { Event as Event5, scheduleTask as
|
|
2917
|
+
import { Event as Event5, asyncTimeout, scheduleTask as scheduleTask5, sleep as sleep2, synchronized, trackLeaks } from "@dxos/async";
|
|
2817
2918
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
2818
|
-
import { cancelWithContext as cancelWithContext2, Context as
|
|
2919
|
+
import { cancelWithContext as cancelWithContext2, Context as Context8, ContextDisposedError } from "@dxos/context";
|
|
2819
2920
|
import { timed, warnAfterTimeout } from "@dxos/debug";
|
|
2820
2921
|
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
2821
|
-
import { failedInvariant } from "@dxos/invariant";
|
|
2922
|
+
import { failedInvariant, invariant as invariant11 } from "@dxos/invariant";
|
|
2822
2923
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
2823
2924
|
import { log as log10 } from "@dxos/log";
|
|
2824
2925
|
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
@@ -2835,6 +2936,7 @@ var AutomergeSpaceState = class {
|
|
|
2835
2936
|
this._onNewRoot = _onNewRoot;
|
|
2836
2937
|
this.rootUrl = void 0;
|
|
2837
2938
|
this.lastEpoch = void 0;
|
|
2939
|
+
this._isProcessingRootDocs = false;
|
|
2838
2940
|
}
|
|
2839
2941
|
async processCredential(credential) {
|
|
2840
2942
|
if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
|
|
@@ -2843,14 +2945,25 @@ var AutomergeSpaceState = class {
|
|
|
2843
2945
|
this.lastEpoch = credential;
|
|
2844
2946
|
if (credential.subject.assertion.automergeRoot) {
|
|
2845
2947
|
this.rootUrl = credential.subject.assertion.automergeRoot;
|
|
2948
|
+
if (this._isProcessingRootDocs) {
|
|
2949
|
+
this._onNewRoot(this.rootUrl);
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
}
|
|
2953
|
+
startProcessingRootDocs() {
|
|
2954
|
+
if (this._isProcessingRootDocs) {
|
|
2955
|
+
return;
|
|
2956
|
+
}
|
|
2957
|
+
if (this.rootUrl) {
|
|
2846
2958
|
this._onNewRoot(this.rootUrl);
|
|
2847
2959
|
}
|
|
2960
|
+
this._isProcessingRootDocs = true;
|
|
2848
2961
|
}
|
|
2849
2962
|
};
|
|
2850
2963
|
|
|
2851
2964
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2852
|
-
import { DeferredTask, Event as Event4, scheduleTask as
|
|
2853
|
-
import { Context as
|
|
2965
|
+
import { DeferredTask, Event as Event4, scheduleTask as scheduleTask4, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
|
|
2966
|
+
import { Context as Context7, rejectOnDispose } from "@dxos/context";
|
|
2854
2967
|
import { invariant as invariant10 } from "@dxos/invariant";
|
|
2855
2968
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
2856
2969
|
import { log as log9 } from "@dxos/log";
|
|
@@ -2864,7 +2977,7 @@ var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
|
2864
2977
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
2865
2978
|
var NotarizationPlugin = class {
|
|
2866
2979
|
constructor() {
|
|
2867
|
-
this._ctx = new
|
|
2980
|
+
this._ctx = new Context7();
|
|
2868
2981
|
this._extensionOpened = new Event4();
|
|
2869
2982
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2870
2983
|
this._processedCredentials = new ComplexSet2(PublicKey7.hash);
|
|
@@ -2916,7 +3029,7 @@ var NotarizationPlugin = class {
|
|
|
2916
3029
|
});
|
|
2917
3030
|
opCtx?.onDispose(() => ctx.dispose());
|
|
2918
3031
|
if (timeout !== 0) {
|
|
2919
|
-
|
|
3032
|
+
scheduleTask4(ctx, () => {
|
|
2920
3033
|
log9.warn("Notarization timeout", {
|
|
2921
3034
|
timeout,
|
|
2922
3035
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
@@ -2950,7 +3063,7 @@ var NotarizationPlugin = class {
|
|
|
2950
3063
|
C: (f, a) => f(...a)
|
|
2951
3064
|
});
|
|
2952
3065
|
peersTried.clear();
|
|
2953
|
-
|
|
3066
|
+
scheduleTask4(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
2954
3067
|
return;
|
|
2955
3068
|
}
|
|
2956
3069
|
peersTried.add(peer);
|
|
@@ -3131,7 +3244,7 @@ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
|
|
|
3131
3244
|
var ENABLE_FEED_PURGE = false;
|
|
3132
3245
|
var DataSpace = class {
|
|
3133
3246
|
constructor(params) {
|
|
3134
|
-
this._ctx = new
|
|
3247
|
+
this._ctx = new Context8();
|
|
3135
3248
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3136
3249
|
this._cache = void 0;
|
|
3137
3250
|
// TODO(dmaretskyi): Move into Space?
|
|
@@ -3211,7 +3324,7 @@ var DataSpace = class {
|
|
|
3211
3324
|
await this._notarizationPlugin.open();
|
|
3212
3325
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3213
3326
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3214
|
-
await this._inner.open(new
|
|
3327
|
+
await this._inner.open(new Context8());
|
|
3215
3328
|
this._state = SpaceState.CONTROL_ONLY;
|
|
3216
3329
|
log10("new state", {
|
|
3217
3330
|
state: SpaceState[this._state]
|
|
@@ -3240,7 +3353,7 @@ var DataSpace = class {
|
|
|
3240
3353
|
C: (f, a) => f(...a)
|
|
3241
3354
|
});
|
|
3242
3355
|
await this._ctx.dispose();
|
|
3243
|
-
this._ctx = new
|
|
3356
|
+
this._ctx = new Context8();
|
|
3244
3357
|
await this.authVerifier.close();
|
|
3245
3358
|
await this._inner.close();
|
|
3246
3359
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
@@ -3259,7 +3372,7 @@ var DataSpace = class {
|
|
|
3259
3372
|
* Initialize the data pipeline in a separate task.
|
|
3260
3373
|
*/
|
|
3261
3374
|
initializeDataPipelineAsync() {
|
|
3262
|
-
|
|
3375
|
+
scheduleTask5(this._ctx, async () => {
|
|
3263
3376
|
try {
|
|
3264
3377
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3265
3378
|
await this.initializeDataPipeline();
|
|
@@ -3310,12 +3423,13 @@ var DataSpace = class {
|
|
|
3310
3423
|
});
|
|
3311
3424
|
await this._initializeAndReadControlPipeline();
|
|
3312
3425
|
await sleep2(1);
|
|
3426
|
+
this._automergeSpaceState.startProcessingRootDocs();
|
|
3313
3427
|
await this._inner.initializeDataPipeline();
|
|
3314
3428
|
this.metrics.dataPipelineOpen = /* @__PURE__ */ new Date();
|
|
3315
3429
|
await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
3316
3430
|
log10("waiting for data pipeline to reach target timeframe", void 0, {
|
|
3317
3431
|
F: __dxlog_file12,
|
|
3318
|
-
L:
|
|
3432
|
+
L: 288,
|
|
3319
3433
|
S: this,
|
|
3320
3434
|
C: (f, a) => f(...a)
|
|
3321
3435
|
});
|
|
@@ -3326,7 +3440,7 @@ var DataSpace = class {
|
|
|
3326
3440
|
this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
|
|
3327
3441
|
log10("data pipeline ready", void 0, {
|
|
3328
3442
|
F: __dxlog_file12,
|
|
3329
|
-
L:
|
|
3443
|
+
L: 296,
|
|
3330
3444
|
S: this,
|
|
3331
3445
|
C: (f, a) => f(...a)
|
|
3332
3446
|
});
|
|
@@ -3336,7 +3450,7 @@ var DataSpace = class {
|
|
|
3336
3450
|
state: SpaceState[this._state]
|
|
3337
3451
|
}, {
|
|
3338
3452
|
F: __dxlog_file12,
|
|
3339
|
-
L:
|
|
3453
|
+
L: 300,
|
|
3340
3454
|
S: this,
|
|
3341
3455
|
C: (f, a) => f(...a)
|
|
3342
3456
|
});
|
|
@@ -3352,7 +3466,7 @@ var DataSpace = class {
|
|
|
3352
3466
|
await this._createWritableFeeds();
|
|
3353
3467
|
log10("writable feeds created", void 0, {
|
|
3354
3468
|
F: __dxlog_file12,
|
|
3355
|
-
L:
|
|
3469
|
+
L: 316,
|
|
3356
3470
|
S: this,
|
|
3357
3471
|
C: (f, a) => f(...a)
|
|
3358
3472
|
});
|
|
@@ -3415,7 +3529,7 @@ var DataSpace = class {
|
|
|
3415
3529
|
rootUrl
|
|
3416
3530
|
}, {
|
|
3417
3531
|
F: __dxlog_file12,
|
|
3418
|
-
L:
|
|
3532
|
+
L: 382,
|
|
3419
3533
|
S: this,
|
|
3420
3534
|
C: (f, a) => f(...a)
|
|
3421
3535
|
});
|
|
@@ -3447,7 +3561,7 @@ var DataSpace = class {
|
|
|
3447
3561
|
err
|
|
3448
3562
|
}, {
|
|
3449
3563
|
F: __dxlog_file12,
|
|
3450
|
-
L:
|
|
3564
|
+
L: 405,
|
|
3451
3565
|
S: this,
|
|
3452
3566
|
C: (f, a) => f(...a)
|
|
3453
3567
|
});
|
|
@@ -3478,15 +3592,40 @@ var DataSpace = class {
|
|
|
3478
3592
|
epoch = await this.dataPipeline.createEpoch();
|
|
3479
3593
|
}
|
|
3480
3594
|
break;
|
|
3481
|
-
case CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3595
|
+
case CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3596
|
+
{
|
|
3597
|
+
const document = this._automergeHost.repo.create();
|
|
3598
|
+
epoch = {
|
|
3599
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3600
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
3601
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe2(),
|
|
3602
|
+
automergeRoot: document.url
|
|
3603
|
+
};
|
|
3604
|
+
}
|
|
3605
|
+
break;
|
|
3606
|
+
case CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
3607
|
+
{
|
|
3608
|
+
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3609
|
+
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3610
|
+
await cancelWithContext2(this._ctx, asyncTimeout(rootHandle.whenReady(), 1e4));
|
|
3611
|
+
const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
|
|
3612
|
+
invariant11(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3613
|
+
F: __dxlog_file12,
|
|
3614
|
+
L: 450,
|
|
3615
|
+
S: this,
|
|
3616
|
+
A: [
|
|
3617
|
+
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3618
|
+
""
|
|
3619
|
+
]
|
|
3620
|
+
});
|
|
3621
|
+
epoch = {
|
|
3622
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3623
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
3624
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new Timeframe2(),
|
|
3625
|
+
automergeRoot: newRoot.url
|
|
3626
|
+
};
|
|
3627
|
+
}
|
|
3628
|
+
break;
|
|
3490
3629
|
}
|
|
3491
3630
|
if (!epoch) {
|
|
3492
3631
|
return;
|
|
@@ -3537,7 +3676,7 @@ var DataSpace = class {
|
|
|
3537
3676
|
state: SpaceState[this._state]
|
|
3538
3677
|
}, {
|
|
3539
3678
|
F: __dxlog_file12,
|
|
3540
|
-
L:
|
|
3679
|
+
L: 514,
|
|
3541
3680
|
S: this,
|
|
3542
3681
|
C: (f, a) => f(...a)
|
|
3543
3682
|
});
|
|
@@ -3592,9 +3731,9 @@ DataSpace = _ts_decorate4([
|
|
|
3592
3731
|
|
|
3593
3732
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
3594
3733
|
import { Event as Event6, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
3595
|
-
import { cancelWithContext as cancelWithContext3, Context as
|
|
3734
|
+
import { cancelWithContext as cancelWithContext3, Context as Context9 } from "@dxos/context";
|
|
3596
3735
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
3597
|
-
import { invariant as
|
|
3736
|
+
import { invariant as invariant12 } from "@dxos/invariant";
|
|
3598
3737
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
3599
3738
|
import { log as log11 } from "@dxos/log";
|
|
3600
3739
|
import { trace as trace7 } from "@dxos/protocols";
|
|
@@ -3695,7 +3834,7 @@ var DataSpaceManager = class {
|
|
|
3695
3834
|
this._signingContext = _signingContext;
|
|
3696
3835
|
this._feedStore = _feedStore;
|
|
3697
3836
|
this._automergeHost = _automergeHost;
|
|
3698
|
-
this._ctx = new
|
|
3837
|
+
this._ctx = new Context9();
|
|
3699
3838
|
this.updated = new Event6();
|
|
3700
3839
|
this._spaces = new ComplexMap3(PublicKey9.hash);
|
|
3701
3840
|
this._isOpen = false;
|
|
@@ -3787,7 +3926,7 @@ var DataSpaceManager = class {
|
|
|
3787
3926
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
3788
3927
|
*/
|
|
3789
3928
|
async createSpace() {
|
|
3790
|
-
|
|
3929
|
+
invariant12(this._isOpen, "Not open.", {
|
|
3791
3930
|
F: __dxlog_file13,
|
|
3792
3931
|
L: 145,
|
|
3793
3932
|
S: this,
|
|
@@ -3824,7 +3963,7 @@ var DataSpaceManager = class {
|
|
|
3824
3963
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
|
|
3825
3964
|
await this._metadataStore.addSpace(metadata);
|
|
3826
3965
|
const memberCredential = credentials[1];
|
|
3827
|
-
|
|
3966
|
+
invariant12(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3828
3967
|
F: __dxlog_file13,
|
|
3829
3968
|
L: 170,
|
|
3830
3969
|
S: this,
|
|
@@ -3848,7 +3987,7 @@ var DataSpaceManager = class {
|
|
|
3848
3987
|
S: this,
|
|
3849
3988
|
C: (f, a) => f(...a)
|
|
3850
3989
|
});
|
|
3851
|
-
|
|
3990
|
+
invariant12(this._isOpen, "Not open.", {
|
|
3852
3991
|
F: __dxlog_file13,
|
|
3853
3992
|
L: 183,
|
|
3854
3993
|
S: this,
|
|
@@ -3857,7 +3996,7 @@ var DataSpaceManager = class {
|
|
|
3857
3996
|
"'Not open.'"
|
|
3858
3997
|
]
|
|
3859
3998
|
});
|
|
3860
|
-
|
|
3999
|
+
invariant12(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
3861
4000
|
F: __dxlog_file13,
|
|
3862
4001
|
L: 184,
|
|
3863
4002
|
S: this,
|
|
@@ -4021,10 +4160,10 @@ DataSpaceManager = _ts_decorate5([
|
|
|
4021
4160
|
], DataSpaceManager);
|
|
4022
4161
|
|
|
4023
4162
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
4024
|
-
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as
|
|
4163
|
+
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask6 } from "@dxos/async";
|
|
4025
4164
|
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
4026
4165
|
import { raise as raise2 } from "@dxos/debug";
|
|
4027
|
-
import { invariant as
|
|
4166
|
+
import { invariant as invariant13 } from "@dxos/invariant";
|
|
4028
4167
|
import { log as log12 } from "@dxos/log";
|
|
4029
4168
|
import { ApiError, SpaceNotFoundError, encodeError } from "@dxos/protocols";
|
|
4030
4169
|
import { SpaceMember as SpaceMember3, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -4079,7 +4218,7 @@ var SpacesServiceImpl = class {
|
|
|
4079
4218
|
}, {
|
|
4080
4219
|
maxFrequency: false ? void 0 : 2
|
|
4081
4220
|
});
|
|
4082
|
-
|
|
4221
|
+
scheduleTask6(ctx, async () => {
|
|
4083
4222
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4084
4223
|
const subscriptions = new EventSubscriptions2();
|
|
4085
4224
|
ctx.onDispose(() => subscriptions.clear());
|
|
@@ -4116,7 +4255,7 @@ var SpacesServiceImpl = class {
|
|
|
4116
4255
|
}
|
|
4117
4256
|
subscribeMessages({ spaceKey, channel }) {
|
|
4118
4257
|
return new Stream10(({ ctx, next }) => {
|
|
4119
|
-
|
|
4258
|
+
scheduleTask6(ctx, async () => {
|
|
4120
4259
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4121
4260
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
4122
4261
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
@@ -4135,7 +4274,7 @@ var SpacesServiceImpl = class {
|
|
|
4135
4274
|
}
|
|
4136
4275
|
};
|
|
4137
4276
|
ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
|
|
4138
|
-
|
|
4277
|
+
scheduleTask6(ctx, async () => {
|
|
4139
4278
|
await space.spaceState.addCredentialProcessor(processor);
|
|
4140
4279
|
if (noTail) {
|
|
4141
4280
|
close();
|
|
@@ -4153,7 +4292,7 @@ var SpacesServiceImpl = class {
|
|
|
4153
4292
|
}
|
|
4154
4293
|
});
|
|
4155
4294
|
} else {
|
|
4156
|
-
|
|
4295
|
+
invariant13(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
4157
4296
|
F: __dxlog_file14,
|
|
4158
4297
|
L: 168,
|
|
4159
4298
|
S: this,
|
|
@@ -4162,7 +4301,7 @@ var SpacesServiceImpl = class {
|
|
|
4162
4301
|
"'Id on unsigned credentials is not allowed'"
|
|
4163
4302
|
]
|
|
4164
4303
|
});
|
|
4165
|
-
|
|
4304
|
+
invariant13(this._identityManager.identity, "Identity is not available", {
|
|
4166
4305
|
F: __dxlog_file14,
|
|
4167
4306
|
L: 169,
|
|
4168
4307
|
S: this,
|
|
@@ -4172,7 +4311,7 @@ var SpacesServiceImpl = class {
|
|
|
4172
4311
|
]
|
|
4173
4312
|
});
|
|
4174
4313
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
4175
|
-
|
|
4314
|
+
invariant13(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
4176
4315
|
F: __dxlog_file14,
|
|
4177
4316
|
L: 171,
|
|
4178
4317
|
S: this,
|
|
@@ -4193,10 +4332,12 @@ var SpacesServiceImpl = class {
|
|
|
4193
4332
|
}
|
|
4194
4333
|
}
|
|
4195
4334
|
}
|
|
4196
|
-
async createEpoch({ spaceKey }) {
|
|
4335
|
+
async createEpoch({ spaceKey, migration }) {
|
|
4197
4336
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4198
4337
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise2(new SpaceNotFoundError(spaceKey));
|
|
4199
|
-
await space.createEpoch(
|
|
4338
|
+
await space.createEpoch({
|
|
4339
|
+
migration
|
|
4340
|
+
});
|
|
4200
4341
|
}
|
|
4201
4342
|
_serializeSpace(space) {
|
|
4202
4343
|
return {
|
|
@@ -4241,17 +4382,18 @@ var getChannelId = (channel) => `user-channel/${channel}`;
|
|
|
4241
4382
|
|
|
4242
4383
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
4243
4384
|
import { Trigger as Trigger5 } from "@dxos/async";
|
|
4244
|
-
import {
|
|
4385
|
+
import { getHeads } from "@dxos/automerge/automerge";
|
|
4386
|
+
import { Context as Context10 } from "@dxos/context";
|
|
4245
4387
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
4246
|
-
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
4388
|
+
import { failUndefined as failUndefined2, warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
|
|
4247
4389
|
import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, SnapshotStore, AutomergeHost } from "@dxos/echo-pipeline";
|
|
4248
|
-
import { IndexMetadataStore } from "@dxos/echo-schema";
|
|
4249
4390
|
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
4250
|
-
import {
|
|
4391
|
+
import { IndexMetadataStore, IndexStore, Indexer } from "@dxos/indexing";
|
|
4392
|
+
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4251
4393
|
import { Keyring } from "@dxos/keyring";
|
|
4252
4394
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
4253
4395
|
import { log as log13 } from "@dxos/log";
|
|
4254
|
-
import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace8 } from "@dxos/protocols";
|
|
4396
|
+
import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, idCodec, trace as trace8 } from "@dxos/protocols";
|
|
4255
4397
|
import { Invitation as Invitation6 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4256
4398
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
4257
4399
|
import { trace as Trace2 } from "@dxos/tracing";
|
|
@@ -4279,9 +4421,6 @@ var ServiceContext = class {
|
|
|
4279
4421
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4280
4422
|
this._instanceId = PublicKey10.random().toHex();
|
|
4281
4423
|
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
4282
|
-
this.indexMetadata = new IndexMetadataStore({
|
|
4283
|
-
directory: storage.createDirectory("index-metadata")
|
|
4284
|
-
});
|
|
4285
4424
|
this.snapshotStore = new SnapshotStore(storage.createDirectory("snapshots"));
|
|
4286
4425
|
this.blobStore = new BlobStore(storage.createDirectory("blobs"));
|
|
4287
4426
|
this.keyring = new Keyring(storage.createDirectory("keyring"));
|
|
@@ -4304,10 +4443,34 @@ var ServiceContext = class {
|
|
|
4304
4443
|
snapshotStore: this.snapshotStore
|
|
4305
4444
|
});
|
|
4306
4445
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
4446
|
+
this.indexMetadata = new IndexMetadataStore({
|
|
4447
|
+
directory: storage.createDirectory("index-metadata")
|
|
4448
|
+
});
|
|
4307
4449
|
this.automergeHost = new AutomergeHost({
|
|
4308
4450
|
directory: storage.createDirectory("automerge"),
|
|
4309
4451
|
metadata: this.indexMetadata
|
|
4310
4452
|
});
|
|
4453
|
+
this.indexer = new Indexer({
|
|
4454
|
+
indexStore: new IndexStore({
|
|
4455
|
+
directory: storage.createDirectory("index-store")
|
|
4456
|
+
}),
|
|
4457
|
+
metadataStore: this.indexMetadata,
|
|
4458
|
+
loadDocuments: async (ids) => {
|
|
4459
|
+
const snapshots = await Promise.all(ids.map(async (id) => {
|
|
4460
|
+
const { documentId, objectId } = idCodec.decode(id);
|
|
4461
|
+
const handle = this.automergeHost.repo.find(documentId);
|
|
4462
|
+
await warnAfterTimeout2(1e3, "to long to load doc", () => handle.whenReady());
|
|
4463
|
+
const doc = handle.docSync();
|
|
4464
|
+
const heads = getHeads(doc);
|
|
4465
|
+
return {
|
|
4466
|
+
id,
|
|
4467
|
+
object: doc.objects[objectId],
|
|
4468
|
+
currentHash: heads.at(-1)
|
|
4469
|
+
};
|
|
4470
|
+
}));
|
|
4471
|
+
return snapshots.filter((snapshot) => snapshot.object);
|
|
4472
|
+
}
|
|
4473
|
+
});
|
|
4311
4474
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4312
4475
|
this._handlerFactories.set(Invitation6.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
|
|
4313
4476
|
}
|
|
@@ -4315,7 +4478,7 @@ var ServiceContext = class {
|
|
|
4315
4478
|
await this._checkStorageVersion();
|
|
4316
4479
|
log13("opening...", void 0, {
|
|
4317
4480
|
F: __dxlog_file15,
|
|
4318
|
-
L:
|
|
4481
|
+
L: 173,
|
|
4319
4482
|
S: this,
|
|
4320
4483
|
C: (f, a) => f(...a)
|
|
4321
4484
|
});
|
|
@@ -4323,7 +4486,7 @@ var ServiceContext = class {
|
|
|
4323
4486
|
id: this._instanceId
|
|
4324
4487
|
}), {
|
|
4325
4488
|
F: __dxlog_file15,
|
|
4326
|
-
L:
|
|
4489
|
+
L: 174,
|
|
4327
4490
|
S: this,
|
|
4328
4491
|
C: (f, a) => f(...a)
|
|
4329
4492
|
});
|
|
@@ -4339,13 +4502,13 @@ var ServiceContext = class {
|
|
|
4339
4502
|
id: this._instanceId
|
|
4340
4503
|
}), {
|
|
4341
4504
|
F: __dxlog_file15,
|
|
4342
|
-
L:
|
|
4505
|
+
L: 184,
|
|
4343
4506
|
S: this,
|
|
4344
4507
|
C: (f, a) => f(...a)
|
|
4345
4508
|
});
|
|
4346
4509
|
log13("opened", void 0, {
|
|
4347
4510
|
F: __dxlog_file15,
|
|
4348
|
-
L:
|
|
4511
|
+
L: 185,
|
|
4349
4512
|
S: this,
|
|
4350
4513
|
C: (f, a) => f(...a)
|
|
4351
4514
|
});
|
|
@@ -4353,7 +4516,7 @@ var ServiceContext = class {
|
|
|
4353
4516
|
async close() {
|
|
4354
4517
|
log13("closing...", void 0, {
|
|
4355
4518
|
F: __dxlog_file15,
|
|
4356
|
-
L:
|
|
4519
|
+
L: 189,
|
|
4357
4520
|
S: this,
|
|
4358
4521
|
C: (f, a) => f(...a)
|
|
4359
4522
|
});
|
|
@@ -4369,23 +4532,24 @@ var ServiceContext = class {
|
|
|
4369
4532
|
await this.signalManager.close();
|
|
4370
4533
|
this.dataServiceSubscriptions.clear();
|
|
4371
4534
|
await this.metadataStore.close();
|
|
4535
|
+
await this.indexer.destroy();
|
|
4372
4536
|
log13("closed", void 0, {
|
|
4373
4537
|
F: __dxlog_file15,
|
|
4374
|
-
L:
|
|
4538
|
+
L: 203,
|
|
4375
4539
|
S: this,
|
|
4376
4540
|
C: (f, a) => f(...a)
|
|
4377
4541
|
});
|
|
4378
4542
|
}
|
|
4379
4543
|
async createIdentity(params = {}) {
|
|
4380
4544
|
const identity = await this.identityManager.createIdentity(params);
|
|
4381
|
-
await this._initialize(new
|
|
4545
|
+
await this._initialize(new Context10());
|
|
4382
4546
|
return identity;
|
|
4383
4547
|
}
|
|
4384
4548
|
getInvitationHandler(invitation) {
|
|
4385
4549
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4386
|
-
|
|
4550
|
+
invariant14(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4387
4551
|
F: __dxlog_file15,
|
|
4388
|
-
L:
|
|
4552
|
+
L: 214,
|
|
4389
4553
|
S: this,
|
|
4390
4554
|
A: [
|
|
4391
4555
|
"factory",
|
|
@@ -4404,7 +4568,7 @@ var ServiceContext = class {
|
|
|
4404
4568
|
}
|
|
4405
4569
|
async _acceptIdentity(params) {
|
|
4406
4570
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
4407
|
-
await this._initialize(new
|
|
4571
|
+
await this._initialize(new Context10());
|
|
4408
4572
|
return identity;
|
|
4409
4573
|
}
|
|
4410
4574
|
async _checkStorageVersion() {
|
|
@@ -4417,7 +4581,7 @@ var ServiceContext = class {
|
|
|
4417
4581
|
async _initialize(ctx) {
|
|
4418
4582
|
log13("initializing spaces...", void 0, {
|
|
4419
4583
|
F: __dxlog_file15,
|
|
4420
|
-
L:
|
|
4584
|
+
L: 245,
|
|
4421
4585
|
S: this,
|
|
4422
4586
|
C: (f, a) => f(...a)
|
|
4423
4587
|
});
|
|
@@ -4438,9 +4602,9 @@ var ServiceContext = class {
|
|
|
4438
4602
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
|
|
4439
4603
|
await this.dataSpaceManager.open();
|
|
4440
4604
|
this._handlerFactories.set(Invitation6.Kind.SPACE, (invitation) => {
|
|
4441
|
-
|
|
4605
|
+
invariant14(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4442
4606
|
F: __dxlog_file15,
|
|
4443
|
-
L:
|
|
4607
|
+
L: 270,
|
|
4444
4608
|
S: this,
|
|
4445
4609
|
A: [
|
|
4446
4610
|
"this.dataSpaceManager",
|
|
@@ -4464,7 +4628,7 @@ var ServiceContext = class {
|
|
|
4464
4628
|
details: assertion
|
|
4465
4629
|
}, {
|
|
4466
4630
|
F: __dxlog_file15,
|
|
4467
|
-
L:
|
|
4631
|
+
L: 286,
|
|
4468
4632
|
S: this,
|
|
4469
4633
|
C: (f, a) => f(...a)
|
|
4470
4634
|
});
|
|
@@ -4475,7 +4639,7 @@ var ServiceContext = class {
|
|
|
4475
4639
|
details: assertion
|
|
4476
4640
|
}, {
|
|
4477
4641
|
F: __dxlog_file15,
|
|
4478
|
-
L:
|
|
4642
|
+
L: 290,
|
|
4479
4643
|
S: this,
|
|
4480
4644
|
C: (f, a) => f(...a)
|
|
4481
4645
|
});
|
|
@@ -4486,7 +4650,7 @@ var ServiceContext = class {
|
|
|
4486
4650
|
details: assertion
|
|
4487
4651
|
}, {
|
|
4488
4652
|
F: __dxlog_file15,
|
|
4489
|
-
L:
|
|
4653
|
+
L: 295,
|
|
4490
4654
|
S: this,
|
|
4491
4655
|
C: (f, a) => f(...a)
|
|
4492
4656
|
});
|
|
@@ -4497,7 +4661,7 @@ var ServiceContext = class {
|
|
|
4497
4661
|
} catch (err) {
|
|
4498
4662
|
log13.catch(err, void 0, {
|
|
4499
4663
|
F: __dxlog_file15,
|
|
4500
|
-
L:
|
|
4664
|
+
L: 301,
|
|
4501
4665
|
S: this,
|
|
4502
4666
|
C: (f, a) => f(...a)
|
|
4503
4667
|
});
|
|
@@ -4543,7 +4707,7 @@ var ServiceRegistry = class {
|
|
|
4543
4707
|
};
|
|
4544
4708
|
|
|
4545
4709
|
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
4546
|
-
import { asyncTimeout, Trigger as Trigger6 } from "@dxos/async";
|
|
4710
|
+
import { asyncTimeout as asyncTimeout2, Trigger as Trigger6 } from "@dxos/async";
|
|
4547
4711
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
4548
4712
|
import { log as log14, logInfo } from "@dxos/log";
|
|
4549
4713
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
@@ -4584,7 +4748,7 @@ var Lock = class {
|
|
|
4584
4748
|
S: this,
|
|
4585
4749
|
C: (f, a) => f(...a)
|
|
4586
4750
|
});
|
|
4587
|
-
await
|
|
4751
|
+
await asyncTimeout2(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
4588
4752
|
log14("acquired lock", void 0, {
|
|
4589
4753
|
F: __dxlog_file16,
|
|
4590
4754
|
L: 44,
|
|
@@ -4718,11 +4882,12 @@ var toStorageType = (type) => {
|
|
|
4718
4882
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
4719
4883
|
import { Event as Event8, synchronized as synchronized3 } from "@dxos/async";
|
|
4720
4884
|
import { clientServiceBundle, defaultKey, Properties } from "@dxos/client-protocol";
|
|
4721
|
-
import { Context as
|
|
4885
|
+
import { Context as Context11 } from "@dxos/context";
|
|
4722
4886
|
import { DocumentModel as DocumentModel2 } from "@dxos/document-model";
|
|
4723
4887
|
import { DataServiceImpl } from "@dxos/echo-pipeline";
|
|
4724
4888
|
import { getRawDoc, getAutomergeObjectCore } from "@dxos/echo-schema";
|
|
4725
|
-
import {
|
|
4889
|
+
import { IndexServiceImpl } from "@dxos/indexing";
|
|
4890
|
+
import { invariant as invariant16 } from "@dxos/invariant";
|
|
4726
4891
|
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
4727
4892
|
import { log as log16 } from "@dxos/log";
|
|
4728
4893
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
@@ -4738,7 +4903,7 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
|
|
|
4738
4903
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
4739
4904
|
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
4740
4905
|
import { Stream as Stream11 } from "@dxos/codec-protobuf";
|
|
4741
|
-
import { invariant as
|
|
4906
|
+
import { invariant as invariant15 } from "@dxos/invariant";
|
|
4742
4907
|
import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4743
4908
|
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
4744
4909
|
var DevicesServiceImpl = class {
|
|
@@ -4757,7 +4922,7 @@ var DevicesServiceImpl = class {
|
|
|
4757
4922
|
devices: []
|
|
4758
4923
|
});
|
|
4759
4924
|
} else {
|
|
4760
|
-
|
|
4925
|
+
invariant15(this._identityManager.identity?.presence, "presence not present", {
|
|
4761
4926
|
F: __dxlog_file17,
|
|
4762
4927
|
L: 32,
|
|
4763
4928
|
S: this,
|
|
@@ -5078,7 +5243,7 @@ var ClientServicesHost = class {
|
|
|
5078
5243
|
lockKey,
|
|
5079
5244
|
onAcquire: () => {
|
|
5080
5245
|
if (!this._opening) {
|
|
5081
|
-
void this.open(new
|
|
5246
|
+
void this.open(new Context11());
|
|
5082
5247
|
}
|
|
5083
5248
|
},
|
|
5084
5249
|
onRelease: () => this.close()
|
|
@@ -5132,9 +5297,9 @@ var ClientServicesHost = class {
|
|
|
5132
5297
|
* Can only be called once.
|
|
5133
5298
|
*/
|
|
5134
5299
|
initialize({ config, ...options }) {
|
|
5135
|
-
|
|
5300
|
+
invariant16(!this._open, "service host is open", {
|
|
5136
5301
|
F: __dxlog_file18,
|
|
5137
|
-
L:
|
|
5302
|
+
L: 191,
|
|
5138
5303
|
S: this,
|
|
5139
5304
|
A: [
|
|
5140
5305
|
"!this._open",
|
|
@@ -5143,14 +5308,14 @@ var ClientServicesHost = class {
|
|
|
5143
5308
|
});
|
|
5144
5309
|
log16("initializing...", void 0, {
|
|
5145
5310
|
F: __dxlog_file18,
|
|
5146
|
-
L:
|
|
5311
|
+
L: 192,
|
|
5147
5312
|
S: this,
|
|
5148
5313
|
C: (f, a) => f(...a)
|
|
5149
5314
|
});
|
|
5150
5315
|
if (config) {
|
|
5151
|
-
|
|
5316
|
+
invariant16(!this._config, "config already set", {
|
|
5152
5317
|
F: __dxlog_file18,
|
|
5153
|
-
L:
|
|
5318
|
+
L: 195,
|
|
5154
5319
|
S: this,
|
|
5155
5320
|
A: [
|
|
5156
5321
|
"!this._config",
|
|
@@ -5166,9 +5331,9 @@ var ClientServicesHost = class {
|
|
|
5166
5331
|
iceServers: this._config?.get("runtime.services.ice")
|
|
5167
5332
|
}), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
5168
5333
|
this._signalManager = signalManager;
|
|
5169
|
-
|
|
5334
|
+
invariant16(!this._networkManager, "network manager already set", {
|
|
5170
5335
|
F: __dxlog_file18,
|
|
5171
|
-
L:
|
|
5336
|
+
L: 211,
|
|
5172
5337
|
S: this,
|
|
5173
5338
|
A: [
|
|
5174
5339
|
"!this._networkManager",
|
|
@@ -5182,7 +5347,7 @@ var ClientServicesHost = class {
|
|
|
5182
5347
|
});
|
|
5183
5348
|
log16("initialized", void 0, {
|
|
5184
5349
|
F: __dxlog_file18,
|
|
5185
|
-
L:
|
|
5350
|
+
L: 218,
|
|
5186
5351
|
S: this,
|
|
5187
5352
|
C: (f, a) => f(...a)
|
|
5188
5353
|
});
|
|
@@ -5196,40 +5361,40 @@ var ClientServicesHost = class {
|
|
|
5196
5361
|
id: traceId
|
|
5197
5362
|
}), {
|
|
5198
5363
|
F: __dxlog_file18,
|
|
5199
|
-
L:
|
|
5364
|
+
L: 229,
|
|
5200
5365
|
S: this,
|
|
5201
5366
|
C: (f, a) => f(...a)
|
|
5202
5367
|
});
|
|
5203
|
-
|
|
5368
|
+
invariant16(this._config, "config not set", {
|
|
5204
5369
|
F: __dxlog_file18,
|
|
5205
|
-
L:
|
|
5370
|
+
L: 231,
|
|
5206
5371
|
S: this,
|
|
5207
5372
|
A: [
|
|
5208
5373
|
"this._config",
|
|
5209
5374
|
"'config not set'"
|
|
5210
5375
|
]
|
|
5211
5376
|
});
|
|
5212
|
-
|
|
5377
|
+
invariant16(this._storage, "storage not set", {
|
|
5213
5378
|
F: __dxlog_file18,
|
|
5214
|
-
L:
|
|
5379
|
+
L: 232,
|
|
5215
5380
|
S: this,
|
|
5216
5381
|
A: [
|
|
5217
5382
|
"this._storage",
|
|
5218
5383
|
"'storage not set'"
|
|
5219
5384
|
]
|
|
5220
5385
|
});
|
|
5221
|
-
|
|
5386
|
+
invariant16(this._signalManager, "signal manager not set", {
|
|
5222
5387
|
F: __dxlog_file18,
|
|
5223
|
-
L:
|
|
5388
|
+
L: 233,
|
|
5224
5389
|
S: this,
|
|
5225
5390
|
A: [
|
|
5226
5391
|
"this._signalManager",
|
|
5227
5392
|
"'signal manager not set'"
|
|
5228
5393
|
]
|
|
5229
5394
|
});
|
|
5230
|
-
|
|
5395
|
+
invariant16(this._networkManager, "network manager not set", {
|
|
5231
5396
|
F: __dxlog_file18,
|
|
5232
|
-
L:
|
|
5397
|
+
L: 234,
|
|
5233
5398
|
S: this,
|
|
5234
5399
|
A: [
|
|
5235
5400
|
"this._networkManager",
|
|
@@ -5241,7 +5406,7 @@ var ClientServicesHost = class {
|
|
|
5241
5406
|
lockKey: this._resourceLock?.lockKey
|
|
5242
5407
|
}, {
|
|
5243
5408
|
F: __dxlog_file18,
|
|
5244
|
-
L:
|
|
5409
|
+
L: 237,
|
|
5245
5410
|
S: this,
|
|
5246
5411
|
C: (f, a) => f(...a)
|
|
5247
5412
|
});
|
|
@@ -5251,13 +5416,17 @@ var ClientServicesHost = class {
|
|
|
5251
5416
|
this._serviceRegistry.setServices({
|
|
5252
5417
|
SystemService: this._systemService,
|
|
5253
5418
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
5254
|
-
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
|
|
5419
|
+
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation), this._serviceContext.metadataStore),
|
|
5255
5420
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
5256
5421
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
5257
5422
|
await this._serviceContext.initialized.wait();
|
|
5258
5423
|
return this._serviceContext.dataSpaceManager;
|
|
5259
5424
|
}),
|
|
5260
5425
|
DataService: new DataServiceImpl(this._serviceContext.dataServiceSubscriptions, this._serviceContext.automergeHost),
|
|
5426
|
+
IndexService: new IndexServiceImpl({
|
|
5427
|
+
indexer: this._serviceContext.indexer,
|
|
5428
|
+
automergeHost: this._serviceContext.automergeHost
|
|
5429
|
+
}),
|
|
5261
5430
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
5262
5431
|
LoggingService: this._loggingService,
|
|
5263
5432
|
TracingService: this._tracingService,
|
|
@@ -5269,6 +5438,24 @@ var ClientServicesHost = class {
|
|
|
5269
5438
|
})
|
|
5270
5439
|
});
|
|
5271
5440
|
await this._serviceContext.open(ctx);
|
|
5441
|
+
invariant16(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5442
|
+
F: __dxlog_file18,
|
|
5443
|
+
L: 303,
|
|
5444
|
+
S: this,
|
|
5445
|
+
A: [
|
|
5446
|
+
"this.serviceRegistry.services.InvitationsService",
|
|
5447
|
+
""
|
|
5448
|
+
]
|
|
5449
|
+
});
|
|
5450
|
+
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5451
|
+
log16("loaded persistent invitations", {
|
|
5452
|
+
count: loadedInvitations.invitations?.length
|
|
5453
|
+
}, {
|
|
5454
|
+
F: __dxlog_file18,
|
|
5455
|
+
L: 306,
|
|
5456
|
+
S: this,
|
|
5457
|
+
C: (f, a) => f(...a)
|
|
5458
|
+
});
|
|
5272
5459
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
5273
5460
|
if (devtoolsProxy) {
|
|
5274
5461
|
this._devtoolsProxy = new WebsocketRpcClient({
|
|
@@ -5287,7 +5474,7 @@ var ClientServicesHost = class {
|
|
|
5287
5474
|
deviceKey
|
|
5288
5475
|
}, {
|
|
5289
5476
|
F: __dxlog_file18,
|
|
5290
|
-
L:
|
|
5477
|
+
L: 323,
|
|
5291
5478
|
S: this,
|
|
5292
5479
|
C: (f, a) => f(...a)
|
|
5293
5480
|
});
|
|
@@ -5295,7 +5482,7 @@ var ClientServicesHost = class {
|
|
|
5295
5482
|
id: traceId
|
|
5296
5483
|
}), {
|
|
5297
5484
|
F: __dxlog_file18,
|
|
5298
|
-
L:
|
|
5485
|
+
L: 324,
|
|
5299
5486
|
S: this,
|
|
5300
5487
|
C: (f, a) => f(...a)
|
|
5301
5488
|
});
|
|
@@ -5309,7 +5496,7 @@ var ClientServicesHost = class {
|
|
|
5309
5496
|
deviceKey
|
|
5310
5497
|
}, {
|
|
5311
5498
|
F: __dxlog_file18,
|
|
5312
|
-
L:
|
|
5499
|
+
L: 335,
|
|
5313
5500
|
S: this,
|
|
5314
5501
|
C: (f, a) => f(...a)
|
|
5315
5502
|
});
|
|
@@ -5325,7 +5512,7 @@ var ClientServicesHost = class {
|
|
|
5325
5512
|
deviceKey
|
|
5326
5513
|
}, {
|
|
5327
5514
|
F: __dxlog_file18,
|
|
5328
|
-
L:
|
|
5515
|
+
L: 342,
|
|
5329
5516
|
S: this,
|
|
5330
5517
|
C: (f, a) => f(...a)
|
|
5331
5518
|
});
|
|
@@ -5336,13 +5523,13 @@ var ClientServicesHost = class {
|
|
|
5336
5523
|
id: traceId
|
|
5337
5524
|
}), {
|
|
5338
5525
|
F: __dxlog_file18,
|
|
5339
|
-
L:
|
|
5526
|
+
L: 347,
|
|
5340
5527
|
S: this,
|
|
5341
5528
|
C: (f, a) => f(...a)
|
|
5342
5529
|
});
|
|
5343
5530
|
log16("resetting...", void 0, {
|
|
5344
5531
|
F: __dxlog_file18,
|
|
5345
|
-
L:
|
|
5532
|
+
L: 349,
|
|
5346
5533
|
S: this,
|
|
5347
5534
|
C: (f, a) => f(...a)
|
|
5348
5535
|
});
|
|
@@ -5350,7 +5537,7 @@ var ClientServicesHost = class {
|
|
|
5350
5537
|
await this._storage.reset();
|
|
5351
5538
|
log16("reset", void 0, {
|
|
5352
5539
|
F: __dxlog_file18,
|
|
5353
|
-
L:
|
|
5540
|
+
L: 352,
|
|
5354
5541
|
S: this,
|
|
5355
5542
|
C: (f, a) => f(...a)
|
|
5356
5543
|
});
|
|
@@ -5358,7 +5545,7 @@ var ClientServicesHost = class {
|
|
|
5358
5545
|
id: traceId
|
|
5359
5546
|
}), {
|
|
5360
5547
|
F: __dxlog_file18,
|
|
5361
|
-
L:
|
|
5548
|
+
L: 353,
|
|
5362
5549
|
S: this,
|
|
5363
5550
|
C: (f, a) => f(...a)
|
|
5364
5551
|
});
|
|
@@ -5371,9 +5558,9 @@ var ClientServicesHost = class {
|
|
|
5371
5558
|
const obj = new Properties(void 0);
|
|
5372
5559
|
obj[defaultKey] = identity.identityKey.toHex();
|
|
5373
5560
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5374
|
-
|
|
5561
|
+
invariant16(automergeIndex, void 0, {
|
|
5375
5562
|
F: __dxlog_file18,
|
|
5376
|
-
L:
|
|
5563
|
+
L: 368,
|
|
5377
5564
|
S: this,
|
|
5378
5565
|
A: [
|
|
5379
5566
|
"automergeIndex",
|
|
@@ -5428,6 +5615,7 @@ export {
|
|
|
5428
5615
|
IdentityServiceImpl,
|
|
5429
5616
|
DeviceInvitationProtocol,
|
|
5430
5617
|
InvitationsHandler,
|
|
5618
|
+
invitationExpired,
|
|
5431
5619
|
InvitationsServiceImpl,
|
|
5432
5620
|
SpaceInvitationProtocol,
|
|
5433
5621
|
ClientRpcServer,
|
|
@@ -5443,4 +5631,4 @@ export {
|
|
|
5443
5631
|
createDefaultModelFactory,
|
|
5444
5632
|
ClientServicesHost
|
|
5445
5633
|
};
|
|
5446
|
-
//# sourceMappingURL=chunk-
|
|
5634
|
+
//# sourceMappingURL=chunk-WAR4XN64.mjs.map
|