@dxos/client-services 0.5.9-main.44fe51d → 0.5.9-main.4c63b2f
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-A4GBBLY6.mjs → chunk-X35KRIRP.mjs} +228 -196
- package/dist/lib/browser/chunk-X35KRIRP.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-X2MLOLTD.cjs → chunk-DG6DPGCI.cjs} +324 -292
- package/dist/lib/node/chunk-DG6DPGCI.cjs.map +7 -0
- package/dist/lib/node/index.cjs +41 -41
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +8 -8
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +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 +36 -36
- package/src/packlets/identity/identity-service.ts +27 -6
- package/src/packlets/spaces/data-space.ts +5 -5
- package/src/packlets/spaces/spaces-service.ts +12 -2
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-A4GBBLY6.mjs.map +0 -7
- package/dist/lib/node/chunk-X2MLOLTD.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_DG6DPGCI_exports = {};
|
|
30
|
+
__export(chunk_DG6DPGCI_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
33
|
ClientServicesProviderResource: () => ClientServicesProviderResource,
|
|
@@ -66,7 +66,7 @@ __export(chunk_X2MLOLTD_exports, {
|
|
|
66
66
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
67
67
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
68
68
|
});
|
|
69
|
-
module.exports = __toCommonJS(
|
|
69
|
+
module.exports = __toCommonJS(chunk_DG6DPGCI_exports);
|
|
70
70
|
var import_async = require("@dxos/async");
|
|
71
71
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
72
72
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -126,72 +126,75 @@ var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip"
|
|
|
126
126
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
127
127
|
var import_tracing4 = require("@dxos/tracing");
|
|
128
128
|
var import_util3 = require("@dxos/util");
|
|
129
|
+
var import_async8 = require("@dxos/async");
|
|
129
130
|
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
130
131
|
var import_context4 = require("@dxos/context");
|
|
131
132
|
var import_credentials8 = require("@dxos/credentials");
|
|
132
133
|
var import_debug2 = require("@dxos/debug");
|
|
133
134
|
var import_invariant4 = require("@dxos/invariant");
|
|
135
|
+
var import_log5 = require("@dxos/log");
|
|
134
136
|
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
137
|
+
var import_util4 = require("@dxos/util");
|
|
135
138
|
var import_invariant5 = require("@dxos/invariant");
|
|
136
139
|
var import_protocols4 = require("@dxos/protocols");
|
|
137
140
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
138
|
-
var
|
|
141
|
+
var import_async9 = require("@dxos/async");
|
|
139
142
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
140
143
|
var import_context5 = require("@dxos/context");
|
|
141
144
|
var import_crypto = require("@dxos/crypto");
|
|
142
145
|
var import_invariant6 = require("@dxos/invariant");
|
|
143
146
|
var import_keys6 = require("@dxos/keys");
|
|
144
|
-
var
|
|
147
|
+
var import_log6 = require("@dxos/log");
|
|
145
148
|
var import_network_manager = require("@dxos/network-manager");
|
|
146
149
|
var import_protocols5 = require("@dxos/protocols");
|
|
147
150
|
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
148
151
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
149
152
|
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
150
|
-
var
|
|
151
|
-
var
|
|
153
|
+
var import_util5 = require("@dxos/util");
|
|
154
|
+
var import_async10 = require("@dxos/async");
|
|
152
155
|
var import_context6 = require("@dxos/context");
|
|
153
156
|
var import_invariant7 = require("@dxos/invariant");
|
|
154
|
-
var
|
|
157
|
+
var import_log7 = require("@dxos/log");
|
|
155
158
|
var import_protocols6 = require("@dxos/protocols");
|
|
156
159
|
var import_invitations3 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
157
160
|
var import_teleport = require("@dxos/teleport");
|
|
158
161
|
var import_context7 = require("@dxos/context");
|
|
159
162
|
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
160
|
-
var
|
|
163
|
+
var import_async11 = require("@dxos/async");
|
|
161
164
|
var import_context8 = require("@dxos/context");
|
|
162
165
|
var import_crypto2 = require("@dxos/crypto");
|
|
163
166
|
var import_invariant8 = require("@dxos/invariant");
|
|
164
167
|
var import_keys7 = require("@dxos/keys");
|
|
165
|
-
var
|
|
168
|
+
var import_log8 = require("@dxos/log");
|
|
166
169
|
var import_protocols7 = require("@dxos/protocols");
|
|
167
170
|
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
168
171
|
var import_invitations4 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
169
172
|
var import_teleport2 = require("@dxos/teleport");
|
|
170
173
|
var import_invariant9 = require("@dxos/invariant");
|
|
171
174
|
var import_keys8 = require("@dxos/keys");
|
|
172
|
-
var
|
|
175
|
+
var import_log9 = require("@dxos/log");
|
|
173
176
|
var import_invitations5 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
174
|
-
var
|
|
177
|
+
var import_util6 = require("@dxos/util");
|
|
175
178
|
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
176
179
|
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
177
180
|
var import_credentials9 = require("@dxos/credentials");
|
|
178
181
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
179
182
|
var import_invariant10 = require("@dxos/invariant");
|
|
180
|
-
var
|
|
183
|
+
var import_log10 = require("@dxos/log");
|
|
181
184
|
var import_protocols8 = require("@dxos/protocols");
|
|
182
185
|
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
183
186
|
var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
184
|
-
var
|
|
187
|
+
var import_async12 = require("@dxos/async");
|
|
185
188
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
186
189
|
var import_context9 = require("@dxos/context");
|
|
187
190
|
var import_credentials11 = require("@dxos/credentials");
|
|
188
191
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
189
192
|
var import_invariant11 = require("@dxos/invariant");
|
|
190
193
|
var import_keys9 = require("@dxos/keys");
|
|
191
|
-
var
|
|
194
|
+
var import_log11 = require("@dxos/log");
|
|
192
195
|
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
193
196
|
var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
194
|
-
var
|
|
197
|
+
var import_async13 = require("@dxos/async");
|
|
195
198
|
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
196
199
|
var import_context10 = require("@dxos/context");
|
|
197
200
|
var import_debug3 = require("@dxos/debug");
|
|
@@ -199,35 +202,35 @@ var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
|
199
202
|
var import_echo_protocol = require("@dxos/echo-protocol");
|
|
200
203
|
var import_invariant12 = require("@dxos/invariant");
|
|
201
204
|
var import_keys10 = require("@dxos/keys");
|
|
202
|
-
var
|
|
205
|
+
var import_log12 = require("@dxos/log");
|
|
203
206
|
var import_protocols9 = require("@dxos/protocols");
|
|
204
207
|
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
205
208
|
var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
206
209
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
207
210
|
var import_tracing5 = require("@dxos/tracing");
|
|
208
|
-
var
|
|
209
|
-
var
|
|
211
|
+
var import_util7 = require("@dxos/util");
|
|
212
|
+
var import_async14 = require("@dxos/async");
|
|
210
213
|
var import_context11 = require("@dxos/context");
|
|
211
214
|
var import_credentials14 = require("@dxos/credentials");
|
|
212
|
-
var
|
|
215
|
+
var import_async15 = require("@dxos/async");
|
|
213
216
|
var import_automerge = require("@dxos/automerge/automerge");
|
|
214
217
|
var import_context12 = require("@dxos/context");
|
|
215
218
|
var import_echo_db = require("@dxos/echo-db");
|
|
216
219
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
217
220
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
218
221
|
var import_invariant13 = require("@dxos/invariant");
|
|
219
|
-
var
|
|
222
|
+
var import_log13 = require("@dxos/log");
|
|
220
223
|
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
221
|
-
var
|
|
222
|
-
var
|
|
224
|
+
var import_util8 = require("@dxos/util");
|
|
225
|
+
var import_async16 = require("@dxos/async");
|
|
223
226
|
var import_context13 = require("@dxos/context");
|
|
224
227
|
var import_invariant14 = require("@dxos/invariant");
|
|
225
228
|
var import_keys11 = require("@dxos/keys");
|
|
226
|
-
var
|
|
229
|
+
var import_log14 = require("@dxos/log");
|
|
227
230
|
var import_protocols10 = require("@dxos/protocols");
|
|
228
231
|
var import_teleport3 = require("@dxos/teleport");
|
|
229
|
-
var
|
|
230
|
-
var
|
|
232
|
+
var import_util9 = require("@dxos/util");
|
|
233
|
+
var import_async17 = require("@dxos/async");
|
|
231
234
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
232
235
|
var import_context14 = require("@dxos/context");
|
|
233
236
|
var import_credentials15 = require("@dxos/credentials");
|
|
@@ -237,28 +240,28 @@ var import_echo_protocol2 = require("@dxos/echo-protocol");
|
|
|
237
240
|
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
238
241
|
var import_invariant15 = require("@dxos/invariant");
|
|
239
242
|
var import_keys12 = require("@dxos/keys");
|
|
240
|
-
var
|
|
243
|
+
var import_log15 = require("@dxos/log");
|
|
241
244
|
var import_protocols11 = require("@dxos/protocols");
|
|
242
245
|
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
243
246
|
var import_credentials16 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
244
247
|
var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
|
|
245
248
|
var import_tracing6 = require("@dxos/tracing");
|
|
246
|
-
var
|
|
249
|
+
var import_util10 = require("@dxos/util");
|
|
247
250
|
var import_credentials17 = require("@dxos/credentials");
|
|
248
251
|
var import_debug4 = require("@dxos/debug");
|
|
249
252
|
var import_credentials18 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
250
253
|
var import_timeframe4 = require("@dxos/timeframe");
|
|
251
|
-
var
|
|
254
|
+
var import_async18 = require("@dxos/async");
|
|
252
255
|
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
253
256
|
var import_credentials19 = require("@dxos/credentials");
|
|
254
257
|
var import_debug5 = require("@dxos/debug");
|
|
255
258
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
256
259
|
var import_invariant16 = require("@dxos/invariant");
|
|
257
|
-
var
|
|
260
|
+
var import_log16 = require("@dxos/log");
|
|
258
261
|
var import_protocols12 = require("@dxos/protocols");
|
|
259
262
|
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
260
263
|
var import_tracing7 = require("@dxos/tracing");
|
|
261
|
-
var
|
|
264
|
+
var import_async19 = require("@dxos/async");
|
|
262
265
|
var import_context15 = require("@dxos/context");
|
|
263
266
|
var import_credentials20 = require("@dxos/credentials");
|
|
264
267
|
var import_debug6 = require("@dxos/debug");
|
|
@@ -268,56 +271,56 @@ var import_feed_store5 = require("@dxos/feed-store");
|
|
|
268
271
|
var import_invariant17 = require("@dxos/invariant");
|
|
269
272
|
var import_keyring = require("@dxos/keyring");
|
|
270
273
|
var import_keys13 = require("@dxos/keys");
|
|
271
|
-
var
|
|
274
|
+
var import_log17 = require("@dxos/log");
|
|
272
275
|
var import_protocols13 = require("@dxos/protocols");
|
|
273
276
|
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
274
277
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
275
278
|
var import_tracing8 = require("@dxos/tracing");
|
|
276
|
-
var
|
|
279
|
+
var import_util11 = require("@dxos/util");
|
|
277
280
|
var import_invariant18 = require("@dxos/invariant");
|
|
278
281
|
var import_lock_file = require("@dxos/lock-file");
|
|
279
|
-
var
|
|
282
|
+
var import_log18 = require("@dxos/log");
|
|
280
283
|
var import_protocols14 = require("@dxos/protocols");
|
|
281
284
|
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
282
285
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
283
286
|
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
284
287
|
var import_config2 = require("@dxos/protocols/proto/dxos/config");
|
|
285
|
-
var
|
|
288
|
+
var import_util12 = require("@dxos/util");
|
|
286
289
|
var import_node_path = __toESM(require("node:path"));
|
|
287
290
|
var import_keys14 = require("@dxos/keys");
|
|
288
291
|
var import_kv_store = require("@dxos/kv-store");
|
|
289
|
-
var
|
|
292
|
+
var import_async20 = require("@dxos/async");
|
|
290
293
|
var import_client_protocol7 = require("@dxos/client-protocol");
|
|
291
294
|
var import_context16 = require("@dxos/context");
|
|
292
295
|
var import_invariant19 = require("@dxos/invariant");
|
|
293
296
|
var import_keys15 = require("@dxos/keys");
|
|
294
|
-
var
|
|
297
|
+
var import_log19 = require("@dxos/log");
|
|
295
298
|
var import_messaging = require("@dxos/messaging");
|
|
296
299
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
297
300
|
var import_protocols15 = require("@dxos/protocols");
|
|
298
301
|
var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
|
|
299
302
|
var import_tracing9 = require("@dxos/tracing");
|
|
300
303
|
var import_websocket_rpc = require("@dxos/websocket-rpc");
|
|
301
|
-
var
|
|
304
|
+
var import_async21 = require("@dxos/async");
|
|
302
305
|
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
303
306
|
var import_invariant20 = require("@dxos/invariant");
|
|
304
307
|
var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
|
|
305
308
|
var import_config3 = require("@dxos/config");
|
|
306
309
|
var import_services19 = require("@dxos/protocols/proto/dxos/client/services");
|
|
307
310
|
var import_tracing10 = require("@dxos/tracing");
|
|
308
|
-
var import_util12 = require("@dxos/util");
|
|
309
|
-
var import_keys16 = require("@dxos/keys");
|
|
310
311
|
var import_util13 = require("@dxos/util");
|
|
311
|
-
var
|
|
312
|
+
var import_keys16 = require("@dxos/keys");
|
|
313
|
+
var import_util14 = require("@dxos/util");
|
|
314
|
+
var import_async22 = require("@dxos/async");
|
|
312
315
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
313
316
|
var import_keys17 = require("@dxos/keys");
|
|
314
|
-
var
|
|
317
|
+
var import_log20 = require("@dxos/log");
|
|
315
318
|
var import_services20 = require("@dxos/protocols/proto/dxos/client/services");
|
|
316
|
-
var
|
|
319
|
+
var import_util15 = require("@dxos/util");
|
|
317
320
|
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
318
321
|
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
319
322
|
var import_services21 = require("@dxos/protocols/proto/dxos/client/services");
|
|
320
|
-
var
|
|
323
|
+
var import_util16 = require("@dxos/util");
|
|
321
324
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
322
325
|
return new import_codec_protobuf.Stream(({ next }) => {
|
|
323
326
|
const subscriptions = new import_async.EventSubscriptions();
|
|
@@ -628,7 +631,7 @@ var DevtoolsServiceImpl = class {
|
|
|
628
631
|
});
|
|
629
632
|
}
|
|
630
633
|
};
|
|
631
|
-
var DXOS_VERSION = "0.5.9-main.
|
|
634
|
+
var DXOS_VERSION = "0.5.9-main.4c63b2f";
|
|
632
635
|
var getPlatform = () => {
|
|
633
636
|
if (process.browser) {
|
|
634
637
|
if (typeof window !== "undefined") {
|
|
@@ -1657,6 +1660,7 @@ IdentityManager = _ts_decorate3([
|
|
|
1657
1660
|
import_tracing4.trace.resource()
|
|
1658
1661
|
], IdentityManager);
|
|
1659
1662
|
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
1663
|
+
var DEFAULT_SPACE_SEARCH_TIMEOUT = 1e4;
|
|
1660
1664
|
var IdentityServiceImpl = class extends import_context4.Resource {
|
|
1661
1665
|
constructor(_identityManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
|
|
1662
1666
|
super();
|
|
@@ -1686,7 +1690,7 @@ var IdentityServiceImpl = class extends import_context4.Resource {
|
|
|
1686
1690
|
const identity = this._identityManager.identity;
|
|
1687
1691
|
(0, import_invariant4.invariant)(identity, void 0, {
|
|
1688
1692
|
F: __dxlog_file6,
|
|
1689
|
-
L:
|
|
1693
|
+
L: 59,
|
|
1690
1694
|
S: this,
|
|
1691
1695
|
A: [
|
|
1692
1696
|
"identity",
|
|
@@ -1720,7 +1724,7 @@ var IdentityServiceImpl = class extends import_context4.Resource {
|
|
|
1720
1724
|
async updateProfile(profile) {
|
|
1721
1725
|
(0, import_invariant4.invariant)(this._identityManager.identity, "Identity not initialized.", {
|
|
1722
1726
|
F: __dxlog_file6,
|
|
1723
|
-
L:
|
|
1727
|
+
L: 89,
|
|
1724
1728
|
S: this,
|
|
1725
1729
|
A: [
|
|
1726
1730
|
"this._identityManager.identity",
|
|
@@ -1734,7 +1738,7 @@ var IdentityServiceImpl = class extends import_context4.Resource {
|
|
|
1734
1738
|
async signPresentation({ presentation, nonce }) {
|
|
1735
1739
|
(0, import_invariant4.invariant)(this._identityManager.identity, "Identity not initialized.", {
|
|
1736
1740
|
F: __dxlog_file6,
|
|
1737
|
-
L:
|
|
1741
|
+
L: 96,
|
|
1738
1742
|
S: this,
|
|
1739
1743
|
A: [
|
|
1740
1744
|
"this._identityManager.identity",
|
|
@@ -1750,9 +1754,11 @@ var IdentityServiceImpl = class extends import_context4.Resource {
|
|
|
1750
1754
|
});
|
|
1751
1755
|
}
|
|
1752
1756
|
async _fixIdentityWithoutDefaultSpace(identity) {
|
|
1753
|
-
let
|
|
1757
|
+
let recodedDefaultSpace = false;
|
|
1758
|
+
let foundDefaultSpace = false;
|
|
1754
1759
|
const dataSpaceManager = this._dataSpaceManagerProvider();
|
|
1755
|
-
|
|
1760
|
+
const recordedDefaultSpaceTrigger = new import_async8.Trigger();
|
|
1761
|
+
const allProcessed = (0, import_util4.safeAwaitAll)(dataSpaceManager.spaces.values(), async (space) => {
|
|
1756
1762
|
if (space.state === import_services4.SpaceState.CLOSED) {
|
|
1757
1763
|
await space.open();
|
|
1758
1764
|
const requiresMigration = space.stateUpdate.waitForCondition(() => space.state === import_services4.SpaceState.REQUIRES_MIGRATION);
|
|
@@ -1762,12 +1768,29 @@ var IdentityServiceImpl = class extends import_context4.Resource {
|
|
|
1762
1768
|
]);
|
|
1763
1769
|
}
|
|
1764
1770
|
if (await dataSpaceManager.isDefaultSpace(space)) {
|
|
1771
|
+
if (foundDefaultSpace) {
|
|
1772
|
+
import_log5.log.warn("Multiple default spaces found. Using the first one.", {
|
|
1773
|
+
duplicate: space.id
|
|
1774
|
+
}, {
|
|
1775
|
+
F: __dxlog_file6,
|
|
1776
|
+
L: 127,
|
|
1777
|
+
S: this,
|
|
1778
|
+
C: (f, a) => f(...a)
|
|
1779
|
+
});
|
|
1780
|
+
return;
|
|
1781
|
+
}
|
|
1782
|
+
foundDefaultSpace = true;
|
|
1765
1783
|
await identity.updateDefaultSpace(space.id);
|
|
1766
|
-
|
|
1767
|
-
|
|
1784
|
+
recodedDefaultSpace = true;
|
|
1785
|
+
recordedDefaultSpaceTrigger.wake();
|
|
1768
1786
|
}
|
|
1769
|
-
}
|
|
1770
|
-
|
|
1787
|
+
});
|
|
1788
|
+
await Promise.race([
|
|
1789
|
+
allProcessed,
|
|
1790
|
+
recordedDefaultSpaceTrigger.wait(),
|
|
1791
|
+
(0, import_async8.sleep)(DEFAULT_SPACE_SEARCH_TIMEOUT)
|
|
1792
|
+
]);
|
|
1793
|
+
if (!recodedDefaultSpace) {
|
|
1771
1794
|
await this._createDefaultSpace(dataSpaceManager);
|
|
1772
1795
|
}
|
|
1773
1796
|
}
|
|
@@ -1908,7 +1931,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1908
1931
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
1909
1932
|
this._callbacks = _callbacks;
|
|
1910
1933
|
this._ctx = new import_context6.Context();
|
|
1911
|
-
this._remoteOptionsTrigger = new
|
|
1934
|
+
this._remoteOptionsTrigger = new import_async10.Trigger();
|
|
1912
1935
|
this._invitationFlowLock = null;
|
|
1913
1936
|
}
|
|
1914
1937
|
hasFlowLock() {
|
|
@@ -1945,14 +1968,14 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1945
1968
|
async onOpen(context) {
|
|
1946
1969
|
await super.onOpen(context);
|
|
1947
1970
|
try {
|
|
1948
|
-
(0,
|
|
1971
|
+
(0, import_log7.log)("guest acquire lock", void 0, {
|
|
1949
1972
|
F: __dxlog_file8,
|
|
1950
1973
|
L: 84,
|
|
1951
1974
|
S: this,
|
|
1952
1975
|
C: (f, a) => f(...a)
|
|
1953
1976
|
});
|
|
1954
1977
|
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
1955
|
-
(0,
|
|
1978
|
+
(0, import_log7.log)("guest lock acquired", void 0, {
|
|
1956
1979
|
F: __dxlog_file8,
|
|
1957
1980
|
L: 86,
|
|
1958
1981
|
S: this,
|
|
@@ -1961,7 +1984,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1961
1984
|
await (0, import_context6.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
|
|
1962
1985
|
role: import_invitations3.Options.Role.GUEST
|
|
1963
1986
|
}));
|
|
1964
|
-
(0,
|
|
1987
|
+
(0, import_log7.log)("options sent", void 0, {
|
|
1965
1988
|
F: __dxlog_file8,
|
|
1966
1989
|
L: 88,
|
|
1967
1990
|
S: this,
|
|
@@ -1970,7 +1993,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1970
1993
|
await (0, import_context6.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1971
1994
|
timeout: OPTIONS_TIMEOUT
|
|
1972
1995
|
}));
|
|
1973
|
-
(0,
|
|
1996
|
+
(0, import_log7.log)("options received", void 0, {
|
|
1974
1997
|
F: __dxlog_file8,
|
|
1975
1998
|
L: 90,
|
|
1976
1999
|
S: this,
|
|
@@ -2004,7 +2027,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
2004
2027
|
if (this._invitationFlowLock != null) {
|
|
2005
2028
|
this._invitationFlowLock.release();
|
|
2006
2029
|
this._invitationFlowLock = null;
|
|
2007
|
-
(0,
|
|
2030
|
+
(0, import_log7.log)("invitation flow lock released", void 0, {
|
|
2008
2031
|
F: __dxlog_file8,
|
|
2009
2032
|
L: 123,
|
|
2010
2033
|
S: this,
|
|
@@ -2029,12 +2052,12 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2029
2052
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
2030
2053
|
this._callbacks = _callbacks;
|
|
2031
2054
|
this._ctx = new import_context8.Context();
|
|
2032
|
-
this._remoteOptionsTrigger = new
|
|
2055
|
+
this._remoteOptionsTrigger = new import_async11.Trigger();
|
|
2033
2056
|
this._challenge = void 0;
|
|
2034
2057
|
this.guestProfile = void 0;
|
|
2035
2058
|
this.authenticationPassed = false;
|
|
2036
2059
|
this.authenticationRetry = 0;
|
|
2037
|
-
this.completedTrigger = new
|
|
2060
|
+
this.completedTrigger = new import_async11.Trigger();
|
|
2038
2061
|
this._invitationFlowLock = null;
|
|
2039
2062
|
}
|
|
2040
2063
|
hasFlowLock() {
|
|
@@ -2061,7 +2084,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2061
2084
|
introduce: async (request) => {
|
|
2062
2085
|
const { profile, invitationId } = request;
|
|
2063
2086
|
const traceId = import_keys7.PublicKey.random().toHex();
|
|
2064
|
-
|
|
2087
|
+
import_log8.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols7.trace.begin({
|
|
2065
2088
|
id: traceId
|
|
2066
2089
|
}), {
|
|
2067
2090
|
F: __dxlog_file9,
|
|
@@ -2072,7 +2095,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2072
2095
|
const invitation = this._requireActiveInvitation();
|
|
2073
2096
|
this._assertInvitationState(import_services8.Invitation.State.CONNECTED);
|
|
2074
2097
|
if (invitationId !== invitation?.invitationId) {
|
|
2075
|
-
|
|
2098
|
+
import_log8.log.warn("incorrect invitationId", {
|
|
2076
2099
|
expected: invitation.invitationId,
|
|
2077
2100
|
actual: invitationId
|
|
2078
2101
|
}, {
|
|
@@ -2082,12 +2105,12 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2082
2105
|
C: (f, a) => f(...a)
|
|
2083
2106
|
});
|
|
2084
2107
|
this._callbacks.onError(new Error("Incorrect invitationId."));
|
|
2085
|
-
(0,
|
|
2108
|
+
(0, import_async11.scheduleTask)(this._ctx, () => this.close());
|
|
2086
2109
|
return {
|
|
2087
2110
|
authMethod: import_services8.Invitation.AuthMethod.NONE
|
|
2088
2111
|
};
|
|
2089
2112
|
}
|
|
2090
|
-
(0,
|
|
2113
|
+
(0, import_log8.log)("guest introduced themselves", {
|
|
2091
2114
|
guestProfile: profile
|
|
2092
2115
|
}, {
|
|
2093
2116
|
F: __dxlog_file9,
|
|
@@ -2098,7 +2121,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2098
2121
|
this.guestProfile = profile;
|
|
2099
2122
|
this._callbacks.onStateUpdate(import_services8.Invitation.State.READY_FOR_AUTHENTICATION);
|
|
2100
2123
|
this._challenge = invitation.authMethod === import_services8.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto2.randomBytes)(32) : void 0;
|
|
2101
|
-
|
|
2124
|
+
import_log8.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols7.trace.end({
|
|
2102
2125
|
id: traceId
|
|
2103
2126
|
}), {
|
|
2104
2127
|
F: __dxlog_file9,
|
|
@@ -2113,7 +2136,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2113
2136
|
},
|
|
2114
2137
|
authenticate: async ({ authCode: code, signedChallenge }) => {
|
|
2115
2138
|
const traceId = import_keys7.PublicKey.random().toHex();
|
|
2116
|
-
|
|
2139
|
+
import_log8.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols7.trace.begin({
|
|
2117
2140
|
id: traceId
|
|
2118
2141
|
}), {
|
|
2119
2142
|
F: __dxlog_file9,
|
|
@@ -2122,7 +2145,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2122
2145
|
C: (f, a) => f(...a)
|
|
2123
2146
|
});
|
|
2124
2147
|
const invitation = this._requireActiveInvitation();
|
|
2125
|
-
(0,
|
|
2148
|
+
(0, import_log8.log)("received authentication request", {
|
|
2126
2149
|
authCode: code
|
|
2127
2150
|
}, {
|
|
2128
2151
|
F: __dxlog_file9,
|
|
@@ -2138,7 +2161,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2138
2161
|
this._callbacks.onStateUpdate(import_services8.Invitation.State.AUTHENTICATING);
|
|
2139
2162
|
switch (invitation.authMethod) {
|
|
2140
2163
|
case import_services8.Invitation.AuthMethod.NONE: {
|
|
2141
|
-
(0,
|
|
2164
|
+
(0, import_log8.log)("authentication not required", void 0, {
|
|
2142
2165
|
F: __dxlog_file9,
|
|
2143
2166
|
L: 152,
|
|
2144
2167
|
S: this,
|
|
@@ -2174,7 +2197,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2174
2197
|
break;
|
|
2175
2198
|
}
|
|
2176
2199
|
default: {
|
|
2177
|
-
|
|
2200
|
+
import_log8.log.error("invalid authentication method", {
|
|
2178
2201
|
authMethod: invitation.authMethod
|
|
2179
2202
|
}, {
|
|
2180
2203
|
F: __dxlog_file9,
|
|
@@ -2191,12 +2214,12 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2191
2214
|
import_invitations4.AuthenticationResponse.Status.INVALID_OTP
|
|
2192
2215
|
].includes(status)) {
|
|
2193
2216
|
this._callbacks.onError(new Error(`Authentication failed, with status=${status}`));
|
|
2194
|
-
(0,
|
|
2217
|
+
(0, import_async11.scheduleTask)(this._ctx, () => this.close());
|
|
2195
2218
|
return {
|
|
2196
2219
|
status
|
|
2197
2220
|
};
|
|
2198
2221
|
}
|
|
2199
|
-
|
|
2222
|
+
import_log8.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols7.trace.end({
|
|
2200
2223
|
id: traceId,
|
|
2201
2224
|
data: {
|
|
2202
2225
|
status
|
|
@@ -2213,7 +2236,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2213
2236
|
},
|
|
2214
2237
|
admit: async (request) => {
|
|
2215
2238
|
const traceId = import_keys7.PublicKey.random().toHex();
|
|
2216
|
-
|
|
2239
|
+
import_log8.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols7.trace.begin({
|
|
2217
2240
|
id: traceId
|
|
2218
2241
|
}), {
|
|
2219
2242
|
F: __dxlog_file9,
|
|
@@ -2230,7 +2253,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2230
2253
|
}
|
|
2231
2254
|
}
|
|
2232
2255
|
const response = await this._callbacks.admit(request);
|
|
2233
|
-
|
|
2256
|
+
import_log8.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols7.trace.end({
|
|
2234
2257
|
id: traceId
|
|
2235
2258
|
}), {
|
|
2236
2259
|
F: __dxlog_file9,
|
|
@@ -2250,14 +2273,14 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2250
2273
|
async onOpen(context) {
|
|
2251
2274
|
await super.onOpen(context);
|
|
2252
2275
|
try {
|
|
2253
|
-
(0,
|
|
2276
|
+
(0, import_log8.log)("host acquire lock", void 0, {
|
|
2254
2277
|
F: __dxlog_file9,
|
|
2255
2278
|
L: 237,
|
|
2256
2279
|
S: this,
|
|
2257
2280
|
C: (f, a) => f(...a)
|
|
2258
2281
|
});
|
|
2259
2282
|
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
2260
|
-
(0,
|
|
2283
|
+
(0, import_log8.log)("host lock acquired", void 0, {
|
|
2261
2284
|
F: __dxlog_file9,
|
|
2262
2285
|
L: 239,
|
|
2263
2286
|
S: this,
|
|
@@ -2268,7 +2291,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2268
2291
|
await this.rpc.InvitationHostService.options({
|
|
2269
2292
|
role: import_invitations4.Options.Role.HOST
|
|
2270
2293
|
});
|
|
2271
|
-
(0,
|
|
2294
|
+
(0, import_log8.log)("options sent", void 0, {
|
|
2272
2295
|
F: __dxlog_file9,
|
|
2273
2296
|
L: 243,
|
|
2274
2297
|
S: this,
|
|
@@ -2277,7 +2300,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2277
2300
|
await (0, import_context8.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
2278
2301
|
timeout: OPTIONS_TIMEOUT2
|
|
2279
2302
|
}));
|
|
2280
|
-
(0,
|
|
2303
|
+
(0, import_log8.log)("options received", void 0, {
|
|
2281
2304
|
F: __dxlog_file9,
|
|
2282
2305
|
L: 245,
|
|
2283
2306
|
S: this,
|
|
@@ -2305,7 +2328,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2305
2328
|
_requireActiveInvitation() {
|
|
2306
2329
|
const invitation = this._callbacks.activeInvitation;
|
|
2307
2330
|
if (invitation == null) {
|
|
2308
|
-
(0,
|
|
2331
|
+
(0, import_async11.scheduleTask)(this._ctx, () => this.close());
|
|
2309
2332
|
throw new Error("Active invitation not found");
|
|
2310
2333
|
}
|
|
2311
2334
|
return invitation;
|
|
@@ -2316,7 +2339,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2316
2339
|
stateOrMany
|
|
2317
2340
|
];
|
|
2318
2341
|
if (!validStates.includes(invitation.state)) {
|
|
2319
|
-
(0,
|
|
2342
|
+
(0, import_async11.scheduleTask)(this._ctx, () => this.close());
|
|
2320
2343
|
throw new import_invariant8.InvariantViolation(`Expected ${stateToString(invitation.state)} to be one of [${validStates.map(stateToString).join(", ")}]`);
|
|
2321
2344
|
}
|
|
2322
2345
|
}
|
|
@@ -2331,7 +2354,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2331
2354
|
if (this._invitationFlowLock != null) {
|
|
2332
2355
|
this._invitationFlowLock?.release();
|
|
2333
2356
|
this._invitationFlowLock = null;
|
|
2334
|
-
(0,
|
|
2357
|
+
(0, import_log8.log)("invitation flow lock released", void 0, {
|
|
2335
2358
|
F: __dxlog_file9,
|
|
2336
2359
|
L: 300,
|
|
2337
2360
|
S: this,
|
|
@@ -2345,7 +2368,7 @@ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
|
|
|
2345
2368
|
var InvitationTopology = class {
|
|
2346
2369
|
constructor(_role) {
|
|
2347
2370
|
this._role = _role;
|
|
2348
|
-
this._seenPeers = new
|
|
2371
|
+
this._seenPeers = new import_util6.ComplexSet(import_keys8.PublicKey.hash);
|
|
2349
2372
|
}
|
|
2350
2373
|
init(controller) {
|
|
2351
2374
|
(0, import_invariant9.invariant)(!this._controller, "Already initialized.", {
|
|
@@ -2378,9 +2401,9 @@ var InvitationTopology = class {
|
|
|
2378
2401
|
return;
|
|
2379
2402
|
}
|
|
2380
2403
|
const firstUnknownPeer = candidates.find((peerId) => !this._seenPeers.has(peerId));
|
|
2381
|
-
this._seenPeers = new
|
|
2404
|
+
this._seenPeers = new import_util6.ComplexSet(import_keys8.PublicKey.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
|
|
2382
2405
|
if (firstUnknownPeer != null) {
|
|
2383
|
-
(0,
|
|
2406
|
+
(0, import_log9.log)("invitation connect", {
|
|
2384
2407
|
ownPeerId,
|
|
2385
2408
|
remotePeerId: firstUnknownPeer
|
|
2386
2409
|
}, {
|
|
@@ -2460,10 +2483,10 @@ var InvitationsHandler = class {
|
|
|
2460
2483
|
guardedState.error(extension, new import_context5.ContextDisposedError());
|
|
2461
2484
|
}
|
|
2462
2485
|
});
|
|
2463
|
-
(0,
|
|
2486
|
+
(0, import_async9.scheduleTask)(connectionCtx, async () => {
|
|
2464
2487
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
2465
2488
|
try {
|
|
2466
|
-
|
|
2489
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.begin({
|
|
2467
2490
|
id: traceId
|
|
2468
2491
|
}), {
|
|
2469
2492
|
F: __dxlog_file11,
|
|
@@ -2471,7 +2494,7 @@ var InvitationsHandler = class {
|
|
|
2471
2494
|
S: this,
|
|
2472
2495
|
C: (f, a) => f(...a)
|
|
2473
2496
|
});
|
|
2474
|
-
(0,
|
|
2497
|
+
(0, import_log6.log)("connected", {
|
|
2475
2498
|
...protocol.toJSON()
|
|
2476
2499
|
}, {
|
|
2477
2500
|
F: __dxlog_file11,
|
|
@@ -2482,7 +2505,7 @@ var InvitationsHandler = class {
|
|
|
2482
2505
|
const deviceKey = await extension.completedTrigger.wait({
|
|
2483
2506
|
timeout: invitation.timeout
|
|
2484
2507
|
});
|
|
2485
|
-
(0,
|
|
2508
|
+
(0, import_log6.log)("admitted guest", {
|
|
2486
2509
|
guest: deviceKey,
|
|
2487
2510
|
...protocol.toJSON()
|
|
2488
2511
|
}, {
|
|
@@ -2492,7 +2515,7 @@ var InvitationsHandler = class {
|
|
|
2492
2515
|
C: (f, a) => f(...a)
|
|
2493
2516
|
});
|
|
2494
2517
|
guardedState.set(extension, import_services6.Invitation.State.SUCCESS);
|
|
2495
|
-
|
|
2518
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.end({
|
|
2496
2519
|
id: traceId
|
|
2497
2520
|
}), {
|
|
2498
2521
|
F: __dxlog_file11,
|
|
@@ -2505,9 +2528,9 @@ var InvitationsHandler = class {
|
|
|
2505
2528
|
await ctx.dispose();
|
|
2506
2529
|
}
|
|
2507
2530
|
} catch (err) {
|
|
2508
|
-
if (err instanceof
|
|
2531
|
+
if (err instanceof import_async9.TimeoutError) {
|
|
2509
2532
|
if (guardedState.set(extension, import_services6.Invitation.State.TIMEOUT)) {
|
|
2510
|
-
(0,
|
|
2533
|
+
(0, import_log6.log)("timeout", {
|
|
2511
2534
|
...protocol.toJSON()
|
|
2512
2535
|
}, {
|
|
2513
2536
|
F: __dxlog_file11,
|
|
@@ -2518,7 +2541,7 @@ var InvitationsHandler = class {
|
|
|
2518
2541
|
}
|
|
2519
2542
|
} else {
|
|
2520
2543
|
if (guardedState.error(extension, err)) {
|
|
2521
|
-
|
|
2544
|
+
import_log6.log.error("failed", err, {
|
|
2522
2545
|
F: __dxlog_file11,
|
|
2523
2546
|
L: 133,
|
|
2524
2547
|
S: this,
|
|
@@ -2526,7 +2549,7 @@ var InvitationsHandler = class {
|
|
|
2526
2549
|
});
|
|
2527
2550
|
}
|
|
2528
2551
|
}
|
|
2529
|
-
|
|
2552
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.error({
|
|
2530
2553
|
id: traceId,
|
|
2531
2554
|
error: err
|
|
2532
2555
|
}), {
|
|
@@ -2541,7 +2564,7 @@ var InvitationsHandler = class {
|
|
|
2541
2564
|
},
|
|
2542
2565
|
onError: (err) => {
|
|
2543
2566
|
if (err instanceof import_protocols5.InvalidInvitationExtensionRoleError) {
|
|
2544
|
-
(0,
|
|
2567
|
+
(0, import_log6.log)("invalid role", {
|
|
2545
2568
|
...err.context
|
|
2546
2569
|
}, {
|
|
2547
2570
|
F: __dxlog_file11,
|
|
@@ -2551,9 +2574,9 @@ var InvitationsHandler = class {
|
|
|
2551
2574
|
});
|
|
2552
2575
|
return;
|
|
2553
2576
|
}
|
|
2554
|
-
if (err instanceof
|
|
2577
|
+
if (err instanceof import_async9.TimeoutError) {
|
|
2555
2578
|
if (guardedState.set(extension, import_services6.Invitation.State.TIMEOUT)) {
|
|
2556
|
-
(0,
|
|
2579
|
+
(0, import_log6.log)("timeout", {
|
|
2557
2580
|
err
|
|
2558
2581
|
}, {
|
|
2559
2582
|
F: __dxlog_file11,
|
|
@@ -2564,7 +2587,7 @@ var InvitationsHandler = class {
|
|
|
2564
2587
|
}
|
|
2565
2588
|
} else {
|
|
2566
2589
|
if (guardedState.error(extension, err)) {
|
|
2567
|
-
|
|
2590
|
+
import_log6.log.error("failed", err, {
|
|
2568
2591
|
F: __dxlog_file11,
|
|
2569
2592
|
L: 153,
|
|
2570
2593
|
S: this,
|
|
@@ -2578,14 +2601,14 @@ var InvitationsHandler = class {
|
|
|
2578
2601
|
};
|
|
2579
2602
|
if (invitation.lifetime && invitation.created) {
|
|
2580
2603
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
2581
|
-
|
|
2604
|
+
import_log6.log.warn("invitation has already expired", void 0, {
|
|
2582
2605
|
F: __dxlog_file11,
|
|
2583
2606
|
L: 164,
|
|
2584
2607
|
S: this,
|
|
2585
2608
|
C: (f, a) => f(...a)
|
|
2586
2609
|
});
|
|
2587
2610
|
} else {
|
|
2588
|
-
(0,
|
|
2611
|
+
(0, import_async9.scheduleTask)(ctx, async () => {
|
|
2589
2612
|
await swarmConnection.close();
|
|
2590
2613
|
guardedState.set(null, import_services6.Invitation.State.EXPIRED);
|
|
2591
2614
|
await ctx.dispose();
|
|
@@ -2593,7 +2616,7 @@ var InvitationsHandler = class {
|
|
|
2593
2616
|
}
|
|
2594
2617
|
}
|
|
2595
2618
|
let swarmConnection;
|
|
2596
|
-
(0,
|
|
2619
|
+
(0, import_async9.scheduleTask)(ctx, async () => {
|
|
2597
2620
|
swarmConnection = await this._joinSwarm(ctx, invitation, import_invitations2.Options.Role.HOST, createExtension);
|
|
2598
2621
|
guardedState.set(null, import_services6.Invitation.State.CONNECTING);
|
|
2599
2622
|
});
|
|
@@ -2611,11 +2634,11 @@ var InvitationsHandler = class {
|
|
|
2611
2634
|
]
|
|
2612
2635
|
});
|
|
2613
2636
|
}
|
|
2614
|
-
const triedPeersIds = new
|
|
2637
|
+
const triedPeersIds = new import_util5.ComplexSet(import_keys6.PublicKey.hash);
|
|
2615
2638
|
const guardedState = this._createGuardedState(ctx, invitation, stream);
|
|
2616
2639
|
const shouldCancelInvitationFlow = (extension) => {
|
|
2617
2640
|
const isLockedByAnotherConnection = guardedState.mutex.isLocked() && !extension.hasFlowLock();
|
|
2618
|
-
(0,
|
|
2641
|
+
(0, import_log6.log)("should cancel invitation flow", {
|
|
2619
2642
|
isLockedByAnotherConnection,
|
|
2620
2643
|
invitationType: import_services6.Invitation.Type.DELEGATED,
|
|
2621
2644
|
triedPeers: triedPeersIds.size
|
|
@@ -2643,7 +2666,7 @@ var InvitationsHandler = class {
|
|
|
2643
2666
|
return;
|
|
2644
2667
|
}
|
|
2645
2668
|
connectionCtx.onDispose(async () => {
|
|
2646
|
-
(0,
|
|
2669
|
+
(0, import_log6.log)("extension disposed", {
|
|
2647
2670
|
admitted,
|
|
2648
2671
|
currentState: guardedState.current.state
|
|
2649
2672
|
}, {
|
|
@@ -2659,10 +2682,10 @@ var InvitationsHandler = class {
|
|
|
2659
2682
|
}
|
|
2660
2683
|
}
|
|
2661
2684
|
});
|
|
2662
|
-
(0,
|
|
2685
|
+
(0, import_async9.scheduleTask)(connectionCtx, async () => {
|
|
2663
2686
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
2664
2687
|
try {
|
|
2665
|
-
|
|
2688
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.begin({
|
|
2666
2689
|
id: traceId
|
|
2667
2690
|
}), {
|
|
2668
2691
|
F: __dxlog_file11,
|
|
@@ -2670,11 +2693,11 @@ var InvitationsHandler = class {
|
|
|
2670
2693
|
S: this,
|
|
2671
2694
|
C: (f, a) => f(...a)
|
|
2672
2695
|
});
|
|
2673
|
-
(0,
|
|
2696
|
+
(0, import_async9.scheduleTask)(connectionCtx, () => {
|
|
2674
2697
|
guardedState.set(extension, import_services6.Invitation.State.TIMEOUT);
|
|
2675
2698
|
extensionCtx.close();
|
|
2676
2699
|
}, timeout);
|
|
2677
|
-
(0,
|
|
2700
|
+
(0, import_log6.log)("connected", {
|
|
2678
2701
|
...protocol.toJSON()
|
|
2679
2702
|
}, {
|
|
2680
2703
|
F: __dxlog_file11,
|
|
@@ -2683,7 +2706,7 @@ var InvitationsHandler = class {
|
|
|
2683
2706
|
C: (f, a) => f(...a)
|
|
2684
2707
|
});
|
|
2685
2708
|
guardedState.set(extension, import_services6.Invitation.State.CONNECTED);
|
|
2686
|
-
(0,
|
|
2709
|
+
(0, import_log6.log)("introduce", {
|
|
2687
2710
|
...protocol.toJSON()
|
|
2688
2711
|
}, {
|
|
2689
2712
|
F: __dxlog_file11,
|
|
@@ -2695,7 +2718,7 @@ var InvitationsHandler = class {
|
|
|
2695
2718
|
invitationId: invitation.invitationId,
|
|
2696
2719
|
...protocol.createIntroduction()
|
|
2697
2720
|
});
|
|
2698
|
-
(0,
|
|
2721
|
+
(0, import_log6.log)("introduce response", {
|
|
2699
2722
|
...protocol.toJSON(),
|
|
2700
2723
|
response: introductionResponse
|
|
2701
2724
|
}, {
|
|
@@ -2717,7 +2740,7 @@ var InvitationsHandler = class {
|
|
|
2717
2740
|
break;
|
|
2718
2741
|
}
|
|
2719
2742
|
}
|
|
2720
|
-
(0,
|
|
2743
|
+
(0, import_log6.log)("request admission", {
|
|
2721
2744
|
...protocol.toJSON()
|
|
2722
2745
|
}, {
|
|
2723
2746
|
F: __dxlog_file11,
|
|
@@ -2729,7 +2752,7 @@ var InvitationsHandler = class {
|
|
|
2729
2752
|
const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
|
|
2730
2753
|
admitted = true;
|
|
2731
2754
|
const result = await protocol.accept(admissionResponse, admissionRequest);
|
|
2732
|
-
(0,
|
|
2755
|
+
(0, import_log6.log)("admitted by host", {
|
|
2733
2756
|
...protocol.toJSON()
|
|
2734
2757
|
}, {
|
|
2735
2758
|
F: __dxlog_file11,
|
|
@@ -2742,7 +2765,7 @@ var InvitationsHandler = class {
|
|
|
2742
2765
|
...result,
|
|
2743
2766
|
state: import_services6.Invitation.State.SUCCESS
|
|
2744
2767
|
});
|
|
2745
|
-
|
|
2768
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.end({
|
|
2746
2769
|
id: traceId
|
|
2747
2770
|
}), {
|
|
2748
2771
|
F: __dxlog_file11,
|
|
@@ -2751,8 +2774,8 @@ var InvitationsHandler = class {
|
|
|
2751
2774
|
C: (f, a) => f(...a)
|
|
2752
2775
|
});
|
|
2753
2776
|
} catch (err) {
|
|
2754
|
-
if (err instanceof
|
|
2755
|
-
(0,
|
|
2777
|
+
if (err instanceof import_async9.TimeoutError) {
|
|
2778
|
+
(0, import_log6.log)("timeout", {
|
|
2756
2779
|
...protocol.toJSON()
|
|
2757
2780
|
}, {
|
|
2758
2781
|
F: __dxlog_file11,
|
|
@@ -2762,7 +2785,7 @@ var InvitationsHandler = class {
|
|
|
2762
2785
|
});
|
|
2763
2786
|
guardedState.set(extension, import_services6.Invitation.State.TIMEOUT);
|
|
2764
2787
|
} else {
|
|
2765
|
-
(0,
|
|
2788
|
+
(0, import_log6.log)("auth failed", err, {
|
|
2766
2789
|
F: __dxlog_file11,
|
|
2767
2790
|
L: 314,
|
|
2768
2791
|
S: this,
|
|
@@ -2771,7 +2794,7 @@ var InvitationsHandler = class {
|
|
|
2771
2794
|
guardedState.error(extension, err);
|
|
2772
2795
|
}
|
|
2773
2796
|
extensionCtx.close(err);
|
|
2774
|
-
|
|
2797
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.error({
|
|
2775
2798
|
id: traceId,
|
|
2776
2799
|
error: err
|
|
2777
2800
|
}), {
|
|
@@ -2787,8 +2810,8 @@ var InvitationsHandler = class {
|
|
|
2787
2810
|
if (err instanceof import_protocols5.InvalidInvitationExtensionRoleError) {
|
|
2788
2811
|
return;
|
|
2789
2812
|
}
|
|
2790
|
-
if (err instanceof
|
|
2791
|
-
(0,
|
|
2813
|
+
if (err instanceof import_async9.TimeoutError) {
|
|
2814
|
+
(0, import_log6.log)("timeout", {
|
|
2792
2815
|
...protocol.toJSON()
|
|
2793
2816
|
}, {
|
|
2794
2817
|
F: __dxlog_file11,
|
|
@@ -2798,7 +2821,7 @@ var InvitationsHandler = class {
|
|
|
2798
2821
|
});
|
|
2799
2822
|
guardedState.set(extension, import_services6.Invitation.State.TIMEOUT);
|
|
2800
2823
|
} else {
|
|
2801
|
-
(0,
|
|
2824
|
+
(0, import_log6.log)("auth failed", err, {
|
|
2802
2825
|
F: __dxlog_file11,
|
|
2803
2826
|
L: 330,
|
|
2804
2827
|
S: this,
|
|
@@ -2810,7 +2833,7 @@ var InvitationsHandler = class {
|
|
|
2810
2833
|
});
|
|
2811
2834
|
return extension;
|
|
2812
2835
|
};
|
|
2813
|
-
(0,
|
|
2836
|
+
(0, import_async9.scheduleTask)(ctx, async () => {
|
|
2814
2837
|
const error = protocol.checkInvitation(invitation);
|
|
2815
2838
|
if (error) {
|
|
2816
2839
|
stream.error(error);
|
|
@@ -2856,7 +2879,7 @@ var InvitationsHandler = class {
|
|
|
2856
2879
|
* invitation flow connections.
|
|
2857
2880
|
*/
|
|
2858
2881
|
_createGuardedState(ctx, invitation, stream) {
|
|
2859
|
-
const mutex = new
|
|
2882
|
+
const mutex = new import_async9.Mutex();
|
|
2860
2883
|
let lastActiveExtension = null;
|
|
2861
2884
|
let currentInvitation = {
|
|
2862
2885
|
...invitation
|
|
@@ -2911,7 +2934,7 @@ var InvitationsHandler = class {
|
|
|
2911
2934
|
};
|
|
2912
2935
|
}
|
|
2913
2936
|
_logStateUpdate(invitation, actor, newState) {
|
|
2914
|
-
(0,
|
|
2937
|
+
(0, import_log6.log)("invitation state update", {
|
|
2915
2938
|
actor: actor?.constructor.name,
|
|
2916
2939
|
newState: stateToString(newState),
|
|
2917
2940
|
oldState: stateToString(invitation.state)
|
|
@@ -2933,7 +2956,7 @@ var InvitationsHandler = class {
|
|
|
2933
2956
|
}
|
|
2934
2957
|
async _handleGuestOtpAuth(extension, setState, authenticated, options) {
|
|
2935
2958
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2936
|
-
(0,
|
|
2959
|
+
(0, import_log6.log)("guest waiting for authentication code...", void 0, {
|
|
2937
2960
|
F: __dxlog_file11,
|
|
2938
2961
|
L: 462,
|
|
2939
2962
|
S: this,
|
|
@@ -2941,7 +2964,7 @@ var InvitationsHandler = class {
|
|
|
2941
2964
|
});
|
|
2942
2965
|
setState(import_services6.Invitation.State.READY_FOR_AUTHENTICATION);
|
|
2943
2966
|
const authCode = await authenticated.wait(options);
|
|
2944
|
-
(0,
|
|
2967
|
+
(0, import_log6.log)("sending authentication request", void 0, {
|
|
2945
2968
|
F: __dxlog_file11,
|
|
2946
2969
|
L: 466,
|
|
2947
2970
|
S: this,
|
|
@@ -2958,7 +2981,7 @@ var InvitationsHandler = class {
|
|
|
2958
2981
|
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2959
2982
|
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2960
2983
|
} else {
|
|
2961
|
-
(0,
|
|
2984
|
+
(0, import_log6.log)("retrying invalid code", {
|
|
2962
2985
|
attempt
|
|
2963
2986
|
}, {
|
|
2964
2987
|
F: __dxlog_file11,
|
|
@@ -2978,7 +3001,7 @@ var InvitationsHandler = class {
|
|
|
2978
3001
|
if (introductionResponse.challenge == null) {
|
|
2979
3002
|
throw new Error("challenge missing in the introduction");
|
|
2980
3003
|
}
|
|
2981
|
-
(0,
|
|
3004
|
+
(0, import_log6.log)("sending authentication request", void 0, {
|
|
2982
3005
|
F: __dxlog_file11,
|
|
2983
3006
|
L: 496,
|
|
2984
3007
|
S: this,
|
|
@@ -3160,7 +3183,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3160
3183
|
if (space.inner.spaceState.getMemberRole(identityKey) !== import_credentials10.SpaceMember.Role.REMOVED) {
|
|
3161
3184
|
throw new import_protocols8.AlreadyJoinedError();
|
|
3162
3185
|
}
|
|
3163
|
-
(0,
|
|
3186
|
+
(0, import_log10.log)("writing guest credentials", {
|
|
3164
3187
|
host: this._signingContext.deviceKey,
|
|
3165
3188
|
guest: deviceKey
|
|
3166
3189
|
}, {
|
|
@@ -3228,7 +3251,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3228
3251
|
]
|
|
3229
3252
|
});
|
|
3230
3253
|
}
|
|
3231
|
-
(0,
|
|
3254
|
+
(0, import_log10.log)("writing delegate space invitation", {
|
|
3232
3255
|
host: this._signingContext.deviceKey,
|
|
3233
3256
|
id: invitation.invitationId
|
|
3234
3257
|
}, {
|
|
@@ -3289,7 +3312,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3289
3312
|
""
|
|
3290
3313
|
]
|
|
3291
3314
|
});
|
|
3292
|
-
(0,
|
|
3315
|
+
(0, import_log10.log)("cancelling delegated space invitation", {
|
|
3293
3316
|
host: this._signingContext.deviceKey,
|
|
3294
3317
|
id: invitation.invitationId
|
|
3295
3318
|
}, {
|
|
@@ -3390,12 +3413,12 @@ var InvitationsManager = class {
|
|
|
3390
3413
|
this._metadataStore = _metadataStore;
|
|
3391
3414
|
this._createInvitations = /* @__PURE__ */ new Map();
|
|
3392
3415
|
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
3393
|
-
this.invitationCreated = new
|
|
3394
|
-
this.invitationAccepted = new
|
|
3395
|
-
this.removedCreated = new
|
|
3396
|
-
this.removedAccepted = new
|
|
3397
|
-
this.saved = new
|
|
3398
|
-
this._persistentInvitationsLoadedEvent = new
|
|
3416
|
+
this.invitationCreated = new import_async12.Event();
|
|
3417
|
+
this.invitationAccepted = new import_async12.Event();
|
|
3418
|
+
this.removedCreated = new import_async12.Event();
|
|
3419
|
+
this.removedAccepted = new import_async12.Event();
|
|
3420
|
+
this.saved = new import_async12.Event();
|
|
3421
|
+
this._persistentInvitationsLoadedEvent = new import_async12.Event();
|
|
3399
3422
|
this._persistentInvitationsLoaded = false;
|
|
3400
3423
|
}
|
|
3401
3424
|
async createInvitation(options) {
|
|
@@ -3424,7 +3447,7 @@ var InvitationsManager = class {
|
|
|
3424
3447
|
try {
|
|
3425
3448
|
await this._persistIfRequired(handler, stream, invitation);
|
|
3426
3449
|
} catch (err) {
|
|
3427
|
-
|
|
3450
|
+
import_log11.log.catch(err, void 0, {
|
|
3428
3451
|
F: __dxlog_file13,
|
|
3429
3452
|
L: 82,
|
|
3430
3453
|
S: this,
|
|
@@ -3466,7 +3489,7 @@ var InvitationsManager = class {
|
|
|
3466
3489
|
invitations: cInvitations.map((invitation) => invitation.get())
|
|
3467
3490
|
};
|
|
3468
3491
|
} catch (err) {
|
|
3469
|
-
|
|
3492
|
+
import_log11.log.catch(err, void 0, {
|
|
3470
3493
|
F: __dxlog_file13,
|
|
3471
3494
|
L: 110,
|
|
3472
3495
|
S: this,
|
|
@@ -3498,7 +3521,7 @@ var InvitationsManager = class {
|
|
|
3498
3521
|
return invitation;
|
|
3499
3522
|
}
|
|
3500
3523
|
async authenticate({ invitationId, authCode }) {
|
|
3501
|
-
(0,
|
|
3524
|
+
(0, import_log11.log)("authenticating...", void 0, {
|
|
3502
3525
|
F: __dxlog_file13,
|
|
3503
3526
|
L: 140,
|
|
3504
3527
|
S: this,
|
|
@@ -3515,7 +3538,7 @@ var InvitationsManager = class {
|
|
|
3515
3538
|
});
|
|
3516
3539
|
const observable = this._acceptInvitations.get(invitationId);
|
|
3517
3540
|
if (!observable) {
|
|
3518
|
-
|
|
3541
|
+
import_log11.log.warn("invalid invitation", {
|
|
3519
3542
|
invitationId
|
|
3520
3543
|
}, {
|
|
3521
3544
|
F: __dxlog_file13,
|
|
@@ -3528,7 +3551,7 @@ var InvitationsManager = class {
|
|
|
3528
3551
|
}
|
|
3529
3552
|
}
|
|
3530
3553
|
async cancelInvitation({ invitationId }) {
|
|
3531
|
-
(0,
|
|
3554
|
+
(0, import_log11.log)("cancelInvitation...", {
|
|
3532
3555
|
invitationId
|
|
3533
3556
|
}, {
|
|
3534
3557
|
F: __dxlog_file13,
|
|
@@ -3605,7 +3628,7 @@ var InvitationsManager = class {
|
|
|
3605
3628
|
};
|
|
3606
3629
|
}
|
|
3607
3630
|
_createObservableInvitation(handler, invitation) {
|
|
3608
|
-
const stream = new
|
|
3631
|
+
const stream = new import_async12.PushStream();
|
|
3609
3632
|
const ctx = new import_context9.Context({
|
|
3610
3633
|
onError: (err) => {
|
|
3611
3634
|
stream.error(err);
|
|
@@ -3613,7 +3636,7 @@ var InvitationsManager = class {
|
|
|
3613
3636
|
}
|
|
3614
3637
|
});
|
|
3615
3638
|
ctx.onDispose(() => {
|
|
3616
|
-
(0,
|
|
3639
|
+
(0, import_log11.log)("complete", {
|
|
3617
3640
|
...handler.toJSON()
|
|
3618
3641
|
}, {
|
|
3619
3642
|
F: __dxlog_file13,
|
|
@@ -3641,12 +3664,12 @@ var InvitationsManager = class {
|
|
|
3641
3664
|
};
|
|
3642
3665
|
}
|
|
3643
3666
|
_createObservableAcceptingInvitation(handler, initialState) {
|
|
3644
|
-
const otpEnteredTrigger = new
|
|
3645
|
-
const stream = new
|
|
3667
|
+
const otpEnteredTrigger = new import_async12.Trigger();
|
|
3668
|
+
const stream = new import_async12.PushStream();
|
|
3646
3669
|
const ctx = new import_context9.Context({
|
|
3647
3670
|
onError: (err) => {
|
|
3648
|
-
if (err instanceof
|
|
3649
|
-
(0,
|
|
3671
|
+
if (err instanceof import_async12.TimeoutError) {
|
|
3672
|
+
(0, import_log11.log)("timeout", {
|
|
3650
3673
|
...handler.toJSON()
|
|
3651
3674
|
}, {
|
|
3652
3675
|
F: __dxlog_file13,
|
|
@@ -3659,7 +3682,7 @@ var InvitationsManager = class {
|
|
|
3659
3682
|
state: import_services11.Invitation.State.TIMEOUT
|
|
3660
3683
|
});
|
|
3661
3684
|
} else {
|
|
3662
|
-
|
|
3685
|
+
import_log11.log.warn("auth failed", err, {
|
|
3663
3686
|
F: __dxlog_file13,
|
|
3664
3687
|
L: 264,
|
|
3665
3688
|
S: this,
|
|
@@ -3674,7 +3697,7 @@ var InvitationsManager = class {
|
|
|
3674
3697
|
}
|
|
3675
3698
|
});
|
|
3676
3699
|
ctx.onDispose(() => {
|
|
3677
|
-
(0,
|
|
3700
|
+
(0, import_log11.log)("complete", {
|
|
3678
3701
|
...handler.toJSON()
|
|
3679
3702
|
}, {
|
|
3680
3703
|
F: __dxlog_file13,
|
|
@@ -3721,7 +3744,7 @@ var InvitationsManager = class {
|
|
|
3721
3744
|
try {
|
|
3722
3745
|
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
3723
3746
|
} catch (err) {
|
|
3724
|
-
|
|
3747
|
+
import_log11.log.catch(err, void 0, {
|
|
3725
3748
|
F: __dxlog_file13,
|
|
3726
3749
|
L: 307,
|
|
3727
3750
|
S: this,
|
|
@@ -3741,7 +3764,7 @@ var AutomergeSpaceState = class extends import_context11.Resource {
|
|
|
3741
3764
|
this._onNewRoot = _onNewRoot;
|
|
3742
3765
|
this.rootUrl = void 0;
|
|
3743
3766
|
this.lastEpoch = void 0;
|
|
3744
|
-
this.onNewEpoch = new
|
|
3767
|
+
this.onNewEpoch = new import_async14.Event();
|
|
3745
3768
|
this._isProcessingRootDocs = false;
|
|
3746
3769
|
}
|
|
3747
3770
|
async _open(ctx) {
|
|
@@ -3790,7 +3813,7 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3790
3813
|
throw new Error("Space does not have an automerge root");
|
|
3791
3814
|
}
|
|
3792
3815
|
const rootHandle = context.repo.find(context.currentRoot);
|
|
3793
|
-
await (0, import_context12.cancelWithContext)(ctx, (0,
|
|
3816
|
+
await (0, import_context12.cancelWithContext)(ctx, (0, import_async15.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3794
3817
|
const newRoot = context.repo.create(rootHandle.docSync());
|
|
3795
3818
|
await context.repo.flush();
|
|
3796
3819
|
return {
|
|
@@ -3798,7 +3821,7 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3798
3821
|
};
|
|
3799
3822
|
}
|
|
3800
3823
|
case import_services13.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT: {
|
|
3801
|
-
|
|
3824
|
+
import_log13.log.info("Fragmenting", void 0, {
|
|
3802
3825
|
F: __dxlog_file14,
|
|
3803
3826
|
L: 63,
|
|
3804
3827
|
S: void 0,
|
|
@@ -3806,7 +3829,7 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3806
3829
|
});
|
|
3807
3830
|
const currentRootUrl = context.currentRoot;
|
|
3808
3831
|
const rootHandle = context.repo.find(currentRootUrl);
|
|
3809
|
-
await (0, import_context12.cancelWithContext)(ctx, (0,
|
|
3832
|
+
await (0, import_context12.cancelWithContext)(ctx, (0, import_async15.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3810
3833
|
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3811
3834
|
const properties = (0, import_echo_db.findInlineObjectOfType)(rootHandle.docSync(), import_echo_schema.TYPE_PROPERTIES);
|
|
3812
3835
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
@@ -3842,7 +3865,7 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3842
3865
|
otherObjects.forEach(([key, value]) => {
|
|
3843
3866
|
const handle = docLoader.createDocumentForObject(key);
|
|
3844
3867
|
handle.change((doc) => {
|
|
3845
|
-
(0,
|
|
3868
|
+
(0, import_util8.assignDeep)(doc, [
|
|
3846
3869
|
"objects",
|
|
3847
3870
|
key
|
|
3848
3871
|
], value);
|
|
@@ -3856,7 +3879,7 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3856
3879
|
case import_services13.CreateEpochRequest.Migration.MIGRATE_REFERENCES_TO_DXN: {
|
|
3857
3880
|
const currentRootUrl = context.currentRoot;
|
|
3858
3881
|
const rootHandle = context.repo.find(currentRootUrl);
|
|
3859
|
-
await (0, import_context12.cancelWithContext)(ctx, (0,
|
|
3882
|
+
await (0, import_context12.cancelWithContext)(ctx, (0, import_async15.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3860
3883
|
(0, import_invariant13.invariant)(rootHandle.docSync(), "Root doc not found", {
|
|
3861
3884
|
F: __dxlog_file14,
|
|
3862
3885
|
L: 100,
|
|
@@ -3869,7 +3892,7 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3869
3892
|
const newRootContent = await (0, import_echo_db.convertLegacySpaceRootDoc)(structuredClone(rootHandle.docSync()));
|
|
3870
3893
|
for (const [id, url] of Object.entries(newRootContent.links ?? {})) {
|
|
3871
3894
|
const handle = context.repo.find(url);
|
|
3872
|
-
await (0, import_context12.cancelWithContext)(ctx, (0,
|
|
3895
|
+
await (0, import_context12.cancelWithContext)(ctx, (0, import_async15.asyncTimeout)(handle.whenReady(), 1e4));
|
|
3873
3896
|
(0, import_invariant13.invariant)(handle.docSync(), "Doc not found", {
|
|
3874
3897
|
F: __dxlog_file14,
|
|
3875
3898
|
L: 107,
|
|
@@ -3917,10 +3940,10 @@ var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
|
3917
3940
|
var NotarizationPlugin = class {
|
|
3918
3941
|
constructor() {
|
|
3919
3942
|
this._ctx = new import_context13.Context();
|
|
3920
|
-
this._extensionOpened = new
|
|
3943
|
+
this._extensionOpened = new import_async16.Event();
|
|
3921
3944
|
this._extensions = /* @__PURE__ */ new Set();
|
|
3922
|
-
this._processedCredentials = new
|
|
3923
|
-
this._processCredentialsTriggers = new
|
|
3945
|
+
this._processedCredentials = new import_util9.ComplexSet(import_keys11.PublicKey.hash);
|
|
3946
|
+
this._processCredentialsTriggers = new import_util9.ComplexMap(import_keys11.PublicKey.hash);
|
|
3924
3947
|
}
|
|
3925
3948
|
get hasWriter() {
|
|
3926
3949
|
return !!this._writer;
|
|
@@ -3934,7 +3957,7 @@ var NotarizationPlugin = class {
|
|
|
3934
3957
|
* Request credentials to be notarized.
|
|
3935
3958
|
*/
|
|
3936
3959
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
3937
|
-
(0,
|
|
3960
|
+
(0, import_log14.log)("notarize", {
|
|
3938
3961
|
credentials
|
|
3939
3962
|
}, {
|
|
3940
3963
|
F: __dxlog_file15,
|
|
@@ -3951,10 +3974,10 @@ var NotarizationPlugin = class {
|
|
|
3951
3974
|
"'Credentials must have an id'"
|
|
3952
3975
|
]
|
|
3953
3976
|
});
|
|
3954
|
-
const errors = new
|
|
3977
|
+
const errors = new import_async16.Trigger();
|
|
3955
3978
|
const ctx = this._ctx.derive({
|
|
3956
3979
|
onError: (err) => {
|
|
3957
|
-
|
|
3980
|
+
import_log14.log.warn("Notarization error", {
|
|
3958
3981
|
err
|
|
3959
3982
|
}, {
|
|
3960
3983
|
F: __dxlog_file15,
|
|
@@ -3968,8 +3991,8 @@ var NotarizationPlugin = class {
|
|
|
3968
3991
|
});
|
|
3969
3992
|
opCtx?.onDispose(() => ctx.dispose());
|
|
3970
3993
|
if (timeout !== 0) {
|
|
3971
|
-
(0,
|
|
3972
|
-
|
|
3994
|
+
(0, import_async16.scheduleTask)(ctx, () => {
|
|
3995
|
+
import_log14.log.warn("Notarization timeout", {
|
|
3973
3996
|
timeout,
|
|
3974
3997
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3975
3998
|
}, {
|
|
@@ -3979,12 +4002,12 @@ var NotarizationPlugin = class {
|
|
|
3979
4002
|
C: (f, a) => f(...a)
|
|
3980
4003
|
});
|
|
3981
4004
|
void ctx.dispose();
|
|
3982
|
-
errors.throw(new
|
|
4005
|
+
errors.throw(new import_async16.TimeoutError(timeout, "Notarization timed out"));
|
|
3983
4006
|
}, timeout);
|
|
3984
4007
|
}
|
|
3985
4008
|
const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
|
|
3986
4009
|
const peersTried = /* @__PURE__ */ new Set();
|
|
3987
|
-
const notarizeTask = new
|
|
4010
|
+
const notarizeTask = new import_async16.DeferredTask(ctx, async () => {
|
|
3988
4011
|
try {
|
|
3989
4012
|
if (this._extensions.size === 0) {
|
|
3990
4013
|
return;
|
|
@@ -3993,7 +4016,7 @@ var NotarizationPlugin = class {
|
|
|
3993
4016
|
...this._extensions
|
|
3994
4017
|
].find((peer2) => !peersTried.has(peer2));
|
|
3995
4018
|
if (!peer) {
|
|
3996
|
-
|
|
4019
|
+
import_log14.log.info("Exhausted all peers to notarize with", {
|
|
3997
4020
|
retryIn: retryTimeout
|
|
3998
4021
|
}, {
|
|
3999
4022
|
F: __dxlog_file15,
|
|
@@ -4002,11 +4025,11 @@ var NotarizationPlugin = class {
|
|
|
4002
4025
|
C: (f, a) => f(...a)
|
|
4003
4026
|
});
|
|
4004
4027
|
peersTried.clear();
|
|
4005
|
-
(0,
|
|
4028
|
+
(0, import_async16.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
4006
4029
|
return;
|
|
4007
4030
|
}
|
|
4008
4031
|
peersTried.add(peer);
|
|
4009
|
-
(0,
|
|
4032
|
+
(0, import_log14.log)("try notarizing", {
|
|
4010
4033
|
peer: peer.localPeerId,
|
|
4011
4034
|
credentialId: credentials.map((credential) => credential.id)
|
|
4012
4035
|
}, {
|
|
@@ -4018,16 +4041,16 @@ var NotarizationPlugin = class {
|
|
|
4018
4041
|
await peer.rpc.NotarizationService.notarize({
|
|
4019
4042
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
4020
4043
|
});
|
|
4021
|
-
(0,
|
|
4044
|
+
(0, import_log14.log)("success", void 0, {
|
|
4022
4045
|
F: __dxlog_file15,
|
|
4023
4046
|
L: 147,
|
|
4024
4047
|
S: this,
|
|
4025
4048
|
C: (f, a) => f(...a)
|
|
4026
4049
|
});
|
|
4027
|
-
await (0,
|
|
4050
|
+
await (0, import_async16.sleep)(successDelay);
|
|
4028
4051
|
} catch (err) {
|
|
4029
4052
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
4030
|
-
|
|
4053
|
+
import_log14.log.info("error notarizing (recoverable)", err, {
|
|
4031
4054
|
F: __dxlog_file15,
|
|
4032
4055
|
L: 151,
|
|
4033
4056
|
S: this,
|
|
@@ -4045,7 +4068,7 @@ var NotarizationPlugin = class {
|
|
|
4045
4068
|
allNotarized,
|
|
4046
4069
|
errors.wait()
|
|
4047
4070
|
]);
|
|
4048
|
-
(0,
|
|
4071
|
+
(0, import_log14.log)("done", void 0, {
|
|
4049
4072
|
F: __dxlog_file15,
|
|
4050
4073
|
L: 162,
|
|
4051
4074
|
S: this,
|
|
@@ -4082,7 +4105,7 @@ var NotarizationPlugin = class {
|
|
|
4082
4105
|
if (this._processedCredentials.has(id)) {
|
|
4083
4106
|
return;
|
|
4084
4107
|
}
|
|
4085
|
-
await (0,
|
|
4108
|
+
await (0, import_util9.entry)(this._processCredentialsTriggers, id).orInsert(new import_async16.Trigger()).value.wait();
|
|
4086
4109
|
}
|
|
4087
4110
|
/**
|
|
4088
4111
|
* Requests from other peers to notarize credentials.
|
|
@@ -4110,7 +4133,7 @@ var NotarizationPlugin = class {
|
|
|
4110
4133
|
createExtension() {
|
|
4111
4134
|
const extension = new NotarizationTeleportExtension({
|
|
4112
4135
|
onOpen: async () => {
|
|
4113
|
-
(0,
|
|
4136
|
+
(0, import_log14.log)("extension opened", {
|
|
4114
4137
|
peer: extension.localPeerId
|
|
4115
4138
|
}, {
|
|
4116
4139
|
F: __dxlog_file15,
|
|
@@ -4122,7 +4145,7 @@ var NotarizationPlugin = class {
|
|
|
4122
4145
|
this._extensionOpened.emit();
|
|
4123
4146
|
},
|
|
4124
4147
|
onClose: async () => {
|
|
4125
|
-
(0,
|
|
4148
|
+
(0, import_log14.log)("extension closed", {
|
|
4126
4149
|
peer: extension.localPeerId
|
|
4127
4150
|
}, {
|
|
4128
4151
|
F: __dxlog_file15,
|
|
@@ -4247,11 +4270,11 @@ var DataSpace = class {
|
|
|
4247
4270
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
4248
4271
|
this._cache = void 0;
|
|
4249
4272
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
4250
|
-
this._epochProcessingMutex = new
|
|
4273
|
+
this._epochProcessingMutex = new import_async13.Mutex();
|
|
4251
4274
|
this._state = import_services12.SpaceState.CLOSED;
|
|
4252
4275
|
this._databaseRoot = null;
|
|
4253
4276
|
this.error = void 0;
|
|
4254
|
-
this.stateUpdate = new
|
|
4277
|
+
this.stateUpdate = new import_async13.Event();
|
|
4255
4278
|
this.metrics = {};
|
|
4256
4279
|
this._inner = params.inner;
|
|
4257
4280
|
this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
|
|
@@ -4264,13 +4287,13 @@ var DataSpace = class {
|
|
|
4264
4287
|
this._callbacks = params.callbacks ?? {};
|
|
4265
4288
|
this._echoHost = params.echoHost;
|
|
4266
4289
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
4267
|
-
trustedKeysProvider: () => new
|
|
4290
|
+
trustedKeysProvider: () => new import_util7.ComplexSet(import_keys10.PublicKey.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== import_credentials13.SpaceMember.Role.REMOVED).map((member) => member.key)),
|
|
4268
4291
|
update: this._inner.stateUpdate,
|
|
4269
4292
|
authTimeout: import_client_protocol4.AUTH_TIMEOUT
|
|
4270
4293
|
});
|
|
4271
4294
|
this._cache = params.cache;
|
|
4272
4295
|
this._state = params.initialState;
|
|
4273
|
-
(0,
|
|
4296
|
+
(0, import_log12.log)("new state", {
|
|
4274
4297
|
state: import_services12.SpaceState[this._state]
|
|
4275
4298
|
}, {
|
|
4276
4299
|
F: __dxlog_file16,
|
|
@@ -4330,7 +4353,7 @@ var DataSpace = class {
|
|
|
4330
4353
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
4331
4354
|
await this._inner.open(new import_context10.Context());
|
|
4332
4355
|
this._state = import_services12.SpaceState.CONTROL_ONLY;
|
|
4333
|
-
(0,
|
|
4356
|
+
(0, import_log12.log)("new state", {
|
|
4334
4357
|
state: import_services12.SpaceState[this._state]
|
|
4335
4358
|
}, {
|
|
4336
4359
|
F: __dxlog_file16,
|
|
@@ -4348,7 +4371,7 @@ var DataSpace = class {
|
|
|
4348
4371
|
async _close() {
|
|
4349
4372
|
await this._callbacks.beforeClose?.();
|
|
4350
4373
|
this._state = import_services12.SpaceState.CLOSED;
|
|
4351
|
-
(0,
|
|
4374
|
+
(0, import_log12.log)("new state", {
|
|
4352
4375
|
state: import_services12.SpaceState[this._state]
|
|
4353
4376
|
}, {
|
|
4354
4377
|
F: __dxlog_file16,
|
|
@@ -4377,13 +4400,13 @@ var DataSpace = class {
|
|
|
4377
4400
|
* Initialize the data pipeline in a separate task.
|
|
4378
4401
|
*/
|
|
4379
4402
|
initializeDataPipelineAsync() {
|
|
4380
|
-
(0,
|
|
4403
|
+
(0, import_async13.scheduleTask)(this._ctx, async () => {
|
|
4381
4404
|
try {
|
|
4382
4405
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
4383
4406
|
await this.initializeDataPipeline();
|
|
4384
4407
|
} catch (err) {
|
|
4385
4408
|
if (err instanceof import_protocols9.CancelledError || err instanceof import_context10.ContextDisposedError) {
|
|
4386
|
-
(0,
|
|
4409
|
+
(0, import_log12.log)("data pipeline initialization cancelled", err, {
|
|
4387
4410
|
F: __dxlog_file16,
|
|
4388
4411
|
L: 265,
|
|
4389
4412
|
S: this,
|
|
@@ -4391,14 +4414,14 @@ var DataSpace = class {
|
|
|
4391
4414
|
});
|
|
4392
4415
|
return;
|
|
4393
4416
|
}
|
|
4394
|
-
|
|
4417
|
+
import_log12.log.error("Error initializing data pipeline", err, {
|
|
4395
4418
|
F: __dxlog_file16,
|
|
4396
4419
|
L: 269,
|
|
4397
4420
|
S: this,
|
|
4398
4421
|
C: (f, a) => f(...a)
|
|
4399
4422
|
});
|
|
4400
4423
|
this._state = import_services12.SpaceState.ERROR;
|
|
4401
|
-
(0,
|
|
4424
|
+
(0, import_log12.log)("new state", {
|
|
4402
4425
|
state: import_services12.SpaceState[this._state]
|
|
4403
4426
|
}, {
|
|
4404
4427
|
F: __dxlog_file16,
|
|
@@ -4418,7 +4441,7 @@ var DataSpace = class {
|
|
|
4418
4441
|
throw new import_protocols9.SystemError("Invalid operation");
|
|
4419
4442
|
}
|
|
4420
4443
|
this._state = import_services12.SpaceState.INITIALIZING;
|
|
4421
|
-
(0,
|
|
4444
|
+
(0, import_log12.log)("new state", {
|
|
4422
4445
|
state: import_services12.SpaceState[this._state]
|
|
4423
4446
|
}, {
|
|
4424
4447
|
F: __dxlog_file16,
|
|
@@ -4427,7 +4450,7 @@ var DataSpace = class {
|
|
|
4427
4450
|
C: (f, a) => f(...a)
|
|
4428
4451
|
});
|
|
4429
4452
|
await this._initializeAndReadControlPipeline();
|
|
4430
|
-
await (0,
|
|
4453
|
+
await (0, import_async13.sleep)(1);
|
|
4431
4454
|
const ready = this.stateUpdate.waitForCondition(() => this._state === import_services12.SpaceState.READY);
|
|
4432
4455
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
4433
4456
|
await ready;
|
|
@@ -4435,7 +4458,7 @@ var DataSpace = class {
|
|
|
4435
4458
|
async _enterReadyState() {
|
|
4436
4459
|
await this._callbacks.beforeReady?.();
|
|
4437
4460
|
this._state = import_services12.SpaceState.READY;
|
|
4438
|
-
(0,
|
|
4461
|
+
(0, import_log12.log)("new state", {
|
|
4439
4462
|
state: import_services12.SpaceState[this._state]
|
|
4440
4463
|
}, {
|
|
4441
4464
|
F: __dxlog_file16,
|
|
@@ -4453,7 +4476,7 @@ var DataSpace = class {
|
|
|
4453
4476
|
});
|
|
4454
4477
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
4455
4478
|
await this._createWritableFeeds();
|
|
4456
|
-
(0,
|
|
4479
|
+
(0, import_log12.log)("writable feeds created", void 0, {
|
|
4457
4480
|
F: __dxlog_file16,
|
|
4458
4481
|
L: 322,
|
|
4459
4482
|
S: this,
|
|
@@ -4513,7 +4536,7 @@ var DataSpace = class {
|
|
|
4513
4536
|
}
|
|
4514
4537
|
}
|
|
4515
4538
|
_onNewAutomergeRoot(rootUrl) {
|
|
4516
|
-
(0,
|
|
4539
|
+
(0, import_log12.log)("loading automerge root doc for space", {
|
|
4517
4540
|
space: this.key,
|
|
4518
4541
|
rootUrl
|
|
4519
4542
|
}, {
|
|
@@ -4522,7 +4545,6 @@ var DataSpace = class {
|
|
|
4522
4545
|
S: this,
|
|
4523
4546
|
C: (f, a) => f(...a)
|
|
4524
4547
|
});
|
|
4525
|
-
this._echoHost.replicateDocument(rootUrl);
|
|
4526
4548
|
const handle = this._echoHost.automergeRepo.find(rootUrl);
|
|
4527
4549
|
queueMicrotask(async () => {
|
|
4528
4550
|
try {
|
|
@@ -4549,8 +4571,10 @@ var DataSpace = class {
|
|
|
4549
4571
|
const root = await this._echoHost.openSpaceRoot(handle.url);
|
|
4550
4572
|
this._databaseRoot = root;
|
|
4551
4573
|
if (root.getVersion() !== import_echo_protocol.SpaceDocVersion.CURRENT) {
|
|
4552
|
-
this._state
|
|
4553
|
-
|
|
4574
|
+
if (this._state !== import_services12.SpaceState.REQUIRES_MIGRATION) {
|
|
4575
|
+
this._state = import_services12.SpaceState.REQUIRES_MIGRATION;
|
|
4576
|
+
this.stateUpdate.emit();
|
|
4577
|
+
}
|
|
4554
4578
|
} else {
|
|
4555
4579
|
if (this._state !== import_services12.SpaceState.READY) {
|
|
4556
4580
|
await this._enterReadyState();
|
|
@@ -4565,7 +4589,7 @@ var DataSpace = class {
|
|
|
4565
4589
|
if (err instanceof import_context10.ContextDisposedError) {
|
|
4566
4590
|
return;
|
|
4567
4591
|
}
|
|
4568
|
-
|
|
4592
|
+
import_log12.log.warn("error loading automerge root doc", {
|
|
4569
4593
|
space: this.key,
|
|
4570
4594
|
rootUrl,
|
|
4571
4595
|
err
|
|
@@ -4653,7 +4677,7 @@ var DataSpace = class {
|
|
|
4653
4677
|
await this._close();
|
|
4654
4678
|
}
|
|
4655
4679
|
this._state = import_services12.SpaceState.INACTIVE;
|
|
4656
|
-
(0,
|
|
4680
|
+
(0, import_log12.log)("new state", {
|
|
4657
4681
|
state: import_services12.SpaceState[this._state]
|
|
4658
4682
|
}, {
|
|
4659
4683
|
F: __dxlog_file16,
|
|
@@ -4684,10 +4708,10 @@ _ts_decorate4([
|
|
|
4684
4708
|
})
|
|
4685
4709
|
], DataSpace.prototype, "_automergeInfo", null);
|
|
4686
4710
|
_ts_decorate4([
|
|
4687
|
-
|
|
4711
|
+
import_async13.synchronized
|
|
4688
4712
|
], DataSpace.prototype, "open", null);
|
|
4689
4713
|
_ts_decorate4([
|
|
4690
|
-
|
|
4714
|
+
import_async13.synchronized
|
|
4691
4715
|
], DataSpace.prototype, "close", null);
|
|
4692
4716
|
_ts_decorate4([
|
|
4693
4717
|
import_tracing5.trace.span({
|
|
@@ -4703,13 +4727,13 @@ _ts_decorate4([
|
|
|
4703
4727
|
(0, import_debug3.timed)(1e4)
|
|
4704
4728
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
4705
4729
|
_ts_decorate4([
|
|
4706
|
-
|
|
4730
|
+
import_async13.synchronized
|
|
4707
4731
|
], DataSpace.prototype, "activate", null);
|
|
4708
4732
|
_ts_decorate4([
|
|
4709
|
-
|
|
4733
|
+
import_async13.synchronized
|
|
4710
4734
|
], DataSpace.prototype, "deactivate", null);
|
|
4711
4735
|
DataSpace = _ts_decorate4([
|
|
4712
|
-
(0,
|
|
4736
|
+
(0, import_async13.trackLeaks)("open", "close"),
|
|
4713
4737
|
import_tracing5.trace.resource()
|
|
4714
4738
|
], DataSpace);
|
|
4715
4739
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
@@ -4801,8 +4825,8 @@ var DataSpaceManager = class {
|
|
|
4801
4825
|
this._invitationsManager = _invitationsManager;
|
|
4802
4826
|
this._params = _params;
|
|
4803
4827
|
this._ctx = new import_context14.Context();
|
|
4804
|
-
this.updated = new
|
|
4805
|
-
this._spaces = new
|
|
4828
|
+
this.updated = new import_async17.Event();
|
|
4829
|
+
this._spaces = new import_util10.ComplexMap(import_keys12.PublicKey.hash);
|
|
4806
4830
|
this._isOpen = false;
|
|
4807
4831
|
this._instanceId = import_keys12.PublicKey.random().toHex();
|
|
4808
4832
|
import_tracing6.trace.diagnostic({
|
|
@@ -4833,13 +4857,13 @@ var DataSpaceManager = class {
|
|
|
4833
4857
|
return this._spaces;
|
|
4834
4858
|
}
|
|
4835
4859
|
async open() {
|
|
4836
|
-
(0,
|
|
4860
|
+
(0, import_log15.log)("open", void 0, {
|
|
4837
4861
|
F: __dxlog_file17,
|
|
4838
4862
|
L: 146,
|
|
4839
4863
|
S: this,
|
|
4840
4864
|
C: (f, a) => f(...a)
|
|
4841
4865
|
});
|
|
4842
|
-
|
|
4866
|
+
import_log15.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.begin({
|
|
4843
4867
|
id: this._instanceId
|
|
4844
4868
|
}), {
|
|
4845
4869
|
F: __dxlog_file17,
|
|
@@ -4847,7 +4871,7 @@ var DataSpaceManager = class {
|
|
|
4847
4871
|
S: this,
|
|
4848
4872
|
C: (f, a) => f(...a)
|
|
4849
4873
|
});
|
|
4850
|
-
(0,
|
|
4874
|
+
(0, import_log15.log)("metadata loaded", {
|
|
4851
4875
|
spaces: this._metadataStore.spaces.length
|
|
4852
4876
|
}, {
|
|
4853
4877
|
F: __dxlog_file17,
|
|
@@ -4855,9 +4879,9 @@ var DataSpaceManager = class {
|
|
|
4855
4879
|
S: this,
|
|
4856
4880
|
C: (f, a) => f(...a)
|
|
4857
4881
|
});
|
|
4858
|
-
await (0,
|
|
4882
|
+
await (0, import_util10.forEachAsync)(this._metadataStore.spaces, async (spaceMetadata) => {
|
|
4859
4883
|
try {
|
|
4860
|
-
(0,
|
|
4884
|
+
(0, import_log15.log)("load space", {
|
|
4861
4885
|
spaceMetadata
|
|
4862
4886
|
}, {
|
|
4863
4887
|
F: __dxlog_file17,
|
|
@@ -4867,7 +4891,7 @@ var DataSpaceManager = class {
|
|
|
4867
4891
|
});
|
|
4868
4892
|
await this._constructSpace(spaceMetadata);
|
|
4869
4893
|
} catch (err) {
|
|
4870
|
-
|
|
4894
|
+
import_log15.log.error("Error loading space", {
|
|
4871
4895
|
spaceMetadata,
|
|
4872
4896
|
err
|
|
4873
4897
|
}, {
|
|
@@ -4880,7 +4904,7 @@ var DataSpaceManager = class {
|
|
|
4880
4904
|
});
|
|
4881
4905
|
this._isOpen = true;
|
|
4882
4906
|
this.updated.emit();
|
|
4883
|
-
|
|
4907
|
+
import_log15.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.end({
|
|
4884
4908
|
id: this._instanceId
|
|
4885
4909
|
}), {
|
|
4886
4910
|
F: __dxlog_file17,
|
|
@@ -4890,7 +4914,7 @@ var DataSpaceManager = class {
|
|
|
4890
4914
|
});
|
|
4891
4915
|
}
|
|
4892
4916
|
async close() {
|
|
4893
|
-
(0,
|
|
4917
|
+
(0, import_log15.log)("close", void 0, {
|
|
4894
4918
|
F: __dxlog_file17,
|
|
4895
4919
|
L: 167,
|
|
4896
4920
|
S: this,
|
|
@@ -4926,7 +4950,7 @@ var DataSpaceManager = class {
|
|
|
4926
4950
|
dataFeedKey,
|
|
4927
4951
|
state: import_services14.SpaceState.ACTIVE
|
|
4928
4952
|
};
|
|
4929
|
-
(0,
|
|
4953
|
+
(0, import_log15.log)("creating space...", {
|
|
4930
4954
|
spaceKey
|
|
4931
4955
|
}, {
|
|
4932
4956
|
F: __dxlog_file17,
|
|
@@ -4969,7 +4993,7 @@ var DataSpaceManager = class {
|
|
|
4969
4993
|
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
4970
4994
|
}
|
|
4971
4995
|
default:
|
|
4972
|
-
|
|
4996
|
+
import_log15.log.warn("unknown space version", {
|
|
4973
4997
|
version: space.databaseRoot.getVersion(),
|
|
4974
4998
|
spaceId: space.id
|
|
4975
4999
|
}, {
|
|
@@ -4997,7 +5021,7 @@ var DataSpaceManager = class {
|
|
|
4997
5021
|
};
|
|
4998
5022
|
const propertiesId = (0, import_echo_schema2.generateEchoId)();
|
|
4999
5023
|
document.change((doc) => {
|
|
5000
|
-
(0,
|
|
5024
|
+
(0, import_util10.assignDeep)(doc, [
|
|
5001
5025
|
"objects",
|
|
5002
5026
|
propertiesId
|
|
5003
5027
|
], properties);
|
|
@@ -5022,7 +5046,7 @@ var DataSpaceManager = class {
|
|
|
5022
5046
|
}
|
|
5023
5047
|
// TODO(burdon): Rename join space.
|
|
5024
5048
|
async acceptSpace(opts) {
|
|
5025
|
-
(0,
|
|
5049
|
+
(0, import_log15.log)("accept space", {
|
|
5026
5050
|
opts
|
|
5027
5051
|
}, {
|
|
5028
5052
|
F: __dxlog_file17,
|
|
@@ -5073,7 +5097,7 @@ var DataSpaceManager = class {
|
|
|
5073
5097
|
}));
|
|
5074
5098
|
}
|
|
5075
5099
|
async _constructSpace(metadata) {
|
|
5076
|
-
(0,
|
|
5100
|
+
(0, import_log15.log)("construct space", {
|
|
5077
5101
|
metadata
|
|
5078
5102
|
}, {
|
|
5079
5103
|
F: __dxlog_file17,
|
|
@@ -5102,7 +5126,7 @@ var DataSpaceManager = class {
|
|
|
5102
5126
|
swarmIdentity: {
|
|
5103
5127
|
peerKey: this._signingContext.deviceKey,
|
|
5104
5128
|
credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
|
|
5105
|
-
credentialAuthenticator: (0,
|
|
5129
|
+
credentialAuthenticator: (0, import_util10.deferFunction)(() => dataSpace.authVerifier.verifier)
|
|
5106
5130
|
},
|
|
5107
5131
|
onAuthorizedConnection: (session) => {
|
|
5108
5132
|
session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
|
|
@@ -5113,7 +5137,7 @@ var DataSpaceManager = class {
|
|
|
5113
5137
|
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
5114
5138
|
},
|
|
5115
5139
|
onAuthFailure: () => {
|
|
5116
|
-
|
|
5140
|
+
import_log15.log.warn("auth failure", void 0, {
|
|
5117
5141
|
F: __dxlog_file17,
|
|
5118
5142
|
L: 343,
|
|
5119
5143
|
S: this,
|
|
@@ -5144,7 +5168,7 @@ var DataSpaceManager = class {
|
|
|
5144
5168
|
signingContext: this._signingContext,
|
|
5145
5169
|
callbacks: {
|
|
5146
5170
|
beforeReady: async () => {
|
|
5147
|
-
(0,
|
|
5171
|
+
(0, import_log15.log)("before space ready", {
|
|
5148
5172
|
space: space.key
|
|
5149
5173
|
}, {
|
|
5150
5174
|
F: __dxlog_file17,
|
|
@@ -5154,7 +5178,7 @@ var DataSpaceManager = class {
|
|
|
5154
5178
|
});
|
|
5155
5179
|
},
|
|
5156
5180
|
afterReady: async () => {
|
|
5157
|
-
(0,
|
|
5181
|
+
(0, import_log15.log)("after space ready", {
|
|
5158
5182
|
space: space.key,
|
|
5159
5183
|
open: this._isOpen
|
|
5160
5184
|
}, {
|
|
@@ -5174,7 +5198,7 @@ var DataSpaceManager = class {
|
|
|
5174
5198
|
}
|
|
5175
5199
|
},
|
|
5176
5200
|
beforeClose: async () => {
|
|
5177
|
-
(0,
|
|
5201
|
+
(0, import_log15.log)("before space close", {
|
|
5178
5202
|
space: space.key
|
|
5179
5203
|
}, {
|
|
5180
5204
|
F: __dxlog_file17,
|
|
@@ -5209,11 +5233,11 @@ var DataSpaceManager = class {
|
|
|
5209
5233
|
return (s && member.role === import_credentials16.SpaceMember.Role.REMOVED !== (s.authStatus === import_echo_pipeline4.AuthStatus.FAILURE)) ?? false;
|
|
5210
5234
|
});
|
|
5211
5235
|
sessionsToClose.forEach((session) => {
|
|
5212
|
-
void session.close().catch(
|
|
5236
|
+
void session.close().catch(import_log15.log.error);
|
|
5213
5237
|
});
|
|
5214
5238
|
closedSessions += sessionsToClose.length;
|
|
5215
5239
|
}
|
|
5216
|
-
(0,
|
|
5240
|
+
(0, import_log15.log)("processed member role changes", {
|
|
5217
5241
|
roleChangeCount: memberInfo.length,
|
|
5218
5242
|
peersOnline: presence.getPeersOnline().length,
|
|
5219
5243
|
closedSessions
|
|
@@ -5230,7 +5254,7 @@ var DataSpaceManager = class {
|
|
|
5230
5254
|
if (role === import_credentials16.SpaceMember.Role.REMOVED) {
|
|
5231
5255
|
const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
|
|
5232
5256
|
if (session != null) {
|
|
5233
|
-
(0,
|
|
5257
|
+
(0, import_log15.log)("closing a session with a removed peer", {
|
|
5234
5258
|
peerId: peerState.peerId
|
|
5235
5259
|
}, {
|
|
5236
5260
|
F: __dxlog_file17,
|
|
@@ -5238,7 +5262,7 @@ var DataSpaceManager = class {
|
|
|
5238
5262
|
S: this,
|
|
5239
5263
|
C: (f, a) => f(...a)
|
|
5240
5264
|
});
|
|
5241
|
-
void session.close().catch(
|
|
5265
|
+
void session.close().catch(import_log15.log.error);
|
|
5242
5266
|
}
|
|
5243
5267
|
}
|
|
5244
5268
|
}
|
|
@@ -5279,19 +5303,19 @@ var DataSpaceManager = class {
|
|
|
5279
5303
|
}
|
|
5280
5304
|
};
|
|
5281
5305
|
_ts_decorate5([
|
|
5282
|
-
|
|
5306
|
+
import_async17.synchronized
|
|
5283
5307
|
], DataSpaceManager.prototype, "open", null);
|
|
5284
5308
|
_ts_decorate5([
|
|
5285
|
-
|
|
5309
|
+
import_async17.synchronized
|
|
5286
5310
|
], DataSpaceManager.prototype, "close", null);
|
|
5287
5311
|
_ts_decorate5([
|
|
5288
|
-
|
|
5312
|
+
import_async17.synchronized
|
|
5289
5313
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
5290
5314
|
_ts_decorate5([
|
|
5291
|
-
|
|
5315
|
+
import_async17.synchronized
|
|
5292
5316
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
5293
5317
|
DataSpaceManager = _ts_decorate5([
|
|
5294
|
-
(0,
|
|
5318
|
+
(0, import_async17.trackLeaks)("open", "close")
|
|
5295
5319
|
], DataSpaceManager);
|
|
5296
5320
|
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
5297
5321
|
var SpacesServiceImpl = class {
|
|
@@ -5359,10 +5383,10 @@ var SpacesServiceImpl = class {
|
|
|
5359
5383
|
}
|
|
5360
5384
|
querySpaces() {
|
|
5361
5385
|
return new import_codec_protobuf11.Stream(({ next, ctx }) => {
|
|
5362
|
-
const scheduler = new
|
|
5386
|
+
const scheduler = new import_async18.UpdateScheduler(ctx, async () => {
|
|
5363
5387
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5364
5388
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
5365
|
-
(0,
|
|
5389
|
+
(0, import_log16.log)("update", {
|
|
5366
5390
|
spaces
|
|
5367
5391
|
}, {
|
|
5368
5392
|
F: __dxlog_file18,
|
|
@@ -5377,14 +5401,22 @@ var SpacesServiceImpl = class {
|
|
|
5377
5401
|
}, {
|
|
5378
5402
|
maxFrequency: process.env.NODE_ENV === "test" ? void 0 : 2
|
|
5379
5403
|
});
|
|
5380
|
-
(0,
|
|
5404
|
+
(0, import_async18.scheduleTask)(ctx, async () => {
|
|
5381
5405
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5382
|
-
const subscriptions = new
|
|
5406
|
+
const subscriptions = new import_async18.EventSubscriptions();
|
|
5383
5407
|
ctx.onDispose(() => subscriptions.clear());
|
|
5384
5408
|
const subscribeSpaces = () => {
|
|
5385
5409
|
subscriptions.clear();
|
|
5386
5410
|
for (const space of dataSpaceManager.spaces.values()) {
|
|
5387
|
-
|
|
5411
|
+
let lastState;
|
|
5412
|
+
subscriptions.add(space.stateUpdate.on(ctx, () => {
|
|
5413
|
+
if (space.state !== lastState) {
|
|
5414
|
+
scheduler.forceTrigger();
|
|
5415
|
+
} else {
|
|
5416
|
+
scheduler.trigger();
|
|
5417
|
+
}
|
|
5418
|
+
lastState = space.state;
|
|
5419
|
+
}));
|
|
5388
5420
|
subscriptions.add(space.presence.updated.on(ctx, () => scheduler.trigger()));
|
|
5389
5421
|
subscriptions.add(space.automergeSpaceState.onNewEpoch.on(ctx, () => scheduler.trigger()));
|
|
5390
5422
|
subscriptions.add(space.inner.controlPipeline.state.timeframeUpdate.on(ctx, () => scheduler.trigger()));
|
|
@@ -5411,7 +5443,7 @@ var SpacesServiceImpl = class {
|
|
|
5411
5443
|
}
|
|
5412
5444
|
subscribeMessages({ spaceKey, channel }) {
|
|
5413
5445
|
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
5414
|
-
(0,
|
|
5446
|
+
(0, import_async18.scheduleTask)(ctx, async () => {
|
|
5415
5447
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5416
5448
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols12.SpaceNotFoundError(spaceKey));
|
|
5417
5449
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
@@ -5430,7 +5462,7 @@ var SpacesServiceImpl = class {
|
|
|
5430
5462
|
}
|
|
5431
5463
|
};
|
|
5432
5464
|
ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
|
|
5433
|
-
(0,
|
|
5465
|
+
(0, import_async18.scheduleTask)(ctx, async () => {
|
|
5434
5466
|
await space.spaceState.addCredentialProcessor(processor);
|
|
5435
5467
|
if (noTail) {
|
|
5436
5468
|
close();
|
|
@@ -5450,7 +5482,7 @@ var SpacesServiceImpl = class {
|
|
|
5450
5482
|
} else {
|
|
5451
5483
|
(0, import_invariant16.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
5452
5484
|
F: __dxlog_file18,
|
|
5453
|
-
L:
|
|
5485
|
+
L: 209,
|
|
5454
5486
|
S: this,
|
|
5455
5487
|
A: [
|
|
5456
5488
|
"!credential.id",
|
|
@@ -5459,7 +5491,7 @@ var SpacesServiceImpl = class {
|
|
|
5459
5491
|
});
|
|
5460
5492
|
(0, import_invariant16.invariant)(this._identityManager.identity, "Identity is not available", {
|
|
5461
5493
|
F: __dxlog_file18,
|
|
5462
|
-
L:
|
|
5494
|
+
L: 210,
|
|
5463
5495
|
S: this,
|
|
5464
5496
|
A: [
|
|
5465
5497
|
"this._identityManager.identity",
|
|
@@ -5469,7 +5501,7 @@ var SpacesServiceImpl = class {
|
|
|
5469
5501
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
5470
5502
|
(0, import_invariant16.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
5471
5503
|
F: __dxlog_file18,
|
|
5472
|
-
L:
|
|
5504
|
+
L: 212,
|
|
5473
5505
|
S: this,
|
|
5474
5506
|
A: [
|
|
5475
5507
|
"credential.issuer.equals(signer.getIssuer())",
|
|
@@ -5577,7 +5609,7 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
5577
5609
|
this.networkManager = networkManager;
|
|
5578
5610
|
this.signalManager = signalManager;
|
|
5579
5611
|
this._runtimeParams = _runtimeParams;
|
|
5580
|
-
this.initialized = new
|
|
5612
|
+
this.initialized = new import_async19.Trigger();
|
|
5581
5613
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
5582
5614
|
this._instanceId = import_keys13.PublicKey.random().toHex();
|
|
5583
5615
|
this.metadataStore = new import_echo_pipeline5.MetadataStore(storage.createDirectory("metadata"));
|
|
@@ -5611,13 +5643,13 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
5611
5643
|
}
|
|
5612
5644
|
async _open(ctx) {
|
|
5613
5645
|
await this._checkStorageVersion();
|
|
5614
|
-
(0,
|
|
5646
|
+
(0, import_log17.log)("opening...", void 0, {
|
|
5615
5647
|
F: __dxlog_file19,
|
|
5616
5648
|
L: 149,
|
|
5617
5649
|
S: this,
|
|
5618
5650
|
C: (f, a) => f(...a)
|
|
5619
5651
|
});
|
|
5620
|
-
|
|
5652
|
+
import_log17.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.begin({
|
|
5621
5653
|
id: this._instanceId
|
|
5622
5654
|
}), {
|
|
5623
5655
|
F: __dxlog_file19,
|
|
@@ -5635,7 +5667,7 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
5635
5667
|
await this._initialize(ctx);
|
|
5636
5668
|
}
|
|
5637
5669
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
5638
|
-
(0,
|
|
5670
|
+
(0, import_log17.log)("loaded persistent invitations", {
|
|
5639
5671
|
count: loadedInvitations.invitations?.length
|
|
5640
5672
|
}, {
|
|
5641
5673
|
F: __dxlog_file19,
|
|
@@ -5643,7 +5675,7 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
5643
5675
|
S: this,
|
|
5644
5676
|
C: (f, a) => f(...a)
|
|
5645
5677
|
});
|
|
5646
|
-
|
|
5678
|
+
import_log17.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.end({
|
|
5647
5679
|
id: this._instanceId
|
|
5648
5680
|
}), {
|
|
5649
5681
|
F: __dxlog_file19,
|
|
@@ -5651,7 +5683,7 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
5651
5683
|
S: this,
|
|
5652
5684
|
C: (f, a) => f(...a)
|
|
5653
5685
|
});
|
|
5654
|
-
(0,
|
|
5686
|
+
(0, import_log17.log)("opened", void 0, {
|
|
5655
5687
|
F: __dxlog_file19,
|
|
5656
5688
|
L: 166,
|
|
5657
5689
|
S: this,
|
|
@@ -5659,7 +5691,7 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
5659
5691
|
});
|
|
5660
5692
|
}
|
|
5661
5693
|
async _close(ctx) {
|
|
5662
|
-
(0,
|
|
5694
|
+
(0, import_log17.log)("closing...", void 0, {
|
|
5663
5695
|
F: __dxlog_file19,
|
|
5664
5696
|
L: 170,
|
|
5665
5697
|
S: this,
|
|
@@ -5676,7 +5708,7 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
5676
5708
|
await this.echoHost.close(ctx);
|
|
5677
5709
|
await this.networkManager.close();
|
|
5678
5710
|
await this.signalManager.close();
|
|
5679
|
-
(0,
|
|
5711
|
+
(0, import_log17.log)("closed", void 0, {
|
|
5680
5712
|
F: __dxlog_file19,
|
|
5681
5713
|
L: 182,
|
|
5682
5714
|
S: this,
|
|
@@ -5722,7 +5754,7 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
5722
5754
|
}
|
|
5723
5755
|
// Called when identity is created.
|
|
5724
5756
|
async _initialize(ctx) {
|
|
5725
|
-
(0,
|
|
5757
|
+
(0, import_log17.log)("initializing spaces...", void 0, {
|
|
5726
5758
|
F: __dxlog_file19,
|
|
5727
5759
|
L: 224,
|
|
5728
5760
|
S: this,
|
|
@@ -5767,7 +5799,7 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
5767
5799
|
return;
|
|
5768
5800
|
}
|
|
5769
5801
|
if (!this.dataSpaceManager) {
|
|
5770
|
-
(0,
|
|
5802
|
+
(0, import_log17.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
5771
5803
|
details: assertion
|
|
5772
5804
|
}, {
|
|
5773
5805
|
F: __dxlog_file19,
|
|
@@ -5778,7 +5810,7 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
5778
5810
|
return;
|
|
5779
5811
|
}
|
|
5780
5812
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
5781
|
-
(0,
|
|
5813
|
+
(0, import_log17.log)("space already exists, ignoring space admission", {
|
|
5782
5814
|
details: assertion
|
|
5783
5815
|
}, {
|
|
5784
5816
|
F: __dxlog_file19,
|
|
@@ -5789,7 +5821,7 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
5789
5821
|
return;
|
|
5790
5822
|
}
|
|
5791
5823
|
try {
|
|
5792
|
-
(0,
|
|
5824
|
+
(0, import_log17.log)("accepting space recorded in halo", {
|
|
5793
5825
|
details: assertion
|
|
5794
5826
|
}, {
|
|
5795
5827
|
F: __dxlog_file19,
|
|
@@ -5802,7 +5834,7 @@ var ServiceContext = class extends import_context15.Resource {
|
|
|
5802
5834
|
genesisFeedKey: assertion.genesisFeedKey
|
|
5803
5835
|
});
|
|
5804
5836
|
} catch (err) {
|
|
5805
|
-
|
|
5837
|
+
import_log17.log.catch(err, void 0, {
|
|
5806
5838
|
F: __dxlog_file19,
|
|
5807
5839
|
L: 280,
|
|
5808
5840
|
S: this,
|
|
@@ -5821,7 +5853,7 @@ _ts_decorate6([
|
|
|
5821
5853
|
import_tracing8.trace.span()
|
|
5822
5854
|
], ServiceContext.prototype, "_initialize", null);
|
|
5823
5855
|
ServiceContext = _ts_decorate6([
|
|
5824
|
-
(0,
|
|
5856
|
+
(0, import_util11.safeInstanceof)("dxos.client-services.ServiceContext"),
|
|
5825
5857
|
import_tracing8.trace.resource()
|
|
5826
5858
|
], ServiceContext);
|
|
5827
5859
|
var ServiceRegistry = class {
|
|
@@ -5867,7 +5899,7 @@ var Lock = class {
|
|
|
5867
5899
|
return this._lockPath;
|
|
5868
5900
|
}
|
|
5869
5901
|
async acquire() {
|
|
5870
|
-
(0,
|
|
5902
|
+
(0, import_log18.log)("acquiring lock...", void 0, {
|
|
5871
5903
|
F: __dxlog_file20,
|
|
5872
5904
|
L: 32,
|
|
5873
5905
|
S: this,
|
|
@@ -5875,7 +5907,7 @@ var Lock = class {
|
|
|
5875
5907
|
});
|
|
5876
5908
|
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
5877
5909
|
await this._onAcquire?.();
|
|
5878
|
-
(0,
|
|
5910
|
+
(0, import_log18.log)("acquired lock", void 0, {
|
|
5879
5911
|
F: __dxlog_file20,
|
|
5880
5912
|
L: 37,
|
|
5881
5913
|
S: this,
|
|
@@ -5897,11 +5929,11 @@ var Lock = class {
|
|
|
5897
5929
|
}
|
|
5898
5930
|
};
|
|
5899
5931
|
_ts_decorate7([
|
|
5900
|
-
|
|
5932
|
+
import_log18.logInfo
|
|
5901
5933
|
], Lock.prototype, "lockKey", null);
|
|
5902
5934
|
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
5903
5935
|
var getRootPath = (config) => {
|
|
5904
|
-
const { dataRoot = (0,
|
|
5936
|
+
const { dataRoot = (0, import_util12.isNode)() ? import_client_protocol6.DX_DATA : "dxos/storage" } = config ?? {};
|
|
5905
5937
|
return `${dataRoot}/`;
|
|
5906
5938
|
};
|
|
5907
5939
|
var isPersistent = (config) => {
|
|
@@ -6016,7 +6048,7 @@ var DevicesServiceImpl = class {
|
|
|
6016
6048
|
presenceSubscribed = true;
|
|
6017
6049
|
}
|
|
6018
6050
|
};
|
|
6019
|
-
const subscriptions = new
|
|
6051
|
+
const subscriptions = new import_async21.EventSubscriptions();
|
|
6020
6052
|
if (this._identityManager.identity) {
|
|
6021
6053
|
subscribeIdentity();
|
|
6022
6054
|
subscribePresence();
|
|
@@ -6056,7 +6088,7 @@ var DiagnosticsCollector = class {
|
|
|
6056
6088
|
client: clientDiagnostics,
|
|
6057
6089
|
broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
|
|
6058
6090
|
};
|
|
6059
|
-
return JSON.parse(JSON.stringify(diagnostics, (0,
|
|
6091
|
+
return JSON.parse(JSON.stringify(diagnostics, (0, import_util13.jsonKeyReplacer)(options)));
|
|
6060
6092
|
}
|
|
6061
6093
|
};
|
|
6062
6094
|
var findSystemServiceProvider = () => {
|
|
@@ -6066,11 +6098,11 @@ var findSystemServiceProvider = () => {
|
|
|
6066
6098
|
};
|
|
6067
6099
|
var findConfigs = () => {
|
|
6068
6100
|
const configs = import_tracing10.TRACE_PROCESSOR.findResourcesByAnnotation(import_config3.ConfigResource);
|
|
6069
|
-
return configs.map((r) => r.instance.deref()).filter(
|
|
6101
|
+
return configs.map((r) => r.instance.deref()).filter(import_util13.nonNullable);
|
|
6070
6102
|
};
|
|
6071
6103
|
var LoggingServiceImpl = class {
|
|
6072
6104
|
constructor() {
|
|
6073
|
-
this._logs = new
|
|
6105
|
+
this._logs = new import_async22.Event();
|
|
6074
6106
|
this._started = Date.now();
|
|
6075
6107
|
this._sessionId = import_keys17.PublicKey.random().toHex();
|
|
6076
6108
|
this._logProcessor = (_config, entry2) => {
|
|
@@ -6078,23 +6110,23 @@ var LoggingServiceImpl = class {
|
|
|
6078
6110
|
};
|
|
6079
6111
|
}
|
|
6080
6112
|
async open() {
|
|
6081
|
-
|
|
6113
|
+
import_log20.log.runtimeConfig.processors.push(this._logProcessor);
|
|
6082
6114
|
}
|
|
6083
6115
|
async close() {
|
|
6084
|
-
const index =
|
|
6085
|
-
|
|
6116
|
+
const index = import_log20.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
6117
|
+
import_log20.log.runtimeConfig.processors.splice(index, 1);
|
|
6086
6118
|
}
|
|
6087
6119
|
async controlMetrics({ reset, record }) {
|
|
6088
6120
|
if (reset) {
|
|
6089
|
-
|
|
6121
|
+
import_util15.tracer.clear();
|
|
6090
6122
|
}
|
|
6091
6123
|
if (record === true) {
|
|
6092
|
-
|
|
6124
|
+
import_util15.tracer.start();
|
|
6093
6125
|
} else if (record === false) {
|
|
6094
|
-
|
|
6126
|
+
import_util15.tracer.stop();
|
|
6095
6127
|
}
|
|
6096
6128
|
return {
|
|
6097
|
-
recording:
|
|
6129
|
+
recording: import_util15.tracer.recording
|
|
6098
6130
|
};
|
|
6099
6131
|
}
|
|
6100
6132
|
/**
|
|
@@ -6102,10 +6134,10 @@ var LoggingServiceImpl = class {
|
|
|
6102
6134
|
*/
|
|
6103
6135
|
queryMetrics({ interval = 5e3 }) {
|
|
6104
6136
|
const getNumericalValues = (key) => {
|
|
6105
|
-
const events =
|
|
6137
|
+
const events = import_util15.tracer.get(key) ?? [];
|
|
6106
6138
|
return {
|
|
6107
6139
|
key,
|
|
6108
|
-
stats: (0,
|
|
6140
|
+
stats: (0, import_util15.numericalValues)(events, "duration")
|
|
6109
6141
|
};
|
|
6110
6142
|
};
|
|
6111
6143
|
return new import_codec_protobuf13.Stream(({ next }) => {
|
|
@@ -6143,7 +6175,7 @@ var LoggingServiceImpl = class {
|
|
|
6143
6175
|
}
|
|
6144
6176
|
const record = {
|
|
6145
6177
|
...entry2,
|
|
6146
|
-
context: (0,
|
|
6178
|
+
context: (0, import_util15.jsonify)((0, import_log20.getContextFromEntry)(entry2)),
|
|
6147
6179
|
timestamp: /* @__PURE__ */ new Date(),
|
|
6148
6180
|
meta: {
|
|
6149
6181
|
// TODO(dmaretskyi): Fix proto.
|
|
@@ -6152,7 +6184,7 @@ var LoggingServiceImpl = class {
|
|
|
6152
6184
|
scope: {
|
|
6153
6185
|
hostSessionId: this._sessionId,
|
|
6154
6186
|
uptimeSeconds: (Date.now() - this._started) / 1e3,
|
|
6155
|
-
name: (0,
|
|
6187
|
+
name: (0, import_util15.getDebugName)(entry2.meta?.S)
|
|
6156
6188
|
}
|
|
6157
6189
|
}
|
|
6158
6190
|
};
|
|
@@ -6233,7 +6265,7 @@ var SystemServiceImpl = class {
|
|
|
6233
6265
|
const diagnostics = await this._getDiagnostics();
|
|
6234
6266
|
return {
|
|
6235
6267
|
timestamp: /* @__PURE__ */ new Date(),
|
|
6236
|
-
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0,
|
|
6268
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util16.jsonKeyReplacer)({
|
|
6237
6269
|
truncate: keys === import_services21.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
6238
6270
|
humanize: keys === import_services21.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
6239
6271
|
})))
|
|
@@ -6290,7 +6322,7 @@ var ClientServicesHost = class {
|
|
|
6290
6322
|
runtimeParams
|
|
6291
6323
|
} = {}) {
|
|
6292
6324
|
this._tracingService = import_tracing9.TRACE_PROCESSOR.createTraceSender();
|
|
6293
|
-
this._statusUpdate = new
|
|
6325
|
+
this._statusUpdate = new import_async20.Event();
|
|
6294
6326
|
this._opening = false;
|
|
6295
6327
|
this._open = false;
|
|
6296
6328
|
this._storage = storage;
|
|
@@ -6373,7 +6405,7 @@ var ClientServicesHost = class {
|
|
|
6373
6405
|
"'service host is open'"
|
|
6374
6406
|
]
|
|
6375
6407
|
});
|
|
6376
|
-
(0,
|
|
6408
|
+
(0, import_log19.log)("initializing...", void 0, {
|
|
6377
6409
|
F: __dxlog_file22,
|
|
6378
6410
|
L: 187,
|
|
6379
6411
|
S: this,
|
|
@@ -6395,7 +6427,7 @@ var ClientServicesHost = class {
|
|
|
6395
6427
|
}
|
|
6396
6428
|
}
|
|
6397
6429
|
if (!options.signalManager) {
|
|
6398
|
-
|
|
6430
|
+
import_log19.log.warn("running signaling without telemetry metadata.", void 0, {
|
|
6399
6431
|
F: __dxlog_file22,
|
|
6400
6432
|
L: 198,
|
|
6401
6433
|
S: this,
|
|
@@ -6420,7 +6452,7 @@ var ClientServicesHost = class {
|
|
|
6420
6452
|
transportFactory,
|
|
6421
6453
|
signalManager
|
|
6422
6454
|
});
|
|
6423
|
-
(0,
|
|
6455
|
+
(0, import_log19.log)("initialized", void 0, {
|
|
6424
6456
|
F: __dxlog_file22,
|
|
6425
6457
|
L: 216,
|
|
6426
6458
|
S: this,
|
|
@@ -6432,7 +6464,7 @@ var ClientServicesHost = class {
|
|
|
6432
6464
|
return;
|
|
6433
6465
|
}
|
|
6434
6466
|
const traceId = import_keys15.PublicKey.random().toHex();
|
|
6435
|
-
|
|
6467
|
+
import_log19.log.trace("dxos.client-services.host.open", import_protocols15.trace.begin({
|
|
6436
6468
|
id: traceId
|
|
6437
6469
|
}), {
|
|
6438
6470
|
F: __dxlog_file22,
|
|
@@ -6477,7 +6509,7 @@ var ClientServicesHost = class {
|
|
|
6477
6509
|
]
|
|
6478
6510
|
});
|
|
6479
6511
|
this._opening = true;
|
|
6480
|
-
(0,
|
|
6512
|
+
(0, import_log19.log)("opening...", {
|
|
6481
6513
|
lockKey: this._resourceLock?.lockKey
|
|
6482
6514
|
}, {
|
|
6483
6515
|
F: __dxlog_file22,
|
|
@@ -6531,7 +6563,7 @@ var ClientServicesHost = class {
|
|
|
6531
6563
|
this._open = true;
|
|
6532
6564
|
this._statusUpdate.emit();
|
|
6533
6565
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6534
|
-
(0,
|
|
6566
|
+
(0, import_log19.log)("opened", {
|
|
6535
6567
|
deviceKey
|
|
6536
6568
|
}, {
|
|
6537
6569
|
F: __dxlog_file22,
|
|
@@ -6539,7 +6571,7 @@ var ClientServicesHost = class {
|
|
|
6539
6571
|
S: this,
|
|
6540
6572
|
C: (f, a) => f(...a)
|
|
6541
6573
|
});
|
|
6542
|
-
|
|
6574
|
+
import_log19.log.trace("dxos.client-services.host.open", import_protocols15.trace.end({
|
|
6543
6575
|
id: traceId
|
|
6544
6576
|
}), {
|
|
6545
6577
|
F: __dxlog_file22,
|
|
@@ -6553,7 +6585,7 @@ var ClientServicesHost = class {
|
|
|
6553
6585
|
return;
|
|
6554
6586
|
}
|
|
6555
6587
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6556
|
-
(0,
|
|
6588
|
+
(0, import_log19.log)("closing...", {
|
|
6557
6589
|
deviceKey
|
|
6558
6590
|
}, {
|
|
6559
6591
|
F: __dxlog_file22,
|
|
@@ -6571,7 +6603,7 @@ var ClientServicesHost = class {
|
|
|
6571
6603
|
await this._level?.close();
|
|
6572
6604
|
this._open = false;
|
|
6573
6605
|
this._statusUpdate.emit();
|
|
6574
|
-
(0,
|
|
6606
|
+
(0, import_log19.log)("closed", {
|
|
6575
6607
|
deviceKey
|
|
6576
6608
|
}, {
|
|
6577
6609
|
F: __dxlog_file22,
|
|
@@ -6582,7 +6614,7 @@ var ClientServicesHost = class {
|
|
|
6582
6614
|
}
|
|
6583
6615
|
async reset() {
|
|
6584
6616
|
const traceId = import_keys15.PublicKey.random().toHex();
|
|
6585
|
-
|
|
6617
|
+
import_log19.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.begin({
|
|
6586
6618
|
id: traceId
|
|
6587
6619
|
}), {
|
|
6588
6620
|
F: __dxlog_file22,
|
|
@@ -6590,7 +6622,7 @@ var ClientServicesHost = class {
|
|
|
6590
6622
|
S: this,
|
|
6591
6623
|
C: (f, a) => f(...a)
|
|
6592
6624
|
});
|
|
6593
|
-
|
|
6625
|
+
import_log19.log.info("resetting...", void 0, {
|
|
6594
6626
|
F: __dxlog_file22,
|
|
6595
6627
|
L: 342,
|
|
6596
6628
|
S: this,
|
|
@@ -6598,13 +6630,13 @@ var ClientServicesHost = class {
|
|
|
6598
6630
|
});
|
|
6599
6631
|
await this._serviceContext?.close();
|
|
6600
6632
|
await this._storage.reset();
|
|
6601
|
-
|
|
6633
|
+
import_log19.log.info("reset", void 0, {
|
|
6602
6634
|
F: __dxlog_file22,
|
|
6603
6635
|
L: 345,
|
|
6604
6636
|
S: this,
|
|
6605
6637
|
C: (f, a) => f(...a)
|
|
6606
6638
|
});
|
|
6607
|
-
|
|
6639
|
+
import_log19.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.end({
|
|
6608
6640
|
id: traceId
|
|
6609
6641
|
}), {
|
|
6610
6642
|
F: __dxlog_file22,
|
|
@@ -6627,11 +6659,11 @@ _ts_decorate8([
|
|
|
6627
6659
|
import_tracing9.trace.info()
|
|
6628
6660
|
], ClientServicesHost.prototype, "_open", void 0);
|
|
6629
6661
|
_ts_decorate8([
|
|
6630
|
-
|
|
6662
|
+
import_async20.synchronized,
|
|
6631
6663
|
import_tracing9.trace.span()
|
|
6632
6664
|
], ClientServicesHost.prototype, "open", null);
|
|
6633
6665
|
_ts_decorate8([
|
|
6634
|
-
|
|
6666
|
+
import_async20.synchronized,
|
|
6635
6667
|
import_tracing9.trace.span()
|
|
6636
6668
|
], ClientServicesHost.prototype, "close", null);
|
|
6637
6669
|
ClientServicesHost = _ts_decorate8([
|
|
@@ -6677,4 +6709,4 @@ ClientServicesHost = _ts_decorate8([
|
|
|
6677
6709
|
subscribeToSpaces,
|
|
6678
6710
|
subscribeToSwarmInfo
|
|
6679
6711
|
});
|
|
6680
|
-
//# sourceMappingURL=chunk-
|
|
6712
|
+
//# sourceMappingURL=chunk-DG6DPGCI.cjs.map
|