@dxos/client-services 0.6.3-next.4424131 → 0.6.3-staging.75e3813
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-M47CB62R.mjs → chunk-JCYU3AYC.mjs} +573 -580
- package/dist/lib/browser/chunk-JCYU3AYC.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -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 +1 -1
- package/dist/lib/node/{chunk-WMIDDIMJ.cjs → chunk-4WZHXQZI.cjs} +655 -659
- package/dist/lib/node/chunk-4WZHXQZI.cjs.map +7 -0
- package/dist/lib/node/index.cjs +44 -46
- 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 +8 -8
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts.map +1 -1
- package/dist/types/src/packlets/services/index.d.ts +0 -1
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/util.d.ts +0 -1
- package/dist/types/src/packlets/services/util.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/package.json +36 -36
- package/src/packlets/diagnostics/diagnostics-collector.ts +1 -2
- package/src/packlets/services/index.ts +0 -1
- package/src/packlets/services/util.ts +0 -2
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-M47CB62R.mjs.map +0 -7
- package/dist/lib/node/chunk-WMIDDIMJ.cjs.map +0 -7
|
@@ -26,11 +26,10 @@ 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_4WZHXQZI_exports = {};
|
|
30
|
+
__export(chunk_4WZHXQZI_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
|
-
ClientServicesProviderResource: () => ClientServicesProviderResource,
|
|
34
33
|
DataSpace: () => DataSpace,
|
|
35
34
|
DataSpaceManager: () => DataSpaceManager,
|
|
36
35
|
DeviceInvitationProtocol: () => DeviceInvitationProtocol,
|
|
@@ -70,7 +69,7 @@ __export(chunk_WMIDDIMJ_exports, {
|
|
|
70
69
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
71
70
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
72
71
|
});
|
|
73
|
-
module.exports = __toCommonJS(
|
|
72
|
+
module.exports = __toCommonJS(chunk_4WZHXQZI_exports);
|
|
74
73
|
var import_async = require("@dxos/async");
|
|
75
74
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
76
75
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -93,17 +92,18 @@ var import_protocols = require("@dxos/protocols");
|
|
|
93
92
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
94
93
|
var import_tracing = require("@dxos/tracing");
|
|
95
94
|
var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
96
|
-
var
|
|
97
|
-
var
|
|
98
|
-
var
|
|
95
|
+
var import_client_protocol = require("@dxos/client-protocol");
|
|
96
|
+
var import_config = require("@dxos/config");
|
|
97
|
+
var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
99
98
|
var import_tracing2 = require("@dxos/tracing");
|
|
99
|
+
var import_util2 = require("@dxos/util");
|
|
100
100
|
var import_async5 = require("@dxos/async");
|
|
101
101
|
var import_context2 = require("@dxos/context");
|
|
102
102
|
var import_credentials2 = require("@dxos/credentials");
|
|
103
103
|
var import_log = require("@dxos/log");
|
|
104
104
|
var import_protocols2 = require("@dxos/protocols");
|
|
105
105
|
var import_async6 = require("@dxos/async");
|
|
106
|
-
var
|
|
106
|
+
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
107
107
|
var import_credentials3 = require("@dxos/credentials");
|
|
108
108
|
var import_feed_store2 = require("@dxos/feed-store");
|
|
109
109
|
var import_invariant2 = require("@dxos/invariant");
|
|
@@ -112,7 +112,7 @@ var import_log2 = require("@dxos/log");
|
|
|
112
112
|
var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
113
113
|
var import_timeframe = require("@dxos/timeframe");
|
|
114
114
|
var import_tracing3 = require("@dxos/tracing");
|
|
115
|
-
var
|
|
115
|
+
var import_util3 = require("@dxos/util");
|
|
116
116
|
var import_credentials5 = require("@dxos/credentials");
|
|
117
117
|
var import_keys4 = require("@dxos/keys");
|
|
118
118
|
var import_log3 = require("@dxos/log");
|
|
@@ -124,26 +124,26 @@ var import_invariant3 = require("@dxos/invariant");
|
|
|
124
124
|
var import_keys5 = require("@dxos/keys");
|
|
125
125
|
var import_log4 = require("@dxos/log");
|
|
126
126
|
var import_protocols3 = require("@dxos/protocols");
|
|
127
|
-
var
|
|
127
|
+
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
128
128
|
var import_credentials7 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
129
129
|
var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
|
|
130
130
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
131
131
|
var import_tracing4 = require("@dxos/tracing");
|
|
132
|
-
var
|
|
132
|
+
var import_util4 = require("@dxos/util");
|
|
133
133
|
var import_async8 = require("@dxos/async");
|
|
134
|
-
var
|
|
134
|
+
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
135
135
|
var import_context4 = require("@dxos/context");
|
|
136
136
|
var import_credentials8 = require("@dxos/credentials");
|
|
137
|
-
var
|
|
137
|
+
var import_debug = require("@dxos/debug");
|
|
138
138
|
var import_invariant4 = require("@dxos/invariant");
|
|
139
139
|
var import_log5 = require("@dxos/log");
|
|
140
|
-
var
|
|
141
|
-
var
|
|
140
|
+
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
141
|
+
var import_util5 = require("@dxos/util");
|
|
142
142
|
var import_invariant5 = require("@dxos/invariant");
|
|
143
143
|
var import_protocols4 = require("@dxos/protocols");
|
|
144
|
-
var
|
|
144
|
+
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
145
145
|
var import_async9 = require("@dxos/async");
|
|
146
|
-
var
|
|
146
|
+
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
147
147
|
var import_context5 = require("@dxos/context");
|
|
148
148
|
var import_crypto = require("@dxos/crypto");
|
|
149
149
|
var import_invariant6 = require("@dxos/invariant");
|
|
@@ -151,11 +151,11 @@ var import_keys6 = require("@dxos/keys");
|
|
|
151
151
|
var import_log6 = require("@dxos/log");
|
|
152
152
|
var import_network_manager = require("@dxos/network-manager");
|
|
153
153
|
var import_protocols5 = require("@dxos/protocols");
|
|
154
|
-
var
|
|
154
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
155
155
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
156
156
|
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
157
157
|
var import_tracing5 = require("@dxos/tracing");
|
|
158
|
-
var
|
|
158
|
+
var import_util6 = require("@dxos/util");
|
|
159
159
|
var import_async10 = require("@dxos/async");
|
|
160
160
|
var import_context6 = require("@dxos/context");
|
|
161
161
|
var import_invariant7 = require("@dxos/invariant");
|
|
@@ -164,7 +164,7 @@ var import_protocols6 = require("@dxos/protocols");
|
|
|
164
164
|
var import_invitations3 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
165
165
|
var import_teleport = require("@dxos/teleport");
|
|
166
166
|
var import_context7 = require("@dxos/context");
|
|
167
|
-
var
|
|
167
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
168
168
|
var import_async11 = require("@dxos/async");
|
|
169
169
|
var import_context8 = require("@dxos/context");
|
|
170
170
|
var import_crypto2 = require("@dxos/crypto");
|
|
@@ -172,67 +172,74 @@ var import_invariant8 = require("@dxos/invariant");
|
|
|
172
172
|
var import_keys7 = require("@dxos/keys");
|
|
173
173
|
var import_log8 = require("@dxos/log");
|
|
174
174
|
var import_protocols7 = require("@dxos/protocols");
|
|
175
|
-
var
|
|
175
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
176
176
|
var import_invitations4 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
177
177
|
var import_teleport2 = require("@dxos/teleport");
|
|
178
178
|
var import_invariant9 = require("@dxos/invariant");
|
|
179
179
|
var import_keys8 = require("@dxos/keys");
|
|
180
180
|
var import_log9 = require("@dxos/log");
|
|
181
181
|
var import_invitations5 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
182
|
-
var
|
|
183
|
-
var
|
|
184
|
-
var
|
|
182
|
+
var import_util7 = require("@dxos/util");
|
|
183
|
+
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
184
|
+
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
185
185
|
var import_credentials9 = require("@dxos/credentials");
|
|
186
186
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
187
187
|
var import_invariant10 = require("@dxos/invariant");
|
|
188
188
|
var import_log10 = require("@dxos/log");
|
|
189
189
|
var import_protocols8 = require("@dxos/protocols");
|
|
190
|
-
var
|
|
190
|
+
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
191
191
|
var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
192
192
|
var import_async12 = require("@dxos/async");
|
|
193
|
-
var
|
|
193
|
+
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
194
194
|
var import_context9 = require("@dxos/context");
|
|
195
195
|
var import_credentials11 = require("@dxos/credentials");
|
|
196
196
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
197
197
|
var import_invariant11 = require("@dxos/invariant");
|
|
198
198
|
var import_keys9 = require("@dxos/keys");
|
|
199
199
|
var import_log11 = require("@dxos/log");
|
|
200
|
-
var
|
|
200
|
+
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
201
201
|
var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
202
|
+
var import_invariant12 = require("@dxos/invariant");
|
|
203
|
+
var import_lock_file = require("@dxos/lock-file");
|
|
204
|
+
var import_log12 = require("@dxos/log");
|
|
205
|
+
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
206
|
+
var import_debug2 = require("@dxos/debug");
|
|
207
|
+
var import_rpc = require("@dxos/rpc");
|
|
208
|
+
var import_tracing6 = require("@dxos/tracing");
|
|
202
209
|
var import_async13 = require("@dxos/async");
|
|
203
|
-
var
|
|
210
|
+
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
204
211
|
var import_context10 = require("@dxos/context");
|
|
205
212
|
var import_debug3 = require("@dxos/debug");
|
|
206
213
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
207
214
|
var import_echo_protocol = require("@dxos/echo-protocol");
|
|
208
|
-
var
|
|
215
|
+
var import_invariant13 = require("@dxos/invariant");
|
|
209
216
|
var import_keys10 = require("@dxos/keys");
|
|
210
|
-
var
|
|
217
|
+
var import_log13 = require("@dxos/log");
|
|
211
218
|
var import_protocols9 = require("@dxos/protocols");
|
|
212
|
-
var
|
|
219
|
+
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
213
220
|
var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
214
221
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
215
|
-
var
|
|
216
|
-
var
|
|
222
|
+
var import_tracing7 = require("@dxos/tracing");
|
|
223
|
+
var import_util8 = require("@dxos/util");
|
|
217
224
|
var import_async14 = require("@dxos/async");
|
|
218
225
|
var import_context11 = require("@dxos/context");
|
|
219
226
|
var import_credentials14 = require("@dxos/credentials");
|
|
220
227
|
var import_echo_db = require("@dxos/echo-db");
|
|
221
228
|
var import_echo_protocol2 = require("@dxos/echo-protocol");
|
|
222
229
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
223
|
-
var
|
|
224
|
-
var
|
|
225
|
-
var
|
|
230
|
+
var import_invariant14 = require("@dxos/invariant");
|
|
231
|
+
var import_log14 = require("@dxos/log");
|
|
232
|
+
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
226
233
|
var import_async15 = require("@dxos/async");
|
|
227
234
|
var import_context12 = require("@dxos/context");
|
|
228
|
-
var
|
|
235
|
+
var import_invariant15 = require("@dxos/invariant");
|
|
229
236
|
var import_keys11 = require("@dxos/keys");
|
|
230
|
-
var
|
|
237
|
+
var import_log15 = require("@dxos/log");
|
|
231
238
|
var import_protocols10 = require("@dxos/protocols");
|
|
232
239
|
var import_teleport3 = require("@dxos/teleport");
|
|
233
|
-
var
|
|
240
|
+
var import_util9 = require("@dxos/util");
|
|
234
241
|
var import_async16 = require("@dxos/async");
|
|
235
|
-
var
|
|
242
|
+
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
236
243
|
var import_context13 = require("@dxos/context");
|
|
237
244
|
var import_credentials15 = require("@dxos/credentials");
|
|
238
245
|
var import_echo_db2 = require("@dxos/echo-db");
|
|
@@ -241,15 +248,15 @@ var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
|
241
248
|
var import_echo_protocol3 = require("@dxos/echo-protocol");
|
|
242
249
|
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
243
250
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
244
|
-
var
|
|
251
|
+
var import_invariant16 = require("@dxos/invariant");
|
|
245
252
|
var import_keys12 = require("@dxos/keys");
|
|
246
|
-
var
|
|
253
|
+
var import_log16 = require("@dxos/log");
|
|
247
254
|
var import_protocols11 = require("@dxos/protocols");
|
|
248
|
-
var
|
|
255
|
+
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
249
256
|
var import_credentials16 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
250
257
|
var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
|
|
251
|
-
var
|
|
252
|
-
var
|
|
258
|
+
var import_tracing8 = require("@dxos/tracing");
|
|
259
|
+
var import_util10 = require("@dxos/util");
|
|
253
260
|
var import_credentials17 = require("@dxos/credentials");
|
|
254
261
|
var import_debug4 = require("@dxos/debug");
|
|
255
262
|
var import_credentials18 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
@@ -259,11 +266,11 @@ var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
|
259
266
|
var import_credentials19 = require("@dxos/credentials");
|
|
260
267
|
var import_debug5 = require("@dxos/debug");
|
|
261
268
|
var import_feed_store5 = require("@dxos/feed-store");
|
|
262
|
-
var
|
|
263
|
-
var
|
|
269
|
+
var import_invariant17 = require("@dxos/invariant");
|
|
270
|
+
var import_log17 = require("@dxos/log");
|
|
264
271
|
var import_protocols12 = require("@dxos/protocols");
|
|
265
|
-
var
|
|
266
|
-
var
|
|
272
|
+
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
273
|
+
var import_tracing9 = require("@dxos/tracing");
|
|
267
274
|
var import_async18 = require("@dxos/async");
|
|
268
275
|
var import_context14 = require("@dxos/context");
|
|
269
276
|
var import_credentials20 = require("@dxos/credentials");
|
|
@@ -271,24 +278,21 @@ var import_debug6 = require("@dxos/debug");
|
|
|
271
278
|
var import_echo_db3 = require("@dxos/echo-db");
|
|
272
279
|
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
273
280
|
var import_feed_store6 = require("@dxos/feed-store");
|
|
274
|
-
var
|
|
281
|
+
var import_invariant18 = require("@dxos/invariant");
|
|
275
282
|
var import_keyring = require("@dxos/keyring");
|
|
276
283
|
var import_keys13 = require("@dxos/keys");
|
|
277
|
-
var
|
|
284
|
+
var import_log18 = require("@dxos/log");
|
|
278
285
|
var import_protocols13 = require("@dxos/protocols");
|
|
279
|
-
var
|
|
286
|
+
var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
|
|
280
287
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
281
|
-
var
|
|
282
|
-
var
|
|
283
|
-
var import_invariant18 = require("@dxos/invariant");
|
|
284
|
-
var import_lock_file = require("@dxos/lock-file");
|
|
285
|
-
var import_log18 = require("@dxos/log");
|
|
288
|
+
var import_tracing10 = require("@dxos/tracing");
|
|
289
|
+
var import_util11 = require("@dxos/util");
|
|
286
290
|
var import_protocols14 = require("@dxos/protocols");
|
|
287
|
-
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
288
|
-
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
289
|
-
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
290
291
|
var import_config2 = require("@dxos/protocols/proto/dxos/config");
|
|
291
|
-
var
|
|
292
|
+
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
293
|
+
var import_client_protocol7 = require("@dxos/client-protocol");
|
|
294
|
+
var import_config3 = require("@dxos/protocols/proto/dxos/config");
|
|
295
|
+
var import_util12 = require("@dxos/util");
|
|
292
296
|
var import_node_path = __toESM(require("node:path"));
|
|
293
297
|
var import_keys14 = require("@dxos/keys");
|
|
294
298
|
var import_kv_store = require("@dxos/kv-store");
|
|
@@ -296,9 +300,9 @@ var import_automerge_repo = require("@dxos/automerge/automerge-repo");
|
|
|
296
300
|
var import_invariant19 = require("@dxos/invariant");
|
|
297
301
|
var import_log19 = require("@dxos/log");
|
|
298
302
|
var import_protocols15 = require("@dxos/protocols");
|
|
299
|
-
var
|
|
303
|
+
var import_util13 = require("@dxos/util");
|
|
300
304
|
var import_async19 = require("@dxos/async");
|
|
301
|
-
var
|
|
305
|
+
var import_client_protocol8 = require("@dxos/client-protocol");
|
|
302
306
|
var import_context15 = require("@dxos/context");
|
|
303
307
|
var import_invariant20 = require("@dxos/invariant");
|
|
304
308
|
var import_keys15 = require("@dxos/keys");
|
|
@@ -306,33 +310,27 @@ var import_log20 = require("@dxos/log");
|
|
|
306
310
|
var import_messaging = require("@dxos/messaging");
|
|
307
311
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
308
312
|
var import_protocols16 = require("@dxos/protocols");
|
|
309
|
-
var
|
|
310
|
-
var
|
|
313
|
+
var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
|
|
314
|
+
var import_tracing11 = require("@dxos/tracing");
|
|
311
315
|
var import_websocket_rpc = require("@dxos/websocket-rpc");
|
|
312
316
|
var import_async20 = require("@dxos/async");
|
|
313
317
|
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
314
318
|
var import_invariant21 = require("@dxos/invariant");
|
|
315
|
-
var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
|
|
316
|
-
var import_config3 = require("@dxos/config");
|
|
317
319
|
var import_services19 = require("@dxos/protocols/proto/dxos/client/services");
|
|
318
|
-
var import_tracing11 = require("@dxos/tracing");
|
|
319
|
-
var import_util13 = require("@dxos/util");
|
|
320
|
-
var import_keys16 = require("@dxos/keys");
|
|
321
|
-
var import_util14 = require("@dxos/util");
|
|
322
320
|
var import_async21 = require("@dxos/async");
|
|
323
321
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
324
|
-
var
|
|
325
|
-
var
|
|
322
|
+
var import_keys16 = require("@dxos/keys");
|
|
323
|
+
var import_util14 = require("@dxos/util");
|
|
326
324
|
var import_async22 = require("@dxos/async");
|
|
327
325
|
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
328
|
-
var
|
|
326
|
+
var import_keys17 = require("@dxos/keys");
|
|
329
327
|
var import_log21 = require("@dxos/log");
|
|
330
328
|
var import_services20 = require("@dxos/protocols/proto/dxos/client/services");
|
|
331
|
-
var
|
|
329
|
+
var import_util15 = require("@dxos/util");
|
|
332
330
|
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
333
331
|
var import_codec_protobuf16 = require("@dxos/codec-protobuf");
|
|
334
332
|
var import_services21 = require("@dxos/protocols/proto/dxos/client/services");
|
|
335
|
-
var
|
|
333
|
+
var import_util16 = require("@dxos/util");
|
|
336
334
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
337
335
|
return new import_codec_protobuf.Stream(({ next }) => {
|
|
338
336
|
const subscriptions = new import_async.EventSubscriptions();
|
|
@@ -647,7 +645,7 @@ var DevtoolsServiceImpl = class {
|
|
|
647
645
|
});
|
|
648
646
|
}
|
|
649
647
|
};
|
|
650
|
-
var DXOS_VERSION = "0.6.3-
|
|
648
|
+
var DXOS_VERSION = "0.6.3-staging.75e3813";
|
|
651
649
|
var getPlatform = () => {
|
|
652
650
|
if (process.browser) {
|
|
653
651
|
if (typeof window !== "undefined") {
|
|
@@ -806,81 +804,40 @@ var createCollectDiagnosticsBroadcastHandler = (_) => {
|
|
|
806
804
|
}
|
|
807
805
|
};
|
|
808
806
|
};
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
else
|
|
814
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
815
|
-
if (d = decorators[i])
|
|
816
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
817
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
818
|
-
}
|
|
819
|
-
var ClientRpcServer = class {
|
|
820
|
-
constructor(params) {
|
|
821
|
-
this._handlerCache = /* @__PURE__ */ new Map();
|
|
822
|
-
this._callMetrics = new import_tracing2.MapCounter();
|
|
823
|
-
const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
|
|
824
|
-
this._handleCall = handleCall;
|
|
825
|
-
this._handleStream = handleStream;
|
|
826
|
-
this._serviceRegistry = serviceRegistry;
|
|
827
|
-
this._rpcPeer = new import_rpc.RpcPeer({
|
|
828
|
-
...rpcOptions,
|
|
829
|
-
callHandler: (method, params2) => {
|
|
830
|
-
const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
|
|
831
|
-
const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
|
|
832
|
-
this._callMetrics.inc(`${serviceName}.${methodName} request`);
|
|
833
|
-
if (this._handleCall) {
|
|
834
|
-
return this._handleCall(methodName, params2, handler);
|
|
835
|
-
} else {
|
|
836
|
-
return handler(methodName, params2);
|
|
837
|
-
}
|
|
838
|
-
},
|
|
839
|
-
streamHandler: (method, params2) => {
|
|
840
|
-
const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
|
|
841
|
-
const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
|
|
842
|
-
this._callMetrics.inc(`${serviceName}.${methodName} request stream`);
|
|
843
|
-
if (this._handleStream) {
|
|
844
|
-
return import_codec_protobuf8.Stream.map(import_codec_protobuf8.Stream.unwrapPromise(this._handleStream(methodName, params2, handler)), (data) => {
|
|
845
|
-
this._callMetrics.inc(`${serviceName}.${methodName} response stream`);
|
|
846
|
-
return data;
|
|
847
|
-
});
|
|
848
|
-
} else {
|
|
849
|
-
return handler(methodName, params2);
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
get _services() {
|
|
855
|
-
return Object.keys(this._serviceRegistry.services);
|
|
856
|
-
}
|
|
857
|
-
async open() {
|
|
858
|
-
await this._rpcPeer.open();
|
|
859
|
-
}
|
|
860
|
-
async close() {
|
|
861
|
-
await this._rpcPeer.close();
|
|
807
|
+
var GET_DIAGNOSTICS_RPC_TIMEOUT = 1e4;
|
|
808
|
+
var DiagnosticsCollector = class {
|
|
809
|
+
static {
|
|
810
|
+
this.broadcastSender = createCollectDiagnosticsBroadcastSender();
|
|
862
811
|
}
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
812
|
+
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
813
|
+
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
814
|
+
keys: options.humanize ? import_services3.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services3.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
815
|
+
}, {
|
|
816
|
+
timeout: GET_DIAGNOSTICS_RPC_TIMEOUT
|
|
817
|
+
});
|
|
818
|
+
const clientDiagnostics = {
|
|
819
|
+
config,
|
|
820
|
+
trace: import_tracing2.TRACE_PROCESSOR.getDiagnostics()
|
|
821
|
+
};
|
|
822
|
+
const diagnostics = serviceDiagnostics != null ? {
|
|
823
|
+
client: clientDiagnostics,
|
|
824
|
+
services: serviceDiagnostics
|
|
825
|
+
} : {
|
|
826
|
+
client: clientDiagnostics,
|
|
827
|
+
broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
|
|
828
|
+
};
|
|
829
|
+
return JSON.parse(JSON.stringify(diagnostics, (0, import_util2.jsonKeyReplacer)(options)));
|
|
873
830
|
}
|
|
874
831
|
};
|
|
875
|
-
|
|
876
|
-
import_tracing2.
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
832
|
+
var findSystemServiceProvider = () => {
|
|
833
|
+
const serviceProviders = import_tracing2.TRACE_PROCESSOR.findResourcesByAnnotation(import_client_protocol.ClientServicesProviderResource);
|
|
834
|
+
const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
|
|
835
|
+
return providerResource?.instance?.deref() ?? null;
|
|
836
|
+
};
|
|
837
|
+
var findConfigs = () => {
|
|
838
|
+
const configs = import_tracing2.TRACE_PROCESSOR.findResourcesByAnnotation(import_config.ConfigResource);
|
|
839
|
+
return configs.map((r) => r.instance.deref()).filter(import_util2.nonNullable);
|
|
840
|
+
};
|
|
884
841
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
|
|
885
842
|
var Credential = import_protocols2.schema.getCodecForType("dxos.halo.credentials.Credential");
|
|
886
843
|
var createAuthProvider = (signer) => async (nonce) => {
|
|
@@ -1033,7 +990,7 @@ var DefaultSpaceStateMachine = class {
|
|
|
1033
990
|
}
|
|
1034
991
|
}
|
|
1035
992
|
};
|
|
1036
|
-
function
|
|
993
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
1037
994
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1038
995
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1039
996
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1074,9 +1031,9 @@ var Identity = class {
|
|
|
1074
1031
|
onUpdate: () => this.stateUpdate.emit()
|
|
1075
1032
|
});
|
|
1076
1033
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
1077
|
-
trustedKeysProvider: () => new
|
|
1034
|
+
trustedKeysProvider: () => new import_util3.ComplexSet(import_keys3.PublicKey.hash, this.authorizedDeviceKeys.keys()),
|
|
1078
1035
|
update: this.stateUpdate,
|
|
1079
|
-
authTimeout:
|
|
1036
|
+
authTimeout: import_client_protocol2.AUTH_TIMEOUT
|
|
1080
1037
|
});
|
|
1081
1038
|
}
|
|
1082
1039
|
// TODO(burdon): Expose state object?
|
|
@@ -1104,7 +1061,7 @@ var Identity = class {
|
|
|
1104
1061
|
async ready() {
|
|
1105
1062
|
await this._deviceStateMachine.deviceChainReady.wait();
|
|
1106
1063
|
await this.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
1107
|
-
timeout:
|
|
1064
|
+
timeout: import_client_protocol2.LOAD_CONTROL_FEEDS_TIMEOUT
|
|
1108
1065
|
});
|
|
1109
1066
|
}
|
|
1110
1067
|
get profileDocument() {
|
|
@@ -1220,16 +1177,16 @@ var Identity = class {
|
|
|
1220
1177
|
})));
|
|
1221
1178
|
}
|
|
1222
1179
|
};
|
|
1223
|
-
|
|
1180
|
+
_ts_decorate([
|
|
1224
1181
|
import_tracing3.trace.span()
|
|
1225
1182
|
], Identity.prototype, "open", null);
|
|
1226
|
-
|
|
1183
|
+
_ts_decorate([
|
|
1227
1184
|
import_tracing3.trace.span()
|
|
1228
1185
|
], Identity.prototype, "close", null);
|
|
1229
|
-
Identity =
|
|
1186
|
+
Identity = _ts_decorate([
|
|
1230
1187
|
import_tracing3.trace.resource()
|
|
1231
1188
|
], Identity);
|
|
1232
|
-
function
|
|
1189
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
1233
1190
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1234
1191
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1235
1192
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1411,7 +1368,7 @@ var IdentityManager = class {
|
|
|
1411
1368
|
// TODO(nf): receive platform info rather than generating it here.
|
|
1412
1369
|
createDefaultDeviceProfile() {
|
|
1413
1370
|
let type;
|
|
1414
|
-
if ((0,
|
|
1371
|
+
if ((0, import_util4.isNode)()) {
|
|
1415
1372
|
type = import_credentials7.DeviceType.AGENT;
|
|
1416
1373
|
} else {
|
|
1417
1374
|
if (import_platform.default.name?.startsWith("iOS") || import_platform.default.name?.startsWith("Android")) {
|
|
@@ -1561,8 +1518,8 @@ var IdentityManager = class {
|
|
|
1561
1518
|
this.stateUpdate.emit();
|
|
1562
1519
|
return {
|
|
1563
1520
|
deviceKey: this._identity.deviceKey,
|
|
1564
|
-
kind:
|
|
1565
|
-
presence:
|
|
1521
|
+
kind: import_services4.DeviceKind.CURRENT,
|
|
1522
|
+
presence: import_services4.Device.PresenceState.ONLINE,
|
|
1566
1523
|
profile
|
|
1567
1524
|
};
|
|
1568
1525
|
}
|
|
@@ -1623,7 +1580,7 @@ var IdentityManager = class {
|
|
|
1623
1580
|
swarmIdentity: {
|
|
1624
1581
|
peerKey: identityRecord.deviceKey,
|
|
1625
1582
|
credentialProvider: createAuthProvider((0, import_credentials6.createCredentialSignerWithKey)(this._keyring, identityRecord.deviceKey)),
|
|
1626
|
-
credentialAuthenticator: (0,
|
|
1583
|
+
credentialAuthenticator: (0, import_util4.deferFunction)(() => identity.authVerifier.verifier)
|
|
1627
1584
|
},
|
|
1628
1585
|
gossip,
|
|
1629
1586
|
identityKey: identityRecord.identityKey
|
|
@@ -1679,12 +1636,12 @@ var IdentityManager = class {
|
|
|
1679
1636
|
});
|
|
1680
1637
|
}
|
|
1681
1638
|
};
|
|
1682
|
-
|
|
1639
|
+
_ts_decorate2([
|
|
1683
1640
|
import_tracing4.trace.span({
|
|
1684
1641
|
showInBrowserTimeline: true
|
|
1685
1642
|
})
|
|
1686
1643
|
], IdentityManager.prototype, "open", null);
|
|
1687
|
-
IdentityManager =
|
|
1644
|
+
IdentityManager = _ts_decorate2([
|
|
1688
1645
|
import_tracing4.trace.resource()
|
|
1689
1646
|
], IdentityManager);
|
|
1690
1647
|
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
@@ -1728,10 +1685,10 @@ var IdentityServiceImpl = class extends import_context4.Resource {
|
|
|
1728
1685
|
await identity.updateDefaultSpace(space.id);
|
|
1729
1686
|
}
|
|
1730
1687
|
async recoverIdentity(request) {
|
|
1731
|
-
return (0,
|
|
1688
|
+
return (0, import_debug.todo)();
|
|
1732
1689
|
}
|
|
1733
1690
|
queryIdentity() {
|
|
1734
|
-
return new
|
|
1691
|
+
return new import_codec_protobuf8.Stream(({ next }) => {
|
|
1735
1692
|
const emitNext = () => next({
|
|
1736
1693
|
identity: this._getIdentity()
|
|
1737
1694
|
});
|
|
@@ -1786,10 +1743,10 @@ var IdentityServiceImpl = class extends import_context4.Resource {
|
|
|
1786
1743
|
let foundDefaultSpace = false;
|
|
1787
1744
|
const dataSpaceManager = this._dataSpaceManagerProvider();
|
|
1788
1745
|
const recordedDefaultSpaceTrigger = new import_async8.Trigger();
|
|
1789
|
-
const allProcessed = (0,
|
|
1790
|
-
if (space.state ===
|
|
1746
|
+
const allProcessed = (0, import_util5.safeAwaitAll)(dataSpaceManager.spaces.values(), async (space) => {
|
|
1747
|
+
if (space.state === import_services5.SpaceState.SPACE_CLOSED) {
|
|
1791
1748
|
await space.open();
|
|
1792
|
-
const requiresMigration = space.stateUpdate.waitForCondition(() => space.state ===
|
|
1749
|
+
const requiresMigration = space.stateUpdate.waitForCondition(() => space.state === import_services5.SpaceState.SPACE_REQUIRES_MIGRATION);
|
|
1793
1750
|
await Promise.race([
|
|
1794
1751
|
space.initializeDataPipeline(),
|
|
1795
1752
|
requiresMigration
|
|
@@ -1845,7 +1802,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1845
1802
|
}
|
|
1846
1803
|
getInvitationContext() {
|
|
1847
1804
|
return {
|
|
1848
|
-
kind:
|
|
1805
|
+
kind: import_services6.Invitation.Kind.DEVICE
|
|
1849
1806
|
};
|
|
1850
1807
|
}
|
|
1851
1808
|
async delegate() {
|
|
@@ -1937,7 +1894,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1937
1894
|
}
|
|
1938
1895
|
};
|
|
1939
1896
|
var stateToString = (state) => {
|
|
1940
|
-
return Object.entries(
|
|
1897
|
+
return Object.entries(import_services8.Invitation.State).find(([key, val]) => val === state)?.[0] ?? "unknown";
|
|
1941
1898
|
};
|
|
1942
1899
|
var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
|
|
1943
1900
|
let guard;
|
|
@@ -2134,7 +2091,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2134
2091
|
C: (f, a) => f(...a)
|
|
2135
2092
|
});
|
|
2136
2093
|
const invitation = this._requireActiveInvitation();
|
|
2137
|
-
this._assertInvitationState(
|
|
2094
|
+
this._assertInvitationState(import_services9.Invitation.State.CONNECTED);
|
|
2138
2095
|
if (invitationId !== invitation?.invitationId) {
|
|
2139
2096
|
import_log8.log.warn("incorrect invitationId", {
|
|
2140
2097
|
expected: invitation.invitationId,
|
|
@@ -2148,7 +2105,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2148
2105
|
this._callbacks.onError(new Error("Incorrect invitationId."));
|
|
2149
2106
|
(0, import_async11.scheduleTask)(this._ctx, () => this.close());
|
|
2150
2107
|
return {
|
|
2151
|
-
authMethod:
|
|
2108
|
+
authMethod: import_services9.Invitation.AuthMethod.NONE
|
|
2152
2109
|
};
|
|
2153
2110
|
}
|
|
2154
2111
|
(0, import_log8.log)("guest introduced themselves", {
|
|
@@ -2160,8 +2117,8 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2160
2117
|
C: (f, a) => f(...a)
|
|
2161
2118
|
});
|
|
2162
2119
|
this.guestProfile = profile;
|
|
2163
|
-
this._callbacks.onStateUpdate(
|
|
2164
|
-
this._challenge = invitation.authMethod ===
|
|
2120
|
+
this._callbacks.onStateUpdate(import_services9.Invitation.State.READY_FOR_AUTHENTICATION);
|
|
2121
|
+
this._challenge = invitation.authMethod === import_services9.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto2.randomBytes)(32) : void 0;
|
|
2165
2122
|
import_log8.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols7.trace.end({
|
|
2166
2123
|
id: traceId
|
|
2167
2124
|
}), {
|
|
@@ -2196,12 +2153,12 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2196
2153
|
});
|
|
2197
2154
|
let status = import_invitations4.AuthenticationResponse.Status.OK;
|
|
2198
2155
|
this._assertInvitationState([
|
|
2199
|
-
|
|
2200
|
-
|
|
2156
|
+
import_services9.Invitation.State.AUTHENTICATING,
|
|
2157
|
+
import_services9.Invitation.State.READY_FOR_AUTHENTICATION
|
|
2201
2158
|
]);
|
|
2202
|
-
this._callbacks.onStateUpdate(
|
|
2159
|
+
this._callbacks.onStateUpdate(import_services9.Invitation.State.AUTHENTICATING);
|
|
2203
2160
|
switch (invitation.authMethod) {
|
|
2204
|
-
case
|
|
2161
|
+
case import_services9.Invitation.AuthMethod.NONE: {
|
|
2205
2162
|
(0, import_log8.log)("authentication not required", void 0, {
|
|
2206
2163
|
F: __dxlog_file10,
|
|
2207
2164
|
L: 152,
|
|
@@ -2212,7 +2169,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2212
2169
|
status: import_invitations4.AuthenticationResponse.Status.OK
|
|
2213
2170
|
};
|
|
2214
2171
|
}
|
|
2215
|
-
case
|
|
2172
|
+
case import_services9.Invitation.AuthMethod.SHARED_SECRET: {
|
|
2216
2173
|
if (invitation.authCode) {
|
|
2217
2174
|
if (this.authenticationRetry++ > MAX_OTP_ATTEMPTS) {
|
|
2218
2175
|
status = import_invitations4.AuthenticationResponse.Status.INVALID_OPT_ATTEMPTS;
|
|
@@ -2224,7 +2181,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2224
2181
|
}
|
|
2225
2182
|
break;
|
|
2226
2183
|
}
|
|
2227
|
-
case
|
|
2184
|
+
case import_services9.Invitation.AuthMethod.KNOWN_PUBLIC_KEY: {
|
|
2228
2185
|
if (!invitation.guestKeypair) {
|
|
2229
2186
|
status = import_invitations4.AuthenticationResponse.Status.INTERNAL_ERROR;
|
|
2230
2187
|
break;
|
|
@@ -2288,7 +2245,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2288
2245
|
const invitation = this._requireActiveInvitation();
|
|
2289
2246
|
try {
|
|
2290
2247
|
if (isAuthenticationRequired(invitation)) {
|
|
2291
|
-
this._assertInvitationState(
|
|
2248
|
+
this._assertInvitationState(import_services9.Invitation.State.AUTHENTICATING);
|
|
2292
2249
|
if (!this.authenticationPassed) {
|
|
2293
2250
|
throw new Error("Not authenticated");
|
|
2294
2251
|
}
|
|
@@ -2328,7 +2285,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2328
2285
|
C: (f, a) => f(...a)
|
|
2329
2286
|
});
|
|
2330
2287
|
const lastState = this._requireActiveInvitation().state;
|
|
2331
|
-
this._callbacks.onStateUpdate(
|
|
2288
|
+
this._callbacks.onStateUpdate(import_services9.Invitation.State.CONNECTING);
|
|
2332
2289
|
await this.rpc.InvitationHostService.options({
|
|
2333
2290
|
role: import_invitations4.InvitationOptions.Role.HOST
|
|
2334
2291
|
});
|
|
@@ -2355,7 +2312,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2355
2312
|
remotePeerId: context.remotePeerId
|
|
2356
2313
|
});
|
|
2357
2314
|
}
|
|
2358
|
-
this._callbacks.onStateUpdate(
|
|
2315
|
+
this._callbacks.onStateUpdate(import_services9.Invitation.State.CONNECTED);
|
|
2359
2316
|
this._callbacks.onOpen(this._ctx, context);
|
|
2360
2317
|
} catch (err) {
|
|
2361
2318
|
if (this._invitationFlowLock != null) {
|
|
@@ -2404,12 +2361,12 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2404
2361
|
}
|
|
2405
2362
|
}
|
|
2406
2363
|
};
|
|
2407
|
-
var isAuthenticationRequired = (invitation) => invitation.authMethod !==
|
|
2364
|
+
var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services9.Invitation.AuthMethod.NONE;
|
|
2408
2365
|
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
|
|
2409
2366
|
var InvitationTopology = class {
|
|
2410
2367
|
constructor(_role) {
|
|
2411
2368
|
this._role = _role;
|
|
2412
|
-
this._seenPeers = new
|
|
2369
|
+
this._seenPeers = new import_util7.ComplexSet(import_keys8.PublicKey.hash);
|
|
2413
2370
|
}
|
|
2414
2371
|
init(controller) {
|
|
2415
2372
|
(0, import_invariant9.invariant)(!this._controller, "Already initialized.", {
|
|
@@ -2442,7 +2399,7 @@ var InvitationTopology = class {
|
|
|
2442
2399
|
return;
|
|
2443
2400
|
}
|
|
2444
2401
|
const firstUnknownPeer = candidates.find((peerId) => !this._seenPeers.has(peerId));
|
|
2445
|
-
this._seenPeers = new
|
|
2402
|
+
this._seenPeers = new import_util7.ComplexSet(import_keys8.PublicKey.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
|
|
2446
2403
|
if (firstUnknownPeer != null) {
|
|
2447
2404
|
(0, import_log9.log)("invitation connect", {
|
|
2448
2405
|
ownPeerId,
|
|
@@ -2557,7 +2514,7 @@ var InvitationsHandler = class {
|
|
|
2557
2514
|
S: this,
|
|
2558
2515
|
C: (f, a) => f(...a)
|
|
2559
2516
|
});
|
|
2560
|
-
guardedState.set(extension,
|
|
2517
|
+
guardedState.set(extension, import_services7.Invitation.State.SUCCESS);
|
|
2561
2518
|
metrics.increment("dxos.invitation.success");
|
|
2562
2519
|
import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.end({
|
|
2563
2520
|
id: traceId
|
|
@@ -2573,7 +2530,7 @@ var InvitationsHandler = class {
|
|
|
2573
2530
|
}
|
|
2574
2531
|
} catch (err) {
|
|
2575
2532
|
if (err instanceof import_async9.TimeoutError) {
|
|
2576
|
-
if (guardedState.set(extension,
|
|
2533
|
+
if (guardedState.set(extension, import_services7.Invitation.State.TIMEOUT)) {
|
|
2577
2534
|
metrics.increment("dxos.invitation.timeout");
|
|
2578
2535
|
(0, import_log6.log)("timeout", {
|
|
2579
2536
|
...protocol.toJSON()
|
|
@@ -2621,7 +2578,7 @@ var InvitationsHandler = class {
|
|
|
2621
2578
|
return;
|
|
2622
2579
|
}
|
|
2623
2580
|
if (err instanceof import_async9.TimeoutError) {
|
|
2624
|
-
if (guardedState.set(extension,
|
|
2581
|
+
if (guardedState.set(extension, import_services7.Invitation.State.TIMEOUT)) {
|
|
2625
2582
|
metrics.increment("dxos.invitation.timeout");
|
|
2626
2583
|
(0, import_log6.log)("timeout", {
|
|
2627
2584
|
err
|
|
@@ -2658,7 +2615,7 @@ var InvitationsHandler = class {
|
|
|
2658
2615
|
} else {
|
|
2659
2616
|
(0, import_async9.scheduleTask)(ctx, async () => {
|
|
2660
2617
|
await swarmConnection.close();
|
|
2661
|
-
guardedState.set(null,
|
|
2618
|
+
guardedState.set(null, import_services7.Invitation.State.EXPIRED);
|
|
2662
2619
|
metrics.increment("dxos.invitation.expired");
|
|
2663
2620
|
await ctx.dispose();
|
|
2664
2621
|
}, invitation.created.getTime() + invitation.lifetime * 1e3 - Date.now());
|
|
@@ -2667,13 +2624,13 @@ var InvitationsHandler = class {
|
|
|
2667
2624
|
let swarmConnection;
|
|
2668
2625
|
(0, import_async9.scheduleTask)(ctx, async () => {
|
|
2669
2626
|
swarmConnection = await this._joinSwarm(ctx, invitation, import_invitations2.InvitationOptions.Role.HOST, createExtension);
|
|
2670
|
-
guardedState.set(null,
|
|
2627
|
+
guardedState.set(null, import_services7.Invitation.State.CONNECTING);
|
|
2671
2628
|
});
|
|
2672
2629
|
}
|
|
2673
2630
|
acceptInvitation(ctx, stream, protocol, invitation, otpEnteredTrigger, deviceProfile) {
|
|
2674
|
-
const { timeout =
|
|
2631
|
+
const { timeout = import_client_protocol3.INVITATION_TIMEOUT } = invitation;
|
|
2675
2632
|
if (deviceProfile) {
|
|
2676
|
-
(0, import_invariant6.invariant)(invitation.kind ===
|
|
2633
|
+
(0, import_invariant6.invariant)(invitation.kind === import_services7.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2677
2634
|
F: __dxlog_file12,
|
|
2678
2635
|
L: 207,
|
|
2679
2636
|
S: this,
|
|
@@ -2683,13 +2640,13 @@ var InvitationsHandler = class {
|
|
|
2683
2640
|
]
|
|
2684
2641
|
});
|
|
2685
2642
|
}
|
|
2686
|
-
const triedPeersIds = new
|
|
2643
|
+
const triedPeersIds = new import_util6.ComplexSet(import_keys6.PublicKey.hash);
|
|
2687
2644
|
const guardedState = this._createGuardedState(ctx, invitation, stream);
|
|
2688
2645
|
const shouldCancelInvitationFlow = (extension) => {
|
|
2689
2646
|
const isLockedByAnotherConnection = guardedState.mutex.isLocked() && !extension.hasFlowLock();
|
|
2690
2647
|
(0, import_log6.log)("should cancel invitation flow", {
|
|
2691
2648
|
isLockedByAnotherConnection,
|
|
2692
|
-
invitationType:
|
|
2649
|
+
invitationType: import_services7.Invitation.Type.DELEGATED,
|
|
2693
2650
|
triedPeers: triedPeersIds.size
|
|
2694
2651
|
}, {
|
|
2695
2652
|
F: __dxlog_file12,
|
|
@@ -2700,7 +2657,7 @@ var InvitationsHandler = class {
|
|
|
2700
2657
|
if (isLockedByAnotherConnection) {
|
|
2701
2658
|
return false;
|
|
2702
2659
|
}
|
|
2703
|
-
return invitation.type !==
|
|
2660
|
+
return invitation.type !== import_services7.Invitation.Type.DELEGATED || triedPeersIds.size >= MAX_DELEGATED_INVITATION_HOST_TRIES;
|
|
2704
2661
|
};
|
|
2705
2662
|
let admitted = false;
|
|
2706
2663
|
const createExtension = () => {
|
|
@@ -2743,7 +2700,7 @@ var InvitationsHandler = class {
|
|
|
2743
2700
|
C: (f, a) => f(...a)
|
|
2744
2701
|
});
|
|
2745
2702
|
(0, import_async9.scheduleTask)(connectionCtx, () => {
|
|
2746
|
-
guardedState.set(extension,
|
|
2703
|
+
guardedState.set(extension, import_services7.Invitation.State.TIMEOUT);
|
|
2747
2704
|
extensionCtx.close();
|
|
2748
2705
|
}, timeout);
|
|
2749
2706
|
(0, import_log6.log)("connected", {
|
|
@@ -2754,7 +2711,7 @@ var InvitationsHandler = class {
|
|
|
2754
2711
|
S: this,
|
|
2755
2712
|
C: (f, a) => f(...a)
|
|
2756
2713
|
});
|
|
2757
|
-
guardedState.set(extension,
|
|
2714
|
+
guardedState.set(extension, import_services7.Invitation.State.CONNECTED);
|
|
2758
2715
|
(0, import_log6.log)("introduce", {
|
|
2759
2716
|
...protocol.toJSON()
|
|
2760
2717
|
}, {
|
|
@@ -2779,12 +2736,12 @@ var InvitationsHandler = class {
|
|
|
2779
2736
|
invitation.authMethod = introductionResponse.authMethod;
|
|
2780
2737
|
if (isAuthenticationRequired(invitation)) {
|
|
2781
2738
|
switch (invitation.authMethod) {
|
|
2782
|
-
case
|
|
2739
|
+
case import_services7.Invitation.AuthMethod.SHARED_SECRET:
|
|
2783
2740
|
await this._handleGuestOtpAuth(extension, (state) => guardedState.set(extension, state), otpEnteredTrigger, {
|
|
2784
2741
|
timeout
|
|
2785
2742
|
});
|
|
2786
2743
|
break;
|
|
2787
|
-
case
|
|
2744
|
+
case import_services7.Invitation.AuthMethod.KNOWN_PUBLIC_KEY:
|
|
2788
2745
|
await this._handleGuestKpkAuth(extension, (state) => guardedState.set(extension, state), invitation, introductionResponse);
|
|
2789
2746
|
break;
|
|
2790
2747
|
}
|
|
@@ -2812,7 +2769,7 @@ var InvitationsHandler = class {
|
|
|
2812
2769
|
await guardedState.complete({
|
|
2813
2770
|
...guardedState.current,
|
|
2814
2771
|
...result,
|
|
2815
|
-
state:
|
|
2772
|
+
state: import_services7.Invitation.State.SUCCESS
|
|
2816
2773
|
});
|
|
2817
2774
|
import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.end({
|
|
2818
2775
|
id: traceId
|
|
@@ -2832,7 +2789,7 @@ var InvitationsHandler = class {
|
|
|
2832
2789
|
S: this,
|
|
2833
2790
|
C: (f, a) => f(...a)
|
|
2834
2791
|
});
|
|
2835
|
-
guardedState.set(extension,
|
|
2792
|
+
guardedState.set(extension, import_services7.Invitation.State.TIMEOUT);
|
|
2836
2793
|
} else {
|
|
2837
2794
|
(0, import_log6.log)("auth failed", err, {
|
|
2838
2795
|
F: __dxlog_file12,
|
|
@@ -2868,7 +2825,7 @@ var InvitationsHandler = class {
|
|
|
2868
2825
|
S: this,
|
|
2869
2826
|
C: (f, a) => f(...a)
|
|
2870
2827
|
});
|
|
2871
|
-
guardedState.set(extension,
|
|
2828
|
+
guardedState.set(extension, import_services7.Invitation.State.TIMEOUT);
|
|
2872
2829
|
} else {
|
|
2873
2830
|
(0, import_log6.log)("auth failed", err, {
|
|
2874
2831
|
F: __dxlog_file12,
|
|
@@ -2898,7 +2855,7 @@ var InvitationsHandler = class {
|
|
|
2898
2855
|
]
|
|
2899
2856
|
});
|
|
2900
2857
|
await this._joinSwarm(ctx, invitation, import_invitations2.InvitationOptions.Role.GUEST, createExtension);
|
|
2901
|
-
guardedState.set(null,
|
|
2858
|
+
guardedState.set(null, import_services7.Invitation.State.CONNECTING);
|
|
2902
2859
|
}
|
|
2903
2860
|
});
|
|
2904
2861
|
}
|
|
@@ -2906,7 +2863,7 @@ var InvitationsHandler = class {
|
|
|
2906
2863
|
let label;
|
|
2907
2864
|
if (role === import_invitations2.InvitationOptions.Role.GUEST) {
|
|
2908
2865
|
label = "invitation guest";
|
|
2909
|
-
} else if (invitation.kind ===
|
|
2866
|
+
} else if (invitation.kind === import_services7.Invitation.Kind.DEVICE) {
|
|
2910
2867
|
label = "invitation host for device";
|
|
2911
2868
|
} else {
|
|
2912
2869
|
label = `invitation host for space ${invitation.spaceKey?.truncate()}`;
|
|
@@ -2968,10 +2925,10 @@ var InvitationsHandler = class {
|
|
|
2968
2925
|
},
|
|
2969
2926
|
error: (extension, error) => {
|
|
2970
2927
|
if (isStateChangeAllowed(extension)) {
|
|
2971
|
-
this._logStateUpdate(currentInvitation, extension,
|
|
2928
|
+
this._logStateUpdate(currentInvitation, extension, import_services7.Invitation.State.ERROR);
|
|
2972
2929
|
currentInvitation = {
|
|
2973
2930
|
...currentInvitation,
|
|
2974
|
-
state:
|
|
2931
|
+
state: import_services7.Invitation.State.ERROR
|
|
2975
2932
|
};
|
|
2976
2933
|
stream.next(currentInvitation);
|
|
2977
2934
|
stream.error(error);
|
|
@@ -3009,11 +2966,11 @@ var InvitationsHandler = class {
|
|
|
3009
2966
|
}
|
|
3010
2967
|
_isNotTerminal(currentState) {
|
|
3011
2968
|
return ![
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
2969
|
+
import_services7.Invitation.State.SUCCESS,
|
|
2970
|
+
import_services7.Invitation.State.ERROR,
|
|
2971
|
+
import_services7.Invitation.State.CANCELLED,
|
|
2972
|
+
import_services7.Invitation.State.TIMEOUT,
|
|
2973
|
+
import_services7.Invitation.State.EXPIRED
|
|
3017
2974
|
].includes(currentState);
|
|
3018
2975
|
}
|
|
3019
2976
|
async _handleGuestOtpAuth(extension, setState, authenticated, options) {
|
|
@@ -3024,7 +2981,7 @@ var InvitationsHandler = class {
|
|
|
3024
2981
|
S: this,
|
|
3025
2982
|
C: (f, a) => f(...a)
|
|
3026
2983
|
});
|
|
3027
|
-
setState(
|
|
2984
|
+
setState(import_services7.Invitation.State.READY_FOR_AUTHENTICATION);
|
|
3028
2985
|
const authCode = await authenticated.wait(options);
|
|
3029
2986
|
(0, import_log6.log)("sending authentication request", void 0, {
|
|
3030
2987
|
F: __dxlog_file12,
|
|
@@ -3032,7 +2989,7 @@ var InvitationsHandler = class {
|
|
|
3032
2989
|
S: this,
|
|
3033
2990
|
C: (f, a) => f(...a)
|
|
3034
2991
|
});
|
|
3035
|
-
setState(
|
|
2992
|
+
setState(import_services7.Invitation.State.AUTHENTICATING);
|
|
3036
2993
|
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
3037
2994
|
authCode
|
|
3038
2995
|
});
|
|
@@ -3069,7 +3026,7 @@ var InvitationsHandler = class {
|
|
|
3069
3026
|
S: this,
|
|
3070
3027
|
C: (f, a) => f(...a)
|
|
3071
3028
|
});
|
|
3072
|
-
setState(
|
|
3029
|
+
setState(import_services7.Invitation.State.AUTHENTICATING);
|
|
3073
3030
|
const signature = (0, import_crypto.sign)(Buffer.from(introductionResponse.challenge), invitation.guestKeypair.privateKey);
|
|
3074
3031
|
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
3075
3032
|
signedChallenge: signature
|
|
@@ -3095,13 +3052,13 @@ var InvitationsServiceImpl = class {
|
|
|
3095
3052
|
return {};
|
|
3096
3053
|
}
|
|
3097
3054
|
createInvitation(options) {
|
|
3098
|
-
return new
|
|
3055
|
+
return new import_codec_protobuf9.Stream(({ next, close }) => {
|
|
3099
3056
|
void this._invitationsManager.createInvitation(options).then((invitation) => invitation.subscribe(next, close, close)).catch(close);
|
|
3100
3057
|
});
|
|
3101
3058
|
}
|
|
3102
3059
|
acceptInvitation(request) {
|
|
3103
3060
|
const invitation = this._invitationsManager.acceptInvitation(request);
|
|
3104
|
-
return new
|
|
3061
|
+
return new import_codec_protobuf9.Stream(({ next, close }) => {
|
|
3105
3062
|
invitation.subscribe(next, close, close);
|
|
3106
3063
|
});
|
|
3107
3064
|
}
|
|
@@ -3112,11 +3069,11 @@ var InvitationsServiceImpl = class {
|
|
|
3112
3069
|
return this._invitationsManager.cancelInvitation(request);
|
|
3113
3070
|
}
|
|
3114
3071
|
queryInvitations() {
|
|
3115
|
-
return new
|
|
3072
|
+
return new import_codec_protobuf9.Stream(({ next, ctx }) => {
|
|
3116
3073
|
this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
|
|
3117
3074
|
next({
|
|
3118
|
-
action:
|
|
3119
|
-
type:
|
|
3075
|
+
action: import_services10.QueryInvitationsResponse.Action.ADDED,
|
|
3076
|
+
type: import_services10.QueryInvitationsResponse.Type.CREATED,
|
|
3120
3077
|
invitations: [
|
|
3121
3078
|
invitation
|
|
3122
3079
|
]
|
|
@@ -3124,8 +3081,8 @@ var InvitationsServiceImpl = class {
|
|
|
3124
3081
|
});
|
|
3125
3082
|
this._invitationsManager.invitationAccepted.on(ctx, (invitation) => {
|
|
3126
3083
|
next({
|
|
3127
|
-
action:
|
|
3128
|
-
type:
|
|
3084
|
+
action: import_services10.QueryInvitationsResponse.Action.ADDED,
|
|
3085
|
+
type: import_services10.QueryInvitationsResponse.Type.ACCEPTED,
|
|
3129
3086
|
invitations: [
|
|
3130
3087
|
invitation
|
|
3131
3088
|
]
|
|
@@ -3133,8 +3090,8 @@ var InvitationsServiceImpl = class {
|
|
|
3133
3090
|
});
|
|
3134
3091
|
this._invitationsManager.removedCreated.on(ctx, (invitation) => {
|
|
3135
3092
|
next({
|
|
3136
|
-
action:
|
|
3137
|
-
type:
|
|
3093
|
+
action: import_services10.QueryInvitationsResponse.Action.REMOVED,
|
|
3094
|
+
type: import_services10.QueryInvitationsResponse.Type.CREATED,
|
|
3138
3095
|
invitations: [
|
|
3139
3096
|
invitation
|
|
3140
3097
|
]
|
|
@@ -3142,8 +3099,8 @@ var InvitationsServiceImpl = class {
|
|
|
3142
3099
|
});
|
|
3143
3100
|
this._invitationsManager.removedAccepted.on(ctx, (invitation) => {
|
|
3144
3101
|
next({
|
|
3145
|
-
action:
|
|
3146
|
-
type:
|
|
3102
|
+
action: import_services10.QueryInvitationsResponse.Action.REMOVED,
|
|
3103
|
+
type: import_services10.QueryInvitationsResponse.Type.ACCEPTED,
|
|
3147
3104
|
invitations: [
|
|
3148
3105
|
invitation
|
|
3149
3106
|
]
|
|
@@ -3151,29 +3108,29 @@ var InvitationsServiceImpl = class {
|
|
|
3151
3108
|
});
|
|
3152
3109
|
this._invitationsManager.saved.on(ctx, (invitation) => {
|
|
3153
3110
|
next({
|
|
3154
|
-
action:
|
|
3155
|
-
type:
|
|
3111
|
+
action: import_services10.QueryInvitationsResponse.Action.SAVED,
|
|
3112
|
+
type: import_services10.QueryInvitationsResponse.Type.CREATED,
|
|
3156
3113
|
invitations: [
|
|
3157
3114
|
invitation
|
|
3158
3115
|
]
|
|
3159
3116
|
});
|
|
3160
3117
|
});
|
|
3161
3118
|
next({
|
|
3162
|
-
action:
|
|
3163
|
-
type:
|
|
3119
|
+
action: import_services10.QueryInvitationsResponse.Action.ADDED,
|
|
3120
|
+
type: import_services10.QueryInvitationsResponse.Type.CREATED,
|
|
3164
3121
|
invitations: this._invitationsManager.getCreatedInvitations(),
|
|
3165
3122
|
existing: true
|
|
3166
3123
|
});
|
|
3167
3124
|
next({
|
|
3168
|
-
action:
|
|
3169
|
-
type:
|
|
3125
|
+
action: import_services10.QueryInvitationsResponse.Action.ADDED,
|
|
3126
|
+
type: import_services10.QueryInvitationsResponse.Type.ACCEPTED,
|
|
3170
3127
|
invitations: this._invitationsManager.getAcceptedInvitations(),
|
|
3171
3128
|
existing: true
|
|
3172
3129
|
});
|
|
3173
3130
|
this._invitationsManager.onPersistentInvitationsLoaded(ctx, () => {
|
|
3174
3131
|
next({
|
|
3175
|
-
action:
|
|
3176
|
-
type:
|
|
3132
|
+
action: import_services10.QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
3133
|
+
type: import_services10.QueryInvitationsResponse.Type.CREATED
|
|
3177
3134
|
});
|
|
3178
3135
|
});
|
|
3179
3136
|
});
|
|
@@ -3208,7 +3165,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3208
3165
|
}
|
|
3209
3166
|
getInvitationContext() {
|
|
3210
3167
|
return {
|
|
3211
|
-
kind:
|
|
3168
|
+
kind: import_services11.Invitation.Kind.SPACE,
|
|
3212
3169
|
spaceKey: this._spaceKey
|
|
3213
3170
|
};
|
|
3214
3171
|
}
|
|
@@ -3266,7 +3223,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3266
3223
|
""
|
|
3267
3224
|
]
|
|
3268
3225
|
});
|
|
3269
|
-
if (invitation.authMethod ===
|
|
3226
|
+
if (invitation.authMethod === import_services11.Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
3270
3227
|
(0, import_invariant10.invariant)(invitation.guestKeypair?.publicKey, void 0, {
|
|
3271
3228
|
F: __dxlog_file13,
|
|
3272
3229
|
L: 99,
|
|
@@ -3293,7 +3250,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3293
3250
|
role: invitation.role ?? import_credentials10.SpaceMember.Role.ADMIN,
|
|
3294
3251
|
expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
|
|
3295
3252
|
multiUse: invitation.multiUse ?? false,
|
|
3296
|
-
guestKey: invitation.authMethod ===
|
|
3253
|
+
guestKey: invitation.authMethod === import_services11.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
|
|
3297
3254
|
});
|
|
3298
3255
|
(0, import_invariant10.invariant)(credential.credential, void 0, {
|
|
3299
3256
|
F: __dxlog_file13,
|
|
@@ -3319,7 +3276,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3319
3276
|
""
|
|
3320
3277
|
]
|
|
3321
3278
|
});
|
|
3322
|
-
(0, import_invariant10.invariant)(invitation.type ===
|
|
3279
|
+
(0, import_invariant10.invariant)(invitation.type === import_services11.Invitation.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
|
|
3323
3280
|
F: __dxlog_file13,
|
|
3324
3281
|
L: 129,
|
|
3325
3282
|
S: this,
|
|
@@ -3599,7 +3556,7 @@ var InvitationsManager = class {
|
|
|
3599
3556
|
if (created.get().persistent) {
|
|
3600
3557
|
await this._metadataStore.removeInvitation(invitationId);
|
|
3601
3558
|
}
|
|
3602
|
-
if (created.get().type ===
|
|
3559
|
+
if (created.get().type === import_services12.Invitation.Type.DELEGATED) {
|
|
3603
3560
|
const handler = this._getHandler(created.get());
|
|
3604
3561
|
await handler.cancelDelegation(created.get());
|
|
3605
3562
|
}
|
|
@@ -3633,8 +3590,8 @@ var InvitationsManager = class {
|
|
|
3633
3590
|
}
|
|
3634
3591
|
}
|
|
3635
3592
|
_createInvitation(protocol, options) {
|
|
3636
|
-
const { invitationId = import_keys9.PublicKey.random().toHex(), type =
|
|
3637
|
-
const authCode = options?.authCode ?? (authMethod ===
|
|
3593
|
+
const { invitationId = import_keys9.PublicKey.random().toHex(), type = import_services12.Invitation.Type.INTERACTIVE, authMethod = import_services12.Invitation.AuthMethod.SHARED_SECRET, state = import_services12.Invitation.State.INIT, timeout = import_client_protocol4.INVITATION_TIMEOUT, swarmKey = import_keys9.PublicKey.random(), persistent = options?.authMethod !== import_services12.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = import_credentials12.SpaceMember.Role.ADMIN, lifetime = 86400, multiUse = false } = options ?? {};
|
|
3594
|
+
const authCode = options?.authCode ?? (authMethod === import_services12.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials11.generatePasscode)(import_client_protocol4.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
3638
3595
|
return {
|
|
3639
3596
|
invitationId,
|
|
3640
3597
|
type,
|
|
@@ -3643,8 +3600,8 @@ var InvitationsManager = class {
|
|
|
3643
3600
|
swarmKey,
|
|
3644
3601
|
authCode,
|
|
3645
3602
|
timeout,
|
|
3646
|
-
persistent: persistent && type !==
|
|
3647
|
-
guestKeypair: guestKeypair ?? (authMethod ===
|
|
3603
|
+
persistent: persistent && type !== import_services12.Invitation.Type.DELEGATED,
|
|
3604
|
+
guestKeypair: guestKeypair ?? (authMethod === import_services12.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
|
|
3648
3605
|
created,
|
|
3649
3606
|
lifetime,
|
|
3650
3607
|
role,
|
|
@@ -3675,13 +3632,13 @@ var InvitationsManager = class {
|
|
|
3675
3632
|
});
|
|
3676
3633
|
stream.complete();
|
|
3677
3634
|
});
|
|
3678
|
-
const observableInvitation = new
|
|
3635
|
+
const observableInvitation = new import_client_protocol4.CancellableInvitation({
|
|
3679
3636
|
initialInvitation: invitation,
|
|
3680
3637
|
subscriber: stream.observable,
|
|
3681
3638
|
onCancel: async () => {
|
|
3682
3639
|
stream.next({
|
|
3683
3640
|
...invitation,
|
|
3684
|
-
state:
|
|
3641
|
+
state: import_services12.Invitation.State.CANCELLED
|
|
3685
3642
|
});
|
|
3686
3643
|
await ctx.dispose();
|
|
3687
3644
|
}
|
|
@@ -3708,7 +3665,7 @@ var InvitationsManager = class {
|
|
|
3708
3665
|
});
|
|
3709
3666
|
stream.next({
|
|
3710
3667
|
...initialState,
|
|
3711
|
-
state:
|
|
3668
|
+
state: import_services12.Invitation.State.TIMEOUT
|
|
3712
3669
|
});
|
|
3713
3670
|
} else {
|
|
3714
3671
|
import_log11.log.warn("auth failed", err, {
|
|
@@ -3719,7 +3676,7 @@ var InvitationsManager = class {
|
|
|
3719
3676
|
});
|
|
3720
3677
|
stream.next({
|
|
3721
3678
|
...initialState,
|
|
3722
|
-
state:
|
|
3679
|
+
state: import_services12.Invitation.State.ERROR
|
|
3723
3680
|
});
|
|
3724
3681
|
}
|
|
3725
3682
|
void ctx.dispose();
|
|
@@ -3739,13 +3696,13 @@ var InvitationsManager = class {
|
|
|
3739
3696
|
});
|
|
3740
3697
|
stream.complete();
|
|
3741
3698
|
});
|
|
3742
|
-
const invitation = new
|
|
3699
|
+
const invitation = new import_client_protocol4.AuthenticatingInvitation({
|
|
3743
3700
|
initialInvitation: initialState,
|
|
3744
3701
|
subscriber: stream.observable,
|
|
3745
3702
|
onCancel: async () => {
|
|
3746
3703
|
stream.next({
|
|
3747
3704
|
...initialState,
|
|
3748
|
-
state:
|
|
3705
|
+
state: import_services12.Invitation.State.CANCELLED
|
|
3749
3706
|
});
|
|
3750
3707
|
await ctx.dispose();
|
|
3751
3708
|
},
|
|
@@ -3761,7 +3718,7 @@ var InvitationsManager = class {
|
|
|
3761
3718
|
};
|
|
3762
3719
|
}
|
|
3763
3720
|
async _persistIfRequired(handler, changeStream, invitation) {
|
|
3764
|
-
if (invitation.type ===
|
|
3721
|
+
if (invitation.type === import_services12.Invitation.Type.DELEGATED && invitation.delegationCredentialId == null) {
|
|
3765
3722
|
const delegationCredentialId = await handler.delegate(invitation);
|
|
3766
3723
|
changeStream.next({
|
|
3767
3724
|
...invitation,
|
|
@@ -3790,26 +3747,155 @@ var InvitationsManager = class {
|
|
|
3790
3747
|
}, callback);
|
|
3791
3748
|
}
|
|
3792
3749
|
};
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
this.
|
|
3812
|
-
|
|
3750
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
3751
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3752
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3753
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3754
|
+
else
|
|
3755
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3756
|
+
if (d = decorators[i])
|
|
3757
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3758
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3759
|
+
}
|
|
3760
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
3761
|
+
var Lock = class {
|
|
3762
|
+
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
3763
|
+
this._lockPath = lockPath;
|
|
3764
|
+
this._onAcquire = onAcquire;
|
|
3765
|
+
this._onRelease = onRelease;
|
|
3766
|
+
}
|
|
3767
|
+
get lockKey() {
|
|
3768
|
+
return this._lockPath;
|
|
3769
|
+
}
|
|
3770
|
+
async acquire() {
|
|
3771
|
+
(0, import_log12.log)("acquiring lock...", void 0, {
|
|
3772
|
+
F: __dxlog_file15,
|
|
3773
|
+
L: 32,
|
|
3774
|
+
S: this,
|
|
3775
|
+
C: (f, a) => f(...a)
|
|
3776
|
+
});
|
|
3777
|
+
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
3778
|
+
await this._onAcquire?.();
|
|
3779
|
+
(0, import_log12.log)("acquired lock", void 0, {
|
|
3780
|
+
F: __dxlog_file15,
|
|
3781
|
+
L: 37,
|
|
3782
|
+
S: this,
|
|
3783
|
+
C: (f, a) => f(...a)
|
|
3784
|
+
});
|
|
3785
|
+
}
|
|
3786
|
+
async release() {
|
|
3787
|
+
await this._onRelease?.();
|
|
3788
|
+
(0, import_invariant12.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
3789
|
+
F: __dxlog_file15,
|
|
3790
|
+
L: 42,
|
|
3791
|
+
S: this,
|
|
3792
|
+
A: [
|
|
3793
|
+
"this._fileHandle",
|
|
3794
|
+
"'Lock is not acquired'"
|
|
3795
|
+
]
|
|
3796
|
+
});
|
|
3797
|
+
await import_lock_file.LockFile.release(this._fileHandle);
|
|
3798
|
+
}
|
|
3799
|
+
};
|
|
3800
|
+
_ts_decorate3([
|
|
3801
|
+
import_log12.logInfo
|
|
3802
|
+
], Lock.prototype, "lockKey", null);
|
|
3803
|
+
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
3804
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
3805
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3806
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3807
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3808
|
+
else
|
|
3809
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3810
|
+
if (d = decorators[i])
|
|
3811
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3812
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3813
|
+
}
|
|
3814
|
+
var ClientRpcServer = class {
|
|
3815
|
+
constructor(params) {
|
|
3816
|
+
this._handlerCache = /* @__PURE__ */ new Map();
|
|
3817
|
+
this._callMetrics = new import_tracing6.MapCounter();
|
|
3818
|
+
const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
|
|
3819
|
+
this._handleCall = handleCall;
|
|
3820
|
+
this._handleStream = handleStream;
|
|
3821
|
+
this._serviceRegistry = serviceRegistry;
|
|
3822
|
+
this._rpcPeer = new import_rpc.RpcPeer({
|
|
3823
|
+
...rpcOptions,
|
|
3824
|
+
callHandler: (method, params2) => {
|
|
3825
|
+
const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
|
|
3826
|
+
const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
|
|
3827
|
+
this._callMetrics.inc(`${serviceName}.${methodName} request`);
|
|
3828
|
+
if (this._handleCall) {
|
|
3829
|
+
return this._handleCall(methodName, params2, handler);
|
|
3830
|
+
} else {
|
|
3831
|
+
return handler(methodName, params2);
|
|
3832
|
+
}
|
|
3833
|
+
},
|
|
3834
|
+
streamHandler: (method, params2) => {
|
|
3835
|
+
const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
|
|
3836
|
+
const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
|
|
3837
|
+
this._callMetrics.inc(`${serviceName}.${methodName} request stream`);
|
|
3838
|
+
if (this._handleStream) {
|
|
3839
|
+
return import_codec_protobuf10.Stream.map(import_codec_protobuf10.Stream.unwrapPromise(this._handleStream(methodName, params2, handler)), (data) => {
|
|
3840
|
+
this._callMetrics.inc(`${serviceName}.${methodName} response stream`);
|
|
3841
|
+
return data;
|
|
3842
|
+
});
|
|
3843
|
+
} else {
|
|
3844
|
+
return handler(methodName, params2);
|
|
3845
|
+
}
|
|
3846
|
+
}
|
|
3847
|
+
});
|
|
3848
|
+
}
|
|
3849
|
+
get _services() {
|
|
3850
|
+
return Object.keys(this._serviceRegistry.services);
|
|
3851
|
+
}
|
|
3852
|
+
async open() {
|
|
3853
|
+
await this._rpcPeer.open();
|
|
3854
|
+
}
|
|
3855
|
+
async close() {
|
|
3856
|
+
await this._rpcPeer.close();
|
|
3857
|
+
}
|
|
3858
|
+
_getServiceHandler(serviceName) {
|
|
3859
|
+
if (!this._handlerCache.has(serviceName)) {
|
|
3860
|
+
const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? (0, import_debug2.raise)(new Error(`Service not available: ${serviceName}`));
|
|
3861
|
+
const service = this._serviceRegistry.services[key];
|
|
3862
|
+
if (!service) {
|
|
3863
|
+
throw new Error(`Service not available: ${serviceName}`);
|
|
3864
|
+
}
|
|
3865
|
+
this._handlerCache.set(serviceName, descriptor.createServer(service));
|
|
3866
|
+
}
|
|
3867
|
+
return this._handlerCache.get(serviceName);
|
|
3868
|
+
}
|
|
3869
|
+
};
|
|
3870
|
+
_ts_decorate4([
|
|
3871
|
+
import_tracing6.trace.metricsCounter()
|
|
3872
|
+
], ClientRpcServer.prototype, "_callMetrics", void 0);
|
|
3873
|
+
_ts_decorate4([
|
|
3874
|
+
import_tracing6.trace.info()
|
|
3875
|
+
], ClientRpcServer.prototype, "_services", null);
|
|
3876
|
+
ClientRpcServer = _ts_decorate4([
|
|
3877
|
+
import_tracing6.trace.resource()
|
|
3878
|
+
], ClientRpcServer);
|
|
3879
|
+
var AutomergeSpaceState = class extends import_context11.Resource {
|
|
3880
|
+
constructor(_onNewRoot) {
|
|
3881
|
+
super();
|
|
3882
|
+
this._onNewRoot = _onNewRoot;
|
|
3883
|
+
this.rootUrl = void 0;
|
|
3884
|
+
this.lastEpoch = void 0;
|
|
3885
|
+
this.onNewEpoch = new import_async14.Event();
|
|
3886
|
+
this._isProcessingRootDocs = false;
|
|
3887
|
+
}
|
|
3888
|
+
async _open(ctx) {
|
|
3889
|
+
}
|
|
3890
|
+
async _close(ctx) {
|
|
3891
|
+
this._isProcessingRootDocs = false;
|
|
3892
|
+
}
|
|
3893
|
+
async processCredential(credential) {
|
|
3894
|
+
if (!(0, import_credentials14.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
3895
|
+
return;
|
|
3896
|
+
}
|
|
3897
|
+
this.lastEpoch = credential;
|
|
3898
|
+
if (credential.subject.assertion.automergeRoot) {
|
|
3813
3899
|
this.rootUrl = credential.subject.assertion.automergeRoot;
|
|
3814
3900
|
if (this._isProcessingRootDocs) {
|
|
3815
3901
|
this._onNewRoot(this.rootUrl);
|
|
@@ -3830,18 +3916,18 @@ var AutomergeSpaceState = class extends import_context11.Resource {
|
|
|
3830
3916
|
await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
|
|
3831
3917
|
}
|
|
3832
3918
|
};
|
|
3833
|
-
var
|
|
3919
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts";
|
|
3834
3920
|
var LOAD_DOC_TIMEOUT = 1e4;
|
|
3835
3921
|
var runEpochMigration = async (ctx, context) => {
|
|
3836
3922
|
switch (context.migration) {
|
|
3837
|
-
case
|
|
3923
|
+
case import_services14.CreateEpochRequest.Migration.INIT_AUTOMERGE: {
|
|
3838
3924
|
const document = context.echoHost.createDoc();
|
|
3839
3925
|
await context.echoHost.flush();
|
|
3840
3926
|
return {
|
|
3841
3927
|
newRoot: document.url
|
|
3842
3928
|
};
|
|
3843
3929
|
}
|
|
3844
|
-
case
|
|
3930
|
+
case import_services14.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY: {
|
|
3845
3931
|
if (!context.currentRoot) {
|
|
3846
3932
|
throw new Error("Space does not have an automerge root");
|
|
3847
3933
|
}
|
|
@@ -3854,9 +3940,9 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3854
3940
|
newRoot: newRoot.url
|
|
3855
3941
|
};
|
|
3856
3942
|
}
|
|
3857
|
-
case
|
|
3858
|
-
|
|
3859
|
-
F:
|
|
3943
|
+
case import_services14.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT: {
|
|
3944
|
+
import_log14.log.info("Fragmenting", void 0, {
|
|
3945
|
+
F: __dxlog_file16,
|
|
3860
3946
|
L: 64,
|
|
3861
3947
|
S: void 0,
|
|
3862
3948
|
C: (f, a) => f(...a)
|
|
@@ -3868,8 +3954,8 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3868
3954
|
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3869
3955
|
const properties = (0, import_echo_db.findInlineObjectOfType)(rootHandle.docSync(), import_echo_schema.TYPE_PROPERTIES);
|
|
3870
3956
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3871
|
-
(0,
|
|
3872
|
-
F:
|
|
3957
|
+
(0, import_invariant14.invariant)(properties, "Properties not found", {
|
|
3958
|
+
F: __dxlog_file16,
|
|
3873
3959
|
L: 75,
|
|
3874
3960
|
S: void 0,
|
|
3875
3961
|
A: [
|
|
@@ -3883,8 +3969,8 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3883
3969
|
properties
|
|
3884
3970
|
])
|
|
3885
3971
|
});
|
|
3886
|
-
(0,
|
|
3887
|
-
F:
|
|
3972
|
+
(0, import_invariant14.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3973
|
+
F: __dxlog_file16,
|
|
3888
3974
|
L: 82,
|
|
3889
3975
|
S: void 0,
|
|
3890
3976
|
A: [
|
|
@@ -3919,13 +4005,13 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3919
4005
|
newRoot: newRoot.url
|
|
3920
4006
|
};
|
|
3921
4007
|
}
|
|
3922
|
-
case
|
|
4008
|
+
case import_services14.CreateEpochRequest.Migration.MIGRATE_REFERENCES_TO_DXN: {
|
|
3923
4009
|
const currentRootUrl = context.currentRoot;
|
|
3924
4010
|
const rootHandle = await context.echoHost.loadDoc(ctx, currentRootUrl, {
|
|
3925
4011
|
timeout: LOAD_DOC_TIMEOUT
|
|
3926
4012
|
});
|
|
3927
|
-
(0,
|
|
3928
|
-
F:
|
|
4013
|
+
(0, import_invariant14.invariant)(rootHandle.docSync(), "Root doc not found", {
|
|
4014
|
+
F: __dxlog_file16,
|
|
3929
4015
|
L: 115,
|
|
3930
4016
|
S: void 0,
|
|
3931
4017
|
A: [
|
|
@@ -3939,8 +4025,8 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3939
4025
|
const handle = await context.echoHost.loadDoc(ctx, url, {
|
|
3940
4026
|
timeout: LOAD_DOC_TIMEOUT
|
|
3941
4027
|
});
|
|
3942
|
-
(0,
|
|
3943
|
-
F:
|
|
4028
|
+
(0, import_invariant14.invariant)(handle.docSync(), void 0, {
|
|
4029
|
+
F: __dxlog_file16,
|
|
3944
4030
|
L: 122,
|
|
3945
4031
|
S: void 0,
|
|
3946
4032
|
A: [
|
|
@@ -3955,12 +4041,12 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3955
4041
|
});
|
|
3956
4042
|
newRootContent.links[id] = newHandle.url;
|
|
3957
4043
|
} catch (err) {
|
|
3958
|
-
|
|
4044
|
+
import_log14.log.warn("Failed to migrate reference", {
|
|
3959
4045
|
id,
|
|
3960
4046
|
url,
|
|
3961
4047
|
error: err
|
|
3962
4048
|
}, {
|
|
3963
|
-
F:
|
|
4049
|
+
F: __dxlog_file16,
|
|
3964
4050
|
L: 128,
|
|
3965
4051
|
S: void 0,
|
|
3966
4052
|
C: (f, a) => f(...a)
|
|
@@ -3977,9 +4063,9 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3977
4063
|
newRoot: newRoot.url
|
|
3978
4064
|
};
|
|
3979
4065
|
}
|
|
3980
|
-
case
|
|
3981
|
-
(0,
|
|
3982
|
-
F:
|
|
4066
|
+
case import_services14.CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
|
|
4067
|
+
(0, import_invariant14.invariant)(context.newAutomergeRoot, void 0, {
|
|
4068
|
+
F: __dxlog_file16,
|
|
3983
4069
|
L: 143,
|
|
3984
4070
|
S: void 0,
|
|
3985
4071
|
A: [
|
|
@@ -3995,7 +4081,7 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
3995
4081
|
}
|
|
3996
4082
|
return {};
|
|
3997
4083
|
};
|
|
3998
|
-
var
|
|
4084
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
3999
4085
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
4000
4086
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
4001
4087
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -4003,13 +4089,13 @@ var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
|
4003
4089
|
var NotarizationPlugin = class {
|
|
4004
4090
|
constructor() {
|
|
4005
4091
|
this._ctx = new import_context12.Context(void 0, {
|
|
4006
|
-
F:
|
|
4092
|
+
F: __dxlog_file17,
|
|
4007
4093
|
L: 62
|
|
4008
4094
|
});
|
|
4009
4095
|
this._extensionOpened = new import_async15.Event();
|
|
4010
4096
|
this._extensions = /* @__PURE__ */ new Set();
|
|
4011
|
-
this._processedCredentials = new
|
|
4012
|
-
this._processCredentialsTriggers = new
|
|
4097
|
+
this._processedCredentials = new import_util9.ComplexSet(import_keys11.PublicKey.hash);
|
|
4098
|
+
this._processCredentialsTriggers = new import_util9.ComplexMap(import_keys11.PublicKey.hash);
|
|
4013
4099
|
}
|
|
4014
4100
|
get hasWriter() {
|
|
4015
4101
|
return !!this._writer;
|
|
@@ -4023,16 +4109,16 @@ var NotarizationPlugin = class {
|
|
|
4023
4109
|
* Request credentials to be notarized.
|
|
4024
4110
|
*/
|
|
4025
4111
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
4026
|
-
(0,
|
|
4112
|
+
(0, import_log15.log)("notarize", {
|
|
4027
4113
|
credentials
|
|
4028
4114
|
}, {
|
|
4029
|
-
F:
|
|
4115
|
+
F: __dxlog_file17,
|
|
4030
4116
|
L: 90,
|
|
4031
4117
|
S: this,
|
|
4032
4118
|
C: (f, a) => f(...a)
|
|
4033
4119
|
});
|
|
4034
|
-
(0,
|
|
4035
|
-
F:
|
|
4120
|
+
(0, import_invariant15.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
4121
|
+
F: __dxlog_file17,
|
|
4036
4122
|
L: 91,
|
|
4037
4123
|
S: this,
|
|
4038
4124
|
A: [
|
|
@@ -4043,10 +4129,10 @@ var NotarizationPlugin = class {
|
|
|
4043
4129
|
const errors = new import_async15.Trigger();
|
|
4044
4130
|
const ctx = this._ctx.derive({
|
|
4045
4131
|
onError: (err) => {
|
|
4046
|
-
|
|
4132
|
+
import_log15.log.warn("Notarization error", {
|
|
4047
4133
|
err
|
|
4048
4134
|
}, {
|
|
4049
|
-
F:
|
|
4135
|
+
F: __dxlog_file17,
|
|
4050
4136
|
L: 99,
|
|
4051
4137
|
S: this,
|
|
4052
4138
|
C: (f, a) => f(...a)
|
|
@@ -4058,11 +4144,11 @@ var NotarizationPlugin = class {
|
|
|
4058
4144
|
opCtx?.onDispose(() => ctx.dispose());
|
|
4059
4145
|
if (timeout !== 0) {
|
|
4060
4146
|
(0, import_async15.scheduleTask)(ctx, () => {
|
|
4061
|
-
|
|
4147
|
+
import_log15.log.warn("Notarization timeout", {
|
|
4062
4148
|
timeout,
|
|
4063
4149
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
4064
4150
|
}, {
|
|
4065
|
-
F:
|
|
4151
|
+
F: __dxlog_file17,
|
|
4066
4152
|
L: 111,
|
|
4067
4153
|
S: this,
|
|
4068
4154
|
C: (f, a) => f(...a)
|
|
@@ -4082,10 +4168,10 @@ var NotarizationPlugin = class {
|
|
|
4082
4168
|
...this._extensions
|
|
4083
4169
|
].find((peer2) => !peersTried.has(peer2));
|
|
4084
4170
|
if (!peer) {
|
|
4085
|
-
|
|
4171
|
+
import_log15.log.info("Exhausted all peers to notarize with", {
|
|
4086
4172
|
retryIn: retryTimeout
|
|
4087
4173
|
}, {
|
|
4088
|
-
F:
|
|
4174
|
+
F: __dxlog_file17,
|
|
4089
4175
|
L: 136,
|
|
4090
4176
|
S: this,
|
|
4091
4177
|
C: (f, a) => f(...a)
|
|
@@ -4095,11 +4181,11 @@ var NotarizationPlugin = class {
|
|
|
4095
4181
|
return;
|
|
4096
4182
|
}
|
|
4097
4183
|
peersTried.add(peer);
|
|
4098
|
-
(0,
|
|
4184
|
+
(0, import_log15.log)("try notarizing", {
|
|
4099
4185
|
peer: peer.localPeerId,
|
|
4100
4186
|
credentialId: credentials.map((credential) => credential.id)
|
|
4101
4187
|
}, {
|
|
4102
|
-
F:
|
|
4188
|
+
F: __dxlog_file17,
|
|
4103
4189
|
L: 143,
|
|
4104
4190
|
S: this,
|
|
4105
4191
|
C: (f, a) => f(...a)
|
|
@@ -4107,8 +4193,8 @@ var NotarizationPlugin = class {
|
|
|
4107
4193
|
await peer.rpc.NotarizationService.notarize({
|
|
4108
4194
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
4109
4195
|
});
|
|
4110
|
-
(0,
|
|
4111
|
-
F:
|
|
4196
|
+
(0, import_log15.log)("success", void 0, {
|
|
4197
|
+
F: __dxlog_file17,
|
|
4112
4198
|
L: 147,
|
|
4113
4199
|
S: this,
|
|
4114
4200
|
C: (f, a) => f(...a)
|
|
@@ -4116,8 +4202,8 @@ var NotarizationPlugin = class {
|
|
|
4116
4202
|
await (0, import_async15.sleep)(successDelay);
|
|
4117
4203
|
} catch (err) {
|
|
4118
4204
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
4119
|
-
|
|
4120
|
-
F:
|
|
4205
|
+
import_log15.log.info("error notarizing (recoverable)", err, {
|
|
4206
|
+
F: __dxlog_file17,
|
|
4121
4207
|
L: 151,
|
|
4122
4208
|
S: this,
|
|
4123
4209
|
C: (f, a) => f(...a)
|
|
@@ -4134,8 +4220,8 @@ var NotarizationPlugin = class {
|
|
|
4134
4220
|
allNotarized,
|
|
4135
4221
|
errors.wait()
|
|
4136
4222
|
]);
|
|
4137
|
-
(0,
|
|
4138
|
-
F:
|
|
4223
|
+
(0, import_log15.log)("done", void 0, {
|
|
4224
|
+
F: __dxlog_file17,
|
|
4139
4225
|
L: 162,
|
|
4140
4226
|
S: this,
|
|
4141
4227
|
C: (f, a) => f(...a)
|
|
@@ -4156,8 +4242,8 @@ var NotarizationPlugin = class {
|
|
|
4156
4242
|
this._processCredentialsTriggers.delete(credential.id);
|
|
4157
4243
|
}
|
|
4158
4244
|
setWriter(writer) {
|
|
4159
|
-
(0,
|
|
4160
|
-
F:
|
|
4245
|
+
(0, import_invariant15.invariant)(!this._writer, "Writer already set.", {
|
|
4246
|
+
F: __dxlog_file17,
|
|
4161
4247
|
L: 181,
|
|
4162
4248
|
S: this,
|
|
4163
4249
|
A: [
|
|
@@ -4171,7 +4257,7 @@ var NotarizationPlugin = class {
|
|
|
4171
4257
|
if (this._processedCredentials.has(id)) {
|
|
4172
4258
|
return;
|
|
4173
4259
|
}
|
|
4174
|
-
await (0,
|
|
4260
|
+
await (0, import_util9.entry)(this._processCredentialsTriggers, id).orInsert(new import_async15.Trigger()).value.wait();
|
|
4175
4261
|
}
|
|
4176
4262
|
/**
|
|
4177
4263
|
* Requests from other peers to notarize credentials.
|
|
@@ -4181,8 +4267,8 @@ var NotarizationPlugin = class {
|
|
|
4181
4267
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
4182
4268
|
}
|
|
4183
4269
|
for (const credential of request.credentials ?? []) {
|
|
4184
|
-
(0,
|
|
4185
|
-
F:
|
|
4270
|
+
(0, import_invariant15.invariant)(credential.id, "Credential must have an id", {
|
|
4271
|
+
F: __dxlog_file17,
|
|
4186
4272
|
L: 200,
|
|
4187
4273
|
S: this,
|
|
4188
4274
|
A: [
|
|
@@ -4199,10 +4285,10 @@ var NotarizationPlugin = class {
|
|
|
4199
4285
|
createExtension() {
|
|
4200
4286
|
const extension = new NotarizationTeleportExtension({
|
|
4201
4287
|
onOpen: async () => {
|
|
4202
|
-
(0,
|
|
4288
|
+
(0, import_log15.log)("extension opened", {
|
|
4203
4289
|
peer: extension.localPeerId
|
|
4204
4290
|
}, {
|
|
4205
|
-
F:
|
|
4291
|
+
F: __dxlog_file17,
|
|
4206
4292
|
L: 211,
|
|
4207
4293
|
S: this,
|
|
4208
4294
|
C: (f, a) => f(...a)
|
|
@@ -4211,10 +4297,10 @@ var NotarizationPlugin = class {
|
|
|
4211
4297
|
this._extensionOpened.emit();
|
|
4212
4298
|
},
|
|
4213
4299
|
onClose: async () => {
|
|
4214
|
-
(0,
|
|
4300
|
+
(0, import_log15.log)("extension closed", {
|
|
4215
4301
|
peer: extension.localPeerId
|
|
4216
4302
|
}, {
|
|
4217
|
-
F:
|
|
4303
|
+
F: __dxlog_file17,
|
|
4218
4304
|
L: 216,
|
|
4219
4305
|
S: this,
|
|
4220
4306
|
C: (f, a) => f(...a)
|
|
@@ -4256,7 +4342,7 @@ var NotarizationTeleportExtension = class extends import_teleport3.RpcExtension
|
|
|
4256
4342
|
await super.onClose(err);
|
|
4257
4343
|
}
|
|
4258
4344
|
};
|
|
4259
|
-
function
|
|
4345
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
4260
4346
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4261
4347
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4262
4348
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4329,18 +4415,18 @@ function _using_ctx() {
|
|
|
4329
4415
|
}
|
|
4330
4416
|
};
|
|
4331
4417
|
}
|
|
4332
|
-
var
|
|
4418
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
4333
4419
|
var DataSpace = class {
|
|
4334
4420
|
constructor(params) {
|
|
4335
4421
|
this._ctx = new import_context10.Context(void 0, {
|
|
4336
|
-
F:
|
|
4422
|
+
F: __dxlog_file18,
|
|
4337
4423
|
L: 84
|
|
4338
4424
|
});
|
|
4339
4425
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
4340
4426
|
this._cache = void 0;
|
|
4341
4427
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
4342
4428
|
this._epochProcessingMutex = new import_async13.Mutex();
|
|
4343
|
-
this._state =
|
|
4429
|
+
this._state = import_services13.SpaceState.SPACE_CLOSED;
|
|
4344
4430
|
this._databaseRoot = null;
|
|
4345
4431
|
this.error = void 0;
|
|
4346
4432
|
this.stateUpdate = new import_async13.Event();
|
|
@@ -4356,16 +4442,16 @@ var DataSpace = class {
|
|
|
4356
4442
|
this._callbacks = params.callbacks ?? {};
|
|
4357
4443
|
this._echoHost = params.echoHost;
|
|
4358
4444
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
4359
|
-
trustedKeysProvider: () => new
|
|
4445
|
+
trustedKeysProvider: () => new import_util8.ComplexSet(import_keys10.PublicKey.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== import_credentials13.SpaceMember.Role.REMOVED).map((member) => member.key)),
|
|
4360
4446
|
update: this._inner.stateUpdate,
|
|
4361
|
-
authTimeout:
|
|
4447
|
+
authTimeout: import_client_protocol5.AUTH_TIMEOUT
|
|
4362
4448
|
});
|
|
4363
4449
|
this._cache = params.cache;
|
|
4364
4450
|
this._state = params.initialState;
|
|
4365
|
-
(0,
|
|
4366
|
-
state:
|
|
4451
|
+
(0, import_log13.log)("new state", {
|
|
4452
|
+
state: import_services13.SpaceState[this._state]
|
|
4367
4453
|
}, {
|
|
4368
|
-
F:
|
|
4454
|
+
F: __dxlog_file18,
|
|
4369
4455
|
L: 146,
|
|
4370
4456
|
S: this,
|
|
4371
4457
|
C: (f, a) => f(...a)
|
|
@@ -4409,7 +4495,7 @@ var DataSpace = class {
|
|
|
4409
4495
|
};
|
|
4410
4496
|
}
|
|
4411
4497
|
async open() {
|
|
4412
|
-
if (this._state ===
|
|
4498
|
+
if (this._state === import_services13.SpaceState.SPACE_CLOSED) {
|
|
4413
4499
|
await this._open();
|
|
4414
4500
|
}
|
|
4415
4501
|
}
|
|
@@ -4421,14 +4507,14 @@ var DataSpace = class {
|
|
|
4421
4507
|
await this._automergeSpaceState.open();
|
|
4422
4508
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
4423
4509
|
await this._inner.open(new import_context10.Context(void 0, {
|
|
4424
|
-
F:
|
|
4510
|
+
F: __dxlog_file18,
|
|
4425
4511
|
L: 215
|
|
4426
4512
|
}));
|
|
4427
|
-
this._state =
|
|
4428
|
-
(0,
|
|
4429
|
-
state:
|
|
4513
|
+
this._state = import_services13.SpaceState.SPACE_CONTROL_ONLY;
|
|
4514
|
+
(0, import_log13.log)("new state", {
|
|
4515
|
+
state: import_services13.SpaceState[this._state]
|
|
4430
4516
|
}, {
|
|
4431
|
-
F:
|
|
4517
|
+
F: __dxlog_file18,
|
|
4432
4518
|
L: 217,
|
|
4433
4519
|
S: this,
|
|
4434
4520
|
C: (f, a) => f(...a)
|
|
@@ -4442,18 +4528,18 @@ var DataSpace = class {
|
|
|
4442
4528
|
}
|
|
4443
4529
|
async _close() {
|
|
4444
4530
|
await this._callbacks.beforeClose?.();
|
|
4445
|
-
this._state =
|
|
4446
|
-
(0,
|
|
4447
|
-
state:
|
|
4531
|
+
this._state = import_services13.SpaceState.SPACE_CLOSED;
|
|
4532
|
+
(0, import_log13.log)("new state", {
|
|
4533
|
+
state: import_services13.SpaceState[this._state]
|
|
4448
4534
|
}, {
|
|
4449
|
-
F:
|
|
4535
|
+
F: __dxlog_file18,
|
|
4450
4536
|
L: 231,
|
|
4451
4537
|
S: this,
|
|
4452
4538
|
C: (f, a) => f(...a)
|
|
4453
4539
|
});
|
|
4454
4540
|
await this._ctx.dispose();
|
|
4455
4541
|
this._ctx = new import_context10.Context(void 0, {
|
|
4456
|
-
F:
|
|
4542
|
+
F: __dxlog_file18,
|
|
4457
4543
|
L: 233
|
|
4458
4544
|
});
|
|
4459
4545
|
await this.authVerifier.close();
|
|
@@ -4481,25 +4567,25 @@ var DataSpace = class {
|
|
|
4481
4567
|
await this.initializeDataPipeline();
|
|
4482
4568
|
} catch (err) {
|
|
4483
4569
|
if (err instanceof import_protocols9.CancelledError || err instanceof import_context10.ContextDisposedError) {
|
|
4484
|
-
(0,
|
|
4485
|
-
F:
|
|
4570
|
+
(0, import_log13.log)("data pipeline initialization cancelled", err, {
|
|
4571
|
+
F: __dxlog_file18,
|
|
4486
4572
|
L: 265,
|
|
4487
4573
|
S: this,
|
|
4488
4574
|
C: (f, a) => f(...a)
|
|
4489
4575
|
});
|
|
4490
4576
|
return;
|
|
4491
4577
|
}
|
|
4492
|
-
|
|
4493
|
-
F:
|
|
4578
|
+
import_log13.log.error("Error initializing data pipeline", err, {
|
|
4579
|
+
F: __dxlog_file18,
|
|
4494
4580
|
L: 269,
|
|
4495
4581
|
S: this,
|
|
4496
4582
|
C: (f, a) => f(...a)
|
|
4497
4583
|
});
|
|
4498
|
-
this._state =
|
|
4499
|
-
(0,
|
|
4500
|
-
state:
|
|
4584
|
+
this._state = import_services13.SpaceState.SPACE_ERROR;
|
|
4585
|
+
(0, import_log13.log)("new state", {
|
|
4586
|
+
state: import_services13.SpaceState[this._state]
|
|
4501
4587
|
}, {
|
|
4502
|
-
F:
|
|
4588
|
+
F: __dxlog_file18,
|
|
4503
4589
|
L: 271,
|
|
4504
4590
|
S: this,
|
|
4505
4591
|
C: (f, a) => f(...a)
|
|
@@ -4512,31 +4598,31 @@ var DataSpace = class {
|
|
|
4512
4598
|
});
|
|
4513
4599
|
}
|
|
4514
4600
|
async initializeDataPipeline() {
|
|
4515
|
-
if (this._state !==
|
|
4601
|
+
if (this._state !== import_services13.SpaceState.SPACE_CONTROL_ONLY) {
|
|
4516
4602
|
throw new import_protocols9.SystemError("Invalid operation");
|
|
4517
4603
|
}
|
|
4518
|
-
this._state =
|
|
4519
|
-
(0,
|
|
4520
|
-
state:
|
|
4604
|
+
this._state = import_services13.SpaceState.SPACE_INITIALIZING;
|
|
4605
|
+
(0, import_log13.log)("new state", {
|
|
4606
|
+
state: import_services13.SpaceState[this._state]
|
|
4521
4607
|
}, {
|
|
4522
|
-
F:
|
|
4608
|
+
F: __dxlog_file18,
|
|
4523
4609
|
L: 287,
|
|
4524
4610
|
S: this,
|
|
4525
4611
|
C: (f, a) => f(...a)
|
|
4526
4612
|
});
|
|
4527
4613
|
await this._initializeAndReadControlPipeline();
|
|
4528
4614
|
await (0, import_async13.sleep)(1);
|
|
4529
|
-
const ready = this.stateUpdate.waitForCondition(() => this._state ===
|
|
4615
|
+
const ready = this.stateUpdate.waitForCondition(() => this._state === import_services13.SpaceState.SPACE_READY);
|
|
4530
4616
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
4531
4617
|
await ready;
|
|
4532
4618
|
}
|
|
4533
4619
|
async _enterReadyState() {
|
|
4534
4620
|
await this._callbacks.beforeReady?.();
|
|
4535
|
-
this._state =
|
|
4536
|
-
(0,
|
|
4537
|
-
state:
|
|
4621
|
+
this._state = import_services13.SpaceState.SPACE_READY;
|
|
4622
|
+
(0, import_log13.log)("new state", {
|
|
4623
|
+
state: import_services13.SpaceState[this._state]
|
|
4538
4624
|
}, {
|
|
4539
|
-
F:
|
|
4625
|
+
F: __dxlog_file18,
|
|
4540
4626
|
L: 306,
|
|
4541
4627
|
S: this,
|
|
4542
4628
|
C: (f, a) => f(...a)
|
|
@@ -4551,8 +4637,8 @@ var DataSpace = class {
|
|
|
4551
4637
|
});
|
|
4552
4638
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
4553
4639
|
await this._createWritableFeeds();
|
|
4554
|
-
(0,
|
|
4555
|
-
F:
|
|
4640
|
+
(0, import_log13.log)("writable feeds created", void 0, {
|
|
4641
|
+
F: __dxlog_file18,
|
|
4556
4642
|
L: 322,
|
|
4557
4643
|
S: this,
|
|
4558
4644
|
C: (f, a) => f(...a)
|
|
@@ -4611,11 +4697,11 @@ var DataSpace = class {
|
|
|
4611
4697
|
}
|
|
4612
4698
|
}
|
|
4613
4699
|
_onNewAutomergeRoot(rootUrl) {
|
|
4614
|
-
(0,
|
|
4700
|
+
(0, import_log13.log)("loading automerge root doc for space", {
|
|
4615
4701
|
space: this.key,
|
|
4616
4702
|
rootUrl
|
|
4617
4703
|
}, {
|
|
4618
|
-
F:
|
|
4704
|
+
F: __dxlog_file18,
|
|
4619
4705
|
L: 388,
|
|
4620
4706
|
S: this,
|
|
4621
4707
|
C: (f, a) => f(...a)
|
|
@@ -4635,7 +4721,7 @@ var DataSpace = class {
|
|
|
4635
4721
|
// Ensure only one root is processed at a time.
|
|
4636
4722
|
_usingCtx.u(await this._epochProcessingMutex.acquire())
|
|
4637
4723
|
);
|
|
4638
|
-
const doc = handle.docSync() ?? (0,
|
|
4724
|
+
const doc = handle.docSync() ?? (0, import_invariant13.failedInvariant)();
|
|
4639
4725
|
if (!doc.access?.spaceKey) {
|
|
4640
4726
|
handle.change((doc2) => {
|
|
4641
4727
|
doc2.access = {
|
|
@@ -4646,9 +4732,9 @@ var DataSpace = class {
|
|
|
4646
4732
|
const root = await this._echoHost.openSpaceRoot(this.id, handle.url);
|
|
4647
4733
|
this._databaseRoot = root;
|
|
4648
4734
|
if (root.getVersion() !== import_echo_protocol.SpaceDocVersion.CURRENT) {
|
|
4649
|
-
this._state =
|
|
4735
|
+
this._state = import_services13.SpaceState.SPACE_REQUIRES_MIGRATION;
|
|
4650
4736
|
this.stateUpdate.emit();
|
|
4651
|
-
} else if (this._state !==
|
|
4737
|
+
} else if (this._state !== import_services13.SpaceState.SPACE_READY) {
|
|
4652
4738
|
await this._enterReadyState();
|
|
4653
4739
|
} else {
|
|
4654
4740
|
this.stateUpdate.emit();
|
|
@@ -4662,12 +4748,12 @@ var DataSpace = class {
|
|
|
4662
4748
|
if (err instanceof import_context10.ContextDisposedError) {
|
|
4663
4749
|
return;
|
|
4664
4750
|
}
|
|
4665
|
-
|
|
4751
|
+
import_log13.log.warn("error loading automerge root doc", {
|
|
4666
4752
|
space: this.key,
|
|
4667
4753
|
rootUrl,
|
|
4668
4754
|
err
|
|
4669
4755
|
}, {
|
|
4670
|
-
F:
|
|
4756
|
+
F: __dxlog_file18,
|
|
4671
4757
|
L: 431,
|
|
4672
4758
|
S: this,
|
|
4673
4759
|
C: (f, a) => f(...a)
|
|
@@ -4736,28 +4822,28 @@ var DataSpace = class {
|
|
|
4736
4822
|
}
|
|
4737
4823
|
async activate() {
|
|
4738
4824
|
if (![
|
|
4739
|
-
|
|
4740
|
-
|
|
4825
|
+
import_services13.SpaceState.SPACE_CLOSED,
|
|
4826
|
+
import_services13.SpaceState.SPACE_INACTIVE
|
|
4741
4827
|
].includes(this._state)) {
|
|
4742
4828
|
return;
|
|
4743
4829
|
}
|
|
4744
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
4830
|
+
await this._metadataStore.setSpaceState(this.key, import_services13.SpaceState.SPACE_ACTIVE);
|
|
4745
4831
|
await this._open();
|
|
4746
4832
|
this.initializeDataPipelineAsync();
|
|
4747
4833
|
}
|
|
4748
4834
|
async deactivate() {
|
|
4749
|
-
if (this._state ===
|
|
4835
|
+
if (this._state === import_services13.SpaceState.SPACE_INACTIVE) {
|
|
4750
4836
|
return;
|
|
4751
4837
|
}
|
|
4752
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
4753
|
-
if (this._state !==
|
|
4838
|
+
await this._metadataStore.setSpaceState(this.key, import_services13.SpaceState.SPACE_INACTIVE);
|
|
4839
|
+
if (this._state !== import_services13.SpaceState.SPACE_CLOSED) {
|
|
4754
4840
|
await this._close();
|
|
4755
4841
|
}
|
|
4756
|
-
this._state =
|
|
4757
|
-
(0,
|
|
4758
|
-
state:
|
|
4842
|
+
this._state = import_services13.SpaceState.SPACE_INACTIVE;
|
|
4843
|
+
(0, import_log13.log)("new state", {
|
|
4844
|
+
state: import_services13.SpaceState[this._state]
|
|
4759
4845
|
}, {
|
|
4760
|
-
F:
|
|
4846
|
+
F: __dxlog_file18,
|
|
4761
4847
|
L: 513,
|
|
4762
4848
|
S: this,
|
|
4763
4849
|
C: (f, a) => f(...a)
|
|
@@ -4765,53 +4851,53 @@ var DataSpace = class {
|
|
|
4765
4851
|
this.stateUpdate.emit();
|
|
4766
4852
|
}
|
|
4767
4853
|
};
|
|
4768
|
-
|
|
4769
|
-
|
|
4854
|
+
_ts_decorate5([
|
|
4855
|
+
import_tracing7.trace.info()
|
|
4770
4856
|
], DataSpace.prototype, "_inner", void 0);
|
|
4771
|
-
|
|
4772
|
-
|
|
4857
|
+
_ts_decorate5([
|
|
4858
|
+
import_tracing7.trace.info()
|
|
4773
4859
|
], DataSpace.prototype, "id", null);
|
|
4774
|
-
|
|
4775
|
-
|
|
4860
|
+
_ts_decorate5([
|
|
4861
|
+
import_tracing7.trace.info()
|
|
4776
4862
|
], DataSpace.prototype, "key", null);
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
enum:
|
|
4863
|
+
_ts_decorate5([
|
|
4864
|
+
import_tracing7.trace.info({
|
|
4865
|
+
enum: import_services13.SpaceState
|
|
4780
4866
|
})
|
|
4781
4867
|
], DataSpace.prototype, "state", null);
|
|
4782
|
-
|
|
4783
|
-
|
|
4868
|
+
_ts_decorate5([
|
|
4869
|
+
import_tracing7.trace.info({
|
|
4784
4870
|
depth: null
|
|
4785
4871
|
})
|
|
4786
4872
|
], DataSpace.prototype, "_automergeInfo", null);
|
|
4787
|
-
|
|
4873
|
+
_ts_decorate5([
|
|
4788
4874
|
import_async13.synchronized
|
|
4789
4875
|
], DataSpace.prototype, "open", null);
|
|
4790
|
-
|
|
4876
|
+
_ts_decorate5([
|
|
4791
4877
|
import_async13.synchronized
|
|
4792
4878
|
], DataSpace.prototype, "close", null);
|
|
4793
|
-
|
|
4794
|
-
|
|
4879
|
+
_ts_decorate5([
|
|
4880
|
+
import_tracing7.trace.span({
|
|
4795
4881
|
showInBrowserTimeline: true
|
|
4796
4882
|
})
|
|
4797
4883
|
], DataSpace.prototype, "initializeDataPipeline", null);
|
|
4798
|
-
|
|
4799
|
-
|
|
4884
|
+
_ts_decorate5([
|
|
4885
|
+
import_tracing7.trace.span({
|
|
4800
4886
|
showInBrowserTimeline: true
|
|
4801
4887
|
})
|
|
4802
4888
|
], DataSpace.prototype, "_initializeAndReadControlPipeline", null);
|
|
4803
|
-
|
|
4889
|
+
_ts_decorate5([
|
|
4804
4890
|
(0, import_debug3.timed)(1e4)
|
|
4805
4891
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
4806
|
-
|
|
4892
|
+
_ts_decorate5([
|
|
4807
4893
|
import_async13.synchronized
|
|
4808
4894
|
], DataSpace.prototype, "activate", null);
|
|
4809
|
-
|
|
4895
|
+
_ts_decorate5([
|
|
4810
4896
|
import_async13.synchronized
|
|
4811
4897
|
], DataSpace.prototype, "deactivate", null);
|
|
4812
|
-
DataSpace =
|
|
4898
|
+
DataSpace = _ts_decorate5([
|
|
4813
4899
|
(0, import_async13.trackLeaks)("open", "close"),
|
|
4814
|
-
|
|
4900
|
+
import_tracing7.trace.resource()
|
|
4815
4901
|
], DataSpace);
|
|
4816
4902
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
4817
4903
|
const credentials = [
|
|
@@ -4877,7 +4963,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
4877
4963
|
}
|
|
4878
4964
|
return credentials;
|
|
4879
4965
|
};
|
|
4880
|
-
function
|
|
4966
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
4881
4967
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4882
4968
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4883
4969
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4887,7 +4973,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
4887
4973
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4888
4974
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4889
4975
|
}
|
|
4890
|
-
var
|
|
4976
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
4891
4977
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
4892
4978
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
4893
4979
|
var DEFAULT_SPACE_KEY = "__DEFAULT__";
|
|
@@ -4902,14 +4988,14 @@ var DataSpaceManager = class {
|
|
|
4902
4988
|
this._invitationsManager = _invitationsManager;
|
|
4903
4989
|
this._params = _params;
|
|
4904
4990
|
this._ctx = new import_context13.Context(void 0, {
|
|
4905
|
-
F:
|
|
4991
|
+
F: __dxlog_file19,
|
|
4906
4992
|
L: 104
|
|
4907
4993
|
});
|
|
4908
4994
|
this.updated = new import_async16.Event();
|
|
4909
|
-
this._spaces = new
|
|
4995
|
+
this._spaces = new import_util10.ComplexMap(import_keys12.PublicKey.hash);
|
|
4910
4996
|
this._isOpen = false;
|
|
4911
4997
|
this._instanceId = import_keys12.PublicKey.random().toHex();
|
|
4912
|
-
|
|
4998
|
+
import_tracing8.trace.diagnostic({
|
|
4913
4999
|
id: "spaces",
|
|
4914
5000
|
name: "Spaces",
|
|
4915
5001
|
fetch: async () => {
|
|
@@ -4920,7 +5006,7 @@ var DataSpaceManager = class {
|
|
|
4920
5006
|
const properties = rootDoc && (0, import_echo_db2.findInlineObjectOfType)(rootDoc, import_echo_schema2.TYPE_PROPERTIES);
|
|
4921
5007
|
return {
|
|
4922
5008
|
key: space.key.toHex(),
|
|
4923
|
-
state:
|
|
5009
|
+
state: import_services15.SpaceState[space.state],
|
|
4924
5010
|
name: properties?.[1].data.name ?? null,
|
|
4925
5011
|
inlineObjects: rootDoc ? Object.keys(rootDoc.objects ?? {}).length : null,
|
|
4926
5012
|
linkedObjects: rootDoc ? Object.keys(rootDoc.links ?? {}).length : null,
|
|
@@ -4937,45 +5023,45 @@ var DataSpaceManager = class {
|
|
|
4937
5023
|
return this._spaces;
|
|
4938
5024
|
}
|
|
4939
5025
|
async open() {
|
|
4940
|
-
(0,
|
|
4941
|
-
F:
|
|
5026
|
+
(0, import_log16.log)("open", void 0, {
|
|
5027
|
+
F: __dxlog_file19,
|
|
4942
5028
|
L: 156,
|
|
4943
5029
|
S: this,
|
|
4944
5030
|
C: (f, a) => f(...a)
|
|
4945
5031
|
});
|
|
4946
|
-
|
|
5032
|
+
import_log16.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.begin({
|
|
4947
5033
|
id: this._instanceId
|
|
4948
5034
|
}), {
|
|
4949
|
-
F:
|
|
5035
|
+
F: __dxlog_file19,
|
|
4950
5036
|
L: 157,
|
|
4951
5037
|
S: this,
|
|
4952
5038
|
C: (f, a) => f(...a)
|
|
4953
5039
|
});
|
|
4954
|
-
(0,
|
|
5040
|
+
(0, import_log16.log)("metadata loaded", {
|
|
4955
5041
|
spaces: this._metadataStore.spaces.length
|
|
4956
5042
|
}, {
|
|
4957
|
-
F:
|
|
5043
|
+
F: __dxlog_file19,
|
|
4958
5044
|
L: 158,
|
|
4959
5045
|
S: this,
|
|
4960
5046
|
C: (f, a) => f(...a)
|
|
4961
5047
|
});
|
|
4962
|
-
await (0,
|
|
5048
|
+
await (0, import_util10.forEachAsync)(this._metadataStore.spaces, async (spaceMetadata) => {
|
|
4963
5049
|
try {
|
|
4964
|
-
(0,
|
|
5050
|
+
(0, import_log16.log)("load space", {
|
|
4965
5051
|
spaceMetadata
|
|
4966
5052
|
}, {
|
|
4967
|
-
F:
|
|
5053
|
+
F: __dxlog_file19,
|
|
4968
5054
|
L: 162,
|
|
4969
5055
|
S: this,
|
|
4970
5056
|
C: (f, a) => f(...a)
|
|
4971
5057
|
});
|
|
4972
5058
|
await this._constructSpace(spaceMetadata);
|
|
4973
5059
|
} catch (err) {
|
|
4974
|
-
|
|
5060
|
+
import_log16.log.error("Error loading space", {
|
|
4975
5061
|
spaceMetadata,
|
|
4976
5062
|
err
|
|
4977
5063
|
}, {
|
|
4978
|
-
F:
|
|
5064
|
+
F: __dxlog_file19,
|
|
4979
5065
|
L: 165,
|
|
4980
5066
|
S: this,
|
|
4981
5067
|
C: (f, a) => f(...a)
|
|
@@ -4984,18 +5070,18 @@ var DataSpaceManager = class {
|
|
|
4984
5070
|
});
|
|
4985
5071
|
this._isOpen = true;
|
|
4986
5072
|
this.updated.emit();
|
|
4987
|
-
|
|
5073
|
+
import_log16.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.end({
|
|
4988
5074
|
id: this._instanceId
|
|
4989
5075
|
}), {
|
|
4990
|
-
F:
|
|
5076
|
+
F: __dxlog_file19,
|
|
4991
5077
|
L: 172,
|
|
4992
5078
|
S: this,
|
|
4993
5079
|
C: (f, a) => f(...a)
|
|
4994
5080
|
});
|
|
4995
5081
|
}
|
|
4996
5082
|
async close() {
|
|
4997
|
-
(0,
|
|
4998
|
-
F:
|
|
5083
|
+
(0, import_log16.log)("close", void 0, {
|
|
5084
|
+
F: __dxlog_file19,
|
|
4999
5085
|
L: 177,
|
|
5000
5086
|
S: this,
|
|
5001
5087
|
C: (f, a) => f(...a)
|
|
@@ -5011,8 +5097,8 @@ var DataSpaceManager = class {
|
|
|
5011
5097
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
5012
5098
|
*/
|
|
5013
5099
|
async createSpace() {
|
|
5014
|
-
(0,
|
|
5015
|
-
F:
|
|
5100
|
+
(0, import_invariant16.invariant)(this._isOpen, "Not open.", {
|
|
5101
|
+
F: __dxlog_file19,
|
|
5016
5102
|
L: 191,
|
|
5017
5103
|
S: this,
|
|
5018
5104
|
A: [
|
|
@@ -5028,12 +5114,12 @@ var DataSpaceManager = class {
|
|
|
5028
5114
|
genesisFeedKey: controlFeedKey,
|
|
5029
5115
|
controlFeedKey,
|
|
5030
5116
|
dataFeedKey,
|
|
5031
|
-
state:
|
|
5117
|
+
state: import_services15.SpaceState.SPACE_ACTIVE
|
|
5032
5118
|
};
|
|
5033
|
-
(0,
|
|
5119
|
+
(0, import_log16.log)("creating space...", {
|
|
5034
5120
|
spaceKey
|
|
5035
5121
|
}, {
|
|
5036
|
-
F:
|
|
5122
|
+
F: __dxlog_file19,
|
|
5037
5123
|
L: 203,
|
|
5038
5124
|
S: this,
|
|
5039
5125
|
C: (f, a) => f(...a)
|
|
@@ -5044,8 +5130,8 @@ var DataSpaceManager = class {
|
|
|
5044
5130
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, root.url);
|
|
5045
5131
|
await this._metadataStore.addSpace(metadata);
|
|
5046
5132
|
const memberCredential = credentials[1];
|
|
5047
|
-
(0,
|
|
5048
|
-
F:
|
|
5133
|
+
(0, import_invariant16.invariant)((0, import_credentials15.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5134
|
+
F: __dxlog_file19,
|
|
5049
5135
|
L: 213,
|
|
5050
5136
|
S: this,
|
|
5051
5137
|
A: [
|
|
@@ -5073,11 +5159,11 @@ var DataSpaceManager = class {
|
|
|
5073
5159
|
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
5074
5160
|
}
|
|
5075
5161
|
default:
|
|
5076
|
-
|
|
5162
|
+
import_log16.log.warn("unknown space version", {
|
|
5077
5163
|
version: space.databaseRoot.getVersion(),
|
|
5078
5164
|
spaceId: space.id
|
|
5079
5165
|
}, {
|
|
5080
|
-
F:
|
|
5166
|
+
F: __dxlog_file19,
|
|
5081
5167
|
L: 238,
|
|
5082
5168
|
S: this,
|
|
5083
5169
|
C: (f, a) => f(...a)
|
|
@@ -5090,7 +5176,7 @@ var DataSpaceManager = class {
|
|
|
5090
5176
|
const document = await this._getSpaceRootDocument(space);
|
|
5091
5177
|
const properties = {
|
|
5092
5178
|
system: {
|
|
5093
|
-
type: (0, import_echo_protocol3.encodeReference)((0, import_echo_schema2.getTypeReference)(
|
|
5179
|
+
type: (0, import_echo_protocol3.encodeReference)((0, import_echo_schema2.getTypeReference)(import_client_protocol6.PropertiesType))
|
|
5094
5180
|
},
|
|
5095
5181
|
data: {
|
|
5096
5182
|
[DEFAULT_SPACE_KEY]: this._signingContext.identityKey.toHex()
|
|
@@ -5101,7 +5187,7 @@ var DataSpaceManager = class {
|
|
|
5101
5187
|
};
|
|
5102
5188
|
const propertiesId = (0, import_echo_schema2.generateEchoId)();
|
|
5103
5189
|
document.change((doc) => {
|
|
5104
|
-
(0,
|
|
5190
|
+
(0, import_util10.assignDeep)(doc, [
|
|
5105
5191
|
"objects",
|
|
5106
5192
|
propertiesId
|
|
5107
5193
|
], properties);
|
|
@@ -5111,8 +5197,8 @@ var DataSpaceManager = class {
|
|
|
5111
5197
|
}
|
|
5112
5198
|
async _getSpaceRootDocument(space) {
|
|
5113
5199
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5114
|
-
(0,
|
|
5115
|
-
F:
|
|
5200
|
+
(0, import_invariant16.invariant)(automergeIndex, void 0, {
|
|
5201
|
+
F: __dxlog_file19,
|
|
5116
5202
|
L: 271,
|
|
5117
5203
|
S: this,
|
|
5118
5204
|
A: [
|
|
@@ -5126,16 +5212,16 @@ var DataSpaceManager = class {
|
|
|
5126
5212
|
}
|
|
5127
5213
|
// TODO(burdon): Rename join space.
|
|
5128
5214
|
async acceptSpace(opts) {
|
|
5129
|
-
(0,
|
|
5215
|
+
(0, import_log16.log)("accept space", {
|
|
5130
5216
|
opts
|
|
5131
5217
|
}, {
|
|
5132
|
-
F:
|
|
5218
|
+
F: __dxlog_file19,
|
|
5133
5219
|
L: 280,
|
|
5134
5220
|
S: this,
|
|
5135
5221
|
C: (f, a) => f(...a)
|
|
5136
5222
|
});
|
|
5137
|
-
(0,
|
|
5138
|
-
F:
|
|
5223
|
+
(0, import_invariant16.invariant)(this._isOpen, "Not open.", {
|
|
5224
|
+
F: __dxlog_file19,
|
|
5139
5225
|
L: 281,
|
|
5140
5226
|
S: this,
|
|
5141
5227
|
A: [
|
|
@@ -5143,8 +5229,8 @@ var DataSpaceManager = class {
|
|
|
5143
5229
|
"'Not open.'"
|
|
5144
5230
|
]
|
|
5145
5231
|
});
|
|
5146
|
-
(0,
|
|
5147
|
-
F:
|
|
5232
|
+
(0, import_invariant16.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
5233
|
+
F: __dxlog_file19,
|
|
5148
5234
|
L: 282,
|
|
5149
5235
|
S: this,
|
|
5150
5236
|
A: [
|
|
@@ -5167,8 +5253,8 @@ var DataSpaceManager = class {
|
|
|
5167
5253
|
}
|
|
5168
5254
|
async admitMember(options) {
|
|
5169
5255
|
const space = this._spaceManager.spaces.get(options.spaceKey);
|
|
5170
|
-
(0,
|
|
5171
|
-
F:
|
|
5256
|
+
(0, import_invariant16.invariant)(space, void 0, {
|
|
5257
|
+
F: __dxlog_file19,
|
|
5172
5258
|
L: 302,
|
|
5173
5259
|
S: this,
|
|
5174
5260
|
A: [
|
|
@@ -5180,8 +5266,8 @@ var DataSpaceManager = class {
|
|
|
5180
5266
|
throw new import_protocols11.AlreadyJoinedError();
|
|
5181
5267
|
}
|
|
5182
5268
|
const credentials = await (0, import_credentials15.createAdmissionCredentials)(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
|
|
5183
|
-
(0,
|
|
5184
|
-
F:
|
|
5269
|
+
(0, import_invariant16.invariant)(credentials[0].credential, void 0, {
|
|
5270
|
+
F: __dxlog_file19,
|
|
5185
5271
|
L: 321,
|
|
5186
5272
|
S: this,
|
|
5187
5273
|
A: [
|
|
@@ -5190,8 +5276,8 @@ var DataSpaceManager = class {
|
|
|
5190
5276
|
]
|
|
5191
5277
|
});
|
|
5192
5278
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5193
|
-
(0,
|
|
5194
|
-
F:
|
|
5279
|
+
(0, import_invariant16.invariant)((0, import_credentials15.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5280
|
+
F: __dxlog_file19,
|
|
5195
5281
|
L: 323,
|
|
5196
5282
|
S: this,
|
|
5197
5283
|
A: [
|
|
@@ -5210,7 +5296,7 @@ var DataSpaceManager = class {
|
|
|
5210
5296
|
async waitUntilSpaceReady(spaceKey) {
|
|
5211
5297
|
await (0, import_context13.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
5212
5298
|
const space = this._spaces.get(spaceKey);
|
|
5213
|
-
return !!space && space.state ===
|
|
5299
|
+
return !!space && space.state === import_services15.SpaceState.SPACE_READY;
|
|
5214
5300
|
}));
|
|
5215
5301
|
}
|
|
5216
5302
|
async requestSpaceAdmissionCredential(spaceKey) {
|
|
@@ -5226,10 +5312,10 @@ var DataSpaceManager = class {
|
|
|
5226
5312
|
});
|
|
5227
5313
|
}
|
|
5228
5314
|
async _constructSpace(metadata) {
|
|
5229
|
-
(0,
|
|
5315
|
+
(0, import_log16.log)("construct space", {
|
|
5230
5316
|
metadata
|
|
5231
5317
|
}, {
|
|
5232
|
-
F:
|
|
5318
|
+
F: __dxlog_file19,
|
|
5233
5319
|
L: 358,
|
|
5234
5320
|
S: this,
|
|
5235
5321
|
C: (f, a) => f(...a)
|
|
@@ -5255,7 +5341,7 @@ var DataSpaceManager = class {
|
|
|
5255
5341
|
swarmIdentity: {
|
|
5256
5342
|
peerKey: this._signingContext.deviceKey,
|
|
5257
5343
|
credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
|
|
5258
|
-
credentialAuthenticator: (0,
|
|
5344
|
+
credentialAuthenticator: (0, import_util10.deferFunction)(() => dataSpace.authVerifier.verifier)
|
|
5259
5345
|
},
|
|
5260
5346
|
onAuthorizedConnection: (session) => queueMicrotask(async () => {
|
|
5261
5347
|
try {
|
|
@@ -5273,10 +5359,10 @@ var DataSpaceManager = class {
|
|
|
5273
5359
|
}
|
|
5274
5360
|
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
5275
5361
|
} catch (err) {
|
|
5276
|
-
|
|
5362
|
+
import_log16.log.warn("error on authorized connection", {
|
|
5277
5363
|
err
|
|
5278
5364
|
}, {
|
|
5279
|
-
F:
|
|
5365
|
+
F: __dxlog_file19,
|
|
5280
5366
|
L: 403,
|
|
5281
5367
|
S: this,
|
|
5282
5368
|
C: (f, a) => f(...a)
|
|
@@ -5285,15 +5371,15 @@ var DataSpaceManager = class {
|
|
|
5285
5371
|
}
|
|
5286
5372
|
}),
|
|
5287
5373
|
onAuthFailure: () => {
|
|
5288
|
-
|
|
5289
|
-
F:
|
|
5374
|
+
import_log16.log.warn("auth failure", void 0, {
|
|
5375
|
+
F: __dxlog_file19,
|
|
5290
5376
|
L: 408,
|
|
5291
5377
|
S: this,
|
|
5292
5378
|
C: (f, a) => f(...a)
|
|
5293
5379
|
});
|
|
5294
5380
|
},
|
|
5295
5381
|
onMemberRolesChanged: async (members) => {
|
|
5296
|
-
if (dataSpace?.state ===
|
|
5382
|
+
if (dataSpace?.state === import_services15.SpaceState.SPACE_READY) {
|
|
5297
5383
|
this._handleMemberRoleChanges(presence, space.protocol, members);
|
|
5298
5384
|
}
|
|
5299
5385
|
},
|
|
@@ -5306,7 +5392,7 @@ var DataSpaceManager = class {
|
|
|
5306
5392
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
5307
5393
|
const dataSpace = new DataSpace({
|
|
5308
5394
|
inner: space,
|
|
5309
|
-
initialState: metadata.state ===
|
|
5395
|
+
initialState: metadata.state === import_services15.SpaceState.SPACE_INACTIVE ? import_services15.SpaceState.SPACE_INACTIVE : import_services15.SpaceState.SPACE_CLOSED,
|
|
5310
5396
|
metadataStore: this._metadataStore,
|
|
5311
5397
|
gossip,
|
|
5312
5398
|
presence,
|
|
@@ -5316,21 +5402,21 @@ var DataSpaceManager = class {
|
|
|
5316
5402
|
signingContext: this._signingContext,
|
|
5317
5403
|
callbacks: {
|
|
5318
5404
|
beforeReady: async () => {
|
|
5319
|
-
(0,
|
|
5405
|
+
(0, import_log16.log)("before space ready", {
|
|
5320
5406
|
space: space.key
|
|
5321
5407
|
}, {
|
|
5322
|
-
F:
|
|
5408
|
+
F: __dxlog_file19,
|
|
5323
5409
|
L: 435,
|
|
5324
5410
|
S: this,
|
|
5325
5411
|
C: (f, a) => f(...a)
|
|
5326
5412
|
});
|
|
5327
5413
|
},
|
|
5328
5414
|
afterReady: async () => {
|
|
5329
|
-
(0,
|
|
5415
|
+
(0, import_log16.log)("after space ready", {
|
|
5330
5416
|
space: space.key,
|
|
5331
5417
|
open: this._isOpen
|
|
5332
5418
|
}, {
|
|
5333
|
-
F:
|
|
5419
|
+
F: __dxlog_file19,
|
|
5334
5420
|
L: 438,
|
|
5335
5421
|
S: this,
|
|
5336
5422
|
C: (f, a) => f(...a)
|
|
@@ -5346,10 +5432,10 @@ var DataSpaceManager = class {
|
|
|
5346
5432
|
}
|
|
5347
5433
|
},
|
|
5348
5434
|
beforeClose: async () => {
|
|
5349
|
-
(0,
|
|
5435
|
+
(0, import_log16.log)("before space close", {
|
|
5350
5436
|
space: space.key
|
|
5351
5437
|
}, {
|
|
5352
|
-
F:
|
|
5438
|
+
F: __dxlog_file19,
|
|
5353
5439
|
L: 446,
|
|
5354
5440
|
S: this,
|
|
5355
5441
|
C: (f, a) => f(...a)
|
|
@@ -5359,7 +5445,7 @@ var DataSpaceManager = class {
|
|
|
5359
5445
|
cache: metadata.cache
|
|
5360
5446
|
});
|
|
5361
5447
|
presence.newPeer.on((peerState) => {
|
|
5362
|
-
if (dataSpace.state ===
|
|
5448
|
+
if (dataSpace.state === import_services15.SpaceState.SPACE_READY) {
|
|
5363
5449
|
this._handleNewPeerConnected(space, peerState);
|
|
5364
5450
|
}
|
|
5365
5451
|
});
|
|
@@ -5381,16 +5467,16 @@ var DataSpaceManager = class {
|
|
|
5381
5467
|
return (s && member.role === import_credentials16.SpaceMember.Role.REMOVED !== (s.authStatus === import_echo_pipeline3.AuthStatus.FAILURE)) ?? false;
|
|
5382
5468
|
});
|
|
5383
5469
|
sessionsToClose.forEach((session) => {
|
|
5384
|
-
void session.close().catch(
|
|
5470
|
+
void session.close().catch(import_log16.log.error);
|
|
5385
5471
|
});
|
|
5386
5472
|
closedSessions += sessionsToClose.length;
|
|
5387
5473
|
}
|
|
5388
|
-
(0,
|
|
5474
|
+
(0, import_log16.log)("processed member role changes", {
|
|
5389
5475
|
roleChangeCount: memberInfo.length,
|
|
5390
5476
|
peersOnline: presence.getPeersOnline().length,
|
|
5391
5477
|
closedSessions
|
|
5392
5478
|
}, {
|
|
5393
|
-
F:
|
|
5479
|
+
F: __dxlog_file19,
|
|
5394
5480
|
L: 482,
|
|
5395
5481
|
S: this,
|
|
5396
5482
|
C: (f, a) => f(...a)
|
|
@@ -5402,20 +5488,20 @@ var DataSpaceManager = class {
|
|
|
5402
5488
|
if (role === import_credentials16.SpaceMember.Role.REMOVED) {
|
|
5403
5489
|
const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
|
|
5404
5490
|
if (session != null) {
|
|
5405
|
-
(0,
|
|
5491
|
+
(0, import_log16.log)("closing a session with a removed peer", {
|
|
5406
5492
|
peerId: peerState.peerId
|
|
5407
5493
|
}, {
|
|
5408
|
-
F:
|
|
5494
|
+
F: __dxlog_file19,
|
|
5409
5495
|
L: 496,
|
|
5410
5496
|
S: this,
|
|
5411
5497
|
C: (f, a) => f(...a)
|
|
5412
5498
|
});
|
|
5413
|
-
void session.close().catch(
|
|
5499
|
+
void session.close().catch(import_log16.log.error);
|
|
5414
5500
|
}
|
|
5415
5501
|
}
|
|
5416
5502
|
}
|
|
5417
5503
|
async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
|
|
5418
|
-
if (dataSpace?.state !==
|
|
5504
|
+
if (dataSpace?.state !== import_services15.SpaceState.SPACE_READY) {
|
|
5419
5505
|
return;
|
|
5420
5506
|
}
|
|
5421
5507
|
if (isActive) {
|
|
@@ -5432,8 +5518,8 @@ var DataSpaceManager = class {
|
|
|
5432
5518
|
async _createDelegatedInvitations(space, invitations) {
|
|
5433
5519
|
const tasks = invitations.map(([credentialId, invitation]) => {
|
|
5434
5520
|
return this._invitationsManager.createInvitation({
|
|
5435
|
-
type:
|
|
5436
|
-
kind:
|
|
5521
|
+
type: import_services15.Invitation.Type.DELEGATED,
|
|
5522
|
+
kind: import_services15.Invitation.Kind.SPACE,
|
|
5437
5523
|
spaceKey: space.key,
|
|
5438
5524
|
authMethod: invitation.authMethod,
|
|
5439
5525
|
invitationId: invitation.invitationId,
|
|
@@ -5450,22 +5536,22 @@ var DataSpaceManager = class {
|
|
|
5450
5536
|
await Promise.all(tasks);
|
|
5451
5537
|
}
|
|
5452
5538
|
};
|
|
5453
|
-
|
|
5539
|
+
_ts_decorate6([
|
|
5454
5540
|
import_async16.synchronized
|
|
5455
5541
|
], DataSpaceManager.prototype, "open", null);
|
|
5456
|
-
|
|
5542
|
+
_ts_decorate6([
|
|
5457
5543
|
import_async16.synchronized
|
|
5458
5544
|
], DataSpaceManager.prototype, "close", null);
|
|
5459
|
-
|
|
5545
|
+
_ts_decorate6([
|
|
5460
5546
|
import_async16.synchronized
|
|
5461
5547
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
5462
|
-
|
|
5548
|
+
_ts_decorate6([
|
|
5463
5549
|
import_async16.synchronized
|
|
5464
5550
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
5465
|
-
DataSpaceManager =
|
|
5551
|
+
DataSpaceManager = _ts_decorate6([
|
|
5466
5552
|
(0, import_async16.trackLeaks)("open", "close")
|
|
5467
5553
|
], DataSpaceManager);
|
|
5468
|
-
var
|
|
5554
|
+
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
5469
5555
|
var SpacesServiceImpl = class {
|
|
5470
5556
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
5471
5557
|
this._identityManager = _identityManager;
|
|
@@ -5484,10 +5570,10 @@ var SpacesServiceImpl = class {
|
|
|
5484
5570
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols12.SpaceNotFoundError(spaceKey));
|
|
5485
5571
|
if (state) {
|
|
5486
5572
|
switch (state) {
|
|
5487
|
-
case
|
|
5573
|
+
case import_services16.SpaceState.SPACE_ACTIVE:
|
|
5488
5574
|
await space.activate();
|
|
5489
5575
|
break;
|
|
5490
|
-
case
|
|
5576
|
+
case import_services16.SpaceState.SPACE_INACTIVE:
|
|
5491
5577
|
await space.deactivate();
|
|
5492
5578
|
break;
|
|
5493
5579
|
default:
|
|
@@ -5508,8 +5594,8 @@ var SpacesServiceImpl = class {
|
|
|
5508
5594
|
});
|
|
5509
5595
|
}
|
|
5510
5596
|
const credentials = await (0, import_credentials19.createAdmissionCredentials)(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
5511
|
-
(0,
|
|
5512
|
-
F:
|
|
5597
|
+
(0, import_invariant17.invariant)(credentials[0].credential, void 0, {
|
|
5598
|
+
F: __dxlog_file20,
|
|
5513
5599
|
L: 102,
|
|
5514
5600
|
S: this,
|
|
5515
5601
|
A: [
|
|
@@ -5518,8 +5604,8 @@ var SpacesServiceImpl = class {
|
|
|
5518
5604
|
]
|
|
5519
5605
|
});
|
|
5520
5606
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5521
|
-
(0,
|
|
5522
|
-
F:
|
|
5607
|
+
(0, import_invariant17.invariant)((0, import_credentials19.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5608
|
+
F: __dxlog_file20,
|
|
5523
5609
|
L: 104,
|
|
5524
5610
|
S: this,
|
|
5525
5611
|
A: [
|
|
@@ -5534,10 +5620,10 @@ var SpacesServiceImpl = class {
|
|
|
5534
5620
|
const scheduler = new import_async17.UpdateScheduler(ctx, async () => {
|
|
5535
5621
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5536
5622
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
5537
|
-
(0,
|
|
5623
|
+
(0, import_log17.log)("update", () => ({
|
|
5538
5624
|
ids: spaces.map((space) => space.id)
|
|
5539
5625
|
}), {
|
|
5540
|
-
F:
|
|
5626
|
+
F: __dxlog_file20,
|
|
5541
5627
|
L: 115,
|
|
5542
5628
|
S: this,
|
|
5543
5629
|
C: (f, a) => f(...a)
|
|
@@ -5628,8 +5714,8 @@ var SpacesServiceImpl = class {
|
|
|
5628
5714
|
}
|
|
5629
5715
|
});
|
|
5630
5716
|
} else {
|
|
5631
|
-
(0,
|
|
5632
|
-
F:
|
|
5717
|
+
(0, import_invariant17.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
5718
|
+
F: __dxlog_file20,
|
|
5633
5719
|
L: 213,
|
|
5634
5720
|
S: this,
|
|
5635
5721
|
A: [
|
|
@@ -5637,8 +5723,8 @@ var SpacesServiceImpl = class {
|
|
|
5637
5723
|
"'Id on unsigned credentials is not allowed'"
|
|
5638
5724
|
]
|
|
5639
5725
|
});
|
|
5640
|
-
(0,
|
|
5641
|
-
F:
|
|
5726
|
+
(0, import_invariant17.invariant)(this._identityManager.identity, "Identity is not available", {
|
|
5727
|
+
F: __dxlog_file20,
|
|
5642
5728
|
L: 214,
|
|
5643
5729
|
S: this,
|
|
5644
5730
|
A: [
|
|
@@ -5647,8 +5733,8 @@ var SpacesServiceImpl = class {
|
|
|
5647
5733
|
]
|
|
5648
5734
|
});
|
|
5649
5735
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
5650
|
-
(0,
|
|
5651
|
-
F:
|
|
5736
|
+
(0, import_invariant17.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
5737
|
+
F: __dxlog_file20,
|
|
5652
5738
|
L: 216,
|
|
5653
5739
|
S: this,
|
|
5654
5740
|
A: [
|
|
@@ -5697,8 +5783,8 @@ var SpacesServiceImpl = class {
|
|
|
5697
5783
|
}
|
|
5698
5784
|
async _joinByAdmission({ credential }) {
|
|
5699
5785
|
const assertion = (0, import_credentials19.getCredentialAssertion)(credential);
|
|
5700
|
-
(0,
|
|
5701
|
-
F:
|
|
5786
|
+
(0, import_invariant17.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
5787
|
+
F: __dxlog_file20,
|
|
5702
5788
|
L: 250,
|
|
5703
5789
|
S: this,
|
|
5704
5790
|
A: [
|
|
@@ -5707,8 +5793,8 @@ var SpacesServiceImpl = class {
|
|
|
5707
5793
|
]
|
|
5708
5794
|
});
|
|
5709
5795
|
const myIdentity = this._identityManager.identity;
|
|
5710
|
-
(0,
|
|
5711
|
-
F:
|
|
5796
|
+
(0, import_invariant17.invariant)(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
|
|
5797
|
+
F: __dxlog_file20,
|
|
5712
5798
|
L: 252,
|
|
5713
5799
|
S: this,
|
|
5714
5800
|
A: [
|
|
@@ -5765,7 +5851,7 @@ var SpacesServiceImpl = class {
|
|
|
5765
5851
|
profile: member.profile ?? {}
|
|
5766
5852
|
},
|
|
5767
5853
|
role: member.role,
|
|
5768
|
-
presence: peers.length > 0 ?
|
|
5854
|
+
presence: peers.length > 0 ? import_services16.SpaceMember.PresenceState.ONLINE : import_services16.SpaceMember.PresenceState.OFFLINE,
|
|
5769
5855
|
peerStates: peers
|
|
5770
5856
|
};
|
|
5771
5857
|
}),
|
|
@@ -5784,7 +5870,7 @@ var SpacesServiceImpl = class {
|
|
|
5784
5870
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5785
5871
|
const identity = this._identityManager.identity?.identityKey.truncate();
|
|
5786
5872
|
if (identity) {
|
|
5787
|
-
|
|
5873
|
+
import_tracing9.trace.metrics.gauge("dxos.echo.space.count", dataSpaceManager.spaces.size, {
|
|
5788
5874
|
tags: {
|
|
5789
5875
|
identity
|
|
5790
5876
|
}
|
|
@@ -5793,7 +5879,7 @@ var SpacesServiceImpl = class {
|
|
|
5793
5879
|
}
|
|
5794
5880
|
};
|
|
5795
5881
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
5796
|
-
function
|
|
5882
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
5797
5883
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5798
5884
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
5799
5885
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -5803,7 +5889,7 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
5803
5889
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5804
5890
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5805
5891
|
}
|
|
5806
|
-
var
|
|
5892
|
+
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
5807
5893
|
var ServiceContext = class extends import_context14.Resource {
|
|
5808
5894
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
5809
5895
|
super();
|
|
@@ -5842,20 +5928,20 @@ var ServiceContext = class extends import_context14.Resource {
|
|
|
5842
5928
|
});
|
|
5843
5929
|
this.invitations = new InvitationsHandler(this.networkManager, _runtimeParams?.invitationConnectionDefaultParams);
|
|
5844
5930
|
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
5845
|
-
this._handlerFactories.set(
|
|
5931
|
+
this._handlerFactories.set(import_services17.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
5846
5932
|
}
|
|
5847
5933
|
async _open(ctx) {
|
|
5848
5934
|
await this._checkStorageVersion();
|
|
5849
|
-
(0,
|
|
5850
|
-
F:
|
|
5935
|
+
(0, import_log18.log)("opening...", void 0, {
|
|
5936
|
+
F: __dxlog_file21,
|
|
5851
5937
|
L: 149,
|
|
5852
5938
|
S: this,
|
|
5853
5939
|
C: (f, a) => f(...a)
|
|
5854
5940
|
});
|
|
5855
|
-
|
|
5941
|
+
import_log18.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.begin({
|
|
5856
5942
|
id: this._instanceId
|
|
5857
5943
|
}), {
|
|
5858
|
-
F:
|
|
5944
|
+
F: __dxlog_file21,
|
|
5859
5945
|
L: 150,
|
|
5860
5946
|
S: this,
|
|
5861
5947
|
C: (f, a) => f(...a)
|
|
@@ -5870,32 +5956,32 @@ var ServiceContext = class extends import_context14.Resource {
|
|
|
5870
5956
|
await this._initialize(ctx);
|
|
5871
5957
|
}
|
|
5872
5958
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
5873
|
-
(0,
|
|
5959
|
+
(0, import_log18.log)("loaded persistent invitations", {
|
|
5874
5960
|
count: loadedInvitations.invitations?.length
|
|
5875
5961
|
}, {
|
|
5876
|
-
F:
|
|
5962
|
+
F: __dxlog_file21,
|
|
5877
5963
|
L: 163,
|
|
5878
5964
|
S: this,
|
|
5879
5965
|
C: (f, a) => f(...a)
|
|
5880
5966
|
});
|
|
5881
|
-
|
|
5967
|
+
import_log18.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.end({
|
|
5882
5968
|
id: this._instanceId
|
|
5883
5969
|
}), {
|
|
5884
|
-
F:
|
|
5970
|
+
F: __dxlog_file21,
|
|
5885
5971
|
L: 165,
|
|
5886
5972
|
S: this,
|
|
5887
5973
|
C: (f, a) => f(...a)
|
|
5888
5974
|
});
|
|
5889
|
-
(0,
|
|
5890
|
-
F:
|
|
5975
|
+
(0, import_log18.log)("opened", void 0, {
|
|
5976
|
+
F: __dxlog_file21,
|
|
5891
5977
|
L: 166,
|
|
5892
5978
|
S: this,
|
|
5893
5979
|
C: (f, a) => f(...a)
|
|
5894
5980
|
});
|
|
5895
5981
|
}
|
|
5896
5982
|
async _close(ctx) {
|
|
5897
|
-
(0,
|
|
5898
|
-
F:
|
|
5983
|
+
(0, import_log18.log)("closing...", void 0, {
|
|
5984
|
+
F: __dxlog_file21,
|
|
5899
5985
|
L: 170,
|
|
5900
5986
|
S: this,
|
|
5901
5987
|
C: (f, a) => f(...a)
|
|
@@ -5911,8 +5997,8 @@ var ServiceContext = class extends import_context14.Resource {
|
|
|
5911
5997
|
await this.echoHost.close(ctx);
|
|
5912
5998
|
await this.networkManager.close();
|
|
5913
5999
|
await this.signalManager.close();
|
|
5914
|
-
(0,
|
|
5915
|
-
F:
|
|
6000
|
+
(0, import_log18.log)("closed", void 0, {
|
|
6001
|
+
F: __dxlog_file21,
|
|
5916
6002
|
L: 182,
|
|
5917
6003
|
S: this,
|
|
5918
6004
|
C: (f, a) => f(...a)
|
|
@@ -5921,15 +6007,15 @@ var ServiceContext = class extends import_context14.Resource {
|
|
|
5921
6007
|
async createIdentity(params = {}) {
|
|
5922
6008
|
const identity = await this.identityManager.createIdentity(params);
|
|
5923
6009
|
await this._initialize(new import_context14.Context(void 0, {
|
|
5924
|
-
F:
|
|
6010
|
+
F: __dxlog_file21,
|
|
5925
6011
|
L: 187
|
|
5926
6012
|
}));
|
|
5927
6013
|
return identity;
|
|
5928
6014
|
}
|
|
5929
6015
|
getInvitationHandler(invitation) {
|
|
5930
6016
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
5931
|
-
(0,
|
|
5932
|
-
F:
|
|
6017
|
+
(0, import_invariant18.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
6018
|
+
F: __dxlog_file21,
|
|
5933
6019
|
L: 193,
|
|
5934
6020
|
S: this,
|
|
5935
6021
|
A: [
|
|
@@ -5950,7 +6036,7 @@ var ServiceContext = class extends import_context14.Resource {
|
|
|
5950
6036
|
async _acceptIdentity(params) {
|
|
5951
6037
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
5952
6038
|
await this._initialize(new import_context14.Context(void 0, {
|
|
5953
|
-
F:
|
|
6039
|
+
F: __dxlog_file21,
|
|
5954
6040
|
L: 209
|
|
5955
6041
|
}));
|
|
5956
6042
|
return identity;
|
|
@@ -5963,8 +6049,8 @@ var ServiceContext = class extends import_context14.Resource {
|
|
|
5963
6049
|
}
|
|
5964
6050
|
// Called when identity is created.
|
|
5965
6051
|
async _initialize(ctx) {
|
|
5966
|
-
(0,
|
|
5967
|
-
F:
|
|
6052
|
+
(0, import_log18.log)("initializing spaces...", void 0, {
|
|
6053
|
+
F: __dxlog_file21,
|
|
5968
6054
|
L: 224,
|
|
5969
6055
|
S: this,
|
|
5970
6056
|
C: (f, a) => f(...a)
|
|
@@ -5985,9 +6071,9 @@ var ServiceContext = class extends import_context14.Resource {
|
|
|
5985
6071
|
};
|
|
5986
6072
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.echoHost, this.invitationsManager, this._runtimeParams);
|
|
5987
6073
|
await this.dataSpaceManager.open();
|
|
5988
|
-
this._handlerFactories.set(
|
|
5989
|
-
(0,
|
|
5990
|
-
F:
|
|
6074
|
+
this._handlerFactories.set(import_services17.Invitation.Kind.SPACE, (invitation) => {
|
|
6075
|
+
(0, import_invariant18.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
6076
|
+
F: __dxlog_file21,
|
|
5991
6077
|
L: 249,
|
|
5992
6078
|
S: this,
|
|
5993
6079
|
A: [
|
|
@@ -6008,10 +6094,10 @@ var ServiceContext = class extends import_context14.Resource {
|
|
|
6008
6094
|
return;
|
|
6009
6095
|
}
|
|
6010
6096
|
if (!this.dataSpaceManager) {
|
|
6011
|
-
(0,
|
|
6097
|
+
(0, import_log18.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
6012
6098
|
details: assertion
|
|
6013
6099
|
}, {
|
|
6014
|
-
F:
|
|
6100
|
+
F: __dxlog_file21,
|
|
6015
6101
|
L: 265,
|
|
6016
6102
|
S: this,
|
|
6017
6103
|
C: (f, a) => f(...a)
|
|
@@ -6019,10 +6105,10 @@ var ServiceContext = class extends import_context14.Resource {
|
|
|
6019
6105
|
return;
|
|
6020
6106
|
}
|
|
6021
6107
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
6022
|
-
(0,
|
|
6108
|
+
(0, import_log18.log)("space already exists, ignoring space admission", {
|
|
6023
6109
|
details: assertion
|
|
6024
6110
|
}, {
|
|
6025
|
-
F:
|
|
6111
|
+
F: __dxlog_file21,
|
|
6026
6112
|
L: 269,
|
|
6027
6113
|
S: this,
|
|
6028
6114
|
C: (f, a) => f(...a)
|
|
@@ -6030,10 +6116,10 @@ var ServiceContext = class extends import_context14.Resource {
|
|
|
6030
6116
|
return;
|
|
6031
6117
|
}
|
|
6032
6118
|
try {
|
|
6033
|
-
(0,
|
|
6119
|
+
(0, import_log18.log)("accepting space recorded in halo", {
|
|
6034
6120
|
details: assertion
|
|
6035
6121
|
}, {
|
|
6036
|
-
F:
|
|
6122
|
+
F: __dxlog_file21,
|
|
6037
6123
|
L: 274,
|
|
6038
6124
|
S: this,
|
|
6039
6125
|
C: (f, a) => f(...a)
|
|
@@ -6043,8 +6129,8 @@ var ServiceContext = class extends import_context14.Resource {
|
|
|
6043
6129
|
genesisFeedKey: assertion.genesisFeedKey
|
|
6044
6130
|
});
|
|
6045
6131
|
} catch (err) {
|
|
6046
|
-
|
|
6047
|
-
F:
|
|
6132
|
+
import_log18.log.catch(err, void 0, {
|
|
6133
|
+
F: __dxlog_file21,
|
|
6048
6134
|
L: 280,
|
|
6049
6135
|
S: this,
|
|
6050
6136
|
C: (f, a) => f(...a)
|
|
@@ -6055,15 +6141,15 @@ var ServiceContext = class extends import_context14.Resource {
|
|
|
6055
6141
|
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
6056
6142
|
}
|
|
6057
6143
|
};
|
|
6058
|
-
|
|
6059
|
-
|
|
6144
|
+
_ts_decorate7([
|
|
6145
|
+
import_tracing10.trace.span()
|
|
6060
6146
|
], ServiceContext.prototype, "_open", null);
|
|
6061
|
-
|
|
6062
|
-
|
|
6147
|
+
_ts_decorate7([
|
|
6148
|
+
import_tracing10.trace.span()
|
|
6063
6149
|
], ServiceContext.prototype, "_initialize", null);
|
|
6064
|
-
ServiceContext =
|
|
6065
|
-
(0,
|
|
6066
|
-
|
|
6150
|
+
ServiceContext = _ts_decorate7([
|
|
6151
|
+
(0, import_util11.safeInstanceof)("dxos.client-services.ServiceContext"),
|
|
6152
|
+
import_tracing10.trace.resource()
|
|
6067
6153
|
], ServiceContext);
|
|
6068
6154
|
var ServiceRegistry = class {
|
|
6069
6155
|
// prettier-ignore
|
|
@@ -6087,69 +6173,15 @@ var ServiceRegistry = class {
|
|
|
6087
6173
|
delete this._handlers[name];
|
|
6088
6174
|
}
|
|
6089
6175
|
};
|
|
6090
|
-
function _ts_decorate7(decorators, target, key, desc) {
|
|
6091
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6092
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
6093
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
6094
|
-
else
|
|
6095
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
6096
|
-
if (d = decorators[i])
|
|
6097
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6098
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6099
|
-
}
|
|
6100
|
-
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
6101
|
-
var Lock = class {
|
|
6102
|
-
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
6103
|
-
this._lockPath = lockPath;
|
|
6104
|
-
this._onAcquire = onAcquire;
|
|
6105
|
-
this._onRelease = onRelease;
|
|
6106
|
-
}
|
|
6107
|
-
get lockKey() {
|
|
6108
|
-
return this._lockPath;
|
|
6109
|
-
}
|
|
6110
|
-
async acquire() {
|
|
6111
|
-
(0, import_log18.log)("acquiring lock...", void 0, {
|
|
6112
|
-
F: __dxlog_file21,
|
|
6113
|
-
L: 32,
|
|
6114
|
-
S: this,
|
|
6115
|
-
C: (f, a) => f(...a)
|
|
6116
|
-
});
|
|
6117
|
-
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
6118
|
-
await this._onAcquire?.();
|
|
6119
|
-
(0, import_log18.log)("acquired lock", void 0, {
|
|
6120
|
-
F: __dxlog_file21,
|
|
6121
|
-
L: 37,
|
|
6122
|
-
S: this,
|
|
6123
|
-
C: (f, a) => f(...a)
|
|
6124
|
-
});
|
|
6125
|
-
}
|
|
6126
|
-
async release() {
|
|
6127
|
-
await this._onRelease?.();
|
|
6128
|
-
(0, import_invariant18.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
6129
|
-
F: __dxlog_file21,
|
|
6130
|
-
L: 42,
|
|
6131
|
-
S: this,
|
|
6132
|
-
A: [
|
|
6133
|
-
"this._fileHandle",
|
|
6134
|
-
"'Lock is not acquired'"
|
|
6135
|
-
]
|
|
6136
|
-
});
|
|
6137
|
-
await import_lock_file.LockFile.release(this._fileHandle);
|
|
6138
|
-
}
|
|
6139
|
-
};
|
|
6140
|
-
_ts_decorate7([
|
|
6141
|
-
import_log18.logInfo
|
|
6142
|
-
], Lock.prototype, "lockKey", null);
|
|
6143
|
-
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
6144
6176
|
var getRootPath = (config) => {
|
|
6145
|
-
const { dataRoot = (0,
|
|
6177
|
+
const { dataRoot = (0, import_util12.isNode)() ? import_client_protocol7.DX_DATA : "dxos/storage" } = config ?? {};
|
|
6146
6178
|
return `${dataRoot}/`;
|
|
6147
6179
|
};
|
|
6148
6180
|
var isPersistent = (config) => {
|
|
6149
6181
|
const { persistent = false } = config ?? {};
|
|
6150
|
-
return config.dataStore !== void 0 && config.dataStore !==
|
|
6182
|
+
return config.dataStore !== void 0 && config.dataStore !== import_config3.Runtime.Client.Storage.StorageDriver.RAM || persistent;
|
|
6151
6183
|
};
|
|
6152
|
-
var StorageDriver =
|
|
6184
|
+
var StorageDriver = import_config2.Runtime.Client.Storage.StorageDriver;
|
|
6153
6185
|
var createStorageObjects = (config) => {
|
|
6154
6186
|
const { persistent = false, keyStore, dataStore } = config ?? {};
|
|
6155
6187
|
if (persistent && dataStore === StorageDriver.RAM) {
|
|
@@ -6295,7 +6327,7 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
6295
6327
|
"'Invalid value type'"
|
|
6296
6328
|
]
|
|
6297
6329
|
});
|
|
6298
|
-
await file.write(0, (0,
|
|
6330
|
+
await file.write(0, (0, import_util13.arrayToBuffer)(entry2.value));
|
|
6299
6331
|
await file.close();
|
|
6300
6332
|
break;
|
|
6301
6333
|
}
|
|
@@ -6383,9 +6415,9 @@ var DevicesServiceImpl = class {
|
|
|
6383
6415
|
const peerState = peers.find((peer) => peer.identityKey.equals(key));
|
|
6384
6416
|
return {
|
|
6385
6417
|
deviceKey: key,
|
|
6386
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ?
|
|
6418
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services19.DeviceKind.CURRENT : import_services19.DeviceKind.TRUSTED,
|
|
6387
6419
|
profile,
|
|
6388
|
-
presence: isMe ?
|
|
6420
|
+
presence: isMe ? import_services19.Device.PresenceState.ONLINE : peerState ? import_services19.Device.PresenceState.ONLINE : import_services19.Device.PresenceState.OFFLINE
|
|
6389
6421
|
};
|
|
6390
6422
|
})
|
|
6391
6423
|
});
|
|
@@ -6426,41 +6458,6 @@ var DevicesServiceImpl = class {
|
|
|
6426
6458
|
});
|
|
6427
6459
|
}
|
|
6428
6460
|
};
|
|
6429
|
-
var ClientServicesProviderResource = Symbol.for("dxos.resource.ClientServices");
|
|
6430
|
-
var GET_DIAGNOSTICS_RPC_TIMEOUT = 1e4;
|
|
6431
|
-
var DiagnosticsCollector = class {
|
|
6432
|
-
static {
|
|
6433
|
-
this.broadcastSender = createCollectDiagnosticsBroadcastSender();
|
|
6434
|
-
}
|
|
6435
|
-
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
6436
|
-
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
6437
|
-
keys: options.humanize ? import_services19.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services19.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
6438
|
-
}, {
|
|
6439
|
-
timeout: GET_DIAGNOSTICS_RPC_TIMEOUT
|
|
6440
|
-
});
|
|
6441
|
-
const clientDiagnostics = {
|
|
6442
|
-
config,
|
|
6443
|
-
trace: import_tracing11.TRACE_PROCESSOR.getDiagnostics()
|
|
6444
|
-
};
|
|
6445
|
-
const diagnostics = serviceDiagnostics != null ? {
|
|
6446
|
-
client: clientDiagnostics,
|
|
6447
|
-
services: serviceDiagnostics
|
|
6448
|
-
} : {
|
|
6449
|
-
client: clientDiagnostics,
|
|
6450
|
-
broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
|
|
6451
|
-
};
|
|
6452
|
-
return JSON.parse(JSON.stringify(diagnostics, (0, import_util13.jsonKeyReplacer)(options)));
|
|
6453
|
-
}
|
|
6454
|
-
};
|
|
6455
|
-
var findSystemServiceProvider = () => {
|
|
6456
|
-
const serviceProviders = import_tracing11.TRACE_PROCESSOR.findResourcesByAnnotation(ClientServicesProviderResource);
|
|
6457
|
-
const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
|
|
6458
|
-
return providerResource?.instance?.deref() ?? null;
|
|
6459
|
-
};
|
|
6460
|
-
var findConfigs = () => {
|
|
6461
|
-
const configs = import_tracing11.TRACE_PROCESSOR.findResourcesByAnnotation(import_config3.ConfigResource);
|
|
6462
|
-
return configs.map((r) => r.instance.deref()).filter(import_util13.nonNullable);
|
|
6463
|
-
};
|
|
6464
6461
|
var ContactsServiceImpl = class {
|
|
6465
6462
|
constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
|
|
6466
6463
|
this._identityManager = _identityManager;
|
|
@@ -6500,7 +6497,7 @@ var ContactsServiceImpl = class {
|
|
|
6500
6497
|
});
|
|
6501
6498
|
}
|
|
6502
6499
|
return acc;
|
|
6503
|
-
}, new
|
|
6500
|
+
}, new import_util14.ComplexMap(import_keys16.PublicKey.hash));
|
|
6504
6501
|
return {
|
|
6505
6502
|
contacts: [
|
|
6506
6503
|
...contacts.values()
|
|
@@ -6508,7 +6505,7 @@ var ContactsServiceImpl = class {
|
|
|
6508
6505
|
};
|
|
6509
6506
|
}
|
|
6510
6507
|
queryContacts() {
|
|
6511
|
-
const subscribedSpaceKeySet = new
|
|
6508
|
+
const subscribedSpaceKeySet = new import_util14.ComplexSet(import_keys16.PublicKey.hash);
|
|
6512
6509
|
return new import_codec_protobuf13.Stream(({ next, ctx }) => {
|
|
6513
6510
|
const pushUpdateTask = new import_async21.UpdateScheduler(ctx, async () => {
|
|
6514
6511
|
const contacts = await this.getContacts();
|
|
@@ -6542,7 +6539,7 @@ var LoggingServiceImpl = class {
|
|
|
6542
6539
|
constructor() {
|
|
6543
6540
|
this._logs = new import_async22.Event();
|
|
6544
6541
|
this._started = Date.now();
|
|
6545
|
-
this._sessionId =
|
|
6542
|
+
this._sessionId = import_keys17.PublicKey.random().toHex();
|
|
6546
6543
|
this._logProcessor = (_config, entry2) => {
|
|
6547
6544
|
this._logs.emit(entry2);
|
|
6548
6545
|
};
|
|
@@ -6556,15 +6553,15 @@ var LoggingServiceImpl = class {
|
|
|
6556
6553
|
}
|
|
6557
6554
|
async controlMetrics({ reset, record }) {
|
|
6558
6555
|
if (reset) {
|
|
6559
|
-
|
|
6556
|
+
import_util15.tracer.clear();
|
|
6560
6557
|
}
|
|
6561
6558
|
if (record === true) {
|
|
6562
|
-
|
|
6559
|
+
import_util15.tracer.start();
|
|
6563
6560
|
} else if (record === false) {
|
|
6564
|
-
|
|
6561
|
+
import_util15.tracer.stop();
|
|
6565
6562
|
}
|
|
6566
6563
|
return {
|
|
6567
|
-
recording:
|
|
6564
|
+
recording: import_util15.tracer.recording
|
|
6568
6565
|
};
|
|
6569
6566
|
}
|
|
6570
6567
|
/**
|
|
@@ -6572,10 +6569,10 @@ var LoggingServiceImpl = class {
|
|
|
6572
6569
|
*/
|
|
6573
6570
|
queryMetrics({ interval = 5e3 }) {
|
|
6574
6571
|
const getNumericalValues = (key) => {
|
|
6575
|
-
const events =
|
|
6572
|
+
const events = import_util15.tracer.get(key) ?? [];
|
|
6576
6573
|
return {
|
|
6577
6574
|
key,
|
|
6578
|
-
stats: (0,
|
|
6575
|
+
stats: (0, import_util15.numericalValues)(events, "duration")
|
|
6579
6576
|
};
|
|
6580
6577
|
};
|
|
6581
6578
|
return new import_codec_protobuf14.Stream(({ next }) => {
|
|
@@ -6613,7 +6610,7 @@ var LoggingServiceImpl = class {
|
|
|
6613
6610
|
}
|
|
6614
6611
|
const record = {
|
|
6615
6612
|
...entry2,
|
|
6616
|
-
context: (0,
|
|
6613
|
+
context: (0, import_util15.jsonify)((0, import_log21.getContextFromEntry)(entry2)),
|
|
6617
6614
|
timestamp: /* @__PURE__ */ new Date(),
|
|
6618
6615
|
meta: {
|
|
6619
6616
|
// TODO(dmaretskyi): Fix proto.
|
|
@@ -6622,7 +6619,7 @@ var LoggingServiceImpl = class {
|
|
|
6622
6619
|
scope: {
|
|
6623
6620
|
hostSessionId: this._sessionId,
|
|
6624
6621
|
uptimeSeconds: (Date.now() - this._started) / 1e3,
|
|
6625
|
-
name: (0,
|
|
6622
|
+
name: (0, import_util15.getDebugName)(entry2.meta?.S)
|
|
6626
6623
|
}
|
|
6627
6624
|
}
|
|
6628
6625
|
};
|
|
@@ -6703,7 +6700,7 @@ var SystemServiceImpl = class {
|
|
|
6703
6700
|
const diagnostics = await this._getDiagnostics();
|
|
6704
6701
|
return {
|
|
6705
6702
|
timestamp: /* @__PURE__ */ new Date(),
|
|
6706
|
-
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0,
|
|
6703
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util16.jsonKeyReplacer)({
|
|
6707
6704
|
truncate: keys === import_services21.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
6708
6705
|
humanize: keys === import_services21.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
6709
6706
|
})))
|
|
@@ -6759,7 +6756,7 @@ var ClientServicesHost = class {
|
|
|
6759
6756
|
callbacks,
|
|
6760
6757
|
runtimeParams
|
|
6761
6758
|
} = {}) {
|
|
6762
|
-
this._tracingService =
|
|
6759
|
+
this._tracingService = import_tracing11.TRACE_PROCESSOR.createTraceSender();
|
|
6763
6760
|
this._statusUpdate = new import_async19.Event();
|
|
6764
6761
|
this._opening = false;
|
|
6765
6762
|
this._open = false;
|
|
@@ -6791,14 +6788,14 @@ var ClientServicesHost = class {
|
|
|
6791
6788
|
this._systemService = new SystemServiceImpl({
|
|
6792
6789
|
config: () => this._config,
|
|
6793
6790
|
statusUpdate: this._statusUpdate,
|
|
6794
|
-
getCurrentStatus: () => this.isOpen ?
|
|
6791
|
+
getCurrentStatus: () => this.isOpen ? import_services18.SystemStatus.ACTIVE : import_services18.SystemStatus.INACTIVE,
|
|
6795
6792
|
getDiagnostics: () => {
|
|
6796
6793
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
6797
6794
|
},
|
|
6798
6795
|
onUpdateStatus: async (status) => {
|
|
6799
|
-
if (!this.isOpen && status ===
|
|
6796
|
+
if (!this.isOpen && status === import_services18.SystemStatus.ACTIVE) {
|
|
6800
6797
|
await this._resourceLock?.acquire();
|
|
6801
|
-
} else if (this.isOpen && status ===
|
|
6798
|
+
} else if (this.isOpen && status === import_services18.SystemStatus.INACTIVE) {
|
|
6802
6799
|
await this._resourceLock?.release();
|
|
6803
6800
|
}
|
|
6804
6801
|
},
|
|
@@ -6808,7 +6805,7 @@ var ClientServicesHost = class {
|
|
|
6808
6805
|
});
|
|
6809
6806
|
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
6810
6807
|
this._loggingService = new LoggingServiceImpl();
|
|
6811
|
-
this._serviceRegistry = new ServiceRegistry(
|
|
6808
|
+
this._serviceRegistry = new ServiceRegistry(import_client_protocol8.clientServiceBundle, {
|
|
6812
6809
|
SystemService: this._systemService,
|
|
6813
6810
|
TracingService: this._tracingService
|
|
6814
6811
|
});
|
|
@@ -6996,7 +6993,7 @@ var ClientServicesHost = class {
|
|
|
6996
6993
|
this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
|
|
6997
6994
|
url: devtoolsProxy,
|
|
6998
6995
|
requested: {},
|
|
6999
|
-
exposed:
|
|
6996
|
+
exposed: import_client_protocol8.clientServiceBundle,
|
|
7000
6997
|
handlers: this.services
|
|
7001
6998
|
});
|
|
7002
6999
|
void this._devtoolsProxy.open();
|
|
@@ -7096,27 +7093,26 @@ var ClientServicesHost = class {
|
|
|
7096
7093
|
}
|
|
7097
7094
|
};
|
|
7098
7095
|
_ts_decorate8([
|
|
7099
|
-
|
|
7096
|
+
import_tracing11.trace.info()
|
|
7100
7097
|
], ClientServicesHost.prototype, "_opening", void 0);
|
|
7101
7098
|
_ts_decorate8([
|
|
7102
|
-
|
|
7099
|
+
import_tracing11.trace.info()
|
|
7103
7100
|
], ClientServicesHost.prototype, "_open", void 0);
|
|
7104
7101
|
_ts_decorate8([
|
|
7105
7102
|
import_async19.synchronized,
|
|
7106
|
-
|
|
7103
|
+
import_tracing11.trace.span()
|
|
7107
7104
|
], ClientServicesHost.prototype, "open", null);
|
|
7108
7105
|
_ts_decorate8([
|
|
7109
7106
|
import_async19.synchronized,
|
|
7110
|
-
|
|
7107
|
+
import_tracing11.trace.span()
|
|
7111
7108
|
], ClientServicesHost.prototype, "close", null);
|
|
7112
7109
|
ClientServicesHost = _ts_decorate8([
|
|
7113
|
-
|
|
7110
|
+
import_tracing11.trace.resource()
|
|
7114
7111
|
], ClientServicesHost);
|
|
7115
7112
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7116
7113
|
0 && (module.exports = {
|
|
7117
7114
|
ClientRpcServer,
|
|
7118
7115
|
ClientServicesHost,
|
|
7119
|
-
ClientServicesProviderResource,
|
|
7120
7116
|
DataSpace,
|
|
7121
7117
|
DataSpaceManager,
|
|
7122
7118
|
DeviceInvitationProtocol,
|
|
@@ -7156,4 +7152,4 @@ ClientServicesHost = _ts_decorate8([
|
|
|
7156
7152
|
subscribeToSpaces,
|
|
7157
7153
|
subscribeToSwarmInfo
|
|
7158
7154
|
});
|
|
7159
|
-
//# sourceMappingURL=chunk-
|
|
7155
|
+
//# sourceMappingURL=chunk-4WZHXQZI.cjs.map
|