@dxos/client-services 0.4.10-main.d658471 → 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-MYKBSRL5.mjs → chunk-BASAWGAA.mjs} +1232 -972
- package/dist/lib/browser/chunk-BASAWGAA.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +13 -3
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +9 -4
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-UBE57IO7.cjs → chunk-4PLPSVK3.cjs} +1094 -917
- package/dist/lib/node/chunk-4PLPSVK3.cjs.map +7 -0
- package/dist/lib/node/index.cjs +49 -39
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +14 -9
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts +5 -0
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts +5 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts +15 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts.map +1 -0
- package/dist/types/src/packlets/{services → diagnostics}/diagnostics.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/index.d.ts +4 -0
- package/dist/types/src/packlets/diagnostics/index.d.ts.map +1 -0
- package/dist/types/src/packlets/indexing/util.d.ts +2 -1
- package/dist/types/src/packlets/indexing/util.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/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 +2 -0
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +5 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/util.d.ts +1 -0
- package/dist/types/src/packlets/services/util.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +3 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +35 -34
- package/src/index.ts +1 -0
- package/src/packlets/diagnostics/browser-diagnostics-broadcast.ts +94 -0
- package/src/packlets/diagnostics/diagnostics-broadcast.ts +20 -0
- package/src/packlets/diagnostics/diagnostics-collector.ts +65 -0
- package/src/packlets/{services → diagnostics}/diagnostics.ts +2 -2
- package/src/packlets/diagnostics/index.ts +7 -0
- package/src/packlets/indexing/util.ts +15 -8
- 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/services/automerge-host.test.ts +10 -4
- package/src/packlets/services/index.ts +1 -1
- package/src/packlets/services/service-context.test.ts +4 -1
- package/src/packlets/services/service-context.ts +16 -3
- package/src/packlets/services/service-host.ts +34 -19
- 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/storage/level.ts +1 -1
- package/src/packlets/system/system-service.ts +1 -1
- package/src/packlets/testing/test-builder.ts +20 -4
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-MYKBSRL5.mjs.map +0 -7
- package/dist/lib/node/chunk-UBE57IO7.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,12 +49,14 @@ __export(chunk_UBE57IO7_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,
|
|
51
57
|
createLevel: () => createLevel,
|
|
52
58
|
createStorageObjects: () => createStorageObjects,
|
|
53
59
|
getNetworkPeers: () => getNetworkPeers,
|
|
54
|
-
invitationExpired: () => invitationExpired,
|
|
55
60
|
isLocked: () => isLocked,
|
|
56
61
|
subscribeToFeedBlocks: () => subscribeToFeedBlocks,
|
|
57
62
|
subscribeToFeeds: () => subscribeToFeeds,
|
|
@@ -61,7 +66,7 @@ __export(chunk_UBE57IO7_exports, {
|
|
|
61
66
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
62
67
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
63
68
|
});
|
|
64
|
-
module.exports = __toCommonJS(
|
|
69
|
+
module.exports = __toCommonJS(chunk_4PLPSVK3_exports);
|
|
65
70
|
var import_async = require("@dxos/async");
|
|
66
71
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
67
72
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -116,6 +121,7 @@ var import_async7 = require("@dxos/async");
|
|
|
116
121
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
117
122
|
var import_context4 = require("@dxos/context");
|
|
118
123
|
var import_credentials7 = require("@dxos/credentials");
|
|
124
|
+
var import_crypto = require("@dxos/crypto");
|
|
119
125
|
var import_invariant5 = require("@dxos/invariant");
|
|
120
126
|
var import_keys5 = require("@dxos/keys");
|
|
121
127
|
var import_log4 = require("@dxos/log");
|
|
@@ -125,6 +131,7 @@ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
125
131
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
126
132
|
var import_async8 = require("@dxos/async");
|
|
127
133
|
var import_context5 = require("@dxos/context");
|
|
134
|
+
var import_crypto2 = require("@dxos/crypto");
|
|
128
135
|
var import_invariant6 = require("@dxos/invariant");
|
|
129
136
|
var import_keys6 = require("@dxos/keys");
|
|
130
137
|
var import_log5 = require("@dxos/log");
|
|
@@ -132,137 +139,142 @@ var import_protocols5 = require("@dxos/protocols");
|
|
|
132
139
|
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
133
140
|
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
134
141
|
var import_teleport = require("@dxos/teleport");
|
|
135
|
-
var import_async9 = require("@dxos/async");
|
|
136
142
|
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
137
|
-
var import_context6 = require("@dxos/context");
|
|
138
|
-
var import_invariant7 = require("@dxos/invariant");
|
|
139
|
-
var import_log6 = require("@dxos/log");
|
|
140
143
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
141
144
|
var import_credentials8 = require("@dxos/credentials");
|
|
142
145
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
143
|
-
var
|
|
144
|
-
var
|
|
146
|
+
var import_invariant7 = require("@dxos/invariant");
|
|
147
|
+
var import_log6 = require("@dxos/log");
|
|
145
148
|
var import_protocols6 = require("@dxos/protocols");
|
|
146
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");
|
|
147
154
|
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
148
155
|
var import_debug2 = require("@dxos/debug");
|
|
149
156
|
var import_rpc = require("@dxos/rpc");
|
|
150
157
|
var import_tracing3 = require("@dxos/tracing");
|
|
151
|
-
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
152
|
-
var import_credentials9 = require("@dxos/credentials");
|
|
153
|
-
var import_invariant9 = require("@dxos/invariant");
|
|
154
|
-
var import_protocols7 = require("@dxos/protocols");
|
|
155
|
-
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
156
|
-
var import_tracing4 = require("@dxos/tracing");
|
|
157
|
-
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
158
158
|
var import_async10 = require("@dxos/async");
|
|
159
159
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
160
|
-
var
|
|
160
|
+
var import_context6 = require("@dxos/context");
|
|
161
161
|
var import_debug3 = require("@dxos/debug");
|
|
162
|
-
var import_echo_db = require("@dxos/echo-db");
|
|
163
|
-
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
164
162
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
165
|
-
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");
|
|
166
166
|
var import_keys7 = require("@dxos/keys");
|
|
167
167
|
var import_log8 = require("@dxos/log");
|
|
168
|
-
var
|
|
169
|
-
var
|
|
170
|
-
var
|
|
168
|
+
var import_protocols7 = require("@dxos/protocols");
|
|
169
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
170
|
+
var import_credentials9 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
171
171
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
172
|
-
var
|
|
172
|
+
var import_tracing4 = require("@dxos/tracing");
|
|
173
173
|
var import_util4 = require("@dxos/util");
|
|
174
174
|
var import_async11 = require("@dxos/async");
|
|
175
|
-
var
|
|
175
|
+
var import_credentials10 = require("@dxos/credentials");
|
|
176
176
|
var import_async12 = require("@dxos/async");
|
|
177
|
-
var
|
|
178
|
-
var
|
|
177
|
+
var import_context7 = require("@dxos/context");
|
|
178
|
+
var import_invariant10 = require("@dxos/invariant");
|
|
179
179
|
var import_keys8 = require("@dxos/keys");
|
|
180
180
|
var import_log9 = require("@dxos/log");
|
|
181
|
-
var
|
|
181
|
+
var import_protocols8 = require("@dxos/protocols");
|
|
182
182
|
var import_teleport2 = require("@dxos/teleport");
|
|
183
183
|
var import_util5 = require("@dxos/util");
|
|
184
184
|
var import_async13 = require("@dxos/async");
|
|
185
|
-
var
|
|
186
|
-
var
|
|
187
|
-
var
|
|
185
|
+
var import_context8 = require("@dxos/context");
|
|
186
|
+
var import_credentials11 = require("@dxos/credentials");
|
|
187
|
+
var import_invariant11 = require("@dxos/invariant");
|
|
188
188
|
var import_keys9 = require("@dxos/keys");
|
|
189
189
|
var import_log10 = require("@dxos/log");
|
|
190
|
-
var
|
|
191
|
-
var
|
|
190
|
+
var import_protocols9 = require("@dxos/protocols");
|
|
191
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
192
192
|
var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
|
|
193
193
|
var import_util6 = require("@dxos/util");
|
|
194
|
-
var
|
|
194
|
+
var import_credentials12 = require("@dxos/credentials");
|
|
195
195
|
var import_debug4 = require("@dxos/debug");
|
|
196
|
-
var
|
|
196
|
+
var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
197
197
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
198
198
|
var import_async14 = require("@dxos/async");
|
|
199
|
-
var
|
|
199
|
+
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
200
200
|
var import_debug5 = require("@dxos/debug");
|
|
201
|
-
var
|
|
201
|
+
var import_invariant12 = require("@dxos/invariant");
|
|
202
202
|
var import_log11 = require("@dxos/log");
|
|
203
|
-
var
|
|
204
|
-
var
|
|
203
|
+
var import_protocols10 = require("@dxos/protocols");
|
|
204
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
205
205
|
var import_async15 = require("@dxos/async");
|
|
206
|
-
var
|
|
207
|
-
var
|
|
206
|
+
var import_context9 = require("@dxos/context");
|
|
207
|
+
var import_credentials14 = require("@dxos/credentials");
|
|
208
208
|
var import_debug6 = require("@dxos/debug");
|
|
209
|
-
var
|
|
209
|
+
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
210
210
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
211
211
|
var import_indexing = require("@dxos/indexing");
|
|
212
|
-
var
|
|
212
|
+
var import_invariant13 = require("@dxos/invariant");
|
|
213
213
|
var import_keyring = require("@dxos/keyring");
|
|
214
214
|
var import_keys10 = require("@dxos/keys");
|
|
215
215
|
var import_log12 = require("@dxos/log");
|
|
216
|
-
var
|
|
217
|
-
var
|
|
216
|
+
var import_protocols11 = require("@dxos/protocols");
|
|
217
|
+
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
218
218
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
219
|
-
var
|
|
219
|
+
var import_tracing5 = require("@dxos/tracing");
|
|
220
220
|
var import_util7 = require("@dxos/util");
|
|
221
221
|
var import_automerge = require("@dxos/automerge/automerge");
|
|
222
|
-
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");
|
|
223
226
|
var import_protocols13 = require("@dxos/protocols");
|
|
224
|
-
var
|
|
225
|
-
var
|
|
226
|
-
var
|
|
227
|
-
var
|
|
228
|
-
var
|
|
229
|
-
var
|
|
230
|
-
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
231
|
-
var import_config2 = require("@dxos/protocols/proto/dxos/config");
|
|
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");
|
|
232
233
|
var import_util8 = require("@dxos/util");
|
|
233
|
-
var import_level = require("level");
|
|
234
|
-
var import_node_path = __toESM(require("node:path"));
|
|
235
|
-
var import_keys11 = require("@dxos/keys");
|
|
236
234
|
var import_async16 = require("@dxos/async");
|
|
237
|
-
var
|
|
238
|
-
var
|
|
239
|
-
var
|
|
240
|
-
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");
|
|
241
239
|
var import_indexing2 = require("@dxos/indexing");
|
|
242
|
-
var
|
|
243
|
-
var
|
|
244
|
-
var
|
|
240
|
+
var import_invariant15 = require("@dxos/invariant");
|
|
241
|
+
var import_keys11 = require("@dxos/keys");
|
|
242
|
+
var import_log13 = require("@dxos/log");
|
|
245
243
|
var import_messaging = require("@dxos/messaging");
|
|
246
244
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
247
|
-
var
|
|
248
|
-
var
|
|
249
|
-
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");
|
|
250
248
|
var import_util9 = require("@dxos/util");
|
|
251
249
|
var import_websocket_rpc = require("@dxos/websocket-rpc");
|
|
252
250
|
var import_async17 = require("@dxos/async");
|
|
253
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");
|
|
254
254
|
var import_invariant17 = require("@dxos/invariant");
|
|
255
|
-
var
|
|
255
|
+
var import_lock_file = require("@dxos/lock-file");
|
|
256
|
+
var import_log14 = require("@dxos/log");
|
|
256
257
|
var import_async18 = require("@dxos/async");
|
|
257
258
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
258
|
-
var
|
|
259
|
+
var import_keys12 = require("@dxos/keys");
|
|
259
260
|
var import_log15 = require("@dxos/log");
|
|
260
|
-
var
|
|
261
|
+
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
261
262
|
var import_util10 = require("@dxos/util");
|
|
262
263
|
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
263
|
-
var
|
|
264
|
-
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");
|
|
265
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");
|
|
266
278
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
267
279
|
return new import_codec_protobuf.Stream(({ next }) => {
|
|
268
280
|
const subscriptions = new import_async.EventSubscriptions();
|
|
@@ -1475,6 +1487,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1475
1487
|
this._callbacks = _callbacks;
|
|
1476
1488
|
this._ctx = new import_context5.Context();
|
|
1477
1489
|
this._remoteOptionsTrigger = new import_async8.Trigger();
|
|
1490
|
+
this._challenge = void 0;
|
|
1478
1491
|
this.invitation = void 0;
|
|
1479
1492
|
this.guestProfile = void 0;
|
|
1480
1493
|
this.authenticationPassed = false;
|
|
@@ -1489,7 +1502,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1489
1502
|
options: async (options) => {
|
|
1490
1503
|
(0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1491
1504
|
F: __dxlog_file6,
|
|
1492
|
-
L:
|
|
1505
|
+
L: 90,
|
|
1493
1506
|
S: this,
|
|
1494
1507
|
A: [
|
|
1495
1508
|
"!this._remoteOptions",
|
|
@@ -1506,7 +1519,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1506
1519
|
id: traceId
|
|
1507
1520
|
}), {
|
|
1508
1521
|
F: __dxlog_file6,
|
|
1509
|
-
L:
|
|
1522
|
+
L: 99,
|
|
1510
1523
|
S: this,
|
|
1511
1524
|
C: (f, a) => f(...a)
|
|
1512
1525
|
});
|
|
@@ -1516,7 +1529,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1516
1529
|
invitationId
|
|
1517
1530
|
}, {
|
|
1518
1531
|
F: __dxlog_file6,
|
|
1519
|
-
L:
|
|
1532
|
+
L: 103,
|
|
1520
1533
|
S: this,
|
|
1521
1534
|
C: (f, a) => f(...a)
|
|
1522
1535
|
});
|
|
@@ -1530,7 +1543,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1530
1543
|
guestProfile: profile
|
|
1531
1544
|
}, {
|
|
1532
1545
|
F: __dxlog_file6,
|
|
1533
|
-
L:
|
|
1546
|
+
L: 112,
|
|
1534
1547
|
S: this,
|
|
1535
1548
|
C: (f, a) => f(...a)
|
|
1536
1549
|
});
|
|
@@ -1539,25 +1552,27 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1539
1552
|
...this.invitation,
|
|
1540
1553
|
state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1541
1554
|
});
|
|
1555
|
+
this._challenge = this.invitation.authMethod === import_services4.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto2.randomBytes)(32) : void 0;
|
|
1542
1556
|
import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols5.trace.end({
|
|
1543
1557
|
id: traceId
|
|
1544
1558
|
}), {
|
|
1545
1559
|
F: __dxlog_file6,
|
|
1546
|
-
L:
|
|
1560
|
+
L: 122,
|
|
1547
1561
|
S: this,
|
|
1548
1562
|
C: (f, a) => f(...a)
|
|
1549
1563
|
});
|
|
1550
1564
|
return {
|
|
1551
|
-
authMethod: this.invitation.authMethod
|
|
1565
|
+
authMethod: this.invitation.authMethod,
|
|
1566
|
+
challenge: this._challenge
|
|
1552
1567
|
};
|
|
1553
1568
|
},
|
|
1554
|
-
authenticate: async ({ authCode: code }) => {
|
|
1569
|
+
authenticate: async ({ authCode: code, signedChallenge }) => {
|
|
1555
1570
|
const traceId = import_keys6.PublicKey.random().toHex();
|
|
1556
1571
|
import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols5.trace.begin({
|
|
1557
1572
|
id: traceId
|
|
1558
1573
|
}), {
|
|
1559
1574
|
F: __dxlog_file6,
|
|
1560
|
-
L:
|
|
1575
|
+
L: 131,
|
|
1561
1576
|
S: this,
|
|
1562
1577
|
C: (f, a) => f(...a)
|
|
1563
1578
|
});
|
|
@@ -1565,14 +1580,14 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1565
1580
|
authCode: code
|
|
1566
1581
|
}, {
|
|
1567
1582
|
F: __dxlog_file6,
|
|
1568
|
-
L:
|
|
1583
|
+
L: 132,
|
|
1569
1584
|
S: this,
|
|
1570
1585
|
C: (f, a) => f(...a)
|
|
1571
1586
|
});
|
|
1572
1587
|
let status = import_invitations2.AuthenticationResponse.Status.OK;
|
|
1573
1588
|
(0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
|
|
1574
1589
|
F: __dxlog_file6,
|
|
1575
|
-
L:
|
|
1590
|
+
L: 135,
|
|
1576
1591
|
S: this,
|
|
1577
1592
|
A: [
|
|
1578
1593
|
"this.invitation",
|
|
@@ -1583,7 +1598,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1583
1598
|
case import_services4.Invitation.AuthMethod.NONE: {
|
|
1584
1599
|
(0, import_log5.log)("authentication not required", void 0, {
|
|
1585
1600
|
F: __dxlog_file6,
|
|
1586
|
-
L:
|
|
1601
|
+
L: 138,
|
|
1587
1602
|
S: this,
|
|
1588
1603
|
C: (f, a) => f(...a)
|
|
1589
1604
|
});
|
|
@@ -1603,12 +1618,25 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1603
1618
|
}
|
|
1604
1619
|
break;
|
|
1605
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
|
+
}
|
|
1606
1634
|
default: {
|
|
1607
1635
|
import_log5.log.error("invalid authentication method", {
|
|
1608
1636
|
authMethod: this.invitation.authMethod
|
|
1609
1637
|
}, {
|
|
1610
1638
|
F: __dxlog_file6,
|
|
1611
|
-
L:
|
|
1639
|
+
L: 176,
|
|
1612
1640
|
S: this,
|
|
1613
1641
|
C: (f, a) => f(...a)
|
|
1614
1642
|
});
|
|
@@ -1623,7 +1651,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1623
1651
|
}
|
|
1624
1652
|
}), {
|
|
1625
1653
|
F: __dxlog_file6,
|
|
1626
|
-
L:
|
|
1654
|
+
L: 182,
|
|
1627
1655
|
S: this,
|
|
1628
1656
|
C: (f, a) => f(...a)
|
|
1629
1657
|
});
|
|
@@ -1637,14 +1665,14 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1637
1665
|
id: traceId
|
|
1638
1666
|
}), {
|
|
1639
1667
|
F: __dxlog_file6,
|
|
1640
|
-
L:
|
|
1668
|
+
L: 188,
|
|
1641
1669
|
S: this,
|
|
1642
1670
|
C: (f, a) => f(...a)
|
|
1643
1671
|
});
|
|
1644
1672
|
try {
|
|
1645
1673
|
(0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
|
|
1646
1674
|
F: __dxlog_file6,
|
|
1647
|
-
L:
|
|
1675
|
+
L: 191,
|
|
1648
1676
|
S: this,
|
|
1649
1677
|
A: [
|
|
1650
1678
|
"this.invitation",
|
|
@@ -1659,7 +1687,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1659
1687
|
id: traceId
|
|
1660
1688
|
}), {
|
|
1661
1689
|
F: __dxlog_file6,
|
|
1662
|
-
L:
|
|
1690
|
+
L: 199,
|
|
1663
1691
|
S: this,
|
|
1664
1692
|
C: (f, a) => f(...a)
|
|
1665
1693
|
});
|
|
@@ -1716,7 +1744,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1716
1744
|
options: async (options) => {
|
|
1717
1745
|
(0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1718
1746
|
F: __dxlog_file6,
|
|
1719
|
-
L:
|
|
1747
|
+
L: 266,
|
|
1720
1748
|
S: this,
|
|
1721
1749
|
A: [
|
|
1722
1750
|
"!this._remoteOptions",
|
|
@@ -1743,7 +1771,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1743
1771
|
try {
|
|
1744
1772
|
(0, import_log5.log)("begin options", void 0, {
|
|
1745
1773
|
F: __dxlog_file6,
|
|
1746
|
-
L:
|
|
1774
|
+
L: 287,
|
|
1747
1775
|
S: this,
|
|
1748
1776
|
C: (f, a) => f(...a)
|
|
1749
1777
|
});
|
|
@@ -1755,7 +1783,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1755
1783
|
}));
|
|
1756
1784
|
(0, import_log5.log)("end options", void 0, {
|
|
1757
1785
|
F: __dxlog_file6,
|
|
1758
|
-
L:
|
|
1786
|
+
L: 290,
|
|
1759
1787
|
S: this,
|
|
1760
1788
|
C: (f, a) => f(...a)
|
|
1761
1789
|
});
|
|
@@ -1769,7 +1797,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1769
1797
|
} catch (err) {
|
|
1770
1798
|
(0, import_log5.log)("openError", err, {
|
|
1771
1799
|
F: __dxlog_file6,
|
|
1772
|
-
L:
|
|
1800
|
+
L: 300,
|
|
1773
1801
|
S: this,
|
|
1774
1802
|
C: (f, a) => f(...a)
|
|
1775
1803
|
});
|
|
@@ -1779,7 +1807,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1779
1807
|
async onClose() {
|
|
1780
1808
|
(0, import_log5.log)("onClose", void 0, {
|
|
1781
1809
|
F: __dxlog_file6,
|
|
1782
|
-
L:
|
|
1810
|
+
L: 306,
|
|
1783
1811
|
S: this,
|
|
1784
1812
|
C: (f, a) => f(...a)
|
|
1785
1813
|
});
|
|
@@ -1796,11 +1824,11 @@ var InvitationsHandler = class {
|
|
|
1796
1824
|
this._networkManager = _networkManager;
|
|
1797
1825
|
}
|
|
1798
1826
|
createInvitation(protocol, options) {
|
|
1799
|
-
const { invitationId = import_keys5.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys5.PublicKey.random(), persistent =
|
|
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 ?? {};
|
|
1800
1828
|
const authCode = options?.authCode ?? (authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1801
1829
|
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
1802
1830
|
F: __dxlog_file7,
|
|
1803
|
-
L:
|
|
1831
|
+
L: 87,
|
|
1804
1832
|
S: this,
|
|
1805
1833
|
A: [
|
|
1806
1834
|
"protocol",
|
|
@@ -1815,9 +1843,11 @@ var InvitationsHandler = class {
|
|
|
1815
1843
|
swarmKey,
|
|
1816
1844
|
authCode,
|
|
1817
1845
|
timeout,
|
|
1818
|
-
persistent,
|
|
1846
|
+
persistent: persistent && type !== import_services3.Invitation.Type.DELEGATED,
|
|
1847
|
+
guestKeypair: guestKeypair ?? (authMethod === import_services3.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
|
|
1819
1848
|
created,
|
|
1820
1849
|
lifetime,
|
|
1850
|
+
multiUse,
|
|
1821
1851
|
...protocol.getInvitationContext()
|
|
1822
1852
|
};
|
|
1823
1853
|
const stream = new import_async7.PushStream();
|
|
@@ -1832,7 +1862,7 @@ var InvitationsHandler = class {
|
|
|
1832
1862
|
...protocol.toJSON()
|
|
1833
1863
|
}, {
|
|
1834
1864
|
F: __dxlog_file7,
|
|
1835
|
-
L:
|
|
1865
|
+
L: 115,
|
|
1836
1866
|
S: this,
|
|
1837
1867
|
C: (f, a) => f(...a)
|
|
1838
1868
|
});
|
|
@@ -1857,7 +1887,7 @@ var InvitationsHandler = class {
|
|
|
1857
1887
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1858
1888
|
(0, import_invariant5.invariant)(deviceKey, void 0, {
|
|
1859
1889
|
F: __dxlog_file7,
|
|
1860
|
-
L:
|
|
1890
|
+
L: 136,
|
|
1861
1891
|
S: this,
|
|
1862
1892
|
A: [
|
|
1863
1893
|
"deviceKey",
|
|
@@ -1880,7 +1910,7 @@ var InvitationsHandler = class {
|
|
|
1880
1910
|
id: traceId
|
|
1881
1911
|
}), {
|
|
1882
1912
|
F: __dxlog_file7,
|
|
1883
|
-
L:
|
|
1913
|
+
L: 154,
|
|
1884
1914
|
S: this,
|
|
1885
1915
|
C: (f, a) => f(...a)
|
|
1886
1916
|
});
|
|
@@ -1888,7 +1918,7 @@ var InvitationsHandler = class {
|
|
|
1888
1918
|
...protocol.toJSON()
|
|
1889
1919
|
}, {
|
|
1890
1920
|
F: __dxlog_file7,
|
|
1891
|
-
L:
|
|
1921
|
+
L: 155,
|
|
1892
1922
|
S: this,
|
|
1893
1923
|
C: (f, a) => f(...a)
|
|
1894
1924
|
});
|
|
@@ -1904,7 +1934,7 @@ var InvitationsHandler = class {
|
|
|
1904
1934
|
...protocol.toJSON()
|
|
1905
1935
|
}, {
|
|
1906
1936
|
F: __dxlog_file7,
|
|
1907
|
-
L:
|
|
1937
|
+
L: 158,
|
|
1908
1938
|
S: this,
|
|
1909
1939
|
C: (f, a) => f(...a)
|
|
1910
1940
|
});
|
|
@@ -1916,7 +1946,7 @@ var InvitationsHandler = class {
|
|
|
1916
1946
|
id: traceId
|
|
1917
1947
|
}), {
|
|
1918
1948
|
F: __dxlog_file7,
|
|
1919
|
-
L:
|
|
1949
|
+
L: 160,
|
|
1920
1950
|
S: this,
|
|
1921
1951
|
C: (f, a) => f(...a)
|
|
1922
1952
|
});
|
|
@@ -1926,7 +1956,7 @@ var InvitationsHandler = class {
|
|
|
1926
1956
|
...protocol.toJSON()
|
|
1927
1957
|
}, {
|
|
1928
1958
|
F: __dxlog_file7,
|
|
1929
|
-
L:
|
|
1959
|
+
L: 163,
|
|
1930
1960
|
S: this,
|
|
1931
1961
|
C: (f, a) => f(...a)
|
|
1932
1962
|
});
|
|
@@ -1937,7 +1967,7 @@ var InvitationsHandler = class {
|
|
|
1937
1967
|
} else {
|
|
1938
1968
|
import_log4.log.error("failed", err, {
|
|
1939
1969
|
F: __dxlog_file7,
|
|
1940
|
-
L:
|
|
1970
|
+
L: 166,
|
|
1941
1971
|
S: this,
|
|
1942
1972
|
C: (f, a) => f(...a)
|
|
1943
1973
|
});
|
|
@@ -1948,12 +1978,12 @@ var InvitationsHandler = class {
|
|
|
1948
1978
|
error: err
|
|
1949
1979
|
}), {
|
|
1950
1980
|
F: __dxlog_file7,
|
|
1951
|
-
L:
|
|
1981
|
+
L: 169,
|
|
1952
1982
|
S: this,
|
|
1953
1983
|
C: (f, a) => f(...a)
|
|
1954
1984
|
});
|
|
1955
1985
|
} finally {
|
|
1956
|
-
if (
|
|
1986
|
+
if (!multiUse) {
|
|
1957
1987
|
await swarmConnection.close();
|
|
1958
1988
|
await ctx.dispose();
|
|
1959
1989
|
}
|
|
@@ -1969,7 +1999,7 @@ var InvitationsHandler = class {
|
|
|
1969
1999
|
...protocol.toJSON()
|
|
1970
2000
|
}, {
|
|
1971
2001
|
F: __dxlog_file7,
|
|
1972
|
-
L:
|
|
2002
|
+
L: 184,
|
|
1973
2003
|
S: this,
|
|
1974
2004
|
C: (f, a) => f(...a)
|
|
1975
2005
|
});
|
|
@@ -1980,7 +2010,7 @@ var InvitationsHandler = class {
|
|
|
1980
2010
|
} else {
|
|
1981
2011
|
import_log4.log.error("failed", err, {
|
|
1982
2012
|
F: __dxlog_file7,
|
|
1983
|
-
L:
|
|
2013
|
+
L: 187,
|
|
1984
2014
|
S: this,
|
|
1985
2015
|
C: (f, a) => f(...a)
|
|
1986
2016
|
});
|
|
@@ -1990,11 +2020,11 @@ var InvitationsHandler = class {
|
|
|
1990
2020
|
});
|
|
1991
2021
|
return extension;
|
|
1992
2022
|
};
|
|
1993
|
-
if (invitation.lifetime && invitation.created
|
|
2023
|
+
if (invitation.lifetime && invitation.created) {
|
|
1994
2024
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
1995
2025
|
import_log4.log.warn("invitation has already expired", void 0, {
|
|
1996
2026
|
F: __dxlog_file7,
|
|
1997
|
-
L:
|
|
2027
|
+
L: 198,
|
|
1998
2028
|
S: this,
|
|
1999
2029
|
C: (f, a) => f(...a)
|
|
2000
2030
|
});
|
|
@@ -2045,7 +2075,7 @@ var InvitationsHandler = class {
|
|
|
2045
2075
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
2046
2076
|
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
2047
2077
|
F: __dxlog_file7,
|
|
2048
|
-
L:
|
|
2078
|
+
L: 252,
|
|
2049
2079
|
S: this,
|
|
2050
2080
|
A: [
|
|
2051
2081
|
"protocol",
|
|
@@ -2055,7 +2085,7 @@ var InvitationsHandler = class {
|
|
|
2055
2085
|
if (deviceProfile) {
|
|
2056
2086
|
(0, import_invariant5.invariant)(invitation.kind === import_services3.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2057
2087
|
F: __dxlog_file7,
|
|
2058
|
-
L:
|
|
2088
|
+
L: 255,
|
|
2059
2089
|
S: this,
|
|
2060
2090
|
A: [
|
|
2061
2091
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -2070,7 +2100,7 @@ var InvitationsHandler = class {
|
|
|
2070
2100
|
const setState = (newData) => {
|
|
2071
2101
|
(0, import_invariant5.invariant)(newData.state !== void 0, void 0, {
|
|
2072
2102
|
F: __dxlog_file7,
|
|
2073
|
-
L:
|
|
2103
|
+
L: 266,
|
|
2074
2104
|
S: this,
|
|
2075
2105
|
A: [
|
|
2076
2106
|
"newData.state !== undefined",
|
|
@@ -2090,7 +2120,7 @@ var InvitationsHandler = class {
|
|
|
2090
2120
|
...protocol.toJSON()
|
|
2091
2121
|
}, {
|
|
2092
2122
|
F: __dxlog_file7,
|
|
2093
|
-
L:
|
|
2123
|
+
L: 274,
|
|
2094
2124
|
S: this,
|
|
2095
2125
|
C: (f, a) => f(...a)
|
|
2096
2126
|
});
|
|
@@ -2100,7 +2130,7 @@ var InvitationsHandler = class {
|
|
|
2100
2130
|
} else {
|
|
2101
2131
|
import_log4.log.warn("auth failed", err, {
|
|
2102
2132
|
F: __dxlog_file7,
|
|
2103
|
-
L:
|
|
2133
|
+
L: 277,
|
|
2104
2134
|
S: this,
|
|
2105
2135
|
C: (f, a) => f(...a)
|
|
2106
2136
|
});
|
|
@@ -2114,7 +2144,7 @@ var InvitationsHandler = class {
|
|
|
2114
2144
|
...protocol.toJSON()
|
|
2115
2145
|
}, {
|
|
2116
2146
|
F: __dxlog_file7,
|
|
2117
|
-
L:
|
|
2147
|
+
L: 285,
|
|
2118
2148
|
S: this,
|
|
2119
2149
|
C: (f, a) => f(...a)
|
|
2120
2150
|
});
|
|
@@ -2129,7 +2159,7 @@ var InvitationsHandler = class {
|
|
|
2129
2159
|
currentState
|
|
2130
2160
|
}, {
|
|
2131
2161
|
F: __dxlog_file7,
|
|
2132
|
-
L:
|
|
2162
|
+
L: 295,
|
|
2133
2163
|
S: this,
|
|
2134
2164
|
C: (f, a) => f(...a)
|
|
2135
2165
|
});
|
|
@@ -2144,7 +2174,7 @@ var InvitationsHandler = class {
|
|
|
2144
2174
|
id: traceId
|
|
2145
2175
|
}), {
|
|
2146
2176
|
F: __dxlog_file7,
|
|
2147
|
-
L:
|
|
2177
|
+
L: 304,
|
|
2148
2178
|
S: this,
|
|
2149
2179
|
C: (f, a) => f(...a)
|
|
2150
2180
|
});
|
|
@@ -2156,7 +2186,7 @@ var InvitationsHandler = class {
|
|
|
2156
2186
|
...protocol.toJSON()
|
|
2157
2187
|
}, {
|
|
2158
2188
|
F: __dxlog_file7,
|
|
2159
|
-
L:
|
|
2189
|
+
L: 312,
|
|
2160
2190
|
S: this,
|
|
2161
2191
|
C: (f, a) => f(...a)
|
|
2162
2192
|
});
|
|
@@ -2167,7 +2197,7 @@ var InvitationsHandler = class {
|
|
|
2167
2197
|
...protocol.toJSON()
|
|
2168
2198
|
}, {
|
|
2169
2199
|
F: __dxlog_file7,
|
|
2170
|
-
L:
|
|
2200
|
+
L: 316,
|
|
2171
2201
|
S: this,
|
|
2172
2202
|
C: (f, a) => f(...a)
|
|
2173
2203
|
});
|
|
@@ -2177,62 +2207,28 @@ var InvitationsHandler = class {
|
|
|
2177
2207
|
response: introductionResponse
|
|
2178
2208
|
}, {
|
|
2179
2209
|
F: __dxlog_file7,
|
|
2180
|
-
L:
|
|
2210
|
+
L: 320,
|
|
2181
2211
|
S: this,
|
|
2182
2212
|
C: (f, a) => f(...a)
|
|
2183
2213
|
});
|
|
2184
2214
|
invitation.authMethod = introductionResponse.authMethod;
|
|
2185
2215
|
if (isAuthenticationRequired(invitation)) {
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
2195
|
-
});
|
|
2196
|
-
const authCode = await authenticated.wait({
|
|
2197
|
-
timeout
|
|
2198
|
-
});
|
|
2199
|
-
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2200
|
-
F: __dxlog_file7,
|
|
2201
|
-
L: 325,
|
|
2202
|
-
S: this,
|
|
2203
|
-
C: (f, a) => f(...a)
|
|
2204
|
-
});
|
|
2205
|
-
setState({
|
|
2206
|
-
state: import_services3.Invitation.State.AUTHENTICATING
|
|
2207
|
-
});
|
|
2208
|
-
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2209
|
-
authCode
|
|
2210
|
-
});
|
|
2211
|
-
if (response.status === void 0 || response.status === import_invitations.AuthenticationResponse.Status.OK) {
|
|
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);
|
|
2212
2224
|
break;
|
|
2213
|
-
}
|
|
2214
|
-
if (response.status === import_invitations.AuthenticationResponse.Status.INVALID_OTP) {
|
|
2215
|
-
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2216
|
-
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2217
|
-
} else {
|
|
2218
|
-
(0, import_log4.log)("retrying invalid code", {
|
|
2219
|
-
attempt
|
|
2220
|
-
}, {
|
|
2221
|
-
F: __dxlog_file7,
|
|
2222
|
-
L: 336,
|
|
2223
|
-
S: this,
|
|
2224
|
-
C: (f, a) => f(...a)
|
|
2225
|
-
});
|
|
2226
|
-
authenticated.reset();
|
|
2227
|
-
}
|
|
2228
|
-
}
|
|
2229
2225
|
}
|
|
2230
2226
|
}
|
|
2231
2227
|
(0, import_log4.log)("request admission", {
|
|
2232
2228
|
...protocol.toJSON()
|
|
2233
2229
|
}, {
|
|
2234
2230
|
F: __dxlog_file7,
|
|
2235
|
-
L:
|
|
2231
|
+
L: 336,
|
|
2236
2232
|
S: this,
|
|
2237
2233
|
C: (f, a) => f(...a)
|
|
2238
2234
|
});
|
|
@@ -2244,7 +2240,7 @@ var InvitationsHandler = class {
|
|
|
2244
2240
|
...protocol.toJSON()
|
|
2245
2241
|
}, {
|
|
2246
2242
|
F: __dxlog_file7,
|
|
2247
|
-
L:
|
|
2243
|
+
L: 347,
|
|
2248
2244
|
S: this,
|
|
2249
2245
|
C: (f, a) => f(...a)
|
|
2250
2246
|
});
|
|
@@ -2257,7 +2253,7 @@ var InvitationsHandler = class {
|
|
|
2257
2253
|
id: traceId
|
|
2258
2254
|
}), {
|
|
2259
2255
|
F: __dxlog_file7,
|
|
2260
|
-
L:
|
|
2256
|
+
L: 349,
|
|
2261
2257
|
S: this,
|
|
2262
2258
|
C: (f, a) => f(...a)
|
|
2263
2259
|
});
|
|
@@ -2267,7 +2263,7 @@ var InvitationsHandler = class {
|
|
|
2267
2263
|
...protocol.toJSON()
|
|
2268
2264
|
}, {
|
|
2269
2265
|
F: __dxlog_file7,
|
|
2270
|
-
L:
|
|
2266
|
+
L: 352,
|
|
2271
2267
|
S: this,
|
|
2272
2268
|
C: (f, a) => f(...a)
|
|
2273
2269
|
});
|
|
@@ -2277,7 +2273,7 @@ var InvitationsHandler = class {
|
|
|
2277
2273
|
} else {
|
|
2278
2274
|
(0, import_log4.log)("auth failed", err, {
|
|
2279
2275
|
F: __dxlog_file7,
|
|
2280
|
-
L:
|
|
2276
|
+
L: 355,
|
|
2281
2277
|
S: this,
|
|
2282
2278
|
C: (f, a) => f(...a)
|
|
2283
2279
|
});
|
|
@@ -2288,7 +2284,7 @@ var InvitationsHandler = class {
|
|
|
2288
2284
|
error: err
|
|
2289
2285
|
}), {
|
|
2290
2286
|
F: __dxlog_file7,
|
|
2291
|
-
L:
|
|
2287
|
+
L: 358,
|
|
2292
2288
|
S: this,
|
|
2293
2289
|
C: (f, a) => f(...a)
|
|
2294
2290
|
});
|
|
@@ -2306,7 +2302,7 @@ var InvitationsHandler = class {
|
|
|
2306
2302
|
...protocol.toJSON()
|
|
2307
2303
|
}, {
|
|
2308
2304
|
F: __dxlog_file7,
|
|
2309
|
-
L:
|
|
2305
|
+
L: 369,
|
|
2310
2306
|
S: this,
|
|
2311
2307
|
C: (f, a) => f(...a)
|
|
2312
2308
|
});
|
|
@@ -2316,7 +2312,7 @@ var InvitationsHandler = class {
|
|
|
2316
2312
|
} else {
|
|
2317
2313
|
(0, import_log4.log)("auth failed", err, {
|
|
2318
2314
|
F: __dxlog_file7,
|
|
2319
|
-
L:
|
|
2315
|
+
L: 372,
|
|
2320
2316
|
S: this,
|
|
2321
2317
|
C: (f, a) => f(...a)
|
|
2322
2318
|
});
|
|
@@ -2333,7 +2329,7 @@ var InvitationsHandler = class {
|
|
|
2333
2329
|
} else {
|
|
2334
2330
|
(0, import_invariant5.invariant)(invitation.swarmKey, void 0, {
|
|
2335
2331
|
F: __dxlog_file7,
|
|
2336
|
-
L:
|
|
2332
|
+
L: 386,
|
|
2337
2333
|
S: this,
|
|
2338
2334
|
A: [
|
|
2339
2335
|
"invitation.swarmKey",
|
|
@@ -2371,198 +2367,111 @@ var InvitationsHandler = class {
|
|
|
2371
2367
|
});
|
|
2372
2368
|
return observable;
|
|
2373
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
|
+
}
|
|
2374
2438
|
};
|
|
2375
|
-
var
|
|
2376
|
-
|
|
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
|
+
};
|
|
2377
2445
|
};
|
|
2378
|
-
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
2379
2446
|
var InvitationsServiceImpl = class {
|
|
2380
|
-
constructor(
|
|
2381
|
-
this.
|
|
2382
|
-
this._getHandler = _getHandler;
|
|
2383
|
-
this._metadataStore = _metadataStore;
|
|
2384
|
-
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2385
|
-
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2386
|
-
this._invitationCreated = new import_async9.Event();
|
|
2387
|
-
this._invitationAccepted = new import_async9.Event();
|
|
2388
|
-
this._removedCreated = new import_async9.Event();
|
|
2389
|
-
this._removedAccepted = new import_async9.Event();
|
|
2390
|
-
this._saved = new import_async9.Event();
|
|
2391
|
-
this._persistentInvitationsLoadedEvent = new import_async9.Event();
|
|
2392
|
-
this._persistentInvitationsLoaded = false;
|
|
2447
|
+
constructor(_invitationsManager) {
|
|
2448
|
+
this._invitationsManager = _invitationsManager;
|
|
2393
2449
|
}
|
|
2394
2450
|
// TODO(burdon): Guest/host label.
|
|
2395
2451
|
getLoggingContext() {
|
|
2396
2452
|
return {};
|
|
2397
2453
|
}
|
|
2398
2454
|
createInvitation(options) {
|
|
2399
|
-
|
|
2400
|
-
const savePersistentInvitationCtx = new import_context6.Context();
|
|
2401
|
-
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2402
|
-
if (existingInvitation) {
|
|
2403
|
-
invitation = existingInvitation;
|
|
2404
|
-
} else {
|
|
2405
|
-
const handler = this._getHandler(options);
|
|
2406
|
-
invitation = this._invitationsHandler.createInvitation(handler, options);
|
|
2407
|
-
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2408
|
-
this._invitationCreated.emit(invitation.get());
|
|
2409
|
-
}
|
|
2455
|
+
const invitation = this._invitationsManager.createInvitation(options);
|
|
2410
2456
|
return new import_codec_protobuf8.Stream(({ next, close }) => {
|
|
2411
|
-
|
|
2412
|
-
(0, import_async9.scheduleTask)(savePersistentInvitationCtx, async () => {
|
|
2413
|
-
try {
|
|
2414
|
-
await this._metadataStore.addInvitation(invitation.get());
|
|
2415
|
-
this._saved.emit(invitation.get());
|
|
2416
|
-
} catch (err) {
|
|
2417
|
-
close(err);
|
|
2418
|
-
}
|
|
2419
|
-
});
|
|
2420
|
-
}
|
|
2421
|
-
invitation.subscribe((invitation2) => {
|
|
2422
|
-
next(invitation2);
|
|
2423
|
-
}, async (err) => {
|
|
2424
|
-
await savePersistentInvitationCtx.dispose();
|
|
2425
|
-
close(err);
|
|
2426
|
-
}, async () => {
|
|
2427
|
-
close();
|
|
2428
|
-
if (invitation.get().persistent) {
|
|
2429
|
-
await savePersistentInvitationCtx.dispose();
|
|
2430
|
-
await this._metadataStore.removeInvitation(invitation.get().invitationId);
|
|
2431
|
-
}
|
|
2432
|
-
this._createInvitations.delete(invitation.get().invitationId);
|
|
2433
|
-
if (invitation.get().type !== import_services5.Invitation.Type.MULTIUSE) {
|
|
2434
|
-
this._removedCreated.emit(invitation.get());
|
|
2435
|
-
}
|
|
2436
|
-
});
|
|
2457
|
+
invitation.subscribe(next, close, close);
|
|
2437
2458
|
});
|
|
2438
2459
|
}
|
|
2439
|
-
|
|
2440
|
-
const
|
|
2441
|
-
const freshInvitations = persistentInvitations.filter(async (invitation) => !invitationExpired(invitation));
|
|
2442
|
-
const cInvitations = freshInvitations.map((persistentInvitation) => {
|
|
2443
|
-
(0, import_invariant7.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2444
|
-
F: __dxlog_file8,
|
|
2445
|
-
L: 109,
|
|
2446
|
-
S: this,
|
|
2447
|
-
A: [
|
|
2448
|
-
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2449
|
-
"'invitation already exists'"
|
|
2450
|
-
]
|
|
2451
|
-
});
|
|
2452
|
-
const handler = this._getHandler(persistentInvitation);
|
|
2453
|
-
const invitation = this._invitationsHandler.createInvitation(handler, persistentInvitation);
|
|
2454
|
-
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2455
|
-
this._invitationCreated.emit(invitation.get());
|
|
2456
|
-
return persistentInvitation;
|
|
2457
|
-
});
|
|
2458
|
-
this._persistentInvitationsLoadedEvent.emit();
|
|
2459
|
-
this._persistentInvitationsLoaded = true;
|
|
2460
|
-
return {
|
|
2461
|
-
invitations: cInvitations
|
|
2462
|
-
};
|
|
2463
|
-
}
|
|
2464
|
-
acceptInvitation({ invitation: options, deviceProfile }) {
|
|
2465
|
-
let invitation;
|
|
2466
|
-
if (deviceProfile) {
|
|
2467
|
-
(0, import_invariant7.invariant)(options.kind === import_services5.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2468
|
-
F: __dxlog_file8,
|
|
2469
|
-
L: 127,
|
|
2470
|
-
S: this,
|
|
2471
|
-
A: [
|
|
2472
|
-
"options.kind === Invitation.Kind.DEVICE",
|
|
2473
|
-
"'deviceProfile provided for non-device invitation'"
|
|
2474
|
-
]
|
|
2475
|
-
});
|
|
2476
|
-
}
|
|
2477
|
-
const existingInvitation = this._acceptInvitations.get(options.invitationId);
|
|
2478
|
-
if (existingInvitation) {
|
|
2479
|
-
invitation = existingInvitation;
|
|
2480
|
-
} else {
|
|
2481
|
-
const handler = this._getHandler(options);
|
|
2482
|
-
invitation = this._invitationsHandler.acceptInvitation(handler, options, deviceProfile);
|
|
2483
|
-
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
2484
|
-
this._invitationAccepted.emit(invitation.get());
|
|
2485
|
-
}
|
|
2460
|
+
acceptInvitation(request) {
|
|
2461
|
+
const invitation = this._invitationsManager.acceptInvitation(request);
|
|
2486
2462
|
return new import_codec_protobuf8.Stream(({ next, close }) => {
|
|
2487
|
-
invitation.subscribe(
|
|
2488
|
-
next(invitation2);
|
|
2489
|
-
}, (err) => {
|
|
2490
|
-
close(err);
|
|
2491
|
-
}, () => {
|
|
2492
|
-
close();
|
|
2493
|
-
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2494
|
-
if (invitation.get().type !== import_services5.Invitation.Type.MULTIUSE) {
|
|
2495
|
-
this._removedAccepted.emit(invitation.get());
|
|
2496
|
-
}
|
|
2497
|
-
});
|
|
2463
|
+
invitation.subscribe(next, close, close);
|
|
2498
2464
|
});
|
|
2499
2465
|
}
|
|
2500
|
-
async authenticate(
|
|
2501
|
-
|
|
2502
|
-
F: __dxlog_file8,
|
|
2503
|
-
L: 160,
|
|
2504
|
-
S: this,
|
|
2505
|
-
C: (f, a) => f(...a)
|
|
2506
|
-
});
|
|
2507
|
-
(0, import_invariant7.invariant)(invitationId, void 0, {
|
|
2508
|
-
F: __dxlog_file8,
|
|
2509
|
-
L: 161,
|
|
2510
|
-
S: this,
|
|
2511
|
-
A: [
|
|
2512
|
-
"invitationId",
|
|
2513
|
-
""
|
|
2514
|
-
]
|
|
2515
|
-
});
|
|
2516
|
-
const observable = this._acceptInvitations.get(invitationId);
|
|
2517
|
-
if (!observable) {
|
|
2518
|
-
import_log6.log.warn("invalid invitation", {
|
|
2519
|
-
invitationId
|
|
2520
|
-
}, {
|
|
2521
|
-
F: __dxlog_file8,
|
|
2522
|
-
L: 164,
|
|
2523
|
-
S: this,
|
|
2524
|
-
C: (f, a) => f(...a)
|
|
2525
|
-
});
|
|
2526
|
-
} else {
|
|
2527
|
-
await observable.authenticate(authCode);
|
|
2528
|
-
}
|
|
2466
|
+
async authenticate(request) {
|
|
2467
|
+
return this._invitationsManager.authenticate(request);
|
|
2529
2468
|
}
|
|
2530
|
-
async cancelInvitation(
|
|
2531
|
-
|
|
2532
|
-
invitationId
|
|
2533
|
-
}, {
|
|
2534
|
-
F: __dxlog_file8,
|
|
2535
|
-
L: 171,
|
|
2536
|
-
S: this,
|
|
2537
|
-
C: (f, a) => f(...a)
|
|
2538
|
-
});
|
|
2539
|
-
(0, import_invariant7.invariant)(invitationId, void 0, {
|
|
2540
|
-
F: __dxlog_file8,
|
|
2541
|
-
L: 172,
|
|
2542
|
-
S: this,
|
|
2543
|
-
A: [
|
|
2544
|
-
"invitationId",
|
|
2545
|
-
""
|
|
2546
|
-
]
|
|
2547
|
-
});
|
|
2548
|
-
const created = this._createInvitations.get(invitationId);
|
|
2549
|
-
const accepted = this._acceptInvitations.get(invitationId);
|
|
2550
|
-
if (created) {
|
|
2551
|
-
await created.cancel();
|
|
2552
|
-
this._createInvitations.delete(invitationId);
|
|
2553
|
-
this._removedCreated.emit(created.get());
|
|
2554
|
-
if (created.get().persistent) {
|
|
2555
|
-
await this._metadataStore.removeInvitation(created.get().invitationId);
|
|
2556
|
-
}
|
|
2557
|
-
} else if (accepted) {
|
|
2558
|
-
await accepted.cancel();
|
|
2559
|
-
this._acceptInvitations.delete(invitationId);
|
|
2560
|
-
this._removedAccepted.emit(accepted.get());
|
|
2561
|
-
}
|
|
2469
|
+
async cancelInvitation(request) {
|
|
2470
|
+
return this._invitationsManager.cancelInvitation(request);
|
|
2562
2471
|
}
|
|
2563
2472
|
queryInvitations() {
|
|
2564
2473
|
return new import_codec_protobuf8.Stream(({ next, ctx }) => {
|
|
2565
|
-
this.
|
|
2474
|
+
this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
|
|
2566
2475
|
next({
|
|
2567
2476
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2568
2477
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2571,7 +2480,7 @@ var InvitationsServiceImpl = class {
|
|
|
2571
2480
|
]
|
|
2572
2481
|
});
|
|
2573
2482
|
});
|
|
2574
|
-
this.
|
|
2483
|
+
this._invitationsManager.invitationAccepted.on(ctx, (invitation) => {
|
|
2575
2484
|
next({
|
|
2576
2485
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2577
2486
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2580,7 +2489,7 @@ var InvitationsServiceImpl = class {
|
|
|
2580
2489
|
]
|
|
2581
2490
|
});
|
|
2582
2491
|
});
|
|
2583
|
-
this.
|
|
2492
|
+
this._invitationsManager.removedCreated.on(ctx, (invitation) => {
|
|
2584
2493
|
next({
|
|
2585
2494
|
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2586
2495
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2589,7 +2498,7 @@ var InvitationsServiceImpl = class {
|
|
|
2589
2498
|
]
|
|
2590
2499
|
});
|
|
2591
2500
|
});
|
|
2592
|
-
this.
|
|
2501
|
+
this._invitationsManager.removedAccepted.on(ctx, (invitation) => {
|
|
2593
2502
|
next({
|
|
2594
2503
|
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2595
2504
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2598,7 +2507,7 @@ var InvitationsServiceImpl = class {
|
|
|
2598
2507
|
]
|
|
2599
2508
|
});
|
|
2600
2509
|
});
|
|
2601
|
-
this.
|
|
2510
|
+
this._invitationsManager.saved.on(ctx, (invitation) => {
|
|
2602
2511
|
next({
|
|
2603
2512
|
action: import_services5.QueryInvitationsResponse.Action.SAVED,
|
|
2604
2513
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2610,32 +2519,25 @@ var InvitationsServiceImpl = class {
|
|
|
2610
2519
|
next({
|
|
2611
2520
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2612
2521
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
2613
|
-
invitations:
|
|
2522
|
+
invitations: this._invitationsManager.getCreatedInvitations(),
|
|
2614
2523
|
existing: true
|
|
2615
2524
|
});
|
|
2616
2525
|
next({
|
|
2617
2526
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2618
2527
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
2619
|
-
invitations:
|
|
2528
|
+
invitations: this._invitationsManager.getAcceptedInvitations(),
|
|
2620
2529
|
existing: true
|
|
2621
2530
|
});
|
|
2622
|
-
|
|
2531
|
+
this._invitationsManager.onPersistentInvitationsLoaded(ctx, () => {
|
|
2623
2532
|
next({
|
|
2624
2533
|
action: import_services5.QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2625
2534
|
type: import_services5.QueryInvitationsResponse.Type.CREATED
|
|
2626
2535
|
});
|
|
2627
|
-
}
|
|
2628
|
-
this._persistentInvitationsLoadedEvent.on(ctx, () => {
|
|
2629
|
-
next({
|
|
2630
|
-
action: import_services5.QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2631
|
-
type: import_services5.QueryInvitationsResponse.Type.CREATED
|
|
2632
|
-
});
|
|
2633
|
-
});
|
|
2634
|
-
}
|
|
2536
|
+
});
|
|
2635
2537
|
});
|
|
2636
2538
|
}
|
|
2637
2539
|
};
|
|
2638
|
-
var
|
|
2540
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2639
2541
|
var SpaceInvitationProtocol = class {
|
|
2640
2542
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
2641
2543
|
this._spaceManager = _spaceManager;
|
|
@@ -2656,8 +2558,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2656
2558
|
};
|
|
2657
2559
|
}
|
|
2658
2560
|
async admit(request, guestProfile) {
|
|
2659
|
-
(0,
|
|
2660
|
-
F:
|
|
2561
|
+
(0, import_invariant7.invariant)(this._spaceKey, void 0, {
|
|
2562
|
+
F: __dxlog_file8,
|
|
2661
2563
|
L: 47,
|
|
2662
2564
|
S: this,
|
|
2663
2565
|
A: [
|
|
@@ -2666,8 +2568,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2666
2568
|
]
|
|
2667
2569
|
});
|
|
2668
2570
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2669
|
-
(0,
|
|
2670
|
-
F:
|
|
2571
|
+
(0, import_invariant7.invariant)(space, void 0, {
|
|
2572
|
+
F: __dxlog_file8,
|
|
2671
2573
|
L: 49,
|
|
2672
2574
|
S: this,
|
|
2673
2575
|
A: [
|
|
@@ -2675,8 +2577,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2675
2577
|
""
|
|
2676
2578
|
]
|
|
2677
2579
|
});
|
|
2678
|
-
(0,
|
|
2679
|
-
F:
|
|
2580
|
+
(0, import_invariant7.invariant)(request.space, void 0, {
|
|
2581
|
+
F: __dxlog_file8,
|
|
2680
2582
|
L: 51,
|
|
2681
2583
|
S: this,
|
|
2682
2584
|
A: [
|
|
@@ -2685,18 +2587,18 @@ var SpaceInvitationProtocol = class {
|
|
|
2685
2587
|
]
|
|
2686
2588
|
});
|
|
2687
2589
|
const { identityKey, deviceKey } = request.space;
|
|
2688
|
-
(0,
|
|
2590
|
+
(0, import_log6.log)("writing guest credentials", {
|
|
2689
2591
|
host: this._signingContext.deviceKey,
|
|
2690
2592
|
guest: deviceKey
|
|
2691
2593
|
}, {
|
|
2692
|
-
F:
|
|
2594
|
+
F: __dxlog_file8,
|
|
2693
2595
|
L: 54,
|
|
2694
2596
|
S: this,
|
|
2695
2597
|
C: (f, a) => f(...a)
|
|
2696
2598
|
});
|
|
2697
2599
|
const credentials = await (0, import_credentials8.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2698
|
-
(0,
|
|
2699
|
-
F:
|
|
2600
|
+
(0, import_invariant7.invariant)(credentials[0].credential, void 0, {
|
|
2601
|
+
F: __dxlog_file8,
|
|
2700
2602
|
L: 65,
|
|
2701
2603
|
S: this,
|
|
2702
2604
|
A: [
|
|
@@ -2705,8 +2607,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2705
2607
|
]
|
|
2706
2608
|
});
|
|
2707
2609
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2708
|
-
(0,
|
|
2709
|
-
F:
|
|
2610
|
+
(0, import_invariant7.invariant)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2611
|
+
F: __dxlog_file8,
|
|
2710
2612
|
L: 67,
|
|
2711
2613
|
S: this,
|
|
2712
2614
|
A: [
|
|
@@ -2745,8 +2647,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2745
2647
|
};
|
|
2746
2648
|
}
|
|
2747
2649
|
async accept(response) {
|
|
2748
|
-
(0,
|
|
2749
|
-
F:
|
|
2650
|
+
(0, import_invariant7.invariant)(response.space, void 0, {
|
|
2651
|
+
F: __dxlog_file8,
|
|
2750
2652
|
L: 107,
|
|
2751
2653
|
S: this,
|
|
2752
2654
|
A: [
|
|
@@ -2756,8 +2658,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2756
2658
|
});
|
|
2757
2659
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2758
2660
|
const assertion = (0, import_credentials8.getCredentialAssertion)(credential);
|
|
2759
|
-
(0,
|
|
2760
|
-
F:
|
|
2661
|
+
(0, import_invariant7.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2662
|
+
F: __dxlog_file8,
|
|
2761
2663
|
L: 110,
|
|
2762
2664
|
S: this,
|
|
2763
2665
|
A: [
|
|
@@ -2765,8 +2667,8 @@ var SpaceInvitationProtocol = class {
|
|
|
2765
2667
|
"'Invalid credential'"
|
|
2766
2668
|
]
|
|
2767
2669
|
});
|
|
2768
|
-
(0,
|
|
2769
|
-
F:
|
|
2670
|
+
(0, import_invariant7.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2671
|
+
F: __dxlog_file8,
|
|
2770
2672
|
L: 111,
|
|
2771
2673
|
S: this,
|
|
2772
2674
|
A: [
|
|
@@ -2789,6 +2691,221 @@ var SpaceInvitationProtocol = class {
|
|
|
2789
2691
|
};
|
|
2790
2692
|
}
|
|
2791
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
|
+
};
|
|
2792
2909
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
2793
2910
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2794
2911
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -2864,141 +2981,6 @@ _ts_decorate3([
|
|
|
2864
2981
|
ClientRpcServer = _ts_decorate3([
|
|
2865
2982
|
import_tracing3.trace.resource()
|
|
2866
2983
|
], ClientRpcServer);
|
|
2867
|
-
var getPlatform = () => {
|
|
2868
|
-
if (process.browser) {
|
|
2869
|
-
if (typeof window !== "undefined") {
|
|
2870
|
-
const { userAgent } = window.navigator;
|
|
2871
|
-
return {
|
|
2872
|
-
type: import_services8.Platform.PLATFORM_TYPE.BROWSER,
|
|
2873
|
-
userAgent,
|
|
2874
|
-
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
2875
|
-
};
|
|
2876
|
-
} else {
|
|
2877
|
-
return {
|
|
2878
|
-
type: import_services8.Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
2879
|
-
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
2880
|
-
};
|
|
2881
|
-
}
|
|
2882
|
-
} else {
|
|
2883
|
-
const { platform: platform2, version, arch } = process;
|
|
2884
|
-
return {
|
|
2885
|
-
type: import_services8.Platform.PLATFORM_TYPE.NODE,
|
|
2886
|
-
platform: platform2,
|
|
2887
|
-
arch,
|
|
2888
|
-
runtime: version,
|
|
2889
|
-
uptime: Math.floor(process.uptime()),
|
|
2890
|
-
memory: process.memoryUsage()
|
|
2891
|
-
};
|
|
2892
|
-
}
|
|
2893
|
-
};
|
|
2894
|
-
var DXOS_VERSION = "0.4.10-main.d658471";
|
|
2895
|
-
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
2896
|
-
var DEFAULT_TIMEOUT = 1e3;
|
|
2897
|
-
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
2898
|
-
const diagnostics = {
|
|
2899
|
-
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2900
|
-
platform: getPlatform(),
|
|
2901
|
-
client: {
|
|
2902
|
-
version: DXOS_VERSION,
|
|
2903
|
-
storage: {
|
|
2904
|
-
version: import_protocols7.STORAGE_VERSION
|
|
2905
|
-
}
|
|
2906
|
-
},
|
|
2907
|
-
trace: import_tracing4.TRACE_PROCESSOR.getDiagnostics()
|
|
2908
|
-
};
|
|
2909
|
-
{
|
|
2910
|
-
(0, import_invariant9.invariant)(clientServices.LoggingService, "SystemService is not available.", {
|
|
2911
|
-
F: __dxlog_file10,
|
|
2912
|
-
L: 108,
|
|
2913
|
-
S: void 0,
|
|
2914
|
-
A: [
|
|
2915
|
-
"clientServices.LoggingService",
|
|
2916
|
-
"'SystemService is not available.'"
|
|
2917
|
-
]
|
|
2918
|
-
});
|
|
2919
|
-
diagnostics.metrics = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
|
|
2920
|
-
timeout: DEFAULT_TIMEOUT
|
|
2921
|
-
}).catch(() => void 0);
|
|
2922
|
-
}
|
|
2923
|
-
if (typeof navigator !== "undefined" && navigator.storage) {
|
|
2924
|
-
const map = /* @__PURE__ */ new Map();
|
|
2925
|
-
const dir = await navigator.storage.getDirectory();
|
|
2926
|
-
for await (const filename of dir?.keys()) {
|
|
2927
|
-
const idx = filename.indexOf("-", filename.indexOf("-") + 1);
|
|
2928
|
-
if (idx === -1) {
|
|
2929
|
-
continue;
|
|
2930
|
-
}
|
|
2931
|
-
map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
|
|
2932
|
-
}
|
|
2933
|
-
diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
|
|
2934
|
-
file,
|
|
2935
|
-
count
|
|
2936
|
-
}));
|
|
2937
|
-
}
|
|
2938
|
-
const identity = serviceContext.identityManager.identity;
|
|
2939
|
-
if (identity) {
|
|
2940
|
-
diagnostics.identity = {
|
|
2941
|
-
identityKey: identity.identityKey,
|
|
2942
|
-
spaceKey: identity.space.key,
|
|
2943
|
-
profile: identity.profileDocument
|
|
2944
|
-
};
|
|
2945
|
-
const { devices } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
|
|
2946
|
-
timeout: DEFAULT_TIMEOUT
|
|
2947
|
-
}).catch(() => void 0) ?? {};
|
|
2948
|
-
diagnostics.devices = devices;
|
|
2949
|
-
if (serviceContext.dataSpaceManager) {
|
|
2950
|
-
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
2951
|
-
}
|
|
2952
|
-
const { feeds = [] } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
2953
|
-
timeout: DEFAULT_TIMEOUT
|
|
2954
|
-
}).catch(() => void 0) ?? {};
|
|
2955
|
-
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
2956
|
-
feedKey,
|
|
2957
|
-
bytes,
|
|
2958
|
-
length
|
|
2959
|
-
}));
|
|
2960
|
-
const status = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
|
|
2961
|
-
timeout: DEFAULT_TIMEOUT
|
|
2962
|
-
}).catch(() => void 0);
|
|
2963
|
-
diagnostics.networkStatus = status;
|
|
2964
|
-
diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
|
|
2965
|
-
}
|
|
2966
|
-
diagnostics.config = config.values;
|
|
2967
|
-
return diagnostics;
|
|
2968
|
-
};
|
|
2969
|
-
var getSpaceStats = async (space) => {
|
|
2970
|
-
const stats = {
|
|
2971
|
-
key: space.key,
|
|
2972
|
-
metrics: space.metrics,
|
|
2973
|
-
epochs: space.inner.spaceState.credentials.filter((0, import_credentials9.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
2974
|
-
...credential.subject.assertion,
|
|
2975
|
-
id: credential.id
|
|
2976
|
-
})),
|
|
2977
|
-
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
2978
|
-
identity: {
|
|
2979
|
-
identityKey: member.key,
|
|
2980
|
-
profile: {
|
|
2981
|
-
displayName: member.assertion.profile?.displayName
|
|
2982
|
-
}
|
|
2983
|
-
},
|
|
2984
|
-
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services7.SpaceMember.PresenceState.ONLINE : import_services7.SpaceMember.PresenceState.OFFLINE
|
|
2985
|
-
})),
|
|
2986
|
-
pipeline: {
|
|
2987
|
-
// TODO(burdon): Pick properties from credentials if needed.
|
|
2988
|
-
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
2989
|
-
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
2990
|
-
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
2991
|
-
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2992
|
-
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
2993
|
-
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
|
|
2994
|
-
}
|
|
2995
|
-
};
|
|
2996
|
-
if (stats.metrics) {
|
|
2997
|
-
const { open, ready } = stats.metrics;
|
|
2998
|
-
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
2999
|
-
}
|
|
3000
|
-
return stats;
|
|
3001
|
-
};
|
|
3002
2984
|
var AutomergeSpaceState = class {
|
|
3003
2985
|
constructor(_onNewRoot) {
|
|
3004
2986
|
this._onNewRoot = _onNewRoot;
|
|
@@ -3008,7 +2990,7 @@ var AutomergeSpaceState = class {
|
|
|
3008
2990
|
this._isProcessingRootDocs = false;
|
|
3009
2991
|
}
|
|
3010
2992
|
async processCredential(credential) {
|
|
3011
|
-
if (!(0,
|
|
2993
|
+
if (!(0, import_credentials10.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
3012
2994
|
return;
|
|
3013
2995
|
}
|
|
3014
2996
|
this.lastEpoch = credential;
|
|
@@ -3033,14 +3015,14 @@ var AutomergeSpaceState = class {
|
|
|
3033
3015
|
await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
|
|
3034
3016
|
}
|
|
3035
3017
|
};
|
|
3036
|
-
var
|
|
3018
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
3037
3019
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
3038
3020
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
3039
3021
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
3040
3022
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
3041
3023
|
var NotarizationPlugin = class {
|
|
3042
3024
|
constructor() {
|
|
3043
|
-
this._ctx = new
|
|
3025
|
+
this._ctx = new import_context7.Context();
|
|
3044
3026
|
this._extensionOpened = new import_async12.Event();
|
|
3045
3027
|
this._extensions = /* @__PURE__ */ new Set();
|
|
3046
3028
|
this._processedCredentials = new import_util5.ComplexSet(import_keys8.PublicKey.hash);
|
|
@@ -3061,13 +3043,13 @@ var NotarizationPlugin = class {
|
|
|
3061
3043
|
(0, import_log9.log)("notarize", {
|
|
3062
3044
|
credentials
|
|
3063
3045
|
}, {
|
|
3064
|
-
F:
|
|
3046
|
+
F: __dxlog_file10,
|
|
3065
3047
|
L: 90,
|
|
3066
3048
|
S: this,
|
|
3067
3049
|
C: (f, a) => f(...a)
|
|
3068
3050
|
});
|
|
3069
|
-
(0,
|
|
3070
|
-
F:
|
|
3051
|
+
(0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
3052
|
+
F: __dxlog_file10,
|
|
3071
3053
|
L: 91,
|
|
3072
3054
|
S: this,
|
|
3073
3055
|
A: [
|
|
@@ -3081,7 +3063,7 @@ var NotarizationPlugin = class {
|
|
|
3081
3063
|
import_log9.log.warn("Notarization error", {
|
|
3082
3064
|
err
|
|
3083
3065
|
}, {
|
|
3084
|
-
F:
|
|
3066
|
+
F: __dxlog_file10,
|
|
3085
3067
|
L: 99,
|
|
3086
3068
|
S: this,
|
|
3087
3069
|
C: (f, a) => f(...a)
|
|
@@ -3097,7 +3079,7 @@ var NotarizationPlugin = class {
|
|
|
3097
3079
|
timeout,
|
|
3098
3080
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3099
3081
|
}, {
|
|
3100
|
-
F:
|
|
3082
|
+
F: __dxlog_file10,
|
|
3101
3083
|
L: 111,
|
|
3102
3084
|
S: this,
|
|
3103
3085
|
C: (f, a) => f(...a)
|
|
@@ -3120,7 +3102,7 @@ var NotarizationPlugin = class {
|
|
|
3120
3102
|
import_log9.log.info("Exhausted all peers to notarize with", {
|
|
3121
3103
|
retryIn: retryTimeout
|
|
3122
3104
|
}, {
|
|
3123
|
-
F:
|
|
3105
|
+
F: __dxlog_file10,
|
|
3124
3106
|
L: 136,
|
|
3125
3107
|
S: this,
|
|
3126
3108
|
C: (f, a) => f(...a)
|
|
@@ -3134,7 +3116,7 @@ var NotarizationPlugin = class {
|
|
|
3134
3116
|
peer: peer.localPeerId,
|
|
3135
3117
|
credentialId: credentials.map((credential) => credential.id)
|
|
3136
3118
|
}, {
|
|
3137
|
-
F:
|
|
3119
|
+
F: __dxlog_file10,
|
|
3138
3120
|
L: 143,
|
|
3139
3121
|
S: this,
|
|
3140
3122
|
C: (f, a) => f(...a)
|
|
@@ -3143,7 +3125,7 @@ var NotarizationPlugin = class {
|
|
|
3143
3125
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
3144
3126
|
});
|
|
3145
3127
|
(0, import_log9.log)("success", void 0, {
|
|
3146
|
-
F:
|
|
3128
|
+
F: __dxlog_file10,
|
|
3147
3129
|
L: 147,
|
|
3148
3130
|
S: this,
|
|
3149
3131
|
C: (f, a) => f(...a)
|
|
@@ -3152,7 +3134,7 @@ var NotarizationPlugin = class {
|
|
|
3152
3134
|
} catch (err) {
|
|
3153
3135
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
3154
3136
|
import_log9.log.info("error notarizing (recoverable)", err, {
|
|
3155
|
-
F:
|
|
3137
|
+
F: __dxlog_file10,
|
|
3156
3138
|
L: 151,
|
|
3157
3139
|
S: this,
|
|
3158
3140
|
C: (f, a) => f(...a)
|
|
@@ -3165,12 +3147,12 @@ var NotarizationPlugin = class {
|
|
|
3165
3147
|
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
3166
3148
|
try {
|
|
3167
3149
|
await Promise.race([
|
|
3168
|
-
(0,
|
|
3150
|
+
(0, import_context7.rejectOnDispose)(ctx),
|
|
3169
3151
|
allNotarized,
|
|
3170
3152
|
errors.wait()
|
|
3171
3153
|
]);
|
|
3172
3154
|
(0, import_log9.log)("done", void 0, {
|
|
3173
|
-
F:
|
|
3155
|
+
F: __dxlog_file10,
|
|
3174
3156
|
L: 162,
|
|
3175
3157
|
S: this,
|
|
3176
3158
|
C: (f, a) => f(...a)
|
|
@@ -3191,8 +3173,8 @@ var NotarizationPlugin = class {
|
|
|
3191
3173
|
this._processCredentialsTriggers.delete(credential.id);
|
|
3192
3174
|
}
|
|
3193
3175
|
setWriter(writer) {
|
|
3194
|
-
(0,
|
|
3195
|
-
F:
|
|
3176
|
+
(0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
|
|
3177
|
+
F: __dxlog_file10,
|
|
3196
3178
|
L: 181,
|
|
3197
3179
|
S: this,
|
|
3198
3180
|
A: [
|
|
@@ -3216,8 +3198,8 @@ var NotarizationPlugin = class {
|
|
|
3216
3198
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
3217
3199
|
}
|
|
3218
3200
|
for (const credential of request.credentials ?? []) {
|
|
3219
|
-
(0,
|
|
3220
|
-
F:
|
|
3201
|
+
(0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
|
|
3202
|
+
F: __dxlog_file10,
|
|
3221
3203
|
L: 200,
|
|
3222
3204
|
S: this,
|
|
3223
3205
|
A: [
|
|
@@ -3237,7 +3219,7 @@ var NotarizationPlugin = class {
|
|
|
3237
3219
|
(0, import_log9.log)("extension opened", {
|
|
3238
3220
|
peer: extension.localPeerId
|
|
3239
3221
|
}, {
|
|
3240
|
-
F:
|
|
3222
|
+
F: __dxlog_file10,
|
|
3241
3223
|
L: 211,
|
|
3242
3224
|
S: this,
|
|
3243
3225
|
C: (f, a) => f(...a)
|
|
@@ -3249,7 +3231,7 @@ var NotarizationPlugin = class {
|
|
|
3249
3231
|
(0, import_log9.log)("extension closed", {
|
|
3250
3232
|
peer: extension.localPeerId
|
|
3251
3233
|
}, {
|
|
3252
|
-
F:
|
|
3234
|
+
F: __dxlog_file10,
|
|
3253
3235
|
L: 216,
|
|
3254
3236
|
S: this,
|
|
3255
3237
|
C: (f, a) => f(...a)
|
|
@@ -3265,10 +3247,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
3265
3247
|
constructor(_params) {
|
|
3266
3248
|
super({
|
|
3267
3249
|
requested: {
|
|
3268
|
-
NotarizationService:
|
|
3250
|
+
NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3269
3251
|
},
|
|
3270
3252
|
exposed: {
|
|
3271
|
-
NotarizationService:
|
|
3253
|
+
NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3272
3254
|
}
|
|
3273
3255
|
});
|
|
3274
3256
|
this._params = _params;
|
|
@@ -3301,14 +3283,14 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3301
3283
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3302
3284
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3303
3285
|
}
|
|
3304
|
-
var
|
|
3286
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3305
3287
|
var DataSpace = class {
|
|
3306
3288
|
constructor(params) {
|
|
3307
|
-
this._ctx = new
|
|
3289
|
+
this._ctx = new import_context6.Context();
|
|
3308
3290
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3309
3291
|
this._cache = void 0;
|
|
3310
3292
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
3311
|
-
this._state =
|
|
3293
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
3312
3294
|
this.error = void 0;
|
|
3313
3295
|
this.stateUpdate = new import_async10.Event();
|
|
3314
3296
|
this.metrics = {};
|
|
@@ -3330,9 +3312,9 @@ var DataSpace = class {
|
|
|
3330
3312
|
this._cache = params.cache;
|
|
3331
3313
|
this._state = params.initialState;
|
|
3332
3314
|
(0, import_log8.log)("new state", {
|
|
3333
|
-
state:
|
|
3315
|
+
state: import_services7.SpaceState[this._state]
|
|
3334
3316
|
}, {
|
|
3335
|
-
F:
|
|
3317
|
+
F: __dxlog_file11,
|
|
3336
3318
|
L: 140,
|
|
3337
3319
|
S: this,
|
|
3338
3320
|
C: (f, a) => f(...a)
|
|
@@ -3377,12 +3359,12 @@ var DataSpace = class {
|
|
|
3377
3359
|
await this._notarizationPlugin.open();
|
|
3378
3360
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3379
3361
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3380
|
-
await this._inner.open(new
|
|
3381
|
-
this._state =
|
|
3362
|
+
await this._inner.open(new import_context6.Context());
|
|
3363
|
+
this._state = import_services7.SpaceState.CONTROL_ONLY;
|
|
3382
3364
|
(0, import_log8.log)("new state", {
|
|
3383
|
-
state:
|
|
3365
|
+
state: import_services7.SpaceState[this._state]
|
|
3384
3366
|
}, {
|
|
3385
|
-
F:
|
|
3367
|
+
F: __dxlog_file11,
|
|
3386
3368
|
L: 198,
|
|
3387
3369
|
S: this,
|
|
3388
3370
|
C: (f, a) => f(...a)
|
|
@@ -3396,17 +3378,17 @@ var DataSpace = class {
|
|
|
3396
3378
|
}
|
|
3397
3379
|
async _close() {
|
|
3398
3380
|
await this._callbacks.beforeClose?.();
|
|
3399
|
-
this._state =
|
|
3381
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
3400
3382
|
(0, import_log8.log)("new state", {
|
|
3401
|
-
state:
|
|
3383
|
+
state: import_services7.SpaceState[this._state]
|
|
3402
3384
|
}, {
|
|
3403
|
-
F:
|
|
3385
|
+
F: __dxlog_file11,
|
|
3404
3386
|
L: 212,
|
|
3405
3387
|
S: this,
|
|
3406
3388
|
C: (f, a) => f(...a)
|
|
3407
3389
|
});
|
|
3408
3390
|
await this._ctx.dispose();
|
|
3409
|
-
this._ctx = new
|
|
3391
|
+
this._ctx = new import_context6.Context();
|
|
3410
3392
|
await this.authVerifier.close();
|
|
3411
3393
|
await this._inner.close();
|
|
3412
3394
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
@@ -3430,9 +3412,9 @@ var DataSpace = class {
|
|
|
3430
3412
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3431
3413
|
await this.initializeDataPipeline();
|
|
3432
3414
|
} catch (err) {
|
|
3433
|
-
if (err instanceof
|
|
3415
|
+
if (err instanceof import_protocols7.CancelledError || err instanceof import_context6.ContextDisposedError) {
|
|
3434
3416
|
(0, import_log8.log)("data pipeline initialization cancelled", err, {
|
|
3435
|
-
F:
|
|
3417
|
+
F: __dxlog_file11,
|
|
3436
3418
|
L: 245,
|
|
3437
3419
|
S: this,
|
|
3438
3420
|
C: (f, a) => f(...a)
|
|
@@ -3440,16 +3422,16 @@ var DataSpace = class {
|
|
|
3440
3422
|
return;
|
|
3441
3423
|
}
|
|
3442
3424
|
import_log8.log.error("Error initializing data pipeline", err, {
|
|
3443
|
-
F:
|
|
3425
|
+
F: __dxlog_file11,
|
|
3444
3426
|
L: 249,
|
|
3445
3427
|
S: this,
|
|
3446
3428
|
C: (f, a) => f(...a)
|
|
3447
3429
|
});
|
|
3448
|
-
this._state =
|
|
3430
|
+
this._state = import_services7.SpaceState.ERROR;
|
|
3449
3431
|
(0, import_log8.log)("new state", {
|
|
3450
|
-
state:
|
|
3432
|
+
state: import_services7.SpaceState[this._state]
|
|
3451
3433
|
}, {
|
|
3452
|
-
F:
|
|
3434
|
+
F: __dxlog_file11,
|
|
3453
3435
|
L: 251,
|
|
3454
3436
|
S: this,
|
|
3455
3437
|
C: (f, a) => f(...a)
|
|
@@ -3462,14 +3444,14 @@ var DataSpace = class {
|
|
|
3462
3444
|
});
|
|
3463
3445
|
}
|
|
3464
3446
|
async initializeDataPipeline() {
|
|
3465
|
-
if (this._state !==
|
|
3466
|
-
throw new
|
|
3447
|
+
if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
|
|
3448
|
+
throw new import_protocols7.SystemError("Invalid operation");
|
|
3467
3449
|
}
|
|
3468
|
-
this._state =
|
|
3450
|
+
this._state = import_services7.SpaceState.INITIALIZING;
|
|
3469
3451
|
(0, import_log8.log)("new state", {
|
|
3470
|
-
state:
|
|
3452
|
+
state: import_services7.SpaceState[this._state]
|
|
3471
3453
|
}, {
|
|
3472
|
-
F:
|
|
3454
|
+
F: __dxlog_file11,
|
|
3473
3455
|
L: 267,
|
|
3474
3456
|
S: this,
|
|
3475
3457
|
C: (f, a) => f(...a)
|
|
@@ -3477,19 +3459,19 @@ var DataSpace = class {
|
|
|
3477
3459
|
await this._initializeAndReadControlPipeline();
|
|
3478
3460
|
await (0, import_async10.sleep)(1);
|
|
3479
3461
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
3480
|
-
await (0,
|
|
3462
|
+
await (0, import_context6.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
3481
3463
|
(0, import_log8.log)("data pipeline ready", void 0, {
|
|
3482
|
-
F:
|
|
3464
|
+
F: __dxlog_file11,
|
|
3483
3465
|
L: 279,
|
|
3484
3466
|
S: this,
|
|
3485
3467
|
C: (f, a) => f(...a)
|
|
3486
3468
|
});
|
|
3487
3469
|
await this._callbacks.beforeReady?.();
|
|
3488
|
-
this._state =
|
|
3470
|
+
this._state = import_services7.SpaceState.READY;
|
|
3489
3471
|
(0, import_log8.log)("new state", {
|
|
3490
|
-
state:
|
|
3472
|
+
state: import_services7.SpaceState[this._state]
|
|
3491
3473
|
}, {
|
|
3492
|
-
F:
|
|
3474
|
+
F: __dxlog_file11,
|
|
3493
3475
|
L: 283,
|
|
3494
3476
|
S: this,
|
|
3495
3477
|
C: (f, a) => f(...a)
|
|
@@ -3505,14 +3487,14 @@ var DataSpace = class {
|
|
|
3505
3487
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
3506
3488
|
await this._createWritableFeeds();
|
|
3507
3489
|
(0, import_log8.log)("writable feeds created", void 0, {
|
|
3508
|
-
F:
|
|
3490
|
+
F: __dxlog_file11,
|
|
3509
3491
|
L: 299,
|
|
3510
3492
|
S: this,
|
|
3511
3493
|
C: (f, a) => f(...a)
|
|
3512
3494
|
});
|
|
3513
3495
|
this.stateUpdate.emit();
|
|
3514
3496
|
if (!this.notarizationPlugin.hasWriter) {
|
|
3515
|
-
this.notarizationPlugin.setWriter((0,
|
|
3497
|
+
this.notarizationPlugin.setWriter((0, import_echo_pipeline2.createMappedFeedWriter)((credential) => ({
|
|
3516
3498
|
credential: {
|
|
3517
3499
|
credential
|
|
3518
3500
|
}
|
|
@@ -3533,7 +3515,7 @@ var DataSpace = class {
|
|
|
3533
3515
|
spaceKey: this.key,
|
|
3534
3516
|
deviceKey: this._signingContext.deviceKey,
|
|
3535
3517
|
identityKey: this._signingContext.identityKey,
|
|
3536
|
-
designation:
|
|
3518
|
+
designation: import_credentials9.AdmittedFeed.Designation.CONTROL
|
|
3537
3519
|
}
|
|
3538
3520
|
}));
|
|
3539
3521
|
}
|
|
@@ -3550,7 +3532,7 @@ var DataSpace = class {
|
|
|
3550
3532
|
spaceKey: this.key,
|
|
3551
3533
|
deviceKey: this._signingContext.deviceKey,
|
|
3552
3534
|
identityKey: this._signingContext.identityKey,
|
|
3553
|
-
designation:
|
|
3535
|
+
designation: import_credentials9.AdmittedFeed.Designation.DATA
|
|
3554
3536
|
}
|
|
3555
3537
|
}));
|
|
3556
3538
|
}
|
|
@@ -3568,7 +3550,7 @@ var DataSpace = class {
|
|
|
3568
3550
|
space: this.key,
|
|
3569
3551
|
rootUrl
|
|
3570
3552
|
}, {
|
|
3571
|
-
F:
|
|
3553
|
+
F: __dxlog_file11,
|
|
3572
3554
|
L: 365,
|
|
3573
3555
|
S: this,
|
|
3574
3556
|
C: (f, a) => f(...a)
|
|
@@ -3578,12 +3560,12 @@ var DataSpace = class {
|
|
|
3578
3560
|
queueMicrotask(async () => {
|
|
3579
3561
|
try {
|
|
3580
3562
|
await (0, import_debug3.warnAfterTimeout)(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
3581
|
-
await (0,
|
|
3563
|
+
await (0, import_context6.cancelWithContext)(this._ctx, handle.whenReady());
|
|
3582
3564
|
});
|
|
3583
3565
|
if (this._ctx.disposed) {
|
|
3584
3566
|
return;
|
|
3585
3567
|
}
|
|
3586
|
-
const doc = handle.docSync() ?? (0,
|
|
3568
|
+
const doc = handle.docSync() ?? (0, import_invariant9.failedInvariant)();
|
|
3587
3569
|
if (!doc.access?.spaceKey) {
|
|
3588
3570
|
handle.change((doc2) => {
|
|
3589
3571
|
doc2.access = {
|
|
@@ -3592,7 +3574,7 @@ var DataSpace = class {
|
|
|
3592
3574
|
});
|
|
3593
3575
|
}
|
|
3594
3576
|
} catch (err) {
|
|
3595
|
-
if (err instanceof
|
|
3577
|
+
if (err instanceof import_context6.ContextDisposedError) {
|
|
3596
3578
|
return;
|
|
3597
3579
|
}
|
|
3598
3580
|
import_log8.log.warn("error loading automerge root doc", {
|
|
@@ -3600,7 +3582,7 @@ var DataSpace = class {
|
|
|
3600
3582
|
rootUrl,
|
|
3601
3583
|
err
|
|
3602
3584
|
}, {
|
|
3603
|
-
F:
|
|
3585
|
+
F: __dxlog_file11,
|
|
3604
3586
|
L: 388,
|
|
3605
3587
|
S: this,
|
|
3606
3588
|
C: (f, a) => f(...a)
|
|
@@ -3627,7 +3609,7 @@ var DataSpace = class {
|
|
|
3627
3609
|
let epoch;
|
|
3628
3610
|
switch (options?.migration) {
|
|
3629
3611
|
case void 0:
|
|
3630
|
-
case
|
|
3612
|
+
case import_services7.CreateEpochRequest.Migration.NONE:
|
|
3631
3613
|
{
|
|
3632
3614
|
epoch = {
|
|
3633
3615
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
@@ -3637,7 +3619,7 @@ var DataSpace = class {
|
|
|
3637
3619
|
};
|
|
3638
3620
|
}
|
|
3639
3621
|
break;
|
|
3640
|
-
case
|
|
3622
|
+
case import_services7.CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3641
3623
|
{
|
|
3642
3624
|
const document = this._automergeHost.repo.create();
|
|
3643
3625
|
epoch = {
|
|
@@ -3648,14 +3630,14 @@ var DataSpace = class {
|
|
|
3648
3630
|
};
|
|
3649
3631
|
}
|
|
3650
3632
|
break;
|
|
3651
|
-
case
|
|
3633
|
+
case import_services7.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
3652
3634
|
{
|
|
3653
3635
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3654
3636
|
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3655
|
-
await (0,
|
|
3637
|
+
await (0, import_context6.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3656
3638
|
const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
|
|
3657
|
-
(0,
|
|
3658
|
-
F:
|
|
3639
|
+
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3640
|
+
F: __dxlog_file11,
|
|
3659
3641
|
L: 438,
|
|
3660
3642
|
S: this,
|
|
3661
3643
|
A: [
|
|
@@ -3671,22 +3653,22 @@ var DataSpace = class {
|
|
|
3671
3653
|
};
|
|
3672
3654
|
}
|
|
3673
3655
|
break;
|
|
3674
|
-
case
|
|
3656
|
+
case import_services7.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
3675
3657
|
{
|
|
3676
3658
|
import_log8.log.info("Fragmenting", void 0, {
|
|
3677
|
-
F:
|
|
3659
|
+
F: __dxlog_file11,
|
|
3678
3660
|
L: 450,
|
|
3679
3661
|
S: this,
|
|
3680
3662
|
C: (f, a) => f(...a)
|
|
3681
3663
|
});
|
|
3682
3664
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3683
3665
|
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3684
|
-
await (0,
|
|
3666
|
+
await (0, import_context6.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3685
3667
|
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3686
|
-
const properties = objects.find(([_, value]) => value.system.type?.itemId ===
|
|
3668
|
+
const properties = objects.find(([_, value]) => value.system.type?.itemId === import_echo_schema.TYPE_PROPERTIES);
|
|
3687
3669
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3688
|
-
(0,
|
|
3689
|
-
F:
|
|
3670
|
+
(0, import_invariant9.invariant)(properties, "Properties not found", {
|
|
3671
|
+
F: __dxlog_file11,
|
|
3690
3672
|
L: 460,
|
|
3691
3673
|
S: this,
|
|
3692
3674
|
A: [
|
|
@@ -3701,8 +3683,8 @@ var DataSpace = class {
|
|
|
3701
3683
|
])
|
|
3702
3684
|
};
|
|
3703
3685
|
const newRoot = this._automergeHost.repo.create(newSpaceDoc);
|
|
3704
|
-
(0,
|
|
3705
|
-
F:
|
|
3686
|
+
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3687
|
+
F: __dxlog_file11,
|
|
3706
3688
|
L: 465,
|
|
3707
3689
|
S: this,
|
|
3708
3690
|
A: [
|
|
@@ -3710,7 +3692,7 @@ var DataSpace = class {
|
|
|
3710
3692
|
""
|
|
3711
3693
|
]
|
|
3712
3694
|
});
|
|
3713
|
-
const docLoader = new
|
|
3695
|
+
const docLoader = new import_echo_pipeline3.AutomergeDocumentLoaderImpl(this.key, this._automergeHost.repo);
|
|
3714
3696
|
await docLoader.loadSpaceRootDocHandle(this._ctx, {
|
|
3715
3697
|
rootUrl: newRoot.url
|
|
3716
3698
|
});
|
|
@@ -3754,24 +3736,24 @@ var DataSpace = class {
|
|
|
3754
3736
|
]));
|
|
3755
3737
|
}
|
|
3756
3738
|
async activate() {
|
|
3757
|
-
if (this._state !==
|
|
3739
|
+
if (this._state !== import_services7.SpaceState.INACTIVE) {
|
|
3758
3740
|
return;
|
|
3759
3741
|
}
|
|
3760
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3742
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.ACTIVE);
|
|
3761
3743
|
await this._open();
|
|
3762
3744
|
this.initializeDataPipelineAsync();
|
|
3763
3745
|
}
|
|
3764
3746
|
async deactivate() {
|
|
3765
|
-
if (this._state ===
|
|
3747
|
+
if (this._state === import_services7.SpaceState.INACTIVE) {
|
|
3766
3748
|
return;
|
|
3767
3749
|
}
|
|
3768
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3750
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.INACTIVE);
|
|
3769
3751
|
await this._close();
|
|
3770
|
-
this._state =
|
|
3752
|
+
this._state = import_services7.SpaceState.INACTIVE;
|
|
3771
3753
|
(0, import_log8.log)("new state", {
|
|
3772
|
-
state:
|
|
3754
|
+
state: import_services7.SpaceState[this._state]
|
|
3773
3755
|
}, {
|
|
3774
|
-
F:
|
|
3756
|
+
F: __dxlog_file11,
|
|
3775
3757
|
L: 531,
|
|
3776
3758
|
S: this,
|
|
3777
3759
|
C: (f, a) => f(...a)
|
|
@@ -3780,18 +3762,18 @@ var DataSpace = class {
|
|
|
3780
3762
|
}
|
|
3781
3763
|
};
|
|
3782
3764
|
_ts_decorate4([
|
|
3783
|
-
|
|
3765
|
+
import_tracing4.trace.info()
|
|
3784
3766
|
], DataSpace.prototype, "_inner", void 0);
|
|
3785
3767
|
_ts_decorate4([
|
|
3786
|
-
|
|
3768
|
+
import_tracing4.trace.info()
|
|
3787
3769
|
], DataSpace.prototype, "key", null);
|
|
3788
3770
|
_ts_decorate4([
|
|
3789
|
-
|
|
3790
|
-
enum:
|
|
3771
|
+
import_tracing4.trace.info({
|
|
3772
|
+
enum: import_services7.SpaceState
|
|
3791
3773
|
})
|
|
3792
3774
|
], DataSpace.prototype, "state", null);
|
|
3793
3775
|
_ts_decorate4([
|
|
3794
|
-
|
|
3776
|
+
import_tracing4.trace.info({
|
|
3795
3777
|
depth: null
|
|
3796
3778
|
})
|
|
3797
3779
|
], DataSpace.prototype, "_automergeInfo", null);
|
|
@@ -3802,12 +3784,12 @@ _ts_decorate4([
|
|
|
3802
3784
|
import_async10.synchronized
|
|
3803
3785
|
], DataSpace.prototype, "close", null);
|
|
3804
3786
|
_ts_decorate4([
|
|
3805
|
-
|
|
3787
|
+
import_tracing4.trace.span({
|
|
3806
3788
|
showInBrowserTimeline: true
|
|
3807
3789
|
})
|
|
3808
3790
|
], DataSpace.prototype, "initializeDataPipeline", null);
|
|
3809
3791
|
_ts_decorate4([
|
|
3810
|
-
|
|
3792
|
+
import_tracing4.trace.span({
|
|
3811
3793
|
showInBrowserTimeline: true
|
|
3812
3794
|
})
|
|
3813
3795
|
], DataSpace.prototype, "_initializeAndReadControlPipeline", null);
|
|
@@ -3822,11 +3804,11 @@ _ts_decorate4([
|
|
|
3822
3804
|
], DataSpace.prototype, "deactivate", null);
|
|
3823
3805
|
DataSpace = _ts_decorate4([
|
|
3824
3806
|
(0, import_async10.trackLeaks)("open", "close"),
|
|
3825
|
-
|
|
3807
|
+
import_tracing4.trace.resource()
|
|
3826
3808
|
], DataSpace);
|
|
3827
3809
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
3828
3810
|
const credentials = [
|
|
3829
|
-
await (0,
|
|
3811
|
+
await (0, import_credentials12.createCredential)({
|
|
3830
3812
|
signer: keyring,
|
|
3831
3813
|
issuer: space.key,
|
|
3832
3814
|
subject: space.key,
|
|
@@ -3835,14 +3817,14 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3835
3817
|
spaceKey: space.key
|
|
3836
3818
|
}
|
|
3837
3819
|
}),
|
|
3838
|
-
await (0,
|
|
3820
|
+
await (0, import_credentials12.createCredential)({
|
|
3839
3821
|
signer: keyring,
|
|
3840
3822
|
issuer: space.key,
|
|
3841
3823
|
subject: signingContext.identityKey,
|
|
3842
3824
|
assertion: {
|
|
3843
3825
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
3844
3826
|
spaceKey: space.key,
|
|
3845
|
-
role:
|
|
3827
|
+
role: import_credentials13.SpaceMember.Role.ADMIN,
|
|
3846
3828
|
profile: signingContext.getProfile(),
|
|
3847
3829
|
genesisFeedKey: space.controlFeedKey ?? (0, import_debug4.failUndefined)()
|
|
3848
3830
|
}
|
|
@@ -3854,7 +3836,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3854
3836
|
spaceKey: space.key,
|
|
3855
3837
|
identityKey: signingContext.identityKey,
|
|
3856
3838
|
deviceKey: signingContext.deviceKey,
|
|
3857
|
-
designation:
|
|
3839
|
+
designation: import_credentials13.AdmittedFeed.Designation.CONTROL
|
|
3858
3840
|
}
|
|
3859
3841
|
}),
|
|
3860
3842
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3864,7 +3846,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3864
3846
|
spaceKey: space.key,
|
|
3865
3847
|
identityKey: signingContext.identityKey,
|
|
3866
3848
|
deviceKey: signingContext.deviceKey,
|
|
3867
|
-
designation:
|
|
3849
|
+
designation: import_credentials13.AdmittedFeed.Designation.DATA
|
|
3868
3850
|
}
|
|
3869
3851
|
}),
|
|
3870
3852
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3898,7 +3880,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
3898
3880
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3899
3881
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3900
3882
|
}
|
|
3901
|
-
var
|
|
3883
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
3902
3884
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3903
3885
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3904
3886
|
var DataSpaceManager = class {
|
|
@@ -3909,7 +3891,7 @@ var DataSpaceManager = class {
|
|
|
3909
3891
|
this._signingContext = _signingContext;
|
|
3910
3892
|
this._feedStore = _feedStore;
|
|
3911
3893
|
this._automergeHost = _automergeHost;
|
|
3912
|
-
this._ctx = new
|
|
3894
|
+
this._ctx = new import_context8.Context();
|
|
3913
3895
|
this.updated = new import_async13.Event();
|
|
3914
3896
|
this._spaces = new import_util6.ComplexMap(import_keys9.PublicKey.hash);
|
|
3915
3897
|
this._isOpen = false;
|
|
@@ -3924,15 +3906,15 @@ var DataSpaceManager = class {
|
|
|
3924
3906
|
}
|
|
3925
3907
|
async open() {
|
|
3926
3908
|
(0, import_log10.log)("open", void 0, {
|
|
3927
|
-
F:
|
|
3909
|
+
F: __dxlog_file12,
|
|
3928
3910
|
L: 98,
|
|
3929
3911
|
S: this,
|
|
3930
3912
|
C: (f, a) => f(...a)
|
|
3931
3913
|
});
|
|
3932
|
-
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({
|
|
3933
3915
|
id: this._instanceId
|
|
3934
3916
|
}), {
|
|
3935
|
-
F:
|
|
3917
|
+
F: __dxlog_file12,
|
|
3936
3918
|
L: 99,
|
|
3937
3919
|
S: this,
|
|
3938
3920
|
C: (f, a) => f(...a)
|
|
@@ -3940,7 +3922,7 @@ var DataSpaceManager = class {
|
|
|
3940
3922
|
(0, import_log10.log)("metadata loaded", {
|
|
3941
3923
|
spaces: this._metadataStore.spaces.length
|
|
3942
3924
|
}, {
|
|
3943
|
-
F:
|
|
3925
|
+
F: __dxlog_file12,
|
|
3944
3926
|
L: 100,
|
|
3945
3927
|
S: this,
|
|
3946
3928
|
C: (f, a) => f(...a)
|
|
@@ -3950,7 +3932,7 @@ var DataSpaceManager = class {
|
|
|
3950
3932
|
(0, import_log10.log)("load space", {
|
|
3951
3933
|
spaceMetadata
|
|
3952
3934
|
}, {
|
|
3953
|
-
F:
|
|
3935
|
+
F: __dxlog_file12,
|
|
3954
3936
|
L: 104,
|
|
3955
3937
|
S: this,
|
|
3956
3938
|
C: (f, a) => f(...a)
|
|
@@ -3961,7 +3943,7 @@ var DataSpaceManager = class {
|
|
|
3961
3943
|
spaceMetadata,
|
|
3962
3944
|
err
|
|
3963
3945
|
}, {
|
|
3964
|
-
F:
|
|
3946
|
+
F: __dxlog_file12,
|
|
3965
3947
|
L: 107,
|
|
3966
3948
|
S: this,
|
|
3967
3949
|
C: (f, a) => f(...a)
|
|
@@ -3971,14 +3953,14 @@ var DataSpaceManager = class {
|
|
|
3971
3953
|
this._isOpen = true;
|
|
3972
3954
|
this.updated.emit();
|
|
3973
3955
|
for (const space of this._spaces.values()) {
|
|
3974
|
-
if (space.state !==
|
|
3956
|
+
if (space.state !== import_services8.SpaceState.INACTIVE) {
|
|
3975
3957
|
space.initializeDataPipelineAsync();
|
|
3976
3958
|
}
|
|
3977
3959
|
}
|
|
3978
|
-
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({
|
|
3979
3961
|
id: this._instanceId
|
|
3980
3962
|
}), {
|
|
3981
|
-
F:
|
|
3963
|
+
F: __dxlog_file12,
|
|
3982
3964
|
L: 120,
|
|
3983
3965
|
S: this,
|
|
3984
3966
|
C: (f, a) => f(...a)
|
|
@@ -3986,7 +3968,7 @@ var DataSpaceManager = class {
|
|
|
3986
3968
|
}
|
|
3987
3969
|
async close() {
|
|
3988
3970
|
(0, import_log10.log)("close", void 0, {
|
|
3989
|
-
F:
|
|
3971
|
+
F: __dxlog_file12,
|
|
3990
3972
|
L: 125,
|
|
3991
3973
|
S: this,
|
|
3992
3974
|
C: (f, a) => f(...a)
|
|
@@ -4001,8 +3983,8 @@ var DataSpaceManager = class {
|
|
|
4001
3983
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
4002
3984
|
*/
|
|
4003
3985
|
async createSpace() {
|
|
4004
|
-
(0,
|
|
4005
|
-
F:
|
|
3986
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3987
|
+
F: __dxlog_file12,
|
|
4006
3988
|
L: 138,
|
|
4007
3989
|
S: this,
|
|
4008
3990
|
A: [
|
|
@@ -4018,12 +4000,12 @@ var DataSpaceManager = class {
|
|
|
4018
4000
|
genesisFeedKey: controlFeedKey,
|
|
4019
4001
|
controlFeedKey,
|
|
4020
4002
|
dataFeedKey,
|
|
4021
|
-
state:
|
|
4003
|
+
state: import_services8.SpaceState.ACTIVE
|
|
4022
4004
|
};
|
|
4023
4005
|
(0, import_log10.log)("creating space...", {
|
|
4024
4006
|
spaceKey
|
|
4025
4007
|
}, {
|
|
4026
|
-
F:
|
|
4008
|
+
F: __dxlog_file12,
|
|
4027
4009
|
L: 150,
|
|
4028
4010
|
S: this,
|
|
4029
4011
|
C: (f, a) => f(...a)
|
|
@@ -4038,8 +4020,8 @@ var DataSpaceManager = class {
|
|
|
4038
4020
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
|
|
4039
4021
|
await this._metadataStore.addSpace(metadata);
|
|
4040
4022
|
const memberCredential = credentials[1];
|
|
4041
|
-
(0,
|
|
4042
|
-
F:
|
|
4023
|
+
(0, import_invariant11.invariant)((0, import_credentials11.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4024
|
+
F: __dxlog_file12,
|
|
4043
4025
|
L: 163,
|
|
4044
4026
|
S: this,
|
|
4045
4027
|
A: [
|
|
@@ -4057,13 +4039,13 @@ var DataSpaceManager = class {
|
|
|
4057
4039
|
(0, import_log10.log)("accept space", {
|
|
4058
4040
|
opts
|
|
4059
4041
|
}, {
|
|
4060
|
-
F:
|
|
4042
|
+
F: __dxlog_file12,
|
|
4061
4043
|
L: 175,
|
|
4062
4044
|
S: this,
|
|
4063
4045
|
C: (f, a) => f(...a)
|
|
4064
4046
|
});
|
|
4065
|
-
(0,
|
|
4066
|
-
F:
|
|
4047
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
4048
|
+
F: __dxlog_file12,
|
|
4067
4049
|
L: 176,
|
|
4068
4050
|
S: this,
|
|
4069
4051
|
A: [
|
|
@@ -4071,8 +4053,8 @@ var DataSpaceManager = class {
|
|
|
4071
4053
|
"'Not open.'"
|
|
4072
4054
|
]
|
|
4073
4055
|
});
|
|
4074
|
-
(0,
|
|
4075
|
-
F:
|
|
4056
|
+
(0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
4057
|
+
F: __dxlog_file12,
|
|
4076
4058
|
L: 177,
|
|
4077
4059
|
S: this,
|
|
4078
4060
|
A: [
|
|
@@ -4098,16 +4080,16 @@ var DataSpaceManager = class {
|
|
|
4098
4080
|
* TODO(dmaretskyi): Consider removing.
|
|
4099
4081
|
*/
|
|
4100
4082
|
async waitUntilSpaceReady(spaceKey) {
|
|
4101
|
-
await (0,
|
|
4083
|
+
await (0, import_context8.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
4102
4084
|
const space = this._spaces.get(spaceKey);
|
|
4103
|
-
return !!space && space.state ===
|
|
4085
|
+
return !!space && space.state === import_services8.SpaceState.READY;
|
|
4104
4086
|
}));
|
|
4105
4087
|
}
|
|
4106
4088
|
async _constructSpace(metadata) {
|
|
4107
4089
|
(0, import_log10.log)("construct space", {
|
|
4108
4090
|
metadata
|
|
4109
4091
|
}, {
|
|
4110
|
-
F:
|
|
4092
|
+
F: __dxlog_file12,
|
|
4111
4093
|
L: 210,
|
|
4112
4094
|
S: this,
|
|
4113
4095
|
C: (f, a) => f(...a)
|
|
@@ -4145,7 +4127,7 @@ var DataSpaceManager = class {
|
|
|
4145
4127
|
},
|
|
4146
4128
|
onAuthFailure: () => {
|
|
4147
4129
|
import_log10.log.warn("auth failure", void 0, {
|
|
4148
|
-
F:
|
|
4130
|
+
F: __dxlog_file12,
|
|
4149
4131
|
L: 247,
|
|
4150
4132
|
S: this,
|
|
4151
4133
|
C: (f, a) => f(...a)
|
|
@@ -4157,7 +4139,7 @@ var DataSpaceManager = class {
|
|
|
4157
4139
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
4158
4140
|
const dataSpace = new DataSpace({
|
|
4159
4141
|
inner: space,
|
|
4160
|
-
initialState: metadata.state ===
|
|
4142
|
+
initialState: metadata.state === import_services8.SpaceState.INACTIVE ? import_services8.SpaceState.INACTIVE : import_services8.SpaceState.CLOSED,
|
|
4161
4143
|
metadataStore: this._metadataStore,
|
|
4162
4144
|
gossip,
|
|
4163
4145
|
presence,
|
|
@@ -4169,7 +4151,7 @@ var DataSpaceManager = class {
|
|
|
4169
4151
|
(0, import_log10.log)("before space ready", {
|
|
4170
4152
|
space: space.key
|
|
4171
4153
|
}, {
|
|
4172
|
-
F:
|
|
4154
|
+
F: __dxlog_file12,
|
|
4173
4155
|
L: 265,
|
|
4174
4156
|
S: this,
|
|
4175
4157
|
C: (f, a) => f(...a)
|
|
@@ -4180,7 +4162,7 @@ var DataSpaceManager = class {
|
|
|
4180
4162
|
space: space.key,
|
|
4181
4163
|
open: this._isOpen
|
|
4182
4164
|
}, {
|
|
4183
|
-
F:
|
|
4165
|
+
F: __dxlog_file12,
|
|
4184
4166
|
L: 268,
|
|
4185
4167
|
S: this,
|
|
4186
4168
|
C: (f, a) => f(...a)
|
|
@@ -4193,7 +4175,7 @@ var DataSpaceManager = class {
|
|
|
4193
4175
|
(0, import_log10.log)("before space close", {
|
|
4194
4176
|
space: space.key
|
|
4195
4177
|
}, {
|
|
4196
|
-
F:
|
|
4178
|
+
F: __dxlog_file12,
|
|
4197
4179
|
L: 274,
|
|
4198
4180
|
S: this,
|
|
4199
4181
|
C: (f, a) => f(...a)
|
|
@@ -4203,7 +4185,7 @@ var DataSpaceManager = class {
|
|
|
4203
4185
|
cache: metadata.cache,
|
|
4204
4186
|
automergeHost: this._automergeHost
|
|
4205
4187
|
});
|
|
4206
|
-
if (metadata.state !==
|
|
4188
|
+
if (metadata.state !== import_services8.SpaceState.INACTIVE) {
|
|
4207
4189
|
await dataSpace.open();
|
|
4208
4190
|
}
|
|
4209
4191
|
if (metadata.controlTimeframe) {
|
|
@@ -4228,7 +4210,7 @@ _ts_decorate5([
|
|
|
4228
4210
|
DataSpaceManager = _ts_decorate5([
|
|
4229
4211
|
(0, import_async13.trackLeaks)("open", "close")
|
|
4230
4212
|
], DataSpaceManager);
|
|
4231
|
-
var
|
|
4213
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
4232
4214
|
var SpacesServiceImpl = class {
|
|
4233
4215
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
4234
4216
|
this._identityManager = _identityManager;
|
|
@@ -4245,29 +4227,29 @@ var SpacesServiceImpl = class {
|
|
|
4245
4227
|
}
|
|
4246
4228
|
async updateSpace({ spaceKey, state }) {
|
|
4247
4229
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4248
|
-
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));
|
|
4249
4231
|
if (state) {
|
|
4250
4232
|
switch (state) {
|
|
4251
|
-
case
|
|
4233
|
+
case import_services9.SpaceState.ACTIVE:
|
|
4252
4234
|
await space.activate();
|
|
4253
4235
|
break;
|
|
4254
|
-
case
|
|
4236
|
+
case import_services9.SpaceState.INACTIVE:
|
|
4255
4237
|
await space.deactivate();
|
|
4256
4238
|
break;
|
|
4257
4239
|
default:
|
|
4258
|
-
throw new
|
|
4240
|
+
throw new import_protocols10.ApiError("Invalid space state");
|
|
4259
4241
|
}
|
|
4260
4242
|
}
|
|
4261
4243
|
}
|
|
4262
4244
|
querySpaces() {
|
|
4263
|
-
return new
|
|
4245
|
+
return new import_codec_protobuf10.Stream(({ next, ctx }) => {
|
|
4264
4246
|
const scheduler = new import_async14.UpdateScheduler(ctx, async () => {
|
|
4265
4247
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4266
4248
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
4267
4249
|
(0, import_log11.log)("update", {
|
|
4268
4250
|
spaces
|
|
4269
4251
|
}, {
|
|
4270
|
-
F:
|
|
4252
|
+
F: __dxlog_file13,
|
|
4271
4253
|
L: 77,
|
|
4272
4254
|
S: this,
|
|
4273
4255
|
C: (f, a) => f(...a)
|
|
@@ -4307,14 +4289,14 @@ var SpacesServiceImpl = class {
|
|
|
4307
4289
|
}
|
|
4308
4290
|
async postMessage({ spaceKey, channel, message }) {
|
|
4309
4291
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4310
|
-
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));
|
|
4311
4293
|
await space.postMessage(getChannelId(channel), message);
|
|
4312
4294
|
}
|
|
4313
4295
|
subscribeMessages({ spaceKey, channel }) {
|
|
4314
|
-
return new
|
|
4296
|
+
return new import_codec_protobuf10.Stream(({ ctx, next }) => {
|
|
4315
4297
|
(0, import_async14.scheduleTask)(ctx, async () => {
|
|
4316
4298
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4317
|
-
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));
|
|
4318
4300
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
4319
4301
|
next(message);
|
|
4320
4302
|
});
|
|
@@ -4323,8 +4305,8 @@ var SpacesServiceImpl = class {
|
|
|
4323
4305
|
});
|
|
4324
4306
|
}
|
|
4325
4307
|
queryCredentials({ spaceKey, noTail }) {
|
|
4326
|
-
return new
|
|
4327
|
-
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));
|
|
4328
4310
|
const processor = {
|
|
4329
4311
|
processCredential: async (credential) => {
|
|
4330
4312
|
next(credential);
|
|
@@ -4340,7 +4322,7 @@ var SpacesServiceImpl = class {
|
|
|
4340
4322
|
});
|
|
4341
4323
|
}
|
|
4342
4324
|
async writeCredentials({ spaceKey, credentials }) {
|
|
4343
|
-
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));
|
|
4344
4326
|
for (const credential of credentials ?? []) {
|
|
4345
4327
|
if (credential.proof) {
|
|
4346
4328
|
await space.controlPipeline.writer.write({
|
|
@@ -4349,8 +4331,8 @@ var SpacesServiceImpl = class {
|
|
|
4349
4331
|
}
|
|
4350
4332
|
});
|
|
4351
4333
|
} else {
|
|
4352
|
-
(0,
|
|
4353
|
-
F:
|
|
4334
|
+
(0, import_invariant12.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
4335
|
+
F: __dxlog_file13,
|
|
4354
4336
|
L: 164,
|
|
4355
4337
|
S: this,
|
|
4356
4338
|
A: [
|
|
@@ -4358,8 +4340,8 @@ var SpacesServiceImpl = class {
|
|
|
4358
4340
|
"'Id on unsigned credentials is not allowed'"
|
|
4359
4341
|
]
|
|
4360
4342
|
});
|
|
4361
|
-
(0,
|
|
4362
|
-
F:
|
|
4343
|
+
(0, import_invariant12.invariant)(this._identityManager.identity, "Identity is not available", {
|
|
4344
|
+
F: __dxlog_file13,
|
|
4363
4345
|
L: 165,
|
|
4364
4346
|
S: this,
|
|
4365
4347
|
A: [
|
|
@@ -4368,8 +4350,8 @@ var SpacesServiceImpl = class {
|
|
|
4368
4350
|
]
|
|
4369
4351
|
});
|
|
4370
4352
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
4371
|
-
(0,
|
|
4372
|
-
F:
|
|
4353
|
+
(0, import_invariant12.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
4354
|
+
F: __dxlog_file13,
|
|
4373
4355
|
L: 167,
|
|
4374
4356
|
S: this,
|
|
4375
4357
|
A: [
|
|
@@ -4391,7 +4373,7 @@ var SpacesServiceImpl = class {
|
|
|
4391
4373
|
}
|
|
4392
4374
|
async createEpoch({ spaceKey, migration }) {
|
|
4393
4375
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4394
|
-
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));
|
|
4395
4377
|
await space.createEpoch({
|
|
4396
4378
|
migration
|
|
4397
4379
|
});
|
|
@@ -4400,7 +4382,7 @@ var SpacesServiceImpl = class {
|
|
|
4400
4382
|
return {
|
|
4401
4383
|
spaceKey: space.key,
|
|
4402
4384
|
state: space.state,
|
|
4403
|
-
error: space.error ? (0,
|
|
4385
|
+
error: space.error ? (0, import_protocols10.encodeError)(space.error) : void 0,
|
|
4404
4386
|
pipeline: {
|
|
4405
4387
|
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
4406
4388
|
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
@@ -4425,7 +4407,7 @@ var SpacesServiceImpl = class {
|
|
|
4425
4407
|
identityKey: member.key,
|
|
4426
4408
|
profile: member.profile ?? {}
|
|
4427
4409
|
},
|
|
4428
|
-
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,
|
|
4429
4411
|
peerStates: peers
|
|
4430
4412
|
};
|
|
4431
4413
|
}),
|
|
@@ -4444,9 +4426,11 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
4444
4426
|
// TODO(mykola): Unload automerge handles after usage.
|
|
4445
4427
|
async function* loadDocuments(ids) {
|
|
4446
4428
|
for (const id of ids) {
|
|
4447
|
-
const { documentId, objectId } =
|
|
4448
|
-
const handle = automergeHost.repo.find(documentId);
|
|
4449
|
-
|
|
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
|
+
}
|
|
4450
4434
|
const doc = handle.docSync();
|
|
4451
4435
|
const hash = (0, import_automerge.getHeads)(doc).join("");
|
|
4452
4436
|
yield doc.objects?.[objectId] ? [
|
|
@@ -4471,13 +4455,15 @@ var createDocumentsIterator = (automergeHost) => (
|
|
|
4471
4455
|
if (visited.has(handle.documentId)) {
|
|
4472
4456
|
return;
|
|
4473
4457
|
}
|
|
4474
|
-
|
|
4458
|
+
if (!handle.isReady()) {
|
|
4459
|
+
await handle.whenReady();
|
|
4460
|
+
}
|
|
4475
4461
|
const doc = handle.docSync();
|
|
4476
4462
|
const heads = (0, import_automerge.getHeads)(doc);
|
|
4477
4463
|
if (doc.objects) {
|
|
4478
4464
|
yield Object.entries(doc.objects).map(([objectId, object]) => {
|
|
4479
4465
|
return {
|
|
4480
|
-
id:
|
|
4466
|
+
id: import_protocols12.idCodec.encode({
|
|
4481
4467
|
documentId: handle.documentId,
|
|
4482
4468
|
objectId
|
|
4483
4469
|
}),
|
|
@@ -4491,7 +4477,7 @@ var createDocumentsIterator = (automergeHost) => (
|
|
|
4491
4477
|
if (visited.has(id)) {
|
|
4492
4478
|
continue;
|
|
4493
4479
|
}
|
|
4494
|
-
const linkHandle = automergeHost.repo.find(id);
|
|
4480
|
+
const linkHandle = automergeHost.repo.handles[id] ?? automergeHost.repo.find(id);
|
|
4495
4481
|
for await (const result of getObjectsFromHandle(linkHandle)) {
|
|
4496
4482
|
yield result;
|
|
4497
4483
|
}
|
|
@@ -4520,8 +4506,8 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4520
4506
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4521
4507
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4522
4508
|
}
|
|
4523
|
-
var
|
|
4524
|
-
var ServiceContext = class extends
|
|
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 {
|
|
4525
4511
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
4526
4512
|
super();
|
|
4527
4513
|
this.storage = storage;
|
|
@@ -4532,8 +4518,8 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4532
4518
|
this.initialized = new import_async15.Trigger();
|
|
4533
4519
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4534
4520
|
this._instanceId = import_keys10.PublicKey.random().toHex();
|
|
4535
|
-
this.metadataStore = new
|
|
4536
|
-
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"));
|
|
4537
4523
|
this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
|
|
4538
4524
|
this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
|
|
4539
4525
|
this.feedStore = new import_feed_store4.FeedStore({
|
|
@@ -4541,12 +4527,12 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4541
4527
|
root: storage.createDirectory("feeds"),
|
|
4542
4528
|
signer: this.keyring,
|
|
4543
4529
|
hypercore: {
|
|
4544
|
-
valueEncoding:
|
|
4530
|
+
valueEncoding: import_echo_pipeline4.valueEncoding,
|
|
4545
4531
|
stats: true
|
|
4546
4532
|
}
|
|
4547
4533
|
})
|
|
4548
4534
|
});
|
|
4549
|
-
this.spaceManager = new
|
|
4535
|
+
this.spaceManager = new import_echo_pipeline4.SpaceManager({
|
|
4550
4536
|
feedStore: this.feedStore,
|
|
4551
4537
|
networkManager: this.networkManager,
|
|
4552
4538
|
blobStore: this.blobStore,
|
|
@@ -4557,64 +4543,79 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4557
4543
|
this.indexMetadata = new import_indexing.IndexMetadataStore({
|
|
4558
4544
|
db: level.sublevel("index-metadata")
|
|
4559
4545
|
});
|
|
4560
|
-
this.automergeHost = new
|
|
4546
|
+
this.automergeHost = new import_echo_pipeline4.AutomergeHost({
|
|
4561
4547
|
directory: storage.createDirectory("automerge"),
|
|
4562
|
-
|
|
4548
|
+
db: level.sublevel("automerge"),
|
|
4549
|
+
storageCallbacks: (0, import_indexing.createStorageCallbacks)({
|
|
4550
|
+
host: () => this.automergeHost,
|
|
4551
|
+
metadata: this.indexMetadata
|
|
4552
|
+
})
|
|
4563
4553
|
});
|
|
4564
4554
|
this.indexer = new import_indexing.Indexer({
|
|
4565
4555
|
indexStore: new import_indexing.IndexStore({
|
|
4566
|
-
|
|
4556
|
+
db: level.sublevel("index-storage")
|
|
4567
4557
|
}),
|
|
4568
4558
|
metadataStore: this.indexMetadata,
|
|
4569
4559
|
loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
|
|
4570
4560
|
getAllDocuments: createDocumentsIterator(this.automergeHost)
|
|
4571
4561
|
});
|
|
4572
4562
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4573
|
-
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)));
|
|
4574
4565
|
}
|
|
4575
4566
|
async _open(ctx) {
|
|
4576
4567
|
await this._checkStorageVersion();
|
|
4577
4568
|
(0, import_log12.log)("opening...", void 0, {
|
|
4578
|
-
F:
|
|
4579
|
-
L:
|
|
4569
|
+
F: __dxlog_file14,
|
|
4570
|
+
L: 164,
|
|
4580
4571
|
S: this,
|
|
4581
4572
|
C: (f, a) => f(...a)
|
|
4582
4573
|
});
|
|
4583
|
-
import_log12.log.trace("dxos.sdk.service-context.open",
|
|
4574
|
+
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.begin({
|
|
4584
4575
|
id: this._instanceId
|
|
4585
4576
|
}), {
|
|
4586
|
-
F:
|
|
4587
|
-
L:
|
|
4577
|
+
F: __dxlog_file14,
|
|
4578
|
+
L: 165,
|
|
4588
4579
|
S: this,
|
|
4589
4580
|
C: (f, a) => f(...a)
|
|
4590
4581
|
});
|
|
4591
4582
|
await this.signalManager.open();
|
|
4592
4583
|
await this.networkManager.open();
|
|
4584
|
+
await this.automergeHost.open();
|
|
4593
4585
|
await this.metadataStore.load();
|
|
4594
4586
|
await this.spaceManager.open();
|
|
4595
4587
|
await this.identityManager.open(ctx);
|
|
4596
4588
|
if (this.identityManager.identity) {
|
|
4597
4589
|
await this._initialize(ctx);
|
|
4598
4590
|
}
|
|
4599
|
-
|
|
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({
|
|
4600
4601
|
id: this._instanceId
|
|
4601
4602
|
}), {
|
|
4602
|
-
F:
|
|
4603
|
-
L:
|
|
4603
|
+
F: __dxlog_file14,
|
|
4604
|
+
L: 180,
|
|
4604
4605
|
S: this,
|
|
4605
4606
|
C: (f, a) => f(...a)
|
|
4606
4607
|
});
|
|
4607
4608
|
(0, import_log12.log)("opened", void 0, {
|
|
4608
|
-
F:
|
|
4609
|
-
L:
|
|
4609
|
+
F: __dxlog_file14,
|
|
4610
|
+
L: 181,
|
|
4610
4611
|
S: this,
|
|
4611
4612
|
C: (f, a) => f(...a)
|
|
4612
4613
|
});
|
|
4613
4614
|
}
|
|
4614
4615
|
async _close() {
|
|
4615
4616
|
(0, import_log12.log)("closing...", void 0, {
|
|
4616
|
-
F:
|
|
4617
|
-
L:
|
|
4617
|
+
F: __dxlog_file14,
|
|
4618
|
+
L: 185,
|
|
4618
4619
|
S: this,
|
|
4619
4620
|
C: (f, a) => f(...a)
|
|
4620
4621
|
});
|
|
@@ -4631,22 +4632,22 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4631
4632
|
await this.metadataStore.close();
|
|
4632
4633
|
await this.indexer.destroy();
|
|
4633
4634
|
(0, import_log12.log)("closed", void 0, {
|
|
4634
|
-
F:
|
|
4635
|
-
L:
|
|
4635
|
+
F: __dxlog_file14,
|
|
4636
|
+
L: 198,
|
|
4636
4637
|
S: this,
|
|
4637
4638
|
C: (f, a) => f(...a)
|
|
4638
4639
|
});
|
|
4639
4640
|
}
|
|
4640
4641
|
async createIdentity(params = {}) {
|
|
4641
4642
|
const identity = await this.identityManager.createIdentity(params);
|
|
4642
|
-
await this._initialize(new
|
|
4643
|
+
await this._initialize(new import_context9.Context());
|
|
4643
4644
|
return identity;
|
|
4644
4645
|
}
|
|
4645
4646
|
getInvitationHandler(invitation) {
|
|
4646
4647
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4647
|
-
(0,
|
|
4648
|
-
F:
|
|
4649
|
-
L:
|
|
4648
|
+
(0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4649
|
+
F: __dxlog_file14,
|
|
4650
|
+
L: 209,
|
|
4650
4651
|
S: this,
|
|
4651
4652
|
A: [
|
|
4652
4653
|
"factory",
|
|
@@ -4665,20 +4666,20 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4665
4666
|
}
|
|
4666
4667
|
async _acceptIdentity(params) {
|
|
4667
4668
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
4668
|
-
await this._initialize(new
|
|
4669
|
+
await this._initialize(new import_context9.Context());
|
|
4669
4670
|
return identity;
|
|
4670
4671
|
}
|
|
4671
4672
|
async _checkStorageVersion() {
|
|
4672
4673
|
await this.metadataStore.load();
|
|
4673
|
-
if (this.metadataStore.version !==
|
|
4674
|
-
throw new
|
|
4674
|
+
if (this.metadataStore.version !== import_protocols11.STORAGE_VERSION) {
|
|
4675
|
+
throw new import_protocols11.InvalidStorageVersionError(import_protocols11.STORAGE_VERSION, this.metadataStore.version);
|
|
4675
4676
|
}
|
|
4676
4677
|
}
|
|
4677
4678
|
// Called when identity is created.
|
|
4678
4679
|
async _initialize(ctx) {
|
|
4679
4680
|
(0, import_log12.log)("initializing spaces...", void 0, {
|
|
4680
|
-
F:
|
|
4681
|
-
L:
|
|
4681
|
+
F: __dxlog_file14,
|
|
4682
|
+
L: 240,
|
|
4682
4683
|
S: this,
|
|
4683
4684
|
C: (f, a) => f(...a)
|
|
4684
4685
|
});
|
|
@@ -4698,10 +4699,10 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4698
4699
|
};
|
|
4699
4700
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
|
|
4700
4701
|
await this.dataSpaceManager.open();
|
|
4701
|
-
this._handlerFactories.set(
|
|
4702
|
-
(0,
|
|
4703
|
-
F:
|
|
4704
|
-
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,
|
|
4705
4706
|
S: this,
|
|
4706
4707
|
A: [
|
|
4707
4708
|
"this.dataSpaceManager",
|
|
@@ -4713,7 +4714,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4713
4714
|
this.initialized.wake();
|
|
4714
4715
|
this._deviceSpaceSync = {
|
|
4715
4716
|
processCredential: async (credential) => {
|
|
4716
|
-
const assertion = (0,
|
|
4717
|
+
const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
|
|
4717
4718
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
4718
4719
|
return;
|
|
4719
4720
|
}
|
|
@@ -4724,8 +4725,8 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4724
4725
|
(0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
4725
4726
|
details: assertion
|
|
4726
4727
|
}, {
|
|
4727
|
-
F:
|
|
4728
|
-
L:
|
|
4728
|
+
F: __dxlog_file14,
|
|
4729
|
+
L: 280,
|
|
4729
4730
|
S: this,
|
|
4730
4731
|
C: (f, a) => f(...a)
|
|
4731
4732
|
});
|
|
@@ -4735,8 +4736,8 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4735
4736
|
(0, import_log12.log)("space already exists, ignoring space admission", {
|
|
4736
4737
|
details: assertion
|
|
4737
4738
|
}, {
|
|
4738
|
-
F:
|
|
4739
|
-
L:
|
|
4739
|
+
F: __dxlog_file14,
|
|
4740
|
+
L: 284,
|
|
4740
4741
|
S: this,
|
|
4741
4742
|
C: (f, a) => f(...a)
|
|
4742
4743
|
});
|
|
@@ -4746,8 +4747,8 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4746
4747
|
(0, import_log12.log)("accepting space recorded in halo", {
|
|
4747
4748
|
details: assertion
|
|
4748
4749
|
}, {
|
|
4749
|
-
F:
|
|
4750
|
-
L:
|
|
4750
|
+
F: __dxlog_file14,
|
|
4751
|
+
L: 289,
|
|
4751
4752
|
S: this,
|
|
4752
4753
|
C: (f, a) => f(...a)
|
|
4753
4754
|
});
|
|
@@ -4757,8 +4758,8 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4757
4758
|
});
|
|
4758
4759
|
} catch (err) {
|
|
4759
4760
|
import_log12.log.catch(err, void 0, {
|
|
4760
|
-
F:
|
|
4761
|
-
L:
|
|
4761
|
+
F: __dxlog_file14,
|
|
4762
|
+
L: 295,
|
|
4762
4763
|
S: this,
|
|
4763
4764
|
C: (f, a) => f(...a)
|
|
4764
4765
|
});
|
|
@@ -4769,14 +4770,14 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4769
4770
|
}
|
|
4770
4771
|
};
|
|
4771
4772
|
_ts_decorate6([
|
|
4772
|
-
|
|
4773
|
+
import_tracing5.trace.span()
|
|
4773
4774
|
], ServiceContext.prototype, "_open", null);
|
|
4774
4775
|
_ts_decorate6([
|
|
4775
|
-
|
|
4776
|
+
import_tracing5.trace.span()
|
|
4776
4777
|
], ServiceContext.prototype, "_initialize", null);
|
|
4777
4778
|
ServiceContext = _ts_decorate6([
|
|
4778
4779
|
(0, import_util7.safeInstanceof)("dxos.client-services.ServiceContext"),
|
|
4779
|
-
|
|
4780
|
+
import_tracing5.trace.resource()
|
|
4780
4781
|
], ServiceContext);
|
|
4781
4782
|
var ServiceRegistry = class {
|
|
4782
4783
|
// prettier-ignore
|
|
@@ -4800,118 +4801,155 @@ var ServiceRegistry = class {
|
|
|
4800
4801
|
delete this._handlers[name];
|
|
4801
4802
|
}
|
|
4802
4803
|
};
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
if (
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
}
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
}
|
|
4820
|
-
|
|
4821
|
-
return
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
});
|
|
4830
|
-
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
4831
|
-
await this._onAcquire?.();
|
|
4832
|
-
(0, import_log13.log)("acquired lock", void 0, {
|
|
4833
|
-
F: __dxlog_file16,
|
|
4834
|
-
L: 37,
|
|
4835
|
-
S: this,
|
|
4836
|
-
C: (f, a) => f(...a)
|
|
4837
|
-
});
|
|
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
|
+
};
|
|
4838
4830
|
}
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
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,
|
|
4845
4851
|
A: [
|
|
4846
|
-
"
|
|
4847
|
-
"'
|
|
4852
|
+
"clientServices.LoggingService",
|
|
4853
|
+
"'SystemService is not available.'"
|
|
4848
4854
|
]
|
|
4849
4855
|
});
|
|
4850
|
-
await
|
|
4851
|
-
|
|
4852
|
-
};
|
|
4853
|
-
_ts_decorate7([
|
|
4854
|
-
import_log13.logInfo
|
|
4855
|
-
], Lock.prototype, "lockKey", null);
|
|
4856
|
-
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
4857
|
-
var getRootPath = (config) => {
|
|
4858
|
-
const { dataRoot = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage" } = config ?? {};
|
|
4859
|
-
return `${dataRoot}/`;
|
|
4860
|
-
};
|
|
4861
|
-
var isPersistent = (config) => {
|
|
4862
|
-
const { persistent = false } = config ?? {};
|
|
4863
|
-
return config.dataStore !== void 0 && config.dataStore !== import_config2.Runtime.Client.Storage.StorageDriver.RAM || persistent;
|
|
4864
|
-
};
|
|
4865
|
-
var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
4866
|
-
var createStorageObjects = (config) => {
|
|
4867
|
-
const { persistent = false, keyStore, dataStore } = config ?? {};
|
|
4868
|
-
if (persistent && dataStore === StorageDriver.RAM) {
|
|
4869
|
-
throw new import_protocols14.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
4856
|
+
diagnostics.metrics = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
|
|
4857
|
+
timeout: DEFAULT_TIMEOUT
|
|
4858
|
+
}).catch(() => void 0);
|
|
4870
4859
|
}
|
|
4871
|
-
if (
|
|
4872
|
-
|
|
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
|
+
}));
|
|
4873
4874
|
}
|
|
4874
|
-
|
|
4875
|
-
|
|
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;
|
|
4876
4902
|
}
|
|
4877
|
-
|
|
4878
|
-
|
|
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();
|
|
4879
4936
|
}
|
|
4937
|
+
return stats;
|
|
4938
|
+
};
|
|
4939
|
+
var createCollectDiagnosticsBroadcastSender = () => {
|
|
4880
4940
|
return {
|
|
4881
|
-
|
|
4882
|
-
type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
|
|
4883
|
-
root: getRootPath(config)
|
|
4884
|
-
})
|
|
4941
|
+
broadcastDiagnosticsRequest: async () => void 0
|
|
4885
4942
|
};
|
|
4886
4943
|
};
|
|
4887
|
-
var
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
return import_random_access_storage.StorageType.CHROME;
|
|
4895
|
-
case StorageDriver.FIREFOX:
|
|
4896
|
-
return import_random_access_storage.StorageType.FIREFOX;
|
|
4897
|
-
case StorageDriver.IDB:
|
|
4898
|
-
return import_random_access_storage.StorageType.IDB;
|
|
4899
|
-
case StorageDriver.NODE:
|
|
4900
|
-
return import_random_access_storage.StorageType.NODE;
|
|
4901
|
-
case StorageDriver.WEBFS:
|
|
4902
|
-
return import_random_access_storage.StorageType.WEBFS;
|
|
4903
|
-
default:
|
|
4904
|
-
throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
|
|
4905
|
-
}
|
|
4906
|
-
};
|
|
4907
|
-
var createLevel = async (config) => {
|
|
4908
|
-
const persistent = isPersistent(config);
|
|
4909
|
-
const storagePath = persistent ? getRootPath(config) : import_node_path.default.join("tmp", "level", import_keys11.PublicKey.random().toHex());
|
|
4910
|
-
const level = new import_level.Level(storagePath);
|
|
4911
|
-
await level.open();
|
|
4912
|
-
return level;
|
|
4944
|
+
var createCollectDiagnosticsBroadcastHandler = (_) => {
|
|
4945
|
+
return {
|
|
4946
|
+
start: () => {
|
|
4947
|
+
},
|
|
4948
|
+
stop: () => {
|
|
4949
|
+
}
|
|
4950
|
+
};
|
|
4913
4951
|
};
|
|
4914
|
-
var
|
|
4952
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
4915
4953
|
var DevicesServiceImpl = class {
|
|
4916
4954
|
constructor(_identityManager) {
|
|
4917
4955
|
this._identityManager = _identityManager;
|
|
@@ -4928,8 +4966,8 @@ var DevicesServiceImpl = class {
|
|
|
4928
4966
|
devices: []
|
|
4929
4967
|
});
|
|
4930
4968
|
} else {
|
|
4931
|
-
(0,
|
|
4932
|
-
F:
|
|
4969
|
+
(0, import_invariant16.invariant)(this._identityManager.identity?.presence, "presence not present", {
|
|
4970
|
+
F: __dxlog_file16,
|
|
4933
4971
|
L: 32,
|
|
4934
4972
|
S: this,
|
|
4935
4973
|
A: [
|
|
@@ -4944,9 +4982,9 @@ var DevicesServiceImpl = class {
|
|
|
4944
4982
|
const peerState = peers.find((peer) => peer.identityKey.equals(key));
|
|
4945
4983
|
return {
|
|
4946
4984
|
deviceKey: key,
|
|
4947
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ?
|
|
4985
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services15.DeviceKind.CURRENT : import_services15.DeviceKind.TRUSTED,
|
|
4948
4986
|
profile,
|
|
4949
|
-
presence: isMe ?
|
|
4987
|
+
presence: isMe ? import_services15.Device.PresenceState.ONLINE : peerState ? import_services15.Device.PresenceState.ONLINE : import_services15.Device.PresenceState.OFFLINE
|
|
4950
4988
|
};
|
|
4951
4989
|
})
|
|
4952
4990
|
});
|
|
@@ -4987,11 +5025,65 @@ var DevicesServiceImpl = class {
|
|
|
4987
5025
|
});
|
|
4988
5026
|
}
|
|
4989
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);
|
|
4990
5082
|
var LoggingServiceImpl = class {
|
|
4991
5083
|
constructor() {
|
|
4992
5084
|
this._logs = new import_async18.Event();
|
|
4993
5085
|
this._started = Date.now();
|
|
4994
|
-
this._sessionId =
|
|
5086
|
+
this._sessionId = import_keys12.PublicKey.random().toHex();
|
|
4995
5087
|
this._logProcessor = (_config, entry2) => {
|
|
4996
5088
|
this._logs.emit(entry2);
|
|
4997
5089
|
};
|
|
@@ -5088,16 +5180,16 @@ var LoggingServiceImpl = class {
|
|
|
5088
5180
|
};
|
|
5089
5181
|
var matchFilter = (filter, level, path2, options) => {
|
|
5090
5182
|
switch (options) {
|
|
5091
|
-
case
|
|
5183
|
+
case import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
5092
5184
|
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5093
|
-
case
|
|
5185
|
+
case import_services16.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
5094
5186
|
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5095
5187
|
}
|
|
5096
5188
|
};
|
|
5097
5189
|
var shouldLog = (entry2, request) => {
|
|
5098
|
-
const options = request.options ??
|
|
5190
|
+
const options = request.options ?? import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5099
5191
|
if (request.filters === void 0) {
|
|
5100
|
-
return options ===
|
|
5192
|
+
return options === import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5101
5193
|
} else {
|
|
5102
5194
|
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
5103
5195
|
}
|
|
@@ -5133,6 +5225,63 @@ var NetworkServiceImpl = class {
|
|
|
5133
5225
|
await this.networkManager.setConnectionState(request.swarm);
|
|
5134
5226
|
}
|
|
5135
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
|
+
};
|
|
5136
5285
|
var SystemServiceImpl = class {
|
|
5137
5286
|
constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
5138
5287
|
this._config = config;
|
|
@@ -5152,9 +5301,9 @@ var SystemServiceImpl = class {
|
|
|
5152
5301
|
const diagnostics = await this._getDiagnostics();
|
|
5153
5302
|
return {
|
|
5154
5303
|
timestamp: /* @__PURE__ */ new Date(),
|
|
5155
|
-
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0,
|
|
5156
|
-
truncate: keys ===
|
|
5157
|
-
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
|
|
5158
5307
|
})))
|
|
5159
5308
|
};
|
|
5160
5309
|
}
|
|
@@ -5202,16 +5351,18 @@ var ClientServicesHost = class {
|
|
|
5202
5351
|
transportFactory,
|
|
5203
5352
|
signalManager,
|
|
5204
5353
|
storage,
|
|
5354
|
+
level,
|
|
5205
5355
|
// TODO(wittjosiah): Turn this on by default.
|
|
5206
5356
|
lockKey,
|
|
5207
5357
|
callbacks,
|
|
5208
5358
|
runtimeParams
|
|
5209
5359
|
} = {}) {
|
|
5210
|
-
this._tracingService =
|
|
5360
|
+
this._tracingService = import_tracing8.TRACE_PROCESSOR.createTraceSender();
|
|
5211
5361
|
this._statusUpdate = new import_async16.Event();
|
|
5212
5362
|
this._opening = false;
|
|
5213
5363
|
this._open = false;
|
|
5214
5364
|
this._storage = storage;
|
|
5365
|
+
this._level = level;
|
|
5215
5366
|
this._callbacks = callbacks;
|
|
5216
5367
|
this._runtimeParams = runtimeParams;
|
|
5217
5368
|
if (config) {
|
|
@@ -5226,7 +5377,7 @@ var ClientServicesHost = class {
|
|
|
5226
5377
|
lockKey,
|
|
5227
5378
|
onAcquire: () => {
|
|
5228
5379
|
if (!this._opening) {
|
|
5229
|
-
void this.open(new
|
|
5380
|
+
void this.open(new import_context10.Context());
|
|
5230
5381
|
}
|
|
5231
5382
|
},
|
|
5232
5383
|
onRelease: () => this.close()
|
|
@@ -5235,14 +5386,14 @@ var ClientServicesHost = class {
|
|
|
5235
5386
|
this._systemService = new SystemServiceImpl({
|
|
5236
5387
|
config: () => this._config,
|
|
5237
5388
|
statusUpdate: this._statusUpdate,
|
|
5238
|
-
getCurrentStatus: () => this.isOpen ?
|
|
5389
|
+
getCurrentStatus: () => this.isOpen ? import_services14.SystemStatus.ACTIVE : import_services14.SystemStatus.INACTIVE,
|
|
5239
5390
|
getDiagnostics: () => {
|
|
5240
5391
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
5241
5392
|
},
|
|
5242
5393
|
onUpdateStatus: async (status) => {
|
|
5243
|
-
if (!this.isOpen && status ===
|
|
5394
|
+
if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
|
|
5244
5395
|
await this._resourceLock?.acquire();
|
|
5245
|
-
} else if (this.isOpen && status ===
|
|
5396
|
+
} else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
|
|
5246
5397
|
await this._resourceLock?.release();
|
|
5247
5398
|
}
|
|
5248
5399
|
},
|
|
@@ -5250,8 +5401,9 @@ var ClientServicesHost = class {
|
|
|
5250
5401
|
await this.reset();
|
|
5251
5402
|
}
|
|
5252
5403
|
});
|
|
5404
|
+
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
5253
5405
|
this._loggingService = new LoggingServiceImpl();
|
|
5254
|
-
this._serviceRegistry = new ServiceRegistry(
|
|
5406
|
+
this._serviceRegistry = new ServiceRegistry(import_client_protocol4.clientServiceBundle, {
|
|
5255
5407
|
SystemService: this._systemService,
|
|
5256
5408
|
TracingService: this._tracingService
|
|
5257
5409
|
});
|
|
@@ -5280,25 +5432,25 @@ var ClientServicesHost = class {
|
|
|
5280
5432
|
* Can only be called once.
|
|
5281
5433
|
*/
|
|
5282
5434
|
initialize({ config, ...options }) {
|
|
5283
|
-
(0,
|
|
5435
|
+
(0, import_invariant15.invariant)(!this._open, "service host is open", {
|
|
5284
5436
|
F: __dxlog_file18,
|
|
5285
|
-
L:
|
|
5437
|
+
L: 198,
|
|
5286
5438
|
S: this,
|
|
5287
5439
|
A: [
|
|
5288
5440
|
"!this._open",
|
|
5289
5441
|
"'service host is open'"
|
|
5290
5442
|
]
|
|
5291
5443
|
});
|
|
5292
|
-
(0,
|
|
5444
|
+
(0, import_log13.log)("initializing...", void 0, {
|
|
5293
5445
|
F: __dxlog_file18,
|
|
5294
|
-
L:
|
|
5446
|
+
L: 199,
|
|
5295
5447
|
S: this,
|
|
5296
5448
|
C: (f, a) => f(...a)
|
|
5297
5449
|
});
|
|
5298
5450
|
if (config) {
|
|
5299
|
-
(0,
|
|
5451
|
+
(0, import_invariant15.invariant)(!this._config, "config already set", {
|
|
5300
5452
|
F: __dxlog_file18,
|
|
5301
|
-
L:
|
|
5453
|
+
L: 202,
|
|
5302
5454
|
S: this,
|
|
5303
5455
|
A: [
|
|
5304
5456
|
"!this._config",
|
|
@@ -5311,9 +5463,9 @@ var ClientServicesHost = class {
|
|
|
5311
5463
|
}
|
|
5312
5464
|
}
|
|
5313
5465
|
if (!options.signalManager) {
|
|
5314
|
-
|
|
5466
|
+
import_log13.log.warn("running signaling without telemetry metadata.", void 0, {
|
|
5315
5467
|
F: __dxlog_file18,
|
|
5316
|
-
L:
|
|
5468
|
+
L: 210,
|
|
5317
5469
|
S: this,
|
|
5318
5470
|
C: (f, a) => f(...a)
|
|
5319
5471
|
});
|
|
@@ -5322,9 +5474,9 @@ var ClientServicesHost = class {
|
|
|
5322
5474
|
iceServers: this._config?.get("runtime.services.ice")
|
|
5323
5475
|
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
5324
5476
|
this._signalManager = signalManager;
|
|
5325
|
-
(0,
|
|
5477
|
+
(0, import_invariant15.invariant)(!this._networkManager, "network manager already set", {
|
|
5326
5478
|
F: __dxlog_file18,
|
|
5327
|
-
L:
|
|
5479
|
+
L: 221,
|
|
5328
5480
|
S: this,
|
|
5329
5481
|
A: [
|
|
5330
5482
|
"!this._networkManager",
|
|
@@ -5336,9 +5488,9 @@ var ClientServicesHost = class {
|
|
|
5336
5488
|
transportFactory,
|
|
5337
5489
|
signalManager
|
|
5338
5490
|
});
|
|
5339
|
-
(0,
|
|
5491
|
+
(0, import_log13.log)("initialized", void 0, {
|
|
5340
5492
|
F: __dxlog_file18,
|
|
5341
|
-
L:
|
|
5493
|
+
L: 228,
|
|
5342
5494
|
S: this,
|
|
5343
5495
|
C: (f, a) => f(...a)
|
|
5344
5496
|
});
|
|
@@ -5347,45 +5499,45 @@ var ClientServicesHost = class {
|
|
|
5347
5499
|
if (this._open) {
|
|
5348
5500
|
return;
|
|
5349
5501
|
}
|
|
5350
|
-
const traceId =
|
|
5351
|
-
|
|
5502
|
+
const traceId = import_keys11.PublicKey.random().toHex();
|
|
5503
|
+
import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.begin({
|
|
5352
5504
|
id: traceId
|
|
5353
5505
|
}), {
|
|
5354
5506
|
F: __dxlog_file18,
|
|
5355
|
-
L:
|
|
5507
|
+
L: 239,
|
|
5356
5508
|
S: this,
|
|
5357
5509
|
C: (f, a) => f(...a)
|
|
5358
5510
|
});
|
|
5359
|
-
(0,
|
|
5511
|
+
(0, import_invariant15.invariant)(this._config, "config not set", {
|
|
5360
5512
|
F: __dxlog_file18,
|
|
5361
|
-
L:
|
|
5513
|
+
L: 241,
|
|
5362
5514
|
S: this,
|
|
5363
5515
|
A: [
|
|
5364
5516
|
"this._config",
|
|
5365
5517
|
"'config not set'"
|
|
5366
5518
|
]
|
|
5367
5519
|
});
|
|
5368
|
-
(0,
|
|
5520
|
+
(0, import_invariant15.invariant)(this._storage, "storage not set", {
|
|
5369
5521
|
F: __dxlog_file18,
|
|
5370
|
-
L:
|
|
5522
|
+
L: 242,
|
|
5371
5523
|
S: this,
|
|
5372
5524
|
A: [
|
|
5373
5525
|
"this._storage",
|
|
5374
5526
|
"'storage not set'"
|
|
5375
5527
|
]
|
|
5376
5528
|
});
|
|
5377
|
-
(0,
|
|
5529
|
+
(0, import_invariant15.invariant)(this._signalManager, "signal manager not set", {
|
|
5378
5530
|
F: __dxlog_file18,
|
|
5379
|
-
L:
|
|
5531
|
+
L: 243,
|
|
5380
5532
|
S: this,
|
|
5381
5533
|
A: [
|
|
5382
5534
|
"this._signalManager",
|
|
5383
5535
|
"'signal manager not set'"
|
|
5384
5536
|
]
|
|
5385
5537
|
});
|
|
5386
|
-
(0,
|
|
5538
|
+
(0, import_invariant15.invariant)(this._networkManager, "network manager not set", {
|
|
5387
5539
|
F: __dxlog_file18,
|
|
5388
|
-
L:
|
|
5540
|
+
L: 244,
|
|
5389
5541
|
S: this,
|
|
5390
5542
|
A: [
|
|
5391
5543
|
"this._networkManager",
|
|
@@ -5393,34 +5545,37 @@ var ClientServicesHost = class {
|
|
|
5393
5545
|
]
|
|
5394
5546
|
});
|
|
5395
5547
|
this._opening = true;
|
|
5396
|
-
(0,
|
|
5548
|
+
(0, import_log13.log)("opening...", {
|
|
5397
5549
|
lockKey: this._resourceLock?.lockKey
|
|
5398
5550
|
}, {
|
|
5399
5551
|
F: __dxlog_file18,
|
|
5400
|
-
L:
|
|
5552
|
+
L: 247,
|
|
5401
5553
|
S: this,
|
|
5402
5554
|
C: (f, a) => f(...a)
|
|
5403
5555
|
});
|
|
5404
5556
|
if (!this._level) {
|
|
5405
5557
|
this._level = await createLevel(this._config.get("runtime.client.storage", {}));
|
|
5406
5558
|
}
|
|
5559
|
+
await this._level.open();
|
|
5407
5560
|
await this._resourceLock?.acquire();
|
|
5408
5561
|
await this._loggingService.open();
|
|
5409
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);
|
|
5410
5568
|
this._serviceRegistry.setServices({
|
|
5411
5569
|
SystemService: this._systemService,
|
|
5412
5570
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
5413
|
-
InvitationsService: new InvitationsServiceImpl(this._serviceContext.
|
|
5571
|
+
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
|
|
5414
5572
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
5415
5573
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
|
|
5416
5574
|
await this._serviceContext.initialized.wait();
|
|
5417
5575
|
return this._serviceContext.dataSpaceManager;
|
|
5418
5576
|
}),
|
|
5419
|
-
DataService: new
|
|
5420
|
-
|
|
5421
|
-
indexer: this._serviceContext.indexer,
|
|
5422
|
-
automergeHost: this._serviceContext.automergeHost
|
|
5423
|
-
}),
|
|
5577
|
+
DataService: new import_echo_pipeline5.DataServiceImpl(this._serviceContext.automergeHost),
|
|
5578
|
+
QueryService: this._queryService,
|
|
5424
5579
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
5425
5580
|
LoggingService: this._loggingService,
|
|
5426
5581
|
TracingService: this._tracingService,
|
|
@@ -5432,51 +5587,34 @@ var ClientServicesHost = class {
|
|
|
5432
5587
|
})
|
|
5433
5588
|
});
|
|
5434
5589
|
await this._serviceContext.open(ctx);
|
|
5435
|
-
(0, import_invariant16.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5436
|
-
F: __dxlog_file18,
|
|
5437
|
-
L: 297,
|
|
5438
|
-
S: this,
|
|
5439
|
-
A: [
|
|
5440
|
-
"this.serviceRegistry.services.InvitationsService",
|
|
5441
|
-
""
|
|
5442
|
-
]
|
|
5443
|
-
});
|
|
5444
|
-
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5445
|
-
(0, import_log14.log)("loaded persistent invitations", {
|
|
5446
|
-
count: loadedInvitations.invitations?.length
|
|
5447
|
-
}, {
|
|
5448
|
-
F: __dxlog_file18,
|
|
5449
|
-
L: 300,
|
|
5450
|
-
S: this,
|
|
5451
|
-
C: (f, a) => f(...a)
|
|
5452
|
-
});
|
|
5453
5590
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
5454
5591
|
if (devtoolsProxy) {
|
|
5455
5592
|
this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
|
|
5456
5593
|
url: devtoolsProxy,
|
|
5457
5594
|
requested: {},
|
|
5458
|
-
exposed:
|
|
5595
|
+
exposed: import_client_protocol4.clientServiceBundle,
|
|
5459
5596
|
handlers: this.services
|
|
5460
5597
|
});
|
|
5461
5598
|
void this._devtoolsProxy.open();
|
|
5462
5599
|
}
|
|
5600
|
+
this.diagnosticsBroadcastHandler.start();
|
|
5463
5601
|
this._opening = false;
|
|
5464
5602
|
this._open = true;
|
|
5465
5603
|
this._statusUpdate.emit();
|
|
5466
5604
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5467
|
-
(0,
|
|
5605
|
+
(0, import_log13.log)("opened", {
|
|
5468
5606
|
deviceKey
|
|
5469
5607
|
}, {
|
|
5470
5608
|
F: __dxlog_file18,
|
|
5471
|
-
L:
|
|
5609
|
+
L: 330,
|
|
5472
5610
|
S: this,
|
|
5473
5611
|
C: (f, a) => f(...a)
|
|
5474
5612
|
});
|
|
5475
|
-
|
|
5613
|
+
import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.end({
|
|
5476
5614
|
id: traceId
|
|
5477
5615
|
}), {
|
|
5478
5616
|
F: __dxlog_file18,
|
|
5479
|
-
L:
|
|
5617
|
+
L: 331,
|
|
5480
5618
|
S: this,
|
|
5481
5619
|
C: (f, a) => f(...a)
|
|
5482
5620
|
});
|
|
@@ -5486,61 +5624,63 @@ var ClientServicesHost = class {
|
|
|
5486
5624
|
return;
|
|
5487
5625
|
}
|
|
5488
5626
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5489
|
-
(0,
|
|
5627
|
+
(0, import_log13.log)("closing...", {
|
|
5490
5628
|
deviceKey
|
|
5491
5629
|
}, {
|
|
5492
5630
|
F: __dxlog_file18,
|
|
5493
|
-
L:
|
|
5631
|
+
L: 342,
|
|
5494
5632
|
S: this,
|
|
5495
5633
|
C: (f, a) => f(...a)
|
|
5496
5634
|
});
|
|
5635
|
+
this.diagnosticsBroadcastHandler.stop();
|
|
5497
5636
|
await this._devtoolsProxy?.close();
|
|
5498
5637
|
this._serviceRegistry.setServices({
|
|
5499
5638
|
SystemService: this._systemService
|
|
5500
5639
|
});
|
|
5501
5640
|
await this._loggingService.close();
|
|
5641
|
+
await this._queryService.close();
|
|
5502
5642
|
await this._serviceContext.close();
|
|
5503
5643
|
await this._level?.close();
|
|
5504
5644
|
this._open = false;
|
|
5505
5645
|
this._statusUpdate.emit();
|
|
5506
|
-
(0,
|
|
5646
|
+
(0, import_log13.log)("closed", {
|
|
5507
5647
|
deviceKey
|
|
5508
5648
|
}, {
|
|
5509
5649
|
F: __dxlog_file18,
|
|
5510
|
-
L:
|
|
5650
|
+
L: 352,
|
|
5511
5651
|
S: this,
|
|
5512
5652
|
C: (f, a) => f(...a)
|
|
5513
5653
|
});
|
|
5514
5654
|
}
|
|
5515
5655
|
async reset() {
|
|
5516
|
-
const traceId =
|
|
5517
|
-
|
|
5656
|
+
const traceId = import_keys11.PublicKey.random().toHex();
|
|
5657
|
+
import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.begin({
|
|
5518
5658
|
id: traceId
|
|
5519
5659
|
}), {
|
|
5520
5660
|
F: __dxlog_file18,
|
|
5521
|
-
L:
|
|
5661
|
+
L: 357,
|
|
5522
5662
|
S: this,
|
|
5523
5663
|
C: (f, a) => f(...a)
|
|
5524
5664
|
});
|
|
5525
|
-
(0,
|
|
5665
|
+
(0, import_log13.log)("resetting...", void 0, {
|
|
5526
5666
|
F: __dxlog_file18,
|
|
5527
|
-
L:
|
|
5667
|
+
L: 359,
|
|
5528
5668
|
S: this,
|
|
5529
5669
|
C: (f, a) => f(...a)
|
|
5530
5670
|
});
|
|
5531
5671
|
await this._serviceContext?.close();
|
|
5532
5672
|
await this._storage.reset();
|
|
5533
|
-
(0,
|
|
5673
|
+
(0, import_log13.log)("reset", void 0, {
|
|
5534
5674
|
F: __dxlog_file18,
|
|
5535
|
-
L:
|
|
5675
|
+
L: 362,
|
|
5536
5676
|
S: this,
|
|
5537
5677
|
C: (f, a) => f(...a)
|
|
5538
5678
|
});
|
|
5539
|
-
|
|
5679
|
+
import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.end({
|
|
5540
5680
|
id: traceId
|
|
5541
5681
|
}), {
|
|
5542
5682
|
F: __dxlog_file18,
|
|
5543
|
-
L:
|
|
5683
|
+
L: 363,
|
|
5544
5684
|
S: this,
|
|
5545
5685
|
C: (f, a) => f(...a)
|
|
5546
5686
|
});
|
|
@@ -5551,9 +5691,9 @@ var ClientServicesHost = class {
|
|
|
5551
5691
|
await this._serviceContext.initialized.wait();
|
|
5552
5692
|
const space = await this._serviceContext.dataSpaceManager.createSpace();
|
|
5553
5693
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5554
|
-
(0,
|
|
5694
|
+
(0, import_invariant15.invariant)(automergeIndex, void 0, {
|
|
5555
5695
|
F: __dxlog_file18,
|
|
5556
|
-
L:
|
|
5696
|
+
L: 375,
|
|
5557
5697
|
S: this,
|
|
5558
5698
|
A: [
|
|
5559
5699
|
"automergeIndex",
|
|
@@ -5564,16 +5704,16 @@ var ClientServicesHost = class {
|
|
|
5564
5704
|
await document.whenReady();
|
|
5565
5705
|
const properties = {
|
|
5566
5706
|
system: {
|
|
5567
|
-
type: (0,
|
|
5707
|
+
type: (0, import_echo_pipeline5.encodeReference)((0, import_echo_schema2.getTypeReference)(import_client_protocol4.Properties))
|
|
5568
5708
|
},
|
|
5569
5709
|
data: {
|
|
5570
|
-
[
|
|
5710
|
+
[import_client_protocol4.defaultKey]: identity.identityKey.toHex()
|
|
5571
5711
|
},
|
|
5572
5712
|
meta: {
|
|
5573
5713
|
keys: []
|
|
5574
5714
|
}
|
|
5575
5715
|
};
|
|
5576
|
-
const propertiesId =
|
|
5716
|
+
const propertiesId = import_keys11.PublicKey.random().toHex();
|
|
5577
5717
|
document.change((doc) => {
|
|
5578
5718
|
(0, import_util9.assignDeep)(doc, [
|
|
5579
5719
|
"objects",
|
|
@@ -5585,35 +5725,70 @@ var ClientServicesHost = class {
|
|
|
5585
5725
|
}
|
|
5586
5726
|
};
|
|
5587
5727
|
_ts_decorate8([
|
|
5588
|
-
|
|
5728
|
+
import_tracing8.trace.info()
|
|
5589
5729
|
], ClientServicesHost.prototype, "_opening", void 0);
|
|
5590
5730
|
_ts_decorate8([
|
|
5591
|
-
|
|
5731
|
+
import_tracing8.trace.info()
|
|
5592
5732
|
], ClientServicesHost.prototype, "_open", void 0);
|
|
5593
5733
|
_ts_decorate8([
|
|
5594
5734
|
import_async16.synchronized,
|
|
5595
|
-
|
|
5735
|
+
import_tracing8.trace.span()
|
|
5596
5736
|
], ClientServicesHost.prototype, "open", null);
|
|
5597
5737
|
_ts_decorate8([
|
|
5598
5738
|
import_async16.synchronized,
|
|
5599
|
-
|
|
5739
|
+
import_tracing8.trace.span()
|
|
5600
5740
|
], ClientServicesHost.prototype, "close", null);
|
|
5601
5741
|
ClientServicesHost = _ts_decorate8([
|
|
5602
|
-
|
|
5742
|
+
import_tracing8.trace.resource()
|
|
5603
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
|
+
};
|
|
5604
5776
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5605
5777
|
0 && (module.exports = {
|
|
5606
5778
|
ClientRpcServer,
|
|
5607
5779
|
ClientServicesHost,
|
|
5780
|
+
ClientServicesProviderResource,
|
|
5608
5781
|
DataSpace,
|
|
5609
5782
|
DataSpaceManager,
|
|
5610
5783
|
DeviceInvitationProtocol,
|
|
5611
5784
|
DevtoolsHostEvents,
|
|
5612
5785
|
DevtoolsServiceImpl,
|
|
5786
|
+
DiagnosticsCollector,
|
|
5613
5787
|
Identity,
|
|
5614
5788
|
IdentityManager,
|
|
5615
5789
|
IdentityServiceImpl,
|
|
5616
5790
|
InvitationsHandler,
|
|
5791
|
+
InvitationsManager,
|
|
5617
5792
|
InvitationsServiceImpl,
|
|
5618
5793
|
Lock,
|
|
5619
5794
|
ServiceContext,
|
|
@@ -5621,12 +5796,14 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5621
5796
|
SpaceInvitationProtocol,
|
|
5622
5797
|
SpacesServiceImpl,
|
|
5623
5798
|
TrustedKeySetAuthVerifier,
|
|
5799
|
+
createAdmissionKeypair,
|
|
5624
5800
|
createAuthProvider,
|
|
5801
|
+
createCollectDiagnosticsBroadcastHandler,
|
|
5802
|
+
createCollectDiagnosticsBroadcastSender,
|
|
5625
5803
|
createDiagnostics,
|
|
5626
5804
|
createLevel,
|
|
5627
5805
|
createStorageObjects,
|
|
5628
5806
|
getNetworkPeers,
|
|
5629
|
-
invitationExpired,
|
|
5630
5807
|
isLocked,
|
|
5631
5808
|
subscribeToFeedBlocks,
|
|
5632
5809
|
subscribeToFeeds,
|
|
@@ -5636,4 +5813,4 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5636
5813
|
subscribeToSpaces,
|
|
5637
5814
|
subscribeToSwarmInfo
|
|
5638
5815
|
});
|
|
5639
|
-
//# sourceMappingURL=chunk-
|
|
5816
|
+
//# sourceMappingURL=chunk-4PLPSVK3.cjs.map
|