@dxos/client-services 0.4.10-main.0302e13 → 0.4.10-main.068c3d8
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-UPLC4TAJ.mjs → chunk-U3AY6WTI.mjs} +1278 -981
- package/dist/lib/browser/chunk-U3AY6WTI.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +15 -3
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +12 -5
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-ZNZ7VJDK.cjs → chunk-3ILFTQW5.cjs} +1107 -898
- package/dist/lib/node/chunk-3ILFTQW5.cjs.map +7 -0
- package/dist/lib/node/index.cjs +50 -38
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +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/index.d.ts +1 -0
- package/dist/types/src/packlets/invitations/index.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-manager.d.ts +42 -0
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/invitations-service.d.ts +7 -23
- 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 +9 -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/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/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/index.ts +1 -0
- package/src/packlets/invitations/invitation-extension.ts +28 -1
- package/src/packlets/invitations/invitations-handler.ts +74 -34
- package/src/packlets/invitations/invitations-manager.ts +197 -0
- package/src/packlets/invitations/invitations-service.ts +21 -168
- 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 +29 -11
- package/src/packlets/services/service-host.ts +50 -19
- 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/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/version.ts +1 -1
- package/dist/lib/browser/chunk-UPLC4TAJ.mjs.map +0 -7
- package/dist/lib/node/chunk-ZNZ7VJDK.cjs.map +0 -7
- package/dist/types/src/packlets/services/diagnostics.d.ts.map +0 -1
|
@@ -26,19 +26,22 @@ 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_3ILFTQW5_exports = {};
|
|
30
|
+
__export(chunk_3ILFTQW5_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,
|
|
41
43
|
InvitationsHandler: () => InvitationsHandler,
|
|
44
|
+
InvitationsManager: () => InvitationsManager,
|
|
42
45
|
InvitationsServiceImpl: () => InvitationsServiceImpl,
|
|
43
46
|
Lock: () => Lock,
|
|
44
47
|
ServiceContext: () => ServiceContext,
|
|
@@ -46,11 +49,14 @@ __export(chunk_ZNZ7VJDK_exports, {
|
|
|
46
49
|
SpaceInvitationProtocol: () => SpaceInvitationProtocol,
|
|
47
50
|
SpacesServiceImpl: () => SpacesServiceImpl,
|
|
48
51
|
TrustedKeySetAuthVerifier: () => TrustedKeySetAuthVerifier,
|
|
52
|
+
createAdmissionKeypair: () => createAdmissionKeypair,
|
|
49
53
|
createAuthProvider: () => createAuthProvider,
|
|
54
|
+
createCollectDiagnosticsBroadcastHandler: () => createCollectDiagnosticsBroadcastHandler,
|
|
55
|
+
createCollectDiagnosticsBroadcastSender: () => createCollectDiagnosticsBroadcastSender,
|
|
50
56
|
createDiagnostics: () => createDiagnostics,
|
|
57
|
+
createLevel: () => createLevel,
|
|
51
58
|
createStorageObjects: () => createStorageObjects,
|
|
52
59
|
getNetworkPeers: () => getNetworkPeers,
|
|
53
|
-
invitationExpired: () => invitationExpired,
|
|
54
60
|
isLocked: () => isLocked,
|
|
55
61
|
subscribeToFeedBlocks: () => subscribeToFeedBlocks,
|
|
56
62
|
subscribeToFeeds: () => subscribeToFeeds,
|
|
@@ -60,7 +66,7 @@ __export(chunk_ZNZ7VJDK_exports, {
|
|
|
60
66
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
61
67
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
62
68
|
});
|
|
63
|
-
module.exports = __toCommonJS(
|
|
69
|
+
module.exports = __toCommonJS(chunk_3ILFTQW5_exports);
|
|
64
70
|
var import_async = require("@dxos/async");
|
|
65
71
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
66
72
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -115,6 +121,7 @@ var import_async7 = require("@dxos/async");
|
|
|
115
121
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
116
122
|
var import_context4 = require("@dxos/context");
|
|
117
123
|
var import_credentials7 = require("@dxos/credentials");
|
|
124
|
+
var import_crypto = require("@dxos/crypto");
|
|
118
125
|
var import_invariant5 = require("@dxos/invariant");
|
|
119
126
|
var import_keys5 = require("@dxos/keys");
|
|
120
127
|
var import_log4 = require("@dxos/log");
|
|
@@ -124,6 +131,7 @@ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
124
131
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
125
132
|
var import_async8 = require("@dxos/async");
|
|
126
133
|
var import_context5 = require("@dxos/context");
|
|
134
|
+
var import_crypto2 = require("@dxos/crypto");
|
|
127
135
|
var import_invariant6 = require("@dxos/invariant");
|
|
128
136
|
var import_keys6 = require("@dxos/keys");
|
|
129
137
|
var import_log5 = require("@dxos/log");
|
|
@@ -131,133 +139,143 @@ var import_protocols5 = require("@dxos/protocols");
|
|
|
131
139
|
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
132
140
|
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
133
141
|
var import_teleport = require("@dxos/teleport");
|
|
134
|
-
var import_async9 = require("@dxos/async");
|
|
135
142
|
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
136
|
-
var import_context6 = require("@dxos/context");
|
|
137
|
-
var import_invariant7 = require("@dxos/invariant");
|
|
138
|
-
var import_log6 = require("@dxos/log");
|
|
139
143
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
140
144
|
var import_credentials8 = require("@dxos/credentials");
|
|
141
145
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
142
|
-
var
|
|
143
|
-
var
|
|
146
|
+
var import_invariant7 = require("@dxos/invariant");
|
|
147
|
+
var import_log6 = require("@dxos/log");
|
|
144
148
|
var import_protocols6 = require("@dxos/protocols");
|
|
145
149
|
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
150
|
+
var import_async9 = require("@dxos/async");
|
|
151
|
+
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
152
|
+
var import_invariant8 = require("@dxos/invariant");
|
|
153
|
+
var import_log7 = require("@dxos/log");
|
|
146
154
|
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
|
-
var
|
|
160
|
+
var import_context6 = require("@dxos/context");
|
|
160
161
|
var import_debug3 = require("@dxos/debug");
|
|
161
162
|
var import_echo_db = require("@dxos/echo-db");
|
|
162
|
-
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
163
163
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
164
|
-
var
|
|
164
|
+
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
165
|
+
var import_invariant9 = require("@dxos/invariant");
|
|
165
166
|
var import_keys7 = require("@dxos/keys");
|
|
166
167
|
var import_log8 = require("@dxos/log");
|
|
167
|
-
var
|
|
168
|
-
var
|
|
169
|
-
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");
|
|
170
171
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
171
|
-
var
|
|
172
|
+
var import_tracing4 = require("@dxos/tracing");
|
|
172
173
|
var import_util4 = require("@dxos/util");
|
|
173
174
|
var import_async11 = require("@dxos/async");
|
|
174
|
-
var
|
|
175
|
+
var import_credentials10 = require("@dxos/credentials");
|
|
175
176
|
var import_async12 = require("@dxos/async");
|
|
176
|
-
var
|
|
177
|
-
var
|
|
177
|
+
var import_context7 = require("@dxos/context");
|
|
178
|
+
var import_invariant10 = require("@dxos/invariant");
|
|
178
179
|
var import_keys8 = require("@dxos/keys");
|
|
179
180
|
var import_log9 = require("@dxos/log");
|
|
180
|
-
var
|
|
181
|
+
var import_protocols8 = require("@dxos/protocols");
|
|
181
182
|
var import_teleport2 = require("@dxos/teleport");
|
|
182
183
|
var import_util5 = require("@dxos/util");
|
|
183
184
|
var import_async13 = require("@dxos/async");
|
|
184
|
-
var
|
|
185
|
-
var
|
|
186
|
-
var
|
|
185
|
+
var import_context8 = require("@dxos/context");
|
|
186
|
+
var import_credentials11 = require("@dxos/credentials");
|
|
187
|
+
var import_invariant11 = require("@dxos/invariant");
|
|
187
188
|
var import_keys9 = require("@dxos/keys");
|
|
188
189
|
var import_log10 = require("@dxos/log");
|
|
189
|
-
var
|
|
190
|
-
var
|
|
190
|
+
var import_protocols9 = require("@dxos/protocols");
|
|
191
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
191
192
|
var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
|
|
192
193
|
var import_util6 = require("@dxos/util");
|
|
193
|
-
var
|
|
194
|
+
var import_credentials12 = require("@dxos/credentials");
|
|
194
195
|
var import_debug4 = require("@dxos/debug");
|
|
195
|
-
var
|
|
196
|
+
var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
196
197
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
197
198
|
var import_async14 = require("@dxos/async");
|
|
198
|
-
var
|
|
199
|
+
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
199
200
|
var import_debug5 = require("@dxos/debug");
|
|
200
|
-
var
|
|
201
|
+
var import_invariant12 = require("@dxos/invariant");
|
|
201
202
|
var import_log11 = require("@dxos/log");
|
|
202
|
-
var
|
|
203
|
-
var
|
|
203
|
+
var import_protocols10 = require("@dxos/protocols");
|
|
204
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
204
205
|
var import_async15 = require("@dxos/async");
|
|
205
|
-
var
|
|
206
|
-
var
|
|
206
|
+
var import_context9 = require("@dxos/context");
|
|
207
|
+
var import_credentials14 = require("@dxos/credentials");
|
|
207
208
|
var import_debug6 = require("@dxos/debug");
|
|
208
|
-
var
|
|
209
|
+
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
209
210
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
210
211
|
var import_indexing = require("@dxos/indexing");
|
|
211
|
-
var
|
|
212
|
+
var import_invariant13 = require("@dxos/invariant");
|
|
212
213
|
var import_keyring = require("@dxos/keyring");
|
|
213
214
|
var import_keys10 = require("@dxos/keys");
|
|
214
215
|
var import_log12 = require("@dxos/log");
|
|
215
|
-
var
|
|
216
|
-
var
|
|
216
|
+
var import_protocols11 = require("@dxos/protocols");
|
|
217
|
+
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
217
218
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
218
|
-
var
|
|
219
|
+
var import_tracing5 = require("@dxos/tracing");
|
|
219
220
|
var import_util7 = require("@dxos/util");
|
|
220
221
|
var import_automerge = require("@dxos/automerge/automerge");
|
|
221
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");
|
|
222
227
|
var import_protocols13 = require("@dxos/protocols");
|
|
223
|
-
var
|
|
224
|
-
var
|
|
225
|
-
var
|
|
226
|
-
var
|
|
227
|
-
var
|
|
228
|
-
var
|
|
229
|
-
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");
|
|
230
234
|
var import_util8 = require("@dxos/util");
|
|
231
235
|
var import_async16 = require("@dxos/async");
|
|
232
|
-
var
|
|
233
|
-
var
|
|
234
|
-
var
|
|
236
|
+
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
237
|
+
var import_context10 = require("@dxos/context");
|
|
238
|
+
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
235
239
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
236
240
|
var import_indexing2 = require("@dxos/indexing");
|
|
237
|
-
var
|
|
241
|
+
var import_invariant15 = require("@dxos/invariant");
|
|
238
242
|
var import_keys11 = require("@dxos/keys");
|
|
239
|
-
var
|
|
243
|
+
var import_log13 = require("@dxos/log");
|
|
240
244
|
var import_messaging = require("@dxos/messaging");
|
|
241
245
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
242
|
-
var
|
|
243
|
-
var
|
|
244
|
-
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");
|
|
245
249
|
var import_util9 = require("@dxos/util");
|
|
246
250
|
var import_websocket_rpc = require("@dxos/websocket-rpc");
|
|
247
251
|
var import_async17 = require("@dxos/async");
|
|
248
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");
|
|
249
255
|
var import_invariant17 = require("@dxos/invariant");
|
|
250
|
-
var
|
|
256
|
+
var import_lock_file = require("@dxos/lock-file");
|
|
257
|
+
var import_log14 = require("@dxos/log");
|
|
251
258
|
var import_async18 = require("@dxos/async");
|
|
252
259
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
253
260
|
var import_keys12 = require("@dxos/keys");
|
|
254
261
|
var import_log15 = require("@dxos/log");
|
|
255
|
-
var
|
|
262
|
+
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
256
263
|
var import_util10 = require("@dxos/util");
|
|
257
264
|
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
258
|
-
var
|
|
259
|
-
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");
|
|
260
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");
|
|
261
279
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
262
280
|
return new import_codec_protobuf.Stream(({ next }) => {
|
|
263
281
|
const subscriptions = new import_async.EventSubscriptions();
|
|
@@ -1470,6 +1488,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1470
1488
|
this._callbacks = _callbacks;
|
|
1471
1489
|
this._ctx = new import_context5.Context();
|
|
1472
1490
|
this._remoteOptionsTrigger = new import_async8.Trigger();
|
|
1491
|
+
this._challenge = void 0;
|
|
1473
1492
|
this.invitation = void 0;
|
|
1474
1493
|
this.guestProfile = void 0;
|
|
1475
1494
|
this.authenticationPassed = false;
|
|
@@ -1484,7 +1503,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1484
1503
|
options: async (options) => {
|
|
1485
1504
|
(0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1486
1505
|
F: __dxlog_file6,
|
|
1487
|
-
L:
|
|
1506
|
+
L: 90,
|
|
1488
1507
|
S: this,
|
|
1489
1508
|
A: [
|
|
1490
1509
|
"!this._remoteOptions",
|
|
@@ -1501,7 +1520,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1501
1520
|
id: traceId
|
|
1502
1521
|
}), {
|
|
1503
1522
|
F: __dxlog_file6,
|
|
1504
|
-
L:
|
|
1523
|
+
L: 99,
|
|
1505
1524
|
S: this,
|
|
1506
1525
|
C: (f, a) => f(...a)
|
|
1507
1526
|
});
|
|
@@ -1511,7 +1530,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1511
1530
|
invitationId
|
|
1512
1531
|
}, {
|
|
1513
1532
|
F: __dxlog_file6,
|
|
1514
|
-
L:
|
|
1533
|
+
L: 103,
|
|
1515
1534
|
S: this,
|
|
1516
1535
|
C: (f, a) => f(...a)
|
|
1517
1536
|
});
|
|
@@ -1525,7 +1544,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1525
1544
|
guestProfile: profile
|
|
1526
1545
|
}, {
|
|
1527
1546
|
F: __dxlog_file6,
|
|
1528
|
-
L:
|
|
1547
|
+
L: 112,
|
|
1529
1548
|
S: this,
|
|
1530
1549
|
C: (f, a) => f(...a)
|
|
1531
1550
|
});
|
|
@@ -1534,25 +1553,27 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1534
1553
|
...this.invitation,
|
|
1535
1554
|
state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1536
1555
|
});
|
|
1556
|
+
this._challenge = this.invitation.authMethod === import_services4.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto2.randomBytes)(32) : void 0;
|
|
1537
1557
|
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols5.trace.end({
|
|
1538
1558
|
id: traceId
|
|
1539
1559
|
}), {
|
|
1540
1560
|
F: __dxlog_file6,
|
|
1541
|
-
L:
|
|
1561
|
+
L: 122,
|
|
1542
1562
|
S: this,
|
|
1543
1563
|
C: (f, a) => f(...a)
|
|
1544
1564
|
});
|
|
1545
1565
|
return {
|
|
1546
|
-
authMethod: this.invitation.authMethod
|
|
1566
|
+
authMethod: this.invitation.authMethod,
|
|
1567
|
+
challenge: this._challenge
|
|
1547
1568
|
};
|
|
1548
1569
|
},
|
|
1549
|
-
authenticate: async ({ authCode: code }) => {
|
|
1570
|
+
authenticate: async ({ authCode: code, signedChallenge }) => {
|
|
1550
1571
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
1551
1572
|
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols5.trace.begin({
|
|
1552
1573
|
id: traceId
|
|
1553
1574
|
}), {
|
|
1554
1575
|
F: __dxlog_file6,
|
|
1555
|
-
L:
|
|
1576
|
+
L: 131,
|
|
1556
1577
|
S: this,
|
|
1557
1578
|
C: (f, a) => f(...a)
|
|
1558
1579
|
});
|
|
@@ -1560,14 +1581,14 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1560
1581
|
authCode: code
|
|
1561
1582
|
}, {
|
|
1562
1583
|
F: __dxlog_file6,
|
|
1563
|
-
L:
|
|
1584
|
+
L: 132,
|
|
1564
1585
|
S: this,
|
|
1565
1586
|
C: (f, a) => f(...a)
|
|
1566
1587
|
});
|
|
1567
1588
|
let status = import_invitations2.AuthenticationResponse.Status.OK;
|
|
1568
1589
|
(0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
|
|
1569
1590
|
F: __dxlog_file6,
|
|
1570
|
-
L:
|
|
1591
|
+
L: 135,
|
|
1571
1592
|
S: this,
|
|
1572
1593
|
A: [
|
|
1573
1594
|
"this.invitation",
|
|
@@ -1578,7 +1599,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1578
1599
|
case import_services4.Invitation.AuthMethod.NONE: {
|
|
1579
1600
|
(0, import_log5.log)("authentication not required", void 0, {
|
|
1580
1601
|
F: __dxlog_file6,
|
|
1581
|
-
L:
|
|
1602
|
+
L: 138,
|
|
1582
1603
|
S: this,
|
|
1583
1604
|
C: (f, a) => f(...a)
|
|
1584
1605
|
});
|
|
@@ -1598,12 +1619,25 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1598
1619
|
}
|
|
1599
1620
|
break;
|
|
1600
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
|
+
}
|
|
1601
1635
|
default: {
|
|
1602
1636
|
import_log5.log.error("invalid authentication method", {
|
|
1603
1637
|
authMethod: this.invitation.authMethod
|
|
1604
1638
|
}, {
|
|
1605
1639
|
F: __dxlog_file6,
|
|
1606
|
-
L:
|
|
1640
|
+
L: 176,
|
|
1607
1641
|
S: this,
|
|
1608
1642
|
C: (f, a) => f(...a)
|
|
1609
1643
|
});
|
|
@@ -1618,7 +1652,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1618
1652
|
}
|
|
1619
1653
|
}), {
|
|
1620
1654
|
F: __dxlog_file6,
|
|
1621
|
-
L:
|
|
1655
|
+
L: 182,
|
|
1622
1656
|
S: this,
|
|
1623
1657
|
C: (f, a) => f(...a)
|
|
1624
1658
|
});
|
|
@@ -1632,14 +1666,14 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1632
1666
|
id: traceId
|
|
1633
1667
|
}), {
|
|
1634
1668
|
F: __dxlog_file6,
|
|
1635
|
-
L:
|
|
1669
|
+
L: 188,
|
|
1636
1670
|
S: this,
|
|
1637
1671
|
C: (f, a) => f(...a)
|
|
1638
1672
|
});
|
|
1639
1673
|
try {
|
|
1640
1674
|
(0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
|
|
1641
1675
|
F: __dxlog_file6,
|
|
1642
|
-
L:
|
|
1676
|
+
L: 191,
|
|
1643
1677
|
S: this,
|
|
1644
1678
|
A: [
|
|
1645
1679
|
"this.invitation",
|
|
@@ -1654,7 +1688,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1654
1688
|
id: traceId
|
|
1655
1689
|
}), {
|
|
1656
1690
|
F: __dxlog_file6,
|
|
1657
|
-
L:
|
|
1691
|
+
L: 199,
|
|
1658
1692
|
S: this,
|
|
1659
1693
|
C: (f, a) => f(...a)
|
|
1660
1694
|
});
|
|
@@ -1711,7 +1745,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1711
1745
|
options: async (options) => {
|
|
1712
1746
|
(0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1713
1747
|
F: __dxlog_file6,
|
|
1714
|
-
L:
|
|
1748
|
+
L: 266,
|
|
1715
1749
|
S: this,
|
|
1716
1750
|
A: [
|
|
1717
1751
|
"!this._remoteOptions",
|
|
@@ -1738,7 +1772,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1738
1772
|
try {
|
|
1739
1773
|
(0, import_log5.log)("begin options", void 0, {
|
|
1740
1774
|
F: __dxlog_file6,
|
|
1741
|
-
L:
|
|
1775
|
+
L: 287,
|
|
1742
1776
|
S: this,
|
|
1743
1777
|
C: (f, a) => f(...a)
|
|
1744
1778
|
});
|
|
@@ -1750,7 +1784,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1750
1784
|
}));
|
|
1751
1785
|
(0, import_log5.log)("end options", void 0, {
|
|
1752
1786
|
F: __dxlog_file6,
|
|
1753
|
-
L:
|
|
1787
|
+
L: 290,
|
|
1754
1788
|
S: this,
|
|
1755
1789
|
C: (f, a) => f(...a)
|
|
1756
1790
|
});
|
|
@@ -1764,7 +1798,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1764
1798
|
} catch (err) {
|
|
1765
1799
|
(0, import_log5.log)("openError", err, {
|
|
1766
1800
|
F: __dxlog_file6,
|
|
1767
|
-
L:
|
|
1801
|
+
L: 300,
|
|
1768
1802
|
S: this,
|
|
1769
1803
|
C: (f, a) => f(...a)
|
|
1770
1804
|
});
|
|
@@ -1774,7 +1808,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1774
1808
|
async onClose() {
|
|
1775
1809
|
(0, import_log5.log)("onClose", void 0, {
|
|
1776
1810
|
F: __dxlog_file6,
|
|
1777
|
-
L:
|
|
1811
|
+
L: 306,
|
|
1778
1812
|
S: this,
|
|
1779
1813
|
C: (f, a) => f(...a)
|
|
1780
1814
|
});
|
|
@@ -1791,11 +1825,11 @@ var InvitationsHandler = class {
|
|
|
1791
1825
|
this._networkManager = _networkManager;
|
|
1792
1826
|
}
|
|
1793
1827
|
createInvitation(protocol, options) {
|
|
1794
|
-
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 ?? {};
|
|
1795
1829
|
const authCode = options?.authCode ?? (authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1796
1830
|
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
1797
1831
|
F: __dxlog_file7,
|
|
1798
|
-
L:
|
|
1832
|
+
L: 87,
|
|
1799
1833
|
S: this,
|
|
1800
1834
|
A: [
|
|
1801
1835
|
"protocol",
|
|
@@ -1810,9 +1844,11 @@ var InvitationsHandler = class {
|
|
|
1810
1844
|
swarmKey,
|
|
1811
1845
|
authCode,
|
|
1812
1846
|
timeout,
|
|
1813
|
-
persistent,
|
|
1847
|
+
persistent: persistent && type !== import_services3.Invitation.Type.DELEGATED,
|
|
1848
|
+
guestKeypair: guestKeypair ?? (authMethod === import_services3.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
|
|
1814
1849
|
created,
|
|
1815
1850
|
lifetime,
|
|
1851
|
+
multiUse,
|
|
1816
1852
|
...protocol.getInvitationContext()
|
|
1817
1853
|
};
|
|
1818
1854
|
const stream = new import_async7.PushStream();
|
|
@@ -1827,7 +1863,7 @@ var InvitationsHandler = class {
|
|
|
1827
1863
|
...protocol.toJSON()
|
|
1828
1864
|
}, {
|
|
1829
1865
|
F: __dxlog_file7,
|
|
1830
|
-
L:
|
|
1866
|
+
L: 115,
|
|
1831
1867
|
S: this,
|
|
1832
1868
|
C: (f, a) => f(...a)
|
|
1833
1869
|
});
|
|
@@ -1852,7 +1888,7 @@ var InvitationsHandler = class {
|
|
|
1852
1888
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1853
1889
|
(0, import_invariant5.invariant)(deviceKey, void 0, {
|
|
1854
1890
|
F: __dxlog_file7,
|
|
1855
|
-
L:
|
|
1891
|
+
L: 136,
|
|
1856
1892
|
S: this,
|
|
1857
1893
|
A: [
|
|
1858
1894
|
"deviceKey",
|
|
@@ -1875,7 +1911,7 @@ var InvitationsHandler = class {
|
|
|
1875
1911
|
id: traceId
|
|
1876
1912
|
}), {
|
|
1877
1913
|
F: __dxlog_file7,
|
|
1878
|
-
L:
|
|
1914
|
+
L: 154,
|
|
1879
1915
|
S: this,
|
|
1880
1916
|
C: (f, a) => f(...a)
|
|
1881
1917
|
});
|
|
@@ -1883,7 +1919,7 @@ var InvitationsHandler = class {
|
|
|
1883
1919
|
...protocol.toJSON()
|
|
1884
1920
|
}, {
|
|
1885
1921
|
F: __dxlog_file7,
|
|
1886
|
-
L:
|
|
1922
|
+
L: 155,
|
|
1887
1923
|
S: this,
|
|
1888
1924
|
C: (f, a) => f(...a)
|
|
1889
1925
|
});
|
|
@@ -1899,7 +1935,7 @@ var InvitationsHandler = class {
|
|
|
1899
1935
|
...protocol.toJSON()
|
|
1900
1936
|
}, {
|
|
1901
1937
|
F: __dxlog_file7,
|
|
1902
|
-
L:
|
|
1938
|
+
L: 158,
|
|
1903
1939
|
S: this,
|
|
1904
1940
|
C: (f, a) => f(...a)
|
|
1905
1941
|
});
|
|
@@ -1911,7 +1947,7 @@ var InvitationsHandler = class {
|
|
|
1911
1947
|
id: traceId
|
|
1912
1948
|
}), {
|
|
1913
1949
|
F: __dxlog_file7,
|
|
1914
|
-
L:
|
|
1950
|
+
L: 160,
|
|
1915
1951
|
S: this,
|
|
1916
1952
|
C: (f, a) => f(...a)
|
|
1917
1953
|
});
|
|
@@ -1921,7 +1957,7 @@ var InvitationsHandler = class {
|
|
|
1921
1957
|
...protocol.toJSON()
|
|
1922
1958
|
}, {
|
|
1923
1959
|
F: __dxlog_file7,
|
|
1924
|
-
L:
|
|
1960
|
+
L: 163,
|
|
1925
1961
|
S: this,
|
|
1926
1962
|
C: (f, a) => f(...a)
|
|
1927
1963
|
});
|
|
@@ -1932,7 +1968,7 @@ var InvitationsHandler = class {
|
|
|
1932
1968
|
} else {
|
|
1933
1969
|
import_log4.log.error("failed", err, {
|
|
1934
1970
|
F: __dxlog_file7,
|
|
1935
|
-
L:
|
|
1971
|
+
L: 166,
|
|
1936
1972
|
S: this,
|
|
1937
1973
|
C: (f, a) => f(...a)
|
|
1938
1974
|
});
|
|
@@ -1943,12 +1979,12 @@ var InvitationsHandler = class {
|
|
|
1943
1979
|
error: err
|
|
1944
1980
|
}), {
|
|
1945
1981
|
F: __dxlog_file7,
|
|
1946
|
-
L:
|
|
1982
|
+
L: 169,
|
|
1947
1983
|
S: this,
|
|
1948
1984
|
C: (f, a) => f(...a)
|
|
1949
1985
|
});
|
|
1950
1986
|
} finally {
|
|
1951
|
-
if (
|
|
1987
|
+
if (!multiUse) {
|
|
1952
1988
|
await swarmConnection.close();
|
|
1953
1989
|
await ctx.dispose();
|
|
1954
1990
|
}
|
|
@@ -1964,7 +2000,7 @@ var InvitationsHandler = class {
|
|
|
1964
2000
|
...protocol.toJSON()
|
|
1965
2001
|
}, {
|
|
1966
2002
|
F: __dxlog_file7,
|
|
1967
|
-
L:
|
|
2003
|
+
L: 184,
|
|
1968
2004
|
S: this,
|
|
1969
2005
|
C: (f, a) => f(...a)
|
|
1970
2006
|
});
|
|
@@ -1975,7 +2011,7 @@ var InvitationsHandler = class {
|
|
|
1975
2011
|
} else {
|
|
1976
2012
|
import_log4.log.error("failed", err, {
|
|
1977
2013
|
F: __dxlog_file7,
|
|
1978
|
-
L:
|
|
2014
|
+
L: 187,
|
|
1979
2015
|
S: this,
|
|
1980
2016
|
C: (f, a) => f(...a)
|
|
1981
2017
|
});
|
|
@@ -1985,11 +2021,11 @@ var InvitationsHandler = class {
|
|
|
1985
2021
|
});
|
|
1986
2022
|
return extension;
|
|
1987
2023
|
};
|
|
1988
|
-
if (invitation.lifetime && invitation.created
|
|
2024
|
+
if (invitation.lifetime && invitation.created) {
|
|
1989
2025
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
1990
2026
|
import_log4.log.warn("invitation has already expired", void 0, {
|
|
1991
2027
|
F: __dxlog_file7,
|
|
1992
|
-
L:
|
|
2028
|
+
L: 198,
|
|
1993
2029
|
S: this,
|
|
1994
2030
|
C: (f, a) => f(...a)
|
|
1995
2031
|
});
|
|
@@ -2040,7 +2076,7 @@ var InvitationsHandler = class {
|
|
|
2040
2076
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
2041
2077
|
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
2042
2078
|
F: __dxlog_file7,
|
|
2043
|
-
L:
|
|
2079
|
+
L: 252,
|
|
2044
2080
|
S: this,
|
|
2045
2081
|
A: [
|
|
2046
2082
|
"protocol",
|
|
@@ -2050,7 +2086,7 @@ var InvitationsHandler = class {
|
|
|
2050
2086
|
if (deviceProfile) {
|
|
2051
2087
|
(0, import_invariant5.invariant)(invitation.kind === import_services3.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2052
2088
|
F: __dxlog_file7,
|
|
2053
|
-
L:
|
|
2089
|
+
L: 255,
|
|
2054
2090
|
S: this,
|
|
2055
2091
|
A: [
|
|
2056
2092
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -2065,7 +2101,7 @@ var InvitationsHandler = class {
|
|
|
2065
2101
|
const setState = (newData) => {
|
|
2066
2102
|
(0, import_invariant5.invariant)(newData.state !== void 0, void 0, {
|
|
2067
2103
|
F: __dxlog_file7,
|
|
2068
|
-
L:
|
|
2104
|
+
L: 266,
|
|
2069
2105
|
S: this,
|
|
2070
2106
|
A: [
|
|
2071
2107
|
"newData.state !== undefined",
|
|
@@ -2085,7 +2121,7 @@ var InvitationsHandler = class {
|
|
|
2085
2121
|
...protocol.toJSON()
|
|
2086
2122
|
}, {
|
|
2087
2123
|
F: __dxlog_file7,
|
|
2088
|
-
L:
|
|
2124
|
+
L: 274,
|
|
2089
2125
|
S: this,
|
|
2090
2126
|
C: (f, a) => f(...a)
|
|
2091
2127
|
});
|
|
@@ -2095,7 +2131,7 @@ var InvitationsHandler = class {
|
|
|
2095
2131
|
} else {
|
|
2096
2132
|
import_log4.log.warn("auth failed", err, {
|
|
2097
2133
|
F: __dxlog_file7,
|
|
2098
|
-
L:
|
|
2134
|
+
L: 277,
|
|
2099
2135
|
S: this,
|
|
2100
2136
|
C: (f, a) => f(...a)
|
|
2101
2137
|
});
|
|
@@ -2109,7 +2145,7 @@ var InvitationsHandler = class {
|
|
|
2109
2145
|
...protocol.toJSON()
|
|
2110
2146
|
}, {
|
|
2111
2147
|
F: __dxlog_file7,
|
|
2112
|
-
L:
|
|
2148
|
+
L: 285,
|
|
2113
2149
|
S: this,
|
|
2114
2150
|
C: (f, a) => f(...a)
|
|
2115
2151
|
});
|
|
@@ -2124,7 +2160,7 @@ var InvitationsHandler = class {
|
|
|
2124
2160
|
currentState
|
|
2125
2161
|
}, {
|
|
2126
2162
|
F: __dxlog_file7,
|
|
2127
|
-
L:
|
|
2163
|
+
L: 295,
|
|
2128
2164
|
S: this,
|
|
2129
2165
|
C: (f, a) => f(...a)
|
|
2130
2166
|
});
|
|
@@ -2139,7 +2175,7 @@ var InvitationsHandler = class {
|
|
|
2139
2175
|
id: traceId
|
|
2140
2176
|
}), {
|
|
2141
2177
|
F: __dxlog_file7,
|
|
2142
|
-
L:
|
|
2178
|
+
L: 304,
|
|
2143
2179
|
S: this,
|
|
2144
2180
|
C: (f, a) => f(...a)
|
|
2145
2181
|
});
|
|
@@ -2151,7 +2187,7 @@ var InvitationsHandler = class {
|
|
|
2151
2187
|
...protocol.toJSON()
|
|
2152
2188
|
}, {
|
|
2153
2189
|
F: __dxlog_file7,
|
|
2154
|
-
L:
|
|
2190
|
+
L: 312,
|
|
2155
2191
|
S: this,
|
|
2156
2192
|
C: (f, a) => f(...a)
|
|
2157
2193
|
});
|
|
@@ -2162,7 +2198,7 @@ var InvitationsHandler = class {
|
|
|
2162
2198
|
...protocol.toJSON()
|
|
2163
2199
|
}, {
|
|
2164
2200
|
F: __dxlog_file7,
|
|
2165
|
-
L:
|
|
2201
|
+
L: 316,
|
|
2166
2202
|
S: this,
|
|
2167
2203
|
C: (f, a) => f(...a)
|
|
2168
2204
|
});
|
|
@@ -2172,62 +2208,28 @@ var InvitationsHandler = class {
|
|
|
2172
2208
|
response: introductionResponse
|
|
2173
2209
|
}, {
|
|
2174
2210
|
F: __dxlog_file7,
|
|
2175
|
-
L:
|
|
2211
|
+
L: 320,
|
|
2176
2212
|
S: this,
|
|
2177
2213
|
C: (f, a) => f(...a)
|
|
2178
2214
|
});
|
|
2179
2215
|
invitation.authMethod = introductionResponse.authMethod;
|
|
2180
2216
|
if (isAuthenticationRequired(invitation)) {
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
2190
|
-
});
|
|
2191
|
-
const authCode = await authenticated.wait({
|
|
2192
|
-
timeout
|
|
2193
|
-
});
|
|
2194
|
-
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2195
|
-
F: __dxlog_file7,
|
|
2196
|
-
L: 325,
|
|
2197
|
-
S: this,
|
|
2198
|
-
C: (f, a) => f(...a)
|
|
2199
|
-
});
|
|
2200
|
-
setState({
|
|
2201
|
-
state: import_services3.Invitation.State.AUTHENTICATING
|
|
2202
|
-
});
|
|
2203
|
-
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2204
|
-
authCode
|
|
2205
|
-
});
|
|
2206
|
-
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);
|
|
2207
2225
|
break;
|
|
2208
|
-
}
|
|
2209
|
-
if (response.status === import_invitations.AuthenticationResponse.Status.INVALID_OTP) {
|
|
2210
|
-
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2211
|
-
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2212
|
-
} else {
|
|
2213
|
-
(0, import_log4.log)("retrying invalid code", {
|
|
2214
|
-
attempt
|
|
2215
|
-
}, {
|
|
2216
|
-
F: __dxlog_file7,
|
|
2217
|
-
L: 336,
|
|
2218
|
-
S: this,
|
|
2219
|
-
C: (f, a) => f(...a)
|
|
2220
|
-
});
|
|
2221
|
-
authenticated.reset();
|
|
2222
|
-
}
|
|
2223
|
-
}
|
|
2224
2226
|
}
|
|
2225
2227
|
}
|
|
2226
2228
|
(0, import_log4.log)("request admission", {
|
|
2227
2229
|
...protocol.toJSON()
|
|
2228
2230
|
}, {
|
|
2229
2231
|
F: __dxlog_file7,
|
|
2230
|
-
L:
|
|
2232
|
+
L: 336,
|
|
2231
2233
|
S: this,
|
|
2232
2234
|
C: (f, a) => f(...a)
|
|
2233
2235
|
});
|
|
@@ -2239,7 +2241,7 @@ var InvitationsHandler = class {
|
|
|
2239
2241
|
...protocol.toJSON()
|
|
2240
2242
|
}, {
|
|
2241
2243
|
F: __dxlog_file7,
|
|
2242
|
-
L:
|
|
2244
|
+
L: 347,
|
|
2243
2245
|
S: this,
|
|
2244
2246
|
C: (f, a) => f(...a)
|
|
2245
2247
|
});
|
|
@@ -2252,7 +2254,7 @@ var InvitationsHandler = class {
|
|
|
2252
2254
|
id: traceId
|
|
2253
2255
|
}), {
|
|
2254
2256
|
F: __dxlog_file7,
|
|
2255
|
-
L:
|
|
2257
|
+
L: 349,
|
|
2256
2258
|
S: this,
|
|
2257
2259
|
C: (f, a) => f(...a)
|
|
2258
2260
|
});
|
|
@@ -2262,7 +2264,7 @@ var InvitationsHandler = class {
|
|
|
2262
2264
|
...protocol.toJSON()
|
|
2263
2265
|
}, {
|
|
2264
2266
|
F: __dxlog_file7,
|
|
2265
|
-
L:
|
|
2267
|
+
L: 352,
|
|
2266
2268
|
S: this,
|
|
2267
2269
|
C: (f, a) => f(...a)
|
|
2268
2270
|
});
|
|
@@ -2272,7 +2274,7 @@ var InvitationsHandler = class {
|
|
|
2272
2274
|
} else {
|
|
2273
2275
|
(0, import_log4.log)("auth failed", err, {
|
|
2274
2276
|
F: __dxlog_file7,
|
|
2275
|
-
L:
|
|
2277
|
+
L: 355,
|
|
2276
2278
|
S: this,
|
|
2277
2279
|
C: (f, a) => f(...a)
|
|
2278
2280
|
});
|
|
@@ -2283,7 +2285,7 @@ var InvitationsHandler = class {
|
|
|
2283
2285
|
error: err
|
|
2284
2286
|
}), {
|
|
2285
2287
|
F: __dxlog_file7,
|
|
2286
|
-
L:
|
|
2288
|
+
L: 358,
|
|
2287
2289
|
S: this,
|
|
2288
2290
|
C: (f, a) => f(...a)
|
|
2289
2291
|
});
|
|
@@ -2301,7 +2303,7 @@ var InvitationsHandler = class {
|
|
|
2301
2303
|
...protocol.toJSON()
|
|
2302
2304
|
}, {
|
|
2303
2305
|
F: __dxlog_file7,
|
|
2304
|
-
L:
|
|
2306
|
+
L: 369,
|
|
2305
2307
|
S: this,
|
|
2306
2308
|
C: (f, a) => f(...a)
|
|
2307
2309
|
});
|
|
@@ -2311,7 +2313,7 @@ var InvitationsHandler = class {
|
|
|
2311
2313
|
} else {
|
|
2312
2314
|
(0, import_log4.log)("auth failed", err, {
|
|
2313
2315
|
F: __dxlog_file7,
|
|
2314
|
-
L:
|
|
2316
|
+
L: 372,
|
|
2315
2317
|
S: this,
|
|
2316
2318
|
C: (f, a) => f(...a)
|
|
2317
2319
|
});
|
|
@@ -2328,7 +2330,7 @@ var InvitationsHandler = class {
|
|
|
2328
2330
|
} else {
|
|
2329
2331
|
(0, import_invariant5.invariant)(invitation.swarmKey, void 0, {
|
|
2330
2332
|
F: __dxlog_file7,
|
|
2331
|
-
L:
|
|
2333
|
+
L: 386,
|
|
2332
2334
|
S: this,
|
|
2333
2335
|
A: [
|
|
2334
2336
|
"invitation.swarmKey",
|
|
@@ -2366,198 +2368,111 @@ var InvitationsHandler = class {
|
|
|
2366
2368
|
});
|
|
2367
2369
|
return observable;
|
|
2368
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: 426,
|
|
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: 430,
|
|
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: 441,
|
|
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: 460,
|
|
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
|
+
}
|
|
2369
2439
|
};
|
|
2370
|
-
var
|
|
2371
|
-
|
|
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
|
+
};
|
|
2372
2446
|
};
|
|
2373
|
-
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
2374
2447
|
var InvitationsServiceImpl = class {
|
|
2375
|
-
constructor(
|
|
2376
|
-
this.
|
|
2377
|
-
this._getHandler = _getHandler;
|
|
2378
|
-
this._metadataStore = _metadataStore;
|
|
2379
|
-
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2380
|
-
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2381
|
-
this._invitationCreated = new import_async9.Event();
|
|
2382
|
-
this._invitationAccepted = new import_async9.Event();
|
|
2383
|
-
this._removedCreated = new import_async9.Event();
|
|
2384
|
-
this._removedAccepted = new import_async9.Event();
|
|
2385
|
-
this._saved = new import_async9.Event();
|
|
2386
|
-
this._persistentInvitationsLoadedEvent = new import_async9.Event();
|
|
2387
|
-
this._persistentInvitationsLoaded = false;
|
|
2448
|
+
constructor(_invitationsManager) {
|
|
2449
|
+
this._invitationsManager = _invitationsManager;
|
|
2388
2450
|
}
|
|
2389
2451
|
// TODO(burdon): Guest/host label.
|
|
2390
2452
|
getLoggingContext() {
|
|
2391
2453
|
return {};
|
|
2392
2454
|
}
|
|
2393
2455
|
createInvitation(options) {
|
|
2394
|
-
|
|
2395
|
-
const savePersistentInvitationCtx = new import_context6.Context();
|
|
2396
|
-
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2397
|
-
if (existingInvitation) {
|
|
2398
|
-
invitation = existingInvitation;
|
|
2399
|
-
} else {
|
|
2400
|
-
const handler = this._getHandler(options);
|
|
2401
|
-
invitation = this._invitationsHandler.createInvitation(handler, options);
|
|
2402
|
-
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2403
|
-
this._invitationCreated.emit(invitation.get());
|
|
2404
|
-
}
|
|
2456
|
+
const invitation = this._invitationsManager.createInvitation(options);
|
|
2405
2457
|
return new import_codec_protobuf8.Stream(({ next, close }) => {
|
|
2406
|
-
|
|
2407
|
-
(0, import_async9.scheduleTask)(savePersistentInvitationCtx, async () => {
|
|
2408
|
-
try {
|
|
2409
|
-
await this._metadataStore.addInvitation(invitation.get());
|
|
2410
|
-
this._saved.emit(invitation.get());
|
|
2411
|
-
} catch (err) {
|
|
2412
|
-
close(err);
|
|
2413
|
-
}
|
|
2414
|
-
});
|
|
2415
|
-
}
|
|
2416
|
-
invitation.subscribe((invitation2) => {
|
|
2417
|
-
next(invitation2);
|
|
2418
|
-
}, async (err) => {
|
|
2419
|
-
await savePersistentInvitationCtx.dispose();
|
|
2420
|
-
close(err);
|
|
2421
|
-
}, async () => {
|
|
2422
|
-
close();
|
|
2423
|
-
if (invitation.get().persistent) {
|
|
2424
|
-
await savePersistentInvitationCtx.dispose();
|
|
2425
|
-
await this._metadataStore.removeInvitation(invitation.get().invitationId);
|
|
2426
|
-
}
|
|
2427
|
-
this._createInvitations.delete(invitation.get().invitationId);
|
|
2428
|
-
if (invitation.get().type !== import_services5.Invitation.Type.MULTIUSE) {
|
|
2429
|
-
this._removedCreated.emit(invitation.get());
|
|
2430
|
-
}
|
|
2431
|
-
});
|
|
2458
|
+
invitation.subscribe(next, close, close);
|
|
2432
2459
|
});
|
|
2433
2460
|
}
|
|
2434
|
-
|
|
2435
|
-
const
|
|
2436
|
-
const freshInvitations = persistentInvitations.filter(async (invitation) => !invitationExpired(invitation));
|
|
2437
|
-
const cInvitations = freshInvitations.map((persistentInvitation) => {
|
|
2438
|
-
(0, import_invariant7.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2439
|
-
F: __dxlog_file8,
|
|
2440
|
-
L: 109,
|
|
2441
|
-
S: this,
|
|
2442
|
-
A: [
|
|
2443
|
-
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2444
|
-
"'invitation already exists'"
|
|
2445
|
-
]
|
|
2446
|
-
});
|
|
2447
|
-
const handler = this._getHandler(persistentInvitation);
|
|
2448
|
-
const invitation = this._invitationsHandler.createInvitation(handler, persistentInvitation);
|
|
2449
|
-
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2450
|
-
this._invitationCreated.emit(invitation.get());
|
|
2451
|
-
return persistentInvitation;
|
|
2452
|
-
});
|
|
2453
|
-
this._persistentInvitationsLoadedEvent.emit();
|
|
2454
|
-
this._persistentInvitationsLoaded = true;
|
|
2455
|
-
return {
|
|
2456
|
-
invitations: cInvitations
|
|
2457
|
-
};
|
|
2458
|
-
}
|
|
2459
|
-
acceptInvitation({ invitation: options, deviceProfile }) {
|
|
2460
|
-
let invitation;
|
|
2461
|
-
if (deviceProfile) {
|
|
2462
|
-
(0, import_invariant7.invariant)(options.kind === import_services5.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2463
|
-
F: __dxlog_file8,
|
|
2464
|
-
L: 127,
|
|
2465
|
-
S: this,
|
|
2466
|
-
A: [
|
|
2467
|
-
"options.kind === Invitation.Kind.DEVICE",
|
|
2468
|
-
"'deviceProfile provided for non-device invitation'"
|
|
2469
|
-
]
|
|
2470
|
-
});
|
|
2471
|
-
}
|
|
2472
|
-
const existingInvitation = this._acceptInvitations.get(options.invitationId);
|
|
2473
|
-
if (existingInvitation) {
|
|
2474
|
-
invitation = existingInvitation;
|
|
2475
|
-
} else {
|
|
2476
|
-
const handler = this._getHandler(options);
|
|
2477
|
-
invitation = this._invitationsHandler.acceptInvitation(handler, options, deviceProfile);
|
|
2478
|
-
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
2479
|
-
this._invitationAccepted.emit(invitation.get());
|
|
2480
|
-
}
|
|
2461
|
+
acceptInvitation(request) {
|
|
2462
|
+
const invitation = this._invitationsManager.acceptInvitation(request);
|
|
2481
2463
|
return new import_codec_protobuf8.Stream(({ next, close }) => {
|
|
2482
|
-
invitation.subscribe(
|
|
2483
|
-
next(invitation2);
|
|
2484
|
-
}, (err) => {
|
|
2485
|
-
close(err);
|
|
2486
|
-
}, () => {
|
|
2487
|
-
close();
|
|
2488
|
-
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2489
|
-
if (invitation.get().type !== import_services5.Invitation.Type.MULTIUSE) {
|
|
2490
|
-
this._removedAccepted.emit(invitation.get());
|
|
2491
|
-
}
|
|
2492
|
-
});
|
|
2464
|
+
invitation.subscribe(next, close, close);
|
|
2493
2465
|
});
|
|
2494
2466
|
}
|
|
2495
|
-
async authenticate(
|
|
2496
|
-
|
|
2497
|
-
F: __dxlog_file8,
|
|
2498
|
-
L: 160,
|
|
2499
|
-
S: this,
|
|
2500
|
-
C: (f, a) => f(...a)
|
|
2501
|
-
});
|
|
2502
|
-
(0, import_invariant7.invariant)(invitationId, void 0, {
|
|
2503
|
-
F: __dxlog_file8,
|
|
2504
|
-
L: 161,
|
|
2505
|
-
S: this,
|
|
2506
|
-
A: [
|
|
2507
|
-
"invitationId",
|
|
2508
|
-
""
|
|
2509
|
-
]
|
|
2510
|
-
});
|
|
2511
|
-
const observable = this._acceptInvitations.get(invitationId);
|
|
2512
|
-
if (!observable) {
|
|
2513
|
-
import_log6.log.warn("invalid invitation", {
|
|
2514
|
-
invitationId
|
|
2515
|
-
}, {
|
|
2516
|
-
F: __dxlog_file8,
|
|
2517
|
-
L: 164,
|
|
2518
|
-
S: this,
|
|
2519
|
-
C: (f, a) => f(...a)
|
|
2520
|
-
});
|
|
2521
|
-
} else {
|
|
2522
|
-
await observable.authenticate(authCode);
|
|
2523
|
-
}
|
|
2467
|
+
async authenticate(request) {
|
|
2468
|
+
return this._invitationsManager.authenticate(request);
|
|
2524
2469
|
}
|
|
2525
|
-
async cancelInvitation(
|
|
2526
|
-
|
|
2527
|
-
invitationId
|
|
2528
|
-
}, {
|
|
2529
|
-
F: __dxlog_file8,
|
|
2530
|
-
L: 171,
|
|
2531
|
-
S: this,
|
|
2532
|
-
C: (f, a) => f(...a)
|
|
2533
|
-
});
|
|
2534
|
-
(0, import_invariant7.invariant)(invitationId, void 0, {
|
|
2535
|
-
F: __dxlog_file8,
|
|
2536
|
-
L: 172,
|
|
2537
|
-
S: this,
|
|
2538
|
-
A: [
|
|
2539
|
-
"invitationId",
|
|
2540
|
-
""
|
|
2541
|
-
]
|
|
2542
|
-
});
|
|
2543
|
-
const created = this._createInvitations.get(invitationId);
|
|
2544
|
-
const accepted = this._acceptInvitations.get(invitationId);
|
|
2545
|
-
if (created) {
|
|
2546
|
-
await created.cancel();
|
|
2547
|
-
this._createInvitations.delete(invitationId);
|
|
2548
|
-
this._removedCreated.emit(created.get());
|
|
2549
|
-
if (created.get().persistent) {
|
|
2550
|
-
await this._metadataStore.removeInvitation(created.get().invitationId);
|
|
2551
|
-
}
|
|
2552
|
-
} else if (accepted) {
|
|
2553
|
-
await accepted.cancel();
|
|
2554
|
-
this._acceptInvitations.delete(invitationId);
|
|
2555
|
-
this._removedAccepted.emit(accepted.get());
|
|
2556
|
-
}
|
|
2470
|
+
async cancelInvitation(request) {
|
|
2471
|
+
return this._invitationsManager.cancelInvitation(request);
|
|
2557
2472
|
}
|
|
2558
2473
|
queryInvitations() {
|
|
2559
2474
|
return new import_codec_protobuf8.Stream(({ next, ctx }) => {
|
|
2560
|
-
this.
|
|
2475
|
+
this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
|
|
2561
2476
|
next({
|
|
2562
2477
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2563
2478
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2566,7 +2481,7 @@ var InvitationsServiceImpl = class {
|
|
|
2566
2481
|
]
|
|
2567
2482
|
});
|
|
2568
2483
|
});
|
|
2569
|
-
this.
|
|
2484
|
+
this._invitationsManager.invitationAccepted.on(ctx, (invitation) => {
|
|
2570
2485
|
next({
|
|
2571
2486
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2572
2487
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2575,7 +2490,7 @@ var InvitationsServiceImpl = class {
|
|
|
2575
2490
|
]
|
|
2576
2491
|
});
|
|
2577
2492
|
});
|
|
2578
|
-
this.
|
|
2493
|
+
this._invitationsManager.removedCreated.on(ctx, (invitation) => {
|
|
2579
2494
|
next({
|
|
2580
2495
|
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2581
2496
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2584,7 +2499,7 @@ var InvitationsServiceImpl = class {
|
|
|
2584
2499
|
]
|
|
2585
2500
|
});
|
|
2586
2501
|
});
|
|
2587
|
-
this.
|
|
2502
|
+
this._invitationsManager.removedAccepted.on(ctx, (invitation) => {
|
|
2588
2503
|
next({
|
|
2589
2504
|
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2590
2505
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2593,7 +2508,7 @@ var InvitationsServiceImpl = class {
|
|
|
2593
2508
|
]
|
|
2594
2509
|
});
|
|
2595
2510
|
});
|
|
2596
|
-
this.
|
|
2511
|
+
this._invitationsManager.saved.on(ctx, (invitation) => {
|
|
2597
2512
|
next({
|
|
2598
2513
|
action: import_services5.QueryInvitationsResponse.Action.SAVED,
|
|
2599
2514
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2605,32 +2520,25 @@ var InvitationsServiceImpl = class {
|
|
|
2605
2520
|
next({
|
|
2606
2521
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2607
2522
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
2608
|
-
invitations:
|
|
2523
|
+
invitations: this._invitationsManager.getCreatedInvitations(),
|
|
2609
2524
|
existing: true
|
|
2610
2525
|
});
|
|
2611
2526
|
next({
|
|
2612
2527
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2613
2528
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
2614
|
-
invitations:
|
|
2529
|
+
invitations: this._invitationsManager.getAcceptedInvitations(),
|
|
2615
2530
|
existing: true
|
|
2616
2531
|
});
|
|
2617
|
-
|
|
2532
|
+
this._invitationsManager.onPersistentInvitationsLoaded(ctx, () => {
|
|
2618
2533
|
next({
|
|
2619
2534
|
action: import_services5.QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2620
2535
|
type: import_services5.QueryInvitationsResponse.Type.CREATED
|
|
2621
2536
|
});
|
|
2622
|
-
}
|
|
2623
|
-
this._persistentInvitationsLoadedEvent.on(ctx, () => {
|
|
2624
|
-
next({
|
|
2625
|
-
action: import_services5.QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2626
|
-
type: import_services5.QueryInvitationsResponse.Type.CREATED
|
|
2627
|
-
});
|
|
2628
|
-
});
|
|
2629
|
-
}
|
|
2537
|
+
});
|
|
2630
2538
|
});
|
|
2631
2539
|
}
|
|
2632
2540
|
};
|
|
2633
|
-
var
|
|
2541
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2634
2542
|
var SpaceInvitationProtocol = class {
|
|
2635
2543
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
2636
2544
|
this._spaceManager = _spaceManager;
|
|
@@ -2651,8 +2559,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2651
2559
|
};
|
|
2652
2560
|
}
|
|
2653
2561
|
async admit(request, guestProfile) {
|
|
2654
|
-
(0,
|
|
2655
|
-
F:
|
|
2562
|
+
(0, import_invariant7.invariant)(this._spaceKey, void 0, {
|
|
2563
|
+
F: __dxlog_file8,
|
|
2656
2564
|
L: 47,
|
|
2657
2565
|
S: this,
|
|
2658
2566
|
A: [
|
|
@@ -2661,8 +2569,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2661
2569
|
]
|
|
2662
2570
|
});
|
|
2663
2571
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2664
|
-
(0,
|
|
2665
|
-
F:
|
|
2572
|
+
(0, import_invariant7.invariant)(space, void 0, {
|
|
2573
|
+
F: __dxlog_file8,
|
|
2666
2574
|
L: 49,
|
|
2667
2575
|
S: this,
|
|
2668
2576
|
A: [
|
|
@@ -2670,8 +2578,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2670
2578
|
""
|
|
2671
2579
|
]
|
|
2672
2580
|
});
|
|
2673
|
-
(0,
|
|
2674
|
-
F:
|
|
2581
|
+
(0, import_invariant7.invariant)(request.space, void 0, {
|
|
2582
|
+
F: __dxlog_file8,
|
|
2675
2583
|
L: 51,
|
|
2676
2584
|
S: this,
|
|
2677
2585
|
A: [
|
|
@@ -2680,18 +2588,18 @@ var SpaceInvitationProtocol = class {
|
|
|
2680
2588
|
]
|
|
2681
2589
|
});
|
|
2682
2590
|
const { identityKey, deviceKey } = request.space;
|
|
2683
|
-
(0,
|
|
2591
|
+
(0, import_log6.log)("writing guest credentials", {
|
|
2684
2592
|
host: this._signingContext.deviceKey,
|
|
2685
2593
|
guest: deviceKey
|
|
2686
2594
|
}, {
|
|
2687
|
-
F:
|
|
2595
|
+
F: __dxlog_file8,
|
|
2688
2596
|
L: 54,
|
|
2689
2597
|
S: this,
|
|
2690
2598
|
C: (f, a) => f(...a)
|
|
2691
2599
|
});
|
|
2692
2600
|
const credentials = await (0, import_credentials8.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2693
|
-
(0,
|
|
2694
|
-
F:
|
|
2601
|
+
(0, import_invariant7.invariant)(credentials[0].credential, void 0, {
|
|
2602
|
+
F: __dxlog_file8,
|
|
2695
2603
|
L: 65,
|
|
2696
2604
|
S: this,
|
|
2697
2605
|
A: [
|
|
@@ -2700,8 +2608,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2700
2608
|
]
|
|
2701
2609
|
});
|
|
2702
2610
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2703
|
-
(0,
|
|
2704
|
-
F:
|
|
2611
|
+
(0, import_invariant7.invariant)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2612
|
+
F: __dxlog_file8,
|
|
2705
2613
|
L: 67,
|
|
2706
2614
|
S: this,
|
|
2707
2615
|
A: [
|
|
@@ -2740,8 +2648,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2740
2648
|
};
|
|
2741
2649
|
}
|
|
2742
2650
|
async accept(response) {
|
|
2743
|
-
(0,
|
|
2744
|
-
F:
|
|
2651
|
+
(0, import_invariant7.invariant)(response.space, void 0, {
|
|
2652
|
+
F: __dxlog_file8,
|
|
2745
2653
|
L: 107,
|
|
2746
2654
|
S: this,
|
|
2747
2655
|
A: [
|
|
@@ -2751,8 +2659,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2751
2659
|
});
|
|
2752
2660
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2753
2661
|
const assertion = (0, import_credentials8.getCredentialAssertion)(credential);
|
|
2754
|
-
(0,
|
|
2755
|
-
F:
|
|
2662
|
+
(0, import_invariant7.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2663
|
+
F: __dxlog_file8,
|
|
2756
2664
|
L: 110,
|
|
2757
2665
|
S: this,
|
|
2758
2666
|
A: [
|
|
@@ -2760,8 +2668,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2760
2668
|
"'Invalid credential'"
|
|
2761
2669
|
]
|
|
2762
2670
|
});
|
|
2763
|
-
(0,
|
|
2764
|
-
F:
|
|
2671
|
+
(0, import_invariant7.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2672
|
+
F: __dxlog_file8,
|
|
2765
2673
|
L: 111,
|
|
2766
2674
|
S: this,
|
|
2767
2675
|
A: [
|
|
@@ -2784,6 +2692,221 @@ var SpaceInvitationProtocol = class {
|
|
|
2784
2692
|
};
|
|
2785
2693
|
}
|
|
2786
2694
|
};
|
|
2695
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
2696
|
+
var InvitationsManager = class {
|
|
2697
|
+
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
2698
|
+
this._invitationsHandler = _invitationsHandler;
|
|
2699
|
+
this._getHandler = _getHandler;
|
|
2700
|
+
this._metadataStore = _metadataStore;
|
|
2701
|
+
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2702
|
+
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2703
|
+
this.invitationCreated = new import_async9.Event();
|
|
2704
|
+
this.invitationAccepted = new import_async9.Event();
|
|
2705
|
+
this.removedCreated = new import_async9.Event();
|
|
2706
|
+
this.removedAccepted = new import_async9.Event();
|
|
2707
|
+
this.saved = new import_async9.Event();
|
|
2708
|
+
this._persistentInvitationsLoadedEvent = new import_async9.Event();
|
|
2709
|
+
this._persistentInvitationsLoaded = false;
|
|
2710
|
+
}
|
|
2711
|
+
createInvitation(options) {
|
|
2712
|
+
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2713
|
+
if (existingInvitation) {
|
|
2714
|
+
return existingInvitation;
|
|
2715
|
+
}
|
|
2716
|
+
const handler = this._getHandler(options);
|
|
2717
|
+
const invitation = this._invitationsHandler.createInvitation(handler, options);
|
|
2718
|
+
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2719
|
+
this.invitationCreated.emit(invitation.get());
|
|
2720
|
+
const saveInvitationTask = invitation.get().persistent ? this._safePersistInBackground(invitation) : Promise.resolve();
|
|
2721
|
+
this._onInvitationComplete(invitation, async () => {
|
|
2722
|
+
this._createInvitations.delete(invitation.get().invitationId);
|
|
2723
|
+
this.removedCreated.emit(invitation.get());
|
|
2724
|
+
if (invitation.get().persistent) {
|
|
2725
|
+
await saveInvitationTask;
|
|
2726
|
+
await this._safeDeleteInvitation(invitation.get());
|
|
2727
|
+
}
|
|
2728
|
+
});
|
|
2729
|
+
return invitation;
|
|
2730
|
+
}
|
|
2731
|
+
async loadPersistentInvitations() {
|
|
2732
|
+
if (this._persistentInvitationsLoaded) {
|
|
2733
|
+
const invitations = this.getCreatedInvitations().filter((i) => i.persistent);
|
|
2734
|
+
return {
|
|
2735
|
+
invitations
|
|
2736
|
+
};
|
|
2737
|
+
}
|
|
2738
|
+
try {
|
|
2739
|
+
const persistentInvitations = this._metadataStore.getInvitations();
|
|
2740
|
+
const freshInvitations = persistentInvitations.filter((invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
|
|
2741
|
+
const cInvitations = freshInvitations.map((persistentInvitation) => {
|
|
2742
|
+
(0, import_invariant8.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2743
|
+
F: __dxlog_file9,
|
|
2744
|
+
L: 82,
|
|
2745
|
+
S: this,
|
|
2746
|
+
A: [
|
|
2747
|
+
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2748
|
+
"'invitation already exists'"
|
|
2749
|
+
]
|
|
2750
|
+
});
|
|
2751
|
+
return this.createInvitation({
|
|
2752
|
+
...persistentInvitation,
|
|
2753
|
+
persistent: false
|
|
2754
|
+
}).get();
|
|
2755
|
+
});
|
|
2756
|
+
return {
|
|
2757
|
+
invitations: cInvitations
|
|
2758
|
+
};
|
|
2759
|
+
} catch (err) {
|
|
2760
|
+
import_log7.log.catch(err, void 0, {
|
|
2761
|
+
F: __dxlog_file9,
|
|
2762
|
+
L: 88,
|
|
2763
|
+
S: this,
|
|
2764
|
+
C: (f, a) => f(...a)
|
|
2765
|
+
});
|
|
2766
|
+
return {
|
|
2767
|
+
invitations: []
|
|
2768
|
+
};
|
|
2769
|
+
} finally {
|
|
2770
|
+
this._persistentInvitationsLoadedEvent.emit();
|
|
2771
|
+
this._persistentInvitationsLoaded = true;
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
acceptInvitation(request) {
|
|
2775
|
+
const options = request.invitation;
|
|
2776
|
+
const existingInvitation = this._acceptInvitations.get(options.invitationId);
|
|
2777
|
+
if (existingInvitation) {
|
|
2778
|
+
return existingInvitation;
|
|
2779
|
+
}
|
|
2780
|
+
const handler = this._getHandler(options);
|
|
2781
|
+
const invitation = this._invitationsHandler.acceptInvitation(handler, options, request.deviceProfile);
|
|
2782
|
+
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
2783
|
+
this.invitationAccepted.emit(invitation.get());
|
|
2784
|
+
this._onInvitationComplete(invitation, () => {
|
|
2785
|
+
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2786
|
+
this.removedAccepted.emit(invitation.get());
|
|
2787
|
+
});
|
|
2788
|
+
return invitation;
|
|
2789
|
+
}
|
|
2790
|
+
async authenticate({ invitationId, authCode }) {
|
|
2791
|
+
(0, import_log7.log)("authenticating...", void 0, {
|
|
2792
|
+
F: __dxlog_file9,
|
|
2793
|
+
L: 117,
|
|
2794
|
+
S: this,
|
|
2795
|
+
C: (f, a) => f(...a)
|
|
2796
|
+
});
|
|
2797
|
+
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2798
|
+
F: __dxlog_file9,
|
|
2799
|
+
L: 118,
|
|
2800
|
+
S: this,
|
|
2801
|
+
A: [
|
|
2802
|
+
"invitationId",
|
|
2803
|
+
""
|
|
2804
|
+
]
|
|
2805
|
+
});
|
|
2806
|
+
const observable = this._acceptInvitations.get(invitationId);
|
|
2807
|
+
if (!observable) {
|
|
2808
|
+
import_log7.log.warn("invalid invitation", {
|
|
2809
|
+
invitationId
|
|
2810
|
+
}, {
|
|
2811
|
+
F: __dxlog_file9,
|
|
2812
|
+
L: 121,
|
|
2813
|
+
S: this,
|
|
2814
|
+
C: (f, a) => f(...a)
|
|
2815
|
+
});
|
|
2816
|
+
} else {
|
|
2817
|
+
await observable.authenticate(authCode);
|
|
2818
|
+
}
|
|
2819
|
+
}
|
|
2820
|
+
async cancelInvitation({ invitationId }) {
|
|
2821
|
+
(0, import_log7.log)("cancelInvitation...", {
|
|
2822
|
+
invitationId
|
|
2823
|
+
}, {
|
|
2824
|
+
F: __dxlog_file9,
|
|
2825
|
+
L: 128,
|
|
2826
|
+
S: this,
|
|
2827
|
+
C: (f, a) => f(...a)
|
|
2828
|
+
});
|
|
2829
|
+
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2830
|
+
F: __dxlog_file9,
|
|
2831
|
+
L: 129,
|
|
2832
|
+
S: this,
|
|
2833
|
+
A: [
|
|
2834
|
+
"invitationId",
|
|
2835
|
+
""
|
|
2836
|
+
]
|
|
2837
|
+
});
|
|
2838
|
+
const created = this._createInvitations.get(invitationId);
|
|
2839
|
+
if (created) {
|
|
2840
|
+
if (created.get().persistent) {
|
|
2841
|
+
await this._metadataStore.removeInvitation(invitationId);
|
|
2842
|
+
}
|
|
2843
|
+
await created.cancel();
|
|
2844
|
+
this._createInvitations.delete(invitationId);
|
|
2845
|
+
this.removedCreated.emit(created.get());
|
|
2846
|
+
return;
|
|
2847
|
+
}
|
|
2848
|
+
const accepted = this._acceptInvitations.get(invitationId);
|
|
2849
|
+
if (accepted) {
|
|
2850
|
+
await accepted.cancel();
|
|
2851
|
+
this._acceptInvitations.delete(invitationId);
|
|
2852
|
+
this.removedAccepted.emit(accepted.get());
|
|
2853
|
+
}
|
|
2854
|
+
}
|
|
2855
|
+
getCreatedInvitations() {
|
|
2856
|
+
return [
|
|
2857
|
+
...this._createInvitations.values()
|
|
2858
|
+
].map((i) => i.get());
|
|
2859
|
+
}
|
|
2860
|
+
getAcceptedInvitations() {
|
|
2861
|
+
return [
|
|
2862
|
+
...this._acceptInvitations.values()
|
|
2863
|
+
].map((i) => i.get());
|
|
2864
|
+
}
|
|
2865
|
+
onPersistentInvitationsLoaded(ctx, callback) {
|
|
2866
|
+
if (this._persistentInvitationsLoaded) {
|
|
2867
|
+
callback();
|
|
2868
|
+
} else {
|
|
2869
|
+
this._persistentInvitationsLoadedEvent.once(ctx, () => callback());
|
|
2870
|
+
}
|
|
2871
|
+
}
|
|
2872
|
+
_safePersistInBackground(invitation) {
|
|
2873
|
+
return new Promise((resolve) => {
|
|
2874
|
+
setTimeout(async () => {
|
|
2875
|
+
try {
|
|
2876
|
+
await this._metadataStore.addInvitation(invitation.get());
|
|
2877
|
+
this.saved.emit(invitation.get());
|
|
2878
|
+
} catch (err) {
|
|
2879
|
+
import_log7.log.catch(err, void 0, {
|
|
2880
|
+
F: __dxlog_file9,
|
|
2881
|
+
L: 173,
|
|
2882
|
+
S: this,
|
|
2883
|
+
C: (f, a) => f(...a)
|
|
2884
|
+
});
|
|
2885
|
+
await invitation.cancel();
|
|
2886
|
+
} finally {
|
|
2887
|
+
resolve();
|
|
2888
|
+
}
|
|
2889
|
+
});
|
|
2890
|
+
});
|
|
2891
|
+
}
|
|
2892
|
+
async _safeDeleteInvitation(invitation) {
|
|
2893
|
+
try {
|
|
2894
|
+
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
2895
|
+
} catch (err) {
|
|
2896
|
+
import_log7.log.catch(err, void 0, {
|
|
2897
|
+
F: __dxlog_file9,
|
|
2898
|
+
L: 186,
|
|
2899
|
+
S: this,
|
|
2900
|
+
C: (f, a) => f(...a)
|
|
2901
|
+
});
|
|
2902
|
+
}
|
|
2903
|
+
}
|
|
2904
|
+
_onInvitationComplete(invitation, callback) {
|
|
2905
|
+
invitation.subscribe(() => {
|
|
2906
|
+
}, () => {
|
|
2907
|
+
}, callback);
|
|
2908
|
+
}
|
|
2909
|
+
};
|
|
2787
2910
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
2788
2911
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2789
2912
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -2859,141 +2982,6 @@ _ts_decorate3([
|
|
|
2859
2982
|
ClientRpcServer = _ts_decorate3([
|
|
2860
2983
|
import_tracing3.trace.resource()
|
|
2861
2984
|
], ClientRpcServer);
|
|
2862
|
-
var getPlatform = () => {
|
|
2863
|
-
if (process.browser) {
|
|
2864
|
-
if (typeof window !== "undefined") {
|
|
2865
|
-
const { userAgent } = window.navigator;
|
|
2866
|
-
return {
|
|
2867
|
-
type: import_services8.Platform.PLATFORM_TYPE.BROWSER,
|
|
2868
|
-
userAgent,
|
|
2869
|
-
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
2870
|
-
};
|
|
2871
|
-
} else {
|
|
2872
|
-
return {
|
|
2873
|
-
type: import_services8.Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
2874
|
-
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
2875
|
-
};
|
|
2876
|
-
}
|
|
2877
|
-
} else {
|
|
2878
|
-
const { platform: platform2, version, arch } = process;
|
|
2879
|
-
return {
|
|
2880
|
-
type: import_services8.Platform.PLATFORM_TYPE.NODE,
|
|
2881
|
-
platform: platform2,
|
|
2882
|
-
arch,
|
|
2883
|
-
runtime: version,
|
|
2884
|
-
uptime: Math.floor(process.uptime()),
|
|
2885
|
-
memory: process.memoryUsage()
|
|
2886
|
-
};
|
|
2887
|
-
}
|
|
2888
|
-
};
|
|
2889
|
-
var DXOS_VERSION = "0.4.10-main.0302e13";
|
|
2890
|
-
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
2891
|
-
var DEFAULT_TIMEOUT = 1e3;
|
|
2892
|
-
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
2893
|
-
const diagnostics = {
|
|
2894
|
-
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2895
|
-
platform: getPlatform(),
|
|
2896
|
-
client: {
|
|
2897
|
-
version: DXOS_VERSION,
|
|
2898
|
-
storage: {
|
|
2899
|
-
version: import_protocols7.STORAGE_VERSION
|
|
2900
|
-
}
|
|
2901
|
-
},
|
|
2902
|
-
trace: import_tracing4.TRACE_PROCESSOR.getDiagnostics()
|
|
2903
|
-
};
|
|
2904
|
-
{
|
|
2905
|
-
(0, import_invariant9.invariant)(clientServices.LoggingService, "SystemService is not available.", {
|
|
2906
|
-
F: __dxlog_file10,
|
|
2907
|
-
L: 108,
|
|
2908
|
-
S: void 0,
|
|
2909
|
-
A: [
|
|
2910
|
-
"clientServices.LoggingService",
|
|
2911
|
-
"'SystemService is not available.'"
|
|
2912
|
-
]
|
|
2913
|
-
});
|
|
2914
|
-
diagnostics.metrics = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
|
|
2915
|
-
timeout: DEFAULT_TIMEOUT
|
|
2916
|
-
}).catch(() => void 0);
|
|
2917
|
-
}
|
|
2918
|
-
if (typeof navigator !== "undefined" && navigator.storage) {
|
|
2919
|
-
const map = /* @__PURE__ */ new Map();
|
|
2920
|
-
const dir = await navigator.storage.getDirectory();
|
|
2921
|
-
for await (const filename of dir?.keys()) {
|
|
2922
|
-
const idx = filename.indexOf("-", filename.indexOf("-") + 1);
|
|
2923
|
-
if (idx === -1) {
|
|
2924
|
-
continue;
|
|
2925
|
-
}
|
|
2926
|
-
map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
|
|
2927
|
-
}
|
|
2928
|
-
diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
|
|
2929
|
-
file,
|
|
2930
|
-
count
|
|
2931
|
-
}));
|
|
2932
|
-
}
|
|
2933
|
-
const identity = serviceContext.identityManager.identity;
|
|
2934
|
-
if (identity) {
|
|
2935
|
-
diagnostics.identity = {
|
|
2936
|
-
identityKey: identity.identityKey,
|
|
2937
|
-
spaceKey: identity.space.key,
|
|
2938
|
-
profile: identity.profileDocument
|
|
2939
|
-
};
|
|
2940
|
-
const { devices } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
|
|
2941
|
-
timeout: DEFAULT_TIMEOUT
|
|
2942
|
-
}).catch(() => void 0) ?? {};
|
|
2943
|
-
diagnostics.devices = devices;
|
|
2944
|
-
if (serviceContext.dataSpaceManager) {
|
|
2945
|
-
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
2946
|
-
}
|
|
2947
|
-
const { feeds = [] } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
2948
|
-
timeout: DEFAULT_TIMEOUT
|
|
2949
|
-
}).catch(() => void 0) ?? {};
|
|
2950
|
-
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
2951
|
-
feedKey,
|
|
2952
|
-
bytes,
|
|
2953
|
-
length
|
|
2954
|
-
}));
|
|
2955
|
-
const status = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
|
|
2956
|
-
timeout: DEFAULT_TIMEOUT
|
|
2957
|
-
}).catch(() => void 0);
|
|
2958
|
-
diagnostics.networkStatus = status;
|
|
2959
|
-
diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
|
|
2960
|
-
}
|
|
2961
|
-
diagnostics.config = config.values;
|
|
2962
|
-
return diagnostics;
|
|
2963
|
-
};
|
|
2964
|
-
var getSpaceStats = async (space) => {
|
|
2965
|
-
const stats = {
|
|
2966
|
-
key: space.key,
|
|
2967
|
-
metrics: space.metrics,
|
|
2968
|
-
epochs: space.inner.spaceState.credentials.filter((0, import_credentials9.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
2969
|
-
...credential.subject.assertion,
|
|
2970
|
-
id: credential.id
|
|
2971
|
-
})),
|
|
2972
|
-
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
2973
|
-
identity: {
|
|
2974
|
-
identityKey: member.key,
|
|
2975
|
-
profile: {
|
|
2976
|
-
displayName: member.assertion.profile?.displayName
|
|
2977
|
-
}
|
|
2978
|
-
},
|
|
2979
|
-
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services7.SpaceMember.PresenceState.ONLINE : import_services7.SpaceMember.PresenceState.OFFLINE
|
|
2980
|
-
})),
|
|
2981
|
-
pipeline: {
|
|
2982
|
-
// TODO(burdon): Pick properties from credentials if needed.
|
|
2983
|
-
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
2984
|
-
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
2985
|
-
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
2986
|
-
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2987
|
-
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
2988
|
-
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
|
|
2989
|
-
}
|
|
2990
|
-
};
|
|
2991
|
-
if (stats.metrics) {
|
|
2992
|
-
const { open, ready } = stats.metrics;
|
|
2993
|
-
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
2994
|
-
}
|
|
2995
|
-
return stats;
|
|
2996
|
-
};
|
|
2997
2985
|
var AutomergeSpaceState = class {
|
|
2998
2986
|
constructor(_onNewRoot) {
|
|
2999
2987
|
this._onNewRoot = _onNewRoot;
|
|
@@ -3003,7 +2991,7 @@ var AutomergeSpaceState = class {
|
|
|
3003
2991
|
this._isProcessingRootDocs = false;
|
|
3004
2992
|
}
|
|
3005
2993
|
async processCredential(credential) {
|
|
3006
|
-
if (!(0,
|
|
2994
|
+
if (!(0, import_credentials10.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
3007
2995
|
return;
|
|
3008
2996
|
}
|
|
3009
2997
|
this.lastEpoch = credential;
|
|
@@ -3028,14 +3016,14 @@ var AutomergeSpaceState = class {
|
|
|
3028
3016
|
await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
|
|
3029
3017
|
}
|
|
3030
3018
|
};
|
|
3031
|
-
var
|
|
3019
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
3032
3020
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
3033
3021
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
3034
3022
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
3035
3023
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
3036
3024
|
var NotarizationPlugin = class {
|
|
3037
3025
|
constructor() {
|
|
3038
|
-
this._ctx = new
|
|
3026
|
+
this._ctx = new import_context7.Context();
|
|
3039
3027
|
this._extensionOpened = new import_async12.Event();
|
|
3040
3028
|
this._extensions = /* @__PURE__ */ new Set();
|
|
3041
3029
|
this._processedCredentials = new import_util5.ComplexSet(import_keys8.PublicKey.hash);
|
|
@@ -3056,13 +3044,13 @@ var NotarizationPlugin = class {
|
|
|
3056
3044
|
(0, import_log9.log)("notarize", {
|
|
3057
3045
|
credentials
|
|
3058
3046
|
}, {
|
|
3059
|
-
F:
|
|
3047
|
+
F: __dxlog_file10,
|
|
3060
3048
|
L: 90,
|
|
3061
3049
|
S: this,
|
|
3062
3050
|
C: (f, a) => f(...a)
|
|
3063
3051
|
});
|
|
3064
|
-
(0,
|
|
3065
|
-
F:
|
|
3052
|
+
(0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
3053
|
+
F: __dxlog_file10,
|
|
3066
3054
|
L: 91,
|
|
3067
3055
|
S: this,
|
|
3068
3056
|
A: [
|
|
@@ -3076,7 +3064,7 @@ var NotarizationPlugin = class {
|
|
|
3076
3064
|
import_log9.log.warn("Notarization error", {
|
|
3077
3065
|
err
|
|
3078
3066
|
}, {
|
|
3079
|
-
F:
|
|
3067
|
+
F: __dxlog_file10,
|
|
3080
3068
|
L: 99,
|
|
3081
3069
|
S: this,
|
|
3082
3070
|
C: (f, a) => f(...a)
|
|
@@ -3092,7 +3080,7 @@ var NotarizationPlugin = class {
|
|
|
3092
3080
|
timeout,
|
|
3093
3081
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3094
3082
|
}, {
|
|
3095
|
-
F:
|
|
3083
|
+
F: __dxlog_file10,
|
|
3096
3084
|
L: 111,
|
|
3097
3085
|
S: this,
|
|
3098
3086
|
C: (f, a) => f(...a)
|
|
@@ -3115,7 +3103,7 @@ var NotarizationPlugin = class {
|
|
|
3115
3103
|
import_log9.log.info("Exhausted all peers to notarize with", {
|
|
3116
3104
|
retryIn: retryTimeout
|
|
3117
3105
|
}, {
|
|
3118
|
-
F:
|
|
3106
|
+
F: __dxlog_file10,
|
|
3119
3107
|
L: 136,
|
|
3120
3108
|
S: this,
|
|
3121
3109
|
C: (f, a) => f(...a)
|
|
@@ -3129,7 +3117,7 @@ var NotarizationPlugin = class {
|
|
|
3129
3117
|
peer: peer.localPeerId,
|
|
3130
3118
|
credentialId: credentials.map((credential) => credential.id)
|
|
3131
3119
|
}, {
|
|
3132
|
-
F:
|
|
3120
|
+
F: __dxlog_file10,
|
|
3133
3121
|
L: 143,
|
|
3134
3122
|
S: this,
|
|
3135
3123
|
C: (f, a) => f(...a)
|
|
@@ -3138,7 +3126,7 @@ var NotarizationPlugin = class {
|
|
|
3138
3126
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
3139
3127
|
});
|
|
3140
3128
|
(0, import_log9.log)("success", void 0, {
|
|
3141
|
-
F:
|
|
3129
|
+
F: __dxlog_file10,
|
|
3142
3130
|
L: 147,
|
|
3143
3131
|
S: this,
|
|
3144
3132
|
C: (f, a) => f(...a)
|
|
@@ -3147,7 +3135,7 @@ var NotarizationPlugin = class {
|
|
|
3147
3135
|
} catch (err) {
|
|
3148
3136
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
3149
3137
|
import_log9.log.info("error notarizing (recoverable)", err, {
|
|
3150
|
-
F:
|
|
3138
|
+
F: __dxlog_file10,
|
|
3151
3139
|
L: 151,
|
|
3152
3140
|
S: this,
|
|
3153
3141
|
C: (f, a) => f(...a)
|
|
@@ -3160,12 +3148,12 @@ var NotarizationPlugin = class {
|
|
|
3160
3148
|
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
3161
3149
|
try {
|
|
3162
3150
|
await Promise.race([
|
|
3163
|
-
(0,
|
|
3151
|
+
(0, import_context7.rejectOnDispose)(ctx),
|
|
3164
3152
|
allNotarized,
|
|
3165
3153
|
errors.wait()
|
|
3166
3154
|
]);
|
|
3167
3155
|
(0, import_log9.log)("done", void 0, {
|
|
3168
|
-
F:
|
|
3156
|
+
F: __dxlog_file10,
|
|
3169
3157
|
L: 162,
|
|
3170
3158
|
S: this,
|
|
3171
3159
|
C: (f, a) => f(...a)
|
|
@@ -3186,8 +3174,8 @@ var NotarizationPlugin = class {
|
|
|
3186
3174
|
this._processCredentialsTriggers.delete(credential.id);
|
|
3187
3175
|
}
|
|
3188
3176
|
setWriter(writer) {
|
|
3189
|
-
(0,
|
|
3190
|
-
F:
|
|
3177
|
+
(0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
|
|
3178
|
+
F: __dxlog_file10,
|
|
3191
3179
|
L: 181,
|
|
3192
3180
|
S: this,
|
|
3193
3181
|
A: [
|
|
@@ -3211,8 +3199,8 @@ var NotarizationPlugin = class {
|
|
|
3211
3199
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
3212
3200
|
}
|
|
3213
3201
|
for (const credential of request.credentials ?? []) {
|
|
3214
|
-
(0,
|
|
3215
|
-
F:
|
|
3202
|
+
(0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
|
|
3203
|
+
F: __dxlog_file10,
|
|
3216
3204
|
L: 200,
|
|
3217
3205
|
S: this,
|
|
3218
3206
|
A: [
|
|
@@ -3232,7 +3220,7 @@ var NotarizationPlugin = class {
|
|
|
3232
3220
|
(0, import_log9.log)("extension opened", {
|
|
3233
3221
|
peer: extension.localPeerId
|
|
3234
3222
|
}, {
|
|
3235
|
-
F:
|
|
3223
|
+
F: __dxlog_file10,
|
|
3236
3224
|
L: 211,
|
|
3237
3225
|
S: this,
|
|
3238
3226
|
C: (f, a) => f(...a)
|
|
@@ -3244,7 +3232,7 @@ var NotarizationPlugin = class {
|
|
|
3244
3232
|
(0, import_log9.log)("extension closed", {
|
|
3245
3233
|
peer: extension.localPeerId
|
|
3246
3234
|
}, {
|
|
3247
|
-
F:
|
|
3235
|
+
F: __dxlog_file10,
|
|
3248
3236
|
L: 216,
|
|
3249
3237
|
S: this,
|
|
3250
3238
|
C: (f, a) => f(...a)
|
|
@@ -3260,10 +3248,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
3260
3248
|
constructor(_params) {
|
|
3261
3249
|
super({
|
|
3262
3250
|
requested: {
|
|
3263
|
-
NotarizationService:
|
|
3251
|
+
NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3264
3252
|
},
|
|
3265
3253
|
exposed: {
|
|
3266
|
-
NotarizationService:
|
|
3254
|
+
NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3267
3255
|
}
|
|
3268
3256
|
});
|
|
3269
3257
|
this._params = _params;
|
|
@@ -3296,14 +3284,14 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3296
3284
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3297
3285
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3298
3286
|
}
|
|
3299
|
-
var
|
|
3287
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3300
3288
|
var DataSpace = class {
|
|
3301
3289
|
constructor(params) {
|
|
3302
|
-
this._ctx = new
|
|
3290
|
+
this._ctx = new import_context6.Context();
|
|
3303
3291
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3304
3292
|
this._cache = void 0;
|
|
3305
3293
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
3306
|
-
this._state =
|
|
3294
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
3307
3295
|
this.error = void 0;
|
|
3308
3296
|
this.stateUpdate = new import_async10.Event();
|
|
3309
3297
|
this.metrics = {};
|
|
@@ -3325,9 +3313,9 @@ var DataSpace = class {
|
|
|
3325
3313
|
this._cache = params.cache;
|
|
3326
3314
|
this._state = params.initialState;
|
|
3327
3315
|
(0, import_log8.log)("new state", {
|
|
3328
|
-
state:
|
|
3316
|
+
state: import_services7.SpaceState[this._state]
|
|
3329
3317
|
}, {
|
|
3330
|
-
F:
|
|
3318
|
+
F: __dxlog_file11,
|
|
3331
3319
|
L: 140,
|
|
3332
3320
|
S: this,
|
|
3333
3321
|
C: (f, a) => f(...a)
|
|
@@ -3372,12 +3360,12 @@ var DataSpace = class {
|
|
|
3372
3360
|
await this._notarizationPlugin.open();
|
|
3373
3361
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3374
3362
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3375
|
-
await this._inner.open(new
|
|
3376
|
-
this._state =
|
|
3363
|
+
await this._inner.open(new import_context6.Context());
|
|
3364
|
+
this._state = import_services7.SpaceState.CONTROL_ONLY;
|
|
3377
3365
|
(0, import_log8.log)("new state", {
|
|
3378
|
-
state:
|
|
3366
|
+
state: import_services7.SpaceState[this._state]
|
|
3379
3367
|
}, {
|
|
3380
|
-
F:
|
|
3368
|
+
F: __dxlog_file11,
|
|
3381
3369
|
L: 198,
|
|
3382
3370
|
S: this,
|
|
3383
3371
|
C: (f, a) => f(...a)
|
|
@@ -3391,17 +3379,17 @@ var DataSpace = class {
|
|
|
3391
3379
|
}
|
|
3392
3380
|
async _close() {
|
|
3393
3381
|
await this._callbacks.beforeClose?.();
|
|
3394
|
-
this._state =
|
|
3382
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
3395
3383
|
(0, import_log8.log)("new state", {
|
|
3396
|
-
state:
|
|
3384
|
+
state: import_services7.SpaceState[this._state]
|
|
3397
3385
|
}, {
|
|
3398
|
-
F:
|
|
3386
|
+
F: __dxlog_file11,
|
|
3399
3387
|
L: 212,
|
|
3400
3388
|
S: this,
|
|
3401
3389
|
C: (f, a) => f(...a)
|
|
3402
3390
|
});
|
|
3403
3391
|
await this._ctx.dispose();
|
|
3404
|
-
this._ctx = new
|
|
3392
|
+
this._ctx = new import_context6.Context();
|
|
3405
3393
|
await this.authVerifier.close();
|
|
3406
3394
|
await this._inner.close();
|
|
3407
3395
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
@@ -3425,9 +3413,9 @@ var DataSpace = class {
|
|
|
3425
3413
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3426
3414
|
await this.initializeDataPipeline();
|
|
3427
3415
|
} catch (err) {
|
|
3428
|
-
if (err instanceof
|
|
3416
|
+
if (err instanceof import_protocols7.CancelledError || err instanceof import_context6.ContextDisposedError) {
|
|
3429
3417
|
(0, import_log8.log)("data pipeline initialization cancelled", err, {
|
|
3430
|
-
F:
|
|
3418
|
+
F: __dxlog_file11,
|
|
3431
3419
|
L: 245,
|
|
3432
3420
|
S: this,
|
|
3433
3421
|
C: (f, a) => f(...a)
|
|
@@ -3435,16 +3423,16 @@ var DataSpace = class {
|
|
|
3435
3423
|
return;
|
|
3436
3424
|
}
|
|
3437
3425
|
import_log8.log.error("Error initializing data pipeline", err, {
|
|
3438
|
-
F:
|
|
3426
|
+
F: __dxlog_file11,
|
|
3439
3427
|
L: 249,
|
|
3440
3428
|
S: this,
|
|
3441
3429
|
C: (f, a) => f(...a)
|
|
3442
3430
|
});
|
|
3443
|
-
this._state =
|
|
3431
|
+
this._state = import_services7.SpaceState.ERROR;
|
|
3444
3432
|
(0, import_log8.log)("new state", {
|
|
3445
|
-
state:
|
|
3433
|
+
state: import_services7.SpaceState[this._state]
|
|
3446
3434
|
}, {
|
|
3447
|
-
F:
|
|
3435
|
+
F: __dxlog_file11,
|
|
3448
3436
|
L: 251,
|
|
3449
3437
|
S: this,
|
|
3450
3438
|
C: (f, a) => f(...a)
|
|
@@ -3457,14 +3445,14 @@ var DataSpace = class {
|
|
|
3457
3445
|
});
|
|
3458
3446
|
}
|
|
3459
3447
|
async initializeDataPipeline() {
|
|
3460
|
-
if (this._state !==
|
|
3461
|
-
throw new
|
|
3448
|
+
if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
|
|
3449
|
+
throw new import_protocols7.SystemError("Invalid operation");
|
|
3462
3450
|
}
|
|
3463
|
-
this._state =
|
|
3451
|
+
this._state = import_services7.SpaceState.INITIALIZING;
|
|
3464
3452
|
(0, import_log8.log)("new state", {
|
|
3465
|
-
state:
|
|
3453
|
+
state: import_services7.SpaceState[this._state]
|
|
3466
3454
|
}, {
|
|
3467
|
-
F:
|
|
3455
|
+
F: __dxlog_file11,
|
|
3468
3456
|
L: 267,
|
|
3469
3457
|
S: this,
|
|
3470
3458
|
C: (f, a) => f(...a)
|
|
@@ -3472,19 +3460,19 @@ var DataSpace = class {
|
|
|
3472
3460
|
await this._initializeAndReadControlPipeline();
|
|
3473
3461
|
await (0, import_async10.sleep)(1);
|
|
3474
3462
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
3475
|
-
await (0,
|
|
3463
|
+
await (0, import_context6.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
3476
3464
|
(0, import_log8.log)("data pipeline ready", void 0, {
|
|
3477
|
-
F:
|
|
3465
|
+
F: __dxlog_file11,
|
|
3478
3466
|
L: 279,
|
|
3479
3467
|
S: this,
|
|
3480
3468
|
C: (f, a) => f(...a)
|
|
3481
3469
|
});
|
|
3482
3470
|
await this._callbacks.beforeReady?.();
|
|
3483
|
-
this._state =
|
|
3471
|
+
this._state = import_services7.SpaceState.READY;
|
|
3484
3472
|
(0, import_log8.log)("new state", {
|
|
3485
|
-
state:
|
|
3473
|
+
state: import_services7.SpaceState[this._state]
|
|
3486
3474
|
}, {
|
|
3487
|
-
F:
|
|
3475
|
+
F: __dxlog_file11,
|
|
3488
3476
|
L: 283,
|
|
3489
3477
|
S: this,
|
|
3490
3478
|
C: (f, a) => f(...a)
|
|
@@ -3500,14 +3488,14 @@ var DataSpace = class {
|
|
|
3500
3488
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
3501
3489
|
await this._createWritableFeeds();
|
|
3502
3490
|
(0, import_log8.log)("writable feeds created", void 0, {
|
|
3503
|
-
F:
|
|
3491
|
+
F: __dxlog_file11,
|
|
3504
3492
|
L: 299,
|
|
3505
3493
|
S: this,
|
|
3506
3494
|
C: (f, a) => f(...a)
|
|
3507
3495
|
});
|
|
3508
3496
|
this.stateUpdate.emit();
|
|
3509
3497
|
if (!this.notarizationPlugin.hasWriter) {
|
|
3510
|
-
this.notarizationPlugin.setWriter((0,
|
|
3498
|
+
this.notarizationPlugin.setWriter((0, import_echo_pipeline2.createMappedFeedWriter)((credential) => ({
|
|
3511
3499
|
credential: {
|
|
3512
3500
|
credential
|
|
3513
3501
|
}
|
|
@@ -3528,7 +3516,7 @@ var DataSpace = class {
|
|
|
3528
3516
|
spaceKey: this.key,
|
|
3529
3517
|
deviceKey: this._signingContext.deviceKey,
|
|
3530
3518
|
identityKey: this._signingContext.identityKey,
|
|
3531
|
-
designation:
|
|
3519
|
+
designation: import_credentials9.AdmittedFeed.Designation.CONTROL
|
|
3532
3520
|
}
|
|
3533
3521
|
}));
|
|
3534
3522
|
}
|
|
@@ -3545,7 +3533,7 @@ var DataSpace = class {
|
|
|
3545
3533
|
spaceKey: this.key,
|
|
3546
3534
|
deviceKey: this._signingContext.deviceKey,
|
|
3547
3535
|
identityKey: this._signingContext.identityKey,
|
|
3548
|
-
designation:
|
|
3536
|
+
designation: import_credentials9.AdmittedFeed.Designation.DATA
|
|
3549
3537
|
}
|
|
3550
3538
|
}));
|
|
3551
3539
|
}
|
|
@@ -3563,7 +3551,7 @@ var DataSpace = class {
|
|
|
3563
3551
|
space: this.key,
|
|
3564
3552
|
rootUrl
|
|
3565
3553
|
}, {
|
|
3566
|
-
F:
|
|
3554
|
+
F: __dxlog_file11,
|
|
3567
3555
|
L: 365,
|
|
3568
3556
|
S: this,
|
|
3569
3557
|
C: (f, a) => f(...a)
|
|
@@ -3573,12 +3561,12 @@ var DataSpace = class {
|
|
|
3573
3561
|
queueMicrotask(async () => {
|
|
3574
3562
|
try {
|
|
3575
3563
|
await (0, import_debug3.warnAfterTimeout)(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
3576
|
-
await (0,
|
|
3564
|
+
await (0, import_context6.cancelWithContext)(this._ctx, handle.whenReady());
|
|
3577
3565
|
});
|
|
3578
3566
|
if (this._ctx.disposed) {
|
|
3579
3567
|
return;
|
|
3580
3568
|
}
|
|
3581
|
-
const doc = handle.docSync() ?? (0,
|
|
3569
|
+
const doc = handle.docSync() ?? (0, import_invariant9.failedInvariant)();
|
|
3582
3570
|
if (!doc.access?.spaceKey) {
|
|
3583
3571
|
handle.change((doc2) => {
|
|
3584
3572
|
doc2.access = {
|
|
@@ -3587,7 +3575,7 @@ var DataSpace = class {
|
|
|
3587
3575
|
});
|
|
3588
3576
|
}
|
|
3589
3577
|
} catch (err) {
|
|
3590
|
-
if (err instanceof
|
|
3578
|
+
if (err instanceof import_context6.ContextDisposedError) {
|
|
3591
3579
|
return;
|
|
3592
3580
|
}
|
|
3593
3581
|
import_log8.log.warn("error loading automerge root doc", {
|
|
@@ -3595,7 +3583,7 @@ var DataSpace = class {
|
|
|
3595
3583
|
rootUrl,
|
|
3596
3584
|
err
|
|
3597
3585
|
}, {
|
|
3598
|
-
F:
|
|
3586
|
+
F: __dxlog_file11,
|
|
3599
3587
|
L: 388,
|
|
3600
3588
|
S: this,
|
|
3601
3589
|
C: (f, a) => f(...a)
|
|
@@ -3622,7 +3610,7 @@ var DataSpace = class {
|
|
|
3622
3610
|
let epoch;
|
|
3623
3611
|
switch (options?.migration) {
|
|
3624
3612
|
case void 0:
|
|
3625
|
-
case
|
|
3613
|
+
case import_services7.CreateEpochRequest.Migration.NONE:
|
|
3626
3614
|
{
|
|
3627
3615
|
epoch = {
|
|
3628
3616
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
@@ -3632,7 +3620,7 @@ var DataSpace = class {
|
|
|
3632
3620
|
};
|
|
3633
3621
|
}
|
|
3634
3622
|
break;
|
|
3635
|
-
case
|
|
3623
|
+
case import_services7.CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3636
3624
|
{
|
|
3637
3625
|
const document = this._automergeHost.repo.create();
|
|
3638
3626
|
epoch = {
|
|
@@ -3643,14 +3631,14 @@ var DataSpace = class {
|
|
|
3643
3631
|
};
|
|
3644
3632
|
}
|
|
3645
3633
|
break;
|
|
3646
|
-
case
|
|
3634
|
+
case import_services7.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
3647
3635
|
{
|
|
3648
3636
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3649
3637
|
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3650
|
-
await (0,
|
|
3638
|
+
await (0, import_context6.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3651
3639
|
const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
|
|
3652
|
-
(0,
|
|
3653
|
-
F:
|
|
3640
|
+
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3641
|
+
F: __dxlog_file11,
|
|
3654
3642
|
L: 438,
|
|
3655
3643
|
S: this,
|
|
3656
3644
|
A: [
|
|
@@ -3666,22 +3654,22 @@ var DataSpace = class {
|
|
|
3666
3654
|
};
|
|
3667
3655
|
}
|
|
3668
3656
|
break;
|
|
3669
|
-
case
|
|
3657
|
+
case import_services7.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
3670
3658
|
{
|
|
3671
3659
|
import_log8.log.info("Fragmenting", void 0, {
|
|
3672
|
-
F:
|
|
3660
|
+
F: __dxlog_file11,
|
|
3673
3661
|
L: 450,
|
|
3674
3662
|
S: this,
|
|
3675
3663
|
C: (f, a) => f(...a)
|
|
3676
3664
|
});
|
|
3677
3665
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3678
3666
|
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3679
|
-
await (0,
|
|
3667
|
+
await (0, import_context6.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3680
3668
|
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3681
3669
|
const properties = objects.find(([_, value]) => value.system.type?.itemId === import_echo_db.TYPE_PROPERTIES);
|
|
3682
3670
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3683
|
-
(0,
|
|
3684
|
-
F:
|
|
3671
|
+
(0, import_invariant9.invariant)(properties, "Properties not found", {
|
|
3672
|
+
F: __dxlog_file11,
|
|
3685
3673
|
L: 460,
|
|
3686
3674
|
S: this,
|
|
3687
3675
|
A: [
|
|
@@ -3696,8 +3684,8 @@ var DataSpace = class {
|
|
|
3696
3684
|
])
|
|
3697
3685
|
};
|
|
3698
3686
|
const newRoot = this._automergeHost.repo.create(newSpaceDoc);
|
|
3699
|
-
(0,
|
|
3700
|
-
F:
|
|
3687
|
+
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3688
|
+
F: __dxlog_file11,
|
|
3701
3689
|
L: 465,
|
|
3702
3690
|
S: this,
|
|
3703
3691
|
A: [
|
|
@@ -3705,7 +3693,7 @@ var DataSpace = class {
|
|
|
3705
3693
|
""
|
|
3706
3694
|
]
|
|
3707
3695
|
});
|
|
3708
|
-
const docLoader = new
|
|
3696
|
+
const docLoader = new import_echo_pipeline3.AutomergeDocumentLoaderImpl(this.key, this._automergeHost.repo);
|
|
3709
3697
|
await docLoader.loadSpaceRootDocHandle(this._ctx, {
|
|
3710
3698
|
rootUrl: newRoot.url
|
|
3711
3699
|
});
|
|
@@ -3749,24 +3737,24 @@ var DataSpace = class {
|
|
|
3749
3737
|
]));
|
|
3750
3738
|
}
|
|
3751
3739
|
async activate() {
|
|
3752
|
-
if (this._state !==
|
|
3740
|
+
if (this._state !== import_services7.SpaceState.INACTIVE) {
|
|
3753
3741
|
return;
|
|
3754
3742
|
}
|
|
3755
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3743
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.ACTIVE);
|
|
3756
3744
|
await this._open();
|
|
3757
3745
|
this.initializeDataPipelineAsync();
|
|
3758
3746
|
}
|
|
3759
3747
|
async deactivate() {
|
|
3760
|
-
if (this._state ===
|
|
3748
|
+
if (this._state === import_services7.SpaceState.INACTIVE) {
|
|
3761
3749
|
return;
|
|
3762
3750
|
}
|
|
3763
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3751
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.INACTIVE);
|
|
3764
3752
|
await this._close();
|
|
3765
|
-
this._state =
|
|
3753
|
+
this._state = import_services7.SpaceState.INACTIVE;
|
|
3766
3754
|
(0, import_log8.log)("new state", {
|
|
3767
|
-
state:
|
|
3755
|
+
state: import_services7.SpaceState[this._state]
|
|
3768
3756
|
}, {
|
|
3769
|
-
F:
|
|
3757
|
+
F: __dxlog_file11,
|
|
3770
3758
|
L: 531,
|
|
3771
3759
|
S: this,
|
|
3772
3760
|
C: (f, a) => f(...a)
|
|
@@ -3775,18 +3763,18 @@ var DataSpace = class {
|
|
|
3775
3763
|
}
|
|
3776
3764
|
};
|
|
3777
3765
|
_ts_decorate4([
|
|
3778
|
-
|
|
3766
|
+
import_tracing4.trace.info()
|
|
3779
3767
|
], DataSpace.prototype, "_inner", void 0);
|
|
3780
3768
|
_ts_decorate4([
|
|
3781
|
-
|
|
3769
|
+
import_tracing4.trace.info()
|
|
3782
3770
|
], DataSpace.prototype, "key", null);
|
|
3783
3771
|
_ts_decorate4([
|
|
3784
|
-
|
|
3785
|
-
enum:
|
|
3772
|
+
import_tracing4.trace.info({
|
|
3773
|
+
enum: import_services7.SpaceState
|
|
3786
3774
|
})
|
|
3787
3775
|
], DataSpace.prototype, "state", null);
|
|
3788
3776
|
_ts_decorate4([
|
|
3789
|
-
|
|
3777
|
+
import_tracing4.trace.info({
|
|
3790
3778
|
depth: null
|
|
3791
3779
|
})
|
|
3792
3780
|
], DataSpace.prototype, "_automergeInfo", null);
|
|
@@ -3797,12 +3785,12 @@ _ts_decorate4([
|
|
|
3797
3785
|
import_async10.synchronized
|
|
3798
3786
|
], DataSpace.prototype, "close", null);
|
|
3799
3787
|
_ts_decorate4([
|
|
3800
|
-
|
|
3788
|
+
import_tracing4.trace.span({
|
|
3801
3789
|
showInBrowserTimeline: true
|
|
3802
3790
|
})
|
|
3803
3791
|
], DataSpace.prototype, "initializeDataPipeline", null);
|
|
3804
3792
|
_ts_decorate4([
|
|
3805
|
-
|
|
3793
|
+
import_tracing4.trace.span({
|
|
3806
3794
|
showInBrowserTimeline: true
|
|
3807
3795
|
})
|
|
3808
3796
|
], DataSpace.prototype, "_initializeAndReadControlPipeline", null);
|
|
@@ -3817,11 +3805,11 @@ _ts_decorate4([
|
|
|
3817
3805
|
], DataSpace.prototype, "deactivate", null);
|
|
3818
3806
|
DataSpace = _ts_decorate4([
|
|
3819
3807
|
(0, import_async10.trackLeaks)("open", "close"),
|
|
3820
|
-
|
|
3808
|
+
import_tracing4.trace.resource()
|
|
3821
3809
|
], DataSpace);
|
|
3822
3810
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
3823
3811
|
const credentials = [
|
|
3824
|
-
await (0,
|
|
3812
|
+
await (0, import_credentials12.createCredential)({
|
|
3825
3813
|
signer: keyring,
|
|
3826
3814
|
issuer: space.key,
|
|
3827
3815
|
subject: space.key,
|
|
@@ -3830,14 +3818,14 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3830
3818
|
spaceKey: space.key
|
|
3831
3819
|
}
|
|
3832
3820
|
}),
|
|
3833
|
-
await (0,
|
|
3821
|
+
await (0, import_credentials12.createCredential)({
|
|
3834
3822
|
signer: keyring,
|
|
3835
3823
|
issuer: space.key,
|
|
3836
3824
|
subject: signingContext.identityKey,
|
|
3837
3825
|
assertion: {
|
|
3838
3826
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
3839
3827
|
spaceKey: space.key,
|
|
3840
|
-
role:
|
|
3828
|
+
role: import_credentials13.SpaceMember.Role.ADMIN,
|
|
3841
3829
|
profile: signingContext.getProfile(),
|
|
3842
3830
|
genesisFeedKey: space.controlFeedKey ?? (0, import_debug4.failUndefined)()
|
|
3843
3831
|
}
|
|
@@ -3849,7 +3837,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3849
3837
|
spaceKey: space.key,
|
|
3850
3838
|
identityKey: signingContext.identityKey,
|
|
3851
3839
|
deviceKey: signingContext.deviceKey,
|
|
3852
|
-
designation:
|
|
3840
|
+
designation: import_credentials13.AdmittedFeed.Designation.CONTROL
|
|
3853
3841
|
}
|
|
3854
3842
|
}),
|
|
3855
3843
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3859,7 +3847,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3859
3847
|
spaceKey: space.key,
|
|
3860
3848
|
identityKey: signingContext.identityKey,
|
|
3861
3849
|
deviceKey: signingContext.deviceKey,
|
|
3862
|
-
designation:
|
|
3850
|
+
designation: import_credentials13.AdmittedFeed.Designation.DATA
|
|
3863
3851
|
}
|
|
3864
3852
|
}),
|
|
3865
3853
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3893,7 +3881,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
3893
3881
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3894
3882
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3895
3883
|
}
|
|
3896
|
-
var
|
|
3884
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
3897
3885
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3898
3886
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3899
3887
|
var DataSpaceManager = class {
|
|
@@ -3904,7 +3892,7 @@ var DataSpaceManager = class {
|
|
|
3904
3892
|
this._signingContext = _signingContext;
|
|
3905
3893
|
this._feedStore = _feedStore;
|
|
3906
3894
|
this._automergeHost = _automergeHost;
|
|
3907
|
-
this._ctx = new
|
|
3895
|
+
this._ctx = new import_context8.Context();
|
|
3908
3896
|
this.updated = new import_async13.Event();
|
|
3909
3897
|
this._spaces = new import_util6.ComplexMap(import_keys9.PublicKey.hash);
|
|
3910
3898
|
this._isOpen = false;
|
|
@@ -3919,15 +3907,15 @@ var DataSpaceManager = class {
|
|
|
3919
3907
|
}
|
|
3920
3908
|
async open() {
|
|
3921
3909
|
(0, import_log10.log)("open", void 0, {
|
|
3922
|
-
F:
|
|
3910
|
+
F: __dxlog_file12,
|
|
3923
3911
|
L: 98,
|
|
3924
3912
|
S: this,
|
|
3925
3913
|
C: (f, a) => f(...a)
|
|
3926
3914
|
});
|
|
3927
|
-
import_log10.log.trace("dxos.echo.data-space-manager.open",
|
|
3915
|
+
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols9.trace.begin({
|
|
3928
3916
|
id: this._instanceId
|
|
3929
3917
|
}), {
|
|
3930
|
-
F:
|
|
3918
|
+
F: __dxlog_file12,
|
|
3931
3919
|
L: 99,
|
|
3932
3920
|
S: this,
|
|
3933
3921
|
C: (f, a) => f(...a)
|
|
@@ -3935,7 +3923,7 @@ var DataSpaceManager = class {
|
|
|
3935
3923
|
(0, import_log10.log)("metadata loaded", {
|
|
3936
3924
|
spaces: this._metadataStore.spaces.length
|
|
3937
3925
|
}, {
|
|
3938
|
-
F:
|
|
3926
|
+
F: __dxlog_file12,
|
|
3939
3927
|
L: 100,
|
|
3940
3928
|
S: this,
|
|
3941
3929
|
C: (f, a) => f(...a)
|
|
@@ -3945,7 +3933,7 @@ var DataSpaceManager = class {
|
|
|
3945
3933
|
(0, import_log10.log)("load space", {
|
|
3946
3934
|
spaceMetadata
|
|
3947
3935
|
}, {
|
|
3948
|
-
F:
|
|
3936
|
+
F: __dxlog_file12,
|
|
3949
3937
|
L: 104,
|
|
3950
3938
|
S: this,
|
|
3951
3939
|
C: (f, a) => f(...a)
|
|
@@ -3956,7 +3944,7 @@ var DataSpaceManager = class {
|
|
|
3956
3944
|
spaceMetadata,
|
|
3957
3945
|
err
|
|
3958
3946
|
}, {
|
|
3959
|
-
F:
|
|
3947
|
+
F: __dxlog_file12,
|
|
3960
3948
|
L: 107,
|
|
3961
3949
|
S: this,
|
|
3962
3950
|
C: (f, a) => f(...a)
|
|
@@ -3966,14 +3954,14 @@ var DataSpaceManager = class {
|
|
|
3966
3954
|
this._isOpen = true;
|
|
3967
3955
|
this.updated.emit();
|
|
3968
3956
|
for (const space of this._spaces.values()) {
|
|
3969
|
-
if (space.state !==
|
|
3957
|
+
if (space.state !== import_services8.SpaceState.INACTIVE) {
|
|
3970
3958
|
space.initializeDataPipelineAsync();
|
|
3971
3959
|
}
|
|
3972
3960
|
}
|
|
3973
|
-
import_log10.log.trace("dxos.echo.data-space-manager.open",
|
|
3961
|
+
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols9.trace.end({
|
|
3974
3962
|
id: this._instanceId
|
|
3975
3963
|
}), {
|
|
3976
|
-
F:
|
|
3964
|
+
F: __dxlog_file12,
|
|
3977
3965
|
L: 120,
|
|
3978
3966
|
S: this,
|
|
3979
3967
|
C: (f, a) => f(...a)
|
|
@@ -3981,7 +3969,7 @@ var DataSpaceManager = class {
|
|
|
3981
3969
|
}
|
|
3982
3970
|
async close() {
|
|
3983
3971
|
(0, import_log10.log)("close", void 0, {
|
|
3984
|
-
F:
|
|
3972
|
+
F: __dxlog_file12,
|
|
3985
3973
|
L: 125,
|
|
3986
3974
|
S: this,
|
|
3987
3975
|
C: (f, a) => f(...a)
|
|
@@ -3996,8 +3984,8 @@ var DataSpaceManager = class {
|
|
|
3996
3984
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
3997
3985
|
*/
|
|
3998
3986
|
async createSpace() {
|
|
3999
|
-
(0,
|
|
4000
|
-
F:
|
|
3987
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3988
|
+
F: __dxlog_file12,
|
|
4001
3989
|
L: 138,
|
|
4002
3990
|
S: this,
|
|
4003
3991
|
A: [
|
|
@@ -4013,12 +4001,12 @@ var DataSpaceManager = class {
|
|
|
4013
4001
|
genesisFeedKey: controlFeedKey,
|
|
4014
4002
|
controlFeedKey,
|
|
4015
4003
|
dataFeedKey,
|
|
4016
|
-
state:
|
|
4004
|
+
state: import_services8.SpaceState.ACTIVE
|
|
4017
4005
|
};
|
|
4018
4006
|
(0, import_log10.log)("creating space...", {
|
|
4019
4007
|
spaceKey
|
|
4020
4008
|
}, {
|
|
4021
|
-
F:
|
|
4009
|
+
F: __dxlog_file12,
|
|
4022
4010
|
L: 150,
|
|
4023
4011
|
S: this,
|
|
4024
4012
|
C: (f, a) => f(...a)
|
|
@@ -4033,8 +4021,8 @@ var DataSpaceManager = class {
|
|
|
4033
4021
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
|
|
4034
4022
|
await this._metadataStore.addSpace(metadata);
|
|
4035
4023
|
const memberCredential = credentials[1];
|
|
4036
|
-
(0,
|
|
4037
|
-
F:
|
|
4024
|
+
(0, import_invariant11.invariant)((0, import_credentials11.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4025
|
+
F: __dxlog_file12,
|
|
4038
4026
|
L: 163,
|
|
4039
4027
|
S: this,
|
|
4040
4028
|
A: [
|
|
@@ -4052,13 +4040,13 @@ var DataSpaceManager = class {
|
|
|
4052
4040
|
(0, import_log10.log)("accept space", {
|
|
4053
4041
|
opts
|
|
4054
4042
|
}, {
|
|
4055
|
-
F:
|
|
4043
|
+
F: __dxlog_file12,
|
|
4056
4044
|
L: 175,
|
|
4057
4045
|
S: this,
|
|
4058
4046
|
C: (f, a) => f(...a)
|
|
4059
4047
|
});
|
|
4060
|
-
(0,
|
|
4061
|
-
F:
|
|
4048
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
4049
|
+
F: __dxlog_file12,
|
|
4062
4050
|
L: 176,
|
|
4063
4051
|
S: this,
|
|
4064
4052
|
A: [
|
|
@@ -4066,8 +4054,8 @@ var DataSpaceManager = class {
|
|
|
4066
4054
|
"'Not open.'"
|
|
4067
4055
|
]
|
|
4068
4056
|
});
|
|
4069
|
-
(0,
|
|
4070
|
-
F:
|
|
4057
|
+
(0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
4058
|
+
F: __dxlog_file12,
|
|
4071
4059
|
L: 177,
|
|
4072
4060
|
S: this,
|
|
4073
4061
|
A: [
|
|
@@ -4093,16 +4081,16 @@ var DataSpaceManager = class {
|
|
|
4093
4081
|
* TODO(dmaretskyi): Consider removing.
|
|
4094
4082
|
*/
|
|
4095
4083
|
async waitUntilSpaceReady(spaceKey) {
|
|
4096
|
-
await (0,
|
|
4084
|
+
await (0, import_context8.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
4097
4085
|
const space = this._spaces.get(spaceKey);
|
|
4098
|
-
return !!space && space.state ===
|
|
4086
|
+
return !!space && space.state === import_services8.SpaceState.READY;
|
|
4099
4087
|
}));
|
|
4100
4088
|
}
|
|
4101
4089
|
async _constructSpace(metadata) {
|
|
4102
4090
|
(0, import_log10.log)("construct space", {
|
|
4103
4091
|
metadata
|
|
4104
4092
|
}, {
|
|
4105
|
-
F:
|
|
4093
|
+
F: __dxlog_file12,
|
|
4106
4094
|
L: 210,
|
|
4107
4095
|
S: this,
|
|
4108
4096
|
C: (f, a) => f(...a)
|
|
@@ -4140,7 +4128,7 @@ var DataSpaceManager = class {
|
|
|
4140
4128
|
},
|
|
4141
4129
|
onAuthFailure: () => {
|
|
4142
4130
|
import_log10.log.warn("auth failure", void 0, {
|
|
4143
|
-
F:
|
|
4131
|
+
F: __dxlog_file12,
|
|
4144
4132
|
L: 247,
|
|
4145
4133
|
S: this,
|
|
4146
4134
|
C: (f, a) => f(...a)
|
|
@@ -4152,7 +4140,7 @@ var DataSpaceManager = class {
|
|
|
4152
4140
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
4153
4141
|
const dataSpace = new DataSpace({
|
|
4154
4142
|
inner: space,
|
|
4155
|
-
initialState: metadata.state ===
|
|
4143
|
+
initialState: metadata.state === import_services8.SpaceState.INACTIVE ? import_services8.SpaceState.INACTIVE : import_services8.SpaceState.CLOSED,
|
|
4156
4144
|
metadataStore: this._metadataStore,
|
|
4157
4145
|
gossip,
|
|
4158
4146
|
presence,
|
|
@@ -4164,7 +4152,7 @@ var DataSpaceManager = class {
|
|
|
4164
4152
|
(0, import_log10.log)("before space ready", {
|
|
4165
4153
|
space: space.key
|
|
4166
4154
|
}, {
|
|
4167
|
-
F:
|
|
4155
|
+
F: __dxlog_file12,
|
|
4168
4156
|
L: 265,
|
|
4169
4157
|
S: this,
|
|
4170
4158
|
C: (f, a) => f(...a)
|
|
@@ -4175,7 +4163,7 @@ var DataSpaceManager = class {
|
|
|
4175
4163
|
space: space.key,
|
|
4176
4164
|
open: this._isOpen
|
|
4177
4165
|
}, {
|
|
4178
|
-
F:
|
|
4166
|
+
F: __dxlog_file12,
|
|
4179
4167
|
L: 268,
|
|
4180
4168
|
S: this,
|
|
4181
4169
|
C: (f, a) => f(...a)
|
|
@@ -4188,7 +4176,7 @@ var DataSpaceManager = class {
|
|
|
4188
4176
|
(0, import_log10.log)("before space close", {
|
|
4189
4177
|
space: space.key
|
|
4190
4178
|
}, {
|
|
4191
|
-
F:
|
|
4179
|
+
F: __dxlog_file12,
|
|
4192
4180
|
L: 274,
|
|
4193
4181
|
S: this,
|
|
4194
4182
|
C: (f, a) => f(...a)
|
|
@@ -4198,7 +4186,7 @@ var DataSpaceManager = class {
|
|
|
4198
4186
|
cache: metadata.cache,
|
|
4199
4187
|
automergeHost: this._automergeHost
|
|
4200
4188
|
});
|
|
4201
|
-
if (metadata.state !==
|
|
4189
|
+
if (metadata.state !== import_services8.SpaceState.INACTIVE) {
|
|
4202
4190
|
await dataSpace.open();
|
|
4203
4191
|
}
|
|
4204
4192
|
if (metadata.controlTimeframe) {
|
|
@@ -4223,7 +4211,7 @@ _ts_decorate5([
|
|
|
4223
4211
|
DataSpaceManager = _ts_decorate5([
|
|
4224
4212
|
(0, import_async13.trackLeaks)("open", "close")
|
|
4225
4213
|
], DataSpaceManager);
|
|
4226
|
-
var
|
|
4214
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
4227
4215
|
var SpacesServiceImpl = class {
|
|
4228
4216
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
4229
4217
|
this._identityManager = _identityManager;
|
|
@@ -4240,29 +4228,29 @@ var SpacesServiceImpl = class {
|
|
|
4240
4228
|
}
|
|
4241
4229
|
async updateSpace({ spaceKey, state }) {
|
|
4242
4230
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4243
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4231
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4244
4232
|
if (state) {
|
|
4245
4233
|
switch (state) {
|
|
4246
|
-
case
|
|
4234
|
+
case import_services9.SpaceState.ACTIVE:
|
|
4247
4235
|
await space.activate();
|
|
4248
4236
|
break;
|
|
4249
|
-
case
|
|
4237
|
+
case import_services9.SpaceState.INACTIVE:
|
|
4250
4238
|
await space.deactivate();
|
|
4251
4239
|
break;
|
|
4252
4240
|
default:
|
|
4253
|
-
throw new
|
|
4241
|
+
throw new import_protocols10.ApiError("Invalid space state");
|
|
4254
4242
|
}
|
|
4255
4243
|
}
|
|
4256
4244
|
}
|
|
4257
4245
|
querySpaces() {
|
|
4258
|
-
return new
|
|
4246
|
+
return new import_codec_protobuf10.Stream(({ next, ctx }) => {
|
|
4259
4247
|
const scheduler = new import_async14.UpdateScheduler(ctx, async () => {
|
|
4260
4248
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4261
4249
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
4262
4250
|
(0, import_log11.log)("update", {
|
|
4263
4251
|
spaces
|
|
4264
4252
|
}, {
|
|
4265
|
-
F:
|
|
4253
|
+
F: __dxlog_file13,
|
|
4266
4254
|
L: 77,
|
|
4267
4255
|
S: this,
|
|
4268
4256
|
C: (f, a) => f(...a)
|
|
@@ -4302,14 +4290,14 @@ var SpacesServiceImpl = class {
|
|
|
4302
4290
|
}
|
|
4303
4291
|
async postMessage({ spaceKey, channel, message }) {
|
|
4304
4292
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4305
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4293
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4306
4294
|
await space.postMessage(getChannelId(channel), message);
|
|
4307
4295
|
}
|
|
4308
4296
|
subscribeMessages({ spaceKey, channel }) {
|
|
4309
|
-
return new
|
|
4297
|
+
return new import_codec_protobuf10.Stream(({ ctx, next }) => {
|
|
4310
4298
|
(0, import_async14.scheduleTask)(ctx, async () => {
|
|
4311
4299
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4312
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4300
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4313
4301
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
4314
4302
|
next(message);
|
|
4315
4303
|
});
|
|
@@ -4318,8 +4306,8 @@ var SpacesServiceImpl = class {
|
|
|
4318
4306
|
});
|
|
4319
4307
|
}
|
|
4320
4308
|
queryCredentials({ spaceKey, noTail }) {
|
|
4321
|
-
return new
|
|
4322
|
-
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4309
|
+
return new import_codec_protobuf10.Stream(({ ctx, next, close }) => {
|
|
4310
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4323
4311
|
const processor = {
|
|
4324
4312
|
processCredential: async (credential) => {
|
|
4325
4313
|
next(credential);
|
|
@@ -4335,7 +4323,7 @@ var SpacesServiceImpl = class {
|
|
|
4335
4323
|
});
|
|
4336
4324
|
}
|
|
4337
4325
|
async writeCredentials({ spaceKey, credentials }) {
|
|
4338
|
-
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4326
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4339
4327
|
for (const credential of credentials ?? []) {
|
|
4340
4328
|
if (credential.proof) {
|
|
4341
4329
|
await space.controlPipeline.writer.write({
|
|
@@ -4344,8 +4332,8 @@ var SpacesServiceImpl = class {
|
|
|
4344
4332
|
}
|
|
4345
4333
|
});
|
|
4346
4334
|
} else {
|
|
4347
|
-
(0,
|
|
4348
|
-
F:
|
|
4335
|
+
(0, import_invariant12.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
4336
|
+
F: __dxlog_file13,
|
|
4349
4337
|
L: 164,
|
|
4350
4338
|
S: this,
|
|
4351
4339
|
A: [
|
|
@@ -4353,8 +4341,8 @@ var SpacesServiceImpl = class {
|
|
|
4353
4341
|
"'Id on unsigned credentials is not allowed'"
|
|
4354
4342
|
]
|
|
4355
4343
|
});
|
|
4356
|
-
(0,
|
|
4357
|
-
F:
|
|
4344
|
+
(0, import_invariant12.invariant)(this._identityManager.identity, "Identity is not available", {
|
|
4345
|
+
F: __dxlog_file13,
|
|
4358
4346
|
L: 165,
|
|
4359
4347
|
S: this,
|
|
4360
4348
|
A: [
|
|
@@ -4363,8 +4351,8 @@ var SpacesServiceImpl = class {
|
|
|
4363
4351
|
]
|
|
4364
4352
|
});
|
|
4365
4353
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
4366
|
-
(0,
|
|
4367
|
-
F:
|
|
4354
|
+
(0, import_invariant12.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
4355
|
+
F: __dxlog_file13,
|
|
4368
4356
|
L: 167,
|
|
4369
4357
|
S: this,
|
|
4370
4358
|
A: [
|
|
@@ -4386,7 +4374,7 @@ var SpacesServiceImpl = class {
|
|
|
4386
4374
|
}
|
|
4387
4375
|
async createEpoch({ spaceKey, migration }) {
|
|
4388
4376
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4389
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4377
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4390
4378
|
await space.createEpoch({
|
|
4391
4379
|
migration
|
|
4392
4380
|
});
|
|
@@ -4395,7 +4383,7 @@ var SpacesServiceImpl = class {
|
|
|
4395
4383
|
return {
|
|
4396
4384
|
spaceKey: space.key,
|
|
4397
4385
|
state: space.state,
|
|
4398
|
-
error: space.error ? (0,
|
|
4386
|
+
error: space.error ? (0, import_protocols10.encodeError)(space.error) : void 0,
|
|
4399
4387
|
pipeline: {
|
|
4400
4388
|
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
4401
4389
|
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
@@ -4420,7 +4408,7 @@ var SpacesServiceImpl = class {
|
|
|
4420
4408
|
identityKey: member.key,
|
|
4421
4409
|
profile: member.profile ?? {}
|
|
4422
4410
|
},
|
|
4423
|
-
presence: member.removed ?
|
|
4411
|
+
presence: member.removed ? import_services9.SpaceMember.PresenceState.REMOVED : isMe || peers.length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE,
|
|
4424
4412
|
peerStates: peers
|
|
4425
4413
|
};
|
|
4426
4414
|
}),
|
|
@@ -4431,7 +4419,7 @@ var SpacesServiceImpl = class {
|
|
|
4431
4419
|
}
|
|
4432
4420
|
};
|
|
4433
4421
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
4434
|
-
var
|
|
4422
|
+
var createSelectedDocumentsIterator = (automergeHost) => (
|
|
4435
4423
|
/**
|
|
4436
4424
|
* Get object data blobs from Automerge Repo by ids.
|
|
4437
4425
|
* @param ids
|
|
@@ -4439,22 +4427,22 @@ var createLoadDocuments = (automergeHost) => (
|
|
|
4439
4427
|
// TODO(mykola): Unload automerge handles after usage.
|
|
4440
4428
|
async function* loadDocuments(ids) {
|
|
4441
4429
|
for (const id of ids) {
|
|
4442
|
-
const { documentId, objectId } =
|
|
4430
|
+
const { documentId, objectId } = import_protocols12.idCodec.decode(id);
|
|
4443
4431
|
const handle = automergeHost.repo.find(documentId);
|
|
4444
4432
|
await (0, import_debug7.warnAfterTimeout)(5e3, "to long to load doc", () => handle.whenReady());
|
|
4445
4433
|
const doc = handle.docSync();
|
|
4446
4434
|
const hash = (0, import_automerge.getHeads)(doc).join("");
|
|
4447
|
-
yield [
|
|
4435
|
+
yield doc.objects?.[objectId] ? [
|
|
4448
4436
|
{
|
|
4449
4437
|
id,
|
|
4450
4438
|
object: doc.objects[objectId],
|
|
4451
4439
|
currentHash: hash
|
|
4452
4440
|
}
|
|
4453
|
-
];
|
|
4441
|
+
] : [];
|
|
4454
4442
|
}
|
|
4455
4443
|
}
|
|
4456
4444
|
);
|
|
4457
|
-
var
|
|
4445
|
+
var createDocumentsIterator = (automergeHost) => (
|
|
4458
4446
|
/**
|
|
4459
4447
|
* Recursively get all object data blobs from Automerge Repo.
|
|
4460
4448
|
* @param ids
|
|
@@ -4472,12 +4460,12 @@ var createGetAllDocuments = (automergeHost) => (
|
|
|
4472
4460
|
if (doc.objects) {
|
|
4473
4461
|
yield Object.entries(doc.objects).map(([objectId, object]) => {
|
|
4474
4462
|
return {
|
|
4475
|
-
id:
|
|
4463
|
+
id: import_protocols12.idCodec.encode({
|
|
4476
4464
|
documentId: handle.documentId,
|
|
4477
4465
|
objectId
|
|
4478
4466
|
}),
|
|
4479
4467
|
object,
|
|
4480
|
-
currentHash: heads.
|
|
4468
|
+
currentHash: heads.join("")
|
|
4481
4469
|
};
|
|
4482
4470
|
});
|
|
4483
4471
|
}
|
|
@@ -4515,18 +4503,20 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4515
4503
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4516
4504
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4517
4505
|
}
|
|
4518
|
-
var
|
|
4519
|
-
var ServiceContext = class {
|
|
4520
|
-
constructor(storage, networkManager, signalManager, _runtimeParams) {
|
|
4506
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
4507
|
+
var ServiceContext = class extends import_context9.Resource {
|
|
4508
|
+
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
4509
|
+
super();
|
|
4521
4510
|
this.storage = storage;
|
|
4511
|
+
this.level = level;
|
|
4522
4512
|
this.networkManager = networkManager;
|
|
4523
4513
|
this.signalManager = signalManager;
|
|
4524
4514
|
this._runtimeParams = _runtimeParams;
|
|
4525
4515
|
this.initialized = new import_async15.Trigger();
|
|
4526
4516
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4527
4517
|
this._instanceId = import_keys10.PublicKey.random().toHex();
|
|
4528
|
-
this.metadataStore = new
|
|
4529
|
-
this.snapshotStore = new
|
|
4518
|
+
this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
|
|
4519
|
+
this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
|
|
4530
4520
|
this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
|
|
4531
4521
|
this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
|
|
4532
4522
|
this.feedStore = new import_feed_store4.FeedStore({
|
|
@@ -4534,12 +4524,12 @@ var ServiceContext = class {
|
|
|
4534
4524
|
root: storage.createDirectory("feeds"),
|
|
4535
4525
|
signer: this.keyring,
|
|
4536
4526
|
hypercore: {
|
|
4537
|
-
valueEncoding:
|
|
4527
|
+
valueEncoding: import_echo_pipeline4.valueEncoding,
|
|
4538
4528
|
stats: true
|
|
4539
4529
|
}
|
|
4540
4530
|
})
|
|
4541
4531
|
});
|
|
4542
|
-
this.spaceManager = new
|
|
4532
|
+
this.spaceManager = new import_echo_pipeline4.SpaceManager({
|
|
4543
4533
|
feedStore: this.feedStore,
|
|
4544
4534
|
networkManager: this.networkManager,
|
|
4545
4535
|
blobStore: this.blobStore,
|
|
@@ -4548,66 +4538,81 @@ var ServiceContext = class {
|
|
|
4548
4538
|
});
|
|
4549
4539
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
4550
4540
|
this.indexMetadata = new import_indexing.IndexMetadataStore({
|
|
4551
|
-
|
|
4541
|
+
db: level.sublevel("index-metadata")
|
|
4552
4542
|
});
|
|
4553
|
-
this.automergeHost = new
|
|
4543
|
+
this.automergeHost = new import_echo_pipeline4.AutomergeHost({
|
|
4554
4544
|
directory: storage.createDirectory("automerge"),
|
|
4555
|
-
|
|
4545
|
+
db: level.sublevel("automerge"),
|
|
4546
|
+
storageCallbacks: (0, import_indexing.createStorageCallbacks)({
|
|
4547
|
+
host: () => this.automergeHost,
|
|
4548
|
+
metadata: this.indexMetadata
|
|
4549
|
+
})
|
|
4556
4550
|
});
|
|
4557
4551
|
this.indexer = new import_indexing.Indexer({
|
|
4558
4552
|
indexStore: new import_indexing.IndexStore({
|
|
4559
|
-
|
|
4553
|
+
db: level.sublevel("index-storage")
|
|
4560
4554
|
}),
|
|
4561
4555
|
metadataStore: this.indexMetadata,
|
|
4562
|
-
loadDocuments:
|
|
4563
|
-
getAllDocuments:
|
|
4556
|
+
loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
|
|
4557
|
+
getAllDocuments: createDocumentsIterator(this.automergeHost)
|
|
4564
4558
|
});
|
|
4565
4559
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4566
|
-
this.
|
|
4560
|
+
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
4561
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
4567
4562
|
}
|
|
4568
|
-
async
|
|
4563
|
+
async _open(ctx) {
|
|
4569
4564
|
await this._checkStorageVersion();
|
|
4570
4565
|
(0, import_log12.log)("opening...", void 0, {
|
|
4571
|
-
F:
|
|
4572
|
-
L:
|
|
4566
|
+
F: __dxlog_file14,
|
|
4567
|
+
L: 164,
|
|
4573
4568
|
S: this,
|
|
4574
4569
|
C: (f, a) => f(...a)
|
|
4575
4570
|
});
|
|
4576
|
-
import_log12.log.trace("dxos.sdk.service-context.open",
|
|
4571
|
+
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.begin({
|
|
4577
4572
|
id: this._instanceId
|
|
4578
4573
|
}), {
|
|
4579
|
-
F:
|
|
4580
|
-
L:
|
|
4574
|
+
F: __dxlog_file14,
|
|
4575
|
+
L: 165,
|
|
4581
4576
|
S: this,
|
|
4582
4577
|
C: (f, a) => f(...a)
|
|
4583
4578
|
});
|
|
4584
4579
|
await this.signalManager.open();
|
|
4585
4580
|
await this.networkManager.open();
|
|
4581
|
+
await this.automergeHost.open();
|
|
4586
4582
|
await this.metadataStore.load();
|
|
4587
4583
|
await this.spaceManager.open();
|
|
4588
4584
|
await this.identityManager.open(ctx);
|
|
4589
4585
|
if (this.identityManager.identity) {
|
|
4590
4586
|
await this._initialize(ctx);
|
|
4591
4587
|
}
|
|
4592
|
-
|
|
4588
|
+
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
4589
|
+
(0, import_log12.log)("loaded persistent invitations", {
|
|
4590
|
+
count: loadedInvitations.invitations?.length
|
|
4591
|
+
}, {
|
|
4592
|
+
F: __dxlog_file14,
|
|
4593
|
+
L: 178,
|
|
4594
|
+
S: this,
|
|
4595
|
+
C: (f, a) => f(...a)
|
|
4596
|
+
});
|
|
4597
|
+
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.end({
|
|
4593
4598
|
id: this._instanceId
|
|
4594
4599
|
}), {
|
|
4595
|
-
F:
|
|
4596
|
-
L:
|
|
4600
|
+
F: __dxlog_file14,
|
|
4601
|
+
L: 180,
|
|
4597
4602
|
S: this,
|
|
4598
4603
|
C: (f, a) => f(...a)
|
|
4599
4604
|
});
|
|
4600
4605
|
(0, import_log12.log)("opened", void 0, {
|
|
4601
|
-
F:
|
|
4602
|
-
L:
|
|
4606
|
+
F: __dxlog_file14,
|
|
4607
|
+
L: 181,
|
|
4603
4608
|
S: this,
|
|
4604
4609
|
C: (f, a) => f(...a)
|
|
4605
4610
|
});
|
|
4606
4611
|
}
|
|
4607
|
-
async
|
|
4612
|
+
async _close() {
|
|
4608
4613
|
(0, import_log12.log)("closing...", void 0, {
|
|
4609
|
-
F:
|
|
4610
|
-
L:
|
|
4614
|
+
F: __dxlog_file14,
|
|
4615
|
+
L: 185,
|
|
4611
4616
|
S: this,
|
|
4612
4617
|
C: (f, a) => f(...a)
|
|
4613
4618
|
});
|
|
@@ -4624,22 +4629,22 @@ var ServiceContext = class {
|
|
|
4624
4629
|
await this.metadataStore.close();
|
|
4625
4630
|
await this.indexer.destroy();
|
|
4626
4631
|
(0, import_log12.log)("closed", void 0, {
|
|
4627
|
-
F:
|
|
4628
|
-
L:
|
|
4632
|
+
F: __dxlog_file14,
|
|
4633
|
+
L: 198,
|
|
4629
4634
|
S: this,
|
|
4630
4635
|
C: (f, a) => f(...a)
|
|
4631
4636
|
});
|
|
4632
4637
|
}
|
|
4633
4638
|
async createIdentity(params = {}) {
|
|
4634
4639
|
const identity = await this.identityManager.createIdentity(params);
|
|
4635
|
-
await this._initialize(new
|
|
4640
|
+
await this._initialize(new import_context9.Context());
|
|
4636
4641
|
return identity;
|
|
4637
4642
|
}
|
|
4638
4643
|
getInvitationHandler(invitation) {
|
|
4639
4644
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4640
|
-
(0,
|
|
4641
|
-
F:
|
|
4642
|
-
L:
|
|
4645
|
+
(0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4646
|
+
F: __dxlog_file14,
|
|
4647
|
+
L: 209,
|
|
4643
4648
|
S: this,
|
|
4644
4649
|
A: [
|
|
4645
4650
|
"factory",
|
|
@@ -4658,20 +4663,20 @@ var ServiceContext = class {
|
|
|
4658
4663
|
}
|
|
4659
4664
|
async _acceptIdentity(params) {
|
|
4660
4665
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
4661
|
-
await this._initialize(new
|
|
4666
|
+
await this._initialize(new import_context9.Context());
|
|
4662
4667
|
return identity;
|
|
4663
4668
|
}
|
|
4664
4669
|
async _checkStorageVersion() {
|
|
4665
4670
|
await this.metadataStore.load();
|
|
4666
|
-
if (this.metadataStore.version !==
|
|
4667
|
-
throw new
|
|
4671
|
+
if (this.metadataStore.version !== import_protocols11.STORAGE_VERSION) {
|
|
4672
|
+
throw new import_protocols11.InvalidStorageVersionError(import_protocols11.STORAGE_VERSION, this.metadataStore.version);
|
|
4668
4673
|
}
|
|
4669
4674
|
}
|
|
4670
4675
|
// Called when identity is created.
|
|
4671
4676
|
async _initialize(ctx) {
|
|
4672
4677
|
(0, import_log12.log)("initializing spaces...", void 0, {
|
|
4673
|
-
F:
|
|
4674
|
-
L:
|
|
4678
|
+
F: __dxlog_file14,
|
|
4679
|
+
L: 240,
|
|
4675
4680
|
S: this,
|
|
4676
4681
|
C: (f, a) => f(...a)
|
|
4677
4682
|
});
|
|
@@ -4691,10 +4696,10 @@ var ServiceContext = class {
|
|
|
4691
4696
|
};
|
|
4692
4697
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
|
|
4693
4698
|
await this.dataSpaceManager.open();
|
|
4694
|
-
this._handlerFactories.set(
|
|
4695
|
-
(0,
|
|
4696
|
-
F:
|
|
4697
|
-
L:
|
|
4699
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
|
|
4700
|
+
(0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4701
|
+
F: __dxlog_file14,
|
|
4702
|
+
L: 264,
|
|
4698
4703
|
S: this,
|
|
4699
4704
|
A: [
|
|
4700
4705
|
"this.dataSpaceManager",
|
|
@@ -4706,7 +4711,7 @@ var ServiceContext = class {
|
|
|
4706
4711
|
this.initialized.wake();
|
|
4707
4712
|
this._deviceSpaceSync = {
|
|
4708
4713
|
processCredential: async (credential) => {
|
|
4709
|
-
const assertion = (0,
|
|
4714
|
+
const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
|
|
4710
4715
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
4711
4716
|
return;
|
|
4712
4717
|
}
|
|
@@ -4717,8 +4722,8 @@ var ServiceContext = class {
|
|
|
4717
4722
|
(0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
4718
4723
|
details: assertion
|
|
4719
4724
|
}, {
|
|
4720
|
-
F:
|
|
4721
|
-
L:
|
|
4725
|
+
F: __dxlog_file14,
|
|
4726
|
+
L: 280,
|
|
4722
4727
|
S: this,
|
|
4723
4728
|
C: (f, a) => f(...a)
|
|
4724
4729
|
});
|
|
@@ -4728,8 +4733,8 @@ var ServiceContext = class {
|
|
|
4728
4733
|
(0, import_log12.log)("space already exists, ignoring space admission", {
|
|
4729
4734
|
details: assertion
|
|
4730
4735
|
}, {
|
|
4731
|
-
F:
|
|
4732
|
-
L:
|
|
4736
|
+
F: __dxlog_file14,
|
|
4737
|
+
L: 284,
|
|
4733
4738
|
S: this,
|
|
4734
4739
|
C: (f, a) => f(...a)
|
|
4735
4740
|
});
|
|
@@ -4739,8 +4744,8 @@ var ServiceContext = class {
|
|
|
4739
4744
|
(0, import_log12.log)("accepting space recorded in halo", {
|
|
4740
4745
|
details: assertion
|
|
4741
4746
|
}, {
|
|
4742
|
-
F:
|
|
4743
|
-
L:
|
|
4747
|
+
F: __dxlog_file14,
|
|
4748
|
+
L: 289,
|
|
4744
4749
|
S: this,
|
|
4745
4750
|
C: (f, a) => f(...a)
|
|
4746
4751
|
});
|
|
@@ -4750,8 +4755,8 @@ var ServiceContext = class {
|
|
|
4750
4755
|
});
|
|
4751
4756
|
} catch (err) {
|
|
4752
4757
|
import_log12.log.catch(err, void 0, {
|
|
4753
|
-
F:
|
|
4754
|
-
L:
|
|
4758
|
+
F: __dxlog_file14,
|
|
4759
|
+
L: 295,
|
|
4755
4760
|
S: this,
|
|
4756
4761
|
C: (f, a) => f(...a)
|
|
4757
4762
|
});
|
|
@@ -4762,14 +4767,14 @@ var ServiceContext = class {
|
|
|
4762
4767
|
}
|
|
4763
4768
|
};
|
|
4764
4769
|
_ts_decorate6([
|
|
4765
|
-
|
|
4766
|
-
], ServiceContext.prototype, "
|
|
4770
|
+
import_tracing5.trace.span()
|
|
4771
|
+
], ServiceContext.prototype, "_open", null);
|
|
4767
4772
|
_ts_decorate6([
|
|
4768
|
-
|
|
4773
|
+
import_tracing5.trace.span()
|
|
4769
4774
|
], ServiceContext.prototype, "_initialize", null);
|
|
4770
4775
|
ServiceContext = _ts_decorate6([
|
|
4771
4776
|
(0, import_util7.safeInstanceof)("dxos.client-services.ServiceContext"),
|
|
4772
|
-
|
|
4777
|
+
import_tracing5.trace.resource()
|
|
4773
4778
|
], ServiceContext);
|
|
4774
4779
|
var ServiceRegistry = class {
|
|
4775
4780
|
// prettier-ignore
|
|
@@ -4793,103 +4798,155 @@ var ServiceRegistry = class {
|
|
|
4793
4798
|
delete this._handlers[name];
|
|
4794
4799
|
}
|
|
4795
4800
|
};
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
if (
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
}
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
}
|
|
4813
|
-
|
|
4814
|
-
return
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
});
|
|
4823
|
-
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
4824
|
-
await this._onAcquire?.();
|
|
4825
|
-
(0, import_log13.log)("acquired lock", void 0, {
|
|
4826
|
-
F: __dxlog_file16,
|
|
4827
|
-
L: 37,
|
|
4828
|
-
S: this,
|
|
4829
|
-
C: (f, a) => f(...a)
|
|
4830
|
-
});
|
|
4801
|
+
var DXOS_VERSION = "0.4.10-main.068c3d8";
|
|
4802
|
+
var getPlatform = () => {
|
|
4803
|
+
if (process.browser) {
|
|
4804
|
+
if (typeof window !== "undefined") {
|
|
4805
|
+
const { userAgent } = window.navigator;
|
|
4806
|
+
return {
|
|
4807
|
+
type: import_services12.Platform.PLATFORM_TYPE.BROWSER,
|
|
4808
|
+
userAgent,
|
|
4809
|
+
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
4810
|
+
};
|
|
4811
|
+
} else {
|
|
4812
|
+
return {
|
|
4813
|
+
type: import_services12.Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
4814
|
+
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
4815
|
+
};
|
|
4816
|
+
}
|
|
4817
|
+
} else {
|
|
4818
|
+
const { platform: platform2, version, arch } = process;
|
|
4819
|
+
return {
|
|
4820
|
+
type: import_services12.Platform.PLATFORM_TYPE.NODE,
|
|
4821
|
+
platform: platform2,
|
|
4822
|
+
arch,
|
|
4823
|
+
runtime: version,
|
|
4824
|
+
uptime: Math.floor(process.uptime()),
|
|
4825
|
+
memory: process.memoryUsage()
|
|
4826
|
+
};
|
|
4831
4827
|
}
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4828
|
+
};
|
|
4829
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
|
|
4830
|
+
var DEFAULT_TIMEOUT = 1e3;
|
|
4831
|
+
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
4832
|
+
const diagnostics = {
|
|
4833
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4834
|
+
platform: getPlatform(),
|
|
4835
|
+
client: {
|
|
4836
|
+
version: DXOS_VERSION,
|
|
4837
|
+
storage: {
|
|
4838
|
+
version: import_protocols13.STORAGE_VERSION
|
|
4839
|
+
}
|
|
4840
|
+
},
|
|
4841
|
+
trace: import_tracing6.TRACE_PROCESSOR.getDiagnostics()
|
|
4842
|
+
};
|
|
4843
|
+
{
|
|
4844
|
+
(0, import_invariant14.invariant)(clientServices.LoggingService, "SystemService is not available.", {
|
|
4845
|
+
F: __dxlog_file15,
|
|
4846
|
+
L: 108,
|
|
4847
|
+
S: void 0,
|
|
4838
4848
|
A: [
|
|
4839
|
-
"
|
|
4840
|
-
"'
|
|
4849
|
+
"clientServices.LoggingService",
|
|
4850
|
+
"'SystemService is not available.'"
|
|
4841
4851
|
]
|
|
4842
4852
|
});
|
|
4843
|
-
await
|
|
4844
|
-
|
|
4845
|
-
};
|
|
4846
|
-
_ts_decorate7([
|
|
4847
|
-
import_log13.logInfo
|
|
4848
|
-
], Lock.prototype, "lockKey", null);
|
|
4849
|
-
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
4850
|
-
var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
4851
|
-
var createStorageObjects = (config) => {
|
|
4852
|
-
const { persistent = false, keyStore, dataStore, dataRoot = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage" } = config ?? {};
|
|
4853
|
-
if (persistent && dataStore === StorageDriver.RAM) {
|
|
4854
|
-
throw new import_protocols14.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
4853
|
+
diagnostics.metrics = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
|
|
4854
|
+
timeout: DEFAULT_TIMEOUT
|
|
4855
|
+
}).catch(() => void 0);
|
|
4855
4856
|
}
|
|
4856
|
-
if (
|
|
4857
|
-
|
|
4857
|
+
if (typeof navigator !== "undefined" && navigator.storage) {
|
|
4858
|
+
const map = /* @__PURE__ */ new Map();
|
|
4859
|
+
const dir = await navigator.storage.getDirectory();
|
|
4860
|
+
for await (const filename of dir?.keys()) {
|
|
4861
|
+
const idx = filename.indexOf("-", filename.indexOf("-") + 1);
|
|
4862
|
+
if (idx === -1) {
|
|
4863
|
+
continue;
|
|
4864
|
+
}
|
|
4865
|
+
map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
|
|
4866
|
+
}
|
|
4867
|
+
diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
|
|
4868
|
+
file,
|
|
4869
|
+
count
|
|
4870
|
+
}));
|
|
4858
4871
|
}
|
|
4859
|
-
|
|
4860
|
-
|
|
4872
|
+
const identity = serviceContext.identityManager.identity;
|
|
4873
|
+
if (identity) {
|
|
4874
|
+
diagnostics.identity = {
|
|
4875
|
+
identityKey: identity.identityKey,
|
|
4876
|
+
spaceKey: identity.space.key,
|
|
4877
|
+
profile: identity.profileDocument
|
|
4878
|
+
};
|
|
4879
|
+
const { devices } = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
|
|
4880
|
+
timeout: DEFAULT_TIMEOUT
|
|
4881
|
+
}).catch(() => void 0) ?? {};
|
|
4882
|
+
diagnostics.devices = devices;
|
|
4883
|
+
if (serviceContext.dataSpaceManager) {
|
|
4884
|
+
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
4885
|
+
}
|
|
4886
|
+
const { feeds = [] } = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
4887
|
+
timeout: DEFAULT_TIMEOUT
|
|
4888
|
+
}).catch(() => void 0) ?? {};
|
|
4889
|
+
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
4890
|
+
feedKey,
|
|
4891
|
+
bytes,
|
|
4892
|
+
length
|
|
4893
|
+
}));
|
|
4894
|
+
const status = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
|
|
4895
|
+
timeout: DEFAULT_TIMEOUT
|
|
4896
|
+
}).catch(() => void 0);
|
|
4897
|
+
diagnostics.networkStatus = status;
|
|
4898
|
+
diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
|
|
4861
4899
|
}
|
|
4862
|
-
|
|
4863
|
-
|
|
4900
|
+
diagnostics.config = config.values;
|
|
4901
|
+
return diagnostics;
|
|
4902
|
+
};
|
|
4903
|
+
var getSpaceStats = async (space) => {
|
|
4904
|
+
const stats = {
|
|
4905
|
+
key: space.key,
|
|
4906
|
+
metrics: space.metrics,
|
|
4907
|
+
epochs: space.inner.spaceState.credentials.filter((0, import_credentials15.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
4908
|
+
...credential.subject.assertion,
|
|
4909
|
+
id: credential.id
|
|
4910
|
+
})),
|
|
4911
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
4912
|
+
identity: {
|
|
4913
|
+
identityKey: member.key,
|
|
4914
|
+
profile: {
|
|
4915
|
+
displayName: member.assertion.profile?.displayName
|
|
4916
|
+
}
|
|
4917
|
+
},
|
|
4918
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services11.SpaceMember.PresenceState.ONLINE : import_services11.SpaceMember.PresenceState.OFFLINE
|
|
4919
|
+
})),
|
|
4920
|
+
pipeline: {
|
|
4921
|
+
// TODO(burdon): Pick properties from credentials if needed.
|
|
4922
|
+
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
4923
|
+
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
4924
|
+
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
4925
|
+
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
4926
|
+
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
4927
|
+
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
|
|
4928
|
+
}
|
|
4929
|
+
};
|
|
4930
|
+
if (stats.metrics) {
|
|
4931
|
+
const { open, ready } = stats.metrics;
|
|
4932
|
+
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
4864
4933
|
}
|
|
4934
|
+
return stats;
|
|
4935
|
+
};
|
|
4936
|
+
var createCollectDiagnosticsBroadcastSender = () => {
|
|
4865
4937
|
return {
|
|
4866
|
-
|
|
4867
|
-
type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
|
|
4868
|
-
root: `${dataRoot}/`
|
|
4869
|
-
})
|
|
4938
|
+
broadcastDiagnosticsRequest: async () => void 0
|
|
4870
4939
|
};
|
|
4871
4940
|
};
|
|
4872
|
-
var
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
return import_random_access_storage.StorageType.CHROME;
|
|
4880
|
-
case StorageDriver.FIREFOX:
|
|
4881
|
-
return import_random_access_storage.StorageType.FIREFOX;
|
|
4882
|
-
case StorageDriver.IDB:
|
|
4883
|
-
return import_random_access_storage.StorageType.IDB;
|
|
4884
|
-
case StorageDriver.NODE:
|
|
4885
|
-
return import_random_access_storage.StorageType.NODE;
|
|
4886
|
-
case StorageDriver.WEBFS:
|
|
4887
|
-
return import_random_access_storage.StorageType.WEBFS;
|
|
4888
|
-
default:
|
|
4889
|
-
throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
|
|
4890
|
-
}
|
|
4941
|
+
var createCollectDiagnosticsBroadcastHandler = (_) => {
|
|
4942
|
+
return {
|
|
4943
|
+
start: () => {
|
|
4944
|
+
},
|
|
4945
|
+
stop: () => {
|
|
4946
|
+
}
|
|
4947
|
+
};
|
|
4891
4948
|
};
|
|
4892
|
-
var
|
|
4949
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
4893
4950
|
var DevicesServiceImpl = class {
|
|
4894
4951
|
constructor(_identityManager) {
|
|
4895
4952
|
this._identityManager = _identityManager;
|
|
@@ -4906,8 +4963,8 @@ var DevicesServiceImpl = class {
|
|
|
4906
4963
|
devices: []
|
|
4907
4964
|
});
|
|
4908
4965
|
} else {
|
|
4909
|
-
(0,
|
|
4910
|
-
F:
|
|
4966
|
+
(0, import_invariant16.invariant)(this._identityManager.identity?.presence, "presence not present", {
|
|
4967
|
+
F: __dxlog_file16,
|
|
4911
4968
|
L: 32,
|
|
4912
4969
|
S: this,
|
|
4913
4970
|
A: [
|
|
@@ -4922,9 +4979,9 @@ var DevicesServiceImpl = class {
|
|
|
4922
4979
|
const peerState = peers.find((peer) => peer.identityKey.equals(key));
|
|
4923
4980
|
return {
|
|
4924
4981
|
deviceKey: key,
|
|
4925
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ?
|
|
4982
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services15.DeviceKind.CURRENT : import_services15.DeviceKind.TRUSTED,
|
|
4926
4983
|
profile,
|
|
4927
|
-
presence: isMe ?
|
|
4984
|
+
presence: isMe ? import_services15.Device.PresenceState.ONLINE : peerState ? import_services15.Device.PresenceState.ONLINE : import_services15.Device.PresenceState.OFFLINE
|
|
4928
4985
|
};
|
|
4929
4986
|
})
|
|
4930
4987
|
});
|
|
@@ -4965,6 +5022,60 @@ var DevicesServiceImpl = class {
|
|
|
4965
5022
|
});
|
|
4966
5023
|
}
|
|
4967
5024
|
};
|
|
5025
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
5026
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5027
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
5028
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
5029
|
+
else
|
|
5030
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
5031
|
+
if (d = decorators[i])
|
|
5032
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5033
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5034
|
+
}
|
|
5035
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
5036
|
+
var Lock = class {
|
|
5037
|
+
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
5038
|
+
this._lockPath = lockPath;
|
|
5039
|
+
this._onAcquire = onAcquire;
|
|
5040
|
+
this._onRelease = onRelease;
|
|
5041
|
+
}
|
|
5042
|
+
get lockKey() {
|
|
5043
|
+
return this._lockPath;
|
|
5044
|
+
}
|
|
5045
|
+
async acquire() {
|
|
5046
|
+
(0, import_log14.log)("acquiring lock...", void 0, {
|
|
5047
|
+
F: __dxlog_file17,
|
|
5048
|
+
L: 32,
|
|
5049
|
+
S: this,
|
|
5050
|
+
C: (f, a) => f(...a)
|
|
5051
|
+
});
|
|
5052
|
+
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
5053
|
+
await this._onAcquire?.();
|
|
5054
|
+
(0, import_log14.log)("acquired lock", void 0, {
|
|
5055
|
+
F: __dxlog_file17,
|
|
5056
|
+
L: 37,
|
|
5057
|
+
S: this,
|
|
5058
|
+
C: (f, a) => f(...a)
|
|
5059
|
+
});
|
|
5060
|
+
}
|
|
5061
|
+
async release() {
|
|
5062
|
+
await this._onRelease?.();
|
|
5063
|
+
(0, import_invariant17.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
5064
|
+
F: __dxlog_file17,
|
|
5065
|
+
L: 42,
|
|
5066
|
+
S: this,
|
|
5067
|
+
A: [
|
|
5068
|
+
"this._fileHandle",
|
|
5069
|
+
"'Lock is not acquired'"
|
|
5070
|
+
]
|
|
5071
|
+
});
|
|
5072
|
+
await import_lock_file.LockFile.release(this._fileHandle);
|
|
5073
|
+
}
|
|
5074
|
+
};
|
|
5075
|
+
_ts_decorate7([
|
|
5076
|
+
import_log14.logInfo
|
|
5077
|
+
], Lock.prototype, "lockKey", null);
|
|
5078
|
+
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
4968
5079
|
var LoggingServiceImpl = class {
|
|
4969
5080
|
constructor() {
|
|
4970
5081
|
this._logs = new import_async18.Event();
|
|
@@ -5064,18 +5175,18 @@ var LoggingServiceImpl = class {
|
|
|
5064
5175
|
});
|
|
5065
5176
|
}
|
|
5066
5177
|
};
|
|
5067
|
-
var matchFilter = (filter, level,
|
|
5178
|
+
var matchFilter = (filter, level, path2, options) => {
|
|
5068
5179
|
switch (options) {
|
|
5069
|
-
case
|
|
5070
|
-
return level >= filter.level && (!filter.pattern ||
|
|
5071
|
-
case
|
|
5072
|
-
return level === filter.level && (!filter.pattern ||
|
|
5180
|
+
case import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
5181
|
+
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5182
|
+
case import_services16.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
5183
|
+
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5073
5184
|
}
|
|
5074
5185
|
};
|
|
5075
5186
|
var shouldLog = (entry2, request) => {
|
|
5076
|
-
const options = request.options ??
|
|
5187
|
+
const options = request.options ?? import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5077
5188
|
if (request.filters === void 0) {
|
|
5078
|
-
return options ===
|
|
5189
|
+
return options === import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5079
5190
|
} else {
|
|
5080
5191
|
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
5081
5192
|
}
|
|
@@ -5111,6 +5222,63 @@ var NetworkServiceImpl = class {
|
|
|
5111
5222
|
await this.networkManager.setConnectionState(request.swarm);
|
|
5112
5223
|
}
|
|
5113
5224
|
};
|
|
5225
|
+
var getRootPath = (config) => {
|
|
5226
|
+
const { dataRoot = (0, import_util11.isNode)() ? import_client_protocol5.DX_DATA : "dxos/storage" } = config ?? {};
|
|
5227
|
+
return `${dataRoot}/`;
|
|
5228
|
+
};
|
|
5229
|
+
var isPersistent = (config) => {
|
|
5230
|
+
const { persistent = false } = config ?? {};
|
|
5231
|
+
return config.dataStore !== void 0 && config.dataStore !== import_config3.Runtime.Client.Storage.StorageDriver.RAM || persistent;
|
|
5232
|
+
};
|
|
5233
|
+
var StorageDriver = import_config2.Runtime.Client.Storage.StorageDriver;
|
|
5234
|
+
var createStorageObjects = (config) => {
|
|
5235
|
+
const { persistent = false, keyStore, dataStore } = config ?? {};
|
|
5236
|
+
if (persistent && dataStore === StorageDriver.RAM) {
|
|
5237
|
+
throw new import_protocols15.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
5238
|
+
}
|
|
5239
|
+
if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
|
|
5240
|
+
throw new import_protocols15.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
5241
|
+
}
|
|
5242
|
+
if (persistent && keyStore === StorageDriver.RAM) {
|
|
5243
|
+
throw new import_protocols15.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
5244
|
+
}
|
|
5245
|
+
if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
|
|
5246
|
+
throw new import_protocols15.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
5247
|
+
}
|
|
5248
|
+
return {
|
|
5249
|
+
storage: (0, import_random_access_storage.createStorage)({
|
|
5250
|
+
type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
|
|
5251
|
+
root: getRootPath(config)
|
|
5252
|
+
})
|
|
5253
|
+
};
|
|
5254
|
+
};
|
|
5255
|
+
var toStorageType = (type) => {
|
|
5256
|
+
switch (type) {
|
|
5257
|
+
case void 0:
|
|
5258
|
+
return void 0;
|
|
5259
|
+
case StorageDriver.RAM:
|
|
5260
|
+
return import_random_access_storage.StorageType.RAM;
|
|
5261
|
+
case StorageDriver.CHROME:
|
|
5262
|
+
return import_random_access_storage.StorageType.CHROME;
|
|
5263
|
+
case StorageDriver.FIREFOX:
|
|
5264
|
+
return import_random_access_storage.StorageType.FIREFOX;
|
|
5265
|
+
case StorageDriver.IDB:
|
|
5266
|
+
return import_random_access_storage.StorageType.IDB;
|
|
5267
|
+
case StorageDriver.NODE:
|
|
5268
|
+
return import_random_access_storage.StorageType.NODE;
|
|
5269
|
+
case StorageDriver.WEBFS:
|
|
5270
|
+
return import_random_access_storage.StorageType.WEBFS;
|
|
5271
|
+
default:
|
|
5272
|
+
throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
|
|
5273
|
+
}
|
|
5274
|
+
};
|
|
5275
|
+
var createLevel = async (config) => {
|
|
5276
|
+
const persistent = isPersistent(config);
|
|
5277
|
+
const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys13.PublicKey.random().toHex()}`;
|
|
5278
|
+
const level = new import_level.Level(storagePath);
|
|
5279
|
+
await level.open();
|
|
5280
|
+
return level;
|
|
5281
|
+
};
|
|
5114
5282
|
var SystemServiceImpl = class {
|
|
5115
5283
|
constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
5116
5284
|
this._config = config;
|
|
@@ -5130,9 +5298,9 @@ var SystemServiceImpl = class {
|
|
|
5130
5298
|
const diagnostics = await this._getDiagnostics();
|
|
5131
5299
|
return {
|
|
5132
5300
|
timestamp: /* @__PURE__ */ new Date(),
|
|
5133
|
-
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0,
|
|
5134
|
-
truncate: keys ===
|
|
5135
|
-
humanize: keys ===
|
|
5301
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util12.jsonKeyReplacer)({
|
|
5302
|
+
truncate: keys === import_services17.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
5303
|
+
humanize: keys === import_services17.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
5136
5304
|
})))
|
|
5137
5305
|
};
|
|
5138
5306
|
}
|
|
@@ -5180,16 +5348,18 @@ var ClientServicesHost = class {
|
|
|
5180
5348
|
transportFactory,
|
|
5181
5349
|
signalManager,
|
|
5182
5350
|
storage,
|
|
5351
|
+
level,
|
|
5183
5352
|
// TODO(wittjosiah): Turn this on by default.
|
|
5184
5353
|
lockKey,
|
|
5185
5354
|
callbacks,
|
|
5186
5355
|
runtimeParams
|
|
5187
5356
|
} = {}) {
|
|
5188
|
-
this._tracingService =
|
|
5357
|
+
this._tracingService = import_tracing8.TRACE_PROCESSOR.createTraceSender();
|
|
5189
5358
|
this._statusUpdate = new import_async16.Event();
|
|
5190
5359
|
this._opening = false;
|
|
5191
5360
|
this._open = false;
|
|
5192
5361
|
this._storage = storage;
|
|
5362
|
+
this._level = level;
|
|
5193
5363
|
this._callbacks = callbacks;
|
|
5194
5364
|
this._runtimeParams = runtimeParams;
|
|
5195
5365
|
if (config) {
|
|
@@ -5204,7 +5374,7 @@ var ClientServicesHost = class {
|
|
|
5204
5374
|
lockKey,
|
|
5205
5375
|
onAcquire: () => {
|
|
5206
5376
|
if (!this._opening) {
|
|
5207
|
-
void this.open(new
|
|
5377
|
+
void this.open(new import_context10.Context());
|
|
5208
5378
|
}
|
|
5209
5379
|
},
|
|
5210
5380
|
onRelease: () => this.close()
|
|
@@ -5213,14 +5383,14 @@ var ClientServicesHost = class {
|
|
|
5213
5383
|
this._systemService = new SystemServiceImpl({
|
|
5214
5384
|
config: () => this._config,
|
|
5215
5385
|
statusUpdate: this._statusUpdate,
|
|
5216
|
-
getCurrentStatus: () => this.isOpen ?
|
|
5386
|
+
getCurrentStatus: () => this.isOpen ? import_services14.SystemStatus.ACTIVE : import_services14.SystemStatus.INACTIVE,
|
|
5217
5387
|
getDiagnostics: () => {
|
|
5218
5388
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
5219
5389
|
},
|
|
5220
5390
|
onUpdateStatus: async (status) => {
|
|
5221
|
-
if (!this.isOpen && status ===
|
|
5391
|
+
if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
|
|
5222
5392
|
await this._resourceLock?.acquire();
|
|
5223
|
-
} else if (this.isOpen && status ===
|
|
5393
|
+
} else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
|
|
5224
5394
|
await this._resourceLock?.release();
|
|
5225
5395
|
}
|
|
5226
5396
|
},
|
|
@@ -5228,8 +5398,9 @@ var ClientServicesHost = class {
|
|
|
5228
5398
|
await this.reset();
|
|
5229
5399
|
}
|
|
5230
5400
|
});
|
|
5401
|
+
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
5231
5402
|
this._loggingService = new LoggingServiceImpl();
|
|
5232
|
-
this._serviceRegistry = new ServiceRegistry(
|
|
5403
|
+
this._serviceRegistry = new ServiceRegistry(import_client_protocol4.clientServiceBundle, {
|
|
5233
5404
|
SystemService: this._systemService,
|
|
5234
5405
|
TracingService: this._tracingService
|
|
5235
5406
|
});
|
|
@@ -5258,25 +5429,25 @@ var ClientServicesHost = class {
|
|
|
5258
5429
|
* Can only be called once.
|
|
5259
5430
|
*/
|
|
5260
5431
|
initialize({ config, ...options }) {
|
|
5261
|
-
(0,
|
|
5432
|
+
(0, import_invariant15.invariant)(!this._open, "service host is open", {
|
|
5262
5433
|
F: __dxlog_file18,
|
|
5263
|
-
L:
|
|
5434
|
+
L: 197,
|
|
5264
5435
|
S: this,
|
|
5265
5436
|
A: [
|
|
5266
5437
|
"!this._open",
|
|
5267
5438
|
"'service host is open'"
|
|
5268
5439
|
]
|
|
5269
5440
|
});
|
|
5270
|
-
(0,
|
|
5441
|
+
(0, import_log13.log)("initializing...", void 0, {
|
|
5271
5442
|
F: __dxlog_file18,
|
|
5272
|
-
L:
|
|
5443
|
+
L: 198,
|
|
5273
5444
|
S: this,
|
|
5274
5445
|
C: (f, a) => f(...a)
|
|
5275
5446
|
});
|
|
5276
5447
|
if (config) {
|
|
5277
|
-
(0,
|
|
5448
|
+
(0, import_invariant15.invariant)(!this._config, "config already set", {
|
|
5278
5449
|
F: __dxlog_file18,
|
|
5279
|
-
L:
|
|
5450
|
+
L: 201,
|
|
5280
5451
|
S: this,
|
|
5281
5452
|
A: [
|
|
5282
5453
|
"!this._config",
|
|
@@ -5289,9 +5460,9 @@ var ClientServicesHost = class {
|
|
|
5289
5460
|
}
|
|
5290
5461
|
}
|
|
5291
5462
|
if (!options.signalManager) {
|
|
5292
|
-
|
|
5463
|
+
import_log13.log.warn("running signaling without telemetry metadata.", void 0, {
|
|
5293
5464
|
F: __dxlog_file18,
|
|
5294
|
-
L:
|
|
5465
|
+
L: 209,
|
|
5295
5466
|
S: this,
|
|
5296
5467
|
C: (f, a) => f(...a)
|
|
5297
5468
|
});
|
|
@@ -5300,9 +5471,9 @@ var ClientServicesHost = class {
|
|
|
5300
5471
|
iceServers: this._config?.get("runtime.services.ice")
|
|
5301
5472
|
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
5302
5473
|
this._signalManager = signalManager;
|
|
5303
|
-
(0,
|
|
5474
|
+
(0, import_invariant15.invariant)(!this._networkManager, "network manager already set", {
|
|
5304
5475
|
F: __dxlog_file18,
|
|
5305
|
-
L:
|
|
5476
|
+
L: 220,
|
|
5306
5477
|
S: this,
|
|
5307
5478
|
A: [
|
|
5308
5479
|
"!this._networkManager",
|
|
@@ -5314,9 +5485,9 @@ var ClientServicesHost = class {
|
|
|
5314
5485
|
transportFactory,
|
|
5315
5486
|
signalManager
|
|
5316
5487
|
});
|
|
5317
|
-
(0,
|
|
5488
|
+
(0, import_log13.log)("initialized", void 0, {
|
|
5318
5489
|
F: __dxlog_file18,
|
|
5319
|
-
L:
|
|
5490
|
+
L: 227,
|
|
5320
5491
|
S: this,
|
|
5321
5492
|
C: (f, a) => f(...a)
|
|
5322
5493
|
});
|
|
@@ -5326,44 +5497,44 @@ var ClientServicesHost = class {
|
|
|
5326
5497
|
return;
|
|
5327
5498
|
}
|
|
5328
5499
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
5329
|
-
|
|
5500
|
+
import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.begin({
|
|
5330
5501
|
id: traceId
|
|
5331
5502
|
}), {
|
|
5332
5503
|
F: __dxlog_file18,
|
|
5333
|
-
L:
|
|
5504
|
+
L: 238,
|
|
5334
5505
|
S: this,
|
|
5335
5506
|
C: (f, a) => f(...a)
|
|
5336
5507
|
});
|
|
5337
|
-
(0,
|
|
5508
|
+
(0, import_invariant15.invariant)(this._config, "config not set", {
|
|
5338
5509
|
F: __dxlog_file18,
|
|
5339
|
-
L:
|
|
5510
|
+
L: 240,
|
|
5340
5511
|
S: this,
|
|
5341
5512
|
A: [
|
|
5342
5513
|
"this._config",
|
|
5343
5514
|
"'config not set'"
|
|
5344
5515
|
]
|
|
5345
5516
|
});
|
|
5346
|
-
(0,
|
|
5517
|
+
(0, import_invariant15.invariant)(this._storage, "storage not set", {
|
|
5347
5518
|
F: __dxlog_file18,
|
|
5348
|
-
L:
|
|
5519
|
+
L: 241,
|
|
5349
5520
|
S: this,
|
|
5350
5521
|
A: [
|
|
5351
5522
|
"this._storage",
|
|
5352
5523
|
"'storage not set'"
|
|
5353
5524
|
]
|
|
5354
5525
|
});
|
|
5355
|
-
(0,
|
|
5526
|
+
(0, import_invariant15.invariant)(this._signalManager, "signal manager not set", {
|
|
5356
5527
|
F: __dxlog_file18,
|
|
5357
|
-
L:
|
|
5528
|
+
L: 242,
|
|
5358
5529
|
S: this,
|
|
5359
5530
|
A: [
|
|
5360
5531
|
"this._signalManager",
|
|
5361
5532
|
"'signal manager not set'"
|
|
5362
5533
|
]
|
|
5363
5534
|
});
|
|
5364
|
-
(0,
|
|
5535
|
+
(0, import_invariant15.invariant)(this._networkManager, "network manager not set", {
|
|
5365
5536
|
F: __dxlog_file18,
|
|
5366
|
-
L:
|
|
5537
|
+
L: 243,
|
|
5367
5538
|
S: this,
|
|
5368
5539
|
A: [
|
|
5369
5540
|
"this._networkManager",
|
|
@@ -5371,27 +5542,31 @@ var ClientServicesHost = class {
|
|
|
5371
5542
|
]
|
|
5372
5543
|
});
|
|
5373
5544
|
this._opening = true;
|
|
5374
|
-
(0,
|
|
5545
|
+
(0, import_log13.log)("opening...", {
|
|
5375
5546
|
lockKey: this._resourceLock?.lockKey
|
|
5376
5547
|
}, {
|
|
5377
5548
|
F: __dxlog_file18,
|
|
5378
|
-
L:
|
|
5549
|
+
L: 246,
|
|
5379
5550
|
S: this,
|
|
5380
5551
|
C: (f, a) => f(...a)
|
|
5381
5552
|
});
|
|
5553
|
+
if (!this._level) {
|
|
5554
|
+
this._level = await createLevel(this._config.get("runtime.client.storage", {}));
|
|
5555
|
+
}
|
|
5556
|
+
await this._level.open();
|
|
5382
5557
|
await this._resourceLock?.acquire();
|
|
5383
5558
|
await this._loggingService.open();
|
|
5384
|
-
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._runtimeParams);
|
|
5559
|
+
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
|
|
5385
5560
|
this._serviceRegistry.setServices({
|
|
5386
5561
|
SystemService: this._systemService,
|
|
5387
5562
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
5388
|
-
InvitationsService: new InvitationsServiceImpl(this._serviceContext.
|
|
5563
|
+
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
|
|
5389
5564
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
5390
5565
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
|
|
5391
5566
|
await this._serviceContext.initialized.wait();
|
|
5392
5567
|
return this._serviceContext.dataSpaceManager;
|
|
5393
5568
|
}),
|
|
5394
|
-
DataService: new
|
|
5569
|
+
DataService: new import_echo_pipeline5.DataServiceImpl(this._serviceContext.automergeHost),
|
|
5395
5570
|
IndexService: new import_indexing2.IndexServiceImpl({
|
|
5396
5571
|
indexer: this._serviceContext.indexer,
|
|
5397
5572
|
automergeHost: this._serviceContext.automergeHost
|
|
@@ -5407,51 +5582,34 @@ var ClientServicesHost = class {
|
|
|
5407
5582
|
})
|
|
5408
5583
|
});
|
|
5409
5584
|
await this._serviceContext.open(ctx);
|
|
5410
|
-
(0, import_invariant16.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5411
|
-
F: __dxlog_file18,
|
|
5412
|
-
L: 289,
|
|
5413
|
-
S: this,
|
|
5414
|
-
A: [
|
|
5415
|
-
"this.serviceRegistry.services.InvitationsService",
|
|
5416
|
-
""
|
|
5417
|
-
]
|
|
5418
|
-
});
|
|
5419
|
-
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5420
|
-
(0, import_log14.log)("loaded persistent invitations", {
|
|
5421
|
-
count: loadedInvitations.invitations?.length
|
|
5422
|
-
}, {
|
|
5423
|
-
F: __dxlog_file18,
|
|
5424
|
-
L: 292,
|
|
5425
|
-
S: this,
|
|
5426
|
-
C: (f, a) => f(...a)
|
|
5427
|
-
});
|
|
5428
5585
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
5429
5586
|
if (devtoolsProxy) {
|
|
5430
5587
|
this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
|
|
5431
5588
|
url: devtoolsProxy,
|
|
5432
5589
|
requested: {},
|
|
5433
|
-
exposed:
|
|
5590
|
+
exposed: import_client_protocol4.clientServiceBundle,
|
|
5434
5591
|
handlers: this.services
|
|
5435
5592
|
});
|
|
5436
5593
|
void this._devtoolsProxy.open();
|
|
5437
5594
|
}
|
|
5595
|
+
this.diagnosticsBroadcastHandler.start();
|
|
5438
5596
|
this._opening = false;
|
|
5439
5597
|
this._open = true;
|
|
5440
5598
|
this._statusUpdate.emit();
|
|
5441
5599
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5442
|
-
(0,
|
|
5600
|
+
(0, import_log13.log)("opened", {
|
|
5443
5601
|
deviceKey
|
|
5444
5602
|
}, {
|
|
5445
5603
|
F: __dxlog_file18,
|
|
5446
|
-
L:
|
|
5604
|
+
L: 326,
|
|
5447
5605
|
S: this,
|
|
5448
5606
|
C: (f, a) => f(...a)
|
|
5449
5607
|
});
|
|
5450
|
-
|
|
5608
|
+
import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.end({
|
|
5451
5609
|
id: traceId
|
|
5452
5610
|
}), {
|
|
5453
5611
|
F: __dxlog_file18,
|
|
5454
|
-
L:
|
|
5612
|
+
L: 327,
|
|
5455
5613
|
S: this,
|
|
5456
5614
|
C: (f, a) => f(...a)
|
|
5457
5615
|
});
|
|
@@ -5461,60 +5619,62 @@ var ClientServicesHost = class {
|
|
|
5461
5619
|
return;
|
|
5462
5620
|
}
|
|
5463
5621
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5464
|
-
(0,
|
|
5622
|
+
(0, import_log13.log)("closing...", {
|
|
5465
5623
|
deviceKey
|
|
5466
5624
|
}, {
|
|
5467
5625
|
F: __dxlog_file18,
|
|
5468
|
-
L:
|
|
5626
|
+
L: 338,
|
|
5469
5627
|
S: this,
|
|
5470
5628
|
C: (f, a) => f(...a)
|
|
5471
5629
|
});
|
|
5630
|
+
this.diagnosticsBroadcastHandler.stop();
|
|
5472
5631
|
await this._devtoolsProxy?.close();
|
|
5473
5632
|
this._serviceRegistry.setServices({
|
|
5474
5633
|
SystemService: this._systemService
|
|
5475
5634
|
});
|
|
5476
5635
|
await this._loggingService.close();
|
|
5477
5636
|
await this._serviceContext.close();
|
|
5637
|
+
await this._level?.close();
|
|
5478
5638
|
this._open = false;
|
|
5479
5639
|
this._statusUpdate.emit();
|
|
5480
|
-
(0,
|
|
5640
|
+
(0, import_log13.log)("closed", {
|
|
5481
5641
|
deviceKey
|
|
5482
5642
|
}, {
|
|
5483
5643
|
F: __dxlog_file18,
|
|
5484
|
-
L:
|
|
5644
|
+
L: 347,
|
|
5485
5645
|
S: this,
|
|
5486
5646
|
C: (f, a) => f(...a)
|
|
5487
5647
|
});
|
|
5488
5648
|
}
|
|
5489
5649
|
async reset() {
|
|
5490
5650
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
5491
|
-
|
|
5651
|
+
import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.begin({
|
|
5492
5652
|
id: traceId
|
|
5493
5653
|
}), {
|
|
5494
5654
|
F: __dxlog_file18,
|
|
5495
|
-
L:
|
|
5655
|
+
L: 352,
|
|
5496
5656
|
S: this,
|
|
5497
5657
|
C: (f, a) => f(...a)
|
|
5498
5658
|
});
|
|
5499
|
-
(0,
|
|
5659
|
+
(0, import_log13.log)("resetting...", void 0, {
|
|
5500
5660
|
F: __dxlog_file18,
|
|
5501
|
-
L:
|
|
5661
|
+
L: 354,
|
|
5502
5662
|
S: this,
|
|
5503
5663
|
C: (f, a) => f(...a)
|
|
5504
5664
|
});
|
|
5505
5665
|
await this._serviceContext?.close();
|
|
5506
5666
|
await this._storage.reset();
|
|
5507
|
-
(0,
|
|
5667
|
+
(0, import_log13.log)("reset", void 0, {
|
|
5508
5668
|
F: __dxlog_file18,
|
|
5509
|
-
L:
|
|
5669
|
+
L: 357,
|
|
5510
5670
|
S: this,
|
|
5511
5671
|
C: (f, a) => f(...a)
|
|
5512
5672
|
});
|
|
5513
|
-
|
|
5673
|
+
import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.end({
|
|
5514
5674
|
id: traceId
|
|
5515
5675
|
}), {
|
|
5516
5676
|
F: __dxlog_file18,
|
|
5517
|
-
L:
|
|
5677
|
+
L: 358,
|
|
5518
5678
|
S: this,
|
|
5519
5679
|
C: (f, a) => f(...a)
|
|
5520
5680
|
});
|
|
@@ -5524,12 +5684,10 @@ var ClientServicesHost = class {
|
|
|
5524
5684
|
const identity = await this._serviceContext.createIdentity(params);
|
|
5525
5685
|
await this._serviceContext.initialized.wait();
|
|
5526
5686
|
const space = await this._serviceContext.dataSpaceManager.createSpace();
|
|
5527
|
-
const obj = new import_client_protocol5.Properties(void 0);
|
|
5528
|
-
obj[import_client_protocol5.defaultKey] = identity.identityKey.toHex();
|
|
5529
5687
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5530
|
-
(0,
|
|
5688
|
+
(0, import_invariant15.invariant)(automergeIndex, void 0, {
|
|
5531
5689
|
F: __dxlog_file18,
|
|
5532
|
-
L:
|
|
5690
|
+
L: 370,
|
|
5533
5691
|
S: this,
|
|
5534
5692
|
A: [
|
|
5535
5693
|
"automergeIndex",
|
|
@@ -5538,45 +5696,93 @@ var ClientServicesHost = class {
|
|
|
5538
5696
|
});
|
|
5539
5697
|
const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
|
|
5540
5698
|
await document.whenReady();
|
|
5699
|
+
const properties = {
|
|
5700
|
+
system: {
|
|
5701
|
+
type: (0, import_echo_pipeline5.encodeReference)((0, import_echo_schema.getTypeReference)(import_client_protocol4.Properties))
|
|
5702
|
+
},
|
|
5703
|
+
data: {
|
|
5704
|
+
[import_client_protocol4.defaultKey]: identity.identityKey.toHex()
|
|
5705
|
+
},
|
|
5706
|
+
meta: {
|
|
5707
|
+
keys: []
|
|
5708
|
+
}
|
|
5709
|
+
};
|
|
5710
|
+
const propertiesId = import_keys11.PublicKey.random().toHex();
|
|
5541
5711
|
document.change((doc) => {
|
|
5542
5712
|
(0, import_util9.assignDeep)(doc, [
|
|
5543
5713
|
"objects",
|
|
5544
|
-
|
|
5545
|
-
],
|
|
5714
|
+
propertiesId
|
|
5715
|
+
], properties);
|
|
5546
5716
|
});
|
|
5717
|
+
await this._serviceContext.automergeHost.repo.flush();
|
|
5547
5718
|
return identity;
|
|
5548
5719
|
}
|
|
5549
5720
|
};
|
|
5550
5721
|
_ts_decorate8([
|
|
5551
|
-
|
|
5722
|
+
import_tracing8.trace.info()
|
|
5552
5723
|
], ClientServicesHost.prototype, "_opening", void 0);
|
|
5553
5724
|
_ts_decorate8([
|
|
5554
|
-
|
|
5725
|
+
import_tracing8.trace.info()
|
|
5555
5726
|
], ClientServicesHost.prototype, "_open", void 0);
|
|
5556
5727
|
_ts_decorate8([
|
|
5557
5728
|
import_async16.synchronized,
|
|
5558
|
-
|
|
5729
|
+
import_tracing8.trace.span()
|
|
5559
5730
|
], ClientServicesHost.prototype, "open", null);
|
|
5560
5731
|
_ts_decorate8([
|
|
5561
5732
|
import_async16.synchronized,
|
|
5562
|
-
|
|
5733
|
+
import_tracing8.trace.span()
|
|
5563
5734
|
], ClientServicesHost.prototype, "close", null);
|
|
5564
5735
|
ClientServicesHost = _ts_decorate8([
|
|
5565
|
-
|
|
5736
|
+
import_tracing8.trace.resource()
|
|
5566
5737
|
], ClientServicesHost);
|
|
5738
|
+
var ClientServicesProviderResource = Symbol.for("dxos.resource.ClientServices");
|
|
5739
|
+
var DiagnosticsCollector = class {
|
|
5740
|
+
static {
|
|
5741
|
+
this.broadcastSender = createCollectDiagnosticsBroadcastSender();
|
|
5742
|
+
}
|
|
5743
|
+
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
5744
|
+
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
5745
|
+
keys: options.humanize ? import_services13.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services13.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
5746
|
+
});
|
|
5747
|
+
const clientDiagnostics = {
|
|
5748
|
+
config,
|
|
5749
|
+
trace: import_tracing7.TRACE_PROCESSOR.getDiagnostics()
|
|
5750
|
+
};
|
|
5751
|
+
const diagnostics = serviceDiagnostics != null ? {
|
|
5752
|
+
client: clientDiagnostics,
|
|
5753
|
+
services: serviceDiagnostics
|
|
5754
|
+
} : {
|
|
5755
|
+
client: clientDiagnostics,
|
|
5756
|
+
broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
|
|
5757
|
+
};
|
|
5758
|
+
return JSON.parse(JSON.stringify(diagnostics, (0, import_util8.jsonKeyReplacer)(options)));
|
|
5759
|
+
}
|
|
5760
|
+
};
|
|
5761
|
+
var findSystemServiceProvider = () => {
|
|
5762
|
+
const serviceProviders = import_tracing7.TRACE_PROCESSOR.findByAnnotation(ClientServicesProviderResource);
|
|
5763
|
+
const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
|
|
5764
|
+
return providerResource?.instance?.deref() ?? null;
|
|
5765
|
+
};
|
|
5766
|
+
var findConfigs = () => {
|
|
5767
|
+
const configs = import_tracing7.TRACE_PROCESSOR.findByAnnotation(import_config.ConfigResource);
|
|
5768
|
+
return configs.map((r) => r.instance.deref()).filter(import_util8.nonNullable);
|
|
5769
|
+
};
|
|
5567
5770
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5568
5771
|
0 && (module.exports = {
|
|
5569
5772
|
ClientRpcServer,
|
|
5570
5773
|
ClientServicesHost,
|
|
5774
|
+
ClientServicesProviderResource,
|
|
5571
5775
|
DataSpace,
|
|
5572
5776
|
DataSpaceManager,
|
|
5573
5777
|
DeviceInvitationProtocol,
|
|
5574
5778
|
DevtoolsHostEvents,
|
|
5575
5779
|
DevtoolsServiceImpl,
|
|
5780
|
+
DiagnosticsCollector,
|
|
5576
5781
|
Identity,
|
|
5577
5782
|
IdentityManager,
|
|
5578
5783
|
IdentityServiceImpl,
|
|
5579
5784
|
InvitationsHandler,
|
|
5785
|
+
InvitationsManager,
|
|
5580
5786
|
InvitationsServiceImpl,
|
|
5581
5787
|
Lock,
|
|
5582
5788
|
ServiceContext,
|
|
@@ -5584,11 +5790,14 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5584
5790
|
SpaceInvitationProtocol,
|
|
5585
5791
|
SpacesServiceImpl,
|
|
5586
5792
|
TrustedKeySetAuthVerifier,
|
|
5793
|
+
createAdmissionKeypair,
|
|
5587
5794
|
createAuthProvider,
|
|
5795
|
+
createCollectDiagnosticsBroadcastHandler,
|
|
5796
|
+
createCollectDiagnosticsBroadcastSender,
|
|
5588
5797
|
createDiagnostics,
|
|
5798
|
+
createLevel,
|
|
5589
5799
|
createStorageObjects,
|
|
5590
5800
|
getNetworkPeers,
|
|
5591
|
-
invitationExpired,
|
|
5592
5801
|
isLocked,
|
|
5593
5802
|
subscribeToFeedBlocks,
|
|
5594
5803
|
subscribeToFeeds,
|
|
@@ -5598,4 +5807,4 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5598
5807
|
subscribeToSpaces,
|
|
5599
5808
|
subscribeToSwarmInfo
|
|
5600
5809
|
});
|
|
5601
|
-
//# sourceMappingURL=chunk-
|
|
5810
|
+
//# sourceMappingURL=chunk-3ILFTQW5.cjs.map
|