@dxos/client-services 0.5.9-main.bdf733d → 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-KNGR7BYM.mjs → chunk-4IR3JP4U.mjs} +767 -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-WWHTBQNR.cjs → chunk-ZBIDLLZ4.cjs} +982 -824
- 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 +1 -0
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.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 +24 -5
- package/src/packlets/spaces/spaces-service.ts +2 -2
- package/src/packlets/testing/test-builder.ts +12 -10
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-KNGR7BYM.mjs.map +0 -7
- package/dist/lib/node/chunk-WWHTBQNR.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_WWHTBQNR_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,17 +4044,17 @@ 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:
|
|
3938
|
-
L:
|
|
4056
|
+
F: __dxlog_file15,
|
|
4057
|
+
L: 143,
|
|
3939
4058
|
S: this,
|
|
3940
4059
|
C: (f, a) => f(...a)
|
|
3941
4060
|
});
|
|
@@ -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,11 +4469,30 @@ 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;
|
|
4477
|
+
case import_services12.CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT:
|
|
4478
|
+
{
|
|
4479
|
+
(0, import_invariant12.invariant)(options.newAutomergeRoot, void 0, {
|
|
4480
|
+
F: __dxlog_file15,
|
|
4481
|
+
L: 517,
|
|
4482
|
+
S: this,
|
|
4483
|
+
A: [
|
|
4484
|
+
"options.newAutomergeRoot",
|
|
4485
|
+
""
|
|
4486
|
+
]
|
|
4487
|
+
});
|
|
4488
|
+
epoch = {
|
|
4489
|
+
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
4490
|
+
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
4491
|
+
timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe3.Timeframe(),
|
|
4492
|
+
automergeRoot: options.newAutomergeRoot
|
|
4493
|
+
};
|
|
4494
|
+
}
|
|
4495
|
+
break;
|
|
4352
4496
|
}
|
|
4353
4497
|
if (!epoch) {
|
|
4354
4498
|
return;
|
|
@@ -4364,33 +4508,39 @@ var DataSpace = class {
|
|
|
4364
4508
|
})
|
|
4365
4509
|
}
|
|
4366
4510
|
});
|
|
4367
|
-
await this.inner.controlPipeline.state.waitUntilTimeframe(new
|
|
4511
|
+
await this.inner.controlPipeline.state.waitUntilTimeframe(new import_timeframe3.Timeframe([
|
|
4368
4512
|
[
|
|
4369
4513
|
receipt.feedKey,
|
|
4370
4514
|
receipt.seq
|
|
4371
4515
|
]
|
|
4372
4516
|
]));
|
|
4517
|
+
await this._echoHost.updateIndexes();
|
|
4373
4518
|
}
|
|
4374
4519
|
async activate() {
|
|
4375
|
-
if (
|
|
4520
|
+
if (![
|
|
4521
|
+
import_services12.SpaceState.CLOSED,
|
|
4522
|
+
import_services12.SpaceState.INACTIVE
|
|
4523
|
+
].includes(this._state)) {
|
|
4376
4524
|
return;
|
|
4377
4525
|
}
|
|
4378
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
4526
|
+
await this._metadataStore.setSpaceState(this.key, import_services12.SpaceState.ACTIVE);
|
|
4379
4527
|
await this._open();
|
|
4380
4528
|
this.initializeDataPipelineAsync();
|
|
4381
4529
|
}
|
|
4382
4530
|
async deactivate() {
|
|
4383
|
-
if (this._state ===
|
|
4531
|
+
if (this._state === import_services12.SpaceState.INACTIVE) {
|
|
4384
4532
|
return;
|
|
4385
4533
|
}
|
|
4386
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
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]
|
|
4391
4541
|
}, {
|
|
4392
|
-
F:
|
|
4393
|
-
L:
|
|
4542
|
+
F: __dxlog_file15,
|
|
4543
|
+
L: 571,
|
|
4394
4544
|
S: this,
|
|
4395
4545
|
C: (f, a) => f(...a)
|
|
4396
4546
|
});
|
|
@@ -4408,7 +4558,7 @@ _ts_decorate4([
|
|
|
4408
4558
|
], DataSpace.prototype, "key", null);
|
|
4409
4559
|
_ts_decorate4([
|
|
4410
4560
|
import_tracing5.trace.info({
|
|
4411
|
-
enum:
|
|
4561
|
+
enum: import_services12.SpaceState
|
|
4412
4562
|
})
|
|
4413
4563
|
], DataSpace.prototype, "state", null);
|
|
4414
4564
|
_ts_decorate4([
|
|
@@ -4459,7 +4609,7 @@ var findPropertiesObject = (spaceDoc) => {
|
|
|
4459
4609
|
};
|
|
4460
4610
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
4461
4611
|
const credentials = [
|
|
4462
|
-
await (0,
|
|
4612
|
+
await (0, import_credentials17.createCredential)({
|
|
4463
4613
|
signer: keyring,
|
|
4464
4614
|
issuer: space.key,
|
|
4465
4615
|
subject: space.key,
|
|
@@ -4468,14 +4618,14 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
4468
4618
|
spaceKey: space.key
|
|
4469
4619
|
}
|
|
4470
4620
|
}),
|
|
4471
|
-
await (0,
|
|
4621
|
+
await (0, import_credentials17.createCredential)({
|
|
4472
4622
|
signer: keyring,
|
|
4473
4623
|
issuer: space.key,
|
|
4474
4624
|
subject: signingContext.identityKey,
|
|
4475
4625
|
assertion: {
|
|
4476
4626
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
4477
4627
|
spaceKey: space.key,
|
|
4478
|
-
role:
|
|
4628
|
+
role: import_credentials18.SpaceMember.Role.OWNER,
|
|
4479
4629
|
profile: signingContext.getProfile(),
|
|
4480
4630
|
genesisFeedKey: space.controlFeedKey ?? (0, import_debug4.failUndefined)()
|
|
4481
4631
|
}
|
|
@@ -4487,7 +4637,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
4487
4637
|
spaceKey: space.key,
|
|
4488
4638
|
identityKey: signingContext.identityKey,
|
|
4489
4639
|
deviceKey: signingContext.deviceKey,
|
|
4490
|
-
designation:
|
|
4640
|
+
designation: import_credentials18.AdmittedFeed.Designation.CONTROL
|
|
4491
4641
|
}
|
|
4492
4642
|
}),
|
|
4493
4643
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -4497,7 +4647,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
4497
4647
|
spaceKey: space.key,
|
|
4498
4648
|
identityKey: signingContext.identityKey,
|
|
4499
4649
|
deviceKey: signingContext.deviceKey,
|
|
4500
|
-
designation:
|
|
4650
|
+
designation: import_credentials18.AdmittedFeed.Designation.DATA
|
|
4501
4651
|
}
|
|
4502
4652
|
}),
|
|
4503
4653
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -4506,7 +4656,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
4506
4656
|
"@type": "dxos.halo.credentials.Epoch",
|
|
4507
4657
|
number: 0,
|
|
4508
4658
|
previousId: void 0,
|
|
4509
|
-
timeframe: new
|
|
4659
|
+
timeframe: new import_timeframe4.Timeframe(),
|
|
4510
4660
|
snapshotCid: void 0,
|
|
4511
4661
|
automergeRoot
|
|
4512
4662
|
}
|
|
@@ -4531,11 +4681,12 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
4531
4681
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4532
4682
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4533
4683
|
}
|
|
4534
|
-
var
|
|
4684
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
4535
4685
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
4536
4686
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
4687
|
+
var DEFAULT_SPACE_KEY = "__DEFAULT__";
|
|
4537
4688
|
var DataSpaceManager = class {
|
|
4538
|
-
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _echoHost, _invitationsManager,
|
|
4689
|
+
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _echoHost, _invitationsManager, _params) {
|
|
4539
4690
|
this._spaceManager = _spaceManager;
|
|
4540
4691
|
this._metadataStore = _metadataStore;
|
|
4541
4692
|
this._keyring = _keyring;
|
|
@@ -4543,14 +4694,12 @@ var DataSpaceManager = class {
|
|
|
4543
4694
|
this._feedStore = _feedStore;
|
|
4544
4695
|
this._echoHost = _echoHost;
|
|
4545
4696
|
this._invitationsManager = _invitationsManager;
|
|
4546
|
-
this.
|
|
4697
|
+
this._params = _params;
|
|
4698
|
+
this._ctx = new import_context12.Context();
|
|
4547
4699
|
this.updated = new import_async15.Event();
|
|
4548
|
-
this._spaces = new import_util8.ComplexMap(
|
|
4700
|
+
this._spaces = new import_util8.ComplexMap(import_keys12.PublicKey.hash);
|
|
4549
4701
|
this._isOpen = false;
|
|
4550
|
-
this._instanceId =
|
|
4551
|
-
const { spaceMemberPresenceAnnounceInterval = PRESENCE_ANNOUNCE_INTERVAL, spaceMemberPresenceOfflineTimeout = PRESENCE_OFFLINE_TIMEOUT } = params ?? {};
|
|
4552
|
-
this._spaceMemberPresenceAnnounceInterval = spaceMemberPresenceAnnounceInterval;
|
|
4553
|
-
this._spaceMemberPresenceOfflineTimeout = spaceMemberPresenceOfflineTimeout;
|
|
4702
|
+
this._instanceId = import_keys12.PublicKey.random().toHex();
|
|
4554
4703
|
import_tracing6.trace.diagnostic({
|
|
4555
4704
|
id: "spaces",
|
|
4556
4705
|
name: "Spaces",
|
|
@@ -4562,7 +4711,7 @@ var DataSpaceManager = class {
|
|
|
4562
4711
|
const properties = rootDoc && findPropertiesObject(rootDoc);
|
|
4563
4712
|
return {
|
|
4564
4713
|
key: space.key.toHex(),
|
|
4565
|
-
state:
|
|
4714
|
+
state: import_services13.SpaceState[space.state],
|
|
4566
4715
|
name: properties?.[1].data.name ?? null,
|
|
4567
4716
|
inlineObjects: rootDoc ? Object.keys(rootDoc.objects ?? {}).length : null,
|
|
4568
4717
|
linkedObjects: rootDoc ? Object.keys(rootDoc.links ?? {}).length : null,
|
|
@@ -4579,46 +4728,46 @@ var DataSpaceManager = class {
|
|
|
4579
4728
|
return this._spaces;
|
|
4580
4729
|
}
|
|
4581
4730
|
async open() {
|
|
4582
|
-
(0,
|
|
4583
|
-
F:
|
|
4584
|
-
L:
|
|
4731
|
+
(0, import_log13.log)("open", void 0, {
|
|
4732
|
+
F: __dxlog_file16,
|
|
4733
|
+
L: 140,
|
|
4585
4734
|
S: this,
|
|
4586
4735
|
C: (f, a) => f(...a)
|
|
4587
4736
|
});
|
|
4588
|
-
|
|
4737
|
+
import_log13.log.trace("dxos.echo.data-space-manager.open", import_protocols11.trace.begin({
|
|
4589
4738
|
id: this._instanceId
|
|
4590
4739
|
}), {
|
|
4591
|
-
F:
|
|
4592
|
-
L:
|
|
4740
|
+
F: __dxlog_file16,
|
|
4741
|
+
L: 141,
|
|
4593
4742
|
S: this,
|
|
4594
4743
|
C: (f, a) => f(...a)
|
|
4595
4744
|
});
|
|
4596
|
-
(0,
|
|
4745
|
+
(0, import_log13.log)("metadata loaded", {
|
|
4597
4746
|
spaces: this._metadataStore.spaces.length
|
|
4598
4747
|
}, {
|
|
4599
|
-
F:
|
|
4600
|
-
L:
|
|
4748
|
+
F: __dxlog_file16,
|
|
4749
|
+
L: 142,
|
|
4601
4750
|
S: this,
|
|
4602
4751
|
C: (f, a) => f(...a)
|
|
4603
4752
|
});
|
|
4604
4753
|
await (0, import_util8.forEachAsync)(this._metadataStore.spaces, async (spaceMetadata) => {
|
|
4605
4754
|
try {
|
|
4606
|
-
(0,
|
|
4755
|
+
(0, import_log13.log)("load space", {
|
|
4607
4756
|
spaceMetadata
|
|
4608
4757
|
}, {
|
|
4609
|
-
F:
|
|
4610
|
-
L:
|
|
4758
|
+
F: __dxlog_file16,
|
|
4759
|
+
L: 146,
|
|
4611
4760
|
S: this,
|
|
4612
4761
|
C: (f, a) => f(...a)
|
|
4613
4762
|
});
|
|
4614
4763
|
await this._constructSpace(spaceMetadata);
|
|
4615
4764
|
} catch (err) {
|
|
4616
|
-
|
|
4765
|
+
import_log13.log.error("Error loading space", {
|
|
4617
4766
|
spaceMetadata,
|
|
4618
4767
|
err
|
|
4619
4768
|
}, {
|
|
4620
|
-
F:
|
|
4621
|
-
L:
|
|
4769
|
+
F: __dxlog_file16,
|
|
4770
|
+
L: 149,
|
|
4622
4771
|
S: this,
|
|
4623
4772
|
C: (f, a) => f(...a)
|
|
4624
4773
|
});
|
|
@@ -4626,24 +4775,19 @@ var DataSpaceManager = class {
|
|
|
4626
4775
|
});
|
|
4627
4776
|
this._isOpen = true;
|
|
4628
4777
|
this.updated.emit();
|
|
4629
|
-
|
|
4630
|
-
if (space.state !== import_services12.SpaceState.INACTIVE) {
|
|
4631
|
-
space.initializeDataPipelineAsync();
|
|
4632
|
-
}
|
|
4633
|
-
}
|
|
4634
|
-
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({
|
|
4635
4779
|
id: this._instanceId
|
|
4636
4780
|
}), {
|
|
4637
|
-
F:
|
|
4638
|
-
L:
|
|
4781
|
+
F: __dxlog_file16,
|
|
4782
|
+
L: 156,
|
|
4639
4783
|
S: this,
|
|
4640
4784
|
C: (f, a) => f(...a)
|
|
4641
4785
|
});
|
|
4642
4786
|
}
|
|
4643
4787
|
async close() {
|
|
4644
|
-
(0,
|
|
4645
|
-
F:
|
|
4646
|
-
L:
|
|
4788
|
+
(0, import_log13.log)("close", void 0, {
|
|
4789
|
+
F: __dxlog_file16,
|
|
4790
|
+
L: 161,
|
|
4647
4791
|
S: this,
|
|
4648
4792
|
C: (f, a) => f(...a)
|
|
4649
4793
|
});
|
|
@@ -4652,14 +4796,15 @@ var DataSpaceManager = class {
|
|
|
4652
4796
|
for (const space of this._spaces.values()) {
|
|
4653
4797
|
await space.close();
|
|
4654
4798
|
}
|
|
4799
|
+
this._spaces.clear();
|
|
4655
4800
|
}
|
|
4656
4801
|
/**
|
|
4657
4802
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
4658
4803
|
*/
|
|
4659
4804
|
async createSpace() {
|
|
4660
4805
|
(0, import_invariant14.invariant)(this._isOpen, "Not open.", {
|
|
4661
|
-
F:
|
|
4662
|
-
L:
|
|
4806
|
+
F: __dxlog_file16,
|
|
4807
|
+
L: 175,
|
|
4663
4808
|
S: this,
|
|
4664
4809
|
A: [
|
|
4665
4810
|
"this._isOpen",
|
|
@@ -4674,24 +4819,25 @@ var DataSpaceManager = class {
|
|
|
4674
4819
|
genesisFeedKey: controlFeedKey,
|
|
4675
4820
|
controlFeedKey,
|
|
4676
4821
|
dataFeedKey,
|
|
4677
|
-
state:
|
|
4822
|
+
state: import_services13.SpaceState.ACTIVE
|
|
4678
4823
|
};
|
|
4679
|
-
(0,
|
|
4824
|
+
(0, import_log13.log)("creating space...", {
|
|
4680
4825
|
spaceKey
|
|
4681
4826
|
}, {
|
|
4682
|
-
F:
|
|
4683
|
-
L:
|
|
4827
|
+
F: __dxlog_file16,
|
|
4828
|
+
L: 187,
|
|
4684
4829
|
S: this,
|
|
4685
4830
|
C: (f, a) => f(...a)
|
|
4686
4831
|
});
|
|
4687
4832
|
const root = await this._echoHost.createSpaceRoot(spaceKey);
|
|
4688
4833
|
const space = await this._constructSpace(metadata);
|
|
4834
|
+
await space.open();
|
|
4689
4835
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, root.url);
|
|
4690
4836
|
await this._metadataStore.addSpace(metadata);
|
|
4691
4837
|
const memberCredential = credentials[1];
|
|
4692
|
-
(0, import_invariant14.invariant)((0,
|
|
4693
|
-
F:
|
|
4694
|
-
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,
|
|
4695
4841
|
S: this,
|
|
4696
4842
|
A: [
|
|
4697
4843
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -4703,19 +4849,63 @@ var DataSpaceManager = class {
|
|
|
4703
4849
|
this.updated.emit();
|
|
4704
4850
|
return space;
|
|
4705
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
|
+
}
|
|
4706
4896
|
// TODO(burdon): Rename join space.
|
|
4707
4897
|
async acceptSpace(opts) {
|
|
4708
|
-
(0,
|
|
4898
|
+
(0, import_log13.log)("accept space", {
|
|
4709
4899
|
opts
|
|
4710
4900
|
}, {
|
|
4711
|
-
F:
|
|
4712
|
-
L:
|
|
4901
|
+
F: __dxlog_file16,
|
|
4902
|
+
L: 249,
|
|
4713
4903
|
S: this,
|
|
4714
4904
|
C: (f, a) => f(...a)
|
|
4715
4905
|
});
|
|
4716
4906
|
(0, import_invariant14.invariant)(this._isOpen, "Not open.", {
|
|
4717
|
-
F:
|
|
4718
|
-
L:
|
|
4907
|
+
F: __dxlog_file16,
|
|
4908
|
+
L: 250,
|
|
4719
4909
|
S: this,
|
|
4720
4910
|
A: [
|
|
4721
4911
|
"this._isOpen",
|
|
@@ -4723,8 +4913,8 @@ var DataSpaceManager = class {
|
|
|
4723
4913
|
]
|
|
4724
4914
|
});
|
|
4725
4915
|
(0, import_invariant14.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
4726
|
-
F:
|
|
4727
|
-
L:
|
|
4916
|
+
F: __dxlog_file16,
|
|
4917
|
+
L: 251,
|
|
4728
4918
|
S: this,
|
|
4729
4919
|
A: [
|
|
4730
4920
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -4738,6 +4928,7 @@ var DataSpaceManager = class {
|
|
|
4738
4928
|
dataTimeframe: opts.dataTimeframe
|
|
4739
4929
|
};
|
|
4740
4930
|
const space = await this._constructSpace(metadata);
|
|
4931
|
+
await space.open();
|
|
4741
4932
|
await this._metadataStore.addSpace(metadata);
|
|
4742
4933
|
space.initializeDataPipelineAsync();
|
|
4743
4934
|
this.updated.emit();
|
|
@@ -4749,17 +4940,17 @@ var DataSpaceManager = class {
|
|
|
4749
4940
|
* TODO(dmaretskyi): Consider removing.
|
|
4750
4941
|
*/
|
|
4751
4942
|
async waitUntilSpaceReady(spaceKey) {
|
|
4752
|
-
await (0,
|
|
4943
|
+
await (0, import_context12.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
4753
4944
|
const space = this._spaces.get(spaceKey);
|
|
4754
|
-
return !!space && space.state ===
|
|
4945
|
+
return !!space && space.state === import_services13.SpaceState.READY;
|
|
4755
4946
|
}));
|
|
4756
4947
|
}
|
|
4757
4948
|
async _constructSpace(metadata) {
|
|
4758
|
-
(0,
|
|
4949
|
+
(0, import_log13.log)("construct space", {
|
|
4759
4950
|
metadata
|
|
4760
4951
|
}, {
|
|
4761
|
-
F:
|
|
4762
|
-
L:
|
|
4952
|
+
F: __dxlog_file16,
|
|
4953
|
+
L: 285,
|
|
4763
4954
|
S: this,
|
|
4764
4955
|
C: (f, a) => f(...a)
|
|
4765
4956
|
});
|
|
@@ -4767,8 +4958,8 @@ var DataSpaceManager = class {
|
|
|
4767
4958
|
localPeerId: this._signingContext.deviceKey
|
|
4768
4959
|
});
|
|
4769
4960
|
const presence = new import_teleport_extension_gossip2.Presence({
|
|
4770
|
-
announceInterval: this.
|
|
4771
|
-
offlineTimeout: this.
|
|
4961
|
+
announceInterval: this._params?.spaceMemberPresenceAnnounceInterval ?? PRESENCE_ANNOUNCE_INTERVAL,
|
|
4962
|
+
offlineTimeout: this._params?.spaceMemberPresenceOfflineTimeout ?? PRESENCE_OFFLINE_TIMEOUT,
|
|
4772
4963
|
identityKey: this._signingContext.identityKey,
|
|
4773
4964
|
gossip
|
|
4774
4965
|
});
|
|
@@ -4795,15 +4986,15 @@ var DataSpaceManager = class {
|
|
|
4795
4986
|
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
4796
4987
|
},
|
|
4797
4988
|
onAuthFailure: () => {
|
|
4798
|
-
|
|
4799
|
-
F:
|
|
4800
|
-
L:
|
|
4989
|
+
import_log13.log.warn("auth failure", void 0, {
|
|
4990
|
+
F: __dxlog_file16,
|
|
4991
|
+
L: 322,
|
|
4801
4992
|
S: this,
|
|
4802
4993
|
C: (f, a) => f(...a)
|
|
4803
4994
|
});
|
|
4804
4995
|
},
|
|
4805
4996
|
onMemberRolesChanged: async (members) => {
|
|
4806
|
-
if (dataSpace?.state ===
|
|
4997
|
+
if (dataSpace?.state === import_services13.SpaceState.READY) {
|
|
4807
4998
|
this._handleMemberRoleChanges(presence, space.protocol, members);
|
|
4808
4999
|
}
|
|
4809
5000
|
},
|
|
@@ -4816,7 +5007,7 @@ var DataSpaceManager = class {
|
|
|
4816
5007
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
4817
5008
|
const dataSpace = new DataSpace({
|
|
4818
5009
|
inner: space,
|
|
4819
|
-
initialState: metadata.state ===
|
|
5010
|
+
initialState: metadata.state === import_services13.SpaceState.INACTIVE ? import_services13.SpaceState.INACTIVE : import_services13.SpaceState.CLOSED,
|
|
4820
5011
|
metadataStore: this._metadataStore,
|
|
4821
5012
|
gossip,
|
|
4822
5013
|
presence,
|
|
@@ -4826,22 +5017,22 @@ var DataSpaceManager = class {
|
|
|
4826
5017
|
signingContext: this._signingContext,
|
|
4827
5018
|
callbacks: {
|
|
4828
5019
|
beforeReady: async () => {
|
|
4829
|
-
(0,
|
|
5020
|
+
(0, import_log13.log)("before space ready", {
|
|
4830
5021
|
space: space.key
|
|
4831
5022
|
}, {
|
|
4832
|
-
F:
|
|
4833
|
-
L:
|
|
5023
|
+
F: __dxlog_file16,
|
|
5024
|
+
L: 349,
|
|
4834
5025
|
S: this,
|
|
4835
5026
|
C: (f, a) => f(...a)
|
|
4836
5027
|
});
|
|
4837
5028
|
},
|
|
4838
5029
|
afterReady: async () => {
|
|
4839
|
-
(0,
|
|
5030
|
+
(0, import_log13.log)("after space ready", {
|
|
4840
5031
|
space: space.key,
|
|
4841
5032
|
open: this._isOpen
|
|
4842
5033
|
}, {
|
|
4843
|
-
F:
|
|
4844
|
-
L:
|
|
5034
|
+
F: __dxlog_file16,
|
|
5035
|
+
L: 352,
|
|
4845
5036
|
S: this,
|
|
4846
5037
|
C: (f, a) => f(...a)
|
|
4847
5038
|
});
|
|
@@ -4856,11 +5047,11 @@ var DataSpaceManager = class {
|
|
|
4856
5047
|
}
|
|
4857
5048
|
},
|
|
4858
5049
|
beforeClose: async () => {
|
|
4859
|
-
(0,
|
|
5050
|
+
(0, import_log13.log)("before space close", {
|
|
4860
5051
|
space: space.key
|
|
4861
5052
|
}, {
|
|
4862
|
-
F:
|
|
4863
|
-
L:
|
|
5053
|
+
F: __dxlog_file16,
|
|
5054
|
+
L: 360,
|
|
4864
5055
|
S: this,
|
|
4865
5056
|
C: (f, a) => f(...a)
|
|
4866
5057
|
});
|
|
@@ -4869,13 +5060,10 @@ var DataSpaceManager = class {
|
|
|
4869
5060
|
cache: metadata.cache
|
|
4870
5061
|
});
|
|
4871
5062
|
presence.newPeer.on((peerState) => {
|
|
4872
|
-
if (dataSpace.state ===
|
|
5063
|
+
if (dataSpace.state === import_services13.SpaceState.READY) {
|
|
4873
5064
|
this._handleNewPeerConnected(space, peerState);
|
|
4874
5065
|
}
|
|
4875
5066
|
});
|
|
4876
|
-
if (metadata.state !== import_services12.SpaceState.INACTIVE) {
|
|
4877
|
-
await dataSpace.open();
|
|
4878
|
-
}
|
|
4879
5067
|
if (metadata.controlTimeframe) {
|
|
4880
5068
|
dataSpace.inner.controlPipeline.state.setTargetTimeframe(metadata.controlTimeframe);
|
|
4881
5069
|
}
|
|
@@ -4891,20 +5079,20 @@ var DataSpaceManager = class {
|
|
|
4891
5079
|
const peers = presence.getPeersByIdentityKey(member.key);
|
|
4892
5080
|
const sessions = peers.map((p) => p.peerId && spaceProtocol.sessions.get(p.peerId));
|
|
4893
5081
|
const sessionsToClose = sessions.filter((s) => {
|
|
4894
|
-
return (s && member.role ===
|
|
5082
|
+
return (s && member.role === import_credentials16.SpaceMember.Role.REMOVED !== (s.authStatus === import_echo_pipeline3.AuthStatus.FAILURE)) ?? false;
|
|
4895
5083
|
});
|
|
4896
5084
|
sessionsToClose.forEach((session) => {
|
|
4897
|
-
void session.close().catch(
|
|
5085
|
+
void session.close().catch(import_log13.log.error);
|
|
4898
5086
|
});
|
|
4899
5087
|
closedSessions += sessionsToClose.length;
|
|
4900
5088
|
}
|
|
4901
|
-
(0,
|
|
5089
|
+
(0, import_log13.log)("processed member role changes", {
|
|
4902
5090
|
roleChangeCount: memberInfo.length,
|
|
4903
5091
|
peersOnline: presence.getPeersOnline().length,
|
|
4904
5092
|
closedSessions
|
|
4905
5093
|
}, {
|
|
4906
|
-
F:
|
|
4907
|
-
L:
|
|
5094
|
+
F: __dxlog_file16,
|
|
5095
|
+
L: 396,
|
|
4908
5096
|
S: this,
|
|
4909
5097
|
C: (f, a) => f(...a)
|
|
4910
5098
|
});
|
|
@@ -4912,23 +5100,23 @@ var DataSpaceManager = class {
|
|
|
4912
5100
|
}
|
|
4913
5101
|
_handleNewPeerConnected(space, peerState) {
|
|
4914
5102
|
const role = space.spaceState.getMemberRole(peerState.identityKey);
|
|
4915
|
-
if (role ===
|
|
5103
|
+
if (role === import_credentials16.SpaceMember.Role.REMOVED) {
|
|
4916
5104
|
const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
|
|
4917
5105
|
if (session != null) {
|
|
4918
|
-
(0,
|
|
5106
|
+
(0, import_log13.log)("closing a session with a removed peer", {
|
|
4919
5107
|
peerId: peerState.peerId
|
|
4920
5108
|
}, {
|
|
4921
|
-
F:
|
|
4922
|
-
L:
|
|
5109
|
+
F: __dxlog_file16,
|
|
5110
|
+
L: 410,
|
|
4923
5111
|
S: this,
|
|
4924
5112
|
C: (f, a) => f(...a)
|
|
4925
5113
|
});
|
|
4926
|
-
void session.close().catch(
|
|
5114
|
+
void session.close().catch(import_log13.log.error);
|
|
4927
5115
|
}
|
|
4928
5116
|
}
|
|
4929
5117
|
}
|
|
4930
5118
|
async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
|
|
4931
|
-
if (dataSpace?.state !==
|
|
5119
|
+
if (dataSpace?.state !== import_services13.SpaceState.READY) {
|
|
4932
5120
|
return;
|
|
4933
5121
|
}
|
|
4934
5122
|
if (isActive) {
|
|
@@ -4945,8 +5133,8 @@ var DataSpaceManager = class {
|
|
|
4945
5133
|
async _createDelegatedInvitations(space, invitations) {
|
|
4946
5134
|
const tasks = invitations.map(([credentialId, invitation]) => {
|
|
4947
5135
|
return this._invitationsManager.createInvitation({
|
|
4948
|
-
type:
|
|
4949
|
-
kind:
|
|
5136
|
+
type: import_services13.Invitation.Type.DELEGATED,
|
|
5137
|
+
kind: import_services13.Invitation.Kind.SPACE,
|
|
4950
5138
|
spaceKey: space.key,
|
|
4951
5139
|
authMethod: invitation.authMethod,
|
|
4952
5140
|
invitationId: invitation.invitationId,
|
|
@@ -4978,7 +5166,7 @@ _ts_decorate5([
|
|
|
4978
5166
|
DataSpaceManager = _ts_decorate5([
|
|
4979
5167
|
(0, import_async15.trackLeaks)("open", "close")
|
|
4980
5168
|
], DataSpaceManager);
|
|
4981
|
-
var
|
|
5169
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
4982
5170
|
var SpacesServiceImpl = class {
|
|
4983
5171
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
4984
5172
|
this._identityManager = _identityManager;
|
|
@@ -4997,10 +5185,10 @@ var SpacesServiceImpl = class {
|
|
|
4997
5185
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols12.SpaceNotFoundError(spaceKey));
|
|
4998
5186
|
if (state) {
|
|
4999
5187
|
switch (state) {
|
|
5000
|
-
case
|
|
5188
|
+
case import_services14.SpaceState.ACTIVE:
|
|
5001
5189
|
await space.activate();
|
|
5002
5190
|
break;
|
|
5003
|
-
case
|
|
5191
|
+
case import_services14.SpaceState.INACTIVE:
|
|
5004
5192
|
await space.deactivate();
|
|
5005
5193
|
break;
|
|
5006
5194
|
default:
|
|
@@ -5020,9 +5208,9 @@ var SpacesServiceImpl = class {
|
|
|
5020
5208
|
role: space.spaceState.getMemberRole(identity.identityKey)
|
|
5021
5209
|
});
|
|
5022
5210
|
}
|
|
5023
|
-
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);
|
|
5024
5212
|
(0, import_invariant15.invariant)(credentials[0].credential, void 0, {
|
|
5025
|
-
F:
|
|
5213
|
+
F: __dxlog_file17,
|
|
5026
5214
|
L: 97,
|
|
5027
5215
|
S: this,
|
|
5028
5216
|
A: [
|
|
@@ -5031,8 +5219,8 @@ var SpacesServiceImpl = class {
|
|
|
5031
5219
|
]
|
|
5032
5220
|
});
|
|
5033
5221
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
5034
|
-
(0, import_invariant15.invariant)((0,
|
|
5035
|
-
F:
|
|
5222
|
+
(0, import_invariant15.invariant)((0, import_credentials19.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
5223
|
+
F: __dxlog_file17,
|
|
5036
5224
|
L: 99,
|
|
5037
5225
|
S: this,
|
|
5038
5226
|
A: [
|
|
@@ -5047,10 +5235,10 @@ var SpacesServiceImpl = class {
|
|
|
5047
5235
|
const scheduler = new import_async16.UpdateScheduler(ctx, async () => {
|
|
5048
5236
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5049
5237
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
5050
|
-
(0,
|
|
5238
|
+
(0, import_log14.log)("update", {
|
|
5051
5239
|
spaces
|
|
5052
5240
|
}, {
|
|
5053
|
-
F:
|
|
5241
|
+
F: __dxlog_file17,
|
|
5054
5242
|
L: 110,
|
|
5055
5243
|
S: this,
|
|
5056
5244
|
C: (f, a) => f(...a)
|
|
@@ -5134,7 +5322,7 @@ var SpacesServiceImpl = class {
|
|
|
5134
5322
|
});
|
|
5135
5323
|
} else {
|
|
5136
5324
|
(0, import_invariant15.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
5137
|
-
F:
|
|
5325
|
+
F: __dxlog_file17,
|
|
5138
5326
|
L: 198,
|
|
5139
5327
|
S: this,
|
|
5140
5328
|
A: [
|
|
@@ -5143,7 +5331,7 @@ var SpacesServiceImpl = class {
|
|
|
5143
5331
|
]
|
|
5144
5332
|
});
|
|
5145
5333
|
(0, import_invariant15.invariant)(this._identityManager.identity, "Identity is not available", {
|
|
5146
|
-
F:
|
|
5334
|
+
F: __dxlog_file17,
|
|
5147
5335
|
L: 199,
|
|
5148
5336
|
S: this,
|
|
5149
5337
|
A: [
|
|
@@ -5153,7 +5341,7 @@ var SpacesServiceImpl = class {
|
|
|
5153
5341
|
});
|
|
5154
5342
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
5155
5343
|
(0, import_invariant15.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
5156
|
-
F:
|
|
5344
|
+
F: __dxlog_file17,
|
|
5157
5345
|
L: 201,
|
|
5158
5346
|
S: this,
|
|
5159
5347
|
A: [
|
|
@@ -5173,11 +5361,12 @@ var SpacesServiceImpl = class {
|
|
|
5173
5361
|
}
|
|
5174
5362
|
}
|
|
5175
5363
|
}
|
|
5176
|
-
async createEpoch({ spaceKey, migration }) {
|
|
5364
|
+
async createEpoch({ spaceKey, migration, automergeRootUrl }) {
|
|
5177
5365
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
5178
5366
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols12.SpaceNotFoundError(spaceKey));
|
|
5179
5367
|
await space.createEpoch({
|
|
5180
|
-
migration
|
|
5368
|
+
migration,
|
|
5369
|
+
newAutomergeRoot: automergeRootUrl
|
|
5181
5370
|
});
|
|
5182
5371
|
}
|
|
5183
5372
|
_serializeSpace(space) {
|
|
@@ -5211,7 +5400,7 @@ var SpacesServiceImpl = class {
|
|
|
5211
5400
|
profile: member.profile ?? {}
|
|
5212
5401
|
},
|
|
5213
5402
|
role: member.role,
|
|
5214
|
-
presence: peers.length > 0 ?
|
|
5403
|
+
presence: peers.length > 0 ? import_services14.SpaceMember.PresenceState.ONLINE : import_services14.SpaceMember.PresenceState.OFFLINE,
|
|
5215
5404
|
peerStates: peers
|
|
5216
5405
|
};
|
|
5217
5406
|
}),
|
|
@@ -5249,8 +5438,8 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
5249
5438
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5250
5439
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5251
5440
|
}
|
|
5252
|
-
var
|
|
5253
|
-
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 {
|
|
5254
5443
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
5255
5444
|
super();
|
|
5256
5445
|
this.storage = storage;
|
|
@@ -5260,7 +5449,7 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5260
5449
|
this._runtimeParams = _runtimeParams;
|
|
5261
5450
|
this.initialized = new import_async17.Trigger();
|
|
5262
5451
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
5263
|
-
this._instanceId =
|
|
5452
|
+
this._instanceId = import_keys13.PublicKey.random().toHex();
|
|
5264
5453
|
this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
|
|
5265
5454
|
this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
|
|
5266
5455
|
this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
|
|
@@ -5284,26 +5473,25 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5284
5473
|
});
|
|
5285
5474
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
5286
5475
|
this.echoHost = new import_echo_db.EchoHost({
|
|
5287
|
-
kv: this.level
|
|
5288
|
-
storage: this.storage
|
|
5476
|
+
kv: this.level
|
|
5289
5477
|
});
|
|
5290
5478
|
this.invitations = new InvitationsHandler(this.networkManager, _runtimeParams?.invitationConnectionDefaultParams);
|
|
5291
5479
|
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
5292
|
-
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)));
|
|
5293
5481
|
}
|
|
5294
5482
|
async _open(ctx) {
|
|
5295
5483
|
await this._checkStorageVersion();
|
|
5296
|
-
(0,
|
|
5297
|
-
F:
|
|
5298
|
-
L:
|
|
5484
|
+
(0, import_log15.log)("opening...", void 0, {
|
|
5485
|
+
F: __dxlog_file18,
|
|
5486
|
+
L: 149,
|
|
5299
5487
|
S: this,
|
|
5300
5488
|
C: (f, a) => f(...a)
|
|
5301
5489
|
});
|
|
5302
|
-
|
|
5490
|
+
import_log15.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.begin({
|
|
5303
5491
|
id: this._instanceId
|
|
5304
5492
|
}), {
|
|
5305
|
-
F:
|
|
5306
|
-
L:
|
|
5493
|
+
F: __dxlog_file18,
|
|
5494
|
+
L: 150,
|
|
5307
5495
|
S: this,
|
|
5308
5496
|
C: (f, a) => f(...a)
|
|
5309
5497
|
});
|
|
@@ -5317,33 +5505,33 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5317
5505
|
await this._initialize(ctx);
|
|
5318
5506
|
}
|
|
5319
5507
|
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
5320
|
-
(0,
|
|
5508
|
+
(0, import_log15.log)("loaded persistent invitations", {
|
|
5321
5509
|
count: loadedInvitations.invitations?.length
|
|
5322
5510
|
}, {
|
|
5323
|
-
F:
|
|
5324
|
-
L:
|
|
5511
|
+
F: __dxlog_file18,
|
|
5512
|
+
L: 163,
|
|
5325
5513
|
S: this,
|
|
5326
5514
|
C: (f, a) => f(...a)
|
|
5327
5515
|
});
|
|
5328
|
-
|
|
5516
|
+
import_log15.log.trace("dxos.sdk.service-context.open", import_protocols13.trace.end({
|
|
5329
5517
|
id: this._instanceId
|
|
5330
5518
|
}), {
|
|
5331
|
-
F:
|
|
5332
|
-
L:
|
|
5519
|
+
F: __dxlog_file18,
|
|
5520
|
+
L: 165,
|
|
5333
5521
|
S: this,
|
|
5334
5522
|
C: (f, a) => f(...a)
|
|
5335
5523
|
});
|
|
5336
|
-
(0,
|
|
5337
|
-
F:
|
|
5338
|
-
L:
|
|
5524
|
+
(0, import_log15.log)("opened", void 0, {
|
|
5525
|
+
F: __dxlog_file18,
|
|
5526
|
+
L: 166,
|
|
5339
5527
|
S: this,
|
|
5340
5528
|
C: (f, a) => f(...a)
|
|
5341
5529
|
});
|
|
5342
5530
|
}
|
|
5343
5531
|
async _close(ctx) {
|
|
5344
|
-
(0,
|
|
5345
|
-
F:
|
|
5346
|
-
L:
|
|
5532
|
+
(0, import_log15.log)("closing...", void 0, {
|
|
5533
|
+
F: __dxlog_file18,
|
|
5534
|
+
L: 170,
|
|
5347
5535
|
S: this,
|
|
5348
5536
|
C: (f, a) => f(...a)
|
|
5349
5537
|
});
|
|
@@ -5358,23 +5546,23 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5358
5546
|
await this.echoHost.close(ctx);
|
|
5359
5547
|
await this.networkManager.close();
|
|
5360
5548
|
await this.signalManager.close();
|
|
5361
|
-
(0,
|
|
5362
|
-
F:
|
|
5363
|
-
L:
|
|
5549
|
+
(0, import_log15.log)("closed", void 0, {
|
|
5550
|
+
F: __dxlog_file18,
|
|
5551
|
+
L: 182,
|
|
5364
5552
|
S: this,
|
|
5365
5553
|
C: (f, a) => f(...a)
|
|
5366
5554
|
});
|
|
5367
5555
|
}
|
|
5368
5556
|
async createIdentity(params = {}) {
|
|
5369
5557
|
const identity = await this.identityManager.createIdentity(params);
|
|
5370
|
-
await this._initialize(new
|
|
5558
|
+
await this._initialize(new import_context13.Context());
|
|
5371
5559
|
return identity;
|
|
5372
5560
|
}
|
|
5373
5561
|
getInvitationHandler(invitation) {
|
|
5374
5562
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
5375
5563
|
(0, import_invariant16.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
5376
|
-
F:
|
|
5377
|
-
L:
|
|
5564
|
+
F: __dxlog_file18,
|
|
5565
|
+
L: 193,
|
|
5378
5566
|
S: this,
|
|
5379
5567
|
A: [
|
|
5380
5568
|
"factory",
|
|
@@ -5393,7 +5581,7 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5393
5581
|
}
|
|
5394
5582
|
async _acceptIdentity(params) {
|
|
5395
5583
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
5396
|
-
await this._initialize(new
|
|
5584
|
+
await this._initialize(new import_context13.Context());
|
|
5397
5585
|
return identity;
|
|
5398
5586
|
}
|
|
5399
5587
|
async _checkStorageVersion() {
|
|
@@ -5404,9 +5592,9 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5404
5592
|
}
|
|
5405
5593
|
// Called when identity is created.
|
|
5406
5594
|
async _initialize(ctx) {
|
|
5407
|
-
(0,
|
|
5408
|
-
F:
|
|
5409
|
-
L:
|
|
5595
|
+
(0, import_log15.log)("initializing spaces...", void 0, {
|
|
5596
|
+
F: __dxlog_file18,
|
|
5597
|
+
L: 224,
|
|
5410
5598
|
S: this,
|
|
5411
5599
|
C: (f, a) => f(...a)
|
|
5412
5600
|
});
|
|
@@ -5426,10 +5614,10 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5426
5614
|
};
|
|
5427
5615
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.echoHost, this.invitationsManager, this._runtimeParams);
|
|
5428
5616
|
await this.dataSpaceManager.open();
|
|
5429
|
-
this._handlerFactories.set(
|
|
5617
|
+
this._handlerFactories.set(import_services15.Invitation.Kind.SPACE, (invitation) => {
|
|
5430
5618
|
(0, import_invariant16.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
5431
|
-
F:
|
|
5432
|
-
L:
|
|
5619
|
+
F: __dxlog_file18,
|
|
5620
|
+
L: 249,
|
|
5433
5621
|
S: this,
|
|
5434
5622
|
A: [
|
|
5435
5623
|
"this.dataSpaceManager",
|
|
@@ -5441,7 +5629,7 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5441
5629
|
this.initialized.wake();
|
|
5442
5630
|
this._deviceSpaceSync = {
|
|
5443
5631
|
processCredential: async (credential) => {
|
|
5444
|
-
const assertion = (0,
|
|
5632
|
+
const assertion = (0, import_credentials20.getCredentialAssertion)(credential);
|
|
5445
5633
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
5446
5634
|
return;
|
|
5447
5635
|
}
|
|
@@ -5449,33 +5637,33 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5449
5637
|
return;
|
|
5450
5638
|
}
|
|
5451
5639
|
if (!this.dataSpaceManager) {
|
|
5452
|
-
(0,
|
|
5640
|
+
(0, import_log15.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
5453
5641
|
details: assertion
|
|
5454
5642
|
}, {
|
|
5455
|
-
F:
|
|
5456
|
-
L:
|
|
5643
|
+
F: __dxlog_file18,
|
|
5644
|
+
L: 265,
|
|
5457
5645
|
S: this,
|
|
5458
5646
|
C: (f, a) => f(...a)
|
|
5459
5647
|
});
|
|
5460
5648
|
return;
|
|
5461
5649
|
}
|
|
5462
5650
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
5463
|
-
(0,
|
|
5651
|
+
(0, import_log15.log)("space already exists, ignoring space admission", {
|
|
5464
5652
|
details: assertion
|
|
5465
5653
|
}, {
|
|
5466
|
-
F:
|
|
5467
|
-
L:
|
|
5654
|
+
F: __dxlog_file18,
|
|
5655
|
+
L: 269,
|
|
5468
5656
|
S: this,
|
|
5469
5657
|
C: (f, a) => f(...a)
|
|
5470
5658
|
});
|
|
5471
5659
|
return;
|
|
5472
5660
|
}
|
|
5473
5661
|
try {
|
|
5474
|
-
(0,
|
|
5662
|
+
(0, import_log15.log)("accepting space recorded in halo", {
|
|
5475
5663
|
details: assertion
|
|
5476
5664
|
}, {
|
|
5477
|
-
F:
|
|
5478
|
-
L:
|
|
5665
|
+
F: __dxlog_file18,
|
|
5666
|
+
L: 274,
|
|
5479
5667
|
S: this,
|
|
5480
5668
|
C: (f, a) => f(...a)
|
|
5481
5669
|
});
|
|
@@ -5484,9 +5672,9 @@ var ServiceContext = class extends import_context12.Resource {
|
|
|
5484
5672
|
genesisFeedKey: assertion.genesisFeedKey
|
|
5485
5673
|
});
|
|
5486
5674
|
} catch (err) {
|
|
5487
|
-
|
|
5488
|
-
F:
|
|
5489
|
-
L:
|
|
5675
|
+
import_log15.log.catch(err, void 0, {
|
|
5676
|
+
F: __dxlog_file18,
|
|
5677
|
+
L: 280,
|
|
5490
5678
|
S: this,
|
|
5491
5679
|
C: (f, a) => f(...a)
|
|
5492
5680
|
});
|
|
@@ -5538,7 +5726,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
5538
5726
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5539
5727
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5540
5728
|
}
|
|
5541
|
-
var
|
|
5729
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
5542
5730
|
var Lock = class {
|
|
5543
5731
|
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
5544
5732
|
this._lockPath = lockPath;
|
|
@@ -5549,16 +5737,16 @@ var Lock = class {
|
|
|
5549
5737
|
return this._lockPath;
|
|
5550
5738
|
}
|
|
5551
5739
|
async acquire() {
|
|
5552
|
-
(0,
|
|
5553
|
-
F:
|
|
5740
|
+
(0, import_log16.log)("acquiring lock...", void 0, {
|
|
5741
|
+
F: __dxlog_file19,
|
|
5554
5742
|
L: 32,
|
|
5555
5743
|
S: this,
|
|
5556
5744
|
C: (f, a) => f(...a)
|
|
5557
5745
|
});
|
|
5558
5746
|
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
5559
5747
|
await this._onAcquire?.();
|
|
5560
|
-
(0,
|
|
5561
|
-
F:
|
|
5748
|
+
(0, import_log16.log)("acquired lock", void 0, {
|
|
5749
|
+
F: __dxlog_file19,
|
|
5562
5750
|
L: 37,
|
|
5563
5751
|
S: this,
|
|
5564
5752
|
C: (f, a) => f(...a)
|
|
@@ -5567,7 +5755,7 @@ var Lock = class {
|
|
|
5567
5755
|
async release() {
|
|
5568
5756
|
await this._onRelease?.();
|
|
5569
5757
|
(0, import_invariant17.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
5570
|
-
F:
|
|
5758
|
+
F: __dxlog_file19,
|
|
5571
5759
|
L: 42,
|
|
5572
5760
|
S: this,
|
|
5573
5761
|
A: [
|
|
@@ -5579,11 +5767,11 @@ var Lock = class {
|
|
|
5579
5767
|
}
|
|
5580
5768
|
};
|
|
5581
5769
|
_ts_decorate7([
|
|
5582
|
-
|
|
5770
|
+
import_log16.logInfo
|
|
5583
5771
|
], Lock.prototype, "lockKey", null);
|
|
5584
5772
|
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
5585
5773
|
var getRootPath = (config) => {
|
|
5586
|
-
const { dataRoot = (0, import_util10.isNode)() ?
|
|
5774
|
+
const { dataRoot = (0, import_util10.isNode)() ? import_client_protocol6.DX_DATA : "dxos/storage" } = config ?? {};
|
|
5587
5775
|
return `${dataRoot}/`;
|
|
5588
5776
|
};
|
|
5589
5777
|
var isPersistent = (config) => {
|
|
@@ -5634,12 +5822,12 @@ var toStorageType = (type) => {
|
|
|
5634
5822
|
};
|
|
5635
5823
|
var createLevel = async (config) => {
|
|
5636
5824
|
const persistent = isPersistent(config);
|
|
5637
|
-
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()}`;
|
|
5638
5826
|
const level = (0, import_kv_store.createLevel)(storagePath);
|
|
5639
5827
|
await level.open();
|
|
5640
5828
|
return level;
|
|
5641
5829
|
};
|
|
5642
|
-
var
|
|
5830
|
+
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
5643
5831
|
var DevicesServiceImpl = class {
|
|
5644
5832
|
constructor(_identityManager) {
|
|
5645
5833
|
this._identityManager = _identityManager;
|
|
@@ -5657,7 +5845,7 @@ var DevicesServiceImpl = class {
|
|
|
5657
5845
|
});
|
|
5658
5846
|
} else {
|
|
5659
5847
|
(0, import_invariant19.invariant)(this._identityManager.identity?.presence, "presence not present", {
|
|
5660
|
-
F:
|
|
5848
|
+
F: __dxlog_file20,
|
|
5661
5849
|
L: 32,
|
|
5662
5850
|
S: this,
|
|
5663
5851
|
A: [
|
|
@@ -5672,9 +5860,9 @@ var DevicesServiceImpl = class {
|
|
|
5672
5860
|
const peerState = peers.find((peer) => peer.identityKey.equals(key));
|
|
5673
5861
|
return {
|
|
5674
5862
|
deviceKey: key,
|
|
5675
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ?
|
|
5863
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services17.DeviceKind.CURRENT : import_services17.DeviceKind.TRUSTED,
|
|
5676
5864
|
profile,
|
|
5677
|
-
presence: isMe ?
|
|
5865
|
+
presence: isMe ? import_services17.Device.PresenceState.ONLINE : peerState ? import_services17.Device.PresenceState.ONLINE : import_services17.Device.PresenceState.OFFLINE
|
|
5678
5866
|
};
|
|
5679
5867
|
})
|
|
5680
5868
|
});
|
|
@@ -5723,7 +5911,7 @@ var DiagnosticsCollector = class {
|
|
|
5723
5911
|
}
|
|
5724
5912
|
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
5725
5913
|
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
5726
|
-
keys: options.humanize ?
|
|
5914
|
+
keys: options.humanize ? import_services18.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services18.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
5727
5915
|
}, {
|
|
5728
5916
|
timeout: GET_DIAGNOSTICS_RPC_TIMEOUT
|
|
5729
5917
|
});
|
|
@@ -5738,7 +5926,7 @@ var DiagnosticsCollector = class {
|
|
|
5738
5926
|
client: clientDiagnostics,
|
|
5739
5927
|
broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
|
|
5740
5928
|
};
|
|
5741
|
-
return JSON.parse(JSON.stringify(diagnostics, (0,
|
|
5929
|
+
return JSON.parse(JSON.stringify(diagnostics, (0, import_util11.jsonKeyReplacer)(options)));
|
|
5742
5930
|
}
|
|
5743
5931
|
};
|
|
5744
5932
|
var findSystemServiceProvider = () => {
|
|
@@ -5748,35 +5936,35 @@ var findSystemServiceProvider = () => {
|
|
|
5748
5936
|
};
|
|
5749
5937
|
var findConfigs = () => {
|
|
5750
5938
|
const configs = import_tracing10.TRACE_PROCESSOR.findResourcesByAnnotation(import_config3.ConfigResource);
|
|
5751
|
-
return configs.map((r) => r.instance.deref()).filter(
|
|
5939
|
+
return configs.map((r) => r.instance.deref()).filter(import_util11.nonNullable);
|
|
5752
5940
|
};
|
|
5753
5941
|
var LoggingServiceImpl = class {
|
|
5754
5942
|
constructor() {
|
|
5755
5943
|
this._logs = new import_async20.Event();
|
|
5756
5944
|
this._started = Date.now();
|
|
5757
|
-
this._sessionId =
|
|
5945
|
+
this._sessionId = import_keys17.PublicKey.random().toHex();
|
|
5758
5946
|
this._logProcessor = (_config, entry2) => {
|
|
5759
5947
|
this._logs.emit(entry2);
|
|
5760
5948
|
};
|
|
5761
5949
|
}
|
|
5762
5950
|
async open() {
|
|
5763
|
-
|
|
5951
|
+
import_log18.log.runtimeConfig.processors.push(this._logProcessor);
|
|
5764
5952
|
}
|
|
5765
5953
|
async close() {
|
|
5766
|
-
const index =
|
|
5767
|
-
|
|
5954
|
+
const index = import_log18.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
5955
|
+
import_log18.log.runtimeConfig.processors.splice(index, 1);
|
|
5768
5956
|
}
|
|
5769
5957
|
async controlMetrics({ reset, record }) {
|
|
5770
5958
|
if (reset) {
|
|
5771
|
-
|
|
5959
|
+
import_util13.tracer.clear();
|
|
5772
5960
|
}
|
|
5773
5961
|
if (record === true) {
|
|
5774
|
-
|
|
5962
|
+
import_util13.tracer.start();
|
|
5775
5963
|
} else if (record === false) {
|
|
5776
|
-
|
|
5964
|
+
import_util13.tracer.stop();
|
|
5777
5965
|
}
|
|
5778
5966
|
return {
|
|
5779
|
-
recording:
|
|
5967
|
+
recording: import_util13.tracer.recording
|
|
5780
5968
|
};
|
|
5781
5969
|
}
|
|
5782
5970
|
/**
|
|
@@ -5784,10 +5972,10 @@ var LoggingServiceImpl = class {
|
|
|
5784
5972
|
*/
|
|
5785
5973
|
queryMetrics({ interval = 5e3 }) {
|
|
5786
5974
|
const getNumericalValues = (key) => {
|
|
5787
|
-
const events =
|
|
5975
|
+
const events = import_util13.tracer.get(key) ?? [];
|
|
5788
5976
|
return {
|
|
5789
5977
|
key,
|
|
5790
|
-
stats: (0,
|
|
5978
|
+
stats: (0, import_util13.numericalValues)(events, "duration")
|
|
5791
5979
|
};
|
|
5792
5980
|
};
|
|
5793
5981
|
return new import_codec_protobuf13.Stream(({ next }) => {
|
|
@@ -5825,7 +6013,7 @@ var LoggingServiceImpl = class {
|
|
|
5825
6013
|
}
|
|
5826
6014
|
const record = {
|
|
5827
6015
|
...entry2,
|
|
5828
|
-
context: (0,
|
|
6016
|
+
context: (0, import_util13.jsonify)((0, import_log18.getContextFromEntry)(entry2)),
|
|
5829
6017
|
timestamp: /* @__PURE__ */ new Date(),
|
|
5830
6018
|
meta: {
|
|
5831
6019
|
// TODO(dmaretskyi): Fix proto.
|
|
@@ -5834,7 +6022,7 @@ var LoggingServiceImpl = class {
|
|
|
5834
6022
|
scope: {
|
|
5835
6023
|
hostSessionId: this._sessionId,
|
|
5836
6024
|
uptimeSeconds: (Date.now() - this._started) / 1e3,
|
|
5837
|
-
name: (0,
|
|
6025
|
+
name: (0, import_util13.getDebugName)(entry2.meta?.S)
|
|
5838
6026
|
}
|
|
5839
6027
|
}
|
|
5840
6028
|
};
|
|
@@ -5851,16 +6039,16 @@ var LoggingServiceImpl = class {
|
|
|
5851
6039
|
};
|
|
5852
6040
|
var matchFilter = (filter, level, path2, options) => {
|
|
5853
6041
|
switch (options) {
|
|
5854
|
-
case
|
|
6042
|
+
case import_services19.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
5855
6043
|
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5856
|
-
case
|
|
6044
|
+
case import_services19.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
5857
6045
|
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5858
6046
|
}
|
|
5859
6047
|
};
|
|
5860
6048
|
var shouldLog = (entry2, request) => {
|
|
5861
|
-
const options = request.options ??
|
|
6049
|
+
const options = request.options ?? import_services19.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5862
6050
|
if (request.filters === void 0) {
|
|
5863
|
-
return options ===
|
|
6051
|
+
return options === import_services19.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5864
6052
|
} else {
|
|
5865
6053
|
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
5866
6054
|
}
|
|
@@ -5915,9 +6103,9 @@ var SystemServiceImpl = class {
|
|
|
5915
6103
|
const diagnostics = await this._getDiagnostics();
|
|
5916
6104
|
return {
|
|
5917
6105
|
timestamp: /* @__PURE__ */ new Date(),
|
|
5918
|
-
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0,
|
|
5919
|
-
truncate: keys ===
|
|
5920
|
-
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
|
|
5921
6109
|
})))
|
|
5922
6110
|
};
|
|
5923
6111
|
}
|
|
@@ -5958,7 +6146,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
5958
6146
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5959
6147
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5960
6148
|
}
|
|
5961
|
-
var
|
|
6149
|
+
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
5962
6150
|
var ClientServicesHost = class {
|
|
5963
6151
|
constructor({
|
|
5964
6152
|
config,
|
|
@@ -5978,7 +6166,7 @@ var ClientServicesHost = class {
|
|
|
5978
6166
|
this._storage = storage;
|
|
5979
6167
|
this._level = level;
|
|
5980
6168
|
this._callbacks = callbacks;
|
|
5981
|
-
this._runtimeParams = runtimeParams;
|
|
6169
|
+
this._runtimeParams = runtimeParams ?? {};
|
|
5982
6170
|
if (config) {
|
|
5983
6171
|
this.initialize({
|
|
5984
6172
|
config,
|
|
@@ -5991,7 +6179,7 @@ var ClientServicesHost = class {
|
|
|
5991
6179
|
lockKey,
|
|
5992
6180
|
onAcquire: () => {
|
|
5993
6181
|
if (!this._opening) {
|
|
5994
|
-
void this.open(new
|
|
6182
|
+
void this.open(new import_context14.Context());
|
|
5995
6183
|
}
|
|
5996
6184
|
},
|
|
5997
6185
|
onRelease: () => this.close()
|
|
@@ -6000,14 +6188,14 @@ var ClientServicesHost = class {
|
|
|
6000
6188
|
this._systemService = new SystemServiceImpl({
|
|
6001
6189
|
config: () => this._config,
|
|
6002
6190
|
statusUpdate: this._statusUpdate,
|
|
6003
|
-
getCurrentStatus: () => this.isOpen ?
|
|
6191
|
+
getCurrentStatus: () => this.isOpen ? import_services16.SystemStatus.ACTIVE : import_services16.SystemStatus.INACTIVE,
|
|
6004
6192
|
getDiagnostics: () => {
|
|
6005
6193
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
6006
6194
|
},
|
|
6007
6195
|
onUpdateStatus: async (status) => {
|
|
6008
|
-
if (!this.isOpen && status ===
|
|
6196
|
+
if (!this.isOpen && status === import_services16.SystemStatus.ACTIVE) {
|
|
6009
6197
|
await this._resourceLock?.acquire();
|
|
6010
|
-
} else if (this.isOpen && status ===
|
|
6198
|
+
} else if (this.isOpen && status === import_services16.SystemStatus.INACTIVE) {
|
|
6011
6199
|
await this._resourceLock?.release();
|
|
6012
6200
|
}
|
|
6013
6201
|
},
|
|
@@ -6017,7 +6205,7 @@ var ClientServicesHost = class {
|
|
|
6017
6205
|
});
|
|
6018
6206
|
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
6019
6207
|
this._loggingService = new LoggingServiceImpl();
|
|
6020
|
-
this._serviceRegistry = new ServiceRegistry(
|
|
6208
|
+
this._serviceRegistry = new ServiceRegistry(import_client_protocol7.clientServiceBundle, {
|
|
6021
6209
|
SystemService: this._systemService,
|
|
6022
6210
|
TracingService: this._tracingService
|
|
6023
6211
|
});
|
|
@@ -6047,24 +6235,24 @@ var ClientServicesHost = class {
|
|
|
6047
6235
|
*/
|
|
6048
6236
|
initialize({ config, ...options }) {
|
|
6049
6237
|
(0, import_invariant18.invariant)(!this._open, "service host is open", {
|
|
6050
|
-
F:
|
|
6051
|
-
L:
|
|
6238
|
+
F: __dxlog_file21,
|
|
6239
|
+
L: 186,
|
|
6052
6240
|
S: this,
|
|
6053
6241
|
A: [
|
|
6054
6242
|
"!this._open",
|
|
6055
6243
|
"'service host is open'"
|
|
6056
6244
|
]
|
|
6057
6245
|
});
|
|
6058
|
-
(0,
|
|
6059
|
-
F:
|
|
6060
|
-
L:
|
|
6246
|
+
(0, import_log17.log)("initializing...", void 0, {
|
|
6247
|
+
F: __dxlog_file21,
|
|
6248
|
+
L: 187,
|
|
6061
6249
|
S: this,
|
|
6062
6250
|
C: (f, a) => f(...a)
|
|
6063
6251
|
});
|
|
6064
6252
|
if (config) {
|
|
6065
6253
|
(0, import_invariant18.invariant)(!this._config, "config already set", {
|
|
6066
|
-
F:
|
|
6067
|
-
L:
|
|
6254
|
+
F: __dxlog_file21,
|
|
6255
|
+
L: 190,
|
|
6068
6256
|
S: this,
|
|
6069
6257
|
A: [
|
|
6070
6258
|
"!this._config",
|
|
@@ -6077,9 +6265,9 @@ var ClientServicesHost = class {
|
|
|
6077
6265
|
}
|
|
6078
6266
|
}
|
|
6079
6267
|
if (!options.signalManager) {
|
|
6080
|
-
|
|
6081
|
-
F:
|
|
6082
|
-
L:
|
|
6268
|
+
import_log17.log.warn("running signaling without telemetry metadata.", void 0, {
|
|
6269
|
+
F: __dxlog_file21,
|
|
6270
|
+
L: 198,
|
|
6083
6271
|
S: this,
|
|
6084
6272
|
C: (f, a) => f(...a)
|
|
6085
6273
|
});
|
|
@@ -6089,8 +6277,8 @@ var ClientServicesHost = class {
|
|
|
6089
6277
|
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
6090
6278
|
this._signalManager = signalManager;
|
|
6091
6279
|
(0, import_invariant18.invariant)(!this._networkManager, "network manager already set", {
|
|
6092
|
-
F:
|
|
6093
|
-
L:
|
|
6280
|
+
F: __dxlog_file21,
|
|
6281
|
+
L: 209,
|
|
6094
6282
|
S: this,
|
|
6095
6283
|
A: [
|
|
6096
6284
|
"!this._networkManager",
|
|
@@ -6102,9 +6290,9 @@ var ClientServicesHost = class {
|
|
|
6102
6290
|
transportFactory,
|
|
6103
6291
|
signalManager
|
|
6104
6292
|
});
|
|
6105
|
-
(0,
|
|
6106
|
-
F:
|
|
6107
|
-
L:
|
|
6293
|
+
(0, import_log17.log)("initialized", void 0, {
|
|
6294
|
+
F: __dxlog_file21,
|
|
6295
|
+
L: 216,
|
|
6108
6296
|
S: this,
|
|
6109
6297
|
C: (f, a) => f(...a)
|
|
6110
6298
|
});
|
|
@@ -6113,18 +6301,18 @@ var ClientServicesHost = class {
|
|
|
6113
6301
|
if (this._open) {
|
|
6114
6302
|
return;
|
|
6115
6303
|
}
|
|
6116
|
-
const traceId =
|
|
6117
|
-
|
|
6304
|
+
const traceId = import_keys15.PublicKey.random().toHex();
|
|
6305
|
+
import_log17.log.trace("dxos.client-services.host.open", import_protocols15.trace.begin({
|
|
6118
6306
|
id: traceId
|
|
6119
6307
|
}), {
|
|
6120
|
-
F:
|
|
6121
|
-
L:
|
|
6308
|
+
F: __dxlog_file21,
|
|
6309
|
+
L: 227,
|
|
6122
6310
|
S: this,
|
|
6123
6311
|
C: (f, a) => f(...a)
|
|
6124
6312
|
});
|
|
6125
6313
|
(0, import_invariant18.invariant)(this._config, "config not set", {
|
|
6126
|
-
F:
|
|
6127
|
-
L:
|
|
6314
|
+
F: __dxlog_file21,
|
|
6315
|
+
L: 229,
|
|
6128
6316
|
S: this,
|
|
6129
6317
|
A: [
|
|
6130
6318
|
"this._config",
|
|
@@ -6132,8 +6320,8 @@ var ClientServicesHost = class {
|
|
|
6132
6320
|
]
|
|
6133
6321
|
});
|
|
6134
6322
|
(0, import_invariant18.invariant)(this._storage, "storage not set", {
|
|
6135
|
-
F:
|
|
6136
|
-
L:
|
|
6323
|
+
F: __dxlog_file21,
|
|
6324
|
+
L: 230,
|
|
6137
6325
|
S: this,
|
|
6138
6326
|
A: [
|
|
6139
6327
|
"this._storage",
|
|
@@ -6141,8 +6329,8 @@ var ClientServicesHost = class {
|
|
|
6141
6329
|
]
|
|
6142
6330
|
});
|
|
6143
6331
|
(0, import_invariant18.invariant)(this._signalManager, "signal manager not set", {
|
|
6144
|
-
F:
|
|
6145
|
-
L:
|
|
6332
|
+
F: __dxlog_file21,
|
|
6333
|
+
L: 231,
|
|
6146
6334
|
S: this,
|
|
6147
6335
|
A: [
|
|
6148
6336
|
"this._signalManager",
|
|
@@ -6150,8 +6338,8 @@ var ClientServicesHost = class {
|
|
|
6150
6338
|
]
|
|
6151
6339
|
});
|
|
6152
6340
|
(0, import_invariant18.invariant)(this._networkManager, "network manager not set", {
|
|
6153
|
-
F:
|
|
6154
|
-
L:
|
|
6341
|
+
F: __dxlog_file21,
|
|
6342
|
+
L: 232,
|
|
6155
6343
|
S: this,
|
|
6156
6344
|
A: [
|
|
6157
6345
|
"this._networkManager",
|
|
@@ -6159,11 +6347,11 @@ var ClientServicesHost = class {
|
|
|
6159
6347
|
]
|
|
6160
6348
|
});
|
|
6161
6349
|
this._opening = true;
|
|
6162
|
-
(0,
|
|
6350
|
+
(0, import_log17.log)("opening...", {
|
|
6163
6351
|
lockKey: this._resourceLock?.lockKey
|
|
6164
6352
|
}, {
|
|
6165
|
-
F:
|
|
6166
|
-
L:
|
|
6353
|
+
F: __dxlog_file21,
|
|
6354
|
+
L: 235,
|
|
6167
6355
|
S: this,
|
|
6168
6356
|
C: (f, a) => f(...a)
|
|
6169
6357
|
});
|
|
@@ -6174,9 +6362,10 @@ var ClientServicesHost = class {
|
|
|
6174
6362
|
await this._level.open();
|
|
6175
6363
|
await this._loggingService.open();
|
|
6176
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));
|
|
6177
6366
|
this._serviceRegistry.setServices({
|
|
6178
6367
|
SystemService: this._systemService,
|
|
6179
|
-
IdentityService:
|
|
6368
|
+
IdentityService: identityService,
|
|
6180
6369
|
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
|
|
6181
6370
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
6182
6371
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
|
|
@@ -6196,12 +6385,13 @@ var ClientServicesHost = class {
|
|
|
6196
6385
|
})
|
|
6197
6386
|
});
|
|
6198
6387
|
await this._serviceContext.open(ctx);
|
|
6388
|
+
await identityService.open();
|
|
6199
6389
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
6200
6390
|
if (devtoolsProxy) {
|
|
6201
6391
|
this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
|
|
6202
6392
|
url: devtoolsProxy,
|
|
6203
6393
|
requested: {},
|
|
6204
|
-
exposed:
|
|
6394
|
+
exposed: import_client_protocol7.clientServiceBundle,
|
|
6205
6395
|
handlers: this.services
|
|
6206
6396
|
});
|
|
6207
6397
|
void this._devtoolsProxy.open();
|
|
@@ -6211,18 +6401,18 @@ var ClientServicesHost = class {
|
|
|
6211
6401
|
this._open = true;
|
|
6212
6402
|
this._statusUpdate.emit();
|
|
6213
6403
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6214
|
-
(0,
|
|
6404
|
+
(0, import_log17.log)("opened", {
|
|
6215
6405
|
deviceKey
|
|
6216
6406
|
}, {
|
|
6217
|
-
F:
|
|
6407
|
+
F: __dxlog_file21,
|
|
6218
6408
|
L: 314,
|
|
6219
6409
|
S: this,
|
|
6220
6410
|
C: (f, a) => f(...a)
|
|
6221
6411
|
});
|
|
6222
|
-
|
|
6412
|
+
import_log17.log.trace("dxos.client-services.host.open", import_protocols15.trace.end({
|
|
6223
6413
|
id: traceId
|
|
6224
6414
|
}), {
|
|
6225
|
-
F:
|
|
6415
|
+
F: __dxlog_file21,
|
|
6226
6416
|
L: 315,
|
|
6227
6417
|
S: this,
|
|
6228
6418
|
C: (f, a) => f(...a)
|
|
@@ -6233,10 +6423,10 @@ var ClientServicesHost = class {
|
|
|
6233
6423
|
return;
|
|
6234
6424
|
}
|
|
6235
6425
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
6236
|
-
(0,
|
|
6426
|
+
(0, import_log17.log)("closing...", {
|
|
6237
6427
|
deviceKey
|
|
6238
6428
|
}, {
|
|
6239
|
-
F:
|
|
6429
|
+
F: __dxlog_file21,
|
|
6240
6430
|
L: 326,
|
|
6241
6431
|
S: this,
|
|
6242
6432
|
C: (f, a) => f(...a)
|
|
@@ -6251,43 +6441,43 @@ var ClientServicesHost = class {
|
|
|
6251
6441
|
await this._level?.close();
|
|
6252
6442
|
this._open = false;
|
|
6253
6443
|
this._statusUpdate.emit();
|
|
6254
|
-
(0,
|
|
6444
|
+
(0, import_log17.log)("closed", {
|
|
6255
6445
|
deviceKey
|
|
6256
6446
|
}, {
|
|
6257
|
-
F:
|
|
6447
|
+
F: __dxlog_file21,
|
|
6258
6448
|
L: 335,
|
|
6259
6449
|
S: this,
|
|
6260
6450
|
C: (f, a) => f(...a)
|
|
6261
6451
|
});
|
|
6262
6452
|
}
|
|
6263
6453
|
async reset() {
|
|
6264
|
-
const traceId =
|
|
6265
|
-
|
|
6454
|
+
const traceId = import_keys15.PublicKey.random().toHex();
|
|
6455
|
+
import_log17.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.begin({
|
|
6266
6456
|
id: traceId
|
|
6267
6457
|
}), {
|
|
6268
|
-
F:
|
|
6458
|
+
F: __dxlog_file21,
|
|
6269
6459
|
L: 340,
|
|
6270
6460
|
S: this,
|
|
6271
6461
|
C: (f, a) => f(...a)
|
|
6272
6462
|
});
|
|
6273
|
-
|
|
6274
|
-
F:
|
|
6463
|
+
import_log17.log.info("resetting...", void 0, {
|
|
6464
|
+
F: __dxlog_file21,
|
|
6275
6465
|
L: 342,
|
|
6276
6466
|
S: this,
|
|
6277
6467
|
C: (f, a) => f(...a)
|
|
6278
6468
|
});
|
|
6279
6469
|
await this._serviceContext?.close();
|
|
6280
6470
|
await this._storage.reset();
|
|
6281
|
-
|
|
6282
|
-
F:
|
|
6471
|
+
import_log17.log.info("reset", void 0, {
|
|
6472
|
+
F: __dxlog_file21,
|
|
6283
6473
|
L: 345,
|
|
6284
6474
|
S: this,
|
|
6285
6475
|
C: (f, a) => f(...a)
|
|
6286
6476
|
});
|
|
6287
|
-
|
|
6477
|
+
import_log17.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.end({
|
|
6288
6478
|
id: traceId
|
|
6289
6479
|
}), {
|
|
6290
|
-
F:
|
|
6480
|
+
F: __dxlog_file21,
|
|
6291
6481
|
L: 346,
|
|
6292
6482
|
S: this,
|
|
6293
6483
|
C: (f, a) => f(...a)
|
|
@@ -6297,38 +6487,6 @@ var ClientServicesHost = class {
|
|
|
6297
6487
|
async _createIdentity(params) {
|
|
6298
6488
|
const identity = await this._serviceContext.createIdentity(params);
|
|
6299
6489
|
await this._serviceContext.initialized.wait();
|
|
6300
|
-
const space = await this._serviceContext.dataSpaceManager.createSpace();
|
|
6301
|
-
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
6302
|
-
(0, import_invariant18.invariant)(automergeIndex, void 0, {
|
|
6303
|
-
F: __dxlog_file20,
|
|
6304
|
-
L: 358,
|
|
6305
|
-
S: this,
|
|
6306
|
-
A: [
|
|
6307
|
-
"automergeIndex",
|
|
6308
|
-
""
|
|
6309
|
-
]
|
|
6310
|
-
});
|
|
6311
|
-
const document = this._serviceContext.echoHost.automergeRepo.find(automergeIndex);
|
|
6312
|
-
await document.whenReady();
|
|
6313
|
-
const properties = {
|
|
6314
|
-
system: {
|
|
6315
|
-
type: (0, import_echo_protocol.encodeReference)((0, import_echo_schema2.getTypeReference)(import_client_protocol6.PropertiesType))
|
|
6316
|
-
},
|
|
6317
|
-
data: {
|
|
6318
|
-
[import_client_protocol6.defaultKey]: identity.identityKey.toHex()
|
|
6319
|
-
},
|
|
6320
|
-
meta: {
|
|
6321
|
-
keys: []
|
|
6322
|
-
}
|
|
6323
|
-
};
|
|
6324
|
-
const propertiesId = import_keys14.PublicKey.random().toHex();
|
|
6325
|
-
document.change((doc) => {
|
|
6326
|
-
(0, import_util11.assignDeep)(doc, [
|
|
6327
|
-
"objects",
|
|
6328
|
-
propertiesId
|
|
6329
|
-
], properties);
|
|
6330
|
-
});
|
|
6331
|
-
await this._serviceContext.echoHost.flush();
|
|
6332
6490
|
return identity;
|
|
6333
6491
|
}
|
|
6334
6492
|
};
|
|
@@ -6390,4 +6548,4 @@ ClientServicesHost = _ts_decorate8([
|
|
|
6390
6548
|
subscribeToSpaces,
|
|
6391
6549
|
subscribeToSwarmInfo
|
|
6392
6550
|
});
|
|
6393
|
-
//# sourceMappingURL=chunk-
|
|
6551
|
+
//# sourceMappingURL=chunk-ZBIDLLZ4.cjs.map
|