@dxos/client-services 0.4.10-main.fa5a270 → 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-7PYX6UUA.mjs → chunk-7S34JE6M.mjs} +980 -656
- package/dist/lib/browser/chunk-7S34JE6M.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +60 -22
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +12 -5
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-4TX623I7.cjs → chunk-DQMGKBOV.cjs} +922 -685
- package/dist/lib/node/chunk-DQMGKBOV.cjs.map +7 -0
- package/dist/lib/node/index.cjs +96 -58
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +16 -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 +3 -2
- 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 +7 -5
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +5 -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/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/index.d.ts +1 -0
- package/dist/types/src/packlets/storage/index.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/level.d.ts +4 -0
- package/dist/types/src/packlets/storage/level.d.ts.map +1 -0
- package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/util.d.ts +4 -0
- package/dist/types/src/packlets/storage/util.d.ts.map +1 -0
- 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 +4 -2
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/shared-worker-connection.d.ts +5 -5
- package/dist/types/src/packlets/vault/shared-worker-connection.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts +2 -0
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts +2 -0
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +36 -34
- package/src/index.ts +1 -0
- package/src/packlets/devices/devices-service.test.ts +1 -1
- 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/identity/identity-service.test.ts +1 -1
- package/src/packlets/indexing/util.ts +6 -6
- package/src/packlets/invitations/device-invitation-protocol.test.ts +1 -1
- 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/network/network-service.test.ts +1 -1
- 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 +9 -6
- package/src/packlets/services/service-context.ts +18 -11
- package/src/packlets/services/service-host.ts +52 -9
- package/src/packlets/services/service-registry.test.ts +1 -1
- package/src/packlets/services/util.ts +2 -0
- package/src/packlets/spaces/data-space-manager.test.ts +4 -4
- package/src/packlets/spaces/data-space.ts +51 -2
- package/src/packlets/spaces/spaces-service.test.ts +1 -1
- package/src/packlets/storage/index.ts +1 -0
- package/src/packlets/storage/level.ts +19 -0
- package/src/packlets/storage/storage.ts +3 -9
- package/src/packlets/storage/util.ts +19 -0
- package/src/packlets/system/system-service.ts +1 -1
- package/src/packlets/testing/test-builder.ts +23 -5
- package/src/packlets/vault/shared-worker-connection.ts +3 -8
- package/src/packlets/vault/worker-runtime.ts +27 -2
- package/src/packlets/vault/worker-session.ts +6 -0
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-7PYX6UUA.mjs.map +0 -7
- package/dist/lib/node/chunk-4TX623I7.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,11 +48,14 @@ __export(chunk_4TX623I7_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,
|
|
56
|
+
createLevel: () => createLevel,
|
|
51
57
|
createStorageObjects: () => createStorageObjects,
|
|
52
58
|
getNetworkPeers: () => getNetworkPeers,
|
|
53
|
-
invitationExpired: () => invitationExpired,
|
|
54
59
|
isLocked: () => isLocked,
|
|
55
60
|
subscribeToFeedBlocks: () => subscribeToFeedBlocks,
|
|
56
61
|
subscribeToFeeds: () => subscribeToFeeds,
|
|
@@ -60,7 +65,7 @@ __export(chunk_4TX623I7_exports, {
|
|
|
60
65
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
61
66
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
62
67
|
});
|
|
63
|
-
module.exports = __toCommonJS(
|
|
68
|
+
module.exports = __toCommonJS(chunk_DQMGKBOV_exports);
|
|
64
69
|
var import_async = require("@dxos/async");
|
|
65
70
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
66
71
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -115,6 +120,7 @@ var import_async7 = require("@dxos/async");
|
|
|
115
120
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
116
121
|
var import_context4 = require("@dxos/context");
|
|
117
122
|
var import_credentials7 = require("@dxos/credentials");
|
|
123
|
+
var import_crypto = require("@dxos/crypto");
|
|
118
124
|
var import_invariant5 = require("@dxos/invariant");
|
|
119
125
|
var import_keys5 = require("@dxos/keys");
|
|
120
126
|
var import_log4 = require("@dxos/log");
|
|
@@ -124,6 +130,7 @@ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
124
130
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
125
131
|
var import_async8 = require("@dxos/async");
|
|
126
132
|
var import_context5 = require("@dxos/context");
|
|
133
|
+
var import_crypto2 = require("@dxos/crypto");
|
|
127
134
|
var import_invariant6 = require("@dxos/invariant");
|
|
128
135
|
var import_keys6 = require("@dxos/keys");
|
|
129
136
|
var import_log5 = require("@dxos/log");
|
|
@@ -134,6 +141,7 @@ var import_teleport = require("@dxos/teleport");
|
|
|
134
141
|
var import_async9 = require("@dxos/async");
|
|
135
142
|
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
136
143
|
var import_context6 = require("@dxos/context");
|
|
144
|
+
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
137
145
|
var import_invariant7 = require("@dxos/invariant");
|
|
138
146
|
var import_log6 = require("@dxos/log");
|
|
139
147
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
@@ -147,115 +155,127 @@ var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
|
147
155
|
var import_debug2 = require("@dxos/debug");
|
|
148
156
|
var import_rpc = require("@dxos/rpc");
|
|
149
157
|
var import_tracing3 = require("@dxos/tracing");
|
|
150
|
-
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
151
|
-
var import_credentials9 = require("@dxos/credentials");
|
|
152
|
-
var import_invariant9 = require("@dxos/invariant");
|
|
153
|
-
var import_protocols7 = require("@dxos/protocols");
|
|
154
|
-
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
155
|
-
var import_tracing4 = require("@dxos/tracing");
|
|
156
|
-
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
157
158
|
var import_async10 = require("@dxos/async");
|
|
158
159
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
159
160
|
var import_context7 = require("@dxos/context");
|
|
160
161
|
var import_debug3 = require("@dxos/debug");
|
|
161
|
-
var
|
|
162
|
-
var
|
|
162
|
+
var import_echo_db = require("@dxos/echo-db");
|
|
163
|
+
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
164
|
+
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
165
|
+
var import_invariant9 = require("@dxos/invariant");
|
|
163
166
|
var import_keys7 = require("@dxos/keys");
|
|
164
167
|
var import_log8 = require("@dxos/log");
|
|
165
|
-
var
|
|
166
|
-
var
|
|
167
|
-
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");
|
|
168
171
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
169
|
-
var
|
|
172
|
+
var import_tracing4 = require("@dxos/tracing");
|
|
170
173
|
var import_util4 = require("@dxos/util");
|
|
171
174
|
var import_async11 = require("@dxos/async");
|
|
172
|
-
var
|
|
175
|
+
var import_credentials10 = require("@dxos/credentials");
|
|
173
176
|
var import_async12 = require("@dxos/async");
|
|
174
177
|
var import_context8 = require("@dxos/context");
|
|
175
|
-
var
|
|
178
|
+
var import_invariant10 = require("@dxos/invariant");
|
|
176
179
|
var import_keys8 = require("@dxos/keys");
|
|
177
180
|
var import_log9 = require("@dxos/log");
|
|
178
|
-
var
|
|
181
|
+
var import_protocols8 = require("@dxos/protocols");
|
|
179
182
|
var import_teleport2 = require("@dxos/teleport");
|
|
180
183
|
var import_util5 = require("@dxos/util");
|
|
181
184
|
var import_async13 = require("@dxos/async");
|
|
182
185
|
var import_context9 = require("@dxos/context");
|
|
183
|
-
var
|
|
184
|
-
var
|
|
186
|
+
var import_credentials11 = require("@dxos/credentials");
|
|
187
|
+
var import_invariant11 = require("@dxos/invariant");
|
|
185
188
|
var import_keys9 = require("@dxos/keys");
|
|
186
189
|
var import_log10 = require("@dxos/log");
|
|
187
|
-
var
|
|
188
|
-
var
|
|
190
|
+
var import_protocols9 = require("@dxos/protocols");
|
|
191
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
189
192
|
var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
|
|
190
193
|
var import_util6 = require("@dxos/util");
|
|
191
|
-
var
|
|
194
|
+
var import_credentials12 = require("@dxos/credentials");
|
|
192
195
|
var import_debug4 = require("@dxos/debug");
|
|
193
|
-
var
|
|
196
|
+
var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
194
197
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
195
198
|
var import_async14 = require("@dxos/async");
|
|
196
|
-
var
|
|
199
|
+
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
197
200
|
var import_debug5 = require("@dxos/debug");
|
|
198
|
-
var
|
|
201
|
+
var import_invariant12 = require("@dxos/invariant");
|
|
199
202
|
var import_log11 = require("@dxos/log");
|
|
200
|
-
var
|
|
201
|
-
var
|
|
203
|
+
var import_protocols10 = require("@dxos/protocols");
|
|
204
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
202
205
|
var import_async15 = require("@dxos/async");
|
|
203
206
|
var import_context10 = require("@dxos/context");
|
|
204
|
-
var
|
|
207
|
+
var import_credentials14 = require("@dxos/credentials");
|
|
205
208
|
var import_debug6 = require("@dxos/debug");
|
|
206
|
-
var
|
|
209
|
+
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
207
210
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
208
211
|
var import_indexing = require("@dxos/indexing");
|
|
209
|
-
var
|
|
212
|
+
var import_invariant13 = require("@dxos/invariant");
|
|
210
213
|
var import_keyring = require("@dxos/keyring");
|
|
211
214
|
var import_keys10 = require("@dxos/keys");
|
|
212
215
|
var import_log12 = require("@dxos/log");
|
|
213
|
-
var
|
|
214
|
-
var
|
|
216
|
+
var import_protocols11 = require("@dxos/protocols");
|
|
217
|
+
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
215
218
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
216
|
-
var
|
|
219
|
+
var import_tracing5 = require("@dxos/tracing");
|
|
217
220
|
var import_util7 = require("@dxos/util");
|
|
218
221
|
var import_automerge = require("@dxos/automerge/automerge");
|
|
219
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");
|
|
220
227
|
var import_protocols13 = require("@dxos/protocols");
|
|
221
|
-
var
|
|
222
|
-
var
|
|
223
|
-
var
|
|
224
|
-
var
|
|
225
|
-
var
|
|
226
|
-
var
|
|
227
|
-
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
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");
|
|
228
234
|
var import_util8 = require("@dxos/util");
|
|
229
235
|
var import_async16 = require("@dxos/async");
|
|
230
|
-
var
|
|
236
|
+
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
231
237
|
var import_context11 = require("@dxos/context");
|
|
232
|
-
var
|
|
238
|
+
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
233
239
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
234
240
|
var import_indexing2 = require("@dxos/indexing");
|
|
235
|
-
var
|
|
241
|
+
var import_invariant15 = require("@dxos/invariant");
|
|
236
242
|
var import_keys11 = require("@dxos/keys");
|
|
237
|
-
var
|
|
243
|
+
var import_log13 = require("@dxos/log");
|
|
238
244
|
var import_messaging = require("@dxos/messaging");
|
|
239
245
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
240
|
-
var
|
|
241
|
-
var
|
|
242
|
-
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");
|
|
243
249
|
var import_util9 = require("@dxos/util");
|
|
244
250
|
var import_websocket_rpc = require("@dxos/websocket-rpc");
|
|
245
251
|
var import_async17 = require("@dxos/async");
|
|
246
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");
|
|
247
255
|
var import_invariant17 = require("@dxos/invariant");
|
|
248
|
-
var
|
|
256
|
+
var import_lock_file = require("@dxos/lock-file");
|
|
257
|
+
var import_log14 = require("@dxos/log");
|
|
249
258
|
var import_async18 = require("@dxos/async");
|
|
250
259
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
251
260
|
var import_keys12 = require("@dxos/keys");
|
|
252
261
|
var import_log15 = require("@dxos/log");
|
|
253
|
-
var
|
|
262
|
+
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
254
263
|
var import_util10 = require("@dxos/util");
|
|
255
264
|
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
256
|
-
var
|
|
257
|
-
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");
|
|
258
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");
|
|
259
279
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
260
280
|
return new import_codec_protobuf.Stream(({ next }) => {
|
|
261
281
|
const subscriptions = new import_async.EventSubscriptions();
|
|
@@ -1468,6 +1488,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1468
1488
|
this._callbacks = _callbacks;
|
|
1469
1489
|
this._ctx = new import_context5.Context();
|
|
1470
1490
|
this._remoteOptionsTrigger = new import_async8.Trigger();
|
|
1491
|
+
this._challenge = void 0;
|
|
1471
1492
|
this.invitation = void 0;
|
|
1472
1493
|
this.guestProfile = void 0;
|
|
1473
1494
|
this.authenticationPassed = false;
|
|
@@ -1482,7 +1503,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1482
1503
|
options: async (options) => {
|
|
1483
1504
|
(0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1484
1505
|
F: __dxlog_file6,
|
|
1485
|
-
L:
|
|
1506
|
+
L: 90,
|
|
1486
1507
|
S: this,
|
|
1487
1508
|
A: [
|
|
1488
1509
|
"!this._remoteOptions",
|
|
@@ -1499,7 +1520,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1499
1520
|
id: traceId
|
|
1500
1521
|
}), {
|
|
1501
1522
|
F: __dxlog_file6,
|
|
1502
|
-
L:
|
|
1523
|
+
L: 99,
|
|
1503
1524
|
S: this,
|
|
1504
1525
|
C: (f, a) => f(...a)
|
|
1505
1526
|
});
|
|
@@ -1509,7 +1530,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1509
1530
|
invitationId
|
|
1510
1531
|
}, {
|
|
1511
1532
|
F: __dxlog_file6,
|
|
1512
|
-
L:
|
|
1533
|
+
L: 103,
|
|
1513
1534
|
S: this,
|
|
1514
1535
|
C: (f, a) => f(...a)
|
|
1515
1536
|
});
|
|
@@ -1523,7 +1544,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1523
1544
|
guestProfile: profile
|
|
1524
1545
|
}, {
|
|
1525
1546
|
F: __dxlog_file6,
|
|
1526
|
-
L:
|
|
1547
|
+
L: 112,
|
|
1527
1548
|
S: this,
|
|
1528
1549
|
C: (f, a) => f(...a)
|
|
1529
1550
|
});
|
|
@@ -1532,25 +1553,27 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1532
1553
|
...this.invitation,
|
|
1533
1554
|
state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1534
1555
|
});
|
|
1556
|
+
this._challenge = this.invitation.authMethod === import_services4.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto2.randomBytes)(32) : void 0;
|
|
1535
1557
|
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols5.trace.end({
|
|
1536
1558
|
id: traceId
|
|
1537
1559
|
}), {
|
|
1538
1560
|
F: __dxlog_file6,
|
|
1539
|
-
L:
|
|
1561
|
+
L: 122,
|
|
1540
1562
|
S: this,
|
|
1541
1563
|
C: (f, a) => f(...a)
|
|
1542
1564
|
});
|
|
1543
1565
|
return {
|
|
1544
|
-
authMethod: this.invitation.authMethod
|
|
1566
|
+
authMethod: this.invitation.authMethod,
|
|
1567
|
+
challenge: this._challenge
|
|
1545
1568
|
};
|
|
1546
1569
|
},
|
|
1547
|
-
authenticate: async ({ authCode: code }) => {
|
|
1570
|
+
authenticate: async ({ authCode: code, signedChallenge }) => {
|
|
1548
1571
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
1549
1572
|
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols5.trace.begin({
|
|
1550
1573
|
id: traceId
|
|
1551
1574
|
}), {
|
|
1552
1575
|
F: __dxlog_file6,
|
|
1553
|
-
L:
|
|
1576
|
+
L: 131,
|
|
1554
1577
|
S: this,
|
|
1555
1578
|
C: (f, a) => f(...a)
|
|
1556
1579
|
});
|
|
@@ -1558,14 +1581,14 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1558
1581
|
authCode: code
|
|
1559
1582
|
}, {
|
|
1560
1583
|
F: __dxlog_file6,
|
|
1561
|
-
L:
|
|
1584
|
+
L: 132,
|
|
1562
1585
|
S: this,
|
|
1563
1586
|
C: (f, a) => f(...a)
|
|
1564
1587
|
});
|
|
1565
1588
|
let status = import_invitations2.AuthenticationResponse.Status.OK;
|
|
1566
1589
|
(0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
|
|
1567
1590
|
F: __dxlog_file6,
|
|
1568
|
-
L:
|
|
1591
|
+
L: 135,
|
|
1569
1592
|
S: this,
|
|
1570
1593
|
A: [
|
|
1571
1594
|
"this.invitation",
|
|
@@ -1576,7 +1599,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1576
1599
|
case import_services4.Invitation.AuthMethod.NONE: {
|
|
1577
1600
|
(0, import_log5.log)("authentication not required", void 0, {
|
|
1578
1601
|
F: __dxlog_file6,
|
|
1579
|
-
L:
|
|
1602
|
+
L: 138,
|
|
1580
1603
|
S: this,
|
|
1581
1604
|
C: (f, a) => f(...a)
|
|
1582
1605
|
});
|
|
@@ -1596,12 +1619,25 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1596
1619
|
}
|
|
1597
1620
|
break;
|
|
1598
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
|
+
}
|
|
1599
1635
|
default: {
|
|
1600
1636
|
import_log5.log.error("invalid authentication method", {
|
|
1601
1637
|
authMethod: this.invitation.authMethod
|
|
1602
1638
|
}, {
|
|
1603
1639
|
F: __dxlog_file6,
|
|
1604
|
-
L:
|
|
1640
|
+
L: 176,
|
|
1605
1641
|
S: this,
|
|
1606
1642
|
C: (f, a) => f(...a)
|
|
1607
1643
|
});
|
|
@@ -1616,7 +1652,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1616
1652
|
}
|
|
1617
1653
|
}), {
|
|
1618
1654
|
F: __dxlog_file6,
|
|
1619
|
-
L:
|
|
1655
|
+
L: 182,
|
|
1620
1656
|
S: this,
|
|
1621
1657
|
C: (f, a) => f(...a)
|
|
1622
1658
|
});
|
|
@@ -1630,14 +1666,14 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1630
1666
|
id: traceId
|
|
1631
1667
|
}), {
|
|
1632
1668
|
F: __dxlog_file6,
|
|
1633
|
-
L:
|
|
1669
|
+
L: 188,
|
|
1634
1670
|
S: this,
|
|
1635
1671
|
C: (f, a) => f(...a)
|
|
1636
1672
|
});
|
|
1637
1673
|
try {
|
|
1638
1674
|
(0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
|
|
1639
1675
|
F: __dxlog_file6,
|
|
1640
|
-
L:
|
|
1676
|
+
L: 191,
|
|
1641
1677
|
S: this,
|
|
1642
1678
|
A: [
|
|
1643
1679
|
"this.invitation",
|
|
@@ -1652,7 +1688,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1652
1688
|
id: traceId
|
|
1653
1689
|
}), {
|
|
1654
1690
|
F: __dxlog_file6,
|
|
1655
|
-
L:
|
|
1691
|
+
L: 199,
|
|
1656
1692
|
S: this,
|
|
1657
1693
|
C: (f, a) => f(...a)
|
|
1658
1694
|
});
|
|
@@ -1709,7 +1745,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1709
1745
|
options: async (options) => {
|
|
1710
1746
|
(0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1711
1747
|
F: __dxlog_file6,
|
|
1712
|
-
L:
|
|
1748
|
+
L: 266,
|
|
1713
1749
|
S: this,
|
|
1714
1750
|
A: [
|
|
1715
1751
|
"!this._remoteOptions",
|
|
@@ -1736,7 +1772,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1736
1772
|
try {
|
|
1737
1773
|
(0, import_log5.log)("begin options", void 0, {
|
|
1738
1774
|
F: __dxlog_file6,
|
|
1739
|
-
L:
|
|
1775
|
+
L: 287,
|
|
1740
1776
|
S: this,
|
|
1741
1777
|
C: (f, a) => f(...a)
|
|
1742
1778
|
});
|
|
@@ -1748,7 +1784,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1748
1784
|
}));
|
|
1749
1785
|
(0, import_log5.log)("end options", void 0, {
|
|
1750
1786
|
F: __dxlog_file6,
|
|
1751
|
-
L:
|
|
1787
|
+
L: 290,
|
|
1752
1788
|
S: this,
|
|
1753
1789
|
C: (f, a) => f(...a)
|
|
1754
1790
|
});
|
|
@@ -1762,7 +1798,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1762
1798
|
} catch (err) {
|
|
1763
1799
|
(0, import_log5.log)("openError", err, {
|
|
1764
1800
|
F: __dxlog_file6,
|
|
1765
|
-
L:
|
|
1801
|
+
L: 300,
|
|
1766
1802
|
S: this,
|
|
1767
1803
|
C: (f, a) => f(...a)
|
|
1768
1804
|
});
|
|
@@ -1772,7 +1808,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1772
1808
|
async onClose() {
|
|
1773
1809
|
(0, import_log5.log)("onClose", void 0, {
|
|
1774
1810
|
F: __dxlog_file6,
|
|
1775
|
-
L:
|
|
1811
|
+
L: 306,
|
|
1776
1812
|
S: this,
|
|
1777
1813
|
C: (f, a) => f(...a)
|
|
1778
1814
|
});
|
|
@@ -1789,11 +1825,11 @@ var InvitationsHandler = class {
|
|
|
1789
1825
|
this._networkManager = _networkManager;
|
|
1790
1826
|
}
|
|
1791
1827
|
createInvitation(protocol, options) {
|
|
1792
|
-
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 ?? {};
|
|
1793
1829
|
const authCode = options?.authCode ?? (authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1794
1830
|
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
1795
1831
|
F: __dxlog_file7,
|
|
1796
|
-
L:
|
|
1832
|
+
L: 87,
|
|
1797
1833
|
S: this,
|
|
1798
1834
|
A: [
|
|
1799
1835
|
"protocol",
|
|
@@ -1808,9 +1844,11 @@ var InvitationsHandler = class {
|
|
|
1808
1844
|
swarmKey,
|
|
1809
1845
|
authCode,
|
|
1810
1846
|
timeout,
|
|
1811
|
-
persistent,
|
|
1847
|
+
persistent: persistent && type !== import_services3.Invitation.Type.DELEGATED,
|
|
1848
|
+
guestKeypair: guestKeypair ?? (authMethod === import_services3.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
|
|
1812
1849
|
created,
|
|
1813
1850
|
lifetime,
|
|
1851
|
+
multiUse,
|
|
1814
1852
|
...protocol.getInvitationContext()
|
|
1815
1853
|
};
|
|
1816
1854
|
const stream = new import_async7.PushStream();
|
|
@@ -1825,7 +1863,7 @@ var InvitationsHandler = class {
|
|
|
1825
1863
|
...protocol.toJSON()
|
|
1826
1864
|
}, {
|
|
1827
1865
|
F: __dxlog_file7,
|
|
1828
|
-
L:
|
|
1866
|
+
L: 115,
|
|
1829
1867
|
S: this,
|
|
1830
1868
|
C: (f, a) => f(...a)
|
|
1831
1869
|
});
|
|
@@ -1850,7 +1888,7 @@ var InvitationsHandler = class {
|
|
|
1850
1888
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1851
1889
|
(0, import_invariant5.invariant)(deviceKey, void 0, {
|
|
1852
1890
|
F: __dxlog_file7,
|
|
1853
|
-
L:
|
|
1891
|
+
L: 136,
|
|
1854
1892
|
S: this,
|
|
1855
1893
|
A: [
|
|
1856
1894
|
"deviceKey",
|
|
@@ -1873,7 +1911,7 @@ var InvitationsHandler = class {
|
|
|
1873
1911
|
id: traceId
|
|
1874
1912
|
}), {
|
|
1875
1913
|
F: __dxlog_file7,
|
|
1876
|
-
L:
|
|
1914
|
+
L: 154,
|
|
1877
1915
|
S: this,
|
|
1878
1916
|
C: (f, a) => f(...a)
|
|
1879
1917
|
});
|
|
@@ -1881,7 +1919,7 @@ var InvitationsHandler = class {
|
|
|
1881
1919
|
...protocol.toJSON()
|
|
1882
1920
|
}, {
|
|
1883
1921
|
F: __dxlog_file7,
|
|
1884
|
-
L:
|
|
1922
|
+
L: 155,
|
|
1885
1923
|
S: this,
|
|
1886
1924
|
C: (f, a) => f(...a)
|
|
1887
1925
|
});
|
|
@@ -1897,7 +1935,7 @@ var InvitationsHandler = class {
|
|
|
1897
1935
|
...protocol.toJSON()
|
|
1898
1936
|
}, {
|
|
1899
1937
|
F: __dxlog_file7,
|
|
1900
|
-
L:
|
|
1938
|
+
L: 158,
|
|
1901
1939
|
S: this,
|
|
1902
1940
|
C: (f, a) => f(...a)
|
|
1903
1941
|
});
|
|
@@ -1909,7 +1947,7 @@ var InvitationsHandler = class {
|
|
|
1909
1947
|
id: traceId
|
|
1910
1948
|
}), {
|
|
1911
1949
|
F: __dxlog_file7,
|
|
1912
|
-
L:
|
|
1950
|
+
L: 160,
|
|
1913
1951
|
S: this,
|
|
1914
1952
|
C: (f, a) => f(...a)
|
|
1915
1953
|
});
|
|
@@ -1919,7 +1957,7 @@ var InvitationsHandler = class {
|
|
|
1919
1957
|
...protocol.toJSON()
|
|
1920
1958
|
}, {
|
|
1921
1959
|
F: __dxlog_file7,
|
|
1922
|
-
L:
|
|
1960
|
+
L: 163,
|
|
1923
1961
|
S: this,
|
|
1924
1962
|
C: (f, a) => f(...a)
|
|
1925
1963
|
});
|
|
@@ -1930,7 +1968,7 @@ var InvitationsHandler = class {
|
|
|
1930
1968
|
} else {
|
|
1931
1969
|
import_log4.log.error("failed", err, {
|
|
1932
1970
|
F: __dxlog_file7,
|
|
1933
|
-
L:
|
|
1971
|
+
L: 166,
|
|
1934
1972
|
S: this,
|
|
1935
1973
|
C: (f, a) => f(...a)
|
|
1936
1974
|
});
|
|
@@ -1941,12 +1979,12 @@ var InvitationsHandler = class {
|
|
|
1941
1979
|
error: err
|
|
1942
1980
|
}), {
|
|
1943
1981
|
F: __dxlog_file7,
|
|
1944
|
-
L:
|
|
1982
|
+
L: 169,
|
|
1945
1983
|
S: this,
|
|
1946
1984
|
C: (f, a) => f(...a)
|
|
1947
1985
|
});
|
|
1948
1986
|
} finally {
|
|
1949
|
-
if (
|
|
1987
|
+
if (!multiUse) {
|
|
1950
1988
|
await swarmConnection.close();
|
|
1951
1989
|
await ctx.dispose();
|
|
1952
1990
|
}
|
|
@@ -1962,7 +2000,7 @@ var InvitationsHandler = class {
|
|
|
1962
2000
|
...protocol.toJSON()
|
|
1963
2001
|
}, {
|
|
1964
2002
|
F: __dxlog_file7,
|
|
1965
|
-
L:
|
|
2003
|
+
L: 184,
|
|
1966
2004
|
S: this,
|
|
1967
2005
|
C: (f, a) => f(...a)
|
|
1968
2006
|
});
|
|
@@ -1973,7 +2011,7 @@ var InvitationsHandler = class {
|
|
|
1973
2011
|
} else {
|
|
1974
2012
|
import_log4.log.error("failed", err, {
|
|
1975
2013
|
F: __dxlog_file7,
|
|
1976
|
-
L:
|
|
2014
|
+
L: 187,
|
|
1977
2015
|
S: this,
|
|
1978
2016
|
C: (f, a) => f(...a)
|
|
1979
2017
|
});
|
|
@@ -1987,7 +2025,7 @@ var InvitationsHandler = class {
|
|
|
1987
2025
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
1988
2026
|
import_log4.log.warn("invitation has already expired", void 0, {
|
|
1989
2027
|
F: __dxlog_file7,
|
|
1990
|
-
L:
|
|
2028
|
+
L: 198,
|
|
1991
2029
|
S: this,
|
|
1992
2030
|
C: (f, a) => f(...a)
|
|
1993
2031
|
});
|
|
@@ -2038,7 +2076,7 @@ var InvitationsHandler = class {
|
|
|
2038
2076
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
2039
2077
|
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
2040
2078
|
F: __dxlog_file7,
|
|
2041
|
-
L:
|
|
2079
|
+
L: 252,
|
|
2042
2080
|
S: this,
|
|
2043
2081
|
A: [
|
|
2044
2082
|
"protocol",
|
|
@@ -2048,7 +2086,7 @@ var InvitationsHandler = class {
|
|
|
2048
2086
|
if (deviceProfile) {
|
|
2049
2087
|
(0, import_invariant5.invariant)(invitation.kind === import_services3.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2050
2088
|
F: __dxlog_file7,
|
|
2051
|
-
L:
|
|
2089
|
+
L: 256,
|
|
2052
2090
|
S: this,
|
|
2053
2091
|
A: [
|
|
2054
2092
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -2063,7 +2101,7 @@ var InvitationsHandler = class {
|
|
|
2063
2101
|
const setState = (newData) => {
|
|
2064
2102
|
(0, import_invariant5.invariant)(newData.state !== void 0, void 0, {
|
|
2065
2103
|
F: __dxlog_file7,
|
|
2066
|
-
L:
|
|
2104
|
+
L: 267,
|
|
2067
2105
|
S: this,
|
|
2068
2106
|
A: [
|
|
2069
2107
|
"newData.state !== undefined",
|
|
@@ -2083,7 +2121,7 @@ var InvitationsHandler = class {
|
|
|
2083
2121
|
...protocol.toJSON()
|
|
2084
2122
|
}, {
|
|
2085
2123
|
F: __dxlog_file7,
|
|
2086
|
-
L:
|
|
2124
|
+
L: 275,
|
|
2087
2125
|
S: this,
|
|
2088
2126
|
C: (f, a) => f(...a)
|
|
2089
2127
|
});
|
|
@@ -2093,7 +2131,7 @@ var InvitationsHandler = class {
|
|
|
2093
2131
|
} else {
|
|
2094
2132
|
import_log4.log.warn("auth failed", err, {
|
|
2095
2133
|
F: __dxlog_file7,
|
|
2096
|
-
L:
|
|
2134
|
+
L: 278,
|
|
2097
2135
|
S: this,
|
|
2098
2136
|
C: (f, a) => f(...a)
|
|
2099
2137
|
});
|
|
@@ -2107,7 +2145,7 @@ var InvitationsHandler = class {
|
|
|
2107
2145
|
...protocol.toJSON()
|
|
2108
2146
|
}, {
|
|
2109
2147
|
F: __dxlog_file7,
|
|
2110
|
-
L:
|
|
2148
|
+
L: 286,
|
|
2111
2149
|
S: this,
|
|
2112
2150
|
C: (f, a) => f(...a)
|
|
2113
2151
|
});
|
|
@@ -2122,7 +2160,7 @@ var InvitationsHandler = class {
|
|
|
2122
2160
|
currentState
|
|
2123
2161
|
}, {
|
|
2124
2162
|
F: __dxlog_file7,
|
|
2125
|
-
L:
|
|
2163
|
+
L: 296,
|
|
2126
2164
|
S: this,
|
|
2127
2165
|
C: (f, a) => f(...a)
|
|
2128
2166
|
});
|
|
@@ -2137,7 +2175,7 @@ var InvitationsHandler = class {
|
|
|
2137
2175
|
id: traceId
|
|
2138
2176
|
}), {
|
|
2139
2177
|
F: __dxlog_file7,
|
|
2140
|
-
L:
|
|
2178
|
+
L: 305,
|
|
2141
2179
|
S: this,
|
|
2142
2180
|
C: (f, a) => f(...a)
|
|
2143
2181
|
});
|
|
@@ -2149,7 +2187,7 @@ var InvitationsHandler = class {
|
|
|
2149
2187
|
...protocol.toJSON()
|
|
2150
2188
|
}, {
|
|
2151
2189
|
F: __dxlog_file7,
|
|
2152
|
-
L:
|
|
2190
|
+
L: 313,
|
|
2153
2191
|
S: this,
|
|
2154
2192
|
C: (f, a) => f(...a)
|
|
2155
2193
|
});
|
|
@@ -2160,7 +2198,7 @@ var InvitationsHandler = class {
|
|
|
2160
2198
|
...protocol.toJSON()
|
|
2161
2199
|
}, {
|
|
2162
2200
|
F: __dxlog_file7,
|
|
2163
|
-
L:
|
|
2201
|
+
L: 317,
|
|
2164
2202
|
S: this,
|
|
2165
2203
|
C: (f, a) => f(...a)
|
|
2166
2204
|
});
|
|
@@ -2170,62 +2208,28 @@ var InvitationsHandler = class {
|
|
|
2170
2208
|
response: introductionResponse
|
|
2171
2209
|
}, {
|
|
2172
2210
|
F: __dxlog_file7,
|
|
2173
|
-
L:
|
|
2211
|
+
L: 321,
|
|
2174
2212
|
S: this,
|
|
2175
2213
|
C: (f, a) => f(...a)
|
|
2176
2214
|
});
|
|
2177
2215
|
invitation.authMethod = introductionResponse.authMethod;
|
|
2178
2216
|
if (isAuthenticationRequired(invitation)) {
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
2188
|
-
});
|
|
2189
|
-
const authCode = await authenticated.wait({
|
|
2190
|
-
timeout
|
|
2191
|
-
});
|
|
2192
|
-
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2193
|
-
F: __dxlog_file7,
|
|
2194
|
-
L: 325,
|
|
2195
|
-
S: this,
|
|
2196
|
-
C: (f, a) => f(...a)
|
|
2197
|
-
});
|
|
2198
|
-
setState({
|
|
2199
|
-
state: import_services3.Invitation.State.AUTHENTICATING
|
|
2200
|
-
});
|
|
2201
|
-
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2202
|
-
authCode
|
|
2203
|
-
});
|
|
2204
|
-
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);
|
|
2205
2225
|
break;
|
|
2206
|
-
}
|
|
2207
|
-
if (response.status === import_invitations.AuthenticationResponse.Status.INVALID_OTP) {
|
|
2208
|
-
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2209
|
-
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2210
|
-
} else {
|
|
2211
|
-
(0, import_log4.log)("retrying invalid code", {
|
|
2212
|
-
attempt
|
|
2213
|
-
}, {
|
|
2214
|
-
F: __dxlog_file7,
|
|
2215
|
-
L: 336,
|
|
2216
|
-
S: this,
|
|
2217
|
-
C: (f, a) => f(...a)
|
|
2218
|
-
});
|
|
2219
|
-
authenticated.reset();
|
|
2220
|
-
}
|
|
2221
|
-
}
|
|
2222
2226
|
}
|
|
2223
2227
|
}
|
|
2224
2228
|
(0, import_log4.log)("request admission", {
|
|
2225
2229
|
...protocol.toJSON()
|
|
2226
2230
|
}, {
|
|
2227
2231
|
F: __dxlog_file7,
|
|
2228
|
-
L:
|
|
2232
|
+
L: 337,
|
|
2229
2233
|
S: this,
|
|
2230
2234
|
C: (f, a) => f(...a)
|
|
2231
2235
|
});
|
|
@@ -2237,7 +2241,7 @@ var InvitationsHandler = class {
|
|
|
2237
2241
|
...protocol.toJSON()
|
|
2238
2242
|
}, {
|
|
2239
2243
|
F: __dxlog_file7,
|
|
2240
|
-
L:
|
|
2244
|
+
L: 348,
|
|
2241
2245
|
S: this,
|
|
2242
2246
|
C: (f, a) => f(...a)
|
|
2243
2247
|
});
|
|
@@ -2250,7 +2254,7 @@ var InvitationsHandler = class {
|
|
|
2250
2254
|
id: traceId
|
|
2251
2255
|
}), {
|
|
2252
2256
|
F: __dxlog_file7,
|
|
2253
|
-
L:
|
|
2257
|
+
L: 350,
|
|
2254
2258
|
S: this,
|
|
2255
2259
|
C: (f, a) => f(...a)
|
|
2256
2260
|
});
|
|
@@ -2260,7 +2264,7 @@ var InvitationsHandler = class {
|
|
|
2260
2264
|
...protocol.toJSON()
|
|
2261
2265
|
}, {
|
|
2262
2266
|
F: __dxlog_file7,
|
|
2263
|
-
L:
|
|
2267
|
+
L: 353,
|
|
2264
2268
|
S: this,
|
|
2265
2269
|
C: (f, a) => f(...a)
|
|
2266
2270
|
});
|
|
@@ -2270,7 +2274,7 @@ var InvitationsHandler = class {
|
|
|
2270
2274
|
} else {
|
|
2271
2275
|
(0, import_log4.log)("auth failed", err, {
|
|
2272
2276
|
F: __dxlog_file7,
|
|
2273
|
-
L:
|
|
2277
|
+
L: 356,
|
|
2274
2278
|
S: this,
|
|
2275
2279
|
C: (f, a) => f(...a)
|
|
2276
2280
|
});
|
|
@@ -2281,7 +2285,7 @@ var InvitationsHandler = class {
|
|
|
2281
2285
|
error: err
|
|
2282
2286
|
}), {
|
|
2283
2287
|
F: __dxlog_file7,
|
|
2284
|
-
L:
|
|
2288
|
+
L: 359,
|
|
2285
2289
|
S: this,
|
|
2286
2290
|
C: (f, a) => f(...a)
|
|
2287
2291
|
});
|
|
@@ -2299,7 +2303,7 @@ var InvitationsHandler = class {
|
|
|
2299
2303
|
...protocol.toJSON()
|
|
2300
2304
|
}, {
|
|
2301
2305
|
F: __dxlog_file7,
|
|
2302
|
-
L:
|
|
2306
|
+
L: 370,
|
|
2303
2307
|
S: this,
|
|
2304
2308
|
C: (f, a) => f(...a)
|
|
2305
2309
|
});
|
|
@@ -2309,7 +2313,7 @@ var InvitationsHandler = class {
|
|
|
2309
2313
|
} else {
|
|
2310
2314
|
(0, import_log4.log)("auth failed", err, {
|
|
2311
2315
|
F: __dxlog_file7,
|
|
2312
|
-
L:
|
|
2316
|
+
L: 373,
|
|
2313
2317
|
S: this,
|
|
2314
2318
|
C: (f, a) => f(...a)
|
|
2315
2319
|
});
|
|
@@ -2326,7 +2330,7 @@ var InvitationsHandler = class {
|
|
|
2326
2330
|
} else {
|
|
2327
2331
|
(0, import_invariant5.invariant)(invitation.swarmKey, void 0, {
|
|
2328
2332
|
F: __dxlog_file7,
|
|
2329
|
-
L:
|
|
2333
|
+
L: 387,
|
|
2330
2334
|
S: this,
|
|
2331
2335
|
A: [
|
|
2332
2336
|
"invitation.swarmKey",
|
|
@@ -2364,9 +2368,81 @@ var InvitationsHandler = class {
|
|
|
2364
2368
|
});
|
|
2365
2369
|
return observable;
|
|
2366
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
|
+
}
|
|
2367
2439
|
};
|
|
2368
|
-
var
|
|
2369
|
-
|
|
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
|
+
};
|
|
2370
2446
|
};
|
|
2371
2447
|
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
2372
2448
|
var InvitationsServiceImpl = class {
|
|
@@ -2423,7 +2499,7 @@ var InvitationsServiceImpl = class {
|
|
|
2423
2499
|
await this._metadataStore.removeInvitation(invitation.get().invitationId);
|
|
2424
2500
|
}
|
|
2425
2501
|
this._createInvitations.delete(invitation.get().invitationId);
|
|
2426
|
-
if (invitation.get().
|
|
2502
|
+
if (!invitation.get().multiUse) {
|
|
2427
2503
|
this._removedCreated.emit(invitation.get());
|
|
2428
2504
|
}
|
|
2429
2505
|
});
|
|
@@ -2431,7 +2507,7 @@ var InvitationsServiceImpl = class {
|
|
|
2431
2507
|
}
|
|
2432
2508
|
async loadPersistentInvitations() {
|
|
2433
2509
|
const persistentInvitations = this._metadataStore.getInvitations();
|
|
2434
|
-
const freshInvitations = persistentInvitations.filter(async (invitation) => !
|
|
2510
|
+
const freshInvitations = persistentInvitations.filter(async (invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
|
|
2435
2511
|
const cInvitations = freshInvitations.map((persistentInvitation) => {
|
|
2436
2512
|
(0, import_invariant7.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2437
2513
|
F: __dxlog_file8,
|
|
@@ -2484,7 +2560,7 @@ var InvitationsServiceImpl = class {
|
|
|
2484
2560
|
}, () => {
|
|
2485
2561
|
close();
|
|
2486
2562
|
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2487
|
-
if (invitation.get().
|
|
2563
|
+
if (!invitation.get().multiUse) {
|
|
2488
2564
|
this._removedAccepted.emit(invitation.get());
|
|
2489
2565
|
}
|
|
2490
2566
|
});
|
|
@@ -2857,176 +2933,41 @@ _ts_decorate3([
|
|
|
2857
2933
|
ClientRpcServer = _ts_decorate3([
|
|
2858
2934
|
import_tracing3.trace.resource()
|
|
2859
2935
|
], ClientRpcServer);
|
|
2860
|
-
var
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
2868
|
-
};
|
|
2869
|
-
} else {
|
|
2870
|
-
return {
|
|
2871
|
-
type: import_services8.Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
2872
|
-
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
2873
|
-
};
|
|
2874
|
-
}
|
|
2875
|
-
} else {
|
|
2876
|
-
const { platform: platform2, version, arch } = process;
|
|
2877
|
-
return {
|
|
2878
|
-
type: import_services8.Platform.PLATFORM_TYPE.NODE,
|
|
2879
|
-
platform: platform2,
|
|
2880
|
-
arch,
|
|
2881
|
-
runtime: version,
|
|
2882
|
-
uptime: Math.floor(process.uptime()),
|
|
2883
|
-
memory: process.memoryUsage()
|
|
2884
|
-
};
|
|
2885
|
-
}
|
|
2886
|
-
};
|
|
2887
|
-
var DXOS_VERSION = "0.4.10-main.fa5a270";
|
|
2888
|
-
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
2889
|
-
var DEFAULT_TIMEOUT = 1e3;
|
|
2890
|
-
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
2891
|
-
const diagnostics = {
|
|
2892
|
-
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2893
|
-
platform: getPlatform(),
|
|
2894
|
-
client: {
|
|
2895
|
-
version: DXOS_VERSION,
|
|
2896
|
-
storage: {
|
|
2897
|
-
version: import_protocols7.STORAGE_VERSION
|
|
2898
|
-
}
|
|
2899
|
-
},
|
|
2900
|
-
trace: import_tracing4.TRACE_PROCESSOR.getDiagnostics()
|
|
2901
|
-
};
|
|
2902
|
-
{
|
|
2903
|
-
(0, import_invariant9.invariant)(clientServices.LoggingService, "SystemService is not available.", {
|
|
2904
|
-
F: __dxlog_file10,
|
|
2905
|
-
L: 108,
|
|
2906
|
-
S: void 0,
|
|
2907
|
-
A: [
|
|
2908
|
-
"clientServices.LoggingService",
|
|
2909
|
-
"'SystemService is not available.'"
|
|
2910
|
-
]
|
|
2911
|
-
});
|
|
2912
|
-
diagnostics.metrics = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
|
|
2913
|
-
timeout: DEFAULT_TIMEOUT
|
|
2914
|
-
}).catch(() => void 0);
|
|
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;
|
|
2915
2943
|
}
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2944
|
+
async processCredential(credential) {
|
|
2945
|
+
if (!(0, import_credentials10.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
2946
|
+
return;
|
|
2947
|
+
}
|
|
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);
|
|
2923
2953
|
}
|
|
2924
|
-
map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
|
|
2925
2954
|
}
|
|
2926
|
-
|
|
2927
|
-
file,
|
|
2928
|
-
count
|
|
2929
|
-
}));
|
|
2955
|
+
this.onNewEpoch.emit(credential);
|
|
2930
2956
|
}
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
identityKey: identity.identityKey,
|
|
2935
|
-
spaceKey: identity.space.key,
|
|
2936
|
-
profile: identity.profileDocument
|
|
2937
|
-
};
|
|
2938
|
-
const { devices } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
|
|
2939
|
-
timeout: DEFAULT_TIMEOUT
|
|
2940
|
-
}).catch(() => void 0) ?? {};
|
|
2941
|
-
diagnostics.devices = devices;
|
|
2942
|
-
if (serviceContext.dataSpaceManager) {
|
|
2943
|
-
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
2957
|
+
startProcessingRootDocs() {
|
|
2958
|
+
if (this._isProcessingRootDocs) {
|
|
2959
|
+
return;
|
|
2944
2960
|
}
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
}
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
}));
|
|
2953
|
-
const status = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
|
|
2954
|
-
timeout: DEFAULT_TIMEOUT
|
|
2955
|
-
}).catch(() => void 0);
|
|
2956
|
-
diagnostics.networkStatus = status;
|
|
2957
|
-
diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
|
|
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);
|
|
2958
2968
|
}
|
|
2959
|
-
diagnostics.config = config.values;
|
|
2960
|
-
return diagnostics;
|
|
2961
2969
|
};
|
|
2962
|
-
var
|
|
2963
|
-
const stats = {
|
|
2964
|
-
key: space.key,
|
|
2965
|
-
metrics: space.metrics,
|
|
2966
|
-
epochs: space.inner.spaceState.credentials.filter((0, import_credentials9.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
2967
|
-
...credential.subject.assertion,
|
|
2968
|
-
id: credential.id
|
|
2969
|
-
})),
|
|
2970
|
-
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
2971
|
-
identity: {
|
|
2972
|
-
identityKey: member.key,
|
|
2973
|
-
profile: {
|
|
2974
|
-
displayName: member.assertion.profile?.displayName
|
|
2975
|
-
}
|
|
2976
|
-
},
|
|
2977
|
-
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services7.SpaceMember.PresenceState.ONLINE : import_services7.SpaceMember.PresenceState.OFFLINE
|
|
2978
|
-
})),
|
|
2979
|
-
pipeline: {
|
|
2980
|
-
// TODO(burdon): Pick properties from credentials if needed.
|
|
2981
|
-
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
2982
|
-
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
2983
|
-
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
2984
|
-
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2985
|
-
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
2986
|
-
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
|
|
2987
|
-
}
|
|
2988
|
-
};
|
|
2989
|
-
if (stats.metrics) {
|
|
2990
|
-
const { open, ready } = stats.metrics;
|
|
2991
|
-
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
2992
|
-
}
|
|
2993
|
-
return stats;
|
|
2994
|
-
};
|
|
2995
|
-
var AutomergeSpaceState = class {
|
|
2996
|
-
constructor(_onNewRoot) {
|
|
2997
|
-
this._onNewRoot = _onNewRoot;
|
|
2998
|
-
this.rootUrl = void 0;
|
|
2999
|
-
this.lastEpoch = void 0;
|
|
3000
|
-
this.onNewEpoch = new import_async11.Event();
|
|
3001
|
-
this._isProcessingRootDocs = false;
|
|
3002
|
-
}
|
|
3003
|
-
async processCredential(credential) {
|
|
3004
|
-
if (!(0, import_credentials11.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
3005
|
-
return;
|
|
3006
|
-
}
|
|
3007
|
-
this.lastEpoch = credential;
|
|
3008
|
-
if (credential.subject.assertion.automergeRoot) {
|
|
3009
|
-
this.rootUrl = credential.subject.assertion.automergeRoot;
|
|
3010
|
-
if (this._isProcessingRootDocs) {
|
|
3011
|
-
this._onNewRoot(this.rootUrl);
|
|
3012
|
-
}
|
|
3013
|
-
}
|
|
3014
|
-
this.onNewEpoch.emit(credential);
|
|
3015
|
-
}
|
|
3016
|
-
startProcessingRootDocs() {
|
|
3017
|
-
if (this._isProcessingRootDocs) {
|
|
3018
|
-
return;
|
|
3019
|
-
}
|
|
3020
|
-
if (this.rootUrl) {
|
|
3021
|
-
this._onNewRoot(this.rootUrl);
|
|
3022
|
-
}
|
|
3023
|
-
this._isProcessingRootDocs = true;
|
|
3024
|
-
}
|
|
3025
|
-
async ensureEpochInitialized() {
|
|
3026
|
-
await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
|
|
3027
|
-
}
|
|
3028
|
-
};
|
|
3029
|
-
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
2970
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
3030
2971
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
3031
2972
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
3032
2973
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -3054,13 +2995,13 @@ var NotarizationPlugin = class {
|
|
|
3054
2995
|
(0, import_log9.log)("notarize", {
|
|
3055
2996
|
credentials
|
|
3056
2997
|
}, {
|
|
3057
|
-
F:
|
|
2998
|
+
F: __dxlog_file10,
|
|
3058
2999
|
L: 90,
|
|
3059
3000
|
S: this,
|
|
3060
3001
|
C: (f, a) => f(...a)
|
|
3061
3002
|
});
|
|
3062
|
-
(0,
|
|
3063
|
-
F:
|
|
3003
|
+
(0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
3004
|
+
F: __dxlog_file10,
|
|
3064
3005
|
L: 91,
|
|
3065
3006
|
S: this,
|
|
3066
3007
|
A: [
|
|
@@ -3074,7 +3015,7 @@ var NotarizationPlugin = class {
|
|
|
3074
3015
|
import_log9.log.warn("Notarization error", {
|
|
3075
3016
|
err
|
|
3076
3017
|
}, {
|
|
3077
|
-
F:
|
|
3018
|
+
F: __dxlog_file10,
|
|
3078
3019
|
L: 99,
|
|
3079
3020
|
S: this,
|
|
3080
3021
|
C: (f, a) => f(...a)
|
|
@@ -3090,7 +3031,7 @@ var NotarizationPlugin = class {
|
|
|
3090
3031
|
timeout,
|
|
3091
3032
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3092
3033
|
}, {
|
|
3093
|
-
F:
|
|
3034
|
+
F: __dxlog_file10,
|
|
3094
3035
|
L: 111,
|
|
3095
3036
|
S: this,
|
|
3096
3037
|
C: (f, a) => f(...a)
|
|
@@ -3113,7 +3054,7 @@ var NotarizationPlugin = class {
|
|
|
3113
3054
|
import_log9.log.info("Exhausted all peers to notarize with", {
|
|
3114
3055
|
retryIn: retryTimeout
|
|
3115
3056
|
}, {
|
|
3116
|
-
F:
|
|
3057
|
+
F: __dxlog_file10,
|
|
3117
3058
|
L: 136,
|
|
3118
3059
|
S: this,
|
|
3119
3060
|
C: (f, a) => f(...a)
|
|
@@ -3127,7 +3068,7 @@ var NotarizationPlugin = class {
|
|
|
3127
3068
|
peer: peer.localPeerId,
|
|
3128
3069
|
credentialId: credentials.map((credential) => credential.id)
|
|
3129
3070
|
}, {
|
|
3130
|
-
F:
|
|
3071
|
+
F: __dxlog_file10,
|
|
3131
3072
|
L: 143,
|
|
3132
3073
|
S: this,
|
|
3133
3074
|
C: (f, a) => f(...a)
|
|
@@ -3136,7 +3077,7 @@ var NotarizationPlugin = class {
|
|
|
3136
3077
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
3137
3078
|
});
|
|
3138
3079
|
(0, import_log9.log)("success", void 0, {
|
|
3139
|
-
F:
|
|
3080
|
+
F: __dxlog_file10,
|
|
3140
3081
|
L: 147,
|
|
3141
3082
|
S: this,
|
|
3142
3083
|
C: (f, a) => f(...a)
|
|
@@ -3145,7 +3086,7 @@ var NotarizationPlugin = class {
|
|
|
3145
3086
|
} catch (err) {
|
|
3146
3087
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
3147
3088
|
import_log9.log.info("error notarizing (recoverable)", err, {
|
|
3148
|
-
F:
|
|
3089
|
+
F: __dxlog_file10,
|
|
3149
3090
|
L: 151,
|
|
3150
3091
|
S: this,
|
|
3151
3092
|
C: (f, a) => f(...a)
|
|
@@ -3163,7 +3104,7 @@ var NotarizationPlugin = class {
|
|
|
3163
3104
|
errors.wait()
|
|
3164
3105
|
]);
|
|
3165
3106
|
(0, import_log9.log)("done", void 0, {
|
|
3166
|
-
F:
|
|
3107
|
+
F: __dxlog_file10,
|
|
3167
3108
|
L: 162,
|
|
3168
3109
|
S: this,
|
|
3169
3110
|
C: (f, a) => f(...a)
|
|
@@ -3184,8 +3125,8 @@ var NotarizationPlugin = class {
|
|
|
3184
3125
|
this._processCredentialsTriggers.delete(credential.id);
|
|
3185
3126
|
}
|
|
3186
3127
|
setWriter(writer) {
|
|
3187
|
-
(0,
|
|
3188
|
-
F:
|
|
3128
|
+
(0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
|
|
3129
|
+
F: __dxlog_file10,
|
|
3189
3130
|
L: 181,
|
|
3190
3131
|
S: this,
|
|
3191
3132
|
A: [
|
|
@@ -3209,8 +3150,8 @@ var NotarizationPlugin = class {
|
|
|
3209
3150
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
3210
3151
|
}
|
|
3211
3152
|
for (const credential of request.credentials ?? []) {
|
|
3212
|
-
(0,
|
|
3213
|
-
F:
|
|
3153
|
+
(0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
|
|
3154
|
+
F: __dxlog_file10,
|
|
3214
3155
|
L: 200,
|
|
3215
3156
|
S: this,
|
|
3216
3157
|
A: [
|
|
@@ -3230,7 +3171,7 @@ var NotarizationPlugin = class {
|
|
|
3230
3171
|
(0, import_log9.log)("extension opened", {
|
|
3231
3172
|
peer: extension.localPeerId
|
|
3232
3173
|
}, {
|
|
3233
|
-
F:
|
|
3174
|
+
F: __dxlog_file10,
|
|
3234
3175
|
L: 211,
|
|
3235
3176
|
S: this,
|
|
3236
3177
|
C: (f, a) => f(...a)
|
|
@@ -3242,7 +3183,7 @@ var NotarizationPlugin = class {
|
|
|
3242
3183
|
(0, import_log9.log)("extension closed", {
|
|
3243
3184
|
peer: extension.localPeerId
|
|
3244
3185
|
}, {
|
|
3245
|
-
F:
|
|
3186
|
+
F: __dxlog_file10,
|
|
3246
3187
|
L: 216,
|
|
3247
3188
|
S: this,
|
|
3248
3189
|
C: (f, a) => f(...a)
|
|
@@ -3258,10 +3199,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
3258
3199
|
constructor(_params) {
|
|
3259
3200
|
super({
|
|
3260
3201
|
requested: {
|
|
3261
|
-
NotarizationService:
|
|
3202
|
+
NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3262
3203
|
},
|
|
3263
3204
|
exposed: {
|
|
3264
|
-
NotarizationService:
|
|
3205
|
+
NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3265
3206
|
}
|
|
3266
3207
|
});
|
|
3267
3208
|
this._params = _params;
|
|
@@ -3294,14 +3235,14 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3294
3235
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3295
3236
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3296
3237
|
}
|
|
3297
|
-
var
|
|
3238
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3298
3239
|
var DataSpace = class {
|
|
3299
3240
|
constructor(params) {
|
|
3300
3241
|
this._ctx = new import_context7.Context();
|
|
3301
3242
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3302
3243
|
this._cache = void 0;
|
|
3303
3244
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
3304
|
-
this._state =
|
|
3245
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
3305
3246
|
this.error = void 0;
|
|
3306
3247
|
this.stateUpdate = new import_async10.Event();
|
|
3307
3248
|
this.metrics = {};
|
|
@@ -3323,10 +3264,10 @@ var DataSpace = class {
|
|
|
3323
3264
|
this._cache = params.cache;
|
|
3324
3265
|
this._state = params.initialState;
|
|
3325
3266
|
(0, import_log8.log)("new state", {
|
|
3326
|
-
state:
|
|
3267
|
+
state: import_services7.SpaceState[this._state]
|
|
3327
3268
|
}, {
|
|
3328
|
-
F:
|
|
3329
|
-
L:
|
|
3269
|
+
F: __dxlog_file11,
|
|
3270
|
+
L: 140,
|
|
3330
3271
|
S: this,
|
|
3331
3272
|
C: (f, a) => f(...a)
|
|
3332
3273
|
});
|
|
@@ -3371,12 +3312,12 @@ var DataSpace = class {
|
|
|
3371
3312
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3372
3313
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3373
3314
|
await this._inner.open(new import_context7.Context());
|
|
3374
|
-
this._state =
|
|
3315
|
+
this._state = import_services7.SpaceState.CONTROL_ONLY;
|
|
3375
3316
|
(0, import_log8.log)("new state", {
|
|
3376
|
-
state:
|
|
3317
|
+
state: import_services7.SpaceState[this._state]
|
|
3377
3318
|
}, {
|
|
3378
|
-
F:
|
|
3379
|
-
L:
|
|
3319
|
+
F: __dxlog_file11,
|
|
3320
|
+
L: 198,
|
|
3380
3321
|
S: this,
|
|
3381
3322
|
C: (f, a) => f(...a)
|
|
3382
3323
|
});
|
|
@@ -3389,12 +3330,12 @@ var DataSpace = class {
|
|
|
3389
3330
|
}
|
|
3390
3331
|
async _close() {
|
|
3391
3332
|
await this._callbacks.beforeClose?.();
|
|
3392
|
-
this._state =
|
|
3333
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
3393
3334
|
(0, import_log8.log)("new state", {
|
|
3394
|
-
state:
|
|
3335
|
+
state: import_services7.SpaceState[this._state]
|
|
3395
3336
|
}, {
|
|
3396
|
-
F:
|
|
3397
|
-
L:
|
|
3337
|
+
F: __dxlog_file11,
|
|
3338
|
+
L: 212,
|
|
3398
3339
|
S: this,
|
|
3399
3340
|
C: (f, a) => f(...a)
|
|
3400
3341
|
});
|
|
@@ -3423,27 +3364,27 @@ var DataSpace = class {
|
|
|
3423
3364
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3424
3365
|
await this.initializeDataPipeline();
|
|
3425
3366
|
} catch (err) {
|
|
3426
|
-
if (err instanceof
|
|
3367
|
+
if (err instanceof import_protocols7.CancelledError || err instanceof import_context7.ContextDisposedError) {
|
|
3427
3368
|
(0, import_log8.log)("data pipeline initialization cancelled", err, {
|
|
3428
|
-
F:
|
|
3429
|
-
L:
|
|
3369
|
+
F: __dxlog_file11,
|
|
3370
|
+
L: 245,
|
|
3430
3371
|
S: this,
|
|
3431
3372
|
C: (f, a) => f(...a)
|
|
3432
3373
|
});
|
|
3433
3374
|
return;
|
|
3434
3375
|
}
|
|
3435
3376
|
import_log8.log.error("Error initializing data pipeline", err, {
|
|
3436
|
-
F:
|
|
3437
|
-
L:
|
|
3377
|
+
F: __dxlog_file11,
|
|
3378
|
+
L: 249,
|
|
3438
3379
|
S: this,
|
|
3439
3380
|
C: (f, a) => f(...a)
|
|
3440
3381
|
});
|
|
3441
|
-
this._state =
|
|
3382
|
+
this._state = import_services7.SpaceState.ERROR;
|
|
3442
3383
|
(0, import_log8.log)("new state", {
|
|
3443
|
-
state:
|
|
3384
|
+
state: import_services7.SpaceState[this._state]
|
|
3444
3385
|
}, {
|
|
3445
|
-
F:
|
|
3446
|
-
L:
|
|
3386
|
+
F: __dxlog_file11,
|
|
3387
|
+
L: 251,
|
|
3447
3388
|
S: this,
|
|
3448
3389
|
C: (f, a) => f(...a)
|
|
3449
3390
|
});
|
|
@@ -3455,15 +3396,15 @@ var DataSpace = class {
|
|
|
3455
3396
|
});
|
|
3456
3397
|
}
|
|
3457
3398
|
async initializeDataPipeline() {
|
|
3458
|
-
if (this._state !==
|
|
3459
|
-
throw new
|
|
3399
|
+
if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
|
|
3400
|
+
throw new import_protocols7.SystemError("Invalid operation");
|
|
3460
3401
|
}
|
|
3461
|
-
this._state =
|
|
3402
|
+
this._state = import_services7.SpaceState.INITIALIZING;
|
|
3462
3403
|
(0, import_log8.log)("new state", {
|
|
3463
|
-
state:
|
|
3404
|
+
state: import_services7.SpaceState[this._state]
|
|
3464
3405
|
}, {
|
|
3465
|
-
F:
|
|
3466
|
-
L:
|
|
3406
|
+
F: __dxlog_file11,
|
|
3407
|
+
L: 267,
|
|
3467
3408
|
S: this,
|
|
3468
3409
|
C: (f, a) => f(...a)
|
|
3469
3410
|
});
|
|
@@ -3472,18 +3413,18 @@ var DataSpace = class {
|
|
|
3472
3413
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
3473
3414
|
await (0, import_context7.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
3474
3415
|
(0, import_log8.log)("data pipeline ready", void 0, {
|
|
3475
|
-
F:
|
|
3476
|
-
L:
|
|
3416
|
+
F: __dxlog_file11,
|
|
3417
|
+
L: 279,
|
|
3477
3418
|
S: this,
|
|
3478
3419
|
C: (f, a) => f(...a)
|
|
3479
3420
|
});
|
|
3480
3421
|
await this._callbacks.beforeReady?.();
|
|
3481
|
-
this._state =
|
|
3422
|
+
this._state = import_services7.SpaceState.READY;
|
|
3482
3423
|
(0, import_log8.log)("new state", {
|
|
3483
|
-
state:
|
|
3424
|
+
state: import_services7.SpaceState[this._state]
|
|
3484
3425
|
}, {
|
|
3485
|
-
F:
|
|
3486
|
-
L:
|
|
3426
|
+
F: __dxlog_file11,
|
|
3427
|
+
L: 283,
|
|
3487
3428
|
S: this,
|
|
3488
3429
|
C: (f, a) => f(...a)
|
|
3489
3430
|
});
|
|
@@ -3498,14 +3439,14 @@ var DataSpace = class {
|
|
|
3498
3439
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
3499
3440
|
await this._createWritableFeeds();
|
|
3500
3441
|
(0, import_log8.log)("writable feeds created", void 0, {
|
|
3501
|
-
F:
|
|
3502
|
-
L:
|
|
3442
|
+
F: __dxlog_file11,
|
|
3443
|
+
L: 299,
|
|
3503
3444
|
S: this,
|
|
3504
3445
|
C: (f, a) => f(...a)
|
|
3505
3446
|
});
|
|
3506
3447
|
this.stateUpdate.emit();
|
|
3507
3448
|
if (!this.notarizationPlugin.hasWriter) {
|
|
3508
|
-
this.notarizationPlugin.setWriter((0,
|
|
3449
|
+
this.notarizationPlugin.setWriter((0, import_echo_pipeline2.createMappedFeedWriter)((credential) => ({
|
|
3509
3450
|
credential: {
|
|
3510
3451
|
credential
|
|
3511
3452
|
}
|
|
@@ -3526,7 +3467,7 @@ var DataSpace = class {
|
|
|
3526
3467
|
spaceKey: this.key,
|
|
3527
3468
|
deviceKey: this._signingContext.deviceKey,
|
|
3528
3469
|
identityKey: this._signingContext.identityKey,
|
|
3529
|
-
designation:
|
|
3470
|
+
designation: import_credentials9.AdmittedFeed.Designation.CONTROL
|
|
3530
3471
|
}
|
|
3531
3472
|
}));
|
|
3532
3473
|
}
|
|
@@ -3543,7 +3484,7 @@ var DataSpace = class {
|
|
|
3543
3484
|
spaceKey: this.key,
|
|
3544
3485
|
deviceKey: this._signingContext.deviceKey,
|
|
3545
3486
|
identityKey: this._signingContext.identityKey,
|
|
3546
|
-
designation:
|
|
3487
|
+
designation: import_credentials9.AdmittedFeed.Designation.DATA
|
|
3547
3488
|
}
|
|
3548
3489
|
}));
|
|
3549
3490
|
}
|
|
@@ -3561,8 +3502,8 @@ var DataSpace = class {
|
|
|
3561
3502
|
space: this.key,
|
|
3562
3503
|
rootUrl
|
|
3563
3504
|
}, {
|
|
3564
|
-
F:
|
|
3565
|
-
L:
|
|
3505
|
+
F: __dxlog_file11,
|
|
3506
|
+
L: 365,
|
|
3566
3507
|
S: this,
|
|
3567
3508
|
C: (f, a) => f(...a)
|
|
3568
3509
|
});
|
|
@@ -3576,7 +3517,7 @@ var DataSpace = class {
|
|
|
3576
3517
|
if (this._ctx.disposed) {
|
|
3577
3518
|
return;
|
|
3578
3519
|
}
|
|
3579
|
-
const doc = handle.docSync() ?? (0,
|
|
3520
|
+
const doc = handle.docSync() ?? (0, import_invariant9.failedInvariant)();
|
|
3580
3521
|
if (!doc.access?.spaceKey) {
|
|
3581
3522
|
handle.change((doc2) => {
|
|
3582
3523
|
doc2.access = {
|
|
@@ -3593,8 +3534,8 @@ var DataSpace = class {
|
|
|
3593
3534
|
rootUrl,
|
|
3594
3535
|
err
|
|
3595
3536
|
}, {
|
|
3596
|
-
F:
|
|
3597
|
-
L:
|
|
3537
|
+
F: __dxlog_file11,
|
|
3538
|
+
L: 388,
|
|
3598
3539
|
S: this,
|
|
3599
3540
|
C: (f, a) => f(...a)
|
|
3600
3541
|
});
|
|
@@ -3620,7 +3561,7 @@ var DataSpace = class {
|
|
|
3620
3561
|
let epoch;
|
|
3621
3562
|
switch (options?.migration) {
|
|
3622
3563
|
case void 0:
|
|
3623
|
-
case
|
|
3564
|
+
case import_services7.CreateEpochRequest.Migration.NONE:
|
|
3624
3565
|
{
|
|
3625
3566
|
epoch = {
|
|
3626
3567
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
@@ -3630,7 +3571,7 @@ var DataSpace = class {
|
|
|
3630
3571
|
};
|
|
3631
3572
|
}
|
|
3632
3573
|
break;
|
|
3633
|
-
case
|
|
3574
|
+
case import_services7.CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3634
3575
|
{
|
|
3635
3576
|
const document = this._automergeHost.repo.create();
|
|
3636
3577
|
epoch = {
|
|
@@ -3641,21 +3582,81 @@ var DataSpace = class {
|
|
|
3641
3582
|
};
|
|
3642
3583
|
}
|
|
3643
3584
|
break;
|
|
3644
|
-
case
|
|
3585
|
+
case import_services7.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
3645
3586
|
{
|
|
3646
3587
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3647
3588
|
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3648
3589
|
await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3649
3590
|
const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
|
|
3650
|
-
(0,
|
|
3651
|
-
F:
|
|
3652
|
-
L:
|
|
3591
|
+
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3592
|
+
F: __dxlog_file11,
|
|
3593
|
+
L: 438,
|
|
3594
|
+
S: this,
|
|
3595
|
+
A: [
|
|
3596
|
+
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3597
|
+
""
|
|
3598
|
+
]
|
|
3599
|
+
});
|
|
3600
|
+
epoch = {
|
|
3601
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3602
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
3603
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe2.Timeframe(),
|
|
3604
|
+
automergeRoot: newRoot.url
|
|
3605
|
+
};
|
|
3606
|
+
}
|
|
3607
|
+
break;
|
|
3608
|
+
case import_services7.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
3609
|
+
{
|
|
3610
|
+
import_log8.log.info("Fragmenting", void 0, {
|
|
3611
|
+
F: __dxlog_file11,
|
|
3612
|
+
L: 450,
|
|
3613
|
+
S: this,
|
|
3614
|
+
C: (f, a) => f(...a)
|
|
3615
|
+
});
|
|
3616
|
+
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3617
|
+
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3618
|
+
await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3619
|
+
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3620
|
+
const properties = objects.find(([_, value]) => value.system.type?.itemId === import_echo_db.TYPE_PROPERTIES);
|
|
3621
|
+
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3622
|
+
(0, import_invariant9.invariant)(properties, "Properties not found", {
|
|
3623
|
+
F: __dxlog_file11,
|
|
3624
|
+
L: 460,
|
|
3625
|
+
S: this,
|
|
3626
|
+
A: [
|
|
3627
|
+
"properties",
|
|
3628
|
+
"'Properties not found'"
|
|
3629
|
+
]
|
|
3630
|
+
});
|
|
3631
|
+
const newSpaceDoc = {
|
|
3632
|
+
...rootHandle.docSync(),
|
|
3633
|
+
objects: Object.fromEntries([
|
|
3634
|
+
properties
|
|
3635
|
+
])
|
|
3636
|
+
};
|
|
3637
|
+
const newRoot = this._automergeHost.repo.create(newSpaceDoc);
|
|
3638
|
+
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3639
|
+
F: __dxlog_file11,
|
|
3640
|
+
L: 465,
|
|
3653
3641
|
S: this,
|
|
3654
3642
|
A: [
|
|
3655
3643
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3656
3644
|
""
|
|
3657
3645
|
]
|
|
3658
3646
|
});
|
|
3647
|
+
const docLoader = new import_echo_pipeline3.AutomergeDocumentLoaderImpl(this.key, this._automergeHost.repo);
|
|
3648
|
+
await docLoader.loadSpaceRootDocHandle(this._ctx, {
|
|
3649
|
+
rootUrl: newRoot.url
|
|
3650
|
+
});
|
|
3651
|
+
otherObjects.forEach(([key, value]) => {
|
|
3652
|
+
const handle = docLoader.createDocumentForObject(key);
|
|
3653
|
+
handle.change((doc) => {
|
|
3654
|
+
(0, import_util4.assignDeep)(doc, [
|
|
3655
|
+
"objects",
|
|
3656
|
+
key
|
|
3657
|
+
], value);
|
|
3658
|
+
});
|
|
3659
|
+
});
|
|
3659
3660
|
epoch = {
|
|
3660
3661
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3661
3662
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
@@ -3687,25 +3688,25 @@ var DataSpace = class {
|
|
|
3687
3688
|
]));
|
|
3688
3689
|
}
|
|
3689
3690
|
async activate() {
|
|
3690
|
-
if (this._state !==
|
|
3691
|
+
if (this._state !== import_services7.SpaceState.INACTIVE) {
|
|
3691
3692
|
return;
|
|
3692
3693
|
}
|
|
3693
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3694
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.ACTIVE);
|
|
3694
3695
|
await this._open();
|
|
3695
3696
|
this.initializeDataPipelineAsync();
|
|
3696
3697
|
}
|
|
3697
3698
|
async deactivate() {
|
|
3698
|
-
if (this._state ===
|
|
3699
|
+
if (this._state === import_services7.SpaceState.INACTIVE) {
|
|
3699
3700
|
return;
|
|
3700
3701
|
}
|
|
3701
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3702
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.INACTIVE);
|
|
3702
3703
|
await this._close();
|
|
3703
|
-
this._state =
|
|
3704
|
+
this._state = import_services7.SpaceState.INACTIVE;
|
|
3704
3705
|
(0, import_log8.log)("new state", {
|
|
3705
|
-
state:
|
|
3706
|
+
state: import_services7.SpaceState[this._state]
|
|
3706
3707
|
}, {
|
|
3707
|
-
F:
|
|
3708
|
-
L:
|
|
3708
|
+
F: __dxlog_file11,
|
|
3709
|
+
L: 531,
|
|
3709
3710
|
S: this,
|
|
3710
3711
|
C: (f, a) => f(...a)
|
|
3711
3712
|
});
|
|
@@ -3713,18 +3714,18 @@ var DataSpace = class {
|
|
|
3713
3714
|
}
|
|
3714
3715
|
};
|
|
3715
3716
|
_ts_decorate4([
|
|
3716
|
-
|
|
3717
|
+
import_tracing4.trace.info()
|
|
3717
3718
|
], DataSpace.prototype, "_inner", void 0);
|
|
3718
3719
|
_ts_decorate4([
|
|
3719
|
-
|
|
3720
|
+
import_tracing4.trace.info()
|
|
3720
3721
|
], DataSpace.prototype, "key", null);
|
|
3721
3722
|
_ts_decorate4([
|
|
3722
|
-
|
|
3723
|
-
enum:
|
|
3723
|
+
import_tracing4.trace.info({
|
|
3724
|
+
enum: import_services7.SpaceState
|
|
3724
3725
|
})
|
|
3725
3726
|
], DataSpace.prototype, "state", null);
|
|
3726
3727
|
_ts_decorate4([
|
|
3727
|
-
|
|
3728
|
+
import_tracing4.trace.info({
|
|
3728
3729
|
depth: null
|
|
3729
3730
|
})
|
|
3730
3731
|
], DataSpace.prototype, "_automergeInfo", null);
|
|
@@ -3735,12 +3736,12 @@ _ts_decorate4([
|
|
|
3735
3736
|
import_async10.synchronized
|
|
3736
3737
|
], DataSpace.prototype, "close", null);
|
|
3737
3738
|
_ts_decorate4([
|
|
3738
|
-
|
|
3739
|
+
import_tracing4.trace.span({
|
|
3739
3740
|
showInBrowserTimeline: true
|
|
3740
3741
|
})
|
|
3741
3742
|
], DataSpace.prototype, "initializeDataPipeline", null);
|
|
3742
3743
|
_ts_decorate4([
|
|
3743
|
-
|
|
3744
|
+
import_tracing4.trace.span({
|
|
3744
3745
|
showInBrowserTimeline: true
|
|
3745
3746
|
})
|
|
3746
3747
|
], DataSpace.prototype, "_initializeAndReadControlPipeline", null);
|
|
@@ -3755,11 +3756,11 @@ _ts_decorate4([
|
|
|
3755
3756
|
], DataSpace.prototype, "deactivate", null);
|
|
3756
3757
|
DataSpace = _ts_decorate4([
|
|
3757
3758
|
(0, import_async10.trackLeaks)("open", "close"),
|
|
3758
|
-
|
|
3759
|
+
import_tracing4.trace.resource()
|
|
3759
3760
|
], DataSpace);
|
|
3760
3761
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
3761
3762
|
const credentials = [
|
|
3762
|
-
await (0,
|
|
3763
|
+
await (0, import_credentials12.createCredential)({
|
|
3763
3764
|
signer: keyring,
|
|
3764
3765
|
issuer: space.key,
|
|
3765
3766
|
subject: space.key,
|
|
@@ -3768,14 +3769,14 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3768
3769
|
spaceKey: space.key
|
|
3769
3770
|
}
|
|
3770
3771
|
}),
|
|
3771
|
-
await (0,
|
|
3772
|
+
await (0, import_credentials12.createCredential)({
|
|
3772
3773
|
signer: keyring,
|
|
3773
3774
|
issuer: space.key,
|
|
3774
3775
|
subject: signingContext.identityKey,
|
|
3775
3776
|
assertion: {
|
|
3776
3777
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
3777
3778
|
spaceKey: space.key,
|
|
3778
|
-
role:
|
|
3779
|
+
role: import_credentials13.SpaceMember.Role.ADMIN,
|
|
3779
3780
|
profile: signingContext.getProfile(),
|
|
3780
3781
|
genesisFeedKey: space.controlFeedKey ?? (0, import_debug4.failUndefined)()
|
|
3781
3782
|
}
|
|
@@ -3787,7 +3788,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3787
3788
|
spaceKey: space.key,
|
|
3788
3789
|
identityKey: signingContext.identityKey,
|
|
3789
3790
|
deviceKey: signingContext.deviceKey,
|
|
3790
|
-
designation:
|
|
3791
|
+
designation: import_credentials13.AdmittedFeed.Designation.CONTROL
|
|
3791
3792
|
}
|
|
3792
3793
|
}),
|
|
3793
3794
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3797,7 +3798,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3797
3798
|
spaceKey: space.key,
|
|
3798
3799
|
identityKey: signingContext.identityKey,
|
|
3799
3800
|
deviceKey: signingContext.deviceKey,
|
|
3800
|
-
designation:
|
|
3801
|
+
designation: import_credentials13.AdmittedFeed.Designation.DATA
|
|
3801
3802
|
}
|
|
3802
3803
|
}),
|
|
3803
3804
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3831,7 +3832,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
3831
3832
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3832
3833
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3833
3834
|
}
|
|
3834
|
-
var
|
|
3835
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
3835
3836
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3836
3837
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3837
3838
|
var DataSpaceManager = class {
|
|
@@ -3857,15 +3858,15 @@ var DataSpaceManager = class {
|
|
|
3857
3858
|
}
|
|
3858
3859
|
async open() {
|
|
3859
3860
|
(0, import_log10.log)("open", void 0, {
|
|
3860
|
-
F:
|
|
3861
|
+
F: __dxlog_file12,
|
|
3861
3862
|
L: 98,
|
|
3862
3863
|
S: this,
|
|
3863
3864
|
C: (f, a) => f(...a)
|
|
3864
3865
|
});
|
|
3865
|
-
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({
|
|
3866
3867
|
id: this._instanceId
|
|
3867
3868
|
}), {
|
|
3868
|
-
F:
|
|
3869
|
+
F: __dxlog_file12,
|
|
3869
3870
|
L: 99,
|
|
3870
3871
|
S: this,
|
|
3871
3872
|
C: (f, a) => f(...a)
|
|
@@ -3873,7 +3874,7 @@ var DataSpaceManager = class {
|
|
|
3873
3874
|
(0, import_log10.log)("metadata loaded", {
|
|
3874
3875
|
spaces: this._metadataStore.spaces.length
|
|
3875
3876
|
}, {
|
|
3876
|
-
F:
|
|
3877
|
+
F: __dxlog_file12,
|
|
3877
3878
|
L: 100,
|
|
3878
3879
|
S: this,
|
|
3879
3880
|
C: (f, a) => f(...a)
|
|
@@ -3883,7 +3884,7 @@ var DataSpaceManager = class {
|
|
|
3883
3884
|
(0, import_log10.log)("load space", {
|
|
3884
3885
|
spaceMetadata
|
|
3885
3886
|
}, {
|
|
3886
|
-
F:
|
|
3887
|
+
F: __dxlog_file12,
|
|
3887
3888
|
L: 104,
|
|
3888
3889
|
S: this,
|
|
3889
3890
|
C: (f, a) => f(...a)
|
|
@@ -3894,7 +3895,7 @@ var DataSpaceManager = class {
|
|
|
3894
3895
|
spaceMetadata,
|
|
3895
3896
|
err
|
|
3896
3897
|
}, {
|
|
3897
|
-
F:
|
|
3898
|
+
F: __dxlog_file12,
|
|
3898
3899
|
L: 107,
|
|
3899
3900
|
S: this,
|
|
3900
3901
|
C: (f, a) => f(...a)
|
|
@@ -3904,14 +3905,14 @@ var DataSpaceManager = class {
|
|
|
3904
3905
|
this._isOpen = true;
|
|
3905
3906
|
this.updated.emit();
|
|
3906
3907
|
for (const space of this._spaces.values()) {
|
|
3907
|
-
if (space.state !==
|
|
3908
|
+
if (space.state !== import_services8.SpaceState.INACTIVE) {
|
|
3908
3909
|
space.initializeDataPipelineAsync();
|
|
3909
3910
|
}
|
|
3910
3911
|
}
|
|
3911
|
-
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({
|
|
3912
3913
|
id: this._instanceId
|
|
3913
3914
|
}), {
|
|
3914
|
-
F:
|
|
3915
|
+
F: __dxlog_file12,
|
|
3915
3916
|
L: 120,
|
|
3916
3917
|
S: this,
|
|
3917
3918
|
C: (f, a) => f(...a)
|
|
@@ -3919,7 +3920,7 @@ var DataSpaceManager = class {
|
|
|
3919
3920
|
}
|
|
3920
3921
|
async close() {
|
|
3921
3922
|
(0, import_log10.log)("close", void 0, {
|
|
3922
|
-
F:
|
|
3923
|
+
F: __dxlog_file12,
|
|
3923
3924
|
L: 125,
|
|
3924
3925
|
S: this,
|
|
3925
3926
|
C: (f, a) => f(...a)
|
|
@@ -3934,8 +3935,8 @@ var DataSpaceManager = class {
|
|
|
3934
3935
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
3935
3936
|
*/
|
|
3936
3937
|
async createSpace() {
|
|
3937
|
-
(0,
|
|
3938
|
-
F:
|
|
3938
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3939
|
+
F: __dxlog_file12,
|
|
3939
3940
|
L: 138,
|
|
3940
3941
|
S: this,
|
|
3941
3942
|
A: [
|
|
@@ -3951,12 +3952,12 @@ var DataSpaceManager = class {
|
|
|
3951
3952
|
genesisFeedKey: controlFeedKey,
|
|
3952
3953
|
controlFeedKey,
|
|
3953
3954
|
dataFeedKey,
|
|
3954
|
-
state:
|
|
3955
|
+
state: import_services8.SpaceState.ACTIVE
|
|
3955
3956
|
};
|
|
3956
3957
|
(0, import_log10.log)("creating space...", {
|
|
3957
3958
|
spaceKey
|
|
3958
3959
|
}, {
|
|
3959
|
-
F:
|
|
3960
|
+
F: __dxlog_file12,
|
|
3960
3961
|
L: 150,
|
|
3961
3962
|
S: this,
|
|
3962
3963
|
C: (f, a) => f(...a)
|
|
@@ -3971,8 +3972,8 @@ var DataSpaceManager = class {
|
|
|
3971
3972
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
|
|
3972
3973
|
await this._metadataStore.addSpace(metadata);
|
|
3973
3974
|
const memberCredential = credentials[1];
|
|
3974
|
-
(0,
|
|
3975
|
-
F:
|
|
3975
|
+
(0, import_invariant11.invariant)((0, import_credentials11.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3976
|
+
F: __dxlog_file12,
|
|
3976
3977
|
L: 163,
|
|
3977
3978
|
S: this,
|
|
3978
3979
|
A: [
|
|
@@ -3990,13 +3991,13 @@ var DataSpaceManager = class {
|
|
|
3990
3991
|
(0, import_log10.log)("accept space", {
|
|
3991
3992
|
opts
|
|
3992
3993
|
}, {
|
|
3993
|
-
F:
|
|
3994
|
+
F: __dxlog_file12,
|
|
3994
3995
|
L: 175,
|
|
3995
3996
|
S: this,
|
|
3996
3997
|
C: (f, a) => f(...a)
|
|
3997
3998
|
});
|
|
3998
|
-
(0,
|
|
3999
|
-
F:
|
|
3999
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
4000
|
+
F: __dxlog_file12,
|
|
4000
4001
|
L: 176,
|
|
4001
4002
|
S: this,
|
|
4002
4003
|
A: [
|
|
@@ -4004,8 +4005,8 @@ var DataSpaceManager = class {
|
|
|
4004
4005
|
"'Not open.'"
|
|
4005
4006
|
]
|
|
4006
4007
|
});
|
|
4007
|
-
(0,
|
|
4008
|
-
F:
|
|
4008
|
+
(0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
4009
|
+
F: __dxlog_file12,
|
|
4009
4010
|
L: 177,
|
|
4010
4011
|
S: this,
|
|
4011
4012
|
A: [
|
|
@@ -4033,14 +4034,14 @@ var DataSpaceManager = class {
|
|
|
4033
4034
|
async waitUntilSpaceReady(spaceKey) {
|
|
4034
4035
|
await (0, import_context9.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
4035
4036
|
const space = this._spaces.get(spaceKey);
|
|
4036
|
-
return !!space && space.state ===
|
|
4037
|
+
return !!space && space.state === import_services8.SpaceState.READY;
|
|
4037
4038
|
}));
|
|
4038
4039
|
}
|
|
4039
4040
|
async _constructSpace(metadata) {
|
|
4040
4041
|
(0, import_log10.log)("construct space", {
|
|
4041
4042
|
metadata
|
|
4042
4043
|
}, {
|
|
4043
|
-
F:
|
|
4044
|
+
F: __dxlog_file12,
|
|
4044
4045
|
L: 210,
|
|
4045
4046
|
S: this,
|
|
4046
4047
|
C: (f, a) => f(...a)
|
|
@@ -4078,7 +4079,7 @@ var DataSpaceManager = class {
|
|
|
4078
4079
|
},
|
|
4079
4080
|
onAuthFailure: () => {
|
|
4080
4081
|
import_log10.log.warn("auth failure", void 0, {
|
|
4081
|
-
F:
|
|
4082
|
+
F: __dxlog_file12,
|
|
4082
4083
|
L: 247,
|
|
4083
4084
|
S: this,
|
|
4084
4085
|
C: (f, a) => f(...a)
|
|
@@ -4090,7 +4091,7 @@ var DataSpaceManager = class {
|
|
|
4090
4091
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
4091
4092
|
const dataSpace = new DataSpace({
|
|
4092
4093
|
inner: space,
|
|
4093
|
-
initialState: metadata.state ===
|
|
4094
|
+
initialState: metadata.state === import_services8.SpaceState.INACTIVE ? import_services8.SpaceState.INACTIVE : import_services8.SpaceState.CLOSED,
|
|
4094
4095
|
metadataStore: this._metadataStore,
|
|
4095
4096
|
gossip,
|
|
4096
4097
|
presence,
|
|
@@ -4102,7 +4103,7 @@ var DataSpaceManager = class {
|
|
|
4102
4103
|
(0, import_log10.log)("before space ready", {
|
|
4103
4104
|
space: space.key
|
|
4104
4105
|
}, {
|
|
4105
|
-
F:
|
|
4106
|
+
F: __dxlog_file12,
|
|
4106
4107
|
L: 265,
|
|
4107
4108
|
S: this,
|
|
4108
4109
|
C: (f, a) => f(...a)
|
|
@@ -4113,7 +4114,7 @@ var DataSpaceManager = class {
|
|
|
4113
4114
|
space: space.key,
|
|
4114
4115
|
open: this._isOpen
|
|
4115
4116
|
}, {
|
|
4116
|
-
F:
|
|
4117
|
+
F: __dxlog_file12,
|
|
4117
4118
|
L: 268,
|
|
4118
4119
|
S: this,
|
|
4119
4120
|
C: (f, a) => f(...a)
|
|
@@ -4126,7 +4127,7 @@ var DataSpaceManager = class {
|
|
|
4126
4127
|
(0, import_log10.log)("before space close", {
|
|
4127
4128
|
space: space.key
|
|
4128
4129
|
}, {
|
|
4129
|
-
F:
|
|
4130
|
+
F: __dxlog_file12,
|
|
4130
4131
|
L: 274,
|
|
4131
4132
|
S: this,
|
|
4132
4133
|
C: (f, a) => f(...a)
|
|
@@ -4136,7 +4137,7 @@ var DataSpaceManager = class {
|
|
|
4136
4137
|
cache: metadata.cache,
|
|
4137
4138
|
automergeHost: this._automergeHost
|
|
4138
4139
|
});
|
|
4139
|
-
if (metadata.state !==
|
|
4140
|
+
if (metadata.state !== import_services8.SpaceState.INACTIVE) {
|
|
4140
4141
|
await dataSpace.open();
|
|
4141
4142
|
}
|
|
4142
4143
|
if (metadata.controlTimeframe) {
|
|
@@ -4161,7 +4162,7 @@ _ts_decorate5([
|
|
|
4161
4162
|
DataSpaceManager = _ts_decorate5([
|
|
4162
4163
|
(0, import_async13.trackLeaks)("open", "close")
|
|
4163
4164
|
], DataSpaceManager);
|
|
4164
|
-
var
|
|
4165
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
4165
4166
|
var SpacesServiceImpl = class {
|
|
4166
4167
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
4167
4168
|
this._identityManager = _identityManager;
|
|
@@ -4178,29 +4179,29 @@ var SpacesServiceImpl = class {
|
|
|
4178
4179
|
}
|
|
4179
4180
|
async updateSpace({ spaceKey, state }) {
|
|
4180
4181
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4181
|
-
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));
|
|
4182
4183
|
if (state) {
|
|
4183
4184
|
switch (state) {
|
|
4184
|
-
case
|
|
4185
|
+
case import_services9.SpaceState.ACTIVE:
|
|
4185
4186
|
await space.activate();
|
|
4186
4187
|
break;
|
|
4187
|
-
case
|
|
4188
|
+
case import_services9.SpaceState.INACTIVE:
|
|
4188
4189
|
await space.deactivate();
|
|
4189
4190
|
break;
|
|
4190
4191
|
default:
|
|
4191
|
-
throw new
|
|
4192
|
+
throw new import_protocols10.ApiError("Invalid space state");
|
|
4192
4193
|
}
|
|
4193
4194
|
}
|
|
4194
4195
|
}
|
|
4195
4196
|
querySpaces() {
|
|
4196
|
-
return new
|
|
4197
|
+
return new import_codec_protobuf10.Stream(({ next, ctx }) => {
|
|
4197
4198
|
const scheduler = new import_async14.UpdateScheduler(ctx, async () => {
|
|
4198
4199
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4199
4200
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
4200
4201
|
(0, import_log11.log)("update", {
|
|
4201
4202
|
spaces
|
|
4202
4203
|
}, {
|
|
4203
|
-
F:
|
|
4204
|
+
F: __dxlog_file13,
|
|
4204
4205
|
L: 77,
|
|
4205
4206
|
S: this,
|
|
4206
4207
|
C: (f, a) => f(...a)
|
|
@@ -4240,14 +4241,14 @@ var SpacesServiceImpl = class {
|
|
|
4240
4241
|
}
|
|
4241
4242
|
async postMessage({ spaceKey, channel, message }) {
|
|
4242
4243
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4243
|
-
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));
|
|
4244
4245
|
await space.postMessage(getChannelId(channel), message);
|
|
4245
4246
|
}
|
|
4246
4247
|
subscribeMessages({ spaceKey, channel }) {
|
|
4247
|
-
return new
|
|
4248
|
+
return new import_codec_protobuf10.Stream(({ ctx, next }) => {
|
|
4248
4249
|
(0, import_async14.scheduleTask)(ctx, async () => {
|
|
4249
4250
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4250
|
-
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));
|
|
4251
4252
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
4252
4253
|
next(message);
|
|
4253
4254
|
});
|
|
@@ -4256,8 +4257,8 @@ var SpacesServiceImpl = class {
|
|
|
4256
4257
|
});
|
|
4257
4258
|
}
|
|
4258
4259
|
queryCredentials({ spaceKey, noTail }) {
|
|
4259
|
-
return new
|
|
4260
|
-
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));
|
|
4261
4262
|
const processor = {
|
|
4262
4263
|
processCredential: async (credential) => {
|
|
4263
4264
|
next(credential);
|
|
@@ -4273,7 +4274,7 @@ var SpacesServiceImpl = class {
|
|
|
4273
4274
|
});
|
|
4274
4275
|
}
|
|
4275
4276
|
async writeCredentials({ spaceKey, credentials }) {
|
|
4276
|
-
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));
|
|
4277
4278
|
for (const credential of credentials ?? []) {
|
|
4278
4279
|
if (credential.proof) {
|
|
4279
4280
|
await space.controlPipeline.writer.write({
|
|
@@ -4282,8 +4283,8 @@ var SpacesServiceImpl = class {
|
|
|
4282
4283
|
}
|
|
4283
4284
|
});
|
|
4284
4285
|
} else {
|
|
4285
|
-
(0,
|
|
4286
|
-
F:
|
|
4286
|
+
(0, import_invariant12.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
4287
|
+
F: __dxlog_file13,
|
|
4287
4288
|
L: 164,
|
|
4288
4289
|
S: this,
|
|
4289
4290
|
A: [
|
|
@@ -4291,8 +4292,8 @@ var SpacesServiceImpl = class {
|
|
|
4291
4292
|
"'Id on unsigned credentials is not allowed'"
|
|
4292
4293
|
]
|
|
4293
4294
|
});
|
|
4294
|
-
(0,
|
|
4295
|
-
F:
|
|
4295
|
+
(0, import_invariant12.invariant)(this._identityManager.identity, "Identity is not available", {
|
|
4296
|
+
F: __dxlog_file13,
|
|
4296
4297
|
L: 165,
|
|
4297
4298
|
S: this,
|
|
4298
4299
|
A: [
|
|
@@ -4301,8 +4302,8 @@ var SpacesServiceImpl = class {
|
|
|
4301
4302
|
]
|
|
4302
4303
|
});
|
|
4303
4304
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
4304
|
-
(0,
|
|
4305
|
-
F:
|
|
4305
|
+
(0, import_invariant12.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
4306
|
+
F: __dxlog_file13,
|
|
4306
4307
|
L: 167,
|
|
4307
4308
|
S: this,
|
|
4308
4309
|
A: [
|
|
@@ -4324,7 +4325,7 @@ var SpacesServiceImpl = class {
|
|
|
4324
4325
|
}
|
|
4325
4326
|
async createEpoch({ spaceKey, migration }) {
|
|
4326
4327
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4327
|
-
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));
|
|
4328
4329
|
await space.createEpoch({
|
|
4329
4330
|
migration
|
|
4330
4331
|
});
|
|
@@ -4333,7 +4334,7 @@ var SpacesServiceImpl = class {
|
|
|
4333
4334
|
return {
|
|
4334
4335
|
spaceKey: space.key,
|
|
4335
4336
|
state: space.state,
|
|
4336
|
-
error: space.error ? (0,
|
|
4337
|
+
error: space.error ? (0, import_protocols10.encodeError)(space.error) : void 0,
|
|
4337
4338
|
pipeline: {
|
|
4338
4339
|
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
4339
4340
|
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
@@ -4358,7 +4359,7 @@ var SpacesServiceImpl = class {
|
|
|
4358
4359
|
identityKey: member.key,
|
|
4359
4360
|
profile: member.profile ?? {}
|
|
4360
4361
|
},
|
|
4361
|
-
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,
|
|
4362
4363
|
peerStates: peers
|
|
4363
4364
|
};
|
|
4364
4365
|
}),
|
|
@@ -4369,7 +4370,7 @@ var SpacesServiceImpl = class {
|
|
|
4369
4370
|
}
|
|
4370
4371
|
};
|
|
4371
4372
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
4372
|
-
var
|
|
4373
|
+
var createSelectedDocumentsIterator = (automergeHost) => (
|
|
4373
4374
|
/**
|
|
4374
4375
|
* Get object data blobs from Automerge Repo by ids.
|
|
4375
4376
|
* @param ids
|
|
@@ -4377,22 +4378,22 @@ var createLoadDocuments = (automergeHost) => (
|
|
|
4377
4378
|
// TODO(mykola): Unload automerge handles after usage.
|
|
4378
4379
|
async function* loadDocuments(ids) {
|
|
4379
4380
|
for (const id of ids) {
|
|
4380
|
-
const { documentId, objectId } =
|
|
4381
|
+
const { documentId, objectId } = import_protocols12.idCodec.decode(id);
|
|
4381
4382
|
const handle = automergeHost.repo.find(documentId);
|
|
4382
4383
|
await (0, import_debug7.warnAfterTimeout)(5e3, "to long to load doc", () => handle.whenReady());
|
|
4383
4384
|
const doc = handle.docSync();
|
|
4384
4385
|
const hash = (0, import_automerge.getHeads)(doc).join("");
|
|
4385
|
-
yield [
|
|
4386
|
+
yield doc.objects?.[objectId] ? [
|
|
4386
4387
|
{
|
|
4387
4388
|
id,
|
|
4388
4389
|
object: doc.objects[objectId],
|
|
4389
4390
|
currentHash: hash
|
|
4390
4391
|
}
|
|
4391
|
-
];
|
|
4392
|
+
] : [];
|
|
4392
4393
|
}
|
|
4393
4394
|
}
|
|
4394
4395
|
);
|
|
4395
|
-
var
|
|
4396
|
+
var createDocumentsIterator = (automergeHost) => (
|
|
4396
4397
|
/**
|
|
4397
4398
|
* Recursively get all object data blobs from Automerge Repo.
|
|
4398
4399
|
* @param ids
|
|
@@ -4410,12 +4411,12 @@ var createGetAllDocuments = (automergeHost) => (
|
|
|
4410
4411
|
if (doc.objects) {
|
|
4411
4412
|
yield Object.entries(doc.objects).map(([objectId, object]) => {
|
|
4412
4413
|
return {
|
|
4413
|
-
id:
|
|
4414
|
+
id: import_protocols12.idCodec.encode({
|
|
4414
4415
|
documentId: handle.documentId,
|
|
4415
4416
|
objectId
|
|
4416
4417
|
}),
|
|
4417
4418
|
object,
|
|
4418
|
-
currentHash: heads.
|
|
4419
|
+
currentHash: heads.join("")
|
|
4419
4420
|
};
|
|
4420
4421
|
});
|
|
4421
4422
|
}
|
|
@@ -4453,18 +4454,20 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4453
4454
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4454
4455
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4455
4456
|
}
|
|
4456
|
-
var
|
|
4457
|
-
var ServiceContext = class {
|
|
4458
|
-
constructor(storage, networkManager, signalManager, _runtimeParams) {
|
|
4457
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
4458
|
+
var ServiceContext = class extends import_context10.Resource {
|
|
4459
|
+
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
4460
|
+
super();
|
|
4459
4461
|
this.storage = storage;
|
|
4462
|
+
this.level = level;
|
|
4460
4463
|
this.networkManager = networkManager;
|
|
4461
4464
|
this.signalManager = signalManager;
|
|
4462
4465
|
this._runtimeParams = _runtimeParams;
|
|
4463
4466
|
this.initialized = new import_async15.Trigger();
|
|
4464
4467
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4465
4468
|
this._instanceId = import_keys10.PublicKey.random().toHex();
|
|
4466
|
-
this.metadataStore = new
|
|
4467
|
-
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"));
|
|
4468
4471
|
this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
|
|
4469
4472
|
this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
|
|
4470
4473
|
this.feedStore = new import_feed_store4.FeedStore({
|
|
@@ -4472,12 +4475,12 @@ var ServiceContext = class {
|
|
|
4472
4475
|
root: storage.createDirectory("feeds"),
|
|
4473
4476
|
signer: this.keyring,
|
|
4474
4477
|
hypercore: {
|
|
4475
|
-
valueEncoding:
|
|
4478
|
+
valueEncoding: import_echo_pipeline4.valueEncoding,
|
|
4476
4479
|
stats: true
|
|
4477
4480
|
}
|
|
4478
4481
|
})
|
|
4479
4482
|
});
|
|
4480
|
-
this.spaceManager = new
|
|
4483
|
+
this.spaceManager = new import_echo_pipeline4.SpaceManager({
|
|
4481
4484
|
feedStore: this.feedStore,
|
|
4482
4485
|
networkManager: this.networkManager,
|
|
4483
4486
|
blobStore: this.blobStore,
|
|
@@ -4486,66 +4489,71 @@ var ServiceContext = class {
|
|
|
4486
4489
|
});
|
|
4487
4490
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
4488
4491
|
this.indexMetadata = new import_indexing.IndexMetadataStore({
|
|
4489
|
-
|
|
4492
|
+
db: level.sublevel("index-metadata")
|
|
4490
4493
|
});
|
|
4491
|
-
this.automergeHost = new
|
|
4494
|
+
this.automergeHost = new import_echo_pipeline4.AutomergeHost({
|
|
4492
4495
|
directory: storage.createDirectory("automerge"),
|
|
4493
|
-
|
|
4496
|
+
db: level.sublevel("automerge"),
|
|
4497
|
+
storageCallbacks: (0, import_indexing.createStorageCallbacks)({
|
|
4498
|
+
host: () => this.automergeHost,
|
|
4499
|
+
metadata: this.indexMetadata
|
|
4500
|
+
})
|
|
4494
4501
|
});
|
|
4495
4502
|
this.indexer = new import_indexing.Indexer({
|
|
4496
4503
|
indexStore: new import_indexing.IndexStore({
|
|
4497
|
-
|
|
4504
|
+
db: level.sublevel("index-storage")
|
|
4498
4505
|
}),
|
|
4499
4506
|
metadataStore: this.indexMetadata,
|
|
4500
|
-
loadDocuments:
|
|
4501
|
-
getAllDocuments:
|
|
4507
|
+
loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
|
|
4508
|
+
getAllDocuments: createDocumentsIterator(this.automergeHost)
|
|
4502
4509
|
});
|
|
4503
4510
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4504
|
-
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)));
|
|
4505
4512
|
}
|
|
4506
|
-
async
|
|
4513
|
+
async _open(ctx) {
|
|
4507
4514
|
await this._checkStorageVersion();
|
|
4508
4515
|
(0, import_log12.log)("opening...", void 0, {
|
|
4509
|
-
F:
|
|
4510
|
-
L:
|
|
4516
|
+
F: __dxlog_file14,
|
|
4517
|
+
L: 157,
|
|
4511
4518
|
S: this,
|
|
4512
4519
|
C: (f, a) => f(...a)
|
|
4513
4520
|
});
|
|
4514
|
-
import_log12.log.trace("dxos.sdk.service-context.open",
|
|
4521
|
+
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.begin({
|
|
4515
4522
|
id: this._instanceId
|
|
4516
4523
|
}), {
|
|
4517
|
-
F:
|
|
4518
|
-
L:
|
|
4524
|
+
F: __dxlog_file14,
|
|
4525
|
+
L: 158,
|
|
4519
4526
|
S: this,
|
|
4520
4527
|
C: (f, a) => f(...a)
|
|
4521
4528
|
});
|
|
4522
4529
|
await this.signalManager.open();
|
|
4523
4530
|
await this.networkManager.open();
|
|
4531
|
+
await this.automergeHost.open();
|
|
4524
4532
|
await this.metadataStore.load();
|
|
4525
4533
|
await this.spaceManager.open();
|
|
4526
4534
|
await this.identityManager.open(ctx);
|
|
4527
4535
|
if (this.identityManager.identity) {
|
|
4528
4536
|
await this._initialize(ctx);
|
|
4529
4537
|
}
|
|
4530
|
-
import_log12.log.trace("dxos.sdk.service-context.open",
|
|
4538
|
+
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.end({
|
|
4531
4539
|
id: this._instanceId
|
|
4532
4540
|
}), {
|
|
4533
|
-
F:
|
|
4534
|
-
L:
|
|
4541
|
+
F: __dxlog_file14,
|
|
4542
|
+
L: 169,
|
|
4535
4543
|
S: this,
|
|
4536
4544
|
C: (f, a) => f(...a)
|
|
4537
4545
|
});
|
|
4538
4546
|
(0, import_log12.log)("opened", void 0, {
|
|
4539
|
-
F:
|
|
4540
|
-
L:
|
|
4547
|
+
F: __dxlog_file14,
|
|
4548
|
+
L: 170,
|
|
4541
4549
|
S: this,
|
|
4542
4550
|
C: (f, a) => f(...a)
|
|
4543
4551
|
});
|
|
4544
4552
|
}
|
|
4545
|
-
async
|
|
4553
|
+
async _close() {
|
|
4546
4554
|
(0, import_log12.log)("closing...", void 0, {
|
|
4547
|
-
F:
|
|
4548
|
-
L:
|
|
4555
|
+
F: __dxlog_file14,
|
|
4556
|
+
L: 174,
|
|
4549
4557
|
S: this,
|
|
4550
4558
|
C: (f, a) => f(...a)
|
|
4551
4559
|
});
|
|
@@ -4562,8 +4570,8 @@ var ServiceContext = class {
|
|
|
4562
4570
|
await this.metadataStore.close();
|
|
4563
4571
|
await this.indexer.destroy();
|
|
4564
4572
|
(0, import_log12.log)("closed", void 0, {
|
|
4565
|
-
F:
|
|
4566
|
-
L:
|
|
4573
|
+
F: __dxlog_file14,
|
|
4574
|
+
L: 187,
|
|
4567
4575
|
S: this,
|
|
4568
4576
|
C: (f, a) => f(...a)
|
|
4569
4577
|
});
|
|
@@ -4575,9 +4583,9 @@ var ServiceContext = class {
|
|
|
4575
4583
|
}
|
|
4576
4584
|
getInvitationHandler(invitation) {
|
|
4577
4585
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4578
|
-
(0,
|
|
4579
|
-
F:
|
|
4580
|
-
L:
|
|
4586
|
+
(0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4587
|
+
F: __dxlog_file14,
|
|
4588
|
+
L: 198,
|
|
4581
4589
|
S: this,
|
|
4582
4590
|
A: [
|
|
4583
4591
|
"factory",
|
|
@@ -4601,15 +4609,15 @@ var ServiceContext = class {
|
|
|
4601
4609
|
}
|
|
4602
4610
|
async _checkStorageVersion() {
|
|
4603
4611
|
await this.metadataStore.load();
|
|
4604
|
-
if (this.metadataStore.version !==
|
|
4605
|
-
throw new
|
|
4612
|
+
if (this.metadataStore.version !== import_protocols11.STORAGE_VERSION) {
|
|
4613
|
+
throw new import_protocols11.InvalidStorageVersionError(import_protocols11.STORAGE_VERSION, this.metadataStore.version);
|
|
4606
4614
|
}
|
|
4607
4615
|
}
|
|
4608
4616
|
// Called when identity is created.
|
|
4609
4617
|
async _initialize(ctx) {
|
|
4610
4618
|
(0, import_log12.log)("initializing spaces...", void 0, {
|
|
4611
|
-
F:
|
|
4612
|
-
L:
|
|
4619
|
+
F: __dxlog_file14,
|
|
4620
|
+
L: 229,
|
|
4613
4621
|
S: this,
|
|
4614
4622
|
C: (f, a) => f(...a)
|
|
4615
4623
|
});
|
|
@@ -4629,10 +4637,10 @@ var ServiceContext = class {
|
|
|
4629
4637
|
};
|
|
4630
4638
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
|
|
4631
4639
|
await this.dataSpaceManager.open();
|
|
4632
|
-
this._handlerFactories.set(
|
|
4633
|
-
(0,
|
|
4634
|
-
F:
|
|
4635
|
-
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,
|
|
4636
4644
|
S: this,
|
|
4637
4645
|
A: [
|
|
4638
4646
|
"this.dataSpaceManager",
|
|
@@ -4644,7 +4652,7 @@ var ServiceContext = class {
|
|
|
4644
4652
|
this.initialized.wake();
|
|
4645
4653
|
this._deviceSpaceSync = {
|
|
4646
4654
|
processCredential: async (credential) => {
|
|
4647
|
-
const assertion = (0,
|
|
4655
|
+
const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
|
|
4648
4656
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
4649
4657
|
return;
|
|
4650
4658
|
}
|
|
@@ -4655,8 +4663,8 @@ var ServiceContext = class {
|
|
|
4655
4663
|
(0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
4656
4664
|
details: assertion
|
|
4657
4665
|
}, {
|
|
4658
|
-
F:
|
|
4659
|
-
L:
|
|
4666
|
+
F: __dxlog_file14,
|
|
4667
|
+
L: 269,
|
|
4660
4668
|
S: this,
|
|
4661
4669
|
C: (f, a) => f(...a)
|
|
4662
4670
|
});
|
|
@@ -4666,8 +4674,8 @@ var ServiceContext = class {
|
|
|
4666
4674
|
(0, import_log12.log)("space already exists, ignoring space admission", {
|
|
4667
4675
|
details: assertion
|
|
4668
4676
|
}, {
|
|
4669
|
-
F:
|
|
4670
|
-
L:
|
|
4677
|
+
F: __dxlog_file14,
|
|
4678
|
+
L: 273,
|
|
4671
4679
|
S: this,
|
|
4672
4680
|
C: (f, a) => f(...a)
|
|
4673
4681
|
});
|
|
@@ -4677,8 +4685,8 @@ var ServiceContext = class {
|
|
|
4677
4685
|
(0, import_log12.log)("accepting space recorded in halo", {
|
|
4678
4686
|
details: assertion
|
|
4679
4687
|
}, {
|
|
4680
|
-
F:
|
|
4681
|
-
L:
|
|
4688
|
+
F: __dxlog_file14,
|
|
4689
|
+
L: 278,
|
|
4682
4690
|
S: this,
|
|
4683
4691
|
C: (f, a) => f(...a)
|
|
4684
4692
|
});
|
|
@@ -4688,8 +4696,8 @@ var ServiceContext = class {
|
|
|
4688
4696
|
});
|
|
4689
4697
|
} catch (err) {
|
|
4690
4698
|
import_log12.log.catch(err, void 0, {
|
|
4691
|
-
F:
|
|
4692
|
-
L:
|
|
4699
|
+
F: __dxlog_file14,
|
|
4700
|
+
L: 284,
|
|
4693
4701
|
S: this,
|
|
4694
4702
|
C: (f, a) => f(...a)
|
|
4695
4703
|
});
|
|
@@ -4700,14 +4708,14 @@ var ServiceContext = class {
|
|
|
4700
4708
|
}
|
|
4701
4709
|
};
|
|
4702
4710
|
_ts_decorate6([
|
|
4703
|
-
|
|
4704
|
-
], ServiceContext.prototype, "
|
|
4711
|
+
import_tracing5.trace.span()
|
|
4712
|
+
], ServiceContext.prototype, "_open", null);
|
|
4705
4713
|
_ts_decorate6([
|
|
4706
|
-
|
|
4714
|
+
import_tracing5.trace.span()
|
|
4707
4715
|
], ServiceContext.prototype, "_initialize", null);
|
|
4708
4716
|
ServiceContext = _ts_decorate6([
|
|
4709
4717
|
(0, import_util7.safeInstanceof)("dxos.client-services.ServiceContext"),
|
|
4710
|
-
|
|
4718
|
+
import_tracing5.trace.resource()
|
|
4711
4719
|
], ServiceContext);
|
|
4712
4720
|
var ServiceRegistry = class {
|
|
4713
4721
|
// prettier-ignore
|
|
@@ -4731,103 +4739,155 @@ var ServiceRegistry = class {
|
|
|
4731
4739
|
delete this._handlers[name];
|
|
4732
4740
|
}
|
|
4733
4741
|
};
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
if (
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
}
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
}
|
|
4751
|
-
|
|
4752
|
-
return
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
});
|
|
4761
|
-
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
4762
|
-
await this._onAcquire?.();
|
|
4763
|
-
(0, import_log13.log)("acquired lock", void 0, {
|
|
4764
|
-
F: __dxlog_file16,
|
|
4765
|
-
L: 37,
|
|
4766
|
-
S: this,
|
|
4767
|
-
C: (f, a) => f(...a)
|
|
4768
|
-
});
|
|
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
|
+
};
|
|
4769
4768
|
}
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
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,
|
|
4776
4789
|
A: [
|
|
4777
|
-
"
|
|
4778
|
-
"'
|
|
4790
|
+
"clientServices.LoggingService",
|
|
4791
|
+
"'SystemService is not available.'"
|
|
4779
4792
|
]
|
|
4780
4793
|
});
|
|
4781
|
-
await
|
|
4782
|
-
|
|
4783
|
-
};
|
|
4784
|
-
_ts_decorate7([
|
|
4785
|
-
import_log13.logInfo
|
|
4786
|
-
], Lock.prototype, "lockKey", null);
|
|
4787
|
-
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
4788
|
-
var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
4789
|
-
var createStorageObjects = (config) => {
|
|
4790
|
-
const { persistent = false, keyStore, dataStore, dataRoot = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage" } = config ?? {};
|
|
4791
|
-
if (persistent && dataStore === StorageDriver.RAM) {
|
|
4792
|
-
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);
|
|
4793
4797
|
}
|
|
4794
|
-
if (
|
|
4795
|
-
|
|
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
|
+
}));
|
|
4796
4812
|
}
|
|
4797
|
-
|
|
4798
|
-
|
|
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;
|
|
4799
4840
|
}
|
|
4800
|
-
|
|
4801
|
-
|
|
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();
|
|
4802
4874
|
}
|
|
4875
|
+
return stats;
|
|
4876
|
+
};
|
|
4877
|
+
var createCollectDiagnosticsBroadcastSender = () => {
|
|
4803
4878
|
return {
|
|
4804
|
-
|
|
4805
|
-
type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
|
|
4806
|
-
root: `${dataRoot}/`
|
|
4807
|
-
})
|
|
4879
|
+
broadcastDiagnosticsRequest: async () => void 0
|
|
4808
4880
|
};
|
|
4809
4881
|
};
|
|
4810
|
-
var
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
return import_random_access_storage.StorageType.CHROME;
|
|
4818
|
-
case StorageDriver.FIREFOX:
|
|
4819
|
-
return import_random_access_storage.StorageType.FIREFOX;
|
|
4820
|
-
case StorageDriver.IDB:
|
|
4821
|
-
return import_random_access_storage.StorageType.IDB;
|
|
4822
|
-
case StorageDriver.NODE:
|
|
4823
|
-
return import_random_access_storage.StorageType.NODE;
|
|
4824
|
-
case StorageDriver.WEBFS:
|
|
4825
|
-
return import_random_access_storage.StorageType.WEBFS;
|
|
4826
|
-
default:
|
|
4827
|
-
throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
|
|
4828
|
-
}
|
|
4882
|
+
var createCollectDiagnosticsBroadcastHandler = (_) => {
|
|
4883
|
+
return {
|
|
4884
|
+
start: () => {
|
|
4885
|
+
},
|
|
4886
|
+
stop: () => {
|
|
4887
|
+
}
|
|
4888
|
+
};
|
|
4829
4889
|
};
|
|
4830
|
-
var
|
|
4890
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
4831
4891
|
var DevicesServiceImpl = class {
|
|
4832
4892
|
constructor(_identityManager) {
|
|
4833
4893
|
this._identityManager = _identityManager;
|
|
@@ -4844,8 +4904,8 @@ var DevicesServiceImpl = class {
|
|
|
4844
4904
|
devices: []
|
|
4845
4905
|
});
|
|
4846
4906
|
} else {
|
|
4847
|
-
(0,
|
|
4848
|
-
F:
|
|
4907
|
+
(0, import_invariant16.invariant)(this._identityManager.identity?.presence, "presence not present", {
|
|
4908
|
+
F: __dxlog_file16,
|
|
4849
4909
|
L: 32,
|
|
4850
4910
|
S: this,
|
|
4851
4911
|
A: [
|
|
@@ -4860,9 +4920,9 @@ var DevicesServiceImpl = class {
|
|
|
4860
4920
|
const peerState = peers.find((peer) => peer.identityKey.equals(key));
|
|
4861
4921
|
return {
|
|
4862
4922
|
deviceKey: key,
|
|
4863
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ?
|
|
4923
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services15.DeviceKind.CURRENT : import_services15.DeviceKind.TRUSTED,
|
|
4864
4924
|
profile,
|
|
4865
|
-
presence: isMe ?
|
|
4925
|
+
presence: isMe ? import_services15.Device.PresenceState.ONLINE : peerState ? import_services15.Device.PresenceState.ONLINE : import_services15.Device.PresenceState.OFFLINE
|
|
4866
4926
|
};
|
|
4867
4927
|
})
|
|
4868
4928
|
});
|
|
@@ -4903,6 +4963,60 @@ var DevicesServiceImpl = class {
|
|
|
4903
4963
|
});
|
|
4904
4964
|
}
|
|
4905
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);
|
|
4906
5020
|
var LoggingServiceImpl = class {
|
|
4907
5021
|
constructor() {
|
|
4908
5022
|
this._logs = new import_async18.Event();
|
|
@@ -5002,18 +5116,18 @@ var LoggingServiceImpl = class {
|
|
|
5002
5116
|
});
|
|
5003
5117
|
}
|
|
5004
5118
|
};
|
|
5005
|
-
var matchFilter = (filter, level,
|
|
5119
|
+
var matchFilter = (filter, level, path2, options) => {
|
|
5006
5120
|
switch (options) {
|
|
5007
|
-
case
|
|
5008
|
-
return level >= filter.level && (!filter.pattern ||
|
|
5009
|
-
case
|
|
5010
|
-
return level === filter.level && (!filter.pattern ||
|
|
5121
|
+
case import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
5122
|
+
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5123
|
+
case import_services16.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
5124
|
+
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5011
5125
|
}
|
|
5012
5126
|
};
|
|
5013
5127
|
var shouldLog = (entry2, request) => {
|
|
5014
|
-
const options = request.options ??
|
|
5128
|
+
const options = request.options ?? import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5015
5129
|
if (request.filters === void 0) {
|
|
5016
|
-
return options ===
|
|
5130
|
+
return options === import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5017
5131
|
} else {
|
|
5018
5132
|
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
5019
5133
|
}
|
|
@@ -5049,6 +5163,63 @@ var NetworkServiceImpl = class {
|
|
|
5049
5163
|
await this.networkManager.setConnectionState(request.swarm);
|
|
5050
5164
|
}
|
|
5051
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
|
+
};
|
|
5052
5223
|
var SystemServiceImpl = class {
|
|
5053
5224
|
constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
5054
5225
|
this._config = config;
|
|
@@ -5068,9 +5239,9 @@ var SystemServiceImpl = class {
|
|
|
5068
5239
|
const diagnostics = await this._getDiagnostics();
|
|
5069
5240
|
return {
|
|
5070
5241
|
timestamp: /* @__PURE__ */ new Date(),
|
|
5071
|
-
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0,
|
|
5072
|
-
truncate: keys ===
|
|
5073
|
-
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
|
|
5074
5245
|
})))
|
|
5075
5246
|
};
|
|
5076
5247
|
}
|
|
@@ -5118,16 +5289,18 @@ var ClientServicesHost = class {
|
|
|
5118
5289
|
transportFactory,
|
|
5119
5290
|
signalManager,
|
|
5120
5291
|
storage,
|
|
5292
|
+
level,
|
|
5121
5293
|
// TODO(wittjosiah): Turn this on by default.
|
|
5122
5294
|
lockKey,
|
|
5123
5295
|
callbacks,
|
|
5124
5296
|
runtimeParams
|
|
5125
5297
|
} = {}) {
|
|
5126
|
-
this._tracingService =
|
|
5298
|
+
this._tracingService = import_tracing8.TRACE_PROCESSOR.createTraceSender();
|
|
5127
5299
|
this._statusUpdate = new import_async16.Event();
|
|
5128
5300
|
this._opening = false;
|
|
5129
5301
|
this._open = false;
|
|
5130
5302
|
this._storage = storage;
|
|
5303
|
+
this._level = level;
|
|
5131
5304
|
this._callbacks = callbacks;
|
|
5132
5305
|
this._runtimeParams = runtimeParams;
|
|
5133
5306
|
if (config) {
|
|
@@ -5151,14 +5324,14 @@ var ClientServicesHost = class {
|
|
|
5151
5324
|
this._systemService = new SystemServiceImpl({
|
|
5152
5325
|
config: () => this._config,
|
|
5153
5326
|
statusUpdate: this._statusUpdate,
|
|
5154
|
-
getCurrentStatus: () => this.isOpen ?
|
|
5327
|
+
getCurrentStatus: () => this.isOpen ? import_services14.SystemStatus.ACTIVE : import_services14.SystemStatus.INACTIVE,
|
|
5155
5328
|
getDiagnostics: () => {
|
|
5156
5329
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
5157
5330
|
},
|
|
5158
5331
|
onUpdateStatus: async (status) => {
|
|
5159
|
-
if (!this.isOpen && status ===
|
|
5332
|
+
if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
|
|
5160
5333
|
await this._resourceLock?.acquire();
|
|
5161
|
-
} else if (this.isOpen && status ===
|
|
5334
|
+
} else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
|
|
5162
5335
|
await this._resourceLock?.release();
|
|
5163
5336
|
}
|
|
5164
5337
|
},
|
|
@@ -5166,8 +5339,9 @@ var ClientServicesHost = class {
|
|
|
5166
5339
|
await this.reset();
|
|
5167
5340
|
}
|
|
5168
5341
|
});
|
|
5342
|
+
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
5169
5343
|
this._loggingService = new LoggingServiceImpl();
|
|
5170
|
-
this._serviceRegistry = new ServiceRegistry(
|
|
5344
|
+
this._serviceRegistry = new ServiceRegistry(import_client_protocol4.clientServiceBundle, {
|
|
5171
5345
|
SystemService: this._systemService,
|
|
5172
5346
|
TracingService: this._tracingService
|
|
5173
5347
|
});
|
|
@@ -5196,25 +5370,25 @@ var ClientServicesHost = class {
|
|
|
5196
5370
|
* Can only be called once.
|
|
5197
5371
|
*/
|
|
5198
5372
|
initialize({ config, ...options }) {
|
|
5199
|
-
(0,
|
|
5373
|
+
(0, import_invariant15.invariant)(!this._open, "service host is open", {
|
|
5200
5374
|
F: __dxlog_file18,
|
|
5201
|
-
L:
|
|
5375
|
+
L: 197,
|
|
5202
5376
|
S: this,
|
|
5203
5377
|
A: [
|
|
5204
5378
|
"!this._open",
|
|
5205
5379
|
"'service host is open'"
|
|
5206
5380
|
]
|
|
5207
5381
|
});
|
|
5208
|
-
(0,
|
|
5382
|
+
(0, import_log13.log)("initializing...", void 0, {
|
|
5209
5383
|
F: __dxlog_file18,
|
|
5210
|
-
L:
|
|
5384
|
+
L: 198,
|
|
5211
5385
|
S: this,
|
|
5212
5386
|
C: (f, a) => f(...a)
|
|
5213
5387
|
});
|
|
5214
5388
|
if (config) {
|
|
5215
|
-
(0,
|
|
5389
|
+
(0, import_invariant15.invariant)(!this._config, "config already set", {
|
|
5216
5390
|
F: __dxlog_file18,
|
|
5217
|
-
L:
|
|
5391
|
+
L: 201,
|
|
5218
5392
|
S: this,
|
|
5219
5393
|
A: [
|
|
5220
5394
|
"!this._config",
|
|
@@ -5226,13 +5400,21 @@ var ClientServicesHost = class {
|
|
|
5226
5400
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
5227
5401
|
}
|
|
5228
5402
|
}
|
|
5403
|
+
if (!options.signalManager) {
|
|
5404
|
+
import_log13.log.warn("running signaling without telemetry metadata.", void 0, {
|
|
5405
|
+
F: __dxlog_file18,
|
|
5406
|
+
L: 209,
|
|
5407
|
+
S: this,
|
|
5408
|
+
C: (f, a) => f(...a)
|
|
5409
|
+
});
|
|
5410
|
+
}
|
|
5229
5411
|
const { connectionLog = true, transportFactory = (0, import_network_manager2.createSimplePeerTransportFactory)({
|
|
5230
5412
|
iceServers: this._config?.get("runtime.services.ice")
|
|
5231
5413
|
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
5232
5414
|
this._signalManager = signalManager;
|
|
5233
|
-
(0,
|
|
5415
|
+
(0, import_invariant15.invariant)(!this._networkManager, "network manager already set", {
|
|
5234
5416
|
F: __dxlog_file18,
|
|
5235
|
-
L:
|
|
5417
|
+
L: 220,
|
|
5236
5418
|
S: this,
|
|
5237
5419
|
A: [
|
|
5238
5420
|
"!this._networkManager",
|
|
@@ -5244,9 +5426,9 @@ var ClientServicesHost = class {
|
|
|
5244
5426
|
transportFactory,
|
|
5245
5427
|
signalManager
|
|
5246
5428
|
});
|
|
5247
|
-
(0,
|
|
5429
|
+
(0, import_log13.log)("initialized", void 0, {
|
|
5248
5430
|
F: __dxlog_file18,
|
|
5249
|
-
L:
|
|
5431
|
+
L: 227,
|
|
5250
5432
|
S: this,
|
|
5251
5433
|
C: (f, a) => f(...a)
|
|
5252
5434
|
});
|
|
@@ -5256,44 +5438,44 @@ var ClientServicesHost = class {
|
|
|
5256
5438
|
return;
|
|
5257
5439
|
}
|
|
5258
5440
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
5259
|
-
|
|
5441
|
+
import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.begin({
|
|
5260
5442
|
id: traceId
|
|
5261
5443
|
}), {
|
|
5262
5444
|
F: __dxlog_file18,
|
|
5263
|
-
L:
|
|
5445
|
+
L: 238,
|
|
5264
5446
|
S: this,
|
|
5265
5447
|
C: (f, a) => f(...a)
|
|
5266
5448
|
});
|
|
5267
|
-
(0,
|
|
5449
|
+
(0, import_invariant15.invariant)(this._config, "config not set", {
|
|
5268
5450
|
F: __dxlog_file18,
|
|
5269
|
-
L:
|
|
5451
|
+
L: 240,
|
|
5270
5452
|
S: this,
|
|
5271
5453
|
A: [
|
|
5272
5454
|
"this._config",
|
|
5273
5455
|
"'config not set'"
|
|
5274
5456
|
]
|
|
5275
5457
|
});
|
|
5276
|
-
(0,
|
|
5458
|
+
(0, import_invariant15.invariant)(this._storage, "storage not set", {
|
|
5277
5459
|
F: __dxlog_file18,
|
|
5278
|
-
L:
|
|
5460
|
+
L: 241,
|
|
5279
5461
|
S: this,
|
|
5280
5462
|
A: [
|
|
5281
5463
|
"this._storage",
|
|
5282
5464
|
"'storage not set'"
|
|
5283
5465
|
]
|
|
5284
5466
|
});
|
|
5285
|
-
(0,
|
|
5467
|
+
(0, import_invariant15.invariant)(this._signalManager, "signal manager not set", {
|
|
5286
5468
|
F: __dxlog_file18,
|
|
5287
|
-
L:
|
|
5469
|
+
L: 242,
|
|
5288
5470
|
S: this,
|
|
5289
5471
|
A: [
|
|
5290
5472
|
"this._signalManager",
|
|
5291
5473
|
"'signal manager not set'"
|
|
5292
5474
|
]
|
|
5293
5475
|
});
|
|
5294
|
-
(0,
|
|
5476
|
+
(0, import_invariant15.invariant)(this._networkManager, "network manager not set", {
|
|
5295
5477
|
F: __dxlog_file18,
|
|
5296
|
-
L:
|
|
5478
|
+
L: 243,
|
|
5297
5479
|
S: this,
|
|
5298
5480
|
A: [
|
|
5299
5481
|
"this._networkManager",
|
|
@@ -5301,17 +5483,21 @@ var ClientServicesHost = class {
|
|
|
5301
5483
|
]
|
|
5302
5484
|
});
|
|
5303
5485
|
this._opening = true;
|
|
5304
|
-
(0,
|
|
5486
|
+
(0, import_log13.log)("opening...", {
|
|
5305
5487
|
lockKey: this._resourceLock?.lockKey
|
|
5306
5488
|
}, {
|
|
5307
5489
|
F: __dxlog_file18,
|
|
5308
|
-
L:
|
|
5490
|
+
L: 246,
|
|
5309
5491
|
S: this,
|
|
5310
5492
|
C: (f, a) => f(...a)
|
|
5311
5493
|
});
|
|
5494
|
+
if (!this._level) {
|
|
5495
|
+
this._level = await createLevel(this._config.get("runtime.client.storage", {}));
|
|
5496
|
+
}
|
|
5497
|
+
await this._level.open();
|
|
5312
5498
|
await this._resourceLock?.acquire();
|
|
5313
5499
|
await this._loggingService.open();
|
|
5314
|
-
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._runtimeParams);
|
|
5500
|
+
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
|
|
5315
5501
|
this._serviceRegistry.setServices({
|
|
5316
5502
|
SystemService: this._systemService,
|
|
5317
5503
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
@@ -5321,7 +5507,7 @@ var ClientServicesHost = class {
|
|
|
5321
5507
|
await this._serviceContext.initialized.wait();
|
|
5322
5508
|
return this._serviceContext.dataSpaceManager;
|
|
5323
5509
|
}),
|
|
5324
|
-
DataService: new
|
|
5510
|
+
DataService: new import_echo_pipeline5.DataServiceImpl(this._serviceContext.automergeHost),
|
|
5325
5511
|
IndexService: new import_indexing2.IndexServiceImpl({
|
|
5326
5512
|
indexer: this._serviceContext.indexer,
|
|
5327
5513
|
automergeHost: this._serviceContext.automergeHost
|
|
@@ -5337,9 +5523,9 @@ var ClientServicesHost = class {
|
|
|
5337
5523
|
})
|
|
5338
5524
|
});
|
|
5339
5525
|
await this._serviceContext.open(ctx);
|
|
5340
|
-
(0,
|
|
5526
|
+
(0, import_invariant15.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5341
5527
|
F: __dxlog_file18,
|
|
5342
|
-
L:
|
|
5528
|
+
L: 314,
|
|
5343
5529
|
S: this,
|
|
5344
5530
|
A: [
|
|
5345
5531
|
"this.serviceRegistry.services.InvitationsService",
|
|
@@ -5347,11 +5533,11 @@ var ClientServicesHost = class {
|
|
|
5347
5533
|
]
|
|
5348
5534
|
});
|
|
5349
5535
|
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5350
|
-
(0,
|
|
5536
|
+
(0, import_log13.log)("loaded persistent invitations", {
|
|
5351
5537
|
count: loadedInvitations.invitations?.length
|
|
5352
5538
|
}, {
|
|
5353
5539
|
F: __dxlog_file18,
|
|
5354
|
-
L:
|
|
5540
|
+
L: 317,
|
|
5355
5541
|
S: this,
|
|
5356
5542
|
C: (f, a) => f(...a)
|
|
5357
5543
|
});
|
|
@@ -5360,28 +5546,29 @@ var ClientServicesHost = class {
|
|
|
5360
5546
|
this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
|
|
5361
5547
|
url: devtoolsProxy,
|
|
5362
5548
|
requested: {},
|
|
5363
|
-
exposed:
|
|
5549
|
+
exposed: import_client_protocol4.clientServiceBundle,
|
|
5364
5550
|
handlers: this.services
|
|
5365
5551
|
});
|
|
5366
5552
|
void this._devtoolsProxy.open();
|
|
5367
5553
|
}
|
|
5554
|
+
this.diagnosticsBroadcastHandler.start();
|
|
5368
5555
|
this._opening = false;
|
|
5369
5556
|
this._open = true;
|
|
5370
5557
|
this._statusUpdate.emit();
|
|
5371
5558
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5372
|
-
(0,
|
|
5559
|
+
(0, import_log13.log)("opened", {
|
|
5373
5560
|
deviceKey
|
|
5374
5561
|
}, {
|
|
5375
5562
|
F: __dxlog_file18,
|
|
5376
|
-
L:
|
|
5563
|
+
L: 335,
|
|
5377
5564
|
S: this,
|
|
5378
5565
|
C: (f, a) => f(...a)
|
|
5379
5566
|
});
|
|
5380
|
-
|
|
5567
|
+
import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.end({
|
|
5381
5568
|
id: traceId
|
|
5382
5569
|
}), {
|
|
5383
5570
|
F: __dxlog_file18,
|
|
5384
|
-
L:
|
|
5571
|
+
L: 336,
|
|
5385
5572
|
S: this,
|
|
5386
5573
|
C: (f, a) => f(...a)
|
|
5387
5574
|
});
|
|
@@ -5391,60 +5578,62 @@ var ClientServicesHost = class {
|
|
|
5391
5578
|
return;
|
|
5392
5579
|
}
|
|
5393
5580
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5394
|
-
(0,
|
|
5581
|
+
(0, import_log13.log)("closing...", {
|
|
5395
5582
|
deviceKey
|
|
5396
5583
|
}, {
|
|
5397
5584
|
F: __dxlog_file18,
|
|
5398
|
-
L:
|
|
5585
|
+
L: 347,
|
|
5399
5586
|
S: this,
|
|
5400
5587
|
C: (f, a) => f(...a)
|
|
5401
5588
|
});
|
|
5589
|
+
this.diagnosticsBroadcastHandler.stop();
|
|
5402
5590
|
await this._devtoolsProxy?.close();
|
|
5403
5591
|
this._serviceRegistry.setServices({
|
|
5404
5592
|
SystemService: this._systemService
|
|
5405
5593
|
});
|
|
5406
5594
|
await this._loggingService.close();
|
|
5407
5595
|
await this._serviceContext.close();
|
|
5596
|
+
await this._level?.close();
|
|
5408
5597
|
this._open = false;
|
|
5409
5598
|
this._statusUpdate.emit();
|
|
5410
|
-
(0,
|
|
5599
|
+
(0, import_log13.log)("closed", {
|
|
5411
5600
|
deviceKey
|
|
5412
5601
|
}, {
|
|
5413
5602
|
F: __dxlog_file18,
|
|
5414
|
-
L:
|
|
5603
|
+
L: 356,
|
|
5415
5604
|
S: this,
|
|
5416
5605
|
C: (f, a) => f(...a)
|
|
5417
5606
|
});
|
|
5418
5607
|
}
|
|
5419
5608
|
async reset() {
|
|
5420
5609
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
5421
|
-
|
|
5610
|
+
import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.begin({
|
|
5422
5611
|
id: traceId
|
|
5423
5612
|
}), {
|
|
5424
5613
|
F: __dxlog_file18,
|
|
5425
|
-
L:
|
|
5614
|
+
L: 361,
|
|
5426
5615
|
S: this,
|
|
5427
5616
|
C: (f, a) => f(...a)
|
|
5428
5617
|
});
|
|
5429
|
-
(0,
|
|
5618
|
+
(0, import_log13.log)("resetting...", void 0, {
|
|
5430
5619
|
F: __dxlog_file18,
|
|
5431
|
-
L:
|
|
5620
|
+
L: 363,
|
|
5432
5621
|
S: this,
|
|
5433
5622
|
C: (f, a) => f(...a)
|
|
5434
5623
|
});
|
|
5435
5624
|
await this._serviceContext?.close();
|
|
5436
5625
|
await this._storage.reset();
|
|
5437
|
-
(0,
|
|
5626
|
+
(0, import_log13.log)("reset", void 0, {
|
|
5438
5627
|
F: __dxlog_file18,
|
|
5439
|
-
L:
|
|
5628
|
+
L: 366,
|
|
5440
5629
|
S: this,
|
|
5441
5630
|
C: (f, a) => f(...a)
|
|
5442
5631
|
});
|
|
5443
|
-
|
|
5632
|
+
import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.end({
|
|
5444
5633
|
id: traceId
|
|
5445
5634
|
}), {
|
|
5446
5635
|
F: __dxlog_file18,
|
|
5447
|
-
L:
|
|
5636
|
+
L: 367,
|
|
5448
5637
|
S: this,
|
|
5449
5638
|
C: (f, a) => f(...a)
|
|
5450
5639
|
});
|
|
@@ -5454,12 +5643,10 @@ var ClientServicesHost = class {
|
|
|
5454
5643
|
const identity = await this._serviceContext.createIdentity(params);
|
|
5455
5644
|
await this._serviceContext.initialized.wait();
|
|
5456
5645
|
const space = await this._serviceContext.dataSpaceManager.createSpace();
|
|
5457
|
-
const obj = new import_client_protocol5.Properties(void 0);
|
|
5458
|
-
obj[import_client_protocol5.defaultKey] = identity.identityKey.toHex();
|
|
5459
5646
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5460
|
-
(0,
|
|
5647
|
+
(0, import_invariant15.invariant)(automergeIndex, void 0, {
|
|
5461
5648
|
F: __dxlog_file18,
|
|
5462
|
-
L:
|
|
5649
|
+
L: 379,
|
|
5463
5650
|
S: this,
|
|
5464
5651
|
A: [
|
|
5465
5652
|
"automergeIndex",
|
|
@@ -5468,41 +5655,88 @@ var ClientServicesHost = class {
|
|
|
5468
5655
|
});
|
|
5469
5656
|
const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
|
|
5470
5657
|
await document.whenReady();
|
|
5658
|
+
const properties = {
|
|
5659
|
+
system: {
|
|
5660
|
+
type: (0, import_echo_pipeline5.encodeReference)((0, import_echo_schema.getTypeReference)(import_client_protocol4.Properties))
|
|
5661
|
+
},
|
|
5662
|
+
data: {
|
|
5663
|
+
[import_client_protocol4.defaultKey]: identity.identityKey.toHex()
|
|
5664
|
+
},
|
|
5665
|
+
meta: {
|
|
5666
|
+
keys: []
|
|
5667
|
+
}
|
|
5668
|
+
};
|
|
5669
|
+
const propertiesId = import_keys11.PublicKey.random().toHex();
|
|
5471
5670
|
document.change((doc) => {
|
|
5472
5671
|
(0, import_util9.assignDeep)(doc, [
|
|
5473
5672
|
"objects",
|
|
5474
|
-
|
|
5475
|
-
],
|
|
5673
|
+
propertiesId
|
|
5674
|
+
], properties);
|
|
5476
5675
|
});
|
|
5676
|
+
await this._serviceContext.automergeHost.repo.flush();
|
|
5477
5677
|
return identity;
|
|
5478
5678
|
}
|
|
5479
5679
|
};
|
|
5480
5680
|
_ts_decorate8([
|
|
5481
|
-
|
|
5681
|
+
import_tracing8.trace.info()
|
|
5482
5682
|
], ClientServicesHost.prototype, "_opening", void 0);
|
|
5483
5683
|
_ts_decorate8([
|
|
5484
|
-
|
|
5684
|
+
import_tracing8.trace.info()
|
|
5485
5685
|
], ClientServicesHost.prototype, "_open", void 0);
|
|
5486
5686
|
_ts_decorate8([
|
|
5487
5687
|
import_async16.synchronized,
|
|
5488
|
-
|
|
5688
|
+
import_tracing8.trace.span()
|
|
5489
5689
|
], ClientServicesHost.prototype, "open", null);
|
|
5490
5690
|
_ts_decorate8([
|
|
5491
5691
|
import_async16.synchronized,
|
|
5492
|
-
|
|
5692
|
+
import_tracing8.trace.span()
|
|
5493
5693
|
], ClientServicesHost.prototype, "close", null);
|
|
5494
5694
|
ClientServicesHost = _ts_decorate8([
|
|
5495
|
-
|
|
5695
|
+
import_tracing8.trace.resource()
|
|
5496
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
|
+
};
|
|
5497
5729
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5498
5730
|
0 && (module.exports = {
|
|
5499
5731
|
ClientRpcServer,
|
|
5500
5732
|
ClientServicesHost,
|
|
5733
|
+
ClientServicesProviderResource,
|
|
5501
5734
|
DataSpace,
|
|
5502
5735
|
DataSpaceManager,
|
|
5503
5736
|
DeviceInvitationProtocol,
|
|
5504
5737
|
DevtoolsHostEvents,
|
|
5505
5738
|
DevtoolsServiceImpl,
|
|
5739
|
+
DiagnosticsCollector,
|
|
5506
5740
|
Identity,
|
|
5507
5741
|
IdentityManager,
|
|
5508
5742
|
IdentityServiceImpl,
|
|
@@ -5514,11 +5748,14 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5514
5748
|
SpaceInvitationProtocol,
|
|
5515
5749
|
SpacesServiceImpl,
|
|
5516
5750
|
TrustedKeySetAuthVerifier,
|
|
5751
|
+
createAdmissionKeypair,
|
|
5517
5752
|
createAuthProvider,
|
|
5753
|
+
createCollectDiagnosticsBroadcastHandler,
|
|
5754
|
+
createCollectDiagnosticsBroadcastSender,
|
|
5518
5755
|
createDiagnostics,
|
|
5756
|
+
createLevel,
|
|
5519
5757
|
createStorageObjects,
|
|
5520
5758
|
getNetworkPeers,
|
|
5521
|
-
invitationExpired,
|
|
5522
5759
|
isLocked,
|
|
5523
5760
|
subscribeToFeedBlocks,
|
|
5524
5761
|
subscribeToFeeds,
|
|
@@ -5528,4 +5765,4 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5528
5765
|
subscribeToSpaces,
|
|
5529
5766
|
subscribeToSwarmInfo
|
|
5530
5767
|
});
|
|
5531
|
-
//# sourceMappingURL=chunk-
|
|
5768
|
+
//# sourceMappingURL=chunk-DQMGKBOV.cjs.map
|