@dxos/client-services 0.1.52 → 0.1.53-main.00be1a9
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-C3SPTMW3.mjs → chunk-RKD47ENR.mjs} +678 -638
- package/dist/lib/browser/chunk-RKD47ENR.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +94 -119
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +6 -6
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +739 -726
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +650 -612
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/devtools/devtools.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.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +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 +1 -1
- 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 +1 -1
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/shell-runtime.d.ts +1 -21
- package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +1 -1
- package/package.json +33 -32
- package/src/packlets/devtools/devtools.ts +2 -2
- package/src/packlets/identity/identity-manager.test.ts +1 -1
- package/src/packlets/identity/identity-manager.ts +8 -8
- package/src/packlets/identity/identity-service.ts +2 -2
- package/src/packlets/identity/identity.test.ts +1 -1
- package/src/packlets/identity/identity.ts +2 -2
- package/src/packlets/invitations/device-invitation-protocol.ts +4 -4
- package/src/packlets/invitations/invitation-extension.ts +5 -5
- package/src/packlets/invitations/invitations-handler.ts +6 -6
- package/src/packlets/invitations/invitations-service.ts +3 -3
- package/src/packlets/invitations/space-invitation-protocol.ts +9 -9
- package/src/packlets/locks/node.ts +2 -2
- package/src/packlets/logging/logging-service.ts +4 -4
- package/src/packlets/services/service-context.test.ts +1 -1
- package/src/packlets/services/service-context.ts +3 -3
- package/src/packlets/services/service-host.ts +19 -10
- package/src/packlets/spaces/data-space-manager.ts +5 -6
- package/src/packlets/spaces/notarization-plugin.ts +4 -4
- package/src/packlets/spaces/spaces-service.ts +20 -24
- package/src/packlets/testing/invitation-utils.ts +2 -2
- package/src/packlets/testing/test-builder.ts +1 -2
- package/src/packlets/vault/iframe-host-runtime.ts +2 -2
- package/src/packlets/vault/iframe-proxy-runtime.ts +2 -2
- package/src/packlets/vault/shell-runtime.ts +3 -49
- package/src/packlets/vault/worker-session.ts +2 -2
- package/dist/lib/browser/chunk-C3SPTMW3.mjs.map +0 -7
|
@@ -61,12 +61,12 @@ var createMockCredential = async ({ signer, issuer }) => (0, import_credentials.
|
|
|
61
61
|
});
|
|
62
62
|
|
|
63
63
|
// packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
|
|
64
|
-
var
|
|
64
|
+
var import_tiny_invariant14 = __toESM(require("tiny-invariant"));
|
|
65
65
|
var import_async18 = require("@dxos/async");
|
|
66
66
|
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
67
67
|
|
|
68
68
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
69
|
-
var
|
|
69
|
+
var import_tiny_invariant11 = __toESM(require("tiny-invariant"));
|
|
70
70
|
var import_async11 = require("@dxos/async");
|
|
71
71
|
var import_credentials14 = require("@dxos/credentials");
|
|
72
72
|
var import_debug6 = require("@dxos/debug");
|
|
@@ -85,6 +85,7 @@ var import_context = require("@dxos/context");
|
|
|
85
85
|
var import_credentials2 = require("@dxos/credentials");
|
|
86
86
|
var import_log = require("@dxos/log");
|
|
87
87
|
var import_protocols = require("@dxos/protocols");
|
|
88
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
|
|
88
89
|
var createAuthProvider = (signer) => async (nonce) => {
|
|
89
90
|
const credential = await signer.createCredential({
|
|
90
91
|
assertion: {
|
|
@@ -110,20 +111,20 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
110
111
|
(0, import_log.log)("authenticating...", {
|
|
111
112
|
credential
|
|
112
113
|
}, {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
F: __dxlog_file,
|
|
115
|
+
L: 57,
|
|
116
|
+
S: this,
|
|
117
|
+
C: (f, a) => f(...a)
|
|
117
118
|
});
|
|
118
119
|
const result = await (0, import_credentials2.verifyCredential)(credential);
|
|
119
120
|
if (result.kind === "fail") {
|
|
120
121
|
(0, import_log.log)("Invalid credential", {
|
|
121
122
|
result
|
|
122
123
|
}, {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
F: __dxlog_file,
|
|
125
|
+
L: 61,
|
|
126
|
+
S: this,
|
|
127
|
+
C: (f, a) => f(...a)
|
|
127
128
|
});
|
|
128
129
|
return false;
|
|
129
130
|
}
|
|
@@ -132,10 +133,10 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
132
133
|
nonce,
|
|
133
134
|
credential
|
|
134
135
|
}, {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
F: __dxlog_file,
|
|
137
|
+
L: 66,
|
|
138
|
+
S: this,
|
|
139
|
+
C: (f, a) => f(...a)
|
|
139
140
|
});
|
|
140
141
|
return false;
|
|
141
142
|
}
|
|
@@ -143,10 +144,10 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
143
144
|
(0, import_log.log)("key is not currently in trusted set, waiting...", {
|
|
144
145
|
key: credential.issuer
|
|
145
146
|
}, {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
F: __dxlog_file,
|
|
148
|
+
L: 71,
|
|
149
|
+
S: this,
|
|
150
|
+
C: (f, a) => f(...a)
|
|
150
151
|
});
|
|
151
152
|
return true;
|
|
152
153
|
}
|
|
@@ -159,20 +160,20 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
159
160
|
(0, import_log.log)("auth success", {
|
|
160
161
|
key: credential.issuer
|
|
161
162
|
}, {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
F: __dxlog_file,
|
|
164
|
+
L: 82,
|
|
165
|
+
S: this,
|
|
166
|
+
C: (f, a) => f(...a)
|
|
166
167
|
});
|
|
167
168
|
trigger.wake(true);
|
|
168
169
|
} else {
|
|
169
170
|
(0, import_log.log)("key is not currently in trusted set, waiting...", {
|
|
170
171
|
key: credential.issuer
|
|
171
172
|
}, {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
173
|
+
F: __dxlog_file,
|
|
174
|
+
L: 85,
|
|
175
|
+
S: this,
|
|
176
|
+
C: (f, a) => f(...a)
|
|
176
177
|
});
|
|
177
178
|
}
|
|
178
179
|
});
|
|
@@ -194,7 +195,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
194
195
|
};
|
|
195
196
|
|
|
196
197
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
197
|
-
var
|
|
198
|
+
var import_tiny_invariant = __toESM(require("tiny-invariant"));
|
|
198
199
|
var import_async2 = require("@dxos/async");
|
|
199
200
|
var import_client_protocol = require("@dxos/client-protocol");
|
|
200
201
|
var import_credentials3 = require("@dxos/credentials");
|
|
@@ -202,6 +203,7 @@ var import_debug = require("@dxos/debug");
|
|
|
202
203
|
var import_feed_store = require("@dxos/feed-store");
|
|
203
204
|
var import_log2 = require("@dxos/log");
|
|
204
205
|
var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
206
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
205
207
|
var Identity = class {
|
|
206
208
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
207
209
|
this.stateUpdate = new import_async2.Event();
|
|
@@ -276,7 +278,7 @@ var Identity = class {
|
|
|
276
278
|
* Requires identity to be ready.
|
|
277
279
|
*/
|
|
278
280
|
getIdentityCredentialSigner() {
|
|
279
|
-
(0,
|
|
281
|
+
(0, import_tiny_invariant.default)(this._deviceStateMachine.processor.deviceCredentialChain, "Device credential chain is not ready.");
|
|
280
282
|
return (0, import_credentials3.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.processor.deviceCredentialChain, this.deviceKey);
|
|
281
283
|
}
|
|
282
284
|
/**
|
|
@@ -293,10 +295,10 @@ var Identity = class {
|
|
|
293
295
|
controlFeedKey,
|
|
294
296
|
dataFeedKey
|
|
295
297
|
}, {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
298
|
+
F: __dxlog_file2,
|
|
299
|
+
L: 156,
|
|
300
|
+
S: this,
|
|
301
|
+
C: (f, a) => f(...a)
|
|
300
302
|
});
|
|
301
303
|
const signer = this.getIdentityCredentialSigner();
|
|
302
304
|
await (0, import_feed_store.writeMessages)(this.controlPipeline.writer, [
|
|
@@ -337,7 +339,7 @@ var Identity = class {
|
|
|
337
339
|
};
|
|
338
340
|
|
|
339
341
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
340
|
-
var
|
|
342
|
+
var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
|
|
341
343
|
var import_async3 = require("@dxos/async");
|
|
342
344
|
var import_credentials5 = require("@dxos/credentials");
|
|
343
345
|
var import_keys2 = require("@dxos/keys");
|
|
@@ -345,6 +347,7 @@ var import_log3 = require("@dxos/log");
|
|
|
345
347
|
var import_protocols2 = require("@dxos/protocols");
|
|
346
348
|
var import_credentials6 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
347
349
|
var import_util = require("@dxos/util");
|
|
350
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
348
351
|
var IdentityManager = class {
|
|
349
352
|
// TODO(burdon): IdentityManagerParams.
|
|
350
353
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
@@ -364,20 +367,20 @@ var IdentityManager = class {
|
|
|
364
367
|
import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.begin({
|
|
365
368
|
id: traceId
|
|
366
369
|
}), {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
370
|
+
F: __dxlog_file3,
|
|
371
|
+
L: 70,
|
|
372
|
+
S: this,
|
|
373
|
+
C: (f, a) => f(...a)
|
|
371
374
|
});
|
|
372
375
|
await this._metadataStore.load();
|
|
373
376
|
const identityRecord = this._metadataStore.getIdentityRecord();
|
|
374
377
|
(0, import_log3.log)("identity record", {
|
|
375
378
|
identityRecord
|
|
376
379
|
}, {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
380
|
+
F: __dxlog_file3,
|
|
381
|
+
L: 74,
|
|
382
|
+
S: this,
|
|
383
|
+
C: (f, a) => f(...a)
|
|
381
384
|
});
|
|
382
385
|
if (identityRecord) {
|
|
383
386
|
this._identity = await this._constructIdentity(identityRecord);
|
|
@@ -387,20 +390,20 @@ var IdentityManager = class {
|
|
|
387
390
|
identityKey: identityRecord.identityKey,
|
|
388
391
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
389
392
|
}, {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
393
|
+
F: __dxlog_file3,
|
|
394
|
+
L: 79,
|
|
395
|
+
S: this,
|
|
396
|
+
C: (f, a) => f(...a)
|
|
394
397
|
});
|
|
395
398
|
this.stateUpdate.emit();
|
|
396
399
|
}
|
|
397
400
|
import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.end({
|
|
398
401
|
id: traceId
|
|
399
402
|
}), {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
403
|
+
F: __dxlog_file3,
|
|
404
|
+
L: 85,
|
|
405
|
+
S: this,
|
|
406
|
+
C: (f, a) => f(...a)
|
|
404
407
|
});
|
|
405
408
|
}
|
|
406
409
|
async close() {
|
|
@@ -409,12 +412,12 @@ var IdentityManager = class {
|
|
|
409
412
|
}
|
|
410
413
|
async createIdentity({ displayName } = {}) {
|
|
411
414
|
var _a;
|
|
412
|
-
(0,
|
|
413
|
-
(0, import_log3.log)("creating identity...",
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
415
|
+
(0, import_tiny_invariant2.default)(!this._identity, "Identity already exists.");
|
|
416
|
+
(0, import_log3.log)("creating identity...", void 0, {
|
|
417
|
+
F: __dxlog_file3,
|
|
418
|
+
L: 94,
|
|
419
|
+
S: this,
|
|
420
|
+
C: (f, a) => f(...a)
|
|
418
421
|
});
|
|
419
422
|
const controlFeedKey = await this._keyring.createKey();
|
|
420
423
|
const identityRecord = {
|
|
@@ -431,8 +434,8 @@ var IdentityManager = class {
|
|
|
431
434
|
await identity.open();
|
|
432
435
|
{
|
|
433
436
|
const generator = new import_credentials5.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
434
|
-
(0,
|
|
435
|
-
(0,
|
|
437
|
+
(0, import_tiny_invariant2.default)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.");
|
|
438
|
+
(0, import_tiny_invariant2.default)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.");
|
|
436
439
|
const credentials = [
|
|
437
440
|
// Space genesis.
|
|
438
441
|
...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
|
|
@@ -460,20 +463,20 @@ var IdentityManager = class {
|
|
|
460
463
|
identityKey: identityRecord.identityKey,
|
|
461
464
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
462
465
|
}, {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
466
|
+
F: __dxlog_file3,
|
|
467
|
+
L: 149,
|
|
468
|
+
S: this,
|
|
469
|
+
C: (f, a) => f(...a)
|
|
467
470
|
});
|
|
468
471
|
this.stateUpdate.emit();
|
|
469
472
|
(0, import_log3.log)("created identity", {
|
|
470
473
|
identityKey: identity.identityKey,
|
|
471
474
|
deviceKey: identity.deviceKey
|
|
472
475
|
}, {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
476
|
+
F: __dxlog_file3,
|
|
477
|
+
L: 155,
|
|
478
|
+
S: this,
|
|
479
|
+
C: (f, a) => f(...a)
|
|
477
480
|
});
|
|
478
481
|
return identity;
|
|
479
482
|
}
|
|
@@ -485,12 +488,12 @@ var IdentityManager = class {
|
|
|
485
488
|
(0, import_log3.log)("accepting identity", {
|
|
486
489
|
params
|
|
487
490
|
}, {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
491
|
+
F: __dxlog_file3,
|
|
492
|
+
L: 163,
|
|
493
|
+
S: this,
|
|
494
|
+
C: (f, a) => f(...a)
|
|
492
495
|
});
|
|
493
|
-
(0,
|
|
496
|
+
(0, import_tiny_invariant2.default)(!this._identity, "Identity already exists.");
|
|
494
497
|
const identityRecord = {
|
|
495
498
|
identityKey: params.identityKey,
|
|
496
499
|
deviceKey: params.deviceKey,
|
|
@@ -511,38 +514,38 @@ var IdentityManager = class {
|
|
|
511
514
|
identityKey: identityRecord.identityKey,
|
|
512
515
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
513
516
|
}, {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
517
|
+
F: __dxlog_file3,
|
|
518
|
+
L: 183,
|
|
519
|
+
S: this,
|
|
520
|
+
C: (f, a) => f(...a)
|
|
518
521
|
});
|
|
519
522
|
this.stateUpdate.emit();
|
|
520
523
|
(0, import_log3.log)("accepted identity", {
|
|
521
524
|
identityKey: identity.identityKey,
|
|
522
525
|
deviceKey: identity.deviceKey
|
|
523
526
|
}, {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
527
|
+
F: __dxlog_file3,
|
|
528
|
+
L: 189,
|
|
529
|
+
S: this,
|
|
530
|
+
C: (f, a) => f(...a)
|
|
528
531
|
});
|
|
529
532
|
return identity;
|
|
530
533
|
}
|
|
531
534
|
async _constructIdentity(identityRecord) {
|
|
532
|
-
(0,
|
|
535
|
+
(0, import_tiny_invariant2.default)(!this._identity);
|
|
533
536
|
(0, import_log3.log)("constructing identity", {
|
|
534
537
|
identityRecord
|
|
535
538
|
}, {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
539
|
+
F: __dxlog_file3,
|
|
540
|
+
L: 195,
|
|
541
|
+
S: this,
|
|
542
|
+
C: (f, a) => f(...a)
|
|
540
543
|
});
|
|
541
|
-
(0,
|
|
544
|
+
(0, import_tiny_invariant2.default)(identityRecord.haloSpace.controlFeedKey);
|
|
542
545
|
const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
|
|
543
546
|
writable: true
|
|
544
547
|
});
|
|
545
|
-
(0,
|
|
548
|
+
(0, import_tiny_invariant2.default)(identityRecord.haloSpace.dataFeedKey);
|
|
546
549
|
const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
|
|
547
550
|
writable: true,
|
|
548
551
|
sparse: true
|
|
@@ -567,10 +570,10 @@ var IdentityManager = class {
|
|
|
567
570
|
(0, import_log3.log)("done", {
|
|
568
571
|
identityKey: identityRecord.identityKey
|
|
569
572
|
}, {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
573
|
+
F: __dxlog_file3,
|
|
574
|
+
L: 226,
|
|
575
|
+
S: this,
|
|
576
|
+
C: (f, a) => f(...a)
|
|
574
577
|
});
|
|
575
578
|
if (identityRecord.haloSpace.controlTimeframe) {
|
|
576
579
|
identity.controlPipeline.state.setTargetTimeframe(identityRecord.haloSpace.controlTimeframe);
|
|
@@ -587,11 +590,11 @@ var IdentityManager = class {
|
|
|
587
590
|
onNetworkConnection: () => {
|
|
588
591
|
},
|
|
589
592
|
onAuthFailure: () => {
|
|
590
|
-
import_log3.log.warn("auth failure",
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
593
|
+
import_log3.log.warn("auth failure", void 0, {
|
|
594
|
+
F: __dxlog_file3,
|
|
595
|
+
L: 245,
|
|
596
|
+
S: this,
|
|
597
|
+
C: (f, a) => f(...a)
|
|
595
598
|
});
|
|
596
599
|
},
|
|
597
600
|
memberKey: identityKey
|
|
@@ -600,7 +603,7 @@ var IdentityManager = class {
|
|
|
600
603
|
};
|
|
601
604
|
|
|
602
605
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
603
|
-
var
|
|
606
|
+
var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
|
|
604
607
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
605
608
|
var import_credentials7 = require("@dxos/credentials");
|
|
606
609
|
var import_debug2 = require("@dxos/debug");
|
|
@@ -636,7 +639,7 @@ var IdentityServiceImpl = class {
|
|
|
636
639
|
};
|
|
637
640
|
}
|
|
638
641
|
async signPresentation({ presentation, nonce }) {
|
|
639
|
-
(0,
|
|
642
|
+
(0, import_tiny_invariant3.default)(this._serviceContext.identityManager.identity, "Identity not initialized.");
|
|
640
643
|
return await (0, import_credentials7.signPresentation)({
|
|
641
644
|
presentation,
|
|
642
645
|
signer: this._serviceContext.keyring,
|
|
@@ -648,7 +651,7 @@ var IdentityServiceImpl = class {
|
|
|
648
651
|
};
|
|
649
652
|
|
|
650
653
|
// packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
|
|
651
|
-
var
|
|
654
|
+
var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
|
|
652
655
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
653
656
|
var DeviceInvitationProtocol = class {
|
|
654
657
|
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
@@ -665,7 +668,7 @@ var DeviceInvitationProtocol = class {
|
|
|
665
668
|
};
|
|
666
669
|
}
|
|
667
670
|
async admit(request) {
|
|
668
|
-
(0,
|
|
671
|
+
(0, import_tiny_invariant4.default)(request.device);
|
|
669
672
|
const identity = this._getIdentity();
|
|
670
673
|
await identity.admitDevice(request.device);
|
|
671
674
|
return {
|
|
@@ -693,9 +696,9 @@ var DeviceInvitationProtocol = class {
|
|
|
693
696
|
};
|
|
694
697
|
}
|
|
695
698
|
async accept(response, request) {
|
|
696
|
-
(0,
|
|
699
|
+
(0, import_tiny_invariant4.default)(response.device);
|
|
697
700
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
698
|
-
(0,
|
|
701
|
+
(0, import_tiny_invariant4.default)(request.device);
|
|
699
702
|
const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
|
|
700
703
|
await this._acceptIdentity({
|
|
701
704
|
identityKey,
|
|
@@ -713,7 +716,7 @@ var DeviceInvitationProtocol = class {
|
|
|
713
716
|
};
|
|
714
717
|
|
|
715
718
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
716
|
-
var
|
|
719
|
+
var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
|
|
717
720
|
var import_async5 = require("@dxos/async");
|
|
718
721
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
719
722
|
var import_context3 = require("@dxos/context");
|
|
@@ -727,7 +730,7 @@ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
727
730
|
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
728
731
|
|
|
729
732
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
730
|
-
var
|
|
733
|
+
var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
|
|
731
734
|
var import_async4 = require("@dxos/async");
|
|
732
735
|
var import_context2 = require("@dxos/context");
|
|
733
736
|
var import_errors = require("@dxos/errors");
|
|
@@ -737,6 +740,7 @@ var import_protocols3 = require("@dxos/protocols");
|
|
|
737
740
|
var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
738
741
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
739
742
|
var import_teleport = require("@dxos/teleport");
|
|
743
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
|
|
740
744
|
var OPTIONS_TIMEOUT = 1e4;
|
|
741
745
|
var MAX_OTP_ATTEMPTS = 3;
|
|
742
746
|
var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
@@ -764,7 +768,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
764
768
|
// Perhaps in the future we will have more complex logic here.
|
|
765
769
|
InvitationHostService: {
|
|
766
770
|
options: async (options) => {
|
|
767
|
-
(0,
|
|
771
|
+
(0, import_tiny_invariant5.default)(!this._remoteOptions, "Remote options already set.");
|
|
768
772
|
this._remoteOptions = options;
|
|
769
773
|
this._remoteOptionsTrigger.wake();
|
|
770
774
|
},
|
|
@@ -774,20 +778,20 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
774
778
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.begin({
|
|
775
779
|
id: traceId
|
|
776
780
|
}), {
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
+
F: __dxlog_file4,
|
|
782
|
+
L: 98,
|
|
783
|
+
S: this,
|
|
784
|
+
C: (f, a) => f(...a)
|
|
781
785
|
});
|
|
782
786
|
const invitation = await this._callbacks.resolveInvitation(request);
|
|
783
787
|
if (!invitation) {
|
|
784
788
|
import_log4.log.warn("invitation not found", {
|
|
785
789
|
invitationId
|
|
786
790
|
}, {
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
+
F: __dxlog_file4,
|
|
792
|
+
L: 102,
|
|
793
|
+
S: this,
|
|
794
|
+
C: (f, a) => f(...a)
|
|
791
795
|
});
|
|
792
796
|
this._callbacks.onError(new Error("Invitation not found."));
|
|
793
797
|
return {
|
|
@@ -798,10 +802,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
798
802
|
(0, import_log4.log)("guest introduced itself", {
|
|
799
803
|
guestProfile: profile
|
|
800
804
|
}, {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
+
F: __dxlog_file4,
|
|
806
|
+
L: 111,
|
|
807
|
+
S: this,
|
|
808
|
+
C: (f, a) => f(...a)
|
|
805
809
|
});
|
|
806
810
|
this.guestProfile = profile;
|
|
807
811
|
this._callbacks.onStateUpdate({
|
|
@@ -811,10 +815,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
811
815
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.end({
|
|
812
816
|
id: traceId
|
|
813
817
|
}), {
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
+
F: __dxlog_file4,
|
|
819
|
+
L: 118,
|
|
820
|
+
S: this,
|
|
821
|
+
C: (f, a) => f(...a)
|
|
818
822
|
});
|
|
819
823
|
return {
|
|
820
824
|
spaceKey: this.invitation.authMethod === import_services2.Invitation.AuthMethod.NONE ? this.invitation.spaceKey : void 0,
|
|
@@ -826,28 +830,28 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
826
830
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols3.trace.begin({
|
|
827
831
|
id: traceId
|
|
828
832
|
}), {
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
+
F: __dxlog_file4,
|
|
834
|
+
L: 127,
|
|
835
|
+
S: this,
|
|
836
|
+
C: (f, a) => f(...a)
|
|
833
837
|
});
|
|
834
838
|
(0, import_log4.log)("received authentication request", {
|
|
835
839
|
authCode: code
|
|
836
840
|
}, {
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
+
F: __dxlog_file4,
|
|
842
|
+
L: 128,
|
|
843
|
+
S: this,
|
|
844
|
+
C: (f, a) => f(...a)
|
|
841
845
|
});
|
|
842
846
|
let status = import_invitations.AuthenticationResponse.Status.OK;
|
|
843
|
-
(0,
|
|
847
|
+
(0, import_tiny_invariant5.default)(this.invitation, "Invitation is not set.");
|
|
844
848
|
switch (this.invitation.authMethod) {
|
|
845
849
|
case import_services2.Invitation.AuthMethod.NONE: {
|
|
846
|
-
(0, import_log4.log)("authentication not required",
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
850
|
+
(0, import_log4.log)("authentication not required", void 0, {
|
|
851
|
+
F: __dxlog_file4,
|
|
852
|
+
L: 134,
|
|
853
|
+
S: this,
|
|
854
|
+
C: (f, a) => f(...a)
|
|
851
855
|
});
|
|
852
856
|
return {
|
|
853
857
|
status: import_invitations.AuthenticationResponse.Status.OK
|
|
@@ -869,10 +873,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
869
873
|
import_log4.log.error("invalid authentication method", {
|
|
870
874
|
authMethod: this.invitation.authMethod
|
|
871
875
|
}, {
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
+
F: __dxlog_file4,
|
|
877
|
+
L: 152,
|
|
878
|
+
S: this,
|
|
879
|
+
C: (f, a) => f(...a)
|
|
876
880
|
});
|
|
877
881
|
status = import_invitations.AuthenticationResponse.Status.INTERNAL_ERROR;
|
|
878
882
|
break;
|
|
@@ -884,10 +888,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
884
888
|
status
|
|
885
889
|
}
|
|
886
890
|
}), {
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
+
F: __dxlog_file4,
|
|
892
|
+
L: 158,
|
|
893
|
+
S: this,
|
|
894
|
+
C: (f, a) => f(...a)
|
|
891
895
|
});
|
|
892
896
|
return {
|
|
893
897
|
status
|
|
@@ -898,13 +902,13 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
898
902
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.begin({
|
|
899
903
|
id: traceId
|
|
900
904
|
}), {
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
+
F: __dxlog_file4,
|
|
906
|
+
L: 164,
|
|
907
|
+
S: this,
|
|
908
|
+
C: (f, a) => f(...a)
|
|
905
909
|
});
|
|
906
910
|
try {
|
|
907
|
-
(0,
|
|
911
|
+
(0, import_tiny_invariant5.default)(this.invitation, "Invitation is not set.");
|
|
908
912
|
if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
|
|
909
913
|
throw new Error("Not authenticated");
|
|
910
914
|
}
|
|
@@ -912,10 +916,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
912
916
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.end({
|
|
913
917
|
id: traceId
|
|
914
918
|
}), {
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
+
F: __dxlog_file4,
|
|
920
|
+
L: 175,
|
|
921
|
+
S: this,
|
|
922
|
+
C: (f, a) => f(...a)
|
|
919
923
|
});
|
|
920
924
|
return response;
|
|
921
925
|
} catch (err) {
|
|
@@ -969,7 +973,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
969
973
|
return {
|
|
970
974
|
InvitationHostService: {
|
|
971
975
|
options: async (options) => {
|
|
972
|
-
(0,
|
|
976
|
+
(0, import_tiny_invariant5.default)(!this._remoteOptions, "Remote options already set.");
|
|
973
977
|
this._remoteOptions = options;
|
|
974
978
|
this._remoteOptionsTrigger.wake();
|
|
975
979
|
},
|
|
@@ -989,11 +993,11 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
989
993
|
var _a;
|
|
990
994
|
await super.onOpen(context);
|
|
991
995
|
try {
|
|
992
|
-
(0, import_log4.log)("begin options",
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
996
|
+
(0, import_log4.log)("begin options", void 0, {
|
|
997
|
+
F: __dxlog_file4,
|
|
998
|
+
L: 263,
|
|
999
|
+
S: this,
|
|
1000
|
+
C: (f, a) => f(...a)
|
|
997
1001
|
});
|
|
998
1002
|
await (0, import_context2.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
|
|
999
1003
|
role: import_invitations.Options.Role.GUEST
|
|
@@ -1001,11 +1005,11 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1001
1005
|
await (0, import_context2.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1002
1006
|
timeout: OPTIONS_TIMEOUT
|
|
1003
1007
|
}));
|
|
1004
|
-
(0, import_log4.log)("end options",
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1008
|
+
(0, import_log4.log)("end options", void 0, {
|
|
1009
|
+
F: __dxlog_file4,
|
|
1010
|
+
L: 266,
|
|
1011
|
+
S: this,
|
|
1012
|
+
C: (f, a) => f(...a)
|
|
1009
1013
|
});
|
|
1010
1014
|
if (((_a = this._remoteOptions) == null ? void 0 : _a.role) !== import_invitations.Options.Role.HOST) {
|
|
1011
1015
|
throw new import_errors.InvalidInvitationExtensionRoleError(void 0, {
|
|
@@ -1016,20 +1020,20 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1016
1020
|
this._callbacks.onOpen(this._ctx);
|
|
1017
1021
|
} catch (err) {
|
|
1018
1022
|
(0, import_log4.log)("openError", err, {
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
+
F: __dxlog_file4,
|
|
1024
|
+
L: 276,
|
|
1025
|
+
S: this,
|
|
1026
|
+
C: (f, a) => f(...a)
|
|
1023
1027
|
});
|
|
1024
1028
|
this._callbacks.onError(err);
|
|
1025
1029
|
}
|
|
1026
1030
|
}
|
|
1027
1031
|
async onClose() {
|
|
1028
|
-
(0, import_log4.log)("onClose",
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1032
|
+
(0, import_log4.log)("onClose", void 0, {
|
|
1033
|
+
F: __dxlog_file4,
|
|
1034
|
+
L: 282,
|
|
1035
|
+
S: this,
|
|
1036
|
+
C: (f, a) => f(...a)
|
|
1033
1037
|
});
|
|
1034
1038
|
await this._ctx.dispose();
|
|
1035
1039
|
}
|
|
@@ -1037,6 +1041,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1037
1041
|
var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services2.Invitation.AuthMethod.NONE;
|
|
1038
1042
|
|
|
1039
1043
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1044
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
1040
1045
|
var InvitationsHandler = class {
|
|
1041
1046
|
/**
|
|
1042
1047
|
* @internal
|
|
@@ -1048,7 +1053,7 @@ var InvitationsHandler = class {
|
|
|
1048
1053
|
var _a;
|
|
1049
1054
|
const { invitationId = import_keys4.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys4.PublicKey.random() } = options != null ? options : {};
|
|
1050
1055
|
const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials8.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0;
|
|
1051
|
-
(0,
|
|
1056
|
+
(0, import_tiny_invariant6.default)(protocol);
|
|
1052
1057
|
const invitation = {
|
|
1053
1058
|
invitationId,
|
|
1054
1059
|
type,
|
|
@@ -1070,10 +1075,10 @@ var InvitationsHandler = class {
|
|
|
1070
1075
|
(0, import_log5.log)("complete", {
|
|
1071
1076
|
...protocol.toJSON()
|
|
1072
1077
|
}, {
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1078
|
+
F: __dxlog_file5,
|
|
1079
|
+
L: 99,
|
|
1080
|
+
S: this,
|
|
1081
|
+
C: (f, a) => f(...a)
|
|
1077
1082
|
});
|
|
1078
1083
|
stream.complete();
|
|
1079
1084
|
});
|
|
@@ -1095,7 +1100,7 @@ var InvitationsHandler = class {
|
|
|
1095
1100
|
var _a2, _b, _c;
|
|
1096
1101
|
try {
|
|
1097
1102
|
const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
|
|
1098
|
-
(0,
|
|
1103
|
+
(0, import_tiny_invariant6.default)(deviceKey);
|
|
1099
1104
|
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1100
1105
|
extension.completedTrigger.wake(deviceKey);
|
|
1101
1106
|
return admissionResponse;
|
|
@@ -1111,18 +1116,18 @@ var InvitationsHandler = class {
|
|
|
1111
1116
|
import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.begin({
|
|
1112
1117
|
id: traceId
|
|
1113
1118
|
}), {
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1119
|
+
F: __dxlog_file5,
|
|
1120
|
+
L: 138,
|
|
1121
|
+
S: this,
|
|
1122
|
+
C: (f, a) => f(...a)
|
|
1118
1123
|
});
|
|
1119
1124
|
(0, import_log5.log)("connected", {
|
|
1120
1125
|
...protocol.toJSON()
|
|
1121
1126
|
}, {
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1127
|
+
F: __dxlog_file5,
|
|
1128
|
+
L: 139,
|
|
1129
|
+
S: this,
|
|
1130
|
+
C: (f, a) => f(...a)
|
|
1126
1131
|
});
|
|
1127
1132
|
stream.next({
|
|
1128
1133
|
...invitation,
|
|
@@ -1135,10 +1140,10 @@ var InvitationsHandler = class {
|
|
|
1135
1140
|
guest: deviceKey,
|
|
1136
1141
|
...protocol.toJSON()
|
|
1137
1142
|
}, {
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1143
|
+
F: __dxlog_file5,
|
|
1144
|
+
L: 142,
|
|
1145
|
+
S: this,
|
|
1146
|
+
C: (f, a) => f(...a)
|
|
1142
1147
|
});
|
|
1143
1148
|
stream.next({
|
|
1144
1149
|
...invitation,
|
|
@@ -1147,20 +1152,20 @@ var InvitationsHandler = class {
|
|
|
1147
1152
|
import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.end({
|
|
1148
1153
|
id: traceId
|
|
1149
1154
|
}), {
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1155
|
+
F: __dxlog_file5,
|
|
1156
|
+
L: 144,
|
|
1157
|
+
S: this,
|
|
1158
|
+
C: (f, a) => f(...a)
|
|
1154
1159
|
});
|
|
1155
1160
|
} catch (err) {
|
|
1156
1161
|
if (err instanceof import_async5.TimeoutError) {
|
|
1157
1162
|
(0, import_log5.log)("timeout", {
|
|
1158
1163
|
...protocol.toJSON()
|
|
1159
1164
|
}, {
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1165
|
+
F: __dxlog_file5,
|
|
1166
|
+
L: 147,
|
|
1167
|
+
S: this,
|
|
1168
|
+
C: (f, a) => f(...a)
|
|
1164
1169
|
});
|
|
1165
1170
|
stream.next({
|
|
1166
1171
|
...invitation,
|
|
@@ -1168,10 +1173,10 @@ var InvitationsHandler = class {
|
|
|
1168
1173
|
});
|
|
1169
1174
|
} else {
|
|
1170
1175
|
import_log5.log.error("failed", err, {
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1176
|
+
F: __dxlog_file5,
|
|
1177
|
+
L: 150,
|
|
1178
|
+
S: this,
|
|
1179
|
+
C: (f, a) => f(...a)
|
|
1175
1180
|
});
|
|
1176
1181
|
stream.error(err);
|
|
1177
1182
|
}
|
|
@@ -1179,10 +1184,10 @@ var InvitationsHandler = class {
|
|
|
1179
1184
|
id: traceId,
|
|
1180
1185
|
error: err
|
|
1181
1186
|
}), {
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1187
|
+
F: __dxlog_file5,
|
|
1188
|
+
L: 153,
|
|
1189
|
+
S: this,
|
|
1190
|
+
C: (f, a) => f(...a)
|
|
1186
1191
|
});
|
|
1187
1192
|
} finally {
|
|
1188
1193
|
if (type !== import_services3.Invitation.Type.MULTIUSE) {
|
|
@@ -1200,10 +1205,10 @@ var InvitationsHandler = class {
|
|
|
1200
1205
|
(0, import_log5.log)("timeout", {
|
|
1201
1206
|
...protocol.toJSON()
|
|
1202
1207
|
}, {
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1208
|
+
F: __dxlog_file5,
|
|
1209
|
+
L: 168,
|
|
1210
|
+
S: this,
|
|
1211
|
+
C: (f, a) => f(...a)
|
|
1207
1212
|
});
|
|
1208
1213
|
stream.next({
|
|
1209
1214
|
...invitation,
|
|
@@ -1211,10 +1216,10 @@ var InvitationsHandler = class {
|
|
|
1211
1216
|
});
|
|
1212
1217
|
} else {
|
|
1213
1218
|
import_log5.log.error("failed", err, {
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1219
|
+
F: __dxlog_file5,
|
|
1220
|
+
L: 171,
|
|
1221
|
+
S: this,
|
|
1222
|
+
C: (f, a) => f(...a)
|
|
1218
1223
|
});
|
|
1219
1224
|
stream.error(err);
|
|
1220
1225
|
}
|
|
@@ -1254,13 +1259,13 @@ var InvitationsHandler = class {
|
|
|
1254
1259
|
}
|
|
1255
1260
|
acceptInvitation(protocol, invitation) {
|
|
1256
1261
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
1257
|
-
(0,
|
|
1262
|
+
(0, import_tiny_invariant6.default)(protocol);
|
|
1258
1263
|
const authenticated = new import_async5.Trigger();
|
|
1259
1264
|
let admitted = false;
|
|
1260
1265
|
let currentState;
|
|
1261
1266
|
const stream = new import_async5.PushStream();
|
|
1262
1267
|
const setState = (newData) => {
|
|
1263
|
-
(0,
|
|
1268
|
+
(0, import_tiny_invariant6.default)(newData.state !== void 0);
|
|
1264
1269
|
currentState = newData.state;
|
|
1265
1270
|
stream.next({
|
|
1266
1271
|
...invitation,
|
|
@@ -1273,20 +1278,20 @@ var InvitationsHandler = class {
|
|
|
1273
1278
|
(0, import_log5.log)("timeout", {
|
|
1274
1279
|
...protocol.toJSON()
|
|
1275
1280
|
}, {
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1281
|
+
F: __dxlog_file5,
|
|
1282
|
+
L: 230,
|
|
1283
|
+
S: this,
|
|
1284
|
+
C: (f, a) => f(...a)
|
|
1280
1285
|
});
|
|
1281
1286
|
setState({
|
|
1282
1287
|
state: import_services3.Invitation.State.TIMEOUT
|
|
1283
1288
|
});
|
|
1284
1289
|
} else {
|
|
1285
1290
|
import_log5.log.warn("auth failed", err, {
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1291
|
+
F: __dxlog_file5,
|
|
1292
|
+
L: 233,
|
|
1293
|
+
S: this,
|
|
1294
|
+
C: (f, a) => f(...a)
|
|
1290
1295
|
});
|
|
1291
1296
|
stream.error(err);
|
|
1292
1297
|
}
|
|
@@ -1297,10 +1302,10 @@ var InvitationsHandler = class {
|
|
|
1297
1302
|
(0, import_log5.log)("complete", {
|
|
1298
1303
|
...protocol.toJSON()
|
|
1299
1304
|
}, {
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1305
|
+
F: __dxlog_file5,
|
|
1306
|
+
L: 241,
|
|
1307
|
+
S: this,
|
|
1308
|
+
C: (f, a) => f(...a)
|
|
1304
1309
|
});
|
|
1305
1310
|
stream.complete();
|
|
1306
1311
|
});
|
|
@@ -1312,10 +1317,10 @@ var InvitationsHandler = class {
|
|
|
1312
1317
|
(0, import_log5.log)("extension disposed", {
|
|
1313
1318
|
currentState
|
|
1314
1319
|
}, {
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1320
|
+
F: __dxlog_file5,
|
|
1321
|
+
L: 251,
|
|
1322
|
+
S: this,
|
|
1323
|
+
C: (f, a) => f(...a)
|
|
1319
1324
|
});
|
|
1320
1325
|
if (!admitted) {
|
|
1321
1326
|
stream.error(new Error("Remote peer disconnected."));
|
|
@@ -1327,10 +1332,10 @@ var InvitationsHandler = class {
|
|
|
1327
1332
|
import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.begin({
|
|
1328
1333
|
id: traceId
|
|
1329
1334
|
}), {
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1335
|
+
F: __dxlog_file5,
|
|
1336
|
+
L: 260,
|
|
1337
|
+
S: this,
|
|
1338
|
+
C: (f, a) => f(...a)
|
|
1334
1339
|
});
|
|
1335
1340
|
if (++connectionCount > 1) {
|
|
1336
1341
|
throw new Error(`multiple connections detected: ${connectionCount}`);
|
|
@@ -1339,10 +1344,10 @@ var InvitationsHandler = class {
|
|
|
1339
1344
|
(0, import_log5.log)("connected", {
|
|
1340
1345
|
...protocol.toJSON()
|
|
1341
1346
|
}, {
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1347
|
+
F: __dxlog_file5,
|
|
1348
|
+
L: 268,
|
|
1349
|
+
S: this,
|
|
1350
|
+
C: (f, a) => f(...a)
|
|
1346
1351
|
});
|
|
1347
1352
|
setState({
|
|
1348
1353
|
state: import_services3.Invitation.State.CONNECTED
|
|
@@ -1350,20 +1355,20 @@ var InvitationsHandler = class {
|
|
|
1350
1355
|
(0, import_log5.log)("introduce", {
|
|
1351
1356
|
...protocol.toJSON()
|
|
1352
1357
|
}, {
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1358
|
+
F: __dxlog_file5,
|
|
1359
|
+
L: 272,
|
|
1360
|
+
S: this,
|
|
1361
|
+
C: (f, a) => f(...a)
|
|
1357
1362
|
});
|
|
1358
1363
|
const introductionResponse = await extension.rpc.InvitationHostService.introduce(protocol.createIntroduction());
|
|
1359
1364
|
(0, import_log5.log)("introduce response", {
|
|
1360
1365
|
...protocol.toJSON(),
|
|
1361
1366
|
response: introductionResponse
|
|
1362
1367
|
}, {
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1368
|
+
F: __dxlog_file5,
|
|
1369
|
+
L: 276,
|
|
1370
|
+
S: this,
|
|
1371
|
+
C: (f, a) => f(...a)
|
|
1367
1372
|
});
|
|
1368
1373
|
invitation.authMethod = introductionResponse.authMethod;
|
|
1369
1374
|
if (introductionResponse.spaceKey) {
|
|
@@ -1371,11 +1376,11 @@ var InvitationsHandler = class {
|
|
|
1371
1376
|
}
|
|
1372
1377
|
if (isAuthenticationRequired(invitation)) {
|
|
1373
1378
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1374
|
-
(0, import_log5.log)("guest waiting for authentication code...",
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
+
(0, import_log5.log)("guest waiting for authentication code...", void 0, {
|
|
1380
|
+
F: __dxlog_file5,
|
|
1381
|
+
L: 285,
|
|
1382
|
+
S: this,
|
|
1383
|
+
C: (f, a) => f(...a)
|
|
1379
1384
|
});
|
|
1380
1385
|
setState({
|
|
1381
1386
|
state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
|
|
@@ -1383,11 +1388,11 @@ var InvitationsHandler = class {
|
|
|
1383
1388
|
const authCode = await authenticated.wait({
|
|
1384
1389
|
timeout
|
|
1385
1390
|
});
|
|
1386
|
-
(0, import_log5.log)("sending authentication request",
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
+
(0, import_log5.log)("sending authentication request", void 0, {
|
|
1392
|
+
F: __dxlog_file5,
|
|
1393
|
+
L: 289,
|
|
1394
|
+
S: this,
|
|
1395
|
+
C: (f, a) => f(...a)
|
|
1391
1396
|
});
|
|
1392
1397
|
setState({
|
|
1393
1398
|
state: import_services3.Invitation.State.AUTHENTICATING
|
|
@@ -1405,10 +1410,10 @@ var InvitationsHandler = class {
|
|
|
1405
1410
|
(0, import_log5.log)("retrying invalid code", {
|
|
1406
1411
|
attempt
|
|
1407
1412
|
}, {
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1413
|
+
F: __dxlog_file5,
|
|
1414
|
+
L: 300,
|
|
1415
|
+
S: this,
|
|
1416
|
+
C: (f, a) => f(...a)
|
|
1412
1417
|
});
|
|
1413
1418
|
authenticated.reset();
|
|
1414
1419
|
}
|
|
@@ -1422,10 +1427,10 @@ var InvitationsHandler = class {
|
|
|
1422
1427
|
(0, import_log5.log)("request admission", {
|
|
1423
1428
|
...protocol.toJSON()
|
|
1424
1429
|
}, {
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1430
|
+
F: __dxlog_file5,
|
|
1431
|
+
L: 311,
|
|
1432
|
+
S: this,
|
|
1433
|
+
C: (f, a) => f(...a)
|
|
1429
1434
|
});
|
|
1430
1435
|
const admissionRequest = await protocol.createAdmissionRequest();
|
|
1431
1436
|
const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
|
|
@@ -1434,10 +1439,10 @@ var InvitationsHandler = class {
|
|
|
1434
1439
|
(0, import_log5.log)("admitted by host", {
|
|
1435
1440
|
...protocol.toJSON()
|
|
1436
1441
|
}, {
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1442
|
+
F: __dxlog_file5,
|
|
1443
|
+
L: 322,
|
|
1444
|
+
S: this,
|
|
1445
|
+
C: (f, a) => f(...a)
|
|
1441
1446
|
});
|
|
1442
1447
|
setState({
|
|
1443
1448
|
...result,
|
|
@@ -1446,30 +1451,30 @@ var InvitationsHandler = class {
|
|
|
1446
1451
|
import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.end({
|
|
1447
1452
|
id: traceId
|
|
1448
1453
|
}), {
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1454
|
+
F: __dxlog_file5,
|
|
1455
|
+
L: 324,
|
|
1456
|
+
S: this,
|
|
1457
|
+
C: (f, a) => f(...a)
|
|
1453
1458
|
});
|
|
1454
1459
|
} catch (err) {
|
|
1455
1460
|
if (err instanceof import_async5.TimeoutError) {
|
|
1456
1461
|
(0, import_log5.log)("timeout", {
|
|
1457
1462
|
...protocol.toJSON()
|
|
1458
1463
|
}, {
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1464
|
+
F: __dxlog_file5,
|
|
1465
|
+
L: 327,
|
|
1466
|
+
S: this,
|
|
1467
|
+
C: (f, a) => f(...a)
|
|
1463
1468
|
});
|
|
1464
1469
|
setState({
|
|
1465
1470
|
state: import_services3.Invitation.State.TIMEOUT
|
|
1466
1471
|
});
|
|
1467
1472
|
} else {
|
|
1468
1473
|
(0, import_log5.log)("auth failed", err, {
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1474
|
+
F: __dxlog_file5,
|
|
1475
|
+
L: 330,
|
|
1476
|
+
S: this,
|
|
1477
|
+
C: (f, a) => f(...a)
|
|
1473
1478
|
});
|
|
1474
1479
|
stream.error(err);
|
|
1475
1480
|
}
|
|
@@ -1477,10 +1482,10 @@ var InvitationsHandler = class {
|
|
|
1477
1482
|
id: traceId,
|
|
1478
1483
|
error: err
|
|
1479
1484
|
}), {
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1485
|
+
F: __dxlog_file5,
|
|
1486
|
+
L: 333,
|
|
1487
|
+
S: this,
|
|
1488
|
+
C: (f, a) => f(...a)
|
|
1484
1489
|
});
|
|
1485
1490
|
} finally {
|
|
1486
1491
|
await ctx.dispose();
|
|
@@ -1495,20 +1500,20 @@ var InvitationsHandler = class {
|
|
|
1495
1500
|
(0, import_log5.log)("timeout", {
|
|
1496
1501
|
...protocol.toJSON()
|
|
1497
1502
|
}, {
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1503
|
+
F: __dxlog_file5,
|
|
1504
|
+
L: 344,
|
|
1505
|
+
S: this,
|
|
1506
|
+
C: (f, a) => f(...a)
|
|
1502
1507
|
});
|
|
1503
1508
|
setState({
|
|
1504
1509
|
state: import_services3.Invitation.State.TIMEOUT
|
|
1505
1510
|
});
|
|
1506
1511
|
} else {
|
|
1507
1512
|
(0, import_log5.log)("auth failed", err, {
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1513
|
+
F: __dxlog_file5,
|
|
1514
|
+
L: 347,
|
|
1515
|
+
S: this,
|
|
1516
|
+
C: (f, a) => f(...a)
|
|
1512
1517
|
});
|
|
1513
1518
|
stream.error(err);
|
|
1514
1519
|
}
|
|
@@ -1517,7 +1522,7 @@ var InvitationsHandler = class {
|
|
|
1517
1522
|
return extension;
|
|
1518
1523
|
};
|
|
1519
1524
|
(0, import_async5.scheduleTask)(ctx, async () => {
|
|
1520
|
-
(0,
|
|
1525
|
+
(0, import_tiny_invariant6.default)(invitation.swarmKey);
|
|
1521
1526
|
const topic = invitation.swarmKey;
|
|
1522
1527
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1523
1528
|
topic,
|
|
@@ -1550,11 +1555,12 @@ var InvitationsHandler = class {
|
|
|
1550
1555
|
};
|
|
1551
1556
|
|
|
1552
1557
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
1553
|
-
var
|
|
1558
|
+
var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
|
|
1554
1559
|
var import_async6 = require("@dxos/async");
|
|
1555
1560
|
var import_codec_protobuf2 = require("@dxos/codec-protobuf");
|
|
1556
1561
|
var import_log6 = require("@dxos/log");
|
|
1557
1562
|
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1563
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
1558
1564
|
var InvitationsServiceImpl = class {
|
|
1559
1565
|
constructor(_invitationsHandler, _getHandler) {
|
|
1560
1566
|
this._invitationsHandler = _invitationsHandler;
|
|
@@ -1615,35 +1621,35 @@ var InvitationsServiceImpl = class {
|
|
|
1615
1621
|
});
|
|
1616
1622
|
}
|
|
1617
1623
|
async authenticate({ invitationId, authCode }) {
|
|
1618
|
-
(0, import_log6.log)("authenticating...",
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1624
|
+
(0, import_log6.log)("authenticating...", void 0, {
|
|
1625
|
+
F: __dxlog_file6,
|
|
1626
|
+
L: 103,
|
|
1627
|
+
S: this,
|
|
1628
|
+
C: (f, a) => f(...a)
|
|
1623
1629
|
});
|
|
1624
|
-
(0,
|
|
1630
|
+
(0, import_tiny_invariant7.default)(invitationId);
|
|
1625
1631
|
const observable = this._acceptInvitations.get(invitationId);
|
|
1626
1632
|
if (!observable) {
|
|
1627
1633
|
import_log6.log.warn("invalid invitation", {
|
|
1628
1634
|
invitationId
|
|
1629
1635
|
}, {
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1636
|
+
F: __dxlog_file6,
|
|
1637
|
+
L: 107,
|
|
1638
|
+
S: this,
|
|
1639
|
+
C: (f, a) => f(...a)
|
|
1634
1640
|
});
|
|
1635
1641
|
} else {
|
|
1636
1642
|
await observable.authenticate(authCode);
|
|
1637
1643
|
}
|
|
1638
1644
|
}
|
|
1639
1645
|
async cancelInvitation({ invitationId }) {
|
|
1640
|
-
(0, import_log6.log)("deleting...",
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1646
|
+
(0, import_log6.log)("deleting...", void 0, {
|
|
1647
|
+
F: __dxlog_file6,
|
|
1648
|
+
L: 114,
|
|
1649
|
+
S: this,
|
|
1650
|
+
C: (f, a) => f(...a)
|
|
1645
1651
|
});
|
|
1646
|
-
(0,
|
|
1652
|
+
(0, import_tiny_invariant7.default)(invitationId);
|
|
1647
1653
|
const created = this._createInvitations.get(invitationId);
|
|
1648
1654
|
const accepted = this._acceptInvitations.get(invitationId);
|
|
1649
1655
|
if (created) {
|
|
@@ -1658,10 +1664,10 @@ var InvitationsServiceImpl = class {
|
|
|
1658
1664
|
import_log6.log.warn("invalid invitation", {
|
|
1659
1665
|
invitationId
|
|
1660
1666
|
}, {
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1667
|
+
F: __dxlog_file6,
|
|
1668
|
+
L: 127,
|
|
1669
|
+
S: this,
|
|
1670
|
+
C: (f, a) => f(...a)
|
|
1665
1671
|
});
|
|
1666
1672
|
}
|
|
1667
1673
|
}
|
|
@@ -1718,11 +1724,12 @@ var InvitationsServiceImpl = class {
|
|
|
1718
1724
|
};
|
|
1719
1725
|
|
|
1720
1726
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
1721
|
-
var
|
|
1727
|
+
var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
|
|
1722
1728
|
var import_credentials9 = require("@dxos/credentials");
|
|
1723
1729
|
var import_feed_store2 = require("@dxos/feed-store");
|
|
1724
1730
|
var import_log7 = require("@dxos/log");
|
|
1725
1731
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1732
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
1726
1733
|
var SpaceInvitationProtocol = class {
|
|
1727
1734
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
1728
1735
|
this._spaceManager = _spaceManager;
|
|
@@ -1744,24 +1751,24 @@ var SpaceInvitationProtocol = class {
|
|
|
1744
1751
|
}
|
|
1745
1752
|
async admit(request, guestProfile) {
|
|
1746
1753
|
var _a;
|
|
1747
|
-
(0,
|
|
1754
|
+
(0, import_tiny_invariant8.default)(this._spaceKey);
|
|
1748
1755
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
1749
|
-
(0,
|
|
1750
|
-
(0,
|
|
1756
|
+
(0, import_tiny_invariant8.default)(space);
|
|
1757
|
+
(0, import_tiny_invariant8.default)(request.space);
|
|
1751
1758
|
const { identityKey, deviceKey } = request.space;
|
|
1752
1759
|
(0, import_log7.log)("writing guest credentials", {
|
|
1753
1760
|
host: this._signingContext.deviceKey,
|
|
1754
1761
|
guest: deviceKey
|
|
1755
1762
|
}, {
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1763
|
+
F: __dxlog_file7,
|
|
1764
|
+
L: 50,
|
|
1765
|
+
S: this,
|
|
1766
|
+
C: (f, a) => f(...a)
|
|
1760
1767
|
});
|
|
1761
1768
|
const credentials = await (0, import_credentials9.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
1762
|
-
(0,
|
|
1769
|
+
(0, import_tiny_invariant8.default)(credentials[0].credential);
|
|
1763
1770
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
1764
|
-
(0,
|
|
1771
|
+
(0, import_tiny_invariant8.default)((0, import_credentials9.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
1765
1772
|
await (0, import_feed_store2.writeMessages)(space.inner.controlPipeline.writer, credentials);
|
|
1766
1773
|
return {
|
|
1767
1774
|
space: {
|
|
@@ -1789,11 +1796,11 @@ var SpaceInvitationProtocol = class {
|
|
|
1789
1796
|
};
|
|
1790
1797
|
}
|
|
1791
1798
|
async accept(response) {
|
|
1792
|
-
(0,
|
|
1799
|
+
(0, import_tiny_invariant8.default)(response.space);
|
|
1793
1800
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
1794
1801
|
const assertion = (0, import_credentials9.getCredentialAssertion)(credential);
|
|
1795
|
-
(0,
|
|
1796
|
-
(0,
|
|
1802
|
+
(0, import_tiny_invariant8.default)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
|
|
1803
|
+
(0, import_tiny_invariant8.default)(credential.subject.id.equals(this._signingContext.identityKey));
|
|
1797
1804
|
await this._spaceManager.acceptSpace({
|
|
1798
1805
|
spaceKey: assertion.spaceKey,
|
|
1799
1806
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
@@ -1808,7 +1815,7 @@ var SpaceInvitationProtocol = class {
|
|
|
1808
1815
|
};
|
|
1809
1816
|
|
|
1810
1817
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
1811
|
-
var
|
|
1818
|
+
var import_tiny_invariant10 = __toESM(require("tiny-invariant"));
|
|
1812
1819
|
var import_async9 = require("@dxos/async");
|
|
1813
1820
|
var import_context6 = require("@dxos/context");
|
|
1814
1821
|
var import_credentials13 = require("@dxos/credentials");
|
|
@@ -1834,7 +1841,7 @@ var import_timeframe = require("@dxos/timeframe");
|
|
|
1834
1841
|
var import_util3 = require("@dxos/util");
|
|
1835
1842
|
|
|
1836
1843
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
1837
|
-
var
|
|
1844
|
+
var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
|
|
1838
1845
|
var import_async7 = require("@dxos/async");
|
|
1839
1846
|
var import_context4 = require("@dxos/context");
|
|
1840
1847
|
var import_keys5 = require("@dxos/keys");
|
|
@@ -1842,6 +1849,7 @@ var import_log8 = require("@dxos/log");
|
|
|
1842
1849
|
var import_protocols5 = require("@dxos/protocols");
|
|
1843
1850
|
var import_teleport2 = require("@dxos/teleport");
|
|
1844
1851
|
var import_util2 = require("@dxos/util");
|
|
1852
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
1845
1853
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
1846
1854
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
1847
1855
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -1866,22 +1874,22 @@ var NotarizationPlugin = class {
|
|
|
1866
1874
|
(0, import_log8.log)("notarize", {
|
|
1867
1875
|
credentials
|
|
1868
1876
|
}, {
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1877
|
+
F: __dxlog_file8,
|
|
1878
|
+
L: 87,
|
|
1879
|
+
S: this,
|
|
1880
|
+
C: (f, a) => f(...a)
|
|
1873
1881
|
});
|
|
1874
|
-
(0,
|
|
1882
|
+
(0, import_tiny_invariant9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
|
|
1875
1883
|
const errors = new import_async7.Trigger();
|
|
1876
1884
|
const ctx = this._ctx.derive({
|
|
1877
1885
|
onError: (err) => {
|
|
1878
1886
|
import_log8.log.warn("Notarization error", {
|
|
1879
1887
|
err
|
|
1880
1888
|
}, {
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1889
|
+
F: __dxlog_file8,
|
|
1890
|
+
L: 96,
|
|
1891
|
+
S: this,
|
|
1892
|
+
C: (f, a) => f(...a)
|
|
1885
1893
|
});
|
|
1886
1894
|
void ctx.dispose();
|
|
1887
1895
|
errors.throw(err);
|
|
@@ -1894,10 +1902,10 @@ var NotarizationPlugin = class {
|
|
|
1894
1902
|
timeout,
|
|
1895
1903
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
1896
1904
|
}, {
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1905
|
+
F: __dxlog_file8,
|
|
1906
|
+
L: 108,
|
|
1907
|
+
S: this,
|
|
1908
|
+
C: (f, a) => f(...a)
|
|
1901
1909
|
});
|
|
1902
1910
|
void ctx.dispose();
|
|
1903
1911
|
errors.throw(new import_async7.TimeoutError(timeout, "Notarization timed out"));
|
|
@@ -1917,10 +1925,10 @@ var NotarizationPlugin = class {
|
|
|
1917
1925
|
import_log8.log.warn("Exhausted all peers to notarize with", {
|
|
1918
1926
|
retryIn: retryTimeout
|
|
1919
1927
|
}, {
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1928
|
+
F: __dxlog_file8,
|
|
1929
|
+
L: 133,
|
|
1930
|
+
S: this,
|
|
1931
|
+
C: (f, a) => f(...a)
|
|
1924
1932
|
});
|
|
1925
1933
|
peersTried.clear();
|
|
1926
1934
|
(0, import_async7.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
@@ -1931,28 +1939,28 @@ var NotarizationPlugin = class {
|
|
|
1931
1939
|
peer: peer.localPeerId,
|
|
1932
1940
|
credentialId: credentials.map((credential) => credential.id)
|
|
1933
1941
|
}, {
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1942
|
+
F: __dxlog_file8,
|
|
1943
|
+
L: 140,
|
|
1944
|
+
S: this,
|
|
1945
|
+
C: (f, a) => f(...a)
|
|
1938
1946
|
});
|
|
1939
1947
|
await peer.rpc.NotarizationService.notarize({
|
|
1940
1948
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
1941
1949
|
});
|
|
1942
|
-
(0, import_log8.log)("success",
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1950
|
+
(0, import_log8.log)("success", void 0, {
|
|
1951
|
+
F: __dxlog_file8,
|
|
1952
|
+
L: 144,
|
|
1953
|
+
S: this,
|
|
1954
|
+
C: (f, a) => f(...a)
|
|
1947
1955
|
});
|
|
1948
1956
|
await (0, import_async7.sleep)(successDelay);
|
|
1949
1957
|
} catch (err) {
|
|
1950
1958
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
1951
1959
|
import_log8.log.warn("error notarizing (recoverable)", err, {
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1960
|
+
F: __dxlog_file8,
|
|
1961
|
+
L: 148,
|
|
1962
|
+
S: this,
|
|
1963
|
+
C: (f, a) => f(...a)
|
|
1956
1964
|
});
|
|
1957
1965
|
}
|
|
1958
1966
|
notarizeTask.schedule();
|
|
@@ -1966,11 +1974,11 @@ var NotarizationPlugin = class {
|
|
|
1966
1974
|
allNotarized,
|
|
1967
1975
|
errors.wait()
|
|
1968
1976
|
]);
|
|
1969
|
-
(0, import_log8.log)("done",
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1977
|
+
(0, import_log8.log)("done", void 0, {
|
|
1978
|
+
F: __dxlog_file8,
|
|
1979
|
+
L: 159,
|
|
1980
|
+
S: this,
|
|
1981
|
+
C: (f, a) => f(...a)
|
|
1974
1982
|
});
|
|
1975
1983
|
} finally {
|
|
1976
1984
|
await ctx.dispose();
|
|
@@ -1989,7 +1997,7 @@ var NotarizationPlugin = class {
|
|
|
1989
1997
|
this._processCredentialsTriggers.delete(credential.id);
|
|
1990
1998
|
}
|
|
1991
1999
|
setWriter(writer) {
|
|
1992
|
-
(0,
|
|
2000
|
+
(0, import_tiny_invariant9.default)(!this._writer, "Writer already set.");
|
|
1993
2001
|
this._writer = writer;
|
|
1994
2002
|
}
|
|
1995
2003
|
async _waitUntilProcessed(id) {
|
|
@@ -2007,7 +2015,7 @@ var NotarizationPlugin = class {
|
|
|
2007
2015
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2008
2016
|
}
|
|
2009
2017
|
for (const credential of (_a = request.credentials) != null ? _a : []) {
|
|
2010
|
-
(0,
|
|
2018
|
+
(0, import_tiny_invariant9.default)(credential.id, "Credential must have an id");
|
|
2011
2019
|
if (this._processedCredentials.has(credential.id)) {
|
|
2012
2020
|
continue;
|
|
2013
2021
|
}
|
|
@@ -2020,10 +2028,10 @@ var NotarizationPlugin = class {
|
|
|
2020
2028
|
(0, import_log8.log)("extension opened", {
|
|
2021
2029
|
peer: extension.localPeerId
|
|
2022
2030
|
}, {
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2031
|
+
F: __dxlog_file8,
|
|
2032
|
+
L: 208,
|
|
2033
|
+
S: this,
|
|
2034
|
+
C: (f, a) => f(...a)
|
|
2027
2035
|
});
|
|
2028
2036
|
this._extensions.add(extension);
|
|
2029
2037
|
this._extensionOpened.emit();
|
|
@@ -2032,10 +2040,10 @@ var NotarizationPlugin = class {
|
|
|
2032
2040
|
(0, import_log8.log)("extension closed", {
|
|
2033
2041
|
peer: extension.localPeerId
|
|
2034
2042
|
}, {
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2043
|
+
F: __dxlog_file8,
|
|
2044
|
+
L: 213,
|
|
2045
|
+
S: this,
|
|
2046
|
+
C: (f, a) => f(...a)
|
|
2039
2047
|
});
|
|
2040
2048
|
this._extensions.delete(extension);
|
|
2041
2049
|
},
|
|
@@ -2076,7 +2084,7 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
2076
2084
|
};
|
|
2077
2085
|
|
|
2078
2086
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2079
|
-
|
|
2087
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
2080
2088
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2081
2089
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2082
2090
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2085,7 +2093,8 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
2085
2093
|
if (d = decorators[i])
|
|
2086
2094
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2087
2095
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2088
|
-
}
|
|
2096
|
+
}
|
|
2097
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2089
2098
|
var DataSpace = class DataSpace2 {
|
|
2090
2099
|
constructor(params) {
|
|
2091
2100
|
this._ctx = new import_context5.Context();
|
|
@@ -2172,18 +2181,18 @@ var DataSpace = class DataSpace2 {
|
|
|
2172
2181
|
} catch (err) {
|
|
2173
2182
|
if (err instanceof import_errors3.CancelledError) {
|
|
2174
2183
|
(0, import_log9.log)("Data pipeline initialization cancelled", err, {
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2184
|
+
F: __dxlog_file9,
|
|
2185
|
+
L: 173,
|
|
2186
|
+
S: this,
|
|
2187
|
+
C: (f, a) => f(...a)
|
|
2179
2188
|
});
|
|
2180
2189
|
return;
|
|
2181
2190
|
}
|
|
2182
2191
|
import_log9.log.error("Error initializing data pipeline", err, {
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2192
|
+
F: __dxlog_file9,
|
|
2193
|
+
L: 177,
|
|
2194
|
+
S: this,
|
|
2195
|
+
C: (f, a) => f(...a)
|
|
2187
2196
|
});
|
|
2188
2197
|
this._state = import_services6.SpaceState.ERROR;
|
|
2189
2198
|
this.error = err;
|
|
@@ -2205,11 +2214,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2205
2214
|
});
|
|
2206
2215
|
this.metrics.controlPipelineReady = new Date();
|
|
2207
2216
|
await this._createWritableFeeds();
|
|
2208
|
-
(0, import_log9.log)("Writable feeds created",
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2217
|
+
(0, import_log9.log)("Writable feeds created", void 0, {
|
|
2218
|
+
F: __dxlog_file9,
|
|
2219
|
+
L: 201,
|
|
2220
|
+
S: this,
|
|
2221
|
+
C: (f, a) => f(...a)
|
|
2213
2222
|
});
|
|
2214
2223
|
this.stateUpdate.emit();
|
|
2215
2224
|
this.notarizationPlugin.setWriter((0, import_echo_pipeline.createMappedFeedWriter)((credential) => ({
|
|
@@ -2220,22 +2229,22 @@ var DataSpace = class DataSpace2 {
|
|
|
2220
2229
|
await this._inner.initializeDataPipeline();
|
|
2221
2230
|
this.metrics.dataPipelineOpen = new Date();
|
|
2222
2231
|
await (0, import_context5.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
2223
|
-
(0, import_log9.log)("waiting for data pipeline to reach target timeframe",
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2232
|
+
(0, import_log9.log)("waiting for data pipeline to reach target timeframe", void 0, {
|
|
2233
|
+
F: __dxlog_file9,
|
|
2234
|
+
L: 220,
|
|
2235
|
+
S: this,
|
|
2236
|
+
C: (f, a) => f(...a)
|
|
2228
2237
|
});
|
|
2229
2238
|
await this._inner.dataPipeline.pipelineState.waitUntilReachedTargetTimeframe({
|
|
2230
2239
|
ctx: this._ctx,
|
|
2231
2240
|
breakOnStall: false
|
|
2232
2241
|
});
|
|
2233
2242
|
this.metrics.dataPipelineReady = new Date();
|
|
2234
|
-
(0, import_log9.log)("data pipeline ready",
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2243
|
+
(0, import_log9.log)("data pipeline ready", void 0, {
|
|
2244
|
+
F: __dxlog_file9,
|
|
2245
|
+
L: 229,
|
|
2246
|
+
S: this,
|
|
2247
|
+
C: (f, a) => f(...a)
|
|
2239
2248
|
});
|
|
2240
2249
|
await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
|
|
2241
2250
|
this._state = import_services6.SpaceState.READY;
|
|
@@ -2314,10 +2323,10 @@ var DataSpace = class DataSpace2 {
|
|
|
2314
2323
|
}
|
|
2315
2324
|
}
|
|
2316
2325
|
};
|
|
2317
|
-
|
|
2326
|
+
_ts_decorate([
|
|
2318
2327
|
(0, import_debug3.timed)(1e4)
|
|
2319
2328
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2320
|
-
DataSpace =
|
|
2329
|
+
DataSpace = _ts_decorate([
|
|
2321
2330
|
(0, import_async8.trackLeaks)("open", "close")
|
|
2322
2331
|
], DataSpace);
|
|
2323
2332
|
|
|
@@ -2392,7 +2401,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2392
2401
|
};
|
|
2393
2402
|
|
|
2394
2403
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2395
|
-
|
|
2404
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
2396
2405
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2397
2406
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2398
2407
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2401,7 +2410,8 @@ var __decorate2 = function(decorators, target, key, desc) {
|
|
|
2401
2410
|
if (d = decorators[i])
|
|
2402
2411
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2403
2412
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2404
|
-
}
|
|
2413
|
+
}
|
|
2414
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
2405
2415
|
var DataSpaceManager = class DataSpaceManager2 {
|
|
2406
2416
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
|
|
2407
2417
|
this._spaceManager = _spaceManager;
|
|
@@ -2421,38 +2431,38 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2421
2431
|
return this._spaces;
|
|
2422
2432
|
}
|
|
2423
2433
|
async open() {
|
|
2424
|
-
(0, import_log10.log)("open",
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2434
|
+
(0, import_log10.log)("open", void 0, {
|
|
2435
|
+
F: __dxlog_file10,
|
|
2436
|
+
L: 80,
|
|
2437
|
+
S: this,
|
|
2438
|
+
C: (f, a) => f(...a)
|
|
2429
2439
|
});
|
|
2430
2440
|
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.begin({
|
|
2431
2441
|
id: this._instanceId
|
|
2432
2442
|
}), {
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2443
|
+
F: __dxlog_file10,
|
|
2444
|
+
L: 81,
|
|
2445
|
+
S: this,
|
|
2446
|
+
C: (f, a) => f(...a)
|
|
2437
2447
|
});
|
|
2438
2448
|
await this._metadataStore.load();
|
|
2439
2449
|
(0, import_log10.log)("metadata loaded", {
|
|
2440
2450
|
spaces: this._metadataStore.spaces.length
|
|
2441
2451
|
}, {
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2452
|
+
F: __dxlog_file10,
|
|
2453
|
+
L: 83,
|
|
2454
|
+
S: this,
|
|
2455
|
+
C: (f, a) => f(...a)
|
|
2446
2456
|
});
|
|
2447
2457
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2448
2458
|
try {
|
|
2449
2459
|
(0, import_log10.log)("load space", {
|
|
2450
2460
|
spaceMetadata
|
|
2451
2461
|
}, {
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2462
|
+
F: __dxlog_file10,
|
|
2463
|
+
L: 87,
|
|
2464
|
+
S: this,
|
|
2465
|
+
C: (f, a) => f(...a)
|
|
2456
2466
|
});
|
|
2457
2467
|
const space = await this._constructSpace(spaceMetadata);
|
|
2458
2468
|
space.initializeDataPipelineAsync();
|
|
@@ -2461,10 +2471,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2461
2471
|
spaceMetadata,
|
|
2462
2472
|
err
|
|
2463
2473
|
}, {
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2474
|
+
F: __dxlog_file10,
|
|
2475
|
+
L: 91,
|
|
2476
|
+
S: this,
|
|
2477
|
+
C: (f, a) => f(...a)
|
|
2468
2478
|
});
|
|
2469
2479
|
}
|
|
2470
2480
|
}
|
|
@@ -2473,18 +2483,18 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2473
2483
|
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.end({
|
|
2474
2484
|
id: this._instanceId
|
|
2475
2485
|
}), {
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2486
|
+
F: __dxlog_file10,
|
|
2487
|
+
L: 97,
|
|
2488
|
+
S: this,
|
|
2489
|
+
C: (f, a) => f(...a)
|
|
2480
2490
|
});
|
|
2481
2491
|
}
|
|
2482
2492
|
async close() {
|
|
2483
|
-
(0, import_log10.log)("close",
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2493
|
+
(0, import_log10.log)("close", void 0, {
|
|
2494
|
+
F: __dxlog_file10,
|
|
2495
|
+
L: 102,
|
|
2496
|
+
S: this,
|
|
2497
|
+
C: (f, a) => f(...a)
|
|
2488
2498
|
});
|
|
2489
2499
|
this._isOpen = false;
|
|
2490
2500
|
await this._ctx.dispose();
|
|
@@ -2496,7 +2506,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2496
2506
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
2497
2507
|
*/
|
|
2498
2508
|
async createSpace() {
|
|
2499
|
-
(0,
|
|
2509
|
+
(0, import_tiny_invariant10.default)(this._isOpen, "Not open.");
|
|
2500
2510
|
const spaceKey = await this._keyring.createKey();
|
|
2501
2511
|
const controlFeedKey = await this._keyring.createKey();
|
|
2502
2512
|
const dataFeedKey = await this._keyring.createKey();
|
|
@@ -2509,16 +2519,16 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2509
2519
|
(0, import_log10.log)("creating space...", {
|
|
2510
2520
|
spaceKey
|
|
2511
2521
|
}, {
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2522
|
+
F: __dxlog_file10,
|
|
2523
|
+
L: 126,
|
|
2524
|
+
S: this,
|
|
2525
|
+
C: (f, a) => f(...a)
|
|
2516
2526
|
});
|
|
2517
2527
|
const space = await this._constructSpace(metadata);
|
|
2518
2528
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
2519
2529
|
await this._metadataStore.addSpace(metadata);
|
|
2520
2530
|
const memberCredential = credentials[1];
|
|
2521
|
-
(0,
|
|
2531
|
+
(0, import_tiny_invariant10.default)((0, import_credentials13.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2522
2532
|
await this._signingContext.recordCredential(memberCredential);
|
|
2523
2533
|
await space.initializeDataPipeline();
|
|
2524
2534
|
this.updated.emit();
|
|
@@ -2529,13 +2539,13 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2529
2539
|
(0, import_log10.log)("accept space", {
|
|
2530
2540
|
opts
|
|
2531
2541
|
}, {
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2542
|
+
F: __dxlog_file10,
|
|
2543
|
+
L: 145,
|
|
2544
|
+
S: this,
|
|
2545
|
+
C: (f, a) => f(...a)
|
|
2536
2546
|
});
|
|
2537
|
-
(0,
|
|
2538
|
-
(0,
|
|
2547
|
+
(0, import_tiny_invariant10.default)(this._isOpen, "Not open.");
|
|
2548
|
+
(0, import_tiny_invariant10.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
|
|
2539
2549
|
const metadata = {
|
|
2540
2550
|
key: opts.spaceKey,
|
|
2541
2551
|
genesisFeedKey: opts.genesisFeedKey,
|
|
@@ -2563,10 +2573,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2563
2573
|
(0, import_log10.log)("construct space", {
|
|
2564
2574
|
metadata
|
|
2565
2575
|
}, {
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2576
|
+
F: __dxlog_file10,
|
|
2577
|
+
L: 180,
|
|
2578
|
+
S: this,
|
|
2579
|
+
C: (f, a) => f(...a)
|
|
2570
2580
|
});
|
|
2571
2581
|
const gossip = new import_teleport_extension_gossip.Gossip({
|
|
2572
2582
|
localPeerId: this._signingContext.deviceKey
|
|
@@ -2598,11 +2608,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2598
2608
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
2599
2609
|
},
|
|
2600
2610
|
onAuthFailure: () => {
|
|
2601
|
-
import_log10.log.warn("auth failure",
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2611
|
+
import_log10.log.warn("auth failure", void 0, {
|
|
2612
|
+
F: __dxlog_file10,
|
|
2613
|
+
L: 211,
|
|
2614
|
+
S: this,
|
|
2615
|
+
C: (f, a) => f(...a)
|
|
2606
2616
|
});
|
|
2607
2617
|
},
|
|
2608
2618
|
memberKey: this._signingContext.identityKey
|
|
@@ -2622,10 +2632,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2622
2632
|
(0, import_log10.log)("before space ready", {
|
|
2623
2633
|
space: space.key
|
|
2624
2634
|
}, {
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2635
|
+
F: __dxlog_file10,
|
|
2636
|
+
L: 228,
|
|
2637
|
+
S: this,
|
|
2638
|
+
C: (f, a) => f(...a)
|
|
2629
2639
|
});
|
|
2630
2640
|
this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2631
2641
|
},
|
|
@@ -2634,10 +2644,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2634
2644
|
space: space.key,
|
|
2635
2645
|
open: this._isOpen
|
|
2636
2646
|
}, {
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2647
|
+
F: __dxlog_file10,
|
|
2648
|
+
L: 235,
|
|
2649
|
+
S: this,
|
|
2650
|
+
C: (f, a) => f(...a)
|
|
2641
2651
|
});
|
|
2642
2652
|
if (this._isOpen) {
|
|
2643
2653
|
this.updated.emit();
|
|
@@ -2657,19 +2667,19 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2657
2667
|
return dataSpace;
|
|
2658
2668
|
}
|
|
2659
2669
|
};
|
|
2660
|
-
|
|
2670
|
+
_ts_decorate2([
|
|
2661
2671
|
import_async9.synchronized
|
|
2662
2672
|
], DataSpaceManager.prototype, "open", null);
|
|
2663
|
-
|
|
2673
|
+
_ts_decorate2([
|
|
2664
2674
|
import_async9.synchronized
|
|
2665
2675
|
], DataSpaceManager.prototype, "close", null);
|
|
2666
|
-
|
|
2676
|
+
_ts_decorate2([
|
|
2667
2677
|
import_async9.synchronized
|
|
2668
2678
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
2669
|
-
|
|
2679
|
+
_ts_decorate2([
|
|
2670
2680
|
import_async9.synchronized
|
|
2671
2681
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
2672
|
-
DataSpaceManager =
|
|
2682
|
+
DataSpaceManager = _ts_decorate2([
|
|
2673
2683
|
(0, import_async9.trackLeaks)("open", "close")
|
|
2674
2684
|
], DataSpaceManager);
|
|
2675
2685
|
|
|
@@ -2682,7 +2692,7 @@ var import_log11 = require("@dxos/log");
|
|
|
2682
2692
|
var import_protocols7 = require("@dxos/protocols");
|
|
2683
2693
|
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2684
2694
|
var import_util5 = require("@dxos/util");
|
|
2685
|
-
var
|
|
2695
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
2686
2696
|
var SpacesServiceImpl = class {
|
|
2687
2697
|
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
2688
2698
|
this._identityManager = _identityManager;
|
|
@@ -2696,28 +2706,30 @@ var SpacesServiceImpl = class {
|
|
|
2696
2706
|
}
|
|
2697
2707
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2698
2708
|
const space = await dataSpaceManager.createSpace();
|
|
2699
|
-
return this.
|
|
2709
|
+
return this._serializeSpace(space);
|
|
2700
2710
|
}
|
|
2701
2711
|
async updateSpace(request) {
|
|
2702
2712
|
(0, import_debug5.todo)();
|
|
2703
2713
|
}
|
|
2704
2714
|
querySpaces() {
|
|
2705
2715
|
return new import_codec_protobuf3.Stream(({ next, ctx }) => {
|
|
2706
|
-
const
|
|
2716
|
+
const scheduler = new import_async10.UpdateScheduler(ctx, async () => {
|
|
2707
2717
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2708
|
-
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this.
|
|
2718
|
+
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
2709
2719
|
(0, import_log11.log)("update", {
|
|
2710
2720
|
spaces
|
|
2711
2721
|
}, {
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2722
|
+
F: __dxlog_file11,
|
|
2723
|
+
L: 60,
|
|
2724
|
+
S: this,
|
|
2725
|
+
C: (f, a) => f(...a)
|
|
2716
2726
|
});
|
|
2717
2727
|
next({
|
|
2718
2728
|
spaces
|
|
2719
2729
|
});
|
|
2720
|
-
}
|
|
2730
|
+
}, {
|
|
2731
|
+
maxFrequency: 2
|
|
2732
|
+
});
|
|
2721
2733
|
(0, import_async10.scheduleTask)(ctx, async () => {
|
|
2722
2734
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2723
2735
|
const subscriptions = new import_async10.EventSubscriptions();
|
|
@@ -2725,21 +2737,21 @@ var SpacesServiceImpl = class {
|
|
|
2725
2737
|
const subscribeSpaces = () => {
|
|
2726
2738
|
subscriptions.clear();
|
|
2727
2739
|
for (const space of dataSpaceManager.spaces.values()) {
|
|
2728
|
-
subscriptions.add(space.stateUpdate.on(ctx,
|
|
2729
|
-
subscriptions.add(space.presence.updated.on(ctx,
|
|
2730
|
-
subscriptions.add(space.dataPipeline.onNewEpoch.on(ctx,
|
|
2731
|
-
space.inner.controlPipeline.state.timeframeUpdate.
|
|
2740
|
+
subscriptions.add(space.stateUpdate.on(ctx, () => scheduler.trigger()));
|
|
2741
|
+
subscriptions.add(space.presence.updated.on(ctx, () => scheduler.trigger()));
|
|
2742
|
+
subscriptions.add(space.dataPipeline.onNewEpoch.on(ctx, () => scheduler.trigger()));
|
|
2743
|
+
space.inner.controlPipeline.state.timeframeUpdate.on(ctx, () => scheduler.trigger());
|
|
2732
2744
|
if (space.dataPipeline.pipelineState) {
|
|
2733
|
-
subscriptions.add(space.dataPipeline.pipelineState.timeframeUpdate.
|
|
2745
|
+
subscriptions.add(space.dataPipeline.pipelineState.timeframeUpdate.on(ctx, () => scheduler.trigger()));
|
|
2734
2746
|
}
|
|
2735
2747
|
}
|
|
2736
2748
|
};
|
|
2737
2749
|
dataSpaceManager.updated.on(ctx, () => {
|
|
2738
2750
|
subscribeSpaces();
|
|
2739
|
-
|
|
2751
|
+
scheduler.trigger();
|
|
2740
2752
|
});
|
|
2741
2753
|
subscribeSpaces();
|
|
2742
|
-
|
|
2754
|
+
scheduler.trigger();
|
|
2743
2755
|
});
|
|
2744
2756
|
if (!this._identityManager.identity) {
|
|
2745
2757
|
next({
|
|
@@ -2797,7 +2809,7 @@ var SpacesServiceImpl = class {
|
|
|
2797
2809
|
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
2798
2810
|
await space.createEpoch();
|
|
2799
2811
|
}
|
|
2800
|
-
|
|
2812
|
+
_serializeSpace(space) {
|
|
2801
2813
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
2802
2814
|
return {
|
|
2803
2815
|
spaceKey: space.key,
|
|
@@ -2837,6 +2849,7 @@ var SpacesServiceImpl = class {
|
|
|
2837
2849
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
2838
2850
|
|
|
2839
2851
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
2852
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
2840
2853
|
var ServiceContext = class {
|
|
2841
2854
|
// prettier-ignore
|
|
2842
2855
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
@@ -2880,17 +2893,17 @@ var ServiceContext = class {
|
|
|
2880
2893
|
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.begin({
|
|
2881
2894
|
id: this._instanceId
|
|
2882
2895
|
}), {
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2896
|
+
F: __dxlog_file12,
|
|
2897
|
+
L: 126,
|
|
2898
|
+
S: this,
|
|
2899
|
+
C: (f, a) => f(...a)
|
|
2887
2900
|
});
|
|
2888
2901
|
await this._checkStorageVersion();
|
|
2889
|
-
(0, import_log12.log)("opening...",
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2902
|
+
(0, import_log12.log)("opening...", void 0, {
|
|
2903
|
+
F: __dxlog_file12,
|
|
2904
|
+
L: 130,
|
|
2905
|
+
S: this,
|
|
2906
|
+
C: (f, a) => f(...a)
|
|
2894
2907
|
});
|
|
2895
2908
|
await this.signalManager.open();
|
|
2896
2909
|
await this.networkManager.open();
|
|
@@ -2899,28 +2912,28 @@ var ServiceContext = class {
|
|
|
2899
2912
|
if (this.identityManager.identity) {
|
|
2900
2913
|
await this._initialize();
|
|
2901
2914
|
}
|
|
2902
|
-
(0, import_log12.log)("opened",
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2915
|
+
(0, import_log12.log)("opened", void 0, {
|
|
2916
|
+
F: __dxlog_file12,
|
|
2917
|
+
L: 138,
|
|
2918
|
+
S: this,
|
|
2919
|
+
C: (f, a) => f(...a)
|
|
2907
2920
|
});
|
|
2908
2921
|
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.end({
|
|
2909
2922
|
id: this._instanceId
|
|
2910
2923
|
}), {
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2924
|
+
F: __dxlog_file12,
|
|
2925
|
+
L: 139,
|
|
2926
|
+
S: this,
|
|
2927
|
+
C: (f, a) => f(...a)
|
|
2915
2928
|
});
|
|
2916
2929
|
}
|
|
2917
2930
|
async close() {
|
|
2918
2931
|
var _a, _b;
|
|
2919
|
-
(0, import_log12.log)("closing...",
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2932
|
+
(0, import_log12.log)("closing...", void 0, {
|
|
2933
|
+
F: __dxlog_file12,
|
|
2934
|
+
L: 143,
|
|
2935
|
+
S: this,
|
|
2936
|
+
C: (f, a) => f(...a)
|
|
2924
2937
|
});
|
|
2925
2938
|
await ((_a = this._deviceSpaceSync) == null ? void 0 : _a.close());
|
|
2926
2939
|
await ((_b = this.dataSpaceManager) == null ? void 0 : _b.close());
|
|
@@ -2930,11 +2943,11 @@ var ServiceContext = class {
|
|
|
2930
2943
|
await this.networkManager.close();
|
|
2931
2944
|
await this.signalManager.close();
|
|
2932
2945
|
this.dataServiceSubscriptions.clear();
|
|
2933
|
-
(0, import_log12.log)("closed",
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2946
|
+
(0, import_log12.log)("closed", void 0, {
|
|
2947
|
+
F: __dxlog_file12,
|
|
2948
|
+
L: 152,
|
|
2949
|
+
S: this,
|
|
2950
|
+
C: (f, a) => f(...a)
|
|
2938
2951
|
});
|
|
2939
2952
|
}
|
|
2940
2953
|
async createIdentity(params = {}) {
|
|
@@ -2944,7 +2957,7 @@ var ServiceContext = class {
|
|
|
2944
2957
|
}
|
|
2945
2958
|
getInvitationHandler(invitation) {
|
|
2946
2959
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
2947
|
-
(0,
|
|
2960
|
+
(0, import_tiny_invariant11.default)(factory, `Unknown invitation kind: ${invitation.kind}`);
|
|
2948
2961
|
return factory(invitation);
|
|
2949
2962
|
}
|
|
2950
2963
|
async _acceptIdentity(params) {
|
|
@@ -2961,11 +2974,11 @@ var ServiceContext = class {
|
|
|
2961
2974
|
// Called when identity is created.
|
|
2962
2975
|
async _initialize() {
|
|
2963
2976
|
var _a;
|
|
2964
|
-
(0, import_log12.log)("initializing spaces...",
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2977
|
+
(0, import_log12.log)("initializing spaces...", void 0, {
|
|
2978
|
+
F: __dxlog_file12,
|
|
2979
|
+
L: 185,
|
|
2980
|
+
S: this,
|
|
2981
|
+
C: (f, a) => f(...a)
|
|
2969
2982
|
});
|
|
2970
2983
|
const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug6.failUndefined)();
|
|
2971
2984
|
const signingContext = {
|
|
@@ -2984,7 +2997,7 @@ var ServiceContext = class {
|
|
|
2984
2997
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
2985
2998
|
await this.dataSpaceManager.open();
|
|
2986
2999
|
this._handlerFactories.set(import_services9.Invitation.Kind.SPACE, (invitation) => {
|
|
2987
|
-
(0,
|
|
3000
|
+
(0, import_tiny_invariant11.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
|
|
2988
3001
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
2989
3002
|
});
|
|
2990
3003
|
this.initialized.wake();
|
|
@@ -3001,10 +3014,10 @@ var ServiceContext = class {
|
|
|
3001
3014
|
(0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3002
3015
|
details: assertion
|
|
3003
3016
|
}, {
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3017
|
+
F: __dxlog_file12,
|
|
3018
|
+
L: 224,
|
|
3019
|
+
S: this,
|
|
3020
|
+
C: (f, a) => f(...a)
|
|
3008
3021
|
});
|
|
3009
3022
|
return;
|
|
3010
3023
|
}
|
|
@@ -3012,10 +3025,10 @@ var ServiceContext = class {
|
|
|
3012
3025
|
(0, import_log12.log)("space already exists, ignoring space admission", {
|
|
3013
3026
|
details: assertion
|
|
3014
3027
|
}, {
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3028
|
+
F: __dxlog_file12,
|
|
3029
|
+
L: 228,
|
|
3030
|
+
S: this,
|
|
3031
|
+
C: (f, a) => f(...a)
|
|
3019
3032
|
});
|
|
3020
3033
|
return;
|
|
3021
3034
|
}
|
|
@@ -3023,21 +3036,21 @@ var ServiceContext = class {
|
|
|
3023
3036
|
(0, import_log12.log)("accepting space recorded in halo", {
|
|
3024
3037
|
details: assertion
|
|
3025
3038
|
}, {
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3039
|
+
F: __dxlog_file12,
|
|
3040
|
+
L: 233,
|
|
3041
|
+
S: this,
|
|
3042
|
+
C: (f, a) => f(...a)
|
|
3030
3043
|
});
|
|
3031
3044
|
await this.dataSpaceManager.acceptSpace({
|
|
3032
3045
|
spaceKey: assertion.spaceKey,
|
|
3033
3046
|
genesisFeedKey: assertion.genesisFeedKey
|
|
3034
3047
|
});
|
|
3035
3048
|
} catch (err) {
|
|
3036
|
-
import_log12.log.catch(err,
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3049
|
+
import_log12.log.catch(err, void 0, {
|
|
3050
|
+
F: __dxlog_file12,
|
|
3051
|
+
L: 239,
|
|
3052
|
+
S: this,
|
|
3053
|
+
C: (f, a) => f(...a)
|
|
3041
3054
|
});
|
|
3042
3055
|
}
|
|
3043
3056
|
}
|
|
@@ -3047,16 +3060,19 @@ var ServiceContext = class {
|
|
|
3047
3060
|
};
|
|
3048
3061
|
|
|
3049
3062
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3050
|
-
var
|
|
3063
|
+
var import_tiny_invariant13 = __toESM(require("tiny-invariant"));
|
|
3051
3064
|
var import_async17 = require("@dxos/async");
|
|
3052
3065
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
3066
|
+
var import_document_model = require("@dxos/document-model");
|
|
3053
3067
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
3054
3068
|
var import_keys12 = require("@dxos/keys");
|
|
3055
3069
|
var import_log15 = require("@dxos/log");
|
|
3056
3070
|
var import_messaging = require("@dxos/messaging");
|
|
3071
|
+
var import_model_factory = require("@dxos/model-factory");
|
|
3057
3072
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
3058
3073
|
var import_protocols9 = require("@dxos/protocols");
|
|
3059
3074
|
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3075
|
+
var import_text_model = require("@dxos/text-model");
|
|
3060
3076
|
|
|
3061
3077
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3062
3078
|
var import_async12 = require("@dxos/async");
|
|
@@ -3320,8 +3336,10 @@ var DevtoolsServiceImpl = class {
|
|
|
3320
3336
|
});
|
|
3321
3337
|
});
|
|
3322
3338
|
}
|
|
3323
|
-
getConfig(request) {
|
|
3324
|
-
|
|
3339
|
+
async getConfig(request) {
|
|
3340
|
+
return {
|
|
3341
|
+
config: JSON.stringify(this.params.config.values)
|
|
3342
|
+
};
|
|
3325
3343
|
}
|
|
3326
3344
|
async getStorageInfo() {
|
|
3327
3345
|
var _a, _b, _c, _d, _e;
|
|
@@ -3417,10 +3435,10 @@ var DevtoolsServiceImpl = class {
|
|
|
3417
3435
|
};
|
|
3418
3436
|
|
|
3419
3437
|
// packages/sdk/client-services/src/packlets/locks/node.ts
|
|
3420
|
-
var
|
|
3438
|
+
var import_tiny_invariant12 = __toESM(require("tiny-invariant"));
|
|
3421
3439
|
var import_lock_file = require("@dxos/lock-file");
|
|
3422
3440
|
var import_log13 = require("@dxos/log");
|
|
3423
|
-
|
|
3441
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
3424
3442
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3425
3443
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3426
3444
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3429,7 +3447,8 @@ var __decorate3 = function(decorators, target, key, desc) {
|
|
|
3429
3447
|
if (d = decorators[i])
|
|
3430
3448
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3431
3449
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3432
|
-
}
|
|
3450
|
+
}
|
|
3451
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
3433
3452
|
var Lock = class {
|
|
3434
3453
|
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
3435
3454
|
this._lockPath = lockPath;
|
|
@@ -3441,29 +3460,29 @@ var Lock = class {
|
|
|
3441
3460
|
}
|
|
3442
3461
|
async acquire() {
|
|
3443
3462
|
var _a;
|
|
3444
|
-
(0, import_log13.log)("acquiring lock...",
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3463
|
+
(0, import_log13.log)("acquiring lock...", void 0, {
|
|
3464
|
+
F: __dxlog_file13,
|
|
3465
|
+
L: 32,
|
|
3466
|
+
S: this,
|
|
3467
|
+
C: (f, a) => f(...a)
|
|
3449
3468
|
});
|
|
3450
3469
|
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
3451
3470
|
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
3452
|
-
(0, import_log13.log)("acquired lock",
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3471
|
+
(0, import_log13.log)("acquired lock", void 0, {
|
|
3472
|
+
F: __dxlog_file13,
|
|
3473
|
+
L: 37,
|
|
3474
|
+
S: this,
|
|
3475
|
+
C: (f, a) => f(...a)
|
|
3457
3476
|
});
|
|
3458
3477
|
}
|
|
3459
3478
|
async release() {
|
|
3460
3479
|
var _a;
|
|
3461
3480
|
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
3462
|
-
(0,
|
|
3481
|
+
(0, import_tiny_invariant12.default)(this._fileHandle, "Lock is not acquired");
|
|
3463
3482
|
await import_lock_file.LockFile.release(this._fileHandle);
|
|
3464
3483
|
}
|
|
3465
3484
|
};
|
|
3466
|
-
|
|
3485
|
+
_ts_decorate3([
|
|
3467
3486
|
import_log13.logInfo
|
|
3468
3487
|
], Lock.prototype, "lockKey", null);
|
|
3469
3488
|
|
|
@@ -3494,7 +3513,7 @@ var LoggingServiceImpl = class {
|
|
|
3494
3513
|
if (LOG_PROCESSING > 0) {
|
|
3495
3514
|
return;
|
|
3496
3515
|
}
|
|
3497
|
-
if (((_a = entry2.meta) == null ? void 0 : _a.
|
|
3516
|
+
if (((_a = entry2.meta) == null ? void 0 : _a.F.includes("logging-service")) || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
|
|
3498
3517
|
return;
|
|
3499
3518
|
}
|
|
3500
3519
|
if (!shouldLog(entry2, request)) {
|
|
@@ -3506,8 +3525,8 @@ var LoggingServiceImpl = class {
|
|
|
3506
3525
|
timestamp: new Date(),
|
|
3507
3526
|
meta: {
|
|
3508
3527
|
// TODO(dmaretskyi): Fix proto.
|
|
3509
|
-
file: (_c = (_b = entry2.meta) == null ? void 0 : _b.
|
|
3510
|
-
line: (_e = (_d = entry2.meta) == null ? void 0 : _d.
|
|
3528
|
+
file: (_c = (_b = entry2.meta) == null ? void 0 : _b.F) != null ? _c : "",
|
|
3529
|
+
line: (_e = (_d = entry2.meta) == null ? void 0 : _d.L) != null ? _e : 0
|
|
3511
3530
|
}
|
|
3512
3531
|
};
|
|
3513
3532
|
try {
|
|
@@ -3537,7 +3556,7 @@ var shouldLog = (entry2, request) => {
|
|
|
3537
3556
|
} else {
|
|
3538
3557
|
return request.filters.some((filter) => {
|
|
3539
3558
|
var _a2, _b;
|
|
3540
|
-
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.
|
|
3559
|
+
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
|
|
3541
3560
|
});
|
|
3542
3561
|
}
|
|
3543
3562
|
};
|
|
@@ -3687,10 +3706,24 @@ var ServiceRegistry = class {
|
|
|
3687
3706
|
};
|
|
3688
3707
|
|
|
3689
3708
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3709
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
3710
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3711
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3712
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3713
|
+
else
|
|
3714
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3715
|
+
if (d = decorators[i])
|
|
3716
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3717
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3718
|
+
}
|
|
3719
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
3720
|
+
var createDefaultModelFactory = () => {
|
|
3721
|
+
return new import_model_factory.ModelFactory().registerModel(import_document_model.DocumentModel).registerModel(import_text_model.TextModel);
|
|
3722
|
+
};
|
|
3690
3723
|
var ClientServicesHost = class {
|
|
3691
3724
|
constructor({
|
|
3692
3725
|
config,
|
|
3693
|
-
modelFactory =
|
|
3726
|
+
modelFactory = createDefaultModelFactory(),
|
|
3694
3727
|
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
3695
3728
|
transportFactory,
|
|
3696
3729
|
signalManager,
|
|
@@ -3762,9 +3795,9 @@ var ClientServicesHost = class {
|
|
|
3762
3795
|
*/
|
|
3763
3796
|
initialize({ config, ...options }) {
|
|
3764
3797
|
var _a, _b, _c;
|
|
3765
|
-
(0,
|
|
3798
|
+
(0, import_tiny_invariant13.default)(!this._open, "service host is open");
|
|
3766
3799
|
if (config) {
|
|
3767
|
-
(0,
|
|
3800
|
+
(0, import_tiny_invariant13.default)(!this._config, "config already set");
|
|
3768
3801
|
this._config = config;
|
|
3769
3802
|
if (!this._storage) {
|
|
3770
3803
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
@@ -3774,7 +3807,7 @@ var ClientServicesHost = class {
|
|
|
3774
3807
|
iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
|
|
3775
3808
|
}), signalManager = new import_messaging.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
|
|
3776
3809
|
this._signalManager = signalManager;
|
|
3777
|
-
(0,
|
|
3810
|
+
(0, import_tiny_invariant13.default)(!this._networkManager, "network manager already set");
|
|
3778
3811
|
this._networkManager = new import_network_manager2.NetworkManager({
|
|
3779
3812
|
log: connectionLog,
|
|
3780
3813
|
transportFactory,
|
|
@@ -3790,23 +3823,23 @@ var ClientServicesHost = class {
|
|
|
3790
3823
|
import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.begin({
|
|
3791
3824
|
id: traceId
|
|
3792
3825
|
}), {
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3826
|
+
F: __dxlog_file14,
|
|
3827
|
+
L: 195,
|
|
3828
|
+
S: this,
|
|
3829
|
+
C: (f, a) => f(...a)
|
|
3797
3830
|
});
|
|
3798
|
-
(0,
|
|
3799
|
-
(0,
|
|
3800
|
-
(0,
|
|
3801
|
-
(0,
|
|
3831
|
+
(0, import_tiny_invariant13.default)(this._config, "config not set");
|
|
3832
|
+
(0, import_tiny_invariant13.default)(this._storage, "storage not set");
|
|
3833
|
+
(0, import_tiny_invariant13.default)(this._signalManager, "signal manager not set");
|
|
3834
|
+
(0, import_tiny_invariant13.default)(this._networkManager, "network manager not set");
|
|
3802
3835
|
this._opening = true;
|
|
3803
3836
|
(0, import_log15.log)("opening...", {
|
|
3804
3837
|
lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
|
|
3805
3838
|
}, {
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3839
|
+
F: __dxlog_file14,
|
|
3840
|
+
L: 203,
|
|
3841
|
+
S: this,
|
|
3842
|
+
C: (f, a) => f(...a)
|
|
3810
3843
|
});
|
|
3811
3844
|
await ((_b = this._resourceLock) == null ? void 0 : _b.acquire());
|
|
3812
3845
|
await this._loggingService.open();
|
|
@@ -3838,18 +3871,18 @@ var ClientServicesHost = class {
|
|
|
3838
3871
|
(0, import_log15.log)("opened", {
|
|
3839
3872
|
deviceKey
|
|
3840
3873
|
}, {
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3874
|
+
F: __dxlog_file14,
|
|
3875
|
+
L: 258,
|
|
3876
|
+
S: this,
|
|
3877
|
+
C: (f, a) => f(...a)
|
|
3845
3878
|
});
|
|
3846
3879
|
import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.end({
|
|
3847
3880
|
id: traceId
|
|
3848
3881
|
}), {
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3882
|
+
F: __dxlog_file14,
|
|
3883
|
+
L: 259,
|
|
3884
|
+
S: this,
|
|
3885
|
+
C: (f, a) => f(...a)
|
|
3853
3886
|
});
|
|
3854
3887
|
}
|
|
3855
3888
|
async close() {
|
|
@@ -3861,10 +3894,10 @@ var ClientServicesHost = class {
|
|
|
3861
3894
|
(0, import_log15.log)("closing...", {
|
|
3862
3895
|
deviceKey
|
|
3863
3896
|
}, {
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3897
|
+
F: __dxlog_file14,
|
|
3898
|
+
L: 269,
|
|
3899
|
+
S: this,
|
|
3900
|
+
C: (f, a) => f(...a)
|
|
3868
3901
|
});
|
|
3869
3902
|
this._serviceRegistry.setServices({
|
|
3870
3903
|
SystemService: this._systemService
|
|
@@ -3876,10 +3909,10 @@ var ClientServicesHost = class {
|
|
|
3876
3909
|
(0, import_log15.log)("closed", {
|
|
3877
3910
|
deviceKey
|
|
3878
3911
|
}, {
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3912
|
+
F: __dxlog_file14,
|
|
3913
|
+
L: 275,
|
|
3914
|
+
S: this,
|
|
3915
|
+
C: (f, a) => f(...a)
|
|
3883
3916
|
});
|
|
3884
3917
|
}
|
|
3885
3918
|
async reset() {
|
|
@@ -3888,35 +3921,41 @@ var ClientServicesHost = class {
|
|
|
3888
3921
|
import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.begin({
|
|
3889
3922
|
id: traceId
|
|
3890
3923
|
}), {
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3924
|
+
F: __dxlog_file14,
|
|
3925
|
+
L: 280,
|
|
3926
|
+
S: this,
|
|
3927
|
+
C: (f, a) => f(...a)
|
|
3895
3928
|
});
|
|
3896
|
-
(0, import_log15.log)("resetting...",
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3929
|
+
(0, import_log15.log)("resetting...", void 0, {
|
|
3930
|
+
F: __dxlog_file14,
|
|
3931
|
+
L: 282,
|
|
3932
|
+
S: this,
|
|
3933
|
+
C: (f, a) => f(...a)
|
|
3901
3934
|
});
|
|
3902
3935
|
await ((_a = this._serviceContext) == null ? void 0 : _a.close());
|
|
3903
3936
|
await this._storage.reset();
|
|
3904
|
-
(0, import_log15.log)("reset",
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3937
|
+
(0, import_log15.log)("reset", void 0, {
|
|
3938
|
+
F: __dxlog_file14,
|
|
3939
|
+
L: 285,
|
|
3940
|
+
S: this,
|
|
3941
|
+
C: (f, a) => f(...a)
|
|
3909
3942
|
});
|
|
3910
3943
|
import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.end({
|
|
3911
3944
|
id: traceId
|
|
3912
3945
|
}), {
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3946
|
+
F: __dxlog_file14,
|
|
3947
|
+
L: 286,
|
|
3948
|
+
S: this,
|
|
3949
|
+
C: (f, a) => f(...a)
|
|
3917
3950
|
});
|
|
3918
3951
|
}
|
|
3919
3952
|
};
|
|
3953
|
+
_ts_decorate4([
|
|
3954
|
+
import_async17.synchronized
|
|
3955
|
+
], ClientServicesHost.prototype, "open", null);
|
|
3956
|
+
_ts_decorate4([
|
|
3957
|
+
import_async17.synchronized
|
|
3958
|
+
], ClientServicesHost.prototype, "close", null);
|
|
3920
3959
|
|
|
3921
3960
|
// packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
|
|
3922
3961
|
var sanitizeInvitation = (invitation) => {
|
|
@@ -3950,7 +3989,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
|
|
|
3950
3989
|
if ((_b2 = (_a2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _a2.onConnecting) == null ? void 0 : _b2.call(_a2, guestObservable)) {
|
|
3951
3990
|
break;
|
|
3952
3991
|
}
|
|
3953
|
-
(0,
|
|
3992
|
+
(0, import_tiny_invariant14.default)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey));
|
|
3954
3993
|
break;
|
|
3955
3994
|
}
|
|
3956
3995
|
case import_services13.Invitation.State.CONNECTED: {
|
|
@@ -4091,7 +4130,6 @@ var acceptInvitation = (guest, invitation) => {
|
|
|
4091
4130
|
};
|
|
4092
4131
|
|
|
4093
4132
|
// packages/sdk/client-services/src/packlets/testing/test-builder.ts
|
|
4094
|
-
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
4095
4133
|
var import_context8 = require("@dxos/context");
|
|
4096
4134
|
var import_credentials15 = require("@dxos/credentials");
|
|
4097
4135
|
var import_echo_pipeline5 = require("@dxos/echo-pipeline");
|
|
@@ -4117,7 +4155,7 @@ var createServiceContext = ({ signalContext = new import_messaging2.MemorySignal
|
|
|
4117
4155
|
signalManager,
|
|
4118
4156
|
transportFactory: import_network_manager3.MemoryTransportFactory
|
|
4119
4157
|
});
|
|
4120
|
-
const modelFactory =
|
|
4158
|
+
const modelFactory = createDefaultModelFactory();
|
|
4121
4159
|
return new ServiceContext(storage, networkManager, signalManager, modelFactory);
|
|
4122
4160
|
};
|
|
4123
4161
|
var createPeers = async (numPeers) => {
|
|
@@ -4207,7 +4245,7 @@ var TestPeer = class {
|
|
|
4207
4245
|
feedStore: this.feedStore,
|
|
4208
4246
|
networkManager: this.networkManager,
|
|
4209
4247
|
metadataStore: this.metadataStore,
|
|
4210
|
-
modelFactory:
|
|
4248
|
+
modelFactory: createDefaultModelFactory(),
|
|
4211
4249
|
snapshotStore: this.snapshotStore,
|
|
4212
4250
|
blobStore: this.blobStore
|
|
4213
4251
|
});
|