@eluvio/elv-client-js 3.2.20 → 3.2.23
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/ElvClient-min.js +1 -1
- package/dist/ElvClient-node-min.js +1 -1
- package/dist/ElvWalletClient-min.js +3 -3
- package/dist/ElvWalletClient-node-min.js +2 -2
- package/dist/src/ElvClient.js +282 -249
- package/dist/src/walletClient/ClientMethods.js +266 -188
- package/dist/src/walletClient/Configuration.js +1 -1
- package/dist/src/walletClient/Utils.js +1 -0
- package/dist/src/walletClient/index.js +144 -40
- package/package.json +1 -1
- package/src/ElvClient.js +17 -9
- package/src/walletClient/ClientMethods.js +26 -0
- package/src/walletClient/Configuration.js +3 -1
- package/src/walletClient/Utils.js +1 -0
package/dist/src/ElvClient.js
CHANGED
|
@@ -864,65 +864,18 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
864
864
|
json 79b {"adr":"VVf4DQU357tDnZGYQeDrntRJ5rs=","spc":"ispc3ANoVSzNA3P6t7abLR69ho5YPPZU"}
|
|
865
865
|
*/
|
|
866
866
|
|
|
867
|
-
/**
|
|
868
|
-
* Create a signed authorization token that can be used to authorize against the fabric
|
|
869
|
-
*
|
|
870
|
-
* @methodGroup Authorization
|
|
871
|
-
* @namedParams
|
|
872
|
-
* @param {number} duration=86400000 - Time until the token expires, in milliseconds (1 hour = 60 * 60 * 1000 = 3600000). Default is 24 hours.
|
|
873
|
-
* @param {Object=} spec - Additional attributes for this token
|
|
874
|
-
* @param {string=} address - Address of the signing account - if not specified, the current signer address will be used.
|
|
875
|
-
* @param {function=} Sign - If specified, this function will be used to produce the signature instead of the client's current signer
|
|
876
|
-
* @param {boolean=} addEthereumPrefix=true - If specified, the 'Ethereum Signed Message' prefixed hash format will be performed. Disable this if the provided Sign method already does this (e.g. Metamask)
|
|
877
|
-
*/
|
|
878
|
-
|
|
879
867
|
}, {
|
|
880
|
-
key: "
|
|
868
|
+
key: "PersonalSign",
|
|
881
869
|
value: function () {
|
|
882
|
-
var
|
|
870
|
+
var _PersonalSign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref11) {
|
|
883
871
|
var _this = this;
|
|
884
872
|
|
|
885
|
-
var
|
|
886
|
-
_ref11$duration,
|
|
887
|
-
duration,
|
|
888
|
-
_ref11$spec,
|
|
889
|
-
spec,
|
|
890
|
-
address,
|
|
891
|
-
Sign,
|
|
892
|
-
_ref11$addEthereumPre,
|
|
893
|
-
addEthereumPrefix,
|
|
894
|
-
token,
|
|
895
|
-
message,
|
|
896
|
-
signature,
|
|
897
|
-
compressedToken,
|
|
898
|
-
_args10 = arguments;
|
|
899
|
-
|
|
873
|
+
var message, addEthereumPrefix, Sign;
|
|
900
874
|
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
901
875
|
while (1) {
|
|
902
876
|
switch (_context10.prev = _context10.next) {
|
|
903
877
|
case 0:
|
|
904
|
-
|
|
905
|
-
address = address || this.CurrentAccountAddress();
|
|
906
|
-
_context10.t0 = _objectSpread;
|
|
907
|
-
_context10.t1 = _objectSpread({}, spec);
|
|
908
|
-
_context10.t2 = {};
|
|
909
|
-
_context10.t3 = "iusr".concat(Utils.AddressToHash(address));
|
|
910
|
-
_context10.t4 = Buffer.from(address.replace(/^0x/, ""), "hex").toString("base64");
|
|
911
|
-
_context10.next = 9;
|
|
912
|
-
return this.ContentSpaceId();
|
|
913
|
-
|
|
914
|
-
case 9:
|
|
915
|
-
_context10.t5 = _context10.sent;
|
|
916
|
-
_context10.t6 = Date.now();
|
|
917
|
-
_context10.t7 = Date.now() + duration;
|
|
918
|
-
_context10.t8 = {
|
|
919
|
-
sub: _context10.t3,
|
|
920
|
-
adr: _context10.t4,
|
|
921
|
-
spc: _context10.t5,
|
|
922
|
-
iat: _context10.t6,
|
|
923
|
-
exp: _context10.t7
|
|
924
|
-
};
|
|
925
|
-
token = (0, _context10.t0)(_context10.t1, _context10.t2, _context10.t8);
|
|
878
|
+
message = _ref11.message, addEthereumPrefix = _ref11.addEthereumPrefix, Sign = _ref11.Sign;
|
|
926
879
|
|
|
927
880
|
if (!Sign) {
|
|
928
881
|
Sign = /*#__PURE__*/function () {
|
|
@@ -941,32 +894,112 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
941
894
|
}, _callee9);
|
|
942
895
|
}));
|
|
943
896
|
|
|
944
|
-
return function Sign(
|
|
897
|
+
return function Sign(_x7) {
|
|
945
898
|
return _ref12.apply(this, arguments);
|
|
946
899
|
};
|
|
947
900
|
}();
|
|
948
901
|
}
|
|
949
902
|
|
|
950
|
-
message = "Eluvio Content Fabric Access Token 1.0\n".concat(JSON.stringify(token));
|
|
951
|
-
|
|
952
903
|
if (addEthereumPrefix) {
|
|
953
904
|
message = Ethers.utils.keccak256(Buffer.from("\x19Ethereum Signed Message:\n".concat(message.length).concat(message), "utf-8"));
|
|
954
905
|
}
|
|
955
906
|
|
|
956
|
-
_context10.next =
|
|
907
|
+
_context10.next = 5;
|
|
957
908
|
return Sign(message);
|
|
958
909
|
|
|
959
|
-
case
|
|
960
|
-
|
|
961
|
-
compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
|
|
962
|
-
return _context10.abrupt("return", "acspjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
|
|
910
|
+
case 5:
|
|
911
|
+
return _context10.abrupt("return", _context10.sent);
|
|
963
912
|
|
|
964
|
-
case
|
|
913
|
+
case 6:
|
|
965
914
|
case "end":
|
|
966
915
|
return _context10.stop();
|
|
967
916
|
}
|
|
968
917
|
}
|
|
969
|
-
}, _callee10
|
|
918
|
+
}, _callee10);
|
|
919
|
+
}));
|
|
920
|
+
|
|
921
|
+
function PersonalSign(_x6) {
|
|
922
|
+
return _PersonalSign.apply(this, arguments);
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
return PersonalSign;
|
|
926
|
+
}()
|
|
927
|
+
/**
|
|
928
|
+
* Create a signed authorization token that can be used to authorize against the fabric
|
|
929
|
+
*
|
|
930
|
+
* @methodGroup Authorization
|
|
931
|
+
* @namedParams
|
|
932
|
+
* @param {number} duration=86400000 - Time until the token expires, in milliseconds (1 hour = 60 * 60 * 1000 = 3600000). Default is 24 hours.
|
|
933
|
+
* @param {Object=} spec - Additional attributes for this token
|
|
934
|
+
* @param {string=} address - Address of the signing account - if not specified, the current signer address will be used.
|
|
935
|
+
* @param {function=} Sign - If specified, this function will be used to produce the signature instead of the client's current signer
|
|
936
|
+
* @param {boolean=} addEthereumPrefix=true - If specified, the 'Ethereum Signed Message' prefixed hash format will be performed. Disable this if the provided Sign method already does this (e.g. Metamask)
|
|
937
|
+
*/
|
|
938
|
+
|
|
939
|
+
}, {
|
|
940
|
+
key: "CreateFabricToken",
|
|
941
|
+
value: function () {
|
|
942
|
+
var _CreateFabricToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
|
943
|
+
var _ref13,
|
|
944
|
+
_ref13$duration,
|
|
945
|
+
duration,
|
|
946
|
+
_ref13$spec,
|
|
947
|
+
spec,
|
|
948
|
+
address,
|
|
949
|
+
Sign,
|
|
950
|
+
_ref13$addEthereumPre,
|
|
951
|
+
addEthereumPrefix,
|
|
952
|
+
token,
|
|
953
|
+
message,
|
|
954
|
+
signature,
|
|
955
|
+
compressedToken,
|
|
956
|
+
_args11 = arguments;
|
|
957
|
+
|
|
958
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
959
|
+
while (1) {
|
|
960
|
+
switch (_context11.prev = _context11.next) {
|
|
961
|
+
case 0:
|
|
962
|
+
_ref13 = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {}, _ref13$duration = _ref13.duration, duration = _ref13$duration === void 0 ? 24 * 60 * 60 * 1000 : _ref13$duration, _ref13$spec = _ref13.spec, spec = _ref13$spec === void 0 ? {} : _ref13$spec, address = _ref13.address, Sign = _ref13.Sign, _ref13$addEthereumPre = _ref13.addEthereumPrefix, addEthereumPrefix = _ref13$addEthereumPre === void 0 ? true : _ref13$addEthereumPre;
|
|
963
|
+
address = address || this.CurrentAccountAddress();
|
|
964
|
+
_context11.t0 = _objectSpread;
|
|
965
|
+
_context11.t1 = _objectSpread({}, spec);
|
|
966
|
+
_context11.t2 = {};
|
|
967
|
+
_context11.t3 = "iusr".concat(Utils.AddressToHash(address));
|
|
968
|
+
_context11.t4 = Buffer.from(address.replace(/^0x/, ""), "hex").toString("base64");
|
|
969
|
+
_context11.next = 9;
|
|
970
|
+
return this.ContentSpaceId();
|
|
971
|
+
|
|
972
|
+
case 9:
|
|
973
|
+
_context11.t5 = _context11.sent;
|
|
974
|
+
_context11.t6 = Date.now();
|
|
975
|
+
_context11.t7 = Date.now() + duration;
|
|
976
|
+
_context11.t8 = {
|
|
977
|
+
sub: _context11.t3,
|
|
978
|
+
adr: _context11.t4,
|
|
979
|
+
spc: _context11.t5,
|
|
980
|
+
iat: _context11.t6,
|
|
981
|
+
exp: _context11.t7
|
|
982
|
+
};
|
|
983
|
+
token = (0, _context11.t0)(_context11.t1, _context11.t2, _context11.t8);
|
|
984
|
+
message = "Eluvio Content Fabric Access Token 1.0\n".concat(JSON.stringify(token));
|
|
985
|
+
_context11.next = 17;
|
|
986
|
+
return this.PersonalSign({
|
|
987
|
+
message: message,
|
|
988
|
+
addEthereumPrefix: addEthereumPrefix,
|
|
989
|
+
Sign: Sign
|
|
990
|
+
});
|
|
991
|
+
|
|
992
|
+
case 17:
|
|
993
|
+
signature = _context11.sent;
|
|
994
|
+
compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
|
|
995
|
+
return _context11.abrupt("return", "acspjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
|
|
996
|
+
|
|
997
|
+
case 20:
|
|
998
|
+
case "end":
|
|
999
|
+
return _context11.stop();
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
}, _callee11, this);
|
|
970
1003
|
}));
|
|
971
1004
|
|
|
972
1005
|
function CreateFabricToken() {
|
|
@@ -995,60 +1028,60 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
995
1028
|
}, {
|
|
996
1029
|
key: "CreateSignedToken",
|
|
997
1030
|
value: function () {
|
|
998
|
-
var _CreateSignedToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
999
|
-
var libraryId, objectId, versionHash, policyId, subject,
|
|
1031
|
+
var _CreateSignedToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref14) {
|
|
1032
|
+
var libraryId, objectId, versionHash, policyId, subject, _ref14$grantType, grantType, _ref14$allowDecryptio, allowDecryption, duration, _ref14$context, context, token, cap, compressedToken, signature;
|
|
1000
1033
|
|
|
1001
|
-
return _regeneratorRuntime.wrap(function
|
|
1034
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
1002
1035
|
while (1) {
|
|
1003
|
-
switch (
|
|
1036
|
+
switch (_context12.prev = _context12.next) {
|
|
1004
1037
|
case 0:
|
|
1005
|
-
libraryId =
|
|
1038
|
+
libraryId = _ref14.libraryId, objectId = _ref14.objectId, versionHash = _ref14.versionHash, policyId = _ref14.policyId, subject = _ref14.subject, _ref14$grantType = _ref14.grantType, grantType = _ref14$grantType === void 0 ? "read" : _ref14$grantType, _ref14$allowDecryptio = _ref14.allowDecryption, allowDecryption = _ref14$allowDecryptio === void 0 ? false : _ref14$allowDecryptio, duration = _ref14.duration, _ref14$context = _ref14.context, context = _ref14$context === void 0 ? {} : _ref14$context;
|
|
1006
1039
|
|
|
1007
1040
|
if (subject) {
|
|
1008
|
-
|
|
1041
|
+
_context12.next = 9;
|
|
1009
1042
|
break;
|
|
1010
1043
|
}
|
|
1011
1044
|
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1045
|
+
_context12.t0 = "iusr";
|
|
1046
|
+
_context12.t1 = this.utils;
|
|
1047
|
+
_context12.next = 6;
|
|
1015
1048
|
return this.CurrentAccountAddress();
|
|
1016
1049
|
|
|
1017
1050
|
case 6:
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
subject =
|
|
1051
|
+
_context12.t2 = _context12.sent;
|
|
1052
|
+
_context12.t3 = _context12.t1.AddressToHash.call(_context12.t1, _context12.t2);
|
|
1053
|
+
subject = _context12.t0.concat.call(_context12.t0, _context12.t3);
|
|
1021
1054
|
|
|
1022
1055
|
case 9:
|
|
1023
1056
|
if (policyId) {
|
|
1024
1057
|
context["elv:delegation-id"] = policyId;
|
|
1025
1058
|
}
|
|
1026
1059
|
|
|
1027
|
-
|
|
1028
|
-
|
|
1060
|
+
_context12.t4 = Buffer;
|
|
1061
|
+
_context12.next = 13;
|
|
1029
1062
|
return this.CurrentAccountAddress().replace(/^0x/, "");
|
|
1030
1063
|
|
|
1031
1064
|
case 13:
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1065
|
+
_context12.t5 = _context12.sent;
|
|
1066
|
+
_context12.t6 = _context12.t4.from.call(_context12.t4, _context12.t5, "hex").toString("base64");
|
|
1067
|
+
_context12.t7 = subject;
|
|
1068
|
+
_context12.next = 18;
|
|
1036
1069
|
return this.ContentSpaceId();
|
|
1037
1070
|
|
|
1038
1071
|
case 18:
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1072
|
+
_context12.t8 = _context12.sent;
|
|
1073
|
+
_context12.t9 = Date.now();
|
|
1074
|
+
_context12.t10 = Date.now() + duration;
|
|
1075
|
+
_context12.t11 = grantType;
|
|
1076
|
+
_context12.t12 = context;
|
|
1044
1077
|
token = {
|
|
1045
|
-
adr:
|
|
1046
|
-
sub:
|
|
1047
|
-
spc:
|
|
1048
|
-
iat:
|
|
1049
|
-
exp:
|
|
1050
|
-
gra:
|
|
1051
|
-
ctx:
|
|
1078
|
+
adr: _context12.t6,
|
|
1079
|
+
sub: _context12.t7,
|
|
1080
|
+
spc: _context12.t8,
|
|
1081
|
+
iat: _context12.t9,
|
|
1082
|
+
exp: _context12.t10,
|
|
1083
|
+
gra: _context12.t11,
|
|
1084
|
+
ctx: _context12.t12
|
|
1052
1085
|
};
|
|
1053
1086
|
|
|
1054
1087
|
if (versionHash) {
|
|
@@ -1056,24 +1089,24 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1056
1089
|
}
|
|
1057
1090
|
|
|
1058
1091
|
if (!objectId) {
|
|
1059
|
-
|
|
1092
|
+
_context12.next = 31;
|
|
1060
1093
|
break;
|
|
1061
1094
|
}
|
|
1062
1095
|
|
|
1063
1096
|
token.qid = objectId;
|
|
1064
1097
|
|
|
1065
1098
|
if (libraryId) {
|
|
1066
|
-
|
|
1099
|
+
_context12.next = 31;
|
|
1067
1100
|
break;
|
|
1068
1101
|
}
|
|
1069
1102
|
|
|
1070
|
-
|
|
1103
|
+
_context12.next = 30;
|
|
1071
1104
|
return this.ContentObjectLibraryId({
|
|
1072
1105
|
objectId: objectId
|
|
1073
1106
|
});
|
|
1074
1107
|
|
|
1075
1108
|
case 30:
|
|
1076
|
-
libraryId =
|
|
1109
|
+
libraryId = _context12.sent;
|
|
1077
1110
|
|
|
1078
1111
|
case 31:
|
|
1079
1112
|
if (libraryId) {
|
|
@@ -1081,38 +1114,38 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1081
1114
|
}
|
|
1082
1115
|
|
|
1083
1116
|
if (!allowDecryption) {
|
|
1084
|
-
|
|
1117
|
+
_context12.next = 37;
|
|
1085
1118
|
break;
|
|
1086
1119
|
}
|
|
1087
1120
|
|
|
1088
|
-
|
|
1121
|
+
_context12.next = 35;
|
|
1089
1122
|
return this.authClient.ReEncryptionConk({
|
|
1090
1123
|
libraryId: libraryId,
|
|
1091
1124
|
objectId: objectId
|
|
1092
1125
|
});
|
|
1093
1126
|
|
|
1094
1127
|
case 35:
|
|
1095
|
-
cap =
|
|
1128
|
+
cap = _context12.sent;
|
|
1096
1129
|
token.apk = cap.public_key;
|
|
1097
1130
|
|
|
1098
1131
|
case 37:
|
|
1099
1132
|
compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
|
|
1100
|
-
|
|
1133
|
+
_context12.next = 40;
|
|
1101
1134
|
return this.authClient.Sign(Ethers.utils.keccak256(compressedToken));
|
|
1102
1135
|
|
|
1103
1136
|
case 40:
|
|
1104
|
-
signature =
|
|
1105
|
-
return
|
|
1137
|
+
signature = _context12.sent;
|
|
1138
|
+
return _context12.abrupt("return", "aessjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
|
|
1106
1139
|
|
|
1107
1140
|
case 42:
|
|
1108
1141
|
case "end":
|
|
1109
|
-
return
|
|
1142
|
+
return _context12.stop();
|
|
1110
1143
|
}
|
|
1111
1144
|
}
|
|
1112
|
-
},
|
|
1145
|
+
}, _callee12, this);
|
|
1113
1146
|
}));
|
|
1114
1147
|
|
|
1115
|
-
function CreateSignedToken(
|
|
1148
|
+
function CreateSignedToken(_x8) {
|
|
1116
1149
|
return _CreateSignedToken.apply(this, arguments);
|
|
1117
1150
|
}
|
|
1118
1151
|
|
|
@@ -1141,13 +1174,13 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1141
1174
|
}, {
|
|
1142
1175
|
key: "SetOauthToken",
|
|
1143
1176
|
value: function () {
|
|
1144
|
-
var _SetOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1177
|
+
var _SetOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref15) {
|
|
1145
1178
|
var token, wallet, signer;
|
|
1146
|
-
return _regeneratorRuntime.wrap(function
|
|
1179
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
1147
1180
|
while (1) {
|
|
1148
|
-
switch (
|
|
1181
|
+
switch (_context13.prev = _context13.next) {
|
|
1149
1182
|
case 0:
|
|
1150
|
-
token =
|
|
1183
|
+
token = _ref15.token;
|
|
1151
1184
|
this.oauthToken = token;
|
|
1152
1185
|
wallet = this.GenerateWallet();
|
|
1153
1186
|
signer = wallet.AddAccountFromMnemonic({
|
|
@@ -1159,13 +1192,13 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1159
1192
|
|
|
1160
1193
|
case 5:
|
|
1161
1194
|
case "end":
|
|
1162
|
-
return
|
|
1195
|
+
return _context13.stop();
|
|
1163
1196
|
}
|
|
1164
1197
|
}
|
|
1165
|
-
},
|
|
1198
|
+
}, _callee13, this);
|
|
1166
1199
|
}));
|
|
1167
1200
|
|
|
1168
|
-
function SetOauthToken(
|
|
1201
|
+
function SetOauthToken(_x9) {
|
|
1169
1202
|
return _SetOauthToken.apply(this, arguments);
|
|
1170
1203
|
}
|
|
1171
1204
|
|
|
@@ -1185,17 +1218,17 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1185
1218
|
}, {
|
|
1186
1219
|
key: "SetSignerFromOauthToken",
|
|
1187
1220
|
value: function () {
|
|
1188
|
-
var _SetSignerFromOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1221
|
+
var _SetSignerFromOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref16) {
|
|
1189
1222
|
var token, wallet, client, _yield$client$authCli, urls, path, httpClient, response, privateKey;
|
|
1190
1223
|
|
|
1191
|
-
return _regeneratorRuntime.wrap(function
|
|
1224
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
1192
1225
|
while (1) {
|
|
1193
|
-
switch (
|
|
1226
|
+
switch (_context14.prev = _context14.next) {
|
|
1194
1227
|
case 0:
|
|
1195
|
-
token =
|
|
1228
|
+
token = _ref16.token;
|
|
1196
1229
|
|
|
1197
1230
|
if (this.trustAuthorityId) {
|
|
1198
|
-
|
|
1231
|
+
_context14.next = 3;
|
|
1199
1232
|
break;
|
|
1200
1233
|
}
|
|
1201
1234
|
|
|
@@ -1203,36 +1236,36 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1203
1236
|
|
|
1204
1237
|
case 3:
|
|
1205
1238
|
wallet = this.GenerateWallet();
|
|
1206
|
-
|
|
1239
|
+
_context14.prev = 4;
|
|
1207
1240
|
|
|
1208
1241
|
if (this.kmsURIs) {
|
|
1209
|
-
|
|
1242
|
+
_context14.next = 17;
|
|
1210
1243
|
break;
|
|
1211
1244
|
}
|
|
1212
1245
|
|
|
1213
|
-
|
|
1246
|
+
_context14.next = 8;
|
|
1214
1247
|
return ElvClient.FromConfigurationUrl({
|
|
1215
1248
|
configUrl: this.configUrl
|
|
1216
1249
|
});
|
|
1217
1250
|
|
|
1218
1251
|
case 8:
|
|
1219
|
-
client =
|
|
1252
|
+
client = _context14.sent;
|
|
1220
1253
|
client.SetSigner({
|
|
1221
1254
|
signer: wallet.AddAccountFromMnemonic({
|
|
1222
1255
|
mnemonic: wallet.GenerateMnemonic()
|
|
1223
1256
|
})
|
|
1224
1257
|
});
|
|
1225
|
-
|
|
1258
|
+
_context14.next = 12;
|
|
1226
1259
|
return client.authClient.KMSInfo({
|
|
1227
1260
|
kmsId: this.trustAuthorityId
|
|
1228
1261
|
});
|
|
1229
1262
|
|
|
1230
1263
|
case 12:
|
|
1231
|
-
_yield$client$authCli =
|
|
1264
|
+
_yield$client$authCli = _context14.sent;
|
|
1232
1265
|
urls = _yield$client$authCli.urls;
|
|
1233
1266
|
|
|
1234
1267
|
if (!(!urls || urls.length === 0)) {
|
|
1235
|
-
|
|
1268
|
+
_context14.next = 16;
|
|
1236
1269
|
break;
|
|
1237
1270
|
}
|
|
1238
1271
|
|
|
@@ -1248,7 +1281,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1248
1281
|
uris: this.kmsURIs,
|
|
1249
1282
|
debug: this.debug
|
|
1250
1283
|
});
|
|
1251
|
-
|
|
1284
|
+
_context14.next = 22;
|
|
1252
1285
|
return this.utils.ResponseToJson(httpClient.Request({
|
|
1253
1286
|
headers: {
|
|
1254
1287
|
Authorization: "Bearer ".concat(token)
|
|
@@ -1259,7 +1292,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1259
1292
|
}));
|
|
1260
1293
|
|
|
1261
1294
|
case 22:
|
|
1262
|
-
response =
|
|
1295
|
+
response = _context14.sent;
|
|
1263
1296
|
privateKey = response["UserSKHex"];
|
|
1264
1297
|
this.SetSigner({
|
|
1265
1298
|
signer: wallet.AddAccount({
|
|
@@ -1267,33 +1300,33 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1267
1300
|
})
|
|
1268
1301
|
}); // Ensure wallet is initialized
|
|
1269
1302
|
|
|
1270
|
-
|
|
1303
|
+
_context14.next = 27;
|
|
1271
1304
|
return this.userProfileClient.WalletAddress();
|
|
1272
1305
|
|
|
1273
1306
|
case 27:
|
|
1274
|
-
|
|
1307
|
+
_context14.next = 36;
|
|
1275
1308
|
break;
|
|
1276
1309
|
|
|
1277
1310
|
case 29:
|
|
1278
|
-
|
|
1279
|
-
|
|
1311
|
+
_context14.prev = 29;
|
|
1312
|
+
_context14.t0 = _context14["catch"](4);
|
|
1280
1313
|
this.Log("Failed to set signer from OAuth token:", true);
|
|
1281
|
-
this.Log(
|
|
1282
|
-
|
|
1314
|
+
this.Log(_context14.t0, true);
|
|
1315
|
+
_context14.next = 35;
|
|
1283
1316
|
return this.ClearSigner();
|
|
1284
1317
|
|
|
1285
1318
|
case 35:
|
|
1286
|
-
throw
|
|
1319
|
+
throw _context14.t0;
|
|
1287
1320
|
|
|
1288
1321
|
case 36:
|
|
1289
1322
|
case "end":
|
|
1290
|
-
return
|
|
1323
|
+
return _context14.stop();
|
|
1291
1324
|
}
|
|
1292
1325
|
}
|
|
1293
|
-
},
|
|
1326
|
+
}, _callee14, this, [[4, 29]]);
|
|
1294
1327
|
}));
|
|
1295
1328
|
|
|
1296
|
-
function SetSignerFromOauthToken(
|
|
1329
|
+
function SetSignerFromOauthToken(_x10) {
|
|
1297
1330
|
return _SetSignerFromOauthToken.apply(this, arguments);
|
|
1298
1331
|
}
|
|
1299
1332
|
|
|
@@ -1310,8 +1343,8 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1310
1343
|
}, {
|
|
1311
1344
|
key: "SetStaticToken",
|
|
1312
1345
|
value: function SetStaticToken() {
|
|
1313
|
-
var
|
|
1314
|
-
token =
|
|
1346
|
+
var _ref17 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1347
|
+
token = _ref17.token;
|
|
1315
1348
|
|
|
1316
1349
|
if (!token) {
|
|
1317
1350
|
token = this.utils.B64(JSON.stringify({
|
|
@@ -1343,36 +1376,36 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1343
1376
|
}, {
|
|
1344
1377
|
key: "SetPolicyAuthorization",
|
|
1345
1378
|
value: function () {
|
|
1346
|
-
var _SetPolicyAuthorization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1379
|
+
var _SetPolicyAuthorization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref18) {
|
|
1347
1380
|
var objectId;
|
|
1348
|
-
return _regeneratorRuntime.wrap(function
|
|
1381
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
1349
1382
|
while (1) {
|
|
1350
|
-
switch (
|
|
1383
|
+
switch (_context15.prev = _context15.next) {
|
|
1351
1384
|
case 0:
|
|
1352
|
-
objectId =
|
|
1353
|
-
|
|
1354
|
-
|
|
1385
|
+
objectId = _ref18.objectId;
|
|
1386
|
+
_context15.t0 = this;
|
|
1387
|
+
_context15.next = 4;
|
|
1355
1388
|
return this.GenerateStateChannelToken({
|
|
1356
1389
|
objectId: objectId
|
|
1357
1390
|
});
|
|
1358
1391
|
|
|
1359
1392
|
case 4:
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
token:
|
|
1393
|
+
_context15.t1 = _context15.sent;
|
|
1394
|
+
_context15.t2 = {
|
|
1395
|
+
token: _context15.t1
|
|
1363
1396
|
};
|
|
1364
1397
|
|
|
1365
|
-
|
|
1398
|
+
_context15.t0.SetStaticToken.call(_context15.t0, _context15.t2);
|
|
1366
1399
|
|
|
1367
1400
|
case 7:
|
|
1368
1401
|
case "end":
|
|
1369
|
-
return
|
|
1402
|
+
return _context15.stop();
|
|
1370
1403
|
}
|
|
1371
1404
|
}
|
|
1372
|
-
},
|
|
1405
|
+
}, _callee15, this);
|
|
1373
1406
|
}));
|
|
1374
1407
|
|
|
1375
|
-
function SetPolicyAuthorization(
|
|
1408
|
+
function SetPolicyAuthorization(_x11) {
|
|
1376
1409
|
return _SetPolicyAuthorization.apply(this, arguments);
|
|
1377
1410
|
}
|
|
1378
1411
|
|
|
@@ -1388,28 +1421,28 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1388
1421
|
}, {
|
|
1389
1422
|
key: "Sign",
|
|
1390
1423
|
value: function () {
|
|
1391
|
-
var _Sign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1424
|
+
var _Sign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(string) {
|
|
1392
1425
|
var signature;
|
|
1393
|
-
return _regeneratorRuntime.wrap(function
|
|
1426
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
1394
1427
|
while (1) {
|
|
1395
|
-
switch (
|
|
1428
|
+
switch (_context16.prev = _context16.next) {
|
|
1396
1429
|
case 0:
|
|
1397
|
-
|
|
1430
|
+
_context16.next = 2;
|
|
1398
1431
|
return this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(string)));
|
|
1399
1432
|
|
|
1400
1433
|
case 2:
|
|
1401
|
-
signature =
|
|
1402
|
-
return
|
|
1434
|
+
signature = _context16.sent;
|
|
1435
|
+
return _context16.abrupt("return", this.utils.FormatSignature(signature));
|
|
1403
1436
|
|
|
1404
1437
|
case 4:
|
|
1405
1438
|
case "end":
|
|
1406
|
-
return
|
|
1439
|
+
return _context16.stop();
|
|
1407
1440
|
}
|
|
1408
1441
|
}
|
|
1409
|
-
},
|
|
1442
|
+
}, _callee16, this);
|
|
1410
1443
|
}));
|
|
1411
1444
|
|
|
1412
|
-
function Sign(
|
|
1445
|
+
function Sign(_x12) {
|
|
1413
1446
|
return _Sign.apply(this, arguments);
|
|
1414
1447
|
}
|
|
1415
1448
|
|
|
@@ -1428,16 +1461,16 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1428
1461
|
}, {
|
|
1429
1462
|
key: "EncryptECIES",
|
|
1430
1463
|
value: function () {
|
|
1431
|
-
var _EncryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1464
|
+
var _EncryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref19) {
|
|
1432
1465
|
var message, publicKey;
|
|
1433
|
-
return _regeneratorRuntime.wrap(function
|
|
1466
|
+
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
1434
1467
|
while (1) {
|
|
1435
|
-
switch (
|
|
1468
|
+
switch (_context17.prev = _context17.next) {
|
|
1436
1469
|
case 0:
|
|
1437
|
-
message =
|
|
1470
|
+
message = _ref19.message, publicKey = _ref19.publicKey;
|
|
1438
1471
|
|
|
1439
1472
|
if (this.signer) {
|
|
1440
|
-
|
|
1473
|
+
_context17.next = 3;
|
|
1441
1474
|
break;
|
|
1442
1475
|
}
|
|
1443
1476
|
|
|
@@ -1445,21 +1478,21 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1445
1478
|
|
|
1446
1479
|
case 3:
|
|
1447
1480
|
ValidatePresence("message", message);
|
|
1448
|
-
|
|
1481
|
+
_context17.next = 6;
|
|
1449
1482
|
return this.Crypto.EncryptConk(message, publicKey || this.signer.signingKey.keyPair.publicKey);
|
|
1450
1483
|
|
|
1451
1484
|
case 6:
|
|
1452
|
-
return
|
|
1485
|
+
return _context17.abrupt("return", _context17.sent);
|
|
1453
1486
|
|
|
1454
1487
|
case 7:
|
|
1455
1488
|
case "end":
|
|
1456
|
-
return
|
|
1489
|
+
return _context17.stop();
|
|
1457
1490
|
}
|
|
1458
1491
|
}
|
|
1459
|
-
},
|
|
1492
|
+
}, _callee17, this);
|
|
1460
1493
|
}));
|
|
1461
1494
|
|
|
1462
|
-
function EncryptECIES(
|
|
1495
|
+
function EncryptECIES(_x13) {
|
|
1463
1496
|
return _EncryptECIES.apply(this, arguments);
|
|
1464
1497
|
}
|
|
1465
1498
|
|
|
@@ -1477,16 +1510,16 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1477
1510
|
}, {
|
|
1478
1511
|
key: "DecryptECIES",
|
|
1479
1512
|
value: function () {
|
|
1480
|
-
var _DecryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1513
|
+
var _DecryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref20) {
|
|
1481
1514
|
var message;
|
|
1482
|
-
return _regeneratorRuntime.wrap(function
|
|
1515
|
+
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
1483
1516
|
while (1) {
|
|
1484
|
-
switch (
|
|
1517
|
+
switch (_context18.prev = _context18.next) {
|
|
1485
1518
|
case 0:
|
|
1486
|
-
message =
|
|
1519
|
+
message = _ref20.message;
|
|
1487
1520
|
|
|
1488
1521
|
if (this.signer) {
|
|
1489
|
-
|
|
1522
|
+
_context18.next = 3;
|
|
1490
1523
|
break;
|
|
1491
1524
|
}
|
|
1492
1525
|
|
|
@@ -1494,21 +1527,21 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1494
1527
|
|
|
1495
1528
|
case 3:
|
|
1496
1529
|
ValidatePresence("message", message);
|
|
1497
|
-
|
|
1530
|
+
_context18.next = 6;
|
|
1498
1531
|
return this.Crypto.DecryptCap(message, this.signer.signingKey.privateKey);
|
|
1499
1532
|
|
|
1500
1533
|
case 6:
|
|
1501
|
-
return
|
|
1534
|
+
return _context18.abrupt("return", _context18.sent);
|
|
1502
1535
|
|
|
1503
1536
|
case 7:
|
|
1504
1537
|
case "end":
|
|
1505
|
-
return
|
|
1538
|
+
return _context18.stop();
|
|
1506
1539
|
}
|
|
1507
1540
|
}
|
|
1508
|
-
},
|
|
1541
|
+
}, _callee18, this);
|
|
1509
1542
|
}));
|
|
1510
1543
|
|
|
1511
|
-
function DecryptECIES(
|
|
1544
|
+
function DecryptECIES(_x14) {
|
|
1512
1545
|
return _DecryptECIES.apply(this, arguments);
|
|
1513
1546
|
}
|
|
1514
1547
|
|
|
@@ -1529,15 +1562,15 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1529
1562
|
}, {
|
|
1530
1563
|
key: "Request",
|
|
1531
1564
|
value: function () {
|
|
1532
|
-
var _Request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1533
|
-
var url,
|
|
1565
|
+
var _Request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(_ref21) {
|
|
1566
|
+
var url, _ref21$format, format, _ref21$method, method, _ref21$headers, headers, body;
|
|
1534
1567
|
|
|
1535
|
-
return _regeneratorRuntime.wrap(function
|
|
1568
|
+
return _regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
1536
1569
|
while (1) {
|
|
1537
|
-
switch (
|
|
1570
|
+
switch (_context19.prev = _context19.next) {
|
|
1538
1571
|
case 0:
|
|
1539
|
-
url =
|
|
1540
|
-
return
|
|
1572
|
+
url = _ref21.url, _ref21$format = _ref21.format, format = _ref21$format === void 0 ? "json" : _ref21$format, _ref21$method = _ref21.method, method = _ref21$method === void 0 ? "GET" : _ref21$method, _ref21$headers = _ref21.headers, headers = _ref21$headers === void 0 ? {} : _ref21$headers, body = _ref21.body;
|
|
1573
|
+
return _context19.abrupt("return", this.utils.ResponseToFormat(format, HttpClient.Fetch(url, {
|
|
1541
1574
|
method: method,
|
|
1542
1575
|
headers: headers,
|
|
1543
1576
|
body: body
|
|
@@ -1545,13 +1578,13 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1545
1578
|
|
|
1546
1579
|
case 2:
|
|
1547
1580
|
case "end":
|
|
1548
|
-
return
|
|
1581
|
+
return _context19.stop();
|
|
1549
1582
|
}
|
|
1550
1583
|
}
|
|
1551
|
-
},
|
|
1584
|
+
}, _callee19, this);
|
|
1552
1585
|
}));
|
|
1553
1586
|
|
|
1554
|
-
function Request(
|
|
1587
|
+
function Request(_x15) {
|
|
1555
1588
|
return _Request.apply(this, arguments);
|
|
1556
1589
|
}
|
|
1557
1590
|
|
|
@@ -1574,20 +1607,20 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1574
1607
|
}, {
|
|
1575
1608
|
key: "CallFromFrameMessage",
|
|
1576
1609
|
value: function () {
|
|
1577
|
-
var _CallFromFrameMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1610
|
+
var _CallFromFrameMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(message, Respond) {
|
|
1578
1611
|
var _this3 = this;
|
|
1579
1612
|
|
|
1580
1613
|
var callback, method, methodResults, responseError;
|
|
1581
|
-
return _regeneratorRuntime.wrap(function
|
|
1614
|
+
return _regeneratorRuntime.wrap(function _callee20$(_context20) {
|
|
1582
1615
|
while (1) {
|
|
1583
|
-
switch (
|
|
1616
|
+
switch (_context20.prev = _context20.next) {
|
|
1584
1617
|
case 0:
|
|
1585
1618
|
if (!(message.type !== "ElvFrameRequest")) {
|
|
1586
|
-
|
|
1619
|
+
_context20.next = 2;
|
|
1587
1620
|
break;
|
|
1588
1621
|
}
|
|
1589
1622
|
|
|
1590
|
-
return
|
|
1623
|
+
return _context20.abrupt("return");
|
|
1591
1624
|
|
|
1592
1625
|
case 2:
|
|
1593
1626
|
if (message.callbackId) {
|
|
@@ -1602,44 +1635,44 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1602
1635
|
message.args.callback = callback;
|
|
1603
1636
|
}
|
|
1604
1637
|
|
|
1605
|
-
|
|
1638
|
+
_context20.prev = 3;
|
|
1606
1639
|
method = message.calledMethod;
|
|
1607
1640
|
|
|
1608
1641
|
if (!(message.module === "userProfileClient")) {
|
|
1609
|
-
|
|
1642
|
+
_context20.next = 13;
|
|
1610
1643
|
break;
|
|
1611
1644
|
}
|
|
1612
1645
|
|
|
1613
1646
|
if (this.userProfileClient.FrameAllowedMethods().includes(method)) {
|
|
1614
|
-
|
|
1647
|
+
_context20.next = 8;
|
|
1615
1648
|
break;
|
|
1616
1649
|
}
|
|
1617
1650
|
|
|
1618
1651
|
throw Error("Invalid user profile method: " + method);
|
|
1619
1652
|
|
|
1620
1653
|
case 8:
|
|
1621
|
-
|
|
1654
|
+
_context20.next = 10;
|
|
1622
1655
|
return this.userProfileClient[method](message.args);
|
|
1623
1656
|
|
|
1624
1657
|
case 10:
|
|
1625
|
-
methodResults =
|
|
1626
|
-
|
|
1658
|
+
methodResults = _context20.sent;
|
|
1659
|
+
_context20.next = 18;
|
|
1627
1660
|
break;
|
|
1628
1661
|
|
|
1629
1662
|
case 13:
|
|
1630
1663
|
if (this.FrameAllowedMethods().includes(method)) {
|
|
1631
|
-
|
|
1664
|
+
_context20.next = 15;
|
|
1632
1665
|
break;
|
|
1633
1666
|
}
|
|
1634
1667
|
|
|
1635
1668
|
throw Error("Invalid method: " + method);
|
|
1636
1669
|
|
|
1637
1670
|
case 15:
|
|
1638
|
-
|
|
1671
|
+
_context20.next = 17;
|
|
1639
1672
|
return this[method](message.args);
|
|
1640
1673
|
|
|
1641
1674
|
case 17:
|
|
1642
|
-
methodResults =
|
|
1675
|
+
methodResults = _context20.sent;
|
|
1643
1676
|
|
|
1644
1677
|
case 18:
|
|
1645
1678
|
Respond(this.utils.MakeClonable({
|
|
@@ -1647,17 +1680,17 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1647
1680
|
requestId: message.requestId,
|
|
1648
1681
|
response: methodResults
|
|
1649
1682
|
}));
|
|
1650
|
-
|
|
1683
|
+
_context20.next = 27;
|
|
1651
1684
|
break;
|
|
1652
1685
|
|
|
1653
1686
|
case 21:
|
|
1654
|
-
|
|
1655
|
-
|
|
1687
|
+
_context20.prev = 21;
|
|
1688
|
+
_context20.t0 = _context20["catch"](3);
|
|
1656
1689
|
// eslint-disable-next-line no-console
|
|
1657
|
-
this.Log("Frame Message Error:\n Method: ".concat(message.calledMethod, "\n Arguments: ").concat(JSON.stringify(message.args, null, 2), "\n Error: ").concat(_typeof(
|
|
1690
|
+
this.Log("Frame Message Error:\n Method: ".concat(message.calledMethod, "\n Arguments: ").concat(JSON.stringify(message.args, null, 2), "\n Error: ").concat(_typeof(_context20.t0) === "object" ? JSON.stringify(_context20.t0, null, 2) : _context20.t0), true); // eslint-disable-next-line no-console
|
|
1658
1691
|
|
|
1659
|
-
console.error(
|
|
1660
|
-
responseError =
|
|
1692
|
+
console.error(_context20.t0);
|
|
1693
|
+
responseError = _context20.t0 instanceof Error ? _context20.t0.message : _context20.t0;
|
|
1661
1694
|
Respond(this.utils.MakeClonable({
|
|
1662
1695
|
type: "ElvFrameResponse",
|
|
1663
1696
|
requestId: message.requestId,
|
|
@@ -1666,13 +1699,13 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1666
1699
|
|
|
1667
1700
|
case 27:
|
|
1668
1701
|
case "end":
|
|
1669
|
-
return
|
|
1702
|
+
return _context20.stop();
|
|
1670
1703
|
}
|
|
1671
1704
|
}
|
|
1672
|
-
},
|
|
1705
|
+
}, _callee20, this, [[3, 21]]);
|
|
1673
1706
|
}));
|
|
1674
1707
|
|
|
1675
|
-
function CallFromFrameMessage(
|
|
1708
|
+
function CallFromFrameMessage(_x16, _x17) {
|
|
1676
1709
|
return _CallFromFrameMessage.apply(this, arguments);
|
|
1677
1710
|
}
|
|
1678
1711
|
|
|
@@ -1681,15 +1714,15 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1681
1714
|
}], [{
|
|
1682
1715
|
key: "Configuration",
|
|
1683
1716
|
value: function () {
|
|
1684
|
-
var _Configuration = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1685
|
-
var configUrl,
|
|
1717
|
+
var _Configuration = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref22) {
|
|
1718
|
+
var configUrl, _ref22$kmsUrls, kmsUrls, region, uri, fabricInfo, filterHTTPS, fabricURIs, ethereumURIs, authServiceURIs, fabricVersion;
|
|
1686
1719
|
|
|
1687
|
-
return _regeneratorRuntime.wrap(function
|
|
1720
|
+
return _regeneratorRuntime.wrap(function _callee21$(_context21) {
|
|
1688
1721
|
while (1) {
|
|
1689
|
-
switch (
|
|
1722
|
+
switch (_context21.prev = _context21.next) {
|
|
1690
1723
|
case 0:
|
|
1691
|
-
configUrl =
|
|
1692
|
-
|
|
1724
|
+
configUrl = _ref22.configUrl, _ref22$kmsUrls = _ref22.kmsUrls, kmsUrls = _ref22$kmsUrls === void 0 ? [] : _ref22$kmsUrls, region = _ref22.region;
|
|
1725
|
+
_context21.prev = 1;
|
|
1693
1726
|
uri = new URI(configUrl);
|
|
1694
1727
|
uri.pathname("/config");
|
|
1695
1728
|
|
|
@@ -1697,11 +1730,11 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1697
1730
|
uri.addSearch("elvgeo", region);
|
|
1698
1731
|
}
|
|
1699
1732
|
|
|
1700
|
-
|
|
1733
|
+
_context21.next = 7;
|
|
1701
1734
|
return Utils.ResponseToJson(HttpClient.Fetch(uri.toString()));
|
|
1702
1735
|
|
|
1703
1736
|
case 7:
|
|
1704
|
-
fabricInfo =
|
|
1737
|
+
fabricInfo = _context21.sent;
|
|
1705
1738
|
|
|
1706
1739
|
// If any HTTPS urls present, throw away HTTP urls so only HTTPS will be used
|
|
1707
1740
|
filterHTTPS = function filterHTTPS(uri) {
|
|
@@ -1727,7 +1760,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1727
1760
|
}
|
|
1728
1761
|
|
|
1729
1762
|
fabricVersion = Math.max.apply(Math, _toConsumableArray(fabricInfo.network.api_versions || [2]));
|
|
1730
|
-
return
|
|
1763
|
+
return _context21.abrupt("return", {
|
|
1731
1764
|
nodeId: fabricInfo.node_id,
|
|
1732
1765
|
contentSpaceId: fabricInfo.qspace.id,
|
|
1733
1766
|
networkId: (fabricInfo.qspace.ethereum || {}).network_id,
|
|
@@ -1740,23 +1773,23 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1740
1773
|
});
|
|
1741
1774
|
|
|
1742
1775
|
case 19:
|
|
1743
|
-
|
|
1744
|
-
|
|
1776
|
+
_context21.prev = 19;
|
|
1777
|
+
_context21.t0 = _context21["catch"](1);
|
|
1745
1778
|
// eslint-disable-next-line no-console
|
|
1746
1779
|
console.error("Error retrieving fabric configuration:"); // eslint-disable-next-line no-console
|
|
1747
1780
|
|
|
1748
|
-
console.error(
|
|
1749
|
-
throw
|
|
1781
|
+
console.error(_context21.t0);
|
|
1782
|
+
throw _context21.t0;
|
|
1750
1783
|
|
|
1751
1784
|
case 24:
|
|
1752
1785
|
case "end":
|
|
1753
|
-
return
|
|
1786
|
+
return _context21.stop();
|
|
1754
1787
|
}
|
|
1755
1788
|
}
|
|
1756
|
-
},
|
|
1789
|
+
}, _callee21, null, [[1, 19]]);
|
|
1757
1790
|
}));
|
|
1758
1791
|
|
|
1759
|
-
function Configuration(
|
|
1792
|
+
function Configuration(_x18) {
|
|
1760
1793
|
return _Configuration.apply(this, arguments);
|
|
1761
1794
|
}
|
|
1762
1795
|
|
|
@@ -1781,25 +1814,25 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1781
1814
|
}, {
|
|
1782
1815
|
key: "FromNetworkName",
|
|
1783
1816
|
value: function () {
|
|
1784
|
-
var _FromNetworkName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1785
|
-
var networkName, region, trustAuthorityId, staticToken,
|
|
1817
|
+
var _FromNetworkName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref23) {
|
|
1818
|
+
var networkName, region, trustAuthorityId, staticToken, _ref23$ethereumContra, ethereumContractTimeout, _ref23$noCache, noCache, _ref23$noAuth, noAuth, assumeV3, configUrl;
|
|
1786
1819
|
|
|
1787
|
-
return _regeneratorRuntime.wrap(function
|
|
1820
|
+
return _regeneratorRuntime.wrap(function _callee22$(_context22) {
|
|
1788
1821
|
while (1) {
|
|
1789
|
-
switch (
|
|
1822
|
+
switch (_context22.prev = _context22.next) {
|
|
1790
1823
|
case 0:
|
|
1791
|
-
networkName =
|
|
1824
|
+
networkName = _ref23.networkName, region = _ref23.region, trustAuthorityId = _ref23.trustAuthorityId, staticToken = _ref23.staticToken, _ref23$ethereumContra = _ref23.ethereumContractTimeout, ethereumContractTimeout = _ref23$ethereumContra === void 0 ? 10 : _ref23$ethereumContra, _ref23$noCache = _ref23.noCache, noCache = _ref23$noCache === void 0 ? false : _ref23$noCache, _ref23$noAuth = _ref23.noAuth, noAuth = _ref23$noAuth === void 0 ? false : _ref23$noAuth, assumeV3 = _ref23.assumeV3;
|
|
1792
1825
|
configUrl = networks[networkName];
|
|
1793
1826
|
|
|
1794
1827
|
if (configUrl) {
|
|
1795
|
-
|
|
1828
|
+
_context22.next = 4;
|
|
1796
1829
|
break;
|
|
1797
1830
|
}
|
|
1798
1831
|
|
|
1799
1832
|
throw Error("Invalid network name: " + networkName);
|
|
1800
1833
|
|
|
1801
1834
|
case 4:
|
|
1802
|
-
|
|
1835
|
+
_context22.next = 6;
|
|
1803
1836
|
return this.FromConfigurationUrl({
|
|
1804
1837
|
configUrl: configUrl,
|
|
1805
1838
|
region: region,
|
|
@@ -1812,17 +1845,17 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1812
1845
|
});
|
|
1813
1846
|
|
|
1814
1847
|
case 6:
|
|
1815
|
-
return
|
|
1848
|
+
return _context22.abrupt("return", _context22.sent);
|
|
1816
1849
|
|
|
1817
1850
|
case 7:
|
|
1818
1851
|
case "end":
|
|
1819
|
-
return
|
|
1852
|
+
return _context22.stop();
|
|
1820
1853
|
}
|
|
1821
1854
|
}
|
|
1822
|
-
},
|
|
1855
|
+
}, _callee22, this);
|
|
1823
1856
|
}));
|
|
1824
1857
|
|
|
1825
|
-
function FromNetworkName(
|
|
1858
|
+
function FromNetworkName(_x19) {
|
|
1826
1859
|
return _FromNetworkName.apply(this, arguments);
|
|
1827
1860
|
}
|
|
1828
1861
|
|
|
@@ -1847,22 +1880,22 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1847
1880
|
}, {
|
|
1848
1881
|
key: "FromConfigurationUrl",
|
|
1849
1882
|
value: function () {
|
|
1850
|
-
var _FromConfigurationUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1851
|
-
var configUrl, region, trustAuthorityId, staticToken,
|
|
1883
|
+
var _FromConfigurationUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref24) {
|
|
1884
|
+
var configUrl, region, trustAuthorityId, staticToken, _ref24$ethereumContra, ethereumContractTimeout, _ref24$noCache, noCache, _ref24$noAuth, noAuth, _ref24$assumeV, assumeV3, _yield$ElvClient$Conf3, contentSpaceId, networkId, networkName, fabricURIs, ethereumURIs, authServiceURIs, fabricVersion, client;
|
|
1852
1885
|
|
|
1853
|
-
return _regeneratorRuntime.wrap(function
|
|
1886
|
+
return _regeneratorRuntime.wrap(function _callee23$(_context23) {
|
|
1854
1887
|
while (1) {
|
|
1855
|
-
switch (
|
|
1888
|
+
switch (_context23.prev = _context23.next) {
|
|
1856
1889
|
case 0:
|
|
1857
|
-
configUrl =
|
|
1858
|
-
|
|
1890
|
+
configUrl = _ref24.configUrl, region = _ref24.region, trustAuthorityId = _ref24.trustAuthorityId, staticToken = _ref24.staticToken, _ref24$ethereumContra = _ref24.ethereumContractTimeout, ethereumContractTimeout = _ref24$ethereumContra === void 0 ? 10 : _ref24$ethereumContra, _ref24$noCache = _ref24.noCache, noCache = _ref24$noCache === void 0 ? false : _ref24$noCache, _ref24$noAuth = _ref24.noAuth, noAuth = _ref24$noAuth === void 0 ? false : _ref24$noAuth, _ref24$assumeV = _ref24.assumeV3, assumeV3 = _ref24$assumeV === void 0 ? false : _ref24$assumeV;
|
|
1891
|
+
_context23.next = 3;
|
|
1859
1892
|
return ElvClient.Configuration({
|
|
1860
1893
|
configUrl: configUrl,
|
|
1861
1894
|
region: region
|
|
1862
1895
|
});
|
|
1863
1896
|
|
|
1864
1897
|
case 3:
|
|
1865
|
-
_yield$ElvClient$Conf3 =
|
|
1898
|
+
_yield$ElvClient$Conf3 = _context23.sent;
|
|
1866
1899
|
contentSpaceId = _yield$ElvClient$Conf3.contentSpaceId;
|
|
1867
1900
|
networkId = _yield$ElvClient$Conf3.networkId;
|
|
1868
1901
|
networkName = _yield$ElvClient$Conf3.networkName;
|
|
@@ -1886,17 +1919,17 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1886
1919
|
assumeV3: assumeV3
|
|
1887
1920
|
});
|
|
1888
1921
|
client.configUrl = configUrl;
|
|
1889
|
-
return
|
|
1922
|
+
return _context23.abrupt("return", client);
|
|
1890
1923
|
|
|
1891
1924
|
case 14:
|
|
1892
1925
|
case "end":
|
|
1893
|
-
return
|
|
1926
|
+
return _context23.stop();
|
|
1894
1927
|
}
|
|
1895
1928
|
}
|
|
1896
|
-
},
|
|
1929
|
+
}, _callee23);
|
|
1897
1930
|
}));
|
|
1898
1931
|
|
|
1899
|
-
function FromConfigurationUrl(
|
|
1932
|
+
function FromConfigurationUrl(_x20) {
|
|
1900
1933
|
return _FromConfigurationUrl.apply(this, arguments);
|
|
1901
1934
|
}
|
|
1902
1935
|
|