@eluvio/elv-client-js 4.2.33 → 4.2.36
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/ElvFrameClient-min.js +1 -1
- package/dist/ElvPermissionsClient-min.js +1 -1
- package/dist/ElvWalletClient-min.js +1 -1
- package/dist/ElvWalletClient-node-min.js +1 -1
- package/dist/src/AuthorizationClient.js +41 -32
- package/dist/src/ElvClient.js +391 -285
- package/dist/src/EthClient.js +3 -2
- package/dist/src/FrameClient.js +1 -1
- package/dist/src/HttpClient.js +59 -52
- package/dist/src/client/ABRPublishing.js +71 -60
- package/dist/src/client/ContentAccess.js +585 -207
- package/dist/src/client/ContentManagement.js +667 -67
- package/dist/src/client/Files.js +1400 -844
- package/dist/src/client/LiveConf.js +66 -45
- package/dist/src/client/LiveStream.js +1649 -1194
- package/package.json +1 -1
- package/src/HttpClient.js +9 -2
- package/src/client/ContentAccess.js +6 -2
- package/src/client/ContentManagement.js +7 -5
- package/src/client/LiveConf.js +19 -13
- package/src/client/LiveStream.js +66 -12
- package/testScripts/Test.js +2 -14
package/dist/src/ElvClient.js
CHANGED
|
@@ -62,6 +62,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
62
62
|
* @param {Array<string>} authServiceURIs - A list of full URIs to auth service endpoints
|
|
63
63
|
* @param {Array<string>} fileServiceURIs - A list of full URIs to file service endpoints
|
|
64
64
|
* @param {Array<string>=} searchURIs - A list of full URIs to search service endpoints
|
|
65
|
+
* @param {Array<string>=} tenantQueryURIs - A list of full URIs to tenant query service endpoints
|
|
65
66
|
* @param {number=} ethereumContractTimeout=10 - Number of seconds to wait for contract calls
|
|
66
67
|
* @param {string=} trustAuthorityId - (OAuth) The ID of the trust authority to use for OAuth authentication
|
|
67
68
|
* @param {string=} staticToken - Static token that will be used for all authorization in place of normal auth. Also known as an anonymous token containing the space
|
|
@@ -83,6 +84,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
83
84
|
authServiceURIs = _ref.authServiceURIs,
|
|
84
85
|
fileServiceURIs = _ref.fileServiceURIs,
|
|
85
86
|
searchURIs = _ref.searchURIs,
|
|
87
|
+
tenantQueryURIs = _ref.tenantQueryURIs,
|
|
86
88
|
_ref$ethereumContract = _ref.ethereumContractTimeout,
|
|
87
89
|
ethereumContractTimeout = _ref$ethereumContract === void 0 ? 10 : _ref$ethereumContract,
|
|
88
90
|
trustAuthorityId = _ref.trustAuthorityId,
|
|
@@ -110,6 +112,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
110
112
|
this.fileServiceURIs = fileServiceURIs || fabricURIs;
|
|
111
113
|
this.ethereumURIs = ethereumURIs;
|
|
112
114
|
this.searchURIs = searchURIs;
|
|
115
|
+
this.tenantQueryURIs = tenantQueryURIs || [];
|
|
113
116
|
this.ethereumContractTimeout = ethereumContractTimeout;
|
|
114
117
|
this.trustAuthorityId = trustAuthorityId;
|
|
115
118
|
this.noCache = noCache;
|
|
@@ -272,6 +275,11 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
272
275
|
networkName: this.networkName,
|
|
273
276
|
debug: this.debug
|
|
274
277
|
});
|
|
278
|
+
this.TenantQueryHttpClient = new HttpClient({
|
|
279
|
+
uris: this.tenantQueryURIs || [],
|
|
280
|
+
networkName: this.networkName,
|
|
281
|
+
debug: this.debug
|
|
282
|
+
});
|
|
275
283
|
this.ethClient = new EthClient({
|
|
276
284
|
client: this,
|
|
277
285
|
uris: this.ethereumURIs,
|
|
@@ -309,7 +317,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
309
317
|
// Initialize crypto wasm
|
|
310
318
|
this.Crypto = Crypto;
|
|
311
319
|
this.Crypto.ElvCrypto();
|
|
312
|
-
case
|
|
320
|
+
case 22:
|
|
313
321
|
case "end":
|
|
314
322
|
return _context2.stop();
|
|
315
323
|
}
|
|
@@ -348,7 +356,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
348
356
|
key: "UseRegion",
|
|
349
357
|
value: function () {
|
|
350
358
|
var _UseRegion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref4) {
|
|
351
|
-
var region, _yield$ElvClient$Conf, fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs;
|
|
359
|
+
var region, _yield$ElvClient$Conf, fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs, tenantQueryURIs;
|
|
352
360
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
353
361
|
while (1) switch (_context3.prev = _context3.next) {
|
|
354
362
|
case 0:
|
|
@@ -371,22 +379,25 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
371
379
|
authServiceURIs = _yield$ElvClient$Conf.authServiceURIs;
|
|
372
380
|
fileServiceURIs = _yield$ElvClient$Conf.fileServiceURIs;
|
|
373
381
|
searchURIs = _yield$ElvClient$Conf.searchURIs;
|
|
382
|
+
tenantQueryURIs = _yield$ElvClient$Conf.tenantQueryURIs;
|
|
374
383
|
this.region = region;
|
|
375
384
|
this.SetNodes({
|
|
376
385
|
fabricURIs: fabricURIs,
|
|
377
386
|
ethereumURIs: ethereumURIs,
|
|
378
387
|
authServiceURIs: authServiceURIs,
|
|
379
388
|
fileServiceURIs: fileServiceURIs,
|
|
380
|
-
searchURIs: searchURIs
|
|
389
|
+
searchURIs: searchURIs,
|
|
390
|
+
tenantQueryURIs: tenantQueryURIs
|
|
381
391
|
});
|
|
382
392
|
return _context3.abrupt("return", {
|
|
383
393
|
fabricURIs: fabricURIs,
|
|
384
394
|
ethereumURIs: ethereumURIs,
|
|
385
395
|
fileServiceURIs: fileServiceURIs,
|
|
386
396
|
authServiceURIs: authServiceURIs,
|
|
387
|
-
searchURIs: searchURIs
|
|
397
|
+
searchURIs: searchURIs,
|
|
398
|
+
tenantQueryURIs: tenantQueryURIs
|
|
388
399
|
});
|
|
389
|
-
case
|
|
400
|
+
case 15:
|
|
390
401
|
case "end":
|
|
391
402
|
return _context3.stop();
|
|
392
403
|
}
|
|
@@ -492,7 +503,8 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
492
503
|
ethereumURIs: this.ethereumURIs,
|
|
493
504
|
authServiceURIs: this.authServiceURIs,
|
|
494
505
|
fileServiceURIs: this.fileServiceURIs,
|
|
495
|
-
searchURIs: this.searchURIs
|
|
506
|
+
searchURIs: this.searchURIs,
|
|
507
|
+
tenantQueryURIs: this.tenantQueryURIs
|
|
496
508
|
};
|
|
497
509
|
}
|
|
498
510
|
|
|
@@ -505,6 +517,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
505
517
|
* @param {Array<string>=} authServiceURIs - A list of URLs for the auth service, in preference order
|
|
506
518
|
* @param {Array<string>=} fileServiceURIs - A list of URLs for file service jobs, in preference order
|
|
507
519
|
* @param {Array<string>=} searchURIs - A list of URLs for the search nodes, in preference order
|
|
520
|
+
* @param {Array<string>=} tenantQueryURIs - A list of URLs for the tenant query nodes, in preference order
|
|
508
521
|
*
|
|
509
522
|
* @methodGroup Nodes
|
|
510
523
|
*/
|
|
@@ -515,7 +528,8 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
515
528
|
ethereumURIs = _ref6.ethereumURIs,
|
|
516
529
|
authServiceURIs = _ref6.authServiceURIs,
|
|
517
530
|
fileServiceURIs = _ref6.fileServiceURIs,
|
|
518
|
-
searchURIs = _ref6.searchURIs
|
|
531
|
+
searchURIs = _ref6.searchURIs,
|
|
532
|
+
tenantQueryURIs = _ref6.tenantQueryURIs;
|
|
519
533
|
if (fabricURIs) {
|
|
520
534
|
this.fabricURIs = fabricURIs;
|
|
521
535
|
this.HttpClient.uris = fabricURIs;
|
|
@@ -541,6 +555,11 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
541
555
|
this.SearchHttpClient.uris = searchURIs;
|
|
542
556
|
this.SearchHttpClient.uriIndex = 0;
|
|
543
557
|
}
|
|
558
|
+
if (tenantQueryURIs) {
|
|
559
|
+
this.tenantQueryURIs = tenantQueryURIs;
|
|
560
|
+
this.TenantQueryHttpClient.uris = tenantQueryURIs;
|
|
561
|
+
this.TenantQueryHttpClient.uriIndex = 0;
|
|
562
|
+
}
|
|
544
563
|
}
|
|
545
564
|
|
|
546
565
|
/**
|
|
@@ -1001,65 +1020,145 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1001
1020
|
PAYLOAD 85b json-compressed
|
|
1002
1021
|
json 79b {"adr":"VVf4DQU357tDnZGYQeDrntRJ5rs=","spc":"ispc3ANoVSzNA3P6t7abLR69ho5YPPZU"}
|
|
1003
1022
|
*/
|
|
1023
|
+
/*
|
|
1024
|
+
PLAIN TOKEN PREFIX + BODY | aplsjcJf1HYcDDUuCdXcSZtU86nYK162YmYJeuqwMczEBJVkD5D5EvsBvVwYDRsf4hzDvBWMoe9piBpqx...
|
|
1025
|
+
PREFIX 6b aplsjc | apl=plain s=ES256K jc=json-compressed
|
|
1026
|
+
BODY base58(SIGNATURE + PAYLOAD)
|
|
1027
|
+
SIGNATURE 65b ES256K signature
|
|
1028
|
+
PAYLOAD raw-deflate JSON
|
|
1029
|
+
json {"adr":"VVf4DQU357tDnZGYQeDrntRJ5rs=","spc":"ispc3ANoVSzNA3P6t7abLR69ho5YPPZU"}
|
|
1030
|
+
*/
|
|
1031
|
+
/**
|
|
1032
|
+
* Create a signed "plain" authorization token (`aplsjc...`).
|
|
1033
|
+
*
|
|
1034
|
+
* Plain tokens are largely the same as client-signed access tokens - they do not contain a b/c transaction
|
|
1035
|
+
* and authorization is determined from the rights of the current signer's address.
|
|
1036
|
+
* Currently needed for tenant content query /tenant/:tid/q/query
|
|
1037
|
+
* This token will be deprecated in the future in favor of client-signed access tokens.
|
|
1038
|
+
*
|
|
1039
|
+
* @methodGroup Authorization
|
|
1040
|
+
* @namedParams
|
|
1041
|
+
* @param {string=} libraryId - Optional library ID to scope the token. If omitted, the token is space-wide.
|
|
1042
|
+
* @returns {Promise<string>} - The signed Plain auth token
|
|
1043
|
+
*/
|
|
1044
|
+
}, {
|
|
1045
|
+
key: "CreatePlainToken",
|
|
1046
|
+
value: function () {
|
|
1047
|
+
var _CreatePlainToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
|
|
1048
|
+
var _ref15,
|
|
1049
|
+
libraryId,
|
|
1050
|
+
address,
|
|
1051
|
+
token,
|
|
1052
|
+
compressedToken,
|
|
1053
|
+
signature,
|
|
1054
|
+
signatureBytes,
|
|
1055
|
+
_args11 = arguments;
|
|
1056
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
1057
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1058
|
+
case 0:
|
|
1059
|
+
_ref15 = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {}, libraryId = _ref15.libraryId;
|
|
1060
|
+
address = this.CurrentAccountAddress();
|
|
1061
|
+
if (address) {
|
|
1062
|
+
_context11.next = 4;
|
|
1063
|
+
break;
|
|
1064
|
+
}
|
|
1065
|
+
throw Error("Unable to create plain token: No signer is configured");
|
|
1066
|
+
case 4:
|
|
1067
|
+
_context11.t0 = Buffer.from(address.replace(/^0x/, ""), "hex").toString("base64");
|
|
1068
|
+
_context11.next = 7;
|
|
1069
|
+
return this.ContentSpaceId();
|
|
1070
|
+
case 7:
|
|
1071
|
+
_context11.t1 = _context11.sent;
|
|
1072
|
+
token = {
|
|
1073
|
+
adr: _context11.t0,
|
|
1074
|
+
spc: _context11.t1
|
|
1075
|
+
};
|
|
1076
|
+
if (libraryId) {
|
|
1077
|
+
token.lib = libraryId;
|
|
1078
|
+
}
|
|
1079
|
+
compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
|
|
1080
|
+
_context11.next = 13;
|
|
1081
|
+
return this.authClient.Sign(Ethers.utils.keccak256(compressedToken));
|
|
1082
|
+
case 13:
|
|
1083
|
+
signature = _context11.sent;
|
|
1084
|
+
signatureBytes = Buffer.from(signature.replace(/^0x/, ""), "hex");
|
|
1085
|
+
if (!(signatureBytes.length !== 65)) {
|
|
1086
|
+
_context11.next = 17;
|
|
1087
|
+
break;
|
|
1088
|
+
}
|
|
1089
|
+
throw Error("Unable to create plain token: Expected a 65-byte ES256K signature");
|
|
1090
|
+
case 17:
|
|
1091
|
+
return _context11.abrupt("return", "aplsjc".concat(this.utils.B58(Buffer.concat([signatureBytes, Buffer.from(compressedToken)]))));
|
|
1092
|
+
case 18:
|
|
1093
|
+
case "end":
|
|
1094
|
+
return _context11.stop();
|
|
1095
|
+
}
|
|
1096
|
+
}, _callee11, this);
|
|
1097
|
+
}));
|
|
1098
|
+
function CreatePlainToken() {
|
|
1099
|
+
return _CreatePlainToken.apply(this, arguments);
|
|
1100
|
+
}
|
|
1101
|
+
return CreatePlainToken;
|
|
1102
|
+
}()
|
|
1004
1103
|
}, {
|
|
1005
1104
|
key: "PersonalSign",
|
|
1006
1105
|
value: function () {
|
|
1007
|
-
var _PersonalSign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1106
|
+
var _PersonalSign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref16) {
|
|
1008
1107
|
var _this2 = this;
|
|
1009
1108
|
var message, addEthereumPrefix, Sign;
|
|
1010
|
-
return _regeneratorRuntime.wrap(function
|
|
1011
|
-
while (1) switch (
|
|
1109
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
1110
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1012
1111
|
case 0:
|
|
1013
|
-
message =
|
|
1112
|
+
message = _ref16.message, addEthereumPrefix = _ref16.addEthereumPrefix, Sign = _ref16.Sign;
|
|
1014
1113
|
if (!Sign) {
|
|
1015
1114
|
// Same as authClient.Sign, but authClient may not yet be initialized
|
|
1016
1115
|
Sign = /*#__PURE__*/function () {
|
|
1017
|
-
var
|
|
1018
|
-
return _regeneratorRuntime.wrap(function
|
|
1019
|
-
while (1) switch (
|
|
1116
|
+
var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(message) {
|
|
1117
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
1118
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1020
1119
|
case 0:
|
|
1021
|
-
|
|
1120
|
+
_context12.t0 = Ethers.utils;
|
|
1022
1121
|
if (!_this2.signer.signDigest) {
|
|
1023
|
-
|
|
1122
|
+
_context12.next = 7;
|
|
1024
1123
|
break;
|
|
1025
1124
|
}
|
|
1026
|
-
|
|
1125
|
+
_context12.next = 4;
|
|
1027
1126
|
return _this2.signer.signDigest(message);
|
|
1028
1127
|
case 4:
|
|
1029
|
-
|
|
1030
|
-
|
|
1128
|
+
_context12.t1 = _context12.sent;
|
|
1129
|
+
_context12.next = 10;
|
|
1031
1130
|
break;
|
|
1032
1131
|
case 7:
|
|
1033
|
-
|
|
1132
|
+
_context12.next = 9;
|
|
1034
1133
|
return _this2.signer._signingKey().signDigest(message);
|
|
1035
1134
|
case 9:
|
|
1036
|
-
|
|
1135
|
+
_context12.t1 = _context12.sent;
|
|
1037
1136
|
case 10:
|
|
1038
|
-
|
|
1039
|
-
return
|
|
1137
|
+
_context12.t2 = _context12.t1;
|
|
1138
|
+
return _context12.abrupt("return", _context12.t0.joinSignature.call(_context12.t0, _context12.t2));
|
|
1040
1139
|
case 12:
|
|
1041
1140
|
case "end":
|
|
1042
|
-
return
|
|
1141
|
+
return _context12.stop();
|
|
1043
1142
|
}
|
|
1044
|
-
},
|
|
1143
|
+
}, _callee12);
|
|
1045
1144
|
}));
|
|
1046
1145
|
return function Sign(_x8) {
|
|
1047
|
-
return
|
|
1146
|
+
return _ref17.apply(this, arguments);
|
|
1048
1147
|
};
|
|
1049
1148
|
}();
|
|
1050
1149
|
}
|
|
1051
1150
|
if (addEthereumPrefix) {
|
|
1052
1151
|
message = Ethers.utils.keccak256(Buffer.from("\x19Ethereum Signed Message:\n".concat(message.length).concat(message), "utf-8"));
|
|
1053
1152
|
}
|
|
1054
|
-
|
|
1153
|
+
_context13.next = 5;
|
|
1055
1154
|
return Sign(message);
|
|
1056
1155
|
case 5:
|
|
1057
|
-
return
|
|
1156
|
+
return _context13.abrupt("return", _context13.sent);
|
|
1058
1157
|
case 6:
|
|
1059
1158
|
case "end":
|
|
1060
|
-
return
|
|
1159
|
+
return _context13.stop();
|
|
1061
1160
|
}
|
|
1062
|
-
},
|
|
1161
|
+
}, _callee13);
|
|
1063
1162
|
}));
|
|
1064
1163
|
function PersonalSign(_x7) {
|
|
1065
1164
|
return _PersonalSign.apply(this, arguments);
|
|
@@ -1080,65 +1179,65 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1080
1179
|
}, {
|
|
1081
1180
|
key: "CreateFabricToken",
|
|
1082
1181
|
value: function () {
|
|
1083
|
-
var _CreateFabricToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1084
|
-
var
|
|
1085
|
-
|
|
1182
|
+
var _CreateFabricToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
|
|
1183
|
+
var _ref18,
|
|
1184
|
+
_ref18$duration,
|
|
1086
1185
|
duration,
|
|
1087
|
-
|
|
1186
|
+
_ref18$spec,
|
|
1088
1187
|
spec,
|
|
1089
1188
|
address,
|
|
1090
1189
|
Sign,
|
|
1091
|
-
|
|
1190
|
+
_ref18$addEthereumPre,
|
|
1092
1191
|
addEthereumPrefix,
|
|
1093
|
-
|
|
1192
|
+
_ref18$context,
|
|
1094
1193
|
context,
|
|
1095
1194
|
token,
|
|
1096
1195
|
message,
|
|
1097
1196
|
signature,
|
|
1098
1197
|
compressedToken,
|
|
1099
|
-
|
|
1100
|
-
return _regeneratorRuntime.wrap(function
|
|
1101
|
-
while (1) switch (
|
|
1198
|
+
_args14 = arguments;
|
|
1199
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
1200
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1102
1201
|
case 0:
|
|
1103
|
-
|
|
1202
|
+
_ref18 = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {}, _ref18$duration = _ref18.duration, duration = _ref18$duration === void 0 ? 24 * 60 * 60 * 1000 : _ref18$duration, _ref18$spec = _ref18.spec, spec = _ref18$spec === void 0 ? {} : _ref18$spec, address = _ref18.address, Sign = _ref18.Sign, _ref18$addEthereumPre = _ref18.addEthereumPrefix, addEthereumPrefix = _ref18$addEthereumPre === void 0 ? true : _ref18$addEthereumPre, _ref18$context = _ref18.context, context = _ref18$context === void 0 ? {} : _ref18$context;
|
|
1104
1203
|
address = address || this.CurrentAccountAddress();
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1204
|
+
_context14.t0 = _objectSpread;
|
|
1205
|
+
_context14.t1 = _objectSpread({}, spec);
|
|
1206
|
+
_context14.t2 = {};
|
|
1207
|
+
_context14.t3 = "iusr".concat(Utils.AddressToHash(address));
|
|
1208
|
+
_context14.t4 = Buffer.from(address.replace(/^0x/, ""), "hex").toString("base64");
|
|
1209
|
+
_context14.next = 9;
|
|
1111
1210
|
return this.ContentSpaceId();
|
|
1112
1211
|
case 9:
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
sub:
|
|
1119
|
-
adr:
|
|
1120
|
-
spc:
|
|
1121
|
-
iat:
|
|
1122
|
-
exp:
|
|
1123
|
-
ctx:
|
|
1212
|
+
_context14.t5 = _context14.sent;
|
|
1213
|
+
_context14.t6 = Date.now();
|
|
1214
|
+
_context14.t7 = Date.now() + duration;
|
|
1215
|
+
_context14.t8 = context;
|
|
1216
|
+
_context14.t9 = {
|
|
1217
|
+
sub: _context14.t3,
|
|
1218
|
+
adr: _context14.t4,
|
|
1219
|
+
spc: _context14.t5,
|
|
1220
|
+
iat: _context14.t6,
|
|
1221
|
+
exp: _context14.t7,
|
|
1222
|
+
ctx: _context14.t8
|
|
1124
1223
|
};
|
|
1125
|
-
token = (0,
|
|
1224
|
+
token = (0, _context14.t0)(_context14.t1, _context14.t2, _context14.t9);
|
|
1126
1225
|
message = "Eluvio Content Fabric Access Token 1.0\n".concat(JSON.stringify(token));
|
|
1127
|
-
|
|
1226
|
+
_context14.next = 18;
|
|
1128
1227
|
return this.PersonalSign({
|
|
1129
1228
|
message: message,
|
|
1130
1229
|
addEthereumPrefix: addEthereumPrefix,
|
|
1131
1230
|
Sign: Sign
|
|
1132
1231
|
});
|
|
1133
1232
|
case 18:
|
|
1134
|
-
signature =
|
|
1233
|
+
signature = _context14.sent;
|
|
1135
1234
|
compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
|
|
1136
|
-
return
|
|
1235
|
+
return _context14.abrupt("return", "acspjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
|
|
1137
1236
|
case 21:
|
|
1138
1237
|
case "end":
|
|
1139
|
-
return
|
|
1238
|
+
return _context14.stop();
|
|
1140
1239
|
}
|
|
1141
|
-
},
|
|
1240
|
+
}, _callee14, this);
|
|
1142
1241
|
}));
|
|
1143
1242
|
function CreateFabricToken() {
|
|
1144
1243
|
return _CreateFabricToken.apply(this, arguments);
|
|
@@ -1166,99 +1265,99 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1166
1265
|
}, {
|
|
1167
1266
|
key: "CreateSignedToken",
|
|
1168
1267
|
value: function () {
|
|
1169
|
-
var _CreateSignedToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1170
|
-
var libraryId, objectId, versionHash, policyId, subject,
|
|
1171
|
-
return _regeneratorRuntime.wrap(function
|
|
1172
|
-
while (1) switch (
|
|
1268
|
+
var _CreateSignedToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref19) {
|
|
1269
|
+
var libraryId, objectId, versionHash, policyId, subject, _ref19$grantType, grantType, _ref19$allowDecryptio, allowDecryption, duration, _ref19$context, context, issueTime, expirationTime, issueDateTime, token, cap, compressedToken, signature;
|
|
1270
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
1271
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1173
1272
|
case 0:
|
|
1174
|
-
libraryId =
|
|
1273
|
+
libraryId = _ref19.libraryId, objectId = _ref19.objectId, versionHash = _ref19.versionHash, policyId = _ref19.policyId, subject = _ref19.subject, _ref19$grantType = _ref19.grantType, grantType = _ref19$grantType === void 0 ? "read" : _ref19$grantType, _ref19$allowDecryptio = _ref19.allowDecryption, allowDecryption = _ref19$allowDecryptio === void 0 ? false : _ref19$allowDecryptio, duration = _ref19.duration, _ref19$context = _ref19.context, context = _ref19$context === void 0 ? {} : _ref19$context, issueTime = _ref19.issueTime, expirationTime = _ref19.expirationTime;
|
|
1175
1274
|
if (subject) {
|
|
1176
|
-
|
|
1275
|
+
_context15.next = 9;
|
|
1177
1276
|
break;
|
|
1178
1277
|
}
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1278
|
+
_context15.t0 = "iusr";
|
|
1279
|
+
_context15.t1 = this.utils;
|
|
1280
|
+
_context15.next = 6;
|
|
1182
1281
|
return this.CurrentAccountAddress();
|
|
1183
1282
|
case 6:
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
subject =
|
|
1283
|
+
_context15.t2 = _context15.sent;
|
|
1284
|
+
_context15.t3 = _context15.t1.AddressToHash.call(_context15.t1, _context15.t2);
|
|
1285
|
+
subject = _context15.t0.concat.call(_context15.t0, _context15.t3);
|
|
1187
1286
|
case 9:
|
|
1188
1287
|
if (policyId) {
|
|
1189
1288
|
context["elv:delegation-id"] = policyId;
|
|
1190
1289
|
}
|
|
1191
1290
|
issueDateTime = issueTime || Date.now();
|
|
1192
|
-
|
|
1193
|
-
|
|
1291
|
+
_context15.t4 = Buffer;
|
|
1292
|
+
_context15.next = 14;
|
|
1194
1293
|
return this.CurrentAccountAddress().replace(/^0x/, "");
|
|
1195
1294
|
case 14:
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1295
|
+
_context15.t5 = _context15.sent;
|
|
1296
|
+
_context15.t6 = _context15.t4.from.call(_context15.t4, _context15.t5, "hex").toString("base64");
|
|
1297
|
+
_context15.t7 = subject;
|
|
1298
|
+
_context15.next = 19;
|
|
1200
1299
|
return this.ContentSpaceId();
|
|
1201
1300
|
case 19:
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1301
|
+
_context15.t8 = _context15.sent;
|
|
1302
|
+
_context15.t9 = issueDateTime;
|
|
1303
|
+
_context15.t10 = expirationTime || issueDateTime + duration;
|
|
1304
|
+
_context15.t11 = grantType;
|
|
1305
|
+
_context15.t12 = context;
|
|
1207
1306
|
token = {
|
|
1208
|
-
adr:
|
|
1209
|
-
sub:
|
|
1210
|
-
spc:
|
|
1211
|
-
iat:
|
|
1212
|
-
exp:
|
|
1213
|
-
gra:
|
|
1214
|
-
ctx:
|
|
1307
|
+
adr: _context15.t6,
|
|
1308
|
+
sub: _context15.t7,
|
|
1309
|
+
spc: _context15.t8,
|
|
1310
|
+
iat: _context15.t9,
|
|
1311
|
+
exp: _context15.t10,
|
|
1312
|
+
gra: _context15.t11,
|
|
1313
|
+
ctx: _context15.t12
|
|
1215
1314
|
};
|
|
1216
1315
|
if (versionHash) {
|
|
1217
1316
|
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1218
1317
|
}
|
|
1219
1318
|
if (!objectId) {
|
|
1220
|
-
|
|
1319
|
+
_context15.next = 32;
|
|
1221
1320
|
break;
|
|
1222
1321
|
}
|
|
1223
1322
|
token.qid = objectId;
|
|
1224
1323
|
if (libraryId) {
|
|
1225
|
-
|
|
1324
|
+
_context15.next = 32;
|
|
1226
1325
|
break;
|
|
1227
1326
|
}
|
|
1228
|
-
|
|
1327
|
+
_context15.next = 31;
|
|
1229
1328
|
return this.ContentObjectLibraryId({
|
|
1230
1329
|
objectId: objectId
|
|
1231
1330
|
});
|
|
1232
1331
|
case 31:
|
|
1233
|
-
libraryId =
|
|
1332
|
+
libraryId = _context15.sent;
|
|
1234
1333
|
case 32:
|
|
1235
1334
|
if (libraryId) {
|
|
1236
1335
|
token.lib = libraryId;
|
|
1237
1336
|
}
|
|
1238
1337
|
if (!allowDecryption) {
|
|
1239
|
-
|
|
1338
|
+
_context15.next = 38;
|
|
1240
1339
|
break;
|
|
1241
1340
|
}
|
|
1242
|
-
|
|
1341
|
+
_context15.next = 36;
|
|
1243
1342
|
return this.authClient.ReEncryptionConk({
|
|
1244
1343
|
libraryId: libraryId,
|
|
1245
1344
|
objectId: objectId
|
|
1246
1345
|
});
|
|
1247
1346
|
case 36:
|
|
1248
|
-
cap =
|
|
1347
|
+
cap = _context15.sent;
|
|
1249
1348
|
token.apk = cap.public_key;
|
|
1250
1349
|
case 38:
|
|
1251
1350
|
compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
|
|
1252
|
-
|
|
1351
|
+
_context15.next = 41;
|
|
1253
1352
|
return this.authClient.Sign(Ethers.utils.keccak256(compressedToken));
|
|
1254
1353
|
case 41:
|
|
1255
|
-
signature =
|
|
1256
|
-
return
|
|
1354
|
+
signature = _context15.sent;
|
|
1355
|
+
return _context15.abrupt("return", "aessjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
|
|
1257
1356
|
case 43:
|
|
1258
1357
|
case "end":
|
|
1259
|
-
return
|
|
1358
|
+
return _context15.stop();
|
|
1260
1359
|
}
|
|
1261
|
-
},
|
|
1360
|
+
}, _callee15, this);
|
|
1262
1361
|
}));
|
|
1263
1362
|
function CreateSignedToken(_x9) {
|
|
1264
1363
|
return _CreateSignedToken.apply(this, arguments);
|
|
@@ -1268,19 +1367,19 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1268
1367
|
}, {
|
|
1269
1368
|
key: "CreateAuthorizationToken",
|
|
1270
1369
|
value: function () {
|
|
1271
|
-
var _CreateAuthorizationToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1272
|
-
return _regeneratorRuntime.wrap(function
|
|
1273
|
-
while (1) switch (
|
|
1370
|
+
var _CreateAuthorizationToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(args) {
|
|
1371
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
1372
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1274
1373
|
case 0:
|
|
1275
|
-
|
|
1374
|
+
_context16.next = 2;
|
|
1276
1375
|
return this.authClient.AuthorizationToken(args);
|
|
1277
1376
|
case 2:
|
|
1278
|
-
return
|
|
1377
|
+
return _context16.abrupt("return", _context16.sent);
|
|
1279
1378
|
case 3:
|
|
1280
1379
|
case "end":
|
|
1281
|
-
return
|
|
1380
|
+
return _context16.stop();
|
|
1282
1381
|
}
|
|
1283
|
-
},
|
|
1382
|
+
}, _callee16, this);
|
|
1284
1383
|
}));
|
|
1285
1384
|
function CreateAuthorizationToken(_x10) {
|
|
1286
1385
|
return _CreateAuthorizationToken.apply(this, arguments);
|
|
@@ -1304,28 +1403,28 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1304
1403
|
}, {
|
|
1305
1404
|
key: "CreateSignedMessageJSON",
|
|
1306
1405
|
value: function () {
|
|
1307
|
-
var _CreateSignedMessageJSON = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1406
|
+
var _CreateSignedMessageJSON = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref20) {
|
|
1308
1407
|
var message, type, msg, signature;
|
|
1309
|
-
return _regeneratorRuntime.wrap(function
|
|
1310
|
-
while (1) switch (
|
|
1408
|
+
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
1409
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1311
1410
|
case 0:
|
|
1312
|
-
message =
|
|
1411
|
+
message = _ref20.message;
|
|
1313
1412
|
// Only one kind of signature supported currently
|
|
1314
1413
|
type = "mje_"; // JSON message, EIP192 signature
|
|
1315
1414
|
msg = JSON.stringify(message);
|
|
1316
|
-
|
|
1415
|
+
_context17.next = 5;
|
|
1317
1416
|
return this.PersonalSign({
|
|
1318
1417
|
message: msg,
|
|
1319
1418
|
addEthereumPrefix: true
|
|
1320
1419
|
});
|
|
1321
1420
|
case 5:
|
|
1322
|
-
signature =
|
|
1323
|
-
return
|
|
1421
|
+
signature = _context17.sent;
|
|
1422
|
+
return _context17.abrupt("return", "".concat(type).concat(Utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(msg)]))));
|
|
1324
1423
|
case 7:
|
|
1325
1424
|
case "end":
|
|
1326
|
-
return
|
|
1425
|
+
return _context17.stop();
|
|
1327
1426
|
}
|
|
1328
|
-
},
|
|
1427
|
+
}, _callee17, this);
|
|
1329
1428
|
}));
|
|
1330
1429
|
function CreateSignedMessageJSON(_x11) {
|
|
1331
1430
|
return _CreateSignedMessageJSON.apply(this, arguments);
|
|
@@ -1343,15 +1442,15 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1343
1442
|
}, {
|
|
1344
1443
|
key: "DecodeSignedMessageJSON",
|
|
1345
1444
|
value: function () {
|
|
1346
|
-
var _DecodeSignedMessageJSON = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1445
|
+
var _DecodeSignedMessageJSON = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref21) {
|
|
1347
1446
|
var signedMessage, type, msgBytes, signature, msg, obj, prefixedMsgHash, signerAddr;
|
|
1348
|
-
return _regeneratorRuntime.wrap(function
|
|
1349
|
-
while (1) switch (
|
|
1447
|
+
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
1448
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1350
1449
|
case 0:
|
|
1351
|
-
signedMessage =
|
|
1450
|
+
signedMessage = _ref21.signedMessage;
|
|
1352
1451
|
type = signedMessage.slice(0, 4);
|
|
1353
|
-
|
|
1354
|
-
|
|
1452
|
+
_context18.t0 = type;
|
|
1453
|
+
_context18.next = _context18.t0 === "mje_" ? 5 : 12;
|
|
1355
1454
|
break;
|
|
1356
1455
|
case 5:
|
|
1357
1456
|
msgBytes = Utils.FromB58(signedMessage.slice(4));
|
|
@@ -1360,7 +1459,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1360
1459
|
obj = JSON.parse(msg);
|
|
1361
1460
|
prefixedMsgHash = Ethers.utils.keccak256(Buffer.from("\x19Ethereum Signed Message:\n".concat(msg.length).concat(msg), "utf-8"));
|
|
1362
1461
|
signerAddr = Ethers.utils.recoverAddress(prefixedMsgHash, signature);
|
|
1363
|
-
return
|
|
1462
|
+
return _context18.abrupt("return", {
|
|
1364
1463
|
type: type,
|
|
1365
1464
|
message: obj,
|
|
1366
1465
|
signerAddress: signerAddr,
|
|
@@ -1370,9 +1469,9 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1370
1469
|
throw new Error("Bad message type: ".concat(type));
|
|
1371
1470
|
case 13:
|
|
1372
1471
|
case "end":
|
|
1373
|
-
return
|
|
1472
|
+
return _context18.stop();
|
|
1374
1473
|
}
|
|
1375
|
-
},
|
|
1474
|
+
}, _callee18);
|
|
1376
1475
|
}));
|
|
1377
1476
|
function DecodeSignedMessageJSON(_x12) {
|
|
1378
1477
|
return _DecodeSignedMessageJSON.apply(this, arguments);
|
|
@@ -1401,12 +1500,12 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1401
1500
|
}, {
|
|
1402
1501
|
key: "SetOauthToken",
|
|
1403
1502
|
value: function () {
|
|
1404
|
-
var _SetOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1503
|
+
var _SetOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(_ref22) {
|
|
1405
1504
|
var token, wallet, signer;
|
|
1406
|
-
return _regeneratorRuntime.wrap(function
|
|
1407
|
-
while (1) switch (
|
|
1505
|
+
return _regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
1506
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1408
1507
|
case 0:
|
|
1409
|
-
token =
|
|
1508
|
+
token = _ref22.token;
|
|
1410
1509
|
this.oauthToken = token;
|
|
1411
1510
|
wallet = this.GenerateWallet();
|
|
1412
1511
|
signer = wallet.AddAccountFromMnemonic({
|
|
@@ -1417,9 +1516,9 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1417
1516
|
});
|
|
1418
1517
|
case 5:
|
|
1419
1518
|
case "end":
|
|
1420
|
-
return
|
|
1519
|
+
return _context19.stop();
|
|
1421
1520
|
}
|
|
1422
|
-
},
|
|
1521
|
+
}, _callee19, this);
|
|
1423
1522
|
}));
|
|
1424
1523
|
function SetOauthToken(_x13) {
|
|
1425
1524
|
return _SetOauthToken.apply(this, arguments);
|
|
@@ -1439,44 +1538,44 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1439
1538
|
}, {
|
|
1440
1539
|
key: "SetSignerFromOauthToken",
|
|
1441
1540
|
value: function () {
|
|
1442
|
-
var _SetSignerFromOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1541
|
+
var _SetSignerFromOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(_ref23) {
|
|
1443
1542
|
var token, wallet, client, _yield$client$authCli, urls, path, httpClient, response, privateKey;
|
|
1444
|
-
return _regeneratorRuntime.wrap(function
|
|
1445
|
-
while (1) switch (
|
|
1543
|
+
return _regeneratorRuntime.wrap(function _callee20$(_context20) {
|
|
1544
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1446
1545
|
case 0:
|
|
1447
|
-
token =
|
|
1546
|
+
token = _ref23.token;
|
|
1448
1547
|
if (this.trustAuthorityId) {
|
|
1449
|
-
|
|
1548
|
+
_context20.next = 3;
|
|
1450
1549
|
break;
|
|
1451
1550
|
}
|
|
1452
1551
|
throw Error("Unable to authorize with OAuth token: No trust authority ID set");
|
|
1453
1552
|
case 3:
|
|
1454
1553
|
wallet = this.GenerateWallet();
|
|
1455
|
-
|
|
1554
|
+
_context20.prev = 4;
|
|
1456
1555
|
if (this.kmsURIs) {
|
|
1457
|
-
|
|
1556
|
+
_context20.next = 17;
|
|
1458
1557
|
break;
|
|
1459
1558
|
}
|
|
1460
|
-
|
|
1559
|
+
_context20.next = 8;
|
|
1461
1560
|
return ElvClient.FromConfigurationUrl({
|
|
1462
1561
|
configUrl: this.configUrl
|
|
1463
1562
|
});
|
|
1464
1563
|
case 8:
|
|
1465
|
-
client =
|
|
1564
|
+
client = _context20.sent;
|
|
1466
1565
|
client.SetSigner({
|
|
1467
1566
|
signer: wallet.AddAccount({
|
|
1468
1567
|
privateKey: this.defaultKey
|
|
1469
1568
|
})
|
|
1470
1569
|
});
|
|
1471
|
-
|
|
1570
|
+
_context20.next = 12;
|
|
1472
1571
|
return client.authClient.KMSInfo({
|
|
1473
1572
|
kmsId: this.trustAuthorityId
|
|
1474
1573
|
});
|
|
1475
1574
|
case 12:
|
|
1476
|
-
_yield$client$authCli =
|
|
1575
|
+
_yield$client$authCli = _context20.sent;
|
|
1477
1576
|
urls = _yield$client$authCli.urls;
|
|
1478
1577
|
if (!(!urls || urls.length === 0)) {
|
|
1479
|
-
|
|
1578
|
+
_context20.next = 16;
|
|
1480
1579
|
break;
|
|
1481
1580
|
}
|
|
1482
1581
|
throw Error("Unable to authorize with OAuth token: No KMS URLs set");
|
|
@@ -1490,7 +1589,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1490
1589
|
networkName: this.networkName,
|
|
1491
1590
|
debug: this.debug
|
|
1492
1591
|
});
|
|
1493
|
-
|
|
1592
|
+
_context20.next = 22;
|
|
1494
1593
|
return this.utils.ResponseToJson(httpClient.Request({
|
|
1495
1594
|
headers: {
|
|
1496
1595
|
Authorization: "Bearer ".concat(token)
|
|
@@ -1500,7 +1599,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1500
1599
|
forceFailover: true
|
|
1501
1600
|
}));
|
|
1502
1601
|
case 22:
|
|
1503
|
-
response =
|
|
1602
|
+
response = _context20.sent;
|
|
1504
1603
|
privateKey = response["UserSKHex"];
|
|
1505
1604
|
this.SetSigner({
|
|
1506
1605
|
signer: wallet.AddAccount({
|
|
@@ -1509,25 +1608,25 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1509
1608
|
});
|
|
1510
1609
|
|
|
1511
1610
|
// Ensure wallet is initialized
|
|
1512
|
-
|
|
1611
|
+
_context20.next = 27;
|
|
1513
1612
|
return this.userProfileClient.WalletAddress();
|
|
1514
1613
|
case 27:
|
|
1515
|
-
|
|
1614
|
+
_context20.next = 36;
|
|
1516
1615
|
break;
|
|
1517
1616
|
case 29:
|
|
1518
|
-
|
|
1519
|
-
|
|
1617
|
+
_context20.prev = 29;
|
|
1618
|
+
_context20.t0 = _context20["catch"](4);
|
|
1520
1619
|
this.Log("Failed to set signer from OAuth token:", true);
|
|
1521
|
-
this.Log(
|
|
1522
|
-
|
|
1620
|
+
this.Log(_context20.t0, true);
|
|
1621
|
+
_context20.next = 35;
|
|
1523
1622
|
return this.ClearSigner();
|
|
1524
1623
|
case 35:
|
|
1525
|
-
throw
|
|
1624
|
+
throw _context20.t0;
|
|
1526
1625
|
case 36:
|
|
1527
1626
|
case "end":
|
|
1528
|
-
return
|
|
1627
|
+
return _context20.stop();
|
|
1529
1628
|
}
|
|
1530
|
-
},
|
|
1629
|
+
}, _callee20, this, [[4, 29]]);
|
|
1531
1630
|
}));
|
|
1532
1631
|
function SetSignerFromOauthToken(_x14) {
|
|
1533
1632
|
return _SetSignerFromOauthToken.apply(this, arguments);
|
|
@@ -1545,8 +1644,8 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1545
1644
|
*/
|
|
1546
1645
|
}, {
|
|
1547
1646
|
key: "CreateStaticToken",
|
|
1548
|
-
value: function CreateStaticToken(
|
|
1549
|
-
var libraryId =
|
|
1647
|
+
value: function CreateStaticToken(_ref24) {
|
|
1648
|
+
var libraryId = _ref24.libraryId;
|
|
1550
1649
|
var token = {
|
|
1551
1650
|
qspace_id: this.contentSpaceId
|
|
1552
1651
|
};
|
|
@@ -1567,10 +1666,10 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1567
1666
|
}, {
|
|
1568
1667
|
key: "SetStaticToken",
|
|
1569
1668
|
value: function SetStaticToken() {
|
|
1570
|
-
var
|
|
1571
|
-
token =
|
|
1572
|
-
|
|
1573
|
-
update =
|
|
1669
|
+
var _ref25 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1670
|
+
token = _ref25.token,
|
|
1671
|
+
_ref25$update = _ref25.update,
|
|
1672
|
+
update = _ref25$update === void 0 ? false : _ref25$update;
|
|
1574
1673
|
if (token) {
|
|
1575
1674
|
this.staticToken = token;
|
|
1576
1675
|
} else {
|
|
@@ -1602,28 +1701,28 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1602
1701
|
}, {
|
|
1603
1702
|
key: "SetPolicyAuthorization",
|
|
1604
1703
|
value: function () {
|
|
1605
|
-
var _SetPolicyAuthorization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1704
|
+
var _SetPolicyAuthorization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref26) {
|
|
1606
1705
|
var objectId;
|
|
1607
|
-
return _regeneratorRuntime.wrap(function
|
|
1608
|
-
while (1) switch (
|
|
1706
|
+
return _regeneratorRuntime.wrap(function _callee21$(_context21) {
|
|
1707
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1609
1708
|
case 0:
|
|
1610
|
-
objectId =
|
|
1611
|
-
|
|
1612
|
-
|
|
1709
|
+
objectId = _ref26.objectId;
|
|
1710
|
+
_context21.t0 = this;
|
|
1711
|
+
_context21.next = 4;
|
|
1613
1712
|
return this.GenerateStateChannelToken({
|
|
1614
1713
|
objectId: objectId
|
|
1615
1714
|
});
|
|
1616
1715
|
case 4:
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
token:
|
|
1716
|
+
_context21.t1 = _context21.sent;
|
|
1717
|
+
_context21.t2 = {
|
|
1718
|
+
token: _context21.t1
|
|
1620
1719
|
};
|
|
1621
|
-
|
|
1720
|
+
_context21.t0.SetStaticToken.call(_context21.t0, _context21.t2);
|
|
1622
1721
|
case 7:
|
|
1623
1722
|
case "end":
|
|
1624
|
-
return
|
|
1723
|
+
return _context21.stop();
|
|
1625
1724
|
}
|
|
1626
|
-
},
|
|
1725
|
+
}, _callee21, this);
|
|
1627
1726
|
}));
|
|
1628
1727
|
function SetPolicyAuthorization(_x15) {
|
|
1629
1728
|
return _SetPolicyAuthorization.apply(this, arguments);
|
|
@@ -1639,21 +1738,21 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1639
1738
|
}, {
|
|
1640
1739
|
key: "Sign",
|
|
1641
1740
|
value: function () {
|
|
1642
|
-
var _Sign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1741
|
+
var _Sign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(string) {
|
|
1643
1742
|
var signature;
|
|
1644
|
-
return _regeneratorRuntime.wrap(function
|
|
1645
|
-
while (1) switch (
|
|
1743
|
+
return _regeneratorRuntime.wrap(function _callee22$(_context22) {
|
|
1744
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1646
1745
|
case 0:
|
|
1647
|
-
|
|
1746
|
+
_context22.next = 2;
|
|
1648
1747
|
return this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(string)));
|
|
1649
1748
|
case 2:
|
|
1650
|
-
signature =
|
|
1651
|
-
return
|
|
1749
|
+
signature = _context22.sent;
|
|
1750
|
+
return _context22.abrupt("return", this.utils.FormatSignature(signature));
|
|
1652
1751
|
case 4:
|
|
1653
1752
|
case "end":
|
|
1654
|
-
return
|
|
1753
|
+
return _context22.stop();
|
|
1655
1754
|
}
|
|
1656
|
-
},
|
|
1755
|
+
}, _callee22, this);
|
|
1657
1756
|
}));
|
|
1658
1757
|
function Sign(_x16) {
|
|
1659
1758
|
return _Sign.apply(this, arguments);
|
|
@@ -1672,28 +1771,28 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1672
1771
|
}, {
|
|
1673
1772
|
key: "EncryptECIES",
|
|
1674
1773
|
value: function () {
|
|
1675
|
-
var _EncryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1774
|
+
var _EncryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref27) {
|
|
1676
1775
|
var message, publicKey;
|
|
1677
|
-
return _regeneratorRuntime.wrap(function
|
|
1678
|
-
while (1) switch (
|
|
1776
|
+
return _regeneratorRuntime.wrap(function _callee23$(_context23) {
|
|
1777
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1679
1778
|
case 0:
|
|
1680
|
-
message =
|
|
1779
|
+
message = _ref27.message, publicKey = _ref27.publicKey;
|
|
1681
1780
|
if (this.signer) {
|
|
1682
|
-
|
|
1781
|
+
_context23.next = 3;
|
|
1683
1782
|
break;
|
|
1684
1783
|
}
|
|
1685
1784
|
throw "Signer not set";
|
|
1686
1785
|
case 3:
|
|
1687
1786
|
ValidatePresence("message", message);
|
|
1688
|
-
|
|
1787
|
+
_context23.next = 6;
|
|
1689
1788
|
return this.Crypto.EncryptConk(message, publicKey || this.signer._signingKey().publicKey);
|
|
1690
1789
|
case 6:
|
|
1691
|
-
return
|
|
1790
|
+
return _context23.abrupt("return", _context23.sent);
|
|
1692
1791
|
case 7:
|
|
1693
1792
|
case "end":
|
|
1694
|
-
return
|
|
1793
|
+
return _context23.stop();
|
|
1695
1794
|
}
|
|
1696
|
-
},
|
|
1795
|
+
}, _callee23, this);
|
|
1697
1796
|
}));
|
|
1698
1797
|
function EncryptECIES(_x17) {
|
|
1699
1798
|
return _EncryptECIES.apply(this, arguments);
|
|
@@ -1711,28 +1810,28 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1711
1810
|
}, {
|
|
1712
1811
|
key: "DecryptECIES",
|
|
1713
1812
|
value: function () {
|
|
1714
|
-
var _DecryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1813
|
+
var _DecryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(_ref28) {
|
|
1715
1814
|
var message;
|
|
1716
|
-
return _regeneratorRuntime.wrap(function
|
|
1717
|
-
while (1) switch (
|
|
1815
|
+
return _regeneratorRuntime.wrap(function _callee24$(_context24) {
|
|
1816
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1718
1817
|
case 0:
|
|
1719
|
-
message =
|
|
1818
|
+
message = _ref28.message;
|
|
1720
1819
|
if (this.signer) {
|
|
1721
|
-
|
|
1820
|
+
_context24.next = 3;
|
|
1722
1821
|
break;
|
|
1723
1822
|
}
|
|
1724
1823
|
throw "Signer not set";
|
|
1725
1824
|
case 3:
|
|
1726
1825
|
ValidatePresence("message", message);
|
|
1727
|
-
|
|
1826
|
+
_context24.next = 6;
|
|
1728
1827
|
return this.Crypto.DecryptCap(message, this.signer);
|
|
1729
1828
|
case 6:
|
|
1730
|
-
return
|
|
1829
|
+
return _context24.abrupt("return", _context24.sent);
|
|
1731
1830
|
case 7:
|
|
1732
1831
|
case "end":
|
|
1733
|
-
return
|
|
1832
|
+
return _context24.stop();
|
|
1734
1833
|
}
|
|
1735
|
-
},
|
|
1834
|
+
}, _callee24, this);
|
|
1736
1835
|
}));
|
|
1737
1836
|
function DecryptECIES(_x18) {
|
|
1738
1837
|
return _DecryptECIES.apply(this, arguments);
|
|
@@ -1753,22 +1852,22 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1753
1852
|
}, {
|
|
1754
1853
|
key: "Request",
|
|
1755
1854
|
value: function () {
|
|
1756
|
-
var _Request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1757
|
-
var url,
|
|
1758
|
-
return _regeneratorRuntime.wrap(function
|
|
1759
|
-
while (1) switch (
|
|
1855
|
+
var _Request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(_ref29) {
|
|
1856
|
+
var url, _ref29$format, format, _ref29$method, method, _ref29$headers, headers, body;
|
|
1857
|
+
return _regeneratorRuntime.wrap(function _callee25$(_context25) {
|
|
1858
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1760
1859
|
case 0:
|
|
1761
|
-
url =
|
|
1762
|
-
return
|
|
1860
|
+
url = _ref29.url, _ref29$format = _ref29.format, format = _ref29$format === void 0 ? "json" : _ref29$format, _ref29$method = _ref29.method, method = _ref29$method === void 0 ? "GET" : _ref29$method, _ref29$headers = _ref29.headers, headers = _ref29$headers === void 0 ? {} : _ref29$headers, body = _ref29.body;
|
|
1861
|
+
return _context25.abrupt("return", this.utils.ResponseToFormat(format, HttpClient.Fetch(url, {
|
|
1763
1862
|
method: method,
|
|
1764
1863
|
headers: headers,
|
|
1765
1864
|
body: body
|
|
1766
1865
|
})));
|
|
1767
1866
|
case 2:
|
|
1768
1867
|
case "end":
|
|
1769
|
-
return
|
|
1868
|
+
return _context25.stop();
|
|
1770
1869
|
}
|
|
1771
|
-
},
|
|
1870
|
+
}, _callee25, this);
|
|
1772
1871
|
}));
|
|
1773
1872
|
function Request(_x19) {
|
|
1774
1873
|
return _Request.apply(this, arguments);
|
|
@@ -1778,12 +1877,12 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1778
1877
|
}, {
|
|
1779
1878
|
key: "MakeAuthServiceRequest",
|
|
1780
1879
|
value: function () {
|
|
1781
|
-
var _MakeAuthServiceRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1782
|
-
var kmsId, objectId, versionHash,
|
|
1783
|
-
return _regeneratorRuntime.wrap(function
|
|
1784
|
-
while (1) switch (
|
|
1880
|
+
var _MakeAuthServiceRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(_ref30) {
|
|
1881
|
+
var kmsId, objectId, versionHash, _ref30$method, method, path, bodyType, _ref30$body, body, _ref30$queryParams, queryParams, headers, format, response;
|
|
1882
|
+
return _regeneratorRuntime.wrap(function _callee26$(_context26) {
|
|
1883
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1785
1884
|
case 0:
|
|
1786
|
-
kmsId =
|
|
1885
|
+
kmsId = _ref30.kmsId, objectId = _ref30.objectId, versionHash = _ref30.versionHash, _ref30$method = _ref30.method, method = _ref30$method === void 0 ? "GET" : _ref30$method, path = _ref30.path, bodyType = _ref30.bodyType, _ref30$body = _ref30.body, body = _ref30$body === void 0 ? {} : _ref30$body, _ref30$queryParams = _ref30.queryParams, queryParams = _ref30$queryParams === void 0 ? {} : _ref30$queryParams, headers = _ref30.headers, format = _ref30.format;
|
|
1787
1886
|
response = this.authClient.MakeAuthServiceRequest({
|
|
1788
1887
|
kmsId: kmsId,
|
|
1789
1888
|
objectId: objectId,
|
|
@@ -1795,12 +1894,12 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1795
1894
|
queryParams: queryParams,
|
|
1796
1895
|
headers: headers
|
|
1797
1896
|
});
|
|
1798
|
-
return
|
|
1897
|
+
return _context26.abrupt("return", !format ? response : this.utils.ResponseToFormat(format, response));
|
|
1799
1898
|
case 3:
|
|
1800
1899
|
case "end":
|
|
1801
|
-
return
|
|
1900
|
+
return _context26.stop();
|
|
1802
1901
|
}
|
|
1803
|
-
},
|
|
1902
|
+
}, _callee26, this);
|
|
1804
1903
|
}));
|
|
1805
1904
|
function MakeAuthServiceRequest(_x20) {
|
|
1806
1905
|
return _MakeAuthServiceRequest.apply(this, arguments);
|
|
@@ -1823,17 +1922,17 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1823
1922
|
}, {
|
|
1824
1923
|
key: "CallFromFrameMessage",
|
|
1825
1924
|
value: function () {
|
|
1826
|
-
var _CallFromFrameMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1925
|
+
var _CallFromFrameMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27(message, Respond) {
|
|
1827
1926
|
var _this4 = this;
|
|
1828
1927
|
var callback, method, methodResults, responseError;
|
|
1829
|
-
return _regeneratorRuntime.wrap(function
|
|
1830
|
-
while (1) switch (
|
|
1928
|
+
return _regeneratorRuntime.wrap(function _callee27$(_context27) {
|
|
1929
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1831
1930
|
case 0:
|
|
1832
1931
|
if (!(message.type !== "ElvFrameRequest")) {
|
|
1833
|
-
|
|
1932
|
+
_context27.next = 2;
|
|
1834
1933
|
break;
|
|
1835
1934
|
}
|
|
1836
|
-
return
|
|
1935
|
+
return _context27.abrupt("return");
|
|
1837
1936
|
case 2:
|
|
1838
1937
|
if (message.callbackId) {
|
|
1839
1938
|
callback = function callback(result) {
|
|
@@ -1845,77 +1944,77 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1845
1944
|
};
|
|
1846
1945
|
message.args.callback = callback;
|
|
1847
1946
|
}
|
|
1848
|
-
|
|
1947
|
+
_context27.prev = 3;
|
|
1849
1948
|
method = message.calledMethod;
|
|
1850
1949
|
if (!(message.module === "walletClient")) {
|
|
1851
|
-
|
|
1950
|
+
_context27.next = 15;
|
|
1852
1951
|
break;
|
|
1853
1952
|
}
|
|
1854
1953
|
if (this.walletClient) {
|
|
1855
|
-
|
|
1954
|
+
_context27.next = 8;
|
|
1856
1955
|
break;
|
|
1857
1956
|
}
|
|
1858
1957
|
throw Error("Wallet client not set");
|
|
1859
1958
|
case 8:
|
|
1860
1959
|
if (!this.walletClient.ForbiddenMethods().includes(method)) {
|
|
1861
|
-
|
|
1960
|
+
_context27.next = 10;
|
|
1862
1961
|
break;
|
|
1863
1962
|
}
|
|
1864
1963
|
throw Error("Invalid user profile method: " + method);
|
|
1865
1964
|
case 10:
|
|
1866
|
-
|
|
1965
|
+
_context27.next = 12;
|
|
1867
1966
|
return this.walletClient[method](message.args);
|
|
1868
1967
|
case 12:
|
|
1869
|
-
methodResults =
|
|
1870
|
-
|
|
1968
|
+
methodResults = _context27.sent;
|
|
1969
|
+
_context27.next = 28;
|
|
1871
1970
|
break;
|
|
1872
1971
|
case 15:
|
|
1873
1972
|
if (!(message.module === "userProfileClient")) {
|
|
1874
|
-
|
|
1973
|
+
_context27.next = 23;
|
|
1875
1974
|
break;
|
|
1876
1975
|
}
|
|
1877
1976
|
if (this.userProfileClient.FrameAllowedMethods().includes(method)) {
|
|
1878
|
-
|
|
1977
|
+
_context27.next = 18;
|
|
1879
1978
|
break;
|
|
1880
1979
|
}
|
|
1881
1980
|
throw Error("Invalid user profile method: " + method);
|
|
1882
1981
|
case 18:
|
|
1883
|
-
|
|
1982
|
+
_context27.next = 20;
|
|
1884
1983
|
return this.userProfileClient[method](message.args);
|
|
1885
1984
|
case 20:
|
|
1886
|
-
methodResults =
|
|
1887
|
-
|
|
1985
|
+
methodResults = _context27.sent;
|
|
1986
|
+
_context27.next = 28;
|
|
1888
1987
|
break;
|
|
1889
1988
|
case 23:
|
|
1890
1989
|
if (this.FrameAllowedMethods().includes(method)) {
|
|
1891
|
-
|
|
1990
|
+
_context27.next = 25;
|
|
1892
1991
|
break;
|
|
1893
1992
|
}
|
|
1894
1993
|
throw Error("Invalid method: " + method);
|
|
1895
1994
|
case 25:
|
|
1896
|
-
|
|
1995
|
+
_context27.next = 27;
|
|
1897
1996
|
return this[method](message.args);
|
|
1898
1997
|
case 27:
|
|
1899
|
-
methodResults =
|
|
1998
|
+
methodResults = _context27.sent;
|
|
1900
1999
|
case 28:
|
|
1901
2000
|
Respond(this.utils.MakeClonable({
|
|
1902
2001
|
type: "ElvFrameResponse",
|
|
1903
2002
|
requestId: message.requestId,
|
|
1904
2003
|
response: methodResults
|
|
1905
2004
|
}));
|
|
1906
|
-
|
|
2005
|
+
_context27.next = 38;
|
|
1907
2006
|
break;
|
|
1908
2007
|
case 31:
|
|
1909
|
-
|
|
1910
|
-
|
|
2008
|
+
_context27.prev = 31;
|
|
2009
|
+
_context27.t0 = _context27["catch"](3);
|
|
1911
2010
|
// eslint-disable-next-line no-console
|
|
1912
|
-
this.Log("Frame Message Error:\n Method: ".concat(message.calledMethod, "\n Arguments: ").concat(JSON.stringify(message.args, null, 2), "\n Error: ").concat(_typeof(
|
|
2011
|
+
this.Log("Frame Message Error:\n Method: ".concat(message.calledMethod, "\n Arguments: ").concat(JSON.stringify(message.args, null, 2), "\n Error: ").concat(_typeof(_context27.t0) === "object" ? JSON.stringify(_context27.t0, null, 2) : _context27.t0), true);
|
|
1913
2012
|
|
|
1914
2013
|
// eslint-disable-next-line no-console
|
|
1915
2014
|
console.error(message);
|
|
1916
2015
|
// eslint-disable-next-line no-console
|
|
1917
|
-
console.error(
|
|
1918
|
-
responseError =
|
|
2016
|
+
console.error(_context27.t0);
|
|
2017
|
+
responseError = _context27.t0 instanceof Error ? _context27.t0.message : _context27.t0;
|
|
1919
2018
|
Respond(this.utils.MakeClonable({
|
|
1920
2019
|
type: "ElvFrameResponse",
|
|
1921
2020
|
requestId: message.requestId,
|
|
@@ -1923,9 +2022,9 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1923
2022
|
}));
|
|
1924
2023
|
case 38:
|
|
1925
2024
|
case "end":
|
|
1926
|
-
return
|
|
2025
|
+
return _context27.stop();
|
|
1927
2026
|
}
|
|
1928
|
-
},
|
|
2027
|
+
}, _callee27, this, [[3, 31]]);
|
|
1929
2028
|
}));
|
|
1930
2029
|
function CallFromFrameMessage(_x21, _x22) {
|
|
1931
2030
|
return _CallFromFrameMessage.apply(this, arguments);
|
|
@@ -1935,13 +2034,13 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1935
2034
|
}], [{
|
|
1936
2035
|
key: "Configuration",
|
|
1937
2036
|
value: function () {
|
|
1938
|
-
var _Configuration = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1939
|
-
var configUrl,
|
|
1940
|
-
return _regeneratorRuntime.wrap(function
|
|
1941
|
-
while (1) switch (
|
|
2037
|
+
var _Configuration = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28(_ref31) {
|
|
2038
|
+
var configUrl, _ref31$kmsUrls, kmsUrls, region, clientIP, uri, fabricInfo, filterHTTPS, fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs, tenantQueryURIs, fabricVersion;
|
|
2039
|
+
return _regeneratorRuntime.wrap(function _callee28$(_context28) {
|
|
2040
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1942
2041
|
case 0:
|
|
1943
|
-
configUrl =
|
|
1944
|
-
|
|
2042
|
+
configUrl = _ref31.configUrl, _ref31$kmsUrls = _ref31.kmsUrls, kmsUrls = _ref31$kmsUrls === void 0 ? [] : _ref31$kmsUrls, region = _ref31.region, clientIP = _ref31.clientIP;
|
|
2043
|
+
_context28.prev = 1;
|
|
1945
2044
|
uri = new URI(configUrl);
|
|
1946
2045
|
uri.pathname("/config");
|
|
1947
2046
|
if (region) {
|
|
@@ -1950,10 +2049,10 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1950
2049
|
if (clientIP) {
|
|
1951
2050
|
uri.addSearch("client_ip", clientIP);
|
|
1952
2051
|
}
|
|
1953
|
-
|
|
2052
|
+
_context28.next = 8;
|
|
1954
2053
|
return Utils.ResponseToJson(HttpClient.Fetch(uri.toString()));
|
|
1955
2054
|
case 8:
|
|
1956
|
-
fabricInfo =
|
|
2055
|
+
fabricInfo = _context28.sent;
|
|
1957
2056
|
// If any HTTPS urls present, throw away HTTP urls so only HTTPS will be used
|
|
1958
2057
|
filterHTTPS = function filterHTTPS(uri) {
|
|
1959
2058
|
return uri.toLowerCase().startsWith("https");
|
|
@@ -1975,8 +2074,12 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1975
2074
|
fileServiceURIs = fileServiceURIs.filter(filterHTTPS);
|
|
1976
2075
|
}
|
|
1977
2076
|
searchURIs = fabricInfo.network.services.search || [];
|
|
2077
|
+
tenantQueryURIs = fabricInfo.network.services.tenant_query || [];
|
|
2078
|
+
if (tenantQueryURIs.find(filterHTTPS)) {
|
|
2079
|
+
tenantQueryURIs = tenantQueryURIs.filter(filterHTTPS);
|
|
2080
|
+
}
|
|
1978
2081
|
fabricVersion = Math.max.apply(Math, _toConsumableArray(fabricInfo.network.api_versions || [2]));
|
|
1979
|
-
return
|
|
2082
|
+
return _context28.abrupt("return", {
|
|
1980
2083
|
nodeId: fabricInfo.node_id,
|
|
1981
2084
|
contentSpaceId: fabricInfo.qspace.id,
|
|
1982
2085
|
networkId: (fabricInfo.qspace.ethereum || {}).network_id,
|
|
@@ -1987,21 +2090,22 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1987
2090
|
fileServiceURIs: fileServiceURIs,
|
|
1988
2091
|
kmsURIs: kmsUrls,
|
|
1989
2092
|
searchURIs: searchURIs,
|
|
2093
|
+
tenantQueryURIs: tenantQueryURIs,
|
|
1990
2094
|
fabricVersion: fabricVersion
|
|
1991
2095
|
});
|
|
1992
|
-
case
|
|
1993
|
-
|
|
1994
|
-
|
|
2096
|
+
case 25:
|
|
2097
|
+
_context28.prev = 25;
|
|
2098
|
+
_context28.t0 = _context28["catch"](1);
|
|
1995
2099
|
// eslint-disable-next-line no-console
|
|
1996
2100
|
console.error("Error retrieving fabric configuration:");
|
|
1997
2101
|
// eslint-disable-next-line no-console
|
|
1998
|
-
console.error(
|
|
1999
|
-
throw
|
|
2000
|
-
case
|
|
2102
|
+
console.error(_context28.t0);
|
|
2103
|
+
throw _context28.t0;
|
|
2104
|
+
case 30:
|
|
2001
2105
|
case "end":
|
|
2002
|
-
return
|
|
2106
|
+
return _context28.stop();
|
|
2003
2107
|
}
|
|
2004
|
-
},
|
|
2108
|
+
}, _callee28, null, [[1, 25]]);
|
|
2005
2109
|
}));
|
|
2006
2110
|
function Configuration(_x23) {
|
|
2007
2111
|
return _Configuration.apply(this, arguments);
|
|
@@ -2040,20 +2144,20 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2040
2144
|
}, {
|
|
2041
2145
|
key: "FromNetworkName",
|
|
2042
2146
|
value: function () {
|
|
2043
|
-
var _FromNetworkName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
2044
|
-
var networkName, region, clientIP, trustAuthorityId, staticToken,
|
|
2045
|
-
return _regeneratorRuntime.wrap(function
|
|
2046
|
-
while (1) switch (
|
|
2147
|
+
var _FromNetworkName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29(_ref32) {
|
|
2148
|
+
var networkName, region, clientIP, trustAuthorityId, staticToken, _ref32$ethereumContra, ethereumContractTimeout, _ref32$noCache, noCache, _ref32$noAuth, noAuth, assumeV3, configUrl;
|
|
2149
|
+
return _regeneratorRuntime.wrap(function _callee29$(_context29) {
|
|
2150
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2047
2151
|
case 0:
|
|
2048
|
-
networkName =
|
|
2152
|
+
networkName = _ref32.networkName, region = _ref32.region, clientIP = _ref32.clientIP, trustAuthorityId = _ref32.trustAuthorityId, staticToken = _ref32.staticToken, _ref32$ethereumContra = _ref32.ethereumContractTimeout, ethereumContractTimeout = _ref32$ethereumContra === void 0 ? 10 : _ref32$ethereumContra, _ref32$noCache = _ref32.noCache, noCache = _ref32$noCache === void 0 ? false : _ref32$noCache, _ref32$noAuth = _ref32.noAuth, noAuth = _ref32$noAuth === void 0 ? false : _ref32$noAuth, assumeV3 = _ref32.assumeV3;
|
|
2049
2153
|
configUrl = this.Networks()[networkName];
|
|
2050
2154
|
if (configUrl) {
|
|
2051
|
-
|
|
2155
|
+
_context29.next = 4;
|
|
2052
2156
|
break;
|
|
2053
2157
|
}
|
|
2054
2158
|
throw Error("Invalid network name: " + networkName);
|
|
2055
2159
|
case 4:
|
|
2056
|
-
|
|
2160
|
+
_context29.next = 6;
|
|
2057
2161
|
return this.FromConfigurationUrl({
|
|
2058
2162
|
configUrl: configUrl,
|
|
2059
2163
|
region: region,
|
|
@@ -2066,12 +2170,12 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2066
2170
|
assumeV3: assumeV3
|
|
2067
2171
|
});
|
|
2068
2172
|
case 6:
|
|
2069
|
-
return
|
|
2173
|
+
return _context29.abrupt("return", _context29.sent);
|
|
2070
2174
|
case 7:
|
|
2071
2175
|
case "end":
|
|
2072
|
-
return
|
|
2176
|
+
return _context29.stop();
|
|
2073
2177
|
}
|
|
2074
|
-
},
|
|
2178
|
+
}, _callee29, this);
|
|
2075
2179
|
}));
|
|
2076
2180
|
function FromNetworkName(_x24) {
|
|
2077
2181
|
return _FromNetworkName.apply(this, arguments);
|
|
@@ -2097,20 +2201,20 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2097
2201
|
}, {
|
|
2098
2202
|
key: "FromConfigurationUrl",
|
|
2099
2203
|
value: function () {
|
|
2100
|
-
var _FromConfigurationUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
2101
|
-
var configUrl, region, clientIP, trustAuthorityId, staticToken,
|
|
2102
|
-
return _regeneratorRuntime.wrap(function
|
|
2103
|
-
while (1) switch (
|
|
2204
|
+
var _FromConfigurationUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30(_ref33) {
|
|
2205
|
+
var configUrl, region, clientIP, trustAuthorityId, staticToken, _ref33$ethereumContra, ethereumContractTimeout, _ref33$noCache, noCache, _ref33$noAuth, noAuth, _ref33$assumeV, assumeV3, _yield$ElvClient$Conf3, contentSpaceId, networkId, networkName, fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs, tenantQueryURIs, fabricVersion, client;
|
|
2206
|
+
return _regeneratorRuntime.wrap(function _callee30$(_context30) {
|
|
2207
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2104
2208
|
case 0:
|
|
2105
|
-
configUrl =
|
|
2106
|
-
|
|
2209
|
+
configUrl = _ref33.configUrl, region = _ref33.region, clientIP = _ref33.clientIP, trustAuthorityId = _ref33.trustAuthorityId, staticToken = _ref33.staticToken, _ref33$ethereumContra = _ref33.ethereumContractTimeout, ethereumContractTimeout = _ref33$ethereumContra === void 0 ? 10 : _ref33$ethereumContra, _ref33$noCache = _ref33.noCache, noCache = _ref33$noCache === void 0 ? false : _ref33$noCache, _ref33$noAuth = _ref33.noAuth, noAuth = _ref33$noAuth === void 0 ? false : _ref33$noAuth, _ref33$assumeV = _ref33.assumeV3, assumeV3 = _ref33$assumeV === void 0 ? false : _ref33$assumeV;
|
|
2210
|
+
_context30.next = 3;
|
|
2107
2211
|
return ElvClient.Configuration({
|
|
2108
2212
|
configUrl: configUrl,
|
|
2109
2213
|
clientIP: clientIP,
|
|
2110
2214
|
region: region
|
|
2111
2215
|
});
|
|
2112
2216
|
case 3:
|
|
2113
|
-
_yield$ElvClient$Conf3 =
|
|
2217
|
+
_yield$ElvClient$Conf3 = _context30.sent;
|
|
2114
2218
|
contentSpaceId = _yield$ElvClient$Conf3.contentSpaceId;
|
|
2115
2219
|
networkId = _yield$ElvClient$Conf3.networkId;
|
|
2116
2220
|
networkName = _yield$ElvClient$Conf3.networkName;
|
|
@@ -2119,6 +2223,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2119
2223
|
authServiceURIs = _yield$ElvClient$Conf3.authServiceURIs;
|
|
2120
2224
|
fileServiceURIs = _yield$ElvClient$Conf3.fileServiceURIs;
|
|
2121
2225
|
searchURIs = _yield$ElvClient$Conf3.searchURIs;
|
|
2226
|
+
tenantQueryURIs = _yield$ElvClient$Conf3.tenantQueryURIs;
|
|
2122
2227
|
fabricVersion = _yield$ElvClient$Conf3.fabricVersion;
|
|
2123
2228
|
client = new ElvClient({
|
|
2124
2229
|
contentSpaceId: contentSpaceId,
|
|
@@ -2130,6 +2235,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2130
2235
|
authServiceURIs: authServiceURIs,
|
|
2131
2236
|
fileServiceURIs: fileServiceURIs,
|
|
2132
2237
|
searchURIs: searchURIs,
|
|
2238
|
+
tenantQueryURIs: tenantQueryURIs,
|
|
2133
2239
|
ethereumContractTimeout: ethereumContractTimeout,
|
|
2134
2240
|
trustAuthorityId: trustAuthorityId,
|
|
2135
2241
|
staticToken: staticToken,
|
|
@@ -2140,12 +2246,12 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2140
2246
|
client.configUrl = configUrl;
|
|
2141
2247
|
client.region = region;
|
|
2142
2248
|
client.clientIP = clientIP;
|
|
2143
|
-
return
|
|
2144
|
-
case
|
|
2249
|
+
return _context30.abrupt("return", client);
|
|
2250
|
+
case 19:
|
|
2145
2251
|
case "end":
|
|
2146
|
-
return
|
|
2252
|
+
return _context30.stop();
|
|
2147
2253
|
}
|
|
2148
|
-
},
|
|
2254
|
+
}, _callee30);
|
|
2149
2255
|
}));
|
|
2150
2256
|
function FromConfigurationUrl(_x25) {
|
|
2151
2257
|
return _FromConfigurationUrl.apply(this, arguments);
|