@dxos/client-services 0.8.0 → 0.8.1-main.81238a8
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/{node-esm/chunk-ORQYMDJN.mjs → browser/chunk-35TJRMUI.mjs} +1306 -853
- package/dist/lib/browser/chunk-35TJRMUI.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-FELZPQQE.cjs → chunk-V7LWQ25J.cjs} +1016 -712
- package/dist/lib/node/chunk-V7LWQ25J.cjs.map +7 -0
- package/dist/lib/node/index.cjs +47 -47
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +8 -8
- package/dist/lib/{browser/chunk-25OL3JVO.mjs → node-esm/chunk-CT42KAJ2.mjs} +721 -554
- package/dist/lib/node-esm/chunk-CT42KAJ2.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1 -1
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +1 -1
- package/dist/types/src/packlets/network/network-service.d.ts +2 -1
- package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
- package/dist/types/src/packlets/space-export/index.d.ts +3 -0
- package/dist/types/src/packlets/space-export/index.d.ts.map +1 -0
- package/dist/types/src/packlets/space-export/space-archive-reader.d.ts +9 -0
- package/dist/types/src/packlets/space-export/space-archive-reader.d.ts.map +1 -0
- package/dist/types/src/packlets/space-export/space-archive-writer.d.ts +23 -0
- package/dist/types/src/packlets/space-export/space-archive-writer.d.ts.map +1 -0
- package/dist/types/src/packlets/space-export/tar.test.d.ts +2 -0
- package/dist/types/src/packlets/space-export/tar.test.d.ts.map +1 -0
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +8 -2
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +1 -0
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +3 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/dist/types/src/version.d.ts.map +1 -1
- package/package.json +39 -38
- package/src/packlets/network/network-service.ts +10 -1
- package/src/packlets/space-export/index.ts +6 -0
- package/src/packlets/space-export/space-archive-reader.ts +33 -0
- package/src/packlets/space-export/space-archive-writer.ts +83 -0
- package/src/packlets/space-export/tar.test.ts +25 -0
- package/src/packlets/spaces/data-space-manager.ts +70 -9
- package/src/packlets/spaces/data-space.ts +14 -1
- package/src/packlets/spaces/spaces-service.ts +39 -1
- package/src/version.ts +1 -5
- package/dist/lib/browser/chunk-25OL3JVO.mjs.map +0 -7
- package/dist/lib/node/chunk-FELZPQQE.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-ORQYMDJN.mjs.map +0 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
|
|
3
3
|
// packages/sdk/client-services/src/packlets/devtools/feeds.ts
|
|
4
4
|
import { EventSubscriptions } from "@dxos/async";
|
|
@@ -397,7 +397,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
|
|
|
397
397
|
import { TRACE_PROCESSOR } from "@dxos/tracing";
|
|
398
398
|
|
|
399
399
|
// packages/sdk/client-services/src/version.ts
|
|
400
|
-
var DXOS_VERSION = "0.8.
|
|
400
|
+
var DXOS_VERSION = "0.8.1-main.81238a8";
|
|
401
401
|
|
|
402
402
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
403
403
|
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -551,98 +551,20 @@ var getStorageDiagnostics = async () => {
|
|
|
551
551
|
}));
|
|
552
552
|
};
|
|
553
553
|
|
|
554
|
-
// packages/sdk/client-services/src/packlets/diagnostics/
|
|
555
|
-
import { Trigger } from "@dxos/async";
|
|
556
|
-
import { log as log2 } from "@dxos/log";
|
|
557
|
-
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/browser-diagnostics-broadcast.ts";
|
|
558
|
-
var CHANNEL_NAME = "dxos.diagnostics.broadcast";
|
|
559
|
-
var MessageType;
|
|
560
|
-
(function(MessageType2) {
|
|
561
|
-
MessageType2["PROBE"] = "probe";
|
|
562
|
-
MessageType2["PROBE_ACK"] = "probe-ack";
|
|
563
|
-
MessageType2["REQUEST_DIAGNOSTICS"] = "request-diagnostics";
|
|
564
|
-
MessageType2["RECEIVE_DIAGNOSTICS"] = "receive-diagnostics";
|
|
565
|
-
})(MessageType || (MessageType = {}));
|
|
554
|
+
// packages/sdk/client-services/src/packlets/diagnostics/diagnostics-broadcast.ts
|
|
566
555
|
var createCollectDiagnosticsBroadcastSender = () => {
|
|
567
556
|
return {
|
|
568
|
-
broadcastDiagnosticsRequest: async () =>
|
|
569
|
-
let expectedResponse = "probe-ack";
|
|
570
|
-
let channel;
|
|
571
|
-
try {
|
|
572
|
-
const trigger = new Trigger();
|
|
573
|
-
channel = new BroadcastChannel(CHANNEL_NAME);
|
|
574
|
-
channel.onmessage = (msg) => {
|
|
575
|
-
if (expectedResponse === msg.data.type) {
|
|
576
|
-
trigger.wake(msg.data);
|
|
577
|
-
}
|
|
578
|
-
};
|
|
579
|
-
channel.postMessage({
|
|
580
|
-
type: "probe"
|
|
581
|
-
});
|
|
582
|
-
await trigger.wait({
|
|
583
|
-
timeout: 200
|
|
584
|
-
});
|
|
585
|
-
expectedResponse = "receive-diagnostics";
|
|
586
|
-
trigger.reset();
|
|
587
|
-
channel.postMessage({
|
|
588
|
-
type: "request-diagnostics"
|
|
589
|
-
});
|
|
590
|
-
const diagnostics = await trigger.wait({
|
|
591
|
-
timeout: 5e3
|
|
592
|
-
});
|
|
593
|
-
return diagnostics.payload;
|
|
594
|
-
} catch (e) {
|
|
595
|
-
const errorDescription = e instanceof Error ? e.message : JSON.stringify(e);
|
|
596
|
-
return {
|
|
597
|
-
expectedResponse,
|
|
598
|
-
errorDescription
|
|
599
|
-
};
|
|
600
|
-
} finally {
|
|
601
|
-
safeClose(channel);
|
|
602
|
-
}
|
|
603
|
-
}
|
|
557
|
+
broadcastDiagnosticsRequest: async () => void 0
|
|
604
558
|
};
|
|
605
559
|
};
|
|
606
|
-
var createCollectDiagnosticsBroadcastHandler = (
|
|
607
|
-
let channel;
|
|
560
|
+
var createCollectDiagnosticsBroadcastHandler = (_) => {
|
|
608
561
|
return {
|
|
609
562
|
start: () => {
|
|
610
|
-
channel = new BroadcastChannel(CHANNEL_NAME);
|
|
611
|
-
channel.onmessage = async (message) => {
|
|
612
|
-
try {
|
|
613
|
-
if (message.data.type === "probe") {
|
|
614
|
-
channel?.postMessage({
|
|
615
|
-
type: "probe-ack"
|
|
616
|
-
});
|
|
617
|
-
} else if (message.data.type === "request-diagnostics") {
|
|
618
|
-
const diagnostics = await systemService.getDiagnostics({});
|
|
619
|
-
channel?.postMessage({
|
|
620
|
-
type: "receive-diagnostics",
|
|
621
|
-
payload: diagnostics
|
|
622
|
-
});
|
|
623
|
-
}
|
|
624
|
-
} catch (error) {
|
|
625
|
-
log2.catch(error, void 0, {
|
|
626
|
-
F: __dxlog_file4,
|
|
627
|
-
L: 77,
|
|
628
|
-
S: void 0,
|
|
629
|
-
C: (f, a) => f(...a)
|
|
630
|
-
});
|
|
631
|
-
}
|
|
632
|
-
};
|
|
633
563
|
},
|
|
634
564
|
stop: () => {
|
|
635
|
-
safeClose(channel);
|
|
636
|
-
channel = void 0;
|
|
637
565
|
}
|
|
638
566
|
};
|
|
639
567
|
};
|
|
640
|
-
var safeClose = (channel) => {
|
|
641
|
-
try {
|
|
642
|
-
channel?.close();
|
|
643
|
-
} catch (e) {
|
|
644
|
-
}
|
|
645
|
-
};
|
|
646
568
|
|
|
647
569
|
// packages/sdk/client-services/src/packlets/diagnostics/diagnostics-collector.ts
|
|
648
570
|
import { ClientServicesProviderResource } from "@dxos/client-protocol";
|
|
@@ -686,12 +608,12 @@ var findConfigs = () => {
|
|
|
686
608
|
};
|
|
687
609
|
|
|
688
610
|
// packages/sdk/client-services/src/packlets/identity/authenticator.ts
|
|
689
|
-
import { Trigger
|
|
611
|
+
import { Trigger } from "@dxos/async";
|
|
690
612
|
import { Context as Context2 } from "@dxos/context";
|
|
691
613
|
import { verifyCredential } from "@dxos/credentials";
|
|
692
|
-
import { log as
|
|
614
|
+
import { log as log2 } from "@dxos/log";
|
|
693
615
|
import { schema } from "@dxos/protocols/proto";
|
|
694
|
-
var
|
|
616
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
|
|
695
617
|
var Credential = schema.getCodecForType("dxos.halo.credentials.Credential");
|
|
696
618
|
var createAuthProvider = (signer) => async (nonce) => {
|
|
697
619
|
const credential = await signer.createCredential({
|
|
@@ -707,7 +629,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
707
629
|
constructor(_params) {
|
|
708
630
|
this._params = _params;
|
|
709
631
|
this._ctx = new Context2(void 0, {
|
|
710
|
-
F:
|
|
632
|
+
F: __dxlog_file4,
|
|
711
633
|
L: 45
|
|
712
634
|
});
|
|
713
635
|
}
|
|
@@ -717,20 +639,20 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
717
639
|
get verifier() {
|
|
718
640
|
return async (nonce, auth) => {
|
|
719
641
|
const credential = Credential.decode(auth);
|
|
720
|
-
|
|
642
|
+
log2("authenticating...", {
|
|
721
643
|
credential
|
|
722
644
|
}, {
|
|
723
|
-
F:
|
|
645
|
+
F: __dxlog_file4,
|
|
724
646
|
L: 56,
|
|
725
647
|
S: this,
|
|
726
648
|
C: (f, a) => f(...a)
|
|
727
649
|
});
|
|
728
650
|
const result = await verifyCredential(credential);
|
|
729
651
|
if (result.kind === "fail") {
|
|
730
|
-
|
|
652
|
+
log2("Invalid credential", {
|
|
731
653
|
result
|
|
732
654
|
}, {
|
|
733
|
-
F:
|
|
655
|
+
F: __dxlog_file4,
|
|
734
656
|
L: 60,
|
|
735
657
|
S: this,
|
|
736
658
|
C: (f, a) => f(...a)
|
|
@@ -738,11 +660,11 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
738
660
|
return false;
|
|
739
661
|
}
|
|
740
662
|
if (!credential.proof.nonce || !Buffer.from(nonce).equals(credential.proof.nonce)) {
|
|
741
|
-
|
|
663
|
+
log2("Invalid nonce", {
|
|
742
664
|
nonce,
|
|
743
665
|
credential
|
|
744
666
|
}, {
|
|
745
|
-
F:
|
|
667
|
+
F: __dxlog_file4,
|
|
746
668
|
L: 65,
|
|
747
669
|
S: this,
|
|
748
670
|
C: (f, a) => f(...a)
|
|
@@ -750,39 +672,39 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
750
672
|
return false;
|
|
751
673
|
}
|
|
752
674
|
if (this._isTrustedKey(credential.issuer)) {
|
|
753
|
-
|
|
675
|
+
log2("key is trusted -- auth success", {
|
|
754
676
|
key: credential.issuer
|
|
755
677
|
}, {
|
|
756
|
-
F:
|
|
678
|
+
F: __dxlog_file4,
|
|
757
679
|
L: 70,
|
|
758
680
|
S: this,
|
|
759
681
|
C: (f, a) => f(...a)
|
|
760
682
|
});
|
|
761
683
|
return true;
|
|
762
684
|
}
|
|
763
|
-
const trigger = new
|
|
685
|
+
const trigger = new Trigger();
|
|
764
686
|
this._ctx.onDispose(() => {
|
|
765
687
|
trigger.wake(false);
|
|
766
688
|
});
|
|
767
689
|
const clear = this._params.update.on(this._ctx, () => {
|
|
768
690
|
if (this._isTrustedKey(credential.issuer)) {
|
|
769
|
-
|
|
691
|
+
log2("auth success", {
|
|
770
692
|
key: credential.issuer
|
|
771
693
|
}, {
|
|
772
|
-
F:
|
|
694
|
+
F: __dxlog_file4,
|
|
773
695
|
L: 81,
|
|
774
696
|
S: this,
|
|
775
697
|
C: (f, a) => f(...a)
|
|
776
698
|
});
|
|
777
699
|
trigger.wake(true);
|
|
778
700
|
} else {
|
|
779
|
-
|
|
701
|
+
log2("key is not currently in trusted set, waiting...", {
|
|
780
702
|
key: credential.issuer,
|
|
781
703
|
trusted: [
|
|
782
704
|
...this._params.trustedKeysProvider()
|
|
783
705
|
]
|
|
784
706
|
}, {
|
|
785
|
-
F:
|
|
707
|
+
F: __dxlog_file4,
|
|
786
708
|
L: 84,
|
|
787
709
|
S: this,
|
|
788
710
|
C: (f, a) => f(...a)
|
|
@@ -813,7 +735,7 @@ import { Context as Context3, Resource } from "@dxos/context";
|
|
|
813
735
|
import { EdgeConnectionClosedError, EdgeIdentityChangedError } from "@dxos/edge-client";
|
|
814
736
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
815
737
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
816
|
-
import { log as
|
|
738
|
+
import { log as log3, logInfo } from "@dxos/log";
|
|
817
739
|
import { EdgeService } from "@dxos/protocols";
|
|
818
740
|
import { buf } from "@dxos/protocols/buf";
|
|
819
741
|
import { MessageSchema as RouterMessageSchema } from "@dxos/protocols/buf/dxos/edge/messenger_pb";
|
|
@@ -886,7 +808,7 @@ function _using_ctx() {
|
|
|
886
808
|
}
|
|
887
809
|
};
|
|
888
810
|
}
|
|
889
|
-
var
|
|
811
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/edge-feed-replicator.ts";
|
|
890
812
|
var EdgeFeedReplicator = class extends Resource {
|
|
891
813
|
constructor({ messenger, spaceId }) {
|
|
892
814
|
super();
|
|
@@ -905,8 +827,8 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
905
827
|
this._spaceId = spaceId;
|
|
906
828
|
}
|
|
907
829
|
async _open() {
|
|
908
|
-
|
|
909
|
-
F:
|
|
830
|
+
log3("open", void 0, {
|
|
831
|
+
F: __dxlog_file5,
|
|
910
832
|
L: 56,
|
|
911
833
|
S: this,
|
|
912
834
|
C: (f, a) => f(...a)
|
|
@@ -921,11 +843,11 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
921
843
|
}
|
|
922
844
|
const [spaceId] = rest;
|
|
923
845
|
if (spaceId !== this._spaceId) {
|
|
924
|
-
|
|
846
|
+
log3("spaceID mismatch", {
|
|
925
847
|
spaceId,
|
|
926
848
|
_spaceId: this._spaceId
|
|
927
849
|
}, {
|
|
928
|
-
F:
|
|
850
|
+
F: __dxlog_file5,
|
|
929
851
|
L: 70,
|
|
930
852
|
S: this,
|
|
931
853
|
C: (f, a) => f(...a)
|
|
@@ -933,12 +855,12 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
933
855
|
return;
|
|
934
856
|
}
|
|
935
857
|
const payload = decodeCbor(message.payload.value);
|
|
936
|
-
|
|
858
|
+
log3("receive", {
|
|
937
859
|
from: message.source,
|
|
938
860
|
feedKey: payload.feedKey,
|
|
939
861
|
type: payload.type
|
|
940
862
|
}, {
|
|
941
|
-
F:
|
|
863
|
+
F: __dxlog_file5,
|
|
942
864
|
L: 75,
|
|
943
865
|
S: this,
|
|
944
866
|
C: (f, a) => f(...a)
|
|
@@ -956,8 +878,8 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
956
878
|
}
|
|
957
879
|
}
|
|
958
880
|
async _close() {
|
|
959
|
-
|
|
960
|
-
F:
|
|
881
|
+
log3("close", void 0, {
|
|
882
|
+
F: __dxlog_file5,
|
|
961
883
|
L: 95,
|
|
962
884
|
S: this,
|
|
963
885
|
C: (f, a) => f(...a)
|
|
@@ -968,8 +890,8 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
968
890
|
this._connected = true;
|
|
969
891
|
const connectionCtx = this._createConnectionContext();
|
|
970
892
|
this._connectionCtx = connectionCtx;
|
|
971
|
-
|
|
972
|
-
F:
|
|
893
|
+
log3("connection context created", void 0, {
|
|
894
|
+
F: __dxlog_file5,
|
|
973
895
|
L: 103,
|
|
974
896
|
S: this,
|
|
975
897
|
C: (f, a) => f(...a)
|
|
@@ -981,8 +903,8 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
981
903
|
});
|
|
982
904
|
}
|
|
983
905
|
async _resetConnection() {
|
|
984
|
-
|
|
985
|
-
F:
|
|
906
|
+
log3("resetConnection", void 0, {
|
|
907
|
+
F: __dxlog_file5,
|
|
986
908
|
L: 112,
|
|
987
909
|
S: this,
|
|
988
910
|
C: (f, a) => f(...a)
|
|
@@ -993,12 +915,12 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
993
915
|
this._remoteLength.clear();
|
|
994
916
|
}
|
|
995
917
|
async addFeed(feed) {
|
|
996
|
-
|
|
918
|
+
log3("addFeed", {
|
|
997
919
|
key: feed.key,
|
|
998
920
|
connected: this._connected,
|
|
999
921
|
hasConnectionCtx: !!this._connectionCtx
|
|
1000
922
|
}, {
|
|
1001
|
-
F:
|
|
923
|
+
F: __dxlog_file5,
|
|
1002
924
|
L: 120,
|
|
1003
925
|
S: this,
|
|
1004
926
|
C: (f, a) => f(...a)
|
|
@@ -1012,10 +934,10 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1012
934
|
return defaultMap(this._pushMutex, key, () => new Mutex());
|
|
1013
935
|
}
|
|
1014
936
|
async _replicateFeed(ctx, feed) {
|
|
1015
|
-
|
|
937
|
+
log3("replicateFeed", {
|
|
1016
938
|
key: feed.key
|
|
1017
939
|
}, {
|
|
1018
|
-
F:
|
|
940
|
+
F: __dxlog_file5,
|
|
1019
941
|
L: 133,
|
|
1020
942
|
S: this,
|
|
1021
943
|
C: (f, a) => f(...a)
|
|
@@ -1030,8 +952,8 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1030
952
|
}
|
|
1031
953
|
async _sendMessage(message) {
|
|
1032
954
|
if (!this._connectionCtx) {
|
|
1033
|
-
|
|
1034
|
-
F:
|
|
955
|
+
log3("message dropped because connection was disposed", void 0, {
|
|
956
|
+
F: __dxlog_file5,
|
|
1035
957
|
L: 146,
|
|
1036
958
|
S: this,
|
|
1037
959
|
C: (f, a) => f(...a)
|
|
@@ -1039,18 +961,18 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1039
961
|
return;
|
|
1040
962
|
}
|
|
1041
963
|
if (message.type === "data") {
|
|
1042
|
-
|
|
964
|
+
log3("sending blocks", {
|
|
1043
965
|
feedKey: message.feedKey,
|
|
1044
966
|
blocks: message.blocks.map((b) => b.index)
|
|
1045
967
|
}, {
|
|
1046
|
-
F:
|
|
968
|
+
F: __dxlog_file5,
|
|
1047
969
|
L: 151,
|
|
1048
970
|
S: this,
|
|
1049
971
|
C: (f, a) => f(...a)
|
|
1050
972
|
});
|
|
1051
973
|
}
|
|
1052
974
|
invariant2(message.feedKey, void 0, {
|
|
1053
|
-
F:
|
|
975
|
+
F: __dxlog_file5,
|
|
1054
976
|
L: 157,
|
|
1055
977
|
S: this,
|
|
1056
978
|
A: [
|
|
@@ -1059,10 +981,10 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1059
981
|
]
|
|
1060
982
|
});
|
|
1061
983
|
const payloadValue = bufferToArray(encodeCbor(message));
|
|
1062
|
-
|
|
984
|
+
log3("send", {
|
|
1063
985
|
type: message.type
|
|
1064
986
|
}, {
|
|
1065
|
-
F:
|
|
987
|
+
F: __dxlog_file5,
|
|
1066
988
|
L: 160,
|
|
1067
989
|
S: this,
|
|
1068
990
|
C: (f, a) => f(...a)
|
|
@@ -1080,8 +1002,8 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1080
1002
|
}
|
|
1081
1003
|
_onMessage(message) {
|
|
1082
1004
|
if (!this._connectionCtx) {
|
|
1083
|
-
|
|
1084
|
-
F:
|
|
1005
|
+
log3.warn("received message after connection context was disposed", void 0, {
|
|
1006
|
+
F: __dxlog_file5,
|
|
1085
1007
|
L: 175,
|
|
1086
1008
|
S: this,
|
|
1087
1009
|
C: (f, a) => f(...a)
|
|
@@ -1096,10 +1018,10 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1096
1018
|
const feedKey = PublicKey3.fromHex(message.feedKey);
|
|
1097
1019
|
const feed = this._feeds.get(feedKey);
|
|
1098
1020
|
if (!feed) {
|
|
1099
|
-
|
|
1021
|
+
log3.warn("Feed not found", {
|
|
1100
1022
|
feedKey
|
|
1101
1023
|
}, {
|
|
1102
|
-
F:
|
|
1024
|
+
F: __dxlog_file5,
|
|
1103
1025
|
L: 184,
|
|
1104
1026
|
S: this,
|
|
1105
1027
|
C: (f, a) => f(...a)
|
|
@@ -1114,8 +1036,8 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1114
1036
|
feedKey
|
|
1115
1037
|
};
|
|
1116
1038
|
if (message.length > feed.length) {
|
|
1117
|
-
|
|
1118
|
-
F:
|
|
1039
|
+
log3("requesting missing blocks", logMeta, {
|
|
1040
|
+
F: __dxlog_file5,
|
|
1119
1041
|
L: 194,
|
|
1120
1042
|
S: this,
|
|
1121
1043
|
C: (f, a) => f(...a)
|
|
@@ -1129,8 +1051,8 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1129
1051
|
}
|
|
1130
1052
|
});
|
|
1131
1053
|
} else if (message.length < feed.length) {
|
|
1132
|
-
|
|
1133
|
-
F:
|
|
1054
|
+
log3("pushing blocks to remote", logMeta, {
|
|
1055
|
+
F: __dxlog_file5,
|
|
1134
1056
|
L: 202,
|
|
1135
1057
|
S: this,
|
|
1136
1058
|
C: (f, a) => f(...a)
|
|
@@ -1145,11 +1067,11 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1145
1067
|
}
|
|
1146
1068
|
}
|
|
1147
1069
|
case "data": {
|
|
1148
|
-
|
|
1070
|
+
log3("received data", {
|
|
1149
1071
|
feed: message.feedKey,
|
|
1150
1072
|
blocks: message.blocks.map((b) => b.index)
|
|
1151
1073
|
}, {
|
|
1152
|
-
F:
|
|
1074
|
+
F: __dxlog_file5,
|
|
1153
1075
|
L: 211,
|
|
1154
1076
|
S: this,
|
|
1155
1077
|
C: (f, a) => f(...a)
|
|
@@ -1157,10 +1079,10 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1157
1079
|
const feedKey = PublicKey3.fromHex(message.feedKey);
|
|
1158
1080
|
const feed = this._feeds.get(feedKey);
|
|
1159
1081
|
if (!feed) {
|
|
1160
|
-
|
|
1082
|
+
log3.warn("Feed not found", {
|
|
1161
1083
|
feedKey
|
|
1162
1084
|
}, {
|
|
1163
|
-
F:
|
|
1085
|
+
F: __dxlog_file5,
|
|
1164
1086
|
L: 216,
|
|
1165
1087
|
S: this,
|
|
1166
1088
|
C: (f, a) => f(...a)
|
|
@@ -1171,10 +1093,10 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1171
1093
|
break;
|
|
1172
1094
|
}
|
|
1173
1095
|
default: {
|
|
1174
|
-
|
|
1096
|
+
log3.warn("Unknown message", {
|
|
1175
1097
|
...message
|
|
1176
1098
|
}, {
|
|
1177
|
-
F:
|
|
1099
|
+
F: __dxlog_file5,
|
|
1178
1100
|
L: 225,
|
|
1179
1101
|
S: this,
|
|
1180
1102
|
C: (f, a) => f(...a)
|
|
@@ -1184,12 +1106,12 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1184
1106
|
});
|
|
1185
1107
|
}
|
|
1186
1108
|
async _pushBlocks(feed, from, to) {
|
|
1187
|
-
|
|
1109
|
+
log3("pushing blocks", {
|
|
1188
1110
|
feed: feed.key.toHex(),
|
|
1189
1111
|
from,
|
|
1190
1112
|
to
|
|
1191
1113
|
}, {
|
|
1192
|
-
F:
|
|
1114
|
+
F: __dxlog_file5,
|
|
1193
1115
|
L: 232,
|
|
1194
1116
|
S: this,
|
|
1195
1117
|
C: (f, a) => f(...a)
|
|
@@ -1199,7 +1121,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1199
1121
|
valueEncoding: "binary"
|
|
1200
1122
|
});
|
|
1201
1123
|
invariant2(data instanceof Uint8Array, void 0, {
|
|
1202
|
-
F:
|
|
1124
|
+
F: __dxlog_file5,
|
|
1203
1125
|
L: 237,
|
|
1204
1126
|
S: this,
|
|
1205
1127
|
A: [
|
|
@@ -1223,11 +1145,11 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1223
1145
|
this._remoteLength.set(feed.key, to);
|
|
1224
1146
|
}
|
|
1225
1147
|
async _integrateBlocks(feed, blocks) {
|
|
1226
|
-
|
|
1148
|
+
log3("integrating blocks", {
|
|
1227
1149
|
feed: feed.key.toHex(),
|
|
1228
1150
|
blocks: blocks.length
|
|
1229
1151
|
}, {
|
|
1230
|
-
F:
|
|
1152
|
+
F: __dxlog_file5,
|
|
1231
1153
|
L: 258,
|
|
1232
1154
|
S: this,
|
|
1233
1155
|
C: (f, a) => f(...a)
|
|
@@ -1248,8 +1170,8 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1248
1170
|
var _usingCtx = _using_ctx();
|
|
1249
1171
|
const _ = _usingCtx.u(await this._getPushMutex(feed.key).acquire());
|
|
1250
1172
|
if (!this._remoteLength.has(feed.key)) {
|
|
1251
|
-
|
|
1252
|
-
F:
|
|
1173
|
+
log3("blocks not pushed because remote length is unknown", void 0, {
|
|
1174
|
+
F: __dxlog_file5,
|
|
1253
1175
|
L: 279,
|
|
1254
1176
|
S: this,
|
|
1255
1177
|
C: (f, a) => f(...a)
|
|
@@ -1273,8 +1195,8 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1273
1195
|
return;
|
|
1274
1196
|
}
|
|
1275
1197
|
if (err instanceof EdgeIdentityChangedError || err instanceof EdgeConnectionClosedError) {
|
|
1276
|
-
|
|
1277
|
-
F:
|
|
1198
|
+
log3("resetting on reconnect", void 0, {
|
|
1199
|
+
F: __dxlog_file5,
|
|
1278
1200
|
L: 296,
|
|
1279
1201
|
S: this,
|
|
1280
1202
|
C: (f, a) => f(...a)
|
|
@@ -1285,7 +1207,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1285
1207
|
}
|
|
1286
1208
|
}
|
|
1287
1209
|
}, {
|
|
1288
|
-
F:
|
|
1210
|
+
F: __dxlog_file5,
|
|
1289
1211
|
L: 290
|
|
1290
1212
|
});
|
|
1291
1213
|
return connectionCtx;
|
|
@@ -1307,12 +1229,13 @@ var bufferizeBlock = (block) => ({
|
|
|
1307
1229
|
|
|
1308
1230
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
1309
1231
|
import { Event as Event7, Mutex as Mutex2, scheduleTask as scheduleTask4, sleep as sleep3, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
1232
|
+
import { save } from "@dxos/automerge/automerge";
|
|
1310
1233
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
1311
|
-
import { Context as
|
|
1234
|
+
import { Context as Context6, ContextDisposedError, cancelWithContext as cancelWithContext2 } from "@dxos/context";
|
|
1312
1235
|
import { timed, warnAfterTimeout } from "@dxos/debug";
|
|
1313
1236
|
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
1314
1237
|
import { SpaceDocVersion as SpaceDocVersion2 } from "@dxos/echo-protocol";
|
|
1315
|
-
import { failedInvariant } from "@dxos/invariant";
|
|
1238
|
+
import { failedInvariant as failedInvariant3, invariant as invariant11 } from "@dxos/invariant";
|
|
1316
1239
|
import { PublicKey as PublicKey8 } from "@dxos/keys";
|
|
1317
1240
|
import { log as log12 } from "@dxos/log";
|
|
1318
1241
|
import { CancelledError, SystemError } from "@dxos/protocols";
|
|
@@ -1370,7 +1293,7 @@ var AutomergeSpaceState = class extends Resource2 {
|
|
|
1370
1293
|
// packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts
|
|
1371
1294
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
1372
1295
|
import { CreateEpochRequest } from "@dxos/protocols/proto/dxos/client/services";
|
|
1373
|
-
var
|
|
1296
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/epoch-migrations.ts";
|
|
1374
1297
|
var LOAD_DOC_TIMEOUT = 1e4;
|
|
1375
1298
|
var runEpochMigration = async (ctx, context) => {
|
|
1376
1299
|
switch (context.migration) {
|
|
@@ -1403,7 +1326,7 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
1403
1326
|
// TODO(dmaretskyi): This path doesn't seem to fit here. This is not a migration.
|
|
1404
1327
|
case CreateEpochRequest.Migration.REPLACE_AUTOMERGE_ROOT: {
|
|
1405
1328
|
invariant3(context.newAutomergeRoot, void 0, {
|
|
1406
|
-
F:
|
|
1329
|
+
F: __dxlog_file6,
|
|
1407
1330
|
L: 62,
|
|
1408
1331
|
S: void 0,
|
|
1409
1332
|
A: [
|
|
@@ -1421,12 +1344,12 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
1421
1344
|
};
|
|
1422
1345
|
|
|
1423
1346
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
1424
|
-
import { DeferredTask, Event as Event3, scheduleTask as scheduleTask2, sleep, TimeoutError, Trigger as
|
|
1347
|
+
import { DeferredTask, Event as Event3, scheduleTask as scheduleTask2, sleep, TimeoutError, Trigger as Trigger2, scheduleMicroTask as scheduleMicroTask2 } from "@dxos/async";
|
|
1425
1348
|
import { rejectOnDispose, Resource as Resource3 } from "@dxos/context";
|
|
1426
1349
|
import { verifyCredential as verifyCredential2 } from "@dxos/credentials";
|
|
1427
1350
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
1428
1351
|
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
1429
|
-
import { logInfo as logInfo2, log as
|
|
1352
|
+
import { logInfo as logInfo2, log as log4 } from "@dxos/log";
|
|
1430
1353
|
import { EdgeCallFailedError } from "@dxos/protocols";
|
|
1431
1354
|
import { schema as schema2 } from "@dxos/protocols/proto";
|
|
1432
1355
|
import { RpcExtension } from "@dxos/teleport";
|
|
@@ -1437,7 +1360,7 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
1437
1360
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1438
1361
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1439
1362
|
}
|
|
1440
|
-
var
|
|
1363
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
1441
1364
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
1442
1365
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
1443
1366
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -1463,7 +1386,7 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1463
1386
|
setActiveEdgePollingEnabled(enabled) {
|
|
1464
1387
|
const client = this._edgeClient;
|
|
1465
1388
|
invariant4(client, void 0, {
|
|
1466
|
-
F:
|
|
1389
|
+
F: __dxlog_file7,
|
|
1467
1390
|
L: 111,
|
|
1468
1391
|
S: this,
|
|
1469
1392
|
A: [
|
|
@@ -1501,16 +1424,16 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1501
1424
|
* Request credentials to be notarized.
|
|
1502
1425
|
*/
|
|
1503
1426
|
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY, edgeRetryJitter }) {
|
|
1504
|
-
|
|
1427
|
+
log4("notarize", {
|
|
1505
1428
|
credentials
|
|
1506
1429
|
}, {
|
|
1507
|
-
F:
|
|
1430
|
+
F: __dxlog_file7,
|
|
1508
1431
|
L: 153,
|
|
1509
1432
|
S: this,
|
|
1510
1433
|
C: (f, a) => f(...a)
|
|
1511
1434
|
});
|
|
1512
1435
|
invariant4(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
1513
|
-
F:
|
|
1436
|
+
F: __dxlog_file7,
|
|
1514
1437
|
L: 154,
|
|
1515
1438
|
S: this,
|
|
1516
1439
|
A: [
|
|
@@ -1518,13 +1441,13 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1518
1441
|
"'Credentials must have an id'"
|
|
1519
1442
|
]
|
|
1520
1443
|
});
|
|
1521
|
-
const errors = new
|
|
1444
|
+
const errors = new Trigger2();
|
|
1522
1445
|
const ctx = this._ctx.derive({
|
|
1523
1446
|
onError: (err) => {
|
|
1524
|
-
|
|
1447
|
+
log4.warn("Notarization error", {
|
|
1525
1448
|
err
|
|
1526
1449
|
}, {
|
|
1527
|
-
F:
|
|
1450
|
+
F: __dxlog_file7,
|
|
1528
1451
|
L: 162,
|
|
1529
1452
|
S: this,
|
|
1530
1453
|
C: (f, a) => f(...a)
|
|
@@ -1555,8 +1478,8 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1555
1478
|
allNotarized,
|
|
1556
1479
|
errors.wait()
|
|
1557
1480
|
]);
|
|
1558
|
-
|
|
1559
|
-
F:
|
|
1481
|
+
log4("done", void 0, {
|
|
1482
|
+
F: __dxlog_file7,
|
|
1560
1483
|
L: 187,
|
|
1561
1484
|
S: this,
|
|
1562
1485
|
C: (f, a) => f(...a)
|
|
@@ -1576,10 +1499,10 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1576
1499
|
...this._extensions
|
|
1577
1500
|
].find((peer2) => !peersTried.has(peer2));
|
|
1578
1501
|
if (!peer) {
|
|
1579
|
-
|
|
1502
|
+
log4.info("Exhausted all peers to notarize with", {
|
|
1580
1503
|
retryIn: retryTimeout
|
|
1581
1504
|
}, {
|
|
1582
|
-
F:
|
|
1505
|
+
F: __dxlog_file7,
|
|
1583
1506
|
L: 210,
|
|
1584
1507
|
S: this,
|
|
1585
1508
|
C: (f, a) => f(...a)
|
|
@@ -1589,11 +1512,11 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1589
1512
|
return;
|
|
1590
1513
|
}
|
|
1591
1514
|
peersTried.add(peer);
|
|
1592
|
-
|
|
1515
|
+
log4("try notarizing", {
|
|
1593
1516
|
peer: peer.localPeerId,
|
|
1594
1517
|
credentialId: credentials.map((credential) => credential.id)
|
|
1595
1518
|
}, {
|
|
1596
|
-
F:
|
|
1519
|
+
F: __dxlog_file7,
|
|
1597
1520
|
L: 217,
|
|
1598
1521
|
S: this,
|
|
1599
1522
|
C: (f, a) => f(...a)
|
|
@@ -1601,8 +1524,8 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1601
1524
|
await peer.rpc.NotarizationService.notarize({
|
|
1602
1525
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
1603
1526
|
});
|
|
1604
|
-
|
|
1605
|
-
F:
|
|
1527
|
+
log4("success", void 0, {
|
|
1528
|
+
F: __dxlog_file7,
|
|
1606
1529
|
L: 221,
|
|
1607
1530
|
S: this,
|
|
1608
1531
|
C: (f, a) => f(...a)
|
|
@@ -1610,8 +1533,8 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1610
1533
|
await sleep(successDelay);
|
|
1611
1534
|
} catch (err) {
|
|
1612
1535
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
1613
|
-
|
|
1614
|
-
F:
|
|
1536
|
+
log4.info("error notarizing (recoverable)", err, {
|
|
1537
|
+
F: __dxlog_file7,
|
|
1615
1538
|
L: 226,
|
|
1616
1539
|
S: this,
|
|
1617
1540
|
C: (f, a) => f(...a)
|
|
@@ -1639,8 +1562,8 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1639
1562
|
jitter: timeouts.jitter
|
|
1640
1563
|
}
|
|
1641
1564
|
});
|
|
1642
|
-
|
|
1643
|
-
F:
|
|
1565
|
+
log4("edge notarization success", void 0, {
|
|
1566
|
+
F: __dxlog_file7,
|
|
1644
1567
|
L: 254,
|
|
1645
1568
|
S: this,
|
|
1646
1569
|
C: (f, a) => f(...a)
|
|
@@ -1663,7 +1586,7 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1663
1586
|
}
|
|
1664
1587
|
setWriter(writer) {
|
|
1665
1588
|
invariant4(!this._writer, "Writer already set.", {
|
|
1666
|
-
F:
|
|
1589
|
+
F: __dxlog_file7,
|
|
1667
1590
|
L: 274,
|
|
1668
1591
|
S: this,
|
|
1669
1592
|
A: [
|
|
@@ -1705,18 +1628,18 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1705
1628
|
});
|
|
1706
1629
|
const credentials = response.awaitingNotarization.credentials;
|
|
1707
1630
|
if (!credentials.length) {
|
|
1708
|
-
|
|
1709
|
-
F:
|
|
1631
|
+
log4("edge did not return credentials for notarization", void 0, {
|
|
1632
|
+
F: __dxlog_file7,
|
|
1710
1633
|
L: 311,
|
|
1711
1634
|
S: this,
|
|
1712
1635
|
C: (f, a) => f(...a)
|
|
1713
1636
|
});
|
|
1714
1637
|
return;
|
|
1715
1638
|
}
|
|
1716
|
-
|
|
1639
|
+
log4("got edge credentials for notarization", {
|
|
1717
1640
|
count: credentials.length
|
|
1718
1641
|
}, {
|
|
1719
|
-
F:
|
|
1642
|
+
F: __dxlog_file7,
|
|
1720
1643
|
L: 315,
|
|
1721
1644
|
S: this,
|
|
1722
1645
|
C: (f, a) => f(...a)
|
|
@@ -1726,10 +1649,10 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1726
1649
|
return credentialCodec.decode(binary);
|
|
1727
1650
|
});
|
|
1728
1651
|
await this._notarizeCredentials(writer, decodedCredentials);
|
|
1729
|
-
|
|
1652
|
+
log4.info("notarized edge credentials", {
|
|
1730
1653
|
count: decodedCredentials.length
|
|
1731
1654
|
}, {
|
|
1732
|
-
F:
|
|
1655
|
+
F: __dxlog_file7,
|
|
1733
1656
|
L: 324,
|
|
1734
1657
|
S: this,
|
|
1735
1658
|
C: (f, a) => f(...a)
|
|
@@ -1743,7 +1666,7 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1743
1666
|
if (this._processedCredentials.has(id)) {
|
|
1744
1667
|
return;
|
|
1745
1668
|
}
|
|
1746
|
-
await entry(this._processCredentialsTriggers, id).orInsert(new
|
|
1669
|
+
await entry(this._processCredentialsTriggers, id).orInsert(new Trigger2()).value.wait();
|
|
1747
1670
|
}
|
|
1748
1671
|
/**
|
|
1749
1672
|
* Requests from other peers to notarize credentials.
|
|
@@ -1757,7 +1680,7 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1757
1680
|
async _notarizeCredentials(writer, credentials) {
|
|
1758
1681
|
for (const credential of credentials) {
|
|
1759
1682
|
invariant4(credential.id, "Credential must have an id", {
|
|
1760
|
-
F:
|
|
1683
|
+
F: __dxlog_file7,
|
|
1761
1684
|
L: 350,
|
|
1762
1685
|
S: this,
|
|
1763
1686
|
A: [
|
|
@@ -1778,10 +1701,10 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1778
1701
|
createExtension() {
|
|
1779
1702
|
const extension = new NotarizationTeleportExtension({
|
|
1780
1703
|
onOpen: async () => {
|
|
1781
|
-
|
|
1704
|
+
log4("extension opened", {
|
|
1782
1705
|
peer: extension.localPeerId
|
|
1783
1706
|
}, {
|
|
1784
|
-
F:
|
|
1707
|
+
F: __dxlog_file7,
|
|
1785
1708
|
L: 365,
|
|
1786
1709
|
S: this,
|
|
1787
1710
|
C: (f, a) => f(...a)
|
|
@@ -1790,10 +1713,10 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1790
1713
|
this._extensionOpened.emit();
|
|
1791
1714
|
},
|
|
1792
1715
|
onClose: async () => {
|
|
1793
|
-
|
|
1716
|
+
log4("extension closed", {
|
|
1794
1717
|
peer: extension.localPeerId
|
|
1795
1718
|
}, {
|
|
1796
|
-
F:
|
|
1719
|
+
F: __dxlog_file7,
|
|
1797
1720
|
L: 370,
|
|
1798
1721
|
S: this,
|
|
1799
1722
|
C: (f, a) => f(...a)
|
|
@@ -1806,11 +1729,11 @@ var NotarizationPlugin = class extends Resource3 {
|
|
|
1806
1729
|
}
|
|
1807
1730
|
_scheduleTimeout(ctx, errors, timeout) {
|
|
1808
1731
|
scheduleTask2(ctx, () => {
|
|
1809
|
-
|
|
1732
|
+
log4.warn("Notarization timeout", {
|
|
1810
1733
|
timeout,
|
|
1811
1734
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
1812
1735
|
}, {
|
|
1813
|
-
F:
|
|
1736
|
+
F: __dxlog_file7,
|
|
1814
1737
|
L: 382,
|
|
1815
1738
|
S: this,
|
|
1816
1739
|
C: (f, a) => f(...a)
|
|
@@ -1825,17 +1748,17 @@ _ts_decorate2([
|
|
|
1825
1748
|
], NotarizationPlugin.prototype, "_spaceId", void 0);
|
|
1826
1749
|
var handleEdgeError = (error) => {
|
|
1827
1750
|
if (!(error instanceof EdgeCallFailedError) || error.errorData) {
|
|
1828
|
-
|
|
1829
|
-
F:
|
|
1751
|
+
log4.catch(error, void 0, {
|
|
1752
|
+
F: __dxlog_file7,
|
|
1830
1753
|
L: 396,
|
|
1831
1754
|
S: void 0,
|
|
1832
1755
|
C: (f, a) => f(...a)
|
|
1833
1756
|
});
|
|
1834
1757
|
} else {
|
|
1835
|
-
|
|
1758
|
+
log4.info("Edge notarization failure", {
|
|
1836
1759
|
reason: error.reason
|
|
1837
1760
|
}, {
|
|
1838
|
-
F:
|
|
1761
|
+
F: __dxlog_file7,
|
|
1839
1762
|
L: 398,
|
|
1840
1763
|
S: void 0,
|
|
1841
1764
|
C: (f, a) => f(...a)
|
|
@@ -1878,7 +1801,7 @@ import { Event as Event5 } from "@dxos/async";
|
|
|
1878
1801
|
import { AUTH_TIMEOUT, LOAD_CONTROL_FEEDS_TIMEOUT } from "@dxos/client-protocol";
|
|
1879
1802
|
import { DeviceStateMachine, createCredentialSignerWithKey, createCredentialSignerWithChain, ProfileStateMachine } from "@dxos/credentials";
|
|
1880
1803
|
import { writeMessages as writeMessages3 } from "@dxos/feed-store";
|
|
1881
|
-
import { invariant as
|
|
1804
|
+
import { invariant as invariant8 } from "@dxos/invariant";
|
|
1882
1805
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
1883
1806
|
import { log as log9 } from "@dxos/log";
|
|
1884
1807
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
@@ -1889,8 +1812,8 @@ import { ComplexSet as ComplexSet2 } from "@dxos/util";
|
|
|
1889
1812
|
// packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts
|
|
1890
1813
|
import { getCredentialAssertion } from "@dxos/credentials";
|
|
1891
1814
|
import { SpaceId } from "@dxos/keys";
|
|
1892
|
-
import { log as
|
|
1893
|
-
var
|
|
1815
|
+
import { log as log5 } from "@dxos/log";
|
|
1816
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/default-space-state-machine.ts";
|
|
1894
1817
|
var DefaultSpaceStateMachine = class {
|
|
1895
1818
|
constructor(_params) {
|
|
1896
1819
|
this._params = _params;
|
|
@@ -1903,11 +1826,11 @@ var DefaultSpaceStateMachine = class {
|
|
|
1903
1826
|
switch (assertion["@type"]) {
|
|
1904
1827
|
case "dxos.halo.credentials.DefaultSpace": {
|
|
1905
1828
|
if (!credential.subject.id.equals(this._params.identityKey)) {
|
|
1906
|
-
|
|
1829
|
+
log5.warn("Invalid default space credential", {
|
|
1907
1830
|
expectedIdentity: this._params.identityKey,
|
|
1908
1831
|
credential
|
|
1909
1832
|
}, {
|
|
1910
|
-
F:
|
|
1833
|
+
F: __dxlog_file8,
|
|
1911
1834
|
L: 32,
|
|
1912
1835
|
S: this,
|
|
1913
1836
|
C: (f, a) => f(...a)
|
|
@@ -1915,10 +1838,10 @@ var DefaultSpaceStateMachine = class {
|
|
|
1915
1838
|
return;
|
|
1916
1839
|
}
|
|
1917
1840
|
if (!SpaceId.isValid(assertion.spaceId)) {
|
|
1918
|
-
|
|
1841
|
+
log5.warn("Invalid default space id", {
|
|
1919
1842
|
id: assertion.spaceId
|
|
1920
1843
|
}, {
|
|
1921
|
-
F:
|
|
1844
|
+
F: __dxlog_file8,
|
|
1922
1845
|
L: 36,
|
|
1923
1846
|
S: this,
|
|
1924
1847
|
C: (f, a) => f(...a)
|
|
@@ -1934,16 +1857,17 @@ var DefaultSpaceStateMachine = class {
|
|
|
1934
1857
|
|
|
1935
1858
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
1936
1859
|
import { Event as Event4, synchronized, trackLeaks } from "@dxos/async";
|
|
1860
|
+
import { interpretAsDocumentId } from "@dxos/automerge/automerge-repo";
|
|
1937
1861
|
import { PropertiesType, TYPE_PROPERTIES } from "@dxos/client-protocol";
|
|
1938
|
-
import { LifecycleState, Resource as Resource4, cancelWithContext } from "@dxos/context";
|
|
1862
|
+
import { Context as Context4, LifecycleState, Resource as Resource4, cancelWithContext } from "@dxos/context";
|
|
1939
1863
|
import { createAdmissionCredentials, getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
1940
|
-
import { findInlineObjectOfType, AuthStatus, CredentialServerExtension } from "@dxos/echo-pipeline";
|
|
1941
|
-
import { SpaceDocVersion, encodeReference } from "@dxos/echo-protocol";
|
|
1864
|
+
import { DatabaseRoot, findInlineObjectOfType, AuthStatus, CredentialServerExtension } from "@dxos/echo-pipeline";
|
|
1865
|
+
import { SpaceDocVersion, createIdFromSpaceKey, encodeReference } from "@dxos/echo-protocol";
|
|
1942
1866
|
import { createObjectId, getTypeReference } from "@dxos/echo-schema";
|
|
1943
1867
|
import { writeMessages } from "@dxos/feed-store";
|
|
1944
|
-
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1868
|
+
import { assertArgument, assertState, failedInvariant, invariant as invariant5 } from "@dxos/invariant";
|
|
1945
1869
|
import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
1946
|
-
import { log as
|
|
1870
|
+
import { log as log6 } from "@dxos/log";
|
|
1947
1871
|
import { AlreadyJoinedError, trace as Trace } from "@dxos/protocols";
|
|
1948
1872
|
import { Invitation, SpaceState } from "@dxos/protocols/proto/dxos/client/services";
|
|
1949
1873
|
import { EdgeReplicationSetting } from "@dxos/protocols/proto/dxos/echo/metadata";
|
|
@@ -2029,7 +1953,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
2029
1953
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2030
1954
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2031
1955
|
}
|
|
2032
|
-
var
|
|
1956
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
2033
1957
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
2034
1958
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
2035
1959
|
var DEFAULT_SPACE_KEY = "__DEFAULT__";
|
|
@@ -2085,66 +2009,71 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2085
2009
|
get spaces() {
|
|
2086
2010
|
return this._spaces;
|
|
2087
2011
|
}
|
|
2012
|
+
getSpaceById(spaceId) {
|
|
2013
|
+
return [
|
|
2014
|
+
...this._spaces.values()
|
|
2015
|
+
].find((space) => space.id === spaceId);
|
|
2016
|
+
}
|
|
2088
2017
|
async _open() {
|
|
2089
|
-
|
|
2090
|
-
F:
|
|
2091
|
-
L:
|
|
2018
|
+
log6("open", void 0, {
|
|
2019
|
+
F: __dxlog_file9,
|
|
2020
|
+
L: 213,
|
|
2092
2021
|
S: this,
|
|
2093
2022
|
C: (f, a) => f(...a)
|
|
2094
2023
|
});
|
|
2095
|
-
|
|
2024
|
+
log6.trace("dxos.echo.data-space-manager.open", Trace.begin({
|
|
2096
2025
|
id: this._instanceId
|
|
2097
2026
|
}), {
|
|
2098
|
-
F:
|
|
2099
|
-
L:
|
|
2027
|
+
F: __dxlog_file9,
|
|
2028
|
+
L: 214,
|
|
2100
2029
|
S: this,
|
|
2101
2030
|
C: (f, a) => f(...a)
|
|
2102
2031
|
});
|
|
2103
|
-
|
|
2032
|
+
log6("metadata loaded", {
|
|
2104
2033
|
spaces: this._metadataStore.spaces.length
|
|
2105
2034
|
}, {
|
|
2106
|
-
F:
|
|
2107
|
-
L:
|
|
2035
|
+
F: __dxlog_file9,
|
|
2036
|
+
L: 215,
|
|
2108
2037
|
S: this,
|
|
2109
2038
|
C: (f, a) => f(...a)
|
|
2110
2039
|
});
|
|
2111
2040
|
await forEachAsync(this._metadataStore.spaces, async (spaceMetadata) => {
|
|
2112
2041
|
try {
|
|
2113
|
-
|
|
2042
|
+
log6("load space", {
|
|
2114
2043
|
spaceMetadata
|
|
2115
2044
|
}, {
|
|
2116
|
-
F:
|
|
2117
|
-
L:
|
|
2045
|
+
F: __dxlog_file9,
|
|
2046
|
+
L: 219,
|
|
2118
2047
|
S: this,
|
|
2119
2048
|
C: (f, a) => f(...a)
|
|
2120
2049
|
});
|
|
2121
2050
|
await this._constructSpace(spaceMetadata);
|
|
2122
2051
|
} catch (err) {
|
|
2123
|
-
|
|
2052
|
+
log6.error("Error loading space", {
|
|
2124
2053
|
spaceMetadata,
|
|
2125
2054
|
err
|
|
2126
2055
|
}, {
|
|
2127
|
-
F:
|
|
2128
|
-
L:
|
|
2056
|
+
F: __dxlog_file9,
|
|
2057
|
+
L: 222,
|
|
2129
2058
|
S: this,
|
|
2130
2059
|
C: (f, a) => f(...a)
|
|
2131
2060
|
});
|
|
2132
2061
|
}
|
|
2133
2062
|
});
|
|
2134
2063
|
this.updated.emit();
|
|
2135
|
-
|
|
2064
|
+
log6.trace("dxos.echo.data-space-manager.open", Trace.end({
|
|
2136
2065
|
id: this._instanceId
|
|
2137
2066
|
}), {
|
|
2138
|
-
F:
|
|
2139
|
-
L:
|
|
2067
|
+
F: __dxlog_file9,
|
|
2068
|
+
L: 228,
|
|
2140
2069
|
S: this,
|
|
2141
2070
|
C: (f, a) => f(...a)
|
|
2142
2071
|
});
|
|
2143
2072
|
}
|
|
2144
2073
|
async _close() {
|
|
2145
|
-
|
|
2146
|
-
F:
|
|
2147
|
-
L:
|
|
2074
|
+
log6("close", void 0, {
|
|
2075
|
+
F: __dxlog_file9,
|
|
2076
|
+
L: 233,
|
|
2148
2077
|
S: this,
|
|
2149
2078
|
C: (f, a) => f(...a)
|
|
2150
2079
|
});
|
|
@@ -2156,19 +2085,13 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2156
2085
|
/**
|
|
2157
2086
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
2158
2087
|
*/
|
|
2159
|
-
async createSpace() {
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
L: 224,
|
|
2163
|
-
S: this,
|
|
2164
|
-
A: [
|
|
2165
|
-
"this._lifecycleState === LifecycleState.OPEN",
|
|
2166
|
-
"'Not open.'"
|
|
2167
|
-
]
|
|
2168
|
-
});
|
|
2088
|
+
async createSpace(options = {}) {
|
|
2089
|
+
assertArgument(!!options.rootUrl === !!options.documents, "root url must be required when providing documents");
|
|
2090
|
+
assertState(this._lifecycleState === LifecycleState.OPEN, "Not open.");
|
|
2169
2091
|
const spaceKey = await this._keyring.createKey();
|
|
2170
2092
|
const controlFeedKey = await this._keyring.createKey();
|
|
2171
2093
|
const dataFeedKey = await this._keyring.createKey();
|
|
2094
|
+
const spaceId = await createIdFromSpaceKey(spaceKey);
|
|
2172
2095
|
const metadata = {
|
|
2173
2096
|
key: spaceKey,
|
|
2174
2097
|
genesisFeedKey: controlFeedKey,
|
|
@@ -2176,23 +2099,85 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2176
2099
|
dataFeedKey,
|
|
2177
2100
|
state: SpaceState.SPACE_ACTIVE
|
|
2178
2101
|
};
|
|
2179
|
-
|
|
2102
|
+
log6.info("creating space...", {
|
|
2103
|
+
spaceId,
|
|
2180
2104
|
spaceKey
|
|
2181
2105
|
}, {
|
|
2182
|
-
F:
|
|
2183
|
-
L:
|
|
2106
|
+
F: __dxlog_file9,
|
|
2107
|
+
L: 262,
|
|
2108
|
+
S: this,
|
|
2109
|
+
C: (f, a) => f(...a)
|
|
2110
|
+
});
|
|
2111
|
+
const documentIdMapping = {};
|
|
2112
|
+
if (options.documents) {
|
|
2113
|
+
invariant5(Object.keys(options.documents).every((documentId) => /^[a-zA-Z0-9]+$/.test(documentId)), "Invalid document IDs", {
|
|
2114
|
+
F: __dxlog_file9,
|
|
2115
|
+
L: 267,
|
|
2116
|
+
S: this,
|
|
2117
|
+
A: [
|
|
2118
|
+
"Object.keys(options.documents).every((documentId) => /^[a-zA-Z0-9]+$/.test(documentId))",
|
|
2119
|
+
"'Invalid document IDs'"
|
|
2120
|
+
]
|
|
2121
|
+
});
|
|
2122
|
+
await Promise.all(Object.entries(options.documents).map(async ([documentId, data]) => {
|
|
2123
|
+
log6("creating document...", {
|
|
2124
|
+
documentId
|
|
2125
|
+
}, {
|
|
2126
|
+
F: __dxlog_file9,
|
|
2127
|
+
L: 274,
|
|
2128
|
+
S: this,
|
|
2129
|
+
C: (f, a) => f(...a)
|
|
2130
|
+
});
|
|
2131
|
+
const newDoc = await this._echoHost.createDoc(data, {
|
|
2132
|
+
preserveHistory: true
|
|
2133
|
+
});
|
|
2134
|
+
documentIdMapping[documentId] = newDoc.documentId;
|
|
2135
|
+
}));
|
|
2136
|
+
}
|
|
2137
|
+
log6("opening space...", {
|
|
2138
|
+
spaceKey
|
|
2139
|
+
}, {
|
|
2140
|
+
F: __dxlog_file9,
|
|
2141
|
+
L: 281,
|
|
2142
|
+
S: this,
|
|
2143
|
+
C: (f, a) => f(...a)
|
|
2144
|
+
});
|
|
2145
|
+
let root;
|
|
2146
|
+
if (options.rootUrl) {
|
|
2147
|
+
const newRootDocId = documentIdMapping[interpretAsDocumentId(options.rootUrl)] ?? failedInvariant();
|
|
2148
|
+
const rootDocHandle = await this._echoHost.loadDoc(Context4.default(void 0, {
|
|
2149
|
+
F: __dxlog_file9,
|
|
2150
|
+
L: 286
|
|
2151
|
+
}), newRootDocId);
|
|
2152
|
+
DatabaseRoot.mapLinks(rootDocHandle, documentIdMapping);
|
|
2153
|
+
root = await this._echoHost.openSpaceRoot(spaceId, `automerge:${newRootDocId}`);
|
|
2154
|
+
} else {
|
|
2155
|
+
root = await this._echoHost.createSpaceRoot(spaceKey);
|
|
2156
|
+
}
|
|
2157
|
+
log6("constructing space...", {
|
|
2158
|
+
spaceKey
|
|
2159
|
+
}, {
|
|
2160
|
+
F: __dxlog_file9,
|
|
2161
|
+
L: 294,
|
|
2184
2162
|
S: this,
|
|
2185
2163
|
C: (f, a) => f(...a)
|
|
2186
2164
|
});
|
|
2187
|
-
const root = await this._echoHost.createSpaceRoot(spaceKey);
|
|
2188
2165
|
const space = await this._constructSpace(metadata);
|
|
2189
2166
|
await space.open();
|
|
2167
|
+
log6("adding space...", {
|
|
2168
|
+
spaceKey
|
|
2169
|
+
}, {
|
|
2170
|
+
F: __dxlog_file9,
|
|
2171
|
+
L: 299,
|
|
2172
|
+
S: this,
|
|
2173
|
+
C: (f, a) => f(...a)
|
|
2174
|
+
});
|
|
2190
2175
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, root.url);
|
|
2191
2176
|
await this._metadataStore.addSpace(metadata);
|
|
2192
2177
|
const memberCredential = credentials[1];
|
|
2193
2178
|
invariant5(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2194
|
-
F:
|
|
2195
|
-
L:
|
|
2179
|
+
F: __dxlog_file9,
|
|
2180
|
+
L: 305,
|
|
2196
2181
|
S: this,
|
|
2197
2182
|
A: [
|
|
2198
2183
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2201,6 +2186,15 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2201
2186
|
});
|
|
2202
2187
|
await this._signingContext.recordCredential(memberCredential);
|
|
2203
2188
|
await space.initializeDataPipeline();
|
|
2189
|
+
log6("space ready.", {
|
|
2190
|
+
spaceId,
|
|
2191
|
+
spaceKey
|
|
2192
|
+
}, {
|
|
2193
|
+
F: __dxlog_file9,
|
|
2194
|
+
L: 310,
|
|
2195
|
+
S: this,
|
|
2196
|
+
C: (f, a) => f(...a)
|
|
2197
|
+
});
|
|
2204
2198
|
this.updated.emit();
|
|
2205
2199
|
return space;
|
|
2206
2200
|
}
|
|
@@ -2217,12 +2211,12 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2217
2211
|
throw new Error("Legacy space version is not supported");
|
|
2218
2212
|
}
|
|
2219
2213
|
default:
|
|
2220
|
-
|
|
2214
|
+
log6.warn("unknown space version", {
|
|
2221
2215
|
version: space.databaseRoot.getVersion(),
|
|
2222
2216
|
spaceId: space.id
|
|
2223
2217
|
}, {
|
|
2224
|
-
F:
|
|
2225
|
-
L:
|
|
2218
|
+
F: __dxlog_file9,
|
|
2219
|
+
L: 330,
|
|
2226
2220
|
S: this,
|
|
2227
2221
|
C: (f, a) => f(...a)
|
|
2228
2222
|
});
|
|
@@ -2256,8 +2250,8 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2256
2250
|
async _getSpaceRootDocument(space) {
|
|
2257
2251
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
2258
2252
|
invariant5(automergeIndex, void 0, {
|
|
2259
|
-
F:
|
|
2260
|
-
L:
|
|
2253
|
+
F: __dxlog_file9,
|
|
2254
|
+
L: 363,
|
|
2261
2255
|
S: this,
|
|
2262
2256
|
A: [
|
|
2263
2257
|
"automergeIndex",
|
|
@@ -2270,17 +2264,17 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2270
2264
|
}
|
|
2271
2265
|
// TODO(burdon): Rename join space.
|
|
2272
2266
|
async acceptSpace(opts) {
|
|
2273
|
-
|
|
2267
|
+
log6("accept space", {
|
|
2274
2268
|
opts
|
|
2275
2269
|
}, {
|
|
2276
|
-
F:
|
|
2277
|
-
L:
|
|
2270
|
+
F: __dxlog_file9,
|
|
2271
|
+
L: 372,
|
|
2278
2272
|
S: this,
|
|
2279
2273
|
C: (f, a) => f(...a)
|
|
2280
2274
|
});
|
|
2281
2275
|
invariant5(this._lifecycleState === LifecycleState.OPEN, "Not open.", {
|
|
2282
|
-
F:
|
|
2283
|
-
L:
|
|
2276
|
+
F: __dxlog_file9,
|
|
2277
|
+
L: 373,
|
|
2284
2278
|
S: this,
|
|
2285
2279
|
A: [
|
|
2286
2280
|
"this._lifecycleState === LifecycleState.OPEN",
|
|
@@ -2288,8 +2282,8 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2288
2282
|
]
|
|
2289
2283
|
});
|
|
2290
2284
|
invariant5(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
2291
|
-
F:
|
|
2292
|
-
L:
|
|
2285
|
+
F: __dxlog_file9,
|
|
2286
|
+
L: 374,
|
|
2293
2287
|
S: this,
|
|
2294
2288
|
A: [
|
|
2295
2289
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -2312,8 +2306,8 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2312
2306
|
async admitMember(options) {
|
|
2313
2307
|
const space = this._spaceManager.spaces.get(options.spaceKey);
|
|
2314
2308
|
invariant5(space, void 0, {
|
|
2315
|
-
F:
|
|
2316
|
-
L:
|
|
2309
|
+
F: __dxlog_file9,
|
|
2310
|
+
L: 394,
|
|
2317
2311
|
S: this,
|
|
2318
2312
|
A: [
|
|
2319
2313
|
"space",
|
|
@@ -2325,8 +2319,8 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2325
2319
|
}
|
|
2326
2320
|
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
|
|
2327
2321
|
invariant5(credentials[0].credential, void 0, {
|
|
2328
|
-
F:
|
|
2329
|
-
L:
|
|
2322
|
+
F: __dxlog_file9,
|
|
2323
|
+
L: 413,
|
|
2330
2324
|
S: this,
|
|
2331
2325
|
A: [
|
|
2332
2326
|
"credentials[0].credential",
|
|
@@ -2335,8 +2329,8 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2335
2329
|
});
|
|
2336
2330
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2337
2331
|
invariant5(getCredentialAssertion2(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2338
|
-
F:
|
|
2339
|
-
L:
|
|
2332
|
+
F: __dxlog_file9,
|
|
2333
|
+
L: 415,
|
|
2340
2334
|
S: this,
|
|
2341
2335
|
A: [
|
|
2342
2336
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2373,8 +2367,8 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2373
2367
|
async setSpaceEdgeReplicationSetting(spaceKey, setting) {
|
|
2374
2368
|
const space = this._spaces.get(spaceKey);
|
|
2375
2369
|
invariant5(space, "Space not found.", {
|
|
2376
|
-
F:
|
|
2377
|
-
L:
|
|
2370
|
+
F: __dxlog_file9,
|
|
2371
|
+
L: 452,
|
|
2378
2372
|
S: this,
|
|
2379
2373
|
A: [
|
|
2380
2374
|
"space",
|
|
@@ -2395,11 +2389,11 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2395
2389
|
space.stateUpdate.emit();
|
|
2396
2390
|
}
|
|
2397
2391
|
async _constructSpace(metadata) {
|
|
2398
|
-
|
|
2392
|
+
log6("construct space", {
|
|
2399
2393
|
metadata
|
|
2400
2394
|
}, {
|
|
2401
|
-
F:
|
|
2402
|
-
L:
|
|
2395
|
+
F: __dxlog_file9,
|
|
2396
|
+
L: 471,
|
|
2403
2397
|
S: this,
|
|
2404
2398
|
C: (f, a) => f(...a)
|
|
2405
2399
|
});
|
|
@@ -2439,11 +2433,11 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2439
2433
|
session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
|
|
2440
2434
|
await this._connectEchoMeshReplicator(space, session);
|
|
2441
2435
|
} catch (err) {
|
|
2442
|
-
|
|
2436
|
+
log6.warn("error on authorized connection", {
|
|
2443
2437
|
err
|
|
2444
2438
|
}, {
|
|
2445
|
-
F:
|
|
2446
|
-
L:
|
|
2439
|
+
F: __dxlog_file9,
|
|
2440
|
+
L: 513,
|
|
2447
2441
|
S: this,
|
|
2448
2442
|
C: (f, a) => f(...a)
|
|
2449
2443
|
});
|
|
@@ -2451,9 +2445,9 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2451
2445
|
}
|
|
2452
2446
|
}),
|
|
2453
2447
|
onAuthFailure: () => {
|
|
2454
|
-
|
|
2455
|
-
F:
|
|
2456
|
-
L:
|
|
2448
|
+
log6.warn("auth failure", void 0, {
|
|
2449
|
+
F: __dxlog_file9,
|
|
2450
|
+
L: 518,
|
|
2457
2451
|
S: this,
|
|
2458
2452
|
C: (f, a) => f(...a)
|
|
2459
2453
|
});
|
|
@@ -2482,22 +2476,22 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2482
2476
|
signingContext: this._signingContext,
|
|
2483
2477
|
callbacks: {
|
|
2484
2478
|
beforeReady: async () => {
|
|
2485
|
-
|
|
2479
|
+
log6("before space ready", {
|
|
2486
2480
|
space: space.key
|
|
2487
2481
|
}, {
|
|
2488
|
-
F:
|
|
2489
|
-
L:
|
|
2482
|
+
F: __dxlog_file9,
|
|
2483
|
+
L: 545,
|
|
2490
2484
|
S: this,
|
|
2491
2485
|
C: (f, a) => f(...a)
|
|
2492
2486
|
});
|
|
2493
2487
|
},
|
|
2494
2488
|
afterReady: async () => {
|
|
2495
|
-
|
|
2489
|
+
log6("after space ready", {
|
|
2496
2490
|
space: space.key,
|
|
2497
2491
|
open: this._lifecycleState === LifecycleState.OPEN
|
|
2498
2492
|
}, {
|
|
2499
|
-
F:
|
|
2500
|
-
L:
|
|
2493
|
+
F: __dxlog_file9,
|
|
2494
|
+
L: 548,
|
|
2501
2495
|
S: this,
|
|
2502
2496
|
C: (f, a) => f(...a)
|
|
2503
2497
|
});
|
|
@@ -2512,11 +2506,11 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2512
2506
|
}
|
|
2513
2507
|
},
|
|
2514
2508
|
beforeClose: async () => {
|
|
2515
|
-
|
|
2509
|
+
log6("before space close", {
|
|
2516
2510
|
space: space.key
|
|
2517
2511
|
}, {
|
|
2518
|
-
F:
|
|
2519
|
-
L:
|
|
2512
|
+
F: __dxlog_file9,
|
|
2513
|
+
L: 556,
|
|
2520
2514
|
S: this,
|
|
2521
2515
|
C: (f, a) => f(...a)
|
|
2522
2516
|
});
|
|
@@ -2533,11 +2527,11 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2533
2527
|
if (!setting || setting === EdgeReplicationSetting.ENABLED) {
|
|
2534
2528
|
await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
|
|
2535
2529
|
} else if (this._echoEdgeReplicator) {
|
|
2536
|
-
|
|
2530
|
+
log6("not connecting EchoEdgeReplicator because of EdgeReplicationSetting", {
|
|
2537
2531
|
spaceId: dataSpace.id
|
|
2538
2532
|
}, {
|
|
2539
|
-
F:
|
|
2540
|
-
L:
|
|
2533
|
+
F: __dxlog_file9,
|
|
2534
|
+
L: 570,
|
|
2541
2535
|
S: this,
|
|
2542
2536
|
C: (f, a) => f(...a)
|
|
2543
2537
|
});
|
|
@@ -2563,11 +2557,11 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2563
2557
|
async _connectEchoMeshReplicator(space, session) {
|
|
2564
2558
|
const replicator = this._meshReplicator;
|
|
2565
2559
|
if (!replicator) {
|
|
2566
|
-
|
|
2560
|
+
log6.warn("p2p automerge replication disabled", {
|
|
2567
2561
|
space: space.key
|
|
2568
2562
|
}, {
|
|
2569
|
-
F:
|
|
2570
|
-
L:
|
|
2563
|
+
F: __dxlog_file9,
|
|
2564
|
+
L: 597,
|
|
2571
2565
|
S: this,
|
|
2572
2566
|
C: (f, a) => f(...a)
|
|
2573
2567
|
});
|
|
@@ -2590,17 +2584,17 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2590
2584
|
return (s && member.role === SpaceMember3.Role.REMOVED !== (s.authStatus === AuthStatus.FAILURE)) ?? false;
|
|
2591
2585
|
});
|
|
2592
2586
|
sessionsToClose.forEach((session) => {
|
|
2593
|
-
void session.close().catch(
|
|
2587
|
+
void session.close().catch(log6.error);
|
|
2594
2588
|
});
|
|
2595
2589
|
closedSessions += sessionsToClose.length;
|
|
2596
2590
|
}
|
|
2597
|
-
|
|
2591
|
+
log6("processed member role changes", {
|
|
2598
2592
|
roleChangeCount: memberInfo.length,
|
|
2599
2593
|
peersOnline: presence.getPeersOnline().length,
|
|
2600
2594
|
closedSessions
|
|
2601
2595
|
}, {
|
|
2602
|
-
F:
|
|
2603
|
-
L:
|
|
2596
|
+
F: __dxlog_file9,
|
|
2597
|
+
L: 623,
|
|
2604
2598
|
S: this,
|
|
2605
2599
|
C: (f, a) => f(...a)
|
|
2606
2600
|
});
|
|
@@ -2611,15 +2605,15 @@ var DataSpaceManager = class extends Resource4 {
|
|
|
2611
2605
|
if (role === SpaceMember3.Role.REMOVED) {
|
|
2612
2606
|
const session = peerState.peerId && space.protocol.sessions.get(peerState.peerId);
|
|
2613
2607
|
if (session != null) {
|
|
2614
|
-
|
|
2608
|
+
log6("closing a session with a removed peer", {
|
|
2615
2609
|
peerId: peerState.peerId
|
|
2616
2610
|
}, {
|
|
2617
|
-
F:
|
|
2618
|
-
L:
|
|
2611
|
+
F: __dxlog_file9,
|
|
2612
|
+
L: 637,
|
|
2619
2613
|
S: this,
|
|
2620
2614
|
C: (f, a) => f(...a)
|
|
2621
2615
|
});
|
|
2622
|
-
void session.close().catch(
|
|
2616
|
+
void session.close().catch(log6.error);
|
|
2623
2617
|
}
|
|
2624
2618
|
}
|
|
2625
2619
|
}
|
|
@@ -2681,11 +2675,172 @@ import { Stream as Stream7 } from "@dxos/codec-protobuf/stream";
|
|
|
2681
2675
|
import { createAdmissionCredentials as createAdmissionCredentials2, createDidFromIdentityKey as createDidFromIdentityKey2, getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
|
|
2682
2676
|
import { raise } from "@dxos/debug";
|
|
2683
2677
|
import { writeMessages as writeMessages2 } from "@dxos/feed-store";
|
|
2684
|
-
import { invariant as
|
|
2678
|
+
import { assertArgument as assertArgument4, assertState as assertState3, invariant as invariant7 } from "@dxos/invariant";
|
|
2679
|
+
import { SpaceId as SpaceId2 } from "@dxos/keys";
|
|
2685
2680
|
import { log as log8 } from "@dxos/log";
|
|
2686
2681
|
import { ApiError, SpaceNotFoundError, encodeError, IdentityNotInitializedError, AuthorizationError } from "@dxos/protocols";
|
|
2687
2682
|
import { SpaceMember as SpaceMember4, SpaceState as SpaceState2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
2688
2683
|
import { trace as trace2 } from "@dxos/tracing";
|
|
2684
|
+
|
|
2685
|
+
// packages/sdk/client-services/src/packlets/space-export/space-archive-writer.ts
|
|
2686
|
+
import { Resource as Resource5 } from "@dxos/context";
|
|
2687
|
+
import { assertArgument as assertArgument2, assertState as assertState2 } from "@dxos/invariant";
|
|
2688
|
+
import { SpaceArchiveFileStructure, SpaceArchiveVersion } from "@dxos/protocols";
|
|
2689
|
+
var CURRENT_VERSION = SpaceArchiveVersion.V1;
|
|
2690
|
+
var SpaceArchiveWriter = class extends Resource5 {
|
|
2691
|
+
constructor() {
|
|
2692
|
+
super(...arguments);
|
|
2693
|
+
this._meta = void 0;
|
|
2694
|
+
this._currentRootUrl = void 0;
|
|
2695
|
+
}
|
|
2696
|
+
async _open(ctx) {
|
|
2697
|
+
this._tar = await import("@obsidize/tar-browserify");
|
|
2698
|
+
}
|
|
2699
|
+
async _close() {
|
|
2700
|
+
return Promise.resolve();
|
|
2701
|
+
}
|
|
2702
|
+
async begin(meta) {
|
|
2703
|
+
assertState2(this._tar, "Not open");
|
|
2704
|
+
assertState2(!this._meta, "Already started");
|
|
2705
|
+
this._meta = meta;
|
|
2706
|
+
this._archive = new this._tar.Archive();
|
|
2707
|
+
}
|
|
2708
|
+
async setCurrentRootUrl(url) {
|
|
2709
|
+
assertArgument2(url.startsWith("automerge:"), "Invalid root URL");
|
|
2710
|
+
assertState2(this._tar, "Not open");
|
|
2711
|
+
assertState2(this._meta, "Not started");
|
|
2712
|
+
this._currentRootUrl = url;
|
|
2713
|
+
}
|
|
2714
|
+
async writeDocument(documentId, data) {
|
|
2715
|
+
assertArgument2(!documentId.startsWith("automerge:"), "Invalid document ID");
|
|
2716
|
+
assertState2(this._archive, "Not open");
|
|
2717
|
+
this._archive.addBinaryFile(`${SpaceArchiveFileStructure.documents}/${documentId}.bin`, data);
|
|
2718
|
+
}
|
|
2719
|
+
async finish() {
|
|
2720
|
+
assertState2(this._archive, "Not open");
|
|
2721
|
+
assertState2(this._meta, "Not started");
|
|
2722
|
+
assertState2(this._currentRootUrl, "No root URL set");
|
|
2723
|
+
const metadata = {
|
|
2724
|
+
version: CURRENT_VERSION,
|
|
2725
|
+
createdAt: Date.now(),
|
|
2726
|
+
exportedBy: this._meta.exportedBy,
|
|
2727
|
+
originalSpaceId: this._meta.spaceId,
|
|
2728
|
+
echo: {
|
|
2729
|
+
currentRootUrl: this._currentRootUrl
|
|
2730
|
+
}
|
|
2731
|
+
};
|
|
2732
|
+
this._archive.addTextFile(SpaceArchiveFileStructure.metadata, JSON.stringify(metadata));
|
|
2733
|
+
const binary = this._archive.toUint8Array();
|
|
2734
|
+
return {
|
|
2735
|
+
filename: `${this._meta.spaceId}.tar`,
|
|
2736
|
+
contents: binary
|
|
2737
|
+
};
|
|
2738
|
+
}
|
|
2739
|
+
};
|
|
2740
|
+
|
|
2741
|
+
// packages/sdk/client-services/src/packlets/space-export/space-archive-reader.ts
|
|
2742
|
+
import { assertArgument as assertArgument3, failedInvariant as failedInvariant2, invariant as invariant6 } from "@dxos/invariant";
|
|
2743
|
+
import { log as log7 } from "@dxos/log";
|
|
2744
|
+
import { SpaceArchiveFileStructure as SpaceArchiveFileStructure2 } from "@dxos/protocols";
|
|
2745
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/space-export/space-archive-reader.ts";
|
|
2746
|
+
var extractSpaceArchive = async (archive) => {
|
|
2747
|
+
const { Archive } = await import("@obsidize/tar-browserify");
|
|
2748
|
+
const { entries } = await Archive.extract(archive.contents);
|
|
2749
|
+
const metadataEntry = entries.find((entry2) => entry2.fileName === SpaceArchiveFileStructure2.metadata);
|
|
2750
|
+
assertArgument3(metadataEntry, "Metadata entry not found");
|
|
2751
|
+
const metadata = JSON.parse(metadataEntry.getContentAsText());
|
|
2752
|
+
const documents = {};
|
|
2753
|
+
for (const entry2 of entries.filter((entry3) => entry3.fileName.startsWith(`${SpaceArchiveFileStructure2.documents}/`))) {
|
|
2754
|
+
const documentId = entry2.fileName.replace(`${SpaceArchiveFileStructure2.documents}/`, "").replace(/\.bin$/, "");
|
|
2755
|
+
invariant6(!documentId.includes("/"), void 0, {
|
|
2756
|
+
F: __dxlog_file10,
|
|
2757
|
+
L: 27,
|
|
2758
|
+
S: void 0,
|
|
2759
|
+
A: [
|
|
2760
|
+
"!documentId.includes('/')",
|
|
2761
|
+
""
|
|
2762
|
+
]
|
|
2763
|
+
});
|
|
2764
|
+
documents[documentId] = entry2.content ?? failedInvariant2();
|
|
2765
|
+
}
|
|
2766
|
+
log7.info("extracted space archive", {
|
|
2767
|
+
metadata,
|
|
2768
|
+
documents
|
|
2769
|
+
}, {
|
|
2770
|
+
F: __dxlog_file10,
|
|
2771
|
+
L: 31,
|
|
2772
|
+
S: void 0,
|
|
2773
|
+
C: (f, a) => f(...a)
|
|
2774
|
+
});
|
|
2775
|
+
return {
|
|
2776
|
+
metadata,
|
|
2777
|
+
documents
|
|
2778
|
+
};
|
|
2779
|
+
};
|
|
2780
|
+
|
|
2781
|
+
// packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
|
|
2782
|
+
function _using_ctx2() {
|
|
2783
|
+
var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
|
|
2784
|
+
var err = new Error();
|
|
2785
|
+
err.name = "SuppressedError";
|
|
2786
|
+
err.suppressed = suppressed;
|
|
2787
|
+
err.error = error;
|
|
2788
|
+
return err;
|
|
2789
|
+
}, empty = {}, stack = [];
|
|
2790
|
+
function using(isAwait, value) {
|
|
2791
|
+
if (value != null) {
|
|
2792
|
+
if (Object(value) !== value) {
|
|
2793
|
+
throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
|
2794
|
+
}
|
|
2795
|
+
if (isAwait) {
|
|
2796
|
+
var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
|
|
2797
|
+
}
|
|
2798
|
+
if (dispose == null) {
|
|
2799
|
+
dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
|
|
2800
|
+
}
|
|
2801
|
+
if (typeof dispose !== "function") {
|
|
2802
|
+
throw new TypeError(`Property [Symbol.dispose] is not a function.`);
|
|
2803
|
+
}
|
|
2804
|
+
stack.push({
|
|
2805
|
+
v: value,
|
|
2806
|
+
d: dispose,
|
|
2807
|
+
a: isAwait
|
|
2808
|
+
});
|
|
2809
|
+
} else if (isAwait) {
|
|
2810
|
+
stack.push({
|
|
2811
|
+
d: value,
|
|
2812
|
+
a: isAwait
|
|
2813
|
+
});
|
|
2814
|
+
}
|
|
2815
|
+
return value;
|
|
2816
|
+
}
|
|
2817
|
+
return {
|
|
2818
|
+
e: empty,
|
|
2819
|
+
u: using.bind(null, false),
|
|
2820
|
+
a: using.bind(null, true),
|
|
2821
|
+
d: function() {
|
|
2822
|
+
var error = this.e;
|
|
2823
|
+
function next() {
|
|
2824
|
+
while (resource = stack.pop()) {
|
|
2825
|
+
try {
|
|
2826
|
+
var resource, disposalResult = resource.d && resource.d.call(resource.v);
|
|
2827
|
+
if (resource.a) {
|
|
2828
|
+
return Promise.resolve(disposalResult).then(next, err);
|
|
2829
|
+
}
|
|
2830
|
+
} catch (e) {
|
|
2831
|
+
return err(e);
|
|
2832
|
+
}
|
|
2833
|
+
}
|
|
2834
|
+
if (error !== empty) throw error;
|
|
2835
|
+
}
|
|
2836
|
+
function err(e) {
|
|
2837
|
+
error = error !== empty ? new _disposeSuppressedError(error, e) : e;
|
|
2838
|
+
return next();
|
|
2839
|
+
}
|
|
2840
|
+
return next();
|
|
2841
|
+
}
|
|
2842
|
+
};
|
|
2843
|
+
}
|
|
2689
2844
|
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
2690
2845
|
var SpacesServiceImpl = class {
|
|
2691
2846
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
@@ -2732,9 +2887,9 @@ var SpacesServiceImpl = class {
|
|
|
2732
2887
|
});
|
|
2733
2888
|
}
|
|
2734
2889
|
const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
2735
|
-
|
|
2890
|
+
invariant7(credentials[0].credential, void 0, {
|
|
2736
2891
|
F: __dxlog_file11,
|
|
2737
|
-
L:
|
|
2892
|
+
L: 118,
|
|
2738
2893
|
S: this,
|
|
2739
2894
|
A: [
|
|
2740
2895
|
"credentials[0].credential",
|
|
@@ -2742,9 +2897,9 @@ var SpacesServiceImpl = class {
|
|
|
2742
2897
|
]
|
|
2743
2898
|
});
|
|
2744
2899
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2745
|
-
|
|
2900
|
+
invariant7(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2746
2901
|
F: __dxlog_file11,
|
|
2747
|
-
L:
|
|
2902
|
+
L: 120,
|
|
2748
2903
|
S: this,
|
|
2749
2904
|
A: [
|
|
2750
2905
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2762,7 +2917,7 @@ var SpacesServiceImpl = class {
|
|
|
2762
2917
|
ids: spaces.map((space) => space.id)
|
|
2763
2918
|
}), {
|
|
2764
2919
|
F: __dxlog_file11,
|
|
2765
|
-
L:
|
|
2920
|
+
L: 133,
|
|
2766
2921
|
S: this,
|
|
2767
2922
|
C: (f, a) => f(...a)
|
|
2768
2923
|
});
|
|
@@ -2771,7 +2926,7 @@ var SpacesServiceImpl = class {
|
|
|
2771
2926
|
spaces
|
|
2772
2927
|
});
|
|
2773
2928
|
}, {
|
|
2774
|
-
maxFrequency:
|
|
2929
|
+
maxFrequency: process.env.NODE_ENV === "test" ? void 0 : 2
|
|
2775
2930
|
});
|
|
2776
2931
|
scheduleTask3(ctx, async () => {
|
|
2777
2932
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
@@ -2852,18 +3007,18 @@ var SpacesServiceImpl = class {
|
|
|
2852
3007
|
}
|
|
2853
3008
|
});
|
|
2854
3009
|
} else {
|
|
2855
|
-
|
|
3010
|
+
invariant7(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
2856
3011
|
F: __dxlog_file11,
|
|
2857
|
-
L:
|
|
3012
|
+
L: 231,
|
|
2858
3013
|
S: this,
|
|
2859
3014
|
A: [
|
|
2860
3015
|
"!credential.id",
|
|
2861
3016
|
"'Id on unsigned credentials is not allowed'"
|
|
2862
3017
|
]
|
|
2863
3018
|
});
|
|
2864
|
-
|
|
3019
|
+
invariant7(this._identityManager.identity, "Identity is not available", {
|
|
2865
3020
|
F: __dxlog_file11,
|
|
2866
|
-
L:
|
|
3021
|
+
L: 232,
|
|
2867
3022
|
S: this,
|
|
2868
3023
|
A: [
|
|
2869
3024
|
"this._identityManager.identity",
|
|
@@ -2871,9 +3026,9 @@ var SpacesServiceImpl = class {
|
|
|
2871
3026
|
]
|
|
2872
3027
|
});
|
|
2873
3028
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
2874
|
-
|
|
3029
|
+
invariant7(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
2875
3030
|
F: __dxlog_file11,
|
|
2876
|
-
L:
|
|
3031
|
+
L: 234,
|
|
2877
3032
|
S: this,
|
|
2878
3033
|
A: [
|
|
2879
3034
|
"credential.issuer.equals(signer.getIssuer())",
|
|
@@ -2919,11 +3074,58 @@ var SpacesServiceImpl = class {
|
|
|
2919
3074
|
credential
|
|
2920
3075
|
});
|
|
2921
3076
|
}
|
|
3077
|
+
async exportSpace(request) {
|
|
3078
|
+
try {
|
|
3079
|
+
var _usingCtx = _using_ctx2();
|
|
3080
|
+
const writer = _usingCtx.a(await new SpaceArchiveWriter().open());
|
|
3081
|
+
assertArgument4(SpaceId2.isValid(request.spaceId), "Invalid space ID");
|
|
3082
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3083
|
+
const space = dataSpaceManager.getSpaceById(request.spaceId) ?? raise(new Error("Space not found"));
|
|
3084
|
+
await writer.begin({
|
|
3085
|
+
spaceId: space.id
|
|
3086
|
+
});
|
|
3087
|
+
const rootUrl = space.automergeSpaceState.lastEpoch?.subject.assertion.automergeRoot;
|
|
3088
|
+
assertState3(rootUrl, "Space does not have a root URL");
|
|
3089
|
+
await writer.setCurrentRootUrl(rootUrl);
|
|
3090
|
+
for await (const [documentId, data] of space.getAllDocuments()) {
|
|
3091
|
+
await writer.writeDocument(documentId, data);
|
|
3092
|
+
}
|
|
3093
|
+
const archive = await writer.finish();
|
|
3094
|
+
return {
|
|
3095
|
+
archive
|
|
3096
|
+
};
|
|
3097
|
+
} catch (_) {
|
|
3098
|
+
_usingCtx.e = _;
|
|
3099
|
+
} finally {
|
|
3100
|
+
await _usingCtx.d();
|
|
3101
|
+
}
|
|
3102
|
+
}
|
|
3103
|
+
async importSpace(request) {
|
|
3104
|
+
const dataSpaceManager = await this._getDataSpaceManager();
|
|
3105
|
+
const extracted = await extractSpaceArchive(request.archive);
|
|
3106
|
+
invariant7(extracted.metadata.echo?.currentRootUrl, "Space archive does not contain a root URL", {
|
|
3107
|
+
F: __dxlog_file11,
|
|
3108
|
+
L: 288,
|
|
3109
|
+
S: this,
|
|
3110
|
+
A: [
|
|
3111
|
+
"extracted.metadata.echo?.currentRootUrl",
|
|
3112
|
+
"'Space archive does not contain a root URL'"
|
|
3113
|
+
]
|
|
3114
|
+
});
|
|
3115
|
+
const space = await dataSpaceManager.createSpace({
|
|
3116
|
+
documents: extracted.documents,
|
|
3117
|
+
rootUrl: extracted.metadata.echo?.currentRootUrl
|
|
3118
|
+
});
|
|
3119
|
+
await this._updateMetrics();
|
|
3120
|
+
return {
|
|
3121
|
+
newSpaceId: space.id
|
|
3122
|
+
};
|
|
3123
|
+
}
|
|
2922
3124
|
async _joinByAdmission({ credential }) {
|
|
2923
3125
|
const assertion = getCredentialAssertion3(credential);
|
|
2924
|
-
|
|
3126
|
+
invariant7(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2925
3127
|
F: __dxlog_file11,
|
|
2926
|
-
L:
|
|
3128
|
+
L: 299,
|
|
2927
3129
|
S: this,
|
|
2928
3130
|
A: [
|
|
2929
3131
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2931,9 +3133,9 @@ var SpacesServiceImpl = class {
|
|
|
2931
3133
|
]
|
|
2932
3134
|
});
|
|
2933
3135
|
const myIdentity = this._identityManager.identity;
|
|
2934
|
-
|
|
3136
|
+
invariant7(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
|
|
2935
3137
|
F: __dxlog_file11,
|
|
2936
|
-
L:
|
|
3138
|
+
L: 301,
|
|
2937
3139
|
S: this,
|
|
2938
3140
|
A: [
|
|
2939
3141
|
"myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
|
|
@@ -3145,7 +3347,7 @@ var Identity = class {
|
|
|
3145
3347
|
* Requires identity to be ready.
|
|
3146
3348
|
*/
|
|
3147
3349
|
getIdentityCredentialSigner() {
|
|
3148
|
-
|
|
3350
|
+
invariant8(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
|
|
3149
3351
|
F: __dxlog_file12,
|
|
3150
3352
|
L: 198,
|
|
3151
3353
|
S: this,
|
|
@@ -3247,9 +3449,9 @@ Identity = _ts_decorate4([
|
|
|
3247
3449
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
3248
3450
|
import platform from "platform";
|
|
3249
3451
|
import { Event as Event6 } from "@dxos/async";
|
|
3250
|
-
import { Context as
|
|
3452
|
+
import { Context as Context5 } from "@dxos/context";
|
|
3251
3453
|
import { createCredentialSignerWithKey as createCredentialSignerWithKey2, createDidFromIdentityKey as createDidFromIdentityKey3, CredentialGenerator } from "@dxos/credentials";
|
|
3252
|
-
import { invariant as
|
|
3454
|
+
import { invariant as invariant9 } from "@dxos/invariant";
|
|
3253
3455
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
3254
3456
|
import { log as log10 } from "@dxos/log";
|
|
3255
3457
|
import { trace as trace4 } from "@dxos/protocols";
|
|
@@ -3328,13 +3530,13 @@ var IdentityManager = class {
|
|
|
3328
3530
|
});
|
|
3329
3531
|
}
|
|
3330
3532
|
async close() {
|
|
3331
|
-
await this._identity?.close(new
|
|
3533
|
+
await this._identity?.close(new Context5(void 0, {
|
|
3332
3534
|
F: __dxlog_file13,
|
|
3333
3535
|
L: 135
|
|
3334
3536
|
}));
|
|
3335
3537
|
}
|
|
3336
3538
|
async createIdentity({ displayName, deviceProfile } = {}) {
|
|
3337
|
-
|
|
3539
|
+
invariant9(!this._identity, "Identity already exists.", {
|
|
3338
3540
|
F: __dxlog_file13,
|
|
3339
3541
|
L: 140,
|
|
3340
3542
|
S: this,
|
|
@@ -3361,13 +3563,13 @@ var IdentityManager = class {
|
|
|
3361
3563
|
}
|
|
3362
3564
|
};
|
|
3363
3565
|
const identity = await this._constructIdentity(identityRecord);
|
|
3364
|
-
await identity.open(new
|
|
3566
|
+
await identity.open(new Context5(void 0, {
|
|
3365
3567
|
F: __dxlog_file13,
|
|
3366
3568
|
L: 156
|
|
3367
3569
|
}));
|
|
3368
3570
|
{
|
|
3369
3571
|
const generator = new CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
|
|
3370
|
-
|
|
3572
|
+
invariant9(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
|
|
3371
3573
|
F: __dxlog_file13,
|
|
3372
3574
|
L: 160,
|
|
3373
3575
|
S: this,
|
|
@@ -3376,7 +3578,7 @@ var IdentityManager = class {
|
|
|
3376
3578
|
"'Genesis feed key is required.'"
|
|
3377
3579
|
]
|
|
3378
3580
|
});
|
|
3379
|
-
|
|
3581
|
+
invariant9(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
|
|
3380
3582
|
F: __dxlog_file13,
|
|
3381
3583
|
L: 161,
|
|
3382
3584
|
S: this,
|
|
@@ -3469,7 +3671,7 @@ var IdentityManager = class {
|
|
|
3469
3671
|
S: this,
|
|
3470
3672
|
C: (f, a) => f(...a)
|
|
3471
3673
|
});
|
|
3472
|
-
|
|
3674
|
+
invariant9(!this._identity, "Identity already exists.", {
|
|
3473
3675
|
F: __dxlog_file13,
|
|
3474
3676
|
L: 245,
|
|
3475
3677
|
S: this,
|
|
@@ -3490,7 +3692,7 @@ var IdentityManager = class {
|
|
|
3490
3692
|
}
|
|
3491
3693
|
};
|
|
3492
3694
|
const identity = await this._constructIdentity(identityRecord);
|
|
3493
|
-
await identity.open(new
|
|
3695
|
+
await identity.open(new Context5(void 0, {
|
|
3494
3696
|
F: __dxlog_file13,
|
|
3495
3697
|
L: 259
|
|
3496
3698
|
}));
|
|
@@ -3534,7 +3736,7 @@ var IdentityManager = class {
|
|
|
3534
3736
|
* Update the profile document of an existing identity.
|
|
3535
3737
|
*/
|
|
3536
3738
|
async updateProfile(profile) {
|
|
3537
|
-
|
|
3739
|
+
invariant9(this._identity, "Identity not initialized.", {
|
|
3538
3740
|
F: __dxlog_file13,
|
|
3539
3741
|
L: 291,
|
|
3540
3742
|
S: this,
|
|
@@ -3565,7 +3767,7 @@ var IdentityManager = class {
|
|
|
3565
3767
|
return profile;
|
|
3566
3768
|
}
|
|
3567
3769
|
async updateDeviceProfile(profile) {
|
|
3568
|
-
|
|
3770
|
+
invariant9(this._identity, "Identity not initialized.", {
|
|
3569
3771
|
F: __dxlog_file13,
|
|
3570
3772
|
L: 308,
|
|
3571
3773
|
S: this,
|
|
@@ -3601,7 +3803,7 @@ var IdentityManager = class {
|
|
|
3601
3803
|
};
|
|
3602
3804
|
}
|
|
3603
3805
|
async _constructIdentity(identityRecord) {
|
|
3604
|
-
|
|
3806
|
+
invariant9(!this._identity, void 0, {
|
|
3605
3807
|
F: __dxlog_file13,
|
|
3606
3808
|
L: 334,
|
|
3607
3809
|
S: this,
|
|
@@ -3627,7 +3829,7 @@ var IdentityManager = class {
|
|
|
3627
3829
|
identityKey: identityRecord.deviceKey,
|
|
3628
3830
|
gossip
|
|
3629
3831
|
});
|
|
3630
|
-
|
|
3832
|
+
invariant9(identityRecord.haloSpace.controlFeedKey, void 0, {
|
|
3631
3833
|
F: __dxlog_file13,
|
|
3632
3834
|
L: 348,
|
|
3633
3835
|
S: this,
|
|
@@ -3639,7 +3841,7 @@ var IdentityManager = class {
|
|
|
3639
3841
|
const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
|
|
3640
3842
|
writable: true
|
|
3641
3843
|
});
|
|
3642
|
-
|
|
3844
|
+
invariant9(identityRecord.haloSpace.dataFeedKey, void 0, {
|
|
3643
3845
|
F: __dxlog_file13,
|
|
3644
3846
|
L: 352,
|
|
3645
3847
|
S: this,
|
|
@@ -3728,17 +3930,17 @@ IdentityManager = _ts_decorate5([
|
|
|
3728
3930
|
], IdentityManager);
|
|
3729
3931
|
|
|
3730
3932
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
3731
|
-
import { Trigger as
|
|
3933
|
+
import { Trigger as Trigger3, sleep as sleep2 } from "@dxos/async";
|
|
3732
3934
|
import { Stream as Stream8 } from "@dxos/codec-protobuf/stream";
|
|
3733
|
-
import { Resource as
|
|
3935
|
+
import { Resource as Resource6 } from "@dxos/context";
|
|
3734
3936
|
import { createCredential as createCredential2, signPresentation } from "@dxos/credentials";
|
|
3735
|
-
import { invariant as
|
|
3937
|
+
import { invariant as invariant10 } from "@dxos/invariant";
|
|
3736
3938
|
import { log as log11 } from "@dxos/log";
|
|
3737
3939
|
import { SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/services";
|
|
3738
3940
|
import { safeAwaitAll } from "@dxos/util";
|
|
3739
3941
|
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
3740
3942
|
var DEFAULT_SPACE_SEARCH_TIMEOUT = 1e4;
|
|
3741
|
-
var IdentityServiceImpl = class extends
|
|
3943
|
+
var IdentityServiceImpl = class extends Resource6 {
|
|
3742
3944
|
constructor(_identityManager, _recoveryManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
|
|
3743
3945
|
super();
|
|
3744
3946
|
this._identityManager = _identityManager;
|
|
@@ -3766,7 +3968,7 @@ var IdentityServiceImpl = class extends Resource5 {
|
|
|
3766
3968
|
async _createDefaultSpace(dataSpaceManager) {
|
|
3767
3969
|
const space = await dataSpaceManager.createDefaultSpace();
|
|
3768
3970
|
const identity = this._identityManager.identity;
|
|
3769
|
-
|
|
3971
|
+
invariant10(identity, void 0, {
|
|
3770
3972
|
F: __dxlog_file14,
|
|
3771
3973
|
L: 61,
|
|
3772
3974
|
S: this,
|
|
@@ -3798,7 +4000,7 @@ var IdentityServiceImpl = class extends Resource5 {
|
|
|
3798
4000
|
};
|
|
3799
4001
|
}
|
|
3800
4002
|
async updateProfile(profile) {
|
|
3801
|
-
|
|
4003
|
+
invariant10(this._identityManager.identity, "Identity not initialized.", {
|
|
3802
4004
|
F: __dxlog_file14,
|
|
3803
4005
|
L: 88,
|
|
3804
4006
|
S: this,
|
|
@@ -3831,7 +4033,7 @@ var IdentityServiceImpl = class extends Resource5 {
|
|
|
3831
4033
|
}
|
|
3832
4034
|
// TODO(burdon): Rename createPresentation?
|
|
3833
4035
|
async signPresentation({ presentation, nonce }) {
|
|
3834
|
-
|
|
4036
|
+
invariant10(this._identityManager.identity, "Identity not initialized.", {
|
|
3835
4037
|
F: __dxlog_file14,
|
|
3836
4038
|
L: 116,
|
|
3837
4039
|
S: this,
|
|
@@ -3850,7 +4052,7 @@ var IdentityServiceImpl = class extends Resource5 {
|
|
|
3850
4052
|
}
|
|
3851
4053
|
async createAuthCredential() {
|
|
3852
4054
|
const identity = this._identityManager.identity;
|
|
3853
|
-
|
|
4055
|
+
invariant10(identity, "Identity not initialized.", {
|
|
3854
4056
|
F: __dxlog_file14,
|
|
3855
4057
|
L: 130,
|
|
3856
4058
|
S: this,
|
|
@@ -3874,7 +4076,7 @@ var IdentityServiceImpl = class extends Resource5 {
|
|
|
3874
4076
|
let recodedDefaultSpace = false;
|
|
3875
4077
|
let foundDefaultSpace = false;
|
|
3876
4078
|
const dataSpaceManager = this._dataSpaceManagerProvider();
|
|
3877
|
-
const recordedDefaultSpaceTrigger = new
|
|
4079
|
+
const recordedDefaultSpaceTrigger = new Trigger3();
|
|
3878
4080
|
const allProcessed = safeAwaitAll(dataSpaceManager.spaces.values(), async (space) => {
|
|
3879
4081
|
if (space.state === SpaceState3.SPACE_CLOSED) {
|
|
3880
4082
|
await space.open();
|
|
@@ -3927,7 +4129,7 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
3927
4129
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3928
4130
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3929
4131
|
}
|
|
3930
|
-
function
|
|
4132
|
+
function _using_ctx3() {
|
|
3931
4133
|
var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
|
|
3932
4134
|
var err = new Error();
|
|
3933
4135
|
err.name = "SuppressedError";
|
|
@@ -3992,9 +4194,9 @@ function _using_ctx2() {
|
|
|
3992
4194
|
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3993
4195
|
var DataSpace = class {
|
|
3994
4196
|
constructor(params) {
|
|
3995
|
-
this._ctx = new
|
|
4197
|
+
this._ctx = new Context6(void 0, {
|
|
3996
4198
|
F: __dxlog_file15,
|
|
3997
|
-
L:
|
|
4199
|
+
L: 97
|
|
3998
4200
|
});
|
|
3999
4201
|
this._cache = void 0;
|
|
4000
4202
|
this._edgeFeedReplicator = void 0;
|
|
@@ -4047,7 +4249,7 @@ var DataSpace = class {
|
|
|
4047
4249
|
state: SpaceState4[this._state]
|
|
4048
4250
|
}, {
|
|
4049
4251
|
F: __dxlog_file15,
|
|
4050
|
-
L:
|
|
4252
|
+
L: 173,
|
|
4051
4253
|
S: this,
|
|
4052
4254
|
C: (f, a) => f(...a)
|
|
4053
4255
|
});
|
|
@@ -4104,9 +4306,9 @@ var DataSpace = class {
|
|
|
4104
4306
|
if (this._edgeFeedReplicator) {
|
|
4105
4307
|
this.inner.protocol.feedAdded.append(this._onFeedAdded);
|
|
4106
4308
|
}
|
|
4107
|
-
await this._inner.open(new
|
|
4309
|
+
await this._inner.open(new Context6(void 0, {
|
|
4108
4310
|
F: __dxlog_file15,
|
|
4109
|
-
L:
|
|
4311
|
+
L: 247
|
|
4110
4312
|
}));
|
|
4111
4313
|
await this._inner.startProtocol();
|
|
4112
4314
|
await this._edgeFeedReplicator?.open();
|
|
@@ -4115,7 +4317,7 @@ var DataSpace = class {
|
|
|
4115
4317
|
state: SpaceState4[this._state]
|
|
4116
4318
|
}, {
|
|
4117
4319
|
F: __dxlog_file15,
|
|
4118
|
-
L:
|
|
4320
|
+
L: 253,
|
|
4119
4321
|
S: this,
|
|
4120
4322
|
C: (f, a) => f(...a)
|
|
4121
4323
|
});
|
|
@@ -4135,14 +4337,14 @@ var DataSpace = class {
|
|
|
4135
4337
|
state: SpaceState4[this._state]
|
|
4136
4338
|
}, {
|
|
4137
4339
|
F: __dxlog_file15,
|
|
4138
|
-
L:
|
|
4340
|
+
L: 272,
|
|
4139
4341
|
S: this,
|
|
4140
4342
|
C: (f, a) => f(...a)
|
|
4141
4343
|
});
|
|
4142
4344
|
await this._ctx.dispose();
|
|
4143
|
-
this._ctx = new
|
|
4345
|
+
this._ctx = new Context6(void 0, {
|
|
4144
4346
|
F: __dxlog_file15,
|
|
4145
|
-
L:
|
|
4347
|
+
L: 274
|
|
4146
4348
|
});
|
|
4147
4349
|
if (this._edgeFeedReplicator) {
|
|
4148
4350
|
this.inner.protocol.feedAdded.remove(this._onFeedAdded);
|
|
@@ -4175,7 +4377,7 @@ var DataSpace = class {
|
|
|
4175
4377
|
if (err instanceof CancelledError || err instanceof ContextDisposedError) {
|
|
4176
4378
|
log12("data pipeline initialization cancelled", err, {
|
|
4177
4379
|
F: __dxlog_file15,
|
|
4178
|
-
L:
|
|
4380
|
+
L: 312,
|
|
4179
4381
|
S: this,
|
|
4180
4382
|
C: (f, a) => f(...a)
|
|
4181
4383
|
});
|
|
@@ -4183,7 +4385,7 @@ var DataSpace = class {
|
|
|
4183
4385
|
}
|
|
4184
4386
|
log12.error("Error initializing data pipeline", err, {
|
|
4185
4387
|
F: __dxlog_file15,
|
|
4186
|
-
L:
|
|
4388
|
+
L: 316,
|
|
4187
4389
|
S: this,
|
|
4188
4390
|
C: (f, a) => f(...a)
|
|
4189
4391
|
});
|
|
@@ -4192,7 +4394,7 @@ var DataSpace = class {
|
|
|
4192
4394
|
state: SpaceState4[this._state]
|
|
4193
4395
|
}, {
|
|
4194
4396
|
F: __dxlog_file15,
|
|
4195
|
-
L:
|
|
4397
|
+
L: 318,
|
|
4196
4398
|
S: this,
|
|
4197
4399
|
C: (f, a) => f(...a)
|
|
4198
4400
|
});
|
|
@@ -4212,13 +4414,13 @@ var DataSpace = class {
|
|
|
4212
4414
|
state: SpaceState4[this._state]
|
|
4213
4415
|
}, {
|
|
4214
4416
|
F: __dxlog_file15,
|
|
4215
|
-
L:
|
|
4417
|
+
L: 334,
|
|
4216
4418
|
S: this,
|
|
4217
4419
|
C: (f, a) => f(...a)
|
|
4218
4420
|
});
|
|
4219
4421
|
log12("initializing control pipeline", void 0, {
|
|
4220
4422
|
F: __dxlog_file15,
|
|
4221
|
-
L:
|
|
4423
|
+
L: 336,
|
|
4222
4424
|
S: this,
|
|
4223
4425
|
C: (f, a) => f(...a)
|
|
4224
4426
|
});
|
|
@@ -4227,25 +4429,52 @@ var DataSpace = class {
|
|
|
4227
4429
|
const ready = this.stateUpdate.waitForCondition(() => this._state === SpaceState4.SPACE_READY);
|
|
4228
4430
|
log12("initializing automerge root", void 0, {
|
|
4229
4431
|
F: __dxlog_file15,
|
|
4230
|
-
L:
|
|
4432
|
+
L: 344,
|
|
4231
4433
|
S: this,
|
|
4232
4434
|
C: (f, a) => f(...a)
|
|
4233
4435
|
});
|
|
4234
4436
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
4235
4437
|
log12("waiting for space to be ready", void 0, {
|
|
4236
4438
|
F: __dxlog_file15,
|
|
4237
|
-
L:
|
|
4439
|
+
L: 348,
|
|
4238
4440
|
S: this,
|
|
4239
4441
|
C: (f, a) => f(...a)
|
|
4240
4442
|
});
|
|
4241
4443
|
await ready;
|
|
4242
4444
|
log12("space is ready", void 0, {
|
|
4243
4445
|
F: __dxlog_file15,
|
|
4244
|
-
L:
|
|
4446
|
+
L: 350,
|
|
4245
4447
|
S: this,
|
|
4246
4448
|
C: (f, a) => f(...a)
|
|
4247
4449
|
});
|
|
4248
4450
|
}
|
|
4451
|
+
async *getAllDocuments() {
|
|
4452
|
+
invariant11(this._databaseRoot, "Space is not ready", {
|
|
4453
|
+
F: __dxlog_file15,
|
|
4454
|
+
L: 354,
|
|
4455
|
+
S: this,
|
|
4456
|
+
A: [
|
|
4457
|
+
"this._databaseRoot",
|
|
4458
|
+
"'Space is not ready'"
|
|
4459
|
+
]
|
|
4460
|
+
});
|
|
4461
|
+
const doc = this._databaseRoot.docSync() ?? failedInvariant3();
|
|
4462
|
+
const root = save(doc);
|
|
4463
|
+
yield [
|
|
4464
|
+
this._databaseRoot.documentId,
|
|
4465
|
+
root
|
|
4466
|
+
];
|
|
4467
|
+
for (const documentUrl of this._databaseRoot.getAllLinkedDocuments()) {
|
|
4468
|
+
const data = await this._echoHost.exportDoc(Context6.default(void 0, {
|
|
4469
|
+
F: __dxlog_file15,
|
|
4470
|
+
L: 360
|
|
4471
|
+
}), documentUrl);
|
|
4472
|
+
yield [
|
|
4473
|
+
documentUrl.replace(/^automerge:/, ""),
|
|
4474
|
+
data
|
|
4475
|
+
];
|
|
4476
|
+
}
|
|
4477
|
+
}
|
|
4249
4478
|
async _enterReadyState() {
|
|
4250
4479
|
await this._callbacks.beforeReady?.();
|
|
4251
4480
|
this._state = SpaceState4.SPACE_READY;
|
|
@@ -4253,7 +4482,7 @@ var DataSpace = class {
|
|
|
4253
4482
|
state: SpaceState4[this._state]
|
|
4254
4483
|
}, {
|
|
4255
4484
|
F: __dxlog_file15,
|
|
4256
|
-
L:
|
|
4485
|
+
L: 369,
|
|
4257
4486
|
S: this,
|
|
4258
4487
|
C: (f, a) => f(...a)
|
|
4259
4488
|
});
|
|
@@ -4270,7 +4499,7 @@ var DataSpace = class {
|
|
|
4270
4499
|
await this._createWritableFeeds();
|
|
4271
4500
|
log12("writable feeds created", void 0, {
|
|
4272
4501
|
F: __dxlog_file15,
|
|
4273
|
-
L:
|
|
4502
|
+
L: 386,
|
|
4274
4503
|
S: this,
|
|
4275
4504
|
C: (f, a) => f(...a)
|
|
4276
4505
|
});
|
|
@@ -4324,7 +4553,7 @@ var DataSpace = class {
|
|
|
4324
4553
|
count: credentials.length
|
|
4325
4554
|
}, {
|
|
4326
4555
|
F: __dxlog_file15,
|
|
4327
|
-
L:
|
|
4556
|
+
L: 444,
|
|
4328
4557
|
S: this,
|
|
4329
4558
|
C: (f, a) => f(...a)
|
|
4330
4559
|
});
|
|
@@ -4335,14 +4564,14 @@ var DataSpace = class {
|
|
|
4335
4564
|
});
|
|
4336
4565
|
log12("credentials notarized", void 0, {
|
|
4337
4566
|
F: __dxlog_file15,
|
|
4338
|
-
L:
|
|
4567
|
+
L: 448,
|
|
4339
4568
|
S: this,
|
|
4340
4569
|
C: (f, a) => f(...a)
|
|
4341
4570
|
});
|
|
4342
4571
|
} catch (err) {
|
|
4343
4572
|
log12.error("error notarizing credentials for feed admission", err, {
|
|
4344
4573
|
F: __dxlog_file15,
|
|
4345
|
-
L:
|
|
4574
|
+
L: 450,
|
|
4346
4575
|
S: this,
|
|
4347
4576
|
C: (f, a) => f(...a)
|
|
4348
4577
|
});
|
|
@@ -4357,7 +4586,7 @@ var DataSpace = class {
|
|
|
4357
4586
|
rootUrl
|
|
4358
4587
|
}, {
|
|
4359
4588
|
F: __dxlog_file15,
|
|
4360
|
-
L:
|
|
4589
|
+
L: 460,
|
|
4361
4590
|
S: this,
|
|
4362
4591
|
C: (f, a) => f(...a)
|
|
4363
4592
|
});
|
|
@@ -4365,7 +4594,7 @@ var DataSpace = class {
|
|
|
4365
4594
|
queueMicrotask(async () => {
|
|
4366
4595
|
try {
|
|
4367
4596
|
try {
|
|
4368
|
-
var _usingCtx =
|
|
4597
|
+
var _usingCtx = _using_ctx3();
|
|
4369
4598
|
await warnAfterTimeout(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
|
|
4370
4599
|
await cancelWithContext2(this._ctx, handle.whenReady());
|
|
4371
4600
|
});
|
|
@@ -4376,7 +4605,7 @@ var DataSpace = class {
|
|
|
4376
4605
|
// Ensure only one root is processed at a time.
|
|
4377
4606
|
_usingCtx.u(await this._epochProcessingMutex.acquire())
|
|
4378
4607
|
);
|
|
4379
|
-
const doc = handle.docSync() ??
|
|
4608
|
+
const doc = handle.docSync() ?? failedInvariant3();
|
|
4380
4609
|
if (!doc.access?.spaceKey) {
|
|
4381
4610
|
handle.change((doc2) => {
|
|
4382
4611
|
doc2.access = {
|
|
@@ -4409,7 +4638,7 @@ var DataSpace = class {
|
|
|
4409
4638
|
err
|
|
4410
4639
|
}, {
|
|
4411
4640
|
F: __dxlog_file15,
|
|
4412
|
-
L:
|
|
4641
|
+
L: 503,
|
|
4413
4642
|
S: this,
|
|
4414
4643
|
C: (f, a) => f(...a)
|
|
4415
4644
|
});
|
|
@@ -4499,7 +4728,7 @@ var DataSpace = class {
|
|
|
4499
4728
|
state: SpaceState4[this._state]
|
|
4500
4729
|
}, {
|
|
4501
4730
|
F: __dxlog_file15,
|
|
4502
|
-
L:
|
|
4731
|
+
L: 585,
|
|
4503
4732
|
S: this,
|
|
4504
4733
|
C: (f, a) => f(...a)
|
|
4505
4734
|
});
|
|
@@ -4560,7 +4789,7 @@ DataSpace = _ts_decorate6([
|
|
|
4560
4789
|
|
|
4561
4790
|
// packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
|
|
4562
4791
|
import { getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credentials";
|
|
4563
|
-
import { invariant as
|
|
4792
|
+
import { invariant as invariant12 } from "@dxos/invariant";
|
|
4564
4793
|
import { AlreadyJoinedError as AlreadyJoinedError2 } from "@dxos/protocols";
|
|
4565
4794
|
import { Invitation as Invitation2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
4566
4795
|
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
|
|
@@ -4590,7 +4819,7 @@ var DeviceInvitationProtocol = class {
|
|
|
4590
4819
|
throw new Error("delegation not supported");
|
|
4591
4820
|
}
|
|
4592
4821
|
async admit(_, request) {
|
|
4593
|
-
|
|
4822
|
+
invariant12(request.device, void 0, {
|
|
4594
4823
|
F: __dxlog_file16,
|
|
4595
4824
|
L: 53,
|
|
4596
4825
|
S: this,
|
|
@@ -4601,7 +4830,7 @@ var DeviceInvitationProtocol = class {
|
|
|
4601
4830
|
});
|
|
4602
4831
|
const identity = this._getIdentity();
|
|
4603
4832
|
const credential = await identity.admitDevice(request.device);
|
|
4604
|
-
|
|
4833
|
+
invariant12(getCredentialAssertion4(credential)["@type"] === "dxos.halo.credentials.AuthorizedDevice", void 0, {
|
|
4605
4834
|
F: __dxlog_file16,
|
|
4606
4835
|
L: 56,
|
|
4607
4836
|
S: this,
|
|
@@ -4646,7 +4875,7 @@ var DeviceInvitationProtocol = class {
|
|
|
4646
4875
|
};
|
|
4647
4876
|
}
|
|
4648
4877
|
async accept(response, request) {
|
|
4649
|
-
|
|
4878
|
+
invariant12(response.device, void 0, {
|
|
4650
4879
|
F: __dxlog_file16,
|
|
4651
4880
|
L: 100,
|
|
4652
4881
|
S: this,
|
|
@@ -4656,7 +4885,7 @@ var DeviceInvitationProtocol = class {
|
|
|
4656
4885
|
]
|
|
4657
4886
|
});
|
|
4658
4887
|
const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
|
|
4659
|
-
|
|
4888
|
+
invariant12(request.device, void 0, {
|
|
4660
4889
|
F: __dxlog_file16,
|
|
4661
4890
|
L: 103,
|
|
4662
4891
|
S: this,
|
|
@@ -4688,7 +4917,7 @@ import { scheduleTask as scheduleTask7, TimeoutError as TimeoutError2 } from "@d
|
|
|
4688
4917
|
import { INVITATION_TIMEOUT, getExpirationTime } from "@dxos/client-protocol";
|
|
4689
4918
|
import { ContextDisposedError as ContextDisposedError3 } from "@dxos/context";
|
|
4690
4919
|
import { createKeyPair, sign as sign2 } from "@dxos/crypto";
|
|
4691
|
-
import { invariant as
|
|
4920
|
+
import { invariant as invariant17 } from "@dxos/invariant";
|
|
4692
4921
|
import { PublicKey as PublicKey11 } from "@dxos/keys";
|
|
4693
4922
|
import { log as log18 } from "@dxos/log";
|
|
4694
4923
|
import { createTeleportProtocolFactory } from "@dxos/network-manager";
|
|
@@ -4702,8 +4931,8 @@ import { ComplexSet as ComplexSet5 } from "@dxos/util";
|
|
|
4702
4931
|
// packages/sdk/client-services/src/packlets/invitations/edge-invitation-handler.ts
|
|
4703
4932
|
import { scheduleMicroTask as scheduleMicroTask3, scheduleTask as scheduleTask5 } from "@dxos/async";
|
|
4704
4933
|
import { sign } from "@dxos/crypto";
|
|
4705
|
-
import { invariant as
|
|
4706
|
-
import { SpaceId as
|
|
4934
|
+
import { invariant as invariant13 } from "@dxos/invariant";
|
|
4935
|
+
import { SpaceId as SpaceId3 } from "@dxos/keys";
|
|
4707
4936
|
import { log as log13 } from "@dxos/log";
|
|
4708
4937
|
import { EdgeAuthChallengeError, EdgeCallFailedError as EdgeCallFailedError2 } from "@dxos/protocols";
|
|
4709
4938
|
import { schema as schema3 } from "@dxos/protocols/proto";
|
|
@@ -4758,7 +4987,7 @@ var EdgeInvitationHandler = class {
|
|
|
4758
4987
|
}
|
|
4759
4988
|
const invitation = guardedState.current;
|
|
4760
4989
|
const spaceId = invitation.spaceId;
|
|
4761
|
-
const canBeHandledByEdge = invitation.authMethod !== Invitation4.AuthMethod.SHARED_SECRET && invitation.type === Invitation4.Type.DELEGATED && invitation.kind === Invitation4.Kind.SPACE && spaceId != null &&
|
|
4990
|
+
const canBeHandledByEdge = invitation.authMethod !== Invitation4.AuthMethod.SHARED_SECRET && invitation.type === Invitation4.Type.DELEGATED && invitation.kind === Invitation4.Kind.SPACE && spaceId != null && SpaceId3.isValid(spaceId);
|
|
4762
4991
|
if (!canBeHandledByEdge) {
|
|
4763
4992
|
log13("invitation could not be handled by edge", {
|
|
4764
4993
|
invitation
|
|
@@ -4854,7 +5083,7 @@ var EdgeInvitationHandler = class {
|
|
|
4854
5083
|
};
|
|
4855
5084
|
}
|
|
4856
5085
|
async _joinSpaceByInvitation(guardedState, spaceId, request) {
|
|
4857
|
-
|
|
5086
|
+
invariant13(this._client, void 0, {
|
|
4858
5087
|
F: __dxlog_file17,
|
|
4859
5088
|
L: 160,
|
|
4860
5089
|
S: this,
|
|
@@ -4891,9 +5120,9 @@ var EdgeInvitationHandler = class {
|
|
|
4891
5120
|
};
|
|
4892
5121
|
|
|
4893
5122
|
// packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts
|
|
4894
|
-
import { Trigger as
|
|
4895
|
-
import { cancelWithContext as cancelWithContext4, Context as
|
|
4896
|
-
import { invariant as
|
|
5123
|
+
import { Trigger as Trigger4 } from "@dxos/async";
|
|
5124
|
+
import { cancelWithContext as cancelWithContext4, Context as Context7 } from "@dxos/context";
|
|
5125
|
+
import { invariant as invariant14 } from "@dxos/invariant";
|
|
4897
5126
|
import { log as log14 } from "@dxos/log";
|
|
4898
5127
|
import { InvalidInvitationExtensionRoleError } from "@dxos/protocols";
|
|
4899
5128
|
import { schema as schema4 } from "@dxos/protocols/proto";
|
|
@@ -4913,11 +5142,11 @@ var InvitationGuestExtension = class extends RpcExtension2 {
|
|
|
4913
5142
|
});
|
|
4914
5143
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
4915
5144
|
this._callbacks = _callbacks;
|
|
4916
|
-
this._ctx = new
|
|
5145
|
+
this._ctx = new Context7(void 0, {
|
|
4917
5146
|
F: __dxlog_file18,
|
|
4918
5147
|
L: 38
|
|
4919
5148
|
});
|
|
4920
|
-
this._remoteOptionsTrigger = new
|
|
5149
|
+
this._remoteOptionsTrigger = new Trigger4();
|
|
4921
5150
|
this._invitationFlowLock = null;
|
|
4922
5151
|
}
|
|
4923
5152
|
hasFlowLock() {
|
|
@@ -4927,7 +5156,7 @@ var InvitationGuestExtension = class extends RpcExtension2 {
|
|
|
4927
5156
|
return {
|
|
4928
5157
|
InvitationHostService: {
|
|
4929
5158
|
options: async (options) => {
|
|
4930
|
-
|
|
5159
|
+
invariant14(!this._remoteOptions, "Remote options already set.", {
|
|
4931
5160
|
F: __dxlog_file18,
|
|
4932
5161
|
L: 68,
|
|
4933
5162
|
S: this,
|
|
@@ -5024,10 +5253,10 @@ var InvitationGuestExtension = class extends RpcExtension2 {
|
|
|
5024
5253
|
};
|
|
5025
5254
|
|
|
5026
5255
|
// packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts
|
|
5027
|
-
import { Trigger as
|
|
5028
|
-
import { cancelWithContext as cancelWithContext5, Context as
|
|
5256
|
+
import { Trigger as Trigger5, scheduleTask as scheduleTask6 } from "@dxos/async";
|
|
5257
|
+
import { cancelWithContext as cancelWithContext5, Context as Context8 } from "@dxos/context";
|
|
5029
5258
|
import { randomBytes, verify } from "@dxos/crypto";
|
|
5030
|
-
import { invariant as
|
|
5259
|
+
import { invariant as invariant15, InvariantViolation } from "@dxos/invariant";
|
|
5031
5260
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
5032
5261
|
import { log as log15 } from "@dxos/log";
|
|
5033
5262
|
import { InvalidInvitationExtensionRoleError as InvalidInvitationExtensionRoleError2, trace as trace6 } from "@dxos/protocols";
|
|
@@ -5050,16 +5279,16 @@ var InvitationHostExtension = class extends RpcExtension3 {
|
|
|
5050
5279
|
});
|
|
5051
5280
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
5052
5281
|
this._callbacks = _callbacks;
|
|
5053
|
-
this._ctx = new
|
|
5282
|
+
this._ctx = new Context8(void 0, {
|
|
5054
5283
|
F: __dxlog_file19,
|
|
5055
5284
|
L: 57
|
|
5056
5285
|
});
|
|
5057
|
-
this._remoteOptionsTrigger = new
|
|
5286
|
+
this._remoteOptionsTrigger = new Trigger5();
|
|
5058
5287
|
this._challenge = void 0;
|
|
5059
5288
|
this.guestProfile = void 0;
|
|
5060
5289
|
this.authenticationPassed = false;
|
|
5061
5290
|
this.authenticationRetry = 0;
|
|
5062
|
-
this.completedTrigger = new
|
|
5291
|
+
this.completedTrigger = new Trigger5();
|
|
5063
5292
|
this._invitationFlowLock = null;
|
|
5064
5293
|
}
|
|
5065
5294
|
hasFlowLock() {
|
|
@@ -5071,7 +5300,7 @@ var InvitationHostExtension = class extends RpcExtension3 {
|
|
|
5071
5300
|
// Perhaps in the future we will have more complex logic here.
|
|
5072
5301
|
InvitationHostService: {
|
|
5073
5302
|
options: async (options) => {
|
|
5074
|
-
|
|
5303
|
+
invariant15(!this._remoteOptions, "Remote options already set.", {
|
|
5075
5304
|
F: __dxlog_file19,
|
|
5076
5305
|
L: 106,
|
|
5077
5306
|
S: this,
|
|
@@ -5462,7 +5691,7 @@ var isNonTerminalState = (currentState) => {
|
|
|
5462
5691
|
};
|
|
5463
5692
|
|
|
5464
5693
|
// packages/sdk/client-services/src/packlets/invitations/invitation-topology.ts
|
|
5465
|
-
import { invariant as
|
|
5694
|
+
import { invariant as invariant16 } from "@dxos/invariant";
|
|
5466
5695
|
import { PublicKey as PublicKey10 } from "@dxos/keys";
|
|
5467
5696
|
import { log as log17 } from "@dxos/log";
|
|
5468
5697
|
import { InvitationOptions as InvitationOptions3 } from "@dxos/protocols/proto/dxos/halo/invitations";
|
|
@@ -5474,7 +5703,7 @@ var InvitationTopology = class {
|
|
|
5474
5703
|
this._seenPeers = new ComplexSet4(PublicKey10.hash);
|
|
5475
5704
|
}
|
|
5476
5705
|
init(controller) {
|
|
5477
|
-
|
|
5706
|
+
invariant16(!this._controller, "Already initialized.", {
|
|
5478
5707
|
F: __dxlog_file21,
|
|
5479
5708
|
L: 42,
|
|
5480
5709
|
S: this,
|
|
@@ -5486,7 +5715,7 @@ var InvitationTopology = class {
|
|
|
5486
5715
|
this._controller = controller;
|
|
5487
5716
|
}
|
|
5488
5717
|
update() {
|
|
5489
|
-
|
|
5718
|
+
invariant16(this._controller, "Not initialized.", {
|
|
5490
5719
|
F: __dxlog_file21,
|
|
5491
5720
|
L: 47,
|
|
5492
5721
|
S: this,
|
|
@@ -5520,7 +5749,7 @@ var InvitationTopology = class {
|
|
|
5520
5749
|
}
|
|
5521
5750
|
}
|
|
5522
5751
|
async onOffer(peer) {
|
|
5523
|
-
|
|
5752
|
+
invariant16(this._controller, "Not initialized.", {
|
|
5524
5753
|
F: __dxlog_file21,
|
|
5525
5754
|
L: 76,
|
|
5526
5755
|
S: this,
|
|
@@ -5589,7 +5818,7 @@ var InvitationsHandler = class {
|
|
|
5589
5818
|
C: (f, a) => f(...a)
|
|
5590
5819
|
});
|
|
5591
5820
|
const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
|
|
5592
|
-
|
|
5821
|
+
invariant17(deviceKey, void 0, {
|
|
5593
5822
|
F: __dxlog_file22,
|
|
5594
5823
|
L: 112,
|
|
5595
5824
|
S: this,
|
|
@@ -5781,7 +6010,7 @@ var InvitationsHandler = class {
|
|
|
5781
6010
|
});
|
|
5782
6011
|
const { timeout = INVITATION_TIMEOUT } = invitation;
|
|
5783
6012
|
if (deviceProfile) {
|
|
5784
|
-
|
|
6013
|
+
invariant17(invitation.kind === Invitation7.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
|
|
5785
6014
|
F: __dxlog_file22,
|
|
5786
6015
|
L: 236,
|
|
5787
6016
|
S: this,
|
|
@@ -6019,7 +6248,7 @@ var InvitationsHandler = class {
|
|
|
6019
6248
|
stream.error(error);
|
|
6020
6249
|
await ctx.dispose();
|
|
6021
6250
|
} else {
|
|
6022
|
-
|
|
6251
|
+
invariant17(invitation.swarmKey, void 0, {
|
|
6023
6252
|
F: __dxlog_file22,
|
|
6024
6253
|
L: 406,
|
|
6025
6254
|
S: this,
|
|
@@ -6242,7 +6471,7 @@ var InvitationsServiceImpl = class {
|
|
|
6242
6471
|
// packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
|
|
6243
6472
|
import { createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInvitationCredential, getCredentialAssertion as getCredentialAssertion5 } from "@dxos/credentials";
|
|
6244
6473
|
import { writeMessages as writeMessages4 } from "@dxos/feed-store";
|
|
6245
|
-
import { invariant as
|
|
6474
|
+
import { invariant as invariant18 } from "@dxos/invariant";
|
|
6246
6475
|
import { log as log19 } from "@dxos/log";
|
|
6247
6476
|
import { AlreadyJoinedError as AlreadyJoinedError3, AuthorizationError as AuthorizationError2, InvalidInvitationError as InvalidInvitationError2, SpaceNotFoundError as SpaceNotFoundError2 } from "@dxos/protocols";
|
|
6248
6477
|
import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -6276,7 +6505,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6276
6505
|
return void 0;
|
|
6277
6506
|
}
|
|
6278
6507
|
getInvitationContext() {
|
|
6279
|
-
|
|
6508
|
+
invariant18(this._spaceKey, void 0, {
|
|
6280
6509
|
F: __dxlog_file23,
|
|
6281
6510
|
L: 65,
|
|
6282
6511
|
S: this,
|
|
@@ -6286,7 +6515,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6286
6515
|
]
|
|
6287
6516
|
});
|
|
6288
6517
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
6289
|
-
|
|
6518
|
+
invariant18(space, void 0, {
|
|
6290
6519
|
F: __dxlog_file23,
|
|
6291
6520
|
L: 67,
|
|
6292
6521
|
S: this,
|
|
@@ -6302,7 +6531,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6302
6531
|
};
|
|
6303
6532
|
}
|
|
6304
6533
|
async admit(invitation, request, guestProfile) {
|
|
6305
|
-
|
|
6534
|
+
invariant18(this._spaceKey && request.space, void 0, {
|
|
6306
6535
|
F: __dxlog_file23,
|
|
6307
6536
|
L: 80,
|
|
6308
6537
|
S: this,
|
|
@@ -6336,7 +6565,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6336
6565
|
};
|
|
6337
6566
|
}
|
|
6338
6567
|
async delegate(invitation) {
|
|
6339
|
-
|
|
6568
|
+
invariant18(this._spaceKey, void 0, {
|
|
6340
6569
|
F: __dxlog_file23,
|
|
6341
6570
|
L: 101,
|
|
6342
6571
|
S: this,
|
|
@@ -6346,7 +6575,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6346
6575
|
]
|
|
6347
6576
|
});
|
|
6348
6577
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
6349
|
-
|
|
6578
|
+
invariant18(space, void 0, {
|
|
6350
6579
|
F: __dxlog_file23,
|
|
6351
6580
|
L: 103,
|
|
6352
6581
|
S: this,
|
|
@@ -6356,7 +6585,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6356
6585
|
]
|
|
6357
6586
|
});
|
|
6358
6587
|
if (invitation.authMethod === Invitation8.AuthMethod.KNOWN_PUBLIC_KEY) {
|
|
6359
|
-
|
|
6588
|
+
invariant18(invitation.guestKeypair?.publicKey, void 0, {
|
|
6360
6589
|
F: __dxlog_file23,
|
|
6361
6590
|
L: 105,
|
|
6362
6591
|
S: this,
|
|
@@ -6384,7 +6613,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6384
6613
|
multiUse: invitation.multiUse ?? false,
|
|
6385
6614
|
guestKey: invitation.authMethod === Invitation8.AuthMethod.KNOWN_PUBLIC_KEY ? invitation.guestKeypair.publicKey : void 0
|
|
6386
6615
|
});
|
|
6387
|
-
|
|
6616
|
+
invariant18(credential.credential, void 0, {
|
|
6388
6617
|
F: __dxlog_file23,
|
|
6389
6618
|
L: 126,
|
|
6390
6619
|
S: this,
|
|
@@ -6399,7 +6628,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6399
6628
|
return credential.credential.credential.id;
|
|
6400
6629
|
}
|
|
6401
6630
|
async cancelDelegation(invitation) {
|
|
6402
|
-
|
|
6631
|
+
invariant18(this._spaceKey, void 0, {
|
|
6403
6632
|
F: __dxlog_file23,
|
|
6404
6633
|
L: 132,
|
|
6405
6634
|
S: this,
|
|
@@ -6408,7 +6637,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6408
6637
|
""
|
|
6409
6638
|
]
|
|
6410
6639
|
});
|
|
6411
|
-
|
|
6640
|
+
invariant18(invitation.type === Invitation8.Type.DELEGATED && invitation.delegationCredentialId, void 0, {
|
|
6412
6641
|
F: __dxlog_file23,
|
|
6413
6642
|
L: 133,
|
|
6414
6643
|
S: this,
|
|
@@ -6418,7 +6647,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6418
6647
|
]
|
|
6419
6648
|
});
|
|
6420
6649
|
const space = this._spaceManager.spaces.get(this._spaceKey);
|
|
6421
|
-
|
|
6650
|
+
invariant18(space, void 0, {
|
|
6422
6651
|
F: __dxlog_file23,
|
|
6423
6652
|
L: 135,
|
|
6424
6653
|
S: this,
|
|
@@ -6437,7 +6666,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6437
6666
|
C: (f, a) => f(...a)
|
|
6438
6667
|
});
|
|
6439
6668
|
const credential = await createCancelDelegatedSpaceInvitationCredential(this._signingContext.credentialSigner, space.key, invitation.delegationCredentialId);
|
|
6440
|
-
|
|
6669
|
+
invariant18(credential.credential, void 0, {
|
|
6441
6670
|
F: __dxlog_file23,
|
|
6442
6671
|
L: 144,
|
|
6443
6672
|
S: this,
|
|
@@ -6476,7 +6705,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6476
6705
|
};
|
|
6477
6706
|
}
|
|
6478
6707
|
async accept(response) {
|
|
6479
|
-
|
|
6708
|
+
invariant18(response.space, void 0, {
|
|
6480
6709
|
F: __dxlog_file23,
|
|
6481
6710
|
L: 179,
|
|
6482
6711
|
S: this,
|
|
@@ -6487,7 +6716,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6487
6716
|
});
|
|
6488
6717
|
const { credential, controlTimeframe, dataTimeframe } = response.space;
|
|
6489
6718
|
const assertion = getCredentialAssertion5(credential);
|
|
6490
|
-
|
|
6719
|
+
invariant18(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
6491
6720
|
F: __dxlog_file23,
|
|
6492
6721
|
L: 182,
|
|
6493
6722
|
S: this,
|
|
@@ -6496,7 +6725,7 @@ var SpaceInvitationProtocol = class {
|
|
|
6496
6725
|
"'Invalid credential'"
|
|
6497
6726
|
]
|
|
6498
6727
|
});
|
|
6499
|
-
|
|
6728
|
+
invariant18(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
|
|
6500
6729
|
F: __dxlog_file23,
|
|
6501
6730
|
L: 183,
|
|
6502
6731
|
S: this,
|
|
@@ -6522,12 +6751,12 @@ var SpaceInvitationProtocol = class {
|
|
|
6522
6751
|
};
|
|
6523
6752
|
|
|
6524
6753
|
// packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts
|
|
6525
|
-
import { Event as Event8, PushStream, TimeoutError as TimeoutError3, Trigger as
|
|
6754
|
+
import { Event as Event8, PushStream, TimeoutError as TimeoutError3, Trigger as Trigger6 } from "@dxos/async";
|
|
6526
6755
|
import { AuthenticatingInvitation, AUTHENTICATION_CODE_LENGTH, CancellableInvitation, INVITATION_TIMEOUT as INVITATION_TIMEOUT2 } from "@dxos/client-protocol";
|
|
6527
|
-
import { Context as
|
|
6756
|
+
import { Context as Context9 } from "@dxos/context";
|
|
6528
6757
|
import { generatePasscode } from "@dxos/credentials";
|
|
6529
6758
|
import { hasInvitationExpired } from "@dxos/echo-pipeline";
|
|
6530
|
-
import { invariant as
|
|
6759
|
+
import { invariant as invariant19 } from "@dxos/invariant";
|
|
6531
6760
|
import { PublicKey as PublicKey12 } from "@dxos/keys";
|
|
6532
6761
|
import { log as log20 } from "@dxos/log";
|
|
6533
6762
|
import { Invitation as Invitation9 } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -6597,7 +6826,7 @@ var InvitationsManager = class {
|
|
|
6597
6826
|
const persistentInvitations = this._metadataStore.getInvitations();
|
|
6598
6827
|
const freshInvitations = persistentInvitations.filter((invitation) => !hasInvitationExpired(invitation));
|
|
6599
6828
|
const loadTasks = freshInvitations.map((persistentInvitation) => {
|
|
6600
|
-
|
|
6829
|
+
invariant19(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
|
|
6601
6830
|
F: __dxlog_file24,
|
|
6602
6831
|
L: 103,
|
|
6603
6832
|
S: this,
|
|
@@ -6654,7 +6883,7 @@ var InvitationsManager = class {
|
|
|
6654
6883
|
S: this,
|
|
6655
6884
|
C: (f, a) => f(...a)
|
|
6656
6885
|
});
|
|
6657
|
-
|
|
6886
|
+
invariant19(invitationId, void 0, {
|
|
6658
6887
|
F: __dxlog_file24,
|
|
6659
6888
|
L: 141,
|
|
6660
6889
|
S: this,
|
|
@@ -6686,7 +6915,7 @@ var InvitationsManager = class {
|
|
|
6686
6915
|
S: this,
|
|
6687
6916
|
C: (f, a) => f(...a)
|
|
6688
6917
|
});
|
|
6689
|
-
|
|
6918
|
+
invariant19(invitationId, void 0, {
|
|
6690
6919
|
F: __dxlog_file24,
|
|
6691
6920
|
L: 152,
|
|
6692
6921
|
S: this,
|
|
@@ -6757,7 +6986,7 @@ var InvitationsManager = class {
|
|
|
6757
6986
|
}
|
|
6758
6987
|
_createObservableInvitation(handler, invitation) {
|
|
6759
6988
|
const stream = new PushStream();
|
|
6760
|
-
const ctx = new
|
|
6989
|
+
const ctx = new Context9({
|
|
6761
6990
|
onError: (err) => {
|
|
6762
6991
|
stream.error(err);
|
|
6763
6992
|
void ctx.dispose();
|
|
@@ -6795,9 +7024,9 @@ var InvitationsManager = class {
|
|
|
6795
7024
|
};
|
|
6796
7025
|
}
|
|
6797
7026
|
_createObservableAcceptingInvitation(handler, initialState) {
|
|
6798
|
-
const otpEnteredTrigger = new
|
|
7027
|
+
const otpEnteredTrigger = new Trigger6();
|
|
6799
7028
|
const stream = new PushStream();
|
|
6800
|
-
const ctx = new
|
|
7029
|
+
const ctx = new Context9({
|
|
6801
7030
|
onError: (err) => {
|
|
6802
7031
|
if (err instanceof TimeoutError3) {
|
|
6803
7032
|
log20("timeout", {
|
|
@@ -6893,9 +7122,9 @@ var InvitationsManager = class {
|
|
|
6893
7122
|
}
|
|
6894
7123
|
};
|
|
6895
7124
|
|
|
6896
|
-
// packages/sdk/client-services/src/packlets/locks/
|
|
6897
|
-
import {
|
|
6898
|
-
import {
|
|
7125
|
+
// packages/sdk/client-services/src/packlets/locks/node.ts
|
|
7126
|
+
import { invariant as invariant20 } from "@dxos/invariant";
|
|
7127
|
+
import { LockFile } from "@dxos/lock-file";
|
|
6899
7128
|
import { log as log21, logInfo as logInfo3 } from "@dxos/log";
|
|
6900
7129
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
6901
7130
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -6903,115 +7132,50 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
6903
7132
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6904
7133
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6905
7134
|
}
|
|
6906
|
-
var __dxlog_file25 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/
|
|
6907
|
-
var Message;
|
|
6908
|
-
(function(Message2) {
|
|
6909
|
-
Message2["ACQUIRING"] = "acquiring";
|
|
6910
|
-
})(Message || (Message = {}));
|
|
7135
|
+
var __dxlog_file25 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
6911
7136
|
var Lock = class {
|
|
6912
|
-
constructor({ lockKey, onAcquire, onRelease }) {
|
|
6913
|
-
this.
|
|
6914
|
-
this._releaseTrigger = new Trigger8();
|
|
6915
|
-
this._lockKey = lockKey;
|
|
7137
|
+
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
7138
|
+
this._lockPath = lockPath;
|
|
6916
7139
|
this._onAcquire = onAcquire;
|
|
6917
7140
|
this._onRelease = onRelease;
|
|
6918
|
-
this._broadcastChannel.onmessage = this._onMessage.bind(this);
|
|
6919
7141
|
}
|
|
6920
7142
|
get lockKey() {
|
|
6921
|
-
return this.
|
|
7143
|
+
return this._lockPath;
|
|
6922
7144
|
}
|
|
6923
7145
|
async acquire() {
|
|
6924
|
-
|
|
6925
|
-
message: "acquiring"
|
|
6926
|
-
});
|
|
6927
|
-
try {
|
|
6928
|
-
log21("aquiring lock...", void 0, {
|
|
6929
|
-
F: __dxlog_file25,
|
|
6930
|
-
L: 42,
|
|
6931
|
-
S: this,
|
|
6932
|
-
C: (f, a) => f(...a)
|
|
6933
|
-
});
|
|
6934
|
-
await asyncTimeout2(this._requestLock(), RESOURCE_LOCK_TIMEOUT);
|
|
6935
|
-
log21("acquired lock", void 0, {
|
|
6936
|
-
F: __dxlog_file25,
|
|
6937
|
-
L: 44,
|
|
6938
|
-
S: this,
|
|
6939
|
-
C: (f, a) => f(...a)
|
|
6940
|
-
});
|
|
6941
|
-
} catch {
|
|
6942
|
-
log21("stealing lock...", void 0, {
|
|
6943
|
-
F: __dxlog_file25,
|
|
6944
|
-
L: 46,
|
|
6945
|
-
S: this,
|
|
6946
|
-
C: (f, a) => f(...a)
|
|
6947
|
-
});
|
|
6948
|
-
await this._requestLock(true);
|
|
6949
|
-
log21("stolen lock", void 0, {
|
|
6950
|
-
F: __dxlog_file25,
|
|
6951
|
-
L: 48,
|
|
6952
|
-
S: this,
|
|
6953
|
-
C: (f, a) => f(...a)
|
|
6954
|
-
});
|
|
6955
|
-
}
|
|
6956
|
-
}
|
|
6957
|
-
async release() {
|
|
6958
|
-
this._releaseTrigger.wake();
|
|
6959
|
-
}
|
|
6960
|
-
_onMessage(event) {
|
|
6961
|
-
if (event.data.message === "acquiring") {
|
|
6962
|
-
this._releaseTrigger.wake();
|
|
6963
|
-
}
|
|
6964
|
-
}
|
|
6965
|
-
async _requestLock(steal = false) {
|
|
6966
|
-
log21("requesting lock...", {
|
|
6967
|
-
steal
|
|
6968
|
-
}, {
|
|
7146
|
+
log21("acquiring lock...", void 0, {
|
|
6969
7147
|
F: __dxlog_file25,
|
|
6970
|
-
L:
|
|
7148
|
+
L: 32,
|
|
6971
7149
|
S: this,
|
|
6972
7150
|
C: (f, a) => f(...a)
|
|
6973
7151
|
});
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
}, async () => {
|
|
6978
|
-
await this._onAcquire?.();
|
|
6979
|
-
acquired.wake();
|
|
6980
|
-
this._releaseTrigger = new Trigger8();
|
|
6981
|
-
await this._releaseTrigger.wait();
|
|
6982
|
-
log21("releasing lock...", void 0, {
|
|
6983
|
-
F: __dxlog_file25,
|
|
6984
|
-
L: 72,
|
|
6985
|
-
S: this,
|
|
6986
|
-
C: (f, a) => f(...a)
|
|
6987
|
-
});
|
|
6988
|
-
await this._onRelease?.();
|
|
6989
|
-
log21("released lock", void 0, {
|
|
6990
|
-
F: __dxlog_file25,
|
|
6991
|
-
L: 74,
|
|
6992
|
-
S: this,
|
|
6993
|
-
C: (f, a) => f(...a)
|
|
6994
|
-
});
|
|
6995
|
-
}).catch(async () => {
|
|
6996
|
-
await this._onRelease?.();
|
|
6997
|
-
});
|
|
6998
|
-
await acquired.wait();
|
|
6999
|
-
log21("recieved lock", {
|
|
7000
|
-
steal
|
|
7001
|
-
}, {
|
|
7152
|
+
this._fileHandle = await LockFile.acquire(this._lockPath);
|
|
7153
|
+
await this._onAcquire?.();
|
|
7154
|
+
log21("acquired lock", void 0, {
|
|
7002
7155
|
F: __dxlog_file25,
|
|
7003
|
-
L:
|
|
7156
|
+
L: 37,
|
|
7004
7157
|
S: this,
|
|
7005
7158
|
C: (f, a) => f(...a)
|
|
7006
7159
|
});
|
|
7007
7160
|
}
|
|
7161
|
+
async release() {
|
|
7162
|
+
await this._onRelease?.();
|
|
7163
|
+
invariant20(this._fileHandle, "Lock is not acquired", {
|
|
7164
|
+
F: __dxlog_file25,
|
|
7165
|
+
L: 42,
|
|
7166
|
+
S: this,
|
|
7167
|
+
A: [
|
|
7168
|
+
"this._fileHandle",
|
|
7169
|
+
"'Lock is not acquired'"
|
|
7170
|
+
]
|
|
7171
|
+
});
|
|
7172
|
+
await LockFile.release(this._fileHandle);
|
|
7173
|
+
}
|
|
7008
7174
|
};
|
|
7009
7175
|
_ts_decorate7([
|
|
7010
7176
|
logInfo3
|
|
7011
7177
|
], Lock.prototype, "lockKey", null);
|
|
7012
|
-
var isLocked = (lockPath) =>
|
|
7013
|
-
throw new Error("Not implemented");
|
|
7014
|
-
};
|
|
7178
|
+
var isLocked = (lockPath) => LockFile.isLocked(lockPath);
|
|
7015
7179
|
|
|
7016
7180
|
// packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
|
|
7017
7181
|
import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
@@ -7092,8 +7256,8 @@ ClientRpcServer = _ts_decorate8([
|
|
|
7092
7256
|
|
|
7093
7257
|
// packages/sdk/client-services/src/packlets/agents/edge-agent-manager.ts
|
|
7094
7258
|
import { DeferredTask as DeferredTask2, Event as Event9, scheduleTask as scheduleTask8, synchronized as synchronized3 } from "@dxos/async";
|
|
7095
|
-
import { Resource as
|
|
7096
|
-
import { invariant as
|
|
7259
|
+
import { Resource as Resource7 } from "@dxos/context";
|
|
7260
|
+
import { invariant as invariant21 } from "@dxos/invariant";
|
|
7097
7261
|
import { PublicKey as PublicKey13 } from "@dxos/keys";
|
|
7098
7262
|
import { log as log22 } from "@dxos/log";
|
|
7099
7263
|
import { EdgeAgentStatus, EdgeCallFailedError as EdgeCallFailedError3 } from "@dxos/protocols";
|
|
@@ -7109,7 +7273,7 @@ var __dxlog_file26 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
|
|
|
7109
7273
|
var AGENT_STATUS_QUERY_RETRY_INTERVAL = 5e3;
|
|
7110
7274
|
var AGENT_STATUS_QUERY_RETRY_JITTER = 1e3;
|
|
7111
7275
|
var AGENT_FEED_ADDED_CHECK_INTERVAL_MS = 3e3;
|
|
7112
|
-
var EdgeAgentManager = class extends
|
|
7276
|
+
var EdgeAgentManager = class extends Resource7 {
|
|
7113
7277
|
constructor(_edgeFeatures, _edgeHttpClient, _dataSpaceManager, _identity) {
|
|
7114
7278
|
super();
|
|
7115
7279
|
this._edgeFeatures = _edgeFeatures;
|
|
@@ -7126,7 +7290,7 @@ var EdgeAgentManager = class extends Resource6 {
|
|
|
7126
7290
|
return this._agentStatus && this._agentStatus !== EdgeAgentStatus.NOT_FOUND;
|
|
7127
7291
|
}
|
|
7128
7292
|
async createAgent() {
|
|
7129
|
-
|
|
7293
|
+
invariant21(this.isOpen, void 0, {
|
|
7130
7294
|
F: __dxlog_file26,
|
|
7131
7295
|
L: 54,
|
|
7132
7296
|
S: this,
|
|
@@ -7135,7 +7299,7 @@ var EdgeAgentManager = class extends Resource6 {
|
|
|
7135
7299
|
""
|
|
7136
7300
|
]
|
|
7137
7301
|
});
|
|
7138
|
-
|
|
7302
|
+
invariant21(this._edgeHttpClient, void 0, {
|
|
7139
7303
|
F: __dxlog_file26,
|
|
7140
7304
|
L: 55,
|
|
7141
7305
|
S: this,
|
|
@@ -7144,7 +7308,7 @@ var EdgeAgentManager = class extends Resource6 {
|
|
|
7144
7308
|
""
|
|
7145
7309
|
]
|
|
7146
7310
|
});
|
|
7147
|
-
|
|
7311
|
+
invariant21(this._edgeFeatures?.agents, void 0, {
|
|
7148
7312
|
F: __dxlog_file26,
|
|
7149
7313
|
L: 56,
|
|
7150
7314
|
S: this,
|
|
@@ -7222,7 +7386,7 @@ var EdgeAgentManager = class extends Resource6 {
|
|
|
7222
7386
|
this._lastKnownDeviceCount = 0;
|
|
7223
7387
|
}
|
|
7224
7388
|
async _fetchAgentStatus() {
|
|
7225
|
-
|
|
7389
|
+
invariant21(this._edgeHttpClient, void 0, {
|
|
7226
7390
|
F: __dxlog_file26,
|
|
7227
7391
|
L: 121,
|
|
7228
7392
|
S: this,
|
|
@@ -7394,14 +7558,14 @@ var mapStatus = (agentStatus) => {
|
|
|
7394
7558
|
};
|
|
7395
7559
|
|
|
7396
7560
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
7397
|
-
import { Mutex as Mutex4, Trigger as
|
|
7398
|
-
import { Context as
|
|
7561
|
+
import { Mutex as Mutex4, Trigger as Trigger7 } from "@dxos/async";
|
|
7562
|
+
import { Context as Context10, Resource as Resource8 } from "@dxos/context";
|
|
7399
7563
|
import { getCredentialAssertion as getCredentialAssertion6 } from "@dxos/credentials";
|
|
7400
7564
|
import { failUndefined as failUndefined2, warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
|
|
7401
7565
|
import { EchoEdgeReplicator, EchoHost, MeshEchoReplicator, MetadataStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
|
|
7402
7566
|
import { createChainEdgeIdentity, createEphemeralEdgeIdentity } from "@dxos/edge-client";
|
|
7403
7567
|
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
7404
|
-
import { invariant as
|
|
7568
|
+
import { invariant as invariant23 } from "@dxos/invariant";
|
|
7405
7569
|
import { Keyring } from "@dxos/keyring";
|
|
7406
7570
|
import { PublicKey as PublicKey15 } from "@dxos/keys";
|
|
7407
7571
|
import { log as log24 } from "@dxos/log";
|
|
@@ -7414,7 +7578,7 @@ import { safeInstanceof } from "@dxos/util";
|
|
|
7414
7578
|
// packages/sdk/client-services/src/packlets/identity/identity-recovery-manager.ts
|
|
7415
7579
|
import { generateSeedPhrase, keyPairFromSeedPhrase } from "@dxos/credentials";
|
|
7416
7580
|
import { sign as sign3 } from "@dxos/crypto";
|
|
7417
|
-
import { invariant as
|
|
7581
|
+
import { invariant as invariant22 } from "@dxos/invariant";
|
|
7418
7582
|
import { PublicKey as PublicKey14 } from "@dxos/keys";
|
|
7419
7583
|
import { log as log23 } from "@dxos/log";
|
|
7420
7584
|
import { EdgeAuthChallengeError as EdgeAuthChallengeError2 } from "@dxos/protocols";
|
|
@@ -7430,7 +7594,7 @@ var EdgeIdentityRecoveryManager = class {
|
|
|
7430
7594
|
}
|
|
7431
7595
|
async createRecoveryCredential({ data }) {
|
|
7432
7596
|
const identity = this._identityProvider();
|
|
7433
|
-
|
|
7597
|
+
invariant22(identity, void 0, {
|
|
7434
7598
|
F: __dxlog_file27,
|
|
7435
7599
|
L: 37,
|
|
7436
7600
|
S: this,
|
|
@@ -7481,7 +7645,7 @@ var EdgeIdentityRecoveryManager = class {
|
|
|
7481
7645
|
};
|
|
7482
7646
|
}
|
|
7483
7647
|
async requestRecoveryChallenge() {
|
|
7484
|
-
|
|
7648
|
+
invariant22(this._edgeClient, "Not connected to EDGE.", {
|
|
7485
7649
|
F: __dxlog_file27,
|
|
7486
7650
|
L: 74,
|
|
7487
7651
|
S: this,
|
|
@@ -7511,7 +7675,7 @@ var EdgeIdentityRecoveryManager = class {
|
|
|
7511
7675
|
}
|
|
7512
7676
|
}
|
|
7513
7677
|
async recoverIdentityWithExternalSignature({ lookupKey, deviceKey, controlFeedKey, signature, clientDataJson, authenticatorData }) {
|
|
7514
|
-
|
|
7678
|
+
invariant22(this._edgeClient, "Not connected to EDGE.", {
|
|
7515
7679
|
F: __dxlog_file27,
|
|
7516
7680
|
L: 106,
|
|
7517
7681
|
S: this,
|
|
@@ -7542,7 +7706,7 @@ var EdgeIdentityRecoveryManager = class {
|
|
|
7542
7706
|
});
|
|
7543
7707
|
}
|
|
7544
7708
|
async recoverIdentity({ recoveryCode }) {
|
|
7545
|
-
|
|
7709
|
+
invariant22(this._edgeClient, "Not connected to EDGE.", {
|
|
7546
7710
|
F: __dxlog_file27,
|
|
7547
7711
|
L: 136,
|
|
7548
7712
|
S: this,
|
|
@@ -7603,7 +7767,7 @@ function _ts_decorate10(decorators, target, key, desc) {
|
|
|
7603
7767
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7604
7768
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7605
7769
|
}
|
|
7606
|
-
function
|
|
7770
|
+
function _using_ctx4() {
|
|
7607
7771
|
var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
|
|
7608
7772
|
var err = new Error();
|
|
7609
7773
|
err.name = "SuppressedError";
|
|
@@ -7666,7 +7830,7 @@ function _using_ctx3() {
|
|
|
7666
7830
|
};
|
|
7667
7831
|
}
|
|
7668
7832
|
var __dxlog_file28 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
7669
|
-
var ServiceContext = class extends
|
|
7833
|
+
var ServiceContext = class extends Resource8 {
|
|
7670
7834
|
constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
|
|
7671
7835
|
super();
|
|
7672
7836
|
this.storage = storage;
|
|
@@ -7678,7 +7842,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7678
7842
|
this._runtimeParams = _runtimeParams;
|
|
7679
7843
|
this._edgeFeatures = _edgeFeatures;
|
|
7680
7844
|
this._edgeIdentityUpdateMutex = new Mutex4();
|
|
7681
|
-
this.initialized = new
|
|
7845
|
+
this.initialized = new Trigger7();
|
|
7682
7846
|
this._meshReplicator = void 0;
|
|
7683
7847
|
this._echoEdgeReplicator = void 0;
|
|
7684
7848
|
this._handlerFactories = /* @__PURE__ */ new Map();
|
|
@@ -7821,7 +7985,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7821
7985
|
const identity = await this.identityManager.createIdentity(params);
|
|
7822
7986
|
await this._setNetworkIdentity();
|
|
7823
7987
|
await identity.joinNetwork();
|
|
7824
|
-
await this._initialize(new
|
|
7988
|
+
await this._initialize(new Context10(void 0, {
|
|
7825
7989
|
F: __dxlog_file28,
|
|
7826
7990
|
L: 258
|
|
7827
7991
|
}));
|
|
@@ -7832,7 +7996,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7832
7996
|
throw new Error("Identity must be created before joining a space.");
|
|
7833
7997
|
}
|
|
7834
7998
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
7835
|
-
|
|
7999
|
+
invariant23(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
7836
8000
|
F: __dxlog_file28,
|
|
7837
8001
|
L: 267,
|
|
7838
8002
|
S: this,
|
|
@@ -7858,7 +8022,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7858
8022
|
});
|
|
7859
8023
|
await identity.joinNetwork();
|
|
7860
8024
|
await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
|
|
7861
|
-
await this._initialize(new
|
|
8025
|
+
await this._initialize(new Context10(void 0, {
|
|
7862
8026
|
F: __dxlog_file28,
|
|
7863
8027
|
L: 286
|
|
7864
8028
|
}));
|
|
@@ -7911,7 +8075,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7911
8075
|
this.edgeAgentManager = new EdgeAgentManager(this._edgeFeatures, this._edgeHttpClient, this.dataSpaceManager, identity);
|
|
7912
8076
|
await this.edgeAgentManager.open();
|
|
7913
8077
|
this._handlerFactories.set(Invitation10.Kind.SPACE, (invitation) => {
|
|
7914
|
-
|
|
8078
|
+
invariant23(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
7915
8079
|
F: __dxlog_file28,
|
|
7916
8080
|
L: 339,
|
|
7917
8081
|
S: this,
|
|
@@ -7981,7 +8145,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
7981
8145
|
}
|
|
7982
8146
|
async _setNetworkIdentity(params) {
|
|
7983
8147
|
try {
|
|
7984
|
-
var _usingCtx =
|
|
8148
|
+
var _usingCtx = _using_ctx4();
|
|
7985
8149
|
const _ = _usingCtx.u(await this._edgeIdentityUpdateMutex.acquire());
|
|
7986
8150
|
let edgeIdentity;
|
|
7987
8151
|
const identity = this.identityManager.identity;
|
|
@@ -8003,7 +8167,7 @@ var ServiceContext = class extends Resource7 {
|
|
|
8003
8167
|
await warnAfterTimeout2(1e4, "Waiting for identity to be ready for edge connection", async () => {
|
|
8004
8168
|
await identity.ready();
|
|
8005
8169
|
});
|
|
8006
|
-
|
|
8170
|
+
invariant23(identity.deviceCredentialChain, void 0, {
|
|
8007
8171
|
F: __dxlog_file28,
|
|
8008
8172
|
L: 403,
|
|
8009
8173
|
S: this,
|
|
@@ -8128,7 +8292,7 @@ var toStorageType = (type) => {
|
|
|
8128
8292
|
};
|
|
8129
8293
|
|
|
8130
8294
|
// packages/sdk/client-services/src/packlets/storage/level.ts
|
|
8131
|
-
import path from "
|
|
8295
|
+
import path from "node:path";
|
|
8132
8296
|
import { PublicKey as PublicKey16 } from "@dxos/keys";
|
|
8133
8297
|
import { createLevel as createKV } from "@dxos/kv-store";
|
|
8134
8298
|
var createLevel = async (config) => {
|
|
@@ -8141,7 +8305,7 @@ var createLevel = async (config) => {
|
|
|
8141
8305
|
|
|
8142
8306
|
// packages/sdk/client-services/src/packlets/storage/profile-archive.ts
|
|
8143
8307
|
import { cbor } from "@dxos/automerge/automerge-repo";
|
|
8144
|
-
import { invariant as
|
|
8308
|
+
import { invariant as invariant24 } from "@dxos/invariant";
|
|
8145
8309
|
import { log as log25 } from "@dxos/log";
|
|
8146
8310
|
import { ProfileArchiveEntryType } from "@dxos/protocols";
|
|
8147
8311
|
import { arrayToBuffer as arrayToBuffer2 } from "@dxos/util";
|
|
@@ -8223,7 +8387,7 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
8223
8387
|
switch (entry2.type) {
|
|
8224
8388
|
case ProfileArchiveEntryType.FILE: {
|
|
8225
8389
|
const directory = await storage.createDirectory();
|
|
8226
|
-
|
|
8390
|
+
invariant24(typeof entry2.key === "string", "Invalid key type", {
|
|
8227
8391
|
F: __dxlog_file29,
|
|
8228
8392
|
L: 79,
|
|
8229
8393
|
S: void 0,
|
|
@@ -8233,7 +8397,7 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
8233
8397
|
]
|
|
8234
8398
|
});
|
|
8235
8399
|
const file = await directory.getOrCreateFile(entry2.key);
|
|
8236
|
-
|
|
8400
|
+
invariant24(entry2.value instanceof Uint8Array, "Invalid value type", {
|
|
8237
8401
|
F: __dxlog_file29,
|
|
8238
8402
|
L: 81,
|
|
8239
8403
|
S: void 0,
|
|
@@ -8247,7 +8411,7 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
8247
8411
|
break;
|
|
8248
8412
|
}
|
|
8249
8413
|
case ProfileArchiveEntryType.KEY_VALUE: {
|
|
8250
|
-
|
|
8414
|
+
invariant24(entry2.key instanceof Uint8Array, "Invalid key type", {
|
|
8251
8415
|
F: __dxlog_file29,
|
|
8252
8416
|
L: 87,
|
|
8253
8417
|
S: void 0,
|
|
@@ -8256,7 +8420,7 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
8256
8420
|
"'Invalid key type'"
|
|
8257
8421
|
]
|
|
8258
8422
|
});
|
|
8259
|
-
|
|
8423
|
+
invariant24(entry2.value instanceof Uint8Array, "Invalid value type", {
|
|
8260
8424
|
F: __dxlog_file29,
|
|
8261
8425
|
L: 88,
|
|
8262
8426
|
S: void 0,
|
|
@@ -8301,9 +8465,9 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
8301
8465
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
8302
8466
|
import { Event as Event11, synchronized as synchronized4 } from "@dxos/async";
|
|
8303
8467
|
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
8304
|
-
import { Context as
|
|
8468
|
+
import { Context as Context11 } from "@dxos/context";
|
|
8305
8469
|
import { EdgeClient, EdgeHttpClient, createStubEdgeIdentity } from "@dxos/edge-client";
|
|
8306
|
-
import { invariant as
|
|
8470
|
+
import { invariant as invariant26 } from "@dxos/invariant";
|
|
8307
8471
|
import { PublicKey as PublicKey19 } from "@dxos/keys";
|
|
8308
8472
|
import { log as log27 } from "@dxos/log";
|
|
8309
8473
|
import { EdgeSignalManager, WebsocketSignalManager } from "@dxos/messaging";
|
|
@@ -8316,7 +8480,7 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
|
|
|
8316
8480
|
// packages/sdk/client-services/src/packlets/devices/devices-service.ts
|
|
8317
8481
|
import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
|
|
8318
8482
|
import { Stream as Stream12 } from "@dxos/codec-protobuf/stream";
|
|
8319
|
-
import { invariant as
|
|
8483
|
+
import { invariant as invariant25 } from "@dxos/invariant";
|
|
8320
8484
|
import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
|
|
8321
8485
|
var __dxlog_file30 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
8322
8486
|
var DevicesServiceImpl = class {
|
|
@@ -8336,7 +8500,7 @@ var DevicesServiceImpl = class {
|
|
|
8336
8500
|
devices: []
|
|
8337
8501
|
});
|
|
8338
8502
|
} else {
|
|
8339
|
-
|
|
8503
|
+
invariant25(this._identityManager.identity?.presence, "presence not present", {
|
|
8340
8504
|
F: __dxlog_file30,
|
|
8341
8505
|
L: 36,
|
|
8342
8506
|
S: this,
|
|
@@ -8647,6 +8811,9 @@ var NetworkServiceImpl = class {
|
|
|
8647
8811
|
async leaveSwarm(request) {
|
|
8648
8812
|
return this.signalManager.leave(request);
|
|
8649
8813
|
}
|
|
8814
|
+
async querySwarm(request) {
|
|
8815
|
+
return this.signalManager.query(request);
|
|
8816
|
+
}
|
|
8650
8817
|
subscribeSwarmState(request) {
|
|
8651
8818
|
return new Stream15(({ next }) => {
|
|
8652
8819
|
const unsubscribe = this.signalManager.swarmState?.on((state) => {
|
|
@@ -8775,7 +8942,7 @@ var ClientServicesHost = class {
|
|
|
8775
8942
|
lockKey,
|
|
8776
8943
|
onAcquire: () => {
|
|
8777
8944
|
if (!this._opening) {
|
|
8778
|
-
void this.open(new
|
|
8945
|
+
void this.open(new Context11(void 0, {
|
|
8779
8946
|
F: __dxlog_file31,
|
|
8780
8947
|
L: 137
|
|
8781
8948
|
}));
|
|
@@ -8833,7 +9000,7 @@ var ClientServicesHost = class {
|
|
|
8833
9000
|
* Can only be called once.
|
|
8834
9001
|
*/
|
|
8835
9002
|
initialize({ config, ...options }) {
|
|
8836
|
-
|
|
9003
|
+
invariant26(!this._open, "service host is open", {
|
|
8837
9004
|
F: __dxlog_file31,
|
|
8838
9005
|
L: 203,
|
|
8839
9006
|
S: this,
|
|
@@ -8849,7 +9016,7 @@ var ClientServicesHost = class {
|
|
|
8849
9016
|
C: (f, a) => f(...a)
|
|
8850
9017
|
});
|
|
8851
9018
|
if (config) {
|
|
8852
|
-
|
|
9019
|
+
invariant26(!this._config, "config already set", {
|
|
8853
9020
|
F: __dxlog_file31,
|
|
8854
9021
|
L: 207,
|
|
8855
9022
|
S: this,
|
|
@@ -8884,7 +9051,7 @@ var ClientServicesHost = class {
|
|
|
8884
9051
|
edgeConnection: this._edgeConnection
|
|
8885
9052
|
}) : new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
8886
9053
|
this._signalManager = signalManager;
|
|
8887
|
-
|
|
9054
|
+
invariant26(!this._networkManager, "network manager already set", {
|
|
8888
9055
|
F: __dxlog_file31,
|
|
8889
9056
|
L: 237,
|
|
8890
9057
|
S: this,
|
|
@@ -8922,7 +9089,7 @@ var ClientServicesHost = class {
|
|
|
8922
9089
|
S: this,
|
|
8923
9090
|
C: (f, a) => f(...a)
|
|
8924
9091
|
});
|
|
8925
|
-
|
|
9092
|
+
invariant26(this._config, "config not set", {
|
|
8926
9093
|
F: __dxlog_file31,
|
|
8927
9094
|
L: 263,
|
|
8928
9095
|
S: this,
|
|
@@ -8931,7 +9098,7 @@ var ClientServicesHost = class {
|
|
|
8931
9098
|
"'config not set'"
|
|
8932
9099
|
]
|
|
8933
9100
|
});
|
|
8934
|
-
|
|
9101
|
+
invariant26(this._storage, "storage not set", {
|
|
8935
9102
|
F: __dxlog_file31,
|
|
8936
9103
|
L: 264,
|
|
8937
9104
|
S: this,
|
|
@@ -8940,7 +9107,7 @@ var ClientServicesHost = class {
|
|
|
8940
9107
|
"'storage not set'"
|
|
8941
9108
|
]
|
|
8942
9109
|
});
|
|
8943
|
-
|
|
9110
|
+
invariant26(this._signalManager, "signal manager not set", {
|
|
8944
9111
|
F: __dxlog_file31,
|
|
8945
9112
|
L: 265,
|
|
8946
9113
|
S: this,
|
|
@@ -8949,7 +9116,7 @@ var ClientServicesHost = class {
|
|
|
8949
9116
|
"'signal manager not set'"
|
|
8950
9117
|
]
|
|
8951
9118
|
});
|
|
8952
|
-
|
|
9119
|
+
invariant26(this._networkManager, "network manager not set", {
|
|
8953
9120
|
F: __dxlog_file31,
|
|
8954
9121
|
L: 266,
|
|
8955
9122
|
S: this,
|
|
@@ -9177,4 +9344,4 @@ export {
|
|
|
9177
9344
|
importProfileData,
|
|
9178
9345
|
ClientServicesHost
|
|
9179
9346
|
};
|
|
9180
|
-
//# sourceMappingURL=chunk-
|
|
9347
|
+
//# sourceMappingURL=chunk-CT42KAJ2.mjs.map
|