@eluvio/elv-client-js 4.0.109 → 4.0.111
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 +14 -15
- package/dist/ElvClient-node-min.js +13 -14
- package/dist/ElvFrameClient-min.js +10 -10
- package/dist/ElvPermissionsClient-min.js +9 -9
- package/dist/ElvWalletClient-min.js +14 -15
- package/dist/ElvWalletClient-node-min.js +13 -14
- package/dist/src/AuthorizationClient.js +12 -9
- package/dist/src/ContentObjectAudit.js +3 -3
- package/dist/src/ContentObjectVerification.js +3 -3
- package/dist/src/Crypto.js +2 -2
- package/dist/src/ElvClient.js +220 -192
- package/dist/src/ElvWallet.js +5 -7
- package/dist/src/EthClient.js +9 -8
- package/dist/src/FrameClient.js +9 -8
- package/dist/src/HttpClient.js +2 -1
- package/dist/src/Id.js +2 -1
- package/dist/src/PermissionsClient.js +19 -31
- package/dist/src/RemoteSigner.js +8 -6
- package/dist/src/UserProfileClient.js +20 -35
- package/dist/src/Utils.js +3 -2
- package/dist/src/client/ABRPublishing.js +2 -2
- package/dist/src/client/AccessGroups.js +2 -2
- package/dist/src/client/ContentAccess.js +3 -2
- package/dist/src/client/ContentManagement.js +3 -3
- package/dist/src/client/Contracts.js +2 -2
- package/dist/src/client/Files.js +2 -2
- package/dist/src/client/LiveConf.js +5 -3
- package/dist/src/client/LiveStream.js +2 -0
- package/dist/src/client/NFT.js +2 -2
- package/dist/src/walletClient/ClientMethods.js +2 -2
- package/dist/src/walletClient/Profile.js +2 -2
- package/dist/src/walletClient/Utils.js +2 -2
- package/dist/src/walletClient/index.js +14 -17
- package/package.json +1 -1
- package/src/AuthorizationClient.js +1 -1
- package/src/ElvClient.js +11 -5
package/dist/src/ElvClient.js
CHANGED
|
@@ -5,8 +5,8 @@ var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
|
5
5
|
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
6
6
|
var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
|
|
7
7
|
var _createClass = require("@babel/runtime/helpers/createClass");
|
|
8
|
-
function ownKeys(
|
|
9
|
-
function _objectSpread(
|
|
8
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
10
|
if (typeof globalThis.Buffer === "undefined") {
|
|
11
11
|
globalThis.Buffer = require("buffer/").Buffer;
|
|
12
12
|
}
|
|
@@ -142,7 +142,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
142
142
|
* @param {string=} clientIP - IP address to use in determining the region to use
|
|
143
143
|
* @return {Promise<Object>} - Object containing content space ID and fabric and ethereum URLs
|
|
144
144
|
*/
|
|
145
|
-
|
|
145
|
+
_createClass(ElvClient, [{
|
|
146
146
|
key: "Log",
|
|
147
147
|
value: function Log(message) {
|
|
148
148
|
var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -275,19 +275,23 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
275
275
|
debug: this.debug,
|
|
276
276
|
timeout: this.ethereumContractTimeout
|
|
277
277
|
});
|
|
278
|
-
if (
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
mnemonic: wallet.GenerateMnemonic()
|
|
282
|
-
});
|
|
283
|
-
this.SetSigner({
|
|
284
|
-
signer: signer,
|
|
285
|
-
reset: false
|
|
286
|
-
});
|
|
287
|
-
this.SetStaticToken({
|
|
288
|
-
token: staticToken
|
|
289
|
-
});
|
|
278
|
+
if (this.signer) {
|
|
279
|
+
_context2.next = 21;
|
|
280
|
+
break;
|
|
290
281
|
}
|
|
282
|
+
wallet = this.GenerateWallet();
|
|
283
|
+
signer = wallet.AddAccountFromMnemonic({
|
|
284
|
+
mnemonic: wallet.GenerateMnemonic()
|
|
285
|
+
});
|
|
286
|
+
this.SetSigner({
|
|
287
|
+
signer: signer,
|
|
288
|
+
reset: false
|
|
289
|
+
});
|
|
290
|
+
_context2.next = 21;
|
|
291
|
+
return this.SetStaticToken({
|
|
292
|
+
token: staticToken
|
|
293
|
+
});
|
|
294
|
+
case 21:
|
|
291
295
|
this.authClient = new AuthorizationClient({
|
|
292
296
|
client: this,
|
|
293
297
|
contentSpaceId: this.contentSpaceId,
|
|
@@ -304,7 +308,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
304
308
|
// Initialize crypto wasm
|
|
305
309
|
this.Crypto = Crypto;
|
|
306
310
|
this.Crypto.ElvCrypto();
|
|
307
|
-
case
|
|
311
|
+
case 25:
|
|
308
312
|
case "end":
|
|
309
313
|
return _context2.stop();
|
|
310
314
|
}
|
|
@@ -341,7 +345,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
341
345
|
*/
|
|
342
346
|
}, {
|
|
343
347
|
key: "UseRegion",
|
|
344
|
-
value:
|
|
348
|
+
value: function () {
|
|
345
349
|
var _UseRegion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref4) {
|
|
346
350
|
var region, _yield$ElvClient$Conf, fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs;
|
|
347
351
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
@@ -401,10 +405,9 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
401
405
|
*
|
|
402
406
|
* @return {Promise<Object>} - An object containing the updated fabric and ethereum URLs in order of preference
|
|
403
407
|
*/
|
|
404
|
-
)
|
|
405
408
|
}, {
|
|
406
409
|
key: "ResetRegion",
|
|
407
|
-
value:
|
|
410
|
+
value: function () {
|
|
408
411
|
var _ResetRegion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
409
412
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
410
413
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -444,10 +447,9 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
444
447
|
*
|
|
445
448
|
* @return {Promise<string>} - The node ID reported by the fabric
|
|
446
449
|
*/
|
|
447
|
-
)
|
|
448
450
|
}, {
|
|
449
451
|
key: "NodeId",
|
|
450
|
-
value:
|
|
452
|
+
value: function () {
|
|
451
453
|
var _NodeId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref5) {
|
|
452
454
|
var region, _yield$ElvClient$Conf2, nodeId;
|
|
453
455
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
@@ -481,7 +483,6 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
481
483
|
*
|
|
482
484
|
* @return {Promise<Object>} - An object containing the lists of fabric, ethereum, auth service, and search urls in use by the client
|
|
483
485
|
*/
|
|
484
|
-
)
|
|
485
486
|
}, {
|
|
486
487
|
key: "Nodes",
|
|
487
488
|
value: function Nodes() {
|
|
@@ -553,7 +554,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
553
554
|
*/
|
|
554
555
|
}, {
|
|
555
556
|
key: "SpaceNodes",
|
|
556
|
-
value:
|
|
557
|
+
value: function () {
|
|
557
558
|
var _SpaceNodes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
558
559
|
var _this = this;
|
|
559
560
|
var _ref7,
|
|
@@ -567,12 +568,14 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
567
568
|
while (1) switch (_context6.prev = _context6.next) {
|
|
568
569
|
case 0:
|
|
569
570
|
_ref7 = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {}, matchEndpoint = _ref7.matchEndpoint, matchNodeId = _ref7.matchNodeId;
|
|
570
|
-
|
|
571
|
+
_context6.next = 3;
|
|
572
|
+
return this.SetStaticToken();
|
|
573
|
+
case 3:
|
|
571
574
|
if (!matchEndpoint) {
|
|
572
|
-
_context6.next =
|
|
575
|
+
_context6.next = 13;
|
|
573
576
|
break;
|
|
574
577
|
}
|
|
575
|
-
_context6.next =
|
|
578
|
+
_context6.next = 6;
|
|
576
579
|
return this.utils.ResponseToJson(this.HttpClient.Request({
|
|
577
580
|
path: UrlJoin("nodes"),
|
|
578
581
|
method: "GET",
|
|
@@ -580,15 +583,15 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
580
583
|
Authorization: "Bearer ".concat(this.staticToken)
|
|
581
584
|
}
|
|
582
585
|
}));
|
|
583
|
-
case
|
|
586
|
+
case 6:
|
|
584
587
|
_yield$this$utils$Res = _context6.sent;
|
|
585
588
|
nodes = _yield$this$utils$Res.nodes;
|
|
586
589
|
if (!(!nodes || !Array.isArray(nodes) || nodes.length === 0)) {
|
|
587
|
-
_context6.next =
|
|
590
|
+
_context6.next = 10;
|
|
588
591
|
break;
|
|
589
592
|
}
|
|
590
593
|
return _context6.abrupt("return", []);
|
|
591
|
-
case
|
|
594
|
+
case 10:
|
|
592
595
|
return _context6.abrupt("return", nodes.filter(function (node) {
|
|
593
596
|
var match = false;
|
|
594
597
|
if (node.services && node.services.fabric_api && node.services.fabric_api.urls) {
|
|
@@ -605,13 +608,15 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
605
608
|
_this.ClearStaticToken();
|
|
606
609
|
return match;
|
|
607
610
|
}));
|
|
608
|
-
case
|
|
611
|
+
case 13:
|
|
609
612
|
if (!matchNodeId) {
|
|
610
|
-
_context6.next =
|
|
613
|
+
_context6.next = 21;
|
|
611
614
|
break;
|
|
612
615
|
}
|
|
613
|
-
this.SetStaticToken();
|
|
614
616
|
_context6.next = 16;
|
|
617
|
+
return this.SetStaticToken();
|
|
618
|
+
case 16:
|
|
619
|
+
_context6.next = 18;
|
|
615
620
|
return this.utils.ResponseToJson(this.HttpClient.Request({
|
|
616
621
|
path: UrlJoin("nodes", matchNodeId),
|
|
617
622
|
method: "GET",
|
|
@@ -619,11 +624,11 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
619
624
|
Authorization: "Bearer ".concat(this.staticToken)
|
|
620
625
|
}
|
|
621
626
|
}));
|
|
622
|
-
case
|
|
627
|
+
case 18:
|
|
623
628
|
node = _context6.sent;
|
|
624
629
|
this.ClearStaticToken();
|
|
625
630
|
return _context6.abrupt("return", [node]);
|
|
626
|
-
case
|
|
631
|
+
case 21:
|
|
627
632
|
case "end":
|
|
628
633
|
return _context6.stop();
|
|
629
634
|
}
|
|
@@ -640,7 +645,6 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
640
645
|
* @methodGroup Nodes
|
|
641
646
|
* @returns {Object} - The name, ID and configuration URL of the network
|
|
642
647
|
*/
|
|
643
|
-
)
|
|
644
648
|
}, {
|
|
645
649
|
key: "NetworkInfo",
|
|
646
650
|
value: function NetworkInfo() {
|
|
@@ -738,7 +742,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
738
742
|
*/
|
|
739
743
|
}, {
|
|
740
744
|
key: "SetRemoteSigner",
|
|
741
|
-
value:
|
|
745
|
+
value: function () {
|
|
742
746
|
var _SetRemoteSigner = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref11) {
|
|
743
747
|
var idToken, authToken, tenantId, extraData, signerURIs, unsignedPublicAuth, signer;
|
|
744
748
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
@@ -793,10 +797,9 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
793
797
|
* @namedParams
|
|
794
798
|
* @param {object} provider - The web3 provider object
|
|
795
799
|
*/
|
|
796
|
-
)
|
|
797
800
|
}, {
|
|
798
801
|
key: "SetSignerFromWeb3Provider",
|
|
799
|
-
value:
|
|
802
|
+
value: function () {
|
|
800
803
|
var _SetSignerFromWeb3Provider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref12) {
|
|
801
804
|
var provider, ethProvider;
|
|
802
805
|
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
@@ -839,10 +842,9 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
839
842
|
*
|
|
840
843
|
* @return {string} - The address of the user
|
|
841
844
|
*/
|
|
842
|
-
)
|
|
843
845
|
}, {
|
|
844
846
|
key: "CreateAccount",
|
|
845
|
-
value:
|
|
847
|
+
value: function () {
|
|
846
848
|
var _CreateAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref13) {
|
|
847
849
|
var tenantId, fundingToken, _ref13$funds, funds, groupToken, wallet, signer;
|
|
848
850
|
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
@@ -917,10 +919,9 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
917
919
|
PAYLOAD 85b json-compressed
|
|
918
920
|
json 79b {"adr":"VVf4DQU357tDnZGYQeDrntRJ5rs=","spc":"ispc3ANoVSzNA3P6t7abLR69ho5YPPZU"}
|
|
919
921
|
*/
|
|
920
|
-
)
|
|
921
922
|
}, {
|
|
922
923
|
key: "PersonalSign",
|
|
923
|
-
value:
|
|
924
|
+
value: function () {
|
|
924
925
|
var _PersonalSign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref14) {
|
|
925
926
|
var _this2 = this;
|
|
926
927
|
var message, addEthereumPrefix, Sign;
|
|
@@ -929,13 +930,32 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
929
930
|
case 0:
|
|
930
931
|
message = _ref14.message, addEthereumPrefix = _ref14.addEthereumPrefix, Sign = _ref14.Sign;
|
|
931
932
|
if (!Sign) {
|
|
933
|
+
// Same as authClient.Sign, but authClient may not yet be initialized
|
|
932
934
|
Sign = /*#__PURE__*/function () {
|
|
933
935
|
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(message) {
|
|
934
936
|
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
935
937
|
while (1) switch (_context10.prev = _context10.next) {
|
|
936
938
|
case 0:
|
|
937
|
-
|
|
938
|
-
|
|
939
|
+
_context10.t0 = Ethers.utils;
|
|
940
|
+
if (!_this2.signer.signDigest) {
|
|
941
|
+
_context10.next = 7;
|
|
942
|
+
break;
|
|
943
|
+
}
|
|
944
|
+
_context10.next = 4;
|
|
945
|
+
return _this2.signer.signDigest(message);
|
|
946
|
+
case 4:
|
|
947
|
+
_context10.t1 = _context10.sent;
|
|
948
|
+
_context10.next = 10;
|
|
949
|
+
break;
|
|
950
|
+
case 7:
|
|
951
|
+
_context10.next = 9;
|
|
952
|
+
return _this2.signer._signingKey().signDigest(message);
|
|
953
|
+
case 9:
|
|
954
|
+
_context10.t1 = _context10.sent;
|
|
955
|
+
case 10:
|
|
956
|
+
_context10.t2 = _context10.t1;
|
|
957
|
+
return _context10.abrupt("return", _context10.t0.joinSignature.call(_context10.t0, _context10.t2));
|
|
958
|
+
case 12:
|
|
939
959
|
case "end":
|
|
940
960
|
return _context10.stop();
|
|
941
961
|
}
|
|
@@ -975,10 +995,9 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
975
995
|
* @param {function=} Sign - If specified, this function will be used to produce the signature instead of the client's current signer
|
|
976
996
|
* @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)
|
|
977
997
|
*/
|
|
978
|
-
)
|
|
979
998
|
}, {
|
|
980
999
|
key: "CreateFabricToken",
|
|
981
|
-
value:
|
|
1000
|
+
value: function () {
|
|
982
1001
|
var _CreateFabricToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
|
|
983
1002
|
var _ref16,
|
|
984
1003
|
_ref16$duration,
|
|
@@ -1060,10 +1079,9 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1060
1079
|
* enabling the user of this token to download encrypted content from the specified object
|
|
1061
1080
|
* @param {Object=} context - Additional JSON context
|
|
1062
1081
|
*/
|
|
1063
|
-
)
|
|
1064
1082
|
}, {
|
|
1065
1083
|
key: "CreateSignedToken",
|
|
1066
|
-
value:
|
|
1084
|
+
value: function () {
|
|
1067
1085
|
var _CreateSignedToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref17) {
|
|
1068
1086
|
var libraryId, objectId, versionHash, policyId, subject, _ref17$grantType, grantType, _ref17$allowDecryptio, allowDecryption, duration, _ref17$context, context, token, cap, compressedToken, signature;
|
|
1069
1087
|
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
@@ -1176,10 +1194,9 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1176
1194
|
* @namedParams
|
|
1177
1195
|
* @param {string} messasge - A JSON object representing the message to sign
|
|
1178
1196
|
*/
|
|
1179
|
-
)
|
|
1180
1197
|
}, {
|
|
1181
1198
|
key: "CreateSignedMessageJSON",
|
|
1182
|
-
value:
|
|
1199
|
+
value: function () {
|
|
1183
1200
|
var _CreateSignedMessageJSON = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref18) {
|
|
1184
1201
|
var message, type, msg, signature;
|
|
1185
1202
|
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
@@ -1216,10 +1233,9 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1216
1233
|
* @param {string} signedMessage - a signed message as created by CreateSignedMessageJSON
|
|
1217
1234
|
* @returns {Promise<Object>} - The decoded message, signer address, signature and signature type
|
|
1218
1235
|
*/
|
|
1219
|
-
)
|
|
1220
1236
|
}, {
|
|
1221
1237
|
key: "DecodeSignedMessageJSON",
|
|
1222
|
-
value:
|
|
1238
|
+
value: function () {
|
|
1223
1239
|
var _DecodeSignedMessageJSON = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref19) {
|
|
1224
1240
|
var signedMessage, type, msgBytes, signature, msg, obj, prefixedMsgHash, signerAddr;
|
|
1225
1241
|
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
@@ -1262,7 +1278,6 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1262
1278
|
* @methodGroup Signers
|
|
1263
1279
|
* @returns {string} - The address of the current signer
|
|
1264
1280
|
*/
|
|
1265
|
-
)
|
|
1266
1281
|
}, {
|
|
1267
1282
|
key: "CurrentAccountAddress",
|
|
1268
1283
|
value: function CurrentAccountAddress() {
|
|
@@ -1278,7 +1293,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1278
1293
|
*/
|
|
1279
1294
|
}, {
|
|
1280
1295
|
key: "SetOauthToken",
|
|
1281
|
-
value:
|
|
1296
|
+
value: function () {
|
|
1282
1297
|
var _SetOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref20) {
|
|
1283
1298
|
var token, wallet, signer;
|
|
1284
1299
|
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
@@ -1314,10 +1329,9 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1314
1329
|
* @namedParams
|
|
1315
1330
|
* @param {string} token - The OAuth ID
|
|
1316
1331
|
*/
|
|
1317
|
-
)
|
|
1318
1332
|
}, {
|
|
1319
1333
|
key: "SetSignerFromOauthToken",
|
|
1320
|
-
value:
|
|
1334
|
+
value: function () {
|
|
1321
1335
|
var _SetSignerFromOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref21) {
|
|
1322
1336
|
var token, wallet, client, _yield$client$authCli, urls, path, httpClient, response, privateKey;
|
|
1323
1337
|
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
@@ -1419,20 +1433,38 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1419
1433
|
* @namedParams
|
|
1420
1434
|
* @param {string=} token - The static token to use. If not provided, the default static token will be set.
|
|
1421
1435
|
*/
|
|
1422
|
-
)
|
|
1423
1436
|
}, {
|
|
1424
1437
|
key: "SetStaticToken",
|
|
1425
|
-
value: function
|
|
1426
|
-
var
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1438
|
+
value: function () {
|
|
1439
|
+
var _SetStaticToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18() {
|
|
1440
|
+
var _this3 = this;
|
|
1441
|
+
var _ref22,
|
|
1442
|
+
token,
|
|
1443
|
+
_args18 = arguments;
|
|
1444
|
+
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
1445
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1446
|
+
case 0:
|
|
1447
|
+
_ref22 = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {}, token = _ref22.token;
|
|
1448
|
+
if (token) {
|
|
1449
|
+
this.staticToken = token;
|
|
1450
|
+
} else {
|
|
1451
|
+
this.CreateFabricToken({
|
|
1452
|
+
duration: 7 * 24 * 60 * 60 * 1000
|
|
1453
|
+
}).then(function (token) {
|
|
1454
|
+
return _this3.staticToken = token;
|
|
1455
|
+
});
|
|
1456
|
+
}
|
|
1457
|
+
case 2:
|
|
1458
|
+
case "end":
|
|
1459
|
+
return _context18.stop();
|
|
1460
|
+
}
|
|
1461
|
+
}, _callee18, this);
|
|
1462
|
+
}));
|
|
1463
|
+
function SetStaticToken() {
|
|
1464
|
+
return _SetStaticToken.apply(this, arguments);
|
|
1432
1465
|
}
|
|
1433
|
-
|
|
1434
|
-
}
|
|
1435
|
-
|
|
1466
|
+
return SetStaticToken;
|
|
1467
|
+
}()
|
|
1436
1468
|
/**
|
|
1437
1469
|
* Clear the set static token for the client
|
|
1438
1470
|
*/
|
|
@@ -1453,29 +1485,30 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1453
1485
|
*/
|
|
1454
1486
|
}, {
|
|
1455
1487
|
key: "SetPolicyAuthorization",
|
|
1456
|
-
value:
|
|
1457
|
-
var _SetPolicyAuthorization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1488
|
+
value: function () {
|
|
1489
|
+
var _SetPolicyAuthorization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(_ref23) {
|
|
1458
1490
|
var objectId;
|
|
1459
|
-
return _regeneratorRuntime.wrap(function
|
|
1460
|
-
while (1) switch (
|
|
1491
|
+
return _regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
1492
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1461
1493
|
case 0:
|
|
1462
1494
|
objectId = _ref23.objectId;
|
|
1463
|
-
|
|
1464
|
-
|
|
1495
|
+
_context19.t0 = this;
|
|
1496
|
+
_context19.next = 4;
|
|
1465
1497
|
return this.GenerateStateChannelToken({
|
|
1466
1498
|
objectId: objectId
|
|
1467
1499
|
});
|
|
1468
1500
|
case 4:
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
token:
|
|
1501
|
+
_context19.t1 = _context19.sent;
|
|
1502
|
+
_context19.t2 = {
|
|
1503
|
+
token: _context19.t1
|
|
1472
1504
|
};
|
|
1473
|
-
|
|
1474
|
-
|
|
1505
|
+
_context19.next = 8;
|
|
1506
|
+
return _context19.t0.SetStaticToken.call(_context19.t0, _context19.t2);
|
|
1507
|
+
case 8:
|
|
1475
1508
|
case "end":
|
|
1476
|
-
return
|
|
1509
|
+
return _context19.stop();
|
|
1477
1510
|
}
|
|
1478
|
-
},
|
|
1511
|
+
}, _callee19, this);
|
|
1479
1512
|
}));
|
|
1480
1513
|
function SetPolicyAuthorization(_x13) {
|
|
1481
1514
|
return _SetPolicyAuthorization.apply(this, arguments);
|
|
@@ -1488,25 +1521,24 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1488
1521
|
* @param {string} string - The string to sign
|
|
1489
1522
|
* @return {Promise<string>} - The signed string
|
|
1490
1523
|
*/
|
|
1491
|
-
)
|
|
1492
1524
|
}, {
|
|
1493
1525
|
key: "Sign",
|
|
1494
|
-
value:
|
|
1495
|
-
var _Sign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1526
|
+
value: function () {
|
|
1527
|
+
var _Sign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(string) {
|
|
1496
1528
|
var signature;
|
|
1497
|
-
return _regeneratorRuntime.wrap(function
|
|
1498
|
-
while (1) switch (
|
|
1529
|
+
return _regeneratorRuntime.wrap(function _callee20$(_context20) {
|
|
1530
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1499
1531
|
case 0:
|
|
1500
|
-
|
|
1532
|
+
_context20.next = 2;
|
|
1501
1533
|
return this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(string)));
|
|
1502
1534
|
case 2:
|
|
1503
|
-
signature =
|
|
1504
|
-
return
|
|
1535
|
+
signature = _context20.sent;
|
|
1536
|
+
return _context20.abrupt("return", this.utils.FormatSignature(signature));
|
|
1505
1537
|
case 4:
|
|
1506
1538
|
case "end":
|
|
1507
|
-
return
|
|
1539
|
+
return _context20.stop();
|
|
1508
1540
|
}
|
|
1509
|
-
},
|
|
1541
|
+
}, _callee20, this);
|
|
1510
1542
|
}));
|
|
1511
1543
|
function Sign(_x14) {
|
|
1512
1544
|
return _Sign.apply(this, arguments);
|
|
@@ -1522,32 +1554,31 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1522
1554
|
*
|
|
1523
1555
|
* @return {Promise<string>} - The encrypted message
|
|
1524
1556
|
*/
|
|
1525
|
-
)
|
|
1526
1557
|
}, {
|
|
1527
1558
|
key: "EncryptECIES",
|
|
1528
|
-
value:
|
|
1529
|
-
var _EncryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1559
|
+
value: function () {
|
|
1560
|
+
var _EncryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref24) {
|
|
1530
1561
|
var message, publicKey;
|
|
1531
|
-
return _regeneratorRuntime.wrap(function
|
|
1532
|
-
while (1) switch (
|
|
1562
|
+
return _regeneratorRuntime.wrap(function _callee21$(_context21) {
|
|
1563
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1533
1564
|
case 0:
|
|
1534
1565
|
message = _ref24.message, publicKey = _ref24.publicKey;
|
|
1535
1566
|
if (this.signer) {
|
|
1536
|
-
|
|
1567
|
+
_context21.next = 3;
|
|
1537
1568
|
break;
|
|
1538
1569
|
}
|
|
1539
1570
|
throw "Signer not set";
|
|
1540
1571
|
case 3:
|
|
1541
1572
|
ValidatePresence("message", message);
|
|
1542
|
-
|
|
1573
|
+
_context21.next = 6;
|
|
1543
1574
|
return this.Crypto.EncryptConk(message, publicKey || this.signer._signingKey().publicKey);
|
|
1544
1575
|
case 6:
|
|
1545
|
-
return
|
|
1576
|
+
return _context21.abrupt("return", _context21.sent);
|
|
1546
1577
|
case 7:
|
|
1547
1578
|
case "end":
|
|
1548
|
-
return
|
|
1579
|
+
return _context21.stop();
|
|
1549
1580
|
}
|
|
1550
|
-
},
|
|
1581
|
+
}, _callee21, this);
|
|
1551
1582
|
}));
|
|
1552
1583
|
function EncryptECIES(_x15) {
|
|
1553
1584
|
return _EncryptECIES.apply(this, arguments);
|
|
@@ -1562,32 +1593,31 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1562
1593
|
*
|
|
1563
1594
|
* @return {Promise<string | Object>} - The decrypted string or object
|
|
1564
1595
|
*/
|
|
1565
|
-
)
|
|
1566
1596
|
}, {
|
|
1567
1597
|
key: "DecryptECIES",
|
|
1568
|
-
value:
|
|
1569
|
-
var _DecryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1598
|
+
value: function () {
|
|
1599
|
+
var _DecryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref25) {
|
|
1570
1600
|
var message;
|
|
1571
|
-
return _regeneratorRuntime.wrap(function
|
|
1572
|
-
while (1) switch (
|
|
1601
|
+
return _regeneratorRuntime.wrap(function _callee22$(_context22) {
|
|
1602
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1573
1603
|
case 0:
|
|
1574
1604
|
message = _ref25.message;
|
|
1575
1605
|
if (this.signer) {
|
|
1576
|
-
|
|
1606
|
+
_context22.next = 3;
|
|
1577
1607
|
break;
|
|
1578
1608
|
}
|
|
1579
1609
|
throw "Signer not set";
|
|
1580
1610
|
case 3:
|
|
1581
1611
|
ValidatePresence("message", message);
|
|
1582
|
-
|
|
1612
|
+
_context22.next = 6;
|
|
1583
1613
|
return this.Crypto.DecryptCap(message, this.signer._signingKey().privateKey);
|
|
1584
1614
|
case 6:
|
|
1585
|
-
return
|
|
1615
|
+
return _context22.abrupt("return", _context22.sent);
|
|
1586
1616
|
case 7:
|
|
1587
1617
|
case "end":
|
|
1588
|
-
return
|
|
1618
|
+
return _context22.stop();
|
|
1589
1619
|
}
|
|
1590
|
-
},
|
|
1620
|
+
}, _callee22, this);
|
|
1591
1621
|
}));
|
|
1592
1622
|
function DecryptECIES(_x16) {
|
|
1593
1623
|
return _DecryptECIES.apply(this, arguments);
|
|
@@ -1605,42 +1635,41 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1605
1635
|
*
|
|
1606
1636
|
* @return {Promise<*>} - Response in the specified format
|
|
1607
1637
|
*/
|
|
1608
|
-
)
|
|
1609
1638
|
}, {
|
|
1610
1639
|
key: "Request",
|
|
1611
|
-
value:
|
|
1612
|
-
var _Request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1640
|
+
value: function () {
|
|
1641
|
+
var _Request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref26) {
|
|
1613
1642
|
var url, _ref26$format, format, _ref26$method, method, _ref26$headers, headers, body;
|
|
1614
|
-
return _regeneratorRuntime.wrap(function
|
|
1615
|
-
while (1) switch (
|
|
1643
|
+
return _regeneratorRuntime.wrap(function _callee23$(_context23) {
|
|
1644
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1616
1645
|
case 0:
|
|
1617
1646
|
url = _ref26.url, _ref26$format = _ref26.format, format = _ref26$format === void 0 ? "json" : _ref26$format, _ref26$method = _ref26.method, method = _ref26$method === void 0 ? "GET" : _ref26$method, _ref26$headers = _ref26.headers, headers = _ref26$headers === void 0 ? {} : _ref26$headers, body = _ref26.body;
|
|
1618
|
-
return
|
|
1647
|
+
return _context23.abrupt("return", this.utils.ResponseToFormat(format, HttpClient.Fetch(url, {
|
|
1619
1648
|
method: method,
|
|
1620
1649
|
headers: headers,
|
|
1621
1650
|
body: body
|
|
1622
1651
|
})));
|
|
1623
1652
|
case 2:
|
|
1624
1653
|
case "end":
|
|
1625
|
-
return
|
|
1654
|
+
return _context23.stop();
|
|
1626
1655
|
}
|
|
1627
|
-
},
|
|
1656
|
+
}, _callee23, this);
|
|
1628
1657
|
}));
|
|
1629
1658
|
function Request(_x17) {
|
|
1630
1659
|
return _Request.apply(this, arguments);
|
|
1631
1660
|
}
|
|
1632
1661
|
return Request;
|
|
1633
|
-
}()
|
|
1662
|
+
}()
|
|
1634
1663
|
}, {
|
|
1635
1664
|
key: "MakeAuthServiceRequest",
|
|
1636
1665
|
value: function () {
|
|
1637
|
-
var _MakeAuthServiceRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1666
|
+
var _MakeAuthServiceRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(_ref27) {
|
|
1638
1667
|
var kmsId, objectId, versionHash, _ref27$method, method, path, bodyType, _ref27$body, body, _ref27$queryParams, queryParams, headers;
|
|
1639
|
-
return _regeneratorRuntime.wrap(function
|
|
1640
|
-
while (1) switch (
|
|
1668
|
+
return _regeneratorRuntime.wrap(function _callee24$(_context24) {
|
|
1669
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1641
1670
|
case 0:
|
|
1642
1671
|
kmsId = _ref27.kmsId, objectId = _ref27.objectId, versionHash = _ref27.versionHash, _ref27$method = _ref27.method, method = _ref27$method === void 0 ? "GET" : _ref27$method, path = _ref27.path, bodyType = _ref27.bodyType, _ref27$body = _ref27.body, body = _ref27$body === void 0 ? {} : _ref27$body, _ref27$queryParams = _ref27.queryParams, queryParams = _ref27$queryParams === void 0 ? {} : _ref27$queryParams, headers = _ref27.headers;
|
|
1643
|
-
return
|
|
1672
|
+
return _context24.abrupt("return", this.authClient.MakeAuthServiceRequest({
|
|
1644
1673
|
kmsId: kmsId,
|
|
1645
1674
|
objectId: objectId,
|
|
1646
1675
|
versionHash: versionHash,
|
|
@@ -1653,9 +1682,9 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1653
1682
|
}));
|
|
1654
1683
|
case 2:
|
|
1655
1684
|
case "end":
|
|
1656
|
-
return
|
|
1685
|
+
return _context24.stop();
|
|
1657
1686
|
}
|
|
1658
|
-
},
|
|
1687
|
+
}, _callee24, this);
|
|
1659
1688
|
}));
|
|
1660
1689
|
function MakeAuthServiceRequest(_x18) {
|
|
1661
1690
|
return _MakeAuthServiceRequest.apply(this, arguments);
|
|
@@ -1667,10 +1696,10 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1667
1696
|
}, {
|
|
1668
1697
|
key: "FrameAllowedMethods",
|
|
1669
1698
|
value: function FrameAllowedMethods() {
|
|
1670
|
-
var
|
|
1699
|
+
var _this4 = this;
|
|
1671
1700
|
var forbiddenMethods = ["constructor", "AccessGroupMembershipMethod", "CallFromFrameMessage", "ClearSigner", "CreateAccount", "EnableMethodLogging", "FormatBlockNumbers", "FrameAllowedMethods", "FromConfigurationUrl", "GenerateWallet", "InitializeClients", "Log", "PersonalSign", "SetRemoteSigner", "SetSigner", "SetSignerFromWeb3Provider", "Sign", "ToggleLogging"];
|
|
1672
1701
|
return Object.getOwnPropertyNames(Object.getPrototypeOf(this)).filter(function (method) {
|
|
1673
|
-
return typeof
|
|
1702
|
+
return typeof _this4[method] === "function" && !forbiddenMethods.includes(method);
|
|
1674
1703
|
});
|
|
1675
1704
|
}
|
|
1676
1705
|
|
|
@@ -1678,21 +1707,21 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1678
1707
|
}, {
|
|
1679
1708
|
key: "CallFromFrameMessage",
|
|
1680
1709
|
value: function () {
|
|
1681
|
-
var _CallFromFrameMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1682
|
-
var
|
|
1710
|
+
var _CallFromFrameMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(message, Respond) {
|
|
1711
|
+
var _this5 = this;
|
|
1683
1712
|
var callback, method, methodResults, responseError;
|
|
1684
|
-
return _regeneratorRuntime.wrap(function
|
|
1685
|
-
while (1) switch (
|
|
1713
|
+
return _regeneratorRuntime.wrap(function _callee25$(_context25) {
|
|
1714
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1686
1715
|
case 0:
|
|
1687
1716
|
if (!(message.type !== "ElvFrameRequest")) {
|
|
1688
|
-
|
|
1717
|
+
_context25.next = 2;
|
|
1689
1718
|
break;
|
|
1690
1719
|
}
|
|
1691
|
-
return
|
|
1720
|
+
return _context25.abrupt("return");
|
|
1692
1721
|
case 2:
|
|
1693
1722
|
if (message.callbackId) {
|
|
1694
1723
|
callback = function callback(result) {
|
|
1695
|
-
Respond(
|
|
1724
|
+
Respond(_this5.utils.MakeClonable({
|
|
1696
1725
|
type: "ElvFrameResponse",
|
|
1697
1726
|
requestId: message.callbackId,
|
|
1698
1727
|
response: result
|
|
@@ -1700,75 +1729,75 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1700
1729
|
};
|
|
1701
1730
|
message.args.callback = callback;
|
|
1702
1731
|
}
|
|
1703
|
-
|
|
1732
|
+
_context25.prev = 3;
|
|
1704
1733
|
method = message.calledMethod;
|
|
1705
1734
|
if (!(message.module === "walletClient")) {
|
|
1706
|
-
|
|
1735
|
+
_context25.next = 15;
|
|
1707
1736
|
break;
|
|
1708
1737
|
}
|
|
1709
1738
|
if (this.walletClient) {
|
|
1710
|
-
|
|
1739
|
+
_context25.next = 8;
|
|
1711
1740
|
break;
|
|
1712
1741
|
}
|
|
1713
1742
|
throw Error("Wallet client not set");
|
|
1714
1743
|
case 8:
|
|
1715
1744
|
if (!this.walletClient.ForbiddenMethods().includes(method)) {
|
|
1716
|
-
|
|
1745
|
+
_context25.next = 10;
|
|
1717
1746
|
break;
|
|
1718
1747
|
}
|
|
1719
1748
|
throw Error("Invalid user profile method: " + method);
|
|
1720
1749
|
case 10:
|
|
1721
|
-
|
|
1750
|
+
_context25.next = 12;
|
|
1722
1751
|
return this.walletClient[method](message.args);
|
|
1723
1752
|
case 12:
|
|
1724
|
-
methodResults =
|
|
1725
|
-
|
|
1753
|
+
methodResults = _context25.sent;
|
|
1754
|
+
_context25.next = 28;
|
|
1726
1755
|
break;
|
|
1727
1756
|
case 15:
|
|
1728
1757
|
if (!(message.module === "userProfileClient")) {
|
|
1729
|
-
|
|
1758
|
+
_context25.next = 23;
|
|
1730
1759
|
break;
|
|
1731
1760
|
}
|
|
1732
1761
|
if (this.userProfileClient.FrameAllowedMethods().includes(method)) {
|
|
1733
|
-
|
|
1762
|
+
_context25.next = 18;
|
|
1734
1763
|
break;
|
|
1735
1764
|
}
|
|
1736
1765
|
throw Error("Invalid user profile method: " + method);
|
|
1737
1766
|
case 18:
|
|
1738
|
-
|
|
1767
|
+
_context25.next = 20;
|
|
1739
1768
|
return this.userProfileClient[method](message.args);
|
|
1740
1769
|
case 20:
|
|
1741
|
-
methodResults =
|
|
1742
|
-
|
|
1770
|
+
methodResults = _context25.sent;
|
|
1771
|
+
_context25.next = 28;
|
|
1743
1772
|
break;
|
|
1744
1773
|
case 23:
|
|
1745
1774
|
if (this.FrameAllowedMethods().includes(method)) {
|
|
1746
|
-
|
|
1775
|
+
_context25.next = 25;
|
|
1747
1776
|
break;
|
|
1748
1777
|
}
|
|
1749
1778
|
throw Error("Invalid method: " + method);
|
|
1750
1779
|
case 25:
|
|
1751
|
-
|
|
1780
|
+
_context25.next = 27;
|
|
1752
1781
|
return this[method](message.args);
|
|
1753
1782
|
case 27:
|
|
1754
|
-
methodResults =
|
|
1783
|
+
methodResults = _context25.sent;
|
|
1755
1784
|
case 28:
|
|
1756
1785
|
Respond(this.utils.MakeClonable({
|
|
1757
1786
|
type: "ElvFrameResponse",
|
|
1758
1787
|
requestId: message.requestId,
|
|
1759
1788
|
response: methodResults
|
|
1760
1789
|
}));
|
|
1761
|
-
|
|
1790
|
+
_context25.next = 37;
|
|
1762
1791
|
break;
|
|
1763
1792
|
case 31:
|
|
1764
|
-
|
|
1765
|
-
|
|
1793
|
+
_context25.prev = 31;
|
|
1794
|
+
_context25.t0 = _context25["catch"](3);
|
|
1766
1795
|
// eslint-disable-next-line no-console
|
|
1767
|
-
this.Log("Frame Message Error:\n Method: ".concat(message.calledMethod, "\n Arguments: ").concat(JSON.stringify(message.args, null, 2), "\n Error: ").concat(_typeof(
|
|
1796
|
+
this.Log("Frame Message Error:\n Method: ".concat(message.calledMethod, "\n Arguments: ").concat(JSON.stringify(message.args, null, 2), "\n Error: ").concat(_typeof(_context25.t0) === "object" ? JSON.stringify(_context25.t0, null, 2) : _context25.t0), true);
|
|
1768
1797
|
|
|
1769
1798
|
// eslint-disable-next-line no-console
|
|
1770
|
-
console.error(
|
|
1771
|
-
responseError =
|
|
1799
|
+
console.error(_context25.t0);
|
|
1800
|
+
responseError = _context25.t0 instanceof Error ? _context25.t0.message : _context25.t0;
|
|
1772
1801
|
Respond(this.utils.MakeClonable({
|
|
1773
1802
|
type: "ElvFrameResponse",
|
|
1774
1803
|
requestId: message.requestId,
|
|
@@ -1776,9 +1805,9 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1776
1805
|
}));
|
|
1777
1806
|
case 37:
|
|
1778
1807
|
case "end":
|
|
1779
|
-
return
|
|
1808
|
+
return _context25.stop();
|
|
1780
1809
|
}
|
|
1781
|
-
},
|
|
1810
|
+
}, _callee25, this, [[3, 31]]);
|
|
1782
1811
|
}));
|
|
1783
1812
|
function CallFromFrameMessage(_x19, _x20) {
|
|
1784
1813
|
return _CallFromFrameMessage.apply(this, arguments);
|
|
@@ -1787,14 +1816,14 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1787
1816
|
}()
|
|
1788
1817
|
}], [{
|
|
1789
1818
|
key: "Configuration",
|
|
1790
|
-
value:
|
|
1791
|
-
var _Configuration = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1819
|
+
value: function () {
|
|
1820
|
+
var _Configuration = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(_ref28) {
|
|
1792
1821
|
var configUrl, _ref28$kmsUrls, kmsUrls, region, clientIP, uri, fabricInfo, filterHTTPS, fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs, fabricVersion;
|
|
1793
|
-
return _regeneratorRuntime.wrap(function
|
|
1794
|
-
while (1) switch (
|
|
1822
|
+
return _regeneratorRuntime.wrap(function _callee26$(_context26) {
|
|
1823
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1795
1824
|
case 0:
|
|
1796
1825
|
configUrl = _ref28.configUrl, _ref28$kmsUrls = _ref28.kmsUrls, kmsUrls = _ref28$kmsUrls === void 0 ? [] : _ref28$kmsUrls, region = _ref28.region, clientIP = _ref28.clientIP;
|
|
1797
|
-
|
|
1826
|
+
_context26.prev = 1;
|
|
1798
1827
|
uri = new URI(configUrl);
|
|
1799
1828
|
uri.pathname("/config");
|
|
1800
1829
|
if (region) {
|
|
@@ -1803,10 +1832,10 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1803
1832
|
if (clientIP) {
|
|
1804
1833
|
uri.addSearch("client_ip", clientIP);
|
|
1805
1834
|
}
|
|
1806
|
-
|
|
1835
|
+
_context26.next = 8;
|
|
1807
1836
|
return Utils.ResponseToJson(HttpClient.Fetch(uri.toString()));
|
|
1808
1837
|
case 8:
|
|
1809
|
-
fabricInfo =
|
|
1838
|
+
fabricInfo = _context26.sent;
|
|
1810
1839
|
// If any HTTPS urls present, throw away HTTP urls so only HTTPS will be used
|
|
1811
1840
|
filterHTTPS = function filterHTTPS(uri) {
|
|
1812
1841
|
return uri.toLowerCase().startsWith("https");
|
|
@@ -1829,7 +1858,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1829
1858
|
}
|
|
1830
1859
|
searchURIs = fabricInfo.network.services.search || [];
|
|
1831
1860
|
fabricVersion = Math.max.apply(Math, _toConsumableArray(fabricInfo.network.api_versions || [2]));
|
|
1832
|
-
return
|
|
1861
|
+
return _context26.abrupt("return", {
|
|
1833
1862
|
nodeId: fabricInfo.node_id,
|
|
1834
1863
|
contentSpaceId: fabricInfo.qspace.id,
|
|
1835
1864
|
networkId: (fabricInfo.qspace.ethereum || {}).network_id,
|
|
@@ -1843,18 +1872,18 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1843
1872
|
fabricVersion: fabricVersion
|
|
1844
1873
|
});
|
|
1845
1874
|
case 23:
|
|
1846
|
-
|
|
1847
|
-
|
|
1875
|
+
_context26.prev = 23;
|
|
1876
|
+
_context26.t0 = _context26["catch"](1);
|
|
1848
1877
|
// eslint-disable-next-line no-console
|
|
1849
1878
|
console.error("Error retrieving fabric configuration:");
|
|
1850
1879
|
// eslint-disable-next-line no-console
|
|
1851
|
-
console.error(
|
|
1852
|
-
throw
|
|
1880
|
+
console.error(_context26.t0);
|
|
1881
|
+
throw _context26.t0;
|
|
1853
1882
|
case 28:
|
|
1854
1883
|
case "end":
|
|
1855
|
-
return
|
|
1884
|
+
return _context26.stop();
|
|
1856
1885
|
}
|
|
1857
|
-
},
|
|
1886
|
+
}, _callee26, null, [[1, 23]]);
|
|
1858
1887
|
}));
|
|
1859
1888
|
function Configuration(_x21) {
|
|
1860
1889
|
return _Configuration.apply(this, arguments);
|
|
@@ -1868,7 +1897,6 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1868
1897
|
*
|
|
1869
1898
|
* @return {Object} - An object using network names as keys and configuration URLs as values.
|
|
1870
1899
|
*/
|
|
1871
|
-
)
|
|
1872
1900
|
}, {
|
|
1873
1901
|
key: "Networks",
|
|
1874
1902
|
value: function Networks() {
|
|
@@ -1893,21 +1921,21 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1893
1921
|
*/
|
|
1894
1922
|
}, {
|
|
1895
1923
|
key: "FromNetworkName",
|
|
1896
|
-
value:
|
|
1897
|
-
var _FromNetworkName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1924
|
+
value: function () {
|
|
1925
|
+
var _FromNetworkName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27(_ref29) {
|
|
1898
1926
|
var networkName, region, clientIP, trustAuthorityId, staticToken, _ref29$ethereumContra, ethereumContractTimeout, _ref29$noCache, noCache, _ref29$noAuth, noAuth, assumeV3, configUrl;
|
|
1899
|
-
return _regeneratorRuntime.wrap(function
|
|
1900
|
-
while (1) switch (
|
|
1927
|
+
return _regeneratorRuntime.wrap(function _callee27$(_context27) {
|
|
1928
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1901
1929
|
case 0:
|
|
1902
1930
|
networkName = _ref29.networkName, region = _ref29.region, clientIP = _ref29.clientIP, trustAuthorityId = _ref29.trustAuthorityId, staticToken = _ref29.staticToken, _ref29$ethereumContra = _ref29.ethereumContractTimeout, ethereumContractTimeout = _ref29$ethereumContra === void 0 ? 10 : _ref29$ethereumContra, _ref29$noCache = _ref29.noCache, noCache = _ref29$noCache === void 0 ? false : _ref29$noCache, _ref29$noAuth = _ref29.noAuth, noAuth = _ref29$noAuth === void 0 ? false : _ref29$noAuth, assumeV3 = _ref29.assumeV3;
|
|
1903
1931
|
configUrl = networks[networkName];
|
|
1904
1932
|
if (configUrl) {
|
|
1905
|
-
|
|
1933
|
+
_context27.next = 4;
|
|
1906
1934
|
break;
|
|
1907
1935
|
}
|
|
1908
1936
|
throw Error("Invalid network name: " + networkName);
|
|
1909
1937
|
case 4:
|
|
1910
|
-
|
|
1938
|
+
_context27.next = 6;
|
|
1911
1939
|
return this.FromConfigurationUrl({
|
|
1912
1940
|
configUrl: configUrl,
|
|
1913
1941
|
region: region,
|
|
@@ -1920,12 +1948,12 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1920
1948
|
assumeV3: assumeV3
|
|
1921
1949
|
});
|
|
1922
1950
|
case 6:
|
|
1923
|
-
return
|
|
1951
|
+
return _context27.abrupt("return", _context27.sent);
|
|
1924
1952
|
case 7:
|
|
1925
1953
|
case "end":
|
|
1926
|
-
return
|
|
1954
|
+
return _context27.stop();
|
|
1927
1955
|
}
|
|
1928
|
-
},
|
|
1956
|
+
}, _callee27, this);
|
|
1929
1957
|
}));
|
|
1930
1958
|
function FromNetworkName(_x22) {
|
|
1931
1959
|
return _FromNetworkName.apply(this, arguments);
|
|
@@ -1948,24 +1976,23 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1948
1976
|
*
|
|
1949
1977
|
* @return {Promise<ElvClient>} - New ElvClient connected to the specified content fabric and blockchain
|
|
1950
1978
|
*/
|
|
1951
|
-
)
|
|
1952
1979
|
}, {
|
|
1953
1980
|
key: "FromConfigurationUrl",
|
|
1954
|
-
value:
|
|
1955
|
-
var _FromConfigurationUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1981
|
+
value: function () {
|
|
1982
|
+
var _FromConfigurationUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28(_ref30) {
|
|
1956
1983
|
var configUrl, region, clientIP, trustAuthorityId, staticToken, _ref30$ethereumContra, ethereumContractTimeout, _ref30$noCache, noCache, _ref30$noAuth, noAuth, _ref30$assumeV, assumeV3, _yield$ElvClient$Conf3, contentSpaceId, networkId, networkName, fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs, fabricVersion, client;
|
|
1957
|
-
return _regeneratorRuntime.wrap(function
|
|
1958
|
-
while (1) switch (
|
|
1984
|
+
return _regeneratorRuntime.wrap(function _callee28$(_context28) {
|
|
1985
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1959
1986
|
case 0:
|
|
1960
1987
|
configUrl = _ref30.configUrl, region = _ref30.region, clientIP = _ref30.clientIP, trustAuthorityId = _ref30.trustAuthorityId, staticToken = _ref30.staticToken, _ref30$ethereumContra = _ref30.ethereumContractTimeout, ethereumContractTimeout = _ref30$ethereumContra === void 0 ? 10 : _ref30$ethereumContra, _ref30$noCache = _ref30.noCache, noCache = _ref30$noCache === void 0 ? false : _ref30$noCache, _ref30$noAuth = _ref30.noAuth, noAuth = _ref30$noAuth === void 0 ? false : _ref30$noAuth, _ref30$assumeV = _ref30.assumeV3, assumeV3 = _ref30$assumeV === void 0 ? false : _ref30$assumeV;
|
|
1961
|
-
|
|
1988
|
+
_context28.next = 3;
|
|
1962
1989
|
return ElvClient.Configuration({
|
|
1963
1990
|
configUrl: configUrl,
|
|
1964
1991
|
clientIP: clientIP,
|
|
1965
1992
|
region: region
|
|
1966
1993
|
});
|
|
1967
1994
|
case 3:
|
|
1968
|
-
_yield$ElvClient$Conf3 =
|
|
1995
|
+
_yield$ElvClient$Conf3 = _context28.sent;
|
|
1969
1996
|
contentSpaceId = _yield$ElvClient$Conf3.contentSpaceId;
|
|
1970
1997
|
networkId = _yield$ElvClient$Conf3.networkId;
|
|
1971
1998
|
networkName = _yield$ElvClient$Conf3.networkName;
|
|
@@ -1995,19 +2022,20 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1995
2022
|
client.configUrl = configUrl;
|
|
1996
2023
|
client.region = region;
|
|
1997
2024
|
client.clientIP = clientIP;
|
|
1998
|
-
return
|
|
2025
|
+
return _context28.abrupt("return", client);
|
|
1999
2026
|
case 18:
|
|
2000
2027
|
case "end":
|
|
2001
|
-
return
|
|
2028
|
+
return _context28.stop();
|
|
2002
2029
|
}
|
|
2003
|
-
},
|
|
2030
|
+
}, _callee28);
|
|
2004
2031
|
}));
|
|
2005
2032
|
function FromConfigurationUrl(_x23) {
|
|
2006
2033
|
return _FromConfigurationUrl.apply(this, arguments);
|
|
2007
2034
|
}
|
|
2008
2035
|
return FromConfigurationUrl;
|
|
2009
|
-
}()
|
|
2036
|
+
}()
|
|
2010
2037
|
}]);
|
|
2038
|
+
return ElvClient;
|
|
2011
2039
|
}();
|
|
2012
2040
|
Object.assign(ElvClient.prototype, require("./client/AccessGroups"));
|
|
2013
2041
|
Object.assign(ElvClient.prototype, require("./client/ContentAccess"));
|