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