@dxos/client-services 0.5.9-main.bd82576 → 0.5.9-main.bf0ae3e
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-HBFVHMVG.mjs → chunk-4IR3JP4U.mjs} +746 -605
- package/dist/lib/browser/chunk-4IR3JP4U.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +11 -11
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-HPSDBJ7Z.cjs → chunk-ZBIDLLZ4.cjs} +962 -825
- package/dist/lib/node/chunk-ZBIDLLZ4.cjs.map +7 -0
- package/dist/lib/node/index.cjs +42 -42
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +17 -17
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts +19 -0
- package/dist/types/src/packlets/identity/default-space-state-machine.d.ts.map +1 -0
- package/dist/types/src/packlets/identity/identity-service.d.ts +14 -7
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +4 -1
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +5 -3
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +8 -6
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +36 -36
- package/src/packlets/identity/default-space-state-machine.ts +44 -0
- package/src/packlets/identity/identity-service.test.ts +35 -5
- package/src/packlets/identity/identity-service.ts +50 -8
- package/src/packlets/identity/identity.ts +25 -2
- package/src/packlets/services/service-context.ts +1 -4
- package/src/packlets/services/service-host.ts +13 -40
- package/src/packlets/spaces/data-space-manager.test.ts +46 -1
- package/src/packlets/spaces/data-space-manager.ts +54 -25
- package/src/packlets/spaces/data-space.ts +10 -5
- package/src/packlets/testing/test-builder.ts +12 -10
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-HBFVHMVG.mjs.map +0 -7
- package/dist/lib/node/chunk-HPSDBJ7Z.cjs.map +0 -7
|
@@ -26,8 +26,8 @@ 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_ZBIDLLZ4_exports = {};
|
|
30
|
+
__export(chunk_ZBIDLLZ4_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
33
|
ClientServicesProviderResource: () => ClientServicesProviderResource,
|
|
@@ -67,7 +67,7 @@ __export(chunk_HPSDBJ7Z_exports, {
|
|
|
67
67
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
68
68
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
69
69
|
});
|
|
70
|
-
module.exports = __toCommonJS(
|
|
70
|
+
module.exports = __toCommonJS(chunk_ZBIDLLZ4_exports);
|
|
71
71
|
var import_async = require("@dxos/async");
|
|
72
72
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
73
73
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -107,200 +107,206 @@ var import_invariant2 = require("@dxos/invariant");
|
|
|
107
107
|
var import_keys3 = require("@dxos/keys");
|
|
108
108
|
var import_log2 = require("@dxos/log");
|
|
109
109
|
var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
110
|
+
var import_timeframe = require("@dxos/timeframe");
|
|
110
111
|
var import_tracing3 = require("@dxos/tracing");
|
|
111
112
|
var import_util2 = require("@dxos/util");
|
|
113
|
+
var import_credentials5 = require("@dxos/credentials");
|
|
114
|
+
var import_keys4 = require("@dxos/keys");
|
|
115
|
+
var import_log3 = require("@dxos/log");
|
|
112
116
|
var import_platform = __toESM(require("platform"));
|
|
113
117
|
var import_async7 = require("@dxos/async");
|
|
114
118
|
var import_context3 = require("@dxos/context");
|
|
115
|
-
var
|
|
119
|
+
var import_credentials6 = require("@dxos/credentials");
|
|
116
120
|
var import_invariant3 = require("@dxos/invariant");
|
|
117
|
-
var
|
|
118
|
-
var
|
|
121
|
+
var import_keys5 = require("@dxos/keys");
|
|
122
|
+
var import_log4 = require("@dxos/log");
|
|
119
123
|
var import_protocols3 = require("@dxos/protocols");
|
|
120
124
|
var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
121
|
-
var
|
|
125
|
+
var import_credentials7 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
122
126
|
var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
|
|
123
|
-
var
|
|
127
|
+
var import_timeframe2 = require("@dxos/timeframe");
|
|
124
128
|
var import_tracing4 = require("@dxos/tracing");
|
|
125
129
|
var import_util3 = require("@dxos/util");
|
|
126
130
|
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
127
|
-
var
|
|
131
|
+
var import_context4 = require("@dxos/context");
|
|
132
|
+
var import_credentials8 = require("@dxos/credentials");
|
|
128
133
|
var import_debug2 = require("@dxos/debug");
|
|
129
134
|
var import_invariant4 = require("@dxos/invariant");
|
|
135
|
+
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
130
136
|
var import_invariant5 = require("@dxos/invariant");
|
|
131
137
|
var import_protocols4 = require("@dxos/protocols");
|
|
132
|
-
var
|
|
138
|
+
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
133
139
|
var import_async8 = require("@dxos/async");
|
|
134
140
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
135
|
-
var
|
|
141
|
+
var import_context5 = require("@dxos/context");
|
|
136
142
|
var import_crypto = require("@dxos/crypto");
|
|
137
143
|
var import_invariant6 = require("@dxos/invariant");
|
|
138
|
-
var
|
|
139
|
-
var
|
|
144
|
+
var import_keys6 = require("@dxos/keys");
|
|
145
|
+
var import_log5 = require("@dxos/log");
|
|
140
146
|
var import_network_manager = require("@dxos/network-manager");
|
|
141
147
|
var import_protocols5 = require("@dxos/protocols");
|
|
142
|
-
var
|
|
148
|
+
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
143
149
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
144
150
|
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
145
151
|
var import_util4 = require("@dxos/util");
|
|
146
152
|
var import_async9 = require("@dxos/async");
|
|
147
|
-
var
|
|
153
|
+
var import_context6 = require("@dxos/context");
|
|
148
154
|
var import_invariant7 = require("@dxos/invariant");
|
|
149
|
-
var
|
|
155
|
+
var import_log6 = require("@dxos/log");
|
|
150
156
|
var import_protocols6 = require("@dxos/protocols");
|
|
151
157
|
var import_invitations3 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
152
158
|
var import_teleport = require("@dxos/teleport");
|
|
153
|
-
var import_context6 = require("@dxos/context");
|
|
154
|
-
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
155
|
-
var import_async10 = require("@dxos/async");
|
|
156
159
|
var import_context7 = require("@dxos/context");
|
|
160
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
161
|
+
var import_async10 = require("@dxos/async");
|
|
162
|
+
var import_context8 = require("@dxos/context");
|
|
157
163
|
var import_crypto2 = require("@dxos/crypto");
|
|
158
164
|
var import_invariant8 = require("@dxos/invariant");
|
|
159
|
-
var
|
|
160
|
-
var
|
|
165
|
+
var import_keys7 = require("@dxos/keys");
|
|
166
|
+
var import_log7 = require("@dxos/log");
|
|
161
167
|
var import_protocols7 = require("@dxos/protocols");
|
|
162
|
-
var
|
|
168
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
163
169
|
var import_invitations4 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
164
170
|
var import_teleport2 = require("@dxos/teleport");
|
|
165
171
|
var import_invariant9 = require("@dxos/invariant");
|
|
166
|
-
var
|
|
167
|
-
var
|
|
172
|
+
var import_keys8 = require("@dxos/keys");
|
|
173
|
+
var import_log8 = require("@dxos/log");
|
|
168
174
|
var import_invitations5 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
169
175
|
var import_util5 = require("@dxos/util");
|
|
170
176
|
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
171
|
-
var
|
|
172
|
-
var
|
|
177
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
178
|
+
var import_credentials9 = require("@dxos/credentials");
|
|
173
179
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
174
180
|
var import_invariant10 = require("@dxos/invariant");
|
|
175
|
-
var
|
|
181
|
+
var import_log9 = require("@dxos/log");
|
|
176
182
|
var import_protocols8 = require("@dxos/protocols");
|
|
177
|
-
var
|
|
178
|
-
var
|
|
183
|
+
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
184
|
+
var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
179
185
|
var import_async11 = require("@dxos/async");
|
|
180
186
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
181
|
-
var
|
|
182
|
-
var
|
|
187
|
+
var import_context9 = require("@dxos/context");
|
|
188
|
+
var import_credentials11 = require("@dxos/credentials");
|
|
183
189
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
184
190
|
var import_invariant11 = require("@dxos/invariant");
|
|
185
|
-
var
|
|
186
|
-
var
|
|
187
|
-
var
|
|
188
|
-
var
|
|
191
|
+
var import_keys9 = require("@dxos/keys");
|
|
192
|
+
var import_log10 = require("@dxos/log");
|
|
193
|
+
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
194
|
+
var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
189
195
|
var import_async12 = require("@dxos/async");
|
|
190
196
|
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
191
|
-
var
|
|
197
|
+
var import_context10 = require("@dxos/context");
|
|
192
198
|
var import_debug3 = require("@dxos/debug");
|
|
193
199
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
194
200
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
195
201
|
var import_invariant12 = require("@dxos/invariant");
|
|
196
|
-
var
|
|
197
|
-
var
|
|
202
|
+
var import_keys10 = require("@dxos/keys");
|
|
203
|
+
var import_log11 = require("@dxos/log");
|
|
198
204
|
var import_protocols9 = require("@dxos/protocols");
|
|
199
|
-
var
|
|
200
|
-
var
|
|
201
|
-
var
|
|
205
|
+
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
206
|
+
var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
207
|
+
var import_timeframe3 = require("@dxos/timeframe");
|
|
202
208
|
var import_tracing5 = require("@dxos/tracing");
|
|
203
209
|
var import_util6 = require("@dxos/util");
|
|
204
210
|
var import_async13 = require("@dxos/async");
|
|
205
|
-
var
|
|
211
|
+
var import_credentials14 = require("@dxos/credentials");
|
|
206
212
|
var import_async14 = require("@dxos/async");
|
|
207
|
-
var
|
|
213
|
+
var import_context11 = require("@dxos/context");
|
|
208
214
|
var import_invariant13 = require("@dxos/invariant");
|
|
209
|
-
var
|
|
210
|
-
var
|
|
215
|
+
var import_keys11 = require("@dxos/keys");
|
|
216
|
+
var import_log12 = require("@dxos/log");
|
|
211
217
|
var import_protocols10 = require("@dxos/protocols");
|
|
212
218
|
var import_teleport3 = require("@dxos/teleport");
|
|
213
219
|
var import_util7 = require("@dxos/util");
|
|
214
220
|
var import_async15 = require("@dxos/async");
|
|
215
|
-
var
|
|
216
|
-
var
|
|
221
|
+
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
222
|
+
var import_context12 = require("@dxos/context");
|
|
223
|
+
var import_credentials15 = require("@dxos/credentials");
|
|
217
224
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
225
|
+
var import_echo_protocol = require("@dxos/echo-protocol");
|
|
226
|
+
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
218
227
|
var import_invariant14 = require("@dxos/invariant");
|
|
219
|
-
var
|
|
220
|
-
var
|
|
228
|
+
var import_keys12 = require("@dxos/keys");
|
|
229
|
+
var import_log13 = require("@dxos/log");
|
|
221
230
|
var import_protocols11 = require("@dxos/protocols");
|
|
222
|
-
var
|
|
223
|
-
var
|
|
231
|
+
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
232
|
+
var import_credentials16 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
224
233
|
var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
|
|
225
234
|
var import_tracing6 = require("@dxos/tracing");
|
|
226
235
|
var import_util8 = require("@dxos/util");
|
|
227
|
-
var
|
|
236
|
+
var import_credentials17 = require("@dxos/credentials");
|
|
228
237
|
var import_debug4 = require("@dxos/debug");
|
|
229
|
-
var
|
|
230
|
-
var
|
|
238
|
+
var import_credentials18 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
239
|
+
var import_timeframe4 = require("@dxos/timeframe");
|
|
231
240
|
var import_async16 = require("@dxos/async");
|
|
232
241
|
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
233
|
-
var
|
|
242
|
+
var import_credentials19 = require("@dxos/credentials");
|
|
234
243
|
var import_debug5 = require("@dxos/debug");
|
|
235
244
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
236
245
|
var import_invariant15 = require("@dxos/invariant");
|
|
237
|
-
var
|
|
246
|
+
var import_log14 = require("@dxos/log");
|
|
238
247
|
var import_protocols12 = require("@dxos/protocols");
|
|
239
|
-
var
|
|
248
|
+
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
240
249
|
var import_tracing7 = require("@dxos/tracing");
|
|
241
250
|
var import_async17 = require("@dxos/async");
|
|
242
|
-
var
|
|
243
|
-
var
|
|
251
|
+
var import_context13 = require("@dxos/context");
|
|
252
|
+
var import_credentials20 = require("@dxos/credentials");
|
|
244
253
|
var import_debug6 = require("@dxos/debug");
|
|
245
254
|
var import_echo_db = require("@dxos/echo-db");
|
|
246
255
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
247
256
|
var import_feed_store5 = require("@dxos/feed-store");
|
|
248
257
|
var import_invariant16 = require("@dxos/invariant");
|
|
249
258
|
var import_keyring = require("@dxos/keyring");
|
|
250
|
-
var
|
|
251
|
-
var
|
|
259
|
+
var import_keys13 = require("@dxos/keys");
|
|
260
|
+
var import_log15 = require("@dxos/log");
|
|
252
261
|
var import_protocols13 = require("@dxos/protocols");
|
|
253
|
-
var
|
|
262
|
+
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
254
263
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
255
264
|
var import_tracing8 = require("@dxos/tracing");
|
|
256
265
|
var import_util9 = require("@dxos/util");
|
|
257
266
|
var import_invariant17 = require("@dxos/invariant");
|
|
258
267
|
var import_lock_file = require("@dxos/lock-file");
|
|
259
|
-
var
|
|
268
|
+
var import_log16 = require("@dxos/log");
|
|
260
269
|
var import_protocols14 = require("@dxos/protocols");
|
|
261
270
|
var import_config = require("@dxos/protocols/proto/dxos/config");
|
|
262
271
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
263
|
-
var
|
|
272
|
+
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
264
273
|
var import_config2 = require("@dxos/protocols/proto/dxos/config");
|
|
265
274
|
var import_util10 = require("@dxos/util");
|
|
266
275
|
var import_node_path = __toESM(require("node:path"));
|
|
267
|
-
var
|
|
276
|
+
var import_keys14 = require("@dxos/keys");
|
|
268
277
|
var import_kv_store = require("@dxos/kv-store");
|
|
269
278
|
var import_async18 = require("@dxos/async");
|
|
270
|
-
var
|
|
271
|
-
var
|
|
272
|
-
var import_echo_protocol = require("@dxos/echo-protocol");
|
|
273
|
-
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
279
|
+
var import_client_protocol7 = require("@dxos/client-protocol");
|
|
280
|
+
var import_context14 = require("@dxos/context");
|
|
274
281
|
var import_invariant18 = require("@dxos/invariant");
|
|
275
|
-
var
|
|
276
|
-
var
|
|
282
|
+
var import_keys15 = require("@dxos/keys");
|
|
283
|
+
var import_log17 = require("@dxos/log");
|
|
277
284
|
var import_messaging = require("@dxos/messaging");
|
|
278
285
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
279
286
|
var import_protocols15 = require("@dxos/protocols");
|
|
280
|
-
var
|
|
287
|
+
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
281
288
|
var import_tracing9 = require("@dxos/tracing");
|
|
282
|
-
var import_util11 = require("@dxos/util");
|
|
283
289
|
var import_websocket_rpc = require("@dxos/websocket-rpc");
|
|
284
290
|
var import_async19 = require("@dxos/async");
|
|
285
291
|
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
286
292
|
var import_invariant19 = require("@dxos/invariant");
|
|
287
|
-
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
288
|
-
var import_config3 = require("@dxos/config");
|
|
289
293
|
var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
|
|
294
|
+
var import_config3 = require("@dxos/config");
|
|
295
|
+
var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
|
|
290
296
|
var import_tracing10 = require("@dxos/tracing");
|
|
297
|
+
var import_util11 = require("@dxos/util");
|
|
298
|
+
var import_keys16 = require("@dxos/keys");
|
|
291
299
|
var import_util12 = require("@dxos/util");
|
|
292
|
-
var import_keys15 = require("@dxos/keys");
|
|
293
|
-
var import_util13 = require("@dxos/util");
|
|
294
300
|
var import_async20 = require("@dxos/async");
|
|
295
301
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
296
|
-
var
|
|
297
|
-
var
|
|
298
|
-
var
|
|
299
|
-
var
|
|
302
|
+
var import_keys17 = require("@dxos/keys");
|
|
303
|
+
var import_log18 = require("@dxos/log");
|
|
304
|
+
var import_services19 = require("@dxos/protocols/proto/dxos/client/services");
|
|
305
|
+
var import_util13 = require("@dxos/util");
|
|
300
306
|
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
301
307
|
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
302
|
-
var
|
|
303
|
-
var
|
|
308
|
+
var import_services20 = require("@dxos/protocols/proto/dxos/client/services");
|
|
309
|
+
var import_util14 = require("@dxos/util");
|
|
304
310
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
305
311
|
return new import_codec_protobuf.Stream(({ next }) => {
|
|
306
312
|
const subscriptions = new import_async.EventSubscriptions();
|
|
@@ -611,7 +617,7 @@ var DevtoolsServiceImpl = class {
|
|
|
611
617
|
});
|
|
612
618
|
}
|
|
613
619
|
};
|
|
614
|
-
var DXOS_VERSION = "0.5.9-main.
|
|
620
|
+
var DXOS_VERSION = "0.5.9-main.bf0ae3e";
|
|
615
621
|
var getPlatform = () => {
|
|
616
622
|
if (process.browser) {
|
|
617
623
|
if (typeof window !== "undefined") {
|
|
@@ -953,6 +959,47 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
953
959
|
return deviceSet.has(deviceKey);
|
|
954
960
|
}
|
|
955
961
|
};
|
|
962
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts";
|
|
963
|
+
var DefaultSpaceStateMachine = class {
|
|
964
|
+
constructor(_params) {
|
|
965
|
+
this._params = _params;
|
|
966
|
+
}
|
|
967
|
+
get spaceId() {
|
|
968
|
+
return this._spaceId;
|
|
969
|
+
}
|
|
970
|
+
async processCredential(credential) {
|
|
971
|
+
const assertion = (0, import_credentials5.getCredentialAssertion)(credential);
|
|
972
|
+
switch (assertion["@type"]) {
|
|
973
|
+
case "dxos.halo.credentials.DefaultSpace": {
|
|
974
|
+
if (!credential.subject.id.equals(this._params.identityKey)) {
|
|
975
|
+
import_log3.log.warn("Invalid default space credential", {
|
|
976
|
+
expectedIdentity: this._params.identityKey,
|
|
977
|
+
credential
|
|
978
|
+
}, {
|
|
979
|
+
F: __dxlog_file3,
|
|
980
|
+
L: 32,
|
|
981
|
+
S: this,
|
|
982
|
+
C: (f, a) => f(...a)
|
|
983
|
+
});
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
if (!import_keys4.SpaceId.isValid(assertion.spaceId)) {
|
|
987
|
+
import_log3.log.warn("Invalid default space id", {
|
|
988
|
+
id: assertion.spaceId
|
|
989
|
+
}, {
|
|
990
|
+
F: __dxlog_file3,
|
|
991
|
+
L: 36,
|
|
992
|
+
S: this,
|
|
993
|
+
C: (f, a) => f(...a)
|
|
994
|
+
});
|
|
995
|
+
return;
|
|
996
|
+
}
|
|
997
|
+
this._spaceId = assertion.spaceId;
|
|
998
|
+
break;
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
};
|
|
956
1003
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
957
1004
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
958
1005
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -963,7 +1010,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
963
1010
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
964
1011
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
965
1012
|
}
|
|
966
|
-
var
|
|
1013
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
967
1014
|
var Identity = class {
|
|
968
1015
|
constructor({ space, signer, identityKey, deviceKey, presence }) {
|
|
969
1016
|
this.stateUpdate = new import_async6.Event();
|
|
@@ -975,8 +1022,8 @@ var Identity = class {
|
|
|
975
1022
|
import_log2.log.trace("dxos.halo.device", {
|
|
976
1023
|
deviceKey
|
|
977
1024
|
}, {
|
|
978
|
-
F:
|
|
979
|
-
L:
|
|
1025
|
+
F: __dxlog_file4,
|
|
1026
|
+
L: 70,
|
|
980
1027
|
S: this,
|
|
981
1028
|
C: (f, a) => f(...a)
|
|
982
1029
|
});
|
|
@@ -989,6 +1036,10 @@ var Identity = class {
|
|
|
989
1036
|
identityKey: this.identityKey,
|
|
990
1037
|
onUpdate: () => this.stateUpdate.emit()
|
|
991
1038
|
});
|
|
1039
|
+
this._defaultSpaceStateMachine = new DefaultSpaceStateMachine({
|
|
1040
|
+
identityKey: this.identityKey,
|
|
1041
|
+
onUpdate: () => this.stateUpdate.emit()
|
|
1042
|
+
});
|
|
992
1043
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
993
1044
|
trustedKeysProvider: () => new import_util2.ComplexSet(import_keys3.PublicKey.hash, this.authorizedDeviceKeys.keys()),
|
|
994
1045
|
update: this.stateUpdate,
|
|
@@ -999,14 +1050,20 @@ var Identity = class {
|
|
|
999
1050
|
get authorizedDeviceKeys() {
|
|
1000
1051
|
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
1001
1052
|
}
|
|
1053
|
+
get defaultSpaceId() {
|
|
1054
|
+
return this._defaultSpaceStateMachine.spaceId;
|
|
1055
|
+
}
|
|
1002
1056
|
async open(ctx) {
|
|
1057
|
+
await this._presence?.open();
|
|
1003
1058
|
await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
|
|
1004
1059
|
await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
|
|
1060
|
+
await this.space.spaceState.addCredentialProcessor(this._defaultSpaceStateMachine);
|
|
1005
1061
|
await this.space.open(ctx);
|
|
1006
1062
|
}
|
|
1007
1063
|
async close(ctx) {
|
|
1008
|
-
await this._presence?.
|
|
1064
|
+
await this._presence?.close();
|
|
1009
1065
|
await this.authVerifier.close();
|
|
1066
|
+
await this.space.spaceState.removeCredentialProcessor(this._defaultSpaceStateMachine);
|
|
1010
1067
|
await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
|
|
1011
1068
|
await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
|
|
1012
1069
|
await this.space.close();
|
|
@@ -1044,8 +1101,8 @@ var Identity = class {
|
|
|
1044
1101
|
*/
|
|
1045
1102
|
getIdentityCredentialSigner() {
|
|
1046
1103
|
(0, import_invariant2.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
|
|
1047
|
-
F:
|
|
1048
|
-
L:
|
|
1104
|
+
F: __dxlog_file4,
|
|
1105
|
+
L: 159,
|
|
1049
1106
|
S: this,
|
|
1050
1107
|
A: [
|
|
1051
1108
|
"this._deviceStateMachine.deviceCredentialChain",
|
|
@@ -1060,6 +1117,26 @@ var Identity = class {
|
|
|
1060
1117
|
getDeviceCredentialSigner() {
|
|
1061
1118
|
return (0, import_credentials3.createCredentialSignerWithKey)(this._signer, this.deviceKey);
|
|
1062
1119
|
}
|
|
1120
|
+
async updateDefaultSpace(spaceId) {
|
|
1121
|
+
const credential = await this.getDeviceCredentialSigner().createCredential({
|
|
1122
|
+
subject: this.identityKey,
|
|
1123
|
+
assertion: {
|
|
1124
|
+
"@type": "dxos.halo.credentials.DefaultSpace",
|
|
1125
|
+
spaceId
|
|
1126
|
+
}
|
|
1127
|
+
});
|
|
1128
|
+
const receipt = await this.controlPipeline.writer.write({
|
|
1129
|
+
credential: {
|
|
1130
|
+
credential
|
|
1131
|
+
}
|
|
1132
|
+
});
|
|
1133
|
+
await this.controlPipeline.state.waitUntilTimeframe(new import_timeframe.Timeframe([
|
|
1134
|
+
[
|
|
1135
|
+
receipt.feedKey,
|
|
1136
|
+
receipt.seq
|
|
1137
|
+
]
|
|
1138
|
+
]));
|
|
1139
|
+
}
|
|
1063
1140
|
async admitDevice({ deviceKey, controlFeedKey, dataFeedKey }) {
|
|
1064
1141
|
(0, import_log2.log)("Admitting device:", {
|
|
1065
1142
|
identityKey: this.identityKey,
|
|
@@ -1068,8 +1145,8 @@ var Identity = class {
|
|
|
1068
1145
|
controlFeedKey,
|
|
1069
1146
|
dataFeedKey
|
|
1070
1147
|
}, {
|
|
1071
|
-
F:
|
|
1072
|
-
L:
|
|
1148
|
+
F: __dxlog_file4,
|
|
1149
|
+
L: 184,
|
|
1073
1150
|
S: this,
|
|
1074
1151
|
C: (f, a) => f(...a)
|
|
1075
1152
|
});
|
|
@@ -1129,7 +1206,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
1129
1206
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1130
1207
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1131
1208
|
}
|
|
1132
|
-
var
|
|
1209
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
1133
1210
|
var DEVICE_PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
1134
1211
|
var DEVICE_PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
1135
1212
|
var IdentityManager = class {
|
|
@@ -1149,20 +1226,20 @@ var IdentityManager = class {
|
|
|
1149
1226
|
return this._identity;
|
|
1150
1227
|
}
|
|
1151
1228
|
async open(ctx) {
|
|
1152
|
-
const traceId =
|
|
1153
|
-
|
|
1229
|
+
const traceId = import_keys5.PublicKey.random().toHex();
|
|
1230
|
+
import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.begin({
|
|
1154
1231
|
id: traceId
|
|
1155
1232
|
}), {
|
|
1156
|
-
F:
|
|
1233
|
+
F: __dxlog_file5,
|
|
1157
1234
|
L: 104,
|
|
1158
1235
|
S: this,
|
|
1159
1236
|
C: (f, a) => f(...a)
|
|
1160
1237
|
});
|
|
1161
1238
|
const identityRecord = this._metadataStore.getIdentityRecord();
|
|
1162
|
-
(0,
|
|
1239
|
+
(0, import_log4.log)("identity record", {
|
|
1163
1240
|
identityRecord
|
|
1164
1241
|
}, {
|
|
1165
|
-
F:
|
|
1242
|
+
F: __dxlog_file5,
|
|
1166
1243
|
L: 107,
|
|
1167
1244
|
S: this,
|
|
1168
1245
|
C: (f, a) => f(...a)
|
|
@@ -1171,21 +1248,21 @@ var IdentityManager = class {
|
|
|
1171
1248
|
this._identity = await this._constructIdentity(identityRecord);
|
|
1172
1249
|
await this._identity.open(ctx);
|
|
1173
1250
|
await this._identity.ready();
|
|
1174
|
-
|
|
1251
|
+
import_log4.log.trace("dxos.halo.identity", {
|
|
1175
1252
|
identityKey: identityRecord.identityKey,
|
|
1176
1253
|
displayName: this._identity.profileDocument?.displayName
|
|
1177
1254
|
}, {
|
|
1178
|
-
F:
|
|
1255
|
+
F: __dxlog_file5,
|
|
1179
1256
|
L: 112,
|
|
1180
1257
|
S: this,
|
|
1181
1258
|
C: (f, a) => f(...a)
|
|
1182
1259
|
});
|
|
1183
1260
|
this.stateUpdate.emit();
|
|
1184
1261
|
}
|
|
1185
|
-
|
|
1262
|
+
import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.end({
|
|
1186
1263
|
id: traceId
|
|
1187
1264
|
}), {
|
|
1188
|
-
F:
|
|
1265
|
+
F: __dxlog_file5,
|
|
1189
1266
|
L: 119,
|
|
1190
1267
|
S: this,
|
|
1191
1268
|
C: (f, a) => f(...a)
|
|
@@ -1196,7 +1273,7 @@ var IdentityManager = class {
|
|
|
1196
1273
|
}
|
|
1197
1274
|
async createIdentity({ displayName, deviceProfile } = {}) {
|
|
1198
1275
|
(0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
|
|
1199
|
-
F:
|
|
1276
|
+
F: __dxlog_file5,
|
|
1200
1277
|
L: 128,
|
|
1201
1278
|
S: this,
|
|
1202
1279
|
A: [
|
|
@@ -1204,8 +1281,8 @@ var IdentityManager = class {
|
|
|
1204
1281
|
"'Identity already exists.'"
|
|
1205
1282
|
]
|
|
1206
1283
|
});
|
|
1207
|
-
(0,
|
|
1208
|
-
F:
|
|
1284
|
+
(0, import_log4.log)("creating identity...", void 0, {
|
|
1285
|
+
F: __dxlog_file5,
|
|
1209
1286
|
L: 129,
|
|
1210
1287
|
S: this,
|
|
1211
1288
|
C: (f, a) => f(...a)
|
|
@@ -1224,9 +1301,9 @@ var IdentityManager = class {
|
|
|
1224
1301
|
const identity = await this._constructIdentity(identityRecord);
|
|
1225
1302
|
await identity.open(new import_context3.Context());
|
|
1226
1303
|
{
|
|
1227
|
-
const generator = new
|
|
1304
|
+
const generator = new import_credentials6.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
1228
1305
|
(0, import_invariant3.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
|
|
1229
|
-
F:
|
|
1306
|
+
F: __dxlog_file5,
|
|
1230
1307
|
L: 148,
|
|
1231
1308
|
S: this,
|
|
1232
1309
|
A: [
|
|
@@ -1235,7 +1312,7 @@ var IdentityManager = class {
|
|
|
1235
1312
|
]
|
|
1236
1313
|
});
|
|
1237
1314
|
(0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
|
|
1238
|
-
F:
|
|
1315
|
+
F: __dxlog_file5,
|
|
1239
1316
|
L: 149,
|
|
1240
1317
|
S: this,
|
|
1241
1318
|
A: [
|
|
@@ -1247,7 +1324,7 @@ var IdentityManager = class {
|
|
|
1247
1324
|
// Space genesis.
|
|
1248
1325
|
...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
|
|
1249
1326
|
// Feed admission.
|
|
1250
|
-
await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey,
|
|
1327
|
+
await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey, import_credentials7.AdmittedFeed.Designation.DATA)
|
|
1251
1328
|
];
|
|
1252
1329
|
if (displayName) {
|
|
1253
1330
|
credentials.push(await generator.createProfileCredential({
|
|
@@ -1270,22 +1347,22 @@ var IdentityManager = class {
|
|
|
1270
1347
|
await this._metadataStore.setIdentityRecord(identityRecord);
|
|
1271
1348
|
this._identity = identity;
|
|
1272
1349
|
await this._identity.ready();
|
|
1273
|
-
|
|
1350
|
+
import_log4.log.trace("dxos.halo.identity", {
|
|
1274
1351
|
identityKey: identityRecord.identityKey,
|
|
1275
1352
|
displayName: this._identity.profileDocument?.displayName
|
|
1276
1353
|
}, {
|
|
1277
|
-
F:
|
|
1354
|
+
F: __dxlog_file5,
|
|
1278
1355
|
L: 191,
|
|
1279
1356
|
S: this,
|
|
1280
1357
|
C: (f, a) => f(...a)
|
|
1281
1358
|
});
|
|
1282
1359
|
this.stateUpdate.emit();
|
|
1283
|
-
(0,
|
|
1360
|
+
(0, import_log4.log)("created identity", {
|
|
1284
1361
|
identityKey: identity.identityKey,
|
|
1285
1362
|
deviceKey: identity.deviceKey,
|
|
1286
1363
|
profile: identity.profileDocument
|
|
1287
1364
|
}, {
|
|
1288
|
-
F:
|
|
1365
|
+
F: __dxlog_file5,
|
|
1289
1366
|
L: 197,
|
|
1290
1367
|
S: this,
|
|
1291
1368
|
C: (f, a) => f(...a)
|
|
@@ -1296,14 +1373,14 @@ var IdentityManager = class {
|
|
|
1296
1373
|
createDefaultDeviceProfile() {
|
|
1297
1374
|
let type;
|
|
1298
1375
|
if ((0, import_util3.isNode)()) {
|
|
1299
|
-
type =
|
|
1376
|
+
type = import_credentials7.DeviceType.AGENT;
|
|
1300
1377
|
} else {
|
|
1301
1378
|
if (import_platform.default.name?.startsWith("iOS") || import_platform.default.name?.startsWith("Android")) {
|
|
1302
|
-
type =
|
|
1379
|
+
type = import_credentials7.DeviceType.MOBILE;
|
|
1303
1380
|
} else if (globalThis.__args) {
|
|
1304
|
-
type =
|
|
1381
|
+
type = import_credentials7.DeviceType.NATIVE;
|
|
1305
1382
|
} else {
|
|
1306
|
-
type =
|
|
1383
|
+
type = import_credentials7.DeviceType.BROWSER;
|
|
1307
1384
|
}
|
|
1308
1385
|
}
|
|
1309
1386
|
return {
|
|
@@ -1319,16 +1396,16 @@ var IdentityManager = class {
|
|
|
1319
1396
|
* Accept an existing identity. Expects its device key to be authorized (now or later).
|
|
1320
1397
|
*/
|
|
1321
1398
|
async acceptIdentity(params) {
|
|
1322
|
-
(0,
|
|
1399
|
+
(0, import_log4.log)("accepting identity", {
|
|
1323
1400
|
params
|
|
1324
1401
|
}, {
|
|
1325
|
-
F:
|
|
1402
|
+
F: __dxlog_file5,
|
|
1326
1403
|
L: 235,
|
|
1327
1404
|
S: this,
|
|
1328
1405
|
C: (f, a) => f(...a)
|
|
1329
1406
|
});
|
|
1330
1407
|
(0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
|
|
1331
|
-
F:
|
|
1408
|
+
F: __dxlog_file5,
|
|
1332
1409
|
L: 236,
|
|
1333
1410
|
S: this,
|
|
1334
1411
|
A: [
|
|
@@ -1352,11 +1429,11 @@ var IdentityManager = class {
|
|
|
1352
1429
|
this._identity = identity;
|
|
1353
1430
|
await this._metadataStore.setIdentityRecord(identityRecord);
|
|
1354
1431
|
await this._identity.ready();
|
|
1355
|
-
|
|
1432
|
+
import_log4.log.trace("dxos.halo.identity", {
|
|
1356
1433
|
identityKey: identityRecord.identityKey,
|
|
1357
1434
|
displayName: this._identity.profileDocument?.displayName
|
|
1358
1435
|
}, {
|
|
1359
|
-
F:
|
|
1436
|
+
F: __dxlog_file5,
|
|
1360
1437
|
L: 255,
|
|
1361
1438
|
S: this,
|
|
1362
1439
|
C: (f, a) => f(...a)
|
|
@@ -1366,11 +1443,11 @@ var IdentityManager = class {
|
|
|
1366
1443
|
...params.deviceProfile
|
|
1367
1444
|
});
|
|
1368
1445
|
this.stateUpdate.emit();
|
|
1369
|
-
(0,
|
|
1446
|
+
(0, import_log4.log)("accepted identity", {
|
|
1370
1447
|
identityKey: identity.identityKey,
|
|
1371
1448
|
deviceKey: identity.deviceKey
|
|
1372
1449
|
}, {
|
|
1373
|
-
F:
|
|
1450
|
+
F: __dxlog_file5,
|
|
1374
1451
|
L: 265,
|
|
1375
1452
|
S: this,
|
|
1376
1453
|
C: (f, a) => f(...a)
|
|
@@ -1382,7 +1459,7 @@ var IdentityManager = class {
|
|
|
1382
1459
|
*/
|
|
1383
1460
|
async updateProfile(profile) {
|
|
1384
1461
|
(0, import_invariant3.invariant)(this._identity, "Identity not initialized.", {
|
|
1385
|
-
F:
|
|
1462
|
+
F: __dxlog_file5,
|
|
1386
1463
|
L: 273,
|
|
1387
1464
|
S: this,
|
|
1388
1465
|
A: [
|
|
@@ -1402,7 +1479,7 @@ var IdentityManager = class {
|
|
|
1402
1479
|
credential
|
|
1403
1480
|
}
|
|
1404
1481
|
});
|
|
1405
|
-
await this._identity.controlPipeline.state.waitUntilTimeframe(new
|
|
1482
|
+
await this._identity.controlPipeline.state.waitUntilTimeframe(new import_timeframe2.Timeframe([
|
|
1406
1483
|
[
|
|
1407
1484
|
receipt.feedKey,
|
|
1408
1485
|
receipt.seq
|
|
@@ -1413,7 +1490,7 @@ var IdentityManager = class {
|
|
|
1413
1490
|
}
|
|
1414
1491
|
async updateDeviceProfile(profile) {
|
|
1415
1492
|
(0, import_invariant3.invariant)(this._identity, "Identity not initialized.", {
|
|
1416
|
-
F:
|
|
1493
|
+
F: __dxlog_file5,
|
|
1417
1494
|
L: 290,
|
|
1418
1495
|
S: this,
|
|
1419
1496
|
A: [
|
|
@@ -1433,7 +1510,7 @@ var IdentityManager = class {
|
|
|
1433
1510
|
credential
|
|
1434
1511
|
}
|
|
1435
1512
|
});
|
|
1436
|
-
await this._identity.controlPipeline.state.waitUntilTimeframe(new
|
|
1513
|
+
await this._identity.controlPipeline.state.waitUntilTimeframe(new import_timeframe2.Timeframe([
|
|
1437
1514
|
[
|
|
1438
1515
|
receipt.feedKey,
|
|
1439
1516
|
receipt.seq
|
|
@@ -1449,7 +1526,7 @@ var IdentityManager = class {
|
|
|
1449
1526
|
}
|
|
1450
1527
|
async _constructIdentity(identityRecord) {
|
|
1451
1528
|
(0, import_invariant3.invariant)(!this._identity, void 0, {
|
|
1452
|
-
F:
|
|
1529
|
+
F: __dxlog_file5,
|
|
1453
1530
|
L: 316,
|
|
1454
1531
|
S: this,
|
|
1455
1532
|
A: [
|
|
@@ -1457,10 +1534,10 @@ var IdentityManager = class {
|
|
|
1457
1534
|
""
|
|
1458
1535
|
]
|
|
1459
1536
|
});
|
|
1460
|
-
(0,
|
|
1537
|
+
(0, import_log4.log)("constructing identity", {
|
|
1461
1538
|
identityRecord
|
|
1462
1539
|
}, {
|
|
1463
|
-
F:
|
|
1540
|
+
F: __dxlog_file5,
|
|
1464
1541
|
L: 317,
|
|
1465
1542
|
S: this,
|
|
1466
1543
|
C: (f, a) => f(...a)
|
|
@@ -1475,7 +1552,7 @@ var IdentityManager = class {
|
|
|
1475
1552
|
gossip
|
|
1476
1553
|
});
|
|
1477
1554
|
(0, import_invariant3.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
|
|
1478
|
-
F:
|
|
1555
|
+
F: __dxlog_file5,
|
|
1479
1556
|
L: 330,
|
|
1480
1557
|
S: this,
|
|
1481
1558
|
A: [
|
|
@@ -1487,7 +1564,7 @@ var IdentityManager = class {
|
|
|
1487
1564
|
writable: true
|
|
1488
1565
|
});
|
|
1489
1566
|
(0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
|
|
1490
|
-
F:
|
|
1567
|
+
F: __dxlog_file5,
|
|
1491
1568
|
L: 334,
|
|
1492
1569
|
S: this,
|
|
1493
1570
|
A: [
|
|
@@ -1503,7 +1580,7 @@ var IdentityManager = class {
|
|
|
1503
1580
|
spaceRecord: identityRecord.haloSpace,
|
|
1504
1581
|
swarmIdentity: {
|
|
1505
1582
|
peerKey: identityRecord.deviceKey,
|
|
1506
|
-
credentialProvider: createAuthProvider((0,
|
|
1583
|
+
credentialProvider: createAuthProvider((0, import_credentials6.createCredentialSignerWithKey)(this._keyring, identityRecord.deviceKey)),
|
|
1507
1584
|
credentialAuthenticator: (0, import_util3.deferFunction)(() => identity.authVerifier.verifier)
|
|
1508
1585
|
},
|
|
1509
1586
|
gossip,
|
|
@@ -1518,10 +1595,10 @@ var IdentityManager = class {
|
|
|
1518
1595
|
identityKey: identityRecord.identityKey,
|
|
1519
1596
|
deviceKey: identityRecord.deviceKey
|
|
1520
1597
|
});
|
|
1521
|
-
(0,
|
|
1598
|
+
(0, import_log4.log)("done", {
|
|
1522
1599
|
identityKey: identityRecord.identityKey
|
|
1523
1600
|
}, {
|
|
1524
|
-
F:
|
|
1601
|
+
F: __dxlog_file5,
|
|
1525
1602
|
L: 360,
|
|
1526
1603
|
S: this,
|
|
1527
1604
|
C: (f, a) => f(...a)
|
|
@@ -1545,8 +1622,8 @@ var IdentityManager = class {
|
|
|
1545
1622
|
}));
|
|
1546
1623
|
},
|
|
1547
1624
|
onAuthFailure: () => {
|
|
1548
|
-
|
|
1549
|
-
F:
|
|
1625
|
+
import_log4.log.warn("auth failure", void 0, {
|
|
1626
|
+
F: __dxlog_file5,
|
|
1550
1627
|
L: 385,
|
|
1551
1628
|
S: this,
|
|
1552
1629
|
C: (f, a) => f(...a)
|
|
@@ -1568,21 +1645,45 @@ _ts_decorate3([
|
|
|
1568
1645
|
IdentityManager = _ts_decorate3([
|
|
1569
1646
|
import_tracing4.trace.resource()
|
|
1570
1647
|
], IdentityManager);
|
|
1571
|
-
var
|
|
1572
|
-
var IdentityServiceImpl = class {
|
|
1573
|
-
constructor(
|
|
1574
|
-
|
|
1648
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
1649
|
+
var IdentityServiceImpl = class extends import_context4.Resource {
|
|
1650
|
+
constructor(_identityManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
|
|
1651
|
+
super();
|
|
1575
1652
|
this._identityManager = _identityManager;
|
|
1576
1653
|
this._keyring = _keyring;
|
|
1654
|
+
this._dataSpaceManagerProvider = _dataSpaceManagerProvider;
|
|
1655
|
+
this._createIdentity = _createIdentity;
|
|
1577
1656
|
this._onProfileUpdate = _onProfileUpdate;
|
|
1578
1657
|
}
|
|
1658
|
+
async _open() {
|
|
1659
|
+
const identity = this._identityManager.identity;
|
|
1660
|
+
if (identity && !identity.defaultSpaceId) {
|
|
1661
|
+
await this._fixIdentityWithoutDefaultSpace(identity);
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1579
1664
|
async createIdentity(request) {
|
|
1580
1665
|
await this._createIdentity({
|
|
1581
1666
|
displayName: request.profile?.displayName,
|
|
1582
1667
|
deviceProfile: request.deviceProfile
|
|
1583
1668
|
});
|
|
1669
|
+
const dataSpaceManager = this._dataSpaceManagerProvider();
|
|
1670
|
+
await this._createDefaultSpace(dataSpaceManager);
|
|
1584
1671
|
return this._getIdentity();
|
|
1585
1672
|
}
|
|
1673
|
+
async _createDefaultSpace(dataSpaceManager) {
|
|
1674
|
+
const space = await dataSpaceManager.createDefaultSpace();
|
|
1675
|
+
const identity = this._identityManager.identity;
|
|
1676
|
+
(0, import_invariant4.invariant)(identity, void 0, {
|
|
1677
|
+
F: __dxlog_file6,
|
|
1678
|
+
L: 54,
|
|
1679
|
+
S: this,
|
|
1680
|
+
A: [
|
|
1681
|
+
"identity",
|
|
1682
|
+
""
|
|
1683
|
+
]
|
|
1684
|
+
});
|
|
1685
|
+
await identity.updateDefaultSpace(space.id);
|
|
1686
|
+
}
|
|
1586
1687
|
async recoverIdentity(request) {
|
|
1587
1688
|
return (0, import_debug2.todo)();
|
|
1588
1689
|
}
|
|
@@ -1607,8 +1708,8 @@ var IdentityServiceImpl = class {
|
|
|
1607
1708
|
}
|
|
1608
1709
|
async updateProfile(profile) {
|
|
1609
1710
|
(0, import_invariant4.invariant)(this._identityManager.identity, "Identity not initialized.", {
|
|
1610
|
-
F:
|
|
1611
|
-
L:
|
|
1711
|
+
F: __dxlog_file6,
|
|
1712
|
+
L: 84,
|
|
1612
1713
|
S: this,
|
|
1613
1714
|
A: [
|
|
1614
1715
|
"this._identityManager.identity",
|
|
@@ -1621,15 +1722,15 @@ var IdentityServiceImpl = class {
|
|
|
1621
1722
|
}
|
|
1622
1723
|
async signPresentation({ presentation, nonce }) {
|
|
1623
1724
|
(0, import_invariant4.invariant)(this._identityManager.identity, "Identity not initialized.", {
|
|
1624
|
-
F:
|
|
1625
|
-
L:
|
|
1725
|
+
F: __dxlog_file6,
|
|
1726
|
+
L: 91,
|
|
1626
1727
|
S: this,
|
|
1627
1728
|
A: [
|
|
1628
1729
|
"this._identityManager.identity",
|
|
1629
1730
|
"'Identity not initialized.'"
|
|
1630
1731
|
]
|
|
1631
1732
|
});
|
|
1632
|
-
return await (0,
|
|
1733
|
+
return await (0, import_credentials8.signPresentation)({
|
|
1633
1734
|
presentation,
|
|
1634
1735
|
signer: this._keyring,
|
|
1635
1736
|
signerKey: this._identityManager.identity.deviceKey,
|
|
@@ -1637,8 +1738,26 @@ var IdentityServiceImpl = class {
|
|
|
1637
1738
|
nonce
|
|
1638
1739
|
});
|
|
1639
1740
|
}
|
|
1741
|
+
async _fixIdentityWithoutDefaultSpace(identity) {
|
|
1742
|
+
let hasDefaultSpace = false;
|
|
1743
|
+
const dataSpaceManager = this._dataSpaceManagerProvider();
|
|
1744
|
+
for (const space of dataSpaceManager.spaces.values()) {
|
|
1745
|
+
if (space.state === import_services4.SpaceState.CLOSED) {
|
|
1746
|
+
await space.open();
|
|
1747
|
+
await space.initializeDataPipeline();
|
|
1748
|
+
}
|
|
1749
|
+
if (await dataSpaceManager.isDefaultSpace(space)) {
|
|
1750
|
+
await identity.updateDefaultSpace(space.id);
|
|
1751
|
+
hasDefaultSpace = true;
|
|
1752
|
+
break;
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
if (!hasDefaultSpace) {
|
|
1756
|
+
await this._createDefaultSpace(dataSpaceManager);
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1640
1759
|
};
|
|
1641
|
-
var
|
|
1760
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
|
|
1642
1761
|
var DeviceInvitationProtocol = class {
|
|
1643
1762
|
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
1644
1763
|
this._keyring = _keyring;
|
|
@@ -1653,7 +1772,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1653
1772
|
}
|
|
1654
1773
|
getInvitationContext() {
|
|
1655
1774
|
return {
|
|
1656
|
-
kind:
|
|
1775
|
+
kind: import_services5.Invitation.Kind.DEVICE
|
|
1657
1776
|
};
|
|
1658
1777
|
}
|
|
1659
1778
|
async delegate() {
|
|
@@ -1664,7 +1783,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1664
1783
|
}
|
|
1665
1784
|
async admit(_, request) {
|
|
1666
1785
|
(0, import_invariant5.invariant)(request.device, void 0, {
|
|
1667
|
-
F:
|
|
1786
|
+
F: __dxlog_file7,
|
|
1668
1787
|
L: 50,
|
|
1669
1788
|
S: this,
|
|
1670
1789
|
A: [
|
|
@@ -1710,7 +1829,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1710
1829
|
}
|
|
1711
1830
|
async accept(response, request) {
|
|
1712
1831
|
(0, import_invariant5.invariant)(response.device, void 0, {
|
|
1713
|
-
F:
|
|
1832
|
+
F: __dxlog_file7,
|
|
1714
1833
|
L: 95,
|
|
1715
1834
|
S: this,
|
|
1716
1835
|
A: [
|
|
@@ -1720,7 +1839,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1720
1839
|
});
|
|
1721
1840
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1722
1841
|
(0, import_invariant5.invariant)(request.device, void 0, {
|
|
1723
|
-
F:
|
|
1842
|
+
F: __dxlog_file7,
|
|
1724
1843
|
L: 98,
|
|
1725
1844
|
S: this,
|
|
1726
1845
|
A: [
|
|
@@ -1745,21 +1864,21 @@ var DeviceInvitationProtocol = class {
|
|
|
1745
1864
|
}
|
|
1746
1865
|
};
|
|
1747
1866
|
var stateToString = (state) => {
|
|
1748
|
-
return Object.entries(
|
|
1867
|
+
return Object.entries(import_services7.Invitation.State).find(([key, val]) => val === state)?.[0] ?? "unknown";
|
|
1749
1868
|
};
|
|
1750
1869
|
var tryAcquireBeforeContextDisposed = async (ctx, mutex) => {
|
|
1751
1870
|
let guard;
|
|
1752
|
-
return (0,
|
|
1871
|
+
return (0, import_context7.cancelWithContext)(ctx, (async () => {
|
|
1753
1872
|
guard = await mutex.acquire();
|
|
1754
1873
|
if (ctx.disposed) {
|
|
1755
1874
|
guard.release();
|
|
1756
1875
|
guard = void 0;
|
|
1757
|
-
throw new
|
|
1876
|
+
throw new import_context7.ContextDisposedError();
|
|
1758
1877
|
}
|
|
1759
1878
|
return guard;
|
|
1760
1879
|
})());
|
|
1761
1880
|
};
|
|
1762
|
-
var
|
|
1881
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts";
|
|
1763
1882
|
var OPTIONS_TIMEOUT = 1e4;
|
|
1764
1883
|
var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
1765
1884
|
constructor(_invitationFlowMutex, _callbacks) {
|
|
@@ -1773,7 +1892,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1773
1892
|
});
|
|
1774
1893
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
1775
1894
|
this._callbacks = _callbacks;
|
|
1776
|
-
this._ctx = new
|
|
1895
|
+
this._ctx = new import_context6.Context();
|
|
1777
1896
|
this._remoteOptionsTrigger = new import_async9.Trigger();
|
|
1778
1897
|
this._invitationFlowLock = null;
|
|
1779
1898
|
}
|
|
@@ -1785,7 +1904,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1785
1904
|
InvitationHostService: {
|
|
1786
1905
|
options: async (options) => {
|
|
1787
1906
|
(0, import_invariant7.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1788
|
-
F:
|
|
1907
|
+
F: __dxlog_file8,
|
|
1789
1908
|
L: 63,
|
|
1790
1909
|
S: this,
|
|
1791
1910
|
A: [
|
|
@@ -1811,33 +1930,33 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1811
1930
|
async onOpen(context) {
|
|
1812
1931
|
await super.onOpen(context);
|
|
1813
1932
|
try {
|
|
1814
|
-
(0,
|
|
1815
|
-
F:
|
|
1933
|
+
(0, import_log6.log)("guest acquire lock", void 0, {
|
|
1934
|
+
F: __dxlog_file8,
|
|
1816
1935
|
L: 84,
|
|
1817
1936
|
S: this,
|
|
1818
1937
|
C: (f, a) => f(...a)
|
|
1819
1938
|
});
|
|
1820
1939
|
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
1821
|
-
(0,
|
|
1822
|
-
F:
|
|
1940
|
+
(0, import_log6.log)("guest lock acquired", void 0, {
|
|
1941
|
+
F: __dxlog_file8,
|
|
1823
1942
|
L: 86,
|
|
1824
1943
|
S: this,
|
|
1825
1944
|
C: (f, a) => f(...a)
|
|
1826
1945
|
});
|
|
1827
|
-
await (0,
|
|
1946
|
+
await (0, import_context6.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
|
|
1828
1947
|
role: import_invitations3.Options.Role.GUEST
|
|
1829
1948
|
}));
|
|
1830
|
-
(0,
|
|
1831
|
-
F:
|
|
1949
|
+
(0, import_log6.log)("options sent", void 0, {
|
|
1950
|
+
F: __dxlog_file8,
|
|
1832
1951
|
L: 88,
|
|
1833
1952
|
S: this,
|
|
1834
1953
|
C: (f, a) => f(...a)
|
|
1835
1954
|
});
|
|
1836
|
-
await (0,
|
|
1955
|
+
await (0, import_context6.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1837
1956
|
timeout: OPTIONS_TIMEOUT
|
|
1838
1957
|
}));
|
|
1839
|
-
(0,
|
|
1840
|
-
F:
|
|
1958
|
+
(0, import_log6.log)("options received", void 0, {
|
|
1959
|
+
F: __dxlog_file8,
|
|
1841
1960
|
L: 90,
|
|
1842
1961
|
S: this,
|
|
1843
1962
|
C: (f, a) => f(...a)
|
|
@@ -1870,8 +1989,8 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1870
1989
|
if (this._invitationFlowLock != null) {
|
|
1871
1990
|
this._invitationFlowLock.release();
|
|
1872
1991
|
this._invitationFlowLock = null;
|
|
1873
|
-
(0,
|
|
1874
|
-
F:
|
|
1992
|
+
(0, import_log6.log)("invitation flow lock released", void 0, {
|
|
1993
|
+
F: __dxlog_file8,
|
|
1875
1994
|
L: 123,
|
|
1876
1995
|
S: this,
|
|
1877
1996
|
C: (f, a) => f(...a)
|
|
@@ -1879,7 +1998,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1879
1998
|
}
|
|
1880
1999
|
}
|
|
1881
2000
|
};
|
|
1882
|
-
var
|
|
2001
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts";
|
|
1883
2002
|
var OPTIONS_TIMEOUT2 = 1e4;
|
|
1884
2003
|
var MAX_OTP_ATTEMPTS = 3;
|
|
1885
2004
|
var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
@@ -1894,7 +2013,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
1894
2013
|
});
|
|
1895
2014
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
1896
2015
|
this._callbacks = _callbacks;
|
|
1897
|
-
this._ctx = new
|
|
2016
|
+
this._ctx = new import_context8.Context();
|
|
1898
2017
|
this._remoteOptionsTrigger = new import_async10.Trigger();
|
|
1899
2018
|
this._challenge = void 0;
|
|
1900
2019
|
this.guestProfile = void 0;
|
|
@@ -1913,7 +2032,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
1913
2032
|
InvitationHostService: {
|
|
1914
2033
|
options: async (options) => {
|
|
1915
2034
|
(0, import_invariant8.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1916
|
-
F:
|
|
2035
|
+
F: __dxlog_file9,
|
|
1917
2036
|
L: 101,
|
|
1918
2037
|
S: this,
|
|
1919
2038
|
A: [
|
|
@@ -1926,23 +2045,23 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
1926
2045
|
},
|
|
1927
2046
|
introduce: async (request) => {
|
|
1928
2047
|
const { profile, invitationId } = request;
|
|
1929
|
-
const traceId =
|
|
1930
|
-
|
|
2048
|
+
const traceId = import_keys7.PublicKey.random().toHex();
|
|
2049
|
+
import_log7.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols7.trace.begin({
|
|
1931
2050
|
id: traceId
|
|
1932
2051
|
}), {
|
|
1933
|
-
F:
|
|
2052
|
+
F: __dxlog_file9,
|
|
1934
2053
|
L: 110,
|
|
1935
2054
|
S: this,
|
|
1936
2055
|
C: (f, a) => f(...a)
|
|
1937
2056
|
});
|
|
1938
2057
|
const invitation = this._requireActiveInvitation();
|
|
1939
|
-
this._assertInvitationState(
|
|
2058
|
+
this._assertInvitationState(import_services8.Invitation.State.CONNECTED);
|
|
1940
2059
|
if (invitationId !== invitation?.invitationId) {
|
|
1941
|
-
|
|
2060
|
+
import_log7.log.warn("incorrect invitationId", {
|
|
1942
2061
|
expected: invitation.invitationId,
|
|
1943
2062
|
actual: invitationId
|
|
1944
2063
|
}, {
|
|
1945
|
-
F:
|
|
2064
|
+
F: __dxlog_file9,
|
|
1946
2065
|
L: 116,
|
|
1947
2066
|
S: this,
|
|
1948
2067
|
C: (f, a) => f(...a)
|
|
@@ -1950,24 +2069,24 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
1950
2069
|
this._callbacks.onError(new Error("Incorrect invitationId."));
|
|
1951
2070
|
(0, import_async10.scheduleTask)(this._ctx, () => this.close());
|
|
1952
2071
|
return {
|
|
1953
|
-
authMethod:
|
|
2072
|
+
authMethod: import_services8.Invitation.AuthMethod.NONE
|
|
1954
2073
|
};
|
|
1955
2074
|
}
|
|
1956
|
-
(0,
|
|
2075
|
+
(0, import_log7.log)("guest introduced themselves", {
|
|
1957
2076
|
guestProfile: profile
|
|
1958
2077
|
}, {
|
|
1959
|
-
F:
|
|
2078
|
+
F: __dxlog_file9,
|
|
1960
2079
|
L: 125,
|
|
1961
2080
|
S: this,
|
|
1962
2081
|
C: (f, a) => f(...a)
|
|
1963
2082
|
});
|
|
1964
2083
|
this.guestProfile = profile;
|
|
1965
|
-
this._callbacks.onStateUpdate(
|
|
1966
|
-
this._challenge = invitation.authMethod ===
|
|
1967
|
-
|
|
2084
|
+
this._callbacks.onStateUpdate(import_services8.Invitation.State.READY_FOR_AUTHENTICATION);
|
|
2085
|
+
this._challenge = invitation.authMethod === import_services8.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? (0, import_crypto2.randomBytes)(32) : void 0;
|
|
2086
|
+
import_log7.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols7.trace.end({
|
|
1968
2087
|
id: traceId
|
|
1969
2088
|
}), {
|
|
1970
|
-
F:
|
|
2089
|
+
F: __dxlog_file9,
|
|
1971
2090
|
L: 132,
|
|
1972
2091
|
S: this,
|
|
1973
2092
|
C: (f, a) => f(...a)
|
|
@@ -1978,34 +2097,34 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
1978
2097
|
};
|
|
1979
2098
|
},
|
|
1980
2099
|
authenticate: async ({ authCode: code, signedChallenge }) => {
|
|
1981
|
-
const traceId =
|
|
1982
|
-
|
|
2100
|
+
const traceId = import_keys7.PublicKey.random().toHex();
|
|
2101
|
+
import_log7.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols7.trace.begin({
|
|
1983
2102
|
id: traceId
|
|
1984
2103
|
}), {
|
|
1985
|
-
F:
|
|
2104
|
+
F: __dxlog_file9,
|
|
1986
2105
|
L: 141,
|
|
1987
2106
|
S: this,
|
|
1988
2107
|
C: (f, a) => f(...a)
|
|
1989
2108
|
});
|
|
1990
2109
|
const invitation = this._requireActiveInvitation();
|
|
1991
|
-
(0,
|
|
2110
|
+
(0, import_log7.log)("received authentication request", {
|
|
1992
2111
|
authCode: code
|
|
1993
2112
|
}, {
|
|
1994
|
-
F:
|
|
2113
|
+
F: __dxlog_file9,
|
|
1995
2114
|
L: 144,
|
|
1996
2115
|
S: this,
|
|
1997
2116
|
C: (f, a) => f(...a)
|
|
1998
2117
|
});
|
|
1999
2118
|
let status = import_invitations4.AuthenticationResponse.Status.OK;
|
|
2000
2119
|
this._assertInvitationState([
|
|
2001
|
-
|
|
2002
|
-
|
|
2120
|
+
import_services8.Invitation.State.AUTHENTICATING,
|
|
2121
|
+
import_services8.Invitation.State.READY_FOR_AUTHENTICATION
|
|
2003
2122
|
]);
|
|
2004
|
-
this._callbacks.onStateUpdate(
|
|
2123
|
+
this._callbacks.onStateUpdate(import_services8.Invitation.State.AUTHENTICATING);
|
|
2005
2124
|
switch (invitation.authMethod) {
|
|
2006
|
-
case
|
|
2007
|
-
(0,
|
|
2008
|
-
F:
|
|
2125
|
+
case import_services8.Invitation.AuthMethod.NONE: {
|
|
2126
|
+
(0, import_log7.log)("authentication not required", void 0, {
|
|
2127
|
+
F: __dxlog_file9,
|
|
2009
2128
|
L: 152,
|
|
2010
2129
|
S: this,
|
|
2011
2130
|
C: (f, a) => f(...a)
|
|
@@ -2014,7 +2133,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2014
2133
|
status: import_invitations4.AuthenticationResponse.Status.OK
|
|
2015
2134
|
};
|
|
2016
2135
|
}
|
|
2017
|
-
case
|
|
2136
|
+
case import_services8.Invitation.AuthMethod.SHARED_SECRET: {
|
|
2018
2137
|
if (invitation.authCode) {
|
|
2019
2138
|
if (this.authenticationRetry++ > MAX_OTP_ATTEMPTS) {
|
|
2020
2139
|
status = import_invitations4.AuthenticationResponse.Status.INVALID_OPT_ATTEMPTS;
|
|
@@ -2026,7 +2145,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2026
2145
|
}
|
|
2027
2146
|
break;
|
|
2028
2147
|
}
|
|
2029
|
-
case
|
|
2148
|
+
case import_services8.Invitation.AuthMethod.KNOWN_PUBLIC_KEY: {
|
|
2030
2149
|
if (!invitation.guestKeypair) {
|
|
2031
2150
|
status = import_invitations4.AuthenticationResponse.Status.INTERNAL_ERROR;
|
|
2032
2151
|
break;
|
|
@@ -2040,10 +2159,10 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2040
2159
|
break;
|
|
2041
2160
|
}
|
|
2042
2161
|
default: {
|
|
2043
|
-
|
|
2162
|
+
import_log7.log.error("invalid authentication method", {
|
|
2044
2163
|
authMethod: invitation.authMethod
|
|
2045
2164
|
}, {
|
|
2046
|
-
F:
|
|
2165
|
+
F: __dxlog_file9,
|
|
2047
2166
|
L: 190,
|
|
2048
2167
|
S: this,
|
|
2049
2168
|
C: (f, a) => f(...a)
|
|
@@ -2062,13 +2181,13 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2062
2181
|
status
|
|
2063
2182
|
};
|
|
2064
2183
|
}
|
|
2065
|
-
|
|
2184
|
+
import_log7.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols7.trace.end({
|
|
2066
2185
|
id: traceId,
|
|
2067
2186
|
data: {
|
|
2068
2187
|
status
|
|
2069
2188
|
}
|
|
2070
2189
|
}), {
|
|
2071
|
-
F:
|
|
2190
|
+
F: __dxlog_file9,
|
|
2072
2191
|
L: 202,
|
|
2073
2192
|
S: this,
|
|
2074
2193
|
C: (f, a) => f(...a)
|
|
@@ -2078,11 +2197,11 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2078
2197
|
};
|
|
2079
2198
|
},
|
|
2080
2199
|
admit: async (request) => {
|
|
2081
|
-
const traceId =
|
|
2082
|
-
|
|
2200
|
+
const traceId = import_keys7.PublicKey.random().toHex();
|
|
2201
|
+
import_log7.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols7.trace.begin({
|
|
2083
2202
|
id: traceId
|
|
2084
2203
|
}), {
|
|
2085
|
-
F:
|
|
2204
|
+
F: __dxlog_file9,
|
|
2086
2205
|
L: 208,
|
|
2087
2206
|
S: this,
|
|
2088
2207
|
C: (f, a) => f(...a)
|
|
@@ -2090,16 +2209,16 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2090
2209
|
const invitation = this._requireActiveInvitation();
|
|
2091
2210
|
try {
|
|
2092
2211
|
if (isAuthenticationRequired(invitation)) {
|
|
2093
|
-
this._assertInvitationState(
|
|
2212
|
+
this._assertInvitationState(import_services8.Invitation.State.AUTHENTICATING);
|
|
2094
2213
|
if (!this.authenticationPassed) {
|
|
2095
2214
|
throw new Error("Not authenticated");
|
|
2096
2215
|
}
|
|
2097
2216
|
}
|
|
2098
2217
|
const response = await this._callbacks.admit(request);
|
|
2099
|
-
|
|
2218
|
+
import_log7.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols7.trace.end({
|
|
2100
2219
|
id: traceId
|
|
2101
2220
|
}), {
|
|
2102
|
-
F:
|
|
2221
|
+
F: __dxlog_file9,
|
|
2103
2222
|
L: 222,
|
|
2104
2223
|
S: this,
|
|
2105
2224
|
C: (f, a) => f(...a)
|
|
@@ -2116,35 +2235,35 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2116
2235
|
async onOpen(context) {
|
|
2117
2236
|
await super.onOpen(context);
|
|
2118
2237
|
try {
|
|
2119
|
-
(0,
|
|
2120
|
-
F:
|
|
2238
|
+
(0, import_log7.log)("host acquire lock", void 0, {
|
|
2239
|
+
F: __dxlog_file9,
|
|
2121
2240
|
L: 237,
|
|
2122
2241
|
S: this,
|
|
2123
2242
|
C: (f, a) => f(...a)
|
|
2124
2243
|
});
|
|
2125
2244
|
this._invitationFlowLock = await tryAcquireBeforeContextDisposed(this._ctx, this._invitationFlowMutex);
|
|
2126
|
-
(0,
|
|
2127
|
-
F:
|
|
2245
|
+
(0, import_log7.log)("host lock acquired", void 0, {
|
|
2246
|
+
F: __dxlog_file9,
|
|
2128
2247
|
L: 239,
|
|
2129
2248
|
S: this,
|
|
2130
2249
|
C: (f, a) => f(...a)
|
|
2131
2250
|
});
|
|
2132
2251
|
const lastState = this._requireActiveInvitation().state;
|
|
2133
|
-
this._callbacks.onStateUpdate(
|
|
2252
|
+
this._callbacks.onStateUpdate(import_services8.Invitation.State.CONNECTING);
|
|
2134
2253
|
await this.rpc.InvitationHostService.options({
|
|
2135
2254
|
role: import_invitations4.Options.Role.HOST
|
|
2136
2255
|
});
|
|
2137
|
-
(0,
|
|
2138
|
-
F:
|
|
2256
|
+
(0, import_log7.log)("options sent", void 0, {
|
|
2257
|
+
F: __dxlog_file9,
|
|
2139
2258
|
L: 243,
|
|
2140
2259
|
S: this,
|
|
2141
2260
|
C: (f, a) => f(...a)
|
|
2142
2261
|
});
|
|
2143
|
-
await (0,
|
|
2262
|
+
await (0, import_context8.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
2144
2263
|
timeout: OPTIONS_TIMEOUT2
|
|
2145
2264
|
}));
|
|
2146
|
-
(0,
|
|
2147
|
-
F:
|
|
2265
|
+
(0, import_log7.log)("options received", void 0, {
|
|
2266
|
+
F: __dxlog_file9,
|
|
2148
2267
|
L: 245,
|
|
2149
2268
|
S: this,
|
|
2150
2269
|
C: (f, a) => f(...a)
|
|
@@ -2157,7 +2276,7 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2157
2276
|
remotePeerId: context.remotePeerId
|
|
2158
2277
|
});
|
|
2159
2278
|
}
|
|
2160
|
-
this._callbacks.onStateUpdate(
|
|
2279
|
+
this._callbacks.onStateUpdate(import_services8.Invitation.State.CONNECTED);
|
|
2161
2280
|
this._callbacks.onOpen(this._ctx, context);
|
|
2162
2281
|
} catch (err) {
|
|
2163
2282
|
if (this._invitationFlowLock != null) {
|
|
@@ -2197,8 +2316,8 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2197
2316
|
if (this._invitationFlowLock != null) {
|
|
2198
2317
|
this._invitationFlowLock?.release();
|
|
2199
2318
|
this._invitationFlowLock = null;
|
|
2200
|
-
(0,
|
|
2201
|
-
F:
|
|
2319
|
+
(0, import_log7.log)("invitation flow lock released", void 0, {
|
|
2320
|
+
F: __dxlog_file9,
|
|
2202
2321
|
L: 300,
|
|
2203
2322
|
S: this,
|
|
2204
2323
|
C: (f, a) => f(...a)
|
|
@@ -2206,16 +2325,16 @@ var InvitationHostExtension = class extends import_teleport2.RpcExtension {
|
|
|
2206
2325
|
}
|
|
2207
2326
|
}
|
|
2208
2327
|
};
|
|
2209
|
-
var isAuthenticationRequired = (invitation) => invitation.authMethod !==
|
|
2210
|
-
var
|
|
2328
|
+
var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services8.Invitation.AuthMethod.NONE;
|
|
2329
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts";
|
|
2211
2330
|
var InvitationTopology = class {
|
|
2212
2331
|
constructor(_role) {
|
|
2213
2332
|
this._role = _role;
|
|
2214
|
-
this._seenPeers = new import_util5.ComplexSet(
|
|
2333
|
+
this._seenPeers = new import_util5.ComplexSet(import_keys8.PublicKey.hash);
|
|
2215
2334
|
}
|
|
2216
2335
|
init(controller) {
|
|
2217
2336
|
(0, import_invariant9.invariant)(!this._controller, "Already initialized.", {
|
|
2218
|
-
F:
|
|
2337
|
+
F: __dxlog_file10,
|
|
2219
2338
|
L: 42,
|
|
2220
2339
|
S: this,
|
|
2221
2340
|
A: [
|
|
@@ -2227,7 +2346,7 @@ var InvitationTopology = class {
|
|
|
2227
2346
|
}
|
|
2228
2347
|
update() {
|
|
2229
2348
|
(0, import_invariant9.invariant)(this._controller, "Not initialized.", {
|
|
2230
|
-
F:
|
|
2349
|
+
F: __dxlog_file10,
|
|
2231
2350
|
L: 47,
|
|
2232
2351
|
S: this,
|
|
2233
2352
|
A: [
|
|
@@ -2244,13 +2363,13 @@ var InvitationTopology = class {
|
|
|
2244
2363
|
return;
|
|
2245
2364
|
}
|
|
2246
2365
|
const firstUnknownPeer = candidates.find((peerId) => !this._seenPeers.has(peerId));
|
|
2247
|
-
this._seenPeers = new import_util5.ComplexSet(
|
|
2366
|
+
this._seenPeers = new import_util5.ComplexSet(import_keys8.PublicKey.hash, allPeers.filter((peerId) => this._seenPeers.has(peerId)));
|
|
2248
2367
|
if (firstUnknownPeer != null) {
|
|
2249
|
-
(0,
|
|
2368
|
+
(0, import_log8.log)("invitation connect", {
|
|
2250
2369
|
ownPeerId,
|
|
2251
2370
|
remotePeerId: firstUnknownPeer
|
|
2252
2371
|
}, {
|
|
2253
|
-
F:
|
|
2372
|
+
F: __dxlog_file10,
|
|
2254
2373
|
L: 69,
|
|
2255
2374
|
S: this,
|
|
2256
2375
|
C: (f, a) => f(...a)
|
|
@@ -2261,7 +2380,7 @@ var InvitationTopology = class {
|
|
|
2261
2380
|
}
|
|
2262
2381
|
async onOffer(peer) {
|
|
2263
2382
|
(0, import_invariant9.invariant)(this._controller, "Not initialized.", {
|
|
2264
|
-
F:
|
|
2383
|
+
F: __dxlog_file10,
|
|
2265
2384
|
L: 76,
|
|
2266
2385
|
S: this,
|
|
2267
2386
|
A: [
|
|
@@ -2278,7 +2397,7 @@ var InvitationTopology = class {
|
|
|
2278
2397
|
return `InvitationTopology(${this._role === import_invitations5.Options.Role.GUEST ? "guest" : "host"})`;
|
|
2279
2398
|
}
|
|
2280
2399
|
};
|
|
2281
|
-
var
|
|
2400
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
2282
2401
|
var MAX_DELEGATED_INVITATION_HOST_TRIES = 3;
|
|
2283
2402
|
var InvitationsHandler = class {
|
|
2284
2403
|
/**
|
|
@@ -2303,7 +2422,7 @@ var InvitationsHandler = class {
|
|
|
2303
2422
|
try {
|
|
2304
2423
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
2305
2424
|
(0, import_invariant6.invariant)(deviceKey, void 0, {
|
|
2306
|
-
F:
|
|
2425
|
+
F: __dxlog_file11,
|
|
2307
2426
|
L: 90,
|
|
2308
2427
|
S: this,
|
|
2309
2428
|
A: [
|
|
@@ -2323,24 +2442,24 @@ var InvitationsHandler = class {
|
|
|
2323
2442
|
let admitted = false;
|
|
2324
2443
|
connectionCtx.onDispose(() => {
|
|
2325
2444
|
if (!admitted) {
|
|
2326
|
-
guardedState.error(extension, new
|
|
2445
|
+
guardedState.error(extension, new import_context5.ContextDisposedError());
|
|
2327
2446
|
}
|
|
2328
2447
|
});
|
|
2329
2448
|
(0, import_async8.scheduleTask)(connectionCtx, async () => {
|
|
2330
|
-
const traceId =
|
|
2449
|
+
const traceId = import_keys6.PublicKey.random().toHex();
|
|
2331
2450
|
try {
|
|
2332
|
-
|
|
2451
|
+
import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.begin({
|
|
2333
2452
|
id: traceId
|
|
2334
2453
|
}), {
|
|
2335
|
-
F:
|
|
2454
|
+
F: __dxlog_file11,
|
|
2336
2455
|
L: 115,
|
|
2337
2456
|
S: this,
|
|
2338
2457
|
C: (f, a) => f(...a)
|
|
2339
2458
|
});
|
|
2340
|
-
(0,
|
|
2459
|
+
(0, import_log5.log)("connected", {
|
|
2341
2460
|
...protocol.toJSON()
|
|
2342
2461
|
}, {
|
|
2343
|
-
F:
|
|
2462
|
+
F: __dxlog_file11,
|
|
2344
2463
|
L: 116,
|
|
2345
2464
|
S: this,
|
|
2346
2465
|
C: (f, a) => f(...a)
|
|
@@ -2348,20 +2467,20 @@ var InvitationsHandler = class {
|
|
|
2348
2467
|
const deviceKey = await extension.completedTrigger.wait({
|
|
2349
2468
|
timeout: invitation.timeout
|
|
2350
2469
|
});
|
|
2351
|
-
(0,
|
|
2470
|
+
(0, import_log5.log)("admitted guest", {
|
|
2352
2471
|
guest: deviceKey,
|
|
2353
2472
|
...protocol.toJSON()
|
|
2354
2473
|
}, {
|
|
2355
|
-
F:
|
|
2474
|
+
F: __dxlog_file11,
|
|
2356
2475
|
L: 118,
|
|
2357
2476
|
S: this,
|
|
2358
2477
|
C: (f, a) => f(...a)
|
|
2359
2478
|
});
|
|
2360
|
-
guardedState.set(extension,
|
|
2361
|
-
|
|
2479
|
+
guardedState.set(extension, import_services6.Invitation.State.SUCCESS);
|
|
2480
|
+
import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.end({
|
|
2362
2481
|
id: traceId
|
|
2363
2482
|
}), {
|
|
2364
|
-
F:
|
|
2483
|
+
F: __dxlog_file11,
|
|
2365
2484
|
L: 120,
|
|
2366
2485
|
S: this,
|
|
2367
2486
|
C: (f, a) => f(...a)
|
|
@@ -2372,11 +2491,11 @@ var InvitationsHandler = class {
|
|
|
2372
2491
|
}
|
|
2373
2492
|
} catch (err) {
|
|
2374
2493
|
if (err instanceof import_async8.TimeoutError) {
|
|
2375
|
-
if (guardedState.set(extension,
|
|
2376
|
-
(0,
|
|
2494
|
+
if (guardedState.set(extension, import_services6.Invitation.State.TIMEOUT)) {
|
|
2495
|
+
(0, import_log5.log)("timeout", {
|
|
2377
2496
|
...protocol.toJSON()
|
|
2378
2497
|
}, {
|
|
2379
|
-
F:
|
|
2498
|
+
F: __dxlog_file11,
|
|
2380
2499
|
L: 129,
|
|
2381
2500
|
S: this,
|
|
2382
2501
|
C: (f, a) => f(...a)
|
|
@@ -2384,19 +2503,19 @@ var InvitationsHandler = class {
|
|
|
2384
2503
|
}
|
|
2385
2504
|
} else {
|
|
2386
2505
|
if (guardedState.error(extension, err)) {
|
|
2387
|
-
|
|
2388
|
-
F:
|
|
2506
|
+
import_log5.log.error("failed", err, {
|
|
2507
|
+
F: __dxlog_file11,
|
|
2389
2508
|
L: 133,
|
|
2390
2509
|
S: this,
|
|
2391
2510
|
C: (f, a) => f(...a)
|
|
2392
2511
|
});
|
|
2393
2512
|
}
|
|
2394
2513
|
}
|
|
2395
|
-
|
|
2514
|
+
import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.error({
|
|
2396
2515
|
id: traceId,
|
|
2397
2516
|
error: err
|
|
2398
2517
|
}), {
|
|
2399
|
-
F:
|
|
2518
|
+
F: __dxlog_file11,
|
|
2400
2519
|
L: 136,
|
|
2401
2520
|
S: this,
|
|
2402
2521
|
C: (f, a) => f(...a)
|
|
@@ -2407,10 +2526,10 @@ var InvitationsHandler = class {
|
|
|
2407
2526
|
},
|
|
2408
2527
|
onError: (err) => {
|
|
2409
2528
|
if (err instanceof import_protocols5.InvalidInvitationExtensionRoleError) {
|
|
2410
|
-
(0,
|
|
2529
|
+
(0, import_log5.log)("invalid role", {
|
|
2411
2530
|
...err.context
|
|
2412
2531
|
}, {
|
|
2413
|
-
F:
|
|
2532
|
+
F: __dxlog_file11,
|
|
2414
2533
|
L: 144,
|
|
2415
2534
|
S: this,
|
|
2416
2535
|
C: (f, a) => f(...a)
|
|
@@ -2418,11 +2537,11 @@ var InvitationsHandler = class {
|
|
|
2418
2537
|
return;
|
|
2419
2538
|
}
|
|
2420
2539
|
if (err instanceof import_async8.TimeoutError) {
|
|
2421
|
-
if (guardedState.set(extension,
|
|
2422
|
-
(0,
|
|
2540
|
+
if (guardedState.set(extension, import_services6.Invitation.State.TIMEOUT)) {
|
|
2541
|
+
(0, import_log5.log)("timeout", {
|
|
2423
2542
|
err
|
|
2424
2543
|
}, {
|
|
2425
|
-
F:
|
|
2544
|
+
F: __dxlog_file11,
|
|
2426
2545
|
L: 149,
|
|
2427
2546
|
S: this,
|
|
2428
2547
|
C: (f, a) => f(...a)
|
|
@@ -2430,8 +2549,8 @@ var InvitationsHandler = class {
|
|
|
2430
2549
|
}
|
|
2431
2550
|
} else {
|
|
2432
2551
|
if (guardedState.error(extension, err)) {
|
|
2433
|
-
|
|
2434
|
-
F:
|
|
2552
|
+
import_log5.log.error("failed", err, {
|
|
2553
|
+
F: __dxlog_file11,
|
|
2435
2554
|
L: 153,
|
|
2436
2555
|
S: this,
|
|
2437
2556
|
C: (f, a) => f(...a)
|
|
@@ -2444,8 +2563,8 @@ var InvitationsHandler = class {
|
|
|
2444
2563
|
};
|
|
2445
2564
|
if (invitation.lifetime && invitation.created) {
|
|
2446
2565
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
2447
|
-
|
|
2448
|
-
F:
|
|
2566
|
+
import_log5.log.warn("invitation has already expired", void 0, {
|
|
2567
|
+
F: __dxlog_file11,
|
|
2449
2568
|
L: 164,
|
|
2450
2569
|
S: this,
|
|
2451
2570
|
C: (f, a) => f(...a)
|
|
@@ -2453,7 +2572,7 @@ var InvitationsHandler = class {
|
|
|
2453
2572
|
} else {
|
|
2454
2573
|
(0, import_async8.scheduleTask)(ctx, async () => {
|
|
2455
2574
|
await swarmConnection.close();
|
|
2456
|
-
guardedState.set(null,
|
|
2575
|
+
guardedState.set(null, import_services6.Invitation.State.EXPIRED);
|
|
2457
2576
|
await ctx.dispose();
|
|
2458
2577
|
}, invitation.created.getTime() + invitation.lifetime * 1e3 - Date.now());
|
|
2459
2578
|
}
|
|
@@ -2461,14 +2580,14 @@ var InvitationsHandler = class {
|
|
|
2461
2580
|
let swarmConnection;
|
|
2462
2581
|
(0, import_async8.scheduleTask)(ctx, async () => {
|
|
2463
2582
|
swarmConnection = await this._joinSwarm(ctx, invitation, import_invitations2.Options.Role.HOST, createExtension);
|
|
2464
|
-
guardedState.set(null,
|
|
2583
|
+
guardedState.set(null, import_services6.Invitation.State.CONNECTING);
|
|
2465
2584
|
});
|
|
2466
2585
|
}
|
|
2467
2586
|
acceptInvitation(ctx, stream, protocol, invitation, otpEnteredTrigger, deviceProfile) {
|
|
2468
2587
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
2469
2588
|
if (deviceProfile) {
|
|
2470
|
-
(0, import_invariant6.invariant)(invitation.kind ===
|
|
2471
|
-
F:
|
|
2589
|
+
(0, import_invariant6.invariant)(invitation.kind === import_services6.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2590
|
+
F: __dxlog_file11,
|
|
2472
2591
|
L: 197,
|
|
2473
2592
|
S: this,
|
|
2474
2593
|
A: [
|
|
@@ -2477,16 +2596,16 @@ var InvitationsHandler = class {
|
|
|
2477
2596
|
]
|
|
2478
2597
|
});
|
|
2479
2598
|
}
|
|
2480
|
-
const triedPeersIds = new import_util4.ComplexSet(
|
|
2599
|
+
const triedPeersIds = new import_util4.ComplexSet(import_keys6.PublicKey.hash);
|
|
2481
2600
|
const guardedState = this._createGuardedState(ctx, invitation, stream);
|
|
2482
2601
|
const shouldCancelInvitationFlow = (extension) => {
|
|
2483
2602
|
const isLockedByAnotherConnection = guardedState.mutex.isLocked() && !extension.hasFlowLock();
|
|
2484
|
-
(0,
|
|
2603
|
+
(0, import_log5.log)("should cancel invitation flow", {
|
|
2485
2604
|
isLockedByAnotherConnection,
|
|
2486
|
-
invitationType:
|
|
2605
|
+
invitationType: import_services6.Invitation.Type.DELEGATED,
|
|
2487
2606
|
triedPeers: triedPeersIds.size
|
|
2488
2607
|
}, {
|
|
2489
|
-
F:
|
|
2608
|
+
F: __dxlog_file11,
|
|
2490
2609
|
L: 205,
|
|
2491
2610
|
S: this,
|
|
2492
2611
|
C: (f, a) => f(...a)
|
|
@@ -2494,7 +2613,7 @@ var InvitationsHandler = class {
|
|
|
2494
2613
|
if (isLockedByAnotherConnection) {
|
|
2495
2614
|
return false;
|
|
2496
2615
|
}
|
|
2497
|
-
return invitation.type !==
|
|
2616
|
+
return invitation.type !== import_services6.Invitation.Type.DELEGATED || triedPeersIds.size >= MAX_DELEGATED_INVITATION_HOST_TRIES;
|
|
2498
2617
|
};
|
|
2499
2618
|
let admitted = false;
|
|
2500
2619
|
const createExtension = () => {
|
|
@@ -2509,50 +2628,50 @@ var InvitationsHandler = class {
|
|
|
2509
2628
|
return;
|
|
2510
2629
|
}
|
|
2511
2630
|
connectionCtx.onDispose(async () => {
|
|
2512
|
-
(0,
|
|
2631
|
+
(0, import_log5.log)("extension disposed", {
|
|
2513
2632
|
admitted,
|
|
2514
2633
|
currentState: guardedState.current.state
|
|
2515
2634
|
}, {
|
|
2516
|
-
F:
|
|
2635
|
+
F: __dxlog_file11,
|
|
2517
2636
|
L: 233,
|
|
2518
2637
|
S: this,
|
|
2519
2638
|
C: (f, a) => f(...a)
|
|
2520
2639
|
});
|
|
2521
2640
|
if (!admitted) {
|
|
2522
|
-
guardedState.error(extension, new
|
|
2641
|
+
guardedState.error(extension, new import_context5.ContextDisposedError());
|
|
2523
2642
|
if (shouldCancelInvitationFlow(extension)) {
|
|
2524
2643
|
await ctx.dispose();
|
|
2525
2644
|
}
|
|
2526
2645
|
}
|
|
2527
2646
|
});
|
|
2528
2647
|
(0, import_async8.scheduleTask)(connectionCtx, async () => {
|
|
2529
|
-
const traceId =
|
|
2648
|
+
const traceId = import_keys6.PublicKey.random().toHex();
|
|
2530
2649
|
try {
|
|
2531
|
-
|
|
2650
|
+
import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.begin({
|
|
2532
2651
|
id: traceId
|
|
2533
2652
|
}), {
|
|
2534
|
-
F:
|
|
2653
|
+
F: __dxlog_file11,
|
|
2535
2654
|
L: 245,
|
|
2536
2655
|
S: this,
|
|
2537
2656
|
C: (f, a) => f(...a)
|
|
2538
2657
|
});
|
|
2539
2658
|
(0, import_async8.scheduleTask)(connectionCtx, () => {
|
|
2540
|
-
guardedState.set(extension,
|
|
2659
|
+
guardedState.set(extension, import_services6.Invitation.State.TIMEOUT);
|
|
2541
2660
|
extensionCtx.close();
|
|
2542
2661
|
}, timeout);
|
|
2543
|
-
(0,
|
|
2662
|
+
(0, import_log5.log)("connected", {
|
|
2544
2663
|
...protocol.toJSON()
|
|
2545
2664
|
}, {
|
|
2546
|
-
F:
|
|
2665
|
+
F: __dxlog_file11,
|
|
2547
2666
|
L: 256,
|
|
2548
2667
|
S: this,
|
|
2549
2668
|
C: (f, a) => f(...a)
|
|
2550
2669
|
});
|
|
2551
|
-
guardedState.set(extension,
|
|
2552
|
-
(0,
|
|
2670
|
+
guardedState.set(extension, import_services6.Invitation.State.CONNECTED);
|
|
2671
|
+
(0, import_log5.log)("introduce", {
|
|
2553
2672
|
...protocol.toJSON()
|
|
2554
2673
|
}, {
|
|
2555
|
-
F:
|
|
2674
|
+
F: __dxlog_file11,
|
|
2556
2675
|
L: 260,
|
|
2557
2676
|
S: this,
|
|
2558
2677
|
C: (f, a) => f(...a)
|
|
@@ -2561,11 +2680,11 @@ var InvitationsHandler = class {
|
|
|
2561
2680
|
invitationId: invitation.invitationId,
|
|
2562
2681
|
...protocol.createIntroduction()
|
|
2563
2682
|
});
|
|
2564
|
-
(0,
|
|
2683
|
+
(0, import_log5.log)("introduce response", {
|
|
2565
2684
|
...protocol.toJSON(),
|
|
2566
2685
|
response: introductionResponse
|
|
2567
2686
|
}, {
|
|
2568
|
-
F:
|
|
2687
|
+
F: __dxlog_file11,
|
|
2569
2688
|
L: 265,
|
|
2570
2689
|
S: this,
|
|
2571
2690
|
C: (f, a) => f(...a)
|
|
@@ -2573,20 +2692,20 @@ var InvitationsHandler = class {
|
|
|
2573
2692
|
invitation.authMethod = introductionResponse.authMethod;
|
|
2574
2693
|
if (isAuthenticationRequired(invitation)) {
|
|
2575
2694
|
switch (invitation.authMethod) {
|
|
2576
|
-
case
|
|
2695
|
+
case import_services6.Invitation.AuthMethod.SHARED_SECRET:
|
|
2577
2696
|
await this._handleGuestOtpAuth(extension, (state) => guardedState.set(extension, state), otpEnteredTrigger, {
|
|
2578
2697
|
timeout
|
|
2579
2698
|
});
|
|
2580
2699
|
break;
|
|
2581
|
-
case
|
|
2700
|
+
case import_services6.Invitation.AuthMethod.KNOWN_PUBLIC_KEY:
|
|
2582
2701
|
await this._handleGuestKpkAuth(extension, (state) => guardedState.set(extension, state), invitation, introductionResponse);
|
|
2583
2702
|
break;
|
|
2584
2703
|
}
|
|
2585
2704
|
}
|
|
2586
|
-
(0,
|
|
2705
|
+
(0, import_log5.log)("request admission", {
|
|
2587
2706
|
...protocol.toJSON()
|
|
2588
2707
|
}, {
|
|
2589
|
-
F:
|
|
2708
|
+
F: __dxlog_file11,
|
|
2590
2709
|
L: 291,
|
|
2591
2710
|
S: this,
|
|
2592
2711
|
C: (f, a) => f(...a)
|
|
@@ -2595,10 +2714,10 @@ var InvitationsHandler = class {
|
|
|
2595
2714
|
const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
|
|
2596
2715
|
admitted = true;
|
|
2597
2716
|
const result = await protocol.accept(admissionResponse, admissionRequest);
|
|
2598
|
-
(0,
|
|
2717
|
+
(0, import_log5.log)("admitted by host", {
|
|
2599
2718
|
...protocol.toJSON()
|
|
2600
2719
|
}, {
|
|
2601
|
-
F:
|
|
2720
|
+
F: __dxlog_file11,
|
|
2602
2721
|
L: 302,
|
|
2603
2722
|
S: this,
|
|
2604
2723
|
C: (f, a) => f(...a)
|
|
@@ -2606,30 +2725,30 @@ var InvitationsHandler = class {
|
|
|
2606
2725
|
await guardedState.complete({
|
|
2607
2726
|
...guardedState.current,
|
|
2608
2727
|
...result,
|
|
2609
|
-
state:
|
|
2728
|
+
state: import_services6.Invitation.State.SUCCESS
|
|
2610
2729
|
});
|
|
2611
|
-
|
|
2730
|
+
import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.end({
|
|
2612
2731
|
id: traceId
|
|
2613
2732
|
}), {
|
|
2614
|
-
F:
|
|
2733
|
+
F: __dxlog_file11,
|
|
2615
2734
|
L: 308,
|
|
2616
2735
|
S: this,
|
|
2617
2736
|
C: (f, a) => f(...a)
|
|
2618
2737
|
});
|
|
2619
2738
|
} catch (err) {
|
|
2620
2739
|
if (err instanceof import_async8.TimeoutError) {
|
|
2621
|
-
(0,
|
|
2740
|
+
(0, import_log5.log)("timeout", {
|
|
2622
2741
|
...protocol.toJSON()
|
|
2623
2742
|
}, {
|
|
2624
|
-
F:
|
|
2743
|
+
F: __dxlog_file11,
|
|
2625
2744
|
L: 311,
|
|
2626
2745
|
S: this,
|
|
2627
2746
|
C: (f, a) => f(...a)
|
|
2628
2747
|
});
|
|
2629
|
-
guardedState.set(extension,
|
|
2748
|
+
guardedState.set(extension, import_services6.Invitation.State.TIMEOUT);
|
|
2630
2749
|
} else {
|
|
2631
|
-
(0,
|
|
2632
|
-
F:
|
|
2750
|
+
(0, import_log5.log)("auth failed", err, {
|
|
2751
|
+
F: __dxlog_file11,
|
|
2633
2752
|
L: 314,
|
|
2634
2753
|
S: this,
|
|
2635
2754
|
C: (f, a) => f(...a)
|
|
@@ -2637,11 +2756,11 @@ var InvitationsHandler = class {
|
|
|
2637
2756
|
guardedState.error(extension, err);
|
|
2638
2757
|
}
|
|
2639
2758
|
extensionCtx.close(err);
|
|
2640
|
-
|
|
2759
|
+
import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.error({
|
|
2641
2760
|
id: traceId,
|
|
2642
2761
|
error: err
|
|
2643
2762
|
}), {
|
|
2644
|
-
F:
|
|
2763
|
+
F: __dxlog_file11,
|
|
2645
2764
|
L: 318,
|
|
2646
2765
|
S: this,
|
|
2647
2766
|
C: (f, a) => f(...a)
|
|
@@ -2654,18 +2773,18 @@ var InvitationsHandler = class {
|
|
|
2654
2773
|
return;
|
|
2655
2774
|
}
|
|
2656
2775
|
if (err instanceof import_async8.TimeoutError) {
|
|
2657
|
-
(0,
|
|
2776
|
+
(0, import_log5.log)("timeout", {
|
|
2658
2777
|
...protocol.toJSON()
|
|
2659
2778
|
}, {
|
|
2660
|
-
F:
|
|
2779
|
+
F: __dxlog_file11,
|
|
2661
2780
|
L: 327,
|
|
2662
2781
|
S: this,
|
|
2663
2782
|
C: (f, a) => f(...a)
|
|
2664
2783
|
});
|
|
2665
|
-
guardedState.set(extension,
|
|
2784
|
+
guardedState.set(extension, import_services6.Invitation.State.TIMEOUT);
|
|
2666
2785
|
} else {
|
|
2667
|
-
(0,
|
|
2668
|
-
F:
|
|
2786
|
+
(0, import_log5.log)("auth failed", err, {
|
|
2787
|
+
F: __dxlog_file11,
|
|
2669
2788
|
L: 330,
|
|
2670
2789
|
S: this,
|
|
2671
2790
|
C: (f, a) => f(...a)
|
|
@@ -2683,7 +2802,7 @@ var InvitationsHandler = class {
|
|
|
2683
2802
|
await ctx.dispose();
|
|
2684
2803
|
} else {
|
|
2685
2804
|
(0, import_invariant6.invariant)(invitation.swarmKey, void 0, {
|
|
2686
|
-
F:
|
|
2805
|
+
F: __dxlog_file11,
|
|
2687
2806
|
L: 345,
|
|
2688
2807
|
S: this,
|
|
2689
2808
|
A: [
|
|
@@ -2692,7 +2811,7 @@ var InvitationsHandler = class {
|
|
|
2692
2811
|
]
|
|
2693
2812
|
});
|
|
2694
2813
|
await this._joinSwarm(ctx, invitation, import_invitations2.Options.Role.GUEST, createExtension);
|
|
2695
|
-
guardedState.set(null,
|
|
2814
|
+
guardedState.set(null, import_services6.Invitation.State.CONNECTING);
|
|
2696
2815
|
}
|
|
2697
2816
|
});
|
|
2698
2817
|
}
|
|
@@ -2700,14 +2819,14 @@ var InvitationsHandler = class {
|
|
|
2700
2819
|
let label;
|
|
2701
2820
|
if (role === import_invitations2.Options.Role.GUEST) {
|
|
2702
2821
|
label = "invitation guest";
|
|
2703
|
-
} else if (invitation.kind ===
|
|
2822
|
+
} else if (invitation.kind === import_services6.Invitation.Kind.DEVICE) {
|
|
2704
2823
|
label = "invitation host for device";
|
|
2705
2824
|
} else {
|
|
2706
2825
|
label = `invitation host for space ${invitation.spaceKey?.truncate()}`;
|
|
2707
2826
|
}
|
|
2708
2827
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
2709
2828
|
topic: invitation.swarmKey,
|
|
2710
|
-
peerId:
|
|
2829
|
+
peerId: import_keys6.PublicKey.random(),
|
|
2711
2830
|
protocolProvider: (0, import_network_manager.createTeleportProtocolFactory)(async (teleport) => {
|
|
2712
2831
|
teleport.addExtension("dxos.halo.invitations", extensionFactory());
|
|
2713
2832
|
}, this._defaultTeleportParams),
|
|
@@ -2762,10 +2881,10 @@ var InvitationsHandler = class {
|
|
|
2762
2881
|
},
|
|
2763
2882
|
error: (extension, error) => {
|
|
2764
2883
|
if (isStateChangeAllowed(extension)) {
|
|
2765
|
-
this._logStateUpdate(currentInvitation, extension,
|
|
2884
|
+
this._logStateUpdate(currentInvitation, extension, import_services6.Invitation.State.ERROR);
|
|
2766
2885
|
currentInvitation = {
|
|
2767
2886
|
...currentInvitation,
|
|
2768
|
-
state:
|
|
2887
|
+
state: import_services6.Invitation.State.ERROR
|
|
2769
2888
|
};
|
|
2770
2889
|
stream.next(currentInvitation);
|
|
2771
2890
|
stream.error(error);
|
|
@@ -2777,12 +2896,12 @@ var InvitationsHandler = class {
|
|
|
2777
2896
|
};
|
|
2778
2897
|
}
|
|
2779
2898
|
_logStateUpdate(invitation, actor, newState) {
|
|
2780
|
-
(0,
|
|
2899
|
+
(0, import_log5.log)("invitation state update", {
|
|
2781
2900
|
actor: actor?.constructor.name,
|
|
2782
2901
|
newState: stateToString(newState),
|
|
2783
2902
|
oldState: stateToString(invitation.state)
|
|
2784
2903
|
}, {
|
|
2785
|
-
F:
|
|
2904
|
+
F: __dxlog_file11,
|
|
2786
2905
|
L: 438,
|
|
2787
2906
|
S: this,
|
|
2788
2907
|
C: (f, a) => f(...a)
|
|
@@ -2790,30 +2909,30 @@ var InvitationsHandler = class {
|
|
|
2790
2909
|
}
|
|
2791
2910
|
_isNotTerminal(currentState) {
|
|
2792
2911
|
return ![
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2912
|
+
import_services6.Invitation.State.SUCCESS,
|
|
2913
|
+
import_services6.Invitation.State.ERROR,
|
|
2914
|
+
import_services6.Invitation.State.CANCELLED,
|
|
2915
|
+
import_services6.Invitation.State.TIMEOUT,
|
|
2916
|
+
import_services6.Invitation.State.EXPIRED
|
|
2798
2917
|
].includes(currentState);
|
|
2799
2918
|
}
|
|
2800
2919
|
async _handleGuestOtpAuth(extension, setState, authenticated, options) {
|
|
2801
2920
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2802
|
-
(0,
|
|
2803
|
-
F:
|
|
2921
|
+
(0, import_log5.log)("guest waiting for authentication code...", void 0, {
|
|
2922
|
+
F: __dxlog_file11,
|
|
2804
2923
|
L: 462,
|
|
2805
2924
|
S: this,
|
|
2806
2925
|
C: (f, a) => f(...a)
|
|
2807
2926
|
});
|
|
2808
|
-
setState(
|
|
2927
|
+
setState(import_services6.Invitation.State.READY_FOR_AUTHENTICATION);
|
|
2809
2928
|
const authCode = await authenticated.wait(options);
|
|
2810
|
-
(0,
|
|
2811
|
-
F:
|
|
2929
|
+
(0, import_log5.log)("sending authentication request", void 0, {
|
|
2930
|
+
F: __dxlog_file11,
|
|
2812
2931
|
L: 466,
|
|
2813
2932
|
S: this,
|
|
2814
2933
|
C: (f, a) => f(...a)
|
|
2815
2934
|
});
|
|
2816
|
-
setState(
|
|
2935
|
+
setState(import_services6.Invitation.State.AUTHENTICATING);
|
|
2817
2936
|
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2818
2937
|
authCode
|
|
2819
2938
|
});
|
|
@@ -2824,10 +2943,10 @@ var InvitationsHandler = class {
|
|
|
2824
2943
|
if (attempt === MAX_OTP_ATTEMPTS) {
|
|
2825
2944
|
throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
|
|
2826
2945
|
} else {
|
|
2827
|
-
(0,
|
|
2946
|
+
(0, import_log5.log)("retrying invalid code", {
|
|
2828
2947
|
attempt
|
|
2829
2948
|
}, {
|
|
2830
|
-
F:
|
|
2949
|
+
F: __dxlog_file11,
|
|
2831
2950
|
L: 477,
|
|
2832
2951
|
S: this,
|
|
2833
2952
|
C: (f, a) => f(...a)
|
|
@@ -2844,13 +2963,13 @@ var InvitationsHandler = class {
|
|
|
2844
2963
|
if (introductionResponse.challenge == null) {
|
|
2845
2964
|
throw new Error("challenge missing in the introduction");
|
|
2846
2965
|
}
|
|
2847
|
-
(0,
|
|
2848
|
-
F:
|
|
2966
|
+
(0, import_log5.log)("sending authentication request", void 0, {
|
|
2967
|
+
F: __dxlog_file11,
|
|
2849
2968
|
L: 496,
|
|
2850
2969
|
S: this,
|
|
2851
2970
|
C: (f, a) => f(...a)
|
|
2852
2971
|
});
|
|
2853
|
-
setState(
|
|
2972
|
+
setState(import_services6.Invitation.State.AUTHENTICATING);
|
|
2854
2973
|
const signature = (0, import_crypto.sign)(Buffer.from(introductionResponse.challenge), invitation.guestKeypair.privateKey);
|
|
2855
2974
|
const response = await extension.rpc.InvitationHostService.authenticate({
|
|
2856
2975
|
signedChallenge: signature
|
|
@@ -2863,7 +2982,7 @@ var InvitationsHandler = class {
|
|
|
2863
2982
|
var createAdmissionKeypair = () => {
|
|
2864
2983
|
const keypair = (0, import_crypto.createKeyPair)();
|
|
2865
2984
|
return {
|
|
2866
|
-
publicKey:
|
|
2985
|
+
publicKey: import_keys6.PublicKey.from(keypair.publicKey),
|
|
2867
2986
|
privateKey: keypair.secretKey
|
|
2868
2987
|
};
|
|
2869
2988
|
};
|
|
@@ -2896,8 +3015,8 @@ var InvitationsServiceImpl = class {
|
|
|
2896
3015
|
return new import_codec_protobuf10.Stream(({ next, ctx }) => {
|
|
2897
3016
|
this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
|
|
2898
3017
|
next({
|
|
2899
|
-
action:
|
|
2900
|
-
type:
|
|
3018
|
+
action: import_services9.QueryInvitationsResponse.Action.ADDED,
|
|
3019
|
+
type: import_services9.QueryInvitationsResponse.Type.CREATED,
|
|
2901
3020
|
invitations: [
|
|
2902
3021
|
invitation
|
|
2903
3022
|
]
|
|
@@ -2905,8 +3024,8 @@ var InvitationsServiceImpl = class {
|
|
|
2905
3024
|
});
|
|
2906
3025
|
this._invitationsManager.invitationAccepted.on(ctx, (invitation) => {
|
|
2907
3026
|
next({
|
|
2908
|
-
action:
|
|
2909
|
-
type:
|
|
3027
|
+
action: import_services9.QueryInvitationsResponse.Action.ADDED,
|
|
3028
|
+
type: import_services9.QueryInvitationsResponse.Type.ACCEPTED,
|
|
2910
3029
|
invitations: [
|
|
2911
3030
|
invitation
|
|
2912
3031
|
]
|
|
@@ -2914,8 +3033,8 @@ var InvitationsServiceImpl = class {
|
|
|
2914
3033
|
});
|
|
2915
3034
|
this._invitationsManager.removedCreated.on(ctx, (invitation) => {
|
|
2916
3035
|
next({
|
|
2917
|
-
action:
|
|
2918
|
-
type:
|
|
3036
|
+
action: import_services9.QueryInvitationsResponse.Action.REMOVED,
|
|
3037
|
+
type: import_services9.QueryInvitationsResponse.Type.CREATED,
|
|
2919
3038
|
invitations: [
|
|
2920
3039
|
invitation
|
|
2921
3040
|
]
|
|
@@ -2923,8 +3042,8 @@ var InvitationsServiceImpl = class {
|
|
|
2923
3042
|
});
|
|
2924
3043
|
this._invitationsManager.removedAccepted.on(ctx, (invitation) => {
|
|
2925
3044
|
next({
|
|
2926
|
-
action:
|
|
2927
|
-
type:
|
|
3045
|
+
action: import_services9.QueryInvitationsResponse.Action.REMOVED,
|
|
3046
|
+
type: import_services9.QueryInvitationsResponse.Type.ACCEPTED,
|
|
2928
3047
|
invitations: [
|
|
2929
3048
|
invitation
|
|
2930
3049
|
]
|
|
@@ -2932,35 +3051,35 @@ var InvitationsServiceImpl = class {
|
|
|
2932
3051
|
});
|
|
2933
3052
|
this._invitationsManager.saved.on(ctx, (invitation) => {
|
|
2934
3053
|
next({
|
|
2935
|
-
action:
|
|
2936
|
-
type:
|
|
3054
|
+
action: import_services9.QueryInvitationsResponse.Action.SAVED,
|
|
3055
|
+
type: import_services9.QueryInvitationsResponse.Type.CREATED,
|
|
2937
3056
|
invitations: [
|
|
2938
3057
|
invitation
|
|
2939
3058
|
]
|
|
2940
3059
|
});
|
|
2941
3060
|
});
|
|
2942
3061
|
next({
|
|
2943
|
-
action:
|
|
2944
|
-
type:
|
|
3062
|
+
action: import_services9.QueryInvitationsResponse.Action.ADDED,
|
|
3063
|
+
type: import_services9.QueryInvitationsResponse.Type.CREATED,
|
|
2945
3064
|
invitations: this._invitationsManager.getCreatedInvitations(),
|
|
2946
3065
|
existing: true
|
|
2947
3066
|
});
|
|
2948
3067
|
next({
|
|
2949
|
-
action:
|
|
2950
|
-
type:
|
|
3068
|
+
action: import_services9.QueryInvitationsResponse.Action.ADDED,
|
|
3069
|
+
type: import_services9.QueryInvitationsResponse.Type.ACCEPTED,
|
|
2951
3070
|
invitations: this._invitationsManager.getAcceptedInvitations(),
|
|
2952
3071
|
existing: true
|
|
2953
3072
|
});
|
|
2954
3073
|
this._invitationsManager.onPersistentInvitationsLoaded(ctx, () => {
|
|
2955
3074
|
next({
|
|
2956
|
-
action:
|
|
2957
|
-
type:
|
|
3075
|
+
action: import_services9.QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
3076
|
+
type: import_services9.QueryInvitationsResponse.Type.CREATED
|
|
2958
3077
|
});
|
|
2959
3078
|
});
|
|
2960
3079
|
});
|
|
2961
3080
|
}
|
|
2962
3081
|
};
|
|
2963
|
-
var
|
|
3082
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2964
3083
|
var SpaceInvitationProtocol = class {
|
|
2965
3084
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
2966
3085
|
this._spaceManager = _spaceManager;
|
|
@@ -2989,13 +3108,13 @@ var SpaceInvitationProtocol = class {
|
|
|
2989
3108
|
}
|
|
2990
3109
|
getInvitationContext() {
|
|
2991
3110
|
return {
|
|
2992
|
-
kind:
|
|
3111
|
+
kind: import_services10.Invitation.Kind.SPACE,
|
|
2993
3112
|
spaceKey: this._spaceKey
|
|
2994
3113
|
};
|
|
2995
3114
|
}
|
|
2996
3115
|
async admit(invitation, request, guestProfile) {
|
|
2997
3116
|
(0, import_invariant10.invariant)(this._spaceKey, void 0, {
|
|
2998
|
-
F:
|
|
3117
|
+
F: __dxlog_file12,
|
|
2999
3118
|
L: 76,
|
|
3000
3119
|
S: this,
|
|
3001
3120
|
A: [
|
|
@@ -3005,7 +3124,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3005
3124
|
});
|
|
3006
3125
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
3007
3126
|
(0, import_invariant10.invariant)(space, void 0, {
|
|
3008
|
-
F:
|
|
3127
|
+
F: __dxlog_file12,
|
|
3009
3128
|
L: 78,
|
|
3010
3129
|
S: this,
|
|
3011
3130
|
A: [
|
|
@@ -3014,7 +3133,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3014
3133
|
]
|
|
3015
3134
|
});
|
|
3016
3135
|
(0, import_invariant10.invariant)(request.space, void 0, {
|
|
3017
|
-
F:
|
|
3136
|
+
F: __dxlog_file12,
|
|
3018
3137
|
L: 80,
|
|
3019
3138
|
S: this,
|
|
3020
3139
|
A: [
|
|
@@ -3023,21 +3142,21 @@ var SpaceInvitationProtocol = class {
|
|
|
3023
3142
|
]
|
|
3024
3143
|
});
|
|
3025
3144
|
const { identityKey, deviceKey } = request.space;
|
|
3026
|
-
if (space.inner.spaceState.getMemberRole(identityKey) !==
|
|
3145
|
+
if (space.inner.spaceState.getMemberRole(identityKey) !== import_credentials10.SpaceMember.Role.REMOVED) {
|
|
3027
3146
|
throw new import_protocols8.AlreadyJoinedError();
|
|
3028
3147
|
}
|
|
3029
|
-
(0,
|
|
3148
|
+
(0, import_log9.log)("writing guest credentials", {
|
|
3030
3149
|
host: this._signingContext.deviceKey,
|
|
3031
3150
|
guest: deviceKey
|
|
3032
3151
|
}, {
|
|
3033
|
-
F:
|
|
3152
|
+
F: __dxlog_file12,
|
|
3034
3153
|
L: 87,
|
|
3035
3154
|
S: this,
|
|
3036
3155
|
C: (f, a) => f(...a)
|
|
3037
3156
|
});
|
|
3038
|
-
const credentials = await (0,
|
|
3157
|
+
const credentials = await (0, import_credentials9.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, invitation.role ?? import_credentials10.SpaceMember.Role.ADMIN, space.inner.spaceState.membershipChainHeads, guestProfile, invitation.delegationCredentialId);
|
|
3039
3158
|
(0, import_invariant10.invariant)(credentials[0].credential, void 0, {
|
|
3040
|
-
F:
|
|
3159
|
+
F: __dxlog_file12,
|
|
3041
3160
|
L: 101,
|
|
3042
3161
|
S: this,
|
|
3043
3162
|
A: [
|
|
@@ -3046,8 +3165,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3046
3165
|
]
|
|
3047
3166
|
});
|
|
3048
3167
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
3049
|
-
(0, import_invariant10.invariant)((0,
|
|
3050
|
-
F:
|
|
3168
|
+
(0, import_invariant10.invariant)((0, import_credentials9.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3169
|
+
F: __dxlog_file12,
|
|
3051
3170
|
L: 103,
|
|
3052
3171
|
S: this,
|
|
3053
3172
|
A: [
|
|
@@ -3065,7 +3184,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3065
3184
|
}
|
|
3066
3185
|
async delegate(invitation) {
|
|
3067
3186
|
(0, import_invariant10.invariant)(this._spaceKey, void 0, {
|
|
3068
|
-
F:
|
|
3187
|
+
F: __dxlog_file12,
|
|
3069
3188
|
L: 116,
|
|
3070
3189
|
S: this,
|
|
3071
3190
|
A: [
|
|
@@ -3075,7 +3194,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3075
3194
|
});
|
|
3076
3195
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
3077
3196
|
(0, import_invariant10.invariant)(space, void 0, {
|
|
3078
|
-
F:
|
|
3197
|
+
F: __dxlog_file12,
|
|
3079
3198
|
L: 118,
|
|
3080
3199
|
S: this,
|
|
3081
3200
|
A: [
|
|
@@ -3083,9 +3202,9 @@ var SpaceInvitationProtocol = class {
|
|
|
3083
3202
|
""
|
|
3084
3203
|
]
|
|
3085
3204
|
});
|
|
3086
|
-
if (invitation.authMethod ===
|
|
3205
|
+
if (invitation.authMethod === import_services10.Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
3087
3206
|
(0, import_invariant10.invariant)(invitation.guestKeypair?.publicKey, void 0, {
|
|
3088
|
-
F:
|
|
3207
|
+
F: __dxlog_file12,
|
|
3089
3208
|
L: 120,
|
|
3090
3209
|
S: this,
|
|
3091
3210
|
A: [
|
|
@@ -3094,26 +3213,26 @@ var SpaceInvitationProtocol = class {
|
|
|
3094
3213
|
]
|
|
3095
3214
|
});
|
|
3096
3215
|
}
|
|
3097
|
-
(0,
|
|
3216
|
+
(0, import_log9.log)("writing delegate space invitation", {
|
|
3098
3217
|
host: this._signingContext.deviceKey,
|
|
3099
3218
|
id: invitation.invitationId
|
|
3100
3219
|
}, {
|
|
3101
|
-
F:
|
|
3220
|
+
F: __dxlog_file12,
|
|
3102
3221
|
L: 123,
|
|
3103
3222
|
S: this,
|
|
3104
3223
|
C: (f, a) => f(...a)
|
|
3105
3224
|
});
|
|
3106
|
-
const credential = await (0,
|
|
3225
|
+
const credential = await (0, import_credentials9.createDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, {
|
|
3107
3226
|
invitationId: invitation.invitationId,
|
|
3108
3227
|
authMethod: invitation.authMethod,
|
|
3109
3228
|
swarmKey: invitation.swarmKey,
|
|
3110
|
-
role: invitation.role ??
|
|
3229
|
+
role: invitation.role ?? import_credentials10.SpaceMember.Role.ADMIN,
|
|
3111
3230
|
expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
|
|
3112
3231
|
multiUse: invitation.multiUse ?? false,
|
|
3113
|
-
guestKey: invitation.authMethod ===
|
|
3232
|
+
guestKey: invitation.authMethod === import_services10.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
|
|
3114
3233
|
});
|
|
3115
3234
|
(0, import_invariant10.invariant)(credential.credential, void 0, {
|
|
3116
|
-
F:
|
|
3235
|
+
F: __dxlog_file12,
|
|
3117
3236
|
L: 143,
|
|
3118
3237
|
S: this,
|
|
3119
3238
|
A: [
|
|
@@ -3128,7 +3247,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3128
3247
|
}
|
|
3129
3248
|
async cancelDelegation(invitation) {
|
|
3130
3249
|
(0, import_invariant10.invariant)(this._spaceKey, void 0, {
|
|
3131
|
-
F:
|
|
3250
|
+
F: __dxlog_file12,
|
|
3132
3251
|
L: 149,
|
|
3133
3252
|
S: this,
|
|
3134
3253
|
A: [
|
|
@@ -3136,8 +3255,8 @@ var SpaceInvitationProtocol = class {
|
|
|
3136
3255
|
""
|
|
3137
3256
|
]
|
|
3138
3257
|
});
|
|
3139
|
-
(0, import_invariant10.invariant)(invitation.type ===
|
|
3140
|
-
F:
|
|
3258
|
+
(0, import_invariant10.invariant)(invitation.type === import_services10.Invitation.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
|
|
3259
|
+
F: __dxlog_file12,
|
|
3141
3260
|
L: 150,
|
|
3142
3261
|
S: this,
|
|
3143
3262
|
A: [
|
|
@@ -3147,7 +3266,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3147
3266
|
});
|
|
3148
3267
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
3149
3268
|
(0, import_invariant10.invariant)(space, void 0, {
|
|
3150
|
-
F:
|
|
3269
|
+
F: __dxlog_file12,
|
|
3151
3270
|
L: 152,
|
|
3152
3271
|
S: this,
|
|
3153
3272
|
A: [
|
|
@@ -3155,18 +3274,18 @@ var SpaceInvitationProtocol = class {
|
|
|
3155
3274
|
""
|
|
3156
3275
|
]
|
|
3157
3276
|
});
|
|
3158
|
-
(0,
|
|
3277
|
+
(0, import_log9.log)("cancelling delegated space invitation", {
|
|
3159
3278
|
host: this._signingContext.deviceKey,
|
|
3160
3279
|
id: invitation.invitationId
|
|
3161
3280
|
}, {
|
|
3162
|
-
F:
|
|
3281
|
+
F: __dxlog_file12,
|
|
3163
3282
|
L: 154,
|
|
3164
3283
|
S: this,
|
|
3165
3284
|
C: (f, a) => f(...a)
|
|
3166
3285
|
});
|
|
3167
|
-
const credential = await (0,
|
|
3286
|
+
const credential = await (0, import_credentials9.createCancelDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
|
|
3168
3287
|
(0, import_invariant10.invariant)(credential.credential, void 0, {
|
|
3169
|
-
F:
|
|
3288
|
+
F: __dxlog_file12,
|
|
3170
3289
|
L: 161,
|
|
3171
3290
|
S: this,
|
|
3172
3291
|
A: [
|
|
@@ -3205,7 +3324,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3205
3324
|
}
|
|
3206
3325
|
async accept(response) {
|
|
3207
3326
|
(0, import_invariant10.invariant)(response.space, void 0, {
|
|
3208
|
-
F:
|
|
3327
|
+
F: __dxlog_file12,
|
|
3209
3328
|
L: 196,
|
|
3210
3329
|
S: this,
|
|
3211
3330
|
A: [
|
|
@@ -3214,9 +3333,9 @@ var SpaceInvitationProtocol = class {
|
|
|
3214
3333
|
]
|
|
3215
3334
|
});
|
|
3216
3335
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
3217
|
-
const assertion = (0,
|
|
3336
|
+
const assertion = (0, import_credentials9.getCredentialAssertion)(credential);
|
|
3218
3337
|
(0, import_invariant10.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
3219
|
-
F:
|
|
3338
|
+
F: __dxlog_file12,
|
|
3220
3339
|
L: 199,
|
|
3221
3340
|
S: this,
|
|
3222
3341
|
A: [
|
|
@@ -3225,7 +3344,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3225
3344
|
]
|
|
3226
3345
|
});
|
|
3227
3346
|
(0, import_invariant10.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
3228
|
-
F:
|
|
3347
|
+
F: __dxlog_file12,
|
|
3229
3348
|
L: 200,
|
|
3230
3349
|
S: this,
|
|
3231
3350
|
A: [
|
|
@@ -3248,7 +3367,7 @@ var SpaceInvitationProtocol = class {
|
|
|
3248
3367
|
};
|
|
3249
3368
|
}
|
|
3250
3369
|
};
|
|
3251
|
-
var
|
|
3370
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
3252
3371
|
var InvitationsManager = class {
|
|
3253
3372
|
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
3254
3373
|
this._invitationsHandler = _invitationsHandler;
|
|
@@ -3290,8 +3409,8 @@ var InvitationsManager = class {
|
|
|
3290
3409
|
try {
|
|
3291
3410
|
await this._persistIfRequired(handler, stream, invitation);
|
|
3292
3411
|
} catch (err) {
|
|
3293
|
-
|
|
3294
|
-
F:
|
|
3412
|
+
import_log10.log.catch(err, void 0, {
|
|
3413
|
+
F: __dxlog_file13,
|
|
3295
3414
|
L: 82,
|
|
3296
3415
|
S: this,
|
|
3297
3416
|
C: (f, a) => f(...a)
|
|
@@ -3314,7 +3433,7 @@ var InvitationsManager = class {
|
|
|
3314
3433
|
const freshInvitations = persistentInvitations.filter((invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
|
|
3315
3434
|
const loadTasks = freshInvitations.map((persistentInvitation) => {
|
|
3316
3435
|
(0, import_invariant11.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
3317
|
-
F:
|
|
3436
|
+
F: __dxlog_file13,
|
|
3318
3437
|
L: 103,
|
|
3319
3438
|
S: this,
|
|
3320
3439
|
A: [
|
|
@@ -3332,8 +3451,8 @@ var InvitationsManager = class {
|
|
|
3332
3451
|
invitations: cInvitations.map((invitation) => invitation.get())
|
|
3333
3452
|
};
|
|
3334
3453
|
} catch (err) {
|
|
3335
|
-
|
|
3336
|
-
F:
|
|
3454
|
+
import_log10.log.catch(err, void 0, {
|
|
3455
|
+
F: __dxlog_file13,
|
|
3337
3456
|
L: 110,
|
|
3338
3457
|
S: this,
|
|
3339
3458
|
C: (f, a) => f(...a)
|
|
@@ -3364,14 +3483,14 @@ var InvitationsManager = class {
|
|
|
3364
3483
|
return invitation;
|
|
3365
3484
|
}
|
|
3366
3485
|
async authenticate({ invitationId, authCode }) {
|
|
3367
|
-
(0,
|
|
3368
|
-
F:
|
|
3486
|
+
(0, import_log10.log)("authenticating...", void 0, {
|
|
3487
|
+
F: __dxlog_file13,
|
|
3369
3488
|
L: 140,
|
|
3370
3489
|
S: this,
|
|
3371
3490
|
C: (f, a) => f(...a)
|
|
3372
3491
|
});
|
|
3373
3492
|
(0, import_invariant11.invariant)(invitationId, void 0, {
|
|
3374
|
-
F:
|
|
3493
|
+
F: __dxlog_file13,
|
|
3375
3494
|
L: 141,
|
|
3376
3495
|
S: this,
|
|
3377
3496
|
A: [
|
|
@@ -3381,10 +3500,10 @@ var InvitationsManager = class {
|
|
|
3381
3500
|
});
|
|
3382
3501
|
const observable = this._acceptInvitations.get(invitationId);
|
|
3383
3502
|
if (!observable) {
|
|
3384
|
-
|
|
3503
|
+
import_log10.log.warn("invalid invitation", {
|
|
3385
3504
|
invitationId
|
|
3386
3505
|
}, {
|
|
3387
|
-
F:
|
|
3506
|
+
F: __dxlog_file13,
|
|
3388
3507
|
L: 144,
|
|
3389
3508
|
S: this,
|
|
3390
3509
|
C: (f, a) => f(...a)
|
|
@@ -3394,16 +3513,16 @@ var InvitationsManager = class {
|
|
|
3394
3513
|
}
|
|
3395
3514
|
}
|
|
3396
3515
|
async cancelInvitation({ invitationId }) {
|
|
3397
|
-
(0,
|
|
3516
|
+
(0, import_log10.log)("cancelInvitation...", {
|
|
3398
3517
|
invitationId
|
|
3399
3518
|
}, {
|
|
3400
|
-
F:
|
|
3519
|
+
F: __dxlog_file13,
|
|
3401
3520
|
L: 151,
|
|
3402
3521
|
S: this,
|
|
3403
3522
|
C: (f, a) => f(...a)
|
|
3404
3523
|
});
|
|
3405
3524
|
(0, import_invariant11.invariant)(invitationId, void 0, {
|
|
3406
|
-
F:
|
|
3525
|
+
F: __dxlog_file13,
|
|
3407
3526
|
L: 152,
|
|
3408
3527
|
S: this,
|
|
3409
3528
|
A: [
|
|
@@ -3416,7 +3535,7 @@ var InvitationsManager = class {
|
|
|
3416
3535
|
if (created.get().persistent) {
|
|
3417
3536
|
await this._metadataStore.removeInvitation(invitationId);
|
|
3418
3537
|
}
|
|
3419
|
-
if (created.get().type ===
|
|
3538
|
+
if (created.get().type === import_services11.Invitation.Type.DELEGATED) {
|
|
3420
3539
|
const handler = this._getHandler(created.get());
|
|
3421
3540
|
await handler.cancelDelegation(created.get());
|
|
3422
3541
|
}
|
|
@@ -3450,8 +3569,8 @@ var InvitationsManager = class {
|
|
|
3450
3569
|
}
|
|
3451
3570
|
}
|
|
3452
3571
|
_createInvitation(protocol, options) {
|
|
3453
|
-
const { invitationId =
|
|
3454
|
-
const authCode = options?.authCode ?? (authMethod ===
|
|
3572
|
+
const { invitationId = import_keys9.PublicKey.random().toHex(), type = import_services11.Invitation.Type.INTERACTIVE, authMethod = import_services11.Invitation.AuthMethod.SHARED_SECRET, state = import_services11.Invitation.State.INIT, timeout = import_client_protocol3.INVITATION_TIMEOUT, swarmKey = import_keys9.PublicKey.random(), persistent = options?.authMethod !== import_services11.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, role = import_credentials12.SpaceMember.Role.ADMIN, lifetime = 86400, multiUse = false } = options ?? {};
|
|
3573
|
+
const authCode = options?.authCode ?? (authMethod === import_services11.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials11.generatePasscode)(import_client_protocol3.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
3455
3574
|
return {
|
|
3456
3575
|
invitationId,
|
|
3457
3576
|
type,
|
|
@@ -3460,8 +3579,8 @@ var InvitationsManager = class {
|
|
|
3460
3579
|
swarmKey,
|
|
3461
3580
|
authCode,
|
|
3462
3581
|
timeout,
|
|
3463
|
-
persistent: persistent && type !==
|
|
3464
|
-
guestKeypair: guestKeypair ?? (authMethod ===
|
|
3582
|
+
persistent: persistent && type !== import_services11.Invitation.Type.DELEGATED,
|
|
3583
|
+
guestKeypair: guestKeypair ?? (authMethod === import_services11.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
|
|
3465
3584
|
created,
|
|
3466
3585
|
lifetime,
|
|
3467
3586
|
role,
|
|
@@ -3472,17 +3591,17 @@ var InvitationsManager = class {
|
|
|
3472
3591
|
}
|
|
3473
3592
|
_createObservableInvitation(handler, invitation) {
|
|
3474
3593
|
const stream = new import_async11.PushStream();
|
|
3475
|
-
const ctx = new
|
|
3594
|
+
const ctx = new import_context9.Context({
|
|
3476
3595
|
onError: (err) => {
|
|
3477
3596
|
stream.error(err);
|
|
3478
3597
|
void ctx.dispose();
|
|
3479
3598
|
}
|
|
3480
3599
|
});
|
|
3481
3600
|
ctx.onDispose(() => {
|
|
3482
|
-
(0,
|
|
3601
|
+
(0, import_log10.log)("complete", {
|
|
3483
3602
|
...handler.toJSON()
|
|
3484
3603
|
}, {
|
|
3485
|
-
F:
|
|
3604
|
+
F: __dxlog_file13,
|
|
3486
3605
|
L: 241,
|
|
3487
3606
|
S: this,
|
|
3488
3607
|
C: (f, a) => f(...a)
|
|
@@ -3495,7 +3614,7 @@ var InvitationsManager = class {
|
|
|
3495
3614
|
onCancel: async () => {
|
|
3496
3615
|
stream.next({
|
|
3497
3616
|
...invitation,
|
|
3498
|
-
state:
|
|
3617
|
+
state: import_services11.Invitation.State.CANCELLED
|
|
3499
3618
|
});
|
|
3500
3619
|
await ctx.dispose();
|
|
3501
3620
|
}
|
|
@@ -3509,41 +3628,41 @@ var InvitationsManager = class {
|
|
|
3509
3628
|
_createObservableAcceptingInvitation(handler, initialState) {
|
|
3510
3629
|
const otpEnteredTrigger = new import_async11.Trigger();
|
|
3511
3630
|
const stream = new import_async11.PushStream();
|
|
3512
|
-
const ctx = new
|
|
3631
|
+
const ctx = new import_context9.Context({
|
|
3513
3632
|
onError: (err) => {
|
|
3514
3633
|
if (err instanceof import_async11.TimeoutError) {
|
|
3515
|
-
(0,
|
|
3634
|
+
(0, import_log10.log)("timeout", {
|
|
3516
3635
|
...handler.toJSON()
|
|
3517
3636
|
}, {
|
|
3518
|
-
F:
|
|
3637
|
+
F: __dxlog_file13,
|
|
3519
3638
|
L: 261,
|
|
3520
3639
|
S: this,
|
|
3521
3640
|
C: (f, a) => f(...a)
|
|
3522
3641
|
});
|
|
3523
3642
|
stream.next({
|
|
3524
3643
|
...initialState,
|
|
3525
|
-
state:
|
|
3644
|
+
state: import_services11.Invitation.State.TIMEOUT
|
|
3526
3645
|
});
|
|
3527
3646
|
} else {
|
|
3528
|
-
|
|
3529
|
-
F:
|
|
3647
|
+
import_log10.log.warn("auth failed", err, {
|
|
3648
|
+
F: __dxlog_file13,
|
|
3530
3649
|
L: 264,
|
|
3531
3650
|
S: this,
|
|
3532
3651
|
C: (f, a) => f(...a)
|
|
3533
3652
|
});
|
|
3534
3653
|
stream.next({
|
|
3535
3654
|
...initialState,
|
|
3536
|
-
state:
|
|
3655
|
+
state: import_services11.Invitation.State.ERROR
|
|
3537
3656
|
});
|
|
3538
3657
|
}
|
|
3539
3658
|
void ctx.dispose();
|
|
3540
3659
|
}
|
|
3541
3660
|
});
|
|
3542
3661
|
ctx.onDispose(() => {
|
|
3543
|
-
(0,
|
|
3662
|
+
(0, import_log10.log)("complete", {
|
|
3544
3663
|
...handler.toJSON()
|
|
3545
3664
|
}, {
|
|
3546
|
-
F:
|
|
3665
|
+
F: __dxlog_file13,
|
|
3547
3666
|
L: 271,
|
|
3548
3667
|
S: this,
|
|
3549
3668
|
C: (f, a) => f(...a)
|
|
@@ -3556,7 +3675,7 @@ var InvitationsManager = class {
|
|
|
3556
3675
|
onCancel: async () => {
|
|
3557
3676
|
stream.next({
|
|
3558
3677
|
...initialState,
|
|
3559
|
-
state:
|
|
3678
|
+
state: import_services11.Invitation.State.CANCELLED
|
|
3560
3679
|
});
|
|
3561
3680
|
await ctx.dispose();
|
|
3562
3681
|
},
|
|
@@ -3572,7 +3691,7 @@ var InvitationsManager = class {
|
|
|
3572
3691
|
};
|
|
3573
3692
|
}
|
|
3574
3693
|
async _persistIfRequired(handler, changeStream, invitation) {
|
|
3575
|
-
if (invitation.type ===
|
|
3694
|
+
if (invitation.type === import_services11.Invitation.Type.DELEGATED && invitation.delegationCredentialId == null) {
|
|
3576
3695
|
const delegationCredentialId = await handler.delegate(invitation);
|
|
3577
3696
|
changeStream.next({
|
|
3578
3697
|
...invitation,
|
|
@@ -3587,8 +3706,8 @@ var InvitationsManager = class {
|
|
|
3587
3706
|
try {
|
|
3588
3707
|
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
3589
3708
|
} catch (err) {
|
|
3590
|
-
|
|
3591
|
-
F:
|
|
3709
|
+
import_log10.log.catch(err, void 0, {
|
|
3710
|
+
F: __dxlog_file13,
|
|
3592
3711
|
L: 307,
|
|
3593
3712
|
S: this,
|
|
3594
3713
|
C: (f, a) => f(...a)
|
|
@@ -3610,7 +3729,7 @@ var AutomergeSpaceState = class {
|
|
|
3610
3729
|
this._isProcessingRootDocs = false;
|
|
3611
3730
|
}
|
|
3612
3731
|
async processCredential(credential) {
|
|
3613
|
-
if (!(0,
|
|
3732
|
+
if (!(0, import_credentials14.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
3614
3733
|
return;
|
|
3615
3734
|
}
|
|
3616
3735
|
this.lastEpoch = credential;
|
|
@@ -3635,18 +3754,18 @@ var AutomergeSpaceState = class {
|
|
|
3635
3754
|
await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
|
|
3636
3755
|
}
|
|
3637
3756
|
};
|
|
3638
|
-
var
|
|
3757
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
3639
3758
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
3640
3759
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
3641
3760
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
3642
3761
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
3643
3762
|
var NotarizationPlugin = class {
|
|
3644
3763
|
constructor() {
|
|
3645
|
-
this._ctx = new
|
|
3764
|
+
this._ctx = new import_context11.Context();
|
|
3646
3765
|
this._extensionOpened = new import_async14.Event();
|
|
3647
3766
|
this._extensions = /* @__PURE__ */ new Set();
|
|
3648
|
-
this._processedCredentials = new import_util7.ComplexSet(
|
|
3649
|
-
this._processCredentialsTriggers = new import_util7.ComplexMap(
|
|
3767
|
+
this._processedCredentials = new import_util7.ComplexSet(import_keys11.PublicKey.hash);
|
|
3768
|
+
this._processCredentialsTriggers = new import_util7.ComplexMap(import_keys11.PublicKey.hash);
|
|
3650
3769
|
}
|
|
3651
3770
|
get hasWriter() {
|
|
3652
3771
|
return !!this._writer;
|
|
@@ -3660,16 +3779,16 @@ var NotarizationPlugin = class {
|
|
|
3660
3779
|
* Request credentials to be notarized.
|
|
3661
3780
|
*/
|
|
3662
3781
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
3663
|
-
(0,
|
|
3782
|
+
(0, import_log12.log)("notarize", {
|
|
3664
3783
|
credentials
|
|
3665
3784
|
}, {
|
|
3666
|
-
F:
|
|
3785
|
+
F: __dxlog_file14,
|
|
3667
3786
|
L: 90,
|
|
3668
3787
|
S: this,
|
|
3669
3788
|
C: (f, a) => f(...a)
|
|
3670
3789
|
});
|
|
3671
3790
|
(0, import_invariant13.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
3672
|
-
F:
|
|
3791
|
+
F: __dxlog_file14,
|
|
3673
3792
|
L: 91,
|
|
3674
3793
|
S: this,
|
|
3675
3794
|
A: [
|
|
@@ -3680,10 +3799,10 @@ var NotarizationPlugin = class {
|
|
|
3680
3799
|
const errors = new import_async14.Trigger();
|
|
3681
3800
|
const ctx = this._ctx.derive({
|
|
3682
3801
|
onError: (err) => {
|
|
3683
|
-
|
|
3802
|
+
import_log12.log.warn("Notarization error", {
|
|
3684
3803
|
err
|
|
3685
3804
|
}, {
|
|
3686
|
-
F:
|
|
3805
|
+
F: __dxlog_file14,
|
|
3687
3806
|
L: 99,
|
|
3688
3807
|
S: this,
|
|
3689
3808
|
C: (f, a) => f(...a)
|
|
@@ -3695,11 +3814,11 @@ var NotarizationPlugin = class {
|
|
|
3695
3814
|
opCtx?.onDispose(() => ctx.dispose());
|
|
3696
3815
|
if (timeout !== 0) {
|
|
3697
3816
|
(0, import_async14.scheduleTask)(ctx, () => {
|
|
3698
|
-
|
|
3817
|
+
import_log12.log.warn("Notarization timeout", {
|
|
3699
3818
|
timeout,
|
|
3700
3819
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3701
3820
|
}, {
|
|
3702
|
-
F:
|
|
3821
|
+
F: __dxlog_file14,
|
|
3703
3822
|
L: 111,
|
|
3704
3823
|
S: this,
|
|
3705
3824
|
C: (f, a) => f(...a)
|
|
@@ -3719,10 +3838,10 @@ var NotarizationPlugin = class {
|
|
|
3719
3838
|
...this._extensions
|
|
3720
3839
|
].find((peer2) => !peersTried.has(peer2));
|
|
3721
3840
|
if (!peer) {
|
|
3722
|
-
|
|
3841
|
+
import_log12.log.info("Exhausted all peers to notarize with", {
|
|
3723
3842
|
retryIn: retryTimeout
|
|
3724
3843
|
}, {
|
|
3725
|
-
F:
|
|
3844
|
+
F: __dxlog_file14,
|
|
3726
3845
|
L: 136,
|
|
3727
3846
|
S: this,
|
|
3728
3847
|
C: (f, a) => f(...a)
|
|
@@ -3732,11 +3851,11 @@ var NotarizationPlugin = class {
|
|
|
3732
3851
|
return;
|
|
3733
3852
|
}
|
|
3734
3853
|
peersTried.add(peer);
|
|
3735
|
-
(0,
|
|
3854
|
+
(0, import_log12.log)("try notarizing", {
|
|
3736
3855
|
peer: peer.localPeerId,
|
|
3737
3856
|
credentialId: credentials.map((credential) => credential.id)
|
|
3738
3857
|
}, {
|
|
3739
|
-
F:
|
|
3858
|
+
F: __dxlog_file14,
|
|
3740
3859
|
L: 143,
|
|
3741
3860
|
S: this,
|
|
3742
3861
|
C: (f, a) => f(...a)
|
|
@@ -3744,8 +3863,8 @@ var NotarizationPlugin = class {
|
|
|
3744
3863
|
await peer.rpc.NotarizationService.notarize({
|
|
3745
3864
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
3746
3865
|
});
|
|
3747
|
-
(0,
|
|
3748
|
-
F:
|
|
3866
|
+
(0, import_log12.log)("success", void 0, {
|
|
3867
|
+
F: __dxlog_file14,
|
|
3749
3868
|
L: 147,
|
|
3750
3869
|
S: this,
|
|
3751
3870
|
C: (f, a) => f(...a)
|
|
@@ -3753,8 +3872,8 @@ var NotarizationPlugin = class {
|
|
|
3753
3872
|
await (0, import_async14.sleep)(successDelay);
|
|
3754
3873
|
} catch (err) {
|
|
3755
3874
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
3756
|
-
|
|
3757
|
-
F:
|
|
3875
|
+
import_log12.log.info("error notarizing (recoverable)", err, {
|
|
3876
|
+
F: __dxlog_file14,
|
|
3758
3877
|
L: 151,
|
|
3759
3878
|
S: this,
|
|
3760
3879
|
C: (f, a) => f(...a)
|
|
@@ -3767,12 +3886,12 @@ var NotarizationPlugin = class {
|
|
|
3767
3886
|
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
3768
3887
|
try {
|
|
3769
3888
|
await Promise.race([
|
|
3770
|
-
(0,
|
|
3889
|
+
(0, import_context11.rejectOnDispose)(ctx),
|
|
3771
3890
|
allNotarized,
|
|
3772
3891
|
errors.wait()
|
|
3773
3892
|
]);
|
|
3774
|
-
(0,
|
|
3775
|
-
F:
|
|
3893
|
+
(0, import_log12.log)("done", void 0, {
|
|
3894
|
+
F: __dxlog_file14,
|
|
3776
3895
|
L: 162,
|
|
3777
3896
|
S: this,
|
|
3778
3897
|
C: (f, a) => f(...a)
|
|
@@ -3794,7 +3913,7 @@ var NotarizationPlugin = class {
|
|
|
3794
3913
|
}
|
|
3795
3914
|
setWriter(writer) {
|
|
3796
3915
|
(0, import_invariant13.invariant)(!this._writer, "Writer already set.", {
|
|
3797
|
-
F:
|
|
3916
|
+
F: __dxlog_file14,
|
|
3798
3917
|
L: 181,
|
|
3799
3918
|
S: this,
|
|
3800
3919
|
A: [
|
|
@@ -3819,7 +3938,7 @@ var NotarizationPlugin = class {
|
|
|
3819
3938
|
}
|
|
3820
3939
|
for (const credential of request.credentials ?? []) {
|
|
3821
3940
|
(0, import_invariant13.invariant)(credential.id, "Credential must have an id", {
|
|
3822
|
-
F:
|
|
3941
|
+
F: __dxlog_file14,
|
|
3823
3942
|
L: 200,
|
|
3824
3943
|
S: this,
|
|
3825
3944
|
A: [
|
|
@@ -3836,10 +3955,10 @@ var NotarizationPlugin = class {
|
|
|
3836
3955
|
createExtension() {
|
|
3837
3956
|
const extension = new NotarizationTeleportExtension({
|
|
3838
3957
|
onOpen: async () => {
|
|
3839
|
-
(0,
|
|
3958
|
+
(0, import_log12.log)("extension opened", {
|
|
3840
3959
|
peer: extension.localPeerId
|
|
3841
3960
|
}, {
|
|
3842
|
-
F:
|
|
3961
|
+
F: __dxlog_file14,
|
|
3843
3962
|
L: 211,
|
|
3844
3963
|
S: this,
|
|
3845
3964
|
C: (f, a) => f(...a)
|
|
@@ -3848,10 +3967,10 @@ var NotarizationPlugin = class {
|
|
|
3848
3967
|
this._extensionOpened.emit();
|
|
3849
3968
|
},
|
|
3850
3969
|
onClose: async () => {
|
|
3851
|
-
(0,
|
|
3970
|
+
(0, import_log12.log)("extension closed", {
|
|
3852
3971
|
peer: extension.localPeerId
|
|
3853
3972
|
}, {
|
|
3854
|
-
F:
|
|
3973
|
+
F: __dxlog_file14,
|
|
3855
3974
|
L: 216,
|
|
3856
3975
|
S: this,
|
|
3857
3976
|
C: (f, a) => f(...a)
|
|
@@ -3903,14 +4022,14 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3903
4022
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3904
4023
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3905
4024
|
}
|
|
3906
|
-
var
|
|
4025
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3907
4026
|
var DataSpace = class {
|
|
3908
4027
|
constructor(params) {
|
|
3909
|
-
this._ctx = new
|
|
4028
|
+
this._ctx = new import_context10.Context();
|
|
3910
4029
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3911
4030
|
this._cache = void 0;
|
|
3912
4031
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
3913
|
-
this._state =
|
|
4032
|
+
this._state = import_services12.SpaceState.CLOSED;
|
|
3914
4033
|
this.error = void 0;
|
|
3915
4034
|
this.stateUpdate = new import_async12.Event();
|
|
3916
4035
|
this.metrics = {};
|
|
@@ -3925,16 +4044,16 @@ var DataSpace = class {
|
|
|
3925
4044
|
this._callbacks = params.callbacks ?? {};
|
|
3926
4045
|
this._echoHost = params.echoHost;
|
|
3927
4046
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
3928
|
-
trustedKeysProvider: () => new import_util6.ComplexSet(
|
|
4047
|
+
trustedKeysProvider: () => new import_util6.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)),
|
|
3929
4048
|
update: this._inner.stateUpdate,
|
|
3930
4049
|
authTimeout: import_client_protocol4.AUTH_TIMEOUT
|
|
3931
4050
|
});
|
|
3932
4051
|
this._cache = params.cache;
|
|
3933
4052
|
this._state = params.initialState;
|
|
3934
|
-
(0,
|
|
3935
|
-
state:
|
|
4053
|
+
(0, import_log11.log)("new state", {
|
|
4054
|
+
state: import_services12.SpaceState[this._state]
|
|
3936
4055
|
}, {
|
|
3937
|
-
F:
|
|
4056
|
+
F: __dxlog_file15,
|
|
3938
4057
|
L: 143,
|
|
3939
4058
|
S: this,
|
|
3940
4059
|
C: (f, a) => f(...a)
|
|
@@ -3975,20 +4094,23 @@ var DataSpace = class {
|
|
|
3975
4094
|
};
|
|
3976
4095
|
}
|
|
3977
4096
|
async open() {
|
|
3978
|
-
|
|
4097
|
+
if (this._state === import_services12.SpaceState.CLOSED) {
|
|
4098
|
+
await this._open();
|
|
4099
|
+
}
|
|
3979
4100
|
}
|
|
3980
4101
|
async _open() {
|
|
4102
|
+
await this._presence.open();
|
|
3981
4103
|
await this._gossip.open();
|
|
3982
4104
|
await this._notarizationPlugin.open();
|
|
3983
4105
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3984
4106
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3985
|
-
await this._inner.open(new
|
|
3986
|
-
this._state =
|
|
3987
|
-
(0,
|
|
3988
|
-
state:
|
|
4107
|
+
await this._inner.open(new import_context10.Context());
|
|
4108
|
+
this._state = import_services12.SpaceState.CONTROL_ONLY;
|
|
4109
|
+
(0, import_log11.log)("new state", {
|
|
4110
|
+
state: import_services12.SpaceState[this._state]
|
|
3989
4111
|
}, {
|
|
3990
|
-
F:
|
|
3991
|
-
L:
|
|
4112
|
+
F: __dxlog_file15,
|
|
4113
|
+
L: 209,
|
|
3992
4114
|
S: this,
|
|
3993
4115
|
C: (f, a) => f(...a)
|
|
3994
4116
|
});
|
|
@@ -4001,23 +4123,23 @@ var DataSpace = class {
|
|
|
4001
4123
|
}
|
|
4002
4124
|
async _close() {
|
|
4003
4125
|
await this._callbacks.beforeClose?.();
|
|
4004
|
-
this._state =
|
|
4005
|
-
(0,
|
|
4006
|
-
state:
|
|
4126
|
+
this._state = import_services12.SpaceState.CLOSED;
|
|
4127
|
+
(0, import_log11.log)("new state", {
|
|
4128
|
+
state: import_services12.SpaceState[this._state]
|
|
4007
4129
|
}, {
|
|
4008
|
-
F:
|
|
4009
|
-
L:
|
|
4130
|
+
F: __dxlog_file15,
|
|
4131
|
+
L: 223,
|
|
4010
4132
|
S: this,
|
|
4011
4133
|
C: (f, a) => f(...a)
|
|
4012
4134
|
});
|
|
4013
4135
|
await this._ctx.dispose();
|
|
4014
|
-
this._ctx = new
|
|
4136
|
+
this._ctx = new import_context10.Context();
|
|
4015
4137
|
await this.authVerifier.close();
|
|
4016
4138
|
await this._inner.close();
|
|
4017
4139
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
4018
4140
|
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
4019
4141
|
await this._notarizationPlugin.close();
|
|
4020
|
-
await this._presence.
|
|
4142
|
+
await this._presence.close();
|
|
4021
4143
|
await this._gossip.close();
|
|
4022
4144
|
}
|
|
4023
4145
|
async postMessage(channel, message) {
|
|
@@ -4035,27 +4157,27 @@ var DataSpace = class {
|
|
|
4035
4157
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
4036
4158
|
await this.initializeDataPipeline();
|
|
4037
4159
|
} catch (err) {
|
|
4038
|
-
if (err instanceof import_protocols9.CancelledError || err instanceof
|
|
4039
|
-
(0,
|
|
4040
|
-
F:
|
|
4041
|
-
L:
|
|
4160
|
+
if (err instanceof import_protocols9.CancelledError || err instanceof import_context10.ContextDisposedError) {
|
|
4161
|
+
(0, import_log11.log)("data pipeline initialization cancelled", err, {
|
|
4162
|
+
F: __dxlog_file15,
|
|
4163
|
+
L: 256,
|
|
4042
4164
|
S: this,
|
|
4043
4165
|
C: (f, a) => f(...a)
|
|
4044
4166
|
});
|
|
4045
4167
|
return;
|
|
4046
4168
|
}
|
|
4047
|
-
|
|
4048
|
-
F:
|
|
4049
|
-
L:
|
|
4169
|
+
import_log11.log.error("Error initializing data pipeline", err, {
|
|
4170
|
+
F: __dxlog_file15,
|
|
4171
|
+
L: 260,
|
|
4050
4172
|
S: this,
|
|
4051
4173
|
C: (f, a) => f(...a)
|
|
4052
4174
|
});
|
|
4053
|
-
this._state =
|
|
4054
|
-
(0,
|
|
4055
|
-
state:
|
|
4175
|
+
this._state = import_services12.SpaceState.ERROR;
|
|
4176
|
+
(0, import_log11.log)("new state", {
|
|
4177
|
+
state: import_services12.SpaceState[this._state]
|
|
4056
4178
|
}, {
|
|
4057
|
-
F:
|
|
4058
|
-
L:
|
|
4179
|
+
F: __dxlog_file15,
|
|
4180
|
+
L: 262,
|
|
4059
4181
|
S: this,
|
|
4060
4182
|
C: (f, a) => f(...a)
|
|
4061
4183
|
});
|
|
@@ -4067,35 +4189,35 @@ var DataSpace = class {
|
|
|
4067
4189
|
});
|
|
4068
4190
|
}
|
|
4069
4191
|
async initializeDataPipeline() {
|
|
4070
|
-
if (this._state !==
|
|
4192
|
+
if (this._state !== import_services12.SpaceState.CONTROL_ONLY) {
|
|
4071
4193
|
throw new import_protocols9.SystemError("Invalid operation");
|
|
4072
4194
|
}
|
|
4073
|
-
this._state =
|
|
4074
|
-
(0,
|
|
4075
|
-
state:
|
|
4195
|
+
this._state = import_services12.SpaceState.INITIALIZING;
|
|
4196
|
+
(0, import_log11.log)("new state", {
|
|
4197
|
+
state: import_services12.SpaceState[this._state]
|
|
4076
4198
|
}, {
|
|
4077
|
-
F:
|
|
4078
|
-
L:
|
|
4199
|
+
F: __dxlog_file15,
|
|
4200
|
+
L: 278,
|
|
4079
4201
|
S: this,
|
|
4080
4202
|
C: (f, a) => f(...a)
|
|
4081
4203
|
});
|
|
4082
4204
|
await this._initializeAndReadControlPipeline();
|
|
4083
4205
|
await (0, import_async12.sleep)(1);
|
|
4084
4206
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
4085
|
-
await (0,
|
|
4086
|
-
(0,
|
|
4087
|
-
F:
|
|
4088
|
-
L:
|
|
4207
|
+
await (0, import_context10.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
4208
|
+
(0, import_log11.log)("data pipeline ready", void 0, {
|
|
4209
|
+
F: __dxlog_file15,
|
|
4210
|
+
L: 290,
|
|
4089
4211
|
S: this,
|
|
4090
4212
|
C: (f, a) => f(...a)
|
|
4091
4213
|
});
|
|
4092
4214
|
await this._callbacks.beforeReady?.();
|
|
4093
|
-
this._state =
|
|
4094
|
-
(0,
|
|
4095
|
-
state:
|
|
4215
|
+
this._state = import_services12.SpaceState.READY;
|
|
4216
|
+
(0, import_log11.log)("new state", {
|
|
4217
|
+
state: import_services12.SpaceState[this._state]
|
|
4096
4218
|
}, {
|
|
4097
|
-
F:
|
|
4098
|
-
L:
|
|
4219
|
+
F: __dxlog_file15,
|
|
4220
|
+
L: 294,
|
|
4099
4221
|
S: this,
|
|
4100
4222
|
C: (f, a) => f(...a)
|
|
4101
4223
|
});
|
|
@@ -4109,9 +4231,9 @@ var DataSpace = class {
|
|
|
4109
4231
|
});
|
|
4110
4232
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
4111
4233
|
await this._createWritableFeeds();
|
|
4112
|
-
(0,
|
|
4113
|
-
F:
|
|
4114
|
-
L:
|
|
4234
|
+
(0, import_log11.log)("writable feeds created", void 0, {
|
|
4235
|
+
F: __dxlog_file15,
|
|
4236
|
+
L: 310,
|
|
4115
4237
|
S: this,
|
|
4116
4238
|
C: (f, a) => f(...a)
|
|
4117
4239
|
});
|
|
@@ -4138,7 +4260,7 @@ var DataSpace = class {
|
|
|
4138
4260
|
spaceKey: this.key,
|
|
4139
4261
|
deviceKey: this._signingContext.deviceKey,
|
|
4140
4262
|
identityKey: this._signingContext.identityKey,
|
|
4141
|
-
designation:
|
|
4263
|
+
designation: import_credentials13.AdmittedFeed.Designation.CONTROL
|
|
4142
4264
|
}
|
|
4143
4265
|
}));
|
|
4144
4266
|
}
|
|
@@ -4155,7 +4277,7 @@ var DataSpace = class {
|
|
|
4155
4277
|
spaceKey: this.key,
|
|
4156
4278
|
deviceKey: this._signingContext.deviceKey,
|
|
4157
4279
|
identityKey: this._signingContext.identityKey,
|
|
4158
|
-
designation:
|
|
4280
|
+
designation: import_credentials13.AdmittedFeed.Designation.DATA
|
|
4159
4281
|
}
|
|
4160
4282
|
}));
|
|
4161
4283
|
}
|
|
@@ -4169,12 +4291,12 @@ var DataSpace = class {
|
|
|
4169
4291
|
}
|
|
4170
4292
|
}
|
|
4171
4293
|
_onNewAutomergeRoot(rootUrl) {
|
|
4172
|
-
(0,
|
|
4294
|
+
(0, import_log11.log)("loading automerge root doc for space", {
|
|
4173
4295
|
space: this.key,
|
|
4174
4296
|
rootUrl
|
|
4175
4297
|
}, {
|
|
4176
|
-
F:
|
|
4177
|
-
L:
|
|
4298
|
+
F: __dxlog_file15,
|
|
4299
|
+
L: 376,
|
|
4178
4300
|
S: this,
|
|
4179
4301
|
C: (f, a) => f(...a)
|
|
4180
4302
|
});
|
|
@@ -4183,7 +4305,7 @@ var DataSpace = class {
|
|
|
4183
4305
|
queueMicrotask(async () => {
|
|
4184
4306
|
try {
|
|
4185
4307
|
await (0, import_debug3.warnAfterTimeout)(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
4186
|
-
await (0,
|
|
4308
|
+
await (0, import_context10.cancelWithContext)(this._ctx, handle.whenReady());
|
|
4187
4309
|
});
|
|
4188
4310
|
if (this._ctx.disposed) {
|
|
4189
4311
|
return;
|
|
@@ -4199,27 +4321,27 @@ var DataSpace = class {
|
|
|
4199
4321
|
if (!this._echoHost.roots.has(handle.documentId)) {
|
|
4200
4322
|
await this._echoHost.openSpaceRoot(handle.url);
|
|
4201
4323
|
} else {
|
|
4202
|
-
|
|
4324
|
+
import_log11.log.warn("echo database root already exists", {
|
|
4203
4325
|
space: this.key,
|
|
4204
4326
|
rootUrl
|
|
4205
4327
|
}, {
|
|
4206
|
-
F:
|
|
4207
|
-
L:
|
|
4328
|
+
F: __dxlog_file15,
|
|
4329
|
+
L: 403,
|
|
4208
4330
|
S: this,
|
|
4209
4331
|
C: (f, a) => f(...a)
|
|
4210
4332
|
});
|
|
4211
4333
|
}
|
|
4212
4334
|
} catch (err) {
|
|
4213
|
-
if (err instanceof
|
|
4335
|
+
if (err instanceof import_context10.ContextDisposedError) {
|
|
4214
4336
|
return;
|
|
4215
4337
|
}
|
|
4216
|
-
|
|
4338
|
+
import_log11.log.warn("error loading automerge root doc", {
|
|
4217
4339
|
space: this.key,
|
|
4218
4340
|
rootUrl,
|
|
4219
4341
|
err
|
|
4220
4342
|
}, {
|
|
4221
|
-
F:
|
|
4222
|
-
L:
|
|
4343
|
+
F: __dxlog_file15,
|
|
4344
|
+
L: 409,
|
|
4223
4345
|
S: this,
|
|
4224
4346
|
C: (f, a) => f(...a)
|
|
4225
4347
|
});
|
|
@@ -4245,36 +4367,39 @@ var DataSpace = class {
|
|
|
4245
4367
|
let epoch;
|
|
4246
4368
|
switch (options?.migration) {
|
|
4247
4369
|
case void 0:
|
|
4248
|
-
case
|
|
4370
|
+
case import_services12.CreateEpochRequest.Migration.NONE:
|
|
4249
4371
|
{
|
|
4250
4372
|
epoch = {
|
|
4251
4373
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4252
4374
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4253
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new
|
|
4375
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
|
|
4254
4376
|
automergeRoot: this._automergeSpaceState.lastEpoch?.subject.assertion?.automergeRoot
|
|
4255
4377
|
};
|
|
4256
4378
|
}
|
|
4257
4379
|
break;
|
|
4258
|
-
case
|
|
4380
|
+
case import_services12.CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
4259
4381
|
{
|
|
4260
4382
|
const document = this._echoHost.automergeRepo.create();
|
|
4261
4383
|
epoch = {
|
|
4262
4384
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4263
4385
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4264
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new
|
|
4386
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
|
|
4265
4387
|
automergeRoot: document.url
|
|
4266
4388
|
};
|
|
4267
4389
|
}
|
|
4268
4390
|
break;
|
|
4269
|
-
case
|
|
4391
|
+
case import_services12.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
4270
4392
|
{
|
|
4271
4393
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
4272
4394
|
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
4273
|
-
await (0,
|
|
4395
|
+
await (0, import_context10.cancelWithContext)(this._ctx, (0, import_async12.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
4274
4396
|
const newRoot = this._echoHost.automergeRepo.create(rootHandle.docSync());
|
|
4397
|
+
await this._echoHost.automergeRepo.flush([
|
|
4398
|
+
newRoot.documentId
|
|
4399
|
+
]);
|
|
4275
4400
|
(0, import_invariant12.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
4276
|
-
F:
|
|
4277
|
-
L:
|
|
4401
|
+
F: __dxlog_file15,
|
|
4402
|
+
L: 460,
|
|
4278
4403
|
S: this,
|
|
4279
4404
|
A: [
|
|
4280
4405
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
@@ -4284,28 +4409,28 @@ var DataSpace = class {
|
|
|
4284
4409
|
epoch = {
|
|
4285
4410
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4286
4411
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4287
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new
|
|
4412
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
|
|
4288
4413
|
automergeRoot: newRoot.url
|
|
4289
4414
|
};
|
|
4290
4415
|
}
|
|
4291
4416
|
break;
|
|
4292
|
-
case
|
|
4417
|
+
case import_services12.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
4293
4418
|
{
|
|
4294
|
-
|
|
4295
|
-
F:
|
|
4296
|
-
L:
|
|
4419
|
+
import_log11.log.info("Fragmenting", void 0, {
|
|
4420
|
+
F: __dxlog_file15,
|
|
4421
|
+
L: 472,
|
|
4297
4422
|
S: this,
|
|
4298
4423
|
C: (f, a) => f(...a)
|
|
4299
4424
|
});
|
|
4300
4425
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
4301
4426
|
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
4302
|
-
await (0,
|
|
4427
|
+
await (0, import_context10.cancelWithContext)(this._ctx, (0, import_async12.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
4303
4428
|
const objects = Object.entries(rootHandle.docSync().objects);
|
|
4304
4429
|
const properties = findPropertiesObject(rootHandle.docSync());
|
|
4305
4430
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
4306
4431
|
(0, import_invariant12.invariant)(properties, "Properties not found", {
|
|
4307
|
-
F:
|
|
4308
|
-
L:
|
|
4432
|
+
F: __dxlog_file15,
|
|
4433
|
+
L: 482,
|
|
4309
4434
|
S: this,
|
|
4310
4435
|
A: [
|
|
4311
4436
|
"properties",
|
|
@@ -4320,8 +4445,8 @@ var DataSpace = class {
|
|
|
4320
4445
|
};
|
|
4321
4446
|
const newRoot = this._echoHost.automergeRepo.create(newSpaceDoc);
|
|
4322
4447
|
(0, import_invariant12.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
4323
|
-
F:
|
|
4324
|
-
L:
|
|
4448
|
+
F: __dxlog_file15,
|
|
4449
|
+
L: 487,
|
|
4325
4450
|
S: this,
|
|
4326
4451
|
A: [
|
|
4327
4452
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
@@ -4344,16 +4469,16 @@ var DataSpace = class {
|
|
|
4344
4469
|
epoch = {
|
|
4345
4470
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4346
4471
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4347
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new
|
|
4472
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
|
|
4348
4473
|
automergeRoot: newRoot.url
|
|
4349
4474
|
};
|
|
4350
4475
|
}
|
|
4351
4476
|
break;
|
|
4352
|
-
case
|
|
4477
|
+
case import_services12.CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT:
|
|
4353
4478
|
{
|
|
4354
4479
|
(0, import_invariant12.invariant)(options.newAutomergeRoot, void 0, {
|
|
4355
|
-
F:
|
|
4356
|
-
L:
|
|
4480
|
+
F: __dxlog_file15,
|
|
4481
|
+
L: 517,
|
|
4357
4482
|
S: this,
|
|
4358
4483
|
A: [
|
|
4359
4484
|
"options.newAutomergeRoot",
|
|
@@ -4363,7 +4488,7 @@ var DataSpace = class {
|
|
|
4363
4488
|
epoch = {
|
|
4364
4489
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4365
4490
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4366
|
-
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new
|
|
4491
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
|
|
4367
4492
|
automergeRoot: options.newAutomergeRoot
|
|
4368
4493
|
};
|
|
4369
4494
|
}
|
|
@@ -4383,7 +4508,7 @@ var DataSpace = class {
|
|
|
4383
4508
|
})
|
|
4384
4509
|
}
|
|
4385
4510
|
});
|
|
4386
|
-
await this.inner.controlPipeline.state.waitUntilTimeframe(new
|
|
4511
|
+
await this.inner.controlPipeline.state.waitUntilTimeframe(new import_timeframe3.Timeframe([
|
|
4387
4512
|
[
|
|
4388
4513
|
receipt.feedKey,
|
|
4389
4514
|
receipt.seq
|
|
@@ -4392,25 +4517,30 @@ var DataSpace = class {
|
|
|
4392
4517
|
await this._echoHost.updateIndexes();
|
|
4393
4518
|
}
|
|
4394
4519
|
async activate() {
|
|
4395
|
-
if (
|
|
4520
|
+
if (![
|
|
4521
|
+
import_services12.SpaceState.CLOSED,
|
|
4522
|
+
import_services12.SpaceState.INACTIVE
|
|
4523
|
+
].includes(this._state)) {
|
|
4396
4524
|
return;
|
|
4397
4525
|
}
|
|
4398
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
4526
|
+
await this._metadataStore.setSpaceState(this.key, import_services12.SpaceState.ACTIVE);
|
|
4399
4527
|
await this._open();
|
|
4400
4528
|
this.initializeDataPipelineAsync();
|
|
4401
4529
|
}
|
|
4402
4530
|
async deactivate() {
|
|
4403
|
-
if (this._state ===
|
|
4531
|
+
if (this._state === import_services12.SpaceState.INACTIVE) {
|
|
4404
4532
|
return;
|
|
4405
4533
|
}
|
|
4406
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4534
|
+
await this._metadataStore.setSpaceState(this.key, import_services12.SpaceState.INACTIVE);
|
|
4535
|
+
if (this._state !== import_services12.SpaceState.CLOSED) {
|
|
4536
|
+
await this._close();
|
|
4537
|
+
}
|
|
4538
|
+
this._state = import_services12.SpaceState.INACTIVE;
|
|
4539
|
+
(0, import_log11.log)("new state", {
|
|
4540
|
+
state: import_services12.SpaceState[this._state]
|
|
4411
4541
|
}, {
|
|
4412
|
-
F:
|
|
4413
|
-
L:
|
|
4542
|
+
F: __dxlog_file15,
|
|
4543
|
+
L: 571,
|
|
4414
4544
|
S: this,
|
|
4415
4545
|
C: (f, a) => f(...a)
|
|
4416
4546
|
});
|
|
@@ -4428,7 +4558,7 @@ _ts_decorate4([
|
|
|
4428
4558
|
], DataSpace.prototype, "key", null);
|
|
4429
4559
|
_ts_decorate4([
|
|
4430
4560
|
import_tracing5.trace.info({
|
|
4431
|
-
enum:
|
|
4561
|
+
enum: import_services12.SpaceState
|
|
4432
4562
|
})
|
|
4433
4563
|
], DataSpace.prototype, "state", null);
|
|
4434
4564
|
_ts_decorate4([
|
|
@@ -4479,7 +4609,7 @@ var findPropertiesObject = (spaceDoc) => {
|
|
|
4479
4609
|
};
|
|
4480
4610
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
4481
4611
|
const credentials = [
|
|
4482
|
-
await (0,
|
|
4612
|
+
await (0, import_credentials17.createCredential)({
|
|
4483
4613
|
signer: keyring,
|
|
4484
4614
|
issuer: space.key,
|
|
4485
4615
|
subject: space.key,
|
|
@@ -4488,14 +4618,14 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
4488
4618
|
spaceKey: space.key
|
|
4489
4619
|
}
|
|
4490
4620
|
}),
|
|
4491
|
-
await (0,
|
|
4621
|
+
await (0, import_credentials17.createCredential)({
|
|
4492
4622
|
signer: keyring,
|
|
4493
4623
|
issuer: space.key,
|
|
4494
4624
|
subject: signingContext.identityKey,
|
|
4495
4625
|
assertion: {
|
|
4496
4626
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
4497
4627
|
spaceKey: space.key,
|
|
4498
|
-
role:
|
|
4628
|
+
role: import_credentials18.SpaceMember.Role.OWNER,
|
|
4499
4629
|
profile: signingContext.getProfile(),
|
|
4500
4630
|
genesisFeedKey: space.controlFeedKey ?? (0, import_debug4.failUndefined)()
|
|
4501
4631
|
}
|
|
@@ -4507,7 +4637,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
4507
4637
|
spaceKey: space.key,
|
|
4508
4638
|
identityKey: signingContext.identityKey,
|
|
4509
4639
|
deviceKey: signingContext.deviceKey,
|
|
4510
|
-
designation:
|
|
4640
|
+
designation: import_credentials18.AdmittedFeed.Designation.CONTROL
|
|
4511
4641
|
}
|
|
4512
4642
|
}),
|
|
4513
4643
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -4517,7 +4647,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
4517
4647
|
spaceKey: space.key,
|
|
4518
4648
|
identityKey: signingContext.identityKey,
|
|
4519
4649
|
deviceKey: signingContext.deviceKey,
|
|
4520
|
-
designation:
|
|
4650
|
+
designation: import_credentials18.AdmittedFeed.Designation.DATA
|
|
4521
4651
|
}
|
|
4522
4652
|
}),
|
|
4523
4653
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -4526,7 +4656,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
4526
4656
|
"@type": "dxos.halo.credentials.Epoch",
|
|
4527
4657
|
number: 0,
|
|
4528
4658
|
previousId: void 0,
|
|
4529
|
-
timeframe: new
|
|
4659
|
+
timeframe: new import_timeframe4.Timeframe(),
|
|
4530
4660
|
snapshotCid: void 0,
|
|
4531
4661
|
automergeRoot
|
|
4532
4662
|
}
|
|
@@ -4551,11 +4681,12 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
4551
4681
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4552
4682
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4553
4683
|
}
|
|
4554
|
-
var
|
|
4684
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
4555
4685
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
4556
4686
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
4687
|
+
var DEFAULT_SPACE_KEY = "__DEFAULT__";
|
|
4557
4688
|
var DataSpaceManager = class {
|
|
4558
|
-
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _echoHost, _invitationsManager,
|
|
4689
|
+
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _echoHost, _invitationsManager, _params) {
|
|
4559
4690
|
this._spaceManager = _spaceManager;
|
|
4560
4691
|
this._metadataStore = _metadataStore;
|
|
4561
4692
|
this._keyring = _keyring;
|
|
@@ -4563,14 +4694,12 @@ var DataSpaceManager = class {
|
|
|
4563
4694
|
this._feedStore = _feedStore;
|
|
4564
4695
|
this._echoHost = _echoHost;
|
|
4565
4696
|
this._invitationsManager = _invitationsManager;
|
|
4566
|
-
this.
|
|
4697
|
+
this._params = _params;
|
|
4698
|
+
this._ctx = new import_context12.Context();
|
|
4567
4699
|
this.updated = new import_async15.Event();
|
|
4568
|
-
this._spaces = new import_util8.ComplexMap(
|
|
4700
|
+
this._spaces = new import_util8.ComplexMap(import_keys12.PublicKey.hash);
|
|
4569
4701
|
this._isOpen = false;
|
|
4570
|
-
this._instanceId =
|
|
4571
|
-
const { spaceMemberPresenceAnnounceInterval = PRESENCE_ANNOUNCE_INTERVAL, spaceMemberPresenceOfflineTimeout = PRESENCE_OFFLINE_TIMEOUT } = params ?? {};
|
|
4572
|
-
this._spaceMemberPresenceAnnounceInterval = spaceMemberPresenceAnnounceInterval;
|
|
4573
|
-
this._spaceMemberPresenceOfflineTimeout = spaceMemberPresenceOfflineTimeout;
|
|
4702
|
+
this._instanceId = import_keys12.PublicKey.random().toHex();
|
|
4574
4703
|
import_tracing6.trace.diagnostic({
|
|
4575
4704
|
id: "spaces",
|
|
4576
4705
|
name: "Spaces",
|
|
@@ -4582,7 +4711,7 @@ var DataSpaceManager = class {
|
|
|
4582
4711
|
const properties = rootDoc && findPropertiesObject(rootDoc);
|
|
4583
4712
|
return {
|
|
4584
4713
|
key: space.key.toHex(),
|
|
4585
|
-
state:
|
|
4714
|
+
state: import_services13.SpaceState[space.state],
|
|
4586
4715
|
name: properties?.[1].data.name ?? null,
|
|
4587
4716
|
inlineObjects: rootDoc ? Object.keys(rootDoc.objects ?? {}).length : null,
|
|
4588
4717
|
linkedObjects: rootDoc ? Object.keys(rootDoc.links ?? {}).length : null,
|
|
@@ -4599,46 +4728,46 @@ var DataSpaceManager = class {
|
|
|
4599
4728
|
return this._spaces;
|
|
4600
4729
|
}
|
|
4601
4730
|
async open() {
|
|
4602
|
-
(0,
|
|
4603
|
-
F:
|
|
4604
|
-
L:
|
|
4731
|
+
(0, import_log13.log)("open", void 0, {
|
|
4732
|
+
F: __dxlog_file16,
|
|
4733
|
+
L: 140,
|
|
4605
4734
|
S: this,
|
|
4606
4735
|
C: (f, a) => f(...a)
|
|
4607
4736
|
});
|
|
4608
|
-
|
|
4737
|
+
import_log13.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.begin({
|
|
4609
4738
|
id: this._instanceId
|
|
4610
4739
|
}), {
|
|
4611
|
-
F:
|
|
4612
|
-
L:
|
|
4740
|
+
F: __dxlog_file16,
|
|
4741
|
+
L: 141,
|
|
4613
4742
|
S: this,
|
|
4614
4743
|
C: (f, a) => f(...a)
|
|
4615
4744
|
});
|
|
4616
|
-
(0,
|
|
4745
|
+
(0, import_log13.log)("metadata loaded", {
|
|
4617
4746
|
spaces: this._metadataStore.spaces.length
|
|
4618
4747
|
}, {
|
|
4619
|
-
F:
|
|
4620
|
-
L:
|
|
4748
|
+
F: __dxlog_file16,
|
|
4749
|
+
L: 142,
|
|
4621
4750
|
S: this,
|
|
4622
4751
|
C: (f, a) => f(...a)
|
|
4623
4752
|
});
|
|
4624
4753
|
await (0, import_util8.forEachAsync)(this._metadataStore.spaces, async (spaceMetadata) => {
|
|
4625
4754
|
try {
|
|
4626
|
-
(0,
|
|
4755
|
+
(0, import_log13.log)("load space", {
|
|
4627
4756
|
spaceMetadata
|
|
4628
4757
|
}, {
|
|
4629
|
-
F:
|
|
4630
|
-
L:
|
|
4758
|
+
F: __dxlog_file16,
|
|
4759
|
+
L: 146,
|
|
4631
4760
|
S: this,
|
|
4632
4761
|
C: (f, a) => f(...a)
|
|
4633
4762
|
});
|
|
4634
4763
|
await this._constructSpace(spaceMetadata);
|
|
4635
4764
|
} catch (err) {
|
|
4636
|
-
|
|
4765
|
+
import_log13.log.error("Error loading space", {
|
|
4637
4766
|
spaceMetadata,
|
|
4638
4767
|
err
|
|
4639
4768
|
}, {
|
|
4640
|
-
F:
|
|
4641
|
-
L:
|
|
4769
|
+
F: __dxlog_file16,
|
|
4770
|
+
L: 149,
|
|
4642
4771
|
S: this,
|
|
4643
4772
|
C: (f, a) => f(...a)
|
|
4644
4773
|
});
|
|
@@ -4646,24 +4775,19 @@ var DataSpaceManager = class {
|
|
|
4646
4775
|
});
|
|
4647
4776
|
this._isOpen = true;
|
|
4648
4777
|
this.updated.emit();
|
|
4649
|
-
|
|
4650
|
-
if (space.state !== import_services12.SpaceState.INACTIVE) {
|
|
4651
|
-
space.initializeDataPipelineAsync();
|
|
4652
|
-
}
|
|
4653
|
-
}
|
|
4654
|
-
import_log12.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.end({
|
|
4778
|
+
import_log13.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.end({
|
|
4655
4779
|
id: this._instanceId
|
|
4656
4780
|
}), {
|
|
4657
|
-
F:
|
|
4658
|
-
L:
|
|
4781
|
+
F: __dxlog_file16,
|
|
4782
|
+
L: 156,
|
|
4659
4783
|
S: this,
|
|
4660
4784
|
C: (f, a) => f(...a)
|
|
4661
4785
|
});
|
|
4662
4786
|
}
|
|
4663
4787
|
async close() {
|
|
4664
|
-
(0,
|
|
4665
|
-
F:
|
|
4666
|
-
L:
|
|
4788
|
+
(0, import_log13.log)("close", void 0, {
|
|
4789
|
+
F: __dxlog_file16,
|
|
4790
|
+
L: 161,
|
|
4667
4791
|
S: this,
|
|
4668
4792
|
C: (f, a) => f(...a)
|
|
4669
4793
|
});
|
|
@@ -4672,14 +4796,15 @@ var DataSpaceManager = class {
|
|
|
4672
4796
|
for (const space of this._spaces.values()) {
|
|
4673
4797
|
await space.close();
|
|
4674
4798
|
}
|
|
4799
|
+
this._spaces.clear();
|
|
4675
4800
|
}
|
|
4676
4801
|
/**
|
|
4677
4802
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
4678
4803
|
*/
|
|
4679
4804
|
async createSpace() {
|
|
4680
4805
|
(0, import_invariant14.invariant)(this._isOpen, "Not open.", {
|
|
4681
|
-
F:
|
|
4682
|
-
L:
|
|
4806
|
+
F: __dxlog_file16,
|
|
4807
|
+
L: 175,
|
|
4683
4808
|
S: this,
|
|
4684
4809
|
A: [
|
|
4685
4810
|
"this._isOpen",
|
|
@@ -4694,24 +4819,25 @@ var DataSpaceManager = class {
|
|
|
4694
4819
|
genesisFeedKey: controlFeedKey,
|
|
4695
4820
|
controlFeedKey,
|
|
4696
4821
|
dataFeedKey,
|
|
4697
|
-
state:
|
|
4822
|
+
state: import_services13.SpaceState.ACTIVE
|
|
4698
4823
|
};
|
|
4699
|
-
(0,
|
|
4824
|
+
(0, import_log13.log)("creating space...", {
|
|
4700
4825
|
spaceKey
|
|
4701
4826
|
}, {
|
|
4702
|
-
F:
|
|
4703
|
-
L:
|
|
4827
|
+
F: __dxlog_file16,
|
|
4828
|
+
L: 187,
|
|
4704
4829
|
S: this,
|
|
4705
4830
|
C: (f, a) => f(...a)
|
|
4706
4831
|
});
|
|
4707
4832
|
const root = await this._echoHost.createSpaceRoot(spaceKey);
|
|
4708
4833
|
const space = await this._constructSpace(metadata);
|
|
4834
|
+
await space.open();
|
|
4709
4835
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, root.url);
|
|
4710
4836
|
await this._metadataStore.addSpace(metadata);
|
|
4711
4837
|
const memberCredential = credentials[1];
|
|
4712
|
-
(0, import_invariant14.invariant)((0,
|
|
4713
|
-
F:
|
|
4714
|
-
L:
|
|
4838
|
+
(0, import_invariant14.invariant)((0, import_credentials15.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4839
|
+
F: __dxlog_file16,
|
|
4840
|
+
L: 197,
|
|
4715
4841
|
S: this,
|
|
4716
4842
|
A: [
|
|
4717
4843
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -4723,19 +4849,63 @@ var DataSpaceManager = class {
|
|
|
4723
4849
|
this.updated.emit();
|
|
4724
4850
|
return space;
|
|
4725
4851
|
}
|
|
4852
|
+
async isDefaultSpace(space) {
|
|
4853
|
+
const rootDoc = await this._getSpaceRootDocument(space);
|
|
4854
|
+
const [_, properties] = findPropertiesObject(rootDoc.docSync()) ?? [];
|
|
4855
|
+
return properties?.data?.[DEFAULT_SPACE_KEY] === this._signingContext.identityKey.toHex();
|
|
4856
|
+
}
|
|
4857
|
+
async createDefaultSpace() {
|
|
4858
|
+
const space = await this.createSpace();
|
|
4859
|
+
const document = await this._getSpaceRootDocument(space);
|
|
4860
|
+
const properties = {
|
|
4861
|
+
system: {
|
|
4862
|
+
type: (0, import_echo_protocol.encodeReference)((0, import_echo_schema2.getTypeReference)(import_client_protocol5.PropertiesType))
|
|
4863
|
+
},
|
|
4864
|
+
data: {
|
|
4865
|
+
[DEFAULT_SPACE_KEY]: this._signingContext.identityKey.toHex()
|
|
4866
|
+
},
|
|
4867
|
+
meta: {
|
|
4868
|
+
keys: []
|
|
4869
|
+
}
|
|
4870
|
+
};
|
|
4871
|
+
const propertiesId = import_keys12.PublicKey.random().toHex();
|
|
4872
|
+
document.change((doc) => {
|
|
4873
|
+
(0, import_util8.assignDeep)(doc, [
|
|
4874
|
+
"objects",
|
|
4875
|
+
propertiesId
|
|
4876
|
+
], properties);
|
|
4877
|
+
});
|
|
4878
|
+
await this._echoHost.flush();
|
|
4879
|
+
return space;
|
|
4880
|
+
}
|
|
4881
|
+
async _getSpaceRootDocument(space) {
|
|
4882
|
+
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
4883
|
+
(0, import_invariant14.invariant)(automergeIndex, void 0, {
|
|
4884
|
+
F: __dxlog_file16,
|
|
4885
|
+
L: 240,
|
|
4886
|
+
S: this,
|
|
4887
|
+
A: [
|
|
4888
|
+
"automergeIndex",
|
|
4889
|
+
""
|
|
4890
|
+
]
|
|
4891
|
+
});
|
|
4892
|
+
const document = this._echoHost.automergeRepo.find(automergeIndex);
|
|
4893
|
+
await document.whenReady();
|
|
4894
|
+
return document;
|
|
4895
|
+
}
|
|
4726
4896
|
// TODO(burdon): Rename join space.
|
|
4727
4897
|
async acceptSpace(opts) {
|
|
4728
|
-
(0,
|
|
4898
|
+
(0, import_log13.log)("accept space", {
|
|
4729
4899
|
opts
|
|
4730
4900
|
}, {
|
|
4731
|
-
F:
|
|
4732
|
-
L:
|
|
4901
|
+
F: __dxlog_file16,
|
|
4902
|
+
L: 249,
|
|
4733
4903
|
S: this,
|
|
4734
4904
|
C: (f, a) => f(...a)
|
|
4735
4905
|
});
|
|
4736
4906
|
(0, import_invariant14.invariant)(this._isOpen, "Not open.", {
|
|
4737
|
-
F:
|
|
4738
|
-
L:
|
|
4907
|
+
F: __dxlog_file16,
|
|
4908
|
+
L: 250,
|
|
4739
4909
|
S: this,
|
|
4740
4910
|
A: [
|
|
4741
4911
|
"this._isOpen",
|
|
@@ -4743,8 +4913,8 @@ var DataSpaceManager = class {
|
|
|
4743
4913
|
]
|
|
4744
4914
|
});
|
|
4745
4915
|
(0, import_invariant14.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
4746
|
-
F:
|
|
4747
|
-
L:
|
|
4916
|
+
F: __dxlog_file16,
|
|
4917
|
+
L: 251,
|
|
4748
4918
|
S: this,
|
|
4749
4919
|
A: [
|
|
4750
4920
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -4758,6 +4928,7 @@ var DataSpaceManager = class {
|
|
|
4758
4928
|
dataTimeframe: opts.dataTimeframe
|
|
4759
4929
|
};
|
|
4760
4930
|
const space = await this._constructSpace(metadata);
|
|
4931
|
+
await space.open();
|
|
4761
4932
|
await this._metadataStore.addSpace(metadata);
|
|
4762
4933
|
space.initializeDataPipelineAsync();
|
|
4763
4934
|
this.updated.emit();
|
|
@@ -4769,17 +4940,17 @@ var DataSpaceManager = class {
|
|
|
4769
4940
|
* TODO(dmaretskyi): Consider removing.
|
|
4770
4941
|
*/
|
|
4771
4942
|
async waitUntilSpaceReady(spaceKey) {
|
|
4772
|
-
await (0,
|
|
4943
|
+
await (0, import_context12.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
4773
4944
|
const space = this._spaces.get(spaceKey);
|
|
4774
|
-
return !!space && space.state ===
|
|
4945
|
+
return !!space && space.state === import_services13.SpaceState.READY;
|
|
4775
4946
|
}));
|
|
4776
4947
|
}
|
|
4777
4948
|
async _constructSpace(metadata) {
|
|
4778
|
-
(0,
|
|
4949
|
+
(0, import_log13.log)("construct space", {
|
|
4779
4950
|
metadata
|
|
4780
4951
|
}, {
|
|
4781
|
-
F:
|
|
4782
|
-
L:
|
|
4952
|
+
F: __dxlog_file16,
|
|
4953
|
+
L: 285,
|
|
4783
4954
|
S: this,
|
|
4784
4955
|
C: (f, a) => f(...a)
|
|
4785
4956
|
});
|
|
@@ -4787,8 +4958,8 @@ var DataSpaceManager = class {
|
|
|
4787
4958
|
localPeerId: this._signingContext.deviceKey
|
|
4788
4959
|
});
|
|
4789
4960
|
const presence = new import_teleport_extension_gossip2.Presence({
|
|
4790
|
-
announceInterval: this.
|
|
4791
|
-
offlineTimeout: this.
|
|
4961
|
+
announceInterval: this._params?.spaceMemberPresenceAnnounceInterval ?? PRESENCE_ANNOUNCE_INTERVAL,
|
|
4962
|
+
offlineTimeout: this._params?.spaceMemberPresenceOfflineTimeout ?? PRESENCE_OFFLINE_TIMEOUT,
|
|
4792
4963
|
identityKey: this._signingContext.identityKey,
|
|
4793
4964
|
gossip
|
|
4794
4965
|
});
|
|
@@ -4815,15 +4986,15 @@ var DataSpaceManager = class {
|
|
|
4815
4986
|
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
4816
4987
|
},
|
|
4817
4988
|
onAuthFailure: () => {
|
|
4818
|
-
|
|
4819
|
-
F:
|
|
4820
|
-
L:
|
|
4989
|
+
import_log13.log.warn("auth failure", void 0, {
|
|
4990
|
+
F: __dxlog_file16,
|
|
4991
|
+
L: 322,
|
|
4821
4992
|
S: this,
|
|
4822
4993
|
C: (f, a) => f(...a)
|
|
4823
4994
|
});
|
|
4824
4995
|
},
|
|
4825
4996
|
onMemberRolesChanged: async (members) => {
|
|
4826
|
-
if (dataSpace?.state ===
|
|
4997
|
+
if (dataSpace?.state === import_services13.SpaceState.READY) {
|
|
4827
4998
|
this._handleMemberRoleChanges(presence, space.protocol, members);
|
|
4828
4999
|
}
|
|
4829
5000
|
},
|
|
@@ -4836,7 +5007,7 @@ var DataSpaceManager = class {
|
|
|
4836
5007
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
4837
5008
|
const dataSpace = new DataSpace({
|
|
4838
5009
|
inner: space,
|
|
4839
|
-
initialState: metadata.state ===
|
|
5010
|
+
initialState: metadata.state === import_services13.SpaceState.INACTIVE ? import_services13.SpaceState.INACTIVE : import_services13.SpaceState.CLOSED,
|
|
4840
5011
|
metadataStore: this._metadataStore,
|
|
4841
5012
|
gossip,
|
|
4842
5013
|
presence,
|
|
@@ -4846,22 +5017,22 @@ var DataSpaceManager = class {
|
|
|
4846
5017
|
signingContext: this._signingContext,
|
|
4847
5018
|
callbacks: {
|
|
4848
5019
|
beforeReady: async () => {
|
|
4849
|
-
(0,
|
|
5020
|
+
(0, import_log13.log)("before space ready", {
|
|
4850
5021
|
space: space.key
|
|
4851
5022
|
}, {
|
|
4852
|
-
F:
|
|
4853
|
-
L:
|
|
5023
|
+
F: __dxlog_file16,
|
|
5024
|
+
L: 349,
|
|
4854
5025
|
S: this,
|
|
4855
5026
|
C: (f, a) => f(...a)
|
|
4856
5027
|
});
|
|
4857
5028
|
},
|
|
4858
5029
|
afterReady: async () => {
|
|
4859
|
-
(0,
|
|
5030
|
+
(0, import_log13.log)("after space ready", {
|
|
4860
5031
|
space: space.key,
|
|
4861
5032
|
open: this._isOpen
|
|
4862
5033
|
}, {
|
|
4863
|
-
F:
|
|
4864
|
-
L:
|
|
5034
|
+
F: __dxlog_file16,
|
|
5035
|
+
L: 352,
|
|
4865
5036
|
S: this,
|
|
4866
5037
|
C: (f, a) => f(...a)
|
|
4867
5038
|
});
|
|
@@ -4876,11 +5047,11 @@ var DataSpaceManager = class {
|
|
|
4876
5047
|
}
|
|
4877
5048
|
},
|
|
4878
5049
|
beforeClose: async () => {
|
|
4879
|
-
(0,
|
|
5050
|
+
(0, import_log13.log)("before space close", {
|
|
4880
5051
|
space: space.key
|
|
4881
5052
|
}, {
|
|
4882
|
-
F:
|
|
4883
|
-
L:
|
|
5053
|
+
F: __dxlog_file16,
|
|
5054
|
+
L: 360,
|
|
4884
5055
|
S: this,
|
|
4885
5056
|
C: (f, a) => f(...a)
|
|
4886
5057
|
});
|
|
@@ -4889,13 +5060,10 @@ var DataSpaceManager = class {
|
|
|
4889
5060
|
cache: metadata.cache
|
|
4890
5061
|
});
|
|
4891
5062
|
presence.newPeer.on((peerState) => {
|
|
4892
|
-
if (dataSpace.state ===
|
|
5063
|
+
if (dataSpace.state === import_services13.SpaceState.READY) {
|
|
4893
5064
|
this._handleNewPeerConnected(space, peerState);
|
|
4894
5065
|
}
|
|
4895
5066
|
});
|
|
4896
|
-
if (metadata.state !== import_services12.SpaceState.INACTIVE) {
|
|
4897
|
-
await dataSpace.open();
|
|
4898
|
-
}
|
|
4899
5067
|
if (metadata.controlTimeframe) {
|
|
4900
5068
|
dataSpace.inner.controlPipeline.state.setTargetTimeframe(metadata.controlTimeframe);
|
|
4901
5069
|
}
|
|
@@ -4911,20 +5079,20 @@ var DataSpaceManager = class {
|
|
|
4911
5079
|
const peers = presence.getPeersByIdentityKey(member.key);
|
|
4912
5080
|
const sessions = peers.map((p) => p.peerId && spaceProtocol.sessions.get(p.peerId));
|
|
4913
5081
|
const sessionsToClose = sessions.filter((s) => {
|
|
4914
|
-
return (s && member.role ===
|
|
5082
|
+
return (s && member.role === import_credentials16.SpaceMember.Role.REMOVED !== (s.authStatus === import_echo_pipeline3.AuthStatus.FAILURE)) ?? false;
|
|
4915
5083
|
});
|
|
4916
5084
|
sessionsToClose.forEach((session) => {
|
|
4917
|
-
void session.close().catch(
|
|
5085
|
+
void session.close().catch(import_log13.log.error);
|
|
4918
5086
|
});
|
|
4919
5087
|
closedSessions += sessionsToClose.length;
|
|
4920
5088
|
}
|
|
4921
|
-
(0,
|
|
5089
|
+
(0, import_log13.log)("processed member role changes", {
|
|
4922
5090
|
roleChangeCount: memberInfo.length,
|
|
4923
5091
|
peersOnline: presence.getPeersOnline().length,
|
|
4924
5092
|
closedSessions
|
|
4925
5093
|
}, {
|
|
4926
|
-
F:
|
|
4927
|
-
L:
|
|
5094
|
+
F: __dxlog_file16,
|
|
5095
|
+
L: 396,
|
|
4928
5096
|
S: this,
|
|
4929
5097
|
C: (f, a) => f(...a)
|
|
4930
5098
|
});
|
|
@@ -4932,23 +5100,23 @@ var DataSpaceManager = class {
|
|
|
4932
5100
|
}
|
|
4933
5101
|
_handleNewPeerConnected(space, peerState) {
|
|
4934
5102
|
const role = space.spaceState.getMemberRole(peerState.identityKey);
|
|
4935
|
-
if (role ===
|
|
5103
|
+
if (role === import_credentials16.SpaceMember.Role.REMOVED) {
|
|
4936
5104
|
const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
|
|
4937
5105
|
if (session != null) {
|
|
4938
|
-
(0,
|
|
5106
|
+
(0, import_log13.log)("closing a session with a removed peer", {
|
|
4939
5107
|
peerId: peerState.peerId
|
|
4940
5108
|
}, {
|
|
4941
|
-
F:
|
|
4942
|
-
L:
|
|
5109
|
+
F: __dxlog_file16,
|
|
5110
|
+
L: 410,
|
|
4943
5111
|
S: this,
|
|
4944
5112
|
C: (f, a) => f(...a)
|
|
4945
5113
|
});
|
|
4946
|
-
void session.close().catch(
|
|
5114
|
+
void session.close().catch(import_log13.log.error);
|
|
4947
5115
|
}
|
|
4948
5116
|
}
|
|
4949
5117
|
}
|
|
4950
5118
|
async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
|
|
4951
|
-
if (dataSpace?.state !==
|
|
5119
|
+
if (dataSpace?.state !== import_services13.SpaceState.READY) {
|
|
4952
5120
|
return;
|
|
4953
5121
|
}
|
|
4954
5122
|
if (isActive) {
|
|
@@ -4965,8 +5133,8 @@ var DataSpaceManager = class {
|
|
|
4965
5133
|
async _createDelegatedInvitations(space, invitations) {
|
|
4966
5134
|
const tasks = invitations.map(([credentialId, invitation]) => {
|
|
4967
5135
|
return this._invitationsManager.createInvitation({
|
|
4968
|
-
type:
|
|
4969
|
-
kind:
|
|
5136
|
+
type: import_services13.Invitation.Type.DELEGATED,
|
|
5137
|
+
kind: import_services13.Invitation.Kind.SPACE,
|
|
4970
5138
|
spaceKey: space.key,
|
|
4971
5139
|
authMethod: invitation.authMethod,
|
|
4972
5140
|
invitationId: invitation.invitationId,
|
|
@@ -4998,7 +5166,7 @@ _ts_decorate5([
|
|
|
4998
5166
|
DataSpaceManager = _ts_decorate5([
|
|
4999
5167
|
(0, import_async15.trackLeaks)("open", "close")
|
|
5000
5168
|
], DataSpaceManager);
|
|
5001
|
-
var
|
|
5169
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
5002
5170
|
var SpacesServiceImpl = class {
|
|
5003
5171
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
5004
5172
|
this._identityManager = _identityManager;
|
|
@@ -5017,10 +5185,10 @@ var SpacesServiceImpl = class {
|
|
|
5017
5185
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols12.SpaceNotFoundError(spaceKey));
|
|
5018
5186
|
if (state) {
|
|
5019
5187
|
switch (state) {
|
|
5020
|
-
case
|
|
5188
|
+
case import_services14.SpaceState.ACTIVE:
|
|
5021
5189
|
await space.activate();
|
|
5022
5190
|
break;
|
|
5023
|
-
case
|
|
5191
|
+
case import_services14.SpaceState.INACTIVE:
|
|
5024
5192
|
await space.deactivate();
|
|
5025
5193
|
break;
|
|
5026
5194
|
default:
|
|
@@ -5040,9 +5208,9 @@ var SpacesServiceImpl = class {
|
|
|
5040
5208
|
role: space.spaceState.getMemberRole(identity.identityKey)
|
|
5041
5209
|
});
|
|
5042
5210
|
}
|
|
5043
|
-
const credentials = await (0,
|
|
5211
|
+
const credentials = await (0, import_credentials19.createAdmissionCredentials)(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
5044
5212
|
(0, import_invariant15.invariant)(credentials[0].credential, void 0, {
|
|
5045
|
-
F:
|
|
5213
|
+
F: __dxlog_file17,
|
|
5046
5214
|
L: 97,
|
|
5047
5215
|
S: this,
|
|
5048
5216
|
A: [
|
|
@@ -5051,8 +5219,8 @@ var SpacesServiceImpl = class {
|
|
|
5051
5219
|
]
|
|
5052
5220
|
});
|
|
5053
5221
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5054
|
-
(0, import_invariant15.invariant)((0,
|
|
5055
|
-
F:
|
|
5222
|
+
(0, import_invariant15.invariant)((0, import_credentials19.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5223
|
+
F: __dxlog_file17,
|
|
5056
5224
|
L: 99,
|
|
5057
5225
|
S: this,
|
|
5058
5226
|
A: [
|
|
@@ -5067,10 +5235,10 @@ var SpacesServiceImpl = class {
|
|
|
5067
5235
|
const scheduler = new import_async16.UpdateScheduler(ctx, async () => {
|
|
5068
5236
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5069
5237
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
5070
|
-
(0,
|
|
5238
|
+
(0, import_log14.log)("update", {
|
|
5071
5239
|
spaces
|
|
5072
5240
|
}, {
|
|
5073
|
-
F:
|
|
5241
|
+
F: __dxlog_file17,
|
|
5074
5242
|
L: 110,
|
|
5075
5243
|
S: this,
|
|
5076
5244
|
C: (f, a) => f(...a)
|
|
@@ -5154,7 +5322,7 @@ var SpacesServiceImpl = class {
|
|
|
5154
5322
|
});
|
|
5155
5323
|
} else {
|
|
5156
5324
|
(0, import_invariant15.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
5157
|
-
F:
|
|
5325
|
+
F: __dxlog_file17,
|
|
5158
5326
|
L: 198,
|
|
5159
5327
|
S: this,
|
|
5160
5328
|
A: [
|
|
@@ -5163,7 +5331,7 @@ var SpacesServiceImpl = class {
|
|
|
5163
5331
|
]
|
|
5164
5332
|
});
|
|
5165
5333
|
(0, import_invariant15.invariant)(this._identityManager.identity, "Identity is not available", {
|
|
5166
|
-
F:
|
|
5334
|
+
F: __dxlog_file17,
|
|
5167
5335
|
L: 199,
|
|
5168
5336
|
S: this,
|
|
5169
5337
|
A: [
|
|
@@ -5173,7 +5341,7 @@ var SpacesServiceImpl = class {
|
|
|
5173
5341
|
});
|
|
5174
5342
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
5175
5343
|
(0, import_invariant15.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
5176
|
-
F:
|
|
5344
|
+
F: __dxlog_file17,
|
|
5177
5345
|
L: 201,
|
|
5178
5346
|
S: this,
|
|
5179
5347
|
A: [
|
|
@@ -5232,7 +5400,7 @@ var SpacesServiceImpl = class {
|
|
|
5232
5400
|
profile: member.profile ?? {}
|
|
5233
5401
|
},
|
|
5234
5402
|
role: member.role,
|
|
5235
|
-
presence: peers.length > 0 ?
|
|
5403
|
+
presence: peers.length > 0 ? import_services14.SpaceMember.PresenceState.ONLINE : import_services14.SpaceMember.PresenceState.OFFLINE,
|
|
5236
5404
|
peerStates: peers
|
|
5237
5405
|
};
|
|
5238
5406
|
}),
|
|
@@ -5270,8 +5438,8 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
5270
5438
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5271
5439
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5272
5440
|
}
|
|
5273
|
-
var
|
|
5274
|
-
var ServiceContext = class extends
|
|
5441
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
5442
|
+
var ServiceContext = class extends import_context13.Resource {
|
|
5275
5443
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
5276
5444
|
super();
|
|
5277
5445
|
this.storage = storage;
|
|
@@ -5281,7 +5449,7 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5281
5449
|
this._runtimeParams = _runtimeParams;
|
|
5282
5450
|
this.initialized = new import_async17.Trigger();
|
|
5283
5451
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
5284
|
-
this._instanceId =
|
|
5452
|
+
this._instanceId = import_keys13.PublicKey.random().toHex();
|
|
5285
5453
|
this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
|
|
5286
5454
|
this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
|
|
5287
5455
|
this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
|
|
@@ -5305,26 +5473,25 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5305
5473
|
});
|
|
5306
5474
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
5307
5475
|
this.echoHost = new import_echo_db.EchoHost({
|
|
5308
|
-
kv: this.level
|
|
5309
|
-
storage: this.storage
|
|
5476
|
+
kv: this.level
|
|
5310
5477
|
});
|
|
5311
5478
|
this.invitations = new InvitationsHandler(this.networkManager, _runtimeParams?.invitationConnectionDefaultParams);
|
|
5312
5479
|
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
5313
|
-
this._handlerFactories.set(
|
|
5480
|
+
this._handlerFactories.set(import_services15.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
5314
5481
|
}
|
|
5315
5482
|
async _open(ctx) {
|
|
5316
5483
|
await this._checkStorageVersion();
|
|
5317
|
-
(0,
|
|
5318
|
-
F:
|
|
5319
|
-
L:
|
|
5484
|
+
(0, import_log15.log)("opening...", void 0, {
|
|
5485
|
+
F: __dxlog_file18,
|
|
5486
|
+
L: 149,
|
|
5320
5487
|
S: this,
|
|
5321
5488
|
C: (f, a) => f(...a)
|
|
5322
5489
|
});
|
|
5323
|
-
|
|
5490
|
+
import_log15.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.begin({
|
|
5324
5491
|
id: this._instanceId
|
|
5325
5492
|
}), {
|
|
5326
|
-
F:
|
|
5327
|
-
L:
|
|
5493
|
+
F: __dxlog_file18,
|
|
5494
|
+
L: 150,
|
|
5328
5495
|
S: this,
|
|
5329
5496
|
C: (f, a) => f(...a)
|
|
5330
5497
|
});
|
|
@@ -5338,33 +5505,33 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5338
5505
|
await this._initialize(ctx);
|
|
5339
5506
|
}
|
|
5340
5507
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
5341
|
-
(0,
|
|
5508
|
+
(0, import_log15.log)("loaded persistent invitations", {
|
|
5342
5509
|
count: loadedInvitations.invitations?.length
|
|
5343
5510
|
}, {
|
|
5344
|
-
F:
|
|
5345
|
-
L:
|
|
5511
|
+
F: __dxlog_file18,
|
|
5512
|
+
L: 163,
|
|
5346
5513
|
S: this,
|
|
5347
5514
|
C: (f, a) => f(...a)
|
|
5348
5515
|
});
|
|
5349
|
-
|
|
5516
|
+
import_log15.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.end({
|
|
5350
5517
|
id: this._instanceId
|
|
5351
5518
|
}), {
|
|
5352
|
-
F:
|
|
5353
|
-
L:
|
|
5519
|
+
F: __dxlog_file18,
|
|
5520
|
+
L: 165,
|
|
5354
5521
|
S: this,
|
|
5355
5522
|
C: (f, a) => f(...a)
|
|
5356
5523
|
});
|
|
5357
|
-
(0,
|
|
5358
|
-
F:
|
|
5359
|
-
L:
|
|
5524
|
+
(0, import_log15.log)("opened", void 0, {
|
|
5525
|
+
F: __dxlog_file18,
|
|
5526
|
+
L: 166,
|
|
5360
5527
|
S: this,
|
|
5361
5528
|
C: (f, a) => f(...a)
|
|
5362
5529
|
});
|
|
5363
5530
|
}
|
|
5364
5531
|
async _close(ctx) {
|
|
5365
|
-
(0,
|
|
5366
|
-
F:
|
|
5367
|
-
L:
|
|
5532
|
+
(0, import_log15.log)("closing...", void 0, {
|
|
5533
|
+
F: __dxlog_file18,
|
|
5534
|
+
L: 170,
|
|
5368
5535
|
S: this,
|
|
5369
5536
|
C: (f, a) => f(...a)
|
|
5370
5537
|
});
|
|
@@ -5379,23 +5546,23 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5379
5546
|
await this.echoHost.close(ctx);
|
|
5380
5547
|
await this.networkManager.close();
|
|
5381
5548
|
await this.signalManager.close();
|
|
5382
|
-
(0,
|
|
5383
|
-
F:
|
|
5384
|
-
L:
|
|
5549
|
+
(0, import_log15.log)("closed", void 0, {
|
|
5550
|
+
F: __dxlog_file18,
|
|
5551
|
+
L: 182,
|
|
5385
5552
|
S: this,
|
|
5386
5553
|
C: (f, a) => f(...a)
|
|
5387
5554
|
});
|
|
5388
5555
|
}
|
|
5389
5556
|
async createIdentity(params = {}) {
|
|
5390
5557
|
const identity = await this.identityManager.createIdentity(params);
|
|
5391
|
-
await this._initialize(new
|
|
5558
|
+
await this._initialize(new import_context13.Context());
|
|
5392
5559
|
return identity;
|
|
5393
5560
|
}
|
|
5394
5561
|
getInvitationHandler(invitation) {
|
|
5395
5562
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
5396
5563
|
(0, import_invariant16.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
5397
|
-
F:
|
|
5398
|
-
L:
|
|
5564
|
+
F: __dxlog_file18,
|
|
5565
|
+
L: 193,
|
|
5399
5566
|
S: this,
|
|
5400
5567
|
A: [
|
|
5401
5568
|
"factory",
|
|
@@ -5414,7 +5581,7 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5414
5581
|
}
|
|
5415
5582
|
async _acceptIdentity(params) {
|
|
5416
5583
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
5417
|
-
await this._initialize(new
|
|
5584
|
+
await this._initialize(new import_context13.Context());
|
|
5418
5585
|
return identity;
|
|
5419
5586
|
}
|
|
5420
5587
|
async _checkStorageVersion() {
|
|
@@ -5425,9 +5592,9 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5425
5592
|
}
|
|
5426
5593
|
// Called when identity is created.
|
|
5427
5594
|
async _initialize(ctx) {
|
|
5428
|
-
(0,
|
|
5429
|
-
F:
|
|
5430
|
-
L:
|
|
5595
|
+
(0, import_log15.log)("initializing spaces...", void 0, {
|
|
5596
|
+
F: __dxlog_file18,
|
|
5597
|
+
L: 224,
|
|
5431
5598
|
S: this,
|
|
5432
5599
|
C: (f, a) => f(...a)
|
|
5433
5600
|
});
|
|
@@ -5447,10 +5614,10 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5447
5614
|
};
|
|
5448
5615
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.echoHost, this.invitationsManager, this._runtimeParams);
|
|
5449
5616
|
await this.dataSpaceManager.open();
|
|
5450
|
-
this._handlerFactories.set(
|
|
5617
|
+
this._handlerFactories.set(import_services15.Invitation.Kind.SPACE, (invitation) => {
|
|
5451
5618
|
(0, import_invariant16.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
5452
|
-
F:
|
|
5453
|
-
L:
|
|
5619
|
+
F: __dxlog_file18,
|
|
5620
|
+
L: 249,
|
|
5454
5621
|
S: this,
|
|
5455
5622
|
A: [
|
|
5456
5623
|
"this.dataSpaceManager",
|
|
@@ -5462,7 +5629,7 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5462
5629
|
this.initialized.wake();
|
|
5463
5630
|
this._deviceSpaceSync = {
|
|
5464
5631
|
processCredential: async (credential) => {
|
|
5465
|
-
const assertion = (0,
|
|
5632
|
+
const assertion = (0, import_credentials20.getCredentialAssertion)(credential);
|
|
5466
5633
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
5467
5634
|
return;
|
|
5468
5635
|
}
|
|
@@ -5470,33 +5637,33 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5470
5637
|
return;
|
|
5471
5638
|
}
|
|
5472
5639
|
if (!this.dataSpaceManager) {
|
|
5473
|
-
(0,
|
|
5640
|
+
(0, import_log15.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
5474
5641
|
details: assertion
|
|
5475
5642
|
}, {
|
|
5476
|
-
F:
|
|
5477
|
-
L:
|
|
5643
|
+
F: __dxlog_file18,
|
|
5644
|
+
L: 265,
|
|
5478
5645
|
S: this,
|
|
5479
5646
|
C: (f, a) => f(...a)
|
|
5480
5647
|
});
|
|
5481
5648
|
return;
|
|
5482
5649
|
}
|
|
5483
5650
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
5484
|
-
(0,
|
|
5651
|
+
(0, import_log15.log)("space already exists, ignoring space admission", {
|
|
5485
5652
|
details: assertion
|
|
5486
5653
|
}, {
|
|
5487
|
-
F:
|
|
5488
|
-
L:
|
|
5654
|
+
F: __dxlog_file18,
|
|
5655
|
+
L: 269,
|
|
5489
5656
|
S: this,
|
|
5490
5657
|
C: (f, a) => f(...a)
|
|
5491
5658
|
});
|
|
5492
5659
|
return;
|
|
5493
5660
|
}
|
|
5494
5661
|
try {
|
|
5495
|
-
(0,
|
|
5662
|
+
(0, import_log15.log)("accepting space recorded in halo", {
|
|
5496
5663
|
details: assertion
|
|
5497
5664
|
}, {
|
|
5498
|
-
F:
|
|
5499
|
-
L:
|
|
5665
|
+
F: __dxlog_file18,
|
|
5666
|
+
L: 274,
|
|
5500
5667
|
S: this,
|
|
5501
5668
|
C: (f, a) => f(...a)
|
|
5502
5669
|
});
|
|
@@ -5505,9 +5672,9 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5505
5672
|
genesisFeedKey: assertion.genesisFeedKey
|
|
5506
5673
|
});
|
|
5507
5674
|
} catch (err) {
|
|
5508
|
-
|
|
5509
|
-
F:
|
|
5510
|
-
L:
|
|
5675
|
+
import_log15.log.catch(err, void 0, {
|
|
5676
|
+
F: __dxlog_file18,
|
|
5677
|
+
L: 280,
|
|
5511
5678
|
S: this,
|
|
5512
5679
|
C: (f, a) => f(...a)
|
|
5513
5680
|
});
|
|
@@ -5559,7 +5726,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
5559
5726
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5560
5727
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5561
5728
|
}
|
|
5562
|
-
var
|
|
5729
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
5563
5730
|
var Lock = class {
|
|
5564
5731
|
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
5565
5732
|
this._lockPath = lockPath;
|
|
@@ -5570,16 +5737,16 @@ var Lock = class {
|
|
|
5570
5737
|
return this._lockPath;
|
|
5571
5738
|
}
|
|
5572
5739
|
async acquire() {
|
|
5573
|
-
(0,
|
|
5574
|
-
F:
|
|
5740
|
+
(0, import_log16.log)("acquiring lock...", void 0, {
|
|
5741
|
+
F: __dxlog_file19,
|
|
5575
5742
|
L: 32,
|
|
5576
5743
|
S: this,
|
|
5577
5744
|
C: (f, a) => f(...a)
|
|
5578
5745
|
});
|
|
5579
5746
|
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
5580
5747
|
await this._onAcquire?.();
|
|
5581
|
-
(0,
|
|
5582
|
-
F:
|
|
5748
|
+
(0, import_log16.log)("acquired lock", void 0, {
|
|
5749
|
+
F: __dxlog_file19,
|
|
5583
5750
|
L: 37,
|
|
5584
5751
|
S: this,
|
|
5585
5752
|
C: (f, a) => f(...a)
|
|
@@ -5588,7 +5755,7 @@ var Lock = class {
|
|
|
5588
5755
|
async release() {
|
|
5589
5756
|
await this._onRelease?.();
|
|
5590
5757
|
(0, import_invariant17.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
5591
|
-
F:
|
|
5758
|
+
F: __dxlog_file19,
|
|
5592
5759
|
L: 42,
|
|
5593
5760
|
S: this,
|
|
5594
5761
|
A: [
|
|
@@ -5600,11 +5767,11 @@ var Lock = class {
|
|
|
5600
5767
|
}
|
|
5601
5768
|
};
|
|
5602
5769
|
_ts_decorate7([
|
|
5603
|
-
|
|
5770
|
+
import_log16.logInfo
|
|
5604
5771
|
], Lock.prototype, "lockKey", null);
|
|
5605
5772
|
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
5606
5773
|
var getRootPath = (config) => {
|
|
5607
|
-
const { dataRoot = (0, import_util10.isNode)() ?
|
|
5774
|
+
const { dataRoot = (0, import_util10.isNode)() ? import_client_protocol6.DX_DATA : "dxos/storage" } = config ?? {};
|
|
5608
5775
|
return `${dataRoot}/`;
|
|
5609
5776
|
};
|
|
5610
5777
|
var isPersistent = (config) => {
|
|
@@ -5655,12 +5822,12 @@ var toStorageType = (type) => {
|
|
|
5655
5822
|
};
|
|
5656
5823
|
var createLevel = async (config) => {
|
|
5657
5824
|
const persistent = isPersistent(config);
|
|
5658
|
-
const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${
|
|
5825
|
+
const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys14.PublicKey.random().toHex()}`;
|
|
5659
5826
|
const level = (0, import_kv_store.createLevel)(storagePath);
|
|
5660
5827
|
await level.open();
|
|
5661
5828
|
return level;
|
|
5662
5829
|
};
|
|
5663
|
-
var
|
|
5830
|
+
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
5664
5831
|
var DevicesServiceImpl = class {
|
|
5665
5832
|
constructor(_identityManager) {
|
|
5666
5833
|
this._identityManager = _identityManager;
|
|
@@ -5678,7 +5845,7 @@ var DevicesServiceImpl = class {
|
|
|
5678
5845
|
});
|
|
5679
5846
|
} else {
|
|
5680
5847
|
(0, import_invariant19.invariant)(this._identityManager.identity?.presence, "presence not present", {
|
|
5681
|
-
F:
|
|
5848
|
+
F: __dxlog_file20,
|
|
5682
5849
|
L: 32,
|
|
5683
5850
|
S: this,
|
|
5684
5851
|
A: [
|
|
@@ -5693,9 +5860,9 @@ var DevicesServiceImpl = class {
|
|
|
5693
5860
|
const peerState = peers.find((peer) => peer.identityKey.equals(key));
|
|
5694
5861
|
return {
|
|
5695
5862
|
deviceKey: key,
|
|
5696
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ?
|
|
5863
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services17.DeviceKind.CURRENT : import_services17.DeviceKind.TRUSTED,
|
|
5697
5864
|
profile,
|
|
5698
|
-
presence: isMe ?
|
|
5865
|
+
presence: isMe ? import_services17.Device.PresenceState.ONLINE : peerState ? import_services17.Device.PresenceState.ONLINE : import_services17.Device.PresenceState.OFFLINE
|
|
5699
5866
|
};
|
|
5700
5867
|
})
|
|
5701
5868
|
});
|
|
@@ -5744,7 +5911,7 @@ var DiagnosticsCollector = class {
|
|
|
5744
5911
|
}
|
|
5745
5912
|
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
5746
5913
|
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
5747
|
-
keys: options.humanize ?
|
|
5914
|
+
keys: options.humanize ? import_services18.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services18.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
5748
5915
|
}, {
|
|
5749
5916
|
timeout: GET_DIAGNOSTICS_RPC_TIMEOUT
|
|
5750
5917
|
});
|
|
@@ -5759,7 +5926,7 @@ var DiagnosticsCollector = class {
|
|
|
5759
5926
|
client: clientDiagnostics,
|
|
5760
5927
|
broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
|
|
5761
5928
|
};
|
|
5762
|
-
return JSON.parse(JSON.stringify(diagnostics, (0,
|
|
5929
|
+
return JSON.parse(JSON.stringify(diagnostics, (0, import_util11.jsonKeyReplacer)(options)));
|
|
5763
5930
|
}
|
|
5764
5931
|
};
|
|
5765
5932
|
var findSystemServiceProvider = () => {
|
|
@@ -5769,35 +5936,35 @@ var findSystemServiceProvider = () => {
|
|
|
5769
5936
|
};
|
|
5770
5937
|
var findConfigs = () => {
|
|
5771
5938
|
const configs = import_tracing10.TRACE_PROCESSOR.findResourcesByAnnotation(import_config3.ConfigResource);
|
|
5772
|
-
return configs.map((r) => r.instance.deref()).filter(
|
|
5939
|
+
return configs.map((r) => r.instance.deref()).filter(import_util11.nonNullable);
|
|
5773
5940
|
};
|
|
5774
5941
|
var LoggingServiceImpl = class {
|
|
5775
5942
|
constructor() {
|
|
5776
5943
|
this._logs = new import_async20.Event();
|
|
5777
5944
|
this._started = Date.now();
|
|
5778
|
-
this._sessionId =
|
|
5945
|
+
this._sessionId = import_keys17.PublicKey.random().toHex();
|
|
5779
5946
|
this._logProcessor = (_config, entry2) => {
|
|
5780
5947
|
this._logs.emit(entry2);
|
|
5781
5948
|
};
|
|
5782
5949
|
}
|
|
5783
5950
|
async open() {
|
|
5784
|
-
|
|
5951
|
+
import_log18.log.runtimeConfig.processors.push(this._logProcessor);
|
|
5785
5952
|
}
|
|
5786
5953
|
async close() {
|
|
5787
|
-
const index =
|
|
5788
|
-
|
|
5954
|
+
const index = import_log18.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
5955
|
+
import_log18.log.runtimeConfig.processors.splice(index, 1);
|
|
5789
5956
|
}
|
|
5790
5957
|
async controlMetrics({ reset, record }) {
|
|
5791
5958
|
if (reset) {
|
|
5792
|
-
|
|
5959
|
+
import_util13.tracer.clear();
|
|
5793
5960
|
}
|
|
5794
5961
|
if (record === true) {
|
|
5795
|
-
|
|
5962
|
+
import_util13.tracer.start();
|
|
5796
5963
|
} else if (record === false) {
|
|
5797
|
-
|
|
5964
|
+
import_util13.tracer.stop();
|
|
5798
5965
|
}
|
|
5799
5966
|
return {
|
|
5800
|
-
recording:
|
|
5967
|
+
recording: import_util13.tracer.recording
|
|
5801
5968
|
};
|
|
5802
5969
|
}
|
|
5803
5970
|
/**
|
|
@@ -5805,10 +5972,10 @@ var LoggingServiceImpl = class {
|
|
|
5805
5972
|
*/
|
|
5806
5973
|
queryMetrics({ interval = 5e3 }) {
|
|
5807
5974
|
const getNumericalValues = (key) => {
|
|
5808
|
-
const events =
|
|
5975
|
+
const events = import_util13.tracer.get(key) ?? [];
|
|
5809
5976
|
return {
|
|
5810
5977
|
key,
|
|
5811
|
-
stats: (0,
|
|
5978
|
+
stats: (0, import_util13.numericalValues)(events, "duration")
|
|
5812
5979
|
};
|
|
5813
5980
|
};
|
|
5814
5981
|
return new import_codec_protobuf13.Stream(({ next }) => {
|
|
@@ -5846,7 +6013,7 @@ var LoggingServiceImpl = class {
|
|
|
5846
6013
|
}
|
|
5847
6014
|
const record = {
|
|
5848
6015
|
...entry2,
|
|
5849
|
-
context: (0,
|
|
6016
|
+
context: (0, import_util13.jsonify)((0, import_log18.getContextFromEntry)(entry2)),
|
|
5850
6017
|
timestamp: /* @__PURE__ */ new Date(),
|
|
5851
6018
|
meta: {
|
|
5852
6019
|
// TODO(dmaretskyi): Fix proto.
|
|
@@ -5855,7 +6022,7 @@ var LoggingServiceImpl = class {
|
|
|
5855
6022
|
scope: {
|
|
5856
6023
|
hostSessionId: this._sessionId,
|
|
5857
6024
|
uptimeSeconds: (Date.now() - this._started) / 1e3,
|
|
5858
|
-
name: (0,
|
|
6025
|
+
name: (0, import_util13.getDebugName)(entry2.meta?.S)
|
|
5859
6026
|
}
|
|
5860
6027
|
}
|
|
5861
6028
|
};
|
|
@@ -5872,16 +6039,16 @@ var LoggingServiceImpl = class {
|
|
|
5872
6039
|
};
|
|
5873
6040
|
var matchFilter = (filter, level, path2, options) => {
|
|
5874
6041
|
switch (options) {
|
|
5875
|
-
case
|
|
6042
|
+
case import_services19.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
5876
6043
|
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5877
|
-
case
|
|
6044
|
+
case import_services19.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
5878
6045
|
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5879
6046
|
}
|
|
5880
6047
|
};
|
|
5881
6048
|
var shouldLog = (entry2, request) => {
|
|
5882
|
-
const options = request.options ??
|
|
6049
|
+
const options = request.options ?? import_services19.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5883
6050
|
if (request.filters === void 0) {
|
|
5884
|
-
return options ===
|
|
6051
|
+
return options === import_services19.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5885
6052
|
} else {
|
|
5886
6053
|
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
5887
6054
|
}
|
|
@@ -5936,9 +6103,9 @@ var SystemServiceImpl = class {
|
|
|
5936
6103
|
const diagnostics = await this._getDiagnostics();
|
|
5937
6104
|
return {
|
|
5938
6105
|
timestamp: /* @__PURE__ */ new Date(),
|
|
5939
|
-
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0,
|
|
5940
|
-
truncate: keys ===
|
|
5941
|
-
humanize: keys ===
|
|
6106
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util14.jsonKeyReplacer)({
|
|
6107
|
+
truncate: keys === import_services20.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
6108
|
+
humanize: keys === import_services20.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
5942
6109
|
})))
|
|
5943
6110
|
};
|
|
5944
6111
|
}
|
|
@@ -5979,7 +6146,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
5979
6146
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5980
6147
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5981
6148
|
}
|
|
5982
|
-
var
|
|
6149
|
+
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
5983
6150
|
var ClientServicesHost = class {
|
|
5984
6151
|
constructor({
|
|
5985
6152
|
config,
|
|
@@ -5999,7 +6166,7 @@ var ClientServicesHost = class {
|
|
|
5999
6166
|
this._storage = storage;
|
|
6000
6167
|
this._level = level;
|
|
6001
6168
|
this._callbacks = callbacks;
|
|
6002
|
-
this._runtimeParams = runtimeParams;
|
|
6169
|
+
this._runtimeParams = runtimeParams ?? {};
|
|
6003
6170
|
if (config) {
|
|
6004
6171
|
this.initialize({
|
|
6005
6172
|
config,
|
|
@@ -6012,7 +6179,7 @@ var ClientServicesHost = class {
|
|
|
6012
6179
|
lockKey,
|
|
6013
6180
|
onAcquire: () => {
|
|
6014
6181
|
if (!this._opening) {
|
|
6015
|
-
void this.open(new
|
|
6182
|
+
void this.open(new import_context14.Context());
|
|
6016
6183
|
}
|
|
6017
6184
|
},
|
|
6018
6185
|
onRelease: () => this.close()
|
|
@@ -6021,14 +6188,14 @@ var ClientServicesHost = class {
|
|
|
6021
6188
|
this._systemService = new SystemServiceImpl({
|
|
6022
6189
|
config: () => this._config,
|
|
6023
6190
|
statusUpdate: this._statusUpdate,
|
|
6024
|
-
getCurrentStatus: () => this.isOpen ?
|
|
6191
|
+
getCurrentStatus: () => this.isOpen ? import_services16.SystemStatus.ACTIVE : import_services16.SystemStatus.INACTIVE,
|
|
6025
6192
|
getDiagnostics: () => {
|
|
6026
6193
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
6027
6194
|
},
|
|
6028
6195
|
onUpdateStatus: async (status) => {
|
|
6029
|
-
if (!this.isOpen && status ===
|
|
6196
|
+
if (!this.isOpen && status === import_services16.SystemStatus.ACTIVE) {
|
|
6030
6197
|
await this._resourceLock?.acquire();
|
|
6031
|
-
} else if (this.isOpen && status ===
|
|
6198
|
+
} else if (this.isOpen && status === import_services16.SystemStatus.INACTIVE) {
|
|
6032
6199
|
await this._resourceLock?.release();
|
|
6033
6200
|
}
|
|
6034
6201
|
},
|
|
@@ -6038,7 +6205,7 @@ var ClientServicesHost = class {
|
|
|
6038
6205
|
});
|
|
6039
6206
|
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
6040
6207
|
this._loggingService = new LoggingServiceImpl();
|
|
6041
|
-
this._serviceRegistry = new ServiceRegistry(
|
|
6208
|
+
this._serviceRegistry = new ServiceRegistry(import_client_protocol7.clientServiceBundle, {
|
|
6042
6209
|
SystemService: this._systemService,
|
|
6043
6210
|
TracingService: this._tracingService
|
|
6044
6211
|
});
|
|
@@ -6068,24 +6235,24 @@ var ClientServicesHost = class {
|
|
|
6068
6235
|
*/
|
|
6069
6236
|
initialize({ config, ...options }) {
|
|
6070
6237
|
(0, import_invariant18.invariant)(!this._open, "service host is open", {
|
|
6071
|
-
F:
|
|
6072
|
-
L:
|
|
6238
|
+
F: __dxlog_file21,
|
|
6239
|
+
L: 186,
|
|
6073
6240
|
S: this,
|
|
6074
6241
|
A: [
|
|
6075
6242
|
"!this._open",
|
|
6076
6243
|
"'service host is open'"
|
|
6077
6244
|
]
|
|
6078
6245
|
});
|
|
6079
|
-
(0,
|
|
6080
|
-
F:
|
|
6081
|
-
L:
|
|
6246
|
+
(0, import_log17.log)("initializing...", void 0, {
|
|
6247
|
+
F: __dxlog_file21,
|
|
6248
|
+
L: 187,
|
|
6082
6249
|
S: this,
|
|
6083
6250
|
C: (f, a) => f(...a)
|
|
6084
6251
|
});
|
|
6085
6252
|
if (config) {
|
|
6086
6253
|
(0, import_invariant18.invariant)(!this._config, "config already set", {
|
|
6087
|
-
F:
|
|
6088
|
-
L:
|
|
6254
|
+
F: __dxlog_file21,
|
|
6255
|
+
L: 190,
|
|
6089
6256
|
S: this,
|
|
6090
6257
|
A: [
|
|
6091
6258
|
"!this._config",
|
|
@@ -6098,9 +6265,9 @@ var ClientServicesHost = class {
|
|
|
6098
6265
|
}
|
|
6099
6266
|
}
|
|
6100
6267
|
if (!options.signalManager) {
|
|
6101
|
-
|
|
6102
|
-
F:
|
|
6103
|
-
L:
|
|
6268
|
+
import_log17.log.warn("running signaling without telemetry metadata.", void 0, {
|
|
6269
|
+
F: __dxlog_file21,
|
|
6270
|
+
L: 198,
|
|
6104
6271
|
S: this,
|
|
6105
6272
|
C: (f, a) => f(...a)
|
|
6106
6273
|
});
|
|
@@ -6110,8 +6277,8 @@ var ClientServicesHost = class {
|
|
|
6110
6277
|
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
6111
6278
|
this._signalManager = signalManager;
|
|
6112
6279
|
(0, import_invariant18.invariant)(!this._networkManager, "network manager already set", {
|
|
6113
|
-
F:
|
|
6114
|
-
L:
|
|
6280
|
+
F: __dxlog_file21,
|
|
6281
|
+
L: 209,
|
|
6115
6282
|
S: this,
|
|
6116
6283
|
A: [
|
|
6117
6284
|
"!this._networkManager",
|
|
@@ -6123,9 +6290,9 @@ var ClientServicesHost = class {
|
|
|
6123
6290
|
transportFactory,
|
|
6124
6291
|
signalManager
|
|
6125
6292
|
});
|
|
6126
|
-
(0,
|
|
6127
|
-
F:
|
|
6128
|
-
L:
|
|
6293
|
+
(0, import_log17.log)("initialized", void 0, {
|
|
6294
|
+
F: __dxlog_file21,
|
|
6295
|
+
L: 216,
|
|
6129
6296
|
S: this,
|
|
6130
6297
|
C: (f, a) => f(...a)
|
|
6131
6298
|
});
|
|
@@ -6134,18 +6301,18 @@ var ClientServicesHost = class {
|
|
|
6134
6301
|
if (this._open) {
|
|
6135
6302
|
return;
|
|
6136
6303
|
}
|
|
6137
|
-
const traceId =
|
|
6138
|
-
|
|
6304
|
+
const traceId = import_keys15.PublicKey.random().toHex();
|
|
6305
|
+
import_log17.log.trace("dxos.client-services.host.open", import_protocols15.trace.begin({
|
|
6139
6306
|
id: traceId
|
|
6140
6307
|
}), {
|
|
6141
|
-
F:
|
|
6142
|
-
L:
|
|
6308
|
+
F: __dxlog_file21,
|
|
6309
|
+
L: 227,
|
|
6143
6310
|
S: this,
|
|
6144
6311
|
C: (f, a) => f(...a)
|
|
6145
6312
|
});
|
|
6146
6313
|
(0, import_invariant18.invariant)(this._config, "config not set", {
|
|
6147
|
-
F:
|
|
6148
|
-
L:
|
|
6314
|
+
F: __dxlog_file21,
|
|
6315
|
+
L: 229,
|
|
6149
6316
|
S: this,
|
|
6150
6317
|
A: [
|
|
6151
6318
|
"this._config",
|
|
@@ -6153,8 +6320,8 @@ var ClientServicesHost = class {
|
|
|
6153
6320
|
]
|
|
6154
6321
|
});
|
|
6155
6322
|
(0, import_invariant18.invariant)(this._storage, "storage not set", {
|
|
6156
|
-
F:
|
|
6157
|
-
L:
|
|
6323
|
+
F: __dxlog_file21,
|
|
6324
|
+
L: 230,
|
|
6158
6325
|
S: this,
|
|
6159
6326
|
A: [
|
|
6160
6327
|
"this._storage",
|
|
@@ -6162,8 +6329,8 @@ var ClientServicesHost = class {
|
|
|
6162
6329
|
]
|
|
6163
6330
|
});
|
|
6164
6331
|
(0, import_invariant18.invariant)(this._signalManager, "signal manager not set", {
|
|
6165
|
-
F:
|
|
6166
|
-
L:
|
|
6332
|
+
F: __dxlog_file21,
|
|
6333
|
+
L: 231,
|
|
6167
6334
|
S: this,
|
|
6168
6335
|
A: [
|
|
6169
6336
|
"this._signalManager",
|
|
@@ -6171,8 +6338,8 @@ var ClientServicesHost = class {
|
|
|
6171
6338
|
]
|
|
6172
6339
|
});
|
|
6173
6340
|
(0, import_invariant18.invariant)(this._networkManager, "network manager not set", {
|
|
6174
|
-
F:
|
|
6175
|
-
L:
|
|
6341
|
+
F: __dxlog_file21,
|
|
6342
|
+
L: 232,
|
|
6176
6343
|
S: this,
|
|
6177
6344
|
A: [
|
|
6178
6345
|
"this._networkManager",
|
|
@@ -6180,11 +6347,11 @@ var ClientServicesHost = class {
|
|
|
6180
6347
|
]
|
|
6181
6348
|
});
|
|
6182
6349
|
this._opening = true;
|
|
6183
|
-
(0,
|
|
6350
|
+
(0, import_log17.log)("opening...", {
|
|
6184
6351
|
lockKey: this._resourceLock?.lockKey
|
|
6185
6352
|
}, {
|
|
6186
|
-
F:
|
|
6187
|
-
L:
|
|
6353
|
+
F: __dxlog_file21,
|
|
6354
|
+
L: 235,
|
|
6188
6355
|
S: this,
|
|
6189
6356
|
C: (f, a) => f(...a)
|
|
6190
6357
|
});
|
|
@@ -6195,9 +6362,10 @@ var ClientServicesHost = class {
|
|
|
6195
6362
|
await this._level.open();
|
|
6196
6363
|
await this._loggingService.open();
|
|
6197
6364
|
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
|
|
6365
|
+
const identityService = new IdentityServiceImpl(this._serviceContext.identityManager, this._serviceContext.keyring, () => this._serviceContext.dataSpaceManager, (params) => this._createIdentity(params), (profile) => this._serviceContext.broadcastProfileUpdate(profile));
|
|
6198
6366
|
this._serviceRegistry.setServices({
|
|
6199
6367
|
SystemService: this._systemService,
|
|
6200
|
-
IdentityService:
|
|
6368
|
+
IdentityService: identityService,
|
|
6201
6369
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
|
|
6202
6370
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
6203
6371
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
|
|
@@ -6217,12 +6385,13 @@ var ClientServicesHost = class {
|
|
|
6217
6385
|
})
|
|
6218
6386
|
});
|
|
6219
6387
|
await this._serviceContext.open(ctx);
|
|
6388
|
+
await identityService.open();
|
|
6220
6389
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
6221
6390
|
if (devtoolsProxy) {
|
|
6222
6391
|
this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
|
|
6223
6392
|
url: devtoolsProxy,
|
|
6224
6393
|
requested: {},
|
|
6225
|
-
exposed:
|
|
6394
|
+
exposed: import_client_protocol7.clientServiceBundle,
|
|
6226
6395
|
handlers: this.services
|
|
6227
6396
|
});
|
|
6228
6397
|
void this._devtoolsProxy.open();
|
|
@@ -6232,18 +6401,18 @@ var ClientServicesHost = class {
|
|
|
6232
6401
|
this._open = true;
|
|
6233
6402
|
this._statusUpdate.emit();
|
|
6234
6403
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6235
|
-
(0,
|
|
6404
|
+
(0, import_log17.log)("opened", {
|
|
6236
6405
|
deviceKey
|
|
6237
6406
|
}, {
|
|
6238
|
-
F:
|
|
6407
|
+
F: __dxlog_file21,
|
|
6239
6408
|
L: 314,
|
|
6240
6409
|
S: this,
|
|
6241
6410
|
C: (f, a) => f(...a)
|
|
6242
6411
|
});
|
|
6243
|
-
|
|
6412
|
+
import_log17.log.trace("dxos.client-services.host.open", import_protocols15.trace.end({
|
|
6244
6413
|
id: traceId
|
|
6245
6414
|
}), {
|
|
6246
|
-
F:
|
|
6415
|
+
F: __dxlog_file21,
|
|
6247
6416
|
L: 315,
|
|
6248
6417
|
S: this,
|
|
6249
6418
|
C: (f, a) => f(...a)
|
|
@@ -6254,10 +6423,10 @@ var ClientServicesHost = class {
|
|
|
6254
6423
|
return;
|
|
6255
6424
|
}
|
|
6256
6425
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6257
|
-
(0,
|
|
6426
|
+
(0, import_log17.log)("closing...", {
|
|
6258
6427
|
deviceKey
|
|
6259
6428
|
}, {
|
|
6260
|
-
F:
|
|
6429
|
+
F: __dxlog_file21,
|
|
6261
6430
|
L: 326,
|
|
6262
6431
|
S: this,
|
|
6263
6432
|
C: (f, a) => f(...a)
|
|
@@ -6272,43 +6441,43 @@ var ClientServicesHost = class {
|
|
|
6272
6441
|
await this._level?.close();
|
|
6273
6442
|
this._open = false;
|
|
6274
6443
|
this._statusUpdate.emit();
|
|
6275
|
-
(0,
|
|
6444
|
+
(0, import_log17.log)("closed", {
|
|
6276
6445
|
deviceKey
|
|
6277
6446
|
}, {
|
|
6278
|
-
F:
|
|
6447
|
+
F: __dxlog_file21,
|
|
6279
6448
|
L: 335,
|
|
6280
6449
|
S: this,
|
|
6281
6450
|
C: (f, a) => f(...a)
|
|
6282
6451
|
});
|
|
6283
6452
|
}
|
|
6284
6453
|
async reset() {
|
|
6285
|
-
const traceId =
|
|
6286
|
-
|
|
6454
|
+
const traceId = import_keys15.PublicKey.random().toHex();
|
|
6455
|
+
import_log17.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.begin({
|
|
6287
6456
|
id: traceId
|
|
6288
6457
|
}), {
|
|
6289
|
-
F:
|
|
6458
|
+
F: __dxlog_file21,
|
|
6290
6459
|
L: 340,
|
|
6291
6460
|
S: this,
|
|
6292
6461
|
C: (f, a) => f(...a)
|
|
6293
6462
|
});
|
|
6294
|
-
|
|
6295
|
-
F:
|
|
6463
|
+
import_log17.log.info("resetting...", void 0, {
|
|
6464
|
+
F: __dxlog_file21,
|
|
6296
6465
|
L: 342,
|
|
6297
6466
|
S: this,
|
|
6298
6467
|
C: (f, a) => f(...a)
|
|
6299
6468
|
});
|
|
6300
6469
|
await this._serviceContext?.close();
|
|
6301
6470
|
await this._storage.reset();
|
|
6302
|
-
|
|
6303
|
-
F:
|
|
6471
|
+
import_log17.log.info("reset", void 0, {
|
|
6472
|
+
F: __dxlog_file21,
|
|
6304
6473
|
L: 345,
|
|
6305
6474
|
S: this,
|
|
6306
6475
|
C: (f, a) => f(...a)
|
|
6307
6476
|
});
|
|
6308
|
-
|
|
6477
|
+
import_log17.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.end({
|
|
6309
6478
|
id: traceId
|
|
6310
6479
|
}), {
|
|
6311
|
-
F:
|
|
6480
|
+
F: __dxlog_file21,
|
|
6312
6481
|
L: 346,
|
|
6313
6482
|
S: this,
|
|
6314
6483
|
C: (f, a) => f(...a)
|
|
@@ -6318,38 +6487,6 @@ var ClientServicesHost = class {
|
|
|
6318
6487
|
async _createIdentity(params) {
|
|
6319
6488
|
const identity = await this._serviceContext.createIdentity(params);
|
|
6320
6489
|
await this._serviceContext.initialized.wait();
|
|
6321
|
-
const space = await this._serviceContext.dataSpaceManager.createSpace();
|
|
6322
|
-
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
6323
|
-
(0, import_invariant18.invariant)(automergeIndex, void 0, {
|
|
6324
|
-
F: __dxlog_file20,
|
|
6325
|
-
L: 358,
|
|
6326
|
-
S: this,
|
|
6327
|
-
A: [
|
|
6328
|
-
"automergeIndex",
|
|
6329
|
-
""
|
|
6330
|
-
]
|
|
6331
|
-
});
|
|
6332
|
-
const document = this._serviceContext.echoHost.automergeRepo.find(automergeIndex);
|
|
6333
|
-
await document.whenReady();
|
|
6334
|
-
const properties = {
|
|
6335
|
-
system: {
|
|
6336
|
-
type: (0, import_echo_protocol.encodeReference)((0, import_echo_schema2.getTypeReference)(import_client_protocol6.PropertiesType))
|
|
6337
|
-
},
|
|
6338
|
-
data: {
|
|
6339
|
-
[import_client_protocol6.defaultKey]: identity.identityKey.toHex()
|
|
6340
|
-
},
|
|
6341
|
-
meta: {
|
|
6342
|
-
keys: []
|
|
6343
|
-
}
|
|
6344
|
-
};
|
|
6345
|
-
const propertiesId = import_keys14.PublicKey.random().toHex();
|
|
6346
|
-
document.change((doc) => {
|
|
6347
|
-
(0, import_util11.assignDeep)(doc, [
|
|
6348
|
-
"objects",
|
|
6349
|
-
propertiesId
|
|
6350
|
-
], properties);
|
|
6351
|
-
});
|
|
6352
|
-
await this._serviceContext.echoHost.flush();
|
|
6353
6490
|
return identity;
|
|
6354
6491
|
}
|
|
6355
6492
|
};
|
|
@@ -6411,4 +6548,4 @@ ClientServicesHost = _ts_decorate8([
|
|
|
6411
6548
|
subscribeToSpaces,
|
|
6412
6549
|
subscribeToSwarmInfo
|
|
6413
6550
|
});
|
|
6414
|
-
//# sourceMappingURL=chunk-
|
|
6551
|
+
//# sourceMappingURL=chunk-ZBIDLLZ4.cjs.map
|