@dxos/client-services 0.5.1-main.f81ddc4 → 0.5.1-next.260c093
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-OE6XNPWD.mjs → chunk-55TEJXLO.mjs} +908 -1264
- package/dist/lib/browser/chunk-55TEJXLO.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +8 -28
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-PQ6V45LX.cjs → chunk-3ZUQNDPT.cjs} +1037 -1385
- package/dist/lib/node/chunk-3ZUQNDPT.cjs.map +7 -0
- package/dist/lib/node/index.cjs +43 -43
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +14 -34
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +1 -2
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/{invitation-host-extension.d.ts → invitation-extension.d.ts} +31 -17
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +1 -6
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +10 -19
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts +1 -2
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +0 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +3 -6
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts +1 -2
- package/dist/types/src/packlets/testing/invitation-utils.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/invitations/device-invitation-protocol.ts +1 -5
- package/src/packlets/invitations/{invitation-host-extension.ts → invitation-extension.ts} +105 -99
- package/src/packlets/invitations/invitation-protocol.ts +1 -7
- package/src/packlets/invitations/invitations-handler.ts +149 -246
- package/src/packlets/invitations/invitations-manager.ts +3 -42
- package/src/packlets/invitations/space-invitation-protocol.ts +1 -19
- package/src/packlets/services/service-context.ts +3 -5
- package/src/packlets/testing/invitation-utils.ts +3 -23
- package/src/packlets/testing/test-builder.ts +1 -3
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-OE6XNPWD.mjs.map +0 -7
- package/dist/lib/node/chunk-PQ6V45LX.cjs.map +0 -7
- package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts +0 -39
- package/dist/types/src/packlets/invitations/invitation-guest-extenstion.d.ts.map +0 -1
- package/dist/types/src/packlets/invitations/invitation-host-extension.d.ts.map +0 -1
- package/dist/types/src/packlets/invitations/invitation-topology.d.ts +0 -37
- package/dist/types/src/packlets/invitations/invitation-topology.d.ts.map +0 -1
- package/dist/types/src/packlets/invitations/invitations-handler.test.d.ts +0 -2
- package/dist/types/src/packlets/invitations/invitations-handler.test.d.ts.map +0 -1
- package/dist/types/src/packlets/invitations/utils.d.ts +0 -6
- package/dist/types/src/packlets/invitations/utils.d.ts.map +0 -1
- package/src/packlets/invitations/invitation-guest-extenstion.ts +0 -126
- package/src/packlets/invitations/invitation-topology.ts +0 -87
- package/src/packlets/invitations/invitations-handler.test.ts +0 -361
- package/src/packlets/invitations/utils.ts +0 -27
|
@@ -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_3ZUQNDPT_exports = {};
|
|
30
|
+
__export(chunk_3ZUQNDPT_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
33
|
ClientServicesProviderResource: () => ClientServicesProviderResource,
|
|
@@ -66,7 +66,7 @@ __export(chunk_PQ6V45LX_exports, {
|
|
|
66
66
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
67
67
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
68
68
|
});
|
|
69
|
-
module.exports = __toCommonJS(
|
|
69
|
+
module.exports = __toCommonJS(chunk_3ZUQNDPT_exports);
|
|
70
70
|
var import_async = require("@dxos/async");
|
|
71
71
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
72
72
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -128,171 +128,155 @@ var import_network_manager = require("@dxos/network-manager");
|
|
|
128
128
|
var import_protocols4 = require("@dxos/protocols");
|
|
129
129
|
var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
130
130
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
131
|
-
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
132
|
-
var import_util4 = require("@dxos/util");
|
|
133
131
|
var import_async8 = require("@dxos/async");
|
|
134
132
|
var import_context5 = require("@dxos/context");
|
|
133
|
+
var import_crypto2 = require("@dxos/crypto");
|
|
135
134
|
var import_invariant6 = require("@dxos/invariant");
|
|
135
|
+
var import_keys6 = require("@dxos/keys");
|
|
136
136
|
var import_log5 = require("@dxos/log");
|
|
137
137
|
var import_protocols5 = require("@dxos/protocols");
|
|
138
|
-
var import_invitations3 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
139
|
-
var import_teleport = require("@dxos/teleport");
|
|
140
|
-
var import_context6 = require("@dxos/context");
|
|
141
138
|
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
142
|
-
var
|
|
143
|
-
var
|
|
144
|
-
var
|
|
139
|
+
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
140
|
+
var import_teleport = require("@dxos/teleport");
|
|
141
|
+
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
142
|
+
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
143
|
+
var import_credentials7 = require("@dxos/credentials");
|
|
144
|
+
var import_feed_store3 = require("@dxos/feed-store");
|
|
145
145
|
var import_invariant7 = require("@dxos/invariant");
|
|
146
|
-
var import_keys6 = require("@dxos/keys");
|
|
147
146
|
var import_log6 = require("@dxos/log");
|
|
148
147
|
var import_protocols6 = require("@dxos/protocols");
|
|
149
|
-
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
150
|
-
var import_invitations4 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
151
|
-
var import_teleport2 = require("@dxos/teleport");
|
|
152
|
-
var import_invariant8 = require("@dxos/invariant");
|
|
153
|
-
var import_keys7 = require("@dxos/keys");
|
|
154
|
-
var import_log7 = require("@dxos/log");
|
|
155
|
-
var import_invitations5 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
156
|
-
var import_util5 = require("@dxos/util");
|
|
157
|
-
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
158
148
|
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
159
|
-
var import_credentials7 = require("@dxos/credentials");
|
|
160
|
-
var import_feed_store3 = require("@dxos/feed-store");
|
|
161
|
-
var import_invariant9 = require("@dxos/invariant");
|
|
162
|
-
var import_log8 = require("@dxos/log");
|
|
163
|
-
var import_protocols7 = require("@dxos/protocols");
|
|
164
|
-
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
165
149
|
var import_credentials8 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
166
|
-
var
|
|
150
|
+
var import_async9 = require("@dxos/async");
|
|
167
151
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
168
|
-
var
|
|
152
|
+
var import_context6 = require("@dxos/context");
|
|
169
153
|
var import_credentials9 = require("@dxos/credentials");
|
|
170
154
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
171
|
-
var
|
|
172
|
-
var
|
|
173
|
-
var
|
|
174
|
-
var
|
|
155
|
+
var import_invariant8 = require("@dxos/invariant");
|
|
156
|
+
var import_keys7 = require("@dxos/keys");
|
|
157
|
+
var import_log7 = require("@dxos/log");
|
|
158
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
175
159
|
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
176
160
|
var import_debug2 = require("@dxos/debug");
|
|
177
161
|
var import_rpc = require("@dxos/rpc");
|
|
178
162
|
var import_tracing3 = require("@dxos/tracing");
|
|
179
|
-
var
|
|
163
|
+
var import_async10 = require("@dxos/async");
|
|
180
164
|
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
181
|
-
var
|
|
165
|
+
var import_context7 = require("@dxos/context");
|
|
182
166
|
var import_debug3 = require("@dxos/debug");
|
|
183
167
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
184
168
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
185
169
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
186
|
-
var
|
|
187
|
-
var
|
|
188
|
-
var
|
|
189
|
-
var
|
|
190
|
-
var
|
|
170
|
+
var import_invariant9 = require("@dxos/invariant");
|
|
171
|
+
var import_keys8 = require("@dxos/keys");
|
|
172
|
+
var import_log8 = require("@dxos/log");
|
|
173
|
+
var import_protocols7 = require("@dxos/protocols");
|
|
174
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
191
175
|
var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
192
176
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
193
177
|
var import_tracing4 = require("@dxos/tracing");
|
|
194
|
-
var
|
|
195
|
-
var
|
|
178
|
+
var import_util4 = require("@dxos/util");
|
|
179
|
+
var import_async11 = require("@dxos/async");
|
|
196
180
|
var import_credentials11 = require("@dxos/credentials");
|
|
181
|
+
var import_async12 = require("@dxos/async");
|
|
182
|
+
var import_context8 = require("@dxos/context");
|
|
183
|
+
var import_invariant10 = require("@dxos/invariant");
|
|
184
|
+
var import_keys9 = require("@dxos/keys");
|
|
185
|
+
var import_log9 = require("@dxos/log");
|
|
186
|
+
var import_protocols8 = require("@dxos/protocols");
|
|
187
|
+
var import_teleport2 = require("@dxos/teleport");
|
|
188
|
+
var import_util5 = require("@dxos/util");
|
|
197
189
|
var import_async13 = require("@dxos/async");
|
|
198
|
-
var
|
|
199
|
-
var
|
|
190
|
+
var import_context9 = require("@dxos/context");
|
|
191
|
+
var import_credentials12 = require("@dxos/credentials");
|
|
192
|
+
var import_invariant11 = require("@dxos/invariant");
|
|
200
193
|
var import_keys10 = require("@dxos/keys");
|
|
201
|
-
var
|
|
194
|
+
var import_log10 = require("@dxos/log");
|
|
202
195
|
var import_protocols9 = require("@dxos/protocols");
|
|
203
|
-
var
|
|
204
|
-
var import_util7 = require("@dxos/util");
|
|
205
|
-
var import_async14 = require("@dxos/async");
|
|
206
|
-
var import_context11 = require("@dxos/context");
|
|
207
|
-
var import_credentials12 = require("@dxos/credentials");
|
|
208
|
-
var import_invariant13 = require("@dxos/invariant");
|
|
209
|
-
var import_keys11 = require("@dxos/keys");
|
|
210
|
-
var import_log12 = require("@dxos/log");
|
|
211
|
-
var import_protocols10 = require("@dxos/protocols");
|
|
212
|
-
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
196
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
213
197
|
var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
|
|
214
|
-
var
|
|
198
|
+
var import_util6 = require("@dxos/util");
|
|
215
199
|
var import_credentials13 = require("@dxos/credentials");
|
|
216
200
|
var import_debug4 = require("@dxos/debug");
|
|
217
201
|
var import_credentials14 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
218
202
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
219
|
-
var
|
|
203
|
+
var import_async14 = require("@dxos/async");
|
|
220
204
|
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
221
205
|
var import_debug5 = require("@dxos/debug");
|
|
222
|
-
var
|
|
223
|
-
var
|
|
224
|
-
var
|
|
225
|
-
var
|
|
226
|
-
var
|
|
227
|
-
var
|
|
206
|
+
var import_invariant12 = require("@dxos/invariant");
|
|
207
|
+
var import_log11 = require("@dxos/log");
|
|
208
|
+
var import_protocols10 = require("@dxos/protocols");
|
|
209
|
+
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
210
|
+
var import_async15 = require("@dxos/async");
|
|
211
|
+
var import_context10 = require("@dxos/context");
|
|
228
212
|
var import_credentials15 = require("@dxos/credentials");
|
|
229
213
|
var import_debug6 = require("@dxos/debug");
|
|
230
214
|
var import_echo_db = require("@dxos/echo-db");
|
|
231
215
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
232
216
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
233
|
-
var
|
|
217
|
+
var import_invariant13 = require("@dxos/invariant");
|
|
234
218
|
var import_keyring = require("@dxos/keyring");
|
|
235
|
-
var
|
|
236
|
-
var
|
|
237
|
-
var
|
|
238
|
-
var
|
|
219
|
+
var import_keys11 = require("@dxos/keys");
|
|
220
|
+
var import_log12 = require("@dxos/log");
|
|
221
|
+
var import_protocols11 = require("@dxos/protocols");
|
|
222
|
+
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
239
223
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
240
224
|
var import_tracing5 = require("@dxos/tracing");
|
|
241
|
-
var
|
|
225
|
+
var import_util7 = require("@dxos/util");
|
|
242
226
|
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
243
227
|
var import_credentials16 = require("@dxos/credentials");
|
|
244
|
-
var
|
|
245
|
-
var
|
|
246
|
-
var
|
|
228
|
+
var import_invariant14 = require("@dxos/invariant");
|
|
229
|
+
var import_protocols12 = require("@dxos/protocols");
|
|
230
|
+
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
247
231
|
var import_tracing6 = require("@dxos/tracing");
|
|
248
|
-
var
|
|
232
|
+
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
249
233
|
var import_config = require("@dxos/config");
|
|
250
|
-
var
|
|
234
|
+
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
251
235
|
var import_tracing7 = require("@dxos/tracing");
|
|
252
|
-
var
|
|
253
|
-
var
|
|
236
|
+
var import_util8 = require("@dxos/util");
|
|
237
|
+
var import_async16 = require("@dxos/async");
|
|
254
238
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
255
|
-
var
|
|
239
|
+
var import_context11 = require("@dxos/context");
|
|
256
240
|
var import_echo_protocol = require("@dxos/echo-protocol");
|
|
257
241
|
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
258
|
-
var
|
|
259
|
-
var
|
|
260
|
-
var
|
|
242
|
+
var import_invariant15 = require("@dxos/invariant");
|
|
243
|
+
var import_keys12 = require("@dxos/keys");
|
|
244
|
+
var import_log13 = require("@dxos/log");
|
|
261
245
|
var import_messaging = require("@dxos/messaging");
|
|
262
246
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
263
|
-
var
|
|
264
|
-
var
|
|
247
|
+
var import_protocols13 = require("@dxos/protocols");
|
|
248
|
+
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
265
249
|
var import_tracing8 = require("@dxos/tracing");
|
|
266
|
-
var
|
|
250
|
+
var import_util9 = require("@dxos/util");
|
|
267
251
|
var import_websocket_rpc = require("@dxos/websocket-rpc");
|
|
268
|
-
var
|
|
252
|
+
var import_async17 = require("@dxos/async");
|
|
269
253
|
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
270
|
-
var
|
|
271
|
-
var
|
|
272
|
-
var
|
|
254
|
+
var import_invariant16 = require("@dxos/invariant");
|
|
255
|
+
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
256
|
+
var import_invariant17 = require("@dxos/invariant");
|
|
273
257
|
var import_lock_file = require("@dxos/lock-file");
|
|
274
|
-
var
|
|
275
|
-
var
|
|
258
|
+
var import_log14 = require("@dxos/log");
|
|
259
|
+
var import_async18 = require("@dxos/async");
|
|
276
260
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
277
|
-
var
|
|
278
|
-
var
|
|
279
|
-
var
|
|
280
|
-
var
|
|
261
|
+
var import_keys13 = require("@dxos/keys");
|
|
262
|
+
var import_log15 = require("@dxos/log");
|
|
263
|
+
var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
|
|
264
|
+
var import_util10 = require("@dxos/util");
|
|
281
265
|
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
282
|
-
var
|
|
266
|
+
var import_protocols14 = require("@dxos/protocols");
|
|
283
267
|
var import_config2 = require("@dxos/protocols/proto/dxos/config");
|
|
284
268
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
285
269
|
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
286
270
|
var import_config3 = require("@dxos/protocols/proto/dxos/config");
|
|
287
|
-
var
|
|
271
|
+
var import_util11 = require("@dxos/util");
|
|
288
272
|
var import_node_path = __toESM(require("node:path"));
|
|
289
|
-
var
|
|
273
|
+
var import_keys14 = require("@dxos/keys");
|
|
290
274
|
var import_kv_store = require("@dxos/kv-store");
|
|
291
275
|
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
292
|
-
var
|
|
293
|
-
var
|
|
294
|
-
var
|
|
295
|
-
var
|
|
276
|
+
var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
|
|
277
|
+
var import_util12 = require("@dxos/util");
|
|
278
|
+
var import_keys15 = require("@dxos/keys");
|
|
279
|
+
var import_util13 = require("@dxos/util");
|
|
296
280
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
297
281
|
return new import_codec_protobuf.Stream(({ next }) => {
|
|
298
282
|
const subscriptions = new import_async.EventSubscriptions();
|
|
@@ -1409,16 +1393,13 @@ var DeviceInvitationProtocol = class {
|
|
|
1409
1393
|
kind: import_services2.Invitation.Kind.DEVICE
|
|
1410
1394
|
};
|
|
1411
1395
|
}
|
|
1412
|
-
async delegate() {
|
|
1413
|
-
throw new Error("delegation not supported");
|
|
1414
|
-
}
|
|
1415
|
-
async cancelDelegation() {
|
|
1396
|
+
async delegate(invitation) {
|
|
1416
1397
|
throw new Error("delegation not supported");
|
|
1417
1398
|
}
|
|
1418
1399
|
async admit(_, request) {
|
|
1419
1400
|
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1420
1401
|
F: __dxlog_file5,
|
|
1421
|
-
L:
|
|
1402
|
+
L: 42,
|
|
1422
1403
|
S: this,
|
|
1423
1404
|
A: [
|
|
1424
1405
|
"request.device",
|
|
@@ -1464,7 +1445,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1464
1445
|
async accept(response, request) {
|
|
1465
1446
|
(0, import_invariant4.invariant)(response.device, void 0, {
|
|
1466
1447
|
F: __dxlog_file5,
|
|
1467
|
-
L:
|
|
1448
|
+
L: 87,
|
|
1468
1449
|
S: this,
|
|
1469
1450
|
A: [
|
|
1470
1451
|
"response.device",
|
|
@@ -1474,7 +1455,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1474
1455
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1475
1456
|
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1476
1457
|
F: __dxlog_file5,
|
|
1477
|
-
L:
|
|
1458
|
+
L: 90,
|
|
1478
1459
|
S: this,
|
|
1479
1460
|
A: [
|
|
1480
1461
|
"request.device",
|
|
@@ -1497,25 +1478,11 @@ var DeviceInvitationProtocol = class {
|
|
|
1497
1478
|
};
|
|
1498
1479
|
}
|
|
1499
1480
|
};
|
|
1500
|
-
var
|
|
1501
|
-
return Object.entries(import_services4.Invitation.State).find(([key, val]) => val === state)?.[0] ?? "unknown";
|
|
1502
|
-
};
|
|
1503
|
-
var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
|
|
1504
|
-
let guard;
|
|
1505
|
-
return (0, import_context6.cancelWithContext)(ctx, (async () => {
|
|
1506
|
-
guard = await mutex.acquire();
|
|
1507
|
-
if (ctx.disposed) {
|
|
1508
|
-
guard.release();
|
|
1509
|
-
guard = void 0;
|
|
1510
|
-
throw new import_context6.ContextDisposedError();
|
|
1511
|
-
}
|
|
1512
|
-
return guard;
|
|
1513
|
-
})());
|
|
1514
|
-
};
|
|
1515
|
-
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
|
|
1481
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
|
|
1516
1482
|
var OPTIONS_TIMEOUT = 1e4;
|
|
1517
|
-
var
|
|
1518
|
-
|
|
1483
|
+
var MAX_OTP_ATTEMPTS = 3;
|
|
1484
|
+
var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
1485
|
+
constructor(_callbacks) {
|
|
1519
1486
|
super({
|
|
1520
1487
|
requested: {
|
|
1521
1488
|
InvitationHostService: import_protocols5.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
@@ -1524,22 +1491,25 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1524
1491
|
InvitationHostService: import_protocols5.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
1525
1492
|
}
|
|
1526
1493
|
});
|
|
1527
|
-
this._invitationFlowMutex = _invitationFlowMutex;
|
|
1528
1494
|
this._callbacks = _callbacks;
|
|
1529
1495
|
this._ctx = new import_context5.Context();
|
|
1530
1496
|
this._remoteOptionsTrigger = new import_async8.Trigger();
|
|
1531
|
-
this.
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1497
|
+
this._challenge = void 0;
|
|
1498
|
+
this.invitation = void 0;
|
|
1499
|
+
this.guestProfile = void 0;
|
|
1500
|
+
this.authenticationPassed = false;
|
|
1501
|
+
this.authenticationRetry = 0;
|
|
1502
|
+
this.completedTrigger = new import_async8.Trigger();
|
|
1535
1503
|
}
|
|
1536
1504
|
async getHandlers() {
|
|
1537
1505
|
return {
|
|
1506
|
+
// TODO(dmaretskyi): For now this is just forwarding the data to callbacks since we don't have session-specific logic.
|
|
1507
|
+
// Perhaps in the future we will have more complex logic here.
|
|
1538
1508
|
InvitationHostService: {
|
|
1539
1509
|
options: async (options) => {
|
|
1540
1510
|
(0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1541
1511
|
F: __dxlog_file6,
|
|
1542
|
-
L:
|
|
1512
|
+
L: 90,
|
|
1543
1513
|
S: this,
|
|
1544
1514
|
A: [
|
|
1545
1515
|
"!this._remoteOptions",
|
|
@@ -1549,280 +1519,146 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1549
1519
|
this._remoteOptions = options;
|
|
1550
1520
|
this._remoteOptionsTrigger.wake();
|
|
1551
1521
|
},
|
|
1552
|
-
introduce: () => {
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1522
|
+
introduce: async (request) => {
|
|
1523
|
+
const { profile, invitationId } = request;
|
|
1524
|
+
const traceId = import_keys6.PublicKey.random().toHex();
|
|
1525
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols5.trace.begin({
|
|
1526
|
+
id: traceId
|
|
1527
|
+
}), {
|
|
1528
|
+
F: __dxlog_file6,
|
|
1529
|
+
L: 99,
|
|
1530
|
+
S: this,
|
|
1531
|
+
C: (f, a) => f(...a)
|
|
1532
|
+
});
|
|
1533
|
+
const invitation = await this._callbacks.resolveInvitation(request);
|
|
1534
|
+
if (!invitation) {
|
|
1535
|
+
import_log5.log.warn("invitation not found", {
|
|
1536
|
+
invitationId
|
|
1537
|
+
}, {
|
|
1538
|
+
F: __dxlog_file6,
|
|
1539
|
+
L: 103,
|
|
1540
|
+
S: this,
|
|
1541
|
+
C: (f, a) => f(...a)
|
|
1542
|
+
});
|
|
1543
|
+
this._callbacks.onError(new Error("Invitation not found."));
|
|
1544
|
+
return {
|
|
1545
|
+
authMethod: import_services4.Invitation.AuthMethod.NONE
|
|
1546
|
+
};
|
|
1547
|
+
}
|
|
1548
|
+
this.invitation = invitation;
|
|
1549
|
+
(0, import_log5.log)("guest introduced itself", {
|
|
1550
|
+
guestProfile: profile
|
|
1551
|
+
}, {
|
|
1552
|
+
F: __dxlog_file6,
|
|
1553
|
+
L: 112,
|
|
1554
|
+
S: this,
|
|
1555
|
+
C: (f, a) => f(...a)
|
|
1556
|
+
});
|
|
1557
|
+
this.guestProfile = profile;
|
|
1558
|
+
this._callbacks.onStateUpdate({
|
|
1559
|
+
...this.invitation,
|
|
1560
|
+
state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1561
|
+
});
|
|
1562
|
+
this._challenge = this.invitation.authMethod === import_services4.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto2.randomBytes)(32) : void 0;
|
|
1563
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols5.trace.end({
|
|
1564
|
+
id: traceId
|
|
1565
|
+
}), {
|
|
1566
|
+
F: __dxlog_file6,
|
|
1567
|
+
L: 122,
|
|
1568
|
+
S: this,
|
|
1569
|
+
C: (f, a) => f(...a)
|
|
1570
|
+
});
|
|
1571
|
+
return {
|
|
1572
|
+
authMethod: this.invitation.authMethod,
|
|
1573
|
+
challenge: this._challenge
|
|
1574
|
+
};
|
|
1557
1575
|
},
|
|
1558
|
-
|
|
1559
|
-
throw new Error("Method not allowed.");
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
};
|
|
1563
|
-
}
|
|
1564
|
-
async onOpen(context) {
|
|
1565
|
-
await super.onOpen(context);
|
|
1566
|
-
try {
|
|
1567
|
-
(0, import_log5.log)("guest acquire lock", void 0, {
|
|
1568
|
-
F: __dxlog_file6,
|
|
1569
|
-
L: 84,
|
|
1570
|
-
S: this,
|
|
1571
|
-
C: (f, a) => f(...a)
|
|
1572
|
-
});
|
|
1573
|
-
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
1574
|
-
(0, import_log5.log)("guest lock acquired", void 0, {
|
|
1575
|
-
F: __dxlog_file6,
|
|
1576
|
-
L: 86,
|
|
1577
|
-
S: this,
|
|
1578
|
-
C: (f, a) => f(...a)
|
|
1579
|
-
});
|
|
1580
|
-
await (0, import_context5.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
|
|
1581
|
-
role: import_invitations3.Options.Role.GUEST
|
|
1582
|
-
}));
|
|
1583
|
-
(0, import_log5.log)("options sent", void 0, {
|
|
1584
|
-
F: __dxlog_file6,
|
|
1585
|
-
L: 88,
|
|
1586
|
-
S: this,
|
|
1587
|
-
C: (f, a) => f(...a)
|
|
1588
|
-
});
|
|
1589
|
-
await (0, import_context5.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1590
|
-
timeout: OPTIONS_TIMEOUT
|
|
1591
|
-
}));
|
|
1592
|
-
(0, import_log5.log)("options received", void 0, {
|
|
1593
|
-
F: __dxlog_file6,
|
|
1594
|
-
L: 90,
|
|
1595
|
-
S: this,
|
|
1596
|
-
C: (f, a) => f(...a)
|
|
1597
|
-
});
|
|
1598
|
-
if (this._remoteOptions?.role !== import_invitations3.Options.Role.HOST) {
|
|
1599
|
-
throw new import_protocols5.InvalidInvitationExtensionRoleError(void 0, {
|
|
1600
|
-
expected: import_invitations3.Options.Role.HOST,
|
|
1601
|
-
remoteOptions: this._remoteOptions,
|
|
1602
|
-
remotePeerId: context.remotePeerId
|
|
1603
|
-
});
|
|
1604
|
-
}
|
|
1605
|
-
this._callbacks.onOpen(this._ctx, context);
|
|
1606
|
-
} catch (err) {
|
|
1607
|
-
if (this._invitationFlowLock != null) {
|
|
1608
|
-
this._callbacks.onError(err);
|
|
1609
|
-
}
|
|
1610
|
-
if (!this._ctx.disposed) {
|
|
1611
|
-
context.close(err);
|
|
1612
|
-
}
|
|
1613
|
-
}
|
|
1614
|
-
}
|
|
1615
|
-
async onClose() {
|
|
1616
|
-
await this._destroy();
|
|
1617
|
-
}
|
|
1618
|
-
async onAbort() {
|
|
1619
|
-
await this._destroy();
|
|
1620
|
-
}
|
|
1621
|
-
async _destroy() {
|
|
1622
|
-
await this._ctx.dispose();
|
|
1623
|
-
if (this._invitationFlowLock != null) {
|
|
1624
|
-
this._invitationFlowLock.release();
|
|
1625
|
-
this._invitationFlowLock = null;
|
|
1626
|
-
(0, import_log5.log)("invitation flow lock released", void 0, {
|
|
1627
|
-
F: __dxlog_file6,
|
|
1628
|
-
L: 123,
|
|
1629
|
-
S: this,
|
|
1630
|
-
C: (f, a) => f(...a)
|
|
1631
|
-
});
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
};
|
|
1635
|
-
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
|
|
1636
|
-
var OPTIONS_TIMEOUT2 = 1e4;
|
|
1637
|
-
var MAX_OTP_ATTEMPTS = 3;
|
|
1638
|
-
var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
1639
|
-
constructor(_invitationFlowMutex, _callbacks) {
|
|
1640
|
-
super({
|
|
1641
|
-
requested: {
|
|
1642
|
-
InvitationHostService: import_protocols6.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
1643
|
-
},
|
|
1644
|
-
exposed: {
|
|
1645
|
-
InvitationHostService: import_protocols6.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
1646
|
-
}
|
|
1647
|
-
});
|
|
1648
|
-
this._invitationFlowMutex = _invitationFlowMutex;
|
|
1649
|
-
this._callbacks = _callbacks;
|
|
1650
|
-
this._ctx = new import_context7.Context();
|
|
1651
|
-
this._remoteOptionsTrigger = new import_async9.Trigger();
|
|
1652
|
-
this._challenge = void 0;
|
|
1653
|
-
this.guestProfile = void 0;
|
|
1654
|
-
this.authenticationPassed = false;
|
|
1655
|
-
this.authenticationRetry = 0;
|
|
1656
|
-
this.completedTrigger = new import_async9.Trigger();
|
|
1657
|
-
this._invitationFlowLock = null;
|
|
1658
|
-
}
|
|
1659
|
-
hasFlowLock() {
|
|
1660
|
-
return this._invitationFlowLock != null;
|
|
1661
|
-
}
|
|
1662
|
-
async getHandlers() {
|
|
1663
|
-
return {
|
|
1664
|
-
// TODO(dmaretskyi): For now this is just forwarding the data to callbacks since we don't have session-specific logic.
|
|
1665
|
-
// Perhaps in the future we will have more complex logic here.
|
|
1666
|
-
InvitationHostService: {
|
|
1667
|
-
options: async (options) => {
|
|
1668
|
-
(0, import_invariant7.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1669
|
-
F: __dxlog_file7,
|
|
1670
|
-
L: 101,
|
|
1671
|
-
S: this,
|
|
1672
|
-
A: [
|
|
1673
|
-
"!this._remoteOptions",
|
|
1674
|
-
"'Remote options already set.'"
|
|
1675
|
-
]
|
|
1676
|
-
});
|
|
1677
|
-
this._remoteOptions = options;
|
|
1678
|
-
this._remoteOptionsTrigger.wake();
|
|
1679
|
-
},
|
|
1680
|
-
introduce: async (request) => {
|
|
1681
|
-
const { profile, invitationId } = request;
|
|
1576
|
+
authenticate: async ({ authCode: code, signedChallenge }) => {
|
|
1682
1577
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
1683
|
-
|
|
1578
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols5.trace.begin({
|
|
1684
1579
|
id: traceId
|
|
1685
1580
|
}), {
|
|
1686
|
-
F:
|
|
1687
|
-
L:
|
|
1581
|
+
F: __dxlog_file6,
|
|
1582
|
+
L: 131,
|
|
1688
1583
|
S: this,
|
|
1689
1584
|
C: (f, a) => f(...a)
|
|
1690
1585
|
});
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
if (invitationId !== invitation?.invitationId) {
|
|
1694
|
-
import_log6.log.warn("incorrect invitationId", {
|
|
1695
|
-
expected: invitation.invitationId,
|
|
1696
|
-
actual: invitationId
|
|
1697
|
-
}, {
|
|
1698
|
-
F: __dxlog_file7,
|
|
1699
|
-
L: 116,
|
|
1700
|
-
S: this,
|
|
1701
|
-
C: (f, a) => f(...a)
|
|
1702
|
-
});
|
|
1703
|
-
this._callbacks.onError(new Error("Incorrect invitationId."));
|
|
1704
|
-
(0, import_async9.scheduleTask)(this._ctx, () => this.close());
|
|
1705
|
-
return {
|
|
1706
|
-
authMethod: import_services5.Invitation.AuthMethod.NONE
|
|
1707
|
-
};
|
|
1708
|
-
}
|
|
1709
|
-
(0, import_log6.log)("guest introduced themselves", {
|
|
1710
|
-
guestProfile: profile
|
|
1586
|
+
(0, import_log5.log)("received authentication request", {
|
|
1587
|
+
authCode: code
|
|
1711
1588
|
}, {
|
|
1712
|
-
F:
|
|
1713
|
-
L: 125,
|
|
1714
|
-
S: this,
|
|
1715
|
-
C: (f, a) => f(...a)
|
|
1716
|
-
});
|
|
1717
|
-
this.guestProfile = profile;
|
|
1718
|
-
this._callbacks.onStateUpdate(import_services5.Invitation.State.READY_FOR_AUTHENTICATION);
|
|
1719
|
-
this._challenge = invitation.authMethod === import_services5.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto2.randomBytes)(32) : void 0;
|
|
1720
|
-
import_log6.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols6.trace.end({
|
|
1721
|
-
id: traceId
|
|
1722
|
-
}), {
|
|
1723
|
-
F: __dxlog_file7,
|
|
1589
|
+
F: __dxlog_file6,
|
|
1724
1590
|
L: 132,
|
|
1725
1591
|
S: this,
|
|
1726
1592
|
C: (f, a) => f(...a)
|
|
1727
1593
|
});
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
},
|
|
1733
|
-
authenticate: async ({ authCode: code, signedChallenge }) => {
|
|
1734
|
-
const traceId = import_keys6.PublicKey.random().toHex();
|
|
1735
|
-
import_log6.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols6.trace.begin({
|
|
1736
|
-
id: traceId
|
|
1737
|
-
}), {
|
|
1738
|
-
F: __dxlog_file7,
|
|
1739
|
-
L: 141,
|
|
1740
|
-
S: this,
|
|
1741
|
-
C: (f, a) => f(...a)
|
|
1742
|
-
});
|
|
1743
|
-
const invitation = this._requireActiveInvitation();
|
|
1744
|
-
(0, import_log6.log)("received authentication request", {
|
|
1745
|
-
authCode: code
|
|
1746
|
-
}, {
|
|
1747
|
-
F: __dxlog_file7,
|
|
1748
|
-
L: 144,
|
|
1594
|
+
let status = import_invitations2.AuthenticationResponse.Status.OK;
|
|
1595
|
+
(0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
|
|
1596
|
+
F: __dxlog_file6,
|
|
1597
|
+
L: 135,
|
|
1749
1598
|
S: this,
|
|
1750
|
-
|
|
1599
|
+
A: [
|
|
1600
|
+
"this.invitation",
|
|
1601
|
+
"'Invitation is not set.'"
|
|
1602
|
+
]
|
|
1751
1603
|
});
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
this._callbacks.onStateUpdate(import_services5.Invitation.State.AUTHENTICATING);
|
|
1758
|
-
switch (invitation.authMethod) {
|
|
1759
|
-
case import_services5.Invitation.AuthMethod.NONE: {
|
|
1760
|
-
(0, import_log6.log)("authentication not required", void 0, {
|
|
1761
|
-
F: __dxlog_file7,
|
|
1762
|
-
L: 152,
|
|
1604
|
+
switch (this.invitation.authMethod) {
|
|
1605
|
+
case import_services4.Invitation.AuthMethod.NONE: {
|
|
1606
|
+
(0, import_log5.log)("authentication not required", void 0, {
|
|
1607
|
+
F: __dxlog_file6,
|
|
1608
|
+
L: 138,
|
|
1763
1609
|
S: this,
|
|
1764
1610
|
C: (f, a) => f(...a)
|
|
1765
1611
|
});
|
|
1766
1612
|
return {
|
|
1767
|
-
status:
|
|
1613
|
+
status: import_invitations2.AuthenticationResponse.Status.OK
|
|
1768
1614
|
};
|
|
1769
1615
|
}
|
|
1770
|
-
case
|
|
1771
|
-
if (invitation.authCode) {
|
|
1616
|
+
case import_services4.Invitation.AuthMethod.SHARED_SECRET: {
|
|
1617
|
+
if (this.invitation.authCode) {
|
|
1772
1618
|
if (this.authenticationRetry++ > MAX_OTP_ATTEMPTS) {
|
|
1773
|
-
status =
|
|
1774
|
-
} else if (code !== invitation.authCode) {
|
|
1775
|
-
status =
|
|
1619
|
+
status = import_invitations2.AuthenticationResponse.Status.INVALID_OPT_ATTEMPTS;
|
|
1620
|
+
} else if (code !== this.invitation.authCode) {
|
|
1621
|
+
status = import_invitations2.AuthenticationResponse.Status.INVALID_OTP;
|
|
1776
1622
|
} else {
|
|
1777
1623
|
this.authenticationPassed = true;
|
|
1778
1624
|
}
|
|
1779
1625
|
}
|
|
1780
1626
|
break;
|
|
1781
1627
|
}
|
|
1782
|
-
case
|
|
1783
|
-
if (!invitation.guestKeypair) {
|
|
1784
|
-
status =
|
|
1628
|
+
case import_services4.Invitation.AuthMethod.KNOWN_PUBLIC_KEY: {
|
|
1629
|
+
if (!this.invitation.guestKeypair) {
|
|
1630
|
+
status = import_invitations2.AuthenticationResponse.Status.INTERNAL_ERROR;
|
|
1785
1631
|
break;
|
|
1786
1632
|
}
|
|
1787
|
-
const isSignatureValid = this._challenge && (0, import_crypto2.verify)(this._challenge, Buffer.from(signedChallenge ?? []), invitation.guestKeypair.publicKey.asBuffer());
|
|
1633
|
+
const isSignatureValid = this._challenge && (0, import_crypto2.verify)(this._challenge, Buffer.from(signedChallenge ?? []), this.invitation.guestKeypair.publicKey.asBuffer());
|
|
1788
1634
|
if (isSignatureValid) {
|
|
1789
1635
|
this.authenticationPassed = true;
|
|
1790
1636
|
} else {
|
|
1791
|
-
status =
|
|
1637
|
+
status = import_invitations2.AuthenticationResponse.Status.INVALID_SIGNATURE;
|
|
1792
1638
|
}
|
|
1793
1639
|
break;
|
|
1794
1640
|
}
|
|
1795
1641
|
default: {
|
|
1796
|
-
|
|
1797
|
-
authMethod: invitation.authMethod
|
|
1642
|
+
import_log5.log.error("invalid authentication method", {
|
|
1643
|
+
authMethod: this.invitation.authMethod
|
|
1798
1644
|
}, {
|
|
1799
|
-
F:
|
|
1800
|
-
L:
|
|
1645
|
+
F: __dxlog_file6,
|
|
1646
|
+
L: 176,
|
|
1801
1647
|
S: this,
|
|
1802
1648
|
C: (f, a) => f(...a)
|
|
1803
1649
|
});
|
|
1804
|
-
status =
|
|
1650
|
+
status = import_invitations2.AuthenticationResponse.Status.INTERNAL_ERROR;
|
|
1805
1651
|
break;
|
|
1806
1652
|
}
|
|
1807
1653
|
}
|
|
1808
|
-
|
|
1809
|
-
import_invitations4.AuthenticationResponse.Status.OK,
|
|
1810
|
-
import_invitations4.AuthenticationResponse.Status.INVALID_OTP
|
|
1811
|
-
].includes(status)) {
|
|
1812
|
-
this._callbacks.onError(new Error(`Authentication failed, with status=${status}`));
|
|
1813
|
-
(0, import_async9.scheduleTask)(this._ctx, () => this.close());
|
|
1814
|
-
return {
|
|
1815
|
-
status
|
|
1816
|
-
};
|
|
1817
|
-
}
|
|
1818
|
-
import_log6.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols6.trace.end({
|
|
1654
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols5.trace.end({
|
|
1819
1655
|
id: traceId,
|
|
1820
1656
|
data: {
|
|
1821
1657
|
status
|
|
1822
1658
|
}
|
|
1823
1659
|
}), {
|
|
1824
|
-
F:
|
|
1825
|
-
L:
|
|
1660
|
+
F: __dxlog_file6,
|
|
1661
|
+
L: 182,
|
|
1826
1662
|
S: this,
|
|
1827
1663
|
C: (f, a) => f(...a)
|
|
1828
1664
|
});
|
|
@@ -1832,28 +1668,33 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
1832
1668
|
},
|
|
1833
1669
|
admit: async (request) => {
|
|
1834
1670
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
1835
|
-
|
|
1671
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols5.trace.begin({
|
|
1836
1672
|
id: traceId
|
|
1837
1673
|
}), {
|
|
1838
|
-
F:
|
|
1839
|
-
L:
|
|
1674
|
+
F: __dxlog_file6,
|
|
1675
|
+
L: 188,
|
|
1840
1676
|
S: this,
|
|
1841
1677
|
C: (f, a) => f(...a)
|
|
1842
1678
|
});
|
|
1843
|
-
const invitation = this._requireActiveInvitation();
|
|
1844
1679
|
try {
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1680
|
+
(0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
|
|
1681
|
+
F: __dxlog_file6,
|
|
1682
|
+
L: 191,
|
|
1683
|
+
S: this,
|
|
1684
|
+
A: [
|
|
1685
|
+
"this.invitation",
|
|
1686
|
+
"'Invitation is not set.'"
|
|
1687
|
+
]
|
|
1688
|
+
});
|
|
1689
|
+
if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
|
|
1690
|
+
throw new Error("Not authenticated");
|
|
1850
1691
|
}
|
|
1851
1692
|
const response = await this._callbacks.admit(request);
|
|
1852
|
-
|
|
1693
|
+
import_log5.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols5.trace.end({
|
|
1853
1694
|
id: traceId
|
|
1854
1695
|
}), {
|
|
1855
|
-
F:
|
|
1856
|
-
L:
|
|
1696
|
+
F: __dxlog_file6,
|
|
1697
|
+
L: 199,
|
|
1857
1698
|
S: this,
|
|
1858
1699
|
C: (f, a) => f(...a)
|
|
1859
1700
|
});
|
|
@@ -1869,195 +1710,147 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
1869
1710
|
async onOpen(context) {
|
|
1870
1711
|
await super.onOpen(context);
|
|
1871
1712
|
try {
|
|
1872
|
-
(0, import_log6.log)("host acquire lock", void 0, {
|
|
1873
|
-
F: __dxlog_file7,
|
|
1874
|
-
L: 237,
|
|
1875
|
-
S: this,
|
|
1876
|
-
C: (f, a) => f(...a)
|
|
1877
|
-
});
|
|
1878
|
-
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
1879
|
-
(0, import_log6.log)("host lock acquired", void 0, {
|
|
1880
|
-
F: __dxlog_file7,
|
|
1881
|
-
L: 239,
|
|
1882
|
-
S: this,
|
|
1883
|
-
C: (f, a) => f(...a)
|
|
1884
|
-
});
|
|
1885
|
-
const lastState = this._requireActiveInvitation().state;
|
|
1886
|
-
this._callbacks.onStateUpdate(import_services5.Invitation.State.CONNECTING);
|
|
1887
1713
|
await this.rpc.InvitationHostService.options({
|
|
1888
|
-
role:
|
|
1714
|
+
role: import_invitations2.Options.Role.HOST
|
|
1889
1715
|
});
|
|
1890
|
-
(0,
|
|
1891
|
-
|
|
1892
|
-
L: 243,
|
|
1893
|
-
S: this,
|
|
1894
|
-
C: (f, a) => f(...a)
|
|
1895
|
-
});
|
|
1896
|
-
await (0, import_context7.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1897
|
-
timeout: OPTIONS_TIMEOUT2
|
|
1716
|
+
await (0, import_context5.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1717
|
+
timeout: OPTIONS_TIMEOUT
|
|
1898
1718
|
}));
|
|
1899
|
-
(
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
C: (f, a) => f(...a)
|
|
1904
|
-
});
|
|
1905
|
-
if (this._remoteOptions?.role !== import_invitations4.Options.Role.GUEST) {
|
|
1906
|
-
this._callbacks.onStateUpdate(lastState);
|
|
1907
|
-
throw new import_protocols6.InvalidInvitationExtensionRoleError(void 0, {
|
|
1908
|
-
expected: import_invitations4.Options.Role.GUEST,
|
|
1909
|
-
remoteOptions: this._remoteOptions,
|
|
1910
|
-
remotePeerId: context.remotePeerId
|
|
1719
|
+
if (this._remoteOptions?.role !== import_invitations2.Options.Role.GUEST) {
|
|
1720
|
+
throw new import_protocols5.InvalidInvitationExtensionRoleError(void 0, {
|
|
1721
|
+
expected: import_invitations2.Options.Role.GUEST,
|
|
1722
|
+
remoteOptions: this._remoteOptions
|
|
1911
1723
|
});
|
|
1912
1724
|
}
|
|
1913
|
-
this._callbacks.
|
|
1914
|
-
this._callbacks.onOpen(this._ctx, context);
|
|
1725
|
+
this._callbacks.onOpen();
|
|
1915
1726
|
} catch (err) {
|
|
1916
|
-
|
|
1917
|
-
this._callbacks.onError(err);
|
|
1918
|
-
}
|
|
1919
|
-
if (!this._ctx.disposed) {
|
|
1920
|
-
context.close(err);
|
|
1921
|
-
}
|
|
1922
|
-
}
|
|
1923
|
-
}
|
|
1924
|
-
_requireActiveInvitation() {
|
|
1925
|
-
const invitation = this._callbacks.activeInvitation;
|
|
1926
|
-
if (invitation == null) {
|
|
1927
|
-
(0, import_async9.scheduleTask)(this._ctx, () => this.close());
|
|
1928
|
-
throw new Error("Active invitation not found");
|
|
1929
|
-
}
|
|
1930
|
-
return invitation;
|
|
1931
|
-
}
|
|
1932
|
-
_assertInvitationState(stateOrMany) {
|
|
1933
|
-
const invitation = this._requireActiveInvitation();
|
|
1934
|
-
const validStates = Array.isArray(stateOrMany) ? stateOrMany : [
|
|
1935
|
-
stateOrMany
|
|
1936
|
-
];
|
|
1937
|
-
if (!validStates.includes(invitation.state)) {
|
|
1938
|
-
(0, import_async9.scheduleTask)(this._ctx, () => this.close());
|
|
1939
|
-
throw new import_invariant7.InvariantViolation(`Expected ${stateToString(invitation.state)} to be one of [${validStates.map(stateToString).join(", ")}]`);
|
|
1727
|
+
this._callbacks.onError(err);
|
|
1940
1728
|
}
|
|
1941
1729
|
}
|
|
1942
1730
|
async onClose() {
|
|
1943
|
-
await this._destroy();
|
|
1944
|
-
}
|
|
1945
|
-
async onAbort() {
|
|
1946
|
-
await this._destroy();
|
|
1947
|
-
}
|
|
1948
|
-
async _destroy() {
|
|
1949
1731
|
await this._ctx.dispose();
|
|
1950
|
-
if (this._invitationFlowLock != null) {
|
|
1951
|
-
this._invitationFlowLock?.release();
|
|
1952
|
-
this._invitationFlowLock = null;
|
|
1953
|
-
(0, import_log6.log)("invitation flow lock released", void 0, {
|
|
1954
|
-
F: __dxlog_file7,
|
|
1955
|
-
L: 300,
|
|
1956
|
-
S: this,
|
|
1957
|
-
C: (f, a) => f(...a)
|
|
1958
|
-
});
|
|
1959
|
-
}
|
|
1960
1732
|
}
|
|
1961
1733
|
};
|
|
1962
|
-
var
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
F: __dxlog_file8,
|
|
1972
|
-
L: 42,
|
|
1973
|
-
S: this,
|
|
1974
|
-
A: [
|
|
1975
|
-
"!this._controller",
|
|
1976
|
-
"'Already initialized.'"
|
|
1977
|
-
]
|
|
1734
|
+
var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
1735
|
+
constructor(_callbacks) {
|
|
1736
|
+
super({
|
|
1737
|
+
requested: {
|
|
1738
|
+
InvitationHostService: import_protocols5.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
1739
|
+
},
|
|
1740
|
+
exposed: {
|
|
1741
|
+
InvitationHostService: import_protocols5.schema.getService("dxos.halo.invitations.InvitationHostService")
|
|
1742
|
+
}
|
|
1978
1743
|
});
|
|
1979
|
-
this.
|
|
1744
|
+
this._callbacks = _callbacks;
|
|
1745
|
+
this._ctx = new import_context5.Context();
|
|
1746
|
+
this._remoteOptionsTrigger = new import_async8.Trigger();
|
|
1980
1747
|
}
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
1748
|
+
async getHandlers() {
|
|
1749
|
+
return {
|
|
1750
|
+
InvitationHostService: {
|
|
1751
|
+
options: async (options) => {
|
|
1752
|
+
(0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1753
|
+
F: __dxlog_file6,
|
|
1754
|
+
L: 266,
|
|
1755
|
+
S: this,
|
|
1756
|
+
A: [
|
|
1757
|
+
"!this._remoteOptions",
|
|
1758
|
+
"'Remote options already set.'"
|
|
1759
|
+
]
|
|
1760
|
+
});
|
|
1761
|
+
this._remoteOptions = options;
|
|
1762
|
+
this._remoteOptionsTrigger.wake();
|
|
1763
|
+
},
|
|
1764
|
+
introduce: () => {
|
|
1765
|
+
throw new Error("Method not allowed.");
|
|
1766
|
+
},
|
|
1767
|
+
authenticate: () => {
|
|
1768
|
+
throw new Error("Method not allowed.");
|
|
1769
|
+
},
|
|
1770
|
+
admit: () => {
|
|
1771
|
+
throw new Error("Method not allowed.");
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
};
|
|
1775
|
+
}
|
|
1776
|
+
async onOpen(context) {
|
|
1777
|
+
await super.onOpen(context);
|
|
1778
|
+
try {
|
|
1779
|
+
(0, import_log5.log)("begin options", void 0, {
|
|
1780
|
+
F: __dxlog_file6,
|
|
1781
|
+
L: 287,
|
|
1782
|
+
S: this,
|
|
1783
|
+
C: (f, a) => f(...a)
|
|
1784
|
+
});
|
|
1785
|
+
await (0, import_context5.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
|
|
1786
|
+
role: import_invitations2.Options.Role.GUEST
|
|
1787
|
+
}));
|
|
1788
|
+
await (0, import_context5.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1789
|
+
timeout: OPTIONS_TIMEOUT
|
|
1790
|
+
}));
|
|
1791
|
+
(0, import_log5.log)("end options", void 0, {
|
|
1792
|
+
F: __dxlog_file6,
|
|
1793
|
+
L: 290,
|
|
2008
1794
|
S: this,
|
|
2009
1795
|
C: (f, a) => f(...a)
|
|
2010
1796
|
});
|
|
2011
|
-
this.
|
|
2012
|
-
|
|
1797
|
+
if (this._remoteOptions?.role !== import_invitations2.Options.Role.HOST) {
|
|
1798
|
+
throw new import_protocols5.InvalidInvitationExtensionRoleError(void 0, {
|
|
1799
|
+
expected: import_invitations2.Options.Role.HOST,
|
|
1800
|
+
remoteOptions: this._remoteOptions
|
|
1801
|
+
});
|
|
1802
|
+
}
|
|
1803
|
+
this._callbacks.onOpen(this._ctx);
|
|
1804
|
+
} catch (err) {
|
|
1805
|
+
(0, import_log5.log)("openError", err, {
|
|
1806
|
+
F: __dxlog_file6,
|
|
1807
|
+
L: 300,
|
|
1808
|
+
S: this,
|
|
1809
|
+
C: (f, a) => f(...a)
|
|
1810
|
+
});
|
|
1811
|
+
this._callbacks.onError(err);
|
|
2013
1812
|
}
|
|
2014
1813
|
}
|
|
2015
|
-
async
|
|
2016
|
-
(0,
|
|
2017
|
-
F:
|
|
2018
|
-
L:
|
|
1814
|
+
async onClose() {
|
|
1815
|
+
(0, import_log5.log)("onClose", void 0, {
|
|
1816
|
+
F: __dxlog_file6,
|
|
1817
|
+
L: 306,
|
|
2019
1818
|
S: this,
|
|
2020
|
-
|
|
2021
|
-
"this._controller",
|
|
2022
|
-
"'Not initialized.'"
|
|
2023
|
-
]
|
|
1819
|
+
C: (f, a) => f(...a)
|
|
2024
1820
|
});
|
|
2025
|
-
|
|
2026
|
-
}
|
|
2027
|
-
async destroy() {
|
|
2028
|
-
this._seenPeers.clear();
|
|
2029
|
-
}
|
|
2030
|
-
toString() {
|
|
2031
|
-
return `InvitationTopology(${this._role === import_invitations5.Options.Role.GUEST ? "guest" : "host"})`;
|
|
1821
|
+
await this._ctx.dispose();
|
|
2032
1822
|
}
|
|
2033
1823
|
};
|
|
2034
|
-
var
|
|
2035
|
-
var
|
|
1824
|
+
var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services4.Invitation.AuthMethod.NONE;
|
|
1825
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
2036
1826
|
var InvitationsHandler = class {
|
|
2037
1827
|
/**
|
|
2038
1828
|
* @internal
|
|
2039
1829
|
*/
|
|
2040
|
-
constructor(_networkManager
|
|
1830
|
+
constructor(_networkManager) {
|
|
2041
1831
|
this._networkManager = _networkManager;
|
|
2042
|
-
this._defaultTeleportParams = _defaultTeleportParams;
|
|
2043
1832
|
}
|
|
2044
1833
|
handleInvitationFlow(ctx, stream, protocol, invitation) {
|
|
2045
|
-
const guardedState = this._createGuardedState(ctx, invitation, stream);
|
|
2046
1834
|
const createExtension = () => {
|
|
2047
|
-
const extension = new InvitationHostExtension(
|
|
2048
|
-
|
|
2049
|
-
|
|
1835
|
+
const extension = new InvitationHostExtension({
|
|
1836
|
+
onStateUpdate: (invitation2) => {
|
|
1837
|
+
stream.next({
|
|
1838
|
+
...invitation2,
|
|
1839
|
+
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1840
|
+
});
|
|
2050
1841
|
},
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
1842
|
+
resolveInvitation: async ({ invitationId }) => {
|
|
1843
|
+
if (invitationId && invitationId !== invitation.invitationId) {
|
|
1844
|
+
return void 0;
|
|
1845
|
+
}
|
|
1846
|
+
return invitation;
|
|
2054
1847
|
},
|
|
2055
1848
|
admit: async (admissionRequest) => {
|
|
2056
1849
|
try {
|
|
2057
1850
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
2058
1851
|
(0, import_invariant5.invariant)(deviceKey, void 0, {
|
|
2059
|
-
F:
|
|
2060
|
-
L:
|
|
1852
|
+
F: __dxlog_file7,
|
|
1853
|
+
L: 87,
|
|
2061
1854
|
S: this,
|
|
2062
1855
|
A: [
|
|
2063
1856
|
"deviceKey",
|
|
@@ -2068,36 +1861,34 @@ var InvitationsHandler = class {
|
|
|
2068
1861
|
extension.completedTrigger.wake(deviceKey);
|
|
2069
1862
|
return admissionResponse;
|
|
2070
1863
|
} catch (err) {
|
|
2071
|
-
|
|
1864
|
+
stream.error(err);
|
|
2072
1865
|
throw err;
|
|
2073
1866
|
}
|
|
2074
1867
|
},
|
|
2075
|
-
onOpen: (
|
|
2076
|
-
|
|
2077
|
-
connectionCtx.onDispose(() => {
|
|
2078
|
-
if (!admitted) {
|
|
2079
|
-
guardedState.error(extension, new import_context4.ContextDisposedError());
|
|
2080
|
-
}
|
|
2081
|
-
});
|
|
2082
|
-
(0, import_async7.scheduleTask)(connectionCtx, async () => {
|
|
1868
|
+
onOpen: () => {
|
|
1869
|
+
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
2083
1870
|
const traceId = import_keys5.PublicKey.random().toHex();
|
|
2084
1871
|
try {
|
|
2085
1872
|
import_log4.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.begin({
|
|
2086
1873
|
id: traceId
|
|
2087
1874
|
}), {
|
|
2088
|
-
F:
|
|
2089
|
-
L:
|
|
1875
|
+
F: __dxlog_file7,
|
|
1876
|
+
L: 105,
|
|
2090
1877
|
S: this,
|
|
2091
1878
|
C: (f, a) => f(...a)
|
|
2092
1879
|
});
|
|
2093
1880
|
(0, import_log4.log)("connected", {
|
|
2094
1881
|
...protocol.toJSON()
|
|
2095
1882
|
}, {
|
|
2096
|
-
F:
|
|
2097
|
-
L:
|
|
1883
|
+
F: __dxlog_file7,
|
|
1884
|
+
L: 106,
|
|
2098
1885
|
S: this,
|
|
2099
1886
|
C: (f, a) => f(...a)
|
|
2100
1887
|
});
|
|
1888
|
+
stream.next({
|
|
1889
|
+
...invitation,
|
|
1890
|
+
state: import_services3.Invitation.State.CONNECTED
|
|
1891
|
+
});
|
|
2101
1892
|
const deviceKey = await extension.completedTrigger.wait({
|
|
2102
1893
|
timeout: invitation.timeout
|
|
2103
1894
|
});
|
|
@@ -2105,91 +1896,88 @@ var InvitationsHandler = class {
|
|
|
2105
1896
|
guest: deviceKey,
|
|
2106
1897
|
...protocol.toJSON()
|
|
2107
1898
|
}, {
|
|
2108
|
-
F:
|
|
2109
|
-
L:
|
|
1899
|
+
F: __dxlog_file7,
|
|
1900
|
+
L: 109,
|
|
2110
1901
|
S: this,
|
|
2111
1902
|
C: (f, a) => f(...a)
|
|
2112
1903
|
});
|
|
2113
|
-
|
|
1904
|
+
stream.next({
|
|
1905
|
+
...invitation,
|
|
1906
|
+
state: import_services3.Invitation.State.SUCCESS
|
|
1907
|
+
});
|
|
2114
1908
|
import_log4.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.end({
|
|
2115
1909
|
id: traceId
|
|
2116
1910
|
}), {
|
|
2117
|
-
F:
|
|
2118
|
-
L:
|
|
1911
|
+
F: __dxlog_file7,
|
|
1912
|
+
L: 111,
|
|
2119
1913
|
S: this,
|
|
2120
1914
|
C: (f, a) => f(...a)
|
|
2121
1915
|
});
|
|
2122
|
-
admitted = true;
|
|
2123
|
-
if (!invitation.multiUse) {
|
|
2124
|
-
await ctx.dispose();
|
|
2125
|
-
}
|
|
2126
1916
|
} catch (err) {
|
|
2127
1917
|
if (err instanceof import_async7.TimeoutError) {
|
|
2128
|
-
|
|
2129
|
-
(
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
1918
|
+
(0, import_log4.log)("timeout", {
|
|
1919
|
+
...protocol.toJSON()
|
|
1920
|
+
}, {
|
|
1921
|
+
F: __dxlog_file7,
|
|
1922
|
+
L: 114,
|
|
1923
|
+
S: this,
|
|
1924
|
+
C: (f, a) => f(...a)
|
|
1925
|
+
});
|
|
1926
|
+
stream.next({
|
|
1927
|
+
...invitation,
|
|
1928
|
+
state: import_services3.Invitation.State.TIMEOUT
|
|
1929
|
+
});
|
|
2138
1930
|
} else {
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
}
|
|
1931
|
+
import_log4.log.error("failed", err, {
|
|
1932
|
+
F: __dxlog_file7,
|
|
1933
|
+
L: 117,
|
|
1934
|
+
S: this,
|
|
1935
|
+
C: (f, a) => f(...a)
|
|
1936
|
+
});
|
|
1937
|
+
stream.error(err);
|
|
2147
1938
|
}
|
|
2148
1939
|
import_log4.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.error({
|
|
2149
1940
|
id: traceId,
|
|
2150
1941
|
error: err
|
|
2151
1942
|
}), {
|
|
2152
|
-
F:
|
|
2153
|
-
L:
|
|
1943
|
+
F: __dxlog_file7,
|
|
1944
|
+
L: 120,
|
|
2154
1945
|
S: this,
|
|
2155
1946
|
C: (f, a) => f(...a)
|
|
2156
1947
|
});
|
|
2157
|
-
|
|
1948
|
+
} finally {
|
|
1949
|
+
if (!invitation.multiUse) {
|
|
1950
|
+
await swarmConnection.close();
|
|
1951
|
+
await ctx.dispose();
|
|
1952
|
+
}
|
|
2158
1953
|
}
|
|
2159
1954
|
});
|
|
2160
1955
|
},
|
|
2161
1956
|
onError: (err) => {
|
|
2162
1957
|
if (err instanceof import_protocols4.InvalidInvitationExtensionRoleError) {
|
|
2163
|
-
|
|
2164
|
-
|
|
1958
|
+
return;
|
|
1959
|
+
}
|
|
1960
|
+
if (err instanceof import_async7.TimeoutError) {
|
|
1961
|
+
(0, import_log4.log)("timeout", {
|
|
1962
|
+
...protocol.toJSON()
|
|
2165
1963
|
}, {
|
|
2166
|
-
F:
|
|
2167
|
-
L:
|
|
1964
|
+
F: __dxlog_file7,
|
|
1965
|
+
L: 135,
|
|
2168
1966
|
S: this,
|
|
2169
1967
|
C: (f, a) => f(...a)
|
|
2170
1968
|
});
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
(0, import_log4.log)("timeout", {
|
|
2176
|
-
err
|
|
2177
|
-
}, {
|
|
2178
|
-
F: __dxlog_file9,
|
|
2179
|
-
L: 149,
|
|
2180
|
-
S: this,
|
|
2181
|
-
C: (f, a) => f(...a)
|
|
2182
|
-
});
|
|
2183
|
-
}
|
|
1969
|
+
stream.next({
|
|
1970
|
+
...invitation,
|
|
1971
|
+
state: import_services3.Invitation.State.TIMEOUT
|
|
1972
|
+
});
|
|
2184
1973
|
} else {
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
}
|
|
1974
|
+
import_log4.log.error("failed", err, {
|
|
1975
|
+
F: __dxlog_file7,
|
|
1976
|
+
L: 138,
|
|
1977
|
+
S: this,
|
|
1978
|
+
C: (f, a) => f(...a)
|
|
1979
|
+
});
|
|
1980
|
+
stream.error(err);
|
|
2193
1981
|
}
|
|
2194
1982
|
}
|
|
2195
1983
|
});
|
|
@@ -2198,31 +1986,57 @@ var InvitationsHandler = class {
|
|
|
2198
1986
|
if (invitation.lifetime && invitation.created) {
|
|
2199
1987
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
2200
1988
|
import_log4.log.warn("invitation has already expired", void 0, {
|
|
2201
|
-
F:
|
|
2202
|
-
L:
|
|
1989
|
+
F: __dxlog_file7,
|
|
1990
|
+
L: 149,
|
|
2203
1991
|
S: this,
|
|
2204
1992
|
C: (f, a) => f(...a)
|
|
2205
1993
|
});
|
|
2206
1994
|
} else {
|
|
2207
1995
|
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
2208
1996
|
await swarmConnection.close();
|
|
2209
|
-
|
|
1997
|
+
stream.next({
|
|
1998
|
+
...invitation,
|
|
1999
|
+
state: import_services3.Invitation.State.EXPIRED
|
|
2000
|
+
});
|
|
2210
2001
|
await ctx.dispose();
|
|
2211
2002
|
}, invitation.created.getTime() + invitation.lifetime * 1e3 - Date.now());
|
|
2212
2003
|
}
|
|
2213
2004
|
}
|
|
2214
2005
|
let swarmConnection;
|
|
2006
|
+
const invitationLabel = "invitation host for " + (invitation.kind === import_services3.Invitation.Kind.DEVICE ? "device" : `space ${invitation.spaceKey?.truncate()}`);
|
|
2215
2007
|
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
2216
|
-
|
|
2217
|
-
|
|
2008
|
+
const topic = invitation.swarmKey;
|
|
2009
|
+
swarmConnection = await this._networkManager.joinSwarm({
|
|
2010
|
+
topic,
|
|
2011
|
+
peerId: topic,
|
|
2012
|
+
protocolProvider: (0, import_network_manager.createTeleportProtocolFactory)(async (teleport) => {
|
|
2013
|
+
teleport.addExtension("dxos.halo.invitations", createExtension());
|
|
2014
|
+
}),
|
|
2015
|
+
topology: new import_network_manager.StarTopology(topic),
|
|
2016
|
+
label: invitationLabel
|
|
2017
|
+
});
|
|
2018
|
+
ctx.onDispose(() => swarmConnection.close());
|
|
2019
|
+
stream.next({
|
|
2020
|
+
...invitation,
|
|
2021
|
+
state: import_services3.Invitation.State.CONNECTING
|
|
2022
|
+
});
|
|
2218
2023
|
});
|
|
2219
2024
|
}
|
|
2220
|
-
acceptInvitation(
|
|
2025
|
+
acceptInvitation(protocol, invitation, deviceProfile) {
|
|
2221
2026
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
2027
|
+
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
2028
|
+
F: __dxlog_file7,
|
|
2029
|
+
L: 191,
|
|
2030
|
+
S: this,
|
|
2031
|
+
A: [
|
|
2032
|
+
"protocol",
|
|
2033
|
+
""
|
|
2034
|
+
]
|
|
2035
|
+
});
|
|
2222
2036
|
if (deviceProfile) {
|
|
2223
2037
|
(0, import_invariant5.invariant)(invitation.kind === import_services3.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2224
|
-
F:
|
|
2225
|
-
L:
|
|
2038
|
+
F: __dxlog_file7,
|
|
2039
|
+
L: 194,
|
|
2226
2040
|
S: this,
|
|
2227
2041
|
A: [
|
|
2228
2042
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -2230,96 +2044,121 @@ var InvitationsHandler = class {
|
|
|
2230
2044
|
]
|
|
2231
2045
|
});
|
|
2232
2046
|
}
|
|
2233
|
-
const
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
triedPeers: triedPeersIds.size
|
|
2241
|
-
}, {
|
|
2242
|
-
F: __dxlog_file9,
|
|
2047
|
+
const authenticated = new import_async7.Trigger();
|
|
2048
|
+
let admitted = false;
|
|
2049
|
+
let currentState;
|
|
2050
|
+
const stream = new import_async7.PushStream();
|
|
2051
|
+
const setState = (newData) => {
|
|
2052
|
+
(0, import_invariant5.invariant)(newData.state !== void 0, void 0, {
|
|
2053
|
+
F: __dxlog_file7,
|
|
2243
2054
|
L: 205,
|
|
2244
2055
|
S: this,
|
|
2245
|
-
|
|
2056
|
+
A: [
|
|
2057
|
+
"newData.state !== undefined",
|
|
2058
|
+
""
|
|
2059
|
+
]
|
|
2060
|
+
});
|
|
2061
|
+
currentState = newData.state;
|
|
2062
|
+
stream.next({
|
|
2063
|
+
...invitation,
|
|
2064
|
+
...newData
|
|
2246
2065
|
});
|
|
2247
|
-
if (isLockedByAnotherConnection) {
|
|
2248
|
-
return false;
|
|
2249
|
-
}
|
|
2250
|
-
return invitation.type !== import_services3.Invitation.Type.DELEGATED || triedPeersIds.size >= MAX_DELEGATED_INVITATION_HOST_TRIES;
|
|
2251
2066
|
};
|
|
2252
|
-
|
|
2067
|
+
const ctx = new import_context4.Context({
|
|
2068
|
+
onError: (err) => {
|
|
2069
|
+
if (err instanceof import_async7.TimeoutError) {
|
|
2070
|
+
(0, import_log4.log)("timeout", {
|
|
2071
|
+
...protocol.toJSON()
|
|
2072
|
+
}, {
|
|
2073
|
+
F: __dxlog_file7,
|
|
2074
|
+
L: 213,
|
|
2075
|
+
S: this,
|
|
2076
|
+
C: (f, a) => f(...a)
|
|
2077
|
+
});
|
|
2078
|
+
setState({
|
|
2079
|
+
state: import_services3.Invitation.State.TIMEOUT
|
|
2080
|
+
});
|
|
2081
|
+
} else {
|
|
2082
|
+
import_log4.log.warn("auth failed", err, {
|
|
2083
|
+
F: __dxlog_file7,
|
|
2084
|
+
L: 216,
|
|
2085
|
+
S: this,
|
|
2086
|
+
C: (f, a) => f(...a)
|
|
2087
|
+
});
|
|
2088
|
+
stream.error(err);
|
|
2089
|
+
}
|
|
2090
|
+
void ctx.dispose();
|
|
2091
|
+
}
|
|
2092
|
+
});
|
|
2093
|
+
ctx.onDispose(() => {
|
|
2094
|
+
(0, import_log4.log)("complete", {
|
|
2095
|
+
...protocol.toJSON()
|
|
2096
|
+
}, {
|
|
2097
|
+
F: __dxlog_file7,
|
|
2098
|
+
L: 224,
|
|
2099
|
+
S: this,
|
|
2100
|
+
C: (f, a) => f(...a)
|
|
2101
|
+
});
|
|
2102
|
+
stream.complete();
|
|
2103
|
+
});
|
|
2253
2104
|
const createExtension = () => {
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
onOpen: (connectionCtx, extensionCtx) => {
|
|
2259
|
-
triedPeersIds.add(extensionCtx.remotePeerId);
|
|
2260
|
-
if (admitted) {
|
|
2261
|
-
extensionCtx.close();
|
|
2262
|
-
return;
|
|
2263
|
-
}
|
|
2264
|
-
connectionCtx.onDispose(async () => {
|
|
2105
|
+
let connectionCount = 0;
|
|
2106
|
+
const extension = new InvitationGuestExtension({
|
|
2107
|
+
onOpen: (extensionCtx) => {
|
|
2108
|
+
extensionCtx.onDispose(async () => {
|
|
2265
2109
|
(0, import_log4.log)("extension disposed", {
|
|
2266
|
-
|
|
2267
|
-
currentState: guardedState.current.state
|
|
2110
|
+
currentState
|
|
2268
2111
|
}, {
|
|
2269
|
-
F:
|
|
2270
|
-
L:
|
|
2112
|
+
F: __dxlog_file7,
|
|
2113
|
+
L: 234,
|
|
2271
2114
|
S: this,
|
|
2272
2115
|
C: (f, a) => f(...a)
|
|
2273
2116
|
});
|
|
2274
2117
|
if (!admitted) {
|
|
2275
|
-
|
|
2276
|
-
if (shouldCancelInvitationFlow(extension)) {
|
|
2277
|
-
await ctx.dispose();
|
|
2278
|
-
}
|
|
2118
|
+
stream.error(new Error("Remote peer disconnected."));
|
|
2279
2119
|
}
|
|
2280
2120
|
});
|
|
2281
|
-
(0, import_async7.scheduleTask)(
|
|
2121
|
+
(0, import_async7.scheduleTask)(ctx, async () => {
|
|
2282
2122
|
const traceId = import_keys5.PublicKey.random().toHex();
|
|
2283
2123
|
try {
|
|
2284
2124
|
import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.begin({
|
|
2285
2125
|
id: traceId
|
|
2286
2126
|
}), {
|
|
2287
|
-
F:
|
|
2288
|
-
L:
|
|
2127
|
+
F: __dxlog_file7,
|
|
2128
|
+
L: 243,
|
|
2289
2129
|
S: this,
|
|
2290
2130
|
C: (f, a) => f(...a)
|
|
2291
2131
|
});
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2132
|
+
if (++connectionCount > 1) {
|
|
2133
|
+
throw new Error(`multiple connections detected: ${connectionCount}`);
|
|
2134
|
+
}
|
|
2135
|
+
(0, import_async7.scheduleTask)(ctx, () => ctx.raise(new import_async7.TimeoutError(timeout)), timeout);
|
|
2296
2136
|
(0, import_log4.log)("connected", {
|
|
2297
2137
|
...protocol.toJSON()
|
|
2298
2138
|
}, {
|
|
2299
|
-
F:
|
|
2300
|
-
L:
|
|
2139
|
+
F: __dxlog_file7,
|
|
2140
|
+
L: 251,
|
|
2301
2141
|
S: this,
|
|
2302
2142
|
C: (f, a) => f(...a)
|
|
2303
2143
|
});
|
|
2304
|
-
|
|
2144
|
+
setState({
|
|
2145
|
+
state: import_services3.Invitation.State.CONNECTED
|
|
2146
|
+
});
|
|
2305
2147
|
(0, import_log4.log)("introduce", {
|
|
2306
2148
|
...protocol.toJSON()
|
|
2307
2149
|
}, {
|
|
2308
|
-
F:
|
|
2309
|
-
L:
|
|
2150
|
+
F: __dxlog_file7,
|
|
2151
|
+
L: 255,
|
|
2310
2152
|
S: this,
|
|
2311
2153
|
C: (f, a) => f(...a)
|
|
2312
2154
|
});
|
|
2313
|
-
const introductionResponse = await extension.rpc.InvitationHostService.introduce(
|
|
2314
|
-
invitationId: invitation.invitationId,
|
|
2315
|
-
...protocol.createIntroduction()
|
|
2316
|
-
});
|
|
2155
|
+
const introductionResponse = await extension.rpc.InvitationHostService.introduce(protocol.createIntroduction());
|
|
2317
2156
|
(0, import_log4.log)("introduce response", {
|
|
2318
2157
|
...protocol.toJSON(),
|
|
2319
2158
|
response: introductionResponse
|
|
2320
2159
|
}, {
|
|
2321
|
-
F:
|
|
2322
|
-
L:
|
|
2160
|
+
F: __dxlog_file7,
|
|
2161
|
+
L: 259,
|
|
2323
2162
|
S: this,
|
|
2324
2163
|
C: (f, a) => f(...a)
|
|
2325
2164
|
});
|
|
@@ -2327,20 +2166,20 @@ var InvitationsHandler = class {
|
|
|
2327
2166
|
if (isAuthenticationRequired(invitation)) {
|
|
2328
2167
|
switch (invitation.authMethod) {
|
|
2329
2168
|
case import_services3.Invitation.AuthMethod.SHARED_SECRET:
|
|
2330
|
-
await this._handleGuestOtpAuth(extension,
|
|
2169
|
+
await this._handleGuestOtpAuth(extension, setState, authenticated, {
|
|
2331
2170
|
timeout
|
|
2332
2171
|
});
|
|
2333
2172
|
break;
|
|
2334
2173
|
case import_services3.Invitation.AuthMethod.KNOWN_PUBLIC_KEY:
|
|
2335
|
-
await this._handleGuestKpkAuth(extension,
|
|
2174
|
+
await this._handleGuestKpkAuth(extension, setState, invitation, introductionResponse);
|
|
2336
2175
|
break;
|
|
2337
2176
|
}
|
|
2338
2177
|
}
|
|
2339
2178
|
(0, import_log4.log)("request admission", {
|
|
2340
2179
|
...protocol.toJSON()
|
|
2341
2180
|
}, {
|
|
2342
|
-
F:
|
|
2343
|
-
L:
|
|
2181
|
+
F: __dxlog_file7,
|
|
2182
|
+
L: 275,
|
|
2344
2183
|
S: this,
|
|
2345
2184
|
C: (f, a) => f(...a)
|
|
2346
2185
|
});
|
|
@@ -2351,21 +2190,21 @@ var InvitationsHandler = class {
|
|
|
2351
2190
|
(0, import_log4.log)("admitted by host", {
|
|
2352
2191
|
...protocol.toJSON()
|
|
2353
2192
|
}, {
|
|
2354
|
-
F:
|
|
2355
|
-
L:
|
|
2193
|
+
F: __dxlog_file7,
|
|
2194
|
+
L: 286,
|
|
2356
2195
|
S: this,
|
|
2357
2196
|
C: (f, a) => f(...a)
|
|
2358
2197
|
});
|
|
2359
|
-
|
|
2360
|
-
...guardedState.current,
|
|
2198
|
+
setState({
|
|
2361
2199
|
...result,
|
|
2200
|
+
target: invitation.target,
|
|
2362
2201
|
state: import_services3.Invitation.State.SUCCESS
|
|
2363
2202
|
});
|
|
2364
2203
|
import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.end({
|
|
2365
2204
|
id: traceId
|
|
2366
2205
|
}), {
|
|
2367
|
-
F:
|
|
2368
|
-
L:
|
|
2206
|
+
F: __dxlog_file7,
|
|
2207
|
+
L: 288,
|
|
2369
2208
|
S: this,
|
|
2370
2209
|
C: (f, a) => f(...a)
|
|
2371
2210
|
});
|
|
@@ -2374,31 +2213,34 @@ var InvitationsHandler = class {
|
|
|
2374
2213
|
(0, import_log4.log)("timeout", {
|
|
2375
2214
|
...protocol.toJSON()
|
|
2376
2215
|
}, {
|
|
2377
|
-
F:
|
|
2378
|
-
L:
|
|
2216
|
+
F: __dxlog_file7,
|
|
2217
|
+
L: 291,
|
|
2379
2218
|
S: this,
|
|
2380
2219
|
C: (f, a) => f(...a)
|
|
2381
2220
|
});
|
|
2382
|
-
|
|
2221
|
+
setState({
|
|
2222
|
+
state: import_services3.Invitation.State.TIMEOUT
|
|
2223
|
+
});
|
|
2383
2224
|
} else {
|
|
2384
2225
|
(0, import_log4.log)("auth failed", err, {
|
|
2385
|
-
F:
|
|
2386
|
-
L:
|
|
2226
|
+
F: __dxlog_file7,
|
|
2227
|
+
L: 294,
|
|
2387
2228
|
S: this,
|
|
2388
2229
|
C: (f, a) => f(...a)
|
|
2389
2230
|
});
|
|
2390
|
-
|
|
2231
|
+
stream.error(err);
|
|
2391
2232
|
}
|
|
2392
|
-
extensionCtx.close(err);
|
|
2393
2233
|
import_log4.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.error({
|
|
2394
2234
|
id: traceId,
|
|
2395
2235
|
error: err
|
|
2396
2236
|
}), {
|
|
2397
|
-
F:
|
|
2398
|
-
L:
|
|
2237
|
+
F: __dxlog_file7,
|
|
2238
|
+
L: 297,
|
|
2399
2239
|
S: this,
|
|
2400
2240
|
C: (f, a) => f(...a)
|
|
2401
2241
|
});
|
|
2242
|
+
} finally {
|
|
2243
|
+
await ctx.dispose();
|
|
2402
2244
|
}
|
|
2403
2245
|
});
|
|
2404
2246
|
},
|
|
@@ -2410,20 +2252,22 @@ var InvitationsHandler = class {
|
|
|
2410
2252
|
(0, import_log4.log)("timeout", {
|
|
2411
2253
|
...protocol.toJSON()
|
|
2412
2254
|
}, {
|
|
2413
|
-
F:
|
|
2414
|
-
L:
|
|
2255
|
+
F: __dxlog_file7,
|
|
2256
|
+
L: 308,
|
|
2415
2257
|
S: this,
|
|
2416
2258
|
C: (f, a) => f(...a)
|
|
2417
2259
|
});
|
|
2418
|
-
|
|
2260
|
+
setState({
|
|
2261
|
+
state: import_services3.Invitation.State.TIMEOUT
|
|
2262
|
+
});
|
|
2419
2263
|
} else {
|
|
2420
2264
|
(0, import_log4.log)("auth failed", err, {
|
|
2421
|
-
F:
|
|
2422
|
-
L:
|
|
2265
|
+
F: __dxlog_file7,
|
|
2266
|
+
L: 311,
|
|
2423
2267
|
S: this,
|
|
2424
2268
|
C: (f, a) => f(...a)
|
|
2425
2269
|
});
|
|
2426
|
-
|
|
2270
|
+
stream.error(err);
|
|
2427
2271
|
}
|
|
2428
2272
|
}
|
|
2429
2273
|
});
|
|
@@ -2433,140 +2277,68 @@ var InvitationsHandler = class {
|
|
|
2433
2277
|
const error = protocol.checkInvitation(invitation);
|
|
2434
2278
|
if (error) {
|
|
2435
2279
|
stream.error(error);
|
|
2436
|
-
await ctx.dispose();
|
|
2437
2280
|
} else {
|
|
2438
2281
|
(0, import_invariant5.invariant)(invitation.swarmKey, void 0, {
|
|
2439
|
-
F:
|
|
2440
|
-
L:
|
|
2282
|
+
F: __dxlog_file7,
|
|
2283
|
+
L: 325,
|
|
2441
2284
|
S: this,
|
|
2442
2285
|
A: [
|
|
2443
2286
|
"invitation.swarmKey",
|
|
2444
2287
|
""
|
|
2445
2288
|
]
|
|
2446
2289
|
});
|
|
2447
|
-
|
|
2448
|
-
|
|
2290
|
+
const topic = invitation.swarmKey;
|
|
2291
|
+
const swarmConnection = await this._networkManager.joinSwarm({
|
|
2292
|
+
topic,
|
|
2293
|
+
peerId: import_keys5.PublicKey.random(),
|
|
2294
|
+
protocolProvider: (0, import_network_manager.createTeleportProtocolFactory)(async (teleport) => {
|
|
2295
|
+
teleport.addExtension("dxos.halo.invitations", createExtension());
|
|
2296
|
+
}),
|
|
2297
|
+
topology: new import_network_manager.StarTopology(topic),
|
|
2298
|
+
label: "invitation guest"
|
|
2299
|
+
});
|
|
2300
|
+
ctx.onDispose(() => swarmConnection.close());
|
|
2301
|
+
setState({
|
|
2302
|
+
state: import_services3.Invitation.State.CONNECTING
|
|
2303
|
+
});
|
|
2449
2304
|
}
|
|
2450
2305
|
});
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
label = `invitation host for space ${invitation.spaceKey?.truncate()}`;
|
|
2460
|
-
}
|
|
2461
|
-
const swarmConnection = await this._networkManager.joinSwarm({
|
|
2462
|
-
topic: invitation.swarmKey,
|
|
2463
|
-
peerId: import_keys5.PublicKey.random(),
|
|
2464
|
-
protocolProvider: (0, import_network_manager.createTeleportProtocolFactory)(async (teleport) => {
|
|
2465
|
-
teleport.addExtension("dxos.halo.invitations", extensionFactory());
|
|
2466
|
-
}, this._defaultTeleportParams),
|
|
2467
|
-
topology: new InvitationTopology(role),
|
|
2468
|
-
label
|
|
2469
|
-
});
|
|
2470
|
-
ctx.onDispose(() => swarmConnection.close());
|
|
2471
|
-
return swarmConnection;
|
|
2472
|
-
}
|
|
2473
|
-
/**
|
|
2474
|
-
* A utility object for serializing invitation state changes by multiple concurrent
|
|
2475
|
-
* invitation flow connections.
|
|
2476
|
-
*/
|
|
2477
|
-
_createGuardedState(ctx, invitation, stream) {
|
|
2478
|
-
const mutex = new import_async7.Mutex();
|
|
2479
|
-
let lastActiveExtension = null;
|
|
2480
|
-
let currentInvitation = {
|
|
2481
|
-
...invitation
|
|
2482
|
-
};
|
|
2483
|
-
const isStateChangeAllowed = (extension) => {
|
|
2484
|
-
if (ctx.disposed || extension !== null && mutex.isLocked() && !extension.hasFlowLock()) {
|
|
2485
|
-
return false;
|
|
2486
|
-
}
|
|
2487
|
-
return extension == null || lastActiveExtension !== extension || this._isNotTerminal(currentInvitation.state);
|
|
2488
|
-
};
|
|
2489
|
-
return {
|
|
2490
|
-
mutex,
|
|
2491
|
-
get current() {
|
|
2492
|
-
return currentInvitation;
|
|
2493
|
-
},
|
|
2494
|
-
// disposing context prevents any further state updates
|
|
2495
|
-
complete: (newState) => {
|
|
2496
|
-
currentInvitation = {
|
|
2497
|
-
...currentInvitation,
|
|
2498
|
-
...newState
|
|
2499
|
-
};
|
|
2500
|
-
stream.next(currentInvitation);
|
|
2501
|
-
return ctx.dispose();
|
|
2502
|
-
},
|
|
2503
|
-
set: (extension, newState) => {
|
|
2504
|
-
if (isStateChangeAllowed(extension)) {
|
|
2505
|
-
this._logStateUpdate(currentInvitation, extension, newState);
|
|
2506
|
-
currentInvitation = {
|
|
2507
|
-
...currentInvitation,
|
|
2508
|
-
state: newState
|
|
2509
|
-
};
|
|
2510
|
-
stream.next(currentInvitation);
|
|
2511
|
-
lastActiveExtension = extension;
|
|
2512
|
-
return true;
|
|
2513
|
-
}
|
|
2514
|
-
return false;
|
|
2306
|
+
const observable = new import_client_protocol2.AuthenticatingInvitation({
|
|
2307
|
+
initialInvitation: invitation,
|
|
2308
|
+
subscriber: stream.observable,
|
|
2309
|
+
onCancel: async () => {
|
|
2310
|
+
setState({
|
|
2311
|
+
state: import_services3.Invitation.State.CANCELLED
|
|
2312
|
+
});
|
|
2313
|
+
await ctx.dispose();
|
|
2515
2314
|
},
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
this._logStateUpdate(currentInvitation, extension, import_services3.Invitation.State.ERROR);
|
|
2519
|
-
currentInvitation = {
|
|
2520
|
-
...currentInvitation,
|
|
2521
|
-
state: import_services3.Invitation.State.ERROR
|
|
2522
|
-
};
|
|
2523
|
-
stream.next(currentInvitation);
|
|
2524
|
-
stream.error(error);
|
|
2525
|
-
lastActiveExtension = extension;
|
|
2526
|
-
return true;
|
|
2527
|
-
}
|
|
2528
|
-
return false;
|
|
2315
|
+
onAuthenticate: async (code) => {
|
|
2316
|
+
authenticated.wake(code);
|
|
2529
2317
|
}
|
|
2530
|
-
};
|
|
2531
|
-
}
|
|
2532
|
-
_logStateUpdate(invitation, actor, newState) {
|
|
2533
|
-
(0, import_log4.log)("invitation state update", {
|
|
2534
|
-
actor: actor?.constructor.name,
|
|
2535
|
-
newState: stateToString(newState),
|
|
2536
|
-
oldState: stateToString(invitation.state)
|
|
2537
|
-
}, {
|
|
2538
|
-
F: __dxlog_file9,
|
|
2539
|
-
L: 438,
|
|
2540
|
-
S: this,
|
|
2541
|
-
C: (f, a) => f(...a)
|
|
2542
2318
|
});
|
|
2543
|
-
|
|
2544
|
-
_isNotTerminal(currentState) {
|
|
2545
|
-
return ![
|
|
2546
|
-
import_services3.Invitation.State.SUCCESS,
|
|
2547
|
-
import_services3.Invitation.State.ERROR,
|
|
2548
|
-
import_services3.Invitation.State.CANCELLED,
|
|
2549
|
-
import_services3.Invitation.State.TIMEOUT,
|
|
2550
|
-
import_services3.Invitation.State.EXPIRED
|
|
2551
|
-
].includes(currentState);
|
|
2319
|
+
return observable;
|
|
2552
2320
|
}
|
|
2553
2321
|
async _handleGuestOtpAuth(extension, setState, authenticated, options) {
|
|
2554
2322
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2555
2323
|
(0, import_log4.log)("guest waiting for authentication code...", void 0, {
|
|
2556
|
-
F:
|
|
2557
|
-
L:
|
|
2324
|
+
F: __dxlog_file7,
|
|
2325
|
+
L: 365,
|
|
2558
2326
|
S: this,
|
|
2559
2327
|
C: (f, a) => f(...a)
|
|
2560
2328
|
});
|
|
2561
|
-
setState(
|
|
2329
|
+
setState({
|
|
2330
|
+
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
2331
|
+
});
|
|
2562
2332
|
const authCode = await authenticated.wait(options);
|
|
2563
2333
|
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2564
|
-
F:
|
|
2565
|
-
L:
|
|
2334
|
+
F: __dxlog_file7,
|
|
2335
|
+
L: 369,
|
|
2566
2336
|
S: this,
|
|
2567
2337
|
C: (f, a) => f(...a)
|
|
2568
2338
|
});
|
|
2569
|
-
setState(
|
|
2339
|
+
setState({
|
|
2340
|
+
state: import_services3.Invitation.State.AUTHENTICATING
|
|
2341
|
+
});
|
|
2570
2342
|
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2571
2343
|
authCode
|
|
2572
2344
|
});
|
|
@@ -2580,8 +2352,8 @@ var InvitationsHandler = class {
|
|
|
2580
2352
|
(0, import_log4.log)("retrying invalid code", {
|
|
2581
2353
|
attempt
|
|
2582
2354
|
}, {
|
|
2583
|
-
F:
|
|
2584
|
-
L:
|
|
2355
|
+
F: __dxlog_file7,
|
|
2356
|
+
L: 380,
|
|
2585
2357
|
S: this,
|
|
2586
2358
|
C: (f, a) => f(...a)
|
|
2587
2359
|
});
|
|
@@ -2598,12 +2370,14 @@ var InvitationsHandler = class {
|
|
|
2598
2370
|
throw new Error("challenge missing in the introduction");
|
|
2599
2371
|
}
|
|
2600
2372
|
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2601
|
-
F:
|
|
2602
|
-
L:
|
|
2373
|
+
F: __dxlog_file7,
|
|
2374
|
+
L: 399,
|
|
2603
2375
|
S: this,
|
|
2604
2376
|
C: (f, a) => f(...a)
|
|
2605
2377
|
});
|
|
2606
|
-
setState(
|
|
2378
|
+
setState({
|
|
2379
|
+
state: import_services3.Invitation.State.AUTHENTICATING
|
|
2380
|
+
});
|
|
2607
2381
|
const signature = (0, import_crypto.sign)(Buffer.from(introductionResponse.challenge), invitation.guestKeypair.privateKey);
|
|
2608
2382
|
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2609
2383
|
signedChallenge: signature
|
|
@@ -2649,8 +2423,8 @@ var InvitationsServiceImpl = class {
|
|
|
2649
2423
|
return new import_codec_protobuf8.Stream(({ next, ctx }) => {
|
|
2650
2424
|
this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
|
|
2651
2425
|
next({
|
|
2652
|
-
action:
|
|
2653
|
-
type:
|
|
2426
|
+
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2427
|
+
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
2654
2428
|
invitations: [
|
|
2655
2429
|
invitation
|
|
2656
2430
|
]
|
|
@@ -2658,8 +2432,8 @@ var InvitationsServiceImpl = class {
|
|
|
2658
2432
|
});
|
|
2659
2433
|
this._invitationsManager.invitationAccepted.on(ctx, (invitation) => {
|
|
2660
2434
|
next({
|
|
2661
|
-
action:
|
|
2662
|
-
type:
|
|
2435
|
+
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2436
|
+
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
2663
2437
|
invitations: [
|
|
2664
2438
|
invitation
|
|
2665
2439
|
]
|
|
@@ -2667,8 +2441,8 @@ var InvitationsServiceImpl = class {
|
|
|
2667
2441
|
});
|
|
2668
2442
|
this._invitationsManager.removedCreated.on(ctx, (invitation) => {
|
|
2669
2443
|
next({
|
|
2670
|
-
action:
|
|
2671
|
-
type:
|
|
2444
|
+
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2445
|
+
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
2672
2446
|
invitations: [
|
|
2673
2447
|
invitation
|
|
2674
2448
|
]
|
|
@@ -2676,8 +2450,8 @@ var InvitationsServiceImpl = class {
|
|
|
2676
2450
|
});
|
|
2677
2451
|
this._invitationsManager.removedAccepted.on(ctx, (invitation) => {
|
|
2678
2452
|
next({
|
|
2679
|
-
action:
|
|
2680
|
-
type:
|
|
2453
|
+
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2454
|
+
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
2681
2455
|
invitations: [
|
|
2682
2456
|
invitation
|
|
2683
2457
|
]
|
|
@@ -2685,35 +2459,35 @@ var InvitationsServiceImpl = class {
|
|
|
2685
2459
|
});
|
|
2686
2460
|
this._invitationsManager.saved.on(ctx, (invitation) => {
|
|
2687
2461
|
next({
|
|
2688
|
-
action:
|
|
2689
|
-
type:
|
|
2462
|
+
action: import_services5.QueryInvitationsResponse.Action.SAVED,
|
|
2463
|
+
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
2690
2464
|
invitations: [
|
|
2691
2465
|
invitation
|
|
2692
2466
|
]
|
|
2693
2467
|
});
|
|
2694
2468
|
});
|
|
2695
2469
|
next({
|
|
2696
|
-
action:
|
|
2697
|
-
type:
|
|
2470
|
+
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2471
|
+
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
2698
2472
|
invitations: this._invitationsManager.getCreatedInvitations(),
|
|
2699
2473
|
existing: true
|
|
2700
2474
|
});
|
|
2701
2475
|
next({
|
|
2702
|
-
action:
|
|
2703
|
-
type:
|
|
2476
|
+
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2477
|
+
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
2704
2478
|
invitations: this._invitationsManager.getAcceptedInvitations(),
|
|
2705
2479
|
existing: true
|
|
2706
2480
|
});
|
|
2707
2481
|
this._invitationsManager.onPersistentInvitationsLoaded(ctx, () => {
|
|
2708
2482
|
next({
|
|
2709
|
-
action:
|
|
2710
|
-
type:
|
|
2483
|
+
action: import_services5.QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2484
|
+
type: import_services5.QueryInvitationsResponse.Type.CREATED
|
|
2711
2485
|
});
|
|
2712
2486
|
});
|
|
2713
2487
|
});
|
|
2714
2488
|
}
|
|
2715
2489
|
};
|
|
2716
|
-
var
|
|
2490
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2717
2491
|
var SpaceInvitationProtocol = class {
|
|
2718
2492
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
2719
2493
|
this._spaceManager = _spaceManager;
|
|
@@ -2729,14 +2503,14 @@ var SpaceInvitationProtocol = class {
|
|
|
2729
2503
|
}
|
|
2730
2504
|
getInvitationContext() {
|
|
2731
2505
|
return {
|
|
2732
|
-
kind:
|
|
2506
|
+
kind: import_services6.Invitation.Kind.SPACE,
|
|
2733
2507
|
spaceKey: this._spaceKey
|
|
2734
2508
|
};
|
|
2735
2509
|
}
|
|
2736
2510
|
async admit(invitation, request, guestProfile) {
|
|
2737
|
-
(0,
|
|
2738
|
-
F:
|
|
2739
|
-
L:
|
|
2511
|
+
(0, import_invariant7.invariant)(this._spaceKey, void 0, {
|
|
2512
|
+
F: __dxlog_file8,
|
|
2513
|
+
L: 55,
|
|
2740
2514
|
S: this,
|
|
2741
2515
|
A: [
|
|
2742
2516
|
"this._spaceKey",
|
|
@@ -2744,18 +2518,18 @@ var SpaceInvitationProtocol = class {
|
|
|
2744
2518
|
]
|
|
2745
2519
|
});
|
|
2746
2520
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2747
|
-
(0,
|
|
2748
|
-
F:
|
|
2749
|
-
L:
|
|
2521
|
+
(0, import_invariant7.invariant)(space, void 0, {
|
|
2522
|
+
F: __dxlog_file8,
|
|
2523
|
+
L: 57,
|
|
2750
2524
|
S: this,
|
|
2751
2525
|
A: [
|
|
2752
2526
|
"space",
|
|
2753
2527
|
""
|
|
2754
2528
|
]
|
|
2755
2529
|
});
|
|
2756
|
-
(0,
|
|
2757
|
-
F:
|
|
2758
|
-
L:
|
|
2530
|
+
(0, import_invariant7.invariant)(request.space, void 0, {
|
|
2531
|
+
F: __dxlog_file8,
|
|
2532
|
+
L: 59,
|
|
2759
2533
|
S: this,
|
|
2760
2534
|
A: [
|
|
2761
2535
|
"request.space",
|
|
@@ -2763,19 +2537,19 @@ var SpaceInvitationProtocol = class {
|
|
|
2763
2537
|
]
|
|
2764
2538
|
});
|
|
2765
2539
|
const { identityKey, deviceKey } = request.space;
|
|
2766
|
-
(0,
|
|
2540
|
+
(0, import_log6.log)("writing guest credentials", {
|
|
2767
2541
|
host: this._signingContext.deviceKey,
|
|
2768
2542
|
guest: deviceKey
|
|
2769
2543
|
}, {
|
|
2770
|
-
F:
|
|
2771
|
-
L:
|
|
2544
|
+
F: __dxlog_file8,
|
|
2545
|
+
L: 62,
|
|
2772
2546
|
S: this,
|
|
2773
2547
|
C: (f, a) => f(...a)
|
|
2774
2548
|
});
|
|
2775
2549
|
const credentials = await (0, import_credentials7.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile, invitation.delegationCredentialId);
|
|
2776
|
-
(0,
|
|
2777
|
-
F:
|
|
2778
|
-
L:
|
|
2550
|
+
(0, import_invariant7.invariant)(credentials[0].credential, void 0, {
|
|
2551
|
+
F: __dxlog_file8,
|
|
2552
|
+
L: 74,
|
|
2779
2553
|
S: this,
|
|
2780
2554
|
A: [
|
|
2781
2555
|
"credentials[0].credential",
|
|
@@ -2783,9 +2557,9 @@ var SpaceInvitationProtocol = class {
|
|
|
2783
2557
|
]
|
|
2784
2558
|
});
|
|
2785
2559
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2786
|
-
(0,
|
|
2787
|
-
F:
|
|
2788
|
-
L:
|
|
2560
|
+
(0, import_invariant7.invariant)((0, import_credentials7.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2561
|
+
F: __dxlog_file8,
|
|
2562
|
+
L: 76,
|
|
2789
2563
|
S: this,
|
|
2790
2564
|
A: [
|
|
2791
2565
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2801,29 +2575,29 @@ var SpaceInvitationProtocol = class {
|
|
|
2801
2575
|
};
|
|
2802
2576
|
}
|
|
2803
2577
|
async delegate(invitation) {
|
|
2804
|
-
(0,
|
|
2805
|
-
F:
|
|
2806
|
-
L:
|
|
2578
|
+
(0, import_invariant7.invariant)(this._spaceKey, void 0, {
|
|
2579
|
+
F: __dxlog_file8,
|
|
2580
|
+
L: 89,
|
|
2807
2581
|
S: this,
|
|
2808
2582
|
A: [
|
|
2809
2583
|
"this._spaceKey",
|
|
2810
2584
|
""
|
|
2811
2585
|
]
|
|
2812
2586
|
});
|
|
2813
|
-
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
2814
|
-
(0,
|
|
2815
|
-
F:
|
|
2816
|
-
L:
|
|
2587
|
+
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2588
|
+
(0, import_invariant7.invariant)(space, void 0, {
|
|
2589
|
+
F: __dxlog_file8,
|
|
2590
|
+
L: 91,
|
|
2817
2591
|
S: this,
|
|
2818
2592
|
A: [
|
|
2819
2593
|
"space",
|
|
2820
2594
|
""
|
|
2821
2595
|
]
|
|
2822
2596
|
});
|
|
2823
|
-
if (invitation.authMethod ===
|
|
2824
|
-
(0,
|
|
2825
|
-
F:
|
|
2826
|
-
L:
|
|
2597
|
+
if (invitation.authMethod === import_services6.Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
2598
|
+
(0, import_invariant7.invariant)(invitation.guestKeypair?.publicKey, void 0, {
|
|
2599
|
+
F: __dxlog_file8,
|
|
2600
|
+
L: 93,
|
|
2827
2601
|
S: this,
|
|
2828
2602
|
A: [
|
|
2829
2603
|
"invitation.guestKeypair?.publicKey",
|
|
@@ -2831,12 +2605,12 @@ var SpaceInvitationProtocol = class {
|
|
|
2831
2605
|
]
|
|
2832
2606
|
});
|
|
2833
2607
|
}
|
|
2834
|
-
(0,
|
|
2608
|
+
(0, import_log6.log)("writing delegate space invitation", {
|
|
2835
2609
|
host: this._signingContext.deviceKey,
|
|
2836
2610
|
id: invitation.invitationId
|
|
2837
2611
|
}, {
|
|
2838
|
-
F:
|
|
2839
|
-
L:
|
|
2612
|
+
F: __dxlog_file8,
|
|
2613
|
+
L: 96,
|
|
2840
2614
|
S: this,
|
|
2841
2615
|
C: (f, a) => f(...a)
|
|
2842
2616
|
});
|
|
@@ -2847,11 +2621,11 @@ var SpaceInvitationProtocol = class {
|
|
|
2847
2621
|
role: import_credentials8.SpaceMember.Role.ADMIN,
|
|
2848
2622
|
expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
|
|
2849
2623
|
multiUse: invitation.multiUse ?? false,
|
|
2850
|
-
guestKey: invitation.authMethod ===
|
|
2624
|
+
guestKey: invitation.authMethod === import_services6.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
|
|
2851
2625
|
});
|
|
2852
|
-
(0,
|
|
2853
|
-
F:
|
|
2854
|
-
L:
|
|
2626
|
+
(0, import_invariant7.invariant)(credential.credential, void 0, {
|
|
2627
|
+
F: __dxlog_file8,
|
|
2628
|
+
L: 116,
|
|
2855
2629
|
S: this,
|
|
2856
2630
|
A: [
|
|
2857
2631
|
"credential.credential",
|
|
@@ -2863,61 +2637,9 @@ var SpaceInvitationProtocol = class {
|
|
|
2863
2637
|
]);
|
|
2864
2638
|
return credential.credential.credential.id;
|
|
2865
2639
|
}
|
|
2866
|
-
async cancelDelegation(invitation) {
|
|
2867
|
-
(0, import_invariant9.invariant)(this._spaceKey, void 0, {
|
|
2868
|
-
F: __dxlog_file10,
|
|
2869
|
-
L: 123,
|
|
2870
|
-
S: this,
|
|
2871
|
-
A: [
|
|
2872
|
-
"this._spaceKey",
|
|
2873
|
-
""
|
|
2874
|
-
]
|
|
2875
|
-
});
|
|
2876
|
-
(0, import_invariant9.invariant)(invitation.type === import_services7.Invitation.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
|
|
2877
|
-
F: __dxlog_file10,
|
|
2878
|
-
L: 124,
|
|
2879
|
-
S: this,
|
|
2880
|
-
A: [
|
|
2881
|
-
"invitation.type === Invitation.Type.DELEGATED && invitation.delegationCredentialId",
|
|
2882
|
-
""
|
|
2883
|
-
]
|
|
2884
|
-
});
|
|
2885
|
-
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
2886
|
-
(0, import_invariant9.invariant)(space, void 0, {
|
|
2887
|
-
F: __dxlog_file10,
|
|
2888
|
-
L: 126,
|
|
2889
|
-
S: this,
|
|
2890
|
-
A: [
|
|
2891
|
-
"space",
|
|
2892
|
-
""
|
|
2893
|
-
]
|
|
2894
|
-
});
|
|
2895
|
-
(0, import_log8.log)("cancelling delegated space invitation", {
|
|
2896
|
-
host: this._signingContext.deviceKey,
|
|
2897
|
-
id: invitation.invitationId
|
|
2898
|
-
}, {
|
|
2899
|
-
F: __dxlog_file10,
|
|
2900
|
-
L: 128,
|
|
2901
|
-
S: this,
|
|
2902
|
-
C: (f, a) => f(...a)
|
|
2903
|
-
});
|
|
2904
|
-
const credential = await (0, import_credentials7.createCancelDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
|
|
2905
|
-
(0, import_invariant9.invariant)(credential.credential, void 0, {
|
|
2906
|
-
F: __dxlog_file10,
|
|
2907
|
-
L: 135,
|
|
2908
|
-
S: this,
|
|
2909
|
-
A: [
|
|
2910
|
-
"credential.credential",
|
|
2911
|
-
""
|
|
2912
|
-
]
|
|
2913
|
-
});
|
|
2914
|
-
await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, [
|
|
2915
|
-
credential
|
|
2916
|
-
]);
|
|
2917
|
-
}
|
|
2918
2640
|
checkInvitation(invitation) {
|
|
2919
2641
|
if (invitation.spaceKey && this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
2920
|
-
return new
|
|
2642
|
+
return new import_protocols6.AlreadyJoinedError("Already joined space.");
|
|
2921
2643
|
}
|
|
2922
2644
|
}
|
|
2923
2645
|
createIntroduction() {
|
|
@@ -2938,9 +2660,9 @@ var SpaceInvitationProtocol = class {
|
|
|
2938
2660
|
};
|
|
2939
2661
|
}
|
|
2940
2662
|
async accept(response) {
|
|
2941
|
-
(0,
|
|
2942
|
-
F:
|
|
2943
|
-
L:
|
|
2663
|
+
(0, import_invariant7.invariant)(response.space, void 0, {
|
|
2664
|
+
F: __dxlog_file8,
|
|
2665
|
+
L: 149,
|
|
2944
2666
|
S: this,
|
|
2945
2667
|
A: [
|
|
2946
2668
|
"response.space",
|
|
@@ -2949,18 +2671,18 @@ var SpaceInvitationProtocol = class {
|
|
|
2949
2671
|
});
|
|
2950
2672
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2951
2673
|
const assertion = (0, import_credentials7.getCredentialAssertion)(credential);
|
|
2952
|
-
(0,
|
|
2953
|
-
F:
|
|
2954
|
-
L:
|
|
2674
|
+
(0, import_invariant7.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2675
|
+
F: __dxlog_file8,
|
|
2676
|
+
L: 152,
|
|
2955
2677
|
S: this,
|
|
2956
2678
|
A: [
|
|
2957
2679
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2958
2680
|
"'Invalid credential'"
|
|
2959
2681
|
]
|
|
2960
2682
|
});
|
|
2961
|
-
(0,
|
|
2962
|
-
F:
|
|
2963
|
-
L:
|
|
2683
|
+
(0, import_invariant7.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2684
|
+
F: __dxlog_file8,
|
|
2685
|
+
L: 153,
|
|
2964
2686
|
S: this,
|
|
2965
2687
|
A: [
|
|
2966
2688
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
@@ -2968,7 +2690,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2968
2690
|
]
|
|
2969
2691
|
});
|
|
2970
2692
|
if (this._spaceManager.spaces.has(assertion.spaceKey)) {
|
|
2971
|
-
throw new
|
|
2693
|
+
throw new import_protocols6.AlreadyJoinedError("Already joined space.");
|
|
2972
2694
|
}
|
|
2973
2695
|
await this._spaceManager.acceptSpace({
|
|
2974
2696
|
spaceKey: assertion.spaceKey,
|
|
@@ -2982,7 +2704,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2982
2704
|
};
|
|
2983
2705
|
}
|
|
2984
2706
|
};
|
|
2985
|
-
var
|
|
2707
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
2986
2708
|
var InvitationsManager = class {
|
|
2987
2709
|
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
2988
2710
|
this._invitationsHandler = _invitationsHandler;
|
|
@@ -2990,12 +2712,12 @@ var InvitationsManager = class {
|
|
|
2990
2712
|
this._metadataStore = _metadataStore;
|
|
2991
2713
|
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2992
2714
|
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2993
|
-
this.invitationCreated = new
|
|
2994
|
-
this.invitationAccepted = new
|
|
2995
|
-
this.removedCreated = new
|
|
2996
|
-
this.removedAccepted = new
|
|
2997
|
-
this.saved = new
|
|
2998
|
-
this._persistentInvitationsLoadedEvent = new
|
|
2715
|
+
this.invitationCreated = new import_async9.Event();
|
|
2716
|
+
this.invitationAccepted = new import_async9.Event();
|
|
2717
|
+
this.removedCreated = new import_async9.Event();
|
|
2718
|
+
this.removedAccepted = new import_async9.Event();
|
|
2719
|
+
this.saved = new import_async9.Event();
|
|
2720
|
+
this._persistentInvitationsLoadedEvent = new import_async9.Event();
|
|
2999
2721
|
this._persistentInvitationsLoaded = false;
|
|
3000
2722
|
}
|
|
3001
2723
|
async createInvitation(options) {
|
|
@@ -3020,8 +2742,8 @@ var InvitationsManager = class {
|
|
|
3020
2742
|
try {
|
|
3021
2743
|
await this._persistIfRequired(handler, stream, invitation);
|
|
3022
2744
|
} catch (err) {
|
|
3023
|
-
|
|
3024
|
-
F:
|
|
2745
|
+
import_log7.log.catch(err, void 0, {
|
|
2746
|
+
F: __dxlog_file9,
|
|
3025
2747
|
L: 76,
|
|
3026
2748
|
S: this,
|
|
3027
2749
|
C: (f, a) => f(...a)
|
|
@@ -3043,8 +2765,8 @@ var InvitationsManager = class {
|
|
|
3043
2765
|
const persistentInvitations = this._metadataStore.getInvitations();
|
|
3044
2766
|
const freshInvitations = persistentInvitations.filter((invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
|
|
3045
2767
|
const loadTasks = freshInvitations.map((persistentInvitation) => {
|
|
3046
|
-
(0,
|
|
3047
|
-
F:
|
|
2768
|
+
(0, import_invariant8.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2769
|
+
F: __dxlog_file9,
|
|
3048
2770
|
L: 97,
|
|
3049
2771
|
S: this,
|
|
3050
2772
|
A: [
|
|
@@ -3062,8 +2784,8 @@ var InvitationsManager = class {
|
|
|
3062
2784
|
invitations: cInvitations.map((invitation) => invitation.get())
|
|
3063
2785
|
};
|
|
3064
2786
|
} catch (err) {
|
|
3065
|
-
|
|
3066
|
-
F:
|
|
2787
|
+
import_log7.log.catch(err, void 0, {
|
|
2788
|
+
F: __dxlog_file9,
|
|
3067
2789
|
L: 104,
|
|
3068
2790
|
S: this,
|
|
3069
2791
|
C: (f, a) => f(...a)
|
|
@@ -3083,8 +2805,7 @@ var InvitationsManager = class {
|
|
|
3083
2805
|
return existingInvitation;
|
|
3084
2806
|
}
|
|
3085
2807
|
const handler = this._getHandler(options);
|
|
3086
|
-
const
|
|
3087
|
-
this._invitationsHandler.acceptInvitation(ctx, stream, handler, options, otpEnteredTrigger, request.deviceProfile);
|
|
2808
|
+
const invitation = this._invitationsHandler.acceptInvitation(handler, options, request.deviceProfile);
|
|
3088
2809
|
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
3089
2810
|
this.invitationAccepted.emit(invitation.get());
|
|
3090
2811
|
this._onInvitationComplete(invitation, () => {
|
|
@@ -3094,15 +2815,15 @@ var InvitationsManager = class {
|
|
|
3094
2815
|
return invitation;
|
|
3095
2816
|
}
|
|
3096
2817
|
async authenticate({ invitationId, authCode }) {
|
|
3097
|
-
(0,
|
|
3098
|
-
F:
|
|
3099
|
-
L:
|
|
2818
|
+
(0, import_log7.log)("authenticating...", void 0, {
|
|
2819
|
+
F: __dxlog_file9,
|
|
2820
|
+
L: 133,
|
|
3100
2821
|
S: this,
|
|
3101
2822
|
C: (f, a) => f(...a)
|
|
3102
2823
|
});
|
|
3103
|
-
(0,
|
|
3104
|
-
F:
|
|
3105
|
-
L:
|
|
2824
|
+
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2825
|
+
F: __dxlog_file9,
|
|
2826
|
+
L: 134,
|
|
3106
2827
|
S: this,
|
|
3107
2828
|
A: [
|
|
3108
2829
|
"invitationId",
|
|
@@ -3111,11 +2832,11 @@ var InvitationsManager = class {
|
|
|
3111
2832
|
});
|
|
3112
2833
|
const observable = this._acceptInvitations.get(invitationId);
|
|
3113
2834
|
if (!observable) {
|
|
3114
|
-
|
|
2835
|
+
import_log7.log.warn("invalid invitation", {
|
|
3115
2836
|
invitationId
|
|
3116
2837
|
}, {
|
|
3117
|
-
F:
|
|
3118
|
-
L:
|
|
2838
|
+
F: __dxlog_file9,
|
|
2839
|
+
L: 137,
|
|
3119
2840
|
S: this,
|
|
3120
2841
|
C: (f, a) => f(...a)
|
|
3121
2842
|
});
|
|
@@ -3124,17 +2845,17 @@ var InvitationsManager = class {
|
|
|
3124
2845
|
}
|
|
3125
2846
|
}
|
|
3126
2847
|
async cancelInvitation({ invitationId }) {
|
|
3127
|
-
(0,
|
|
2848
|
+
(0, import_log7.log)("cancelInvitation...", {
|
|
3128
2849
|
invitationId
|
|
3129
2850
|
}, {
|
|
3130
|
-
F:
|
|
3131
|
-
L:
|
|
2851
|
+
F: __dxlog_file9,
|
|
2852
|
+
L: 144,
|
|
3132
2853
|
S: this,
|
|
3133
2854
|
C: (f, a) => f(...a)
|
|
3134
2855
|
});
|
|
3135
|
-
(0,
|
|
3136
|
-
F:
|
|
3137
|
-
L:
|
|
2856
|
+
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2857
|
+
F: __dxlog_file9,
|
|
2858
|
+
L: 145,
|
|
3138
2859
|
S: this,
|
|
3139
2860
|
A: [
|
|
3140
2861
|
"invitationId",
|
|
@@ -3146,10 +2867,6 @@ var InvitationsManager = class {
|
|
|
3146
2867
|
if (created.get().persistent) {
|
|
3147
2868
|
await this._metadataStore.removeInvitation(invitationId);
|
|
3148
2869
|
}
|
|
3149
|
-
if (created.get().type === import_services8.Invitation.Type.DELEGATED) {
|
|
3150
|
-
const handler = this._getHandler(created.get());
|
|
3151
|
-
await handler.cancelDelegation(created.get());
|
|
3152
|
-
}
|
|
3153
2870
|
await created.cancel();
|
|
3154
2871
|
this._createInvitations.delete(invitationId);
|
|
3155
2872
|
this.removedCreated.emit(created.get());
|
|
@@ -3180,8 +2897,8 @@ var InvitationsManager = class {
|
|
|
3180
2897
|
}
|
|
3181
2898
|
}
|
|
3182
2899
|
_createInvitation(protocol, options) {
|
|
3183
|
-
const { invitationId =
|
|
3184
|
-
const authCode = options?.authCode ?? (authMethod ===
|
|
2900
|
+
const { invitationId = import_keys7.PublicKey.random().toHex(), type = import_services7.Invitation.Type.INTERACTIVE, authMethod = import_services7.Invitation.AuthMethod.SHARED_SECRET, state = import_services7.Invitation.State.INIT, timeout = import_client_protocol3.INVITATION_TIMEOUT, swarmKey = import_keys7.PublicKey.random(), persistent = options?.authMethod !== import_services7.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, lifetime = 86400, multiUse = false } = options ?? {};
|
|
2901
|
+
const authCode = options?.authCode ?? (authMethod === import_services7.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials9.generatePasscode)(import_client_protocol3.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
3185
2902
|
return {
|
|
3186
2903
|
invitationId,
|
|
3187
2904
|
type,
|
|
@@ -3190,8 +2907,8 @@ var InvitationsManager = class {
|
|
|
3190
2907
|
swarmKey,
|
|
3191
2908
|
authCode,
|
|
3192
2909
|
timeout,
|
|
3193
|
-
persistent: persistent && type !==
|
|
3194
|
-
guestKeypair: guestKeypair ?? (authMethod ===
|
|
2910
|
+
persistent: persistent && type !== import_services7.Invitation.Type.DELEGATED,
|
|
2911
|
+
guestKeypair: guestKeypair ?? (authMethod === import_services7.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
|
|
3195
2912
|
created,
|
|
3196
2913
|
lifetime,
|
|
3197
2914
|
multiUse,
|
|
@@ -3200,19 +2917,19 @@ var InvitationsManager = class {
|
|
|
3200
2917
|
};
|
|
3201
2918
|
}
|
|
3202
2919
|
_createObservableInvitation(handler, invitation) {
|
|
3203
|
-
const stream = new
|
|
3204
|
-
const ctx = new
|
|
2920
|
+
const stream = new import_async9.PushStream();
|
|
2921
|
+
const ctx = new import_context6.Context({
|
|
3205
2922
|
onError: (err) => {
|
|
3206
2923
|
stream.error(err);
|
|
3207
2924
|
void ctx.dispose();
|
|
3208
2925
|
}
|
|
3209
2926
|
});
|
|
3210
2927
|
ctx.onDispose(() => {
|
|
3211
|
-
(0,
|
|
2928
|
+
(0, import_log7.log)("complete", {
|
|
3212
2929
|
...handler.toJSON()
|
|
3213
2930
|
}, {
|
|
3214
|
-
F:
|
|
3215
|
-
L:
|
|
2931
|
+
F: __dxlog_file9,
|
|
2932
|
+
L: 228,
|
|
3216
2933
|
S: this,
|
|
3217
2934
|
C: (f, a) => f(...a)
|
|
3218
2935
|
});
|
|
@@ -3224,7 +2941,7 @@ var InvitationsManager = class {
|
|
|
3224
2941
|
onCancel: async () => {
|
|
3225
2942
|
stream.next({
|
|
3226
2943
|
...invitation,
|
|
3227
|
-
state:
|
|
2944
|
+
state: import_services7.Invitation.State.CANCELLED
|
|
3228
2945
|
});
|
|
3229
2946
|
await ctx.dispose();
|
|
3230
2947
|
}
|
|
@@ -3235,73 +2952,8 @@ var InvitationsManager = class {
|
|
|
3235
2952
|
observableInvitation
|
|
3236
2953
|
};
|
|
3237
2954
|
}
|
|
3238
|
-
_createObservableAcceptingInvitation(handler, initialState) {
|
|
3239
|
-
const otpEnteredTrigger = new import_async10.Trigger();
|
|
3240
|
-
const stream = new import_async10.PushStream();
|
|
3241
|
-
const ctx = new import_context8.Context({
|
|
3242
|
-
onError: (err) => {
|
|
3243
|
-
if (err instanceof import_async10.TimeoutError) {
|
|
3244
|
-
(0, import_log9.log)("timeout", {
|
|
3245
|
-
...handler.toJSON()
|
|
3246
|
-
}, {
|
|
3247
|
-
F: __dxlog_file11,
|
|
3248
|
-
L: 253,
|
|
3249
|
-
S: this,
|
|
3250
|
-
C: (f, a) => f(...a)
|
|
3251
|
-
});
|
|
3252
|
-
stream.next({
|
|
3253
|
-
...initialState,
|
|
3254
|
-
state: import_services8.Invitation.State.TIMEOUT
|
|
3255
|
-
});
|
|
3256
|
-
} else {
|
|
3257
|
-
import_log9.log.warn("auth failed", err, {
|
|
3258
|
-
F: __dxlog_file11,
|
|
3259
|
-
L: 256,
|
|
3260
|
-
S: this,
|
|
3261
|
-
C: (f, a) => f(...a)
|
|
3262
|
-
});
|
|
3263
|
-
stream.next({
|
|
3264
|
-
...initialState,
|
|
3265
|
-
state: import_services8.Invitation.State.ERROR
|
|
3266
|
-
});
|
|
3267
|
-
}
|
|
3268
|
-
void ctx.dispose();
|
|
3269
|
-
}
|
|
3270
|
-
});
|
|
3271
|
-
ctx.onDispose(() => {
|
|
3272
|
-
(0, import_log9.log)("complete", {
|
|
3273
|
-
...handler.toJSON()
|
|
3274
|
-
}, {
|
|
3275
|
-
F: __dxlog_file11,
|
|
3276
|
-
L: 263,
|
|
3277
|
-
S: this,
|
|
3278
|
-
C: (f, a) => f(...a)
|
|
3279
|
-
});
|
|
3280
|
-
stream.complete();
|
|
3281
|
-
});
|
|
3282
|
-
const invitation = new import_client_protocol3.AuthenticatingInvitation({
|
|
3283
|
-
initialInvitation: initialState,
|
|
3284
|
-
subscriber: stream.observable,
|
|
3285
|
-
onCancel: async () => {
|
|
3286
|
-
stream.next({
|
|
3287
|
-
...initialState,
|
|
3288
|
-
state: import_services8.Invitation.State.CANCELLED
|
|
3289
|
-
});
|
|
3290
|
-
await ctx.dispose();
|
|
3291
|
-
},
|
|
3292
|
-
onAuthenticate: async (code) => {
|
|
3293
|
-
otpEnteredTrigger.wake(code);
|
|
3294
|
-
}
|
|
3295
|
-
});
|
|
3296
|
-
return {
|
|
3297
|
-
ctx,
|
|
3298
|
-
invitation,
|
|
3299
|
-
stream,
|
|
3300
|
-
otpEnteredTrigger
|
|
3301
|
-
};
|
|
3302
|
-
}
|
|
3303
2955
|
async _persistIfRequired(handler, changeStream, invitation) {
|
|
3304
|
-
if (invitation.type ===
|
|
2956
|
+
if (invitation.type === import_services7.Invitation.Type.DELEGATED && invitation.delegationCredentialId == null) {
|
|
3305
2957
|
const delegationCredentialId = await handler.delegate(invitation);
|
|
3306
2958
|
changeStream.next({
|
|
3307
2959
|
...invitation,
|
|
@@ -3316,9 +2968,9 @@ var InvitationsManager = class {
|
|
|
3316
2968
|
try {
|
|
3317
2969
|
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
3318
2970
|
} catch (err) {
|
|
3319
|
-
|
|
3320
|
-
F:
|
|
3321
|
-
L:
|
|
2971
|
+
import_log7.log.catch(err, void 0, {
|
|
2972
|
+
F: __dxlog_file9,
|
|
2973
|
+
L: 260,
|
|
3322
2974
|
S: this,
|
|
3323
2975
|
C: (f, a) => f(...a)
|
|
3324
2976
|
});
|
|
@@ -3410,7 +3062,7 @@ var AutomergeSpaceState = class {
|
|
|
3410
3062
|
this._onNewRoot = _onNewRoot;
|
|
3411
3063
|
this.rootUrl = void 0;
|
|
3412
3064
|
this.lastEpoch = void 0;
|
|
3413
|
-
this.onNewEpoch = new
|
|
3065
|
+
this.onNewEpoch = new import_async11.Event();
|
|
3414
3066
|
this._isProcessingRootDocs = false;
|
|
3415
3067
|
}
|
|
3416
3068
|
async processCredential(credential) {
|
|
@@ -3439,18 +3091,18 @@ var AutomergeSpaceState = class {
|
|
|
3439
3091
|
await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
|
|
3440
3092
|
}
|
|
3441
3093
|
};
|
|
3442
|
-
var
|
|
3094
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
3443
3095
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
3444
3096
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
3445
3097
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
3446
3098
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
3447
3099
|
var NotarizationPlugin = class {
|
|
3448
3100
|
constructor() {
|
|
3449
|
-
this._ctx = new
|
|
3450
|
-
this._extensionOpened = new
|
|
3101
|
+
this._ctx = new import_context8.Context();
|
|
3102
|
+
this._extensionOpened = new import_async12.Event();
|
|
3451
3103
|
this._extensions = /* @__PURE__ */ new Set();
|
|
3452
|
-
this._processedCredentials = new
|
|
3453
|
-
this._processCredentialsTriggers = new
|
|
3104
|
+
this._processedCredentials = new import_util5.ComplexSet(import_keys9.PublicKey.hash);
|
|
3105
|
+
this._processCredentialsTriggers = new import_util5.ComplexMap(import_keys9.PublicKey.hash);
|
|
3454
3106
|
}
|
|
3455
3107
|
get hasWriter() {
|
|
3456
3108
|
return !!this._writer;
|
|
@@ -3464,16 +3116,16 @@ var NotarizationPlugin = class {
|
|
|
3464
3116
|
* Request credentials to be notarized.
|
|
3465
3117
|
*/
|
|
3466
3118
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
3467
|
-
(0,
|
|
3119
|
+
(0, import_log9.log)("notarize", {
|
|
3468
3120
|
credentials
|
|
3469
3121
|
}, {
|
|
3470
|
-
F:
|
|
3122
|
+
F: __dxlog_file10,
|
|
3471
3123
|
L: 90,
|
|
3472
3124
|
S: this,
|
|
3473
3125
|
C: (f, a) => f(...a)
|
|
3474
3126
|
});
|
|
3475
|
-
(0,
|
|
3476
|
-
F:
|
|
3127
|
+
(0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
3128
|
+
F: __dxlog_file10,
|
|
3477
3129
|
L: 91,
|
|
3478
3130
|
S: this,
|
|
3479
3131
|
A: [
|
|
@@ -3481,13 +3133,13 @@ var NotarizationPlugin = class {
|
|
|
3481
3133
|
"'Credentials must have an id'"
|
|
3482
3134
|
]
|
|
3483
3135
|
});
|
|
3484
|
-
const errors = new
|
|
3136
|
+
const errors = new import_async12.Trigger();
|
|
3485
3137
|
const ctx = this._ctx.derive({
|
|
3486
3138
|
onError: (err) => {
|
|
3487
|
-
|
|
3139
|
+
import_log9.log.warn("Notarization error", {
|
|
3488
3140
|
err
|
|
3489
3141
|
}, {
|
|
3490
|
-
F:
|
|
3142
|
+
F: __dxlog_file10,
|
|
3491
3143
|
L: 99,
|
|
3492
3144
|
S: this,
|
|
3493
3145
|
C: (f, a) => f(...a)
|
|
@@ -3498,23 +3150,23 @@ var NotarizationPlugin = class {
|
|
|
3498
3150
|
});
|
|
3499
3151
|
opCtx?.onDispose(() => ctx.dispose());
|
|
3500
3152
|
if (timeout !== 0) {
|
|
3501
|
-
(0,
|
|
3502
|
-
|
|
3153
|
+
(0, import_async12.scheduleTask)(ctx, () => {
|
|
3154
|
+
import_log9.log.warn("Notarization timeout", {
|
|
3503
3155
|
timeout,
|
|
3504
3156
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3505
3157
|
}, {
|
|
3506
|
-
F:
|
|
3158
|
+
F: __dxlog_file10,
|
|
3507
3159
|
L: 111,
|
|
3508
3160
|
S: this,
|
|
3509
3161
|
C: (f, a) => f(...a)
|
|
3510
3162
|
});
|
|
3511
3163
|
void ctx.dispose();
|
|
3512
|
-
errors.throw(new
|
|
3164
|
+
errors.throw(new import_async12.TimeoutError(timeout, "Notarization timed out"));
|
|
3513
3165
|
}, timeout);
|
|
3514
3166
|
}
|
|
3515
3167
|
const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
|
|
3516
3168
|
const peersTried = /* @__PURE__ */ new Set();
|
|
3517
|
-
const notarizeTask = new
|
|
3169
|
+
const notarizeTask = new import_async12.DeferredTask(ctx, async () => {
|
|
3518
3170
|
try {
|
|
3519
3171
|
if (this._extensions.size === 0) {
|
|
3520
3172
|
return;
|
|
@@ -3523,24 +3175,24 @@ var NotarizationPlugin = class {
|
|
|
3523
3175
|
...this._extensions
|
|
3524
3176
|
].find((peer2) => !peersTried.has(peer2));
|
|
3525
3177
|
if (!peer) {
|
|
3526
|
-
|
|
3178
|
+
import_log9.log.info("Exhausted all peers to notarize with", {
|
|
3527
3179
|
retryIn: retryTimeout
|
|
3528
3180
|
}, {
|
|
3529
|
-
F:
|
|
3181
|
+
F: __dxlog_file10,
|
|
3530
3182
|
L: 136,
|
|
3531
3183
|
S: this,
|
|
3532
3184
|
C: (f, a) => f(...a)
|
|
3533
3185
|
});
|
|
3534
3186
|
peersTried.clear();
|
|
3535
|
-
(0,
|
|
3187
|
+
(0, import_async12.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
3536
3188
|
return;
|
|
3537
3189
|
}
|
|
3538
3190
|
peersTried.add(peer);
|
|
3539
|
-
(0,
|
|
3191
|
+
(0, import_log9.log)("try notarizing", {
|
|
3540
3192
|
peer: peer.localPeerId,
|
|
3541
3193
|
credentialId: credentials.map((credential) => credential.id)
|
|
3542
3194
|
}, {
|
|
3543
|
-
F:
|
|
3195
|
+
F: __dxlog_file10,
|
|
3544
3196
|
L: 143,
|
|
3545
3197
|
S: this,
|
|
3546
3198
|
C: (f, a) => f(...a)
|
|
@@ -3548,17 +3200,17 @@ var NotarizationPlugin = class {
|
|
|
3548
3200
|
await peer.rpc.NotarizationService.notarize({
|
|
3549
3201
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
3550
3202
|
});
|
|
3551
|
-
(0,
|
|
3552
|
-
F:
|
|
3203
|
+
(0, import_log9.log)("success", void 0, {
|
|
3204
|
+
F: __dxlog_file10,
|
|
3553
3205
|
L: 147,
|
|
3554
3206
|
S: this,
|
|
3555
3207
|
C: (f, a) => f(...a)
|
|
3556
3208
|
});
|
|
3557
|
-
await (0,
|
|
3209
|
+
await (0, import_async12.sleep)(successDelay);
|
|
3558
3210
|
} catch (err) {
|
|
3559
3211
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
3560
|
-
|
|
3561
|
-
F:
|
|
3212
|
+
import_log9.log.info("error notarizing (recoverable)", err, {
|
|
3213
|
+
F: __dxlog_file10,
|
|
3562
3214
|
L: 151,
|
|
3563
3215
|
S: this,
|
|
3564
3216
|
C: (f, a) => f(...a)
|
|
@@ -3571,12 +3223,12 @@ var NotarizationPlugin = class {
|
|
|
3571
3223
|
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
3572
3224
|
try {
|
|
3573
3225
|
await Promise.race([
|
|
3574
|
-
(0,
|
|
3226
|
+
(0, import_context8.rejectOnDispose)(ctx),
|
|
3575
3227
|
allNotarized,
|
|
3576
3228
|
errors.wait()
|
|
3577
3229
|
]);
|
|
3578
|
-
(0,
|
|
3579
|
-
F:
|
|
3230
|
+
(0, import_log9.log)("done", void 0, {
|
|
3231
|
+
F: __dxlog_file10,
|
|
3580
3232
|
L: 162,
|
|
3581
3233
|
S: this,
|
|
3582
3234
|
C: (f, a) => f(...a)
|
|
@@ -3597,8 +3249,8 @@ var NotarizationPlugin = class {
|
|
|
3597
3249
|
this._processCredentialsTriggers.delete(credential.id);
|
|
3598
3250
|
}
|
|
3599
3251
|
setWriter(writer) {
|
|
3600
|
-
(0,
|
|
3601
|
-
F:
|
|
3252
|
+
(0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
|
|
3253
|
+
F: __dxlog_file10,
|
|
3602
3254
|
L: 181,
|
|
3603
3255
|
S: this,
|
|
3604
3256
|
A: [
|
|
@@ -3612,7 +3264,7 @@ var NotarizationPlugin = class {
|
|
|
3612
3264
|
if (this._processedCredentials.has(id)) {
|
|
3613
3265
|
return;
|
|
3614
3266
|
}
|
|
3615
|
-
await (0,
|
|
3267
|
+
await (0, import_util5.entry)(this._processCredentialsTriggers, id).orInsert(new import_async12.Trigger()).value.wait();
|
|
3616
3268
|
}
|
|
3617
3269
|
/**
|
|
3618
3270
|
* Requests from other peers to notarize credentials.
|
|
@@ -3622,8 +3274,8 @@ var NotarizationPlugin = class {
|
|
|
3622
3274
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
3623
3275
|
}
|
|
3624
3276
|
for (const credential of request.credentials ?? []) {
|
|
3625
|
-
(0,
|
|
3626
|
-
F:
|
|
3277
|
+
(0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
|
|
3278
|
+
F: __dxlog_file10,
|
|
3627
3279
|
L: 200,
|
|
3628
3280
|
S: this,
|
|
3629
3281
|
A: [
|
|
@@ -3640,10 +3292,10 @@ var NotarizationPlugin = class {
|
|
|
3640
3292
|
createExtension() {
|
|
3641
3293
|
const extension = new NotarizationTeleportExtension({
|
|
3642
3294
|
onOpen: async () => {
|
|
3643
|
-
(0,
|
|
3295
|
+
(0, import_log9.log)("extension opened", {
|
|
3644
3296
|
peer: extension.localPeerId
|
|
3645
3297
|
}, {
|
|
3646
|
-
F:
|
|
3298
|
+
F: __dxlog_file10,
|
|
3647
3299
|
L: 211,
|
|
3648
3300
|
S: this,
|
|
3649
3301
|
C: (f, a) => f(...a)
|
|
@@ -3652,10 +3304,10 @@ var NotarizationPlugin = class {
|
|
|
3652
3304
|
this._extensionOpened.emit();
|
|
3653
3305
|
},
|
|
3654
3306
|
onClose: async () => {
|
|
3655
|
-
(0,
|
|
3307
|
+
(0, import_log9.log)("extension closed", {
|
|
3656
3308
|
peer: extension.localPeerId
|
|
3657
3309
|
}, {
|
|
3658
|
-
F:
|
|
3310
|
+
F: __dxlog_file10,
|
|
3659
3311
|
L: 216,
|
|
3660
3312
|
S: this,
|
|
3661
3313
|
C: (f, a) => f(...a)
|
|
@@ -3667,14 +3319,14 @@ var NotarizationPlugin = class {
|
|
|
3667
3319
|
return extension;
|
|
3668
3320
|
}
|
|
3669
3321
|
};
|
|
3670
|
-
var NotarizationTeleportExtension = class extends
|
|
3322
|
+
var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension {
|
|
3671
3323
|
constructor(_params) {
|
|
3672
3324
|
super({
|
|
3673
3325
|
requested: {
|
|
3674
|
-
NotarizationService:
|
|
3326
|
+
NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3675
3327
|
},
|
|
3676
3328
|
exposed: {
|
|
3677
|
-
NotarizationService:
|
|
3329
|
+
NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3678
3330
|
}
|
|
3679
3331
|
});
|
|
3680
3332
|
this._params = _params;
|
|
@@ -3707,16 +3359,16 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3707
3359
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3708
3360
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3709
3361
|
}
|
|
3710
|
-
var
|
|
3362
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3711
3363
|
var DataSpace = class {
|
|
3712
3364
|
constructor(params) {
|
|
3713
|
-
this._ctx = new
|
|
3365
|
+
this._ctx = new import_context7.Context();
|
|
3714
3366
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3715
3367
|
this._cache = void 0;
|
|
3716
3368
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
3717
|
-
this._state =
|
|
3369
|
+
this._state = import_services8.SpaceState.CLOSED;
|
|
3718
3370
|
this.error = void 0;
|
|
3719
|
-
this.stateUpdate = new
|
|
3371
|
+
this.stateUpdate = new import_async10.Event();
|
|
3720
3372
|
this.metrics = {};
|
|
3721
3373
|
this._inner = params.inner;
|
|
3722
3374
|
this._inner.stateUpdate.on(this._ctx, () => this.stateUpdate.emit());
|
|
@@ -3729,16 +3381,16 @@ var DataSpace = class {
|
|
|
3729
3381
|
this._callbacks = params.callbacks ?? {};
|
|
3730
3382
|
this._echoHost = params.echoHost;
|
|
3731
3383
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
3732
|
-
trustedKeysProvider: () => new
|
|
3384
|
+
trustedKeysProvider: () => new import_util4.ComplexSet(import_keys8.PublicKey.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => !member.removed).map((member) => member.key)),
|
|
3733
3385
|
update: this._inner.stateUpdate,
|
|
3734
3386
|
authTimeout: import_client_protocol4.AUTH_TIMEOUT
|
|
3735
3387
|
});
|
|
3736
3388
|
this._cache = params.cache;
|
|
3737
3389
|
this._state = params.initialState;
|
|
3738
|
-
(0,
|
|
3739
|
-
state:
|
|
3390
|
+
(0, import_log8.log)("new state", {
|
|
3391
|
+
state: import_services8.SpaceState[this._state]
|
|
3740
3392
|
}, {
|
|
3741
|
-
F:
|
|
3393
|
+
F: __dxlog_file11,
|
|
3742
3394
|
L: 136,
|
|
3743
3395
|
S: this,
|
|
3744
3396
|
C: (f, a) => f(...a)
|
|
@@ -3783,12 +3435,12 @@ var DataSpace = class {
|
|
|
3783
3435
|
await this._notarizationPlugin.open();
|
|
3784
3436
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3785
3437
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3786
|
-
await this._inner.open(new
|
|
3787
|
-
this._state =
|
|
3788
|
-
(0,
|
|
3789
|
-
state:
|
|
3438
|
+
await this._inner.open(new import_context7.Context());
|
|
3439
|
+
this._state = import_services8.SpaceState.CONTROL_ONLY;
|
|
3440
|
+
(0, import_log8.log)("new state", {
|
|
3441
|
+
state: import_services8.SpaceState[this._state]
|
|
3790
3442
|
}, {
|
|
3791
|
-
F:
|
|
3443
|
+
F: __dxlog_file11,
|
|
3792
3444
|
L: 194,
|
|
3793
3445
|
S: this,
|
|
3794
3446
|
C: (f, a) => f(...a)
|
|
@@ -3802,17 +3454,17 @@ var DataSpace = class {
|
|
|
3802
3454
|
}
|
|
3803
3455
|
async _close() {
|
|
3804
3456
|
await this._callbacks.beforeClose?.();
|
|
3805
|
-
this._state =
|
|
3806
|
-
(0,
|
|
3807
|
-
state:
|
|
3457
|
+
this._state = import_services8.SpaceState.CLOSED;
|
|
3458
|
+
(0, import_log8.log)("new state", {
|
|
3459
|
+
state: import_services8.SpaceState[this._state]
|
|
3808
3460
|
}, {
|
|
3809
|
-
F:
|
|
3461
|
+
F: __dxlog_file11,
|
|
3810
3462
|
L: 208,
|
|
3811
3463
|
S: this,
|
|
3812
3464
|
C: (f, a) => f(...a)
|
|
3813
3465
|
});
|
|
3814
3466
|
await this._ctx.dispose();
|
|
3815
|
-
this._ctx = new
|
|
3467
|
+
this._ctx = new import_context7.Context();
|
|
3816
3468
|
await this.authVerifier.close();
|
|
3817
3469
|
await this._inner.close();
|
|
3818
3470
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
@@ -3831,31 +3483,31 @@ var DataSpace = class {
|
|
|
3831
3483
|
* Initialize the data pipeline in a separate task.
|
|
3832
3484
|
*/
|
|
3833
3485
|
initializeDataPipelineAsync() {
|
|
3834
|
-
(0,
|
|
3486
|
+
(0, import_async10.scheduleTask)(this._ctx, async () => {
|
|
3835
3487
|
try {
|
|
3836
3488
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3837
3489
|
await this.initializeDataPipeline();
|
|
3838
3490
|
} catch (err) {
|
|
3839
|
-
if (err instanceof
|
|
3840
|
-
(0,
|
|
3841
|
-
F:
|
|
3491
|
+
if (err instanceof import_protocols7.CancelledError || err instanceof import_context7.ContextDisposedError) {
|
|
3492
|
+
(0, import_log8.log)("data pipeline initialization cancelled", err, {
|
|
3493
|
+
F: __dxlog_file11,
|
|
3842
3494
|
L: 241,
|
|
3843
3495
|
S: this,
|
|
3844
3496
|
C: (f, a) => f(...a)
|
|
3845
3497
|
});
|
|
3846
3498
|
return;
|
|
3847
3499
|
}
|
|
3848
|
-
|
|
3849
|
-
F:
|
|
3500
|
+
import_log8.log.error("Error initializing data pipeline", err, {
|
|
3501
|
+
F: __dxlog_file11,
|
|
3850
3502
|
L: 245,
|
|
3851
3503
|
S: this,
|
|
3852
3504
|
C: (f, a) => f(...a)
|
|
3853
3505
|
});
|
|
3854
|
-
this._state =
|
|
3855
|
-
(0,
|
|
3856
|
-
state:
|
|
3506
|
+
this._state = import_services8.SpaceState.ERROR;
|
|
3507
|
+
(0, import_log8.log)("new state", {
|
|
3508
|
+
state: import_services8.SpaceState[this._state]
|
|
3857
3509
|
}, {
|
|
3858
|
-
F:
|
|
3510
|
+
F: __dxlog_file11,
|
|
3859
3511
|
L: 247,
|
|
3860
3512
|
S: this,
|
|
3861
3513
|
C: (f, a) => f(...a)
|
|
@@ -3868,34 +3520,34 @@ var DataSpace = class {
|
|
|
3868
3520
|
});
|
|
3869
3521
|
}
|
|
3870
3522
|
async initializeDataPipeline() {
|
|
3871
|
-
if (this._state !==
|
|
3872
|
-
throw new
|
|
3523
|
+
if (this._state !== import_services8.SpaceState.CONTROL_ONLY) {
|
|
3524
|
+
throw new import_protocols7.SystemError("Invalid operation");
|
|
3873
3525
|
}
|
|
3874
|
-
this._state =
|
|
3875
|
-
(0,
|
|
3876
|
-
state:
|
|
3526
|
+
this._state = import_services8.SpaceState.INITIALIZING;
|
|
3527
|
+
(0, import_log8.log)("new state", {
|
|
3528
|
+
state: import_services8.SpaceState[this._state]
|
|
3877
3529
|
}, {
|
|
3878
|
-
F:
|
|
3530
|
+
F: __dxlog_file11,
|
|
3879
3531
|
L: 263,
|
|
3880
3532
|
S: this,
|
|
3881
3533
|
C: (f, a) => f(...a)
|
|
3882
3534
|
});
|
|
3883
3535
|
await this._initializeAndReadControlPipeline();
|
|
3884
|
-
await (0,
|
|
3536
|
+
await (0, import_async10.sleep)(1);
|
|
3885
3537
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
3886
|
-
await (0,
|
|
3887
|
-
(0,
|
|
3888
|
-
F:
|
|
3538
|
+
await (0, import_context7.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
3539
|
+
(0, import_log8.log)("data pipeline ready", void 0, {
|
|
3540
|
+
F: __dxlog_file11,
|
|
3889
3541
|
L: 275,
|
|
3890
3542
|
S: this,
|
|
3891
3543
|
C: (f, a) => f(...a)
|
|
3892
3544
|
});
|
|
3893
3545
|
await this._callbacks.beforeReady?.();
|
|
3894
|
-
this._state =
|
|
3895
|
-
(0,
|
|
3896
|
-
state:
|
|
3546
|
+
this._state = import_services8.SpaceState.READY;
|
|
3547
|
+
(0, import_log8.log)("new state", {
|
|
3548
|
+
state: import_services8.SpaceState[this._state]
|
|
3897
3549
|
}, {
|
|
3898
|
-
F:
|
|
3550
|
+
F: __dxlog_file11,
|
|
3899
3551
|
L: 279,
|
|
3900
3552
|
S: this,
|
|
3901
3553
|
C: (f, a) => f(...a)
|
|
@@ -3910,8 +3562,8 @@ var DataSpace = class {
|
|
|
3910
3562
|
});
|
|
3911
3563
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
3912
3564
|
await this._createWritableFeeds();
|
|
3913
|
-
(0,
|
|
3914
|
-
F:
|
|
3565
|
+
(0, import_log8.log)("writable feeds created", void 0, {
|
|
3566
|
+
F: __dxlog_file11,
|
|
3915
3567
|
L: 295,
|
|
3916
3568
|
S: this,
|
|
3917
3569
|
C: (f, a) => f(...a)
|
|
@@ -3970,11 +3622,11 @@ var DataSpace = class {
|
|
|
3970
3622
|
}
|
|
3971
3623
|
}
|
|
3972
3624
|
_onNewAutomergeRoot(rootUrl) {
|
|
3973
|
-
(0,
|
|
3625
|
+
(0, import_log8.log)("loading automerge root doc for space", {
|
|
3974
3626
|
space: this.key,
|
|
3975
3627
|
rootUrl
|
|
3976
3628
|
}, {
|
|
3977
|
-
F:
|
|
3629
|
+
F: __dxlog_file11,
|
|
3978
3630
|
L: 361,
|
|
3979
3631
|
S: this,
|
|
3980
3632
|
C: (f, a) => f(...a)
|
|
@@ -3984,12 +3636,12 @@ var DataSpace = class {
|
|
|
3984
3636
|
queueMicrotask(async () => {
|
|
3985
3637
|
try {
|
|
3986
3638
|
await (0, import_debug3.warnAfterTimeout)(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
3987
|
-
await (0,
|
|
3639
|
+
await (0, import_context7.cancelWithContext)(this._ctx, handle.whenReady());
|
|
3988
3640
|
});
|
|
3989
3641
|
if (this._ctx.disposed) {
|
|
3990
3642
|
return;
|
|
3991
3643
|
}
|
|
3992
|
-
const doc = handle.docSync() ?? (0,
|
|
3644
|
+
const doc = handle.docSync() ?? (0, import_invariant9.failedInvariant)();
|
|
3993
3645
|
if (!doc.access?.spaceKey) {
|
|
3994
3646
|
handle.change((doc2) => {
|
|
3995
3647
|
doc2.access = {
|
|
@@ -3998,15 +3650,15 @@ var DataSpace = class {
|
|
|
3998
3650
|
});
|
|
3999
3651
|
}
|
|
4000
3652
|
} catch (err) {
|
|
4001
|
-
if (err instanceof
|
|
3653
|
+
if (err instanceof import_context7.ContextDisposedError) {
|
|
4002
3654
|
return;
|
|
4003
3655
|
}
|
|
4004
|
-
|
|
3656
|
+
import_log8.log.warn("error loading automerge root doc", {
|
|
4005
3657
|
space: this.key,
|
|
4006
3658
|
rootUrl,
|
|
4007
3659
|
err
|
|
4008
3660
|
}, {
|
|
4009
|
-
F:
|
|
3661
|
+
F: __dxlog_file11,
|
|
4010
3662
|
L: 384,
|
|
4011
3663
|
S: this,
|
|
4012
3664
|
C: (f, a) => f(...a)
|
|
@@ -4033,7 +3685,7 @@ var DataSpace = class {
|
|
|
4033
3685
|
let epoch;
|
|
4034
3686
|
switch (options?.migration) {
|
|
4035
3687
|
case void 0:
|
|
4036
|
-
case
|
|
3688
|
+
case import_services8.CreateEpochRequest.Migration.NONE:
|
|
4037
3689
|
{
|
|
4038
3690
|
epoch = {
|
|
4039
3691
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
@@ -4043,7 +3695,7 @@ var DataSpace = class {
|
|
|
4043
3695
|
};
|
|
4044
3696
|
}
|
|
4045
3697
|
break;
|
|
4046
|
-
case
|
|
3698
|
+
case import_services8.CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
4047
3699
|
{
|
|
4048
3700
|
const document = this._echoHost.automergeRepo.create();
|
|
4049
3701
|
epoch = {
|
|
@@ -4054,14 +3706,14 @@ var DataSpace = class {
|
|
|
4054
3706
|
};
|
|
4055
3707
|
}
|
|
4056
3708
|
break;
|
|
4057
|
-
case
|
|
3709
|
+
case import_services8.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
4058
3710
|
{
|
|
4059
3711
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
4060
3712
|
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
4061
|
-
await (0,
|
|
3713
|
+
await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
4062
3714
|
const newRoot = this._echoHost.automergeRepo.create(rootHandle.docSync());
|
|
4063
|
-
(0,
|
|
4064
|
-
F:
|
|
3715
|
+
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3716
|
+
F: __dxlog_file11,
|
|
4065
3717
|
L: 434,
|
|
4066
3718
|
S: this,
|
|
4067
3719
|
A: [
|
|
@@ -4077,22 +3729,22 @@ var DataSpace = class {
|
|
|
4077
3729
|
};
|
|
4078
3730
|
}
|
|
4079
3731
|
break;
|
|
4080
|
-
case
|
|
3732
|
+
case import_services8.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
4081
3733
|
{
|
|
4082
|
-
|
|
4083
|
-
F:
|
|
3734
|
+
import_log8.log.info("Fragmenting", void 0, {
|
|
3735
|
+
F: __dxlog_file11,
|
|
4084
3736
|
L: 446,
|
|
4085
3737
|
S: this,
|
|
4086
3738
|
C: (f, a) => f(...a)
|
|
4087
3739
|
});
|
|
4088
3740
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
4089
3741
|
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
4090
|
-
await (0,
|
|
3742
|
+
await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
4091
3743
|
const objects = Object.entries(rootHandle.docSync().objects);
|
|
4092
3744
|
const properties = objects.find(([_, value]) => value.system.type?.itemId === import_echo_schema.TYPE_PROPERTIES);
|
|
4093
3745
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
4094
|
-
(0,
|
|
4095
|
-
F:
|
|
3746
|
+
(0, import_invariant9.invariant)(properties, "Properties not found", {
|
|
3747
|
+
F: __dxlog_file11,
|
|
4096
3748
|
L: 456,
|
|
4097
3749
|
S: this,
|
|
4098
3750
|
A: [
|
|
@@ -4107,8 +3759,8 @@ var DataSpace = class {
|
|
|
4107
3759
|
])
|
|
4108
3760
|
};
|
|
4109
3761
|
const newRoot = this._echoHost.automergeRepo.create(newSpaceDoc);
|
|
4110
|
-
(0,
|
|
4111
|
-
F:
|
|
3762
|
+
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3763
|
+
F: __dxlog_file11,
|
|
4112
3764
|
L: 461,
|
|
4113
3765
|
S: this,
|
|
4114
3766
|
A: [
|
|
@@ -4123,7 +3775,7 @@ var DataSpace = class {
|
|
|
4123
3775
|
otherObjects.forEach(([key, value]) => {
|
|
4124
3776
|
const handle = docLoader.createDocumentForObject(key);
|
|
4125
3777
|
handle.change((doc) => {
|
|
4126
|
-
(0,
|
|
3778
|
+
(0, import_util4.assignDeep)(doc, [
|
|
4127
3779
|
"objects",
|
|
4128
3780
|
key
|
|
4129
3781
|
], value);
|
|
@@ -4160,24 +3812,24 @@ var DataSpace = class {
|
|
|
4160
3812
|
]));
|
|
4161
3813
|
}
|
|
4162
3814
|
async activate() {
|
|
4163
|
-
if (this._state !==
|
|
3815
|
+
if (this._state !== import_services8.SpaceState.INACTIVE) {
|
|
4164
3816
|
return;
|
|
4165
3817
|
}
|
|
4166
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3818
|
+
await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.ACTIVE);
|
|
4167
3819
|
await this._open();
|
|
4168
3820
|
this.initializeDataPipelineAsync();
|
|
4169
3821
|
}
|
|
4170
3822
|
async deactivate() {
|
|
4171
|
-
if (this._state ===
|
|
3823
|
+
if (this._state === import_services8.SpaceState.INACTIVE) {
|
|
4172
3824
|
return;
|
|
4173
3825
|
}
|
|
4174
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3826
|
+
await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.INACTIVE);
|
|
4175
3827
|
await this._close();
|
|
4176
|
-
this._state =
|
|
4177
|
-
(0,
|
|
4178
|
-
state:
|
|
3828
|
+
this._state = import_services8.SpaceState.INACTIVE;
|
|
3829
|
+
(0, import_log8.log)("new state", {
|
|
3830
|
+
state: import_services8.SpaceState[this._state]
|
|
4179
3831
|
}, {
|
|
4180
|
-
F:
|
|
3832
|
+
F: __dxlog_file11,
|
|
4181
3833
|
L: 527,
|
|
4182
3834
|
S: this,
|
|
4183
3835
|
C: (f, a) => f(...a)
|
|
@@ -4193,7 +3845,7 @@ _ts_decorate4([
|
|
|
4193
3845
|
], DataSpace.prototype, "key", null);
|
|
4194
3846
|
_ts_decorate4([
|
|
4195
3847
|
import_tracing4.trace.info({
|
|
4196
|
-
enum:
|
|
3848
|
+
enum: import_services8.SpaceState
|
|
4197
3849
|
})
|
|
4198
3850
|
], DataSpace.prototype, "state", null);
|
|
4199
3851
|
_ts_decorate4([
|
|
@@ -4202,10 +3854,10 @@ _ts_decorate4([
|
|
|
4202
3854
|
})
|
|
4203
3855
|
], DataSpace.prototype, "_automergeInfo", null);
|
|
4204
3856
|
_ts_decorate4([
|
|
4205
|
-
|
|
3857
|
+
import_async10.synchronized
|
|
4206
3858
|
], DataSpace.prototype, "open", null);
|
|
4207
3859
|
_ts_decorate4([
|
|
4208
|
-
|
|
3860
|
+
import_async10.synchronized
|
|
4209
3861
|
], DataSpace.prototype, "close", null);
|
|
4210
3862
|
_ts_decorate4([
|
|
4211
3863
|
import_tracing4.trace.span({
|
|
@@ -4221,13 +3873,13 @@ _ts_decorate4([
|
|
|
4221
3873
|
(0, import_debug3.timed)(1e4)
|
|
4222
3874
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
4223
3875
|
_ts_decorate4([
|
|
4224
|
-
|
|
3876
|
+
import_async10.synchronized
|
|
4225
3877
|
], DataSpace.prototype, "activate", null);
|
|
4226
3878
|
_ts_decorate4([
|
|
4227
|
-
|
|
3879
|
+
import_async10.synchronized
|
|
4228
3880
|
], DataSpace.prototype, "deactivate", null);
|
|
4229
3881
|
DataSpace = _ts_decorate4([
|
|
4230
|
-
(0,
|
|
3882
|
+
(0, import_async10.trackLeaks)("open", "close"),
|
|
4231
3883
|
import_tracing4.trace.resource()
|
|
4232
3884
|
], DataSpace);
|
|
4233
3885
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
@@ -4304,7 +3956,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
4304
3956
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4305
3957
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4306
3958
|
}
|
|
4307
|
-
var
|
|
3959
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
4308
3960
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
4309
3961
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
4310
3962
|
var DataSpaceManager = class {
|
|
@@ -4316,11 +3968,11 @@ var DataSpaceManager = class {
|
|
|
4316
3968
|
this._feedStore = _feedStore;
|
|
4317
3969
|
this._echoHost = _echoHost;
|
|
4318
3970
|
this._invitationsManager = _invitationsManager;
|
|
4319
|
-
this._ctx = new
|
|
4320
|
-
this.updated = new
|
|
4321
|
-
this._spaces = new
|
|
3971
|
+
this._ctx = new import_context9.Context();
|
|
3972
|
+
this.updated = new import_async13.Event();
|
|
3973
|
+
this._spaces = new import_util6.ComplexMap(import_keys10.PublicKey.hash);
|
|
4322
3974
|
this._isOpen = false;
|
|
4323
|
-
this._instanceId =
|
|
3975
|
+
this._instanceId = import_keys10.PublicKey.random().toHex();
|
|
4324
3976
|
const { spaceMemberPresenceAnnounceInterval = PRESENCE_ANNOUNCE_INTERVAL, spaceMemberPresenceOfflineTimeout = PRESENCE_OFFLINE_TIMEOUT } = params ?? {};
|
|
4325
3977
|
this._spaceMemberPresenceAnnounceInterval = spaceMemberPresenceAnnounceInterval;
|
|
4326
3978
|
this._spaceMemberPresenceOfflineTimeout = spaceMemberPresenceOfflineTimeout;
|
|
@@ -4330,45 +3982,45 @@ var DataSpaceManager = class {
|
|
|
4330
3982
|
return this._spaces;
|
|
4331
3983
|
}
|
|
4332
3984
|
async open() {
|
|
4333
|
-
(0,
|
|
4334
|
-
F:
|
|
3985
|
+
(0, import_log10.log)("open", void 0, {
|
|
3986
|
+
F: __dxlog_file12,
|
|
4335
3987
|
L: 102,
|
|
4336
3988
|
S: this,
|
|
4337
3989
|
C: (f, a) => f(...a)
|
|
4338
3990
|
});
|
|
4339
|
-
|
|
3991
|
+
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols9.trace.begin({
|
|
4340
3992
|
id: this._instanceId
|
|
4341
3993
|
}), {
|
|
4342
|
-
F:
|
|
3994
|
+
F: __dxlog_file12,
|
|
4343
3995
|
L: 103,
|
|
4344
3996
|
S: this,
|
|
4345
3997
|
C: (f, a) => f(...a)
|
|
4346
3998
|
});
|
|
4347
|
-
(0,
|
|
3999
|
+
(0, import_log10.log)("metadata loaded", {
|
|
4348
4000
|
spaces: this._metadataStore.spaces.length
|
|
4349
4001
|
}, {
|
|
4350
|
-
F:
|
|
4002
|
+
F: __dxlog_file12,
|
|
4351
4003
|
L: 104,
|
|
4352
4004
|
S: this,
|
|
4353
4005
|
C: (f, a) => f(...a)
|
|
4354
4006
|
});
|
|
4355
|
-
await (0,
|
|
4007
|
+
await (0, import_util6.forEachAsync)(this._metadataStore.spaces, async (spaceMetadata) => {
|
|
4356
4008
|
try {
|
|
4357
|
-
(0,
|
|
4009
|
+
(0, import_log10.log)("load space", {
|
|
4358
4010
|
spaceMetadata
|
|
4359
4011
|
}, {
|
|
4360
|
-
F:
|
|
4012
|
+
F: __dxlog_file12,
|
|
4361
4013
|
L: 108,
|
|
4362
4014
|
S: this,
|
|
4363
4015
|
C: (f, a) => f(...a)
|
|
4364
4016
|
});
|
|
4365
4017
|
await this._constructSpace(spaceMetadata);
|
|
4366
4018
|
} catch (err) {
|
|
4367
|
-
|
|
4019
|
+
import_log10.log.error("Error loading space", {
|
|
4368
4020
|
spaceMetadata,
|
|
4369
4021
|
err
|
|
4370
4022
|
}, {
|
|
4371
|
-
F:
|
|
4023
|
+
F: __dxlog_file12,
|
|
4372
4024
|
L: 111,
|
|
4373
4025
|
S: this,
|
|
4374
4026
|
C: (f, a) => f(...a)
|
|
@@ -4378,22 +4030,22 @@ var DataSpaceManager = class {
|
|
|
4378
4030
|
this._isOpen = true;
|
|
4379
4031
|
this.updated.emit();
|
|
4380
4032
|
for (const space of this._spaces.values()) {
|
|
4381
|
-
if (space.state !==
|
|
4033
|
+
if (space.state !== import_services9.SpaceState.INACTIVE) {
|
|
4382
4034
|
space.initializeDataPipelineAsync();
|
|
4383
4035
|
}
|
|
4384
4036
|
}
|
|
4385
|
-
|
|
4037
|
+
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols9.trace.end({
|
|
4386
4038
|
id: this._instanceId
|
|
4387
4039
|
}), {
|
|
4388
|
-
F:
|
|
4040
|
+
F: __dxlog_file12,
|
|
4389
4041
|
L: 124,
|
|
4390
4042
|
S: this,
|
|
4391
4043
|
C: (f, a) => f(...a)
|
|
4392
4044
|
});
|
|
4393
4045
|
}
|
|
4394
4046
|
async close() {
|
|
4395
|
-
(0,
|
|
4396
|
-
F:
|
|
4047
|
+
(0, import_log10.log)("close", void 0, {
|
|
4048
|
+
F: __dxlog_file12,
|
|
4397
4049
|
L: 129,
|
|
4398
4050
|
S: this,
|
|
4399
4051
|
C: (f, a) => f(...a)
|
|
@@ -4408,8 +4060,8 @@ var DataSpaceManager = class {
|
|
|
4408
4060
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
4409
4061
|
*/
|
|
4410
4062
|
async createSpace() {
|
|
4411
|
-
(0,
|
|
4412
|
-
F:
|
|
4063
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
4064
|
+
F: __dxlog_file12,
|
|
4413
4065
|
L: 142,
|
|
4414
4066
|
S: this,
|
|
4415
4067
|
A: [
|
|
@@ -4425,12 +4077,12 @@ var DataSpaceManager = class {
|
|
|
4425
4077
|
genesisFeedKey: controlFeedKey,
|
|
4426
4078
|
controlFeedKey,
|
|
4427
4079
|
dataFeedKey,
|
|
4428
|
-
state:
|
|
4080
|
+
state: import_services9.SpaceState.ACTIVE
|
|
4429
4081
|
};
|
|
4430
|
-
(0,
|
|
4082
|
+
(0, import_log10.log)("creating space...", {
|
|
4431
4083
|
spaceKey
|
|
4432
4084
|
}, {
|
|
4433
|
-
F:
|
|
4085
|
+
F: __dxlog_file12,
|
|
4434
4086
|
L: 154,
|
|
4435
4087
|
S: this,
|
|
4436
4088
|
C: (f, a) => f(...a)
|
|
@@ -4440,8 +4092,8 @@ var DataSpaceManager = class {
|
|
|
4440
4092
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRootUrl);
|
|
4441
4093
|
await this._metadataStore.addSpace(metadata);
|
|
4442
4094
|
const memberCredential = credentials[1];
|
|
4443
|
-
(0,
|
|
4444
|
-
F:
|
|
4095
|
+
(0, import_invariant11.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4096
|
+
F: __dxlog_file12,
|
|
4445
4097
|
L: 163,
|
|
4446
4098
|
S: this,
|
|
4447
4099
|
A: [
|
|
@@ -4456,16 +4108,16 @@ var DataSpaceManager = class {
|
|
|
4456
4108
|
}
|
|
4457
4109
|
// TODO(burdon): Rename join space.
|
|
4458
4110
|
async acceptSpace(opts) {
|
|
4459
|
-
(0,
|
|
4111
|
+
(0, import_log10.log)("accept space", {
|
|
4460
4112
|
opts
|
|
4461
4113
|
}, {
|
|
4462
|
-
F:
|
|
4114
|
+
F: __dxlog_file12,
|
|
4463
4115
|
L: 175,
|
|
4464
4116
|
S: this,
|
|
4465
4117
|
C: (f, a) => f(...a)
|
|
4466
4118
|
});
|
|
4467
|
-
(0,
|
|
4468
|
-
F:
|
|
4119
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
4120
|
+
F: __dxlog_file12,
|
|
4469
4121
|
L: 176,
|
|
4470
4122
|
S: this,
|
|
4471
4123
|
A: [
|
|
@@ -4473,8 +4125,8 @@ var DataSpaceManager = class {
|
|
|
4473
4125
|
"'Not open.'"
|
|
4474
4126
|
]
|
|
4475
4127
|
});
|
|
4476
|
-
(0,
|
|
4477
|
-
F:
|
|
4128
|
+
(0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
4129
|
+
F: __dxlog_file12,
|
|
4478
4130
|
L: 177,
|
|
4479
4131
|
S: this,
|
|
4480
4132
|
A: [
|
|
@@ -4500,16 +4152,16 @@ var DataSpaceManager = class {
|
|
|
4500
4152
|
* TODO(dmaretskyi): Consider removing.
|
|
4501
4153
|
*/
|
|
4502
4154
|
async waitUntilSpaceReady(spaceKey) {
|
|
4503
|
-
await (0,
|
|
4155
|
+
await (0, import_context9.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
4504
4156
|
const space = this._spaces.get(spaceKey);
|
|
4505
|
-
return !!space && space.state ===
|
|
4157
|
+
return !!space && space.state === import_services9.SpaceState.READY;
|
|
4506
4158
|
}));
|
|
4507
4159
|
}
|
|
4508
4160
|
async _constructSpace(metadata) {
|
|
4509
|
-
(0,
|
|
4161
|
+
(0, import_log10.log)("construct space", {
|
|
4510
4162
|
metadata
|
|
4511
4163
|
}, {
|
|
4512
|
-
F:
|
|
4164
|
+
F: __dxlog_file12,
|
|
4513
4165
|
L: 210,
|
|
4514
4166
|
S: this,
|
|
4515
4167
|
C: (f, a) => f(...a)
|
|
@@ -4535,7 +4187,7 @@ var DataSpaceManager = class {
|
|
|
4535
4187
|
swarmIdentity: {
|
|
4536
4188
|
peerKey: this._signingContext.deviceKey,
|
|
4537
4189
|
credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
|
|
4538
|
-
credentialAuthenticator: (0,
|
|
4190
|
+
credentialAuthenticator: (0, import_util6.deferFunction)(() => dataSpace.authVerifier.verifier)
|
|
4539
4191
|
},
|
|
4540
4192
|
onAuthorizedConnection: (session) => {
|
|
4541
4193
|
session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
|
|
@@ -4546,8 +4198,8 @@ var DataSpaceManager = class {
|
|
|
4546
4198
|
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
4547
4199
|
},
|
|
4548
4200
|
onAuthFailure: () => {
|
|
4549
|
-
|
|
4550
|
-
F:
|
|
4201
|
+
import_log10.log.warn("auth failure", void 0, {
|
|
4202
|
+
F: __dxlog_file12,
|
|
4551
4203
|
L: 247,
|
|
4552
4204
|
S: this,
|
|
4553
4205
|
C: (f, a) => f(...a)
|
|
@@ -4562,7 +4214,7 @@ var DataSpaceManager = class {
|
|
|
4562
4214
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
4563
4215
|
const dataSpace = new DataSpace({
|
|
4564
4216
|
inner: space,
|
|
4565
|
-
initialState: metadata.state ===
|
|
4217
|
+
initialState: metadata.state === import_services9.SpaceState.INACTIVE ? import_services9.SpaceState.INACTIVE : import_services9.SpaceState.CLOSED,
|
|
4566
4218
|
metadataStore: this._metadataStore,
|
|
4567
4219
|
gossip,
|
|
4568
4220
|
presence,
|
|
@@ -4572,21 +4224,21 @@ var DataSpaceManager = class {
|
|
|
4572
4224
|
signingContext: this._signingContext,
|
|
4573
4225
|
callbacks: {
|
|
4574
4226
|
beforeReady: async () => {
|
|
4575
|
-
(0,
|
|
4227
|
+
(0, import_log10.log)("before space ready", {
|
|
4576
4228
|
space: space.key
|
|
4577
4229
|
}, {
|
|
4578
|
-
F:
|
|
4230
|
+
F: __dxlog_file12,
|
|
4579
4231
|
L: 269,
|
|
4580
4232
|
S: this,
|
|
4581
4233
|
C: (f, a) => f(...a)
|
|
4582
4234
|
});
|
|
4583
4235
|
},
|
|
4584
4236
|
afterReady: async () => {
|
|
4585
|
-
(0,
|
|
4237
|
+
(0, import_log10.log)("after space ready", {
|
|
4586
4238
|
space: space.key,
|
|
4587
4239
|
open: this._isOpen
|
|
4588
4240
|
}, {
|
|
4589
|
-
F:
|
|
4241
|
+
F: __dxlog_file12,
|
|
4590
4242
|
L: 272,
|
|
4591
4243
|
S: this,
|
|
4592
4244
|
C: (f, a) => f(...a)
|
|
@@ -4599,10 +4251,10 @@ var DataSpaceManager = class {
|
|
|
4599
4251
|
}
|
|
4600
4252
|
},
|
|
4601
4253
|
beforeClose: async () => {
|
|
4602
|
-
(0,
|
|
4254
|
+
(0, import_log10.log)("before space close", {
|
|
4603
4255
|
space: space.key
|
|
4604
4256
|
}, {
|
|
4605
|
-
F:
|
|
4257
|
+
F: __dxlog_file12,
|
|
4606
4258
|
L: 279,
|
|
4607
4259
|
S: this,
|
|
4608
4260
|
C: (f, a) => f(...a)
|
|
@@ -4611,7 +4263,7 @@ var DataSpaceManager = class {
|
|
|
4611
4263
|
},
|
|
4612
4264
|
cache: metadata.cache
|
|
4613
4265
|
});
|
|
4614
|
-
if (metadata.state !==
|
|
4266
|
+
if (metadata.state !== import_services9.SpaceState.INACTIVE) {
|
|
4615
4267
|
await dataSpace.open();
|
|
4616
4268
|
}
|
|
4617
4269
|
if (metadata.controlTimeframe) {
|
|
@@ -4621,7 +4273,7 @@ var DataSpaceManager = class {
|
|
|
4621
4273
|
return dataSpace;
|
|
4622
4274
|
}
|
|
4623
4275
|
async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
|
|
4624
|
-
if (dataSpace?.state !==
|
|
4276
|
+
if (dataSpace?.state !== import_services9.SpaceState.READY) {
|
|
4625
4277
|
return;
|
|
4626
4278
|
}
|
|
4627
4279
|
if (isActive) {
|
|
@@ -4638,8 +4290,8 @@ var DataSpaceManager = class {
|
|
|
4638
4290
|
async _createDelegatedInvitations(space, invitations) {
|
|
4639
4291
|
const tasks = invitations.map(([credentialId, invitation]) => {
|
|
4640
4292
|
return this._invitationsManager.createInvitation({
|
|
4641
|
-
type:
|
|
4642
|
-
kind:
|
|
4293
|
+
type: import_services9.Invitation.Type.DELEGATED,
|
|
4294
|
+
kind: import_services9.Invitation.Kind.SPACE,
|
|
4643
4295
|
spaceKey: space.key,
|
|
4644
4296
|
authMethod: invitation.authMethod,
|
|
4645
4297
|
invitationId: invitation.invitationId,
|
|
@@ -4657,21 +4309,21 @@ var DataSpaceManager = class {
|
|
|
4657
4309
|
}
|
|
4658
4310
|
};
|
|
4659
4311
|
_ts_decorate5([
|
|
4660
|
-
|
|
4312
|
+
import_async13.synchronized
|
|
4661
4313
|
], DataSpaceManager.prototype, "open", null);
|
|
4662
4314
|
_ts_decorate5([
|
|
4663
|
-
|
|
4315
|
+
import_async13.synchronized
|
|
4664
4316
|
], DataSpaceManager.prototype, "close", null);
|
|
4665
4317
|
_ts_decorate5([
|
|
4666
|
-
|
|
4318
|
+
import_async13.synchronized
|
|
4667
4319
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
4668
4320
|
_ts_decorate5([
|
|
4669
|
-
|
|
4321
|
+
import_async13.synchronized
|
|
4670
4322
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
4671
4323
|
DataSpaceManager = _ts_decorate5([
|
|
4672
|
-
(0,
|
|
4324
|
+
(0, import_async13.trackLeaks)("open", "close")
|
|
4673
4325
|
], DataSpaceManager);
|
|
4674
|
-
var
|
|
4326
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
4675
4327
|
var SpacesServiceImpl = class {
|
|
4676
4328
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
4677
4329
|
this._identityManager = _identityManager;
|
|
@@ -4688,29 +4340,29 @@ var SpacesServiceImpl = class {
|
|
|
4688
4340
|
}
|
|
4689
4341
|
async updateSpace({ spaceKey, state }) {
|
|
4690
4342
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4691
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4343
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4692
4344
|
if (state) {
|
|
4693
4345
|
switch (state) {
|
|
4694
|
-
case
|
|
4346
|
+
case import_services10.SpaceState.ACTIVE:
|
|
4695
4347
|
await space.activate();
|
|
4696
4348
|
break;
|
|
4697
|
-
case
|
|
4349
|
+
case import_services10.SpaceState.INACTIVE:
|
|
4698
4350
|
await space.deactivate();
|
|
4699
4351
|
break;
|
|
4700
4352
|
default:
|
|
4701
|
-
throw new
|
|
4353
|
+
throw new import_protocols10.ApiError("Invalid space state");
|
|
4702
4354
|
}
|
|
4703
4355
|
}
|
|
4704
4356
|
}
|
|
4705
4357
|
querySpaces() {
|
|
4706
4358
|
return new import_codec_protobuf10.Stream(({ next, ctx }) => {
|
|
4707
|
-
const scheduler = new
|
|
4359
|
+
const scheduler = new import_async14.UpdateScheduler(ctx, async () => {
|
|
4708
4360
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4709
4361
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
4710
|
-
(0,
|
|
4362
|
+
(0, import_log11.log)("update", {
|
|
4711
4363
|
spaces
|
|
4712
4364
|
}, {
|
|
4713
|
-
F:
|
|
4365
|
+
F: __dxlog_file13,
|
|
4714
4366
|
L: 77,
|
|
4715
4367
|
S: this,
|
|
4716
4368
|
C: (f, a) => f(...a)
|
|
@@ -4721,9 +4373,9 @@ var SpacesServiceImpl = class {
|
|
|
4721
4373
|
}, {
|
|
4722
4374
|
maxFrequency: process.env.NODE_ENV === "test" ? void 0 : 2
|
|
4723
4375
|
});
|
|
4724
|
-
(0,
|
|
4376
|
+
(0, import_async14.scheduleTask)(ctx, async () => {
|
|
4725
4377
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4726
|
-
const subscriptions = new
|
|
4378
|
+
const subscriptions = new import_async14.EventSubscriptions();
|
|
4727
4379
|
ctx.onDispose(() => subscriptions.clear());
|
|
4728
4380
|
const subscribeSpaces = () => {
|
|
4729
4381
|
subscriptions.clear();
|
|
@@ -4750,14 +4402,14 @@ var SpacesServiceImpl = class {
|
|
|
4750
4402
|
}
|
|
4751
4403
|
async postMessage({ spaceKey, channel, message }) {
|
|
4752
4404
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4753
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4405
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4754
4406
|
await space.postMessage(getChannelId(channel), message);
|
|
4755
4407
|
}
|
|
4756
4408
|
subscribeMessages({ spaceKey, channel }) {
|
|
4757
4409
|
return new import_codec_protobuf10.Stream(({ ctx, next }) => {
|
|
4758
|
-
(0,
|
|
4410
|
+
(0, import_async14.scheduleTask)(ctx, async () => {
|
|
4759
4411
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4760
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4412
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4761
4413
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
4762
4414
|
next(message);
|
|
4763
4415
|
});
|
|
@@ -4767,14 +4419,14 @@ var SpacesServiceImpl = class {
|
|
|
4767
4419
|
}
|
|
4768
4420
|
queryCredentials({ spaceKey, noTail }) {
|
|
4769
4421
|
return new import_codec_protobuf10.Stream(({ ctx, next, close }) => {
|
|
4770
|
-
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4422
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4771
4423
|
const processor = {
|
|
4772
4424
|
processCredential: async (credential) => {
|
|
4773
4425
|
next(credential);
|
|
4774
4426
|
}
|
|
4775
4427
|
};
|
|
4776
4428
|
ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
|
|
4777
|
-
(0,
|
|
4429
|
+
(0, import_async14.scheduleTask)(ctx, async () => {
|
|
4778
4430
|
await space.spaceState.addCredentialProcessor(processor);
|
|
4779
4431
|
if (noTail) {
|
|
4780
4432
|
close();
|
|
@@ -4783,7 +4435,7 @@ var SpacesServiceImpl = class {
|
|
|
4783
4435
|
});
|
|
4784
4436
|
}
|
|
4785
4437
|
async writeCredentials({ spaceKey, credentials }) {
|
|
4786
|
-
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4438
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4787
4439
|
for (const credential of credentials ?? []) {
|
|
4788
4440
|
if (credential.proof) {
|
|
4789
4441
|
await space.controlPipeline.writer.write({
|
|
@@ -4792,8 +4444,8 @@ var SpacesServiceImpl = class {
|
|
|
4792
4444
|
}
|
|
4793
4445
|
});
|
|
4794
4446
|
} else {
|
|
4795
|
-
(0,
|
|
4796
|
-
F:
|
|
4447
|
+
(0, import_invariant12.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
4448
|
+
F: __dxlog_file13,
|
|
4797
4449
|
L: 164,
|
|
4798
4450
|
S: this,
|
|
4799
4451
|
A: [
|
|
@@ -4801,8 +4453,8 @@ var SpacesServiceImpl = class {
|
|
|
4801
4453
|
"'Id on unsigned credentials is not allowed'"
|
|
4802
4454
|
]
|
|
4803
4455
|
});
|
|
4804
|
-
(0,
|
|
4805
|
-
F:
|
|
4456
|
+
(0, import_invariant12.invariant)(this._identityManager.identity, "Identity is not available", {
|
|
4457
|
+
F: __dxlog_file13,
|
|
4806
4458
|
L: 165,
|
|
4807
4459
|
S: this,
|
|
4808
4460
|
A: [
|
|
@@ -4811,8 +4463,8 @@ var SpacesServiceImpl = class {
|
|
|
4811
4463
|
]
|
|
4812
4464
|
});
|
|
4813
4465
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
4814
|
-
(0,
|
|
4815
|
-
F:
|
|
4466
|
+
(0, import_invariant12.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
4467
|
+
F: __dxlog_file13,
|
|
4816
4468
|
L: 167,
|
|
4817
4469
|
S: this,
|
|
4818
4470
|
A: [
|
|
@@ -4834,7 +4486,7 @@ var SpacesServiceImpl = class {
|
|
|
4834
4486
|
}
|
|
4835
4487
|
async createEpoch({ spaceKey, migration }) {
|
|
4836
4488
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4837
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4489
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4838
4490
|
await space.createEpoch({
|
|
4839
4491
|
migration
|
|
4840
4492
|
});
|
|
@@ -4843,7 +4495,7 @@ var SpacesServiceImpl = class {
|
|
|
4843
4495
|
return {
|
|
4844
4496
|
spaceKey: space.key,
|
|
4845
4497
|
state: space.state,
|
|
4846
|
-
error: space.error ? (0,
|
|
4498
|
+
error: space.error ? (0, import_protocols10.encodeError)(space.error) : void 0,
|
|
4847
4499
|
pipeline: {
|
|
4848
4500
|
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
4849
4501
|
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
@@ -4868,7 +4520,7 @@ var SpacesServiceImpl = class {
|
|
|
4868
4520
|
identityKey: member.key,
|
|
4869
4521
|
profile: member.profile ?? {}
|
|
4870
4522
|
},
|
|
4871
|
-
presence: member.removed ?
|
|
4523
|
+
presence: member.removed ? import_services10.SpaceMember.PresenceState.REMOVED : isMe || peers.length > 0 ? import_services10.SpaceMember.PresenceState.ONLINE : import_services10.SpaceMember.PresenceState.OFFLINE,
|
|
4872
4524
|
peerStates: peers
|
|
4873
4525
|
};
|
|
4874
4526
|
}),
|
|
@@ -4889,8 +4541,8 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4889
4541
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4890
4542
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4891
4543
|
}
|
|
4892
|
-
var
|
|
4893
|
-
var ServiceContext = class extends
|
|
4544
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
4545
|
+
var ServiceContext = class extends import_context10.Resource {
|
|
4894
4546
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
4895
4547
|
super();
|
|
4896
4548
|
this.storage = storage;
|
|
@@ -4898,9 +4550,9 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
4898
4550
|
this.networkManager = networkManager;
|
|
4899
4551
|
this.signalManager = signalManager;
|
|
4900
4552
|
this._runtimeParams = _runtimeParams;
|
|
4901
|
-
this.initialized = new
|
|
4553
|
+
this.initialized = new import_async15.Trigger();
|
|
4902
4554
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4903
|
-
this._instanceId =
|
|
4555
|
+
this._instanceId = import_keys11.PublicKey.random().toHex();
|
|
4904
4556
|
this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
|
|
4905
4557
|
this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
|
|
4906
4558
|
this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
|
|
@@ -4927,23 +4579,23 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
4927
4579
|
kv: this.level,
|
|
4928
4580
|
storage: this.storage
|
|
4929
4581
|
});
|
|
4930
|
-
this.invitations = new InvitationsHandler(this.networkManager
|
|
4582
|
+
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4931
4583
|
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
4932
|
-
this._handlerFactories.set(
|
|
4584
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
4933
4585
|
}
|
|
4934
4586
|
async _open(ctx) {
|
|
4935
4587
|
await this._checkStorageVersion();
|
|
4936
|
-
(0,
|
|
4937
|
-
F:
|
|
4938
|
-
L:
|
|
4588
|
+
(0, import_log12.log)("opening...", void 0, {
|
|
4589
|
+
F: __dxlog_file14,
|
|
4590
|
+
L: 150,
|
|
4939
4591
|
S: this,
|
|
4940
4592
|
C: (f, a) => f(...a)
|
|
4941
4593
|
});
|
|
4942
|
-
|
|
4594
|
+
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.begin({
|
|
4943
4595
|
id: this._instanceId
|
|
4944
4596
|
}), {
|
|
4945
|
-
F:
|
|
4946
|
-
L:
|
|
4597
|
+
F: __dxlog_file14,
|
|
4598
|
+
L: 151,
|
|
4947
4599
|
S: this,
|
|
4948
4600
|
C: (f, a) => f(...a)
|
|
4949
4601
|
});
|
|
@@ -4957,33 +4609,33 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
4957
4609
|
await this._initialize(ctx);
|
|
4958
4610
|
}
|
|
4959
4611
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
4960
|
-
(0,
|
|
4612
|
+
(0, import_log12.log)("loaded persistent invitations", {
|
|
4961
4613
|
count: loadedInvitations.invitations?.length
|
|
4962
4614
|
}, {
|
|
4963
|
-
F:
|
|
4964
|
-
L:
|
|
4615
|
+
F: __dxlog_file14,
|
|
4616
|
+
L: 164,
|
|
4965
4617
|
S: this,
|
|
4966
4618
|
C: (f, a) => f(...a)
|
|
4967
4619
|
});
|
|
4968
|
-
|
|
4620
|
+
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.end({
|
|
4969
4621
|
id: this._instanceId
|
|
4970
4622
|
}), {
|
|
4971
|
-
F:
|
|
4972
|
-
L:
|
|
4623
|
+
F: __dxlog_file14,
|
|
4624
|
+
L: 166,
|
|
4973
4625
|
S: this,
|
|
4974
4626
|
C: (f, a) => f(...a)
|
|
4975
4627
|
});
|
|
4976
|
-
(0,
|
|
4977
|
-
F:
|
|
4978
|
-
L:
|
|
4628
|
+
(0, import_log12.log)("opened", void 0, {
|
|
4629
|
+
F: __dxlog_file14,
|
|
4630
|
+
L: 167,
|
|
4979
4631
|
S: this,
|
|
4980
4632
|
C: (f, a) => f(...a)
|
|
4981
4633
|
});
|
|
4982
4634
|
}
|
|
4983
4635
|
async _close(ctx) {
|
|
4984
|
-
(0,
|
|
4985
|
-
F:
|
|
4986
|
-
L:
|
|
4636
|
+
(0, import_log12.log)("closing...", void 0, {
|
|
4637
|
+
F: __dxlog_file14,
|
|
4638
|
+
L: 171,
|
|
4987
4639
|
S: this,
|
|
4988
4640
|
C: (f, a) => f(...a)
|
|
4989
4641
|
});
|
|
@@ -4998,23 +4650,23 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
4998
4650
|
await this.echoHost.close(ctx);
|
|
4999
4651
|
await this.networkManager.close();
|
|
5000
4652
|
await this.signalManager.close();
|
|
5001
|
-
(0,
|
|
5002
|
-
F:
|
|
5003
|
-
L:
|
|
4653
|
+
(0, import_log12.log)("closed", void 0, {
|
|
4654
|
+
F: __dxlog_file14,
|
|
4655
|
+
L: 183,
|
|
5004
4656
|
S: this,
|
|
5005
4657
|
C: (f, a) => f(...a)
|
|
5006
4658
|
});
|
|
5007
4659
|
}
|
|
5008
4660
|
async createIdentity(params = {}) {
|
|
5009
4661
|
const identity = await this.identityManager.createIdentity(params);
|
|
5010
|
-
await this._initialize(new
|
|
4662
|
+
await this._initialize(new import_context10.Context());
|
|
5011
4663
|
return identity;
|
|
5012
4664
|
}
|
|
5013
4665
|
getInvitationHandler(invitation) {
|
|
5014
4666
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
5015
|
-
(0,
|
|
5016
|
-
F:
|
|
5017
|
-
L:
|
|
4667
|
+
(0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4668
|
+
F: __dxlog_file14,
|
|
4669
|
+
L: 194,
|
|
5018
4670
|
S: this,
|
|
5019
4671
|
A: [
|
|
5020
4672
|
"factory",
|
|
@@ -5033,20 +4685,20 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5033
4685
|
}
|
|
5034
4686
|
async _acceptIdentity(params) {
|
|
5035
4687
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
5036
|
-
await this._initialize(new
|
|
4688
|
+
await this._initialize(new import_context10.Context());
|
|
5037
4689
|
return identity;
|
|
5038
4690
|
}
|
|
5039
4691
|
async _checkStorageVersion() {
|
|
5040
4692
|
await this.metadataStore.load();
|
|
5041
|
-
if (this.metadataStore.version !==
|
|
5042
|
-
throw new
|
|
4693
|
+
if (this.metadataStore.version !== import_protocols11.STORAGE_VERSION) {
|
|
4694
|
+
throw new import_protocols11.InvalidStorageVersionError(import_protocols11.STORAGE_VERSION, this.metadataStore.version);
|
|
5043
4695
|
}
|
|
5044
4696
|
}
|
|
5045
4697
|
// Called when identity is created.
|
|
5046
4698
|
async _initialize(ctx) {
|
|
5047
|
-
(0,
|
|
5048
|
-
F:
|
|
5049
|
-
L:
|
|
4699
|
+
(0, import_log12.log)("initializing spaces...", void 0, {
|
|
4700
|
+
F: __dxlog_file14,
|
|
4701
|
+
L: 225,
|
|
5050
4702
|
S: this,
|
|
5051
4703
|
C: (f, a) => f(...a)
|
|
5052
4704
|
});
|
|
@@ -5066,10 +4718,10 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5066
4718
|
};
|
|
5067
4719
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.echoHost, this.invitationsManager, this._runtimeParams);
|
|
5068
4720
|
await this.dataSpaceManager.open();
|
|
5069
|
-
this._handlerFactories.set(
|
|
5070
|
-
(0,
|
|
5071
|
-
F:
|
|
5072
|
-
L:
|
|
4721
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.SPACE, (invitation) => {
|
|
4722
|
+
(0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4723
|
+
F: __dxlog_file14,
|
|
4724
|
+
L: 250,
|
|
5073
4725
|
S: this,
|
|
5074
4726
|
A: [
|
|
5075
4727
|
"this.dataSpaceManager",
|
|
@@ -5089,33 +4741,33 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5089
4741
|
return;
|
|
5090
4742
|
}
|
|
5091
4743
|
if (!this.dataSpaceManager) {
|
|
5092
|
-
(0,
|
|
4744
|
+
(0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
5093
4745
|
details: assertion
|
|
5094
4746
|
}, {
|
|
5095
|
-
F:
|
|
5096
|
-
L:
|
|
4747
|
+
F: __dxlog_file14,
|
|
4748
|
+
L: 266,
|
|
5097
4749
|
S: this,
|
|
5098
4750
|
C: (f, a) => f(...a)
|
|
5099
4751
|
});
|
|
5100
4752
|
return;
|
|
5101
4753
|
}
|
|
5102
4754
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
5103
|
-
(0,
|
|
4755
|
+
(0, import_log12.log)("space already exists, ignoring space admission", {
|
|
5104
4756
|
details: assertion
|
|
5105
4757
|
}, {
|
|
5106
|
-
F:
|
|
5107
|
-
L:
|
|
4758
|
+
F: __dxlog_file14,
|
|
4759
|
+
L: 270,
|
|
5108
4760
|
S: this,
|
|
5109
4761
|
C: (f, a) => f(...a)
|
|
5110
4762
|
});
|
|
5111
4763
|
return;
|
|
5112
4764
|
}
|
|
5113
4765
|
try {
|
|
5114
|
-
(0,
|
|
4766
|
+
(0, import_log12.log)("accepting space recorded in halo", {
|
|
5115
4767
|
details: assertion
|
|
5116
4768
|
}, {
|
|
5117
|
-
F:
|
|
5118
|
-
L:
|
|
4769
|
+
F: __dxlog_file14,
|
|
4770
|
+
L: 275,
|
|
5119
4771
|
S: this,
|
|
5120
4772
|
C: (f, a) => f(...a)
|
|
5121
4773
|
});
|
|
@@ -5124,9 +4776,9 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5124
4776
|
genesisFeedKey: assertion.genesisFeedKey
|
|
5125
4777
|
});
|
|
5126
4778
|
} catch (err) {
|
|
5127
|
-
|
|
5128
|
-
F:
|
|
5129
|
-
L:
|
|
4779
|
+
import_log12.log.catch(err, void 0, {
|
|
4780
|
+
F: __dxlog_file14,
|
|
4781
|
+
L: 281,
|
|
5130
4782
|
S: this,
|
|
5131
4783
|
C: (f, a) => f(...a)
|
|
5132
4784
|
});
|
|
@@ -5143,7 +4795,7 @@ _ts_decorate6([
|
|
|
5143
4795
|
import_tracing5.trace.span()
|
|
5144
4796
|
], ServiceContext.prototype, "_initialize", null);
|
|
5145
4797
|
ServiceContext = _ts_decorate6([
|
|
5146
|
-
(0,
|
|
4798
|
+
(0, import_util7.safeInstanceof)("dxos.client-services.ServiceContext"),
|
|
5147
4799
|
import_tracing5.trace.resource()
|
|
5148
4800
|
], ServiceContext);
|
|
5149
4801
|
var ServiceRegistry = class {
|
|
@@ -5168,26 +4820,26 @@ var ServiceRegistry = class {
|
|
|
5168
4820
|
delete this._handlers[name];
|
|
5169
4821
|
}
|
|
5170
4822
|
};
|
|
5171
|
-
var DXOS_VERSION = "0.5.1-
|
|
4823
|
+
var DXOS_VERSION = "0.5.1-next.260c093";
|
|
5172
4824
|
var getPlatform = () => {
|
|
5173
4825
|
if (process.browser) {
|
|
5174
4826
|
if (typeof window !== "undefined") {
|
|
5175
4827
|
const { userAgent } = window.navigator;
|
|
5176
4828
|
return {
|
|
5177
|
-
type:
|
|
4829
|
+
type: import_services13.Platform.PLATFORM_TYPE.BROWSER,
|
|
5178
4830
|
userAgent,
|
|
5179
4831
|
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
5180
4832
|
};
|
|
5181
4833
|
} else {
|
|
5182
4834
|
return {
|
|
5183
|
-
type:
|
|
4835
|
+
type: import_services13.Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
5184
4836
|
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
5185
4837
|
};
|
|
5186
4838
|
}
|
|
5187
4839
|
} else {
|
|
5188
4840
|
const { platform: platform2, version, arch } = process;
|
|
5189
4841
|
return {
|
|
5190
|
-
type:
|
|
4842
|
+
type: import_services13.Platform.PLATFORM_TYPE.NODE,
|
|
5191
4843
|
platform: platform2,
|
|
5192
4844
|
arch,
|
|
5193
4845
|
runtime: version,
|
|
@@ -5196,7 +4848,7 @@ var getPlatform = () => {
|
|
|
5196
4848
|
};
|
|
5197
4849
|
}
|
|
5198
4850
|
};
|
|
5199
|
-
var
|
|
4851
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
|
|
5200
4852
|
var DEFAULT_TIMEOUT = 1e3;
|
|
5201
4853
|
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
5202
4854
|
const diagnostics = {
|
|
@@ -5205,14 +4857,14 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
5205
4857
|
client: {
|
|
5206
4858
|
version: DXOS_VERSION,
|
|
5207
4859
|
storage: {
|
|
5208
|
-
version:
|
|
4860
|
+
version: import_protocols12.STORAGE_VERSION
|
|
5209
4861
|
}
|
|
5210
4862
|
},
|
|
5211
4863
|
trace: import_tracing6.TRACE_PROCESSOR.getDiagnostics()
|
|
5212
4864
|
};
|
|
5213
4865
|
{
|
|
5214
|
-
(0,
|
|
5215
|
-
F:
|
|
4866
|
+
(0, import_invariant14.invariant)(clientServices.LoggingService, "SystemService is not available.", {
|
|
4867
|
+
F: __dxlog_file15,
|
|
5216
4868
|
L: 108,
|
|
5217
4869
|
S: void 0,
|
|
5218
4870
|
A: [
|
|
@@ -5285,7 +4937,7 @@ var getSpaceStats = async (space) => {
|
|
|
5285
4937
|
displayName: member.assertion.profile?.displayName
|
|
5286
4938
|
}
|
|
5287
4939
|
},
|
|
5288
|
-
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ?
|
|
4940
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services12.SpaceMember.PresenceState.ONLINE : import_services12.SpaceMember.PresenceState.OFFLINE
|
|
5289
4941
|
})),
|
|
5290
4942
|
pipeline: {
|
|
5291
4943
|
// TODO(burdon): Pick properties from credentials if needed.
|
|
@@ -5316,7 +4968,7 @@ var createCollectDiagnosticsBroadcastHandler = (_) => {
|
|
|
5316
4968
|
}
|
|
5317
4969
|
};
|
|
5318
4970
|
};
|
|
5319
|
-
var
|
|
4971
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
5320
4972
|
var DevicesServiceImpl = class {
|
|
5321
4973
|
constructor(_identityManager) {
|
|
5322
4974
|
this._identityManager = _identityManager;
|
|
@@ -5333,8 +4985,8 @@ var DevicesServiceImpl = class {
|
|
|
5333
4985
|
devices: []
|
|
5334
4986
|
});
|
|
5335
4987
|
} else {
|
|
5336
|
-
(0,
|
|
5337
|
-
F:
|
|
4988
|
+
(0, import_invariant16.invariant)(this._identityManager.identity?.presence, "presence not present", {
|
|
4989
|
+
F: __dxlog_file16,
|
|
5338
4990
|
L: 32,
|
|
5339
4991
|
S: this,
|
|
5340
4992
|
A: [
|
|
@@ -5349,9 +5001,9 @@ var DevicesServiceImpl = class {
|
|
|
5349
5001
|
const peerState = peers.find((peer) => peer.identityKey.equals(key));
|
|
5350
5002
|
return {
|
|
5351
5003
|
deviceKey: key,
|
|
5352
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ?
|
|
5004
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services16.DeviceKind.CURRENT : import_services16.DeviceKind.TRUSTED,
|
|
5353
5005
|
profile,
|
|
5354
|
-
presence: isMe ?
|
|
5006
|
+
presence: isMe ? import_services16.Device.PresenceState.ONLINE : peerState ? import_services16.Device.PresenceState.ONLINE : import_services16.Device.PresenceState.OFFLINE
|
|
5355
5007
|
};
|
|
5356
5008
|
})
|
|
5357
5009
|
});
|
|
@@ -5375,7 +5027,7 @@ var DevicesServiceImpl = class {
|
|
|
5375
5027
|
presenceSubscribed = true;
|
|
5376
5028
|
}
|
|
5377
5029
|
};
|
|
5378
|
-
const subscriptions = new
|
|
5030
|
+
const subscriptions = new import_async17.EventSubscriptions();
|
|
5379
5031
|
if (this._identityManager.identity) {
|
|
5380
5032
|
subscribeIdentity();
|
|
5381
5033
|
subscribePresence();
|
|
@@ -5402,7 +5054,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
5402
5054
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5403
5055
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5404
5056
|
}
|
|
5405
|
-
var
|
|
5057
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
5406
5058
|
var Lock = class {
|
|
5407
5059
|
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
5408
5060
|
this._lockPath = lockPath;
|
|
@@ -5413,16 +5065,16 @@ var Lock = class {
|
|
|
5413
5065
|
return this._lockPath;
|
|
5414
5066
|
}
|
|
5415
5067
|
async acquire() {
|
|
5416
|
-
(0,
|
|
5417
|
-
F:
|
|
5068
|
+
(0, import_log14.log)("acquiring lock...", void 0, {
|
|
5069
|
+
F: __dxlog_file17,
|
|
5418
5070
|
L: 32,
|
|
5419
5071
|
S: this,
|
|
5420
5072
|
C: (f, a) => f(...a)
|
|
5421
5073
|
});
|
|
5422
5074
|
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
5423
5075
|
await this._onAcquire?.();
|
|
5424
|
-
(0,
|
|
5425
|
-
F:
|
|
5076
|
+
(0, import_log14.log)("acquired lock", void 0, {
|
|
5077
|
+
F: __dxlog_file17,
|
|
5426
5078
|
L: 37,
|
|
5427
5079
|
S: this,
|
|
5428
5080
|
C: (f, a) => f(...a)
|
|
@@ -5430,8 +5082,8 @@ var Lock = class {
|
|
|
5430
5082
|
}
|
|
5431
5083
|
async release() {
|
|
5432
5084
|
await this._onRelease?.();
|
|
5433
|
-
(0,
|
|
5434
|
-
F:
|
|
5085
|
+
(0, import_invariant17.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
5086
|
+
F: __dxlog_file17,
|
|
5435
5087
|
L: 42,
|
|
5436
5088
|
S: this,
|
|
5437
5089
|
A: [
|
|
@@ -5443,36 +5095,36 @@ var Lock = class {
|
|
|
5443
5095
|
}
|
|
5444
5096
|
};
|
|
5445
5097
|
_ts_decorate7([
|
|
5446
|
-
|
|
5098
|
+
import_log14.logInfo
|
|
5447
5099
|
], Lock.prototype, "lockKey", null);
|
|
5448
5100
|
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
5449
5101
|
var LoggingServiceImpl = class {
|
|
5450
5102
|
constructor() {
|
|
5451
|
-
this._logs = new
|
|
5103
|
+
this._logs = new import_async18.Event();
|
|
5452
5104
|
this._started = Date.now();
|
|
5453
|
-
this._sessionId =
|
|
5105
|
+
this._sessionId = import_keys13.PublicKey.random().toHex();
|
|
5454
5106
|
this._logProcessor = (_config, entry2) => {
|
|
5455
5107
|
this._logs.emit(entry2);
|
|
5456
5108
|
};
|
|
5457
5109
|
}
|
|
5458
5110
|
async open() {
|
|
5459
|
-
|
|
5111
|
+
import_log15.log.runtimeConfig.processors.push(this._logProcessor);
|
|
5460
5112
|
}
|
|
5461
5113
|
async close() {
|
|
5462
|
-
const index =
|
|
5463
|
-
|
|
5114
|
+
const index = import_log15.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
5115
|
+
import_log15.log.runtimeConfig.processors.splice(index, 1);
|
|
5464
5116
|
}
|
|
5465
5117
|
async controlMetrics({ reset, record }) {
|
|
5466
5118
|
if (reset) {
|
|
5467
|
-
|
|
5119
|
+
import_util10.tracer.clear();
|
|
5468
5120
|
}
|
|
5469
5121
|
if (record === true) {
|
|
5470
|
-
|
|
5122
|
+
import_util10.tracer.start();
|
|
5471
5123
|
} else if (record === false) {
|
|
5472
|
-
|
|
5124
|
+
import_util10.tracer.stop();
|
|
5473
5125
|
}
|
|
5474
5126
|
return {
|
|
5475
|
-
recording:
|
|
5127
|
+
recording: import_util10.tracer.recording
|
|
5476
5128
|
};
|
|
5477
5129
|
}
|
|
5478
5130
|
/**
|
|
@@ -5480,10 +5132,10 @@ var LoggingServiceImpl = class {
|
|
|
5480
5132
|
*/
|
|
5481
5133
|
queryMetrics({ interval = 5e3 }) {
|
|
5482
5134
|
const getNumericalValues = (key) => {
|
|
5483
|
-
const events =
|
|
5135
|
+
const events = import_util10.tracer.get(key) ?? [];
|
|
5484
5136
|
return {
|
|
5485
5137
|
key,
|
|
5486
|
-
stats: (0,
|
|
5138
|
+
stats: (0, import_util10.numericalValues)(events, "duration")
|
|
5487
5139
|
};
|
|
5488
5140
|
};
|
|
5489
5141
|
return new import_codec_protobuf13.Stream(({ next }) => {
|
|
@@ -5521,7 +5173,7 @@ var LoggingServiceImpl = class {
|
|
|
5521
5173
|
}
|
|
5522
5174
|
const record = {
|
|
5523
5175
|
...entry2,
|
|
5524
|
-
context: (0,
|
|
5176
|
+
context: (0, import_util10.jsonify)((0, import_log15.getContextFromEntry)(entry2)),
|
|
5525
5177
|
timestamp: /* @__PURE__ */ new Date(),
|
|
5526
5178
|
meta: {
|
|
5527
5179
|
// TODO(dmaretskyi): Fix proto.
|
|
@@ -5530,7 +5182,7 @@ var LoggingServiceImpl = class {
|
|
|
5530
5182
|
scope: {
|
|
5531
5183
|
hostSessionId: this._sessionId,
|
|
5532
5184
|
uptimeSeconds: (Date.now() - this._started) / 1e3,
|
|
5533
|
-
name: (0,
|
|
5185
|
+
name: (0, import_util10.getDebugName)(entry2.meta?.S)
|
|
5534
5186
|
}
|
|
5535
5187
|
}
|
|
5536
5188
|
};
|
|
@@ -5547,16 +5199,16 @@ var LoggingServiceImpl = class {
|
|
|
5547
5199
|
};
|
|
5548
5200
|
var matchFilter = (filter, level, path2, options) => {
|
|
5549
5201
|
switch (options) {
|
|
5550
|
-
case
|
|
5202
|
+
case import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
5551
5203
|
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5552
|
-
case
|
|
5204
|
+
case import_services17.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
5553
5205
|
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5554
5206
|
}
|
|
5555
5207
|
};
|
|
5556
5208
|
var shouldLog = (entry2, request) => {
|
|
5557
|
-
const options = request.options ??
|
|
5209
|
+
const options = request.options ?? import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5558
5210
|
if (request.filters === void 0) {
|
|
5559
|
-
return options ===
|
|
5211
|
+
return options === import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5560
5212
|
} else {
|
|
5561
5213
|
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
5562
5214
|
}
|
|
@@ -5593,7 +5245,7 @@ var NetworkServiceImpl = class {
|
|
|
5593
5245
|
}
|
|
5594
5246
|
};
|
|
5595
5247
|
var getRootPath = (config) => {
|
|
5596
|
-
const { dataRoot = (0,
|
|
5248
|
+
const { dataRoot = (0, import_util11.isNode)() ? import_client_protocol6.DX_DATA : "dxos/storage" } = config ?? {};
|
|
5597
5249
|
return `${dataRoot}/`;
|
|
5598
5250
|
};
|
|
5599
5251
|
var isPersistent = (config) => {
|
|
@@ -5604,16 +5256,16 @@ var StorageDriver = import_config2.Runtime.Client.Storage.StorageDriver;
|
|
|
5604
5256
|
var createStorageObjects = (config) => {
|
|
5605
5257
|
const { persistent = false, keyStore, dataStore } = config ?? {};
|
|
5606
5258
|
if (persistent && dataStore === StorageDriver.RAM) {
|
|
5607
|
-
throw new
|
|
5259
|
+
throw new import_protocols14.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
5608
5260
|
}
|
|
5609
5261
|
if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
|
|
5610
|
-
throw new
|
|
5262
|
+
throw new import_protocols14.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
5611
5263
|
}
|
|
5612
5264
|
if (persistent && keyStore === StorageDriver.RAM) {
|
|
5613
|
-
throw new
|
|
5265
|
+
throw new import_protocols14.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
5614
5266
|
}
|
|
5615
5267
|
if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
|
|
5616
|
-
throw new
|
|
5268
|
+
throw new import_protocols14.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
5617
5269
|
}
|
|
5618
5270
|
return {
|
|
5619
5271
|
storage: (0, import_random_access_storage.createStorage)({
|
|
@@ -5644,7 +5296,7 @@ var toStorageType = (type) => {
|
|
|
5644
5296
|
};
|
|
5645
5297
|
var createLevel = async (config) => {
|
|
5646
5298
|
const persistent = isPersistent(config);
|
|
5647
|
-
const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${
|
|
5299
|
+
const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys14.PublicKey.random().toHex()}`;
|
|
5648
5300
|
const level = (0, import_kv_store.createLevel)(storagePath);
|
|
5649
5301
|
await level.open();
|
|
5650
5302
|
return level;
|
|
@@ -5668,9 +5320,9 @@ var SystemServiceImpl = class {
|
|
|
5668
5320
|
const diagnostics = await this._getDiagnostics();
|
|
5669
5321
|
return {
|
|
5670
5322
|
timestamp: /* @__PURE__ */ new Date(),
|
|
5671
|
-
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0,
|
|
5672
|
-
truncate: keys ===
|
|
5673
|
-
humanize: keys ===
|
|
5323
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util12.jsonKeyReplacer)({
|
|
5324
|
+
truncate: keys === import_services18.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
5325
|
+
humanize: keys === import_services18.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
5674
5326
|
})))
|
|
5675
5327
|
};
|
|
5676
5328
|
}
|
|
@@ -5711,7 +5363,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
5711
5363
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5712
5364
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5713
5365
|
}
|
|
5714
|
-
var
|
|
5366
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
5715
5367
|
var ClientServicesHost = class {
|
|
5716
5368
|
constructor({
|
|
5717
5369
|
config,
|
|
@@ -5725,7 +5377,7 @@ var ClientServicesHost = class {
|
|
|
5725
5377
|
runtimeParams
|
|
5726
5378
|
} = {}) {
|
|
5727
5379
|
this._tracingService = import_tracing8.TRACE_PROCESSOR.createTraceSender();
|
|
5728
|
-
this._statusUpdate = new
|
|
5380
|
+
this._statusUpdate = new import_async16.Event();
|
|
5729
5381
|
this._opening = false;
|
|
5730
5382
|
this._open = false;
|
|
5731
5383
|
this._storage = storage;
|
|
@@ -5744,7 +5396,7 @@ var ClientServicesHost = class {
|
|
|
5744
5396
|
lockKey,
|
|
5745
5397
|
onAcquire: () => {
|
|
5746
5398
|
if (!this._opening) {
|
|
5747
|
-
void this.open(new
|
|
5399
|
+
void this.open(new import_context11.Context());
|
|
5748
5400
|
}
|
|
5749
5401
|
},
|
|
5750
5402
|
onRelease: () => this.close()
|
|
@@ -5753,14 +5405,14 @@ var ClientServicesHost = class {
|
|
|
5753
5405
|
this._systemService = new SystemServiceImpl({
|
|
5754
5406
|
config: () => this._config,
|
|
5755
5407
|
statusUpdate: this._statusUpdate,
|
|
5756
|
-
getCurrentStatus: () => this.isOpen ?
|
|
5408
|
+
getCurrentStatus: () => this.isOpen ? import_services15.SystemStatus.ACTIVE : import_services15.SystemStatus.INACTIVE,
|
|
5757
5409
|
getDiagnostics: () => {
|
|
5758
5410
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
5759
5411
|
},
|
|
5760
5412
|
onUpdateStatus: async (status) => {
|
|
5761
|
-
if (!this.isOpen && status ===
|
|
5413
|
+
if (!this.isOpen && status === import_services15.SystemStatus.ACTIVE) {
|
|
5762
5414
|
await this._resourceLock?.acquire();
|
|
5763
|
-
} else if (this.isOpen && status ===
|
|
5415
|
+
} else if (this.isOpen && status === import_services15.SystemStatus.INACTIVE) {
|
|
5764
5416
|
await this._resourceLock?.release();
|
|
5765
5417
|
}
|
|
5766
5418
|
},
|
|
@@ -5799,8 +5451,8 @@ var ClientServicesHost = class {
|
|
|
5799
5451
|
* Can only be called once.
|
|
5800
5452
|
*/
|
|
5801
5453
|
initialize({ config, ...options }) {
|
|
5802
|
-
(0,
|
|
5803
|
-
F:
|
|
5454
|
+
(0, import_invariant15.invariant)(!this._open, "service host is open", {
|
|
5455
|
+
F: __dxlog_file18,
|
|
5804
5456
|
L: 189,
|
|
5805
5457
|
S: this,
|
|
5806
5458
|
A: [
|
|
@@ -5808,15 +5460,15 @@ var ClientServicesHost = class {
|
|
|
5808
5460
|
"'service host is open'"
|
|
5809
5461
|
]
|
|
5810
5462
|
});
|
|
5811
|
-
(0,
|
|
5812
|
-
F:
|
|
5463
|
+
(0, import_log13.log)("initializing...", void 0, {
|
|
5464
|
+
F: __dxlog_file18,
|
|
5813
5465
|
L: 190,
|
|
5814
5466
|
S: this,
|
|
5815
5467
|
C: (f, a) => f(...a)
|
|
5816
5468
|
});
|
|
5817
5469
|
if (config) {
|
|
5818
|
-
(0,
|
|
5819
|
-
F:
|
|
5470
|
+
(0, import_invariant15.invariant)(!this._config, "config already set", {
|
|
5471
|
+
F: __dxlog_file18,
|
|
5820
5472
|
L: 193,
|
|
5821
5473
|
S: this,
|
|
5822
5474
|
A: [
|
|
@@ -5830,8 +5482,8 @@ var ClientServicesHost = class {
|
|
|
5830
5482
|
}
|
|
5831
5483
|
}
|
|
5832
5484
|
if (!options.signalManager) {
|
|
5833
|
-
|
|
5834
|
-
F:
|
|
5485
|
+
import_log13.log.warn("running signaling without telemetry metadata.", void 0, {
|
|
5486
|
+
F: __dxlog_file18,
|
|
5835
5487
|
L: 201,
|
|
5836
5488
|
S: this,
|
|
5837
5489
|
C: (f, a) => f(...a)
|
|
@@ -5841,8 +5493,8 @@ var ClientServicesHost = class {
|
|
|
5841
5493
|
iceServers: this._config?.get("runtime.services.ice")
|
|
5842
5494
|
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
5843
5495
|
this._signalManager = signalManager;
|
|
5844
|
-
(0,
|
|
5845
|
-
F:
|
|
5496
|
+
(0, import_invariant15.invariant)(!this._networkManager, "network manager already set", {
|
|
5497
|
+
F: __dxlog_file18,
|
|
5846
5498
|
L: 212,
|
|
5847
5499
|
S: this,
|
|
5848
5500
|
A: [
|
|
@@ -5855,8 +5507,8 @@ var ClientServicesHost = class {
|
|
|
5855
5507
|
transportFactory,
|
|
5856
5508
|
signalManager
|
|
5857
5509
|
});
|
|
5858
|
-
(0,
|
|
5859
|
-
F:
|
|
5510
|
+
(0, import_log13.log)("initialized", void 0, {
|
|
5511
|
+
F: __dxlog_file18,
|
|
5860
5512
|
L: 219,
|
|
5861
5513
|
S: this,
|
|
5862
5514
|
C: (f, a) => f(...a)
|
|
@@ -5866,17 +5518,17 @@ var ClientServicesHost = class {
|
|
|
5866
5518
|
if (this._open) {
|
|
5867
5519
|
return;
|
|
5868
5520
|
}
|
|
5869
|
-
const traceId =
|
|
5870
|
-
|
|
5521
|
+
const traceId = import_keys12.PublicKey.random().toHex();
|
|
5522
|
+
import_log13.log.trace("dxos.client-services.host.open", import_protocols13.trace.begin({
|
|
5871
5523
|
id: traceId
|
|
5872
5524
|
}), {
|
|
5873
|
-
F:
|
|
5525
|
+
F: __dxlog_file18,
|
|
5874
5526
|
L: 230,
|
|
5875
5527
|
S: this,
|
|
5876
5528
|
C: (f, a) => f(...a)
|
|
5877
5529
|
});
|
|
5878
|
-
(0,
|
|
5879
|
-
F:
|
|
5530
|
+
(0, import_invariant15.invariant)(this._config, "config not set", {
|
|
5531
|
+
F: __dxlog_file18,
|
|
5880
5532
|
L: 232,
|
|
5881
5533
|
S: this,
|
|
5882
5534
|
A: [
|
|
@@ -5884,8 +5536,8 @@ var ClientServicesHost = class {
|
|
|
5884
5536
|
"'config not set'"
|
|
5885
5537
|
]
|
|
5886
5538
|
});
|
|
5887
|
-
(0,
|
|
5888
|
-
F:
|
|
5539
|
+
(0, import_invariant15.invariant)(this._storage, "storage not set", {
|
|
5540
|
+
F: __dxlog_file18,
|
|
5889
5541
|
L: 233,
|
|
5890
5542
|
S: this,
|
|
5891
5543
|
A: [
|
|
@@ -5893,8 +5545,8 @@ var ClientServicesHost = class {
|
|
|
5893
5545
|
"'storage not set'"
|
|
5894
5546
|
]
|
|
5895
5547
|
});
|
|
5896
|
-
(0,
|
|
5897
|
-
F:
|
|
5548
|
+
(0, import_invariant15.invariant)(this._signalManager, "signal manager not set", {
|
|
5549
|
+
F: __dxlog_file18,
|
|
5898
5550
|
L: 234,
|
|
5899
5551
|
S: this,
|
|
5900
5552
|
A: [
|
|
@@ -5902,8 +5554,8 @@ var ClientServicesHost = class {
|
|
|
5902
5554
|
"'signal manager not set'"
|
|
5903
5555
|
]
|
|
5904
5556
|
});
|
|
5905
|
-
(0,
|
|
5906
|
-
F:
|
|
5557
|
+
(0, import_invariant15.invariant)(this._networkManager, "network manager not set", {
|
|
5558
|
+
F: __dxlog_file18,
|
|
5907
5559
|
L: 235,
|
|
5908
5560
|
S: this,
|
|
5909
5561
|
A: [
|
|
@@ -5912,10 +5564,10 @@ var ClientServicesHost = class {
|
|
|
5912
5564
|
]
|
|
5913
5565
|
});
|
|
5914
5566
|
this._opening = true;
|
|
5915
|
-
(0,
|
|
5567
|
+
(0, import_log13.log)("opening...", {
|
|
5916
5568
|
lockKey: this._resourceLock?.lockKey
|
|
5917
5569
|
}, {
|
|
5918
|
-
F:
|
|
5570
|
+
F: __dxlog_file18,
|
|
5919
5571
|
L: 238,
|
|
5920
5572
|
S: this,
|
|
5921
5573
|
C: (f, a) => f(...a)
|
|
@@ -5964,18 +5616,18 @@ var ClientServicesHost = class {
|
|
|
5964
5616
|
this._open = true;
|
|
5965
5617
|
this._statusUpdate.emit();
|
|
5966
5618
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5967
|
-
(0,
|
|
5619
|
+
(0, import_log13.log)("opened", {
|
|
5968
5620
|
deviceKey
|
|
5969
5621
|
}, {
|
|
5970
|
-
F:
|
|
5622
|
+
F: __dxlog_file18,
|
|
5971
5623
|
L: 314,
|
|
5972
5624
|
S: this,
|
|
5973
5625
|
C: (f, a) => f(...a)
|
|
5974
5626
|
});
|
|
5975
|
-
|
|
5627
|
+
import_log13.log.trace("dxos.client-services.host.open", import_protocols13.trace.end({
|
|
5976
5628
|
id: traceId
|
|
5977
5629
|
}), {
|
|
5978
|
-
F:
|
|
5630
|
+
F: __dxlog_file18,
|
|
5979
5631
|
L: 315,
|
|
5980
5632
|
S: this,
|
|
5981
5633
|
C: (f, a) => f(...a)
|
|
@@ -5986,10 +5638,10 @@ var ClientServicesHost = class {
|
|
|
5986
5638
|
return;
|
|
5987
5639
|
}
|
|
5988
5640
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5989
|
-
(0,
|
|
5641
|
+
(0, import_log13.log)("closing...", {
|
|
5990
5642
|
deviceKey
|
|
5991
5643
|
}, {
|
|
5992
|
-
F:
|
|
5644
|
+
F: __dxlog_file18,
|
|
5993
5645
|
L: 326,
|
|
5994
5646
|
S: this,
|
|
5995
5647
|
C: (f, a) => f(...a)
|
|
@@ -6004,43 +5656,43 @@ var ClientServicesHost = class {
|
|
|
6004
5656
|
await this._level?.close();
|
|
6005
5657
|
this._open = false;
|
|
6006
5658
|
this._statusUpdate.emit();
|
|
6007
|
-
(0,
|
|
5659
|
+
(0, import_log13.log)("closed", {
|
|
6008
5660
|
deviceKey
|
|
6009
5661
|
}, {
|
|
6010
|
-
F:
|
|
5662
|
+
F: __dxlog_file18,
|
|
6011
5663
|
L: 335,
|
|
6012
5664
|
S: this,
|
|
6013
5665
|
C: (f, a) => f(...a)
|
|
6014
5666
|
});
|
|
6015
5667
|
}
|
|
6016
5668
|
async reset() {
|
|
6017
|
-
const traceId =
|
|
6018
|
-
|
|
5669
|
+
const traceId = import_keys12.PublicKey.random().toHex();
|
|
5670
|
+
import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols13.trace.begin({
|
|
6019
5671
|
id: traceId
|
|
6020
5672
|
}), {
|
|
6021
|
-
F:
|
|
5673
|
+
F: __dxlog_file18,
|
|
6022
5674
|
L: 340,
|
|
6023
5675
|
S: this,
|
|
6024
5676
|
C: (f, a) => f(...a)
|
|
6025
5677
|
});
|
|
6026
|
-
(0,
|
|
6027
|
-
F:
|
|
5678
|
+
(0, import_log13.log)("resetting...", void 0, {
|
|
5679
|
+
F: __dxlog_file18,
|
|
6028
5680
|
L: 342,
|
|
6029
5681
|
S: this,
|
|
6030
5682
|
C: (f, a) => f(...a)
|
|
6031
5683
|
});
|
|
6032
5684
|
await this._serviceContext?.close();
|
|
6033
5685
|
await this._storage.reset();
|
|
6034
|
-
(0,
|
|
6035
|
-
F:
|
|
5686
|
+
(0, import_log13.log)("reset", void 0, {
|
|
5687
|
+
F: __dxlog_file18,
|
|
6036
5688
|
L: 345,
|
|
6037
5689
|
S: this,
|
|
6038
5690
|
C: (f, a) => f(...a)
|
|
6039
5691
|
});
|
|
6040
|
-
|
|
5692
|
+
import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols13.trace.end({
|
|
6041
5693
|
id: traceId
|
|
6042
5694
|
}), {
|
|
6043
|
-
F:
|
|
5695
|
+
F: __dxlog_file18,
|
|
6044
5696
|
L: 346,
|
|
6045
5697
|
S: this,
|
|
6046
5698
|
C: (f, a) => f(...a)
|
|
@@ -6052,8 +5704,8 @@ var ClientServicesHost = class {
|
|
|
6052
5704
|
await this._serviceContext.initialized.wait();
|
|
6053
5705
|
const space = await this._serviceContext.dataSpaceManager.createSpace();
|
|
6054
5706
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
6055
|
-
(0,
|
|
6056
|
-
F:
|
|
5707
|
+
(0, import_invariant15.invariant)(automergeIndex, void 0, {
|
|
5708
|
+
F: __dxlog_file18,
|
|
6057
5709
|
L: 358,
|
|
6058
5710
|
S: this,
|
|
6059
5711
|
A: [
|
|
@@ -6074,9 +5726,9 @@ var ClientServicesHost = class {
|
|
|
6074
5726
|
keys: []
|
|
6075
5727
|
}
|
|
6076
5728
|
};
|
|
6077
|
-
const propertiesId =
|
|
5729
|
+
const propertiesId = import_keys12.PublicKey.random().toHex();
|
|
6078
5730
|
document.change((doc) => {
|
|
6079
|
-
(0,
|
|
5731
|
+
(0, import_util9.assignDeep)(doc, [
|
|
6080
5732
|
"objects",
|
|
6081
5733
|
propertiesId
|
|
6082
5734
|
], properties);
|
|
@@ -6092,11 +5744,11 @@ _ts_decorate8([
|
|
|
6092
5744
|
import_tracing8.trace.info()
|
|
6093
5745
|
], ClientServicesHost.prototype, "_open", void 0);
|
|
6094
5746
|
_ts_decorate8([
|
|
6095
|
-
|
|
5747
|
+
import_async16.synchronized,
|
|
6096
5748
|
import_tracing8.trace.span()
|
|
6097
5749
|
], ClientServicesHost.prototype, "open", null);
|
|
6098
5750
|
_ts_decorate8([
|
|
6099
|
-
|
|
5751
|
+
import_async16.synchronized,
|
|
6100
5752
|
import_tracing8.trace.span()
|
|
6101
5753
|
], ClientServicesHost.prototype, "close", null);
|
|
6102
5754
|
ClientServicesHost = _ts_decorate8([
|
|
@@ -6109,7 +5761,7 @@ var DiagnosticsCollector = class {
|
|
|
6109
5761
|
}
|
|
6110
5762
|
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
6111
5763
|
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
6112
|
-
keys: options.humanize ?
|
|
5764
|
+
keys: options.humanize ? import_services14.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services14.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
6113
5765
|
});
|
|
6114
5766
|
const clientDiagnostics = {
|
|
6115
5767
|
config,
|
|
@@ -6122,7 +5774,7 @@ var DiagnosticsCollector = class {
|
|
|
6122
5774
|
client: clientDiagnostics,
|
|
6123
5775
|
broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
|
|
6124
5776
|
};
|
|
6125
|
-
return JSON.parse(JSON.stringify(diagnostics, (0,
|
|
5777
|
+
return JSON.parse(JSON.stringify(diagnostics, (0, import_util8.jsonKeyReplacer)(options)));
|
|
6126
5778
|
}
|
|
6127
5779
|
};
|
|
6128
5780
|
var findSystemServiceProvider = () => {
|
|
@@ -6132,7 +5784,7 @@ var findSystemServiceProvider = () => {
|
|
|
6132
5784
|
};
|
|
6133
5785
|
var findConfigs = () => {
|
|
6134
5786
|
const configs = import_tracing7.TRACE_PROCESSOR.findByAnnotation(import_config.ConfigResource);
|
|
6135
|
-
return configs.map((r) => r.instance.deref()).filter(
|
|
5787
|
+
return configs.map((r) => r.instance.deref()).filter(import_util8.nonNullable);
|
|
6136
5788
|
};
|
|
6137
5789
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6138
5790
|
0 && (module.exports = {
|
|
@@ -6174,4 +5826,4 @@ var findConfigs = () => {
|
|
|
6174
5826
|
subscribeToSpaces,
|
|
6175
5827
|
subscribeToSwarmInfo
|
|
6176
5828
|
});
|
|
6177
|
-
//# sourceMappingURL=chunk-
|
|
5829
|
+
//# sourceMappingURL=chunk-3ZUQNDPT.cjs.map
|