@dxos/client-services 0.1.25 → 0.1.27-next.a0dff21
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-R2FEBB66.mjs → chunk-OTSGRZZI.mjs} +796 -579
- package/dist/lib/browser/chunk-OTSGRZZI.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +19 -15
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +46 -46
- package/dist/lib/browser/packlets/testing/index.mjs.map +4 -4
- package/dist/lib/node/index.cjs +864 -641
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +753 -631
- package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/packlets/deprecated/index.d.ts +0 -3
- package/dist/types/src/packlets/deprecated/index.d.ts.map +1 -1
- package/dist/types/src/packlets/{identity/devices-service-impl.d.ts → devices/devices-service.d.ts} +4 -3
- package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -0
- package/dist/types/src/packlets/devices/index.d.ts +2 -0
- package/dist/types/src/packlets/devices/index.d.ts.map +1 -0
- package/dist/types/src/packlets/identity/authenticator.d.ts +1 -1
- package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts +2 -2
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts +14 -0
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -0
- package/dist/types/src/packlets/identity/identity.d.ts +2 -2
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/index.d.ts +1 -0
- package/dist/types/src/packlets/identity/index.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/{halo-invitations-handler.d.ts → device-invitations-handler.d.ts} +5 -5
- package/dist/types/src/packlets/invitations/device-invitations-handler.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/device-invitations-handler.test.d.ts +2 -0
- package/dist/types/src/packlets/invitations/device-invitations-handler.test.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/{halo-invitations-proxy.d.ts → device-invitations-proxy.d.ts} +2 -2
- package/dist/types/src/packlets/invitations/device-invitations-proxy.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/{halo-invitations-service.d.ts → device-invitations-service.d.ts} +2 -2
- package/dist/types/src/packlets/invitations/device-invitations-service.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/device-invitations-service.test.d.ts +2 -0
- package/dist/types/src/packlets/invitations/device-invitations-service.test.d.ts.map +1 -0
- package/dist/types/src/packlets/invitations/index.d.ts +3 -3
- package/dist/types/src/packlets/invitations/index.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts +6 -0
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitations-handler.d.ts +1 -1
- package/dist/types/src/packlets/invitations/space-invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/services/index.d.ts +0 -1
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +3 -3
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-definitions.d.ts +5 -7
- package/dist/types/src/packlets/services/service-definitions.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +1 -0
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +12 -5
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/system/index.d.ts +2 -0
- package/dist/types/src/packlets/system/index.d.ts.map +1 -0
- package/dist/types/src/packlets/system/system-service.d.ts +28 -0
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -0
- package/dist/types/src/packlets/system/system-service.test.d.ts +2 -0
- package/dist/types/src/packlets/system/system-service.test.d.ts.map +1 -0
- package/dist/types/src/packlets/testing/index.d.ts +1 -1
- package/dist/types/src/packlets/testing/index.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +11 -4
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts +6 -1
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/index.d.ts +2 -0
- package/dist/types/src/packlets/vault/index.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/services.d.ts +9 -1
- package/dist/types/src/packlets/vault/services.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/shell-controller.d.ts +18 -0
- package/dist/types/src/packlets/vault/shell-controller.d.ts.map +1 -0
- package/dist/types/src/packlets/vault/shell-runtime.d.ts +45 -0
- package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +1 -0
- package/dist/types/src/packlets/vault/worker-runtime.d.ts +2 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts +4 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/package.json +29 -28
- package/src/index.ts +0 -1
- package/src/packlets/deprecated/index.ts +0 -3
- package/src/packlets/{identity/devices-service-impl.ts → devices/devices-service.ts} +10 -8
- package/src/packlets/devices/index.ts +5 -0
- package/src/packlets/devtools/spaces.ts +1 -1
- package/src/packlets/identity/authenticator.ts +1 -1
- package/src/packlets/identity/identity-manager.test.ts +1 -1
- package/src/packlets/identity/identity-manager.ts +2 -2
- package/src/packlets/identity/identity-service.ts +67 -0
- package/src/packlets/identity/identity.test.ts +1 -1
- package/src/packlets/identity/identity.ts +1 -1
- package/src/packlets/identity/index.ts +1 -0
- package/src/packlets/invitations/{halo-invitations-handler.test.ts → device-invitations-handler.test.ts} +2 -2
- package/src/packlets/invitations/{halo-invitations-handler.ts → device-invitations-handler.ts} +4 -4
- package/src/packlets/invitations/{halo-invitations-proxy.ts → device-invitations-proxy.ts} +1 -1
- package/src/packlets/invitations/{halo-invitations-service.test.ts → device-invitations-service.test.ts} +10 -10
- package/src/packlets/invitations/{halo-invitations-service.ts → device-invitations-service.ts} +1 -1
- package/src/packlets/invitations/index.ts +3 -3
- package/src/packlets/invitations/invitations-handler.ts +6 -0
- package/src/packlets/invitations/invitations-service.ts +2 -2
- package/src/packlets/invitations/space-invitations-handler.test.ts +1 -1
- package/src/packlets/invitations/space-invitations-handler.ts +55 -20
- package/src/packlets/services/index.ts +0 -1
- package/src/packlets/services/service-context.test.ts +3 -3
- package/src/packlets/services/service-context.ts +5 -5
- package/src/packlets/services/service-definitions.ts +14 -14
- package/src/packlets/services/service-host.test.ts +9 -9
- package/src/packlets/services/service-host.ts +40 -25
- package/src/packlets/spaces/data-space-manager.test.ts +1 -1
- package/src/packlets/spaces/data-space-manager.ts +4 -4
- package/src/packlets/spaces/data-space.ts +3 -3
- package/src/packlets/spaces/spaces-service.ts +93 -11
- package/src/packlets/system/index.ts +5 -0
- package/src/packlets/system/system-service.test.ts +80 -0
- package/src/packlets/system/system-service.ts +70 -0
- package/src/packlets/testing/index.ts +1 -1
- package/src/packlets/testing/test-builder.ts +3 -3
- package/src/packlets/vault/iframe-host-runtime.ts +28 -10
- package/src/packlets/vault/iframe-proxy-runtime.ts +16 -1
- package/src/packlets/vault/index.ts +2 -0
- package/src/packlets/vault/services.ts +17 -1
- package/src/packlets/vault/shell-controller.ts +56 -0
- package/src/packlets/vault/shell-runtime.ts +121 -0
- package/src/packlets/vault/worker-runtime.ts +3 -1
- package/src/packlets/vault/worker-session.ts +28 -19
- package/dist/lib/browser/chunk-R2FEBB66.mjs.map +0 -7
- package/dist/types/src/packlets/deprecated/invitations.d.ts +0 -47
- package/dist/types/src/packlets/deprecated/invitations.d.ts.map +0 -1
- package/dist/types/src/packlets/deprecated/profile.d.ts +0 -18
- package/dist/types/src/packlets/deprecated/profile.d.ts.map +0 -1
- package/dist/types/src/packlets/deprecated/space.d.ts +0 -23
- package/dist/types/src/packlets/deprecated/space.d.ts.map +0 -1
- package/dist/types/src/packlets/deprecated/system.d.ts +0 -24
- package/dist/types/src/packlets/deprecated/system.d.ts.map +0 -1
- package/dist/types/src/packlets/identity/devices-service-impl.d.ts.map +0 -1
- package/dist/types/src/packlets/invitations/halo-invitations-handler.d.ts.map +0 -1
- package/dist/types/src/packlets/invitations/halo-invitations-handler.test.d.ts +0 -2
- package/dist/types/src/packlets/invitations/halo-invitations-handler.test.d.ts.map +0 -1
- package/dist/types/src/packlets/invitations/halo-invitations-proxy.d.ts.map +0 -1
- package/dist/types/src/packlets/invitations/halo-invitations-service.d.ts.map +0 -1
- package/dist/types/src/packlets/invitations/halo-invitations-service.test.d.ts +0 -2
- package/dist/types/src/packlets/invitations/halo-invitations-service.test.d.ts.map +0 -1
- package/dist/types/src/packlets/services/signer.d.ts +0 -6
- package/dist/types/src/packlets/services/signer.d.ts.map +0 -1
- package/src/packlets/deprecated/invitations.ts +0 -63
- package/src/packlets/deprecated/profile.ts +0 -85
- package/src/packlets/deprecated/space.ts +0 -258
- package/src/packlets/deprecated/system.ts +0 -48
- package/src/packlets/services/signer.ts +0 -11
|
@@ -59,10 +59,53 @@ var createMockCredential = async ({ signer, issuer }) => (0, import_credentials.
|
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
+
// packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
|
|
63
|
+
var import_node_assert = __toESM(require("node:assert"));
|
|
64
|
+
var import_async = require("@dxos/async");
|
|
65
|
+
var import_debug = require("@dxos/debug");
|
|
66
|
+
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
67
|
+
var performInvitation = async (host, guest, context) => {
|
|
68
|
+
const done1 = new import_async.Trigger();
|
|
69
|
+
const done2 = new import_async.Trigger();
|
|
70
|
+
const observable1 = await host.createInvitation(context, {
|
|
71
|
+
type: import_services.Invitation.Type.INTERACTIVE_TESTING
|
|
72
|
+
});
|
|
73
|
+
observable1.subscribe({
|
|
74
|
+
onConnecting: async (invitation1) => {
|
|
75
|
+
const observable2 = await guest.acceptInvitation(invitation1, {
|
|
76
|
+
type: import_services.Invitation.Type.INTERACTIVE_TESTING
|
|
77
|
+
});
|
|
78
|
+
observable2.subscribe({
|
|
79
|
+
onConnecting: async (invitation2) => {
|
|
80
|
+
(0, import_node_assert.default)(invitation1.swarmKey.equals(invitation2.swarmKey));
|
|
81
|
+
},
|
|
82
|
+
onConnected: async (invitation2) => {
|
|
83
|
+
},
|
|
84
|
+
onSuccess: (invitation) => {
|
|
85
|
+
done2.wake(invitation);
|
|
86
|
+
},
|
|
87
|
+
onCancelled: () => (0, import_debug.raise)(new Error()),
|
|
88
|
+
onTimeout: (err) => (0, import_debug.raise)(err),
|
|
89
|
+
onError: (err) => (0, import_debug.raise)(err)
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
onConnected: async (invitation1) => {
|
|
93
|
+
},
|
|
94
|
+
onCancelled: () => (0, import_debug.raise)(new Error("cancelled")),
|
|
95
|
+
onSuccess: (invitation) => {
|
|
96
|
+
done1.wake(invitation);
|
|
97
|
+
},
|
|
98
|
+
onTimeout: (err) => (0, import_debug.raise)(err),
|
|
99
|
+
onError: (err) => (0, import_debug.raise)(err)
|
|
100
|
+
});
|
|
101
|
+
await done1.wait();
|
|
102
|
+
await done2.wait();
|
|
103
|
+
};
|
|
104
|
+
|
|
62
105
|
// packages/sdk/client-services/src/packlets/testing/test-builder.ts
|
|
63
106
|
var import_credentials13 = require("@dxos/credentials");
|
|
64
|
-
var
|
|
65
|
-
var import_testing = require("@dxos/echo-
|
|
107
|
+
var import_echo_pipeline6 = require("@dxos/echo-pipeline");
|
|
108
|
+
var import_testing = require("@dxos/echo-pipeline/testing");
|
|
66
109
|
var import_feed_store5 = require("@dxos/feed-store");
|
|
67
110
|
var import_keyring2 = require("@dxos/keyring");
|
|
68
111
|
var import_messaging3 = require("@dxos/messaging");
|
|
@@ -70,16 +113,16 @@ var import_network_manager6 = require("@dxos/network-manager");
|
|
|
70
113
|
var import_random_access_storage2 = require("@dxos/random-access-storage");
|
|
71
114
|
|
|
72
115
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
var
|
|
76
|
-
var
|
|
116
|
+
var import_async12 = require("@dxos/async");
|
|
117
|
+
var import_credentials12 = require("@dxos/credentials");
|
|
118
|
+
var import_debug5 = require("@dxos/debug");
|
|
119
|
+
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
77
120
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
78
121
|
var import_keyring = require("@dxos/keyring");
|
|
79
122
|
var import_log10 = require("@dxos/log");
|
|
80
123
|
|
|
81
124
|
// packages/sdk/client-services/src/packlets/identity/authenticator.ts
|
|
82
|
-
var
|
|
125
|
+
var import_async2 = require("@dxos/async");
|
|
83
126
|
var import_context = require("@dxos/context");
|
|
84
127
|
var import_credentials2 = require("@dxos/credentials");
|
|
85
128
|
var import_log = require("@dxos/log");
|
|
@@ -149,7 +192,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
149
192
|
});
|
|
150
193
|
return true;
|
|
151
194
|
}
|
|
152
|
-
const trigger = new
|
|
195
|
+
const trigger = new import_async2.Trigger();
|
|
153
196
|
this._ctx.onDispose(() => {
|
|
154
197
|
trigger.wake(false);
|
|
155
198
|
});
|
|
@@ -193,17 +236,17 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
193
236
|
};
|
|
194
237
|
|
|
195
238
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
196
|
-
var
|
|
197
|
-
var
|
|
239
|
+
var import_node_assert2 = __toESM(require("node:assert"));
|
|
240
|
+
var import_async3 = require("@dxos/async");
|
|
198
241
|
var import_credentials3 = require("@dxos/credentials");
|
|
199
|
-
var
|
|
242
|
+
var import_debug2 = require("@dxos/debug");
|
|
200
243
|
var import_feed_store = require("@dxos/feed-store");
|
|
201
244
|
var import_log2 = require("@dxos/log");
|
|
202
245
|
var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
203
246
|
var AUTH_TIMEOUT = 3e4;
|
|
204
247
|
var Identity = class {
|
|
205
248
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
206
|
-
this.stateUpdate = new
|
|
249
|
+
this.stateUpdate = new import_async3.Event();
|
|
207
250
|
this.space = space;
|
|
208
251
|
this._signer = signer;
|
|
209
252
|
this.identityKey = identityKey;
|
|
@@ -266,8 +309,8 @@ var Identity = class {
|
|
|
266
309
|
var _a, _b;
|
|
267
310
|
return {
|
|
268
311
|
deviceKey: this.deviceKey,
|
|
269
|
-
controlFeedKey: (_a = this.space.controlFeedKey) != null ? _a : (0,
|
|
270
|
-
dataFeedKey: (_b = this.space.dataFeedKey) != null ? _b : (0,
|
|
312
|
+
controlFeedKey: (_a = this.space.controlFeedKey) != null ? _a : (0, import_debug2.failUndefined)(),
|
|
313
|
+
dataFeedKey: (_b = this.space.dataFeedKey) != null ? _b : (0, import_debug2.failUndefined)()
|
|
271
314
|
};
|
|
272
315
|
}
|
|
273
316
|
/**
|
|
@@ -275,7 +318,7 @@ var Identity = class {
|
|
|
275
318
|
* Requires identity to be ready.
|
|
276
319
|
*/
|
|
277
320
|
getIdentityCredentialSigner() {
|
|
278
|
-
(0,
|
|
321
|
+
(0, import_node_assert2.default)(this._deviceStateMachine.processor.deviceCredentialChain, "Device credential chain is not ready.");
|
|
279
322
|
return (0, import_credentials3.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.processor.deviceCredentialChain, this.deviceKey);
|
|
280
323
|
}
|
|
281
324
|
/**
|
|
@@ -336,8 +379,8 @@ var Identity = class {
|
|
|
336
379
|
};
|
|
337
380
|
|
|
338
381
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
339
|
-
var
|
|
340
|
-
var
|
|
382
|
+
var import_node_assert3 = __toESM(require("node:assert"));
|
|
383
|
+
var import_async4 = require("@dxos/async");
|
|
341
384
|
var import_credentials5 = require("@dxos/credentials");
|
|
342
385
|
var import_log3 = require("@dxos/log");
|
|
343
386
|
var import_credentials6 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
@@ -350,7 +393,7 @@ var IdentityManager = class {
|
|
|
350
393
|
this._keyring = _keyring;
|
|
351
394
|
this._feedStore = _feedStore;
|
|
352
395
|
this._spaceManager = _spaceManager;
|
|
353
|
-
this.stateUpdate = new
|
|
396
|
+
this.stateUpdate = new import_async4.Event();
|
|
354
397
|
}
|
|
355
398
|
get identity() {
|
|
356
399
|
return this._identity;
|
|
@@ -378,7 +421,7 @@ var IdentityManager = class {
|
|
|
378
421
|
await ((_a = this._identity) == null ? void 0 : _a.close());
|
|
379
422
|
}
|
|
380
423
|
async createIdentity({ displayName } = {}) {
|
|
381
|
-
(0,
|
|
424
|
+
(0, import_node_assert3.default)(!this._identity, "Identity already exists.");
|
|
382
425
|
(0, import_log3.log)("creating identity...", {}, {
|
|
383
426
|
file: "identity-manager.ts",
|
|
384
427
|
line: 78,
|
|
@@ -447,7 +490,7 @@ var IdentityManager = class {
|
|
|
447
490
|
scope: this,
|
|
448
491
|
callSite: (f, a) => f(...a)
|
|
449
492
|
});
|
|
450
|
-
(0,
|
|
493
|
+
(0, import_node_assert3.default)(!this._identity, "Identity already exists.");
|
|
451
494
|
const identityRecord = {
|
|
452
495
|
identityKey: params.identityKey,
|
|
453
496
|
deviceKey: params.deviceKey,
|
|
@@ -476,7 +519,7 @@ var IdentityManager = class {
|
|
|
476
519
|
return identity;
|
|
477
520
|
}
|
|
478
521
|
async _constructIdentity(identityRecord) {
|
|
479
|
-
(0,
|
|
522
|
+
(0, import_node_assert3.default)(!this._identity);
|
|
480
523
|
(0, import_log3.log)("constructing identity", {
|
|
481
524
|
identityRecord
|
|
482
525
|
}, {
|
|
@@ -531,32 +574,80 @@ var IdentityManager = class {
|
|
|
531
574
|
}
|
|
532
575
|
};
|
|
533
576
|
|
|
577
|
+
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
578
|
+
var import_node_assert4 = __toESM(require("node:assert"));
|
|
579
|
+
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
580
|
+
var import_credentials7 = require("@dxos/credentials");
|
|
581
|
+
var import_debug3 = require("@dxos/debug");
|
|
582
|
+
var IdentityServiceImpl = class {
|
|
583
|
+
// TODO(wittjosiah): Remove dependency on service context.
|
|
584
|
+
constructor(_serviceContext) {
|
|
585
|
+
this._serviceContext = _serviceContext;
|
|
586
|
+
}
|
|
587
|
+
async createIdentity(request) {
|
|
588
|
+
await this._serviceContext.createIdentity(request);
|
|
589
|
+
return this._getIdentity();
|
|
590
|
+
}
|
|
591
|
+
async recoverIdentity(request) {
|
|
592
|
+
return (0, import_debug3.todo)();
|
|
593
|
+
}
|
|
594
|
+
queryIdentity() {
|
|
595
|
+
return new import_codec_protobuf.Stream(({ next }) => {
|
|
596
|
+
const emitNext = () => next({
|
|
597
|
+
identity: this._getIdentity()
|
|
598
|
+
});
|
|
599
|
+
emitNext();
|
|
600
|
+
return this._serviceContext.identityManager.stateUpdate.on(emitNext);
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
_getIdentity() {
|
|
604
|
+
if (!this._serviceContext.identityManager.identity) {
|
|
605
|
+
return void 0;
|
|
606
|
+
}
|
|
607
|
+
return {
|
|
608
|
+
identityKey: this._serviceContext.identityManager.identity.identityKey,
|
|
609
|
+
spaceKey: this._serviceContext.identityManager.identity.space.key,
|
|
610
|
+
profile: this._serviceContext.identityManager.identity.profileDocument
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
async signPresentation({ presentation, nonce }) {
|
|
614
|
+
(0, import_node_assert4.default)(this._serviceContext.identityManager.identity, "Identity not initialized.");
|
|
615
|
+
return await (0, import_credentials7.signPresentation)({
|
|
616
|
+
presentation,
|
|
617
|
+
signer: this._serviceContext.keyring,
|
|
618
|
+
signerKey: this._serviceContext.identityManager.identity.deviceKey,
|
|
619
|
+
chain: this._serviceContext.identityManager.identity.deviceCredentialChain,
|
|
620
|
+
nonce
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
|
|
534
625
|
// packages/sdk/client-services/src/packlets/invitations/encoder.ts
|
|
535
626
|
var import_base_x = __toESM(require("base-x"));
|
|
536
627
|
var import_protocols2 = require("@dxos/protocols");
|
|
537
628
|
var base62 = (0, import_base_x.default)("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
|
538
629
|
var codec = import_protocols2.schema.getCodecForType("dxos.client.services.Invitation");
|
|
539
630
|
|
|
540
|
-
// packages/sdk/client-services/src/packlets/invitations/
|
|
541
|
-
var
|
|
542
|
-
var
|
|
631
|
+
// packages/sdk/client-services/src/packlets/invitations/device-invitations-handler.ts
|
|
632
|
+
var import_node_assert5 = __toESM(require("node:assert"));
|
|
633
|
+
var import_async6 = require("@dxos/async");
|
|
543
634
|
var import_context2 = require("@dxos/context");
|
|
544
|
-
var
|
|
635
|
+
var import_credentials8 = require("@dxos/credentials");
|
|
545
636
|
var import_keys2 = require("@dxos/keys");
|
|
546
637
|
var import_log4 = require("@dxos/log");
|
|
547
638
|
var import_network_manager = require("@dxos/network-manager");
|
|
548
639
|
var import_protocols3 = require("@dxos/protocols");
|
|
549
|
-
var
|
|
640
|
+
var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
550
641
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
551
642
|
var import_teleport = require("@dxos/teleport");
|
|
552
643
|
|
|
553
644
|
// packages/sdk/client-services/src/packlets/invitations/invitations.ts
|
|
554
|
-
var
|
|
555
|
-
var
|
|
645
|
+
var import_async5 = require("@dxos/async");
|
|
646
|
+
var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
556
647
|
var AUTHENTICATION_CODE_LENGTH = 6;
|
|
557
648
|
var INVITATION_TIMEOUT = 3 * 6e4;
|
|
558
649
|
var ON_CLOSE_DELAY = 1e3;
|
|
559
|
-
var InvitationObservableProvider = class extends
|
|
650
|
+
var InvitationObservableProvider = class extends import_async5.CancellableObservableProvider {
|
|
560
651
|
get invitation() {
|
|
561
652
|
return this._invitation;
|
|
562
653
|
}
|
|
@@ -583,8 +674,8 @@ var AbstractInvitationsHandler = class {
|
|
|
583
674
|
}
|
|
584
675
|
};
|
|
585
676
|
|
|
586
|
-
// packages/sdk/client-services/src/packlets/invitations/
|
|
587
|
-
var
|
|
677
|
+
// packages/sdk/client-services/src/packlets/invitations/device-invitations-handler.ts
|
|
678
|
+
var DeviceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
588
679
|
// prettier-ignore
|
|
589
680
|
constructor(_params) {
|
|
590
681
|
super(_params.networkManager);
|
|
@@ -595,13 +686,13 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
595
686
|
*/
|
|
596
687
|
createInvitation(context, options) {
|
|
597
688
|
const { type, timeout = INVITATION_TIMEOUT, swarmKey } = options != null ? options : {};
|
|
598
|
-
(0,
|
|
689
|
+
(0, import_node_assert5.default)(type !== import_services3.Invitation.Type.OFFLINE);
|
|
599
690
|
const identity = this._params.getIdentity();
|
|
600
691
|
const invitation = {
|
|
601
692
|
type,
|
|
602
693
|
invitationId: import_keys2.PublicKey.random().toHex(),
|
|
603
694
|
swarmKey: swarmKey != null ? swarmKey : import_keys2.PublicKey.random(),
|
|
604
|
-
authenticationCode: (0,
|
|
695
|
+
authenticationCode: (0, import_credentials8.generatePasscode)(AUTHENTICATION_CODE_LENGTH)
|
|
605
696
|
};
|
|
606
697
|
const ctx = new import_context2.Context({
|
|
607
698
|
onError: (err) => {
|
|
@@ -613,14 +704,14 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
613
704
|
await ctx.dispose();
|
|
614
705
|
});
|
|
615
706
|
let authenticationCode;
|
|
616
|
-
const complete = new
|
|
707
|
+
const complete = new import_async6.Trigger();
|
|
617
708
|
const createExtension = () => new HostHaloInvitationExtension({
|
|
618
709
|
requestAdmission: async () => {
|
|
619
710
|
var _a, _b;
|
|
620
711
|
(0, import_log4.log)("responding with admission offer", {
|
|
621
712
|
host: identity.deviceKey
|
|
622
713
|
}, {
|
|
623
|
-
file: "
|
|
714
|
+
file: "device-invitations-handler.ts",
|
|
624
715
|
line: 91,
|
|
625
716
|
scope: this,
|
|
626
717
|
callSite: (f, a) => f(...a)
|
|
@@ -636,7 +727,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
636
727
|
(0, import_log4.log)("received authentication request", {
|
|
637
728
|
authenticationCode: code
|
|
638
729
|
}, {
|
|
639
|
-
file: "
|
|
730
|
+
file: "device-invitations-handler.ts",
|
|
640
731
|
line: 105,
|
|
641
732
|
scope: this,
|
|
642
733
|
callSite: (f, a) => f(...a)
|
|
@@ -649,7 +740,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
649
740
|
// TODO(burdon): Not used: controlFeedKey, dataFeedKey.
|
|
650
741
|
presentAdmissionCredentials: async (credentials) => {
|
|
651
742
|
try {
|
|
652
|
-
if (invitation.type !==
|
|
743
|
+
if (invitation.type !== import_services3.Invitation.Type.INTERACTIVE_TESTING) {
|
|
653
744
|
if (invitation.authenticationCode === void 0 || invitation.authenticationCode !== authenticationCode) {
|
|
654
745
|
throw new Error(`invalid authentication code: ${authenticationCode}`);
|
|
655
746
|
}
|
|
@@ -658,7 +749,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
658
749
|
host: identity.deviceKey,
|
|
659
750
|
guest: credentials.deviceKey
|
|
660
751
|
}, {
|
|
661
|
-
file: "
|
|
752
|
+
file: "device-invitations-handler.ts",
|
|
662
753
|
line: 120,
|
|
663
754
|
scope: this,
|
|
664
755
|
callSite: (f, a) => f(...a)
|
|
@@ -671,13 +762,13 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
671
762
|
}
|
|
672
763
|
},
|
|
673
764
|
onOpen: () => {
|
|
674
|
-
(0,
|
|
765
|
+
(0, import_async6.scheduleTask)(ctx, async () => {
|
|
675
766
|
var _a, _b;
|
|
676
767
|
try {
|
|
677
768
|
(0, import_log4.log)("connected", {
|
|
678
769
|
host: identity.deviceKey
|
|
679
770
|
}, {
|
|
680
|
-
file: "
|
|
771
|
+
file: "device-invitations-handler.ts",
|
|
681
772
|
line: 136,
|
|
682
773
|
scope: this,
|
|
683
774
|
callSite: (f, a) => f(...a)
|
|
@@ -690,7 +781,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
690
781
|
host: identity.deviceKey,
|
|
691
782
|
guest: deviceKey
|
|
692
783
|
}, {
|
|
693
|
-
file: "
|
|
784
|
+
file: "device-invitations-handler.ts",
|
|
694
785
|
line: 139,
|
|
695
786
|
scope: this,
|
|
696
787
|
callSite: (f, a) => f(...a)
|
|
@@ -699,7 +790,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
699
790
|
} catch (err) {
|
|
700
791
|
if (!observable.cancelled) {
|
|
701
792
|
import_log4.log.error("failed", err, {
|
|
702
|
-
file: "
|
|
793
|
+
file: "device-invitations-handler.ts",
|
|
703
794
|
line: 143,
|
|
704
795
|
scope: this,
|
|
705
796
|
callSite: (f, a) => f(...a)
|
|
@@ -707,13 +798,13 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
707
798
|
observable.callback.onError(err);
|
|
708
799
|
}
|
|
709
800
|
} finally {
|
|
710
|
-
await (0,
|
|
801
|
+
await (0, import_async6.sleep)(ON_CLOSE_DELAY);
|
|
711
802
|
await ctx.dispose();
|
|
712
803
|
}
|
|
713
804
|
});
|
|
714
805
|
}
|
|
715
806
|
});
|
|
716
|
-
(0,
|
|
807
|
+
(0, import_async6.scheduleTask)(ctx, async () => {
|
|
717
808
|
var _a, _b;
|
|
718
809
|
const topic = invitation.swarmKey;
|
|
719
810
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
@@ -742,7 +833,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
742
833
|
observable.callback.onError(err);
|
|
743
834
|
}
|
|
744
835
|
});
|
|
745
|
-
const authenticated = new
|
|
836
|
+
const authenticated = new import_async6.Trigger();
|
|
746
837
|
const observable = new AuthenticatingInvitationProvider({
|
|
747
838
|
onCancel: async () => {
|
|
748
839
|
await ctx.dispose();
|
|
@@ -753,33 +844,33 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
753
844
|
}
|
|
754
845
|
});
|
|
755
846
|
let connectionCount = 0;
|
|
756
|
-
const complete = new
|
|
847
|
+
const complete = new import_async6.Trigger();
|
|
757
848
|
const createExtension = () => {
|
|
758
849
|
const extension = new GuestHaloInvitationExtension({
|
|
759
850
|
onOpen: () => {
|
|
760
|
-
(0,
|
|
851
|
+
(0, import_async6.scheduleTask)(ctx, async () => {
|
|
761
852
|
var _a, _b, _c, _d;
|
|
762
853
|
try {
|
|
763
854
|
if (++connectionCount > 1) {
|
|
764
855
|
throw new Error(`multiple connections detected: ${connectionCount}`);
|
|
765
856
|
}
|
|
766
857
|
(0, import_log4.log)("connected", {}, {
|
|
767
|
-
file: "
|
|
858
|
+
file: "device-invitations-handler.ts",
|
|
768
859
|
line: 214,
|
|
769
860
|
scope: this,
|
|
770
861
|
callSite: (f, a) => f(...a)
|
|
771
862
|
});
|
|
772
863
|
(_b = (_a = observable.callback).onConnected) == null ? void 0 : _b.call(_a, invitation);
|
|
773
864
|
(0, import_log4.log)("sending admission request", {}, {
|
|
774
|
-
file: "
|
|
865
|
+
file: "device-invitations-handler.ts",
|
|
775
866
|
line: 218,
|
|
776
867
|
scope: this,
|
|
777
868
|
callSite: (f, a) => f(...a)
|
|
778
869
|
});
|
|
779
870
|
const { identityKey, haloSpaceKey, genesisFeedKey } = await extension.rpc.HaloHostService.requestAdmission();
|
|
780
|
-
if (invitation.type === void 0 || invitation.type ===
|
|
871
|
+
if (invitation.type === void 0 || invitation.type === import_services3.Invitation.Type.INTERACTIVE) {
|
|
781
872
|
(0, import_log4.log)("guest waiting for authentication code...", {}, {
|
|
782
|
-
file: "
|
|
873
|
+
file: "device-invitations-handler.ts",
|
|
783
874
|
line: 225,
|
|
784
875
|
scope: this,
|
|
785
876
|
callSite: (f, a) => f(...a)
|
|
@@ -789,7 +880,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
789
880
|
timeout
|
|
790
881
|
});
|
|
791
882
|
(0, import_log4.log)("sending authentication request", {}, {
|
|
792
|
-
file: "
|
|
883
|
+
file: "device-invitations-handler.ts",
|
|
793
884
|
line: 228,
|
|
794
885
|
scope: this,
|
|
795
886
|
callSite: (f, a) => f(...a)
|
|
@@ -807,7 +898,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
807
898
|
controlFeedKey,
|
|
808
899
|
dataFeedKey
|
|
809
900
|
}, {
|
|
810
|
-
file: "
|
|
901
|
+
file: "device-invitations-handler.ts",
|
|
811
902
|
line: 237,
|
|
812
903
|
scope: this,
|
|
813
904
|
callSite: (f, a) => f(...a)
|
|
@@ -829,7 +920,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
829
920
|
guest: identity.deviceKey,
|
|
830
921
|
identityKey
|
|
831
922
|
}, {
|
|
832
|
-
file: "
|
|
923
|
+
file: "device-invitations-handler.ts",
|
|
833
924
|
line: 256,
|
|
834
925
|
scope: this,
|
|
835
926
|
callSite: (f, a) => f(...a)
|
|
@@ -838,7 +929,7 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
838
929
|
} catch (err) {
|
|
839
930
|
if (!observable.cancelled) {
|
|
840
931
|
import_log4.log.warn("auth failed", err, {
|
|
841
|
-
file: "
|
|
932
|
+
file: "device-invitations-handler.ts",
|
|
842
933
|
line: 260,
|
|
843
934
|
scope: this,
|
|
844
935
|
callSite: (f, a) => f(...a)
|
|
@@ -853,9 +944,9 @@ var HaloInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
853
944
|
});
|
|
854
945
|
return extension;
|
|
855
946
|
};
|
|
856
|
-
(0,
|
|
947
|
+
(0, import_async6.scheduleTask)(ctx, async () => {
|
|
857
948
|
var _a, _b;
|
|
858
|
-
(0,
|
|
949
|
+
(0, import_node_assert5.default)(invitation.swarmKey);
|
|
859
950
|
const topic = invitation.swarmKey;
|
|
860
951
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
861
952
|
topic,
|
|
@@ -925,15 +1016,15 @@ var GuestHaloInvitationExtension = class extends import_teleport.RpcExtension {
|
|
|
925
1016
|
};
|
|
926
1017
|
|
|
927
1018
|
// packages/sdk/client-services/src/packlets/invitations/invitations-proxy.ts
|
|
928
|
-
var
|
|
1019
|
+
var import_async7 = require("@dxos/async");
|
|
929
1020
|
var import_log5 = require("@dxos/log");
|
|
930
|
-
var
|
|
1021
|
+
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
931
1022
|
|
|
932
1023
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
933
|
-
var
|
|
934
|
-
var
|
|
1024
|
+
var import_node_assert6 = __toESM(require("node:assert"));
|
|
1025
|
+
var import_codec_protobuf2 = require("@dxos/codec-protobuf");
|
|
935
1026
|
var import_log6 = require("@dxos/log");
|
|
936
|
-
var
|
|
1027
|
+
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
937
1028
|
var AbstractInvitationsService = class {
|
|
938
1029
|
// prettier-ignore
|
|
939
1030
|
constructor(_identityManager, _getInvitationsHandler) {
|
|
@@ -950,7 +1041,7 @@ var AbstractInvitationsService = class {
|
|
|
950
1041
|
};
|
|
951
1042
|
}
|
|
952
1043
|
createInvitation(invitation) {
|
|
953
|
-
return new
|
|
1044
|
+
return new import_codec_protobuf2.Stream(({ next, close }) => {
|
|
954
1045
|
const invitationsHandler = this._getInvitationsHandler();
|
|
955
1046
|
const context = this.getContext(invitation);
|
|
956
1047
|
(0, import_log6.log)("stream opened", this.getLoggingContext(), {
|
|
@@ -960,48 +1051,49 @@ var AbstractInvitationsService = class {
|
|
|
960
1051
|
callSite: (f, a) => f(...a)
|
|
961
1052
|
});
|
|
962
1053
|
let invitationId;
|
|
963
|
-
const { type, swarmKey } = invitation;
|
|
1054
|
+
const { type, swarmKey, authMethod } = invitation;
|
|
964
1055
|
const observable = invitationsHandler.createInvitation(context, {
|
|
965
1056
|
type,
|
|
966
|
-
swarmKey
|
|
1057
|
+
swarmKey,
|
|
1058
|
+
authMethod
|
|
967
1059
|
});
|
|
968
1060
|
observable.subscribe({
|
|
969
1061
|
onConnecting: (invitation2) => {
|
|
970
|
-
(0,
|
|
1062
|
+
(0, import_node_assert6.default)(invitation2.invitationId);
|
|
971
1063
|
invitationId = invitation2.invitationId;
|
|
972
1064
|
this._createInvitations.set(invitation2.invitationId, observable);
|
|
973
|
-
invitation2.state =
|
|
1065
|
+
invitation2.state = import_services5.Invitation.State.CONNECTING;
|
|
974
1066
|
next(invitation2);
|
|
975
1067
|
},
|
|
976
1068
|
onConnected: (invitation2) => {
|
|
977
|
-
(0,
|
|
978
|
-
invitation2.state =
|
|
1069
|
+
(0, import_node_assert6.default)(invitation2.invitationId);
|
|
1070
|
+
invitation2.state = import_services5.Invitation.State.CONNECTED;
|
|
979
1071
|
next(invitation2);
|
|
980
1072
|
},
|
|
981
1073
|
onAuthenticating: (invitation2) => {
|
|
982
|
-
(0,
|
|
983
|
-
invitation2.state =
|
|
1074
|
+
(0, import_node_assert6.default)(invitation2.invitationId);
|
|
1075
|
+
invitation2.state = import_services5.Invitation.State.AUTHENTICATING;
|
|
984
1076
|
next(invitation2);
|
|
985
1077
|
},
|
|
986
1078
|
onSuccess: (invitation2) => {
|
|
987
|
-
(0,
|
|
988
|
-
invitation2.state =
|
|
1079
|
+
(0, import_node_assert6.default)(invitation2.invitationId);
|
|
1080
|
+
invitation2.state = import_services5.Invitation.State.SUCCESS;
|
|
989
1081
|
next(invitation2);
|
|
990
1082
|
close();
|
|
991
1083
|
},
|
|
992
1084
|
onCancelled: () => {
|
|
993
|
-
(0,
|
|
1085
|
+
(0, import_node_assert6.default)(invitationId);
|
|
994
1086
|
invitation.invitationId = invitationId;
|
|
995
|
-
invitation.state =
|
|
1087
|
+
invitation.state = import_services5.Invitation.State.CANCELLED;
|
|
996
1088
|
next(invitation);
|
|
997
1089
|
close();
|
|
998
1090
|
},
|
|
999
1091
|
onTimeout: (err) => {
|
|
1000
|
-
invitation.state =
|
|
1092
|
+
invitation.state = import_services5.Invitation.State.TIMEOUT;
|
|
1001
1093
|
close(err);
|
|
1002
1094
|
},
|
|
1003
1095
|
onError: (err) => {
|
|
1004
|
-
invitation.state =
|
|
1096
|
+
invitation.state = import_services5.Invitation.State.ERROR;
|
|
1005
1097
|
close(err);
|
|
1006
1098
|
}
|
|
1007
1099
|
});
|
|
@@ -1030,7 +1122,7 @@ var AbstractInvitationsService = class {
|
|
|
1030
1122
|
});
|
|
1031
1123
|
}
|
|
1032
1124
|
acceptInvitation(invitation, options) {
|
|
1033
|
-
return new
|
|
1125
|
+
return new import_codec_protobuf2.Stream(({ next, close }) => {
|
|
1034
1126
|
(0, import_log6.log)("stream opened", this.getLoggingContext(), {
|
|
1035
1127
|
file: "invitations-service.ts",
|
|
1036
1128
|
line: 104,
|
|
@@ -1042,40 +1134,40 @@ var AbstractInvitationsService = class {
|
|
|
1042
1134
|
const observable = invitationsHandler.acceptInvitation(invitation, options);
|
|
1043
1135
|
observable.subscribe({
|
|
1044
1136
|
onConnecting: (invitation2) => {
|
|
1045
|
-
(0,
|
|
1137
|
+
(0, import_node_assert6.default)(invitation2.invitationId);
|
|
1046
1138
|
invitationId = invitation2.invitationId;
|
|
1047
1139
|
this._acceptInvitations.set(invitation2.invitationId, observable);
|
|
1048
|
-
invitation2.state =
|
|
1140
|
+
invitation2.state = import_services5.Invitation.State.CONNECTING;
|
|
1049
1141
|
next(invitation2);
|
|
1050
1142
|
},
|
|
1051
1143
|
onConnected: (invitation2) => {
|
|
1052
|
-
(0,
|
|
1053
|
-
invitation2.state =
|
|
1144
|
+
(0, import_node_assert6.default)(invitation2.invitationId);
|
|
1145
|
+
invitation2.state = import_services5.Invitation.State.CONNECTED;
|
|
1054
1146
|
next(invitation2);
|
|
1055
1147
|
},
|
|
1056
1148
|
onAuthenticating: (invitation2) => {
|
|
1057
|
-
(0,
|
|
1058
|
-
invitation2.state =
|
|
1149
|
+
(0, import_node_assert6.default)(invitation2.invitationId);
|
|
1150
|
+
invitation2.state = import_services5.Invitation.State.AUTHENTICATING;
|
|
1059
1151
|
next(invitation2);
|
|
1060
1152
|
},
|
|
1061
1153
|
onSuccess: (invitation2) => {
|
|
1062
|
-
invitation2.state =
|
|
1154
|
+
invitation2.state = import_services5.Invitation.State.SUCCESS;
|
|
1063
1155
|
next(invitation2);
|
|
1064
1156
|
close();
|
|
1065
1157
|
},
|
|
1066
1158
|
onCancelled: () => {
|
|
1067
|
-
(0,
|
|
1159
|
+
(0, import_node_assert6.default)(invitationId);
|
|
1068
1160
|
invitation.invitationId = invitationId;
|
|
1069
|
-
invitation.state =
|
|
1161
|
+
invitation.state = import_services5.Invitation.State.CANCELLED;
|
|
1070
1162
|
next(invitation);
|
|
1071
1163
|
close();
|
|
1072
1164
|
},
|
|
1073
1165
|
onTimeout: (err) => {
|
|
1074
|
-
invitation.state =
|
|
1166
|
+
invitation.state = import_services5.Invitation.State.TIMEOUT;
|
|
1075
1167
|
close(err);
|
|
1076
1168
|
},
|
|
1077
1169
|
onError: (err) => {
|
|
1078
|
-
invitation.state =
|
|
1170
|
+
invitation.state = import_services5.Invitation.State.ERROR;
|
|
1079
1171
|
close(err);
|
|
1080
1172
|
}
|
|
1081
1173
|
});
|
|
@@ -1110,7 +1202,7 @@ var AbstractInvitationsService = class {
|
|
|
1110
1202
|
scope: this,
|
|
1111
1203
|
callSite: (f, a) => f(...a)
|
|
1112
1204
|
});
|
|
1113
|
-
(0,
|
|
1205
|
+
(0, import_node_assert6.default)(invitationId);
|
|
1114
1206
|
const observable = this._acceptInvitations.get(invitationId);
|
|
1115
1207
|
if (!observable) {
|
|
1116
1208
|
import_log6.log.warn("invalid invitation", {
|
|
@@ -1133,7 +1225,7 @@ var AbstractInvitationsService = class {
|
|
|
1133
1225
|
scope: this,
|
|
1134
1226
|
callSite: (f, a) => f(...a)
|
|
1135
1227
|
});
|
|
1136
|
-
(0,
|
|
1228
|
+
(0, import_node_assert6.default)(invitation.invitationId);
|
|
1137
1229
|
const observable = (_a = this._createInvitations.get(invitation.invitationId)) != null ? _a : this._acceptInvitations.get(invitation.invitationId);
|
|
1138
1230
|
if (!observable) {
|
|
1139
1231
|
import_log6.log.warn("invalid invitation", {
|
|
@@ -1150,8 +1242,8 @@ var AbstractInvitationsService = class {
|
|
|
1150
1242
|
}
|
|
1151
1243
|
};
|
|
1152
1244
|
|
|
1153
|
-
// packages/sdk/client-services/src/packlets/invitations/
|
|
1154
|
-
var
|
|
1245
|
+
// packages/sdk/client-services/src/packlets/invitations/device-invitations-service.ts
|
|
1246
|
+
var DeviceInvitationsServiceImpl = class extends AbstractInvitationsService {
|
|
1155
1247
|
// prettier-ignore
|
|
1156
1248
|
constructor(identityManager, invitationsHandler) {
|
|
1157
1249
|
super(identityManager, () => invitationsHandler);
|
|
@@ -1162,16 +1254,16 @@ var HaloInvitationsServiceImpl = class extends AbstractInvitationsService {
|
|
|
1162
1254
|
};
|
|
1163
1255
|
|
|
1164
1256
|
// packages/sdk/client-services/src/packlets/invitations/space-invitations-handler.ts
|
|
1165
|
-
var
|
|
1166
|
-
var
|
|
1257
|
+
var import_node_assert7 = __toESM(require("node:assert"));
|
|
1258
|
+
var import_async8 = require("@dxos/async");
|
|
1167
1259
|
var import_context3 = require("@dxos/context");
|
|
1168
|
-
var
|
|
1260
|
+
var import_credentials9 = require("@dxos/credentials");
|
|
1169
1261
|
var import_feed_store2 = require("@dxos/feed-store");
|
|
1170
1262
|
var import_keys3 = require("@dxos/keys");
|
|
1171
1263
|
var import_log7 = require("@dxos/log");
|
|
1172
1264
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
1173
1265
|
var import_protocols4 = require("@dxos/protocols");
|
|
1174
|
-
var
|
|
1266
|
+
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1175
1267
|
var import_invitations4 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
1176
1268
|
var import_teleport2 = require("@dxos/teleport");
|
|
1177
1269
|
var MAX_OTP_ATTEMPTS = 3;
|
|
@@ -1186,16 +1278,19 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1186
1278
|
* Creates an invitation and listens for a join request from the invited (guest) peer.
|
|
1187
1279
|
*/
|
|
1188
1280
|
createInvitation(space, options) {
|
|
1281
|
+
var _a;
|
|
1189
1282
|
let swarmConnection;
|
|
1190
1283
|
const { type, timeout = INVITATION_TIMEOUT, swarmKey } = options != null ? options : {};
|
|
1191
|
-
(0,
|
|
1192
|
-
(0,
|
|
1284
|
+
(0, import_node_assert7.default)(type !== import_services6.Invitation.Type.OFFLINE);
|
|
1285
|
+
(0, import_node_assert7.default)(space);
|
|
1193
1286
|
const invitation = {
|
|
1194
1287
|
type,
|
|
1195
1288
|
invitationId: import_keys3.PublicKey.random().toHex(),
|
|
1196
1289
|
swarmKey: swarmKey != null ? swarmKey : import_keys3.PublicKey.random(),
|
|
1197
1290
|
spaceKey: space.key,
|
|
1198
|
-
|
|
1291
|
+
authMethod: (_a = options == null ? void 0 : options.authMethod) != null ? _a : import_invitations4.AuthMethod.SHARED_SECRET,
|
|
1292
|
+
authenticationCode: (0, import_credentials9.generatePasscode)(AUTHENTICATION_CODE_LENGTH)
|
|
1293
|
+
// TODO(dmaretskyi): Don't generate if authMethod === NONE .
|
|
1199
1294
|
};
|
|
1200
1295
|
const ctx = new import_context3.Context({
|
|
1201
1296
|
onError: (err) => {
|
|
@@ -1206,44 +1301,76 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1206
1301
|
const observable = new InvitationObservableProvider(async () => {
|
|
1207
1302
|
await (swarmConnection == null ? void 0 : swarmConnection.close());
|
|
1208
1303
|
});
|
|
1209
|
-
let
|
|
1304
|
+
let authenticationPassed = false;
|
|
1210
1305
|
let authenticationRetry = 0;
|
|
1211
1306
|
const createExtension = () => {
|
|
1212
|
-
const complete = new
|
|
1307
|
+
const complete = new import_async8.Trigger();
|
|
1213
1308
|
let guestProfile;
|
|
1214
1309
|
const hostInvitationExtension = new HostSpaceInvitationExtension({
|
|
1215
1310
|
introduce: async ({ profile }) => {
|
|
1216
|
-
var
|
|
1311
|
+
var _a2, _b;
|
|
1217
1312
|
(0, import_log7.log)("guest introduced itself", {
|
|
1218
1313
|
guestProfile: profile,
|
|
1219
1314
|
host: this._signingContext.deviceKey,
|
|
1220
1315
|
spaceKey: space.key
|
|
1221
1316
|
}, {
|
|
1222
1317
|
file: "space-invitations-handler.ts",
|
|
1223
|
-
line:
|
|
1318
|
+
line: 101,
|
|
1224
1319
|
scope: this,
|
|
1225
1320
|
callSite: (f, a) => f(...a)
|
|
1226
1321
|
});
|
|
1227
1322
|
guestProfile = profile;
|
|
1228
|
-
(_b = (
|
|
1323
|
+
(_b = (_a2 = observable.callback).onAuthenticating) == null ? void 0 : _b.call(_a2, invitation);
|
|
1324
|
+
return {
|
|
1325
|
+
spaceKey: type === import_services6.Invitation.Type.INTERACTIVE_TESTING || type === import_services6.Invitation.Type.MULTIUSE_TESTING ? space.key : void 0,
|
|
1326
|
+
authMethod: invitation.authMethod
|
|
1327
|
+
};
|
|
1229
1328
|
},
|
|
1230
1329
|
authenticate: async ({ authenticationCode: code }) => {
|
|
1231
1330
|
(0, import_log7.log)("received authentication request", {
|
|
1232
1331
|
authenticationCode: code
|
|
1233
1332
|
}, {
|
|
1234
1333
|
file: "space-invitations-handler.ts",
|
|
1235
|
-
line:
|
|
1334
|
+
line: 123,
|
|
1236
1335
|
scope: this,
|
|
1237
1336
|
callSite: (f, a) => f(...a)
|
|
1238
1337
|
});
|
|
1239
1338
|
let status = import_invitations4.AuthenticationResponse.Status.OK;
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1339
|
+
switch (invitation.authMethod) {
|
|
1340
|
+
case import_invitations4.AuthMethod.NONE: {
|
|
1341
|
+
(0, import_log7.log)("authentication not required", {}, {
|
|
1342
|
+
file: "space-invitations-handler.ts",
|
|
1343
|
+
line: 128,
|
|
1344
|
+
scope: this,
|
|
1345
|
+
callSite: (f, a) => f(...a)
|
|
1346
|
+
});
|
|
1347
|
+
return {
|
|
1348
|
+
status: import_invitations4.AuthenticationResponse.Status.OK
|
|
1349
|
+
};
|
|
1350
|
+
}
|
|
1351
|
+
case import_invitations4.AuthMethod.SHARED_SECRET: {
|
|
1352
|
+
if (invitation.authenticationCode) {
|
|
1353
|
+
if (authenticationRetry++ > MAX_OTP_ATTEMPTS) {
|
|
1354
|
+
status = import_invitations4.AuthenticationResponse.Status.INVALID_OPT_ATTEMPTS;
|
|
1355
|
+
} else if (code !== invitation.authenticationCode) {
|
|
1356
|
+
status = import_invitations4.AuthenticationResponse.Status.INVALID_OTP;
|
|
1357
|
+
} else {
|
|
1358
|
+
authenticationPassed = true;
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
break;
|
|
1362
|
+
}
|
|
1363
|
+
default: {
|
|
1364
|
+
import_log7.log.error("invalid authentication method", {
|
|
1365
|
+
authMethod: invitation.authMethod
|
|
1366
|
+
}, {
|
|
1367
|
+
file: "space-invitations-handler.ts",
|
|
1368
|
+
line: 144,
|
|
1369
|
+
scope: this,
|
|
1370
|
+
callSite: (f, a) => f(...a)
|
|
1371
|
+
});
|
|
1372
|
+
status = import_invitations4.AuthenticationResponse.Status.INTERNAL_ERROR;
|
|
1373
|
+
break;
|
|
1247
1374
|
}
|
|
1248
1375
|
}
|
|
1249
1376
|
return {
|
|
@@ -1252,24 +1379,22 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1252
1379
|
},
|
|
1253
1380
|
requestAdmission: async ({ identityKey, deviceKey, controlFeedKey, dataFeedKey }) => {
|
|
1254
1381
|
try {
|
|
1255
|
-
if (invitation
|
|
1256
|
-
|
|
1257
|
-
throw new Error(`invalid authentication code: ${authenticationCode}`);
|
|
1258
|
-
}
|
|
1382
|
+
if (isAuthenticationRequired(invitation) && !authenticationPassed) {
|
|
1383
|
+
throw new Error("Not authenticated");
|
|
1259
1384
|
}
|
|
1260
1385
|
(0, import_log7.log)("writing guest credentials", {
|
|
1261
1386
|
host: this._signingContext.deviceKey,
|
|
1262
1387
|
guest: deviceKey
|
|
1263
1388
|
}, {
|
|
1264
1389
|
file: "space-invitations-handler.ts",
|
|
1265
|
-
line:
|
|
1390
|
+
line: 160,
|
|
1266
1391
|
scope: this,
|
|
1267
1392
|
callSite: (f, a) => f(...a)
|
|
1268
1393
|
});
|
|
1269
|
-
const credentials = await (0,
|
|
1270
|
-
(0,
|
|
1394
|
+
const credentials = await (0, import_credentials9.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
1395
|
+
(0, import_node_assert7.default)(credentials[0].credential);
|
|
1271
1396
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
1272
|
-
(0,
|
|
1397
|
+
(0, import_node_assert7.default)((0, import_credentials9.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
1273
1398
|
await (0, import_feed_store2.writeMessages)(space.inner.controlPipeline.writer, credentials);
|
|
1274
1399
|
complete.wake(deviceKey);
|
|
1275
1400
|
return {
|
|
@@ -1281,18 +1406,18 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1281
1406
|
}
|
|
1282
1407
|
},
|
|
1283
1408
|
onOpen: () => {
|
|
1284
|
-
(0,
|
|
1285
|
-
var
|
|
1409
|
+
(0, import_async8.scheduleTask)(ctx, async () => {
|
|
1410
|
+
var _a2, _b;
|
|
1286
1411
|
try {
|
|
1287
1412
|
(0, import_log7.log)("connected", {
|
|
1288
1413
|
host: this._signingContext.deviceKey
|
|
1289
1414
|
}, {
|
|
1290
1415
|
file: "space-invitations-handler.ts",
|
|
1291
|
-
line:
|
|
1416
|
+
line: 191,
|
|
1292
1417
|
scope: this,
|
|
1293
1418
|
callSite: (f, a) => f(...a)
|
|
1294
1419
|
});
|
|
1295
|
-
(_b = (
|
|
1420
|
+
(_b = (_a2 = observable.callback).onConnected) == null ? void 0 : _b.call(_a2, invitation);
|
|
1296
1421
|
const deviceKey = await complete.wait({
|
|
1297
1422
|
timeout
|
|
1298
1423
|
});
|
|
@@ -1301,7 +1426,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1301
1426
|
guest: deviceKey
|
|
1302
1427
|
}, {
|
|
1303
1428
|
file: "space-invitations-handler.ts",
|
|
1304
|
-
line:
|
|
1429
|
+
line: 194,
|
|
1305
1430
|
scope: this,
|
|
1306
1431
|
callSite: (f, a) => f(...a)
|
|
1307
1432
|
});
|
|
@@ -1310,15 +1435,15 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1310
1435
|
if (!observable.cancelled) {
|
|
1311
1436
|
import_log7.log.error("failed", err, {
|
|
1312
1437
|
file: "space-invitations-handler.ts",
|
|
1313
|
-
line:
|
|
1438
|
+
line: 198,
|
|
1314
1439
|
scope: this,
|
|
1315
1440
|
callSite: (f, a) => f(...a)
|
|
1316
1441
|
});
|
|
1317
1442
|
observable.callback.onError(err);
|
|
1318
1443
|
}
|
|
1319
1444
|
} finally {
|
|
1320
|
-
if (type !==
|
|
1321
|
-
await (0,
|
|
1445
|
+
if (type !== import_services6.Invitation.Type.MULTIUSE_TESTING) {
|
|
1446
|
+
await (0, import_async8.sleep)(ON_CLOSE_DELAY);
|
|
1322
1447
|
await ctx.dispose();
|
|
1323
1448
|
}
|
|
1324
1449
|
}
|
|
@@ -1327,8 +1452,8 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1327
1452
|
});
|
|
1328
1453
|
return hostInvitationExtension;
|
|
1329
1454
|
};
|
|
1330
|
-
(0,
|
|
1331
|
-
var
|
|
1455
|
+
(0, import_async8.scheduleTask)(ctx, async () => {
|
|
1456
|
+
var _a2, _b;
|
|
1332
1457
|
const topic = invitation.swarmKey;
|
|
1333
1458
|
const swarmConnection2 = await this._networkManager.joinSwarm({
|
|
1334
1459
|
topic,
|
|
@@ -1339,7 +1464,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1339
1464
|
topology: new import_network_manager2.StarTopology(topic)
|
|
1340
1465
|
});
|
|
1341
1466
|
ctx.onDispose(() => swarmConnection2.close());
|
|
1342
|
-
(_b = (
|
|
1467
|
+
(_b = (_a2 = observable.callback).onConnecting) == null ? void 0 : _b.call(_a2, invitation);
|
|
1343
1468
|
});
|
|
1344
1469
|
return observable;
|
|
1345
1470
|
}
|
|
@@ -1356,7 +1481,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1356
1481
|
observable.callback.onError(err);
|
|
1357
1482
|
}
|
|
1358
1483
|
});
|
|
1359
|
-
const authenticated = new
|
|
1484
|
+
const authenticated = new import_async8.Trigger();
|
|
1360
1485
|
const observable = new AuthenticatingInvitationProvider({
|
|
1361
1486
|
onCancel: async () => {
|
|
1362
1487
|
await ctx.dispose();
|
|
@@ -1366,12 +1491,12 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1366
1491
|
}
|
|
1367
1492
|
});
|
|
1368
1493
|
let connectionCount = 0;
|
|
1369
|
-
const complete = new
|
|
1494
|
+
const complete = new import_async8.Trigger();
|
|
1370
1495
|
const createExtension = () => {
|
|
1371
1496
|
const extension = new GuestSpaceInvitationExtension({
|
|
1372
1497
|
onOpen: () => {
|
|
1373
|
-
(0,
|
|
1374
|
-
var _a, _b, _c, _d;
|
|
1498
|
+
(0, import_async8.scheduleTask)(ctx, async () => {
|
|
1499
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1375
1500
|
try {
|
|
1376
1501
|
if (++connectionCount > 1) {
|
|
1377
1502
|
throw new Error(`multiple connections detected: ${connectionCount}`);
|
|
@@ -1380,7 +1505,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1380
1505
|
guest: this._signingContext.deviceKey
|
|
1381
1506
|
}, {
|
|
1382
1507
|
file: "space-invitations-handler.ts",
|
|
1383
|
-
line:
|
|
1508
|
+
line: 271,
|
|
1384
1509
|
scope: this,
|
|
1385
1510
|
callSite: (f, a) => f(...a)
|
|
1386
1511
|
});
|
|
@@ -1389,28 +1514,42 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1389
1514
|
guest: this._signingContext.deviceKey
|
|
1390
1515
|
}, {
|
|
1391
1516
|
file: "space-invitations-handler.ts",
|
|
1392
|
-
line:
|
|
1517
|
+
line: 275,
|
|
1393
1518
|
scope: this,
|
|
1394
1519
|
callSite: (f, a) => f(...a)
|
|
1395
1520
|
});
|
|
1396
|
-
await extension.rpc.SpaceHostService.introduce({
|
|
1521
|
+
const introductionResponse = await extension.rpc.SpaceHostService.introduce({
|
|
1397
1522
|
profile: this._signingContext.profile
|
|
1398
1523
|
});
|
|
1399
|
-
|
|
1524
|
+
(0, import_log7.log)("introduce response", {
|
|
1525
|
+
guest: this._signingContext.deviceKey,
|
|
1526
|
+
response: introductionResponse
|
|
1527
|
+
}, {
|
|
1528
|
+
file: "space-invitations-handler.ts",
|
|
1529
|
+
line: 279,
|
|
1530
|
+
scope: this,
|
|
1531
|
+
callSite: (f, a) => f(...a)
|
|
1532
|
+
});
|
|
1533
|
+
invitation.authMethod = introductionResponse.authMethod;
|
|
1534
|
+
if (introductionResponse.spaceKey) {
|
|
1535
|
+
invitation.spaceKey = introductionResponse.spaceKey;
|
|
1536
|
+
}
|
|
1537
|
+
if (isAuthenticationRequired(invitation)) {
|
|
1538
|
+
(_d = (_c = observable.callback).onAuthenticating) == null ? void 0 : _d.call(_c, invitation);
|
|
1400
1539
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1401
1540
|
(0, import_log7.log)("guest waiting for authentication code...", {}, {
|
|
1402
1541
|
file: "space-invitations-handler.ts",
|
|
1403
|
-
line:
|
|
1542
|
+
line: 293,
|
|
1404
1543
|
scope: this,
|
|
1405
1544
|
callSite: (f, a) => f(...a)
|
|
1406
1545
|
});
|
|
1407
|
-
(
|
|
1546
|
+
(_f = (_e = observable.callback).onAuthenticating) == null ? void 0 : _f.call(_e, invitation);
|
|
1408
1547
|
const authenticationCode = await authenticated.wait({
|
|
1409
1548
|
timeout
|
|
1410
1549
|
});
|
|
1411
1550
|
(0, import_log7.log)("sending authentication request", {}, {
|
|
1412
1551
|
file: "space-invitations-handler.ts",
|
|
1413
|
-
line:
|
|
1552
|
+
line: 297,
|
|
1414
1553
|
scope: this,
|
|
1415
1554
|
callSite: (f, a) => f(...a)
|
|
1416
1555
|
});
|
|
@@ -1428,7 +1567,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1428
1567
|
attempt
|
|
1429
1568
|
}, {
|
|
1430
1569
|
file: "space-invitations-handler.ts",
|
|
1431
|
-
line:
|
|
1570
|
+
line: 307,
|
|
1432
1571
|
scope: this,
|
|
1433
1572
|
callSite: (f, a) => f(...a)
|
|
1434
1573
|
});
|
|
@@ -1443,7 +1582,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1443
1582
|
guest: this._signingContext.deviceKey
|
|
1444
1583
|
}, {
|
|
1445
1584
|
file: "space-invitations-handler.ts",
|
|
1446
|
-
line:
|
|
1585
|
+
line: 318,
|
|
1447
1586
|
scope: this,
|
|
1448
1587
|
callSite: (f, a) => f(...a)
|
|
1449
1588
|
});
|
|
@@ -1453,9 +1592,9 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1453
1592
|
controlFeedKey,
|
|
1454
1593
|
dataFeedKey
|
|
1455
1594
|
});
|
|
1456
|
-
const assertion = (0,
|
|
1457
|
-
(0,
|
|
1458
|
-
(0,
|
|
1595
|
+
const assertion = (0, import_credentials9.getCredentialAssertion)(credential);
|
|
1596
|
+
(0, import_node_assert7.default)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
|
|
1597
|
+
(0, import_node_assert7.default)(credential.subject.id.equals(this._signingContext.identityKey));
|
|
1459
1598
|
const space = await this._spaceManager.acceptSpace({
|
|
1460
1599
|
spaceKey: assertion.spaceKey,
|
|
1461
1600
|
genesisFeedKey: assertion.genesisFeedKey
|
|
@@ -1466,7 +1605,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1466
1605
|
spaceKey: space.key
|
|
1467
1606
|
}, {
|
|
1468
1607
|
file: "space-invitations-handler.ts",
|
|
1469
|
-
line:
|
|
1608
|
+
line: 340,
|
|
1470
1609
|
scope: this,
|
|
1471
1610
|
callSite: (f, a) => f(...a)
|
|
1472
1611
|
});
|
|
@@ -1475,7 +1614,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1475
1614
|
if (!observable.cancelled) {
|
|
1476
1615
|
import_log7.log.warn("auth failed", err, {
|
|
1477
1616
|
file: "space-invitations-handler.ts",
|
|
1478
|
-
line:
|
|
1617
|
+
line: 344,
|
|
1479
1618
|
scope: this,
|
|
1480
1619
|
callSite: (f, a) => f(...a)
|
|
1481
1620
|
});
|
|
@@ -1489,9 +1628,9 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1489
1628
|
});
|
|
1490
1629
|
return extension;
|
|
1491
1630
|
};
|
|
1492
|
-
(0,
|
|
1631
|
+
(0, import_async8.scheduleTask)(ctx, async () => {
|
|
1493
1632
|
var _a, _b;
|
|
1494
|
-
(0,
|
|
1633
|
+
(0, import_node_assert7.default)(invitation.swarmKey);
|
|
1495
1634
|
const topic = invitation.swarmKey;
|
|
1496
1635
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1497
1636
|
topic,
|
|
@@ -1510,6 +1649,7 @@ var SpaceInvitationsHandler = class extends AbstractInvitationsHandler {
|
|
|
1510
1649
|
return observable;
|
|
1511
1650
|
}
|
|
1512
1651
|
};
|
|
1652
|
+
var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_invitations4.AuthMethod.NONE && invitation.type !== import_services6.Invitation.Type.INTERACTIVE_TESTING && invitation.type !== import_services6.Invitation.Type.MULTIUSE_TESTING;
|
|
1513
1653
|
var HostSpaceInvitationExtension = class extends import_teleport2.RpcExtension {
|
|
1514
1654
|
constructor(_callbacks) {
|
|
1515
1655
|
super({
|
|
@@ -1560,7 +1700,7 @@ var GuestSpaceInvitationExtension = class extends import_teleport2.RpcExtension
|
|
|
1560
1700
|
};
|
|
1561
1701
|
|
|
1562
1702
|
// packages/sdk/client-services/src/packlets/invitations/space-invitations-service.ts
|
|
1563
|
-
var
|
|
1703
|
+
var import_node_assert8 = __toESM(require("node:assert"));
|
|
1564
1704
|
var SpaceInvitationsServiceImpl = class extends AbstractInvitationsService {
|
|
1565
1705
|
// prettier-ignore
|
|
1566
1706
|
constructor(identityManager, invitationsHandler, _getSpaceManager) {
|
|
@@ -1569,37 +1709,37 @@ var SpaceInvitationsServiceImpl = class extends AbstractInvitationsService {
|
|
|
1569
1709
|
this._getSpaceManager = _getSpaceManager;
|
|
1570
1710
|
}
|
|
1571
1711
|
getContext(invitation) {
|
|
1572
|
-
(0,
|
|
1712
|
+
(0, import_node_assert8.default)(invitation.spaceKey);
|
|
1573
1713
|
const spaceManager = this._getSpaceManager();
|
|
1574
1714
|
const space = spaceManager.spaces.get(invitation.spaceKey);
|
|
1575
|
-
(0,
|
|
1715
|
+
(0, import_node_assert8.default)(space);
|
|
1576
1716
|
return space;
|
|
1577
1717
|
}
|
|
1578
1718
|
};
|
|
1579
1719
|
|
|
1580
1720
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
1581
|
-
var
|
|
1582
|
-
var
|
|
1721
|
+
var import_node_assert10 = __toESM(require("node:assert"));
|
|
1722
|
+
var import_async11 = require("@dxos/async");
|
|
1583
1723
|
var import_context6 = require("@dxos/context");
|
|
1584
|
-
var
|
|
1585
|
-
var
|
|
1724
|
+
var import_credentials11 = require("@dxos/credentials");
|
|
1725
|
+
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
1586
1726
|
var import_keys6 = require("@dxos/keys");
|
|
1587
1727
|
var import_log9 = require("@dxos/log");
|
|
1588
1728
|
var import_teleport_extension_presence = require("@dxos/teleport-extension-presence");
|
|
1589
1729
|
var import_util4 = require("@dxos/util");
|
|
1590
1730
|
|
|
1591
1731
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
1592
|
-
var
|
|
1732
|
+
var import_async10 = require("@dxos/async");
|
|
1593
1733
|
var import_context5 = require("@dxos/context");
|
|
1594
|
-
var
|
|
1595
|
-
var
|
|
1734
|
+
var import_debug4 = require("@dxos/debug");
|
|
1735
|
+
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
1596
1736
|
var import_keys5 = require("@dxos/keys");
|
|
1597
|
-
var
|
|
1737
|
+
var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
1598
1738
|
var import_util3 = require("@dxos/util");
|
|
1599
1739
|
|
|
1600
1740
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
1601
|
-
var
|
|
1602
|
-
var
|
|
1741
|
+
var import_node_assert9 = __toESM(require("node:assert"));
|
|
1742
|
+
var import_async9 = require("@dxos/async");
|
|
1603
1743
|
var import_context4 = require("@dxos/context");
|
|
1604
1744
|
var import_keys4 = require("@dxos/keys");
|
|
1605
1745
|
var import_log8 = require("@dxos/log");
|
|
@@ -1611,7 +1751,7 @@ var NOTARIZE_TIMEOUT = 1e4;
|
|
|
1611
1751
|
var NotarizationPlugin = class {
|
|
1612
1752
|
constructor() {
|
|
1613
1753
|
this._ctx = new import_context4.Context();
|
|
1614
|
-
this._extensionOpened = new
|
|
1754
|
+
this._extensionOpened = new import_async9.Event();
|
|
1615
1755
|
this._extensions = /* @__PURE__ */ new Set();
|
|
1616
1756
|
this._processedCredentials = new import_util2.ComplexSet(import_keys4.PublicKey.hash);
|
|
1617
1757
|
this._processCredentialsTriggers = new import_util2.ComplexMap(import_keys4.PublicKey.hash);
|
|
@@ -1633,8 +1773,8 @@ var NotarizationPlugin = class {
|
|
|
1633
1773
|
scope: this,
|
|
1634
1774
|
callSite: (f, a) => f(...a)
|
|
1635
1775
|
});
|
|
1636
|
-
(0,
|
|
1637
|
-
const errors = new
|
|
1776
|
+
(0, import_node_assert9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
|
|
1777
|
+
const errors = new import_async9.Trigger();
|
|
1638
1778
|
const ctx = this._ctx.derive({
|
|
1639
1779
|
onError: (err) => {
|
|
1640
1780
|
import_log8.log.warn("Notarization error", {
|
|
@@ -1649,7 +1789,7 @@ var NotarizationPlugin = class {
|
|
|
1649
1789
|
errors.throw(err);
|
|
1650
1790
|
}
|
|
1651
1791
|
});
|
|
1652
|
-
(0,
|
|
1792
|
+
(0, import_async9.scheduleTask)(ctx, () => {
|
|
1653
1793
|
import_log8.log.warn("Notarization timeout", {}, {
|
|
1654
1794
|
file: "notarization-plugin.ts",
|
|
1655
1795
|
line: 61,
|
|
@@ -1657,11 +1797,11 @@ var NotarizationPlugin = class {
|
|
|
1657
1797
|
callSite: (f, a) => f(...a)
|
|
1658
1798
|
});
|
|
1659
1799
|
void ctx.dispose();
|
|
1660
|
-
errors.throw(new
|
|
1800
|
+
errors.throw(new import_async9.TimeoutError(NOTARIZE_TIMEOUT, "Notarization timed out"));
|
|
1661
1801
|
}, NOTARIZE_TIMEOUT);
|
|
1662
1802
|
const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
|
|
1663
1803
|
const peersTried = /* @__PURE__ */ new Set();
|
|
1664
|
-
const notarizeTask = new
|
|
1804
|
+
const notarizeTask = new import_async9.DeferredTask(ctx, async () => {
|
|
1665
1805
|
try {
|
|
1666
1806
|
if (this._extensions.size === 0) {
|
|
1667
1807
|
import_log8.log.warn("No peers to notarize with", {}, {
|
|
@@ -1685,7 +1825,7 @@ var NotarizationPlugin = class {
|
|
|
1685
1825
|
callSite: (f, a) => f(...a)
|
|
1686
1826
|
});
|
|
1687
1827
|
peersTried.clear();
|
|
1688
|
-
(0,
|
|
1828
|
+
(0, import_async9.scheduleTask)(ctx, () => notarizeTask.schedule(), RETRY_TIMEOUT);
|
|
1689
1829
|
return;
|
|
1690
1830
|
}
|
|
1691
1831
|
peersTried.add(peer);
|
|
@@ -1747,14 +1887,14 @@ var NotarizationPlugin = class {
|
|
|
1747
1887
|
this._processCredentialsTriggers.delete(credential.id);
|
|
1748
1888
|
}
|
|
1749
1889
|
setWriter(writer) {
|
|
1750
|
-
(0,
|
|
1890
|
+
(0, import_node_assert9.default)(!this._writer, "Writer already set.");
|
|
1751
1891
|
this._writer = writer;
|
|
1752
1892
|
}
|
|
1753
1893
|
async _waitUntilProcessed(id) {
|
|
1754
1894
|
if (this._processedCredentials.has(id)) {
|
|
1755
1895
|
return;
|
|
1756
1896
|
}
|
|
1757
|
-
await (0, import_util2.entry)(this._processCredentialsTriggers, id).orInsert(new
|
|
1897
|
+
await (0, import_util2.entry)(this._processCredentialsTriggers, id).orInsert(new import_async9.Trigger()).value.wait();
|
|
1758
1898
|
}
|
|
1759
1899
|
/**
|
|
1760
1900
|
* Requests from other peers to notarize credentials.
|
|
@@ -1765,7 +1905,7 @@ var NotarizationPlugin = class {
|
|
|
1765
1905
|
throw new Error("Writer not set");
|
|
1766
1906
|
}
|
|
1767
1907
|
for (const credential of (_a = request.credentials) != null ? _a : []) {
|
|
1768
|
-
(0,
|
|
1908
|
+
(0, import_node_assert9.default)(credential.id, "Credential must have an id");
|
|
1769
1909
|
if (this._processedCredentials.has(credential.id)) {
|
|
1770
1910
|
continue;
|
|
1771
1911
|
}
|
|
@@ -1855,7 +1995,7 @@ var DataSpace = class DataSpace2 {
|
|
|
1855
1995
|
this._feedStore = params.feedStore;
|
|
1856
1996
|
this._metadataStore = params.metadataStore;
|
|
1857
1997
|
this._signingContext = params.signingContext;
|
|
1858
|
-
this._dataPipelineController = new
|
|
1998
|
+
this._dataPipelineController = new import_echo_pipeline.DataPipelineControllerImpl({
|
|
1859
1999
|
modelFactory: params.modelFactory,
|
|
1860
2000
|
metadataStore: params.metadataStore,
|
|
1861
2001
|
snapshotManager: params.snapshotManager,
|
|
@@ -1911,7 +2051,7 @@ var DataSpace = class DataSpace2 {
|
|
|
1911
2051
|
timeout: CONTROL_PIPELINE_READY_TIMEFRAME
|
|
1912
2052
|
});
|
|
1913
2053
|
await this._createWritableFeeds();
|
|
1914
|
-
this.notarizationPlugin.setWriter((0,
|
|
2054
|
+
this.notarizationPlugin.setWriter((0, import_echo_pipeline.createMappedFeedWriter)((credential) => ({
|
|
1915
2055
|
credential: {
|
|
1916
2056
|
credential
|
|
1917
2057
|
}
|
|
@@ -1932,7 +2072,7 @@ var DataSpace = class DataSpace2 {
|
|
|
1932
2072
|
spaceKey: this.key,
|
|
1933
2073
|
deviceKey: this._signingContext.deviceKey,
|
|
1934
2074
|
identityKey: this._signingContext.identityKey,
|
|
1935
|
-
designation:
|
|
2075
|
+
designation: import_credentials10.AdmittedFeed.Designation.CONTROL
|
|
1936
2076
|
}
|
|
1937
2077
|
}));
|
|
1938
2078
|
}
|
|
@@ -1948,7 +2088,7 @@ var DataSpace = class DataSpace2 {
|
|
|
1948
2088
|
spaceKey: this.key,
|
|
1949
2089
|
deviceKey: this._signingContext.deviceKey,
|
|
1950
2090
|
identityKey: this._signingContext.identityKey,
|
|
1951
|
-
designation:
|
|
2091
|
+
designation: import_credentials10.AdmittedFeed.Designation.DATA
|
|
1952
2092
|
}
|
|
1953
2093
|
}));
|
|
1954
2094
|
}
|
|
@@ -1959,10 +2099,10 @@ var DataSpace = class DataSpace2 {
|
|
|
1959
2099
|
}
|
|
1960
2100
|
};
|
|
1961
2101
|
__decorate([
|
|
1962
|
-
(0,
|
|
2102
|
+
(0, import_debug4.timed)(1e4)
|
|
1963
2103
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
1964
2104
|
DataSpace = __decorate([
|
|
1965
|
-
(0,
|
|
2105
|
+
(0, import_async10.trackLeaks)("open", "close")
|
|
1966
2106
|
], DataSpace);
|
|
1967
2107
|
|
|
1968
2108
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
@@ -1988,7 +2128,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
1988
2128
|
this._feedStore = _feedStore;
|
|
1989
2129
|
this._snapshotStore = _snapshotStore;
|
|
1990
2130
|
this._ctx = new import_context6.Context();
|
|
1991
|
-
this.updated = new
|
|
2131
|
+
this.updated = new import_async11.Event();
|
|
1992
2132
|
this._spaces = new import_util4.ComplexMap(import_keys6.PublicKey.hash);
|
|
1993
2133
|
}
|
|
1994
2134
|
// TODO(burdon): Remove.
|
|
@@ -2061,10 +2201,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2061
2201
|
callSite: (f, a) => f(...a)
|
|
2062
2202
|
});
|
|
2063
2203
|
const space = await this._constructSpace(metadata);
|
|
2064
|
-
const credentials = await (0,
|
|
2204
|
+
const credentials = await (0, import_echo_pipeline2.spaceGenesis)(this._keyring, this._signingContext, space.inner);
|
|
2065
2205
|
await this._metadataStore.addSpace(metadata);
|
|
2066
2206
|
const memberCredential = credentials[1];
|
|
2067
|
-
(0,
|
|
2207
|
+
(0, import_node_assert10.default)((0, import_credentials11.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2068
2208
|
await this._signingContext.recordCredential(memberCredential);
|
|
2069
2209
|
await space.initializeDataPipeline();
|
|
2070
2210
|
this._dataServiceSubscriptions.registerSpace(space.key, space.dataPipelineController.databaseBackend.createDataServiceHost());
|
|
@@ -2073,7 +2213,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2073
2213
|
}
|
|
2074
2214
|
// TODO(burdon): Rename join space.
|
|
2075
2215
|
async acceptSpace(opts) {
|
|
2076
|
-
(0,
|
|
2216
|
+
(0, import_node_assert10.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
|
|
2077
2217
|
const metadata = {
|
|
2078
2218
|
key: opts.spaceKey,
|
|
2079
2219
|
genesisFeedKey: opts.genesisFeedKey
|
|
@@ -2092,7 +2232,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2092
2232
|
offlineTimeout: 3e4,
|
|
2093
2233
|
identityKey: this._signingContext.identityKey
|
|
2094
2234
|
});
|
|
2095
|
-
const snapshotManager = new
|
|
2235
|
+
const snapshotManager = new import_echo_pipeline2.SnapshotManager(this._snapshotStore);
|
|
2096
2236
|
const controlFeed = metadata.controlFeedKey && await this._feedStore.openFeed(metadata.controlFeedKey, {
|
|
2097
2237
|
writable: true
|
|
2098
2238
|
});
|
|
@@ -2134,19 +2274,19 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2134
2274
|
}
|
|
2135
2275
|
};
|
|
2136
2276
|
__decorate2([
|
|
2137
|
-
|
|
2277
|
+
import_async11.synchronized
|
|
2138
2278
|
], DataSpaceManager.prototype, "open", null);
|
|
2139
2279
|
__decorate2([
|
|
2140
|
-
|
|
2280
|
+
import_async11.synchronized
|
|
2141
2281
|
], DataSpaceManager.prototype, "close", null);
|
|
2142
2282
|
__decorate2([
|
|
2143
|
-
|
|
2283
|
+
import_async11.synchronized
|
|
2144
2284
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
2145
2285
|
__decorate2([
|
|
2146
|
-
|
|
2286
|
+
import_async11.synchronized
|
|
2147
2287
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
2148
2288
|
DataSpaceManager = __decorate2([
|
|
2149
|
-
(0,
|
|
2289
|
+
(0, import_async11.trackLeaks)("open", "close")
|
|
2150
2290
|
], DataSpaceManager);
|
|
2151
2291
|
|
|
2152
2292
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
@@ -2156,30 +2296,30 @@ var ServiceContext = class {
|
|
|
2156
2296
|
this.storage = storage;
|
|
2157
2297
|
this.networkManager = networkManager;
|
|
2158
2298
|
this.modelFactory = modelFactory;
|
|
2159
|
-
this.initialized = new
|
|
2160
|
-
this.dataServiceSubscriptions = new
|
|
2161
|
-
this.metadataStore = new
|
|
2162
|
-
this.snapshotStore = new
|
|
2299
|
+
this.initialized = new import_async12.Trigger();
|
|
2300
|
+
this.dataServiceSubscriptions = new import_echo_pipeline3.DataServiceSubscriptions();
|
|
2301
|
+
this.metadataStore = new import_echo_pipeline3.MetadataStore(storage.createDirectory("metadata"));
|
|
2302
|
+
this.snapshotStore = new import_echo_pipeline3.SnapshotStore(storage.createDirectory("snapshots"));
|
|
2163
2303
|
this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
|
|
2164
2304
|
this.feedStore = new import_feed_store3.FeedStore({
|
|
2165
2305
|
factory: new import_feed_store3.FeedFactory({
|
|
2166
2306
|
root: storage.createDirectory("feeds"),
|
|
2167
2307
|
signer: this.keyring,
|
|
2168
2308
|
hypercore: {
|
|
2169
|
-
valueEncoding:
|
|
2309
|
+
valueEncoding: import_echo_pipeline3.valueEncoding
|
|
2170
2310
|
}
|
|
2171
2311
|
})
|
|
2172
2312
|
});
|
|
2173
|
-
this.spaceManager = new
|
|
2313
|
+
this.spaceManager = new import_echo_pipeline3.SpaceManager({
|
|
2174
2314
|
feedStore: this.feedStore,
|
|
2175
2315
|
networkManager: this.networkManager
|
|
2176
2316
|
});
|
|
2177
2317
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
2178
|
-
this.
|
|
2318
|
+
this.deviceInvitations = new DeviceInvitationsHandler({
|
|
2179
2319
|
networkManager: this.networkManager,
|
|
2180
2320
|
getIdentity: () => {
|
|
2181
2321
|
var _a;
|
|
2182
|
-
return (_a = this.identityManager.identity) != null ? _a : (0,
|
|
2322
|
+
return (_a = this.identityManager.identity) != null ? _a : (0, import_debug5.failUndefined)();
|
|
2183
2323
|
},
|
|
2184
2324
|
acceptIdentity: this._acceptIdentity.bind(this),
|
|
2185
2325
|
keyring: this.keyring
|
|
@@ -2262,7 +2402,7 @@ var ServiceContext = class {
|
|
|
2262
2402
|
scope: this,
|
|
2263
2403
|
callSite: (f, a) => f(...a)
|
|
2264
2404
|
});
|
|
2265
|
-
const identity = (_a = this.identityManager.identity) != null ? _a : (0,
|
|
2405
|
+
const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug5.failUndefined)();
|
|
2266
2406
|
const signingContext = {
|
|
2267
2407
|
credentialSigner: identity.getIdentityCredentialSigner(),
|
|
2268
2408
|
identityKey: identity.identityKey,
|
|
@@ -2282,7 +2422,7 @@ var ServiceContext = class {
|
|
|
2282
2422
|
this.initialized.wake();
|
|
2283
2423
|
this._deviceSpaceSync = identity.space.spaceState.registerProcessor({
|
|
2284
2424
|
process: async (credential) => {
|
|
2285
|
-
const assertion = (0,
|
|
2425
|
+
const assertion = (0, import_credentials12.getCredentialAssertion)(credential);
|
|
2286
2426
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
2287
2427
|
return;
|
|
2288
2428
|
}
|
|
@@ -2342,227 +2482,30 @@ var ServiceContext = class {
|
|
|
2342
2482
|
var import_protocols6 = require("@dxos/protocols");
|
|
2343
2483
|
var import_rpc = require("@dxos/rpc");
|
|
2344
2484
|
var clientServiceBundle = (0, import_rpc.createServiceBundle)({
|
|
2345
|
-
|
|
2485
|
+
SystemService: import_protocols6.schema.getService("dxos.client.services.SystemService"),
|
|
2486
|
+
IdentityService: import_protocols6.schema.getService("dxos.client.services.IdentityService"),
|
|
2487
|
+
DeviceInvitationsService: import_protocols6.schema.getService("dxos.client.services.DeviceInvitationsService"),
|
|
2346
2488
|
DevicesService: import_protocols6.schema.getService("dxos.client.services.DevicesService"),
|
|
2347
2489
|
SpaceInvitationsService: import_protocols6.schema.getService("dxos.client.services.SpaceInvitationsService"),
|
|
2348
2490
|
SpacesService: import_protocols6.schema.getService("dxos.client.services.SpacesService"),
|
|
2491
|
+
DataService: import_protocols6.schema.getService("dxos.echo.service.DataService"),
|
|
2349
2492
|
NetworkService: import_protocols6.schema.getService("dxos.client.services.NetworkService"),
|
|
2350
2493
|
// TODO(burdon): Deprecated.
|
|
2351
|
-
SpaceService: import_protocols6.schema.getService("dxos.client.SpaceService"),
|
|
2352
|
-
DataService: import_protocols6.schema.getService("dxos.echo.service.DataService"),
|
|
2353
|
-
ProfileService: import_protocols6.schema.getService("dxos.client.ProfileService"),
|
|
2354
|
-
SystemService: import_protocols6.schema.getService("dxos.client.SystemService"),
|
|
2355
2494
|
DevtoolsHost: import_protocols6.schema.getService("dxos.devtools.host.DevtoolsHost"),
|
|
2356
2495
|
TracingService: import_protocols6.schema.getService("dxos.devtools.host.TracingService")
|
|
2357
2496
|
});
|
|
2358
2497
|
|
|
2359
2498
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
2499
|
+
var import_node_assert13 = __toESM(require("node:assert"));
|
|
2500
|
+
var import_async23 = require("@dxos/async");
|
|
2360
2501
|
var import_debug7 = require("@dxos/debug");
|
|
2361
2502
|
var import_document_model = require("@dxos/document-model");
|
|
2362
|
-
var
|
|
2363
|
-
var
|
|
2503
|
+
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
2504
|
+
var import_log17 = require("@dxos/log");
|
|
2364
2505
|
var import_model_factory = require("@dxos/model-factory");
|
|
2365
|
-
var
|
|
2506
|
+
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2366
2507
|
var import_text_model = require("@dxos/text-model");
|
|
2367
2508
|
|
|
2368
|
-
// packages/sdk/client-services/src/packlets/deprecated/space.ts
|
|
2369
|
-
var import_node_assert9 = __toESM(require("node:assert"));
|
|
2370
|
-
var import_codec_protobuf2 = require("@dxos/codec-protobuf");
|
|
2371
|
-
var import_debug4 = require("@dxos/debug");
|
|
2372
|
-
var import_log11 = require("@dxos/log");
|
|
2373
|
-
var import_client = require("@dxos/protocols/proto/dxos/client");
|
|
2374
|
-
var import_util5 = require("@dxos/util");
|
|
2375
|
-
var SpaceServiceImpl = class {
|
|
2376
|
-
constructor(serviceContext) {
|
|
2377
|
-
this.serviceContext = serviceContext;
|
|
2378
|
-
this.inviteeInvitations = /* @__PURE__ */ new Map();
|
|
2379
|
-
}
|
|
2380
|
-
subscribeToSpace(request) {
|
|
2381
|
-
return new import_codec_protobuf2.Stream(({ next }) => {
|
|
2382
|
-
next({
|
|
2383
|
-
space: {
|
|
2384
|
-
publicKey: request.spaceKey,
|
|
2385
|
-
isOpen: true,
|
|
2386
|
-
isActive: true,
|
|
2387
|
-
members: []
|
|
2388
|
-
}
|
|
2389
|
-
});
|
|
2390
|
-
});
|
|
2391
|
-
}
|
|
2392
|
-
subscribeSpaces() {
|
|
2393
|
-
return new import_codec_protobuf2.Stream(({ next, ctx }) => {
|
|
2394
|
-
const onUpdate = () => {
|
|
2395
|
-
const spaces = Array.from(this.serviceContext.dataSpaceManager.spaces.values()).filter((space) => this.serviceContext.dataServiceSubscriptions.getDataService(space.key)).map((space) => ({
|
|
2396
|
-
publicKey: space.key,
|
|
2397
|
-
isOpen: true,
|
|
2398
|
-
isActive: true,
|
|
2399
|
-
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
2400
|
-
var _a, _b, _c;
|
|
2401
|
-
return {
|
|
2402
|
-
identityKey: member.key,
|
|
2403
|
-
profile: {
|
|
2404
|
-
identityKey: member.key,
|
|
2405
|
-
displayName: (_b = (_a = member.assertion.profile) == null ? void 0 : _a.displayName) != null ? _b : (0, import_util5.humanize)(member.key)
|
|
2406
|
-
},
|
|
2407
|
-
presence: ((_c = this.serviceContext.identityManager.identity) == null ? void 0 : _c.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_client.SpaceMember.PresenceState.ONLINE : import_client.SpaceMember.PresenceState.OFFLINE
|
|
2408
|
-
};
|
|
2409
|
-
})
|
|
2410
|
-
}));
|
|
2411
|
-
(0, import_log11.log)("update", {
|
|
2412
|
-
spaces
|
|
2413
|
-
}, {
|
|
2414
|
-
file: "space.ts",
|
|
2415
|
-
line: 119,
|
|
2416
|
-
scope: this,
|
|
2417
|
-
callSite: (f, a) => f(...a)
|
|
2418
|
-
});
|
|
2419
|
-
next({
|
|
2420
|
-
spaces
|
|
2421
|
-
});
|
|
2422
|
-
};
|
|
2423
|
-
setTimeout(async () => {
|
|
2424
|
-
if (!this.serviceContext.dataSpaceManager) {
|
|
2425
|
-
next({
|
|
2426
|
-
spaces: []
|
|
2427
|
-
});
|
|
2428
|
-
}
|
|
2429
|
-
await this.serviceContext.initialized.wait();
|
|
2430
|
-
const subscribeSpaces = () => {
|
|
2431
|
-
for (const space of this.serviceContext.dataSpaceManager.spaces.values()) {
|
|
2432
|
-
if (!this.serviceContext.dataServiceSubscriptions.getDataService(space.key)) {
|
|
2433
|
-
continue;
|
|
2434
|
-
}
|
|
2435
|
-
space.stateUpdate.on(ctx, onUpdate);
|
|
2436
|
-
space.presence.updated.on(ctx, onUpdate);
|
|
2437
|
-
}
|
|
2438
|
-
};
|
|
2439
|
-
this.serviceContext.dataSpaceManager.updated.on(ctx, () => {
|
|
2440
|
-
subscribeSpaces();
|
|
2441
|
-
onUpdate();
|
|
2442
|
-
});
|
|
2443
|
-
subscribeSpaces();
|
|
2444
|
-
onUpdate();
|
|
2445
|
-
});
|
|
2446
|
-
});
|
|
2447
|
-
}
|
|
2448
|
-
async getSpaceDetails(request) {
|
|
2449
|
-
return (0, import_debug4.todo)();
|
|
2450
|
-
}
|
|
2451
|
-
async createSpace() {
|
|
2452
|
-
if (!this.serviceContext.identityManager.identity) {
|
|
2453
|
-
throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/halo");
|
|
2454
|
-
}
|
|
2455
|
-
await this.serviceContext.initialized.wait();
|
|
2456
|
-
const space = await this.serviceContext.dataSpaceManager.createSpace();
|
|
2457
|
-
return {
|
|
2458
|
-
publicKey: space.key,
|
|
2459
|
-
isOpen: true,
|
|
2460
|
-
isActive: true
|
|
2461
|
-
};
|
|
2462
|
-
}
|
|
2463
|
-
async cloneSpace(snapshot) {
|
|
2464
|
-
return (0, import_debug4.todo)();
|
|
2465
|
-
}
|
|
2466
|
-
async setSpaceState(request) {
|
|
2467
|
-
return (0, import_debug4.todo)();
|
|
2468
|
-
}
|
|
2469
|
-
async authenticateInvitation(request) {
|
|
2470
|
-
var _a;
|
|
2471
|
-
(0, import_node_assert9.default)(request.processId, "Process ID is missing.");
|
|
2472
|
-
const invitation = this.inviteeInvitations.get(request.processId);
|
|
2473
|
-
(0, import_node_assert9.default)(invitation, "Invitation not found.");
|
|
2474
|
-
(0, import_node_assert9.default)(request.secret, "Secret not provided.");
|
|
2475
|
-
invitation.secret = request.secret;
|
|
2476
|
-
(_a = invitation.secretTrigger) == null ? void 0 : _a.call(invitation);
|
|
2477
|
-
}
|
|
2478
|
-
subscribeMembers(request) {
|
|
2479
|
-
return (0, import_debug4.todo)();
|
|
2480
|
-
}
|
|
2481
|
-
async createSnapshot(request) {
|
|
2482
|
-
return (0, import_debug4.todo)();
|
|
2483
|
-
}
|
|
2484
|
-
};
|
|
2485
|
-
|
|
2486
|
-
// packages/sdk/client-services/src/packlets/deprecated/profile.ts
|
|
2487
|
-
var import_node_assert10 = __toESM(require("node:assert"));
|
|
2488
|
-
var import_codec_protobuf3 = require("@dxos/codec-protobuf");
|
|
2489
|
-
var import_credentials12 = require("@dxos/credentials");
|
|
2490
|
-
var import_debug5 = require("@dxos/debug");
|
|
2491
|
-
var ProfileServiceImpl = class {
|
|
2492
|
-
constructor(context) {
|
|
2493
|
-
this.context = context;
|
|
2494
|
-
this.inviteeInvitations = /* @__PURE__ */ new Map();
|
|
2495
|
-
}
|
|
2496
|
-
subscribeProfile() {
|
|
2497
|
-
return new import_codec_protobuf3.Stream(({ next }) => {
|
|
2498
|
-
const emitNext = () => {
|
|
2499
|
-
var _a;
|
|
2500
|
-
return next({
|
|
2501
|
-
profile: this.context.identityManager.identity ? {
|
|
2502
|
-
identityKey: this.context.identityManager.identity.identityKey,
|
|
2503
|
-
deviceKey: this.context.identityManager.identity.deviceKey,
|
|
2504
|
-
displayName: (_a = this.context.identityManager.identity.profileDocument) == null ? void 0 : _a.displayName,
|
|
2505
|
-
haloSpace: this.context.identityManager.identity.space.key
|
|
2506
|
-
} : void 0
|
|
2507
|
-
});
|
|
2508
|
-
};
|
|
2509
|
-
emitNext();
|
|
2510
|
-
return this.context.identityManager.stateUpdate.on(emitNext);
|
|
2511
|
-
});
|
|
2512
|
-
}
|
|
2513
|
-
async createProfile(request) {
|
|
2514
|
-
var _a;
|
|
2515
|
-
await this.context.createIdentity({
|
|
2516
|
-
displayName: request.displayName
|
|
2517
|
-
});
|
|
2518
|
-
return {
|
|
2519
|
-
identityKey: this.context.identityManager.identity.identityKey,
|
|
2520
|
-
deviceKey: this.context.identityManager.identity.deviceKey,
|
|
2521
|
-
displayName: (_a = this.context.identityManager.identity.profileDocument) == null ? void 0 : _a.displayName,
|
|
2522
|
-
haloSpace: this.context.identityManager.identity.space.key
|
|
2523
|
-
};
|
|
2524
|
-
}
|
|
2525
|
-
async recoverProfile(request) {
|
|
2526
|
-
return (0, import_debug5.todo)();
|
|
2527
|
-
if (!request.seedPhrase) {
|
|
2528
|
-
throw new Error("Recovery SeedPhrase not provided.");
|
|
2529
|
-
}
|
|
2530
|
-
}
|
|
2531
|
-
async signPresentation({ presentation, nonce }) {
|
|
2532
|
-
(0, import_node_assert10.default)(this.context.identityManager.identity, "Identity not initialized.");
|
|
2533
|
-
return await (0, import_credentials12.signPresentation)({
|
|
2534
|
-
presentation,
|
|
2535
|
-
signer: this.context.keyring,
|
|
2536
|
-
signerKey: this.context.identityManager.identity.deviceKey,
|
|
2537
|
-
chain: this.context.identityManager.identity.deviceCredentialChain,
|
|
2538
|
-
nonce
|
|
2539
|
-
});
|
|
2540
|
-
}
|
|
2541
|
-
};
|
|
2542
|
-
|
|
2543
|
-
// packages/sdk/client-services/src/packlets/deprecated/system.ts
|
|
2544
|
-
var SystemServiceImpl = class {
|
|
2545
|
-
constructor({ config, onInit, onStatus, onReset }) {
|
|
2546
|
-
this._config = config;
|
|
2547
|
-
this._onInit = onInit;
|
|
2548
|
-
this._onStatus = onStatus;
|
|
2549
|
-
this._onReset = onReset;
|
|
2550
|
-
}
|
|
2551
|
-
async getConfig() {
|
|
2552
|
-
return this._config.values;
|
|
2553
|
-
}
|
|
2554
|
-
// TODO(burdon): Connect to iframe RPC heartbeat for network status?
|
|
2555
|
-
async getStatus() {
|
|
2556
|
-
return this._onStatus();
|
|
2557
|
-
}
|
|
2558
|
-
async initSession() {
|
|
2559
|
-
await this._onInit();
|
|
2560
|
-
}
|
|
2561
|
-
async reset() {
|
|
2562
|
-
await this._onReset();
|
|
2563
|
-
}
|
|
2564
|
-
};
|
|
2565
|
-
|
|
2566
2509
|
// packages/sdk/client-services/src/packlets/deprecated/tracing.ts
|
|
2567
2510
|
var TracingServiceImpl = class {
|
|
2568
2511
|
constructor(_config) {
|
|
@@ -2576,23 +2519,70 @@ var TracingServiceImpl = class {
|
|
|
2576
2519
|
}
|
|
2577
2520
|
};
|
|
2578
2521
|
|
|
2579
|
-
// packages/sdk/client-services/src/packlets/
|
|
2522
|
+
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
2580
2523
|
var import_async13 = require("@dxos/async");
|
|
2581
|
-
var
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2524
|
+
var import_codec_protobuf3 = require("@dxos/codec-protobuf");
|
|
2525
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2526
|
+
var DevicesServiceImpl = class {
|
|
2527
|
+
constructor(_identityManager) {
|
|
2528
|
+
this._identityManager = _identityManager;
|
|
2529
|
+
}
|
|
2530
|
+
updateDevice(request) {
|
|
2531
|
+
throw new Error("Method not implemented.");
|
|
2532
|
+
}
|
|
2533
|
+
queryDevices() {
|
|
2534
|
+
return new import_codec_protobuf3.Stream(({ next }) => {
|
|
2535
|
+
const update = () => {
|
|
2536
|
+
var _a;
|
|
2537
|
+
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
2538
|
+
if (!deviceKeys) {
|
|
2539
|
+
next({
|
|
2540
|
+
devices: []
|
|
2541
|
+
});
|
|
2542
|
+
} else {
|
|
2543
|
+
next({
|
|
2544
|
+
devices: Array.from(deviceKeys.values()).map((key) => {
|
|
2545
|
+
var _a2;
|
|
2546
|
+
return {
|
|
2547
|
+
deviceKey: key,
|
|
2548
|
+
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services7.DeviceKind.CURRENT : import_services7.DeviceKind.TRUSTED
|
|
2549
|
+
};
|
|
2550
|
+
})
|
|
2551
|
+
});
|
|
2552
|
+
}
|
|
2553
|
+
};
|
|
2554
|
+
const subscriptions = new import_async13.EventSubscriptions();
|
|
2555
|
+
subscriptions.add(this._identityManager.stateUpdate.on(() => {
|
|
2556
|
+
update();
|
|
2557
|
+
if (this._identityManager.identity) {
|
|
2558
|
+
subscriptions.add(this._identityManager.identity.stateUpdate.on(() => {
|
|
2559
|
+
update();
|
|
2560
|
+
}));
|
|
2561
|
+
}
|
|
2562
|
+
}));
|
|
2563
|
+
update();
|
|
2564
|
+
return () => subscriptions.clear();
|
|
2565
|
+
});
|
|
2566
|
+
}
|
|
2567
|
+
};
|
|
2568
|
+
|
|
2569
|
+
// packages/sdk/client-services/src/packlets/devtools/devtools.ts
|
|
2570
|
+
var import_async15 = require("@dxos/async");
|
|
2571
|
+
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
2572
|
+
|
|
2573
|
+
// packages/sdk/client-services/src/packlets/devtools/feeds.ts
|
|
2574
|
+
var import_async14 = require("@dxos/async");
|
|
2575
|
+
var import_codec_protobuf4 = require("@dxos/codec-protobuf");
|
|
2576
|
+
var import_feed_store4 = require("@dxos/feed-store");
|
|
2587
2577
|
var import_keys7 = require("@dxos/keys");
|
|
2588
|
-
var
|
|
2578
|
+
var import_util5 = require("@dxos/util");
|
|
2589
2579
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
2590
2580
|
return new import_codec_protobuf4.Stream(({ next }) => {
|
|
2591
2581
|
if ((feedKeys == null ? void 0 : feedKeys.length) === 0) {
|
|
2592
2582
|
return;
|
|
2593
2583
|
}
|
|
2594
|
-
const subscriptions = new
|
|
2595
|
-
const feedMap = new
|
|
2584
|
+
const subscriptions = new import_async14.EventSubscriptions();
|
|
2585
|
+
const feedMap = new import_util5.ComplexMap(import_keys7.PublicKey.hash);
|
|
2596
2586
|
const update = () => {
|
|
2597
2587
|
const { feeds } = feedStore;
|
|
2598
2588
|
feeds.filter((feed) => !(feedKeys == null ? void 0 : feedKeys.length) || feedKeys.some((feedKey) => feedKey.equals(feed.key))).forEach((feed) => {
|
|
@@ -2621,7 +2611,7 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
|
|
|
2621
2611
|
if (!feedKey) {
|
|
2622
2612
|
return;
|
|
2623
2613
|
}
|
|
2624
|
-
const subscriptions = new
|
|
2614
|
+
const subscriptions = new import_async14.EventSubscriptions();
|
|
2625
2615
|
const timeout = setTimeout(async () => {
|
|
2626
2616
|
const feed = feedStore.getFeed(feedKey);
|
|
2627
2617
|
if (!feed) {
|
|
@@ -2762,7 +2752,7 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
|
|
|
2762
2752
|
// packages/sdk/client-services/src/packlets/devtools/devtools.ts
|
|
2763
2753
|
var DevtoolsHostEvents = class {
|
|
2764
2754
|
constructor() {
|
|
2765
|
-
this.ready = new
|
|
2755
|
+
this.ready = new import_async15.Event();
|
|
2766
2756
|
}
|
|
2767
2757
|
};
|
|
2768
2758
|
var DevtoolsServiceImpl = class {
|
|
@@ -2846,56 +2836,14 @@ var DevtoolsServiceImpl = class {
|
|
|
2846
2836
|
}
|
|
2847
2837
|
};
|
|
2848
2838
|
|
|
2849
|
-
// packages/sdk/client-services/src/packlets/identity/devices-service-impl.ts
|
|
2850
|
-
var import_async14 = require("@dxos/async");
|
|
2851
|
-
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
2852
|
-
var DevicesServiceImpl = class {
|
|
2853
|
-
constructor(_identityManager) {
|
|
2854
|
-
this._identityManager = _identityManager;
|
|
2855
|
-
}
|
|
2856
|
-
updateDevice() {
|
|
2857
|
-
throw new Error("Method not implemented.");
|
|
2858
|
-
}
|
|
2859
|
-
queryDevices() {
|
|
2860
|
-
return new import_codec_protobuf9.Stream(({ next }) => {
|
|
2861
|
-
const update = () => {
|
|
2862
|
-
var _a;
|
|
2863
|
-
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
2864
|
-
if (!deviceKeys) {
|
|
2865
|
-
next({
|
|
2866
|
-
devices: []
|
|
2867
|
-
});
|
|
2868
|
-
} else {
|
|
2869
|
-
next({
|
|
2870
|
-
devices: Array.from(deviceKeys.values()).map((key) => ({
|
|
2871
|
-
deviceKey: key
|
|
2872
|
-
}))
|
|
2873
|
-
});
|
|
2874
|
-
}
|
|
2875
|
-
};
|
|
2876
|
-
const dispose = new import_async14.EventSubscriptions();
|
|
2877
|
-
dispose.add(this._identityManager.stateUpdate.on(() => {
|
|
2878
|
-
update();
|
|
2879
|
-
if (this._identityManager.identity) {
|
|
2880
|
-
dispose.add(this._identityManager.identity.stateUpdate.on(() => {
|
|
2881
|
-
update();
|
|
2882
|
-
}));
|
|
2883
|
-
}
|
|
2884
|
-
}));
|
|
2885
|
-
update();
|
|
2886
|
-
return () => dispose.clear();
|
|
2887
|
-
});
|
|
2888
|
-
}
|
|
2889
|
-
};
|
|
2890
|
-
|
|
2891
2839
|
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
2892
|
-
var
|
|
2840
|
+
var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
2893
2841
|
var NetworkServiceImpl = class {
|
|
2894
2842
|
constructor(networkManager) {
|
|
2895
2843
|
this.networkManager = networkManager;
|
|
2896
2844
|
}
|
|
2897
2845
|
subscribeToNetworkStatus() {
|
|
2898
|
-
return new
|
|
2846
|
+
return new import_codec_protobuf9.Stream(({ next }) => {
|
|
2899
2847
|
const unsubscribe = this.networkManager.connectionStateChanged.on((state) => next({
|
|
2900
2848
|
state
|
|
2901
2849
|
}));
|
|
@@ -2911,39 +2859,94 @@ var NetworkServiceImpl = class {
|
|
|
2911
2859
|
};
|
|
2912
2860
|
|
|
2913
2861
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
2914
|
-
var
|
|
2915
|
-
var
|
|
2862
|
+
var import_async16 = require("@dxos/async");
|
|
2863
|
+
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
2916
2864
|
var import_debug6 = require("@dxos/debug");
|
|
2917
|
-
var
|
|
2865
|
+
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
2866
|
+
var import_log11 = require("@dxos/log");
|
|
2867
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2868
|
+
var import_util6 = require("@dxos/util");
|
|
2918
2869
|
var SpacesServiceImpl = class {
|
|
2919
|
-
constructor(_spaceManager) {
|
|
2870
|
+
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
2871
|
+
this._identityManager = _identityManager;
|
|
2920
2872
|
this._spaceManager = _spaceManager;
|
|
2873
|
+
this._dataServiceSubscriptions = _dataServiceSubscriptions;
|
|
2874
|
+
this._getDataSpaceManager = _getDataSpaceManager;
|
|
2921
2875
|
}
|
|
2922
2876
|
async createSpace() {
|
|
2923
|
-
|
|
2877
|
+
if (!this._identityManager.identity) {
|
|
2878
|
+
throw new Error("This device has no HALO identity available. See https://docs.dxos.org/guide/halo");
|
|
2879
|
+
}
|
|
2880
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2881
|
+
const space = await dataSpaceManager.createSpace();
|
|
2882
|
+
return this._transformSpace(space);
|
|
2924
2883
|
}
|
|
2925
|
-
|
|
2926
|
-
|
|
2884
|
+
async updateSpace(request) {
|
|
2885
|
+
(0, import_debug6.todo)();
|
|
2927
2886
|
}
|
|
2928
|
-
|
|
2929
|
-
|
|
2887
|
+
querySpaces() {
|
|
2888
|
+
return new import_codec_protobuf10.Stream(({ next, ctx }) => {
|
|
2889
|
+
const onUpdate = async () => {
|
|
2890
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2891
|
+
const spaces = Array.from(dataSpaceManager.spaces.values()).filter((space) => this._dataServiceSubscriptions.getDataService(space.key)).map((space) => this._transformSpace(space));
|
|
2892
|
+
(0, import_log11.log)("update", {
|
|
2893
|
+
spaces
|
|
2894
|
+
}, {
|
|
2895
|
+
file: "spaces-service.ts",
|
|
2896
|
+
line: 59,
|
|
2897
|
+
scope: this,
|
|
2898
|
+
callSite: (f, a) => f(...a)
|
|
2899
|
+
});
|
|
2900
|
+
next({
|
|
2901
|
+
spaces
|
|
2902
|
+
});
|
|
2903
|
+
};
|
|
2904
|
+
setTimeout(async () => {
|
|
2905
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2906
|
+
const subscriptions = new import_async16.EventSubscriptions();
|
|
2907
|
+
const subscribeSpaces = () => {
|
|
2908
|
+
subscriptions.clear();
|
|
2909
|
+
for (const space of dataSpaceManager.spaces.values()) {
|
|
2910
|
+
if (!this._dataServiceSubscriptions.getDataService(space.key)) {
|
|
2911
|
+
continue;
|
|
2912
|
+
}
|
|
2913
|
+
subscriptions.add(space.stateUpdate.on(ctx, onUpdate));
|
|
2914
|
+
subscriptions.add(space.presence.updated.on(ctx, onUpdate));
|
|
2915
|
+
}
|
|
2916
|
+
};
|
|
2917
|
+
dataSpaceManager.updated.on(ctx, () => {
|
|
2918
|
+
subscribeSpaces();
|
|
2919
|
+
void onUpdate();
|
|
2920
|
+
});
|
|
2921
|
+
ctx.onDispose(() => subscriptions.clear());
|
|
2922
|
+
(0, import_async16.scheduleTask)(ctx, () => {
|
|
2923
|
+
subscribeSpaces();
|
|
2924
|
+
void onUpdate();
|
|
2925
|
+
});
|
|
2926
|
+
});
|
|
2927
|
+
if (!this._identityManager.identity) {
|
|
2928
|
+
next({
|
|
2929
|
+
spaces: []
|
|
2930
|
+
});
|
|
2931
|
+
}
|
|
2932
|
+
});
|
|
2930
2933
|
}
|
|
2931
2934
|
queryCredentials({ spaceKey }) {
|
|
2932
|
-
return new
|
|
2935
|
+
return new import_codec_protobuf10.Stream(({ ctx, next }) => {
|
|
2933
2936
|
var _a;
|
|
2934
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new
|
|
2937
|
+
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline4.SpaceNotFoundError(spaceKey));
|
|
2935
2938
|
const processor = space.spaceState.registerProcessor({
|
|
2936
2939
|
process: async (credential) => {
|
|
2937
2940
|
next(credential);
|
|
2938
2941
|
}
|
|
2939
2942
|
});
|
|
2940
2943
|
ctx.onDispose(() => processor.close());
|
|
2941
|
-
(0,
|
|
2944
|
+
(0, import_async16.scheduleTask)(ctx, () => processor.open());
|
|
2942
2945
|
});
|
|
2943
2946
|
}
|
|
2944
2947
|
async writeCredentials({ spaceKey, credentials }) {
|
|
2945
2948
|
var _a;
|
|
2946
|
-
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new
|
|
2949
|
+
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline4.SpaceNotFoundError(spaceKey));
|
|
2947
2950
|
for (const credential of credentials != null ? credentials : []) {
|
|
2948
2951
|
await space.controlPipeline.writer.write({
|
|
2949
2952
|
credential: {
|
|
@@ -2952,6 +2955,24 @@ var SpacesServiceImpl = class {
|
|
|
2952
2955
|
});
|
|
2953
2956
|
}
|
|
2954
2957
|
}
|
|
2958
|
+
_transformSpace(space) {
|
|
2959
|
+
return {
|
|
2960
|
+
spaceKey: space.key,
|
|
2961
|
+
status: space.isOpen ? import_services8.SpaceStatus.ACTIVE : import_services8.SpaceStatus.INACTIVE,
|
|
2962
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
2963
|
+
var _a, _b, _c;
|
|
2964
|
+
return {
|
|
2965
|
+
identity: {
|
|
2966
|
+
identityKey: member.key,
|
|
2967
|
+
profile: {
|
|
2968
|
+
displayName: (_b = (_a = member.assertion.profile) == null ? void 0 : _a.displayName) != null ? _b : (0, import_util6.humanize)(member.key)
|
|
2969
|
+
}
|
|
2970
|
+
},
|
|
2971
|
+
presence: ((_c = this._identityManager.identity) == null ? void 0 : _c.identityKey.equals(member.key)) || space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services8.SpaceMember.PresenceState.ONLINE : import_services8.SpaceMember.PresenceState.OFFLINE
|
|
2972
|
+
};
|
|
2973
|
+
})
|
|
2974
|
+
};
|
|
2975
|
+
}
|
|
2955
2976
|
};
|
|
2956
2977
|
|
|
2957
2978
|
// packages/sdk/client-services/src/packlets/storage/storage.ts
|
|
@@ -2999,12 +3020,128 @@ var toStorageType = (type) => {
|
|
|
2999
3020
|
}
|
|
3000
3021
|
};
|
|
3001
3022
|
|
|
3023
|
+
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
3024
|
+
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
3025
|
+
var SystemServiceImpl = class {
|
|
3026
|
+
constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
3027
|
+
this._config = config;
|
|
3028
|
+
this._statusUpdate = statusUpdate;
|
|
3029
|
+
this._getCurrentStatus = getCurrentStatus;
|
|
3030
|
+
this._onUpdateStatus = onUpdateStatus;
|
|
3031
|
+
this._onReset = onReset;
|
|
3032
|
+
}
|
|
3033
|
+
async getConfig() {
|
|
3034
|
+
return this._config.values;
|
|
3035
|
+
}
|
|
3036
|
+
async updateStatus({ status }) {
|
|
3037
|
+
await this._onUpdateStatus(status);
|
|
3038
|
+
}
|
|
3039
|
+
queryStatus() {
|
|
3040
|
+
return new import_codec_protobuf11.Stream(({ next }) => {
|
|
3041
|
+
const update = () => {
|
|
3042
|
+
next({
|
|
3043
|
+
status: this._getCurrentStatus()
|
|
3044
|
+
});
|
|
3045
|
+
};
|
|
3046
|
+
update();
|
|
3047
|
+
const unsubscribe = this._statusUpdate.on(() => update());
|
|
3048
|
+
const interval = setInterval(update, 3e3);
|
|
3049
|
+
return () => {
|
|
3050
|
+
clearInterval(interval);
|
|
3051
|
+
unsubscribe();
|
|
3052
|
+
};
|
|
3053
|
+
});
|
|
3054
|
+
}
|
|
3055
|
+
async reset() {
|
|
3056
|
+
await this._onReset();
|
|
3057
|
+
}
|
|
3058
|
+
};
|
|
3059
|
+
|
|
3002
3060
|
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
3003
|
-
var
|
|
3061
|
+
var import_async18 = require("@dxos/async");
|
|
3004
3062
|
var import_log12 = require("@dxos/log");
|
|
3005
3063
|
var import_messaging = require("@dxos/messaging");
|
|
3006
3064
|
var import_network_manager3 = require("@dxos/network-manager");
|
|
3065
|
+
var import_rpc3 = require("@dxos/rpc");
|
|
3066
|
+
var import_util7 = require("@dxos/util");
|
|
3067
|
+
|
|
3068
|
+
// packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
|
|
3069
|
+
var import_node_assert11 = __toESM(require("node:assert"));
|
|
3070
|
+
var import_async17 = require("@dxos/async");
|
|
3071
|
+
var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
|
|
3007
3072
|
var import_rpc2 = require("@dxos/rpc");
|
|
3073
|
+
|
|
3074
|
+
// packages/sdk/client-services/src/packlets/vault/services.ts
|
|
3075
|
+
var import_protocols7 = require("@dxos/protocols");
|
|
3076
|
+
var iframeServiceBundle = {
|
|
3077
|
+
IframeService: import_protocols7.schema.getService("dxos.iframe.IframeService"),
|
|
3078
|
+
BridgeService: import_protocols7.schema.getService("dxos.mesh.bridge.BridgeService")
|
|
3079
|
+
};
|
|
3080
|
+
var workerServiceBundle = {
|
|
3081
|
+
WorkerService: import_protocols7.schema.getService("dxos.iframe.WorkerService")
|
|
3082
|
+
};
|
|
3083
|
+
var appServiceBundle = {
|
|
3084
|
+
AppService: import_protocols7.schema.getService("dxos.iframe.AppService")
|
|
3085
|
+
};
|
|
3086
|
+
var shellServiceBundle = {
|
|
3087
|
+
ShellService: import_protocols7.schema.getService("dxos.iframe.ShellService")
|
|
3088
|
+
};
|
|
3089
|
+
|
|
3090
|
+
// packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
|
|
3091
|
+
var ShellRuntimeImpl = class {
|
|
3092
|
+
constructor(_port) {
|
|
3093
|
+
this._port = _port;
|
|
3094
|
+
this.layoutUpdate = new import_async17.Event();
|
|
3095
|
+
this._layout = import_iframe.ShellLayout.DEFAULT;
|
|
3096
|
+
}
|
|
3097
|
+
get layout() {
|
|
3098
|
+
return this._layout;
|
|
3099
|
+
}
|
|
3100
|
+
get invitationCode() {
|
|
3101
|
+
return this._invitationCode;
|
|
3102
|
+
}
|
|
3103
|
+
get spaceKey() {
|
|
3104
|
+
return this._spaceKey;
|
|
3105
|
+
}
|
|
3106
|
+
setLayout(layout, options = {}) {
|
|
3107
|
+
this._layout = layout;
|
|
3108
|
+
this._invitationCode = options.invitationCode;
|
|
3109
|
+
this._spaceKey = options.spaceKey;
|
|
3110
|
+
this.layoutUpdate.emit({
|
|
3111
|
+
layout,
|
|
3112
|
+
...options
|
|
3113
|
+
});
|
|
3114
|
+
}
|
|
3115
|
+
async setAppContext(context) {
|
|
3116
|
+
(0, import_node_assert11.default)(this._appRpc, "runtime not open");
|
|
3117
|
+
await this._appRpc.rpc.AppService.setContext(context);
|
|
3118
|
+
}
|
|
3119
|
+
async open() {
|
|
3120
|
+
this._appRpc = (0, import_rpc2.createProtoRpcPeer)({
|
|
3121
|
+
requested: appServiceBundle,
|
|
3122
|
+
exposed: shellServiceBundle,
|
|
3123
|
+
handlers: {
|
|
3124
|
+
ShellService: {
|
|
3125
|
+
setLayout: async (request) => {
|
|
3126
|
+
this._layout = request.layout;
|
|
3127
|
+
this._invitationCode = request.invitationCode;
|
|
3128
|
+
this._spaceKey = request.spaceKey;
|
|
3129
|
+
this.layoutUpdate.emit(request);
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
3132
|
+
},
|
|
3133
|
+
port: this._port
|
|
3134
|
+
});
|
|
3135
|
+
await this._appRpc.open();
|
|
3136
|
+
}
|
|
3137
|
+
async close() {
|
|
3138
|
+
var _a;
|
|
3139
|
+
await ((_a = this._appRpc) == null ? void 0 : _a.close());
|
|
3140
|
+
this._appRpc = void 0;
|
|
3141
|
+
}
|
|
3142
|
+
};
|
|
3143
|
+
|
|
3144
|
+
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
3008
3145
|
var __decorate3 = function(decorators, target, key, desc) {
|
|
3009
3146
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3010
3147
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -3017,11 +3154,12 @@ var __decorate3 = function(decorators, target, key, desc) {
|
|
|
3017
3154
|
};
|
|
3018
3155
|
var LOCK_KEY = "DXOS_RESOURCE_LOCK";
|
|
3019
3156
|
var IFrameHostRuntime = class {
|
|
3020
|
-
constructor({ configProvider, appPort }) {
|
|
3157
|
+
constructor({ configProvider, appPort, shellPort }) {
|
|
3021
3158
|
this._transportFactory = (0, import_network_manager3.createWebRTCTransportFactory)();
|
|
3022
|
-
this._ready = new
|
|
3159
|
+
this._ready = new import_async18.Trigger();
|
|
3023
3160
|
this._configProvider = configProvider;
|
|
3024
3161
|
this._appPort = appPort;
|
|
3162
|
+
this._shellPort = shellPort;
|
|
3025
3163
|
this._getService = async (find) => {
|
|
3026
3164
|
const error = await this._ready.wait();
|
|
3027
3165
|
if (error) {
|
|
@@ -3033,16 +3171,26 @@ var IFrameHostRuntime = class {
|
|
|
3033
3171
|
}
|
|
3034
3172
|
return service;
|
|
3035
3173
|
};
|
|
3174
|
+
if (this._shellPort) {
|
|
3175
|
+
this._shellRuntime = new ShellRuntimeImpl(this._shellPort);
|
|
3176
|
+
}
|
|
3177
|
+
}
|
|
3178
|
+
get services() {
|
|
3179
|
+
return this._clientServices;
|
|
3180
|
+
}
|
|
3181
|
+
get shell() {
|
|
3182
|
+
return this._shellRuntime;
|
|
3036
3183
|
}
|
|
3037
3184
|
async start() {
|
|
3185
|
+
var _a;
|
|
3038
3186
|
(0, import_log12.log)("starting...", {}, {
|
|
3039
3187
|
file: "iframe-host-runtime.ts",
|
|
3040
|
-
line:
|
|
3188
|
+
line: 81,
|
|
3041
3189
|
scope: this,
|
|
3042
3190
|
callSite: (f, a) => f(...a)
|
|
3043
3191
|
});
|
|
3044
3192
|
try {
|
|
3045
|
-
this._config = await this._configProvider
|
|
3193
|
+
this._config = await (0, import_util7.getAsyncValue)(this._configProvider);
|
|
3046
3194
|
const signalServer = this._config.get("runtime.services.signal.server");
|
|
3047
3195
|
this._clientServices = new ClientServicesHost({
|
|
3048
3196
|
lockKey: LOCK_KEY,
|
|
@@ -3055,17 +3203,16 @@ var IFrameHostRuntime = class {
|
|
|
3055
3203
|
transportFactory: this._transportFactory
|
|
3056
3204
|
})
|
|
3057
3205
|
});
|
|
3058
|
-
this._clientRpc = (0,
|
|
3206
|
+
this._clientRpc = (0, import_rpc3.createProtoRpcPeer)({
|
|
3059
3207
|
exposed: clientServiceBundle,
|
|
3060
3208
|
handlers: {
|
|
3061
3209
|
DataService: async () => await this._getService((services) => services.DataService),
|
|
3210
|
+
DeviceInvitationsService: async () => await this._getService((services) => services.DeviceInvitationsService),
|
|
3062
3211
|
DevicesService: async () => await this._getService((services) => services.DevicesService),
|
|
3063
3212
|
DevtoolsHost: async () => await this._getService((services) => services.DevtoolsHost),
|
|
3064
|
-
HaloInvitationsService: async () => await this._getService((services) => services.HaloInvitationsService),
|
|
3065
3213
|
NetworkService: async () => await this._getService((services) => services.NetworkService),
|
|
3066
|
-
|
|
3214
|
+
IdentityService: async () => await this._getService((services) => services.IdentityService),
|
|
3067
3215
|
SpaceInvitationsService: async () => await this._getService((services) => services.SpaceInvitationsService),
|
|
3068
|
-
SpaceService: async () => await this._getService((services) => services.SpaceService),
|
|
3069
3216
|
SpacesService: async () => await this._getService((services) => services.SpacesService),
|
|
3070
3217
|
SystemService: async () => await this._getService((services) => services.SystemService),
|
|
3071
3218
|
TracingService: async () => await this._getService((services) => services.TracingService)
|
|
@@ -3074,12 +3221,13 @@ var IFrameHostRuntime = class {
|
|
|
3074
3221
|
});
|
|
3075
3222
|
await Promise.all([
|
|
3076
3223
|
this._clientServices.open(),
|
|
3077
|
-
this._clientRpc.open()
|
|
3224
|
+
this._clientRpc.open(),
|
|
3225
|
+
(_a = this._shellRuntime) == null ? void 0 : _a.open()
|
|
3078
3226
|
]);
|
|
3079
3227
|
this._ready.wake(void 0);
|
|
3080
3228
|
(0, import_log12.log)("started", {}, {
|
|
3081
3229
|
file: "iframe-host-runtime.ts",
|
|
3082
|
-
line:
|
|
3230
|
+
line: 116,
|
|
3083
3231
|
scope: this,
|
|
3084
3232
|
callSite: (f, a) => f(...a)
|
|
3085
3233
|
});
|
|
@@ -3087,24 +3235,26 @@ var IFrameHostRuntime = class {
|
|
|
3087
3235
|
this._ready.wake(err);
|
|
3088
3236
|
import_log12.log.catch(err, {}, {
|
|
3089
3237
|
file: "iframe-host-runtime.ts",
|
|
3090
|
-
line:
|
|
3238
|
+
line: 119,
|
|
3091
3239
|
scope: this,
|
|
3092
3240
|
callSite: (f, a) => f(...a)
|
|
3093
3241
|
});
|
|
3094
3242
|
}
|
|
3095
3243
|
}
|
|
3096
3244
|
async stop() {
|
|
3245
|
+
var _a;
|
|
3097
3246
|
(0, import_log12.log)("stopping...", {}, {
|
|
3098
3247
|
file: "iframe-host-runtime.ts",
|
|
3099
|
-
line:
|
|
3248
|
+
line: 124,
|
|
3100
3249
|
scope: this,
|
|
3101
3250
|
callSite: (f, a) => f(...a)
|
|
3102
3251
|
});
|
|
3103
3252
|
await this._clientRpc.close();
|
|
3104
3253
|
await this._clientServices.close();
|
|
3254
|
+
await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
|
|
3105
3255
|
(0, import_log12.log)("stopped", {}, {
|
|
3106
3256
|
file: "iframe-host-runtime.ts",
|
|
3107
|
-
line:
|
|
3257
|
+
line: 128,
|
|
3108
3258
|
scope: this,
|
|
3109
3259
|
callSite: (f, a) => f(...a)
|
|
3110
3260
|
});
|
|
@@ -3116,21 +3266,17 @@ __decorate3([
|
|
|
3116
3266
|
|
|
3117
3267
|
// packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
|
|
3118
3268
|
var import_network_manager4 = require("@dxos/network-manager");
|
|
3119
|
-
var
|
|
3269
|
+
var import_rpc4 = require("@dxos/rpc");
|
|
3120
3270
|
|
|
3121
|
-
// packages/sdk/client-services/src/packlets/vault/
|
|
3122
|
-
var
|
|
3123
|
-
var
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
};
|
|
3127
|
-
var workerServiceBundle = {
|
|
3128
|
-
WorkerService: import_protocols7.schema.getService("dxos.iframe.WorkerService")
|
|
3129
|
-
};
|
|
3271
|
+
// packages/sdk/client-services/src/packlets/vault/shell-controller.ts
|
|
3272
|
+
var import_async19 = require("@dxos/async");
|
|
3273
|
+
var import_log13 = require("@dxos/log");
|
|
3274
|
+
var import_iframe2 = require("@dxos/protocols/proto/dxos/iframe");
|
|
3275
|
+
var import_rpc5 = require("@dxos/rpc");
|
|
3130
3276
|
|
|
3131
3277
|
// packages/sdk/client-services/src/packlets/vault/vault-resource-lock.ts
|
|
3132
|
-
var
|
|
3133
|
-
var
|
|
3278
|
+
var import_async20 = require("@dxos/async");
|
|
3279
|
+
var import_log14 = require("@dxos/log");
|
|
3134
3280
|
var Message;
|
|
3135
3281
|
(function(Message2) {
|
|
3136
3282
|
Message2["ACQUIRING"] = "acquiring";
|
|
@@ -3138,7 +3284,7 @@ var Message;
|
|
|
3138
3284
|
var VaultResourceLock = class {
|
|
3139
3285
|
constructor({ lockKey, onAcquire, onRelease }) {
|
|
3140
3286
|
this._broadcastChannel = new BroadcastChannel("vault-resource-lock");
|
|
3141
|
-
this._releaseTrigger = new
|
|
3287
|
+
this._releaseTrigger = new import_async20.Trigger();
|
|
3142
3288
|
this._lockKey = lockKey;
|
|
3143
3289
|
this._onAcquire = onAcquire;
|
|
3144
3290
|
this._onRelease = onRelease;
|
|
@@ -3149,7 +3295,7 @@ var VaultResourceLock = class {
|
|
|
3149
3295
|
message: Message.ACQUIRING
|
|
3150
3296
|
});
|
|
3151
3297
|
try {
|
|
3152
|
-
await (0,
|
|
3298
|
+
await (0, import_async20.asyncTimeout)(this._requestLock(), 3e3);
|
|
3153
3299
|
} catch (e) {
|
|
3154
3300
|
await this._requestLock(true);
|
|
3155
3301
|
}
|
|
@@ -3163,7 +3309,7 @@ var VaultResourceLock = class {
|
|
|
3163
3309
|
}
|
|
3164
3310
|
}
|
|
3165
3311
|
async _requestLock(steal = false) {
|
|
3166
|
-
(0,
|
|
3312
|
+
(0, import_log14.log)("requesting lock...", {
|
|
3167
3313
|
steal
|
|
3168
3314
|
}, {
|
|
3169
3315
|
file: "vault-resource-lock.ts",
|
|
@@ -3171,23 +3317,23 @@ var VaultResourceLock = class {
|
|
|
3171
3317
|
scope: this,
|
|
3172
3318
|
callSite: (f, a) => f(...a)
|
|
3173
3319
|
});
|
|
3174
|
-
const acquired = new
|
|
3320
|
+
const acquired = new import_async20.Trigger();
|
|
3175
3321
|
void navigator.locks.request(this._lockKey, {
|
|
3176
3322
|
steal
|
|
3177
3323
|
}, async () => {
|
|
3178
3324
|
var _a, _b;
|
|
3179
3325
|
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
3180
3326
|
acquired.wake();
|
|
3181
|
-
this._releaseTrigger = new
|
|
3327
|
+
this._releaseTrigger = new import_async20.Trigger();
|
|
3182
3328
|
await this._releaseTrigger.wait();
|
|
3183
|
-
(0,
|
|
3329
|
+
(0, import_log14.log)("releasing lock...", {}, {
|
|
3184
3330
|
file: "vault-resource-lock.ts",
|
|
3185
3331
|
line: 65,
|
|
3186
3332
|
scope: this,
|
|
3187
3333
|
callSite: (f, a) => f(...a)
|
|
3188
3334
|
});
|
|
3189
3335
|
await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
|
|
3190
|
-
(0,
|
|
3336
|
+
(0, import_log14.log)("released lock", {}, {
|
|
3191
3337
|
file: "vault-resource-lock.ts",
|
|
3192
3338
|
line: 67,
|
|
3193
3339
|
scope: this,
|
|
@@ -3198,7 +3344,7 @@ var VaultResourceLock = class {
|
|
|
3198
3344
|
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
3199
3345
|
});
|
|
3200
3346
|
await acquired.wait();
|
|
3201
|
-
(0,
|
|
3347
|
+
(0, import_log14.log)("recieved lock", {
|
|
3202
3348
|
steal
|
|
3203
3349
|
}, {
|
|
3204
3350
|
file: "vault-resource-lock.ts",
|
|
@@ -3210,17 +3356,17 @@ var VaultResourceLock = class {
|
|
|
3210
3356
|
};
|
|
3211
3357
|
|
|
3212
3358
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
3213
|
-
var
|
|
3214
|
-
var
|
|
3359
|
+
var import_async22 = require("@dxos/async");
|
|
3360
|
+
var import_log16 = require("@dxos/log");
|
|
3215
3361
|
var import_messaging2 = require("@dxos/messaging");
|
|
3216
3362
|
var import_network_manager5 = require("@dxos/network-manager");
|
|
3217
3363
|
|
|
3218
3364
|
// packages/sdk/client-services/src/packlets/vault/worker-session.ts
|
|
3219
|
-
var
|
|
3220
|
-
var
|
|
3221
|
-
var
|
|
3222
|
-
var
|
|
3223
|
-
var
|
|
3365
|
+
var import_node_assert12 = __toESM(require("node:assert"));
|
|
3366
|
+
var import_async21 = require("@dxos/async");
|
|
3367
|
+
var import_log15 = require("@dxos/log");
|
|
3368
|
+
var import_rpc6 = require("@dxos/rpc");
|
|
3369
|
+
var import_util8 = require("@dxos/util");
|
|
3224
3370
|
var __decorate4 = function(decorators, target, key, desc) {
|
|
3225
3371
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3226
3372
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -3232,33 +3378,38 @@ var __decorate4 = function(decorators, target, key, desc) {
|
|
|
3232
3378
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3233
3379
|
};
|
|
3234
3380
|
var WorkerSession = class {
|
|
3235
|
-
constructor({ getService, systemPort, appPort, options = {
|
|
3381
|
+
constructor({ getService, systemPort, appPort, shellPort, options = {
|
|
3236
3382
|
heartbeatInterval: 1e3
|
|
3237
3383
|
} }) {
|
|
3238
|
-
this._startTrigger = new
|
|
3239
|
-
this.onClose = new
|
|
3240
|
-
(0,
|
|
3241
|
-
(0,
|
|
3384
|
+
this._startTrigger = new import_async21.Trigger();
|
|
3385
|
+
this.onClose = new import_util8.Callback();
|
|
3386
|
+
(0, import_node_assert12.default)(options);
|
|
3387
|
+
(0, import_node_assert12.default)(getService);
|
|
3242
3388
|
this._options = options;
|
|
3243
3389
|
this._getService = getService;
|
|
3244
|
-
|
|
3390
|
+
const handlers = {
|
|
3391
|
+
DataService: () => this._getService((services) => services.DataService),
|
|
3392
|
+
DeviceInvitationsService: () => this._getService((services) => services.DeviceInvitationsService),
|
|
3393
|
+
DevicesService: () => this._getService((services) => services.DevicesService),
|
|
3394
|
+
DevtoolsHost: () => this._getService((services) => services.DevtoolsHost),
|
|
3395
|
+
NetworkService: () => this._getService((services) => services.NetworkService),
|
|
3396
|
+
IdentityService: () => this._getService((services) => services.IdentityService),
|
|
3397
|
+
SpaceInvitationsService: () => this._getService((services) => services.SpaceInvitationsService),
|
|
3398
|
+
SpacesService: () => this._getService((services) => services.SpacesService),
|
|
3399
|
+
SystemService: () => this._getService((services) => services.SystemService),
|
|
3400
|
+
TracingService: () => this._getService((services) => services.TracingService)
|
|
3401
|
+
};
|
|
3402
|
+
this._clientRpc = (0, import_rpc6.createProtoRpcPeer)({
|
|
3245
3403
|
exposed: clientServiceBundle,
|
|
3246
|
-
handlers
|
|
3247
|
-
DataService: async () => await this._getService((services) => services.DataService),
|
|
3248
|
-
DevicesService: async () => await this._getService((services) => services.DevicesService),
|
|
3249
|
-
DevtoolsHost: async () => await this._getService((services) => services.DevtoolsHost),
|
|
3250
|
-
HaloInvitationsService: async () => await this._getService((services) => services.HaloInvitationsService),
|
|
3251
|
-
NetworkService: async () => await this._getService((services) => services.NetworkService),
|
|
3252
|
-
ProfileService: async () => await this._getService((services) => services.ProfileService),
|
|
3253
|
-
SpaceInvitationsService: async () => await this._getService((services) => services.SpaceInvitationsService),
|
|
3254
|
-
SpaceService: async () => await this._getService((services) => services.SpaceService),
|
|
3255
|
-
SpacesService: async () => await this._getService((services) => services.SpacesService),
|
|
3256
|
-
SystemService: async () => await this._getService((services) => services.SystemService),
|
|
3257
|
-
TracingService: async () => await this._getService((services) => services.TracingService)
|
|
3258
|
-
},
|
|
3404
|
+
handlers,
|
|
3259
3405
|
port: appPort
|
|
3260
3406
|
});
|
|
3261
|
-
this.
|
|
3407
|
+
this._shellClientRpc = (0, import_rpc6.createProtoRpcPeer)({
|
|
3408
|
+
exposed: clientServiceBundle,
|
|
3409
|
+
handlers,
|
|
3410
|
+
port: shellPort
|
|
3411
|
+
});
|
|
3412
|
+
this._iframeRpc = (0, import_rpc6.createProtoRpcPeer)({
|
|
3262
3413
|
requested: iframeServiceBundle,
|
|
3263
3414
|
exposed: workerServiceBundle,
|
|
3264
3415
|
handlers: {
|
|
@@ -3272,9 +3423,9 @@ var WorkerSession = class {
|
|
|
3272
3423
|
try {
|
|
3273
3424
|
await this.close();
|
|
3274
3425
|
} catch (err) {
|
|
3275
|
-
|
|
3426
|
+
import_log15.log.catch(err, {}, {
|
|
3276
3427
|
file: "worker-session.ts",
|
|
3277
|
-
line:
|
|
3428
|
+
line: 91,
|
|
3278
3429
|
scope: this,
|
|
3279
3430
|
callSite: (f, a) => f(...a)
|
|
3280
3431
|
});
|
|
@@ -3290,15 +3441,16 @@ var WorkerSession = class {
|
|
|
3290
3441
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
3291
3442
|
}
|
|
3292
3443
|
async open() {
|
|
3293
|
-
|
|
3444
|
+
import_log15.log.info("opening..", {}, {
|
|
3294
3445
|
file: "worker-session.ts",
|
|
3295
|
-
line:
|
|
3446
|
+
line: 105,
|
|
3296
3447
|
scope: this,
|
|
3297
3448
|
callSite: (f, a) => f(...a)
|
|
3298
3449
|
});
|
|
3299
3450
|
await Promise.all([
|
|
3300
3451
|
this._clientRpc.open(),
|
|
3301
|
-
this._iframeRpc.open()
|
|
3452
|
+
this._iframeRpc.open(),
|
|
3453
|
+
this._maybeOpenShell()
|
|
3302
3454
|
]);
|
|
3303
3455
|
await this._startTrigger.wait({
|
|
3304
3456
|
timeout: 3e3
|
|
@@ -3307,20 +3459,20 @@ var WorkerSession = class {
|
|
|
3307
3459
|
try {
|
|
3308
3460
|
await this._iframeRpc.rpc.IframeService.heartbeat();
|
|
3309
3461
|
} catch (err1) {
|
|
3310
|
-
|
|
3462
|
+
import_log15.log.warn("Heartbeat failed", {
|
|
3311
3463
|
err: err1
|
|
3312
3464
|
}, {
|
|
3313
3465
|
file: "worker-session.ts",
|
|
3314
|
-
line:
|
|
3466
|
+
line: 117,
|
|
3315
3467
|
scope: this,
|
|
3316
3468
|
callSite: (f, a) => f(...a)
|
|
3317
3469
|
});
|
|
3318
3470
|
try {
|
|
3319
3471
|
await this.close();
|
|
3320
3472
|
} catch (err) {
|
|
3321
|
-
|
|
3473
|
+
import_log15.log.catch(err, {}, {
|
|
3322
3474
|
file: "worker-session.ts",
|
|
3323
|
-
line:
|
|
3475
|
+
line: 121,
|
|
3324
3476
|
scope: this,
|
|
3325
3477
|
callSite: (f, a) => f(...a)
|
|
3326
3478
|
});
|
|
@@ -3329,18 +3481,18 @@ var WorkerSession = class {
|
|
|
3329
3481
|
}, this._options.heartbeatInterval);
|
|
3330
3482
|
}
|
|
3331
3483
|
async close() {
|
|
3332
|
-
|
|
3484
|
+
import_log15.log.info("closing..", {}, {
|
|
3333
3485
|
file: "worker-session.ts",
|
|
3334
|
-
line:
|
|
3486
|
+
line: 128,
|
|
3335
3487
|
scope: this,
|
|
3336
3488
|
callSite: (f, a) => f(...a)
|
|
3337
3489
|
});
|
|
3338
3490
|
try {
|
|
3339
3491
|
await this.onClose.callIfSet();
|
|
3340
3492
|
} catch (err) {
|
|
3341
|
-
|
|
3493
|
+
import_log15.log.catch(err, {}, {
|
|
3342
3494
|
file: "worker-session.ts",
|
|
3343
|
-
line:
|
|
3495
|
+
line: 132,
|
|
3344
3496
|
scope: this,
|
|
3345
3497
|
callSite: (f, a) => f(...a)
|
|
3346
3498
|
});
|
|
@@ -3353,9 +3505,21 @@ var WorkerSession = class {
|
|
|
3353
3505
|
this._iframeRpc.close()
|
|
3354
3506
|
]);
|
|
3355
3507
|
}
|
|
3508
|
+
async _maybeOpenShell() {
|
|
3509
|
+
try {
|
|
3510
|
+
await (0, import_async21.asyncTimeout)(this._shellClientRpc.open(), 1e3);
|
|
3511
|
+
} catch (e) {
|
|
3512
|
+
import_log15.log.info("No shell connected.", {}, {
|
|
3513
|
+
file: "worker-session.ts",
|
|
3514
|
+
line: 146,
|
|
3515
|
+
scope: this,
|
|
3516
|
+
callSite: (f, a) => f(...a)
|
|
3517
|
+
});
|
|
3518
|
+
}
|
|
3519
|
+
}
|
|
3356
3520
|
};
|
|
3357
3521
|
__decorate4([
|
|
3358
|
-
|
|
3522
|
+
import_log15.logInfo
|
|
3359
3523
|
], WorkerSession.prototype, "origin", void 0);
|
|
3360
3524
|
|
|
3361
3525
|
// packages/sdk/client-services/src/packlets/services/service-registry.ts
|
|
@@ -3387,8 +3551,10 @@ var ClientServicesHost = class {
|
|
|
3387
3551
|
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
3388
3552
|
networkManager,
|
|
3389
3553
|
storage = createStorageObjects(config.get("runtime.client.storage", {})).storage,
|
|
3554
|
+
// TODO(wittjosiah): Turn this on by default.
|
|
3390
3555
|
lockKey
|
|
3391
3556
|
}) {
|
|
3557
|
+
this._statusUpdate = new import_async23.Event();
|
|
3392
3558
|
this._open = false;
|
|
3393
3559
|
this._config = config;
|
|
3394
3560
|
this._modelFactory = modelFactory;
|
|
@@ -3401,23 +3567,19 @@ var ClientServicesHost = class {
|
|
|
3401
3567
|
}) : void 0;
|
|
3402
3568
|
this._systemService = new SystemServiceImpl({
|
|
3403
3569
|
config: this._config,
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
};
|
|
3570
|
+
statusUpdate: this._statusUpdate,
|
|
3571
|
+
getCurrentStatus: () => this.isOpen ? import_services16.SystemStatus.ACTIVE : import_services16.SystemStatus.INACTIVE,
|
|
3572
|
+
onUpdateStatus: async (status) => {
|
|
3573
|
+
var _a, _b;
|
|
3574
|
+
if (!this.isOpen && status === import_services16.SystemStatus.ACTIVE) {
|
|
3575
|
+
await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
|
|
3576
|
+
} else if (this.isOpen && status === import_services16.SystemStatus.INACTIVE) {
|
|
3577
|
+
await ((_b = this._resourceLock) == null ? void 0 : _b.release());
|
|
3413
3578
|
}
|
|
3414
|
-
return {
|
|
3415
|
-
status: import_client2.Status.ACTIVE
|
|
3416
|
-
};
|
|
3417
3579
|
},
|
|
3418
3580
|
onReset: async () => {
|
|
3419
|
-
|
|
3420
|
-
await
|
|
3581
|
+
(0, import_node_assert13.default)(this._serviceContext, "service host is closed");
|
|
3582
|
+
await this._serviceContext.reset();
|
|
3421
3583
|
}
|
|
3422
3584
|
});
|
|
3423
3585
|
this._serviceRegistry = new ServiceRegistry(clientServiceBundle, {
|
|
@@ -3434,22 +3596,23 @@ var ClientServicesHost = class {
|
|
|
3434
3596
|
return this._serviceRegistry.services;
|
|
3435
3597
|
}
|
|
3436
3598
|
async open() {
|
|
3437
|
-
var _a;
|
|
3599
|
+
var _a, _b;
|
|
3438
3600
|
if (this._open) {
|
|
3439
3601
|
return;
|
|
3440
3602
|
}
|
|
3441
|
-
(0,
|
|
3603
|
+
(0, import_log17.log)("opening...", {}, {
|
|
3442
3604
|
file: "service-host.ts",
|
|
3443
|
-
line:
|
|
3605
|
+
line: 133,
|
|
3444
3606
|
scope: this,
|
|
3445
3607
|
callSite: (f, a) => f(...a)
|
|
3446
3608
|
});
|
|
3609
|
+
await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
|
|
3447
3610
|
this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._modelFactory);
|
|
3448
3611
|
this._serviceRegistry.setServices({
|
|
3449
|
-
// TODO(burdon): Move to new protobuf definitions.
|
|
3450
3612
|
SystemService: this._systemService,
|
|
3451
|
-
|
|
3613
|
+
IdentityService: new IdentityServiceImpl(this._serviceContext),
|
|
3452
3614
|
DevicesService: new DevicesServiceImpl(this._serviceContext.identityManager),
|
|
3615
|
+
DeviceInvitationsService: new DeviceInvitationsServiceImpl(this._serviceContext.identityManager, this._serviceContext.deviceInvitations),
|
|
3453
3616
|
SpaceInvitationsService: new SpaceInvitationsServiceImpl(this._serviceContext.identityManager, () => {
|
|
3454
3617
|
var _a2;
|
|
3455
3618
|
return (_a2 = this._serviceContext.spaceInvitations) != null ? _a2 : (0, import_debug7.raise)(new Error("SpaceInvitations not initialized"));
|
|
@@ -3457,13 +3620,13 @@ var ClientServicesHost = class {
|
|
|
3457
3620
|
var _a2;
|
|
3458
3621
|
return (_a2 = this._serviceContext.dataSpaceManager) != null ? _a2 : (0, import_debug7.raise)(new Error("SpaceManager not initialized"));
|
|
3459
3622
|
}),
|
|
3460
|
-
SpacesService: new SpacesServiceImpl(this._serviceContext.spaceManager)
|
|
3461
|
-
|
|
3623
|
+
SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, this._serviceContext.dataServiceSubscriptions, async () => {
|
|
3624
|
+
await this._serviceContext.initialized.wait();
|
|
3625
|
+
return this._serviceContext.dataSpaceManager;
|
|
3626
|
+
}),
|
|
3627
|
+
DataService: new import_echo_pipeline5.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
|
|
3462
3628
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager),
|
|
3463
3629
|
// TODO(burdon): Move to new protobuf definitions.
|
|
3464
|
-
ProfileService: new ProfileServiceImpl(this._serviceContext),
|
|
3465
|
-
// TODO(burdon): Port old SubscribeSpaces to QueryServices>
|
|
3466
|
-
SpaceService: new SpaceServiceImpl(this._serviceContext),
|
|
3467
3630
|
TracingService: new TracingServiceImpl(this._config),
|
|
3468
3631
|
DevtoolsHost: new DevtoolsServiceImpl({
|
|
3469
3632
|
events: new DevtoolsHostEvents(),
|
|
@@ -3473,12 +3636,13 @@ var ClientServicesHost = class {
|
|
|
3473
3636
|
});
|
|
3474
3637
|
await this._serviceContext.open();
|
|
3475
3638
|
this._open = true;
|
|
3476
|
-
|
|
3477
|
-
(
|
|
3639
|
+
this._statusUpdate.emit();
|
|
3640
|
+
const deviceKey = (_b = this._serviceContext.identityManager.identity) == null ? void 0 : _b.deviceKey;
|
|
3641
|
+
(0, import_log17.log)("opened", {
|
|
3478
3642
|
deviceKey
|
|
3479
3643
|
}, {
|
|
3480
3644
|
file: "service-host.ts",
|
|
3481
|
-
line:
|
|
3645
|
+
line: 186,
|
|
3482
3646
|
scope: this,
|
|
3483
3647
|
callSite: (f, a) => f(...a)
|
|
3484
3648
|
});
|
|
@@ -3489,11 +3653,11 @@ var ClientServicesHost = class {
|
|
|
3489
3653
|
return;
|
|
3490
3654
|
}
|
|
3491
3655
|
const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
|
|
3492
|
-
(0,
|
|
3656
|
+
(0, import_log17.log)("closing...", {
|
|
3493
3657
|
deviceKey
|
|
3494
3658
|
}, {
|
|
3495
3659
|
file: "service-host.ts",
|
|
3496
|
-
line:
|
|
3660
|
+
line: 195,
|
|
3497
3661
|
scope: this,
|
|
3498
3662
|
callSite: (f, a) => f(...a)
|
|
3499
3663
|
});
|
|
@@ -3502,11 +3666,12 @@ var ClientServicesHost = class {
|
|
|
3502
3666
|
});
|
|
3503
3667
|
await this._serviceContext.close();
|
|
3504
3668
|
this._open = false;
|
|
3505
|
-
(
|
|
3669
|
+
this._statusUpdate.emit();
|
|
3670
|
+
(0, import_log17.log)("closed", {
|
|
3506
3671
|
deviceKey
|
|
3507
3672
|
}, {
|
|
3508
3673
|
file: "service-host.ts",
|
|
3509
|
-
line:
|
|
3674
|
+
line: 200,
|
|
3510
3675
|
scope: this,
|
|
3511
3676
|
callSite: (f, a) => f(...a)
|
|
3512
3677
|
});
|
|
@@ -3514,9 +3679,9 @@ var ClientServicesHost = class {
|
|
|
3514
3679
|
};
|
|
3515
3680
|
|
|
3516
3681
|
// packages/sdk/client-services/src/packlets/services/service-proxy.ts
|
|
3517
|
-
var
|
|
3682
|
+
var import_async24 = require("@dxos/async");
|
|
3518
3683
|
var import_errors2 = require("@dxos/errors");
|
|
3519
|
-
var
|
|
3684
|
+
var import_rpc7 = require("@dxos/rpc");
|
|
3520
3685
|
|
|
3521
3686
|
// packages/sdk/client-services/src/packlets/testing/test-builder.ts
|
|
3522
3687
|
var createServiceHost = (config, signalManagerContext) => {
|
|
@@ -3587,18 +3752,18 @@ var TestPeer = class {
|
|
|
3587
3752
|
root: this.storage.createDirectory("feeds"),
|
|
3588
3753
|
signer: this.keyring,
|
|
3589
3754
|
hypercore: {
|
|
3590
|
-
valueEncoding:
|
|
3755
|
+
valueEncoding: import_echo_pipeline6.valueEncoding
|
|
3591
3756
|
}
|
|
3592
3757
|
})
|
|
3593
3758
|
});
|
|
3594
3759
|
}
|
|
3595
3760
|
get metadataStore() {
|
|
3596
3761
|
var _a, _b;
|
|
3597
|
-
return (_b = (_a = this._props).metadataStore) != null ? _b : _a.metadataStore = new
|
|
3762
|
+
return (_b = (_a = this._props).metadataStore) != null ? _b : _a.metadataStore = new import_echo_pipeline6.MetadataStore(this.storage.createDirectory("metadata"));
|
|
3598
3763
|
}
|
|
3599
3764
|
get snapshotStore() {
|
|
3600
3765
|
var _a, _b;
|
|
3601
|
-
return (_b = (_a = this._props).snapshotStore) != null ? _b : _a.snapshotStore = new
|
|
3766
|
+
return (_b = (_a = this._props).snapshotStore) != null ? _b : _a.snapshotStore = new import_echo_pipeline6.SnapshotStore(this.storage.createDirectory("snapshots"));
|
|
3602
3767
|
}
|
|
3603
3768
|
get networkManager() {
|
|
3604
3769
|
var _a, _b;
|
|
@@ -3609,7 +3774,7 @@ var TestPeer = class {
|
|
|
3609
3774
|
}
|
|
3610
3775
|
get spaceManager() {
|
|
3611
3776
|
var _a, _b;
|
|
3612
|
-
return (_b = (_a = this._props).spaceManager) != null ? _b : _a.spaceManager = new
|
|
3777
|
+
return (_b = (_a = this._props).spaceManager) != null ? _b : _a.spaceManager = new import_echo_pipeline6.SpaceManager({
|
|
3613
3778
|
feedStore: this.feedStore,
|
|
3614
3779
|
networkManager: this.networkManager
|
|
3615
3780
|
});
|
|
@@ -3629,49 +3794,6 @@ var createSigningContext = async (keyring) => {
|
|
|
3629
3794
|
// No-op.
|
|
3630
3795
|
};
|
|
3631
3796
|
};
|
|
3632
|
-
|
|
3633
|
-
// packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
|
|
3634
|
-
var import_node_assert12 = __toESM(require("node:assert"));
|
|
3635
|
-
var import_async21 = require("@dxos/async");
|
|
3636
|
-
var import_debug8 = require("@dxos/debug");
|
|
3637
|
-
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3638
|
-
var performInvitation = async (host, guest, context) => {
|
|
3639
|
-
const done1 = new import_async21.Trigger();
|
|
3640
|
-
const done2 = new import_async21.Trigger();
|
|
3641
|
-
const observable1 = await host.createInvitation(context, {
|
|
3642
|
-
type: import_services12.Invitation.Type.INTERACTIVE_TESTING
|
|
3643
|
-
});
|
|
3644
|
-
observable1.subscribe({
|
|
3645
|
-
onConnecting: async (invitation1) => {
|
|
3646
|
-
const observable2 = await guest.acceptInvitation(invitation1, {
|
|
3647
|
-
type: import_services12.Invitation.Type.INTERACTIVE_TESTING
|
|
3648
|
-
});
|
|
3649
|
-
observable2.subscribe({
|
|
3650
|
-
onConnecting: async (invitation2) => {
|
|
3651
|
-
(0, import_node_assert12.default)(invitation1.swarmKey.equals(invitation2.swarmKey));
|
|
3652
|
-
},
|
|
3653
|
-
onConnected: async (invitation2) => {
|
|
3654
|
-
},
|
|
3655
|
-
onSuccess: (invitation) => {
|
|
3656
|
-
done2.wake(invitation);
|
|
3657
|
-
},
|
|
3658
|
-
onCancelled: () => (0, import_debug8.raise)(new Error()),
|
|
3659
|
-
onTimeout: (err) => (0, import_debug8.raise)(err),
|
|
3660
|
-
onError: (err) => (0, import_debug8.raise)(err)
|
|
3661
|
-
});
|
|
3662
|
-
},
|
|
3663
|
-
onConnected: async (invitation1) => {
|
|
3664
|
-
},
|
|
3665
|
-
onCancelled: () => (0, import_debug8.raise)(new Error("cancelled")),
|
|
3666
|
-
onSuccess: (invitation) => {
|
|
3667
|
-
done1.wake(invitation);
|
|
3668
|
-
},
|
|
3669
|
-
onTimeout: (err) => (0, import_debug8.raise)(err),
|
|
3670
|
-
onError: (err) => (0, import_debug8.raise)(err)
|
|
3671
|
-
});
|
|
3672
|
-
await done1.wait();
|
|
3673
|
-
await done2.wait();
|
|
3674
|
-
};
|
|
3675
3797
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3676
3798
|
0 && (module.exports = {
|
|
3677
3799
|
TestBuilder,
|