@dxos/client-services 0.4.10-main.e96274c → 0.4.10-main.e99db3e
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-UVEPMM4Z.mjs → chunk-KFDIAZLU.mjs} +355 -287
- package/dist/lib/browser/chunk-KFDIAZLU.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +125 -112
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/{chunk-GZWBW7OC.cjs → chunk-GAS53XAH.cjs} +445 -377
- package/dist/lib/node/chunk-GAS53XAH.cjs.map +7 -0
- package/dist/lib/node/index.cjs +43 -43
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +125 -115
- 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 +0 -5
- 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/invitation-protocol.d.ts +6 -1
- package/dist/types/src/packlets/invitations/invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +4 -2
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts +9 -7
- package/dist/types/src/packlets/invitations/invitations-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts +2 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts.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/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +3 -0
- 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 +1 -65
- package/src/packlets/invitations/device-invitation-protocol.ts +6 -1
- package/src/packlets/invitations/invitation-protocol.ts +7 -1
- package/src/packlets/invitations/invitations-handler.ts +10 -71
- package/src/packlets/invitations/invitations-manager.ts +114 -40
- package/src/packlets/invitations/invitations-service.ts +4 -2
- package/src/packlets/invitations/space-invitation-protocol.ts +45 -3
- package/src/packlets/services/service-context.ts +3 -2
- package/src/packlets/spaces/data-space-manager.ts +48 -2
- package/src/packlets/testing/invitation-utils.ts +100 -97
- package/src/packlets/testing/test-builder.ts +19 -1
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-UVEPMM4Z.mjs.map +0 -7
- package/dist/lib/node/chunk-GZWBW7OC.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_GAS53XAH_exports = {};
|
|
30
|
+
__export(chunk_GAS53XAH_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
33
|
ClientServicesProviderResource: () => ClientServicesProviderResource,
|
|
@@ -66,7 +66,7 @@ __export(chunk_GZWBW7OC_exports, {
|
|
|
66
66
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
67
67
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
68
68
|
});
|
|
69
|
-
module.exports = __toCommonJS(
|
|
69
|
+
module.exports = __toCommonJS(chunk_GAS53XAH_exports);
|
|
70
70
|
var import_async = require("@dxos/async");
|
|
71
71
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
72
72
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -120,7 +120,6 @@ var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
120
120
|
var import_async7 = require("@dxos/async");
|
|
121
121
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
122
122
|
var import_context4 = require("@dxos/context");
|
|
123
|
-
var import_credentials7 = require("@dxos/credentials");
|
|
124
123
|
var import_crypto = require("@dxos/crypto");
|
|
125
124
|
var import_invariant5 = require("@dxos/invariant");
|
|
126
125
|
var import_keys5 = require("@dxos/keys");
|
|
@@ -141,59 +140,65 @@ var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations")
|
|
|
141
140
|
var import_teleport = require("@dxos/teleport");
|
|
142
141
|
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
143
142
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
144
|
-
var
|
|
143
|
+
var import_credentials7 = require("@dxos/credentials");
|
|
145
144
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
146
145
|
var import_invariant7 = require("@dxos/invariant");
|
|
147
146
|
var import_log6 = require("@dxos/log");
|
|
148
147
|
var import_protocols6 = require("@dxos/protocols");
|
|
149
148
|
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
149
|
+
var import_credentials8 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
150
150
|
var import_async9 = require("@dxos/async");
|
|
151
|
+
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
152
|
+
var import_context6 = require("@dxos/context");
|
|
153
|
+
var import_credentials9 = require("@dxos/credentials");
|
|
151
154
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
152
155
|
var import_invariant8 = require("@dxos/invariant");
|
|
156
|
+
var import_keys7 = require("@dxos/keys");
|
|
153
157
|
var import_log7 = require("@dxos/log");
|
|
158
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
154
159
|
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
155
160
|
var import_debug2 = require("@dxos/debug");
|
|
156
161
|
var import_rpc = require("@dxos/rpc");
|
|
157
162
|
var import_tracing3 = require("@dxos/tracing");
|
|
158
163
|
var import_async10 = require("@dxos/async");
|
|
159
|
-
var
|
|
160
|
-
var
|
|
164
|
+
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
165
|
+
var import_context7 = require("@dxos/context");
|
|
161
166
|
var import_debug3 = require("@dxos/debug");
|
|
162
167
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
163
168
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
164
169
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
165
170
|
var import_invariant9 = require("@dxos/invariant");
|
|
166
|
-
var
|
|
171
|
+
var import_keys8 = require("@dxos/keys");
|
|
167
172
|
var import_log8 = require("@dxos/log");
|
|
168
173
|
var import_protocols7 = require("@dxos/protocols");
|
|
169
|
-
var
|
|
170
|
-
var
|
|
174
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
175
|
+
var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
171
176
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
172
177
|
var import_tracing4 = require("@dxos/tracing");
|
|
173
178
|
var import_util4 = require("@dxos/util");
|
|
174
179
|
var import_async11 = require("@dxos/async");
|
|
175
|
-
var
|
|
180
|
+
var import_credentials11 = require("@dxos/credentials");
|
|
176
181
|
var import_async12 = require("@dxos/async");
|
|
177
|
-
var
|
|
182
|
+
var import_context8 = require("@dxos/context");
|
|
178
183
|
var import_invariant10 = require("@dxos/invariant");
|
|
179
|
-
var
|
|
184
|
+
var import_keys9 = require("@dxos/keys");
|
|
180
185
|
var import_log9 = require("@dxos/log");
|
|
181
186
|
var import_protocols8 = require("@dxos/protocols");
|
|
182
187
|
var import_teleport2 = require("@dxos/teleport");
|
|
183
188
|
var import_util5 = require("@dxos/util");
|
|
184
189
|
var import_async13 = require("@dxos/async");
|
|
185
|
-
var
|
|
186
|
-
var
|
|
190
|
+
var import_context9 = require("@dxos/context");
|
|
191
|
+
var import_credentials12 = require("@dxos/credentials");
|
|
187
192
|
var import_invariant11 = require("@dxos/invariant");
|
|
188
|
-
var
|
|
193
|
+
var import_keys10 = require("@dxos/keys");
|
|
189
194
|
var import_log10 = require("@dxos/log");
|
|
190
195
|
var import_protocols9 = require("@dxos/protocols");
|
|
191
|
-
var
|
|
196
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
192
197
|
var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
|
|
193
198
|
var import_util6 = require("@dxos/util");
|
|
194
|
-
var
|
|
199
|
+
var import_credentials13 = require("@dxos/credentials");
|
|
195
200
|
var import_debug4 = require("@dxos/debug");
|
|
196
|
-
var
|
|
201
|
+
var import_credentials14 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
197
202
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
198
203
|
var import_async14 = require("@dxos/async");
|
|
199
204
|
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
@@ -201,79 +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
|
-
var
|
|
207
|
-
var
|
|
211
|
+
var import_context10 = require("@dxos/context");
|
|
212
|
+
var import_credentials15 = require("@dxos/credentials");
|
|
208
213
|
var import_debug6 = require("@dxos/debug");
|
|
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
227
|
var import_protocols12 = require("@dxos/protocols");
|
|
223
228
|
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
224
|
-
var
|
|
229
|
+
var import_credentials16 = require("@dxos/credentials");
|
|
225
230
|
var import_invariant14 = require("@dxos/invariant");
|
|
226
231
|
var import_protocols13 = require("@dxos/protocols");
|
|
227
|
-
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
228
|
-
var import_tracing6 = require("@dxos/tracing");
|
|
229
232
|
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
230
|
-
var
|
|
233
|
+
var import_tracing6 = require("@dxos/tracing");
|
|
231
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");
|
|
232
237
|
var import_tracing7 = require("@dxos/tracing");
|
|
233
238
|
var import_util8 = require("@dxos/util");
|
|
234
239
|
var import_async16 = require("@dxos/async");
|
|
235
|
-
var
|
|
236
|
-
var
|
|
240
|
+
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
241
|
+
var import_context11 = require("@dxos/context");
|
|
237
242
|
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
238
243
|
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
239
244
|
var import_indexing2 = require("@dxos/indexing");
|
|
240
245
|
var import_invariant15 = require("@dxos/invariant");
|
|
241
|
-
var
|
|
246
|
+
var import_keys12 = require("@dxos/keys");
|
|
242
247
|
var import_log13 = require("@dxos/log");
|
|
243
248
|
var import_messaging = require("@dxos/messaging");
|
|
244
249
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
245
250
|
var import_protocols14 = require("@dxos/protocols");
|
|
246
|
-
var
|
|
251
|
+
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
247
252
|
var import_tracing8 = require("@dxos/tracing");
|
|
248
253
|
var import_util9 = require("@dxos/util");
|
|
249
254
|
var import_websocket_rpc = require("@dxos/websocket-rpc");
|
|
250
255
|
var import_async17 = require("@dxos/async");
|
|
251
256
|
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
252
257
|
var import_invariant16 = require("@dxos/invariant");
|
|
253
|
-
var
|
|
258
|
+
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
254
259
|
var import_invariant17 = require("@dxos/invariant");
|
|
255
260
|
var import_lock_file = require("@dxos/lock-file");
|
|
256
261
|
var import_log14 = require("@dxos/log");
|
|
257
262
|
var import_async18 = require("@dxos/async");
|
|
258
263
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
259
|
-
var
|
|
264
|
+
var import_keys13 = require("@dxos/keys");
|
|
260
265
|
var import_log15 = require("@dxos/log");
|
|
261
|
-
var
|
|
266
|
+
var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
|
|
262
267
|
var import_util10 = require("@dxos/util");
|
|
263
268
|
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
264
269
|
var import_protocols15 = require("@dxos/protocols");
|
|
265
270
|
var import_config2 = require("@dxos/protocols/proto/dxos/config");
|
|
266
271
|
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
267
|
-
var
|
|
272
|
+
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
268
273
|
var import_config3 = require("@dxos/protocols/proto/dxos/config");
|
|
269
274
|
var import_util11 = require("@dxos/util");
|
|
270
275
|
var import_level = require("level");
|
|
271
276
|
var import_node_path = __toESM(require("node:path"));
|
|
272
|
-
var
|
|
277
|
+
var import_keys14 = require("@dxos/keys");
|
|
273
278
|
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
274
|
-
var
|
|
279
|
+
var import_services18 = require("@dxos/protocols/proto/dxos/client/services");
|
|
275
280
|
var import_util12 = require("@dxos/util");
|
|
276
|
-
var
|
|
281
|
+
var import_keys15 = require("@dxos/keys");
|
|
277
282
|
var import_util13 = require("@dxos/util");
|
|
278
283
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
279
284
|
return new import_codec_protobuf.Stream(({ next }) => {
|
|
@@ -1292,7 +1297,9 @@ var IdentityManager = class {
|
|
|
1292
1297
|
C: (f, a) => f(...a)
|
|
1293
1298
|
});
|
|
1294
1299
|
},
|
|
1295
|
-
memberKey: identityKey
|
|
1300
|
+
memberKey: identityKey,
|
|
1301
|
+
onDelegatedInvitationStatusChange: async () => {
|
|
1302
|
+
}
|
|
1296
1303
|
});
|
|
1297
1304
|
}
|
|
1298
1305
|
};
|
|
@@ -1389,10 +1396,13 @@ var DeviceInvitationProtocol = class {
|
|
|
1389
1396
|
kind: import_services2.Invitation.Kind.DEVICE
|
|
1390
1397
|
};
|
|
1391
1398
|
}
|
|
1392
|
-
async
|
|
1399
|
+
async delegate(invitation) {
|
|
1400
|
+
throw new Error("delegation not supported");
|
|
1401
|
+
}
|
|
1402
|
+
async admit(_, request) {
|
|
1393
1403
|
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1394
1404
|
F: __dxlog_file5,
|
|
1395
|
-
L:
|
|
1405
|
+
L: 42,
|
|
1396
1406
|
S: this,
|
|
1397
1407
|
A: [
|
|
1398
1408
|
"request.device",
|
|
@@ -1438,7 +1448,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1438
1448
|
async accept(response, request) {
|
|
1439
1449
|
(0, import_invariant4.invariant)(response.device, void 0, {
|
|
1440
1450
|
F: __dxlog_file5,
|
|
1441
|
-
L:
|
|
1451
|
+
L: 87,
|
|
1442
1452
|
S: this,
|
|
1443
1453
|
A: [
|
|
1444
1454
|
"response.device",
|
|
@@ -1448,7 +1458,7 @@ var DeviceInvitationProtocol = class {
|
|
|
1448
1458
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1449
1459
|
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1450
1460
|
F: __dxlog_file5,
|
|
1451
|
-
L:
|
|
1461
|
+
L: 90,
|
|
1452
1462
|
S: this,
|
|
1453
1463
|
A: [
|
|
1454
1464
|
"request.device",
|
|
@@ -1823,51 +1833,7 @@ var InvitationsHandler = class {
|
|
|
1823
1833
|
constructor(_networkManager) {
|
|
1824
1834
|
this._networkManager = _networkManager;
|
|
1825
1835
|
}
|
|
1826
|
-
|
|
1827
|
-
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 ?? {};
|
|
1828
|
-
const authCode = options?.authCode ?? (authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0);
|
|
1829
|
-
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
1830
|
-
F: __dxlog_file7,
|
|
1831
|
-
L: 87,
|
|
1832
|
-
S: this,
|
|
1833
|
-
A: [
|
|
1834
|
-
"protocol",
|
|
1835
|
-
""
|
|
1836
|
-
]
|
|
1837
|
-
});
|
|
1838
|
-
const invitation = {
|
|
1839
|
-
invitationId,
|
|
1840
|
-
type,
|
|
1841
|
-
authMethod,
|
|
1842
|
-
state,
|
|
1843
|
-
swarmKey,
|
|
1844
|
-
authCode,
|
|
1845
|
-
timeout,
|
|
1846
|
-
persistent: persistent && type !== import_services3.Invitation.Type.DELEGATED,
|
|
1847
|
-
guestKeypair: guestKeypair ?? (authMethod === import_services3.Invitation.AuthMethod.KNOWN_PUBLIC_KEY ? createAdmissionKeypair() : void 0),
|
|
1848
|
-
created,
|
|
1849
|
-
lifetime,
|
|
1850
|
-
multiUse,
|
|
1851
|
-
...protocol.getInvitationContext()
|
|
1852
|
-
};
|
|
1853
|
-
const stream = new import_async7.PushStream();
|
|
1854
|
-
const ctx = new import_context4.Context({
|
|
1855
|
-
onError: (err) => {
|
|
1856
|
-
stream.error(err);
|
|
1857
|
-
void ctx.dispose();
|
|
1858
|
-
}
|
|
1859
|
-
});
|
|
1860
|
-
ctx.onDispose(() => {
|
|
1861
|
-
(0, import_log4.log)("complete", {
|
|
1862
|
-
...protocol.toJSON()
|
|
1863
|
-
}, {
|
|
1864
|
-
F: __dxlog_file7,
|
|
1865
|
-
L: 115,
|
|
1866
|
-
S: this,
|
|
1867
|
-
C: (f, a) => f(...a)
|
|
1868
|
-
});
|
|
1869
|
-
stream.complete();
|
|
1870
|
-
});
|
|
1836
|
+
handleInvitationFlow(ctx, stream, protocol, invitation) {
|
|
1871
1837
|
const createExtension = () => {
|
|
1872
1838
|
const extension = new InvitationHostExtension({
|
|
1873
1839
|
onStateUpdate: (invitation2) => {
|
|
@@ -1876,8 +1842,8 @@ var InvitationsHandler = class {
|
|
|
1876
1842
|
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
1877
1843
|
});
|
|
1878
1844
|
},
|
|
1879
|
-
resolveInvitation: async ({ invitationId
|
|
1880
|
-
if (
|
|
1845
|
+
resolveInvitation: async ({ invitationId }) => {
|
|
1846
|
+
if (invitationId && invitationId !== invitation.invitationId) {
|
|
1881
1847
|
return void 0;
|
|
1882
1848
|
}
|
|
1883
1849
|
return invitation;
|
|
@@ -1887,14 +1853,14 @@ var InvitationsHandler = class {
|
|
|
1887
1853
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
1888
1854
|
(0, import_invariant5.invariant)(deviceKey, void 0, {
|
|
1889
1855
|
F: __dxlog_file7,
|
|
1890
|
-
L:
|
|
1856
|
+
L: 87,
|
|
1891
1857
|
S: this,
|
|
1892
1858
|
A: [
|
|
1893
1859
|
"deviceKey",
|
|
1894
1860
|
""
|
|
1895
1861
|
]
|
|
1896
1862
|
});
|
|
1897
|
-
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1863
|
+
const admissionResponse = await protocol.admit(invitation, admissionRequest, extension.guestProfile);
|
|
1898
1864
|
extension.completedTrigger.wake(deviceKey);
|
|
1899
1865
|
return admissionResponse;
|
|
1900
1866
|
} catch (err) {
|
|
@@ -1910,7 +1876,7 @@ var InvitationsHandler = class {
|
|
|
1910
1876
|
id: traceId
|
|
1911
1877
|
}), {
|
|
1912
1878
|
F: __dxlog_file7,
|
|
1913
|
-
L:
|
|
1879
|
+
L: 105,
|
|
1914
1880
|
S: this,
|
|
1915
1881
|
C: (f, a) => f(...a)
|
|
1916
1882
|
});
|
|
@@ -1918,7 +1884,7 @@ var InvitationsHandler = class {
|
|
|
1918
1884
|
...protocol.toJSON()
|
|
1919
1885
|
}, {
|
|
1920
1886
|
F: __dxlog_file7,
|
|
1921
|
-
L:
|
|
1887
|
+
L: 106,
|
|
1922
1888
|
S: this,
|
|
1923
1889
|
C: (f, a) => f(...a)
|
|
1924
1890
|
});
|
|
@@ -1927,14 +1893,14 @@ var InvitationsHandler = class {
|
|
|
1927
1893
|
state: import_services3.Invitation.State.CONNECTED
|
|
1928
1894
|
});
|
|
1929
1895
|
const deviceKey = await extension.completedTrigger.wait({
|
|
1930
|
-
timeout
|
|
1896
|
+
timeout: invitation.timeout
|
|
1931
1897
|
});
|
|
1932
1898
|
(0, import_log4.log)("admitted guest", {
|
|
1933
1899
|
guest: deviceKey,
|
|
1934
1900
|
...protocol.toJSON()
|
|
1935
1901
|
}, {
|
|
1936
1902
|
F: __dxlog_file7,
|
|
1937
|
-
L:
|
|
1903
|
+
L: 109,
|
|
1938
1904
|
S: this,
|
|
1939
1905
|
C: (f, a) => f(...a)
|
|
1940
1906
|
});
|
|
@@ -1946,7 +1912,7 @@ var InvitationsHandler = class {
|
|
|
1946
1912
|
id: traceId
|
|
1947
1913
|
}), {
|
|
1948
1914
|
F: __dxlog_file7,
|
|
1949
|
-
L:
|
|
1915
|
+
L: 111,
|
|
1950
1916
|
S: this,
|
|
1951
1917
|
C: (f, a) => f(...a)
|
|
1952
1918
|
});
|
|
@@ -1956,7 +1922,7 @@ var InvitationsHandler = class {
|
|
|
1956
1922
|
...protocol.toJSON()
|
|
1957
1923
|
}, {
|
|
1958
1924
|
F: __dxlog_file7,
|
|
1959
|
-
L:
|
|
1925
|
+
L: 114,
|
|
1960
1926
|
S: this,
|
|
1961
1927
|
C: (f, a) => f(...a)
|
|
1962
1928
|
});
|
|
@@ -1967,7 +1933,7 @@ var InvitationsHandler = class {
|
|
|
1967
1933
|
} else {
|
|
1968
1934
|
import_log4.log.error("failed", err, {
|
|
1969
1935
|
F: __dxlog_file7,
|
|
1970
|
-
L:
|
|
1936
|
+
L: 117,
|
|
1971
1937
|
S: this,
|
|
1972
1938
|
C: (f, a) => f(...a)
|
|
1973
1939
|
});
|
|
@@ -1978,12 +1944,12 @@ var InvitationsHandler = class {
|
|
|
1978
1944
|
error: err
|
|
1979
1945
|
}), {
|
|
1980
1946
|
F: __dxlog_file7,
|
|
1981
|
-
L:
|
|
1947
|
+
L: 120,
|
|
1982
1948
|
S: this,
|
|
1983
1949
|
C: (f, a) => f(...a)
|
|
1984
1950
|
});
|
|
1985
1951
|
} finally {
|
|
1986
|
-
if (!multiUse) {
|
|
1952
|
+
if (!invitation.multiUse) {
|
|
1987
1953
|
await swarmConnection.close();
|
|
1988
1954
|
await ctx.dispose();
|
|
1989
1955
|
}
|
|
@@ -1999,7 +1965,7 @@ var InvitationsHandler = class {
|
|
|
1999
1965
|
...protocol.toJSON()
|
|
2000
1966
|
}, {
|
|
2001
1967
|
F: __dxlog_file7,
|
|
2002
|
-
L:
|
|
1968
|
+
L: 135,
|
|
2003
1969
|
S: this,
|
|
2004
1970
|
C: (f, a) => f(...a)
|
|
2005
1971
|
});
|
|
@@ -2010,7 +1976,7 @@ var InvitationsHandler = class {
|
|
|
2010
1976
|
} else {
|
|
2011
1977
|
import_log4.log.error("failed", err, {
|
|
2012
1978
|
F: __dxlog_file7,
|
|
2013
|
-
L:
|
|
1979
|
+
L: 138,
|
|
2014
1980
|
S: this,
|
|
2015
1981
|
C: (f, a) => f(...a)
|
|
2016
1982
|
});
|
|
@@ -2024,7 +1990,7 @@ var InvitationsHandler = class {
|
|
|
2024
1990
|
if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
|
|
2025
1991
|
import_log4.log.warn("invitation has already expired", void 0, {
|
|
2026
1992
|
F: __dxlog_file7,
|
|
2027
|
-
L:
|
|
1993
|
+
L: 149,
|
|
2028
1994
|
S: this,
|
|
2029
1995
|
C: (f, a) => f(...a)
|
|
2030
1996
|
});
|
|
@@ -2058,24 +2024,12 @@ var InvitationsHandler = class {
|
|
|
2058
2024
|
state: import_services3.Invitation.State.CONNECTING
|
|
2059
2025
|
});
|
|
2060
2026
|
});
|
|
2061
|
-
const observable = new import_client_protocol2.CancellableInvitation({
|
|
2062
|
-
initialInvitation: invitation,
|
|
2063
|
-
subscriber: stream.observable,
|
|
2064
|
-
onCancel: async () => {
|
|
2065
|
-
stream.next({
|
|
2066
|
-
...invitation,
|
|
2067
|
-
state: import_services3.Invitation.State.CANCELLED
|
|
2068
|
-
});
|
|
2069
|
-
await ctx.dispose();
|
|
2070
|
-
}
|
|
2071
|
-
});
|
|
2072
|
-
return observable;
|
|
2073
2027
|
}
|
|
2074
2028
|
acceptInvitation(protocol, invitation, deviceProfile) {
|
|
2075
2029
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
2076
2030
|
(0, import_invariant5.invariant)(protocol, void 0, {
|
|
2077
2031
|
F: __dxlog_file7,
|
|
2078
|
-
L:
|
|
2032
|
+
L: 191,
|
|
2079
2033
|
S: this,
|
|
2080
2034
|
A: [
|
|
2081
2035
|
"protocol",
|
|
@@ -2085,7 +2039,7 @@ var InvitationsHandler = class {
|
|
|
2085
2039
|
if (deviceProfile) {
|
|
2086
2040
|
(0, import_invariant5.invariant)(invitation.kind === import_services3.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
2087
2041
|
F: __dxlog_file7,
|
|
2088
|
-
L:
|
|
2042
|
+
L: 194,
|
|
2089
2043
|
S: this,
|
|
2090
2044
|
A: [
|
|
2091
2045
|
"invitation.kind === Invitation.Kind.DEVICE",
|
|
@@ -2100,7 +2054,7 @@ var InvitationsHandler = class {
|
|
|
2100
2054
|
const setState = (newData) => {
|
|
2101
2055
|
(0, import_invariant5.invariant)(newData.state !== void 0, void 0, {
|
|
2102
2056
|
F: __dxlog_file7,
|
|
2103
|
-
L:
|
|
2057
|
+
L: 205,
|
|
2104
2058
|
S: this,
|
|
2105
2059
|
A: [
|
|
2106
2060
|
"newData.state !== undefined",
|
|
@@ -2120,7 +2074,7 @@ var InvitationsHandler = class {
|
|
|
2120
2074
|
...protocol.toJSON()
|
|
2121
2075
|
}, {
|
|
2122
2076
|
F: __dxlog_file7,
|
|
2123
|
-
L:
|
|
2077
|
+
L: 213,
|
|
2124
2078
|
S: this,
|
|
2125
2079
|
C: (f, a) => f(...a)
|
|
2126
2080
|
});
|
|
@@ -2130,7 +2084,7 @@ var InvitationsHandler = class {
|
|
|
2130
2084
|
} else {
|
|
2131
2085
|
import_log4.log.warn("auth failed", err, {
|
|
2132
2086
|
F: __dxlog_file7,
|
|
2133
|
-
L:
|
|
2087
|
+
L: 216,
|
|
2134
2088
|
S: this,
|
|
2135
2089
|
C: (f, a) => f(...a)
|
|
2136
2090
|
});
|
|
@@ -2144,7 +2098,7 @@ var InvitationsHandler = class {
|
|
|
2144
2098
|
...protocol.toJSON()
|
|
2145
2099
|
}, {
|
|
2146
2100
|
F: __dxlog_file7,
|
|
2147
|
-
L:
|
|
2101
|
+
L: 224,
|
|
2148
2102
|
S: this,
|
|
2149
2103
|
C: (f, a) => f(...a)
|
|
2150
2104
|
});
|
|
@@ -2159,7 +2113,7 @@ var InvitationsHandler = class {
|
|
|
2159
2113
|
currentState
|
|
2160
2114
|
}, {
|
|
2161
2115
|
F: __dxlog_file7,
|
|
2162
|
-
L:
|
|
2116
|
+
L: 234,
|
|
2163
2117
|
S: this,
|
|
2164
2118
|
C: (f, a) => f(...a)
|
|
2165
2119
|
});
|
|
@@ -2174,7 +2128,7 @@ var InvitationsHandler = class {
|
|
|
2174
2128
|
id: traceId
|
|
2175
2129
|
}), {
|
|
2176
2130
|
F: __dxlog_file7,
|
|
2177
|
-
L:
|
|
2131
|
+
L: 243,
|
|
2178
2132
|
S: this,
|
|
2179
2133
|
C: (f, a) => f(...a)
|
|
2180
2134
|
});
|
|
@@ -2186,7 +2140,7 @@ var InvitationsHandler = class {
|
|
|
2186
2140
|
...protocol.toJSON()
|
|
2187
2141
|
}, {
|
|
2188
2142
|
F: __dxlog_file7,
|
|
2189
|
-
L:
|
|
2143
|
+
L: 251,
|
|
2190
2144
|
S: this,
|
|
2191
2145
|
C: (f, a) => f(...a)
|
|
2192
2146
|
});
|
|
@@ -2197,7 +2151,7 @@ var InvitationsHandler = class {
|
|
|
2197
2151
|
...protocol.toJSON()
|
|
2198
2152
|
}, {
|
|
2199
2153
|
F: __dxlog_file7,
|
|
2200
|
-
L:
|
|
2154
|
+
L: 255,
|
|
2201
2155
|
S: this,
|
|
2202
2156
|
C: (f, a) => f(...a)
|
|
2203
2157
|
});
|
|
@@ -2207,7 +2161,7 @@ var InvitationsHandler = class {
|
|
|
2207
2161
|
response: introductionResponse
|
|
2208
2162
|
}, {
|
|
2209
2163
|
F: __dxlog_file7,
|
|
2210
|
-
L:
|
|
2164
|
+
L: 259,
|
|
2211
2165
|
S: this,
|
|
2212
2166
|
C: (f, a) => f(...a)
|
|
2213
2167
|
});
|
|
@@ -2228,7 +2182,7 @@ var InvitationsHandler = class {
|
|
|
2228
2182
|
...protocol.toJSON()
|
|
2229
2183
|
}, {
|
|
2230
2184
|
F: __dxlog_file7,
|
|
2231
|
-
L:
|
|
2185
|
+
L: 275,
|
|
2232
2186
|
S: this,
|
|
2233
2187
|
C: (f, a) => f(...a)
|
|
2234
2188
|
});
|
|
@@ -2240,7 +2194,7 @@ var InvitationsHandler = class {
|
|
|
2240
2194
|
...protocol.toJSON()
|
|
2241
2195
|
}, {
|
|
2242
2196
|
F: __dxlog_file7,
|
|
2243
|
-
L:
|
|
2197
|
+
L: 286,
|
|
2244
2198
|
S: this,
|
|
2245
2199
|
C: (f, a) => f(...a)
|
|
2246
2200
|
});
|
|
@@ -2253,7 +2207,7 @@ var InvitationsHandler = class {
|
|
|
2253
2207
|
id: traceId
|
|
2254
2208
|
}), {
|
|
2255
2209
|
F: __dxlog_file7,
|
|
2256
|
-
L:
|
|
2210
|
+
L: 288,
|
|
2257
2211
|
S: this,
|
|
2258
2212
|
C: (f, a) => f(...a)
|
|
2259
2213
|
});
|
|
@@ -2263,7 +2217,7 @@ var InvitationsHandler = class {
|
|
|
2263
2217
|
...protocol.toJSON()
|
|
2264
2218
|
}, {
|
|
2265
2219
|
F: __dxlog_file7,
|
|
2266
|
-
L:
|
|
2220
|
+
L: 291,
|
|
2267
2221
|
S: this,
|
|
2268
2222
|
C: (f, a) => f(...a)
|
|
2269
2223
|
});
|
|
@@ -2273,7 +2227,7 @@ var InvitationsHandler = class {
|
|
|
2273
2227
|
} else {
|
|
2274
2228
|
(0, import_log4.log)("auth failed", err, {
|
|
2275
2229
|
F: __dxlog_file7,
|
|
2276
|
-
L:
|
|
2230
|
+
L: 294,
|
|
2277
2231
|
S: this,
|
|
2278
2232
|
C: (f, a) => f(...a)
|
|
2279
2233
|
});
|
|
@@ -2284,7 +2238,7 @@ var InvitationsHandler = class {
|
|
|
2284
2238
|
error: err
|
|
2285
2239
|
}), {
|
|
2286
2240
|
F: __dxlog_file7,
|
|
2287
|
-
L:
|
|
2241
|
+
L: 297,
|
|
2288
2242
|
S: this,
|
|
2289
2243
|
C: (f, a) => f(...a)
|
|
2290
2244
|
});
|
|
@@ -2302,7 +2256,7 @@ var InvitationsHandler = class {
|
|
|
2302
2256
|
...protocol.toJSON()
|
|
2303
2257
|
}, {
|
|
2304
2258
|
F: __dxlog_file7,
|
|
2305
|
-
L:
|
|
2259
|
+
L: 308,
|
|
2306
2260
|
S: this,
|
|
2307
2261
|
C: (f, a) => f(...a)
|
|
2308
2262
|
});
|
|
@@ -2312,7 +2266,7 @@ var InvitationsHandler = class {
|
|
|
2312
2266
|
} else {
|
|
2313
2267
|
(0, import_log4.log)("auth failed", err, {
|
|
2314
2268
|
F: __dxlog_file7,
|
|
2315
|
-
L:
|
|
2269
|
+
L: 311,
|
|
2316
2270
|
S: this,
|
|
2317
2271
|
C: (f, a) => f(...a)
|
|
2318
2272
|
});
|
|
@@ -2329,7 +2283,7 @@ var InvitationsHandler = class {
|
|
|
2329
2283
|
} else {
|
|
2330
2284
|
(0, import_invariant5.invariant)(invitation.swarmKey, void 0, {
|
|
2331
2285
|
F: __dxlog_file7,
|
|
2332
|
-
L:
|
|
2286
|
+
L: 325,
|
|
2333
2287
|
S: this,
|
|
2334
2288
|
A: [
|
|
2335
2289
|
"invitation.swarmKey",
|
|
@@ -2371,7 +2325,7 @@ var InvitationsHandler = class {
|
|
|
2371
2325
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
2372
2326
|
(0, import_log4.log)("guest waiting for authentication code...", void 0, {
|
|
2373
2327
|
F: __dxlog_file7,
|
|
2374
|
-
L:
|
|
2328
|
+
L: 365,
|
|
2375
2329
|
S: this,
|
|
2376
2330
|
C: (f, a) => f(...a)
|
|
2377
2331
|
});
|
|
@@ -2381,7 +2335,7 @@ var InvitationsHandler = class {
|
|
|
2381
2335
|
const authCode = await authenticated.wait(options);
|
|
2382
2336
|
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2383
2337
|
F: __dxlog_file7,
|
|
2384
|
-
L:
|
|
2338
|
+
L: 369,
|
|
2385
2339
|
S: this,
|
|
2386
2340
|
C: (f, a) => f(...a)
|
|
2387
2341
|
});
|
|
@@ -2402,7 +2356,7 @@ var InvitationsHandler = class {
|
|
|
2402
2356
|
attempt
|
|
2403
2357
|
}, {
|
|
2404
2358
|
F: __dxlog_file7,
|
|
2405
|
-
L:
|
|
2359
|
+
L: 380,
|
|
2406
2360
|
S: this,
|
|
2407
2361
|
C: (f, a) => f(...a)
|
|
2408
2362
|
});
|
|
@@ -2420,7 +2374,7 @@ var InvitationsHandler = class {
|
|
|
2420
2374
|
}
|
|
2421
2375
|
(0, import_log4.log)("sending authentication request", void 0, {
|
|
2422
2376
|
F: __dxlog_file7,
|
|
2423
|
-
L:
|
|
2377
|
+
L: 399,
|
|
2424
2378
|
S: this,
|
|
2425
2379
|
C: (f, a) => f(...a)
|
|
2426
2380
|
});
|
|
@@ -2452,9 +2406,8 @@ var InvitationsServiceImpl = class {
|
|
|
2452
2406
|
return {};
|
|
2453
2407
|
}
|
|
2454
2408
|
createInvitation(options) {
|
|
2455
|
-
const invitation = this._invitationsManager.createInvitation(options);
|
|
2456
2409
|
return new import_codec_protobuf8.Stream(({ next, close }) => {
|
|
2457
|
-
invitation.subscribe(next, close, close);
|
|
2410
|
+
void this._invitationsManager.createInvitation(options).then((invitation) => invitation.subscribe(next, close, close)).catch(close);
|
|
2458
2411
|
});
|
|
2459
2412
|
}
|
|
2460
2413
|
acceptInvitation(request) {
|
|
@@ -2557,10 +2510,10 @@ var SpaceInvitationProtocol = class {
|
|
|
2557
2510
|
spaceKey: this._spaceKey
|
|
2558
2511
|
};
|
|
2559
2512
|
}
|
|
2560
|
-
async admit(request, guestProfile) {
|
|
2513
|
+
async admit(invitation, request, guestProfile) {
|
|
2561
2514
|
(0, import_invariant7.invariant)(this._spaceKey, void 0, {
|
|
2562
2515
|
F: __dxlog_file8,
|
|
2563
|
-
L:
|
|
2516
|
+
L: 55,
|
|
2564
2517
|
S: this,
|
|
2565
2518
|
A: [
|
|
2566
2519
|
"this._spaceKey",
|
|
@@ -2570,7 +2523,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2570
2523
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2571
2524
|
(0, import_invariant7.invariant)(space, void 0, {
|
|
2572
2525
|
F: __dxlog_file8,
|
|
2573
|
-
L:
|
|
2526
|
+
L: 57,
|
|
2574
2527
|
S: this,
|
|
2575
2528
|
A: [
|
|
2576
2529
|
"space",
|
|
@@ -2579,7 +2532,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2579
2532
|
});
|
|
2580
2533
|
(0, import_invariant7.invariant)(request.space, void 0, {
|
|
2581
2534
|
F: __dxlog_file8,
|
|
2582
|
-
L:
|
|
2535
|
+
L: 59,
|
|
2583
2536
|
S: this,
|
|
2584
2537
|
A: [
|
|
2585
2538
|
"request.space",
|
|
@@ -2592,14 +2545,14 @@ var SpaceInvitationProtocol = class {
|
|
|
2592
2545
|
guest: deviceKey
|
|
2593
2546
|
}, {
|
|
2594
2547
|
F: __dxlog_file8,
|
|
2595
|
-
L:
|
|
2548
|
+
L: 62,
|
|
2596
2549
|
S: this,
|
|
2597
2550
|
C: (f, a) => f(...a)
|
|
2598
2551
|
});
|
|
2599
|
-
const credentials = await (0,
|
|
2552
|
+
const credentials = await (0, import_credentials7.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile, invitation.delegationCredentialId);
|
|
2600
2553
|
(0, import_invariant7.invariant)(credentials[0].credential, void 0, {
|
|
2601
2554
|
F: __dxlog_file8,
|
|
2602
|
-
L:
|
|
2555
|
+
L: 74,
|
|
2603
2556
|
S: this,
|
|
2604
2557
|
A: [
|
|
2605
2558
|
"credentials[0].credential",
|
|
@@ -2607,9 +2560,9 @@ var SpaceInvitationProtocol = class {
|
|
|
2607
2560
|
]
|
|
2608
2561
|
});
|
|
2609
2562
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2610
|
-
(0, import_invariant7.invariant)((0,
|
|
2563
|
+
(0, import_invariant7.invariant)((0, import_credentials7.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2611
2564
|
F: __dxlog_file8,
|
|
2612
|
-
L:
|
|
2565
|
+
L: 76,
|
|
2613
2566
|
S: this,
|
|
2614
2567
|
A: [
|
|
2615
2568
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2624,6 +2577,69 @@ var SpaceInvitationProtocol = class {
|
|
|
2624
2577
|
}
|
|
2625
2578
|
};
|
|
2626
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
|
+
}
|
|
2627
2643
|
checkInvitation(invitation) {
|
|
2628
2644
|
if (invitation.spaceKey && this._spaceManager.spaces.has(invitation.spaceKey)) {
|
|
2629
2645
|
return new import_protocols6.AlreadyJoinedError("Already joined space.");
|
|
@@ -2649,7 +2665,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2649
2665
|
async accept(response) {
|
|
2650
2666
|
(0, import_invariant7.invariant)(response.space, void 0, {
|
|
2651
2667
|
F: __dxlog_file8,
|
|
2652
|
-
L:
|
|
2668
|
+
L: 149,
|
|
2653
2669
|
S: this,
|
|
2654
2670
|
A: [
|
|
2655
2671
|
"response.space",
|
|
@@ -2657,10 +2673,10 @@ var SpaceInvitationProtocol = class {
|
|
|
2657
2673
|
]
|
|
2658
2674
|
});
|
|
2659
2675
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2660
|
-
const assertion = (0,
|
|
2676
|
+
const assertion = (0, import_credentials7.getCredentialAssertion)(credential);
|
|
2661
2677
|
(0, import_invariant7.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2662
2678
|
F: __dxlog_file8,
|
|
2663
|
-
L:
|
|
2679
|
+
L: 152,
|
|
2664
2680
|
S: this,
|
|
2665
2681
|
A: [
|
|
2666
2682
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2669,7 +2685,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2669
2685
|
});
|
|
2670
2686
|
(0, import_invariant7.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2671
2687
|
F: __dxlog_file8,
|
|
2672
|
-
L:
|
|
2688
|
+
L: 153,
|
|
2673
2689
|
S: this,
|
|
2674
2690
|
A: [
|
|
2675
2691
|
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
@@ -2707,25 +2723,39 @@ var InvitationsManager = class {
|
|
|
2707
2723
|
this._persistentInvitationsLoadedEvent = new import_async9.Event();
|
|
2708
2724
|
this._persistentInvitationsLoaded = false;
|
|
2709
2725
|
}
|
|
2710
|
-
createInvitation(options) {
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2726
|
+
async createInvitation(options) {
|
|
2727
|
+
if (options.invitationId) {
|
|
2728
|
+
const existingInvitation = this._createInvitations.get(options.invitationId);
|
|
2729
|
+
if (existingInvitation) {
|
|
2730
|
+
return existingInvitation;
|
|
2731
|
+
}
|
|
2714
2732
|
}
|
|
2715
2733
|
const handler = this._getHandler(options);
|
|
2716
|
-
const invitation = this.
|
|
2717
|
-
this.
|
|
2718
|
-
this.
|
|
2719
|
-
|
|
2720
|
-
this._onInvitationComplete(
|
|
2721
|
-
this._createInvitations.delete(
|
|
2722
|
-
this.removedCreated.emit(
|
|
2723
|
-
if (
|
|
2724
|
-
await
|
|
2725
|
-
await this._safeDeleteInvitation(invitation.get());
|
|
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());
|
|
2726
2743
|
}
|
|
2727
2744
|
});
|
|
2728
|
-
|
|
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;
|
|
2729
2759
|
}
|
|
2730
2760
|
async loadPersistentInvitations() {
|
|
2731
2761
|
if (this._persistentInvitationsLoaded) {
|
|
@@ -2737,10 +2767,10 @@ var InvitationsManager = class {
|
|
|
2737
2767
|
try {
|
|
2738
2768
|
const persistentInvitations = this._metadataStore.getInvitations();
|
|
2739
2769
|
const freshInvitations = persistentInvitations.filter((invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
|
|
2740
|
-
const
|
|
2770
|
+
const loadTasks = freshInvitations.map((persistentInvitation) => {
|
|
2741
2771
|
(0, import_invariant8.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
2742
2772
|
F: __dxlog_file9,
|
|
2743
|
-
L:
|
|
2773
|
+
L: 97,
|
|
2744
2774
|
S: this,
|
|
2745
2775
|
A: [
|
|
2746
2776
|
"!this._createInvitations.get(persistentInvitation.invitationId)",
|
|
@@ -2750,15 +2780,16 @@ var InvitationsManager = class {
|
|
|
2750
2780
|
return this.createInvitation({
|
|
2751
2781
|
...persistentInvitation,
|
|
2752
2782
|
persistent: false
|
|
2753
|
-
})
|
|
2783
|
+
});
|
|
2754
2784
|
});
|
|
2785
|
+
const cInvitations = await Promise.all(loadTasks);
|
|
2755
2786
|
return {
|
|
2756
|
-
invitations: cInvitations
|
|
2787
|
+
invitations: cInvitations.map((invitation) => invitation.get())
|
|
2757
2788
|
};
|
|
2758
2789
|
} catch (err) {
|
|
2759
2790
|
import_log7.log.catch(err, void 0, {
|
|
2760
2791
|
F: __dxlog_file9,
|
|
2761
|
-
L:
|
|
2792
|
+
L: 104,
|
|
2762
2793
|
S: this,
|
|
2763
2794
|
C: (f, a) => f(...a)
|
|
2764
2795
|
});
|
|
@@ -2789,13 +2820,13 @@ var InvitationsManager = class {
|
|
|
2789
2820
|
async authenticate({ invitationId, authCode }) {
|
|
2790
2821
|
(0, import_log7.log)("authenticating...", void 0, {
|
|
2791
2822
|
F: __dxlog_file9,
|
|
2792
|
-
L:
|
|
2823
|
+
L: 133,
|
|
2793
2824
|
S: this,
|
|
2794
2825
|
C: (f, a) => f(...a)
|
|
2795
2826
|
});
|
|
2796
2827
|
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2797
2828
|
F: __dxlog_file9,
|
|
2798
|
-
L:
|
|
2829
|
+
L: 134,
|
|
2799
2830
|
S: this,
|
|
2800
2831
|
A: [
|
|
2801
2832
|
"invitationId",
|
|
@@ -2808,7 +2839,7 @@ var InvitationsManager = class {
|
|
|
2808
2839
|
invitationId
|
|
2809
2840
|
}, {
|
|
2810
2841
|
F: __dxlog_file9,
|
|
2811
|
-
L:
|
|
2842
|
+
L: 137,
|
|
2812
2843
|
S: this,
|
|
2813
2844
|
C: (f, a) => f(...a)
|
|
2814
2845
|
});
|
|
@@ -2821,13 +2852,13 @@ var InvitationsManager = class {
|
|
|
2821
2852
|
invitationId
|
|
2822
2853
|
}, {
|
|
2823
2854
|
F: __dxlog_file9,
|
|
2824
|
-
L:
|
|
2855
|
+
L: 144,
|
|
2825
2856
|
S: this,
|
|
2826
2857
|
C: (f, a) => f(...a)
|
|
2827
2858
|
});
|
|
2828
2859
|
(0, import_invariant8.invariant)(invitationId, void 0, {
|
|
2829
2860
|
F: __dxlog_file9,
|
|
2830
|
-
L:
|
|
2861
|
+
L: 145,
|
|
2831
2862
|
S: this,
|
|
2832
2863
|
A: [
|
|
2833
2864
|
"invitationId",
|
|
@@ -2868,25 +2899,73 @@ var InvitationsManager = class {
|
|
|
2868
2899
|
this._persistentInvitationsLoadedEvent.once(ctx, () => callback());
|
|
2869
2900
|
}
|
|
2870
2901
|
}
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
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)
|
|
2888
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
|
+
}
|
|
2889
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
|
+
}
|
|
2890
2969
|
}
|
|
2891
2970
|
async _safeDeleteInvitation(invitation) {
|
|
2892
2971
|
try {
|
|
@@ -2894,7 +2973,7 @@ var InvitationsManager = class {
|
|
|
2894
2973
|
} catch (err) {
|
|
2895
2974
|
import_log7.log.catch(err, void 0, {
|
|
2896
2975
|
F: __dxlog_file9,
|
|
2897
|
-
L:
|
|
2976
|
+
L: 260,
|
|
2898
2977
|
S: this,
|
|
2899
2978
|
C: (f, a) => f(...a)
|
|
2900
2979
|
});
|
|
@@ -2990,7 +3069,7 @@ var AutomergeSpaceState = class {
|
|
|
2990
3069
|
this._isProcessingRootDocs = false;
|
|
2991
3070
|
}
|
|
2992
3071
|
async processCredential(credential) {
|
|
2993
|
-
if (!(0,
|
|
3072
|
+
if (!(0, import_credentials11.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
2994
3073
|
return;
|
|
2995
3074
|
}
|
|
2996
3075
|
this.lastEpoch = credential;
|
|
@@ -3022,11 +3101,11 @@ var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
|
3022
3101
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
3023
3102
|
var NotarizationPlugin = class {
|
|
3024
3103
|
constructor() {
|
|
3025
|
-
this._ctx = new
|
|
3104
|
+
this._ctx = new import_context8.Context();
|
|
3026
3105
|
this._extensionOpened = new import_async12.Event();
|
|
3027
3106
|
this._extensions = /* @__PURE__ */ new Set();
|
|
3028
|
-
this._processedCredentials = new import_util5.ComplexSet(
|
|
3029
|
-
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);
|
|
3030
3109
|
}
|
|
3031
3110
|
get hasWriter() {
|
|
3032
3111
|
return !!this._writer;
|
|
@@ -3147,7 +3226,7 @@ var NotarizationPlugin = class {
|
|
|
3147
3226
|
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
3148
3227
|
try {
|
|
3149
3228
|
await Promise.race([
|
|
3150
|
-
(0,
|
|
3229
|
+
(0, import_context8.rejectOnDispose)(ctx),
|
|
3151
3230
|
allNotarized,
|
|
3152
3231
|
errors.wait()
|
|
3153
3232
|
]);
|
|
@@ -3286,11 +3365,11 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3286
3365
|
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3287
3366
|
var DataSpace = class {
|
|
3288
3367
|
constructor(params) {
|
|
3289
|
-
this._ctx = new
|
|
3368
|
+
this._ctx = new import_context7.Context();
|
|
3290
3369
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3291
3370
|
this._cache = void 0;
|
|
3292
3371
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
3293
|
-
this._state =
|
|
3372
|
+
this._state = import_services8.SpaceState.CLOSED;
|
|
3294
3373
|
this.error = void 0;
|
|
3295
3374
|
this.stateUpdate = new import_async10.Event();
|
|
3296
3375
|
this.metrics = {};
|
|
@@ -3305,14 +3384,14 @@ var DataSpace = class {
|
|
|
3305
3384
|
this._callbacks = params.callbacks ?? {};
|
|
3306
3385
|
this._automergeHost = params.automergeHost;
|
|
3307
3386
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
3308
|
-
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)),
|
|
3309
3388
|
update: this._inner.stateUpdate,
|
|
3310
|
-
authTimeout:
|
|
3389
|
+
authTimeout: import_client_protocol4.AUTH_TIMEOUT
|
|
3311
3390
|
});
|
|
3312
3391
|
this._cache = params.cache;
|
|
3313
3392
|
this._state = params.initialState;
|
|
3314
3393
|
(0, import_log8.log)("new state", {
|
|
3315
|
-
state:
|
|
3394
|
+
state: import_services8.SpaceState[this._state]
|
|
3316
3395
|
}, {
|
|
3317
3396
|
F: __dxlog_file11,
|
|
3318
3397
|
L: 140,
|
|
@@ -3359,10 +3438,10 @@ var DataSpace = class {
|
|
|
3359
3438
|
await this._notarizationPlugin.open();
|
|
3360
3439
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3361
3440
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3362
|
-
await this._inner.open(new
|
|
3363
|
-
this._state =
|
|
3441
|
+
await this._inner.open(new import_context7.Context());
|
|
3442
|
+
this._state = import_services8.SpaceState.CONTROL_ONLY;
|
|
3364
3443
|
(0, import_log8.log)("new state", {
|
|
3365
|
-
state:
|
|
3444
|
+
state: import_services8.SpaceState[this._state]
|
|
3366
3445
|
}, {
|
|
3367
3446
|
F: __dxlog_file11,
|
|
3368
3447
|
L: 198,
|
|
@@ -3378,9 +3457,9 @@ var DataSpace = class {
|
|
|
3378
3457
|
}
|
|
3379
3458
|
async _close() {
|
|
3380
3459
|
await this._callbacks.beforeClose?.();
|
|
3381
|
-
this._state =
|
|
3460
|
+
this._state = import_services8.SpaceState.CLOSED;
|
|
3382
3461
|
(0, import_log8.log)("new state", {
|
|
3383
|
-
state:
|
|
3462
|
+
state: import_services8.SpaceState[this._state]
|
|
3384
3463
|
}, {
|
|
3385
3464
|
F: __dxlog_file11,
|
|
3386
3465
|
L: 212,
|
|
@@ -3388,7 +3467,7 @@ var DataSpace = class {
|
|
|
3388
3467
|
C: (f, a) => f(...a)
|
|
3389
3468
|
});
|
|
3390
3469
|
await this._ctx.dispose();
|
|
3391
|
-
this._ctx = new
|
|
3470
|
+
this._ctx = new import_context7.Context();
|
|
3392
3471
|
await this.authVerifier.close();
|
|
3393
3472
|
await this._inner.close();
|
|
3394
3473
|
await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
|
|
@@ -3412,7 +3491,7 @@ var DataSpace = class {
|
|
|
3412
3491
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3413
3492
|
await this.initializeDataPipeline();
|
|
3414
3493
|
} catch (err) {
|
|
3415
|
-
if (err instanceof import_protocols7.CancelledError || err instanceof
|
|
3494
|
+
if (err instanceof import_protocols7.CancelledError || err instanceof import_context7.ContextDisposedError) {
|
|
3416
3495
|
(0, import_log8.log)("data pipeline initialization cancelled", err, {
|
|
3417
3496
|
F: __dxlog_file11,
|
|
3418
3497
|
L: 245,
|
|
@@ -3427,9 +3506,9 @@ var DataSpace = class {
|
|
|
3427
3506
|
S: this,
|
|
3428
3507
|
C: (f, a) => f(...a)
|
|
3429
3508
|
});
|
|
3430
|
-
this._state =
|
|
3509
|
+
this._state = import_services8.SpaceState.ERROR;
|
|
3431
3510
|
(0, import_log8.log)("new state", {
|
|
3432
|
-
state:
|
|
3511
|
+
state: import_services8.SpaceState[this._state]
|
|
3433
3512
|
}, {
|
|
3434
3513
|
F: __dxlog_file11,
|
|
3435
3514
|
L: 251,
|
|
@@ -3444,12 +3523,12 @@ var DataSpace = class {
|
|
|
3444
3523
|
});
|
|
3445
3524
|
}
|
|
3446
3525
|
async initializeDataPipeline() {
|
|
3447
|
-
if (this._state !==
|
|
3526
|
+
if (this._state !== import_services8.SpaceState.CONTROL_ONLY) {
|
|
3448
3527
|
throw new import_protocols7.SystemError("Invalid operation");
|
|
3449
3528
|
}
|
|
3450
|
-
this._state =
|
|
3529
|
+
this._state = import_services8.SpaceState.INITIALIZING;
|
|
3451
3530
|
(0, import_log8.log)("new state", {
|
|
3452
|
-
state:
|
|
3531
|
+
state: import_services8.SpaceState[this._state]
|
|
3453
3532
|
}, {
|
|
3454
3533
|
F: __dxlog_file11,
|
|
3455
3534
|
L: 267,
|
|
@@ -3459,7 +3538,7 @@ var DataSpace = class {
|
|
|
3459
3538
|
await this._initializeAndReadControlPipeline();
|
|
3460
3539
|
await (0, import_async10.sleep)(1);
|
|
3461
3540
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
3462
|
-
await (0,
|
|
3541
|
+
await (0, import_context7.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
3463
3542
|
(0, import_log8.log)("data pipeline ready", void 0, {
|
|
3464
3543
|
F: __dxlog_file11,
|
|
3465
3544
|
L: 279,
|
|
@@ -3467,9 +3546,9 @@ var DataSpace = class {
|
|
|
3467
3546
|
C: (f, a) => f(...a)
|
|
3468
3547
|
});
|
|
3469
3548
|
await this._callbacks.beforeReady?.();
|
|
3470
|
-
this._state =
|
|
3549
|
+
this._state = import_services8.SpaceState.READY;
|
|
3471
3550
|
(0, import_log8.log)("new state", {
|
|
3472
|
-
state:
|
|
3551
|
+
state: import_services8.SpaceState[this._state]
|
|
3473
3552
|
}, {
|
|
3474
3553
|
F: __dxlog_file11,
|
|
3475
3554
|
L: 283,
|
|
@@ -3515,7 +3594,7 @@ var DataSpace = class {
|
|
|
3515
3594
|
spaceKey: this.key,
|
|
3516
3595
|
deviceKey: this._signingContext.deviceKey,
|
|
3517
3596
|
identityKey: this._signingContext.identityKey,
|
|
3518
|
-
designation:
|
|
3597
|
+
designation: import_credentials10.AdmittedFeed.Designation.CONTROL
|
|
3519
3598
|
}
|
|
3520
3599
|
}));
|
|
3521
3600
|
}
|
|
@@ -3532,7 +3611,7 @@ var DataSpace = class {
|
|
|
3532
3611
|
spaceKey: this.key,
|
|
3533
3612
|
deviceKey: this._signingContext.deviceKey,
|
|
3534
3613
|
identityKey: this._signingContext.identityKey,
|
|
3535
|
-
designation:
|
|
3614
|
+
designation: import_credentials10.AdmittedFeed.Designation.DATA
|
|
3536
3615
|
}
|
|
3537
3616
|
}));
|
|
3538
3617
|
}
|
|
@@ -3560,7 +3639,7 @@ var DataSpace = class {
|
|
|
3560
3639
|
queueMicrotask(async () => {
|
|
3561
3640
|
try {
|
|
3562
3641
|
await (0, import_debug3.warnAfterTimeout)(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
3563
|
-
await (0,
|
|
3642
|
+
await (0, import_context7.cancelWithContext)(this._ctx, handle.whenReady());
|
|
3564
3643
|
});
|
|
3565
3644
|
if (this._ctx.disposed) {
|
|
3566
3645
|
return;
|
|
@@ -3574,7 +3653,7 @@ var DataSpace = class {
|
|
|
3574
3653
|
});
|
|
3575
3654
|
}
|
|
3576
3655
|
} catch (err) {
|
|
3577
|
-
if (err instanceof
|
|
3656
|
+
if (err instanceof import_context7.ContextDisposedError) {
|
|
3578
3657
|
return;
|
|
3579
3658
|
}
|
|
3580
3659
|
import_log8.log.warn("error loading automerge root doc", {
|
|
@@ -3609,7 +3688,7 @@ var DataSpace = class {
|
|
|
3609
3688
|
let epoch;
|
|
3610
3689
|
switch (options?.migration) {
|
|
3611
3690
|
case void 0:
|
|
3612
|
-
case
|
|
3691
|
+
case import_services8.CreateEpochRequest.Migration.NONE:
|
|
3613
3692
|
{
|
|
3614
3693
|
epoch = {
|
|
3615
3694
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
@@ -3619,7 +3698,7 @@ var DataSpace = class {
|
|
|
3619
3698
|
};
|
|
3620
3699
|
}
|
|
3621
3700
|
break;
|
|
3622
|
-
case
|
|
3701
|
+
case import_services8.CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3623
3702
|
{
|
|
3624
3703
|
const document = this._automergeHost.repo.create();
|
|
3625
3704
|
epoch = {
|
|
@@ -3630,11 +3709,11 @@ var DataSpace = class {
|
|
|
3630
3709
|
};
|
|
3631
3710
|
}
|
|
3632
3711
|
break;
|
|
3633
|
-
case
|
|
3712
|
+
case import_services8.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
3634
3713
|
{
|
|
3635
3714
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3636
3715
|
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3637
|
-
await (0,
|
|
3716
|
+
await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3638
3717
|
const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
|
|
3639
3718
|
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3640
3719
|
F: __dxlog_file11,
|
|
@@ -3653,7 +3732,7 @@ var DataSpace = class {
|
|
|
3653
3732
|
};
|
|
3654
3733
|
}
|
|
3655
3734
|
break;
|
|
3656
|
-
case
|
|
3735
|
+
case import_services8.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
3657
3736
|
{
|
|
3658
3737
|
import_log8.log.info("Fragmenting", void 0, {
|
|
3659
3738
|
F: __dxlog_file11,
|
|
@@ -3663,7 +3742,7 @@ var DataSpace = class {
|
|
|
3663
3742
|
});
|
|
3664
3743
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3665
3744
|
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3666
|
-
await (0,
|
|
3745
|
+
await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3667
3746
|
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3668
3747
|
const properties = objects.find(([_, value]) => value.system.type?.itemId === import_echo_schema.TYPE_PROPERTIES);
|
|
3669
3748
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
@@ -3736,22 +3815,22 @@ var DataSpace = class {
|
|
|
3736
3815
|
]));
|
|
3737
3816
|
}
|
|
3738
3817
|
async activate() {
|
|
3739
|
-
if (this._state !==
|
|
3818
|
+
if (this._state !== import_services8.SpaceState.INACTIVE) {
|
|
3740
3819
|
return;
|
|
3741
3820
|
}
|
|
3742
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3821
|
+
await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.ACTIVE);
|
|
3743
3822
|
await this._open();
|
|
3744
3823
|
this.initializeDataPipelineAsync();
|
|
3745
3824
|
}
|
|
3746
3825
|
async deactivate() {
|
|
3747
|
-
if (this._state ===
|
|
3826
|
+
if (this._state === import_services8.SpaceState.INACTIVE) {
|
|
3748
3827
|
return;
|
|
3749
3828
|
}
|
|
3750
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3829
|
+
await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.INACTIVE);
|
|
3751
3830
|
await this._close();
|
|
3752
|
-
this._state =
|
|
3831
|
+
this._state = import_services8.SpaceState.INACTIVE;
|
|
3753
3832
|
(0, import_log8.log)("new state", {
|
|
3754
|
-
state:
|
|
3833
|
+
state: import_services8.SpaceState[this._state]
|
|
3755
3834
|
}, {
|
|
3756
3835
|
F: __dxlog_file11,
|
|
3757
3836
|
L: 531,
|
|
@@ -3769,7 +3848,7 @@ _ts_decorate4([
|
|
|
3769
3848
|
], DataSpace.prototype, "key", null);
|
|
3770
3849
|
_ts_decorate4([
|
|
3771
3850
|
import_tracing4.trace.info({
|
|
3772
|
-
enum:
|
|
3851
|
+
enum: import_services8.SpaceState
|
|
3773
3852
|
})
|
|
3774
3853
|
], DataSpace.prototype, "state", null);
|
|
3775
3854
|
_ts_decorate4([
|
|
@@ -3808,7 +3887,7 @@ DataSpace = _ts_decorate4([
|
|
|
3808
3887
|
], DataSpace);
|
|
3809
3888
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
3810
3889
|
const credentials = [
|
|
3811
|
-
await (0,
|
|
3890
|
+
await (0, import_credentials13.createCredential)({
|
|
3812
3891
|
signer: keyring,
|
|
3813
3892
|
issuer: space.key,
|
|
3814
3893
|
subject: space.key,
|
|
@@ -3817,14 +3896,14 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3817
3896
|
spaceKey: space.key
|
|
3818
3897
|
}
|
|
3819
3898
|
}),
|
|
3820
|
-
await (0,
|
|
3899
|
+
await (0, import_credentials13.createCredential)({
|
|
3821
3900
|
signer: keyring,
|
|
3822
3901
|
issuer: space.key,
|
|
3823
3902
|
subject: signingContext.identityKey,
|
|
3824
3903
|
assertion: {
|
|
3825
3904
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
3826
3905
|
spaceKey: space.key,
|
|
3827
|
-
role:
|
|
3906
|
+
role: import_credentials14.SpaceMember.Role.ADMIN,
|
|
3828
3907
|
profile: signingContext.getProfile(),
|
|
3829
3908
|
genesisFeedKey: space.controlFeedKey ?? (0, import_debug4.failUndefined)()
|
|
3830
3909
|
}
|
|
@@ -3836,7 +3915,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3836
3915
|
spaceKey: space.key,
|
|
3837
3916
|
identityKey: signingContext.identityKey,
|
|
3838
3917
|
deviceKey: signingContext.deviceKey,
|
|
3839
|
-
designation:
|
|
3918
|
+
designation: import_credentials14.AdmittedFeed.Designation.CONTROL
|
|
3840
3919
|
}
|
|
3841
3920
|
}),
|
|
3842
3921
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3846,7 +3925,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3846
3925
|
spaceKey: space.key,
|
|
3847
3926
|
identityKey: signingContext.identityKey,
|
|
3848
3927
|
deviceKey: signingContext.deviceKey,
|
|
3849
|
-
designation:
|
|
3928
|
+
designation: import_credentials14.AdmittedFeed.Designation.DATA
|
|
3850
3929
|
}
|
|
3851
3930
|
}),
|
|
3852
3931
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3884,18 +3963,19 @@ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
|
|
|
3884
3963
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3885
3964
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3886
3965
|
var DataSpaceManager = class {
|
|
3887
|
-
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _automergeHost, params) {
|
|
3966
|
+
constructor(_spaceManager, _metadataStore, _keyring, _signingContext, _feedStore, _automergeHost, _invitationsManager, params) {
|
|
3888
3967
|
this._spaceManager = _spaceManager;
|
|
3889
3968
|
this._metadataStore = _metadataStore;
|
|
3890
3969
|
this._keyring = _keyring;
|
|
3891
3970
|
this._signingContext = _signingContext;
|
|
3892
3971
|
this._feedStore = _feedStore;
|
|
3893
3972
|
this._automergeHost = _automergeHost;
|
|
3894
|
-
this.
|
|
3973
|
+
this._invitationsManager = _invitationsManager;
|
|
3974
|
+
this._ctx = new import_context9.Context();
|
|
3895
3975
|
this.updated = new import_async13.Event();
|
|
3896
|
-
this._spaces = new import_util6.ComplexMap(
|
|
3976
|
+
this._spaces = new import_util6.ComplexMap(import_keys10.PublicKey.hash);
|
|
3897
3977
|
this._isOpen = false;
|
|
3898
|
-
this._instanceId =
|
|
3978
|
+
this._instanceId = import_keys10.PublicKey.random().toHex();
|
|
3899
3979
|
const { spaceMemberPresenceAnnounceInterval = PRESENCE_ANNOUNCE_INTERVAL, spaceMemberPresenceOfflineTimeout = PRESENCE_OFFLINE_TIMEOUT } = params ?? {};
|
|
3900
3980
|
this._spaceMemberPresenceAnnounceInterval = spaceMemberPresenceAnnounceInterval;
|
|
3901
3981
|
this._spaceMemberPresenceOfflineTimeout = spaceMemberPresenceOfflineTimeout;
|
|
@@ -3907,7 +3987,7 @@ var DataSpaceManager = class {
|
|
|
3907
3987
|
async open() {
|
|
3908
3988
|
(0, import_log10.log)("open", void 0, {
|
|
3909
3989
|
F: __dxlog_file12,
|
|
3910
|
-
L:
|
|
3990
|
+
L: 101,
|
|
3911
3991
|
S: this,
|
|
3912
3992
|
C: (f, a) => f(...a)
|
|
3913
3993
|
});
|
|
@@ -3915,7 +3995,7 @@ var DataSpaceManager = class {
|
|
|
3915
3995
|
id: this._instanceId
|
|
3916
3996
|
}), {
|
|
3917
3997
|
F: __dxlog_file12,
|
|
3918
|
-
L:
|
|
3998
|
+
L: 102,
|
|
3919
3999
|
S: this,
|
|
3920
4000
|
C: (f, a) => f(...a)
|
|
3921
4001
|
});
|
|
@@ -3923,7 +4003,7 @@ var DataSpaceManager = class {
|
|
|
3923
4003
|
spaces: this._metadataStore.spaces.length
|
|
3924
4004
|
}, {
|
|
3925
4005
|
F: __dxlog_file12,
|
|
3926
|
-
L:
|
|
4006
|
+
L: 103,
|
|
3927
4007
|
S: this,
|
|
3928
4008
|
C: (f, a) => f(...a)
|
|
3929
4009
|
});
|
|
@@ -3933,7 +4013,7 @@ var DataSpaceManager = class {
|
|
|
3933
4013
|
spaceMetadata
|
|
3934
4014
|
}, {
|
|
3935
4015
|
F: __dxlog_file12,
|
|
3936
|
-
L:
|
|
4016
|
+
L: 107,
|
|
3937
4017
|
S: this,
|
|
3938
4018
|
C: (f, a) => f(...a)
|
|
3939
4019
|
});
|
|
@@ -3944,7 +4024,7 @@ var DataSpaceManager = class {
|
|
|
3944
4024
|
err
|
|
3945
4025
|
}, {
|
|
3946
4026
|
F: __dxlog_file12,
|
|
3947
|
-
L:
|
|
4027
|
+
L: 110,
|
|
3948
4028
|
S: this,
|
|
3949
4029
|
C: (f, a) => f(...a)
|
|
3950
4030
|
});
|
|
@@ -3953,7 +4033,7 @@ var DataSpaceManager = class {
|
|
|
3953
4033
|
this._isOpen = true;
|
|
3954
4034
|
this.updated.emit();
|
|
3955
4035
|
for (const space of this._spaces.values()) {
|
|
3956
|
-
if (space.state !==
|
|
4036
|
+
if (space.state !== import_services9.SpaceState.INACTIVE) {
|
|
3957
4037
|
space.initializeDataPipelineAsync();
|
|
3958
4038
|
}
|
|
3959
4039
|
}
|
|
@@ -3961,7 +4041,7 @@ var DataSpaceManager = class {
|
|
|
3961
4041
|
id: this._instanceId
|
|
3962
4042
|
}), {
|
|
3963
4043
|
F: __dxlog_file12,
|
|
3964
|
-
L:
|
|
4044
|
+
L: 123,
|
|
3965
4045
|
S: this,
|
|
3966
4046
|
C: (f, a) => f(...a)
|
|
3967
4047
|
});
|
|
@@ -3969,7 +4049,7 @@ var DataSpaceManager = class {
|
|
|
3969
4049
|
async close() {
|
|
3970
4050
|
(0, import_log10.log)("close", void 0, {
|
|
3971
4051
|
F: __dxlog_file12,
|
|
3972
|
-
L:
|
|
4052
|
+
L: 128,
|
|
3973
4053
|
S: this,
|
|
3974
4054
|
C: (f, a) => f(...a)
|
|
3975
4055
|
});
|
|
@@ -3985,7 +4065,7 @@ var DataSpaceManager = class {
|
|
|
3985
4065
|
async createSpace() {
|
|
3986
4066
|
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3987
4067
|
F: __dxlog_file12,
|
|
3988
|
-
L:
|
|
4068
|
+
L: 141,
|
|
3989
4069
|
S: this,
|
|
3990
4070
|
A: [
|
|
3991
4071
|
"this._isOpen",
|
|
@@ -4000,13 +4080,13 @@ var DataSpaceManager = class {
|
|
|
4000
4080
|
genesisFeedKey: controlFeedKey,
|
|
4001
4081
|
controlFeedKey,
|
|
4002
4082
|
dataFeedKey,
|
|
4003
|
-
state:
|
|
4083
|
+
state: import_services9.SpaceState.ACTIVE
|
|
4004
4084
|
};
|
|
4005
4085
|
(0, import_log10.log)("creating space...", {
|
|
4006
4086
|
spaceKey
|
|
4007
4087
|
}, {
|
|
4008
4088
|
F: __dxlog_file12,
|
|
4009
|
-
L:
|
|
4089
|
+
L: 153,
|
|
4010
4090
|
S: this,
|
|
4011
4091
|
C: (f, a) => f(...a)
|
|
4012
4092
|
});
|
|
@@ -4020,9 +4100,9 @@ var DataSpaceManager = class {
|
|
|
4020
4100
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
|
|
4021
4101
|
await this._metadataStore.addSpace(metadata);
|
|
4022
4102
|
const memberCredential = credentials[1];
|
|
4023
|
-
(0, import_invariant11.invariant)((0,
|
|
4103
|
+
(0, import_invariant11.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
4024
4104
|
F: __dxlog_file12,
|
|
4025
|
-
L:
|
|
4105
|
+
L: 166,
|
|
4026
4106
|
S: this,
|
|
4027
4107
|
A: [
|
|
4028
4108
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -4040,13 +4120,13 @@ var DataSpaceManager = class {
|
|
|
4040
4120
|
opts
|
|
4041
4121
|
}, {
|
|
4042
4122
|
F: __dxlog_file12,
|
|
4043
|
-
L:
|
|
4123
|
+
L: 178,
|
|
4044
4124
|
S: this,
|
|
4045
4125
|
C: (f, a) => f(...a)
|
|
4046
4126
|
});
|
|
4047
4127
|
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
4048
4128
|
F: __dxlog_file12,
|
|
4049
|
-
L:
|
|
4129
|
+
L: 179,
|
|
4050
4130
|
S: this,
|
|
4051
4131
|
A: [
|
|
4052
4132
|
"this._isOpen",
|
|
@@ -4055,7 +4135,7 @@ var DataSpaceManager = class {
|
|
|
4055
4135
|
});
|
|
4056
4136
|
(0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
4057
4137
|
F: __dxlog_file12,
|
|
4058
|
-
L:
|
|
4138
|
+
L: 180,
|
|
4059
4139
|
S: this,
|
|
4060
4140
|
A: [
|
|
4061
4141
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -4080,9 +4160,9 @@ var DataSpaceManager = class {
|
|
|
4080
4160
|
* TODO(dmaretskyi): Consider removing.
|
|
4081
4161
|
*/
|
|
4082
4162
|
async waitUntilSpaceReady(spaceKey) {
|
|
4083
|
-
await (0,
|
|
4163
|
+
await (0, import_context9.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
4084
4164
|
const space = this._spaces.get(spaceKey);
|
|
4085
|
-
return !!space && space.state ===
|
|
4165
|
+
return !!space && space.state === import_services9.SpaceState.READY;
|
|
4086
4166
|
}));
|
|
4087
4167
|
}
|
|
4088
4168
|
async _constructSpace(metadata) {
|
|
@@ -4090,7 +4170,7 @@ var DataSpaceManager = class {
|
|
|
4090
4170
|
metadata
|
|
4091
4171
|
}, {
|
|
4092
4172
|
F: __dxlog_file12,
|
|
4093
|
-
L:
|
|
4173
|
+
L: 213,
|
|
4094
4174
|
S: this,
|
|
4095
4175
|
C: (f, a) => f(...a)
|
|
4096
4176
|
});
|
|
@@ -4128,18 +4208,21 @@ var DataSpaceManager = class {
|
|
|
4128
4208
|
onAuthFailure: () => {
|
|
4129
4209
|
import_log10.log.warn("auth failure", void 0, {
|
|
4130
4210
|
F: __dxlog_file12,
|
|
4131
|
-
L:
|
|
4211
|
+
L: 250,
|
|
4132
4212
|
S: this,
|
|
4133
4213
|
C: (f, a) => f(...a)
|
|
4134
4214
|
});
|
|
4135
4215
|
},
|
|
4136
|
-
memberKey: this._signingContext.identityKey
|
|
4216
|
+
memberKey: this._signingContext.identityKey,
|
|
4217
|
+
onDelegatedInvitationStatusChange: (invitation, isActive) => {
|
|
4218
|
+
return this._handleInvitationStatusChange(dataSpace, invitation, isActive);
|
|
4219
|
+
}
|
|
4137
4220
|
});
|
|
4138
4221
|
controlFeed && await space.setControlFeed(controlFeed);
|
|
4139
4222
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
4140
4223
|
const dataSpace = new DataSpace({
|
|
4141
4224
|
inner: space,
|
|
4142
|
-
initialState: metadata.state ===
|
|
4225
|
+
initialState: metadata.state === import_services9.SpaceState.INACTIVE ? import_services9.SpaceState.INACTIVE : import_services9.SpaceState.CLOSED,
|
|
4143
4226
|
metadataStore: this._metadataStore,
|
|
4144
4227
|
gossip,
|
|
4145
4228
|
presence,
|
|
@@ -4152,7 +4235,7 @@ var DataSpaceManager = class {
|
|
|
4152
4235
|
space: space.key
|
|
4153
4236
|
}, {
|
|
4154
4237
|
F: __dxlog_file12,
|
|
4155
|
-
L:
|
|
4238
|
+
L: 271,
|
|
4156
4239
|
S: this,
|
|
4157
4240
|
C: (f, a) => f(...a)
|
|
4158
4241
|
});
|
|
@@ -4163,11 +4246,14 @@ var DataSpaceManager = class {
|
|
|
4163
4246
|
open: this._isOpen
|
|
4164
4247
|
}, {
|
|
4165
4248
|
F: __dxlog_file12,
|
|
4166
|
-
L:
|
|
4249
|
+
L: 274,
|
|
4167
4250
|
S: this,
|
|
4168
4251
|
C: (f, a) => f(...a)
|
|
4169
4252
|
});
|
|
4170
4253
|
if (this._isOpen) {
|
|
4254
|
+
await this._createDelegatedInvitations(dataSpace, [
|
|
4255
|
+
...space.spaceState.invitations.entries()
|
|
4256
|
+
]);
|
|
4171
4257
|
this.updated.emit();
|
|
4172
4258
|
}
|
|
4173
4259
|
},
|
|
@@ -4176,7 +4262,7 @@ var DataSpaceManager = class {
|
|
|
4176
4262
|
space: space.key
|
|
4177
4263
|
}, {
|
|
4178
4264
|
F: __dxlog_file12,
|
|
4179
|
-
L:
|
|
4265
|
+
L: 281,
|
|
4180
4266
|
S: this,
|
|
4181
4267
|
C: (f, a) => f(...a)
|
|
4182
4268
|
});
|
|
@@ -4185,7 +4271,7 @@ var DataSpaceManager = class {
|
|
|
4185
4271
|
cache: metadata.cache,
|
|
4186
4272
|
automergeHost: this._automergeHost
|
|
4187
4273
|
});
|
|
4188
|
-
if (metadata.state !==
|
|
4274
|
+
if (metadata.state !== import_services9.SpaceState.INACTIVE) {
|
|
4189
4275
|
await dataSpace.open();
|
|
4190
4276
|
}
|
|
4191
4277
|
if (metadata.controlTimeframe) {
|
|
@@ -4194,6 +4280,41 @@ var DataSpaceManager = class {
|
|
|
4194
4280
|
this._spaces.set(metadata.key, dataSpace);
|
|
4195
4281
|
return dataSpace;
|
|
4196
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
|
+
}
|
|
4197
4318
|
};
|
|
4198
4319
|
_ts_decorate5([
|
|
4199
4320
|
import_async13.synchronized
|
|
@@ -4230,10 +4351,10 @@ var SpacesServiceImpl = class {
|
|
|
4230
4351
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4231
4352
|
if (state) {
|
|
4232
4353
|
switch (state) {
|
|
4233
|
-
case
|
|
4354
|
+
case import_services10.SpaceState.ACTIVE:
|
|
4234
4355
|
await space.activate();
|
|
4235
4356
|
break;
|
|
4236
|
-
case
|
|
4357
|
+
case import_services10.SpaceState.INACTIVE:
|
|
4237
4358
|
await space.deactivate();
|
|
4238
4359
|
break;
|
|
4239
4360
|
default:
|
|
@@ -4407,7 +4528,7 @@ var SpacesServiceImpl = class {
|
|
|
4407
4528
|
identityKey: member.key,
|
|
4408
4529
|
profile: member.profile ?? {}
|
|
4409
4530
|
},
|
|
4410
|
-
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,
|
|
4411
4532
|
peerStates: peers
|
|
4412
4533
|
};
|
|
4413
4534
|
}),
|
|
@@ -4443,59 +4564,6 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
4443
4564
|
}
|
|
4444
4565
|
}
|
|
4445
4566
|
);
|
|
4446
|
-
var createDocumentsIterator = (automergeHost) => (
|
|
4447
|
-
/**
|
|
4448
|
-
* Recursively get all object data blobs from Automerge Repo.
|
|
4449
|
-
* @param ids
|
|
4450
|
-
*/
|
|
4451
|
-
// TODO(mykola): Unload automerge handles after usage.
|
|
4452
|
-
async function* getAllDocuments() {
|
|
4453
|
-
const visited = /* @__PURE__ */ new Set();
|
|
4454
|
-
async function* getObjectsFromHandle(handle) {
|
|
4455
|
-
if (visited.has(handle.documentId)) {
|
|
4456
|
-
return;
|
|
4457
|
-
}
|
|
4458
|
-
if (!handle.isReady()) {
|
|
4459
|
-
await handle.whenReady();
|
|
4460
|
-
}
|
|
4461
|
-
const doc = handle.docSync();
|
|
4462
|
-
const heads = (0, import_automerge.getHeads)(doc);
|
|
4463
|
-
if (doc.objects) {
|
|
4464
|
-
yield Object.entries(doc.objects).map(([objectId, object]) => {
|
|
4465
|
-
return {
|
|
4466
|
-
id: import_protocols12.idCodec.encode({
|
|
4467
|
-
documentId: handle.documentId,
|
|
4468
|
-
objectId
|
|
4469
|
-
}),
|
|
4470
|
-
object,
|
|
4471
|
-
currentHash: heads.join("")
|
|
4472
|
-
};
|
|
4473
|
-
});
|
|
4474
|
-
}
|
|
4475
|
-
if (doc.links) {
|
|
4476
|
-
for (const id of Object.values(doc.links)) {
|
|
4477
|
-
if (visited.has(id)) {
|
|
4478
|
-
continue;
|
|
4479
|
-
}
|
|
4480
|
-
const linkHandle = automergeHost.repo.handles[id] ?? automergeHost.repo.find(id);
|
|
4481
|
-
for await (const result of getObjectsFromHandle(linkHandle)) {
|
|
4482
|
-
yield result;
|
|
4483
|
-
}
|
|
4484
|
-
}
|
|
4485
|
-
}
|
|
4486
|
-
visited.add(handle.documentId);
|
|
4487
|
-
}
|
|
4488
|
-
for (const handle of Object.values(automergeHost.repo.handles)) {
|
|
4489
|
-
if (visited.has(handle.documentId)) {
|
|
4490
|
-
continue;
|
|
4491
|
-
}
|
|
4492
|
-
for await (const result of getObjectsFromHandle(handle)) {
|
|
4493
|
-
yield result;
|
|
4494
|
-
}
|
|
4495
|
-
visited.add(handle.documentId);
|
|
4496
|
-
}
|
|
4497
|
-
}
|
|
4498
|
-
);
|
|
4499
4567
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
4500
4568
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4501
4569
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -4507,7 +4575,7 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4507
4575
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4508
4576
|
}
|
|
4509
4577
|
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
4510
|
-
var ServiceContext = class extends
|
|
4578
|
+
var ServiceContext = class extends import_context10.Resource {
|
|
4511
4579
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
4512
4580
|
super();
|
|
4513
4581
|
this.storage = storage;
|
|
@@ -4517,7 +4585,7 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4517
4585
|
this._runtimeParams = _runtimeParams;
|
|
4518
4586
|
this.initialized = new import_async15.Trigger();
|
|
4519
4587
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
4520
|
-
this._instanceId =
|
|
4588
|
+
this._instanceId = import_keys11.PublicKey.random().toHex();
|
|
4521
4589
|
this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
|
|
4522
4590
|
this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
|
|
4523
4591
|
this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
|
|
@@ -4552,16 +4620,16 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4552
4620
|
})
|
|
4553
4621
|
});
|
|
4554
4622
|
this.indexer = new import_indexing.Indexer({
|
|
4623
|
+
db: this.level,
|
|
4555
4624
|
indexStore: new import_indexing.IndexStore({
|
|
4556
4625
|
db: level.sublevel("index-storage")
|
|
4557
4626
|
}),
|
|
4558
4627
|
metadataStore: this.indexMetadata,
|
|
4559
|
-
loadDocuments: createSelectedDocumentsIterator(this.automergeHost)
|
|
4560
|
-
getAllDocuments: createDocumentsIterator(this.automergeHost)
|
|
4628
|
+
loadDocuments: createSelectedDocumentsIterator(this.automergeHost)
|
|
4561
4629
|
});
|
|
4562
4630
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4563
4631
|
this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
|
|
4564
|
-
this._handlerFactories.set(
|
|
4632
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
4565
4633
|
}
|
|
4566
4634
|
async _open(ctx) {
|
|
4567
4635
|
await this._checkStorageVersion();
|
|
@@ -4640,7 +4708,7 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4640
4708
|
}
|
|
4641
4709
|
async createIdentity(params = {}) {
|
|
4642
4710
|
const identity = await this.identityManager.createIdentity(params);
|
|
4643
|
-
await this._initialize(new
|
|
4711
|
+
await this._initialize(new import_context10.Context());
|
|
4644
4712
|
return identity;
|
|
4645
4713
|
}
|
|
4646
4714
|
getInvitationHandler(invitation) {
|
|
@@ -4666,7 +4734,7 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4666
4734
|
}
|
|
4667
4735
|
async _acceptIdentity(params) {
|
|
4668
4736
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
4669
|
-
await this._initialize(new
|
|
4737
|
+
await this._initialize(new import_context10.Context());
|
|
4670
4738
|
return identity;
|
|
4671
4739
|
}
|
|
4672
4740
|
async _checkStorageVersion() {
|
|
@@ -4697,12 +4765,12 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4697
4765
|
});
|
|
4698
4766
|
}
|
|
4699
4767
|
};
|
|
4700
|
-
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);
|
|
4701
4769
|
await this.dataSpaceManager.open();
|
|
4702
|
-
this._handlerFactories.set(
|
|
4770
|
+
this._handlerFactories.set(import_services11.Invitation.Kind.SPACE, (invitation) => {
|
|
4703
4771
|
(0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4704
4772
|
F: __dxlog_file14,
|
|
4705
|
-
L:
|
|
4773
|
+
L: 265,
|
|
4706
4774
|
S: this,
|
|
4707
4775
|
A: [
|
|
4708
4776
|
"this.dataSpaceManager",
|
|
@@ -4714,7 +4782,7 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4714
4782
|
this.initialized.wake();
|
|
4715
4783
|
this._deviceSpaceSync = {
|
|
4716
4784
|
processCredential: async (credential) => {
|
|
4717
|
-
const assertion = (0,
|
|
4785
|
+
const assertion = (0, import_credentials15.getCredentialAssertion)(credential);
|
|
4718
4786
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
4719
4787
|
return;
|
|
4720
4788
|
}
|
|
@@ -4726,7 +4794,7 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4726
4794
|
details: assertion
|
|
4727
4795
|
}, {
|
|
4728
4796
|
F: __dxlog_file14,
|
|
4729
|
-
L:
|
|
4797
|
+
L: 281,
|
|
4730
4798
|
S: this,
|
|
4731
4799
|
C: (f, a) => f(...a)
|
|
4732
4800
|
});
|
|
@@ -4737,7 +4805,7 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4737
4805
|
details: assertion
|
|
4738
4806
|
}, {
|
|
4739
4807
|
F: __dxlog_file14,
|
|
4740
|
-
L:
|
|
4808
|
+
L: 285,
|
|
4741
4809
|
S: this,
|
|
4742
4810
|
C: (f, a) => f(...a)
|
|
4743
4811
|
});
|
|
@@ -4748,7 +4816,7 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4748
4816
|
details: assertion
|
|
4749
4817
|
}, {
|
|
4750
4818
|
F: __dxlog_file14,
|
|
4751
|
-
L:
|
|
4819
|
+
L: 290,
|
|
4752
4820
|
S: this,
|
|
4753
4821
|
C: (f, a) => f(...a)
|
|
4754
4822
|
});
|
|
@@ -4759,7 +4827,7 @@ var ServiceContext = class extends import_context9.Resource {
|
|
|
4759
4827
|
} catch (err) {
|
|
4760
4828
|
import_log12.log.catch(err, void 0, {
|
|
4761
4829
|
F: __dxlog_file14,
|
|
4762
|
-
L:
|
|
4830
|
+
L: 296,
|
|
4763
4831
|
S: this,
|
|
4764
4832
|
C: (f, a) => f(...a)
|
|
4765
4833
|
});
|
|
@@ -4801,26 +4869,26 @@ var ServiceRegistry = class {
|
|
|
4801
4869
|
delete this._handlers[name];
|
|
4802
4870
|
}
|
|
4803
4871
|
};
|
|
4804
|
-
var DXOS_VERSION = "0.4.10-main.
|
|
4872
|
+
var DXOS_VERSION = "0.4.10-main.e99db3e";
|
|
4805
4873
|
var getPlatform = () => {
|
|
4806
4874
|
if (process.browser) {
|
|
4807
4875
|
if (typeof window !== "undefined") {
|
|
4808
4876
|
const { userAgent } = window.navigator;
|
|
4809
4877
|
return {
|
|
4810
|
-
type:
|
|
4878
|
+
type: import_services13.Platform.PLATFORM_TYPE.BROWSER,
|
|
4811
4879
|
userAgent,
|
|
4812
4880
|
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
4813
4881
|
};
|
|
4814
4882
|
} else {
|
|
4815
4883
|
return {
|
|
4816
|
-
type:
|
|
4884
|
+
type: import_services13.Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
4817
4885
|
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
4818
4886
|
};
|
|
4819
4887
|
}
|
|
4820
4888
|
} else {
|
|
4821
4889
|
const { platform: platform2, version, arch } = process;
|
|
4822
4890
|
return {
|
|
4823
|
-
type:
|
|
4891
|
+
type: import_services13.Platform.PLATFORM_TYPE.NODE,
|
|
4824
4892
|
platform: platform2,
|
|
4825
4893
|
arch,
|
|
4826
4894
|
runtime: version,
|
|
@@ -4907,7 +4975,7 @@ var getSpaceStats = async (space) => {
|
|
|
4907
4975
|
const stats = {
|
|
4908
4976
|
key: space.key,
|
|
4909
4977
|
metrics: space.metrics,
|
|
4910
|
-
epochs: space.inner.spaceState.credentials.filter((0,
|
|
4978
|
+
epochs: space.inner.spaceState.credentials.filter((0, import_credentials16.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
4911
4979
|
...credential.subject.assertion,
|
|
4912
4980
|
id: credential.id
|
|
4913
4981
|
})),
|
|
@@ -4918,7 +4986,7 @@ var getSpaceStats = async (space) => {
|
|
|
4918
4986
|
displayName: member.assertion.profile?.displayName
|
|
4919
4987
|
}
|
|
4920
4988
|
},
|
|
4921
|
-
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
|
|
4922
4990
|
})),
|
|
4923
4991
|
pipeline: {
|
|
4924
4992
|
// TODO(burdon): Pick properties from credentials if needed.
|
|
@@ -4982,9 +5050,9 @@ var DevicesServiceImpl = class {
|
|
|
4982
5050
|
const peerState = peers.find((peer) => peer.identityKey.equals(key));
|
|
4983
5051
|
return {
|
|
4984
5052
|
deviceKey: key,
|
|
4985
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ?
|
|
5053
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services16.DeviceKind.CURRENT : import_services16.DeviceKind.TRUSTED,
|
|
4986
5054
|
profile,
|
|
4987
|
-
presence: isMe ?
|
|
5055
|
+
presence: isMe ? import_services16.Device.PresenceState.ONLINE : peerState ? import_services16.Device.PresenceState.ONLINE : import_services16.Device.PresenceState.OFFLINE
|
|
4988
5056
|
};
|
|
4989
5057
|
})
|
|
4990
5058
|
});
|
|
@@ -5083,7 +5151,7 @@ var LoggingServiceImpl = class {
|
|
|
5083
5151
|
constructor() {
|
|
5084
5152
|
this._logs = new import_async18.Event();
|
|
5085
5153
|
this._started = Date.now();
|
|
5086
|
-
this._sessionId =
|
|
5154
|
+
this._sessionId = import_keys13.PublicKey.random().toHex();
|
|
5087
5155
|
this._logProcessor = (_config, entry2) => {
|
|
5088
5156
|
this._logs.emit(entry2);
|
|
5089
5157
|
};
|
|
@@ -5180,16 +5248,16 @@ var LoggingServiceImpl = class {
|
|
|
5180
5248
|
};
|
|
5181
5249
|
var matchFilter = (filter, level, path2, options) => {
|
|
5182
5250
|
switch (options) {
|
|
5183
|
-
case
|
|
5251
|
+
case import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
5184
5252
|
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5185
|
-
case
|
|
5253
|
+
case import_services17.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
5186
5254
|
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5187
5255
|
}
|
|
5188
5256
|
};
|
|
5189
5257
|
var shouldLog = (entry2, request) => {
|
|
5190
|
-
const options = request.options ??
|
|
5258
|
+
const options = request.options ?? import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5191
5259
|
if (request.filters === void 0) {
|
|
5192
|
-
return options ===
|
|
5260
|
+
return options === import_services17.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5193
5261
|
} else {
|
|
5194
5262
|
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
5195
5263
|
}
|
|
@@ -5226,7 +5294,7 @@ var NetworkServiceImpl = class {
|
|
|
5226
5294
|
}
|
|
5227
5295
|
};
|
|
5228
5296
|
var getRootPath = (config) => {
|
|
5229
|
-
const { dataRoot = (0, import_util11.isNode)() ?
|
|
5297
|
+
const { dataRoot = (0, import_util11.isNode)() ? import_client_protocol6.DX_DATA : "dxos/storage" } = config ?? {};
|
|
5230
5298
|
return `${dataRoot}/`;
|
|
5231
5299
|
};
|
|
5232
5300
|
var isPersistent = (config) => {
|
|
@@ -5277,7 +5345,7 @@ var toStorageType = (type) => {
|
|
|
5277
5345
|
};
|
|
5278
5346
|
var createLevel = async (config) => {
|
|
5279
5347
|
const persistent = isPersistent(config);
|
|
5280
|
-
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()}`;
|
|
5281
5349
|
const level = new import_level.Level(storagePath);
|
|
5282
5350
|
await level.open();
|
|
5283
5351
|
return level;
|
|
@@ -5302,8 +5370,8 @@ var SystemServiceImpl = class {
|
|
|
5302
5370
|
return {
|
|
5303
5371
|
timestamp: /* @__PURE__ */ new Date(),
|
|
5304
5372
|
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util12.jsonKeyReplacer)({
|
|
5305
|
-
truncate: keys ===
|
|
5306
|
-
humanize: keys ===
|
|
5373
|
+
truncate: keys === import_services18.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
5374
|
+
humanize: keys === import_services18.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
5307
5375
|
})))
|
|
5308
5376
|
};
|
|
5309
5377
|
}
|
|
@@ -5377,7 +5445,7 @@ var ClientServicesHost = class {
|
|
|
5377
5445
|
lockKey,
|
|
5378
5446
|
onAcquire: () => {
|
|
5379
5447
|
if (!this._opening) {
|
|
5380
|
-
void this.open(new
|
|
5448
|
+
void this.open(new import_context11.Context());
|
|
5381
5449
|
}
|
|
5382
5450
|
},
|
|
5383
5451
|
onRelease: () => this.close()
|
|
@@ -5386,14 +5454,14 @@ var ClientServicesHost = class {
|
|
|
5386
5454
|
this._systemService = new SystemServiceImpl({
|
|
5387
5455
|
config: () => this._config,
|
|
5388
5456
|
statusUpdate: this._statusUpdate,
|
|
5389
|
-
getCurrentStatus: () => this.isOpen ?
|
|
5457
|
+
getCurrentStatus: () => this.isOpen ? import_services15.SystemStatus.ACTIVE : import_services15.SystemStatus.INACTIVE,
|
|
5390
5458
|
getDiagnostics: () => {
|
|
5391
5459
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
5392
5460
|
},
|
|
5393
5461
|
onUpdateStatus: async (status) => {
|
|
5394
|
-
if (!this.isOpen && status ===
|
|
5462
|
+
if (!this.isOpen && status === import_services15.SystemStatus.ACTIVE) {
|
|
5395
5463
|
await this._resourceLock?.acquire();
|
|
5396
|
-
} else if (this.isOpen && status ===
|
|
5464
|
+
} else if (this.isOpen && status === import_services15.SystemStatus.INACTIVE) {
|
|
5397
5465
|
await this._resourceLock?.release();
|
|
5398
5466
|
}
|
|
5399
5467
|
},
|
|
@@ -5403,7 +5471,7 @@ var ClientServicesHost = class {
|
|
|
5403
5471
|
});
|
|
5404
5472
|
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
5405
5473
|
this._loggingService = new LoggingServiceImpl();
|
|
5406
|
-
this._serviceRegistry = new ServiceRegistry(
|
|
5474
|
+
this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
|
|
5407
5475
|
SystemService: this._systemService,
|
|
5408
5476
|
TracingService: this._tracingService
|
|
5409
5477
|
});
|
|
@@ -5499,7 +5567,7 @@ var ClientServicesHost = class {
|
|
|
5499
5567
|
if (this._open) {
|
|
5500
5568
|
return;
|
|
5501
5569
|
}
|
|
5502
|
-
const traceId =
|
|
5570
|
+
const traceId = import_keys12.PublicKey.random().toHex();
|
|
5503
5571
|
import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.begin({
|
|
5504
5572
|
id: traceId
|
|
5505
5573
|
}), {
|
|
@@ -5592,7 +5660,7 @@ var ClientServicesHost = class {
|
|
|
5592
5660
|
this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
|
|
5593
5661
|
url: devtoolsProxy,
|
|
5594
5662
|
requested: {},
|
|
5595
|
-
exposed:
|
|
5663
|
+
exposed: import_client_protocol5.clientServiceBundle,
|
|
5596
5664
|
handlers: this.services
|
|
5597
5665
|
});
|
|
5598
5666
|
void this._devtoolsProxy.open();
|
|
@@ -5653,7 +5721,7 @@ var ClientServicesHost = class {
|
|
|
5653
5721
|
});
|
|
5654
5722
|
}
|
|
5655
5723
|
async reset() {
|
|
5656
|
-
const traceId =
|
|
5724
|
+
const traceId = import_keys12.PublicKey.random().toHex();
|
|
5657
5725
|
import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.begin({
|
|
5658
5726
|
id: traceId
|
|
5659
5727
|
}), {
|
|
@@ -5704,16 +5772,16 @@ var ClientServicesHost = class {
|
|
|
5704
5772
|
await document.whenReady();
|
|
5705
5773
|
const properties = {
|
|
5706
5774
|
system: {
|
|
5707
|
-
type: (0, import_echo_pipeline5.encodeReference)((0, import_echo_schema2.getTypeReference)(
|
|
5775
|
+
type: (0, import_echo_pipeline5.encodeReference)((0, import_echo_schema2.getTypeReference)(import_client_protocol5.Properties))
|
|
5708
5776
|
},
|
|
5709
5777
|
data: {
|
|
5710
|
-
[
|
|
5778
|
+
[import_client_protocol5.defaultKey]: identity.identityKey.toHex()
|
|
5711
5779
|
},
|
|
5712
5780
|
meta: {
|
|
5713
5781
|
keys: []
|
|
5714
5782
|
}
|
|
5715
5783
|
};
|
|
5716
|
-
const propertiesId =
|
|
5784
|
+
const propertiesId = import_keys12.PublicKey.random().toHex();
|
|
5717
5785
|
document.change((doc) => {
|
|
5718
5786
|
(0, import_util9.assignDeep)(doc, [
|
|
5719
5787
|
"objects",
|
|
@@ -5748,7 +5816,7 @@ var DiagnosticsCollector = class {
|
|
|
5748
5816
|
}
|
|
5749
5817
|
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
5750
5818
|
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
5751
|
-
keys: options.humanize ?
|
|
5819
|
+
keys: options.humanize ? import_services14.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services14.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
5752
5820
|
});
|
|
5753
5821
|
const clientDiagnostics = {
|
|
5754
5822
|
config,
|
|
@@ -5813,4 +5881,4 @@ var findConfigs = () => {
|
|
|
5813
5881
|
subscribeToSpaces,
|
|
5814
5882
|
subscribeToSwarmInfo
|
|
5815
5883
|
});
|
|
5816
|
-
//# sourceMappingURL=chunk-
|
|
5884
|
+
//# sourceMappingURL=chunk-GAS53XAH.cjs.map
|