@dxos/client-services 0.4.10-main.e2d2318 → 0.4.10-main.e6ba7bc
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-HAFART26.mjs → chunk-NE6FWMYP.mjs} +631 -511
- package/dist/lib/browser/chunk-NE6FWMYP.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +3 -1
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +127 -113
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-5YDVC6TU.cjs → chunk-3EKN7HG6.cjs} +699 -580
- package/dist/lib/node/chunk-3EKN7HG6.cjs.map +7 -0
- package/dist/lib/node/index.cjs +44 -42
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +127 -116
- 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/indexing/util.d.ts +2 -6
- package/dist/types/src/packlets/indexing/util.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 +2 -0
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +3 -2
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +5 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +6 -4
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +34 -34
- package/src/packlets/identity/identity-manager.ts +1 -0
- package/src/packlets/identity/identity.test.ts +3 -0
- package/src/packlets/indexing/util.ts +9 -66
- 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 +1 -1
- package/src/packlets/services/service-context.ts +17 -5
- package/src/packlets/services/service-host.ts +13 -17
- package/src/packlets/spaces/data-space-manager.ts +48 -2
- package/src/packlets/spaces/data-space.ts +1 -1
- package/src/packlets/testing/invitation-utils.ts +100 -97
- package/src/packlets/testing/test-builder.ts +23 -5
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-HAFART26.mjs.map +0 -7
- package/dist/lib/node/chunk-5YDVC6TU.cjs.map +0 -7
|
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_3EKN7HG6_exports = {};
|
|
30
|
+
__export(chunk_3EKN7HG6_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
33
|
ClientServicesProviderResource: () => ClientServicesProviderResource,
|
|
@@ -41,6 +41,7 @@ __export(chunk_5YDVC6TU_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_5YDVC6TU_exports, {
|
|
|
65
66
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
66
67
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
67
68
|
});
|
|
68
|
-
module.exports = __toCommonJS(
|
|
69
|
+
module.exports = __toCommonJS(chunk_3EKN7HG6_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,79 @@ 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");
|
|
209
214
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
210
215
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
211
216
|
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
226
|
var import_automerge = require("@dxos/automerge/automerge");
|
|
222
|
-
var import_debug7 = require("@dxos/debug");
|
|
223
227
|
var import_protocols12 = require("@dxos/protocols");
|
|
224
228
|
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
225
|
-
var
|
|
229
|
+
var import_credentials16 = require("@dxos/credentials");
|
|
226
230
|
var import_invariant14 = require("@dxos/invariant");
|
|
227
231
|
var import_protocols13 = require("@dxos/protocols");
|
|
228
|
-
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
229
|
-
var import_tracing6 = require("@dxos/tracing");
|
|
230
232
|
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
231
|
-
var
|
|
233
|
+
var import_tracing6 = require("@dxos/tracing");
|
|
232
234
|
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
235
|
+
var import_config = require("@dxos/config");
|
|
236
|
+
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
233
237
|
var import_tracing7 = require("@dxos/tracing");
|
|
234
238
|
var import_util8 = require("@dxos/util");
|
|
235
239
|
var import_async16 = require("@dxos/async");
|
|
236
|
-
var
|
|
240
|
+
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
237
241
|
var import_context11 = require("@dxos/context");
|
|
238
242
|
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
239
|
-
var
|
|
243
|
+
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
240
244
|
var import_indexing2 = require("@dxos/indexing");
|
|
241
245
|
var import_invariant15 = require("@dxos/invariant");
|
|
242
|
-
var
|
|
246
|
+
var import_keys12 = require("@dxos/keys");
|
|
243
247
|
var import_log13 = require("@dxos/log");
|
|
244
248
|
var import_messaging = require("@dxos/messaging");
|
|
245
249
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
246
250
|
var import_protocols14 = require("@dxos/protocols");
|
|
247
|
-
var
|
|
251
|
+
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
248
252
|
var import_tracing8 = require("@dxos/tracing");
|
|
249
253
|
var import_util9 = require("@dxos/util");
|
|
250
254
|
var import_websocket_rpc = require("@dxos/websocket-rpc");
|
|
251
255
|
var import_async17 = require("@dxos/async");
|
|
252
256
|
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
253
257
|
var import_invariant16 = require("@dxos/invariant");
|
|
254
|
-
var
|
|
258
|
+
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
255
259
|
var import_invariant17 = require("@dxos/invariant");
|
|
256
260
|
var import_lock_file = require("@dxos/lock-file");
|
|
257
261
|
var import_log14 = require("@dxos/log");
|
|
258
262
|
var import_async18 = require("@dxos/async");
|
|
259
263
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
260
|
-
var
|
|
264
|
+
var import_keys13 = require("@dxos/keys");
|
|
261
265
|
var import_log15 = require("@dxos/log");
|
|
262
|
-
var
|
|
266
|
+
var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
|
|
263
267
|
var import_util10 = require("@dxos/util");
|
|
264
268
|
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
265
269
|
var import_protocols15 = require("@dxos/protocols");
|
|
266
270
|
var import_config2 = require("@dxos/protocols/proto/dxos/config");
|
|
267
271
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
268
|
-
var
|
|
272
|
+
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
269
273
|
var import_config3 = require("@dxos/protocols/proto/dxos/config");
|
|
270
274
|
var import_util11 = require("@dxos/util");
|
|
271
275
|
var import_level = require("level");
|
|
272
276
|
var import_node_path = __toESM(require("node:path"));
|
|
273
|
-
var
|
|
277
|
+
var import_keys14 = require("@dxos/keys");
|
|
274
278
|
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
275
|
-
var
|
|
279
|
+
var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
|
|
276
280
|
var import_util12 = require("@dxos/util");
|
|
277
|
-
var
|
|
281
|
+
var import_keys15 = require("@dxos/keys");
|
|
278
282
|
var import_util13 = require("@dxos/util");
|
|
279
283
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
280
284
|
return new import_codec_protobuf.Stream(({ next }) => {
|
|
@@ -1293,7 +1297,9 @@ var IdentityManager = class {
|
|
|
1293
1297
|
C: (f, a) => f(...a)
|
|
1294
1298
|
});
|
|
1295
1299
|
},
|
|
1296
|
-
memberKey: identityKey
|
|
1300
|
+
memberKey: identityKey,
|
|
1301
|
+
onDelegatedInvitationStatusChange: async () => {
|
|
1302
|
+
}
|
|
1297
1303
|
});
|
|
1298
1304
|
}
|
|
1299
1305
|
};
|
|
@@ -1390,10 +1396,13 @@ var DeviceInvitationProtocol = class {
|
|
|
1390
1396
|
kind: import_services2.Invitation.Kind.DEVICE
|
|
1391
1397
|
};
|
|
1392
1398
|
}
|
|
1393
|
-
async
|
|
1399
|
+
async delegate(invitation) {
|
|
1400
|
+
throw new Error("delegation not supported");
|
|
1401
|
+
}
|
|
1402
|
+
async admit(_, request) {
|
|
1394
1403
|
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1395
1404
|
F: __dxlog_file5,
|
|
1396
|
-
L:
|
|
1405
|
+
L: 42,
|
|
1397
1406
|
S: this,
|
|
1398
1407
|
A: [
|
|
1399
1408
|
"request.device",
|
|
@@ -1439,7 +1448,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1439
1448
|
async accept(response, request) {
|
|
1440
1449
|
(0, import_invariant4.invariant)(response.device, void 0, {
|
|
1441
1450
|
F: __dxlog_file5,
|
|
1442
|
-
L:
|
|
1451
|
+
L: 87,
|
|
1443
1452
|
S: this,
|
|
1444
1453
|
A: [
|
|
1445
1454
|
"response.device",
|
|
@@ -1449,7 +1458,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1449
1458
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1450
1459
|
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1451
1460
|
F: __dxlog_file5,
|
|
1452
|
-
L:
|
|
1461
|
+
L: 90,
|
|
1453
1462
|
S: this,
|
|
1454
1463
|
A: [
|
|
1455
1464
|
"request.device",
|
|
@@ -1824,51 +1833,7 @@ var InvitationsHandler = class {
|
|
|
1824
1833
|
constructor(_networkManager) {
|
|
1825
1834
|
this._networkManager = _networkManager;
|
|
1826
1835
|
}
|
|
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
|
-
});
|
|
1836
|
+
handleInvitationFlow(ctx, stream, protocol, invitation) {
|
|
1872
1837
|
const createExtension = () => {
|
|
1873
1838
|
const extension = new InvitationHostExtension({
|
|
1874
1839
|
onStateUpdate: (invitation2) => {
|
|
@@ -1877,8 +1842,8 @@ var InvitationsHandler = class {
|
|
|
1877
1842
|
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1878
1843
|
});
|
|
1879
1844
|
},
|
|
1880
|
-
resolveInvitation: async ({ invitationId
|
|
1881
|
-
if (
|
|
1845
|
+
resolveInvitation: async ({ invitationId }) => {
|
|
1846
|
+
if (invitationId && invitationId !== invitation.invitationId) {
|
|
1882
1847
|
return void 0;
|
|
1883
1848
|
}
|
|
1884
1849
|
return invitation;
|
|
@@ -1888,14 +1853,14 @@ var InvitationsHandler = class {
|
|
|
1888
1853
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1889
1854
|
(0, import_invariant5.invariant)(deviceKey, void 0, {
|
|
1890
1855
|
F: __dxlog_file7,
|
|
1891
|
-
L:
|
|
1856
|
+
L: 87,
|
|
1892
1857
|
S: this,
|
|
1893
1858
|
A: [
|
|
1894
1859
|
"deviceKey",
|
|
1895
1860
|
""
|
|
1896
1861
|
]
|
|
1897
1862
|
});
|
|
1898
|
-
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1863
|
+
const admissionResponse = await protocol.admit(invitation, admissionRequest, extension.guestProfile);
|
|
1899
1864
|
extension.completedTrigger.wake(deviceKey);
|
|
1900
1865
|
return admissionResponse;
|
|
1901
1866
|
} catch (err) {
|
|
@@ -1911,7 +1876,7 @@ var InvitationsHandler = class {
|
|
|
1911
1876
|
id: traceId
|
|
1912
1877
|
}), {
|
|
1913
1878
|
F: __dxlog_file7,
|
|
1914
|
-
L:
|
|
1879
|
+
L: 105,
|
|
1915
1880
|
S: this,
|
|
1916
1881
|
C: (f, a) => f(...a)
|
|
1917
1882
|
});
|
|
@@ -1919,7 +1884,7 @@ var InvitationsHandler = class {
|
|
|
1919
1884
|
...protocol.toJSON()
|
|
1920
1885
|
}, {
|
|
1921
1886
|
F: __dxlog_file7,
|
|
1922
|
-
L:
|
|
1887
|
+
L: 106,
|
|
1923
1888
|
S: this,
|
|
1924
1889
|
C: (f, a) => f(...a)
|
|
1925
1890
|
});
|
|
@@ -1928,14 +1893,14 @@ var InvitationsHandler = class {
|
|
|
1928
1893
|
state: import_services3.Invitation.State.CONNECTED
|
|
1929
1894
|
});
|
|
1930
1895
|
const deviceKey = await extension.completedTrigger.wait({
|
|
1931
|
-
timeout
|
|
1896
|
+
timeout: invitation.timeout
|
|
1932
1897
|
});
|
|
1933
1898
|
(0, import_log4.log)("admitted guest", {
|
|
1934
1899
|
guest: deviceKey,
|
|
1935
1900
|
...protocol.toJSON()
|
|
1936
1901
|
}, {
|
|
1937
1902
|
F: __dxlog_file7,
|
|
1938
|
-
L:
|
|
1903
|
+
L: 109,
|
|
1939
1904
|
S: this,
|
|
1940
1905
|
C: (f, a) => f(...a)
|
|
1941
1906
|
});
|
|
@@ -1947,7 +1912,7 @@ var InvitationsHandler = class {
|
|
|
1947
1912
|
id: traceId
|
|
1948
1913
|
}), {
|
|
1949
1914
|
F: __dxlog_file7,
|
|
1950
|
-
L:
|
|
1915
|
+
L: 111,
|
|
1951
1916
|
S: this,
|
|
1952
1917
|
C: (f, a) => f(...a)
|
|
1953
1918
|
});
|
|
@@ -1957,7 +1922,7 @@ var InvitationsHandler = class {
|
|
|
1957
1922
|
...protocol.toJSON()
|
|
1958
1923
|
}, {
|
|
1959
1924
|
F: __dxlog_file7,
|
|
1960
|
-
L:
|
|
1925
|
+
L: 114,
|
|
1961
1926
|
S: this,
|
|
1962
1927
|
C: (f, a) => f(...a)
|
|
1963
1928
|
});
|
|
@@ -1968,7 +1933,7 @@ var InvitationsHandler = class {
|
|
|
1968
1933
|
} else {
|
|
1969
1934
|
import_log4.log.error("failed", err, {
|
|
1970
1935
|
F: __dxlog_file7,
|
|
1971
|
-
L:
|
|
1936
|
+
L: 117,
|
|
1972
1937
|
S: this,
|
|
1973
1938
|
C: (f, a) => f(...a)
|
|
1974
1939
|
});
|
|
@@ -1979,12 +1944,12 @@ var InvitationsHandler = class {
|
|
|
1979
1944
|
error: err
|
|
1980
1945
|
}), {
|
|
1981
1946
|
F: __dxlog_file7,
|
|
1982
|
-
L:
|
|
1947
|
+
L: 120,
|
|
1983
1948
|
S: this,
|
|
1984
1949
|
C: (f, a) => f(...a)
|
|
1985
1950
|
});
|
|
1986
1951
|
} finally {
|
|
1987
|
-
if (!multiUse) {
|
|
1952
|
+
if (!invitation.multiUse) {
|
|
1988
1953
|
await swarmConnection.close();
|
|
1989
1954
|
await ctx.dispose();
|
|
1990
1955
|
}
|
|
@@ -2000,7 +1965,7 @@ var InvitationsHandler = class {
|
|
|
2000
1965
|
...protocol.toJSON()
|
|
2001
1966
|
}, {
|
|
2002
1967
|
F: __dxlog_file7,
|
|
2003
|
-
L:
|
|
1968
|
+
L: 135,
|
|
2004
1969
|
S: this,
|
|
2005
1970
|
C: (f, a) => f(...a)
|
|
2006
1971
|
});
|
|
@@ -2011,7 +1976,7 @@ var InvitationsHandler = class {
|
|
|
2011
1976
|
} else {
|
|
2012
1977
|
import_log4.log.error("failed", err, {
|
|
2013
1978
|
F: __dxlog_file7,
|
|
2014
|
-
L:
|
|
1979
|
+
L: 138,
|
|
2015
1980
|
S: this,
|
|
2016
1981
|
C: (f, a) => f(...a)
|
|
2017
1982
|
});
|
|
@@ -2021,11 +1986,11 @@ var InvitationsHandler = class {
|
|
|
2021
1986
|
});
|
|
2022
1987
|
return extension;
|
|
2023
1988
|
};
|
|
2024
|
-
if (invitation.lifetime && invitation.created
|
|
1989
|
+
if (invitation.lifetime && invitation.created) {
|
|
2025
1990
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
2026
1991
|
import_log4.log.warn("invitation has already expired", void 0, {
|
|
2027
1992
|
F: __dxlog_file7,
|
|
2028
|
-
L:
|
|
1993
|
+
L: 149,
|
|
2029
1994
|
S: this,
|
|
2030
1995
|
C: (f, a) => f(...a)
|
|
2031
1996
|
});
|
|
@@ -2059,24 +2024,12 @@ var InvitationsHandler = class {
|
|
|
2059
2024
|
state: import_services3.Invitation.State.CONNECTING
|
|
2060
2025
|
});
|
|
2061
2026
|
});
|
|
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
2027
|
}
|
|
2075
2028
|
acceptInvitation(protocol, invitation, deviceProfile) {
|
|
2076
2029
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
2077
2030
|
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
2078
2031
|
F: __dxlog_file7,
|
|
2079
|
-
L:
|
|
2032
|
+
L: 191,
|
|
2080
2033
|
S: this,
|
|
2081
2034
|
A: [
|
|
2082
2035
|
"protocol",
|
|
@@ -2086,7 +2039,7 @@ var InvitationsHandler = class {
|
|
|
2086
2039
|
if (deviceProfile) {
|
|
2087
2040
|
(0, import_invariant5.invariant)(invitation.kind === import_services3.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2088
2041
|
F: __dxlog_file7,
|
|
2089
|
-
L:
|
|
2042
|
+
L: 194,
|
|
2090
2043
|
S: this,
|
|
2091
2044
|
A: [
|
|
2092
2045
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -2101,7 +2054,7 @@ var InvitationsHandler = class {
|
|
|
2101
2054
|
const setState = (newData) => {
|
|
2102
2055
|
(0, import_invariant5.invariant)(newData.state !== void 0, void 0, {
|
|
2103
2056
|
F: __dxlog_file7,
|
|
2104
|
-
L:
|
|
2057
|
+
L: 205,
|
|
2105
2058
|
S: this,
|
|
2106
2059
|
A: [
|
|
2107
2060
|
"newData.state !== undefined",
|
|
@@ -2121,7 +2074,7 @@ var InvitationsHandler = class {
|
|
|
2121
2074
|
...protocol.toJSON()
|
|
2122
2075
|
}, {
|
|
2123
2076
|
F: __dxlog_file7,
|
|
2124
|
-
L:
|
|
2077
|
+
L: 213,
|
|
2125
2078
|
S: this,
|
|
2126
2079
|
C: (f, a) => f(...a)
|
|
2127
2080
|
});
|
|
@@ -2131,7 +2084,7 @@ var InvitationsHandler = class {
|
|
|
2131
2084
|
} else {
|
|
2132
2085
|
import_log4.log.warn("auth failed", err, {
|
|
2133
2086
|
F: __dxlog_file7,
|
|
2134
|
-
L:
|
|
2087
|
+
L: 216,
|
|
2135
2088
|
S: this,
|
|
2136
2089
|
C: (f, a) => f(...a)
|
|
2137
2090
|
});
|
|
@@ -2145,7 +2098,7 @@ var InvitationsHandler = class {
|
|
|
2145
2098
|
...protocol.toJSON()
|
|
2146
2099
|
}, {
|
|
2147
2100
|
F: __dxlog_file7,
|
|
2148
|
-
L:
|
|
2101
|
+
L: 224,
|
|
2149
2102
|
S: this,
|
|
2150
2103
|
C: (f, a) => f(...a)
|
|
2151
2104
|
});
|
|
@@ -2160,7 +2113,7 @@ var InvitationsHandler = class {
|
|
|
2160
2113
|
currentState
|
|
2161
2114
|
}, {
|
|
2162
2115
|
F: __dxlog_file7,
|
|
2163
|
-
L:
|
|
2116
|
+
L: 234,
|
|
2164
2117
|
S: this,
|
|
2165
2118
|
C: (f, a) => f(...a)
|
|
2166
2119
|
});
|
|
@@ -2175,7 +2128,7 @@ var InvitationsHandler = class {
|
|
|
2175
2128
|
id: traceId
|
|
2176
2129
|
}), {
|
|
2177
2130
|
F: __dxlog_file7,
|
|
2178
|
-
L:
|
|
2131
|
+
L: 243,
|
|
2179
2132
|
S: this,
|
|
2180
2133
|
C: (f, a) => f(...a)
|
|
2181
2134
|
});
|
|
@@ -2187,7 +2140,7 @@ var InvitationsHandler = class {
|
|
|
2187
2140
|
...protocol.toJSON()
|
|
2188
2141
|
}, {
|
|
2189
2142
|
F: __dxlog_file7,
|
|
2190
|
-
L:
|
|
2143
|
+
L: 251,
|
|
2191
2144
|
S: this,
|
|
2192
2145
|
C: (f, a) => f(...a)
|
|
2193
2146
|
});
|
|
@@ -2198,7 +2151,7 @@ var InvitationsHandler = class {
|
|
|
2198
2151
|
...protocol.toJSON()
|
|
2199
2152
|
}, {
|
|
2200
2153
|
F: __dxlog_file7,
|
|
2201
|
-
L:
|
|
2154
|
+
L: 255,
|
|
2202
2155
|
S: this,
|
|
2203
2156
|
C: (f, a) => f(...a)
|
|
2204
2157
|
});
|
|
@@ -2208,7 +2161,7 @@ var InvitationsHandler = class {
|
|
|
2208
2161
|
response: introductionResponse
|
|
2209
2162
|
}, {
|
|
2210
2163
|
F: __dxlog_file7,
|
|
2211
|
-
L:
|
|
2164
|
+
L: 259,
|
|
2212
2165
|
S: this,
|
|
2213
2166
|
C: (f, a) => f(...a)
|
|
2214
2167
|
});
|
|
@@ -2229,7 +2182,7 @@ var InvitationsHandler = class {
|
|
|
2229
2182
|
...protocol.toJSON()
|
|
2230
2183
|
}, {
|
|
2231
2184
|
F: __dxlog_file7,
|
|
2232
|
-
L:
|
|
2185
|
+
L: 275,
|
|
2233
2186
|
S: this,
|
|
2234
2187
|
C: (f, a) => f(...a)
|
|
2235
2188
|
});
|
|
@@ -2241,7 +2194,7 @@ var InvitationsHandler = class {
|
|
|
2241
2194
|
...protocol.toJSON()
|
|
2242
2195
|
}, {
|
|
2243
2196
|
F: __dxlog_file7,
|
|
2244
|
-
L:
|
|
2197
|
+
L: 286,
|
|
2245
2198
|
S: this,
|
|
2246
2199
|
C: (f, a) => f(...a)
|
|
2247
2200
|
});
|
|
@@ -2254,7 +2207,7 @@ var InvitationsHandler = class {
|
|
|
2254
2207
|
id: traceId
|
|
2255
2208
|
}), {
|
|
2256
2209
|
F: __dxlog_file7,
|
|
2257
|
-
L:
|
|
2210
|
+
L: 288,
|
|
2258
2211
|
S: this,
|
|
2259
2212
|
C: (f, a) => f(...a)
|
|
2260
2213
|
});
|
|
@@ -2264,7 +2217,7 @@ var InvitationsHandler = class {
|
|
|
2264
2217
|
...protocol.toJSON()
|
|
2265
2218
|
}, {
|
|
2266
2219
|
F: __dxlog_file7,
|
|
2267
|
-
L:
|
|
2220
|
+
L: 291,
|
|
2268
2221
|
S: this,
|
|
2269
2222
|
C: (f, a) => f(...a)
|
|
2270
2223
|
});
|
|
@@ -2274,7 +2227,7 @@ var InvitationsHandler = class {
|
|
|
2274
2227
|
} else {
|
|
2275
2228
|
(0, import_log4.log)("auth failed", err, {
|
|
2276
2229
|
F: __dxlog_file7,
|
|
2277
|
-
L:
|
|
2230
|
+
L: 294,
|
|
2278
2231
|
S: this,
|
|
2279
2232
|
C: (f, a) => f(...a)
|
|
2280
2233
|
});
|
|
@@ -2285,7 +2238,7 @@ var InvitationsHandler = class {
|
|
|
2285
2238
|
error: err
|
|
2286
2239
|
}), {
|
|
2287
2240
|
F: __dxlog_file7,
|
|
2288
|
-
L:
|
|
2241
|
+
L: 297,
|
|
2289
2242
|
S: this,
|
|
2290
2243
|
C: (f, a) => f(...a)
|
|
2291
2244
|
});
|
|
@@ -2303,7 +2256,7 @@ var InvitationsHandler = class {
|
|
|
2303
2256
|
...protocol.toJSON()
|
|
2304
2257
|
}, {
|
|
2305
2258
|
F: __dxlog_file7,
|
|
2306
|
-
L:
|
|
2259
|
+
L: 308,
|
|
2307
2260
|
S: this,
|
|
2308
2261
|
C: (f, a) => f(...a)
|
|
2309
2262
|
});
|
|
@@ -2313,7 +2266,7 @@ var InvitationsHandler = class {
|
|
|
2313
2266
|
} else {
|
|
2314
2267
|
(0, import_log4.log)("auth failed", err, {
|
|
2315
2268
|
F: __dxlog_file7,
|
|
2316
|
-
L:
|
|
2269
|
+
L: 311,
|
|
2317
2270
|
S: this,
|
|
2318
2271
|
C: (f, a) => f(...a)
|
|
2319
2272
|
});
|
|
@@ -2330,7 +2283,7 @@ var InvitationsHandler = class {
|
|
|
2330
2283
|
} else {
|
|
2331
2284
|
(0, import_invariant5.invariant)(invitation.swarmKey, void 0, {
|
|
2332
2285
|
F: __dxlog_file7,
|
|
2333
|
-
L:
|
|
2286
|
+
L: 325,
|
|
2334
2287
|
S: this,
|
|
2335
2288
|
A: [
|
|
2336
2289
|
"invitation.swarmKey",
|
|
@@ -2372,7 +2325,7 @@ var InvitationsHandler = class {
|
|
|
2372
2325
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2373
2326
|
(0, import_log4.log)("guest waiting for authentication code...", void 0, {
|
|
2374
2327
|
F: __dxlog_file7,
|
|
2375
|
-
L:
|
|
2328
|
+
L: 365,
|
|
2376
2329
|
S: this,
|
|
2377
2330
|
C: (f, a) => f(...a)
|
|
2378
2331
|
});
|
|
@@ -2382,7 +2335,7 @@ var InvitationsHandler = class {
|
|
|
2382
2335
|
const authCode = await authenticated.wait(options);
|
|
2383
2336
|
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2384
2337
|
F: __dxlog_file7,
|
|
2385
|
-
L:
|
|
2338
|
+
L: 369,
|
|
2386
2339
|
S: this,
|
|
2387
2340
|
C: (f, a) => f(...a)
|
|
2388
2341
|
});
|
|
@@ -2403,7 +2356,7 @@ var InvitationsHandler = class {
|
|
|
2403
2356
|
attempt
|
|
2404
2357
|
}, {
|
|
2405
2358
|
F: __dxlog_file7,
|
|
2406
|
-
L:
|
|
2359
|
+
L: 380,
|
|
2407
2360
|
S: this,
|
|
2408
2361
|
C: (f, a) => f(...a)
|
|
2409
2362
|
});
|
|
@@ -2421,7 +2374,7 @@ var InvitationsHandler = class {
|
|
|
2421
2374
|
}
|
|
2422
2375
|
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2423
2376
|
F: __dxlog_file7,
|
|
2424
|
-
L:
|
|
2377
|
+
L: 399,
|
|
2425
2378
|
S: this,
|
|
2426
2379
|
C: (f, a) => f(...a)
|
|
2427
2380
|
});
|
|
@@ -2444,194 +2397,34 @@ var createAdmissionKeypair = () => {
|
|
|
2444
2397
|
privateKey: keypair.secretKey
|
|
2445
2398
|
};
|
|
2446
2399
|
};
|
|
2447
|
-
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
2448
2400
|
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;
|
|
2401
|
+
constructor(_invitationsManager) {
|
|
2402
|
+
this._invitationsManager = _invitationsManager;
|
|
2462
2403
|
}
|
|
2463
2404
|
// TODO(burdon): Guest/host label.
|
|
2464
2405
|
getLoggingContext() {
|
|
2465
2406
|
return {};
|
|
2466
2407
|
}
|
|
2467
2408
|
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
2409
|
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
|
-
});
|
|
2410
|
+
void this._invitationsManager.createInvitation(options).then((invitation) => invitation.subscribe(next, close, close)).catch(close);
|
|
2506
2411
|
});
|
|
2507
2412
|
}
|
|
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
|
-
}
|
|
2413
|
+
acceptInvitation(request) {
|
|
2414
|
+
const invitation = this._invitationsManager.acceptInvitation(request);
|
|
2555
2415
|
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
|
-
});
|
|
2416
|
+
invitation.subscribe(next, close, close);
|
|
2567
2417
|
});
|
|
2568
2418
|
}
|
|
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
|
-
}
|
|
2419
|
+
async authenticate(request) {
|
|
2420
|
+
return this._invitationsManager.authenticate(request);
|
|
2598
2421
|
}
|
|
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
|
-
}
|
|
2422
|
+
async cancelInvitation(request) {
|
|
2423
|
+
return this._invitationsManager.cancelInvitation(request);
|
|
2631
2424
|
}
|
|
2632
2425
|
queryInvitations() {
|
|
2633
2426
|
return new import_codec_protobuf8.Stream(({ next, ctx }) => {
|
|
2634
|
-
this.
|
|
2427
|
+
this._invitationsManager.invitationCreated.on(ctx, (invitation) => {
|
|
2635
2428
|
next({
|
|
2636
2429
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2637
2430
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2640,7 +2433,7 @@ var InvitationsServiceImpl = class {
|
|
|
2640
2433
|
]
|
|
2641
2434
|
});
|
|
2642
2435
|
});
|
|
2643
|
-
this.
|
|
2436
|
+
this._invitationsManager.invitationAccepted.on(ctx, (invitation) => {
|
|
2644
2437
|
next({
|
|
2645
2438
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2646
2439
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2649,7 +2442,7 @@ var InvitationsServiceImpl = class {
|
|
|
2649
2442
|
]
|
|
2650
2443
|
});
|
|
2651
2444
|
});
|
|
2652
|
-
this.
|
|
2445
|
+
this._invitationsManager.removedCreated.on(ctx, (invitation) => {
|
|
2653
2446
|
next({
|
|
2654
2447
|
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2655
2448
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2658,7 +2451,7 @@ var InvitationsServiceImpl = class {
|
|
|
2658
2451
|
]
|
|
2659
2452
|
});
|
|
2660
2453
|
});
|
|
2661
|
-
this.
|
|
2454
|
+
this._invitationsManager.removedAccepted.on(ctx, (invitation) => {
|
|
2662
2455
|
next({
|
|
2663
2456
|
action: import_services5.QueryInvitationsResponse.Action.REMOVED,
|
|
2664
2457
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
@@ -2667,7 +2460,7 @@ var InvitationsServiceImpl = class {
|
|
|
2667
2460
|
]
|
|
2668
2461
|
});
|
|
2669
2462
|
});
|
|
2670
|
-
this.
|
|
2463
|
+
this._invitationsManager.saved.on(ctx, (invitation) => {
|
|
2671
2464
|
next({
|
|
2672
2465
|
action: import_services5.QueryInvitationsResponse.Action.SAVED,
|
|
2673
2466
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
@@ -2679,32 +2472,25 @@ var InvitationsServiceImpl = class {
|
|
|
2679
2472
|
next({
|
|
2680
2473
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2681
2474
|
type: import_services5.QueryInvitationsResponse.Type.CREATED,
|
|
2682
|
-
invitations:
|
|
2475
|
+
invitations: this._invitationsManager.getCreatedInvitations(),
|
|
2683
2476
|
existing: true
|
|
2684
2477
|
});
|
|
2685
2478
|
next({
|
|
2686
2479
|
action: import_services5.QueryInvitationsResponse.Action.ADDED,
|
|
2687
2480
|
type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
|
|
2688
|
-
invitations:
|
|
2481
|
+
invitations: this._invitationsManager.getAcceptedInvitations(),
|
|
2689
2482
|
existing: true
|
|
2690
2483
|
});
|
|
2691
|
-
|
|
2484
|
+
this._invitationsManager.onPersistentInvitationsLoaded(ctx, () => {
|
|
2692
2485
|
next({
|
|
2693
2486
|
action: import_services5.QueryInvitationsResponse.Action.LOAD_COMPLETE,
|
|
2694
2487
|
type: import_services5.QueryInvitationsResponse.Type.CREATED
|
|
2695
2488
|
});
|
|
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
|
-
}
|
|
2489
|
+
});
|
|
2704
2490
|
});
|
|
2705
2491
|
}
|
|
2706
2492
|
};
|
|
2707
|
-
var
|
|
2493
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2708
2494
|
var SpaceInvitationProtocol = class {
|
|
2709
2495
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
2710
2496
|
this._spaceManager = _spaceManager;
|
|
@@ -2724,10 +2510,10 @@ var SpaceInvitationProtocol = class {
|
|
|
2724
2510
|
spaceKey: this._spaceKey
|
|
2725
2511
|
};
|
|
2726
2512
|
}
|
|
2727
|
-
async admit(request, guestProfile) {
|
|
2728
|
-
(0,
|
|
2729
|
-
F:
|
|
2730
|
-
L:
|
|
2513
|
+
async admit(invitation, request, guestProfile) {
|
|
2514
|
+
(0, import_invariant7.invariant)(this._spaceKey, void 0, {
|
|
2515
|
+
F: __dxlog_file8,
|
|
2516
|
+
L: 55,
|
|
2731
2517
|
S: this,
|
|
2732
2518
|
A: [
|
|
2733
2519
|
"this._spaceKey",
|
|
@@ -2735,18 +2521,18 @@ var SpaceInvitationProtocol = class {
|
|
|
2735
2521
|
]
|
|
2736
2522
|
});
|
|
2737
2523
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2738
|
-
(0,
|
|
2739
|
-
F:
|
|
2740
|
-
L:
|
|
2524
|
+
(0, import_invariant7.invariant)(space, void 0, {
|
|
2525
|
+
F: __dxlog_file8,
|
|
2526
|
+
L: 57,
|
|
2741
2527
|
S: this,
|
|
2742
2528
|
A: [
|
|
2743
2529
|
"space",
|
|
2744
2530
|
""
|
|
2745
2531
|
]
|
|
2746
2532
|
});
|
|
2747
|
-
(0,
|
|
2748
|
-
F:
|
|
2749
|
-
L:
|
|
2533
|
+
(0, import_invariant7.invariant)(request.space, void 0, {
|
|
2534
|
+
F: __dxlog_file8,
|
|
2535
|
+
L: 59,
|
|
2750
2536
|
S: this,
|
|
2751
2537
|
A: [
|
|
2752
2538
|
"request.space",
|
|
@@ -2754,19 +2540,19 @@ var SpaceInvitationProtocol = class {
|
|
|
2754
2540
|
]
|
|
2755
2541
|
});
|
|
2756
2542
|
const { identityKey, deviceKey } = request.space;
|
|
2757
|
-
(0,
|
|
2543
|
+
(0, import_log6.log)("writing guest credentials", {
|
|
2758
2544
|
host: this._signingContext.deviceKey,
|
|
2759
2545
|
guest: deviceKey
|
|
2760
2546
|
}, {
|
|
2761
|
-
F:
|
|
2762
|
-
L:
|
|
2547
|
+
F: __dxlog_file8,
|
|
2548
|
+
L: 62,
|
|
2763
2549
|
S: this,
|
|
2764
2550
|
C: (f, a) => f(...a)
|
|
2765
2551
|
});
|
|
2766
|
-
const credentials = await (0,
|
|
2767
|
-
(0,
|
|
2768
|
-
F:
|
|
2769
|
-
L:
|
|
2552
|
+
const credentials = await (0, import_credentials7.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile, invitation.delegationCredentialId);
|
|
2553
|
+
(0, import_invariant7.invariant)(credentials[0].credential, void 0, {
|
|
2554
|
+
F: __dxlog_file8,
|
|
2555
|
+
L: 74,
|
|
2770
2556
|
S: this,
|
|
2771
2557
|
A: [
|
|
2772
2558
|
"credentials[0].credential",
|
|
@@ -2774,9 +2560,9 @@ var SpaceInvitationProtocol = class {
|
|
|
2774
2560
|
]
|
|
2775
2561
|
});
|
|
2776
2562
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2777
|
-
(0,
|
|
2778
|
-
F:
|
|
2779
|
-
L:
|
|
2563
|
+
(0, import_invariant7.invariant)((0, import_credentials7.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2564
|
+
F: __dxlog_file8,
|
|
2565
|
+
L: 76,
|
|
2780
2566
|
S: this,
|
|
2781
2567
|
A: [
|
|
2782
2568
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2791,6 +2577,69 @@ var SpaceInvitationProtocol = class {
|
|
|
2791
2577
|
}
|
|
2792
2578
|
};
|
|
2793
2579
|
}
|
|
2580
|
+
async delegate(invitation) {
|
|
2581
|
+
(0, import_invariant7.invariant)(this._spaceKey, void 0, {
|
|
2582
|
+
F: __dxlog_file8,
|
|
2583
|
+
L: 89,
|
|
2584
|
+
S: this,
|
|
2585
|
+
A: [
|
|
2586
|
+
"this._spaceKey",
|
|
2587
|
+
""
|
|
2588
|
+
]
|
|
2589
|
+
});
|
|
2590
|
+
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2591
|
+
(0, import_invariant7.invariant)(space, void 0, {
|
|
2592
|
+
F: __dxlog_file8,
|
|
2593
|
+
L: 91,
|
|
2594
|
+
S: this,
|
|
2595
|
+
A: [
|
|
2596
|
+
"space",
|
|
2597
|
+
""
|
|
2598
|
+
]
|
|
2599
|
+
});
|
|
2600
|
+
if (invitation.authMethod === import_services6.Invitation.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
2601
|
+
(0, import_invariant7.invariant)(invitation.guestKeypair?.publicKey, void 0, {
|
|
2602
|
+
F: __dxlog_file8,
|
|
2603
|
+
L: 93,
|
|
2604
|
+
S: this,
|
|
2605
|
+
A: [
|
|
2606
|
+
"invitation.guestKeypair?.publicKey",
|
|
2607
|
+
""
|
|
2608
|
+
]
|
|
2609
|
+
});
|
|
2610
|
+
}
|
|
2611
|
+
(0, import_log6.log)("writing delegate space invitation", {
|
|
2612
|
+
host: this._signingContext.deviceKey,
|
|
2613
|
+
id: invitation.invitationId
|
|
2614
|
+
}, {
|
|
2615
|
+
F: __dxlog_file8,
|
|
2616
|
+
L: 96,
|
|
2617
|
+
S: this,
|
|
2618
|
+
C: (f, a) => f(...a)
|
|
2619
|
+
});
|
|
2620
|
+
const credential = await (0, import_credentials7.createDelegatedSpaceInvitationCredential)(this._signingContext.credentialSigner, space.key, {
|
|
2621
|
+
invitationId: invitation.invitationId,
|
|
2622
|
+
authMethod: invitation.authMethod,
|
|
2623
|
+
swarmKey: invitation.swarmKey,
|
|
2624
|
+
role: import_credentials8.SpaceMember.Role.ADMIN,
|
|
2625
|
+
expiresOn: invitation.lifetime ? new Date((invitation.created?.getTime() ?? Date.now()) + invitation.lifetime) : void 0,
|
|
2626
|
+
multiUse: invitation.multiUse ?? false,
|
|
2627
|
+
guestKey: invitation.authMethod === import_services6.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
|
|
2628
|
+
});
|
|
2629
|
+
(0, import_invariant7.invariant)(credential.credential, void 0, {
|
|
2630
|
+
F: __dxlog_file8,
|
|
2631
|
+
L: 116,
|
|
2632
|
+
S: this,
|
|
2633
|
+
A: [
|
|
2634
|
+
"credential.credential",
|
|
2635
|
+
""
|
|
2636
|
+
]
|
|
2637
|
+
});
|
|
2638
|
+
await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, [
|
|
2639
|
+
credential
|
|
2640
|
+
]);
|
|
2641
|
+
return credential.credential.credential.id;
|
|
2642
|
+
}
|
|
2794
2643
|
checkInvitation(invitation) {
|
|
2795
2644
|
if (invitation.spaceKey && this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
2796
2645
|
return new import_protocols6.AlreadyJoinedError("Already joined space.");
|
|
@@ -2814,9 +2663,9 @@ var SpaceInvitationProtocol = class {
|
|
|
2814
2663
|
};
|
|
2815
2664
|
}
|
|
2816
2665
|
async accept(response) {
|
|
2817
|
-
(0,
|
|
2818
|
-
F:
|
|
2819
|
-
L:
|
|
2666
|
+
(0, import_invariant7.invariant)(response.space, void 0, {
|
|
2667
|
+
F: __dxlog_file8,
|
|
2668
|
+
L: 149,
|
|
2820
2669
|
S: this,
|
|
2821
2670
|
A: [
|
|
2822
2671
|
"response.space",
|
|
@@ -2824,19 +2673,19 @@ var SpaceInvitationProtocol = class {
|
|
|
2824
2673
|
]
|
|
2825
2674
|
});
|
|
2826
2675
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2827
|
-
const assertion = (0,
|
|
2828
|
-
(0,
|
|
2829
|
-
F:
|
|
2830
|
-
L:
|
|
2676
|
+
const assertion = (0, import_credentials7.getCredentialAssertion)(credential);
|
|
2677
|
+
(0, import_invariant7.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2678
|
+
F: __dxlog_file8,
|
|
2679
|
+
L: 152,
|
|
2831
2680
|
S: this,
|
|
2832
2681
|
A: [
|
|
2833
2682
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2834
2683
|
"'Invalid credential'"
|
|
2835
2684
|
]
|
|
2836
2685
|
});
|
|
2837
|
-
(0,
|
|
2838
|
-
F:
|
|
2839
|
-
L:
|
|
2686
|
+
(0, import_invariant7.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2687
|
+
F: __dxlog_file8,
|
|
2688
|
+
L: 153,
|
|
2840
2689
|
S: this,
|
|
2841
2690
|
A: [
|
|
2842
2691
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
@@ -2858,6 +2707,284 @@ var SpaceInvitationProtocol = class {
|
|
|
2858
2707
|
};
|
|
2859
2708
|
}
|
|
2860
2709
|
};
|
|
2710
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts";
|
|
2711
|
+
var InvitationsManager = class {
|
|
2712
|
+
constructor(_invitationsHandler, _getHandler, _metadataStore) {
|
|
2713
|
+
this._invitationsHandler = _invitationsHandler;
|
|
2714
|
+
this._getHandler = _getHandler;
|
|
2715
|
+
this._metadataStore = _metadataStore;
|
|
2716
|
+
this._createInvitations = /* @__PURE__ */ new Map();
|
|
2717
|
+
this._acceptInvitations = /* @__PURE__ */ new Map();
|
|
2718
|
+
this.invitationCreated = new import_async9.Event();
|
|
2719
|
+
this.invitationAccepted = new import_async9.Event();
|
|
2720
|
+
this.removedCreated = new import_async9.Event();
|
|
2721
|
+
this.removedAccepted = new import_async9.Event();
|
|
2722
|
+
this.saved = new import_async9.Event();
|
|
2723
|
+
this._persistentInvitationsLoadedEvent = new import_async9.Event();
|
|
2724
|
+
this._persistentInvitationsLoaded = false;
|
|
2725
|
+
}
|
|
2726
|
+
async createInvitation(options) {
|
|
2727
|
+
if (options.invitationId) {
|
|
2728
|
+
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2729
|
+
if (existingInvitation) {
|
|
2730
|
+
return existingInvitation;
|
|
2731
|
+
}
|
|
2732
|
+
}
|
|
2733
|
+
const handler = this._getHandler(options);
|
|
2734
|
+
const invitation = this._createInvitation(handler, options);
|
|
2735
|
+
const { ctx, stream, observableInvitation } = this._createObservableInvitation(handler, invitation);
|
|
2736
|
+
this._createInvitations.set(invitation.invitationId, observableInvitation);
|
|
2737
|
+
this.invitationCreated.emit(invitation);
|
|
2738
|
+
this._onInvitationComplete(observableInvitation, async () => {
|
|
2739
|
+
this._createInvitations.delete(observableInvitation.get().invitationId);
|
|
2740
|
+
this.removedCreated.emit(observableInvitation.get());
|
|
2741
|
+
if (observableInvitation.get().persistent) {
|
|
2742
|
+
await this._safeDeleteInvitation(observableInvitation.get());
|
|
2743
|
+
}
|
|
2744
|
+
});
|
|
2745
|
+
try {
|
|
2746
|
+
await this._persistIfRequired(handler, stream, invitation);
|
|
2747
|
+
} catch (err) {
|
|
2748
|
+
import_log7.log.catch(err, void 0, {
|
|
2749
|
+
F: __dxlog_file9,
|
|
2750
|
+
L: 76,
|
|
2751
|
+
S: this,
|
|
2752
|
+
C: (f, a) => f(...a)
|
|
2753
|
+
});
|
|
2754
|
+
await observableInvitation.cancel();
|
|
2755
|
+
return observableInvitation;
|
|
2756
|
+
}
|
|
2757
|
+
this._invitationsHandler.handleInvitationFlow(ctx, stream, handler, observableInvitation.get());
|
|
2758
|
+
return observableInvitation;
|
|
2759
|
+
}
|
|
2760
|
+
async loadPersistentInvitations() {
|
|
2761
|
+
if (this._persistentInvitationsLoaded) {
|
|
2762
|
+
const invitations = this.getCreatedInvitations().filter((i) => i.persistent);
|
|
2763
|
+
return {
|
|
2764
|
+
invitations
|
|
2765
|
+
};
|
|
2766
|
+
}
|
|
2767
|
+
try {
|
|
2768
|
+
const persistentInvitations = this._metadataStore.getInvitations();
|
|
2769
|
+
const freshInvitations = persistentInvitations.filter((invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
|
|
2770
|
+
const loadTasks = freshInvitations.map((persistentInvitation) => {
|
|
2771
|
+
(0, import_invariant8.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2772
|
+
F: __dxlog_file9,
|
|
2773
|
+
L: 97,
|
|
2774
|
+
S: this,
|
|
2775
|
+
A: [
|
|
2776
|
+
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
2777
|
+
"'invitation already exists'"
|
|
2778
|
+
]
|
|
2779
|
+
});
|
|
2780
|
+
return this.createInvitation({
|
|
2781
|
+
...persistentInvitation,
|
|
2782
|
+
persistent: false
|
|
2783
|
+
});
|
|
2784
|
+
});
|
|
2785
|
+
const cInvitations = await Promise.all(loadTasks);
|
|
2786
|
+
return {
|
|
2787
|
+
invitations: cInvitations.map((invitation) => invitation.get())
|
|
2788
|
+
};
|
|
2789
|
+
} catch (err) {
|
|
2790
|
+
import_log7.log.catch(err, void 0, {
|
|
2791
|
+
F: __dxlog_file9,
|
|
2792
|
+
L: 104,
|
|
2793
|
+
S: this,
|
|
2794
|
+
C: (f, a) => f(...a)
|
|
2795
|
+
});
|
|
2796
|
+
return {
|
|
2797
|
+
invitations: []
|
|
2798
|
+
};
|
|
2799
|
+
} finally {
|
|
2800
|
+
this._persistentInvitationsLoadedEvent.emit();
|
|
2801
|
+
this._persistentInvitationsLoaded = true;
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
acceptInvitation(request) {
|
|
2805
|
+
const options = request.invitation;
|
|
2806
|
+
const existingInvitation = this._acceptInvitations.get(options.invitationId);
|
|
2807
|
+
if (existingInvitation) {
|
|
2808
|
+
return existingInvitation;
|
|
2809
|
+
}
|
|
2810
|
+
const handler = this._getHandler(options);
|
|
2811
|
+
const invitation = this._invitationsHandler.acceptInvitation(handler, options, request.deviceProfile);
|
|
2812
|
+
this._acceptInvitations.set(invitation.get().invitationId, invitation);
|
|
2813
|
+
this.invitationAccepted.emit(invitation.get());
|
|
2814
|
+
this._onInvitationComplete(invitation, () => {
|
|
2815
|
+
this._acceptInvitations.delete(invitation.get().invitationId);
|
|
2816
|
+
this.removedAccepted.emit(invitation.get());
|
|
2817
|
+
});
|
|
2818
|
+
return invitation;
|
|
2819
|
+
}
|
|
2820
|
+
async authenticate({ invitationId, authCode }) {
|
|
2821
|
+
(0, import_log7.log)("authenticating...", void 0, {
|
|
2822
|
+
F: __dxlog_file9,
|
|
2823
|
+
L: 133,
|
|
2824
|
+
S: this,
|
|
2825
|
+
C: (f, a) => f(...a)
|
|
2826
|
+
});
|
|
2827
|
+
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2828
|
+
F: __dxlog_file9,
|
|
2829
|
+
L: 134,
|
|
2830
|
+
S: this,
|
|
2831
|
+
A: [
|
|
2832
|
+
"invitationId",
|
|
2833
|
+
""
|
|
2834
|
+
]
|
|
2835
|
+
});
|
|
2836
|
+
const observable = this._acceptInvitations.get(invitationId);
|
|
2837
|
+
if (!observable) {
|
|
2838
|
+
import_log7.log.warn("invalid invitation", {
|
|
2839
|
+
invitationId
|
|
2840
|
+
}, {
|
|
2841
|
+
F: __dxlog_file9,
|
|
2842
|
+
L: 137,
|
|
2843
|
+
S: this,
|
|
2844
|
+
C: (f, a) => f(...a)
|
|
2845
|
+
});
|
|
2846
|
+
} else {
|
|
2847
|
+
await observable.authenticate(authCode);
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
async cancelInvitation({ invitationId }) {
|
|
2851
|
+
(0, import_log7.log)("cancelInvitation...", {
|
|
2852
|
+
invitationId
|
|
2853
|
+
}, {
|
|
2854
|
+
F: __dxlog_file9,
|
|
2855
|
+
L: 144,
|
|
2856
|
+
S: this,
|
|
2857
|
+
C: (f, a) => f(...a)
|
|
2858
|
+
});
|
|
2859
|
+
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2860
|
+
F: __dxlog_file9,
|
|
2861
|
+
L: 145,
|
|
2862
|
+
S: this,
|
|
2863
|
+
A: [
|
|
2864
|
+
"invitationId",
|
|
2865
|
+
""
|
|
2866
|
+
]
|
|
2867
|
+
});
|
|
2868
|
+
const created = this._createInvitations.get(invitationId);
|
|
2869
|
+
if (created) {
|
|
2870
|
+
if (created.get().persistent) {
|
|
2871
|
+
await this._metadataStore.removeInvitation(invitationId);
|
|
2872
|
+
}
|
|
2873
|
+
await created.cancel();
|
|
2874
|
+
this._createInvitations.delete(invitationId);
|
|
2875
|
+
this.removedCreated.emit(created.get());
|
|
2876
|
+
return;
|
|
2877
|
+
}
|
|
2878
|
+
const accepted = this._acceptInvitations.get(invitationId);
|
|
2879
|
+
if (accepted) {
|
|
2880
|
+
await accepted.cancel();
|
|
2881
|
+
this._acceptInvitations.delete(invitationId);
|
|
2882
|
+
this.removedAccepted.emit(accepted.get());
|
|
2883
|
+
}
|
|
2884
|
+
}
|
|
2885
|
+
getCreatedInvitations() {
|
|
2886
|
+
return [
|
|
2887
|
+
...this._createInvitations.values()
|
|
2888
|
+
].map((i) => i.get());
|
|
2889
|
+
}
|
|
2890
|
+
getAcceptedInvitations() {
|
|
2891
|
+
return [
|
|
2892
|
+
...this._acceptInvitations.values()
|
|
2893
|
+
].map((i) => i.get());
|
|
2894
|
+
}
|
|
2895
|
+
onPersistentInvitationsLoaded(ctx, callback) {
|
|
2896
|
+
if (this._persistentInvitationsLoaded) {
|
|
2897
|
+
callback();
|
|
2898
|
+
} else {
|
|
2899
|
+
this._persistentInvitationsLoadedEvent.once(ctx, () => callback());
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
_createInvitation(protocol, options) {
|
|
2903
|
+
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 ?? {};
|
|
2904
|
+
const authCode = options?.authCode ?? (authMethod === import_services7.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials9.generatePasscode)(import_client_protocol3.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
2905
|
+
return {
|
|
2906
|
+
invitationId,
|
|
2907
|
+
type,
|
|
2908
|
+
authMethod,
|
|
2909
|
+
state,
|
|
2910
|
+
swarmKey,
|
|
2911
|
+
authCode,
|
|
2912
|
+
timeout,
|
|
2913
|
+
persistent: persistent && type !== import_services7.Invitation.Type.DELEGATED,
|
|
2914
|
+
guestKeypair: guestKeypair ?? (authMethod === import_services7.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
|
|
2915
|
+
created,
|
|
2916
|
+
lifetime,
|
|
2917
|
+
multiUse,
|
|
2918
|
+
delegationCredentialId: options?.delegationCredentialId,
|
|
2919
|
+
...protocol.getInvitationContext()
|
|
2920
|
+
};
|
|
2921
|
+
}
|
|
2922
|
+
_createObservableInvitation(handler, invitation) {
|
|
2923
|
+
const stream = new import_async9.PushStream();
|
|
2924
|
+
const ctx = new import_context6.Context({
|
|
2925
|
+
onError: (err) => {
|
|
2926
|
+
stream.error(err);
|
|
2927
|
+
void ctx.dispose();
|
|
2928
|
+
}
|
|
2929
|
+
});
|
|
2930
|
+
ctx.onDispose(() => {
|
|
2931
|
+
(0, import_log7.log)("complete", {
|
|
2932
|
+
...handler.toJSON()
|
|
2933
|
+
}, {
|
|
2934
|
+
F: __dxlog_file9,
|
|
2935
|
+
L: 228,
|
|
2936
|
+
S: this,
|
|
2937
|
+
C: (f, a) => f(...a)
|
|
2938
|
+
});
|
|
2939
|
+
stream.complete();
|
|
2940
|
+
});
|
|
2941
|
+
const observableInvitation = new import_client_protocol3.CancellableInvitation({
|
|
2942
|
+
initialInvitation: invitation,
|
|
2943
|
+
subscriber: stream.observable,
|
|
2944
|
+
onCancel: async () => {
|
|
2945
|
+
stream.next({
|
|
2946
|
+
...invitation,
|
|
2947
|
+
state: import_services7.Invitation.State.CANCELLED
|
|
2948
|
+
});
|
|
2949
|
+
await ctx.dispose();
|
|
2950
|
+
}
|
|
2951
|
+
});
|
|
2952
|
+
return {
|
|
2953
|
+
ctx,
|
|
2954
|
+
stream,
|
|
2955
|
+
observableInvitation
|
|
2956
|
+
};
|
|
2957
|
+
}
|
|
2958
|
+
async _persistIfRequired(handler, changeStream, invitation) {
|
|
2959
|
+
if (invitation.type === import_services7.Invitation.Type.DELEGATED && invitation.delegationCredentialId == null) {
|
|
2960
|
+
const delegationCredentialId = await handler.delegate(invitation);
|
|
2961
|
+
changeStream.next({
|
|
2962
|
+
...invitation,
|
|
2963
|
+
delegationCredentialId
|
|
2964
|
+
});
|
|
2965
|
+
} else if (invitation.persistent) {
|
|
2966
|
+
await this._metadataStore.addInvitation(invitation);
|
|
2967
|
+
this.saved.emit(invitation);
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
async _safeDeleteInvitation(invitation) {
|
|
2971
|
+
try {
|
|
2972
|
+
await this._metadataStore.removeInvitation(invitation.invitationId);
|
|
2973
|
+
} catch (err) {
|
|
2974
|
+
import_log7.log.catch(err, void 0, {
|
|
2975
|
+
F: __dxlog_file9,
|
|
2976
|
+
L: 260,
|
|
2977
|
+
S: this,
|
|
2978
|
+
C: (f, a) => f(...a)
|
|
2979
|
+
});
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
2982
|
+
_onInvitationComplete(invitation, callback) {
|
|
2983
|
+
invitation.subscribe(() => {
|
|
2984
|
+
}, () => {
|
|
2985
|
+
}, callback);
|
|
2986
|
+
}
|
|
2987
|
+
};
|
|
2861
2988
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
2862
2989
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2863
2990
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -2942,7 +3069,7 @@ var AutomergeSpaceState = class {
|
|
|
2942
3069
|
this._isProcessingRootDocs = false;
|
|
2943
3070
|
}
|
|
2944
3071
|
async processCredential(credential) {
|
|
2945
|
-
if (!(0,
|
|
3072
|
+
if (!(0, import_credentials11.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
2946
3073
|
return;
|
|
2947
3074
|
}
|
|
2948
3075
|
this.lastEpoch = credential;
|
|
@@ -2977,8 +3104,8 @@ var NotarizationPlugin = class {
|
|
|
2977
3104
|
this._ctx = new import_context8.Context();
|
|
2978
3105
|
this._extensionOpened = new import_async12.Event();
|
|
2979
3106
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2980
|
-
this._processedCredentials = new import_util5.ComplexSet(
|
|
2981
|
-
this._processCredentialsTriggers = new import_util5.ComplexMap(
|
|
3107
|
+
this._processedCredentials = new import_util5.ComplexSet(import_keys9.PublicKey.hash);
|
|
3108
|
+
this._processCredentialsTriggers = new import_util5.ComplexMap(import_keys9.PublicKey.hash);
|
|
2982
3109
|
}
|
|
2983
3110
|
get hasWriter() {
|
|
2984
3111
|
return !!this._writer;
|
|
@@ -3242,7 +3369,7 @@ var DataSpace = class {
|
|
|
3242
3369
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3243
3370
|
this._cache = void 0;
|
|
3244
3371
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
3245
|
-
this._state =
|
|
3372
|
+
this._state = import_services8.SpaceState.CLOSED;
|
|
3246
3373
|
this.error = void 0;
|
|
3247
3374
|
this.stateUpdate = new import_async10.Event();
|
|
3248
3375
|
this.metrics = {};
|
|
@@ -3257,14 +3384,14 @@ var DataSpace = class {
|
|
|
3257
3384
|
this._callbacks = params.callbacks ?? {};
|
|
3258
3385
|
this._automergeHost = params.automergeHost;
|
|
3259
3386
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
3260
|
-
trustedKeysProvider: () => new import_util4.ComplexSet(
|
|
3387
|
+
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
3388
|
update: this._inner.stateUpdate,
|
|
3262
|
-
authTimeout:
|
|
3389
|
+
authTimeout: import_client_protocol4.AUTH_TIMEOUT
|
|
3263
3390
|
});
|
|
3264
3391
|
this._cache = params.cache;
|
|
3265
3392
|
this._state = params.initialState;
|
|
3266
3393
|
(0, import_log8.log)("new state", {
|
|
3267
|
-
state:
|
|
3394
|
+
state: import_services8.SpaceState[this._state]
|
|
3268
3395
|
}, {
|
|
3269
3396
|
F: __dxlog_file11,
|
|
3270
3397
|
L: 140,
|
|
@@ -3312,9 +3439,9 @@ var DataSpace = class {
|
|
|
3312
3439
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3313
3440
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3314
3441
|
await this._inner.open(new import_context7.Context());
|
|
3315
|
-
this._state =
|
|
3442
|
+
this._state = import_services8.SpaceState.CONTROL_ONLY;
|
|
3316
3443
|
(0, import_log8.log)("new state", {
|
|
3317
|
-
state:
|
|
3444
|
+
state: import_services8.SpaceState[this._state]
|
|
3318
3445
|
}, {
|
|
3319
3446
|
F: __dxlog_file11,
|
|
3320
3447
|
L: 198,
|
|
@@ -3330,9 +3457,9 @@ var DataSpace = class {
|
|
|
3330
3457
|
}
|
|
3331
3458
|
async _close() {
|
|
3332
3459
|
await this._callbacks.beforeClose?.();
|
|
3333
|
-
this._state =
|
|
3460
|
+
this._state = import_services8.SpaceState.CLOSED;
|
|
3334
3461
|
(0, import_log8.log)("new state", {
|
|
3335
|
-
state:
|
|
3462
|
+
state: import_services8.SpaceState[this._state]
|
|
3336
3463
|
}, {
|
|
3337
3464
|
F: __dxlog_file11,
|
|
3338
3465
|
L: 212,
|
|
@@ -3379,9 +3506,9 @@ var DataSpace = class {
|
|
|
3379
3506
|
S: this,
|
|
3380
3507
|
C: (f, a) => f(...a)
|
|
3381
3508
|
});
|
|
3382
|
-
this._state =
|
|
3509
|
+
this._state = import_services8.SpaceState.ERROR;
|
|
3383
3510
|
(0, import_log8.log)("new state", {
|
|
3384
|
-
state:
|
|
3511
|
+
state: import_services8.SpaceState[this._state]
|
|
3385
3512
|
}, {
|
|
3386
3513
|
F: __dxlog_file11,
|
|
3387
3514
|
L: 251,
|
|
@@ -3396,12 +3523,12 @@ var DataSpace = class {
|
|
|
3396
3523
|
});
|
|
3397
3524
|
}
|
|
3398
3525
|
async initializeDataPipeline() {
|
|
3399
|
-
if (this._state !==
|
|
3526
|
+
if (this._state !== import_services8.SpaceState.CONTROL_ONLY) {
|
|
3400
3527
|
throw new import_protocols7.SystemError("Invalid operation");
|
|
3401
3528
|
}
|
|
3402
|
-
this._state =
|
|
3529
|
+
this._state = import_services8.SpaceState.INITIALIZING;
|
|
3403
3530
|
(0, import_log8.log)("new state", {
|
|
3404
|
-
state:
|
|
3531
|
+
state: import_services8.SpaceState[this._state]
|
|
3405
3532
|
}, {
|
|
3406
3533
|
F: __dxlog_file11,
|
|
3407
3534
|
L: 267,
|
|
@@ -3419,9 +3546,9 @@ var DataSpace = class {
|
|
|
3419
3546
|
C: (f, a) => f(...a)
|
|
3420
3547
|
});
|
|
3421
3548
|
await this._callbacks.beforeReady?.();
|
|
3422
|
-
this._state =
|
|
3549
|
+
this._state = import_services8.SpaceState.READY;
|
|
3423
3550
|
(0, import_log8.log)("new state", {
|
|
3424
|
-
state:
|
|
3551
|
+
state: import_services8.SpaceState[this._state]
|
|
3425
3552
|
}, {
|
|
3426
3553
|
F: __dxlog_file11,
|
|
3427
3554
|
L: 283,
|
|
@@ -3467,7 +3594,7 @@ var DataSpace = class {
|
|
|
3467
3594
|
spaceKey: this.key,
|
|
3468
3595
|
deviceKey: this._signingContext.deviceKey,
|
|
3469
3596
|
identityKey: this._signingContext.identityKey,
|
|
3470
|
-
designation:
|
|
3597
|
+
designation: import_credentials10.AdmittedFeed.Designation.CONTROL
|
|
3471
3598
|
}
|
|
3472
3599
|
}));
|
|
3473
3600
|
}
|
|
@@ -3484,7 +3611,7 @@ var DataSpace = class {
|
|
|
3484
3611
|
spaceKey: this.key,
|
|
3485
3612
|
deviceKey: this._signingContext.deviceKey,
|
|
3486
3613
|
identityKey: this._signingContext.identityKey,
|
|
3487
|
-
designation:
|
|
3614
|
+
designation: import_credentials10.AdmittedFeed.Designation.DATA
|
|
3488
3615
|
}
|
|
3489
3616
|
}));
|
|
3490
3617
|
}
|
|
@@ -3561,7 +3688,7 @@ var DataSpace = class {
|
|
|
3561
3688
|
let epoch;
|
|
3562
3689
|
switch (options?.migration) {
|
|
3563
3690
|
case void 0:
|
|
3564
|
-
case
|
|
3691
|
+
case import_services8.CreateEpochRequest.Migration.NONE:
|
|
3565
3692
|
{
|
|
3566
3693
|
epoch = {
|
|
3567
3694
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
@@ -3571,7 +3698,7 @@ var DataSpace = class {
|
|
|
3571
3698
|
};
|
|
3572
3699
|
}
|
|
3573
3700
|
break;
|
|
3574
|
-
case
|
|
3701
|
+
case import_services8.CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3575
3702
|
{
|
|
3576
3703
|
const document = this._automergeHost.repo.create();
|
|
3577
3704
|
epoch = {
|
|
@@ -3582,7 +3709,7 @@ var DataSpace = class {
|
|
|
3582
3709
|
};
|
|
3583
3710
|
}
|
|
3584
3711
|
break;
|
|
3585
|
-
case
|
|
3712
|
+
case import_services8.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
3586
3713
|
{
|
|
3587
3714
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3588
3715
|
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
@@ -3605,7 +3732,7 @@ var DataSpace = class {
|
|
|
3605
3732
|
};
|
|
3606
3733
|
}
|
|
3607
3734
|
break;
|
|
3608
|
-
case
|
|
3735
|
+
case import_services8.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
3609
3736
|
{
|
|
3610
3737
|
import_log8.log.info("Fragmenting", void 0, {
|
|
3611
3738
|
F: __dxlog_file11,
|
|
@@ -3617,7 +3744,7 @@ var DataSpace = class {
|
|
|
3617
3744
|
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3618
3745
|
await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3619
3746
|
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3620
|
-
const properties = objects.find(([_, value]) => value.system.type?.itemId ===
|
|
3747
|
+
const properties = objects.find(([_, value]) => value.system.type?.itemId === import_echo_schema.TYPE_PROPERTIES);
|
|
3621
3748
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3622
3749
|
(0, import_invariant9.invariant)(properties, "Properties not found", {
|
|
3623
3750
|
F: __dxlog_file11,
|
|
@@ -3688,22 +3815,22 @@ var DataSpace = class {
|
|
|
3688
3815
|
]));
|
|
3689
3816
|
}
|
|
3690
3817
|
async activate() {
|
|
3691
|
-
if (this._state !==
|
|
3818
|
+
if (this._state !== import_services8.SpaceState.INACTIVE) {
|
|
3692
3819
|
return;
|
|
3693
3820
|
}
|
|
3694
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3821
|
+
await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.ACTIVE);
|
|
3695
3822
|
await this._open();
|
|
3696
3823
|
this.initializeDataPipelineAsync();
|
|
3697
3824
|
}
|
|
3698
3825
|
async deactivate() {
|
|
3699
|
-
if (this._state ===
|
|
3826
|
+
if (this._state === import_services8.SpaceState.INACTIVE) {
|
|
3700
3827
|
return;
|
|
3701
3828
|
}
|
|
3702
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3829
|
+
await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.INACTIVE);
|
|
3703
3830
|
await this._close();
|
|
3704
|
-
this._state =
|
|
3831
|
+
this._state = import_services8.SpaceState.INACTIVE;
|
|
3705
3832
|
(0, import_log8.log)("new state", {
|
|
3706
|
-
state:
|
|
3833
|
+
state: import_services8.SpaceState[this._state]
|
|
3707
3834
|
}, {
|
|
3708
3835
|
F: __dxlog_file11,
|
|
3709
3836
|
L: 531,
|
|
@@ -3721,7 +3848,7 @@ _ts_decorate4([
|
|
|
3721
3848
|
], DataSpace.prototype, "key", null);
|
|
3722
3849
|
_ts_decorate4([
|
|
3723
3850
|
import_tracing4.trace.info({
|
|
3724
|
-
enum:
|
|
3851
|
+
enum: import_services8.SpaceState
|
|
3725
3852
|
})
|
|
3726
3853
|
], DataSpace.prototype, "state", null);
|
|
3727
3854
|
_ts_decorate4([
|
|
@@ -3760,7 +3887,7 @@ DataSpace = _ts_decorate4([
|
|
|
3760
3887
|
], DataSpace);
|
|
3761
3888
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
3762
3889
|
const credentials = [
|
|
3763
|
-
await (0,
|
|
3890
|
+
await (0, import_credentials13.createCredential)({
|
|
3764
3891
|
signer: keyring,
|
|
3765
3892
|
issuer: space.key,
|
|
3766
3893
|
subject: space.key,
|
|
@@ -3769,14 +3896,14 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3769
3896
|
spaceKey: space.key
|
|
3770
3897
|
}
|
|
3771
3898
|
}),
|
|
3772
|
-
await (0,
|
|
3899
|
+
await (0, import_credentials13.createCredential)({
|
|
3773
3900
|
signer: keyring,
|
|
3774
3901
|
issuer: space.key,
|
|
3775
3902
|
subject: signingContext.identityKey,
|
|
3776
3903
|
assertion: {
|
|
3777
3904
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
3778
3905
|
spaceKey: space.key,
|
|
3779
|
-
role:
|
|
3906
|
+
role: import_credentials14.SpaceMember.Role.ADMIN,
|
|
3780
3907
|
profile: signingContext.getProfile(),
|
|
3781
3908
|
genesisFeedKey: space.controlFeedKey ?? (0, import_debug4.failUndefined)()
|
|
3782
3909
|
}
|
|
@@ -3788,7 +3915,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3788
3915
|
spaceKey: space.key,
|
|
3789
3916
|
identityKey: signingContext.identityKey,
|
|
3790
3917
|
deviceKey: signingContext.deviceKey,
|
|
3791
|
-
designation:
|
|
3918
|
+
designation: import_credentials14.AdmittedFeed.Designation.CONTROL
|
|
3792
3919
|
}
|
|
3793
3920
|
}),
|
|
3794
3921
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3798,7 +3925,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3798
3925
|
spaceKey: space.key,
|
|
3799
3926
|
identityKey: signingContext.identityKey,
|
|
3800
3927
|
deviceKey: signingContext.deviceKey,
|
|
3801
|
-
designation:
|
|
3928
|
+
designation: import_credentials14.AdmittedFeed.Designation.DATA
|
|
3802
3929
|
}
|
|
3803
3930
|
}),
|
|
3804
3931
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3836,18 +3963,19 @@ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
|
|
|
3836
3963
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3837
3964
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3838
3965
|
var DataSpaceManager = class {
|
|
3839
|
-
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _automergeHost, params) {
|
|
3966
|
+
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _automergeHost, _invitationsManager, params) {
|
|
3840
3967
|
this._spaceManager = _spaceManager;
|
|
3841
3968
|
this._metadataStore = _metadataStore;
|
|
3842
3969
|
this._keyring = _keyring;
|
|
3843
3970
|
this._signingContext = _signingContext;
|
|
3844
3971
|
this._feedStore = _feedStore;
|
|
3845
3972
|
this._automergeHost = _automergeHost;
|
|
3973
|
+
this._invitationsManager = _invitationsManager;
|
|
3846
3974
|
this._ctx = new import_context9.Context();
|
|
3847
3975
|
this.updated = new import_async13.Event();
|
|
3848
|
-
this._spaces = new import_util6.ComplexMap(
|
|
3976
|
+
this._spaces = new import_util6.ComplexMap(import_keys10.PublicKey.hash);
|
|
3849
3977
|
this._isOpen = false;
|
|
3850
|
-
this._instanceId =
|
|
3978
|
+
this._instanceId = import_keys10.PublicKey.random().toHex();
|
|
3851
3979
|
const { spaceMemberPresenceAnnounceInterval = PRESENCE_ANNOUNCE_INTERVAL, spaceMemberPresenceOfflineTimeout = PRESENCE_OFFLINE_TIMEOUT } = params ?? {};
|
|
3852
3980
|
this._spaceMemberPresenceAnnounceInterval = spaceMemberPresenceAnnounceInterval;
|
|
3853
3981
|
this._spaceMemberPresenceOfflineTimeout = spaceMemberPresenceOfflineTimeout;
|
|
@@ -3859,7 +3987,7 @@ var DataSpaceManager = class {
|
|
|
3859
3987
|
async open() {
|
|
3860
3988
|
(0, import_log10.log)("open", void 0, {
|
|
3861
3989
|
F: __dxlog_file12,
|
|
3862
|
-
L:
|
|
3990
|
+
L: 101,
|
|
3863
3991
|
S: this,
|
|
3864
3992
|
C: (f, a) => f(...a)
|
|
3865
3993
|
});
|
|
@@ -3867,7 +3995,7 @@ var DataSpaceManager = class {
|
|
|
3867
3995
|
id: this._instanceId
|
|
3868
3996
|
}), {
|
|
3869
3997
|
F: __dxlog_file12,
|
|
3870
|
-
L:
|
|
3998
|
+
L: 102,
|
|
3871
3999
|
S: this,
|
|
3872
4000
|
C: (f, a) => f(...a)
|
|
3873
4001
|
});
|
|
@@ -3875,7 +4003,7 @@ var DataSpaceManager = class {
|
|
|
3875
4003
|
spaces: this._metadataStore.spaces.length
|
|
3876
4004
|
}, {
|
|
3877
4005
|
F: __dxlog_file12,
|
|
3878
|
-
L:
|
|
4006
|
+
L: 103,
|
|
3879
4007
|
S: this,
|
|
3880
4008
|
C: (f, a) => f(...a)
|
|
3881
4009
|
});
|
|
@@ -3885,7 +4013,7 @@ var DataSpaceManager = class {
|
|
|
3885
4013
|
spaceMetadata
|
|
3886
4014
|
}, {
|
|
3887
4015
|
F: __dxlog_file12,
|
|
3888
|
-
L:
|
|
4016
|
+
L: 107,
|
|
3889
4017
|
S: this,
|
|
3890
4018
|
C: (f, a) => f(...a)
|
|
3891
4019
|
});
|
|
@@ -3896,7 +4024,7 @@ var DataSpaceManager = class {
|
|
|
3896
4024
|
err
|
|
3897
4025
|
}, {
|
|
3898
4026
|
F: __dxlog_file12,
|
|
3899
|
-
L:
|
|
4027
|
+
L: 110,
|
|
3900
4028
|
S: this,
|
|
3901
4029
|
C: (f, a) => f(...a)
|
|
3902
4030
|
});
|
|
@@ -3905,7 +4033,7 @@ var DataSpaceManager = class {
|
|
|
3905
4033
|
this._isOpen = true;
|
|
3906
4034
|
this.updated.emit();
|
|
3907
4035
|
for (const space of this._spaces.values()) {
|
|
3908
|
-
if (space.state !==
|
|
4036
|
+
if (space.state !== import_services9.SpaceState.INACTIVE) {
|
|
3909
4037
|
space.initializeDataPipelineAsync();
|
|
3910
4038
|
}
|
|
3911
4039
|
}
|
|
@@ -3913,7 +4041,7 @@ var DataSpaceManager = class {
|
|
|
3913
4041
|
id: this._instanceId
|
|
3914
4042
|
}), {
|
|
3915
4043
|
F: __dxlog_file12,
|
|
3916
|
-
L:
|
|
4044
|
+
L: 123,
|
|
3917
4045
|
S: this,
|
|
3918
4046
|
C: (f, a) => f(...a)
|
|
3919
4047
|
});
|
|
@@ -3921,7 +4049,7 @@ var DataSpaceManager = class {
|
|
|
3921
4049
|
async close() {
|
|
3922
4050
|
(0, import_log10.log)("close", void 0, {
|
|
3923
4051
|
F: __dxlog_file12,
|
|
3924
|
-
L:
|
|
4052
|
+
L: 128,
|
|
3925
4053
|
S: this,
|
|
3926
4054
|
C: (f, a) => f(...a)
|
|
3927
4055
|
});
|
|
@@ -3937,7 +4065,7 @@ var DataSpaceManager = class {
|
|
|
3937
4065
|
async createSpace() {
|
|
3938
4066
|
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3939
4067
|
F: __dxlog_file12,
|
|
3940
|
-
L:
|
|
4068
|
+
L: 141,
|
|
3941
4069
|
S: this,
|
|
3942
4070
|
A: [
|
|
3943
4071
|
"this._isOpen",
|
|
@@ -3952,13 +4080,13 @@ var DataSpaceManager = class {
|
|
|
3952
4080
|
genesisFeedKey: controlFeedKey,
|
|
3953
4081
|
controlFeedKey,
|
|
3954
4082
|
dataFeedKey,
|
|
3955
|
-
state:
|
|
4083
|
+
state: import_services9.SpaceState.ACTIVE
|
|
3956
4084
|
};
|
|
3957
4085
|
(0, import_log10.log)("creating space...", {
|
|
3958
4086
|
spaceKey
|
|
3959
4087
|
}, {
|
|
3960
4088
|
F: __dxlog_file12,
|
|
3961
|
-
L:
|
|
4089
|
+
L: 153,
|
|
3962
4090
|
S: this,
|
|
3963
4091
|
C: (f, a) => f(...a)
|
|
3964
4092
|
});
|
|
@@ -3972,9 +4100,9 @@ var DataSpaceManager = class {
|
|
|
3972
4100
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
|
|
3973
4101
|
await this._metadataStore.addSpace(metadata);
|
|
3974
4102
|
const memberCredential = credentials[1];
|
|
3975
|
-
(0, import_invariant11.invariant)((0,
|
|
4103
|
+
(0, import_invariant11.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3976
4104
|
F: __dxlog_file12,
|
|
3977
|
-
L:
|
|
4105
|
+
L: 166,
|
|
3978
4106
|
S: this,
|
|
3979
4107
|
A: [
|
|
3980
4108
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -3992,13 +4120,13 @@ var DataSpaceManager = class {
|
|
|
3992
4120
|
opts
|
|
3993
4121
|
}, {
|
|
3994
4122
|
F: __dxlog_file12,
|
|
3995
|
-
L:
|
|
4123
|
+
L: 178,
|
|
3996
4124
|
S: this,
|
|
3997
4125
|
C: (f, a) => f(...a)
|
|
3998
4126
|
});
|
|
3999
4127
|
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
4000
4128
|
F: __dxlog_file12,
|
|
4001
|
-
L:
|
|
4129
|
+
L: 179,
|
|
4002
4130
|
S: this,
|
|
4003
4131
|
A: [
|
|
4004
4132
|
"this._isOpen",
|
|
@@ -4007,7 +4135,7 @@ var DataSpaceManager = class {
|
|
|
4007
4135
|
});
|
|
4008
4136
|
(0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
4009
4137
|
F: __dxlog_file12,
|
|
4010
|
-
L:
|
|
4138
|
+
L: 180,
|
|
4011
4139
|
S: this,
|
|
4012
4140
|
A: [
|
|
4013
4141
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -4034,7 +4162,7 @@ var DataSpaceManager = class {
|
|
|
4034
4162
|
async waitUntilSpaceReady(spaceKey) {
|
|
4035
4163
|
await (0, import_context9.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
4036
4164
|
const space = this._spaces.get(spaceKey);
|
|
4037
|
-
return !!space && space.state ===
|
|
4165
|
+
return !!space && space.state === import_services9.SpaceState.READY;
|
|
4038
4166
|
}));
|
|
4039
4167
|
}
|
|
4040
4168
|
async _constructSpace(metadata) {
|
|
@@ -4042,7 +4170,7 @@ var DataSpaceManager = class {
|
|
|
4042
4170
|
metadata
|
|
4043
4171
|
}, {
|
|
4044
4172
|
F: __dxlog_file12,
|
|
4045
|
-
L:
|
|
4173
|
+
L: 213,
|
|
4046
4174
|
S: this,
|
|
4047
4175
|
C: (f, a) => f(...a)
|
|
4048
4176
|
});
|
|
@@ -4080,18 +4208,21 @@ var DataSpaceManager = class {
|
|
|
4080
4208
|
onAuthFailure: () => {
|
|
4081
4209
|
import_log10.log.warn("auth failure", void 0, {
|
|
4082
4210
|
F: __dxlog_file12,
|
|
4083
|
-
L:
|
|
4211
|
+
L: 250,
|
|
4084
4212
|
S: this,
|
|
4085
4213
|
C: (f, a) => f(...a)
|
|
4086
4214
|
});
|
|
4087
4215
|
},
|
|
4088
|
-
memberKey: this._signingContext.identityKey
|
|
4216
|
+
memberKey: this._signingContext.identityKey,
|
|
4217
|
+
onDelegatedInvitationStatusChange: (invitation, isActive) => {
|
|
4218
|
+
return this._handleInvitationStatusChange(dataSpace, invitation, isActive);
|
|
4219
|
+
}
|
|
4089
4220
|
});
|
|
4090
4221
|
controlFeed && await space.setControlFeed(controlFeed);
|
|
4091
4222
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
4092
4223
|
const dataSpace = new DataSpace({
|
|
4093
4224
|
inner: space,
|
|
4094
|
-
initialState: metadata.state ===
|
|
4225
|
+
initialState: metadata.state === import_services9.SpaceState.INACTIVE ? import_services9.SpaceState.INACTIVE : import_services9.SpaceState.CLOSED,
|
|
4095
4226
|
metadataStore: this._metadataStore,
|
|
4096
4227
|
gossip,
|
|
4097
4228
|
presence,
|
|
@@ -4104,7 +4235,7 @@ var DataSpaceManager = class {
|
|
|
4104
4235
|
space: space.key
|
|
4105
4236
|
}, {
|
|
4106
4237
|
F: __dxlog_file12,
|
|
4107
|
-
L:
|
|
4238
|
+
L: 271,
|
|
4108
4239
|
S: this,
|
|
4109
4240
|
C: (f, a) => f(...a)
|
|
4110
4241
|
});
|
|
@@ -4115,11 +4246,14 @@ var DataSpaceManager = class {
|
|
|
4115
4246
|
open: this._isOpen
|
|
4116
4247
|
}, {
|
|
4117
4248
|
F: __dxlog_file12,
|
|
4118
|
-
L:
|
|
4249
|
+
L: 274,
|
|
4119
4250
|
S: this,
|
|
4120
4251
|
C: (f, a) => f(...a)
|
|
4121
4252
|
});
|
|
4122
4253
|
if (this._isOpen) {
|
|
4254
|
+
await this._createDelegatedInvitations(dataSpace, [
|
|
4255
|
+
...space.spaceState.invitations.entries()
|
|
4256
|
+
]);
|
|
4123
4257
|
this.updated.emit();
|
|
4124
4258
|
}
|
|
4125
4259
|
},
|
|
@@ -4128,7 +4262,7 @@ var DataSpaceManager = class {
|
|
|
4128
4262
|
space: space.key
|
|
4129
4263
|
}, {
|
|
4130
4264
|
F: __dxlog_file12,
|
|
4131
|
-
L:
|
|
4265
|
+
L: 281,
|
|
4132
4266
|
S: this,
|
|
4133
4267
|
C: (f, a) => f(...a)
|
|
4134
4268
|
});
|
|
@@ -4137,7 +4271,7 @@ var DataSpaceManager = class {
|
|
|
4137
4271
|
cache: metadata.cache,
|
|
4138
4272
|
automergeHost: this._automergeHost
|
|
4139
4273
|
});
|
|
4140
|
-
if (metadata.state !==
|
|
4274
|
+
if (metadata.state !== import_services9.SpaceState.INACTIVE) {
|
|
4141
4275
|
await dataSpace.open();
|
|
4142
4276
|
}
|
|
4143
4277
|
if (metadata.controlTimeframe) {
|
|
@@ -4146,6 +4280,41 @@ var DataSpaceManager = class {
|
|
|
4146
4280
|
this._spaces.set(metadata.key, dataSpace);
|
|
4147
4281
|
return dataSpace;
|
|
4148
4282
|
}
|
|
4283
|
+
async _handleInvitationStatusChange(dataSpace, delegatedInvitation, isActive) {
|
|
4284
|
+
if (dataSpace?.state !== import_services9.SpaceState.READY) {
|
|
4285
|
+
return;
|
|
4286
|
+
}
|
|
4287
|
+
if (isActive) {
|
|
4288
|
+
await this._createDelegatedInvitations(dataSpace, [
|
|
4289
|
+
[
|
|
4290
|
+
delegatedInvitation.credentialId,
|
|
4291
|
+
delegatedInvitation.invitation
|
|
4292
|
+
]
|
|
4293
|
+
]);
|
|
4294
|
+
} else {
|
|
4295
|
+
await this._invitationsManager.cancelInvitation(delegatedInvitation.invitation);
|
|
4296
|
+
}
|
|
4297
|
+
}
|
|
4298
|
+
async _createDelegatedInvitations(space, invitations) {
|
|
4299
|
+
const tasks = invitations.map(([credentialId, invitation]) => {
|
|
4300
|
+
return this._invitationsManager.createInvitation({
|
|
4301
|
+
type: import_services9.Invitation.Type.DELEGATED,
|
|
4302
|
+
kind: import_services9.Invitation.Kind.SPACE,
|
|
4303
|
+
spaceKey: space.key,
|
|
4304
|
+
authMethod: invitation.authMethod,
|
|
4305
|
+
invitationId: invitation.invitationId,
|
|
4306
|
+
swarmKey: invitation.swarmKey,
|
|
4307
|
+
guestKeypair: invitation.guestKey ? {
|
|
4308
|
+
publicKey: invitation.guestKey
|
|
4309
|
+
} : void 0,
|
|
4310
|
+
lifetime: invitation.expiresOn ? invitation.expiresOn.getTime() - Date.now() : void 0,
|
|
4311
|
+
multiUse: invitation.multiUse,
|
|
4312
|
+
delegationCredentialId: credentialId,
|
|
4313
|
+
persistent: false
|
|
4314
|
+
});
|
|
4315
|
+
});
|
|
4316
|
+
await Promise.all(tasks);
|
|
4317
|
+
}
|
|
4149
4318
|
};
|
|
4150
4319
|
_ts_decorate5([
|
|
4151
4320
|
import_async13.synchronized
|
|
@@ -4182,10 +4351,10 @@ var SpacesServiceImpl = class {
|
|
|
4182
4351
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4183
4352
|
if (state) {
|
|
4184
4353
|
switch (state) {
|
|
4185
|
-
case
|
|
4354
|
+
case import_services10.SpaceState.ACTIVE:
|
|
4186
4355
|
await space.activate();
|
|
4187
4356
|
break;
|
|
4188
|
-
case
|
|
4357
|
+
case import_services10.SpaceState.INACTIVE:
|
|
4189
4358
|
await space.deactivate();
|
|
4190
4359
|
break;
|
|
4191
4360
|
default:
|
|
@@ -4359,7 +4528,7 @@ var SpacesServiceImpl = class {
|
|
|
4359
4528
|
identityKey: member.key,
|
|
4360
4529
|
profile: member.profile ?? {}
|
|
4361
4530
|
},
|
|
4362
|
-
presence: member.removed ?
|
|
4531
|
+
presence: member.removed ? import_services10.SpaceMember.PresenceState.REMOVED : isMe || peers.length > 0 ? import_services10.SpaceMember.PresenceState.ONLINE : import_services10.SpaceMember.PresenceState.OFFLINE,
|
|
4363
4532
|
peerStates: peers
|
|
4364
4533
|
};
|
|
4365
4534
|
}),
|
|
@@ -4379,8 +4548,10 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
4379
4548
|
async function* loadDocuments(ids) {
|
|
4380
4549
|
for (const id of ids) {
|
|
4381
4550
|
const { documentId, objectId } = import_protocols12.idCodec.decode(id);
|
|
4382
|
-
const handle = automergeHost.repo.find(documentId);
|
|
4383
|
-
|
|
4551
|
+
const handle = automergeHost.repo.handles[documentId] ?? automergeHost.repo.find(documentId);
|
|
4552
|
+
if (!handle.isReady()) {
|
|
4553
|
+
await handle.whenReady();
|
|
4554
|
+
}
|
|
4384
4555
|
const doc = handle.docSync();
|
|
4385
4556
|
const hash = (0, import_automerge.getHeads)(doc).join("");
|
|
4386
4557
|
yield doc.objects?.[objectId] ? [
|
|
@@ -4393,57 +4564,6 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
4393
4564
|
}
|
|
4394
4565
|
}
|
|
4395
4566
|
);
|
|
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
4567
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
4448
4568
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4449
4569
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -4465,7 +4585,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4465
4585
|
this._runtimeParams = _runtimeParams;
|
|
4466
4586
|
this.initialized = new import_async15.Trigger();
|
|
4467
4587
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4468
|
-
this._instanceId =
|
|
4588
|
+
this._instanceId = import_keys11.PublicKey.random().toHex();
|
|
4469
4589
|
this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
|
|
4470
4590
|
this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
|
|
4471
4591
|
this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
|
|
@@ -4494,24 +4614,28 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4494
4614
|
this.automergeHost = new import_echo_pipeline4.AutomergeHost({
|
|
4495
4615
|
directory: storage.createDirectory("automerge"),
|
|
4496
4616
|
db: level.sublevel("automerge"),
|
|
4497
|
-
|
|
4617
|
+
storageCallbacks: (0, import_indexing.createStorageCallbacks)({
|
|
4618
|
+
host: () => this.automergeHost,
|
|
4619
|
+
metadata: this.indexMetadata
|
|
4620
|
+
})
|
|
4498
4621
|
});
|
|
4499
4622
|
this.indexer = new import_indexing.Indexer({
|
|
4623
|
+
db: this.level,
|
|
4500
4624
|
indexStore: new import_indexing.IndexStore({
|
|
4501
|
-
|
|
4625
|
+
db: level.sublevel("index-storage")
|
|
4502
4626
|
}),
|
|
4503
4627
|
metadataStore: this.indexMetadata,
|
|
4504
|
-
loadDocuments: createSelectedDocumentsIterator(this.automergeHost)
|
|
4505
|
-
getAllDocuments: createDocumentsIterator(this.automergeHost)
|
|
4628
|
+
loadDocuments: createSelectedDocumentsIterator(this.automergeHost)
|
|
4506
4629
|
});
|
|
4507
4630
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4508
|
-
this.
|
|
4631
|
+
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
4632
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
4509
4633
|
}
|
|
4510
4634
|
async _open(ctx) {
|
|
4511
4635
|
await this._checkStorageVersion();
|
|
4512
4636
|
(0, import_log12.log)("opening...", void 0, {
|
|
4513
4637
|
F: __dxlog_file14,
|
|
4514
|
-
L:
|
|
4638
|
+
L: 164,
|
|
4515
4639
|
S: this,
|
|
4516
4640
|
C: (f, a) => f(...a)
|
|
4517
4641
|
});
|
|
@@ -4519,7 +4643,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4519
4643
|
id: this._instanceId
|
|
4520
4644
|
}), {
|
|
4521
4645
|
F: __dxlog_file14,
|
|
4522
|
-
L:
|
|
4646
|
+
L: 165,
|
|
4523
4647
|
S: this,
|
|
4524
4648
|
C: (f, a) => f(...a)
|
|
4525
4649
|
});
|
|
@@ -4532,17 +4656,26 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4532
4656
|
if (this.identityManager.identity) {
|
|
4533
4657
|
await this._initialize(ctx);
|
|
4534
4658
|
}
|
|
4659
|
+
const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
|
|
4660
|
+
(0, import_log12.log)("loaded persistent invitations", {
|
|
4661
|
+
count: loadedInvitations.invitations?.length
|
|
4662
|
+
}, {
|
|
4663
|
+
F: __dxlog_file14,
|
|
4664
|
+
L: 178,
|
|
4665
|
+
S: this,
|
|
4666
|
+
C: (f, a) => f(...a)
|
|
4667
|
+
});
|
|
4535
4668
|
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.end({
|
|
4536
4669
|
id: this._instanceId
|
|
4537
4670
|
}), {
|
|
4538
4671
|
F: __dxlog_file14,
|
|
4539
|
-
L:
|
|
4672
|
+
L: 180,
|
|
4540
4673
|
S: this,
|
|
4541
4674
|
C: (f, a) => f(...a)
|
|
4542
4675
|
});
|
|
4543
4676
|
(0, import_log12.log)("opened", void 0, {
|
|
4544
4677
|
F: __dxlog_file14,
|
|
4545
|
-
L:
|
|
4678
|
+
L: 181,
|
|
4546
4679
|
S: this,
|
|
4547
4680
|
C: (f, a) => f(...a)
|
|
4548
4681
|
});
|
|
@@ -4550,7 +4683,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4550
4683
|
async _close() {
|
|
4551
4684
|
(0, import_log12.log)("closing...", void 0, {
|
|
4552
4685
|
F: __dxlog_file14,
|
|
4553
|
-
L:
|
|
4686
|
+
L: 185,
|
|
4554
4687
|
S: this,
|
|
4555
4688
|
C: (f, a) => f(...a)
|
|
4556
4689
|
});
|
|
@@ -4568,7 +4701,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4568
4701
|
await this.indexer.destroy();
|
|
4569
4702
|
(0, import_log12.log)("closed", void 0, {
|
|
4570
4703
|
F: __dxlog_file14,
|
|
4571
|
-
L:
|
|
4704
|
+
L: 198,
|
|
4572
4705
|
S: this,
|
|
4573
4706
|
C: (f, a) => f(...a)
|
|
4574
4707
|
});
|
|
@@ -4582,7 +4715,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4582
4715
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4583
4716
|
(0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4584
4717
|
F: __dxlog_file14,
|
|
4585
|
-
L:
|
|
4718
|
+
L: 209,
|
|
4586
4719
|
S: this,
|
|
4587
4720
|
A: [
|
|
4588
4721
|
"factory",
|
|
@@ -4614,7 +4747,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4614
4747
|
async _initialize(ctx) {
|
|
4615
4748
|
(0, import_log12.log)("initializing spaces...", void 0, {
|
|
4616
4749
|
F: __dxlog_file14,
|
|
4617
|
-
L:
|
|
4750
|
+
L: 240,
|
|
4618
4751
|
S: this,
|
|
4619
4752
|
C: (f, a) => f(...a)
|
|
4620
4753
|
});
|
|
@@ -4632,12 +4765,12 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4632
4765
|
});
|
|
4633
4766
|
}
|
|
4634
4767
|
};
|
|
4635
|
-
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
|
|
4768
|
+
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this.invitationsManager, this._runtimeParams);
|
|
4636
4769
|
await this.dataSpaceManager.open();
|
|
4637
|
-
this._handlerFactories.set(
|
|
4770
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.SPACE, (invitation) => {
|
|
4638
4771
|
(0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4639
4772
|
F: __dxlog_file14,
|
|
4640
|
-
L:
|
|
4773
|
+
L: 265,
|
|
4641
4774
|
S: this,
|
|
4642
4775
|
A: [
|
|
4643
4776
|
"this.dataSpaceManager",
|
|
@@ -4649,7 +4782,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4649
4782
|
this.initialized.wake();
|
|
4650
4783
|
this._deviceSpaceSync = {
|
|
4651
4784
|
processCredential: async (credential) => {
|
|
4652
|
-
const assertion = (0,
|
|
4785
|
+
const assertion = (0, import_credentials15.getCredentialAssertion)(credential);
|
|
4653
4786
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
4654
4787
|
return;
|
|
4655
4788
|
}
|
|
@@ -4661,7 +4794,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4661
4794
|
details: assertion
|
|
4662
4795
|
}, {
|
|
4663
4796
|
F: __dxlog_file14,
|
|
4664
|
-
L:
|
|
4797
|
+
L: 281,
|
|
4665
4798
|
S: this,
|
|
4666
4799
|
C: (f, a) => f(...a)
|
|
4667
4800
|
});
|
|
@@ -4672,7 +4805,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4672
4805
|
details: assertion
|
|
4673
4806
|
}, {
|
|
4674
4807
|
F: __dxlog_file14,
|
|
4675
|
-
L:
|
|
4808
|
+
L: 285,
|
|
4676
4809
|
S: this,
|
|
4677
4810
|
C: (f, a) => f(...a)
|
|
4678
4811
|
});
|
|
@@ -4683,7 +4816,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4683
4816
|
details: assertion
|
|
4684
4817
|
}, {
|
|
4685
4818
|
F: __dxlog_file14,
|
|
4686
|
-
L:
|
|
4819
|
+
L: 290,
|
|
4687
4820
|
S: this,
|
|
4688
4821
|
C: (f, a) => f(...a)
|
|
4689
4822
|
});
|
|
@@ -4694,7 +4827,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4694
4827
|
} catch (err) {
|
|
4695
4828
|
import_log12.log.catch(err, void 0, {
|
|
4696
4829
|
F: __dxlog_file14,
|
|
4697
|
-
L:
|
|
4830
|
+
L: 296,
|
|
4698
4831
|
S: this,
|
|
4699
4832
|
C: (f, a) => f(...a)
|
|
4700
4833
|
});
|
|
@@ -4736,26 +4869,26 @@ var ServiceRegistry = class {
|
|
|
4736
4869
|
delete this._handlers[name];
|
|
4737
4870
|
}
|
|
4738
4871
|
};
|
|
4739
|
-
var DXOS_VERSION = "0.4.10-main.
|
|
4872
|
+
var DXOS_VERSION = "0.4.10-main.e6ba7bc";
|
|
4740
4873
|
var getPlatform = () => {
|
|
4741
4874
|
if (process.browser) {
|
|
4742
4875
|
if (typeof window !== "undefined") {
|
|
4743
4876
|
const { userAgent } = window.navigator;
|
|
4744
4877
|
return {
|
|
4745
|
-
type:
|
|
4878
|
+
type: import_services13.Platform.PLATFORM_TYPE.BROWSER,
|
|
4746
4879
|
userAgent,
|
|
4747
4880
|
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
4748
4881
|
};
|
|
4749
4882
|
} else {
|
|
4750
4883
|
return {
|
|
4751
|
-
type:
|
|
4884
|
+
type: import_services13.Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
4752
4885
|
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
4753
4886
|
};
|
|
4754
4887
|
}
|
|
4755
4888
|
} else {
|
|
4756
4889
|
const { platform: platform2, version, arch } = process;
|
|
4757
4890
|
return {
|
|
4758
|
-
type:
|
|
4891
|
+
type: import_services13.Platform.PLATFORM_TYPE.NODE,
|
|
4759
4892
|
platform: platform2,
|
|
4760
4893
|
arch,
|
|
4761
4894
|
runtime: version,
|
|
@@ -4842,7 +4975,7 @@ var getSpaceStats = async (space) => {
|
|
|
4842
4975
|
const stats = {
|
|
4843
4976
|
key: space.key,
|
|
4844
4977
|
metrics: space.metrics,
|
|
4845
|
-
epochs: space.inner.spaceState.credentials.filter((0,
|
|
4978
|
+
epochs: space.inner.spaceState.credentials.filter((0, import_credentials16.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
4846
4979
|
...credential.subject.assertion,
|
|
4847
4980
|
id: credential.id
|
|
4848
4981
|
})),
|
|
@@ -4853,7 +4986,7 @@ var getSpaceStats = async (space) => {
|
|
|
4853
4986
|
displayName: member.assertion.profile?.displayName
|
|
4854
4987
|
}
|
|
4855
4988
|
},
|
|
4856
|
-
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ?
|
|
4989
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services12.SpaceMember.PresenceState.ONLINE : import_services12.SpaceMember.PresenceState.OFFLINE
|
|
4857
4990
|
})),
|
|
4858
4991
|
pipeline: {
|
|
4859
4992
|
// TODO(burdon): Pick properties from credentials if needed.
|
|
@@ -4917,9 +5050,9 @@ var DevicesServiceImpl = class {
|
|
|
4917
5050
|
const peerState = peers.find((peer) => peer.identityKey.equals(key));
|
|
4918
5051
|
return {
|
|
4919
5052
|
deviceKey: key,
|
|
4920
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ?
|
|
5053
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services16.DeviceKind.CURRENT : import_services16.DeviceKind.TRUSTED,
|
|
4921
5054
|
profile,
|
|
4922
|
-
presence: isMe ?
|
|
5055
|
+
presence: isMe ? import_services16.Device.PresenceState.ONLINE : peerState ? import_services16.Device.PresenceState.ONLINE : import_services16.Device.PresenceState.OFFLINE
|
|
4923
5056
|
};
|
|
4924
5057
|
})
|
|
4925
5058
|
});
|
|
@@ -5018,7 +5151,7 @@ var LoggingServiceImpl = class {
|
|
|
5018
5151
|
constructor() {
|
|
5019
5152
|
this._logs = new import_async18.Event();
|
|
5020
5153
|
this._started = Date.now();
|
|
5021
|
-
this._sessionId =
|
|
5154
|
+
this._sessionId = import_keys13.PublicKey.random().toHex();
|
|
5022
5155
|
this._logProcessor = (_config, entry2) => {
|
|
5023
5156
|
this._logs.emit(entry2);
|
|
5024
5157
|
};
|
|
@@ -5115,16 +5248,16 @@ var LoggingServiceImpl = class {
|
|
|
5115
5248
|
};
|
|
5116
5249
|
var matchFilter = (filter, level, path2, options) => {
|
|
5117
5250
|
switch (options) {
|
|
5118
|
-
case
|
|
5251
|
+
case import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
5119
5252
|
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5120
|
-
case
|
|
5253
|
+
case import_services17.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
5121
5254
|
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5122
5255
|
}
|
|
5123
5256
|
};
|
|
5124
5257
|
var shouldLog = (entry2, request) => {
|
|
5125
|
-
const options = request.options ??
|
|
5258
|
+
const options = request.options ?? import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5126
5259
|
if (request.filters === void 0) {
|
|
5127
|
-
return options ===
|
|
5260
|
+
return options === import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5128
5261
|
} else {
|
|
5129
5262
|
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
5130
5263
|
}
|
|
@@ -5161,7 +5294,7 @@ var NetworkServiceImpl = class {
|
|
|
5161
5294
|
}
|
|
5162
5295
|
};
|
|
5163
5296
|
var getRootPath = (config) => {
|
|
5164
|
-
const { dataRoot = (0, import_util11.isNode)() ?
|
|
5297
|
+
const { dataRoot = (0, import_util11.isNode)() ? import_client_protocol6.DX_DATA : "dxos/storage" } = config ?? {};
|
|
5165
5298
|
return `${dataRoot}/`;
|
|
5166
5299
|
};
|
|
5167
5300
|
var isPersistent = (config) => {
|
|
@@ -5212,7 +5345,7 @@ var toStorageType = (type) => {
|
|
|
5212
5345
|
};
|
|
5213
5346
|
var createLevel = async (config) => {
|
|
5214
5347
|
const persistent = isPersistent(config);
|
|
5215
|
-
const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${
|
|
5348
|
+
const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys14.PublicKey.random().toHex()}`;
|
|
5216
5349
|
const level = new import_level.Level(storagePath);
|
|
5217
5350
|
await level.open();
|
|
5218
5351
|
return level;
|
|
@@ -5237,8 +5370,8 @@ var SystemServiceImpl = class {
|
|
|
5237
5370
|
return {
|
|
5238
5371
|
timestamp: /* @__PURE__ */ new Date(),
|
|
5239
5372
|
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util12.jsonKeyReplacer)({
|
|
5240
|
-
truncate: keys ===
|
|
5241
|
-
humanize: keys ===
|
|
5373
|
+
truncate: keys === import_services18.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
5374
|
+
humanize: keys === import_services18.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
5242
5375
|
})))
|
|
5243
5376
|
};
|
|
5244
5377
|
}
|
|
@@ -5321,14 +5454,14 @@ var ClientServicesHost = class {
|
|
|
5321
5454
|
this._systemService = new SystemServiceImpl({
|
|
5322
5455
|
config: () => this._config,
|
|
5323
5456
|
statusUpdate: this._statusUpdate,
|
|
5324
|
-
getCurrentStatus: () => this.isOpen ?
|
|
5457
|
+
getCurrentStatus: () => this.isOpen ? import_services15.SystemStatus.ACTIVE : import_services15.SystemStatus.INACTIVE,
|
|
5325
5458
|
getDiagnostics: () => {
|
|
5326
5459
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
5327
5460
|
},
|
|
5328
5461
|
onUpdateStatus: async (status) => {
|
|
5329
|
-
if (!this.isOpen && status ===
|
|
5462
|
+
if (!this.isOpen && status === import_services15.SystemStatus.ACTIVE) {
|
|
5330
5463
|
await this._resourceLock?.acquire();
|
|
5331
|
-
} else if (this.isOpen && status ===
|
|
5464
|
+
} else if (this.isOpen && status === import_services15.SystemStatus.INACTIVE) {
|
|
5332
5465
|
await this._resourceLock?.release();
|
|
5333
5466
|
}
|
|
5334
5467
|
},
|
|
@@ -5338,7 +5471,7 @@ var ClientServicesHost = class {
|
|
|
5338
5471
|
});
|
|
5339
5472
|
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
5340
5473
|
this._loggingService = new LoggingServiceImpl();
|
|
5341
|
-
this._serviceRegistry = new ServiceRegistry(
|
|
5474
|
+
this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
|
|
5342
5475
|
SystemService: this._systemService,
|
|
5343
5476
|
TracingService: this._tracingService
|
|
5344
5477
|
});
|
|
@@ -5369,7 +5502,7 @@ var ClientServicesHost = class {
|
|
|
5369
5502
|
initialize({ config, ...options }) {
|
|
5370
5503
|
(0, import_invariant15.invariant)(!this._open, "service host is open", {
|
|
5371
5504
|
F: __dxlog_file18,
|
|
5372
|
-
L:
|
|
5505
|
+
L: 198,
|
|
5373
5506
|
S: this,
|
|
5374
5507
|
A: [
|
|
5375
5508
|
"!this._open",
|
|
@@ -5378,14 +5511,14 @@ var ClientServicesHost = class {
|
|
|
5378
5511
|
});
|
|
5379
5512
|
(0, import_log13.log)("initializing...", void 0, {
|
|
5380
5513
|
F: __dxlog_file18,
|
|
5381
|
-
L:
|
|
5514
|
+
L: 199,
|
|
5382
5515
|
S: this,
|
|
5383
5516
|
C: (f, a) => f(...a)
|
|
5384
5517
|
});
|
|
5385
5518
|
if (config) {
|
|
5386
5519
|
(0, import_invariant15.invariant)(!this._config, "config already set", {
|
|
5387
5520
|
F: __dxlog_file18,
|
|
5388
|
-
L:
|
|
5521
|
+
L: 202,
|
|
5389
5522
|
S: this,
|
|
5390
5523
|
A: [
|
|
5391
5524
|
"!this._config",
|
|
@@ -5400,7 +5533,7 @@ var ClientServicesHost = class {
|
|
|
5400
5533
|
if (!options.signalManager) {
|
|
5401
5534
|
import_log13.log.warn("running signaling without telemetry metadata.", void 0, {
|
|
5402
5535
|
F: __dxlog_file18,
|
|
5403
|
-
L:
|
|
5536
|
+
L: 210,
|
|
5404
5537
|
S: this,
|
|
5405
5538
|
C: (f, a) => f(...a)
|
|
5406
5539
|
});
|
|
@@ -5411,7 +5544,7 @@ var ClientServicesHost = class {
|
|
|
5411
5544
|
this._signalManager = signalManager;
|
|
5412
5545
|
(0, import_invariant15.invariant)(!this._networkManager, "network manager already set", {
|
|
5413
5546
|
F: __dxlog_file18,
|
|
5414
|
-
L:
|
|
5547
|
+
L: 221,
|
|
5415
5548
|
S: this,
|
|
5416
5549
|
A: [
|
|
5417
5550
|
"!this._networkManager",
|
|
@@ -5425,7 +5558,7 @@ var ClientServicesHost = class {
|
|
|
5425
5558
|
});
|
|
5426
5559
|
(0, import_log13.log)("initialized", void 0, {
|
|
5427
5560
|
F: __dxlog_file18,
|
|
5428
|
-
L:
|
|
5561
|
+
L: 228,
|
|
5429
5562
|
S: this,
|
|
5430
5563
|
C: (f, a) => f(...a)
|
|
5431
5564
|
});
|
|
@@ -5434,18 +5567,18 @@ var ClientServicesHost = class {
|
|
|
5434
5567
|
if (this._open) {
|
|
5435
5568
|
return;
|
|
5436
5569
|
}
|
|
5437
|
-
const traceId =
|
|
5570
|
+
const traceId = import_keys12.PublicKey.random().toHex();
|
|
5438
5571
|
import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.begin({
|
|
5439
5572
|
id: traceId
|
|
5440
5573
|
}), {
|
|
5441
5574
|
F: __dxlog_file18,
|
|
5442
|
-
L:
|
|
5575
|
+
L: 239,
|
|
5443
5576
|
S: this,
|
|
5444
5577
|
C: (f, a) => f(...a)
|
|
5445
5578
|
});
|
|
5446
5579
|
(0, import_invariant15.invariant)(this._config, "config not set", {
|
|
5447
5580
|
F: __dxlog_file18,
|
|
5448
|
-
L:
|
|
5581
|
+
L: 241,
|
|
5449
5582
|
S: this,
|
|
5450
5583
|
A: [
|
|
5451
5584
|
"this._config",
|
|
@@ -5454,7 +5587,7 @@ var ClientServicesHost = class {
|
|
|
5454
5587
|
});
|
|
5455
5588
|
(0, import_invariant15.invariant)(this._storage, "storage not set", {
|
|
5456
5589
|
F: __dxlog_file18,
|
|
5457
|
-
L:
|
|
5590
|
+
L: 242,
|
|
5458
5591
|
S: this,
|
|
5459
5592
|
A: [
|
|
5460
5593
|
"this._storage",
|
|
@@ -5463,7 +5596,7 @@ var ClientServicesHost = class {
|
|
|
5463
5596
|
});
|
|
5464
5597
|
(0, import_invariant15.invariant)(this._signalManager, "signal manager not set", {
|
|
5465
5598
|
F: __dxlog_file18,
|
|
5466
|
-
L:
|
|
5599
|
+
L: 243,
|
|
5467
5600
|
S: this,
|
|
5468
5601
|
A: [
|
|
5469
5602
|
"this._signalManager",
|
|
@@ -5472,7 +5605,7 @@ var ClientServicesHost = class {
|
|
|
5472
5605
|
});
|
|
5473
5606
|
(0, import_invariant15.invariant)(this._networkManager, "network manager not set", {
|
|
5474
5607
|
F: __dxlog_file18,
|
|
5475
|
-
L:
|
|
5608
|
+
L: 244,
|
|
5476
5609
|
S: this,
|
|
5477
5610
|
A: [
|
|
5478
5611
|
"this._networkManager",
|
|
@@ -5484,7 +5617,7 @@ var ClientServicesHost = class {
|
|
|
5484
5617
|
lockKey: this._resourceLock?.lockKey
|
|
5485
5618
|
}, {
|
|
5486
5619
|
F: __dxlog_file18,
|
|
5487
|
-
L:
|
|
5620
|
+
L: 247,
|
|
5488
5621
|
S: this,
|
|
5489
5622
|
C: (f, a) => f(...a)
|
|
5490
5623
|
});
|
|
@@ -5495,20 +5628,22 @@ var ClientServicesHost = class {
|
|
|
5495
5628
|
await this._resourceLock?.acquire();
|
|
5496
5629
|
await this._loggingService.open();
|
|
5497
5630
|
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
|
|
5631
|
+
this._queryService = new import_indexing2.QueryServiceImpl({
|
|
5632
|
+
indexer: this._serviceContext.indexer,
|
|
5633
|
+
automergeHost: this._serviceContext.automergeHost
|
|
5634
|
+
});
|
|
5635
|
+
await this._queryService.open(ctx);
|
|
5498
5636
|
this._serviceRegistry.setServices({
|
|
5499
5637
|
SystemService: this._systemService,
|
|
5500
5638
|
IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
|
|
5501
|
-
InvitationsService: new InvitationsServiceImpl(this._serviceContext.
|
|
5639
|
+
InvitationsService: new InvitationsServiceImpl(this._serviceContext.invitationsManager),
|
|
5502
5640
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
5503
5641
|
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, async () => {
|
|
5504
5642
|
await this._serviceContext.initialized.wait();
|
|
5505
5643
|
return this._serviceContext.dataSpaceManager;
|
|
5506
5644
|
}),
|
|
5507
5645
|
DataService: new import_echo_pipeline5.DataServiceImpl(this._serviceContext.automergeHost),
|
|
5508
|
-
|
|
5509
|
-
indexer: this._serviceContext.indexer,
|
|
5510
|
-
automergeHost: this._serviceContext.automergeHost
|
|
5511
|
-
}),
|
|
5646
|
+
QueryService: this._queryService,
|
|
5512
5647
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
5513
5648
|
LoggingService: this._loggingService,
|
|
5514
5649
|
TracingService: this._tracingService,
|
|
@@ -5520,30 +5655,12 @@ var ClientServicesHost = class {
|
|
|
5520
5655
|
})
|
|
5521
5656
|
});
|
|
5522
5657
|
await this._serviceContext.open(ctx);
|
|
5523
|
-
(0, import_invariant15.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5524
|
-
F: __dxlog_file18,
|
|
5525
|
-
L: 314,
|
|
5526
|
-
S: this,
|
|
5527
|
-
A: [
|
|
5528
|
-
"this.serviceRegistry.services.InvitationsService",
|
|
5529
|
-
""
|
|
5530
|
-
]
|
|
5531
|
-
});
|
|
5532
|
-
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5533
|
-
(0, import_log13.log)("loaded persistent invitations", {
|
|
5534
|
-
count: loadedInvitations.invitations?.length
|
|
5535
|
-
}, {
|
|
5536
|
-
F: __dxlog_file18,
|
|
5537
|
-
L: 317,
|
|
5538
|
-
S: this,
|
|
5539
|
-
C: (f, a) => f(...a)
|
|
5540
|
-
});
|
|
5541
5658
|
const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
|
|
5542
5659
|
if (devtoolsProxy) {
|
|
5543
5660
|
this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
|
|
5544
5661
|
url: devtoolsProxy,
|
|
5545
5662
|
requested: {},
|
|
5546
|
-
exposed:
|
|
5663
|
+
exposed: import_client_protocol5.clientServiceBundle,
|
|
5547
5664
|
handlers: this.services
|
|
5548
5665
|
});
|
|
5549
5666
|
void this._devtoolsProxy.open();
|
|
@@ -5557,7 +5674,7 @@ var ClientServicesHost = class {
|
|
|
5557
5674
|
deviceKey
|
|
5558
5675
|
}, {
|
|
5559
5676
|
F: __dxlog_file18,
|
|
5560
|
-
L:
|
|
5677
|
+
L: 330,
|
|
5561
5678
|
S: this,
|
|
5562
5679
|
C: (f, a) => f(...a)
|
|
5563
5680
|
});
|
|
@@ -5565,7 +5682,7 @@ var ClientServicesHost = class {
|
|
|
5565
5682
|
id: traceId
|
|
5566
5683
|
}), {
|
|
5567
5684
|
F: __dxlog_file18,
|
|
5568
|
-
L:
|
|
5685
|
+
L: 331,
|
|
5569
5686
|
S: this,
|
|
5570
5687
|
C: (f, a) => f(...a)
|
|
5571
5688
|
});
|
|
@@ -5579,7 +5696,7 @@ var ClientServicesHost = class {
|
|
|
5579
5696
|
deviceKey
|
|
5580
5697
|
}, {
|
|
5581
5698
|
F: __dxlog_file18,
|
|
5582
|
-
L:
|
|
5699
|
+
L: 342,
|
|
5583
5700
|
S: this,
|
|
5584
5701
|
C: (f, a) => f(...a)
|
|
5585
5702
|
});
|
|
@@ -5589,6 +5706,7 @@ var ClientServicesHost = class {
|
|
|
5589
5706
|
SystemService: this._systemService
|
|
5590
5707
|
});
|
|
5591
5708
|
await this._loggingService.close();
|
|
5709
|
+
await this._queryService.close();
|
|
5592
5710
|
await this._serviceContext.close();
|
|
5593
5711
|
await this._level?.close();
|
|
5594
5712
|
this._open = false;
|
|
@@ -5597,24 +5715,24 @@ var ClientServicesHost = class {
|
|
|
5597
5715
|
deviceKey
|
|
5598
5716
|
}, {
|
|
5599
5717
|
F: __dxlog_file18,
|
|
5600
|
-
L:
|
|
5718
|
+
L: 352,
|
|
5601
5719
|
S: this,
|
|
5602
5720
|
C: (f, a) => f(...a)
|
|
5603
5721
|
});
|
|
5604
5722
|
}
|
|
5605
5723
|
async reset() {
|
|
5606
|
-
const traceId =
|
|
5724
|
+
const traceId = import_keys12.PublicKey.random().toHex();
|
|
5607
5725
|
import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.begin({
|
|
5608
5726
|
id: traceId
|
|
5609
5727
|
}), {
|
|
5610
5728
|
F: __dxlog_file18,
|
|
5611
|
-
L:
|
|
5729
|
+
L: 357,
|
|
5612
5730
|
S: this,
|
|
5613
5731
|
C: (f, a) => f(...a)
|
|
5614
5732
|
});
|
|
5615
5733
|
(0, import_log13.log)("resetting...", void 0, {
|
|
5616
5734
|
F: __dxlog_file18,
|
|
5617
|
-
L:
|
|
5735
|
+
L: 359,
|
|
5618
5736
|
S: this,
|
|
5619
5737
|
C: (f, a) => f(...a)
|
|
5620
5738
|
});
|
|
@@ -5622,7 +5740,7 @@ var ClientServicesHost = class {
|
|
|
5622
5740
|
await this._storage.reset();
|
|
5623
5741
|
(0, import_log13.log)("reset", void 0, {
|
|
5624
5742
|
F: __dxlog_file18,
|
|
5625
|
-
L:
|
|
5743
|
+
L: 362,
|
|
5626
5744
|
S: this,
|
|
5627
5745
|
C: (f, a) => f(...a)
|
|
5628
5746
|
});
|
|
@@ -5630,7 +5748,7 @@ var ClientServicesHost = class {
|
|
|
5630
5748
|
id: traceId
|
|
5631
5749
|
}), {
|
|
5632
5750
|
F: __dxlog_file18,
|
|
5633
|
-
L:
|
|
5751
|
+
L: 363,
|
|
5634
5752
|
S: this,
|
|
5635
5753
|
C: (f, a) => f(...a)
|
|
5636
5754
|
});
|
|
@@ -5643,7 +5761,7 @@ var ClientServicesHost = class {
|
|
|
5643
5761
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5644
5762
|
(0, import_invariant15.invariant)(automergeIndex, void 0, {
|
|
5645
5763
|
F: __dxlog_file18,
|
|
5646
|
-
L:
|
|
5764
|
+
L: 375,
|
|
5647
5765
|
S: this,
|
|
5648
5766
|
A: [
|
|
5649
5767
|
"automergeIndex",
|
|
@@ -5654,16 +5772,16 @@ var ClientServicesHost = class {
|
|
|
5654
5772
|
await document.whenReady();
|
|
5655
5773
|
const properties = {
|
|
5656
5774
|
system: {
|
|
5657
|
-
type: (0, import_echo_pipeline5.encodeReference)((0,
|
|
5775
|
+
type: (0, import_echo_pipeline5.encodeReference)((0, import_echo_schema2.getTypeReference)(import_client_protocol5.Properties))
|
|
5658
5776
|
},
|
|
5659
5777
|
data: {
|
|
5660
|
-
[
|
|
5778
|
+
[import_client_protocol5.defaultKey]: identity.identityKey.toHex()
|
|
5661
5779
|
},
|
|
5662
5780
|
meta: {
|
|
5663
5781
|
keys: []
|
|
5664
5782
|
}
|
|
5665
5783
|
};
|
|
5666
|
-
const propertiesId =
|
|
5784
|
+
const propertiesId = import_keys12.PublicKey.random().toHex();
|
|
5667
5785
|
document.change((doc) => {
|
|
5668
5786
|
(0, import_util9.assignDeep)(doc, [
|
|
5669
5787
|
"objects",
|
|
@@ -5698,7 +5816,7 @@ var DiagnosticsCollector = class {
|
|
|
5698
5816
|
}
|
|
5699
5817
|
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
5700
5818
|
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
5701
|
-
keys: options.humanize ?
|
|
5819
|
+
keys: options.humanize ? import_services14.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services14.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
5702
5820
|
});
|
|
5703
5821
|
const clientDiagnostics = {
|
|
5704
5822
|
config,
|
|
@@ -5738,6 +5856,7 @@ var findConfigs = () => {
|
|
|
5738
5856
|
IdentityManager,
|
|
5739
5857
|
IdentityServiceImpl,
|
|
5740
5858
|
InvitationsHandler,
|
|
5859
|
+
InvitationsManager,
|
|
5741
5860
|
InvitationsServiceImpl,
|
|
5742
5861
|
Lock,
|
|
5743
5862
|
ServiceContext,
|
|
@@ -5762,4 +5881,4 @@ var findConfigs = () => {
|
|
|
5762
5881
|
subscribeToSpaces,
|
|
5763
5882
|
subscribeToSwarmInfo
|
|
5764
5883
|
});
|
|
5765
|
-
//# sourceMappingURL=chunk-
|
|
5884
|
+
//# sourceMappingURL=chunk-3EKN7HG6.cjs.map
|