@dxos/client-services 0.1.55 → 0.1.56-main.01afb72
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-XSZIBW37.mjs → chunk-53BV3Q7V.mjs} +1131 -463
- package/dist/lib/browser/chunk-53BV3Q7V.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +63 -42
- 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 +13 -4
- package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +1279 -593
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +1410 -736
- package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
- package/dist/types/src/packlets/identity/identity-manager.d.ts +2 -1
- package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +3 -2
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-extension.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/logging/logging-service.d.ts +6 -2
- package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
- package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
- package/dist/types/src/packlets/services/diagnostics.d.ts +46 -0
- package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -0
- package/dist/types/src/packlets/services/index.d.ts +1 -0
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/platform.d.ts +16 -0
- package/dist/types/src/packlets/services/platform.d.ts.map +1 -0
- package/dist/types/src/packlets/services/service-context.d.ts +2 -1
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +7 -3
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/util.d.ts +6 -0
- package/dist/types/src/packlets/services/util.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +12 -2
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/packlets/testing/invitation-utils.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
- package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +2 -0
- package/dist/types/src/version.d.ts.map +1 -0
- package/package.json +34 -33
- package/src/packlets/devices/devices-service.test.ts +2 -1
- package/src/packlets/identity/authenticator.test.ts +2 -2
- package/src/packlets/identity/identity-manager.test.ts +4 -3
- package/src/packlets/identity/identity-manager.ts +10 -7
- package/src/packlets/identity/identity-service.test.ts +2 -1
- package/src/packlets/identity/identity-service.ts +1 -2
- package/src/packlets/identity/identity.test.ts +7 -6
- package/src/packlets/identity/identity.ts +9 -5
- package/src/packlets/invitations/device-invitation-protocol.test.ts +2 -1
- package/src/packlets/invitations/device-invitation-protocol.ts +1 -2
- package/src/packlets/invitations/invitation-extension.ts +1 -2
- package/src/packlets/invitations/invitations-handler.ts +1 -2
- package/src/packlets/invitations/invitations-service.ts +1 -2
- package/src/packlets/invitations/space-invitation-protocol.ts +1 -2
- package/src/packlets/locks/node.ts +1 -1
- package/src/packlets/logging/logging-service.ts +17 -9
- package/src/packlets/network/network-service.test.ts +2 -1
- package/src/packlets/services/client-rpc-server.ts +4 -4
- package/src/packlets/services/diagnostics.ts +211 -0
- package/src/packlets/services/index.ts +1 -0
- package/src/packlets/services/platform.ts +48 -0
- package/src/packlets/services/service-context.ts +14 -11
- package/src/packlets/services/service-host.test.ts +11 -10
- package/src/packlets/services/service-host.ts +38 -23
- package/src/packlets/services/service-registry.test.ts +3 -1
- package/src/packlets/services/util.ts +33 -0
- package/src/packlets/spaces/data-space-manager.ts +2 -3
- package/src/packlets/spaces/data-space.ts +1 -1
- package/src/packlets/spaces/notarization-plugin.ts +1 -2
- package/src/packlets/spaces/spaces-service.test.ts +2 -1
- package/src/packlets/spaces/spaces-service.ts +18 -12
- package/src/packlets/system/system-service.test.ts +1 -0
- package/src/packlets/system/system-service.ts +34 -2
- package/src/packlets/testing/invitation-utils.ts +1 -2
- package/src/packlets/testing/test-builder.ts +1 -1
- package/src/packlets/vault/iframe-host-runtime.ts +2 -1
- package/src/packlets/vault/shell-runtime.ts +1 -2
- package/src/packlets/vault/worker-runtime.ts +2 -1
- package/src/packlets/vault/worker-session.ts +7 -3
- package/src/version.ts +1 -0
- package/dist/lib/browser/chunk-XSZIBW37.mjs.map +0 -7
package/dist/lib/node/index.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// packages/sdk/client-services/src/index.ts
|
|
@@ -55,6 +45,7 @@ __export(src_exports, {
|
|
|
55
45
|
WorkerSession: () => WorkerSession,
|
|
56
46
|
createAuthProvider: () => createAuthProvider,
|
|
57
47
|
createDefaultModelFactory: () => createDefaultModelFactory,
|
|
48
|
+
createDiagnostics: () => createDiagnostics,
|
|
58
49
|
createStorageObjects: () => createStorageObjects,
|
|
59
50
|
getNetworkPeers: () => getNetworkPeers,
|
|
60
51
|
isLocked: () => isLocked,
|
|
@@ -420,7 +411,7 @@ var import_context2 = require("@dxos/context");
|
|
|
420
411
|
var import_credentials = require("@dxos/credentials");
|
|
421
412
|
var import_log = require("@dxos/log");
|
|
422
413
|
var import_protocols = require("@dxos/protocols");
|
|
423
|
-
var __dxlog_file = "/
|
|
414
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
|
|
424
415
|
var Credential = import_protocols.schema.getCodecForType("dxos.halo.credentials.Credential");
|
|
425
416
|
var createAuthProvider = (signer) => async (nonce) => {
|
|
426
417
|
const credential = await signer.createCredential({
|
|
@@ -531,16 +522,27 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
531
522
|
};
|
|
532
523
|
|
|
533
524
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
534
|
-
var import_tiny_invariant = __toESM(require("tiny-invariant"));
|
|
535
525
|
var import_async5 = require("@dxos/async");
|
|
536
526
|
var import_client_protocol = require("@dxos/client-protocol");
|
|
537
527
|
var import_credentials2 = require("@dxos/credentials");
|
|
538
528
|
var import_debug = require("@dxos/debug");
|
|
539
529
|
var import_feed_store2 = require("@dxos/feed-store");
|
|
530
|
+
var import_invariant = require("@dxos/invariant");
|
|
540
531
|
var import_log2 = require("@dxos/log");
|
|
541
532
|
var import_credentials3 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
542
|
-
var
|
|
543
|
-
|
|
533
|
+
var import_tracing = require("@dxos/tracing");
|
|
534
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
535
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
536
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
537
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
538
|
+
else
|
|
539
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
540
|
+
if (d = decorators[i])
|
|
541
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
542
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
543
|
+
}
|
|
544
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
|
|
545
|
+
var Identity = class Identity2 {
|
|
544
546
|
constructor({ space, signer, identityKey, deviceKey }) {
|
|
545
547
|
this.stateUpdate = new import_async5.Event();
|
|
546
548
|
this.space = space;
|
|
@@ -566,12 +568,12 @@ var Identity = class {
|
|
|
566
568
|
get authorizedDeviceKeys() {
|
|
567
569
|
return this._deviceStateMachine.authorizedDeviceKeys;
|
|
568
570
|
}
|
|
569
|
-
async open() {
|
|
571
|
+
async open(ctx) {
|
|
570
572
|
await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
|
|
571
573
|
await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
|
|
572
|
-
await this.space.open();
|
|
574
|
+
await this.space.open(ctx);
|
|
573
575
|
}
|
|
574
|
-
async close() {
|
|
576
|
+
async close(ctx) {
|
|
575
577
|
await this.authVerifier.close();
|
|
576
578
|
await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
|
|
577
579
|
await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
|
|
@@ -614,7 +616,15 @@ var Identity = class {
|
|
|
614
616
|
* Requires identity to be ready.
|
|
615
617
|
*/
|
|
616
618
|
getIdentityCredentialSigner() {
|
|
617
|
-
(0,
|
|
619
|
+
(0, import_invariant.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
|
|
620
|
+
F: __dxlog_file2,
|
|
621
|
+
L: 139,
|
|
622
|
+
S: this,
|
|
623
|
+
A: [
|
|
624
|
+
"this._deviceStateMachine.deviceCredentialChain",
|
|
625
|
+
"'Device credential chain is not ready.'"
|
|
626
|
+
]
|
|
627
|
+
});
|
|
618
628
|
return (0, import_credentials2.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
|
|
619
629
|
}
|
|
620
630
|
/**
|
|
@@ -632,7 +642,7 @@ var Identity = class {
|
|
|
632
642
|
dataFeedKey
|
|
633
643
|
}, {
|
|
634
644
|
F: __dxlog_file2,
|
|
635
|
-
L:
|
|
645
|
+
L: 155,
|
|
636
646
|
S: this,
|
|
637
647
|
C: (f, a) => f(...a)
|
|
638
648
|
});
|
|
@@ -673,18 +683,39 @@ var Identity = class {
|
|
|
673
683
|
})));
|
|
674
684
|
}
|
|
675
685
|
};
|
|
686
|
+
_ts_decorate([
|
|
687
|
+
import_tracing.trace.span()
|
|
688
|
+
], Identity.prototype, "open", null);
|
|
689
|
+
_ts_decorate([
|
|
690
|
+
import_tracing.trace.span()
|
|
691
|
+
], Identity.prototype, "close", null);
|
|
692
|
+
Identity = _ts_decorate([
|
|
693
|
+
import_tracing.trace.resource()
|
|
694
|
+
], Identity);
|
|
676
695
|
|
|
677
696
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
678
|
-
var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
|
|
679
697
|
var import_async6 = require("@dxos/async");
|
|
698
|
+
var import_context3 = require("@dxos/context");
|
|
680
699
|
var import_credentials4 = require("@dxos/credentials");
|
|
700
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
681
701
|
var import_keys4 = require("@dxos/keys");
|
|
682
702
|
var import_log3 = require("@dxos/log");
|
|
683
703
|
var import_protocols2 = require("@dxos/protocols");
|
|
684
704
|
var import_credentials5 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
705
|
+
var import_tracing2 = require("@dxos/tracing");
|
|
685
706
|
var import_util2 = require("@dxos/util");
|
|
686
|
-
|
|
687
|
-
var
|
|
707
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
708
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
709
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
710
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
711
|
+
else
|
|
712
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
713
|
+
if (d = decorators[i])
|
|
714
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
715
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
716
|
+
}
|
|
717
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
|
|
718
|
+
var IdentityManager = class IdentityManager2 {
|
|
688
719
|
// TODO(burdon): IdentityManagerParams.
|
|
689
720
|
// TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
|
|
690
721
|
constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
|
|
@@ -697,14 +728,14 @@ var IdentityManager = class {
|
|
|
697
728
|
get identity() {
|
|
698
729
|
return this._identity;
|
|
699
730
|
}
|
|
700
|
-
async open() {
|
|
731
|
+
async open(ctx) {
|
|
701
732
|
var _a;
|
|
702
733
|
const traceId = import_keys4.PublicKey.random().toHex();
|
|
703
734
|
import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.begin({
|
|
704
735
|
id: traceId
|
|
705
736
|
}), {
|
|
706
737
|
F: __dxlog_file3,
|
|
707
|
-
L:
|
|
738
|
+
L: 73,
|
|
708
739
|
S: this,
|
|
709
740
|
C: (f, a) => f(...a)
|
|
710
741
|
});
|
|
@@ -714,20 +745,20 @@ var IdentityManager = class {
|
|
|
714
745
|
identityRecord
|
|
715
746
|
}, {
|
|
716
747
|
F: __dxlog_file3,
|
|
717
|
-
L:
|
|
748
|
+
L: 77,
|
|
718
749
|
S: this,
|
|
719
750
|
C: (f, a) => f(...a)
|
|
720
751
|
});
|
|
721
752
|
if (identityRecord) {
|
|
722
753
|
this._identity = await this._constructIdentity(identityRecord);
|
|
723
|
-
await this._identity.open();
|
|
754
|
+
await this._identity.open(ctx);
|
|
724
755
|
await this._identity.ready();
|
|
725
756
|
import_log3.log.trace("dxos.halo.identity", {
|
|
726
757
|
identityKey: identityRecord.identityKey,
|
|
727
758
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
728
759
|
}, {
|
|
729
760
|
F: __dxlog_file3,
|
|
730
|
-
L:
|
|
761
|
+
L: 82,
|
|
731
762
|
S: this,
|
|
732
763
|
C: (f, a) => f(...a)
|
|
733
764
|
});
|
|
@@ -737,21 +768,29 @@ var IdentityManager = class {
|
|
|
737
768
|
id: traceId
|
|
738
769
|
}), {
|
|
739
770
|
F: __dxlog_file3,
|
|
740
|
-
L:
|
|
771
|
+
L: 88,
|
|
741
772
|
S: this,
|
|
742
773
|
C: (f, a) => f(...a)
|
|
743
774
|
});
|
|
744
775
|
}
|
|
745
776
|
async close() {
|
|
746
777
|
var _a;
|
|
747
|
-
await ((_a = this._identity) == null ? void 0 : _a.close());
|
|
778
|
+
await ((_a = this._identity) == null ? void 0 : _a.close(new import_context3.Context()));
|
|
748
779
|
}
|
|
749
780
|
async createIdentity({ displayName } = {}) {
|
|
750
781
|
var _a;
|
|
751
|
-
(0,
|
|
782
|
+
(0, import_invariant2.invariant)(!this._identity, "Identity already exists.", {
|
|
783
|
+
F: __dxlog_file3,
|
|
784
|
+
L: 96,
|
|
785
|
+
S: this,
|
|
786
|
+
A: [
|
|
787
|
+
"!this._identity",
|
|
788
|
+
"'Identity already exists.'"
|
|
789
|
+
]
|
|
790
|
+
});
|
|
752
791
|
(0, import_log3.log)("creating identity...", void 0, {
|
|
753
792
|
F: __dxlog_file3,
|
|
754
|
-
L:
|
|
793
|
+
L: 97,
|
|
755
794
|
S: this,
|
|
756
795
|
C: (f, a) => f(...a)
|
|
757
796
|
});
|
|
@@ -767,11 +806,27 @@ var IdentityManager = class {
|
|
|
767
806
|
}
|
|
768
807
|
};
|
|
769
808
|
const identity = await this._constructIdentity(identityRecord);
|
|
770
|
-
await identity.open();
|
|
809
|
+
await identity.open(new import_context3.Context());
|
|
771
810
|
{
|
|
772
811
|
const generator = new import_credentials4.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
773
|
-
(0,
|
|
774
|
-
|
|
812
|
+
(0, import_invariant2.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
|
|
813
|
+
F: __dxlog_file3,
|
|
814
|
+
L: 116,
|
|
815
|
+
S: this,
|
|
816
|
+
A: [
|
|
817
|
+
"identityRecord.haloSpace.genesisFeedKey",
|
|
818
|
+
"'Genesis feed key is required.'"
|
|
819
|
+
]
|
|
820
|
+
});
|
|
821
|
+
(0, import_invariant2.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
|
|
822
|
+
F: __dxlog_file3,
|
|
823
|
+
L: 117,
|
|
824
|
+
S: this,
|
|
825
|
+
A: [
|
|
826
|
+
"identityRecord.haloSpace.dataFeedKey",
|
|
827
|
+
"'Data feed key is required.'"
|
|
828
|
+
]
|
|
829
|
+
});
|
|
775
830
|
const credentials = [
|
|
776
831
|
// Space genesis.
|
|
777
832
|
...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
|
|
@@ -800,7 +855,7 @@ var IdentityManager = class {
|
|
|
800
855
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
801
856
|
}, {
|
|
802
857
|
F: __dxlog_file3,
|
|
803
|
-
L:
|
|
858
|
+
L: 152,
|
|
804
859
|
S: this,
|
|
805
860
|
C: (f, a) => f(...a)
|
|
806
861
|
});
|
|
@@ -810,7 +865,7 @@ var IdentityManager = class {
|
|
|
810
865
|
deviceKey: identity.deviceKey
|
|
811
866
|
}, {
|
|
812
867
|
F: __dxlog_file3,
|
|
813
|
-
L:
|
|
868
|
+
L: 158,
|
|
814
869
|
S: this,
|
|
815
870
|
C: (f, a) => f(...a)
|
|
816
871
|
});
|
|
@@ -825,11 +880,19 @@ var IdentityManager = class {
|
|
|
825
880
|
params
|
|
826
881
|
}, {
|
|
827
882
|
F: __dxlog_file3,
|
|
828
|
-
L:
|
|
883
|
+
L: 166,
|
|
829
884
|
S: this,
|
|
830
885
|
C: (f, a) => f(...a)
|
|
831
886
|
});
|
|
832
|
-
(0,
|
|
887
|
+
(0, import_invariant2.invariant)(!this._identity, "Identity already exists.", {
|
|
888
|
+
F: __dxlog_file3,
|
|
889
|
+
L: 167,
|
|
890
|
+
S: this,
|
|
891
|
+
A: [
|
|
892
|
+
"!this._identity",
|
|
893
|
+
"'Identity already exists.'"
|
|
894
|
+
]
|
|
895
|
+
});
|
|
833
896
|
const identityRecord = {
|
|
834
897
|
identityKey: params.identityKey,
|
|
835
898
|
deviceKey: params.deviceKey,
|
|
@@ -842,7 +905,7 @@ var IdentityManager = class {
|
|
|
842
905
|
}
|
|
843
906
|
};
|
|
844
907
|
const identity = await this._constructIdentity(identityRecord);
|
|
845
|
-
await identity.open();
|
|
908
|
+
await identity.open(new import_context3.Context());
|
|
846
909
|
this._identity = identity;
|
|
847
910
|
await this._metadataStore.setIdentityRecord(identityRecord);
|
|
848
911
|
await this._identity.ready();
|
|
@@ -851,7 +914,7 @@ var IdentityManager = class {
|
|
|
851
914
|
displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
|
|
852
915
|
}, {
|
|
853
916
|
F: __dxlog_file3,
|
|
854
|
-
L:
|
|
917
|
+
L: 186,
|
|
855
918
|
S: this,
|
|
856
919
|
C: (f, a) => f(...a)
|
|
857
920
|
});
|
|
@@ -861,27 +924,51 @@ var IdentityManager = class {
|
|
|
861
924
|
deviceKey: identity.deviceKey
|
|
862
925
|
}, {
|
|
863
926
|
F: __dxlog_file3,
|
|
864
|
-
L:
|
|
927
|
+
L: 192,
|
|
865
928
|
S: this,
|
|
866
929
|
C: (f, a) => f(...a)
|
|
867
930
|
});
|
|
868
931
|
return identity;
|
|
869
932
|
}
|
|
870
933
|
async _constructIdentity(identityRecord) {
|
|
871
|
-
(0,
|
|
934
|
+
(0, import_invariant2.invariant)(!this._identity, void 0, {
|
|
935
|
+
F: __dxlog_file3,
|
|
936
|
+
L: 197,
|
|
937
|
+
S: this,
|
|
938
|
+
A: [
|
|
939
|
+
"!this._identity",
|
|
940
|
+
""
|
|
941
|
+
]
|
|
942
|
+
});
|
|
872
943
|
(0, import_log3.log)("constructing identity", {
|
|
873
944
|
identityRecord
|
|
874
945
|
}, {
|
|
875
946
|
F: __dxlog_file3,
|
|
876
|
-
L:
|
|
947
|
+
L: 198,
|
|
877
948
|
S: this,
|
|
878
949
|
C: (f, a) => f(...a)
|
|
879
950
|
});
|
|
880
|
-
(0,
|
|
951
|
+
(0, import_invariant2.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
|
|
952
|
+
F: __dxlog_file3,
|
|
953
|
+
L: 201,
|
|
954
|
+
S: this,
|
|
955
|
+
A: [
|
|
956
|
+
"identityRecord.haloSpace.controlFeedKey",
|
|
957
|
+
""
|
|
958
|
+
]
|
|
959
|
+
});
|
|
881
960
|
const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
|
|
882
961
|
writable: true
|
|
883
962
|
});
|
|
884
|
-
(0,
|
|
963
|
+
(0, import_invariant2.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
|
|
964
|
+
F: __dxlog_file3,
|
|
965
|
+
L: 205,
|
|
966
|
+
S: this,
|
|
967
|
+
A: [
|
|
968
|
+
"identityRecord.haloSpace.dataFeedKey",
|
|
969
|
+
""
|
|
970
|
+
]
|
|
971
|
+
});
|
|
885
972
|
const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
|
|
886
973
|
writable: true,
|
|
887
974
|
sparse: true
|
|
@@ -907,7 +994,7 @@ var IdentityManager = class {
|
|
|
907
994
|
identityKey: identityRecord.identityKey
|
|
908
995
|
}, {
|
|
909
996
|
F: __dxlog_file3,
|
|
910
|
-
L:
|
|
997
|
+
L: 229,
|
|
911
998
|
S: this,
|
|
912
999
|
C: (f, a) => f(...a)
|
|
913
1000
|
});
|
|
@@ -928,7 +1015,7 @@ var IdentityManager = class {
|
|
|
928
1015
|
onAuthFailure: () => {
|
|
929
1016
|
import_log3.log.warn("auth failure", void 0, {
|
|
930
1017
|
F: __dxlog_file3,
|
|
931
|
-
L:
|
|
1018
|
+
L: 248,
|
|
932
1019
|
S: this,
|
|
933
1020
|
C: (f, a) => f(...a)
|
|
934
1021
|
});
|
|
@@ -937,12 +1024,19 @@ var IdentityManager = class {
|
|
|
937
1024
|
});
|
|
938
1025
|
}
|
|
939
1026
|
};
|
|
1027
|
+
_ts_decorate2([
|
|
1028
|
+
import_tracing2.trace.span()
|
|
1029
|
+
], IdentityManager.prototype, "open", null);
|
|
1030
|
+
IdentityManager = _ts_decorate2([
|
|
1031
|
+
import_tracing2.trace.resource()
|
|
1032
|
+
], IdentityManager);
|
|
940
1033
|
|
|
941
1034
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
942
|
-
var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
|
|
943
1035
|
var import_codec_protobuf7 = require("@dxos/codec-protobuf");
|
|
944
1036
|
var import_credentials6 = require("@dxos/credentials");
|
|
945
1037
|
var import_debug2 = require("@dxos/debug");
|
|
1038
|
+
var import_invariant3 = require("@dxos/invariant");
|
|
1039
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
946
1040
|
var IdentityServiceImpl = class {
|
|
947
1041
|
// TODO(wittjosiah): Remove dependency on service context.
|
|
948
1042
|
constructor(_serviceContext) {
|
|
@@ -975,7 +1069,15 @@ var IdentityServiceImpl = class {
|
|
|
975
1069
|
};
|
|
976
1070
|
}
|
|
977
1071
|
async signPresentation({ presentation, nonce }) {
|
|
978
|
-
(0,
|
|
1072
|
+
(0, import_invariant3.invariant)(this._serviceContext.identityManager.identity, "Identity not initialized.", {
|
|
1073
|
+
F: __dxlog_file4,
|
|
1074
|
+
L: 56,
|
|
1075
|
+
S: this,
|
|
1076
|
+
A: [
|
|
1077
|
+
"this._serviceContext.identityManager.identity",
|
|
1078
|
+
"'Identity not initialized.'"
|
|
1079
|
+
]
|
|
1080
|
+
});
|
|
979
1081
|
return await (0, import_credentials6.signPresentation)({
|
|
980
1082
|
presentation,
|
|
981
1083
|
signer: this._serviceContext.keyring,
|
|
@@ -987,8 +1089,9 @@ var IdentityServiceImpl = class {
|
|
|
987
1089
|
};
|
|
988
1090
|
|
|
989
1091
|
// packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
|
|
990
|
-
var
|
|
1092
|
+
var import_invariant4 = require("@dxos/invariant");
|
|
991
1093
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
1094
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
|
|
992
1095
|
var DeviceInvitationProtocol = class {
|
|
993
1096
|
constructor(_keyring, _getIdentity, _acceptIdentity) {
|
|
994
1097
|
this._keyring = _keyring;
|
|
@@ -1004,7 +1107,15 @@ var DeviceInvitationProtocol = class {
|
|
|
1004
1107
|
};
|
|
1005
1108
|
}
|
|
1006
1109
|
async admit(request) {
|
|
1007
|
-
(0,
|
|
1110
|
+
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1111
|
+
F: __dxlog_file5,
|
|
1112
|
+
L: 31,
|
|
1113
|
+
S: this,
|
|
1114
|
+
A: [
|
|
1115
|
+
"request.device",
|
|
1116
|
+
""
|
|
1117
|
+
]
|
|
1118
|
+
});
|
|
1008
1119
|
const identity = this._getIdentity();
|
|
1009
1120
|
await identity.admitDevice(request.device);
|
|
1010
1121
|
return {
|
|
@@ -1032,9 +1143,25 @@ var DeviceInvitationProtocol = class {
|
|
|
1032
1143
|
};
|
|
1033
1144
|
}
|
|
1034
1145
|
async accept(response, request) {
|
|
1035
|
-
(0,
|
|
1146
|
+
(0, import_invariant4.invariant)(response.device, void 0, {
|
|
1147
|
+
F: __dxlog_file5,
|
|
1148
|
+
L: 64,
|
|
1149
|
+
S: this,
|
|
1150
|
+
A: [
|
|
1151
|
+
"response.device",
|
|
1152
|
+
""
|
|
1153
|
+
]
|
|
1154
|
+
});
|
|
1036
1155
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
1037
|
-
(0,
|
|
1156
|
+
(0, import_invariant4.invariant)(request.device, void 0, {
|
|
1157
|
+
F: __dxlog_file5,
|
|
1158
|
+
L: 67,
|
|
1159
|
+
S: this,
|
|
1160
|
+
A: [
|
|
1161
|
+
"request.device",
|
|
1162
|
+
""
|
|
1163
|
+
]
|
|
1164
|
+
});
|
|
1038
1165
|
const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
|
|
1039
1166
|
await this._acceptIdentity({
|
|
1040
1167
|
identityKey,
|
|
@@ -1052,12 +1179,12 @@ var DeviceInvitationProtocol = class {
|
|
|
1052
1179
|
};
|
|
1053
1180
|
|
|
1054
1181
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1055
|
-
var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
|
|
1056
1182
|
var import_async8 = require("@dxos/async");
|
|
1057
1183
|
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
1058
|
-
var
|
|
1184
|
+
var import_context5 = require("@dxos/context");
|
|
1059
1185
|
var import_credentials7 = require("@dxos/credentials");
|
|
1060
1186
|
var import_errors2 = require("@dxos/errors");
|
|
1187
|
+
var import_invariant6 = require("@dxos/invariant");
|
|
1061
1188
|
var import_keys6 = require("@dxos/keys");
|
|
1062
1189
|
var import_log5 = require("@dxos/log");
|
|
1063
1190
|
var import_network_manager = require("@dxos/network-manager");
|
|
@@ -1066,17 +1193,17 @@ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
|
|
|
1066
1193
|
var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
1067
1194
|
|
|
1068
1195
|
// packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
|
|
1069
|
-
var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
|
|
1070
1196
|
var import_async7 = require("@dxos/async");
|
|
1071
|
-
var
|
|
1197
|
+
var import_context4 = require("@dxos/context");
|
|
1072
1198
|
var import_errors = require("@dxos/errors");
|
|
1199
|
+
var import_invariant5 = require("@dxos/invariant");
|
|
1073
1200
|
var import_keys5 = require("@dxos/keys");
|
|
1074
1201
|
var import_log4 = require("@dxos/log");
|
|
1075
1202
|
var import_protocols3 = require("@dxos/protocols");
|
|
1076
1203
|
var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1077
1204
|
var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
|
|
1078
1205
|
var import_teleport = require("@dxos/teleport");
|
|
1079
|
-
var
|
|
1206
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
|
|
1080
1207
|
var OPTIONS_TIMEOUT = 1e4;
|
|
1081
1208
|
var MAX_OTP_ATTEMPTS = 3;
|
|
1082
1209
|
var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
@@ -1090,7 +1217,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1090
1217
|
}
|
|
1091
1218
|
});
|
|
1092
1219
|
this._callbacks = _callbacks;
|
|
1093
|
-
this._ctx = new
|
|
1220
|
+
this._ctx = new import_context4.Context();
|
|
1094
1221
|
this._remoteOptionsTrigger = new import_async7.Trigger();
|
|
1095
1222
|
this.invitation = void 0;
|
|
1096
1223
|
this.guestProfile = void 0;
|
|
@@ -1104,7 +1231,15 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1104
1231
|
// Perhaps in the future we will have more complex logic here.
|
|
1105
1232
|
InvitationHostService: {
|
|
1106
1233
|
options: async (options) => {
|
|
1107
|
-
(0,
|
|
1234
|
+
(0, import_invariant5.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1235
|
+
F: __dxlog_file6,
|
|
1236
|
+
L: 88,
|
|
1237
|
+
S: this,
|
|
1238
|
+
A: [
|
|
1239
|
+
"!this._remoteOptions",
|
|
1240
|
+
"'Remote options already set.'"
|
|
1241
|
+
]
|
|
1242
|
+
});
|
|
1108
1243
|
this._remoteOptions = options;
|
|
1109
1244
|
this._remoteOptionsTrigger.wake();
|
|
1110
1245
|
},
|
|
@@ -1114,8 +1249,8 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1114
1249
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.begin({
|
|
1115
1250
|
id: traceId
|
|
1116
1251
|
}), {
|
|
1117
|
-
F:
|
|
1118
|
-
L:
|
|
1252
|
+
F: __dxlog_file6,
|
|
1253
|
+
L: 97,
|
|
1119
1254
|
S: this,
|
|
1120
1255
|
C: (f, a) => f(...a)
|
|
1121
1256
|
});
|
|
@@ -1124,8 +1259,8 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1124
1259
|
import_log4.log.warn("invitation not found", {
|
|
1125
1260
|
invitationId
|
|
1126
1261
|
}, {
|
|
1127
|
-
F:
|
|
1128
|
-
L:
|
|
1262
|
+
F: __dxlog_file6,
|
|
1263
|
+
L: 101,
|
|
1129
1264
|
S: this,
|
|
1130
1265
|
C: (f, a) => f(...a)
|
|
1131
1266
|
});
|
|
@@ -1138,8 +1273,8 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1138
1273
|
(0, import_log4.log)("guest introduced itself", {
|
|
1139
1274
|
guestProfile: profile
|
|
1140
1275
|
}, {
|
|
1141
|
-
F:
|
|
1142
|
-
L:
|
|
1276
|
+
F: __dxlog_file6,
|
|
1277
|
+
L: 110,
|
|
1143
1278
|
S: this,
|
|
1144
1279
|
C: (f, a) => f(...a)
|
|
1145
1280
|
});
|
|
@@ -1151,8 +1286,8 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1151
1286
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.end({
|
|
1152
1287
|
id: traceId
|
|
1153
1288
|
}), {
|
|
1154
|
-
F:
|
|
1155
|
-
L:
|
|
1289
|
+
F: __dxlog_file6,
|
|
1290
|
+
L: 117,
|
|
1156
1291
|
S: this,
|
|
1157
1292
|
C: (f, a) => f(...a)
|
|
1158
1293
|
});
|
|
@@ -1166,26 +1301,34 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1166
1301
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols3.trace.begin({
|
|
1167
1302
|
id: traceId
|
|
1168
1303
|
}), {
|
|
1169
|
-
F:
|
|
1170
|
-
L:
|
|
1304
|
+
F: __dxlog_file6,
|
|
1305
|
+
L: 126,
|
|
1171
1306
|
S: this,
|
|
1172
1307
|
C: (f, a) => f(...a)
|
|
1173
1308
|
});
|
|
1174
1309
|
(0, import_log4.log)("received authentication request", {
|
|
1175
1310
|
authCode: code
|
|
1176
1311
|
}, {
|
|
1177
|
-
F:
|
|
1178
|
-
L:
|
|
1312
|
+
F: __dxlog_file6,
|
|
1313
|
+
L: 127,
|
|
1179
1314
|
S: this,
|
|
1180
1315
|
C: (f, a) => f(...a)
|
|
1181
1316
|
});
|
|
1182
1317
|
let status = import_invitations.AuthenticationResponse.Status.OK;
|
|
1183
|
-
(0,
|
|
1318
|
+
(0, import_invariant5.invariant)(this.invitation, "Invitation is not set.", {
|
|
1319
|
+
F: __dxlog_file6,
|
|
1320
|
+
L: 130,
|
|
1321
|
+
S: this,
|
|
1322
|
+
A: [
|
|
1323
|
+
"this.invitation",
|
|
1324
|
+
"'Invitation is not set.'"
|
|
1325
|
+
]
|
|
1326
|
+
});
|
|
1184
1327
|
switch (this.invitation.authMethod) {
|
|
1185
1328
|
case import_services2.Invitation.AuthMethod.NONE: {
|
|
1186
1329
|
(0, import_log4.log)("authentication not required", void 0, {
|
|
1187
|
-
F:
|
|
1188
|
-
L:
|
|
1330
|
+
F: __dxlog_file6,
|
|
1331
|
+
L: 133,
|
|
1189
1332
|
S: this,
|
|
1190
1333
|
C: (f, a) => f(...a)
|
|
1191
1334
|
});
|
|
@@ -1209,8 +1352,8 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1209
1352
|
import_log4.log.error("invalid authentication method", {
|
|
1210
1353
|
authMethod: this.invitation.authMethod
|
|
1211
1354
|
}, {
|
|
1212
|
-
F:
|
|
1213
|
-
L:
|
|
1355
|
+
F: __dxlog_file6,
|
|
1356
|
+
L: 151,
|
|
1214
1357
|
S: this,
|
|
1215
1358
|
C: (f, a) => f(...a)
|
|
1216
1359
|
});
|
|
@@ -1224,8 +1367,8 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1224
1367
|
status
|
|
1225
1368
|
}
|
|
1226
1369
|
}), {
|
|
1227
|
-
F:
|
|
1228
|
-
L:
|
|
1370
|
+
F: __dxlog_file6,
|
|
1371
|
+
L: 157,
|
|
1229
1372
|
S: this,
|
|
1230
1373
|
C: (f, a) => f(...a)
|
|
1231
1374
|
});
|
|
@@ -1238,13 +1381,21 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1238
1381
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.begin({
|
|
1239
1382
|
id: traceId
|
|
1240
1383
|
}), {
|
|
1241
|
-
F:
|
|
1242
|
-
L:
|
|
1384
|
+
F: __dxlog_file6,
|
|
1385
|
+
L: 163,
|
|
1243
1386
|
S: this,
|
|
1244
1387
|
C: (f, a) => f(...a)
|
|
1245
1388
|
});
|
|
1246
1389
|
try {
|
|
1247
|
-
(0,
|
|
1390
|
+
(0, import_invariant5.invariant)(this.invitation, "Invitation is not set.", {
|
|
1391
|
+
F: __dxlog_file6,
|
|
1392
|
+
L: 166,
|
|
1393
|
+
S: this,
|
|
1394
|
+
A: [
|
|
1395
|
+
"this.invitation",
|
|
1396
|
+
"'Invitation is not set.'"
|
|
1397
|
+
]
|
|
1398
|
+
});
|
|
1248
1399
|
if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
|
|
1249
1400
|
throw new Error("Not authenticated");
|
|
1250
1401
|
}
|
|
@@ -1252,8 +1403,8 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1252
1403
|
import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.end({
|
|
1253
1404
|
id: traceId
|
|
1254
1405
|
}), {
|
|
1255
|
-
F:
|
|
1256
|
-
L:
|
|
1406
|
+
F: __dxlog_file6,
|
|
1407
|
+
L: 174,
|
|
1257
1408
|
S: this,
|
|
1258
1409
|
C: (f, a) => f(...a)
|
|
1259
1410
|
});
|
|
@@ -1273,7 +1424,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
|
|
|
1273
1424
|
await this.rpc.InvitationHostService.options({
|
|
1274
1425
|
role: import_invitations.Options.Role.HOST
|
|
1275
1426
|
});
|
|
1276
|
-
await (0,
|
|
1427
|
+
await (0, import_context4.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1277
1428
|
timeout: OPTIONS_TIMEOUT
|
|
1278
1429
|
}));
|
|
1279
1430
|
if (((_a = this._remoteOptions) == null ? void 0 : _a.role) !== import_invitations.Options.Role.GUEST) {
|
|
@@ -1302,14 +1453,22 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1302
1453
|
}
|
|
1303
1454
|
});
|
|
1304
1455
|
this._callbacks = _callbacks;
|
|
1305
|
-
this._ctx = new
|
|
1456
|
+
this._ctx = new import_context4.Context();
|
|
1306
1457
|
this._remoteOptionsTrigger = new import_async7.Trigger();
|
|
1307
1458
|
}
|
|
1308
1459
|
async getHandlers() {
|
|
1309
1460
|
return {
|
|
1310
1461
|
InvitationHostService: {
|
|
1311
1462
|
options: async (options) => {
|
|
1312
|
-
(0,
|
|
1463
|
+
(0, import_invariant5.invariant)(!this._remoteOptions, "Remote options already set.", {
|
|
1464
|
+
F: __dxlog_file6,
|
|
1465
|
+
L: 241,
|
|
1466
|
+
S: this,
|
|
1467
|
+
A: [
|
|
1468
|
+
"!this._remoteOptions",
|
|
1469
|
+
"'Remote options already set.'"
|
|
1470
|
+
]
|
|
1471
|
+
});
|
|
1313
1472
|
this._remoteOptions = options;
|
|
1314
1473
|
this._remoteOptionsTrigger.wake();
|
|
1315
1474
|
},
|
|
@@ -1330,20 +1489,20 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1330
1489
|
await super.onOpen(context);
|
|
1331
1490
|
try {
|
|
1332
1491
|
(0, import_log4.log)("begin options", void 0, {
|
|
1333
|
-
F:
|
|
1334
|
-
L:
|
|
1492
|
+
F: __dxlog_file6,
|
|
1493
|
+
L: 262,
|
|
1335
1494
|
S: this,
|
|
1336
1495
|
C: (f, a) => f(...a)
|
|
1337
1496
|
});
|
|
1338
|
-
await (0,
|
|
1497
|
+
await (0, import_context4.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
|
|
1339
1498
|
role: import_invitations.Options.Role.GUEST
|
|
1340
1499
|
}));
|
|
1341
|
-
await (0,
|
|
1500
|
+
await (0, import_context4.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
|
|
1342
1501
|
timeout: OPTIONS_TIMEOUT
|
|
1343
1502
|
}));
|
|
1344
1503
|
(0, import_log4.log)("end options", void 0, {
|
|
1345
|
-
F:
|
|
1346
|
-
L:
|
|
1504
|
+
F: __dxlog_file6,
|
|
1505
|
+
L: 265,
|
|
1347
1506
|
S: this,
|
|
1348
1507
|
C: (f, a) => f(...a)
|
|
1349
1508
|
});
|
|
@@ -1356,8 +1515,8 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1356
1515
|
this._callbacks.onOpen(this._ctx);
|
|
1357
1516
|
} catch (err) {
|
|
1358
1517
|
(0, import_log4.log)("openError", err, {
|
|
1359
|
-
F:
|
|
1360
|
-
L:
|
|
1518
|
+
F: __dxlog_file6,
|
|
1519
|
+
L: 275,
|
|
1361
1520
|
S: this,
|
|
1362
1521
|
C: (f, a) => f(...a)
|
|
1363
1522
|
});
|
|
@@ -1366,8 +1525,8 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1366
1525
|
}
|
|
1367
1526
|
async onClose() {
|
|
1368
1527
|
(0, import_log4.log)("onClose", void 0, {
|
|
1369
|
-
F:
|
|
1370
|
-
L:
|
|
1528
|
+
F: __dxlog_file6,
|
|
1529
|
+
L: 281,
|
|
1371
1530
|
S: this,
|
|
1372
1531
|
C: (f, a) => f(...a)
|
|
1373
1532
|
});
|
|
@@ -1377,7 +1536,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
|
|
|
1377
1536
|
var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services2.Invitation.AuthMethod.NONE;
|
|
1378
1537
|
|
|
1379
1538
|
// packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
|
|
1380
|
-
var
|
|
1539
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
|
|
1381
1540
|
var InvitationsHandler = class {
|
|
1382
1541
|
/**
|
|
1383
1542
|
* @internal
|
|
@@ -1389,7 +1548,15 @@ var InvitationsHandler = class {
|
|
|
1389
1548
|
var _a;
|
|
1390
1549
|
const { invitationId = import_keys6.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys6.PublicKey.random() } = options != null ? options : {};
|
|
1391
1550
|
const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0;
|
|
1392
|
-
(0,
|
|
1551
|
+
(0, import_invariant6.invariant)(protocol, void 0, {
|
|
1552
|
+
F: __dxlog_file7,
|
|
1553
|
+
L: 76,
|
|
1554
|
+
S: this,
|
|
1555
|
+
A: [
|
|
1556
|
+
"protocol",
|
|
1557
|
+
""
|
|
1558
|
+
]
|
|
1559
|
+
});
|
|
1393
1560
|
const invitation = {
|
|
1394
1561
|
invitationId,
|
|
1395
1562
|
type,
|
|
@@ -1401,7 +1568,7 @@ var InvitationsHandler = class {
|
|
|
1401
1568
|
...protocol.getInvitationContext()
|
|
1402
1569
|
};
|
|
1403
1570
|
const stream = new import_async8.PushStream();
|
|
1404
|
-
const ctx = new
|
|
1571
|
+
const ctx = new import_context5.Context({
|
|
1405
1572
|
onError: (err) => {
|
|
1406
1573
|
void ctx.dispose();
|
|
1407
1574
|
stream.error(err);
|
|
@@ -1411,8 +1578,8 @@ var InvitationsHandler = class {
|
|
|
1411
1578
|
(0, import_log5.log)("complete", {
|
|
1412
1579
|
...protocol.toJSON()
|
|
1413
1580
|
}, {
|
|
1414
|
-
F:
|
|
1415
|
-
L:
|
|
1581
|
+
F: __dxlog_file7,
|
|
1582
|
+
L: 98,
|
|
1416
1583
|
S: this,
|
|
1417
1584
|
C: (f, a) => f(...a)
|
|
1418
1585
|
});
|
|
@@ -1436,7 +1603,15 @@ var InvitationsHandler = class {
|
|
|
1436
1603
|
var _a2, _b, _c;
|
|
1437
1604
|
try {
|
|
1438
1605
|
const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
|
|
1439
|
-
(0,
|
|
1606
|
+
(0, import_invariant6.invariant)(deviceKey, void 0, {
|
|
1607
|
+
F: __dxlog_file7,
|
|
1608
|
+
L: 119,
|
|
1609
|
+
S: this,
|
|
1610
|
+
A: [
|
|
1611
|
+
"deviceKey",
|
|
1612
|
+
""
|
|
1613
|
+
]
|
|
1614
|
+
});
|
|
1440
1615
|
const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
|
|
1441
1616
|
extension.completedTrigger.wake(deviceKey);
|
|
1442
1617
|
return admissionResponse;
|
|
@@ -1452,16 +1627,16 @@ var InvitationsHandler = class {
|
|
|
1452
1627
|
import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.begin({
|
|
1453
1628
|
id: traceId
|
|
1454
1629
|
}), {
|
|
1455
|
-
F:
|
|
1456
|
-
L:
|
|
1630
|
+
F: __dxlog_file7,
|
|
1631
|
+
L: 137,
|
|
1457
1632
|
S: this,
|
|
1458
1633
|
C: (f, a) => f(...a)
|
|
1459
1634
|
});
|
|
1460
1635
|
(0, import_log5.log)("connected", {
|
|
1461
1636
|
...protocol.toJSON()
|
|
1462
1637
|
}, {
|
|
1463
|
-
F:
|
|
1464
|
-
L:
|
|
1638
|
+
F: __dxlog_file7,
|
|
1639
|
+
L: 138,
|
|
1465
1640
|
S: this,
|
|
1466
1641
|
C: (f, a) => f(...a)
|
|
1467
1642
|
});
|
|
@@ -1476,8 +1651,8 @@ var InvitationsHandler = class {
|
|
|
1476
1651
|
guest: deviceKey,
|
|
1477
1652
|
...protocol.toJSON()
|
|
1478
1653
|
}, {
|
|
1479
|
-
F:
|
|
1480
|
-
L:
|
|
1654
|
+
F: __dxlog_file7,
|
|
1655
|
+
L: 141,
|
|
1481
1656
|
S: this,
|
|
1482
1657
|
C: (f, a) => f(...a)
|
|
1483
1658
|
});
|
|
@@ -1488,8 +1663,8 @@ var InvitationsHandler = class {
|
|
|
1488
1663
|
import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.end({
|
|
1489
1664
|
id: traceId
|
|
1490
1665
|
}), {
|
|
1491
|
-
F:
|
|
1492
|
-
L:
|
|
1666
|
+
F: __dxlog_file7,
|
|
1667
|
+
L: 143,
|
|
1493
1668
|
S: this,
|
|
1494
1669
|
C: (f, a) => f(...a)
|
|
1495
1670
|
});
|
|
@@ -1498,8 +1673,8 @@ var InvitationsHandler = class {
|
|
|
1498
1673
|
(0, import_log5.log)("timeout", {
|
|
1499
1674
|
...protocol.toJSON()
|
|
1500
1675
|
}, {
|
|
1501
|
-
F:
|
|
1502
|
-
L:
|
|
1676
|
+
F: __dxlog_file7,
|
|
1677
|
+
L: 146,
|
|
1503
1678
|
S: this,
|
|
1504
1679
|
C: (f, a) => f(...a)
|
|
1505
1680
|
});
|
|
@@ -1509,8 +1684,8 @@ var InvitationsHandler = class {
|
|
|
1509
1684
|
});
|
|
1510
1685
|
} else {
|
|
1511
1686
|
import_log5.log.error("failed", err, {
|
|
1512
|
-
F:
|
|
1513
|
-
L:
|
|
1687
|
+
F: __dxlog_file7,
|
|
1688
|
+
L: 149,
|
|
1514
1689
|
S: this,
|
|
1515
1690
|
C: (f, a) => f(...a)
|
|
1516
1691
|
});
|
|
@@ -1520,8 +1695,8 @@ var InvitationsHandler = class {
|
|
|
1520
1695
|
id: traceId,
|
|
1521
1696
|
error: err
|
|
1522
1697
|
}), {
|
|
1523
|
-
F:
|
|
1524
|
-
L:
|
|
1698
|
+
F: __dxlog_file7,
|
|
1699
|
+
L: 152,
|
|
1525
1700
|
S: this,
|
|
1526
1701
|
C: (f, a) => f(...a)
|
|
1527
1702
|
});
|
|
@@ -1541,8 +1716,8 @@ var InvitationsHandler = class {
|
|
|
1541
1716
|
(0, import_log5.log)("timeout", {
|
|
1542
1717
|
...protocol.toJSON()
|
|
1543
1718
|
}, {
|
|
1544
|
-
F:
|
|
1545
|
-
L:
|
|
1719
|
+
F: __dxlog_file7,
|
|
1720
|
+
L: 167,
|
|
1546
1721
|
S: this,
|
|
1547
1722
|
C: (f, a) => f(...a)
|
|
1548
1723
|
});
|
|
@@ -1552,8 +1727,8 @@ var InvitationsHandler = class {
|
|
|
1552
1727
|
});
|
|
1553
1728
|
} else {
|
|
1554
1729
|
import_log5.log.error("failed", err, {
|
|
1555
|
-
F:
|
|
1556
|
-
L:
|
|
1730
|
+
F: __dxlog_file7,
|
|
1731
|
+
L: 170,
|
|
1557
1732
|
S: this,
|
|
1558
1733
|
C: (f, a) => f(...a)
|
|
1559
1734
|
});
|
|
@@ -1595,27 +1770,43 @@ var InvitationsHandler = class {
|
|
|
1595
1770
|
}
|
|
1596
1771
|
acceptInvitation(protocol, invitation) {
|
|
1597
1772
|
const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
|
|
1598
|
-
(0,
|
|
1773
|
+
(0, import_invariant6.invariant)(protocol, void 0, {
|
|
1774
|
+
F: __dxlog_file7,
|
|
1775
|
+
L: 210,
|
|
1776
|
+
S: this,
|
|
1777
|
+
A: [
|
|
1778
|
+
"protocol",
|
|
1779
|
+
""
|
|
1780
|
+
]
|
|
1781
|
+
});
|
|
1599
1782
|
const authenticated = new import_async8.Trigger();
|
|
1600
1783
|
let admitted = false;
|
|
1601
1784
|
let currentState;
|
|
1602
1785
|
const stream = new import_async8.PushStream();
|
|
1603
1786
|
const setState = (newData) => {
|
|
1604
|
-
(0,
|
|
1787
|
+
(0, import_invariant6.invariant)(newData.state !== void 0, void 0, {
|
|
1788
|
+
F: __dxlog_file7,
|
|
1789
|
+
L: 221,
|
|
1790
|
+
S: this,
|
|
1791
|
+
A: [
|
|
1792
|
+
"newData.state !== undefined",
|
|
1793
|
+
""
|
|
1794
|
+
]
|
|
1795
|
+
});
|
|
1605
1796
|
currentState = newData.state;
|
|
1606
1797
|
stream.next({
|
|
1607
1798
|
...invitation,
|
|
1608
1799
|
...newData
|
|
1609
1800
|
});
|
|
1610
1801
|
};
|
|
1611
|
-
const ctx = new
|
|
1802
|
+
const ctx = new import_context5.Context({
|
|
1612
1803
|
onError: (err) => {
|
|
1613
1804
|
if (err instanceof import_async8.TimeoutError) {
|
|
1614
1805
|
(0, import_log5.log)("timeout", {
|
|
1615
1806
|
...protocol.toJSON()
|
|
1616
1807
|
}, {
|
|
1617
|
-
F:
|
|
1618
|
-
L:
|
|
1808
|
+
F: __dxlog_file7,
|
|
1809
|
+
L: 229,
|
|
1619
1810
|
S: this,
|
|
1620
1811
|
C: (f, a) => f(...a)
|
|
1621
1812
|
});
|
|
@@ -1624,8 +1815,8 @@ var InvitationsHandler = class {
|
|
|
1624
1815
|
});
|
|
1625
1816
|
} else {
|
|
1626
1817
|
import_log5.log.warn("auth failed", err, {
|
|
1627
|
-
F:
|
|
1628
|
-
L:
|
|
1818
|
+
F: __dxlog_file7,
|
|
1819
|
+
L: 232,
|
|
1629
1820
|
S: this,
|
|
1630
1821
|
C: (f, a) => f(...a)
|
|
1631
1822
|
});
|
|
@@ -1638,8 +1829,8 @@ var InvitationsHandler = class {
|
|
|
1638
1829
|
(0, import_log5.log)("complete", {
|
|
1639
1830
|
...protocol.toJSON()
|
|
1640
1831
|
}, {
|
|
1641
|
-
F:
|
|
1642
|
-
L:
|
|
1832
|
+
F: __dxlog_file7,
|
|
1833
|
+
L: 240,
|
|
1643
1834
|
S: this,
|
|
1644
1835
|
C: (f, a) => f(...a)
|
|
1645
1836
|
});
|
|
@@ -1653,8 +1844,8 @@ var InvitationsHandler = class {
|
|
|
1653
1844
|
(0, import_log5.log)("extension disposed", {
|
|
1654
1845
|
currentState
|
|
1655
1846
|
}, {
|
|
1656
|
-
F:
|
|
1657
|
-
L:
|
|
1847
|
+
F: __dxlog_file7,
|
|
1848
|
+
L: 250,
|
|
1658
1849
|
S: this,
|
|
1659
1850
|
C: (f, a) => f(...a)
|
|
1660
1851
|
});
|
|
@@ -1668,8 +1859,8 @@ var InvitationsHandler = class {
|
|
|
1668
1859
|
import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.begin({
|
|
1669
1860
|
id: traceId
|
|
1670
1861
|
}), {
|
|
1671
|
-
F:
|
|
1672
|
-
L:
|
|
1862
|
+
F: __dxlog_file7,
|
|
1863
|
+
L: 259,
|
|
1673
1864
|
S: this,
|
|
1674
1865
|
C: (f, a) => f(...a)
|
|
1675
1866
|
});
|
|
@@ -1680,8 +1871,8 @@ var InvitationsHandler = class {
|
|
|
1680
1871
|
(0, import_log5.log)("connected", {
|
|
1681
1872
|
...protocol.toJSON()
|
|
1682
1873
|
}, {
|
|
1683
|
-
F:
|
|
1684
|
-
L:
|
|
1874
|
+
F: __dxlog_file7,
|
|
1875
|
+
L: 267,
|
|
1685
1876
|
S: this,
|
|
1686
1877
|
C: (f, a) => f(...a)
|
|
1687
1878
|
});
|
|
@@ -1691,8 +1882,8 @@ var InvitationsHandler = class {
|
|
|
1691
1882
|
(0, import_log5.log)("introduce", {
|
|
1692
1883
|
...protocol.toJSON()
|
|
1693
1884
|
}, {
|
|
1694
|
-
F:
|
|
1695
|
-
L:
|
|
1885
|
+
F: __dxlog_file7,
|
|
1886
|
+
L: 271,
|
|
1696
1887
|
S: this,
|
|
1697
1888
|
C: (f, a) => f(...a)
|
|
1698
1889
|
});
|
|
@@ -1701,8 +1892,8 @@ var InvitationsHandler = class {
|
|
|
1701
1892
|
...protocol.toJSON(),
|
|
1702
1893
|
response: introductionResponse
|
|
1703
1894
|
}, {
|
|
1704
|
-
F:
|
|
1705
|
-
L:
|
|
1895
|
+
F: __dxlog_file7,
|
|
1896
|
+
L: 275,
|
|
1706
1897
|
S: this,
|
|
1707
1898
|
C: (f, a) => f(...a)
|
|
1708
1899
|
});
|
|
@@ -1713,8 +1904,8 @@ var InvitationsHandler = class {
|
|
|
1713
1904
|
if (isAuthenticationRequired(invitation)) {
|
|
1714
1905
|
for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
|
|
1715
1906
|
(0, import_log5.log)("guest waiting for authentication code...", void 0, {
|
|
1716
|
-
F:
|
|
1717
|
-
L:
|
|
1907
|
+
F: __dxlog_file7,
|
|
1908
|
+
L: 284,
|
|
1718
1909
|
S: this,
|
|
1719
1910
|
C: (f, a) => f(...a)
|
|
1720
1911
|
});
|
|
@@ -1725,8 +1916,8 @@ var InvitationsHandler = class {
|
|
|
1725
1916
|
timeout
|
|
1726
1917
|
});
|
|
1727
1918
|
(0, import_log5.log)("sending authentication request", void 0, {
|
|
1728
|
-
F:
|
|
1729
|
-
L:
|
|
1919
|
+
F: __dxlog_file7,
|
|
1920
|
+
L: 288,
|
|
1730
1921
|
S: this,
|
|
1731
1922
|
C: (f, a) => f(...a)
|
|
1732
1923
|
});
|
|
@@ -1746,8 +1937,8 @@ var InvitationsHandler = class {
|
|
|
1746
1937
|
(0, import_log5.log)("retrying invalid code", {
|
|
1747
1938
|
attempt
|
|
1748
1939
|
}, {
|
|
1749
|
-
F:
|
|
1750
|
-
L:
|
|
1940
|
+
F: __dxlog_file7,
|
|
1941
|
+
L: 299,
|
|
1751
1942
|
S: this,
|
|
1752
1943
|
C: (f, a) => f(...a)
|
|
1753
1944
|
});
|
|
@@ -1763,8 +1954,8 @@ var InvitationsHandler = class {
|
|
|
1763
1954
|
(0, import_log5.log)("request admission", {
|
|
1764
1955
|
...protocol.toJSON()
|
|
1765
1956
|
}, {
|
|
1766
|
-
F:
|
|
1767
|
-
L:
|
|
1957
|
+
F: __dxlog_file7,
|
|
1958
|
+
L: 310,
|
|
1768
1959
|
S: this,
|
|
1769
1960
|
C: (f, a) => f(...a)
|
|
1770
1961
|
});
|
|
@@ -1775,8 +1966,8 @@ var InvitationsHandler = class {
|
|
|
1775
1966
|
(0, import_log5.log)("admitted by host", {
|
|
1776
1967
|
...protocol.toJSON()
|
|
1777
1968
|
}, {
|
|
1778
|
-
F:
|
|
1779
|
-
L:
|
|
1969
|
+
F: __dxlog_file7,
|
|
1970
|
+
L: 321,
|
|
1780
1971
|
S: this,
|
|
1781
1972
|
C: (f, a) => f(...a)
|
|
1782
1973
|
});
|
|
@@ -1787,8 +1978,8 @@ var InvitationsHandler = class {
|
|
|
1787
1978
|
import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.end({
|
|
1788
1979
|
id: traceId
|
|
1789
1980
|
}), {
|
|
1790
|
-
F:
|
|
1791
|
-
L:
|
|
1981
|
+
F: __dxlog_file7,
|
|
1982
|
+
L: 323,
|
|
1792
1983
|
S: this,
|
|
1793
1984
|
C: (f, a) => f(...a)
|
|
1794
1985
|
});
|
|
@@ -1797,8 +1988,8 @@ var InvitationsHandler = class {
|
|
|
1797
1988
|
(0, import_log5.log)("timeout", {
|
|
1798
1989
|
...protocol.toJSON()
|
|
1799
1990
|
}, {
|
|
1800
|
-
F:
|
|
1801
|
-
L:
|
|
1991
|
+
F: __dxlog_file7,
|
|
1992
|
+
L: 326,
|
|
1802
1993
|
S: this,
|
|
1803
1994
|
C: (f, a) => f(...a)
|
|
1804
1995
|
});
|
|
@@ -1807,8 +1998,8 @@ var InvitationsHandler = class {
|
|
|
1807
1998
|
});
|
|
1808
1999
|
} else {
|
|
1809
2000
|
(0, import_log5.log)("auth failed", err, {
|
|
1810
|
-
F:
|
|
1811
|
-
L:
|
|
2001
|
+
F: __dxlog_file7,
|
|
2002
|
+
L: 329,
|
|
1812
2003
|
S: this,
|
|
1813
2004
|
C: (f, a) => f(...a)
|
|
1814
2005
|
});
|
|
@@ -1818,8 +2009,8 @@ var InvitationsHandler = class {
|
|
|
1818
2009
|
id: traceId,
|
|
1819
2010
|
error: err
|
|
1820
2011
|
}), {
|
|
1821
|
-
F:
|
|
1822
|
-
L:
|
|
2012
|
+
F: __dxlog_file7,
|
|
2013
|
+
L: 332,
|
|
1823
2014
|
S: this,
|
|
1824
2015
|
C: (f, a) => f(...a)
|
|
1825
2016
|
});
|
|
@@ -1836,8 +2027,8 @@ var InvitationsHandler = class {
|
|
|
1836
2027
|
(0, import_log5.log)("timeout", {
|
|
1837
2028
|
...protocol.toJSON()
|
|
1838
2029
|
}, {
|
|
1839
|
-
F:
|
|
1840
|
-
L:
|
|
2030
|
+
F: __dxlog_file7,
|
|
2031
|
+
L: 343,
|
|
1841
2032
|
S: this,
|
|
1842
2033
|
C: (f, a) => f(...a)
|
|
1843
2034
|
});
|
|
@@ -1846,8 +2037,8 @@ var InvitationsHandler = class {
|
|
|
1846
2037
|
});
|
|
1847
2038
|
} else {
|
|
1848
2039
|
(0, import_log5.log)("auth failed", err, {
|
|
1849
|
-
F:
|
|
1850
|
-
L:
|
|
2040
|
+
F: __dxlog_file7,
|
|
2041
|
+
L: 346,
|
|
1851
2042
|
S: this,
|
|
1852
2043
|
C: (f, a) => f(...a)
|
|
1853
2044
|
});
|
|
@@ -1858,7 +2049,15 @@ var InvitationsHandler = class {
|
|
|
1858
2049
|
return extension;
|
|
1859
2050
|
};
|
|
1860
2051
|
(0, import_async8.scheduleTask)(ctx, async () => {
|
|
1861
|
-
(0,
|
|
2052
|
+
(0, import_invariant6.invariant)(invitation.swarmKey, void 0, {
|
|
2053
|
+
F: __dxlog_file7,
|
|
2054
|
+
L: 356,
|
|
2055
|
+
S: this,
|
|
2056
|
+
A: [
|
|
2057
|
+
"invitation.swarmKey",
|
|
2058
|
+
""
|
|
2059
|
+
]
|
|
2060
|
+
});
|
|
1862
2061
|
const topic = invitation.swarmKey;
|
|
1863
2062
|
const swarmConnection = await this._networkManager.joinSwarm({
|
|
1864
2063
|
topic,
|
|
@@ -1891,12 +2090,12 @@ var InvitationsHandler = class {
|
|
|
1891
2090
|
};
|
|
1892
2091
|
|
|
1893
2092
|
// packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
|
|
1894
|
-
var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
|
|
1895
2093
|
var import_async9 = require("@dxos/async");
|
|
1896
2094
|
var import_codec_protobuf8 = require("@dxos/codec-protobuf");
|
|
2095
|
+
var import_invariant7 = require("@dxos/invariant");
|
|
1897
2096
|
var import_log6 = require("@dxos/log");
|
|
1898
2097
|
var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
|
|
1899
|
-
var
|
|
2098
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
|
|
1900
2099
|
var InvitationsServiceImpl = class {
|
|
1901
2100
|
constructor(_invitationsHandler, _getHandler) {
|
|
1902
2101
|
this._invitationsHandler = _invitationsHandler;
|
|
@@ -1958,19 +2157,27 @@ var InvitationsServiceImpl = class {
|
|
|
1958
2157
|
}
|
|
1959
2158
|
async authenticate({ invitationId, authCode }) {
|
|
1960
2159
|
(0, import_log6.log)("authenticating...", void 0, {
|
|
1961
|
-
F:
|
|
1962
|
-
L:
|
|
2160
|
+
F: __dxlog_file8,
|
|
2161
|
+
L: 102,
|
|
1963
2162
|
S: this,
|
|
1964
2163
|
C: (f, a) => f(...a)
|
|
1965
2164
|
});
|
|
1966
|
-
(0,
|
|
2165
|
+
(0, import_invariant7.invariant)(invitationId, void 0, {
|
|
2166
|
+
F: __dxlog_file8,
|
|
2167
|
+
L: 103,
|
|
2168
|
+
S: this,
|
|
2169
|
+
A: [
|
|
2170
|
+
"invitationId",
|
|
2171
|
+
""
|
|
2172
|
+
]
|
|
2173
|
+
});
|
|
1967
2174
|
const observable = this._acceptInvitations.get(invitationId);
|
|
1968
2175
|
if (!observable) {
|
|
1969
2176
|
import_log6.log.warn("invalid invitation", {
|
|
1970
2177
|
invitationId
|
|
1971
2178
|
}, {
|
|
1972
|
-
F:
|
|
1973
|
-
L:
|
|
2179
|
+
F: __dxlog_file8,
|
|
2180
|
+
L: 106,
|
|
1974
2181
|
S: this,
|
|
1975
2182
|
C: (f, a) => f(...a)
|
|
1976
2183
|
});
|
|
@@ -1980,12 +2187,20 @@ var InvitationsServiceImpl = class {
|
|
|
1980
2187
|
}
|
|
1981
2188
|
async cancelInvitation({ invitationId }) {
|
|
1982
2189
|
(0, import_log6.log)("deleting...", void 0, {
|
|
1983
|
-
F:
|
|
1984
|
-
L:
|
|
2190
|
+
F: __dxlog_file8,
|
|
2191
|
+
L: 113,
|
|
1985
2192
|
S: this,
|
|
1986
2193
|
C: (f, a) => f(...a)
|
|
1987
2194
|
});
|
|
1988
|
-
(0,
|
|
2195
|
+
(0, import_invariant7.invariant)(invitationId, void 0, {
|
|
2196
|
+
F: __dxlog_file8,
|
|
2197
|
+
L: 114,
|
|
2198
|
+
S: this,
|
|
2199
|
+
A: [
|
|
2200
|
+
"invitationId",
|
|
2201
|
+
""
|
|
2202
|
+
]
|
|
2203
|
+
});
|
|
1989
2204
|
const created = this._createInvitations.get(invitationId);
|
|
1990
2205
|
const accepted = this._acceptInvitations.get(invitationId);
|
|
1991
2206
|
if (created) {
|
|
@@ -2000,8 +2215,8 @@ var InvitationsServiceImpl = class {
|
|
|
2000
2215
|
import_log6.log.warn("invalid invitation", {
|
|
2001
2216
|
invitationId
|
|
2002
2217
|
}, {
|
|
2003
|
-
F:
|
|
2004
|
-
L:
|
|
2218
|
+
F: __dxlog_file8,
|
|
2219
|
+
L: 126,
|
|
2005
2220
|
S: this,
|
|
2006
2221
|
C: (f, a) => f(...a)
|
|
2007
2222
|
});
|
|
@@ -2060,12 +2275,12 @@ var InvitationsServiceImpl = class {
|
|
|
2060
2275
|
};
|
|
2061
2276
|
|
|
2062
2277
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
2063
|
-
var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
|
|
2064
2278
|
var import_credentials8 = require("@dxos/credentials");
|
|
2065
2279
|
var import_feed_store3 = require("@dxos/feed-store");
|
|
2280
|
+
var import_invariant8 = require("@dxos/invariant");
|
|
2066
2281
|
var import_log7 = require("@dxos/log");
|
|
2067
2282
|
var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2068
|
-
var
|
|
2283
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
|
|
2069
2284
|
var SpaceInvitationProtocol = class {
|
|
2070
2285
|
constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
|
|
2071
2286
|
this._spaceManager = _spaceManager;
|
|
@@ -2087,24 +2302,64 @@ var SpaceInvitationProtocol = class {
|
|
|
2087
2302
|
}
|
|
2088
2303
|
async admit(request, guestProfile) {
|
|
2089
2304
|
var _a;
|
|
2090
|
-
(0,
|
|
2305
|
+
(0, import_invariant8.invariant)(this._spaceKey, void 0, {
|
|
2306
|
+
F: __dxlog_file9,
|
|
2307
|
+
L: 42,
|
|
2308
|
+
S: this,
|
|
2309
|
+
A: [
|
|
2310
|
+
"this._spaceKey",
|
|
2311
|
+
""
|
|
2312
|
+
]
|
|
2313
|
+
});
|
|
2091
2314
|
const space = await this._spaceManager.spaces.get(this._spaceKey);
|
|
2092
|
-
(0,
|
|
2093
|
-
|
|
2315
|
+
(0, import_invariant8.invariant)(space, void 0, {
|
|
2316
|
+
F: __dxlog_file9,
|
|
2317
|
+
L: 44,
|
|
2318
|
+
S: this,
|
|
2319
|
+
A: [
|
|
2320
|
+
"space",
|
|
2321
|
+
""
|
|
2322
|
+
]
|
|
2323
|
+
});
|
|
2324
|
+
(0, import_invariant8.invariant)(request.space, void 0, {
|
|
2325
|
+
F: __dxlog_file9,
|
|
2326
|
+
L: 46,
|
|
2327
|
+
S: this,
|
|
2328
|
+
A: [
|
|
2329
|
+
"request.space",
|
|
2330
|
+
""
|
|
2331
|
+
]
|
|
2332
|
+
});
|
|
2094
2333
|
const { identityKey, deviceKey } = request.space;
|
|
2095
2334
|
(0, import_log7.log)("writing guest credentials", {
|
|
2096
2335
|
host: this._signingContext.deviceKey,
|
|
2097
2336
|
guest: deviceKey
|
|
2098
2337
|
}, {
|
|
2099
|
-
F:
|
|
2100
|
-
L:
|
|
2338
|
+
F: __dxlog_file9,
|
|
2339
|
+
L: 49,
|
|
2101
2340
|
S: this,
|
|
2102
2341
|
C: (f, a) => f(...a)
|
|
2103
2342
|
});
|
|
2104
2343
|
const credentials = await (0, import_credentials8.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
|
|
2105
|
-
(0,
|
|
2344
|
+
(0, import_invariant8.invariant)(credentials[0].credential, void 0, {
|
|
2345
|
+
F: __dxlog_file9,
|
|
2346
|
+
L: 60,
|
|
2347
|
+
S: this,
|
|
2348
|
+
A: [
|
|
2349
|
+
"credentials[0].credential",
|
|
2350
|
+
""
|
|
2351
|
+
]
|
|
2352
|
+
});
|
|
2106
2353
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2107
|
-
(0,
|
|
2354
|
+
(0, import_invariant8.invariant)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2355
|
+
F: __dxlog_file9,
|
|
2356
|
+
L: 62,
|
|
2357
|
+
S: this,
|
|
2358
|
+
A: [
|
|
2359
|
+
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2360
|
+
""
|
|
2361
|
+
]
|
|
2362
|
+
});
|
|
2108
2363
|
await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, credentials);
|
|
2109
2364
|
return {
|
|
2110
2365
|
space: {
|
|
@@ -2132,11 +2387,35 @@ var SpaceInvitationProtocol = class {
|
|
|
2132
2387
|
};
|
|
2133
2388
|
}
|
|
2134
2389
|
async accept(response) {
|
|
2135
|
-
(0,
|
|
2390
|
+
(0, import_invariant8.invariant)(response.space, void 0, {
|
|
2391
|
+
F: __dxlog_file9,
|
|
2392
|
+
L: 97,
|
|
2393
|
+
S: this,
|
|
2394
|
+
A: [
|
|
2395
|
+
"response.space",
|
|
2396
|
+
""
|
|
2397
|
+
]
|
|
2398
|
+
});
|
|
2136
2399
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
2137
2400
|
const assertion = (0, import_credentials8.getCredentialAssertion)(credential);
|
|
2138
|
-
(0,
|
|
2139
|
-
|
|
2401
|
+
(0, import_invariant8.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2402
|
+
F: __dxlog_file9,
|
|
2403
|
+
L: 100,
|
|
2404
|
+
S: this,
|
|
2405
|
+
A: [
|
|
2406
|
+
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
2407
|
+
"'Invalid credential'"
|
|
2408
|
+
]
|
|
2409
|
+
});
|
|
2410
|
+
(0, import_invariant8.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
2411
|
+
F: __dxlog_file9,
|
|
2412
|
+
L: 101,
|
|
2413
|
+
S: this,
|
|
2414
|
+
A: [
|
|
2415
|
+
"credential.subject.id.equals(this._signingContext.identityKey)",
|
|
2416
|
+
""
|
|
2417
|
+
]
|
|
2418
|
+
});
|
|
2140
2419
|
await this._spaceManager.acceptSpace({
|
|
2141
2420
|
spaceKey: assertion.spaceKey,
|
|
2142
2421
|
genesisFeedKey: assertion.genesisFeedKey,
|
|
@@ -2203,63 +2482,231 @@ var ClientRpcServer = class {
|
|
|
2203
2482
|
}
|
|
2204
2483
|
};
|
|
2205
2484
|
|
|
2485
|
+
// packages/sdk/client-services/src/packlets/services/diagnostics.ts
|
|
2486
|
+
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
2487
|
+
var import_credentials9 = require("@dxos/credentials");
|
|
2488
|
+
var import_document_model = require("@dxos/document-model");
|
|
2489
|
+
var import_invariant9 = require("@dxos/invariant");
|
|
2490
|
+
var import_log8 = require("@dxos/log");
|
|
2491
|
+
var import_protocols5 = require("@dxos/protocols");
|
|
2492
|
+
var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2493
|
+
|
|
2494
|
+
// packages/sdk/client-services/src/version.ts
|
|
2495
|
+
var DXOS_VERSION = "0.1.56-main.01afb72";
|
|
2496
|
+
|
|
2497
|
+
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
2498
|
+
var getPlatform = () => {
|
|
2499
|
+
if (process.browser) {
|
|
2500
|
+
if (typeof window !== "undefined") {
|
|
2501
|
+
const { userAgent } = window.navigator;
|
|
2502
|
+
return {
|
|
2503
|
+
type: "browser",
|
|
2504
|
+
userAgent,
|
|
2505
|
+
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
2506
|
+
};
|
|
2507
|
+
} else {
|
|
2508
|
+
return {
|
|
2509
|
+
type: "shared-worker",
|
|
2510
|
+
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
2511
|
+
};
|
|
2512
|
+
}
|
|
2513
|
+
} else {
|
|
2514
|
+
const { platform, version, arch } = process;
|
|
2515
|
+
return {
|
|
2516
|
+
type: "node",
|
|
2517
|
+
platform: `${platform} ${version} ${arch}`,
|
|
2518
|
+
runtime: process.version,
|
|
2519
|
+
uptime: Math.floor(process.uptime()),
|
|
2520
|
+
memory: process.memoryUsage()
|
|
2521
|
+
};
|
|
2522
|
+
}
|
|
2523
|
+
};
|
|
2524
|
+
|
|
2525
|
+
// packages/sdk/client-services/src/packlets/services/diagnostics.ts
|
|
2526
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
2527
|
+
var DEFAULT_TIMEOUT = 1e3;
|
|
2528
|
+
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
2529
|
+
var _a, _b, _c;
|
|
2530
|
+
const diagnostics = {
|
|
2531
|
+
created: new Date().toISOString(),
|
|
2532
|
+
platform: getPlatform(),
|
|
2533
|
+
client: {
|
|
2534
|
+
version: DXOS_VERSION,
|
|
2535
|
+
storage: {
|
|
2536
|
+
version: import_protocols5.STORAGE_VERSION
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
};
|
|
2540
|
+
{
|
|
2541
|
+
(0, import_invariant9.invariant)(clientServices.LoggingService, "SystemService is not available.", {
|
|
2542
|
+
F: __dxlog_file10,
|
|
2543
|
+
L: 87,
|
|
2544
|
+
S: void 0,
|
|
2545
|
+
A: [
|
|
2546
|
+
"clientServices.LoggingService",
|
|
2547
|
+
"'SystemService is not available.'"
|
|
2548
|
+
]
|
|
2549
|
+
});
|
|
2550
|
+
diagnostics.metrics = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
|
|
2551
|
+
timeout: DEFAULT_TIMEOUT
|
|
2552
|
+
}).catch(() => void 0);
|
|
2553
|
+
}
|
|
2554
|
+
const identity = serviceContext.identityManager.identity;
|
|
2555
|
+
if (identity) {
|
|
2556
|
+
diagnostics.identity = {
|
|
2557
|
+
identityKey: identity.identityKey,
|
|
2558
|
+
spaceKey: identity.space.key,
|
|
2559
|
+
profile: identity.profileDocument
|
|
2560
|
+
};
|
|
2561
|
+
const { devices } = (_a = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
|
|
2562
|
+
timeout: DEFAULT_TIMEOUT
|
|
2563
|
+
}).catch(() => void 0)) != null ? _a : {};
|
|
2564
|
+
diagnostics.devices = devices;
|
|
2565
|
+
if (serviceContext.dataSpaceManager) {
|
|
2566
|
+
diagnostics.spaces = await Promise.all((_b = Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space))) != null ? _b : []);
|
|
2567
|
+
}
|
|
2568
|
+
const { feeds = [] } = (_c = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
2569
|
+
timeout: DEFAULT_TIMEOUT
|
|
2570
|
+
}).catch(() => void 0)) != null ? _c : {};
|
|
2571
|
+
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
2572
|
+
feedKey,
|
|
2573
|
+
bytes,
|
|
2574
|
+
length
|
|
2575
|
+
}));
|
|
2576
|
+
}
|
|
2577
|
+
diagnostics.config = config.values;
|
|
2578
|
+
return diagnostics;
|
|
2579
|
+
};
|
|
2580
|
+
var getProperties = (space) => {
|
|
2581
|
+
let properties = {};
|
|
2582
|
+
try {
|
|
2583
|
+
const propertiesItem = space.dataPipeline.itemManager.items.find((item) => {
|
|
2584
|
+
var _a, _b;
|
|
2585
|
+
return ((_a = item.modelMeta) == null ? void 0 : _a.type) === import_document_model.DocumentModel.meta.type && ((_b = item.state) == null ? void 0 : _b.type) === "dxos.sdk.client.Properties";
|
|
2586
|
+
});
|
|
2587
|
+
const state = propertiesItem == null ? void 0 : propertiesItem.state;
|
|
2588
|
+
properties = state == null ? void 0 : state.data;
|
|
2589
|
+
} catch (err) {
|
|
2590
|
+
import_log8.log.warn(err.message, void 0, {
|
|
2591
|
+
F: __dxlog_file10,
|
|
2592
|
+
L: 144,
|
|
2593
|
+
S: void 0,
|
|
2594
|
+
C: (f, a) => f(...a)
|
|
2595
|
+
});
|
|
2596
|
+
}
|
|
2597
|
+
return properties;
|
|
2598
|
+
};
|
|
2599
|
+
var getSpaceStats = async (space) => {
|
|
2600
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2601
|
+
const stats = {
|
|
2602
|
+
key: space.key,
|
|
2603
|
+
metrics: space.metrics,
|
|
2604
|
+
epochs: space.inner.spaceState.credentials.filter((0, import_credentials9.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
2605
|
+
...credential.subject.assertion,
|
|
2606
|
+
id: credential.id
|
|
2607
|
+
})),
|
|
2608
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
2609
|
+
var _a2;
|
|
2610
|
+
return {
|
|
2611
|
+
identity: {
|
|
2612
|
+
identityKey: member.key,
|
|
2613
|
+
profile: {
|
|
2614
|
+
displayName: (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName
|
|
2615
|
+
}
|
|
2616
|
+
},
|
|
2617
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services6.SpaceMember.PresenceState.ONLINE : import_services6.SpaceMember.PresenceState.OFFLINE
|
|
2618
|
+
};
|
|
2619
|
+
}),
|
|
2620
|
+
pipeline: {
|
|
2621
|
+
// TODO(burdon): Pick properties from credentials if needed.
|
|
2622
|
+
// currentEpoch: space.dataPipeline.currentEpoch,
|
|
2623
|
+
// appliedEpoch: space.dataPipeline.appliedEpoch,
|
|
2624
|
+
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
2625
|
+
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2626
|
+
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
2627
|
+
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
|
|
2628
|
+
// TODO(burdon): Empty?
|
|
2629
|
+
dataFeeds: (_b = (_a = space.dataPipeline.pipelineState) == null ? void 0 : _a.feeds.map((feed) => feed.key)) != null ? _b : [],
|
|
2630
|
+
startDataTimeframe: (_c = space.dataPipeline.pipelineState) == null ? void 0 : _c.startTimeframe,
|
|
2631
|
+
currentDataTimeframe: (_d = space.dataPipeline.pipelineState) == null ? void 0 : _d.timeframe,
|
|
2632
|
+
targetDataTimeframe: (_e = space.dataPipeline.pipelineState) == null ? void 0 : _e.targetTimeframe,
|
|
2633
|
+
totalDataTimeframe: (_f = space.dataPipeline.pipelineState) == null ? void 0 : _f.endTimeframe
|
|
2634
|
+
}
|
|
2635
|
+
};
|
|
2636
|
+
if (space.dataPipeline.itemManager) {
|
|
2637
|
+
Object.assign(stats, {
|
|
2638
|
+
properties: getProperties(space),
|
|
2639
|
+
db: {
|
|
2640
|
+
objects: space.dataPipeline.itemManager.entities.size
|
|
2641
|
+
}
|
|
2642
|
+
});
|
|
2643
|
+
}
|
|
2644
|
+
if (stats.metrics) {
|
|
2645
|
+
const { open, ready } = stats.metrics;
|
|
2646
|
+
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
2647
|
+
}
|
|
2648
|
+
return stats;
|
|
2649
|
+
};
|
|
2650
|
+
|
|
2206
2651
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
2207
|
-
var import_tiny_invariant11 = __toESM(require("tiny-invariant"));
|
|
2208
2652
|
var import_async14 = require("@dxos/async");
|
|
2209
|
-
var
|
|
2653
|
+
var import_context9 = require("@dxos/context");
|
|
2654
|
+
var import_credentials14 = require("@dxos/credentials");
|
|
2210
2655
|
var import_debug7 = require("@dxos/debug");
|
|
2211
2656
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
2212
2657
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
2658
|
+
var import_invariant12 = require("@dxos/invariant");
|
|
2213
2659
|
var import_keyring = require("@dxos/keyring");
|
|
2214
2660
|
var import_keys10 = require("@dxos/keys");
|
|
2215
|
-
var
|
|
2216
|
-
var
|
|
2217
|
-
var
|
|
2661
|
+
var import_log13 = require("@dxos/log");
|
|
2662
|
+
var import_protocols9 = require("@dxos/protocols");
|
|
2663
|
+
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2218
2664
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
2665
|
+
var import_tracing3 = require("@dxos/tracing");
|
|
2219
2666
|
|
|
2220
2667
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2221
|
-
var import_tiny_invariant10 = __toESM(require("tiny-invariant"));
|
|
2222
2668
|
var import_async12 = require("@dxos/async");
|
|
2223
|
-
var
|
|
2224
|
-
var
|
|
2669
|
+
var import_context8 = require("@dxos/context");
|
|
2670
|
+
var import_credentials13 = require("@dxos/credentials");
|
|
2671
|
+
var import_invariant11 = require("@dxos/invariant");
|
|
2225
2672
|
var import_keys9 = require("@dxos/keys");
|
|
2226
|
-
var
|
|
2227
|
-
var
|
|
2228
|
-
var
|
|
2673
|
+
var import_log11 = require("@dxos/log");
|
|
2674
|
+
var import_protocols7 = require("@dxos/protocols");
|
|
2675
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2229
2676
|
var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
|
|
2230
2677
|
var import_util5 = require("@dxos/util");
|
|
2231
2678
|
|
|
2232
2679
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2233
2680
|
var import_async11 = require("@dxos/async");
|
|
2234
2681
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
2235
|
-
var
|
|
2682
|
+
var import_context7 = require("@dxos/context");
|
|
2236
2683
|
var import_debug4 = require("@dxos/debug");
|
|
2237
2684
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
2238
2685
|
var import_errors3 = require("@dxos/errors");
|
|
2239
2686
|
var import_keys8 = require("@dxos/keys");
|
|
2240
|
-
var
|
|
2241
|
-
var
|
|
2242
|
-
var
|
|
2687
|
+
var import_log10 = require("@dxos/log");
|
|
2688
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
2689
|
+
var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2243
2690
|
var import_timeframe = require("@dxos/timeframe");
|
|
2244
2691
|
var import_util4 = require("@dxos/util");
|
|
2245
2692
|
|
|
2246
2693
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
2247
|
-
var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
|
|
2248
2694
|
var import_async10 = require("@dxos/async");
|
|
2249
|
-
var
|
|
2695
|
+
var import_context6 = require("@dxos/context");
|
|
2696
|
+
var import_invariant10 = require("@dxos/invariant");
|
|
2250
2697
|
var import_keys7 = require("@dxos/keys");
|
|
2251
|
-
var
|
|
2252
|
-
var
|
|
2698
|
+
var import_log9 = require("@dxos/log");
|
|
2699
|
+
var import_protocols6 = require("@dxos/protocols");
|
|
2253
2700
|
var import_teleport2 = require("@dxos/teleport");
|
|
2254
2701
|
var import_util3 = require("@dxos/util");
|
|
2255
|
-
var
|
|
2702
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
2256
2703
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
2257
2704
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
2258
2705
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
2259
2706
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
2260
2707
|
var NotarizationPlugin = class {
|
|
2261
2708
|
constructor() {
|
|
2262
|
-
this._ctx = new
|
|
2709
|
+
this._ctx = new import_context6.Context();
|
|
2263
2710
|
this._extensionOpened = new import_async10.Event();
|
|
2264
2711
|
this._extensions = /* @__PURE__ */ new Set();
|
|
2265
2712
|
this._processedCredentials = new import_util3.ComplexSet(import_keys7.PublicKey.hash);
|
|
@@ -2277,23 +2724,31 @@ var NotarizationPlugin = class {
|
|
|
2277
2724
|
* Request credentials to be notarized.
|
|
2278
2725
|
*/
|
|
2279
2726
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
2280
|
-
(0,
|
|
2727
|
+
(0, import_log9.log)("notarize", {
|
|
2281
2728
|
credentials
|
|
2282
2729
|
}, {
|
|
2283
|
-
F:
|
|
2284
|
-
L:
|
|
2730
|
+
F: __dxlog_file11,
|
|
2731
|
+
L: 90,
|
|
2285
2732
|
S: this,
|
|
2286
2733
|
C: (f, a) => f(...a)
|
|
2287
2734
|
});
|
|
2288
|
-
(0,
|
|
2735
|
+
(0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
2736
|
+
F: __dxlog_file11,
|
|
2737
|
+
L: 91,
|
|
2738
|
+
S: this,
|
|
2739
|
+
A: [
|
|
2740
|
+
"credentials.every((credential) => credential.id)",
|
|
2741
|
+
"'Credentials must have an id'"
|
|
2742
|
+
]
|
|
2743
|
+
});
|
|
2289
2744
|
const errors = new import_async10.Trigger();
|
|
2290
2745
|
const ctx = this._ctx.derive({
|
|
2291
2746
|
onError: (err) => {
|
|
2292
|
-
|
|
2747
|
+
import_log9.log.warn("Notarization error", {
|
|
2293
2748
|
err
|
|
2294
2749
|
}, {
|
|
2295
|
-
F:
|
|
2296
|
-
L:
|
|
2750
|
+
F: __dxlog_file11,
|
|
2751
|
+
L: 99,
|
|
2297
2752
|
S: this,
|
|
2298
2753
|
C: (f, a) => f(...a)
|
|
2299
2754
|
});
|
|
@@ -2304,12 +2759,12 @@ var NotarizationPlugin = class {
|
|
|
2304
2759
|
opCtx == null ? void 0 : opCtx.onDispose(() => ctx.dispose());
|
|
2305
2760
|
if (timeout !== 0) {
|
|
2306
2761
|
(0, import_async10.scheduleTask)(ctx, () => {
|
|
2307
|
-
|
|
2762
|
+
import_log9.log.warn("Notarization timeout", {
|
|
2308
2763
|
timeout,
|
|
2309
2764
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
2310
2765
|
}, {
|
|
2311
|
-
F:
|
|
2312
|
-
L:
|
|
2766
|
+
F: __dxlog_file11,
|
|
2767
|
+
L: 111,
|
|
2313
2768
|
S: this,
|
|
2314
2769
|
C: (f, a) => f(...a)
|
|
2315
2770
|
});
|
|
@@ -2328,11 +2783,11 @@ var NotarizationPlugin = class {
|
|
|
2328
2783
|
...this._extensions
|
|
2329
2784
|
].find((peer2) => !peersTried.has(peer2));
|
|
2330
2785
|
if (!peer) {
|
|
2331
|
-
|
|
2786
|
+
import_log9.log.warn("Exhausted all peers to notarize with", {
|
|
2332
2787
|
retryIn: retryTimeout
|
|
2333
2788
|
}, {
|
|
2334
|
-
F:
|
|
2335
|
-
L:
|
|
2789
|
+
F: __dxlog_file11,
|
|
2790
|
+
L: 136,
|
|
2336
2791
|
S: this,
|
|
2337
2792
|
C: (f, a) => f(...a)
|
|
2338
2793
|
});
|
|
@@ -2341,30 +2796,30 @@ var NotarizationPlugin = class {
|
|
|
2341
2796
|
return;
|
|
2342
2797
|
}
|
|
2343
2798
|
peersTried.add(peer);
|
|
2344
|
-
(0,
|
|
2799
|
+
(0, import_log9.log)("try notarizing", {
|
|
2345
2800
|
peer: peer.localPeerId,
|
|
2346
2801
|
credentialId: credentials.map((credential) => credential.id)
|
|
2347
2802
|
}, {
|
|
2348
|
-
F:
|
|
2349
|
-
L:
|
|
2803
|
+
F: __dxlog_file11,
|
|
2804
|
+
L: 143,
|
|
2350
2805
|
S: this,
|
|
2351
2806
|
C: (f, a) => f(...a)
|
|
2352
2807
|
});
|
|
2353
2808
|
await peer.rpc.NotarizationService.notarize({
|
|
2354
2809
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
2355
2810
|
});
|
|
2356
|
-
(0,
|
|
2357
|
-
F:
|
|
2358
|
-
L:
|
|
2811
|
+
(0, import_log9.log)("success", void 0, {
|
|
2812
|
+
F: __dxlog_file11,
|
|
2813
|
+
L: 147,
|
|
2359
2814
|
S: this,
|
|
2360
2815
|
C: (f, a) => f(...a)
|
|
2361
2816
|
});
|
|
2362
2817
|
await (0, import_async10.sleep)(successDelay);
|
|
2363
2818
|
} catch (err) {
|
|
2364
2819
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
2365
|
-
|
|
2366
|
-
F:
|
|
2367
|
-
L:
|
|
2820
|
+
import_log9.log.warn("error notarizing (recoverable)", err, {
|
|
2821
|
+
F: __dxlog_file11,
|
|
2822
|
+
L: 151,
|
|
2368
2823
|
S: this,
|
|
2369
2824
|
C: (f, a) => f(...a)
|
|
2370
2825
|
});
|
|
@@ -2376,13 +2831,13 @@ var NotarizationPlugin = class {
|
|
|
2376
2831
|
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
2377
2832
|
try {
|
|
2378
2833
|
await Promise.race([
|
|
2379
|
-
(0,
|
|
2834
|
+
(0, import_context6.rejectOnDispose)(ctx),
|
|
2380
2835
|
allNotarized,
|
|
2381
2836
|
errors.wait()
|
|
2382
2837
|
]);
|
|
2383
|
-
(0,
|
|
2384
|
-
F:
|
|
2385
|
-
L:
|
|
2838
|
+
(0, import_log9.log)("done", void 0, {
|
|
2839
|
+
F: __dxlog_file11,
|
|
2840
|
+
L: 162,
|
|
2386
2841
|
S: this,
|
|
2387
2842
|
C: (f, a) => f(...a)
|
|
2388
2843
|
});
|
|
@@ -2403,7 +2858,15 @@ var NotarizationPlugin = class {
|
|
|
2403
2858
|
this._processCredentialsTriggers.delete(credential.id);
|
|
2404
2859
|
}
|
|
2405
2860
|
setWriter(writer) {
|
|
2406
|
-
(0,
|
|
2861
|
+
(0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
|
|
2862
|
+
F: __dxlog_file11,
|
|
2863
|
+
L: 181,
|
|
2864
|
+
S: this,
|
|
2865
|
+
A: [
|
|
2866
|
+
"!this._writer",
|
|
2867
|
+
"'Writer already set.'"
|
|
2868
|
+
]
|
|
2869
|
+
});
|
|
2407
2870
|
this._writer = writer;
|
|
2408
2871
|
}
|
|
2409
2872
|
async _waitUntilProcessed(id) {
|
|
@@ -2421,7 +2884,15 @@ var NotarizationPlugin = class {
|
|
|
2421
2884
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
2422
2885
|
}
|
|
2423
2886
|
for (const credential of (_a = request.credentials) != null ? _a : []) {
|
|
2424
|
-
(0,
|
|
2887
|
+
(0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
|
|
2888
|
+
F: __dxlog_file11,
|
|
2889
|
+
L: 200,
|
|
2890
|
+
S: this,
|
|
2891
|
+
A: [
|
|
2892
|
+
"credential.id",
|
|
2893
|
+
"'Credential must have an id'"
|
|
2894
|
+
]
|
|
2895
|
+
});
|
|
2425
2896
|
if (this._processedCredentials.has(credential.id)) {
|
|
2426
2897
|
continue;
|
|
2427
2898
|
}
|
|
@@ -2431,11 +2902,11 @@ var NotarizationPlugin = class {
|
|
|
2431
2902
|
createExtension() {
|
|
2432
2903
|
const extension = new NotarizationTeleportExtension({
|
|
2433
2904
|
onOpen: async () => {
|
|
2434
|
-
(0,
|
|
2905
|
+
(0, import_log9.log)("extension opened", {
|
|
2435
2906
|
peer: extension.localPeerId
|
|
2436
2907
|
}, {
|
|
2437
|
-
F:
|
|
2438
|
-
L:
|
|
2908
|
+
F: __dxlog_file11,
|
|
2909
|
+
L: 211,
|
|
2439
2910
|
S: this,
|
|
2440
2911
|
C: (f, a) => f(...a)
|
|
2441
2912
|
});
|
|
@@ -2443,11 +2914,11 @@ var NotarizationPlugin = class {
|
|
|
2443
2914
|
this._extensionOpened.emit();
|
|
2444
2915
|
},
|
|
2445
2916
|
onClose: async () => {
|
|
2446
|
-
(0,
|
|
2917
|
+
(0, import_log9.log)("extension closed", {
|
|
2447
2918
|
peer: extension.localPeerId
|
|
2448
2919
|
}, {
|
|
2449
|
-
F:
|
|
2450
|
-
L:
|
|
2920
|
+
F: __dxlog_file11,
|
|
2921
|
+
L: 216,
|
|
2451
2922
|
S: this,
|
|
2452
2923
|
C: (f, a) => f(...a)
|
|
2453
2924
|
});
|
|
@@ -2462,10 +2933,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
2462
2933
|
constructor(_params) {
|
|
2463
2934
|
super({
|
|
2464
2935
|
requested: {
|
|
2465
|
-
NotarizationService:
|
|
2936
|
+
NotarizationService: import_protocols6.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
2466
2937
|
},
|
|
2467
2938
|
exposed: {
|
|
2468
|
-
NotarizationService:
|
|
2939
|
+
NotarizationService: import_protocols6.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
2469
2940
|
}
|
|
2470
2941
|
});
|
|
2471
2942
|
this._params = _params;
|
|
@@ -2490,7 +2961,7 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
2490
2961
|
};
|
|
2491
2962
|
|
|
2492
2963
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
2493
|
-
function
|
|
2964
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
2494
2965
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2495
2966
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2496
2967
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2500,12 +2971,12 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
2500
2971
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2501
2972
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2502
2973
|
}
|
|
2503
|
-
var
|
|
2974
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
2504
2975
|
var DataSpace = class DataSpace2 {
|
|
2505
2976
|
constructor(params) {
|
|
2506
|
-
this._ctx = new
|
|
2977
|
+
this._ctx = new import_context7.Context();
|
|
2507
2978
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
2508
|
-
this._state =
|
|
2979
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
2509
2980
|
/**
|
|
2510
2981
|
* Error for _state === SpaceState.ERROR.
|
|
2511
2982
|
*/
|
|
@@ -2561,8 +3032,8 @@ var DataSpace = class DataSpace2 {
|
|
|
2561
3032
|
async _open() {
|
|
2562
3033
|
await this._notarizationPlugin.open();
|
|
2563
3034
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
2564
|
-
await this._inner.open();
|
|
2565
|
-
this._state =
|
|
3035
|
+
await this._inner.open(new import_context7.Context());
|
|
3036
|
+
this._state = import_services7.SpaceState.CONTROL_ONLY;
|
|
2566
3037
|
this.stateUpdate.emit();
|
|
2567
3038
|
this.metrics = {};
|
|
2568
3039
|
this.metrics.open = new Date();
|
|
@@ -2573,9 +3044,9 @@ var DataSpace = class DataSpace2 {
|
|
|
2573
3044
|
async _close() {
|
|
2574
3045
|
var _a, _b;
|
|
2575
3046
|
await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
|
|
2576
|
-
this._state =
|
|
3047
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
2577
3048
|
await this._ctx.dispose();
|
|
2578
|
-
this._ctx = new
|
|
3049
|
+
this._ctx = new import_context7.Context();
|
|
2579
3050
|
await this.authVerifier.close();
|
|
2580
3051
|
await this._inner.close();
|
|
2581
3052
|
await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
|
|
@@ -2598,21 +3069,21 @@ var DataSpace = class DataSpace2 {
|
|
|
2598
3069
|
await this.initializeDataPipeline();
|
|
2599
3070
|
} catch (err) {
|
|
2600
3071
|
if (err instanceof import_errors3.CancelledError) {
|
|
2601
|
-
(0,
|
|
2602
|
-
F:
|
|
3072
|
+
(0, import_log10.log)("data pipeline initialization cancelled", err, {
|
|
3073
|
+
F: __dxlog_file12,
|
|
2603
3074
|
L: 193,
|
|
2604
3075
|
S: this,
|
|
2605
3076
|
C: (f, a) => f(...a)
|
|
2606
3077
|
});
|
|
2607
3078
|
return;
|
|
2608
3079
|
}
|
|
2609
|
-
|
|
2610
|
-
F:
|
|
3080
|
+
import_log10.log.error("Error initializing data pipeline", err, {
|
|
3081
|
+
F: __dxlog_file12,
|
|
2611
3082
|
L: 197,
|
|
2612
3083
|
S: this,
|
|
2613
3084
|
C: (f, a) => f(...a)
|
|
2614
3085
|
});
|
|
2615
|
-
this._state =
|
|
3086
|
+
this._state = import_services7.SpaceState.ERROR;
|
|
2616
3087
|
this.error = err;
|
|
2617
3088
|
this.stateUpdate.emit();
|
|
2618
3089
|
} finally {
|
|
@@ -2622,18 +3093,18 @@ var DataSpace = class DataSpace2 {
|
|
|
2622
3093
|
}
|
|
2623
3094
|
async initializeDataPipeline() {
|
|
2624
3095
|
var _a, _b, _c, _d;
|
|
2625
|
-
if (this._state !==
|
|
3096
|
+
if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
|
|
2626
3097
|
throw new import_errors3.SystemError("Invalid operation");
|
|
2627
3098
|
}
|
|
2628
|
-
this._state =
|
|
3099
|
+
this._state = import_services7.SpaceState.INITIALIZING;
|
|
2629
3100
|
await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
2630
3101
|
ctx: this._ctx,
|
|
2631
3102
|
breakOnStall: false
|
|
2632
3103
|
});
|
|
2633
3104
|
this.metrics.controlPipelineReady = new Date();
|
|
2634
3105
|
await this._createWritableFeeds();
|
|
2635
|
-
(0,
|
|
2636
|
-
F:
|
|
3106
|
+
(0, import_log10.log)("writable feeds created", void 0, {
|
|
3107
|
+
F: __dxlog_file12,
|
|
2637
3108
|
L: 221,
|
|
2638
3109
|
S: this,
|
|
2639
3110
|
C: (f, a) => f(...a)
|
|
@@ -2648,9 +3119,9 @@ var DataSpace = class DataSpace2 {
|
|
|
2648
3119
|
}
|
|
2649
3120
|
await this._inner.initializeDataPipeline();
|
|
2650
3121
|
this.metrics.dataPipelineOpen = new Date();
|
|
2651
|
-
await (0,
|
|
2652
|
-
(0,
|
|
2653
|
-
F:
|
|
3122
|
+
await (0, import_context7.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
|
|
3123
|
+
(0, import_log10.log)("waiting for data pipeline to reach target timeframe", void 0, {
|
|
3124
|
+
F: __dxlog_file12,
|
|
2654
3125
|
L: 242,
|
|
2655
3126
|
S: this,
|
|
2656
3127
|
C: (f, a) => f(...a)
|
|
@@ -2660,14 +3131,14 @@ var DataSpace = class DataSpace2 {
|
|
|
2660
3131
|
breakOnStall: false
|
|
2661
3132
|
});
|
|
2662
3133
|
this.metrics.dataPipelineReady = new Date();
|
|
2663
|
-
(0,
|
|
2664
|
-
F:
|
|
3134
|
+
(0, import_log10.log)("data pipeline ready", void 0, {
|
|
3135
|
+
F: __dxlog_file12,
|
|
2665
3136
|
L: 251,
|
|
2666
3137
|
S: this,
|
|
2667
3138
|
C: (f, a) => f(...a)
|
|
2668
3139
|
});
|
|
2669
3140
|
await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
|
|
2670
|
-
this._state =
|
|
3141
|
+
this._state = import_services7.SpaceState.READY;
|
|
2671
3142
|
this.stateUpdate.emit();
|
|
2672
3143
|
await ((_d = (_c = this._callbacks).afterReady) == null ? void 0 : _d.call(_c));
|
|
2673
3144
|
}
|
|
@@ -2685,7 +3156,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2685
3156
|
spaceKey: this.key,
|
|
2686
3157
|
deviceKey: this._signingContext.deviceKey,
|
|
2687
3158
|
identityKey: this._signingContext.identityKey,
|
|
2688
|
-
designation:
|
|
3159
|
+
designation: import_credentials10.AdmittedFeed.Designation.CONTROL
|
|
2689
3160
|
}
|
|
2690
3161
|
}));
|
|
2691
3162
|
}
|
|
@@ -2702,7 +3173,7 @@ var DataSpace = class DataSpace2 {
|
|
|
2702
3173
|
spaceKey: this.key,
|
|
2703
3174
|
deviceKey: this._signingContext.deviceKey,
|
|
2704
3175
|
identityKey: this._signingContext.identityKey,
|
|
2705
|
-
designation:
|
|
3176
|
+
designation: import_credentials10.AdmittedFeed.Designation.DATA
|
|
2706
3177
|
}
|
|
2707
3178
|
}));
|
|
2708
3179
|
}
|
|
@@ -2743,51 +3214,51 @@ var DataSpace = class DataSpace2 {
|
|
|
2743
3214
|
}
|
|
2744
3215
|
}
|
|
2745
3216
|
async activate() {
|
|
2746
|
-
if (this._state !==
|
|
3217
|
+
if (this._state !== import_services7.SpaceState.INACTIVE) {
|
|
2747
3218
|
return;
|
|
2748
3219
|
}
|
|
2749
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3220
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.ACTIVE);
|
|
2750
3221
|
await this._open();
|
|
2751
3222
|
this.initializeDataPipelineAsync();
|
|
2752
3223
|
}
|
|
2753
3224
|
async deactivate() {
|
|
2754
|
-
if (this._state ===
|
|
3225
|
+
if (this._state === import_services7.SpaceState.INACTIVE) {
|
|
2755
3226
|
return;
|
|
2756
3227
|
}
|
|
2757
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3228
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.INACTIVE);
|
|
2758
3229
|
await this._close();
|
|
2759
|
-
this._state =
|
|
3230
|
+
this._state = import_services7.SpaceState.INACTIVE;
|
|
2760
3231
|
this.stateUpdate.emit();
|
|
2761
3232
|
}
|
|
2762
3233
|
};
|
|
2763
|
-
|
|
3234
|
+
_ts_decorate3([
|
|
2764
3235
|
import_async11.synchronized
|
|
2765
3236
|
], DataSpace.prototype, "open", null);
|
|
2766
|
-
|
|
3237
|
+
_ts_decorate3([
|
|
2767
3238
|
import_async11.synchronized
|
|
2768
3239
|
], DataSpace.prototype, "close", null);
|
|
2769
|
-
|
|
3240
|
+
_ts_decorate3([
|
|
2770
3241
|
(0, import_debug4.timed)(1e4)
|
|
2771
3242
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
2772
|
-
|
|
3243
|
+
_ts_decorate3([
|
|
2773
3244
|
import_async11.synchronized
|
|
2774
3245
|
], DataSpace.prototype, "activate", null);
|
|
2775
|
-
|
|
3246
|
+
_ts_decorate3([
|
|
2776
3247
|
import_async11.synchronized
|
|
2777
3248
|
], DataSpace.prototype, "deactivate", null);
|
|
2778
|
-
DataSpace =
|
|
3249
|
+
DataSpace = _ts_decorate3([
|
|
2779
3250
|
(0, import_async11.trackLeaks)("open", "close")
|
|
2780
3251
|
], DataSpace);
|
|
2781
3252
|
|
|
2782
3253
|
// packages/sdk/client-services/src/packlets/spaces/genesis.ts
|
|
2783
|
-
var
|
|
3254
|
+
var import_credentials11 = require("@dxos/credentials");
|
|
2784
3255
|
var import_debug5 = require("@dxos/debug");
|
|
2785
|
-
var
|
|
3256
|
+
var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
2786
3257
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
2787
3258
|
var spaceGenesis = async (keyring, signingContext, space) => {
|
|
2788
3259
|
var _a, _b, _c, _d;
|
|
2789
3260
|
const credentials = [
|
|
2790
|
-
await (0,
|
|
3261
|
+
await (0, import_credentials11.createCredential)({
|
|
2791
3262
|
signer: keyring,
|
|
2792
3263
|
issuer: space.key,
|
|
2793
3264
|
subject: space.key,
|
|
@@ -2796,14 +3267,14 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2796
3267
|
spaceKey: space.key
|
|
2797
3268
|
}
|
|
2798
3269
|
}),
|
|
2799
|
-
await (0,
|
|
3270
|
+
await (0, import_credentials11.createCredential)({
|
|
2800
3271
|
signer: keyring,
|
|
2801
3272
|
issuer: space.key,
|
|
2802
3273
|
subject: signingContext.identityKey,
|
|
2803
3274
|
assertion: {
|
|
2804
3275
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
2805
3276
|
spaceKey: space.key,
|
|
2806
|
-
role:
|
|
3277
|
+
role: import_credentials12.SpaceMember.Role.ADMIN,
|
|
2807
3278
|
profile: signingContext.profile,
|
|
2808
3279
|
genesisFeedKey: (_a = space.controlFeedKey) != null ? _a : (0, import_debug5.failUndefined)()
|
|
2809
3280
|
}
|
|
@@ -2815,7 +3286,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2815
3286
|
spaceKey: space.key,
|
|
2816
3287
|
identityKey: signingContext.identityKey,
|
|
2817
3288
|
deviceKey: signingContext.deviceKey,
|
|
2818
|
-
designation:
|
|
3289
|
+
designation: import_credentials12.AdmittedFeed.Designation.CONTROL
|
|
2819
3290
|
}
|
|
2820
3291
|
}),
|
|
2821
3292
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -2825,7 +3296,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2825
3296
|
spaceKey: space.key,
|
|
2826
3297
|
identityKey: signingContext.identityKey,
|
|
2827
3298
|
deviceKey: signingContext.deviceKey,
|
|
2828
|
-
designation:
|
|
3299
|
+
designation: import_credentials12.AdmittedFeed.Designation.DATA
|
|
2829
3300
|
}
|
|
2830
3301
|
}),
|
|
2831
3302
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -2850,7 +3321,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
|
|
|
2850
3321
|
};
|
|
2851
3322
|
|
|
2852
3323
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
2853
|
-
function
|
|
3324
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
2854
3325
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2855
3326
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2856
3327
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2860,7 +3331,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
2860
3331
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2861
3332
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2862
3333
|
}
|
|
2863
|
-
var
|
|
3334
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
2864
3335
|
var DataSpaceManager = class DataSpaceManager2 {
|
|
2865
3336
|
constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
|
|
2866
3337
|
this._spaceManager = _spaceManager;
|
|
@@ -2869,7 +3340,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2869
3340
|
this._keyring = _keyring;
|
|
2870
3341
|
this._signingContext = _signingContext;
|
|
2871
3342
|
this._feedStore = _feedStore;
|
|
2872
|
-
this._ctx = new
|
|
3343
|
+
this._ctx = new import_context8.Context();
|
|
2873
3344
|
this.updated = new import_async12.Event();
|
|
2874
3345
|
this._spaces = new import_util5.ComplexMap(import_keys9.PublicKey.hash);
|
|
2875
3346
|
this._isOpen = false;
|
|
@@ -2880,50 +3351,50 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2880
3351
|
return this._spaces;
|
|
2881
3352
|
}
|
|
2882
3353
|
async open() {
|
|
2883
|
-
(0,
|
|
2884
|
-
F:
|
|
2885
|
-
L:
|
|
3354
|
+
(0, import_log11.log)("open", void 0, {
|
|
3355
|
+
F: __dxlog_file13,
|
|
3356
|
+
L: 79,
|
|
2886
3357
|
S: this,
|
|
2887
3358
|
C: (f, a) => f(...a)
|
|
2888
3359
|
});
|
|
2889
|
-
|
|
3360
|
+
import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols7.trace.begin({
|
|
2890
3361
|
id: this._instanceId
|
|
2891
3362
|
}), {
|
|
2892
|
-
F:
|
|
2893
|
-
L:
|
|
3363
|
+
F: __dxlog_file13,
|
|
3364
|
+
L: 80,
|
|
2894
3365
|
S: this,
|
|
2895
3366
|
C: (f, a) => f(...a)
|
|
2896
3367
|
});
|
|
2897
3368
|
await this._metadataStore.load();
|
|
2898
|
-
(0,
|
|
3369
|
+
(0, import_log11.log)("metadata loaded", {
|
|
2899
3370
|
spaces: this._metadataStore.spaces.length
|
|
2900
3371
|
}, {
|
|
2901
|
-
F:
|
|
2902
|
-
L:
|
|
3372
|
+
F: __dxlog_file13,
|
|
3373
|
+
L: 82,
|
|
2903
3374
|
S: this,
|
|
2904
3375
|
C: (f, a) => f(...a)
|
|
2905
3376
|
});
|
|
2906
3377
|
for (const spaceMetadata of this._metadataStore.spaces) {
|
|
2907
3378
|
try {
|
|
2908
|
-
(0,
|
|
3379
|
+
(0, import_log11.log)("load space", {
|
|
2909
3380
|
spaceMetadata
|
|
2910
3381
|
}, {
|
|
2911
|
-
F:
|
|
2912
|
-
L:
|
|
3382
|
+
F: __dxlog_file13,
|
|
3383
|
+
L: 86,
|
|
2913
3384
|
S: this,
|
|
2914
3385
|
C: (f, a) => f(...a)
|
|
2915
3386
|
});
|
|
2916
3387
|
const space = await this._constructSpace(spaceMetadata);
|
|
2917
|
-
if (spaceMetadata.state !==
|
|
3388
|
+
if (spaceMetadata.state !== import_services8.SpaceState.INACTIVE) {
|
|
2918
3389
|
space.initializeDataPipelineAsync();
|
|
2919
3390
|
}
|
|
2920
3391
|
} catch (err) {
|
|
2921
|
-
|
|
3392
|
+
import_log11.log.error("Error loading space", {
|
|
2922
3393
|
spaceMetadata,
|
|
2923
3394
|
err
|
|
2924
3395
|
}, {
|
|
2925
|
-
F:
|
|
2926
|
-
L:
|
|
3396
|
+
F: __dxlog_file13,
|
|
3397
|
+
L: 92,
|
|
2927
3398
|
S: this,
|
|
2928
3399
|
C: (f, a) => f(...a)
|
|
2929
3400
|
});
|
|
@@ -2931,19 +3402,19 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2931
3402
|
}
|
|
2932
3403
|
this._isOpen = true;
|
|
2933
3404
|
this.updated.emit();
|
|
2934
|
-
|
|
3405
|
+
import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols7.trace.end({
|
|
2935
3406
|
id: this._instanceId
|
|
2936
3407
|
}), {
|
|
2937
|
-
F:
|
|
2938
|
-
L:
|
|
3408
|
+
F: __dxlog_file13,
|
|
3409
|
+
L: 98,
|
|
2939
3410
|
S: this,
|
|
2940
3411
|
C: (f, a) => f(...a)
|
|
2941
3412
|
});
|
|
2942
3413
|
}
|
|
2943
3414
|
async close() {
|
|
2944
|
-
(0,
|
|
2945
|
-
F:
|
|
2946
|
-
L:
|
|
3415
|
+
(0, import_log11.log)("close", void 0, {
|
|
3416
|
+
F: __dxlog_file13,
|
|
3417
|
+
L: 103,
|
|
2947
3418
|
S: this,
|
|
2948
3419
|
C: (f, a) => f(...a)
|
|
2949
3420
|
});
|
|
@@ -2957,7 +3428,15 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2957
3428
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
2958
3429
|
*/
|
|
2959
3430
|
async createSpace() {
|
|
2960
|
-
(0,
|
|
3431
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3432
|
+
F: __dxlog_file13,
|
|
3433
|
+
L: 116,
|
|
3434
|
+
S: this,
|
|
3435
|
+
A: [
|
|
3436
|
+
"this._isOpen",
|
|
3437
|
+
"'Not open.'"
|
|
3438
|
+
]
|
|
3439
|
+
});
|
|
2961
3440
|
const spaceKey = await this._keyring.createKey();
|
|
2962
3441
|
const controlFeedKey = await this._keyring.createKey();
|
|
2963
3442
|
const dataFeedKey = await this._keyring.createKey();
|
|
@@ -2966,13 +3445,13 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2966
3445
|
genesisFeedKey: controlFeedKey,
|
|
2967
3446
|
controlFeedKey,
|
|
2968
3447
|
dataFeedKey,
|
|
2969
|
-
state:
|
|
3448
|
+
state: import_services8.SpaceState.ACTIVE
|
|
2970
3449
|
};
|
|
2971
|
-
(0,
|
|
3450
|
+
(0, import_log11.log)("creating space...", {
|
|
2972
3451
|
spaceKey
|
|
2973
3452
|
}, {
|
|
2974
|
-
F:
|
|
2975
|
-
L:
|
|
3453
|
+
F: __dxlog_file13,
|
|
3454
|
+
L: 128,
|
|
2976
3455
|
S: this,
|
|
2977
3456
|
C: (f, a) => f(...a)
|
|
2978
3457
|
});
|
|
@@ -2980,7 +3459,15 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2980
3459
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
|
|
2981
3460
|
await this._metadataStore.addSpace(metadata);
|
|
2982
3461
|
const memberCredential = credentials[1];
|
|
2983
|
-
(0,
|
|
3462
|
+
(0, import_invariant11.invariant)((0, import_credentials13.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3463
|
+
F: __dxlog_file13,
|
|
3464
|
+
L: 135,
|
|
3465
|
+
S: this,
|
|
3466
|
+
A: [
|
|
3467
|
+
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
3468
|
+
""
|
|
3469
|
+
]
|
|
3470
|
+
});
|
|
2984
3471
|
await this._signingContext.recordCredential(memberCredential);
|
|
2985
3472
|
await space.initializeDataPipeline();
|
|
2986
3473
|
this.updated.emit();
|
|
@@ -2988,16 +3475,32 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
2988
3475
|
}
|
|
2989
3476
|
// TODO(burdon): Rename join space.
|
|
2990
3477
|
async acceptSpace(opts) {
|
|
2991
|
-
(0,
|
|
3478
|
+
(0, import_log11.log)("accept space", {
|
|
2992
3479
|
opts
|
|
2993
3480
|
}, {
|
|
2994
|
-
F:
|
|
2995
|
-
L:
|
|
3481
|
+
F: __dxlog_file13,
|
|
3482
|
+
L: 147,
|
|
2996
3483
|
S: this,
|
|
2997
3484
|
C: (f, a) => f(...a)
|
|
2998
3485
|
});
|
|
2999
|
-
(0,
|
|
3000
|
-
|
|
3486
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3487
|
+
F: __dxlog_file13,
|
|
3488
|
+
L: 148,
|
|
3489
|
+
S: this,
|
|
3490
|
+
A: [
|
|
3491
|
+
"this._isOpen",
|
|
3492
|
+
"'Not open.'"
|
|
3493
|
+
]
|
|
3494
|
+
});
|
|
3495
|
+
(0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
3496
|
+
F: __dxlog_file13,
|
|
3497
|
+
L: 149,
|
|
3498
|
+
S: this,
|
|
3499
|
+
A: [
|
|
3500
|
+
"!this._spaces.has(opts.spaceKey)",
|
|
3501
|
+
"'Space already exists.'"
|
|
3502
|
+
]
|
|
3503
|
+
});
|
|
3001
3504
|
const metadata = {
|
|
3002
3505
|
key: opts.spaceKey,
|
|
3003
3506
|
genesisFeedKey: opts.genesisFeedKey,
|
|
@@ -3016,17 +3519,17 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3016
3519
|
* TODO(dmaretskyi): Consider removing.
|
|
3017
3520
|
*/
|
|
3018
3521
|
async waitUntilSpaceReady(spaceKey) {
|
|
3019
|
-
await (0,
|
|
3522
|
+
await (0, import_context8.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
3020
3523
|
const space = this._spaces.get(spaceKey);
|
|
3021
|
-
return !!space && space.state ===
|
|
3524
|
+
return !!space && space.state === import_services8.SpaceState.READY;
|
|
3022
3525
|
}));
|
|
3023
3526
|
}
|
|
3024
3527
|
async _constructSpace(metadata) {
|
|
3025
|
-
(0,
|
|
3528
|
+
(0, import_log11.log)("construct space", {
|
|
3026
3529
|
metadata
|
|
3027
3530
|
}, {
|
|
3028
|
-
F:
|
|
3029
|
-
L:
|
|
3531
|
+
F: __dxlog_file13,
|
|
3532
|
+
L: 182,
|
|
3030
3533
|
S: this,
|
|
3031
3534
|
C: (f, a) => f(...a)
|
|
3032
3535
|
});
|
|
@@ -3034,7 +3537,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3034
3537
|
localPeerId: this._signingContext.deviceKey
|
|
3035
3538
|
});
|
|
3036
3539
|
const presence = new import_teleport_extension_gossip.Presence({
|
|
3037
|
-
announceInterval:
|
|
3540
|
+
announceInterval: 1e3,
|
|
3038
3541
|
offlineTimeout: 5e3,
|
|
3039
3542
|
identityKey: this._signingContext.identityKey,
|
|
3040
3543
|
gossip
|
|
@@ -3060,9 +3563,9 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3060
3563
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
3061
3564
|
},
|
|
3062
3565
|
onAuthFailure: () => {
|
|
3063
|
-
|
|
3064
|
-
F:
|
|
3065
|
-
L:
|
|
3566
|
+
import_log11.log.warn("auth failure", void 0, {
|
|
3567
|
+
F: __dxlog_file13,
|
|
3568
|
+
L: 213,
|
|
3066
3569
|
S: this,
|
|
3067
3570
|
C: (f, a) => f(...a)
|
|
3068
3571
|
});
|
|
@@ -3073,7 +3576,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3073
3576
|
dataFeed && space.setDataFeed(dataFeed);
|
|
3074
3577
|
const dataSpace = new DataSpace({
|
|
3075
3578
|
inner: space,
|
|
3076
|
-
initialState: metadata.state ===
|
|
3579
|
+
initialState: metadata.state === import_services8.SpaceState.INACTIVE ? import_services8.SpaceState.INACTIVE : import_services8.SpaceState.CLOSED,
|
|
3077
3580
|
metadataStore: this._metadataStore,
|
|
3078
3581
|
gossip,
|
|
3079
3582
|
presence,
|
|
@@ -3082,23 +3585,23 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3082
3585
|
signingContext: this._signingContext,
|
|
3083
3586
|
callbacks: {
|
|
3084
3587
|
beforeReady: async () => {
|
|
3085
|
-
(0,
|
|
3588
|
+
(0, import_log11.log)("before space ready", {
|
|
3086
3589
|
space: space.key
|
|
3087
3590
|
}, {
|
|
3088
|
-
F:
|
|
3089
|
-
L:
|
|
3591
|
+
F: __dxlog_file13,
|
|
3592
|
+
L: 231,
|
|
3090
3593
|
S: this,
|
|
3091
3594
|
C: (f, a) => f(...a)
|
|
3092
3595
|
});
|
|
3093
3596
|
await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
|
|
3094
3597
|
},
|
|
3095
3598
|
afterReady: async () => {
|
|
3096
|
-
(0,
|
|
3599
|
+
(0, import_log11.log)("after space ready", {
|
|
3097
3600
|
space: space.key,
|
|
3098
3601
|
open: this._isOpen
|
|
3099
3602
|
}, {
|
|
3100
|
-
F:
|
|
3101
|
-
L:
|
|
3603
|
+
F: __dxlog_file13,
|
|
3604
|
+
L: 238,
|
|
3102
3605
|
S: this,
|
|
3103
3606
|
C: (f, a) => f(...a)
|
|
3104
3607
|
});
|
|
@@ -3107,11 +3610,11 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3107
3610
|
}
|
|
3108
3611
|
},
|
|
3109
3612
|
beforeClose: async () => {
|
|
3110
|
-
(0,
|
|
3613
|
+
(0, import_log11.log)("before space close", {
|
|
3111
3614
|
space: space.key
|
|
3112
3615
|
}, {
|
|
3113
|
-
F:
|
|
3114
|
-
L:
|
|
3616
|
+
F: __dxlog_file13,
|
|
3617
|
+
L: 244,
|
|
3115
3618
|
S: this,
|
|
3116
3619
|
C: (f, a) => f(...a)
|
|
3117
3620
|
});
|
|
@@ -3120,7 +3623,7 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3120
3623
|
},
|
|
3121
3624
|
cache: metadata.cache
|
|
3122
3625
|
});
|
|
3123
|
-
if (metadata.state !==
|
|
3626
|
+
if (metadata.state !== import_services8.SpaceState.INACTIVE) {
|
|
3124
3627
|
await dataSpace.open();
|
|
3125
3628
|
}
|
|
3126
3629
|
if (metadata.controlTimeframe) {
|
|
@@ -3133,33 +3636,33 @@ var DataSpaceManager = class DataSpaceManager2 {
|
|
|
3133
3636
|
return dataSpace;
|
|
3134
3637
|
}
|
|
3135
3638
|
};
|
|
3136
|
-
|
|
3639
|
+
_ts_decorate4([
|
|
3137
3640
|
import_async12.synchronized
|
|
3138
3641
|
], DataSpaceManager.prototype, "open", null);
|
|
3139
|
-
|
|
3642
|
+
_ts_decorate4([
|
|
3140
3643
|
import_async12.synchronized
|
|
3141
3644
|
], DataSpaceManager.prototype, "close", null);
|
|
3142
|
-
|
|
3645
|
+
_ts_decorate4([
|
|
3143
3646
|
import_async12.synchronized
|
|
3144
3647
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
3145
|
-
|
|
3648
|
+
_ts_decorate4([
|
|
3146
3649
|
import_async12.synchronized
|
|
3147
3650
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
3148
|
-
DataSpaceManager =
|
|
3651
|
+
DataSpaceManager = _ts_decorate4([
|
|
3149
3652
|
(0, import_async12.trackLeaks)("open", "close")
|
|
3150
3653
|
], DataSpaceManager);
|
|
3151
3654
|
|
|
3152
3655
|
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
3153
3656
|
var import_async13 = require("@dxos/async");
|
|
3154
|
-
var
|
|
3657
|
+
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
3155
3658
|
var import_debug6 = require("@dxos/debug");
|
|
3156
3659
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
3157
3660
|
var import_errors4 = require("@dxos/errors");
|
|
3158
|
-
var
|
|
3159
|
-
var
|
|
3160
|
-
var
|
|
3661
|
+
var import_log12 = require("@dxos/log");
|
|
3662
|
+
var import_protocols8 = require("@dxos/protocols");
|
|
3663
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3161
3664
|
var import_util6 = require("@dxos/util");
|
|
3162
|
-
var
|
|
3665
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
3163
3666
|
var SpacesServiceImpl = class {
|
|
3164
3667
|
constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
|
|
3165
3668
|
this._identityManager = _identityManager;
|
|
@@ -3181,10 +3684,10 @@ var SpacesServiceImpl = class {
|
|
|
3181
3684
|
const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3182
3685
|
if (state) {
|
|
3183
3686
|
switch (state) {
|
|
3184
|
-
case
|
|
3687
|
+
case import_services9.SpaceState.ACTIVE:
|
|
3185
3688
|
await space.activate();
|
|
3186
3689
|
break;
|
|
3187
|
-
case
|
|
3690
|
+
case import_services9.SpaceState.INACTIVE:
|
|
3188
3691
|
await space.deactivate();
|
|
3189
3692
|
break;
|
|
3190
3693
|
default:
|
|
@@ -3193,14 +3696,14 @@ var SpacesServiceImpl = class {
|
|
|
3193
3696
|
}
|
|
3194
3697
|
}
|
|
3195
3698
|
querySpaces() {
|
|
3196
|
-
return new
|
|
3699
|
+
return new import_codec_protobuf11.Stream(({ next, ctx }) => {
|
|
3197
3700
|
const scheduler = new import_async13.UpdateScheduler(ctx, async () => {
|
|
3198
3701
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3199
3702
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
3200
|
-
(0,
|
|
3703
|
+
(0, import_log12.log)("update", {
|
|
3201
3704
|
spaces
|
|
3202
3705
|
}, {
|
|
3203
|
-
F:
|
|
3706
|
+
F: __dxlog_file14,
|
|
3204
3707
|
L: 78,
|
|
3205
3708
|
S: this,
|
|
3206
3709
|
C: (f, a) => f(...a)
|
|
@@ -3248,7 +3751,7 @@ var SpacesServiceImpl = class {
|
|
|
3248
3751
|
await space.postMessage(getChannelId(channel), message);
|
|
3249
3752
|
}
|
|
3250
3753
|
subscribeMessages({ spaceKey, channel }) {
|
|
3251
|
-
return new
|
|
3754
|
+
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
3252
3755
|
(0, import_async13.scheduleTask)(ctx, async () => {
|
|
3253
3756
|
var _a;
|
|
3254
3757
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
@@ -3261,7 +3764,7 @@ var SpacesServiceImpl = class {
|
|
|
3261
3764
|
});
|
|
3262
3765
|
}
|
|
3263
3766
|
queryCredentials({ spaceKey }) {
|
|
3264
|
-
return new
|
|
3767
|
+
return new import_codec_protobuf11.Stream(({ ctx, next }) => {
|
|
3265
3768
|
var _a;
|
|
3266
3769
|
const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
|
|
3267
3770
|
const processor = {
|
|
@@ -3295,7 +3798,7 @@ var SpacesServiceImpl = class {
|
|
|
3295
3798
|
return {
|
|
3296
3799
|
spaceKey: space.key,
|
|
3297
3800
|
state: space.state,
|
|
3298
|
-
error: space.error ? (0,
|
|
3801
|
+
error: space.error ? (0, import_protocols8.encodeError)(space.error) : void 0,
|
|
3299
3802
|
pipeline: {
|
|
3300
3803
|
currentEpoch: space.dataPipeline.currentEpoch,
|
|
3301
3804
|
appliedEpoch: space.dataPipeline.appliedEpoch,
|
|
@@ -3311,14 +3814,20 @@ var SpacesServiceImpl = class {
|
|
|
3311
3814
|
},
|
|
3312
3815
|
members: Array.from(space.inner.spaceState.members.values()).map((member) => {
|
|
3313
3816
|
var _a2, _b2, _c2;
|
|
3817
|
+
const peers = space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key));
|
|
3818
|
+
const isMe = (_a2 = this._identityManager.identity) == null ? void 0 : _a2.identityKey.equals(member.key);
|
|
3819
|
+
if (isMe) {
|
|
3820
|
+
peers.push(space.presence.getLocalState());
|
|
3821
|
+
}
|
|
3314
3822
|
return {
|
|
3315
3823
|
identity: {
|
|
3316
3824
|
identityKey: member.key,
|
|
3317
3825
|
profile: {
|
|
3318
|
-
displayName: (
|
|
3826
|
+
displayName: (_c2 = (_b2 = member.assertion.profile) == null ? void 0 : _b2.displayName) != null ? _c2 : (0, import_util6.humanize)(member.key)
|
|
3319
3827
|
}
|
|
3320
3828
|
},
|
|
3321
|
-
presence:
|
|
3829
|
+
presence: isMe || peers.length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE,
|
|
3830
|
+
peerStates: peers
|
|
3322
3831
|
};
|
|
3323
3832
|
}),
|
|
3324
3833
|
creator: (_g = space.inner.spaceState.creator) == null ? void 0 : _g.key,
|
|
@@ -3330,8 +3839,18 @@ var SpacesServiceImpl = class {
|
|
|
3330
3839
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
3331
3840
|
|
|
3332
3841
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
3333
|
-
|
|
3334
|
-
var
|
|
3842
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
3843
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3844
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3845
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
3846
|
+
else
|
|
3847
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
3848
|
+
if (d = decorators[i])
|
|
3849
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3850
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3851
|
+
}
|
|
3852
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
3853
|
+
var ServiceContext = class ServiceContext2 {
|
|
3335
3854
|
// prettier-ignore
|
|
3336
3855
|
constructor(storage, networkManager, signalManager, modelFactory) {
|
|
3337
3856
|
this.storage = storage;
|
|
@@ -3365,54 +3884,54 @@ var ServiceContext = class {
|
|
|
3365
3884
|
});
|
|
3366
3885
|
this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
|
|
3367
3886
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
3368
|
-
this._handlerFactories.set(
|
|
3887
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
|
|
3369
3888
|
var _a;
|
|
3370
3889
|
return (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
|
|
3371
3890
|
}, this._acceptIdentity.bind(this)));
|
|
3372
3891
|
}
|
|
3373
|
-
async open() {
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
L: 126,
|
|
3892
|
+
async open(ctx) {
|
|
3893
|
+
await this._checkStorageVersion();
|
|
3894
|
+
(0, import_log13.log)("opening...", void 0, {
|
|
3895
|
+
F: __dxlog_file15,
|
|
3896
|
+
L: 131,
|
|
3379
3897
|
S: this,
|
|
3380
3898
|
C: (f, a) => f(...a)
|
|
3381
3899
|
});
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3900
|
+
import_log13.log.trace("dxos.sdk.service-context.open", import_protocols9.trace.begin({
|
|
3901
|
+
id: this._instanceId
|
|
3902
|
+
}), {
|
|
3903
|
+
F: __dxlog_file15,
|
|
3904
|
+
L: 132,
|
|
3386
3905
|
S: this,
|
|
3387
3906
|
C: (f, a) => f(...a)
|
|
3388
3907
|
});
|
|
3389
3908
|
await this.signalManager.open();
|
|
3390
3909
|
await this.networkManager.open();
|
|
3391
3910
|
await this.spaceManager.open();
|
|
3392
|
-
await this.identityManager.open();
|
|
3911
|
+
await this.identityManager.open(ctx);
|
|
3393
3912
|
if (this.identityManager.identity) {
|
|
3394
|
-
await this._initialize();
|
|
3913
|
+
await this._initialize(ctx);
|
|
3395
3914
|
}
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3915
|
+
import_log13.log.trace("dxos.sdk.service-context.open", import_protocols9.trace.end({
|
|
3916
|
+
id: this._instanceId
|
|
3917
|
+
}), {
|
|
3918
|
+
F: __dxlog_file15,
|
|
3919
|
+
L: 140,
|
|
3399
3920
|
S: this,
|
|
3400
3921
|
C: (f, a) => f(...a)
|
|
3401
3922
|
});
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
F: __dxlog_file12,
|
|
3406
|
-
L: 139,
|
|
3923
|
+
(0, import_log13.log)("opened", void 0, {
|
|
3924
|
+
F: __dxlog_file15,
|
|
3925
|
+
L: 141,
|
|
3407
3926
|
S: this,
|
|
3408
3927
|
C: (f, a) => f(...a)
|
|
3409
3928
|
});
|
|
3410
3929
|
}
|
|
3411
3930
|
async close() {
|
|
3412
3931
|
var _a;
|
|
3413
|
-
(0,
|
|
3414
|
-
F:
|
|
3415
|
-
L:
|
|
3932
|
+
(0, import_log13.log)("closing...", void 0, {
|
|
3933
|
+
F: __dxlog_file15,
|
|
3934
|
+
L: 145,
|
|
3416
3935
|
S: this,
|
|
3417
3936
|
C: (f, a) => f(...a)
|
|
3418
3937
|
});
|
|
@@ -3426,40 +3945,48 @@ var ServiceContext = class {
|
|
|
3426
3945
|
await this.networkManager.close();
|
|
3427
3946
|
await this.signalManager.close();
|
|
3428
3947
|
this.dataServiceSubscriptions.clear();
|
|
3429
|
-
(0,
|
|
3430
|
-
F:
|
|
3431
|
-
L:
|
|
3948
|
+
(0, import_log13.log)("closed", void 0, {
|
|
3949
|
+
F: __dxlog_file15,
|
|
3950
|
+
L: 156,
|
|
3432
3951
|
S: this,
|
|
3433
3952
|
C: (f, a) => f(...a)
|
|
3434
3953
|
});
|
|
3435
3954
|
}
|
|
3436
3955
|
async createIdentity(params = {}) {
|
|
3437
3956
|
const identity = await this.identityManager.createIdentity(params);
|
|
3438
|
-
await this._initialize();
|
|
3957
|
+
await this._initialize(new import_context9.Context());
|
|
3439
3958
|
return identity;
|
|
3440
3959
|
}
|
|
3441
3960
|
getInvitationHandler(invitation) {
|
|
3442
3961
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
3443
|
-
(0,
|
|
3962
|
+
(0, import_invariant12.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
3963
|
+
F: __dxlog_file15,
|
|
3964
|
+
L: 168,
|
|
3965
|
+
S: this,
|
|
3966
|
+
A: [
|
|
3967
|
+
"factory",
|
|
3968
|
+
"`Unknown invitation kind: ${invitation.kind}`"
|
|
3969
|
+
]
|
|
3970
|
+
});
|
|
3444
3971
|
return factory(invitation);
|
|
3445
3972
|
}
|
|
3446
3973
|
async _acceptIdentity(params) {
|
|
3447
3974
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
3448
|
-
await this._initialize();
|
|
3975
|
+
await this._initialize(new import_context9.Context());
|
|
3449
3976
|
return identity;
|
|
3450
3977
|
}
|
|
3451
3978
|
async _checkStorageVersion() {
|
|
3452
3979
|
await this.metadataStore.load();
|
|
3453
|
-
if (this.metadataStore.version !==
|
|
3454
|
-
throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${
|
|
3980
|
+
if (this.metadataStore.version !== import_protocols9.STORAGE_VERSION) {
|
|
3981
|
+
throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${import_protocols9.STORAGE_VERSION}`);
|
|
3455
3982
|
}
|
|
3456
3983
|
}
|
|
3457
3984
|
// Called when identity is created.
|
|
3458
|
-
async _initialize() {
|
|
3985
|
+
async _initialize(ctx) {
|
|
3459
3986
|
var _a;
|
|
3460
|
-
(0,
|
|
3461
|
-
F:
|
|
3462
|
-
L:
|
|
3987
|
+
(0, import_log13.log)("initializing spaces...", void 0, {
|
|
3988
|
+
F: __dxlog_file15,
|
|
3989
|
+
L: 190,
|
|
3463
3990
|
S: this,
|
|
3464
3991
|
C: (f, a) => f(...a)
|
|
3465
3992
|
});
|
|
@@ -3479,14 +4006,22 @@ var ServiceContext = class {
|
|
|
3479
4006
|
};
|
|
3480
4007
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
|
|
3481
4008
|
await this.dataSpaceManager.open();
|
|
3482
|
-
this._handlerFactories.set(
|
|
3483
|
-
(0,
|
|
4009
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
|
|
4010
|
+
(0, import_invariant12.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4011
|
+
F: __dxlog_file15,
|
|
4012
|
+
L: 213,
|
|
4013
|
+
S: this,
|
|
4014
|
+
A: [
|
|
4015
|
+
"this.dataSpaceManager",
|
|
4016
|
+
"'dataSpaceManager not initialized yet'"
|
|
4017
|
+
]
|
|
4018
|
+
});
|
|
3484
4019
|
return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
|
|
3485
4020
|
});
|
|
3486
4021
|
this.initialized.wake();
|
|
3487
4022
|
this._deviceSpaceSync = {
|
|
3488
4023
|
processCredential: async (credential) => {
|
|
3489
|
-
const assertion = (0,
|
|
4024
|
+
const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
|
|
3490
4025
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
3491
4026
|
return;
|
|
3492
4027
|
}
|
|
@@ -3494,33 +4029,33 @@ var ServiceContext = class {
|
|
|
3494
4029
|
return;
|
|
3495
4030
|
}
|
|
3496
4031
|
if (!this.dataSpaceManager) {
|
|
3497
|
-
(0,
|
|
4032
|
+
(0, import_log13.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
3498
4033
|
details: assertion
|
|
3499
4034
|
}, {
|
|
3500
|
-
F:
|
|
3501
|
-
L:
|
|
4035
|
+
F: __dxlog_file15,
|
|
4036
|
+
L: 229,
|
|
3502
4037
|
S: this,
|
|
3503
4038
|
C: (f, a) => f(...a)
|
|
3504
4039
|
});
|
|
3505
4040
|
return;
|
|
3506
4041
|
}
|
|
3507
4042
|
if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
|
|
3508
|
-
(0,
|
|
4043
|
+
(0, import_log13.log)("space already exists, ignoring space admission", {
|
|
3509
4044
|
details: assertion
|
|
3510
4045
|
}, {
|
|
3511
|
-
F:
|
|
3512
|
-
L:
|
|
4046
|
+
F: __dxlog_file15,
|
|
4047
|
+
L: 233,
|
|
3513
4048
|
S: this,
|
|
3514
4049
|
C: (f, a) => f(...a)
|
|
3515
4050
|
});
|
|
3516
4051
|
return;
|
|
3517
4052
|
}
|
|
3518
4053
|
try {
|
|
3519
|
-
(0,
|
|
4054
|
+
(0, import_log13.log)("accepting space recorded in halo", {
|
|
3520
4055
|
details: assertion
|
|
3521
4056
|
}, {
|
|
3522
|
-
F:
|
|
3523
|
-
L:
|
|
4057
|
+
F: __dxlog_file15,
|
|
4058
|
+
L: 238,
|
|
3524
4059
|
S: this,
|
|
3525
4060
|
C: (f, a) => f(...a)
|
|
3526
4061
|
});
|
|
@@ -3529,9 +4064,9 @@ var ServiceContext = class {
|
|
|
3529
4064
|
genesisFeedKey: assertion.genesisFeedKey
|
|
3530
4065
|
});
|
|
3531
4066
|
} catch (err) {
|
|
3532
|
-
|
|
3533
|
-
F:
|
|
3534
|
-
L:
|
|
4067
|
+
import_log13.log.catch(err, void 0, {
|
|
4068
|
+
F: __dxlog_file15,
|
|
4069
|
+
L: 244,
|
|
3535
4070
|
S: this,
|
|
3536
4071
|
C: (f, a) => f(...a)
|
|
3537
4072
|
});
|
|
@@ -3541,26 +4076,37 @@ var ServiceContext = class {
|
|
|
3541
4076
|
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
3542
4077
|
}
|
|
3543
4078
|
};
|
|
4079
|
+
_ts_decorate5([
|
|
4080
|
+
import_tracing3.trace.span()
|
|
4081
|
+
], ServiceContext.prototype, "open", null);
|
|
4082
|
+
_ts_decorate5([
|
|
4083
|
+
import_tracing3.trace.span()
|
|
4084
|
+
], ServiceContext.prototype, "_initialize", null);
|
|
4085
|
+
ServiceContext = _ts_decorate5([
|
|
4086
|
+
import_tracing3.trace.resource()
|
|
4087
|
+
], ServiceContext);
|
|
3544
4088
|
|
|
3545
4089
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3546
|
-
var import_tiny_invariant13 = __toESM(require("tiny-invariant"));
|
|
3547
4090
|
var import_async17 = require("@dxos/async");
|
|
3548
4091
|
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
3549
|
-
var
|
|
4092
|
+
var import_context10 = require("@dxos/context");
|
|
4093
|
+
var import_document_model2 = require("@dxos/document-model");
|
|
3550
4094
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
4095
|
+
var import_invariant14 = require("@dxos/invariant");
|
|
3551
4096
|
var import_keys11 = require("@dxos/keys");
|
|
3552
|
-
var
|
|
4097
|
+
var import_log16 = require("@dxos/log");
|
|
3553
4098
|
var import_messaging = require("@dxos/messaging");
|
|
3554
4099
|
var import_model_factory = require("@dxos/model-factory");
|
|
3555
4100
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
3556
|
-
var
|
|
3557
|
-
var
|
|
4101
|
+
var import_protocols10 = require("@dxos/protocols");
|
|
4102
|
+
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3558
4103
|
var import_text_model = require("@dxos/text-model");
|
|
4104
|
+
var import_tracing4 = require("@dxos/tracing");
|
|
3559
4105
|
|
|
3560
4106
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
3561
4107
|
var import_async15 = require("@dxos/async");
|
|
3562
|
-
var
|
|
3563
|
-
var
|
|
4108
|
+
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
4109
|
+
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3564
4110
|
var DevicesServiceImpl = class {
|
|
3565
4111
|
constructor(_identityManager) {
|
|
3566
4112
|
this._identityManager = _identityManager;
|
|
@@ -3569,7 +4115,7 @@ var DevicesServiceImpl = class {
|
|
|
3569
4115
|
throw new Error("Method not implemented.");
|
|
3570
4116
|
}
|
|
3571
4117
|
queryDevices() {
|
|
3572
|
-
return new
|
|
4118
|
+
return new import_codec_protobuf12.Stream(({ next }) => {
|
|
3573
4119
|
const update = () => {
|
|
3574
4120
|
var _a;
|
|
3575
4121
|
const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
|
|
@@ -3583,7 +4129,7 @@ var DevicesServiceImpl = class {
|
|
|
3583
4129
|
var _a2;
|
|
3584
4130
|
return {
|
|
3585
4131
|
deviceKey: key,
|
|
3586
|
-
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ?
|
|
4132
|
+
kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services11.DeviceKind.CURRENT : import_services11.DeviceKind.TRUSTED
|
|
3587
4133
|
};
|
|
3588
4134
|
})
|
|
3589
4135
|
});
|
|
@@ -3605,10 +4151,10 @@ var DevicesServiceImpl = class {
|
|
|
3605
4151
|
};
|
|
3606
4152
|
|
|
3607
4153
|
// packages/sdk/client-services/src/packlets/locks/node.ts
|
|
3608
|
-
var
|
|
4154
|
+
var import_invariant13 = require("@dxos/invariant");
|
|
3609
4155
|
var import_lock_file = require("@dxos/lock-file");
|
|
3610
|
-
var
|
|
3611
|
-
function
|
|
4156
|
+
var import_log14 = require("@dxos/log");
|
|
4157
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
3612
4158
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3613
4159
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3614
4160
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3618,7 +4164,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
3618
4164
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3619
4165
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3620
4166
|
}
|
|
3621
|
-
var
|
|
4167
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
3622
4168
|
var Lock = class {
|
|
3623
4169
|
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
3624
4170
|
this._lockPath = lockPath;
|
|
@@ -3630,16 +4176,16 @@ var Lock = class {
|
|
|
3630
4176
|
}
|
|
3631
4177
|
async acquire() {
|
|
3632
4178
|
var _a;
|
|
3633
|
-
(0,
|
|
3634
|
-
F:
|
|
4179
|
+
(0, import_log14.log)("acquiring lock...", void 0, {
|
|
4180
|
+
F: __dxlog_file16,
|
|
3635
4181
|
L: 32,
|
|
3636
4182
|
S: this,
|
|
3637
4183
|
C: (f, a) => f(...a)
|
|
3638
4184
|
});
|
|
3639
4185
|
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
3640
4186
|
await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
|
|
3641
|
-
(0,
|
|
3642
|
-
F:
|
|
4187
|
+
(0, import_log14.log)("acquired lock", void 0, {
|
|
4188
|
+
F: __dxlog_file16,
|
|
3643
4189
|
L: 37,
|
|
3644
4190
|
S: this,
|
|
3645
4191
|
C: (f, a) => f(...a)
|
|
@@ -3648,34 +4194,43 @@ var Lock = class {
|
|
|
3648
4194
|
async release() {
|
|
3649
4195
|
var _a;
|
|
3650
4196
|
await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
|
|
3651
|
-
(0,
|
|
4197
|
+
(0, import_invariant13.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
4198
|
+
F: __dxlog_file16,
|
|
4199
|
+
L: 42,
|
|
4200
|
+
S: this,
|
|
4201
|
+
A: [
|
|
4202
|
+
"this._fileHandle",
|
|
4203
|
+
"'Lock is not acquired'"
|
|
4204
|
+
]
|
|
4205
|
+
});
|
|
3652
4206
|
await import_lock_file.LockFile.release(this._fileHandle);
|
|
3653
4207
|
}
|
|
3654
4208
|
};
|
|
3655
|
-
|
|
3656
|
-
|
|
4209
|
+
_ts_decorate6([
|
|
4210
|
+
import_log14.logInfo
|
|
3657
4211
|
], Lock.prototype, "lockKey", null);
|
|
3658
4212
|
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
3659
4213
|
|
|
3660
4214
|
// packages/sdk/client-services/src/packlets/logging/logging-service.ts
|
|
3661
4215
|
var import_async16 = require("@dxos/async");
|
|
3662
|
-
var
|
|
3663
|
-
var
|
|
3664
|
-
var
|
|
4216
|
+
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
4217
|
+
var import_log15 = require("@dxos/log");
|
|
4218
|
+
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
3665
4219
|
var import_util7 = require("@dxos/util");
|
|
3666
4220
|
var LoggingServiceImpl = class {
|
|
3667
4221
|
constructor() {
|
|
3668
4222
|
this._logs = new import_async16.Event();
|
|
4223
|
+
this._started = new Date();
|
|
3669
4224
|
this._logProcessor = (_config, entry2) => {
|
|
3670
4225
|
this._logs.emit(entry2);
|
|
3671
4226
|
};
|
|
3672
4227
|
}
|
|
3673
4228
|
async open() {
|
|
3674
|
-
|
|
4229
|
+
import_log15.log.runtimeConfig.processors.push(this._logProcessor);
|
|
3675
4230
|
}
|
|
3676
4231
|
async close() {
|
|
3677
|
-
const index =
|
|
3678
|
-
|
|
4232
|
+
const index = import_log15.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
|
|
4233
|
+
import_log15.log.runtimeConfig.processors.splice(index, 1);
|
|
3679
4234
|
}
|
|
3680
4235
|
async controlMetrics({ reset, record }) {
|
|
3681
4236
|
if (reset) {
|
|
@@ -3690,35 +4245,41 @@ var LoggingServiceImpl = class {
|
|
|
3690
4245
|
recording: import_util7.tracer.recording
|
|
3691
4246
|
};
|
|
3692
4247
|
}
|
|
3693
|
-
|
|
3694
|
-
|
|
4248
|
+
/**
|
|
4249
|
+
* @deprecated (Move to diagnostics).
|
|
4250
|
+
*/
|
|
4251
|
+
queryMetrics({ interval = 5e3 }) {
|
|
4252
|
+
const getNumericalValues = (key) => {
|
|
3695
4253
|
var _a;
|
|
3696
|
-
const
|
|
4254
|
+
const events = (_a = import_util7.tracer.get(key)) != null ? _a : [];
|
|
3697
4255
|
return {
|
|
3698
4256
|
key,
|
|
3699
|
-
stats: (0, import_util7.numericalValues)(
|
|
4257
|
+
stats: (0, import_util7.numericalValues)(events, "duration")
|
|
3700
4258
|
};
|
|
3701
4259
|
};
|
|
3702
|
-
return new
|
|
4260
|
+
return new import_codec_protobuf13.Stream(({ next }) => {
|
|
3703
4261
|
const update = () => {
|
|
3704
4262
|
const metrics = {
|
|
3705
4263
|
timestamp: new Date(),
|
|
3706
4264
|
values: [
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
]
|
|
4265
|
+
getNumericalValues("dxos.echo.pipeline.control"),
|
|
4266
|
+
getNumericalValues("dxos.echo.pipeline.data")
|
|
4267
|
+
].filter(Boolean)
|
|
3710
4268
|
};
|
|
3711
|
-
next(
|
|
4269
|
+
next({
|
|
4270
|
+
timestamp: new Date(),
|
|
4271
|
+
metrics
|
|
4272
|
+
});
|
|
3712
4273
|
};
|
|
3713
4274
|
update();
|
|
3714
|
-
const i = setInterval(update, interval);
|
|
4275
|
+
const i = setInterval(update, Math.max(interval, 1e3));
|
|
3715
4276
|
return () => {
|
|
3716
4277
|
clearInterval(i);
|
|
3717
4278
|
};
|
|
3718
4279
|
});
|
|
3719
4280
|
}
|
|
3720
4281
|
queryLogs(request) {
|
|
3721
|
-
return new
|
|
4282
|
+
return new import_codec_protobuf13.Stream(({ ctx, next }) => {
|
|
3722
4283
|
const handler = (entry2) => {
|
|
3723
4284
|
var _a, _b, _c, _d, _e;
|
|
3724
4285
|
if (LOG_PROCESSING > 0) {
|
|
@@ -3732,7 +4293,7 @@ var LoggingServiceImpl = class {
|
|
|
3732
4293
|
}
|
|
3733
4294
|
const record = {
|
|
3734
4295
|
...entry2,
|
|
3735
|
-
context: (0, import_util7.jsonify)((0,
|
|
4296
|
+
context: (0, import_util7.jsonify)((0, import_log15.getContextFromEntry)(entry2)),
|
|
3736
4297
|
timestamp: new Date(),
|
|
3737
4298
|
meta: {
|
|
3738
4299
|
// TODO(dmaretskyi): Fix proto.
|
|
@@ -3753,17 +4314,17 @@ var LoggingServiceImpl = class {
|
|
|
3753
4314
|
};
|
|
3754
4315
|
var matchFilter = (filter, level, path, options) => {
|
|
3755
4316
|
switch (options) {
|
|
3756
|
-
case
|
|
4317
|
+
case import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
3757
4318
|
return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
|
|
3758
|
-
case
|
|
4319
|
+
case import_services12.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
3759
4320
|
return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
|
|
3760
4321
|
}
|
|
3761
4322
|
};
|
|
3762
4323
|
var shouldLog = (entry2, request) => {
|
|
3763
4324
|
var _a;
|
|
3764
|
-
const options = (_a = request.options) != null ? _a :
|
|
4325
|
+
const options = (_a = request.options) != null ? _a : import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
3765
4326
|
if (request.filters === void 0) {
|
|
3766
|
-
return options ===
|
|
4327
|
+
return options === import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
3767
4328
|
} else {
|
|
3768
4329
|
return request.filters.some((filter) => {
|
|
3769
4330
|
var _a2, _b;
|
|
@@ -3774,14 +4335,14 @@ var shouldLog = (entry2, request) => {
|
|
|
3774
4335
|
var LOG_PROCESSING = 0;
|
|
3775
4336
|
|
|
3776
4337
|
// packages/sdk/client-services/src/packlets/network/network-service.ts
|
|
3777
|
-
var
|
|
4338
|
+
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
3778
4339
|
var NetworkServiceImpl = class {
|
|
3779
4340
|
constructor(networkManager, signalManager) {
|
|
3780
4341
|
this.networkManager = networkManager;
|
|
3781
4342
|
this.signalManager = signalManager;
|
|
3782
4343
|
}
|
|
3783
4344
|
queryStatus() {
|
|
3784
|
-
return new
|
|
4345
|
+
return new import_codec_protobuf14.Stream(({ next }) => {
|
|
3785
4346
|
const update = () => {
|
|
3786
4347
|
next({
|
|
3787
4348
|
swarm: this.networkManager.connectionState,
|
|
@@ -3855,12 +4416,15 @@ var toStorageType = (type) => {
|
|
|
3855
4416
|
};
|
|
3856
4417
|
|
|
3857
4418
|
// packages/sdk/client-services/src/packlets/system/system-service.ts
|
|
3858
|
-
var
|
|
4419
|
+
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
4420
|
+
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
4421
|
+
var import_util9 = require("@dxos/util");
|
|
3859
4422
|
var SystemServiceImpl = class {
|
|
3860
|
-
constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
4423
|
+
constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
3861
4424
|
this._config = config;
|
|
3862
4425
|
this._statusUpdate = statusUpdate;
|
|
3863
4426
|
this._getCurrentStatus = getCurrentStatus;
|
|
4427
|
+
this._getDiagnostics = getDiagnostics;
|
|
3864
4428
|
this._onUpdateStatus = onUpdateStatus;
|
|
3865
4429
|
this._onReset = onReset;
|
|
3866
4430
|
}
|
|
@@ -3868,12 +4432,25 @@ var SystemServiceImpl = class {
|
|
|
3868
4432
|
var _a, _b;
|
|
3869
4433
|
return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
|
|
3870
4434
|
}
|
|
4435
|
+
/**
|
|
4436
|
+
* NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
|
|
4437
|
+
*/
|
|
4438
|
+
async getDiagnostics({ keys } = {}) {
|
|
4439
|
+
const diagnostics = await this._getDiagnostics();
|
|
4440
|
+
return {
|
|
4441
|
+
timestamp: new Date(),
|
|
4442
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util9.jsonKeyReplacer)({
|
|
4443
|
+
truncate: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
4444
|
+
humanize: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
4445
|
+
})))
|
|
4446
|
+
};
|
|
4447
|
+
}
|
|
3871
4448
|
async updateStatus({ status }) {
|
|
3872
4449
|
await this._onUpdateStatus(status);
|
|
3873
4450
|
}
|
|
3874
4451
|
// TODO(burdon): Standardize interval option in stream request?
|
|
3875
4452
|
queryStatus({ interval = 3e3 } = {}) {
|
|
3876
|
-
return new
|
|
4453
|
+
return new import_codec_protobuf15.Stream(({ next }) => {
|
|
3877
4454
|
const update = () => {
|
|
3878
4455
|
next({
|
|
3879
4456
|
status: this._getCurrentStatus()
|
|
@@ -3918,7 +4495,7 @@ var ServiceRegistry = class {
|
|
|
3918
4495
|
};
|
|
3919
4496
|
|
|
3920
4497
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
3921
|
-
function
|
|
4498
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
3922
4499
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3923
4500
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
3924
4501
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3928,23 +4505,22 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3928
4505
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3929
4506
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3930
4507
|
}
|
|
3931
|
-
var
|
|
4508
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
|
|
3932
4509
|
var createDefaultModelFactory = () => {
|
|
3933
|
-
return new import_model_factory.ModelFactory().registerModel(
|
|
4510
|
+
return new import_model_factory.ModelFactory().registerModel(import_document_model2.DocumentModel).registerModel(import_text_model.TextModel);
|
|
3934
4511
|
};
|
|
3935
|
-
var ClientServicesHost = class {
|
|
4512
|
+
var ClientServicesHost = class ClientServicesHost2 {
|
|
3936
4513
|
constructor({
|
|
3937
4514
|
config,
|
|
3938
4515
|
modelFactory = createDefaultModelFactory(),
|
|
3939
|
-
// TODO(burdon): Create ApolloLink abstraction (see Client).
|
|
3940
4516
|
transportFactory,
|
|
3941
4517
|
signalManager,
|
|
3942
|
-
connectionLog,
|
|
3943
4518
|
storage,
|
|
3944
4519
|
// TODO(wittjosiah): Turn this on by default.
|
|
3945
4520
|
lockKey,
|
|
3946
4521
|
callbacks
|
|
3947
4522
|
} = {}) {
|
|
4523
|
+
this._tracingService = import_tracing4.TRACE_PROCESSOR.createTraceSender();
|
|
3948
4524
|
this._statusUpdate = new import_async17.Event();
|
|
3949
4525
|
this._opening = false;
|
|
3950
4526
|
this._open = false;
|
|
@@ -3963,7 +4539,7 @@ var ClientServicesHost = class {
|
|
|
3963
4539
|
lockKey,
|
|
3964
4540
|
onAcquire: () => {
|
|
3965
4541
|
if (!this._opening) {
|
|
3966
|
-
void this.open();
|
|
4542
|
+
void this.open(new import_context10.Context());
|
|
3967
4543
|
}
|
|
3968
4544
|
},
|
|
3969
4545
|
onRelease: () => this.close()
|
|
@@ -3972,12 +4548,15 @@ var ClientServicesHost = class {
|
|
|
3972
4548
|
this._systemService = new SystemServiceImpl({
|
|
3973
4549
|
config: this._config,
|
|
3974
4550
|
statusUpdate: this._statusUpdate,
|
|
3975
|
-
getCurrentStatus: () => this.isOpen ?
|
|
4551
|
+
getCurrentStatus: () => this.isOpen ? import_services14.SystemStatus.ACTIVE : import_services14.SystemStatus.INACTIVE,
|
|
4552
|
+
getDiagnostics: () => {
|
|
4553
|
+
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
4554
|
+
},
|
|
3976
4555
|
onUpdateStatus: async (status) => {
|
|
3977
4556
|
var _a, _b;
|
|
3978
|
-
if (!this.isOpen && status ===
|
|
4557
|
+
if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
|
|
3979
4558
|
await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
|
|
3980
|
-
} else if (this.isOpen && status ===
|
|
4559
|
+
} else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
|
|
3981
4560
|
await ((_b = this._resourceLock) == null ? void 0 : _b.release());
|
|
3982
4561
|
}
|
|
3983
4562
|
},
|
|
@@ -3987,12 +4566,19 @@ var ClientServicesHost = class {
|
|
|
3987
4566
|
});
|
|
3988
4567
|
this._loggingService = new LoggingServiceImpl();
|
|
3989
4568
|
this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
|
|
3990
|
-
SystemService: this._systemService
|
|
4569
|
+
SystemService: this._systemService,
|
|
4570
|
+
TracingService: this._tracingService
|
|
3991
4571
|
});
|
|
3992
4572
|
}
|
|
3993
4573
|
get isOpen() {
|
|
3994
4574
|
return this._open;
|
|
3995
4575
|
}
|
|
4576
|
+
get config() {
|
|
4577
|
+
return this._config;
|
|
4578
|
+
}
|
|
4579
|
+
get context() {
|
|
4580
|
+
return this._serviceContext;
|
|
4581
|
+
}
|
|
3996
4582
|
get serviceRegistry() {
|
|
3997
4583
|
return this._serviceRegistry;
|
|
3998
4584
|
}
|
|
@@ -4009,9 +4595,31 @@ var ClientServicesHost = class {
|
|
|
4009
4595
|
*/
|
|
4010
4596
|
initialize({ config, ...options }) {
|
|
4011
4597
|
var _a, _b, _c;
|
|
4012
|
-
(0,
|
|
4598
|
+
(0, import_invariant14.invariant)(!this._open, "service host is open", {
|
|
4599
|
+
F: __dxlog_file17,
|
|
4600
|
+
L: 181,
|
|
4601
|
+
S: this,
|
|
4602
|
+
A: [
|
|
4603
|
+
"!this._open",
|
|
4604
|
+
"'service host is open'"
|
|
4605
|
+
]
|
|
4606
|
+
});
|
|
4607
|
+
import_log16.log.info("initializing...", void 0, {
|
|
4608
|
+
F: __dxlog_file17,
|
|
4609
|
+
L: 182,
|
|
4610
|
+
S: this,
|
|
4611
|
+
C: (f, a) => f(...a)
|
|
4612
|
+
});
|
|
4013
4613
|
if (config) {
|
|
4014
|
-
(0,
|
|
4614
|
+
(0, import_invariant14.invariant)(!this._config, "config already set", {
|
|
4615
|
+
F: __dxlog_file17,
|
|
4616
|
+
L: 185,
|
|
4617
|
+
S: this,
|
|
4618
|
+
A: [
|
|
4619
|
+
"!this._config",
|
|
4620
|
+
"'config already set'"
|
|
4621
|
+
]
|
|
4622
|
+
});
|
|
4015
4623
|
this._config = config;
|
|
4016
4624
|
if (!this._storage) {
|
|
4017
4625
|
this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
|
|
@@ -4021,37 +4629,83 @@ var ClientServicesHost = class {
|
|
|
4021
4629
|
iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
|
|
4022
4630
|
}), signalManager = new import_messaging.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
|
|
4023
4631
|
this._signalManager = signalManager;
|
|
4024
|
-
(0,
|
|
4632
|
+
(0, import_invariant14.invariant)(!this._networkManager, "network manager already set", {
|
|
4633
|
+
F: __dxlog_file17,
|
|
4634
|
+
L: 201,
|
|
4635
|
+
S: this,
|
|
4636
|
+
A: [
|
|
4637
|
+
"!this._networkManager",
|
|
4638
|
+
"'network manager already set'"
|
|
4639
|
+
]
|
|
4640
|
+
});
|
|
4025
4641
|
this._networkManager = new import_network_manager2.NetworkManager({
|
|
4026
4642
|
log: connectionLog,
|
|
4027
4643
|
transportFactory,
|
|
4028
4644
|
signalManager
|
|
4029
4645
|
});
|
|
4646
|
+
import_log16.log.info("initialized", void 0, {
|
|
4647
|
+
F: __dxlog_file17,
|
|
4648
|
+
L: 208,
|
|
4649
|
+
S: this,
|
|
4650
|
+
C: (f, a) => f(...a)
|
|
4651
|
+
});
|
|
4030
4652
|
}
|
|
4031
|
-
async open() {
|
|
4653
|
+
async open(ctx) {
|
|
4032
4654
|
var _a, _b, _c;
|
|
4033
4655
|
if (this._open) {
|
|
4034
4656
|
return;
|
|
4035
4657
|
}
|
|
4036
4658
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
4037
|
-
|
|
4659
|
+
import_log16.log.trace("dxos.client-services.host.open", import_protocols10.trace.begin({
|
|
4038
4660
|
id: traceId
|
|
4039
4661
|
}), {
|
|
4040
|
-
F:
|
|
4041
|
-
L:
|
|
4662
|
+
F: __dxlog_file17,
|
|
4663
|
+
L: 219,
|
|
4042
4664
|
S: this,
|
|
4043
4665
|
C: (f, a) => f(...a)
|
|
4044
4666
|
});
|
|
4045
|
-
(0,
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4667
|
+
(0, import_invariant14.invariant)(this._config, "config not set", {
|
|
4668
|
+
F: __dxlog_file17,
|
|
4669
|
+
L: 221,
|
|
4670
|
+
S: this,
|
|
4671
|
+
A: [
|
|
4672
|
+
"this._config",
|
|
4673
|
+
"'config not set'"
|
|
4674
|
+
]
|
|
4675
|
+
});
|
|
4676
|
+
(0, import_invariant14.invariant)(this._storage, "storage not set", {
|
|
4677
|
+
F: __dxlog_file17,
|
|
4678
|
+
L: 222,
|
|
4679
|
+
S: this,
|
|
4680
|
+
A: [
|
|
4681
|
+
"this._storage",
|
|
4682
|
+
"'storage not set'"
|
|
4683
|
+
]
|
|
4684
|
+
});
|
|
4685
|
+
(0, import_invariant14.invariant)(this._signalManager, "signal manager not set", {
|
|
4686
|
+
F: __dxlog_file17,
|
|
4687
|
+
L: 223,
|
|
4688
|
+
S: this,
|
|
4689
|
+
A: [
|
|
4690
|
+
"this._signalManager",
|
|
4691
|
+
"'signal manager not set'"
|
|
4692
|
+
]
|
|
4693
|
+
});
|
|
4694
|
+
(0, import_invariant14.invariant)(this._networkManager, "network manager not set", {
|
|
4695
|
+
F: __dxlog_file17,
|
|
4696
|
+
L: 224,
|
|
4697
|
+
S: this,
|
|
4698
|
+
A: [
|
|
4699
|
+
"this._networkManager",
|
|
4700
|
+
"'network manager not set'"
|
|
4701
|
+
]
|
|
4702
|
+
});
|
|
4049
4703
|
this._opening = true;
|
|
4050
|
-
|
|
4704
|
+
import_log16.log.info("opening...", {
|
|
4051
4705
|
lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
|
|
4052
4706
|
}, {
|
|
4053
|
-
F:
|
|
4054
|
-
L:
|
|
4707
|
+
F: __dxlog_file17,
|
|
4708
|
+
L: 227,
|
|
4055
4709
|
S: this,
|
|
4056
4710
|
C: (f, a) => f(...a)
|
|
4057
4711
|
});
|
|
@@ -4070,6 +4724,7 @@ var ClientServicesHost = class {
|
|
|
4070
4724
|
DataService: new import_echo_pipeline4.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
|
|
4071
4725
|
NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
|
|
4072
4726
|
LoggingService: this._loggingService,
|
|
4727
|
+
TracingService: this._tracingService,
|
|
4073
4728
|
// TODO(burdon): Move to new protobuf definitions.
|
|
4074
4729
|
DevtoolsHost: new DevtoolsServiceImpl({
|
|
4075
4730
|
events: new DevtoolsHostEvents(),
|
|
@@ -4077,24 +4732,24 @@ var ClientServicesHost = class {
|
|
|
4077
4732
|
context: this._serviceContext
|
|
4078
4733
|
})
|
|
4079
4734
|
});
|
|
4080
|
-
await this._serviceContext.open();
|
|
4735
|
+
await this._serviceContext.open(ctx);
|
|
4081
4736
|
this._opening = false;
|
|
4082
4737
|
this._open = true;
|
|
4083
4738
|
this._statusUpdate.emit();
|
|
4084
4739
|
const deviceKey = (_c = this._serviceContext.identityManager.identity) == null ? void 0 : _c.deviceKey;
|
|
4085
|
-
|
|
4740
|
+
import_log16.log.info("opened", {
|
|
4086
4741
|
deviceKey
|
|
4087
4742
|
}, {
|
|
4088
|
-
F:
|
|
4089
|
-
L:
|
|
4743
|
+
F: __dxlog_file17,
|
|
4744
|
+
L: 280,
|
|
4090
4745
|
S: this,
|
|
4091
4746
|
C: (f, a) => f(...a)
|
|
4092
4747
|
});
|
|
4093
|
-
|
|
4748
|
+
import_log16.log.trace("dxos.client-services.host.open", import_protocols10.trace.end({
|
|
4094
4749
|
id: traceId
|
|
4095
4750
|
}), {
|
|
4096
|
-
F:
|
|
4097
|
-
L:
|
|
4751
|
+
F: __dxlog_file17,
|
|
4752
|
+
L: 281,
|
|
4098
4753
|
S: this,
|
|
4099
4754
|
C: (f, a) => f(...a)
|
|
4100
4755
|
});
|
|
@@ -4105,11 +4760,11 @@ var ClientServicesHost = class {
|
|
|
4105
4760
|
return;
|
|
4106
4761
|
}
|
|
4107
4762
|
const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
|
|
4108
|
-
|
|
4763
|
+
import_log16.log.info("closing...", {
|
|
4109
4764
|
deviceKey
|
|
4110
4765
|
}, {
|
|
4111
|
-
F:
|
|
4112
|
-
L:
|
|
4766
|
+
F: __dxlog_file17,
|
|
4767
|
+
L: 292,
|
|
4113
4768
|
S: this,
|
|
4114
4769
|
C: (f, a) => f(...a)
|
|
4115
4770
|
});
|
|
@@ -4120,11 +4775,11 @@ var ClientServicesHost = class {
|
|
|
4120
4775
|
await this._serviceContext.close();
|
|
4121
4776
|
this._open = false;
|
|
4122
4777
|
this._statusUpdate.emit();
|
|
4123
|
-
|
|
4778
|
+
import_log16.log.info("closed", {
|
|
4124
4779
|
deviceKey
|
|
4125
4780
|
}, {
|
|
4126
|
-
F:
|
|
4127
|
-
L:
|
|
4781
|
+
F: __dxlog_file17,
|
|
4782
|
+
L: 298,
|
|
4128
4783
|
S: this,
|
|
4129
4784
|
C: (f, a) => f(...a)
|
|
4130
4785
|
});
|
|
@@ -4132,60 +4787,73 @@ var ClientServicesHost = class {
|
|
|
4132
4787
|
async reset() {
|
|
4133
4788
|
var _a, _b, _c;
|
|
4134
4789
|
const traceId = import_keys11.PublicKey.random().toHex();
|
|
4135
|
-
|
|
4790
|
+
import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.begin({
|
|
4136
4791
|
id: traceId
|
|
4137
4792
|
}), {
|
|
4138
|
-
F:
|
|
4139
|
-
L:
|
|
4793
|
+
F: __dxlog_file17,
|
|
4794
|
+
L: 303,
|
|
4140
4795
|
S: this,
|
|
4141
4796
|
C: (f, a) => f(...a)
|
|
4142
4797
|
});
|
|
4143
|
-
(0,
|
|
4144
|
-
F:
|
|
4145
|
-
L:
|
|
4798
|
+
(0, import_log16.log)("resetting...", void 0, {
|
|
4799
|
+
F: __dxlog_file17,
|
|
4800
|
+
L: 305,
|
|
4146
4801
|
S: this,
|
|
4147
4802
|
C: (f, a) => f(...a)
|
|
4148
4803
|
});
|
|
4149
4804
|
await ((_a = this._serviceContext) == null ? void 0 : _a.close());
|
|
4150
4805
|
await this._storage.reset();
|
|
4151
|
-
(0,
|
|
4152
|
-
F:
|
|
4153
|
-
L:
|
|
4806
|
+
(0, import_log16.log)("reset", void 0, {
|
|
4807
|
+
F: __dxlog_file17,
|
|
4808
|
+
L: 308,
|
|
4154
4809
|
S: this,
|
|
4155
4810
|
C: (f, a) => f(...a)
|
|
4156
4811
|
});
|
|
4157
|
-
|
|
4812
|
+
import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.end({
|
|
4158
4813
|
id: traceId
|
|
4159
4814
|
}), {
|
|
4160
|
-
F:
|
|
4161
|
-
L:
|
|
4815
|
+
F: __dxlog_file17,
|
|
4816
|
+
L: 309,
|
|
4162
4817
|
S: this,
|
|
4163
4818
|
C: (f, a) => f(...a)
|
|
4164
4819
|
});
|
|
4165
4820
|
await ((_c = (_b = this._callbacks) == null ? void 0 : _b.onReset) == null ? void 0 : _c.call(_b));
|
|
4166
4821
|
}
|
|
4167
4822
|
};
|
|
4168
|
-
|
|
4169
|
-
|
|
4823
|
+
_ts_decorate7([
|
|
4824
|
+
import_tracing4.trace.info()
|
|
4825
|
+
], ClientServicesHost.prototype, "_opening", void 0);
|
|
4826
|
+
_ts_decorate7([
|
|
4827
|
+
import_tracing4.trace.info()
|
|
4828
|
+
], ClientServicesHost.prototype, "_open", void 0);
|
|
4829
|
+
_ts_decorate7([
|
|
4830
|
+
import_async17.synchronized,
|
|
4831
|
+
import_tracing4.trace.span()
|
|
4170
4832
|
], ClientServicesHost.prototype, "open", null);
|
|
4171
|
-
|
|
4172
|
-
import_async17.synchronized
|
|
4833
|
+
_ts_decorate7([
|
|
4834
|
+
import_async17.synchronized,
|
|
4835
|
+
import_tracing4.trace.span()
|
|
4173
4836
|
], ClientServicesHost.prototype, "close", null);
|
|
4837
|
+
ClientServicesHost = _ts_decorate7([
|
|
4838
|
+
import_tracing4.trace.resource()
|
|
4839
|
+
], ClientServicesHost);
|
|
4174
4840
|
|
|
4175
4841
|
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
4176
4842
|
var import_async19 = require("@dxos/async");
|
|
4177
4843
|
var import_client_protocol7 = require("@dxos/client-protocol");
|
|
4178
|
-
var
|
|
4844
|
+
var import_context11 = require("@dxos/context");
|
|
4845
|
+
var import_log17 = require("@dxos/log");
|
|
4179
4846
|
var import_messaging2 = require("@dxos/messaging");
|
|
4180
4847
|
var import_network_manager3 = require("@dxos/network-manager");
|
|
4181
|
-
var
|
|
4848
|
+
var import_util10 = require("@dxos/util");
|
|
4182
4849
|
|
|
4183
4850
|
// packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
|
|
4184
|
-
var import_tiny_invariant14 = __toESM(require("tiny-invariant"));
|
|
4185
4851
|
var import_async18 = require("@dxos/async");
|
|
4186
4852
|
var import_client_protocol6 = require("@dxos/client-protocol");
|
|
4853
|
+
var import_invariant15 = require("@dxos/invariant");
|
|
4187
4854
|
var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
|
|
4188
4855
|
var import_rpc2 = require("@dxos/rpc");
|
|
4856
|
+
var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/shell-runtime.ts";
|
|
4189
4857
|
var ShellRuntimeImpl = class {
|
|
4190
4858
|
constructor(_port) {
|
|
4191
4859
|
this._port = _port;
|
|
@@ -4211,7 +4879,15 @@ var ShellRuntimeImpl = class {
|
|
|
4211
4879
|
});
|
|
4212
4880
|
}
|
|
4213
4881
|
async setAppContext(context) {
|
|
4214
|
-
(0,
|
|
4882
|
+
(0, import_invariant15.invariant)(this._appRpc, "runtime not open", {
|
|
4883
|
+
F: __dxlog_file18,
|
|
4884
|
+
L: 44,
|
|
4885
|
+
S: this,
|
|
4886
|
+
A: [
|
|
4887
|
+
"this._appRpc",
|
|
4888
|
+
"'runtime not open'"
|
|
4889
|
+
]
|
|
4890
|
+
});
|
|
4215
4891
|
await this._appRpc.rpc.AppService.setContext(context);
|
|
4216
4892
|
}
|
|
4217
4893
|
async open() {
|
|
@@ -4240,7 +4916,7 @@ var ShellRuntimeImpl = class {
|
|
|
4240
4916
|
};
|
|
4241
4917
|
|
|
4242
4918
|
// packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
|
|
4243
|
-
function
|
|
4919
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
4244
4920
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4245
4921
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4246
4922
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4250,7 +4926,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
4250
4926
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4251
4927
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4252
4928
|
}
|
|
4253
|
-
var
|
|
4929
|
+
var __dxlog_file19 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts";
|
|
4254
4930
|
var LOCK_KEY = "DXOS_RESOURCE_LOCK";
|
|
4255
4931
|
var IFrameHostRuntime = class {
|
|
4256
4932
|
constructor({ config, origin, appPort, shellPort }) {
|
|
@@ -4271,14 +4947,14 @@ var IFrameHostRuntime = class {
|
|
|
4271
4947
|
}
|
|
4272
4948
|
async start() {
|
|
4273
4949
|
var _a;
|
|
4274
|
-
(0,
|
|
4275
|
-
F:
|
|
4276
|
-
L:
|
|
4950
|
+
(0, import_log17.log)("starting...", void 0, {
|
|
4951
|
+
F: __dxlog_file19,
|
|
4952
|
+
L: 71,
|
|
4277
4953
|
S: this,
|
|
4278
4954
|
C: (f, a) => f(...a)
|
|
4279
4955
|
});
|
|
4280
4956
|
try {
|
|
4281
|
-
this._config = await (0,
|
|
4957
|
+
this._config = await (0, import_util10.getAsyncValue)(this._configProvider);
|
|
4282
4958
|
this._transportFactory = (0, import_network_manager3.createWebRTCTransportFactory)({
|
|
4283
4959
|
iceServers: this._config.get("runtime.services.ice")
|
|
4284
4960
|
});
|
|
@@ -4315,22 +4991,22 @@ var IFrameHostRuntime = class {
|
|
|
4315
4991
|
...middleware
|
|
4316
4992
|
});
|
|
4317
4993
|
await Promise.all([
|
|
4318
|
-
this._clientServices.open(),
|
|
4994
|
+
this._clientServices.open(new import_context11.Context()),
|
|
4319
4995
|
this._clientRpc.open(),
|
|
4320
4996
|
(_a = this._shellRuntime) == null ? void 0 : _a.open()
|
|
4321
4997
|
]);
|
|
4322
4998
|
this._ready.wake(void 0);
|
|
4323
|
-
(0,
|
|
4324
|
-
F:
|
|
4325
|
-
L:
|
|
4999
|
+
(0, import_log17.log)("started", void 0, {
|
|
5000
|
+
F: __dxlog_file19,
|
|
5001
|
+
L: 114,
|
|
4326
5002
|
S: this,
|
|
4327
5003
|
C: (f, a) => f(...a)
|
|
4328
5004
|
});
|
|
4329
5005
|
} catch (err) {
|
|
4330
5006
|
this._ready.wake(err);
|
|
4331
|
-
|
|
4332
|
-
F:
|
|
4333
|
-
L:
|
|
5007
|
+
import_log17.log.catch(err, void 0, {
|
|
5008
|
+
F: __dxlog_file19,
|
|
5009
|
+
L: 117,
|
|
4334
5010
|
S: this,
|
|
4335
5011
|
C: (f, a) => f(...a)
|
|
4336
5012
|
});
|
|
@@ -4338,36 +5014,36 @@ var IFrameHostRuntime = class {
|
|
|
4338
5014
|
}
|
|
4339
5015
|
async stop() {
|
|
4340
5016
|
var _a;
|
|
4341
|
-
(0,
|
|
4342
|
-
F:
|
|
4343
|
-
L:
|
|
5017
|
+
(0, import_log17.log)("stopping...", void 0, {
|
|
5018
|
+
F: __dxlog_file19,
|
|
5019
|
+
L: 122,
|
|
4344
5020
|
S: this,
|
|
4345
5021
|
C: (f, a) => f(...a)
|
|
4346
5022
|
});
|
|
4347
5023
|
await this._clientRpc.close();
|
|
4348
5024
|
await this._clientServices.close();
|
|
4349
5025
|
await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
|
|
4350
|
-
(0,
|
|
4351
|
-
F:
|
|
4352
|
-
L:
|
|
5026
|
+
(0, import_log17.log)("stopped", void 0, {
|
|
5027
|
+
F: __dxlog_file19,
|
|
5028
|
+
L: 126,
|
|
4353
5029
|
S: this,
|
|
4354
5030
|
C: (f, a) => f(...a)
|
|
4355
5031
|
});
|
|
4356
5032
|
}
|
|
4357
5033
|
};
|
|
4358
|
-
|
|
4359
|
-
|
|
5034
|
+
_ts_decorate8([
|
|
5035
|
+
import_log17.logInfo
|
|
4360
5036
|
], IFrameHostRuntime.prototype, "origin", void 0);
|
|
4361
5037
|
|
|
4362
5038
|
// packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
|
|
4363
5039
|
var import_async20 = require("@dxos/async");
|
|
4364
5040
|
var import_client_protocol8 = require("@dxos/client-protocol");
|
|
4365
5041
|
var import_errors6 = require("@dxos/errors");
|
|
4366
|
-
var
|
|
5042
|
+
var import_log18 = require("@dxos/log");
|
|
4367
5043
|
var import_network_manager4 = require("@dxos/network-manager");
|
|
4368
5044
|
var import_rpc3 = require("@dxos/rpc");
|
|
4369
|
-
var
|
|
4370
|
-
var
|
|
5045
|
+
var import_util11 = require("@dxos/util");
|
|
5046
|
+
var __dxlog_file20 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts";
|
|
4371
5047
|
var IFrameProxyRuntime = class {
|
|
4372
5048
|
constructor({ config, systemPort, shellPort }) {
|
|
4373
5049
|
this._id = String(Math.floor(Math.random() * 1e6));
|
|
@@ -4384,7 +5060,7 @@ var IFrameProxyRuntime = class {
|
|
|
4384
5060
|
}
|
|
4385
5061
|
async open(origin) {
|
|
4386
5062
|
var _a;
|
|
4387
|
-
this._config = await (0,
|
|
5063
|
+
this._config = await (0, import_util11.getAsyncValue)(this._configProvider);
|
|
4388
5064
|
this._transportService = new import_network_manager4.WebRTCTransportService({
|
|
4389
5065
|
iceServers: this._config.get("runtime.services.ice")
|
|
4390
5066
|
});
|
|
@@ -4415,8 +5091,8 @@ var IFrameProxyRuntime = class {
|
|
|
4415
5091
|
lockKey
|
|
4416
5092
|
});
|
|
4417
5093
|
} catch (err) {
|
|
4418
|
-
|
|
4419
|
-
F:
|
|
5094
|
+
import_log18.log.catch(err, void 0, {
|
|
5095
|
+
F: __dxlog_file20,
|
|
4420
5096
|
L: 85,
|
|
4421
5097
|
S: this,
|
|
4422
5098
|
C: (f, a) => f(...a)
|
|
@@ -4439,18 +5115,19 @@ var IFrameProxyRuntime = class {
|
|
|
4439
5115
|
|
|
4440
5116
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
4441
5117
|
var import_async22 = require("@dxos/async");
|
|
4442
|
-
var
|
|
5118
|
+
var import_context12 = require("@dxos/context");
|
|
5119
|
+
var import_log20 = require("@dxos/log");
|
|
4443
5120
|
var import_messaging3 = require("@dxos/messaging");
|
|
4444
5121
|
var import_network_manager5 = require("@dxos/network-manager");
|
|
4445
5122
|
|
|
4446
5123
|
// packages/sdk/client-services/src/packlets/vault/worker-session.ts
|
|
4447
|
-
var import_tiny_invariant15 = __toESM(require("tiny-invariant"));
|
|
4448
5124
|
var import_async21 = require("@dxos/async");
|
|
4449
5125
|
var import_client_protocol9 = require("@dxos/client-protocol");
|
|
4450
|
-
var
|
|
5126
|
+
var import_invariant16 = require("@dxos/invariant");
|
|
5127
|
+
var import_log19 = require("@dxos/log");
|
|
4451
5128
|
var import_rpc4 = require("@dxos/rpc");
|
|
4452
|
-
var
|
|
4453
|
-
function
|
|
5129
|
+
var import_util12 = require("@dxos/util");
|
|
5130
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
4454
5131
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4455
5132
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4456
5133
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4460,12 +5137,20 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4460
5137
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4461
5138
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4462
5139
|
}
|
|
4463
|
-
var
|
|
5140
|
+
var __dxlog_file21 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/worker-session.ts";
|
|
4464
5141
|
var WorkerSession = class {
|
|
4465
5142
|
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
|
|
4466
5143
|
this._startTrigger = new import_async21.Trigger();
|
|
4467
|
-
this.onClose = new
|
|
4468
|
-
(0,
|
|
5144
|
+
this.onClose = new import_util12.Callback();
|
|
5145
|
+
(0, import_invariant16.invariant)(serviceHost, void 0, {
|
|
5146
|
+
F: __dxlog_file21,
|
|
5147
|
+
L: 49,
|
|
5148
|
+
S: this,
|
|
5149
|
+
A: [
|
|
5150
|
+
"serviceHost",
|
|
5151
|
+
""
|
|
5152
|
+
]
|
|
5153
|
+
});
|
|
4469
5154
|
this._serviceHost = serviceHost;
|
|
4470
5155
|
const middleware = {
|
|
4471
5156
|
handleCall: async (method, params, handler) => {
|
|
@@ -4512,8 +5197,8 @@ var WorkerSession = class {
|
|
|
4512
5197
|
try {
|
|
4513
5198
|
await this.close();
|
|
4514
5199
|
} catch (err) {
|
|
4515
|
-
|
|
4516
|
-
F:
|
|
5200
|
+
import_log19.log.catch(err, void 0, {
|
|
5201
|
+
F: __dxlog_file21,
|
|
4517
5202
|
L: 99,
|
|
4518
5203
|
S: this,
|
|
4519
5204
|
C: (f, a) => f(...a)
|
|
@@ -4529,8 +5214,8 @@ var WorkerSession = class {
|
|
|
4529
5214
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
4530
5215
|
}
|
|
4531
5216
|
async open() {
|
|
4532
|
-
|
|
4533
|
-
F:
|
|
5217
|
+
import_log19.log.info("opening...", void 0, {
|
|
5218
|
+
F: __dxlog_file21,
|
|
4534
5219
|
L: 113,
|
|
4535
5220
|
S: this,
|
|
4536
5221
|
C: (f, a) => f(...a)
|
|
@@ -4546,26 +5231,26 @@ var WorkerSession = class {
|
|
|
4546
5231
|
if (this.lockKey) {
|
|
4547
5232
|
void this._afterLockReleases(this.lockKey, () => this.close());
|
|
4548
5233
|
}
|
|
4549
|
-
|
|
4550
|
-
F:
|
|
4551
|
-
L:
|
|
5234
|
+
import_log19.log.info("opened", void 0, {
|
|
5235
|
+
F: __dxlog_file21,
|
|
5236
|
+
L: 124,
|
|
4552
5237
|
S: this,
|
|
4553
5238
|
C: (f, a) => f(...a)
|
|
4554
5239
|
});
|
|
4555
5240
|
}
|
|
4556
5241
|
async close() {
|
|
4557
|
-
|
|
4558
|
-
F:
|
|
4559
|
-
L:
|
|
5242
|
+
import_log19.log.info("closing...", void 0, {
|
|
5243
|
+
F: __dxlog_file21,
|
|
5244
|
+
L: 128,
|
|
4560
5245
|
S: this,
|
|
4561
5246
|
C: (f, a) => f(...a)
|
|
4562
5247
|
});
|
|
4563
5248
|
try {
|
|
4564
5249
|
await this.onClose.callIfSet();
|
|
4565
5250
|
} catch (err) {
|
|
4566
|
-
|
|
4567
|
-
F:
|
|
4568
|
-
L:
|
|
5251
|
+
import_log19.log.catch(err, void 0, {
|
|
5252
|
+
F: __dxlog_file21,
|
|
5253
|
+
L: 132,
|
|
4569
5254
|
S: this,
|
|
4570
5255
|
C: (f, a) => f(...a)
|
|
4571
5256
|
});
|
|
@@ -4574,9 +5259,9 @@ var WorkerSession = class {
|
|
|
4574
5259
|
this._clientRpc.close(),
|
|
4575
5260
|
this._iframeRpc.close()
|
|
4576
5261
|
]);
|
|
4577
|
-
|
|
4578
|
-
F:
|
|
4579
|
-
L:
|
|
5262
|
+
import_log19.log.info("closed", void 0, {
|
|
5263
|
+
F: __dxlog_file21,
|
|
5264
|
+
L: 136,
|
|
4580
5265
|
S: this,
|
|
4581
5266
|
C: (f, a) => f(...a)
|
|
4582
5267
|
});
|
|
@@ -4585,9 +5270,9 @@ var WorkerSession = class {
|
|
|
4585
5270
|
try {
|
|
4586
5271
|
await (0, import_async21.asyncTimeout)(this._shellClientRpc.open(), 1e3);
|
|
4587
5272
|
} catch (e) {
|
|
4588
|
-
|
|
4589
|
-
F:
|
|
4590
|
-
L:
|
|
5273
|
+
import_log19.log.info("No shell connected.", void 0, {
|
|
5274
|
+
F: __dxlog_file21,
|
|
5275
|
+
L: 143,
|
|
4591
5276
|
S: this,
|
|
4592
5277
|
C: (f, a) => f(...a)
|
|
4593
5278
|
});
|
|
@@ -4598,15 +5283,15 @@ var WorkerSession = class {
|
|
|
4598
5283
|
}).then(callback);
|
|
4599
5284
|
}
|
|
4600
5285
|
};
|
|
4601
|
-
|
|
4602
|
-
|
|
5286
|
+
_ts_decorate9([
|
|
5287
|
+
import_log19.logInfo
|
|
4603
5288
|
], WorkerSession.prototype, "origin", void 0);
|
|
4604
|
-
|
|
4605
|
-
|
|
5289
|
+
_ts_decorate9([
|
|
5290
|
+
import_log19.logInfo
|
|
4606
5291
|
], WorkerSession.prototype, "lockKey", void 0);
|
|
4607
5292
|
|
|
4608
5293
|
// packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
|
|
4609
|
-
var
|
|
5294
|
+
var __dxlog_file22 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/worker-runtime.ts";
|
|
4610
5295
|
var WorkerRuntime = class {
|
|
4611
5296
|
// prettier-ignore
|
|
4612
5297
|
constructor(_configProvider) {
|
|
@@ -4626,9 +5311,9 @@ var WorkerRuntime = class {
|
|
|
4626
5311
|
return this._clientServices;
|
|
4627
5312
|
}
|
|
4628
5313
|
async start() {
|
|
4629
|
-
(0,
|
|
4630
|
-
F:
|
|
4631
|
-
L:
|
|
5314
|
+
(0, import_log20.log)("starting...", void 0, {
|
|
5315
|
+
F: __dxlog_file22,
|
|
5316
|
+
L: 49,
|
|
4632
5317
|
S: this,
|
|
4633
5318
|
C: (f, a) => f(...a)
|
|
4634
5319
|
});
|
|
@@ -4640,19 +5325,19 @@ var WorkerRuntime = class {
|
|
|
4640
5325
|
signalManager: signals ? new import_messaging3.WebsocketSignalManager(signals) : new import_messaging3.MemorySignalManager(new import_messaging3.MemorySignalManagerContext()),
|
|
4641
5326
|
transportFactory: this._transportFactory
|
|
4642
5327
|
});
|
|
4643
|
-
await this._clientServices.open();
|
|
5328
|
+
await this._clientServices.open(new import_context12.Context());
|
|
4644
5329
|
this._ready.wake(void 0);
|
|
4645
|
-
(0,
|
|
4646
|
-
F:
|
|
4647
|
-
L:
|
|
5330
|
+
(0, import_log20.log)("started", void 0, {
|
|
5331
|
+
F: __dxlog_file22,
|
|
5332
|
+
L: 63,
|
|
4648
5333
|
S: this,
|
|
4649
5334
|
C: (f, a) => f(...a)
|
|
4650
5335
|
});
|
|
4651
5336
|
} catch (err) {
|
|
4652
5337
|
this._ready.wake(err);
|
|
4653
|
-
|
|
4654
|
-
F:
|
|
4655
|
-
L:
|
|
5338
|
+
import_log20.log.catch(err, void 0, {
|
|
5339
|
+
F: __dxlog_file22,
|
|
5340
|
+
L: 66,
|
|
4656
5341
|
S: this,
|
|
4657
5342
|
C: (f, a) => f(...a)
|
|
4658
5343
|
});
|
|
@@ -4684,9 +5369,9 @@ var WorkerRuntime = class {
|
|
|
4684
5369
|
* Selects one of the existing session fro WebRTC networking.
|
|
4685
5370
|
*/
|
|
4686
5371
|
_reconnectWebrtc() {
|
|
4687
|
-
(0,
|
|
4688
|
-
F:
|
|
4689
|
-
L:
|
|
5372
|
+
(0, import_log20.log)("reconnecting webrtc...", void 0, {
|
|
5373
|
+
F: __dxlog_file22,
|
|
5374
|
+
L: 103,
|
|
4690
5375
|
S: this,
|
|
4691
5376
|
C: (f, a) => f(...a)
|
|
4692
5377
|
});
|
|
@@ -4733,6 +5418,7 @@ var WorkerRuntime = class {
|
|
|
4733
5418
|
WorkerSession,
|
|
4734
5419
|
createAuthProvider,
|
|
4735
5420
|
createDefaultModelFactory,
|
|
5421
|
+
createDiagnostics,
|
|
4736
5422
|
createStorageObjects,
|
|
4737
5423
|
getNetworkPeers,
|
|
4738
5424
|
isLocked,
|