@dxos/client-services 0.1.52 → 0.1.53-main.01c99c0
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-3EI4PM2V.mjs} +820 -696
- package/dist/lib/browser/chunk-3EI4PM2V.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +101 -120
- 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 +24 -7
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +887 -784
- 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 +804 -666
- 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/identity/authenticator.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +7 -1
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +11 -2
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +2 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +2 -2
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts +7 -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/authenticator.ts +4 -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 +22 -27
- 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 +12 -10
- package/src/packlets/services/service-host.test.ts +50 -2
- package/src/packlets/services/service-host.ts +28 -10
- package/src/packlets/spaces/data-space-manager.test.ts +75 -119
- package/src/packlets/spaces/data-space-manager.ts +18 -9
- package/src/packlets/spaces/data-space.ts +66 -20
- package/src/packlets/spaces/notarization-plugin.test.ts +1 -1
- package/src/packlets/spaces/notarization-plugin.ts +9 -5
- package/src/packlets/spaces/spaces-service.test.ts +5 -3
- package/src/packlets/spaces/spaces-service.ts +46 -32
- package/src/packlets/testing/invitation-utils.ts +2 -2
- package/src/packlets/testing/test-builder.ts +36 -4
- 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-runtime.ts +1 -1
- package/src/packlets/vault/worker-session.ts +2 -2
- package/dist/lib/browser/chunk-C3SPTMW3.mjs.map +0 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "@dxos/node-std/globals"
|
|
1
|
+
import "@dxos/node-std/globals";
|
|
2
2
|
|
|
3
3
|
// packages/sdk/client-services/src/packlets/devtools/feeds.ts
|
|
4
4
|
import { EventSubscriptions } from "@dxos/async";
|
|
@@ -248,8 +248,10 @@ var DevtoolsServiceImpl = class {
|
|
|
248
248
|
});
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
|
-
getConfig(request) {
|
|
252
|
-
|
|
251
|
+
async getConfig(request) {
|
|
252
|
+
return {
|
|
253
|
+
config: JSON.stringify(this.params.config.values)
|
|
254
|
+
};
|
|
253
255
|
}
|
|
254
256
|
async getStorageInfo() {
|
|
255
257
|
var _a, _b, _c, _d, _e;
|
|
@@ -350,6 +352,8 @@ import { Context as Context2 } from "@dxos/context";
|
|
|
350
352
|
import { verifyCredential } from "@dxos/credentials";
|
|
351
353
|
import { log } from "@dxos/log";
|
|
352
354
|
import { schema } from "@dxos/protocols";
|
|
355
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
|
|
356
|
+
var Credential = schema.getCodecForType("dxos.halo.credentials.Credential");
|
|
353
357
|
var createAuthProvider = (signer) => async (nonce) => {
|
|
354
358
|
const credential = await signer.createCredential({
|
|
355
359
|
assertion: {
|
|
@@ -358,7 +362,7 @@ var createAuthProvider = (signer) => async (nonce) => {
|
|
|
358
362
|
subject: signer.getIssuer(),
|
|
359
363
|
nonce
|
|
360
364
|
});
|
|
361
|
-
return
|
|
365
|
+
return Credential.encode(credential);
|
|
362
366
|
};
|
|
363
367
|
var TrustedKeySetAuthVerifier = class {
|
|
364
368
|
// prettier-ignore
|
|
@@ -371,24 +375,24 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
371
375
|
}
|
|
372
376
|
get verifier() {
|
|
373
377
|
return async (nonce, auth) => {
|
|
374
|
-
const credential =
|
|
378
|
+
const credential = Credential.decode(auth);
|
|
375
379
|
log("authenticating...", {
|
|
376
380
|
credential
|
|
377
381
|
}, {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
+
F: __dxlog_file,
|
|
383
|
+
L: 59,
|
|
384
|
+
S: this,
|
|
385
|
+
C: (f, a) => f(...a)
|
|
382
386
|
});
|
|
383
387
|
const result = await verifyCredential(credential);
|
|
384
388
|
if (result.kind === "fail") {
|
|
385
389
|
log("Invalid credential", {
|
|
386
390
|
result
|
|
387
391
|
}, {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
+
F: __dxlog_file,
|
|
393
|
+
L: 63,
|
|
394
|
+
S: this,
|
|
395
|
+
C: (f, a) => f(...a)
|
|
392
396
|
});
|
|
393
397
|
return false;
|
|
394
398
|
}
|
|
@@ -397,10 +401,10 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
397
401
|
nonce,
|
|
398
402
|
credential
|
|
399
403
|
}, {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
+
F: __dxlog_file,
|
|
405
|
+
L: 68,
|
|
406
|
+
S: this,
|
|
407
|
+
C: (f, a) => f(...a)
|
|
404
408
|
});
|
|
405
409
|
return false;
|
|
406
410
|
}
|
|
@@ -408,10 +412,10 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
408
412
|
log("key is not currently in trusted set, waiting...", {
|
|
409
413
|
key: credential.issuer
|
|
410
414
|
}, {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
+
F: __dxlog_file,
|
|
416
|
+
L: 73,
|
|
417
|
+
S: this,
|
|
418
|
+
C: (f, a) => f(...a)
|
|
415
419
|
});
|
|
416
420
|
return true;
|
|
417
421
|
}
|
|
@@ -424,20 +428,20 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
424
428
|
log("auth success", {
|
|
425
429
|
key: credential.issuer
|
|
426
430
|
}, {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
+
F: __dxlog_file,
|
|
432
|
+
L: 84,
|
|
433
|
+
S: this,
|
|
434
|
+
C: (f, a) => f(...a)
|
|
431
435
|
});
|
|
432
436
|
trigger.wake(true);
|
|
433
437
|
} else {
|
|
434
438
|
log("key is not currently in trusted set, waiting...", {
|
|
435
439
|
key: credential.issuer
|
|
436
440
|
}, {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
+
F: __dxlog_file,
|
|
442
|
+
L: 87,
|
|
443
|
+
S: this,
|
|
444
|
+
C: (f, a) => f(...a)
|
|
441
445
|
});
|
|
442
446
|
}
|
|
443
447
|
});
|
|
@@ -459,7 +463,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
459
463
|
};
|
|
460
464
|
|
|
461
465
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
462
|
-
import
|
|
466
|
+
import invariant from "tiny-invariant";
|
|
463
467
|
import { Event } from "@dxos/async";
|
|
464
468
|
import { AUTH_TIMEOUT, LOAD_CONTROL_FEEDS_TIMEOUT } from "@dxos/client-protocol";
|
|
465
469
|
import { DeviceStateMachine, createCredentialSignerWithKey, createCredentialSignerWithChain, ProfileStateMachine } from "@dxos/credentials";
|
|
@@ -467,6 +471,7 @@ import { failUndefined } from "@dxos/debug";
|
|
|
467
471
|
import { writeMessages } from "@dxos/feed-store";
|
|
468
472
|
import { log as log2 } from "@dxos/log";
|
|
469
473
|
import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
474
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
470
475
|
var Identity = class {
|
|
471
476
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
472
477
|
this.stateUpdate = new Event();
|
|
@@ -474,15 +479,15 @@ var Identity = class {
|
|
|
474
479
|
this._signer = signer;
|
|
475
480
|
this.identityKey = identityKey;
|
|
476
481
|
this.deviceKey = deviceKey;
|
|
477
|
-
this._deviceStateMachine =
|
|
482
|
+
this._deviceStateMachine = new DeviceStateMachine({
|
|
478
483
|
identityKey: this.identityKey,
|
|
479
484
|
deviceKey: this.deviceKey,
|
|
480
485
|
onUpdate: () => this.stateUpdate.emit()
|
|
481
|
-
})
|
|
482
|
-
this._profileStateMachine =
|
|
486
|
+
});
|
|
487
|
+
this._profileStateMachine = new ProfileStateMachine({
|
|
483
488
|
identityKey: this.identityKey,
|
|
484
489
|
onUpdate: () => this.stateUpdate.emit()
|
|
485
|
-
})
|
|
490
|
+
});
|
|
486
491
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
487
492
|
trustedKeysProvider: () => this.authorizedDeviceKeys,
|
|
488
493
|
update: this.stateUpdate,
|
|
@@ -491,27 +496,27 @@ var Identity = class {
|
|
|
491
496
|
}
|
|
492
497
|
// TODO(burdon): Expose state object?
|
|
493
498
|
get authorizedDeviceKeys() {
|
|
494
|
-
return this._deviceStateMachine.
|
|
499
|
+
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
495
500
|
}
|
|
496
501
|
async open() {
|
|
497
|
-
await this.
|
|
498
|
-
await this.
|
|
502
|
+
await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
|
|
503
|
+
await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
|
|
499
504
|
await this.space.open();
|
|
500
505
|
}
|
|
501
506
|
async close() {
|
|
502
507
|
await this.authVerifier.close();
|
|
503
|
-
await this.
|
|
504
|
-
await this.
|
|
508
|
+
await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
|
|
509
|
+
await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
|
|
505
510
|
await this.space.close();
|
|
506
511
|
}
|
|
507
512
|
async ready() {
|
|
508
|
-
await this._deviceStateMachine.
|
|
513
|
+
await this._deviceStateMachine.deviceChainReady.wait();
|
|
509
514
|
await this.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
510
515
|
timeout: LOAD_CONTROL_FEEDS_TIMEOUT
|
|
511
516
|
});
|
|
512
517
|
}
|
|
513
518
|
get profileDocument() {
|
|
514
|
-
return this._profileStateMachine.
|
|
519
|
+
return this._profileStateMachine.profile;
|
|
515
520
|
}
|
|
516
521
|
/**
|
|
517
522
|
* @test-only
|
|
@@ -526,7 +531,7 @@ var Identity = class {
|
|
|
526
531
|
return this.space.genesisFeedKey;
|
|
527
532
|
}
|
|
528
533
|
get deviceCredentialChain() {
|
|
529
|
-
return this._deviceStateMachine.
|
|
534
|
+
return this._deviceStateMachine.deviceCredentialChain;
|
|
530
535
|
}
|
|
531
536
|
getAdmissionCredentials() {
|
|
532
537
|
var _a, _b;
|
|
@@ -541,8 +546,8 @@ var Identity = class {
|
|
|
541
546
|
* Requires identity to be ready.
|
|
542
547
|
*/
|
|
543
548
|
getIdentityCredentialSigner() {
|
|
544
|
-
|
|
545
|
-
return createCredentialSignerWithChain(this._signer, this._deviceStateMachine.
|
|
549
|
+
invariant(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.");
|
|
550
|
+
return createCredentialSignerWithChain(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
|
|
546
551
|
}
|
|
547
552
|
/**
|
|
548
553
|
* Issues credentials as device.
|
|
@@ -558,10 +563,10 @@ var Identity = class {
|
|
|
558
563
|
controlFeedKey,
|
|
559
564
|
dataFeedKey
|
|
560
565
|
}, {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
566
|
+
F: __dxlog_file2,
|
|
567
|
+
L: 151,
|
|
568
|
+
S: this,
|
|
569
|
+
C: (f, a) => f(...a)
|
|
565
570
|
});
|
|
566
571
|
const signer = this.getIdentityCredentialSigner();
|
|
567
572
|
await writeMessages(this.controlPipeline.writer, [
|
|
@@ -602,7 +607,7 @@ var Identity = class {
|
|
|
602
607
|
};
|
|
603
608
|
|
|
604
609
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
605
|
-
import
|
|
610
|
+
import invariant2 from "tiny-invariant";
|
|
606
611
|
import { Event as Event2 } from "@dxos/async";
|
|
607
612
|
import { createCredentialSignerWithKey as createCredentialSignerWithKey2, CredentialGenerator } from "@dxos/credentials";
|
|
608
613
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
@@ -610,6 +615,7 @@ import { log as log3 } from "@dxos/log";
|
|
|
610
615
|
import { trace } from "@dxos/protocols";
|
|
611
616
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
612
617
|
import { deferFunction } from "@dxos/util";
|
|
618
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
613
619
|
var IdentityManager = class {
|
|
614
620
|
// TODO(burdon): IdentityManagerParams.
|
|
615
621
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
@@ -629,20 +635,20 @@ var IdentityManager = class {
|
|
|
629
635
|
log3.trace("dxos.halo.identity-manager.open", trace.begin({
|
|
630
636
|
id: traceId
|
|
631
637
|
}), {
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
638
|
+
F: __dxlog_file3,
|
|
639
|
+
L: 70,
|
|
640
|
+
S: this,
|
|
641
|
+
C: (f, a) => f(...a)
|
|
636
642
|
});
|
|
637
643
|
await this._metadataStore.load();
|
|
638
644
|
const identityRecord = this._metadataStore.getIdentityRecord();
|
|
639
645
|
log3("identity record", {
|
|
640
646
|
identityRecord
|
|
641
647
|
}, {
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
648
|
+
F: __dxlog_file3,
|
|
649
|
+
L: 74,
|
|
650
|
+
S: this,
|
|
651
|
+
C: (f, a) => f(...a)
|
|
646
652
|
});
|
|
647
653
|
if (identityRecord) {
|
|
648
654
|
this._identity = await this._constructIdentity(identityRecord);
|
|
@@ -652,20 +658,20 @@ var IdentityManager = class {
|
|
|
652
658
|
identityKey: identityRecord.identityKey,
|
|
653
659
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
654
660
|
}, {
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
661
|
+
F: __dxlog_file3,
|
|
662
|
+
L: 79,
|
|
663
|
+
S: this,
|
|
664
|
+
C: (f, a) => f(...a)
|
|
659
665
|
});
|
|
660
666
|
this.stateUpdate.emit();
|
|
661
667
|
}
|
|
662
668
|
log3.trace("dxos.halo.identity-manager.open", trace.end({
|
|
663
669
|
id: traceId
|
|
664
670
|
}), {
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
671
|
+
F: __dxlog_file3,
|
|
672
|
+
L: 85,
|
|
673
|
+
S: this,
|
|
674
|
+
C: (f, a) => f(...a)
|
|
669
675
|
});
|
|
670
676
|
}
|
|
671
677
|
async close() {
|
|
@@ -674,12 +680,12 @@ var IdentityManager = class {
|
|
|
674
680
|
}
|
|
675
681
|
async createIdentity({ displayName } = {}) {
|
|
676
682
|
var _a;
|
|
677
|
-
|
|
678
|
-
log3("creating identity...",
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
+
invariant2(!this._identity, "Identity already exists.");
|
|
684
|
+
log3("creating identity...", void 0, {
|
|
685
|
+
F: __dxlog_file3,
|
|
686
|
+
L: 94,
|
|
687
|
+
S: this,
|
|
688
|
+
C: (f, a) => f(...a)
|
|
683
689
|
});
|
|
684
690
|
const controlFeedKey = await this._keyring.createKey();
|
|
685
691
|
const identityRecord = {
|
|
@@ -696,8 +702,8 @@ var IdentityManager = class {
|
|
|
696
702
|
await identity.open();
|
|
697
703
|
{
|
|
698
704
|
const generator = new CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
699
|
-
|
|
700
|
-
|
|
705
|
+
invariant2(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.");
|
|
706
|
+
invariant2(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.");
|
|
701
707
|
const credentials = [
|
|
702
708
|
// Space genesis.
|
|
703
709
|
...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
|
|
@@ -725,20 +731,20 @@ var IdentityManager = class {
|
|
|
725
731
|
identityKey: identityRecord.identityKey,
|
|
726
732
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
727
733
|
}, {
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
734
|
+
F: __dxlog_file3,
|
|
735
|
+
L: 149,
|
|
736
|
+
S: this,
|
|
737
|
+
C: (f, a) => f(...a)
|
|
732
738
|
});
|
|
733
739
|
this.stateUpdate.emit();
|
|
734
740
|
log3("created identity", {
|
|
735
741
|
identityKey: identity.identityKey,
|
|
736
742
|
deviceKey: identity.deviceKey
|
|
737
743
|
}, {
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
744
|
+
F: __dxlog_file3,
|
|
745
|
+
L: 155,
|
|
746
|
+
S: this,
|
|
747
|
+
C: (f, a) => f(...a)
|
|
742
748
|
});
|
|
743
749
|
return identity;
|
|
744
750
|
}
|
|
@@ -750,12 +756,12 @@ var IdentityManager = class {
|
|
|
750
756
|
log3("accepting identity", {
|
|
751
757
|
params
|
|
752
758
|
}, {
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
759
|
+
F: __dxlog_file3,
|
|
760
|
+
L: 163,
|
|
761
|
+
S: this,
|
|
762
|
+
C: (f, a) => f(...a)
|
|
757
763
|
});
|
|
758
|
-
|
|
764
|
+
invariant2(!this._identity, "Identity already exists.");
|
|
759
765
|
const identityRecord = {
|
|
760
766
|
identityKey: params.identityKey,
|
|
761
767
|
deviceKey: params.deviceKey,
|
|
@@ -776,38 +782,38 @@ var IdentityManager = class {
|
|
|
776
782
|
identityKey: identityRecord.identityKey,
|
|
777
783
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
778
784
|
}, {
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
785
|
+
F: __dxlog_file3,
|
|
786
|
+
L: 183,
|
|
787
|
+
S: this,
|
|
788
|
+
C: (f, a) => f(...a)
|
|
783
789
|
});
|
|
784
790
|
this.stateUpdate.emit();
|
|
785
791
|
log3("accepted identity", {
|
|
786
792
|
identityKey: identity.identityKey,
|
|
787
793
|
deviceKey: identity.deviceKey
|
|
788
794
|
}, {
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
795
|
+
F: __dxlog_file3,
|
|
796
|
+
L: 189,
|
|
797
|
+
S: this,
|
|
798
|
+
C: (f, a) => f(...a)
|
|
793
799
|
});
|
|
794
800
|
return identity;
|
|
795
801
|
}
|
|
796
802
|
async _constructIdentity(identityRecord) {
|
|
797
|
-
|
|
803
|
+
invariant2(!this._identity);
|
|
798
804
|
log3("constructing identity", {
|
|
799
805
|
identityRecord
|
|
800
806
|
}, {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
807
|
+
F: __dxlog_file3,
|
|
808
|
+
L: 195,
|
|
809
|
+
S: this,
|
|
810
|
+
C: (f, a) => f(...a)
|
|
805
811
|
});
|
|
806
|
-
|
|
812
|
+
invariant2(identityRecord.haloSpace.controlFeedKey);
|
|
807
813
|
const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
|
|
808
814
|
writable: true
|
|
809
815
|
});
|
|
810
|
-
|
|
816
|
+
invariant2(identityRecord.haloSpace.dataFeedKey);
|
|
811
817
|
const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
|
|
812
818
|
writable: true,
|
|
813
819
|
sparse: true
|
|
@@ -832,10 +838,10 @@ var IdentityManager = class {
|
|
|
832
838
|
log3("done", {
|
|
833
839
|
identityKey: identityRecord.identityKey
|
|
834
840
|
}, {
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
841
|
+
F: __dxlog_file3,
|
|
842
|
+
L: 226,
|
|
843
|
+
S: this,
|
|
844
|
+
C: (f, a) => f(...a)
|
|
839
845
|
});
|
|
840
846
|
if (identityRecord.haloSpace.controlTimeframe) {
|
|
841
847
|
identity.controlPipeline.state.setTargetTimeframe(identityRecord.haloSpace.controlTimeframe);
|
|
@@ -852,11 +858,11 @@ var IdentityManager = class {
|
|
|
852
858
|
onNetworkConnection: () => {
|
|
853
859
|
},
|
|
854
860
|
onAuthFailure: () => {
|
|
855
|
-
log3.warn("auth failure",
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
861
|
+
log3.warn("auth failure", void 0, {
|
|
862
|
+
F: __dxlog_file3,
|
|
863
|
+
L: 245,
|
|
864
|
+
S: this,
|
|
865
|
+
C: (f, a) => f(...a)
|
|
860
866
|
});
|
|
861
867
|
},
|
|
862
868
|
memberKey: identityKey
|
|
@@ -865,7 +871,7 @@ var IdentityManager = class {
|
|
|
865
871
|
};
|
|
866
872
|
|
|
867
873
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
868
|
-
import
|
|
874
|
+
import invariant3 from "tiny-invariant";
|
|
869
875
|
import { Stream as Stream7 } from "@dxos/codec-protobuf";
|
|
870
876
|
import { signPresentation } from "@dxos/credentials";
|
|
871
877
|
import { todo } from "@dxos/debug";
|
|
@@ -901,7 +907,7 @@ var IdentityServiceImpl = class {
|
|
|
901
907
|
};
|
|
902
908
|
}
|
|
903
909
|
async signPresentation({ presentation, nonce }) {
|
|
904
|
-
|
|
910
|
+
invariant3(this._serviceContext.identityManager.identity, "Identity not initialized.");
|
|
905
911
|
return await signPresentation({
|
|
906
912
|
presentation,
|
|
907
913
|
signer: this._serviceContext.keyring,
|
|
@@ -913,7 +919,7 @@ var IdentityServiceImpl = class {
|
|
|
913
919
|
};
|
|
914
920
|
|
|
915
921
|
// packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
|
|
916
|
-
import
|
|
922
|
+
import invariant4 from "tiny-invariant";
|
|
917
923
|
import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
|
|
918
924
|
var DeviceInvitationProtocol = class {
|
|
919
925
|
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
@@ -930,7 +936,7 @@ var DeviceInvitationProtocol = class {
|
|
|
930
936
|
};
|
|
931
937
|
}
|
|
932
938
|
async admit(request) {
|
|
933
|
-
|
|
939
|
+
invariant4(request.device);
|
|
934
940
|
const identity = this._getIdentity();
|
|
935
941
|
await identity.admitDevice(request.device);
|
|
936
942
|
return {
|
|
@@ -958,9 +964,9 @@ var DeviceInvitationProtocol = class {
|
|
|
958
964
|
};
|
|
959
965
|
}
|
|
960
966
|
async accept(response, request) {
|
|
961
|
-
|
|
967
|
+
invariant4(response.device);
|
|
962
968
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
963
|
-
|
|
969
|
+
invariant4(request.device);
|
|
964
970
|
const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
|
|
965
971
|
await this._acceptIdentity({
|
|
966
972
|
identityKey,
|
|
@@ -978,7 +984,7 @@ var DeviceInvitationProtocol = class {
|
|
|
978
984
|
};
|
|
979
985
|
|
|
980
986
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
981
|
-
import
|
|
987
|
+
import invariant6 from "tiny-invariant";
|
|
982
988
|
import { PushStream, scheduleTask as scheduleTask2, TimeoutError, Trigger as Trigger3 } from "@dxos/async";
|
|
983
989
|
import { AuthenticatingInvitationObservable, AUTHENTICATION_CODE_LENGTH, CancellableInvitationObservable, INVITATION_TIMEOUT } from "@dxos/client-protocol";
|
|
984
990
|
import { Context as Context4 } from "@dxos/context";
|
|
@@ -992,7 +998,7 @@ import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/ser
|
|
|
992
998
|
import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
993
999
|
|
|
994
1000
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
995
|
-
import
|
|
1001
|
+
import invariant5 from "tiny-invariant";
|
|
996
1002
|
import { Trigger as Trigger2 } from "@dxos/async";
|
|
997
1003
|
import { cancelWithContext, Context as Context3 } from "@dxos/context";
|
|
998
1004
|
import { InvalidInvitationExtensionRoleError } from "@dxos/errors";
|
|
@@ -1002,6 +1008,7 @@ import { schema as schema2, trace as trace2 } from "@dxos/protocols";
|
|
|
1002
1008
|
import { Invitation as Invitation2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1003
1009
|
import { AuthenticationResponse, Options } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1004
1010
|
import { RpcExtension } from "@dxos/teleport";
|
|
1011
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
|
|
1005
1012
|
var OPTIONS_TIMEOUT = 1e4;
|
|
1006
1013
|
var MAX_OTP_ATTEMPTS = 3;
|
|
1007
1014
|
var InvitationHostExtension = class extends RpcExtension {
|
|
@@ -1029,7 +1036,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1029
1036
|
// Perhaps in the future we will have more complex logic here.
|
|
1030
1037
|
InvitationHostService: {
|
|
1031
1038
|
options: async (options) => {
|
|
1032
|
-
|
|
1039
|
+
invariant5(!this._remoteOptions, "Remote options already set.");
|
|
1033
1040
|
this._remoteOptions = options;
|
|
1034
1041
|
this._remoteOptionsTrigger.wake();
|
|
1035
1042
|
},
|
|
@@ -1039,20 +1046,20 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1039
1046
|
log4.trace("dxos.sdk.invitation-handler.host.introduce", trace2.begin({
|
|
1040
1047
|
id: traceId
|
|
1041
1048
|
}), {
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1049
|
+
F: __dxlog_file4,
|
|
1050
|
+
L: 98,
|
|
1051
|
+
S: this,
|
|
1052
|
+
C: (f, a) => f(...a)
|
|
1046
1053
|
});
|
|
1047
1054
|
const invitation = await this._callbacks.resolveInvitation(request);
|
|
1048
1055
|
if (!invitation) {
|
|
1049
1056
|
log4.warn("invitation not found", {
|
|
1050
1057
|
invitationId
|
|
1051
1058
|
}, {
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1059
|
+
F: __dxlog_file4,
|
|
1060
|
+
L: 102,
|
|
1061
|
+
S: this,
|
|
1062
|
+
C: (f, a) => f(...a)
|
|
1056
1063
|
});
|
|
1057
1064
|
this._callbacks.onError(new Error("Invitation not found."));
|
|
1058
1065
|
return {
|
|
@@ -1063,10 +1070,10 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1063
1070
|
log4("guest introduced itself", {
|
|
1064
1071
|
guestProfile: profile
|
|
1065
1072
|
}, {
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1073
|
+
F: __dxlog_file4,
|
|
1074
|
+
L: 111,
|
|
1075
|
+
S: this,
|
|
1076
|
+
C: (f, a) => f(...a)
|
|
1070
1077
|
});
|
|
1071
1078
|
this.guestProfile = profile;
|
|
1072
1079
|
this._callbacks.onStateUpdate({
|
|
@@ -1076,10 +1083,10 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1076
1083
|
log4.trace("dxos.sdk.invitation-handler.host.introduce", trace2.end({
|
|
1077
1084
|
id: traceId
|
|
1078
1085
|
}), {
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1086
|
+
F: __dxlog_file4,
|
|
1087
|
+
L: 118,
|
|
1088
|
+
S: this,
|
|
1089
|
+
C: (f, a) => f(...a)
|
|
1083
1090
|
});
|
|
1084
1091
|
return {
|
|
1085
1092
|
spaceKey: this.invitation.authMethod === Invitation2.AuthMethod.NONE ? this.invitation.spaceKey : void 0,
|
|
@@ -1091,28 +1098,28 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1091
1098
|
log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace2.begin({
|
|
1092
1099
|
id: traceId
|
|
1093
1100
|
}), {
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1101
|
+
F: __dxlog_file4,
|
|
1102
|
+
L: 127,
|
|
1103
|
+
S: this,
|
|
1104
|
+
C: (f, a) => f(...a)
|
|
1098
1105
|
});
|
|
1099
1106
|
log4("received authentication request", {
|
|
1100
1107
|
authCode: code
|
|
1101
1108
|
}, {
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1109
|
+
F: __dxlog_file4,
|
|
1110
|
+
L: 128,
|
|
1111
|
+
S: this,
|
|
1112
|
+
C: (f, a) => f(...a)
|
|
1106
1113
|
});
|
|
1107
1114
|
let status = AuthenticationResponse.Status.OK;
|
|
1108
|
-
|
|
1115
|
+
invariant5(this.invitation, "Invitation is not set.");
|
|
1109
1116
|
switch (this.invitation.authMethod) {
|
|
1110
1117
|
case Invitation2.AuthMethod.NONE: {
|
|
1111
|
-
log4("authentication not required",
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1118
|
+
log4("authentication not required", void 0, {
|
|
1119
|
+
F: __dxlog_file4,
|
|
1120
|
+
L: 134,
|
|
1121
|
+
S: this,
|
|
1122
|
+
C: (f, a) => f(...a)
|
|
1116
1123
|
});
|
|
1117
1124
|
return {
|
|
1118
1125
|
status: AuthenticationResponse.Status.OK
|
|
@@ -1134,10 +1141,10 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1134
1141
|
log4.error("invalid authentication method", {
|
|
1135
1142
|
authMethod: this.invitation.authMethod
|
|
1136
1143
|
}, {
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1144
|
+
F: __dxlog_file4,
|
|
1145
|
+
L: 152,
|
|
1146
|
+
S: this,
|
|
1147
|
+
C: (f, a) => f(...a)
|
|
1141
1148
|
});
|
|
1142
1149
|
status = AuthenticationResponse.Status.INTERNAL_ERROR;
|
|
1143
1150
|
break;
|
|
@@ -1149,10 +1156,10 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1149
1156
|
status
|
|
1150
1157
|
}
|
|
1151
1158
|
}), {
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1159
|
+
F: __dxlog_file4,
|
|
1160
|
+
L: 158,
|
|
1161
|
+
S: this,
|
|
1162
|
+
C: (f, a) => f(...a)
|
|
1156
1163
|
});
|
|
1157
1164
|
return {
|
|
1158
1165
|
status
|
|
@@ -1163,13 +1170,13 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1163
1170
|
log4.trace("dxos.sdk.invitation-handler.host.admit", trace2.begin({
|
|
1164
1171
|
id: traceId
|
|
1165
1172
|
}), {
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1173
|
+
F: __dxlog_file4,
|
|
1174
|
+
L: 164,
|
|
1175
|
+
S: this,
|
|
1176
|
+
C: (f, a) => f(...a)
|
|
1170
1177
|
});
|
|
1171
1178
|
try {
|
|
1172
|
-
|
|
1179
|
+
invariant5(this.invitation, "Invitation is not set.");
|
|
1173
1180
|
if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
|
|
1174
1181
|
throw new Error("Not authenticated");
|
|
1175
1182
|
}
|
|
@@ -1177,10 +1184,10 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1177
1184
|
log4.trace("dxos.sdk.invitation-handler.host.admit", trace2.end({
|
|
1178
1185
|
id: traceId
|
|
1179
1186
|
}), {
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1187
|
+
F: __dxlog_file4,
|
|
1188
|
+
L: 175,
|
|
1189
|
+
S: this,
|
|
1190
|
+
C: (f, a) => f(...a)
|
|
1184
1191
|
});
|
|
1185
1192
|
return response;
|
|
1186
1193
|
} catch (err) {
|
|
@@ -1234,7 +1241,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1234
1241
|
return {
|
|
1235
1242
|
InvitationHostService: {
|
|
1236
1243
|
options: async (options) => {
|
|
1237
|
-
|
|
1244
|
+
invariant5(!this._remoteOptions, "Remote options already set.");
|
|
1238
1245
|
this._remoteOptions = options;
|
|
1239
1246
|
this._remoteOptionsTrigger.wake();
|
|
1240
1247
|
},
|
|
@@ -1254,11 +1261,11 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1254
1261
|
var _a;
|
|
1255
1262
|
await super.onOpen(context);
|
|
1256
1263
|
try {
|
|
1257
|
-
log4("begin options",
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1264
|
+
log4("begin options", void 0, {
|
|
1265
|
+
F: __dxlog_file4,
|
|
1266
|
+
L: 263,
|
|
1267
|
+
S: this,
|
|
1268
|
+
C: (f, a) => f(...a)
|
|
1262
1269
|
});
|
|
1263
1270
|
await cancelWithContext(this._ctx, this.rpc.InvitationHostService.options({
|
|
1264
1271
|
role: Options.Role.GUEST
|
|
@@ -1266,11 +1273,11 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1266
1273
|
await cancelWithContext(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1267
1274
|
timeout: OPTIONS_TIMEOUT
|
|
1268
1275
|
}));
|
|
1269
|
-
log4("end options",
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1276
|
+
log4("end options", void 0, {
|
|
1277
|
+
F: __dxlog_file4,
|
|
1278
|
+
L: 266,
|
|
1279
|
+
S: this,
|
|
1280
|
+
C: (f, a) => f(...a)
|
|
1274
1281
|
});
|
|
1275
1282
|
if (((_a = this._remoteOptions) == null ? void 0 : _a.role) !== Options.Role.HOST) {
|
|
1276
1283
|
throw new InvalidInvitationExtensionRoleError(void 0, {
|
|
@@ -1281,20 +1288,20 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1281
1288
|
this._callbacks.onOpen(this._ctx);
|
|
1282
1289
|
} catch (err) {
|
|
1283
1290
|
log4("openError", err, {
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1291
|
+
F: __dxlog_file4,
|
|
1292
|
+
L: 276,
|
|
1293
|
+
S: this,
|
|
1294
|
+
C: (f, a) => f(...a)
|
|
1288
1295
|
});
|
|
1289
1296
|
this._callbacks.onError(err);
|
|
1290
1297
|
}
|
|
1291
1298
|
}
|
|
1292
1299
|
async onClose() {
|
|
1293
|
-
log4("onClose",
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1300
|
+
log4("onClose", void 0, {
|
|
1301
|
+
F: __dxlog_file4,
|
|
1302
|
+
L: 282,
|
|
1303
|
+
S: this,
|
|
1304
|
+
C: (f, a) => f(...a)
|
|
1298
1305
|
});
|
|
1299
1306
|
await this._ctx.dispose();
|
|
1300
1307
|
}
|
|
@@ -1302,6 +1309,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1302
1309
|
var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitation2.AuthMethod.NONE;
|
|
1303
1310
|
|
|
1304
1311
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1312
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
1305
1313
|
var InvitationsHandler = class {
|
|
1306
1314
|
/**
|
|
1307
1315
|
* @internal
|
|
@@ -1313,7 +1321,7 @@ var InvitationsHandler = class {
|
|
|
1313
1321
|
var _a;
|
|
1314
1322
|
const { invitationId = PublicKey5.random().toHex(), type = Invitation3.Type.INTERACTIVE, authMethod = Invitation3.AuthMethod.SHARED_SECRET, state = Invitation3.State.INIT, timeout = INVITATION_TIMEOUT, swarmKey = PublicKey5.random() } = options != null ? options : {};
|
|
1315
1323
|
const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === Invitation3.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0;
|
|
1316
|
-
|
|
1324
|
+
invariant6(protocol);
|
|
1317
1325
|
const invitation = {
|
|
1318
1326
|
invitationId,
|
|
1319
1327
|
type,
|
|
@@ -1335,10 +1343,10 @@ var InvitationsHandler = class {
|
|
|
1335
1343
|
log5("complete", {
|
|
1336
1344
|
...protocol.toJSON()
|
|
1337
1345
|
}, {
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1346
|
+
F: __dxlog_file5,
|
|
1347
|
+
L: 99,
|
|
1348
|
+
S: this,
|
|
1349
|
+
C: (f, a) => f(...a)
|
|
1342
1350
|
});
|
|
1343
1351
|
stream.complete();
|
|
1344
1352
|
});
|
|
@@ -1360,7 +1368,7 @@ var InvitationsHandler = class {
|
|
|
1360
1368
|
var _a2, _b, _c;
|
|
1361
1369
|
try {
|
|
1362
1370
|
const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
|
|
1363
|
-
|
|
1371
|
+
invariant6(deviceKey);
|
|
1364
1372
|
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1365
1373
|
extension.completedTrigger.wake(deviceKey);
|
|
1366
1374
|
return admissionResponse;
|
|
@@ -1376,18 +1384,18 @@ var InvitationsHandler = class {
|
|
|
1376
1384
|
log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace3.begin({
|
|
1377
1385
|
id: traceId
|
|
1378
1386
|
}), {
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1387
|
+
F: __dxlog_file5,
|
|
1388
|
+
L: 138,
|
|
1389
|
+
S: this,
|
|
1390
|
+
C: (f, a) => f(...a)
|
|
1383
1391
|
});
|
|
1384
1392
|
log5("connected", {
|
|
1385
1393
|
...protocol.toJSON()
|
|
1386
1394
|
}, {
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1395
|
+
F: __dxlog_file5,
|
|
1396
|
+
L: 139,
|
|
1397
|
+
S: this,
|
|
1398
|
+
C: (f, a) => f(...a)
|
|
1391
1399
|
});
|
|
1392
1400
|
stream.next({
|
|
1393
1401
|
...invitation,
|
|
@@ -1400,10 +1408,10 @@ var InvitationsHandler = class {
|
|
|
1400
1408
|
guest: deviceKey,
|
|
1401
1409
|
...protocol.toJSON()
|
|
1402
1410
|
}, {
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1411
|
+
F: __dxlog_file5,
|
|
1412
|
+
L: 142,
|
|
1413
|
+
S: this,
|
|
1414
|
+
C: (f, a) => f(...a)
|
|
1407
1415
|
});
|
|
1408
1416
|
stream.next({
|
|
1409
1417
|
...invitation,
|
|
@@ -1412,20 +1420,20 @@ var InvitationsHandler = class {
|
|
|
1412
1420
|
log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace3.end({
|
|
1413
1421
|
id: traceId
|
|
1414
1422
|
}), {
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1423
|
+
F: __dxlog_file5,
|
|
1424
|
+
L: 144,
|
|
1425
|
+
S: this,
|
|
1426
|
+
C: (f, a) => f(...a)
|
|
1419
1427
|
});
|
|
1420
1428
|
} catch (err) {
|
|
1421
1429
|
if (err instanceof TimeoutError) {
|
|
1422
1430
|
log5("timeout", {
|
|
1423
1431
|
...protocol.toJSON()
|
|
1424
1432
|
}, {
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1433
|
+
F: __dxlog_file5,
|
|
1434
|
+
L: 147,
|
|
1435
|
+
S: this,
|
|
1436
|
+
C: (f, a) => f(...a)
|
|
1429
1437
|
});
|
|
1430
1438
|
stream.next({
|
|
1431
1439
|
...invitation,
|
|
@@ -1433,10 +1441,10 @@ var InvitationsHandler = class {
|
|
|
1433
1441
|
});
|
|
1434
1442
|
} else {
|
|
1435
1443
|
log5.error("failed", err, {
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1444
|
+
F: __dxlog_file5,
|
|
1445
|
+
L: 150,
|
|
1446
|
+
S: this,
|
|
1447
|
+
C: (f, a) => f(...a)
|
|
1440
1448
|
});
|
|
1441
1449
|
stream.error(err);
|
|
1442
1450
|
}
|
|
@@ -1444,10 +1452,10 @@ var InvitationsHandler = class {
|
|
|
1444
1452
|
id: traceId,
|
|
1445
1453
|
error: err
|
|
1446
1454
|
}), {
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1455
|
+
F: __dxlog_file5,
|
|
1456
|
+
L: 153,
|
|
1457
|
+
S: this,
|
|
1458
|
+
C: (f, a) => f(...a)
|
|
1451
1459
|
});
|
|
1452
1460
|
} finally {
|
|
1453
1461
|
if (type !== Invitation3.Type.MULTIUSE) {
|
|
@@ -1465,10 +1473,10 @@ var InvitationsHandler = class {
|
|
|
1465
1473
|
log5("timeout", {
|
|
1466
1474
|
...protocol.toJSON()
|
|
1467
1475
|
}, {
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1476
|
+
F: __dxlog_file5,
|
|
1477
|
+
L: 168,
|
|
1478
|
+
S: this,
|
|
1479
|
+
C: (f, a) => f(...a)
|
|
1472
1480
|
});
|
|
1473
1481
|
stream.next({
|
|
1474
1482
|
...invitation,
|
|
@@ -1476,10 +1484,10 @@ var InvitationsHandler = class {
|
|
|
1476
1484
|
});
|
|
1477
1485
|
} else {
|
|
1478
1486
|
log5.error("failed", err, {
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1487
|
+
F: __dxlog_file5,
|
|
1488
|
+
L: 171,
|
|
1489
|
+
S: this,
|
|
1490
|
+
C: (f, a) => f(...a)
|
|
1483
1491
|
});
|
|
1484
1492
|
stream.error(err);
|
|
1485
1493
|
}
|
|
@@ -1519,13 +1527,13 @@ var InvitationsHandler = class {
|
|
|
1519
1527
|
}
|
|
1520
1528
|
acceptInvitation(protocol, invitation) {
|
|
1521
1529
|
const { timeout = INVITATION_TIMEOUT } = invitation;
|
|
1522
|
-
|
|
1530
|
+
invariant6(protocol);
|
|
1523
1531
|
const authenticated = new Trigger3();
|
|
1524
1532
|
let admitted = false;
|
|
1525
1533
|
let currentState;
|
|
1526
1534
|
const stream = new PushStream();
|
|
1527
1535
|
const setState = (newData) => {
|
|
1528
|
-
|
|
1536
|
+
invariant6(newData.state !== void 0);
|
|
1529
1537
|
currentState = newData.state;
|
|
1530
1538
|
stream.next({
|
|
1531
1539
|
...invitation,
|
|
@@ -1538,20 +1546,20 @@ var InvitationsHandler = class {
|
|
|
1538
1546
|
log5("timeout", {
|
|
1539
1547
|
...protocol.toJSON()
|
|
1540
1548
|
}, {
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1549
|
+
F: __dxlog_file5,
|
|
1550
|
+
L: 230,
|
|
1551
|
+
S: this,
|
|
1552
|
+
C: (f, a) => f(...a)
|
|
1545
1553
|
});
|
|
1546
1554
|
setState({
|
|
1547
1555
|
state: Invitation3.State.TIMEOUT
|
|
1548
1556
|
});
|
|
1549
1557
|
} else {
|
|
1550
1558
|
log5.warn("auth failed", err, {
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1559
|
+
F: __dxlog_file5,
|
|
1560
|
+
L: 233,
|
|
1561
|
+
S: this,
|
|
1562
|
+
C: (f, a) => f(...a)
|
|
1555
1563
|
});
|
|
1556
1564
|
stream.error(err);
|
|
1557
1565
|
}
|
|
@@ -1562,10 +1570,10 @@ var InvitationsHandler = class {
|
|
|
1562
1570
|
log5("complete", {
|
|
1563
1571
|
...protocol.toJSON()
|
|
1564
1572
|
}, {
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1573
|
+
F: __dxlog_file5,
|
|
1574
|
+
L: 241,
|
|
1575
|
+
S: this,
|
|
1576
|
+
C: (f, a) => f(...a)
|
|
1569
1577
|
});
|
|
1570
1578
|
stream.complete();
|
|
1571
1579
|
});
|
|
@@ -1577,10 +1585,10 @@ var InvitationsHandler = class {
|
|
|
1577
1585
|
log5("extension disposed", {
|
|
1578
1586
|
currentState
|
|
1579
1587
|
}, {
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1588
|
+
F: __dxlog_file5,
|
|
1589
|
+
L: 251,
|
|
1590
|
+
S: this,
|
|
1591
|
+
C: (f, a) => f(...a)
|
|
1584
1592
|
});
|
|
1585
1593
|
if (!admitted) {
|
|
1586
1594
|
stream.error(new Error("Remote peer disconnected."));
|
|
@@ -1592,10 +1600,10 @@ var InvitationsHandler = class {
|
|
|
1592
1600
|
log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace3.begin({
|
|
1593
1601
|
id: traceId
|
|
1594
1602
|
}), {
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1603
|
+
F: __dxlog_file5,
|
|
1604
|
+
L: 260,
|
|
1605
|
+
S: this,
|
|
1606
|
+
C: (f, a) => f(...a)
|
|
1599
1607
|
});
|
|
1600
1608
|
if (++connectionCount > 1) {
|
|
1601
1609
|
throw new Error(`multiple connections detected: ${connectionCount}`);
|
|
@@ -1604,10 +1612,10 @@ var InvitationsHandler = class {
|
|
|
1604
1612
|
log5("connected", {
|
|
1605
1613
|
...protocol.toJSON()
|
|
1606
1614
|
}, {
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1615
|
+
F: __dxlog_file5,
|
|
1616
|
+
L: 268,
|
|
1617
|
+
S: this,
|
|
1618
|
+
C: (f, a) => f(...a)
|
|
1611
1619
|
});
|
|
1612
1620
|
setState({
|
|
1613
1621
|
state: Invitation3.State.CONNECTED
|
|
@@ -1615,20 +1623,20 @@ var InvitationsHandler = class {
|
|
|
1615
1623
|
log5("introduce", {
|
|
1616
1624
|
...protocol.toJSON()
|
|
1617
1625
|
}, {
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1626
|
+
F: __dxlog_file5,
|
|
1627
|
+
L: 272,
|
|
1628
|
+
S: this,
|
|
1629
|
+
C: (f, a) => f(...a)
|
|
1622
1630
|
});
|
|
1623
1631
|
const introductionResponse = await extension.rpc.InvitationHostService.introduce(protocol.createIntroduction());
|
|
1624
1632
|
log5("introduce response", {
|
|
1625
1633
|
...protocol.toJSON(),
|
|
1626
1634
|
response: introductionResponse
|
|
1627
1635
|
}, {
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1636
|
+
F: __dxlog_file5,
|
|
1637
|
+
L: 276,
|
|
1638
|
+
S: this,
|
|
1639
|
+
C: (f, a) => f(...a)
|
|
1632
1640
|
});
|
|
1633
1641
|
invitation.authMethod = introductionResponse.authMethod;
|
|
1634
1642
|
if (introductionResponse.spaceKey) {
|
|
@@ -1636,11 +1644,11 @@ var InvitationsHandler = class {
|
|
|
1636
1644
|
}
|
|
1637
1645
|
if (isAuthenticationRequired(invitation)) {
|
|
1638
1646
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1639
|
-
log5("guest waiting for authentication code...",
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1647
|
+
log5("guest waiting for authentication code...", void 0, {
|
|
1648
|
+
F: __dxlog_file5,
|
|
1649
|
+
L: 285,
|
|
1650
|
+
S: this,
|
|
1651
|
+
C: (f, a) => f(...a)
|
|
1644
1652
|
});
|
|
1645
1653
|
setState({
|
|
1646
1654
|
state: Invitation3.State.READY_FOR_AUTHENTICATION
|
|
@@ -1648,11 +1656,11 @@ var InvitationsHandler = class {
|
|
|
1648
1656
|
const authCode = await authenticated.wait({
|
|
1649
1657
|
timeout
|
|
1650
1658
|
});
|
|
1651
|
-
log5("sending authentication request",
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1659
|
+
log5("sending authentication request", void 0, {
|
|
1660
|
+
F: __dxlog_file5,
|
|
1661
|
+
L: 289,
|
|
1662
|
+
S: this,
|
|
1663
|
+
C: (f, a) => f(...a)
|
|
1656
1664
|
});
|
|
1657
1665
|
setState({
|
|
1658
1666
|
state: Invitation3.State.AUTHENTICATING
|
|
@@ -1670,10 +1678,10 @@ var InvitationsHandler = class {
|
|
|
1670
1678
|
log5("retrying invalid code", {
|
|
1671
1679
|
attempt
|
|
1672
1680
|
}, {
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1681
|
+
F: __dxlog_file5,
|
|
1682
|
+
L: 300,
|
|
1683
|
+
S: this,
|
|
1684
|
+
C: (f, a) => f(...a)
|
|
1677
1685
|
});
|
|
1678
1686
|
authenticated.reset();
|
|
1679
1687
|
}
|
|
@@ -1687,10 +1695,10 @@ var InvitationsHandler = class {
|
|
|
1687
1695
|
log5("request admission", {
|
|
1688
1696
|
...protocol.toJSON()
|
|
1689
1697
|
}, {
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1698
|
+
F: __dxlog_file5,
|
|
1699
|
+
L: 311,
|
|
1700
|
+
S: this,
|
|
1701
|
+
C: (f, a) => f(...a)
|
|
1694
1702
|
});
|
|
1695
1703
|
const admissionRequest = await protocol.createAdmissionRequest();
|
|
1696
1704
|
const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
|
|
@@ -1699,10 +1707,10 @@ var InvitationsHandler = class {
|
|
|
1699
1707
|
log5("admitted by host", {
|
|
1700
1708
|
...protocol.toJSON()
|
|
1701
1709
|
}, {
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1710
|
+
F: __dxlog_file5,
|
|
1711
|
+
L: 322,
|
|
1712
|
+
S: this,
|
|
1713
|
+
C: (f, a) => f(...a)
|
|
1706
1714
|
});
|
|
1707
1715
|
setState({
|
|
1708
1716
|
...result,
|
|
@@ -1711,30 +1719,30 @@ var InvitationsHandler = class {
|
|
|
1711
1719
|
log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace3.end({
|
|
1712
1720
|
id: traceId
|
|
1713
1721
|
}), {
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1722
|
+
F: __dxlog_file5,
|
|
1723
|
+
L: 324,
|
|
1724
|
+
S: this,
|
|
1725
|
+
C: (f, a) => f(...a)
|
|
1718
1726
|
});
|
|
1719
1727
|
} catch (err) {
|
|
1720
1728
|
if (err instanceof TimeoutError) {
|
|
1721
1729
|
log5("timeout", {
|
|
1722
1730
|
...protocol.toJSON()
|
|
1723
1731
|
}, {
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1732
|
+
F: __dxlog_file5,
|
|
1733
|
+
L: 327,
|
|
1734
|
+
S: this,
|
|
1735
|
+
C: (f, a) => f(...a)
|
|
1728
1736
|
});
|
|
1729
1737
|
setState({
|
|
1730
1738
|
state: Invitation3.State.TIMEOUT
|
|
1731
1739
|
});
|
|
1732
1740
|
} else {
|
|
1733
1741
|
log5("auth failed", err, {
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1742
|
+
F: __dxlog_file5,
|
|
1743
|
+
L: 330,
|
|
1744
|
+
S: this,
|
|
1745
|
+
C: (f, a) => f(...a)
|
|
1738
1746
|
});
|
|
1739
1747
|
stream.error(err);
|
|
1740
1748
|
}
|
|
@@ -1742,10 +1750,10 @@ var InvitationsHandler = class {
|
|
|
1742
1750
|
id: traceId,
|
|
1743
1751
|
error: err
|
|
1744
1752
|
}), {
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1753
|
+
F: __dxlog_file5,
|
|
1754
|
+
L: 333,
|
|
1755
|
+
S: this,
|
|
1756
|
+
C: (f, a) => f(...a)
|
|
1749
1757
|
});
|
|
1750
1758
|
} finally {
|
|
1751
1759
|
await ctx.dispose();
|
|
@@ -1760,20 +1768,20 @@ var InvitationsHandler = class {
|
|
|
1760
1768
|
log5("timeout", {
|
|
1761
1769
|
...protocol.toJSON()
|
|
1762
1770
|
}, {
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1771
|
+
F: __dxlog_file5,
|
|
1772
|
+
L: 344,
|
|
1773
|
+
S: this,
|
|
1774
|
+
C: (f, a) => f(...a)
|
|
1767
1775
|
});
|
|
1768
1776
|
setState({
|
|
1769
1777
|
state: Invitation3.State.TIMEOUT
|
|
1770
1778
|
});
|
|
1771
1779
|
} else {
|
|
1772
1780
|
log5("auth failed", err, {
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1781
|
+
F: __dxlog_file5,
|
|
1782
|
+
L: 347,
|
|
1783
|
+
S: this,
|
|
1784
|
+
C: (f, a) => f(...a)
|
|
1777
1785
|
});
|
|
1778
1786
|
stream.error(err);
|
|
1779
1787
|
}
|
|
@@ -1782,7 +1790,7 @@ var InvitationsHandler = class {
|
|
|
1782
1790
|
return extension;
|
|
1783
1791
|
};
|
|
1784
1792
|
scheduleTask2(ctx, async () => {
|
|
1785
|
-
|
|
1793
|
+
invariant6(invitation.swarmKey);
|
|
1786
1794
|
const topic = invitation.swarmKey;
|
|
1787
1795
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1788
1796
|
topic,
|
|
@@ -1815,11 +1823,12 @@ var InvitationsHandler = class {
|
|
|
1815
1823
|
};
|
|
1816
1824
|
|
|
1817
1825
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
1818
|
-
import
|
|
1826
|
+
import invariant7 from "tiny-invariant";
|
|
1819
1827
|
import { Event as Event3 } from "@dxos/async";
|
|
1820
1828
|
import { Stream as Stream8 } from "@dxos/codec-protobuf";
|
|
1821
1829
|
import { log as log6 } from "@dxos/log";
|
|
1822
1830
|
import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
|
|
1831
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
1823
1832
|
var InvitationsServiceImpl = class {
|
|
1824
1833
|
constructor(_invitationsHandler, _getHandler) {
|
|
1825
1834
|
this._invitationsHandler = _invitationsHandler;
|
|
@@ -1880,35 +1889,35 @@ var InvitationsServiceImpl = class {
|
|
|
1880
1889
|
});
|
|
1881
1890
|
}
|
|
1882
1891
|
async authenticate({ invitationId, authCode }) {
|
|
1883
|
-
log6("authenticating...",
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1892
|
+
log6("authenticating...", void 0, {
|
|
1893
|
+
F: __dxlog_file6,
|
|
1894
|
+
L: 103,
|
|
1895
|
+
S: this,
|
|
1896
|
+
C: (f, a) => f(...a)
|
|
1888
1897
|
});
|
|
1889
|
-
|
|
1898
|
+
invariant7(invitationId);
|
|
1890
1899
|
const observable = this._acceptInvitations.get(invitationId);
|
|
1891
1900
|
if (!observable) {
|
|
1892
1901
|
log6.warn("invalid invitation", {
|
|
1893
1902
|
invitationId
|
|
1894
1903
|
}, {
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1904
|
+
F: __dxlog_file6,
|
|
1905
|
+
L: 107,
|
|
1906
|
+
S: this,
|
|
1907
|
+
C: (f, a) => f(...a)
|
|
1899
1908
|
});
|
|
1900
1909
|
} else {
|
|
1901
1910
|
await observable.authenticate(authCode);
|
|
1902
1911
|
}
|
|
1903
1912
|
}
|
|
1904
1913
|
async cancelInvitation({ invitationId }) {
|
|
1905
|
-
log6("deleting...",
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1914
|
+
log6("deleting...", void 0, {
|
|
1915
|
+
F: __dxlog_file6,
|
|
1916
|
+
L: 114,
|
|
1917
|
+
S: this,
|
|
1918
|
+
C: (f, a) => f(...a)
|
|
1910
1919
|
});
|
|
1911
|
-
|
|
1920
|
+
invariant7(invitationId);
|
|
1912
1921
|
const created = this._createInvitations.get(invitationId);
|
|
1913
1922
|
const accepted = this._acceptInvitations.get(invitationId);
|
|
1914
1923
|
if (created) {
|
|
@@ -1923,10 +1932,10 @@ var InvitationsServiceImpl = class {
|
|
|
1923
1932
|
log6.warn("invalid invitation", {
|
|
1924
1933
|
invitationId
|
|
1925
1934
|
}, {
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1935
|
+
F: __dxlog_file6,
|
|
1936
|
+
L: 127,
|
|
1937
|
+
S: this,
|
|
1938
|
+
C: (f, a) => f(...a)
|
|
1930
1939
|
});
|
|
1931
1940
|
}
|
|
1932
1941
|
}
|
|
@@ -1983,11 +1992,12 @@ var InvitationsServiceImpl = class {
|
|
|
1983
1992
|
};
|
|
1984
1993
|
|
|
1985
1994
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
1986
|
-
import
|
|
1995
|
+
import invariant8 from "tiny-invariant";
|
|
1987
1996
|
import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/credentials";
|
|
1988
1997
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
1989
1998
|
import { log as log7 } from "@dxos/log";
|
|
1990
1999
|
import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2000
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
1991
2001
|
var SpaceInvitationProtocol = class {
|
|
1992
2002
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
1993
2003
|
this._spaceManager = _spaceManager;
|
|
@@ -2009,24 +2019,24 @@ var SpaceInvitationProtocol = class {
|
|
|
2009
2019
|
}
|
|
2010
2020
|
async admit(request, guestProfile) {
|
|
2011
2021
|
var _a;
|
|
2012
|
-
|
|
2022
|
+
invariant8(this._spaceKey);
|
|
2013
2023
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2014
|
-
|
|
2015
|
-
|
|
2024
|
+
invariant8(space);
|
|
2025
|
+
invariant8(request.space);
|
|
2016
2026
|
const { identityKey, deviceKey } = request.space;
|
|
2017
2027
|
log7("writing guest credentials", {
|
|
2018
2028
|
host: this._signingContext.deviceKey,
|
|
2019
2029
|
guest: deviceKey
|
|
2020
2030
|
}, {
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2031
|
+
F: __dxlog_file7,
|
|
2032
|
+
L: 50,
|
|
2033
|
+
S: this,
|
|
2034
|
+
C: (f, a) => f(...a)
|
|
2025
2035
|
});
|
|
2026
2036
|
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2027
|
-
|
|
2037
|
+
invariant8(credentials[0].credential);
|
|
2028
2038
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2029
|
-
|
|
2039
|
+
invariant8(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2030
2040
|
await writeMessages2(space.inner.controlPipeline.writer, credentials);
|
|
2031
2041
|
return {
|
|
2032
2042
|
space: {
|
|
@@ -2054,11 +2064,11 @@ var SpaceInvitationProtocol = class {
|
|
|
2054
2064
|
};
|
|
2055
2065
|
}
|
|
2056
2066
|
async accept(response) {
|
|
2057
|
-
|
|
2067
|
+
invariant8(response.space);
|
|
2058
2068
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2059
2069
|
const assertion = getCredentialAssertion(credential);
|
|
2060
|
-
|
|
2061
|
-
|
|
2070
|
+
invariant8(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
|
|
2071
|
+
invariant8(credential.subject.id.equals(this._signingContext.identityKey));
|
|
2062
2072
|
await this._spaceManager.acceptSpace({
|
|
2063
2073
|
spaceKey: assertion.spaceKey,
|
|
2064
2074
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
@@ -2073,7 +2083,7 @@ var SpaceInvitationProtocol = class {
|
|
|
2073
2083
|
};
|
|
2074
2084
|
|
|
2075
2085
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2076
|
-
import { Event as Event5, scheduleTask as scheduleTask4, trackLeaks } from "@dxos/async";
|
|
2086
|
+
import { Event as Event5, scheduleTask as scheduleTask4, synchronized, trackLeaks } from "@dxos/async";
|
|
2077
2087
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
2078
2088
|
import { cancelWithContext as cancelWithContext2, Context as Context6 } from "@dxos/context";
|
|
2079
2089
|
import { timed } from "@dxos/debug";
|
|
@@ -2087,7 +2097,7 @@ import { Timeframe } from "@dxos/timeframe";
|
|
|
2087
2097
|
import { ComplexSet as ComplexSet2 } from "@dxos/util";
|
|
2088
2098
|
|
|
2089
2099
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2090
|
-
import
|
|
2100
|
+
import invariant9 from "tiny-invariant";
|
|
2091
2101
|
import { DeferredTask, Event as Event4, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
|
|
2092
2102
|
import { Context as Context5, rejectOnDispose } from "@dxos/context";
|
|
2093
2103
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
@@ -2095,6 +2105,7 @@ import { log as log8 } from "@dxos/log";
|
|
|
2095
2105
|
import { schema as schema3 } from "@dxos/protocols";
|
|
2096
2106
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
2097
2107
|
import { ComplexMap as ComplexMap2, ComplexSet, entry } from "@dxos/util";
|
|
2108
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
2098
2109
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
2099
2110
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
2100
2111
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -2107,6 +2118,9 @@ var NotarizationPlugin = class {
|
|
|
2107
2118
|
this._processedCredentials = new ComplexSet(PublicKey6.hash);
|
|
2108
2119
|
this._processCredentialsTriggers = new ComplexMap2(PublicKey6.hash);
|
|
2109
2120
|
}
|
|
2121
|
+
get hasWriter() {
|
|
2122
|
+
return !!this._writer;
|
|
2123
|
+
}
|
|
2110
2124
|
async open() {
|
|
2111
2125
|
}
|
|
2112
2126
|
async close() {
|
|
@@ -2119,22 +2133,22 @@ var NotarizationPlugin = class {
|
|
|
2119
2133
|
log8("notarize", {
|
|
2120
2134
|
credentials
|
|
2121
2135
|
}, {
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2136
|
+
F: __dxlog_file8,
|
|
2137
|
+
L: 91,
|
|
2138
|
+
S: this,
|
|
2139
|
+
C: (f, a) => f(...a)
|
|
2126
2140
|
});
|
|
2127
|
-
|
|
2141
|
+
invariant9(credentials.every((credential) => credential.id), "Credentials must have an id");
|
|
2128
2142
|
const errors = new Trigger4();
|
|
2129
2143
|
const ctx = this._ctx.derive({
|
|
2130
2144
|
onError: (err) => {
|
|
2131
2145
|
log8.warn("Notarization error", {
|
|
2132
2146
|
err
|
|
2133
2147
|
}, {
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2148
|
+
F: __dxlog_file8,
|
|
2149
|
+
L: 100,
|
|
2150
|
+
S: this,
|
|
2151
|
+
C: (f, a) => f(...a)
|
|
2138
2152
|
});
|
|
2139
2153
|
void ctx.dispose();
|
|
2140
2154
|
errors.throw(err);
|
|
@@ -2147,10 +2161,10 @@ var NotarizationPlugin = class {
|
|
|
2147
2161
|
timeout,
|
|
2148
2162
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
2149
2163
|
}, {
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2164
|
+
F: __dxlog_file8,
|
|
2165
|
+
L: 112,
|
|
2166
|
+
S: this,
|
|
2167
|
+
C: (f, a) => f(...a)
|
|
2154
2168
|
});
|
|
2155
2169
|
void ctx.dispose();
|
|
2156
2170
|
errors.throw(new TimeoutError2(timeout, "Notarization timed out"));
|
|
@@ -2170,10 +2184,10 @@ var NotarizationPlugin = class {
|
|
|
2170
2184
|
log8.warn("Exhausted all peers to notarize with", {
|
|
2171
2185
|
retryIn: retryTimeout
|
|
2172
2186
|
}, {
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2187
|
+
F: __dxlog_file8,
|
|
2188
|
+
L: 137,
|
|
2189
|
+
S: this,
|
|
2190
|
+
C: (f, a) => f(...a)
|
|
2177
2191
|
});
|
|
2178
2192
|
peersTried.clear();
|
|
2179
2193
|
scheduleTask3(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
@@ -2184,28 +2198,28 @@ var NotarizationPlugin = class {
|
|
|
2184
2198
|
peer: peer.localPeerId,
|
|
2185
2199
|
credentialId: credentials.map((credential) => credential.id)
|
|
2186
2200
|
}, {
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2201
|
+
F: __dxlog_file8,
|
|
2202
|
+
L: 144,
|
|
2203
|
+
S: this,
|
|
2204
|
+
C: (f, a) => f(...a)
|
|
2191
2205
|
});
|
|
2192
2206
|
await peer.rpc.NotarizationService.notarize({
|
|
2193
2207
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
2194
2208
|
});
|
|
2195
|
-
log8("success",
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2209
|
+
log8("success", void 0, {
|
|
2210
|
+
F: __dxlog_file8,
|
|
2211
|
+
L: 148,
|
|
2212
|
+
S: this,
|
|
2213
|
+
C: (f, a) => f(...a)
|
|
2200
2214
|
});
|
|
2201
2215
|
await sleep(successDelay);
|
|
2202
2216
|
} catch (err) {
|
|
2203
2217
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
2204
2218
|
log8.warn("error notarizing (recoverable)", err, {
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2219
|
+
F: __dxlog_file8,
|
|
2220
|
+
L: 152,
|
|
2221
|
+
S: this,
|
|
2222
|
+
C: (f, a) => f(...a)
|
|
2209
2223
|
});
|
|
2210
2224
|
}
|
|
2211
2225
|
notarizeTask.schedule();
|
|
@@ -2219,11 +2233,11 @@ var NotarizationPlugin = class {
|
|
|
2219
2233
|
allNotarized,
|
|
2220
2234
|
errors.wait()
|
|
2221
2235
|
]);
|
|
2222
|
-
log8("done",
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2236
|
+
log8("done", void 0, {
|
|
2237
|
+
F: __dxlog_file8,
|
|
2238
|
+
L: 163,
|
|
2239
|
+
S: this,
|
|
2240
|
+
C: (f, a) => f(...a)
|
|
2227
2241
|
});
|
|
2228
2242
|
} finally {
|
|
2229
2243
|
await ctx.dispose();
|
|
@@ -2232,7 +2246,7 @@ var NotarizationPlugin = class {
|
|
|
2232
2246
|
/**
|
|
2233
2247
|
* Called with credentials arriving from the control pipeline.
|
|
2234
2248
|
*/
|
|
2235
|
-
async
|
|
2249
|
+
async processCredential(credential) {
|
|
2236
2250
|
var _a;
|
|
2237
2251
|
if (!credential.id) {
|
|
2238
2252
|
return;
|
|
@@ -2242,7 +2256,7 @@ var NotarizationPlugin = class {
|
|
|
2242
2256
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2243
2257
|
}
|
|
2244
2258
|
setWriter(writer) {
|
|
2245
|
-
|
|
2259
|
+
invariant9(!this._writer, "Writer already set.");
|
|
2246
2260
|
this._writer = writer;
|
|
2247
2261
|
}
|
|
2248
2262
|
async _waitUntilProcessed(id) {
|
|
@@ -2260,7 +2274,7 @@ var NotarizationPlugin = class {
|
|
|
2260
2274
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2261
2275
|
}
|
|
2262
2276
|
for (const credential of (_a = request.credentials) != null ? _a : []) {
|
|
2263
|
-
|
|
2277
|
+
invariant9(credential.id, "Credential must have an id");
|
|
2264
2278
|
if (this._processedCredentials.has(credential.id)) {
|
|
2265
2279
|
continue;
|
|
2266
2280
|
}
|
|
@@ -2273,10 +2287,10 @@ var NotarizationPlugin = class {
|
|
|
2273
2287
|
log8("extension opened", {
|
|
2274
2288
|
peer: extension.localPeerId
|
|
2275
2289
|
}, {
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2290
|
+
F: __dxlog_file8,
|
|
2291
|
+
L: 212,
|
|
2292
|
+
S: this,
|
|
2293
|
+
C: (f, a) => f(...a)
|
|
2280
2294
|
});
|
|
2281
2295
|
this._extensions.add(extension);
|
|
2282
2296
|
this._extensionOpened.emit();
|
|
@@ -2285,10 +2299,10 @@ var NotarizationPlugin = class {
|
|
|
2285
2299
|
log8("extension closed", {
|
|
2286
2300
|
peer: extension.localPeerId
|
|
2287
2301
|
}, {
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2302
|
+
F: __dxlog_file8,
|
|
2303
|
+
L: 217,
|
|
2304
|
+
S: this,
|
|
2305
|
+
C: (f, a) => f(...a)
|
|
2292
2306
|
});
|
|
2293
2307
|
this._extensions.delete(extension);
|
|
2294
2308
|
},
|
|
@@ -2329,7 +2343,7 @@ var NotarizationTeleportExtension = class extends RpcExtension2 {
|
|
|
2329
2343
|
};
|
|
2330
2344
|
|
|
2331
2345
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2332
|
-
|
|
2346
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
2333
2347
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2334
2348
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2335
2349
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2338,10 +2352,12 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
2338
2352
|
if (d = decorators[i])
|
|
2339
2353
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2340
2354
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2341
|
-
}
|
|
2355
|
+
}
|
|
2356
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2342
2357
|
var DataSpace = class DataSpace2 {
|
|
2343
2358
|
constructor(params) {
|
|
2344
2359
|
this._ctx = new Context6();
|
|
2360
|
+
this._notarizationPlugin = new NotarizationPlugin();
|
|
2345
2361
|
this._state = SpaceState.CLOSED;
|
|
2346
2362
|
/**
|
|
2347
2363
|
* Error for _state === SpaceState.ERROR.
|
|
@@ -2364,8 +2380,8 @@ var DataSpace = class DataSpace2 {
|
|
|
2364
2380
|
update: this._inner.stateUpdate,
|
|
2365
2381
|
authTimeout: AUTH_TIMEOUT2
|
|
2366
2382
|
});
|
|
2367
|
-
this._notarizationPluginConsumer = this._inner.spaceState.registerProcessor(new NotarizationPlugin());
|
|
2368
2383
|
this._cache = params.cache;
|
|
2384
|
+
this._state = params.initialState;
|
|
2369
2385
|
}
|
|
2370
2386
|
get key() {
|
|
2371
2387
|
return this._inner.key;
|
|
@@ -2387,25 +2403,36 @@ var DataSpace = class DataSpace2 {
|
|
|
2387
2403
|
return this._presence;
|
|
2388
2404
|
}
|
|
2389
2405
|
get notarizationPlugin() {
|
|
2390
|
-
return this.
|
|
2406
|
+
return this._notarizationPlugin;
|
|
2391
2407
|
}
|
|
2392
2408
|
get cache() {
|
|
2393
2409
|
return this._cache;
|
|
2394
2410
|
}
|
|
2395
2411
|
async open() {
|
|
2396
|
-
await this.
|
|
2397
|
-
|
|
2412
|
+
await this._open();
|
|
2413
|
+
}
|
|
2414
|
+
async _open() {
|
|
2415
|
+
await this._notarizationPlugin.open();
|
|
2416
|
+
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
2398
2417
|
await this._inner.open();
|
|
2399
|
-
this._state = SpaceState.
|
|
2418
|
+
this._state = SpaceState.CONTROL_ONLY;
|
|
2419
|
+
this.stateUpdate.emit();
|
|
2420
|
+
this.metrics = {};
|
|
2400
2421
|
this.metrics.open = new Date();
|
|
2401
2422
|
}
|
|
2402
2423
|
async close() {
|
|
2424
|
+
await this._close();
|
|
2425
|
+
}
|
|
2426
|
+
async _close() {
|
|
2427
|
+
var _a, _b;
|
|
2428
|
+
await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
|
|
2403
2429
|
this._state = SpaceState.CLOSED;
|
|
2404
2430
|
await this._ctx.dispose();
|
|
2431
|
+
this._ctx = new Context6();
|
|
2405
2432
|
await this.authVerifier.close();
|
|
2406
2433
|
await this._inner.close();
|
|
2407
|
-
await this.
|
|
2408
|
-
await this.
|
|
2434
|
+
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
2435
|
+
await this._notarizationPlugin.close();
|
|
2409
2436
|
await this._presence.destroy();
|
|
2410
2437
|
}
|
|
2411
2438
|
async postMessage(channel, message) {
|
|
@@ -2425,18 +2452,18 @@ var DataSpace = class DataSpace2 {
|
|
|
2425
2452
|
} catch (err) {
|
|
2426
2453
|
if (err instanceof CancelledError) {
|
|
2427
2454
|
log9("Data pipeline initialization cancelled", err, {
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2455
|
+
F: __dxlog_file9,
|
|
2456
|
+
L: 193,
|
|
2457
|
+
S: this,
|
|
2458
|
+
C: (f, a) => f(...a)
|
|
2432
2459
|
});
|
|
2433
2460
|
return;
|
|
2434
2461
|
}
|
|
2435
2462
|
log9.error("Error initializing data pipeline", err, {
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2463
|
+
F: __dxlog_file9,
|
|
2464
|
+
L: 197,
|
|
2465
|
+
S: this,
|
|
2466
|
+
C: (f, a) => f(...a)
|
|
2440
2467
|
});
|
|
2441
2468
|
this._state = SpaceState.ERROR;
|
|
2442
2469
|
this.error = err;
|
|
@@ -2448,7 +2475,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2448
2475
|
}
|
|
2449
2476
|
async initializeDataPipeline() {
|
|
2450
2477
|
var _a, _b, _c, _d;
|
|
2451
|
-
if (this._state !== SpaceState.
|
|
2478
|
+
if (this._state !== SpaceState.CONTROL_ONLY) {
|
|
2452
2479
|
throw new SystemError("Invalid operation");
|
|
2453
2480
|
}
|
|
2454
2481
|
this._state = SpaceState.INITIALIZING;
|
|
@@ -2458,37 +2485,39 @@ var DataSpace = class DataSpace2 {
|
|
|
2458
2485
|
});
|
|
2459
2486
|
this.metrics.controlPipelineReady = new Date();
|
|
2460
2487
|
await this._createWritableFeeds();
|
|
2461
|
-
log9("Writable feeds created",
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2488
|
+
log9("Writable feeds created", void 0, {
|
|
2489
|
+
F: __dxlog_file9,
|
|
2490
|
+
L: 221,
|
|
2491
|
+
S: this,
|
|
2492
|
+
C: (f, a) => f(...a)
|
|
2466
2493
|
});
|
|
2467
2494
|
this.stateUpdate.emit();
|
|
2468
|
-
this.notarizationPlugin.
|
|
2469
|
-
credential
|
|
2470
|
-
credential
|
|
2471
|
-
|
|
2472
|
-
|
|
2495
|
+
if (!this.notarizationPlugin.hasWriter) {
|
|
2496
|
+
this.notarizationPlugin.setWriter(createMappedFeedWriter((credential) => ({
|
|
2497
|
+
credential: {
|
|
2498
|
+
credential
|
|
2499
|
+
}
|
|
2500
|
+
}), this._inner.controlPipeline.writer));
|
|
2501
|
+
}
|
|
2473
2502
|
await this._inner.initializeDataPipeline();
|
|
2474
2503
|
this.metrics.dataPipelineOpen = new Date();
|
|
2475
2504
|
await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
2476
|
-
log9("waiting for data pipeline to reach target timeframe",
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2505
|
+
log9("waiting for data pipeline to reach target timeframe", void 0, {
|
|
2506
|
+
F: __dxlog_file9,
|
|
2507
|
+
L: 242,
|
|
2508
|
+
S: this,
|
|
2509
|
+
C: (f, a) => f(...a)
|
|
2481
2510
|
});
|
|
2482
2511
|
await this._inner.dataPipeline.pipelineState.waitUntilReachedTargetTimeframe({
|
|
2483
2512
|
ctx: this._ctx,
|
|
2484
2513
|
breakOnStall: false
|
|
2485
2514
|
});
|
|
2486
2515
|
this.metrics.dataPipelineReady = new Date();
|
|
2487
|
-
log9("data pipeline ready",
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2516
|
+
log9("data pipeline ready", void 0, {
|
|
2517
|
+
F: __dxlog_file9,
|
|
2518
|
+
L: 251,
|
|
2519
|
+
S: this,
|
|
2520
|
+
C: (f, a) => f(...a)
|
|
2492
2521
|
});
|
|
2493
2522
|
await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
|
|
2494
2523
|
this._state = SpaceState.READY;
|
|
@@ -2566,17 +2595,46 @@ var DataSpace = class DataSpace2 {
|
|
|
2566
2595
|
}
|
|
2567
2596
|
}
|
|
2568
2597
|
}
|
|
2598
|
+
async activate() {
|
|
2599
|
+
if (this._state !== SpaceState.INACTIVE) {
|
|
2600
|
+
throw new SystemError("Invalid operation");
|
|
2601
|
+
}
|
|
2602
|
+
await this._metadataStore.setSpaceState(this.key, SpaceState.ACTIVE);
|
|
2603
|
+
await this._open();
|
|
2604
|
+
this.initializeDataPipelineAsync();
|
|
2605
|
+
}
|
|
2606
|
+
async deactivate() {
|
|
2607
|
+
if (this._state === SpaceState.INACTIVE) {
|
|
2608
|
+
throw new SystemError("Invalid operation");
|
|
2609
|
+
}
|
|
2610
|
+
await this._metadataStore.setSpaceState(this.key, SpaceState.INACTIVE);
|
|
2611
|
+
await this._close();
|
|
2612
|
+
this._state = SpaceState.INACTIVE;
|
|
2613
|
+
this.stateUpdate.emit();
|
|
2614
|
+
}
|
|
2569
2615
|
};
|
|
2570
|
-
|
|
2616
|
+
_ts_decorate([
|
|
2617
|
+
synchronized
|
|
2618
|
+
], DataSpace.prototype, "open", null);
|
|
2619
|
+
_ts_decorate([
|
|
2620
|
+
synchronized
|
|
2621
|
+
], DataSpace.prototype, "close", null);
|
|
2622
|
+
_ts_decorate([
|
|
2571
2623
|
timed(1e4)
|
|
2572
2624
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2573
|
-
|
|
2625
|
+
_ts_decorate([
|
|
2626
|
+
synchronized
|
|
2627
|
+
], DataSpace.prototype, "activate", null);
|
|
2628
|
+
_ts_decorate([
|
|
2629
|
+
synchronized
|
|
2630
|
+
], DataSpace.prototype, "deactivate", null);
|
|
2631
|
+
DataSpace = _ts_decorate([
|
|
2574
2632
|
trackLeaks("open", "close")
|
|
2575
2633
|
], DataSpace);
|
|
2576
2634
|
|
|
2577
2635
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2578
|
-
import
|
|
2579
|
-
import { Event as Event6, synchronized, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
2636
|
+
import invariant10 from "tiny-invariant";
|
|
2637
|
+
import { Event as Event6, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
2580
2638
|
import { cancelWithContext as cancelWithContext3, Context as Context7 } from "@dxos/context";
|
|
2581
2639
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
2582
2640
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
@@ -2657,7 +2715,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2657
2715
|
};
|
|
2658
2716
|
|
|
2659
2717
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2660
|
-
|
|
2718
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
2661
2719
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2662
2720
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2663
2721
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2666,7 +2724,8 @@ var __decorate2 = function(decorators, target, key, desc) {
|
|
|
2666
2724
|
if (d = decorators[i])
|
|
2667
2725
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2668
2726
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2669
|
-
}
|
|
2727
|
+
}
|
|
2728
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
2670
2729
|
var DataSpaceManager = class DataSpaceManager2 {
|
|
2671
2730
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
|
|
2672
2731
|
this._spaceManager = _spaceManager;
|
|
@@ -2686,50 +2745,52 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2686
2745
|
return this._spaces;
|
|
2687
2746
|
}
|
|
2688
2747
|
async open() {
|
|
2689
|
-
log10("open",
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2748
|
+
log10("open", void 0, {
|
|
2749
|
+
F: __dxlog_file10,
|
|
2750
|
+
L: 80,
|
|
2751
|
+
S: this,
|
|
2752
|
+
C: (f, a) => f(...a)
|
|
2694
2753
|
});
|
|
2695
2754
|
log10.trace("dxos.echo.data-space-manager.open", trace4.begin({
|
|
2696
2755
|
id: this._instanceId
|
|
2697
2756
|
}), {
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2757
|
+
F: __dxlog_file10,
|
|
2758
|
+
L: 81,
|
|
2759
|
+
S: this,
|
|
2760
|
+
C: (f, a) => f(...a)
|
|
2702
2761
|
});
|
|
2703
2762
|
await this._metadataStore.load();
|
|
2704
2763
|
log10("metadata loaded", {
|
|
2705
2764
|
spaces: this._metadataStore.spaces.length
|
|
2706
2765
|
}, {
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2766
|
+
F: __dxlog_file10,
|
|
2767
|
+
L: 83,
|
|
2768
|
+
S: this,
|
|
2769
|
+
C: (f, a) => f(...a)
|
|
2711
2770
|
});
|
|
2712
2771
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2713
2772
|
try {
|
|
2714
2773
|
log10("load space", {
|
|
2715
2774
|
spaceMetadata
|
|
2716
2775
|
}, {
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2776
|
+
F: __dxlog_file10,
|
|
2777
|
+
L: 87,
|
|
2778
|
+
S: this,
|
|
2779
|
+
C: (f, a) => f(...a)
|
|
2721
2780
|
});
|
|
2722
2781
|
const space = await this._constructSpace(spaceMetadata);
|
|
2723
|
-
|
|
2782
|
+
if (spaceMetadata.state !== SpaceState2.INACTIVE) {
|
|
2783
|
+
space.initializeDataPipelineAsync();
|
|
2784
|
+
}
|
|
2724
2785
|
} catch (err) {
|
|
2725
2786
|
log10.error("Error loading space", {
|
|
2726
2787
|
spaceMetadata,
|
|
2727
2788
|
err
|
|
2728
2789
|
}, {
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2790
|
+
F: __dxlog_file10,
|
|
2791
|
+
L: 93,
|
|
2792
|
+
S: this,
|
|
2793
|
+
C: (f, a) => f(...a)
|
|
2733
2794
|
});
|
|
2734
2795
|
}
|
|
2735
2796
|
}
|
|
@@ -2738,18 +2799,18 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2738
2799
|
log10.trace("dxos.echo.data-space-manager.open", trace4.end({
|
|
2739
2800
|
id: this._instanceId
|
|
2740
2801
|
}), {
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2802
|
+
F: __dxlog_file10,
|
|
2803
|
+
L: 99,
|
|
2804
|
+
S: this,
|
|
2805
|
+
C: (f, a) => f(...a)
|
|
2745
2806
|
});
|
|
2746
2807
|
}
|
|
2747
2808
|
async close() {
|
|
2748
|
-
log10("close",
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2809
|
+
log10("close", void 0, {
|
|
2810
|
+
F: __dxlog_file10,
|
|
2811
|
+
L: 104,
|
|
2812
|
+
S: this,
|
|
2813
|
+
C: (f, a) => f(...a)
|
|
2753
2814
|
});
|
|
2754
2815
|
this._isOpen = false;
|
|
2755
2816
|
await this._ctx.dispose();
|
|
@@ -2761,7 +2822,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2761
2822
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
2762
2823
|
*/
|
|
2763
2824
|
async createSpace() {
|
|
2764
|
-
|
|
2825
|
+
invariant10(this._isOpen, "Not open.");
|
|
2765
2826
|
const spaceKey = await this._keyring.createKey();
|
|
2766
2827
|
const controlFeedKey = await this._keyring.createKey();
|
|
2767
2828
|
const dataFeedKey = await this._keyring.createKey();
|
|
@@ -2769,21 +2830,22 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2769
2830
|
key: spaceKey,
|
|
2770
2831
|
genesisFeedKey: controlFeedKey,
|
|
2771
2832
|
controlFeedKey,
|
|
2772
|
-
dataFeedKey
|
|
2833
|
+
dataFeedKey,
|
|
2834
|
+
state: SpaceState2.ACTIVE
|
|
2773
2835
|
};
|
|
2774
2836
|
log10("creating space...", {
|
|
2775
2837
|
spaceKey
|
|
2776
2838
|
}, {
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2839
|
+
F: __dxlog_file10,
|
|
2840
|
+
L: 129,
|
|
2841
|
+
S: this,
|
|
2842
|
+
C: (f, a) => f(...a)
|
|
2781
2843
|
});
|
|
2782
2844
|
const space = await this._constructSpace(metadata);
|
|
2783
2845
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
2784
2846
|
await this._metadataStore.addSpace(metadata);
|
|
2785
2847
|
const memberCredential = credentials[1];
|
|
2786
|
-
|
|
2848
|
+
invariant10(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2787
2849
|
await this._signingContext.recordCredential(memberCredential);
|
|
2788
2850
|
await space.initializeDataPipeline();
|
|
2789
2851
|
this.updated.emit();
|
|
@@ -2794,13 +2856,13 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2794
2856
|
log10("accept space", {
|
|
2795
2857
|
opts
|
|
2796
2858
|
}, {
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2859
|
+
F: __dxlog_file10,
|
|
2860
|
+
L: 148,
|
|
2861
|
+
S: this,
|
|
2862
|
+
C: (f, a) => f(...a)
|
|
2801
2863
|
});
|
|
2802
|
-
|
|
2803
|
-
|
|
2864
|
+
invariant10(this._isOpen, "Not open.");
|
|
2865
|
+
invariant10(!this._spaces.has(opts.spaceKey), "Space already exists.");
|
|
2804
2866
|
const metadata = {
|
|
2805
2867
|
key: opts.spaceKey,
|
|
2806
2868
|
genesisFeedKey: opts.genesisFeedKey,
|
|
@@ -2828,10 +2890,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2828
2890
|
log10("construct space", {
|
|
2829
2891
|
metadata
|
|
2830
2892
|
}, {
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2893
|
+
F: __dxlog_file10,
|
|
2894
|
+
L: 183,
|
|
2895
|
+
S: this,
|
|
2896
|
+
C: (f, a) => f(...a)
|
|
2835
2897
|
});
|
|
2836
2898
|
const gossip = new Gossip({
|
|
2837
2899
|
localPeerId: this._signingContext.deviceKey
|
|
@@ -2863,11 +2925,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2863
2925
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
2864
2926
|
},
|
|
2865
2927
|
onAuthFailure: () => {
|
|
2866
|
-
log10.warn("auth failure",
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2928
|
+
log10.warn("auth failure", void 0, {
|
|
2929
|
+
F: __dxlog_file10,
|
|
2930
|
+
L: 214,
|
|
2931
|
+
S: this,
|
|
2932
|
+
C: (f, a) => f(...a)
|
|
2871
2933
|
});
|
|
2872
2934
|
},
|
|
2873
2935
|
memberKey: this._signingContext.identityKey
|
|
@@ -2876,6 +2938,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2876
2938
|
dataFeed && space.setDataFeed(dataFeed);
|
|
2877
2939
|
const dataSpace = new DataSpace({
|
|
2878
2940
|
inner: space,
|
|
2941
|
+
initialState: metadata.state === SpaceState2.INACTIVE ? SpaceState2.INACTIVE : SpaceState2.CLOSED,
|
|
2879
2942
|
metadataStore: this._metadataStore,
|
|
2880
2943
|
gossip,
|
|
2881
2944
|
presence,
|
|
@@ -2887,31 +2950,44 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2887
2950
|
log10("before space ready", {
|
|
2888
2951
|
space: space.key
|
|
2889
2952
|
}, {
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2953
|
+
F: __dxlog_file10,
|
|
2954
|
+
L: 232,
|
|
2955
|
+
S: this,
|
|
2956
|
+
C: (f, a) => f(...a)
|
|
2894
2957
|
});
|
|
2895
|
-
this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2958
|
+
await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2896
2959
|
},
|
|
2897
2960
|
afterReady: async () => {
|
|
2898
2961
|
log10("after space ready", {
|
|
2899
2962
|
space: space.key,
|
|
2900
2963
|
open: this._isOpen
|
|
2901
2964
|
}, {
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2965
|
+
F: __dxlog_file10,
|
|
2966
|
+
L: 239,
|
|
2967
|
+
S: this,
|
|
2968
|
+
C: (f, a) => f(...a)
|
|
2906
2969
|
});
|
|
2907
2970
|
if (this._isOpen) {
|
|
2908
2971
|
this.updated.emit();
|
|
2909
2972
|
}
|
|
2973
|
+
},
|
|
2974
|
+
beforeClose: async () => {
|
|
2975
|
+
log10("before space close", {
|
|
2976
|
+
space: space.key
|
|
2977
|
+
}, {
|
|
2978
|
+
F: __dxlog_file10,
|
|
2979
|
+
L: 245,
|
|
2980
|
+
S: this,
|
|
2981
|
+
C: (f, a) => f(...a)
|
|
2982
|
+
});
|
|
2983
|
+
await this._dataServiceSubscriptions.unregisterSpace(space.key);
|
|
2910
2984
|
}
|
|
2911
2985
|
},
|
|
2912
2986
|
cache: metadata.cache
|
|
2913
2987
|
});
|
|
2914
|
-
|
|
2988
|
+
if (metadata.state !== SpaceState2.INACTIVE) {
|
|
2989
|
+
await dataSpace.open();
|
|
2990
|
+
}
|
|
2915
2991
|
if (metadata.controlTimeframe) {
|
|
2916
2992
|
dataSpace.inner.controlPipeline.state.setTargetTimeframe(metadata.controlTimeframe);
|
|
2917
2993
|
}
|
|
@@ -2922,32 +2998,33 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2922
2998
|
return dataSpace;
|
|
2923
2999
|
}
|
|
2924
3000
|
};
|
|
2925
|
-
|
|
2926
|
-
|
|
3001
|
+
_ts_decorate2([
|
|
3002
|
+
synchronized2
|
|
2927
3003
|
], DataSpaceManager.prototype, "open", null);
|
|
2928
|
-
|
|
2929
|
-
|
|
3004
|
+
_ts_decorate2([
|
|
3005
|
+
synchronized2
|
|
2930
3006
|
], DataSpaceManager.prototype, "close", null);
|
|
2931
|
-
|
|
2932
|
-
|
|
3007
|
+
_ts_decorate2([
|
|
3008
|
+
synchronized2
|
|
2933
3009
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
2934
|
-
|
|
2935
|
-
|
|
3010
|
+
_ts_decorate2([
|
|
3011
|
+
synchronized2
|
|
2936
3012
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
2937
|
-
DataSpaceManager =
|
|
3013
|
+
DataSpaceManager = _ts_decorate2([
|
|
2938
3014
|
trackLeaks2("open", "close")
|
|
2939
3015
|
], DataSpaceManager);
|
|
2940
3016
|
|
|
2941
3017
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
2942
|
-
import { EventSubscriptions as EventSubscriptions2, scheduleTask as scheduleTask5 } from "@dxos/async";
|
|
3018
|
+
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask5 } from "@dxos/async";
|
|
2943
3019
|
import { Stream as Stream9 } from "@dxos/codec-protobuf";
|
|
2944
|
-
import { raise
|
|
3020
|
+
import { raise } from "@dxos/debug";
|
|
2945
3021
|
import { SpaceNotFoundError } from "@dxos/echo-pipeline";
|
|
3022
|
+
import { ApiError } from "@dxos/errors";
|
|
2946
3023
|
import { log as log11 } from "@dxos/log";
|
|
2947
3024
|
import { encodeError } from "@dxos/protocols";
|
|
2948
|
-
import { SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3025
|
+
import { SpaceMember as SpaceMember2, SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2949
3026
|
import { humanize } from "@dxos/util";
|
|
2950
|
-
var
|
|
3027
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
2951
3028
|
var SpacesServiceImpl = class {
|
|
2952
3029
|
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
2953
3030
|
this._identityManager = _identityManager;
|
|
@@ -2961,28 +3038,44 @@ var SpacesServiceImpl = class {
|
|
|
2961
3038
|
}
|
|
2962
3039
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2963
3040
|
const space = await dataSpaceManager.createSpace();
|
|
2964
|
-
return this.
|
|
3041
|
+
return this._serializeSpace(space);
|
|
2965
3042
|
}
|
|
2966
|
-
async updateSpace(
|
|
2967
|
-
|
|
3043
|
+
async updateSpace({ spaceKey, state }) {
|
|
3044
|
+
var _a;
|
|
3045
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3046
|
+
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise(new SpaceNotFoundError(spaceKey));
|
|
3047
|
+
if (state) {
|
|
3048
|
+
switch (state) {
|
|
3049
|
+
case SpaceState3.ACTIVE:
|
|
3050
|
+
await space.activate();
|
|
3051
|
+
break;
|
|
3052
|
+
case SpaceState3.INACTIVE:
|
|
3053
|
+
await space.deactivate();
|
|
3054
|
+
break;
|
|
3055
|
+
default:
|
|
3056
|
+
throw new ApiError("Invalid space state");
|
|
3057
|
+
}
|
|
3058
|
+
}
|
|
2968
3059
|
}
|
|
2969
3060
|
querySpaces() {
|
|
2970
3061
|
return new Stream9(({ next, ctx }) => {
|
|
2971
|
-
const
|
|
3062
|
+
const scheduler = new UpdateScheduler(ctx, async () => {
|
|
2972
3063
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2973
|
-
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this.
|
|
3064
|
+
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
2974
3065
|
log11("update", {
|
|
2975
3066
|
spaces
|
|
2976
3067
|
}, {
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
3068
|
+
F: __dxlog_file11,
|
|
3069
|
+
L: 78,
|
|
3070
|
+
S: this,
|
|
3071
|
+
C: (f, a) => f(...a)
|
|
2981
3072
|
});
|
|
2982
3073
|
next({
|
|
2983
3074
|
spaces
|
|
2984
3075
|
});
|
|
2985
|
-
}
|
|
3076
|
+
}, {
|
|
3077
|
+
maxFrequency: 2
|
|
3078
|
+
});
|
|
2986
3079
|
scheduleTask5(ctx, async () => {
|
|
2987
3080
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2988
3081
|
const subscriptions = new EventSubscriptions2();
|
|
@@ -2990,21 +3083,21 @@ var SpacesServiceImpl = class {
|
|
|
2990
3083
|
const subscribeSpaces = () => {
|
|
2991
3084
|
subscriptions.clear();
|
|
2992
3085
|
for (const space of dataSpaceManager.spaces.values()) {
|
|
2993
|
-
subscriptions.add(space.stateUpdate.on(ctx,
|
|
2994
|
-
subscriptions.add(space.presence.updated.on(ctx,
|
|
2995
|
-
subscriptions.add(space.dataPipeline.onNewEpoch.on(ctx,
|
|
2996
|
-
space.inner.controlPipeline.state.timeframeUpdate.
|
|
3086
|
+
subscriptions.add(space.stateUpdate.on(ctx, () => scheduler.trigger()));
|
|
3087
|
+
subscriptions.add(space.presence.updated.on(ctx, () => scheduler.trigger()));
|
|
3088
|
+
subscriptions.add(space.dataPipeline.onNewEpoch.on(ctx, () => scheduler.trigger()));
|
|
3089
|
+
space.inner.controlPipeline.state.timeframeUpdate.on(ctx, () => scheduler.trigger());
|
|
2997
3090
|
if (space.dataPipeline.pipelineState) {
|
|
2998
|
-
subscriptions.add(space.dataPipeline.pipelineState.timeframeUpdate.
|
|
3091
|
+
subscriptions.add(space.dataPipeline.pipelineState.timeframeUpdate.on(ctx, () => scheduler.trigger()));
|
|
2999
3092
|
}
|
|
3000
3093
|
}
|
|
3001
3094
|
};
|
|
3002
3095
|
dataSpaceManager.updated.on(ctx, () => {
|
|
3003
3096
|
subscribeSpaces();
|
|
3004
|
-
|
|
3097
|
+
scheduler.trigger();
|
|
3005
3098
|
});
|
|
3006
3099
|
subscribeSpaces();
|
|
3007
|
-
|
|
3100
|
+
scheduler.trigger();
|
|
3008
3101
|
});
|
|
3009
3102
|
if (!this._identityManager.identity) {
|
|
3010
3103
|
next({
|
|
@@ -3036,13 +3129,13 @@ var SpacesServiceImpl = class {
|
|
|
3036
3129
|
return new Stream9(({ ctx, next }) => {
|
|
3037
3130
|
var _a;
|
|
3038
3131
|
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : raise(new SpaceNotFoundError(spaceKey));
|
|
3039
|
-
const processor =
|
|
3040
|
-
|
|
3132
|
+
const processor = {
|
|
3133
|
+
processCredential: async (credential) => {
|
|
3041
3134
|
next(credential);
|
|
3042
3135
|
}
|
|
3043
|
-
}
|
|
3044
|
-
ctx.onDispose(() =>
|
|
3045
|
-
scheduleTask5(ctx, () =>
|
|
3136
|
+
};
|
|
3137
|
+
ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
|
|
3138
|
+
scheduleTask5(ctx, () => space.spaceState.addCredentialProcessor(processor));
|
|
3046
3139
|
});
|
|
3047
3140
|
}
|
|
3048
3141
|
async writeCredentials({ spaceKey, credentials }) {
|
|
@@ -3062,7 +3155,7 @@ var SpacesServiceImpl = class {
|
|
|
3062
3155
|
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise(new SpaceNotFoundError(spaceKey));
|
|
3063
3156
|
await space.createEpoch();
|
|
3064
3157
|
}
|
|
3065
|
-
|
|
3158
|
+
_serializeSpace(space) {
|
|
3066
3159
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
3067
3160
|
return {
|
|
3068
3161
|
spaceKey: space.key,
|
|
@@ -3102,7 +3195,7 @@ var SpacesServiceImpl = class {
|
|
|
3102
3195
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
3103
3196
|
|
|
3104
3197
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3105
|
-
import
|
|
3198
|
+
import invariant11 from "tiny-invariant";
|
|
3106
3199
|
import { Trigger as Trigger5 } from "@dxos/async";
|
|
3107
3200
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
3108
3201
|
import { failUndefined as failUndefined3 } from "@dxos/debug";
|
|
@@ -3114,6 +3207,7 @@ import { log as log12 } from "@dxos/log";
|
|
|
3114
3207
|
import { STORAGE_VERSION, trace as trace5 } from "@dxos/protocols";
|
|
3115
3208
|
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3116
3209
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
3210
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
3117
3211
|
var ServiceContext = class {
|
|
3118
3212
|
// prettier-ignore
|
|
3119
3213
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
@@ -3157,17 +3251,17 @@ var ServiceContext = class {
|
|
|
3157
3251
|
log12.trace("dxos.sdk.service-context.open", trace5.begin({
|
|
3158
3252
|
id: this._instanceId
|
|
3159
3253
|
}), {
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3254
|
+
F: __dxlog_file12,
|
|
3255
|
+
L: 126,
|
|
3256
|
+
S: this,
|
|
3257
|
+
C: (f, a) => f(...a)
|
|
3164
3258
|
});
|
|
3165
3259
|
await this._checkStorageVersion();
|
|
3166
|
-
log12("opening...",
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3260
|
+
log12("opening...", void 0, {
|
|
3261
|
+
F: __dxlog_file12,
|
|
3262
|
+
L: 130,
|
|
3263
|
+
S: this,
|
|
3264
|
+
C: (f, a) => f(...a)
|
|
3171
3265
|
});
|
|
3172
3266
|
await this.signalManager.open();
|
|
3173
3267
|
await this.networkManager.open();
|
|
@@ -3176,42 +3270,44 @@ var ServiceContext = class {
|
|
|
3176
3270
|
if (this.identityManager.identity) {
|
|
3177
3271
|
await this._initialize();
|
|
3178
3272
|
}
|
|
3179
|
-
log12("opened",
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3273
|
+
log12("opened", void 0, {
|
|
3274
|
+
F: __dxlog_file12,
|
|
3275
|
+
L: 138,
|
|
3276
|
+
S: this,
|
|
3277
|
+
C: (f, a) => f(...a)
|
|
3184
3278
|
});
|
|
3185
3279
|
log12.trace("dxos.sdk.service-context.open", trace5.end({
|
|
3186
3280
|
id: this._instanceId
|
|
3187
3281
|
}), {
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3282
|
+
F: __dxlog_file12,
|
|
3283
|
+
L: 139,
|
|
3284
|
+
S: this,
|
|
3285
|
+
C: (f, a) => f(...a)
|
|
3192
3286
|
});
|
|
3193
3287
|
}
|
|
3194
3288
|
async close() {
|
|
3195
|
-
var _a
|
|
3196
|
-
log12("closing...",
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
});
|
|
3202
|
-
|
|
3203
|
-
|
|
3289
|
+
var _a;
|
|
3290
|
+
log12("closing...", void 0, {
|
|
3291
|
+
F: __dxlog_file12,
|
|
3292
|
+
L: 143,
|
|
3293
|
+
S: this,
|
|
3294
|
+
C: (f, a) => f(...a)
|
|
3295
|
+
});
|
|
3296
|
+
if (this._deviceSpaceSync && this.identityManager.identity) {
|
|
3297
|
+
await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
|
|
3298
|
+
}
|
|
3299
|
+
await ((_a = this.dataSpaceManager) == null ? void 0 : _a.close());
|
|
3204
3300
|
await this.identityManager.close();
|
|
3205
3301
|
await this.spaceManager.close();
|
|
3206
3302
|
await this.feedStore.close();
|
|
3207
3303
|
await this.networkManager.close();
|
|
3208
3304
|
await this.signalManager.close();
|
|
3209
3305
|
this.dataServiceSubscriptions.clear();
|
|
3210
|
-
log12("closed",
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3306
|
+
log12("closed", void 0, {
|
|
3307
|
+
F: __dxlog_file12,
|
|
3308
|
+
L: 154,
|
|
3309
|
+
S: this,
|
|
3310
|
+
C: (f, a) => f(...a)
|
|
3215
3311
|
});
|
|
3216
3312
|
}
|
|
3217
3313
|
async createIdentity(params = {}) {
|
|
@@ -3221,7 +3317,7 @@ var ServiceContext = class {
|
|
|
3221
3317
|
}
|
|
3222
3318
|
getInvitationHandler(invitation) {
|
|
3223
3319
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3224
|
-
|
|
3320
|
+
invariant11(factory, `Unknown invitation kind: ${invitation.kind}`);
|
|
3225
3321
|
return factory(invitation);
|
|
3226
3322
|
}
|
|
3227
3323
|
async _acceptIdentity(params) {
|
|
@@ -3238,11 +3334,11 @@ var ServiceContext = class {
|
|
|
3238
3334
|
// Called when identity is created.
|
|
3239
3335
|
async _initialize() {
|
|
3240
3336
|
var _a;
|
|
3241
|
-
log12("initializing spaces...",
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3337
|
+
log12("initializing spaces...", void 0, {
|
|
3338
|
+
F: __dxlog_file12,
|
|
3339
|
+
L: 187,
|
|
3340
|
+
S: this,
|
|
3341
|
+
C: (f, a) => f(...a)
|
|
3246
3342
|
});
|
|
3247
3343
|
const identity = (_a = this.identityManager.identity) != null ? _a : failUndefined3();
|
|
3248
3344
|
const signingContext = {
|
|
@@ -3261,12 +3357,12 @@ var ServiceContext = class {
|
|
|
3261
3357
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
3262
3358
|
await this.dataSpaceManager.open();
|
|
3263
3359
|
this._handlerFactories.set(Invitation5.Kind.SPACE, (invitation) => {
|
|
3264
|
-
|
|
3360
|
+
invariant11(this.dataSpaceManager, "dataSpaceManager not initialized yet");
|
|
3265
3361
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
3266
3362
|
});
|
|
3267
3363
|
this.initialized.wake();
|
|
3268
|
-
this._deviceSpaceSync =
|
|
3269
|
-
|
|
3364
|
+
this._deviceSpaceSync = {
|
|
3365
|
+
processCredential: async (credential) => {
|
|
3270
3366
|
const assertion = getCredentialAssertion3(credential);
|
|
3271
3367
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
3272
3368
|
return;
|
|
@@ -3278,10 +3374,10 @@ var ServiceContext = class {
|
|
|
3278
3374
|
log12("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3279
3375
|
details: assertion
|
|
3280
3376
|
}, {
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3377
|
+
F: __dxlog_file12,
|
|
3378
|
+
L: 226,
|
|
3379
|
+
S: this,
|
|
3380
|
+
C: (f, a) => f(...a)
|
|
3285
3381
|
});
|
|
3286
3382
|
return;
|
|
3287
3383
|
}
|
|
@@ -3289,10 +3385,10 @@ var ServiceContext = class {
|
|
|
3289
3385
|
log12("space already exists, ignoring space admission", {
|
|
3290
3386
|
details: assertion
|
|
3291
3387
|
}, {
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3388
|
+
F: __dxlog_file12,
|
|
3389
|
+
L: 230,
|
|
3390
|
+
S: this,
|
|
3391
|
+
C: (f, a) => f(...a)
|
|
3296
3392
|
});
|
|
3297
3393
|
return;
|
|
3298
3394
|
}
|
|
@@ -3300,26 +3396,26 @@ var ServiceContext = class {
|
|
|
3300
3396
|
log12("accepting space recorded in halo", {
|
|
3301
3397
|
details: assertion
|
|
3302
3398
|
}, {
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3399
|
+
F: __dxlog_file12,
|
|
3400
|
+
L: 235,
|
|
3401
|
+
S: this,
|
|
3402
|
+
C: (f, a) => f(...a)
|
|
3307
3403
|
});
|
|
3308
3404
|
await this.dataSpaceManager.acceptSpace({
|
|
3309
3405
|
spaceKey: assertion.spaceKey,
|
|
3310
3406
|
genesisFeedKey: assertion.genesisFeedKey
|
|
3311
3407
|
});
|
|
3312
3408
|
} catch (err) {
|
|
3313
|
-
log12.catch(err,
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3409
|
+
log12.catch(err, void 0, {
|
|
3410
|
+
F: __dxlog_file12,
|
|
3411
|
+
L: 241,
|
|
3412
|
+
S: this,
|
|
3413
|
+
C: (f, a) => f(...a)
|
|
3318
3414
|
});
|
|
3319
3415
|
}
|
|
3320
3416
|
}
|
|
3321
|
-
}
|
|
3322
|
-
await this._deviceSpaceSync
|
|
3417
|
+
};
|
|
3418
|
+
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
3323
3419
|
}
|
|
3324
3420
|
};
|
|
3325
3421
|
|
|
@@ -3327,7 +3423,7 @@ var ServiceContext = class {
|
|
|
3327
3423
|
import { asyncTimeout, Trigger as Trigger6 } from "@dxos/async";
|
|
3328
3424
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
3329
3425
|
import { log as log13, logInfo } from "@dxos/log";
|
|
3330
|
-
|
|
3426
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
3331
3427
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3332
3428
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3333
3429
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3336,7 +3432,8 @@ var __decorate3 = function(decorators, target, key, desc) {
|
|
|
3336
3432
|
if (d = decorators[i])
|
|
3337
3433
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3338
3434
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3339
|
-
}
|
|
3435
|
+
}
|
|
3436
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
3340
3437
|
var Message;
|
|
3341
3438
|
(function(Message2) {
|
|
3342
3439
|
Message2["ACQUIRING"] = "acquiring";
|
|
@@ -3358,32 +3455,32 @@ var Lock = class {
|
|
|
3358
3455
|
message: Message.ACQUIRING
|
|
3359
3456
|
});
|
|
3360
3457
|
try {
|
|
3361
|
-
log13("aquiring lock...",
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3458
|
+
log13("aquiring lock...", void 0, {
|
|
3459
|
+
F: __dxlog_file13,
|
|
3460
|
+
L: 42,
|
|
3461
|
+
S: this,
|
|
3462
|
+
C: (f, a) => f(...a)
|
|
3366
3463
|
});
|
|
3367
3464
|
await asyncTimeout(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
3368
|
-
log13("acquired lock",
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3465
|
+
log13("acquired lock", void 0, {
|
|
3466
|
+
F: __dxlog_file13,
|
|
3467
|
+
L: 44,
|
|
3468
|
+
S: this,
|
|
3469
|
+
C: (f, a) => f(...a)
|
|
3373
3470
|
});
|
|
3374
3471
|
} catch (e) {
|
|
3375
|
-
log13("stealing lock...",
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3472
|
+
log13("stealing lock...", void 0, {
|
|
3473
|
+
F: __dxlog_file13,
|
|
3474
|
+
L: 46,
|
|
3475
|
+
S: this,
|
|
3476
|
+
C: (f, a) => f(...a)
|
|
3380
3477
|
});
|
|
3381
3478
|
await this._requestLock(true);
|
|
3382
|
-
log13("stolen lock",
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3479
|
+
log13("stolen lock", void 0, {
|
|
3480
|
+
F: __dxlog_file13,
|
|
3481
|
+
L: 48,
|
|
3482
|
+
S: this,
|
|
3483
|
+
C: (f, a) => f(...a)
|
|
3387
3484
|
});
|
|
3388
3485
|
}
|
|
3389
3486
|
}
|
|
@@ -3399,10 +3496,10 @@ var Lock = class {
|
|
|
3399
3496
|
log13("requesting lock...", {
|
|
3400
3497
|
steal
|
|
3401
3498
|
}, {
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3499
|
+
F: __dxlog_file13,
|
|
3500
|
+
L: 63,
|
|
3501
|
+
S: this,
|
|
3502
|
+
C: (f, a) => f(...a)
|
|
3406
3503
|
});
|
|
3407
3504
|
const acquired = new Trigger6();
|
|
3408
3505
|
void navigator.locks.request(this._lockKey, {
|
|
@@ -3413,18 +3510,18 @@ var Lock = class {
|
|
|
3413
3510
|
acquired.wake();
|
|
3414
3511
|
this._releaseTrigger = new Trigger6();
|
|
3415
3512
|
await this._releaseTrigger.wait();
|
|
3416
|
-
log13("releasing lock...",
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3513
|
+
log13("releasing lock...", void 0, {
|
|
3514
|
+
F: __dxlog_file13,
|
|
3515
|
+
L: 72,
|
|
3516
|
+
S: this,
|
|
3517
|
+
C: (f, a) => f(...a)
|
|
3421
3518
|
});
|
|
3422
3519
|
await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
|
|
3423
|
-
log13("released lock",
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3520
|
+
log13("released lock", void 0, {
|
|
3521
|
+
F: __dxlog_file13,
|
|
3522
|
+
L: 74,
|
|
3523
|
+
S: this,
|
|
3524
|
+
C: (f, a) => f(...a)
|
|
3428
3525
|
});
|
|
3429
3526
|
}).catch(async () => {
|
|
3430
3527
|
var _a;
|
|
@@ -3434,14 +3531,14 @@ var Lock = class {
|
|
|
3434
3531
|
log13("recieved lock", {
|
|
3435
3532
|
steal
|
|
3436
3533
|
}, {
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3534
|
+
F: __dxlog_file13,
|
|
3535
|
+
L: 81,
|
|
3536
|
+
S: this,
|
|
3537
|
+
C: (f, a) => f(...a)
|
|
3441
3538
|
});
|
|
3442
3539
|
}
|
|
3443
3540
|
};
|
|
3444
|
-
|
|
3541
|
+
_ts_decorate3([
|
|
3445
3542
|
logInfo
|
|
3446
3543
|
], Lock.prototype, "lockKey", null);
|
|
3447
3544
|
var isLocked = (lockPath) => {
|
|
@@ -3522,16 +3619,19 @@ var ServiceRegistry = class {
|
|
|
3522
3619
|
};
|
|
3523
3620
|
|
|
3524
3621
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3525
|
-
import
|
|
3526
|
-
import { Event as Event8 } from "@dxos/async";
|
|
3527
|
-
import { clientServiceBundle
|
|
3622
|
+
import invariant12 from "tiny-invariant";
|
|
3623
|
+
import { Event as Event8, synchronized as synchronized3 } from "@dxos/async";
|
|
3624
|
+
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
3625
|
+
import { DocumentModel } from "@dxos/document-model";
|
|
3528
3626
|
import { DataServiceImpl } from "@dxos/echo-pipeline";
|
|
3529
3627
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
3530
3628
|
import { log as log15 } from "@dxos/log";
|
|
3531
3629
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
3630
|
+
import { ModelFactory } from "@dxos/model-factory";
|
|
3532
3631
|
import { createWebRTCTransportFactory, NetworkManager } from "@dxos/network-manager";
|
|
3533
3632
|
import { trace as trace6 } from "@dxos/protocols";
|
|
3534
3633
|
import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
3634
|
+
import { TextModel } from "@dxos/text-model";
|
|
3535
3635
|
|
|
3536
3636
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3537
3637
|
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
@@ -3607,7 +3707,7 @@ var LoggingServiceImpl = class {
|
|
|
3607
3707
|
if (LOG_PROCESSING > 0) {
|
|
3608
3708
|
return;
|
|
3609
3709
|
}
|
|
3610
|
-
if (((_a = entry2.meta) == null ? void 0 : _a.
|
|
3710
|
+
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"))) {
|
|
3611
3711
|
return;
|
|
3612
3712
|
}
|
|
3613
3713
|
if (!shouldLog(entry2, request)) {
|
|
@@ -3619,8 +3719,8 @@ var LoggingServiceImpl = class {
|
|
|
3619
3719
|
timestamp: new Date(),
|
|
3620
3720
|
meta: {
|
|
3621
3721
|
// TODO(dmaretskyi): Fix proto.
|
|
3622
|
-
file: (_c = (_b = entry2.meta) == null ? void 0 : _b.
|
|
3623
|
-
line: (_e = (_d = entry2.meta) == null ? void 0 : _d.
|
|
3722
|
+
file: (_c = (_b = entry2.meta) == null ? void 0 : _b.F) != null ? _c : "",
|
|
3723
|
+
line: (_e = (_d = entry2.meta) == null ? void 0 : _d.L) != null ? _e : 0
|
|
3624
3724
|
}
|
|
3625
3725
|
};
|
|
3626
3726
|
try {
|
|
@@ -3650,7 +3750,7 @@ var shouldLog = (entry2, request) => {
|
|
|
3650
3750
|
} else {
|
|
3651
3751
|
return request.filters.some((filter) => {
|
|
3652
3752
|
var _a2, _b;
|
|
3653
|
-
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.
|
|
3753
|
+
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
|
|
3654
3754
|
});
|
|
3655
3755
|
}
|
|
3656
3756
|
};
|
|
@@ -3727,6 +3827,20 @@ var SystemServiceImpl = class {
|
|
|
3727
3827
|
};
|
|
3728
3828
|
|
|
3729
3829
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3830
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
3831
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3832
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3833
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3834
|
+
else
|
|
3835
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3836
|
+
if (d = decorators[i])
|
|
3837
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3838
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3839
|
+
}
|
|
3840
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
3841
|
+
var createDefaultModelFactory = () => {
|
|
3842
|
+
return new ModelFactory().registerModel(DocumentModel).registerModel(TextModel);
|
|
3843
|
+
};
|
|
3730
3844
|
var ClientServicesHost = class {
|
|
3731
3845
|
constructor({
|
|
3732
3846
|
config,
|
|
@@ -3737,13 +3851,15 @@ var ClientServicesHost = class {
|
|
|
3737
3851
|
connectionLog,
|
|
3738
3852
|
storage,
|
|
3739
3853
|
// TODO(wittjosiah): Turn this on by default.
|
|
3740
|
-
lockKey
|
|
3854
|
+
lockKey,
|
|
3855
|
+
callbacks
|
|
3741
3856
|
} = {}) {
|
|
3742
3857
|
this._statusUpdate = new Event8();
|
|
3743
3858
|
this._opening = false;
|
|
3744
3859
|
this._open = false;
|
|
3745
3860
|
this._storage = storage;
|
|
3746
3861
|
this._modelFactory = modelFactory;
|
|
3862
|
+
this._callbacks = callbacks;
|
|
3747
3863
|
if (config) {
|
|
3748
3864
|
this.initialize({
|
|
3749
3865
|
config,
|
|
@@ -3802,9 +3918,9 @@ var ClientServicesHost = class {
|
|
|
3802
3918
|
*/
|
|
3803
3919
|
initialize({ config, ...options }) {
|
|
3804
3920
|
var _a, _b, _c;
|
|
3805
|
-
|
|
3921
|
+
invariant12(!this._open, "service host is open");
|
|
3806
3922
|
if (config) {
|
|
3807
|
-
|
|
3923
|
+
invariant12(!this._config, "config already set");
|
|
3808
3924
|
this._config = config;
|
|
3809
3925
|
if (!this._storage) {
|
|
3810
3926
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
@@ -3814,7 +3930,7 @@ var ClientServicesHost = class {
|
|
|
3814
3930
|
iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
|
|
3815
3931
|
}), signalManager = new WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
|
|
3816
3932
|
this._signalManager = signalManager;
|
|
3817
|
-
|
|
3933
|
+
invariant12(!this._networkManager, "network manager already set");
|
|
3818
3934
|
this._networkManager = new NetworkManager({
|
|
3819
3935
|
log: connectionLog,
|
|
3820
3936
|
transportFactory,
|
|
@@ -3830,23 +3946,23 @@ var ClientServicesHost = class {
|
|
|
3830
3946
|
log15.trace("dxos.sdk.client-services-host.open", trace6.begin({
|
|
3831
3947
|
id: traceId
|
|
3832
3948
|
}), {
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
});
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3949
|
+
F: __dxlog_file14,
|
|
3950
|
+
L: 203,
|
|
3951
|
+
S: this,
|
|
3952
|
+
C: (f, a) => f(...a)
|
|
3953
|
+
});
|
|
3954
|
+
invariant12(this._config, "config not set");
|
|
3955
|
+
invariant12(this._storage, "storage not set");
|
|
3956
|
+
invariant12(this._signalManager, "signal manager not set");
|
|
3957
|
+
invariant12(this._networkManager, "network manager not set");
|
|
3842
3958
|
this._opening = true;
|
|
3843
3959
|
log15("opening...", {
|
|
3844
3960
|
lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
|
|
3845
3961
|
}, {
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3962
|
+
F: __dxlog_file14,
|
|
3963
|
+
L: 211,
|
|
3964
|
+
S: this,
|
|
3965
|
+
C: (f, a) => f(...a)
|
|
3850
3966
|
});
|
|
3851
3967
|
await ((_b = this._resourceLock) == null ? void 0 : _b.acquire());
|
|
3852
3968
|
await this._loggingService.open();
|
|
@@ -3878,18 +3994,18 @@ var ClientServicesHost = class {
|
|
|
3878
3994
|
log15("opened", {
|
|
3879
3995
|
deviceKey
|
|
3880
3996
|
}, {
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3997
|
+
F: __dxlog_file14,
|
|
3998
|
+
L: 266,
|
|
3999
|
+
S: this,
|
|
4000
|
+
C: (f, a) => f(...a)
|
|
3885
4001
|
});
|
|
3886
4002
|
log15.trace("dxos.sdk.client-services-host.open", trace6.end({
|
|
3887
4003
|
id: traceId
|
|
3888
4004
|
}), {
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
4005
|
+
F: __dxlog_file14,
|
|
4006
|
+
L: 267,
|
|
4007
|
+
S: this,
|
|
4008
|
+
C: (f, a) => f(...a)
|
|
3893
4009
|
});
|
|
3894
4010
|
}
|
|
3895
4011
|
async close() {
|
|
@@ -3901,10 +4017,10 @@ var ClientServicesHost = class {
|
|
|
3901
4017
|
log15("closing...", {
|
|
3902
4018
|
deviceKey
|
|
3903
4019
|
}, {
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
4020
|
+
F: __dxlog_file14,
|
|
4021
|
+
L: 277,
|
|
4022
|
+
S: this,
|
|
4023
|
+
C: (f, a) => f(...a)
|
|
3908
4024
|
});
|
|
3909
4025
|
this._serviceRegistry.setServices({
|
|
3910
4026
|
SystemService: this._systemService
|
|
@@ -3916,47 +4032,54 @@ var ClientServicesHost = class {
|
|
|
3916
4032
|
log15("closed", {
|
|
3917
4033
|
deviceKey
|
|
3918
4034
|
}, {
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
4035
|
+
F: __dxlog_file14,
|
|
4036
|
+
L: 283,
|
|
4037
|
+
S: this,
|
|
4038
|
+
C: (f, a) => f(...a)
|
|
3923
4039
|
});
|
|
3924
4040
|
}
|
|
3925
4041
|
async reset() {
|
|
3926
|
-
var _a;
|
|
4042
|
+
var _a, _b, _c;
|
|
3927
4043
|
const traceId = PublicKey10.random().toHex();
|
|
3928
4044
|
log15.trace("dxos.sdk.client-services-host.reset", trace6.begin({
|
|
3929
4045
|
id: traceId
|
|
3930
4046
|
}), {
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
4047
|
+
F: __dxlog_file14,
|
|
4048
|
+
L: 288,
|
|
4049
|
+
S: this,
|
|
4050
|
+
C: (f, a) => f(...a)
|
|
3935
4051
|
});
|
|
3936
|
-
log15("resetting...",
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
4052
|
+
log15("resetting...", void 0, {
|
|
4053
|
+
F: __dxlog_file14,
|
|
4054
|
+
L: 290,
|
|
4055
|
+
S: this,
|
|
4056
|
+
C: (f, a) => f(...a)
|
|
3941
4057
|
});
|
|
3942
4058
|
await ((_a = this._serviceContext) == null ? void 0 : _a.close());
|
|
3943
4059
|
await this._storage.reset();
|
|
3944
|
-
log15("reset",
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
4060
|
+
log15("reset", void 0, {
|
|
4061
|
+
F: __dxlog_file14,
|
|
4062
|
+
L: 293,
|
|
4063
|
+
S: this,
|
|
4064
|
+
C: (f, a) => f(...a)
|
|
3949
4065
|
});
|
|
3950
4066
|
log15.trace("dxos.sdk.client-services-host.reset", trace6.end({
|
|
3951
4067
|
id: traceId
|
|
3952
4068
|
}), {
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
4069
|
+
F: __dxlog_file14,
|
|
4070
|
+
L: 294,
|
|
4071
|
+
S: this,
|
|
4072
|
+
C: (f, a) => f(...a)
|
|
3957
4073
|
});
|
|
4074
|
+
await ((_c = (_b = this._callbacks) == null ? void 0 : _b.onReset) == null ? void 0 : _c.call(_b));
|
|
3958
4075
|
}
|
|
3959
4076
|
};
|
|
4077
|
+
_ts_decorate4([
|
|
4078
|
+
synchronized3
|
|
4079
|
+
], ClientServicesHost.prototype, "open", null);
|
|
4080
|
+
_ts_decorate4([
|
|
4081
|
+
synchronized3
|
|
4082
|
+
], ClientServicesHost.prototype, "close", null);
|
|
3960
4083
|
|
|
3961
4084
|
export {
|
|
3962
4085
|
subscribeToFeeds,
|
|
@@ -3986,6 +4109,7 @@ export {
|
|
|
3986
4109
|
isLocked,
|
|
3987
4110
|
createStorageObjects,
|
|
3988
4111
|
ServiceRegistry,
|
|
4112
|
+
createDefaultModelFactory,
|
|
3989
4113
|
ClientServicesHost
|
|
3990
4114
|
};
|
|
3991
|
-
//# sourceMappingURL=chunk-
|
|
4115
|
+
//# sourceMappingURL=chunk-3EI4PM2V.mjs.map
|