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