@eluvio/elv-client-js 4.2.4 → 4.2.6
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 +710 -709
- package/dist/src/ContentObjectAudit.js +56 -56
- package/dist/src/ContentObjectVerification.js +281 -0
- package/dist/src/Crypto.js +85 -85
- package/dist/src/ElvClient.js +499 -529
- package/dist/src/ElvWallet.js +28 -30
- package/dist/src/EthClient.js +311 -311
- package/dist/src/FrameClient.js +64 -63
- package/dist/src/HttpClient.js +60 -60
- package/dist/src/Id.js +2 -1
- package/dist/src/PermissionsClient.js +487 -499
- package/dist/src/RemoteSigner.js +83 -82
- package/dist/src/UserProfileClient.js +374 -392
- package/dist/src/Utils.js +66 -69
- package/dist/src/Validation.js +10 -10
- package/dist/src/client/ABRPublishing.js +238 -238
- package/dist/src/client/AccessGroups.js +474 -477
- package/dist/src/client/ContentAccess.js +1709 -1705
- package/dist/src/client/ContentManagement.js +871 -871
- package/dist/src/client/Contracts.js +578 -575
- package/dist/src/client/Files.js +684 -700
- package/dist/src/client/LiveConf.js +3 -1
- package/dist/src/client/LiveStream.js +693 -694
- package/dist/src/client/NFT.js +14 -14
- package/dist/src/client/NTP.js +84 -84
- package/dist/src/client/Shares.js +60 -53
- package/dist/src/walletClient/ClientMethods.js +951 -977
- package/dist/src/walletClient/Notifications.js +14 -14
- package/dist/src/walletClient/Profile.js +66 -66
- package/dist/src/walletClient/Utils.js +15 -15
- package/dist/src/walletClient/index.js +562 -572
- package/package.json +1 -1
- package/src/Utils.js +1 -4
- package/src/client/ABRPublishing.js +1 -1
- package/src/client/LiveStream.js +77 -50
package/dist/src/ElvClient.js
CHANGED
|
@@ -147,7 +147,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
147
147
|
* @param {string=} clientIP - IP address to use in determining the region to use
|
|
148
148
|
* @return {Promise<Object>} - Object containing content space ID and fabric and ethereum URLs
|
|
149
149
|
*/
|
|
150
|
-
|
|
150
|
+
_createClass(ElvClient, [{
|
|
151
151
|
key: "Log",
|
|
152
152
|
value: function Log(message) {
|
|
153
153
|
var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -190,28 +190,28 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
190
190
|
}).forEach(function (methodName) {
|
|
191
191
|
var originalMethod = klass[methodName].bind(klass);
|
|
192
192
|
if (originalMethod.constructor.name === "AsyncFunction") {
|
|
193
|
-
klass[methodName] = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
193
|
+
klass[methodName] = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
194
194
|
var start,
|
|
195
195
|
_len,
|
|
196
196
|
args,
|
|
197
197
|
_key,
|
|
198
198
|
result,
|
|
199
199
|
_args = arguments;
|
|
200
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
200
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
201
201
|
while (1) switch (_context.prev = _context.next) {
|
|
202
202
|
case 0:
|
|
203
203
|
start = Date.now();
|
|
204
204
|
for (_len = _args.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
205
205
|
args[_key] = _args[_key];
|
|
206
206
|
}
|
|
207
|
-
_context.next =
|
|
207
|
+
_context.next = 4;
|
|
208
208
|
return originalMethod.apply(void 0, args);
|
|
209
|
-
case
|
|
209
|
+
case 4:
|
|
210
210
|
result = _context.sent;
|
|
211
211
|
// eslint-disable-next-line no-console
|
|
212
212
|
console.log(methodName, Date.now() - start, "ms", JSON.stringify(args));
|
|
213
213
|
return _context.abrupt("return", result);
|
|
214
|
-
case
|
|
214
|
+
case 7:
|
|
215
215
|
case "end":
|
|
216
216
|
return _context.stop();
|
|
217
217
|
}
|
|
@@ -236,14 +236,14 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
236
236
|
}, {
|
|
237
237
|
key: "InitializeClients",
|
|
238
238
|
value: function () {
|
|
239
|
-
var _InitializeClients = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
239
|
+
var _InitializeClients = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
240
240
|
var _ref3,
|
|
241
241
|
staticToken,
|
|
242
242
|
uris,
|
|
243
243
|
wallet,
|
|
244
244
|
signer,
|
|
245
245
|
_args2 = arguments;
|
|
246
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
246
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
247
247
|
while (1) switch (_context2.prev = _context2.next) {
|
|
248
248
|
case 0:
|
|
249
249
|
_ref3 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, staticToken = _ref3.staticToken;
|
|
@@ -311,7 +311,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
311
311
|
// Initialize crypto wasm
|
|
312
312
|
this.Crypto = Crypto;
|
|
313
313
|
this.Crypto.ElvCrypto();
|
|
314
|
-
case
|
|
314
|
+
case 21:
|
|
315
315
|
case "end":
|
|
316
316
|
return _context2.stop();
|
|
317
317
|
}
|
|
@@ -348,25 +348,25 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
348
348
|
*/
|
|
349
349
|
}, {
|
|
350
350
|
key: "UseRegion",
|
|
351
|
-
value:
|
|
352
|
-
var _UseRegion = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref4) {
|
|
351
|
+
value: function () {
|
|
352
|
+
var _UseRegion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref4) {
|
|
353
353
|
var region, _yield$ElvClient$Conf, fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs;
|
|
354
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
354
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
355
355
|
while (1) switch (_context3.prev = _context3.next) {
|
|
356
356
|
case 0:
|
|
357
357
|
region = _ref4.region;
|
|
358
358
|
if (this.configUrl) {
|
|
359
|
-
_context3.next =
|
|
359
|
+
_context3.next = 3;
|
|
360
360
|
break;
|
|
361
361
|
}
|
|
362
362
|
throw Error("Unable to change region: Configuration URL not set");
|
|
363
|
-
case
|
|
364
|
-
_context3.next =
|
|
363
|
+
case 3:
|
|
364
|
+
_context3.next = 5;
|
|
365
365
|
return ElvClient.Configuration({
|
|
366
366
|
configUrl: this.configUrl,
|
|
367
367
|
region: region
|
|
368
368
|
});
|
|
369
|
-
case
|
|
369
|
+
case 5:
|
|
370
370
|
_yield$ElvClient$Conf = _context3.sent;
|
|
371
371
|
fabricURIs = _yield$ElvClient$Conf.fabricURIs;
|
|
372
372
|
ethereumURIs = _yield$ElvClient$Conf.ethereumURIs;
|
|
@@ -388,7 +388,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
388
388
|
authServiceURIs: authServiceURIs,
|
|
389
389
|
searchURIs: searchURIs
|
|
390
390
|
});
|
|
391
|
-
case
|
|
391
|
+
case 14:
|
|
392
392
|
case "end":
|
|
393
393
|
return _context3.stop();
|
|
394
394
|
}
|
|
@@ -408,27 +408,26 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
408
408
|
*
|
|
409
409
|
* @return {Promise<Object>} - An object containing the updated fabric and ethereum URLs in order of preference
|
|
410
410
|
*/
|
|
411
|
-
)
|
|
412
411
|
}, {
|
|
413
412
|
key: "ResetRegion",
|
|
414
|
-
value:
|
|
415
|
-
var _ResetRegion = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
416
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
413
|
+
value: function () {
|
|
414
|
+
var _ResetRegion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
415
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
417
416
|
while (1) switch (_context4.prev = _context4.next) {
|
|
418
417
|
case 0:
|
|
419
418
|
if (this.configUrl) {
|
|
420
|
-
_context4.next =
|
|
419
|
+
_context4.next = 2;
|
|
421
420
|
break;
|
|
422
421
|
}
|
|
423
422
|
throw Error("Unable to change region: Configuration URL not set");
|
|
424
|
-
case
|
|
425
|
-
_context4.next =
|
|
423
|
+
case 2:
|
|
424
|
+
_context4.next = 4;
|
|
426
425
|
return this.UseRegion({
|
|
427
426
|
region: ""
|
|
428
427
|
});
|
|
429
|
-
case
|
|
428
|
+
case 4:
|
|
430
429
|
return _context4.abrupt("return", _context4.sent);
|
|
431
|
-
case
|
|
430
|
+
case 5:
|
|
432
431
|
case "end":
|
|
433
432
|
return _context4.stop();
|
|
434
433
|
}
|
|
@@ -451,26 +450,25 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
451
450
|
*
|
|
452
451
|
* @return {Promise<string>} - The node ID reported by the fabric
|
|
453
452
|
*/
|
|
454
|
-
)
|
|
455
453
|
}, {
|
|
456
454
|
key: "NodeId",
|
|
457
|
-
value:
|
|
458
|
-
var _NodeId = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref5) {
|
|
455
|
+
value: function () {
|
|
456
|
+
var _NodeId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref5) {
|
|
459
457
|
var region, _yield$ElvClient$Conf2, nodeId;
|
|
460
|
-
return _regeneratorRuntime.wrap(function (_context5) {
|
|
458
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
461
459
|
while (1) switch (_context5.prev = _context5.next) {
|
|
462
460
|
case 0:
|
|
463
461
|
region = _ref5.region;
|
|
464
|
-
_context5.next =
|
|
462
|
+
_context5.next = 3;
|
|
465
463
|
return ElvClient.Configuration({
|
|
466
464
|
configUrl: this.configUrl,
|
|
467
465
|
region: region
|
|
468
466
|
});
|
|
469
|
-
case
|
|
467
|
+
case 3:
|
|
470
468
|
_yield$ElvClient$Conf2 = _context5.sent;
|
|
471
469
|
nodeId = _yield$ElvClient$Conf2.nodeId;
|
|
472
470
|
return _context5.abrupt("return", nodeId);
|
|
473
|
-
case
|
|
471
|
+
case 6:
|
|
474
472
|
case "end":
|
|
475
473
|
return _context5.stop();
|
|
476
474
|
}
|
|
@@ -488,7 +486,6 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
488
486
|
*
|
|
489
487
|
* @return {Promise<Object>} - An object containing the lists of fabric, ethereum, auth service, and search urls in use by the client
|
|
490
488
|
*/
|
|
491
|
-
)
|
|
492
489
|
}, {
|
|
493
490
|
key: "Nodes",
|
|
494
491
|
value: function Nodes() {
|
|
@@ -561,8 +558,8 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
561
558
|
*/
|
|
562
559
|
}, {
|
|
563
560
|
key: "SpaceNodes",
|
|
564
|
-
value:
|
|
565
|
-
var _SpaceNodes = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
561
|
+
value: function () {
|
|
562
|
+
var _SpaceNodes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
566
563
|
var _this = this;
|
|
567
564
|
var _ref7,
|
|
568
565
|
matchEndpoint,
|
|
@@ -574,16 +571,16 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
574
571
|
_yield$this$utils$Res2,
|
|
575
572
|
_nodes,
|
|
576
573
|
_args6 = arguments;
|
|
577
|
-
return _regeneratorRuntime.wrap(function (_context6) {
|
|
574
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
578
575
|
while (1) switch (_context6.prev = _context6.next) {
|
|
579
576
|
case 0:
|
|
580
577
|
_ref7 = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {}, matchEndpoint = _ref7.matchEndpoint, matchNodeId = _ref7.matchNodeId, matchWriteToken = _ref7.matchWriteToken;
|
|
581
578
|
this.SetStaticToken();
|
|
582
579
|
if (!matchEndpoint) {
|
|
583
|
-
_context6.next =
|
|
580
|
+
_context6.next = 12;
|
|
584
581
|
break;
|
|
585
582
|
}
|
|
586
|
-
_context6.next =
|
|
583
|
+
_context6.next = 5;
|
|
587
584
|
return this.utils.ResponseToJson(this.HttpClient.Request({
|
|
588
585
|
path: UrlJoin("nodes"),
|
|
589
586
|
method: "GET",
|
|
@@ -591,15 +588,15 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
591
588
|
Authorization: "Bearer ".concat(this.staticToken)
|
|
592
589
|
}
|
|
593
590
|
}));
|
|
594
|
-
case
|
|
591
|
+
case 5:
|
|
595
592
|
_yield$this$utils$Res = _context6.sent;
|
|
596
593
|
nodes = _yield$this$utils$Res.nodes;
|
|
597
594
|
if (!(!nodes || !Array.isArray(nodes) || nodes.length === 0)) {
|
|
598
|
-
_context6.next =
|
|
595
|
+
_context6.next = 9;
|
|
599
596
|
break;
|
|
600
597
|
}
|
|
601
598
|
return _context6.abrupt("return", []);
|
|
602
|
-
case
|
|
599
|
+
case 9:
|
|
603
600
|
return _context6.abrupt("return", nodes.filter(function (node) {
|
|
604
601
|
var match = false;
|
|
605
602
|
if (node.services && node.services.fabric_api && node.services.fabric_api.urls) {
|
|
@@ -616,13 +613,13 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
616
613
|
_this.ClearStaticToken();
|
|
617
614
|
return match;
|
|
618
615
|
}));
|
|
619
|
-
case
|
|
616
|
+
case 12:
|
|
620
617
|
if (!matchNodeId) {
|
|
621
|
-
_context6.next =
|
|
618
|
+
_context6.next = 21;
|
|
622
619
|
break;
|
|
623
620
|
}
|
|
624
621
|
this.SetStaticToken();
|
|
625
|
-
_context6.next =
|
|
622
|
+
_context6.next = 16;
|
|
626
623
|
return this.utils.ResponseToJson(this.HttpClient.Request({
|
|
627
624
|
path: UrlJoin("nodes", matchNodeId),
|
|
628
625
|
method: "GET",
|
|
@@ -630,17 +627,17 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
630
627
|
Authorization: "Bearer ".concat(this.staticToken)
|
|
631
628
|
}
|
|
632
629
|
}));
|
|
633
|
-
case
|
|
630
|
+
case 16:
|
|
634
631
|
node = _context6.sent;
|
|
635
632
|
this.ClearStaticToken();
|
|
636
633
|
return _context6.abrupt("return", [node]);
|
|
637
|
-
case
|
|
634
|
+
case 21:
|
|
638
635
|
if (!matchWriteToken) {
|
|
639
|
-
_context6.next =
|
|
636
|
+
_context6.next = 29;
|
|
640
637
|
break;
|
|
641
638
|
}
|
|
642
639
|
this.SetStaticToken();
|
|
643
|
-
_context6.next =
|
|
640
|
+
_context6.next = 25;
|
|
644
641
|
return this.utils.ResponseToJson(this.HttpClient.Request({
|
|
645
642
|
path: UrlJoin("nodes"),
|
|
646
643
|
method: "GET",
|
|
@@ -651,12 +648,12 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
651
648
|
token: matchWriteToken
|
|
652
649
|
}
|
|
653
650
|
}));
|
|
654
|
-
case
|
|
651
|
+
case 25:
|
|
655
652
|
_yield$this$utils$Res2 = _context6.sent;
|
|
656
653
|
_nodes = _yield$this$utils$Res2.nodes;
|
|
657
654
|
this.ClearStaticToken();
|
|
658
655
|
return _context6.abrupt("return", _nodes);
|
|
659
|
-
case
|
|
656
|
+
case 29:
|
|
660
657
|
case "end":
|
|
661
658
|
return _context6.stop();
|
|
662
659
|
}
|
|
@@ -673,7 +670,6 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
673
670
|
* @methodGroup Nodes
|
|
674
671
|
* @returns {Object} - The name, ID and configuration URL of the network
|
|
675
672
|
*/
|
|
676
|
-
)
|
|
677
673
|
}, {
|
|
678
674
|
key: "NetworkInfo",
|
|
679
675
|
value: function NetworkInfo() {
|
|
@@ -695,31 +691,31 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
695
691
|
*/
|
|
696
692
|
}, {
|
|
697
693
|
key: "WriteTokenNodeUrlNetwork",
|
|
698
|
-
value:
|
|
699
|
-
var _WriteTokenNodeUrlNetwork = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref8) {
|
|
694
|
+
value: function () {
|
|
695
|
+
var _WriteTokenNodeUrlNetwork = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref8) {
|
|
700
696
|
var writeToken, nodes, nodeUrl;
|
|
701
|
-
return _regeneratorRuntime.wrap(function (_context7) {
|
|
697
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
702
698
|
while (1) switch (_context7.prev = _context7.next) {
|
|
703
699
|
case 0:
|
|
704
700
|
writeToken = _ref8.writeToken;
|
|
705
701
|
ValidateWriteToken(writeToken);
|
|
706
|
-
_context7.next =
|
|
702
|
+
_context7.next = 4;
|
|
707
703
|
return this.SpaceNodes({
|
|
708
704
|
matchWriteToken: writeToken
|
|
709
705
|
});
|
|
710
|
-
case
|
|
706
|
+
case 4:
|
|
711
707
|
nodes = _context7.sent;
|
|
712
708
|
nodeUrl = nodes && nodes[0] && nodes[0].services && nodes[0].services.fabric_api && nodes[0].services.fabric_api.urls && nodes[0].services.fabric_api.urls[0];
|
|
713
709
|
if (nodeUrl) {
|
|
714
|
-
_context7.next =
|
|
710
|
+
_context7.next = 9;
|
|
715
711
|
break;
|
|
716
712
|
}
|
|
717
713
|
// eslint-disable-next-line no-console
|
|
718
714
|
console.error("No node url found for write token: ".concat(writeToken));
|
|
719
715
|
return _context7.abrupt("return", "");
|
|
720
|
-
case
|
|
716
|
+
case 9:
|
|
721
717
|
return _context7.abrupt("return", nodeUrl ? nodeUrl.toString() : undefined);
|
|
722
|
-
case
|
|
718
|
+
case 10:
|
|
723
719
|
case "end":
|
|
724
720
|
return _context7.stop();
|
|
725
721
|
}
|
|
@@ -739,7 +735,6 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
739
735
|
*
|
|
740
736
|
* @returns {string} - The node url for a write token
|
|
741
737
|
*/
|
|
742
|
-
)
|
|
743
738
|
}, {
|
|
744
739
|
key: "WriteTokenNodeUrlLocal",
|
|
745
740
|
value: function WriteTokenNodeUrlLocal(_ref9) {
|
|
@@ -750,9 +745,9 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
750
745
|
}
|
|
751
746
|
}, {
|
|
752
747
|
key: "RecordWriteToken",
|
|
753
|
-
value: function RecordWriteToken(
|
|
754
|
-
var writeToken =
|
|
755
|
-
fabricNodeUrl =
|
|
748
|
+
value: function RecordWriteToken(_ref10) {
|
|
749
|
+
var writeToken = _ref10.writeToken,
|
|
750
|
+
fabricNodeUrl = _ref10.fabricNodeUrl;
|
|
756
751
|
this.HttpClient.RecordWriteToken(writeToken, fabricNodeUrl);
|
|
757
752
|
}
|
|
758
753
|
|
|
@@ -802,10 +797,10 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
802
797
|
*/
|
|
803
798
|
}, {
|
|
804
799
|
key: "SetSigner",
|
|
805
|
-
value: function SetSigner(
|
|
806
|
-
var signer =
|
|
807
|
-
|
|
808
|
-
reset =
|
|
800
|
+
value: function SetSigner(_ref11) {
|
|
801
|
+
var signer = _ref11.signer,
|
|
802
|
+
_ref11$reset = _ref11.reset,
|
|
803
|
+
reset = _ref11$reset === void 0 ? true : _ref11$reset;
|
|
809
804
|
this.staticToken = undefined;
|
|
810
805
|
signer.connect(this.ethClient.Provider());
|
|
811
806
|
signer.provider.pollingInterval = 500;
|
|
@@ -829,41 +824,41 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
829
824
|
*/
|
|
830
825
|
}, {
|
|
831
826
|
key: "SetRemoteSigner",
|
|
832
|
-
value:
|
|
833
|
-
var _SetRemoteSigner = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(
|
|
834
|
-
var idToken, authToken, tenantId, extraData, signerURIs, unsignedPublicAuth, signer
|
|
835
|
-
return _regeneratorRuntime.wrap(function (_context8) {
|
|
827
|
+
value: function () {
|
|
828
|
+
var _SetRemoteSigner = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref12) {
|
|
829
|
+
var idToken, authToken, tenantId, extraData, signerURIs, unsignedPublicAuth, signer;
|
|
830
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
836
831
|
while (1) switch (_context8.prev = _context8.next) {
|
|
837
832
|
case 0:
|
|
838
|
-
idToken =
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
_context8.next =
|
|
833
|
+
idToken = _ref12.idToken, authToken = _ref12.authToken, tenantId = _ref12.tenantId, extraData = _ref12.extraData, signerURIs = _ref12.signerURIs, unsignedPublicAuth = _ref12.unsignedPublicAuth;
|
|
834
|
+
_context8.t0 = RemoteSigner;
|
|
835
|
+
_context8.t1 = signerURIs || this.authServiceURIs;
|
|
836
|
+
_context8.t2 = idToken;
|
|
837
|
+
_context8.t3 = authToken;
|
|
838
|
+
_context8.t4 = tenantId;
|
|
839
|
+
_context8.next = 8;
|
|
845
840
|
return this.ethClient.Provider();
|
|
846
|
-
case
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
signerURIs:
|
|
852
|
-
idToken:
|
|
853
|
-
authToken:
|
|
854
|
-
tenantId:
|
|
855
|
-
provider:
|
|
856
|
-
extraData:
|
|
857
|
-
unsignedPublicAuth:
|
|
841
|
+
case 8:
|
|
842
|
+
_context8.t5 = _context8.sent;
|
|
843
|
+
_context8.t6 = extraData;
|
|
844
|
+
_context8.t7 = unsignedPublicAuth;
|
|
845
|
+
_context8.t8 = {
|
|
846
|
+
signerURIs: _context8.t1,
|
|
847
|
+
idToken: _context8.t2,
|
|
848
|
+
authToken: _context8.t3,
|
|
849
|
+
tenantId: _context8.t4,
|
|
850
|
+
provider: _context8.t5,
|
|
851
|
+
extraData: _context8.t6,
|
|
852
|
+
unsignedPublicAuth: _context8.t7
|
|
858
853
|
};
|
|
859
|
-
signer = new
|
|
860
|
-
_context8.next =
|
|
854
|
+
signer = new _context8.t0(_context8.t8);
|
|
855
|
+
_context8.next = 15;
|
|
861
856
|
return signer.Initialize();
|
|
862
|
-
case
|
|
857
|
+
case 15:
|
|
863
858
|
this.SetSigner({
|
|
864
859
|
signer: signer
|
|
865
860
|
});
|
|
866
|
-
case
|
|
861
|
+
case 16:
|
|
867
862
|
case "end":
|
|
868
863
|
return _context8.stop();
|
|
869
864
|
}
|
|
@@ -884,27 +879,26 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
884
879
|
* @namedParams
|
|
885
880
|
* @param {object} provider - The web3 provider object
|
|
886
881
|
*/
|
|
887
|
-
)
|
|
888
882
|
}, {
|
|
889
883
|
key: "SetSignerFromWeb3Provider",
|
|
890
|
-
value:
|
|
891
|
-
var _SetSignerFromWeb3Provider = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(
|
|
884
|
+
value: function () {
|
|
885
|
+
var _SetSignerFromWeb3Provider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref13) {
|
|
892
886
|
var provider, ethProvider;
|
|
893
|
-
return _regeneratorRuntime.wrap(function (_context9) {
|
|
887
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
894
888
|
while (1) switch (_context9.prev = _context9.next) {
|
|
895
889
|
case 0:
|
|
896
|
-
provider =
|
|
890
|
+
provider = _ref13.provider;
|
|
897
891
|
this.staticToken = undefined;
|
|
898
892
|
ethProvider = new Ethers.providers.Web3Provider(provider);
|
|
899
893
|
ethProvider.pollingInterval = 250;
|
|
900
894
|
this.signer = ethProvider.getSigner();
|
|
901
|
-
_context9.next =
|
|
895
|
+
_context9.next = 7;
|
|
902
896
|
return this.signer.getAddress();
|
|
903
|
-
case
|
|
897
|
+
case 7:
|
|
904
898
|
this.signer.address = _context9.sent;
|
|
905
|
-
_context9.next =
|
|
899
|
+
_context9.next = 10;
|
|
906
900
|
return this.InitializeClients();
|
|
907
|
-
case
|
|
901
|
+
case 10:
|
|
908
902
|
case "end":
|
|
909
903
|
return _context9.stop();
|
|
910
904
|
}
|
|
@@ -930,16 +924,15 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
930
924
|
*
|
|
931
925
|
* @return {string} - The address of the user
|
|
932
926
|
*/
|
|
933
|
-
)
|
|
934
927
|
}, {
|
|
935
928
|
key: "CreateAccount",
|
|
936
|
-
value:
|
|
937
|
-
var _CreateAccount = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
938
|
-
var tenantId, fundingToken,
|
|
939
|
-
return _regeneratorRuntime.wrap(function (
|
|
940
|
-
while (1) switch (
|
|
929
|
+
value: function () {
|
|
930
|
+
var _CreateAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref14) {
|
|
931
|
+
var tenantId, fundingToken, _ref14$funds, funds, groupToken, wallet, signer;
|
|
932
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
933
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
941
934
|
case 0:
|
|
942
|
-
tenantId =
|
|
935
|
+
tenantId = _ref14.tenantId, fundingToken = _ref14.fundingToken, _ref14$funds = _ref14.funds, funds = _ref14$funds === void 0 ? 0.5 : _ref14$funds, groupToken = _ref14.groupToken;
|
|
943
936
|
if (!this.signer) {
|
|
944
937
|
wallet = this.GenerateWallet();
|
|
945
938
|
signer = wallet.AddAccountFromMnemonic({
|
|
@@ -949,7 +942,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
949
942
|
signer: signer
|
|
950
943
|
});
|
|
951
944
|
}
|
|
952
|
-
|
|
945
|
+
_context10.next = 4;
|
|
953
946
|
return this.authClient.MakeKMSRequest({
|
|
954
947
|
method: "POST",
|
|
955
948
|
path: "/ks/otp/fnd/".concat(tenantId),
|
|
@@ -961,21 +954,21 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
961
954
|
Authorization: "Bearer ".concat(fundingToken)
|
|
962
955
|
}
|
|
963
956
|
});
|
|
964
|
-
case
|
|
965
|
-
|
|
957
|
+
case 4:
|
|
958
|
+
_context10.next = 6;
|
|
966
959
|
return this.userProfileClient.CreateWallet();
|
|
967
|
-
case
|
|
968
|
-
|
|
960
|
+
case 6:
|
|
961
|
+
_context10.next = 8;
|
|
969
962
|
return this.userProfileClient.ReplaceUserMetadata({
|
|
970
963
|
metadataSubtree: "tenantContractId",
|
|
971
964
|
metadata: tenantId
|
|
972
965
|
});
|
|
973
|
-
case
|
|
966
|
+
case 8:
|
|
974
967
|
if (!groupToken) {
|
|
975
|
-
|
|
968
|
+
_context10.next = 11;
|
|
976
969
|
break;
|
|
977
970
|
}
|
|
978
|
-
|
|
971
|
+
_context10.next = 11;
|
|
979
972
|
return this.authClient.MakeKMSRequest({
|
|
980
973
|
method: "POST",
|
|
981
974
|
path: "/ks/otp/grp/".concat(tenantId),
|
|
@@ -986,13 +979,13 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
986
979
|
Authorization: "Bearer ".concat(groupToken)
|
|
987
980
|
}
|
|
988
981
|
});
|
|
989
|
-
case
|
|
990
|
-
return
|
|
991
|
-
case
|
|
982
|
+
case 11:
|
|
983
|
+
return _context10.abrupt("return", this.utils.FormatAddress(this.signer.address));
|
|
984
|
+
case 12:
|
|
992
985
|
case "end":
|
|
993
|
-
return
|
|
986
|
+
return _context10.stop();
|
|
994
987
|
}
|
|
995
|
-
},
|
|
988
|
+
}, _callee10, this);
|
|
996
989
|
}));
|
|
997
990
|
function CreateAccount(_x6) {
|
|
998
991
|
return _CreateAccount.apply(this, arguments);
|
|
@@ -1008,67 +1001,65 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1008
1001
|
PAYLOAD 85b json-compressed
|
|
1009
1002
|
json 79b {"adr":"VVf4DQU357tDnZGYQeDrntRJ5rs=","spc":"ispc3ANoVSzNA3P6t7abLR69ho5YPPZU"}
|
|
1010
1003
|
*/
|
|
1011
|
-
)
|
|
1012
1004
|
}, {
|
|
1013
1005
|
key: "PersonalSign",
|
|
1014
|
-
value:
|
|
1015
|
-
var _PersonalSign = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1006
|
+
value: function () {
|
|
1007
|
+
var _PersonalSign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref15) {
|
|
1016
1008
|
var _this2 = this;
|
|
1017
1009
|
var message, addEthereumPrefix, Sign;
|
|
1018
|
-
return _regeneratorRuntime.wrap(function (
|
|
1019
|
-
while (1) switch (
|
|
1010
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
1011
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1020
1012
|
case 0:
|
|
1021
|
-
message =
|
|
1013
|
+
message = _ref15.message, addEthereumPrefix = _ref15.addEthereumPrefix, Sign = _ref15.Sign;
|
|
1022
1014
|
if (!Sign) {
|
|
1023
1015
|
// Same as authClient.Sign, but authClient may not yet be initialized
|
|
1024
1016
|
Sign = /*#__PURE__*/function () {
|
|
1025
|
-
var
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
while (1) switch (_context1.prev = _context1.next) {
|
|
1017
|
+
var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(message) {
|
|
1018
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
1019
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1029
1020
|
case 0:
|
|
1030
|
-
|
|
1021
|
+
_context11.t0 = Ethers.utils;
|
|
1031
1022
|
if (!_this2.signer.signDigest) {
|
|
1032
|
-
|
|
1023
|
+
_context11.next = 7;
|
|
1033
1024
|
break;
|
|
1034
1025
|
}
|
|
1035
|
-
|
|
1026
|
+
_context11.next = 4;
|
|
1036
1027
|
return _this2.signer.signDigest(message);
|
|
1037
|
-
case
|
|
1038
|
-
|
|
1039
|
-
|
|
1028
|
+
case 4:
|
|
1029
|
+
_context11.t1 = _context11.sent;
|
|
1030
|
+
_context11.next = 10;
|
|
1040
1031
|
break;
|
|
1041
|
-
case
|
|
1042
|
-
|
|
1032
|
+
case 7:
|
|
1033
|
+
_context11.next = 9;
|
|
1043
1034
|
return _this2.signer._signingKey().signDigest(message);
|
|
1044
|
-
case
|
|
1045
|
-
|
|
1046
|
-
case
|
|
1047
|
-
|
|
1048
|
-
return
|
|
1049
|
-
case
|
|
1035
|
+
case 9:
|
|
1036
|
+
_context11.t1 = _context11.sent;
|
|
1037
|
+
case 10:
|
|
1038
|
+
_context11.t2 = _context11.t1;
|
|
1039
|
+
return _context11.abrupt("return", _context11.t0.joinSignature.call(_context11.t0, _context11.t2));
|
|
1040
|
+
case 12:
|
|
1050
1041
|
case "end":
|
|
1051
|
-
return
|
|
1042
|
+
return _context11.stop();
|
|
1052
1043
|
}
|
|
1053
|
-
},
|
|
1044
|
+
}, _callee11);
|
|
1054
1045
|
}));
|
|
1055
1046
|
return function Sign(_x8) {
|
|
1056
|
-
return
|
|
1047
|
+
return _ref16.apply(this, arguments);
|
|
1057
1048
|
};
|
|
1058
1049
|
}();
|
|
1059
1050
|
}
|
|
1060
1051
|
if (addEthereumPrefix) {
|
|
1061
1052
|
message = Ethers.utils.keccak256(Buffer.from("\x19Ethereum Signed Message:\n".concat(message.length).concat(message), "utf-8"));
|
|
1062
1053
|
}
|
|
1063
|
-
|
|
1054
|
+
_context12.next = 5;
|
|
1064
1055
|
return Sign(message);
|
|
1065
|
-
case
|
|
1066
|
-
return
|
|
1067
|
-
case
|
|
1056
|
+
case 5:
|
|
1057
|
+
return _context12.abrupt("return", _context12.sent);
|
|
1058
|
+
case 6:
|
|
1068
1059
|
case "end":
|
|
1069
|
-
return
|
|
1060
|
+
return _context12.stop();
|
|
1070
1061
|
}
|
|
1071
|
-
},
|
|
1062
|
+
}, _callee12);
|
|
1072
1063
|
}));
|
|
1073
1064
|
function PersonalSign(_x7) {
|
|
1074
1065
|
return _PersonalSign.apply(this, arguments);
|
|
@@ -1086,79 +1077,68 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1086
1077
|
* @param {function=} Sign - If specified, this function will be used to produce the signature instead of the client's current signer
|
|
1087
1078
|
* @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)
|
|
1088
1079
|
*/
|
|
1089
|
-
)
|
|
1090
1080
|
}, {
|
|
1091
1081
|
key: "CreateFabricToken",
|
|
1092
|
-
value:
|
|
1093
|
-
var _CreateFabricToken = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1094
|
-
var
|
|
1095
|
-
|
|
1082
|
+
value: function () {
|
|
1083
|
+
var _CreateFabricToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
|
|
1084
|
+
var _ref17,
|
|
1085
|
+
_ref17$duration,
|
|
1096
1086
|
duration,
|
|
1097
|
-
|
|
1087
|
+
_ref17$spec,
|
|
1098
1088
|
spec,
|
|
1099
1089
|
address,
|
|
1100
1090
|
Sign,
|
|
1101
|
-
|
|
1091
|
+
_ref17$addEthereumPre,
|
|
1102
1092
|
addEthereumPrefix,
|
|
1103
|
-
|
|
1093
|
+
_ref17$context,
|
|
1104
1094
|
context,
|
|
1105
1095
|
token,
|
|
1106
1096
|
message,
|
|
1107
1097
|
signature,
|
|
1108
1098
|
compressedToken,
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
_t13,
|
|
1113
|
-
_t14,
|
|
1114
|
-
_t15,
|
|
1115
|
-
_t16,
|
|
1116
|
-
_t17,
|
|
1117
|
-
_t18,
|
|
1118
|
-
_t19,
|
|
1119
|
-
_t20;
|
|
1120
|
-
return _regeneratorRuntime.wrap(function (_context11) {
|
|
1121
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
1099
|
+
_args13 = arguments;
|
|
1100
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
1101
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1122
1102
|
case 0:
|
|
1123
|
-
|
|
1103
|
+
_ref17 = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {}, _ref17$duration = _ref17.duration, duration = _ref17$duration === void 0 ? 24 * 60 * 60 * 1000 : _ref17$duration, _ref17$spec = _ref17.spec, spec = _ref17$spec === void 0 ? {} : _ref17$spec, address = _ref17.address, Sign = _ref17.Sign, _ref17$addEthereumPre = _ref17.addEthereumPrefix, addEthereumPrefix = _ref17$addEthereumPre === void 0 ? true : _ref17$addEthereumPre, _ref17$context = _ref17.context, context = _ref17$context === void 0 ? {} : _ref17$context;
|
|
1124
1104
|
address = address || this.CurrentAccountAddress();
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1105
|
+
_context13.t0 = _objectSpread;
|
|
1106
|
+
_context13.t1 = _objectSpread({}, spec);
|
|
1107
|
+
_context13.t2 = {};
|
|
1108
|
+
_context13.t3 = "iusr".concat(Utils.AddressToHash(address));
|
|
1109
|
+
_context13.t4 = Buffer.from(address.replace(/^0x/, ""), "hex").toString("base64");
|
|
1110
|
+
_context13.next = 9;
|
|
1131
1111
|
return this.ContentSpaceId();
|
|
1132
|
-
case
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
sub:
|
|
1139
|
-
adr:
|
|
1140
|
-
spc:
|
|
1141
|
-
iat:
|
|
1142
|
-
exp:
|
|
1143
|
-
ctx:
|
|
1112
|
+
case 9:
|
|
1113
|
+
_context13.t5 = _context13.sent;
|
|
1114
|
+
_context13.t6 = Date.now();
|
|
1115
|
+
_context13.t7 = Date.now() + duration;
|
|
1116
|
+
_context13.t8 = context;
|
|
1117
|
+
_context13.t9 = {
|
|
1118
|
+
sub: _context13.t3,
|
|
1119
|
+
adr: _context13.t4,
|
|
1120
|
+
spc: _context13.t5,
|
|
1121
|
+
iat: _context13.t6,
|
|
1122
|
+
exp: _context13.t7,
|
|
1123
|
+
ctx: _context13.t8
|
|
1144
1124
|
};
|
|
1145
|
-
token =
|
|
1125
|
+
token = (0, _context13.t0)(_context13.t1, _context13.t2, _context13.t9);
|
|
1146
1126
|
message = "Eluvio Content Fabric Access Token 1.0\n".concat(JSON.stringify(token));
|
|
1147
|
-
|
|
1127
|
+
_context13.next = 18;
|
|
1148
1128
|
return this.PersonalSign({
|
|
1149
1129
|
message: message,
|
|
1150
1130
|
addEthereumPrefix: addEthereumPrefix,
|
|
1151
1131
|
Sign: Sign
|
|
1152
1132
|
});
|
|
1153
|
-
case
|
|
1154
|
-
signature =
|
|
1133
|
+
case 18:
|
|
1134
|
+
signature = _context13.sent;
|
|
1155
1135
|
compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
|
|
1156
|
-
return
|
|
1157
|
-
case
|
|
1136
|
+
return _context13.abrupt("return", "acspjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
|
|
1137
|
+
case 21:
|
|
1158
1138
|
case "end":
|
|
1159
|
-
return
|
|
1139
|
+
return _context13.stop();
|
|
1160
1140
|
}
|
|
1161
|
-
},
|
|
1141
|
+
}, _callee13, this);
|
|
1162
1142
|
}));
|
|
1163
1143
|
function CreateFabricToken() {
|
|
1164
1144
|
return _CreateFabricToken.apply(this, arguments);
|
|
@@ -1183,127 +1163,126 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1183
1163
|
* @param {number=} issueTime - Issue Time in milliseconds
|
|
1184
1164
|
* @param {number=} expirationTime - Expiration Time in milliseconds
|
|
1185
1165
|
*/
|
|
1186
|
-
)
|
|
1187
1166
|
}, {
|
|
1188
1167
|
key: "CreateSignedToken",
|
|
1189
|
-
value:
|
|
1190
|
-
var _CreateSignedToken = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1191
|
-
var libraryId, objectId, versionHash, policyId, subject,
|
|
1192
|
-
return _regeneratorRuntime.wrap(function (
|
|
1193
|
-
while (1) switch (
|
|
1168
|
+
value: function () {
|
|
1169
|
+
var _CreateSignedToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref18) {
|
|
1170
|
+
var libraryId, objectId, versionHash, policyId, subject, _ref18$grantType, grantType, _ref18$allowDecryptio, allowDecryption, duration, _ref18$context, context, issueTime, expirationTime, issueDateTime, token, cap, compressedToken, signature;
|
|
1171
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
1172
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1194
1173
|
case 0:
|
|
1195
|
-
libraryId =
|
|
1174
|
+
libraryId = _ref18.libraryId, objectId = _ref18.objectId, versionHash = _ref18.versionHash, policyId = _ref18.policyId, subject = _ref18.subject, _ref18$grantType = _ref18.grantType, grantType = _ref18$grantType === void 0 ? "read" : _ref18$grantType, _ref18$allowDecryptio = _ref18.allowDecryption, allowDecryption = _ref18$allowDecryptio === void 0 ? false : _ref18$allowDecryptio, duration = _ref18.duration, _ref18$context = _ref18.context, context = _ref18$context === void 0 ? {} : _ref18$context, issueTime = _ref18.issueTime, expirationTime = _ref18.expirationTime;
|
|
1196
1175
|
if (subject) {
|
|
1197
|
-
|
|
1176
|
+
_context14.next = 9;
|
|
1198
1177
|
break;
|
|
1199
1178
|
}
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1179
|
+
_context14.t0 = "iusr";
|
|
1180
|
+
_context14.t1 = this.utils;
|
|
1181
|
+
_context14.next = 6;
|
|
1203
1182
|
return this.CurrentAccountAddress();
|
|
1204
|
-
case
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
subject =
|
|
1208
|
-
case
|
|
1183
|
+
case 6:
|
|
1184
|
+
_context14.t2 = _context14.sent;
|
|
1185
|
+
_context14.t3 = _context14.t1.AddressToHash.call(_context14.t1, _context14.t2);
|
|
1186
|
+
subject = _context14.t0.concat.call(_context14.t0, _context14.t3);
|
|
1187
|
+
case 9:
|
|
1209
1188
|
if (policyId) {
|
|
1210
1189
|
context["elv:delegation-id"] = policyId;
|
|
1211
1190
|
}
|
|
1212
1191
|
issueDateTime = issueTime || Date.now();
|
|
1213
|
-
|
|
1214
|
-
|
|
1192
|
+
_context14.t4 = Buffer;
|
|
1193
|
+
_context14.next = 14;
|
|
1215
1194
|
return this.CurrentAccountAddress().replace(/^0x/, "");
|
|
1216
|
-
case
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1195
|
+
case 14:
|
|
1196
|
+
_context14.t5 = _context14.sent;
|
|
1197
|
+
_context14.t6 = _context14.t4.from.call(_context14.t4, _context14.t5, "hex").toString("base64");
|
|
1198
|
+
_context14.t7 = subject;
|
|
1199
|
+
_context14.next = 19;
|
|
1221
1200
|
return this.ContentSpaceId();
|
|
1222
|
-
case
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1201
|
+
case 19:
|
|
1202
|
+
_context14.t8 = _context14.sent;
|
|
1203
|
+
_context14.t9 = issueDateTime;
|
|
1204
|
+
_context14.t10 = expirationTime || issueDateTime + duration;
|
|
1205
|
+
_context14.t11 = grantType;
|
|
1206
|
+
_context14.t12 = context;
|
|
1228
1207
|
token = {
|
|
1229
|
-
adr:
|
|
1230
|
-
sub:
|
|
1231
|
-
spc:
|
|
1232
|
-
iat:
|
|
1233
|
-
exp:
|
|
1234
|
-
gra:
|
|
1235
|
-
ctx:
|
|
1208
|
+
adr: _context14.t6,
|
|
1209
|
+
sub: _context14.t7,
|
|
1210
|
+
spc: _context14.t8,
|
|
1211
|
+
iat: _context14.t9,
|
|
1212
|
+
exp: _context14.t10,
|
|
1213
|
+
gra: _context14.t11,
|
|
1214
|
+
ctx: _context14.t12
|
|
1236
1215
|
};
|
|
1237
1216
|
if (versionHash) {
|
|
1238
1217
|
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1239
1218
|
}
|
|
1240
1219
|
if (!objectId) {
|
|
1241
|
-
|
|
1220
|
+
_context14.next = 32;
|
|
1242
1221
|
break;
|
|
1243
1222
|
}
|
|
1244
1223
|
token.qid = objectId;
|
|
1245
1224
|
if (libraryId) {
|
|
1246
|
-
|
|
1225
|
+
_context14.next = 32;
|
|
1247
1226
|
break;
|
|
1248
1227
|
}
|
|
1249
|
-
|
|
1228
|
+
_context14.next = 31;
|
|
1250
1229
|
return this.ContentObjectLibraryId({
|
|
1251
1230
|
objectId: objectId
|
|
1252
1231
|
});
|
|
1253
|
-
case
|
|
1254
|
-
libraryId =
|
|
1255
|
-
case
|
|
1232
|
+
case 31:
|
|
1233
|
+
libraryId = _context14.sent;
|
|
1234
|
+
case 32:
|
|
1256
1235
|
if (libraryId) {
|
|
1257
1236
|
token.lib = libraryId;
|
|
1258
1237
|
}
|
|
1259
1238
|
if (!allowDecryption) {
|
|
1260
|
-
|
|
1239
|
+
_context14.next = 38;
|
|
1261
1240
|
break;
|
|
1262
1241
|
}
|
|
1263
|
-
|
|
1242
|
+
_context14.next = 36;
|
|
1264
1243
|
return this.authClient.ReEncryptionConk({
|
|
1265
1244
|
libraryId: libraryId,
|
|
1266
1245
|
objectId: objectId
|
|
1267
1246
|
});
|
|
1268
|
-
case
|
|
1269
|
-
cap =
|
|
1247
|
+
case 36:
|
|
1248
|
+
cap = _context14.sent;
|
|
1270
1249
|
token.apk = cap.public_key;
|
|
1271
|
-
case
|
|
1250
|
+
case 38:
|
|
1272
1251
|
compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
|
|
1273
|
-
|
|
1252
|
+
_context14.next = 41;
|
|
1274
1253
|
return this.authClient.Sign(Ethers.utils.keccak256(compressedToken));
|
|
1275
|
-
case
|
|
1276
|
-
signature =
|
|
1277
|
-
return
|
|
1278
|
-
case
|
|
1254
|
+
case 41:
|
|
1255
|
+
signature = _context14.sent;
|
|
1256
|
+
return _context14.abrupt("return", "aessjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
|
|
1257
|
+
case 43:
|
|
1279
1258
|
case "end":
|
|
1280
|
-
return
|
|
1259
|
+
return _context14.stop();
|
|
1281
1260
|
}
|
|
1282
|
-
},
|
|
1261
|
+
}, _callee14, this);
|
|
1283
1262
|
}));
|
|
1284
1263
|
function CreateSignedToken(_x9) {
|
|
1285
1264
|
return _CreateSignedToken.apply(this, arguments);
|
|
1286
1265
|
}
|
|
1287
1266
|
return CreateSignedToken;
|
|
1288
|
-
}()
|
|
1267
|
+
}()
|
|
1289
1268
|
}, {
|
|
1290
1269
|
key: "CreateAuthorizationToken",
|
|
1291
1270
|
value: function () {
|
|
1292
|
-
var _CreateAuthorizationToken = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1293
|
-
return _regeneratorRuntime.wrap(function (
|
|
1294
|
-
while (1) switch (
|
|
1271
|
+
var _CreateAuthorizationToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(args) {
|
|
1272
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
1273
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1295
1274
|
case 0:
|
|
1296
|
-
|
|
1275
|
+
_context15.next = 2;
|
|
1297
1276
|
return this.authClient.AuthorizationToken(args);
|
|
1298
|
-
case 1:
|
|
1299
|
-
return _context13.abrupt("return", _context13.sent);
|
|
1300
1277
|
case 2:
|
|
1278
|
+
return _context15.abrupt("return", _context15.sent);
|
|
1279
|
+
case 3:
|
|
1301
1280
|
case "end":
|
|
1302
|
-
return
|
|
1281
|
+
return _context15.stop();
|
|
1303
1282
|
}
|
|
1304
|
-
},
|
|
1283
|
+
}, _callee15, this);
|
|
1305
1284
|
}));
|
|
1306
|
-
function CreateAuthorizationToken(
|
|
1285
|
+
function CreateAuthorizationToken(_x10) {
|
|
1307
1286
|
return _CreateAuthorizationToken.apply(this, arguments);
|
|
1308
1287
|
}
|
|
1309
1288
|
return CreateAuthorizationToken;
|
|
@@ -1324,31 +1303,31 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1324
1303
|
*/
|
|
1325
1304
|
}, {
|
|
1326
1305
|
key: "CreateSignedMessageJSON",
|
|
1327
|
-
value:
|
|
1328
|
-
var _CreateSignedMessageJSON = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1306
|
+
value: function () {
|
|
1307
|
+
var _CreateSignedMessageJSON = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref19) {
|
|
1329
1308
|
var message, type, msg, signature;
|
|
1330
|
-
return _regeneratorRuntime.wrap(function (
|
|
1331
|
-
while (1) switch (
|
|
1309
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
1310
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1332
1311
|
case 0:
|
|
1333
|
-
message =
|
|
1312
|
+
message = _ref19.message;
|
|
1334
1313
|
// Only one kind of signature supported currently
|
|
1335
1314
|
type = "mje_"; // JSON message, EIP192 signature
|
|
1336
1315
|
msg = JSON.stringify(message);
|
|
1337
|
-
|
|
1316
|
+
_context16.next = 5;
|
|
1338
1317
|
return this.PersonalSign({
|
|
1339
1318
|
message: msg,
|
|
1340
1319
|
addEthereumPrefix: true
|
|
1341
1320
|
});
|
|
1342
|
-
case
|
|
1343
|
-
signature =
|
|
1344
|
-
return
|
|
1345
|
-
case
|
|
1321
|
+
case 5:
|
|
1322
|
+
signature = _context16.sent;
|
|
1323
|
+
return _context16.abrupt("return", "".concat(type).concat(Utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(msg)]))));
|
|
1324
|
+
case 7:
|
|
1346
1325
|
case "end":
|
|
1347
|
-
return
|
|
1326
|
+
return _context16.stop();
|
|
1348
1327
|
}
|
|
1349
|
-
},
|
|
1328
|
+
}, _callee16, this);
|
|
1350
1329
|
}));
|
|
1351
|
-
function CreateSignedMessageJSON(
|
|
1330
|
+
function CreateSignedMessageJSON(_x11) {
|
|
1352
1331
|
return _CreateSignedMessageJSON.apply(this, arguments);
|
|
1353
1332
|
}
|
|
1354
1333
|
return CreateSignedMessageJSON;
|
|
@@ -1361,42 +1340,41 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1361
1340
|
* @param {string} signedMessage - a signed message as created by CreateSignedMessageJSON
|
|
1362
1341
|
* @returns {Promise<Object>} - The decoded message, signer address, signature and signature type
|
|
1363
1342
|
*/
|
|
1364
|
-
)
|
|
1365
1343
|
}, {
|
|
1366
1344
|
key: "DecodeSignedMessageJSON",
|
|
1367
|
-
value:
|
|
1368
|
-
var _DecodeSignedMessageJSON = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1369
|
-
var signedMessage, type, msgBytes, signature, msg, obj, prefixedMsgHash, signerAddr
|
|
1370
|
-
return _regeneratorRuntime.wrap(function (
|
|
1371
|
-
while (1) switch (
|
|
1345
|
+
value: function () {
|
|
1346
|
+
var _DecodeSignedMessageJSON = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref20) {
|
|
1347
|
+
var signedMessage, type, msgBytes, signature, msg, obj, prefixedMsgHash, signerAddr;
|
|
1348
|
+
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
1349
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1372
1350
|
case 0:
|
|
1373
|
-
signedMessage =
|
|
1351
|
+
signedMessage = _ref20.signedMessage;
|
|
1374
1352
|
type = signedMessage.slice(0, 4);
|
|
1375
|
-
|
|
1376
|
-
|
|
1353
|
+
_context17.t0 = type;
|
|
1354
|
+
_context17.next = _context17.t0 === "mje_" ? 5 : 12;
|
|
1377
1355
|
break;
|
|
1378
|
-
case
|
|
1356
|
+
case 5:
|
|
1379
1357
|
msgBytes = Utils.FromB58(signedMessage.slice(4));
|
|
1380
1358
|
signature = msgBytes.slice(0, 65);
|
|
1381
1359
|
msg = msgBytes.slice(65);
|
|
1382
1360
|
obj = JSON.parse(msg);
|
|
1383
1361
|
prefixedMsgHash = Ethers.utils.keccak256(Buffer.from("\x19Ethereum Signed Message:\n".concat(msg.length).concat(msg), "utf-8"));
|
|
1384
1362
|
signerAddr = Ethers.utils.recoverAddress(prefixedMsgHash, signature);
|
|
1385
|
-
return
|
|
1363
|
+
return _context17.abrupt("return", {
|
|
1386
1364
|
type: type,
|
|
1387
1365
|
message: obj,
|
|
1388
1366
|
signerAddress: signerAddr,
|
|
1389
1367
|
signature: "0x" + signature.toString("hex")
|
|
1390
1368
|
});
|
|
1391
|
-
case
|
|
1369
|
+
case 12:
|
|
1392
1370
|
throw new Error("Bad message type: ".concat(type));
|
|
1393
|
-
case
|
|
1371
|
+
case 13:
|
|
1394
1372
|
case "end":
|
|
1395
|
-
return
|
|
1373
|
+
return _context17.stop();
|
|
1396
1374
|
}
|
|
1397
|
-
},
|
|
1375
|
+
}, _callee17);
|
|
1398
1376
|
}));
|
|
1399
|
-
function DecodeSignedMessageJSON(
|
|
1377
|
+
function DecodeSignedMessageJSON(_x12) {
|
|
1400
1378
|
return _DecodeSignedMessageJSON.apply(this, arguments);
|
|
1401
1379
|
}
|
|
1402
1380
|
return DecodeSignedMessageJSON;
|
|
@@ -1407,7 +1385,6 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1407
1385
|
* @methodGroup Signers
|
|
1408
1386
|
* @returns {string} - The address of the current signer
|
|
1409
1387
|
*/
|
|
1410
|
-
)
|
|
1411
1388
|
}, {
|
|
1412
1389
|
key: "CurrentAccountAddress",
|
|
1413
1390
|
value: function CurrentAccountAddress() {
|
|
@@ -1423,13 +1400,13 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1423
1400
|
*/
|
|
1424
1401
|
}, {
|
|
1425
1402
|
key: "SetOauthToken",
|
|
1426
|
-
value:
|
|
1427
|
-
var _SetOauthToken = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1403
|
+
value: function () {
|
|
1404
|
+
var _SetOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref21) {
|
|
1428
1405
|
var token, wallet, signer;
|
|
1429
|
-
return _regeneratorRuntime.wrap(function (
|
|
1430
|
-
while (1) switch (
|
|
1406
|
+
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
1407
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1431
1408
|
case 0:
|
|
1432
|
-
token =
|
|
1409
|
+
token = _ref21.token;
|
|
1433
1410
|
this.oauthToken = token;
|
|
1434
1411
|
wallet = this.GenerateWallet();
|
|
1435
1412
|
signer = wallet.AddAccountFromMnemonic({
|
|
@@ -1438,13 +1415,13 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1438
1415
|
this.SetSigner({
|
|
1439
1416
|
signer: signer
|
|
1440
1417
|
});
|
|
1441
|
-
case
|
|
1418
|
+
case 5:
|
|
1442
1419
|
case "end":
|
|
1443
|
-
return
|
|
1420
|
+
return _context18.stop();
|
|
1444
1421
|
}
|
|
1445
|
-
},
|
|
1422
|
+
}, _callee18, this);
|
|
1446
1423
|
}));
|
|
1447
|
-
function SetOauthToken(
|
|
1424
|
+
function SetOauthToken(_x13) {
|
|
1448
1425
|
return _SetOauthToken.apply(this, arguments);
|
|
1449
1426
|
}
|
|
1450
1427
|
return SetOauthToken;
|
|
@@ -1459,61 +1436,60 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1459
1436
|
* @namedParams
|
|
1460
1437
|
* @param {string} token - The OAuth ID
|
|
1461
1438
|
*/
|
|
1462
|
-
)
|
|
1463
1439
|
}, {
|
|
1464
1440
|
key: "SetSignerFromOauthToken",
|
|
1465
|
-
value:
|
|
1466
|
-
var _SetSignerFromOauthToken = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1467
|
-
var token, wallet, client, _yield$client$authCli, urls, path, httpClient, response, privateKey
|
|
1468
|
-
return _regeneratorRuntime.wrap(function (
|
|
1469
|
-
while (1) switch (
|
|
1441
|
+
value: function () {
|
|
1442
|
+
var _SetSignerFromOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(_ref22) {
|
|
1443
|
+
var token, wallet, client, _yield$client$authCli, urls, path, httpClient, response, privateKey;
|
|
1444
|
+
return _regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
1445
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1470
1446
|
case 0:
|
|
1471
|
-
token =
|
|
1447
|
+
token = _ref22.token;
|
|
1472
1448
|
if (this.trustAuthorityId) {
|
|
1473
|
-
|
|
1449
|
+
_context19.next = 3;
|
|
1474
1450
|
break;
|
|
1475
1451
|
}
|
|
1476
1452
|
throw Error("Unable to authorize with OAuth token: No trust authority ID set");
|
|
1477
|
-
case
|
|
1453
|
+
case 3:
|
|
1478
1454
|
wallet = this.GenerateWallet();
|
|
1479
|
-
|
|
1455
|
+
_context19.prev = 4;
|
|
1480
1456
|
if (this.kmsURIs) {
|
|
1481
|
-
|
|
1457
|
+
_context19.next = 17;
|
|
1482
1458
|
break;
|
|
1483
1459
|
}
|
|
1484
|
-
|
|
1460
|
+
_context19.next = 8;
|
|
1485
1461
|
return ElvClient.FromConfigurationUrl({
|
|
1486
1462
|
configUrl: this.configUrl
|
|
1487
1463
|
});
|
|
1488
|
-
case
|
|
1489
|
-
client =
|
|
1464
|
+
case 8:
|
|
1465
|
+
client = _context19.sent;
|
|
1490
1466
|
client.SetSigner({
|
|
1491
1467
|
signer: wallet.AddAccount({
|
|
1492
1468
|
privateKey: this.defaultKey
|
|
1493
1469
|
})
|
|
1494
1470
|
});
|
|
1495
|
-
|
|
1471
|
+
_context19.next = 12;
|
|
1496
1472
|
return client.authClient.KMSInfo({
|
|
1497
1473
|
kmsId: this.trustAuthorityId
|
|
1498
1474
|
});
|
|
1499
|
-
case
|
|
1500
|
-
_yield$client$authCli =
|
|
1475
|
+
case 12:
|
|
1476
|
+
_yield$client$authCli = _context19.sent;
|
|
1501
1477
|
urls = _yield$client$authCli.urls;
|
|
1502
1478
|
if (!(!urls || urls.length === 0)) {
|
|
1503
|
-
|
|
1479
|
+
_context19.next = 16;
|
|
1504
1480
|
break;
|
|
1505
1481
|
}
|
|
1506
1482
|
throw Error("Unable to authorize with OAuth token: No KMS URLs set");
|
|
1507
|
-
case
|
|
1483
|
+
case 16:
|
|
1508
1484
|
this.kmsURIs = urls;
|
|
1509
|
-
case
|
|
1485
|
+
case 17:
|
|
1510
1486
|
this.oauthToken = token;
|
|
1511
1487
|
path = "/ks/jwt/wlt";
|
|
1512
1488
|
httpClient = new HttpClient({
|
|
1513
1489
|
uris: this.kmsURIs,
|
|
1514
1490
|
debug: this.debug
|
|
1515
1491
|
});
|
|
1516
|
-
|
|
1492
|
+
_context19.next = 22;
|
|
1517
1493
|
return this.utils.ResponseToJson(httpClient.Request({
|
|
1518
1494
|
headers: {
|
|
1519
1495
|
Authorization: "Bearer ".concat(token)
|
|
@@ -1522,8 +1498,8 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1522
1498
|
path: path,
|
|
1523
1499
|
forceFailover: true
|
|
1524
1500
|
}));
|
|
1525
|
-
case
|
|
1526
|
-
response =
|
|
1501
|
+
case 22:
|
|
1502
|
+
response = _context19.sent;
|
|
1527
1503
|
privateKey = response["UserSKHex"];
|
|
1528
1504
|
this.SetSigner({
|
|
1529
1505
|
signer: wallet.AddAccount({
|
|
@@ -1532,27 +1508,27 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1532
1508
|
});
|
|
1533
1509
|
|
|
1534
1510
|
// Ensure wallet is initialized
|
|
1535
|
-
|
|
1511
|
+
_context19.next = 27;
|
|
1536
1512
|
return this.userProfileClient.WalletAddress();
|
|
1537
|
-
case
|
|
1538
|
-
|
|
1513
|
+
case 27:
|
|
1514
|
+
_context19.next = 36;
|
|
1539
1515
|
break;
|
|
1540
|
-
case
|
|
1541
|
-
|
|
1542
|
-
|
|
1516
|
+
case 29:
|
|
1517
|
+
_context19.prev = 29;
|
|
1518
|
+
_context19.t0 = _context19["catch"](4);
|
|
1543
1519
|
this.Log("Failed to set signer from OAuth token:", true);
|
|
1544
|
-
this.Log(
|
|
1545
|
-
|
|
1520
|
+
this.Log(_context19.t0, true);
|
|
1521
|
+
_context19.next = 35;
|
|
1546
1522
|
return this.ClearSigner();
|
|
1547
|
-
case
|
|
1548
|
-
throw
|
|
1549
|
-
case
|
|
1523
|
+
case 35:
|
|
1524
|
+
throw _context19.t0;
|
|
1525
|
+
case 36:
|
|
1550
1526
|
case "end":
|
|
1551
|
-
return
|
|
1527
|
+
return _context19.stop();
|
|
1552
1528
|
}
|
|
1553
|
-
},
|
|
1529
|
+
}, _callee19, this, [[4, 29]]);
|
|
1554
1530
|
}));
|
|
1555
|
-
function SetSignerFromOauthToken(
|
|
1531
|
+
function SetSignerFromOauthToken(_x14) {
|
|
1556
1532
|
return _SetSignerFromOauthToken.apply(this, arguments);
|
|
1557
1533
|
}
|
|
1558
1534
|
return SetSignerFromOauthToken;
|
|
@@ -1566,11 +1542,10 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1566
1542
|
*
|
|
1567
1543
|
* @return {string} - The created static token
|
|
1568
1544
|
*/
|
|
1569
|
-
)
|
|
1570
1545
|
}, {
|
|
1571
1546
|
key: "CreateStaticToken",
|
|
1572
|
-
value: function CreateStaticToken(
|
|
1573
|
-
var libraryId =
|
|
1547
|
+
value: function CreateStaticToken(_ref23) {
|
|
1548
|
+
var libraryId = _ref23.libraryId;
|
|
1574
1549
|
var token = {
|
|
1575
1550
|
qspace_id: this.client.contentSpaceId
|
|
1576
1551
|
};
|
|
@@ -1591,10 +1566,10 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1591
1566
|
}, {
|
|
1592
1567
|
key: "SetStaticToken",
|
|
1593
1568
|
value: function SetStaticToken() {
|
|
1594
|
-
var
|
|
1595
|
-
token =
|
|
1596
|
-
|
|
1597
|
-
update =
|
|
1569
|
+
var _ref24 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1570
|
+
token = _ref24.token,
|
|
1571
|
+
_ref24$update = _ref24.update,
|
|
1572
|
+
update = _ref24$update === void 0 ? false : _ref24$update;
|
|
1598
1573
|
if (token) {
|
|
1599
1574
|
this.staticToken = token;
|
|
1600
1575
|
} else {
|
|
@@ -1625,31 +1600,31 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1625
1600
|
*/
|
|
1626
1601
|
}, {
|
|
1627
1602
|
key: "SetPolicyAuthorization",
|
|
1628
|
-
value:
|
|
1629
|
-
var _SetPolicyAuthorization = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1630
|
-
var objectId
|
|
1631
|
-
return _regeneratorRuntime.wrap(function (
|
|
1632
|
-
while (1) switch (
|
|
1603
|
+
value: function () {
|
|
1604
|
+
var _SetPolicyAuthorization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(_ref25) {
|
|
1605
|
+
var objectId;
|
|
1606
|
+
return _regeneratorRuntime.wrap(function _callee20$(_context20) {
|
|
1607
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1633
1608
|
case 0:
|
|
1634
|
-
objectId =
|
|
1635
|
-
|
|
1636
|
-
|
|
1609
|
+
objectId = _ref25.objectId;
|
|
1610
|
+
_context20.t0 = this;
|
|
1611
|
+
_context20.next = 4;
|
|
1637
1612
|
return this.GenerateStateChannelToken({
|
|
1638
1613
|
objectId: objectId
|
|
1639
1614
|
});
|
|
1640
|
-
case
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
token:
|
|
1615
|
+
case 4:
|
|
1616
|
+
_context20.t1 = _context20.sent;
|
|
1617
|
+
_context20.t2 = {
|
|
1618
|
+
token: _context20.t1
|
|
1644
1619
|
};
|
|
1645
|
-
|
|
1646
|
-
case
|
|
1620
|
+
_context20.t0.SetStaticToken.call(_context20.t0, _context20.t2);
|
|
1621
|
+
case 7:
|
|
1647
1622
|
case "end":
|
|
1648
|
-
return
|
|
1623
|
+
return _context20.stop();
|
|
1649
1624
|
}
|
|
1650
|
-
},
|
|
1625
|
+
}, _callee20, this);
|
|
1651
1626
|
}));
|
|
1652
|
-
function SetPolicyAuthorization(
|
|
1627
|
+
function SetPolicyAuthorization(_x15) {
|
|
1653
1628
|
return _SetPolicyAuthorization.apply(this, arguments);
|
|
1654
1629
|
}
|
|
1655
1630
|
return SetPolicyAuthorization;
|
|
@@ -1660,27 +1635,26 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1660
1635
|
* @param {string} string - The string to sign
|
|
1661
1636
|
* @return {Promise<string>} - The signed string
|
|
1662
1637
|
*/
|
|
1663
|
-
)
|
|
1664
1638
|
}, {
|
|
1665
1639
|
key: "Sign",
|
|
1666
|
-
value:
|
|
1667
|
-
var _Sign = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1640
|
+
value: function () {
|
|
1641
|
+
var _Sign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(string) {
|
|
1668
1642
|
var signature;
|
|
1669
|
-
return _regeneratorRuntime.wrap(function (
|
|
1670
|
-
while (1) switch (
|
|
1643
|
+
return _regeneratorRuntime.wrap(function _callee21$(_context21) {
|
|
1644
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1671
1645
|
case 0:
|
|
1672
|
-
|
|
1646
|
+
_context21.next = 2;
|
|
1673
1647
|
return this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(string)));
|
|
1674
|
-
case 1:
|
|
1675
|
-
signature = _context19.sent;
|
|
1676
|
-
return _context19.abrupt("return", this.utils.FormatSignature(signature));
|
|
1677
1648
|
case 2:
|
|
1649
|
+
signature = _context21.sent;
|
|
1650
|
+
return _context21.abrupt("return", this.utils.FormatSignature(signature));
|
|
1651
|
+
case 4:
|
|
1678
1652
|
case "end":
|
|
1679
|
-
return
|
|
1653
|
+
return _context21.stop();
|
|
1680
1654
|
}
|
|
1681
|
-
},
|
|
1655
|
+
}, _callee21, this);
|
|
1682
1656
|
}));
|
|
1683
|
-
function Sign(
|
|
1657
|
+
function Sign(_x16) {
|
|
1684
1658
|
return _Sign.apply(this, arguments);
|
|
1685
1659
|
}
|
|
1686
1660
|
return Sign;
|
|
@@ -1694,34 +1668,33 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1694
1668
|
*
|
|
1695
1669
|
* @return {Promise<string>} - The encrypted message
|
|
1696
1670
|
*/
|
|
1697
|
-
)
|
|
1698
1671
|
}, {
|
|
1699
1672
|
key: "EncryptECIES",
|
|
1700
|
-
value:
|
|
1701
|
-
var _EncryptECIES = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1673
|
+
value: function () {
|
|
1674
|
+
var _EncryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref26) {
|
|
1702
1675
|
var message, publicKey;
|
|
1703
|
-
return _regeneratorRuntime.wrap(function (
|
|
1704
|
-
while (1) switch (
|
|
1676
|
+
return _regeneratorRuntime.wrap(function _callee22$(_context22) {
|
|
1677
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1705
1678
|
case 0:
|
|
1706
|
-
message =
|
|
1679
|
+
message = _ref26.message, publicKey = _ref26.publicKey;
|
|
1707
1680
|
if (this.signer) {
|
|
1708
|
-
|
|
1681
|
+
_context22.next = 3;
|
|
1709
1682
|
break;
|
|
1710
1683
|
}
|
|
1711
1684
|
throw "Signer not set";
|
|
1712
|
-
case
|
|
1685
|
+
case 3:
|
|
1713
1686
|
ValidatePresence("message", message);
|
|
1714
|
-
|
|
1687
|
+
_context22.next = 6;
|
|
1715
1688
|
return this.Crypto.EncryptConk(message, publicKey || this.signer._signingKey().publicKey);
|
|
1716
|
-
case
|
|
1717
|
-
return
|
|
1718
|
-
case
|
|
1689
|
+
case 6:
|
|
1690
|
+
return _context22.abrupt("return", _context22.sent);
|
|
1691
|
+
case 7:
|
|
1719
1692
|
case "end":
|
|
1720
|
-
return
|
|
1693
|
+
return _context22.stop();
|
|
1721
1694
|
}
|
|
1722
|
-
},
|
|
1695
|
+
}, _callee22, this);
|
|
1723
1696
|
}));
|
|
1724
|
-
function EncryptECIES(
|
|
1697
|
+
function EncryptECIES(_x17) {
|
|
1725
1698
|
return _EncryptECIES.apply(this, arguments);
|
|
1726
1699
|
}
|
|
1727
1700
|
return EncryptECIES;
|
|
@@ -1734,34 +1707,33 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1734
1707
|
*
|
|
1735
1708
|
* @return {Promise<string | Object>} - The decrypted string or object
|
|
1736
1709
|
*/
|
|
1737
|
-
)
|
|
1738
1710
|
}, {
|
|
1739
1711
|
key: "DecryptECIES",
|
|
1740
|
-
value:
|
|
1741
|
-
var _DecryptECIES = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1712
|
+
value: function () {
|
|
1713
|
+
var _DecryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref27) {
|
|
1742
1714
|
var message;
|
|
1743
|
-
return _regeneratorRuntime.wrap(function (
|
|
1744
|
-
while (1) switch (
|
|
1715
|
+
return _regeneratorRuntime.wrap(function _callee23$(_context23) {
|
|
1716
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1745
1717
|
case 0:
|
|
1746
|
-
message =
|
|
1718
|
+
message = _ref27.message;
|
|
1747
1719
|
if (this.signer) {
|
|
1748
|
-
|
|
1720
|
+
_context23.next = 3;
|
|
1749
1721
|
break;
|
|
1750
1722
|
}
|
|
1751
1723
|
throw "Signer not set";
|
|
1752
|
-
case
|
|
1724
|
+
case 3:
|
|
1753
1725
|
ValidatePresence("message", message);
|
|
1754
|
-
|
|
1726
|
+
_context23.next = 6;
|
|
1755
1727
|
return this.Crypto.DecryptCap(message, this.signer._signingKey().privateKey);
|
|
1756
|
-
case
|
|
1757
|
-
return
|
|
1758
|
-
case
|
|
1728
|
+
case 6:
|
|
1729
|
+
return _context23.abrupt("return", _context23.sent);
|
|
1730
|
+
case 7:
|
|
1759
1731
|
case "end":
|
|
1760
|
-
return
|
|
1732
|
+
return _context23.stop();
|
|
1761
1733
|
}
|
|
1762
|
-
},
|
|
1734
|
+
}, _callee23, this);
|
|
1763
1735
|
}));
|
|
1764
|
-
function DecryptECIES(
|
|
1736
|
+
function DecryptECIES(_x18) {
|
|
1765
1737
|
return _DecryptECIES.apply(this, arguments);
|
|
1766
1738
|
}
|
|
1767
1739
|
return DecryptECIES;
|
|
@@ -1777,41 +1749,40 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1777
1749
|
*
|
|
1778
1750
|
* @return {Promise<*>} - Response in the specified format
|
|
1779
1751
|
*/
|
|
1780
|
-
)
|
|
1781
1752
|
}, {
|
|
1782
1753
|
key: "Request",
|
|
1783
|
-
value:
|
|
1784
|
-
var _Request = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1785
|
-
var url,
|
|
1786
|
-
return _regeneratorRuntime.wrap(function (
|
|
1787
|
-
while (1) switch (
|
|
1754
|
+
value: function () {
|
|
1755
|
+
var _Request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(_ref28) {
|
|
1756
|
+
var url, _ref28$format, format, _ref28$method, method, _ref28$headers, headers, body;
|
|
1757
|
+
return _regeneratorRuntime.wrap(function _callee24$(_context24) {
|
|
1758
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1788
1759
|
case 0:
|
|
1789
|
-
url =
|
|
1790
|
-
return
|
|
1760
|
+
url = _ref28.url, _ref28$format = _ref28.format, format = _ref28$format === void 0 ? "json" : _ref28$format, _ref28$method = _ref28.method, method = _ref28$method === void 0 ? "GET" : _ref28$method, _ref28$headers = _ref28.headers, headers = _ref28$headers === void 0 ? {} : _ref28$headers, body = _ref28.body;
|
|
1761
|
+
return _context24.abrupt("return", this.utils.ResponseToFormat(format, HttpClient.Fetch(url, {
|
|
1791
1762
|
method: method,
|
|
1792
1763
|
headers: headers,
|
|
1793
1764
|
body: body
|
|
1794
1765
|
})));
|
|
1795
|
-
case
|
|
1766
|
+
case 2:
|
|
1796
1767
|
case "end":
|
|
1797
|
-
return
|
|
1768
|
+
return _context24.stop();
|
|
1798
1769
|
}
|
|
1799
|
-
},
|
|
1770
|
+
}, _callee24, this);
|
|
1800
1771
|
}));
|
|
1801
|
-
function Request(
|
|
1772
|
+
function Request(_x19) {
|
|
1802
1773
|
return _Request.apply(this, arguments);
|
|
1803
1774
|
}
|
|
1804
1775
|
return Request;
|
|
1805
|
-
}()
|
|
1776
|
+
}()
|
|
1806
1777
|
}, {
|
|
1807
1778
|
key: "MakeAuthServiceRequest",
|
|
1808
1779
|
value: function () {
|
|
1809
|
-
var _MakeAuthServiceRequest = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1810
|
-
var kmsId, objectId, versionHash,
|
|
1811
|
-
return _regeneratorRuntime.wrap(function (
|
|
1812
|
-
while (1) switch (
|
|
1780
|
+
var _MakeAuthServiceRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(_ref29) {
|
|
1781
|
+
var kmsId, objectId, versionHash, _ref29$method, method, path, bodyType, _ref29$body, body, _ref29$queryParams, queryParams, headers, format, response;
|
|
1782
|
+
return _regeneratorRuntime.wrap(function _callee25$(_context25) {
|
|
1783
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1813
1784
|
case 0:
|
|
1814
|
-
kmsId =
|
|
1785
|
+
kmsId = _ref29.kmsId, objectId = _ref29.objectId, versionHash = _ref29.versionHash, _ref29$method = _ref29.method, method = _ref29$method === void 0 ? "GET" : _ref29$method, path = _ref29.path, bodyType = _ref29.bodyType, _ref29$body = _ref29.body, body = _ref29$body === void 0 ? {} : _ref29$body, _ref29$queryParams = _ref29.queryParams, queryParams = _ref29$queryParams === void 0 ? {} : _ref29$queryParams, headers = _ref29.headers, format = _ref29.format;
|
|
1815
1786
|
response = this.authClient.MakeAuthServiceRequest({
|
|
1816
1787
|
kmsId: kmsId,
|
|
1817
1788
|
objectId: objectId,
|
|
@@ -1823,14 +1794,14 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1823
1794
|
queryParams: queryParams,
|
|
1824
1795
|
headers: headers
|
|
1825
1796
|
});
|
|
1826
|
-
return
|
|
1827
|
-
case
|
|
1797
|
+
return _context25.abrupt("return", !format ? response : this.utils.ResponseToFormat(format, response));
|
|
1798
|
+
case 3:
|
|
1828
1799
|
case "end":
|
|
1829
|
-
return
|
|
1800
|
+
return _context25.stop();
|
|
1830
1801
|
}
|
|
1831
|
-
},
|
|
1802
|
+
}, _callee25, this);
|
|
1832
1803
|
}));
|
|
1833
|
-
function MakeAuthServiceRequest(
|
|
1804
|
+
function MakeAuthServiceRequest(_x20) {
|
|
1834
1805
|
return _MakeAuthServiceRequest.apply(this, arguments);
|
|
1835
1806
|
}
|
|
1836
1807
|
return MakeAuthServiceRequest;
|
|
@@ -1851,18 +1822,18 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1851
1822
|
}, {
|
|
1852
1823
|
key: "CallFromFrameMessage",
|
|
1853
1824
|
value: function () {
|
|
1854
|
-
var _CallFromFrameMessage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1825
|
+
var _CallFromFrameMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(message, Respond) {
|
|
1855
1826
|
var _this4 = this;
|
|
1856
|
-
var callback, method, methodResults, responseError
|
|
1857
|
-
return _regeneratorRuntime.wrap(function (
|
|
1858
|
-
while (1) switch (
|
|
1827
|
+
var callback, method, methodResults, responseError;
|
|
1828
|
+
return _regeneratorRuntime.wrap(function _callee26$(_context26) {
|
|
1829
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1859
1830
|
case 0:
|
|
1860
1831
|
if (!(message.type !== "ElvFrameRequest")) {
|
|
1861
|
-
|
|
1832
|
+
_context26.next = 2;
|
|
1862
1833
|
break;
|
|
1863
1834
|
}
|
|
1864
|
-
return
|
|
1865
|
-
case
|
|
1835
|
+
return _context26.abrupt("return");
|
|
1836
|
+
case 2:
|
|
1866
1837
|
if (message.callbackId) {
|
|
1867
1838
|
callback = function callback(result) {
|
|
1868
1839
|
Respond(_this4.utils.MakeClonable({
|
|
@@ -1873,103 +1844,103 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1873
1844
|
};
|
|
1874
1845
|
message.args.callback = callback;
|
|
1875
1846
|
}
|
|
1876
|
-
|
|
1847
|
+
_context26.prev = 3;
|
|
1877
1848
|
method = message.calledMethod;
|
|
1878
1849
|
if (!(message.module === "walletClient")) {
|
|
1879
|
-
|
|
1850
|
+
_context26.next = 15;
|
|
1880
1851
|
break;
|
|
1881
1852
|
}
|
|
1882
1853
|
if (this.walletClient) {
|
|
1883
|
-
|
|
1854
|
+
_context26.next = 8;
|
|
1884
1855
|
break;
|
|
1885
1856
|
}
|
|
1886
1857
|
throw Error("Wallet client not set");
|
|
1887
|
-
case
|
|
1858
|
+
case 8:
|
|
1888
1859
|
if (!this.walletClient.ForbiddenMethods().includes(method)) {
|
|
1889
|
-
|
|
1860
|
+
_context26.next = 10;
|
|
1890
1861
|
break;
|
|
1891
1862
|
}
|
|
1892
1863
|
throw Error("Invalid user profile method: " + method);
|
|
1893
|
-
case
|
|
1894
|
-
|
|
1864
|
+
case 10:
|
|
1865
|
+
_context26.next = 12;
|
|
1895
1866
|
return this.walletClient[method](message.args);
|
|
1896
|
-
case
|
|
1897
|
-
methodResults =
|
|
1898
|
-
|
|
1867
|
+
case 12:
|
|
1868
|
+
methodResults = _context26.sent;
|
|
1869
|
+
_context26.next = 28;
|
|
1899
1870
|
break;
|
|
1900
|
-
case
|
|
1871
|
+
case 15:
|
|
1901
1872
|
if (!(message.module === "userProfileClient")) {
|
|
1902
|
-
|
|
1873
|
+
_context26.next = 23;
|
|
1903
1874
|
break;
|
|
1904
1875
|
}
|
|
1905
1876
|
if (this.userProfileClient.FrameAllowedMethods().includes(method)) {
|
|
1906
|
-
|
|
1877
|
+
_context26.next = 18;
|
|
1907
1878
|
break;
|
|
1908
1879
|
}
|
|
1909
1880
|
throw Error("Invalid user profile method: " + method);
|
|
1910
|
-
case
|
|
1911
|
-
|
|
1881
|
+
case 18:
|
|
1882
|
+
_context26.next = 20;
|
|
1912
1883
|
return this.userProfileClient[method](message.args);
|
|
1913
|
-
case
|
|
1914
|
-
methodResults =
|
|
1915
|
-
|
|
1884
|
+
case 20:
|
|
1885
|
+
methodResults = _context26.sent;
|
|
1886
|
+
_context26.next = 28;
|
|
1916
1887
|
break;
|
|
1917
|
-
case
|
|
1888
|
+
case 23:
|
|
1918
1889
|
if (this.FrameAllowedMethods().includes(method)) {
|
|
1919
|
-
|
|
1890
|
+
_context26.next = 25;
|
|
1920
1891
|
break;
|
|
1921
1892
|
}
|
|
1922
1893
|
throw Error("Invalid method: " + method);
|
|
1923
|
-
case
|
|
1924
|
-
|
|
1894
|
+
case 25:
|
|
1895
|
+
_context26.next = 27;
|
|
1925
1896
|
return this[method](message.args);
|
|
1926
|
-
case
|
|
1927
|
-
methodResults =
|
|
1928
|
-
case
|
|
1897
|
+
case 27:
|
|
1898
|
+
methodResults = _context26.sent;
|
|
1899
|
+
case 28:
|
|
1929
1900
|
Respond(this.utils.MakeClonable({
|
|
1930
1901
|
type: "ElvFrameResponse",
|
|
1931
1902
|
requestId: message.requestId,
|
|
1932
1903
|
response: methodResults
|
|
1933
1904
|
}));
|
|
1934
|
-
|
|
1905
|
+
_context26.next = 38;
|
|
1935
1906
|
break;
|
|
1936
|
-
case
|
|
1937
|
-
|
|
1938
|
-
|
|
1907
|
+
case 31:
|
|
1908
|
+
_context26.prev = 31;
|
|
1909
|
+
_context26.t0 = _context26["catch"](3);
|
|
1939
1910
|
// eslint-disable-next-line no-console
|
|
1940
|
-
this.Log("Frame Message Error:\n Method: ".concat(message.calledMethod, "\n Arguments: ").concat(JSON.stringify(message.args, null, 2), "\n Error: ").concat(_typeof(
|
|
1911
|
+
this.Log("Frame Message Error:\n Method: ".concat(message.calledMethod, "\n Arguments: ").concat(JSON.stringify(message.args, null, 2), "\n Error: ").concat(_typeof(_context26.t0) === "object" ? JSON.stringify(_context26.t0, null, 2) : _context26.t0), true);
|
|
1941
1912
|
|
|
1942
1913
|
// eslint-disable-next-line no-console
|
|
1943
1914
|
console.error(message);
|
|
1944
1915
|
// eslint-disable-next-line no-console
|
|
1945
|
-
console.error(
|
|
1946
|
-
responseError =
|
|
1916
|
+
console.error(_context26.t0);
|
|
1917
|
+
responseError = _context26.t0 instanceof Error ? _context26.t0.message : _context26.t0;
|
|
1947
1918
|
Respond(this.utils.MakeClonable({
|
|
1948
1919
|
type: "ElvFrameResponse",
|
|
1949
1920
|
requestId: message.requestId,
|
|
1950
1921
|
error: responseError
|
|
1951
1922
|
}));
|
|
1952
|
-
case
|
|
1923
|
+
case 38:
|
|
1953
1924
|
case "end":
|
|
1954
|
-
return
|
|
1925
|
+
return _context26.stop();
|
|
1955
1926
|
}
|
|
1956
|
-
},
|
|
1927
|
+
}, _callee26, this, [[3, 31]]);
|
|
1957
1928
|
}));
|
|
1958
|
-
function CallFromFrameMessage(
|
|
1929
|
+
function CallFromFrameMessage(_x21, _x22) {
|
|
1959
1930
|
return _CallFromFrameMessage.apply(this, arguments);
|
|
1960
1931
|
}
|
|
1961
1932
|
return CallFromFrameMessage;
|
|
1962
1933
|
}()
|
|
1963
1934
|
}], [{
|
|
1964
1935
|
key: "Configuration",
|
|
1965
|
-
value:
|
|
1966
|
-
var _Configuration = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1967
|
-
var configUrl,
|
|
1968
|
-
return _regeneratorRuntime.wrap(function (
|
|
1969
|
-
while (1) switch (
|
|
1936
|
+
value: function () {
|
|
1937
|
+
var _Configuration = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27(_ref30) {
|
|
1938
|
+
var configUrl, _ref30$kmsUrls, kmsUrls, region, clientIP, uri, fabricInfo, filterHTTPS, fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs, fabricVersion;
|
|
1939
|
+
return _regeneratorRuntime.wrap(function _callee27$(_context27) {
|
|
1940
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1970
1941
|
case 0:
|
|
1971
|
-
configUrl =
|
|
1972
|
-
|
|
1942
|
+
configUrl = _ref30.configUrl, _ref30$kmsUrls = _ref30.kmsUrls, kmsUrls = _ref30$kmsUrls === void 0 ? [] : _ref30$kmsUrls, region = _ref30.region, clientIP = _ref30.clientIP;
|
|
1943
|
+
_context27.prev = 1;
|
|
1973
1944
|
uri = new URI(configUrl);
|
|
1974
1945
|
uri.pathname("/config");
|
|
1975
1946
|
if (region) {
|
|
@@ -1978,10 +1949,10 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1978
1949
|
if (clientIP) {
|
|
1979
1950
|
uri.addSearch("client_ip", clientIP);
|
|
1980
1951
|
}
|
|
1981
|
-
|
|
1952
|
+
_context27.next = 8;
|
|
1982
1953
|
return Utils.ResponseToJson(HttpClient.Fetch(uri.toString()));
|
|
1983
|
-
case
|
|
1984
|
-
fabricInfo =
|
|
1954
|
+
case 8:
|
|
1955
|
+
fabricInfo = _context27.sent;
|
|
1985
1956
|
// If any HTTPS urls present, throw away HTTP urls so only HTTPS will be used
|
|
1986
1957
|
filterHTTPS = function filterHTTPS(uri) {
|
|
1987
1958
|
return uri.toLowerCase().startsWith("https");
|
|
@@ -2004,7 +1975,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2004
1975
|
}
|
|
2005
1976
|
searchURIs = fabricInfo.network.services.search || [];
|
|
2006
1977
|
fabricVersion = Math.max.apply(Math, _toConsumableArray(fabricInfo.network.api_versions || [2]));
|
|
2007
|
-
return
|
|
1978
|
+
return _context27.abrupt("return", {
|
|
2008
1979
|
nodeId: fabricInfo.node_id,
|
|
2009
1980
|
contentSpaceId: fabricInfo.qspace.id,
|
|
2010
1981
|
networkId: (fabricInfo.qspace.ethereum || {}).network_id,
|
|
@@ -2017,21 +1988,21 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2017
1988
|
searchURIs: searchURIs,
|
|
2018
1989
|
fabricVersion: fabricVersion
|
|
2019
1990
|
});
|
|
2020
|
-
case
|
|
2021
|
-
|
|
2022
|
-
|
|
1991
|
+
case 23:
|
|
1992
|
+
_context27.prev = 23;
|
|
1993
|
+
_context27.t0 = _context27["catch"](1);
|
|
2023
1994
|
// eslint-disable-next-line no-console
|
|
2024
1995
|
console.error("Error retrieving fabric configuration:");
|
|
2025
1996
|
// eslint-disable-next-line no-console
|
|
2026
|
-
console.error(
|
|
2027
|
-
throw
|
|
2028
|
-
case
|
|
1997
|
+
console.error(_context27.t0);
|
|
1998
|
+
throw _context27.t0;
|
|
1999
|
+
case 28:
|
|
2029
2000
|
case "end":
|
|
2030
|
-
return
|
|
2001
|
+
return _context27.stop();
|
|
2031
2002
|
}
|
|
2032
|
-
},
|
|
2003
|
+
}, _callee27, null, [[1, 23]]);
|
|
2033
2004
|
}));
|
|
2034
|
-
function Configuration(
|
|
2005
|
+
function Configuration(_x23) {
|
|
2035
2006
|
return _Configuration.apply(this, arguments);
|
|
2036
2007
|
}
|
|
2037
2008
|
return Configuration;
|
|
@@ -2043,7 +2014,6 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2043
2014
|
*
|
|
2044
2015
|
* @return {Object} - An object using network names as keys and configuration URLs as values.
|
|
2045
2016
|
*/
|
|
2046
|
-
)
|
|
2047
2017
|
}, {
|
|
2048
2018
|
key: "Networks",
|
|
2049
2019
|
value: function Networks() {
|
|
@@ -2068,21 +2038,21 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2068
2038
|
*/
|
|
2069
2039
|
}, {
|
|
2070
2040
|
key: "FromNetworkName",
|
|
2071
|
-
value:
|
|
2072
|
-
var _FromNetworkName = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
2073
|
-
var networkName, region, clientIP, trustAuthorityId, staticToken,
|
|
2074
|
-
return _regeneratorRuntime.wrap(function (
|
|
2075
|
-
while (1) switch (
|
|
2041
|
+
value: function () {
|
|
2042
|
+
var _FromNetworkName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28(_ref31) {
|
|
2043
|
+
var networkName, region, clientIP, trustAuthorityId, staticToken, _ref31$ethereumContra, ethereumContractTimeout, _ref31$noCache, noCache, _ref31$noAuth, noAuth, assumeV3, configUrl;
|
|
2044
|
+
return _regeneratorRuntime.wrap(function _callee28$(_context28) {
|
|
2045
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2076
2046
|
case 0:
|
|
2077
|
-
networkName =
|
|
2047
|
+
networkName = _ref31.networkName, region = _ref31.region, clientIP = _ref31.clientIP, trustAuthorityId = _ref31.trustAuthorityId, staticToken = _ref31.staticToken, _ref31$ethereumContra = _ref31.ethereumContractTimeout, ethereumContractTimeout = _ref31$ethereumContra === void 0 ? 10 : _ref31$ethereumContra, _ref31$noCache = _ref31.noCache, noCache = _ref31$noCache === void 0 ? false : _ref31$noCache, _ref31$noAuth = _ref31.noAuth, noAuth = _ref31$noAuth === void 0 ? false : _ref31$noAuth, assumeV3 = _ref31.assumeV3;
|
|
2078
2048
|
configUrl = networks[networkName];
|
|
2079
2049
|
if (configUrl) {
|
|
2080
|
-
|
|
2050
|
+
_context28.next = 4;
|
|
2081
2051
|
break;
|
|
2082
2052
|
}
|
|
2083
2053
|
throw Error("Invalid network name: " + networkName);
|
|
2084
|
-
case
|
|
2085
|
-
|
|
2054
|
+
case 4:
|
|
2055
|
+
_context28.next = 6;
|
|
2086
2056
|
return this.FromConfigurationUrl({
|
|
2087
2057
|
configUrl: configUrl,
|
|
2088
2058
|
region: region,
|
|
@@ -2094,15 +2064,15 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2094
2064
|
noAuth: noAuth,
|
|
2095
2065
|
assumeV3: assumeV3
|
|
2096
2066
|
});
|
|
2097
|
-
case
|
|
2098
|
-
return
|
|
2099
|
-
case
|
|
2067
|
+
case 6:
|
|
2068
|
+
return _context28.abrupt("return", _context28.sent);
|
|
2069
|
+
case 7:
|
|
2100
2070
|
case "end":
|
|
2101
|
-
return
|
|
2071
|
+
return _context28.stop();
|
|
2102
2072
|
}
|
|
2103
|
-
},
|
|
2073
|
+
}, _callee28, this);
|
|
2104
2074
|
}));
|
|
2105
|
-
function FromNetworkName(
|
|
2075
|
+
function FromNetworkName(_x24) {
|
|
2106
2076
|
return _FromNetworkName.apply(this, arguments);
|
|
2107
2077
|
}
|
|
2108
2078
|
return FromNetworkName;
|
|
@@ -2123,24 +2093,23 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2123
2093
|
*
|
|
2124
2094
|
* @return {Promise<ElvClient>} - New ElvClient connected to the specified content fabric and blockchain
|
|
2125
2095
|
*/
|
|
2126
|
-
)
|
|
2127
2096
|
}, {
|
|
2128
2097
|
key: "FromConfigurationUrl",
|
|
2129
|
-
value:
|
|
2130
|
-
var _FromConfigurationUrl = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
2131
|
-
var configUrl, region, clientIP, trustAuthorityId, staticToken,
|
|
2132
|
-
return _regeneratorRuntime.wrap(function (
|
|
2133
|
-
while (1) switch (
|
|
2098
|
+
value: function () {
|
|
2099
|
+
var _FromConfigurationUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29(_ref32) {
|
|
2100
|
+
var configUrl, region, clientIP, trustAuthorityId, staticToken, _ref32$ethereumContra, ethereumContractTimeout, _ref32$noCache, noCache, _ref32$noAuth, noAuth, _ref32$assumeV, assumeV3, _yield$ElvClient$Conf3, contentSpaceId, networkId, networkName, fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs, fabricVersion, client;
|
|
2101
|
+
return _regeneratorRuntime.wrap(function _callee29$(_context29) {
|
|
2102
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2134
2103
|
case 0:
|
|
2135
|
-
configUrl =
|
|
2136
|
-
|
|
2104
|
+
configUrl = _ref32.configUrl, 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, _ref32$assumeV = _ref32.assumeV3, assumeV3 = _ref32$assumeV === void 0 ? false : _ref32$assumeV;
|
|
2105
|
+
_context29.next = 3;
|
|
2137
2106
|
return ElvClient.Configuration({
|
|
2138
2107
|
configUrl: configUrl,
|
|
2139
2108
|
clientIP: clientIP,
|
|
2140
2109
|
region: region
|
|
2141
2110
|
});
|
|
2142
|
-
case
|
|
2143
|
-
_yield$ElvClient$Conf3 =
|
|
2111
|
+
case 3:
|
|
2112
|
+
_yield$ElvClient$Conf3 = _context29.sent;
|
|
2144
2113
|
contentSpaceId = _yield$ElvClient$Conf3.contentSpaceId;
|
|
2145
2114
|
networkId = _yield$ElvClient$Conf3.networkId;
|
|
2146
2115
|
networkName = _yield$ElvClient$Conf3.networkName;
|
|
@@ -2170,19 +2139,20 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2170
2139
|
client.configUrl = configUrl;
|
|
2171
2140
|
client.region = region;
|
|
2172
2141
|
client.clientIP = clientIP;
|
|
2173
|
-
return
|
|
2174
|
-
case
|
|
2142
|
+
return _context29.abrupt("return", client);
|
|
2143
|
+
case 18:
|
|
2175
2144
|
case "end":
|
|
2176
|
-
return
|
|
2145
|
+
return _context29.stop();
|
|
2177
2146
|
}
|
|
2178
|
-
},
|
|
2147
|
+
}, _callee29);
|
|
2179
2148
|
}));
|
|
2180
|
-
function FromConfigurationUrl(
|
|
2149
|
+
function FromConfigurationUrl(_x25) {
|
|
2181
2150
|
return _FromConfigurationUrl.apply(this, arguments);
|
|
2182
2151
|
}
|
|
2183
2152
|
return FromConfigurationUrl;
|
|
2184
|
-
}()
|
|
2153
|
+
}()
|
|
2185
2154
|
}]);
|
|
2155
|
+
return ElvClient;
|
|
2186
2156
|
}();
|
|
2187
2157
|
Object.assign(ElvClient.prototype, require("./client/AccessGroups"));
|
|
2188
2158
|
Object.assign(ElvClient.prototype, require("./client/ContentAccess"));
|