@dxos/client-services 0.4.10-main.fd4f2a3 → 0.4.10-main.fe71b4c
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-V2ALN47T.mjs → chunk-7S34JE6M.mjs} +836 -625
- package/dist/lib/browser/chunk-7S34JE6M.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +11 -3
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +9 -4
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-7WXQVUAE.cjs → chunk-DQMGKBOV.cjs} +854 -725
- package/dist/lib/node/chunk-DQMGKBOV.cjs.map +7 -0
- package/dist/lib/node/index.cjs +47 -39
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +14 -9
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts +5 -0
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts +5 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts +15 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts.map +1 -0
- package/dist/types/src/packlets/{services → diagnostics}/diagnostics.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/index.d.ts +4 -0
- package/dist/types/src/packlets/diagnostics/index.d.ts.map +1 -0
- package/dist/types/src/packlets/indexing/util.d.ts +2 -1
- package/dist/types/src/packlets/indexing/util.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts +1 -0
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +4 -2
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/index.d.ts +1 -1
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +4 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/util.d.ts +1 -0
- package/dist/types/src/packlets/services/util.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +3 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +35 -34
- package/src/index.ts +1 -0
- package/src/packlets/diagnostics/browser-diagnostics-broadcast.ts +94 -0
- package/src/packlets/diagnostics/diagnostics-broadcast.ts +20 -0
- package/src/packlets/diagnostics/diagnostics-collector.ts +65 -0
- package/src/packlets/{services → diagnostics}/diagnostics.ts +2 -2
- package/src/packlets/diagnostics/index.ts +7 -0
- package/src/packlets/indexing/util.ts +2 -2
- package/src/packlets/invitations/invitation-extension.ts +28 -1
- package/src/packlets/invitations/invitations-handler.ts +73 -32
- package/src/packlets/invitations/invitations-service.ts +5 -5
- package/src/packlets/services/automerge-host.test.ts +9 -3
- package/src/packlets/services/index.ts +1 -1
- package/src/packlets/services/service-context.test.ts +4 -1
- package/src/packlets/services/service-context.ts +5 -3
- package/src/packlets/services/service-host.ts +23 -4
- package/src/packlets/services/util.ts +2 -0
- package/src/packlets/spaces/data-space-manager.test.ts +4 -4
- package/src/packlets/storage/level.ts +1 -1
- package/src/packlets/system/system-service.ts +1 -1
- package/src/packlets/testing/test-builder.ts +20 -4
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-V2ALN47T.mjs.map +0 -7
- package/dist/lib/node/chunk-7WXQVUAE.cjs.map +0 -7
- package/dist/types/src/packlets/services/diagnostics.d.ts.map +0 -1
|
@@ -26,15 +26,17 @@ 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_DQMGKBOV_exports = {};
|
|
30
|
+
__export(chunk_DQMGKBOV_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
|
+
ClientServicesProviderResource: () => ClientServicesProviderResource,
|
|
33
34
|
DataSpace: () => DataSpace,
|
|
34
35
|
DataSpaceManager: () => DataSpaceManager,
|
|
35
36
|
DeviceInvitationProtocol: () => DeviceInvitationProtocol,
|
|
36
37
|
DevtoolsHostEvents: () => DevtoolsHostEvents,
|
|
37
38
|
DevtoolsServiceImpl: () => DevtoolsServiceImpl,
|
|
39
|
+
DiagnosticsCollector: () => DiagnosticsCollector,
|
|
38
40
|
Identity: () => Identity,
|
|
39
41
|
IdentityManager: () => IdentityManager,
|
|
40
42
|
IdentityServiceImpl: () => IdentityServiceImpl,
|
|
@@ -46,12 +48,14 @@ __export(chunk_7WXQVUAE_exports, {
|
|
|
46
48
|
SpaceInvitationProtocol: () => SpaceInvitationProtocol,
|
|
47
49
|
SpacesServiceImpl: () => SpacesServiceImpl,
|
|
48
50
|
TrustedKeySetAuthVerifier: () => TrustedKeySetAuthVerifier,
|
|
51
|
+
createAdmissionKeypair: () => createAdmissionKeypair,
|
|
49
52
|
createAuthProvider: () => createAuthProvider,
|
|
53
|
+
createCollectDiagnosticsBroadcastHandler: () => createCollectDiagnosticsBroadcastHandler,
|
|
54
|
+
createCollectDiagnosticsBroadcastSender: () => createCollectDiagnosticsBroadcastSender,
|
|
50
55
|
createDiagnostics: () => createDiagnostics,
|
|
51
56
|
createLevel: () => createLevel,
|
|
52
57
|
createStorageObjects: () => createStorageObjects,
|
|
53
58
|
getNetworkPeers: () => getNetworkPeers,
|
|
54
|
-
invitationExpired: () => invitationExpired,
|
|
55
59
|
isLocked: () => isLocked,
|
|
56
60
|
subscribeToFeedBlocks: () => subscribeToFeedBlocks,
|
|
57
61
|
subscribeToFeeds: () => subscribeToFeeds,
|
|
@@ -61,7 +65,7 @@ __export(chunk_7WXQVUAE_exports, {
|
|
|
61
65
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
62
66
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
63
67
|
});
|
|
64
|
-
module.exports = __toCommonJS(
|
|
68
|
+
module.exports = __toCommonJS(chunk_DQMGKBOV_exports);
|
|
65
69
|
var import_async = require("@dxos/async");
|
|
66
70
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
67
71
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -116,6 +120,7 @@ var import_async7 = require("@dxos/async");
|
|
|
116
120
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
117
121
|
var import_context4 = require("@dxos/context");
|
|
118
122
|
var import_credentials7 = require("@dxos/credentials");
|
|
123
|
+
var import_crypto = require("@dxos/crypto");
|
|
119
124
|
var import_invariant5 = require("@dxos/invariant");
|
|
120
125
|
var import_keys5 = require("@dxos/keys");
|
|
121
126
|
var import_log4 = require("@dxos/log");
|
|
@@ -125,6 +130,7 @@ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
125
130
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
126
131
|
var import_async8 = require("@dxos/async");
|
|
127
132
|
var import_context5 = require("@dxos/context");
|
|
133
|
+
var import_crypto2 = require("@dxos/crypto");
|
|
128
134
|
var import_invariant6 = require("@dxos/invariant");
|
|
129
135
|
var import_keys6 = require("@dxos/keys");
|
|
130
136
|
var import_log5 = require("@dxos/log");
|
|
@@ -135,6 +141,7 @@ var import_teleport = require("@dxos/teleport");
|
|
|
135
141
|
var import_async9 = require("@dxos/async");
|
|
136
142
|
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
137
143
|
var import_context6 = require("@dxos/context");
|
|
144
|
+
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
138
145
|
var import_invariant7 = require("@dxos/invariant");
|
|
139
146
|
var import_log6 = require("@dxos/log");
|
|
140
147
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
@@ -148,121 +155,127 @@ var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
|
148
155
|
var import_debug2 = require("@dxos/debug");
|
|
149
156
|
var import_rpc = require("@dxos/rpc");
|
|
150
157
|
var import_tracing3 = require("@dxos/tracing");
|
|
151
|
-
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
152
|
-
var import_credentials9 = require("@dxos/credentials");
|
|
153
|
-
var import_invariant9 = require("@dxos/invariant");
|
|
154
|
-
var import_protocols7 = require("@dxos/protocols");
|
|
155
|
-
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
156
|
-
var import_tracing4 = require("@dxos/tracing");
|
|
157
|
-
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
158
158
|
var import_async10 = require("@dxos/async");
|
|
159
159
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
160
160
|
var import_context7 = require("@dxos/context");
|
|
161
161
|
var import_debug3 = require("@dxos/debug");
|
|
162
162
|
var import_echo_db = require("@dxos/echo-db");
|
|
163
|
-
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
164
163
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
165
|
-
var
|
|
164
|
+
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
165
|
+
var import_invariant9 = require("@dxos/invariant");
|
|
166
166
|
var import_keys7 = require("@dxos/keys");
|
|
167
167
|
var import_log8 = require("@dxos/log");
|
|
168
|
-
var
|
|
169
|
-
var
|
|
170
|
-
var
|
|
168
|
+
var import_protocols7 = require("@dxos/protocols");
|
|
169
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
170
|
+
var import_credentials9 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
171
171
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
172
|
-
var
|
|
172
|
+
var import_tracing4 = require("@dxos/tracing");
|
|
173
173
|
var import_util4 = require("@dxos/util");
|
|
174
174
|
var import_async11 = require("@dxos/async");
|
|
175
|
-
var
|
|
175
|
+
var import_credentials10 = require("@dxos/credentials");
|
|
176
176
|
var import_async12 = require("@dxos/async");
|
|
177
177
|
var import_context8 = require("@dxos/context");
|
|
178
|
-
var
|
|
178
|
+
var import_invariant10 = require("@dxos/invariant");
|
|
179
179
|
var import_keys8 = require("@dxos/keys");
|
|
180
180
|
var import_log9 = require("@dxos/log");
|
|
181
|
-
var
|
|
181
|
+
var import_protocols8 = require("@dxos/protocols");
|
|
182
182
|
var import_teleport2 = require("@dxos/teleport");
|
|
183
183
|
var import_util5 = require("@dxos/util");
|
|
184
184
|
var import_async13 = require("@dxos/async");
|
|
185
185
|
var import_context9 = require("@dxos/context");
|
|
186
|
-
var
|
|
187
|
-
var
|
|
186
|
+
var import_credentials11 = require("@dxos/credentials");
|
|
187
|
+
var import_invariant11 = require("@dxos/invariant");
|
|
188
188
|
var import_keys9 = require("@dxos/keys");
|
|
189
189
|
var import_log10 = require("@dxos/log");
|
|
190
|
-
var
|
|
191
|
-
var
|
|
190
|
+
var import_protocols9 = require("@dxos/protocols");
|
|
191
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
192
192
|
var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
|
|
193
193
|
var import_util6 = require("@dxos/util");
|
|
194
|
-
var
|
|
194
|
+
var import_credentials12 = require("@dxos/credentials");
|
|
195
195
|
var import_debug4 = require("@dxos/debug");
|
|
196
|
-
var
|
|
196
|
+
var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
197
197
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
198
198
|
var import_async14 = require("@dxos/async");
|
|
199
|
-
var
|
|
199
|
+
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
200
200
|
var import_debug5 = require("@dxos/debug");
|
|
201
|
-
var
|
|
201
|
+
var import_invariant12 = require("@dxos/invariant");
|
|
202
202
|
var import_log11 = require("@dxos/log");
|
|
203
|
-
var
|
|
204
|
-
var
|
|
203
|
+
var import_protocols10 = require("@dxos/protocols");
|
|
204
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
205
205
|
var import_async15 = require("@dxos/async");
|
|
206
206
|
var import_context10 = require("@dxos/context");
|
|
207
|
-
var
|
|
207
|
+
var import_credentials14 = require("@dxos/credentials");
|
|
208
208
|
var import_debug6 = require("@dxos/debug");
|
|
209
|
-
var
|
|
209
|
+
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
210
210
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
211
211
|
var import_indexing = require("@dxos/indexing");
|
|
212
|
-
var
|
|
212
|
+
var import_invariant13 = require("@dxos/invariant");
|
|
213
213
|
var import_keyring = require("@dxos/keyring");
|
|
214
214
|
var import_keys10 = require("@dxos/keys");
|
|
215
215
|
var import_log12 = require("@dxos/log");
|
|
216
|
-
var
|
|
217
|
-
var
|
|
216
|
+
var import_protocols11 = require("@dxos/protocols");
|
|
217
|
+
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
218
218
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
219
|
-
var
|
|
219
|
+
var import_tracing5 = require("@dxos/tracing");
|
|
220
220
|
var import_util7 = require("@dxos/util");
|
|
221
221
|
var import_automerge = require("@dxos/automerge/automerge");
|
|
222
222
|
var import_debug7 = require("@dxos/debug");
|
|
223
|
+
var import_protocols12 = require("@dxos/protocols");
|
|
224
|
+
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
225
|
+
var import_credentials15 = require("@dxos/credentials");
|
|
226
|
+
var import_invariant14 = require("@dxos/invariant");
|
|
223
227
|
var import_protocols13 = require("@dxos/protocols");
|
|
224
|
-
var
|
|
225
|
-
var
|
|
226
|
-
var
|
|
227
|
-
var
|
|
228
|
-
var
|
|
229
|
-
var
|
|
230
|
-
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
231
|
-
var import_config2 = require("@dxos/protocols/proto/dxos/config");
|
|
228
|
+
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
229
|
+
var import_tracing6 = require("@dxos/tracing");
|
|
230
|
+
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
231
|
+
var import_config = require("@dxos/config");
|
|
232
|
+
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
233
|
+
var import_tracing7 = require("@dxos/tracing");
|
|
232
234
|
var import_util8 = require("@dxos/util");
|
|
233
|
-
var import_level = require("level");
|
|
234
|
-
var import_node_path = __toESM(require("node:path"));
|
|
235
|
-
var import_keys11 = require("@dxos/keys");
|
|
236
235
|
var import_async16 = require("@dxos/async");
|
|
237
|
-
var
|
|
236
|
+
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
238
237
|
var import_context11 = require("@dxos/context");
|
|
239
|
-
var
|
|
240
|
-
var
|
|
238
|
+
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
239
|
+
var import_echo_schema = require("@dxos/echo-schema");
|
|
241
240
|
var import_indexing2 = require("@dxos/indexing");
|
|
242
|
-
var
|
|
243
|
-
var
|
|
244
|
-
var
|
|
241
|
+
var import_invariant15 = require("@dxos/invariant");
|
|
242
|
+
var import_keys11 = require("@dxos/keys");
|
|
243
|
+
var import_log13 = require("@dxos/log");
|
|
245
244
|
var import_messaging = require("@dxos/messaging");
|
|
246
245
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
247
|
-
var
|
|
248
|
-
var
|
|
249
|
-
var
|
|
246
|
+
var import_protocols14 = require("@dxos/protocols");
|
|
247
|
+
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
248
|
+
var import_tracing8 = require("@dxos/tracing");
|
|
250
249
|
var import_util9 = require("@dxos/util");
|
|
251
250
|
var import_websocket_rpc = require("@dxos/websocket-rpc");
|
|
252
251
|
var import_async17 = require("@dxos/async");
|
|
253
252
|
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
253
|
+
var import_invariant16 = require("@dxos/invariant");
|
|
254
|
+
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
254
255
|
var import_invariant17 = require("@dxos/invariant");
|
|
255
|
-
var
|
|
256
|
+
var import_lock_file = require("@dxos/lock-file");
|
|
257
|
+
var import_log14 = require("@dxos/log");
|
|
256
258
|
var import_async18 = require("@dxos/async");
|
|
257
259
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
258
|
-
var
|
|
260
|
+
var import_keys12 = require("@dxos/keys");
|
|
259
261
|
var import_log15 = require("@dxos/log");
|
|
260
|
-
var
|
|
262
|
+
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
261
263
|
var import_util10 = require("@dxos/util");
|
|
262
264
|
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
263
|
-
var
|
|
264
|
-
var
|
|
265
|
+
var import_protocols15 = require("@dxos/protocols");
|
|
266
|
+
var import_config2 = require("@dxos/protocols/proto/dxos/config");
|
|
267
|
+
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
268
|
+
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
269
|
+
var import_config3 = require("@dxos/protocols/proto/dxos/config");
|
|
265
270
|
var import_util11 = require("@dxos/util");
|
|
271
|
+
var import_level = require("level");
|
|
272
|
+
var import_node_path = __toESM(require("node:path"));
|
|
273
|
+
var import_keys13 = require("@dxos/keys");
|
|
274
|
+
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
275
|
+
var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
|
|
276
|
+
var import_util12 = require("@dxos/util");
|
|
277
|
+
var import_keys14 = require("@dxos/keys");
|
|
278
|
+
var import_util13 = require("@dxos/util");
|
|
266
279
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
267
280
|
return new import_codec_protobuf.Stream(({ next }) => {
|
|
268
281
|
const subscriptions = new import_async.EventSubscriptions();
|
|
@@ -1475,6 +1488,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1475
1488
|
this._callbacks = _callbacks;
|
|
1476
1489
|
this._ctx = new import_context5.Context();
|
|
1477
1490
|
this._remoteOptionsTrigger = new import_async8.Trigger();
|
|
1491
|
+
this._challenge = void 0;
|
|
1478
1492
|
this.invitation = void 0;
|
|
1479
1493
|
this.guestProfile = void 0;
|
|
1480
1494
|
this.authenticationPassed = false;
|
|
@@ -1489,7 +1503,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1489
1503
|
options: async (options) => {
|
|
1490
1504
|
(0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1491
1505
|
F: __dxlog_file6,
|
|
1492
|
-
L:
|
|
1506
|
+
L: 90,
|
|
1493
1507
|
S: this,
|
|
1494
1508
|
A: [
|
|
1495
1509
|
"!this._remoteOptions",
|
|
@@ -1506,7 +1520,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1506
1520
|
id: traceId
|
|
1507
1521
|
}), {
|
|
1508
1522
|
F: __dxlog_file6,
|
|
1509
|
-
L:
|
|
1523
|
+
L: 99,
|
|
1510
1524
|
S: this,
|
|
1511
1525
|
C: (f, a) => f(...a)
|
|
1512
1526
|
});
|
|
@@ -1516,7 +1530,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1516
1530
|
invitationId
|
|
1517
1531
|
}, {
|
|
1518
1532
|
F: __dxlog_file6,
|
|
1519
|
-
L:
|
|
1533
|
+
L: 103,
|
|
1520
1534
|
S: this,
|
|
1521
1535
|
C: (f, a) => f(...a)
|
|
1522
1536
|
});
|
|
@@ -1530,7 +1544,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1530
1544
|
guestProfile: profile
|
|
1531
1545
|
}, {
|
|
1532
1546
|
F: __dxlog_file6,
|
|
1533
|
-
L:
|
|
1547
|
+
L: 112,
|
|
1534
1548
|
S: this,
|
|
1535
1549
|
C: (f, a) => f(...a)
|
|
1536
1550
|
});
|
|
@@ -1539,25 +1553,27 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1539
1553
|
...this.invitation,
|
|
1540
1554
|
state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1541
1555
|
});
|
|
1556
|
+
this._challenge = this.invitation.authMethod === import_services4.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto2.randomBytes)(32) : void 0;
|
|
1542
1557
|
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols5.trace.end({
|
|
1543
1558
|
id: traceId
|
|
1544
1559
|
}), {
|
|
1545
1560
|
F: __dxlog_file6,
|
|
1546
|
-
L:
|
|
1561
|
+
L: 122,
|
|
1547
1562
|
S: this,
|
|
1548
1563
|
C: (f, a) => f(...a)
|
|
1549
1564
|
});
|
|
1550
1565
|
return {
|
|
1551
|
-
authMethod: this.invitation.authMethod
|
|
1566
|
+
authMethod: this.invitation.authMethod,
|
|
1567
|
+
challenge: this._challenge
|
|
1552
1568
|
};
|
|
1553
1569
|
},
|
|
1554
|
-
authenticate: async ({ authCode: code }) => {
|
|
1570
|
+
authenticate: async ({ authCode: code, signedChallenge }) => {
|
|
1555
1571
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
1556
1572
|
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols5.trace.begin({
|
|
1557
1573
|
id: traceId
|
|
1558
1574
|
}), {
|
|
1559
1575
|
F: __dxlog_file6,
|
|
1560
|
-
L:
|
|
1576
|
+
L: 131,
|
|
1561
1577
|
S: this,
|
|
1562
1578
|
C: (f, a) => f(...a)
|
|
1563
1579
|
});
|
|
@@ -1565,14 +1581,14 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1565
1581
|
authCode: code
|
|
1566
1582
|
}, {
|
|
1567
1583
|
F: __dxlog_file6,
|
|
1568
|
-
L:
|
|
1584
|
+
L: 132,
|
|
1569
1585
|
S: this,
|
|
1570
1586
|
C: (f, a) => f(...a)
|
|
1571
1587
|
});
|
|
1572
1588
|
let status = import_invitations2.AuthenticationResponse.Status.OK;
|
|
1573
1589
|
(0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
|
|
1574
1590
|
F: __dxlog_file6,
|
|
1575
|
-
L:
|
|
1591
|
+
L: 135,
|
|
1576
1592
|
S: this,
|
|
1577
1593
|
A: [
|
|
1578
1594
|
"this.invitation",
|
|
@@ -1583,7 +1599,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1583
1599
|
case import_services4.Invitation.AuthMethod.NONE: {
|
|
1584
1600
|
(0, import_log5.log)("authentication not required", void 0, {
|
|
1585
1601
|
F: __dxlog_file6,
|
|
1586
|
-
L:
|
|
1602
|
+
L: 138,
|
|
1587
1603
|
S: this,
|
|
1588
1604
|
C: (f, a) => f(...a)
|
|
1589
1605
|
});
|
|
@@ -1603,12 +1619,25 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1603
1619
|
}
|
|
1604
1620
|
break;
|
|
1605
1621
|
}
|
|
1622
|
+
case import_services4.Invitation.AuthMethod.KNOWN_PUBLIC_KEY: {
|
|
1623
|
+
if (!this.invitation.guestKeypair) {
|
|
1624
|
+
status = import_invitations2.AuthenticationResponse.Status.INTERNAL_ERROR;
|
|
1625
|
+
break;
|
|
1626
|
+
}
|
|
1627
|
+
const isSignatureValid = this._challenge && (0, import_crypto2.verify)(this._challenge, Buffer.from(signedChallenge ?? []), this.invitation.guestKeypair.publicKey.asBuffer());
|
|
1628
|
+
if (isSignatureValid) {
|
|
1629
|
+
this.authenticationPassed = true;
|
|
1630
|
+
} else {
|
|
1631
|
+
status = import_invitations2.AuthenticationResponse.Status.INVALID_SIGNATURE;
|
|
1632
|
+
}
|
|
1633
|
+
break;
|
|
1634
|
+
}
|
|
1606
1635
|
default: {
|
|
1607
1636
|
import_log5.log.error("invalid authentication method", {
|
|
1608
1637
|
authMethod: this.invitation.authMethod
|
|
1609
1638
|
}, {
|
|
1610
1639
|
F: __dxlog_file6,
|
|
1611
|
-
L:
|
|
1640
|
+
L: 176,
|
|
1612
1641
|
S: this,
|
|
1613
1642
|
C: (f, a) => f(...a)
|
|
1614
1643
|
});
|
|
@@ -1623,7 +1652,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1623
1652
|
}
|
|
1624
1653
|
}), {
|
|
1625
1654
|
F: __dxlog_file6,
|
|
1626
|
-
L:
|
|
1655
|
+
L: 182,
|
|
1627
1656
|
S: this,
|
|
1628
1657
|
C: (f, a) => f(...a)
|
|
1629
1658
|
});
|
|
@@ -1637,14 +1666,14 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1637
1666
|
id: traceId
|
|
1638
1667
|
}), {
|
|
1639
1668
|
F: __dxlog_file6,
|
|
1640
|
-
L:
|
|
1669
|
+
L: 188,
|
|
1641
1670
|
S: this,
|
|
1642
1671
|
C: (f, a) => f(...a)
|
|
1643
1672
|
});
|
|
1644
1673
|
try {
|
|
1645
1674
|
(0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
|
|
1646
1675
|
F: __dxlog_file6,
|
|
1647
|
-
L:
|
|
1676
|
+
L: 191,
|
|
1648
1677
|
S: this,
|
|
1649
1678
|
A: [
|
|
1650
1679
|
"this.invitation",
|
|
@@ -1659,7 +1688,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1659
1688
|
id: traceId
|
|
1660
1689
|
}), {
|
|
1661
1690
|
F: __dxlog_file6,
|
|
1662
|
-
L:
|
|
1691
|
+
L: 199,
|
|
1663
1692
|
S: this,
|
|
1664
1693
|
C: (f, a) => f(...a)
|
|
1665
1694
|
});
|
|
@@ -1716,7 +1745,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1716
1745
|
options: async (options) => {
|
|
1717
1746
|
(0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1718
1747
|
F: __dxlog_file6,
|
|
1719
|
-
L:
|
|
1748
|
+
L: 266,
|
|
1720
1749
|
S: this,
|
|
1721
1750
|
A: [
|
|
1722
1751
|
"!this._remoteOptions",
|
|
@@ -1743,7 +1772,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1743
1772
|
try {
|
|
1744
1773
|
(0, import_log5.log)("begin options", void 0, {
|
|
1745
1774
|
F: __dxlog_file6,
|
|
1746
|
-
L:
|
|
1775
|
+
L: 287,
|
|
1747
1776
|
S: this,
|
|
1748
1777
|
C: (f, a) => f(...a)
|
|
1749
1778
|
});
|
|
@@ -1755,7 +1784,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1755
1784
|
}));
|
|
1756
1785
|
(0, import_log5.log)("end options", void 0, {
|
|
1757
1786
|
F: __dxlog_file6,
|
|
1758
|
-
L:
|
|
1787
|
+
L: 290,
|
|
1759
1788
|
S: this,
|
|
1760
1789
|
C: (f, a) => f(...a)
|
|
1761
1790
|
});
|
|
@@ -1769,7 +1798,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1769
1798
|
} catch (err) {
|
|
1770
1799
|
(0, import_log5.log)("openError", err, {
|
|
1771
1800
|
F: __dxlog_file6,
|
|
1772
|
-
L:
|
|
1801
|
+
L: 300,
|
|
1773
1802
|
S: this,
|
|
1774
1803
|
C: (f, a) => f(...a)
|
|
1775
1804
|
});
|
|
@@ -1779,7 +1808,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1779
1808
|
async onClose() {
|
|
1780
1809
|
(0, import_log5.log)("onClose", void 0, {
|
|
1781
1810
|
F: __dxlog_file6,
|
|
1782
|
-
L:
|
|
1811
|
+
L: 306,
|
|
1783
1812
|
S: this,
|
|
1784
1813
|
C: (f, a) => f(...a)
|
|
1785
1814
|
});
|
|
@@ -1796,11 +1825,11 @@ var InvitationsHandler = class {
|
|
|
1796
1825
|
this._networkManager = _networkManager;
|
|
1797
1826
|
}
|
|
1798
1827
|
createInvitation(protocol, options) {
|
|
1799
|
-
const { invitationId = import_keys5.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys5.PublicKey.random(), persistent =
|
|
1828
|
+
const { invitationId = import_keys5.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys5.PublicKey.random(), persistent = options?.authMethod !== import_services3.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, lifetime = 86400, multiUse = false } = options ?? {};
|
|
1800
1829
|
const authCode = options?.authCode ?? (authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1801
1830
|
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
1802
1831
|
F: __dxlog_file7,
|
|
1803
|
-
L:
|
|
1832
|
+
L: 87,
|
|
1804
1833
|
S: this,
|
|
1805
1834
|
A: [
|
|
1806
1835
|
"protocol",
|
|
@@ -1815,9 +1844,11 @@ var InvitationsHandler = class {
|
|
|
1815
1844
|
swarmKey,
|
|
1816
1845
|
authCode,
|
|
1817
1846
|
timeout,
|
|
1818
|
-
persistent,
|
|
1847
|
+
persistent: persistent && type !== import_services3.Invitation.Type.DELEGATED,
|
|
1848
|
+
guestKeypair: guestKeypair ?? (authMethod === import_services3.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
|
|
1819
1849
|
created,
|
|
1820
1850
|
lifetime,
|
|
1851
|
+
multiUse,
|
|
1821
1852
|
...protocol.getInvitationContext()
|
|
1822
1853
|
};
|
|
1823
1854
|
const stream = new import_async7.PushStream();
|
|
@@ -1832,7 +1863,7 @@ var InvitationsHandler = class {
|
|
|
1832
1863
|
...protocol.toJSON()
|
|
1833
1864
|
}, {
|
|
1834
1865
|
F: __dxlog_file7,
|
|
1835
|
-
L:
|
|
1866
|
+
L: 115,
|
|
1836
1867
|
S: this,
|
|
1837
1868
|
C: (f, a) => f(...a)
|
|
1838
1869
|
});
|
|
@@ -1857,7 +1888,7 @@ var InvitationsHandler = class {
|
|
|
1857
1888
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1858
1889
|
(0, import_invariant5.invariant)(deviceKey, void 0, {
|
|
1859
1890
|
F: __dxlog_file7,
|
|
1860
|
-
L:
|
|
1891
|
+
L: 136,
|
|
1861
1892
|
S: this,
|
|
1862
1893
|
A: [
|
|
1863
1894
|
"deviceKey",
|
|
@@ -1880,7 +1911,7 @@ var InvitationsHandler = class {
|
|
|
1880
1911
|
id: traceId
|
|
1881
1912
|
}), {
|
|
1882
1913
|
F: __dxlog_file7,
|
|
1883
|
-
L:
|
|
1914
|
+
L: 154,
|
|
1884
1915
|
S: this,
|
|
1885
1916
|
C: (f, a) => f(...a)
|
|
1886
1917
|
});
|
|
@@ -1888,7 +1919,7 @@ var InvitationsHandler = class {
|
|
|
1888
1919
|
...protocol.toJSON()
|
|
1889
1920
|
}, {
|
|
1890
1921
|
F: __dxlog_file7,
|
|
1891
|
-
L:
|
|
1922
|
+
L: 155,
|
|
1892
1923
|
S: this,
|
|
1893
1924
|
C: (f, a) => f(...a)
|
|
1894
1925
|
});
|
|
@@ -1904,7 +1935,7 @@ var InvitationsHandler = class {
|
|
|
1904
1935
|
...protocol.toJSON()
|
|
1905
1936
|
}, {
|
|
1906
1937
|
F: __dxlog_file7,
|
|
1907
|
-
L:
|
|
1938
|
+
L: 158,
|
|
1908
1939
|
S: this,
|
|
1909
1940
|
C: (f, a) => f(...a)
|
|
1910
1941
|
});
|
|
@@ -1916,7 +1947,7 @@ var InvitationsHandler = class {
|
|
|
1916
1947
|
id: traceId
|
|
1917
1948
|
}), {
|
|
1918
1949
|
F: __dxlog_file7,
|
|
1919
|
-
L:
|
|
1950
|
+
L: 160,
|
|
1920
1951
|
S: this,
|
|
1921
1952
|
C: (f, a) => f(...a)
|
|
1922
1953
|
});
|
|
@@ -1926,7 +1957,7 @@ var InvitationsHandler = class {
|
|
|
1926
1957
|
...protocol.toJSON()
|
|
1927
1958
|
}, {
|
|
1928
1959
|
F: __dxlog_file7,
|
|
1929
|
-
L:
|
|
1960
|
+
L: 163,
|
|
1930
1961
|
S: this,
|
|
1931
1962
|
C: (f, a) => f(...a)
|
|
1932
1963
|
});
|
|
@@ -1937,7 +1968,7 @@ var InvitationsHandler = class {
|
|
|
1937
1968
|
} else {
|
|
1938
1969
|
import_log4.log.error("failed", err, {
|
|
1939
1970
|
F: __dxlog_file7,
|
|
1940
|
-
L:
|
|
1971
|
+
L: 166,
|
|
1941
1972
|
S: this,
|
|
1942
1973
|
C: (f, a) => f(...a)
|
|
1943
1974
|
});
|
|
@@ -1948,12 +1979,12 @@ var InvitationsHandler = class {
|
|
|
1948
1979
|
error: err
|
|
1949
1980
|
}), {
|
|
1950
1981
|
F: __dxlog_file7,
|
|
1951
|
-
L:
|
|
1982
|
+
L: 169,
|
|
1952
1983
|
S: this,
|
|
1953
1984
|
C: (f, a) => f(...a)
|
|
1954
1985
|
});
|
|
1955
1986
|
} finally {
|
|
1956
|
-
if (
|
|
1987
|
+
if (!multiUse) {
|
|
1957
1988
|
await swarmConnection.close();
|
|
1958
1989
|
await ctx.dispose();
|
|
1959
1990
|
}
|
|
@@ -1969,7 +2000,7 @@ var InvitationsHandler = class {
|
|
|
1969
2000
|
...protocol.toJSON()
|
|
1970
2001
|
}, {
|
|
1971
2002
|
F: __dxlog_file7,
|
|
1972
|
-
L:
|
|
2003
|
+
L: 184,
|
|
1973
2004
|
S: this,
|
|
1974
2005
|
C: (f, a) => f(...a)
|
|
1975
2006
|
});
|
|
@@ -1980,7 +2011,7 @@ var InvitationsHandler = class {
|
|
|
1980
2011
|
} else {
|
|
1981
2012
|
import_log4.log.error("failed", err, {
|
|
1982
2013
|
F: __dxlog_file7,
|
|
1983
|
-
L:
|
|
2014
|
+
L: 187,
|
|
1984
2015
|
S: this,
|
|
1985
2016
|
C: (f, a) => f(...a)
|
|
1986
2017
|
});
|
|
@@ -1994,7 +2025,7 @@ var InvitationsHandler = class {
|
|
|
1994
2025
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
1995
2026
|
import_log4.log.warn("invitation has already expired", void 0, {
|
|
1996
2027
|
F: __dxlog_file7,
|
|
1997
|
-
L:
|
|
2028
|
+
L: 198,
|
|
1998
2029
|
S: this,
|
|
1999
2030
|
C: (f, a) => f(...a)
|
|
2000
2031
|
});
|
|
@@ -2045,7 +2076,7 @@ var InvitationsHandler = class {
|
|
|
2045
2076
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
2046
2077
|
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
2047
2078
|
F: __dxlog_file7,
|
|
2048
|
-
L:
|
|
2079
|
+
L: 252,
|
|
2049
2080
|
S: this,
|
|
2050
2081
|
A: [
|
|
2051
2082
|
"protocol",
|
|
@@ -2055,7 +2086,7 @@ var InvitationsHandler = class {
|
|
|
2055
2086
|
if (deviceProfile) {
|
|
2056
2087
|
(0, import_invariant5.invariant)(invitation.kind === import_services3.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2057
2088
|
F: __dxlog_file7,
|
|
2058
|
-
L:
|
|
2089
|
+
L: 256,
|
|
2059
2090
|
S: this,
|
|
2060
2091
|
A: [
|
|
2061
2092
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -2070,7 +2101,7 @@ var InvitationsHandler = class {
|
|
|
2070
2101
|
const setState = (newData) => {
|
|
2071
2102
|
(0, import_invariant5.invariant)(newData.state !== void 0, void 0, {
|
|
2072
2103
|
F: __dxlog_file7,
|
|
2073
|
-
L:
|
|
2104
|
+
L: 267,
|
|
2074
2105
|
S: this,
|
|
2075
2106
|
A: [
|
|
2076
2107
|
"newData.state !== undefined",
|
|
@@ -2090,7 +2121,7 @@ var InvitationsHandler = class {
|
|
|
2090
2121
|
...protocol.toJSON()
|
|
2091
2122
|
}, {
|
|
2092
2123
|
F: __dxlog_file7,
|
|
2093
|
-
L:
|
|
2124
|
+
L: 275,
|
|
2094
2125
|
S: this,
|
|
2095
2126
|
C: (f, a) => f(...a)
|
|
2096
2127
|
});
|
|
@@ -2100,7 +2131,7 @@ var InvitationsHandler = class {
|
|
|
2100
2131
|
} else {
|
|
2101
2132
|
import_log4.log.warn("auth failed", err, {
|
|
2102
2133
|
F: __dxlog_file7,
|
|
2103
|
-
L:
|
|
2134
|
+
L: 278,
|
|
2104
2135
|
S: this,
|
|
2105
2136
|
C: (f, a) => f(...a)
|
|
2106
2137
|
});
|
|
@@ -2114,7 +2145,7 @@ var InvitationsHandler = class {
|
|
|
2114
2145
|
...protocol.toJSON()
|
|
2115
2146
|
}, {
|
|
2116
2147
|
F: __dxlog_file7,
|
|
2117
|
-
L:
|
|
2148
|
+
L: 286,
|
|
2118
2149
|
S: this,
|
|
2119
2150
|
C: (f, a) => f(...a)
|
|
2120
2151
|
});
|
|
@@ -2129,7 +2160,7 @@ var InvitationsHandler = class {
|
|
|
2129
2160
|
currentState
|
|
2130
2161
|
}, {
|
|
2131
2162
|
F: __dxlog_file7,
|
|
2132
|
-
L:
|
|
2163
|
+
L: 296,
|
|
2133
2164
|
S: this,
|
|
2134
2165
|
C: (f, a) => f(...a)
|
|
2135
2166
|
});
|
|
@@ -2144,7 +2175,7 @@ var InvitationsHandler = class {
|
|
|
2144
2175
|
id: traceId
|
|
2145
2176
|
}), {
|
|
2146
2177
|
F: __dxlog_file7,
|
|
2147
|
-
L:
|
|
2178
|
+
L: 305,
|
|
2148
2179
|
S: this,
|
|
2149
2180
|
C: (f, a) => f(...a)
|
|
2150
2181
|
});
|
|
@@ -2156,7 +2187,7 @@ var InvitationsHandler = class {
|
|
|
2156
2187
|
...protocol.toJSON()
|
|
2157
2188
|
}, {
|
|
2158
2189
|
F: __dxlog_file7,
|
|
2159
|
-
L:
|
|
2190
|
+
L: 313,
|
|
2160
2191
|
S: this,
|
|
2161
2192
|
C: (f, a) => f(...a)
|
|
2162
2193
|
});
|
|
@@ -2167,7 +2198,7 @@ var InvitationsHandler = class {
|
|
|
2167
2198
|
...protocol.toJSON()
|
|
2168
2199
|
}, {
|
|
2169
2200
|
F: __dxlog_file7,
|
|
2170
|
-
L:
|
|
2201
|
+
L: 317,
|
|
2171
2202
|
S: this,
|
|
2172
2203
|
C: (f, a) => f(...a)
|
|
2173
2204
|
});
|
|
@@ -2177,62 +2208,28 @@ var InvitationsHandler = class {
|
|
|
2177
2208
|
response: introductionResponse
|
|
2178
2209
|
}, {
|
|
2179
2210
|
F: __dxlog_file7,
|
|
2180
|
-
L:
|
|
2211
|
+
L: 321,
|
|
2181
2212
|
S: this,
|
|
2182
2213
|
C: (f, a) => f(...a)
|
|
2183
2214
|
});
|
|
2184
2215
|
invitation.authMethod = introductionResponse.authMethod;
|
|
2185
2216
|
if (isAuthenticationRequired(invitation)) {
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
2195
|
-
});
|
|
2196
|
-
const authCode = await authenticated.wait({
|
|
2197
|
-
timeout
|
|
2198
|
-
});
|
|
2199
|
-
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2200
|
-
F: __dxlog_file7,
|
|
2201
|
-
L: 325,
|
|
2202
|
-
S: this,
|
|
2203
|
-
C: (f, a) => f(...a)
|
|
2204
|
-
});
|
|
2205
|
-
setState({
|
|
2206
|
-
state: import_services3.Invitation.State.AUTHENTICATING
|
|
2207
|
-
});
|
|
2208
|
-
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2209
|
-
authCode
|
|
2210
|
-
});
|
|
2211
|
-
if (response.status === void 0 || response.status === import_invitations.AuthenticationResponse.Status.OK) {
|
|
2217
|
+
switch (invitation.authMethod) {
|
|
2218
|
+
case import_services3.Invitation.AuthMethod.SHARED_SECRET:
|
|
2219
|
+
await this._handleGuestOtpAuth(extension, setState, authenticated, {
|
|
2220
|
+
timeout
|
|
2221
|
+
});
|
|
2222
|
+
break;
|
|
2223
|
+
case import_services3.Invitation.AuthMethod.KNOWN_PUBLIC_KEY:
|
|
2224
|
+
await this._handleGuestKpkAuth(extension, setState, invitation, introductionResponse);
|
|
2212
2225
|
break;
|
|
2213
|
-
}
|
|
2214
|
-
if (response.status === import_invitations.AuthenticationResponse.Status.INVALID_OTP) {
|
|
2215
|
-
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2216
|
-
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2217
|
-
} else {
|
|
2218
|
-
(0, import_log4.log)("retrying invalid code", {
|
|
2219
|
-
attempt
|
|
2220
|
-
}, {
|
|
2221
|
-
F: __dxlog_file7,
|
|
2222
|
-
L: 336,
|
|
2223
|
-
S: this,
|
|
2224
|
-
C: (f, a) => f(...a)
|
|
2225
|
-
});
|
|
2226
|
-
authenticated.reset();
|
|
2227
|
-
}
|
|
2228
|
-
}
|
|
2229
2226
|
}
|
|
2230
2227
|
}
|
|
2231
2228
|
(0, import_log4.log)("request admission", {
|
|
2232
2229
|
...protocol.toJSON()
|
|
2233
2230
|
}, {
|
|
2234
2231
|
F: __dxlog_file7,
|
|
2235
|
-
L:
|
|
2232
|
+
L: 337,
|
|
2236
2233
|
S: this,
|
|
2237
2234
|
C: (f, a) => f(...a)
|
|
2238
2235
|
});
|
|
@@ -2244,7 +2241,7 @@ var InvitationsHandler = class {
|
|
|
2244
2241
|
...protocol.toJSON()
|
|
2245
2242
|
}, {
|
|
2246
2243
|
F: __dxlog_file7,
|
|
2247
|
-
L:
|
|
2244
|
+
L: 348,
|
|
2248
2245
|
S: this,
|
|
2249
2246
|
C: (f, a) => f(...a)
|
|
2250
2247
|
});
|
|
@@ -2257,7 +2254,7 @@ var InvitationsHandler = class {
|
|
|
2257
2254
|
id: traceId
|
|
2258
2255
|
}), {
|
|
2259
2256
|
F: __dxlog_file7,
|
|
2260
|
-
L:
|
|
2257
|
+
L: 350,
|
|
2261
2258
|
S: this,
|
|
2262
2259
|
C: (f, a) => f(...a)
|
|
2263
2260
|
});
|
|
@@ -2267,7 +2264,7 @@ var InvitationsHandler = class {
|
|
|
2267
2264
|
...protocol.toJSON()
|
|
2268
2265
|
}, {
|
|
2269
2266
|
F: __dxlog_file7,
|
|
2270
|
-
L:
|
|
2267
|
+
L: 353,
|
|
2271
2268
|
S: this,
|
|
2272
2269
|
C: (f, a) => f(...a)
|
|
2273
2270
|
});
|
|
@@ -2277,7 +2274,7 @@ var InvitationsHandler = class {
|
|
|
2277
2274
|
} else {
|
|
2278
2275
|
(0, import_log4.log)("auth failed", err, {
|
|
2279
2276
|
F: __dxlog_file7,
|
|
2280
|
-
L:
|
|
2277
|
+
L: 356,
|
|
2281
2278
|
S: this,
|
|
2282
2279
|
C: (f, a) => f(...a)
|
|
2283
2280
|
});
|
|
@@ -2288,7 +2285,7 @@ var InvitationsHandler = class {
|
|
|
2288
2285
|
error: err
|
|
2289
2286
|
}), {
|
|
2290
2287
|
F: __dxlog_file7,
|
|
2291
|
-
L:
|
|
2288
|
+
L: 359,
|
|
2292
2289
|
S: this,
|
|
2293
2290
|
C: (f, a) => f(...a)
|
|
2294
2291
|
});
|
|
@@ -2306,7 +2303,7 @@ var InvitationsHandler = class {
|
|
|
2306
2303
|
...protocol.toJSON()
|
|
2307
2304
|
}, {
|
|
2308
2305
|
F: __dxlog_file7,
|
|
2309
|
-
L:
|
|
2306
|
+
L: 370,
|
|
2310
2307
|
S: this,
|
|
2311
2308
|
C: (f, a) => f(...a)
|
|
2312
2309
|
});
|
|
@@ -2316,7 +2313,7 @@ var InvitationsHandler = class {
|
|
|
2316
2313
|
} else {
|
|
2317
2314
|
(0, import_log4.log)("auth failed", err, {
|
|
2318
2315
|
F: __dxlog_file7,
|
|
2319
|
-
L:
|
|
2316
|
+
L: 373,
|
|
2320
2317
|
S: this,
|
|
2321
2318
|
C: (f, a) => f(...a)
|
|
2322
2319
|
});
|
|
@@ -2333,7 +2330,7 @@ var InvitationsHandler = class {
|
|
|
2333
2330
|
} else {
|
|
2334
2331
|
(0, import_invariant5.invariant)(invitation.swarmKey, void 0, {
|
|
2335
2332
|
F: __dxlog_file7,
|
|
2336
|
-
L:
|
|
2333
|
+
L: 387,
|
|
2337
2334
|
S: this,
|
|
2338
2335
|
A: [
|
|
2339
2336
|
"invitation.swarmKey",
|
|
@@ -2371,9 +2368,81 @@ var InvitationsHandler = class {
|
|
|
2371
2368
|
});
|
|
2372
2369
|
return observable;
|
|
2373
2370
|
}
|
|
2371
|
+
async _handleGuestOtpAuth(extension, setState, authenticated, options) {
|
|
2372
|
+
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2373
|
+
(0, import_log4.log)("guest waiting for authentication code...", void 0, {
|
|
2374
|
+
F: __dxlog_file7,
|
|
2375
|
+
L: 427,
|
|
2376
|
+
S: this,
|
|
2377
|
+
C: (f, a) => f(...a)
|
|
2378
|
+
});
|
|
2379
|
+
setState({
|
|
2380
|
+
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
2381
|
+
});
|
|
2382
|
+
const authCode = await authenticated.wait(options);
|
|
2383
|
+
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2384
|
+
F: __dxlog_file7,
|
|
2385
|
+
L: 431,
|
|
2386
|
+
S: this,
|
|
2387
|
+
C: (f, a) => f(...a)
|
|
2388
|
+
});
|
|
2389
|
+
setState({
|
|
2390
|
+
state: import_services3.Invitation.State.AUTHENTICATING
|
|
2391
|
+
});
|
|
2392
|
+
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2393
|
+
authCode
|
|
2394
|
+
});
|
|
2395
|
+
if (response.status === void 0 || response.status === import_invitations.AuthenticationResponse.Status.OK) {
|
|
2396
|
+
break;
|
|
2397
|
+
}
|
|
2398
|
+
if (response.status === import_invitations.AuthenticationResponse.Status.INVALID_OTP) {
|
|
2399
|
+
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2400
|
+
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2401
|
+
} else {
|
|
2402
|
+
(0, import_log4.log)("retrying invalid code", {
|
|
2403
|
+
attempt
|
|
2404
|
+
}, {
|
|
2405
|
+
F: __dxlog_file7,
|
|
2406
|
+
L: 442,
|
|
2407
|
+
S: this,
|
|
2408
|
+
C: (f, a) => f(...a)
|
|
2409
|
+
});
|
|
2410
|
+
authenticated.reset();
|
|
2411
|
+
}
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
}
|
|
2415
|
+
async _handleGuestKpkAuth(extension, setState, invitation, introductionResponse) {
|
|
2416
|
+
if (invitation.guestKeypair?.privateKey == null) {
|
|
2417
|
+
throw new Error("keypair missing in the invitation");
|
|
2418
|
+
}
|
|
2419
|
+
if (introductionResponse.challenge == null) {
|
|
2420
|
+
throw new Error("challenge missing in the introduction");
|
|
2421
|
+
}
|
|
2422
|
+
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2423
|
+
F: __dxlog_file7,
|
|
2424
|
+
L: 461,
|
|
2425
|
+
S: this,
|
|
2426
|
+
C: (f, a) => f(...a)
|
|
2427
|
+
});
|
|
2428
|
+
setState({
|
|
2429
|
+
state: import_services3.Invitation.State.AUTHENTICATING
|
|
2430
|
+
});
|
|
2431
|
+
const signature = (0, import_crypto.sign)(Buffer.from(introductionResponse.challenge), invitation.guestKeypair.privateKey);
|
|
2432
|
+
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2433
|
+
signedChallenge: signature
|
|
2434
|
+
});
|
|
2435
|
+
if (response.status !== import_invitations.AuthenticationResponse.Status.OK) {
|
|
2436
|
+
throw new Error(`Authentication failed with code: ${response.status}`);
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2374
2439
|
};
|
|
2375
|
-
var
|
|
2376
|
-
|
|
2440
|
+
var createAdmissionKeypair = () => {
|
|
2441
|
+
const keypair = (0, import_crypto.createKeyPair)();
|
|
2442
|
+
return {
|
|
2443
|
+
publicKey: import_keys5.PublicKey.from(keypair.publicKey),
|
|
2444
|
+
privateKey: keypair.secretKey
|
|
2445
|
+
};
|
|
2377
2446
|
};
|
|
2378
2447
|
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
2379
2448
|
var InvitationsServiceImpl = class {
|
|
@@ -2430,7 +2499,7 @@ var InvitationsServiceImpl = class {
|
|
|
2430
2499
|
await this._metadataStore.removeInvitation(invitation.get().invitationId);
|
|
2431
2500
|
}
|
|
2432
2501
|
this._createInvitations.delete(invitation.get().invitationId);
|
|
2433
|
-
if (invitation.get().
|
|
2502
|
+
if (!invitation.get().multiUse) {
|
|
2434
2503
|
this._removedCreated.emit(invitation.get());
|
|
2435
2504
|
}
|
|
2436
2505
|
});
|
|
@@ -2438,7 +2507,7 @@ var InvitationsServiceImpl = class {
|
|
|
2438
2507
|
}
|
|
2439
2508
|
async loadPersistentInvitations() {
|
|
2440
2509
|
const persistentInvitations = this._metadataStore.getInvitations();
|
|
2441
|
-
const freshInvitations = persistentInvitations.filter(async (invitation) => !
|
|
2510
|
+
const freshInvitations = persistentInvitations.filter(async (invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
|
|
2442
2511
|
const cInvitations = freshInvitations.map((persistentInvitation) => {
|
|
2443
2512
|
(0, import_invariant7.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2444
2513
|
F: __dxlog_file8,
|
|
@@ -2491,7 +2560,7 @@ var InvitationsServiceImpl = class {
|
|
|
2491
2560
|
}, () => {
|
|
2492
2561
|
close();
|
|
2493
2562
|
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2494
|
-
if (invitation.get().
|
|
2563
|
+
if (!invitation.get().multiUse) {
|
|
2495
2564
|
this._removedAccepted.emit(invitation.get());
|
|
2496
2565
|
}
|
|
2497
2566
|
});
|
|
@@ -2864,215 +2933,80 @@ _ts_decorate3([
|
|
|
2864
2933
|
ClientRpcServer = _ts_decorate3([
|
|
2865
2934
|
import_tracing3.trace.resource()
|
|
2866
2935
|
], ClientRpcServer);
|
|
2867
|
-
var
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
return
|
|
2878
|
-
type: import_services8.Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
2879
|
-
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
2880
|
-
};
|
|
2936
|
+
var AutomergeSpaceState = class {
|
|
2937
|
+
constructor(_onNewRoot) {
|
|
2938
|
+
this._onNewRoot = _onNewRoot;
|
|
2939
|
+
this.rootUrl = void 0;
|
|
2940
|
+
this.lastEpoch = void 0;
|
|
2941
|
+
this.onNewEpoch = new import_async11.Event();
|
|
2942
|
+
this._isProcessingRootDocs = false;
|
|
2943
|
+
}
|
|
2944
|
+
async processCredential(credential) {
|
|
2945
|
+
if (!(0, import_credentials10.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
2946
|
+
return;
|
|
2881
2947
|
}
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2948
|
+
this.lastEpoch = credential;
|
|
2949
|
+
if (credential.subject.assertion.automergeRoot) {
|
|
2950
|
+
this.rootUrl = credential.subject.assertion.automergeRoot;
|
|
2951
|
+
if (this._isProcessingRootDocs) {
|
|
2952
|
+
this._onNewRoot(this.rootUrl);
|
|
2953
|
+
}
|
|
2954
|
+
}
|
|
2955
|
+
this.onNewEpoch.emit(credential);
|
|
2956
|
+
}
|
|
2957
|
+
startProcessingRootDocs() {
|
|
2958
|
+
if (this._isProcessingRootDocs) {
|
|
2959
|
+
return;
|
|
2960
|
+
}
|
|
2961
|
+
if (this.rootUrl) {
|
|
2962
|
+
this._onNewRoot(this.rootUrl);
|
|
2963
|
+
}
|
|
2964
|
+
this._isProcessingRootDocs = true;
|
|
2965
|
+
}
|
|
2966
|
+
async ensureEpochInitialized() {
|
|
2967
|
+
await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
|
|
2892
2968
|
}
|
|
2893
2969
|
};
|
|
2894
|
-
var
|
|
2895
|
-
var
|
|
2896
|
-
var
|
|
2897
|
-
var
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2970
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
2971
|
+
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
2972
|
+
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
2973
|
+
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
2974
|
+
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
2975
|
+
var NotarizationPlugin = class {
|
|
2976
|
+
constructor() {
|
|
2977
|
+
this._ctx = new import_context8.Context();
|
|
2978
|
+
this._extensionOpened = new import_async12.Event();
|
|
2979
|
+
this._extensions = /* @__PURE__ */ new Set();
|
|
2980
|
+
this._processedCredentials = new import_util5.ComplexSet(import_keys8.PublicKey.hash);
|
|
2981
|
+
this._processCredentialsTriggers = new import_util5.ComplexMap(import_keys8.PublicKey.hash);
|
|
2982
|
+
}
|
|
2983
|
+
get hasWriter() {
|
|
2984
|
+
return !!this._writer;
|
|
2985
|
+
}
|
|
2986
|
+
async open() {
|
|
2987
|
+
}
|
|
2988
|
+
async close() {
|
|
2989
|
+
await this._ctx.dispose();
|
|
2990
|
+
}
|
|
2991
|
+
/**
|
|
2992
|
+
* Request credentials to be notarized.
|
|
2993
|
+
*/
|
|
2994
|
+
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
2995
|
+
(0, import_log9.log)("notarize", {
|
|
2996
|
+
credentials
|
|
2997
|
+
}, {
|
|
2911
2998
|
F: __dxlog_file10,
|
|
2912
|
-
L:
|
|
2913
|
-
S:
|
|
2999
|
+
L: 90,
|
|
3000
|
+
S: this,
|
|
3001
|
+
C: (f, a) => f(...a)
|
|
3002
|
+
});
|
|
3003
|
+
(0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
3004
|
+
F: __dxlog_file10,
|
|
3005
|
+
L: 91,
|
|
3006
|
+
S: this,
|
|
2914
3007
|
A: [
|
|
2915
|
-
"
|
|
2916
|
-
"'
|
|
2917
|
-
]
|
|
2918
|
-
});
|
|
2919
|
-
diagnostics.metrics = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
|
|
2920
|
-
timeout: DEFAULT_TIMEOUT
|
|
2921
|
-
}).catch(() => void 0);
|
|
2922
|
-
}
|
|
2923
|
-
if (typeof navigator !== "undefined" && navigator.storage) {
|
|
2924
|
-
const map = /* @__PURE__ */ new Map();
|
|
2925
|
-
const dir = await navigator.storage.getDirectory();
|
|
2926
|
-
for await (const filename of dir?.keys()) {
|
|
2927
|
-
const idx = filename.indexOf("-", filename.indexOf("-") + 1);
|
|
2928
|
-
if (idx === -1) {
|
|
2929
|
-
continue;
|
|
2930
|
-
}
|
|
2931
|
-
map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
|
|
2932
|
-
}
|
|
2933
|
-
diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
|
|
2934
|
-
file,
|
|
2935
|
-
count
|
|
2936
|
-
}));
|
|
2937
|
-
}
|
|
2938
|
-
const identity = serviceContext.identityManager.identity;
|
|
2939
|
-
if (identity) {
|
|
2940
|
-
diagnostics.identity = {
|
|
2941
|
-
identityKey: identity.identityKey,
|
|
2942
|
-
spaceKey: identity.space.key,
|
|
2943
|
-
profile: identity.profileDocument
|
|
2944
|
-
};
|
|
2945
|
-
const { devices } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
|
|
2946
|
-
timeout: DEFAULT_TIMEOUT
|
|
2947
|
-
}).catch(() => void 0) ?? {};
|
|
2948
|
-
diagnostics.devices = devices;
|
|
2949
|
-
if (serviceContext.dataSpaceManager) {
|
|
2950
|
-
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
2951
|
-
}
|
|
2952
|
-
const { feeds = [] } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
2953
|
-
timeout: DEFAULT_TIMEOUT
|
|
2954
|
-
}).catch(() => void 0) ?? {};
|
|
2955
|
-
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
2956
|
-
feedKey,
|
|
2957
|
-
bytes,
|
|
2958
|
-
length
|
|
2959
|
-
}));
|
|
2960
|
-
const status = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
|
|
2961
|
-
timeout: DEFAULT_TIMEOUT
|
|
2962
|
-
}).catch(() => void 0);
|
|
2963
|
-
diagnostics.networkStatus = status;
|
|
2964
|
-
diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
|
|
2965
|
-
}
|
|
2966
|
-
diagnostics.config = config.values;
|
|
2967
|
-
return diagnostics;
|
|
2968
|
-
};
|
|
2969
|
-
var getSpaceStats = async (space) => {
|
|
2970
|
-
const stats = {
|
|
2971
|
-
key: space.key,
|
|
2972
|
-
metrics: space.metrics,
|
|
2973
|
-
epochs: space.inner.spaceState.credentials.filter((0, import_credentials9.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
2974
|
-
...credential.subject.assertion,
|
|
2975
|
-
id: credential.id
|
|
2976
|
-
})),
|
|
2977
|
-
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
2978
|
-
identity: {
|
|
2979
|
-
identityKey: member.key,
|
|
2980
|
-
profile: {
|
|
2981
|
-
displayName: member.assertion.profile?.displayName
|
|
2982
|
-
}
|
|
2983
|
-
},
|
|
2984
|
-
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services7.SpaceMember.PresenceState.ONLINE : import_services7.SpaceMember.PresenceState.OFFLINE
|
|
2985
|
-
})),
|
|
2986
|
-
pipeline: {
|
|
2987
|
-
// TODO(burdon): Pick properties from credentials if needed.
|
|
2988
|
-
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
2989
|
-
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
2990
|
-
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
2991
|
-
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2992
|
-
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
2993
|
-
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
|
|
2994
|
-
}
|
|
2995
|
-
};
|
|
2996
|
-
if (stats.metrics) {
|
|
2997
|
-
const { open, ready } = stats.metrics;
|
|
2998
|
-
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
2999
|
-
}
|
|
3000
|
-
return stats;
|
|
3001
|
-
};
|
|
3002
|
-
var AutomergeSpaceState = class {
|
|
3003
|
-
constructor(_onNewRoot) {
|
|
3004
|
-
this._onNewRoot = _onNewRoot;
|
|
3005
|
-
this.rootUrl = void 0;
|
|
3006
|
-
this.lastEpoch = void 0;
|
|
3007
|
-
this.onNewEpoch = new import_async11.Event();
|
|
3008
|
-
this._isProcessingRootDocs = false;
|
|
3009
|
-
}
|
|
3010
|
-
async processCredential(credential) {
|
|
3011
|
-
if (!(0, import_credentials11.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
3012
|
-
return;
|
|
3013
|
-
}
|
|
3014
|
-
this.lastEpoch = credential;
|
|
3015
|
-
if (credential.subject.assertion.automergeRoot) {
|
|
3016
|
-
this.rootUrl = credential.subject.assertion.automergeRoot;
|
|
3017
|
-
if (this._isProcessingRootDocs) {
|
|
3018
|
-
this._onNewRoot(this.rootUrl);
|
|
3019
|
-
}
|
|
3020
|
-
}
|
|
3021
|
-
this.onNewEpoch.emit(credential);
|
|
3022
|
-
}
|
|
3023
|
-
startProcessingRootDocs() {
|
|
3024
|
-
if (this._isProcessingRootDocs) {
|
|
3025
|
-
return;
|
|
3026
|
-
}
|
|
3027
|
-
if (this.rootUrl) {
|
|
3028
|
-
this._onNewRoot(this.rootUrl);
|
|
3029
|
-
}
|
|
3030
|
-
this._isProcessingRootDocs = true;
|
|
3031
|
-
}
|
|
3032
|
-
async ensureEpochInitialized() {
|
|
3033
|
-
await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
|
|
3034
|
-
}
|
|
3035
|
-
};
|
|
3036
|
-
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
3037
|
-
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
3038
|
-
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
3039
|
-
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
3040
|
-
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
3041
|
-
var NotarizationPlugin = class {
|
|
3042
|
-
constructor() {
|
|
3043
|
-
this._ctx = new import_context8.Context();
|
|
3044
|
-
this._extensionOpened = new import_async12.Event();
|
|
3045
|
-
this._extensions = /* @__PURE__ */ new Set();
|
|
3046
|
-
this._processedCredentials = new import_util5.ComplexSet(import_keys8.PublicKey.hash);
|
|
3047
|
-
this._processCredentialsTriggers = new import_util5.ComplexMap(import_keys8.PublicKey.hash);
|
|
3048
|
-
}
|
|
3049
|
-
get hasWriter() {
|
|
3050
|
-
return !!this._writer;
|
|
3051
|
-
}
|
|
3052
|
-
async open() {
|
|
3053
|
-
}
|
|
3054
|
-
async close() {
|
|
3055
|
-
await this._ctx.dispose();
|
|
3056
|
-
}
|
|
3057
|
-
/**
|
|
3058
|
-
* Request credentials to be notarized.
|
|
3059
|
-
*/
|
|
3060
|
-
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
3061
|
-
(0, import_log9.log)("notarize", {
|
|
3062
|
-
credentials
|
|
3063
|
-
}, {
|
|
3064
|
-
F: __dxlog_file11,
|
|
3065
|
-
L: 90,
|
|
3066
|
-
S: this,
|
|
3067
|
-
C: (f, a) => f(...a)
|
|
3068
|
-
});
|
|
3069
|
-
(0, import_invariant11.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
3070
|
-
F: __dxlog_file11,
|
|
3071
|
-
L: 91,
|
|
3072
|
-
S: this,
|
|
3073
|
-
A: [
|
|
3074
|
-
"credentials.every((credential) => credential.id)",
|
|
3075
|
-
"'Credentials must have an id'"
|
|
3008
|
+
"credentials.every((credential) => credential.id)",
|
|
3009
|
+
"'Credentials must have an id'"
|
|
3076
3010
|
]
|
|
3077
3011
|
});
|
|
3078
3012
|
const errors = new import_async12.Trigger();
|
|
@@ -3081,7 +3015,7 @@ var NotarizationPlugin = class {
|
|
|
3081
3015
|
import_log9.log.warn("Notarization error", {
|
|
3082
3016
|
err
|
|
3083
3017
|
}, {
|
|
3084
|
-
F:
|
|
3018
|
+
F: __dxlog_file10,
|
|
3085
3019
|
L: 99,
|
|
3086
3020
|
S: this,
|
|
3087
3021
|
C: (f, a) => f(...a)
|
|
@@ -3097,7 +3031,7 @@ var NotarizationPlugin = class {
|
|
|
3097
3031
|
timeout,
|
|
3098
3032
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3099
3033
|
}, {
|
|
3100
|
-
F:
|
|
3034
|
+
F: __dxlog_file10,
|
|
3101
3035
|
L: 111,
|
|
3102
3036
|
S: this,
|
|
3103
3037
|
C: (f, a) => f(...a)
|
|
@@ -3120,7 +3054,7 @@ var NotarizationPlugin = class {
|
|
|
3120
3054
|
import_log9.log.info("Exhausted all peers to notarize with", {
|
|
3121
3055
|
retryIn: retryTimeout
|
|
3122
3056
|
}, {
|
|
3123
|
-
F:
|
|
3057
|
+
F: __dxlog_file10,
|
|
3124
3058
|
L: 136,
|
|
3125
3059
|
S: this,
|
|
3126
3060
|
C: (f, a) => f(...a)
|
|
@@ -3134,7 +3068,7 @@ var NotarizationPlugin = class {
|
|
|
3134
3068
|
peer: peer.localPeerId,
|
|
3135
3069
|
credentialId: credentials.map((credential) => credential.id)
|
|
3136
3070
|
}, {
|
|
3137
|
-
F:
|
|
3071
|
+
F: __dxlog_file10,
|
|
3138
3072
|
L: 143,
|
|
3139
3073
|
S: this,
|
|
3140
3074
|
C: (f, a) => f(...a)
|
|
@@ -3143,7 +3077,7 @@ var NotarizationPlugin = class {
|
|
|
3143
3077
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
3144
3078
|
});
|
|
3145
3079
|
(0, import_log9.log)("success", void 0, {
|
|
3146
|
-
F:
|
|
3080
|
+
F: __dxlog_file10,
|
|
3147
3081
|
L: 147,
|
|
3148
3082
|
S: this,
|
|
3149
3083
|
C: (f, a) => f(...a)
|
|
@@ -3152,7 +3086,7 @@ var NotarizationPlugin = class {
|
|
|
3152
3086
|
} catch (err) {
|
|
3153
3087
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
3154
3088
|
import_log9.log.info("error notarizing (recoverable)", err, {
|
|
3155
|
-
F:
|
|
3089
|
+
F: __dxlog_file10,
|
|
3156
3090
|
L: 151,
|
|
3157
3091
|
S: this,
|
|
3158
3092
|
C: (f, a) => f(...a)
|
|
@@ -3170,7 +3104,7 @@ var NotarizationPlugin = class {
|
|
|
3170
3104
|
errors.wait()
|
|
3171
3105
|
]);
|
|
3172
3106
|
(0, import_log9.log)("done", void 0, {
|
|
3173
|
-
F:
|
|
3107
|
+
F: __dxlog_file10,
|
|
3174
3108
|
L: 162,
|
|
3175
3109
|
S: this,
|
|
3176
3110
|
C: (f, a) => f(...a)
|
|
@@ -3191,8 +3125,8 @@ var NotarizationPlugin = class {
|
|
|
3191
3125
|
this._processCredentialsTriggers.delete(credential.id);
|
|
3192
3126
|
}
|
|
3193
3127
|
setWriter(writer) {
|
|
3194
|
-
(0,
|
|
3195
|
-
F:
|
|
3128
|
+
(0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
|
|
3129
|
+
F: __dxlog_file10,
|
|
3196
3130
|
L: 181,
|
|
3197
3131
|
S: this,
|
|
3198
3132
|
A: [
|
|
@@ -3216,8 +3150,8 @@ var NotarizationPlugin = class {
|
|
|
3216
3150
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
3217
3151
|
}
|
|
3218
3152
|
for (const credential of request.credentials ?? []) {
|
|
3219
|
-
(0,
|
|
3220
|
-
F:
|
|
3153
|
+
(0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
|
|
3154
|
+
F: __dxlog_file10,
|
|
3221
3155
|
L: 200,
|
|
3222
3156
|
S: this,
|
|
3223
3157
|
A: [
|
|
@@ -3237,7 +3171,7 @@ var NotarizationPlugin = class {
|
|
|
3237
3171
|
(0, import_log9.log)("extension opened", {
|
|
3238
3172
|
peer: extension.localPeerId
|
|
3239
3173
|
}, {
|
|
3240
|
-
F:
|
|
3174
|
+
F: __dxlog_file10,
|
|
3241
3175
|
L: 211,
|
|
3242
3176
|
S: this,
|
|
3243
3177
|
C: (f, a) => f(...a)
|
|
@@ -3249,7 +3183,7 @@ var NotarizationPlugin = class {
|
|
|
3249
3183
|
(0, import_log9.log)("extension closed", {
|
|
3250
3184
|
peer: extension.localPeerId
|
|
3251
3185
|
}, {
|
|
3252
|
-
F:
|
|
3186
|
+
F: __dxlog_file10,
|
|
3253
3187
|
L: 216,
|
|
3254
3188
|
S: this,
|
|
3255
3189
|
C: (f, a) => f(...a)
|
|
@@ -3265,10 +3199,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
3265
3199
|
constructor(_params) {
|
|
3266
3200
|
super({
|
|
3267
3201
|
requested: {
|
|
3268
|
-
NotarizationService:
|
|
3202
|
+
NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3269
3203
|
},
|
|
3270
3204
|
exposed: {
|
|
3271
|
-
NotarizationService:
|
|
3205
|
+
NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3272
3206
|
}
|
|
3273
3207
|
});
|
|
3274
3208
|
this._params = _params;
|
|
@@ -3301,14 +3235,14 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3301
3235
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3302
3236
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3303
3237
|
}
|
|
3304
|
-
var
|
|
3238
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3305
3239
|
var DataSpace = class {
|
|
3306
3240
|
constructor(params) {
|
|
3307
3241
|
this._ctx = new import_context7.Context();
|
|
3308
3242
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3309
3243
|
this._cache = void 0;
|
|
3310
3244
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
3311
|
-
this._state =
|
|
3245
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
3312
3246
|
this.error = void 0;
|
|
3313
3247
|
this.stateUpdate = new import_async10.Event();
|
|
3314
3248
|
this.metrics = {};
|
|
@@ -3330,9 +3264,9 @@ var DataSpace = class {
|
|
|
3330
3264
|
this._cache = params.cache;
|
|
3331
3265
|
this._state = params.initialState;
|
|
3332
3266
|
(0, import_log8.log)("new state", {
|
|
3333
|
-
state:
|
|
3267
|
+
state: import_services7.SpaceState[this._state]
|
|
3334
3268
|
}, {
|
|
3335
|
-
F:
|
|
3269
|
+
F: __dxlog_file11,
|
|
3336
3270
|
L: 140,
|
|
3337
3271
|
S: this,
|
|
3338
3272
|
C: (f, a) => f(...a)
|
|
@@ -3378,11 +3312,11 @@ var DataSpace = class {
|
|
|
3378
3312
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3379
3313
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3380
3314
|
await this._inner.open(new import_context7.Context());
|
|
3381
|
-
this._state =
|
|
3315
|
+
this._state = import_services7.SpaceState.CONTROL_ONLY;
|
|
3382
3316
|
(0, import_log8.log)("new state", {
|
|
3383
|
-
state:
|
|
3317
|
+
state: import_services7.SpaceState[this._state]
|
|
3384
3318
|
}, {
|
|
3385
|
-
F:
|
|
3319
|
+
F: __dxlog_file11,
|
|
3386
3320
|
L: 198,
|
|
3387
3321
|
S: this,
|
|
3388
3322
|
C: (f, a) => f(...a)
|
|
@@ -3396,11 +3330,11 @@ var DataSpace = class {
|
|
|
3396
3330
|
}
|
|
3397
3331
|
async _close() {
|
|
3398
3332
|
await this._callbacks.beforeClose?.();
|
|
3399
|
-
this._state =
|
|
3333
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
3400
3334
|
(0, import_log8.log)("new state", {
|
|
3401
|
-
state:
|
|
3335
|
+
state: import_services7.SpaceState[this._state]
|
|
3402
3336
|
}, {
|
|
3403
|
-
F:
|
|
3337
|
+
F: __dxlog_file11,
|
|
3404
3338
|
L: 212,
|
|
3405
3339
|
S: this,
|
|
3406
3340
|
C: (f, a) => f(...a)
|
|
@@ -3430,9 +3364,9 @@ var DataSpace = class {
|
|
|
3430
3364
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3431
3365
|
await this.initializeDataPipeline();
|
|
3432
3366
|
} catch (err) {
|
|
3433
|
-
if (err instanceof
|
|
3367
|
+
if (err instanceof import_protocols7.CancelledError || err instanceof import_context7.ContextDisposedError) {
|
|
3434
3368
|
(0, import_log8.log)("data pipeline initialization cancelled", err, {
|
|
3435
|
-
F:
|
|
3369
|
+
F: __dxlog_file11,
|
|
3436
3370
|
L: 245,
|
|
3437
3371
|
S: this,
|
|
3438
3372
|
C: (f, a) => f(...a)
|
|
@@ -3440,16 +3374,16 @@ var DataSpace = class {
|
|
|
3440
3374
|
return;
|
|
3441
3375
|
}
|
|
3442
3376
|
import_log8.log.error("Error initializing data pipeline", err, {
|
|
3443
|
-
F:
|
|
3377
|
+
F: __dxlog_file11,
|
|
3444
3378
|
L: 249,
|
|
3445
3379
|
S: this,
|
|
3446
3380
|
C: (f, a) => f(...a)
|
|
3447
3381
|
});
|
|
3448
|
-
this._state =
|
|
3382
|
+
this._state = import_services7.SpaceState.ERROR;
|
|
3449
3383
|
(0, import_log8.log)("new state", {
|
|
3450
|
-
state:
|
|
3384
|
+
state: import_services7.SpaceState[this._state]
|
|
3451
3385
|
}, {
|
|
3452
|
-
F:
|
|
3386
|
+
F: __dxlog_file11,
|
|
3453
3387
|
L: 251,
|
|
3454
3388
|
S: this,
|
|
3455
3389
|
C: (f, a) => f(...a)
|
|
@@ -3462,14 +3396,14 @@ var DataSpace = class {
|
|
|
3462
3396
|
});
|
|
3463
3397
|
}
|
|
3464
3398
|
async initializeDataPipeline() {
|
|
3465
|
-
if (this._state !==
|
|
3466
|
-
throw new
|
|
3399
|
+
if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
|
|
3400
|
+
throw new import_protocols7.SystemError("Invalid operation");
|
|
3467
3401
|
}
|
|
3468
|
-
this._state =
|
|
3402
|
+
this._state = import_services7.SpaceState.INITIALIZING;
|
|
3469
3403
|
(0, import_log8.log)("new state", {
|
|
3470
|
-
state:
|
|
3404
|
+
state: import_services7.SpaceState[this._state]
|
|
3471
3405
|
}, {
|
|
3472
|
-
F:
|
|
3406
|
+
F: __dxlog_file11,
|
|
3473
3407
|
L: 267,
|
|
3474
3408
|
S: this,
|
|
3475
3409
|
C: (f, a) => f(...a)
|
|
@@ -3479,17 +3413,17 @@ var DataSpace = class {
|
|
|
3479
3413
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
3480
3414
|
await (0, import_context7.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
3481
3415
|
(0, import_log8.log)("data pipeline ready", void 0, {
|
|
3482
|
-
F:
|
|
3416
|
+
F: __dxlog_file11,
|
|
3483
3417
|
L: 279,
|
|
3484
3418
|
S: this,
|
|
3485
3419
|
C: (f, a) => f(...a)
|
|
3486
3420
|
});
|
|
3487
3421
|
await this._callbacks.beforeReady?.();
|
|
3488
|
-
this._state =
|
|
3422
|
+
this._state = import_services7.SpaceState.READY;
|
|
3489
3423
|
(0, import_log8.log)("new state", {
|
|
3490
|
-
state:
|
|
3424
|
+
state: import_services7.SpaceState[this._state]
|
|
3491
3425
|
}, {
|
|
3492
|
-
F:
|
|
3426
|
+
F: __dxlog_file11,
|
|
3493
3427
|
L: 283,
|
|
3494
3428
|
S: this,
|
|
3495
3429
|
C: (f, a) => f(...a)
|
|
@@ -3505,14 +3439,14 @@ var DataSpace = class {
|
|
|
3505
3439
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
3506
3440
|
await this._createWritableFeeds();
|
|
3507
3441
|
(0, import_log8.log)("writable feeds created", void 0, {
|
|
3508
|
-
F:
|
|
3442
|
+
F: __dxlog_file11,
|
|
3509
3443
|
L: 299,
|
|
3510
3444
|
S: this,
|
|
3511
3445
|
C: (f, a) => f(...a)
|
|
3512
3446
|
});
|
|
3513
3447
|
this.stateUpdate.emit();
|
|
3514
3448
|
if (!this.notarizationPlugin.hasWriter) {
|
|
3515
|
-
this.notarizationPlugin.setWriter((0,
|
|
3449
|
+
this.notarizationPlugin.setWriter((0, import_echo_pipeline2.createMappedFeedWriter)((credential) => ({
|
|
3516
3450
|
credential: {
|
|
3517
3451
|
credential
|
|
3518
3452
|
}
|
|
@@ -3533,7 +3467,7 @@ var DataSpace = class {
|
|
|
3533
3467
|
spaceKey: this.key,
|
|
3534
3468
|
deviceKey: this._signingContext.deviceKey,
|
|
3535
3469
|
identityKey: this._signingContext.identityKey,
|
|
3536
|
-
designation:
|
|
3470
|
+
designation: import_credentials9.AdmittedFeed.Designation.CONTROL
|
|
3537
3471
|
}
|
|
3538
3472
|
}));
|
|
3539
3473
|
}
|
|
@@ -3550,7 +3484,7 @@ var DataSpace = class {
|
|
|
3550
3484
|
spaceKey: this.key,
|
|
3551
3485
|
deviceKey: this._signingContext.deviceKey,
|
|
3552
3486
|
identityKey: this._signingContext.identityKey,
|
|
3553
|
-
designation:
|
|
3487
|
+
designation: import_credentials9.AdmittedFeed.Designation.DATA
|
|
3554
3488
|
}
|
|
3555
3489
|
}));
|
|
3556
3490
|
}
|
|
@@ -3568,7 +3502,7 @@ var DataSpace = class {
|
|
|
3568
3502
|
space: this.key,
|
|
3569
3503
|
rootUrl
|
|
3570
3504
|
}, {
|
|
3571
|
-
F:
|
|
3505
|
+
F: __dxlog_file11,
|
|
3572
3506
|
L: 365,
|
|
3573
3507
|
S: this,
|
|
3574
3508
|
C: (f, a) => f(...a)
|
|
@@ -3583,7 +3517,7 @@ var DataSpace = class {
|
|
|
3583
3517
|
if (this._ctx.disposed) {
|
|
3584
3518
|
return;
|
|
3585
3519
|
}
|
|
3586
|
-
const doc = handle.docSync() ?? (0,
|
|
3520
|
+
const doc = handle.docSync() ?? (0, import_invariant9.failedInvariant)();
|
|
3587
3521
|
if (!doc.access?.spaceKey) {
|
|
3588
3522
|
handle.change((doc2) => {
|
|
3589
3523
|
doc2.access = {
|
|
@@ -3600,7 +3534,7 @@ var DataSpace = class {
|
|
|
3600
3534
|
rootUrl,
|
|
3601
3535
|
err
|
|
3602
3536
|
}, {
|
|
3603
|
-
F:
|
|
3537
|
+
F: __dxlog_file11,
|
|
3604
3538
|
L: 388,
|
|
3605
3539
|
S: this,
|
|
3606
3540
|
C: (f, a) => f(...a)
|
|
@@ -3627,7 +3561,7 @@ var DataSpace = class {
|
|
|
3627
3561
|
let epoch;
|
|
3628
3562
|
switch (options?.migration) {
|
|
3629
3563
|
case void 0:
|
|
3630
|
-
case
|
|
3564
|
+
case import_services7.CreateEpochRequest.Migration.NONE:
|
|
3631
3565
|
{
|
|
3632
3566
|
epoch = {
|
|
3633
3567
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
@@ -3637,7 +3571,7 @@ var DataSpace = class {
|
|
|
3637
3571
|
};
|
|
3638
3572
|
}
|
|
3639
3573
|
break;
|
|
3640
|
-
case
|
|
3574
|
+
case import_services7.CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3641
3575
|
{
|
|
3642
3576
|
const document = this._automergeHost.repo.create();
|
|
3643
3577
|
epoch = {
|
|
@@ -3648,14 +3582,14 @@ var DataSpace = class {
|
|
|
3648
3582
|
};
|
|
3649
3583
|
}
|
|
3650
3584
|
break;
|
|
3651
|
-
case
|
|
3585
|
+
case import_services7.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
3652
3586
|
{
|
|
3653
3587
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3654
3588
|
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3655
3589
|
await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3656
3590
|
const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
|
|
3657
|
-
(0,
|
|
3658
|
-
F:
|
|
3591
|
+
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3592
|
+
F: __dxlog_file11,
|
|
3659
3593
|
L: 438,
|
|
3660
3594
|
S: this,
|
|
3661
3595
|
A: [
|
|
@@ -3671,10 +3605,10 @@ var DataSpace = class {
|
|
|
3671
3605
|
};
|
|
3672
3606
|
}
|
|
3673
3607
|
break;
|
|
3674
|
-
case
|
|
3608
|
+
case import_services7.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
3675
3609
|
{
|
|
3676
3610
|
import_log8.log.info("Fragmenting", void 0, {
|
|
3677
|
-
F:
|
|
3611
|
+
F: __dxlog_file11,
|
|
3678
3612
|
L: 450,
|
|
3679
3613
|
S: this,
|
|
3680
3614
|
C: (f, a) => f(...a)
|
|
@@ -3685,8 +3619,8 @@ var DataSpace = class {
|
|
|
3685
3619
|
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3686
3620
|
const properties = objects.find(([_, value]) => value.system.type?.itemId === import_echo_db.TYPE_PROPERTIES);
|
|
3687
3621
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3688
|
-
(0,
|
|
3689
|
-
F:
|
|
3622
|
+
(0, import_invariant9.invariant)(properties, "Properties not found", {
|
|
3623
|
+
F: __dxlog_file11,
|
|
3690
3624
|
L: 460,
|
|
3691
3625
|
S: this,
|
|
3692
3626
|
A: [
|
|
@@ -3701,8 +3635,8 @@ var DataSpace = class {
|
|
|
3701
3635
|
])
|
|
3702
3636
|
};
|
|
3703
3637
|
const newRoot = this._automergeHost.repo.create(newSpaceDoc);
|
|
3704
|
-
(0,
|
|
3705
|
-
F:
|
|
3638
|
+
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3639
|
+
F: __dxlog_file11,
|
|
3706
3640
|
L: 465,
|
|
3707
3641
|
S: this,
|
|
3708
3642
|
A: [
|
|
@@ -3710,7 +3644,7 @@ var DataSpace = class {
|
|
|
3710
3644
|
""
|
|
3711
3645
|
]
|
|
3712
3646
|
});
|
|
3713
|
-
const docLoader = new
|
|
3647
|
+
const docLoader = new import_echo_pipeline3.AutomergeDocumentLoaderImpl(this.key, this._automergeHost.repo);
|
|
3714
3648
|
await docLoader.loadSpaceRootDocHandle(this._ctx, {
|
|
3715
3649
|
rootUrl: newRoot.url
|
|
3716
3650
|
});
|
|
@@ -3754,24 +3688,24 @@ var DataSpace = class {
|
|
|
3754
3688
|
]));
|
|
3755
3689
|
}
|
|
3756
3690
|
async activate() {
|
|
3757
|
-
if (this._state !==
|
|
3691
|
+
if (this._state !== import_services7.SpaceState.INACTIVE) {
|
|
3758
3692
|
return;
|
|
3759
3693
|
}
|
|
3760
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3694
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.ACTIVE);
|
|
3761
3695
|
await this._open();
|
|
3762
3696
|
this.initializeDataPipelineAsync();
|
|
3763
3697
|
}
|
|
3764
3698
|
async deactivate() {
|
|
3765
|
-
if (this._state ===
|
|
3699
|
+
if (this._state === import_services7.SpaceState.INACTIVE) {
|
|
3766
3700
|
return;
|
|
3767
3701
|
}
|
|
3768
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3702
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.INACTIVE);
|
|
3769
3703
|
await this._close();
|
|
3770
|
-
this._state =
|
|
3704
|
+
this._state = import_services7.SpaceState.INACTIVE;
|
|
3771
3705
|
(0, import_log8.log)("new state", {
|
|
3772
|
-
state:
|
|
3706
|
+
state: import_services7.SpaceState[this._state]
|
|
3773
3707
|
}, {
|
|
3774
|
-
F:
|
|
3708
|
+
F: __dxlog_file11,
|
|
3775
3709
|
L: 531,
|
|
3776
3710
|
S: this,
|
|
3777
3711
|
C: (f, a) => f(...a)
|
|
@@ -3780,18 +3714,18 @@ var DataSpace = class {
|
|
|
3780
3714
|
}
|
|
3781
3715
|
};
|
|
3782
3716
|
_ts_decorate4([
|
|
3783
|
-
|
|
3717
|
+
import_tracing4.trace.info()
|
|
3784
3718
|
], DataSpace.prototype, "_inner", void 0);
|
|
3785
3719
|
_ts_decorate4([
|
|
3786
|
-
|
|
3720
|
+
import_tracing4.trace.info()
|
|
3787
3721
|
], DataSpace.prototype, "key", null);
|
|
3788
3722
|
_ts_decorate4([
|
|
3789
|
-
|
|
3790
|
-
enum:
|
|
3723
|
+
import_tracing4.trace.info({
|
|
3724
|
+
enum: import_services7.SpaceState
|
|
3791
3725
|
})
|
|
3792
3726
|
], DataSpace.prototype, "state", null);
|
|
3793
3727
|
_ts_decorate4([
|
|
3794
|
-
|
|
3728
|
+
import_tracing4.trace.info({
|
|
3795
3729
|
depth: null
|
|
3796
3730
|
})
|
|
3797
3731
|
], DataSpace.prototype, "_automergeInfo", null);
|
|
@@ -3802,12 +3736,12 @@ _ts_decorate4([
|
|
|
3802
3736
|
import_async10.synchronized
|
|
3803
3737
|
], DataSpace.prototype, "close", null);
|
|
3804
3738
|
_ts_decorate4([
|
|
3805
|
-
|
|
3739
|
+
import_tracing4.trace.span({
|
|
3806
3740
|
showInBrowserTimeline: true
|
|
3807
3741
|
})
|
|
3808
3742
|
], DataSpace.prototype, "initializeDataPipeline", null);
|
|
3809
3743
|
_ts_decorate4([
|
|
3810
|
-
|
|
3744
|
+
import_tracing4.trace.span({
|
|
3811
3745
|
showInBrowserTimeline: true
|
|
3812
3746
|
})
|
|
3813
3747
|
], DataSpace.prototype, "_initializeAndReadControlPipeline", null);
|
|
@@ -3822,11 +3756,11 @@ _ts_decorate4([
|
|
|
3822
3756
|
], DataSpace.prototype, "deactivate", null);
|
|
3823
3757
|
DataSpace = _ts_decorate4([
|
|
3824
3758
|
(0, import_async10.trackLeaks)("open", "close"),
|
|
3825
|
-
|
|
3759
|
+
import_tracing4.trace.resource()
|
|
3826
3760
|
], DataSpace);
|
|
3827
3761
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
3828
3762
|
const credentials = [
|
|
3829
|
-
await (0,
|
|
3763
|
+
await (0, import_credentials12.createCredential)({
|
|
3830
3764
|
signer: keyring,
|
|
3831
3765
|
issuer: space.key,
|
|
3832
3766
|
subject: space.key,
|
|
@@ -3835,14 +3769,14 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3835
3769
|
spaceKey: space.key
|
|
3836
3770
|
}
|
|
3837
3771
|
}),
|
|
3838
|
-
await (0,
|
|
3772
|
+
await (0, import_credentials12.createCredential)({
|
|
3839
3773
|
signer: keyring,
|
|
3840
3774
|
issuer: space.key,
|
|
3841
3775
|
subject: signingContext.identityKey,
|
|
3842
3776
|
assertion: {
|
|
3843
3777
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
3844
3778
|
spaceKey: space.key,
|
|
3845
|
-
role:
|
|
3779
|
+
role: import_credentials13.SpaceMember.Role.ADMIN,
|
|
3846
3780
|
profile: signingContext.getProfile(),
|
|
3847
3781
|
genesisFeedKey: space.controlFeedKey ?? (0, import_debug4.failUndefined)()
|
|
3848
3782
|
}
|
|
@@ -3854,7 +3788,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3854
3788
|
spaceKey: space.key,
|
|
3855
3789
|
identityKey: signingContext.identityKey,
|
|
3856
3790
|
deviceKey: signingContext.deviceKey,
|
|
3857
|
-
designation:
|
|
3791
|
+
designation: import_credentials13.AdmittedFeed.Designation.CONTROL
|
|
3858
3792
|
}
|
|
3859
3793
|
}),
|
|
3860
3794
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3864,7 +3798,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3864
3798
|
spaceKey: space.key,
|
|
3865
3799
|
identityKey: signingContext.identityKey,
|
|
3866
3800
|
deviceKey: signingContext.deviceKey,
|
|
3867
|
-
designation:
|
|
3801
|
+
designation: import_credentials13.AdmittedFeed.Designation.DATA
|
|
3868
3802
|
}
|
|
3869
3803
|
}),
|
|
3870
3804
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3898,7 +3832,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
3898
3832
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3899
3833
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3900
3834
|
}
|
|
3901
|
-
var
|
|
3835
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
3902
3836
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3903
3837
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3904
3838
|
var DataSpaceManager = class {
|
|
@@ -3924,15 +3858,15 @@ var DataSpaceManager = class {
|
|
|
3924
3858
|
}
|
|
3925
3859
|
async open() {
|
|
3926
3860
|
(0, import_log10.log)("open", void 0, {
|
|
3927
|
-
F:
|
|
3861
|
+
F: __dxlog_file12,
|
|
3928
3862
|
L: 98,
|
|
3929
3863
|
S: this,
|
|
3930
3864
|
C: (f, a) => f(...a)
|
|
3931
3865
|
});
|
|
3932
|
-
import_log10.log.trace("dxos.echo.data-space-manager.open",
|
|
3866
|
+
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols9.trace.begin({
|
|
3933
3867
|
id: this._instanceId
|
|
3934
3868
|
}), {
|
|
3935
|
-
F:
|
|
3869
|
+
F: __dxlog_file12,
|
|
3936
3870
|
L: 99,
|
|
3937
3871
|
S: this,
|
|
3938
3872
|
C: (f, a) => f(...a)
|
|
@@ -3940,7 +3874,7 @@ var DataSpaceManager = class {
|
|
|
3940
3874
|
(0, import_log10.log)("metadata loaded", {
|
|
3941
3875
|
spaces: this._metadataStore.spaces.length
|
|
3942
3876
|
}, {
|
|
3943
|
-
F:
|
|
3877
|
+
F: __dxlog_file12,
|
|
3944
3878
|
L: 100,
|
|
3945
3879
|
S: this,
|
|
3946
3880
|
C: (f, a) => f(...a)
|
|
@@ -3950,7 +3884,7 @@ var DataSpaceManager = class {
|
|
|
3950
3884
|
(0, import_log10.log)("load space", {
|
|
3951
3885
|
spaceMetadata
|
|
3952
3886
|
}, {
|
|
3953
|
-
F:
|
|
3887
|
+
F: __dxlog_file12,
|
|
3954
3888
|
L: 104,
|
|
3955
3889
|
S: this,
|
|
3956
3890
|
C: (f, a) => f(...a)
|
|
@@ -3961,7 +3895,7 @@ var DataSpaceManager = class {
|
|
|
3961
3895
|
spaceMetadata,
|
|
3962
3896
|
err
|
|
3963
3897
|
}, {
|
|
3964
|
-
F:
|
|
3898
|
+
F: __dxlog_file12,
|
|
3965
3899
|
L: 107,
|
|
3966
3900
|
S: this,
|
|
3967
3901
|
C: (f, a) => f(...a)
|
|
@@ -3971,14 +3905,14 @@ var DataSpaceManager = class {
|
|
|
3971
3905
|
this._isOpen = true;
|
|
3972
3906
|
this.updated.emit();
|
|
3973
3907
|
for (const space of this._spaces.values()) {
|
|
3974
|
-
if (space.state !==
|
|
3908
|
+
if (space.state !== import_services8.SpaceState.INACTIVE) {
|
|
3975
3909
|
space.initializeDataPipelineAsync();
|
|
3976
3910
|
}
|
|
3977
3911
|
}
|
|
3978
|
-
import_log10.log.trace("dxos.echo.data-space-manager.open",
|
|
3912
|
+
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols9.trace.end({
|
|
3979
3913
|
id: this._instanceId
|
|
3980
3914
|
}), {
|
|
3981
|
-
F:
|
|
3915
|
+
F: __dxlog_file12,
|
|
3982
3916
|
L: 120,
|
|
3983
3917
|
S: this,
|
|
3984
3918
|
C: (f, a) => f(...a)
|
|
@@ -3986,7 +3920,7 @@ var DataSpaceManager = class {
|
|
|
3986
3920
|
}
|
|
3987
3921
|
async close() {
|
|
3988
3922
|
(0, import_log10.log)("close", void 0, {
|
|
3989
|
-
F:
|
|
3923
|
+
F: __dxlog_file12,
|
|
3990
3924
|
L: 125,
|
|
3991
3925
|
S: this,
|
|
3992
3926
|
C: (f, a) => f(...a)
|
|
@@ -4001,8 +3935,8 @@ var DataSpaceManager = class {
|
|
|
4001
3935
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
4002
3936
|
*/
|
|
4003
3937
|
async createSpace() {
|
|
4004
|
-
(0,
|
|
4005
|
-
F:
|
|
3938
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3939
|
+
F: __dxlog_file12,
|
|
4006
3940
|
L: 138,
|
|
4007
3941
|
S: this,
|
|
4008
3942
|
A: [
|
|
@@ -4018,12 +3952,12 @@ var DataSpaceManager = class {
|
|
|
4018
3952
|
genesisFeedKey: controlFeedKey,
|
|
4019
3953
|
controlFeedKey,
|
|
4020
3954
|
dataFeedKey,
|
|
4021
|
-
state:
|
|
3955
|
+
state: import_services8.SpaceState.ACTIVE
|
|
4022
3956
|
};
|
|
4023
3957
|
(0, import_log10.log)("creating space...", {
|
|
4024
3958
|
spaceKey
|
|
4025
3959
|
}, {
|
|
4026
|
-
F:
|
|
3960
|
+
F: __dxlog_file12,
|
|
4027
3961
|
L: 150,
|
|
4028
3962
|
S: this,
|
|
4029
3963
|
C: (f, a) => f(...a)
|
|
@@ -4038,8 +3972,8 @@ var DataSpaceManager = class {
|
|
|
4038
3972
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
|
|
4039
3973
|
await this._metadataStore.addSpace(metadata);
|
|
4040
3974
|
const memberCredential = credentials[1];
|
|
4041
|
-
(0,
|
|
4042
|
-
F:
|
|
3975
|
+
(0, import_invariant11.invariant)((0, import_credentials11.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3976
|
+
F: __dxlog_file12,
|
|
4043
3977
|
L: 163,
|
|
4044
3978
|
S: this,
|
|
4045
3979
|
A: [
|
|
@@ -4057,13 +3991,13 @@ var DataSpaceManager = class {
|
|
|
4057
3991
|
(0, import_log10.log)("accept space", {
|
|
4058
3992
|
opts
|
|
4059
3993
|
}, {
|
|
4060
|
-
F:
|
|
3994
|
+
F: __dxlog_file12,
|
|
4061
3995
|
L: 175,
|
|
4062
3996
|
S: this,
|
|
4063
3997
|
C: (f, a) => f(...a)
|
|
4064
3998
|
});
|
|
4065
|
-
(0,
|
|
4066
|
-
F:
|
|
3999
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
4000
|
+
F: __dxlog_file12,
|
|
4067
4001
|
L: 176,
|
|
4068
4002
|
S: this,
|
|
4069
4003
|
A: [
|
|
@@ -4071,8 +4005,8 @@ var DataSpaceManager = class {
|
|
|
4071
4005
|
"'Not open.'"
|
|
4072
4006
|
]
|
|
4073
4007
|
});
|
|
4074
|
-
(0,
|
|
4075
|
-
F:
|
|
4008
|
+
(0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
4009
|
+
F: __dxlog_file12,
|
|
4076
4010
|
L: 177,
|
|
4077
4011
|
S: this,
|
|
4078
4012
|
A: [
|
|
@@ -4100,14 +4034,14 @@ var DataSpaceManager = class {
|
|
|
4100
4034
|
async waitUntilSpaceReady(spaceKey) {
|
|
4101
4035
|
await (0, import_context9.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
4102
4036
|
const space = this._spaces.get(spaceKey);
|
|
4103
|
-
return !!space && space.state ===
|
|
4037
|
+
return !!space && space.state === import_services8.SpaceState.READY;
|
|
4104
4038
|
}));
|
|
4105
4039
|
}
|
|
4106
4040
|
async _constructSpace(metadata) {
|
|
4107
4041
|
(0, import_log10.log)("construct space", {
|
|
4108
4042
|
metadata
|
|
4109
4043
|
}, {
|
|
4110
|
-
F:
|
|
4044
|
+
F: __dxlog_file12,
|
|
4111
4045
|
L: 210,
|
|
4112
4046
|
S: this,
|
|
4113
4047
|
C: (f, a) => f(...a)
|
|
@@ -4145,7 +4079,7 @@ var DataSpaceManager = class {
|
|
|
4145
4079
|
},
|
|
4146
4080
|
onAuthFailure: () => {
|
|
4147
4081
|
import_log10.log.warn("auth failure", void 0, {
|
|
4148
|
-
F:
|
|
4082
|
+
F: __dxlog_file12,
|
|
4149
4083
|
L: 247,
|
|
4150
4084
|
S: this,
|
|
4151
4085
|
C: (f, a) => f(...a)
|
|
@@ -4157,7 +4091,7 @@ var DataSpaceManager = class {
|
|
|
4157
4091
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
4158
4092
|
const dataSpace = new DataSpace({
|
|
4159
4093
|
inner: space,
|
|
4160
|
-
initialState: metadata.state ===
|
|
4094
|
+
initialState: metadata.state === import_services8.SpaceState.INACTIVE ? import_services8.SpaceState.INACTIVE : import_services8.SpaceState.CLOSED,
|
|
4161
4095
|
metadataStore: this._metadataStore,
|
|
4162
4096
|
gossip,
|
|
4163
4097
|
presence,
|
|
@@ -4169,7 +4103,7 @@ var DataSpaceManager = class {
|
|
|
4169
4103
|
(0, import_log10.log)("before space ready", {
|
|
4170
4104
|
space: space.key
|
|
4171
4105
|
}, {
|
|
4172
|
-
F:
|
|
4106
|
+
F: __dxlog_file12,
|
|
4173
4107
|
L: 265,
|
|
4174
4108
|
S: this,
|
|
4175
4109
|
C: (f, a) => f(...a)
|
|
@@ -4180,7 +4114,7 @@ var DataSpaceManager = class {
|
|
|
4180
4114
|
space: space.key,
|
|
4181
4115
|
open: this._isOpen
|
|
4182
4116
|
}, {
|
|
4183
|
-
F:
|
|
4117
|
+
F: __dxlog_file12,
|
|
4184
4118
|
L: 268,
|
|
4185
4119
|
S: this,
|
|
4186
4120
|
C: (f, a) => f(...a)
|
|
@@ -4193,7 +4127,7 @@ var DataSpaceManager = class {
|
|
|
4193
4127
|
(0, import_log10.log)("before space close", {
|
|
4194
4128
|
space: space.key
|
|
4195
4129
|
}, {
|
|
4196
|
-
F:
|
|
4130
|
+
F: __dxlog_file12,
|
|
4197
4131
|
L: 274,
|
|
4198
4132
|
S: this,
|
|
4199
4133
|
C: (f, a) => f(...a)
|
|
@@ -4203,7 +4137,7 @@ var DataSpaceManager = class {
|
|
|
4203
4137
|
cache: metadata.cache,
|
|
4204
4138
|
automergeHost: this._automergeHost
|
|
4205
4139
|
});
|
|
4206
|
-
if (metadata.state !==
|
|
4140
|
+
if (metadata.state !== import_services8.SpaceState.INACTIVE) {
|
|
4207
4141
|
await dataSpace.open();
|
|
4208
4142
|
}
|
|
4209
4143
|
if (metadata.controlTimeframe) {
|
|
@@ -4228,7 +4162,7 @@ _ts_decorate5([
|
|
|
4228
4162
|
DataSpaceManager = _ts_decorate5([
|
|
4229
4163
|
(0, import_async13.trackLeaks)("open", "close")
|
|
4230
4164
|
], DataSpaceManager);
|
|
4231
|
-
var
|
|
4165
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
4232
4166
|
var SpacesServiceImpl = class {
|
|
4233
4167
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
4234
4168
|
this._identityManager = _identityManager;
|
|
@@ -4245,29 +4179,29 @@ var SpacesServiceImpl = class {
|
|
|
4245
4179
|
}
|
|
4246
4180
|
async updateSpace({ spaceKey, state }) {
|
|
4247
4181
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4248
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4182
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4249
4183
|
if (state) {
|
|
4250
4184
|
switch (state) {
|
|
4251
|
-
case
|
|
4185
|
+
case import_services9.SpaceState.ACTIVE:
|
|
4252
4186
|
await space.activate();
|
|
4253
4187
|
break;
|
|
4254
|
-
case
|
|
4188
|
+
case import_services9.SpaceState.INACTIVE:
|
|
4255
4189
|
await space.deactivate();
|
|
4256
4190
|
break;
|
|
4257
4191
|
default:
|
|
4258
|
-
throw new
|
|
4192
|
+
throw new import_protocols10.ApiError("Invalid space state");
|
|
4259
4193
|
}
|
|
4260
4194
|
}
|
|
4261
4195
|
}
|
|
4262
4196
|
querySpaces() {
|
|
4263
|
-
return new
|
|
4197
|
+
return new import_codec_protobuf10.Stream(({ next, ctx }) => {
|
|
4264
4198
|
const scheduler = new import_async14.UpdateScheduler(ctx, async () => {
|
|
4265
4199
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4266
4200
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
4267
4201
|
(0, import_log11.log)("update", {
|
|
4268
4202
|
spaces
|
|
4269
4203
|
}, {
|
|
4270
|
-
F:
|
|
4204
|
+
F: __dxlog_file13,
|
|
4271
4205
|
L: 77,
|
|
4272
4206
|
S: this,
|
|
4273
4207
|
C: (f, a) => f(...a)
|
|
@@ -4307,14 +4241,14 @@ var SpacesServiceImpl = class {
|
|
|
4307
4241
|
}
|
|
4308
4242
|
async postMessage({ spaceKey, channel, message }) {
|
|
4309
4243
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4310
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4244
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4311
4245
|
await space.postMessage(getChannelId(channel), message);
|
|
4312
4246
|
}
|
|
4313
4247
|
subscribeMessages({ spaceKey, channel }) {
|
|
4314
|
-
return new
|
|
4248
|
+
return new import_codec_protobuf10.Stream(({ ctx, next }) => {
|
|
4315
4249
|
(0, import_async14.scheduleTask)(ctx, async () => {
|
|
4316
4250
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4317
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4251
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4318
4252
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
4319
4253
|
next(message);
|
|
4320
4254
|
});
|
|
@@ -4323,8 +4257,8 @@ var SpacesServiceImpl = class {
|
|
|
4323
4257
|
});
|
|
4324
4258
|
}
|
|
4325
4259
|
queryCredentials({ spaceKey, noTail }) {
|
|
4326
|
-
return new
|
|
4327
|
-
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4260
|
+
return new import_codec_protobuf10.Stream(({ ctx, next, close }) => {
|
|
4261
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4328
4262
|
const processor = {
|
|
4329
4263
|
processCredential: async (credential) => {
|
|
4330
4264
|
next(credential);
|
|
@@ -4340,7 +4274,7 @@ var SpacesServiceImpl = class {
|
|
|
4340
4274
|
});
|
|
4341
4275
|
}
|
|
4342
4276
|
async writeCredentials({ spaceKey, credentials }) {
|
|
4343
|
-
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4277
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4344
4278
|
for (const credential of credentials ?? []) {
|
|
4345
4279
|
if (credential.proof) {
|
|
4346
4280
|
await space.controlPipeline.writer.write({
|
|
@@ -4349,8 +4283,8 @@ var SpacesServiceImpl = class {
|
|
|
4349
4283
|
}
|
|
4350
4284
|
});
|
|
4351
4285
|
} else {
|
|
4352
|
-
(0,
|
|
4353
|
-
F:
|
|
4286
|
+
(0, import_invariant12.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
4287
|
+
F: __dxlog_file13,
|
|
4354
4288
|
L: 164,
|
|
4355
4289
|
S: this,
|
|
4356
4290
|
A: [
|
|
@@ -4358,8 +4292,8 @@ var SpacesServiceImpl = class {
|
|
|
4358
4292
|
"'Id on unsigned credentials is not allowed'"
|
|
4359
4293
|
]
|
|
4360
4294
|
});
|
|
4361
|
-
(0,
|
|
4362
|
-
F:
|
|
4295
|
+
(0, import_invariant12.invariant)(this._identityManager.identity, "Identity is not available", {
|
|
4296
|
+
F: __dxlog_file13,
|
|
4363
4297
|
L: 165,
|
|
4364
4298
|
S: this,
|
|
4365
4299
|
A: [
|
|
@@ -4368,8 +4302,8 @@ var SpacesServiceImpl = class {
|
|
|
4368
4302
|
]
|
|
4369
4303
|
});
|
|
4370
4304
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
4371
|
-
(0,
|
|
4372
|
-
F:
|
|
4305
|
+
(0, import_invariant12.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
4306
|
+
F: __dxlog_file13,
|
|
4373
4307
|
L: 167,
|
|
4374
4308
|
S: this,
|
|
4375
4309
|
A: [
|
|
@@ -4391,7 +4325,7 @@ var SpacesServiceImpl = class {
|
|
|
4391
4325
|
}
|
|
4392
4326
|
async createEpoch({ spaceKey, migration }) {
|
|
4393
4327
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4394
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4328
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4395
4329
|
await space.createEpoch({
|
|
4396
4330
|
migration
|
|
4397
4331
|
});
|
|
@@ -4400,7 +4334,7 @@ var SpacesServiceImpl = class {
|
|
|
4400
4334
|
return {
|
|
4401
4335
|
spaceKey: space.key,
|
|
4402
4336
|
state: space.state,
|
|
4403
|
-
error: space.error ? (0,
|
|
4337
|
+
error: space.error ? (0, import_protocols10.encodeError)(space.error) : void 0,
|
|
4404
4338
|
pipeline: {
|
|
4405
4339
|
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
4406
4340
|
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
@@ -4425,7 +4359,7 @@ var SpacesServiceImpl = class {
|
|
|
4425
4359
|
identityKey: member.key,
|
|
4426
4360
|
profile: member.profile ?? {}
|
|
4427
4361
|
},
|
|
4428
|
-
presence: member.removed ?
|
|
4362
|
+
presence: member.removed ? import_services9.SpaceMember.PresenceState.REMOVED : isMe || peers.length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE,
|
|
4429
4363
|
peerStates: peers
|
|
4430
4364
|
};
|
|
4431
4365
|
}),
|
|
@@ -4444,7 +4378,7 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
4444
4378
|
// TODO(mykola): Unload automerge handles after usage.
|
|
4445
4379
|
async function* loadDocuments(ids) {
|
|
4446
4380
|
for (const id of ids) {
|
|
4447
|
-
const { documentId, objectId } =
|
|
4381
|
+
const { documentId, objectId } = import_protocols12.idCodec.decode(id);
|
|
4448
4382
|
const handle = automergeHost.repo.find(documentId);
|
|
4449
4383
|
await (0, import_debug7.warnAfterTimeout)(5e3, "to long to load doc", () => handle.whenReady());
|
|
4450
4384
|
const doc = handle.docSync();
|
|
@@ -4477,7 +4411,7 @@ var createDocumentsIterator = (automergeHost) => (
|
|
|
4477
4411
|
if (doc.objects) {
|
|
4478
4412
|
yield Object.entries(doc.objects).map(([objectId, object]) => {
|
|
4479
4413
|
return {
|
|
4480
|
-
id:
|
|
4414
|
+
id: import_protocols12.idCodec.encode({
|
|
4481
4415
|
documentId: handle.documentId,
|
|
4482
4416
|
objectId
|
|
4483
4417
|
}),
|
|
@@ -4520,7 +4454,7 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4520
4454
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4521
4455
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4522
4456
|
}
|
|
4523
|
-
var
|
|
4457
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
4524
4458
|
var ServiceContext = class extends import_context10.Resource {
|
|
4525
4459
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
4526
4460
|
super();
|
|
@@ -4532,8 +4466,8 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4532
4466
|
this.initialized = new import_async15.Trigger();
|
|
4533
4467
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4534
4468
|
this._instanceId = import_keys10.PublicKey.random().toHex();
|
|
4535
|
-
this.metadataStore = new
|
|
4536
|
-
this.snapshotStore = new
|
|
4469
|
+
this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
|
|
4470
|
+
this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
|
|
4537
4471
|
this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
|
|
4538
4472
|
this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
|
|
4539
4473
|
this.feedStore = new import_feed_store4.FeedStore({
|
|
@@ -4541,12 +4475,12 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4541
4475
|
root: storage.createDirectory("feeds"),
|
|
4542
4476
|
signer: this.keyring,
|
|
4543
4477
|
hypercore: {
|
|
4544
|
-
valueEncoding:
|
|
4478
|
+
valueEncoding: import_echo_pipeline4.valueEncoding,
|
|
4545
4479
|
stats: true
|
|
4546
4480
|
}
|
|
4547
4481
|
})
|
|
4548
4482
|
});
|
|
4549
|
-
this.spaceManager = new
|
|
4483
|
+
this.spaceManager = new import_echo_pipeline4.SpaceManager({
|
|
4550
4484
|
feedStore: this.feedStore,
|
|
4551
4485
|
networkManager: this.networkManager,
|
|
4552
4486
|
blobStore: this.blobStore,
|
|
@@ -4557,64 +4491,69 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4557
4491
|
this.indexMetadata = new import_indexing.IndexMetadataStore({
|
|
4558
4492
|
db: level.sublevel("index-metadata")
|
|
4559
4493
|
});
|
|
4560
|
-
this.automergeHost = new
|
|
4494
|
+
this.automergeHost = new import_echo_pipeline4.AutomergeHost({
|
|
4561
4495
|
directory: storage.createDirectory("automerge"),
|
|
4562
|
-
|
|
4496
|
+
db: level.sublevel("automerge"),
|
|
4497
|
+
storageCallbacks: (0, import_indexing.createStorageCallbacks)({
|
|
4498
|
+
host: () => this.automergeHost,
|
|
4499
|
+
metadata: this.indexMetadata
|
|
4500
|
+
})
|
|
4563
4501
|
});
|
|
4564
4502
|
this.indexer = new import_indexing.Indexer({
|
|
4565
4503
|
indexStore: new import_indexing.IndexStore({
|
|
4566
|
-
|
|
4504
|
+
db: level.sublevel("index-storage")
|
|
4567
4505
|
}),
|
|
4568
4506
|
metadataStore: this.indexMetadata,
|
|
4569
4507
|
loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
|
|
4570
4508
|
getAllDocuments: createDocumentsIterator(this.automergeHost)
|
|
4571
4509
|
});
|
|
4572
4510
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4573
|
-
this._handlerFactories.set(
|
|
4511
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
4574
4512
|
}
|
|
4575
4513
|
async _open(ctx) {
|
|
4576
4514
|
await this._checkStorageVersion();
|
|
4577
4515
|
(0, import_log12.log)("opening...", void 0, {
|
|
4578
|
-
F:
|
|
4579
|
-
L:
|
|
4516
|
+
F: __dxlog_file14,
|
|
4517
|
+
L: 157,
|
|
4580
4518
|
S: this,
|
|
4581
4519
|
C: (f, a) => f(...a)
|
|
4582
4520
|
});
|
|
4583
|
-
import_log12.log.trace("dxos.sdk.service-context.open",
|
|
4521
|
+
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.begin({
|
|
4584
4522
|
id: this._instanceId
|
|
4585
4523
|
}), {
|
|
4586
|
-
F:
|
|
4587
|
-
L:
|
|
4524
|
+
F: __dxlog_file14,
|
|
4525
|
+
L: 158,
|
|
4588
4526
|
S: this,
|
|
4589
4527
|
C: (f, a) => f(...a)
|
|
4590
4528
|
});
|
|
4591
4529
|
await this.signalManager.open();
|
|
4592
4530
|
await this.networkManager.open();
|
|
4531
|
+
await this.automergeHost.open();
|
|
4593
4532
|
await this.metadataStore.load();
|
|
4594
4533
|
await this.spaceManager.open();
|
|
4595
4534
|
await this.identityManager.open(ctx);
|
|
4596
4535
|
if (this.identityManager.identity) {
|
|
4597
4536
|
await this._initialize(ctx);
|
|
4598
4537
|
}
|
|
4599
|
-
import_log12.log.trace("dxos.sdk.service-context.open",
|
|
4538
|
+
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.end({
|
|
4600
4539
|
id: this._instanceId
|
|
4601
4540
|
}), {
|
|
4602
|
-
F:
|
|
4603
|
-
L:
|
|
4541
|
+
F: __dxlog_file14,
|
|
4542
|
+
L: 169,
|
|
4604
4543
|
S: this,
|
|
4605
4544
|
C: (f, a) => f(...a)
|
|
4606
4545
|
});
|
|
4607
4546
|
(0, import_log12.log)("opened", void 0, {
|
|
4608
|
-
F:
|
|
4609
|
-
L:
|
|
4547
|
+
F: __dxlog_file14,
|
|
4548
|
+
L: 170,
|
|
4610
4549
|
S: this,
|
|
4611
4550
|
C: (f, a) => f(...a)
|
|
4612
4551
|
});
|
|
4613
4552
|
}
|
|
4614
4553
|
async _close() {
|
|
4615
4554
|
(0, import_log12.log)("closing...", void 0, {
|
|
4616
|
-
F:
|
|
4617
|
-
L:
|
|
4555
|
+
F: __dxlog_file14,
|
|
4556
|
+
L: 174,
|
|
4618
4557
|
S: this,
|
|
4619
4558
|
C: (f, a) => f(...a)
|
|
4620
4559
|
});
|
|
@@ -4631,8 +4570,8 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4631
4570
|
await this.metadataStore.close();
|
|
4632
4571
|
await this.indexer.destroy();
|
|
4633
4572
|
(0, import_log12.log)("closed", void 0, {
|
|
4634
|
-
F:
|
|
4635
|
-
L:
|
|
4573
|
+
F: __dxlog_file14,
|
|
4574
|
+
L: 187,
|
|
4636
4575
|
S: this,
|
|
4637
4576
|
C: (f, a) => f(...a)
|
|
4638
4577
|
});
|
|
@@ -4644,9 +4583,9 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4644
4583
|
}
|
|
4645
4584
|
getInvitationHandler(invitation) {
|
|
4646
4585
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4647
|
-
(0,
|
|
4648
|
-
F:
|
|
4649
|
-
L:
|
|
4586
|
+
(0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4587
|
+
F: __dxlog_file14,
|
|
4588
|
+
L: 198,
|
|
4650
4589
|
S: this,
|
|
4651
4590
|
A: [
|
|
4652
4591
|
"factory",
|
|
@@ -4670,15 +4609,15 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4670
4609
|
}
|
|
4671
4610
|
async _checkStorageVersion() {
|
|
4672
4611
|
await this.metadataStore.load();
|
|
4673
|
-
if (this.metadataStore.version !==
|
|
4674
|
-
throw new
|
|
4612
|
+
if (this.metadataStore.version !== import_protocols11.STORAGE_VERSION) {
|
|
4613
|
+
throw new import_protocols11.InvalidStorageVersionError(import_protocols11.STORAGE_VERSION, this.metadataStore.version);
|
|
4675
4614
|
}
|
|
4676
4615
|
}
|
|
4677
4616
|
// Called when identity is created.
|
|
4678
4617
|
async _initialize(ctx) {
|
|
4679
4618
|
(0, import_log12.log)("initializing spaces...", void 0, {
|
|
4680
|
-
F:
|
|
4681
|
-
L:
|
|
4619
|
+
F: __dxlog_file14,
|
|
4620
|
+
L: 229,
|
|
4682
4621
|
S: this,
|
|
4683
4622
|
C: (f, a) => f(...a)
|
|
4684
4623
|
});
|
|
@@ -4698,10 +4637,10 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4698
4637
|
};
|
|
4699
4638
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
|
|
4700
4639
|
await this.dataSpaceManager.open();
|
|
4701
|
-
this._handlerFactories.set(
|
|
4702
|
-
(0,
|
|
4703
|
-
F:
|
|
4704
|
-
L:
|
|
4640
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
|
|
4641
|
+
(0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4642
|
+
F: __dxlog_file14,
|
|
4643
|
+
L: 253,
|
|
4705
4644
|
S: this,
|
|
4706
4645
|
A: [
|
|
4707
4646
|
"this.dataSpaceManager",
|
|
@@ -4713,7 +4652,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4713
4652
|
this.initialized.wake();
|
|
4714
4653
|
this._deviceSpaceSync = {
|
|
4715
4654
|
processCredential: async (credential) => {
|
|
4716
|
-
const assertion = (0,
|
|
4655
|
+
const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
|
|
4717
4656
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
4718
4657
|
return;
|
|
4719
4658
|
}
|
|
@@ -4724,8 +4663,8 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4724
4663
|
(0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
4725
4664
|
details: assertion
|
|
4726
4665
|
}, {
|
|
4727
|
-
F:
|
|
4728
|
-
L:
|
|
4666
|
+
F: __dxlog_file14,
|
|
4667
|
+
L: 269,
|
|
4729
4668
|
S: this,
|
|
4730
4669
|
C: (f, a) => f(...a)
|
|
4731
4670
|
});
|
|
@@ -4735,8 +4674,8 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4735
4674
|
(0, import_log12.log)("space already exists, ignoring space admission", {
|
|
4736
4675
|
details: assertion
|
|
4737
4676
|
}, {
|
|
4738
|
-
F:
|
|
4739
|
-
L:
|
|
4677
|
+
F: __dxlog_file14,
|
|
4678
|
+
L: 273,
|
|
4740
4679
|
S: this,
|
|
4741
4680
|
C: (f, a) => f(...a)
|
|
4742
4681
|
});
|
|
@@ -4746,8 +4685,8 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4746
4685
|
(0, import_log12.log)("accepting space recorded in halo", {
|
|
4747
4686
|
details: assertion
|
|
4748
4687
|
}, {
|
|
4749
|
-
F:
|
|
4750
|
-
L:
|
|
4688
|
+
F: __dxlog_file14,
|
|
4689
|
+
L: 278,
|
|
4751
4690
|
S: this,
|
|
4752
4691
|
C: (f, a) => f(...a)
|
|
4753
4692
|
});
|
|
@@ -4757,8 +4696,8 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4757
4696
|
});
|
|
4758
4697
|
} catch (err) {
|
|
4759
4698
|
import_log12.log.catch(err, void 0, {
|
|
4760
|
-
F:
|
|
4761
|
-
L:
|
|
4699
|
+
F: __dxlog_file14,
|
|
4700
|
+
L: 284,
|
|
4762
4701
|
S: this,
|
|
4763
4702
|
C: (f, a) => f(...a)
|
|
4764
4703
|
});
|
|
@@ -4769,14 +4708,14 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4769
4708
|
}
|
|
4770
4709
|
};
|
|
4771
4710
|
_ts_decorate6([
|
|
4772
|
-
|
|
4711
|
+
import_tracing5.trace.span()
|
|
4773
4712
|
], ServiceContext.prototype, "_open", null);
|
|
4774
4713
|
_ts_decorate6([
|
|
4775
|
-
|
|
4714
|
+
import_tracing5.trace.span()
|
|
4776
4715
|
], ServiceContext.prototype, "_initialize", null);
|
|
4777
4716
|
ServiceContext = _ts_decorate6([
|
|
4778
4717
|
(0, import_util7.safeInstanceof)("dxos.client-services.ServiceContext"),
|
|
4779
|
-
|
|
4718
|
+
import_tracing5.trace.resource()
|
|
4780
4719
|
], ServiceContext);
|
|
4781
4720
|
var ServiceRegistry = class {
|
|
4782
4721
|
// prettier-ignore
|
|
@@ -4800,118 +4739,155 @@ var ServiceRegistry = class {
|
|
|
4800
4739
|
delete this._handlers[name];
|
|
4801
4740
|
}
|
|
4802
4741
|
};
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
if (
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
}
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
}
|
|
4820
|
-
|
|
4821
|
-
return
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
});
|
|
4830
|
-
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
4831
|
-
await this._onAcquire?.();
|
|
4832
|
-
(0, import_log13.log)("acquired lock", void 0, {
|
|
4833
|
-
F: __dxlog_file16,
|
|
4834
|
-
L: 37,
|
|
4835
|
-
S: this,
|
|
4836
|
-
C: (f, a) => f(...a)
|
|
4837
|
-
});
|
|
4742
|
+
var DXOS_VERSION = "0.4.10-main.fe71b4c";
|
|
4743
|
+
var getPlatform = () => {
|
|
4744
|
+
if (process.browser) {
|
|
4745
|
+
if (typeof window !== "undefined") {
|
|
4746
|
+
const { userAgent } = window.navigator;
|
|
4747
|
+
return {
|
|
4748
|
+
type: import_services12.Platform.PLATFORM_TYPE.BROWSER,
|
|
4749
|
+
userAgent,
|
|
4750
|
+
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
4751
|
+
};
|
|
4752
|
+
} else {
|
|
4753
|
+
return {
|
|
4754
|
+
type: import_services12.Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
4755
|
+
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
4756
|
+
};
|
|
4757
|
+
}
|
|
4758
|
+
} else {
|
|
4759
|
+
const { platform: platform2, version, arch } = process;
|
|
4760
|
+
return {
|
|
4761
|
+
type: import_services12.Platform.PLATFORM_TYPE.NODE,
|
|
4762
|
+
platform: platform2,
|
|
4763
|
+
arch,
|
|
4764
|
+
runtime: version,
|
|
4765
|
+
uptime: Math.floor(process.uptime()),
|
|
4766
|
+
memory: process.memoryUsage()
|
|
4767
|
+
};
|
|
4838
4768
|
}
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4769
|
+
};
|
|
4770
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
|
|
4771
|
+
var DEFAULT_TIMEOUT = 1e3;
|
|
4772
|
+
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
4773
|
+
const diagnostics = {
|
|
4774
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4775
|
+
platform: getPlatform(),
|
|
4776
|
+
client: {
|
|
4777
|
+
version: DXOS_VERSION,
|
|
4778
|
+
storage: {
|
|
4779
|
+
version: import_protocols13.STORAGE_VERSION
|
|
4780
|
+
}
|
|
4781
|
+
},
|
|
4782
|
+
trace: import_tracing6.TRACE_PROCESSOR.getDiagnostics()
|
|
4783
|
+
};
|
|
4784
|
+
{
|
|
4785
|
+
(0, import_invariant14.invariant)(clientServices.LoggingService, "SystemService is not available.", {
|
|
4786
|
+
F: __dxlog_file15,
|
|
4787
|
+
L: 108,
|
|
4788
|
+
S: void 0,
|
|
4845
4789
|
A: [
|
|
4846
|
-
"
|
|
4847
|
-
"'
|
|
4790
|
+
"clientServices.LoggingService",
|
|
4791
|
+
"'SystemService is not available.'"
|
|
4848
4792
|
]
|
|
4849
4793
|
});
|
|
4850
|
-
await
|
|
4851
|
-
|
|
4852
|
-
};
|
|
4853
|
-
_ts_decorate7([
|
|
4854
|
-
import_log13.logInfo
|
|
4855
|
-
], Lock.prototype, "lockKey", null);
|
|
4856
|
-
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
4857
|
-
var getRootPath = (config) => {
|
|
4858
|
-
const { dataRoot = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage" } = config ?? {};
|
|
4859
|
-
return `${dataRoot}/`;
|
|
4860
|
-
};
|
|
4861
|
-
var isPersistent = (config) => {
|
|
4862
|
-
const { persistent = false } = config ?? {};
|
|
4863
|
-
return config.dataStore !== void 0 && config.dataStore !== import_config2.Runtime.Client.Storage.StorageDriver.RAM || persistent;
|
|
4864
|
-
};
|
|
4865
|
-
var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
4866
|
-
var createStorageObjects = (config) => {
|
|
4867
|
-
const { persistent = false, keyStore, dataStore } = config ?? {};
|
|
4868
|
-
if (persistent && dataStore === StorageDriver.RAM) {
|
|
4869
|
-
throw new import_protocols14.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
4794
|
+
diagnostics.metrics = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
|
|
4795
|
+
timeout: DEFAULT_TIMEOUT
|
|
4796
|
+
}).catch(() => void 0);
|
|
4870
4797
|
}
|
|
4871
|
-
if (
|
|
4872
|
-
|
|
4798
|
+
if (typeof navigator !== "undefined" && navigator.storage) {
|
|
4799
|
+
const map = /* @__PURE__ */ new Map();
|
|
4800
|
+
const dir = await navigator.storage.getDirectory();
|
|
4801
|
+
for await (const filename of dir?.keys()) {
|
|
4802
|
+
const idx = filename.indexOf("-", filename.indexOf("-") + 1);
|
|
4803
|
+
if (idx === -1) {
|
|
4804
|
+
continue;
|
|
4805
|
+
}
|
|
4806
|
+
map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
|
|
4807
|
+
}
|
|
4808
|
+
diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
|
|
4809
|
+
file,
|
|
4810
|
+
count
|
|
4811
|
+
}));
|
|
4873
4812
|
}
|
|
4874
|
-
|
|
4875
|
-
|
|
4813
|
+
const identity = serviceContext.identityManager.identity;
|
|
4814
|
+
if (identity) {
|
|
4815
|
+
diagnostics.identity = {
|
|
4816
|
+
identityKey: identity.identityKey,
|
|
4817
|
+
spaceKey: identity.space.key,
|
|
4818
|
+
profile: identity.profileDocument
|
|
4819
|
+
};
|
|
4820
|
+
const { devices } = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
|
|
4821
|
+
timeout: DEFAULT_TIMEOUT
|
|
4822
|
+
}).catch(() => void 0) ?? {};
|
|
4823
|
+
diagnostics.devices = devices;
|
|
4824
|
+
if (serviceContext.dataSpaceManager) {
|
|
4825
|
+
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
4826
|
+
}
|
|
4827
|
+
const { feeds = [] } = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
4828
|
+
timeout: DEFAULT_TIMEOUT
|
|
4829
|
+
}).catch(() => void 0) ?? {};
|
|
4830
|
+
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
4831
|
+
feedKey,
|
|
4832
|
+
bytes,
|
|
4833
|
+
length
|
|
4834
|
+
}));
|
|
4835
|
+
const status = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
|
|
4836
|
+
timeout: DEFAULT_TIMEOUT
|
|
4837
|
+
}).catch(() => void 0);
|
|
4838
|
+
diagnostics.networkStatus = status;
|
|
4839
|
+
diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
|
|
4876
4840
|
}
|
|
4877
|
-
|
|
4878
|
-
|
|
4841
|
+
diagnostics.config = config.values;
|
|
4842
|
+
return diagnostics;
|
|
4843
|
+
};
|
|
4844
|
+
var getSpaceStats = async (space) => {
|
|
4845
|
+
const stats = {
|
|
4846
|
+
key: space.key,
|
|
4847
|
+
metrics: space.metrics,
|
|
4848
|
+
epochs: space.inner.spaceState.credentials.filter((0, import_credentials15.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
4849
|
+
...credential.subject.assertion,
|
|
4850
|
+
id: credential.id
|
|
4851
|
+
})),
|
|
4852
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
4853
|
+
identity: {
|
|
4854
|
+
identityKey: member.key,
|
|
4855
|
+
profile: {
|
|
4856
|
+
displayName: member.assertion.profile?.displayName
|
|
4857
|
+
}
|
|
4858
|
+
},
|
|
4859
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services11.SpaceMember.PresenceState.ONLINE : import_services11.SpaceMember.PresenceState.OFFLINE
|
|
4860
|
+
})),
|
|
4861
|
+
pipeline: {
|
|
4862
|
+
// TODO(burdon): Pick properties from credentials if needed.
|
|
4863
|
+
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
4864
|
+
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
4865
|
+
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
4866
|
+
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
4867
|
+
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
4868
|
+
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
|
|
4869
|
+
}
|
|
4870
|
+
};
|
|
4871
|
+
if (stats.metrics) {
|
|
4872
|
+
const { open, ready } = stats.metrics;
|
|
4873
|
+
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
4879
4874
|
}
|
|
4875
|
+
return stats;
|
|
4876
|
+
};
|
|
4877
|
+
var createCollectDiagnosticsBroadcastSender = () => {
|
|
4880
4878
|
return {
|
|
4881
|
-
|
|
4882
|
-
type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
|
|
4883
|
-
root: getRootPath(config)
|
|
4884
|
-
})
|
|
4879
|
+
broadcastDiagnosticsRequest: async () => void 0
|
|
4885
4880
|
};
|
|
4886
4881
|
};
|
|
4887
|
-
var
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
return import_random_access_storage.StorageType.CHROME;
|
|
4895
|
-
case StorageDriver.FIREFOX:
|
|
4896
|
-
return import_random_access_storage.StorageType.FIREFOX;
|
|
4897
|
-
case StorageDriver.IDB:
|
|
4898
|
-
return import_random_access_storage.StorageType.IDB;
|
|
4899
|
-
case StorageDriver.NODE:
|
|
4900
|
-
return import_random_access_storage.StorageType.NODE;
|
|
4901
|
-
case StorageDriver.WEBFS:
|
|
4902
|
-
return import_random_access_storage.StorageType.WEBFS;
|
|
4903
|
-
default:
|
|
4904
|
-
throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
|
|
4905
|
-
}
|
|
4906
|
-
};
|
|
4907
|
-
var createLevel = async (config) => {
|
|
4908
|
-
const persistent = isPersistent(config);
|
|
4909
|
-
const storagePath = persistent ? getRootPath(config) : import_node_path.default.join("tmp", "level", import_keys11.PublicKey.random().toHex());
|
|
4910
|
-
const level = new import_level.Level(storagePath);
|
|
4911
|
-
await level.open();
|
|
4912
|
-
return level;
|
|
4882
|
+
var createCollectDiagnosticsBroadcastHandler = (_) => {
|
|
4883
|
+
return {
|
|
4884
|
+
start: () => {
|
|
4885
|
+
},
|
|
4886
|
+
stop: () => {
|
|
4887
|
+
}
|
|
4888
|
+
};
|
|
4913
4889
|
};
|
|
4914
|
-
var
|
|
4890
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
4915
4891
|
var DevicesServiceImpl = class {
|
|
4916
4892
|
constructor(_identityManager) {
|
|
4917
4893
|
this._identityManager = _identityManager;
|
|
@@ -4928,8 +4904,8 @@ var DevicesServiceImpl = class {
|
|
|
4928
4904
|
devices: []
|
|
4929
4905
|
});
|
|
4930
4906
|
} else {
|
|
4931
|
-
(0,
|
|
4932
|
-
F:
|
|
4907
|
+
(0, import_invariant16.invariant)(this._identityManager.identity?.presence, "presence not present", {
|
|
4908
|
+
F: __dxlog_file16,
|
|
4933
4909
|
L: 32,
|
|
4934
4910
|
S: this,
|
|
4935
4911
|
A: [
|
|
@@ -4944,9 +4920,9 @@ var DevicesServiceImpl = class {
|
|
|
4944
4920
|
const peerState = peers.find((peer) => peer.identityKey.equals(key));
|
|
4945
4921
|
return {
|
|
4946
4922
|
deviceKey: key,
|
|
4947
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ?
|
|
4923
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services15.DeviceKind.CURRENT : import_services15.DeviceKind.TRUSTED,
|
|
4948
4924
|
profile,
|
|
4949
|
-
presence: isMe ?
|
|
4925
|
+
presence: isMe ? import_services15.Device.PresenceState.ONLINE : peerState ? import_services15.Device.PresenceState.ONLINE : import_services15.Device.PresenceState.OFFLINE
|
|
4950
4926
|
};
|
|
4951
4927
|
})
|
|
4952
4928
|
});
|
|
@@ -4987,11 +4963,65 @@ var DevicesServiceImpl = class {
|
|
|
4987
4963
|
});
|
|
4988
4964
|
}
|
|
4989
4965
|
};
|
|
4966
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
4967
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4968
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4969
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
4970
|
+
else
|
|
4971
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
4972
|
+
if (d = decorators[i])
|
|
4973
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4974
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4975
|
+
}
|
|
4976
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
4977
|
+
var Lock = class {
|
|
4978
|
+
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
4979
|
+
this._lockPath = lockPath;
|
|
4980
|
+
this._onAcquire = onAcquire;
|
|
4981
|
+
this._onRelease = onRelease;
|
|
4982
|
+
}
|
|
4983
|
+
get lockKey() {
|
|
4984
|
+
return this._lockPath;
|
|
4985
|
+
}
|
|
4986
|
+
async acquire() {
|
|
4987
|
+
(0, import_log14.log)("acquiring lock...", void 0, {
|
|
4988
|
+
F: __dxlog_file17,
|
|
4989
|
+
L: 32,
|
|
4990
|
+
S: this,
|
|
4991
|
+
C: (f, a) => f(...a)
|
|
4992
|
+
});
|
|
4993
|
+
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
4994
|
+
await this._onAcquire?.();
|
|
4995
|
+
(0, import_log14.log)("acquired lock", void 0, {
|
|
4996
|
+
F: __dxlog_file17,
|
|
4997
|
+
L: 37,
|
|
4998
|
+
S: this,
|
|
4999
|
+
C: (f, a) => f(...a)
|
|
5000
|
+
});
|
|
5001
|
+
}
|
|
5002
|
+
async release() {
|
|
5003
|
+
await this._onRelease?.();
|
|
5004
|
+
(0, import_invariant17.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
5005
|
+
F: __dxlog_file17,
|
|
5006
|
+
L: 42,
|
|
5007
|
+
S: this,
|
|
5008
|
+
A: [
|
|
5009
|
+
"this._fileHandle",
|
|
5010
|
+
"'Lock is not acquired'"
|
|
5011
|
+
]
|
|
5012
|
+
});
|
|
5013
|
+
await import_lock_file.LockFile.release(this._fileHandle);
|
|
5014
|
+
}
|
|
5015
|
+
};
|
|
5016
|
+
_ts_decorate7([
|
|
5017
|
+
import_log14.logInfo
|
|
5018
|
+
], Lock.prototype, "lockKey", null);
|
|
5019
|
+
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
4990
5020
|
var LoggingServiceImpl = class {
|
|
4991
5021
|
constructor() {
|
|
4992
5022
|
this._logs = new import_async18.Event();
|
|
4993
5023
|
this._started = Date.now();
|
|
4994
|
-
this._sessionId =
|
|
5024
|
+
this._sessionId = import_keys12.PublicKey.random().toHex();
|
|
4995
5025
|
this._logProcessor = (_config, entry2) => {
|
|
4996
5026
|
this._logs.emit(entry2);
|
|
4997
5027
|
};
|
|
@@ -5088,16 +5118,16 @@ var LoggingServiceImpl = class {
|
|
|
5088
5118
|
};
|
|
5089
5119
|
var matchFilter = (filter, level, path2, options) => {
|
|
5090
5120
|
switch (options) {
|
|
5091
|
-
case
|
|
5121
|
+
case import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
5092
5122
|
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5093
|
-
case
|
|
5123
|
+
case import_services16.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
5094
5124
|
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5095
5125
|
}
|
|
5096
5126
|
};
|
|
5097
5127
|
var shouldLog = (entry2, request) => {
|
|
5098
|
-
const options = request.options ??
|
|
5128
|
+
const options = request.options ?? import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5099
5129
|
if (request.filters === void 0) {
|
|
5100
|
-
return options ===
|
|
5130
|
+
return options === import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5101
5131
|
} else {
|
|
5102
5132
|
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
5103
5133
|
}
|
|
@@ -5133,6 +5163,63 @@ var NetworkServiceImpl = class {
|
|
|
5133
5163
|
await this.networkManager.setConnectionState(request.swarm);
|
|
5134
5164
|
}
|
|
5135
5165
|
};
|
|
5166
|
+
var getRootPath = (config) => {
|
|
5167
|
+
const { dataRoot = (0, import_util11.isNode)() ? import_client_protocol5.DX_DATA : "dxos/storage" } = config ?? {};
|
|
5168
|
+
return `${dataRoot}/`;
|
|
5169
|
+
};
|
|
5170
|
+
var isPersistent = (config) => {
|
|
5171
|
+
const { persistent = false } = config ?? {};
|
|
5172
|
+
return config.dataStore !== void 0 && config.dataStore !== import_config3.Runtime.Client.Storage.StorageDriver.RAM || persistent;
|
|
5173
|
+
};
|
|
5174
|
+
var StorageDriver = import_config2.Runtime.Client.Storage.StorageDriver;
|
|
5175
|
+
var createStorageObjects = (config) => {
|
|
5176
|
+
const { persistent = false, keyStore, dataStore } = config ?? {};
|
|
5177
|
+
if (persistent && dataStore === StorageDriver.RAM) {
|
|
5178
|
+
throw new import_protocols15.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
5179
|
+
}
|
|
5180
|
+
if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
|
|
5181
|
+
throw new import_protocols15.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
5182
|
+
}
|
|
5183
|
+
if (persistent && keyStore === StorageDriver.RAM) {
|
|
5184
|
+
throw new import_protocols15.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
5185
|
+
}
|
|
5186
|
+
if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
|
|
5187
|
+
throw new import_protocols15.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
5188
|
+
}
|
|
5189
|
+
return {
|
|
5190
|
+
storage: (0, import_random_access_storage.createStorage)({
|
|
5191
|
+
type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
|
|
5192
|
+
root: getRootPath(config)
|
|
5193
|
+
})
|
|
5194
|
+
};
|
|
5195
|
+
};
|
|
5196
|
+
var toStorageType = (type) => {
|
|
5197
|
+
switch (type) {
|
|
5198
|
+
case void 0:
|
|
5199
|
+
return void 0;
|
|
5200
|
+
case StorageDriver.RAM:
|
|
5201
|
+
return import_random_access_storage.StorageType.RAM;
|
|
5202
|
+
case StorageDriver.CHROME:
|
|
5203
|
+
return import_random_access_storage.StorageType.CHROME;
|
|
5204
|
+
case StorageDriver.FIREFOX:
|
|
5205
|
+
return import_random_access_storage.StorageType.FIREFOX;
|
|
5206
|
+
case StorageDriver.IDB:
|
|
5207
|
+
return import_random_access_storage.StorageType.IDB;
|
|
5208
|
+
case StorageDriver.NODE:
|
|
5209
|
+
return import_random_access_storage.StorageType.NODE;
|
|
5210
|
+
case StorageDriver.WEBFS:
|
|
5211
|
+
return import_random_access_storage.StorageType.WEBFS;
|
|
5212
|
+
default:
|
|
5213
|
+
throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
|
|
5214
|
+
}
|
|
5215
|
+
};
|
|
5216
|
+
var createLevel = async (config) => {
|
|
5217
|
+
const persistent = isPersistent(config);
|
|
5218
|
+
const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys13.PublicKey.random().toHex()}`;
|
|
5219
|
+
const level = new import_level.Level(storagePath);
|
|
5220
|
+
await level.open();
|
|
5221
|
+
return level;
|
|
5222
|
+
};
|
|
5136
5223
|
var SystemServiceImpl = class {
|
|
5137
5224
|
constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
5138
5225
|
this._config = config;
|
|
@@ -5152,9 +5239,9 @@ var SystemServiceImpl = class {
|
|
|
5152
5239
|
const diagnostics = await this._getDiagnostics();
|
|
5153
5240
|
return {
|
|
5154
5241
|
timestamp: /* @__PURE__ */ new Date(),
|
|
5155
|
-
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0,
|
|
5156
|
-
truncate: keys ===
|
|
5157
|
-
humanize: keys ===
|
|
5242
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util12.jsonKeyReplacer)({
|
|
5243
|
+
truncate: keys === import_services17.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
5244
|
+
humanize: keys === import_services17.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
5158
5245
|
})))
|
|
5159
5246
|
};
|
|
5160
5247
|
}
|
|
@@ -5202,16 +5289,18 @@ var ClientServicesHost = class {
|
|
|
5202
5289
|
transportFactory,
|
|
5203
5290
|
signalManager,
|
|
5204
5291
|
storage,
|
|
5292
|
+
level,
|
|
5205
5293
|
// TODO(wittjosiah): Turn this on by default.
|
|
5206
5294
|
lockKey,
|
|
5207
5295
|
callbacks,
|
|
5208
5296
|
runtimeParams
|
|
5209
5297
|
} = {}) {
|
|
5210
|
-
this._tracingService =
|
|
5298
|
+
this._tracingService = import_tracing8.TRACE_PROCESSOR.createTraceSender();
|
|
5211
5299
|
this._statusUpdate = new import_async16.Event();
|
|
5212
5300
|
this._opening = false;
|
|
5213
5301
|
this._open = false;
|
|
5214
5302
|
this._storage = storage;
|
|
5303
|
+
this._level = level;
|
|
5215
5304
|
this._callbacks = callbacks;
|
|
5216
5305
|
this._runtimeParams = runtimeParams;
|
|
5217
5306
|
if (config) {
|
|
@@ -5235,14 +5324,14 @@ var ClientServicesHost = class {
|
|
|
5235
5324
|
this._systemService = new SystemServiceImpl({
|
|
5236
5325
|
config: () => this._config,
|
|
5237
5326
|
statusUpdate: this._statusUpdate,
|
|
5238
|
-
getCurrentStatus: () => this.isOpen ?
|
|
5327
|
+
getCurrentStatus: () => this.isOpen ? import_services14.SystemStatus.ACTIVE : import_services14.SystemStatus.INACTIVE,
|
|
5239
5328
|
getDiagnostics: () => {
|
|
5240
5329
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
5241
5330
|
},
|
|
5242
5331
|
onUpdateStatus: async (status) => {
|
|
5243
|
-
if (!this.isOpen && status ===
|
|
5332
|
+
if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
|
|
5244
5333
|
await this._resourceLock?.acquire();
|
|
5245
|
-
} else if (this.isOpen && status ===
|
|
5334
|
+
} else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
|
|
5246
5335
|
await this._resourceLock?.release();
|
|
5247
5336
|
}
|
|
5248
5337
|
},
|
|
@@ -5250,8 +5339,9 @@ var ClientServicesHost = class {
|
|
|
5250
5339
|
await this.reset();
|
|
5251
5340
|
}
|
|
5252
5341
|
});
|
|
5342
|
+
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
5253
5343
|
this._loggingService = new LoggingServiceImpl();
|
|
5254
|
-
this._serviceRegistry = new ServiceRegistry(
|
|
5344
|
+
this._serviceRegistry = new ServiceRegistry(import_client_protocol4.clientServiceBundle, {
|
|
5255
5345
|
SystemService: this._systemService,
|
|
5256
5346
|
TracingService: this._tracingService
|
|
5257
5347
|
});
|
|
@@ -5280,25 +5370,25 @@ var ClientServicesHost = class {
|
|
|
5280
5370
|
* Can only be called once.
|
|
5281
5371
|
*/
|
|
5282
5372
|
initialize({ config, ...options }) {
|
|
5283
|
-
(0,
|
|
5373
|
+
(0, import_invariant15.invariant)(!this._open, "service host is open", {
|
|
5284
5374
|
F: __dxlog_file18,
|
|
5285
|
-
L:
|
|
5375
|
+
L: 197,
|
|
5286
5376
|
S: this,
|
|
5287
5377
|
A: [
|
|
5288
5378
|
"!this._open",
|
|
5289
5379
|
"'service host is open'"
|
|
5290
5380
|
]
|
|
5291
5381
|
});
|
|
5292
|
-
(0,
|
|
5382
|
+
(0, import_log13.log)("initializing...", void 0, {
|
|
5293
5383
|
F: __dxlog_file18,
|
|
5294
|
-
L:
|
|
5384
|
+
L: 198,
|
|
5295
5385
|
S: this,
|
|
5296
5386
|
C: (f, a) => f(...a)
|
|
5297
5387
|
});
|
|
5298
5388
|
if (config) {
|
|
5299
|
-
(0,
|
|
5389
|
+
(0, import_invariant15.invariant)(!this._config, "config already set", {
|
|
5300
5390
|
F: __dxlog_file18,
|
|
5301
|
-
L:
|
|
5391
|
+
L: 201,
|
|
5302
5392
|
S: this,
|
|
5303
5393
|
A: [
|
|
5304
5394
|
"!this._config",
|
|
@@ -5311,9 +5401,9 @@ var ClientServicesHost = class {
|
|
|
5311
5401
|
}
|
|
5312
5402
|
}
|
|
5313
5403
|
if (!options.signalManager) {
|
|
5314
|
-
|
|
5404
|
+
import_log13.log.warn("running signaling without telemetry metadata.", void 0, {
|
|
5315
5405
|
F: __dxlog_file18,
|
|
5316
|
-
L:
|
|
5406
|
+
L: 209,
|
|
5317
5407
|
S: this,
|
|
5318
5408
|
C: (f, a) => f(...a)
|
|
5319
5409
|
});
|
|
@@ -5322,9 +5412,9 @@ var ClientServicesHost = class {
|
|
|
5322
5412
|
iceServers: this._config?.get("runtime.services.ice")
|
|
5323
5413
|
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
5324
5414
|
this._signalManager = signalManager;
|
|
5325
|
-
(0,
|
|
5415
|
+
(0, import_invariant15.invariant)(!this._networkManager, "network manager already set", {
|
|
5326
5416
|
F: __dxlog_file18,
|
|
5327
|
-
L:
|
|
5417
|
+
L: 220,
|
|
5328
5418
|
S: this,
|
|
5329
5419
|
A: [
|
|
5330
5420
|
"!this._networkManager",
|
|
@@ -5336,9 +5426,9 @@ var ClientServicesHost = class {
|
|
|
5336
5426
|
transportFactory,
|
|
5337
5427
|
signalManager
|
|
5338
5428
|
});
|
|
5339
|
-
(0,
|
|
5429
|
+
(0, import_log13.log)("initialized", void 0, {
|
|
5340
5430
|
F: __dxlog_file18,
|
|
5341
|
-
L:
|
|
5431
|
+
L: 227,
|
|
5342
5432
|
S: this,
|
|
5343
5433
|
C: (f, a) => f(...a)
|
|
5344
5434
|
});
|
|
@@ -5347,45 +5437,45 @@ var ClientServicesHost = class {
|
|
|
5347
5437
|
if (this._open) {
|
|
5348
5438
|
return;
|
|
5349
5439
|
}
|
|
5350
|
-
const traceId =
|
|
5351
|
-
|
|
5440
|
+
const traceId = import_keys11.PublicKey.random().toHex();
|
|
5441
|
+
import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.begin({
|
|
5352
5442
|
id: traceId
|
|
5353
5443
|
}), {
|
|
5354
5444
|
F: __dxlog_file18,
|
|
5355
|
-
L:
|
|
5445
|
+
L: 238,
|
|
5356
5446
|
S: this,
|
|
5357
5447
|
C: (f, a) => f(...a)
|
|
5358
5448
|
});
|
|
5359
|
-
(0,
|
|
5449
|
+
(0, import_invariant15.invariant)(this._config, "config not set", {
|
|
5360
5450
|
F: __dxlog_file18,
|
|
5361
|
-
L:
|
|
5451
|
+
L: 240,
|
|
5362
5452
|
S: this,
|
|
5363
5453
|
A: [
|
|
5364
5454
|
"this._config",
|
|
5365
5455
|
"'config not set'"
|
|
5366
5456
|
]
|
|
5367
5457
|
});
|
|
5368
|
-
(0,
|
|
5458
|
+
(0, import_invariant15.invariant)(this._storage, "storage not set", {
|
|
5369
5459
|
F: __dxlog_file18,
|
|
5370
|
-
L:
|
|
5460
|
+
L: 241,
|
|
5371
5461
|
S: this,
|
|
5372
5462
|
A: [
|
|
5373
5463
|
"this._storage",
|
|
5374
5464
|
"'storage not set'"
|
|
5375
5465
|
]
|
|
5376
5466
|
});
|
|
5377
|
-
(0,
|
|
5467
|
+
(0, import_invariant15.invariant)(this._signalManager, "signal manager not set", {
|
|
5378
5468
|
F: __dxlog_file18,
|
|
5379
|
-
L:
|
|
5469
|
+
L: 242,
|
|
5380
5470
|
S: this,
|
|
5381
5471
|
A: [
|
|
5382
5472
|
"this._signalManager",
|
|
5383
5473
|
"'signal manager not set'"
|
|
5384
5474
|
]
|
|
5385
5475
|
});
|
|
5386
|
-
(0,
|
|
5476
|
+
(0, import_invariant15.invariant)(this._networkManager, "network manager not set", {
|
|
5387
5477
|
F: __dxlog_file18,
|
|
5388
|
-
L:
|
|
5478
|
+
L: 243,
|
|
5389
5479
|
S: this,
|
|
5390
5480
|
A: [
|
|
5391
5481
|
"this._networkManager",
|
|
@@ -5393,17 +5483,18 @@ var ClientServicesHost = class {
|
|
|
5393
5483
|
]
|
|
5394
5484
|
});
|
|
5395
5485
|
this._opening = true;
|
|
5396
|
-
(0,
|
|
5486
|
+
(0, import_log13.log)("opening...", {
|
|
5397
5487
|
lockKey: this._resourceLock?.lockKey
|
|
5398
5488
|
}, {
|
|
5399
5489
|
F: __dxlog_file18,
|
|
5400
|
-
L:
|
|
5490
|
+
L: 246,
|
|
5401
5491
|
S: this,
|
|
5402
5492
|
C: (f, a) => f(...a)
|
|
5403
5493
|
});
|
|
5404
5494
|
if (!this._level) {
|
|
5405
5495
|
this._level = await createLevel(this._config.get("runtime.client.storage", {}));
|
|
5406
5496
|
}
|
|
5497
|
+
await this._level.open();
|
|
5407
5498
|
await this._resourceLock?.acquire();
|
|
5408
5499
|
await this._loggingService.open();
|
|
5409
5500
|
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
|
|
@@ -5416,7 +5507,7 @@ var ClientServicesHost = class {
|
|
|
5416
5507
|
await this._serviceContext.initialized.wait();
|
|
5417
5508
|
return this._serviceContext.dataSpaceManager;
|
|
5418
5509
|
}),
|
|
5419
|
-
DataService: new
|
|
5510
|
+
DataService: new import_echo_pipeline5.DataServiceImpl(this._serviceContext.automergeHost),
|
|
5420
5511
|
IndexService: new import_indexing2.IndexServiceImpl({
|
|
5421
5512
|
indexer: this._serviceContext.indexer,
|
|
5422
5513
|
automergeHost: this._serviceContext.automergeHost
|
|
@@ -5432,9 +5523,9 @@ var ClientServicesHost = class {
|
|
|
5432
5523
|
})
|
|
5433
5524
|
});
|
|
5434
5525
|
await this._serviceContext.open(ctx);
|
|
5435
|
-
(0,
|
|
5526
|
+
(0, import_invariant15.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5436
5527
|
F: __dxlog_file18,
|
|
5437
|
-
L:
|
|
5528
|
+
L: 314,
|
|
5438
5529
|
S: this,
|
|
5439
5530
|
A: [
|
|
5440
5531
|
"this.serviceRegistry.services.InvitationsService",
|
|
@@ -5442,11 +5533,11 @@ var ClientServicesHost = class {
|
|
|
5442
5533
|
]
|
|
5443
5534
|
});
|
|
5444
5535
|
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5445
|
-
(0,
|
|
5536
|
+
(0, import_log13.log)("loaded persistent invitations", {
|
|
5446
5537
|
count: loadedInvitations.invitations?.length
|
|
5447
5538
|
}, {
|
|
5448
5539
|
F: __dxlog_file18,
|
|
5449
|
-
L:
|
|
5540
|
+
L: 317,
|
|
5450
5541
|
S: this,
|
|
5451
5542
|
C: (f, a) => f(...a)
|
|
5452
5543
|
});
|
|
@@ -5455,28 +5546,29 @@ var ClientServicesHost = class {
|
|
|
5455
5546
|
this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
|
|
5456
5547
|
url: devtoolsProxy,
|
|
5457
5548
|
requested: {},
|
|
5458
|
-
exposed:
|
|
5549
|
+
exposed: import_client_protocol4.clientServiceBundle,
|
|
5459
5550
|
handlers: this.services
|
|
5460
5551
|
});
|
|
5461
5552
|
void this._devtoolsProxy.open();
|
|
5462
5553
|
}
|
|
5554
|
+
this.diagnosticsBroadcastHandler.start();
|
|
5463
5555
|
this._opening = false;
|
|
5464
5556
|
this._open = true;
|
|
5465
5557
|
this._statusUpdate.emit();
|
|
5466
5558
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5467
|
-
(0,
|
|
5559
|
+
(0, import_log13.log)("opened", {
|
|
5468
5560
|
deviceKey
|
|
5469
5561
|
}, {
|
|
5470
5562
|
F: __dxlog_file18,
|
|
5471
|
-
L:
|
|
5563
|
+
L: 335,
|
|
5472
5564
|
S: this,
|
|
5473
5565
|
C: (f, a) => f(...a)
|
|
5474
5566
|
});
|
|
5475
|
-
|
|
5567
|
+
import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.end({
|
|
5476
5568
|
id: traceId
|
|
5477
5569
|
}), {
|
|
5478
5570
|
F: __dxlog_file18,
|
|
5479
|
-
L:
|
|
5571
|
+
L: 336,
|
|
5480
5572
|
S: this,
|
|
5481
5573
|
C: (f, a) => f(...a)
|
|
5482
5574
|
});
|
|
@@ -5486,14 +5578,15 @@ var ClientServicesHost = class {
|
|
|
5486
5578
|
return;
|
|
5487
5579
|
}
|
|
5488
5580
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5489
|
-
(0,
|
|
5581
|
+
(0, import_log13.log)("closing...", {
|
|
5490
5582
|
deviceKey
|
|
5491
5583
|
}, {
|
|
5492
5584
|
F: __dxlog_file18,
|
|
5493
|
-
L:
|
|
5585
|
+
L: 347,
|
|
5494
5586
|
S: this,
|
|
5495
5587
|
C: (f, a) => f(...a)
|
|
5496
5588
|
});
|
|
5589
|
+
this.diagnosticsBroadcastHandler.stop();
|
|
5497
5590
|
await this._devtoolsProxy?.close();
|
|
5498
5591
|
this._serviceRegistry.setServices({
|
|
5499
5592
|
SystemService: this._systemService
|
|
@@ -5503,44 +5596,44 @@ var ClientServicesHost = class {
|
|
|
5503
5596
|
await this._level?.close();
|
|
5504
5597
|
this._open = false;
|
|
5505
5598
|
this._statusUpdate.emit();
|
|
5506
|
-
(0,
|
|
5599
|
+
(0, import_log13.log)("closed", {
|
|
5507
5600
|
deviceKey
|
|
5508
5601
|
}, {
|
|
5509
5602
|
F: __dxlog_file18,
|
|
5510
|
-
L:
|
|
5603
|
+
L: 356,
|
|
5511
5604
|
S: this,
|
|
5512
5605
|
C: (f, a) => f(...a)
|
|
5513
5606
|
});
|
|
5514
5607
|
}
|
|
5515
5608
|
async reset() {
|
|
5516
|
-
const traceId =
|
|
5517
|
-
|
|
5609
|
+
const traceId = import_keys11.PublicKey.random().toHex();
|
|
5610
|
+
import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.begin({
|
|
5518
5611
|
id: traceId
|
|
5519
5612
|
}), {
|
|
5520
5613
|
F: __dxlog_file18,
|
|
5521
|
-
L:
|
|
5614
|
+
L: 361,
|
|
5522
5615
|
S: this,
|
|
5523
5616
|
C: (f, a) => f(...a)
|
|
5524
5617
|
});
|
|
5525
|
-
(0,
|
|
5618
|
+
(0, import_log13.log)("resetting...", void 0, {
|
|
5526
5619
|
F: __dxlog_file18,
|
|
5527
|
-
L:
|
|
5620
|
+
L: 363,
|
|
5528
5621
|
S: this,
|
|
5529
5622
|
C: (f, a) => f(...a)
|
|
5530
5623
|
});
|
|
5531
5624
|
await this._serviceContext?.close();
|
|
5532
5625
|
await this._storage.reset();
|
|
5533
|
-
(0,
|
|
5626
|
+
(0, import_log13.log)("reset", void 0, {
|
|
5534
5627
|
F: __dxlog_file18,
|
|
5535
|
-
L:
|
|
5628
|
+
L: 366,
|
|
5536
5629
|
S: this,
|
|
5537
5630
|
C: (f, a) => f(...a)
|
|
5538
5631
|
});
|
|
5539
|
-
|
|
5632
|
+
import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.end({
|
|
5540
5633
|
id: traceId
|
|
5541
5634
|
}), {
|
|
5542
5635
|
F: __dxlog_file18,
|
|
5543
|
-
L:
|
|
5636
|
+
L: 367,
|
|
5544
5637
|
S: this,
|
|
5545
5638
|
C: (f, a) => f(...a)
|
|
5546
5639
|
});
|
|
@@ -5551,9 +5644,9 @@ var ClientServicesHost = class {
|
|
|
5551
5644
|
await this._serviceContext.initialized.wait();
|
|
5552
5645
|
const space = await this._serviceContext.dataSpaceManager.createSpace();
|
|
5553
5646
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5554
|
-
(0,
|
|
5647
|
+
(0, import_invariant15.invariant)(automergeIndex, void 0, {
|
|
5555
5648
|
F: __dxlog_file18,
|
|
5556
|
-
L:
|
|
5649
|
+
L: 379,
|
|
5557
5650
|
S: this,
|
|
5558
5651
|
A: [
|
|
5559
5652
|
"automergeIndex",
|
|
@@ -5564,16 +5657,16 @@ var ClientServicesHost = class {
|
|
|
5564
5657
|
await document.whenReady();
|
|
5565
5658
|
const properties = {
|
|
5566
5659
|
system: {
|
|
5567
|
-
type: (0,
|
|
5660
|
+
type: (0, import_echo_pipeline5.encodeReference)((0, import_echo_schema.getTypeReference)(import_client_protocol4.Properties))
|
|
5568
5661
|
},
|
|
5569
5662
|
data: {
|
|
5570
|
-
[
|
|
5663
|
+
[import_client_protocol4.defaultKey]: identity.identityKey.toHex()
|
|
5571
5664
|
},
|
|
5572
5665
|
meta: {
|
|
5573
5666
|
keys: []
|
|
5574
5667
|
}
|
|
5575
5668
|
};
|
|
5576
|
-
const propertiesId =
|
|
5669
|
+
const propertiesId = import_keys11.PublicKey.random().toHex();
|
|
5577
5670
|
document.change((doc) => {
|
|
5578
5671
|
(0, import_util9.assignDeep)(doc, [
|
|
5579
5672
|
"objects",
|
|
@@ -5585,31 +5678,65 @@ var ClientServicesHost = class {
|
|
|
5585
5678
|
}
|
|
5586
5679
|
};
|
|
5587
5680
|
_ts_decorate8([
|
|
5588
|
-
|
|
5681
|
+
import_tracing8.trace.info()
|
|
5589
5682
|
], ClientServicesHost.prototype, "_opening", void 0);
|
|
5590
5683
|
_ts_decorate8([
|
|
5591
|
-
|
|
5684
|
+
import_tracing8.trace.info()
|
|
5592
5685
|
], ClientServicesHost.prototype, "_open", void 0);
|
|
5593
5686
|
_ts_decorate8([
|
|
5594
5687
|
import_async16.synchronized,
|
|
5595
|
-
|
|
5688
|
+
import_tracing8.trace.span()
|
|
5596
5689
|
], ClientServicesHost.prototype, "open", null);
|
|
5597
5690
|
_ts_decorate8([
|
|
5598
5691
|
import_async16.synchronized,
|
|
5599
|
-
|
|
5692
|
+
import_tracing8.trace.span()
|
|
5600
5693
|
], ClientServicesHost.prototype, "close", null);
|
|
5601
5694
|
ClientServicesHost = _ts_decorate8([
|
|
5602
|
-
|
|
5695
|
+
import_tracing8.trace.resource()
|
|
5603
5696
|
], ClientServicesHost);
|
|
5697
|
+
var ClientServicesProviderResource = Symbol.for("dxos.resource.ClientServices");
|
|
5698
|
+
var DiagnosticsCollector = class {
|
|
5699
|
+
static {
|
|
5700
|
+
this.broadcastSender = createCollectDiagnosticsBroadcastSender();
|
|
5701
|
+
}
|
|
5702
|
+
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
5703
|
+
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
5704
|
+
keys: options.humanize ? import_services13.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services13.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
5705
|
+
});
|
|
5706
|
+
const clientDiagnostics = {
|
|
5707
|
+
config,
|
|
5708
|
+
trace: import_tracing7.TRACE_PROCESSOR.getDiagnostics()
|
|
5709
|
+
};
|
|
5710
|
+
const diagnostics = serviceDiagnostics != null ? {
|
|
5711
|
+
client: clientDiagnostics,
|
|
5712
|
+
services: serviceDiagnostics
|
|
5713
|
+
} : {
|
|
5714
|
+
client: clientDiagnostics,
|
|
5715
|
+
broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
|
|
5716
|
+
};
|
|
5717
|
+
return JSON.parse(JSON.stringify(diagnostics, (0, import_util8.jsonKeyReplacer)(options)));
|
|
5718
|
+
}
|
|
5719
|
+
};
|
|
5720
|
+
var findSystemServiceProvider = () => {
|
|
5721
|
+
const serviceProviders = import_tracing7.TRACE_PROCESSOR.findByAnnotation(ClientServicesProviderResource);
|
|
5722
|
+
const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
|
|
5723
|
+
return providerResource?.instance?.deref() ?? null;
|
|
5724
|
+
};
|
|
5725
|
+
var findConfigs = () => {
|
|
5726
|
+
const configs = import_tracing7.TRACE_PROCESSOR.findByAnnotation(import_config.ConfigResource);
|
|
5727
|
+
return configs.map((r) => r.instance.deref()).filter(import_util8.nonNullable);
|
|
5728
|
+
};
|
|
5604
5729
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5605
5730
|
0 && (module.exports = {
|
|
5606
5731
|
ClientRpcServer,
|
|
5607
5732
|
ClientServicesHost,
|
|
5733
|
+
ClientServicesProviderResource,
|
|
5608
5734
|
DataSpace,
|
|
5609
5735
|
DataSpaceManager,
|
|
5610
5736
|
DeviceInvitationProtocol,
|
|
5611
5737
|
DevtoolsHostEvents,
|
|
5612
5738
|
DevtoolsServiceImpl,
|
|
5739
|
+
DiagnosticsCollector,
|
|
5613
5740
|
Identity,
|
|
5614
5741
|
IdentityManager,
|
|
5615
5742
|
IdentityServiceImpl,
|
|
@@ -5621,12 +5748,14 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5621
5748
|
SpaceInvitationProtocol,
|
|
5622
5749
|
SpacesServiceImpl,
|
|
5623
5750
|
TrustedKeySetAuthVerifier,
|
|
5751
|
+
createAdmissionKeypair,
|
|
5624
5752
|
createAuthProvider,
|
|
5753
|
+
createCollectDiagnosticsBroadcastHandler,
|
|
5754
|
+
createCollectDiagnosticsBroadcastSender,
|
|
5625
5755
|
createDiagnostics,
|
|
5626
5756
|
createLevel,
|
|
5627
5757
|
createStorageObjects,
|
|
5628
5758
|
getNetworkPeers,
|
|
5629
|
-
invitationExpired,
|
|
5630
5759
|
isLocked,
|
|
5631
5760
|
subscribeToFeedBlocks,
|
|
5632
5761
|
subscribeToFeeds,
|
|
@@ -5636,4 +5765,4 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5636
5765
|
subscribeToSpaces,
|
|
5637
5766
|
subscribeToSwarmInfo
|
|
5638
5767
|
});
|
|
5639
|
-
//# sourceMappingURL=chunk-
|
|
5768
|
+
//# sourceMappingURL=chunk-DQMGKBOV.cjs.map
|