@dxos/client-services 0.4.10-main.c5e8686 → 0.4.10-main.c685d5c
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-FUEOAPLA.mjs → chunk-X4CYZ5QC.mjs} +652 -594
- package/dist/lib/browser/chunk-X4CYZ5QC.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +8 -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-VRSCM2WE.cjs → chunk-NBYEU3KW.cjs} +740 -679
- package/dist/lib/node/chunk-NBYEU3KW.cjs.map +7 -0
- package/dist/lib/node/index.cjs +49 -45
- 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/index.d.ts +1 -0
- package/dist/types/src/packlets/invitations/index.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 +44 -0
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/invitations-service.d.ts +7 -23
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/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 +6 -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/index.ts +1 -0
- package/src/packlets/invitations/invitation-protocol.ts +7 -1
- package/src/packlets/invitations/invitations-handler.ts +11 -73
- package/src/packlets/invitations/invitations-manager.ts +271 -0
- package/src/packlets/invitations/invitations-service.ts +23 -168
- 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 +23 -25
- package/src/packlets/services/service-host.test.ts +6 -0
- package/src/packlets/services/service-host.ts +6 -26
- 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-FUEOAPLA.mjs.map +0 -7
- package/dist/lib/node/chunk-VRSCM2WE.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_NBYEU3KW_exports = {};
|
|
30
|
+
__export(chunk_NBYEU3KW_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
33
|
ClientServicesProviderResource: () => ClientServicesProviderResource,
|
|
@@ -41,6 +41,7 @@ __export(chunk_VRSCM2WE_exports, {
|
|
|
41
41
|
IdentityManager: () => IdentityManager,
|
|
42
42
|
IdentityServiceImpl: () => IdentityServiceImpl,
|
|
43
43
|
InvitationsHandler: () => InvitationsHandler,
|
|
44
|
+
InvitationsManager: () => InvitationsManager,
|
|
44
45
|
InvitationsServiceImpl: () => InvitationsServiceImpl,
|
|
45
46
|
Lock: () => Lock,
|
|
46
47
|
ServiceContext: () => ServiceContext,
|
|
@@ -65,7 +66,7 @@ __export(chunk_VRSCM2WE_exports, {
|
|
|
65
66
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
66
67
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
67
68
|
});
|
|
68
|
-
module.exports = __toCommonJS(
|
|
69
|
+
module.exports = __toCommonJS(chunk_NBYEU3KW_exports);
|
|
69
70
|
var import_async = require("@dxos/async");
|
|
70
71
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
71
72
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -119,7 +120,6 @@ var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
119
120
|
var import_async7 = require("@dxos/async");
|
|
120
121
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
121
122
|
var import_context4 = require("@dxos/context");
|
|
122
|
-
var import_credentials7 = require("@dxos/credentials");
|
|
123
123
|
var import_crypto = require("@dxos/crypto");
|
|
124
124
|
var import_invariant5 = require("@dxos/invariant");
|
|
125
125
|
var import_keys5 = require("@dxos/keys");
|
|
@@ -138,62 +138,67 @@ var import_protocols5 = require("@dxos/protocols");
|
|
|
138
138
|
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
139
139
|
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
140
140
|
var import_teleport = require("@dxos/teleport");
|
|
141
|
-
var import_async9 = require("@dxos/async");
|
|
142
141
|
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
143
|
-
var import_context6 = require("@dxos/context");
|
|
144
|
-
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
145
|
-
var import_invariant7 = require("@dxos/invariant");
|
|
146
|
-
var import_log6 = require("@dxos/log");
|
|
147
142
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
148
|
-
var
|
|
143
|
+
var import_credentials7 = require("@dxos/credentials");
|
|
149
144
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
150
|
-
var
|
|
151
|
-
var
|
|
145
|
+
var import_invariant7 = require("@dxos/invariant");
|
|
146
|
+
var import_log6 = require("@dxos/log");
|
|
152
147
|
var import_protocols6 = require("@dxos/protocols");
|
|
153
148
|
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
149
|
+
var import_credentials8 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
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");
|
|
154
|
+
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
155
|
+
var import_invariant8 = require("@dxos/invariant");
|
|
156
|
+
var import_keys7 = require("@dxos/keys");
|
|
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
|
|
164
|
+
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
160
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
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
190
|
var import_context9 = require("@dxos/context");
|
|
186
|
-
var
|
|
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
211
|
var import_context10 = require("@dxos/context");
|
|
207
|
-
var
|
|
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
|
|
238
|
+
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
237
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
|
});
|
|
@@ -2021,11 +1983,11 @@ var InvitationsHandler = class {
|
|
|
2021
1983
|
});
|
|
2022
1984
|
return extension;
|
|
2023
1985
|
};
|
|
2024
|
-
if (invitation.lifetime && invitation.created
|
|
1986
|
+
if (invitation.lifetime && invitation.created) {
|
|
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
|
});
|
|
@@ -2444,194 +2394,34 @@ var createAdmissionKeypair = () => {
|
|
|
2444
2394
|
privateKey: keypair.secretKey
|
|
2445
2395
|
};
|
|
2446
2396
|
};
|
|
2447
|
-
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
2448
2397
|
var InvitationsServiceImpl = class {
|
|
2449
|
-
constructor(
|
|
2450
|
-
this.
|
|
2451
|
-
this._getHandler = _getHandler;
|
|
2452
|
-
this._metadataStore = _metadataStore;
|
|
2453
|
-
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2454
|
-
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2455
|
-
this._invitationCreated = new import_async9.Event();
|
|
2456
|
-
this._invitationAccepted = new import_async9.Event();
|
|
2457
|
-
this._removedCreated = new import_async9.Event();
|
|
2458
|
-
this._removedAccepted = new import_async9.Event();
|
|
2459
|
-
this._saved = new import_async9.Event();
|
|
2460
|
-
this._persistentInvitationsLoadedEvent = new import_async9.Event();
|
|
2461
|
-
this._persistentInvitationsLoaded = false;
|
|
2398
|
+
constructor(_invitationsManager) {
|
|
2399
|
+
this._invitationsManager = _invitationsManager;
|
|
2462
2400
|
}
|
|
2463
2401
|
// TODO(burdon): Guest/host label.
|
|
2464
2402
|
getLoggingContext() {
|
|
2465
2403
|
return {};
|
|
2466
2404
|
}
|
|
2467
2405
|
createInvitation(options) {
|
|
2468
|
-
let invitation;
|
|
2469
|
-
const savePersistentInvitationCtx = new import_context6.Context();
|
|
2470
|
-
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2471
|
-
if (existingInvitation) {
|
|
2472
|
-
invitation = existingInvitation;
|
|
2473
|
-
} else {
|
|
2474
|
-
const handler = this._getHandler(options);
|
|
2475
|
-
invitation = this._invitationsHandler.createInvitation(handler, options);
|
|
2476
|
-
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2477
|
-
this._invitationCreated.emit(invitation.get());
|
|
2478
|
-
}
|
|
2479
2406
|
return new import_codec_protobuf8.Stream(({ next, close }) => {
|
|
2480
|
-
|
|
2481
|
-
(0, import_async9.scheduleTask)(savePersistentInvitationCtx, async () => {
|
|
2482
|
-
try {
|
|
2483
|
-
await this._metadataStore.addInvitation(invitation.get());
|
|
2484
|
-
this._saved.emit(invitation.get());
|
|
2485
|
-
} catch (err) {
|
|
2486
|
-
close(err);
|
|
2487
|
-
}
|
|
2488
|
-
});
|
|
2489
|
-
}
|
|
2490
|
-
invitation.subscribe((invitation2) => {
|
|
2491
|
-
next(invitation2);
|
|
2492
|
-
}, async (err) => {
|
|
2493
|
-
await savePersistentInvitationCtx.dispose();
|
|
2494
|
-
close(err);
|
|
2495
|
-
}, async () => {
|
|
2496
|
-
close();
|
|
2497
|
-
if (invitation.get().persistent) {
|
|
2498
|
-
await savePersistentInvitationCtx.dispose();
|
|
2499
|
-
await this._metadataStore.removeInvitation(invitation.get().invitationId);
|
|
2500
|
-
}
|
|
2501
|
-
this._createInvitations.delete(invitation.get().invitationId);
|
|
2502
|
-
if (!invitation.get().multiUse) {
|
|
2503
|
-
this._removedCreated.emit(invitation.get());
|
|
2504
|
-
}
|
|
2505
|
-
});
|
|
2407
|
+
void this._invitationsManager.createInvitation(options).then((invitation) => invitation.subscribe(next, close, close)).catch(close);
|
|
2506
2408
|
});
|
|
2507
2409
|
}
|
|
2508
|
-
|
|
2509
|
-
const
|
|
2510
|
-
const freshInvitations = persistentInvitations.filter(async (invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
|
|
2511
|
-
const cInvitations = freshInvitations.map((persistentInvitation) => {
|
|
2512
|
-
(0, import_invariant7.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2513
|
-
F: __dxlog_file8,
|
|
2514
|
-
L: 109,
|
|
2515
|
-
S: this,
|
|
2516
|
-
A: [
|
|
2517
|
-
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2518
|
-
"'invitation already exists'"
|
|
2519
|
-
]
|
|
2520
|
-
});
|
|
2521
|
-
const handler = this._getHandler(persistentInvitation);
|
|
2522
|
-
const invitation = this._invitationsHandler.createInvitation(handler, persistentInvitation);
|
|
2523
|
-
this._createInvitations.set(invitation.get().invitationId, invitation);
|
|
2524
|
-
this._invitationCreated.emit(invitation.get());
|
|
2525
|
-
return persistentInvitation;
|
|
2526
|
-
});
|
|
2527
|
-
this._persistentInvitationsLoadedEvent.emit();
|
|
2528
|
-
this._persistentInvitationsLoaded = true;
|
|
2529
|
-
return {
|
|
2530
|
-
invitations: cInvitations
|
|
2531
|
-
};
|
|
2532
|
-
}
|
|
2533
|
-
acceptInvitation({ invitation: options, deviceProfile }) {
|
|
2534
|
-
let invitation;
|
|
2535
|
-
if (deviceProfile) {
|
|
2536
|
-
(0, import_invariant7.invariant)(options.kind === import_services5.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2537
|
-
F: __dxlog_file8,
|
|
2538
|
-
L: 127,
|
|
2539
|
-
S: this,
|
|
2540
|
-
A: [
|
|
2541
|
-
"options.kind === Invitation.Kind.DEVICE",
|
|
2542
|
-
"'deviceProfile provided for non-device invitation'"
|
|
2543
|
-
]
|
|
2544
|
-
});
|
|
2545
|
-
}
|
|
2546
|
-
const existingInvitation = this._acceptInvitations.get(options.invitationId);
|
|
2547
|
-
if (existingInvitation) {
|
|
2548
|
-
invitation = existingInvitation;
|
|
2549
|
-
} else {
|
|
2550
|
-
const handler = this._getHandler(options);
|
|
2551
|
-
invitation = this._invitationsHandler.acceptInvitation(handler, options, deviceProfile);
|
|
2552
|
-
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
2553
|
-
this._invitationAccepted.emit(invitation.get());
|
|
2554
|
-
}
|
|
2410
|
+
acceptInvitation(request) {
|
|
2411
|
+
const invitation = this._invitationsManager.acceptInvitation(request);
|
|
2555
2412
|
return new import_codec_protobuf8.Stream(({ next, close }) => {
|
|
2556
|
-
invitation.subscribe(
|
|
2557
|
-
next(invitation2);
|
|
2558
|
-
}, (err) => {
|
|
2559
|
-
close(err);
|
|
2560
|
-
}, () => {
|
|
2561
|
-
close();
|
|
2562
|
-
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2563
|
-
if (!invitation.get().multiUse) {
|
|
2564
|
-
this._removedAccepted.emit(invitation.get());
|
|
2565
|
-
}
|
|
2566
|
-
});
|
|
2413
|
+
invitation.subscribe(next, close, close);
|
|
2567
2414
|
});
|
|
2568
2415
|
}
|
|
2569
|
-
async authenticate(
|
|
2570
|
-
|
|
2571
|
-
F: __dxlog_file8,
|
|
2572
|
-
L: 160,
|
|
2573
|
-
S: this,
|
|
2574
|
-
C: (f, a) => f(...a)
|
|
2575
|
-
});
|
|
2576
|
-
(0, import_invariant7.invariant)(invitationId, void 0, {
|
|
2577
|
-
F: __dxlog_file8,
|
|
2578
|
-
L: 161,
|
|
2579
|
-
S: this,
|
|
2580
|
-
A: [
|
|
2581
|
-
"invitationId",
|
|
2582
|
-
""
|
|
2583
|
-
]
|
|
2584
|
-
});
|
|
2585
|
-
const observable = this._acceptInvitations.get(invitationId);
|
|
2586
|
-
if (!observable) {
|
|
2587
|
-
import_log6.log.warn("invalid invitation", {
|
|
2588
|
-
invitationId
|
|
2589
|
-
}, {
|
|
2590
|
-
F: __dxlog_file8,
|
|
2591
|
-
L: 164,
|
|
2592
|
-
S: this,
|
|
2593
|
-
C: (f, a) => f(...a)
|
|
2594
|
-
});
|
|
2595
|
-
} else {
|
|
2596
|
-
await observable.authenticate(authCode);
|
|
2597
|
-
}
|
|
2416
|
+
async authenticate(request) {
|
|
2417
|
+
return this._invitationsManager.authenticate(request);
|
|
2598
2418
|
}
|
|
2599
|
-
async cancelInvitation(
|
|
2600
|
-
|
|
2601
|
-
invitationId
|
|
2602
|
-
}, {
|
|
2603
|
-
F: __dxlog_file8,
|
|
2604
|
-
L: 171,
|
|
2605
|
-
S: this,
|
|
2606
|
-
C: (f, a) => f(...a)
|
|
2607
|
-
});
|
|
2608
|
-
(0, import_invariant7.invariant)(invitationId, void 0, {
|
|
2609
|
-
F: __dxlog_file8,
|
|
2610
|
-
L: 172,
|
|
2611
|
-
S: this,
|
|
2612
|
-
A: [
|
|
2613
|
-
"invitationId",
|
|
2614
|
-
""
|
|
2615
|
-
]
|
|
2616
|
-
});
|
|
2617
|
-
const created = this._createInvitations.get(invitationId);
|
|
2618
|
-
const accepted = this._acceptInvitations.get(invitationId);
|
|
2619
|
-
if (created) {
|
|
2620
|
-
await created.cancel();
|
|
2621
|
-
this._createInvitations.delete(invitationId);
|
|
2622
|
-
this._removedCreated.emit(created.get());
|
|
2623
|
-
if (created.get().persistent) {
|
|
2624
|
-
await this._metadataStore.removeInvitation(created.get().invitationId);
|
|
2625
|
-
}
|
|
2626
|
-
} else if (accepted) {
|
|
2627
|
-
await accepted.cancel();
|
|
2628
|
-
this._acceptInvitations.delete(invitationId);
|
|
2629
|
-
this._removedAccepted.emit(accepted.get());
|
|
2630
|
-
}
|
|
2419
|
+
async cancelInvitation(request) {
|
|
2420
|
+
return this._invitationsManager.cancelInvitation(request);
|
|
2631
2421
|
}
|
|
2632
2422
|
queryInvitations() {
|
|
2633
2423
|
return new import_codec_protobuf8.Stream(({ next, ctx }) => {
|
|
2634
|
-
this.
|
|
2424
|
+
this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
|
|
2635
2425
|
next({
|
|
2636
2426
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2637
2427
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2640,7 +2430,7 @@ var InvitationsServiceImpl = class {
|
|
|
2640
2430
|
]
|
|
2641
2431
|
});
|
|
2642
2432
|
});
|
|
2643
|
-
this.
|
|
2433
|
+
this._invitationsManager.invitationAccepted.on(ctx, (invitation) => {
|
|
2644
2434
|
next({
|
|
2645
2435
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2646
2436
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2649,7 +2439,7 @@ var InvitationsServiceImpl = class {
|
|
|
2649
2439
|
]
|
|
2650
2440
|
});
|
|
2651
2441
|
});
|
|
2652
|
-
this.
|
|
2442
|
+
this._invitationsManager.removedCreated.on(ctx, (invitation) => {
|
|
2653
2443
|
next({
|
|
2654
2444
|
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2655
2445
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2658,7 +2448,7 @@ var InvitationsServiceImpl = class {
|
|
|
2658
2448
|
]
|
|
2659
2449
|
});
|
|
2660
2450
|
});
|
|
2661
|
-
this.
|
|
2451
|
+
this._invitationsManager.removedAccepted.on(ctx, (invitation) => {
|
|
2662
2452
|
next({
|
|
2663
2453
|
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2664
2454
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2667,7 +2457,7 @@ var InvitationsServiceImpl = class {
|
|
|
2667
2457
|
]
|
|
2668
2458
|
});
|
|
2669
2459
|
});
|
|
2670
|
-
this.
|
|
2460
|
+
this._invitationsManager.saved.on(ctx, (invitation) => {
|
|
2671
2461
|
next({
|
|
2672
2462
|
action: import_services5.QueryInvitationsResponse.Action.SAVED,
|
|
2673
2463
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2679,32 +2469,25 @@ var InvitationsServiceImpl = class {
|
|
|
2679
2469
|
next({
|
|
2680
2470
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2681
2471
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
2682
|
-
invitations:
|
|
2472
|
+
invitations: this._invitationsManager.getCreatedInvitations(),
|
|
2683
2473
|
existing: true
|
|
2684
2474
|
});
|
|
2685
2475
|
next({
|
|
2686
2476
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2687
2477
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
2688
|
-
invitations:
|
|
2478
|
+
invitations: this._invitationsManager.getAcceptedInvitations(),
|
|
2689
2479
|
existing: true
|
|
2690
2480
|
});
|
|
2691
|
-
|
|
2481
|
+
this._invitationsManager.onPersistentInvitationsLoaded(ctx, () => {
|
|
2692
2482
|
next({
|
|
2693
2483
|
action: import_services5.QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2694
2484
|
type: import_services5.QueryInvitationsResponse.Type.CREATED
|
|
2695
2485
|
});
|
|
2696
|
-
}
|
|
2697
|
-
this._persistentInvitationsLoadedEvent.on(ctx, () => {
|
|
2698
|
-
next({
|
|
2699
|
-
action: import_services5.QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2700
|
-
type: import_services5.QueryInvitationsResponse.Type.CREATED
|
|
2701
|
-
});
|
|
2702
|
-
});
|
|
2703
|
-
}
|
|
2486
|
+
});
|
|
2704
2487
|
});
|
|
2705
2488
|
}
|
|
2706
2489
|
};
|
|
2707
|
-
var
|
|
2490
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2708
2491
|
var SpaceInvitationProtocol = class {
|
|
2709
2492
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
2710
2493
|
this._spaceManager = _spaceManager;
|
|
@@ -2724,10 +2507,10 @@ var SpaceInvitationProtocol = class {
|
|
|
2724
2507
|
spaceKey: this._spaceKey
|
|
2725
2508
|
};
|
|
2726
2509
|
}
|
|
2727
|
-
async admit(request, guestProfile) {
|
|
2728
|
-
(0,
|
|
2729
|
-
F:
|
|
2730
|
-
L:
|
|
2510
|
+
async admit(invitation, request, guestProfile) {
|
|
2511
|
+
(0, import_invariant7.invariant)(this._spaceKey, void 0, {
|
|
2512
|
+
F: __dxlog_file8,
|
|
2513
|
+
L: 55,
|
|
2731
2514
|
S: this,
|
|
2732
2515
|
A: [
|
|
2733
2516
|
"this._spaceKey",
|
|
@@ -2735,18 +2518,18 @@ var SpaceInvitationProtocol = class {
|
|
|
2735
2518
|
]
|
|
2736
2519
|
});
|
|
2737
2520
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2738
|
-
(0,
|
|
2739
|
-
F:
|
|
2740
|
-
L:
|
|
2521
|
+
(0, import_invariant7.invariant)(space, void 0, {
|
|
2522
|
+
F: __dxlog_file8,
|
|
2523
|
+
L: 57,
|
|
2741
2524
|
S: this,
|
|
2742
2525
|
A: [
|
|
2743
2526
|
"space",
|
|
2744
2527
|
""
|
|
2745
2528
|
]
|
|
2746
2529
|
});
|
|
2747
|
-
(0,
|
|
2748
|
-
F:
|
|
2749
|
-
L:
|
|
2530
|
+
(0, import_invariant7.invariant)(request.space, void 0, {
|
|
2531
|
+
F: __dxlog_file8,
|
|
2532
|
+
L: 59,
|
|
2750
2533
|
S: this,
|
|
2751
2534
|
A: [
|
|
2752
2535
|
"request.space",
|
|
@@ -2754,19 +2537,19 @@ var SpaceInvitationProtocol = class {
|
|
|
2754
2537
|
]
|
|
2755
2538
|
});
|
|
2756
2539
|
const { identityKey, deviceKey } = request.space;
|
|
2757
|
-
(0,
|
|
2540
|
+
(0, import_log6.log)("writing guest credentials", {
|
|
2758
2541
|
host: this._signingContext.deviceKey,
|
|
2759
2542
|
guest: deviceKey
|
|
2760
2543
|
}, {
|
|
2761
|
-
F:
|
|
2762
|
-
L:
|
|
2544
|
+
F: __dxlog_file8,
|
|
2545
|
+
L: 62,
|
|
2763
2546
|
S: this,
|
|
2764
2547
|
C: (f, a) => f(...a)
|
|
2765
2548
|
});
|
|
2766
|
-
const credentials = await (0,
|
|
2767
|
-
(0,
|
|
2768
|
-
F:
|
|
2769
|
-
L:
|
|
2549
|
+
const credentials = await (0, import_credentials7.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile, invitation.delegationCredentialId);
|
|
2550
|
+
(0, import_invariant7.invariant)(credentials[0].credential, void 0, {
|
|
2551
|
+
F: __dxlog_file8,
|
|
2552
|
+
L: 74,
|
|
2770
2553
|
S: this,
|
|
2771
2554
|
A: [
|
|
2772
2555
|
"credentials[0].credential",
|
|
@@ -2774,22 +2557,85 @@ var SpaceInvitationProtocol = class {
|
|
|
2774
2557
|
]
|
|
2775
2558
|
});
|
|
2776
2559
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2777
|
-
(0,
|
|
2778
|
-
F:
|
|
2779
|
-
L:
|
|
2560
|
+
(0, import_invariant7.invariant)((0, import_credentials7.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2561
|
+
F: __dxlog_file8,
|
|
2562
|
+
L: 76,
|
|
2563
|
+
S: this,
|
|
2564
|
+
A: [
|
|
2565
|
+
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2566
|
+
""
|
|
2567
|
+
]
|
|
2568
|
+
});
|
|
2569
|
+
await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, credentials);
|
|
2570
|
+
return {
|
|
2571
|
+
space: {
|
|
2572
|
+
credential: spaceMemberCredential,
|
|
2573
|
+
controlTimeframe: space.inner.controlPipeline.state.timeframe
|
|
2574
|
+
}
|
|
2575
|
+
};
|
|
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,
|
|
2780
2629
|
S: this,
|
|
2781
2630
|
A: [
|
|
2782
|
-
"
|
|
2631
|
+
"credential.credential",
|
|
2783
2632
|
""
|
|
2784
2633
|
]
|
|
2785
2634
|
});
|
|
2786
|
-
await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer,
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
controlTimeframe: space.inner.controlPipeline.state.timeframe
|
|
2791
|
-
}
|
|
2792
|
-
};
|
|
2635
|
+
await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, [
|
|
2636
|
+
credential
|
|
2637
|
+
]);
|
|
2638
|
+
return credential.credential.credential.id;
|
|
2793
2639
|
}
|
|
2794
2640
|
checkInvitation(invitation) {
|
|
2795
2641
|
if (invitation.spaceKey && this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
@@ -2814,9 +2660,9 @@ var SpaceInvitationProtocol = class {
|
|
|
2814
2660
|
};
|
|
2815
2661
|
}
|
|
2816
2662
|
async accept(response) {
|
|
2817
|
-
(0,
|
|
2818
|
-
F:
|
|
2819
|
-
L:
|
|
2663
|
+
(0, import_invariant7.invariant)(response.space, void 0, {
|
|
2664
|
+
F: __dxlog_file8,
|
|
2665
|
+
L: 149,
|
|
2820
2666
|
S: this,
|
|
2821
2667
|
A: [
|
|
2822
2668
|
"response.space",
|
|
@@ -2824,19 +2670,19 @@ var SpaceInvitationProtocol = class {
|
|
|
2824
2670
|
]
|
|
2825
2671
|
});
|
|
2826
2672
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2827
|
-
const assertion = (0,
|
|
2828
|
-
(0,
|
|
2829
|
-
F:
|
|
2830
|
-
L:
|
|
2673
|
+
const assertion = (0, import_credentials7.getCredentialAssertion)(credential);
|
|
2674
|
+
(0, import_invariant7.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2675
|
+
F: __dxlog_file8,
|
|
2676
|
+
L: 152,
|
|
2831
2677
|
S: this,
|
|
2832
2678
|
A: [
|
|
2833
2679
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2834
2680
|
"'Invalid credential'"
|
|
2835
2681
|
]
|
|
2836
2682
|
});
|
|
2837
|
-
(0,
|
|
2838
|
-
F:
|
|
2839
|
-
L:
|
|
2683
|
+
(0, import_invariant7.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2684
|
+
F: __dxlog_file8,
|
|
2685
|
+
L: 153,
|
|
2840
2686
|
S: this,
|
|
2841
2687
|
A: [
|
|
2842
2688
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
@@ -2858,6 +2704,284 @@ var SpaceInvitationProtocol = class {
|
|
|
2858
2704
|
};
|
|
2859
2705
|
}
|
|
2860
2706
|
};
|
|
2707
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
2708
|
+
var InvitationsManager = class {
|
|
2709
|
+
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
2710
|
+
this._invitationsHandler = _invitationsHandler;
|
|
2711
|
+
this._getHandler = _getHandler;
|
|
2712
|
+
this._metadataStore = _metadataStore;
|
|
2713
|
+
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2714
|
+
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2715
|
+
this.invitationCreated = new import_async9.Event();
|
|
2716
|
+
this.invitationAccepted = new import_async9.Event();
|
|
2717
|
+
this.removedCreated = new import_async9.Event();
|
|
2718
|
+
this.removedAccepted = new import_async9.Event();
|
|
2719
|
+
this.saved = new import_async9.Event();
|
|
2720
|
+
this._persistentInvitationsLoadedEvent = new import_async9.Event();
|
|
2721
|
+
this._persistentInvitationsLoaded = false;
|
|
2722
|
+
}
|
|
2723
|
+
async createInvitation(options) {
|
|
2724
|
+
if (options.invitationId) {
|
|
2725
|
+
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2726
|
+
if (existingInvitation) {
|
|
2727
|
+
return existingInvitation;
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
const handler = this._getHandler(options);
|
|
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());
|
|
2740
|
+
}
|
|
2741
|
+
});
|
|
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;
|
|
2756
|
+
}
|
|
2757
|
+
async loadPersistentInvitations() {
|
|
2758
|
+
if (this._persistentInvitationsLoaded) {
|
|
2759
|
+
const invitations = this.getCreatedInvitations().filter((i) => i.persistent);
|
|
2760
|
+
return {
|
|
2761
|
+
invitations
|
|
2762
|
+
};
|
|
2763
|
+
}
|
|
2764
|
+
try {
|
|
2765
|
+
const persistentInvitations = this._metadataStore.getInvitations();
|
|
2766
|
+
const freshInvitations = persistentInvitations.filter((invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
|
|
2767
|
+
const loadTasks = freshInvitations.map((persistentInvitation) => {
|
|
2768
|
+
(0, import_invariant8.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2769
|
+
F: __dxlog_file9,
|
|
2770
|
+
L: 97,
|
|
2771
|
+
S: this,
|
|
2772
|
+
A: [
|
|
2773
|
+
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2774
|
+
"'invitation already exists'"
|
|
2775
|
+
]
|
|
2776
|
+
});
|
|
2777
|
+
return this.createInvitation({
|
|
2778
|
+
...persistentInvitation,
|
|
2779
|
+
persistent: false
|
|
2780
|
+
});
|
|
2781
|
+
});
|
|
2782
|
+
const cInvitations = await Promise.all(loadTasks);
|
|
2783
|
+
return {
|
|
2784
|
+
invitations: cInvitations.map((invitation) => invitation.get())
|
|
2785
|
+
};
|
|
2786
|
+
} catch (err) {
|
|
2787
|
+
import_log7.log.catch(err, void 0, {
|
|
2788
|
+
F: __dxlog_file9,
|
|
2789
|
+
L: 104,
|
|
2790
|
+
S: this,
|
|
2791
|
+
C: (f, a) => f(...a)
|
|
2792
|
+
});
|
|
2793
|
+
return {
|
|
2794
|
+
invitations: []
|
|
2795
|
+
};
|
|
2796
|
+
} finally {
|
|
2797
|
+
this._persistentInvitationsLoadedEvent.emit();
|
|
2798
|
+
this._persistentInvitationsLoaded = true;
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2801
|
+
acceptInvitation(request) {
|
|
2802
|
+
const options = request.invitation;
|
|
2803
|
+
const existingInvitation = this._acceptInvitations.get(options.invitationId);
|
|
2804
|
+
if (existingInvitation) {
|
|
2805
|
+
return existingInvitation;
|
|
2806
|
+
}
|
|
2807
|
+
const handler = this._getHandler(options);
|
|
2808
|
+
const invitation = this._invitationsHandler.acceptInvitation(handler, options, request.deviceProfile);
|
|
2809
|
+
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
2810
|
+
this.invitationAccepted.emit(invitation.get());
|
|
2811
|
+
this._onInvitationComplete(invitation, () => {
|
|
2812
|
+
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2813
|
+
this.removedAccepted.emit(invitation.get());
|
|
2814
|
+
});
|
|
2815
|
+
return invitation;
|
|
2816
|
+
}
|
|
2817
|
+
async authenticate({ invitationId, authCode }) {
|
|
2818
|
+
(0, import_log7.log)("authenticating...", void 0, {
|
|
2819
|
+
F: __dxlog_file9,
|
|
2820
|
+
L: 133,
|
|
2821
|
+
S: this,
|
|
2822
|
+
C: (f, a) => f(...a)
|
|
2823
|
+
});
|
|
2824
|
+
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2825
|
+
F: __dxlog_file9,
|
|
2826
|
+
L: 134,
|
|
2827
|
+
S: this,
|
|
2828
|
+
A: [
|
|
2829
|
+
"invitationId",
|
|
2830
|
+
""
|
|
2831
|
+
]
|
|
2832
|
+
});
|
|
2833
|
+
const observable = this._acceptInvitations.get(invitationId);
|
|
2834
|
+
if (!observable) {
|
|
2835
|
+
import_log7.log.warn("invalid invitation", {
|
|
2836
|
+
invitationId
|
|
2837
|
+
}, {
|
|
2838
|
+
F: __dxlog_file9,
|
|
2839
|
+
L: 137,
|
|
2840
|
+
S: this,
|
|
2841
|
+
C: (f, a) => f(...a)
|
|
2842
|
+
});
|
|
2843
|
+
} else {
|
|
2844
|
+
await observable.authenticate(authCode);
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
async cancelInvitation({ invitationId }) {
|
|
2848
|
+
(0, import_log7.log)("cancelInvitation...", {
|
|
2849
|
+
invitationId
|
|
2850
|
+
}, {
|
|
2851
|
+
F: __dxlog_file9,
|
|
2852
|
+
L: 144,
|
|
2853
|
+
S: this,
|
|
2854
|
+
C: (f, a) => f(...a)
|
|
2855
|
+
});
|
|
2856
|
+
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2857
|
+
F: __dxlog_file9,
|
|
2858
|
+
L: 145,
|
|
2859
|
+
S: this,
|
|
2860
|
+
A: [
|
|
2861
|
+
"invitationId",
|
|
2862
|
+
""
|
|
2863
|
+
]
|
|
2864
|
+
});
|
|
2865
|
+
const created = this._createInvitations.get(invitationId);
|
|
2866
|
+
if (created) {
|
|
2867
|
+
if (created.get().persistent) {
|
|
2868
|
+
await this._metadataStore.removeInvitation(invitationId);
|
|
2869
|
+
}
|
|
2870
|
+
await created.cancel();
|
|
2871
|
+
this._createInvitations.delete(invitationId);
|
|
2872
|
+
this.removedCreated.emit(created.get());
|
|
2873
|
+
return;
|
|
2874
|
+
}
|
|
2875
|
+
const accepted = this._acceptInvitations.get(invitationId);
|
|
2876
|
+
if (accepted) {
|
|
2877
|
+
await accepted.cancel();
|
|
2878
|
+
this._acceptInvitations.delete(invitationId);
|
|
2879
|
+
this.removedAccepted.emit(accepted.get());
|
|
2880
|
+
}
|
|
2881
|
+
}
|
|
2882
|
+
getCreatedInvitations() {
|
|
2883
|
+
return [
|
|
2884
|
+
...this._createInvitations.values()
|
|
2885
|
+
].map((i) => i.get());
|
|
2886
|
+
}
|
|
2887
|
+
getAcceptedInvitations() {
|
|
2888
|
+
return [
|
|
2889
|
+
...this._acceptInvitations.values()
|
|
2890
|
+
].map((i) => i.get());
|
|
2891
|
+
}
|
|
2892
|
+
onPersistentInvitationsLoaded(ctx, callback) {
|
|
2893
|
+
if (this._persistentInvitationsLoaded) {
|
|
2894
|
+
callback();
|
|
2895
|
+
} else {
|
|
2896
|
+
this._persistentInvitationsLoadedEvent.once(ctx, () => callback());
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
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)
|
|
2935
|
+
});
|
|
2936
|
+
stream.complete();
|
|
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
|
+
}
|
|
2966
|
+
}
|
|
2967
|
+
async _safeDeleteInvitation(invitation) {
|
|
2968
|
+
try {
|
|
2969
|
+
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
2970
|
+
} catch (err) {
|
|
2971
|
+
import_log7.log.catch(err, void 0, {
|
|
2972
|
+
F: __dxlog_file9,
|
|
2973
|
+
L: 260,
|
|
2974
|
+
S: this,
|
|
2975
|
+
C: (f, a) => f(...a)
|
|
2976
|
+
});
|
|
2977
|
+
}
|
|
2978
|
+
}
|
|
2979
|
+
_onInvitationComplete(invitation, callback) {
|
|
2980
|
+
invitation.subscribe(() => {
|
|
2981
|
+
}, () => {
|
|
2982
|
+
}, callback);
|
|
2983
|
+
}
|
|
2984
|
+
};
|
|
2861
2985
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
2862
2986
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2863
2987
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -2942,7 +3066,7 @@ var AutomergeSpaceState = class {
|
|
|
2942
3066
|
this._isProcessingRootDocs = false;
|
|
2943
3067
|
}
|
|
2944
3068
|
async processCredential(credential) {
|
|
2945
|
-
if (!(0,
|
|
3069
|
+
if (!(0, import_credentials11.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
2946
3070
|
return;
|
|
2947
3071
|
}
|
|
2948
3072
|
this.lastEpoch = credential;
|
|
@@ -2977,8 +3101,8 @@ var NotarizationPlugin = class {
|
|
|
2977
3101
|
this._ctx = new import_context8.Context();
|
|
2978
3102
|
this._extensionOpened = new import_async12.Event();
|
|
2979
3103
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2980
|
-
this._processedCredentials = new import_util5.ComplexSet(
|
|
2981
|
-
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);
|
|
2982
3106
|
}
|
|
2983
3107
|
get hasWriter() {
|
|
2984
3108
|
return !!this._writer;
|
|
@@ -3242,7 +3366,7 @@ var DataSpace = class {
|
|
|
3242
3366
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3243
3367
|
this._cache = void 0;
|
|
3244
3368
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
3245
|
-
this._state =
|
|
3369
|
+
this._state = import_services8.SpaceState.CLOSED;
|
|
3246
3370
|
this.error = void 0;
|
|
3247
3371
|
this.stateUpdate = new import_async10.Event();
|
|
3248
3372
|
this.metrics = {};
|
|
@@ -3255,19 +3379,19 @@ var DataSpace = class {
|
|
|
3255
3379
|
this._metadataStore = params.metadataStore;
|
|
3256
3380
|
this._signingContext = params.signingContext;
|
|
3257
3381
|
this._callbacks = params.callbacks ?? {};
|
|
3258
|
-
this.
|
|
3382
|
+
this._echoHost = params.echoHost;
|
|
3259
3383
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
3260
|
-
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)),
|
|
3261
3385
|
update: this._inner.stateUpdate,
|
|
3262
|
-
authTimeout:
|
|
3386
|
+
authTimeout: import_client_protocol4.AUTH_TIMEOUT
|
|
3263
3387
|
});
|
|
3264
3388
|
this._cache = params.cache;
|
|
3265
3389
|
this._state = params.initialState;
|
|
3266
3390
|
(0, import_log8.log)("new state", {
|
|
3267
|
-
state:
|
|
3391
|
+
state: import_services8.SpaceState[this._state]
|
|
3268
3392
|
}, {
|
|
3269
3393
|
F: __dxlog_file11,
|
|
3270
|
-
L:
|
|
3394
|
+
L: 135,
|
|
3271
3395
|
S: this,
|
|
3272
3396
|
C: (f, a) => f(...a)
|
|
3273
3397
|
});
|
|
@@ -3312,12 +3436,12 @@ var DataSpace = class {
|
|
|
3312
3436
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3313
3437
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3314
3438
|
await this._inner.open(new import_context7.Context());
|
|
3315
|
-
this._state =
|
|
3439
|
+
this._state = import_services8.SpaceState.CONTROL_ONLY;
|
|
3316
3440
|
(0, import_log8.log)("new state", {
|
|
3317
|
-
state:
|
|
3441
|
+
state: import_services8.SpaceState[this._state]
|
|
3318
3442
|
}, {
|
|
3319
3443
|
F: __dxlog_file11,
|
|
3320
|
-
L:
|
|
3444
|
+
L: 193,
|
|
3321
3445
|
S: this,
|
|
3322
3446
|
C: (f, a) => f(...a)
|
|
3323
3447
|
});
|
|
@@ -3330,12 +3454,12 @@ var DataSpace = class {
|
|
|
3330
3454
|
}
|
|
3331
3455
|
async _close() {
|
|
3332
3456
|
await this._callbacks.beforeClose?.();
|
|
3333
|
-
this._state =
|
|
3457
|
+
this._state = import_services8.SpaceState.CLOSED;
|
|
3334
3458
|
(0, import_log8.log)("new state", {
|
|
3335
|
-
state:
|
|
3459
|
+
state: import_services8.SpaceState[this._state]
|
|
3336
3460
|
}, {
|
|
3337
3461
|
F: __dxlog_file11,
|
|
3338
|
-
L:
|
|
3462
|
+
L: 207,
|
|
3339
3463
|
S: this,
|
|
3340
3464
|
C: (f, a) => f(...a)
|
|
3341
3465
|
});
|
|
@@ -3367,7 +3491,7 @@ var DataSpace = class {
|
|
|
3367
3491
|
if (err instanceof import_protocols7.CancelledError || err instanceof import_context7.ContextDisposedError) {
|
|
3368
3492
|
(0, import_log8.log)("data pipeline initialization cancelled", err, {
|
|
3369
3493
|
F: __dxlog_file11,
|
|
3370
|
-
L:
|
|
3494
|
+
L: 240,
|
|
3371
3495
|
S: this,
|
|
3372
3496
|
C: (f, a) => f(...a)
|
|
3373
3497
|
});
|
|
@@ -3375,16 +3499,16 @@ var DataSpace = class {
|
|
|
3375
3499
|
}
|
|
3376
3500
|
import_log8.log.error("Error initializing data pipeline", err, {
|
|
3377
3501
|
F: __dxlog_file11,
|
|
3378
|
-
L:
|
|
3502
|
+
L: 244,
|
|
3379
3503
|
S: this,
|
|
3380
3504
|
C: (f, a) => f(...a)
|
|
3381
3505
|
});
|
|
3382
|
-
this._state =
|
|
3506
|
+
this._state = import_services8.SpaceState.ERROR;
|
|
3383
3507
|
(0, import_log8.log)("new state", {
|
|
3384
|
-
state:
|
|
3508
|
+
state: import_services8.SpaceState[this._state]
|
|
3385
3509
|
}, {
|
|
3386
3510
|
F: __dxlog_file11,
|
|
3387
|
-
L:
|
|
3511
|
+
L: 246,
|
|
3388
3512
|
S: this,
|
|
3389
3513
|
C: (f, a) => f(...a)
|
|
3390
3514
|
});
|
|
@@ -3396,15 +3520,15 @@ var DataSpace = class {
|
|
|
3396
3520
|
});
|
|
3397
3521
|
}
|
|
3398
3522
|
async initializeDataPipeline() {
|
|
3399
|
-
if (this._state !==
|
|
3523
|
+
if (this._state !== import_services8.SpaceState.CONTROL_ONLY) {
|
|
3400
3524
|
throw new import_protocols7.SystemError("Invalid operation");
|
|
3401
3525
|
}
|
|
3402
|
-
this._state =
|
|
3526
|
+
this._state = import_services8.SpaceState.INITIALIZING;
|
|
3403
3527
|
(0, import_log8.log)("new state", {
|
|
3404
|
-
state:
|
|
3528
|
+
state: import_services8.SpaceState[this._state]
|
|
3405
3529
|
}, {
|
|
3406
3530
|
F: __dxlog_file11,
|
|
3407
|
-
L:
|
|
3531
|
+
L: 262,
|
|
3408
3532
|
S: this,
|
|
3409
3533
|
C: (f, a) => f(...a)
|
|
3410
3534
|
});
|
|
@@ -3414,17 +3538,17 @@ var DataSpace = class {
|
|
|
3414
3538
|
await (0, import_context7.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
3415
3539
|
(0, import_log8.log)("data pipeline ready", void 0, {
|
|
3416
3540
|
F: __dxlog_file11,
|
|
3417
|
-
L:
|
|
3541
|
+
L: 274,
|
|
3418
3542
|
S: this,
|
|
3419
3543
|
C: (f, a) => f(...a)
|
|
3420
3544
|
});
|
|
3421
3545
|
await this._callbacks.beforeReady?.();
|
|
3422
|
-
this._state =
|
|
3546
|
+
this._state = import_services8.SpaceState.READY;
|
|
3423
3547
|
(0, import_log8.log)("new state", {
|
|
3424
|
-
state:
|
|
3548
|
+
state: import_services8.SpaceState[this._state]
|
|
3425
3549
|
}, {
|
|
3426
3550
|
F: __dxlog_file11,
|
|
3427
|
-
L:
|
|
3551
|
+
L: 278,
|
|
3428
3552
|
S: this,
|
|
3429
3553
|
C: (f, a) => f(...a)
|
|
3430
3554
|
});
|
|
@@ -3440,7 +3564,7 @@ var DataSpace = class {
|
|
|
3440
3564
|
await this._createWritableFeeds();
|
|
3441
3565
|
(0, import_log8.log)("writable feeds created", void 0, {
|
|
3442
3566
|
F: __dxlog_file11,
|
|
3443
|
-
L:
|
|
3567
|
+
L: 294,
|
|
3444
3568
|
S: this,
|
|
3445
3569
|
C: (f, a) => f(...a)
|
|
3446
3570
|
});
|
|
@@ -3467,7 +3591,7 @@ var DataSpace = class {
|
|
|
3467
3591
|
spaceKey: this.key,
|
|
3468
3592
|
deviceKey: this._signingContext.deviceKey,
|
|
3469
3593
|
identityKey: this._signingContext.identityKey,
|
|
3470
|
-
designation:
|
|
3594
|
+
designation: import_credentials10.AdmittedFeed.Designation.CONTROL
|
|
3471
3595
|
}
|
|
3472
3596
|
}));
|
|
3473
3597
|
}
|
|
@@ -3484,7 +3608,7 @@ var DataSpace = class {
|
|
|
3484
3608
|
spaceKey: this.key,
|
|
3485
3609
|
deviceKey: this._signingContext.deviceKey,
|
|
3486
3610
|
identityKey: this._signingContext.identityKey,
|
|
3487
|
-
designation:
|
|
3611
|
+
designation: import_credentials10.AdmittedFeed.Designation.DATA
|
|
3488
3612
|
}
|
|
3489
3613
|
}));
|
|
3490
3614
|
}
|
|
@@ -3503,12 +3627,12 @@ var DataSpace = class {
|
|
|
3503
3627
|
rootUrl
|
|
3504
3628
|
}, {
|
|
3505
3629
|
F: __dxlog_file11,
|
|
3506
|
-
L:
|
|
3630
|
+
L: 360,
|
|
3507
3631
|
S: this,
|
|
3508
3632
|
C: (f, a) => f(...a)
|
|
3509
3633
|
});
|
|
3510
|
-
this.
|
|
3511
|
-
const handle = this.
|
|
3634
|
+
this._echoHost.replicateDocument(rootUrl);
|
|
3635
|
+
const handle = this._echoHost.automergeRepo.find(rootUrl);
|
|
3512
3636
|
queueMicrotask(async () => {
|
|
3513
3637
|
try {
|
|
3514
3638
|
await (0, import_debug3.warnAfterTimeout)(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
@@ -3535,7 +3659,7 @@ var DataSpace = class {
|
|
|
3535
3659
|
err
|
|
3536
3660
|
}, {
|
|
3537
3661
|
F: __dxlog_file11,
|
|
3538
|
-
L:
|
|
3662
|
+
L: 383,
|
|
3539
3663
|
S: this,
|
|
3540
3664
|
C: (f, a) => f(...a)
|
|
3541
3665
|
});
|
|
@@ -3561,7 +3685,7 @@ var DataSpace = class {
|
|
|
3561
3685
|
let epoch;
|
|
3562
3686
|
switch (options?.migration) {
|
|
3563
3687
|
case void 0:
|
|
3564
|
-
case
|
|
3688
|
+
case import_services8.CreateEpochRequest.Migration.NONE:
|
|
3565
3689
|
{
|
|
3566
3690
|
epoch = {
|
|
3567
3691
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
@@ -3571,9 +3695,9 @@ var DataSpace = class {
|
|
|
3571
3695
|
};
|
|
3572
3696
|
}
|
|
3573
3697
|
break;
|
|
3574
|
-
case
|
|
3698
|
+
case import_services8.CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3575
3699
|
{
|
|
3576
|
-
const document = this.
|
|
3700
|
+
const document = this._echoHost.automergeRepo.create();
|
|
3577
3701
|
epoch = {
|
|
3578
3702
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
3579
3703
|
number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
|
|
@@ -3582,15 +3706,15 @@ var DataSpace = class {
|
|
|
3582
3706
|
};
|
|
3583
3707
|
}
|
|
3584
3708
|
break;
|
|
3585
|
-
case
|
|
3709
|
+
case import_services8.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
3586
3710
|
{
|
|
3587
3711
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3588
|
-
const rootHandle = this.
|
|
3712
|
+
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
3589
3713
|
await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3590
|
-
const newRoot = this.
|
|
3714
|
+
const newRoot = this._echoHost.automergeRepo.create(rootHandle.docSync());
|
|
3591
3715
|
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3592
3716
|
F: __dxlog_file11,
|
|
3593
|
-
L:
|
|
3717
|
+
L: 433,
|
|
3594
3718
|
S: this,
|
|
3595
3719
|
A: [
|
|
3596
3720
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
@@ -3605,23 +3729,23 @@ var DataSpace = class {
|
|
|
3605
3729
|
};
|
|
3606
3730
|
}
|
|
3607
3731
|
break;
|
|
3608
|
-
case
|
|
3732
|
+
case import_services8.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
3609
3733
|
{
|
|
3610
3734
|
import_log8.log.info("Fragmenting", void 0, {
|
|
3611
3735
|
F: __dxlog_file11,
|
|
3612
|
-
L:
|
|
3736
|
+
L: 445,
|
|
3613
3737
|
S: this,
|
|
3614
3738
|
C: (f, a) => f(...a)
|
|
3615
3739
|
});
|
|
3616
3740
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3617
|
-
const rootHandle = this.
|
|
3741
|
+
const rootHandle = this._echoHost.automergeRepo.find(currentRootUrl);
|
|
3618
3742
|
await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3619
3743
|
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3620
|
-
const properties = objects.find(([_, value]) => value.system.type?.itemId ===
|
|
3744
|
+
const properties = objects.find(([_, value]) => value.system.type?.itemId === import_echo_schema.TYPE_PROPERTIES);
|
|
3621
3745
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3622
3746
|
(0, import_invariant9.invariant)(properties, "Properties not found", {
|
|
3623
3747
|
F: __dxlog_file11,
|
|
3624
|
-
L:
|
|
3748
|
+
L: 455,
|
|
3625
3749
|
S: this,
|
|
3626
3750
|
A: [
|
|
3627
3751
|
"properties",
|
|
@@ -3634,17 +3758,17 @@ var DataSpace = class {
|
|
|
3634
3758
|
properties
|
|
3635
3759
|
])
|
|
3636
3760
|
};
|
|
3637
|
-
const newRoot = this.
|
|
3761
|
+
const newRoot = this._echoHost.automergeRepo.create(newSpaceDoc);
|
|
3638
3762
|
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3639
3763
|
F: __dxlog_file11,
|
|
3640
|
-
L:
|
|
3764
|
+
L: 460,
|
|
3641
3765
|
S: this,
|
|
3642
3766
|
A: [
|
|
3643
3767
|
"typeof newRoot.url === 'string' && newRoot.url.length > 0",
|
|
3644
3768
|
""
|
|
3645
3769
|
]
|
|
3646
3770
|
});
|
|
3647
|
-
const docLoader = new import_echo_pipeline3.AutomergeDocumentLoaderImpl(this.key, this.
|
|
3771
|
+
const docLoader = new import_echo_pipeline3.AutomergeDocumentLoaderImpl(this.key, this._echoHost.automergeRepo);
|
|
3648
3772
|
await docLoader.loadSpaceRootDocHandle(this._ctx, {
|
|
3649
3773
|
rootUrl: newRoot.url
|
|
3650
3774
|
});
|
|
@@ -3688,25 +3812,25 @@ var DataSpace = class {
|
|
|
3688
3812
|
]));
|
|
3689
3813
|
}
|
|
3690
3814
|
async activate() {
|
|
3691
|
-
if (this._state !==
|
|
3815
|
+
if (this._state !== import_services8.SpaceState.INACTIVE) {
|
|
3692
3816
|
return;
|
|
3693
3817
|
}
|
|
3694
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3818
|
+
await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.ACTIVE);
|
|
3695
3819
|
await this._open();
|
|
3696
3820
|
this.initializeDataPipelineAsync();
|
|
3697
3821
|
}
|
|
3698
3822
|
async deactivate() {
|
|
3699
|
-
if (this._state ===
|
|
3823
|
+
if (this._state === import_services8.SpaceState.INACTIVE) {
|
|
3700
3824
|
return;
|
|
3701
3825
|
}
|
|
3702
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3826
|
+
await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.INACTIVE);
|
|
3703
3827
|
await this._close();
|
|
3704
|
-
this._state =
|
|
3828
|
+
this._state = import_services8.SpaceState.INACTIVE;
|
|
3705
3829
|
(0, import_log8.log)("new state", {
|
|
3706
|
-
state:
|
|
3830
|
+
state: import_services8.SpaceState[this._state]
|
|
3707
3831
|
}, {
|
|
3708
3832
|
F: __dxlog_file11,
|
|
3709
|
-
L:
|
|
3833
|
+
L: 526,
|
|
3710
3834
|
S: this,
|
|
3711
3835
|
C: (f, a) => f(...a)
|
|
3712
3836
|
});
|
|
@@ -3721,7 +3845,7 @@ _ts_decorate4([
|
|
|
3721
3845
|
], DataSpace.prototype, "key", null);
|
|
3722
3846
|
_ts_decorate4([
|
|
3723
3847
|
import_tracing4.trace.info({
|
|
3724
|
-
enum:
|
|
3848
|
+
enum: import_services8.SpaceState
|
|
3725
3849
|
})
|
|
3726
3850
|
], DataSpace.prototype, "state", null);
|
|
3727
3851
|
_ts_decorate4([
|
|
@@ -3760,7 +3884,7 @@ DataSpace = _ts_decorate4([
|
|
|
3760
3884
|
], DataSpace);
|
|
3761
3885
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
3762
3886
|
const credentials = [
|
|
3763
|
-
await (0,
|
|
3887
|
+
await (0, import_credentials13.createCredential)({
|
|
3764
3888
|
signer: keyring,
|
|
3765
3889
|
issuer: space.key,
|
|
3766
3890
|
subject: space.key,
|
|
@@ -3769,14 +3893,14 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3769
3893
|
spaceKey: space.key
|
|
3770
3894
|
}
|
|
3771
3895
|
}),
|
|
3772
|
-
await (0,
|
|
3896
|
+
await (0, import_credentials13.createCredential)({
|
|
3773
3897
|
signer: keyring,
|
|
3774
3898
|
issuer: space.key,
|
|
3775
3899
|
subject: signingContext.identityKey,
|
|
3776
3900
|
assertion: {
|
|
3777
3901
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
3778
3902
|
spaceKey: space.key,
|
|
3779
|
-
role:
|
|
3903
|
+
role: import_credentials14.SpaceMember.Role.ADMIN,
|
|
3780
3904
|
profile: signingContext.getProfile(),
|
|
3781
3905
|
genesisFeedKey: space.controlFeedKey ?? (0, import_debug4.failUndefined)()
|
|
3782
3906
|
}
|
|
@@ -3788,7 +3912,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3788
3912
|
spaceKey: space.key,
|
|
3789
3913
|
identityKey: signingContext.identityKey,
|
|
3790
3914
|
deviceKey: signingContext.deviceKey,
|
|
3791
|
-
designation:
|
|
3915
|
+
designation: import_credentials14.AdmittedFeed.Designation.CONTROL
|
|
3792
3916
|
}
|
|
3793
3917
|
}),
|
|
3794
3918
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3798,7 +3922,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3798
3922
|
spaceKey: space.key,
|
|
3799
3923
|
identityKey: signingContext.identityKey,
|
|
3800
3924
|
deviceKey: signingContext.deviceKey,
|
|
3801
|
-
designation:
|
|
3925
|
+
designation: import_credentials14.AdmittedFeed.Designation.DATA
|
|
3802
3926
|
}
|
|
3803
3927
|
}),
|
|
3804
3928
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3836,18 +3960,19 @@ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
|
|
|
3836
3960
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3837
3961
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3838
3962
|
var DataSpaceManager = class {
|
|
3839
|
-
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore,
|
|
3963
|
+
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _echoHost, _invitationsManager, params) {
|
|
3840
3964
|
this._spaceManager = _spaceManager;
|
|
3841
3965
|
this._metadataStore = _metadataStore;
|
|
3842
3966
|
this._keyring = _keyring;
|
|
3843
3967
|
this._signingContext = _signingContext;
|
|
3844
3968
|
this._feedStore = _feedStore;
|
|
3845
|
-
this.
|
|
3969
|
+
this._echoHost = _echoHost;
|
|
3970
|
+
this._invitationsManager = _invitationsManager;
|
|
3846
3971
|
this._ctx = new import_context9.Context();
|
|
3847
3972
|
this.updated = new import_async13.Event();
|
|
3848
|
-
this._spaces = new import_util6.ComplexMap(
|
|
3973
|
+
this._spaces = new import_util6.ComplexMap(import_keys10.PublicKey.hash);
|
|
3849
3974
|
this._isOpen = false;
|
|
3850
|
-
this._instanceId =
|
|
3975
|
+
this._instanceId = import_keys10.PublicKey.random().toHex();
|
|
3851
3976
|
const { spaceMemberPresenceAnnounceInterval = PRESENCE_ANNOUNCE_INTERVAL, spaceMemberPresenceOfflineTimeout = PRESENCE_OFFLINE_TIMEOUT } = params ?? {};
|
|
3852
3977
|
this._spaceMemberPresenceAnnounceInterval = spaceMemberPresenceAnnounceInterval;
|
|
3853
3978
|
this._spaceMemberPresenceOfflineTimeout = spaceMemberPresenceOfflineTimeout;
|
|
@@ -3859,7 +3984,7 @@ var DataSpaceManager = class {
|
|
|
3859
3984
|
async open() {
|
|
3860
3985
|
(0, import_log10.log)("open", void 0, {
|
|
3861
3986
|
F: __dxlog_file12,
|
|
3862
|
-
L:
|
|
3987
|
+
L: 102,
|
|
3863
3988
|
S: this,
|
|
3864
3989
|
C: (f, a) => f(...a)
|
|
3865
3990
|
});
|
|
@@ -3867,7 +3992,7 @@ var DataSpaceManager = class {
|
|
|
3867
3992
|
id: this._instanceId
|
|
3868
3993
|
}), {
|
|
3869
3994
|
F: __dxlog_file12,
|
|
3870
|
-
L:
|
|
3995
|
+
L: 103,
|
|
3871
3996
|
S: this,
|
|
3872
3997
|
C: (f, a) => f(...a)
|
|
3873
3998
|
});
|
|
@@ -3875,7 +4000,7 @@ var DataSpaceManager = class {
|
|
|
3875
4000
|
spaces: this._metadataStore.spaces.length
|
|
3876
4001
|
}, {
|
|
3877
4002
|
F: __dxlog_file12,
|
|
3878
|
-
L:
|
|
4003
|
+
L: 104,
|
|
3879
4004
|
S: this,
|
|
3880
4005
|
C: (f, a) => f(...a)
|
|
3881
4006
|
});
|
|
@@ -3885,7 +4010,7 @@ var DataSpaceManager = class {
|
|
|
3885
4010
|
spaceMetadata
|
|
3886
4011
|
}, {
|
|
3887
4012
|
F: __dxlog_file12,
|
|
3888
|
-
L:
|
|
4013
|
+
L: 108,
|
|
3889
4014
|
S: this,
|
|
3890
4015
|
C: (f, a) => f(...a)
|
|
3891
4016
|
});
|
|
@@ -3896,7 +4021,7 @@ var DataSpaceManager = class {
|
|
|
3896
4021
|
err
|
|
3897
4022
|
}, {
|
|
3898
4023
|
F: __dxlog_file12,
|
|
3899
|
-
L:
|
|
4024
|
+
L: 111,
|
|
3900
4025
|
S: this,
|
|
3901
4026
|
C: (f, a) => f(...a)
|
|
3902
4027
|
});
|
|
@@ -3905,7 +4030,7 @@ var DataSpaceManager = class {
|
|
|
3905
4030
|
this._isOpen = true;
|
|
3906
4031
|
this.updated.emit();
|
|
3907
4032
|
for (const space of this._spaces.values()) {
|
|
3908
|
-
if (space.state !==
|
|
4033
|
+
if (space.state !== import_services9.SpaceState.INACTIVE) {
|
|
3909
4034
|
space.initializeDataPipelineAsync();
|
|
3910
4035
|
}
|
|
3911
4036
|
}
|
|
@@ -3913,7 +4038,7 @@ var DataSpaceManager = class {
|
|
|
3913
4038
|
id: this._instanceId
|
|
3914
4039
|
}), {
|
|
3915
4040
|
F: __dxlog_file12,
|
|
3916
|
-
L:
|
|
4041
|
+
L: 124,
|
|
3917
4042
|
S: this,
|
|
3918
4043
|
C: (f, a) => f(...a)
|
|
3919
4044
|
});
|
|
@@ -3921,7 +4046,7 @@ var DataSpaceManager = class {
|
|
|
3921
4046
|
async close() {
|
|
3922
4047
|
(0, import_log10.log)("close", void 0, {
|
|
3923
4048
|
F: __dxlog_file12,
|
|
3924
|
-
L:
|
|
4049
|
+
L: 129,
|
|
3925
4050
|
S: this,
|
|
3926
4051
|
C: (f, a) => f(...a)
|
|
3927
4052
|
});
|
|
@@ -3937,7 +4062,7 @@ var DataSpaceManager = class {
|
|
|
3937
4062
|
async createSpace() {
|
|
3938
4063
|
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3939
4064
|
F: __dxlog_file12,
|
|
3940
|
-
L:
|
|
4065
|
+
L: 142,
|
|
3941
4066
|
S: this,
|
|
3942
4067
|
A: [
|
|
3943
4068
|
"this._isOpen",
|
|
@@ -3952,27 +4077,22 @@ var DataSpaceManager = class {
|
|
|
3952
4077
|
genesisFeedKey: controlFeedKey,
|
|
3953
4078
|
controlFeedKey,
|
|
3954
4079
|
dataFeedKey,
|
|
3955
|
-
state:
|
|
4080
|
+
state: import_services9.SpaceState.ACTIVE
|
|
3956
4081
|
};
|
|
3957
4082
|
(0, import_log10.log)("creating space...", {
|
|
3958
4083
|
spaceKey
|
|
3959
4084
|
}, {
|
|
3960
4085
|
F: __dxlog_file12,
|
|
3961
|
-
L:
|
|
4086
|
+
L: 154,
|
|
3962
4087
|
S: this,
|
|
3963
4088
|
C: (f, a) => f(...a)
|
|
3964
4089
|
});
|
|
3965
|
-
const
|
|
3966
|
-
automergeRoot.change((doc) => {
|
|
3967
|
-
doc.access = {
|
|
3968
|
-
spaceKey: spaceKey.toHex()
|
|
3969
|
-
};
|
|
3970
|
-
});
|
|
4090
|
+
const automergeRootUrl = await this._echoHost.createSpaceRoot(spaceKey);
|
|
3971
4091
|
const space = await this._constructSpace(metadata);
|
|
3972
|
-
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner,
|
|
4092
|
+
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRootUrl);
|
|
3973
4093
|
await this._metadataStore.addSpace(metadata);
|
|
3974
4094
|
const memberCredential = credentials[1];
|
|
3975
|
-
(0, import_invariant11.invariant)((0,
|
|
4095
|
+
(0, import_invariant11.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3976
4096
|
F: __dxlog_file12,
|
|
3977
4097
|
L: 163,
|
|
3978
4098
|
S: this,
|
|
@@ -4034,7 +4154,7 @@ var DataSpaceManager = class {
|
|
|
4034
4154
|
async waitUntilSpaceReady(spaceKey) {
|
|
4035
4155
|
await (0, import_context9.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
4036
4156
|
const space = this._spaces.get(spaceKey);
|
|
4037
|
-
return !!space && space.state ===
|
|
4157
|
+
return !!space && space.state === import_services9.SpaceState.READY;
|
|
4038
4158
|
}));
|
|
4039
4159
|
}
|
|
4040
4160
|
async _constructSpace(metadata) {
|
|
@@ -4074,8 +4194,8 @@ var DataSpaceManager = class {
|
|
|
4074
4194
|
remotePeerId: session.remotePeerId
|
|
4075
4195
|
}));
|
|
4076
4196
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
4077
|
-
this.
|
|
4078
|
-
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());
|
|
4079
4199
|
},
|
|
4080
4200
|
onAuthFailure: () => {
|
|
4081
4201
|
import_log10.log.warn("auth failure", void 0, {
|
|
@@ -4085,18 +4205,22 @@ var DataSpaceManager = class {
|
|
|
4085
4205
|
C: (f, a) => f(...a)
|
|
4086
4206
|
});
|
|
4087
4207
|
},
|
|
4088
|
-
memberKey: this._signingContext.identityKey
|
|
4208
|
+
memberKey: this._signingContext.identityKey,
|
|
4209
|
+
onDelegatedInvitationStatusChange: (invitation, isActive) => {
|
|
4210
|
+
return this._handleInvitationStatusChange(dataSpace, invitation, isActive);
|
|
4211
|
+
}
|
|
4089
4212
|
});
|
|
4090
4213
|
controlFeed && await space.setControlFeed(controlFeed);
|
|
4091
4214
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
4092
4215
|
const dataSpace = new DataSpace({
|
|
4093
4216
|
inner: space,
|
|
4094
|
-
initialState: metadata.state ===
|
|
4217
|
+
initialState: metadata.state === import_services9.SpaceState.INACTIVE ? import_services9.SpaceState.INACTIVE : import_services9.SpaceState.CLOSED,
|
|
4095
4218
|
metadataStore: this._metadataStore,
|
|
4096
4219
|
gossip,
|
|
4097
4220
|
presence,
|
|
4098
4221
|
keyring: this._keyring,
|
|
4099
4222
|
feedStore: this._feedStore,
|
|
4223
|
+
echoHost: this._echoHost,
|
|
4100
4224
|
signingContext: this._signingContext,
|
|
4101
4225
|
callbacks: {
|
|
4102
4226
|
beforeReady: async () => {
|
|
@@ -4104,7 +4228,7 @@ var DataSpaceManager = class {
|
|
|
4104
4228
|
space: space.key
|
|
4105
4229
|
}, {
|
|
4106
4230
|
F: __dxlog_file12,
|
|
4107
|
-
L:
|
|
4231
|
+
L: 269,
|
|
4108
4232
|
S: this,
|
|
4109
4233
|
C: (f, a) => f(...a)
|
|
4110
4234
|
});
|
|
@@ -4115,11 +4239,14 @@ var DataSpaceManager = class {
|
|
|
4115
4239
|
open: this._isOpen
|
|
4116
4240
|
}, {
|
|
4117
4241
|
F: __dxlog_file12,
|
|
4118
|
-
L:
|
|
4242
|
+
L: 272,
|
|
4119
4243
|
S: this,
|
|
4120
4244
|
C: (f, a) => f(...a)
|
|
4121
4245
|
});
|
|
4122
4246
|
if (this._isOpen) {
|
|
4247
|
+
await this._createDelegatedInvitations(dataSpace, [
|
|
4248
|
+
...space.spaceState.invitations.entries()
|
|
4249
|
+
]);
|
|
4123
4250
|
this.updated.emit();
|
|
4124
4251
|
}
|
|
4125
4252
|
},
|
|
@@ -4128,16 +4255,15 @@ var DataSpaceManager = class {
|
|
|
4128
4255
|
space: space.key
|
|
4129
4256
|
}, {
|
|
4130
4257
|
F: __dxlog_file12,
|
|
4131
|
-
L:
|
|
4258
|
+
L: 279,
|
|
4132
4259
|
S: this,
|
|
4133
4260
|
C: (f, a) => f(...a)
|
|
4134
4261
|
});
|
|
4135
4262
|
}
|
|
4136
4263
|
},
|
|
4137
|
-
cache: metadata.cache
|
|
4138
|
-
automergeHost: this._automergeHost
|
|
4264
|
+
cache: metadata.cache
|
|
4139
4265
|
});
|
|
4140
|
-
if (metadata.state !==
|
|
4266
|
+
if (metadata.state !== import_services9.SpaceState.INACTIVE) {
|
|
4141
4267
|
await dataSpace.open();
|
|
4142
4268
|
}
|
|
4143
4269
|
if (metadata.controlTimeframe) {
|
|
@@ -4146,6 +4272,41 @@ var DataSpaceManager = class {
|
|
|
4146
4272
|
this._spaces.set(metadata.key, dataSpace);
|
|
4147
4273
|
return dataSpace;
|
|
4148
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
|
+
}
|
|
4149
4310
|
};
|
|
4150
4311
|
_ts_decorate5([
|
|
4151
4312
|
import_async13.synchronized
|
|
@@ -4182,10 +4343,10 @@ var SpacesServiceImpl = class {
|
|
|
4182
4343
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4183
4344
|
if (state) {
|
|
4184
4345
|
switch (state) {
|
|
4185
|
-
case
|
|
4346
|
+
case import_services10.SpaceState.ACTIVE:
|
|
4186
4347
|
await space.activate();
|
|
4187
4348
|
break;
|
|
4188
|
-
case
|
|
4349
|
+
case import_services10.SpaceState.INACTIVE:
|
|
4189
4350
|
await space.deactivate();
|
|
4190
4351
|
break;
|
|
4191
4352
|
default:
|
|
@@ -4359,7 +4520,7 @@ var SpacesServiceImpl = class {
|
|
|
4359
4520
|
identityKey: member.key,
|
|
4360
4521
|
profile: member.profile ?? {}
|
|
4361
4522
|
},
|
|
4362
|
-
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,
|
|
4363
4524
|
peerStates: peers
|
|
4364
4525
|
};
|
|
4365
4526
|
}),
|
|
@@ -4370,80 +4531,6 @@ var SpacesServiceImpl = class {
|
|
|
4370
4531
|
}
|
|
4371
4532
|
};
|
|
4372
4533
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
4373
|
-
var createSelectedDocumentsIterator = (automergeHost) => (
|
|
4374
|
-
/**
|
|
4375
|
-
* Get object data blobs from Automerge Repo by ids.
|
|
4376
|
-
* @param ids
|
|
4377
|
-
*/
|
|
4378
|
-
// TODO(mykola): Unload automerge handles after usage.
|
|
4379
|
-
async function* loadDocuments(ids) {
|
|
4380
|
-
for (const id of ids) {
|
|
4381
|
-
const { documentId, objectId } = import_protocols12.idCodec.decode(id);
|
|
4382
|
-
const handle = automergeHost.repo.find(documentId);
|
|
4383
|
-
await (0, import_debug7.warnAfterTimeout)(5e3, "to long to load doc", () => handle.whenReady());
|
|
4384
|
-
const doc = handle.docSync();
|
|
4385
|
-
const hash = (0, import_automerge.getHeads)(doc).join("");
|
|
4386
|
-
yield doc.objects?.[objectId] ? [
|
|
4387
|
-
{
|
|
4388
|
-
id,
|
|
4389
|
-
object: doc.objects[objectId],
|
|
4390
|
-
currentHash: hash
|
|
4391
|
-
}
|
|
4392
|
-
] : [];
|
|
4393
|
-
}
|
|
4394
|
-
}
|
|
4395
|
-
);
|
|
4396
|
-
var createDocumentsIterator = (automergeHost) => (
|
|
4397
|
-
/**
|
|
4398
|
-
* Recursively get all object data blobs from Automerge Repo.
|
|
4399
|
-
* @param ids
|
|
4400
|
-
*/
|
|
4401
|
-
// TODO(mykola): Unload automerge handles after usage.
|
|
4402
|
-
async function* getAllDocuments() {
|
|
4403
|
-
const visited = /* @__PURE__ */ new Set();
|
|
4404
|
-
async function* getObjectsFromHandle(handle) {
|
|
4405
|
-
if (visited.has(handle.documentId)) {
|
|
4406
|
-
return;
|
|
4407
|
-
}
|
|
4408
|
-
await (0, import_debug7.warnAfterTimeout)(5e3, "to long to load doc", () => handle.whenReady());
|
|
4409
|
-
const doc = handle.docSync();
|
|
4410
|
-
const heads = (0, import_automerge.getHeads)(doc);
|
|
4411
|
-
if (doc.objects) {
|
|
4412
|
-
yield Object.entries(doc.objects).map(([objectId, object]) => {
|
|
4413
|
-
return {
|
|
4414
|
-
id: import_protocols12.idCodec.encode({
|
|
4415
|
-
documentId: handle.documentId,
|
|
4416
|
-
objectId
|
|
4417
|
-
}),
|
|
4418
|
-
object,
|
|
4419
|
-
currentHash: heads.join("")
|
|
4420
|
-
};
|
|
4421
|
-
});
|
|
4422
|
-
}
|
|
4423
|
-
if (doc.links) {
|
|
4424
|
-
for (const id of Object.values(doc.links)) {
|
|
4425
|
-
if (visited.has(id)) {
|
|
4426
|
-
continue;
|
|
4427
|
-
}
|
|
4428
|
-
const linkHandle = automergeHost.repo.find(id);
|
|
4429
|
-
for await (const result of getObjectsFromHandle(linkHandle)) {
|
|
4430
|
-
yield result;
|
|
4431
|
-
}
|
|
4432
|
-
}
|
|
4433
|
-
}
|
|
4434
|
-
visited.add(handle.documentId);
|
|
4435
|
-
}
|
|
4436
|
-
for (const handle of Object.values(automergeHost.repo.handles)) {
|
|
4437
|
-
if (visited.has(handle.documentId)) {
|
|
4438
|
-
continue;
|
|
4439
|
-
}
|
|
4440
|
-
for await (const result of getObjectsFromHandle(handle)) {
|
|
4441
|
-
yield result;
|
|
4442
|
-
}
|
|
4443
|
-
visited.add(handle.documentId);
|
|
4444
|
-
}
|
|
4445
|
-
}
|
|
4446
|
-
);
|
|
4447
4534
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
4448
4535
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4449
4536
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -4465,7 +4552,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4465
4552
|
this._runtimeParams = _runtimeParams;
|
|
4466
4553
|
this.initialized = new import_async15.Trigger();
|
|
4467
4554
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4468
|
-
this._instanceId =
|
|
4555
|
+
this._instanceId = import_keys11.PublicKey.random().toHex();
|
|
4469
4556
|
this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
|
|
4470
4557
|
this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
|
|
4471
4558
|
this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
|
|
@@ -4488,33 +4575,19 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4488
4575
|
snapshotStore: this.snapshotStore
|
|
4489
4576
|
});
|
|
4490
4577
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
|
|
4491
|
-
this.
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
this.automergeHost = new import_echo_pipeline4.AutomergeHost({
|
|
4495
|
-
directory: storage.createDirectory("automerge"),
|
|
4496
|
-
db: level.sublevel("automerge"),
|
|
4497
|
-
storageCallbacks: (0, import_indexing.createStorageCallbacks)({
|
|
4498
|
-
host: () => this.automergeHost,
|
|
4499
|
-
metadata: this.indexMetadata
|
|
4500
|
-
})
|
|
4501
|
-
});
|
|
4502
|
-
this.indexer = new import_indexing.Indexer({
|
|
4503
|
-
indexStore: new import_indexing.IndexStore({
|
|
4504
|
-
db: level.sublevel("index-storage")
|
|
4505
|
-
}),
|
|
4506
|
-
metadataStore: this.indexMetadata,
|
|
4507
|
-
loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
|
|
4508
|
-
getAllDocuments: createDocumentsIterator(this.automergeHost)
|
|
4578
|
+
this.echoHost = new import_echo_db.EchoHost({
|
|
4579
|
+
kv: this.level,
|
|
4580
|
+
storage: this.storage
|
|
4509
4581
|
});
|
|
4510
4582
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4511
|
-
this.
|
|
4583
|
+
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
4584
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
4512
4585
|
}
|
|
4513
4586
|
async _open(ctx) {
|
|
4514
4587
|
await this._checkStorageVersion();
|
|
4515
4588
|
(0, import_log12.log)("opening...", void 0, {
|
|
4516
4589
|
F: __dxlog_file14,
|
|
4517
|
-
L:
|
|
4590
|
+
L: 151,
|
|
4518
4591
|
S: this,
|
|
4519
4592
|
C: (f, a) => f(...a)
|
|
4520
4593
|
});
|
|
@@ -4522,56 +4595,64 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4522
4595
|
id: this._instanceId
|
|
4523
4596
|
}), {
|
|
4524
4597
|
F: __dxlog_file14,
|
|
4525
|
-
L:
|
|
4598
|
+
L: 152,
|
|
4526
4599
|
S: this,
|
|
4527
4600
|
C: (f, a) => f(...a)
|
|
4528
4601
|
});
|
|
4529
4602
|
await this.signalManager.open();
|
|
4530
4603
|
await this.networkManager.open();
|
|
4531
|
-
await this.
|
|
4604
|
+
await this.echoHost.open(ctx);
|
|
4532
4605
|
await this.metadataStore.load();
|
|
4533
4606
|
await this.spaceManager.open();
|
|
4534
4607
|
await this.identityManager.open(ctx);
|
|
4535
4608
|
if (this.identityManager.identity) {
|
|
4536
4609
|
await this._initialize(ctx);
|
|
4537
4610
|
}
|
|
4611
|
+
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
4612
|
+
(0, import_log12.log)("loaded persistent invitations", {
|
|
4613
|
+
count: loadedInvitations.invitations?.length
|
|
4614
|
+
}, {
|
|
4615
|
+
F: __dxlog_file14,
|
|
4616
|
+
L: 165,
|
|
4617
|
+
S: this,
|
|
4618
|
+
C: (f, a) => f(...a)
|
|
4619
|
+
});
|
|
4538
4620
|
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.end({
|
|
4539
4621
|
id: this._instanceId
|
|
4540
4622
|
}), {
|
|
4541
4623
|
F: __dxlog_file14,
|
|
4542
|
-
L:
|
|
4624
|
+
L: 167,
|
|
4543
4625
|
S: this,
|
|
4544
4626
|
C: (f, a) => f(...a)
|
|
4545
4627
|
});
|
|
4546
4628
|
(0, import_log12.log)("opened", void 0, {
|
|
4547
4629
|
F: __dxlog_file14,
|
|
4548
|
-
L:
|
|
4630
|
+
L: 168,
|
|
4549
4631
|
S: this,
|
|
4550
4632
|
C: (f, a) => f(...a)
|
|
4551
4633
|
});
|
|
4552
4634
|
}
|
|
4553
|
-
async _close() {
|
|
4635
|
+
async _close(ctx) {
|
|
4554
4636
|
(0, import_log12.log)("closing...", void 0, {
|
|
4555
4637
|
F: __dxlog_file14,
|
|
4556
|
-
L:
|
|
4638
|
+
L: 172,
|
|
4557
4639
|
S: this,
|
|
4558
4640
|
C: (f, a) => f(...a)
|
|
4559
4641
|
});
|
|
4560
4642
|
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
4561
4643
|
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
4562
4644
|
}
|
|
4563
|
-
await this.automergeHost.close();
|
|
4564
4645
|
await this.dataSpaceManager?.close();
|
|
4565
4646
|
await this.identityManager.close();
|
|
4566
4647
|
await this.spaceManager.close();
|
|
4567
4648
|
await this.feedStore.close();
|
|
4649
|
+
await this.metadataStore.close();
|
|
4650
|
+
await this.echoHost.close(ctx);
|
|
4568
4651
|
await this.networkManager.close();
|
|
4569
4652
|
await this.signalManager.close();
|
|
4570
|
-
await this.metadataStore.close();
|
|
4571
|
-
await this.indexer.destroy();
|
|
4572
4653
|
(0, import_log12.log)("closed", void 0, {
|
|
4573
4654
|
F: __dxlog_file14,
|
|
4574
|
-
L:
|
|
4655
|
+
L: 184,
|
|
4575
4656
|
S: this,
|
|
4576
4657
|
C: (f, a) => f(...a)
|
|
4577
4658
|
});
|
|
@@ -4585,7 +4666,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4585
4666
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4586
4667
|
(0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4587
4668
|
F: __dxlog_file14,
|
|
4588
|
-
L:
|
|
4669
|
+
L: 195,
|
|
4589
4670
|
S: this,
|
|
4590
4671
|
A: [
|
|
4591
4672
|
"factory",
|
|
@@ -4617,7 +4698,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4617
4698
|
async _initialize(ctx) {
|
|
4618
4699
|
(0, import_log12.log)("initializing spaces...", void 0, {
|
|
4619
4700
|
F: __dxlog_file14,
|
|
4620
|
-
L:
|
|
4701
|
+
L: 226,
|
|
4621
4702
|
S: this,
|
|
4622
4703
|
C: (f, a) => f(...a)
|
|
4623
4704
|
});
|
|
@@ -4635,12 +4716,12 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4635
4716
|
});
|
|
4636
4717
|
}
|
|
4637
4718
|
};
|
|
4638
|
-
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);
|
|
4639
4720
|
await this.dataSpaceManager.open();
|
|
4640
|
-
this._handlerFactories.set(
|
|
4721
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.SPACE, (invitation) => {
|
|
4641
4722
|
(0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4642
4723
|
F: __dxlog_file14,
|
|
4643
|
-
L:
|
|
4724
|
+
L: 251,
|
|
4644
4725
|
S: this,
|
|
4645
4726
|
A: [
|
|
4646
4727
|
"this.dataSpaceManager",
|
|
@@ -4652,7 +4733,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4652
4733
|
this.initialized.wake();
|
|
4653
4734
|
this._deviceSpaceSync = {
|
|
4654
4735
|
processCredential: async (credential) => {
|
|
4655
|
-
const assertion = (0,
|
|
4736
|
+
const assertion = (0, import_credentials15.getCredentialAssertion)(credential);
|
|
4656
4737
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
4657
4738
|
return;
|
|
4658
4739
|
}
|
|
@@ -4664,7 +4745,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4664
4745
|
details: assertion
|
|
4665
4746
|
}, {
|
|
4666
4747
|
F: __dxlog_file14,
|
|
4667
|
-
L:
|
|
4748
|
+
L: 267,
|
|
4668
4749
|
S: this,
|
|
4669
4750
|
C: (f, a) => f(...a)
|
|
4670
4751
|
});
|
|
@@ -4675,7 +4756,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4675
4756
|
details: assertion
|
|
4676
4757
|
}, {
|
|
4677
4758
|
F: __dxlog_file14,
|
|
4678
|
-
L:
|
|
4759
|
+
L: 271,
|
|
4679
4760
|
S: this,
|
|
4680
4761
|
C: (f, a) => f(...a)
|
|
4681
4762
|
});
|
|
@@ -4686,7 +4767,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4686
4767
|
details: assertion
|
|
4687
4768
|
}, {
|
|
4688
4769
|
F: __dxlog_file14,
|
|
4689
|
-
L:
|
|
4770
|
+
L: 276,
|
|
4690
4771
|
S: this,
|
|
4691
4772
|
C: (f, a) => f(...a)
|
|
4692
4773
|
});
|
|
@@ -4697,7 +4778,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4697
4778
|
} catch (err) {
|
|
4698
4779
|
import_log12.log.catch(err, void 0, {
|
|
4699
4780
|
F: __dxlog_file14,
|
|
4700
|
-
L:
|
|
4781
|
+
L: 282,
|
|
4701
4782
|
S: this,
|
|
4702
4783
|
C: (f, a) => f(...a)
|
|
4703
4784
|
});
|
|
@@ -4739,26 +4820,26 @@ var ServiceRegistry = class {
|
|
|
4739
4820
|
delete this._handlers[name];
|
|
4740
4821
|
}
|
|
4741
4822
|
};
|
|
4742
|
-
var DXOS_VERSION = "0.4.10-main.
|
|
4823
|
+
var DXOS_VERSION = "0.4.10-main.c685d5c";
|
|
4743
4824
|
var getPlatform = () => {
|
|
4744
4825
|
if (process.browser) {
|
|
4745
4826
|
if (typeof window !== "undefined") {
|
|
4746
4827
|
const { userAgent } = window.navigator;
|
|
4747
4828
|
return {
|
|
4748
|
-
type:
|
|
4829
|
+
type: import_services13.Platform.PLATFORM_TYPE.BROWSER,
|
|
4749
4830
|
userAgent,
|
|
4750
4831
|
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
4751
4832
|
};
|
|
4752
4833
|
} else {
|
|
4753
4834
|
return {
|
|
4754
|
-
type:
|
|
4835
|
+
type: import_services13.Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
4755
4836
|
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
4756
4837
|
};
|
|
4757
4838
|
}
|
|
4758
4839
|
} else {
|
|
4759
4840
|
const { platform: platform2, version, arch } = process;
|
|
4760
4841
|
return {
|
|
4761
|
-
type:
|
|
4842
|
+
type: import_services13.Platform.PLATFORM_TYPE.NODE,
|
|
4762
4843
|
platform: platform2,
|
|
4763
4844
|
arch,
|
|
4764
4845
|
runtime: version,
|
|
@@ -4776,7 +4857,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
|
4776
4857
|
client: {
|
|
4777
4858
|
version: DXOS_VERSION,
|
|
4778
4859
|
storage: {
|
|
4779
|
-
version:
|
|
4860
|
+
version: import_protocols12.STORAGE_VERSION
|
|
4780
4861
|
}
|
|
4781
4862
|
},
|
|
4782
4863
|
trace: import_tracing6.TRACE_PROCESSOR.getDiagnostics()
|
|
@@ -4845,7 +4926,7 @@ var getSpaceStats = async (space) => {
|
|
|
4845
4926
|
const stats = {
|
|
4846
4927
|
key: space.key,
|
|
4847
4928
|
metrics: space.metrics,
|
|
4848
|
-
epochs: space.inner.spaceState.credentials.filter((0,
|
|
4929
|
+
epochs: space.inner.spaceState.credentials.filter((0, import_credentials16.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
4849
4930
|
...credential.subject.assertion,
|
|
4850
4931
|
id: credential.id
|
|
4851
4932
|
})),
|
|
@@ -4856,7 +4937,7 @@ var getSpaceStats = async (space) => {
|
|
|
4856
4937
|
displayName: member.assertion.profile?.displayName
|
|
4857
4938
|
}
|
|
4858
4939
|
},
|
|
4859
|
-
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
|
|
4860
4941
|
})),
|
|
4861
4942
|
pipeline: {
|
|
4862
4943
|
// TODO(burdon): Pick properties from credentials if needed.
|
|
@@ -4920,9 +5001,9 @@ var DevicesServiceImpl = class {
|
|
|
4920
5001
|
const peerState = peers.find((peer) => peer.identityKey.equals(key));
|
|
4921
5002
|
return {
|
|
4922
5003
|
deviceKey: key,
|
|
4923
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ?
|
|
5004
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services16.DeviceKind.CURRENT : import_services16.DeviceKind.TRUSTED,
|
|
4924
5005
|
profile,
|
|
4925
|
-
presence: isMe ?
|
|
5006
|
+
presence: isMe ? import_services16.Device.PresenceState.ONLINE : peerState ? import_services16.Device.PresenceState.ONLINE : import_services16.Device.PresenceState.OFFLINE
|
|
4926
5007
|
};
|
|
4927
5008
|
})
|
|
4928
5009
|
});
|
|
@@ -5021,7 +5102,7 @@ var LoggingServiceImpl = class {
|
|
|
5021
5102
|
constructor() {
|
|
5022
5103
|
this._logs = new import_async18.Event();
|
|
5023
5104
|
this._started = Date.now();
|
|
5024
|
-
this._sessionId =
|
|
5105
|
+
this._sessionId = import_keys13.PublicKey.random().toHex();
|
|
5025
5106
|
this._logProcessor = (_config, entry2) => {
|
|
5026
5107
|
this._logs.emit(entry2);
|
|
5027
5108
|
};
|
|
@@ -5118,16 +5199,16 @@ var LoggingServiceImpl = class {
|
|
|
5118
5199
|
};
|
|
5119
5200
|
var matchFilter = (filter, level, path2, options) => {
|
|
5120
5201
|
switch (options) {
|
|
5121
|
-
case
|
|
5202
|
+
case import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
5122
5203
|
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5123
|
-
case
|
|
5204
|
+
case import_services17.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
5124
5205
|
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5125
5206
|
}
|
|
5126
5207
|
};
|
|
5127
5208
|
var shouldLog = (entry2, request) => {
|
|
5128
|
-
const options = request.options ??
|
|
5209
|
+
const options = request.options ?? import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5129
5210
|
if (request.filters === void 0) {
|
|
5130
|
-
return options ===
|
|
5211
|
+
return options === import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5131
5212
|
} else {
|
|
5132
5213
|
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
5133
5214
|
}
|
|
@@ -5164,7 +5245,7 @@ var NetworkServiceImpl = class {
|
|
|
5164
5245
|
}
|
|
5165
5246
|
};
|
|
5166
5247
|
var getRootPath = (config) => {
|
|
5167
|
-
const { dataRoot = (0, import_util11.isNode)() ?
|
|
5248
|
+
const { dataRoot = (0, import_util11.isNode)() ? import_client_protocol6.DX_DATA : "dxos/storage" } = config ?? {};
|
|
5168
5249
|
return `${dataRoot}/`;
|
|
5169
5250
|
};
|
|
5170
5251
|
var isPersistent = (config) => {
|
|
@@ -5175,16 +5256,16 @@ var StorageDriver = import_config2.Runtime.Client.Storage.StorageDriver;
|
|
|
5175
5256
|
var createStorageObjects = (config) => {
|
|
5176
5257
|
const { persistent = false, keyStore, dataStore } = config ?? {};
|
|
5177
5258
|
if (persistent && dataStore === StorageDriver.RAM) {
|
|
5178
|
-
throw new
|
|
5259
|
+
throw new import_protocols14.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
5179
5260
|
}
|
|
5180
5261
|
if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
|
|
5181
|
-
throw new
|
|
5262
|
+
throw new import_protocols14.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
5182
5263
|
}
|
|
5183
5264
|
if (persistent && keyStore === StorageDriver.RAM) {
|
|
5184
|
-
throw new
|
|
5265
|
+
throw new import_protocols14.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
5185
5266
|
}
|
|
5186
5267
|
if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
|
|
5187
|
-
throw new
|
|
5268
|
+
throw new import_protocols14.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
5188
5269
|
}
|
|
5189
5270
|
return {
|
|
5190
5271
|
storage: (0, import_random_access_storage.createStorage)({
|
|
@@ -5215,7 +5296,7 @@ var toStorageType = (type) => {
|
|
|
5215
5296
|
};
|
|
5216
5297
|
var createLevel = async (config) => {
|
|
5217
5298
|
const persistent = isPersistent(config);
|
|
5218
|
-
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()}`;
|
|
5219
5300
|
const level = new import_level.Level(storagePath);
|
|
5220
5301
|
await level.open();
|
|
5221
5302
|
return level;
|
|
@@ -5240,8 +5321,8 @@ var SystemServiceImpl = class {
|
|
|
5240
5321
|
return {
|
|
5241
5322
|
timestamp: /* @__PURE__ */ new Date(),
|
|
5242
5323
|
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util12.jsonKeyReplacer)({
|
|
5243
|
-
truncate: keys ===
|
|
5244
|
-
humanize: keys ===
|
|
5324
|
+
truncate: keys === import_services18.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
5325
|
+
humanize: keys === import_services18.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
5245
5326
|
})))
|
|
5246
5327
|
};
|
|
5247
5328
|
}
|
|
@@ -5324,14 +5405,14 @@ var ClientServicesHost = class {
|
|
|
5324
5405
|
this._systemService = new SystemServiceImpl({
|
|
5325
5406
|
config: () => this._config,
|
|
5326
5407
|
statusUpdate: this._statusUpdate,
|
|
5327
|
-
getCurrentStatus: () => this.isOpen ?
|
|
5408
|
+
getCurrentStatus: () => this.isOpen ? import_services15.SystemStatus.ACTIVE : import_services15.SystemStatus.INACTIVE,
|
|
5328
5409
|
getDiagnostics: () => {
|
|
5329
5410
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
5330
5411
|
},
|
|
5331
5412
|
onUpdateStatus: async (status) => {
|
|
5332
|
-
if (!this.isOpen && status ===
|
|
5413
|
+
if (!this.isOpen && status === import_services15.SystemStatus.ACTIVE) {
|
|
5333
5414
|
await this._resourceLock?.acquire();
|
|
5334
|
-
} else if (this.isOpen && status ===
|
|
5415
|
+
} else if (this.isOpen && status === import_services15.SystemStatus.INACTIVE) {
|
|
5335
5416
|
await this._resourceLock?.release();
|
|
5336
5417
|
}
|
|
5337
5418
|
},
|
|
@@ -5341,7 +5422,7 @@ var ClientServicesHost = class {
|
|
|
5341
5422
|
});
|
|
5342
5423
|
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
5343
5424
|
this._loggingService = new LoggingServiceImpl();
|
|
5344
|
-
this._serviceRegistry = new ServiceRegistry(
|
|
5425
|
+
this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
|
|
5345
5426
|
SystemService: this._systemService,
|
|
5346
5427
|
TracingService: this._tracingService
|
|
5347
5428
|
});
|
|
@@ -5372,7 +5453,7 @@ var ClientServicesHost = class {
|
|
|
5372
5453
|
initialize({ config, ...options }) {
|
|
5373
5454
|
(0, import_invariant15.invariant)(!this._open, "service host is open", {
|
|
5374
5455
|
F: __dxlog_file18,
|
|
5375
|
-
L:
|
|
5456
|
+
L: 190,
|
|
5376
5457
|
S: this,
|
|
5377
5458
|
A: [
|
|
5378
5459
|
"!this._open",
|
|
@@ -5381,14 +5462,14 @@ var ClientServicesHost = class {
|
|
|
5381
5462
|
});
|
|
5382
5463
|
(0, import_log13.log)("initializing...", void 0, {
|
|
5383
5464
|
F: __dxlog_file18,
|
|
5384
|
-
L:
|
|
5465
|
+
L: 191,
|
|
5385
5466
|
S: this,
|
|
5386
5467
|
C: (f, a) => f(...a)
|
|
5387
5468
|
});
|
|
5388
5469
|
if (config) {
|
|
5389
5470
|
(0, import_invariant15.invariant)(!this._config, "config already set", {
|
|
5390
5471
|
F: __dxlog_file18,
|
|
5391
|
-
L:
|
|
5472
|
+
L: 194,
|
|
5392
5473
|
S: this,
|
|
5393
5474
|
A: [
|
|
5394
5475
|
"!this._config",
|
|
@@ -5403,7 +5484,7 @@ var ClientServicesHost = class {
|
|
|
5403
5484
|
if (!options.signalManager) {
|
|
5404
5485
|
import_log13.log.warn("running signaling without telemetry metadata.", void 0, {
|
|
5405
5486
|
F: __dxlog_file18,
|
|
5406
|
-
L:
|
|
5487
|
+
L: 202,
|
|
5407
5488
|
S: this,
|
|
5408
5489
|
C: (f, a) => f(...a)
|
|
5409
5490
|
});
|
|
@@ -5414,7 +5495,7 @@ var ClientServicesHost = class {
|
|
|
5414
5495
|
this._signalManager = signalManager;
|
|
5415
5496
|
(0, import_invariant15.invariant)(!this._networkManager, "network manager already set", {
|
|
5416
5497
|
F: __dxlog_file18,
|
|
5417
|
-
L:
|
|
5498
|
+
L: 213,
|
|
5418
5499
|
S: this,
|
|
5419
5500
|
A: [
|
|
5420
5501
|
"!this._networkManager",
|
|
@@ -5428,7 +5509,7 @@ var ClientServicesHost = class {
|
|
|
5428
5509
|
});
|
|
5429
5510
|
(0, import_log13.log)("initialized", void 0, {
|
|
5430
5511
|
F: __dxlog_file18,
|
|
5431
|
-
L:
|
|
5512
|
+
L: 220,
|
|
5432
5513
|
S: this,
|
|
5433
5514
|
C: (f, a) => f(...a)
|
|
5434
5515
|
});
|
|
@@ -5437,18 +5518,18 @@ var ClientServicesHost = class {
|
|
|
5437
5518
|
if (this._open) {
|
|
5438
5519
|
return;
|
|
5439
5520
|
}
|
|
5440
|
-
const traceId =
|
|
5441
|
-
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({
|
|
5442
5523
|
id: traceId
|
|
5443
5524
|
}), {
|
|
5444
5525
|
F: __dxlog_file18,
|
|
5445
|
-
L:
|
|
5526
|
+
L: 231,
|
|
5446
5527
|
S: this,
|
|
5447
5528
|
C: (f, a) => f(...a)
|
|
5448
5529
|
});
|
|
5449
5530
|
(0, import_invariant15.invariant)(this._config, "config not set", {
|
|
5450
5531
|
F: __dxlog_file18,
|
|
5451
|
-
L:
|
|
5532
|
+
L: 233,
|
|
5452
5533
|
S: this,
|
|
5453
5534
|
A: [
|
|
5454
5535
|
"this._config",
|
|
@@ -5457,7 +5538,7 @@ var ClientServicesHost = class {
|
|
|
5457
5538
|
});
|
|
5458
5539
|
(0, import_invariant15.invariant)(this._storage, "storage not set", {
|
|
5459
5540
|
F: __dxlog_file18,
|
|
5460
|
-
L:
|
|
5541
|
+
L: 234,
|
|
5461
5542
|
S: this,
|
|
5462
5543
|
A: [
|
|
5463
5544
|
"this._storage",
|
|
@@ -5466,7 +5547,7 @@ var ClientServicesHost = class {
|
|
|
5466
5547
|
});
|
|
5467
5548
|
(0, import_invariant15.invariant)(this._signalManager, "signal manager not set", {
|
|
5468
5549
|
F: __dxlog_file18,
|
|
5469
|
-
L:
|
|
5550
|
+
L: 235,
|
|
5470
5551
|
S: this,
|
|
5471
5552
|
A: [
|
|
5472
5553
|
"this._signalManager",
|
|
@@ -5475,7 +5556,7 @@ var ClientServicesHost = class {
|
|
|
5475
5556
|
});
|
|
5476
5557
|
(0, import_invariant15.invariant)(this._networkManager, "network manager not set", {
|
|
5477
5558
|
F: __dxlog_file18,
|
|
5478
|
-
L:
|
|
5559
|
+
L: 236,
|
|
5479
5560
|
S: this,
|
|
5480
5561
|
A: [
|
|
5481
5562
|
"this._networkManager",
|
|
@@ -5487,7 +5568,7 @@ var ClientServicesHost = class {
|
|
|
5487
5568
|
lockKey: this._resourceLock?.lockKey
|
|
5488
5569
|
}, {
|
|
5489
5570
|
F: __dxlog_file18,
|
|
5490
|
-
L:
|
|
5571
|
+
L: 239,
|
|
5491
5572
|
S: this,
|
|
5492
5573
|
C: (f, a) => f(...a)
|
|
5493
5574
|
});
|
|
@@ -5501,17 +5582,14 @@ var ClientServicesHost = class {
|
|
|
5501
5582
|
this._serviceRegistry.setServices({
|
|
5502
5583
|
SystemService: this._systemService,
|
|
5503
5584
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
5504
|
-
InvitationsService: new InvitationsServiceImpl(this._serviceContext.
|
|
5585
|
+
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
|
|
5505
5586
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
5506
5587
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
|
|
5507
5588
|
await this._serviceContext.initialized.wait();
|
|
5508
5589
|
return this._serviceContext.dataSpaceManager;
|
|
5509
5590
|
}),
|
|
5510
|
-
DataService:
|
|
5511
|
-
|
|
5512
|
-
indexer: this._serviceContext.indexer,
|
|
5513
|
-
automergeHost: this._serviceContext.automergeHost
|
|
5514
|
-
}),
|
|
5591
|
+
DataService: this._serviceContext.echoHost.dataService,
|
|
5592
|
+
QueryService: this._serviceContext.echoHost.queryService,
|
|
5515
5593
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
5516
5594
|
LoggingService: this._loggingService,
|
|
5517
5595
|
TracingService: this._tracingService,
|
|
@@ -5523,30 +5601,12 @@ var ClientServicesHost = class {
|
|
|
5523
5601
|
})
|
|
5524
5602
|
});
|
|
5525
5603
|
await this._serviceContext.open(ctx);
|
|
5526
|
-
(0, import_invariant15.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5527
|
-
F: __dxlog_file18,
|
|
5528
|
-
L: 314,
|
|
5529
|
-
S: this,
|
|
5530
|
-
A: [
|
|
5531
|
-
"this.serviceRegistry.services.InvitationsService",
|
|
5532
|
-
""
|
|
5533
|
-
]
|
|
5534
|
-
});
|
|
5535
|
-
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5536
|
-
(0, import_log13.log)("loaded persistent invitations", {
|
|
5537
|
-
count: loadedInvitations.invitations?.length
|
|
5538
|
-
}, {
|
|
5539
|
-
F: __dxlog_file18,
|
|
5540
|
-
L: 317,
|
|
5541
|
-
S: this,
|
|
5542
|
-
C: (f, a) => f(...a)
|
|
5543
|
-
});
|
|
5544
5604
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
5545
5605
|
if (devtoolsProxy) {
|
|
5546
5606
|
this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
|
|
5547
5607
|
url: devtoolsProxy,
|
|
5548
5608
|
requested: {},
|
|
5549
|
-
exposed:
|
|
5609
|
+
exposed: import_client_protocol5.clientServiceBundle,
|
|
5550
5610
|
handlers: this.services
|
|
5551
5611
|
});
|
|
5552
5612
|
void this._devtoolsProxy.open();
|
|
@@ -5560,15 +5620,15 @@ var ClientServicesHost = class {
|
|
|
5560
5620
|
deviceKey
|
|
5561
5621
|
}, {
|
|
5562
5622
|
F: __dxlog_file18,
|
|
5563
|
-
L:
|
|
5623
|
+
L: 315,
|
|
5564
5624
|
S: this,
|
|
5565
5625
|
C: (f, a) => f(...a)
|
|
5566
5626
|
});
|
|
5567
|
-
import_log13.log.trace("dxos.client-services.host.open",
|
|
5627
|
+
import_log13.log.trace("dxos.client-services.host.open", import_protocols13.trace.end({
|
|
5568
5628
|
id: traceId
|
|
5569
5629
|
}), {
|
|
5570
5630
|
F: __dxlog_file18,
|
|
5571
|
-
L:
|
|
5631
|
+
L: 316,
|
|
5572
5632
|
S: this,
|
|
5573
5633
|
C: (f, a) => f(...a)
|
|
5574
5634
|
});
|
|
@@ -5582,7 +5642,7 @@ var ClientServicesHost = class {
|
|
|
5582
5642
|
deviceKey
|
|
5583
5643
|
}, {
|
|
5584
5644
|
F: __dxlog_file18,
|
|
5585
|
-
L:
|
|
5645
|
+
L: 327,
|
|
5586
5646
|
S: this,
|
|
5587
5647
|
C: (f, a) => f(...a)
|
|
5588
5648
|
});
|
|
@@ -5600,24 +5660,24 @@ var ClientServicesHost = class {
|
|
|
5600
5660
|
deviceKey
|
|
5601
5661
|
}, {
|
|
5602
5662
|
F: __dxlog_file18,
|
|
5603
|
-
L:
|
|
5663
|
+
L: 336,
|
|
5604
5664
|
S: this,
|
|
5605
5665
|
C: (f, a) => f(...a)
|
|
5606
5666
|
});
|
|
5607
5667
|
}
|
|
5608
5668
|
async reset() {
|
|
5609
|
-
const traceId =
|
|
5610
|
-
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({
|
|
5611
5671
|
id: traceId
|
|
5612
5672
|
}), {
|
|
5613
5673
|
F: __dxlog_file18,
|
|
5614
|
-
L:
|
|
5674
|
+
L: 341,
|
|
5615
5675
|
S: this,
|
|
5616
5676
|
C: (f, a) => f(...a)
|
|
5617
5677
|
});
|
|
5618
5678
|
(0, import_log13.log)("resetting...", void 0, {
|
|
5619
5679
|
F: __dxlog_file18,
|
|
5620
|
-
L:
|
|
5680
|
+
L: 343,
|
|
5621
5681
|
S: this,
|
|
5622
5682
|
C: (f, a) => f(...a)
|
|
5623
5683
|
});
|
|
@@ -5625,15 +5685,15 @@ var ClientServicesHost = class {
|
|
|
5625
5685
|
await this._storage.reset();
|
|
5626
5686
|
(0, import_log13.log)("reset", void 0, {
|
|
5627
5687
|
F: __dxlog_file18,
|
|
5628
|
-
L:
|
|
5688
|
+
L: 346,
|
|
5629
5689
|
S: this,
|
|
5630
5690
|
C: (f, a) => f(...a)
|
|
5631
5691
|
});
|
|
5632
|
-
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({
|
|
5633
5693
|
id: traceId
|
|
5634
5694
|
}), {
|
|
5635
5695
|
F: __dxlog_file18,
|
|
5636
|
-
L:
|
|
5696
|
+
L: 347,
|
|
5637
5697
|
S: this,
|
|
5638
5698
|
C: (f, a) => f(...a)
|
|
5639
5699
|
});
|
|
@@ -5646,34 +5706,34 @@ var ClientServicesHost = class {
|
|
|
5646
5706
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5647
5707
|
(0, import_invariant15.invariant)(automergeIndex, void 0, {
|
|
5648
5708
|
F: __dxlog_file18,
|
|
5649
|
-
L:
|
|
5709
|
+
L: 359,
|
|
5650
5710
|
S: this,
|
|
5651
5711
|
A: [
|
|
5652
5712
|
"automergeIndex",
|
|
5653
5713
|
""
|
|
5654
5714
|
]
|
|
5655
5715
|
});
|
|
5656
|
-
const document = await this._serviceContext.
|
|
5716
|
+
const document = await this._serviceContext.echoHost.automergeRepo.find(automergeIndex);
|
|
5657
5717
|
await document.whenReady();
|
|
5658
5718
|
const properties = {
|
|
5659
5719
|
system: {
|
|
5660
|
-
type: (0, import_echo_pipeline5.encodeReference)((0,
|
|
5720
|
+
type: (0, import_echo_pipeline5.encodeReference)((0, import_echo_schema2.getTypeReference)(import_client_protocol5.Properties))
|
|
5661
5721
|
},
|
|
5662
5722
|
data: {
|
|
5663
|
-
[
|
|
5723
|
+
[import_client_protocol5.defaultKey]: identity.identityKey.toHex()
|
|
5664
5724
|
},
|
|
5665
5725
|
meta: {
|
|
5666
5726
|
keys: []
|
|
5667
5727
|
}
|
|
5668
5728
|
};
|
|
5669
|
-
const propertiesId =
|
|
5729
|
+
const propertiesId = import_keys12.PublicKey.random().toHex();
|
|
5670
5730
|
document.change((doc) => {
|
|
5671
5731
|
(0, import_util9.assignDeep)(doc, [
|
|
5672
5732
|
"objects",
|
|
5673
5733
|
propertiesId
|
|
5674
5734
|
], properties);
|
|
5675
5735
|
});
|
|
5676
|
-
await this._serviceContext.
|
|
5736
|
+
await this._serviceContext.echoHost.flush();
|
|
5677
5737
|
return identity;
|
|
5678
5738
|
}
|
|
5679
5739
|
};
|
|
@@ -5701,7 +5761,7 @@ var DiagnosticsCollector = class {
|
|
|
5701
5761
|
}
|
|
5702
5762
|
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
5703
5763
|
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
5704
|
-
keys: options.humanize ?
|
|
5764
|
+
keys: options.humanize ? import_services14.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services14.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
5705
5765
|
});
|
|
5706
5766
|
const clientDiagnostics = {
|
|
5707
5767
|
config,
|
|
@@ -5741,6 +5801,7 @@ var findConfigs = () => {
|
|
|
5741
5801
|
IdentityManager,
|
|
5742
5802
|
IdentityServiceImpl,
|
|
5743
5803
|
InvitationsHandler,
|
|
5804
|
+
InvitationsManager,
|
|
5744
5805
|
InvitationsServiceImpl,
|
|
5745
5806
|
Lock,
|
|
5746
5807
|
ServiceContext,
|
|
@@ -5765,4 +5826,4 @@ var findConfigs = () => {
|
|
|
5765
5826
|
subscribeToSpaces,
|
|
5766
5827
|
subscribeToSwarmInfo
|
|
5767
5828
|
});
|
|
5768
|
-
//# sourceMappingURL=chunk-
|
|
5829
|
+
//# sourceMappingURL=chunk-NBYEU3KW.cjs.map
|