@dxos/client-services 0.1.52 → 0.1.53-main.00be1a9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{chunk-C3SPTMW3.mjs → chunk-RKD47ENR.mjs} +678 -638
- package/dist/lib/browser/chunk-RKD47ENR.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +94 -119
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +6 -6
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +739 -726
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +650 -612
- package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
- package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +1 -0
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts +1 -1
- package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/shell-runtime.d.ts +1 -21
- package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +1 -1
- package/package.json +33 -32
- package/src/packlets/devtools/devtools.ts +2 -2
- package/src/packlets/identity/identity-manager.test.ts +1 -1
- package/src/packlets/identity/identity-manager.ts +8 -8
- package/src/packlets/identity/identity-service.ts +2 -2
- package/src/packlets/identity/identity.test.ts +1 -1
- package/src/packlets/identity/identity.ts +2 -2
- package/src/packlets/invitations/device-invitation-protocol.ts +4 -4
- package/src/packlets/invitations/invitation-extension.ts +5 -5
- package/src/packlets/invitations/invitations-handler.ts +6 -6
- package/src/packlets/invitations/invitations-service.ts +3 -3
- package/src/packlets/invitations/space-invitation-protocol.ts +9 -9
- package/src/packlets/locks/node.ts +2 -2
- package/src/packlets/logging/logging-service.ts +4 -4
- package/src/packlets/services/service-context.test.ts +1 -1
- package/src/packlets/services/service-context.ts +3 -3
- package/src/packlets/services/service-host.ts +19 -10
- package/src/packlets/spaces/data-space-manager.ts +5 -6
- package/src/packlets/spaces/notarization-plugin.ts +4 -4
- package/src/packlets/spaces/spaces-service.ts +20 -24
- package/src/packlets/testing/invitation-utils.ts +2 -2
- package/src/packlets/testing/test-builder.ts +1 -2
- package/src/packlets/vault/iframe-host-runtime.ts +2 -2
- package/src/packlets/vault/iframe-proxy-runtime.ts +2 -2
- package/src/packlets/vault/shell-runtime.ts +3 -49
- package/src/packlets/vault/worker-session.ts +2 -2
- package/dist/lib/browser/chunk-C3SPTMW3.mjs.map +0 -7
|
@@ -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,7 @@ 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";
|
|
353
356
|
var createAuthProvider = (signer) => async (nonce) => {
|
|
354
357
|
const credential = await signer.createCredential({
|
|
355
358
|
assertion: {
|
|
@@ -375,20 +378,20 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
375
378
|
log("authenticating...", {
|
|
376
379
|
credential
|
|
377
380
|
}, {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
381
|
+
F: __dxlog_file,
|
|
382
|
+
L: 57,
|
|
383
|
+
S: this,
|
|
384
|
+
C: (f, a) => f(...a)
|
|
382
385
|
});
|
|
383
386
|
const result = await verifyCredential(credential);
|
|
384
387
|
if (result.kind === "fail") {
|
|
385
388
|
log("Invalid credential", {
|
|
386
389
|
result
|
|
387
390
|
}, {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
391
|
+
F: __dxlog_file,
|
|
392
|
+
L: 61,
|
|
393
|
+
S: this,
|
|
394
|
+
C: (f, a) => f(...a)
|
|
392
395
|
});
|
|
393
396
|
return false;
|
|
394
397
|
}
|
|
@@ -397,10 +400,10 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
397
400
|
nonce,
|
|
398
401
|
credential
|
|
399
402
|
}, {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
403
|
+
F: __dxlog_file,
|
|
404
|
+
L: 66,
|
|
405
|
+
S: this,
|
|
406
|
+
C: (f, a) => f(...a)
|
|
404
407
|
});
|
|
405
408
|
return false;
|
|
406
409
|
}
|
|
@@ -408,10 +411,10 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
408
411
|
log("key is not currently in trusted set, waiting...", {
|
|
409
412
|
key: credential.issuer
|
|
410
413
|
}, {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
414
|
+
F: __dxlog_file,
|
|
415
|
+
L: 71,
|
|
416
|
+
S: this,
|
|
417
|
+
C: (f, a) => f(...a)
|
|
415
418
|
});
|
|
416
419
|
return true;
|
|
417
420
|
}
|
|
@@ -424,20 +427,20 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
424
427
|
log("auth success", {
|
|
425
428
|
key: credential.issuer
|
|
426
429
|
}, {
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
430
|
+
F: __dxlog_file,
|
|
431
|
+
L: 82,
|
|
432
|
+
S: this,
|
|
433
|
+
C: (f, a) => f(...a)
|
|
431
434
|
});
|
|
432
435
|
trigger.wake(true);
|
|
433
436
|
} else {
|
|
434
437
|
log("key is not currently in trusted set, waiting...", {
|
|
435
438
|
key: credential.issuer
|
|
436
439
|
}, {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
440
|
+
F: __dxlog_file,
|
|
441
|
+
L: 85,
|
|
442
|
+
S: this,
|
|
443
|
+
C: (f, a) => f(...a)
|
|
441
444
|
});
|
|
442
445
|
}
|
|
443
446
|
});
|
|
@@ -459,7 +462,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
459
462
|
};
|
|
460
463
|
|
|
461
464
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
462
|
-
import
|
|
465
|
+
import invariant from "tiny-invariant";
|
|
463
466
|
import { Event } from "@dxos/async";
|
|
464
467
|
import { AUTH_TIMEOUT, LOAD_CONTROL_FEEDS_TIMEOUT } from "@dxos/client-protocol";
|
|
465
468
|
import { DeviceStateMachine, createCredentialSignerWithKey, createCredentialSignerWithChain, ProfileStateMachine } from "@dxos/credentials";
|
|
@@ -467,6 +470,7 @@ import { failUndefined } from "@dxos/debug";
|
|
|
467
470
|
import { writeMessages } from "@dxos/feed-store";
|
|
468
471
|
import { log as log2 } from "@dxos/log";
|
|
469
472
|
import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
473
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
470
474
|
var Identity = class {
|
|
471
475
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
472
476
|
this.stateUpdate = new Event();
|
|
@@ -541,7 +545,7 @@ var Identity = class {
|
|
|
541
545
|
* Requires identity to be ready.
|
|
542
546
|
*/
|
|
543
547
|
getIdentityCredentialSigner() {
|
|
544
|
-
|
|
548
|
+
invariant(this._deviceStateMachine.processor.deviceCredentialChain, "Device credential chain is not ready.");
|
|
545
549
|
return createCredentialSignerWithChain(this._signer, this._deviceStateMachine.processor.deviceCredentialChain, this.deviceKey);
|
|
546
550
|
}
|
|
547
551
|
/**
|
|
@@ -558,10 +562,10 @@ var Identity = class {
|
|
|
558
562
|
controlFeedKey,
|
|
559
563
|
dataFeedKey
|
|
560
564
|
}, {
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
+
F: __dxlog_file2,
|
|
566
|
+
L: 156,
|
|
567
|
+
S: this,
|
|
568
|
+
C: (f, a) => f(...a)
|
|
565
569
|
});
|
|
566
570
|
const signer = this.getIdentityCredentialSigner();
|
|
567
571
|
await writeMessages(this.controlPipeline.writer, [
|
|
@@ -602,7 +606,7 @@ var Identity = class {
|
|
|
602
606
|
};
|
|
603
607
|
|
|
604
608
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
605
|
-
import
|
|
609
|
+
import invariant2 from "tiny-invariant";
|
|
606
610
|
import { Event as Event2 } from "@dxos/async";
|
|
607
611
|
import { createCredentialSignerWithKey as createCredentialSignerWithKey2, CredentialGenerator } from "@dxos/credentials";
|
|
608
612
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
@@ -610,6 +614,7 @@ import { log as log3 } from "@dxos/log";
|
|
|
610
614
|
import { trace } from "@dxos/protocols";
|
|
611
615
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
612
616
|
import { deferFunction } from "@dxos/util";
|
|
617
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
613
618
|
var IdentityManager = class {
|
|
614
619
|
// TODO(burdon): IdentityManagerParams.
|
|
615
620
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
@@ -629,20 +634,20 @@ var IdentityManager = class {
|
|
|
629
634
|
log3.trace("dxos.halo.identity-manager.open", trace.begin({
|
|
630
635
|
id: traceId
|
|
631
636
|
}), {
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
637
|
+
F: __dxlog_file3,
|
|
638
|
+
L: 70,
|
|
639
|
+
S: this,
|
|
640
|
+
C: (f, a) => f(...a)
|
|
636
641
|
});
|
|
637
642
|
await this._metadataStore.load();
|
|
638
643
|
const identityRecord = this._metadataStore.getIdentityRecord();
|
|
639
644
|
log3("identity record", {
|
|
640
645
|
identityRecord
|
|
641
646
|
}, {
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
647
|
+
F: __dxlog_file3,
|
|
648
|
+
L: 74,
|
|
649
|
+
S: this,
|
|
650
|
+
C: (f, a) => f(...a)
|
|
646
651
|
});
|
|
647
652
|
if (identityRecord) {
|
|
648
653
|
this._identity = await this._constructIdentity(identityRecord);
|
|
@@ -652,20 +657,20 @@ var IdentityManager = class {
|
|
|
652
657
|
identityKey: identityRecord.identityKey,
|
|
653
658
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
654
659
|
}, {
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
660
|
+
F: __dxlog_file3,
|
|
661
|
+
L: 79,
|
|
662
|
+
S: this,
|
|
663
|
+
C: (f, a) => f(...a)
|
|
659
664
|
});
|
|
660
665
|
this.stateUpdate.emit();
|
|
661
666
|
}
|
|
662
667
|
log3.trace("dxos.halo.identity-manager.open", trace.end({
|
|
663
668
|
id: traceId
|
|
664
669
|
}), {
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
670
|
+
F: __dxlog_file3,
|
|
671
|
+
L: 85,
|
|
672
|
+
S: this,
|
|
673
|
+
C: (f, a) => f(...a)
|
|
669
674
|
});
|
|
670
675
|
}
|
|
671
676
|
async close() {
|
|
@@ -674,12 +679,12 @@ var IdentityManager = class {
|
|
|
674
679
|
}
|
|
675
680
|
async createIdentity({ displayName } = {}) {
|
|
676
681
|
var _a;
|
|
677
|
-
|
|
678
|
-
log3("creating identity...",
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
682
|
+
invariant2(!this._identity, "Identity already exists.");
|
|
683
|
+
log3("creating identity...", void 0, {
|
|
684
|
+
F: __dxlog_file3,
|
|
685
|
+
L: 94,
|
|
686
|
+
S: this,
|
|
687
|
+
C: (f, a) => f(...a)
|
|
683
688
|
});
|
|
684
689
|
const controlFeedKey = await this._keyring.createKey();
|
|
685
690
|
const identityRecord = {
|
|
@@ -696,8 +701,8 @@ var IdentityManager = class {
|
|
|
696
701
|
await identity.open();
|
|
697
702
|
{
|
|
698
703
|
const generator = new CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
699
|
-
|
|
700
|
-
|
|
704
|
+
invariant2(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.");
|
|
705
|
+
invariant2(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.");
|
|
701
706
|
const credentials = [
|
|
702
707
|
// Space genesis.
|
|
703
708
|
...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
|
|
@@ -725,20 +730,20 @@ var IdentityManager = class {
|
|
|
725
730
|
identityKey: identityRecord.identityKey,
|
|
726
731
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
727
732
|
}, {
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
733
|
+
F: __dxlog_file3,
|
|
734
|
+
L: 149,
|
|
735
|
+
S: this,
|
|
736
|
+
C: (f, a) => f(...a)
|
|
732
737
|
});
|
|
733
738
|
this.stateUpdate.emit();
|
|
734
739
|
log3("created identity", {
|
|
735
740
|
identityKey: identity.identityKey,
|
|
736
741
|
deviceKey: identity.deviceKey
|
|
737
742
|
}, {
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
743
|
+
F: __dxlog_file3,
|
|
744
|
+
L: 155,
|
|
745
|
+
S: this,
|
|
746
|
+
C: (f, a) => f(...a)
|
|
742
747
|
});
|
|
743
748
|
return identity;
|
|
744
749
|
}
|
|
@@ -750,12 +755,12 @@ var IdentityManager = class {
|
|
|
750
755
|
log3("accepting identity", {
|
|
751
756
|
params
|
|
752
757
|
}, {
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
758
|
+
F: __dxlog_file3,
|
|
759
|
+
L: 163,
|
|
760
|
+
S: this,
|
|
761
|
+
C: (f, a) => f(...a)
|
|
757
762
|
});
|
|
758
|
-
|
|
763
|
+
invariant2(!this._identity, "Identity already exists.");
|
|
759
764
|
const identityRecord = {
|
|
760
765
|
identityKey: params.identityKey,
|
|
761
766
|
deviceKey: params.deviceKey,
|
|
@@ -776,38 +781,38 @@ var IdentityManager = class {
|
|
|
776
781
|
identityKey: identityRecord.identityKey,
|
|
777
782
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
778
783
|
}, {
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
784
|
+
F: __dxlog_file3,
|
|
785
|
+
L: 183,
|
|
786
|
+
S: this,
|
|
787
|
+
C: (f, a) => f(...a)
|
|
783
788
|
});
|
|
784
789
|
this.stateUpdate.emit();
|
|
785
790
|
log3("accepted identity", {
|
|
786
791
|
identityKey: identity.identityKey,
|
|
787
792
|
deviceKey: identity.deviceKey
|
|
788
793
|
}, {
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
794
|
+
F: __dxlog_file3,
|
|
795
|
+
L: 189,
|
|
796
|
+
S: this,
|
|
797
|
+
C: (f, a) => f(...a)
|
|
793
798
|
});
|
|
794
799
|
return identity;
|
|
795
800
|
}
|
|
796
801
|
async _constructIdentity(identityRecord) {
|
|
797
|
-
|
|
802
|
+
invariant2(!this._identity);
|
|
798
803
|
log3("constructing identity", {
|
|
799
804
|
identityRecord
|
|
800
805
|
}, {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
806
|
+
F: __dxlog_file3,
|
|
807
|
+
L: 195,
|
|
808
|
+
S: this,
|
|
809
|
+
C: (f, a) => f(...a)
|
|
805
810
|
});
|
|
806
|
-
|
|
811
|
+
invariant2(identityRecord.haloSpace.controlFeedKey);
|
|
807
812
|
const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
|
|
808
813
|
writable: true
|
|
809
814
|
});
|
|
810
|
-
|
|
815
|
+
invariant2(identityRecord.haloSpace.dataFeedKey);
|
|
811
816
|
const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
|
|
812
817
|
writable: true,
|
|
813
818
|
sparse: true
|
|
@@ -832,10 +837,10 @@ var IdentityManager = class {
|
|
|
832
837
|
log3("done", {
|
|
833
838
|
identityKey: identityRecord.identityKey
|
|
834
839
|
}, {
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
840
|
+
F: __dxlog_file3,
|
|
841
|
+
L: 226,
|
|
842
|
+
S: this,
|
|
843
|
+
C: (f, a) => f(...a)
|
|
839
844
|
});
|
|
840
845
|
if (identityRecord.haloSpace.controlTimeframe) {
|
|
841
846
|
identity.controlPipeline.state.setTargetTimeframe(identityRecord.haloSpace.controlTimeframe);
|
|
@@ -852,11 +857,11 @@ var IdentityManager = class {
|
|
|
852
857
|
onNetworkConnection: () => {
|
|
853
858
|
},
|
|
854
859
|
onAuthFailure: () => {
|
|
855
|
-
log3.warn("auth failure",
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
+
log3.warn("auth failure", void 0, {
|
|
861
|
+
F: __dxlog_file3,
|
|
862
|
+
L: 245,
|
|
863
|
+
S: this,
|
|
864
|
+
C: (f, a) => f(...a)
|
|
860
865
|
});
|
|
861
866
|
},
|
|
862
867
|
memberKey: identityKey
|
|
@@ -865,7 +870,7 @@ var IdentityManager = class {
|
|
|
865
870
|
};
|
|
866
871
|
|
|
867
872
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
868
|
-
import
|
|
873
|
+
import invariant3 from "tiny-invariant";
|
|
869
874
|
import { Stream as Stream7 } from "@dxos/codec-protobuf";
|
|
870
875
|
import { signPresentation } from "@dxos/credentials";
|
|
871
876
|
import { todo } from "@dxos/debug";
|
|
@@ -901,7 +906,7 @@ var IdentityServiceImpl = class {
|
|
|
901
906
|
};
|
|
902
907
|
}
|
|
903
908
|
async signPresentation({ presentation, nonce }) {
|
|
904
|
-
|
|
909
|
+
invariant3(this._serviceContext.identityManager.identity, "Identity not initialized.");
|
|
905
910
|
return await signPresentation({
|
|
906
911
|
presentation,
|
|
907
912
|
signer: this._serviceContext.keyring,
|
|
@@ -913,7 +918,7 @@ var IdentityServiceImpl = class {
|
|
|
913
918
|
};
|
|
914
919
|
|
|
915
920
|
// packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
|
|
916
|
-
import
|
|
921
|
+
import invariant4 from "tiny-invariant";
|
|
917
922
|
import { Invitation } from "@dxos/protocols/proto/dxos/client/services";
|
|
918
923
|
var DeviceInvitationProtocol = class {
|
|
919
924
|
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
@@ -930,7 +935,7 @@ var DeviceInvitationProtocol = class {
|
|
|
930
935
|
};
|
|
931
936
|
}
|
|
932
937
|
async admit(request) {
|
|
933
|
-
|
|
938
|
+
invariant4(request.device);
|
|
934
939
|
const identity = this._getIdentity();
|
|
935
940
|
await identity.admitDevice(request.device);
|
|
936
941
|
return {
|
|
@@ -958,9 +963,9 @@ var DeviceInvitationProtocol = class {
|
|
|
958
963
|
};
|
|
959
964
|
}
|
|
960
965
|
async accept(response, request) {
|
|
961
|
-
|
|
966
|
+
invariant4(response.device);
|
|
962
967
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
963
|
-
|
|
968
|
+
invariant4(request.device);
|
|
964
969
|
const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
|
|
965
970
|
await this._acceptIdentity({
|
|
966
971
|
identityKey,
|
|
@@ -978,7 +983,7 @@ var DeviceInvitationProtocol = class {
|
|
|
978
983
|
};
|
|
979
984
|
|
|
980
985
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
981
|
-
import
|
|
986
|
+
import invariant6 from "tiny-invariant";
|
|
982
987
|
import { PushStream, scheduleTask as scheduleTask2, TimeoutError, Trigger as Trigger3 } from "@dxos/async";
|
|
983
988
|
import { AuthenticatingInvitationObservable, AUTHENTICATION_CODE_LENGTH, CancellableInvitationObservable, INVITATION_TIMEOUT } from "@dxos/client-protocol";
|
|
984
989
|
import { Context as Context4 } from "@dxos/context";
|
|
@@ -992,7 +997,7 @@ import { Invitation as Invitation3 } from "@dxos/protocols/proto/dxos/client/ser
|
|
|
992
997
|
import { AuthenticationResponse as AuthenticationResponse2 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
993
998
|
|
|
994
999
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
995
|
-
import
|
|
1000
|
+
import invariant5 from "tiny-invariant";
|
|
996
1001
|
import { Trigger as Trigger2 } from "@dxos/async";
|
|
997
1002
|
import { cancelWithContext, Context as Context3 } from "@dxos/context";
|
|
998
1003
|
import { InvalidInvitationExtensionRoleError } from "@dxos/errors";
|
|
@@ -1002,6 +1007,7 @@ import { schema as schema2, trace as trace2 } from "@dxos/protocols";
|
|
|
1002
1007
|
import { Invitation as Invitation2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1003
1008
|
import { AuthenticationResponse, Options } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
1004
1009
|
import { RpcExtension } from "@dxos/teleport";
|
|
1010
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
|
|
1005
1011
|
var OPTIONS_TIMEOUT = 1e4;
|
|
1006
1012
|
var MAX_OTP_ATTEMPTS = 3;
|
|
1007
1013
|
var InvitationHostExtension = class extends RpcExtension {
|
|
@@ -1029,7 +1035,7 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1029
1035
|
// Perhaps in the future we will have more complex logic here.
|
|
1030
1036
|
InvitationHostService: {
|
|
1031
1037
|
options: async (options) => {
|
|
1032
|
-
|
|
1038
|
+
invariant5(!this._remoteOptions, "Remote options already set.");
|
|
1033
1039
|
this._remoteOptions = options;
|
|
1034
1040
|
this._remoteOptionsTrigger.wake();
|
|
1035
1041
|
},
|
|
@@ -1039,20 +1045,20 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1039
1045
|
log4.trace("dxos.sdk.invitation-handler.host.introduce", trace2.begin({
|
|
1040
1046
|
id: traceId
|
|
1041
1047
|
}), {
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1048
|
+
F: __dxlog_file4,
|
|
1049
|
+
L: 98,
|
|
1050
|
+
S: this,
|
|
1051
|
+
C: (f, a) => f(...a)
|
|
1046
1052
|
});
|
|
1047
1053
|
const invitation = await this._callbacks.resolveInvitation(request);
|
|
1048
1054
|
if (!invitation) {
|
|
1049
1055
|
log4.warn("invitation not found", {
|
|
1050
1056
|
invitationId
|
|
1051
1057
|
}, {
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1058
|
+
F: __dxlog_file4,
|
|
1059
|
+
L: 102,
|
|
1060
|
+
S: this,
|
|
1061
|
+
C: (f, a) => f(...a)
|
|
1056
1062
|
});
|
|
1057
1063
|
this._callbacks.onError(new Error("Invitation not found."));
|
|
1058
1064
|
return {
|
|
@@ -1063,10 +1069,10 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1063
1069
|
log4("guest introduced itself", {
|
|
1064
1070
|
guestProfile: profile
|
|
1065
1071
|
}, {
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1072
|
+
F: __dxlog_file4,
|
|
1073
|
+
L: 111,
|
|
1074
|
+
S: this,
|
|
1075
|
+
C: (f, a) => f(...a)
|
|
1070
1076
|
});
|
|
1071
1077
|
this.guestProfile = profile;
|
|
1072
1078
|
this._callbacks.onStateUpdate({
|
|
@@ -1076,10 +1082,10 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1076
1082
|
log4.trace("dxos.sdk.invitation-handler.host.introduce", trace2.end({
|
|
1077
1083
|
id: traceId
|
|
1078
1084
|
}), {
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1085
|
+
F: __dxlog_file4,
|
|
1086
|
+
L: 118,
|
|
1087
|
+
S: this,
|
|
1088
|
+
C: (f, a) => f(...a)
|
|
1083
1089
|
});
|
|
1084
1090
|
return {
|
|
1085
1091
|
spaceKey: this.invitation.authMethod === Invitation2.AuthMethod.NONE ? this.invitation.spaceKey : void 0,
|
|
@@ -1091,28 +1097,28 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1091
1097
|
log4.trace("dxos.sdk.invitation-handler.host.authenticate", trace2.begin({
|
|
1092
1098
|
id: traceId
|
|
1093
1099
|
}), {
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1100
|
+
F: __dxlog_file4,
|
|
1101
|
+
L: 127,
|
|
1102
|
+
S: this,
|
|
1103
|
+
C: (f, a) => f(...a)
|
|
1098
1104
|
});
|
|
1099
1105
|
log4("received authentication request", {
|
|
1100
1106
|
authCode: code
|
|
1101
1107
|
}, {
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1108
|
+
F: __dxlog_file4,
|
|
1109
|
+
L: 128,
|
|
1110
|
+
S: this,
|
|
1111
|
+
C: (f, a) => f(...a)
|
|
1106
1112
|
});
|
|
1107
1113
|
let status = AuthenticationResponse.Status.OK;
|
|
1108
|
-
|
|
1114
|
+
invariant5(this.invitation, "Invitation is not set.");
|
|
1109
1115
|
switch (this.invitation.authMethod) {
|
|
1110
1116
|
case Invitation2.AuthMethod.NONE: {
|
|
1111
|
-
log4("authentication not required",
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1117
|
+
log4("authentication not required", void 0, {
|
|
1118
|
+
F: __dxlog_file4,
|
|
1119
|
+
L: 134,
|
|
1120
|
+
S: this,
|
|
1121
|
+
C: (f, a) => f(...a)
|
|
1116
1122
|
});
|
|
1117
1123
|
return {
|
|
1118
1124
|
status: AuthenticationResponse.Status.OK
|
|
@@ -1134,10 +1140,10 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1134
1140
|
log4.error("invalid authentication method", {
|
|
1135
1141
|
authMethod: this.invitation.authMethod
|
|
1136
1142
|
}, {
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1143
|
+
F: __dxlog_file4,
|
|
1144
|
+
L: 152,
|
|
1145
|
+
S: this,
|
|
1146
|
+
C: (f, a) => f(...a)
|
|
1141
1147
|
});
|
|
1142
1148
|
status = AuthenticationResponse.Status.INTERNAL_ERROR;
|
|
1143
1149
|
break;
|
|
@@ -1149,10 +1155,10 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1149
1155
|
status
|
|
1150
1156
|
}
|
|
1151
1157
|
}), {
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1158
|
+
F: __dxlog_file4,
|
|
1159
|
+
L: 158,
|
|
1160
|
+
S: this,
|
|
1161
|
+
C: (f, a) => f(...a)
|
|
1156
1162
|
});
|
|
1157
1163
|
return {
|
|
1158
1164
|
status
|
|
@@ -1163,13 +1169,13 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1163
1169
|
log4.trace("dxos.sdk.invitation-handler.host.admit", trace2.begin({
|
|
1164
1170
|
id: traceId
|
|
1165
1171
|
}), {
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1172
|
+
F: __dxlog_file4,
|
|
1173
|
+
L: 164,
|
|
1174
|
+
S: this,
|
|
1175
|
+
C: (f, a) => f(...a)
|
|
1170
1176
|
});
|
|
1171
1177
|
try {
|
|
1172
|
-
|
|
1178
|
+
invariant5(this.invitation, "Invitation is not set.");
|
|
1173
1179
|
if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
|
|
1174
1180
|
throw new Error("Not authenticated");
|
|
1175
1181
|
}
|
|
@@ -1177,10 +1183,10 @@ var InvitationHostExtension = class extends RpcExtension {
|
|
|
1177
1183
|
log4.trace("dxos.sdk.invitation-handler.host.admit", trace2.end({
|
|
1178
1184
|
id: traceId
|
|
1179
1185
|
}), {
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1186
|
+
F: __dxlog_file4,
|
|
1187
|
+
L: 175,
|
|
1188
|
+
S: this,
|
|
1189
|
+
C: (f, a) => f(...a)
|
|
1184
1190
|
});
|
|
1185
1191
|
return response;
|
|
1186
1192
|
} catch (err) {
|
|
@@ -1234,7 +1240,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1234
1240
|
return {
|
|
1235
1241
|
InvitationHostService: {
|
|
1236
1242
|
options: async (options) => {
|
|
1237
|
-
|
|
1243
|
+
invariant5(!this._remoteOptions, "Remote options already set.");
|
|
1238
1244
|
this._remoteOptions = options;
|
|
1239
1245
|
this._remoteOptionsTrigger.wake();
|
|
1240
1246
|
},
|
|
@@ -1254,11 +1260,11 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1254
1260
|
var _a;
|
|
1255
1261
|
await super.onOpen(context);
|
|
1256
1262
|
try {
|
|
1257
|
-
log4("begin options",
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1263
|
+
log4("begin options", void 0, {
|
|
1264
|
+
F: __dxlog_file4,
|
|
1265
|
+
L: 263,
|
|
1266
|
+
S: this,
|
|
1267
|
+
C: (f, a) => f(...a)
|
|
1262
1268
|
});
|
|
1263
1269
|
await cancelWithContext(this._ctx, this.rpc.InvitationHostService.options({
|
|
1264
1270
|
role: Options.Role.GUEST
|
|
@@ -1266,11 +1272,11 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1266
1272
|
await cancelWithContext(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1267
1273
|
timeout: OPTIONS_TIMEOUT
|
|
1268
1274
|
}));
|
|
1269
|
-
log4("end options",
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1275
|
+
log4("end options", void 0, {
|
|
1276
|
+
F: __dxlog_file4,
|
|
1277
|
+
L: 266,
|
|
1278
|
+
S: this,
|
|
1279
|
+
C: (f, a) => f(...a)
|
|
1274
1280
|
});
|
|
1275
1281
|
if (((_a = this._remoteOptions) == null ? void 0 : _a.role) !== Options.Role.HOST) {
|
|
1276
1282
|
throw new InvalidInvitationExtensionRoleError(void 0, {
|
|
@@ -1281,20 +1287,20 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1281
1287
|
this._callbacks.onOpen(this._ctx);
|
|
1282
1288
|
} catch (err) {
|
|
1283
1289
|
log4("openError", err, {
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1290
|
+
F: __dxlog_file4,
|
|
1291
|
+
L: 276,
|
|
1292
|
+
S: this,
|
|
1293
|
+
C: (f, a) => f(...a)
|
|
1288
1294
|
});
|
|
1289
1295
|
this._callbacks.onError(err);
|
|
1290
1296
|
}
|
|
1291
1297
|
}
|
|
1292
1298
|
async onClose() {
|
|
1293
|
-
log4("onClose",
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1299
|
+
log4("onClose", void 0, {
|
|
1300
|
+
F: __dxlog_file4,
|
|
1301
|
+
L: 282,
|
|
1302
|
+
S: this,
|
|
1303
|
+
C: (f, a) => f(...a)
|
|
1298
1304
|
});
|
|
1299
1305
|
await this._ctx.dispose();
|
|
1300
1306
|
}
|
|
@@ -1302,6 +1308,7 @@ var InvitationGuestExtension = class extends RpcExtension {
|
|
|
1302
1308
|
var isAuthenticationRequired = (invitation) => invitation.authMethod !== Invitation2.AuthMethod.NONE;
|
|
1303
1309
|
|
|
1304
1310
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1311
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
1305
1312
|
var InvitationsHandler = class {
|
|
1306
1313
|
/**
|
|
1307
1314
|
* @internal
|
|
@@ -1313,7 +1320,7 @@ var InvitationsHandler = class {
|
|
|
1313
1320
|
var _a;
|
|
1314
1321
|
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
1322
|
const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === Invitation3.AuthMethod.SHARED_SECRET ? generatePasscode(AUTHENTICATION_CODE_LENGTH) : void 0;
|
|
1316
|
-
|
|
1323
|
+
invariant6(protocol);
|
|
1317
1324
|
const invitation = {
|
|
1318
1325
|
invitationId,
|
|
1319
1326
|
type,
|
|
@@ -1335,10 +1342,10 @@ var InvitationsHandler = class {
|
|
|
1335
1342
|
log5("complete", {
|
|
1336
1343
|
...protocol.toJSON()
|
|
1337
1344
|
}, {
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1345
|
+
F: __dxlog_file5,
|
|
1346
|
+
L: 99,
|
|
1347
|
+
S: this,
|
|
1348
|
+
C: (f, a) => f(...a)
|
|
1342
1349
|
});
|
|
1343
1350
|
stream.complete();
|
|
1344
1351
|
});
|
|
@@ -1360,7 +1367,7 @@ var InvitationsHandler = class {
|
|
|
1360
1367
|
var _a2, _b, _c;
|
|
1361
1368
|
try {
|
|
1362
1369
|
const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
|
|
1363
|
-
|
|
1370
|
+
invariant6(deviceKey);
|
|
1364
1371
|
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1365
1372
|
extension.completedTrigger.wake(deviceKey);
|
|
1366
1373
|
return admissionResponse;
|
|
@@ -1376,18 +1383,18 @@ var InvitationsHandler = class {
|
|
|
1376
1383
|
log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace3.begin({
|
|
1377
1384
|
id: traceId
|
|
1378
1385
|
}), {
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1386
|
+
F: __dxlog_file5,
|
|
1387
|
+
L: 138,
|
|
1388
|
+
S: this,
|
|
1389
|
+
C: (f, a) => f(...a)
|
|
1383
1390
|
});
|
|
1384
1391
|
log5("connected", {
|
|
1385
1392
|
...protocol.toJSON()
|
|
1386
1393
|
}, {
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1394
|
+
F: __dxlog_file5,
|
|
1395
|
+
L: 139,
|
|
1396
|
+
S: this,
|
|
1397
|
+
C: (f, a) => f(...a)
|
|
1391
1398
|
});
|
|
1392
1399
|
stream.next({
|
|
1393
1400
|
...invitation,
|
|
@@ -1400,10 +1407,10 @@ var InvitationsHandler = class {
|
|
|
1400
1407
|
guest: deviceKey,
|
|
1401
1408
|
...protocol.toJSON()
|
|
1402
1409
|
}, {
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1410
|
+
F: __dxlog_file5,
|
|
1411
|
+
L: 142,
|
|
1412
|
+
S: this,
|
|
1413
|
+
C: (f, a) => f(...a)
|
|
1407
1414
|
});
|
|
1408
1415
|
stream.next({
|
|
1409
1416
|
...invitation,
|
|
@@ -1412,20 +1419,20 @@ var InvitationsHandler = class {
|
|
|
1412
1419
|
log5.trace("dxos.sdk.invitations-handler.host.onOpen", trace3.end({
|
|
1413
1420
|
id: traceId
|
|
1414
1421
|
}), {
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1422
|
+
F: __dxlog_file5,
|
|
1423
|
+
L: 144,
|
|
1424
|
+
S: this,
|
|
1425
|
+
C: (f, a) => f(...a)
|
|
1419
1426
|
});
|
|
1420
1427
|
} catch (err) {
|
|
1421
1428
|
if (err instanceof TimeoutError) {
|
|
1422
1429
|
log5("timeout", {
|
|
1423
1430
|
...protocol.toJSON()
|
|
1424
1431
|
}, {
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1432
|
+
F: __dxlog_file5,
|
|
1433
|
+
L: 147,
|
|
1434
|
+
S: this,
|
|
1435
|
+
C: (f, a) => f(...a)
|
|
1429
1436
|
});
|
|
1430
1437
|
stream.next({
|
|
1431
1438
|
...invitation,
|
|
@@ -1433,10 +1440,10 @@ var InvitationsHandler = class {
|
|
|
1433
1440
|
});
|
|
1434
1441
|
} else {
|
|
1435
1442
|
log5.error("failed", err, {
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1443
|
+
F: __dxlog_file5,
|
|
1444
|
+
L: 150,
|
|
1445
|
+
S: this,
|
|
1446
|
+
C: (f, a) => f(...a)
|
|
1440
1447
|
});
|
|
1441
1448
|
stream.error(err);
|
|
1442
1449
|
}
|
|
@@ -1444,10 +1451,10 @@ var InvitationsHandler = class {
|
|
|
1444
1451
|
id: traceId,
|
|
1445
1452
|
error: err
|
|
1446
1453
|
}), {
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1454
|
+
F: __dxlog_file5,
|
|
1455
|
+
L: 153,
|
|
1456
|
+
S: this,
|
|
1457
|
+
C: (f, a) => f(...a)
|
|
1451
1458
|
});
|
|
1452
1459
|
} finally {
|
|
1453
1460
|
if (type !== Invitation3.Type.MULTIUSE) {
|
|
@@ -1465,10 +1472,10 @@ var InvitationsHandler = class {
|
|
|
1465
1472
|
log5("timeout", {
|
|
1466
1473
|
...protocol.toJSON()
|
|
1467
1474
|
}, {
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1475
|
+
F: __dxlog_file5,
|
|
1476
|
+
L: 168,
|
|
1477
|
+
S: this,
|
|
1478
|
+
C: (f, a) => f(...a)
|
|
1472
1479
|
});
|
|
1473
1480
|
stream.next({
|
|
1474
1481
|
...invitation,
|
|
@@ -1476,10 +1483,10 @@ var InvitationsHandler = class {
|
|
|
1476
1483
|
});
|
|
1477
1484
|
} else {
|
|
1478
1485
|
log5.error("failed", err, {
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1486
|
+
F: __dxlog_file5,
|
|
1487
|
+
L: 171,
|
|
1488
|
+
S: this,
|
|
1489
|
+
C: (f, a) => f(...a)
|
|
1483
1490
|
});
|
|
1484
1491
|
stream.error(err);
|
|
1485
1492
|
}
|
|
@@ -1519,13 +1526,13 @@ var InvitationsHandler = class {
|
|
|
1519
1526
|
}
|
|
1520
1527
|
acceptInvitation(protocol, invitation) {
|
|
1521
1528
|
const { timeout = INVITATION_TIMEOUT } = invitation;
|
|
1522
|
-
|
|
1529
|
+
invariant6(protocol);
|
|
1523
1530
|
const authenticated = new Trigger3();
|
|
1524
1531
|
let admitted = false;
|
|
1525
1532
|
let currentState;
|
|
1526
1533
|
const stream = new PushStream();
|
|
1527
1534
|
const setState = (newData) => {
|
|
1528
|
-
|
|
1535
|
+
invariant6(newData.state !== void 0);
|
|
1529
1536
|
currentState = newData.state;
|
|
1530
1537
|
stream.next({
|
|
1531
1538
|
...invitation,
|
|
@@ -1538,20 +1545,20 @@ var InvitationsHandler = class {
|
|
|
1538
1545
|
log5("timeout", {
|
|
1539
1546
|
...protocol.toJSON()
|
|
1540
1547
|
}, {
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1548
|
+
F: __dxlog_file5,
|
|
1549
|
+
L: 230,
|
|
1550
|
+
S: this,
|
|
1551
|
+
C: (f, a) => f(...a)
|
|
1545
1552
|
});
|
|
1546
1553
|
setState({
|
|
1547
1554
|
state: Invitation3.State.TIMEOUT
|
|
1548
1555
|
});
|
|
1549
1556
|
} else {
|
|
1550
1557
|
log5.warn("auth failed", err, {
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1558
|
+
F: __dxlog_file5,
|
|
1559
|
+
L: 233,
|
|
1560
|
+
S: this,
|
|
1561
|
+
C: (f, a) => f(...a)
|
|
1555
1562
|
});
|
|
1556
1563
|
stream.error(err);
|
|
1557
1564
|
}
|
|
@@ -1562,10 +1569,10 @@ var InvitationsHandler = class {
|
|
|
1562
1569
|
log5("complete", {
|
|
1563
1570
|
...protocol.toJSON()
|
|
1564
1571
|
}, {
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1572
|
+
F: __dxlog_file5,
|
|
1573
|
+
L: 241,
|
|
1574
|
+
S: this,
|
|
1575
|
+
C: (f, a) => f(...a)
|
|
1569
1576
|
});
|
|
1570
1577
|
stream.complete();
|
|
1571
1578
|
});
|
|
@@ -1577,10 +1584,10 @@ var InvitationsHandler = class {
|
|
|
1577
1584
|
log5("extension disposed", {
|
|
1578
1585
|
currentState
|
|
1579
1586
|
}, {
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1587
|
+
F: __dxlog_file5,
|
|
1588
|
+
L: 251,
|
|
1589
|
+
S: this,
|
|
1590
|
+
C: (f, a) => f(...a)
|
|
1584
1591
|
});
|
|
1585
1592
|
if (!admitted) {
|
|
1586
1593
|
stream.error(new Error("Remote peer disconnected."));
|
|
@@ -1592,10 +1599,10 @@ var InvitationsHandler = class {
|
|
|
1592
1599
|
log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace3.begin({
|
|
1593
1600
|
id: traceId
|
|
1594
1601
|
}), {
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1602
|
+
F: __dxlog_file5,
|
|
1603
|
+
L: 260,
|
|
1604
|
+
S: this,
|
|
1605
|
+
C: (f, a) => f(...a)
|
|
1599
1606
|
});
|
|
1600
1607
|
if (++connectionCount > 1) {
|
|
1601
1608
|
throw new Error(`multiple connections detected: ${connectionCount}`);
|
|
@@ -1604,10 +1611,10 @@ var InvitationsHandler = class {
|
|
|
1604
1611
|
log5("connected", {
|
|
1605
1612
|
...protocol.toJSON()
|
|
1606
1613
|
}, {
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1614
|
+
F: __dxlog_file5,
|
|
1615
|
+
L: 268,
|
|
1616
|
+
S: this,
|
|
1617
|
+
C: (f, a) => f(...a)
|
|
1611
1618
|
});
|
|
1612
1619
|
setState({
|
|
1613
1620
|
state: Invitation3.State.CONNECTED
|
|
@@ -1615,20 +1622,20 @@ var InvitationsHandler = class {
|
|
|
1615
1622
|
log5("introduce", {
|
|
1616
1623
|
...protocol.toJSON()
|
|
1617
1624
|
}, {
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1625
|
+
F: __dxlog_file5,
|
|
1626
|
+
L: 272,
|
|
1627
|
+
S: this,
|
|
1628
|
+
C: (f, a) => f(...a)
|
|
1622
1629
|
});
|
|
1623
1630
|
const introductionResponse = await extension.rpc.InvitationHostService.introduce(protocol.createIntroduction());
|
|
1624
1631
|
log5("introduce response", {
|
|
1625
1632
|
...protocol.toJSON(),
|
|
1626
1633
|
response: introductionResponse
|
|
1627
1634
|
}, {
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1635
|
+
F: __dxlog_file5,
|
|
1636
|
+
L: 276,
|
|
1637
|
+
S: this,
|
|
1638
|
+
C: (f, a) => f(...a)
|
|
1632
1639
|
});
|
|
1633
1640
|
invitation.authMethod = introductionResponse.authMethod;
|
|
1634
1641
|
if (introductionResponse.spaceKey) {
|
|
@@ -1636,11 +1643,11 @@ var InvitationsHandler = class {
|
|
|
1636
1643
|
}
|
|
1637
1644
|
if (isAuthenticationRequired(invitation)) {
|
|
1638
1645
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1639
|
-
log5("guest waiting for authentication code...",
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1646
|
+
log5("guest waiting for authentication code...", void 0, {
|
|
1647
|
+
F: __dxlog_file5,
|
|
1648
|
+
L: 285,
|
|
1649
|
+
S: this,
|
|
1650
|
+
C: (f, a) => f(...a)
|
|
1644
1651
|
});
|
|
1645
1652
|
setState({
|
|
1646
1653
|
state: Invitation3.State.READY_FOR_AUTHENTICATION
|
|
@@ -1648,11 +1655,11 @@ var InvitationsHandler = class {
|
|
|
1648
1655
|
const authCode = await authenticated.wait({
|
|
1649
1656
|
timeout
|
|
1650
1657
|
});
|
|
1651
|
-
log5("sending authentication request",
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1658
|
+
log5("sending authentication request", void 0, {
|
|
1659
|
+
F: __dxlog_file5,
|
|
1660
|
+
L: 289,
|
|
1661
|
+
S: this,
|
|
1662
|
+
C: (f, a) => f(...a)
|
|
1656
1663
|
});
|
|
1657
1664
|
setState({
|
|
1658
1665
|
state: Invitation3.State.AUTHENTICATING
|
|
@@ -1670,10 +1677,10 @@ var InvitationsHandler = class {
|
|
|
1670
1677
|
log5("retrying invalid code", {
|
|
1671
1678
|
attempt
|
|
1672
1679
|
}, {
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1680
|
+
F: __dxlog_file5,
|
|
1681
|
+
L: 300,
|
|
1682
|
+
S: this,
|
|
1683
|
+
C: (f, a) => f(...a)
|
|
1677
1684
|
});
|
|
1678
1685
|
authenticated.reset();
|
|
1679
1686
|
}
|
|
@@ -1687,10 +1694,10 @@ var InvitationsHandler = class {
|
|
|
1687
1694
|
log5("request admission", {
|
|
1688
1695
|
...protocol.toJSON()
|
|
1689
1696
|
}, {
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1697
|
+
F: __dxlog_file5,
|
|
1698
|
+
L: 311,
|
|
1699
|
+
S: this,
|
|
1700
|
+
C: (f, a) => f(...a)
|
|
1694
1701
|
});
|
|
1695
1702
|
const admissionRequest = await protocol.createAdmissionRequest();
|
|
1696
1703
|
const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
|
|
@@ -1699,10 +1706,10 @@ var InvitationsHandler = class {
|
|
|
1699
1706
|
log5("admitted by host", {
|
|
1700
1707
|
...protocol.toJSON()
|
|
1701
1708
|
}, {
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1709
|
+
F: __dxlog_file5,
|
|
1710
|
+
L: 322,
|
|
1711
|
+
S: this,
|
|
1712
|
+
C: (f, a) => f(...a)
|
|
1706
1713
|
});
|
|
1707
1714
|
setState({
|
|
1708
1715
|
...result,
|
|
@@ -1711,30 +1718,30 @@ var InvitationsHandler = class {
|
|
|
1711
1718
|
log5.trace("dxos.sdk.invitations-handler.guest.onOpen", trace3.end({
|
|
1712
1719
|
id: traceId
|
|
1713
1720
|
}), {
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1721
|
+
F: __dxlog_file5,
|
|
1722
|
+
L: 324,
|
|
1723
|
+
S: this,
|
|
1724
|
+
C: (f, a) => f(...a)
|
|
1718
1725
|
});
|
|
1719
1726
|
} catch (err) {
|
|
1720
1727
|
if (err instanceof TimeoutError) {
|
|
1721
1728
|
log5("timeout", {
|
|
1722
1729
|
...protocol.toJSON()
|
|
1723
1730
|
}, {
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1731
|
+
F: __dxlog_file5,
|
|
1732
|
+
L: 327,
|
|
1733
|
+
S: this,
|
|
1734
|
+
C: (f, a) => f(...a)
|
|
1728
1735
|
});
|
|
1729
1736
|
setState({
|
|
1730
1737
|
state: Invitation3.State.TIMEOUT
|
|
1731
1738
|
});
|
|
1732
1739
|
} else {
|
|
1733
1740
|
log5("auth failed", err, {
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1741
|
+
F: __dxlog_file5,
|
|
1742
|
+
L: 330,
|
|
1743
|
+
S: this,
|
|
1744
|
+
C: (f, a) => f(...a)
|
|
1738
1745
|
});
|
|
1739
1746
|
stream.error(err);
|
|
1740
1747
|
}
|
|
@@ -1742,10 +1749,10 @@ var InvitationsHandler = class {
|
|
|
1742
1749
|
id: traceId,
|
|
1743
1750
|
error: err
|
|
1744
1751
|
}), {
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1752
|
+
F: __dxlog_file5,
|
|
1753
|
+
L: 333,
|
|
1754
|
+
S: this,
|
|
1755
|
+
C: (f, a) => f(...a)
|
|
1749
1756
|
});
|
|
1750
1757
|
} finally {
|
|
1751
1758
|
await ctx.dispose();
|
|
@@ -1760,20 +1767,20 @@ var InvitationsHandler = class {
|
|
|
1760
1767
|
log5("timeout", {
|
|
1761
1768
|
...protocol.toJSON()
|
|
1762
1769
|
}, {
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1770
|
+
F: __dxlog_file5,
|
|
1771
|
+
L: 344,
|
|
1772
|
+
S: this,
|
|
1773
|
+
C: (f, a) => f(...a)
|
|
1767
1774
|
});
|
|
1768
1775
|
setState({
|
|
1769
1776
|
state: Invitation3.State.TIMEOUT
|
|
1770
1777
|
});
|
|
1771
1778
|
} else {
|
|
1772
1779
|
log5("auth failed", err, {
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1780
|
+
F: __dxlog_file5,
|
|
1781
|
+
L: 347,
|
|
1782
|
+
S: this,
|
|
1783
|
+
C: (f, a) => f(...a)
|
|
1777
1784
|
});
|
|
1778
1785
|
stream.error(err);
|
|
1779
1786
|
}
|
|
@@ -1782,7 +1789,7 @@ var InvitationsHandler = class {
|
|
|
1782
1789
|
return extension;
|
|
1783
1790
|
};
|
|
1784
1791
|
scheduleTask2(ctx, async () => {
|
|
1785
|
-
|
|
1792
|
+
invariant6(invitation.swarmKey);
|
|
1786
1793
|
const topic = invitation.swarmKey;
|
|
1787
1794
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1788
1795
|
topic,
|
|
@@ -1815,11 +1822,12 @@ var InvitationsHandler = class {
|
|
|
1815
1822
|
};
|
|
1816
1823
|
|
|
1817
1824
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
1818
|
-
import
|
|
1825
|
+
import invariant7 from "tiny-invariant";
|
|
1819
1826
|
import { Event as Event3 } from "@dxos/async";
|
|
1820
1827
|
import { Stream as Stream8 } from "@dxos/codec-protobuf";
|
|
1821
1828
|
import { log as log6 } from "@dxos/log";
|
|
1822
1829
|
import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
|
|
1830
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
1823
1831
|
var InvitationsServiceImpl = class {
|
|
1824
1832
|
constructor(_invitationsHandler, _getHandler) {
|
|
1825
1833
|
this._invitationsHandler = _invitationsHandler;
|
|
@@ -1880,35 +1888,35 @@ var InvitationsServiceImpl = class {
|
|
|
1880
1888
|
});
|
|
1881
1889
|
}
|
|
1882
1890
|
async authenticate({ invitationId, authCode }) {
|
|
1883
|
-
log6("authenticating...",
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1891
|
+
log6("authenticating...", void 0, {
|
|
1892
|
+
F: __dxlog_file6,
|
|
1893
|
+
L: 103,
|
|
1894
|
+
S: this,
|
|
1895
|
+
C: (f, a) => f(...a)
|
|
1888
1896
|
});
|
|
1889
|
-
|
|
1897
|
+
invariant7(invitationId);
|
|
1890
1898
|
const observable = this._acceptInvitations.get(invitationId);
|
|
1891
1899
|
if (!observable) {
|
|
1892
1900
|
log6.warn("invalid invitation", {
|
|
1893
1901
|
invitationId
|
|
1894
1902
|
}, {
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1903
|
+
F: __dxlog_file6,
|
|
1904
|
+
L: 107,
|
|
1905
|
+
S: this,
|
|
1906
|
+
C: (f, a) => f(...a)
|
|
1899
1907
|
});
|
|
1900
1908
|
} else {
|
|
1901
1909
|
await observable.authenticate(authCode);
|
|
1902
1910
|
}
|
|
1903
1911
|
}
|
|
1904
1912
|
async cancelInvitation({ invitationId }) {
|
|
1905
|
-
log6("deleting...",
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1913
|
+
log6("deleting...", void 0, {
|
|
1914
|
+
F: __dxlog_file6,
|
|
1915
|
+
L: 114,
|
|
1916
|
+
S: this,
|
|
1917
|
+
C: (f, a) => f(...a)
|
|
1910
1918
|
});
|
|
1911
|
-
|
|
1919
|
+
invariant7(invitationId);
|
|
1912
1920
|
const created = this._createInvitations.get(invitationId);
|
|
1913
1921
|
const accepted = this._acceptInvitations.get(invitationId);
|
|
1914
1922
|
if (created) {
|
|
@@ -1923,10 +1931,10 @@ var InvitationsServiceImpl = class {
|
|
|
1923
1931
|
log6.warn("invalid invitation", {
|
|
1924
1932
|
invitationId
|
|
1925
1933
|
}, {
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1934
|
+
F: __dxlog_file6,
|
|
1935
|
+
L: 127,
|
|
1936
|
+
S: this,
|
|
1937
|
+
C: (f, a) => f(...a)
|
|
1930
1938
|
});
|
|
1931
1939
|
}
|
|
1932
1940
|
}
|
|
@@ -1983,11 +1991,12 @@ var InvitationsServiceImpl = class {
|
|
|
1983
1991
|
};
|
|
1984
1992
|
|
|
1985
1993
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
1986
|
-
import
|
|
1994
|
+
import invariant8 from "tiny-invariant";
|
|
1987
1995
|
import { createAdmissionCredentials, getCredentialAssertion } from "@dxos/credentials";
|
|
1988
1996
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
1989
1997
|
import { log as log7 } from "@dxos/log";
|
|
1990
1998
|
import { Invitation as Invitation4 } from "@dxos/protocols/proto/dxos/client/services";
|
|
1999
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
1991
2000
|
var SpaceInvitationProtocol = class {
|
|
1992
2001
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
1993
2002
|
this._spaceManager = _spaceManager;
|
|
@@ -2009,24 +2018,24 @@ var SpaceInvitationProtocol = class {
|
|
|
2009
2018
|
}
|
|
2010
2019
|
async admit(request, guestProfile) {
|
|
2011
2020
|
var _a;
|
|
2012
|
-
|
|
2021
|
+
invariant8(this._spaceKey);
|
|
2013
2022
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2014
|
-
|
|
2015
|
-
|
|
2023
|
+
invariant8(space);
|
|
2024
|
+
invariant8(request.space);
|
|
2016
2025
|
const { identityKey, deviceKey } = request.space;
|
|
2017
2026
|
log7("writing guest credentials", {
|
|
2018
2027
|
host: this._signingContext.deviceKey,
|
|
2019
2028
|
guest: deviceKey
|
|
2020
2029
|
}, {
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2030
|
+
F: __dxlog_file7,
|
|
2031
|
+
L: 50,
|
|
2032
|
+
S: this,
|
|
2033
|
+
C: (f, a) => f(...a)
|
|
2025
2034
|
});
|
|
2026
2035
|
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2027
|
-
|
|
2036
|
+
invariant8(credentials[0].credential);
|
|
2028
2037
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2029
|
-
|
|
2038
|
+
invariant8(getCredentialAssertion(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2030
2039
|
await writeMessages2(space.inner.controlPipeline.writer, credentials);
|
|
2031
2040
|
return {
|
|
2032
2041
|
space: {
|
|
@@ -2054,11 +2063,11 @@ var SpaceInvitationProtocol = class {
|
|
|
2054
2063
|
};
|
|
2055
2064
|
}
|
|
2056
2065
|
async accept(response) {
|
|
2057
|
-
|
|
2066
|
+
invariant8(response.space);
|
|
2058
2067
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2059
2068
|
const assertion = getCredentialAssertion(credential);
|
|
2060
|
-
|
|
2061
|
-
|
|
2069
|
+
invariant8(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
|
|
2070
|
+
invariant8(credential.subject.id.equals(this._signingContext.identityKey));
|
|
2062
2071
|
await this._spaceManager.acceptSpace({
|
|
2063
2072
|
spaceKey: assertion.spaceKey,
|
|
2064
2073
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
@@ -2087,7 +2096,7 @@ import { Timeframe } from "@dxos/timeframe";
|
|
|
2087
2096
|
import { ComplexSet as ComplexSet2 } from "@dxos/util";
|
|
2088
2097
|
|
|
2089
2098
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2090
|
-
import
|
|
2099
|
+
import invariant9 from "tiny-invariant";
|
|
2091
2100
|
import { DeferredTask, Event as Event4, scheduleTask as scheduleTask3, sleep, TimeoutError as TimeoutError2, Trigger as Trigger4 } from "@dxos/async";
|
|
2092
2101
|
import { Context as Context5, rejectOnDispose } from "@dxos/context";
|
|
2093
2102
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
@@ -2095,6 +2104,7 @@ import { log as log8 } from "@dxos/log";
|
|
|
2095
2104
|
import { schema as schema3 } from "@dxos/protocols";
|
|
2096
2105
|
import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
|
|
2097
2106
|
import { ComplexMap as ComplexMap2, ComplexSet, entry } from "@dxos/util";
|
|
2107
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
2098
2108
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
2099
2109
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
2100
2110
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -2119,22 +2129,22 @@ var NotarizationPlugin = class {
|
|
|
2119
2129
|
log8("notarize", {
|
|
2120
2130
|
credentials
|
|
2121
2131
|
}, {
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2132
|
+
F: __dxlog_file8,
|
|
2133
|
+
L: 87,
|
|
2134
|
+
S: this,
|
|
2135
|
+
C: (f, a) => f(...a)
|
|
2126
2136
|
});
|
|
2127
|
-
|
|
2137
|
+
invariant9(credentials.every((credential) => credential.id), "Credentials must have an id");
|
|
2128
2138
|
const errors = new Trigger4();
|
|
2129
2139
|
const ctx = this._ctx.derive({
|
|
2130
2140
|
onError: (err) => {
|
|
2131
2141
|
log8.warn("Notarization error", {
|
|
2132
2142
|
err
|
|
2133
2143
|
}, {
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2144
|
+
F: __dxlog_file8,
|
|
2145
|
+
L: 96,
|
|
2146
|
+
S: this,
|
|
2147
|
+
C: (f, a) => f(...a)
|
|
2138
2148
|
});
|
|
2139
2149
|
void ctx.dispose();
|
|
2140
2150
|
errors.throw(err);
|
|
@@ -2147,10 +2157,10 @@ var NotarizationPlugin = class {
|
|
|
2147
2157
|
timeout,
|
|
2148
2158
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
2149
2159
|
}, {
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2160
|
+
F: __dxlog_file8,
|
|
2161
|
+
L: 108,
|
|
2162
|
+
S: this,
|
|
2163
|
+
C: (f, a) => f(...a)
|
|
2154
2164
|
});
|
|
2155
2165
|
void ctx.dispose();
|
|
2156
2166
|
errors.throw(new TimeoutError2(timeout, "Notarization timed out"));
|
|
@@ -2170,10 +2180,10 @@ var NotarizationPlugin = class {
|
|
|
2170
2180
|
log8.warn("Exhausted all peers to notarize with", {
|
|
2171
2181
|
retryIn: retryTimeout
|
|
2172
2182
|
}, {
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2183
|
+
F: __dxlog_file8,
|
|
2184
|
+
L: 133,
|
|
2185
|
+
S: this,
|
|
2186
|
+
C: (f, a) => f(...a)
|
|
2177
2187
|
});
|
|
2178
2188
|
peersTried.clear();
|
|
2179
2189
|
scheduleTask3(ctx, () => notarizeTask.schedule(), retryTimeout);
|
|
@@ -2184,28 +2194,28 @@ var NotarizationPlugin = class {
|
|
|
2184
2194
|
peer: peer.localPeerId,
|
|
2185
2195
|
credentialId: credentials.map((credential) => credential.id)
|
|
2186
2196
|
}, {
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2197
|
+
F: __dxlog_file8,
|
|
2198
|
+
L: 140,
|
|
2199
|
+
S: this,
|
|
2200
|
+
C: (f, a) => f(...a)
|
|
2191
2201
|
});
|
|
2192
2202
|
await peer.rpc.NotarizationService.notarize({
|
|
2193
2203
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
2194
2204
|
});
|
|
2195
|
-
log8("success",
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2205
|
+
log8("success", void 0, {
|
|
2206
|
+
F: __dxlog_file8,
|
|
2207
|
+
L: 144,
|
|
2208
|
+
S: this,
|
|
2209
|
+
C: (f, a) => f(...a)
|
|
2200
2210
|
});
|
|
2201
2211
|
await sleep(successDelay);
|
|
2202
2212
|
} catch (err) {
|
|
2203
2213
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
2204
2214
|
log8.warn("error notarizing (recoverable)", err, {
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2215
|
+
F: __dxlog_file8,
|
|
2216
|
+
L: 148,
|
|
2217
|
+
S: this,
|
|
2218
|
+
C: (f, a) => f(...a)
|
|
2209
2219
|
});
|
|
2210
2220
|
}
|
|
2211
2221
|
notarizeTask.schedule();
|
|
@@ -2219,11 +2229,11 @@ var NotarizationPlugin = class {
|
|
|
2219
2229
|
allNotarized,
|
|
2220
2230
|
errors.wait()
|
|
2221
2231
|
]);
|
|
2222
|
-
log8("done",
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2232
|
+
log8("done", void 0, {
|
|
2233
|
+
F: __dxlog_file8,
|
|
2234
|
+
L: 159,
|
|
2235
|
+
S: this,
|
|
2236
|
+
C: (f, a) => f(...a)
|
|
2227
2237
|
});
|
|
2228
2238
|
} finally {
|
|
2229
2239
|
await ctx.dispose();
|
|
@@ -2242,7 +2252,7 @@ var NotarizationPlugin = class {
|
|
|
2242
2252
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2243
2253
|
}
|
|
2244
2254
|
setWriter(writer) {
|
|
2245
|
-
|
|
2255
|
+
invariant9(!this._writer, "Writer already set.");
|
|
2246
2256
|
this._writer = writer;
|
|
2247
2257
|
}
|
|
2248
2258
|
async _waitUntilProcessed(id) {
|
|
@@ -2260,7 +2270,7 @@ var NotarizationPlugin = class {
|
|
|
2260
2270
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2261
2271
|
}
|
|
2262
2272
|
for (const credential of (_a = request.credentials) != null ? _a : []) {
|
|
2263
|
-
|
|
2273
|
+
invariant9(credential.id, "Credential must have an id");
|
|
2264
2274
|
if (this._processedCredentials.has(credential.id)) {
|
|
2265
2275
|
continue;
|
|
2266
2276
|
}
|
|
@@ -2273,10 +2283,10 @@ var NotarizationPlugin = class {
|
|
|
2273
2283
|
log8("extension opened", {
|
|
2274
2284
|
peer: extension.localPeerId
|
|
2275
2285
|
}, {
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2286
|
+
F: __dxlog_file8,
|
|
2287
|
+
L: 208,
|
|
2288
|
+
S: this,
|
|
2289
|
+
C: (f, a) => f(...a)
|
|
2280
2290
|
});
|
|
2281
2291
|
this._extensions.add(extension);
|
|
2282
2292
|
this._extensionOpened.emit();
|
|
@@ -2285,10 +2295,10 @@ var NotarizationPlugin = class {
|
|
|
2285
2295
|
log8("extension closed", {
|
|
2286
2296
|
peer: extension.localPeerId
|
|
2287
2297
|
}, {
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2298
|
+
F: __dxlog_file8,
|
|
2299
|
+
L: 213,
|
|
2300
|
+
S: this,
|
|
2301
|
+
C: (f, a) => f(...a)
|
|
2292
2302
|
});
|
|
2293
2303
|
this._extensions.delete(extension);
|
|
2294
2304
|
},
|
|
@@ -2329,7 +2339,7 @@ var NotarizationTeleportExtension = class extends RpcExtension2 {
|
|
|
2329
2339
|
};
|
|
2330
2340
|
|
|
2331
2341
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2332
|
-
|
|
2342
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
2333
2343
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2334
2344
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2335
2345
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2338,7 +2348,8 @@ var __decorate = function(decorators, target, key, desc) {
|
|
|
2338
2348
|
if (d = decorators[i])
|
|
2339
2349
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2340
2350
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2341
|
-
}
|
|
2351
|
+
}
|
|
2352
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2342
2353
|
var DataSpace = class DataSpace2 {
|
|
2343
2354
|
constructor(params) {
|
|
2344
2355
|
this._ctx = new Context6();
|
|
@@ -2425,18 +2436,18 @@ var DataSpace = class DataSpace2 {
|
|
|
2425
2436
|
} catch (err) {
|
|
2426
2437
|
if (err instanceof CancelledError) {
|
|
2427
2438
|
log9("Data pipeline initialization cancelled", err, {
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2439
|
+
F: __dxlog_file9,
|
|
2440
|
+
L: 173,
|
|
2441
|
+
S: this,
|
|
2442
|
+
C: (f, a) => f(...a)
|
|
2432
2443
|
});
|
|
2433
2444
|
return;
|
|
2434
2445
|
}
|
|
2435
2446
|
log9.error("Error initializing data pipeline", err, {
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2447
|
+
F: __dxlog_file9,
|
|
2448
|
+
L: 177,
|
|
2449
|
+
S: this,
|
|
2450
|
+
C: (f, a) => f(...a)
|
|
2440
2451
|
});
|
|
2441
2452
|
this._state = SpaceState.ERROR;
|
|
2442
2453
|
this.error = err;
|
|
@@ -2458,11 +2469,11 @@ var DataSpace = class DataSpace2 {
|
|
|
2458
2469
|
});
|
|
2459
2470
|
this.metrics.controlPipelineReady = new Date();
|
|
2460
2471
|
await this._createWritableFeeds();
|
|
2461
|
-
log9("Writable feeds created",
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2472
|
+
log9("Writable feeds created", void 0, {
|
|
2473
|
+
F: __dxlog_file9,
|
|
2474
|
+
L: 201,
|
|
2475
|
+
S: this,
|
|
2476
|
+
C: (f, a) => f(...a)
|
|
2466
2477
|
});
|
|
2467
2478
|
this.stateUpdate.emit();
|
|
2468
2479
|
this.notarizationPlugin.setWriter(createMappedFeedWriter((credential) => ({
|
|
@@ -2473,22 +2484,22 @@ var DataSpace = class DataSpace2 {
|
|
|
2473
2484
|
await this._inner.initializeDataPipeline();
|
|
2474
2485
|
this.metrics.dataPipelineOpen = new Date();
|
|
2475
2486
|
await cancelWithContext2(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
2476
|
-
log9("waiting for data pipeline to reach target timeframe",
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2487
|
+
log9("waiting for data pipeline to reach target timeframe", void 0, {
|
|
2488
|
+
F: __dxlog_file9,
|
|
2489
|
+
L: 220,
|
|
2490
|
+
S: this,
|
|
2491
|
+
C: (f, a) => f(...a)
|
|
2481
2492
|
});
|
|
2482
2493
|
await this._inner.dataPipeline.pipelineState.waitUntilReachedTargetTimeframe({
|
|
2483
2494
|
ctx: this._ctx,
|
|
2484
2495
|
breakOnStall: false
|
|
2485
2496
|
});
|
|
2486
2497
|
this.metrics.dataPipelineReady = new Date();
|
|
2487
|
-
log9("data pipeline ready",
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2498
|
+
log9("data pipeline ready", void 0, {
|
|
2499
|
+
F: __dxlog_file9,
|
|
2500
|
+
L: 229,
|
|
2501
|
+
S: this,
|
|
2502
|
+
C: (f, a) => f(...a)
|
|
2492
2503
|
});
|
|
2493
2504
|
await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
|
|
2494
2505
|
this._state = SpaceState.READY;
|
|
@@ -2567,15 +2578,15 @@ var DataSpace = class DataSpace2 {
|
|
|
2567
2578
|
}
|
|
2568
2579
|
}
|
|
2569
2580
|
};
|
|
2570
|
-
|
|
2581
|
+
_ts_decorate([
|
|
2571
2582
|
timed(1e4)
|
|
2572
2583
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2573
|
-
DataSpace =
|
|
2584
|
+
DataSpace = _ts_decorate([
|
|
2574
2585
|
trackLeaks("open", "close")
|
|
2575
2586
|
], DataSpace);
|
|
2576
2587
|
|
|
2577
2588
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2578
|
-
import
|
|
2589
|
+
import invariant10 from "tiny-invariant";
|
|
2579
2590
|
import { Event as Event6, synchronized, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
2580
2591
|
import { cancelWithContext as cancelWithContext3, Context as Context7 } from "@dxos/context";
|
|
2581
2592
|
import { getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
@@ -2657,7 +2668,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2657
2668
|
};
|
|
2658
2669
|
|
|
2659
2670
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2660
|
-
|
|
2671
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
2661
2672
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2662
2673
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2663
2674
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2666,7 +2677,8 @@ var __decorate2 = function(decorators, target, key, desc) {
|
|
|
2666
2677
|
if (d = decorators[i])
|
|
2667
2678
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2668
2679
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2669
|
-
}
|
|
2680
|
+
}
|
|
2681
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
2670
2682
|
var DataSpaceManager = class DataSpaceManager2 {
|
|
2671
2683
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
|
|
2672
2684
|
this._spaceManager = _spaceManager;
|
|
@@ -2686,38 +2698,38 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2686
2698
|
return this._spaces;
|
|
2687
2699
|
}
|
|
2688
2700
|
async open() {
|
|
2689
|
-
log10("open",
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2701
|
+
log10("open", void 0, {
|
|
2702
|
+
F: __dxlog_file10,
|
|
2703
|
+
L: 80,
|
|
2704
|
+
S: this,
|
|
2705
|
+
C: (f, a) => f(...a)
|
|
2694
2706
|
});
|
|
2695
2707
|
log10.trace("dxos.echo.data-space-manager.open", trace4.begin({
|
|
2696
2708
|
id: this._instanceId
|
|
2697
2709
|
}), {
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2710
|
+
F: __dxlog_file10,
|
|
2711
|
+
L: 81,
|
|
2712
|
+
S: this,
|
|
2713
|
+
C: (f, a) => f(...a)
|
|
2702
2714
|
});
|
|
2703
2715
|
await this._metadataStore.load();
|
|
2704
2716
|
log10("metadata loaded", {
|
|
2705
2717
|
spaces: this._metadataStore.spaces.length
|
|
2706
2718
|
}, {
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2719
|
+
F: __dxlog_file10,
|
|
2720
|
+
L: 83,
|
|
2721
|
+
S: this,
|
|
2722
|
+
C: (f, a) => f(...a)
|
|
2711
2723
|
});
|
|
2712
2724
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2713
2725
|
try {
|
|
2714
2726
|
log10("load space", {
|
|
2715
2727
|
spaceMetadata
|
|
2716
2728
|
}, {
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2729
|
+
F: __dxlog_file10,
|
|
2730
|
+
L: 87,
|
|
2731
|
+
S: this,
|
|
2732
|
+
C: (f, a) => f(...a)
|
|
2721
2733
|
});
|
|
2722
2734
|
const space = await this._constructSpace(spaceMetadata);
|
|
2723
2735
|
space.initializeDataPipelineAsync();
|
|
@@ -2726,10 +2738,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2726
2738
|
spaceMetadata,
|
|
2727
2739
|
err
|
|
2728
2740
|
}, {
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2741
|
+
F: __dxlog_file10,
|
|
2742
|
+
L: 91,
|
|
2743
|
+
S: this,
|
|
2744
|
+
C: (f, a) => f(...a)
|
|
2733
2745
|
});
|
|
2734
2746
|
}
|
|
2735
2747
|
}
|
|
@@ -2738,18 +2750,18 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2738
2750
|
log10.trace("dxos.echo.data-space-manager.open", trace4.end({
|
|
2739
2751
|
id: this._instanceId
|
|
2740
2752
|
}), {
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2753
|
+
F: __dxlog_file10,
|
|
2754
|
+
L: 97,
|
|
2755
|
+
S: this,
|
|
2756
|
+
C: (f, a) => f(...a)
|
|
2745
2757
|
});
|
|
2746
2758
|
}
|
|
2747
2759
|
async close() {
|
|
2748
|
-
log10("close",
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2760
|
+
log10("close", void 0, {
|
|
2761
|
+
F: __dxlog_file10,
|
|
2762
|
+
L: 102,
|
|
2763
|
+
S: this,
|
|
2764
|
+
C: (f, a) => f(...a)
|
|
2753
2765
|
});
|
|
2754
2766
|
this._isOpen = false;
|
|
2755
2767
|
await this._ctx.dispose();
|
|
@@ -2761,7 +2773,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2761
2773
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
2762
2774
|
*/
|
|
2763
2775
|
async createSpace() {
|
|
2764
|
-
|
|
2776
|
+
invariant10(this._isOpen, "Not open.");
|
|
2765
2777
|
const spaceKey = await this._keyring.createKey();
|
|
2766
2778
|
const controlFeedKey = await this._keyring.createKey();
|
|
2767
2779
|
const dataFeedKey = await this._keyring.createKey();
|
|
@@ -2774,16 +2786,16 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2774
2786
|
log10("creating space...", {
|
|
2775
2787
|
spaceKey
|
|
2776
2788
|
}, {
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2789
|
+
F: __dxlog_file10,
|
|
2790
|
+
L: 126,
|
|
2791
|
+
S: this,
|
|
2792
|
+
C: (f, a) => f(...a)
|
|
2781
2793
|
});
|
|
2782
2794
|
const space = await this._constructSpace(metadata);
|
|
2783
2795
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
2784
2796
|
await this._metadataStore.addSpace(metadata);
|
|
2785
2797
|
const memberCredential = credentials[1];
|
|
2786
|
-
|
|
2798
|
+
invariant10(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
|
|
2787
2799
|
await this._signingContext.recordCredential(memberCredential);
|
|
2788
2800
|
await space.initializeDataPipeline();
|
|
2789
2801
|
this.updated.emit();
|
|
@@ -2794,13 +2806,13 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2794
2806
|
log10("accept space", {
|
|
2795
2807
|
opts
|
|
2796
2808
|
}, {
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2809
|
+
F: __dxlog_file10,
|
|
2810
|
+
L: 145,
|
|
2811
|
+
S: this,
|
|
2812
|
+
C: (f, a) => f(...a)
|
|
2801
2813
|
});
|
|
2802
|
-
|
|
2803
|
-
|
|
2814
|
+
invariant10(this._isOpen, "Not open.");
|
|
2815
|
+
invariant10(!this._spaces.has(opts.spaceKey), "Space already exists.");
|
|
2804
2816
|
const metadata = {
|
|
2805
2817
|
key: opts.spaceKey,
|
|
2806
2818
|
genesisFeedKey: opts.genesisFeedKey,
|
|
@@ -2828,10 +2840,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2828
2840
|
log10("construct space", {
|
|
2829
2841
|
metadata
|
|
2830
2842
|
}, {
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2843
|
+
F: __dxlog_file10,
|
|
2844
|
+
L: 180,
|
|
2845
|
+
S: this,
|
|
2846
|
+
C: (f, a) => f(...a)
|
|
2835
2847
|
});
|
|
2836
2848
|
const gossip = new Gossip({
|
|
2837
2849
|
localPeerId: this._signingContext.deviceKey
|
|
@@ -2863,11 +2875,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2863
2875
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
2864
2876
|
},
|
|
2865
2877
|
onAuthFailure: () => {
|
|
2866
|
-
log10.warn("auth failure",
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2878
|
+
log10.warn("auth failure", void 0, {
|
|
2879
|
+
F: __dxlog_file10,
|
|
2880
|
+
L: 211,
|
|
2881
|
+
S: this,
|
|
2882
|
+
C: (f, a) => f(...a)
|
|
2871
2883
|
});
|
|
2872
2884
|
},
|
|
2873
2885
|
memberKey: this._signingContext.identityKey
|
|
@@ -2887,10 +2899,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2887
2899
|
log10("before space ready", {
|
|
2888
2900
|
space: space.key
|
|
2889
2901
|
}, {
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2902
|
+
F: __dxlog_file10,
|
|
2903
|
+
L: 228,
|
|
2904
|
+
S: this,
|
|
2905
|
+
C: (f, a) => f(...a)
|
|
2894
2906
|
});
|
|
2895
2907
|
this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
2896
2908
|
},
|
|
@@ -2899,10 +2911,10 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2899
2911
|
space: space.key,
|
|
2900
2912
|
open: this._isOpen
|
|
2901
2913
|
}, {
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2914
|
+
F: __dxlog_file10,
|
|
2915
|
+
L: 235,
|
|
2916
|
+
S: this,
|
|
2917
|
+
C: (f, a) => f(...a)
|
|
2906
2918
|
});
|
|
2907
2919
|
if (this._isOpen) {
|
|
2908
2920
|
this.updated.emit();
|
|
@@ -2922,24 +2934,24 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2922
2934
|
return dataSpace;
|
|
2923
2935
|
}
|
|
2924
2936
|
};
|
|
2925
|
-
|
|
2937
|
+
_ts_decorate2([
|
|
2926
2938
|
synchronized
|
|
2927
2939
|
], DataSpaceManager.prototype, "open", null);
|
|
2928
|
-
|
|
2940
|
+
_ts_decorate2([
|
|
2929
2941
|
synchronized
|
|
2930
2942
|
], DataSpaceManager.prototype, "close", null);
|
|
2931
|
-
|
|
2943
|
+
_ts_decorate2([
|
|
2932
2944
|
synchronized
|
|
2933
2945
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
2934
|
-
|
|
2946
|
+
_ts_decorate2([
|
|
2935
2947
|
synchronized
|
|
2936
2948
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
2937
|
-
DataSpaceManager =
|
|
2949
|
+
DataSpaceManager = _ts_decorate2([
|
|
2938
2950
|
trackLeaks2("open", "close")
|
|
2939
2951
|
], DataSpaceManager);
|
|
2940
2952
|
|
|
2941
2953
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
2942
|
-
import { EventSubscriptions as EventSubscriptions2, scheduleTask as scheduleTask5 } from "@dxos/async";
|
|
2954
|
+
import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask5 } from "@dxos/async";
|
|
2943
2955
|
import { Stream as Stream9 } from "@dxos/codec-protobuf";
|
|
2944
2956
|
import { raise, todo as todo2 } from "@dxos/debug";
|
|
2945
2957
|
import { SpaceNotFoundError } from "@dxos/echo-pipeline";
|
|
@@ -2947,7 +2959,7 @@ import { log as log11 } from "@dxos/log";
|
|
|
2947
2959
|
import { encodeError } from "@dxos/protocols";
|
|
2948
2960
|
import { SpaceMember as SpaceMember2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2949
2961
|
import { humanize } from "@dxos/util";
|
|
2950
|
-
var
|
|
2962
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
2951
2963
|
var SpacesServiceImpl = class {
|
|
2952
2964
|
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
2953
2965
|
this._identityManager = _identityManager;
|
|
@@ -2961,28 +2973,30 @@ var SpacesServiceImpl = class {
|
|
|
2961
2973
|
}
|
|
2962
2974
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2963
2975
|
const space = await dataSpaceManager.createSpace();
|
|
2964
|
-
return this.
|
|
2976
|
+
return this._serializeSpace(space);
|
|
2965
2977
|
}
|
|
2966
2978
|
async updateSpace(request) {
|
|
2967
2979
|
todo2();
|
|
2968
2980
|
}
|
|
2969
2981
|
querySpaces() {
|
|
2970
2982
|
return new Stream9(({ next, ctx }) => {
|
|
2971
|
-
const
|
|
2983
|
+
const scheduler = new UpdateScheduler(ctx, async () => {
|
|
2972
2984
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2973
|
-
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this.
|
|
2985
|
+
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
2974
2986
|
log11("update", {
|
|
2975
2987
|
spaces
|
|
2976
2988
|
}, {
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2989
|
+
F: __dxlog_file11,
|
|
2990
|
+
L: 60,
|
|
2991
|
+
S: this,
|
|
2992
|
+
C: (f, a) => f(...a)
|
|
2981
2993
|
});
|
|
2982
2994
|
next({
|
|
2983
2995
|
spaces
|
|
2984
2996
|
});
|
|
2985
|
-
}
|
|
2997
|
+
}, {
|
|
2998
|
+
maxFrequency: 2
|
|
2999
|
+
});
|
|
2986
3000
|
scheduleTask5(ctx, async () => {
|
|
2987
3001
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2988
3002
|
const subscriptions = new EventSubscriptions2();
|
|
@@ -2990,21 +3004,21 @@ var SpacesServiceImpl = class {
|
|
|
2990
3004
|
const subscribeSpaces = () => {
|
|
2991
3005
|
subscriptions.clear();
|
|
2992
3006
|
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.
|
|
3007
|
+
subscriptions.add(space.stateUpdate.on(ctx, () => scheduler.trigger()));
|
|
3008
|
+
subscriptions.add(space.presence.updated.on(ctx, () => scheduler.trigger()));
|
|
3009
|
+
subscriptions.add(space.dataPipeline.onNewEpoch.on(ctx, () => scheduler.trigger()));
|
|
3010
|
+
space.inner.controlPipeline.state.timeframeUpdate.on(ctx, () => scheduler.trigger());
|
|
2997
3011
|
if (space.dataPipeline.pipelineState) {
|
|
2998
|
-
subscriptions.add(space.dataPipeline.pipelineState.timeframeUpdate.
|
|
3012
|
+
subscriptions.add(space.dataPipeline.pipelineState.timeframeUpdate.on(ctx, () => scheduler.trigger()));
|
|
2999
3013
|
}
|
|
3000
3014
|
}
|
|
3001
3015
|
};
|
|
3002
3016
|
dataSpaceManager.updated.on(ctx, () => {
|
|
3003
3017
|
subscribeSpaces();
|
|
3004
|
-
|
|
3018
|
+
scheduler.trigger();
|
|
3005
3019
|
});
|
|
3006
3020
|
subscribeSpaces();
|
|
3007
|
-
|
|
3021
|
+
scheduler.trigger();
|
|
3008
3022
|
});
|
|
3009
3023
|
if (!this._identityManager.identity) {
|
|
3010
3024
|
next({
|
|
@@ -3062,7 +3076,7 @@ var SpacesServiceImpl = class {
|
|
|
3062
3076
|
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : raise(new SpaceNotFoundError(spaceKey));
|
|
3063
3077
|
await space.createEpoch();
|
|
3064
3078
|
}
|
|
3065
|
-
|
|
3079
|
+
_serializeSpace(space) {
|
|
3066
3080
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
3067
3081
|
return {
|
|
3068
3082
|
spaceKey: space.key,
|
|
@@ -3102,7 +3116,7 @@ var SpacesServiceImpl = class {
|
|
|
3102
3116
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
3103
3117
|
|
|
3104
3118
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3105
|
-
import
|
|
3119
|
+
import invariant11 from "tiny-invariant";
|
|
3106
3120
|
import { Trigger as Trigger5 } from "@dxos/async";
|
|
3107
3121
|
import { getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
3108
3122
|
import { failUndefined as failUndefined3 } from "@dxos/debug";
|
|
@@ -3114,6 +3128,7 @@ import { log as log12 } from "@dxos/log";
|
|
|
3114
3128
|
import { STORAGE_VERSION, trace as trace5 } from "@dxos/protocols";
|
|
3115
3129
|
import { Invitation as Invitation5 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3116
3130
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
3131
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
3117
3132
|
var ServiceContext = class {
|
|
3118
3133
|
// prettier-ignore
|
|
3119
3134
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
@@ -3157,17 +3172,17 @@ var ServiceContext = class {
|
|
|
3157
3172
|
log12.trace("dxos.sdk.service-context.open", trace5.begin({
|
|
3158
3173
|
id: this._instanceId
|
|
3159
3174
|
}), {
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3175
|
+
F: __dxlog_file12,
|
|
3176
|
+
L: 126,
|
|
3177
|
+
S: this,
|
|
3178
|
+
C: (f, a) => f(...a)
|
|
3164
3179
|
});
|
|
3165
3180
|
await this._checkStorageVersion();
|
|
3166
|
-
log12("opening...",
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3181
|
+
log12("opening...", void 0, {
|
|
3182
|
+
F: __dxlog_file12,
|
|
3183
|
+
L: 130,
|
|
3184
|
+
S: this,
|
|
3185
|
+
C: (f, a) => f(...a)
|
|
3171
3186
|
});
|
|
3172
3187
|
await this.signalManager.open();
|
|
3173
3188
|
await this.networkManager.open();
|
|
@@ -3176,28 +3191,28 @@ var ServiceContext = class {
|
|
|
3176
3191
|
if (this.identityManager.identity) {
|
|
3177
3192
|
await this._initialize();
|
|
3178
3193
|
}
|
|
3179
|
-
log12("opened",
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3194
|
+
log12("opened", void 0, {
|
|
3195
|
+
F: __dxlog_file12,
|
|
3196
|
+
L: 138,
|
|
3197
|
+
S: this,
|
|
3198
|
+
C: (f, a) => f(...a)
|
|
3184
3199
|
});
|
|
3185
3200
|
log12.trace("dxos.sdk.service-context.open", trace5.end({
|
|
3186
3201
|
id: this._instanceId
|
|
3187
3202
|
}), {
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3203
|
+
F: __dxlog_file12,
|
|
3204
|
+
L: 139,
|
|
3205
|
+
S: this,
|
|
3206
|
+
C: (f, a) => f(...a)
|
|
3192
3207
|
});
|
|
3193
3208
|
}
|
|
3194
3209
|
async close() {
|
|
3195
3210
|
var _a, _b;
|
|
3196
|
-
log12("closing...",
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3211
|
+
log12("closing...", void 0, {
|
|
3212
|
+
F: __dxlog_file12,
|
|
3213
|
+
L: 143,
|
|
3214
|
+
S: this,
|
|
3215
|
+
C: (f, a) => f(...a)
|
|
3201
3216
|
});
|
|
3202
3217
|
await ((_a = this._deviceSpaceSync) == null ? void 0 : _a.close());
|
|
3203
3218
|
await ((_b = this.dataSpaceManager) == null ? void 0 : _b.close());
|
|
@@ -3207,11 +3222,11 @@ var ServiceContext = class {
|
|
|
3207
3222
|
await this.networkManager.close();
|
|
3208
3223
|
await this.signalManager.close();
|
|
3209
3224
|
this.dataServiceSubscriptions.clear();
|
|
3210
|
-
log12("closed",
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3225
|
+
log12("closed", void 0, {
|
|
3226
|
+
F: __dxlog_file12,
|
|
3227
|
+
L: 152,
|
|
3228
|
+
S: this,
|
|
3229
|
+
C: (f, a) => f(...a)
|
|
3215
3230
|
});
|
|
3216
3231
|
}
|
|
3217
3232
|
async createIdentity(params = {}) {
|
|
@@ -3221,7 +3236,7 @@ var ServiceContext = class {
|
|
|
3221
3236
|
}
|
|
3222
3237
|
getInvitationHandler(invitation) {
|
|
3223
3238
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3224
|
-
|
|
3239
|
+
invariant11(factory, `Unknown invitation kind: ${invitation.kind}`);
|
|
3225
3240
|
return factory(invitation);
|
|
3226
3241
|
}
|
|
3227
3242
|
async _acceptIdentity(params) {
|
|
@@ -3238,11 +3253,11 @@ var ServiceContext = class {
|
|
|
3238
3253
|
// Called when identity is created.
|
|
3239
3254
|
async _initialize() {
|
|
3240
3255
|
var _a;
|
|
3241
|
-
log12("initializing spaces...",
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3256
|
+
log12("initializing spaces...", void 0, {
|
|
3257
|
+
F: __dxlog_file12,
|
|
3258
|
+
L: 185,
|
|
3259
|
+
S: this,
|
|
3260
|
+
C: (f, a) => f(...a)
|
|
3246
3261
|
});
|
|
3247
3262
|
const identity = (_a = this.identityManager.identity) != null ? _a : failUndefined3();
|
|
3248
3263
|
const signingContext = {
|
|
@@ -3261,7 +3276,7 @@ var ServiceContext = class {
|
|
|
3261
3276
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
3262
3277
|
await this.dataSpaceManager.open();
|
|
3263
3278
|
this._handlerFactories.set(Invitation5.Kind.SPACE, (invitation) => {
|
|
3264
|
-
|
|
3279
|
+
invariant11(this.dataSpaceManager, "dataSpaceManager not initialized yet");
|
|
3265
3280
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
3266
3281
|
});
|
|
3267
3282
|
this.initialized.wake();
|
|
@@ -3278,10 +3293,10 @@ var ServiceContext = class {
|
|
|
3278
3293
|
log12("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3279
3294
|
details: assertion
|
|
3280
3295
|
}, {
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3296
|
+
F: __dxlog_file12,
|
|
3297
|
+
L: 224,
|
|
3298
|
+
S: this,
|
|
3299
|
+
C: (f, a) => f(...a)
|
|
3285
3300
|
});
|
|
3286
3301
|
return;
|
|
3287
3302
|
}
|
|
@@ -3289,10 +3304,10 @@ var ServiceContext = class {
|
|
|
3289
3304
|
log12("space already exists, ignoring space admission", {
|
|
3290
3305
|
details: assertion
|
|
3291
3306
|
}, {
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3307
|
+
F: __dxlog_file12,
|
|
3308
|
+
L: 228,
|
|
3309
|
+
S: this,
|
|
3310
|
+
C: (f, a) => f(...a)
|
|
3296
3311
|
});
|
|
3297
3312
|
return;
|
|
3298
3313
|
}
|
|
@@ -3300,21 +3315,21 @@ var ServiceContext = class {
|
|
|
3300
3315
|
log12("accepting space recorded in halo", {
|
|
3301
3316
|
details: assertion
|
|
3302
3317
|
}, {
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3318
|
+
F: __dxlog_file12,
|
|
3319
|
+
L: 233,
|
|
3320
|
+
S: this,
|
|
3321
|
+
C: (f, a) => f(...a)
|
|
3307
3322
|
});
|
|
3308
3323
|
await this.dataSpaceManager.acceptSpace({
|
|
3309
3324
|
spaceKey: assertion.spaceKey,
|
|
3310
3325
|
genesisFeedKey: assertion.genesisFeedKey
|
|
3311
3326
|
});
|
|
3312
3327
|
} catch (err) {
|
|
3313
|
-
log12.catch(err,
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3328
|
+
log12.catch(err, void 0, {
|
|
3329
|
+
F: __dxlog_file12,
|
|
3330
|
+
L: 239,
|
|
3331
|
+
S: this,
|
|
3332
|
+
C: (f, a) => f(...a)
|
|
3318
3333
|
});
|
|
3319
3334
|
}
|
|
3320
3335
|
}
|
|
@@ -3327,7 +3342,7 @@ var ServiceContext = class {
|
|
|
3327
3342
|
import { asyncTimeout, Trigger as Trigger6 } from "@dxos/async";
|
|
3328
3343
|
import { RESOURCE_LOCK_TIMEOUT } from "@dxos/client-protocol";
|
|
3329
3344
|
import { log as log13, logInfo } from "@dxos/log";
|
|
3330
|
-
|
|
3345
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
3331
3346
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3332
3347
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3333
3348
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3336,7 +3351,8 @@ var __decorate3 = function(decorators, target, key, desc) {
|
|
|
3336
3351
|
if (d = decorators[i])
|
|
3337
3352
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3338
3353
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3339
|
-
}
|
|
3354
|
+
}
|
|
3355
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/browser.ts";
|
|
3340
3356
|
var Message;
|
|
3341
3357
|
(function(Message2) {
|
|
3342
3358
|
Message2["ACQUIRING"] = "acquiring";
|
|
@@ -3358,32 +3374,32 @@ var Lock = class {
|
|
|
3358
3374
|
message: Message.ACQUIRING
|
|
3359
3375
|
});
|
|
3360
3376
|
try {
|
|
3361
|
-
log13("aquiring lock...",
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3377
|
+
log13("aquiring lock...", void 0, {
|
|
3378
|
+
F: __dxlog_file13,
|
|
3379
|
+
L: 42,
|
|
3380
|
+
S: this,
|
|
3381
|
+
C: (f, a) => f(...a)
|
|
3366
3382
|
});
|
|
3367
3383
|
await asyncTimeout(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
3368
|
-
log13("acquired lock",
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3384
|
+
log13("acquired lock", void 0, {
|
|
3385
|
+
F: __dxlog_file13,
|
|
3386
|
+
L: 44,
|
|
3387
|
+
S: this,
|
|
3388
|
+
C: (f, a) => f(...a)
|
|
3373
3389
|
});
|
|
3374
3390
|
} catch (e) {
|
|
3375
|
-
log13("stealing lock...",
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3391
|
+
log13("stealing lock...", void 0, {
|
|
3392
|
+
F: __dxlog_file13,
|
|
3393
|
+
L: 46,
|
|
3394
|
+
S: this,
|
|
3395
|
+
C: (f, a) => f(...a)
|
|
3380
3396
|
});
|
|
3381
3397
|
await this._requestLock(true);
|
|
3382
|
-
log13("stolen lock",
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3398
|
+
log13("stolen lock", void 0, {
|
|
3399
|
+
F: __dxlog_file13,
|
|
3400
|
+
L: 48,
|
|
3401
|
+
S: this,
|
|
3402
|
+
C: (f, a) => f(...a)
|
|
3387
3403
|
});
|
|
3388
3404
|
}
|
|
3389
3405
|
}
|
|
@@ -3399,10 +3415,10 @@ var Lock = class {
|
|
|
3399
3415
|
log13("requesting lock...", {
|
|
3400
3416
|
steal
|
|
3401
3417
|
}, {
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3418
|
+
F: __dxlog_file13,
|
|
3419
|
+
L: 63,
|
|
3420
|
+
S: this,
|
|
3421
|
+
C: (f, a) => f(...a)
|
|
3406
3422
|
});
|
|
3407
3423
|
const acquired = new Trigger6();
|
|
3408
3424
|
void navigator.locks.request(this._lockKey, {
|
|
@@ -3413,18 +3429,18 @@ var Lock = class {
|
|
|
3413
3429
|
acquired.wake();
|
|
3414
3430
|
this._releaseTrigger = new Trigger6();
|
|
3415
3431
|
await this._releaseTrigger.wait();
|
|
3416
|
-
log13("releasing lock...",
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3432
|
+
log13("releasing lock...", void 0, {
|
|
3433
|
+
F: __dxlog_file13,
|
|
3434
|
+
L: 72,
|
|
3435
|
+
S: this,
|
|
3436
|
+
C: (f, a) => f(...a)
|
|
3421
3437
|
});
|
|
3422
3438
|
await ((_b = this._onRelease) == null ? void 0 : _b.call(this));
|
|
3423
|
-
log13("released lock",
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3439
|
+
log13("released lock", void 0, {
|
|
3440
|
+
F: __dxlog_file13,
|
|
3441
|
+
L: 74,
|
|
3442
|
+
S: this,
|
|
3443
|
+
C: (f, a) => f(...a)
|
|
3428
3444
|
});
|
|
3429
3445
|
}).catch(async () => {
|
|
3430
3446
|
var _a;
|
|
@@ -3434,14 +3450,14 @@ var Lock = class {
|
|
|
3434
3450
|
log13("recieved lock", {
|
|
3435
3451
|
steal
|
|
3436
3452
|
}, {
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3453
|
+
F: __dxlog_file13,
|
|
3454
|
+
L: 81,
|
|
3455
|
+
S: this,
|
|
3456
|
+
C: (f, a) => f(...a)
|
|
3441
3457
|
});
|
|
3442
3458
|
}
|
|
3443
3459
|
};
|
|
3444
|
-
|
|
3460
|
+
_ts_decorate3([
|
|
3445
3461
|
logInfo
|
|
3446
3462
|
], Lock.prototype, "lockKey", null);
|
|
3447
3463
|
var isLocked = (lockPath) => {
|
|
@@ -3522,16 +3538,19 @@ var ServiceRegistry = class {
|
|
|
3522
3538
|
};
|
|
3523
3539
|
|
|
3524
3540
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3525
|
-
import
|
|
3526
|
-
import { Event as Event8 } from "@dxos/async";
|
|
3527
|
-
import { clientServiceBundle
|
|
3541
|
+
import invariant12 from "tiny-invariant";
|
|
3542
|
+
import { Event as Event8, synchronized as synchronized2 } from "@dxos/async";
|
|
3543
|
+
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
3544
|
+
import { DocumentModel } from "@dxos/document-model";
|
|
3528
3545
|
import { DataServiceImpl } from "@dxos/echo-pipeline";
|
|
3529
3546
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
3530
3547
|
import { log as log15 } from "@dxos/log";
|
|
3531
3548
|
import { WebsocketSignalManager } from "@dxos/messaging";
|
|
3549
|
+
import { ModelFactory } from "@dxos/model-factory";
|
|
3532
3550
|
import { createWebRTCTransportFactory, NetworkManager } from "@dxos/network-manager";
|
|
3533
3551
|
import { trace as trace6 } from "@dxos/protocols";
|
|
3534
3552
|
import { SystemStatus } from "@dxos/protocols/proto/dxos/client/services";
|
|
3553
|
+
import { TextModel } from "@dxos/text-model";
|
|
3535
3554
|
|
|
3536
3555
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3537
3556
|
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
@@ -3607,7 +3626,7 @@ var LoggingServiceImpl = class {
|
|
|
3607
3626
|
if (LOG_PROCESSING > 0) {
|
|
3608
3627
|
return;
|
|
3609
3628
|
}
|
|
3610
|
-
if (((_a = entry2.meta) == null ? void 0 : _a.
|
|
3629
|
+
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
3630
|
return;
|
|
3612
3631
|
}
|
|
3613
3632
|
if (!shouldLog(entry2, request)) {
|
|
@@ -3619,8 +3638,8 @@ var LoggingServiceImpl = class {
|
|
|
3619
3638
|
timestamp: new Date(),
|
|
3620
3639
|
meta: {
|
|
3621
3640
|
// TODO(dmaretskyi): Fix proto.
|
|
3622
|
-
file: (_c = (_b = entry2.meta) == null ? void 0 : _b.
|
|
3623
|
-
line: (_e = (_d = entry2.meta) == null ? void 0 : _d.
|
|
3641
|
+
file: (_c = (_b = entry2.meta) == null ? void 0 : _b.F) != null ? _c : "",
|
|
3642
|
+
line: (_e = (_d = entry2.meta) == null ? void 0 : _d.L) != null ? _e : 0
|
|
3624
3643
|
}
|
|
3625
3644
|
};
|
|
3626
3645
|
try {
|
|
@@ -3650,7 +3669,7 @@ var shouldLog = (entry2, request) => {
|
|
|
3650
3669
|
} else {
|
|
3651
3670
|
return request.filters.some((filter) => {
|
|
3652
3671
|
var _a2, _b;
|
|
3653
|
-
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.
|
|
3672
|
+
return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
|
|
3654
3673
|
});
|
|
3655
3674
|
}
|
|
3656
3675
|
};
|
|
@@ -3727,6 +3746,20 @@ var SystemServiceImpl = class {
|
|
|
3727
3746
|
};
|
|
3728
3747
|
|
|
3729
3748
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3749
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
3750
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3751
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3752
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3753
|
+
else
|
|
3754
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3755
|
+
if (d = decorators[i])
|
|
3756
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3757
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3758
|
+
}
|
|
3759
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
3760
|
+
var createDefaultModelFactory = () => {
|
|
3761
|
+
return new ModelFactory().registerModel(DocumentModel).registerModel(TextModel);
|
|
3762
|
+
};
|
|
3730
3763
|
var ClientServicesHost = class {
|
|
3731
3764
|
constructor({
|
|
3732
3765
|
config,
|
|
@@ -3802,9 +3835,9 @@ var ClientServicesHost = class {
|
|
|
3802
3835
|
*/
|
|
3803
3836
|
initialize({ config, ...options }) {
|
|
3804
3837
|
var _a, _b, _c;
|
|
3805
|
-
|
|
3838
|
+
invariant12(!this._open, "service host is open");
|
|
3806
3839
|
if (config) {
|
|
3807
|
-
|
|
3840
|
+
invariant12(!this._config, "config already set");
|
|
3808
3841
|
this._config = config;
|
|
3809
3842
|
if (!this._storage) {
|
|
3810
3843
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
@@ -3814,7 +3847,7 @@ var ClientServicesHost = class {
|
|
|
3814
3847
|
iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
|
|
3815
3848
|
}), signalManager = new WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
|
|
3816
3849
|
this._signalManager = signalManager;
|
|
3817
|
-
|
|
3850
|
+
invariant12(!this._networkManager, "network manager already set");
|
|
3818
3851
|
this._networkManager = new NetworkManager({
|
|
3819
3852
|
log: connectionLog,
|
|
3820
3853
|
transportFactory,
|
|
@@ -3830,23 +3863,23 @@ var ClientServicesHost = class {
|
|
|
3830
3863
|
log15.trace("dxos.sdk.client-services-host.open", trace6.begin({
|
|
3831
3864
|
id: traceId
|
|
3832
3865
|
}), {
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
});
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3866
|
+
F: __dxlog_file14,
|
|
3867
|
+
L: 195,
|
|
3868
|
+
S: this,
|
|
3869
|
+
C: (f, a) => f(...a)
|
|
3870
|
+
});
|
|
3871
|
+
invariant12(this._config, "config not set");
|
|
3872
|
+
invariant12(this._storage, "storage not set");
|
|
3873
|
+
invariant12(this._signalManager, "signal manager not set");
|
|
3874
|
+
invariant12(this._networkManager, "network manager not set");
|
|
3842
3875
|
this._opening = true;
|
|
3843
3876
|
log15("opening...", {
|
|
3844
3877
|
lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
|
|
3845
3878
|
}, {
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3879
|
+
F: __dxlog_file14,
|
|
3880
|
+
L: 203,
|
|
3881
|
+
S: this,
|
|
3882
|
+
C: (f, a) => f(...a)
|
|
3850
3883
|
});
|
|
3851
3884
|
await ((_b = this._resourceLock) == null ? void 0 : _b.acquire());
|
|
3852
3885
|
await this._loggingService.open();
|
|
@@ -3878,18 +3911,18 @@ var ClientServicesHost = class {
|
|
|
3878
3911
|
log15("opened", {
|
|
3879
3912
|
deviceKey
|
|
3880
3913
|
}, {
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3914
|
+
F: __dxlog_file14,
|
|
3915
|
+
L: 258,
|
|
3916
|
+
S: this,
|
|
3917
|
+
C: (f, a) => f(...a)
|
|
3885
3918
|
});
|
|
3886
3919
|
log15.trace("dxos.sdk.client-services-host.open", trace6.end({
|
|
3887
3920
|
id: traceId
|
|
3888
3921
|
}), {
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3922
|
+
F: __dxlog_file14,
|
|
3923
|
+
L: 259,
|
|
3924
|
+
S: this,
|
|
3925
|
+
C: (f, a) => f(...a)
|
|
3893
3926
|
});
|
|
3894
3927
|
}
|
|
3895
3928
|
async close() {
|
|
@@ -3901,10 +3934,10 @@ var ClientServicesHost = class {
|
|
|
3901
3934
|
log15("closing...", {
|
|
3902
3935
|
deviceKey
|
|
3903
3936
|
}, {
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3937
|
+
F: __dxlog_file14,
|
|
3938
|
+
L: 269,
|
|
3939
|
+
S: this,
|
|
3940
|
+
C: (f, a) => f(...a)
|
|
3908
3941
|
});
|
|
3909
3942
|
this._serviceRegistry.setServices({
|
|
3910
3943
|
SystemService: this._systemService
|
|
@@ -3916,10 +3949,10 @@ var ClientServicesHost = class {
|
|
|
3916
3949
|
log15("closed", {
|
|
3917
3950
|
deviceKey
|
|
3918
3951
|
}, {
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3952
|
+
F: __dxlog_file14,
|
|
3953
|
+
L: 275,
|
|
3954
|
+
S: this,
|
|
3955
|
+
C: (f, a) => f(...a)
|
|
3923
3956
|
});
|
|
3924
3957
|
}
|
|
3925
3958
|
async reset() {
|
|
@@ -3928,35 +3961,41 @@ var ClientServicesHost = class {
|
|
|
3928
3961
|
log15.trace("dxos.sdk.client-services-host.reset", trace6.begin({
|
|
3929
3962
|
id: traceId
|
|
3930
3963
|
}), {
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3964
|
+
F: __dxlog_file14,
|
|
3965
|
+
L: 280,
|
|
3966
|
+
S: this,
|
|
3967
|
+
C: (f, a) => f(...a)
|
|
3935
3968
|
});
|
|
3936
|
-
log15("resetting...",
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3969
|
+
log15("resetting...", void 0, {
|
|
3970
|
+
F: __dxlog_file14,
|
|
3971
|
+
L: 282,
|
|
3972
|
+
S: this,
|
|
3973
|
+
C: (f, a) => f(...a)
|
|
3941
3974
|
});
|
|
3942
3975
|
await ((_a = this._serviceContext) == null ? void 0 : _a.close());
|
|
3943
3976
|
await this._storage.reset();
|
|
3944
|
-
log15("reset",
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3977
|
+
log15("reset", void 0, {
|
|
3978
|
+
F: __dxlog_file14,
|
|
3979
|
+
L: 285,
|
|
3980
|
+
S: this,
|
|
3981
|
+
C: (f, a) => f(...a)
|
|
3949
3982
|
});
|
|
3950
3983
|
log15.trace("dxos.sdk.client-services-host.reset", trace6.end({
|
|
3951
3984
|
id: traceId
|
|
3952
3985
|
}), {
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3986
|
+
F: __dxlog_file14,
|
|
3987
|
+
L: 286,
|
|
3988
|
+
S: this,
|
|
3989
|
+
C: (f, a) => f(...a)
|
|
3957
3990
|
});
|
|
3958
3991
|
}
|
|
3959
3992
|
};
|
|
3993
|
+
_ts_decorate4([
|
|
3994
|
+
synchronized2
|
|
3995
|
+
], ClientServicesHost.prototype, "open", null);
|
|
3996
|
+
_ts_decorate4([
|
|
3997
|
+
synchronized2
|
|
3998
|
+
], ClientServicesHost.prototype, "close", null);
|
|
3960
3999
|
|
|
3961
4000
|
export {
|
|
3962
4001
|
subscribeToFeeds,
|
|
@@ -3986,6 +4025,7 @@ export {
|
|
|
3986
4025
|
isLocked,
|
|
3987
4026
|
createStorageObjects,
|
|
3988
4027
|
ServiceRegistry,
|
|
4028
|
+
createDefaultModelFactory,
|
|
3989
4029
|
ClientServicesHost
|
|
3990
4030
|
};
|
|
3991
|
-
//# sourceMappingURL=chunk-
|
|
4031
|
+
//# sourceMappingURL=chunk-RKD47ENR.mjs.map
|