@dxos/client-services 0.4.10-main.c75170d → 0.4.10-main.c8e5c39
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-JP7F2IH3.mjs → chunk-7OKNHCYB.mjs} +425 -410
- package/dist/lib/browser/chunk-7OKNHCYB.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +6 -4
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +131 -116
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-34EZSH65.cjs → chunk-5JA576YH.cjs} +527 -508
- package/dist/lib/node/chunk-5JA576YH.cjs.map +7 -0
- package/dist/lib/node/index.cjs +48 -46
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +130 -118
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts +3 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts +6 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +4 -2
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts +9 -7
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +2 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +4 -6
- package/dist/types/src/packlets/services/service-context.d.ts.map +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 +8 -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 +4 -3
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/storage/level.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +7 -3
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +34 -34
- package/src/packlets/identity/identity-manager.ts +1 -0
- package/src/packlets/identity/identity.test.ts +3 -0
- package/src/packlets/invitations/device-invitation-protocol.ts +6 -1
- package/src/packlets/invitations/invitation-protocol.ts +7 -1
- package/src/packlets/invitations/invitations-handler.ts +10 -71
- package/src/packlets/invitations/invitations-manager.ts +114 -40
- package/src/packlets/invitations/invitations-service.ts +4 -2
- package/src/packlets/invitations/space-invitation-protocol.ts +45 -3
- package/src/packlets/services/automerge-host.test.ts +4 -4
- package/src/packlets/services/service-context.test.ts +3 -3
- package/src/packlets/services/service-context.ts +12 -25
- package/src/packlets/services/service-host.test.ts +6 -0
- package/src/packlets/services/service-host.ts +5 -16
- package/src/packlets/spaces/data-space-manager.test.ts +4 -4
- package/src/packlets/spaces/data-space-manager.ts +56 -13
- package/src/packlets/spaces/data-space.ts +14 -19
- package/src/packlets/storage/level.ts +1 -0
- package/src/packlets/testing/invitation-utils.ts +100 -97
- package/src/packlets/testing/test-builder.ts +27 -14
- package/src/packlets/vault/worker-runtime.ts +3 -1
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-JP7F2IH3.mjs.map +0 -7
- package/dist/lib/node/chunk-34EZSH65.cjs.map +0 -7
- package/dist/types/src/packlets/indexing/index.d.ts +0 -2
- package/dist/types/src/packlets/indexing/index.d.ts.map +0 -1
- package/dist/types/src/packlets/indexing/util.d.ts +0 -16
- package/dist/types/src/packlets/indexing/util.d.ts.map +0 -1
- package/src/packlets/indexing/index.ts +0 -5
- package/src/packlets/indexing/util.ts +0 -89
|
@@ -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_5JA576YH_exports = {};
|
|
30
|
+
__export(chunk_5JA576YH_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
33
|
ClientServicesProviderResource: () => ClientServicesProviderResource,
|
|
@@ -66,7 +66,7 @@ __export(chunk_34EZSH65_exports, {
|
|
|
66
66
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
67
67
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
68
68
|
});
|
|
69
|
-
module.exports = __toCommonJS(
|
|
69
|
+
module.exports = __toCommonJS(chunk_5JA576YH_exports);
|
|
70
70
|
var import_async = require("@dxos/async");
|
|
71
71
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
72
72
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -120,7 +120,6 @@ var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
120
120
|
var import_async7 = require("@dxos/async");
|
|
121
121
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
122
122
|
var import_context4 = require("@dxos/context");
|
|
123
|
-
var import_credentials7 = require("@dxos/credentials");
|
|
124
123
|
var import_crypto = require("@dxos/crypto");
|
|
125
124
|
var import_invariant5 = require("@dxos/invariant");
|
|
126
125
|
var import_keys5 = require("@dxos/keys");
|
|
@@ -141,59 +140,65 @@ var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations")
|
|
|
141
140
|
var import_teleport = require("@dxos/teleport");
|
|
142
141
|
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
143
142
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
144
|
-
var
|
|
143
|
+
var import_credentials7 = require("@dxos/credentials");
|
|
145
144
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
146
145
|
var import_invariant7 = require("@dxos/invariant");
|
|
147
146
|
var import_log6 = require("@dxos/log");
|
|
148
147
|
var import_protocols6 = require("@dxos/protocols");
|
|
149
148
|
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
149
|
+
var import_credentials8 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
150
150
|
var import_async9 = require("@dxos/async");
|
|
151
|
+
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
152
|
+
var import_context6 = require("@dxos/context");
|
|
153
|
+
var import_credentials9 = require("@dxos/credentials");
|
|
151
154
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
152
155
|
var import_invariant8 = require("@dxos/invariant");
|
|
156
|
+
var import_keys7 = require("@dxos/keys");
|
|
153
157
|
var import_log7 = require("@dxos/log");
|
|
158
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
154
159
|
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
155
160
|
var import_debug2 = require("@dxos/debug");
|
|
156
161
|
var import_rpc = require("@dxos/rpc");
|
|
157
162
|
var import_tracing3 = require("@dxos/tracing");
|
|
158
163
|
var import_async10 = require("@dxos/async");
|
|
159
|
-
var
|
|
160
|
-
var
|
|
164
|
+
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
165
|
+
var import_context7 = require("@dxos/context");
|
|
161
166
|
var import_debug3 = require("@dxos/debug");
|
|
162
|
-
var import_echo_db = require("@dxos/echo-db");
|
|
163
167
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
164
168
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
169
|
+
var import_echo_schema = require("@dxos/echo-schema");
|
|
165
170
|
var import_invariant9 = require("@dxos/invariant");
|
|
166
|
-
var
|
|
171
|
+
var import_keys8 = require("@dxos/keys");
|
|
167
172
|
var import_log8 = require("@dxos/log");
|
|
168
173
|
var import_protocols7 = require("@dxos/protocols");
|
|
169
|
-
var
|
|
170
|
-
var
|
|
174
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
175
|
+
var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
171
176
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
172
177
|
var import_tracing4 = require("@dxos/tracing");
|
|
173
178
|
var import_util4 = require("@dxos/util");
|
|
174
179
|
var import_async11 = require("@dxos/async");
|
|
175
|
-
var
|
|
180
|
+
var import_credentials11 = require("@dxos/credentials");
|
|
176
181
|
var import_async12 = require("@dxos/async");
|
|
177
|
-
var
|
|
182
|
+
var import_context8 = require("@dxos/context");
|
|
178
183
|
var import_invariant10 = require("@dxos/invariant");
|
|
179
|
-
var
|
|
184
|
+
var import_keys9 = require("@dxos/keys");
|
|
180
185
|
var import_log9 = require("@dxos/log");
|
|
181
186
|
var import_protocols8 = require("@dxos/protocols");
|
|
182
187
|
var import_teleport2 = require("@dxos/teleport");
|
|
183
188
|
var import_util5 = require("@dxos/util");
|
|
184
189
|
var import_async13 = require("@dxos/async");
|
|
185
|
-
var
|
|
186
|
-
var
|
|
190
|
+
var import_context9 = require("@dxos/context");
|
|
191
|
+
var import_credentials12 = require("@dxos/credentials");
|
|
187
192
|
var import_invariant11 = require("@dxos/invariant");
|
|
188
|
-
var
|
|
193
|
+
var import_keys10 = require("@dxos/keys");
|
|
189
194
|
var import_log10 = require("@dxos/log");
|
|
190
195
|
var import_protocols9 = require("@dxos/protocols");
|
|
191
|
-
var
|
|
196
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
192
197
|
var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
|
|
193
198
|
var import_util6 = require("@dxos/util");
|
|
194
|
-
var
|
|
199
|
+
var import_credentials13 = require("@dxos/credentials");
|
|
195
200
|
var import_debug4 = require("@dxos/debug");
|
|
196
|
-
var
|
|
201
|
+
var import_credentials14 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
197
202
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
198
203
|
var import_async14 = require("@dxos/async");
|
|
199
204
|
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
@@ -201,80 +206,76 @@ var import_debug5 = require("@dxos/debug");
|
|
|
201
206
|
var import_invariant12 = require("@dxos/invariant");
|
|
202
207
|
var import_log11 = require("@dxos/log");
|
|
203
208
|
var import_protocols10 = require("@dxos/protocols");
|
|
204
|
-
var
|
|
209
|
+
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
205
210
|
var import_async15 = require("@dxos/async");
|
|
206
|
-
var
|
|
207
|
-
var
|
|
211
|
+
var import_context10 = require("@dxos/context");
|
|
212
|
+
var import_credentials15 = require("@dxos/credentials");
|
|
208
213
|
var import_debug6 = require("@dxos/debug");
|
|
214
|
+
var import_echo_db = require("@dxos/echo-db");
|
|
209
215
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
210
216
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
211
|
-
var import_indexing = require("@dxos/indexing");
|
|
212
217
|
var import_invariant13 = require("@dxos/invariant");
|
|
213
218
|
var import_keyring = require("@dxos/keyring");
|
|
214
|
-
var
|
|
219
|
+
var import_keys11 = require("@dxos/keys");
|
|
215
220
|
var import_log12 = require("@dxos/log");
|
|
216
221
|
var import_protocols11 = require("@dxos/protocols");
|
|
217
|
-
var
|
|
222
|
+
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
218
223
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
219
224
|
var import_tracing5 = require("@dxos/tracing");
|
|
220
225
|
var import_util7 = require("@dxos/util");
|
|
221
|
-
var import_automerge = require("@dxos/automerge/automerge");
|
|
222
|
-
var import_debug7 = require("@dxos/debug");
|
|
223
|
-
var import_protocols12 = require("@dxos/protocols");
|
|
224
226
|
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
225
|
-
var
|
|
227
|
+
var import_credentials16 = require("@dxos/credentials");
|
|
226
228
|
var import_invariant14 = require("@dxos/invariant");
|
|
227
|
-
var
|
|
228
|
-
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
229
|
-
var import_tracing6 = require("@dxos/tracing");
|
|
229
|
+
var import_protocols12 = require("@dxos/protocols");
|
|
230
230
|
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
231
|
-
var
|
|
231
|
+
var import_tracing6 = require("@dxos/tracing");
|
|
232
232
|
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
233
|
+
var import_config = require("@dxos/config");
|
|
234
|
+
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
233
235
|
var import_tracing7 = require("@dxos/tracing");
|
|
234
236
|
var import_util8 = require("@dxos/util");
|
|
235
237
|
var import_async16 = require("@dxos/async");
|
|
236
|
-
var
|
|
237
|
-
var
|
|
238
|
+
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
239
|
+
var import_context11 = require("@dxos/context");
|
|
238
240
|
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
239
|
-
var
|
|
240
|
-
var import_indexing2 = require("@dxos/indexing");
|
|
241
|
+
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
241
242
|
var import_invariant15 = require("@dxos/invariant");
|
|
242
|
-
var
|
|
243
|
+
var import_keys12 = require("@dxos/keys");
|
|
243
244
|
var import_log13 = require("@dxos/log");
|
|
244
245
|
var import_messaging = require("@dxos/messaging");
|
|
245
246
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
246
|
-
var
|
|
247
|
-
var
|
|
247
|
+
var import_protocols13 = require("@dxos/protocols");
|
|
248
|
+
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
248
249
|
var import_tracing8 = require("@dxos/tracing");
|
|
249
250
|
var import_util9 = require("@dxos/util");
|
|
250
251
|
var import_websocket_rpc = require("@dxos/websocket-rpc");
|
|
251
252
|
var import_async17 = require("@dxos/async");
|
|
252
253
|
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
253
254
|
var import_invariant16 = require("@dxos/invariant");
|
|
254
|
-
var
|
|
255
|
+
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
255
256
|
var import_invariant17 = require("@dxos/invariant");
|
|
256
257
|
var import_lock_file = require("@dxos/lock-file");
|
|
257
258
|
var import_log14 = require("@dxos/log");
|
|
258
259
|
var import_async18 = require("@dxos/async");
|
|
259
260
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
260
|
-
var
|
|
261
|
+
var import_keys13 = require("@dxos/keys");
|
|
261
262
|
var import_log15 = require("@dxos/log");
|
|
262
|
-
var
|
|
263
|
+
var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
|
|
263
264
|
var import_util10 = require("@dxos/util");
|
|
264
265
|
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
265
|
-
var
|
|
266
|
+
var import_protocols14 = require("@dxos/protocols");
|
|
266
267
|
var import_config2 = require("@dxos/protocols/proto/dxos/config");
|
|
267
268
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
268
|
-
var
|
|
269
|
+
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
269
270
|
var import_config3 = require("@dxos/protocols/proto/dxos/config");
|
|
270
271
|
var import_util11 = require("@dxos/util");
|
|
271
272
|
var import_level = require("level");
|
|
272
273
|
var import_node_path = __toESM(require("node:path"));
|
|
273
|
-
var
|
|
274
|
+
var import_keys14 = require("@dxos/keys");
|
|
274
275
|
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
275
|
-
var
|
|
276
|
+
var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
|
|
276
277
|
var import_util12 = require("@dxos/util");
|
|
277
|
-
var
|
|
278
|
+
var import_keys15 = require("@dxos/keys");
|
|
278
279
|
var import_util13 = require("@dxos/util");
|
|
279
280
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
280
281
|
return new import_codec_protobuf.Stream(({ next }) => {
|
|
@@ -1293,7 +1294,9 @@ var IdentityManager = class {
|
|
|
1293
1294
|
C: (f, a) => f(...a)
|
|
1294
1295
|
});
|
|
1295
1296
|
},
|
|
1296
|
-
memberKey: identityKey
|
|
1297
|
+
memberKey: identityKey,
|
|
1298
|
+
onDelegatedInvitationStatusChange: async () => {
|
|
1299
|
+
}
|
|
1297
1300
|
});
|
|
1298
1301
|
}
|
|
1299
1302
|
};
|
|
@@ -1390,10 +1393,13 @@ var DeviceInvitationProtocol = class {
|
|
|
1390
1393
|
kind: import_services2.Invitation.Kind.DEVICE
|
|
1391
1394
|
};
|
|
1392
1395
|
}
|
|
1393
|
-
async
|
|
1396
|
+
async delegate(invitation) {
|
|
1397
|
+
throw new Error("delegation not supported");
|
|
1398
|
+
}
|
|
1399
|
+
async admit(_, request) {
|
|
1394
1400
|
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1395
1401
|
F: __dxlog_file5,
|
|
1396
|
-
L:
|
|
1402
|
+
L: 42,
|
|
1397
1403
|
S: this,
|
|
1398
1404
|
A: [
|
|
1399
1405
|
"request.device",
|
|
@@ -1439,7 +1445,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1439
1445
|
async accept(response, request) {
|
|
1440
1446
|
(0, import_invariant4.invariant)(response.device, void 0, {
|
|
1441
1447
|
F: __dxlog_file5,
|
|
1442
|
-
L:
|
|
1448
|
+
L: 87,
|
|
1443
1449
|
S: this,
|
|
1444
1450
|
A: [
|
|
1445
1451
|
"response.device",
|
|
@@ -1449,7 +1455,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1449
1455
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1450
1456
|
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1451
1457
|
F: __dxlog_file5,
|
|
1452
|
-
L:
|
|
1458
|
+
L: 90,
|
|
1453
1459
|
S: this,
|
|
1454
1460
|
A: [
|
|
1455
1461
|
"request.device",
|
|
@@ -1824,51 +1830,7 @@ var InvitationsHandler = class {
|
|
|
1824
1830
|
constructor(_networkManager) {
|
|
1825
1831
|
this._networkManager = _networkManager;
|
|
1826
1832
|
}
|
|
1827
|
-
|
|
1828
|
-
const { invitationId = import_keys5.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys5.PublicKey.random(), persistent = options?.authMethod !== import_services3.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, lifetime = 86400, multiUse = false } = options ?? {};
|
|
1829
|
-
const authCode = options?.authCode ?? (authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1830
|
-
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
1831
|
-
F: __dxlog_file7,
|
|
1832
|
-
L: 87,
|
|
1833
|
-
S: this,
|
|
1834
|
-
A: [
|
|
1835
|
-
"protocol",
|
|
1836
|
-
""
|
|
1837
|
-
]
|
|
1838
|
-
});
|
|
1839
|
-
const invitation = {
|
|
1840
|
-
invitationId,
|
|
1841
|
-
type,
|
|
1842
|
-
authMethod,
|
|
1843
|
-
state,
|
|
1844
|
-
swarmKey,
|
|
1845
|
-
authCode,
|
|
1846
|
-
timeout,
|
|
1847
|
-
persistent: persistent && type !== import_services3.Invitation.Type.DELEGATED,
|
|
1848
|
-
guestKeypair: guestKeypair ?? (authMethod === import_services3.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
|
|
1849
|
-
created,
|
|
1850
|
-
lifetime,
|
|
1851
|
-
multiUse,
|
|
1852
|
-
...protocol.getInvitationContext()
|
|
1853
|
-
};
|
|
1854
|
-
const stream = new import_async7.PushStream();
|
|
1855
|
-
const ctx = new import_context4.Context({
|
|
1856
|
-
onError: (err) => {
|
|
1857
|
-
stream.error(err);
|
|
1858
|
-
void ctx.dispose();
|
|
1859
|
-
}
|
|
1860
|
-
});
|
|
1861
|
-
ctx.onDispose(() => {
|
|
1862
|
-
(0, import_log4.log)("complete", {
|
|
1863
|
-
...protocol.toJSON()
|
|
1864
|
-
}, {
|
|
1865
|
-
F: __dxlog_file7,
|
|
1866
|
-
L: 115,
|
|
1867
|
-
S: this,
|
|
1868
|
-
C: (f, a) => f(...a)
|
|
1869
|
-
});
|
|
1870
|
-
stream.complete();
|
|
1871
|
-
});
|
|
1833
|
+
handleInvitationFlow(ctx, stream, protocol, invitation) {
|
|
1872
1834
|
const createExtension = () => {
|
|
1873
1835
|
const extension = new InvitationHostExtension({
|
|
1874
1836
|
onStateUpdate: (invitation2) => {
|
|
@@ -1877,8 +1839,8 @@ var InvitationsHandler = class {
|
|
|
1877
1839
|
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1878
1840
|
});
|
|
1879
1841
|
},
|
|
1880
|
-
resolveInvitation: async ({ invitationId
|
|
1881
|
-
if (
|
|
1842
|
+
resolveInvitation: async ({ invitationId }) => {
|
|
1843
|
+
if (invitationId && invitationId !== invitation.invitationId) {
|
|
1882
1844
|
return void 0;
|
|
1883
1845
|
}
|
|
1884
1846
|
return invitation;
|
|
@@ -1888,14 +1850,14 @@ var InvitationsHandler = class {
|
|
|
1888
1850
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1889
1851
|
(0, import_invariant5.invariant)(deviceKey, void 0, {
|
|
1890
1852
|
F: __dxlog_file7,
|
|
1891
|
-
L:
|
|
1853
|
+
L: 87,
|
|
1892
1854
|
S: this,
|
|
1893
1855
|
A: [
|
|
1894
1856
|
"deviceKey",
|
|
1895
1857
|
""
|
|
1896
1858
|
]
|
|
1897
1859
|
});
|
|
1898
|
-
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1860
|
+
const admissionResponse = await protocol.admit(invitation, admissionRequest, extension.guestProfile);
|
|
1899
1861
|
extension.completedTrigger.wake(deviceKey);
|
|
1900
1862
|
return admissionResponse;
|
|
1901
1863
|
} catch (err) {
|
|
@@ -1911,7 +1873,7 @@ var InvitationsHandler = class {
|
|
|
1911
1873
|
id: traceId
|
|
1912
1874
|
}), {
|
|
1913
1875
|
F: __dxlog_file7,
|
|
1914
|
-
L:
|
|
1876
|
+
L: 105,
|
|
1915
1877
|
S: this,
|
|
1916
1878
|
C: (f, a) => f(...a)
|
|
1917
1879
|
});
|
|
@@ -1919,7 +1881,7 @@ var InvitationsHandler = class {
|
|
|
1919
1881
|
...protocol.toJSON()
|
|
1920
1882
|
}, {
|
|
1921
1883
|
F: __dxlog_file7,
|
|
1922
|
-
L:
|
|
1884
|
+
L: 106,
|
|
1923
1885
|
S: this,
|
|
1924
1886
|
C: (f, a) => f(...a)
|
|
1925
1887
|
});
|
|
@@ -1928,14 +1890,14 @@ var InvitationsHandler = class {
|
|
|
1928
1890
|
state: import_services3.Invitation.State.CONNECTED
|
|
1929
1891
|
});
|
|
1930
1892
|
const deviceKey = await extension.completedTrigger.wait({
|
|
1931
|
-
timeout
|
|
1893
|
+
timeout: invitation.timeout
|
|
1932
1894
|
});
|
|
1933
1895
|
(0, import_log4.log)("admitted guest", {
|
|
1934
1896
|
guest: deviceKey,
|
|
1935
1897
|
...protocol.toJSON()
|
|
1936
1898
|
}, {
|
|
1937
1899
|
F: __dxlog_file7,
|
|
1938
|
-
L:
|
|
1900
|
+
L: 109,
|
|
1939
1901
|
S: this,
|
|
1940
1902
|
C: (f, a) => f(...a)
|
|
1941
1903
|
});
|
|
@@ -1947,7 +1909,7 @@ var InvitationsHandler = class {
|
|
|
1947
1909
|
id: traceId
|
|
1948
1910
|
}), {
|
|
1949
1911
|
F: __dxlog_file7,
|
|
1950
|
-
L:
|
|
1912
|
+
L: 111,
|
|
1951
1913
|
S: this,
|
|
1952
1914
|
C: (f, a) => f(...a)
|
|
1953
1915
|
});
|
|
@@ -1957,7 +1919,7 @@ var InvitationsHandler = class {
|
|
|
1957
1919
|
...protocol.toJSON()
|
|
1958
1920
|
}, {
|
|
1959
1921
|
F: __dxlog_file7,
|
|
1960
|
-
L:
|
|
1922
|
+
L: 114,
|
|
1961
1923
|
S: this,
|
|
1962
1924
|
C: (f, a) => f(...a)
|
|
1963
1925
|
});
|
|
@@ -1968,7 +1930,7 @@ var InvitationsHandler = class {
|
|
|
1968
1930
|
} else {
|
|
1969
1931
|
import_log4.log.error("failed", err, {
|
|
1970
1932
|
F: __dxlog_file7,
|
|
1971
|
-
L:
|
|
1933
|
+
L: 117,
|
|
1972
1934
|
S: this,
|
|
1973
1935
|
C: (f, a) => f(...a)
|
|
1974
1936
|
});
|
|
@@ -1979,12 +1941,12 @@ var InvitationsHandler = class {
|
|
|
1979
1941
|
error: err
|
|
1980
1942
|
}), {
|
|
1981
1943
|
F: __dxlog_file7,
|
|
1982
|
-
L:
|
|
1944
|
+
L: 120,
|
|
1983
1945
|
S: this,
|
|
1984
1946
|
C: (f, a) => f(...a)
|
|
1985
1947
|
});
|
|
1986
1948
|
} finally {
|
|
1987
|
-
if (!multiUse) {
|
|
1949
|
+
if (!invitation.multiUse) {
|
|
1988
1950
|
await swarmConnection.close();
|
|
1989
1951
|
await ctx.dispose();
|
|
1990
1952
|
}
|
|
@@ -2000,7 +1962,7 @@ var InvitationsHandler = class {
|
|
|
2000
1962
|
...protocol.toJSON()
|
|
2001
1963
|
}, {
|
|
2002
1964
|
F: __dxlog_file7,
|
|
2003
|
-
L:
|
|
1965
|
+
L: 135,
|
|
2004
1966
|
S: this,
|
|
2005
1967
|
C: (f, a) => f(...a)
|
|
2006
1968
|
});
|
|
@@ -2011,7 +1973,7 @@ var InvitationsHandler = class {
|
|
|
2011
1973
|
} else {
|
|
2012
1974
|
import_log4.log.error("failed", err, {
|
|
2013
1975
|
F: __dxlog_file7,
|
|
2014
|
-
L:
|
|
1976
|
+
L: 138,
|
|
2015
1977
|
S: this,
|
|
2016
1978
|
C: (f, a) => f(...a)
|
|
2017
1979
|
});
|
|
@@ -2025,7 +1987,7 @@ var InvitationsHandler = class {
|
|
|
2025
1987
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
2026
1988
|
import_log4.log.warn("invitation has already expired", void 0, {
|
|
2027
1989
|
F: __dxlog_file7,
|
|
2028
|
-
L:
|
|
1990
|
+
L: 149,
|
|
2029
1991
|
S: this,
|
|
2030
1992
|
C: (f, a) => f(...a)
|
|
2031
1993
|
});
|
|
@@ -2059,24 +2021,12 @@ var InvitationsHandler = class {
|
|
|
2059
2021
|
state: import_services3.Invitation.State.CONNECTING
|
|
2060
2022
|
});
|
|
2061
2023
|
});
|
|
2062
|
-
const observable = new import_client_protocol2.CancellableInvitation({
|
|
2063
|
-
initialInvitation: invitation,
|
|
2064
|
-
subscriber: stream.observable,
|
|
2065
|
-
onCancel: async () => {
|
|
2066
|
-
stream.next({
|
|
2067
|
-
...invitation,
|
|
2068
|
-
state: import_services3.Invitation.State.CANCELLED
|
|
2069
|
-
});
|
|
2070
|
-
await ctx.dispose();
|
|
2071
|
-
}
|
|
2072
|
-
});
|
|
2073
|
-
return observable;
|
|
2074
2024
|
}
|
|
2075
2025
|
acceptInvitation(protocol, invitation, deviceProfile) {
|
|
2076
2026
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
2077
2027
|
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
2078
2028
|
F: __dxlog_file7,
|
|
2079
|
-
L:
|
|
2029
|
+
L: 191,
|
|
2080
2030
|
S: this,
|
|
2081
2031
|
A: [
|
|
2082
2032
|
"protocol",
|
|
@@ -2086,7 +2036,7 @@ var InvitationsHandler = class {
|
|
|
2086
2036
|
if (deviceProfile) {
|
|
2087
2037
|
(0, import_invariant5.invariant)(invitation.kind === import_services3.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2088
2038
|
F: __dxlog_file7,
|
|
2089
|
-
L:
|
|
2039
|
+
L: 194,
|
|
2090
2040
|
S: this,
|
|
2091
2041
|
A: [
|
|
2092
2042
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -2101,7 +2051,7 @@ var InvitationsHandler = class {
|
|
|
2101
2051
|
const setState = (newData) => {
|
|
2102
2052
|
(0, import_invariant5.invariant)(newData.state !== void 0, void 0, {
|
|
2103
2053
|
F: __dxlog_file7,
|
|
2104
|
-
L:
|
|
2054
|
+
L: 205,
|
|
2105
2055
|
S: this,
|
|
2106
2056
|
A: [
|
|
2107
2057
|
"newData.state !== undefined",
|
|
@@ -2121,7 +2071,7 @@ var InvitationsHandler = class {
|
|
|
2121
2071
|
...protocol.toJSON()
|
|
2122
2072
|
}, {
|
|
2123
2073
|
F: __dxlog_file7,
|
|
2124
|
-
L:
|
|
2074
|
+
L: 213,
|
|
2125
2075
|
S: this,
|
|
2126
2076
|
C: (f, a) => f(...a)
|
|
2127
2077
|
});
|
|
@@ -2131,7 +2081,7 @@ var InvitationsHandler = class {
|
|
|
2131
2081
|
} else {
|
|
2132
2082
|
import_log4.log.warn("auth failed", err, {
|
|
2133
2083
|
F: __dxlog_file7,
|
|
2134
|
-
L:
|
|
2084
|
+
L: 216,
|
|
2135
2085
|
S: this,
|
|
2136
2086
|
C: (f, a) => f(...a)
|
|
2137
2087
|
});
|
|
@@ -2145,7 +2095,7 @@ var InvitationsHandler = class {
|
|
|
2145
2095
|
...protocol.toJSON()
|
|
2146
2096
|
}, {
|
|
2147
2097
|
F: __dxlog_file7,
|
|
2148
|
-
L:
|
|
2098
|
+
L: 224,
|
|
2149
2099
|
S: this,
|
|
2150
2100
|
C: (f, a) => f(...a)
|
|
2151
2101
|
});
|
|
@@ -2160,7 +2110,7 @@ var InvitationsHandler = class {
|
|
|
2160
2110
|
currentState
|
|
2161
2111
|
}, {
|
|
2162
2112
|
F: __dxlog_file7,
|
|
2163
|
-
L:
|
|
2113
|
+
L: 234,
|
|
2164
2114
|
S: this,
|
|
2165
2115
|
C: (f, a) => f(...a)
|
|
2166
2116
|
});
|
|
@@ -2175,7 +2125,7 @@ var InvitationsHandler = class {
|
|
|
2175
2125
|
id: traceId
|
|
2176
2126
|
}), {
|
|
2177
2127
|
F: __dxlog_file7,
|
|
2178
|
-
L:
|
|
2128
|
+
L: 243,
|
|
2179
2129
|
S: this,
|
|
2180
2130
|
C: (f, a) => f(...a)
|
|
2181
2131
|
});
|
|
@@ -2187,7 +2137,7 @@ var InvitationsHandler = class {
|
|
|
2187
2137
|
...protocol.toJSON()
|
|
2188
2138
|
}, {
|
|
2189
2139
|
F: __dxlog_file7,
|
|
2190
|
-
L:
|
|
2140
|
+
L: 251,
|
|
2191
2141
|
S: this,
|
|
2192
2142
|
C: (f, a) => f(...a)
|
|
2193
2143
|
});
|
|
@@ -2198,7 +2148,7 @@ var InvitationsHandler = class {
|
|
|
2198
2148
|
...protocol.toJSON()
|
|
2199
2149
|
}, {
|
|
2200
2150
|
F: __dxlog_file7,
|
|
2201
|
-
L:
|
|
2151
|
+
L: 255,
|
|
2202
2152
|
S: this,
|
|
2203
2153
|
C: (f, a) => f(...a)
|
|
2204
2154
|
});
|
|
@@ -2208,7 +2158,7 @@ var InvitationsHandler = class {
|
|
|
2208
2158
|
response: introductionResponse
|
|
2209
2159
|
}, {
|
|
2210
2160
|
F: __dxlog_file7,
|
|
2211
|
-
L:
|
|
2161
|
+
L: 259,
|
|
2212
2162
|
S: this,
|
|
2213
2163
|
C: (f, a) => f(...a)
|
|
2214
2164
|
});
|
|
@@ -2229,7 +2179,7 @@ var InvitationsHandler = class {
|
|
|
2229
2179
|
...protocol.toJSON()
|
|
2230
2180
|
}, {
|
|
2231
2181
|
F: __dxlog_file7,
|
|
2232
|
-
L:
|
|
2182
|
+
L: 275,
|
|
2233
2183
|
S: this,
|
|
2234
2184
|
C: (f, a) => f(...a)
|
|
2235
2185
|
});
|
|
@@ -2241,7 +2191,7 @@ var InvitationsHandler = class {
|
|
|
2241
2191
|
...protocol.toJSON()
|
|
2242
2192
|
}, {
|
|
2243
2193
|
F: __dxlog_file7,
|
|
2244
|
-
L:
|
|
2194
|
+
L: 286,
|
|
2245
2195
|
S: this,
|
|
2246
2196
|
C: (f, a) => f(...a)
|
|
2247
2197
|
});
|
|
@@ -2254,7 +2204,7 @@ var InvitationsHandler = class {
|
|
|
2254
2204
|
id: traceId
|
|
2255
2205
|
}), {
|
|
2256
2206
|
F: __dxlog_file7,
|
|
2257
|
-
L:
|
|
2207
|
+
L: 288,
|
|
2258
2208
|
S: this,
|
|
2259
2209
|
C: (f, a) => f(...a)
|
|
2260
2210
|
});
|
|
@@ -2264,7 +2214,7 @@ var InvitationsHandler = class {
|
|
|
2264
2214
|
...protocol.toJSON()
|
|
2265
2215
|
}, {
|
|
2266
2216
|
F: __dxlog_file7,
|
|
2267
|
-
L:
|
|
2217
|
+
L: 291,
|
|
2268
2218
|
S: this,
|
|
2269
2219
|
C: (f, a) => f(...a)
|
|
2270
2220
|
});
|
|
@@ -2274,7 +2224,7 @@ var InvitationsHandler = class {
|
|
|
2274
2224
|
} else {
|
|
2275
2225
|
(0, import_log4.log)("auth failed", err, {
|
|
2276
2226
|
F: __dxlog_file7,
|
|
2277
|
-
L:
|
|
2227
|
+
L: 294,
|
|
2278
2228
|
S: this,
|
|
2279
2229
|
C: (f, a) => f(...a)
|
|
2280
2230
|
});
|
|
@@ -2285,7 +2235,7 @@ var InvitationsHandler = class {
|
|
|
2285
2235
|
error: err
|
|
2286
2236
|
}), {
|
|
2287
2237
|
F: __dxlog_file7,
|
|
2288
|
-
L:
|
|
2238
|
+
L: 297,
|
|
2289
2239
|
S: this,
|
|
2290
2240
|
C: (f, a) => f(...a)
|
|
2291
2241
|
});
|
|
@@ -2303,7 +2253,7 @@ var InvitationsHandler = class {
|
|
|
2303
2253
|
...protocol.toJSON()
|
|
2304
2254
|
}, {
|
|
2305
2255
|
F: __dxlog_file7,
|
|
2306
|
-
L:
|
|
2256
|
+
L: 308,
|
|
2307
2257
|
S: this,
|
|
2308
2258
|
C: (f, a) => f(...a)
|
|
2309
2259
|
});
|
|
@@ -2313,7 +2263,7 @@ var InvitationsHandler = class {
|
|
|
2313
2263
|
} else {
|
|
2314
2264
|
(0, import_log4.log)("auth failed", err, {
|
|
2315
2265
|
F: __dxlog_file7,
|
|
2316
|
-
L:
|
|
2266
|
+
L: 311,
|
|
2317
2267
|
S: this,
|
|
2318
2268
|
C: (f, a) => f(...a)
|
|
2319
2269
|
});
|
|
@@ -2330,7 +2280,7 @@ var InvitationsHandler = class {
|
|
|
2330
2280
|
} else {
|
|
2331
2281
|
(0, import_invariant5.invariant)(invitation.swarmKey, void 0, {
|
|
2332
2282
|
F: __dxlog_file7,
|
|
2333
|
-
L:
|
|
2283
|
+
L: 325,
|
|
2334
2284
|
S: this,
|
|
2335
2285
|
A: [
|
|
2336
2286
|
"invitation.swarmKey",
|
|
@@ -2372,7 +2322,7 @@ var InvitationsHandler = class {
|
|
|
2372
2322
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2373
2323
|
(0, import_log4.log)("guest waiting for authentication code...", void 0, {
|
|
2374
2324
|
F: __dxlog_file7,
|
|
2375
|
-
L:
|
|
2325
|
+
L: 365,
|
|
2376
2326
|
S: this,
|
|
2377
2327
|
C: (f, a) => f(...a)
|
|
2378
2328
|
});
|
|
@@ -2382,7 +2332,7 @@ var InvitationsHandler = class {
|
|
|
2382
2332
|
const authCode = await authenticated.wait(options);
|
|
2383
2333
|
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2384
2334
|
F: __dxlog_file7,
|
|
2385
|
-
L:
|
|
2335
|
+
L: 369,
|
|
2386
2336
|
S: this,
|
|
2387
2337
|
C: (f, a) => f(...a)
|
|
2388
2338
|
});
|
|
@@ -2403,7 +2353,7 @@ var InvitationsHandler = class {
|
|
|
2403
2353
|
attempt
|
|
2404
2354
|
}, {
|
|
2405
2355
|
F: __dxlog_file7,
|
|
2406
|
-
L:
|
|
2356
|
+
L: 380,
|
|
2407
2357
|
S: this,
|
|
2408
2358
|
C: (f, a) => f(...a)
|
|
2409
2359
|
});
|
|
@@ -2421,7 +2371,7 @@ var InvitationsHandler = class {
|
|
|
2421
2371
|
}
|
|
2422
2372
|
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2423
2373
|
F: __dxlog_file7,
|
|
2424
|
-
L:
|
|
2374
|
+
L: 399,
|
|
2425
2375
|
S: this,
|
|
2426
2376
|
C: (f, a) => f(...a)
|
|
2427
2377
|
});
|
|
@@ -2453,9 +2403,8 @@ var InvitationsServiceImpl = class {
|
|
|
2453
2403
|
return {};
|
|
2454
2404
|
}
|
|
2455
2405
|
createInvitation(options) {
|
|
2456
|
-
const invitation = this._invitationsManager.createInvitation(options);
|
|
2457
2406
|
return new import_codec_protobuf8.Stream(({ next, close }) => {
|
|
2458
|
-
invitation.subscribe(next, close, close);
|
|
2407
|
+
void this._invitationsManager.createInvitation(options).then((invitation) => invitation.subscribe(next, close, close)).catch(close);
|
|
2459
2408
|
});
|
|
2460
2409
|
}
|
|
2461
2410
|
acceptInvitation(request) {
|
|
@@ -2558,10 +2507,10 @@ var SpaceInvitationProtocol = class {
|
|
|
2558
2507
|
spaceKey: this._spaceKey
|
|
2559
2508
|
};
|
|
2560
2509
|
}
|
|
2561
|
-
async admit(request, guestProfile) {
|
|
2510
|
+
async admit(invitation, request, guestProfile) {
|
|
2562
2511
|
(0, import_invariant7.invariant)(this._spaceKey, void 0, {
|
|
2563
2512
|
F: __dxlog_file8,
|
|
2564
|
-
L:
|
|
2513
|
+
L: 55,
|
|
2565
2514
|
S: this,
|
|
2566
2515
|
A: [
|
|
2567
2516
|
"this._spaceKey",
|
|
@@ -2571,7 +2520,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2571
2520
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2572
2521
|
(0, import_invariant7.invariant)(space, void 0, {
|
|
2573
2522
|
F: __dxlog_file8,
|
|
2574
|
-
L:
|
|
2523
|
+
L: 57,
|
|
2575
2524
|
S: this,
|
|
2576
2525
|
A: [
|
|
2577
2526
|
"space",
|
|
@@ -2580,7 +2529,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2580
2529
|
});
|
|
2581
2530
|
(0, import_invariant7.invariant)(request.space, void 0, {
|
|
2582
2531
|
F: __dxlog_file8,
|
|
2583
|
-
L:
|
|
2532
|
+
L: 59,
|
|
2584
2533
|
S: this,
|
|
2585
2534
|
A: [
|
|
2586
2535
|
"request.space",
|
|
@@ -2593,14 +2542,14 @@ var SpaceInvitationProtocol = class {
|
|
|
2593
2542
|
guest: deviceKey
|
|
2594
2543
|
}, {
|
|
2595
2544
|
F: __dxlog_file8,
|
|
2596
|
-
L:
|
|
2545
|
+
L: 62,
|
|
2597
2546
|
S: this,
|
|
2598
2547
|
C: (f, a) => f(...a)
|
|
2599
2548
|
});
|
|
2600
|
-
const credentials = await (0,
|
|
2549
|
+
const credentials = await (0, import_credentials7.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile, invitation.delegationCredentialId);
|
|
2601
2550
|
(0, import_invariant7.invariant)(credentials[0].credential, void 0, {
|
|
2602
2551
|
F: __dxlog_file8,
|
|
2603
|
-
L:
|
|
2552
|
+
L: 74,
|
|
2604
2553
|
S: this,
|
|
2605
2554
|
A: [
|
|
2606
2555
|
"credentials[0].credential",
|
|
@@ -2608,9 +2557,9 @@ var SpaceInvitationProtocol = class {
|
|
|
2608
2557
|
]
|
|
2609
2558
|
});
|
|
2610
2559
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2611
|
-
(0, import_invariant7.invariant)((0,
|
|
2560
|
+
(0, import_invariant7.invariant)((0, import_credentials7.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2612
2561
|
F: __dxlog_file8,
|
|
2613
|
-
L:
|
|
2562
|
+
L: 76,
|
|
2614
2563
|
S: this,
|
|
2615
2564
|
A: [
|
|
2616
2565
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2625,6 +2574,69 @@ var SpaceInvitationProtocol = class {
|
|
|
2625
2574
|
}
|
|
2626
2575
|
};
|
|
2627
2576
|
}
|
|
2577
|
+
async delegate(invitation) {
|
|
2578
|
+
(0, import_invariant7.invariant)(this._spaceKey, void 0, {
|
|
2579
|
+
F: __dxlog_file8,
|
|
2580
|
+
L: 89,
|
|
2581
|
+
S: this,
|
|
2582
|
+
A: [
|
|
2583
|
+
"this._spaceKey",
|
|
2584
|
+
""
|
|
2585
|
+
]
|
|
2586
|
+
});
|
|
2587
|
+
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2588
|
+
(0, import_invariant7.invariant)(space, void 0, {
|
|
2589
|
+
F: __dxlog_file8,
|
|
2590
|
+
L: 91,
|
|
2591
|
+
S: this,
|
|
2592
|
+
A: [
|
|
2593
|
+
"space",
|
|
2594
|
+
""
|
|
2595
|
+
]
|
|
2596
|
+
});
|
|
2597
|
+
if (invitation.authMethod === import_services6.Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
2598
|
+
(0, import_invariant7.invariant)(invitation.guestKeypair?.publicKey, void 0, {
|
|
2599
|
+
F: __dxlog_file8,
|
|
2600
|
+
L: 93,
|
|
2601
|
+
S: this,
|
|
2602
|
+
A: [
|
|
2603
|
+
"invitation.guestKeypair?.publicKey",
|
|
2604
|
+
""
|
|
2605
|
+
]
|
|
2606
|
+
});
|
|
2607
|
+
}
|
|
2608
|
+
(0, import_log6.log)("writing delegate space invitation", {
|
|
2609
|
+
host: this._signingContext.deviceKey,
|
|
2610
|
+
id: invitation.invitationId
|
|
2611
|
+
}, {
|
|
2612
|
+
F: __dxlog_file8,
|
|
2613
|
+
L: 96,
|
|
2614
|
+
S: this,
|
|
2615
|
+
C: (f, a) => f(...a)
|
|
2616
|
+
});
|
|
2617
|
+
const credential = await (0, import_credentials7.createDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, {
|
|
2618
|
+
invitationId: invitation.invitationId,
|
|
2619
|
+
authMethod: invitation.authMethod,
|
|
2620
|
+
swarmKey: invitation.swarmKey,
|
|
2621
|
+
role: import_credentials8.SpaceMember.Role.ADMIN,
|
|
2622
|
+
expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
|
|
2623
|
+
multiUse: invitation.multiUse ?? false,
|
|
2624
|
+
guestKey: invitation.authMethod === import_services6.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
|
|
2625
|
+
});
|
|
2626
|
+
(0, import_invariant7.invariant)(credential.credential, void 0, {
|
|
2627
|
+
F: __dxlog_file8,
|
|
2628
|
+
L: 116,
|
|
2629
|
+
S: this,
|
|
2630
|
+
A: [
|
|
2631
|
+
"credential.credential",
|
|
2632
|
+
""
|
|
2633
|
+
]
|
|
2634
|
+
});
|
|
2635
|
+
await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, [
|
|
2636
|
+
credential
|
|
2637
|
+
]);
|
|
2638
|
+
return credential.credential.credential.id;
|
|
2639
|
+
}
|
|
2628
2640
|
checkInvitation(invitation) {
|
|
2629
2641
|
if (invitation.spaceKey && this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
2630
2642
|
return new import_protocols6.AlreadyJoinedError("Already joined space.");
|
|
@@ -2650,7 +2662,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2650
2662
|
async accept(response) {
|
|
2651
2663
|
(0, import_invariant7.invariant)(response.space, void 0, {
|
|
2652
2664
|
F: __dxlog_file8,
|
|
2653
|
-
L:
|
|
2665
|
+
L: 149,
|
|
2654
2666
|
S: this,
|
|
2655
2667
|
A: [
|
|
2656
2668
|
"response.space",
|
|
@@ -2658,10 +2670,10 @@ var SpaceInvitationProtocol = class {
|
|
|
2658
2670
|
]
|
|
2659
2671
|
});
|
|
2660
2672
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2661
|
-
const assertion = (0,
|
|
2673
|
+
const assertion = (0, import_credentials7.getCredentialAssertion)(credential);
|
|
2662
2674
|
(0, import_invariant7.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2663
2675
|
F: __dxlog_file8,
|
|
2664
|
-
L:
|
|
2676
|
+
L: 152,
|
|
2665
2677
|
S: this,
|
|
2666
2678
|
A: [
|
|
2667
2679
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2670,7 +2682,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2670
2682
|
});
|
|
2671
2683
|
(0, import_invariant7.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2672
2684
|
F: __dxlog_file8,
|
|
2673
|
-
L:
|
|
2685
|
+
L: 153,
|
|
2674
2686
|
S: this,
|
|
2675
2687
|
A: [
|
|
2676
2688
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
@@ -2708,25 +2720,39 @@ var InvitationsManager = class {
|
|
|
2708
2720
|
this._persistentInvitationsLoadedEvent = new import_async9.Event();
|
|
2709
2721
|
this._persistentInvitationsLoaded = false;
|
|
2710
2722
|
}
|
|
2711
|
-
createInvitation(options) {
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2723
|
+
async createInvitation(options) {
|
|
2724
|
+
if (options.invitationId) {
|
|
2725
|
+
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2726
|
+
if (existingInvitation) {
|
|
2727
|
+
return existingInvitation;
|
|
2728
|
+
}
|
|
2715
2729
|
}
|
|
2716
2730
|
const handler = this._getHandler(options);
|
|
2717
|
-
const invitation = this.
|
|
2718
|
-
this.
|
|
2719
|
-
this.
|
|
2720
|
-
|
|
2721
|
-
this._onInvitationComplete(
|
|
2722
|
-
this._createInvitations.delete(
|
|
2723
|
-
this.removedCreated.emit(
|
|
2724
|
-
if (
|
|
2725
|
-
await
|
|
2726
|
-
await this._safeDeleteInvitation(invitation.get());
|
|
2731
|
+
const invitation = this._createInvitation(handler, options);
|
|
2732
|
+
const { ctx, stream, observableInvitation } = this._createObservableInvitation(handler, invitation);
|
|
2733
|
+
this._createInvitations.set(invitation.invitationId, observableInvitation);
|
|
2734
|
+
this.invitationCreated.emit(invitation);
|
|
2735
|
+
this._onInvitationComplete(observableInvitation, async () => {
|
|
2736
|
+
this._createInvitations.delete(observableInvitation.get().invitationId);
|
|
2737
|
+
this.removedCreated.emit(observableInvitation.get());
|
|
2738
|
+
if (observableInvitation.get().persistent) {
|
|
2739
|
+
await this._safeDeleteInvitation(observableInvitation.get());
|
|
2727
2740
|
}
|
|
2728
2741
|
});
|
|
2729
|
-
|
|
2742
|
+
try {
|
|
2743
|
+
await this._persistIfRequired(handler, stream, invitation);
|
|
2744
|
+
} catch (err) {
|
|
2745
|
+
import_log7.log.catch(err, void 0, {
|
|
2746
|
+
F: __dxlog_file9,
|
|
2747
|
+
L: 76,
|
|
2748
|
+
S: this,
|
|
2749
|
+
C: (f, a) => f(...a)
|
|
2750
|
+
});
|
|
2751
|
+
await observableInvitation.cancel();
|
|
2752
|
+
return observableInvitation;
|
|
2753
|
+
}
|
|
2754
|
+
this._invitationsHandler.handleInvitationFlow(ctx, stream, handler, observableInvitation.get());
|
|
2755
|
+
return observableInvitation;
|
|
2730
2756
|
}
|
|
2731
2757
|
async loadPersistentInvitations() {
|
|
2732
2758
|
if (this._persistentInvitationsLoaded) {
|
|
@@ -2738,10 +2764,10 @@ var InvitationsManager = class {
|
|
|
2738
2764
|
try {
|
|
2739
2765
|
const persistentInvitations = this._metadataStore.getInvitations();
|
|
2740
2766
|
const freshInvitations = persistentInvitations.filter((invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
|
|
2741
|
-
const
|
|
2767
|
+
const loadTasks = freshInvitations.map((persistentInvitation) => {
|
|
2742
2768
|
(0, import_invariant8.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2743
2769
|
F: __dxlog_file9,
|
|
2744
|
-
L:
|
|
2770
|
+
L: 97,
|
|
2745
2771
|
S: this,
|
|
2746
2772
|
A: [
|
|
2747
2773
|
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
@@ -2751,15 +2777,16 @@ var InvitationsManager = class {
|
|
|
2751
2777
|
return this.createInvitation({
|
|
2752
2778
|
...persistentInvitation,
|
|
2753
2779
|
persistent: false
|
|
2754
|
-
})
|
|
2780
|
+
});
|
|
2755
2781
|
});
|
|
2782
|
+
const cInvitations = await Promise.all(loadTasks);
|
|
2756
2783
|
return {
|
|
2757
|
-
invitations: cInvitations
|
|
2784
|
+
invitations: cInvitations.map((invitation) => invitation.get())
|
|
2758
2785
|
};
|
|
2759
2786
|
} catch (err) {
|
|
2760
2787
|
import_log7.log.catch(err, void 0, {
|
|
2761
2788
|
F: __dxlog_file9,
|
|
2762
|
-
L:
|
|
2789
|
+
L: 104,
|
|
2763
2790
|
S: this,
|
|
2764
2791
|
C: (f, a) => f(...a)
|
|
2765
2792
|
});
|
|
@@ -2790,13 +2817,13 @@ var InvitationsManager = class {
|
|
|
2790
2817
|
async authenticate({ invitationId, authCode }) {
|
|
2791
2818
|
(0, import_log7.log)("authenticating...", void 0, {
|
|
2792
2819
|
F: __dxlog_file9,
|
|
2793
|
-
L:
|
|
2820
|
+
L: 133,
|
|
2794
2821
|
S: this,
|
|
2795
2822
|
C: (f, a) => f(...a)
|
|
2796
2823
|
});
|
|
2797
2824
|
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2798
2825
|
F: __dxlog_file9,
|
|
2799
|
-
L:
|
|
2826
|
+
L: 134,
|
|
2800
2827
|
S: this,
|
|
2801
2828
|
A: [
|
|
2802
2829
|
"invitationId",
|
|
@@ -2809,7 +2836,7 @@ var InvitationsManager = class {
|
|
|
2809
2836
|
invitationId
|
|
2810
2837
|
}, {
|
|
2811
2838
|
F: __dxlog_file9,
|
|
2812
|
-
L:
|
|
2839
|
+
L: 137,
|
|
2813
2840
|
S: this,
|
|
2814
2841
|
C: (f, a) => f(...a)
|
|
2815
2842
|
});
|
|
@@ -2822,13 +2849,13 @@ var InvitationsManager = class {
|
|
|
2822
2849
|
invitationId
|
|
2823
2850
|
}, {
|
|
2824
2851
|
F: __dxlog_file9,
|
|
2825
|
-
L:
|
|
2852
|
+
L: 144,
|
|
2826
2853
|
S: this,
|
|
2827
2854
|
C: (f, a) => f(...a)
|
|
2828
2855
|
});
|
|
2829
2856
|
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2830
2857
|
F: __dxlog_file9,
|
|
2831
|
-
L:
|
|
2858
|
+
L: 145,
|
|
2832
2859
|
S: this,
|
|
2833
2860
|
A: [
|
|
2834
2861
|
"invitationId",
|
|
@@ -2869,25 +2896,73 @@ var InvitationsManager = class {
|
|
|
2869
2896
|
this._persistentInvitationsLoadedEvent.once(ctx, () => callback());
|
|
2870
2897
|
}
|
|
2871
2898
|
}
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2899
|
+
_createInvitation(protocol, options) {
|
|
2900
|
+
const { invitationId = import_keys7.PublicKey.random().toHex(), type = import_services7.Invitation.Type.INTERACTIVE, authMethod = import_services7.Invitation.AuthMethod.SHARED_SECRET, state = import_services7.Invitation.State.INIT, timeout = import_client_protocol3.INVITATION_TIMEOUT, swarmKey = import_keys7.PublicKey.random(), persistent = options?.authMethod !== import_services7.Invitation.AuthMethod.KNOWN_PUBLIC_KEY, created = /* @__PURE__ */ new Date(), guestKeypair = void 0, lifetime = 86400, multiUse = false } = options ?? {};
|
|
2901
|
+
const authCode = options?.authCode ?? (authMethod === import_services7.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials9.generatePasscode)(import_client_protocol3.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
2902
|
+
return {
|
|
2903
|
+
invitationId,
|
|
2904
|
+
type,
|
|
2905
|
+
authMethod,
|
|
2906
|
+
state,
|
|
2907
|
+
swarmKey,
|
|
2908
|
+
authCode,
|
|
2909
|
+
timeout,
|
|
2910
|
+
persistent: persistent && type !== import_services7.Invitation.Type.DELEGATED,
|
|
2911
|
+
guestKeypair: guestKeypair ?? (authMethod === import_services7.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
|
|
2912
|
+
created,
|
|
2913
|
+
lifetime,
|
|
2914
|
+
multiUse,
|
|
2915
|
+
delegationCredentialId: options?.delegationCredentialId,
|
|
2916
|
+
...protocol.getInvitationContext()
|
|
2917
|
+
};
|
|
2918
|
+
}
|
|
2919
|
+
_createObservableInvitation(handler, invitation) {
|
|
2920
|
+
const stream = new import_async9.PushStream();
|
|
2921
|
+
const ctx = new import_context6.Context({
|
|
2922
|
+
onError: (err) => {
|
|
2923
|
+
stream.error(err);
|
|
2924
|
+
void ctx.dispose();
|
|
2925
|
+
}
|
|
2926
|
+
});
|
|
2927
|
+
ctx.onDispose(() => {
|
|
2928
|
+
(0, import_log7.log)("complete", {
|
|
2929
|
+
...handler.toJSON()
|
|
2930
|
+
}, {
|
|
2931
|
+
F: __dxlog_file9,
|
|
2932
|
+
L: 228,
|
|
2933
|
+
S: this,
|
|
2934
|
+
C: (f, a) => f(...a)
|
|
2889
2935
|
});
|
|
2936
|
+
stream.complete();
|
|
2890
2937
|
});
|
|
2938
|
+
const observableInvitation = new import_client_protocol3.CancellableInvitation({
|
|
2939
|
+
initialInvitation: invitation,
|
|
2940
|
+
subscriber: stream.observable,
|
|
2941
|
+
onCancel: async () => {
|
|
2942
|
+
stream.next({
|
|
2943
|
+
...invitation,
|
|
2944
|
+
state: import_services7.Invitation.State.CANCELLED
|
|
2945
|
+
});
|
|
2946
|
+
await ctx.dispose();
|
|
2947
|
+
}
|
|
2948
|
+
});
|
|
2949
|
+
return {
|
|
2950
|
+
ctx,
|
|
2951
|
+
stream,
|
|
2952
|
+
observableInvitation
|
|
2953
|
+
};
|
|
2954
|
+
}
|
|
2955
|
+
async _persistIfRequired(handler, changeStream, invitation) {
|
|
2956
|
+
if (invitation.type === import_services7.Invitation.Type.DELEGATED && invitation.delegationCredentialId == null) {
|
|
2957
|
+
const delegationCredentialId = await handler.delegate(invitation);
|
|
2958
|
+
changeStream.next({
|
|
2959
|
+
...invitation,
|
|
2960
|
+
delegationCredentialId
|
|
2961
|
+
});
|
|
2962
|
+
} else if (invitation.persistent) {
|
|
2963
|
+
await this._metadataStore.addInvitation(invitation);
|
|
2964
|
+
this.saved.emit(invitation);
|
|
2965
|
+
}
|
|
2891
2966
|
}
|
|
2892
2967
|
async _safeDeleteInvitation(invitation) {
|
|
2893
2968
|
try {
|
|
@@ -2895,7 +2970,7 @@ var InvitationsManager = class {
|
|
|
2895
2970
|
} catch (err) {
|
|
2896
2971
|
import_log7.log.catch(err, void 0, {
|
|
2897
2972
|
F: __dxlog_file9,
|
|
2898
|
-
L:
|
|
2973
|
+
L: 260,
|
|
2899
2974
|
S: this,
|
|
2900
2975
|
C: (f, a) => f(...a)
|
|
2901
2976
|
});
|
|
@@ -2991,7 +3066,7 @@ var AutomergeSpaceState = class {
|
|
|
2991
3066
|
this._isProcessingRootDocs = false;
|
|
2992
3067
|
}
|
|
2993
3068
|
async processCredential(credential) {
|
|
2994
|
-
if (!(0,
|
|
3069
|
+
if (!(0, import_credentials11.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
2995
3070
|
return;
|
|
2996
3071
|
}
|
|
2997
3072
|
this.lastEpoch = credential;
|
|
@@ -3023,11 +3098,11 @@ var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
|
3023
3098
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
3024
3099
|
var NotarizationPlugin = class {
|
|
3025
3100
|
constructor() {
|
|
3026
|
-
this._ctx = new
|
|
3101
|
+
this._ctx = new import_context8.Context();
|
|
3027
3102
|
this._extensionOpened = new import_async12.Event();
|
|
3028
3103
|
this._extensions = /* @__PURE__ */ new Set();
|
|
3029
|
-
this._processedCredentials = new import_util5.ComplexSet(
|
|
3030
|
-
this._processCredentialsTriggers = new import_util5.ComplexMap(
|
|
3104
|
+
this._processedCredentials = new import_util5.ComplexSet(import_keys9.PublicKey.hash);
|
|
3105
|
+
this._processCredentialsTriggers = new import_util5.ComplexMap(import_keys9.PublicKey.hash);
|
|
3031
3106
|
}
|
|
3032
3107
|
get hasWriter() {
|
|
3033
3108
|
return !!this._writer;
|
|
@@ -3148,7 +3223,7 @@ var NotarizationPlugin = class {
|
|
|
3148
3223
|
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
3149
3224
|
try {
|
|
3150
3225
|
await Promise.race([
|
|
3151
|
-
(0,
|
|
3226
|
+
(0, import_context8.rejectOnDispose)(ctx),
|
|
3152
3227
|
allNotarized,
|
|
3153
3228
|
errors.wait()
|
|
3154
3229
|
]);
|
|
@@ -3287,11 +3362,11 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3287
3362
|
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3288
3363
|
var DataSpace = class {
|
|
3289
3364
|
constructor(params) {
|
|
3290
|
-
this._ctx = new
|
|
3365
|
+
this._ctx = new import_context7.Context();
|
|
3291
3366
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3292
3367
|
this._cache = void 0;
|
|
3293
3368
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
3294
|
-
this._state =
|
|
3369
|
+
this._state = import_services8.SpaceState.CLOSED;
|
|
3295
3370
|
this.error = void 0;
|
|
3296
3371
|
this.stateUpdate = new import_async10.Event();
|
|
3297
3372
|
this.metrics = {};
|
|
@@ -3304,19 +3379,19 @@ var DataSpace = class {
|
|
|
3304
3379
|
this._metadataStore = params.metadataStore;
|
|
3305
3380
|
this._signingContext = params.signingContext;
|
|
3306
3381
|
this._callbacks = params.callbacks ?? {};
|
|
3307
|
-
this.
|
|
3382
|
+
this._echoHost = params.echoHost;
|
|
3308
3383
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
3309
|
-
trustedKeysProvider: () => new import_util4.ComplexSet(
|
|
3384
|
+
trustedKeysProvider: () => new import_util4.ComplexSet(import_keys8.PublicKey.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => !member.removed).map((member) => member.key)),
|
|
3310
3385
|
update: this._inner.stateUpdate,
|
|
3311
|
-
authTimeout:
|
|
3386
|
+
authTimeout: import_client_protocol4.AUTH_TIMEOUT
|
|
3312
3387
|
});
|
|
3313
3388
|
this._cache = params.cache;
|
|
3314
3389
|
this._state = params.initialState;
|
|
3315
3390
|
(0, import_log8.log)("new state", {
|
|
3316
|
-
state:
|
|
3391
|
+
state: import_services8.SpaceState[this._state]
|
|
3317
3392
|
}, {
|
|
3318
3393
|
F: __dxlog_file11,
|
|
3319
|
-
L:
|
|
3394
|
+
L: 135,
|
|
3320
3395
|
S: this,
|
|
3321
3396
|
C: (f, a) => f(...a)
|
|
3322
3397
|
});
|
|
@@ -3360,13 +3435,13 @@ var DataSpace = class {
|
|
|
3360
3435
|
await this._notarizationPlugin.open();
|
|
3361
3436
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3362
3437
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3363
|
-
await this._inner.open(new
|
|
3364
|
-
this._state =
|
|
3438
|
+
await this._inner.open(new import_context7.Context());
|
|
3439
|
+
this._state = import_services8.SpaceState.CONTROL_ONLY;
|
|
3365
3440
|
(0, import_log8.log)("new state", {
|
|
3366
|
-
state:
|
|
3441
|
+
state: import_services8.SpaceState[this._state]
|
|
3367
3442
|
}, {
|
|
3368
3443
|
F: __dxlog_file11,
|
|
3369
|
-
L:
|
|
3444
|
+
L: 193,
|
|
3370
3445
|
S: this,
|
|
3371
3446
|
C: (f, a) => f(...a)
|
|
3372
3447
|
});
|
|
@@ -3379,17 +3454,17 @@ var DataSpace = class {
|
|
|
3379
3454
|
}
|
|
3380
3455
|
async _close() {
|
|
3381
3456
|
await this._callbacks.beforeClose?.();
|
|
3382
|
-
this._state =
|
|
3457
|
+
this._state = import_services8.SpaceState.CLOSED;
|
|
3383
3458
|
(0, import_log8.log)("new state", {
|
|
3384
|
-
state:
|
|
3459
|
+
state: import_services8.SpaceState[this._state]
|
|
3385
3460
|
}, {
|
|
3386
3461
|
F: __dxlog_file11,
|
|
3387
|
-
L:
|
|
3462
|
+
L: 207,
|
|
3388
3463
|
S: this,
|
|
3389
3464
|
C: (f, a) => f(...a)
|
|
3390
3465
|
});
|
|
3391
3466
|
await this._ctx.dispose();
|
|
3392
|
-
this._ctx = new
|
|
3467
|
+
this._ctx = new import_context7.Context();
|
|
3393
3468
|
await this.authVerifier.close();
|
|
3394
3469
|
await this._inner.close();
|
|
3395
3470
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
@@ -3413,10 +3488,10 @@ var DataSpace = class {
|
|
|
3413
3488
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3414
3489
|
await this.initializeDataPipeline();
|
|
3415
3490
|
} catch (err) {
|
|
3416
|
-
if (err instanceof import_protocols7.CancelledError || err instanceof
|
|
3491
|
+
if (err instanceof import_protocols7.CancelledError || err instanceof import_context7.ContextDisposedError) {
|
|
3417
3492
|
(0, import_log8.log)("data pipeline initialization cancelled", err, {
|
|
3418
3493
|
F: __dxlog_file11,
|
|
3419
|
-
L:
|
|
3494
|
+
L: 240,
|
|
3420
3495
|
S: this,
|
|
3421
3496
|
C: (f, a) => f(...a)
|
|
3422
3497
|
});
|
|
@@ -3424,16 +3499,16 @@ var DataSpace = class {
|
|
|
3424
3499
|
}
|
|
3425
3500
|
import_log8.log.error("Error initializing data pipeline", err, {
|
|
3426
3501
|
F: __dxlog_file11,
|
|
3427
|
-
L:
|
|
3502
|
+
L: 244,
|
|
3428
3503
|
S: this,
|
|
3429
3504
|
C: (f, a) => f(...a)
|
|
3430
3505
|
});
|
|
3431
|
-
this._state =
|
|
3506
|
+
this._state = import_services8.SpaceState.ERROR;
|
|
3432
3507
|
(0, import_log8.log)("new state", {
|
|
3433
|
-
state:
|
|
3508
|
+
state: import_services8.SpaceState[this._state]
|
|
3434
3509
|
}, {
|
|
3435
3510
|
F: __dxlog_file11,
|
|
3436
|
-
L:
|
|
3511
|
+
L: 246,
|
|
3437
3512
|
S: this,
|
|
3438
3513
|
C: (f, a) => f(...a)
|
|
3439
3514
|
});
|
|
@@ -3445,35 +3520,35 @@ var DataSpace = class {
|
|
|
3445
3520
|
});
|
|
3446
3521
|
}
|
|
3447
3522
|
async initializeDataPipeline() {
|
|
3448
|
-
if (this._state !==
|
|
3523
|
+
if (this._state !== import_services8.SpaceState.CONTROL_ONLY) {
|
|
3449
3524
|
throw new import_protocols7.SystemError("Invalid operation");
|
|
3450
3525
|
}
|
|
3451
|
-
this._state =
|
|
3526
|
+
this._state = import_services8.SpaceState.INITIALIZING;
|
|
3452
3527
|
(0, import_log8.log)("new state", {
|
|
3453
|
-
state:
|
|
3528
|
+
state: import_services8.SpaceState[this._state]
|
|
3454
3529
|
}, {
|
|
3455
3530
|
F: __dxlog_file11,
|
|
3456
|
-
L:
|
|
3531
|
+
L: 262,
|
|
3457
3532
|
S: this,
|
|
3458
3533
|
C: (f, a) => f(...a)
|
|
3459
3534
|
});
|
|
3460
3535
|
await this._initializeAndReadControlPipeline();
|
|
3461
3536
|
await (0, import_async10.sleep)(1);
|
|
3462
3537
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
3463
|
-
await (0,
|
|
3538
|
+
await (0, import_context7.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
3464
3539
|
(0, import_log8.log)("data pipeline ready", void 0, {
|
|
3465
3540
|
F: __dxlog_file11,
|
|
3466
|
-
L:
|
|
3541
|
+
L: 274,
|
|
3467
3542
|
S: this,
|
|
3468
3543
|
C: (f, a) => f(...a)
|
|
3469
3544
|
});
|
|
3470
3545
|
await this._callbacks.beforeReady?.();
|
|
3471
|
-
this._state =
|
|
3546
|
+
this._state = import_services8.SpaceState.READY;
|
|
3472
3547
|
(0, import_log8.log)("new state", {
|
|
3473
|
-
state:
|
|
3548
|
+
state: import_services8.SpaceState[this._state]
|
|
3474
3549
|
}, {
|
|
3475
3550
|
F: __dxlog_file11,
|
|
3476
|
-
L:
|
|
3551
|
+
L: 278,
|
|
3477
3552
|
S: this,
|
|
3478
3553
|
C: (f, a) => f(...a)
|
|
3479
3554
|
});
|
|
@@ -3489,7 +3564,7 @@ var DataSpace = class {
|
|
|
3489
3564
|
await this._createWritableFeeds();
|
|
3490
3565
|
(0, import_log8.log)("writable feeds created", void 0, {
|
|
3491
3566
|
F: __dxlog_file11,
|
|
3492
|
-
L:
|
|
3567
|
+
L: 294,
|
|
3493
3568
|
S: this,
|
|
3494
3569
|
C: (f, a) => f(...a)
|
|
3495
3570
|
});
|
|
@@ -3516,7 +3591,7 @@ var DataSpace = class {
|
|
|
3516
3591
|
spaceKey: this.key,
|
|
3517
3592
|
deviceKey: this._signingContext.deviceKey,
|
|
3518
3593
|
identityKey: this._signingContext.identityKey,
|
|
3519
|
-
designation:
|
|
3594
|
+
designation: import_credentials10.AdmittedFeed.Designation.CONTROL
|
|
3520
3595
|
}
|
|
3521
3596
|
}));
|
|
3522
3597
|
}
|
|
@@ -3533,7 +3608,7 @@ var DataSpace = class {
|
|
|
3533
3608
|
spaceKey: this.key,
|
|
3534
3609
|
deviceKey: this._signingContext.deviceKey,
|
|
3535
3610
|
identityKey: this._signingContext.identityKey,
|
|
3536
|
-
designation:
|
|
3611
|
+
designation: import_credentials10.AdmittedFeed.Designation.DATA
|
|
3537
3612
|
}
|
|
3538
3613
|
}));
|
|
3539
3614
|
}
|
|
@@ -3552,16 +3627,16 @@ var DataSpace = class {
|
|
|
3552
3627
|
rootUrl
|
|
3553
3628
|
}, {
|
|
3554
3629
|
F: __dxlog_file11,
|
|
3555
|
-
L:
|
|
3630
|
+
L: 360,
|
|
3556
3631
|
S: this,
|
|
3557
3632
|
C: (f, a) => f(...a)
|
|
3558
3633
|
});
|
|
3559
|
-
this.
|
|
3560
|
-
const handle = this.
|
|
3634
|
+
this._echoHost.replicateDocument(rootUrl);
|
|
3635
|
+
const handle = this._echoHost.automergeRepo.find(rootUrl);
|
|
3561
3636
|
queueMicrotask(async () => {
|
|
3562
3637
|
try {
|
|
3563
3638
|
await (0, import_debug3.warnAfterTimeout)(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
3564
|
-
await (0,
|
|
3639
|
+
await (0, import_context7.cancelWithContext)(this._ctx, handle.whenReady());
|
|
3565
3640
|
});
|
|
3566
3641
|
if (this._ctx.disposed) {
|
|
3567
3642
|
return;
|
|
@@ -3575,7 +3650,7 @@ var DataSpace = class {
|
|
|
3575
3650
|
});
|
|
3576
3651
|
}
|
|
3577
3652
|
} catch (err) {
|
|
3578
|
-
if (err instanceof
|
|
3653
|
+
if (err instanceof import_context7.ContextDisposedError) {
|
|
3579
3654
|
return;
|
|
3580
3655
|
}
|
|
3581
3656
|
import_log8.log.warn("error loading automerge root doc", {
|
|
@@ -3584,7 +3659,7 @@ var DataSpace = class {
|
|
|
3584
3659
|
err
|
|
3585
3660
|
}, {
|
|
3586
3661
|
F: __dxlog_file11,
|
|
3587
|
-
L:
|
|
3662
|
+
L: 383,
|
|
3588
3663
|
S: this,
|
|
3589
3664
|
C: (f, a) => f(...a)
|
|
3590
3665
|
});
|
|
@@ -3610,7 +3685,7 @@ var DataSpace = class {
|
|
|
3610
3685
|
let epoch;
|
|
3611
3686
|
switch (options?.migration) {
|
|
3612
3687
|
case void 0:
|
|
3613
|
-
case
|
|
3688
|
+
case import_services8.CreateEpochRequest.Migration.NONE:
|
|
3614
3689
|
{
|
|
3615
3690
|
epoch = {
|
|
3616
3691
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
@@ -3620,9 +3695,9 @@ var DataSpace = class {
|
|
|
3620
3695
|
};
|
|
3621
3696
|
}
|
|
3622
3697
|
break;
|
|
3623
|
-
case
|
|
3698
|
+
case import_services8.CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3624
3699
|
{
|
|
3625
|
-
const document = this.
|
|
3700
|
+
const document = this._echoHost.automergeRepo.create();
|
|
3626
3701
|
epoch = {
|
|
3627
3702
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3628
3703
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
@@ -3631,15 +3706,15 @@ var DataSpace = class {
|
|
|
3631
3706
|
};
|
|
3632
3707
|
}
|
|
3633
3708
|
break;
|
|
3634
|
-
case
|
|
3709
|
+
case import_services8.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
3635
3710
|
{
|
|
3636
3711
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3637
|
-
const rootHandle = this.
|
|
3638
|
-
await (0,
|
|
3639
|
-
const newRoot = this.
|
|
3712
|
+
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
3713
|
+
await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3714
|
+
const newRoot = this._echoHost.automergeRepo.create(rootHandle.docSync());
|
|
3640
3715
|
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3641
3716
|
F: __dxlog_file11,
|
|
3642
|
-
L:
|
|
3717
|
+
L: 433,
|
|
3643
3718
|
S: this,
|
|
3644
3719
|
A: [
|
|
3645
3720
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
@@ -3654,23 +3729,23 @@ var DataSpace = class {
|
|
|
3654
3729
|
};
|
|
3655
3730
|
}
|
|
3656
3731
|
break;
|
|
3657
|
-
case
|
|
3732
|
+
case import_services8.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
3658
3733
|
{
|
|
3659
3734
|
import_log8.log.info("Fragmenting", void 0, {
|
|
3660
3735
|
F: __dxlog_file11,
|
|
3661
|
-
L:
|
|
3736
|
+
L: 445,
|
|
3662
3737
|
S: this,
|
|
3663
3738
|
C: (f, a) => f(...a)
|
|
3664
3739
|
});
|
|
3665
3740
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3666
|
-
const rootHandle = this.
|
|
3667
|
-
await (0,
|
|
3741
|
+
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
3742
|
+
await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3668
3743
|
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3669
|
-
const properties = objects.find(([_, value]) => value.system.type?.itemId ===
|
|
3744
|
+
const properties = objects.find(([_, value]) => value.system.type?.itemId === import_echo_schema.TYPE_PROPERTIES);
|
|
3670
3745
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3671
3746
|
(0, import_invariant9.invariant)(properties, "Properties not found", {
|
|
3672
3747
|
F: __dxlog_file11,
|
|
3673
|
-
L:
|
|
3748
|
+
L: 455,
|
|
3674
3749
|
S: this,
|
|
3675
3750
|
A: [
|
|
3676
3751
|
"properties",
|
|
@@ -3683,17 +3758,17 @@ var DataSpace = class {
|
|
|
3683
3758
|
properties
|
|
3684
3759
|
])
|
|
3685
3760
|
};
|
|
3686
|
-
const newRoot = this.
|
|
3761
|
+
const newRoot = this._echoHost.automergeRepo.create(newSpaceDoc);
|
|
3687
3762
|
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3688
3763
|
F: __dxlog_file11,
|
|
3689
|
-
L:
|
|
3764
|
+
L: 460,
|
|
3690
3765
|
S: this,
|
|
3691
3766
|
A: [
|
|
3692
3767
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3693
3768
|
""
|
|
3694
3769
|
]
|
|
3695
3770
|
});
|
|
3696
|
-
const docLoader = new import_echo_pipeline3.AutomergeDocumentLoaderImpl(this.key, this.
|
|
3771
|
+
const docLoader = new import_echo_pipeline3.AutomergeDocumentLoaderImpl(this.key, this._echoHost.automergeRepo);
|
|
3697
3772
|
await docLoader.loadSpaceRootDocHandle(this._ctx, {
|
|
3698
3773
|
rootUrl: newRoot.url
|
|
3699
3774
|
});
|
|
@@ -3737,25 +3812,25 @@ var DataSpace = class {
|
|
|
3737
3812
|
]));
|
|
3738
3813
|
}
|
|
3739
3814
|
async activate() {
|
|
3740
|
-
if (this._state !==
|
|
3815
|
+
if (this._state !== import_services8.SpaceState.INACTIVE) {
|
|
3741
3816
|
return;
|
|
3742
3817
|
}
|
|
3743
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3818
|
+
await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.ACTIVE);
|
|
3744
3819
|
await this._open();
|
|
3745
3820
|
this.initializeDataPipelineAsync();
|
|
3746
3821
|
}
|
|
3747
3822
|
async deactivate() {
|
|
3748
|
-
if (this._state ===
|
|
3823
|
+
if (this._state === import_services8.SpaceState.INACTIVE) {
|
|
3749
3824
|
return;
|
|
3750
3825
|
}
|
|
3751
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3826
|
+
await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.INACTIVE);
|
|
3752
3827
|
await this._close();
|
|
3753
|
-
this._state =
|
|
3828
|
+
this._state = import_services8.SpaceState.INACTIVE;
|
|
3754
3829
|
(0, import_log8.log)("new state", {
|
|
3755
|
-
state:
|
|
3830
|
+
state: import_services8.SpaceState[this._state]
|
|
3756
3831
|
}, {
|
|
3757
3832
|
F: __dxlog_file11,
|
|
3758
|
-
L:
|
|
3833
|
+
L: 526,
|
|
3759
3834
|
S: this,
|
|
3760
3835
|
C: (f, a) => f(...a)
|
|
3761
3836
|
});
|
|
@@ -3770,7 +3845,7 @@ _ts_decorate4([
|
|
|
3770
3845
|
], DataSpace.prototype, "key", null);
|
|
3771
3846
|
_ts_decorate4([
|
|
3772
3847
|
import_tracing4.trace.info({
|
|
3773
|
-
enum:
|
|
3848
|
+
enum: import_services8.SpaceState
|
|
3774
3849
|
})
|
|
3775
3850
|
], DataSpace.prototype, "state", null);
|
|
3776
3851
|
_ts_decorate4([
|
|
@@ -3809,7 +3884,7 @@ DataSpace = _ts_decorate4([
|
|
|
3809
3884
|
], DataSpace);
|
|
3810
3885
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
3811
3886
|
const credentials = [
|
|
3812
|
-
await (0,
|
|
3887
|
+
await (0, import_credentials13.createCredential)({
|
|
3813
3888
|
signer: keyring,
|
|
3814
3889
|
issuer: space.key,
|
|
3815
3890
|
subject: space.key,
|
|
@@ -3818,14 +3893,14 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3818
3893
|
spaceKey: space.key
|
|
3819
3894
|
}
|
|
3820
3895
|
}),
|
|
3821
|
-
await (0,
|
|
3896
|
+
await (0, import_credentials13.createCredential)({
|
|
3822
3897
|
signer: keyring,
|
|
3823
3898
|
issuer: space.key,
|
|
3824
3899
|
subject: signingContext.identityKey,
|
|
3825
3900
|
assertion: {
|
|
3826
3901
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
3827
3902
|
spaceKey: space.key,
|
|
3828
|
-
role:
|
|
3903
|
+
role: import_credentials14.SpaceMember.Role.ADMIN,
|
|
3829
3904
|
profile: signingContext.getProfile(),
|
|
3830
3905
|
genesisFeedKey: space.controlFeedKey ?? (0, import_debug4.failUndefined)()
|
|
3831
3906
|
}
|
|
@@ -3837,7 +3912,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3837
3912
|
spaceKey: space.key,
|
|
3838
3913
|
identityKey: signingContext.identityKey,
|
|
3839
3914
|
deviceKey: signingContext.deviceKey,
|
|
3840
|
-
designation:
|
|
3915
|
+
designation: import_credentials14.AdmittedFeed.Designation.CONTROL
|
|
3841
3916
|
}
|
|
3842
3917
|
}),
|
|
3843
3918
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3847,7 +3922,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3847
3922
|
spaceKey: space.key,
|
|
3848
3923
|
identityKey: signingContext.identityKey,
|
|
3849
3924
|
deviceKey: signingContext.deviceKey,
|
|
3850
|
-
designation:
|
|
3925
|
+
designation: import_credentials14.AdmittedFeed.Designation.DATA
|
|
3851
3926
|
}
|
|
3852
3927
|
}),
|
|
3853
3928
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3885,18 +3960,19 @@ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
|
|
|
3885
3960
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3886
3961
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3887
3962
|
var DataSpaceManager = class {
|
|
3888
|
-
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore,
|
|
3963
|
+
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _echoHost, _invitationsManager, params) {
|
|
3889
3964
|
this._spaceManager = _spaceManager;
|
|
3890
3965
|
this._metadataStore = _metadataStore;
|
|
3891
3966
|
this._keyring = _keyring;
|
|
3892
3967
|
this._signingContext = _signingContext;
|
|
3893
3968
|
this._feedStore = _feedStore;
|
|
3894
|
-
this.
|
|
3895
|
-
this.
|
|
3969
|
+
this._echoHost = _echoHost;
|
|
3970
|
+
this._invitationsManager = _invitationsManager;
|
|
3971
|
+
this._ctx = new import_context9.Context();
|
|
3896
3972
|
this.updated = new import_async13.Event();
|
|
3897
|
-
this._spaces = new import_util6.ComplexMap(
|
|
3973
|
+
this._spaces = new import_util6.ComplexMap(import_keys10.PublicKey.hash);
|
|
3898
3974
|
this._isOpen = false;
|
|
3899
|
-
this._instanceId =
|
|
3975
|
+
this._instanceId = import_keys10.PublicKey.random().toHex();
|
|
3900
3976
|
const { spaceMemberPresenceAnnounceInterval = PRESENCE_ANNOUNCE_INTERVAL, spaceMemberPresenceOfflineTimeout = PRESENCE_OFFLINE_TIMEOUT } = params ?? {};
|
|
3901
3977
|
this._spaceMemberPresenceAnnounceInterval = spaceMemberPresenceAnnounceInterval;
|
|
3902
3978
|
this._spaceMemberPresenceOfflineTimeout = spaceMemberPresenceOfflineTimeout;
|
|
@@ -3908,7 +3984,7 @@ var DataSpaceManager = class {
|
|
|
3908
3984
|
async open() {
|
|
3909
3985
|
(0, import_log10.log)("open", void 0, {
|
|
3910
3986
|
F: __dxlog_file12,
|
|
3911
|
-
L:
|
|
3987
|
+
L: 102,
|
|
3912
3988
|
S: this,
|
|
3913
3989
|
C: (f, a) => f(...a)
|
|
3914
3990
|
});
|
|
@@ -3916,7 +3992,7 @@ var DataSpaceManager = class {
|
|
|
3916
3992
|
id: this._instanceId
|
|
3917
3993
|
}), {
|
|
3918
3994
|
F: __dxlog_file12,
|
|
3919
|
-
L:
|
|
3995
|
+
L: 103,
|
|
3920
3996
|
S: this,
|
|
3921
3997
|
C: (f, a) => f(...a)
|
|
3922
3998
|
});
|
|
@@ -3924,7 +4000,7 @@ var DataSpaceManager = class {
|
|
|
3924
4000
|
spaces: this._metadataStore.spaces.length
|
|
3925
4001
|
}, {
|
|
3926
4002
|
F: __dxlog_file12,
|
|
3927
|
-
L:
|
|
4003
|
+
L: 104,
|
|
3928
4004
|
S: this,
|
|
3929
4005
|
C: (f, a) => f(...a)
|
|
3930
4006
|
});
|
|
@@ -3934,7 +4010,7 @@ var DataSpaceManager = class {
|
|
|
3934
4010
|
spaceMetadata
|
|
3935
4011
|
}, {
|
|
3936
4012
|
F: __dxlog_file12,
|
|
3937
|
-
L:
|
|
4013
|
+
L: 108,
|
|
3938
4014
|
S: this,
|
|
3939
4015
|
C: (f, a) => f(...a)
|
|
3940
4016
|
});
|
|
@@ -3945,7 +4021,7 @@ var DataSpaceManager = class {
|
|
|
3945
4021
|
err
|
|
3946
4022
|
}, {
|
|
3947
4023
|
F: __dxlog_file12,
|
|
3948
|
-
L:
|
|
4024
|
+
L: 111,
|
|
3949
4025
|
S: this,
|
|
3950
4026
|
C: (f, a) => f(...a)
|
|
3951
4027
|
});
|
|
@@ -3954,7 +4030,7 @@ var DataSpaceManager = class {
|
|
|
3954
4030
|
this._isOpen = true;
|
|
3955
4031
|
this.updated.emit();
|
|
3956
4032
|
for (const space of this._spaces.values()) {
|
|
3957
|
-
if (space.state !==
|
|
4033
|
+
if (space.state !== import_services9.SpaceState.INACTIVE) {
|
|
3958
4034
|
space.initializeDataPipelineAsync();
|
|
3959
4035
|
}
|
|
3960
4036
|
}
|
|
@@ -3962,7 +4038,7 @@ var DataSpaceManager = class {
|
|
|
3962
4038
|
id: this._instanceId
|
|
3963
4039
|
}), {
|
|
3964
4040
|
F: __dxlog_file12,
|
|
3965
|
-
L:
|
|
4041
|
+
L: 124,
|
|
3966
4042
|
S: this,
|
|
3967
4043
|
C: (f, a) => f(...a)
|
|
3968
4044
|
});
|
|
@@ -3970,7 +4046,7 @@ var DataSpaceManager = class {
|
|
|
3970
4046
|
async close() {
|
|
3971
4047
|
(0, import_log10.log)("close", void 0, {
|
|
3972
4048
|
F: __dxlog_file12,
|
|
3973
|
-
L:
|
|
4049
|
+
L: 129,
|
|
3974
4050
|
S: this,
|
|
3975
4051
|
C: (f, a) => f(...a)
|
|
3976
4052
|
});
|
|
@@ -3986,7 +4062,7 @@ var DataSpaceManager = class {
|
|
|
3986
4062
|
async createSpace() {
|
|
3987
4063
|
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3988
4064
|
F: __dxlog_file12,
|
|
3989
|
-
L:
|
|
4065
|
+
L: 142,
|
|
3990
4066
|
S: this,
|
|
3991
4067
|
A: [
|
|
3992
4068
|
"this._isOpen",
|
|
@@ -4001,27 +4077,22 @@ var DataSpaceManager = class {
|
|
|
4001
4077
|
genesisFeedKey: controlFeedKey,
|
|
4002
4078
|
controlFeedKey,
|
|
4003
4079
|
dataFeedKey,
|
|
4004
|
-
state:
|
|
4080
|
+
state: import_services9.SpaceState.ACTIVE
|
|
4005
4081
|
};
|
|
4006
4082
|
(0, import_log10.log)("creating space...", {
|
|
4007
4083
|
spaceKey
|
|
4008
4084
|
}, {
|
|
4009
4085
|
F: __dxlog_file12,
|
|
4010
|
-
L:
|
|
4086
|
+
L: 154,
|
|
4011
4087
|
S: this,
|
|
4012
4088
|
C: (f, a) => f(...a)
|
|
4013
4089
|
});
|
|
4014
|
-
const
|
|
4015
|
-
automergeRoot.change((doc) => {
|
|
4016
|
-
doc.access = {
|
|
4017
|
-
spaceKey: spaceKey.toHex()
|
|
4018
|
-
};
|
|
4019
|
-
});
|
|
4090
|
+
const automergeRootUrl = await this._echoHost.createSpaceRoot(spaceKey);
|
|
4020
4091
|
const space = await this._constructSpace(metadata);
|
|
4021
|
-
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner,
|
|
4092
|
+
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRootUrl);
|
|
4022
4093
|
await this._metadataStore.addSpace(metadata);
|
|
4023
4094
|
const memberCredential = credentials[1];
|
|
4024
|
-
(0, import_invariant11.invariant)((0,
|
|
4095
|
+
(0, import_invariant11.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4025
4096
|
F: __dxlog_file12,
|
|
4026
4097
|
L: 163,
|
|
4027
4098
|
S: this,
|
|
@@ -4081,9 +4152,9 @@ var DataSpaceManager = class {
|
|
|
4081
4152
|
* TODO(dmaretskyi): Consider removing.
|
|
4082
4153
|
*/
|
|
4083
4154
|
async waitUntilSpaceReady(spaceKey) {
|
|
4084
|
-
await (0,
|
|
4155
|
+
await (0, import_context9.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
4085
4156
|
const space = this._spaces.get(spaceKey);
|
|
4086
|
-
return !!space && space.state ===
|
|
4157
|
+
return !!space && space.state === import_services9.SpaceState.READY;
|
|
4087
4158
|
}));
|
|
4088
4159
|
}
|
|
4089
4160
|
async _constructSpace(metadata) {
|
|
@@ -4123,8 +4194,8 @@ var DataSpaceManager = class {
|
|
|
4123
4194
|
remotePeerId: session.remotePeerId
|
|
4124
4195
|
}));
|
|
4125
4196
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
4126
|
-
this.
|
|
4127
|
-
session.addExtension("dxos.mesh.teleport.automerge", this.
|
|
4197
|
+
this._echoHost.authorizeDevice(space.key, session.remotePeerId);
|
|
4198
|
+
session.addExtension("dxos.mesh.teleport.automerge", this._echoHost.createReplicationExtension());
|
|
4128
4199
|
},
|
|
4129
4200
|
onAuthFailure: () => {
|
|
4130
4201
|
import_log10.log.warn("auth failure", void 0, {
|
|
@@ -4134,18 +4205,22 @@ var DataSpaceManager = class {
|
|
|
4134
4205
|
C: (f, a) => f(...a)
|
|
4135
4206
|
});
|
|
4136
4207
|
},
|
|
4137
|
-
memberKey: this._signingContext.identityKey
|
|
4208
|
+
memberKey: this._signingContext.identityKey,
|
|
4209
|
+
onDelegatedInvitationStatusChange: (invitation, isActive) => {
|
|
4210
|
+
return this._handleInvitationStatusChange(dataSpace, invitation, isActive);
|
|
4211
|
+
}
|
|
4138
4212
|
});
|
|
4139
4213
|
controlFeed && await space.setControlFeed(controlFeed);
|
|
4140
4214
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
4141
4215
|
const dataSpace = new DataSpace({
|
|
4142
4216
|
inner: space,
|
|
4143
|
-
initialState: metadata.state ===
|
|
4217
|
+
initialState: metadata.state === import_services9.SpaceState.INACTIVE ? import_services9.SpaceState.INACTIVE : import_services9.SpaceState.CLOSED,
|
|
4144
4218
|
metadataStore: this._metadataStore,
|
|
4145
4219
|
gossip,
|
|
4146
4220
|
presence,
|
|
4147
4221
|
keyring: this._keyring,
|
|
4148
4222
|
feedStore: this._feedStore,
|
|
4223
|
+
echoHost: this._echoHost,
|
|
4149
4224
|
signingContext: this._signingContext,
|
|
4150
4225
|
callbacks: {
|
|
4151
4226
|
beforeReady: async () => {
|
|
@@ -4153,7 +4228,7 @@ var DataSpaceManager = class {
|
|
|
4153
4228
|
space: space.key
|
|
4154
4229
|
}, {
|
|
4155
4230
|
F: __dxlog_file12,
|
|
4156
|
-
L:
|
|
4231
|
+
L: 269,
|
|
4157
4232
|
S: this,
|
|
4158
4233
|
C: (f, a) => f(...a)
|
|
4159
4234
|
});
|
|
@@ -4164,11 +4239,14 @@ var DataSpaceManager = class {
|
|
|
4164
4239
|
open: this._isOpen
|
|
4165
4240
|
}, {
|
|
4166
4241
|
F: __dxlog_file12,
|
|
4167
|
-
L:
|
|
4242
|
+
L: 272,
|
|
4168
4243
|
S: this,
|
|
4169
4244
|
C: (f, a) => f(...a)
|
|
4170
4245
|
});
|
|
4171
4246
|
if (this._isOpen) {
|
|
4247
|
+
await this._createDelegatedInvitations(dataSpace, [
|
|
4248
|
+
...space.spaceState.invitations.entries()
|
|
4249
|
+
]);
|
|
4172
4250
|
this.updated.emit();
|
|
4173
4251
|
}
|
|
4174
4252
|
},
|
|
@@ -4177,16 +4255,15 @@ var DataSpaceManager = class {
|
|
|
4177
4255
|
space: space.key
|
|
4178
4256
|
}, {
|
|
4179
4257
|
F: __dxlog_file12,
|
|
4180
|
-
L:
|
|
4258
|
+
L: 279,
|
|
4181
4259
|
S: this,
|
|
4182
4260
|
C: (f, a) => f(...a)
|
|
4183
4261
|
});
|
|
4184
4262
|
}
|
|
4185
4263
|
},
|
|
4186
|
-
cache: metadata.cache
|
|
4187
|
-
automergeHost: this._automergeHost
|
|
4264
|
+
cache: metadata.cache
|
|
4188
4265
|
});
|
|
4189
|
-
if (metadata.state !==
|
|
4266
|
+
if (metadata.state !== import_services9.SpaceState.INACTIVE) {
|
|
4190
4267
|
await dataSpace.open();
|
|
4191
4268
|
}
|
|
4192
4269
|
if (metadata.controlTimeframe) {
|
|
@@ -4195,6 +4272,41 @@ var DataSpaceManager = class {
|
|
|
4195
4272
|
this._spaces.set(metadata.key, dataSpace);
|
|
4196
4273
|
return dataSpace;
|
|
4197
4274
|
}
|
|
4275
|
+
async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
|
|
4276
|
+
if (dataSpace?.state !== import_services9.SpaceState.READY) {
|
|
4277
|
+
return;
|
|
4278
|
+
}
|
|
4279
|
+
if (isActive) {
|
|
4280
|
+
await this._createDelegatedInvitations(dataSpace, [
|
|
4281
|
+
[
|
|
4282
|
+
delegatedInvitation.credentialId,
|
|
4283
|
+
delegatedInvitation.invitation
|
|
4284
|
+
]
|
|
4285
|
+
]);
|
|
4286
|
+
} else {
|
|
4287
|
+
await this._invitationsManager.cancelInvitation(delegatedInvitation.invitation);
|
|
4288
|
+
}
|
|
4289
|
+
}
|
|
4290
|
+
async _createDelegatedInvitations(space, invitations) {
|
|
4291
|
+
const tasks = invitations.map(([credentialId, invitation]) => {
|
|
4292
|
+
return this._invitationsManager.createInvitation({
|
|
4293
|
+
type: import_services9.Invitation.Type.DELEGATED,
|
|
4294
|
+
kind: import_services9.Invitation.Kind.SPACE,
|
|
4295
|
+
spaceKey: space.key,
|
|
4296
|
+
authMethod: invitation.authMethod,
|
|
4297
|
+
invitationId: invitation.invitationId,
|
|
4298
|
+
swarmKey: invitation.swarmKey,
|
|
4299
|
+
guestKeypair: invitation.guestKey ? {
|
|
4300
|
+
publicKey: invitation.guestKey
|
|
4301
|
+
} : void 0,
|
|
4302
|
+
lifetime: invitation.expiresOn ? invitation.expiresOn.getTime() - Date.now() : void 0,
|
|
4303
|
+
multiUse: invitation.multiUse,
|
|
4304
|
+
delegationCredentialId: credentialId,
|
|
4305
|
+
persistent: false
|
|
4306
|
+
});
|
|
4307
|
+
});
|
|
4308
|
+
await Promise.all(tasks);
|
|
4309
|
+
}
|
|
4198
4310
|
};
|
|
4199
4311
|
_ts_decorate5([
|
|
4200
4312
|
import_async13.synchronized
|
|
@@ -4231,10 +4343,10 @@ var SpacesServiceImpl = class {
|
|
|
4231
4343
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4232
4344
|
if (state) {
|
|
4233
4345
|
switch (state) {
|
|
4234
|
-
case
|
|
4346
|
+
case import_services10.SpaceState.ACTIVE:
|
|
4235
4347
|
await space.activate();
|
|
4236
4348
|
break;
|
|
4237
|
-
case
|
|
4349
|
+
case import_services10.SpaceState.INACTIVE:
|
|
4238
4350
|
await space.deactivate();
|
|
4239
4351
|
break;
|
|
4240
4352
|
default:
|
|
@@ -4408,7 +4520,7 @@ var SpacesServiceImpl = class {
|
|
|
4408
4520
|
identityKey: member.key,
|
|
4409
4521
|
profile: member.profile ?? {}
|
|
4410
4522
|
},
|
|
4411
|
-
presence: member.removed ?
|
|
4523
|
+
presence: member.removed ? import_services10.SpaceMember.PresenceState.REMOVED : isMe || peers.length > 0 ? import_services10.SpaceMember.PresenceState.ONLINE : import_services10.SpaceMember.PresenceState.OFFLINE,
|
|
4412
4524
|
peerStates: peers
|
|
4413
4525
|
};
|
|
4414
4526
|
}),
|
|
@@ -4419,80 +4531,6 @@ var SpacesServiceImpl = class {
|
|
|
4419
4531
|
}
|
|
4420
4532
|
};
|
|
4421
4533
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
4422
|
-
var createSelectedDocumentsIterator = (automergeHost) => (
|
|
4423
|
-
/**
|
|
4424
|
-
* Get object data blobs from Automerge Repo by ids.
|
|
4425
|
-
* @param ids
|
|
4426
|
-
*/
|
|
4427
|
-
// TODO(mykola): Unload automerge handles after usage.
|
|
4428
|
-
async function* loadDocuments(ids) {
|
|
4429
|
-
for (const id of ids) {
|
|
4430
|
-
const { documentId, objectId } = import_protocols12.idCodec.decode(id);
|
|
4431
|
-
const handle = automergeHost.repo.find(documentId);
|
|
4432
|
-
await (0, import_debug7.warnAfterTimeout)(5e3, "to long to load doc", () => handle.whenReady());
|
|
4433
|
-
const doc = handle.docSync();
|
|
4434
|
-
const hash = (0, import_automerge.getHeads)(doc).join("");
|
|
4435
|
-
yield doc.objects?.[objectId] ? [
|
|
4436
|
-
{
|
|
4437
|
-
id,
|
|
4438
|
-
object: doc.objects[objectId],
|
|
4439
|
-
currentHash: hash
|
|
4440
|
-
}
|
|
4441
|
-
] : [];
|
|
4442
|
-
}
|
|
4443
|
-
}
|
|
4444
|
-
);
|
|
4445
|
-
var createDocumentsIterator = (automergeHost) => (
|
|
4446
|
-
/**
|
|
4447
|
-
* Recursively get all object data blobs from Automerge Repo.
|
|
4448
|
-
* @param ids
|
|
4449
|
-
*/
|
|
4450
|
-
// TODO(mykola): Unload automerge handles after usage.
|
|
4451
|
-
async function* getAllDocuments() {
|
|
4452
|
-
const visited = /* @__PURE__ */ new Set();
|
|
4453
|
-
async function* getObjectsFromHandle(handle) {
|
|
4454
|
-
if (visited.has(handle.documentId)) {
|
|
4455
|
-
return;
|
|
4456
|
-
}
|
|
4457
|
-
await (0, import_debug7.warnAfterTimeout)(5e3, "to long to load doc", () => handle.whenReady());
|
|
4458
|
-
const doc = handle.docSync();
|
|
4459
|
-
const heads = (0, import_automerge.getHeads)(doc);
|
|
4460
|
-
if (doc.objects) {
|
|
4461
|
-
yield Object.entries(doc.objects).map(([objectId, object]) => {
|
|
4462
|
-
return {
|
|
4463
|
-
id: import_protocols12.idCodec.encode({
|
|
4464
|
-
documentId: handle.documentId,
|
|
4465
|
-
objectId
|
|
4466
|
-
}),
|
|
4467
|
-
object,
|
|
4468
|
-
currentHash: heads.join("")
|
|
4469
|
-
};
|
|
4470
|
-
});
|
|
4471
|
-
}
|
|
4472
|
-
if (doc.links) {
|
|
4473
|
-
for (const id of Object.values(doc.links)) {
|
|
4474
|
-
if (visited.has(id)) {
|
|
4475
|
-
continue;
|
|
4476
|
-
}
|
|
4477
|
-
const linkHandle = automergeHost.repo.find(id);
|
|
4478
|
-
for await (const result of getObjectsFromHandle(linkHandle)) {
|
|
4479
|
-
yield result;
|
|
4480
|
-
}
|
|
4481
|
-
}
|
|
4482
|
-
}
|
|
4483
|
-
visited.add(handle.documentId);
|
|
4484
|
-
}
|
|
4485
|
-
for (const handle of Object.values(automergeHost.repo.handles)) {
|
|
4486
|
-
if (visited.has(handle.documentId)) {
|
|
4487
|
-
continue;
|
|
4488
|
-
}
|
|
4489
|
-
for await (const result of getObjectsFromHandle(handle)) {
|
|
4490
|
-
yield result;
|
|
4491
|
-
}
|
|
4492
|
-
visited.add(handle.documentId);
|
|
4493
|
-
}
|
|
4494
|
-
}
|
|
4495
|
-
);
|
|
4496
4534
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
4497
4535
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4498
4536
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -4504,7 +4542,7 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4504
4542
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4505
4543
|
}
|
|
4506
4544
|
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
4507
|
-
var ServiceContext = class extends
|
|
4545
|
+
var ServiceContext = class extends import_context10.Resource {
|
|
4508
4546
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
4509
4547
|
super();
|
|
4510
4548
|
this.storage = storage;
|
|
@@ -4514,7 +4552,7 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4514
4552
|
this._runtimeParams = _runtimeParams;
|
|
4515
4553
|
this.initialized = new import_async15.Trigger();
|
|
4516
4554
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4517
|
-
this._instanceId =
|
|
4555
|
+
this._instanceId = import_keys11.PublicKey.random().toHex();
|
|
4518
4556
|
this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
|
|
4519
4557
|
this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
|
|
4520
4558
|
this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
|
|
@@ -4537,34 +4575,19 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4537
4575
|
snapshotStore: this.snapshotStore
|
|
4538
4576
|
});
|
|
4539
4577
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
4540
|
-
this.
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
this.automergeHost = new import_echo_pipeline4.AutomergeHost({
|
|
4544
|
-
directory: storage.createDirectory("automerge"),
|
|
4545
|
-
db: level.sublevel("automerge"),
|
|
4546
|
-
storageCallbacks: (0, import_indexing.createStorageCallbacks)({
|
|
4547
|
-
host: () => this.automergeHost,
|
|
4548
|
-
metadata: this.indexMetadata
|
|
4549
|
-
})
|
|
4550
|
-
});
|
|
4551
|
-
this.indexer = new import_indexing.Indexer({
|
|
4552
|
-
indexStore: new import_indexing.IndexStore({
|
|
4553
|
-
db: level.sublevel("index-storage")
|
|
4554
|
-
}),
|
|
4555
|
-
metadataStore: this.indexMetadata,
|
|
4556
|
-
loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
|
|
4557
|
-
getAllDocuments: createDocumentsIterator(this.automergeHost)
|
|
4578
|
+
this.echoHost = new import_echo_db.EchoHost({
|
|
4579
|
+
kv: this.level,
|
|
4580
|
+
storage: this.storage
|
|
4558
4581
|
});
|
|
4559
4582
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4560
4583
|
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
4561
|
-
this._handlerFactories.set(
|
|
4584
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
4562
4585
|
}
|
|
4563
4586
|
async _open(ctx) {
|
|
4564
4587
|
await this._checkStorageVersion();
|
|
4565
4588
|
(0, import_log12.log)("opening...", void 0, {
|
|
4566
4589
|
F: __dxlog_file14,
|
|
4567
|
-
L:
|
|
4590
|
+
L: 151,
|
|
4568
4591
|
S: this,
|
|
4569
4592
|
C: (f, a) => f(...a)
|
|
4570
4593
|
});
|
|
@@ -4572,13 +4595,13 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4572
4595
|
id: this._instanceId
|
|
4573
4596
|
}), {
|
|
4574
4597
|
F: __dxlog_file14,
|
|
4575
|
-
L:
|
|
4598
|
+
L: 152,
|
|
4576
4599
|
S: this,
|
|
4577
4600
|
C: (f, a) => f(...a)
|
|
4578
4601
|
});
|
|
4579
4602
|
await this.signalManager.open();
|
|
4580
4603
|
await this.networkManager.open();
|
|
4581
|
-
await this.
|
|
4604
|
+
await this.echoHost.open(ctx);
|
|
4582
4605
|
await this.metadataStore.load();
|
|
4583
4606
|
await this.spaceManager.open();
|
|
4584
4607
|
await this.identityManager.open(ctx);
|
|
@@ -4590,7 +4613,7 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4590
4613
|
count: loadedInvitations.invitations?.length
|
|
4591
4614
|
}, {
|
|
4592
4615
|
F: __dxlog_file14,
|
|
4593
|
-
L:
|
|
4616
|
+
L: 165,
|
|
4594
4617
|
S: this,
|
|
4595
4618
|
C: (f, a) => f(...a)
|
|
4596
4619
|
});
|
|
@@ -4598,53 +4621,52 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4598
4621
|
id: this._instanceId
|
|
4599
4622
|
}), {
|
|
4600
4623
|
F: __dxlog_file14,
|
|
4601
|
-
L:
|
|
4624
|
+
L: 167,
|
|
4602
4625
|
S: this,
|
|
4603
4626
|
C: (f, a) => f(...a)
|
|
4604
4627
|
});
|
|
4605
4628
|
(0, import_log12.log)("opened", void 0, {
|
|
4606
4629
|
F: __dxlog_file14,
|
|
4607
|
-
L:
|
|
4630
|
+
L: 168,
|
|
4608
4631
|
S: this,
|
|
4609
4632
|
C: (f, a) => f(...a)
|
|
4610
4633
|
});
|
|
4611
4634
|
}
|
|
4612
|
-
async _close() {
|
|
4635
|
+
async _close(ctx) {
|
|
4613
4636
|
(0, import_log12.log)("closing...", void 0, {
|
|
4614
4637
|
F: __dxlog_file14,
|
|
4615
|
-
L:
|
|
4638
|
+
L: 172,
|
|
4616
4639
|
S: this,
|
|
4617
4640
|
C: (f, a) => f(...a)
|
|
4618
4641
|
});
|
|
4619
4642
|
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
4620
4643
|
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
4621
4644
|
}
|
|
4622
|
-
await this.automergeHost.close();
|
|
4623
4645
|
await this.dataSpaceManager?.close();
|
|
4624
4646
|
await this.identityManager.close();
|
|
4625
4647
|
await this.spaceManager.close();
|
|
4626
4648
|
await this.feedStore.close();
|
|
4649
|
+
await this.metadataStore.close();
|
|
4650
|
+
await this.echoHost.close(ctx);
|
|
4627
4651
|
await this.networkManager.close();
|
|
4628
4652
|
await this.signalManager.close();
|
|
4629
|
-
await this.metadataStore.close();
|
|
4630
|
-
await this.indexer.destroy();
|
|
4631
4653
|
(0, import_log12.log)("closed", void 0, {
|
|
4632
4654
|
F: __dxlog_file14,
|
|
4633
|
-
L:
|
|
4655
|
+
L: 184,
|
|
4634
4656
|
S: this,
|
|
4635
4657
|
C: (f, a) => f(...a)
|
|
4636
4658
|
});
|
|
4637
4659
|
}
|
|
4638
4660
|
async createIdentity(params = {}) {
|
|
4639
4661
|
const identity = await this.identityManager.createIdentity(params);
|
|
4640
|
-
await this._initialize(new
|
|
4662
|
+
await this._initialize(new import_context10.Context());
|
|
4641
4663
|
return identity;
|
|
4642
4664
|
}
|
|
4643
4665
|
getInvitationHandler(invitation) {
|
|
4644
4666
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4645
4667
|
(0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4646
4668
|
F: __dxlog_file14,
|
|
4647
|
-
L:
|
|
4669
|
+
L: 195,
|
|
4648
4670
|
S: this,
|
|
4649
4671
|
A: [
|
|
4650
4672
|
"factory",
|
|
@@ -4663,7 +4685,7 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4663
4685
|
}
|
|
4664
4686
|
async _acceptIdentity(params) {
|
|
4665
4687
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
4666
|
-
await this._initialize(new
|
|
4688
|
+
await this._initialize(new import_context10.Context());
|
|
4667
4689
|
return identity;
|
|
4668
4690
|
}
|
|
4669
4691
|
async _checkStorageVersion() {
|
|
@@ -4676,7 +4698,7 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4676
4698
|
async _initialize(ctx) {
|
|
4677
4699
|
(0, import_log12.log)("initializing spaces...", void 0, {
|
|
4678
4700
|
F: __dxlog_file14,
|
|
4679
|
-
L:
|
|
4701
|
+
L: 226,
|
|
4680
4702
|
S: this,
|
|
4681
4703
|
C: (f, a) => f(...a)
|
|
4682
4704
|
});
|
|
@@ -4694,12 +4716,12 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4694
4716
|
});
|
|
4695
4717
|
}
|
|
4696
4718
|
};
|
|
4697
|
-
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.
|
|
4719
|
+
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.echoHost, this.invitationsManager, this._runtimeParams);
|
|
4698
4720
|
await this.dataSpaceManager.open();
|
|
4699
|
-
this._handlerFactories.set(
|
|
4721
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.SPACE, (invitation) => {
|
|
4700
4722
|
(0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4701
4723
|
F: __dxlog_file14,
|
|
4702
|
-
L:
|
|
4724
|
+
L: 251,
|
|
4703
4725
|
S: this,
|
|
4704
4726
|
A: [
|
|
4705
4727
|
"this.dataSpaceManager",
|
|
@@ -4711,7 +4733,7 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4711
4733
|
this.initialized.wake();
|
|
4712
4734
|
this._deviceSpaceSync = {
|
|
4713
4735
|
processCredential: async (credential) => {
|
|
4714
|
-
const assertion = (0,
|
|
4736
|
+
const assertion = (0, import_credentials15.getCredentialAssertion)(credential);
|
|
4715
4737
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
4716
4738
|
return;
|
|
4717
4739
|
}
|
|
@@ -4723,7 +4745,7 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4723
4745
|
details: assertion
|
|
4724
4746
|
}, {
|
|
4725
4747
|
F: __dxlog_file14,
|
|
4726
|
-
L:
|
|
4748
|
+
L: 267,
|
|
4727
4749
|
S: this,
|
|
4728
4750
|
C: (f, a) => f(...a)
|
|
4729
4751
|
});
|
|
@@ -4734,7 +4756,7 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4734
4756
|
details: assertion
|
|
4735
4757
|
}, {
|
|
4736
4758
|
F: __dxlog_file14,
|
|
4737
|
-
L:
|
|
4759
|
+
L: 271,
|
|
4738
4760
|
S: this,
|
|
4739
4761
|
C: (f, a) => f(...a)
|
|
4740
4762
|
});
|
|
@@ -4745,7 +4767,7 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4745
4767
|
details: assertion
|
|
4746
4768
|
}, {
|
|
4747
4769
|
F: __dxlog_file14,
|
|
4748
|
-
L:
|
|
4770
|
+
L: 276,
|
|
4749
4771
|
S: this,
|
|
4750
4772
|
C: (f, a) => f(...a)
|
|
4751
4773
|
});
|
|
@@ -4756,7 +4778,7 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4756
4778
|
} catch (err) {
|
|
4757
4779
|
import_log12.log.catch(err, void 0, {
|
|
4758
4780
|
F: __dxlog_file14,
|
|
4759
|
-
L:
|
|
4781
|
+
L: 282,
|
|
4760
4782
|
S: this,
|
|
4761
4783
|
C: (f, a) => f(...a)
|
|
4762
4784
|
});
|
|
@@ -4798,26 +4820,26 @@ var ServiceRegistry = class {
|
|
|
4798
4820
|
delete this._handlers[name];
|
|
4799
4821
|
}
|
|
4800
4822
|
};
|
|
4801
|
-
var DXOS_VERSION = "0.4.10-main.
|
|
4823
|
+
var DXOS_VERSION = "0.4.10-main.c8e5c39";
|
|
4802
4824
|
var getPlatform = () => {
|
|
4803
4825
|
if (process.browser) {
|
|
4804
4826
|
if (typeof window !== "undefined") {
|
|
4805
4827
|
const { userAgent } = window.navigator;
|
|
4806
4828
|
return {
|
|
4807
|
-
type:
|
|
4829
|
+
type: import_services13.Platform.PLATFORM_TYPE.BROWSER,
|
|
4808
4830
|
userAgent,
|
|
4809
4831
|
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
4810
4832
|
};
|
|
4811
4833
|
} else {
|
|
4812
4834
|
return {
|
|
4813
|
-
type:
|
|
4835
|
+
type: import_services13.Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
4814
4836
|
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
4815
4837
|
};
|
|
4816
4838
|
}
|
|
4817
4839
|
} else {
|
|
4818
4840
|
const { platform: platform2, version, arch } = process;
|
|
4819
4841
|
return {
|
|
4820
|
-
type:
|
|
4842
|
+
type: import_services13.Platform.PLATFORM_TYPE.NODE,
|
|
4821
4843
|
platform: platform2,
|
|
4822
4844
|
arch,
|
|
4823
4845
|
runtime: version,
|
|
@@ -4835,7 +4857,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
4835
4857
|
client: {
|
|
4836
4858
|
version: DXOS_VERSION,
|
|
4837
4859
|
storage: {
|
|
4838
|
-
version:
|
|
4860
|
+
version: import_protocols12.STORAGE_VERSION
|
|
4839
4861
|
}
|
|
4840
4862
|
},
|
|
4841
4863
|
trace: import_tracing6.TRACE_PROCESSOR.getDiagnostics()
|
|
@@ -4904,7 +4926,7 @@ var getSpaceStats = async (space) => {
|
|
|
4904
4926
|
const stats = {
|
|
4905
4927
|
key: space.key,
|
|
4906
4928
|
metrics: space.metrics,
|
|
4907
|
-
epochs: space.inner.spaceState.credentials.filter((0,
|
|
4929
|
+
epochs: space.inner.spaceState.credentials.filter((0, import_credentials16.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
4908
4930
|
...credential.subject.assertion,
|
|
4909
4931
|
id: credential.id
|
|
4910
4932
|
})),
|
|
@@ -4915,7 +4937,7 @@ var getSpaceStats = async (space) => {
|
|
|
4915
4937
|
displayName: member.assertion.profile?.displayName
|
|
4916
4938
|
}
|
|
4917
4939
|
},
|
|
4918
|
-
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ?
|
|
4940
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services12.SpaceMember.PresenceState.ONLINE : import_services12.SpaceMember.PresenceState.OFFLINE
|
|
4919
4941
|
})),
|
|
4920
4942
|
pipeline: {
|
|
4921
4943
|
// TODO(burdon): Pick properties from credentials if needed.
|
|
@@ -4979,9 +5001,9 @@ var DevicesServiceImpl = class {
|
|
|
4979
5001
|
const peerState = peers.find((peer) => peer.identityKey.equals(key));
|
|
4980
5002
|
return {
|
|
4981
5003
|
deviceKey: key,
|
|
4982
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ?
|
|
5004
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services16.DeviceKind.CURRENT : import_services16.DeviceKind.TRUSTED,
|
|
4983
5005
|
profile,
|
|
4984
|
-
presence: isMe ?
|
|
5006
|
+
presence: isMe ? import_services16.Device.PresenceState.ONLINE : peerState ? import_services16.Device.PresenceState.ONLINE : import_services16.Device.PresenceState.OFFLINE
|
|
4985
5007
|
};
|
|
4986
5008
|
})
|
|
4987
5009
|
});
|
|
@@ -5080,7 +5102,7 @@ var LoggingServiceImpl = class {
|
|
|
5080
5102
|
constructor() {
|
|
5081
5103
|
this._logs = new import_async18.Event();
|
|
5082
5104
|
this._started = Date.now();
|
|
5083
|
-
this._sessionId =
|
|
5105
|
+
this._sessionId = import_keys13.PublicKey.random().toHex();
|
|
5084
5106
|
this._logProcessor = (_config, entry2) => {
|
|
5085
5107
|
this._logs.emit(entry2);
|
|
5086
5108
|
};
|
|
@@ -5177,16 +5199,16 @@ var LoggingServiceImpl = class {
|
|
|
5177
5199
|
};
|
|
5178
5200
|
var matchFilter = (filter, level, path2, options) => {
|
|
5179
5201
|
switch (options) {
|
|
5180
|
-
case
|
|
5202
|
+
case import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
5181
5203
|
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5182
|
-
case
|
|
5204
|
+
case import_services17.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
5183
5205
|
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5184
5206
|
}
|
|
5185
5207
|
};
|
|
5186
5208
|
var shouldLog = (entry2, request) => {
|
|
5187
|
-
const options = request.options ??
|
|
5209
|
+
const options = request.options ?? import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5188
5210
|
if (request.filters === void 0) {
|
|
5189
|
-
return options ===
|
|
5211
|
+
return options === import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5190
5212
|
} else {
|
|
5191
5213
|
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
5192
5214
|
}
|
|
@@ -5223,7 +5245,7 @@ var NetworkServiceImpl = class {
|
|
|
5223
5245
|
}
|
|
5224
5246
|
};
|
|
5225
5247
|
var getRootPath = (config) => {
|
|
5226
|
-
const { dataRoot = (0, import_util11.isNode)() ?
|
|
5248
|
+
const { dataRoot = (0, import_util11.isNode)() ? import_client_protocol6.DX_DATA : "dxos/storage" } = config ?? {};
|
|
5227
5249
|
return `${dataRoot}/`;
|
|
5228
5250
|
};
|
|
5229
5251
|
var isPersistent = (config) => {
|
|
@@ -5234,16 +5256,16 @@ var StorageDriver = import_config2.Runtime.Client.Storage.StorageDriver;
|
|
|
5234
5256
|
var createStorageObjects = (config) => {
|
|
5235
5257
|
const { persistent = false, keyStore, dataStore } = config ?? {};
|
|
5236
5258
|
if (persistent && dataStore === StorageDriver.RAM) {
|
|
5237
|
-
throw new
|
|
5259
|
+
throw new import_protocols14.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
5238
5260
|
}
|
|
5239
5261
|
if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
|
|
5240
|
-
throw new
|
|
5262
|
+
throw new import_protocols14.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
5241
5263
|
}
|
|
5242
5264
|
if (persistent && keyStore === StorageDriver.RAM) {
|
|
5243
|
-
throw new
|
|
5265
|
+
throw new import_protocols14.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
5244
5266
|
}
|
|
5245
5267
|
if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
|
|
5246
|
-
throw new
|
|
5268
|
+
throw new import_protocols14.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
5247
5269
|
}
|
|
5248
5270
|
return {
|
|
5249
5271
|
storage: (0, import_random_access_storage.createStorage)({
|
|
@@ -5274,7 +5296,7 @@ var toStorageType = (type) => {
|
|
|
5274
5296
|
};
|
|
5275
5297
|
var createLevel = async (config) => {
|
|
5276
5298
|
const persistent = isPersistent(config);
|
|
5277
|
-
const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${
|
|
5299
|
+
const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys14.PublicKey.random().toHex()}`;
|
|
5278
5300
|
const level = new import_level.Level(storagePath);
|
|
5279
5301
|
await level.open();
|
|
5280
5302
|
return level;
|
|
@@ -5299,8 +5321,8 @@ var SystemServiceImpl = class {
|
|
|
5299
5321
|
return {
|
|
5300
5322
|
timestamp: /* @__PURE__ */ new Date(),
|
|
5301
5323
|
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util12.jsonKeyReplacer)({
|
|
5302
|
-
truncate: keys ===
|
|
5303
|
-
humanize: keys ===
|
|
5324
|
+
truncate: keys === import_services18.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
5325
|
+
humanize: keys === import_services18.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
5304
5326
|
})))
|
|
5305
5327
|
};
|
|
5306
5328
|
}
|
|
@@ -5374,7 +5396,7 @@ var ClientServicesHost = class {
|
|
|
5374
5396
|
lockKey,
|
|
5375
5397
|
onAcquire: () => {
|
|
5376
5398
|
if (!this._opening) {
|
|
5377
|
-
void this.open(new
|
|
5399
|
+
void this.open(new import_context11.Context());
|
|
5378
5400
|
}
|
|
5379
5401
|
},
|
|
5380
5402
|
onRelease: () => this.close()
|
|
@@ -5383,14 +5405,14 @@ var ClientServicesHost = class {
|
|
|
5383
5405
|
this._systemService = new SystemServiceImpl({
|
|
5384
5406
|
config: () => this._config,
|
|
5385
5407
|
statusUpdate: this._statusUpdate,
|
|
5386
|
-
getCurrentStatus: () => this.isOpen ?
|
|
5408
|
+
getCurrentStatus: () => this.isOpen ? import_services15.SystemStatus.ACTIVE : import_services15.SystemStatus.INACTIVE,
|
|
5387
5409
|
getDiagnostics: () => {
|
|
5388
5410
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
5389
5411
|
},
|
|
5390
5412
|
onUpdateStatus: async (status) => {
|
|
5391
|
-
if (!this.isOpen && status ===
|
|
5413
|
+
if (!this.isOpen && status === import_services15.SystemStatus.ACTIVE) {
|
|
5392
5414
|
await this._resourceLock?.acquire();
|
|
5393
|
-
} else if (this.isOpen && status ===
|
|
5415
|
+
} else if (this.isOpen && status === import_services15.SystemStatus.INACTIVE) {
|
|
5394
5416
|
await this._resourceLock?.release();
|
|
5395
5417
|
}
|
|
5396
5418
|
},
|
|
@@ -5400,7 +5422,7 @@ var ClientServicesHost = class {
|
|
|
5400
5422
|
});
|
|
5401
5423
|
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
5402
5424
|
this._loggingService = new LoggingServiceImpl();
|
|
5403
|
-
this._serviceRegistry = new ServiceRegistry(
|
|
5425
|
+
this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
|
|
5404
5426
|
SystemService: this._systemService,
|
|
5405
5427
|
TracingService: this._tracingService
|
|
5406
5428
|
});
|
|
@@ -5431,7 +5453,7 @@ var ClientServicesHost = class {
|
|
|
5431
5453
|
initialize({ config, ...options }) {
|
|
5432
5454
|
(0, import_invariant15.invariant)(!this._open, "service host is open", {
|
|
5433
5455
|
F: __dxlog_file18,
|
|
5434
|
-
L:
|
|
5456
|
+
L: 190,
|
|
5435
5457
|
S: this,
|
|
5436
5458
|
A: [
|
|
5437
5459
|
"!this._open",
|
|
@@ -5440,14 +5462,14 @@ var ClientServicesHost = class {
|
|
|
5440
5462
|
});
|
|
5441
5463
|
(0, import_log13.log)("initializing...", void 0, {
|
|
5442
5464
|
F: __dxlog_file18,
|
|
5443
|
-
L:
|
|
5465
|
+
L: 191,
|
|
5444
5466
|
S: this,
|
|
5445
5467
|
C: (f, a) => f(...a)
|
|
5446
5468
|
});
|
|
5447
5469
|
if (config) {
|
|
5448
5470
|
(0, import_invariant15.invariant)(!this._config, "config already set", {
|
|
5449
5471
|
F: __dxlog_file18,
|
|
5450
|
-
L:
|
|
5472
|
+
L: 194,
|
|
5451
5473
|
S: this,
|
|
5452
5474
|
A: [
|
|
5453
5475
|
"!this._config",
|
|
@@ -5462,7 +5484,7 @@ var ClientServicesHost = class {
|
|
|
5462
5484
|
if (!options.signalManager) {
|
|
5463
5485
|
import_log13.log.warn("running signaling without telemetry metadata.", void 0, {
|
|
5464
5486
|
F: __dxlog_file18,
|
|
5465
|
-
L:
|
|
5487
|
+
L: 202,
|
|
5466
5488
|
S: this,
|
|
5467
5489
|
C: (f, a) => f(...a)
|
|
5468
5490
|
});
|
|
@@ -5473,7 +5495,7 @@ var ClientServicesHost = class {
|
|
|
5473
5495
|
this._signalManager = signalManager;
|
|
5474
5496
|
(0, import_invariant15.invariant)(!this._networkManager, "network manager already set", {
|
|
5475
5497
|
F: __dxlog_file18,
|
|
5476
|
-
L:
|
|
5498
|
+
L: 213,
|
|
5477
5499
|
S: this,
|
|
5478
5500
|
A: [
|
|
5479
5501
|
"!this._networkManager",
|
|
@@ -5487,7 +5509,7 @@ var ClientServicesHost = class {
|
|
|
5487
5509
|
});
|
|
5488
5510
|
(0, import_log13.log)("initialized", void 0, {
|
|
5489
5511
|
F: __dxlog_file18,
|
|
5490
|
-
L:
|
|
5512
|
+
L: 220,
|
|
5491
5513
|
S: this,
|
|
5492
5514
|
C: (f, a) => f(...a)
|
|
5493
5515
|
});
|
|
@@ -5496,18 +5518,18 @@ var ClientServicesHost = class {
|
|
|
5496
5518
|
if (this._open) {
|
|
5497
5519
|
return;
|
|
5498
5520
|
}
|
|
5499
|
-
const traceId =
|
|
5500
|
-
import_log13.log.trace("dxos.client-services.host.open",
|
|
5521
|
+
const traceId = import_keys12.PublicKey.random().toHex();
|
|
5522
|
+
import_log13.log.trace("dxos.client-services.host.open", import_protocols13.trace.begin({
|
|
5501
5523
|
id: traceId
|
|
5502
5524
|
}), {
|
|
5503
5525
|
F: __dxlog_file18,
|
|
5504
|
-
L:
|
|
5526
|
+
L: 231,
|
|
5505
5527
|
S: this,
|
|
5506
5528
|
C: (f, a) => f(...a)
|
|
5507
5529
|
});
|
|
5508
5530
|
(0, import_invariant15.invariant)(this._config, "config not set", {
|
|
5509
5531
|
F: __dxlog_file18,
|
|
5510
|
-
L:
|
|
5532
|
+
L: 233,
|
|
5511
5533
|
S: this,
|
|
5512
5534
|
A: [
|
|
5513
5535
|
"this._config",
|
|
@@ -5516,7 +5538,7 @@ var ClientServicesHost = class {
|
|
|
5516
5538
|
});
|
|
5517
5539
|
(0, import_invariant15.invariant)(this._storage, "storage not set", {
|
|
5518
5540
|
F: __dxlog_file18,
|
|
5519
|
-
L:
|
|
5541
|
+
L: 234,
|
|
5520
5542
|
S: this,
|
|
5521
5543
|
A: [
|
|
5522
5544
|
"this._storage",
|
|
@@ -5525,7 +5547,7 @@ var ClientServicesHost = class {
|
|
|
5525
5547
|
});
|
|
5526
5548
|
(0, import_invariant15.invariant)(this._signalManager, "signal manager not set", {
|
|
5527
5549
|
F: __dxlog_file18,
|
|
5528
|
-
L:
|
|
5550
|
+
L: 235,
|
|
5529
5551
|
S: this,
|
|
5530
5552
|
A: [
|
|
5531
5553
|
"this._signalManager",
|
|
@@ -5534,7 +5556,7 @@ var ClientServicesHost = class {
|
|
|
5534
5556
|
});
|
|
5535
5557
|
(0, import_invariant15.invariant)(this._networkManager, "network manager not set", {
|
|
5536
5558
|
F: __dxlog_file18,
|
|
5537
|
-
L:
|
|
5559
|
+
L: 236,
|
|
5538
5560
|
S: this,
|
|
5539
5561
|
A: [
|
|
5540
5562
|
"this._networkManager",
|
|
@@ -5546,7 +5568,7 @@ var ClientServicesHost = class {
|
|
|
5546
5568
|
lockKey: this._resourceLock?.lockKey
|
|
5547
5569
|
}, {
|
|
5548
5570
|
F: __dxlog_file18,
|
|
5549
|
-
L:
|
|
5571
|
+
L: 239,
|
|
5550
5572
|
S: this,
|
|
5551
5573
|
C: (f, a) => f(...a)
|
|
5552
5574
|
});
|
|
@@ -5566,11 +5588,8 @@ var ClientServicesHost = class {
|
|
|
5566
5588
|
await this._serviceContext.initialized.wait();
|
|
5567
5589
|
return this._serviceContext.dataSpaceManager;
|
|
5568
5590
|
}),
|
|
5569
|
-
DataService:
|
|
5570
|
-
|
|
5571
|
-
indexer: this._serviceContext.indexer,
|
|
5572
|
-
automergeHost: this._serviceContext.automergeHost
|
|
5573
|
-
}),
|
|
5591
|
+
DataService: this._serviceContext.echoHost.dataService,
|
|
5592
|
+
QueryService: this._serviceContext.echoHost.queryService,
|
|
5574
5593
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
5575
5594
|
LoggingService: this._loggingService,
|
|
5576
5595
|
TracingService: this._tracingService,
|
|
@@ -5587,7 +5606,7 @@ var ClientServicesHost = class {
|
|
|
5587
5606
|
this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
|
|
5588
5607
|
url: devtoolsProxy,
|
|
5589
5608
|
requested: {},
|
|
5590
|
-
exposed:
|
|
5609
|
+
exposed: import_client_protocol5.clientServiceBundle,
|
|
5591
5610
|
handlers: this.services
|
|
5592
5611
|
});
|
|
5593
5612
|
void this._devtoolsProxy.open();
|
|
@@ -5601,15 +5620,15 @@ var ClientServicesHost = class {
|
|
|
5601
5620
|
deviceKey
|
|
5602
5621
|
}, {
|
|
5603
5622
|
F: __dxlog_file18,
|
|
5604
|
-
L:
|
|
5623
|
+
L: 315,
|
|
5605
5624
|
S: this,
|
|
5606
5625
|
C: (f, a) => f(...a)
|
|
5607
5626
|
});
|
|
5608
|
-
import_log13.log.trace("dxos.client-services.host.open",
|
|
5627
|
+
import_log13.log.trace("dxos.client-services.host.open", import_protocols13.trace.end({
|
|
5609
5628
|
id: traceId
|
|
5610
5629
|
}), {
|
|
5611
5630
|
F: __dxlog_file18,
|
|
5612
|
-
L:
|
|
5631
|
+
L: 316,
|
|
5613
5632
|
S: this,
|
|
5614
5633
|
C: (f, a) => f(...a)
|
|
5615
5634
|
});
|
|
@@ -5623,7 +5642,7 @@ var ClientServicesHost = class {
|
|
|
5623
5642
|
deviceKey
|
|
5624
5643
|
}, {
|
|
5625
5644
|
F: __dxlog_file18,
|
|
5626
|
-
L:
|
|
5645
|
+
L: 327,
|
|
5627
5646
|
S: this,
|
|
5628
5647
|
C: (f, a) => f(...a)
|
|
5629
5648
|
});
|
|
@@ -5641,24 +5660,24 @@ var ClientServicesHost = class {
|
|
|
5641
5660
|
deviceKey
|
|
5642
5661
|
}, {
|
|
5643
5662
|
F: __dxlog_file18,
|
|
5644
|
-
L:
|
|
5663
|
+
L: 336,
|
|
5645
5664
|
S: this,
|
|
5646
5665
|
C: (f, a) => f(...a)
|
|
5647
5666
|
});
|
|
5648
5667
|
}
|
|
5649
5668
|
async reset() {
|
|
5650
|
-
const traceId =
|
|
5651
|
-
import_log13.log.trace("dxos.sdk.client-services-host.reset",
|
|
5669
|
+
const traceId = import_keys12.PublicKey.random().toHex();
|
|
5670
|
+
import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols13.trace.begin({
|
|
5652
5671
|
id: traceId
|
|
5653
5672
|
}), {
|
|
5654
5673
|
F: __dxlog_file18,
|
|
5655
|
-
L:
|
|
5674
|
+
L: 341,
|
|
5656
5675
|
S: this,
|
|
5657
5676
|
C: (f, a) => f(...a)
|
|
5658
5677
|
});
|
|
5659
5678
|
(0, import_log13.log)("resetting...", void 0, {
|
|
5660
5679
|
F: __dxlog_file18,
|
|
5661
|
-
L:
|
|
5680
|
+
L: 343,
|
|
5662
5681
|
S: this,
|
|
5663
5682
|
C: (f, a) => f(...a)
|
|
5664
5683
|
});
|
|
@@ -5666,15 +5685,15 @@ var ClientServicesHost = class {
|
|
|
5666
5685
|
await this._storage.reset();
|
|
5667
5686
|
(0, import_log13.log)("reset", void 0, {
|
|
5668
5687
|
F: __dxlog_file18,
|
|
5669
|
-
L:
|
|
5688
|
+
L: 346,
|
|
5670
5689
|
S: this,
|
|
5671
5690
|
C: (f, a) => f(...a)
|
|
5672
5691
|
});
|
|
5673
|
-
import_log13.log.trace("dxos.sdk.client-services-host.reset",
|
|
5692
|
+
import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols13.trace.end({
|
|
5674
5693
|
id: traceId
|
|
5675
5694
|
}), {
|
|
5676
5695
|
F: __dxlog_file18,
|
|
5677
|
-
L:
|
|
5696
|
+
L: 347,
|
|
5678
5697
|
S: this,
|
|
5679
5698
|
C: (f, a) => f(...a)
|
|
5680
5699
|
});
|
|
@@ -5687,34 +5706,34 @@ var ClientServicesHost = class {
|
|
|
5687
5706
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5688
5707
|
(0, import_invariant15.invariant)(automergeIndex, void 0, {
|
|
5689
5708
|
F: __dxlog_file18,
|
|
5690
|
-
L:
|
|
5709
|
+
L: 359,
|
|
5691
5710
|
S: this,
|
|
5692
5711
|
A: [
|
|
5693
5712
|
"automergeIndex",
|
|
5694
5713
|
""
|
|
5695
5714
|
]
|
|
5696
5715
|
});
|
|
5697
|
-
const document = await this._serviceContext.
|
|
5716
|
+
const document = await this._serviceContext.echoHost.automergeRepo.find(automergeIndex);
|
|
5698
5717
|
await document.whenReady();
|
|
5699
5718
|
const properties = {
|
|
5700
5719
|
system: {
|
|
5701
|
-
type: (0, import_echo_pipeline5.encodeReference)((0,
|
|
5720
|
+
type: (0, import_echo_pipeline5.encodeReference)((0, import_echo_schema2.getTypeReference)(import_client_protocol5.Properties))
|
|
5702
5721
|
},
|
|
5703
5722
|
data: {
|
|
5704
|
-
[
|
|
5723
|
+
[import_client_protocol5.defaultKey]: identity.identityKey.toHex()
|
|
5705
5724
|
},
|
|
5706
5725
|
meta: {
|
|
5707
5726
|
keys: []
|
|
5708
5727
|
}
|
|
5709
5728
|
};
|
|
5710
|
-
const propertiesId =
|
|
5729
|
+
const propertiesId = import_keys12.PublicKey.random().toHex();
|
|
5711
5730
|
document.change((doc) => {
|
|
5712
5731
|
(0, import_util9.assignDeep)(doc, [
|
|
5713
5732
|
"objects",
|
|
5714
5733
|
propertiesId
|
|
5715
5734
|
], properties);
|
|
5716
5735
|
});
|
|
5717
|
-
await this._serviceContext.
|
|
5736
|
+
await this._serviceContext.echoHost.flush();
|
|
5718
5737
|
return identity;
|
|
5719
5738
|
}
|
|
5720
5739
|
};
|
|
@@ -5742,7 +5761,7 @@ var DiagnosticsCollector = class {
|
|
|
5742
5761
|
}
|
|
5743
5762
|
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
5744
5763
|
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
5745
|
-
keys: options.humanize ?
|
|
5764
|
+
keys: options.humanize ? import_services14.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services14.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
5746
5765
|
});
|
|
5747
5766
|
const clientDiagnostics = {
|
|
5748
5767
|
config,
|
|
@@ -5807,4 +5826,4 @@ var findConfigs = () => {
|
|
|
5807
5826
|
subscribeToSpaces,
|
|
5808
5827
|
subscribeToSwarmInfo
|
|
5809
5828
|
});
|
|
5810
|
-
//# sourceMappingURL=chunk-
|
|
5829
|
+
//# sourceMappingURL=chunk-5JA576YH.cjs.map
|