@dxos/client-services 0.4.7 → 0.4.8-main.ac78619
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-5DNT7O4B.mjs} +290 -130
- package/dist/lib/browser/chunk-5DNT7O4B.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-IIMBD24E.cjs} +264 -103
- package/dist/lib/node/chunk-IIMBD24E.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-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 +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/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/version.ts +1 -5
- package/dist/lib/browser/chunk-NI6XJLUJ.mjs.map +0 -7
- package/dist/lib/node/chunk-RH65IX2V.cjs.map +0 -7
|
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_IIMBD24E_exports = {};
|
|
30
|
+
__export(chunk_IIMBD24E_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
33
|
DataSpace: () => DataSpace,
|
|
@@ -51,6 +51,7 @@ __export(chunk_RH65IX2V_exports, {
|
|
|
51
51
|
createDiagnostics: () => createDiagnostics,
|
|
52
52
|
createStorageObjects: () => createStorageObjects,
|
|
53
53
|
getNetworkPeers: () => getNetworkPeers,
|
|
54
|
+
invitationExpired: () => invitationExpired,
|
|
54
55
|
isLocked: () => isLocked,
|
|
55
56
|
subscribeToFeedBlocks: () => subscribeToFeedBlocks,
|
|
56
57
|
subscribeToFeeds: () => subscribeToFeeds,
|
|
@@ -60,7 +61,7 @@ __export(chunk_RH65IX2V_exports, {
|
|
|
60
61
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
61
62
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
62
63
|
});
|
|
63
|
-
module.exports = __toCommonJS(
|
|
64
|
+
module.exports = __toCommonJS(chunk_IIMBD24E_exports);
|
|
64
65
|
var import_async = require("@dxos/async");
|
|
65
66
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
66
67
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -133,6 +134,7 @@ var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations")
|
|
|
133
134
|
var import_teleport = require("@dxos/teleport");
|
|
134
135
|
var import_async9 = require("@dxos/async");
|
|
135
136
|
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
137
|
+
var import_context6 = require("@dxos/context");
|
|
136
138
|
var import_invariant7 = require("@dxos/invariant");
|
|
137
139
|
var import_log6 = require("@dxos/log");
|
|
138
140
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
@@ -158,7 +160,7 @@ var import_tracing4 = require("@dxos/tracing");
|
|
|
158
160
|
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
159
161
|
var import_async10 = require("@dxos/async");
|
|
160
162
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
161
|
-
var
|
|
163
|
+
var import_context7 = require("@dxos/context");
|
|
162
164
|
var import_debug3 = require("@dxos/debug");
|
|
163
165
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
164
166
|
var import_invariant10 = require("@dxos/invariant");
|
|
@@ -172,7 +174,7 @@ var import_tracing5 = require("@dxos/tracing");
|
|
|
172
174
|
var import_util4 = require("@dxos/util");
|
|
173
175
|
var import_credentials11 = require("@dxos/credentials");
|
|
174
176
|
var import_async11 = require("@dxos/async");
|
|
175
|
-
var
|
|
177
|
+
var import_context8 = require("@dxos/context");
|
|
176
178
|
var import_invariant11 = require("@dxos/invariant");
|
|
177
179
|
var import_keys8 = require("@dxos/keys");
|
|
178
180
|
var import_log10 = require("@dxos/log");
|
|
@@ -180,7 +182,7 @@ var import_protocols9 = require("@dxos/protocols");
|
|
|
180
182
|
var import_teleport2 = require("@dxos/teleport");
|
|
181
183
|
var import_util5 = require("@dxos/util");
|
|
182
184
|
var import_async12 = require("@dxos/async");
|
|
183
|
-
var
|
|
185
|
+
var import_context9 = require("@dxos/context");
|
|
184
186
|
var import_credentials12 = require("@dxos/credentials");
|
|
185
187
|
var import_invariant12 = require("@dxos/invariant");
|
|
186
188
|
var import_keys9 = require("@dxos/keys");
|
|
@@ -201,7 +203,7 @@ var import_log12 = require("@dxos/log");
|
|
|
201
203
|
var import_protocols11 = require("@dxos/protocols");
|
|
202
204
|
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
203
205
|
var import_async14 = require("@dxos/async");
|
|
204
|
-
var
|
|
206
|
+
var import_context10 = require("@dxos/context");
|
|
205
207
|
var import_credentials15 = require("@dxos/credentials");
|
|
206
208
|
var import_debug6 = require("@dxos/debug");
|
|
207
209
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
@@ -226,7 +228,7 @@ var import_random_access_storage = require("@dxos/random-access-storage");
|
|
|
226
228
|
var import_util8 = require("@dxos/util");
|
|
227
229
|
var import_async15 = require("@dxos/async");
|
|
228
230
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
229
|
-
var
|
|
231
|
+
var import_context11 = require("@dxos/context");
|
|
230
232
|
var import_document_model2 = require("@dxos/document-model");
|
|
231
233
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
232
234
|
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
@@ -1230,7 +1232,7 @@ var IdentityManager = class {
|
|
|
1230
1232
|
identityKey: identityRecord.identityKey
|
|
1231
1233
|
});
|
|
1232
1234
|
await space.setControlFeed(controlFeed);
|
|
1233
|
-
|
|
1235
|
+
await space.setDataFeed(dataFeed);
|
|
1234
1236
|
const identity = new Identity({
|
|
1235
1237
|
space,
|
|
1236
1238
|
presence,
|
|
@@ -1788,11 +1790,11 @@ var InvitationsHandler = class {
|
|
|
1788
1790
|
this._networkManager = _networkManager;
|
|
1789
1791
|
}
|
|
1790
1792
|
createInvitation(protocol, options) {
|
|
1791
|
-
const { invitationId = import_keys5.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys5.PublicKey.random() } = options ?? {};
|
|
1793
|
+
const { invitationId = import_keys5.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys5.PublicKey.random(), persistent = true, created = /* @__PURE__ */ new Date(), lifetime = 86400 } = options ?? {};
|
|
1792
1794
|
const authCode = options?.authCode ?? (authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1793
1795
|
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
1794
1796
|
F: __dxlog_file7,
|
|
1795
|
-
L:
|
|
1797
|
+
L: 84,
|
|
1796
1798
|
S: this,
|
|
1797
1799
|
A: [
|
|
1798
1800
|
"protocol",
|
|
@@ -1807,13 +1809,16 @@ var InvitationsHandler = class {
|
|
|
1807
1809
|
swarmKey,
|
|
1808
1810
|
authCode,
|
|
1809
1811
|
timeout,
|
|
1812
|
+
persistent,
|
|
1813
|
+
created,
|
|
1814
|
+
lifetime,
|
|
1810
1815
|
...protocol.getInvitationContext()
|
|
1811
1816
|
};
|
|
1812
1817
|
const stream = new import_async7.PushStream();
|
|
1813
1818
|
const ctx = new import_context4.Context({
|
|
1814
1819
|
onError: (err) => {
|
|
1815
|
-
void ctx.dispose();
|
|
1816
1820
|
stream.error(err);
|
|
1821
|
+
void ctx.dispose();
|
|
1817
1822
|
}
|
|
1818
1823
|
});
|
|
1819
1824
|
ctx.onDispose(() => {
|
|
@@ -1821,7 +1826,7 @@ var InvitationsHandler = class {
|
|
|
1821
1826
|
...protocol.toJSON()
|
|
1822
1827
|
}, {
|
|
1823
1828
|
F: __dxlog_file7,
|
|
1824
|
-
L:
|
|
1829
|
+
L: 109,
|
|
1825
1830
|
S: this,
|
|
1826
1831
|
C: (f, a) => f(...a)
|
|
1827
1832
|
});
|
|
@@ -1846,7 +1851,7 @@ var InvitationsHandler = class {
|
|
|
1846
1851
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1847
1852
|
(0, import_invariant5.invariant)(deviceKey, void 0, {
|
|
1848
1853
|
F: __dxlog_file7,
|
|
1849
|
-
L:
|
|
1854
|
+
L: 130,
|
|
1850
1855
|
S: this,
|
|
1851
1856
|
A: [
|
|
1852
1857
|
"deviceKey",
|
|
@@ -1869,7 +1874,7 @@ var InvitationsHandler = class {
|
|
|
1869
1874
|
id: traceId
|
|
1870
1875
|
}), {
|
|
1871
1876
|
F: __dxlog_file7,
|
|
1872
|
-
L:
|
|
1877
|
+
L: 148,
|
|
1873
1878
|
S: this,
|
|
1874
1879
|
C: (f, a) => f(...a)
|
|
1875
1880
|
});
|
|
@@ -1877,7 +1882,7 @@ var InvitationsHandler = class {
|
|
|
1877
1882
|
...protocol.toJSON()
|
|
1878
1883
|
}, {
|
|
1879
1884
|
F: __dxlog_file7,
|
|
1880
|
-
L:
|
|
1885
|
+
L: 149,
|
|
1881
1886
|
S: this,
|
|
1882
1887
|
C: (f, a) => f(...a)
|
|
1883
1888
|
});
|
|
@@ -1893,7 +1898,7 @@ var InvitationsHandler = class {
|
|
|
1893
1898
|
...protocol.toJSON()
|
|
1894
1899
|
}, {
|
|
1895
1900
|
F: __dxlog_file7,
|
|
1896
|
-
L:
|
|
1901
|
+
L: 152,
|
|
1897
1902
|
S: this,
|
|
1898
1903
|
C: (f, a) => f(...a)
|
|
1899
1904
|
});
|
|
@@ -1905,7 +1910,7 @@ var InvitationsHandler = class {
|
|
|
1905
1910
|
id: traceId
|
|
1906
1911
|
}), {
|
|
1907
1912
|
F: __dxlog_file7,
|
|
1908
|
-
L:
|
|
1913
|
+
L: 154,
|
|
1909
1914
|
S: this,
|
|
1910
1915
|
C: (f, a) => f(...a)
|
|
1911
1916
|
});
|
|
@@ -1915,7 +1920,7 @@ var InvitationsHandler = class {
|
|
|
1915
1920
|
...protocol.toJSON()
|
|
1916
1921
|
}, {
|
|
1917
1922
|
F: __dxlog_file7,
|
|
1918
|
-
L:
|
|
1923
|
+
L: 157,
|
|
1919
1924
|
S: this,
|
|
1920
1925
|
C: (f, a) => f(...a)
|
|
1921
1926
|
});
|
|
@@ -1926,7 +1931,7 @@ var InvitationsHandler = class {
|
|
|
1926
1931
|
} else {
|
|
1927
1932
|
import_log4.log.error("failed", err, {
|
|
1928
1933
|
F: __dxlog_file7,
|
|
1929
|
-
L:
|
|
1934
|
+
L: 160,
|
|
1930
1935
|
S: this,
|
|
1931
1936
|
C: (f, a) => f(...a)
|
|
1932
1937
|
});
|
|
@@ -1937,7 +1942,7 @@ var InvitationsHandler = class {
|
|
|
1937
1942
|
error: err
|
|
1938
1943
|
}), {
|
|
1939
1944
|
F: __dxlog_file7,
|
|
1940
|
-
L:
|
|
1945
|
+
L: 163,
|
|
1941
1946
|
S: this,
|
|
1942
1947
|
C: (f, a) => f(...a)
|
|
1943
1948
|
});
|
|
@@ -1958,7 +1963,7 @@ var InvitationsHandler = class {
|
|
|
1958
1963
|
...protocol.toJSON()
|
|
1959
1964
|
}, {
|
|
1960
1965
|
F: __dxlog_file7,
|
|
1961
|
-
L:
|
|
1966
|
+
L: 178,
|
|
1962
1967
|
S: this,
|
|
1963
1968
|
C: (f, a) => f(...a)
|
|
1964
1969
|
});
|
|
@@ -1969,7 +1974,7 @@ var InvitationsHandler = class {
|
|
|
1969
1974
|
} else {
|
|
1970
1975
|
import_log4.log.error("failed", err, {
|
|
1971
1976
|
F: __dxlog_file7,
|
|
1972
|
-
L:
|
|
1977
|
+
L: 181,
|
|
1973
1978
|
S: this,
|
|
1974
1979
|
C: (f, a) => f(...a)
|
|
1975
1980
|
});
|
|
@@ -1979,7 +1984,27 @@ var InvitationsHandler = class {
|
|
|
1979
1984
|
});
|
|
1980
1985
|
return extension;
|
|
1981
1986
|
};
|
|
1987
|
+
if (invitation.lifetime && invitation.created && invitation.lifetime !== 0) {
|
|
1988
|
+
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
1989
|
+
import_log4.log.warn("invitation has already expired", void 0, {
|
|
1990
|
+
F: __dxlog_file7,
|
|
1991
|
+
L: 192,
|
|
1992
|
+
S: this,
|
|
1993
|
+
C: (f, a) => f(...a)
|
|
1994
|
+
});
|
|
1995
|
+
} else {
|
|
1996
|
+
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
1997
|
+
await swarmConnection.close();
|
|
1998
|
+
stream.next({
|
|
1999
|
+
...invitation,
|
|
2000
|
+
state: import_services3.Invitation.State.EXPIRED
|
|
2001
|
+
});
|
|
2002
|
+
await ctx.dispose();
|
|
2003
|
+
}, invitation.created.getTime() + invitation.lifetime * 1e3 - Date.now());
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
1982
2006
|
let swarmConnection;
|
|
2007
|
+
const invitationLabel = "invitation host for " + (invitation.kind === import_services3.Invitation.Kind.DEVICE ? "device" : `space ${invitation.spaceKey?.truncate()}`);
|
|
1983
2008
|
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
1984
2009
|
const topic = invitation.swarmKey;
|
|
1985
2010
|
swarmConnection = await this._networkManager.joinSwarm({
|
|
@@ -1989,7 +2014,7 @@ var InvitationsHandler = class {
|
|
|
1989
2014
|
teleport.addExtension("dxos.halo.invitations", createExtension());
|
|
1990
2015
|
}),
|
|
1991
2016
|
topology: new import_network_manager.StarTopology(topic),
|
|
1992
|
-
label:
|
|
2017
|
+
label: invitationLabel
|
|
1993
2018
|
});
|
|
1994
2019
|
ctx.onDispose(() => swarmConnection.close());
|
|
1995
2020
|
stream.next({
|
|
@@ -2014,7 +2039,7 @@ var InvitationsHandler = class {
|
|
|
2014
2039
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
2015
2040
|
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
2016
2041
|
F: __dxlog_file7,
|
|
2017
|
-
L:
|
|
2042
|
+
L: 246,
|
|
2018
2043
|
S: this,
|
|
2019
2044
|
A: [
|
|
2020
2045
|
"protocol",
|
|
@@ -2024,7 +2049,7 @@ var InvitationsHandler = class {
|
|
|
2024
2049
|
if (deviceProfile) {
|
|
2025
2050
|
(0, import_invariant5.invariant)(invitation.kind === import_services3.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2026
2051
|
F: __dxlog_file7,
|
|
2027
|
-
L:
|
|
2052
|
+
L: 250,
|
|
2028
2053
|
S: this,
|
|
2029
2054
|
A: [
|
|
2030
2055
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -2039,7 +2064,7 @@ var InvitationsHandler = class {
|
|
|
2039
2064
|
const setState = (newData) => {
|
|
2040
2065
|
(0, import_invariant5.invariant)(newData.state !== void 0, void 0, {
|
|
2041
2066
|
F: __dxlog_file7,
|
|
2042
|
-
L:
|
|
2067
|
+
L: 261,
|
|
2043
2068
|
S: this,
|
|
2044
2069
|
A: [
|
|
2045
2070
|
"newData.state !== undefined",
|
|
@@ -2059,7 +2084,7 @@ var InvitationsHandler = class {
|
|
|
2059
2084
|
...protocol.toJSON()
|
|
2060
2085
|
}, {
|
|
2061
2086
|
F: __dxlog_file7,
|
|
2062
|
-
L:
|
|
2087
|
+
L: 269,
|
|
2063
2088
|
S: this,
|
|
2064
2089
|
C: (f, a) => f(...a)
|
|
2065
2090
|
});
|
|
@@ -2069,7 +2094,7 @@ var InvitationsHandler = class {
|
|
|
2069
2094
|
} else {
|
|
2070
2095
|
import_log4.log.warn("auth failed", err, {
|
|
2071
2096
|
F: __dxlog_file7,
|
|
2072
|
-
L:
|
|
2097
|
+
L: 272,
|
|
2073
2098
|
S: this,
|
|
2074
2099
|
C: (f, a) => f(...a)
|
|
2075
2100
|
});
|
|
@@ -2083,7 +2108,7 @@ var InvitationsHandler = class {
|
|
|
2083
2108
|
...protocol.toJSON()
|
|
2084
2109
|
}, {
|
|
2085
2110
|
F: __dxlog_file7,
|
|
2086
|
-
L:
|
|
2111
|
+
L: 280,
|
|
2087
2112
|
S: this,
|
|
2088
2113
|
C: (f, a) => f(...a)
|
|
2089
2114
|
});
|
|
@@ -2098,7 +2123,7 @@ var InvitationsHandler = class {
|
|
|
2098
2123
|
currentState
|
|
2099
2124
|
}, {
|
|
2100
2125
|
F: __dxlog_file7,
|
|
2101
|
-
L:
|
|
2126
|
+
L: 290,
|
|
2102
2127
|
S: this,
|
|
2103
2128
|
C: (f, a) => f(...a)
|
|
2104
2129
|
});
|
|
@@ -2113,7 +2138,7 @@ var InvitationsHandler = class {
|
|
|
2113
2138
|
id: traceId
|
|
2114
2139
|
}), {
|
|
2115
2140
|
F: __dxlog_file7,
|
|
2116
|
-
L:
|
|
2141
|
+
L: 299,
|
|
2117
2142
|
S: this,
|
|
2118
2143
|
C: (f, a) => f(...a)
|
|
2119
2144
|
});
|
|
@@ -2125,7 +2150,7 @@ var InvitationsHandler = class {
|
|
|
2125
2150
|
...protocol.toJSON()
|
|
2126
2151
|
}, {
|
|
2127
2152
|
F: __dxlog_file7,
|
|
2128
|
-
L:
|
|
2153
|
+
L: 307,
|
|
2129
2154
|
S: this,
|
|
2130
2155
|
C: (f, a) => f(...a)
|
|
2131
2156
|
});
|
|
@@ -2136,7 +2161,7 @@ var InvitationsHandler = class {
|
|
|
2136
2161
|
...protocol.toJSON()
|
|
2137
2162
|
}, {
|
|
2138
2163
|
F: __dxlog_file7,
|
|
2139
|
-
L:
|
|
2164
|
+
L: 311,
|
|
2140
2165
|
S: this,
|
|
2141
2166
|
C: (f, a) => f(...a)
|
|
2142
2167
|
});
|
|
@@ -2146,7 +2171,7 @@ var InvitationsHandler = class {
|
|
|
2146
2171
|
response: introductionResponse
|
|
2147
2172
|
}, {
|
|
2148
2173
|
F: __dxlog_file7,
|
|
2149
|
-
L:
|
|
2174
|
+
L: 315,
|
|
2150
2175
|
S: this,
|
|
2151
2176
|
C: (f, a) => f(...a)
|
|
2152
2177
|
});
|
|
@@ -2155,7 +2180,7 @@ var InvitationsHandler = class {
|
|
|
2155
2180
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2156
2181
|
(0, import_log4.log)("guest waiting for authentication code...", void 0, {
|
|
2157
2182
|
F: __dxlog_file7,
|
|
2158
|
-
L:
|
|
2183
|
+
L: 321,
|
|
2159
2184
|
S: this,
|
|
2160
2185
|
C: (f, a) => f(...a)
|
|
2161
2186
|
});
|
|
@@ -2167,7 +2192,7 @@ var InvitationsHandler = class {
|
|
|
2167
2192
|
});
|
|
2168
2193
|
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2169
2194
|
F: __dxlog_file7,
|
|
2170
|
-
L:
|
|
2195
|
+
L: 325,
|
|
2171
2196
|
S: this,
|
|
2172
2197
|
C: (f, a) => f(...a)
|
|
2173
2198
|
});
|
|
@@ -2188,7 +2213,7 @@ var InvitationsHandler = class {
|
|
|
2188
2213
|
attempt
|
|
2189
2214
|
}, {
|
|
2190
2215
|
F: __dxlog_file7,
|
|
2191
|
-
L:
|
|
2216
|
+
L: 336,
|
|
2192
2217
|
S: this,
|
|
2193
2218
|
C: (f, a) => f(...a)
|
|
2194
2219
|
});
|
|
@@ -2201,7 +2226,7 @@ var InvitationsHandler = class {
|
|
|
2201
2226
|
...protocol.toJSON()
|
|
2202
2227
|
}, {
|
|
2203
2228
|
F: __dxlog_file7,
|
|
2204
|
-
L:
|
|
2229
|
+
L: 344,
|
|
2205
2230
|
S: this,
|
|
2206
2231
|
C: (f, a) => f(...a)
|
|
2207
2232
|
});
|
|
@@ -2213,7 +2238,7 @@ var InvitationsHandler = class {
|
|
|
2213
2238
|
...protocol.toJSON()
|
|
2214
2239
|
}, {
|
|
2215
2240
|
F: __dxlog_file7,
|
|
2216
|
-
L:
|
|
2241
|
+
L: 355,
|
|
2217
2242
|
S: this,
|
|
2218
2243
|
C: (f, a) => f(...a)
|
|
2219
2244
|
});
|
|
@@ -2226,7 +2251,7 @@ var InvitationsHandler = class {
|
|
|
2226
2251
|
id: traceId
|
|
2227
2252
|
}), {
|
|
2228
2253
|
F: __dxlog_file7,
|
|
2229
|
-
L:
|
|
2254
|
+
L: 357,
|
|
2230
2255
|
S: this,
|
|
2231
2256
|
C: (f, a) => f(...a)
|
|
2232
2257
|
});
|
|
@@ -2236,7 +2261,7 @@ var InvitationsHandler = class {
|
|
|
2236
2261
|
...protocol.toJSON()
|
|
2237
2262
|
}, {
|
|
2238
2263
|
F: __dxlog_file7,
|
|
2239
|
-
L:
|
|
2264
|
+
L: 360,
|
|
2240
2265
|
S: this,
|
|
2241
2266
|
C: (f, a) => f(...a)
|
|
2242
2267
|
});
|
|
@@ -2246,7 +2271,7 @@ var InvitationsHandler = class {
|
|
|
2246
2271
|
} else {
|
|
2247
2272
|
(0, import_log4.log)("auth failed", err, {
|
|
2248
2273
|
F: __dxlog_file7,
|
|
2249
|
-
L:
|
|
2274
|
+
L: 363,
|
|
2250
2275
|
S: this,
|
|
2251
2276
|
C: (f, a) => f(...a)
|
|
2252
2277
|
});
|
|
@@ -2257,7 +2282,7 @@ var InvitationsHandler = class {
|
|
|
2257
2282
|
error: err
|
|
2258
2283
|
}), {
|
|
2259
2284
|
F: __dxlog_file7,
|
|
2260
|
-
L:
|
|
2285
|
+
L: 366,
|
|
2261
2286
|
S: this,
|
|
2262
2287
|
C: (f, a) => f(...a)
|
|
2263
2288
|
});
|
|
@@ -2275,7 +2300,7 @@ var InvitationsHandler = class {
|
|
|
2275
2300
|
...protocol.toJSON()
|
|
2276
2301
|
}, {
|
|
2277
2302
|
F: __dxlog_file7,
|
|
2278
|
-
L:
|
|
2303
|
+
L: 377,
|
|
2279
2304
|
S: this,
|
|
2280
2305
|
C: (f, a) => f(...a)
|
|
2281
2306
|
});
|
|
@@ -2285,7 +2310,7 @@ var InvitationsHandler = class {
|
|
|
2285
2310
|
} else {
|
|
2286
2311
|
(0, import_log4.log)("auth failed", err, {
|
|
2287
2312
|
F: __dxlog_file7,
|
|
2288
|
-
L:
|
|
2313
|
+
L: 380,
|
|
2289
2314
|
S: this,
|
|
2290
2315
|
C: (f, a) => f(...a)
|
|
2291
2316
|
});
|
|
@@ -2302,7 +2327,7 @@ var InvitationsHandler = class {
|
|
|
2302
2327
|
} else {
|
|
2303
2328
|
(0, import_invariant5.invariant)(invitation.swarmKey, void 0, {
|
|
2304
2329
|
F: __dxlog_file7,
|
|
2305
|
-
L:
|
|
2330
|
+
L: 394,
|
|
2306
2331
|
S: this,
|
|
2307
2332
|
A: [
|
|
2308
2333
|
"invitation.swarmKey",
|
|
@@ -2341,17 +2366,24 @@ var InvitationsHandler = class {
|
|
|
2341
2366
|
return observable;
|
|
2342
2367
|
}
|
|
2343
2368
|
};
|
|
2369
|
+
var invitationExpired = (invitation) => {
|
|
2370
|
+
return invitation.created && invitation.lifetime && invitation.lifetime !== 0 && invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now();
|
|
2371
|
+
};
|
|
2344
2372
|
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
2345
2373
|
var InvitationsServiceImpl = class {
|
|
2346
|
-
constructor(_invitationsHandler, _getHandler) {
|
|
2374
|
+
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
2347
2375
|
this._invitationsHandler = _invitationsHandler;
|
|
2348
2376
|
this._getHandler = _getHandler;
|
|
2377
|
+
this._metadataStore = _metadataStore;
|
|
2349
2378
|
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2350
2379
|
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2351
2380
|
this._invitationCreated = new import_async9.Event();
|
|
2352
2381
|
this._invitationAccepted = new import_async9.Event();
|
|
2353
2382
|
this._removedCreated = new import_async9.Event();
|
|
2354
2383
|
this._removedAccepted = new import_async9.Event();
|
|
2384
|
+
this._saved = new import_async9.Event();
|
|
2385
|
+
this._persistentInvitationsLoadedEvent = new import_async9.Event();
|
|
2386
|
+
this._persistentInvitationsLoaded = false;
|
|
2355
2387
|
}
|
|
2356
2388
|
// TODO(burdon): Guest/host label.
|
|
2357
2389
|
getLoggingContext() {
|
|
@@ -2359,6 +2391,7 @@ var InvitationsServiceImpl = class {
|
|
|
2359
2391
|
}
|
|
2360
2392
|
createInvitation(options) {
|
|
2361
2393
|
let invitation;
|
|
2394
|
+
const savePersistentInvitationCtx = new import_context6.Context();
|
|
2362
2395
|
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2363
2396
|
if (existingInvitation) {
|
|
2364
2397
|
invitation = existingInvitation;
|
|
@@ -2369,12 +2402,27 @@ var InvitationsServiceImpl = class {
|
|
|
2369
2402
|
this._invitationCreated.emit(invitation.get());
|
|
2370
2403
|
}
|
|
2371
2404
|
return new import_codec_protobuf8.Stream(({ next, close }) => {
|
|
2405
|
+
if (invitation.get().persistent) {
|
|
2406
|
+
(0, import_async9.scheduleTask)(savePersistentInvitationCtx, async () => {
|
|
2407
|
+
try {
|
|
2408
|
+
await this._metadataStore.addInvitation(invitation.get());
|
|
2409
|
+
this._saved.emit(invitation.get());
|
|
2410
|
+
} catch (err) {
|
|
2411
|
+
close(err);
|
|
2412
|
+
}
|
|
2413
|
+
});
|
|
2414
|
+
}
|
|
2372
2415
|
invitation.subscribe((invitation2) => {
|
|
2373
2416
|
next(invitation2);
|
|
2374
|
-
}, (err) => {
|
|
2417
|
+
}, async (err) => {
|
|
2418
|
+
await savePersistentInvitationCtx.dispose();
|
|
2375
2419
|
close(err);
|
|
2376
|
-
}, () => {
|
|
2420
|
+
}, async () => {
|
|
2377
2421
|
close();
|
|
2422
|
+
if (invitation.get().persistent) {
|
|
2423
|
+
await savePersistentInvitationCtx.dispose();
|
|
2424
|
+
await this._metadataStore.removeInvitation(invitation.get().invitationId);
|
|
2425
|
+
}
|
|
2378
2426
|
this._createInvitations.delete(invitation.get().invitationId);
|
|
2379
2427
|
if (invitation.get().type !== import_services5.Invitation.Type.MULTIUSE) {
|
|
2380
2428
|
this._removedCreated.emit(invitation.get());
|
|
@@ -2382,12 +2430,37 @@ var InvitationsServiceImpl = class {
|
|
|
2382
2430
|
});
|
|
2383
2431
|
});
|
|
2384
2432
|
}
|
|
2433
|
+
async loadPersistentInvitations() {
|
|
2434
|
+
const persistentInvitations = this._metadataStore.getInvitations();
|
|
2435
|
+
const freshInvitations = persistentInvitations.filter(async (invitation) => !invitationExpired(invitation));
|
|
2436
|
+
const cInvitations = freshInvitations.map((persistentInvitation) => {
|
|
2437
|
+
(0, import_invariant7.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2438
|
+
F: __dxlog_file8,
|
|
2439
|
+
L: 109,
|
|
2440
|
+
S: this,
|
|
2441
|
+
A: [
|
|
2442
|
+
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2443
|
+
"'invitation already exists'"
|
|
2444
|
+
]
|
|
2445
|
+
});
|
|
2446
|
+
const handler = this._getHandler(persistentInvitation);
|
|
2447
|
+
const invitation = this._invitationsHandler.createInvitation(handler, persistentInvitation);
|
|
2448
|
+
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2449
|
+
this._invitationCreated.emit(invitation.get());
|
|
2450
|
+
return persistentInvitation;
|
|
2451
|
+
});
|
|
2452
|
+
this._persistentInvitationsLoadedEvent.emit();
|
|
2453
|
+
this._persistentInvitationsLoaded = true;
|
|
2454
|
+
return {
|
|
2455
|
+
invitations: cInvitations
|
|
2456
|
+
};
|
|
2457
|
+
}
|
|
2385
2458
|
acceptInvitation({ invitation: options, deviceProfile }) {
|
|
2386
2459
|
let invitation;
|
|
2387
2460
|
if (deviceProfile) {
|
|
2388
2461
|
(0, import_invariant7.invariant)(options.kind === import_services5.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2389
2462
|
F: __dxlog_file8,
|
|
2390
|
-
L:
|
|
2463
|
+
L: 127,
|
|
2391
2464
|
S: this,
|
|
2392
2465
|
A: [
|
|
2393
2466
|
"options.kind === Invitation.Kind.DEVICE",
|
|
@@ -2421,13 +2494,13 @@ var InvitationsServiceImpl = class {
|
|
|
2421
2494
|
async authenticate({ invitationId, authCode }) {
|
|
2422
2495
|
(0, import_log6.log)("authenticating...", void 0, {
|
|
2423
2496
|
F: __dxlog_file8,
|
|
2424
|
-
L:
|
|
2497
|
+
L: 160,
|
|
2425
2498
|
S: this,
|
|
2426
2499
|
C: (f, a) => f(...a)
|
|
2427
2500
|
});
|
|
2428
2501
|
(0, import_invariant7.invariant)(invitationId, void 0, {
|
|
2429
2502
|
F: __dxlog_file8,
|
|
2430
|
-
L:
|
|
2503
|
+
L: 161,
|
|
2431
2504
|
S: this,
|
|
2432
2505
|
A: [
|
|
2433
2506
|
"invitationId",
|
|
@@ -2440,7 +2513,7 @@ var InvitationsServiceImpl = class {
|
|
|
2440
2513
|
invitationId
|
|
2441
2514
|
}, {
|
|
2442
2515
|
F: __dxlog_file8,
|
|
2443
|
-
L:
|
|
2516
|
+
L: 164,
|
|
2444
2517
|
S: this,
|
|
2445
2518
|
C: (f, a) => f(...a)
|
|
2446
2519
|
});
|
|
@@ -2449,15 +2522,17 @@ var InvitationsServiceImpl = class {
|
|
|
2449
2522
|
}
|
|
2450
2523
|
}
|
|
2451
2524
|
async cancelInvitation({ invitationId }) {
|
|
2452
|
-
(0, import_log6.log)("
|
|
2525
|
+
(0, import_log6.log)("cancelInvitation...", {
|
|
2526
|
+
invitationId
|
|
2527
|
+
}, {
|
|
2453
2528
|
F: __dxlog_file8,
|
|
2454
|
-
L:
|
|
2529
|
+
L: 171,
|
|
2455
2530
|
S: this,
|
|
2456
2531
|
C: (f, a) => f(...a)
|
|
2457
2532
|
});
|
|
2458
2533
|
(0, import_invariant7.invariant)(invitationId, void 0, {
|
|
2459
2534
|
F: __dxlog_file8,
|
|
2460
|
-
L:
|
|
2535
|
+
L: 172,
|
|
2461
2536
|
S: this,
|
|
2462
2537
|
A: [
|
|
2463
2538
|
"invitationId",
|
|
@@ -2470,6 +2545,9 @@ var InvitationsServiceImpl = class {
|
|
|
2470
2545
|
await created.cancel();
|
|
2471
2546
|
this._createInvitations.delete(invitationId);
|
|
2472
2547
|
this._removedCreated.emit(created.get());
|
|
2548
|
+
if (created.get().persistent) {
|
|
2549
|
+
await this._metadataStore.removeInvitation(created.get().invitationId);
|
|
2550
|
+
}
|
|
2473
2551
|
} else if (accepted) {
|
|
2474
2552
|
await accepted.cancel();
|
|
2475
2553
|
this._acceptInvitations.delete(invitationId);
|
|
@@ -2514,16 +2592,40 @@ var InvitationsServiceImpl = class {
|
|
|
2514
2592
|
]
|
|
2515
2593
|
});
|
|
2516
2594
|
});
|
|
2595
|
+
this._saved.on(ctx, (invitation) => {
|
|
2596
|
+
next({
|
|
2597
|
+
action: import_services5.QueryInvitationsResponse.Action.SAVED,
|
|
2598
|
+
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
2599
|
+
invitations: [
|
|
2600
|
+
invitation
|
|
2601
|
+
]
|
|
2602
|
+
});
|
|
2603
|
+
});
|
|
2517
2604
|
next({
|
|
2518
2605
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2519
2606
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
2520
|
-
invitations: Array.from(this._createInvitations.values()).map((invitation) => invitation.get())
|
|
2607
|
+
invitations: Array.from(this._createInvitations.values()).map((invitation) => invitation.get()),
|
|
2608
|
+
existing: true
|
|
2521
2609
|
});
|
|
2522
2610
|
next({
|
|
2523
2611
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2524
2612
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
2525
|
-
invitations: Array.from(this._acceptInvitations.values()).map((invitation) => invitation.get())
|
|
2613
|
+
invitations: Array.from(this._acceptInvitations.values()).map((invitation) => invitation.get()),
|
|
2614
|
+
existing: true
|
|
2526
2615
|
});
|
|
2616
|
+
if (this._persistentInvitationsLoaded) {
|
|
2617
|
+
next({
|
|
2618
|
+
action: import_services5.QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2619
|
+
type: import_services5.QueryInvitationsResponse.Type.CREATED
|
|
2620
|
+
});
|
|
2621
|
+
} else {
|
|
2622
|
+
this._persistentInvitationsLoadedEvent.on(ctx, () => {
|
|
2623
|
+
next({
|
|
2624
|
+
action: import_services5.QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2625
|
+
type: import_services5.QueryInvitationsResponse.Type.CREATED
|
|
2626
|
+
});
|
|
2627
|
+
});
|
|
2628
|
+
}
|
|
2527
2629
|
});
|
|
2528
2630
|
}
|
|
2529
2631
|
};
|
|
@@ -2784,7 +2886,7 @@ var getPlatform = () => {
|
|
|
2784
2886
|
};
|
|
2785
2887
|
}
|
|
2786
2888
|
};
|
|
2787
|
-
var DXOS_VERSION = "0.4.
|
|
2889
|
+
var DXOS_VERSION = "0.4.8-main.ac78619";
|
|
2788
2890
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
2789
2891
|
var DEFAULT_TIMEOUT = 1e3;
|
|
2790
2892
|
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
@@ -2927,6 +3029,7 @@ var AutomergeSpaceState = class {
|
|
|
2927
3029
|
this._onNewRoot = _onNewRoot;
|
|
2928
3030
|
this.rootUrl = void 0;
|
|
2929
3031
|
this.lastEpoch = void 0;
|
|
3032
|
+
this._isProcessingRootDocs = false;
|
|
2930
3033
|
}
|
|
2931
3034
|
async processCredential(credential) {
|
|
2932
3035
|
if (!(0, import_credentials11.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
@@ -2935,8 +3038,19 @@ var AutomergeSpaceState = class {
|
|
|
2935
3038
|
this.lastEpoch = credential;
|
|
2936
3039
|
if (credential.subject.assertion.automergeRoot) {
|
|
2937
3040
|
this.rootUrl = credential.subject.assertion.automergeRoot;
|
|
3041
|
+
if (this._isProcessingRootDocs) {
|
|
3042
|
+
this._onNewRoot(this.rootUrl);
|
|
3043
|
+
}
|
|
3044
|
+
}
|
|
3045
|
+
}
|
|
3046
|
+
startProcessingRootDocs() {
|
|
3047
|
+
if (this._isProcessingRootDocs) {
|
|
3048
|
+
return;
|
|
3049
|
+
}
|
|
3050
|
+
if (this.rootUrl) {
|
|
2938
3051
|
this._onNewRoot(this.rootUrl);
|
|
2939
3052
|
}
|
|
3053
|
+
this._isProcessingRootDocs = true;
|
|
2940
3054
|
}
|
|
2941
3055
|
};
|
|
2942
3056
|
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
@@ -2946,7 +3060,7 @@ var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
|
2946
3060
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
2947
3061
|
var NotarizationPlugin = class {
|
|
2948
3062
|
constructor() {
|
|
2949
|
-
this._ctx = new
|
|
3063
|
+
this._ctx = new import_context8.Context();
|
|
2950
3064
|
this._extensionOpened = new import_async11.Event();
|
|
2951
3065
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2952
3066
|
this._processedCredentials = new import_util5.ComplexSet(import_keys8.PublicKey.hash);
|
|
@@ -3071,7 +3185,7 @@ var NotarizationPlugin = class {
|
|
|
3071
3185
|
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
3072
3186
|
try {
|
|
3073
3187
|
await Promise.race([
|
|
3074
|
-
(0,
|
|
3188
|
+
(0, import_context8.rejectOnDispose)(ctx),
|
|
3075
3189
|
allNotarized,
|
|
3076
3190
|
errors.wait()
|
|
3077
3191
|
]);
|
|
@@ -3211,7 +3325,7 @@ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
|
|
|
3211
3325
|
var ENABLE_FEED_PURGE = false;
|
|
3212
3326
|
var DataSpace = class {
|
|
3213
3327
|
constructor(params) {
|
|
3214
|
-
this._ctx = new
|
|
3328
|
+
this._ctx = new import_context7.Context();
|
|
3215
3329
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3216
3330
|
this._cache = void 0;
|
|
3217
3331
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
@@ -3287,7 +3401,7 @@ var DataSpace = class {
|
|
|
3287
3401
|
await this._notarizationPlugin.open();
|
|
3288
3402
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3289
3403
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3290
|
-
await this._inner.open(new
|
|
3404
|
+
await this._inner.open(new import_context7.Context());
|
|
3291
3405
|
this._state = import_services9.SpaceState.CONTROL_ONLY;
|
|
3292
3406
|
(0, import_log9.log)("new state", {
|
|
3293
3407
|
state: import_services9.SpaceState[this._state]
|
|
@@ -3316,7 +3430,7 @@ var DataSpace = class {
|
|
|
3316
3430
|
C: (f, a) => f(...a)
|
|
3317
3431
|
});
|
|
3318
3432
|
await this._ctx.dispose();
|
|
3319
|
-
this._ctx = new
|
|
3433
|
+
this._ctx = new import_context7.Context();
|
|
3320
3434
|
await this.authVerifier.close();
|
|
3321
3435
|
await this._inner.close();
|
|
3322
3436
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
@@ -3340,7 +3454,7 @@ var DataSpace = class {
|
|
|
3340
3454
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3341
3455
|
await this.initializeDataPipeline();
|
|
3342
3456
|
} catch (err) {
|
|
3343
|
-
if (err instanceof import_protocols8.CancelledError || err instanceof
|
|
3457
|
+
if (err instanceof import_protocols8.CancelledError || err instanceof import_context7.ContextDisposedError) {
|
|
3344
3458
|
(0, import_log9.log)("data pipeline initialization cancelled", err, {
|
|
3345
3459
|
F: __dxlog_file12,
|
|
3346
3460
|
L: 250,
|
|
@@ -3386,12 +3500,13 @@ var DataSpace = class {
|
|
|
3386
3500
|
});
|
|
3387
3501
|
await this._initializeAndReadControlPipeline();
|
|
3388
3502
|
await (0, import_async10.sleep)(1);
|
|
3503
|
+
this._automergeSpaceState.startProcessingRootDocs();
|
|
3389
3504
|
await this._inner.initializeDataPipeline();
|
|
3390
3505
|
this.metrics.dataPipelineOpen = /* @__PURE__ */ new Date();
|
|
3391
|
-
await (0,
|
|
3506
|
+
await (0, import_context7.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
3392
3507
|
(0, import_log9.log)("waiting for data pipeline to reach target timeframe", void 0, {
|
|
3393
3508
|
F: __dxlog_file12,
|
|
3394
|
-
L:
|
|
3509
|
+
L: 288,
|
|
3395
3510
|
S: this,
|
|
3396
3511
|
C: (f, a) => f(...a)
|
|
3397
3512
|
});
|
|
@@ -3402,7 +3517,7 @@ var DataSpace = class {
|
|
|
3402
3517
|
this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
|
|
3403
3518
|
(0, import_log9.log)("data pipeline ready", void 0, {
|
|
3404
3519
|
F: __dxlog_file12,
|
|
3405
|
-
L:
|
|
3520
|
+
L: 296,
|
|
3406
3521
|
S: this,
|
|
3407
3522
|
C: (f, a) => f(...a)
|
|
3408
3523
|
});
|
|
@@ -3412,7 +3527,7 @@ var DataSpace = class {
|
|
|
3412
3527
|
state: import_services9.SpaceState[this._state]
|
|
3413
3528
|
}, {
|
|
3414
3529
|
F: __dxlog_file12,
|
|
3415
|
-
L:
|
|
3530
|
+
L: 300,
|
|
3416
3531
|
S: this,
|
|
3417
3532
|
C: (f, a) => f(...a)
|
|
3418
3533
|
});
|
|
@@ -3428,7 +3543,7 @@ var DataSpace = class {
|
|
|
3428
3543
|
await this._createWritableFeeds();
|
|
3429
3544
|
(0, import_log9.log)("writable feeds created", void 0, {
|
|
3430
3545
|
F: __dxlog_file12,
|
|
3431
|
-
L:
|
|
3546
|
+
L: 316,
|
|
3432
3547
|
S: this,
|
|
3433
3548
|
C: (f, a) => f(...a)
|
|
3434
3549
|
});
|
|
@@ -3491,7 +3606,7 @@ var DataSpace = class {
|
|
|
3491
3606
|
rootUrl
|
|
3492
3607
|
}, {
|
|
3493
3608
|
F: __dxlog_file12,
|
|
3494
|
-
L:
|
|
3609
|
+
L: 382,
|
|
3495
3610
|
S: this,
|
|
3496
3611
|
C: (f, a) => f(...a)
|
|
3497
3612
|
});
|
|
@@ -3500,7 +3615,7 @@ var DataSpace = class {
|
|
|
3500
3615
|
queueMicrotask(async () => {
|
|
3501
3616
|
try {
|
|
3502
3617
|
await (0, import_debug3.warnAfterTimeout)(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
3503
|
-
await (0,
|
|
3618
|
+
await (0, import_context7.cancelWithContext)(this._ctx, handle.whenReady());
|
|
3504
3619
|
});
|
|
3505
3620
|
if (this._ctx.disposed) {
|
|
3506
3621
|
return;
|
|
@@ -3514,7 +3629,7 @@ var DataSpace = class {
|
|
|
3514
3629
|
});
|
|
3515
3630
|
}
|
|
3516
3631
|
} catch (err) {
|
|
3517
|
-
if (err instanceof
|
|
3632
|
+
if (err instanceof import_context7.ContextDisposedError) {
|
|
3518
3633
|
return;
|
|
3519
3634
|
}
|
|
3520
3635
|
import_log9.log.warn("error loading automerge root doc", {
|
|
@@ -3523,7 +3638,7 @@ var DataSpace = class {
|
|
|
3523
3638
|
err
|
|
3524
3639
|
}, {
|
|
3525
3640
|
F: __dxlog_file12,
|
|
3526
|
-
L:
|
|
3641
|
+
L: 405,
|
|
3527
3642
|
S: this,
|
|
3528
3643
|
C: (f, a) => f(...a)
|
|
3529
3644
|
});
|
|
@@ -3554,15 +3669,40 @@ var DataSpace = class {
|
|
|
3554
3669
|
epoch = await this.dataPipeline.createEpoch();
|
|
3555
3670
|
}
|
|
3556
3671
|
break;
|
|
3557
|
-
case import_services9.CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3672
|
+
case import_services9.CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3673
|
+
{
|
|
3674
|
+
const document = this._automergeHost.repo.create();
|
|
3675
|
+
epoch = {
|
|
3676
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3677
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
3678
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe2.Timeframe(),
|
|
3679
|
+
automergeRoot: document.url
|
|
3680
|
+
};
|
|
3681
|
+
}
|
|
3682
|
+
break;
|
|
3683
|
+
case import_services9.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
3684
|
+
{
|
|
3685
|
+
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3686
|
+
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3687
|
+
await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3688
|
+
const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
|
|
3689
|
+
(0, import_invariant10.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3690
|
+
F: __dxlog_file12,
|
|
3691
|
+
L: 450,
|
|
3692
|
+
S: this,
|
|
3693
|
+
A: [
|
|
3694
|
+
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3695
|
+
""
|
|
3696
|
+
]
|
|
3697
|
+
});
|
|
3698
|
+
epoch = {
|
|
3699
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3700
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
3701
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe2.Timeframe(),
|
|
3702
|
+
automergeRoot: newRoot.url
|
|
3703
|
+
};
|
|
3704
|
+
}
|
|
3705
|
+
break;
|
|
3566
3706
|
}
|
|
3567
3707
|
if (!epoch) {
|
|
3568
3708
|
return;
|
|
@@ -3613,7 +3753,7 @@ var DataSpace = class {
|
|
|
3613
3753
|
state: import_services9.SpaceState[this._state]
|
|
3614
3754
|
}, {
|
|
3615
3755
|
F: __dxlog_file12,
|
|
3616
|
-
L:
|
|
3756
|
+
L: 514,
|
|
3617
3757
|
S: this,
|
|
3618
3758
|
C: (f, a) => f(...a)
|
|
3619
3759
|
});
|
|
@@ -3751,7 +3891,7 @@ var DataSpaceManager = class {
|
|
|
3751
3891
|
this._signingContext = _signingContext;
|
|
3752
3892
|
this._feedStore = _feedStore;
|
|
3753
3893
|
this._automergeHost = _automergeHost;
|
|
3754
|
-
this._ctx = new
|
|
3894
|
+
this._ctx = new import_context9.Context();
|
|
3755
3895
|
this.updated = new import_async12.Event();
|
|
3756
3896
|
this._spaces = new import_util6.ComplexMap(import_keys9.PublicKey.hash);
|
|
3757
3897
|
this._isOpen = false;
|
|
@@ -3940,7 +4080,7 @@ var DataSpaceManager = class {
|
|
|
3940
4080
|
* TODO(dmaretskyi): Consider removing.
|
|
3941
4081
|
*/
|
|
3942
4082
|
async waitUntilSpaceReady(spaceKey) {
|
|
3943
|
-
await (0,
|
|
4083
|
+
await (0, import_context9.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
3944
4084
|
const space = this._spaces.get(spaceKey);
|
|
3945
4085
|
return !!space && space.state === import_services10.SpaceState.READY;
|
|
3946
4086
|
}));
|
|
@@ -4240,10 +4380,12 @@ var SpacesServiceImpl = class {
|
|
|
4240
4380
|
}
|
|
4241
4381
|
}
|
|
4242
4382
|
}
|
|
4243
|
-
async createEpoch({ spaceKey }) {
|
|
4383
|
+
async createEpoch({ spaceKey, migration }) {
|
|
4244
4384
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4245
4385
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
|
|
4246
|
-
await space.createEpoch(
|
|
4386
|
+
await space.createEpoch({
|
|
4387
|
+
migration
|
|
4388
|
+
});
|
|
4247
4389
|
}
|
|
4248
4390
|
_serializeSpace(space) {
|
|
4249
4391
|
return {
|
|
@@ -4407,7 +4549,7 @@ var ServiceContext = class {
|
|
|
4407
4549
|
}
|
|
4408
4550
|
async createIdentity(params = {}) {
|
|
4409
4551
|
const identity = await this.identityManager.createIdentity(params);
|
|
4410
|
-
await this._initialize(new
|
|
4552
|
+
await this._initialize(new import_context10.Context());
|
|
4411
4553
|
return identity;
|
|
4412
4554
|
}
|
|
4413
4555
|
getInvitationHandler(invitation) {
|
|
@@ -4433,7 +4575,7 @@ var ServiceContext = class {
|
|
|
4433
4575
|
}
|
|
4434
4576
|
async _acceptIdentity(params) {
|
|
4435
4577
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
4436
|
-
await this._initialize(new
|
|
4578
|
+
await this._initialize(new import_context10.Context());
|
|
4437
4579
|
return identity;
|
|
4438
4580
|
}
|
|
4439
4581
|
async _checkStorageVersion() {
|
|
@@ -4984,7 +5126,7 @@ var ClientServicesHost = class {
|
|
|
4984
5126
|
lockKey,
|
|
4985
5127
|
onAcquire: () => {
|
|
4986
5128
|
if (!this._opening) {
|
|
4987
|
-
void this.open(new
|
|
5129
|
+
void this.open(new import_context11.Context());
|
|
4988
5130
|
}
|
|
4989
5131
|
},
|
|
4990
5132
|
onRelease: () => this.close()
|
|
@@ -5157,7 +5299,7 @@ var ClientServicesHost = class {
|
|
|
5157
5299
|
this._serviceRegistry.setServices({
|
|
5158
5300
|
SystemService: this._systemService,
|
|
5159
5301
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
5160
|
-
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
|
|
5302
|
+
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation), this._serviceContext.metadataStore),
|
|
5161
5303
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
5162
5304
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
5163
5305
|
await this._serviceContext.initialized.wait();
|
|
@@ -5175,6 +5317,24 @@ var ClientServicesHost = class {
|
|
|
5175
5317
|
})
|
|
5176
5318
|
});
|
|
5177
5319
|
await this._serviceContext.open(ctx);
|
|
5320
|
+
(0, import_invariant16.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5321
|
+
F: __dxlog_file18,
|
|
5322
|
+
L: 297,
|
|
5323
|
+
S: this,
|
|
5324
|
+
A: [
|
|
5325
|
+
"this.serviceRegistry.services.InvitationsService",
|
|
5326
|
+
""
|
|
5327
|
+
]
|
|
5328
|
+
});
|
|
5329
|
+
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5330
|
+
(0, import_log15.log)("loaded persistent invitations", {
|
|
5331
|
+
count: loadedInvitations.invitations?.length
|
|
5332
|
+
}, {
|
|
5333
|
+
F: __dxlog_file18,
|
|
5334
|
+
L: 300,
|
|
5335
|
+
S: this,
|
|
5336
|
+
C: (f, a) => f(...a)
|
|
5337
|
+
});
|
|
5178
5338
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
5179
5339
|
if (devtoolsProxy) {
|
|
5180
5340
|
this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
|
|
@@ -5193,7 +5353,7 @@ var ClientServicesHost = class {
|
|
|
5193
5353
|
deviceKey
|
|
5194
5354
|
}, {
|
|
5195
5355
|
F: __dxlog_file18,
|
|
5196
|
-
L:
|
|
5356
|
+
L: 317,
|
|
5197
5357
|
S: this,
|
|
5198
5358
|
C: (f, a) => f(...a)
|
|
5199
5359
|
});
|
|
@@ -5201,7 +5361,7 @@ var ClientServicesHost = class {
|
|
|
5201
5361
|
id: traceId
|
|
5202
5362
|
}), {
|
|
5203
5363
|
F: __dxlog_file18,
|
|
5204
|
-
L:
|
|
5364
|
+
L: 318,
|
|
5205
5365
|
S: this,
|
|
5206
5366
|
C: (f, a) => f(...a)
|
|
5207
5367
|
});
|
|
@@ -5215,7 +5375,7 @@ var ClientServicesHost = class {
|
|
|
5215
5375
|
deviceKey
|
|
5216
5376
|
}, {
|
|
5217
5377
|
F: __dxlog_file18,
|
|
5218
|
-
L:
|
|
5378
|
+
L: 329,
|
|
5219
5379
|
S: this,
|
|
5220
5380
|
C: (f, a) => f(...a)
|
|
5221
5381
|
});
|
|
@@ -5231,7 +5391,7 @@ var ClientServicesHost = class {
|
|
|
5231
5391
|
deviceKey
|
|
5232
5392
|
}, {
|
|
5233
5393
|
F: __dxlog_file18,
|
|
5234
|
-
L:
|
|
5394
|
+
L: 336,
|
|
5235
5395
|
S: this,
|
|
5236
5396
|
C: (f, a) => f(...a)
|
|
5237
5397
|
});
|
|
@@ -5242,13 +5402,13 @@ var ClientServicesHost = class {
|
|
|
5242
5402
|
id: traceId
|
|
5243
5403
|
}), {
|
|
5244
5404
|
F: __dxlog_file18,
|
|
5245
|
-
L:
|
|
5405
|
+
L: 341,
|
|
5246
5406
|
S: this,
|
|
5247
5407
|
C: (f, a) => f(...a)
|
|
5248
5408
|
});
|
|
5249
5409
|
(0, import_log15.log)("resetting...", void 0, {
|
|
5250
5410
|
F: __dxlog_file18,
|
|
5251
|
-
L:
|
|
5411
|
+
L: 343,
|
|
5252
5412
|
S: this,
|
|
5253
5413
|
C: (f, a) => f(...a)
|
|
5254
5414
|
});
|
|
@@ -5256,7 +5416,7 @@ var ClientServicesHost = class {
|
|
|
5256
5416
|
await this._storage.reset();
|
|
5257
5417
|
(0, import_log15.log)("reset", void 0, {
|
|
5258
5418
|
F: __dxlog_file18,
|
|
5259
|
-
L:
|
|
5419
|
+
L: 346,
|
|
5260
5420
|
S: this,
|
|
5261
5421
|
C: (f, a) => f(...a)
|
|
5262
5422
|
});
|
|
@@ -5264,7 +5424,7 @@ var ClientServicesHost = class {
|
|
|
5264
5424
|
id: traceId
|
|
5265
5425
|
}), {
|
|
5266
5426
|
F: __dxlog_file18,
|
|
5267
|
-
L:
|
|
5427
|
+
L: 347,
|
|
5268
5428
|
S: this,
|
|
5269
5429
|
C: (f, a) => f(...a)
|
|
5270
5430
|
});
|
|
@@ -5279,7 +5439,7 @@ var ClientServicesHost = class {
|
|
|
5279
5439
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5280
5440
|
(0, import_invariant16.invariant)(automergeIndex, void 0, {
|
|
5281
5441
|
F: __dxlog_file18,
|
|
5282
|
-
L:
|
|
5442
|
+
L: 362,
|
|
5283
5443
|
S: this,
|
|
5284
5444
|
A: [
|
|
5285
5445
|
"automergeIndex",
|
|
@@ -5339,6 +5499,7 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5339
5499
|
createDiagnostics,
|
|
5340
5500
|
createStorageObjects,
|
|
5341
5501
|
getNetworkPeers,
|
|
5502
|
+
invitationExpired,
|
|
5342
5503
|
isLocked,
|
|
5343
5504
|
subscribeToFeedBlocks,
|
|
5344
5505
|
subscribeToFeeds,
|
|
@@ -5348,4 +5509,4 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5348
5509
|
subscribeToSpaces,
|
|
5349
5510
|
subscribeToSwarmInfo
|
|
5350
5511
|
});
|
|
5351
|
-
//# sourceMappingURL=chunk-
|
|
5512
|
+
//# sourceMappingURL=chunk-IIMBD24E.cjs.map
|