@dxos/client-services 0.4.7-next.f4b92be → 0.4.8-main.00e6f19
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-NTKD4OQC.mjs → chunk-EQPR3Z5Y.mjs} +426 -164
- package/dist/lib/browser/chunk-EQPR3Z5Y.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-GCIW4VHF.cjs → chunk-VDSDEN45.cjs} +405 -146
- package/dist/lib/node/chunk-VDSDEN45.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/indexing/index.d.ts +2 -0
- package/dist/types/src/packlets/indexing/index.d.ts.map +1 -0
- package/dist/types/src/packlets/indexing/util.d.ts +15 -0
- package/dist/types/src/packlets/indexing/util.d.ts.map +1 -0
- 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 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +2 -0
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +37 -35
- package/src/packlets/identity/identity-manager.ts +1 -1
- package/src/packlets/indexing/index.ts +5 -0
- package/src/packlets/indexing/util.ts +89 -0
- 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/service-context.ts +13 -2
- package/src/packlets/services/service-host.ts +15 -2
- package/src/packlets/spaces/automerge-space-state.ts +15 -0
- package/src/packlets/spaces/data-space.ts +33 -11
- package/src/packlets/spaces/spaces-service.ts +2 -2
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-NTKD4OQC.mjs.map +0 -7
- package/dist/lib/node/chunk-GCIW4VHF.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_VDSDEN45_exports = {};
|
|
30
|
+
__export(chunk_VDSDEN45_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
33
|
DataSpace: () => DataSpace,
|
|
@@ -51,6 +51,7 @@ __export(chunk_GCIW4VHF_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_GCIW4VHF_exports, {
|
|
|
60
61
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
61
62
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
62
63
|
});
|
|
63
|
-
module.exports = __toCommonJS(
|
|
64
|
+
module.exports = __toCommonJS(chunk_VDSDEN45_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,12 +203,12 @@ 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");
|
|
208
|
-
var import_echo_schema = require("@dxos/echo-schema");
|
|
209
210
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
211
|
+
var import_indexing = require("@dxos/indexing");
|
|
210
212
|
var import_invariant14 = require("@dxos/invariant");
|
|
211
213
|
var import_keyring = require("@dxos/keyring");
|
|
212
214
|
var import_keys10 = require("@dxos/keys");
|
|
@@ -216,27 +218,31 @@ var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
216
218
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
217
219
|
var import_tracing6 = require("@dxos/tracing");
|
|
218
220
|
var import_util7 = require("@dxos/util");
|
|
221
|
+
var import_automerge = require("@dxos/automerge/automerge");
|
|
222
|
+
var import_debug7 = require("@dxos/debug");
|
|
223
|
+
var import_protocols13 = require("@dxos/protocols");
|
|
219
224
|
var import_invariant15 = require("@dxos/invariant");
|
|
220
225
|
var import_lock_file = require("@dxos/lock-file");
|
|
221
226
|
var import_log14 = require("@dxos/log");
|
|
222
227
|
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
223
|
-
var
|
|
228
|
+
var import_protocols14 = require("@dxos/protocols");
|
|
224
229
|
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
225
230
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
226
231
|
var import_util8 = require("@dxos/util");
|
|
227
232
|
var import_async15 = require("@dxos/async");
|
|
228
233
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
229
|
-
var
|
|
234
|
+
var import_context11 = require("@dxos/context");
|
|
230
235
|
var import_document_model2 = require("@dxos/document-model");
|
|
231
236
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
232
|
-
var
|
|
237
|
+
var import_echo_schema = require("@dxos/echo-schema");
|
|
238
|
+
var import_indexing2 = require("@dxos/indexing");
|
|
233
239
|
var import_invariant16 = require("@dxos/invariant");
|
|
234
240
|
var import_keys11 = require("@dxos/keys");
|
|
235
241
|
var import_log15 = require("@dxos/log");
|
|
236
242
|
var import_messaging = require("@dxos/messaging");
|
|
237
243
|
var import_model_factory = require("@dxos/model-factory");
|
|
238
244
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
239
|
-
var
|
|
245
|
+
var import_protocols15 = require("@dxos/protocols");
|
|
240
246
|
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
241
247
|
var import_text_model = require("@dxos/text-model");
|
|
242
248
|
var import_tracing7 = require("@dxos/tracing");
|
|
@@ -248,6 +254,7 @@ var import_invariant17 = require("@dxos/invariant");
|
|
|
248
254
|
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
249
255
|
var import_async17 = require("@dxos/async");
|
|
250
256
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
257
|
+
var import_keys12 = require("@dxos/keys");
|
|
251
258
|
var import_log16 = require("@dxos/log");
|
|
252
259
|
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
253
260
|
var import_util10 = require("@dxos/util");
|
|
@@ -1229,7 +1236,7 @@ var IdentityManager = class {
|
|
|
1229
1236
|
identityKey: identityRecord.identityKey
|
|
1230
1237
|
});
|
|
1231
1238
|
await space.setControlFeed(controlFeed);
|
|
1232
|
-
|
|
1239
|
+
await space.setDataFeed(dataFeed);
|
|
1233
1240
|
const identity = new Identity({
|
|
1234
1241
|
space,
|
|
1235
1242
|
presence,
|
|
@@ -1787,11 +1794,11 @@ var InvitationsHandler = class {
|
|
|
1787
1794
|
this._networkManager = _networkManager;
|
|
1788
1795
|
}
|
|
1789
1796
|
createInvitation(protocol, options) {
|
|
1790
|
-
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 ?? {};
|
|
1797
|
+
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 ?? {};
|
|
1791
1798
|
const authCode = options?.authCode ?? (authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1792
1799
|
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
1793
1800
|
F: __dxlog_file7,
|
|
1794
|
-
L:
|
|
1801
|
+
L: 84,
|
|
1795
1802
|
S: this,
|
|
1796
1803
|
A: [
|
|
1797
1804
|
"protocol",
|
|
@@ -1806,13 +1813,16 @@ var InvitationsHandler = class {
|
|
|
1806
1813
|
swarmKey,
|
|
1807
1814
|
authCode,
|
|
1808
1815
|
timeout,
|
|
1816
|
+
persistent,
|
|
1817
|
+
created,
|
|
1818
|
+
lifetime,
|
|
1809
1819
|
...protocol.getInvitationContext()
|
|
1810
1820
|
};
|
|
1811
1821
|
const stream = new import_async7.PushStream();
|
|
1812
1822
|
const ctx = new import_context4.Context({
|
|
1813
1823
|
onError: (err) => {
|
|
1814
|
-
void ctx.dispose();
|
|
1815
1824
|
stream.error(err);
|
|
1825
|
+
void ctx.dispose();
|
|
1816
1826
|
}
|
|
1817
1827
|
});
|
|
1818
1828
|
ctx.onDispose(() => {
|
|
@@ -1820,7 +1830,7 @@ var InvitationsHandler = class {
|
|
|
1820
1830
|
...protocol.toJSON()
|
|
1821
1831
|
}, {
|
|
1822
1832
|
F: __dxlog_file7,
|
|
1823
|
-
L:
|
|
1833
|
+
L: 109,
|
|
1824
1834
|
S: this,
|
|
1825
1835
|
C: (f, a) => f(...a)
|
|
1826
1836
|
});
|
|
@@ -1845,7 +1855,7 @@ var InvitationsHandler = class {
|
|
|
1845
1855
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1846
1856
|
(0, import_invariant5.invariant)(deviceKey, void 0, {
|
|
1847
1857
|
F: __dxlog_file7,
|
|
1848
|
-
L:
|
|
1858
|
+
L: 130,
|
|
1849
1859
|
S: this,
|
|
1850
1860
|
A: [
|
|
1851
1861
|
"deviceKey",
|
|
@@ -1868,7 +1878,7 @@ var InvitationsHandler = class {
|
|
|
1868
1878
|
id: traceId
|
|
1869
1879
|
}), {
|
|
1870
1880
|
F: __dxlog_file7,
|
|
1871
|
-
L:
|
|
1881
|
+
L: 148,
|
|
1872
1882
|
S: this,
|
|
1873
1883
|
C: (f, a) => f(...a)
|
|
1874
1884
|
});
|
|
@@ -1876,7 +1886,7 @@ var InvitationsHandler = class {
|
|
|
1876
1886
|
...protocol.toJSON()
|
|
1877
1887
|
}, {
|
|
1878
1888
|
F: __dxlog_file7,
|
|
1879
|
-
L:
|
|
1889
|
+
L: 149,
|
|
1880
1890
|
S: this,
|
|
1881
1891
|
C: (f, a) => f(...a)
|
|
1882
1892
|
});
|
|
@@ -1892,7 +1902,7 @@ var InvitationsHandler = class {
|
|
|
1892
1902
|
...protocol.toJSON()
|
|
1893
1903
|
}, {
|
|
1894
1904
|
F: __dxlog_file7,
|
|
1895
|
-
L:
|
|
1905
|
+
L: 152,
|
|
1896
1906
|
S: this,
|
|
1897
1907
|
C: (f, a) => f(...a)
|
|
1898
1908
|
});
|
|
@@ -1904,7 +1914,7 @@ var InvitationsHandler = class {
|
|
|
1904
1914
|
id: traceId
|
|
1905
1915
|
}), {
|
|
1906
1916
|
F: __dxlog_file7,
|
|
1907
|
-
L:
|
|
1917
|
+
L: 154,
|
|
1908
1918
|
S: this,
|
|
1909
1919
|
C: (f, a) => f(...a)
|
|
1910
1920
|
});
|
|
@@ -1914,7 +1924,7 @@ var InvitationsHandler = class {
|
|
|
1914
1924
|
...protocol.toJSON()
|
|
1915
1925
|
}, {
|
|
1916
1926
|
F: __dxlog_file7,
|
|
1917
|
-
L:
|
|
1927
|
+
L: 157,
|
|
1918
1928
|
S: this,
|
|
1919
1929
|
C: (f, a) => f(...a)
|
|
1920
1930
|
});
|
|
@@ -1925,7 +1935,7 @@ var InvitationsHandler = class {
|
|
|
1925
1935
|
} else {
|
|
1926
1936
|
import_log4.log.error("failed", err, {
|
|
1927
1937
|
F: __dxlog_file7,
|
|
1928
|
-
L:
|
|
1938
|
+
L: 160,
|
|
1929
1939
|
S: this,
|
|
1930
1940
|
C: (f, a) => f(...a)
|
|
1931
1941
|
});
|
|
@@ -1936,7 +1946,7 @@ var InvitationsHandler = class {
|
|
|
1936
1946
|
error: err
|
|
1937
1947
|
}), {
|
|
1938
1948
|
F: __dxlog_file7,
|
|
1939
|
-
L:
|
|
1949
|
+
L: 163,
|
|
1940
1950
|
S: this,
|
|
1941
1951
|
C: (f, a) => f(...a)
|
|
1942
1952
|
});
|
|
@@ -1957,7 +1967,7 @@ var InvitationsHandler = class {
|
|
|
1957
1967
|
...protocol.toJSON()
|
|
1958
1968
|
}, {
|
|
1959
1969
|
F: __dxlog_file7,
|
|
1960
|
-
L:
|
|
1970
|
+
L: 178,
|
|
1961
1971
|
S: this,
|
|
1962
1972
|
C: (f, a) => f(...a)
|
|
1963
1973
|
});
|
|
@@ -1968,7 +1978,7 @@ var InvitationsHandler = class {
|
|
|
1968
1978
|
} else {
|
|
1969
1979
|
import_log4.log.error("failed", err, {
|
|
1970
1980
|
F: __dxlog_file7,
|
|
1971
|
-
L:
|
|
1981
|
+
L: 181,
|
|
1972
1982
|
S: this,
|
|
1973
1983
|
C: (f, a) => f(...a)
|
|
1974
1984
|
});
|
|
@@ -1978,7 +1988,27 @@ var InvitationsHandler = class {
|
|
|
1978
1988
|
});
|
|
1979
1989
|
return extension;
|
|
1980
1990
|
};
|
|
1991
|
+
if (invitation.lifetime && invitation.created && invitation.lifetime !== 0) {
|
|
1992
|
+
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
1993
|
+
import_log4.log.warn("invitation has already expired", void 0, {
|
|
1994
|
+
F: __dxlog_file7,
|
|
1995
|
+
L: 192,
|
|
1996
|
+
S: this,
|
|
1997
|
+
C: (f, a) => f(...a)
|
|
1998
|
+
});
|
|
1999
|
+
} else {
|
|
2000
|
+
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
2001
|
+
await swarmConnection.close();
|
|
2002
|
+
stream.next({
|
|
2003
|
+
...invitation,
|
|
2004
|
+
state: import_services3.Invitation.State.EXPIRED
|
|
2005
|
+
});
|
|
2006
|
+
await ctx.dispose();
|
|
2007
|
+
}, invitation.created.getTime() + invitation.lifetime * 1e3 - Date.now());
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
1981
2010
|
let swarmConnection;
|
|
2011
|
+
const invitationLabel = "invitation host for " + (invitation.kind === import_services3.Invitation.Kind.DEVICE ? "device" : `space ${invitation.spaceKey?.truncate()}`);
|
|
1982
2012
|
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
1983
2013
|
const topic = invitation.swarmKey;
|
|
1984
2014
|
swarmConnection = await this._networkManager.joinSwarm({
|
|
@@ -1988,7 +2018,7 @@ var InvitationsHandler = class {
|
|
|
1988
2018
|
teleport.addExtension("dxos.halo.invitations", createExtension());
|
|
1989
2019
|
}),
|
|
1990
2020
|
topology: new import_network_manager.StarTopology(topic),
|
|
1991
|
-
label:
|
|
2021
|
+
label: invitationLabel
|
|
1992
2022
|
});
|
|
1993
2023
|
ctx.onDispose(() => swarmConnection.close());
|
|
1994
2024
|
stream.next({
|
|
@@ -2013,7 +2043,7 @@ var InvitationsHandler = class {
|
|
|
2013
2043
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
2014
2044
|
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
2015
2045
|
F: __dxlog_file7,
|
|
2016
|
-
L:
|
|
2046
|
+
L: 246,
|
|
2017
2047
|
S: this,
|
|
2018
2048
|
A: [
|
|
2019
2049
|
"protocol",
|
|
@@ -2023,7 +2053,7 @@ var InvitationsHandler = class {
|
|
|
2023
2053
|
if (deviceProfile) {
|
|
2024
2054
|
(0, import_invariant5.invariant)(invitation.kind === import_services3.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2025
2055
|
F: __dxlog_file7,
|
|
2026
|
-
L:
|
|
2056
|
+
L: 250,
|
|
2027
2057
|
S: this,
|
|
2028
2058
|
A: [
|
|
2029
2059
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -2038,7 +2068,7 @@ var InvitationsHandler = class {
|
|
|
2038
2068
|
const setState = (newData) => {
|
|
2039
2069
|
(0, import_invariant5.invariant)(newData.state !== void 0, void 0, {
|
|
2040
2070
|
F: __dxlog_file7,
|
|
2041
|
-
L:
|
|
2071
|
+
L: 261,
|
|
2042
2072
|
S: this,
|
|
2043
2073
|
A: [
|
|
2044
2074
|
"newData.state !== undefined",
|
|
@@ -2058,7 +2088,7 @@ var InvitationsHandler = class {
|
|
|
2058
2088
|
...protocol.toJSON()
|
|
2059
2089
|
}, {
|
|
2060
2090
|
F: __dxlog_file7,
|
|
2061
|
-
L:
|
|
2091
|
+
L: 269,
|
|
2062
2092
|
S: this,
|
|
2063
2093
|
C: (f, a) => f(...a)
|
|
2064
2094
|
});
|
|
@@ -2068,7 +2098,7 @@ var InvitationsHandler = class {
|
|
|
2068
2098
|
} else {
|
|
2069
2099
|
import_log4.log.warn("auth failed", err, {
|
|
2070
2100
|
F: __dxlog_file7,
|
|
2071
|
-
L:
|
|
2101
|
+
L: 272,
|
|
2072
2102
|
S: this,
|
|
2073
2103
|
C: (f, a) => f(...a)
|
|
2074
2104
|
});
|
|
@@ -2082,7 +2112,7 @@ var InvitationsHandler = class {
|
|
|
2082
2112
|
...protocol.toJSON()
|
|
2083
2113
|
}, {
|
|
2084
2114
|
F: __dxlog_file7,
|
|
2085
|
-
L:
|
|
2115
|
+
L: 280,
|
|
2086
2116
|
S: this,
|
|
2087
2117
|
C: (f, a) => f(...a)
|
|
2088
2118
|
});
|
|
@@ -2097,7 +2127,7 @@ var InvitationsHandler = class {
|
|
|
2097
2127
|
currentState
|
|
2098
2128
|
}, {
|
|
2099
2129
|
F: __dxlog_file7,
|
|
2100
|
-
L:
|
|
2130
|
+
L: 290,
|
|
2101
2131
|
S: this,
|
|
2102
2132
|
C: (f, a) => f(...a)
|
|
2103
2133
|
});
|
|
@@ -2112,7 +2142,7 @@ var InvitationsHandler = class {
|
|
|
2112
2142
|
id: traceId
|
|
2113
2143
|
}), {
|
|
2114
2144
|
F: __dxlog_file7,
|
|
2115
|
-
L:
|
|
2145
|
+
L: 299,
|
|
2116
2146
|
S: this,
|
|
2117
2147
|
C: (f, a) => f(...a)
|
|
2118
2148
|
});
|
|
@@ -2124,7 +2154,7 @@ var InvitationsHandler = class {
|
|
|
2124
2154
|
...protocol.toJSON()
|
|
2125
2155
|
}, {
|
|
2126
2156
|
F: __dxlog_file7,
|
|
2127
|
-
L:
|
|
2157
|
+
L: 307,
|
|
2128
2158
|
S: this,
|
|
2129
2159
|
C: (f, a) => f(...a)
|
|
2130
2160
|
});
|
|
@@ -2135,7 +2165,7 @@ var InvitationsHandler = class {
|
|
|
2135
2165
|
...protocol.toJSON()
|
|
2136
2166
|
}, {
|
|
2137
2167
|
F: __dxlog_file7,
|
|
2138
|
-
L:
|
|
2168
|
+
L: 311,
|
|
2139
2169
|
S: this,
|
|
2140
2170
|
C: (f, a) => f(...a)
|
|
2141
2171
|
});
|
|
@@ -2145,7 +2175,7 @@ var InvitationsHandler = class {
|
|
|
2145
2175
|
response: introductionResponse
|
|
2146
2176
|
}, {
|
|
2147
2177
|
F: __dxlog_file7,
|
|
2148
|
-
L:
|
|
2178
|
+
L: 315,
|
|
2149
2179
|
S: this,
|
|
2150
2180
|
C: (f, a) => f(...a)
|
|
2151
2181
|
});
|
|
@@ -2154,7 +2184,7 @@ var InvitationsHandler = class {
|
|
|
2154
2184
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2155
2185
|
(0, import_log4.log)("guest waiting for authentication code...", void 0, {
|
|
2156
2186
|
F: __dxlog_file7,
|
|
2157
|
-
L:
|
|
2187
|
+
L: 321,
|
|
2158
2188
|
S: this,
|
|
2159
2189
|
C: (f, a) => f(...a)
|
|
2160
2190
|
});
|
|
@@ -2166,7 +2196,7 @@ var InvitationsHandler = class {
|
|
|
2166
2196
|
});
|
|
2167
2197
|
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2168
2198
|
F: __dxlog_file7,
|
|
2169
|
-
L:
|
|
2199
|
+
L: 325,
|
|
2170
2200
|
S: this,
|
|
2171
2201
|
C: (f, a) => f(...a)
|
|
2172
2202
|
});
|
|
@@ -2187,7 +2217,7 @@ var InvitationsHandler = class {
|
|
|
2187
2217
|
attempt
|
|
2188
2218
|
}, {
|
|
2189
2219
|
F: __dxlog_file7,
|
|
2190
|
-
L:
|
|
2220
|
+
L: 336,
|
|
2191
2221
|
S: this,
|
|
2192
2222
|
C: (f, a) => f(...a)
|
|
2193
2223
|
});
|
|
@@ -2200,7 +2230,7 @@ var InvitationsHandler = class {
|
|
|
2200
2230
|
...protocol.toJSON()
|
|
2201
2231
|
}, {
|
|
2202
2232
|
F: __dxlog_file7,
|
|
2203
|
-
L:
|
|
2233
|
+
L: 344,
|
|
2204
2234
|
S: this,
|
|
2205
2235
|
C: (f, a) => f(...a)
|
|
2206
2236
|
});
|
|
@@ -2212,7 +2242,7 @@ var InvitationsHandler = class {
|
|
|
2212
2242
|
...protocol.toJSON()
|
|
2213
2243
|
}, {
|
|
2214
2244
|
F: __dxlog_file7,
|
|
2215
|
-
L:
|
|
2245
|
+
L: 355,
|
|
2216
2246
|
S: this,
|
|
2217
2247
|
C: (f, a) => f(...a)
|
|
2218
2248
|
});
|
|
@@ -2225,7 +2255,7 @@ var InvitationsHandler = class {
|
|
|
2225
2255
|
id: traceId
|
|
2226
2256
|
}), {
|
|
2227
2257
|
F: __dxlog_file7,
|
|
2228
|
-
L:
|
|
2258
|
+
L: 357,
|
|
2229
2259
|
S: this,
|
|
2230
2260
|
C: (f, a) => f(...a)
|
|
2231
2261
|
});
|
|
@@ -2235,7 +2265,7 @@ var InvitationsHandler = class {
|
|
|
2235
2265
|
...protocol.toJSON()
|
|
2236
2266
|
}, {
|
|
2237
2267
|
F: __dxlog_file7,
|
|
2238
|
-
L:
|
|
2268
|
+
L: 360,
|
|
2239
2269
|
S: this,
|
|
2240
2270
|
C: (f, a) => f(...a)
|
|
2241
2271
|
});
|
|
@@ -2245,7 +2275,7 @@ var InvitationsHandler = class {
|
|
|
2245
2275
|
} else {
|
|
2246
2276
|
(0, import_log4.log)("auth failed", err, {
|
|
2247
2277
|
F: __dxlog_file7,
|
|
2248
|
-
L:
|
|
2278
|
+
L: 363,
|
|
2249
2279
|
S: this,
|
|
2250
2280
|
C: (f, a) => f(...a)
|
|
2251
2281
|
});
|
|
@@ -2256,7 +2286,7 @@ var InvitationsHandler = class {
|
|
|
2256
2286
|
error: err
|
|
2257
2287
|
}), {
|
|
2258
2288
|
F: __dxlog_file7,
|
|
2259
|
-
L:
|
|
2289
|
+
L: 366,
|
|
2260
2290
|
S: this,
|
|
2261
2291
|
C: (f, a) => f(...a)
|
|
2262
2292
|
});
|
|
@@ -2274,7 +2304,7 @@ var InvitationsHandler = class {
|
|
|
2274
2304
|
...protocol.toJSON()
|
|
2275
2305
|
}, {
|
|
2276
2306
|
F: __dxlog_file7,
|
|
2277
|
-
L:
|
|
2307
|
+
L: 377,
|
|
2278
2308
|
S: this,
|
|
2279
2309
|
C: (f, a) => f(...a)
|
|
2280
2310
|
});
|
|
@@ -2284,7 +2314,7 @@ var InvitationsHandler = class {
|
|
|
2284
2314
|
} else {
|
|
2285
2315
|
(0, import_log4.log)("auth failed", err, {
|
|
2286
2316
|
F: __dxlog_file7,
|
|
2287
|
-
L:
|
|
2317
|
+
L: 380,
|
|
2288
2318
|
S: this,
|
|
2289
2319
|
C: (f, a) => f(...a)
|
|
2290
2320
|
});
|
|
@@ -2301,7 +2331,7 @@ var InvitationsHandler = class {
|
|
|
2301
2331
|
} else {
|
|
2302
2332
|
(0, import_invariant5.invariant)(invitation.swarmKey, void 0, {
|
|
2303
2333
|
F: __dxlog_file7,
|
|
2304
|
-
L:
|
|
2334
|
+
L: 394,
|
|
2305
2335
|
S: this,
|
|
2306
2336
|
A: [
|
|
2307
2337
|
"invitation.swarmKey",
|
|
@@ -2340,17 +2370,24 @@ var InvitationsHandler = class {
|
|
|
2340
2370
|
return observable;
|
|
2341
2371
|
}
|
|
2342
2372
|
};
|
|
2373
|
+
var invitationExpired = (invitation) => {
|
|
2374
|
+
return invitation.created && invitation.lifetime && invitation.lifetime !== 0 && invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now();
|
|
2375
|
+
};
|
|
2343
2376
|
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
2344
2377
|
var InvitationsServiceImpl = class {
|
|
2345
|
-
constructor(_invitationsHandler, _getHandler) {
|
|
2378
|
+
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
2346
2379
|
this._invitationsHandler = _invitationsHandler;
|
|
2347
2380
|
this._getHandler = _getHandler;
|
|
2381
|
+
this._metadataStore = _metadataStore;
|
|
2348
2382
|
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2349
2383
|
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2350
2384
|
this._invitationCreated = new import_async9.Event();
|
|
2351
2385
|
this._invitationAccepted = new import_async9.Event();
|
|
2352
2386
|
this._removedCreated = new import_async9.Event();
|
|
2353
2387
|
this._removedAccepted = new import_async9.Event();
|
|
2388
|
+
this._saved = new import_async9.Event();
|
|
2389
|
+
this._persistentInvitationsLoadedEvent = new import_async9.Event();
|
|
2390
|
+
this._persistentInvitationsLoaded = false;
|
|
2354
2391
|
}
|
|
2355
2392
|
// TODO(burdon): Guest/host label.
|
|
2356
2393
|
getLoggingContext() {
|
|
@@ -2358,6 +2395,7 @@ var InvitationsServiceImpl = class {
|
|
|
2358
2395
|
}
|
|
2359
2396
|
createInvitation(options) {
|
|
2360
2397
|
let invitation;
|
|
2398
|
+
const savePersistentInvitationCtx = new import_context6.Context();
|
|
2361
2399
|
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2362
2400
|
if (existingInvitation) {
|
|
2363
2401
|
invitation = existingInvitation;
|
|
@@ -2368,12 +2406,27 @@ var InvitationsServiceImpl = class {
|
|
|
2368
2406
|
this._invitationCreated.emit(invitation.get());
|
|
2369
2407
|
}
|
|
2370
2408
|
return new import_codec_protobuf8.Stream(({ next, close }) => {
|
|
2409
|
+
if (invitation.get().persistent) {
|
|
2410
|
+
(0, import_async9.scheduleTask)(savePersistentInvitationCtx, async () => {
|
|
2411
|
+
try {
|
|
2412
|
+
await this._metadataStore.addInvitation(invitation.get());
|
|
2413
|
+
this._saved.emit(invitation.get());
|
|
2414
|
+
} catch (err) {
|
|
2415
|
+
close(err);
|
|
2416
|
+
}
|
|
2417
|
+
});
|
|
2418
|
+
}
|
|
2371
2419
|
invitation.subscribe((invitation2) => {
|
|
2372
2420
|
next(invitation2);
|
|
2373
|
-
}, (err) => {
|
|
2421
|
+
}, async (err) => {
|
|
2422
|
+
await savePersistentInvitationCtx.dispose();
|
|
2374
2423
|
close(err);
|
|
2375
|
-
}, () => {
|
|
2424
|
+
}, async () => {
|
|
2376
2425
|
close();
|
|
2426
|
+
if (invitation.get().persistent) {
|
|
2427
|
+
await savePersistentInvitationCtx.dispose();
|
|
2428
|
+
await this._metadataStore.removeInvitation(invitation.get().invitationId);
|
|
2429
|
+
}
|
|
2377
2430
|
this._createInvitations.delete(invitation.get().invitationId);
|
|
2378
2431
|
if (invitation.get().type !== import_services5.Invitation.Type.MULTIUSE) {
|
|
2379
2432
|
this._removedCreated.emit(invitation.get());
|
|
@@ -2381,12 +2434,37 @@ var InvitationsServiceImpl = class {
|
|
|
2381
2434
|
});
|
|
2382
2435
|
});
|
|
2383
2436
|
}
|
|
2437
|
+
async loadPersistentInvitations() {
|
|
2438
|
+
const persistentInvitations = this._metadataStore.getInvitations();
|
|
2439
|
+
const freshInvitations = persistentInvitations.filter(async (invitation) => !invitationExpired(invitation));
|
|
2440
|
+
const cInvitations = freshInvitations.map((persistentInvitation) => {
|
|
2441
|
+
(0, import_invariant7.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2442
|
+
F: __dxlog_file8,
|
|
2443
|
+
L: 109,
|
|
2444
|
+
S: this,
|
|
2445
|
+
A: [
|
|
2446
|
+
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2447
|
+
"'invitation already exists'"
|
|
2448
|
+
]
|
|
2449
|
+
});
|
|
2450
|
+
const handler = this._getHandler(persistentInvitation);
|
|
2451
|
+
const invitation = this._invitationsHandler.createInvitation(handler, persistentInvitation);
|
|
2452
|
+
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2453
|
+
this._invitationCreated.emit(invitation.get());
|
|
2454
|
+
return persistentInvitation;
|
|
2455
|
+
});
|
|
2456
|
+
this._persistentInvitationsLoadedEvent.emit();
|
|
2457
|
+
this._persistentInvitationsLoaded = true;
|
|
2458
|
+
return {
|
|
2459
|
+
invitations: cInvitations
|
|
2460
|
+
};
|
|
2461
|
+
}
|
|
2384
2462
|
acceptInvitation({ invitation: options, deviceProfile }) {
|
|
2385
2463
|
let invitation;
|
|
2386
2464
|
if (deviceProfile) {
|
|
2387
2465
|
(0, import_invariant7.invariant)(options.kind === import_services5.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2388
2466
|
F: __dxlog_file8,
|
|
2389
|
-
L:
|
|
2467
|
+
L: 127,
|
|
2390
2468
|
S: this,
|
|
2391
2469
|
A: [
|
|
2392
2470
|
"options.kind === Invitation.Kind.DEVICE",
|
|
@@ -2420,13 +2498,13 @@ var InvitationsServiceImpl = class {
|
|
|
2420
2498
|
async authenticate({ invitationId, authCode }) {
|
|
2421
2499
|
(0, import_log6.log)("authenticating...", void 0, {
|
|
2422
2500
|
F: __dxlog_file8,
|
|
2423
|
-
L:
|
|
2501
|
+
L: 160,
|
|
2424
2502
|
S: this,
|
|
2425
2503
|
C: (f, a) => f(...a)
|
|
2426
2504
|
});
|
|
2427
2505
|
(0, import_invariant7.invariant)(invitationId, void 0, {
|
|
2428
2506
|
F: __dxlog_file8,
|
|
2429
|
-
L:
|
|
2507
|
+
L: 161,
|
|
2430
2508
|
S: this,
|
|
2431
2509
|
A: [
|
|
2432
2510
|
"invitationId",
|
|
@@ -2439,7 +2517,7 @@ var InvitationsServiceImpl = class {
|
|
|
2439
2517
|
invitationId
|
|
2440
2518
|
}, {
|
|
2441
2519
|
F: __dxlog_file8,
|
|
2442
|
-
L:
|
|
2520
|
+
L: 164,
|
|
2443
2521
|
S: this,
|
|
2444
2522
|
C: (f, a) => f(...a)
|
|
2445
2523
|
});
|
|
@@ -2448,15 +2526,17 @@ var InvitationsServiceImpl = class {
|
|
|
2448
2526
|
}
|
|
2449
2527
|
}
|
|
2450
2528
|
async cancelInvitation({ invitationId }) {
|
|
2451
|
-
(0, import_log6.log)("
|
|
2529
|
+
(0, import_log6.log)("cancelInvitation...", {
|
|
2530
|
+
invitationId
|
|
2531
|
+
}, {
|
|
2452
2532
|
F: __dxlog_file8,
|
|
2453
|
-
L:
|
|
2533
|
+
L: 171,
|
|
2454
2534
|
S: this,
|
|
2455
2535
|
C: (f, a) => f(...a)
|
|
2456
2536
|
});
|
|
2457
2537
|
(0, import_invariant7.invariant)(invitationId, void 0, {
|
|
2458
2538
|
F: __dxlog_file8,
|
|
2459
|
-
L:
|
|
2539
|
+
L: 172,
|
|
2460
2540
|
S: this,
|
|
2461
2541
|
A: [
|
|
2462
2542
|
"invitationId",
|
|
@@ -2469,6 +2549,9 @@ var InvitationsServiceImpl = class {
|
|
|
2469
2549
|
await created.cancel();
|
|
2470
2550
|
this._createInvitations.delete(invitationId);
|
|
2471
2551
|
this._removedCreated.emit(created.get());
|
|
2552
|
+
if (created.get().persistent) {
|
|
2553
|
+
await this._metadataStore.removeInvitation(created.get().invitationId);
|
|
2554
|
+
}
|
|
2472
2555
|
} else if (accepted) {
|
|
2473
2556
|
await accepted.cancel();
|
|
2474
2557
|
this._acceptInvitations.delete(invitationId);
|
|
@@ -2513,16 +2596,40 @@ var InvitationsServiceImpl = class {
|
|
|
2513
2596
|
]
|
|
2514
2597
|
});
|
|
2515
2598
|
});
|
|
2599
|
+
this._saved.on(ctx, (invitation) => {
|
|
2600
|
+
next({
|
|
2601
|
+
action: import_services5.QueryInvitationsResponse.Action.SAVED,
|
|
2602
|
+
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
2603
|
+
invitations: [
|
|
2604
|
+
invitation
|
|
2605
|
+
]
|
|
2606
|
+
});
|
|
2607
|
+
});
|
|
2516
2608
|
next({
|
|
2517
2609
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2518
2610
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
2519
|
-
invitations: Array.from(this._createInvitations.values()).map((invitation) => invitation.get())
|
|
2611
|
+
invitations: Array.from(this._createInvitations.values()).map((invitation) => invitation.get()),
|
|
2612
|
+
existing: true
|
|
2520
2613
|
});
|
|
2521
2614
|
next({
|
|
2522
2615
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2523
2616
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
2524
|
-
invitations: Array.from(this._acceptInvitations.values()).map((invitation) => invitation.get())
|
|
2617
|
+
invitations: Array.from(this._acceptInvitations.values()).map((invitation) => invitation.get()),
|
|
2618
|
+
existing: true
|
|
2525
2619
|
});
|
|
2620
|
+
if (this._persistentInvitationsLoaded) {
|
|
2621
|
+
next({
|
|
2622
|
+
action: import_services5.QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2623
|
+
type: import_services5.QueryInvitationsResponse.Type.CREATED
|
|
2624
|
+
});
|
|
2625
|
+
} else {
|
|
2626
|
+
this._persistentInvitationsLoadedEvent.on(ctx, () => {
|
|
2627
|
+
next({
|
|
2628
|
+
action: import_services5.QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2629
|
+
type: import_services5.QueryInvitationsResponse.Type.CREATED
|
|
2630
|
+
});
|
|
2631
|
+
});
|
|
2632
|
+
}
|
|
2526
2633
|
});
|
|
2527
2634
|
}
|
|
2528
2635
|
};
|
|
@@ -2783,7 +2890,7 @@ var getPlatform = () => {
|
|
|
2783
2890
|
};
|
|
2784
2891
|
}
|
|
2785
2892
|
};
|
|
2786
|
-
var DXOS_VERSION = "0.4.
|
|
2893
|
+
var DXOS_VERSION = "0.4.8-main.00e6f19";
|
|
2787
2894
|
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
2788
2895
|
var DEFAULT_TIMEOUT = 1e3;
|
|
2789
2896
|
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
@@ -2926,6 +3033,7 @@ var AutomergeSpaceState = class {
|
|
|
2926
3033
|
this._onNewRoot = _onNewRoot;
|
|
2927
3034
|
this.rootUrl = void 0;
|
|
2928
3035
|
this.lastEpoch = void 0;
|
|
3036
|
+
this._isProcessingRootDocs = false;
|
|
2929
3037
|
}
|
|
2930
3038
|
async processCredential(credential) {
|
|
2931
3039
|
if (!(0, import_credentials11.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
@@ -2934,8 +3042,19 @@ var AutomergeSpaceState = class {
|
|
|
2934
3042
|
this.lastEpoch = credential;
|
|
2935
3043
|
if (credential.subject.assertion.automergeRoot) {
|
|
2936
3044
|
this.rootUrl = credential.subject.assertion.automergeRoot;
|
|
3045
|
+
if (this._isProcessingRootDocs) {
|
|
3046
|
+
this._onNewRoot(this.rootUrl);
|
|
3047
|
+
}
|
|
3048
|
+
}
|
|
3049
|
+
}
|
|
3050
|
+
startProcessingRootDocs() {
|
|
3051
|
+
if (this._isProcessingRootDocs) {
|
|
3052
|
+
return;
|
|
3053
|
+
}
|
|
3054
|
+
if (this.rootUrl) {
|
|
2937
3055
|
this._onNewRoot(this.rootUrl);
|
|
2938
3056
|
}
|
|
3057
|
+
this._isProcessingRootDocs = true;
|
|
2939
3058
|
}
|
|
2940
3059
|
};
|
|
2941
3060
|
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
@@ -2945,7 +3064,7 @@ var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
|
2945
3064
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
2946
3065
|
var NotarizationPlugin = class {
|
|
2947
3066
|
constructor() {
|
|
2948
|
-
this._ctx = new
|
|
3067
|
+
this._ctx = new import_context8.Context();
|
|
2949
3068
|
this._extensionOpened = new import_async11.Event();
|
|
2950
3069
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2951
3070
|
this._processedCredentials = new import_util5.ComplexSet(import_keys8.PublicKey.hash);
|
|
@@ -3070,7 +3189,7 @@ var NotarizationPlugin = class {
|
|
|
3070
3189
|
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
3071
3190
|
try {
|
|
3072
3191
|
await Promise.race([
|
|
3073
|
-
(0,
|
|
3192
|
+
(0, import_context8.rejectOnDispose)(ctx),
|
|
3074
3193
|
allNotarized,
|
|
3075
3194
|
errors.wait()
|
|
3076
3195
|
]);
|
|
@@ -3210,7 +3329,7 @@ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
|
|
|
3210
3329
|
var ENABLE_FEED_PURGE = false;
|
|
3211
3330
|
var DataSpace = class {
|
|
3212
3331
|
constructor(params) {
|
|
3213
|
-
this._ctx = new
|
|
3332
|
+
this._ctx = new import_context7.Context();
|
|
3214
3333
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3215
3334
|
this._cache = void 0;
|
|
3216
3335
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
@@ -3286,7 +3405,7 @@ var DataSpace = class {
|
|
|
3286
3405
|
await this._notarizationPlugin.open();
|
|
3287
3406
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3288
3407
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3289
|
-
await this._inner.open(new
|
|
3408
|
+
await this._inner.open(new import_context7.Context());
|
|
3290
3409
|
this._state = import_services9.SpaceState.CONTROL_ONLY;
|
|
3291
3410
|
(0, import_log9.log)("new state", {
|
|
3292
3411
|
state: import_services9.SpaceState[this._state]
|
|
@@ -3315,7 +3434,7 @@ var DataSpace = class {
|
|
|
3315
3434
|
C: (f, a) => f(...a)
|
|
3316
3435
|
});
|
|
3317
3436
|
await this._ctx.dispose();
|
|
3318
|
-
this._ctx = new
|
|
3437
|
+
this._ctx = new import_context7.Context();
|
|
3319
3438
|
await this.authVerifier.close();
|
|
3320
3439
|
await this._inner.close();
|
|
3321
3440
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
@@ -3339,7 +3458,7 @@ var DataSpace = class {
|
|
|
3339
3458
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3340
3459
|
await this.initializeDataPipeline();
|
|
3341
3460
|
} catch (err) {
|
|
3342
|
-
if (err instanceof import_protocols8.CancelledError || err instanceof
|
|
3461
|
+
if (err instanceof import_protocols8.CancelledError || err instanceof import_context7.ContextDisposedError) {
|
|
3343
3462
|
(0, import_log9.log)("data pipeline initialization cancelled", err, {
|
|
3344
3463
|
F: __dxlog_file12,
|
|
3345
3464
|
L: 250,
|
|
@@ -3385,12 +3504,13 @@ var DataSpace = class {
|
|
|
3385
3504
|
});
|
|
3386
3505
|
await this._initializeAndReadControlPipeline();
|
|
3387
3506
|
await (0, import_async10.sleep)(1);
|
|
3507
|
+
this._automergeSpaceState.startProcessingRootDocs();
|
|
3388
3508
|
await this._inner.initializeDataPipeline();
|
|
3389
3509
|
this.metrics.dataPipelineOpen = /* @__PURE__ */ new Date();
|
|
3390
|
-
await (0,
|
|
3510
|
+
await (0, import_context7.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
3391
3511
|
(0, import_log9.log)("waiting for data pipeline to reach target timeframe", void 0, {
|
|
3392
3512
|
F: __dxlog_file12,
|
|
3393
|
-
L:
|
|
3513
|
+
L: 288,
|
|
3394
3514
|
S: this,
|
|
3395
3515
|
C: (f, a) => f(...a)
|
|
3396
3516
|
});
|
|
@@ -3401,7 +3521,7 @@ var DataSpace = class {
|
|
|
3401
3521
|
this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
|
|
3402
3522
|
(0, import_log9.log)("data pipeline ready", void 0, {
|
|
3403
3523
|
F: __dxlog_file12,
|
|
3404
|
-
L:
|
|
3524
|
+
L: 296,
|
|
3405
3525
|
S: this,
|
|
3406
3526
|
C: (f, a) => f(...a)
|
|
3407
3527
|
});
|
|
@@ -3411,7 +3531,7 @@ var DataSpace = class {
|
|
|
3411
3531
|
state: import_services9.SpaceState[this._state]
|
|
3412
3532
|
}, {
|
|
3413
3533
|
F: __dxlog_file12,
|
|
3414
|
-
L:
|
|
3534
|
+
L: 300,
|
|
3415
3535
|
S: this,
|
|
3416
3536
|
C: (f, a) => f(...a)
|
|
3417
3537
|
});
|
|
@@ -3427,7 +3547,7 @@ var DataSpace = class {
|
|
|
3427
3547
|
await this._createWritableFeeds();
|
|
3428
3548
|
(0, import_log9.log)("writable feeds created", void 0, {
|
|
3429
3549
|
F: __dxlog_file12,
|
|
3430
|
-
L:
|
|
3550
|
+
L: 316,
|
|
3431
3551
|
S: this,
|
|
3432
3552
|
C: (f, a) => f(...a)
|
|
3433
3553
|
});
|
|
@@ -3490,7 +3610,7 @@ var DataSpace = class {
|
|
|
3490
3610
|
rootUrl
|
|
3491
3611
|
}, {
|
|
3492
3612
|
F: __dxlog_file12,
|
|
3493
|
-
L:
|
|
3613
|
+
L: 382,
|
|
3494
3614
|
S: this,
|
|
3495
3615
|
C: (f, a) => f(...a)
|
|
3496
3616
|
});
|
|
@@ -3499,7 +3619,7 @@ var DataSpace = class {
|
|
|
3499
3619
|
queueMicrotask(async () => {
|
|
3500
3620
|
try {
|
|
3501
3621
|
await (0, import_debug3.warnAfterTimeout)(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
3502
|
-
await (0,
|
|
3622
|
+
await (0, import_context7.cancelWithContext)(this._ctx, handle.whenReady());
|
|
3503
3623
|
});
|
|
3504
3624
|
if (this._ctx.disposed) {
|
|
3505
3625
|
return;
|
|
@@ -3513,7 +3633,7 @@ var DataSpace = class {
|
|
|
3513
3633
|
});
|
|
3514
3634
|
}
|
|
3515
3635
|
} catch (err) {
|
|
3516
|
-
if (err instanceof
|
|
3636
|
+
if (err instanceof import_context7.ContextDisposedError) {
|
|
3517
3637
|
return;
|
|
3518
3638
|
}
|
|
3519
3639
|
import_log9.log.warn("error loading automerge root doc", {
|
|
@@ -3522,7 +3642,7 @@ var DataSpace = class {
|
|
|
3522
3642
|
err
|
|
3523
3643
|
}, {
|
|
3524
3644
|
F: __dxlog_file12,
|
|
3525
|
-
L:
|
|
3645
|
+
L: 405,
|
|
3526
3646
|
S: this,
|
|
3527
3647
|
C: (f, a) => f(...a)
|
|
3528
3648
|
});
|
|
@@ -3553,15 +3673,40 @@ var DataSpace = class {
|
|
|
3553
3673
|
epoch = await this.dataPipeline.createEpoch();
|
|
3554
3674
|
}
|
|
3555
3675
|
break;
|
|
3556
|
-
case import_services9.CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3676
|
+
case import_services9.CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3677
|
+
{
|
|
3678
|
+
const document = this._automergeHost.repo.create();
|
|
3679
|
+
epoch = {
|
|
3680
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3681
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
3682
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe2.Timeframe(),
|
|
3683
|
+
automergeRoot: document.url
|
|
3684
|
+
};
|
|
3685
|
+
}
|
|
3686
|
+
break;
|
|
3687
|
+
case import_services9.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
3688
|
+
{
|
|
3689
|
+
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3690
|
+
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3691
|
+
await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3692
|
+
const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
|
|
3693
|
+
(0, import_invariant10.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3694
|
+
F: __dxlog_file12,
|
|
3695
|
+
L: 450,
|
|
3696
|
+
S: this,
|
|
3697
|
+
A: [
|
|
3698
|
+
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3699
|
+
""
|
|
3700
|
+
]
|
|
3701
|
+
});
|
|
3702
|
+
epoch = {
|
|
3703
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3704
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
3705
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe2.Timeframe(),
|
|
3706
|
+
automergeRoot: newRoot.url
|
|
3707
|
+
};
|
|
3708
|
+
}
|
|
3709
|
+
break;
|
|
3565
3710
|
}
|
|
3566
3711
|
if (!epoch) {
|
|
3567
3712
|
return;
|
|
@@ -3612,7 +3757,7 @@ var DataSpace = class {
|
|
|
3612
3757
|
state: import_services9.SpaceState[this._state]
|
|
3613
3758
|
}, {
|
|
3614
3759
|
F: __dxlog_file12,
|
|
3615
|
-
L:
|
|
3760
|
+
L: 514,
|
|
3616
3761
|
S: this,
|
|
3617
3762
|
C: (f, a) => f(...a)
|
|
3618
3763
|
});
|
|
@@ -3750,7 +3895,7 @@ var DataSpaceManager = class {
|
|
|
3750
3895
|
this._signingContext = _signingContext;
|
|
3751
3896
|
this._feedStore = _feedStore;
|
|
3752
3897
|
this._automergeHost = _automergeHost;
|
|
3753
|
-
this._ctx = new
|
|
3898
|
+
this._ctx = new import_context9.Context();
|
|
3754
3899
|
this.updated = new import_async12.Event();
|
|
3755
3900
|
this._spaces = new import_util6.ComplexMap(import_keys9.PublicKey.hash);
|
|
3756
3901
|
this._isOpen = false;
|
|
@@ -3939,7 +4084,7 @@ var DataSpaceManager = class {
|
|
|
3939
4084
|
* TODO(dmaretskyi): Consider removing.
|
|
3940
4085
|
*/
|
|
3941
4086
|
async waitUntilSpaceReady(spaceKey) {
|
|
3942
|
-
await (0,
|
|
4087
|
+
await (0, import_context9.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
3943
4088
|
const space = this._spaces.get(spaceKey);
|
|
3944
4089
|
return !!space && space.state === import_services10.SpaceState.READY;
|
|
3945
4090
|
}));
|
|
@@ -4239,10 +4384,12 @@ var SpacesServiceImpl = class {
|
|
|
4239
4384
|
}
|
|
4240
4385
|
}
|
|
4241
4386
|
}
|
|
4242
|
-
async createEpoch({ spaceKey }) {
|
|
4387
|
+
async createEpoch({ spaceKey, migration }) {
|
|
4243
4388
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4244
4389
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
|
|
4245
|
-
await space.createEpoch(
|
|
4390
|
+
await space.createEpoch({
|
|
4391
|
+
migration
|
|
4392
|
+
});
|
|
4246
4393
|
}
|
|
4247
4394
|
_serializeSpace(space) {
|
|
4248
4395
|
return {
|
|
@@ -4284,6 +4431,80 @@ var SpacesServiceImpl = class {
|
|
|
4284
4431
|
}
|
|
4285
4432
|
};
|
|
4286
4433
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
4434
|
+
var createLoadDocuments = (automergeHost) => (
|
|
4435
|
+
/**
|
|
4436
|
+
* Get object data blobs from Automerge Repo by ids.
|
|
4437
|
+
* @param ids
|
|
4438
|
+
*/
|
|
4439
|
+
// TODO(mykola): Unload automerge handles after usage.
|
|
4440
|
+
async function* loadDocuments(ids) {
|
|
4441
|
+
for (const id of ids) {
|
|
4442
|
+
const { documentId, objectId } = import_protocols13.idCodec.decode(id);
|
|
4443
|
+
const handle = automergeHost.repo.find(documentId);
|
|
4444
|
+
await (0, import_debug7.warnAfterTimeout)(5e3, "to long to load doc", () => handle.whenReady());
|
|
4445
|
+
const doc = handle.docSync();
|
|
4446
|
+
const heads = (0, import_automerge.getHeads)(doc);
|
|
4447
|
+
yield [
|
|
4448
|
+
{
|
|
4449
|
+
id,
|
|
4450
|
+
object: doc.objects[objectId],
|
|
4451
|
+
currentHash: heads.at(-1)
|
|
4452
|
+
}
|
|
4453
|
+
];
|
|
4454
|
+
}
|
|
4455
|
+
}
|
|
4456
|
+
);
|
|
4457
|
+
var createGetAllDocuments = (automergeHost) => (
|
|
4458
|
+
/**
|
|
4459
|
+
* Recursively get all object data blobs from Automerge Repo.
|
|
4460
|
+
* @param ids
|
|
4461
|
+
*/
|
|
4462
|
+
// TODO(mykola): Unload automerge handles after usage.
|
|
4463
|
+
async function* getAllDocuments() {
|
|
4464
|
+
const visited = /* @__PURE__ */ new Set();
|
|
4465
|
+
async function* getObjectsFromHandle(handle) {
|
|
4466
|
+
if (visited.has(handle.documentId)) {
|
|
4467
|
+
return;
|
|
4468
|
+
}
|
|
4469
|
+
await (0, import_debug7.warnAfterTimeout)(5e3, "to long to load doc", () => handle.whenReady());
|
|
4470
|
+
const doc = handle.docSync();
|
|
4471
|
+
const heads = (0, import_automerge.getHeads)(doc);
|
|
4472
|
+
if (doc.objects) {
|
|
4473
|
+
yield Object.entries(doc.objects).map(([objectId, object]) => {
|
|
4474
|
+
return {
|
|
4475
|
+
id: import_protocols13.idCodec.encode({
|
|
4476
|
+
documentId: handle.documentId,
|
|
4477
|
+
objectId
|
|
4478
|
+
}),
|
|
4479
|
+
object,
|
|
4480
|
+
currentHash: heads.at(-1)
|
|
4481
|
+
};
|
|
4482
|
+
});
|
|
4483
|
+
}
|
|
4484
|
+
if (doc.links) {
|
|
4485
|
+
for (const id of Object.values(doc.links)) {
|
|
4486
|
+
if (visited.has(id)) {
|
|
4487
|
+
continue;
|
|
4488
|
+
}
|
|
4489
|
+
const linkHandle = automergeHost.repo.find(id);
|
|
4490
|
+
for await (const result of getObjectsFromHandle(linkHandle)) {
|
|
4491
|
+
yield result;
|
|
4492
|
+
}
|
|
4493
|
+
}
|
|
4494
|
+
}
|
|
4495
|
+
visited.add(handle.documentId);
|
|
4496
|
+
}
|
|
4497
|
+
for (const handle of Object.values(automergeHost.repo.handles)) {
|
|
4498
|
+
if (visited.has(handle.documentId)) {
|
|
4499
|
+
continue;
|
|
4500
|
+
}
|
|
4501
|
+
for await (const result of getObjectsFromHandle(handle)) {
|
|
4502
|
+
yield result;
|
|
4503
|
+
}
|
|
4504
|
+
visited.add(handle.documentId);
|
|
4505
|
+
}
|
|
4506
|
+
}
|
|
4507
|
+
);
|
|
4287
4508
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
4288
4509
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4289
4510
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -4307,9 +4528,6 @@ var ServiceContext = class {
|
|
|
4307
4528
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4308
4529
|
this._instanceId = import_keys10.PublicKey.random().toHex();
|
|
4309
4530
|
this.metadataStore = new import_echo_pipeline2.MetadataStore(storage.createDirectory("metadata"));
|
|
4310
|
-
this.indexMetadata = new import_echo_schema.IndexMetadataStore({
|
|
4311
|
-
directory: storage.createDirectory("index-metadata")
|
|
4312
|
-
});
|
|
4313
4531
|
this.snapshotStore = new import_echo_pipeline2.SnapshotStore(storage.createDirectory("snapshots"));
|
|
4314
4532
|
this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
|
|
4315
4533
|
this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
|
|
@@ -4332,10 +4550,21 @@ var ServiceContext = class {
|
|
|
4332
4550
|
snapshotStore: this.snapshotStore
|
|
4333
4551
|
});
|
|
4334
4552
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
4553
|
+
this.indexMetadata = new import_indexing.IndexMetadataStore({
|
|
4554
|
+
directory: storage.createDirectory("index-metadata")
|
|
4555
|
+
});
|
|
4335
4556
|
this.automergeHost = new import_echo_pipeline2.AutomergeHost({
|
|
4336
4557
|
directory: storage.createDirectory("automerge"),
|
|
4337
4558
|
metadata: this.indexMetadata
|
|
4338
4559
|
});
|
|
4560
|
+
this.indexer = new import_indexing.Indexer({
|
|
4561
|
+
indexStore: new import_indexing.IndexStore({
|
|
4562
|
+
directory: storage.createDirectory("index-store")
|
|
4563
|
+
}),
|
|
4564
|
+
metadataStore: this.indexMetadata,
|
|
4565
|
+
loadDocuments: createLoadDocuments(this.automergeHost),
|
|
4566
|
+
getAllDocuments: createGetAllDocuments(this.automergeHost)
|
|
4567
|
+
});
|
|
4339
4568
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4340
4569
|
this._handlerFactories.set(import_services12.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
4341
4570
|
}
|
|
@@ -4343,7 +4572,7 @@ var ServiceContext = class {
|
|
|
4343
4572
|
await this._checkStorageVersion();
|
|
4344
4573
|
(0, import_log13.log)("opening...", void 0, {
|
|
4345
4574
|
F: __dxlog_file15,
|
|
4346
|
-
L:
|
|
4575
|
+
L: 162,
|
|
4347
4576
|
S: this,
|
|
4348
4577
|
C: (f, a) => f(...a)
|
|
4349
4578
|
});
|
|
@@ -4351,7 +4580,7 @@ var ServiceContext = class {
|
|
|
4351
4580
|
id: this._instanceId
|
|
4352
4581
|
}), {
|
|
4353
4582
|
F: __dxlog_file15,
|
|
4354
|
-
L:
|
|
4583
|
+
L: 163,
|
|
4355
4584
|
S: this,
|
|
4356
4585
|
C: (f, a) => f(...a)
|
|
4357
4586
|
});
|
|
@@ -4367,13 +4596,13 @@ var ServiceContext = class {
|
|
|
4367
4596
|
id: this._instanceId
|
|
4368
4597
|
}), {
|
|
4369
4598
|
F: __dxlog_file15,
|
|
4370
|
-
L:
|
|
4599
|
+
L: 173,
|
|
4371
4600
|
S: this,
|
|
4372
4601
|
C: (f, a) => f(...a)
|
|
4373
4602
|
});
|
|
4374
4603
|
(0, import_log13.log)("opened", void 0, {
|
|
4375
4604
|
F: __dxlog_file15,
|
|
4376
|
-
L:
|
|
4605
|
+
L: 174,
|
|
4377
4606
|
S: this,
|
|
4378
4607
|
C: (f, a) => f(...a)
|
|
4379
4608
|
});
|
|
@@ -4381,7 +4610,7 @@ var ServiceContext = class {
|
|
|
4381
4610
|
async close() {
|
|
4382
4611
|
(0, import_log13.log)("closing...", void 0, {
|
|
4383
4612
|
F: __dxlog_file15,
|
|
4384
|
-
L:
|
|
4613
|
+
L: 178,
|
|
4385
4614
|
S: this,
|
|
4386
4615
|
C: (f, a) => f(...a)
|
|
4387
4616
|
});
|
|
@@ -4397,23 +4626,24 @@ var ServiceContext = class {
|
|
|
4397
4626
|
await this.signalManager.close();
|
|
4398
4627
|
this.dataServiceSubscriptions.clear();
|
|
4399
4628
|
await this.metadataStore.close();
|
|
4629
|
+
await this.indexer.destroy();
|
|
4400
4630
|
(0, import_log13.log)("closed", void 0, {
|
|
4401
4631
|
F: __dxlog_file15,
|
|
4402
|
-
L:
|
|
4632
|
+
L: 192,
|
|
4403
4633
|
S: this,
|
|
4404
4634
|
C: (f, a) => f(...a)
|
|
4405
4635
|
});
|
|
4406
4636
|
}
|
|
4407
4637
|
async createIdentity(params = {}) {
|
|
4408
4638
|
const identity = await this.identityManager.createIdentity(params);
|
|
4409
|
-
await this._initialize(new
|
|
4639
|
+
await this._initialize(new import_context10.Context());
|
|
4410
4640
|
return identity;
|
|
4411
4641
|
}
|
|
4412
4642
|
getInvitationHandler(invitation) {
|
|
4413
4643
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4414
4644
|
(0, import_invariant14.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4415
4645
|
F: __dxlog_file15,
|
|
4416
|
-
L:
|
|
4646
|
+
L: 203,
|
|
4417
4647
|
S: this,
|
|
4418
4648
|
A: [
|
|
4419
4649
|
"factory",
|
|
@@ -4432,7 +4662,7 @@ var ServiceContext = class {
|
|
|
4432
4662
|
}
|
|
4433
4663
|
async _acceptIdentity(params) {
|
|
4434
4664
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
4435
|
-
await this._initialize(new
|
|
4665
|
+
await this._initialize(new import_context10.Context());
|
|
4436
4666
|
return identity;
|
|
4437
4667
|
}
|
|
4438
4668
|
async _checkStorageVersion() {
|
|
@@ -4445,7 +4675,7 @@ var ServiceContext = class {
|
|
|
4445
4675
|
async _initialize(ctx) {
|
|
4446
4676
|
(0, import_log13.log)("initializing spaces...", void 0, {
|
|
4447
4677
|
F: __dxlog_file15,
|
|
4448
|
-
L:
|
|
4678
|
+
L: 234,
|
|
4449
4679
|
S: this,
|
|
4450
4680
|
C: (f, a) => f(...a)
|
|
4451
4681
|
});
|
|
@@ -4468,7 +4698,7 @@ var ServiceContext = class {
|
|
|
4468
4698
|
this._handlerFactories.set(import_services12.Invitation.Kind.SPACE, (invitation) => {
|
|
4469
4699
|
(0, import_invariant14.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4470
4700
|
F: __dxlog_file15,
|
|
4471
|
-
L:
|
|
4701
|
+
L: 259,
|
|
4472
4702
|
S: this,
|
|
4473
4703
|
A: [
|
|
4474
4704
|
"this.dataSpaceManager",
|
|
@@ -4492,7 +4722,7 @@ var ServiceContext = class {
|
|
|
4492
4722
|
details: assertion
|
|
4493
4723
|
}, {
|
|
4494
4724
|
F: __dxlog_file15,
|
|
4495
|
-
L:
|
|
4725
|
+
L: 275,
|
|
4496
4726
|
S: this,
|
|
4497
4727
|
C: (f, a) => f(...a)
|
|
4498
4728
|
});
|
|
@@ -4503,7 +4733,7 @@ var ServiceContext = class {
|
|
|
4503
4733
|
details: assertion
|
|
4504
4734
|
}, {
|
|
4505
4735
|
F: __dxlog_file15,
|
|
4506
|
-
L:
|
|
4736
|
+
L: 279,
|
|
4507
4737
|
S: this,
|
|
4508
4738
|
C: (f, a) => f(...a)
|
|
4509
4739
|
});
|
|
@@ -4514,7 +4744,7 @@ var ServiceContext = class {
|
|
|
4514
4744
|
details: assertion
|
|
4515
4745
|
}, {
|
|
4516
4746
|
F: __dxlog_file15,
|
|
4517
|
-
L:
|
|
4747
|
+
L: 284,
|
|
4518
4748
|
S: this,
|
|
4519
4749
|
C: (f, a) => f(...a)
|
|
4520
4750
|
});
|
|
@@ -4525,7 +4755,7 @@ var ServiceContext = class {
|
|
|
4525
4755
|
} catch (err) {
|
|
4526
4756
|
import_log13.log.catch(err, void 0, {
|
|
4527
4757
|
F: __dxlog_file15,
|
|
4528
|
-
L:
|
|
4758
|
+
L: 290,
|
|
4529
4759
|
S: this,
|
|
4530
4760
|
C: (f, a) => f(...a)
|
|
4531
4761
|
});
|
|
@@ -4625,16 +4855,16 @@ var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
|
4625
4855
|
var createStorageObjects = (config) => {
|
|
4626
4856
|
const { persistent = false, keyStore, dataStore, dataRoot = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage" } = config ?? {};
|
|
4627
4857
|
if (persistent && dataStore === StorageDriver.RAM) {
|
|
4628
|
-
throw new
|
|
4858
|
+
throw new import_protocols14.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
4629
4859
|
}
|
|
4630
4860
|
if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
|
|
4631
|
-
throw new
|
|
4861
|
+
throw new import_protocols14.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
4632
4862
|
}
|
|
4633
4863
|
if (persistent && keyStore === StorageDriver.RAM) {
|
|
4634
|
-
throw new
|
|
4864
|
+
throw new import_protocols14.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
4635
4865
|
}
|
|
4636
4866
|
if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
|
|
4637
|
-
throw new
|
|
4867
|
+
throw new import_protocols14.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
4638
4868
|
}
|
|
4639
4869
|
return {
|
|
4640
4870
|
storage: (0, import_random_access_storage.createStorage)({
|
|
@@ -4742,7 +4972,8 @@ var DevicesServiceImpl = class {
|
|
|
4742
4972
|
var LoggingServiceImpl = class {
|
|
4743
4973
|
constructor() {
|
|
4744
4974
|
this._logs = new import_async17.Event();
|
|
4745
|
-
this._started =
|
|
4975
|
+
this._started = Date.now();
|
|
4976
|
+
this._sessionId = import_keys12.PublicKey.random().toHex();
|
|
4746
4977
|
this._logProcessor = (_config, entry2) => {
|
|
4747
4978
|
this._logs.emit(entry2);
|
|
4748
4979
|
};
|
|
@@ -4818,7 +5049,12 @@ var LoggingServiceImpl = class {
|
|
|
4818
5049
|
meta: {
|
|
4819
5050
|
// TODO(dmaretskyi): Fix proto.
|
|
4820
5051
|
file: entry2.meta?.F ?? "",
|
|
4821
|
-
line: entry2.meta?.L ?? 0
|
|
5052
|
+
line: entry2.meta?.L ?? 0,
|
|
5053
|
+
scope: {
|
|
5054
|
+
hostSessionId: this._sessionId,
|
|
5055
|
+
uptimeSeconds: (Date.now() - this._started) / 1e3,
|
|
5056
|
+
name: (0, import_util10.getDebugName)(entry2.meta?.S)
|
|
5057
|
+
}
|
|
4822
5058
|
}
|
|
4823
5059
|
};
|
|
4824
5060
|
try {
|
|
@@ -4977,7 +5213,7 @@ var ClientServicesHost = class {
|
|
|
4977
5213
|
lockKey,
|
|
4978
5214
|
onAcquire: () => {
|
|
4979
5215
|
if (!this._opening) {
|
|
4980
|
-
void this.open(new
|
|
5216
|
+
void this.open(new import_context11.Context());
|
|
4981
5217
|
}
|
|
4982
5218
|
},
|
|
4983
5219
|
onRelease: () => this.close()
|
|
@@ -5033,7 +5269,7 @@ var ClientServicesHost = class {
|
|
|
5033
5269
|
initialize({ config, ...options }) {
|
|
5034
5270
|
(0, import_invariant16.invariant)(!this._open, "service host is open", {
|
|
5035
5271
|
F: __dxlog_file18,
|
|
5036
|
-
L:
|
|
5272
|
+
L: 191,
|
|
5037
5273
|
S: this,
|
|
5038
5274
|
A: [
|
|
5039
5275
|
"!this._open",
|
|
@@ -5042,14 +5278,14 @@ var ClientServicesHost = class {
|
|
|
5042
5278
|
});
|
|
5043
5279
|
(0, import_log15.log)("initializing...", void 0, {
|
|
5044
5280
|
F: __dxlog_file18,
|
|
5045
|
-
L:
|
|
5281
|
+
L: 192,
|
|
5046
5282
|
S: this,
|
|
5047
5283
|
C: (f, a) => f(...a)
|
|
5048
5284
|
});
|
|
5049
5285
|
if (config) {
|
|
5050
5286
|
(0, import_invariant16.invariant)(!this._config, "config already set", {
|
|
5051
5287
|
F: __dxlog_file18,
|
|
5052
|
-
L:
|
|
5288
|
+
L: 195,
|
|
5053
5289
|
S: this,
|
|
5054
5290
|
A: [
|
|
5055
5291
|
"!this._config",
|
|
@@ -5067,7 +5303,7 @@ var ClientServicesHost = class {
|
|
|
5067
5303
|
this._signalManager = signalManager;
|
|
5068
5304
|
(0, import_invariant16.invariant)(!this._networkManager, "network manager already set", {
|
|
5069
5305
|
F: __dxlog_file18,
|
|
5070
|
-
L:
|
|
5306
|
+
L: 211,
|
|
5071
5307
|
S: this,
|
|
5072
5308
|
A: [
|
|
5073
5309
|
"!this._networkManager",
|
|
@@ -5081,7 +5317,7 @@ var ClientServicesHost = class {
|
|
|
5081
5317
|
});
|
|
5082
5318
|
(0, import_log15.log)("initialized", void 0, {
|
|
5083
5319
|
F: __dxlog_file18,
|
|
5084
|
-
L:
|
|
5320
|
+
L: 218,
|
|
5085
5321
|
S: this,
|
|
5086
5322
|
C: (f, a) => f(...a)
|
|
5087
5323
|
});
|
|
@@ -5091,17 +5327,17 @@ var ClientServicesHost = class {
|
|
|
5091
5327
|
return;
|
|
5092
5328
|
}
|
|
5093
5329
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
5094
|
-
import_log15.log.trace("dxos.client-services.host.open",
|
|
5330
|
+
import_log15.log.trace("dxos.client-services.host.open", import_protocols15.trace.begin({
|
|
5095
5331
|
id: traceId
|
|
5096
5332
|
}), {
|
|
5097
5333
|
F: __dxlog_file18,
|
|
5098
|
-
L:
|
|
5334
|
+
L: 229,
|
|
5099
5335
|
S: this,
|
|
5100
5336
|
C: (f, a) => f(...a)
|
|
5101
5337
|
});
|
|
5102
5338
|
(0, import_invariant16.invariant)(this._config, "config not set", {
|
|
5103
5339
|
F: __dxlog_file18,
|
|
5104
|
-
L:
|
|
5340
|
+
L: 231,
|
|
5105
5341
|
S: this,
|
|
5106
5342
|
A: [
|
|
5107
5343
|
"this._config",
|
|
@@ -5110,7 +5346,7 @@ var ClientServicesHost = class {
|
|
|
5110
5346
|
});
|
|
5111
5347
|
(0, import_invariant16.invariant)(this._storage, "storage not set", {
|
|
5112
5348
|
F: __dxlog_file18,
|
|
5113
|
-
L:
|
|
5349
|
+
L: 232,
|
|
5114
5350
|
S: this,
|
|
5115
5351
|
A: [
|
|
5116
5352
|
"this._storage",
|
|
@@ -5119,7 +5355,7 @@ var ClientServicesHost = class {
|
|
|
5119
5355
|
});
|
|
5120
5356
|
(0, import_invariant16.invariant)(this._signalManager, "signal manager not set", {
|
|
5121
5357
|
F: __dxlog_file18,
|
|
5122
|
-
L:
|
|
5358
|
+
L: 233,
|
|
5123
5359
|
S: this,
|
|
5124
5360
|
A: [
|
|
5125
5361
|
"this._signalManager",
|
|
@@ -5128,7 +5364,7 @@ var ClientServicesHost = class {
|
|
|
5128
5364
|
});
|
|
5129
5365
|
(0, import_invariant16.invariant)(this._networkManager, "network manager not set", {
|
|
5130
5366
|
F: __dxlog_file18,
|
|
5131
|
-
L:
|
|
5367
|
+
L: 234,
|
|
5132
5368
|
S: this,
|
|
5133
5369
|
A: [
|
|
5134
5370
|
"this._networkManager",
|
|
@@ -5140,7 +5376,7 @@ var ClientServicesHost = class {
|
|
|
5140
5376
|
lockKey: this._resourceLock?.lockKey
|
|
5141
5377
|
}, {
|
|
5142
5378
|
F: __dxlog_file18,
|
|
5143
|
-
L:
|
|
5379
|
+
L: 237,
|
|
5144
5380
|
S: this,
|
|
5145
5381
|
C: (f, a) => f(...a)
|
|
5146
5382
|
});
|
|
@@ -5150,13 +5386,17 @@ var ClientServicesHost = class {
|
|
|
5150
5386
|
this._serviceRegistry.setServices({
|
|
5151
5387
|
SystemService: this._systemService,
|
|
5152
5388
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
5153
|
-
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation)),
|
|
5389
|
+
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitations, (invitation) => this._serviceContext.getInvitationHandler(invitation), this._serviceContext.metadataStore),
|
|
5154
5390
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
5155
5391
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
5156
5392
|
await this._serviceContext.initialized.wait();
|
|
5157
5393
|
return this._serviceContext.dataSpaceManager;
|
|
5158
5394
|
}),
|
|
5159
5395
|
DataService: new import_echo_pipeline3.DataServiceImpl(this._serviceContext.dataServiceSubscriptions, this._serviceContext.automergeHost),
|
|
5396
|
+
IndexService: new import_indexing2.IndexServiceImpl({
|
|
5397
|
+
indexer: this._serviceContext.indexer,
|
|
5398
|
+
automergeHost: this._serviceContext.automergeHost
|
|
5399
|
+
}),
|
|
5160
5400
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
5161
5401
|
LoggingService: this._loggingService,
|
|
5162
5402
|
TracingService: this._tracingService,
|
|
@@ -5168,6 +5408,24 @@ var ClientServicesHost = class {
|
|
|
5168
5408
|
})
|
|
5169
5409
|
});
|
|
5170
5410
|
await this._serviceContext.open(ctx);
|
|
5411
|
+
(0, import_invariant16.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5412
|
+
F: __dxlog_file18,
|
|
5413
|
+
L: 303,
|
|
5414
|
+
S: this,
|
|
5415
|
+
A: [
|
|
5416
|
+
"this.serviceRegistry.services.InvitationsService",
|
|
5417
|
+
""
|
|
5418
|
+
]
|
|
5419
|
+
});
|
|
5420
|
+
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5421
|
+
(0, import_log15.log)("loaded persistent invitations", {
|
|
5422
|
+
count: loadedInvitations.invitations?.length
|
|
5423
|
+
}, {
|
|
5424
|
+
F: __dxlog_file18,
|
|
5425
|
+
L: 306,
|
|
5426
|
+
S: this,
|
|
5427
|
+
C: (f, a) => f(...a)
|
|
5428
|
+
});
|
|
5171
5429
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
5172
5430
|
if (devtoolsProxy) {
|
|
5173
5431
|
this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
|
|
@@ -5186,15 +5444,15 @@ var ClientServicesHost = class {
|
|
|
5186
5444
|
deviceKey
|
|
5187
5445
|
}, {
|
|
5188
5446
|
F: __dxlog_file18,
|
|
5189
|
-
L:
|
|
5447
|
+
L: 323,
|
|
5190
5448
|
S: this,
|
|
5191
5449
|
C: (f, a) => f(...a)
|
|
5192
5450
|
});
|
|
5193
|
-
import_log15.log.trace("dxos.client-services.host.open",
|
|
5451
|
+
import_log15.log.trace("dxos.client-services.host.open", import_protocols15.trace.end({
|
|
5194
5452
|
id: traceId
|
|
5195
5453
|
}), {
|
|
5196
5454
|
F: __dxlog_file18,
|
|
5197
|
-
L:
|
|
5455
|
+
L: 324,
|
|
5198
5456
|
S: this,
|
|
5199
5457
|
C: (f, a) => f(...a)
|
|
5200
5458
|
});
|
|
@@ -5208,7 +5466,7 @@ var ClientServicesHost = class {
|
|
|
5208
5466
|
deviceKey
|
|
5209
5467
|
}, {
|
|
5210
5468
|
F: __dxlog_file18,
|
|
5211
|
-
L:
|
|
5469
|
+
L: 335,
|
|
5212
5470
|
S: this,
|
|
5213
5471
|
C: (f, a) => f(...a)
|
|
5214
5472
|
});
|
|
@@ -5224,24 +5482,24 @@ var ClientServicesHost = class {
|
|
|
5224
5482
|
deviceKey
|
|
5225
5483
|
}, {
|
|
5226
5484
|
F: __dxlog_file18,
|
|
5227
|
-
L:
|
|
5485
|
+
L: 342,
|
|
5228
5486
|
S: this,
|
|
5229
5487
|
C: (f, a) => f(...a)
|
|
5230
5488
|
});
|
|
5231
5489
|
}
|
|
5232
5490
|
async reset() {
|
|
5233
5491
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
5234
|
-
import_log15.log.trace("dxos.sdk.client-services-host.reset",
|
|
5492
|
+
import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.begin({
|
|
5235
5493
|
id: traceId
|
|
5236
5494
|
}), {
|
|
5237
5495
|
F: __dxlog_file18,
|
|
5238
|
-
L:
|
|
5496
|
+
L: 347,
|
|
5239
5497
|
S: this,
|
|
5240
5498
|
C: (f, a) => f(...a)
|
|
5241
5499
|
});
|
|
5242
5500
|
(0, import_log15.log)("resetting...", void 0, {
|
|
5243
5501
|
F: __dxlog_file18,
|
|
5244
|
-
L:
|
|
5502
|
+
L: 349,
|
|
5245
5503
|
S: this,
|
|
5246
5504
|
C: (f, a) => f(...a)
|
|
5247
5505
|
});
|
|
@@ -5249,15 +5507,15 @@ var ClientServicesHost = class {
|
|
|
5249
5507
|
await this._storage.reset();
|
|
5250
5508
|
(0, import_log15.log)("reset", void 0, {
|
|
5251
5509
|
F: __dxlog_file18,
|
|
5252
|
-
L:
|
|
5510
|
+
L: 352,
|
|
5253
5511
|
S: this,
|
|
5254
5512
|
C: (f, a) => f(...a)
|
|
5255
5513
|
});
|
|
5256
|
-
import_log15.log.trace("dxos.sdk.client-services-host.reset",
|
|
5514
|
+
import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.end({
|
|
5257
5515
|
id: traceId
|
|
5258
5516
|
}), {
|
|
5259
5517
|
F: __dxlog_file18,
|
|
5260
|
-
L:
|
|
5518
|
+
L: 353,
|
|
5261
5519
|
S: this,
|
|
5262
5520
|
C: (f, a) => f(...a)
|
|
5263
5521
|
});
|
|
@@ -5272,7 +5530,7 @@ var ClientServicesHost = class {
|
|
|
5272
5530
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5273
5531
|
(0, import_invariant16.invariant)(automergeIndex, void 0, {
|
|
5274
5532
|
F: __dxlog_file18,
|
|
5275
|
-
L:
|
|
5533
|
+
L: 368,
|
|
5276
5534
|
S: this,
|
|
5277
5535
|
A: [
|
|
5278
5536
|
"automergeIndex",
|
|
@@ -5284,8 +5542,8 @@ var ClientServicesHost = class {
|
|
|
5284
5542
|
document.change((doc) => {
|
|
5285
5543
|
(0, import_util9.assignDeep)(doc, [
|
|
5286
5544
|
"objects",
|
|
5287
|
-
(0,
|
|
5288
|
-
], (0,
|
|
5545
|
+
(0, import_echo_schema.getAutomergeObjectCore)(obj).id
|
|
5546
|
+
], (0, import_echo_schema.getRawDoc)(obj).handle.docSync());
|
|
5289
5547
|
});
|
|
5290
5548
|
return identity;
|
|
5291
5549
|
}
|
|
@@ -5332,6 +5590,7 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5332
5590
|
createDiagnostics,
|
|
5333
5591
|
createStorageObjects,
|
|
5334
5592
|
getNetworkPeers,
|
|
5593
|
+
invitationExpired,
|
|
5335
5594
|
isLocked,
|
|
5336
5595
|
subscribeToFeedBlocks,
|
|
5337
5596
|
subscribeToFeeds,
|
|
@@ -5341,4 +5600,4 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5341
5600
|
subscribeToSpaces,
|
|
5342
5601
|
subscribeToSwarmInfo
|
|
5343
5602
|
});
|
|
5344
|
-
//# sourceMappingURL=chunk-
|
|
5603
|
+
//# sourceMappingURL=chunk-VDSDEN45.cjs.map
|