@dxos/client-services 0.4.7-main.85d9ee7 → 0.4.7-main.b1ae49b
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-KESTWAZ5.mjs → chunk-XXUWZUVG.mjs} +324 -150
- package/dist/lib/browser/chunk-XXUWZUVG.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +7 -3
- package/dist/lib/browser/index.mjs.map +2 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +4 -2
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-RG6HMYQS.cjs → chunk-65WPTUZO.cjs} +297 -122
- package/dist/lib/node/chunk-65WPTUZO.cjs.map +7 -0
- package/dist/lib/node/index.cjs +43 -39
- package/dist/lib/node/index.cjs.map +2 -2
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +11 -9
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- 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/logging/logging-service.d.ts +1 -0
- package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +2 -0
- 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/packlets/vault/shared-worker-connection.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +35 -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/logging/logging-service.ts +9 -2
- package/src/packlets/services/automerge-host.test.ts +1 -1
- package/src/packlets/services/service-context.ts +7 -1
- package/src/packlets/services/service-host.ts +9 -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/packlets/testing/test-builder.ts +1 -1
- package/src/packlets/vault/shared-worker-connection.ts +3 -1
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-KESTWAZ5.mjs.map +0 -7
- package/dist/lib/node/chunk-RG6HMYQS.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.7-main.
|
|
2775
|
+
var DXOS_VERSION = "0.4.7-main.b1ae49b";
|
|
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,12 +4382,13 @@ 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 { Context as
|
|
4385
|
+
import { Context as Context10 } from "@dxos/context";
|
|
4245
4386
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
4246
4387
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
4247
4388
|
import { valueEncoding, MetadataStore, SpaceManager, DataServiceSubscriptions, SnapshotStore, AutomergeHost } from "@dxos/echo-pipeline";
|
|
4389
|
+
import { IndexMetadataStore } from "@dxos/echo-schema";
|
|
4248
4390
|
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
4249
|
-
import { invariant as
|
|
4391
|
+
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4250
4392
|
import { Keyring } from "@dxos/keyring";
|
|
4251
4393
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
4252
4394
|
import { log as log13 } from "@dxos/log";
|
|
@@ -4278,6 +4420,9 @@ var ServiceContext = class {
|
|
|
4278
4420
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4279
4421
|
this._instanceId = PublicKey10.random().toHex();
|
|
4280
4422
|
this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
|
|
4423
|
+
this.indexMetadata = new IndexMetadataStore({
|
|
4424
|
+
directory: storage.createDirectory("index-metadata")
|
|
4425
|
+
});
|
|
4281
4426
|
this.snapshotStore = new SnapshotStore(storage.createDirectory("snapshots"));
|
|
4282
4427
|
this.blobStore = new BlobStore(storage.createDirectory("blobs"));
|
|
4283
4428
|
this.keyring = new Keyring(storage.createDirectory("keyring"));
|
|
@@ -4300,7 +4445,10 @@ var ServiceContext = class {
|
|
|
4300
4445
|
snapshotStore: this.snapshotStore
|
|
4301
4446
|
});
|
|
4302
4447
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
4303
|
-
this.automergeHost = new AutomergeHost(
|
|
4448
|
+
this.automergeHost = new AutomergeHost({
|
|
4449
|
+
directory: storage.createDirectory("automerge"),
|
|
4450
|
+
metadata: this.indexMetadata
|
|
4451
|
+
});
|
|
4304
4452
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4305
4453
|
this._handlerFactories.set(Invitation6.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? failUndefined2(), this._acceptIdentity.bind(this)));
|
|
4306
4454
|
}
|
|
@@ -4308,7 +4456,7 @@ var ServiceContext = class {
|
|
|
4308
4456
|
await this._checkStorageVersion();
|
|
4309
4457
|
log13("opening...", void 0, {
|
|
4310
4458
|
F: __dxlog_file15,
|
|
4311
|
-
L:
|
|
4459
|
+
L: 152,
|
|
4312
4460
|
S: this,
|
|
4313
4461
|
C: (f, a) => f(...a)
|
|
4314
4462
|
});
|
|
@@ -4316,7 +4464,7 @@ var ServiceContext = class {
|
|
|
4316
4464
|
id: this._instanceId
|
|
4317
4465
|
}), {
|
|
4318
4466
|
F: __dxlog_file15,
|
|
4319
|
-
L:
|
|
4467
|
+
L: 153,
|
|
4320
4468
|
S: this,
|
|
4321
4469
|
C: (f, a) => f(...a)
|
|
4322
4470
|
});
|
|
@@ -4332,13 +4480,13 @@ var ServiceContext = class {
|
|
|
4332
4480
|
id: this._instanceId
|
|
4333
4481
|
}), {
|
|
4334
4482
|
F: __dxlog_file15,
|
|
4335
|
-
L:
|
|
4483
|
+
L: 163,
|
|
4336
4484
|
S: this,
|
|
4337
4485
|
C: (f, a) => f(...a)
|
|
4338
4486
|
});
|
|
4339
4487
|
log13("opened", void 0, {
|
|
4340
4488
|
F: __dxlog_file15,
|
|
4341
|
-
L:
|
|
4489
|
+
L: 164,
|
|
4342
4490
|
S: this,
|
|
4343
4491
|
C: (f, a) => f(...a)
|
|
4344
4492
|
});
|
|
@@ -4346,7 +4494,7 @@ var ServiceContext = class {
|
|
|
4346
4494
|
async close() {
|
|
4347
4495
|
log13("closing...", void 0, {
|
|
4348
4496
|
F: __dxlog_file15,
|
|
4349
|
-
L:
|
|
4497
|
+
L: 168,
|
|
4350
4498
|
S: this,
|
|
4351
4499
|
C: (f, a) => f(...a)
|
|
4352
4500
|
});
|
|
@@ -4364,21 +4512,21 @@ var ServiceContext = class {
|
|
|
4364
4512
|
await this.metadataStore.close();
|
|
4365
4513
|
log13("closed", void 0, {
|
|
4366
4514
|
F: __dxlog_file15,
|
|
4367
|
-
L:
|
|
4515
|
+
L: 181,
|
|
4368
4516
|
S: this,
|
|
4369
4517
|
C: (f, a) => f(...a)
|
|
4370
4518
|
});
|
|
4371
4519
|
}
|
|
4372
4520
|
async createIdentity(params = {}) {
|
|
4373
4521
|
const identity = await this.identityManager.createIdentity(params);
|
|
4374
|
-
await this._initialize(new
|
|
4522
|
+
await this._initialize(new Context10());
|
|
4375
4523
|
return identity;
|
|
4376
4524
|
}
|
|
4377
4525
|
getInvitationHandler(invitation) {
|
|
4378
4526
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4379
|
-
|
|
4527
|
+
invariant14(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4380
4528
|
F: __dxlog_file15,
|
|
4381
|
-
L:
|
|
4529
|
+
L: 192,
|
|
4382
4530
|
S: this,
|
|
4383
4531
|
A: [
|
|
4384
4532
|
"factory",
|
|
@@ -4397,7 +4545,7 @@ var ServiceContext = class {
|
|
|
4397
4545
|
}
|
|
4398
4546
|
async _acceptIdentity(params) {
|
|
4399
4547
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
4400
|
-
await this._initialize(new
|
|
4548
|
+
await this._initialize(new Context10());
|
|
4401
4549
|
return identity;
|
|
4402
4550
|
}
|
|
4403
4551
|
async _checkStorageVersion() {
|
|
@@ -4410,7 +4558,7 @@ var ServiceContext = class {
|
|
|
4410
4558
|
async _initialize(ctx) {
|
|
4411
4559
|
log13("initializing spaces...", void 0, {
|
|
4412
4560
|
F: __dxlog_file15,
|
|
4413
|
-
L:
|
|
4561
|
+
L: 223,
|
|
4414
4562
|
S: this,
|
|
4415
4563
|
C: (f, a) => f(...a)
|
|
4416
4564
|
});
|
|
@@ -4431,9 +4579,9 @@ var ServiceContext = class {
|
|
|
4431
4579
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
|
|
4432
4580
|
await this.dataSpaceManager.open();
|
|
4433
4581
|
this._handlerFactories.set(Invitation6.Kind.SPACE, (invitation) => {
|
|
4434
|
-
|
|
4582
|
+
invariant14(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4435
4583
|
F: __dxlog_file15,
|
|
4436
|
-
L:
|
|
4584
|
+
L: 248,
|
|
4437
4585
|
S: this,
|
|
4438
4586
|
A: [
|
|
4439
4587
|
"this.dataSpaceManager",
|
|
@@ -4457,7 +4605,7 @@ var ServiceContext = class {
|
|
|
4457
4605
|
details: assertion
|
|
4458
4606
|
}, {
|
|
4459
4607
|
F: __dxlog_file15,
|
|
4460
|
-
L:
|
|
4608
|
+
L: 264,
|
|
4461
4609
|
S: this,
|
|
4462
4610
|
C: (f, a) => f(...a)
|
|
4463
4611
|
});
|
|
@@ -4468,7 +4616,7 @@ var ServiceContext = class {
|
|
|
4468
4616
|
details: assertion
|
|
4469
4617
|
}, {
|
|
4470
4618
|
F: __dxlog_file15,
|
|
4471
|
-
L:
|
|
4619
|
+
L: 268,
|
|
4472
4620
|
S: this,
|
|
4473
4621
|
C: (f, a) => f(...a)
|
|
4474
4622
|
});
|
|
@@ -4479,7 +4627,7 @@ var ServiceContext = class {
|
|
|
4479
4627
|
details: assertion
|
|
4480
4628
|
}, {
|
|
4481
4629
|
F: __dxlog_file15,
|
|
4482
|
-
L:
|
|
4630
|
+
L: 273,
|
|
4483
4631
|
S: this,
|
|
4484
4632
|
C: (f, a) => f(...a)
|
|
4485
4633
|
});
|
|
@@ -4490,7 +4638,7 @@ var ServiceContext = class {
|
|
|
4490
4638
|
} catch (err) {
|
|
4491
4639
|
log13.catch(err, void 0, {
|
|
4492
4640
|
F: __dxlog_file15,
|
|
4493
|
-
L:
|
|
4641
|
+
L: 279,
|
|
4494
4642
|
S: this,
|
|
4495
4643
|
C: (f, a) => f(...a)
|
|
4496
4644
|
});
|
|
@@ -4536,7 +4684,7 @@ var ServiceRegistry = class {
|
|
|
4536
4684
|
};
|
|
4537
4685
|
|
|
4538
4686
|
// packages/sdk/client-services/src/packlets/locks/browser.ts
|
|
4539
|
-
import { asyncTimeout, Trigger as Trigger6 } from "@dxos/async";
|
|
4687
|
+
import { asyncTimeout as asyncTimeout2, Trigger as Trigger6 } from "@dxos/async";
|
|
4540
4688
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
4541
4689
|
import { log as log14, logInfo } from "@dxos/log";
|
|
4542
4690
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
@@ -4577,7 +4725,7 @@ var Lock = class {
|
|
|
4577
4725
|
S: this,
|
|
4578
4726
|
C: (f, a) => f(...a)
|
|
4579
4727
|
});
|
|
4580
|
-
await
|
|
4728
|
+
await asyncTimeout2(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
4581
4729
|
log14("acquired lock", void 0, {
|
|
4582
4730
|
F: __dxlog_file16,
|
|
4583
4731
|
L: 44,
|
|
@@ -4711,12 +4859,12 @@ var toStorageType = (type) => {
|
|
|
4711
4859
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
4712
4860
|
import { Event as Event8, synchronized as synchronized3 } from "@dxos/async";
|
|
4713
4861
|
import { clientServiceBundle, defaultKey, Properties } from "@dxos/client-protocol";
|
|
4714
|
-
import { Context as
|
|
4862
|
+
import { Context as Context11 } from "@dxos/context";
|
|
4715
4863
|
import { DocumentModel as DocumentModel2 } from "@dxos/document-model";
|
|
4716
4864
|
import { DataServiceImpl } from "@dxos/echo-pipeline";
|
|
4717
4865
|
import { getRawDoc, getAutomergeObjectCore } from "@dxos/echo-schema";
|
|
4718
|
-
import { invariant as
|
|
4719
|
-
import { PublicKey as
|
|
4866
|
+
import { invariant as invariant16 } from "@dxos/invariant";
|
|
4867
|
+
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
4720
4868
|
import { log as log16 } from "@dxos/log";
|
|
4721
4869
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
4722
4870
|
import { ModelFactory } from "@dxos/model-factory";
|
|
@@ -4731,7 +4879,7 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
|
|
|
4731
4879
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
4732
4880
|
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
4733
4881
|
import { Stream as Stream11 } from "@dxos/codec-protobuf";
|
|
4734
|
-
import { invariant as
|
|
4882
|
+
import { invariant as invariant15 } from "@dxos/invariant";
|
|
4735
4883
|
import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4736
4884
|
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
4737
4885
|
var DevicesServiceImpl = class {
|
|
@@ -4750,7 +4898,7 @@ var DevicesServiceImpl = class {
|
|
|
4750
4898
|
devices: []
|
|
4751
4899
|
});
|
|
4752
4900
|
} else {
|
|
4753
|
-
|
|
4901
|
+
invariant15(this._identityManager.identity?.presence, "presence not present", {
|
|
4754
4902
|
F: __dxlog_file17,
|
|
4755
4903
|
L: 32,
|
|
4756
4904
|
S: this,
|
|
@@ -4813,13 +4961,15 @@ var DevicesServiceImpl = class {
|
|
|
4813
4961
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
4814
4962
|
import { Event as Event7 } from "@dxos/async";
|
|
4815
4963
|
import { Stream as Stream12 } from "@dxos/codec-protobuf";
|
|
4964
|
+
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4816
4965
|
import { getContextFromEntry, log as log15 } from "@dxos/log";
|
|
4817
4966
|
import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
4818
|
-
import { jsonify, numericalValues, tracer } from "@dxos/util";
|
|
4967
|
+
import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
|
|
4819
4968
|
var LoggingServiceImpl = class {
|
|
4820
4969
|
constructor() {
|
|
4821
4970
|
this._logs = new Event7();
|
|
4822
|
-
this._started =
|
|
4971
|
+
this._started = Date.now();
|
|
4972
|
+
this._sessionId = PublicKey11.random().toHex();
|
|
4823
4973
|
this._logProcessor = (_config, entry2) => {
|
|
4824
4974
|
this._logs.emit(entry2);
|
|
4825
4975
|
};
|
|
@@ -4895,7 +5045,12 @@ var LoggingServiceImpl = class {
|
|
|
4895
5045
|
meta: {
|
|
4896
5046
|
// TODO(dmaretskyi): Fix proto.
|
|
4897
5047
|
file: entry2.meta?.F ?? "",
|
|
4898
|
-
line: entry2.meta?.L ?? 0
|
|
5048
|
+
line: entry2.meta?.L ?? 0,
|
|
5049
|
+
scope: {
|
|
5050
|
+
hostSessionId: this._sessionId,
|
|
5051
|
+
uptimeSeconds: (Date.now() - this._started) / 1e3,
|
|
5052
|
+
name: getDebugName(entry2.meta?.S)
|
|
5053
|
+
}
|
|
4899
5054
|
}
|
|
4900
5055
|
};
|
|
4901
5056
|
try {
|
|
@@ -5064,7 +5219,7 @@ var ClientServicesHost = class {
|
|
|
5064
5219
|
lockKey,
|
|
5065
5220
|
onAcquire: () => {
|
|
5066
5221
|
if (!this._opening) {
|
|
5067
|
-
void this.open(new
|
|
5222
|
+
void this.open(new Context11());
|
|
5068
5223
|
}
|
|
5069
5224
|
},
|
|
5070
5225
|
onRelease: () => this.close()
|
|
@@ -5118,7 +5273,7 @@ var ClientServicesHost = class {
|
|
|
5118
5273
|
* Can only be called once.
|
|
5119
5274
|
*/
|
|
5120
5275
|
initialize({ config, ...options }) {
|
|
5121
|
-
|
|
5276
|
+
invariant16(!this._open, "service host is open", {
|
|
5122
5277
|
F: __dxlog_file18,
|
|
5123
5278
|
L: 190,
|
|
5124
5279
|
S: this,
|
|
@@ -5134,7 +5289,7 @@ var ClientServicesHost = class {
|
|
|
5134
5289
|
C: (f, a) => f(...a)
|
|
5135
5290
|
});
|
|
5136
5291
|
if (config) {
|
|
5137
|
-
|
|
5292
|
+
invariant16(!this._config, "config already set", {
|
|
5138
5293
|
F: __dxlog_file18,
|
|
5139
5294
|
L: 194,
|
|
5140
5295
|
S: this,
|
|
@@ -5152,7 +5307,7 @@ var ClientServicesHost = class {
|
|
|
5152
5307
|
iceServers: this._config?.get("runtime.services.ice")
|
|
5153
5308
|
}), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
5154
5309
|
this._signalManager = signalManager;
|
|
5155
|
-
|
|
5310
|
+
invariant16(!this._networkManager, "network manager already set", {
|
|
5156
5311
|
F: __dxlog_file18,
|
|
5157
5312
|
L: 210,
|
|
5158
5313
|
S: this,
|
|
@@ -5177,7 +5332,7 @@ var ClientServicesHost = class {
|
|
|
5177
5332
|
if (this._open) {
|
|
5178
5333
|
return;
|
|
5179
5334
|
}
|
|
5180
|
-
const traceId =
|
|
5335
|
+
const traceId = PublicKey12.random().toHex();
|
|
5181
5336
|
log16.trace("dxos.client-services.host.open", trace9.begin({
|
|
5182
5337
|
id: traceId
|
|
5183
5338
|
}), {
|
|
@@ -5186,7 +5341,7 @@ var ClientServicesHost = class {
|
|
|
5186
5341
|
S: this,
|
|
5187
5342
|
C: (f, a) => f(...a)
|
|
5188
5343
|
});
|
|
5189
|
-
|
|
5344
|
+
invariant16(this._config, "config not set", {
|
|
5190
5345
|
F: __dxlog_file18,
|
|
5191
5346
|
L: 230,
|
|
5192
5347
|
S: this,
|
|
@@ -5195,7 +5350,7 @@ var ClientServicesHost = class {
|
|
|
5195
5350
|
"'config not set'"
|
|
5196
5351
|
]
|
|
5197
5352
|
});
|
|
5198
|
-
|
|
5353
|
+
invariant16(this._storage, "storage not set", {
|
|
5199
5354
|
F: __dxlog_file18,
|
|
5200
5355
|
L: 231,
|
|
5201
5356
|
S: this,
|
|
@@ -5204,7 +5359,7 @@ var ClientServicesHost = class {
|
|
|
5204
5359
|
"'storage not set'"
|
|
5205
5360
|
]
|
|
5206
5361
|
});
|
|
5207
|
-
|
|
5362
|
+
invariant16(this._signalManager, "signal manager not set", {
|
|
5208
5363
|
F: __dxlog_file18,
|
|
5209
5364
|
L: 232,
|
|
5210
5365
|
S: this,
|
|
@@ -5213,7 +5368,7 @@ var ClientServicesHost = class {
|
|
|
5213
5368
|
"'signal manager not set'"
|
|
5214
5369
|
]
|
|
5215
5370
|
});
|
|
5216
|
-
|
|
5371
|
+
invariant16(this._networkManager, "network manager not set", {
|
|
5217
5372
|
F: __dxlog_file18,
|
|
5218
5373
|
L: 233,
|
|
5219
5374
|
S: this,
|
|
@@ -5237,7 +5392,7 @@ var ClientServicesHost = class {
|
|
|
5237
5392
|
this._serviceRegistry.setServices({
|
|
5238
5393
|
SystemService: this._systemService,
|
|
5239
5394
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
5240
|
-
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
|
|
5395
|
+
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation), this._serviceContext.metadataStore),
|
|
5241
5396
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
5242
5397
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
5243
5398
|
await this._serviceContext.initialized.wait();
|
|
@@ -5255,6 +5410,24 @@ var ClientServicesHost = class {
|
|
|
5255
5410
|
})
|
|
5256
5411
|
});
|
|
5257
5412
|
await this._serviceContext.open(ctx);
|
|
5413
|
+
invariant16(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5414
|
+
F: __dxlog_file18,
|
|
5415
|
+
L: 297,
|
|
5416
|
+
S: this,
|
|
5417
|
+
A: [
|
|
5418
|
+
"this.serviceRegistry.services.InvitationsService",
|
|
5419
|
+
""
|
|
5420
|
+
]
|
|
5421
|
+
});
|
|
5422
|
+
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5423
|
+
log16("loaded persistent invitations", {
|
|
5424
|
+
count: loadedInvitations.invitations?.length
|
|
5425
|
+
}, {
|
|
5426
|
+
F: __dxlog_file18,
|
|
5427
|
+
L: 300,
|
|
5428
|
+
S: this,
|
|
5429
|
+
C: (f, a) => f(...a)
|
|
5430
|
+
});
|
|
5258
5431
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
5259
5432
|
if (devtoolsProxy) {
|
|
5260
5433
|
this._devtoolsProxy = new WebsocketRpcClient({
|
|
@@ -5273,7 +5446,7 @@ var ClientServicesHost = class {
|
|
|
5273
5446
|
deviceKey
|
|
5274
5447
|
}, {
|
|
5275
5448
|
F: __dxlog_file18,
|
|
5276
|
-
L:
|
|
5449
|
+
L: 317,
|
|
5277
5450
|
S: this,
|
|
5278
5451
|
C: (f, a) => f(...a)
|
|
5279
5452
|
});
|
|
@@ -5281,7 +5454,7 @@ var ClientServicesHost = class {
|
|
|
5281
5454
|
id: traceId
|
|
5282
5455
|
}), {
|
|
5283
5456
|
F: __dxlog_file18,
|
|
5284
|
-
L:
|
|
5457
|
+
L: 318,
|
|
5285
5458
|
S: this,
|
|
5286
5459
|
C: (f, a) => f(...a)
|
|
5287
5460
|
});
|
|
@@ -5295,7 +5468,7 @@ var ClientServicesHost = class {
|
|
|
5295
5468
|
deviceKey
|
|
5296
5469
|
}, {
|
|
5297
5470
|
F: __dxlog_file18,
|
|
5298
|
-
L:
|
|
5471
|
+
L: 329,
|
|
5299
5472
|
S: this,
|
|
5300
5473
|
C: (f, a) => f(...a)
|
|
5301
5474
|
});
|
|
@@ -5311,24 +5484,24 @@ var ClientServicesHost = class {
|
|
|
5311
5484
|
deviceKey
|
|
5312
5485
|
}, {
|
|
5313
5486
|
F: __dxlog_file18,
|
|
5314
|
-
L:
|
|
5487
|
+
L: 336,
|
|
5315
5488
|
S: this,
|
|
5316
5489
|
C: (f, a) => f(...a)
|
|
5317
5490
|
});
|
|
5318
5491
|
}
|
|
5319
5492
|
async reset() {
|
|
5320
|
-
const traceId =
|
|
5493
|
+
const traceId = PublicKey12.random().toHex();
|
|
5321
5494
|
log16.trace("dxos.sdk.client-services-host.reset", trace9.begin({
|
|
5322
5495
|
id: traceId
|
|
5323
5496
|
}), {
|
|
5324
5497
|
F: __dxlog_file18,
|
|
5325
|
-
L:
|
|
5498
|
+
L: 341,
|
|
5326
5499
|
S: this,
|
|
5327
5500
|
C: (f, a) => f(...a)
|
|
5328
5501
|
});
|
|
5329
5502
|
log16("resetting...", void 0, {
|
|
5330
5503
|
F: __dxlog_file18,
|
|
5331
|
-
L:
|
|
5504
|
+
L: 343,
|
|
5332
5505
|
S: this,
|
|
5333
5506
|
C: (f, a) => f(...a)
|
|
5334
5507
|
});
|
|
@@ -5336,7 +5509,7 @@ var ClientServicesHost = class {
|
|
|
5336
5509
|
await this._storage.reset();
|
|
5337
5510
|
log16("reset", void 0, {
|
|
5338
5511
|
F: __dxlog_file18,
|
|
5339
|
-
L:
|
|
5512
|
+
L: 346,
|
|
5340
5513
|
S: this,
|
|
5341
5514
|
C: (f, a) => f(...a)
|
|
5342
5515
|
});
|
|
@@ -5344,7 +5517,7 @@ var ClientServicesHost = class {
|
|
|
5344
5517
|
id: traceId
|
|
5345
5518
|
}), {
|
|
5346
5519
|
F: __dxlog_file18,
|
|
5347
|
-
L:
|
|
5520
|
+
L: 347,
|
|
5348
5521
|
S: this,
|
|
5349
5522
|
C: (f, a) => f(...a)
|
|
5350
5523
|
});
|
|
@@ -5357,9 +5530,9 @@ var ClientServicesHost = class {
|
|
|
5357
5530
|
const obj = new Properties(void 0);
|
|
5358
5531
|
obj[defaultKey] = identity.identityKey.toHex();
|
|
5359
5532
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5360
|
-
|
|
5533
|
+
invariant16(automergeIndex, void 0, {
|
|
5361
5534
|
F: __dxlog_file18,
|
|
5362
|
-
L:
|
|
5535
|
+
L: 362,
|
|
5363
5536
|
S: this,
|
|
5364
5537
|
A: [
|
|
5365
5538
|
"automergeIndex",
|
|
@@ -5414,6 +5587,7 @@ export {
|
|
|
5414
5587
|
IdentityServiceImpl,
|
|
5415
5588
|
DeviceInvitationProtocol,
|
|
5416
5589
|
InvitationsHandler,
|
|
5590
|
+
invitationExpired,
|
|
5417
5591
|
InvitationsServiceImpl,
|
|
5418
5592
|
SpaceInvitationProtocol,
|
|
5419
5593
|
ClientRpcServer,
|
|
@@ -5429,4 +5603,4 @@ export {
|
|
|
5429
5603
|
createDefaultModelFactory,
|
|
5430
5604
|
ClientServicesHost
|
|
5431
5605
|
};
|
|
5432
|
-
//# sourceMappingURL=chunk-
|
|
5606
|
+
//# sourceMappingURL=chunk-XXUWZUVG.mjs.map
|