@eluvio/elv-client-js 4.2.13 → 4.2.15
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 +723 -710
- package/dist/src/ContentObjectAudit.js +56 -56
- package/dist/src/Crypto.js +85 -85
- package/dist/src/ElvClient.js +502 -530
- package/dist/src/ElvWallet.js +28 -30
- package/dist/src/EthClient.js +311 -311
- package/dist/src/FrameClient.js +65 -64
- 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 +178 -123
- 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 +239 -239
- package/dist/src/client/AccessGroups.js +474 -477
- package/dist/src/client/ContentAccess.js +1713 -1708
- package/dist/src/client/ContentManagement.js +871 -871
- package/dist/src/client/Contracts.js +736 -582
- package/dist/src/client/Files.js +684 -700
- package/dist/src/client/LiveConf.js +6 -1
- package/dist/src/client/LiveStream.js +686 -722
- 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 +584 -581
- package/package.json +3 -2
- package/src/ElvClient.js +2 -1
- package/src/FrameClient.js +3 -0
- package/src/LogMessage.js +1 -1
- package/src/RemoteSigner.js +17 -3
- package/src/client/ABRPublishing.js +1 -1
- package/src/client/ContentAccess.js +17 -13
- package/src/client/Contracts.js +88 -7
- package/src/walletClient/index.js +15 -4
- package/utilities/ChannelCreate.js +1 -1
- package/utilities/CompositionCreate.js +517 -0
- package/utilities/LibraryDownloadMp4.js +371 -0
- package/utilities/MezDownloadMp4.js +177 -0
- package/utilities/lib/DownloadFile.js +88 -0
- package/utilities/lib/FrameAccurateVideo.js +431 -0
- package/utilities/lib/concerns/Metadata.js +2 -1
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,43 @@ 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, userIdCode, 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.
|
|
833
|
+
idToken = _ref12.idToken, userIdCode = _ref12.userIdCode, 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 = userIdCode;
|
|
838
|
+
_context8.t4 = authToken;
|
|
839
|
+
_context8.t5 = tenantId;
|
|
840
|
+
_context8.next = 9;
|
|
845
841
|
return this.ethClient.Provider();
|
|
846
|
-
case
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
signerURIs:
|
|
852
|
-
idToken:
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
842
|
+
case 9:
|
|
843
|
+
_context8.t6 = _context8.sent;
|
|
844
|
+
_context8.t7 = extraData;
|
|
845
|
+
_context8.t8 = unsignedPublicAuth;
|
|
846
|
+
_context8.t9 = {
|
|
847
|
+
signerURIs: _context8.t1,
|
|
848
|
+
idToken: _context8.t2,
|
|
849
|
+
userIdCode: _context8.t3,
|
|
850
|
+
authToken: _context8.t4,
|
|
851
|
+
tenantId: _context8.t5,
|
|
852
|
+
provider: _context8.t6,
|
|
853
|
+
extraData: _context8.t7,
|
|
854
|
+
unsignedPublicAuth: _context8.t8
|
|
858
855
|
};
|
|
859
|
-
signer = new
|
|
860
|
-
_context8.next =
|
|
856
|
+
signer = new _context8.t0(_context8.t9);
|
|
857
|
+
_context8.next = 16;
|
|
861
858
|
return signer.Initialize();
|
|
862
|
-
case
|
|
859
|
+
case 16:
|
|
863
860
|
this.SetSigner({
|
|
864
861
|
signer: signer
|
|
865
862
|
});
|
|
866
|
-
case
|
|
863
|
+
case 17:
|
|
867
864
|
case "end":
|
|
868
865
|
return _context8.stop();
|
|
869
866
|
}
|
|
@@ -884,27 +881,26 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
884
881
|
* @namedParams
|
|
885
882
|
* @param {object} provider - The web3 provider object
|
|
886
883
|
*/
|
|
887
|
-
)
|
|
888
884
|
}, {
|
|
889
885
|
key: "SetSignerFromWeb3Provider",
|
|
890
|
-
value:
|
|
891
|
-
var _SetSignerFromWeb3Provider = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(
|
|
886
|
+
value: function () {
|
|
887
|
+
var _SetSignerFromWeb3Provider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref13) {
|
|
892
888
|
var provider, ethProvider;
|
|
893
|
-
return _regeneratorRuntime.wrap(function (_context9) {
|
|
889
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
894
890
|
while (1) switch (_context9.prev = _context9.next) {
|
|
895
891
|
case 0:
|
|
896
|
-
provider =
|
|
892
|
+
provider = _ref13.provider;
|
|
897
893
|
this.staticToken = undefined;
|
|
898
894
|
ethProvider = new Ethers.providers.Web3Provider(provider);
|
|
899
895
|
ethProvider.pollingInterval = 250;
|
|
900
896
|
this.signer = ethProvider.getSigner();
|
|
901
|
-
_context9.next =
|
|
897
|
+
_context9.next = 7;
|
|
902
898
|
return this.signer.getAddress();
|
|
903
|
-
case
|
|
899
|
+
case 7:
|
|
904
900
|
this.signer.address = _context9.sent;
|
|
905
|
-
_context9.next =
|
|
901
|
+
_context9.next = 10;
|
|
906
902
|
return this.InitializeClients();
|
|
907
|
-
case
|
|
903
|
+
case 10:
|
|
908
904
|
case "end":
|
|
909
905
|
return _context9.stop();
|
|
910
906
|
}
|
|
@@ -930,16 +926,15 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
930
926
|
*
|
|
931
927
|
* @return {string} - The address of the user
|
|
932
928
|
*/
|
|
933
|
-
)
|
|
934
929
|
}, {
|
|
935
930
|
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 (
|
|
931
|
+
value: function () {
|
|
932
|
+
var _CreateAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref14) {
|
|
933
|
+
var tenantId, fundingToken, _ref14$funds, funds, groupToken, wallet, signer;
|
|
934
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
935
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
941
936
|
case 0:
|
|
942
|
-
tenantId =
|
|
937
|
+
tenantId = _ref14.tenantId, fundingToken = _ref14.fundingToken, _ref14$funds = _ref14.funds, funds = _ref14$funds === void 0 ? 0.5 : _ref14$funds, groupToken = _ref14.groupToken;
|
|
943
938
|
if (!this.signer) {
|
|
944
939
|
wallet = this.GenerateWallet();
|
|
945
940
|
signer = wallet.AddAccountFromMnemonic({
|
|
@@ -949,7 +944,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
949
944
|
signer: signer
|
|
950
945
|
});
|
|
951
946
|
}
|
|
952
|
-
|
|
947
|
+
_context10.next = 4;
|
|
953
948
|
return this.authClient.MakeKMSRequest({
|
|
954
949
|
method: "POST",
|
|
955
950
|
path: "/ks/otp/fnd/".concat(tenantId),
|
|
@@ -961,21 +956,21 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
961
956
|
Authorization: "Bearer ".concat(fundingToken)
|
|
962
957
|
}
|
|
963
958
|
});
|
|
964
|
-
case
|
|
965
|
-
|
|
959
|
+
case 4:
|
|
960
|
+
_context10.next = 6;
|
|
966
961
|
return this.userProfileClient.CreateWallet();
|
|
967
|
-
case
|
|
968
|
-
|
|
962
|
+
case 6:
|
|
963
|
+
_context10.next = 8;
|
|
969
964
|
return this.userProfileClient.ReplaceUserMetadata({
|
|
970
965
|
metadataSubtree: "tenantContractId",
|
|
971
966
|
metadata: tenantId
|
|
972
967
|
});
|
|
973
|
-
case
|
|
968
|
+
case 8:
|
|
974
969
|
if (!groupToken) {
|
|
975
|
-
|
|
970
|
+
_context10.next = 11;
|
|
976
971
|
break;
|
|
977
972
|
}
|
|
978
|
-
|
|
973
|
+
_context10.next = 11;
|
|
979
974
|
return this.authClient.MakeKMSRequest({
|
|
980
975
|
method: "POST",
|
|
981
976
|
path: "/ks/otp/grp/".concat(tenantId),
|
|
@@ -986,13 +981,13 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
986
981
|
Authorization: "Bearer ".concat(groupToken)
|
|
987
982
|
}
|
|
988
983
|
});
|
|
989
|
-
case
|
|
990
|
-
return
|
|
991
|
-
case
|
|
984
|
+
case 11:
|
|
985
|
+
return _context10.abrupt("return", this.utils.FormatAddress(this.signer.address));
|
|
986
|
+
case 12:
|
|
992
987
|
case "end":
|
|
993
|
-
return
|
|
988
|
+
return _context10.stop();
|
|
994
989
|
}
|
|
995
|
-
},
|
|
990
|
+
}, _callee10, this);
|
|
996
991
|
}));
|
|
997
992
|
function CreateAccount(_x6) {
|
|
998
993
|
return _CreateAccount.apply(this, arguments);
|
|
@@ -1008,67 +1003,65 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1008
1003
|
PAYLOAD 85b json-compressed
|
|
1009
1004
|
json 79b {"adr":"VVf4DQU357tDnZGYQeDrntRJ5rs=","spc":"ispc3ANoVSzNA3P6t7abLR69ho5YPPZU"}
|
|
1010
1005
|
*/
|
|
1011
|
-
)
|
|
1012
1006
|
}, {
|
|
1013
1007
|
key: "PersonalSign",
|
|
1014
|
-
value:
|
|
1015
|
-
var _PersonalSign = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1008
|
+
value: function () {
|
|
1009
|
+
var _PersonalSign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref15) {
|
|
1016
1010
|
var _this2 = this;
|
|
1017
1011
|
var message, addEthereumPrefix, Sign;
|
|
1018
|
-
return _regeneratorRuntime.wrap(function (
|
|
1019
|
-
while (1) switch (
|
|
1012
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
1013
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1020
1014
|
case 0:
|
|
1021
|
-
message =
|
|
1015
|
+
message = _ref15.message, addEthereumPrefix = _ref15.addEthereumPrefix, Sign = _ref15.Sign;
|
|
1022
1016
|
if (!Sign) {
|
|
1023
1017
|
// Same as authClient.Sign, but authClient may not yet be initialized
|
|
1024
1018
|
Sign = /*#__PURE__*/function () {
|
|
1025
|
-
var
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
while (1) switch (_context1.prev = _context1.next) {
|
|
1019
|
+
var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(message) {
|
|
1020
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
1021
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1029
1022
|
case 0:
|
|
1030
|
-
|
|
1023
|
+
_context11.t0 = Ethers.utils;
|
|
1031
1024
|
if (!_this2.signer.signDigest) {
|
|
1032
|
-
|
|
1025
|
+
_context11.next = 7;
|
|
1033
1026
|
break;
|
|
1034
1027
|
}
|
|
1035
|
-
|
|
1028
|
+
_context11.next = 4;
|
|
1036
1029
|
return _this2.signer.signDigest(message);
|
|
1037
|
-
case
|
|
1038
|
-
|
|
1039
|
-
|
|
1030
|
+
case 4:
|
|
1031
|
+
_context11.t1 = _context11.sent;
|
|
1032
|
+
_context11.next = 10;
|
|
1040
1033
|
break;
|
|
1041
|
-
case
|
|
1042
|
-
|
|
1034
|
+
case 7:
|
|
1035
|
+
_context11.next = 9;
|
|
1043
1036
|
return _this2.signer._signingKey().signDigest(message);
|
|
1044
|
-
case
|
|
1045
|
-
|
|
1046
|
-
case
|
|
1047
|
-
|
|
1048
|
-
return
|
|
1049
|
-
case
|
|
1037
|
+
case 9:
|
|
1038
|
+
_context11.t1 = _context11.sent;
|
|
1039
|
+
case 10:
|
|
1040
|
+
_context11.t2 = _context11.t1;
|
|
1041
|
+
return _context11.abrupt("return", _context11.t0.joinSignature.call(_context11.t0, _context11.t2));
|
|
1042
|
+
case 12:
|
|
1050
1043
|
case "end":
|
|
1051
|
-
return
|
|
1044
|
+
return _context11.stop();
|
|
1052
1045
|
}
|
|
1053
|
-
},
|
|
1046
|
+
}, _callee11);
|
|
1054
1047
|
}));
|
|
1055
1048
|
return function Sign(_x8) {
|
|
1056
|
-
return
|
|
1049
|
+
return _ref16.apply(this, arguments);
|
|
1057
1050
|
};
|
|
1058
1051
|
}();
|
|
1059
1052
|
}
|
|
1060
1053
|
if (addEthereumPrefix) {
|
|
1061
1054
|
message = Ethers.utils.keccak256(Buffer.from("\x19Ethereum Signed Message:\n".concat(message.length).concat(message), "utf-8"));
|
|
1062
1055
|
}
|
|
1063
|
-
|
|
1056
|
+
_context12.next = 5;
|
|
1064
1057
|
return Sign(message);
|
|
1065
|
-
case
|
|
1066
|
-
return
|
|
1067
|
-
case
|
|
1058
|
+
case 5:
|
|
1059
|
+
return _context12.abrupt("return", _context12.sent);
|
|
1060
|
+
case 6:
|
|
1068
1061
|
case "end":
|
|
1069
|
-
return
|
|
1062
|
+
return _context12.stop();
|
|
1070
1063
|
}
|
|
1071
|
-
},
|
|
1064
|
+
}, _callee12);
|
|
1072
1065
|
}));
|
|
1073
1066
|
function PersonalSign(_x7) {
|
|
1074
1067
|
return _PersonalSign.apply(this, arguments);
|
|
@@ -1086,79 +1079,68 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1086
1079
|
* @param {function=} Sign - If specified, this function will be used to produce the signature instead of the client's current signer
|
|
1087
1080
|
* @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
1081
|
*/
|
|
1089
|
-
)
|
|
1090
1082
|
}, {
|
|
1091
1083
|
key: "CreateFabricToken",
|
|
1092
|
-
value:
|
|
1093
|
-
var _CreateFabricToken = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1094
|
-
var
|
|
1095
|
-
|
|
1084
|
+
value: function () {
|
|
1085
|
+
var _CreateFabricToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
|
|
1086
|
+
var _ref17,
|
|
1087
|
+
_ref17$duration,
|
|
1096
1088
|
duration,
|
|
1097
|
-
|
|
1089
|
+
_ref17$spec,
|
|
1098
1090
|
spec,
|
|
1099
1091
|
address,
|
|
1100
1092
|
Sign,
|
|
1101
|
-
|
|
1093
|
+
_ref17$addEthereumPre,
|
|
1102
1094
|
addEthereumPrefix,
|
|
1103
|
-
|
|
1095
|
+
_ref17$context,
|
|
1104
1096
|
context,
|
|
1105
1097
|
token,
|
|
1106
1098
|
message,
|
|
1107
1099
|
signature,
|
|
1108
1100
|
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) {
|
|
1101
|
+
_args13 = arguments;
|
|
1102
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
1103
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1122
1104
|
case 0:
|
|
1123
|
-
|
|
1105
|
+
_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
1106
|
address = address || this.CurrentAccountAddress();
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1107
|
+
_context13.t0 = _objectSpread;
|
|
1108
|
+
_context13.t1 = _objectSpread({}, spec);
|
|
1109
|
+
_context13.t2 = {};
|
|
1110
|
+
_context13.t3 = "iusr".concat(Utils.AddressToHash(address));
|
|
1111
|
+
_context13.t4 = Buffer.from(address.replace(/^0x/, ""), "hex").toString("base64");
|
|
1112
|
+
_context13.next = 9;
|
|
1131
1113
|
return this.ContentSpaceId();
|
|
1132
|
-
case
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
sub:
|
|
1139
|
-
adr:
|
|
1140
|
-
spc:
|
|
1141
|
-
iat:
|
|
1142
|
-
exp:
|
|
1143
|
-
ctx:
|
|
1114
|
+
case 9:
|
|
1115
|
+
_context13.t5 = _context13.sent;
|
|
1116
|
+
_context13.t6 = Date.now();
|
|
1117
|
+
_context13.t7 = Date.now() + duration;
|
|
1118
|
+
_context13.t8 = context;
|
|
1119
|
+
_context13.t9 = {
|
|
1120
|
+
sub: _context13.t3,
|
|
1121
|
+
adr: _context13.t4,
|
|
1122
|
+
spc: _context13.t5,
|
|
1123
|
+
iat: _context13.t6,
|
|
1124
|
+
exp: _context13.t7,
|
|
1125
|
+
ctx: _context13.t8
|
|
1144
1126
|
};
|
|
1145
|
-
token =
|
|
1127
|
+
token = (0, _context13.t0)(_context13.t1, _context13.t2, _context13.t9);
|
|
1146
1128
|
message = "Eluvio Content Fabric Access Token 1.0\n".concat(JSON.stringify(token));
|
|
1147
|
-
|
|
1129
|
+
_context13.next = 18;
|
|
1148
1130
|
return this.PersonalSign({
|
|
1149
1131
|
message: message,
|
|
1150
1132
|
addEthereumPrefix: addEthereumPrefix,
|
|
1151
1133
|
Sign: Sign
|
|
1152
1134
|
});
|
|
1153
|
-
case
|
|
1154
|
-
signature =
|
|
1135
|
+
case 18:
|
|
1136
|
+
signature = _context13.sent;
|
|
1155
1137
|
compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
|
|
1156
|
-
return
|
|
1157
|
-
case
|
|
1138
|
+
return _context13.abrupt("return", "acspjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
|
|
1139
|
+
case 21:
|
|
1158
1140
|
case "end":
|
|
1159
|
-
return
|
|
1141
|
+
return _context13.stop();
|
|
1160
1142
|
}
|
|
1161
|
-
},
|
|
1143
|
+
}, _callee13, this);
|
|
1162
1144
|
}));
|
|
1163
1145
|
function CreateFabricToken() {
|
|
1164
1146
|
return _CreateFabricToken.apply(this, arguments);
|
|
@@ -1183,127 +1165,126 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1183
1165
|
* @param {number=} issueTime - Issue Time in milliseconds
|
|
1184
1166
|
* @param {number=} expirationTime - Expiration Time in milliseconds
|
|
1185
1167
|
*/
|
|
1186
|
-
)
|
|
1187
1168
|
}, {
|
|
1188
1169
|
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 (
|
|
1170
|
+
value: function () {
|
|
1171
|
+
var _CreateSignedToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref18) {
|
|
1172
|
+
var libraryId, objectId, versionHash, policyId, subject, _ref18$grantType, grantType, _ref18$allowDecryptio, allowDecryption, duration, _ref18$context, context, issueTime, expirationTime, issueDateTime, token, cap, compressedToken, signature;
|
|
1173
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
1174
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1194
1175
|
case 0:
|
|
1195
|
-
libraryId =
|
|
1176
|
+
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
1177
|
if (subject) {
|
|
1197
|
-
|
|
1178
|
+
_context14.next = 9;
|
|
1198
1179
|
break;
|
|
1199
1180
|
}
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1181
|
+
_context14.t0 = "iusr";
|
|
1182
|
+
_context14.t1 = this.utils;
|
|
1183
|
+
_context14.next = 6;
|
|
1203
1184
|
return this.CurrentAccountAddress();
|
|
1204
|
-
case
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
subject =
|
|
1208
|
-
case
|
|
1185
|
+
case 6:
|
|
1186
|
+
_context14.t2 = _context14.sent;
|
|
1187
|
+
_context14.t3 = _context14.t1.AddressToHash.call(_context14.t1, _context14.t2);
|
|
1188
|
+
subject = _context14.t0.concat.call(_context14.t0, _context14.t3);
|
|
1189
|
+
case 9:
|
|
1209
1190
|
if (policyId) {
|
|
1210
1191
|
context["elv:delegation-id"] = policyId;
|
|
1211
1192
|
}
|
|
1212
1193
|
issueDateTime = issueTime || Date.now();
|
|
1213
|
-
|
|
1214
|
-
|
|
1194
|
+
_context14.t4 = Buffer;
|
|
1195
|
+
_context14.next = 14;
|
|
1215
1196
|
return this.CurrentAccountAddress().replace(/^0x/, "");
|
|
1216
|
-
case
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1197
|
+
case 14:
|
|
1198
|
+
_context14.t5 = _context14.sent;
|
|
1199
|
+
_context14.t6 = _context14.t4.from.call(_context14.t4, _context14.t5, "hex").toString("base64");
|
|
1200
|
+
_context14.t7 = subject;
|
|
1201
|
+
_context14.next = 19;
|
|
1221
1202
|
return this.ContentSpaceId();
|
|
1222
|
-
case
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1203
|
+
case 19:
|
|
1204
|
+
_context14.t8 = _context14.sent;
|
|
1205
|
+
_context14.t9 = issueDateTime;
|
|
1206
|
+
_context14.t10 = expirationTime || issueDateTime + duration;
|
|
1207
|
+
_context14.t11 = grantType;
|
|
1208
|
+
_context14.t12 = context;
|
|
1228
1209
|
token = {
|
|
1229
|
-
adr:
|
|
1230
|
-
sub:
|
|
1231
|
-
spc:
|
|
1232
|
-
iat:
|
|
1233
|
-
exp:
|
|
1234
|
-
gra:
|
|
1235
|
-
ctx:
|
|
1210
|
+
adr: _context14.t6,
|
|
1211
|
+
sub: _context14.t7,
|
|
1212
|
+
spc: _context14.t8,
|
|
1213
|
+
iat: _context14.t9,
|
|
1214
|
+
exp: _context14.t10,
|
|
1215
|
+
gra: _context14.t11,
|
|
1216
|
+
ctx: _context14.t12
|
|
1236
1217
|
};
|
|
1237
1218
|
if (versionHash) {
|
|
1238
1219
|
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1239
1220
|
}
|
|
1240
1221
|
if (!objectId) {
|
|
1241
|
-
|
|
1222
|
+
_context14.next = 32;
|
|
1242
1223
|
break;
|
|
1243
1224
|
}
|
|
1244
1225
|
token.qid = objectId;
|
|
1245
1226
|
if (libraryId) {
|
|
1246
|
-
|
|
1227
|
+
_context14.next = 32;
|
|
1247
1228
|
break;
|
|
1248
1229
|
}
|
|
1249
|
-
|
|
1230
|
+
_context14.next = 31;
|
|
1250
1231
|
return this.ContentObjectLibraryId({
|
|
1251
1232
|
objectId: objectId
|
|
1252
1233
|
});
|
|
1253
|
-
case
|
|
1254
|
-
libraryId =
|
|
1255
|
-
case
|
|
1234
|
+
case 31:
|
|
1235
|
+
libraryId = _context14.sent;
|
|
1236
|
+
case 32:
|
|
1256
1237
|
if (libraryId) {
|
|
1257
1238
|
token.lib = libraryId;
|
|
1258
1239
|
}
|
|
1259
1240
|
if (!allowDecryption) {
|
|
1260
|
-
|
|
1241
|
+
_context14.next = 38;
|
|
1261
1242
|
break;
|
|
1262
1243
|
}
|
|
1263
|
-
|
|
1244
|
+
_context14.next = 36;
|
|
1264
1245
|
return this.authClient.ReEncryptionConk({
|
|
1265
1246
|
libraryId: libraryId,
|
|
1266
1247
|
objectId: objectId
|
|
1267
1248
|
});
|
|
1268
|
-
case
|
|
1269
|
-
cap =
|
|
1249
|
+
case 36:
|
|
1250
|
+
cap = _context14.sent;
|
|
1270
1251
|
token.apk = cap.public_key;
|
|
1271
|
-
case
|
|
1252
|
+
case 38:
|
|
1272
1253
|
compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
|
|
1273
|
-
|
|
1254
|
+
_context14.next = 41;
|
|
1274
1255
|
return this.authClient.Sign(Ethers.utils.keccak256(compressedToken));
|
|
1275
|
-
case
|
|
1276
|
-
signature =
|
|
1277
|
-
return
|
|
1278
|
-
case
|
|
1256
|
+
case 41:
|
|
1257
|
+
signature = _context14.sent;
|
|
1258
|
+
return _context14.abrupt("return", "aessjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
|
|
1259
|
+
case 43:
|
|
1279
1260
|
case "end":
|
|
1280
|
-
return
|
|
1261
|
+
return _context14.stop();
|
|
1281
1262
|
}
|
|
1282
|
-
},
|
|
1263
|
+
}, _callee14, this);
|
|
1283
1264
|
}));
|
|
1284
1265
|
function CreateSignedToken(_x9) {
|
|
1285
1266
|
return _CreateSignedToken.apply(this, arguments);
|
|
1286
1267
|
}
|
|
1287
1268
|
return CreateSignedToken;
|
|
1288
|
-
}()
|
|
1269
|
+
}()
|
|
1289
1270
|
}, {
|
|
1290
1271
|
key: "CreateAuthorizationToken",
|
|
1291
1272
|
value: function () {
|
|
1292
|
-
var _CreateAuthorizationToken = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1293
|
-
return _regeneratorRuntime.wrap(function (
|
|
1294
|
-
while (1) switch (
|
|
1273
|
+
var _CreateAuthorizationToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(args) {
|
|
1274
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
1275
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1295
1276
|
case 0:
|
|
1296
|
-
|
|
1277
|
+
_context15.next = 2;
|
|
1297
1278
|
return this.authClient.AuthorizationToken(args);
|
|
1298
|
-
case 1:
|
|
1299
|
-
return _context13.abrupt("return", _context13.sent);
|
|
1300
1279
|
case 2:
|
|
1280
|
+
return _context15.abrupt("return", _context15.sent);
|
|
1281
|
+
case 3:
|
|
1301
1282
|
case "end":
|
|
1302
|
-
return
|
|
1283
|
+
return _context15.stop();
|
|
1303
1284
|
}
|
|
1304
|
-
},
|
|
1285
|
+
}, _callee15, this);
|
|
1305
1286
|
}));
|
|
1306
|
-
function CreateAuthorizationToken(
|
|
1287
|
+
function CreateAuthorizationToken(_x10) {
|
|
1307
1288
|
return _CreateAuthorizationToken.apply(this, arguments);
|
|
1308
1289
|
}
|
|
1309
1290
|
return CreateAuthorizationToken;
|
|
@@ -1324,31 +1305,31 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1324
1305
|
*/
|
|
1325
1306
|
}, {
|
|
1326
1307
|
key: "CreateSignedMessageJSON",
|
|
1327
|
-
value:
|
|
1328
|
-
var _CreateSignedMessageJSON = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1308
|
+
value: function () {
|
|
1309
|
+
var _CreateSignedMessageJSON = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref19) {
|
|
1329
1310
|
var message, type, msg, signature;
|
|
1330
|
-
return _regeneratorRuntime.wrap(function (
|
|
1331
|
-
while (1) switch (
|
|
1311
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
1312
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1332
1313
|
case 0:
|
|
1333
|
-
message =
|
|
1314
|
+
message = _ref19.message;
|
|
1334
1315
|
// Only one kind of signature supported currently
|
|
1335
1316
|
type = "mje_"; // JSON message, EIP192 signature
|
|
1336
1317
|
msg = JSON.stringify(message);
|
|
1337
|
-
|
|
1318
|
+
_context16.next = 5;
|
|
1338
1319
|
return this.PersonalSign({
|
|
1339
1320
|
message: msg,
|
|
1340
1321
|
addEthereumPrefix: true
|
|
1341
1322
|
});
|
|
1342
|
-
case
|
|
1343
|
-
signature =
|
|
1344
|
-
return
|
|
1345
|
-
case
|
|
1323
|
+
case 5:
|
|
1324
|
+
signature = _context16.sent;
|
|
1325
|
+
return _context16.abrupt("return", "".concat(type).concat(Utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(msg)]))));
|
|
1326
|
+
case 7:
|
|
1346
1327
|
case "end":
|
|
1347
|
-
return
|
|
1328
|
+
return _context16.stop();
|
|
1348
1329
|
}
|
|
1349
|
-
},
|
|
1330
|
+
}, _callee16, this);
|
|
1350
1331
|
}));
|
|
1351
|
-
function CreateSignedMessageJSON(
|
|
1332
|
+
function CreateSignedMessageJSON(_x11) {
|
|
1352
1333
|
return _CreateSignedMessageJSON.apply(this, arguments);
|
|
1353
1334
|
}
|
|
1354
1335
|
return CreateSignedMessageJSON;
|
|
@@ -1361,42 +1342,41 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1361
1342
|
* @param {string} signedMessage - a signed message as created by CreateSignedMessageJSON
|
|
1362
1343
|
* @returns {Promise<Object>} - The decoded message, signer address, signature and signature type
|
|
1363
1344
|
*/
|
|
1364
|
-
)
|
|
1365
1345
|
}, {
|
|
1366
1346
|
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 (
|
|
1347
|
+
value: function () {
|
|
1348
|
+
var _DecodeSignedMessageJSON = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref20) {
|
|
1349
|
+
var signedMessage, type, msgBytes, signature, msg, obj, prefixedMsgHash, signerAddr;
|
|
1350
|
+
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
1351
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1372
1352
|
case 0:
|
|
1373
|
-
signedMessage =
|
|
1353
|
+
signedMessage = _ref20.signedMessage;
|
|
1374
1354
|
type = signedMessage.slice(0, 4);
|
|
1375
|
-
|
|
1376
|
-
|
|
1355
|
+
_context17.t0 = type;
|
|
1356
|
+
_context17.next = _context17.t0 === "mje_" ? 5 : 12;
|
|
1377
1357
|
break;
|
|
1378
|
-
case
|
|
1358
|
+
case 5:
|
|
1379
1359
|
msgBytes = Utils.FromB58(signedMessage.slice(4));
|
|
1380
1360
|
signature = msgBytes.slice(0, 65);
|
|
1381
1361
|
msg = msgBytes.slice(65);
|
|
1382
1362
|
obj = JSON.parse(msg);
|
|
1383
1363
|
prefixedMsgHash = Ethers.utils.keccak256(Buffer.from("\x19Ethereum Signed Message:\n".concat(msg.length).concat(msg), "utf-8"));
|
|
1384
1364
|
signerAddr = Ethers.utils.recoverAddress(prefixedMsgHash, signature);
|
|
1385
|
-
return
|
|
1365
|
+
return _context17.abrupt("return", {
|
|
1386
1366
|
type: type,
|
|
1387
1367
|
message: obj,
|
|
1388
1368
|
signerAddress: signerAddr,
|
|
1389
1369
|
signature: "0x" + signature.toString("hex")
|
|
1390
1370
|
});
|
|
1391
|
-
case
|
|
1371
|
+
case 12:
|
|
1392
1372
|
throw new Error("Bad message type: ".concat(type));
|
|
1393
|
-
case
|
|
1373
|
+
case 13:
|
|
1394
1374
|
case "end":
|
|
1395
|
-
return
|
|
1375
|
+
return _context17.stop();
|
|
1396
1376
|
}
|
|
1397
|
-
},
|
|
1377
|
+
}, _callee17);
|
|
1398
1378
|
}));
|
|
1399
|
-
function DecodeSignedMessageJSON(
|
|
1379
|
+
function DecodeSignedMessageJSON(_x12) {
|
|
1400
1380
|
return _DecodeSignedMessageJSON.apply(this, arguments);
|
|
1401
1381
|
}
|
|
1402
1382
|
return DecodeSignedMessageJSON;
|
|
@@ -1407,7 +1387,6 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1407
1387
|
* @methodGroup Signers
|
|
1408
1388
|
* @returns {string} - The address of the current signer
|
|
1409
1389
|
*/
|
|
1410
|
-
)
|
|
1411
1390
|
}, {
|
|
1412
1391
|
key: "CurrentAccountAddress",
|
|
1413
1392
|
value: function CurrentAccountAddress() {
|
|
@@ -1423,13 +1402,13 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1423
1402
|
*/
|
|
1424
1403
|
}, {
|
|
1425
1404
|
key: "SetOauthToken",
|
|
1426
|
-
value:
|
|
1427
|
-
var _SetOauthToken = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1405
|
+
value: function () {
|
|
1406
|
+
var _SetOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref21) {
|
|
1428
1407
|
var token, wallet, signer;
|
|
1429
|
-
return _regeneratorRuntime.wrap(function (
|
|
1430
|
-
while (1) switch (
|
|
1408
|
+
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
1409
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1431
1410
|
case 0:
|
|
1432
|
-
token =
|
|
1411
|
+
token = _ref21.token;
|
|
1433
1412
|
this.oauthToken = token;
|
|
1434
1413
|
wallet = this.GenerateWallet();
|
|
1435
1414
|
signer = wallet.AddAccountFromMnemonic({
|
|
@@ -1438,13 +1417,13 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1438
1417
|
this.SetSigner({
|
|
1439
1418
|
signer: signer
|
|
1440
1419
|
});
|
|
1441
|
-
case
|
|
1420
|
+
case 5:
|
|
1442
1421
|
case "end":
|
|
1443
|
-
return
|
|
1422
|
+
return _context18.stop();
|
|
1444
1423
|
}
|
|
1445
|
-
},
|
|
1424
|
+
}, _callee18, this);
|
|
1446
1425
|
}));
|
|
1447
|
-
function SetOauthToken(
|
|
1426
|
+
function SetOauthToken(_x13) {
|
|
1448
1427
|
return _SetOauthToken.apply(this, arguments);
|
|
1449
1428
|
}
|
|
1450
1429
|
return SetOauthToken;
|
|
@@ -1459,61 +1438,60 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1459
1438
|
* @namedParams
|
|
1460
1439
|
* @param {string} token - The OAuth ID
|
|
1461
1440
|
*/
|
|
1462
|
-
)
|
|
1463
1441
|
}, {
|
|
1464
1442
|
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 (
|
|
1443
|
+
value: function () {
|
|
1444
|
+
var _SetSignerFromOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(_ref22) {
|
|
1445
|
+
var token, wallet, client, _yield$client$authCli, urls, path, httpClient, response, privateKey;
|
|
1446
|
+
return _regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
1447
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1470
1448
|
case 0:
|
|
1471
|
-
token =
|
|
1449
|
+
token = _ref22.token;
|
|
1472
1450
|
if (this.trustAuthorityId) {
|
|
1473
|
-
|
|
1451
|
+
_context19.next = 3;
|
|
1474
1452
|
break;
|
|
1475
1453
|
}
|
|
1476
1454
|
throw Error("Unable to authorize with OAuth token: No trust authority ID set");
|
|
1477
|
-
case
|
|
1455
|
+
case 3:
|
|
1478
1456
|
wallet = this.GenerateWallet();
|
|
1479
|
-
|
|
1457
|
+
_context19.prev = 4;
|
|
1480
1458
|
if (this.kmsURIs) {
|
|
1481
|
-
|
|
1459
|
+
_context19.next = 17;
|
|
1482
1460
|
break;
|
|
1483
1461
|
}
|
|
1484
|
-
|
|
1462
|
+
_context19.next = 8;
|
|
1485
1463
|
return ElvClient.FromConfigurationUrl({
|
|
1486
1464
|
configUrl: this.configUrl
|
|
1487
1465
|
});
|
|
1488
|
-
case
|
|
1489
|
-
client =
|
|
1466
|
+
case 8:
|
|
1467
|
+
client = _context19.sent;
|
|
1490
1468
|
client.SetSigner({
|
|
1491
1469
|
signer: wallet.AddAccount({
|
|
1492
1470
|
privateKey: this.defaultKey
|
|
1493
1471
|
})
|
|
1494
1472
|
});
|
|
1495
|
-
|
|
1473
|
+
_context19.next = 12;
|
|
1496
1474
|
return client.authClient.KMSInfo({
|
|
1497
1475
|
kmsId: this.trustAuthorityId
|
|
1498
1476
|
});
|
|
1499
|
-
case
|
|
1500
|
-
_yield$client$authCli =
|
|
1477
|
+
case 12:
|
|
1478
|
+
_yield$client$authCli = _context19.sent;
|
|
1501
1479
|
urls = _yield$client$authCli.urls;
|
|
1502
1480
|
if (!(!urls || urls.length === 0)) {
|
|
1503
|
-
|
|
1481
|
+
_context19.next = 16;
|
|
1504
1482
|
break;
|
|
1505
1483
|
}
|
|
1506
1484
|
throw Error("Unable to authorize with OAuth token: No KMS URLs set");
|
|
1507
|
-
case
|
|
1485
|
+
case 16:
|
|
1508
1486
|
this.kmsURIs = urls;
|
|
1509
|
-
case
|
|
1487
|
+
case 17:
|
|
1510
1488
|
this.oauthToken = token;
|
|
1511
1489
|
path = "/ks/jwt/wlt";
|
|
1512
1490
|
httpClient = new HttpClient({
|
|
1513
1491
|
uris: this.kmsURIs,
|
|
1514
1492
|
debug: this.debug
|
|
1515
1493
|
});
|
|
1516
|
-
|
|
1494
|
+
_context19.next = 22;
|
|
1517
1495
|
return this.utils.ResponseToJson(httpClient.Request({
|
|
1518
1496
|
headers: {
|
|
1519
1497
|
Authorization: "Bearer ".concat(token)
|
|
@@ -1522,8 +1500,8 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1522
1500
|
path: path,
|
|
1523
1501
|
forceFailover: true
|
|
1524
1502
|
}));
|
|
1525
|
-
case
|
|
1526
|
-
response =
|
|
1503
|
+
case 22:
|
|
1504
|
+
response = _context19.sent;
|
|
1527
1505
|
privateKey = response["UserSKHex"];
|
|
1528
1506
|
this.SetSigner({
|
|
1529
1507
|
signer: wallet.AddAccount({
|
|
@@ -1532,27 +1510,27 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1532
1510
|
});
|
|
1533
1511
|
|
|
1534
1512
|
// Ensure wallet is initialized
|
|
1535
|
-
|
|
1513
|
+
_context19.next = 27;
|
|
1536
1514
|
return this.userProfileClient.WalletAddress();
|
|
1537
|
-
case
|
|
1538
|
-
|
|
1515
|
+
case 27:
|
|
1516
|
+
_context19.next = 36;
|
|
1539
1517
|
break;
|
|
1540
|
-
case
|
|
1541
|
-
|
|
1542
|
-
|
|
1518
|
+
case 29:
|
|
1519
|
+
_context19.prev = 29;
|
|
1520
|
+
_context19.t0 = _context19["catch"](4);
|
|
1543
1521
|
this.Log("Failed to set signer from OAuth token:", true);
|
|
1544
|
-
this.Log(
|
|
1545
|
-
|
|
1522
|
+
this.Log(_context19.t0, true);
|
|
1523
|
+
_context19.next = 35;
|
|
1546
1524
|
return this.ClearSigner();
|
|
1547
|
-
case
|
|
1548
|
-
throw
|
|
1549
|
-
case
|
|
1525
|
+
case 35:
|
|
1526
|
+
throw _context19.t0;
|
|
1527
|
+
case 36:
|
|
1550
1528
|
case "end":
|
|
1551
|
-
return
|
|
1529
|
+
return _context19.stop();
|
|
1552
1530
|
}
|
|
1553
|
-
},
|
|
1531
|
+
}, _callee19, this, [[4, 29]]);
|
|
1554
1532
|
}));
|
|
1555
|
-
function SetSignerFromOauthToken(
|
|
1533
|
+
function SetSignerFromOauthToken(_x14) {
|
|
1556
1534
|
return _SetSignerFromOauthToken.apply(this, arguments);
|
|
1557
1535
|
}
|
|
1558
1536
|
return SetSignerFromOauthToken;
|
|
@@ -1566,13 +1544,12 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1566
1544
|
*
|
|
1567
1545
|
* @return {string} - The created static token
|
|
1568
1546
|
*/
|
|
1569
|
-
)
|
|
1570
1547
|
}, {
|
|
1571
1548
|
key: "CreateStaticToken",
|
|
1572
|
-
value: function CreateStaticToken(
|
|
1573
|
-
var libraryId =
|
|
1549
|
+
value: function CreateStaticToken(_ref23) {
|
|
1550
|
+
var libraryId = _ref23.libraryId;
|
|
1574
1551
|
var token = {
|
|
1575
|
-
qspace_id: this.
|
|
1552
|
+
qspace_id: this.contentSpaceId
|
|
1576
1553
|
};
|
|
1577
1554
|
if (libraryId) {
|
|
1578
1555
|
token.qlib_id = libraryId;
|
|
@@ -1591,10 +1568,10 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1591
1568
|
}, {
|
|
1592
1569
|
key: "SetStaticToken",
|
|
1593
1570
|
value: function SetStaticToken() {
|
|
1594
|
-
var
|
|
1595
|
-
token =
|
|
1596
|
-
|
|
1597
|
-
update =
|
|
1571
|
+
var _ref24 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1572
|
+
token = _ref24.token,
|
|
1573
|
+
_ref24$update = _ref24.update,
|
|
1574
|
+
update = _ref24$update === void 0 ? false : _ref24$update;
|
|
1598
1575
|
if (token) {
|
|
1599
1576
|
this.staticToken = token;
|
|
1600
1577
|
} else {
|
|
@@ -1625,31 +1602,31 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1625
1602
|
*/
|
|
1626
1603
|
}, {
|
|
1627
1604
|
key: "SetPolicyAuthorization",
|
|
1628
|
-
value:
|
|
1629
|
-
var _SetPolicyAuthorization = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1630
|
-
var objectId
|
|
1631
|
-
return _regeneratorRuntime.wrap(function (
|
|
1632
|
-
while (1) switch (
|
|
1605
|
+
value: function () {
|
|
1606
|
+
var _SetPolicyAuthorization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(_ref25) {
|
|
1607
|
+
var objectId;
|
|
1608
|
+
return _regeneratorRuntime.wrap(function _callee20$(_context20) {
|
|
1609
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1633
1610
|
case 0:
|
|
1634
|
-
objectId =
|
|
1635
|
-
|
|
1636
|
-
|
|
1611
|
+
objectId = _ref25.objectId;
|
|
1612
|
+
_context20.t0 = this;
|
|
1613
|
+
_context20.next = 4;
|
|
1637
1614
|
return this.GenerateStateChannelToken({
|
|
1638
1615
|
objectId: objectId
|
|
1639
1616
|
});
|
|
1640
|
-
case
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
token:
|
|
1617
|
+
case 4:
|
|
1618
|
+
_context20.t1 = _context20.sent;
|
|
1619
|
+
_context20.t2 = {
|
|
1620
|
+
token: _context20.t1
|
|
1644
1621
|
};
|
|
1645
|
-
|
|
1646
|
-
case
|
|
1622
|
+
_context20.t0.SetStaticToken.call(_context20.t0, _context20.t2);
|
|
1623
|
+
case 7:
|
|
1647
1624
|
case "end":
|
|
1648
|
-
return
|
|
1625
|
+
return _context20.stop();
|
|
1649
1626
|
}
|
|
1650
|
-
},
|
|
1627
|
+
}, _callee20, this);
|
|
1651
1628
|
}));
|
|
1652
|
-
function SetPolicyAuthorization(
|
|
1629
|
+
function SetPolicyAuthorization(_x15) {
|
|
1653
1630
|
return _SetPolicyAuthorization.apply(this, arguments);
|
|
1654
1631
|
}
|
|
1655
1632
|
return SetPolicyAuthorization;
|
|
@@ -1660,27 +1637,26 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1660
1637
|
* @param {string} string - The string to sign
|
|
1661
1638
|
* @return {Promise<string>} - The signed string
|
|
1662
1639
|
*/
|
|
1663
|
-
)
|
|
1664
1640
|
}, {
|
|
1665
1641
|
key: "Sign",
|
|
1666
|
-
value:
|
|
1667
|
-
var _Sign = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1642
|
+
value: function () {
|
|
1643
|
+
var _Sign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(string) {
|
|
1668
1644
|
var signature;
|
|
1669
|
-
return _regeneratorRuntime.wrap(function (
|
|
1670
|
-
while (1) switch (
|
|
1645
|
+
return _regeneratorRuntime.wrap(function _callee21$(_context21) {
|
|
1646
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1671
1647
|
case 0:
|
|
1672
|
-
|
|
1648
|
+
_context21.next = 2;
|
|
1673
1649
|
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
1650
|
case 2:
|
|
1651
|
+
signature = _context21.sent;
|
|
1652
|
+
return _context21.abrupt("return", this.utils.FormatSignature(signature));
|
|
1653
|
+
case 4:
|
|
1678
1654
|
case "end":
|
|
1679
|
-
return
|
|
1655
|
+
return _context21.stop();
|
|
1680
1656
|
}
|
|
1681
|
-
},
|
|
1657
|
+
}, _callee21, this);
|
|
1682
1658
|
}));
|
|
1683
|
-
function Sign(
|
|
1659
|
+
function Sign(_x16) {
|
|
1684
1660
|
return _Sign.apply(this, arguments);
|
|
1685
1661
|
}
|
|
1686
1662
|
return Sign;
|
|
@@ -1694,34 +1670,33 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1694
1670
|
*
|
|
1695
1671
|
* @return {Promise<string>} - The encrypted message
|
|
1696
1672
|
*/
|
|
1697
|
-
)
|
|
1698
1673
|
}, {
|
|
1699
1674
|
key: "EncryptECIES",
|
|
1700
|
-
value:
|
|
1701
|
-
var _EncryptECIES = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1675
|
+
value: function () {
|
|
1676
|
+
var _EncryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref26) {
|
|
1702
1677
|
var message, publicKey;
|
|
1703
|
-
return _regeneratorRuntime.wrap(function (
|
|
1704
|
-
while (1) switch (
|
|
1678
|
+
return _regeneratorRuntime.wrap(function _callee22$(_context22) {
|
|
1679
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1705
1680
|
case 0:
|
|
1706
|
-
message =
|
|
1681
|
+
message = _ref26.message, publicKey = _ref26.publicKey;
|
|
1707
1682
|
if (this.signer) {
|
|
1708
|
-
|
|
1683
|
+
_context22.next = 3;
|
|
1709
1684
|
break;
|
|
1710
1685
|
}
|
|
1711
1686
|
throw "Signer not set";
|
|
1712
|
-
case
|
|
1687
|
+
case 3:
|
|
1713
1688
|
ValidatePresence("message", message);
|
|
1714
|
-
|
|
1689
|
+
_context22.next = 6;
|
|
1715
1690
|
return this.Crypto.EncryptConk(message, publicKey || this.signer._signingKey().publicKey);
|
|
1716
|
-
case
|
|
1717
|
-
return
|
|
1718
|
-
case
|
|
1691
|
+
case 6:
|
|
1692
|
+
return _context22.abrupt("return", _context22.sent);
|
|
1693
|
+
case 7:
|
|
1719
1694
|
case "end":
|
|
1720
|
-
return
|
|
1695
|
+
return _context22.stop();
|
|
1721
1696
|
}
|
|
1722
|
-
},
|
|
1697
|
+
}, _callee22, this);
|
|
1723
1698
|
}));
|
|
1724
|
-
function EncryptECIES(
|
|
1699
|
+
function EncryptECIES(_x17) {
|
|
1725
1700
|
return _EncryptECIES.apply(this, arguments);
|
|
1726
1701
|
}
|
|
1727
1702
|
return EncryptECIES;
|
|
@@ -1734,34 +1709,33 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1734
1709
|
*
|
|
1735
1710
|
* @return {Promise<string | Object>} - The decrypted string or object
|
|
1736
1711
|
*/
|
|
1737
|
-
)
|
|
1738
1712
|
}, {
|
|
1739
1713
|
key: "DecryptECIES",
|
|
1740
|
-
value:
|
|
1741
|
-
var _DecryptECIES = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1714
|
+
value: function () {
|
|
1715
|
+
var _DecryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref27) {
|
|
1742
1716
|
var message;
|
|
1743
|
-
return _regeneratorRuntime.wrap(function (
|
|
1744
|
-
while (1) switch (
|
|
1717
|
+
return _regeneratorRuntime.wrap(function _callee23$(_context23) {
|
|
1718
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1745
1719
|
case 0:
|
|
1746
|
-
message =
|
|
1720
|
+
message = _ref27.message;
|
|
1747
1721
|
if (this.signer) {
|
|
1748
|
-
|
|
1722
|
+
_context23.next = 3;
|
|
1749
1723
|
break;
|
|
1750
1724
|
}
|
|
1751
1725
|
throw "Signer not set";
|
|
1752
|
-
case
|
|
1726
|
+
case 3:
|
|
1753
1727
|
ValidatePresence("message", message);
|
|
1754
|
-
|
|
1728
|
+
_context23.next = 6;
|
|
1755
1729
|
return this.Crypto.DecryptCap(message, this.signer._signingKey().privateKey);
|
|
1756
|
-
case
|
|
1757
|
-
return
|
|
1758
|
-
case
|
|
1730
|
+
case 6:
|
|
1731
|
+
return _context23.abrupt("return", _context23.sent);
|
|
1732
|
+
case 7:
|
|
1759
1733
|
case "end":
|
|
1760
|
-
return
|
|
1734
|
+
return _context23.stop();
|
|
1761
1735
|
}
|
|
1762
|
-
},
|
|
1736
|
+
}, _callee23, this);
|
|
1763
1737
|
}));
|
|
1764
|
-
function DecryptECIES(
|
|
1738
|
+
function DecryptECIES(_x18) {
|
|
1765
1739
|
return _DecryptECIES.apply(this, arguments);
|
|
1766
1740
|
}
|
|
1767
1741
|
return DecryptECIES;
|
|
@@ -1777,41 +1751,40 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1777
1751
|
*
|
|
1778
1752
|
* @return {Promise<*>} - Response in the specified format
|
|
1779
1753
|
*/
|
|
1780
|
-
)
|
|
1781
1754
|
}, {
|
|
1782
1755
|
key: "Request",
|
|
1783
|
-
value:
|
|
1784
|
-
var _Request = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1785
|
-
var url,
|
|
1786
|
-
return _regeneratorRuntime.wrap(function (
|
|
1787
|
-
while (1) switch (
|
|
1756
|
+
value: function () {
|
|
1757
|
+
var _Request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(_ref28) {
|
|
1758
|
+
var url, _ref28$format, format, _ref28$method, method, _ref28$headers, headers, body;
|
|
1759
|
+
return _regeneratorRuntime.wrap(function _callee24$(_context24) {
|
|
1760
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1788
1761
|
case 0:
|
|
1789
|
-
url =
|
|
1790
|
-
return
|
|
1762
|
+
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;
|
|
1763
|
+
return _context24.abrupt("return", this.utils.ResponseToFormat(format, HttpClient.Fetch(url, {
|
|
1791
1764
|
method: method,
|
|
1792
1765
|
headers: headers,
|
|
1793
1766
|
body: body
|
|
1794
1767
|
})));
|
|
1795
|
-
case
|
|
1768
|
+
case 2:
|
|
1796
1769
|
case "end":
|
|
1797
|
-
return
|
|
1770
|
+
return _context24.stop();
|
|
1798
1771
|
}
|
|
1799
|
-
},
|
|
1772
|
+
}, _callee24, this);
|
|
1800
1773
|
}));
|
|
1801
|
-
function Request(
|
|
1774
|
+
function Request(_x19) {
|
|
1802
1775
|
return _Request.apply(this, arguments);
|
|
1803
1776
|
}
|
|
1804
1777
|
return Request;
|
|
1805
|
-
}()
|
|
1778
|
+
}()
|
|
1806
1779
|
}, {
|
|
1807
1780
|
key: "MakeAuthServiceRequest",
|
|
1808
1781
|
value: function () {
|
|
1809
|
-
var _MakeAuthServiceRequest = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1810
|
-
var kmsId, objectId, versionHash,
|
|
1811
|
-
return _regeneratorRuntime.wrap(function (
|
|
1812
|
-
while (1) switch (
|
|
1782
|
+
var _MakeAuthServiceRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(_ref29) {
|
|
1783
|
+
var kmsId, objectId, versionHash, _ref29$method, method, path, bodyType, _ref29$body, body, _ref29$queryParams, queryParams, headers, format, response;
|
|
1784
|
+
return _regeneratorRuntime.wrap(function _callee25$(_context25) {
|
|
1785
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1813
1786
|
case 0:
|
|
1814
|
-
kmsId =
|
|
1787
|
+
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
1788
|
response = this.authClient.MakeAuthServiceRequest({
|
|
1816
1789
|
kmsId: kmsId,
|
|
1817
1790
|
objectId: objectId,
|
|
@@ -1823,14 +1796,14 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1823
1796
|
queryParams: queryParams,
|
|
1824
1797
|
headers: headers
|
|
1825
1798
|
});
|
|
1826
|
-
return
|
|
1827
|
-
case
|
|
1799
|
+
return _context25.abrupt("return", !format ? response : this.utils.ResponseToFormat(format, response));
|
|
1800
|
+
case 3:
|
|
1828
1801
|
case "end":
|
|
1829
|
-
return
|
|
1802
|
+
return _context25.stop();
|
|
1830
1803
|
}
|
|
1831
|
-
},
|
|
1804
|
+
}, _callee25, this);
|
|
1832
1805
|
}));
|
|
1833
|
-
function MakeAuthServiceRequest(
|
|
1806
|
+
function MakeAuthServiceRequest(_x20) {
|
|
1834
1807
|
return _MakeAuthServiceRequest.apply(this, arguments);
|
|
1835
1808
|
}
|
|
1836
1809
|
return MakeAuthServiceRequest;
|
|
@@ -1851,18 +1824,18 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1851
1824
|
}, {
|
|
1852
1825
|
key: "CallFromFrameMessage",
|
|
1853
1826
|
value: function () {
|
|
1854
|
-
var _CallFromFrameMessage = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1827
|
+
var _CallFromFrameMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(message, Respond) {
|
|
1855
1828
|
var _this4 = this;
|
|
1856
|
-
var callback, method, methodResults, responseError
|
|
1857
|
-
return _regeneratorRuntime.wrap(function (
|
|
1858
|
-
while (1) switch (
|
|
1829
|
+
var callback, method, methodResults, responseError;
|
|
1830
|
+
return _regeneratorRuntime.wrap(function _callee26$(_context26) {
|
|
1831
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1859
1832
|
case 0:
|
|
1860
1833
|
if (!(message.type !== "ElvFrameRequest")) {
|
|
1861
|
-
|
|
1834
|
+
_context26.next = 2;
|
|
1862
1835
|
break;
|
|
1863
1836
|
}
|
|
1864
|
-
return
|
|
1865
|
-
case
|
|
1837
|
+
return _context26.abrupt("return");
|
|
1838
|
+
case 2:
|
|
1866
1839
|
if (message.callbackId) {
|
|
1867
1840
|
callback = function callback(result) {
|
|
1868
1841
|
Respond(_this4.utils.MakeClonable({
|
|
@@ -1873,103 +1846,103 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1873
1846
|
};
|
|
1874
1847
|
message.args.callback = callback;
|
|
1875
1848
|
}
|
|
1876
|
-
|
|
1849
|
+
_context26.prev = 3;
|
|
1877
1850
|
method = message.calledMethod;
|
|
1878
1851
|
if (!(message.module === "walletClient")) {
|
|
1879
|
-
|
|
1852
|
+
_context26.next = 15;
|
|
1880
1853
|
break;
|
|
1881
1854
|
}
|
|
1882
1855
|
if (this.walletClient) {
|
|
1883
|
-
|
|
1856
|
+
_context26.next = 8;
|
|
1884
1857
|
break;
|
|
1885
1858
|
}
|
|
1886
1859
|
throw Error("Wallet client not set");
|
|
1887
|
-
case
|
|
1860
|
+
case 8:
|
|
1888
1861
|
if (!this.walletClient.ForbiddenMethods().includes(method)) {
|
|
1889
|
-
|
|
1862
|
+
_context26.next = 10;
|
|
1890
1863
|
break;
|
|
1891
1864
|
}
|
|
1892
1865
|
throw Error("Invalid user profile method: " + method);
|
|
1893
|
-
case
|
|
1894
|
-
|
|
1866
|
+
case 10:
|
|
1867
|
+
_context26.next = 12;
|
|
1895
1868
|
return this.walletClient[method](message.args);
|
|
1896
|
-
case
|
|
1897
|
-
methodResults =
|
|
1898
|
-
|
|
1869
|
+
case 12:
|
|
1870
|
+
methodResults = _context26.sent;
|
|
1871
|
+
_context26.next = 28;
|
|
1899
1872
|
break;
|
|
1900
|
-
case
|
|
1873
|
+
case 15:
|
|
1901
1874
|
if (!(message.module === "userProfileClient")) {
|
|
1902
|
-
|
|
1875
|
+
_context26.next = 23;
|
|
1903
1876
|
break;
|
|
1904
1877
|
}
|
|
1905
1878
|
if (this.userProfileClient.FrameAllowedMethods().includes(method)) {
|
|
1906
|
-
|
|
1879
|
+
_context26.next = 18;
|
|
1907
1880
|
break;
|
|
1908
1881
|
}
|
|
1909
1882
|
throw Error("Invalid user profile method: " + method);
|
|
1910
|
-
case
|
|
1911
|
-
|
|
1883
|
+
case 18:
|
|
1884
|
+
_context26.next = 20;
|
|
1912
1885
|
return this.userProfileClient[method](message.args);
|
|
1913
|
-
case
|
|
1914
|
-
methodResults =
|
|
1915
|
-
|
|
1886
|
+
case 20:
|
|
1887
|
+
methodResults = _context26.sent;
|
|
1888
|
+
_context26.next = 28;
|
|
1916
1889
|
break;
|
|
1917
|
-
case
|
|
1890
|
+
case 23:
|
|
1918
1891
|
if (this.FrameAllowedMethods().includes(method)) {
|
|
1919
|
-
|
|
1892
|
+
_context26.next = 25;
|
|
1920
1893
|
break;
|
|
1921
1894
|
}
|
|
1922
1895
|
throw Error("Invalid method: " + method);
|
|
1923
|
-
case
|
|
1924
|
-
|
|
1896
|
+
case 25:
|
|
1897
|
+
_context26.next = 27;
|
|
1925
1898
|
return this[method](message.args);
|
|
1926
|
-
case
|
|
1927
|
-
methodResults =
|
|
1928
|
-
case
|
|
1899
|
+
case 27:
|
|
1900
|
+
methodResults = _context26.sent;
|
|
1901
|
+
case 28:
|
|
1929
1902
|
Respond(this.utils.MakeClonable({
|
|
1930
1903
|
type: "ElvFrameResponse",
|
|
1931
1904
|
requestId: message.requestId,
|
|
1932
1905
|
response: methodResults
|
|
1933
1906
|
}));
|
|
1934
|
-
|
|
1907
|
+
_context26.next = 38;
|
|
1935
1908
|
break;
|
|
1936
|
-
case
|
|
1937
|
-
|
|
1938
|
-
|
|
1909
|
+
case 31:
|
|
1910
|
+
_context26.prev = 31;
|
|
1911
|
+
_context26.t0 = _context26["catch"](3);
|
|
1939
1912
|
// 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(
|
|
1913
|
+
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
1914
|
|
|
1942
1915
|
// eslint-disable-next-line no-console
|
|
1943
1916
|
console.error(message);
|
|
1944
1917
|
// eslint-disable-next-line no-console
|
|
1945
|
-
console.error(
|
|
1946
|
-
responseError =
|
|
1918
|
+
console.error(_context26.t0);
|
|
1919
|
+
responseError = _context26.t0 instanceof Error ? _context26.t0.message : _context26.t0;
|
|
1947
1920
|
Respond(this.utils.MakeClonable({
|
|
1948
1921
|
type: "ElvFrameResponse",
|
|
1949
1922
|
requestId: message.requestId,
|
|
1950
1923
|
error: responseError
|
|
1951
1924
|
}));
|
|
1952
|
-
case
|
|
1925
|
+
case 38:
|
|
1953
1926
|
case "end":
|
|
1954
|
-
return
|
|
1927
|
+
return _context26.stop();
|
|
1955
1928
|
}
|
|
1956
|
-
},
|
|
1929
|
+
}, _callee26, this, [[3, 31]]);
|
|
1957
1930
|
}));
|
|
1958
|
-
function CallFromFrameMessage(
|
|
1931
|
+
function CallFromFrameMessage(_x21, _x22) {
|
|
1959
1932
|
return _CallFromFrameMessage.apply(this, arguments);
|
|
1960
1933
|
}
|
|
1961
1934
|
return CallFromFrameMessage;
|
|
1962
1935
|
}()
|
|
1963
1936
|
}], [{
|
|
1964
1937
|
key: "Configuration",
|
|
1965
|
-
value:
|
|
1966
|
-
var _Configuration = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1967
|
-
var configUrl,
|
|
1968
|
-
return _regeneratorRuntime.wrap(function (
|
|
1969
|
-
while (1) switch (
|
|
1938
|
+
value: function () {
|
|
1939
|
+
var _Configuration = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27(_ref30) {
|
|
1940
|
+
var configUrl, _ref30$kmsUrls, kmsUrls, region, clientIP, uri, fabricInfo, filterHTTPS, fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs, fabricVersion;
|
|
1941
|
+
return _regeneratorRuntime.wrap(function _callee27$(_context27) {
|
|
1942
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1970
1943
|
case 0:
|
|
1971
|
-
configUrl =
|
|
1972
|
-
|
|
1944
|
+
configUrl = _ref30.configUrl, _ref30$kmsUrls = _ref30.kmsUrls, kmsUrls = _ref30$kmsUrls === void 0 ? [] : _ref30$kmsUrls, region = _ref30.region, clientIP = _ref30.clientIP;
|
|
1945
|
+
_context27.prev = 1;
|
|
1973
1946
|
uri = new URI(configUrl);
|
|
1974
1947
|
uri.pathname("/config");
|
|
1975
1948
|
if (region) {
|
|
@@ -1978,10 +1951,10 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1978
1951
|
if (clientIP) {
|
|
1979
1952
|
uri.addSearch("client_ip", clientIP);
|
|
1980
1953
|
}
|
|
1981
|
-
|
|
1954
|
+
_context27.next = 8;
|
|
1982
1955
|
return Utils.ResponseToJson(HttpClient.Fetch(uri.toString()));
|
|
1983
|
-
case
|
|
1984
|
-
fabricInfo =
|
|
1956
|
+
case 8:
|
|
1957
|
+
fabricInfo = _context27.sent;
|
|
1985
1958
|
// If any HTTPS urls present, throw away HTTP urls so only HTTPS will be used
|
|
1986
1959
|
filterHTTPS = function filterHTTPS(uri) {
|
|
1987
1960
|
return uri.toLowerCase().startsWith("https");
|
|
@@ -2004,7 +1977,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2004
1977
|
}
|
|
2005
1978
|
searchURIs = fabricInfo.network.services.search || [];
|
|
2006
1979
|
fabricVersion = Math.max.apply(Math, _toConsumableArray(fabricInfo.network.api_versions || [2]));
|
|
2007
|
-
return
|
|
1980
|
+
return _context27.abrupt("return", {
|
|
2008
1981
|
nodeId: fabricInfo.node_id,
|
|
2009
1982
|
contentSpaceId: fabricInfo.qspace.id,
|
|
2010
1983
|
networkId: (fabricInfo.qspace.ethereum || {}).network_id,
|
|
@@ -2017,21 +1990,21 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2017
1990
|
searchURIs: searchURIs,
|
|
2018
1991
|
fabricVersion: fabricVersion
|
|
2019
1992
|
});
|
|
2020
|
-
case
|
|
2021
|
-
|
|
2022
|
-
|
|
1993
|
+
case 23:
|
|
1994
|
+
_context27.prev = 23;
|
|
1995
|
+
_context27.t0 = _context27["catch"](1);
|
|
2023
1996
|
// eslint-disable-next-line no-console
|
|
2024
1997
|
console.error("Error retrieving fabric configuration:");
|
|
2025
1998
|
// eslint-disable-next-line no-console
|
|
2026
|
-
console.error(
|
|
2027
|
-
throw
|
|
2028
|
-
case
|
|
1999
|
+
console.error(_context27.t0);
|
|
2000
|
+
throw _context27.t0;
|
|
2001
|
+
case 28:
|
|
2029
2002
|
case "end":
|
|
2030
|
-
return
|
|
2003
|
+
return _context27.stop();
|
|
2031
2004
|
}
|
|
2032
|
-
},
|
|
2005
|
+
}, _callee27, null, [[1, 23]]);
|
|
2033
2006
|
}));
|
|
2034
|
-
function Configuration(
|
|
2007
|
+
function Configuration(_x23) {
|
|
2035
2008
|
return _Configuration.apply(this, arguments);
|
|
2036
2009
|
}
|
|
2037
2010
|
return Configuration;
|
|
@@ -2043,7 +2016,6 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2043
2016
|
*
|
|
2044
2017
|
* @return {Object} - An object using network names as keys and configuration URLs as values.
|
|
2045
2018
|
*/
|
|
2046
|
-
)
|
|
2047
2019
|
}, {
|
|
2048
2020
|
key: "Networks",
|
|
2049
2021
|
value: function Networks() {
|
|
@@ -2068,21 +2040,21 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2068
2040
|
*/
|
|
2069
2041
|
}, {
|
|
2070
2042
|
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 (
|
|
2043
|
+
value: function () {
|
|
2044
|
+
var _FromNetworkName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28(_ref31) {
|
|
2045
|
+
var networkName, region, clientIP, trustAuthorityId, staticToken, _ref31$ethereumContra, ethereumContractTimeout, _ref31$noCache, noCache, _ref31$noAuth, noAuth, assumeV3, configUrl;
|
|
2046
|
+
return _regeneratorRuntime.wrap(function _callee28$(_context28) {
|
|
2047
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2076
2048
|
case 0:
|
|
2077
|
-
networkName =
|
|
2049
|
+
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
2050
|
configUrl = networks[networkName];
|
|
2079
2051
|
if (configUrl) {
|
|
2080
|
-
|
|
2052
|
+
_context28.next = 4;
|
|
2081
2053
|
break;
|
|
2082
2054
|
}
|
|
2083
2055
|
throw Error("Invalid network name: " + networkName);
|
|
2084
|
-
case
|
|
2085
|
-
|
|
2056
|
+
case 4:
|
|
2057
|
+
_context28.next = 6;
|
|
2086
2058
|
return this.FromConfigurationUrl({
|
|
2087
2059
|
configUrl: configUrl,
|
|
2088
2060
|
region: region,
|
|
@@ -2094,15 +2066,15 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2094
2066
|
noAuth: noAuth,
|
|
2095
2067
|
assumeV3: assumeV3
|
|
2096
2068
|
});
|
|
2097
|
-
case
|
|
2098
|
-
return
|
|
2099
|
-
case
|
|
2069
|
+
case 6:
|
|
2070
|
+
return _context28.abrupt("return", _context28.sent);
|
|
2071
|
+
case 7:
|
|
2100
2072
|
case "end":
|
|
2101
|
-
return
|
|
2073
|
+
return _context28.stop();
|
|
2102
2074
|
}
|
|
2103
|
-
},
|
|
2075
|
+
}, _callee28, this);
|
|
2104
2076
|
}));
|
|
2105
|
-
function FromNetworkName(
|
|
2077
|
+
function FromNetworkName(_x24) {
|
|
2106
2078
|
return _FromNetworkName.apply(this, arguments);
|
|
2107
2079
|
}
|
|
2108
2080
|
return FromNetworkName;
|
|
@@ -2123,24 +2095,23 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2123
2095
|
*
|
|
2124
2096
|
* @return {Promise<ElvClient>} - New ElvClient connected to the specified content fabric and blockchain
|
|
2125
2097
|
*/
|
|
2126
|
-
)
|
|
2127
2098
|
}, {
|
|
2128
2099
|
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 (
|
|
2100
|
+
value: function () {
|
|
2101
|
+
var _FromConfigurationUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29(_ref32) {
|
|
2102
|
+
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;
|
|
2103
|
+
return _regeneratorRuntime.wrap(function _callee29$(_context29) {
|
|
2104
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2134
2105
|
case 0:
|
|
2135
|
-
configUrl =
|
|
2136
|
-
|
|
2106
|
+
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;
|
|
2107
|
+
_context29.next = 3;
|
|
2137
2108
|
return ElvClient.Configuration({
|
|
2138
2109
|
configUrl: configUrl,
|
|
2139
2110
|
clientIP: clientIP,
|
|
2140
2111
|
region: region
|
|
2141
2112
|
});
|
|
2142
|
-
case
|
|
2143
|
-
_yield$ElvClient$Conf3 =
|
|
2113
|
+
case 3:
|
|
2114
|
+
_yield$ElvClient$Conf3 = _context29.sent;
|
|
2144
2115
|
contentSpaceId = _yield$ElvClient$Conf3.contentSpaceId;
|
|
2145
2116
|
networkId = _yield$ElvClient$Conf3.networkId;
|
|
2146
2117
|
networkName = _yield$ElvClient$Conf3.networkName;
|
|
@@ -2170,19 +2141,20 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2170
2141
|
client.configUrl = configUrl;
|
|
2171
2142
|
client.region = region;
|
|
2172
2143
|
client.clientIP = clientIP;
|
|
2173
|
-
return
|
|
2174
|
-
case
|
|
2144
|
+
return _context29.abrupt("return", client);
|
|
2145
|
+
case 18:
|
|
2175
2146
|
case "end":
|
|
2176
|
-
return
|
|
2147
|
+
return _context29.stop();
|
|
2177
2148
|
}
|
|
2178
|
-
},
|
|
2149
|
+
}, _callee29);
|
|
2179
2150
|
}));
|
|
2180
|
-
function FromConfigurationUrl(
|
|
2151
|
+
function FromConfigurationUrl(_x25) {
|
|
2181
2152
|
return _FromConfigurationUrl.apply(this, arguments);
|
|
2182
2153
|
}
|
|
2183
2154
|
return FromConfigurationUrl;
|
|
2184
|
-
}()
|
|
2155
|
+
}()
|
|
2185
2156
|
}]);
|
|
2157
|
+
return ElvClient;
|
|
2186
2158
|
}();
|
|
2187
2159
|
Object.assign(ElvClient.prototype, require("./client/AccessGroups"));
|
|
2188
2160
|
Object.assign(ElvClient.prototype, require("./client/ContentAccess"));
|