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