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