@dxos/client-services 0.5.9-main.b8d8fee → 0.5.9-main.bd9c8b3
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-2EFXBSRZ.mjs → chunk-KI7FY3ZO.mjs} +718 -555
- package/dist/lib/browser/chunk-KI7FY3ZO.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -3
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +2 -3
- package/dist/lib/browser/packlets/testing/index.mjs.map +2 -2
- package/dist/lib/node/{chunk-2SS7JAIR.cjs → chunk-XWMOEZYI.cjs} +869 -709
- package/dist/lib/node/chunk-XWMOEZYI.cjs.map +7 -0
- package/dist/lib/node/index.cjs +41 -43
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +9 -10
- package/dist/lib/node/packlets/testing/index.cjs.map +2 -2
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +4 -1
- package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +9 -9
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/epoch-migrations.d.ts +23 -0
- package/dist/types/src/packlets/spaces/epoch-migrations.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -2
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.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 +33 -7
- package/src/packlets/services/service-context.ts +1 -4
- package/src/packlets/spaces/automerge-space-state.ts +11 -2
- package/src/packlets/spaces/data-space-manager.ts +35 -14
- package/src/packlets/spaces/data-space.ts +76 -148
- package/src/packlets/spaces/epoch-migrations.ts +135 -0
- package/src/packlets/spaces/spaces-service.ts +16 -4
- package/src/packlets/testing/test-builder.ts +1 -4
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-2EFXBSRZ.mjs.map +0 -7
- package/dist/lib/node/chunk-2SS7JAIR.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_XWMOEZYI_exports = {};
|
|
30
|
+
__export(chunk_XWMOEZYI_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
33
|
ClientServicesProviderResource: () => ClientServicesProviderResource,
|
|
@@ -56,7 +56,6 @@ __export(chunk_2SS7JAIR_exports, {
|
|
|
56
56
|
createDiagnostics: () => createDiagnostics,
|
|
57
57
|
createLevel: () => createLevel,
|
|
58
58
|
createStorageObjects: () => createStorageObjects,
|
|
59
|
-
findPropertiesObject: () => findPropertiesObject,
|
|
60
59
|
getNetworkPeers: () => getNetworkPeers,
|
|
61
60
|
isLocked: () => isLocked,
|
|
62
61
|
subscribeToFeedBlocks: () => subscribeToFeedBlocks,
|
|
@@ -67,7 +66,7 @@ __export(chunk_2SS7JAIR_exports, {
|
|
|
67
66
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
68
67
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
69
68
|
});
|
|
70
|
-
module.exports = __toCommonJS(
|
|
69
|
+
module.exports = __toCommonJS(chunk_XWMOEZYI_exports);
|
|
71
70
|
var import_async = require("@dxos/async");
|
|
72
71
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
73
72
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -127,186 +126,201 @@ var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip"
|
|
|
127
126
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
128
127
|
var import_tracing4 = require("@dxos/tracing");
|
|
129
128
|
var import_util3 = require("@dxos/util");
|
|
129
|
+
var import_async8 = require("@dxos/async");
|
|
130
130
|
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
131
131
|
var import_context4 = require("@dxos/context");
|
|
132
132
|
var import_credentials8 = require("@dxos/credentials");
|
|
133
133
|
var import_debug2 = require("@dxos/debug");
|
|
134
134
|
var import_invariant4 = require("@dxos/invariant");
|
|
135
|
+
var import_log5 = require("@dxos/log");
|
|
135
136
|
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
137
|
+
var import_util4 = require("@dxos/util");
|
|
136
138
|
var import_invariant5 = require("@dxos/invariant");
|
|
137
139
|
var import_protocols4 = require("@dxos/protocols");
|
|
138
140
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
139
|
-
var
|
|
141
|
+
var import_async9 = require("@dxos/async");
|
|
140
142
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
141
143
|
var import_context5 = require("@dxos/context");
|
|
142
144
|
var import_crypto = require("@dxos/crypto");
|
|
143
145
|
var import_invariant6 = require("@dxos/invariant");
|
|
144
146
|
var import_keys6 = require("@dxos/keys");
|
|
145
|
-
var
|
|
147
|
+
var import_log6 = require("@dxos/log");
|
|
146
148
|
var import_network_manager = require("@dxos/network-manager");
|
|
147
149
|
var import_protocols5 = require("@dxos/protocols");
|
|
148
150
|
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
149
151
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
150
152
|
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
151
|
-
var
|
|
152
|
-
var
|
|
153
|
+
var import_util5 = require("@dxos/util");
|
|
154
|
+
var import_async10 = require("@dxos/async");
|
|
153
155
|
var import_context6 = require("@dxos/context");
|
|
154
156
|
var import_invariant7 = require("@dxos/invariant");
|
|
155
|
-
var
|
|
157
|
+
var import_log7 = require("@dxos/log");
|
|
156
158
|
var import_protocols6 = require("@dxos/protocols");
|
|
157
159
|
var import_invitations3 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
158
160
|
var import_teleport = require("@dxos/teleport");
|
|
159
161
|
var import_context7 = require("@dxos/context");
|
|
160
162
|
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
161
|
-
var
|
|
163
|
+
var import_async11 = require("@dxos/async");
|
|
162
164
|
var import_context8 = require("@dxos/context");
|
|
163
165
|
var import_crypto2 = require("@dxos/crypto");
|
|
164
166
|
var import_invariant8 = require("@dxos/invariant");
|
|
165
167
|
var import_keys7 = require("@dxos/keys");
|
|
166
|
-
var
|
|
168
|
+
var import_log8 = require("@dxos/log");
|
|
167
169
|
var import_protocols7 = require("@dxos/protocols");
|
|
168
170
|
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
169
171
|
var import_invitations4 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
170
172
|
var import_teleport2 = require("@dxos/teleport");
|
|
171
173
|
var import_invariant9 = require("@dxos/invariant");
|
|
172
174
|
var import_keys8 = require("@dxos/keys");
|
|
173
|
-
var
|
|
175
|
+
var import_log9 = require("@dxos/log");
|
|
174
176
|
var import_invitations5 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
175
|
-
var
|
|
177
|
+
var import_util6 = require("@dxos/util");
|
|
176
178
|
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
177
179
|
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
178
180
|
var import_credentials9 = require("@dxos/credentials");
|
|
179
181
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
180
182
|
var import_invariant10 = require("@dxos/invariant");
|
|
181
|
-
var
|
|
183
|
+
var import_log10 = require("@dxos/log");
|
|
182
184
|
var import_protocols8 = require("@dxos/protocols");
|
|
183
185
|
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
184
186
|
var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
185
|
-
var
|
|
187
|
+
var import_async12 = require("@dxos/async");
|
|
186
188
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
187
189
|
var import_context9 = require("@dxos/context");
|
|
188
190
|
var import_credentials11 = require("@dxos/credentials");
|
|
189
191
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
190
192
|
var import_invariant11 = require("@dxos/invariant");
|
|
191
193
|
var import_keys9 = require("@dxos/keys");
|
|
192
|
-
var
|
|
194
|
+
var import_log11 = require("@dxos/log");
|
|
193
195
|
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
194
196
|
var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
195
|
-
var
|
|
197
|
+
var import_async13 = require("@dxos/async");
|
|
196
198
|
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
197
199
|
var import_context10 = require("@dxos/context");
|
|
198
200
|
var import_debug3 = require("@dxos/debug");
|
|
199
201
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
200
|
-
var
|
|
202
|
+
var import_echo_protocol = require("@dxos/echo-protocol");
|
|
201
203
|
var import_invariant12 = require("@dxos/invariant");
|
|
202
204
|
var import_keys10 = require("@dxos/keys");
|
|
203
|
-
var
|
|
205
|
+
var import_log12 = require("@dxos/log");
|
|
204
206
|
var import_protocols9 = require("@dxos/protocols");
|
|
205
207
|
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
206
208
|
var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
207
209
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
208
210
|
var import_tracing5 = require("@dxos/tracing");
|
|
209
|
-
var
|
|
210
|
-
var import_async13 = require("@dxos/async");
|
|
211
|
-
var import_credentials14 = require("@dxos/credentials");
|
|
211
|
+
var import_util7 = require("@dxos/util");
|
|
212
212
|
var import_async14 = require("@dxos/async");
|
|
213
213
|
var import_context11 = require("@dxos/context");
|
|
214
|
+
var import_credentials14 = require("@dxos/credentials");
|
|
215
|
+
var import_async15 = require("@dxos/async");
|
|
216
|
+
var import_automerge = require("@dxos/automerge/automerge");
|
|
217
|
+
var import_context12 = require("@dxos/context");
|
|
218
|
+
var import_echo_db = require("@dxos/echo-db");
|
|
219
|
+
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
220
|
+
var import_echo_schema = require("@dxos/echo-schema");
|
|
214
221
|
var import_invariant13 = require("@dxos/invariant");
|
|
222
|
+
var import_log13 = require("@dxos/log");
|
|
223
|
+
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
224
|
+
var import_util8 = require("@dxos/util");
|
|
225
|
+
var import_async16 = require("@dxos/async");
|
|
226
|
+
var import_context13 = require("@dxos/context");
|
|
227
|
+
var import_invariant14 = require("@dxos/invariant");
|
|
215
228
|
var import_keys11 = require("@dxos/keys");
|
|
216
|
-
var
|
|
229
|
+
var import_log14 = require("@dxos/log");
|
|
217
230
|
var import_protocols10 = require("@dxos/protocols");
|
|
218
231
|
var import_teleport3 = require("@dxos/teleport");
|
|
219
|
-
var
|
|
220
|
-
var
|
|
232
|
+
var import_util9 = require("@dxos/util");
|
|
233
|
+
var import_async17 = require("@dxos/async");
|
|
221
234
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
222
|
-
var
|
|
235
|
+
var import_context14 = require("@dxos/context");
|
|
223
236
|
var import_credentials15 = require("@dxos/credentials");
|
|
224
|
-
var
|
|
225
|
-
var
|
|
237
|
+
var import_echo_db2 = require("@dxos/echo-db");
|
|
238
|
+
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
239
|
+
var import_echo_protocol2 = require("@dxos/echo-protocol");
|
|
226
240
|
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
227
|
-
var
|
|
241
|
+
var import_invariant15 = require("@dxos/invariant");
|
|
228
242
|
var import_keys12 = require("@dxos/keys");
|
|
229
|
-
var
|
|
243
|
+
var import_log15 = require("@dxos/log");
|
|
230
244
|
var import_protocols11 = require("@dxos/protocols");
|
|
231
|
-
var
|
|
245
|
+
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
232
246
|
var import_credentials16 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
233
247
|
var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
|
|
234
248
|
var import_tracing6 = require("@dxos/tracing");
|
|
235
|
-
var
|
|
249
|
+
var import_util10 = require("@dxos/util");
|
|
236
250
|
var import_credentials17 = require("@dxos/credentials");
|
|
237
251
|
var import_debug4 = require("@dxos/debug");
|
|
238
252
|
var import_credentials18 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
239
253
|
var import_timeframe4 = require("@dxos/timeframe");
|
|
240
|
-
var
|
|
254
|
+
var import_async18 = require("@dxos/async");
|
|
241
255
|
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
242
256
|
var import_credentials19 = require("@dxos/credentials");
|
|
243
257
|
var import_debug5 = require("@dxos/debug");
|
|
244
258
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
245
|
-
var
|
|
246
|
-
var
|
|
259
|
+
var import_invariant16 = require("@dxos/invariant");
|
|
260
|
+
var import_log16 = require("@dxos/log");
|
|
247
261
|
var import_protocols12 = require("@dxos/protocols");
|
|
248
|
-
var
|
|
262
|
+
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
249
263
|
var import_tracing7 = require("@dxos/tracing");
|
|
250
|
-
var
|
|
251
|
-
var
|
|
264
|
+
var import_async19 = require("@dxos/async");
|
|
265
|
+
var import_context15 = require("@dxos/context");
|
|
252
266
|
var import_credentials20 = require("@dxos/credentials");
|
|
253
267
|
var import_debug6 = require("@dxos/debug");
|
|
254
|
-
var
|
|
255
|
-
var
|
|
268
|
+
var import_echo_db3 = require("@dxos/echo-db");
|
|
269
|
+
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
256
270
|
var import_feed_store5 = require("@dxos/feed-store");
|
|
257
|
-
var
|
|
271
|
+
var import_invariant17 = require("@dxos/invariant");
|
|
258
272
|
var import_keyring = require("@dxos/keyring");
|
|
259
273
|
var import_keys13 = require("@dxos/keys");
|
|
260
|
-
var
|
|
274
|
+
var import_log17 = require("@dxos/log");
|
|
261
275
|
var import_protocols13 = require("@dxos/protocols");
|
|
262
|
-
var
|
|
276
|
+
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
263
277
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
264
278
|
var import_tracing8 = require("@dxos/tracing");
|
|
265
|
-
var
|
|
266
|
-
var
|
|
279
|
+
var import_util11 = require("@dxos/util");
|
|
280
|
+
var import_invariant18 = require("@dxos/invariant");
|
|
267
281
|
var import_lock_file = require("@dxos/lock-file");
|
|
268
|
-
var
|
|
282
|
+
var import_log18 = require("@dxos/log");
|
|
269
283
|
var import_protocols14 = require("@dxos/protocols");
|
|
270
284
|
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
271
285
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
272
286
|
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
273
287
|
var import_config2 = require("@dxos/protocols/proto/dxos/config");
|
|
274
|
-
var
|
|
288
|
+
var import_util12 = require("@dxos/util");
|
|
275
289
|
var import_node_path = __toESM(require("node:path"));
|
|
276
290
|
var import_keys14 = require("@dxos/keys");
|
|
277
291
|
var import_kv_store = require("@dxos/kv-store");
|
|
278
|
-
var
|
|
292
|
+
var import_async20 = require("@dxos/async");
|
|
279
293
|
var import_client_protocol7 = require("@dxos/client-protocol");
|
|
280
|
-
var
|
|
281
|
-
var
|
|
294
|
+
var import_context16 = require("@dxos/context");
|
|
295
|
+
var import_invariant19 = require("@dxos/invariant");
|
|
282
296
|
var import_keys15 = require("@dxos/keys");
|
|
283
|
-
var
|
|
297
|
+
var import_log19 = require("@dxos/log");
|
|
284
298
|
var import_messaging = require("@dxos/messaging");
|
|
285
299
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
286
300
|
var import_protocols15 = require("@dxos/protocols");
|
|
287
|
-
var
|
|
301
|
+
var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
|
|
288
302
|
var import_tracing9 = require("@dxos/tracing");
|
|
289
303
|
var import_websocket_rpc = require("@dxos/websocket-rpc");
|
|
290
|
-
var
|
|
304
|
+
var import_async21 = require("@dxos/async");
|
|
291
305
|
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
292
|
-
var
|
|
293
|
-
var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
|
|
294
|
-
var import_config3 = require("@dxos/config");
|
|
306
|
+
var import_invariant20 = require("@dxos/invariant");
|
|
295
307
|
var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
|
|
308
|
+
var import_config3 = require("@dxos/config");
|
|
309
|
+
var import_services19 = require("@dxos/protocols/proto/dxos/client/services");
|
|
296
310
|
var import_tracing10 = require("@dxos/tracing");
|
|
297
|
-
var
|
|
311
|
+
var import_util13 = require("@dxos/util");
|
|
298
312
|
var import_keys16 = require("@dxos/keys");
|
|
299
|
-
var
|
|
300
|
-
var
|
|
313
|
+
var import_util14 = require("@dxos/util");
|
|
314
|
+
var import_async22 = require("@dxos/async");
|
|
301
315
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
302
316
|
var import_keys17 = require("@dxos/keys");
|
|
303
|
-
var
|
|
304
|
-
var
|
|
305
|
-
var
|
|
317
|
+
var import_log20 = require("@dxos/log");
|
|
318
|
+
var import_services20 = require("@dxos/protocols/proto/dxos/client/services");
|
|
319
|
+
var import_util15 = require("@dxos/util");
|
|
306
320
|
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
307
321
|
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
308
|
-
var
|
|
309
|
-
var
|
|
322
|
+
var import_services21 = require("@dxos/protocols/proto/dxos/client/services");
|
|
323
|
+
var import_util16 = require("@dxos/util");
|
|
310
324
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
311
325
|
return new import_codec_protobuf.Stream(({ next }) => {
|
|
312
326
|
const subscriptions = new import_async.EventSubscriptions();
|
|
@@ -617,7 +631,7 @@ var DevtoolsServiceImpl = class {
|
|
|
617
631
|
});
|
|
618
632
|
}
|
|
619
633
|
};
|
|
620
|
-
var DXOS_VERSION = "0.5.9-main.
|
|
634
|
+
var DXOS_VERSION = "0.5.9-main.bd9c8b3";
|
|
621
635
|
var getPlatform = () => {
|
|
622
636
|
if (process.browser) {
|
|
623
637
|
if (typeof window !== "undefined") {
|
|
@@ -1646,6 +1660,7 @@ IdentityManager = _ts_decorate3([
|
|
|
1646
1660
|
import_tracing4.trace.resource()
|
|
1647
1661
|
], IdentityManager);
|
|
1648
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;
|
|
1649
1664
|
var IdentityServiceImpl = class extends import_context4.Resource {
|
|
1650
1665
|
constructor(_identityManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
|
|
1651
1666
|
super();
|
|
@@ -1675,7 +1690,7 @@ var IdentityServiceImpl = class extends import_context4.Resource {
|
|
|
1675
1690
|
const identity = this._identityManager.identity;
|
|
1676
1691
|
(0, import_invariant4.invariant)(identity, void 0, {
|
|
1677
1692
|
F: __dxlog_file6,
|
|
1678
|
-
L:
|
|
1693
|
+
L: 59,
|
|
1679
1694
|
S: this,
|
|
1680
1695
|
A: [
|
|
1681
1696
|
"identity",
|
|
@@ -1709,7 +1724,7 @@ var IdentityServiceImpl = class extends import_context4.Resource {
|
|
|
1709
1724
|
async updateProfile(profile) {
|
|
1710
1725
|
(0, import_invariant4.invariant)(this._identityManager.identity, "Identity not initialized.", {
|
|
1711
1726
|
F: __dxlog_file6,
|
|
1712
|
-
L:
|
|
1727
|
+
L: 89,
|
|
1713
1728
|
S: this,
|
|
1714
1729
|
A: [
|
|
1715
1730
|
"this._identityManager.identity",
|
|
@@ -1723,7 +1738,7 @@ var IdentityServiceImpl = class extends import_context4.Resource {
|
|
|
1723
1738
|
async signPresentation({ presentation, nonce }) {
|
|
1724
1739
|
(0, import_invariant4.invariant)(this._identityManager.identity, "Identity not initialized.", {
|
|
1725
1740
|
F: __dxlog_file6,
|
|
1726
|
-
L:
|
|
1741
|
+
L: 96,
|
|
1727
1742
|
S: this,
|
|
1728
1743
|
A: [
|
|
1729
1744
|
"this._identityManager.identity",
|
|
@@ -1739,20 +1754,43 @@ var IdentityServiceImpl = class extends import_context4.Resource {
|
|
|
1739
1754
|
});
|
|
1740
1755
|
}
|
|
1741
1756
|
async _fixIdentityWithoutDefaultSpace(identity) {
|
|
1742
|
-
let
|
|
1757
|
+
let recodedDefaultSpace = false;
|
|
1758
|
+
let foundDefaultSpace = false;
|
|
1743
1759
|
const dataSpaceManager = this._dataSpaceManagerProvider();
|
|
1744
|
-
|
|
1760
|
+
const recordedDefaultSpaceTrigger = new import_async8.Trigger();
|
|
1761
|
+
const allProcessed = (0, import_util4.safeAwaitAll)(dataSpaceManager.spaces.values(), async (space) => {
|
|
1745
1762
|
if (space.state === import_services4.SpaceState.CLOSED) {
|
|
1746
1763
|
await space.open();
|
|
1747
|
-
|
|
1764
|
+
const requiresMigration = space.stateUpdate.waitForCondition(() => space.state === import_services4.SpaceState.REQUIRES_MIGRATION);
|
|
1765
|
+
await Promise.race([
|
|
1766
|
+
space.initializeDataPipeline(),
|
|
1767
|
+
requiresMigration
|
|
1768
|
+
]);
|
|
1748
1769
|
}
|
|
1749
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;
|
|
1750
1783
|
await identity.updateDefaultSpace(space.id);
|
|
1751
|
-
|
|
1752
|
-
|
|
1784
|
+
recodedDefaultSpace = true;
|
|
1785
|
+
recordedDefaultSpaceTrigger.wake();
|
|
1753
1786
|
}
|
|
1754
|
-
}
|
|
1755
|
-
|
|
1787
|
+
});
|
|
1788
|
+
await Promise.race([
|
|
1789
|
+
allProcessed,
|
|
1790
|
+
recordedDefaultSpaceTrigger.wait(),
|
|
1791
|
+
(0, import_async8.sleep)(DEFAULT_SPACE_SEARCH_TIMEOUT)
|
|
1792
|
+
]);
|
|
1793
|
+
if (!recodedDefaultSpace) {
|
|
1756
1794
|
await this._createDefaultSpace(dataSpaceManager);
|
|
1757
1795
|
}
|
|
1758
1796
|
}
|
|
@@ -1893,7 +1931,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1893
1931
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
1894
1932
|
this._callbacks = _callbacks;
|
|
1895
1933
|
this._ctx = new import_context6.Context();
|
|
1896
|
-
this._remoteOptionsTrigger = new
|
|
1934
|
+
this._remoteOptionsTrigger = new import_async10.Trigger();
|
|
1897
1935
|
this._invitationFlowLock = null;
|
|
1898
1936
|
}
|
|
1899
1937
|
hasFlowLock() {
|
|
@@ -1930,14 +1968,14 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1930
1968
|
async onOpen(context) {
|
|
1931
1969
|
await super.onOpen(context);
|
|
1932
1970
|
try {
|
|
1933
|
-
(0,
|
|
1971
|
+
(0, import_log7.log)("guest acquire lock", void 0, {
|
|
1934
1972
|
F: __dxlog_file8,
|
|
1935
1973
|
L: 84,
|
|
1936
1974
|
S: this,
|
|
1937
1975
|
C: (f, a) => f(...a)
|
|
1938
1976
|
});
|
|
1939
1977
|
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
1940
|
-
(0,
|
|
1978
|
+
(0, import_log7.log)("guest lock acquired", void 0, {
|
|
1941
1979
|
F: __dxlog_file8,
|
|
1942
1980
|
L: 86,
|
|
1943
1981
|
S: this,
|
|
@@ -1946,7 +1984,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1946
1984
|
await (0, import_context6.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
|
|
1947
1985
|
role: import_invitations3.Options.Role.GUEST
|
|
1948
1986
|
}));
|
|
1949
|
-
(0,
|
|
1987
|
+
(0, import_log7.log)("options sent", void 0, {
|
|
1950
1988
|
F: __dxlog_file8,
|
|
1951
1989
|
L: 88,
|
|
1952
1990
|
S: this,
|
|
@@ -1955,7 +1993,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1955
1993
|
await (0, import_context6.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1956
1994
|
timeout: OPTIONS_TIMEOUT
|
|
1957
1995
|
}));
|
|
1958
|
-
(0,
|
|
1996
|
+
(0, import_log7.log)("options received", void 0, {
|
|
1959
1997
|
F: __dxlog_file8,
|
|
1960
1998
|
L: 90,
|
|
1961
1999
|
S: this,
|
|
@@ -1989,7 +2027,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1989
2027
|
if (this._invitationFlowLock != null) {
|
|
1990
2028
|
this._invitationFlowLock.release();
|
|
1991
2029
|
this._invitationFlowLock = null;
|
|
1992
|
-
(0,
|
|
2030
|
+
(0, import_log7.log)("invitation flow lock released", void 0, {
|
|
1993
2031
|
F: __dxlog_file8,
|
|
1994
2032
|
L: 123,
|
|
1995
2033
|
S: this,
|
|
@@ -2014,12 +2052,12 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2014
2052
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
2015
2053
|
this._callbacks = _callbacks;
|
|
2016
2054
|
this._ctx = new import_context8.Context();
|
|
2017
|
-
this._remoteOptionsTrigger = new
|
|
2055
|
+
this._remoteOptionsTrigger = new import_async11.Trigger();
|
|
2018
2056
|
this._challenge = void 0;
|
|
2019
2057
|
this.guestProfile = void 0;
|
|
2020
2058
|
this.authenticationPassed = false;
|
|
2021
2059
|
this.authenticationRetry = 0;
|
|
2022
|
-
this.completedTrigger = new
|
|
2060
|
+
this.completedTrigger = new import_async11.Trigger();
|
|
2023
2061
|
this._invitationFlowLock = null;
|
|
2024
2062
|
}
|
|
2025
2063
|
hasFlowLock() {
|
|
@@ -2046,7 +2084,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2046
2084
|
introduce: async (request) => {
|
|
2047
2085
|
const { profile, invitationId } = request;
|
|
2048
2086
|
const traceId = import_keys7.PublicKey.random().toHex();
|
|
2049
|
-
|
|
2087
|
+
import_log8.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols7.trace.begin({
|
|
2050
2088
|
id: traceId
|
|
2051
2089
|
}), {
|
|
2052
2090
|
F: __dxlog_file9,
|
|
@@ -2057,7 +2095,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2057
2095
|
const invitation = this._requireActiveInvitation();
|
|
2058
2096
|
this._assertInvitationState(import_services8.Invitation.State.CONNECTED);
|
|
2059
2097
|
if (invitationId !== invitation?.invitationId) {
|
|
2060
|
-
|
|
2098
|
+
import_log8.log.warn("incorrect invitationId", {
|
|
2061
2099
|
expected: invitation.invitationId,
|
|
2062
2100
|
actual: invitationId
|
|
2063
2101
|
}, {
|
|
@@ -2067,12 +2105,12 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2067
2105
|
C: (f, a) => f(...a)
|
|
2068
2106
|
});
|
|
2069
2107
|
this._callbacks.onError(new Error("Incorrect invitationId."));
|
|
2070
|
-
(0,
|
|
2108
|
+
(0, import_async11.scheduleTask)(this._ctx, () => this.close());
|
|
2071
2109
|
return {
|
|
2072
2110
|
authMethod: import_services8.Invitation.AuthMethod.NONE
|
|
2073
2111
|
};
|
|
2074
2112
|
}
|
|
2075
|
-
(0,
|
|
2113
|
+
(0, import_log8.log)("guest introduced themselves", {
|
|
2076
2114
|
guestProfile: profile
|
|
2077
2115
|
}, {
|
|
2078
2116
|
F: __dxlog_file9,
|
|
@@ -2083,7 +2121,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2083
2121
|
this.guestProfile = profile;
|
|
2084
2122
|
this._callbacks.onStateUpdate(import_services8.Invitation.State.READY_FOR_AUTHENTICATION);
|
|
2085
2123
|
this._challenge = invitation.authMethod === import_services8.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto2.randomBytes)(32) : void 0;
|
|
2086
|
-
|
|
2124
|
+
import_log8.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols7.trace.end({
|
|
2087
2125
|
id: traceId
|
|
2088
2126
|
}), {
|
|
2089
2127
|
F: __dxlog_file9,
|
|
@@ -2098,7 +2136,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2098
2136
|
},
|
|
2099
2137
|
authenticate: async ({ authCode: code, signedChallenge }) => {
|
|
2100
2138
|
const traceId = import_keys7.PublicKey.random().toHex();
|
|
2101
|
-
|
|
2139
|
+
import_log8.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols7.trace.begin({
|
|
2102
2140
|
id: traceId
|
|
2103
2141
|
}), {
|
|
2104
2142
|
F: __dxlog_file9,
|
|
@@ -2107,7 +2145,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2107
2145
|
C: (f, a) => f(...a)
|
|
2108
2146
|
});
|
|
2109
2147
|
const invitation = this._requireActiveInvitation();
|
|
2110
|
-
(0,
|
|
2148
|
+
(0, import_log8.log)("received authentication request", {
|
|
2111
2149
|
authCode: code
|
|
2112
2150
|
}, {
|
|
2113
2151
|
F: __dxlog_file9,
|
|
@@ -2123,7 +2161,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2123
2161
|
this._callbacks.onStateUpdate(import_services8.Invitation.State.AUTHENTICATING);
|
|
2124
2162
|
switch (invitation.authMethod) {
|
|
2125
2163
|
case import_services8.Invitation.AuthMethod.NONE: {
|
|
2126
|
-
(0,
|
|
2164
|
+
(0, import_log8.log)("authentication not required", void 0, {
|
|
2127
2165
|
F: __dxlog_file9,
|
|
2128
2166
|
L: 152,
|
|
2129
2167
|
S: this,
|
|
@@ -2159,7 +2197,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2159
2197
|
break;
|
|
2160
2198
|
}
|
|
2161
2199
|
default: {
|
|
2162
|
-
|
|
2200
|
+
import_log8.log.error("invalid authentication method", {
|
|
2163
2201
|
authMethod: invitation.authMethod
|
|
2164
2202
|
}, {
|
|
2165
2203
|
F: __dxlog_file9,
|
|
@@ -2176,12 +2214,12 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2176
2214
|
import_invitations4.AuthenticationResponse.Status.INVALID_OTP
|
|
2177
2215
|
].includes(status)) {
|
|
2178
2216
|
this._callbacks.onError(new Error(`Authentication failed, with status=${status}`));
|
|
2179
|
-
(0,
|
|
2217
|
+
(0, import_async11.scheduleTask)(this._ctx, () => this.close());
|
|
2180
2218
|
return {
|
|
2181
2219
|
status
|
|
2182
2220
|
};
|
|
2183
2221
|
}
|
|
2184
|
-
|
|
2222
|
+
import_log8.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols7.trace.end({
|
|
2185
2223
|
id: traceId,
|
|
2186
2224
|
data: {
|
|
2187
2225
|
status
|
|
@@ -2198,7 +2236,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2198
2236
|
},
|
|
2199
2237
|
admit: async (request) => {
|
|
2200
2238
|
const traceId = import_keys7.PublicKey.random().toHex();
|
|
2201
|
-
|
|
2239
|
+
import_log8.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols7.trace.begin({
|
|
2202
2240
|
id: traceId
|
|
2203
2241
|
}), {
|
|
2204
2242
|
F: __dxlog_file9,
|
|
@@ -2215,7 +2253,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2215
2253
|
}
|
|
2216
2254
|
}
|
|
2217
2255
|
const response = await this._callbacks.admit(request);
|
|
2218
|
-
|
|
2256
|
+
import_log8.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols7.trace.end({
|
|
2219
2257
|
id: traceId
|
|
2220
2258
|
}), {
|
|
2221
2259
|
F: __dxlog_file9,
|
|
@@ -2235,14 +2273,14 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2235
2273
|
async onOpen(context) {
|
|
2236
2274
|
await super.onOpen(context);
|
|
2237
2275
|
try {
|
|
2238
|
-
(0,
|
|
2276
|
+
(0, import_log8.log)("host acquire lock", void 0, {
|
|
2239
2277
|
F: __dxlog_file9,
|
|
2240
2278
|
L: 237,
|
|
2241
2279
|
S: this,
|
|
2242
2280
|
C: (f, a) => f(...a)
|
|
2243
2281
|
});
|
|
2244
2282
|
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
2245
|
-
(0,
|
|
2283
|
+
(0, import_log8.log)("host lock acquired", void 0, {
|
|
2246
2284
|
F: __dxlog_file9,
|
|
2247
2285
|
L: 239,
|
|
2248
2286
|
S: this,
|
|
@@ -2253,7 +2291,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2253
2291
|
await this.rpc.InvitationHostService.options({
|
|
2254
2292
|
role: import_invitations4.Options.Role.HOST
|
|
2255
2293
|
});
|
|
2256
|
-
(0,
|
|
2294
|
+
(0, import_log8.log)("options sent", void 0, {
|
|
2257
2295
|
F: __dxlog_file9,
|
|
2258
2296
|
L: 243,
|
|
2259
2297
|
S: this,
|
|
@@ -2262,7 +2300,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2262
2300
|
await (0, import_context8.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
2263
2301
|
timeout: OPTIONS_TIMEOUT2
|
|
2264
2302
|
}));
|
|
2265
|
-
(0,
|
|
2303
|
+
(0, import_log8.log)("options received", void 0, {
|
|
2266
2304
|
F: __dxlog_file9,
|
|
2267
2305
|
L: 245,
|
|
2268
2306
|
S: this,
|
|
@@ -2290,7 +2328,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2290
2328
|
_requireActiveInvitation() {
|
|
2291
2329
|
const invitation = this._callbacks.activeInvitation;
|
|
2292
2330
|
if (invitation == null) {
|
|
2293
|
-
(0,
|
|
2331
|
+
(0, import_async11.scheduleTask)(this._ctx, () => this.close());
|
|
2294
2332
|
throw new Error("Active invitation not found");
|
|
2295
2333
|
}
|
|
2296
2334
|
return invitation;
|
|
@@ -2301,7 +2339,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2301
2339
|
stateOrMany
|
|
2302
2340
|
];
|
|
2303
2341
|
if (!validStates.includes(invitation.state)) {
|
|
2304
|
-
(0,
|
|
2342
|
+
(0, import_async11.scheduleTask)(this._ctx, () => this.close());
|
|
2305
2343
|
throw new import_invariant8.InvariantViolation(`Expected ${stateToString(invitation.state)} to be one of [${validStates.map(stateToString).join(", ")}]`);
|
|
2306
2344
|
}
|
|
2307
2345
|
}
|
|
@@ -2316,7 +2354,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2316
2354
|
if (this._invitationFlowLock != null) {
|
|
2317
2355
|
this._invitationFlowLock?.release();
|
|
2318
2356
|
this._invitationFlowLock = null;
|
|
2319
|
-
(0,
|
|
2357
|
+
(0, import_log8.log)("invitation flow lock released", void 0, {
|
|
2320
2358
|
F: __dxlog_file9,
|
|
2321
2359
|
L: 300,
|
|
2322
2360
|
S: this,
|
|
@@ -2330,7 +2368,7 @@ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
|
|
|
2330
2368
|
var InvitationTopology = class {
|
|
2331
2369
|
constructor(_role) {
|
|
2332
2370
|
this._role = _role;
|
|
2333
|
-
this._seenPeers = new
|
|
2371
|
+
this._seenPeers = new import_util6.ComplexSet(import_keys8.PublicKey.hash);
|
|
2334
2372
|
}
|
|
2335
2373
|
init(controller) {
|
|
2336
2374
|
(0, import_invariant9.invariant)(!this._controller, "Already initialized.", {
|
|
@@ -2363,9 +2401,9 @@ var InvitationTopology = class {
|
|
|
2363
2401
|
return;
|
|
2364
2402
|
}
|
|
2365
2403
|
const firstUnknownPeer = candidates.find((peerId) => !this._seenPeers.has(peerId));
|
|
2366
|
-
this._seenPeers = new
|
|
2404
|
+
this._seenPeers = new import_util6.ComplexSet(import_keys8.PublicKey.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
|
|
2367
2405
|
if (firstUnknownPeer != null) {
|
|
2368
|
-
(0,
|
|
2406
|
+
(0, import_log9.log)("invitation connect", {
|
|
2369
2407
|
ownPeerId,
|
|
2370
2408
|
remotePeerId: firstUnknownPeer
|
|
2371
2409
|
}, {
|
|
@@ -2445,10 +2483,10 @@ var InvitationsHandler = class {
|
|
|
2445
2483
|
guardedState.error(extension, new import_context5.ContextDisposedError());
|
|
2446
2484
|
}
|
|
2447
2485
|
});
|
|
2448
|
-
(0,
|
|
2486
|
+
(0, import_async9.scheduleTask)(connectionCtx, async () => {
|
|
2449
2487
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
2450
2488
|
try {
|
|
2451
|
-
|
|
2489
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.begin({
|
|
2452
2490
|
id: traceId
|
|
2453
2491
|
}), {
|
|
2454
2492
|
F: __dxlog_file11,
|
|
@@ -2456,7 +2494,7 @@ var InvitationsHandler = class {
|
|
|
2456
2494
|
S: this,
|
|
2457
2495
|
C: (f, a) => f(...a)
|
|
2458
2496
|
});
|
|
2459
|
-
(0,
|
|
2497
|
+
(0, import_log6.log)("connected", {
|
|
2460
2498
|
...protocol.toJSON()
|
|
2461
2499
|
}, {
|
|
2462
2500
|
F: __dxlog_file11,
|
|
@@ -2467,7 +2505,7 @@ var InvitationsHandler = class {
|
|
|
2467
2505
|
const deviceKey = await extension.completedTrigger.wait({
|
|
2468
2506
|
timeout: invitation.timeout
|
|
2469
2507
|
});
|
|
2470
|
-
(0,
|
|
2508
|
+
(0, import_log6.log)("admitted guest", {
|
|
2471
2509
|
guest: deviceKey,
|
|
2472
2510
|
...protocol.toJSON()
|
|
2473
2511
|
}, {
|
|
@@ -2477,7 +2515,7 @@ var InvitationsHandler = class {
|
|
|
2477
2515
|
C: (f, a) => f(...a)
|
|
2478
2516
|
});
|
|
2479
2517
|
guardedState.set(extension, import_services6.Invitation.State.SUCCESS);
|
|
2480
|
-
|
|
2518
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.end({
|
|
2481
2519
|
id: traceId
|
|
2482
2520
|
}), {
|
|
2483
2521
|
F: __dxlog_file11,
|
|
@@ -2490,9 +2528,9 @@ var InvitationsHandler = class {
|
|
|
2490
2528
|
await ctx.dispose();
|
|
2491
2529
|
}
|
|
2492
2530
|
} catch (err) {
|
|
2493
|
-
if (err instanceof
|
|
2531
|
+
if (err instanceof import_async9.TimeoutError) {
|
|
2494
2532
|
if (guardedState.set(extension, import_services6.Invitation.State.TIMEOUT)) {
|
|
2495
|
-
(0,
|
|
2533
|
+
(0, import_log6.log)("timeout", {
|
|
2496
2534
|
...protocol.toJSON()
|
|
2497
2535
|
}, {
|
|
2498
2536
|
F: __dxlog_file11,
|
|
@@ -2503,7 +2541,7 @@ var InvitationsHandler = class {
|
|
|
2503
2541
|
}
|
|
2504
2542
|
} else {
|
|
2505
2543
|
if (guardedState.error(extension, err)) {
|
|
2506
|
-
|
|
2544
|
+
import_log6.log.error("failed", err, {
|
|
2507
2545
|
F: __dxlog_file11,
|
|
2508
2546
|
L: 133,
|
|
2509
2547
|
S: this,
|
|
@@ -2511,7 +2549,7 @@ var InvitationsHandler = class {
|
|
|
2511
2549
|
});
|
|
2512
2550
|
}
|
|
2513
2551
|
}
|
|
2514
|
-
|
|
2552
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.error({
|
|
2515
2553
|
id: traceId,
|
|
2516
2554
|
error: err
|
|
2517
2555
|
}), {
|
|
@@ -2526,7 +2564,7 @@ var InvitationsHandler = class {
|
|
|
2526
2564
|
},
|
|
2527
2565
|
onError: (err) => {
|
|
2528
2566
|
if (err instanceof import_protocols5.InvalidInvitationExtensionRoleError) {
|
|
2529
|
-
(0,
|
|
2567
|
+
(0, import_log6.log)("invalid role", {
|
|
2530
2568
|
...err.context
|
|
2531
2569
|
}, {
|
|
2532
2570
|
F: __dxlog_file11,
|
|
@@ -2536,9 +2574,9 @@ var InvitationsHandler = class {
|
|
|
2536
2574
|
});
|
|
2537
2575
|
return;
|
|
2538
2576
|
}
|
|
2539
|
-
if (err instanceof
|
|
2577
|
+
if (err instanceof import_async9.TimeoutError) {
|
|
2540
2578
|
if (guardedState.set(extension, import_services6.Invitation.State.TIMEOUT)) {
|
|
2541
|
-
(0,
|
|
2579
|
+
(0, import_log6.log)("timeout", {
|
|
2542
2580
|
err
|
|
2543
2581
|
}, {
|
|
2544
2582
|
F: __dxlog_file11,
|
|
@@ -2549,7 +2587,7 @@ var InvitationsHandler = class {
|
|
|
2549
2587
|
}
|
|
2550
2588
|
} else {
|
|
2551
2589
|
if (guardedState.error(extension, err)) {
|
|
2552
|
-
|
|
2590
|
+
import_log6.log.error("failed", err, {
|
|
2553
2591
|
F: __dxlog_file11,
|
|
2554
2592
|
L: 153,
|
|
2555
2593
|
S: this,
|
|
@@ -2563,14 +2601,14 @@ var InvitationsHandler = class {
|
|
|
2563
2601
|
};
|
|
2564
2602
|
if (invitation.lifetime && invitation.created) {
|
|
2565
2603
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
2566
|
-
|
|
2604
|
+
import_log6.log.warn("invitation has already expired", void 0, {
|
|
2567
2605
|
F: __dxlog_file11,
|
|
2568
2606
|
L: 164,
|
|
2569
2607
|
S: this,
|
|
2570
2608
|
C: (f, a) => f(...a)
|
|
2571
2609
|
});
|
|
2572
2610
|
} else {
|
|
2573
|
-
(0,
|
|
2611
|
+
(0, import_async9.scheduleTask)(ctx, async () => {
|
|
2574
2612
|
await swarmConnection.close();
|
|
2575
2613
|
guardedState.set(null, import_services6.Invitation.State.EXPIRED);
|
|
2576
2614
|
await ctx.dispose();
|
|
@@ -2578,7 +2616,7 @@ var InvitationsHandler = class {
|
|
|
2578
2616
|
}
|
|
2579
2617
|
}
|
|
2580
2618
|
let swarmConnection;
|
|
2581
|
-
(0,
|
|
2619
|
+
(0, import_async9.scheduleTask)(ctx, async () => {
|
|
2582
2620
|
swarmConnection = await this._joinSwarm(ctx, invitation, import_invitations2.Options.Role.HOST, createExtension);
|
|
2583
2621
|
guardedState.set(null, import_services6.Invitation.State.CONNECTING);
|
|
2584
2622
|
});
|
|
@@ -2596,11 +2634,11 @@ var InvitationsHandler = class {
|
|
|
2596
2634
|
]
|
|
2597
2635
|
});
|
|
2598
2636
|
}
|
|
2599
|
-
const triedPeersIds = new
|
|
2637
|
+
const triedPeersIds = new import_util5.ComplexSet(import_keys6.PublicKey.hash);
|
|
2600
2638
|
const guardedState = this._createGuardedState(ctx, invitation, stream);
|
|
2601
2639
|
const shouldCancelInvitationFlow = (extension) => {
|
|
2602
2640
|
const isLockedByAnotherConnection = guardedState.mutex.isLocked() && !extension.hasFlowLock();
|
|
2603
|
-
(0,
|
|
2641
|
+
(0, import_log6.log)("should cancel invitation flow", {
|
|
2604
2642
|
isLockedByAnotherConnection,
|
|
2605
2643
|
invitationType: import_services6.Invitation.Type.DELEGATED,
|
|
2606
2644
|
triedPeers: triedPeersIds.size
|
|
@@ -2628,7 +2666,7 @@ var InvitationsHandler = class {
|
|
|
2628
2666
|
return;
|
|
2629
2667
|
}
|
|
2630
2668
|
connectionCtx.onDispose(async () => {
|
|
2631
|
-
(0,
|
|
2669
|
+
(0, import_log6.log)("extension disposed", {
|
|
2632
2670
|
admitted,
|
|
2633
2671
|
currentState: guardedState.current.state
|
|
2634
2672
|
}, {
|
|
@@ -2644,10 +2682,10 @@ var InvitationsHandler = class {
|
|
|
2644
2682
|
}
|
|
2645
2683
|
}
|
|
2646
2684
|
});
|
|
2647
|
-
(0,
|
|
2685
|
+
(0, import_async9.scheduleTask)(connectionCtx, async () => {
|
|
2648
2686
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
2649
2687
|
try {
|
|
2650
|
-
|
|
2688
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.begin({
|
|
2651
2689
|
id: traceId
|
|
2652
2690
|
}), {
|
|
2653
2691
|
F: __dxlog_file11,
|
|
@@ -2655,11 +2693,11 @@ var InvitationsHandler = class {
|
|
|
2655
2693
|
S: this,
|
|
2656
2694
|
C: (f, a) => f(...a)
|
|
2657
2695
|
});
|
|
2658
|
-
(0,
|
|
2696
|
+
(0, import_async9.scheduleTask)(connectionCtx, () => {
|
|
2659
2697
|
guardedState.set(extension, import_services6.Invitation.State.TIMEOUT);
|
|
2660
2698
|
extensionCtx.close();
|
|
2661
2699
|
}, timeout);
|
|
2662
|
-
(0,
|
|
2700
|
+
(0, import_log6.log)("connected", {
|
|
2663
2701
|
...protocol.toJSON()
|
|
2664
2702
|
}, {
|
|
2665
2703
|
F: __dxlog_file11,
|
|
@@ -2668,7 +2706,7 @@ var InvitationsHandler = class {
|
|
|
2668
2706
|
C: (f, a) => f(...a)
|
|
2669
2707
|
});
|
|
2670
2708
|
guardedState.set(extension, import_services6.Invitation.State.CONNECTED);
|
|
2671
|
-
(0,
|
|
2709
|
+
(0, import_log6.log)("introduce", {
|
|
2672
2710
|
...protocol.toJSON()
|
|
2673
2711
|
}, {
|
|
2674
2712
|
F: __dxlog_file11,
|
|
@@ -2680,7 +2718,7 @@ var InvitationsHandler = class {
|
|
|
2680
2718
|
invitationId: invitation.invitationId,
|
|
2681
2719
|
...protocol.createIntroduction()
|
|
2682
2720
|
});
|
|
2683
|
-
(0,
|
|
2721
|
+
(0, import_log6.log)("introduce response", {
|
|
2684
2722
|
...protocol.toJSON(),
|
|
2685
2723
|
response: introductionResponse
|
|
2686
2724
|
}, {
|
|
@@ -2702,7 +2740,7 @@ var InvitationsHandler = class {
|
|
|
2702
2740
|
break;
|
|
2703
2741
|
}
|
|
2704
2742
|
}
|
|
2705
|
-
(0,
|
|
2743
|
+
(0, import_log6.log)("request admission", {
|
|
2706
2744
|
...protocol.toJSON()
|
|
2707
2745
|
}, {
|
|
2708
2746
|
F: __dxlog_file11,
|
|
@@ -2714,7 +2752,7 @@ var InvitationsHandler = class {
|
|
|
2714
2752
|
const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
|
|
2715
2753
|
admitted = true;
|
|
2716
2754
|
const result = await protocol.accept(admissionResponse, admissionRequest);
|
|
2717
|
-
(0,
|
|
2755
|
+
(0, import_log6.log)("admitted by host", {
|
|
2718
2756
|
...protocol.toJSON()
|
|
2719
2757
|
}, {
|
|
2720
2758
|
F: __dxlog_file11,
|
|
@@ -2727,7 +2765,7 @@ var InvitationsHandler = class {
|
|
|
2727
2765
|
...result,
|
|
2728
2766
|
state: import_services6.Invitation.State.SUCCESS
|
|
2729
2767
|
});
|
|
2730
|
-
|
|
2768
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.end({
|
|
2731
2769
|
id: traceId
|
|
2732
2770
|
}), {
|
|
2733
2771
|
F: __dxlog_file11,
|
|
@@ -2736,8 +2774,8 @@ var InvitationsHandler = class {
|
|
|
2736
2774
|
C: (f, a) => f(...a)
|
|
2737
2775
|
});
|
|
2738
2776
|
} catch (err) {
|
|
2739
|
-
if (err instanceof
|
|
2740
|
-
(0,
|
|
2777
|
+
if (err instanceof import_async9.TimeoutError) {
|
|
2778
|
+
(0, import_log6.log)("timeout", {
|
|
2741
2779
|
...protocol.toJSON()
|
|
2742
2780
|
}, {
|
|
2743
2781
|
F: __dxlog_file11,
|
|
@@ -2747,7 +2785,7 @@ var InvitationsHandler = class {
|
|
|
2747
2785
|
});
|
|
2748
2786
|
guardedState.set(extension, import_services6.Invitation.State.TIMEOUT);
|
|
2749
2787
|
} else {
|
|
2750
|
-
(0,
|
|
2788
|
+
(0, import_log6.log)("auth failed", err, {
|
|
2751
2789
|
F: __dxlog_file11,
|
|
2752
2790
|
L: 314,
|
|
2753
2791
|
S: this,
|
|
@@ -2756,7 +2794,7 @@ var InvitationsHandler = class {
|
|
|
2756
2794
|
guardedState.error(extension, err);
|
|
2757
2795
|
}
|
|
2758
2796
|
extensionCtx.close(err);
|
|
2759
|
-
|
|
2797
|
+
import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.error({
|
|
2760
2798
|
id: traceId,
|
|
2761
2799
|
error: err
|
|
2762
2800
|
}), {
|
|
@@ -2772,8 +2810,8 @@ var InvitationsHandler = class {
|
|
|
2772
2810
|
if (err instanceof import_protocols5.InvalidInvitationExtensionRoleError) {
|
|
2773
2811
|
return;
|
|
2774
2812
|
}
|
|
2775
|
-
if (err instanceof
|
|
2776
|
-
(0,
|
|
2813
|
+
if (err instanceof import_async9.TimeoutError) {
|
|
2814
|
+
(0, import_log6.log)("timeout", {
|
|
2777
2815
|
...protocol.toJSON()
|
|
2778
2816
|
}, {
|
|
2779
2817
|
F: __dxlog_file11,
|
|
@@ -2783,7 +2821,7 @@ var InvitationsHandler = class {
|
|
|
2783
2821
|
});
|
|
2784
2822
|
guardedState.set(extension, import_services6.Invitation.State.TIMEOUT);
|
|
2785
2823
|
} else {
|
|
2786
|
-
(0,
|
|
2824
|
+
(0, import_log6.log)("auth failed", err, {
|
|
2787
2825
|
F: __dxlog_file11,
|
|
2788
2826
|
L: 330,
|
|
2789
2827
|
S: this,
|
|
@@ -2795,7 +2833,7 @@ var InvitationsHandler = class {
|
|
|
2795
2833
|
});
|
|
2796
2834
|
return extension;
|
|
2797
2835
|
};
|
|
2798
|
-
(0,
|
|
2836
|
+
(0, import_async9.scheduleTask)(ctx, async () => {
|
|
2799
2837
|
const error = protocol.checkInvitation(invitation);
|
|
2800
2838
|
if (error) {
|
|
2801
2839
|
stream.error(error);
|
|
@@ -2841,7 +2879,7 @@ var InvitationsHandler = class {
|
|
|
2841
2879
|
* invitation flow connections.
|
|
2842
2880
|
*/
|
|
2843
2881
|
_createGuardedState(ctx, invitation, stream) {
|
|
2844
|
-
const mutex = new
|
|
2882
|
+
const mutex = new import_async9.Mutex();
|
|
2845
2883
|
let lastActiveExtension = null;
|
|
2846
2884
|
let currentInvitation = {
|
|
2847
2885
|
...invitation
|
|
@@ -2896,7 +2934,7 @@ var InvitationsHandler = class {
|
|
|
2896
2934
|
};
|
|
2897
2935
|
}
|
|
2898
2936
|
_logStateUpdate(invitation, actor, newState) {
|
|
2899
|
-
(0,
|
|
2937
|
+
(0, import_log6.log)("invitation state update", {
|
|
2900
2938
|
actor: actor?.constructor.name,
|
|
2901
2939
|
newState: stateToString(newState),
|
|
2902
2940
|
oldState: stateToString(invitation.state)
|
|
@@ -2918,7 +2956,7 @@ var InvitationsHandler = class {
|
|
|
2918
2956
|
}
|
|
2919
2957
|
async _handleGuestOtpAuth(extension, setState, authenticated, options) {
|
|
2920
2958
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2921
|
-
(0,
|
|
2959
|
+
(0, import_log6.log)("guest waiting for authentication code...", void 0, {
|
|
2922
2960
|
F: __dxlog_file11,
|
|
2923
2961
|
L: 462,
|
|
2924
2962
|
S: this,
|
|
@@ -2926,7 +2964,7 @@ var InvitationsHandler = class {
|
|
|
2926
2964
|
});
|
|
2927
2965
|
setState(import_services6.Invitation.State.READY_FOR_AUTHENTICATION);
|
|
2928
2966
|
const authCode = await authenticated.wait(options);
|
|
2929
|
-
(0,
|
|
2967
|
+
(0, import_log6.log)("sending authentication request", void 0, {
|
|
2930
2968
|
F: __dxlog_file11,
|
|
2931
2969
|
L: 466,
|
|
2932
2970
|
S: this,
|
|
@@ -2943,7 +2981,7 @@ var InvitationsHandler = class {
|
|
|
2943
2981
|
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2944
2982
|
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2945
2983
|
} else {
|
|
2946
|
-
(0,
|
|
2984
|
+
(0, import_log6.log)("retrying invalid code", {
|
|
2947
2985
|
attempt
|
|
2948
2986
|
}, {
|
|
2949
2987
|
F: __dxlog_file11,
|
|
@@ -2963,7 +3001,7 @@ var InvitationsHandler = class {
|
|
|
2963
3001
|
if (introductionResponse.challenge == null) {
|
|
2964
3002
|
throw new Error("challenge missing in the introduction");
|
|
2965
3003
|
}
|
|
2966
|
-
(0,
|
|
3004
|
+
(0, import_log6.log)("sending authentication request", void 0, {
|
|
2967
3005
|
F: __dxlog_file11,
|
|
2968
3006
|
L: 496,
|
|
2969
3007
|
S: this,
|
|
@@ -3145,7 +3183,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3145
3183
|
if (space.inner.spaceState.getMemberRole(identityKey) !== import_credentials10.SpaceMember.Role.REMOVED) {
|
|
3146
3184
|
throw new import_protocols8.AlreadyJoinedError();
|
|
3147
3185
|
}
|
|
3148
|
-
(0,
|
|
3186
|
+
(0, import_log10.log)("writing guest credentials", {
|
|
3149
3187
|
host: this._signingContext.deviceKey,
|
|
3150
3188
|
guest: deviceKey
|
|
3151
3189
|
}, {
|
|
@@ -3213,7 +3251,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3213
3251
|
]
|
|
3214
3252
|
});
|
|
3215
3253
|
}
|
|
3216
|
-
(0,
|
|
3254
|
+
(0, import_log10.log)("writing delegate space invitation", {
|
|
3217
3255
|
host: this._signingContext.deviceKey,
|
|
3218
3256
|
id: invitation.invitationId
|
|
3219
3257
|
}, {
|
|
@@ -3274,7 +3312,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3274
3312
|
""
|
|
3275
3313
|
]
|
|
3276
3314
|
});
|
|
3277
|
-
(0,
|
|
3315
|
+
(0, import_log10.log)("cancelling delegated space invitation", {
|
|
3278
3316
|
host: this._signingContext.deviceKey,
|
|
3279
3317
|
id: invitation.invitationId
|
|
3280
3318
|
}, {
|
|
@@ -3375,12 +3413,12 @@ var InvitationsManager = class {
|
|
|
3375
3413
|
this._metadataStore = _metadataStore;
|
|
3376
3414
|
this._createInvitations = /* @__PURE__ */ new Map();
|
|
3377
3415
|
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
3378
|
-
this.invitationCreated = new
|
|
3379
|
-
this.invitationAccepted = new
|
|
3380
|
-
this.removedCreated = new
|
|
3381
|
-
this.removedAccepted = new
|
|
3382
|
-
this.saved = new
|
|
3383
|
-
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();
|
|
3384
3422
|
this._persistentInvitationsLoaded = false;
|
|
3385
3423
|
}
|
|
3386
3424
|
async createInvitation(options) {
|
|
@@ -3409,7 +3447,7 @@ var InvitationsManager = class {
|
|
|
3409
3447
|
try {
|
|
3410
3448
|
await this._persistIfRequired(handler, stream, invitation);
|
|
3411
3449
|
} catch (err) {
|
|
3412
|
-
|
|
3450
|
+
import_log11.log.catch(err, void 0, {
|
|
3413
3451
|
F: __dxlog_file13,
|
|
3414
3452
|
L: 82,
|
|
3415
3453
|
S: this,
|
|
@@ -3451,7 +3489,7 @@ var InvitationsManager = class {
|
|
|
3451
3489
|
invitations: cInvitations.map((invitation) => invitation.get())
|
|
3452
3490
|
};
|
|
3453
3491
|
} catch (err) {
|
|
3454
|
-
|
|
3492
|
+
import_log11.log.catch(err, void 0, {
|
|
3455
3493
|
F: __dxlog_file13,
|
|
3456
3494
|
L: 110,
|
|
3457
3495
|
S: this,
|
|
@@ -3483,7 +3521,7 @@ var InvitationsManager = class {
|
|
|
3483
3521
|
return invitation;
|
|
3484
3522
|
}
|
|
3485
3523
|
async authenticate({ invitationId, authCode }) {
|
|
3486
|
-
(0,
|
|
3524
|
+
(0, import_log11.log)("authenticating...", void 0, {
|
|
3487
3525
|
F: __dxlog_file13,
|
|
3488
3526
|
L: 140,
|
|
3489
3527
|
S: this,
|
|
@@ -3500,7 +3538,7 @@ var InvitationsManager = class {
|
|
|
3500
3538
|
});
|
|
3501
3539
|
const observable = this._acceptInvitations.get(invitationId);
|
|
3502
3540
|
if (!observable) {
|
|
3503
|
-
|
|
3541
|
+
import_log11.log.warn("invalid invitation", {
|
|
3504
3542
|
invitationId
|
|
3505
3543
|
}, {
|
|
3506
3544
|
F: __dxlog_file13,
|
|
@@ -3513,7 +3551,7 @@ var InvitationsManager = class {
|
|
|
3513
3551
|
}
|
|
3514
3552
|
}
|
|
3515
3553
|
async cancelInvitation({ invitationId }) {
|
|
3516
|
-
(0,
|
|
3554
|
+
(0, import_log11.log)("cancelInvitation...", {
|
|
3517
3555
|
invitationId
|
|
3518
3556
|
}, {
|
|
3519
3557
|
F: __dxlog_file13,
|
|
@@ -3590,7 +3628,7 @@ var InvitationsManager = class {
|
|
|
3590
3628
|
};
|
|
3591
3629
|
}
|
|
3592
3630
|
_createObservableInvitation(handler, invitation) {
|
|
3593
|
-
const stream = new
|
|
3631
|
+
const stream = new import_async12.PushStream();
|
|
3594
3632
|
const ctx = new import_context9.Context({
|
|
3595
3633
|
onError: (err) => {
|
|
3596
3634
|
stream.error(err);
|
|
@@ -3598,7 +3636,7 @@ var InvitationsManager = class {
|
|
|
3598
3636
|
}
|
|
3599
3637
|
});
|
|
3600
3638
|
ctx.onDispose(() => {
|
|
3601
|
-
(0,
|
|
3639
|
+
(0, import_log11.log)("complete", {
|
|
3602
3640
|
...handler.toJSON()
|
|
3603
3641
|
}, {
|
|
3604
3642
|
F: __dxlog_file13,
|
|
@@ -3626,12 +3664,12 @@ var InvitationsManager = class {
|
|
|
3626
3664
|
};
|
|
3627
3665
|
}
|
|
3628
3666
|
_createObservableAcceptingInvitation(handler, initialState) {
|
|
3629
|
-
const otpEnteredTrigger = new
|
|
3630
|
-
const stream = new
|
|
3667
|
+
const otpEnteredTrigger = new import_async12.Trigger();
|
|
3668
|
+
const stream = new import_async12.PushStream();
|
|
3631
3669
|
const ctx = new import_context9.Context({
|
|
3632
3670
|
onError: (err) => {
|
|
3633
|
-
if (err instanceof
|
|
3634
|
-
(0,
|
|
3671
|
+
if (err instanceof import_async12.TimeoutError) {
|
|
3672
|
+
(0, import_log11.log)("timeout", {
|
|
3635
3673
|
...handler.toJSON()
|
|
3636
3674
|
}, {
|
|
3637
3675
|
F: __dxlog_file13,
|
|
@@ -3644,7 +3682,7 @@ var InvitationsManager = class {
|
|
|
3644
3682
|
state: import_services11.Invitation.State.TIMEOUT
|
|
3645
3683
|
});
|
|
3646
3684
|
} else {
|
|
3647
|
-
|
|
3685
|
+
import_log11.log.warn("auth failed", err, {
|
|
3648
3686
|
F: __dxlog_file13,
|
|
3649
3687
|
L: 264,
|
|
3650
3688
|
S: this,
|
|
@@ -3659,7 +3697,7 @@ var InvitationsManager = class {
|
|
|
3659
3697
|
}
|
|
3660
3698
|
});
|
|
3661
3699
|
ctx.onDispose(() => {
|
|
3662
|
-
(0,
|
|
3700
|
+
(0, import_log11.log)("complete", {
|
|
3663
3701
|
...handler.toJSON()
|
|
3664
3702
|
}, {
|
|
3665
3703
|
F: __dxlog_file13,
|
|
@@ -3706,7 +3744,7 @@ var InvitationsManager = class {
|
|
|
3706
3744
|
try {
|
|
3707
3745
|
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
3708
3746
|
} catch (err) {
|
|
3709
|
-
|
|
3747
|
+
import_log11.log.catch(err, void 0, {
|
|
3710
3748
|
F: __dxlog_file13,
|
|
3711
3749
|
L: 307,
|
|
3712
3750
|
S: this,
|
|
@@ -3720,12 +3758,18 @@ var InvitationsManager = class {
|
|
|
3720
3758
|
}, callback);
|
|
3721
3759
|
}
|
|
3722
3760
|
};
|
|
3723
|
-
var AutomergeSpaceState = class {
|
|
3761
|
+
var AutomergeSpaceState = class extends import_context11.Resource {
|
|
3724
3762
|
constructor(_onNewRoot) {
|
|
3763
|
+
super();
|
|
3725
3764
|
this._onNewRoot = _onNewRoot;
|
|
3726
3765
|
this.rootUrl = void 0;
|
|
3727
3766
|
this.lastEpoch = void 0;
|
|
3728
|
-
this.onNewEpoch = new
|
|
3767
|
+
this.onNewEpoch = new import_async14.Event();
|
|
3768
|
+
this._isProcessingRootDocs = false;
|
|
3769
|
+
}
|
|
3770
|
+
async _open(ctx) {
|
|
3771
|
+
}
|
|
3772
|
+
async _close(ctx) {
|
|
3729
3773
|
this._isProcessingRootDocs = false;
|
|
3730
3774
|
}
|
|
3731
3775
|
async processCredential(credential) {
|
|
@@ -3754,18 +3798,152 @@ var AutomergeSpaceState = class {
|
|
|
3754
3798
|
await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
|
|
3755
3799
|
}
|
|
3756
3800
|
};
|
|
3757
|
-
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/
|
|
3801
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts";
|
|
3802
|
+
var runEpochMigration = async (ctx, context) => {
|
|
3803
|
+
switch (context.migration) {
|
|
3804
|
+
case import_services13.CreateEpochRequest.Migration.INIT_AUTOMERGE: {
|
|
3805
|
+
const document = context.repo.create();
|
|
3806
|
+
await context.repo.flush();
|
|
3807
|
+
return {
|
|
3808
|
+
newRoot: document.url
|
|
3809
|
+
};
|
|
3810
|
+
}
|
|
3811
|
+
case import_services13.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY: {
|
|
3812
|
+
if (!context.currentRoot) {
|
|
3813
|
+
throw new Error("Space does not have an automerge root");
|
|
3814
|
+
}
|
|
3815
|
+
const rootHandle = context.repo.find(context.currentRoot);
|
|
3816
|
+
await (0, import_context12.cancelWithContext)(ctx, (0, import_async15.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3817
|
+
const newRoot = context.repo.create(rootHandle.docSync());
|
|
3818
|
+
await context.repo.flush();
|
|
3819
|
+
return {
|
|
3820
|
+
newRoot: newRoot.url
|
|
3821
|
+
};
|
|
3822
|
+
}
|
|
3823
|
+
case import_services13.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT: {
|
|
3824
|
+
import_log13.log.info("Fragmenting", void 0, {
|
|
3825
|
+
F: __dxlog_file14,
|
|
3826
|
+
L: 63,
|
|
3827
|
+
S: void 0,
|
|
3828
|
+
C: (f, a) => f(...a)
|
|
3829
|
+
});
|
|
3830
|
+
const currentRootUrl = context.currentRoot;
|
|
3831
|
+
const rootHandle = context.repo.find(currentRootUrl);
|
|
3832
|
+
await (0, import_context12.cancelWithContext)(ctx, (0, import_async15.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3833
|
+
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3834
|
+
const properties = (0, import_echo_db.findInlineObjectOfType)(rootHandle.docSync(), import_echo_schema.TYPE_PROPERTIES);
|
|
3835
|
+
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3836
|
+
(0, import_invariant13.invariant)(properties, "Properties not found", {
|
|
3837
|
+
F: __dxlog_file14,
|
|
3838
|
+
L: 73,
|
|
3839
|
+
S: void 0,
|
|
3840
|
+
A: [
|
|
3841
|
+
"properties",
|
|
3842
|
+
"'Properties not found'"
|
|
3843
|
+
]
|
|
3844
|
+
});
|
|
3845
|
+
const newSpaceDoc = {
|
|
3846
|
+
...rootHandle.docSync(),
|
|
3847
|
+
objects: Object.fromEntries([
|
|
3848
|
+
properties
|
|
3849
|
+
])
|
|
3850
|
+
};
|
|
3851
|
+
const newRoot = context.repo.create(newSpaceDoc);
|
|
3852
|
+
(0, import_invariant13.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3853
|
+
F: __dxlog_file14,
|
|
3854
|
+
L: 78,
|
|
3855
|
+
S: void 0,
|
|
3856
|
+
A: [
|
|
3857
|
+
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3858
|
+
""
|
|
3859
|
+
]
|
|
3860
|
+
});
|
|
3861
|
+
const docLoader = new import_echo_pipeline3.AutomergeDocumentLoaderImpl(context.spaceId, context.repo, context.spaceKey);
|
|
3862
|
+
await docLoader.loadSpaceRootDocHandle(ctx, {
|
|
3863
|
+
rootUrl: newRoot.url
|
|
3864
|
+
});
|
|
3865
|
+
otherObjects.forEach(([key, value]) => {
|
|
3866
|
+
const handle = docLoader.createDocumentForObject(key);
|
|
3867
|
+
handle.change((doc) => {
|
|
3868
|
+
(0, import_util8.assignDeep)(doc, [
|
|
3869
|
+
"objects",
|
|
3870
|
+
key
|
|
3871
|
+
], value);
|
|
3872
|
+
});
|
|
3873
|
+
});
|
|
3874
|
+
await context.repo.flush();
|
|
3875
|
+
return {
|
|
3876
|
+
newRoot: newRoot.url
|
|
3877
|
+
};
|
|
3878
|
+
}
|
|
3879
|
+
case import_services13.CreateEpochRequest.Migration.MIGRATE_REFERENCES_TO_DXN: {
|
|
3880
|
+
const currentRootUrl = context.currentRoot;
|
|
3881
|
+
const rootHandle = context.repo.find(currentRootUrl);
|
|
3882
|
+
await (0, import_context12.cancelWithContext)(ctx, (0, import_async15.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3883
|
+
(0, import_invariant13.invariant)(rootHandle.docSync(), "Root doc not found", {
|
|
3884
|
+
F: __dxlog_file14,
|
|
3885
|
+
L: 100,
|
|
3886
|
+
S: void 0,
|
|
3887
|
+
A: [
|
|
3888
|
+
"rootHandle.docSync()",
|
|
3889
|
+
"'Root doc not found'"
|
|
3890
|
+
]
|
|
3891
|
+
});
|
|
3892
|
+
const newRootContent = await (0, import_echo_db.convertLegacySpaceRootDoc)(structuredClone(rootHandle.docSync()));
|
|
3893
|
+
for (const [id, url] of Object.entries(newRootContent.links ?? {})) {
|
|
3894
|
+
const handle = context.repo.find(url);
|
|
3895
|
+
await (0, import_context12.cancelWithContext)(ctx, (0, import_async15.asyncTimeout)(handle.whenReady(), 1e4));
|
|
3896
|
+
(0, import_invariant13.invariant)(handle.docSync(), "Doc not found", {
|
|
3897
|
+
F: __dxlog_file14,
|
|
3898
|
+
L: 107,
|
|
3899
|
+
S: void 0,
|
|
3900
|
+
A: [
|
|
3901
|
+
"handle.docSync()",
|
|
3902
|
+
"'Doc not found'"
|
|
3903
|
+
]
|
|
3904
|
+
});
|
|
3905
|
+
const newDoc = await (0, import_echo_db.convertLegacyReferences)(structuredClone(handle.docSync()));
|
|
3906
|
+
const migratedDoc = (0, import_echo_db.migrateDocument)(handle.docSync(), newDoc);
|
|
3907
|
+
const newHandle = context.repo.import(import_automerge.next.save(migratedDoc));
|
|
3908
|
+
newRootContent.links[id] = newHandle.url;
|
|
3909
|
+
}
|
|
3910
|
+
const migratedRoot = (0, import_echo_db.migrateDocument)(rootHandle.docSync(), newRootContent);
|
|
3911
|
+
const newRoot = context.repo.import(import_automerge.next.save(migratedRoot));
|
|
3912
|
+
await context.repo.flush();
|
|
3913
|
+
return {
|
|
3914
|
+
newRoot: newRoot.url
|
|
3915
|
+
};
|
|
3916
|
+
}
|
|
3917
|
+
case import_services13.CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
|
|
3918
|
+
(0, import_invariant13.invariant)(context.newAutomergeRoot, void 0, {
|
|
3919
|
+
F: __dxlog_file14,
|
|
3920
|
+
L: 124,
|
|
3921
|
+
S: void 0,
|
|
3922
|
+
A: [
|
|
3923
|
+
"context.newAutomergeRoot",
|
|
3924
|
+
""
|
|
3925
|
+
]
|
|
3926
|
+
});
|
|
3927
|
+
await context.repo.flush();
|
|
3928
|
+
return {
|
|
3929
|
+
newRoot: context.newAutomergeRoot
|
|
3930
|
+
};
|
|
3931
|
+
}
|
|
3932
|
+
}
|
|
3933
|
+
return {};
|
|
3934
|
+
};
|
|
3935
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
3758
3936
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
3759
3937
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
3760
3938
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
3761
3939
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
3762
3940
|
var NotarizationPlugin = class {
|
|
3763
3941
|
constructor() {
|
|
3764
|
-
this._ctx = new
|
|
3765
|
-
this._extensionOpened = new
|
|
3942
|
+
this._ctx = new import_context13.Context();
|
|
3943
|
+
this._extensionOpened = new import_async16.Event();
|
|
3766
3944
|
this._extensions = /* @__PURE__ */ new Set();
|
|
3767
|
-
this._processedCredentials = new
|
|
3768
|
-
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);
|
|
3769
3947
|
}
|
|
3770
3948
|
get hasWriter() {
|
|
3771
3949
|
return !!this._writer;
|
|
@@ -3779,16 +3957,16 @@ var NotarizationPlugin = class {
|
|
|
3779
3957
|
* Request credentials to be notarized.
|
|
3780
3958
|
*/
|
|
3781
3959
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
3782
|
-
(0,
|
|
3960
|
+
(0, import_log14.log)("notarize", {
|
|
3783
3961
|
credentials
|
|
3784
3962
|
}, {
|
|
3785
|
-
F:
|
|
3963
|
+
F: __dxlog_file15,
|
|
3786
3964
|
L: 90,
|
|
3787
3965
|
S: this,
|
|
3788
3966
|
C: (f, a) => f(...a)
|
|
3789
3967
|
});
|
|
3790
|
-
(0,
|
|
3791
|
-
F:
|
|
3968
|
+
(0, import_invariant14.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
3969
|
+
F: __dxlog_file15,
|
|
3792
3970
|
L: 91,
|
|
3793
3971
|
S: this,
|
|
3794
3972
|
A: [
|
|
@@ -3796,13 +3974,13 @@ var NotarizationPlugin = class {
|
|
|
3796
3974
|
"'Credentials must have an id'"
|
|
3797
3975
|
]
|
|
3798
3976
|
});
|
|
3799
|
-
const errors = new
|
|
3977
|
+
const errors = new import_async16.Trigger();
|
|
3800
3978
|
const ctx = this._ctx.derive({
|
|
3801
3979
|
onError: (err) => {
|
|
3802
|
-
|
|
3980
|
+
import_log14.log.warn("Notarization error", {
|
|
3803
3981
|
err
|
|
3804
3982
|
}, {
|
|
3805
|
-
F:
|
|
3983
|
+
F: __dxlog_file15,
|
|
3806
3984
|
L: 99,
|
|
3807
3985
|
S: this,
|
|
3808
3986
|
C: (f, a) => f(...a)
|
|
@@ -3813,23 +3991,23 @@ var NotarizationPlugin = class {
|
|
|
3813
3991
|
});
|
|
3814
3992
|
opCtx?.onDispose(() => ctx.dispose());
|
|
3815
3993
|
if (timeout !== 0) {
|
|
3816
|
-
(0,
|
|
3817
|
-
|
|
3994
|
+
(0, import_async16.scheduleTask)(ctx, () => {
|
|
3995
|
+
import_log14.log.warn("Notarization timeout", {
|
|
3818
3996
|
timeout,
|
|
3819
3997
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3820
3998
|
}, {
|
|
3821
|
-
F:
|
|
3999
|
+
F: __dxlog_file15,
|
|
3822
4000
|
L: 111,
|
|
3823
4001
|
S: this,
|
|
3824
4002
|
C: (f, a) => f(...a)
|
|
3825
4003
|
});
|
|
3826
4004
|
void ctx.dispose();
|
|
3827
|
-
errors.throw(new
|
|
4005
|
+
errors.throw(new import_async16.TimeoutError(timeout, "Notarization timed out"));
|
|
3828
4006
|
}, timeout);
|
|
3829
4007
|
}
|
|
3830
4008
|
const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
|
|
3831
4009
|
const peersTried = /* @__PURE__ */ new Set();
|
|
3832
|
-
const notarizeTask = new
|
|
4010
|
+
const notarizeTask = new import_async16.DeferredTask(ctx, async () => {
|
|
3833
4011
|
try {
|
|
3834
4012
|
if (this._extensions.size === 0) {
|
|
3835
4013
|
return;
|
|
@@ -3838,24 +4016,24 @@ var NotarizationPlugin = class {
|
|
|
3838
4016
|
...this._extensions
|
|
3839
4017
|
].find((peer2) => !peersTried.has(peer2));
|
|
3840
4018
|
if (!peer) {
|
|
3841
|
-
|
|
4019
|
+
import_log14.log.info("Exhausted all peers to notarize with", {
|
|
3842
4020
|
retryIn: retryTimeout
|
|
3843
4021
|
}, {
|
|
3844
|
-
F:
|
|
4022
|
+
F: __dxlog_file15,
|
|
3845
4023
|
L: 136,
|
|
3846
4024
|
S: this,
|
|
3847
4025
|
C: (f, a) => f(...a)
|
|
3848
4026
|
});
|
|
3849
4027
|
peersTried.clear();
|
|
3850
|
-
(0,
|
|
4028
|
+
(0, import_async16.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
3851
4029
|
return;
|
|
3852
4030
|
}
|
|
3853
4031
|
peersTried.add(peer);
|
|
3854
|
-
(0,
|
|
4032
|
+
(0, import_log14.log)("try notarizing", {
|
|
3855
4033
|
peer: peer.localPeerId,
|
|
3856
4034
|
credentialId: credentials.map((credential) => credential.id)
|
|
3857
4035
|
}, {
|
|
3858
|
-
F:
|
|
4036
|
+
F: __dxlog_file15,
|
|
3859
4037
|
L: 143,
|
|
3860
4038
|
S: this,
|
|
3861
4039
|
C: (f, a) => f(...a)
|
|
@@ -3863,17 +4041,17 @@ var NotarizationPlugin = class {
|
|
|
3863
4041
|
await peer.rpc.NotarizationService.notarize({
|
|
3864
4042
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
3865
4043
|
});
|
|
3866
|
-
(0,
|
|
3867
|
-
F:
|
|
4044
|
+
(0, import_log14.log)("success", void 0, {
|
|
4045
|
+
F: __dxlog_file15,
|
|
3868
4046
|
L: 147,
|
|
3869
4047
|
S: this,
|
|
3870
4048
|
C: (f, a) => f(...a)
|
|
3871
4049
|
});
|
|
3872
|
-
await (0,
|
|
4050
|
+
await (0, import_async16.sleep)(successDelay);
|
|
3873
4051
|
} catch (err) {
|
|
3874
4052
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
3875
|
-
|
|
3876
|
-
F:
|
|
4053
|
+
import_log14.log.info("error notarizing (recoverable)", err, {
|
|
4054
|
+
F: __dxlog_file15,
|
|
3877
4055
|
L: 151,
|
|
3878
4056
|
S: this,
|
|
3879
4057
|
C: (f, a) => f(...a)
|
|
@@ -3886,12 +4064,12 @@ var NotarizationPlugin = class {
|
|
|
3886
4064
|
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
3887
4065
|
try {
|
|
3888
4066
|
await Promise.race([
|
|
3889
|
-
(0,
|
|
4067
|
+
(0, import_context13.rejectOnDispose)(ctx),
|
|
3890
4068
|
allNotarized,
|
|
3891
4069
|
errors.wait()
|
|
3892
4070
|
]);
|
|
3893
|
-
(0,
|
|
3894
|
-
F:
|
|
4071
|
+
(0, import_log14.log)("done", void 0, {
|
|
4072
|
+
F: __dxlog_file15,
|
|
3895
4073
|
L: 162,
|
|
3896
4074
|
S: this,
|
|
3897
4075
|
C: (f, a) => f(...a)
|
|
@@ -3912,8 +4090,8 @@ var NotarizationPlugin = class {
|
|
|
3912
4090
|
this._processCredentialsTriggers.delete(credential.id);
|
|
3913
4091
|
}
|
|
3914
4092
|
setWriter(writer) {
|
|
3915
|
-
(0,
|
|
3916
|
-
F:
|
|
4093
|
+
(0, import_invariant14.invariant)(!this._writer, "Writer already set.", {
|
|
4094
|
+
F: __dxlog_file15,
|
|
3917
4095
|
L: 181,
|
|
3918
4096
|
S: this,
|
|
3919
4097
|
A: [
|
|
@@ -3927,7 +4105,7 @@ var NotarizationPlugin = class {
|
|
|
3927
4105
|
if (this._processedCredentials.has(id)) {
|
|
3928
4106
|
return;
|
|
3929
4107
|
}
|
|
3930
|
-
await (0,
|
|
4108
|
+
await (0, import_util9.entry)(this._processCredentialsTriggers, id).orInsert(new import_async16.Trigger()).value.wait();
|
|
3931
4109
|
}
|
|
3932
4110
|
/**
|
|
3933
4111
|
* Requests from other peers to notarize credentials.
|
|
@@ -3937,8 +4115,8 @@ var NotarizationPlugin = class {
|
|
|
3937
4115
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
3938
4116
|
}
|
|
3939
4117
|
for (const credential of request.credentials ?? []) {
|
|
3940
|
-
(0,
|
|
3941
|
-
F:
|
|
4118
|
+
(0, import_invariant14.invariant)(credential.id, "Credential must have an id", {
|
|
4119
|
+
F: __dxlog_file15,
|
|
3942
4120
|
L: 200,
|
|
3943
4121
|
S: this,
|
|
3944
4122
|
A: [
|
|
@@ -3955,10 +4133,10 @@ var NotarizationPlugin = class {
|
|
|
3955
4133
|
createExtension() {
|
|
3956
4134
|
const extension = new NotarizationTeleportExtension({
|
|
3957
4135
|
onOpen: async () => {
|
|
3958
|
-
(0,
|
|
4136
|
+
(0, import_log14.log)("extension opened", {
|
|
3959
4137
|
peer: extension.localPeerId
|
|
3960
4138
|
}, {
|
|
3961
|
-
F:
|
|
4139
|
+
F: __dxlog_file15,
|
|
3962
4140
|
L: 211,
|
|
3963
4141
|
S: this,
|
|
3964
4142
|
C: (f, a) => f(...a)
|
|
@@ -3967,10 +4145,10 @@ var NotarizationPlugin = class {
|
|
|
3967
4145
|
this._extensionOpened.emit();
|
|
3968
4146
|
},
|
|
3969
4147
|
onClose: async () => {
|
|
3970
|
-
(0,
|
|
4148
|
+
(0, import_log14.log)("extension closed", {
|
|
3971
4149
|
peer: extension.localPeerId
|
|
3972
4150
|
}, {
|
|
3973
|
-
F:
|
|
4151
|
+
F: __dxlog_file15,
|
|
3974
4152
|
L: 216,
|
|
3975
4153
|
S: this,
|
|
3976
4154
|
C: (f, a) => f(...a)
|
|
@@ -4022,16 +4200,81 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
4022
4200
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4023
4201
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4024
4202
|
}
|
|
4025
|
-
|
|
4203
|
+
function _using_ctx() {
|
|
4204
|
+
var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
|
|
4205
|
+
var err = new Error();
|
|
4206
|
+
err.name = "SuppressedError";
|
|
4207
|
+
err.suppressed = suppressed;
|
|
4208
|
+
err.error = error;
|
|
4209
|
+
return err;
|
|
4210
|
+
}, empty = {}, stack = [];
|
|
4211
|
+
function using(isAwait, value) {
|
|
4212
|
+
if (value != null) {
|
|
4213
|
+
if (Object(value) !== value) {
|
|
4214
|
+
throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
|
4215
|
+
}
|
|
4216
|
+
if (isAwait) {
|
|
4217
|
+
var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
|
|
4218
|
+
}
|
|
4219
|
+
if (dispose == null) {
|
|
4220
|
+
dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
|
|
4221
|
+
}
|
|
4222
|
+
if (typeof dispose !== "function") {
|
|
4223
|
+
throw new TypeError(`Property [Symbol.dispose] is not a function.`);
|
|
4224
|
+
}
|
|
4225
|
+
stack.push({
|
|
4226
|
+
v: value,
|
|
4227
|
+
d: dispose,
|
|
4228
|
+
a: isAwait
|
|
4229
|
+
});
|
|
4230
|
+
} else if (isAwait) {
|
|
4231
|
+
stack.push({
|
|
4232
|
+
d: value,
|
|
4233
|
+
a: isAwait
|
|
4234
|
+
});
|
|
4235
|
+
}
|
|
4236
|
+
return value;
|
|
4237
|
+
}
|
|
4238
|
+
return {
|
|
4239
|
+
e: empty,
|
|
4240
|
+
u: using.bind(null, false),
|
|
4241
|
+
a: using.bind(null, true),
|
|
4242
|
+
d: function() {
|
|
4243
|
+
var error = this.e;
|
|
4244
|
+
function next() {
|
|
4245
|
+
while (resource = stack.pop()) {
|
|
4246
|
+
try {
|
|
4247
|
+
var resource, disposalResult = resource.d && resource.d.call(resource.v);
|
|
4248
|
+
if (resource.a) {
|
|
4249
|
+
return Promise.resolve(disposalResult).then(next, err);
|
|
4250
|
+
}
|
|
4251
|
+
} catch (e) {
|
|
4252
|
+
return err(e);
|
|
4253
|
+
}
|
|
4254
|
+
}
|
|
4255
|
+
if (error !== empty)
|
|
4256
|
+
throw error;
|
|
4257
|
+
}
|
|
4258
|
+
function err(e) {
|
|
4259
|
+
error = error !== empty ? new _disposeSuppressedError(error, e) : e;
|
|
4260
|
+
return next();
|
|
4261
|
+
}
|
|
4262
|
+
return next();
|
|
4263
|
+
}
|
|
4264
|
+
};
|
|
4265
|
+
}
|
|
4266
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
4026
4267
|
var DataSpace = class {
|
|
4027
4268
|
constructor(params) {
|
|
4028
4269
|
this._ctx = new import_context10.Context();
|
|
4029
4270
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
4030
4271
|
this._cache = void 0;
|
|
4031
4272
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
4273
|
+
this._epochProcessingMutex = new import_async13.Mutex();
|
|
4032
4274
|
this._state = import_services12.SpaceState.CLOSED;
|
|
4275
|
+
this._databaseRoot = null;
|
|
4033
4276
|
this.error = void 0;
|
|
4034
|
-
this.stateUpdate = new
|
|
4277
|
+
this.stateUpdate = new import_async13.Event();
|
|
4035
4278
|
this.metrics = {};
|
|
4036
4279
|
this._inner = params.inner;
|
|
4037
4280
|
this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
|
|
@@ -4044,17 +4287,17 @@ var DataSpace = class {
|
|
|
4044
4287
|
this._callbacks = params.callbacks ?? {};
|
|
4045
4288
|
this._echoHost = params.echoHost;
|
|
4046
4289
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
4047
|
-
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)),
|
|
4048
4291
|
update: this._inner.stateUpdate,
|
|
4049
4292
|
authTimeout: import_client_protocol4.AUTH_TIMEOUT
|
|
4050
4293
|
});
|
|
4051
4294
|
this._cache = params.cache;
|
|
4052
4295
|
this._state = params.initialState;
|
|
4053
|
-
(0,
|
|
4296
|
+
(0, import_log12.log)("new state", {
|
|
4054
4297
|
state: import_services12.SpaceState[this._state]
|
|
4055
4298
|
}, {
|
|
4056
|
-
F:
|
|
4057
|
-
L:
|
|
4299
|
+
F: __dxlog_file16,
|
|
4300
|
+
L: 146,
|
|
4058
4301
|
S: this,
|
|
4059
4302
|
C: (f, a) => f(...a)
|
|
4060
4303
|
});
|
|
@@ -4087,6 +4330,9 @@ var DataSpace = class {
|
|
|
4087
4330
|
get automergeSpaceState() {
|
|
4088
4331
|
return this._automergeSpaceState;
|
|
4089
4332
|
}
|
|
4333
|
+
get databaseRoot() {
|
|
4334
|
+
return this._databaseRoot;
|
|
4335
|
+
}
|
|
4090
4336
|
get _automergeInfo() {
|
|
4091
4337
|
return {
|
|
4092
4338
|
rootUrl: this._automergeSpaceState.rootUrl,
|
|
@@ -4103,14 +4349,15 @@ var DataSpace = class {
|
|
|
4103
4349
|
await this._gossip.open();
|
|
4104
4350
|
await this._notarizationPlugin.open();
|
|
4105
4351
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
4352
|
+
await this._automergeSpaceState.open();
|
|
4106
4353
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
4107
4354
|
await this._inner.open(new import_context10.Context());
|
|
4108
4355
|
this._state = import_services12.SpaceState.CONTROL_ONLY;
|
|
4109
|
-
(0,
|
|
4356
|
+
(0, import_log12.log)("new state", {
|
|
4110
4357
|
state: import_services12.SpaceState[this._state]
|
|
4111
4358
|
}, {
|
|
4112
|
-
F:
|
|
4113
|
-
L:
|
|
4359
|
+
F: __dxlog_file16,
|
|
4360
|
+
L: 217,
|
|
4114
4361
|
S: this,
|
|
4115
4362
|
C: (f, a) => f(...a)
|
|
4116
4363
|
});
|
|
@@ -4124,11 +4371,11 @@ var DataSpace = class {
|
|
|
4124
4371
|
async _close() {
|
|
4125
4372
|
await this._callbacks.beforeClose?.();
|
|
4126
4373
|
this._state = import_services12.SpaceState.CLOSED;
|
|
4127
|
-
(0,
|
|
4374
|
+
(0, import_log12.log)("new state", {
|
|
4128
4375
|
state: import_services12.SpaceState[this._state]
|
|
4129
4376
|
}, {
|
|
4130
|
-
F:
|
|
4131
|
-
L:
|
|
4377
|
+
F: __dxlog_file16,
|
|
4378
|
+
L: 231,
|
|
4132
4379
|
S: this,
|
|
4133
4380
|
C: (f, a) => f(...a)
|
|
4134
4381
|
});
|
|
@@ -4137,6 +4384,7 @@ var DataSpace = class {
|
|
|
4137
4384
|
await this.authVerifier.close();
|
|
4138
4385
|
await this._inner.close();
|
|
4139
4386
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
4387
|
+
await this._automergeSpaceState.close();
|
|
4140
4388
|
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
4141
4389
|
await this._notarizationPlugin.close();
|
|
4142
4390
|
await this._presence.close();
|
|
@@ -4152,32 +4400,32 @@ var DataSpace = class {
|
|
|
4152
4400
|
* Initialize the data pipeline in a separate task.
|
|
4153
4401
|
*/
|
|
4154
4402
|
initializeDataPipelineAsync() {
|
|
4155
|
-
(0,
|
|
4403
|
+
(0, import_async13.scheduleTask)(this._ctx, async () => {
|
|
4156
4404
|
try {
|
|
4157
4405
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
4158
4406
|
await this.initializeDataPipeline();
|
|
4159
4407
|
} catch (err) {
|
|
4160
4408
|
if (err instanceof import_protocols9.CancelledError || err instanceof import_context10.ContextDisposedError) {
|
|
4161
|
-
(0,
|
|
4162
|
-
F:
|
|
4163
|
-
L:
|
|
4409
|
+
(0, import_log12.log)("data pipeline initialization cancelled", err, {
|
|
4410
|
+
F: __dxlog_file16,
|
|
4411
|
+
L: 265,
|
|
4164
4412
|
S: this,
|
|
4165
4413
|
C: (f, a) => f(...a)
|
|
4166
4414
|
});
|
|
4167
4415
|
return;
|
|
4168
4416
|
}
|
|
4169
|
-
|
|
4170
|
-
F:
|
|
4171
|
-
L:
|
|
4417
|
+
import_log12.log.error("Error initializing data pipeline", err, {
|
|
4418
|
+
F: __dxlog_file16,
|
|
4419
|
+
L: 269,
|
|
4172
4420
|
S: this,
|
|
4173
4421
|
C: (f, a) => f(...a)
|
|
4174
4422
|
});
|
|
4175
4423
|
this._state = import_services12.SpaceState.ERROR;
|
|
4176
|
-
(0,
|
|
4424
|
+
(0, import_log12.log)("new state", {
|
|
4177
4425
|
state: import_services12.SpaceState[this._state]
|
|
4178
4426
|
}, {
|
|
4179
|
-
F:
|
|
4180
|
-
L:
|
|
4427
|
+
F: __dxlog_file16,
|
|
4428
|
+
L: 271,
|
|
4181
4429
|
S: this,
|
|
4182
4430
|
C: (f, a) => f(...a)
|
|
4183
4431
|
});
|
|
@@ -4193,31 +4441,28 @@ var DataSpace = class {
|
|
|
4193
4441
|
throw new import_protocols9.SystemError("Invalid operation");
|
|
4194
4442
|
}
|
|
4195
4443
|
this._state = import_services12.SpaceState.INITIALIZING;
|
|
4196
|
-
(0,
|
|
4444
|
+
(0, import_log12.log)("new state", {
|
|
4197
4445
|
state: import_services12.SpaceState[this._state]
|
|
4198
4446
|
}, {
|
|
4199
|
-
F:
|
|
4200
|
-
L:
|
|
4447
|
+
F: __dxlog_file16,
|
|
4448
|
+
L: 287,
|
|
4201
4449
|
S: this,
|
|
4202
4450
|
C: (f, a) => f(...a)
|
|
4203
4451
|
});
|
|
4204
4452
|
await this._initializeAndReadControlPipeline();
|
|
4205
|
-
await (0,
|
|
4453
|
+
await (0, import_async13.sleep)(1);
|
|
4454
|
+
const ready = this.stateUpdate.waitForCondition(() => this._state === import_services12.SpaceState.READY);
|
|
4206
4455
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
4207
|
-
await
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
L: 290,
|
|
4211
|
-
S: this,
|
|
4212
|
-
C: (f, a) => f(...a)
|
|
4213
|
-
});
|
|
4456
|
+
await ready;
|
|
4457
|
+
}
|
|
4458
|
+
async _enterReadyState() {
|
|
4214
4459
|
await this._callbacks.beforeReady?.();
|
|
4215
4460
|
this._state = import_services12.SpaceState.READY;
|
|
4216
|
-
(0,
|
|
4461
|
+
(0, import_log12.log)("new state", {
|
|
4217
4462
|
state: import_services12.SpaceState[this._state]
|
|
4218
4463
|
}, {
|
|
4219
|
-
F:
|
|
4220
|
-
L:
|
|
4464
|
+
F: __dxlog_file16,
|
|
4465
|
+
L: 306,
|
|
4221
4466
|
S: this,
|
|
4222
4467
|
C: (f, a) => f(...a)
|
|
4223
4468
|
});
|
|
@@ -4231,9 +4476,9 @@ var DataSpace = class {
|
|
|
4231
4476
|
});
|
|
4232
4477
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
4233
4478
|
await this._createWritableFeeds();
|
|
4234
|
-
(0,
|
|
4235
|
-
F:
|
|
4236
|
-
L:
|
|
4479
|
+
(0, import_log12.log)("writable feeds created", void 0, {
|
|
4480
|
+
F: __dxlog_file16,
|
|
4481
|
+
L: 322,
|
|
4237
4482
|
S: this,
|
|
4238
4483
|
C: (f, a) => f(...a)
|
|
4239
4484
|
});
|
|
@@ -4291,57 +4536,66 @@ var DataSpace = class {
|
|
|
4291
4536
|
}
|
|
4292
4537
|
}
|
|
4293
4538
|
_onNewAutomergeRoot(rootUrl) {
|
|
4294
|
-
(0,
|
|
4539
|
+
(0, import_log12.log)("loading automerge root doc for space", {
|
|
4295
4540
|
space: this.key,
|
|
4296
4541
|
rootUrl
|
|
4297
4542
|
}, {
|
|
4298
|
-
F:
|
|
4299
|
-
L:
|
|
4543
|
+
F: __dxlog_file16,
|
|
4544
|
+
L: 388,
|
|
4300
4545
|
S: this,
|
|
4301
4546
|
C: (f, a) => f(...a)
|
|
4302
4547
|
});
|
|
4303
|
-
this._echoHost.replicateDocument(rootUrl);
|
|
4304
4548
|
const handle = this._echoHost.automergeRepo.find(rootUrl);
|
|
4305
4549
|
queueMicrotask(async () => {
|
|
4306
4550
|
try {
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
return;
|
|
4312
|
-
}
|
|
4313
|
-
const doc = handle.docSync() ?? (0, import_invariant12.failedInvariant)();
|
|
4314
|
-
if (!doc.access?.spaceKey) {
|
|
4315
|
-
handle.change((doc2) => {
|
|
4316
|
-
doc2.access = {
|
|
4317
|
-
spaceKey: this.key.toHex()
|
|
4318
|
-
};
|
|
4319
|
-
});
|
|
4320
|
-
}
|
|
4321
|
-
if (!this._echoHost.roots.has(handle.documentId)) {
|
|
4322
|
-
await this._echoHost.openSpaceRoot(handle.url);
|
|
4323
|
-
} else {
|
|
4324
|
-
import_log11.log.warn("echo database root already exists", {
|
|
4325
|
-
space: this.key,
|
|
4326
|
-
rootUrl
|
|
4327
|
-
}, {
|
|
4328
|
-
F: __dxlog_file15,
|
|
4329
|
-
L: 403,
|
|
4330
|
-
S: this,
|
|
4331
|
-
C: (f, a) => f(...a)
|
|
4551
|
+
try {
|
|
4552
|
+
var _usingCtx = _using_ctx();
|
|
4553
|
+
await (0, import_debug3.warnAfterTimeout)(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
4554
|
+
await (0, import_context10.cancelWithContext)(this._ctx, handle.whenReady());
|
|
4332
4555
|
});
|
|
4556
|
+
if (this._ctx.disposed) {
|
|
4557
|
+
return;
|
|
4558
|
+
}
|
|
4559
|
+
const _guard = (
|
|
4560
|
+
// Ensure only one root is processed at a time.
|
|
4561
|
+
_usingCtx.u(await this._epochProcessingMutex.acquire())
|
|
4562
|
+
);
|
|
4563
|
+
const doc = handle.docSync() ?? (0, import_invariant12.failedInvariant)();
|
|
4564
|
+
if (!doc.access?.spaceKey) {
|
|
4565
|
+
handle.change((doc2) => {
|
|
4566
|
+
doc2.access = {
|
|
4567
|
+
spaceKey: this.key.toHex()
|
|
4568
|
+
};
|
|
4569
|
+
});
|
|
4570
|
+
}
|
|
4571
|
+
const root = await this._echoHost.openSpaceRoot(handle.url);
|
|
4572
|
+
this._databaseRoot = root;
|
|
4573
|
+
if (root.getVersion() !== import_echo_protocol.SpaceDocVersion.CURRENT) {
|
|
4574
|
+
if (this._state !== import_services12.SpaceState.REQUIRES_MIGRATION) {
|
|
4575
|
+
this._state = import_services12.SpaceState.REQUIRES_MIGRATION;
|
|
4576
|
+
this.stateUpdate.emit();
|
|
4577
|
+
}
|
|
4578
|
+
} else {
|
|
4579
|
+
if (this._state !== import_services12.SpaceState.READY) {
|
|
4580
|
+
await this._enterReadyState();
|
|
4581
|
+
}
|
|
4582
|
+
}
|
|
4583
|
+
} catch (_) {
|
|
4584
|
+
_usingCtx.e = _;
|
|
4585
|
+
} finally {
|
|
4586
|
+
_usingCtx.d();
|
|
4333
4587
|
}
|
|
4334
4588
|
} catch (err) {
|
|
4335
4589
|
if (err instanceof import_context10.ContextDisposedError) {
|
|
4336
4590
|
return;
|
|
4337
4591
|
}
|
|
4338
|
-
|
|
4592
|
+
import_log12.log.warn("error loading automerge root doc", {
|
|
4339
4593
|
space: this.key,
|
|
4340
4594
|
rootUrl,
|
|
4341
4595
|
err
|
|
4342
4596
|
}, {
|
|
4343
|
-
F:
|
|
4344
|
-
L:
|
|
4597
|
+
F: __dxlog_file16,
|
|
4598
|
+
L: 431,
|
|
4345
4599
|
S: this,
|
|
4346
4600
|
C: (f, a) => f(...a)
|
|
4347
4601
|
});
|
|
@@ -4364,148 +4618,34 @@ var DataSpace = class {
|
|
|
4364
4618
|
});
|
|
4365
4619
|
}
|
|
4366
4620
|
async createEpoch(options) {
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
case import_services12.CreateEpochRequest.Migration.NONE:
|
|
4371
|
-
{
|
|
4372
|
-
epoch = {
|
|
4373
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4374
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4375
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
|
|
4376
|
-
automergeRoot: this._automergeSpaceState.lastEpoch?.subject.assertion?.automergeRoot
|
|
4377
|
-
};
|
|
4378
|
-
}
|
|
4379
|
-
break;
|
|
4380
|
-
case import_services12.CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
4381
|
-
{
|
|
4382
|
-
const document = this._echoHost.automergeRepo.create();
|
|
4383
|
-
epoch = {
|
|
4384
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4385
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4386
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
|
|
4387
|
-
automergeRoot: document.url
|
|
4388
|
-
};
|
|
4389
|
-
}
|
|
4390
|
-
break;
|
|
4391
|
-
case import_services12.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
4392
|
-
{
|
|
4393
|
-
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
4394
|
-
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
4395
|
-
await (0, import_context10.cancelWithContext)(this._ctx, (0, import_async12.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
4396
|
-
const newRoot = this._echoHost.automergeRepo.create(rootHandle.docSync());
|
|
4397
|
-
await this._echoHost.automergeRepo.flush([
|
|
4398
|
-
newRoot.documentId
|
|
4399
|
-
]);
|
|
4400
|
-
(0, import_invariant12.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
4401
|
-
F: __dxlog_file15,
|
|
4402
|
-
L: 460,
|
|
4403
|
-
S: this,
|
|
4404
|
-
A: [
|
|
4405
|
-
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
4406
|
-
""
|
|
4407
|
-
]
|
|
4408
|
-
});
|
|
4409
|
-
epoch = {
|
|
4410
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4411
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4412
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
|
|
4413
|
-
automergeRoot: newRoot.url
|
|
4414
|
-
};
|
|
4415
|
-
}
|
|
4416
|
-
break;
|
|
4417
|
-
case import_services12.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
4418
|
-
{
|
|
4419
|
-
import_log11.log.info("Fragmenting", void 0, {
|
|
4420
|
-
F: __dxlog_file15,
|
|
4421
|
-
L: 472,
|
|
4422
|
-
S: this,
|
|
4423
|
-
C: (f, a) => f(...a)
|
|
4424
|
-
});
|
|
4425
|
-
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
4426
|
-
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
4427
|
-
await (0, import_context10.cancelWithContext)(this._ctx, (0, import_async12.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
4428
|
-
const objects = Object.entries(rootHandle.docSync().objects);
|
|
4429
|
-
const properties = findPropertiesObject(rootHandle.docSync());
|
|
4430
|
-
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
4431
|
-
(0, import_invariant12.invariant)(properties, "Properties not found", {
|
|
4432
|
-
F: __dxlog_file15,
|
|
4433
|
-
L: 482,
|
|
4434
|
-
S: this,
|
|
4435
|
-
A: [
|
|
4436
|
-
"properties",
|
|
4437
|
-
"'Properties not found'"
|
|
4438
|
-
]
|
|
4439
|
-
});
|
|
4440
|
-
const newSpaceDoc = {
|
|
4441
|
-
...rootHandle.docSync(),
|
|
4442
|
-
objects: Object.fromEntries([
|
|
4443
|
-
properties
|
|
4444
|
-
])
|
|
4445
|
-
};
|
|
4446
|
-
const newRoot = this._echoHost.automergeRepo.create(newSpaceDoc);
|
|
4447
|
-
(0, import_invariant12.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
4448
|
-
F: __dxlog_file15,
|
|
4449
|
-
L: 487,
|
|
4450
|
-
S: this,
|
|
4451
|
-
A: [
|
|
4452
|
-
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
4453
|
-
""
|
|
4454
|
-
]
|
|
4455
|
-
});
|
|
4456
|
-
const docLoader = new import_echo_pipeline2.AutomergeDocumentLoaderImpl(await (0, import_echo_pipeline2.createIdFromSpaceKey)(this.key), this._echoHost.automergeRepo, this.key);
|
|
4457
|
-
await docLoader.loadSpaceRootDocHandle(this._ctx, {
|
|
4458
|
-
rootUrl: newRoot.url
|
|
4459
|
-
});
|
|
4460
|
-
otherObjects.forEach(([key, value]) => {
|
|
4461
|
-
const handle = docLoader.createDocumentForObject(key);
|
|
4462
|
-
handle.change((doc) => {
|
|
4463
|
-
(0, import_util6.assignDeep)(doc, [
|
|
4464
|
-
"objects",
|
|
4465
|
-
key
|
|
4466
|
-
], value);
|
|
4467
|
-
});
|
|
4468
|
-
});
|
|
4469
|
-
epoch = {
|
|
4470
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4471
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4472
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
|
|
4473
|
-
automergeRoot: newRoot.url
|
|
4474
|
-
};
|
|
4475
|
-
}
|
|
4476
|
-
break;
|
|
4477
|
-
case import_services12.CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT:
|
|
4478
|
-
{
|
|
4479
|
-
(0, import_invariant12.invariant)(options.newAutomergeRoot, void 0, {
|
|
4480
|
-
F: __dxlog_file15,
|
|
4481
|
-
L: 517,
|
|
4482
|
-
S: this,
|
|
4483
|
-
A: [
|
|
4484
|
-
"options.newAutomergeRoot",
|
|
4485
|
-
""
|
|
4486
|
-
]
|
|
4487
|
-
});
|
|
4488
|
-
epoch = {
|
|
4489
|
-
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4490
|
-
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4491
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
|
|
4492
|
-
automergeRoot: options.newAutomergeRoot
|
|
4493
|
-
};
|
|
4494
|
-
}
|
|
4495
|
-
break;
|
|
4496
|
-
}
|
|
4497
|
-
if (!epoch) {
|
|
4498
|
-
return;
|
|
4621
|
+
const ctx = this._ctx.derive();
|
|
4622
|
+
if (!options?.migration) {
|
|
4623
|
+
return null;
|
|
4499
4624
|
}
|
|
4625
|
+
const { newRoot } = await runEpochMigration(ctx, {
|
|
4626
|
+
repo: this._echoHost.automergeRepo,
|
|
4627
|
+
spaceId: this.id,
|
|
4628
|
+
spaceKey: this.key,
|
|
4629
|
+
migration: options.migration,
|
|
4630
|
+
currentRoot: this._automergeSpaceState.rootUrl ?? null,
|
|
4631
|
+
newAutomergeRoot: options.newAutomergeRoot
|
|
4632
|
+
});
|
|
4633
|
+
const epoch = {
|
|
4634
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4635
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4636
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
|
|
4637
|
+
automergeRoot: newRoot ?? this._automergeSpaceState.rootUrl
|
|
4638
|
+
};
|
|
4639
|
+
const credential = await this._signingContext.credentialSigner.createCredential({
|
|
4640
|
+
subject: this.key,
|
|
4641
|
+
assertion: {
|
|
4642
|
+
"@type": "dxos.halo.credentials.Epoch",
|
|
4643
|
+
...epoch
|
|
4644
|
+
}
|
|
4645
|
+
});
|
|
4500
4646
|
const receipt = await this.inner.controlPipeline.writer.write({
|
|
4501
4647
|
credential: {
|
|
4502
|
-
credential
|
|
4503
|
-
subject: this.key,
|
|
4504
|
-
assertion: {
|
|
4505
|
-
"@type": "dxos.halo.credentials.Epoch",
|
|
4506
|
-
...epoch
|
|
4507
|
-
}
|
|
4508
|
-
})
|
|
4648
|
+
credential
|
|
4509
4649
|
}
|
|
4510
4650
|
});
|
|
4511
4651
|
await this.inner.controlPipeline.state.waitUntilTimeframe(new import_timeframe3.Timeframe([
|
|
@@ -4515,6 +4655,7 @@ var DataSpace = class {
|
|
|
4515
4655
|
]
|
|
4516
4656
|
]));
|
|
4517
4657
|
await this._echoHost.updateIndexes();
|
|
4658
|
+
return credential;
|
|
4518
4659
|
}
|
|
4519
4660
|
async activate() {
|
|
4520
4661
|
if (![
|
|
@@ -4536,11 +4677,11 @@ var DataSpace = class {
|
|
|
4536
4677
|
await this._close();
|
|
4537
4678
|
}
|
|
4538
4679
|
this._state = import_services12.SpaceState.INACTIVE;
|
|
4539
|
-
(0,
|
|
4680
|
+
(0, import_log12.log)("new state", {
|
|
4540
4681
|
state: import_services12.SpaceState[this._state]
|
|
4541
4682
|
}, {
|
|
4542
|
-
F:
|
|
4543
|
-
L:
|
|
4683
|
+
F: __dxlog_file16,
|
|
4684
|
+
L: 512,
|
|
4544
4685
|
S: this,
|
|
4545
4686
|
C: (f, a) => f(...a)
|
|
4546
4687
|
});
|
|
@@ -4567,10 +4708,10 @@ _ts_decorate4([
|
|
|
4567
4708
|
})
|
|
4568
4709
|
], DataSpace.prototype, "_automergeInfo", null);
|
|
4569
4710
|
_ts_decorate4([
|
|
4570
|
-
|
|
4711
|
+
import_async13.synchronized
|
|
4571
4712
|
], DataSpace.prototype, "open", null);
|
|
4572
4713
|
_ts_decorate4([
|
|
4573
|
-
|
|
4714
|
+
import_async13.synchronized
|
|
4574
4715
|
], DataSpace.prototype, "close", null);
|
|
4575
4716
|
_ts_decorate4([
|
|
4576
4717
|
import_tracing5.trace.span({
|
|
@@ -4586,27 +4727,15 @@ _ts_decorate4([
|
|
|
4586
4727
|
(0, import_debug3.timed)(1e4)
|
|
4587
4728
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
4588
4729
|
_ts_decorate4([
|
|
4589
|
-
|
|
4730
|
+
import_async13.synchronized
|
|
4590
4731
|
], DataSpace.prototype, "activate", null);
|
|
4591
4732
|
_ts_decorate4([
|
|
4592
|
-
|
|
4733
|
+
import_async13.synchronized
|
|
4593
4734
|
], DataSpace.prototype, "deactivate", null);
|
|
4594
4735
|
DataSpace = _ts_decorate4([
|
|
4595
|
-
(0,
|
|
4736
|
+
(0, import_async13.trackLeaks)("open", "close"),
|
|
4596
4737
|
import_tracing5.trace.resource()
|
|
4597
4738
|
], DataSpace);
|
|
4598
|
-
var findPropertiesObject = (spaceDoc) => {
|
|
4599
|
-
for (const id in spaceDoc.objects ?? {}) {
|
|
4600
|
-
const obj = spaceDoc.objects[id];
|
|
4601
|
-
if (obj.system.type?.itemId === import_echo_schema.TYPE_PROPERTIES) {
|
|
4602
|
-
return [
|
|
4603
|
-
id,
|
|
4604
|
-
obj
|
|
4605
|
-
];
|
|
4606
|
-
}
|
|
4607
|
-
}
|
|
4608
|
-
return void 0;
|
|
4609
|
-
};
|
|
4610
4739
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
4611
4740
|
const credentials = [
|
|
4612
4741
|
await (0, import_credentials17.createCredential)({
|
|
@@ -4681,7 +4810,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
4681
4810
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4682
4811
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4683
4812
|
}
|
|
4684
|
-
var
|
|
4813
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
4685
4814
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
4686
4815
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
4687
4816
|
var DEFAULT_SPACE_KEY = "__DEFAULT__";
|
|
@@ -4695,9 +4824,9 @@ var DataSpaceManager = class {
|
|
|
4695
4824
|
this._echoHost = _echoHost;
|
|
4696
4825
|
this._invitationsManager = _invitationsManager;
|
|
4697
4826
|
this._params = _params;
|
|
4698
|
-
this._ctx = new
|
|
4699
|
-
this.updated = new
|
|
4700
|
-
this._spaces = new
|
|
4827
|
+
this._ctx = new import_context14.Context();
|
|
4828
|
+
this.updated = new import_async17.Event();
|
|
4829
|
+
this._spaces = new import_util10.ComplexMap(import_keys12.PublicKey.hash);
|
|
4701
4830
|
this._isOpen = false;
|
|
4702
4831
|
this._instanceId = import_keys12.PublicKey.random().toHex();
|
|
4703
4832
|
import_tracing6.trace.diagnostic({
|
|
@@ -4708,10 +4837,10 @@ var DataSpaceManager = class {
|
|
|
4708
4837
|
const rootUrl = space.automergeSpaceState.rootUrl;
|
|
4709
4838
|
const rootHandle = rootUrl ? this._echoHost.automergeRepo.find(rootUrl) : void 0;
|
|
4710
4839
|
const rootDoc = rootHandle?.docSync();
|
|
4711
|
-
const properties = rootDoc &&
|
|
4840
|
+
const properties = rootDoc && (0, import_echo_db2.findInlineObjectOfType)(rootDoc, import_echo_schema2.TYPE_PROPERTIES);
|
|
4712
4841
|
return {
|
|
4713
4842
|
key: space.key.toHex(),
|
|
4714
|
-
state:
|
|
4843
|
+
state: import_services14.SpaceState[space.state],
|
|
4715
4844
|
name: properties?.[1].data.name ?? null,
|
|
4716
4845
|
inlineObjects: rootDoc ? Object.keys(rootDoc.objects ?? {}).length : null,
|
|
4717
4846
|
linkedObjects: rootDoc ? Object.keys(rootDoc.links ?? {}).length : null,
|
|
@@ -4728,46 +4857,46 @@ var DataSpaceManager = class {
|
|
|
4728
4857
|
return this._spaces;
|
|
4729
4858
|
}
|
|
4730
4859
|
async open() {
|
|
4731
|
-
(0,
|
|
4732
|
-
F:
|
|
4733
|
-
L:
|
|
4860
|
+
(0, import_log15.log)("open", void 0, {
|
|
4861
|
+
F: __dxlog_file17,
|
|
4862
|
+
L: 146,
|
|
4734
4863
|
S: this,
|
|
4735
4864
|
C: (f, a) => f(...a)
|
|
4736
4865
|
});
|
|
4737
|
-
|
|
4866
|
+
import_log15.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.begin({
|
|
4738
4867
|
id: this._instanceId
|
|
4739
4868
|
}), {
|
|
4740
|
-
F:
|
|
4741
|
-
L:
|
|
4869
|
+
F: __dxlog_file17,
|
|
4870
|
+
L: 147,
|
|
4742
4871
|
S: this,
|
|
4743
4872
|
C: (f, a) => f(...a)
|
|
4744
4873
|
});
|
|
4745
|
-
(0,
|
|
4874
|
+
(0, import_log15.log)("metadata loaded", {
|
|
4746
4875
|
spaces: this._metadataStore.spaces.length
|
|
4747
4876
|
}, {
|
|
4748
|
-
F:
|
|
4749
|
-
L:
|
|
4877
|
+
F: __dxlog_file17,
|
|
4878
|
+
L: 148,
|
|
4750
4879
|
S: this,
|
|
4751
4880
|
C: (f, a) => f(...a)
|
|
4752
4881
|
});
|
|
4753
|
-
await (0,
|
|
4882
|
+
await (0, import_util10.forEachAsync)(this._metadataStore.spaces, async (spaceMetadata) => {
|
|
4754
4883
|
try {
|
|
4755
|
-
(0,
|
|
4884
|
+
(0, import_log15.log)("load space", {
|
|
4756
4885
|
spaceMetadata
|
|
4757
4886
|
}, {
|
|
4758
|
-
F:
|
|
4759
|
-
L:
|
|
4887
|
+
F: __dxlog_file17,
|
|
4888
|
+
L: 152,
|
|
4760
4889
|
S: this,
|
|
4761
4890
|
C: (f, a) => f(...a)
|
|
4762
4891
|
});
|
|
4763
4892
|
await this._constructSpace(spaceMetadata);
|
|
4764
4893
|
} catch (err) {
|
|
4765
|
-
|
|
4894
|
+
import_log15.log.error("Error loading space", {
|
|
4766
4895
|
spaceMetadata,
|
|
4767
4896
|
err
|
|
4768
4897
|
}, {
|
|
4769
|
-
F:
|
|
4770
|
-
L:
|
|
4898
|
+
F: __dxlog_file17,
|
|
4899
|
+
L: 155,
|
|
4771
4900
|
S: this,
|
|
4772
4901
|
C: (f, a) => f(...a)
|
|
4773
4902
|
});
|
|
@@ -4775,19 +4904,19 @@ var DataSpaceManager = class {
|
|
|
4775
4904
|
});
|
|
4776
4905
|
this._isOpen = true;
|
|
4777
4906
|
this.updated.emit();
|
|
4778
|
-
|
|
4907
|
+
import_log15.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.end({
|
|
4779
4908
|
id: this._instanceId
|
|
4780
4909
|
}), {
|
|
4781
|
-
F:
|
|
4782
|
-
L:
|
|
4910
|
+
F: __dxlog_file17,
|
|
4911
|
+
L: 162,
|
|
4783
4912
|
S: this,
|
|
4784
4913
|
C: (f, a) => f(...a)
|
|
4785
4914
|
});
|
|
4786
4915
|
}
|
|
4787
4916
|
async close() {
|
|
4788
|
-
(0,
|
|
4789
|
-
F:
|
|
4790
|
-
L:
|
|
4917
|
+
(0, import_log15.log)("close", void 0, {
|
|
4918
|
+
F: __dxlog_file17,
|
|
4919
|
+
L: 167,
|
|
4791
4920
|
S: this,
|
|
4792
4921
|
C: (f, a) => f(...a)
|
|
4793
4922
|
});
|
|
@@ -4802,9 +4931,9 @@ var DataSpaceManager = class {
|
|
|
4802
4931
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
4803
4932
|
*/
|
|
4804
4933
|
async createSpace() {
|
|
4805
|
-
(0,
|
|
4806
|
-
F:
|
|
4807
|
-
L:
|
|
4934
|
+
(0, import_invariant15.invariant)(this._isOpen, "Not open.", {
|
|
4935
|
+
F: __dxlog_file17,
|
|
4936
|
+
L: 181,
|
|
4808
4937
|
S: this,
|
|
4809
4938
|
A: [
|
|
4810
4939
|
"this._isOpen",
|
|
@@ -4819,13 +4948,13 @@ var DataSpaceManager = class {
|
|
|
4819
4948
|
genesisFeedKey: controlFeedKey,
|
|
4820
4949
|
controlFeedKey,
|
|
4821
4950
|
dataFeedKey,
|
|
4822
|
-
state:
|
|
4951
|
+
state: import_services14.SpaceState.ACTIVE
|
|
4823
4952
|
};
|
|
4824
|
-
(0,
|
|
4953
|
+
(0, import_log15.log)("creating space...", {
|
|
4825
4954
|
spaceKey
|
|
4826
4955
|
}, {
|
|
4827
|
-
F:
|
|
4828
|
-
L:
|
|
4956
|
+
F: __dxlog_file17,
|
|
4957
|
+
L: 193,
|
|
4829
4958
|
S: this,
|
|
4830
4959
|
C: (f, a) => f(...a)
|
|
4831
4960
|
});
|
|
@@ -4835,9 +4964,9 @@ var DataSpaceManager = class {
|
|
|
4835
4964
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, root.url);
|
|
4836
4965
|
await this._metadataStore.addSpace(metadata);
|
|
4837
4966
|
const memberCredential = credentials[1];
|
|
4838
|
-
(0,
|
|
4839
|
-
F:
|
|
4840
|
-
L:
|
|
4967
|
+
(0, import_invariant15.invariant)((0, import_credentials15.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4968
|
+
F: __dxlog_file17,
|
|
4969
|
+
L: 203,
|
|
4841
4970
|
S: this,
|
|
4842
4971
|
A: [
|
|
4843
4972
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -4850,16 +4979,38 @@ var DataSpaceManager = class {
|
|
|
4850
4979
|
return space;
|
|
4851
4980
|
}
|
|
4852
4981
|
async isDefaultSpace(space) {
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4982
|
+
if (!space.databaseRoot) {
|
|
4983
|
+
return false;
|
|
4984
|
+
}
|
|
4985
|
+
switch (space.databaseRoot.getVersion()) {
|
|
4986
|
+
case import_echo_protocol2.SpaceDocVersion.CURRENT: {
|
|
4987
|
+
const [_, properties] = (0, import_echo_db2.findInlineObjectOfType)(space.databaseRoot.docSync(), import_echo_schema2.TYPE_PROPERTIES) ?? [];
|
|
4988
|
+
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
4989
|
+
}
|
|
4990
|
+
case import_echo_protocol2.SpaceDocVersion.LEGACY: {
|
|
4991
|
+
const convertedDoc = await (0, import_echo_db2.convertLegacyReferences)(space.databaseRoot.docSync());
|
|
4992
|
+
const [_, properties] = (0, import_echo_db2.findInlineObjectOfType)(convertedDoc, import_echo_protocol2.LEGACY_TYPE_PROPERTIES) ?? [];
|
|
4993
|
+
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
4994
|
+
}
|
|
4995
|
+
default:
|
|
4996
|
+
import_log15.log.warn("unknown space version", {
|
|
4997
|
+
version: space.databaseRoot.getVersion(),
|
|
4998
|
+
spaceId: space.id
|
|
4999
|
+
}, {
|
|
5000
|
+
F: __dxlog_file17,
|
|
5001
|
+
L: 228,
|
|
5002
|
+
S: this,
|
|
5003
|
+
C: (f, a) => f(...a)
|
|
5004
|
+
});
|
|
5005
|
+
return false;
|
|
5006
|
+
}
|
|
4856
5007
|
}
|
|
4857
5008
|
async createDefaultSpace() {
|
|
4858
5009
|
const space = await this.createSpace();
|
|
4859
5010
|
const document = await this._getSpaceRootDocument(space);
|
|
4860
5011
|
const properties = {
|
|
4861
5012
|
system: {
|
|
4862
|
-
type: (0,
|
|
5013
|
+
type: (0, import_echo_protocol2.encodeReference)((0, import_echo_schema2.getTypeReference)(import_client_protocol5.PropertiesType))
|
|
4863
5014
|
},
|
|
4864
5015
|
data: {
|
|
4865
5016
|
[DEFAULT_SPACE_KEY]: this._signingContext.identityKey.toHex()
|
|
@@ -4868,9 +5019,9 @@ var DataSpaceManager = class {
|
|
|
4868
5019
|
keys: []
|
|
4869
5020
|
}
|
|
4870
5021
|
};
|
|
4871
|
-
const propertiesId =
|
|
5022
|
+
const propertiesId = (0, import_echo_schema2.generateEchoId)();
|
|
4872
5023
|
document.change((doc) => {
|
|
4873
|
-
(0,
|
|
5024
|
+
(0, import_util10.assignDeep)(doc, [
|
|
4874
5025
|
"objects",
|
|
4875
5026
|
propertiesId
|
|
4876
5027
|
], properties);
|
|
@@ -4880,9 +5031,9 @@ var DataSpaceManager = class {
|
|
|
4880
5031
|
}
|
|
4881
5032
|
async _getSpaceRootDocument(space) {
|
|
4882
5033
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
4883
|
-
(0,
|
|
4884
|
-
F:
|
|
4885
|
-
L:
|
|
5034
|
+
(0, import_invariant15.invariant)(automergeIndex, void 0, {
|
|
5035
|
+
F: __dxlog_file17,
|
|
5036
|
+
L: 261,
|
|
4886
5037
|
S: this,
|
|
4887
5038
|
A: [
|
|
4888
5039
|
"automergeIndex",
|
|
@@ -4895,26 +5046,26 @@ var DataSpaceManager = class {
|
|
|
4895
5046
|
}
|
|
4896
5047
|
// TODO(burdon): Rename join space.
|
|
4897
5048
|
async acceptSpace(opts) {
|
|
4898
|
-
(0,
|
|
5049
|
+
(0, import_log15.log)("accept space", {
|
|
4899
5050
|
opts
|
|
4900
5051
|
}, {
|
|
4901
|
-
F:
|
|
4902
|
-
L:
|
|
5052
|
+
F: __dxlog_file17,
|
|
5053
|
+
L: 270,
|
|
4903
5054
|
S: this,
|
|
4904
5055
|
C: (f, a) => f(...a)
|
|
4905
5056
|
});
|
|
4906
|
-
(0,
|
|
4907
|
-
F:
|
|
4908
|
-
L:
|
|
5057
|
+
(0, import_invariant15.invariant)(this._isOpen, "Not open.", {
|
|
5058
|
+
F: __dxlog_file17,
|
|
5059
|
+
L: 271,
|
|
4909
5060
|
S: this,
|
|
4910
5061
|
A: [
|
|
4911
5062
|
"this._isOpen",
|
|
4912
5063
|
"'Not open.'"
|
|
4913
5064
|
]
|
|
4914
5065
|
});
|
|
4915
|
-
(0,
|
|
4916
|
-
F:
|
|
4917
|
-
L:
|
|
5066
|
+
(0, import_invariant15.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
5067
|
+
F: __dxlog_file17,
|
|
5068
|
+
L: 272,
|
|
4918
5069
|
S: this,
|
|
4919
5070
|
A: [
|
|
4920
5071
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -4940,17 +5091,17 @@ var DataSpaceManager = class {
|
|
|
4940
5091
|
* TODO(dmaretskyi): Consider removing.
|
|
4941
5092
|
*/
|
|
4942
5093
|
async waitUntilSpaceReady(spaceKey) {
|
|
4943
|
-
await (0,
|
|
5094
|
+
await (0, import_context14.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
4944
5095
|
const space = this._spaces.get(spaceKey);
|
|
4945
|
-
return !!space && space.state ===
|
|
5096
|
+
return !!space && space.state === import_services14.SpaceState.READY;
|
|
4946
5097
|
}));
|
|
4947
5098
|
}
|
|
4948
5099
|
async _constructSpace(metadata) {
|
|
4949
|
-
(0,
|
|
5100
|
+
(0, import_log15.log)("construct space", {
|
|
4950
5101
|
metadata
|
|
4951
5102
|
}, {
|
|
4952
|
-
F:
|
|
4953
|
-
L:
|
|
5103
|
+
F: __dxlog_file17,
|
|
5104
|
+
L: 306,
|
|
4954
5105
|
S: this,
|
|
4955
5106
|
C: (f, a) => f(...a)
|
|
4956
5107
|
});
|
|
@@ -4975,7 +5126,7 @@ var DataSpaceManager = class {
|
|
|
4975
5126
|
swarmIdentity: {
|
|
4976
5127
|
peerKey: this._signingContext.deviceKey,
|
|
4977
5128
|
credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
|
|
4978
|
-
credentialAuthenticator: (0,
|
|
5129
|
+
credentialAuthenticator: (0, import_util10.deferFunction)(() => dataSpace.authVerifier.verifier)
|
|
4979
5130
|
},
|
|
4980
5131
|
onAuthorizedConnection: (session) => {
|
|
4981
5132
|
session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
|
|
@@ -4986,15 +5137,15 @@ var DataSpaceManager = class {
|
|
|
4986
5137
|
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
4987
5138
|
},
|
|
4988
5139
|
onAuthFailure: () => {
|
|
4989
|
-
|
|
4990
|
-
F:
|
|
4991
|
-
L:
|
|
5140
|
+
import_log15.log.warn("auth failure", void 0, {
|
|
5141
|
+
F: __dxlog_file17,
|
|
5142
|
+
L: 343,
|
|
4992
5143
|
S: this,
|
|
4993
5144
|
C: (f, a) => f(...a)
|
|
4994
5145
|
});
|
|
4995
5146
|
},
|
|
4996
5147
|
onMemberRolesChanged: async (members) => {
|
|
4997
|
-
if (dataSpace?.state ===
|
|
5148
|
+
if (dataSpace?.state === import_services14.SpaceState.READY) {
|
|
4998
5149
|
this._handleMemberRoleChanges(presence, space.protocol, members);
|
|
4999
5150
|
}
|
|
5000
5151
|
},
|
|
@@ -5007,7 +5158,7 @@ var DataSpaceManager = class {
|
|
|
5007
5158
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
5008
5159
|
const dataSpace = new DataSpace({
|
|
5009
5160
|
inner: space,
|
|
5010
|
-
initialState: metadata.state ===
|
|
5161
|
+
initialState: metadata.state === import_services14.SpaceState.INACTIVE ? import_services14.SpaceState.INACTIVE : import_services14.SpaceState.CLOSED,
|
|
5011
5162
|
metadataStore: this._metadataStore,
|
|
5012
5163
|
gossip,
|
|
5013
5164
|
presence,
|
|
@@ -5017,22 +5168,22 @@ var DataSpaceManager = class {
|
|
|
5017
5168
|
signingContext: this._signingContext,
|
|
5018
5169
|
callbacks: {
|
|
5019
5170
|
beforeReady: async () => {
|
|
5020
|
-
(0,
|
|
5171
|
+
(0, import_log15.log)("before space ready", {
|
|
5021
5172
|
space: space.key
|
|
5022
5173
|
}, {
|
|
5023
|
-
F:
|
|
5024
|
-
L:
|
|
5174
|
+
F: __dxlog_file17,
|
|
5175
|
+
L: 370,
|
|
5025
5176
|
S: this,
|
|
5026
5177
|
C: (f, a) => f(...a)
|
|
5027
5178
|
});
|
|
5028
5179
|
},
|
|
5029
5180
|
afterReady: async () => {
|
|
5030
|
-
(0,
|
|
5181
|
+
(0, import_log15.log)("after space ready", {
|
|
5031
5182
|
space: space.key,
|
|
5032
5183
|
open: this._isOpen
|
|
5033
5184
|
}, {
|
|
5034
|
-
F:
|
|
5035
|
-
L:
|
|
5185
|
+
F: __dxlog_file17,
|
|
5186
|
+
L: 373,
|
|
5036
5187
|
S: this,
|
|
5037
5188
|
C: (f, a) => f(...a)
|
|
5038
5189
|
});
|
|
@@ -5047,11 +5198,11 @@ var DataSpaceManager = class {
|
|
|
5047
5198
|
}
|
|
5048
5199
|
},
|
|
5049
5200
|
beforeClose: async () => {
|
|
5050
|
-
(0,
|
|
5201
|
+
(0, import_log15.log)("before space close", {
|
|
5051
5202
|
space: space.key
|
|
5052
5203
|
}, {
|
|
5053
|
-
F:
|
|
5054
|
-
L:
|
|
5204
|
+
F: __dxlog_file17,
|
|
5205
|
+
L: 381,
|
|
5055
5206
|
S: this,
|
|
5056
5207
|
C: (f, a) => f(...a)
|
|
5057
5208
|
});
|
|
@@ -5060,7 +5211,7 @@ var DataSpaceManager = class {
|
|
|
5060
5211
|
cache: metadata.cache
|
|
5061
5212
|
});
|
|
5062
5213
|
presence.newPeer.on((peerState) => {
|
|
5063
|
-
if (dataSpace.state ===
|
|
5214
|
+
if (dataSpace.state === import_services14.SpaceState.READY) {
|
|
5064
5215
|
this._handleNewPeerConnected(space, peerState);
|
|
5065
5216
|
}
|
|
5066
5217
|
});
|
|
@@ -5079,20 +5230,20 @@ var DataSpaceManager = class {
|
|
|
5079
5230
|
const peers = presence.getPeersByIdentityKey(member.key);
|
|
5080
5231
|
const sessions = peers.map((p) => p.peerId && spaceProtocol.sessions.get(p.peerId));
|
|
5081
5232
|
const sessionsToClose = sessions.filter((s) => {
|
|
5082
|
-
return (s && member.role === import_credentials16.SpaceMember.Role.REMOVED !== (s.authStatus ===
|
|
5233
|
+
return (s && member.role === import_credentials16.SpaceMember.Role.REMOVED !== (s.authStatus === import_echo_pipeline4.AuthStatus.FAILURE)) ?? false;
|
|
5083
5234
|
});
|
|
5084
5235
|
sessionsToClose.forEach((session) => {
|
|
5085
|
-
void session.close().catch(
|
|
5236
|
+
void session.close().catch(import_log15.log.error);
|
|
5086
5237
|
});
|
|
5087
5238
|
closedSessions += sessionsToClose.length;
|
|
5088
5239
|
}
|
|
5089
|
-
(0,
|
|
5240
|
+
(0, import_log15.log)("processed member role changes", {
|
|
5090
5241
|
roleChangeCount: memberInfo.length,
|
|
5091
5242
|
peersOnline: presence.getPeersOnline().length,
|
|
5092
5243
|
closedSessions
|
|
5093
5244
|
}, {
|
|
5094
|
-
F:
|
|
5095
|
-
L:
|
|
5245
|
+
F: __dxlog_file17,
|
|
5246
|
+
L: 417,
|
|
5096
5247
|
S: this,
|
|
5097
5248
|
C: (f, a) => f(...a)
|
|
5098
5249
|
});
|
|
@@ -5103,20 +5254,20 @@ var DataSpaceManager = class {
|
|
|
5103
5254
|
if (role === import_credentials16.SpaceMember.Role.REMOVED) {
|
|
5104
5255
|
const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
|
|
5105
5256
|
if (session != null) {
|
|
5106
|
-
(0,
|
|
5257
|
+
(0, import_log15.log)("closing a session with a removed peer", {
|
|
5107
5258
|
peerId: peerState.peerId
|
|
5108
5259
|
}, {
|
|
5109
|
-
F:
|
|
5110
|
-
L:
|
|
5260
|
+
F: __dxlog_file17,
|
|
5261
|
+
L: 431,
|
|
5111
5262
|
S: this,
|
|
5112
5263
|
C: (f, a) => f(...a)
|
|
5113
5264
|
});
|
|
5114
|
-
void session.close().catch(
|
|
5265
|
+
void session.close().catch(import_log15.log.error);
|
|
5115
5266
|
}
|
|
5116
5267
|
}
|
|
5117
5268
|
}
|
|
5118
5269
|
async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
|
|
5119
|
-
if (dataSpace?.state !==
|
|
5270
|
+
if (dataSpace?.state !== import_services14.SpaceState.READY) {
|
|
5120
5271
|
return;
|
|
5121
5272
|
}
|
|
5122
5273
|
if (isActive) {
|
|
@@ -5133,8 +5284,8 @@ var DataSpaceManager = class {
|
|
|
5133
5284
|
async _createDelegatedInvitations(space, invitations) {
|
|
5134
5285
|
const tasks = invitations.map(([credentialId, invitation]) => {
|
|
5135
5286
|
return this._invitationsManager.createInvitation({
|
|
5136
|
-
type:
|
|
5137
|
-
kind:
|
|
5287
|
+
type: import_services14.Invitation.Type.DELEGATED,
|
|
5288
|
+
kind: import_services14.Invitation.Kind.SPACE,
|
|
5138
5289
|
spaceKey: space.key,
|
|
5139
5290
|
authMethod: invitation.authMethod,
|
|
5140
5291
|
invitationId: invitation.invitationId,
|
|
@@ -5152,21 +5303,21 @@ var DataSpaceManager = class {
|
|
|
5152
5303
|
}
|
|
5153
5304
|
};
|
|
5154
5305
|
_ts_decorate5([
|
|
5155
|
-
|
|
5306
|
+
import_async17.synchronized
|
|
5156
5307
|
], DataSpaceManager.prototype, "open", null);
|
|
5157
5308
|
_ts_decorate5([
|
|
5158
|
-
|
|
5309
|
+
import_async17.synchronized
|
|
5159
5310
|
], DataSpaceManager.prototype, "close", null);
|
|
5160
5311
|
_ts_decorate5([
|
|
5161
|
-
|
|
5312
|
+
import_async17.synchronized
|
|
5162
5313
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
5163
5314
|
_ts_decorate5([
|
|
5164
|
-
|
|
5315
|
+
import_async17.synchronized
|
|
5165
5316
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
5166
5317
|
DataSpaceManager = _ts_decorate5([
|
|
5167
|
-
(0,
|
|
5318
|
+
(0, import_async17.trackLeaks)("open", "close")
|
|
5168
5319
|
], DataSpaceManager);
|
|
5169
|
-
var
|
|
5320
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
5170
5321
|
var SpacesServiceImpl = class {
|
|
5171
5322
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
5172
5323
|
this._identityManager = _identityManager;
|
|
@@ -5185,10 +5336,10 @@ var SpacesServiceImpl = class {
|
|
|
5185
5336
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols12.SpaceNotFoundError(spaceKey));
|
|
5186
5337
|
if (state) {
|
|
5187
5338
|
switch (state) {
|
|
5188
|
-
case
|
|
5339
|
+
case import_services15.SpaceState.ACTIVE:
|
|
5189
5340
|
await space.activate();
|
|
5190
5341
|
break;
|
|
5191
|
-
case
|
|
5342
|
+
case import_services15.SpaceState.INACTIVE:
|
|
5192
5343
|
await space.deactivate();
|
|
5193
5344
|
break;
|
|
5194
5345
|
default:
|
|
@@ -5209,9 +5360,9 @@ var SpacesServiceImpl = class {
|
|
|
5209
5360
|
});
|
|
5210
5361
|
}
|
|
5211
5362
|
const credentials = await (0, import_credentials19.createAdmissionCredentials)(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
5212
|
-
(0,
|
|
5213
|
-
F:
|
|
5214
|
-
L:
|
|
5363
|
+
(0, import_invariant16.invariant)(credentials[0].credential, void 0, {
|
|
5364
|
+
F: __dxlog_file18,
|
|
5365
|
+
L: 98,
|
|
5215
5366
|
S: this,
|
|
5216
5367
|
A: [
|
|
5217
5368
|
"credentials[0].credential",
|
|
@@ -5219,9 +5370,9 @@ var SpacesServiceImpl = class {
|
|
|
5219
5370
|
]
|
|
5220
5371
|
});
|
|
5221
5372
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5222
|
-
(0,
|
|
5223
|
-
F:
|
|
5224
|
-
L:
|
|
5373
|
+
(0, import_invariant16.invariant)((0, import_credentials19.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5374
|
+
F: __dxlog_file18,
|
|
5375
|
+
L: 100,
|
|
5225
5376
|
S: this,
|
|
5226
5377
|
A: [
|
|
5227
5378
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -5232,14 +5383,14 @@ var SpacesServiceImpl = class {
|
|
|
5232
5383
|
}
|
|
5233
5384
|
querySpaces() {
|
|
5234
5385
|
return new import_codec_protobuf11.Stream(({ next, ctx }) => {
|
|
5235
|
-
const scheduler = new
|
|
5386
|
+
const scheduler = new import_async18.UpdateScheduler(ctx, async () => {
|
|
5236
5387
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5237
5388
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
5238
|
-
(0,
|
|
5389
|
+
(0, import_log16.log)("update", {
|
|
5239
5390
|
spaces
|
|
5240
5391
|
}, {
|
|
5241
|
-
F:
|
|
5242
|
-
L:
|
|
5392
|
+
F: __dxlog_file18,
|
|
5393
|
+
L: 111,
|
|
5243
5394
|
S: this,
|
|
5244
5395
|
C: (f, a) => f(...a)
|
|
5245
5396
|
});
|
|
@@ -5250,14 +5401,22 @@ var SpacesServiceImpl = class {
|
|
|
5250
5401
|
}, {
|
|
5251
5402
|
maxFrequency: process.env.NODE_ENV === "test" ? void 0 : 2
|
|
5252
5403
|
});
|
|
5253
|
-
(0,
|
|
5404
|
+
(0, import_async18.scheduleTask)(ctx, async () => {
|
|
5254
5405
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5255
|
-
const subscriptions = new
|
|
5406
|
+
const subscriptions = new import_async18.EventSubscriptions();
|
|
5256
5407
|
ctx.onDispose(() => subscriptions.clear());
|
|
5257
5408
|
const subscribeSpaces = () => {
|
|
5258
5409
|
subscriptions.clear();
|
|
5259
5410
|
for (const space of dataSpaceManager.spaces.values()) {
|
|
5260
|
-
|
|
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
|
+
}));
|
|
5261
5420
|
subscriptions.add(space.presence.updated.on(ctx, () => scheduler.trigger()));
|
|
5262
5421
|
subscriptions.add(space.automergeSpaceState.onNewEpoch.on(ctx, () => scheduler.trigger()));
|
|
5263
5422
|
subscriptions.add(space.inner.controlPipeline.state.timeframeUpdate.on(ctx, () => scheduler.trigger()));
|
|
@@ -5284,7 +5443,7 @@ var SpacesServiceImpl = class {
|
|
|
5284
5443
|
}
|
|
5285
5444
|
subscribeMessages({ spaceKey, channel }) {
|
|
5286
5445
|
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
5287
|
-
(0,
|
|
5446
|
+
(0, import_async18.scheduleTask)(ctx, async () => {
|
|
5288
5447
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5289
5448
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols12.SpaceNotFoundError(spaceKey));
|
|
5290
5449
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
@@ -5303,7 +5462,7 @@ var SpacesServiceImpl = class {
|
|
|
5303
5462
|
}
|
|
5304
5463
|
};
|
|
5305
5464
|
ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
|
|
5306
|
-
(0,
|
|
5465
|
+
(0, import_async18.scheduleTask)(ctx, async () => {
|
|
5307
5466
|
await space.spaceState.addCredentialProcessor(processor);
|
|
5308
5467
|
if (noTail) {
|
|
5309
5468
|
close();
|
|
@@ -5321,18 +5480,18 @@ var SpacesServiceImpl = class {
|
|
|
5321
5480
|
}
|
|
5322
5481
|
});
|
|
5323
5482
|
} else {
|
|
5324
|
-
(0,
|
|
5325
|
-
F:
|
|
5326
|
-
L:
|
|
5483
|
+
(0, import_invariant16.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
5484
|
+
F: __dxlog_file18,
|
|
5485
|
+
L: 209,
|
|
5327
5486
|
S: this,
|
|
5328
5487
|
A: [
|
|
5329
5488
|
"!credential.id",
|
|
5330
5489
|
"'Id on unsigned credentials is not allowed'"
|
|
5331
5490
|
]
|
|
5332
5491
|
});
|
|
5333
|
-
(0,
|
|
5334
|
-
F:
|
|
5335
|
-
L:
|
|
5492
|
+
(0, import_invariant16.invariant)(this._identityManager.identity, "Identity is not available", {
|
|
5493
|
+
F: __dxlog_file18,
|
|
5494
|
+
L: 210,
|
|
5336
5495
|
S: this,
|
|
5337
5496
|
A: [
|
|
5338
5497
|
"this._identityManager.identity",
|
|
@@ -5340,9 +5499,9 @@ var SpacesServiceImpl = class {
|
|
|
5340
5499
|
]
|
|
5341
5500
|
});
|
|
5342
5501
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
5343
|
-
(0,
|
|
5344
|
-
F:
|
|
5345
|
-
L:
|
|
5502
|
+
(0, import_invariant16.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
5503
|
+
F: __dxlog_file18,
|
|
5504
|
+
L: 212,
|
|
5346
5505
|
S: this,
|
|
5347
5506
|
A: [
|
|
5348
5507
|
"credential.issuer.equals(signer.getIssuer())",
|
|
@@ -5364,10 +5523,13 @@ var SpacesServiceImpl = class {
|
|
|
5364
5523
|
async createEpoch({ spaceKey, migration, automergeRootUrl }) {
|
|
5365
5524
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5366
5525
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols12.SpaceNotFoundError(spaceKey));
|
|
5367
|
-
await space.createEpoch({
|
|
5526
|
+
const credential = await space.createEpoch({
|
|
5368
5527
|
migration,
|
|
5369
5528
|
newAutomergeRoot: automergeRootUrl
|
|
5370
5529
|
});
|
|
5530
|
+
return {
|
|
5531
|
+
epochCredential: credential ?? void 0
|
|
5532
|
+
};
|
|
5371
5533
|
}
|
|
5372
5534
|
_serializeSpace(space) {
|
|
5373
5535
|
return {
|
|
@@ -5400,7 +5562,7 @@ var SpacesServiceImpl = class {
|
|
|
5400
5562
|
profile: member.profile ?? {}
|
|
5401
5563
|
},
|
|
5402
5564
|
role: member.role,
|
|
5403
|
-
presence: peers.length > 0 ?
|
|
5565
|
+
presence: peers.length > 0 ? import_services15.SpaceMember.PresenceState.ONLINE : import_services15.SpaceMember.PresenceState.OFFLINE,
|
|
5404
5566
|
peerStates: peers
|
|
5405
5567
|
};
|
|
5406
5568
|
}),
|
|
@@ -5438,8 +5600,8 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
5438
5600
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5439
5601
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5440
5602
|
}
|
|
5441
|
-
var
|
|
5442
|
-
var ServiceContext = class extends
|
|
5603
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
5604
|
+
var ServiceContext = class extends import_context15.Resource {
|
|
5443
5605
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
5444
5606
|
super();
|
|
5445
5607
|
this.storage = storage;
|
|
@@ -5447,11 +5609,11 @@ var ServiceContext = class extends import_context13.Resource {
|
|
|
5447
5609
|
this.networkManager = networkManager;
|
|
5448
5610
|
this.signalManager = signalManager;
|
|
5449
5611
|
this._runtimeParams = _runtimeParams;
|
|
5450
|
-
this.initialized = new
|
|
5612
|
+
this.initialized = new import_async19.Trigger();
|
|
5451
5613
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
5452
5614
|
this._instanceId = import_keys13.PublicKey.random().toHex();
|
|
5453
|
-
this.metadataStore = new
|
|
5454
|
-
this.snapshotStore = new
|
|
5615
|
+
this.metadataStore = new import_echo_pipeline5.MetadataStore(storage.createDirectory("metadata"));
|
|
5616
|
+
this.snapshotStore = new import_echo_pipeline5.SnapshotStore(storage.createDirectory("snapshots"));
|
|
5455
5617
|
this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
|
|
5456
5618
|
this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
|
|
5457
5619
|
this.feedStore = new import_feed_store5.FeedStore({
|
|
@@ -5459,12 +5621,12 @@ var ServiceContext = class extends import_context13.Resource {
|
|
|
5459
5621
|
root: storage.createDirectory("feeds"),
|
|
5460
5622
|
signer: this.keyring,
|
|
5461
5623
|
hypercore: {
|
|
5462
|
-
valueEncoding:
|
|
5624
|
+
valueEncoding: import_echo_pipeline5.valueEncoding,
|
|
5463
5625
|
stats: true
|
|
5464
5626
|
}
|
|
5465
5627
|
})
|
|
5466
5628
|
});
|
|
5467
|
-
this.spaceManager = new
|
|
5629
|
+
this.spaceManager = new import_echo_pipeline5.SpaceManager({
|
|
5468
5630
|
feedStore: this.feedStore,
|
|
5469
5631
|
networkManager: this.networkManager,
|
|
5470
5632
|
blobStore: this.blobStore,
|
|
@@ -5472,27 +5634,26 @@ var ServiceContext = class extends import_context13.Resource {
|
|
|
5472
5634
|
snapshotStore: this.snapshotStore
|
|
5473
5635
|
});
|
|
5474
5636
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
5475
|
-
this.echoHost = new
|
|
5476
|
-
kv: this.level
|
|
5477
|
-
storage: this.storage
|
|
5637
|
+
this.echoHost = new import_echo_db3.EchoHost({
|
|
5638
|
+
kv: this.level
|
|
5478
5639
|
});
|
|
5479
5640
|
this.invitations = new InvitationsHandler(this.networkManager, _runtimeParams?.invitationConnectionDefaultParams);
|
|
5480
5641
|
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
5481
|
-
this._handlerFactories.set(
|
|
5642
|
+
this._handlerFactories.set(import_services16.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
5482
5643
|
}
|
|
5483
5644
|
async _open(ctx) {
|
|
5484
5645
|
await this._checkStorageVersion();
|
|
5485
|
-
(0,
|
|
5486
|
-
F:
|
|
5487
|
-
L:
|
|
5646
|
+
(0, import_log17.log)("opening...", void 0, {
|
|
5647
|
+
F: __dxlog_file19,
|
|
5648
|
+
L: 149,
|
|
5488
5649
|
S: this,
|
|
5489
5650
|
C: (f, a) => f(...a)
|
|
5490
5651
|
});
|
|
5491
|
-
|
|
5652
|
+
import_log17.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.begin({
|
|
5492
5653
|
id: this._instanceId
|
|
5493
5654
|
}), {
|
|
5494
|
-
F:
|
|
5495
|
-
L:
|
|
5655
|
+
F: __dxlog_file19,
|
|
5656
|
+
L: 150,
|
|
5496
5657
|
S: this,
|
|
5497
5658
|
C: (f, a) => f(...a)
|
|
5498
5659
|
});
|
|
@@ -5506,33 +5667,33 @@ var ServiceContext = class extends import_context13.Resource {
|
|
|
5506
5667
|
await this._initialize(ctx);
|
|
5507
5668
|
}
|
|
5508
5669
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
5509
|
-
(0,
|
|
5670
|
+
(0, import_log17.log)("loaded persistent invitations", {
|
|
5510
5671
|
count: loadedInvitations.invitations?.length
|
|
5511
5672
|
}, {
|
|
5512
|
-
F:
|
|
5513
|
-
L:
|
|
5673
|
+
F: __dxlog_file19,
|
|
5674
|
+
L: 163,
|
|
5514
5675
|
S: this,
|
|
5515
5676
|
C: (f, a) => f(...a)
|
|
5516
5677
|
});
|
|
5517
|
-
|
|
5678
|
+
import_log17.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.end({
|
|
5518
5679
|
id: this._instanceId
|
|
5519
5680
|
}), {
|
|
5520
|
-
F:
|
|
5521
|
-
L:
|
|
5681
|
+
F: __dxlog_file19,
|
|
5682
|
+
L: 165,
|
|
5522
5683
|
S: this,
|
|
5523
5684
|
C: (f, a) => f(...a)
|
|
5524
5685
|
});
|
|
5525
|
-
(0,
|
|
5526
|
-
F:
|
|
5527
|
-
L:
|
|
5686
|
+
(0, import_log17.log)("opened", void 0, {
|
|
5687
|
+
F: __dxlog_file19,
|
|
5688
|
+
L: 166,
|
|
5528
5689
|
S: this,
|
|
5529
5690
|
C: (f, a) => f(...a)
|
|
5530
5691
|
});
|
|
5531
5692
|
}
|
|
5532
5693
|
async _close(ctx) {
|
|
5533
|
-
(0,
|
|
5534
|
-
F:
|
|
5535
|
-
L:
|
|
5694
|
+
(0, import_log17.log)("closing...", void 0, {
|
|
5695
|
+
F: __dxlog_file19,
|
|
5696
|
+
L: 170,
|
|
5536
5697
|
S: this,
|
|
5537
5698
|
C: (f, a) => f(...a)
|
|
5538
5699
|
});
|
|
@@ -5547,23 +5708,23 @@ var ServiceContext = class extends import_context13.Resource {
|
|
|
5547
5708
|
await this.echoHost.close(ctx);
|
|
5548
5709
|
await this.networkManager.close();
|
|
5549
5710
|
await this.signalManager.close();
|
|
5550
|
-
(0,
|
|
5551
|
-
F:
|
|
5552
|
-
L:
|
|
5711
|
+
(0, import_log17.log)("closed", void 0, {
|
|
5712
|
+
F: __dxlog_file19,
|
|
5713
|
+
L: 182,
|
|
5553
5714
|
S: this,
|
|
5554
5715
|
C: (f, a) => f(...a)
|
|
5555
5716
|
});
|
|
5556
5717
|
}
|
|
5557
5718
|
async createIdentity(params = {}) {
|
|
5558
5719
|
const identity = await this.identityManager.createIdentity(params);
|
|
5559
|
-
await this._initialize(new
|
|
5720
|
+
await this._initialize(new import_context15.Context());
|
|
5560
5721
|
return identity;
|
|
5561
5722
|
}
|
|
5562
5723
|
getInvitationHandler(invitation) {
|
|
5563
5724
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
5564
|
-
(0,
|
|
5565
|
-
F:
|
|
5566
|
-
L:
|
|
5725
|
+
(0, import_invariant17.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
5726
|
+
F: __dxlog_file19,
|
|
5727
|
+
L: 193,
|
|
5567
5728
|
S: this,
|
|
5568
5729
|
A: [
|
|
5569
5730
|
"factory",
|
|
@@ -5582,7 +5743,7 @@ var ServiceContext = class extends import_context13.Resource {
|
|
|
5582
5743
|
}
|
|
5583
5744
|
async _acceptIdentity(params) {
|
|
5584
5745
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
5585
|
-
await this._initialize(new
|
|
5746
|
+
await this._initialize(new import_context15.Context());
|
|
5586
5747
|
return identity;
|
|
5587
5748
|
}
|
|
5588
5749
|
async _checkStorageVersion() {
|
|
@@ -5593,9 +5754,9 @@ var ServiceContext = class extends import_context13.Resource {
|
|
|
5593
5754
|
}
|
|
5594
5755
|
// Called when identity is created.
|
|
5595
5756
|
async _initialize(ctx) {
|
|
5596
|
-
(0,
|
|
5597
|
-
F:
|
|
5598
|
-
L:
|
|
5757
|
+
(0, import_log17.log)("initializing spaces...", void 0, {
|
|
5758
|
+
F: __dxlog_file19,
|
|
5759
|
+
L: 224,
|
|
5599
5760
|
S: this,
|
|
5600
5761
|
C: (f, a) => f(...a)
|
|
5601
5762
|
});
|
|
@@ -5615,10 +5776,10 @@ var ServiceContext = class extends import_context13.Resource {
|
|
|
5615
5776
|
};
|
|
5616
5777
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.echoHost, this.invitationsManager, this._runtimeParams);
|
|
5617
5778
|
await this.dataSpaceManager.open();
|
|
5618
|
-
this._handlerFactories.set(
|
|
5619
|
-
(0,
|
|
5620
|
-
F:
|
|
5621
|
-
L:
|
|
5779
|
+
this._handlerFactories.set(import_services16.Invitation.Kind.SPACE, (invitation) => {
|
|
5780
|
+
(0, import_invariant17.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
5781
|
+
F: __dxlog_file19,
|
|
5782
|
+
L: 249,
|
|
5622
5783
|
S: this,
|
|
5623
5784
|
A: [
|
|
5624
5785
|
"this.dataSpaceManager",
|
|
@@ -5638,33 +5799,33 @@ var ServiceContext = class extends import_context13.Resource {
|
|
|
5638
5799
|
return;
|
|
5639
5800
|
}
|
|
5640
5801
|
if (!this.dataSpaceManager) {
|
|
5641
|
-
(0,
|
|
5802
|
+
(0, import_log17.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
5642
5803
|
details: assertion
|
|
5643
5804
|
}, {
|
|
5644
|
-
F:
|
|
5645
|
-
L:
|
|
5805
|
+
F: __dxlog_file19,
|
|
5806
|
+
L: 265,
|
|
5646
5807
|
S: this,
|
|
5647
5808
|
C: (f, a) => f(...a)
|
|
5648
5809
|
});
|
|
5649
5810
|
return;
|
|
5650
5811
|
}
|
|
5651
5812
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
5652
|
-
(0,
|
|
5813
|
+
(0, import_log17.log)("space already exists, ignoring space admission", {
|
|
5653
5814
|
details: assertion
|
|
5654
5815
|
}, {
|
|
5655
|
-
F:
|
|
5656
|
-
L:
|
|
5816
|
+
F: __dxlog_file19,
|
|
5817
|
+
L: 269,
|
|
5657
5818
|
S: this,
|
|
5658
5819
|
C: (f, a) => f(...a)
|
|
5659
5820
|
});
|
|
5660
5821
|
return;
|
|
5661
5822
|
}
|
|
5662
5823
|
try {
|
|
5663
|
-
(0,
|
|
5824
|
+
(0, import_log17.log)("accepting space recorded in halo", {
|
|
5664
5825
|
details: assertion
|
|
5665
5826
|
}, {
|
|
5666
|
-
F:
|
|
5667
|
-
L:
|
|
5827
|
+
F: __dxlog_file19,
|
|
5828
|
+
L: 274,
|
|
5668
5829
|
S: this,
|
|
5669
5830
|
C: (f, a) => f(...a)
|
|
5670
5831
|
});
|
|
@@ -5673,9 +5834,9 @@ var ServiceContext = class extends import_context13.Resource {
|
|
|
5673
5834
|
genesisFeedKey: assertion.genesisFeedKey
|
|
5674
5835
|
});
|
|
5675
5836
|
} catch (err) {
|
|
5676
|
-
|
|
5677
|
-
F:
|
|
5678
|
-
L:
|
|
5837
|
+
import_log17.log.catch(err, void 0, {
|
|
5838
|
+
F: __dxlog_file19,
|
|
5839
|
+
L: 280,
|
|
5679
5840
|
S: this,
|
|
5680
5841
|
C: (f, a) => f(...a)
|
|
5681
5842
|
});
|
|
@@ -5692,7 +5853,7 @@ _ts_decorate6([
|
|
|
5692
5853
|
import_tracing8.trace.span()
|
|
5693
5854
|
], ServiceContext.prototype, "_initialize", null);
|
|
5694
5855
|
ServiceContext = _ts_decorate6([
|
|
5695
|
-
(0,
|
|
5856
|
+
(0, import_util11.safeInstanceof)("dxos.client-services.ServiceContext"),
|
|
5696
5857
|
import_tracing8.trace.resource()
|
|
5697
5858
|
], ServiceContext);
|
|
5698
5859
|
var ServiceRegistry = class {
|
|
@@ -5727,7 +5888,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
5727
5888
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5728
5889
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5729
5890
|
}
|
|
5730
|
-
var
|
|
5891
|
+
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
5731
5892
|
var Lock = class {
|
|
5732
5893
|
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
5733
5894
|
this._lockPath = lockPath;
|
|
@@ -5738,16 +5899,16 @@ var Lock = class {
|
|
|
5738
5899
|
return this._lockPath;
|
|
5739
5900
|
}
|
|
5740
5901
|
async acquire() {
|
|
5741
|
-
(0,
|
|
5742
|
-
F:
|
|
5902
|
+
(0, import_log18.log)("acquiring lock...", void 0, {
|
|
5903
|
+
F: __dxlog_file20,
|
|
5743
5904
|
L: 32,
|
|
5744
5905
|
S: this,
|
|
5745
5906
|
C: (f, a) => f(...a)
|
|
5746
5907
|
});
|
|
5747
5908
|
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
5748
5909
|
await this._onAcquire?.();
|
|
5749
|
-
(0,
|
|
5750
|
-
F:
|
|
5910
|
+
(0, import_log18.log)("acquired lock", void 0, {
|
|
5911
|
+
F: __dxlog_file20,
|
|
5751
5912
|
L: 37,
|
|
5752
5913
|
S: this,
|
|
5753
5914
|
C: (f, a) => f(...a)
|
|
@@ -5755,8 +5916,8 @@ var Lock = class {
|
|
|
5755
5916
|
}
|
|
5756
5917
|
async release() {
|
|
5757
5918
|
await this._onRelease?.();
|
|
5758
|
-
(0,
|
|
5759
|
-
F:
|
|
5919
|
+
(0, import_invariant18.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
5920
|
+
F: __dxlog_file20,
|
|
5760
5921
|
L: 42,
|
|
5761
5922
|
S: this,
|
|
5762
5923
|
A: [
|
|
@@ -5768,11 +5929,11 @@ var Lock = class {
|
|
|
5768
5929
|
}
|
|
5769
5930
|
};
|
|
5770
5931
|
_ts_decorate7([
|
|
5771
|
-
|
|
5932
|
+
import_log18.logInfo
|
|
5772
5933
|
], Lock.prototype, "lockKey", null);
|
|
5773
5934
|
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
5774
5935
|
var getRootPath = (config) => {
|
|
5775
|
-
const { dataRoot = (0,
|
|
5936
|
+
const { dataRoot = (0, import_util12.isNode)() ? import_client_protocol6.DX_DATA : "dxos/storage" } = config ?? {};
|
|
5776
5937
|
return `${dataRoot}/`;
|
|
5777
5938
|
};
|
|
5778
5939
|
var isPersistent = (config) => {
|
|
@@ -5828,7 +5989,7 @@ var createLevel = async (config) => {
|
|
|
5828
5989
|
await level.open();
|
|
5829
5990
|
return level;
|
|
5830
5991
|
};
|
|
5831
|
-
var
|
|
5992
|
+
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
5832
5993
|
var DevicesServiceImpl = class {
|
|
5833
5994
|
constructor(_identityManager) {
|
|
5834
5995
|
this._identityManager = _identityManager;
|
|
@@ -5845,8 +6006,8 @@ var DevicesServiceImpl = class {
|
|
|
5845
6006
|
devices: []
|
|
5846
6007
|
});
|
|
5847
6008
|
} else {
|
|
5848
|
-
(0,
|
|
5849
|
-
F:
|
|
6009
|
+
(0, import_invariant20.invariant)(this._identityManager.identity?.presence, "presence not present", {
|
|
6010
|
+
F: __dxlog_file21,
|
|
5850
6011
|
L: 32,
|
|
5851
6012
|
S: this,
|
|
5852
6013
|
A: [
|
|
@@ -5861,9 +6022,9 @@ var DevicesServiceImpl = class {
|
|
|
5861
6022
|
const peerState = peers.find((peer) => peer.identityKey.equals(key));
|
|
5862
6023
|
return {
|
|
5863
6024
|
deviceKey: key,
|
|
5864
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ?
|
|
6025
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services18.DeviceKind.CURRENT : import_services18.DeviceKind.TRUSTED,
|
|
5865
6026
|
profile,
|
|
5866
|
-
presence: isMe ?
|
|
6027
|
+
presence: isMe ? import_services18.Device.PresenceState.ONLINE : peerState ? import_services18.Device.PresenceState.ONLINE : import_services18.Device.PresenceState.OFFLINE
|
|
5867
6028
|
};
|
|
5868
6029
|
})
|
|
5869
6030
|
});
|
|
@@ -5887,7 +6048,7 @@ var DevicesServiceImpl = class {
|
|
|
5887
6048
|
presenceSubscribed = true;
|
|
5888
6049
|
}
|
|
5889
6050
|
};
|
|
5890
|
-
const subscriptions = new
|
|
6051
|
+
const subscriptions = new import_async21.EventSubscriptions();
|
|
5891
6052
|
if (this._identityManager.identity) {
|
|
5892
6053
|
subscribeIdentity();
|
|
5893
6054
|
subscribePresence();
|
|
@@ -5912,7 +6073,7 @@ var DiagnosticsCollector = class {
|
|
|
5912
6073
|
}
|
|
5913
6074
|
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
5914
6075
|
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
5915
|
-
keys: options.humanize ?
|
|
6076
|
+
keys: options.humanize ? import_services19.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services19.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
5916
6077
|
}, {
|
|
5917
6078
|
timeout: GET_DIAGNOSTICS_RPC_TIMEOUT
|
|
5918
6079
|
});
|
|
@@ -5927,7 +6088,7 @@ var DiagnosticsCollector = class {
|
|
|
5927
6088
|
client: clientDiagnostics,
|
|
5928
6089
|
broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
|
|
5929
6090
|
};
|
|
5930
|
-
return JSON.parse(JSON.stringify(diagnostics, (0,
|
|
6091
|
+
return JSON.parse(JSON.stringify(diagnostics, (0, import_util13.jsonKeyReplacer)(options)));
|
|
5931
6092
|
}
|
|
5932
6093
|
};
|
|
5933
6094
|
var findSystemServiceProvider = () => {
|
|
@@ -5937,11 +6098,11 @@ var findSystemServiceProvider = () => {
|
|
|
5937
6098
|
};
|
|
5938
6099
|
var findConfigs = () => {
|
|
5939
6100
|
const configs = import_tracing10.TRACE_PROCESSOR.findResourcesByAnnotation(import_config3.ConfigResource);
|
|
5940
|
-
return configs.map((r) => r.instance.deref()).filter(
|
|
6101
|
+
return configs.map((r) => r.instance.deref()).filter(import_util13.nonNullable);
|
|
5941
6102
|
};
|
|
5942
6103
|
var LoggingServiceImpl = class {
|
|
5943
6104
|
constructor() {
|
|
5944
|
-
this._logs = new
|
|
6105
|
+
this._logs = new import_async22.Event();
|
|
5945
6106
|
this._started = Date.now();
|
|
5946
6107
|
this._sessionId = import_keys17.PublicKey.random().toHex();
|
|
5947
6108
|
this._logProcessor = (_config, entry2) => {
|
|
@@ -5949,23 +6110,23 @@ var LoggingServiceImpl = class {
|
|
|
5949
6110
|
};
|
|
5950
6111
|
}
|
|
5951
6112
|
async open() {
|
|
5952
|
-
|
|
6113
|
+
import_log20.log.runtimeConfig.processors.push(this._logProcessor);
|
|
5953
6114
|
}
|
|
5954
6115
|
async close() {
|
|
5955
|
-
const index =
|
|
5956
|
-
|
|
6116
|
+
const index = import_log20.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
6117
|
+
import_log20.log.runtimeConfig.processors.splice(index, 1);
|
|
5957
6118
|
}
|
|
5958
6119
|
async controlMetrics({ reset, record }) {
|
|
5959
6120
|
if (reset) {
|
|
5960
|
-
|
|
6121
|
+
import_util15.tracer.clear();
|
|
5961
6122
|
}
|
|
5962
6123
|
if (record === true) {
|
|
5963
|
-
|
|
6124
|
+
import_util15.tracer.start();
|
|
5964
6125
|
} else if (record === false) {
|
|
5965
|
-
|
|
6126
|
+
import_util15.tracer.stop();
|
|
5966
6127
|
}
|
|
5967
6128
|
return {
|
|
5968
|
-
recording:
|
|
6129
|
+
recording: import_util15.tracer.recording
|
|
5969
6130
|
};
|
|
5970
6131
|
}
|
|
5971
6132
|
/**
|
|
@@ -5973,10 +6134,10 @@ var LoggingServiceImpl = class {
|
|
|
5973
6134
|
*/
|
|
5974
6135
|
queryMetrics({ interval = 5e3 }) {
|
|
5975
6136
|
const getNumericalValues = (key) => {
|
|
5976
|
-
const events =
|
|
6137
|
+
const events = import_util15.tracer.get(key) ?? [];
|
|
5977
6138
|
return {
|
|
5978
6139
|
key,
|
|
5979
|
-
stats: (0,
|
|
6140
|
+
stats: (0, import_util15.numericalValues)(events, "duration")
|
|
5980
6141
|
};
|
|
5981
6142
|
};
|
|
5982
6143
|
return new import_codec_protobuf13.Stream(({ next }) => {
|
|
@@ -6014,7 +6175,7 @@ var LoggingServiceImpl = class {
|
|
|
6014
6175
|
}
|
|
6015
6176
|
const record = {
|
|
6016
6177
|
...entry2,
|
|
6017
|
-
context: (0,
|
|
6178
|
+
context: (0, import_util15.jsonify)((0, import_log20.getContextFromEntry)(entry2)),
|
|
6018
6179
|
timestamp: /* @__PURE__ */ new Date(),
|
|
6019
6180
|
meta: {
|
|
6020
6181
|
// TODO(dmaretskyi): Fix proto.
|
|
@@ -6023,7 +6184,7 @@ var LoggingServiceImpl = class {
|
|
|
6023
6184
|
scope: {
|
|
6024
6185
|
hostSessionId: this._sessionId,
|
|
6025
6186
|
uptimeSeconds: (Date.now() - this._started) / 1e3,
|
|
6026
|
-
name: (0,
|
|
6187
|
+
name: (0, import_util15.getDebugName)(entry2.meta?.S)
|
|
6027
6188
|
}
|
|
6028
6189
|
}
|
|
6029
6190
|
};
|
|
@@ -6040,16 +6201,16 @@ var LoggingServiceImpl = class {
|
|
|
6040
6201
|
};
|
|
6041
6202
|
var matchFilter = (filter, level, path2, options) => {
|
|
6042
6203
|
switch (options) {
|
|
6043
|
-
case
|
|
6204
|
+
case import_services20.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
6044
6205
|
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
6045
|
-
case
|
|
6206
|
+
case import_services20.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
6046
6207
|
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
6047
6208
|
}
|
|
6048
6209
|
};
|
|
6049
6210
|
var shouldLog = (entry2, request) => {
|
|
6050
|
-
const options = request.options ??
|
|
6211
|
+
const options = request.options ?? import_services20.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
6051
6212
|
if (request.filters === void 0) {
|
|
6052
|
-
return options ===
|
|
6213
|
+
return options === import_services20.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
6053
6214
|
} else {
|
|
6054
6215
|
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
6055
6216
|
}
|
|
@@ -6104,9 +6265,9 @@ var SystemServiceImpl = class {
|
|
|
6104
6265
|
const diagnostics = await this._getDiagnostics();
|
|
6105
6266
|
return {
|
|
6106
6267
|
timestamp: /* @__PURE__ */ new Date(),
|
|
6107
|
-
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0,
|
|
6108
|
-
truncate: keys ===
|
|
6109
|
-
humanize: keys ===
|
|
6268
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util16.jsonKeyReplacer)({
|
|
6269
|
+
truncate: keys === import_services21.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
6270
|
+
humanize: keys === import_services21.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
6110
6271
|
})))
|
|
6111
6272
|
};
|
|
6112
6273
|
}
|
|
@@ -6147,7 +6308,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
6147
6308
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6148
6309
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6149
6310
|
}
|
|
6150
|
-
var
|
|
6311
|
+
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
6151
6312
|
var ClientServicesHost = class {
|
|
6152
6313
|
constructor({
|
|
6153
6314
|
config,
|
|
@@ -6161,7 +6322,7 @@ var ClientServicesHost = class {
|
|
|
6161
6322
|
runtimeParams
|
|
6162
6323
|
} = {}) {
|
|
6163
6324
|
this._tracingService = import_tracing9.TRACE_PROCESSOR.createTraceSender();
|
|
6164
|
-
this._statusUpdate = new
|
|
6325
|
+
this._statusUpdate = new import_async20.Event();
|
|
6165
6326
|
this._opening = false;
|
|
6166
6327
|
this._open = false;
|
|
6167
6328
|
this._storage = storage;
|
|
@@ -6180,7 +6341,7 @@ var ClientServicesHost = class {
|
|
|
6180
6341
|
lockKey,
|
|
6181
6342
|
onAcquire: () => {
|
|
6182
6343
|
if (!this._opening) {
|
|
6183
|
-
void this.open(new
|
|
6344
|
+
void this.open(new import_context16.Context());
|
|
6184
6345
|
}
|
|
6185
6346
|
},
|
|
6186
6347
|
onRelease: () => this.close()
|
|
@@ -6189,14 +6350,14 @@ var ClientServicesHost = class {
|
|
|
6189
6350
|
this._systemService = new SystemServiceImpl({
|
|
6190
6351
|
config: () => this._config,
|
|
6191
6352
|
statusUpdate: this._statusUpdate,
|
|
6192
|
-
getCurrentStatus: () => this.isOpen ?
|
|
6353
|
+
getCurrentStatus: () => this.isOpen ? import_services17.SystemStatus.ACTIVE : import_services17.SystemStatus.INACTIVE,
|
|
6193
6354
|
getDiagnostics: () => {
|
|
6194
6355
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
6195
6356
|
},
|
|
6196
6357
|
onUpdateStatus: async (status) => {
|
|
6197
|
-
if (!this.isOpen && status ===
|
|
6358
|
+
if (!this.isOpen && status === import_services17.SystemStatus.ACTIVE) {
|
|
6198
6359
|
await this._resourceLock?.acquire();
|
|
6199
|
-
} else if (this.isOpen && status ===
|
|
6360
|
+
} else if (this.isOpen && status === import_services17.SystemStatus.INACTIVE) {
|
|
6200
6361
|
await this._resourceLock?.release();
|
|
6201
6362
|
}
|
|
6202
6363
|
},
|
|
@@ -6235,8 +6396,8 @@ var ClientServicesHost = class {
|
|
|
6235
6396
|
* Can only be called once.
|
|
6236
6397
|
*/
|
|
6237
6398
|
initialize({ config, ...options }) {
|
|
6238
|
-
(0,
|
|
6239
|
-
F:
|
|
6399
|
+
(0, import_invariant19.invariant)(!this._open, "service host is open", {
|
|
6400
|
+
F: __dxlog_file22,
|
|
6240
6401
|
L: 186,
|
|
6241
6402
|
S: this,
|
|
6242
6403
|
A: [
|
|
@@ -6244,15 +6405,15 @@ var ClientServicesHost = class {
|
|
|
6244
6405
|
"'service host is open'"
|
|
6245
6406
|
]
|
|
6246
6407
|
});
|
|
6247
|
-
(0,
|
|
6248
|
-
F:
|
|
6408
|
+
(0, import_log19.log)("initializing...", void 0, {
|
|
6409
|
+
F: __dxlog_file22,
|
|
6249
6410
|
L: 187,
|
|
6250
6411
|
S: this,
|
|
6251
6412
|
C: (f, a) => f(...a)
|
|
6252
6413
|
});
|
|
6253
6414
|
if (config) {
|
|
6254
|
-
(0,
|
|
6255
|
-
F:
|
|
6415
|
+
(0, import_invariant19.invariant)(!this._config, "config already set", {
|
|
6416
|
+
F: __dxlog_file22,
|
|
6256
6417
|
L: 190,
|
|
6257
6418
|
S: this,
|
|
6258
6419
|
A: [
|
|
@@ -6266,8 +6427,8 @@ var ClientServicesHost = class {
|
|
|
6266
6427
|
}
|
|
6267
6428
|
}
|
|
6268
6429
|
if (!options.signalManager) {
|
|
6269
|
-
|
|
6270
|
-
F:
|
|
6430
|
+
import_log19.log.warn("running signaling without telemetry metadata.", void 0, {
|
|
6431
|
+
F: __dxlog_file22,
|
|
6271
6432
|
L: 198,
|
|
6272
6433
|
S: this,
|
|
6273
6434
|
C: (f, a) => f(...a)
|
|
@@ -6277,8 +6438,8 @@ var ClientServicesHost = class {
|
|
|
6277
6438
|
iceServers: this._config?.get("runtime.services.ice")
|
|
6278
6439
|
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
6279
6440
|
this._signalManager = signalManager;
|
|
6280
|
-
(0,
|
|
6281
|
-
F:
|
|
6441
|
+
(0, import_invariant19.invariant)(!this._networkManager, "network manager already set", {
|
|
6442
|
+
F: __dxlog_file22,
|
|
6282
6443
|
L: 209,
|
|
6283
6444
|
S: this,
|
|
6284
6445
|
A: [
|
|
@@ -6291,8 +6452,8 @@ var ClientServicesHost = class {
|
|
|
6291
6452
|
transportFactory,
|
|
6292
6453
|
signalManager
|
|
6293
6454
|
});
|
|
6294
|
-
(0,
|
|
6295
|
-
F:
|
|
6455
|
+
(0, import_log19.log)("initialized", void 0, {
|
|
6456
|
+
F: __dxlog_file22,
|
|
6296
6457
|
L: 216,
|
|
6297
6458
|
S: this,
|
|
6298
6459
|
C: (f, a) => f(...a)
|
|
@@ -6303,16 +6464,16 @@ var ClientServicesHost = class {
|
|
|
6303
6464
|
return;
|
|
6304
6465
|
}
|
|
6305
6466
|
const traceId = import_keys15.PublicKey.random().toHex();
|
|
6306
|
-
|
|
6467
|
+
import_log19.log.trace("dxos.client-services.host.open", import_protocols15.trace.begin({
|
|
6307
6468
|
id: traceId
|
|
6308
6469
|
}), {
|
|
6309
|
-
F:
|
|
6470
|
+
F: __dxlog_file22,
|
|
6310
6471
|
L: 227,
|
|
6311
6472
|
S: this,
|
|
6312
6473
|
C: (f, a) => f(...a)
|
|
6313
6474
|
});
|
|
6314
|
-
(0,
|
|
6315
|
-
F:
|
|
6475
|
+
(0, import_invariant19.invariant)(this._config, "config not set", {
|
|
6476
|
+
F: __dxlog_file22,
|
|
6316
6477
|
L: 229,
|
|
6317
6478
|
S: this,
|
|
6318
6479
|
A: [
|
|
@@ -6320,8 +6481,8 @@ var ClientServicesHost = class {
|
|
|
6320
6481
|
"'config not set'"
|
|
6321
6482
|
]
|
|
6322
6483
|
});
|
|
6323
|
-
(0,
|
|
6324
|
-
F:
|
|
6484
|
+
(0, import_invariant19.invariant)(this._storage, "storage not set", {
|
|
6485
|
+
F: __dxlog_file22,
|
|
6325
6486
|
L: 230,
|
|
6326
6487
|
S: this,
|
|
6327
6488
|
A: [
|
|
@@ -6329,8 +6490,8 @@ var ClientServicesHost = class {
|
|
|
6329
6490
|
"'storage not set'"
|
|
6330
6491
|
]
|
|
6331
6492
|
});
|
|
6332
|
-
(0,
|
|
6333
|
-
F:
|
|
6493
|
+
(0, import_invariant19.invariant)(this._signalManager, "signal manager not set", {
|
|
6494
|
+
F: __dxlog_file22,
|
|
6334
6495
|
L: 231,
|
|
6335
6496
|
S: this,
|
|
6336
6497
|
A: [
|
|
@@ -6338,8 +6499,8 @@ var ClientServicesHost = class {
|
|
|
6338
6499
|
"'signal manager not set'"
|
|
6339
6500
|
]
|
|
6340
6501
|
});
|
|
6341
|
-
(0,
|
|
6342
|
-
F:
|
|
6502
|
+
(0, import_invariant19.invariant)(this._networkManager, "network manager not set", {
|
|
6503
|
+
F: __dxlog_file22,
|
|
6343
6504
|
L: 232,
|
|
6344
6505
|
S: this,
|
|
6345
6506
|
A: [
|
|
@@ -6348,10 +6509,10 @@ var ClientServicesHost = class {
|
|
|
6348
6509
|
]
|
|
6349
6510
|
});
|
|
6350
6511
|
this._opening = true;
|
|
6351
|
-
(0,
|
|
6512
|
+
(0, import_log19.log)("opening...", {
|
|
6352
6513
|
lockKey: this._resourceLock?.lockKey
|
|
6353
6514
|
}, {
|
|
6354
|
-
F:
|
|
6515
|
+
F: __dxlog_file22,
|
|
6355
6516
|
L: 235,
|
|
6356
6517
|
S: this,
|
|
6357
6518
|
C: (f, a) => f(...a)
|
|
@@ -6402,18 +6563,18 @@ var ClientServicesHost = class {
|
|
|
6402
6563
|
this._open = true;
|
|
6403
6564
|
this._statusUpdate.emit();
|
|
6404
6565
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6405
|
-
(0,
|
|
6566
|
+
(0, import_log19.log)("opened", {
|
|
6406
6567
|
deviceKey
|
|
6407
6568
|
}, {
|
|
6408
|
-
F:
|
|
6569
|
+
F: __dxlog_file22,
|
|
6409
6570
|
L: 314,
|
|
6410
6571
|
S: this,
|
|
6411
6572
|
C: (f, a) => f(...a)
|
|
6412
6573
|
});
|
|
6413
|
-
|
|
6574
|
+
import_log19.log.trace("dxos.client-services.host.open", import_protocols15.trace.end({
|
|
6414
6575
|
id: traceId
|
|
6415
6576
|
}), {
|
|
6416
|
-
F:
|
|
6577
|
+
F: __dxlog_file22,
|
|
6417
6578
|
L: 315,
|
|
6418
6579
|
S: this,
|
|
6419
6580
|
C: (f, a) => f(...a)
|
|
@@ -6424,10 +6585,10 @@ var ClientServicesHost = class {
|
|
|
6424
6585
|
return;
|
|
6425
6586
|
}
|
|
6426
6587
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6427
|
-
(0,
|
|
6588
|
+
(0, import_log19.log)("closing...", {
|
|
6428
6589
|
deviceKey
|
|
6429
6590
|
}, {
|
|
6430
|
-
F:
|
|
6591
|
+
F: __dxlog_file22,
|
|
6431
6592
|
L: 326,
|
|
6432
6593
|
S: this,
|
|
6433
6594
|
C: (f, a) => f(...a)
|
|
@@ -6442,10 +6603,10 @@ var ClientServicesHost = class {
|
|
|
6442
6603
|
await this._level?.close();
|
|
6443
6604
|
this._open = false;
|
|
6444
6605
|
this._statusUpdate.emit();
|
|
6445
|
-
(0,
|
|
6606
|
+
(0, import_log19.log)("closed", {
|
|
6446
6607
|
deviceKey
|
|
6447
6608
|
}, {
|
|
6448
|
-
F:
|
|
6609
|
+
F: __dxlog_file22,
|
|
6449
6610
|
L: 335,
|
|
6450
6611
|
S: this,
|
|
6451
6612
|
C: (f, a) => f(...a)
|
|
@@ -6453,32 +6614,32 @@ var ClientServicesHost = class {
|
|
|
6453
6614
|
}
|
|
6454
6615
|
async reset() {
|
|
6455
6616
|
const traceId = import_keys15.PublicKey.random().toHex();
|
|
6456
|
-
|
|
6617
|
+
import_log19.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.begin({
|
|
6457
6618
|
id: traceId
|
|
6458
6619
|
}), {
|
|
6459
|
-
F:
|
|
6620
|
+
F: __dxlog_file22,
|
|
6460
6621
|
L: 340,
|
|
6461
6622
|
S: this,
|
|
6462
6623
|
C: (f, a) => f(...a)
|
|
6463
6624
|
});
|
|
6464
|
-
|
|
6465
|
-
F:
|
|
6625
|
+
import_log19.log.info("resetting...", void 0, {
|
|
6626
|
+
F: __dxlog_file22,
|
|
6466
6627
|
L: 342,
|
|
6467
6628
|
S: this,
|
|
6468
6629
|
C: (f, a) => f(...a)
|
|
6469
6630
|
});
|
|
6470
6631
|
await this._serviceContext?.close();
|
|
6471
6632
|
await this._storage.reset();
|
|
6472
|
-
|
|
6473
|
-
F:
|
|
6633
|
+
import_log19.log.info("reset", void 0, {
|
|
6634
|
+
F: __dxlog_file22,
|
|
6474
6635
|
L: 345,
|
|
6475
6636
|
S: this,
|
|
6476
6637
|
C: (f, a) => f(...a)
|
|
6477
6638
|
});
|
|
6478
|
-
|
|
6639
|
+
import_log19.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.end({
|
|
6479
6640
|
id: traceId
|
|
6480
6641
|
}), {
|
|
6481
|
-
F:
|
|
6642
|
+
F: __dxlog_file22,
|
|
6482
6643
|
L: 346,
|
|
6483
6644
|
S: this,
|
|
6484
6645
|
C: (f, a) => f(...a)
|
|
@@ -6498,11 +6659,11 @@ _ts_decorate8([
|
|
|
6498
6659
|
import_tracing9.trace.info()
|
|
6499
6660
|
], ClientServicesHost.prototype, "_open", void 0);
|
|
6500
6661
|
_ts_decorate8([
|
|
6501
|
-
|
|
6662
|
+
import_async20.synchronized,
|
|
6502
6663
|
import_tracing9.trace.span()
|
|
6503
6664
|
], ClientServicesHost.prototype, "open", null);
|
|
6504
6665
|
_ts_decorate8([
|
|
6505
|
-
|
|
6666
|
+
import_async20.synchronized,
|
|
6506
6667
|
import_tracing9.trace.span()
|
|
6507
6668
|
], ClientServicesHost.prototype, "close", null);
|
|
6508
6669
|
ClientServicesHost = _ts_decorate8([
|
|
@@ -6538,7 +6699,6 @@ ClientServicesHost = _ts_decorate8([
|
|
|
6538
6699
|
createDiagnostics,
|
|
6539
6700
|
createLevel,
|
|
6540
6701
|
createStorageObjects,
|
|
6541
|
-
findPropertiesObject,
|
|
6542
6702
|
getNetworkPeers,
|
|
6543
6703
|
isLocked,
|
|
6544
6704
|
subscribeToFeedBlocks,
|
|
@@ -6549,4 +6709,4 @@ ClientServicesHost = _ts_decorate8([
|
|
|
6549
6709
|
subscribeToSpaces,
|
|
6550
6710
|
subscribeToSwarmInfo
|
|
6551
6711
|
});
|
|
6552
|
-
//# sourceMappingURL=chunk-
|
|
6712
|
+
//# sourceMappingURL=chunk-XWMOEZYI.cjs.map
|