@dxos/client-services 0.6.12-main.78ddbdf → 0.6.12-main.7907542
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/{chunk-XSFLJVDP.mjs → chunk-6UTFANWL.mjs} +686 -304
- package/dist/lib/browser/chunk-6UTFANWL.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 +2 -2
- package/dist/lib/browser/testing/index.mjs.map +2 -2
- package/dist/lib/node/{chunk-F3WGFGEN.cjs → chunk-2UUETFZ2.cjs} +776 -394
- package/dist/lib/node/chunk-2UUETFZ2.cjs.map +7 -0
- package/dist/lib/node/index.cjs +45 -45
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +8 -8
- package/dist/lib/node/testing/index.cjs.map +2 -2
- package/dist/lib/node-esm/{chunk-3HDLTAT2.mjs → chunk-EQAI46LQ.mjs} +686 -304
- package/dist/lib/node-esm/chunk-EQAI46LQ.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 +2 -2
- package/dist/lib/node-esm/testing/index.mjs.map +2 -2
- package/dist/types/src/packlets/identity/authenticator.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/contacts-service.d.ts +1 -1
- package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -1
- package/dist/types/src/packlets/identity/identity.d.ts +1 -0
- package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-context.d.ts +4 -2
- package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +1 -0
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts +5 -1
- package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts +3 -1
- package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts +2 -0
- package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +31 -6
- package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
- package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +38 -38
- package/src/packlets/identity/authenticator.ts +5 -2
- package/src/packlets/identity/contacts-service.ts +1 -1
- package/src/packlets/identity/identity.ts +4 -0
- package/src/packlets/services/service-context.ts +41 -17
- package/src/packlets/services/service-host.ts +7 -5
- package/src/packlets/spaces/data-space-manager.ts +32 -4
- package/src/packlets/spaces/data-space.ts +27 -4
- package/src/packlets/spaces/edge-feed-replicator.test.ts +22 -15
- package/src/packlets/spaces/edge-feed-replicator.ts +45 -25
- package/src/packlets/spaces/notarization-plugin.test.ts +8 -4
- package/src/packlets/spaces/notarization-plugin.ts +169 -29
- package/src/packlets/spaces/spaces-service.ts +6 -1
- package/src/packlets/testing/test-builder.ts +1 -1
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-XSFLJVDP.mjs.map +0 -7
- package/dist/lib/node/chunk-F3WGFGEN.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-3HDLTAT2.mjs.map +0 -7
|
@@ -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.6.12-main.
|
|
400
|
+
var DXOS_VERSION = "0.6.12-main.7907542";
|
|
401
401
|
|
|
402
402
|
// packages/sdk/client-services/src/packlets/services/platform.ts
|
|
403
403
|
import { Platform } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -670,7 +670,7 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
670
670
|
return false;
|
|
671
671
|
}
|
|
672
672
|
if (this._isTrustedKey(credential.issuer)) {
|
|
673
|
-
log2("key is
|
|
673
|
+
log2("key is trusted -- auth success", {
|
|
674
674
|
key: credential.issuer
|
|
675
675
|
}, {
|
|
676
676
|
F: __dxlog_file4,
|
|
@@ -697,7 +697,10 @@ var TrustedKeySetAuthVerifier = class {
|
|
|
697
697
|
trigger.wake(true);
|
|
698
698
|
} else {
|
|
699
699
|
log2("key is not currently in trusted set, waiting...", {
|
|
700
|
-
key: credential.issuer
|
|
700
|
+
key: credential.issuer,
|
|
701
|
+
trusted: [
|
|
702
|
+
...this._params.trustedKeysProvider()
|
|
703
|
+
]
|
|
701
704
|
}, {
|
|
702
705
|
F: __dxlog_file4,
|
|
703
706
|
L: 84,
|
|
@@ -730,11 +733,17 @@ import { Context as Context3, Resource } from "@dxos/context";
|
|
|
730
733
|
import { EdgeConnectionClosedError, EdgeIdentityChangedError } from "@dxos/edge-client";
|
|
731
734
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
732
735
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
733
|
-
import { log as log3 } from "@dxos/log";
|
|
736
|
+
import { log as log3, logInfo } from "@dxos/log";
|
|
734
737
|
import { EdgeService } from "@dxos/protocols";
|
|
735
738
|
import { buf } from "@dxos/protocols/buf";
|
|
736
739
|
import { MessageSchema as RouterMessageSchema } from "@dxos/protocols/buf/dxos/edge/messenger_pb";
|
|
737
740
|
import { ComplexMap as ComplexMap2, arrayToBuffer, bufferToArray, defaultMap, rangeFromTo } from "@dxos/util";
|
|
741
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
742
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
743
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
744
|
+
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;
|
|
745
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
746
|
+
}
|
|
738
747
|
function _using_ctx() {
|
|
739
748
|
var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
|
|
740
749
|
var err = new Error();
|
|
@@ -816,6 +825,12 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
816
825
|
this._spaceId = spaceId;
|
|
817
826
|
}
|
|
818
827
|
async _open() {
|
|
828
|
+
log3("open", void 0, {
|
|
829
|
+
F: __dxlog_file5,
|
|
830
|
+
L: 56,
|
|
831
|
+
S: this,
|
|
832
|
+
C: (f, a) => f(...a)
|
|
833
|
+
});
|
|
819
834
|
this._ctx.onDispose(this._messenger.addListener((message) => {
|
|
820
835
|
if (!message.serviceId) {
|
|
821
836
|
return;
|
|
@@ -831,20 +846,20 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
831
846
|
_spaceId: this._spaceId
|
|
832
847
|
}, {
|
|
833
848
|
F: __dxlog_file5,
|
|
834
|
-
L:
|
|
849
|
+
L: 70,
|
|
835
850
|
S: this,
|
|
836
851
|
C: (f, a) => f(...a)
|
|
837
852
|
});
|
|
838
853
|
return;
|
|
839
854
|
}
|
|
840
855
|
const payload = decodeCbor(message.payload.value);
|
|
841
|
-
log3
|
|
856
|
+
log3("receive", {
|
|
842
857
|
from: message.source,
|
|
843
858
|
feedKey: payload.feedKey,
|
|
844
859
|
type: payload.type
|
|
845
860
|
}, {
|
|
846
861
|
F: __dxlog_file5,
|
|
847
|
-
L:
|
|
862
|
+
L: 75,
|
|
848
863
|
S: this,
|
|
849
864
|
C: (f, a) => f(...a)
|
|
850
865
|
});
|
|
@@ -852,46 +867,44 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
852
867
|
}));
|
|
853
868
|
this._messenger.connected.on(this._ctx, async () => {
|
|
854
869
|
await this._resetConnection();
|
|
855
|
-
this.
|
|
856
|
-
const connectionCtx = new Context3({
|
|
857
|
-
onError: async (err) => {
|
|
858
|
-
if (connectionCtx !== this._connectionCtx) {
|
|
859
|
-
return;
|
|
860
|
-
}
|
|
861
|
-
if (err instanceof EdgeIdentityChangedError || err instanceof EdgeConnectionClosedError) {
|
|
862
|
-
log3("resetting on reconnect", void 0, {
|
|
863
|
-
F: __dxlog_file5,
|
|
864
|
-
L: 86,
|
|
865
|
-
S: this,
|
|
866
|
-
C: (f, a) => f(...a)
|
|
867
|
-
});
|
|
868
|
-
await this._resetConnection();
|
|
869
|
-
} else {
|
|
870
|
-
this._ctx.raise(err);
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
}, {
|
|
874
|
-
F: __dxlog_file5,
|
|
875
|
-
L: 80
|
|
876
|
-
});
|
|
877
|
-
this._connectionCtx = connectionCtx;
|
|
878
|
-
log3("connection context created", void 0, {
|
|
879
|
-
F: __dxlog_file5,
|
|
880
|
-
L: 94,
|
|
881
|
-
S: this,
|
|
882
|
-
C: (f, a) => f(...a)
|
|
883
|
-
});
|
|
884
|
-
scheduleMicroTask(connectionCtx, async () => {
|
|
885
|
-
for (const feed of this._feeds.values()) {
|
|
886
|
-
await this._replicateFeed(connectionCtx, feed);
|
|
887
|
-
}
|
|
888
|
-
});
|
|
870
|
+
this._startReplication();
|
|
889
871
|
});
|
|
872
|
+
if (this._messenger.isConnected) {
|
|
873
|
+
this._startReplication();
|
|
874
|
+
}
|
|
890
875
|
}
|
|
891
876
|
async _close() {
|
|
877
|
+
log3("close", void 0, {
|
|
878
|
+
F: __dxlog_file5,
|
|
879
|
+
L: 91,
|
|
880
|
+
S: this,
|
|
881
|
+
C: (f, a) => f(...a)
|
|
882
|
+
});
|
|
892
883
|
await this._resetConnection();
|
|
893
884
|
}
|
|
885
|
+
_startReplication() {
|
|
886
|
+
this._connected = true;
|
|
887
|
+
const connectionCtx = this._createConnectionContext();
|
|
888
|
+
this._connectionCtx = connectionCtx;
|
|
889
|
+
log3("connection context created", void 0, {
|
|
890
|
+
F: __dxlog_file5,
|
|
891
|
+
L: 99,
|
|
892
|
+
S: this,
|
|
893
|
+
C: (f, a) => f(...a)
|
|
894
|
+
});
|
|
895
|
+
scheduleMicroTask(connectionCtx, async () => {
|
|
896
|
+
for (const feed of this._feeds.values()) {
|
|
897
|
+
await this._replicateFeed(connectionCtx, feed);
|
|
898
|
+
}
|
|
899
|
+
});
|
|
900
|
+
}
|
|
894
901
|
async _resetConnection() {
|
|
902
|
+
log3("resetConnection", void 0, {
|
|
903
|
+
F: __dxlog_file5,
|
|
904
|
+
L: 108,
|
|
905
|
+
S: this,
|
|
906
|
+
C: (f, a) => f(...a)
|
|
907
|
+
});
|
|
895
908
|
this._connected = false;
|
|
896
909
|
await this._connectionCtx?.dispose();
|
|
897
910
|
this._connectionCtx = void 0;
|
|
@@ -899,10 +912,12 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
899
912
|
}
|
|
900
913
|
async addFeed(feed) {
|
|
901
914
|
log3.info("addFeed", {
|
|
902
|
-
key: feed.key
|
|
915
|
+
key: feed.key,
|
|
916
|
+
connected: this._connected,
|
|
917
|
+
hasConnectionCtx: !!this._connectionCtx
|
|
903
918
|
}, {
|
|
904
919
|
F: __dxlog_file5,
|
|
905
|
-
L:
|
|
920
|
+
L: 116,
|
|
906
921
|
S: this,
|
|
907
922
|
C: (f, a) => f(...a)
|
|
908
923
|
});
|
|
@@ -915,6 +930,14 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
915
930
|
return defaultMap(this._pushMutex, key, () => new Mutex());
|
|
916
931
|
}
|
|
917
932
|
async _replicateFeed(ctx, feed) {
|
|
933
|
+
log3("replicateFeed", {
|
|
934
|
+
key: feed.key
|
|
935
|
+
}, {
|
|
936
|
+
F: __dxlog_file5,
|
|
937
|
+
L: 129,
|
|
938
|
+
S: this,
|
|
939
|
+
C: (f, a) => f(...a)
|
|
940
|
+
});
|
|
918
941
|
await this._sendMessage({
|
|
919
942
|
type: "get-metadata",
|
|
920
943
|
feedKey: feed.key.toHex()
|
|
@@ -927,7 +950,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
927
950
|
if (!this._connectionCtx) {
|
|
928
951
|
log3.info("message dropped because connection was disposed", void 0, {
|
|
929
952
|
F: __dxlog_file5,
|
|
930
|
-
L:
|
|
953
|
+
L: 142,
|
|
931
954
|
S: this,
|
|
932
955
|
C: (f, a) => f(...a)
|
|
933
956
|
});
|
|
@@ -941,13 +964,13 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
941
964
|
};
|
|
942
965
|
log3.info("sending message", logPayload, {
|
|
943
966
|
F: __dxlog_file5,
|
|
944
|
-
L:
|
|
967
|
+
L: 148,
|
|
945
968
|
S: this,
|
|
946
969
|
C: (f, a) => f(...a)
|
|
947
970
|
});
|
|
948
971
|
invariant2(message.feedKey, void 0, {
|
|
949
972
|
F: __dxlog_file5,
|
|
950
|
-
L:
|
|
973
|
+
L: 150,
|
|
951
974
|
S: this,
|
|
952
975
|
A: [
|
|
953
976
|
"message.feedKey",
|
|
@@ -955,6 +978,14 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
955
978
|
]
|
|
956
979
|
});
|
|
957
980
|
const payloadValue = bufferToArray(encodeCbor(message));
|
|
981
|
+
log3("send", {
|
|
982
|
+
type: message.type
|
|
983
|
+
}, {
|
|
984
|
+
F: __dxlog_file5,
|
|
985
|
+
L: 153,
|
|
986
|
+
S: this,
|
|
987
|
+
C: (f, a) => f(...a)
|
|
988
|
+
});
|
|
958
989
|
await this._messenger.send(buf.create(RouterMessageSchema, {
|
|
959
990
|
source: {
|
|
960
991
|
identityKey: this._messenger.identityKey,
|
|
@@ -970,7 +1001,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
970
1001
|
if (!this._connectionCtx) {
|
|
971
1002
|
log3.warn("received message after connection context was disposed", void 0, {
|
|
972
1003
|
F: __dxlog_file5,
|
|
973
|
-
L:
|
|
1004
|
+
L: 168,
|
|
974
1005
|
S: this,
|
|
975
1006
|
C: (f, a) => f(...a)
|
|
976
1007
|
});
|
|
@@ -985,7 +1016,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
985
1016
|
message
|
|
986
1017
|
}, {
|
|
987
1018
|
F: __dxlog_file5,
|
|
988
|
-
L:
|
|
1019
|
+
L: 174,
|
|
989
1020
|
S: this,
|
|
990
1021
|
C: (f, a) => f(...a)
|
|
991
1022
|
});
|
|
@@ -996,7 +1027,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
996
1027
|
feedKey
|
|
997
1028
|
}, {
|
|
998
1029
|
F: __dxlog_file5,
|
|
999
|
-
L:
|
|
1030
|
+
L: 179,
|
|
1000
1031
|
S: this,
|
|
1001
1032
|
C: (f, a) => f(...a)
|
|
1002
1033
|
});
|
|
@@ -1029,7 +1060,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1029
1060
|
blocks: message.blocks.map((b) => b.index)
|
|
1030
1061
|
}, {
|
|
1031
1062
|
F: __dxlog_file5,
|
|
1032
|
-
L:
|
|
1063
|
+
L: 201,
|
|
1033
1064
|
S: this,
|
|
1034
1065
|
C: (f, a) => f(...a)
|
|
1035
1066
|
});
|
|
@@ -1040,7 +1071,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1040
1071
|
feedKey
|
|
1041
1072
|
}, {
|
|
1042
1073
|
F: __dxlog_file5,
|
|
1043
|
-
L:
|
|
1074
|
+
L: 206,
|
|
1044
1075
|
S: this,
|
|
1045
1076
|
C: (f, a) => f(...a)
|
|
1046
1077
|
});
|
|
@@ -1054,7 +1085,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1054
1085
|
...message
|
|
1055
1086
|
}, {
|
|
1056
1087
|
F: __dxlog_file5,
|
|
1057
|
-
L:
|
|
1088
|
+
L: 215,
|
|
1058
1089
|
S: this,
|
|
1059
1090
|
C: (f, a) => f(...a)
|
|
1060
1091
|
});
|
|
@@ -1069,7 +1100,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1069
1100
|
to
|
|
1070
1101
|
}, {
|
|
1071
1102
|
F: __dxlog_file5,
|
|
1072
|
-
L:
|
|
1103
|
+
L: 222,
|
|
1073
1104
|
S: this,
|
|
1074
1105
|
C: (f, a) => f(...a)
|
|
1075
1106
|
});
|
|
@@ -1079,7 +1110,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1079
1110
|
});
|
|
1080
1111
|
invariant2(data instanceof Uint8Array, void 0, {
|
|
1081
1112
|
F: __dxlog_file5,
|
|
1082
|
-
L:
|
|
1113
|
+
L: 227,
|
|
1083
1114
|
S: this,
|
|
1084
1115
|
A: [
|
|
1085
1116
|
"data instanceof Uint8Array",
|
|
@@ -1107,7 +1138,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1107
1138
|
blocks: blocks.length
|
|
1108
1139
|
}, {
|
|
1109
1140
|
F: __dxlog_file5,
|
|
1110
|
-
L:
|
|
1141
|
+
L: 248,
|
|
1111
1142
|
S: this,
|
|
1112
1143
|
C: (f, a) => f(...a)
|
|
1113
1144
|
});
|
|
@@ -1129,7 +1160,7 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1129
1160
|
if (!this._remoteLength.has(feed.key)) {
|
|
1130
1161
|
log3("blocks not pushed because remote length is unknown", void 0, {
|
|
1131
1162
|
F: __dxlog_file5,
|
|
1132
|
-
L:
|
|
1163
|
+
L: 269,
|
|
1133
1164
|
S: this,
|
|
1134
1165
|
C: (f, a) => f(...a)
|
|
1135
1166
|
});
|
|
@@ -1145,7 +1176,34 @@ var EdgeFeedReplicator = class extends Resource {
|
|
|
1145
1176
|
_usingCtx.d();
|
|
1146
1177
|
}
|
|
1147
1178
|
}
|
|
1179
|
+
_createConnectionContext() {
|
|
1180
|
+
const connectionCtx = new Context3({
|
|
1181
|
+
onError: async (err) => {
|
|
1182
|
+
if (connectionCtx !== this._connectionCtx) {
|
|
1183
|
+
return;
|
|
1184
|
+
}
|
|
1185
|
+
if (err instanceof EdgeIdentityChangedError || err instanceof EdgeConnectionClosedError) {
|
|
1186
|
+
log3("resetting on reconnect", void 0, {
|
|
1187
|
+
F: __dxlog_file5,
|
|
1188
|
+
L: 286,
|
|
1189
|
+
S: this,
|
|
1190
|
+
C: (f, a) => f(...a)
|
|
1191
|
+
});
|
|
1192
|
+
await this._resetConnection();
|
|
1193
|
+
} else {
|
|
1194
|
+
this._ctx.raise(err);
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
}, {
|
|
1198
|
+
F: __dxlog_file5,
|
|
1199
|
+
L: 280
|
|
1200
|
+
});
|
|
1201
|
+
return connectionCtx;
|
|
1202
|
+
}
|
|
1148
1203
|
};
|
|
1204
|
+
_ts_decorate([
|
|
1205
|
+
logInfo
|
|
1206
|
+
], EdgeFeedReplicator.prototype, "_spaceId", void 0);
|
|
1149
1207
|
var bufferizeBlock = (block) => ({
|
|
1150
1208
|
index: block.index,
|
|
1151
1209
|
data: arrayToBuffer(block.data),
|
|
@@ -1160,7 +1218,7 @@ var bufferizeBlock = (block) => ({
|
|
|
1160
1218
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
1161
1219
|
import { Event as Event7, Mutex as Mutex2, scheduleTask as scheduleTask4, sleep as sleep3, synchronized as synchronized2, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
1162
1220
|
import { AUTH_TIMEOUT as AUTH_TIMEOUT2 } from "@dxos/client-protocol";
|
|
1163
|
-
import { Context as
|
|
1221
|
+
import { Context as Context5, ContextDisposedError, cancelWithContext as cancelWithContext2 } from "@dxos/context";
|
|
1164
1222
|
import { timed, warnAfterTimeout } from "@dxos/debug";
|
|
1165
1223
|
import { createMappedFeedWriter } from "@dxos/echo-pipeline";
|
|
1166
1224
|
import { SpaceDocVersion as SpaceDocVersion3 } from "@dxos/echo-protocol";
|
|
@@ -1395,53 +1453,67 @@ var runEpochMigration = async (ctx, context) => {
|
|
|
1395
1453
|
};
|
|
1396
1454
|
|
|
1397
1455
|
// packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
|
|
1398
|
-
import { DeferredTask, Event as Event3, scheduleTask as scheduleTask2, sleep, TimeoutError, Trigger as Trigger2 } from "@dxos/async";
|
|
1399
|
-
import {
|
|
1456
|
+
import { DeferredTask, Event as Event3, scheduleTask as scheduleTask2, sleep, TimeoutError, Trigger as Trigger2, scheduleMicroTask as scheduleMicroTask2 } from "@dxos/async";
|
|
1457
|
+
import { rejectOnDispose, Resource as Resource3 } from "@dxos/context";
|
|
1458
|
+
import { verifyCredential as verifyCredential2 } from "@dxos/credentials";
|
|
1400
1459
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
1401
1460
|
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
1402
|
-
import { log as log5 } from "@dxos/log";
|
|
1461
|
+
import { logInfo as logInfo2, log as log5 } from "@dxos/log";
|
|
1462
|
+
import { EdgeCallFailedError } from "@dxos/protocols";
|
|
1403
1463
|
import { schema as schema2 } from "@dxos/protocols/proto";
|
|
1404
1464
|
import { RpcExtension } from "@dxos/teleport";
|
|
1405
1465
|
import { ComplexMap as ComplexMap3, ComplexSet, entry } from "@dxos/util";
|
|
1466
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
1467
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1468
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1469
|
+
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;
|
|
1470
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1471
|
+
}
|
|
1406
1472
|
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
1407
1473
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
1408
1474
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
1409
1475
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
1476
|
+
var MAX_EDGE_RETRIES = 2;
|
|
1410
1477
|
var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
|
|
1411
|
-
var
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
L: 62
|
|
1416
|
-
});
|
|
1478
|
+
var credentialCodec = schema2.getCodecForType("dxos.halo.credentials.Credential");
|
|
1479
|
+
var NotarizationPlugin = class extends Resource3 {
|
|
1480
|
+
constructor(params) {
|
|
1481
|
+
super();
|
|
1417
1482
|
this._extensionOpened = new Event3();
|
|
1418
1483
|
this._extensions = /* @__PURE__ */ new Set();
|
|
1419
1484
|
this._processedCredentials = new ComplexSet(PublicKey4.hash);
|
|
1420
1485
|
this._processCredentialsTriggers = new ComplexMap3(PublicKey4.hash);
|
|
1486
|
+
this._spaceId = params.spaceId;
|
|
1487
|
+
if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
|
|
1488
|
+
this._edgeClient = params.edgeClient;
|
|
1489
|
+
}
|
|
1421
1490
|
}
|
|
1422
1491
|
get hasWriter() {
|
|
1423
1492
|
return !!this._writer;
|
|
1424
1493
|
}
|
|
1425
|
-
async
|
|
1494
|
+
async _open() {
|
|
1495
|
+
if (this._edgeClient && this._writer) {
|
|
1496
|
+
this._notarizePendingEdgeCredentials(this._edgeClient, this._writer);
|
|
1497
|
+
}
|
|
1426
1498
|
}
|
|
1427
|
-
async
|
|
1499
|
+
async _close() {
|
|
1428
1500
|
await this._ctx.dispose();
|
|
1429
1501
|
}
|
|
1430
1502
|
/**
|
|
1431
1503
|
* Request credentials to be notarized.
|
|
1432
1504
|
*/
|
|
1433
|
-
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
|
|
1505
|
+
async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY, edgeRetryJitter }) {
|
|
1434
1506
|
log5("notarize", {
|
|
1435
1507
|
credentials
|
|
1436
1508
|
}, {
|
|
1437
1509
|
F: __dxlog_file7,
|
|
1438
|
-
L:
|
|
1510
|
+
L: 126,
|
|
1439
1511
|
S: this,
|
|
1440
1512
|
C: (f, a) => f(...a)
|
|
1441
1513
|
});
|
|
1442
1514
|
invariant4(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
1443
1515
|
F: __dxlog_file7,
|
|
1444
|
-
L:
|
|
1516
|
+
L: 127,
|
|
1445
1517
|
S: this,
|
|
1446
1518
|
A: [
|
|
1447
1519
|
"credentials.every((credential) => credential.id)",
|
|
@@ -1455,7 +1527,7 @@ var NotarizationPlugin = class {
|
|
|
1455
1527
|
err
|
|
1456
1528
|
}, {
|
|
1457
1529
|
F: __dxlog_file7,
|
|
1458
|
-
L:
|
|
1530
|
+
L: 135,
|
|
1459
1531
|
S: this,
|
|
1460
1532
|
C: (f, a) => f(...a)
|
|
1461
1533
|
});
|
|
@@ -1465,21 +1537,37 @@ var NotarizationPlugin = class {
|
|
|
1465
1537
|
});
|
|
1466
1538
|
opCtx?.onDispose(() => ctx.dispose());
|
|
1467
1539
|
if (timeout !== 0) {
|
|
1468
|
-
|
|
1469
|
-
log5.warn("Notarization timeout", {
|
|
1470
|
-
timeout,
|
|
1471
|
-
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
1472
|
-
}, {
|
|
1473
|
-
F: __dxlog_file7,
|
|
1474
|
-
L: 111,
|
|
1475
|
-
S: this,
|
|
1476
|
-
C: (f, a) => f(...a)
|
|
1477
|
-
});
|
|
1478
|
-
void ctx.dispose();
|
|
1479
|
-
errors.throw(new TimeoutError(timeout, "Notarization timed out"));
|
|
1480
|
-
}, timeout);
|
|
1540
|
+
this._scheduleTimeout(ctx, errors, timeout);
|
|
1481
1541
|
}
|
|
1482
1542
|
const allNotarized = Promise.all(credentials.map((credential) => this._waitUntilProcessed(credential.id)));
|
|
1543
|
+
this._tryNotarizeCredentialsWithPeers(ctx, credentials, {
|
|
1544
|
+
retryTimeout,
|
|
1545
|
+
successDelay
|
|
1546
|
+
});
|
|
1547
|
+
if (this._edgeClient) {
|
|
1548
|
+
this._tryNotarizeCredentialsWithEdge(ctx, this._edgeClient, credentials, {
|
|
1549
|
+
retryTimeout,
|
|
1550
|
+
successDelay,
|
|
1551
|
+
jitter: edgeRetryJitter
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
try {
|
|
1555
|
+
await Promise.race([
|
|
1556
|
+
rejectOnDispose(ctx),
|
|
1557
|
+
allNotarized,
|
|
1558
|
+
errors.wait()
|
|
1559
|
+
]);
|
|
1560
|
+
log5("done", void 0, {
|
|
1561
|
+
F: __dxlog_file7,
|
|
1562
|
+
L: 160,
|
|
1563
|
+
S: this,
|
|
1564
|
+
C: (f, a) => f(...a)
|
|
1565
|
+
});
|
|
1566
|
+
} finally {
|
|
1567
|
+
await ctx.dispose();
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
_tryNotarizeCredentialsWithPeers(ctx, credentials, { retryTimeout, successDelay }) {
|
|
1483
1571
|
const peersTried = /* @__PURE__ */ new Set();
|
|
1484
1572
|
const notarizeTask = new DeferredTask(ctx, async () => {
|
|
1485
1573
|
try {
|
|
@@ -1494,7 +1582,7 @@ var NotarizationPlugin = class {
|
|
|
1494
1582
|
retryIn: retryTimeout
|
|
1495
1583
|
}, {
|
|
1496
1584
|
F: __dxlog_file7,
|
|
1497
|
-
L:
|
|
1585
|
+
L: 183,
|
|
1498
1586
|
S: this,
|
|
1499
1587
|
C: (f, a) => f(...a)
|
|
1500
1588
|
});
|
|
@@ -1508,7 +1596,7 @@ var NotarizationPlugin = class {
|
|
|
1508
1596
|
credentialId: credentials.map((credential) => credential.id)
|
|
1509
1597
|
}, {
|
|
1510
1598
|
F: __dxlog_file7,
|
|
1511
|
-
L:
|
|
1599
|
+
L: 190,
|
|
1512
1600
|
S: this,
|
|
1513
1601
|
C: (f, a) => f(...a)
|
|
1514
1602
|
});
|
|
@@ -1517,7 +1605,7 @@ var NotarizationPlugin = class {
|
|
|
1517
1605
|
});
|
|
1518
1606
|
log5("success", void 0, {
|
|
1519
1607
|
F: __dxlog_file7,
|
|
1520
|
-
L:
|
|
1608
|
+
L: 194,
|
|
1521
1609
|
S: this,
|
|
1522
1610
|
C: (f, a) => f(...a)
|
|
1523
1611
|
});
|
|
@@ -1526,7 +1614,7 @@ var NotarizationPlugin = class {
|
|
|
1526
1614
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
1527
1615
|
log5.info("error notarizing (recoverable)", err, {
|
|
1528
1616
|
F: __dxlog_file7,
|
|
1529
|
-
L:
|
|
1617
|
+
L: 199,
|
|
1530
1618
|
S: this,
|
|
1531
1619
|
C: (f, a) => f(...a)
|
|
1532
1620
|
});
|
|
@@ -1536,21 +1624,33 @@ var NotarizationPlugin = class {
|
|
|
1536
1624
|
});
|
|
1537
1625
|
notarizeTask.schedule();
|
|
1538
1626
|
this._extensionOpened.on(ctx, () => notarizeTask.schedule());
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1627
|
+
}
|
|
1628
|
+
_tryNotarizeCredentialsWithEdge(ctx, client, credentials, timeouts) {
|
|
1629
|
+
const encodedCredentials = credentials.map((credential) => {
|
|
1630
|
+
const binary = credentialCodec.encode(credential);
|
|
1631
|
+
return Buffer.from(binary).toString("base64");
|
|
1632
|
+
});
|
|
1633
|
+
scheduleTask2(ctx, async () => {
|
|
1634
|
+
try {
|
|
1635
|
+
await client.notarizeCredentials(this._spaceId, {
|
|
1636
|
+
credentials: encodedCredentials
|
|
1637
|
+
}, {
|
|
1638
|
+
retry: {
|
|
1639
|
+
count: MAX_EDGE_RETRIES,
|
|
1640
|
+
timeout: timeouts.retryTimeout,
|
|
1641
|
+
jitter: timeouts.jitter
|
|
1642
|
+
}
|
|
1643
|
+
});
|
|
1644
|
+
log5("edge notarization success", void 0, {
|
|
1645
|
+
F: __dxlog_file7,
|
|
1646
|
+
L: 227,
|
|
1647
|
+
S: this,
|
|
1648
|
+
C: (f, a) => f(...a)
|
|
1649
|
+
});
|
|
1650
|
+
} catch (error) {
|
|
1651
|
+
handleEdgeError(error);
|
|
1652
|
+
}
|
|
1653
|
+
});
|
|
1554
1654
|
}
|
|
1555
1655
|
/**
|
|
1556
1656
|
* Called with credentials arriving from the control pipeline.
|
|
@@ -1566,7 +1666,7 @@ var NotarizationPlugin = class {
|
|
|
1566
1666
|
setWriter(writer) {
|
|
1567
1667
|
invariant4(!this._writer, "Writer already set.", {
|
|
1568
1668
|
F: __dxlog_file7,
|
|
1569
|
-
L:
|
|
1669
|
+
L: 247,
|
|
1570
1670
|
S: this,
|
|
1571
1671
|
A: [
|
|
1572
1672
|
"!this._writer",
|
|
@@ -1574,6 +1674,59 @@ var NotarizationPlugin = class {
|
|
|
1574
1674
|
]
|
|
1575
1675
|
});
|
|
1576
1676
|
this._writer = writer;
|
|
1677
|
+
if (this._edgeClient) {
|
|
1678
|
+
this._notarizePendingEdgeCredentials(this._edgeClient, writer);
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
/**
|
|
1682
|
+
* The method is used only for adding agent feeds to spaces.
|
|
1683
|
+
* When an agent is created we can admit them into all the existing spaces. In case the operation fails
|
|
1684
|
+
* this method will fix it on the next space open.
|
|
1685
|
+
* Given how rarely this happens there's no need to poll the endpoint.
|
|
1686
|
+
*/
|
|
1687
|
+
_notarizePendingEdgeCredentials(client, writer) {
|
|
1688
|
+
scheduleMicroTask2(this._ctx, async () => {
|
|
1689
|
+
try {
|
|
1690
|
+
const response = await client.getCredentialsForNotarization(this._spaceId, {
|
|
1691
|
+
retry: {
|
|
1692
|
+
count: MAX_EDGE_RETRIES
|
|
1693
|
+
}
|
|
1694
|
+
});
|
|
1695
|
+
const credentials = response.awaitingNotarization.credentials;
|
|
1696
|
+
if (!credentials.length) {
|
|
1697
|
+
log5("edge did not return credentials for notarization", void 0, {
|
|
1698
|
+
F: __dxlog_file7,
|
|
1699
|
+
L: 269,
|
|
1700
|
+
S: this,
|
|
1701
|
+
C: (f, a) => f(...a)
|
|
1702
|
+
});
|
|
1703
|
+
return;
|
|
1704
|
+
}
|
|
1705
|
+
log5("got edge credentials for notarization", {
|
|
1706
|
+
count: credentials.length
|
|
1707
|
+
}, {
|
|
1708
|
+
F: __dxlog_file7,
|
|
1709
|
+
L: 273,
|
|
1710
|
+
S: this,
|
|
1711
|
+
C: (f, a) => f(...a)
|
|
1712
|
+
});
|
|
1713
|
+
const decodedCredentials = credentials.map((credential) => {
|
|
1714
|
+
const binary = Buffer.from(credential, "base64");
|
|
1715
|
+
return credentialCodec.decode(binary);
|
|
1716
|
+
});
|
|
1717
|
+
await this._notarizeCredentials(writer, decodedCredentials);
|
|
1718
|
+
log5.info("notarized edge credentials", {
|
|
1719
|
+
count: decodedCredentials.length
|
|
1720
|
+
}, {
|
|
1721
|
+
F: __dxlog_file7,
|
|
1722
|
+
L: 282,
|
|
1723
|
+
S: this,
|
|
1724
|
+
C: (f, a) => f(...a)
|
|
1725
|
+
});
|
|
1726
|
+
} catch (error) {
|
|
1727
|
+
handleEdgeError(error);
|
|
1728
|
+
}
|
|
1729
|
+
});
|
|
1577
1730
|
}
|
|
1578
1731
|
async _waitUntilProcessed(id) {
|
|
1579
1732
|
if (this._processedCredentials.has(id)) {
|
|
@@ -1588,10 +1741,13 @@ var NotarizationPlugin = class {
|
|
|
1588
1741
|
if (!this._writer) {
|
|
1589
1742
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
1590
1743
|
}
|
|
1591
|
-
|
|
1744
|
+
await this._notarizeCredentials(this._writer, request.credentials ?? []);
|
|
1745
|
+
}
|
|
1746
|
+
async _notarizeCredentials(writer, credentials) {
|
|
1747
|
+
for (const credential of credentials) {
|
|
1592
1748
|
invariant4(credential.id, "Credential must have an id", {
|
|
1593
1749
|
F: __dxlog_file7,
|
|
1594
|
-
L:
|
|
1750
|
+
L: 308,
|
|
1595
1751
|
S: this,
|
|
1596
1752
|
A: [
|
|
1597
1753
|
"credential.id",
|
|
@@ -1601,7 +1757,11 @@ var NotarizationPlugin = class {
|
|
|
1601
1757
|
if (this._processedCredentials.has(credential.id)) {
|
|
1602
1758
|
continue;
|
|
1603
1759
|
}
|
|
1604
|
-
await
|
|
1760
|
+
const verificationResult = await verifyCredential2(credential);
|
|
1761
|
+
if (verificationResult.kind === "fail") {
|
|
1762
|
+
throw new Error(`Credential verification failed: ${verificationResult.errors.join("\n")}.`);
|
|
1763
|
+
}
|
|
1764
|
+
await writer.write(credential);
|
|
1605
1765
|
}
|
|
1606
1766
|
}
|
|
1607
1767
|
createExtension() {
|
|
@@ -1611,7 +1771,7 @@ var NotarizationPlugin = class {
|
|
|
1611
1771
|
peer: extension.localPeerId
|
|
1612
1772
|
}, {
|
|
1613
1773
|
F: __dxlog_file7,
|
|
1614
|
-
L:
|
|
1774
|
+
L: 323,
|
|
1615
1775
|
S: this,
|
|
1616
1776
|
C: (f, a) => f(...a)
|
|
1617
1777
|
});
|
|
@@ -1623,7 +1783,7 @@ var NotarizationPlugin = class {
|
|
|
1623
1783
|
peer: extension.localPeerId
|
|
1624
1784
|
}, {
|
|
1625
1785
|
F: __dxlog_file7,
|
|
1626
|
-
L:
|
|
1786
|
+
L: 328,
|
|
1627
1787
|
S: this,
|
|
1628
1788
|
C: (f, a) => f(...a)
|
|
1629
1789
|
});
|
|
@@ -1633,6 +1793,43 @@ var NotarizationPlugin = class {
|
|
|
1633
1793
|
});
|
|
1634
1794
|
return extension;
|
|
1635
1795
|
}
|
|
1796
|
+
_scheduleTimeout(ctx, errors, timeout) {
|
|
1797
|
+
scheduleTask2(ctx, () => {
|
|
1798
|
+
log5.warn("Notarization timeout", {
|
|
1799
|
+
timeout,
|
|
1800
|
+
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
1801
|
+
}, {
|
|
1802
|
+
F: __dxlog_file7,
|
|
1803
|
+
L: 340,
|
|
1804
|
+
S: this,
|
|
1805
|
+
C: (f, a) => f(...a)
|
|
1806
|
+
});
|
|
1807
|
+
void ctx.dispose();
|
|
1808
|
+
errors.throw(new TimeoutError(timeout, "Notarization timed out"));
|
|
1809
|
+
}, timeout);
|
|
1810
|
+
}
|
|
1811
|
+
};
|
|
1812
|
+
_ts_decorate2([
|
|
1813
|
+
logInfo2
|
|
1814
|
+
], NotarizationPlugin.prototype, "_spaceId", void 0);
|
|
1815
|
+
var handleEdgeError = (error) => {
|
|
1816
|
+
if (!(error instanceof EdgeCallFailedError) || error.errorData) {
|
|
1817
|
+
log5.catch(error, void 0, {
|
|
1818
|
+
F: __dxlog_file7,
|
|
1819
|
+
L: 354,
|
|
1820
|
+
S: void 0,
|
|
1821
|
+
C: (f, a) => f(...a)
|
|
1822
|
+
});
|
|
1823
|
+
} else {
|
|
1824
|
+
log5.info("Edge notarization failure", {
|
|
1825
|
+
reason: error.reason
|
|
1826
|
+
}, {
|
|
1827
|
+
F: __dxlog_file7,
|
|
1828
|
+
L: 356,
|
|
1829
|
+
S: void 0,
|
|
1830
|
+
C: (f, a) => f(...a)
|
|
1831
|
+
});
|
|
1832
|
+
}
|
|
1636
1833
|
};
|
|
1637
1834
|
var NotarizationTeleportExtension = class extends RpcExtension {
|
|
1638
1835
|
constructor(_params) {
|
|
@@ -1727,7 +1924,7 @@ var DefaultSpaceStateMachine = class {
|
|
|
1727
1924
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
1728
1925
|
import { Event as Event4, synchronized, trackLeaks } from "@dxos/async";
|
|
1729
1926
|
import { PropertiesType } from "@dxos/client-protocol";
|
|
1730
|
-
import { LifecycleState, Resource as
|
|
1927
|
+
import { LifecycleState, Resource as Resource4, cancelWithContext } from "@dxos/context";
|
|
1731
1928
|
import { createAdmissionCredentials, getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
|
|
1732
1929
|
import { convertLegacyReferences as convertLegacyReferences2, findInlineObjectOfType as findInlineObjectOfType2, AuthStatus, CredentialServerExtension } from "@dxos/echo-pipeline";
|
|
1733
1930
|
import { LEGACY_TYPE_PROPERTIES, SpaceDocVersion as SpaceDocVersion2, encodeReference } from "@dxos/echo-protocol";
|
|
@@ -1738,6 +1935,7 @@ import { PublicKey as PublicKey5 } from "@dxos/keys";
|
|
|
1738
1935
|
import { log as log7 } from "@dxos/log";
|
|
1739
1936
|
import { AlreadyJoinedError, trace as Trace } from "@dxos/protocols";
|
|
1740
1937
|
import { Invitation, SpaceState } from "@dxos/protocols/proto/dxos/client/services";
|
|
1938
|
+
import { EdgeReplicationSetting } from "@dxos/protocols/proto/dxos/echo/metadata";
|
|
1741
1939
|
import { SpaceMember as SpaceMember3 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1742
1940
|
import { Gossip, Presence } from "@dxos/teleport-extension-gossip";
|
|
1743
1941
|
import { trace } from "@dxos/tracing";
|
|
@@ -1814,7 +2012,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
1814
2012
|
};
|
|
1815
2013
|
|
|
1816
2014
|
// packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
|
|
1817
|
-
function
|
|
2015
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
1818
2016
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1819
2017
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1820
2018
|
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;
|
|
@@ -1824,13 +2022,14 @@ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/sr
|
|
|
1824
2022
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
1825
2023
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
1826
2024
|
var DEFAULT_SPACE_KEY = "__DEFAULT__";
|
|
1827
|
-
var DataSpaceManager = class extends
|
|
2025
|
+
var DataSpaceManager = class extends Resource4 {
|
|
1828
2026
|
constructor(params) {
|
|
1829
2027
|
super();
|
|
1830
2028
|
this.updated = new Event4();
|
|
1831
2029
|
this._spaces = new ComplexMap4(PublicKey5.hash);
|
|
1832
2030
|
this._instanceId = PublicKey5.random().toHex();
|
|
1833
2031
|
this._edgeConnection = void 0;
|
|
2032
|
+
this._edgeHttpClient = void 0;
|
|
1834
2033
|
this._edgeFeatures = void 0;
|
|
1835
2034
|
this._meshReplicator = void 0;
|
|
1836
2035
|
this._echoEdgeReplicator = void 0;
|
|
@@ -1846,6 +2045,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
1846
2045
|
this._edgeConnection = params.edgeConnection;
|
|
1847
2046
|
this._edgeFeatures = params.edgeFeatures;
|
|
1848
2047
|
this._echoEdgeReplicator = params.echoEdgeReplicator;
|
|
2048
|
+
this._edgeHttpClient = params.edgeHttpClient;
|
|
1849
2049
|
this._runtimeParams = params.runtimeParams;
|
|
1850
2050
|
trace.diagnostic({
|
|
1851
2051
|
id: "spaces",
|
|
@@ -1877,7 +2077,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
1877
2077
|
async _open() {
|
|
1878
2078
|
log7("open", void 0, {
|
|
1879
2079
|
F: __dxlog_file9,
|
|
1880
|
-
L:
|
|
2080
|
+
L: 198,
|
|
1881
2081
|
S: this,
|
|
1882
2082
|
C: (f, a) => f(...a)
|
|
1883
2083
|
});
|
|
@@ -1885,7 +2085,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
1885
2085
|
id: this._instanceId
|
|
1886
2086
|
}), {
|
|
1887
2087
|
F: __dxlog_file9,
|
|
1888
|
-
L:
|
|
2088
|
+
L: 199,
|
|
1889
2089
|
S: this,
|
|
1890
2090
|
C: (f, a) => f(...a)
|
|
1891
2091
|
});
|
|
@@ -1893,7 +2093,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
1893
2093
|
spaces: this._metadataStore.spaces.length
|
|
1894
2094
|
}, {
|
|
1895
2095
|
F: __dxlog_file9,
|
|
1896
|
-
L:
|
|
2096
|
+
L: 200,
|
|
1897
2097
|
S: this,
|
|
1898
2098
|
C: (f, a) => f(...a)
|
|
1899
2099
|
});
|
|
@@ -1903,7 +2103,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
1903
2103
|
spaceMetadata
|
|
1904
2104
|
}, {
|
|
1905
2105
|
F: __dxlog_file9,
|
|
1906
|
-
L:
|
|
2106
|
+
L: 204,
|
|
1907
2107
|
S: this,
|
|
1908
2108
|
C: (f, a) => f(...a)
|
|
1909
2109
|
});
|
|
@@ -1914,7 +2114,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
1914
2114
|
err
|
|
1915
2115
|
}, {
|
|
1916
2116
|
F: __dxlog_file9,
|
|
1917
|
-
L:
|
|
2117
|
+
L: 207,
|
|
1918
2118
|
S: this,
|
|
1919
2119
|
C: (f, a) => f(...a)
|
|
1920
2120
|
});
|
|
@@ -1925,7 +2125,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
1925
2125
|
id: this._instanceId
|
|
1926
2126
|
}), {
|
|
1927
2127
|
F: __dxlog_file9,
|
|
1928
|
-
L:
|
|
2128
|
+
L: 213,
|
|
1929
2129
|
S: this,
|
|
1930
2130
|
C: (f, a) => f(...a)
|
|
1931
2131
|
});
|
|
@@ -1933,7 +2133,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
1933
2133
|
async _close() {
|
|
1934
2134
|
log7("close", void 0, {
|
|
1935
2135
|
F: __dxlog_file9,
|
|
1936
|
-
L:
|
|
2136
|
+
L: 218,
|
|
1937
2137
|
S: this,
|
|
1938
2138
|
C: (f, a) => f(...a)
|
|
1939
2139
|
});
|
|
@@ -1948,7 +2148,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
1948
2148
|
async createSpace() {
|
|
1949
2149
|
invariant5(this._lifecycleState === LifecycleState.OPEN, "Not open.", {
|
|
1950
2150
|
F: __dxlog_file9,
|
|
1951
|
-
L:
|
|
2151
|
+
L: 230,
|
|
1952
2152
|
S: this,
|
|
1953
2153
|
A: [
|
|
1954
2154
|
"this._lifecycleState === LifecycleState.OPEN",
|
|
@@ -1969,7 +2169,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
1969
2169
|
spaceKey
|
|
1970
2170
|
}, {
|
|
1971
2171
|
F: __dxlog_file9,
|
|
1972
|
-
L:
|
|
2172
|
+
L: 242,
|
|
1973
2173
|
S: this,
|
|
1974
2174
|
C: (f, a) => f(...a)
|
|
1975
2175
|
});
|
|
@@ -1981,7 +2181,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
1981
2181
|
const memberCredential = credentials[1];
|
|
1982
2182
|
invariant5(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
1983
2183
|
F: __dxlog_file9,
|
|
1984
|
-
L:
|
|
2184
|
+
L: 252,
|
|
1985
2185
|
S: this,
|
|
1986
2186
|
A: [
|
|
1987
2187
|
"getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2013,7 +2213,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
2013
2213
|
spaceId: space.id
|
|
2014
2214
|
}, {
|
|
2015
2215
|
F: __dxlog_file9,
|
|
2016
|
-
L:
|
|
2216
|
+
L: 277,
|
|
2017
2217
|
S: this,
|
|
2018
2218
|
C: (f, a) => f(...a)
|
|
2019
2219
|
});
|
|
@@ -2048,7 +2248,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
2048
2248
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
2049
2249
|
invariant5(automergeIndex, void 0, {
|
|
2050
2250
|
F: __dxlog_file9,
|
|
2051
|
-
L:
|
|
2251
|
+
L: 310,
|
|
2052
2252
|
S: this,
|
|
2053
2253
|
A: [
|
|
2054
2254
|
"automergeIndex",
|
|
@@ -2065,13 +2265,13 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
2065
2265
|
opts
|
|
2066
2266
|
}, {
|
|
2067
2267
|
F: __dxlog_file9,
|
|
2068
|
-
L:
|
|
2268
|
+
L: 319,
|
|
2069
2269
|
S: this,
|
|
2070
2270
|
C: (f, a) => f(...a)
|
|
2071
2271
|
});
|
|
2072
2272
|
invariant5(this._lifecycleState === LifecycleState.OPEN, "Not open.", {
|
|
2073
2273
|
F: __dxlog_file9,
|
|
2074
|
-
L:
|
|
2274
|
+
L: 320,
|
|
2075
2275
|
S: this,
|
|
2076
2276
|
A: [
|
|
2077
2277
|
"this._lifecycleState === LifecycleState.OPEN",
|
|
@@ -2080,7 +2280,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
2080
2280
|
});
|
|
2081
2281
|
invariant5(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
2082
2282
|
F: __dxlog_file9,
|
|
2083
|
-
L:
|
|
2283
|
+
L: 321,
|
|
2084
2284
|
S: this,
|
|
2085
2285
|
A: [
|
|
2086
2286
|
"!this._spaces.has(opts.spaceKey)",
|
|
@@ -2104,7 +2304,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
2104
2304
|
const space = this._spaceManager.spaces.get(options.spaceKey);
|
|
2105
2305
|
invariant5(space, void 0, {
|
|
2106
2306
|
F: __dxlog_file9,
|
|
2107
|
-
L:
|
|
2307
|
+
L: 341,
|
|
2108
2308
|
S: this,
|
|
2109
2309
|
A: [
|
|
2110
2310
|
"space",
|
|
@@ -2117,7 +2317,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
2117
2317
|
const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
|
|
2118
2318
|
invariant5(credentials[0].credential, void 0, {
|
|
2119
2319
|
F: __dxlog_file9,
|
|
2120
|
-
L:
|
|
2320
|
+
L: 360,
|
|
2121
2321
|
S: this,
|
|
2122
2322
|
A: [
|
|
2123
2323
|
"credentials[0].credential",
|
|
@@ -2127,7 +2327,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
2127
2327
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2128
2328
|
invariant5(getCredentialAssertion2(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2129
2329
|
F: __dxlog_file9,
|
|
2130
|
-
L:
|
|
2330
|
+
L: 362,
|
|
2131
2331
|
S: this,
|
|
2132
2332
|
A: [
|
|
2133
2333
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2161,12 +2361,35 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
2161
2361
|
}
|
|
2162
2362
|
});
|
|
2163
2363
|
}
|
|
2364
|
+
async setSpaceEdgeReplicationSetting(spaceKey, setting) {
|
|
2365
|
+
const space = this._spaces.get(spaceKey);
|
|
2366
|
+
invariant5(space, "Space not found.", {
|
|
2367
|
+
F: __dxlog_file9,
|
|
2368
|
+
L: 399,
|
|
2369
|
+
S: this,
|
|
2370
|
+
A: [
|
|
2371
|
+
"space",
|
|
2372
|
+
"'Space not found.'"
|
|
2373
|
+
]
|
|
2374
|
+
});
|
|
2375
|
+
await this._metadataStore.setSpaceEdgeReplicationSetting(spaceKey, setting);
|
|
2376
|
+
if (space.isOpen) {
|
|
2377
|
+
switch (setting) {
|
|
2378
|
+
case EdgeReplicationSetting.DISABLED:
|
|
2379
|
+
await this._echoEdgeReplicator?.disconnectFromSpace(space.id);
|
|
2380
|
+
break;
|
|
2381
|
+
case EdgeReplicationSetting.ENABLED:
|
|
2382
|
+
await this._echoEdgeReplicator?.connectToSpace(space.id);
|
|
2383
|
+
break;
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
}
|
|
2164
2387
|
async _constructSpace(metadata) {
|
|
2165
2388
|
log7("construct space", {
|
|
2166
2389
|
metadata
|
|
2167
2390
|
}, {
|
|
2168
2391
|
F: __dxlog_file9,
|
|
2169
|
-
L:
|
|
2392
|
+
L: 416,
|
|
2170
2393
|
S: this,
|
|
2171
2394
|
C: (f, a) => f(...a)
|
|
2172
2395
|
});
|
|
@@ -2210,7 +2433,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
2210
2433
|
err
|
|
2211
2434
|
}, {
|
|
2212
2435
|
F: __dxlog_file9,
|
|
2213
|
-
L:
|
|
2436
|
+
L: 458,
|
|
2214
2437
|
S: this,
|
|
2215
2438
|
C: (f, a) => f(...a)
|
|
2216
2439
|
});
|
|
@@ -2220,7 +2443,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
2220
2443
|
onAuthFailure: () => {
|
|
2221
2444
|
log7.warn("auth failure", void 0, {
|
|
2222
2445
|
F: __dxlog_file9,
|
|
2223
|
-
L:
|
|
2446
|
+
L: 463,
|
|
2224
2447
|
S: this,
|
|
2225
2448
|
C: (f, a) => f(...a)
|
|
2226
2449
|
});
|
|
@@ -2253,7 +2476,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
2253
2476
|
space: space.key
|
|
2254
2477
|
}, {
|
|
2255
2478
|
F: __dxlog_file9,
|
|
2256
|
-
L:
|
|
2479
|
+
L: 490,
|
|
2257
2480
|
S: this,
|
|
2258
2481
|
C: (f, a) => f(...a)
|
|
2259
2482
|
});
|
|
@@ -2264,7 +2487,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
2264
2487
|
open: this._lifecycleState === LifecycleState.OPEN
|
|
2265
2488
|
}, {
|
|
2266
2489
|
F: __dxlog_file9,
|
|
2267
|
-
L:
|
|
2490
|
+
L: 493,
|
|
2268
2491
|
S: this,
|
|
2269
2492
|
C: (f, a) => f(...a)
|
|
2270
2493
|
});
|
|
@@ -2283,7 +2506,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
2283
2506
|
space: space.key
|
|
2284
2507
|
}, {
|
|
2285
2508
|
F: __dxlog_file9,
|
|
2286
|
-
L:
|
|
2509
|
+
L: 501,
|
|
2287
2510
|
S: this,
|
|
2288
2511
|
C: (f, a) => f(...a)
|
|
2289
2512
|
});
|
|
@@ -2291,13 +2514,20 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
2291
2514
|
},
|
|
2292
2515
|
cache: metadata.cache,
|
|
2293
2516
|
edgeConnection: this._edgeConnection,
|
|
2517
|
+
edgeHttpClient: this._edgeHttpClient,
|
|
2294
2518
|
edgeFeatures: this._edgeFeatures
|
|
2295
2519
|
});
|
|
2296
2520
|
dataSpace.postOpen.append(async () => {
|
|
2297
|
-
|
|
2521
|
+
const setting = dataSpace.getEdgeReplicationSetting();
|
|
2522
|
+
if (setting === EdgeReplicationSetting.ENABLED) {
|
|
2523
|
+
await this._echoEdgeReplicator?.connectToSpace(dataSpace.id);
|
|
2524
|
+
}
|
|
2298
2525
|
});
|
|
2299
2526
|
dataSpace.preClose.append(async () => {
|
|
2300
|
-
|
|
2527
|
+
const setting = dataSpace.getEdgeReplicationSetting();
|
|
2528
|
+
if (setting === EdgeReplicationSetting.ENABLED) {
|
|
2529
|
+
await this._echoEdgeReplicator?.disconnectFromSpace(dataSpace.id);
|
|
2530
|
+
}
|
|
2301
2531
|
});
|
|
2302
2532
|
presence.newPeer.on((peerState) => {
|
|
2303
2533
|
if (dataSpace.state === SpaceState.SPACE_READY) {
|
|
@@ -2317,7 +2547,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
2317
2547
|
space: space.key
|
|
2318
2548
|
}, {
|
|
2319
2549
|
F: __dxlog_file9,
|
|
2320
|
-
L:
|
|
2550
|
+
L: 539,
|
|
2321
2551
|
S: this,
|
|
2322
2552
|
C: (f, a) => f(...a)
|
|
2323
2553
|
});
|
|
@@ -2350,7 +2580,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
2350
2580
|
closedSessions
|
|
2351
2581
|
}, {
|
|
2352
2582
|
F: __dxlog_file9,
|
|
2353
|
-
L:
|
|
2583
|
+
L: 565,
|
|
2354
2584
|
S: this,
|
|
2355
2585
|
C: (f, a) => f(...a)
|
|
2356
2586
|
});
|
|
@@ -2365,7 +2595,7 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
2365
2595
|
peerId: peerState.peerId
|
|
2366
2596
|
}, {
|
|
2367
2597
|
F: __dxlog_file9,
|
|
2368
|
-
L:
|
|
2598
|
+
L: 579,
|
|
2369
2599
|
S: this,
|
|
2370
2600
|
C: (f, a) => f(...a)
|
|
2371
2601
|
});
|
|
@@ -2409,19 +2639,19 @@ var DataSpaceManager = class extends Resource3 {
|
|
|
2409
2639
|
await Promise.all(tasks);
|
|
2410
2640
|
}
|
|
2411
2641
|
};
|
|
2412
|
-
|
|
2642
|
+
_ts_decorate3([
|
|
2413
2643
|
synchronized
|
|
2414
2644
|
], DataSpaceManager.prototype, "_open", null);
|
|
2415
|
-
|
|
2645
|
+
_ts_decorate3([
|
|
2416
2646
|
synchronized
|
|
2417
2647
|
], DataSpaceManager.prototype, "_close", null);
|
|
2418
|
-
|
|
2648
|
+
_ts_decorate3([
|
|
2419
2649
|
synchronized
|
|
2420
2650
|
], DataSpaceManager.prototype, "createSpace", null);
|
|
2421
|
-
|
|
2651
|
+
_ts_decorate3([
|
|
2422
2652
|
synchronized
|
|
2423
2653
|
], DataSpaceManager.prototype, "acceptSpace", null);
|
|
2424
|
-
DataSpaceManager =
|
|
2654
|
+
DataSpaceManager = _ts_decorate3([
|
|
2425
2655
|
trackLeaks("open", "close")
|
|
2426
2656
|
], DataSpaceManager);
|
|
2427
2657
|
|
|
@@ -2450,7 +2680,7 @@ var SpacesServiceImpl = class {
|
|
|
2450
2680
|
await this._updateMetrics();
|
|
2451
2681
|
return this._serializeSpace(space);
|
|
2452
2682
|
}
|
|
2453
|
-
async updateSpace({ spaceKey, state }) {
|
|
2683
|
+
async updateSpace({ spaceKey, state, edgeReplication }) {
|
|
2454
2684
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
2455
2685
|
const space = dataSpaceManager.spaces.get(spaceKey) ?? raise(new SpaceNotFoundError(spaceKey));
|
|
2456
2686
|
if (state) {
|
|
@@ -2465,6 +2695,9 @@ var SpacesServiceImpl = class {
|
|
|
2465
2695
|
throw new ApiError("Invalid space state");
|
|
2466
2696
|
}
|
|
2467
2697
|
}
|
|
2698
|
+
if (edgeReplication !== void 0) {
|
|
2699
|
+
await dataSpaceManager.setSpaceEdgeReplicationSetting(spaceKey, edgeReplication);
|
|
2700
|
+
}
|
|
2468
2701
|
}
|
|
2469
2702
|
async updateMemberRole(request) {
|
|
2470
2703
|
const identity = this._requireIdentity();
|
|
@@ -2481,7 +2714,7 @@ var SpacesServiceImpl = class {
|
|
|
2481
2714
|
const credentials = await createAdmissionCredentials2(identity.getIdentityCredentialSigner(), request.memberKey, space.key, space.genesisFeedKey, request.newRole, space.spaceState.membershipChainHeads);
|
|
2482
2715
|
invariant6(credentials[0].credential, void 0, {
|
|
2483
2716
|
F: __dxlog_file10,
|
|
2484
|
-
L:
|
|
2717
|
+
L: 106,
|
|
2485
2718
|
S: this,
|
|
2486
2719
|
A: [
|
|
2487
2720
|
"credentials[0].credential",
|
|
@@ -2491,7 +2724,7 @@ var SpacesServiceImpl = class {
|
|
|
2491
2724
|
const spaceMemberCredential = credentials[0].credential.credential;
|
|
2492
2725
|
invariant6(getCredentialAssertion3(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
2493
2726
|
F: __dxlog_file10,
|
|
2494
|
-
L:
|
|
2727
|
+
L: 108,
|
|
2495
2728
|
S: this,
|
|
2496
2729
|
A: [
|
|
2497
2730
|
"getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2509,7 +2742,7 @@ var SpacesServiceImpl = class {
|
|
|
2509
2742
|
ids: spaces.map((space) => space.id)
|
|
2510
2743
|
}), {
|
|
2511
2744
|
F: __dxlog_file10,
|
|
2512
|
-
L:
|
|
2745
|
+
L: 119,
|
|
2513
2746
|
S: this,
|
|
2514
2747
|
C: (f, a) => f(...a)
|
|
2515
2748
|
});
|
|
@@ -2601,7 +2834,7 @@ var SpacesServiceImpl = class {
|
|
|
2601
2834
|
} else {
|
|
2602
2835
|
invariant6(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
2603
2836
|
F: __dxlog_file10,
|
|
2604
|
-
L:
|
|
2837
|
+
L: 217,
|
|
2605
2838
|
S: this,
|
|
2606
2839
|
A: [
|
|
2607
2840
|
"!credential.id",
|
|
@@ -2610,7 +2843,7 @@ var SpacesServiceImpl = class {
|
|
|
2610
2843
|
});
|
|
2611
2844
|
invariant6(this._identityManager.identity, "Identity is not available", {
|
|
2612
2845
|
F: __dxlog_file10,
|
|
2613
|
-
L:
|
|
2846
|
+
L: 218,
|
|
2614
2847
|
S: this,
|
|
2615
2848
|
A: [
|
|
2616
2849
|
"this._identityManager.identity",
|
|
@@ -2620,7 +2853,7 @@ var SpacesServiceImpl = class {
|
|
|
2620
2853
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
2621
2854
|
invariant6(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
2622
2855
|
F: __dxlog_file10,
|
|
2623
|
-
L:
|
|
2856
|
+
L: 220,
|
|
2624
2857
|
S: this,
|
|
2625
2858
|
A: [
|
|
2626
2859
|
"credential.issuer.equals(signer.getIssuer())",
|
|
@@ -2670,7 +2903,7 @@ var SpacesServiceImpl = class {
|
|
|
2670
2903
|
const assertion = getCredentialAssertion3(credential);
|
|
2671
2904
|
invariant6(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
|
|
2672
2905
|
F: __dxlog_file10,
|
|
2673
|
-
L:
|
|
2906
|
+
L: 254,
|
|
2674
2907
|
S: this,
|
|
2675
2908
|
A: [
|
|
2676
2909
|
"assertion['@type'] === 'dxos.halo.credentials.SpaceMember'",
|
|
@@ -2680,7 +2913,7 @@ var SpacesServiceImpl = class {
|
|
|
2680
2913
|
const myIdentity = this._identityManager.identity;
|
|
2681
2914
|
invariant6(myIdentity && credential.subject.id.equals(myIdentity.identityKey), void 0, {
|
|
2682
2915
|
F: __dxlog_file10,
|
|
2683
|
-
L:
|
|
2916
|
+
L: 256,
|
|
2684
2917
|
S: this,
|
|
2685
2918
|
A: [
|
|
2686
2919
|
"myIdentity && credential.subject.id.equals(myIdentity.identityKey)",
|
|
@@ -2742,7 +2975,8 @@ var SpacesServiceImpl = class {
|
|
|
2742
2975
|
}),
|
|
2743
2976
|
creator: space.inner.spaceState.creator?.key,
|
|
2744
2977
|
cache: space.cache,
|
|
2745
|
-
metrics: space.metrics
|
|
2978
|
+
metrics: space.metrics,
|
|
2979
|
+
edgeReplication: space.getEdgeReplicationSetting()
|
|
2746
2980
|
};
|
|
2747
2981
|
}
|
|
2748
2982
|
_requireIdentity() {
|
|
@@ -2766,7 +3000,7 @@ var SpacesServiceImpl = class {
|
|
|
2766
3000
|
var getChannelId = (channel) => `user-channel/${channel}`;
|
|
2767
3001
|
|
|
2768
3002
|
// packages/sdk/client-services/src/packlets/identity/identity.ts
|
|
2769
|
-
function
|
|
3003
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
2770
3004
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2771
3005
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2772
3006
|
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;
|
|
@@ -2875,6 +3109,9 @@ var Identity = class {
|
|
|
2875
3109
|
get presence() {
|
|
2876
3110
|
return this._presence;
|
|
2877
3111
|
}
|
|
3112
|
+
get signer() {
|
|
3113
|
+
return this._signer;
|
|
3114
|
+
}
|
|
2878
3115
|
/**
|
|
2879
3116
|
* Issues credentials as identity.
|
|
2880
3117
|
* Requires identity to be ready.
|
|
@@ -2882,7 +3119,7 @@ var Identity = class {
|
|
|
2882
3119
|
getIdentityCredentialSigner() {
|
|
2883
3120
|
invariant7(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
|
|
2884
3121
|
F: __dxlog_file11,
|
|
2885
|
-
L:
|
|
3122
|
+
L: 189,
|
|
2886
3123
|
S: this,
|
|
2887
3124
|
A: [
|
|
2888
3125
|
"this._deviceStateMachine.deviceCredentialChain",
|
|
@@ -2926,7 +3163,7 @@ var Identity = class {
|
|
|
2926
3163
|
dataFeedKey
|
|
2927
3164
|
}, {
|
|
2928
3165
|
F: __dxlog_file11,
|
|
2929
|
-
L:
|
|
3166
|
+
L: 214,
|
|
2930
3167
|
S: this,
|
|
2931
3168
|
C: (f, a) => f(...a)
|
|
2932
3169
|
});
|
|
@@ -2967,20 +3204,20 @@ var Identity = class {
|
|
|
2967
3204
|
})));
|
|
2968
3205
|
}
|
|
2969
3206
|
};
|
|
2970
|
-
|
|
3207
|
+
_ts_decorate4([
|
|
2971
3208
|
trace3.span()
|
|
2972
3209
|
], Identity.prototype, "open", null);
|
|
2973
|
-
|
|
3210
|
+
_ts_decorate4([
|
|
2974
3211
|
trace3.span()
|
|
2975
3212
|
], Identity.prototype, "close", null);
|
|
2976
|
-
Identity =
|
|
3213
|
+
Identity = _ts_decorate4([
|
|
2977
3214
|
trace3.resource()
|
|
2978
3215
|
], Identity);
|
|
2979
3216
|
|
|
2980
3217
|
// packages/sdk/client-services/src/packlets/identity/identity-manager.ts
|
|
2981
3218
|
import platform from "platform";
|
|
2982
3219
|
import { Event as Event6 } from "@dxos/async";
|
|
2983
|
-
import { Context as
|
|
3220
|
+
import { Context as Context4 } from "@dxos/context";
|
|
2984
3221
|
import { createCredentialSignerWithKey as createCredentialSignerWithKey2, CredentialGenerator } from "@dxos/credentials";
|
|
2985
3222
|
import { invariant as invariant8 } from "@dxos/invariant";
|
|
2986
3223
|
import { PublicKey as PublicKey7 } from "@dxos/keys";
|
|
@@ -2992,7 +3229,7 @@ import { Gossip as Gossip2, Presence as Presence2 } from "@dxos/teleport-extensi
|
|
|
2992
3229
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
2993
3230
|
import { trace as Trace2 } from "@dxos/tracing";
|
|
2994
3231
|
import { isNode, deferFunction as deferFunction2 } from "@dxos/util";
|
|
2995
|
-
function
|
|
3232
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
2996
3233
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2997
3234
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2998
3235
|
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;
|
|
@@ -3062,7 +3299,7 @@ var IdentityManager = class {
|
|
|
3062
3299
|
});
|
|
3063
3300
|
}
|
|
3064
3301
|
async close() {
|
|
3065
|
-
await this._identity?.close(new
|
|
3302
|
+
await this._identity?.close(new Context4(void 0, {
|
|
3066
3303
|
F: __dxlog_file12,
|
|
3067
3304
|
L: 140
|
|
3068
3305
|
}));
|
|
@@ -3095,7 +3332,7 @@ var IdentityManager = class {
|
|
|
3095
3332
|
}
|
|
3096
3333
|
};
|
|
3097
3334
|
const identity = await this._constructIdentity(identityRecord);
|
|
3098
|
-
await identity.open(new
|
|
3335
|
+
await identity.open(new Context4(void 0, {
|
|
3099
3336
|
F: __dxlog_file12,
|
|
3100
3337
|
L: 161
|
|
3101
3338
|
}));
|
|
@@ -3224,7 +3461,7 @@ var IdentityManager = class {
|
|
|
3224
3461
|
}
|
|
3225
3462
|
};
|
|
3226
3463
|
const identity = await this._constructIdentity(identityRecord);
|
|
3227
|
-
await identity.open(new
|
|
3464
|
+
await identity.open(new Context4(void 0, {
|
|
3228
3465
|
F: __dxlog_file12,
|
|
3229
3466
|
L: 268
|
|
3230
3467
|
}));
|
|
@@ -3443,19 +3680,19 @@ var IdentityManager = class {
|
|
|
3443
3680
|
});
|
|
3444
3681
|
}
|
|
3445
3682
|
};
|
|
3446
|
-
|
|
3683
|
+
_ts_decorate5([
|
|
3447
3684
|
Trace2.span({
|
|
3448
3685
|
showInBrowserTimeline: true
|
|
3449
3686
|
})
|
|
3450
3687
|
], IdentityManager.prototype, "open", null);
|
|
3451
|
-
IdentityManager =
|
|
3688
|
+
IdentityManager = _ts_decorate5([
|
|
3452
3689
|
Trace2.resource()
|
|
3453
3690
|
], IdentityManager);
|
|
3454
3691
|
|
|
3455
3692
|
// packages/sdk/client-services/src/packlets/identity/identity-service.ts
|
|
3456
3693
|
import { Trigger as Trigger3, sleep as sleep2 } from "@dxos/async";
|
|
3457
3694
|
import { Stream as Stream8 } from "@dxos/codec-protobuf";
|
|
3458
|
-
import { Resource as
|
|
3695
|
+
import { Resource as Resource5 } from "@dxos/context";
|
|
3459
3696
|
import { signPresentation } from "@dxos/credentials";
|
|
3460
3697
|
import { todo } from "@dxos/debug";
|
|
3461
3698
|
import { invariant as invariant9 } from "@dxos/invariant";
|
|
@@ -3464,7 +3701,7 @@ import { SpaceState as SpaceState3 } from "@dxos/protocols/proto/dxos/client/ser
|
|
|
3464
3701
|
import { safeAwaitAll } from "@dxos/util";
|
|
3465
3702
|
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
|
|
3466
3703
|
var DEFAULT_SPACE_SEARCH_TIMEOUT = 1e4;
|
|
3467
|
-
var IdentityServiceImpl = class extends
|
|
3704
|
+
var IdentityServiceImpl = class extends Resource5 {
|
|
3468
3705
|
constructor(_identityManager, _keyring, _dataSpaceManagerProvider, _createIdentity, _onProfileUpdate) {
|
|
3469
3706
|
super();
|
|
3470
3707
|
this._identityManager = _identityManager;
|
|
@@ -3608,7 +3845,7 @@ var IdentityServiceImpl = class extends Resource4 {
|
|
|
3608
3845
|
};
|
|
3609
3846
|
|
|
3610
3847
|
// packages/sdk/client-services/src/packlets/spaces/data-space.ts
|
|
3611
|
-
function
|
|
3848
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
3612
3849
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3613
3850
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
3614
3851
|
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;
|
|
@@ -3679,11 +3916,10 @@ function _using_ctx2() {
|
|
|
3679
3916
|
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3680
3917
|
var DataSpace = class {
|
|
3681
3918
|
constructor(params) {
|
|
3682
|
-
this._ctx = new
|
|
3919
|
+
this._ctx = new Context5(void 0, {
|
|
3683
3920
|
F: __dxlog_file14,
|
|
3684
|
-
L:
|
|
3921
|
+
L: 95
|
|
3685
3922
|
});
|
|
3686
|
-
this._notarizationPlugin = new NotarizationPlugin();
|
|
3687
3923
|
this._cache = void 0;
|
|
3688
3924
|
this._edgeFeedReplicator = void 0;
|
|
3689
3925
|
// TODO(dmaretskyi): Move into Space?
|
|
@@ -3712,6 +3948,11 @@ var DataSpace = class {
|
|
|
3712
3948
|
this._signingContext = params.signingContext;
|
|
3713
3949
|
this._callbacks = params.callbacks ?? {};
|
|
3714
3950
|
this._echoHost = params.echoHost;
|
|
3951
|
+
this._notarizationPlugin = new NotarizationPlugin({
|
|
3952
|
+
spaceId: this._inner.id,
|
|
3953
|
+
edgeClient: params.edgeHttpClient,
|
|
3954
|
+
edgeFeatures: params.edgeFeatures
|
|
3955
|
+
});
|
|
3715
3956
|
this.authVerifier = new TrustedKeySetAuthVerifier({
|
|
3716
3957
|
trustedKeysProvider: () => new ComplexSet3(PublicKey8.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== SpaceMember5.Role.REMOVED).map((member) => member.key)),
|
|
3717
3958
|
update: this._inner.stateUpdate,
|
|
@@ -3729,7 +3970,7 @@ var DataSpace = class {
|
|
|
3729
3970
|
state: SpaceState4[this._state]
|
|
3730
3971
|
}, {
|
|
3731
3972
|
F: __dxlog_file14,
|
|
3732
|
-
L:
|
|
3973
|
+
L: 170,
|
|
3733
3974
|
S: this,
|
|
3734
3975
|
C: (f, a) => f(...a)
|
|
3735
3976
|
});
|
|
@@ -3786,9 +4027,9 @@ var DataSpace = class {
|
|
|
3786
4027
|
if (this._edgeFeedReplicator) {
|
|
3787
4028
|
this.inner.protocol.feedAdded.append(this._onFeedAdded);
|
|
3788
4029
|
}
|
|
3789
|
-
await this._inner.open(new
|
|
4030
|
+
await this._inner.open(new Context5(void 0, {
|
|
3790
4031
|
F: __dxlog_file14,
|
|
3791
|
-
L:
|
|
4032
|
+
L: 244
|
|
3792
4033
|
}));
|
|
3793
4034
|
await this._edgeFeedReplicator?.open();
|
|
3794
4035
|
this._state = SpaceState4.SPACE_CONTROL_ONLY;
|
|
@@ -3796,7 +4037,7 @@ var DataSpace = class {
|
|
|
3796
4037
|
state: SpaceState4[this._state]
|
|
3797
4038
|
}, {
|
|
3798
4039
|
F: __dxlog_file14,
|
|
3799
|
-
L:
|
|
4040
|
+
L: 249,
|
|
3800
4041
|
S: this,
|
|
3801
4042
|
C: (f, a) => f(...a)
|
|
3802
4043
|
});
|
|
@@ -3816,14 +4057,14 @@ var DataSpace = class {
|
|
|
3816
4057
|
state: SpaceState4[this._state]
|
|
3817
4058
|
}, {
|
|
3818
4059
|
F: __dxlog_file14,
|
|
3819
|
-
L:
|
|
4060
|
+
L: 268,
|
|
3820
4061
|
S: this,
|
|
3821
4062
|
C: (f, a) => f(...a)
|
|
3822
4063
|
});
|
|
3823
4064
|
await this._ctx.dispose();
|
|
3824
|
-
this._ctx = new
|
|
4065
|
+
this._ctx = new Context5(void 0, {
|
|
3825
4066
|
F: __dxlog_file14,
|
|
3826
|
-
L:
|
|
4067
|
+
L: 270
|
|
3827
4068
|
});
|
|
3828
4069
|
if (this._edgeFeedReplicator) {
|
|
3829
4070
|
this.inner.protocol.feedAdded.remove(this._onFeedAdded);
|
|
@@ -3856,7 +4097,7 @@ var DataSpace = class {
|
|
|
3856
4097
|
if (err instanceof CancelledError || err instanceof ContextDisposedError) {
|
|
3857
4098
|
log12("data pipeline initialization cancelled", err, {
|
|
3858
4099
|
F: __dxlog_file14,
|
|
3859
|
-
L:
|
|
4100
|
+
L: 308,
|
|
3860
4101
|
S: this,
|
|
3861
4102
|
C: (f, a) => f(...a)
|
|
3862
4103
|
});
|
|
@@ -3864,7 +4105,7 @@ var DataSpace = class {
|
|
|
3864
4105
|
}
|
|
3865
4106
|
log12.error("Error initializing data pipeline", err, {
|
|
3866
4107
|
F: __dxlog_file14,
|
|
3867
|
-
L:
|
|
4108
|
+
L: 312,
|
|
3868
4109
|
S: this,
|
|
3869
4110
|
C: (f, a) => f(...a)
|
|
3870
4111
|
});
|
|
@@ -3873,7 +4114,7 @@ var DataSpace = class {
|
|
|
3873
4114
|
state: SpaceState4[this._state]
|
|
3874
4115
|
}, {
|
|
3875
4116
|
F: __dxlog_file14,
|
|
3876
|
-
L:
|
|
4117
|
+
L: 314,
|
|
3877
4118
|
S: this,
|
|
3878
4119
|
C: (f, a) => f(...a)
|
|
3879
4120
|
});
|
|
@@ -3893,15 +4134,39 @@ var DataSpace = class {
|
|
|
3893
4134
|
state: SpaceState4[this._state]
|
|
3894
4135
|
}, {
|
|
3895
4136
|
F: __dxlog_file14,
|
|
3896
|
-
L:
|
|
4137
|
+
L: 330,
|
|
4138
|
+
S: this,
|
|
4139
|
+
C: (f, a) => f(...a)
|
|
4140
|
+
});
|
|
4141
|
+
log12("initializing control pipeline", void 0, {
|
|
4142
|
+
F: __dxlog_file14,
|
|
4143
|
+
L: 332,
|
|
3897
4144
|
S: this,
|
|
3898
4145
|
C: (f, a) => f(...a)
|
|
3899
4146
|
});
|
|
3900
4147
|
await this._initializeAndReadControlPipeline();
|
|
3901
4148
|
await sleep3(1);
|
|
3902
4149
|
const ready = this.stateUpdate.waitForCondition(() => this._state === SpaceState4.SPACE_READY);
|
|
4150
|
+
log12("initializing automerge root", void 0, {
|
|
4151
|
+
F: __dxlog_file14,
|
|
4152
|
+
L: 340,
|
|
4153
|
+
S: this,
|
|
4154
|
+
C: (f, a) => f(...a)
|
|
4155
|
+
});
|
|
3903
4156
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
4157
|
+
log12("waiting for space to be ready", void 0, {
|
|
4158
|
+
F: __dxlog_file14,
|
|
4159
|
+
L: 344,
|
|
4160
|
+
S: this,
|
|
4161
|
+
C: (f, a) => f(...a)
|
|
4162
|
+
});
|
|
3904
4163
|
await ready;
|
|
4164
|
+
log12("space is ready", void 0, {
|
|
4165
|
+
F: __dxlog_file14,
|
|
4166
|
+
L: 346,
|
|
4167
|
+
S: this,
|
|
4168
|
+
C: (f, a) => f(...a)
|
|
4169
|
+
});
|
|
3905
4170
|
}
|
|
3906
4171
|
async _enterReadyState() {
|
|
3907
4172
|
await this._callbacks.beforeReady?.();
|
|
@@ -3910,7 +4175,7 @@ var DataSpace = class {
|
|
|
3910
4175
|
state: SpaceState4[this._state]
|
|
3911
4176
|
}, {
|
|
3912
4177
|
F: __dxlog_file14,
|
|
3913
|
-
L:
|
|
4178
|
+
L: 353,
|
|
3914
4179
|
S: this,
|
|
3915
4180
|
C: (f, a) => f(...a)
|
|
3916
4181
|
});
|
|
@@ -3920,13 +4185,14 @@ var DataSpace = class {
|
|
|
3920
4185
|
async _initializeAndReadControlPipeline() {
|
|
3921
4186
|
await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
|
|
3922
4187
|
ctx: this._ctx,
|
|
4188
|
+
timeout: 1e4,
|
|
3923
4189
|
breakOnStall: false
|
|
3924
4190
|
});
|
|
3925
4191
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
3926
4192
|
await this._createWritableFeeds();
|
|
3927
4193
|
log12("writable feeds created", void 0, {
|
|
3928
4194
|
F: __dxlog_file14,
|
|
3929
|
-
L:
|
|
4195
|
+
L: 370,
|
|
3930
4196
|
S: this,
|
|
3931
4197
|
C: (f, a) => f(...a)
|
|
3932
4198
|
});
|
|
@@ -3975,11 +4241,35 @@ var DataSpace = class {
|
|
|
3975
4241
|
}));
|
|
3976
4242
|
}
|
|
3977
4243
|
if (credentials.length > 0) {
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
4244
|
+
try {
|
|
4245
|
+
log12("will notarize credentials for feed admission", {
|
|
4246
|
+
count: credentials.length
|
|
4247
|
+
}, {
|
|
4248
|
+
F: __dxlog_file14,
|
|
4249
|
+
L: 428,
|
|
4250
|
+
S: this,
|
|
4251
|
+
C: (f, a) => f(...a)
|
|
4252
|
+
});
|
|
4253
|
+
await this.notarizationPlugin.notarize({
|
|
4254
|
+
ctx: this._ctx,
|
|
4255
|
+
credentials,
|
|
4256
|
+
timeout: 0
|
|
4257
|
+
});
|
|
4258
|
+
log12("credentials notarized", void 0, {
|
|
4259
|
+
F: __dxlog_file14,
|
|
4260
|
+
L: 432,
|
|
4261
|
+
S: this,
|
|
4262
|
+
C: (f, a) => f(...a)
|
|
4263
|
+
});
|
|
4264
|
+
} catch (err) {
|
|
4265
|
+
log12.error("error notarizing credentials for feed admission", err, {
|
|
4266
|
+
F: __dxlog_file14,
|
|
4267
|
+
L: 434,
|
|
4268
|
+
S: this,
|
|
4269
|
+
C: (f, a) => f(...a)
|
|
4270
|
+
});
|
|
4271
|
+
throw err;
|
|
4272
|
+
}
|
|
3983
4273
|
await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
|
|
3984
4274
|
}
|
|
3985
4275
|
}
|
|
@@ -3989,7 +4279,7 @@ var DataSpace = class {
|
|
|
3989
4279
|
rootUrl
|
|
3990
4280
|
}, {
|
|
3991
4281
|
F: __dxlog_file14,
|
|
3992
|
-
L:
|
|
4282
|
+
L: 444,
|
|
3993
4283
|
S: this,
|
|
3994
4284
|
C: (f, a) => f(...a)
|
|
3995
4285
|
});
|
|
@@ -4041,7 +4331,7 @@ var DataSpace = class {
|
|
|
4041
4331
|
err
|
|
4042
4332
|
}, {
|
|
4043
4333
|
F: __dxlog_file14,
|
|
4044
|
-
L:
|
|
4334
|
+
L: 487,
|
|
4045
4335
|
S: this,
|
|
4046
4336
|
C: (f, a) => f(...a)
|
|
4047
4337
|
});
|
|
@@ -4131,58 +4421,61 @@ var DataSpace = class {
|
|
|
4131
4421
|
state: SpaceState4[this._state]
|
|
4132
4422
|
}, {
|
|
4133
4423
|
F: __dxlog_file14,
|
|
4134
|
-
L:
|
|
4424
|
+
L: 569,
|
|
4135
4425
|
S: this,
|
|
4136
4426
|
C: (f, a) => f(...a)
|
|
4137
4427
|
});
|
|
4138
4428
|
this.stateUpdate.emit();
|
|
4139
4429
|
}
|
|
4430
|
+
getEdgeReplicationSetting() {
|
|
4431
|
+
return this._metadataStore.getSpaceEdgeReplicationSetting(this.key);
|
|
4432
|
+
}
|
|
4140
4433
|
};
|
|
4141
|
-
|
|
4434
|
+
_ts_decorate6([
|
|
4142
4435
|
trace5.info()
|
|
4143
4436
|
], DataSpace.prototype, "_inner", void 0);
|
|
4144
|
-
|
|
4437
|
+
_ts_decorate6([
|
|
4145
4438
|
trace5.info()
|
|
4146
4439
|
], DataSpace.prototype, "id", null);
|
|
4147
|
-
|
|
4440
|
+
_ts_decorate6([
|
|
4148
4441
|
trace5.info()
|
|
4149
4442
|
], DataSpace.prototype, "key", null);
|
|
4150
|
-
|
|
4443
|
+
_ts_decorate6([
|
|
4151
4444
|
trace5.info({
|
|
4152
4445
|
enum: SpaceState4
|
|
4153
4446
|
})
|
|
4154
4447
|
], DataSpace.prototype, "state", null);
|
|
4155
|
-
|
|
4448
|
+
_ts_decorate6([
|
|
4156
4449
|
trace5.info({
|
|
4157
4450
|
depth: null
|
|
4158
4451
|
})
|
|
4159
4452
|
], DataSpace.prototype, "_automergeInfo", null);
|
|
4160
|
-
|
|
4453
|
+
_ts_decorate6([
|
|
4161
4454
|
synchronized2
|
|
4162
4455
|
], DataSpace.prototype, "open", null);
|
|
4163
|
-
|
|
4456
|
+
_ts_decorate6([
|
|
4164
4457
|
synchronized2
|
|
4165
4458
|
], DataSpace.prototype, "close", null);
|
|
4166
|
-
|
|
4459
|
+
_ts_decorate6([
|
|
4167
4460
|
trace5.span({
|
|
4168
4461
|
showInBrowserTimeline: true
|
|
4169
4462
|
})
|
|
4170
4463
|
], DataSpace.prototype, "initializeDataPipeline", null);
|
|
4171
|
-
|
|
4464
|
+
_ts_decorate6([
|
|
4172
4465
|
trace5.span({
|
|
4173
4466
|
showInBrowserTimeline: true
|
|
4174
4467
|
})
|
|
4175
4468
|
], DataSpace.prototype, "_initializeAndReadControlPipeline", null);
|
|
4176
|
-
|
|
4469
|
+
_ts_decorate6([
|
|
4177
4470
|
timed(1e4)
|
|
4178
4471
|
], DataSpace.prototype, "_createWritableFeeds", null);
|
|
4179
|
-
|
|
4472
|
+
_ts_decorate6([
|
|
4180
4473
|
synchronized2
|
|
4181
4474
|
], DataSpace.prototype, "activate", null);
|
|
4182
|
-
|
|
4475
|
+
_ts_decorate6([
|
|
4183
4476
|
synchronized2
|
|
4184
4477
|
], DataSpace.prototype, "deactivate", null);
|
|
4185
|
-
DataSpace =
|
|
4478
|
+
DataSpace = _ts_decorate6([
|
|
4186
4479
|
trackLeaks2("open", "close"),
|
|
4187
4480
|
trace5.resource()
|
|
4188
4481
|
], DataSpace);
|
|
@@ -4316,7 +4609,7 @@ import { ComplexSet as ComplexSet5 } from "@dxos/util";
|
|
|
4316
4609
|
|
|
4317
4610
|
// packages/sdk/client-services/src/packlets/invitations/invitation-guest-extenstion.ts
|
|
4318
4611
|
import { Trigger as Trigger4 } from "@dxos/async";
|
|
4319
|
-
import { cancelWithContext as cancelWithContext4, Context as
|
|
4612
|
+
import { cancelWithContext as cancelWithContext4, Context as Context6 } from "@dxos/context";
|
|
4320
4613
|
import { invariant as invariant11 } from "@dxos/invariant";
|
|
4321
4614
|
import { log as log13 } from "@dxos/log";
|
|
4322
4615
|
import { InvalidInvitationExtensionRoleError } from "@dxos/protocols";
|
|
@@ -4358,7 +4651,7 @@ var InvitationGuestExtension = class extends RpcExtension2 {
|
|
|
4358
4651
|
});
|
|
4359
4652
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
4360
4653
|
this._callbacks = _callbacks;
|
|
4361
|
-
this._ctx = new
|
|
4654
|
+
this._ctx = new Context6(void 0, {
|
|
4362
4655
|
F: __dxlog_file16,
|
|
4363
4656
|
L: 34
|
|
4364
4657
|
});
|
|
@@ -4470,7 +4763,7 @@ var InvitationGuestExtension = class extends RpcExtension2 {
|
|
|
4470
4763
|
|
|
4471
4764
|
// packages/sdk/client-services/src/packlets/invitations/invitation-host-extension.ts
|
|
4472
4765
|
import { Trigger as Trigger5, scheduleTask as scheduleTask5 } from "@dxos/async";
|
|
4473
|
-
import { cancelWithContext as cancelWithContext5, Context as
|
|
4766
|
+
import { cancelWithContext as cancelWithContext5, Context as Context7 } from "@dxos/context";
|
|
4474
4767
|
import { randomBytes, verify } from "@dxos/crypto";
|
|
4475
4768
|
import { invariant as invariant12, InvariantViolation } from "@dxos/invariant";
|
|
4476
4769
|
import { PublicKey as PublicKey9 } from "@dxos/keys";
|
|
@@ -4495,7 +4788,7 @@ var InvitationHostExtension = class extends RpcExtension3 {
|
|
|
4495
4788
|
});
|
|
4496
4789
|
this._invitationFlowMutex = _invitationFlowMutex;
|
|
4497
4790
|
this._callbacks = _callbacks;
|
|
4498
|
-
this._ctx = new
|
|
4791
|
+
this._ctx = new Context7(void 0, {
|
|
4499
4792
|
F: __dxlog_file17,
|
|
4500
4793
|
L: 53
|
|
4501
4794
|
});
|
|
@@ -5870,7 +6163,7 @@ var SpaceInvitationProtocol = class {
|
|
|
5870
6163
|
// packages/sdk/client-services/src/packlets/invitations/invitations-manager.ts
|
|
5871
6164
|
import { Event as Event8, PushStream, TimeoutError as TimeoutError3, Trigger as Trigger6 } from "@dxos/async";
|
|
5872
6165
|
import { AuthenticatingInvitation, AUTHENTICATION_CODE_LENGTH, CancellableInvitation, INVITATION_TIMEOUT as INVITATION_TIMEOUT2 } from "@dxos/client-protocol";
|
|
5873
|
-
import { Context as
|
|
6166
|
+
import { Context as Context8 } from "@dxos/context";
|
|
5874
6167
|
import { generatePasscode } from "@dxos/credentials";
|
|
5875
6168
|
import { hasInvitationExpired } from "@dxos/echo-pipeline";
|
|
5876
6169
|
import { invariant as invariant16 } from "@dxos/invariant";
|
|
@@ -6102,7 +6395,7 @@ var InvitationsManager = class {
|
|
|
6102
6395
|
}
|
|
6103
6396
|
_createObservableInvitation(handler, invitation) {
|
|
6104
6397
|
const stream = new PushStream();
|
|
6105
|
-
const ctx = new
|
|
6398
|
+
const ctx = new Context8({
|
|
6106
6399
|
onError: (err) => {
|
|
6107
6400
|
stream.error(err);
|
|
6108
6401
|
void ctx.dispose();
|
|
@@ -6142,7 +6435,7 @@ var InvitationsManager = class {
|
|
|
6142
6435
|
_createObservableAcceptingInvitation(handler, initialState) {
|
|
6143
6436
|
const otpEnteredTrigger = new Trigger6();
|
|
6144
6437
|
const stream = new PushStream();
|
|
6145
|
-
const ctx = new
|
|
6438
|
+
const ctx = new Context8({
|
|
6146
6439
|
onError: (err) => {
|
|
6147
6440
|
if (err instanceof TimeoutError3) {
|
|
6148
6441
|
log18("timeout", {
|
|
@@ -6241,8 +6534,8 @@ var InvitationsManager = class {
|
|
|
6241
6534
|
// packages/sdk/client-services/src/packlets/locks/node.ts
|
|
6242
6535
|
import { invariant as invariant17 } from "@dxos/invariant";
|
|
6243
6536
|
import { LockFile } from "@dxos/lock-file";
|
|
6244
|
-
import { log as log19, logInfo } from "@dxos/log";
|
|
6245
|
-
function
|
|
6537
|
+
import { log as log19, logInfo as logInfo3 } from "@dxos/log";
|
|
6538
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
6246
6539
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6247
6540
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6248
6541
|
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;
|
|
@@ -6288,8 +6581,8 @@ var Lock = class {
|
|
|
6288
6581
|
await LockFile.release(this._fileHandle);
|
|
6289
6582
|
}
|
|
6290
6583
|
};
|
|
6291
|
-
|
|
6292
|
-
|
|
6584
|
+
_ts_decorate7([
|
|
6585
|
+
logInfo3
|
|
6293
6586
|
], Lock.prototype, "lockKey", null);
|
|
6294
6587
|
var isLocked = (lockPath) => LockFile.isLocked(lockPath);
|
|
6295
6588
|
|
|
@@ -6298,7 +6591,7 @@ import { Stream as Stream10 } from "@dxos/codec-protobuf";
|
|
|
6298
6591
|
import { raise as raise2 } from "@dxos/debug";
|
|
6299
6592
|
import { parseMethodName, RpcPeer } from "@dxos/rpc";
|
|
6300
6593
|
import { MapCounter, trace as trace8 } from "@dxos/tracing";
|
|
6301
|
-
function
|
|
6594
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
6302
6595
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6303
6596
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6304
6597
|
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;
|
|
@@ -6360,22 +6653,23 @@ var ClientRpcServer = class {
|
|
|
6360
6653
|
return this._handlerCache.get(serviceName);
|
|
6361
6654
|
}
|
|
6362
6655
|
};
|
|
6363
|
-
|
|
6656
|
+
_ts_decorate8([
|
|
6364
6657
|
trace8.metricsCounter()
|
|
6365
6658
|
], ClientRpcServer.prototype, "_callMetrics", void 0);
|
|
6366
|
-
|
|
6659
|
+
_ts_decorate8([
|
|
6367
6660
|
trace8.info()
|
|
6368
6661
|
], ClientRpcServer.prototype, "_services", null);
|
|
6369
|
-
ClientRpcServer =
|
|
6662
|
+
ClientRpcServer = _ts_decorate8([
|
|
6370
6663
|
trace8.resource()
|
|
6371
6664
|
], ClientRpcServer);
|
|
6372
6665
|
|
|
6373
6666
|
// packages/sdk/client-services/src/packlets/services/service-context.ts
|
|
6374
|
-
import { Trigger as Trigger7 } from "@dxos/async";
|
|
6375
|
-
import { Context as
|
|
6667
|
+
import { Mutex as Mutex4, scheduleMicroTask as scheduleMicroTask3, Trigger as Trigger7 } from "@dxos/async";
|
|
6668
|
+
import { Context as Context9, Resource as Resource6 } from "@dxos/context";
|
|
6376
6669
|
import { getCredentialAssertion as getCredentialAssertion5 } from "@dxos/credentials";
|
|
6377
|
-
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
6670
|
+
import { failUndefined as failUndefined2, warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
|
|
6378
6671
|
import { EchoEdgeReplicator, EchoHost, MeshEchoReplicator, MetadataStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
|
|
6672
|
+
import { createChainEdgeIdentity, createEphemeralEdgeIdentity } from "@dxos/edge-client";
|
|
6379
6673
|
import { FeedFactory, FeedStore } from "@dxos/feed-store";
|
|
6380
6674
|
import { invariant as invariant18 } from "@dxos/invariant";
|
|
6381
6675
|
import { Keyring } from "@dxos/keyring";
|
|
@@ -6386,23 +6680,87 @@ import { Invitation as Invitation8 } from "@dxos/protocols/proto/dxos/client/ser
|
|
|
6386
6680
|
import { BlobStore } from "@dxos/teleport-extension-object-sync";
|
|
6387
6681
|
import { trace as Trace3 } from "@dxos/tracing";
|
|
6388
6682
|
import { safeInstanceof } from "@dxos/util";
|
|
6389
|
-
function
|
|
6683
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
6390
6684
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6391
6685
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6392
6686
|
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;
|
|
6393
6687
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6394
6688
|
}
|
|
6689
|
+
function _using_ctx3() {
|
|
6690
|
+
var _disposeSuppressedError = typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed) {
|
|
6691
|
+
var err = new Error();
|
|
6692
|
+
err.name = "SuppressedError";
|
|
6693
|
+
err.suppressed = suppressed;
|
|
6694
|
+
err.error = error;
|
|
6695
|
+
return err;
|
|
6696
|
+
}, empty = {}, stack = [];
|
|
6697
|
+
function using(isAwait, value) {
|
|
6698
|
+
if (value != null) {
|
|
6699
|
+
if (Object(value) !== value) {
|
|
6700
|
+
throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");
|
|
6701
|
+
}
|
|
6702
|
+
if (isAwait) {
|
|
6703
|
+
var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
|
|
6704
|
+
}
|
|
6705
|
+
if (dispose == null) {
|
|
6706
|
+
dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
|
|
6707
|
+
}
|
|
6708
|
+
if (typeof dispose !== "function") {
|
|
6709
|
+
throw new TypeError(`Property [Symbol.dispose] is not a function.`);
|
|
6710
|
+
}
|
|
6711
|
+
stack.push({
|
|
6712
|
+
v: value,
|
|
6713
|
+
d: dispose,
|
|
6714
|
+
a: isAwait
|
|
6715
|
+
});
|
|
6716
|
+
} else if (isAwait) {
|
|
6717
|
+
stack.push({
|
|
6718
|
+
d: value,
|
|
6719
|
+
a: isAwait
|
|
6720
|
+
});
|
|
6721
|
+
}
|
|
6722
|
+
return value;
|
|
6723
|
+
}
|
|
6724
|
+
return {
|
|
6725
|
+
e: empty,
|
|
6726
|
+
u: using.bind(null, false),
|
|
6727
|
+
a: using.bind(null, true),
|
|
6728
|
+
d: function() {
|
|
6729
|
+
var error = this.e;
|
|
6730
|
+
function next() {
|
|
6731
|
+
while (resource = stack.pop()) {
|
|
6732
|
+
try {
|
|
6733
|
+
var resource, disposalResult = resource.d && resource.d.call(resource.v);
|
|
6734
|
+
if (resource.a) {
|
|
6735
|
+
return Promise.resolve(disposalResult).then(next, err);
|
|
6736
|
+
}
|
|
6737
|
+
} catch (e) {
|
|
6738
|
+
return err(e);
|
|
6739
|
+
}
|
|
6740
|
+
}
|
|
6741
|
+
if (error !== empty) throw error;
|
|
6742
|
+
}
|
|
6743
|
+
function err(e) {
|
|
6744
|
+
error = error !== empty ? new _disposeSuppressedError(error, e) : e;
|
|
6745
|
+
return next();
|
|
6746
|
+
}
|
|
6747
|
+
return next();
|
|
6748
|
+
}
|
|
6749
|
+
};
|
|
6750
|
+
}
|
|
6395
6751
|
var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
6396
|
-
var ServiceContext = class extends
|
|
6397
|
-
constructor(storage, level, networkManager, signalManager, _edgeConnection, _runtimeParams, _edgeFeatures) {
|
|
6752
|
+
var ServiceContext = class extends Resource6 {
|
|
6753
|
+
constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
|
|
6398
6754
|
super();
|
|
6399
6755
|
this.storage = storage;
|
|
6400
6756
|
this.level = level;
|
|
6401
6757
|
this.networkManager = networkManager;
|
|
6402
6758
|
this.signalManager = signalManager;
|
|
6403
6759
|
this._edgeConnection = _edgeConnection;
|
|
6760
|
+
this._edgeHttpClient = _edgeHttpClient;
|
|
6404
6761
|
this._runtimeParams = _runtimeParams;
|
|
6405
6762
|
this._edgeFeatures = _edgeFeatures;
|
|
6763
|
+
this._edgeIdentityUpdateMutex = new Mutex4();
|
|
6406
6764
|
this.initialized = new Trigger7();
|
|
6407
6765
|
this._meshReplicator = void 0;
|
|
6408
6766
|
this._echoEdgeReplicator = void 0;
|
|
@@ -6440,23 +6798,42 @@ var ServiceContext = class extends Resource5 {
|
|
|
6440
6798
|
callbacks: {
|
|
6441
6799
|
onIdentityConstruction: (identity) => {
|
|
6442
6800
|
if (this._edgeConnection) {
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6801
|
+
scheduleMicroTask3(this._ctx, async () => {
|
|
6802
|
+
try {
|
|
6803
|
+
var _usingCtx = _using_ctx3();
|
|
6804
|
+
const _ = _usingCtx.u(await this._edgeIdentityUpdateMutex.acquire());
|
|
6805
|
+
log20.info("Setting identity on edge connection", {
|
|
6806
|
+
identity: identity.identityKey.toHex(),
|
|
6807
|
+
oldIdentity: this._edgeConnection.identityKey,
|
|
6808
|
+
swarms: this.networkManager.topics
|
|
6809
|
+
}, {
|
|
6810
|
+
F: __dxlog_file23,
|
|
6811
|
+
L: 147,
|
|
6812
|
+
S: this,
|
|
6813
|
+
C: (f, a) => f(...a)
|
|
6814
|
+
});
|
|
6815
|
+
await warnAfterTimeout2(1e4, "Waiting for identity to be ready for edge connection", async () => {
|
|
6816
|
+
await identity.ready();
|
|
6817
|
+
});
|
|
6818
|
+
invariant18(identity.deviceCredentialChain, void 0, {
|
|
6819
|
+
F: __dxlog_file23,
|
|
6820
|
+
L: 157,
|
|
6821
|
+
S: this,
|
|
6822
|
+
A: [
|
|
6823
|
+
"identity.deviceCredentialChain",
|
|
6824
|
+
""
|
|
6825
|
+
]
|
|
6826
|
+
});
|
|
6827
|
+
this._edgeConnection.setIdentity(await createChainEdgeIdentity(identity.signer, identity.identityKey, identity.deviceKey, identity.deviceCredentialChain, []));
|
|
6828
|
+
this.networkManager.setPeerInfo({
|
|
6829
|
+
identityKey: identity.identityKey.toHex(),
|
|
6830
|
+
peerKey: identity.deviceKey.toHex()
|
|
6831
|
+
});
|
|
6832
|
+
} catch (_) {
|
|
6833
|
+
_usingCtx.e = _;
|
|
6834
|
+
} finally {
|
|
6835
|
+
_usingCtx.d();
|
|
6836
|
+
}
|
|
6460
6837
|
});
|
|
6461
6838
|
}
|
|
6462
6839
|
}
|
|
@@ -6482,7 +6859,7 @@ var ServiceContext = class extends Resource5 {
|
|
|
6482
6859
|
await this._checkStorageVersion();
|
|
6483
6860
|
log20("opening...", void 0, {
|
|
6484
6861
|
F: __dxlog_file23,
|
|
6485
|
-
L:
|
|
6862
|
+
L: 217,
|
|
6486
6863
|
S: this,
|
|
6487
6864
|
C: (f, a) => f(...a)
|
|
6488
6865
|
});
|
|
@@ -6490,11 +6867,14 @@ var ServiceContext = class extends Resource5 {
|
|
|
6490
6867
|
id: this._instanceId
|
|
6491
6868
|
}), {
|
|
6492
6869
|
F: __dxlog_file23,
|
|
6493
|
-
L:
|
|
6870
|
+
L: 218,
|
|
6494
6871
|
S: this,
|
|
6495
6872
|
C: (f, a) => f(...a)
|
|
6496
6873
|
});
|
|
6497
|
-
|
|
6874
|
+
if (this._edgeConnection) {
|
|
6875
|
+
this._edgeConnection.setIdentity(await createEphemeralEdgeIdentity());
|
|
6876
|
+
await this._edgeConnection.open();
|
|
6877
|
+
}
|
|
6498
6878
|
await this.signalManager.open();
|
|
6499
6879
|
await this.networkManager.open();
|
|
6500
6880
|
await this.echoHost.open(ctx);
|
|
@@ -6515,7 +6895,7 @@ var ServiceContext = class extends Resource5 {
|
|
|
6515
6895
|
count: loadedInvitations.invitations?.length
|
|
6516
6896
|
}, {
|
|
6517
6897
|
F: __dxlog_file23,
|
|
6518
|
-
L:
|
|
6898
|
+
L: 245,
|
|
6519
6899
|
S: this,
|
|
6520
6900
|
C: (f, a) => f(...a)
|
|
6521
6901
|
});
|
|
@@ -6523,13 +6903,13 @@ var ServiceContext = class extends Resource5 {
|
|
|
6523
6903
|
id: this._instanceId
|
|
6524
6904
|
}), {
|
|
6525
6905
|
F: __dxlog_file23,
|
|
6526
|
-
L:
|
|
6906
|
+
L: 247,
|
|
6527
6907
|
S: this,
|
|
6528
6908
|
C: (f, a) => f(...a)
|
|
6529
6909
|
});
|
|
6530
6910
|
log20("opened", void 0, {
|
|
6531
6911
|
F: __dxlog_file23,
|
|
6532
|
-
L:
|
|
6912
|
+
L: 248,
|
|
6533
6913
|
S: this,
|
|
6534
6914
|
C: (f, a) => f(...a)
|
|
6535
6915
|
});
|
|
@@ -6537,7 +6917,7 @@ var ServiceContext = class extends Resource5 {
|
|
|
6537
6917
|
async _close(ctx) {
|
|
6538
6918
|
log20("closing...", void 0, {
|
|
6539
6919
|
F: __dxlog_file23,
|
|
6540
|
-
L:
|
|
6920
|
+
L: 252,
|
|
6541
6921
|
S: this,
|
|
6542
6922
|
C: (f, a) => f(...a)
|
|
6543
6923
|
});
|
|
@@ -6555,16 +6935,16 @@ var ServiceContext = class extends Resource5 {
|
|
|
6555
6935
|
await this._edgeConnection?.close();
|
|
6556
6936
|
log20("closed", void 0, {
|
|
6557
6937
|
F: __dxlog_file23,
|
|
6558
|
-
L:
|
|
6938
|
+
L: 267,
|
|
6559
6939
|
S: this,
|
|
6560
6940
|
C: (f, a) => f(...a)
|
|
6561
6941
|
});
|
|
6562
6942
|
}
|
|
6563
6943
|
async createIdentity(params = {}) {
|
|
6564
6944
|
const identity = await this.identityManager.createIdentity(params);
|
|
6565
|
-
await this._initialize(new
|
|
6945
|
+
await this._initialize(new Context9(void 0, {
|
|
6566
6946
|
F: __dxlog_file23,
|
|
6567
|
-
L:
|
|
6947
|
+
L: 272
|
|
6568
6948
|
}));
|
|
6569
6949
|
return identity;
|
|
6570
6950
|
}
|
|
@@ -6572,7 +6952,7 @@ var ServiceContext = class extends Resource5 {
|
|
|
6572
6952
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
6573
6953
|
invariant18(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
6574
6954
|
F: __dxlog_file23,
|
|
6575
|
-
L:
|
|
6955
|
+
L: 278,
|
|
6576
6956
|
S: this,
|
|
6577
6957
|
A: [
|
|
6578
6958
|
"factory",
|
|
@@ -6591,9 +6971,9 @@ var ServiceContext = class extends Resource5 {
|
|
|
6591
6971
|
}
|
|
6592
6972
|
async _acceptIdentity(params) {
|
|
6593
6973
|
const identity = await this.identityManager.acceptIdentity(params);
|
|
6594
|
-
await this._initialize(new
|
|
6974
|
+
await this._initialize(new Context9(void 0, {
|
|
6595
6975
|
F: __dxlog_file23,
|
|
6596
|
-
L:
|
|
6976
|
+
L: 294
|
|
6597
6977
|
}));
|
|
6598
6978
|
return identity;
|
|
6599
6979
|
}
|
|
@@ -6607,7 +6987,7 @@ var ServiceContext = class extends Resource5 {
|
|
|
6607
6987
|
async _initialize(ctx) {
|
|
6608
6988
|
log20("initializing spaces...", void 0, {
|
|
6609
6989
|
F: __dxlog_file23,
|
|
6610
|
-
L:
|
|
6990
|
+
L: 309,
|
|
6611
6991
|
S: this,
|
|
6612
6992
|
C: (f, a) => f(...a)
|
|
6613
6993
|
});
|
|
@@ -6634,6 +7014,7 @@ var ServiceContext = class extends Resource5 {
|
|
|
6634
7014
|
echoHost: this.echoHost,
|
|
6635
7015
|
invitationsManager: this.invitationsManager,
|
|
6636
7016
|
edgeConnection: this._edgeConnection,
|
|
7017
|
+
edgeHttpClient: this._edgeHttpClient,
|
|
6637
7018
|
echoEdgeReplicator: this._echoEdgeReplicator,
|
|
6638
7019
|
meshReplicator: this._meshReplicator,
|
|
6639
7020
|
runtimeParams: this._runtimeParams,
|
|
@@ -6643,7 +7024,7 @@ var ServiceContext = class extends Resource5 {
|
|
|
6643
7024
|
this._handlerFactories.set(Invitation8.Kind.SPACE, (invitation) => {
|
|
6644
7025
|
invariant18(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
6645
7026
|
F: __dxlog_file23,
|
|
6646
|
-
L:
|
|
7027
|
+
L: 339,
|
|
6647
7028
|
S: this,
|
|
6648
7029
|
A: [
|
|
6649
7030
|
"this.dataSpaceManager",
|
|
@@ -6667,7 +7048,7 @@ var ServiceContext = class extends Resource5 {
|
|
|
6667
7048
|
details: assertion
|
|
6668
7049
|
}, {
|
|
6669
7050
|
F: __dxlog_file23,
|
|
6670
|
-
L:
|
|
7051
|
+
L: 355,
|
|
6671
7052
|
S: this,
|
|
6672
7053
|
C: (f, a) => f(...a)
|
|
6673
7054
|
});
|
|
@@ -6678,7 +7059,7 @@ var ServiceContext = class extends Resource5 {
|
|
|
6678
7059
|
details: assertion
|
|
6679
7060
|
}, {
|
|
6680
7061
|
F: __dxlog_file23,
|
|
6681
|
-
L:
|
|
7062
|
+
L: 359,
|
|
6682
7063
|
S: this,
|
|
6683
7064
|
C: (f, a) => f(...a)
|
|
6684
7065
|
});
|
|
@@ -6689,7 +7070,7 @@ var ServiceContext = class extends Resource5 {
|
|
|
6689
7070
|
details: assertion
|
|
6690
7071
|
}, {
|
|
6691
7072
|
F: __dxlog_file23,
|
|
6692
|
-
L:
|
|
7073
|
+
L: 364,
|
|
6693
7074
|
S: this,
|
|
6694
7075
|
C: (f, a) => f(...a)
|
|
6695
7076
|
});
|
|
@@ -6700,7 +7081,7 @@ var ServiceContext = class extends Resource5 {
|
|
|
6700
7081
|
} catch (err) {
|
|
6701
7082
|
log20.catch(err, void 0, {
|
|
6702
7083
|
F: __dxlog_file23,
|
|
6703
|
-
L:
|
|
7084
|
+
L: 370,
|
|
6704
7085
|
S: this,
|
|
6705
7086
|
C: (f, a) => f(...a)
|
|
6706
7087
|
});
|
|
@@ -6710,13 +7091,13 @@ var ServiceContext = class extends Resource5 {
|
|
|
6710
7091
|
await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
|
|
6711
7092
|
}
|
|
6712
7093
|
};
|
|
6713
|
-
|
|
7094
|
+
_ts_decorate9([
|
|
6714
7095
|
Trace3.span()
|
|
6715
7096
|
], ServiceContext.prototype, "_open", null);
|
|
6716
|
-
|
|
7097
|
+
_ts_decorate9([
|
|
6717
7098
|
Trace3.span()
|
|
6718
7099
|
], ServiceContext.prototype, "_initialize", null);
|
|
6719
|
-
ServiceContext =
|
|
7100
|
+
ServiceContext = _ts_decorate9([
|
|
6720
7101
|
safeInstanceof("dxos.client-services.ServiceContext"),
|
|
6721
7102
|
Trace3.resource()
|
|
6722
7103
|
], ServiceContext);
|
|
@@ -6981,8 +7362,8 @@ var importProfileData = async ({ storage, level }, archive) => {
|
|
|
6981
7362
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
6982
7363
|
import { Event as Event10, synchronized as synchronized3 } from "@dxos/async";
|
|
6983
7364
|
import { clientServiceBundle } from "@dxos/client-protocol";
|
|
6984
|
-
import { Context as
|
|
6985
|
-
import { EdgeClient } from "@dxos/edge-client";
|
|
7365
|
+
import { Context as Context10 } from "@dxos/context";
|
|
7366
|
+
import { EdgeClient, EdgeHttpClient, createStubEdgeIdentity } from "@dxos/edge-client";
|
|
6986
7367
|
import { invariant as invariant21 } from "@dxos/invariant";
|
|
6987
7368
|
import { PublicKey as PublicKey17 } from "@dxos/keys";
|
|
6988
7369
|
import { log as log23 } from "@dxos/log";
|
|
@@ -7373,7 +7754,7 @@ var SystemServiceImpl = class {
|
|
|
7373
7754
|
};
|
|
7374
7755
|
|
|
7375
7756
|
// packages/sdk/client-services/src/packlets/services/service-host.ts
|
|
7376
|
-
function
|
|
7757
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
7377
7758
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
7378
7759
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7379
7760
|
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;
|
|
@@ -7395,6 +7776,7 @@ var ClientServicesHost = class {
|
|
|
7395
7776
|
this._tracingService = TRACE_PROCESSOR3.createTraceSender();
|
|
7396
7777
|
this._statusUpdate = new Event10();
|
|
7397
7778
|
this._edgeConnection = void 0;
|
|
7779
|
+
this._edgeHttpClient = void 0;
|
|
7398
7780
|
this._opening = false;
|
|
7399
7781
|
this._open = false;
|
|
7400
7782
|
this._storage = storage;
|
|
@@ -7416,9 +7798,9 @@ var ClientServicesHost = class {
|
|
|
7416
7798
|
lockKey,
|
|
7417
7799
|
onAcquire: () => {
|
|
7418
7800
|
if (!this._opening) {
|
|
7419
|
-
void this.open(new
|
|
7801
|
+
void this.open(new Context10(void 0, {
|
|
7420
7802
|
F: __dxlog_file26,
|
|
7421
|
-
L:
|
|
7803
|
+
L: 133
|
|
7422
7804
|
}));
|
|
7423
7805
|
}
|
|
7424
7806
|
},
|
|
@@ -7476,7 +7858,7 @@ var ClientServicesHost = class {
|
|
|
7476
7858
|
initialize({ config, ...options }) {
|
|
7477
7859
|
invariant21(!this._open, "service host is open", {
|
|
7478
7860
|
F: __dxlog_file26,
|
|
7479
|
-
L:
|
|
7861
|
+
L: 199,
|
|
7480
7862
|
S: this,
|
|
7481
7863
|
A: [
|
|
7482
7864
|
"!this._open",
|
|
@@ -7485,14 +7867,14 @@ var ClientServicesHost = class {
|
|
|
7485
7867
|
});
|
|
7486
7868
|
log23("initializing...", void 0, {
|
|
7487
7869
|
F: __dxlog_file26,
|
|
7488
|
-
L:
|
|
7870
|
+
L: 200,
|
|
7489
7871
|
S: this,
|
|
7490
7872
|
C: (f, a) => f(...a)
|
|
7491
7873
|
});
|
|
7492
7874
|
if (config) {
|
|
7493
7875
|
invariant21(!this._config, "config already set", {
|
|
7494
7876
|
F: __dxlog_file26,
|
|
7495
|
-
L:
|
|
7877
|
+
L: 203,
|
|
7496
7878
|
S: this,
|
|
7497
7879
|
A: [
|
|
7498
7880
|
"!this._config",
|
|
@@ -7507,17 +7889,17 @@ var ClientServicesHost = class {
|
|
|
7507
7889
|
if (!options.signalManager) {
|
|
7508
7890
|
log23.warn("running signaling without telemetry metadata.", void 0, {
|
|
7509
7891
|
F: __dxlog_file26,
|
|
7510
|
-
L:
|
|
7892
|
+
L: 211,
|
|
7511
7893
|
S: this,
|
|
7512
7894
|
C: (f, a) => f(...a)
|
|
7513
7895
|
});
|
|
7514
7896
|
}
|
|
7515
7897
|
const edgeEndpoint = config?.get("runtime.services.edge.url");
|
|
7516
7898
|
if (edgeEndpoint) {
|
|
7517
|
-
|
|
7518
|
-
this._edgeConnection = new EdgeClient(randomKey, randomKey, {
|
|
7899
|
+
this._edgeConnection = new EdgeClient(createStubEdgeIdentity(), {
|
|
7519
7900
|
socketEndpoint: edgeEndpoint
|
|
7520
7901
|
});
|
|
7902
|
+
this._edgeHttpClient = new EdgeHttpClient(edgeEndpoint);
|
|
7521
7903
|
}
|
|
7522
7904
|
const { connectionLog = true, transportFactory = createRtcTransportFactory({
|
|
7523
7905
|
iceServers: this._config?.get("runtime.services.ice")
|
|
@@ -7527,7 +7909,7 @@ var ClientServicesHost = class {
|
|
|
7527
7909
|
this._signalManager = signalManager;
|
|
7528
7910
|
invariant21(!this._networkManager, "network manager already set", {
|
|
7529
7911
|
F: __dxlog_file26,
|
|
7530
|
-
L:
|
|
7912
|
+
L: 233,
|
|
7531
7913
|
S: this,
|
|
7532
7914
|
A: [
|
|
7533
7915
|
"!this._networkManager",
|
|
@@ -7545,7 +7927,7 @@ var ClientServicesHost = class {
|
|
|
7545
7927
|
});
|
|
7546
7928
|
log23("initialized", void 0, {
|
|
7547
7929
|
F: __dxlog_file26,
|
|
7548
|
-
L:
|
|
7930
|
+
L: 246,
|
|
7549
7931
|
S: this,
|
|
7550
7932
|
C: (f, a) => f(...a)
|
|
7551
7933
|
});
|
|
@@ -7559,13 +7941,13 @@ var ClientServicesHost = class {
|
|
|
7559
7941
|
id: traceId
|
|
7560
7942
|
}), {
|
|
7561
7943
|
F: __dxlog_file26,
|
|
7562
|
-
L:
|
|
7944
|
+
L: 257,
|
|
7563
7945
|
S: this,
|
|
7564
7946
|
C: (f, a) => f(...a)
|
|
7565
7947
|
});
|
|
7566
7948
|
invariant21(this._config, "config not set", {
|
|
7567
7949
|
F: __dxlog_file26,
|
|
7568
|
-
L:
|
|
7950
|
+
L: 259,
|
|
7569
7951
|
S: this,
|
|
7570
7952
|
A: [
|
|
7571
7953
|
"this._config",
|
|
@@ -7574,7 +7956,7 @@ var ClientServicesHost = class {
|
|
|
7574
7956
|
});
|
|
7575
7957
|
invariant21(this._storage, "storage not set", {
|
|
7576
7958
|
F: __dxlog_file26,
|
|
7577
|
-
L:
|
|
7959
|
+
L: 260,
|
|
7578
7960
|
S: this,
|
|
7579
7961
|
A: [
|
|
7580
7962
|
"this._storage",
|
|
@@ -7583,7 +7965,7 @@ var ClientServicesHost = class {
|
|
|
7583
7965
|
});
|
|
7584
7966
|
invariant21(this._signalManager, "signal manager not set", {
|
|
7585
7967
|
F: __dxlog_file26,
|
|
7586
|
-
L:
|
|
7968
|
+
L: 261,
|
|
7587
7969
|
S: this,
|
|
7588
7970
|
A: [
|
|
7589
7971
|
"this._signalManager",
|
|
@@ -7592,7 +7974,7 @@ var ClientServicesHost = class {
|
|
|
7592
7974
|
});
|
|
7593
7975
|
invariant21(this._networkManager, "network manager not set", {
|
|
7594
7976
|
F: __dxlog_file26,
|
|
7595
|
-
L:
|
|
7977
|
+
L: 262,
|
|
7596
7978
|
S: this,
|
|
7597
7979
|
A: [
|
|
7598
7980
|
"this._networkManager",
|
|
@@ -7604,7 +7986,7 @@ var ClientServicesHost = class {
|
|
|
7604
7986
|
lockKey: this._resourceLock?.lockKey
|
|
7605
7987
|
}, {
|
|
7606
7988
|
F: __dxlog_file26,
|
|
7607
|
-
L:
|
|
7989
|
+
L: 265,
|
|
7608
7990
|
S: this,
|
|
7609
7991
|
C: (f, a) => f(...a)
|
|
7610
7992
|
});
|
|
@@ -7614,7 +7996,7 @@ var ClientServicesHost = class {
|
|
|
7614
7996
|
}
|
|
7615
7997
|
await this._level.open();
|
|
7616
7998
|
await this._loggingService.open();
|
|
7617
|
-
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._edgeConnection, this._runtimeParams, this._config.get("runtime.client.edgeFeatures"));
|
|
7999
|
+
this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._edgeConnection, this._edgeHttpClient, this._runtimeParams, this._config.get("runtime.client.edgeFeatures"));
|
|
7618
8000
|
const dataSpaceManagerProvider = async () => {
|
|
7619
8001
|
await this._serviceContext.initialized.wait();
|
|
7620
8002
|
return this._serviceContext.dataSpaceManager;
|
|
@@ -7660,7 +8042,7 @@ var ClientServicesHost = class {
|
|
|
7660
8042
|
deviceKey
|
|
7661
8043
|
}, {
|
|
7662
8044
|
F: __dxlog_file26,
|
|
7663
|
-
L:
|
|
8045
|
+
L: 354,
|
|
7664
8046
|
S: this,
|
|
7665
8047
|
C: (f, a) => f(...a)
|
|
7666
8048
|
});
|
|
@@ -7668,7 +8050,7 @@ var ClientServicesHost = class {
|
|
|
7668
8050
|
id: traceId
|
|
7669
8051
|
}), {
|
|
7670
8052
|
F: __dxlog_file26,
|
|
7671
|
-
L:
|
|
8053
|
+
L: 355,
|
|
7672
8054
|
S: this,
|
|
7673
8055
|
C: (f, a) => f(...a)
|
|
7674
8056
|
});
|
|
@@ -7682,7 +8064,7 @@ var ClientServicesHost = class {
|
|
|
7682
8064
|
deviceKey
|
|
7683
8065
|
}, {
|
|
7684
8066
|
F: __dxlog_file26,
|
|
7685
|
-
L:
|
|
8067
|
+
L: 366,
|
|
7686
8068
|
S: this,
|
|
7687
8069
|
C: (f, a) => f(...a)
|
|
7688
8070
|
});
|
|
@@ -7700,7 +8082,7 @@ var ClientServicesHost = class {
|
|
|
7700
8082
|
deviceKey
|
|
7701
8083
|
}, {
|
|
7702
8084
|
F: __dxlog_file26,
|
|
7703
|
-
L:
|
|
8085
|
+
L: 375,
|
|
7704
8086
|
S: this,
|
|
7705
8087
|
C: (f, a) => f(...a)
|
|
7706
8088
|
});
|
|
@@ -7711,13 +8093,13 @@ var ClientServicesHost = class {
|
|
|
7711
8093
|
id: traceId
|
|
7712
8094
|
}), {
|
|
7713
8095
|
F: __dxlog_file26,
|
|
7714
|
-
L:
|
|
8096
|
+
L: 380,
|
|
7715
8097
|
S: this,
|
|
7716
8098
|
C: (f, a) => f(...a)
|
|
7717
8099
|
});
|
|
7718
8100
|
log23.info("resetting...", void 0, {
|
|
7719
8101
|
F: __dxlog_file26,
|
|
7720
|
-
L:
|
|
8102
|
+
L: 382,
|
|
7721
8103
|
S: this,
|
|
7722
8104
|
C: (f, a) => f(...a)
|
|
7723
8105
|
});
|
|
@@ -7725,7 +8107,7 @@ var ClientServicesHost = class {
|
|
|
7725
8107
|
await this._storage.reset();
|
|
7726
8108
|
log23.info("reset", void 0, {
|
|
7727
8109
|
F: __dxlog_file26,
|
|
7728
|
-
L:
|
|
8110
|
+
L: 385,
|
|
7729
8111
|
S: this,
|
|
7730
8112
|
C: (f, a) => f(...a)
|
|
7731
8113
|
});
|
|
@@ -7733,7 +8115,7 @@ var ClientServicesHost = class {
|
|
|
7733
8115
|
id: traceId
|
|
7734
8116
|
}), {
|
|
7735
8117
|
F: __dxlog_file26,
|
|
7736
|
-
L:
|
|
8118
|
+
L: 386,
|
|
7737
8119
|
S: this,
|
|
7738
8120
|
C: (f, a) => f(...a)
|
|
7739
8121
|
});
|
|
@@ -7745,21 +8127,21 @@ var ClientServicesHost = class {
|
|
|
7745
8127
|
return identity;
|
|
7746
8128
|
}
|
|
7747
8129
|
};
|
|
7748
|
-
|
|
8130
|
+
_ts_decorate10([
|
|
7749
8131
|
Trace4.info()
|
|
7750
8132
|
], ClientServicesHost.prototype, "_opening", void 0);
|
|
7751
|
-
|
|
8133
|
+
_ts_decorate10([
|
|
7752
8134
|
Trace4.info()
|
|
7753
8135
|
], ClientServicesHost.prototype, "_open", void 0);
|
|
7754
|
-
|
|
8136
|
+
_ts_decorate10([
|
|
7755
8137
|
synchronized3,
|
|
7756
8138
|
Trace4.span()
|
|
7757
8139
|
], ClientServicesHost.prototype, "open", null);
|
|
7758
|
-
|
|
8140
|
+
_ts_decorate10([
|
|
7759
8141
|
synchronized3,
|
|
7760
8142
|
Trace4.span()
|
|
7761
8143
|
], ClientServicesHost.prototype, "close", null);
|
|
7762
|
-
ClientServicesHost =
|
|
8144
|
+
ClientServicesHost = _ts_decorate10([
|
|
7763
8145
|
Trace4.resource()
|
|
7764
8146
|
], ClientServicesHost);
|
|
7765
8147
|
|
|
@@ -7806,4 +8188,4 @@ export {
|
|
|
7806
8188
|
importProfileData,
|
|
7807
8189
|
ClientServicesHost
|
|
7808
8190
|
};
|
|
7809
|
-
//# sourceMappingURL=chunk-
|
|
8191
|
+
//# sourceMappingURL=chunk-EQAI46LQ.mjs.map
|