@eluvio/elv-client-js 3.2.41 → 3.2.43
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 +4 -4
- package/dist/ElvClient-node-min.js +6 -6
- package/dist/ElvWalletClient-min.js +4 -4
- package/dist/ElvWalletClient-node-min.js +6 -6
- package/dist/src/AuthorizationClient.js +507 -599
- package/dist/src/client/ContentManagement.js +152 -52
- package/dist/src/walletClient/Notifications.js +5 -0
- package/package.json +1 -1
- package/src/AuthorizationClient.js +0 -43
- package/src/client/ContentAccess.js +0 -1
- package/src/client/ContentManagement.js +71 -8
- package/src/walletClient/index.js +1 -1
|
@@ -24,11 +24,6 @@ var UrlJoin = require("url-join");
|
|
|
24
24
|
|
|
25
25
|
var _require = require("./LogMessage"),
|
|
26
26
|
LogMessage = _require.LogMessage;
|
|
27
|
-
|
|
28
|
-
var _require2 = require("./Validation"),
|
|
29
|
-
ValidateObject = _require2.ValidateObject;
|
|
30
|
-
|
|
31
|
-
var Pako = require("pako");
|
|
32
27
|
/*
|
|
33
28
|
// -- Contract javascript files built using build/BuildContracts.js
|
|
34
29
|
const SpaceContract = require("./contracts/BaseContentSpace");
|
|
@@ -418,138 +413,51 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
418
413
|
|
|
419
414
|
return GenerateAuthorizationToken;
|
|
420
415
|
}()
|
|
421
|
-
}, {
|
|
422
|
-
key: "GenerateSignedLinkToken",
|
|
423
|
-
value: function () {
|
|
424
|
-
var _GenerateSignedLinkToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref5) {
|
|
425
|
-
var containerId, versionHash, link, canEdit, _Utils$DecodeVersionH, objectId, signerAddress, token, compressedToken, signature;
|
|
426
|
-
|
|
427
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
428
|
-
while (1) {
|
|
429
|
-
switch (_context4.prev = _context4.next) {
|
|
430
|
-
case 0:
|
|
431
|
-
containerId = _ref5.containerId, versionHash = _ref5.versionHash, link = _ref5.link;
|
|
432
|
-
ValidateObject(containerId);
|
|
433
|
-
_context4.next = 4;
|
|
434
|
-
return this.client.CallContractMethod({
|
|
435
|
-
contractAddress: Utils.HashToAddress(containerId),
|
|
436
|
-
methodName: "canEdit"
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
case 4:
|
|
440
|
-
canEdit = _context4.sent;
|
|
441
|
-
_Utils$DecodeVersionH = Utils.DecodeVersionHash(versionHash), objectId = _Utils$DecodeVersionH.objectId;
|
|
442
|
-
|
|
443
|
-
if (canEdit) {
|
|
444
|
-
_context4.next = 8;
|
|
445
|
-
break;
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
throw Error("Current user does not have permission to edit content object ".concat(objectId));
|
|
449
|
-
|
|
450
|
-
case 8:
|
|
451
|
-
signerAddress = this.client.CurrentAccountAddress();
|
|
452
|
-
_context4.t0 = Utils.B64(signerAddress.replace("0x", ""), "hex");
|
|
453
|
-
_context4.next = 12;
|
|
454
|
-
return this.client.ContentSpaceId();
|
|
455
|
-
|
|
456
|
-
case 12:
|
|
457
|
-
_context4.t1 = _context4.sent;
|
|
458
|
-
_context4.next = 15;
|
|
459
|
-
return this.client.ContentObjectLibraryId({
|
|
460
|
-
objectId: objectId
|
|
461
|
-
});
|
|
462
|
-
|
|
463
|
-
case 15:
|
|
464
|
-
_context4.t2 = _context4.sent;
|
|
465
|
-
_context4.t3 = objectId;
|
|
466
|
-
_context4.t4 = Utils.FormatAddress(signerAddress);
|
|
467
|
-
_context4.t5 = Date.now();
|
|
468
|
-
_context4.t6 = Date.now() + 3600000;
|
|
469
|
-
_context4.t7 = {
|
|
470
|
-
elv: {
|
|
471
|
-
lnk: link,
|
|
472
|
-
src: containerId
|
|
473
|
-
}
|
|
474
|
-
};
|
|
475
|
-
token = {
|
|
476
|
-
adr: _context4.t0,
|
|
477
|
-
spc: _context4.t1,
|
|
478
|
-
lib: _context4.t2,
|
|
479
|
-
qid: _context4.t3,
|
|
480
|
-
sub: _context4.t4,
|
|
481
|
-
gra: "read",
|
|
482
|
-
iat: _context4.t5,
|
|
483
|
-
exp: _context4.t6,
|
|
484
|
-
ctx: _context4.t7
|
|
485
|
-
};
|
|
486
|
-
compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
|
|
487
|
-
_context4.next = 25;
|
|
488
|
-
return this.Sign(Ethers.utils.keccak256(compressedToken));
|
|
489
|
-
|
|
490
|
-
case 25:
|
|
491
|
-
signature = _context4.sent;
|
|
492
|
-
return _context4.abrupt("return", "aslsjc".concat(Utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
|
|
493
|
-
|
|
494
|
-
case 27:
|
|
495
|
-
case "end":
|
|
496
|
-
return _context4.stop();
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
}, _callee4, this);
|
|
500
|
-
}));
|
|
501
|
-
|
|
502
|
-
function GenerateSignedLinkToken(_x4) {
|
|
503
|
-
return _GenerateSignedLinkToken.apply(this, arguments);
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
return GenerateSignedLinkToken;
|
|
507
|
-
}()
|
|
508
416
|
}, {
|
|
509
417
|
key: "MakeAccessRequest",
|
|
510
418
|
value: function () {
|
|
511
|
-
var _MakeAccessRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
419
|
+
var _MakeAccessRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref5) {
|
|
512
420
|
var _this = this;
|
|
513
421
|
|
|
514
|
-
var libraryId, objectId, versionHash,
|
|
422
|
+
var libraryId, objectId, versionHash, _ref5$args, args, _ref5$publicKey, publicKey, _ref5$update, update, _ref5$skipCache, skipCache, _ref5$noCache, noCache, cacheOnly, walletContractAddress, walletCreated, id, _yield$this$ContractI, isV3, accessType, abi, _yield$this$AccessInf, accessArgs, checkAccessCharge, address, elapsed, _cache, accessRequest, cache;
|
|
515
423
|
|
|
516
|
-
return _regeneratorRuntime.wrap(function
|
|
424
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
517
425
|
while (1) {
|
|
518
|
-
switch (
|
|
426
|
+
switch (_context4.prev = _context4.next) {
|
|
519
427
|
case 0:
|
|
520
|
-
libraryId =
|
|
428
|
+
libraryId = _ref5.libraryId, objectId = _ref5.objectId, versionHash = _ref5.versionHash, _ref5$args = _ref5.args, args = _ref5$args === void 0 ? [] : _ref5$args, _ref5$publicKey = _ref5.publicKey, publicKey = _ref5$publicKey === void 0 ? "" : _ref5$publicKey, _ref5$update = _ref5.update, update = _ref5$update === void 0 ? false : _ref5$update, _ref5$skipCache = _ref5.skipCache, skipCache = _ref5$skipCache === void 0 ? false : _ref5$skipCache, _ref5$noCache = _ref5.noCache, noCache = _ref5$noCache === void 0 ? false : _ref5$noCache, cacheOnly = _ref5.cacheOnly;
|
|
521
429
|
|
|
522
430
|
if (this.client.signer) {
|
|
523
|
-
|
|
431
|
+
_context4.next = 3;
|
|
524
432
|
break;
|
|
525
433
|
}
|
|
526
434
|
|
|
527
|
-
return
|
|
435
|
+
return _context4.abrupt("return", {
|
|
528
436
|
transactionHash: ""
|
|
529
437
|
});
|
|
530
438
|
|
|
531
439
|
case 3:
|
|
532
|
-
|
|
440
|
+
_context4.next = 5;
|
|
533
441
|
return this.client.userProfileClient.UserWalletAddress({
|
|
534
442
|
address: this.client.signer.address
|
|
535
443
|
});
|
|
536
444
|
|
|
537
445
|
case 5:
|
|
538
|
-
walletContractAddress =
|
|
446
|
+
walletContractAddress = _context4.sent;
|
|
539
447
|
|
|
540
448
|
if (walletContractAddress) {
|
|
541
|
-
|
|
449
|
+
_context4.next = 12;
|
|
542
450
|
break;
|
|
543
451
|
}
|
|
544
452
|
|
|
545
|
-
|
|
453
|
+
_context4.next = 9;
|
|
546
454
|
return this.client.userProfileClient.WalletAddress();
|
|
547
455
|
|
|
548
456
|
case 9:
|
|
549
|
-
walletCreated =
|
|
457
|
+
walletCreated = _context4.sent;
|
|
550
458
|
|
|
551
459
|
if (walletCreated) {
|
|
552
|
-
|
|
460
|
+
_context4.next = 12;
|
|
553
461
|
break;
|
|
554
462
|
}
|
|
555
463
|
|
|
@@ -561,26 +469,26 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
561
469
|
}
|
|
562
470
|
|
|
563
471
|
id = objectId || libraryId || this.contentSpaceId;
|
|
564
|
-
|
|
472
|
+
_context4.next = 16;
|
|
565
473
|
return this.ContractInfo({
|
|
566
474
|
id: id
|
|
567
475
|
});
|
|
568
476
|
|
|
569
477
|
case 16:
|
|
570
|
-
_yield$this$ContractI =
|
|
478
|
+
_yield$this$ContractI = _context4.sent;
|
|
571
479
|
isV3 = _yield$this$ContractI.isV3;
|
|
572
480
|
accessType = _yield$this$ContractI.accessType;
|
|
573
481
|
abi = _yield$this$ContractI.abi;
|
|
574
482
|
|
|
575
483
|
if (!(typeof accessType === "undefined")) {
|
|
576
|
-
|
|
484
|
+
_context4.next = 22;
|
|
577
485
|
break;
|
|
578
486
|
}
|
|
579
487
|
|
|
580
488
|
throw Error("Unable to determine contract info for ".concat(id, " (").concat(this.client.utils.HashToAddress(id), ") - Wrong network?"));
|
|
581
489
|
|
|
582
490
|
case 22:
|
|
583
|
-
|
|
491
|
+
_context4.next = 24;
|
|
584
492
|
return this.AccessInfo({
|
|
585
493
|
accessType: accessType,
|
|
586
494
|
publicKey: publicKey,
|
|
@@ -590,7 +498,7 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
590
498
|
});
|
|
591
499
|
|
|
592
500
|
case 24:
|
|
593
|
-
_yield$this$AccessInf =
|
|
501
|
+
_yield$this$AccessInf = _context4.sent;
|
|
594
502
|
accessArgs = _yield$this$AccessInf.accessArgs;
|
|
595
503
|
checkAccessCharge = _yield$this$AccessInf.checkAccessCharge;
|
|
596
504
|
address = Utils.HashToAddress(id);
|
|
@@ -598,11 +506,11 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
598
506
|
|
|
599
507
|
case 29:
|
|
600
508
|
if (!this.transactionLocks[id]) {
|
|
601
|
-
|
|
509
|
+
_context4.next = 36;
|
|
602
510
|
break;
|
|
603
511
|
}
|
|
604
512
|
|
|
605
|
-
|
|
513
|
+
_context4.next = 32;
|
|
606
514
|
return new Promise(function (resolve) {
|
|
607
515
|
return setTimeout(resolve, 100);
|
|
608
516
|
});
|
|
@@ -615,31 +523,31 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
615
523
|
delete this.transactionLocks[id];
|
|
616
524
|
}
|
|
617
525
|
|
|
618
|
-
|
|
526
|
+
_context4.next = 29;
|
|
619
527
|
break;
|
|
620
528
|
|
|
621
529
|
case 36:
|
|
622
|
-
|
|
530
|
+
_context4.prev = 36;
|
|
623
531
|
this.transactionLocks[id] = true; // Check cache for existing transaction
|
|
624
532
|
|
|
625
533
|
if (!(!noCache && !skipCache)) {
|
|
626
|
-
|
|
534
|
+
_context4.next = 46;
|
|
627
535
|
break;
|
|
628
536
|
}
|
|
629
537
|
|
|
630
538
|
_cache = update ? this.modifyTransactions : this.accessTransactions;
|
|
631
539
|
|
|
632
540
|
if (!_cache[address]) {
|
|
633
|
-
|
|
541
|
+
_context4.next = 46;
|
|
634
542
|
break;
|
|
635
543
|
}
|
|
636
544
|
|
|
637
545
|
if (!(_cache[address].issuedAt > Date.now() - 12 * 60 * 60 * 1000)) {
|
|
638
|
-
|
|
546
|
+
_context4.next = 45;
|
|
639
547
|
break;
|
|
640
548
|
}
|
|
641
549
|
|
|
642
|
-
return
|
|
550
|
+
return _context4.abrupt("return", _cache[address]);
|
|
643
551
|
|
|
644
552
|
case 45:
|
|
645
553
|
// Token expired
|
|
@@ -647,33 +555,33 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
647
555
|
|
|
648
556
|
case 46:
|
|
649
557
|
if (!cacheOnly) {
|
|
650
|
-
|
|
558
|
+
_context4.next = 48;
|
|
651
559
|
break;
|
|
652
560
|
}
|
|
653
561
|
|
|
654
|
-
return
|
|
562
|
+
return _context4.abrupt("return");
|
|
655
563
|
|
|
656
564
|
case 48:
|
|
657
565
|
if (!update) {
|
|
658
|
-
|
|
566
|
+
_context4.next = 55;
|
|
659
567
|
break;
|
|
660
568
|
}
|
|
661
569
|
|
|
662
570
|
this.Log("Making update request on ".concat(accessType, " ").concat(id));
|
|
663
|
-
|
|
571
|
+
_context4.next = 52;
|
|
664
572
|
return this.UpdateRequest({
|
|
665
573
|
id: id,
|
|
666
574
|
abi: abi
|
|
667
575
|
});
|
|
668
576
|
|
|
669
577
|
case 52:
|
|
670
|
-
accessRequest =
|
|
671
|
-
|
|
578
|
+
accessRequest = _context4.sent;
|
|
579
|
+
_context4.next = 59;
|
|
672
580
|
break;
|
|
673
581
|
|
|
674
582
|
case 55:
|
|
675
583
|
this.Log("Making access request on ".concat(accessType, " ").concat(id));
|
|
676
|
-
|
|
584
|
+
_context4.next = 58;
|
|
677
585
|
return this.AccessRequest({
|
|
678
586
|
id: id,
|
|
679
587
|
args: accessArgs,
|
|
@@ -681,11 +589,11 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
681
589
|
});
|
|
682
590
|
|
|
683
591
|
case 58:
|
|
684
|
-
accessRequest =
|
|
592
|
+
accessRequest = _context4.sent;
|
|
685
593
|
|
|
686
594
|
case 59:
|
|
687
595
|
cache = update ? this.modifyTransactions : this.accessTransactions;
|
|
688
|
-
|
|
596
|
+
_context4.prev = 60;
|
|
689
597
|
|
|
690
598
|
if (!noCache) {
|
|
691
599
|
cache[address] = {
|
|
@@ -701,32 +609,32 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
701
609
|
});
|
|
702
610
|
}
|
|
703
611
|
|
|
704
|
-
return
|
|
612
|
+
return _context4.abrupt("return", accessRequest);
|
|
705
613
|
|
|
706
614
|
case 65:
|
|
707
|
-
|
|
708
|
-
|
|
615
|
+
_context4.prev = 65;
|
|
616
|
+
_context4.t0 = _context4["catch"](60);
|
|
709
617
|
|
|
710
618
|
if (!noCache) {
|
|
711
619
|
delete cache[address];
|
|
712
620
|
}
|
|
713
621
|
|
|
714
|
-
throw
|
|
622
|
+
throw _context4.t0;
|
|
715
623
|
|
|
716
624
|
case 69:
|
|
717
|
-
|
|
625
|
+
_context4.prev = 69;
|
|
718
626
|
delete this.transactionLocks[id];
|
|
719
|
-
return
|
|
627
|
+
return _context4.finish(69);
|
|
720
628
|
|
|
721
629
|
case 72:
|
|
722
630
|
case "end":
|
|
723
|
-
return
|
|
631
|
+
return _context4.stop();
|
|
724
632
|
}
|
|
725
633
|
}
|
|
726
|
-
},
|
|
634
|
+
}, _callee4, this, [[36,, 69, 72], [60, 65]]);
|
|
727
635
|
}));
|
|
728
636
|
|
|
729
|
-
function MakeAccessRequest(
|
|
637
|
+
function MakeAccessRequest(_x4) {
|
|
730
638
|
return _MakeAccessRequest.apply(this, arguments);
|
|
731
639
|
}
|
|
732
640
|
|
|
@@ -735,21 +643,21 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
735
643
|
}, {
|
|
736
644
|
key: "AccessRequest",
|
|
737
645
|
value: function () {
|
|
738
|
-
var _AccessRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
739
|
-
var id,
|
|
646
|
+
var _AccessRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref6) {
|
|
647
|
+
var id, _ref6$args, args, _ref6$checkAccessChar, checkAccessCharge, _yield$this$ContractI2, isV3, accessType, abi, accessCharge, owner, accessChargeArgs, event, methodName, contractAddress;
|
|
740
648
|
|
|
741
|
-
return _regeneratorRuntime.wrap(function
|
|
649
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
742
650
|
while (1) {
|
|
743
|
-
switch (
|
|
651
|
+
switch (_context5.prev = _context5.next) {
|
|
744
652
|
case 0:
|
|
745
|
-
id =
|
|
746
|
-
|
|
653
|
+
id = _ref6.id, _ref6$args = _ref6.args, args = _ref6$args === void 0 ? [] : _ref6$args, _ref6$checkAccessChar = _ref6.checkAccessCharge, checkAccessCharge = _ref6$checkAccessChar === void 0 ? false : _ref6$checkAccessChar;
|
|
654
|
+
_context5.next = 3;
|
|
747
655
|
return this.ContractInfo({
|
|
748
656
|
id: id
|
|
749
657
|
});
|
|
750
658
|
|
|
751
659
|
case 3:
|
|
752
|
-
_yield$this$ContractI2 =
|
|
660
|
+
_yield$this$ContractI2 = _context5.sent;
|
|
753
661
|
isV3 = _yield$this$ContractI2.isV3;
|
|
754
662
|
accessType = _yield$this$ContractI2.accessType;
|
|
755
663
|
abi = _yield$this$ContractI2.abi;
|
|
@@ -757,46 +665,46 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
757
665
|
accessCharge = 0;
|
|
758
666
|
|
|
759
667
|
if (!(checkAccessCharge && accessType === ACCESS_TYPES.OBJECT)) {
|
|
760
|
-
|
|
668
|
+
_context5.next = 26;
|
|
761
669
|
break;
|
|
762
670
|
}
|
|
763
671
|
|
|
764
|
-
|
|
672
|
+
_context5.next = 11;
|
|
765
673
|
return this.Owner({
|
|
766
674
|
id: id,
|
|
767
675
|
abi: abi
|
|
768
676
|
});
|
|
769
677
|
|
|
770
678
|
case 11:
|
|
771
|
-
owner =
|
|
679
|
+
owner = _context5.sent;
|
|
772
680
|
|
|
773
681
|
if (Utils.EqualAddress(this.client.signer.address, owner)) {
|
|
774
|
-
|
|
682
|
+
_context5.next = 26;
|
|
775
683
|
break;
|
|
776
684
|
}
|
|
777
685
|
|
|
778
|
-
|
|
686
|
+
_context5.prev = 13;
|
|
779
687
|
// Extract level, custom values and stakeholders from accessRequest arguments
|
|
780
688
|
accessChargeArgs = isV3 ? [0, [], []] : [args[0], args[3], args[4]]; // Access charge is in wei, but methods take ether - convert to charge to ether
|
|
781
689
|
|
|
782
|
-
|
|
783
|
-
|
|
690
|
+
_context5.t0 = Utils;
|
|
691
|
+
_context5.next = 18;
|
|
784
692
|
return this.GetAccessCharge({
|
|
785
693
|
objectId: id,
|
|
786
694
|
args: accessChargeArgs
|
|
787
695
|
});
|
|
788
696
|
|
|
789
697
|
case 18:
|
|
790
|
-
|
|
791
|
-
accessCharge =
|
|
792
|
-
|
|
698
|
+
_context5.t1 = _context5.sent;
|
|
699
|
+
accessCharge = _context5.t0.WeiToEther.call(_context5.t0, _context5.t1);
|
|
700
|
+
_context5.next = 26;
|
|
793
701
|
break;
|
|
794
702
|
|
|
795
703
|
case 22:
|
|
796
|
-
|
|
797
|
-
|
|
704
|
+
_context5.prev = 22;
|
|
705
|
+
_context5.t2 = _context5["catch"](13);
|
|
798
706
|
this.Log("Failed to get access charge for", id);
|
|
799
|
-
this.Log(
|
|
707
|
+
this.Log(_context5.t2);
|
|
800
708
|
|
|
801
709
|
case 26:
|
|
802
710
|
if (accessCharge > 0) {
|
|
@@ -811,7 +719,7 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
811
719
|
methodName = "accessRequest";
|
|
812
720
|
}
|
|
813
721
|
|
|
814
|
-
|
|
722
|
+
_context5.next = 31;
|
|
815
723
|
return this.ContractHasMethod({
|
|
816
724
|
contractAddress: contractAddress,
|
|
817
725
|
abi: abi,
|
|
@@ -819,19 +727,19 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
819
727
|
});
|
|
820
728
|
|
|
821
729
|
case 31:
|
|
822
|
-
if (
|
|
823
|
-
|
|
730
|
+
if (_context5.sent) {
|
|
731
|
+
_context5.next = 34;
|
|
824
732
|
break;
|
|
825
733
|
}
|
|
826
734
|
|
|
827
735
|
this.Log("".concat(accessType, " ").concat(id, " has no ").concat(methodName, " method. Skipping"));
|
|
828
|
-
return
|
|
736
|
+
return _context5.abrupt("return", {
|
|
829
737
|
transactionHash: "",
|
|
830
738
|
logs: []
|
|
831
739
|
});
|
|
832
740
|
|
|
833
741
|
case 34:
|
|
834
|
-
|
|
742
|
+
_context5.next = 36;
|
|
835
743
|
return this.client.CallContractMethodAndWait({
|
|
836
744
|
contractAddress: contractAddress,
|
|
837
745
|
abi: abi,
|
|
@@ -841,27 +749,27 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
841
749
|
});
|
|
842
750
|
|
|
843
751
|
case 36:
|
|
844
|
-
event =
|
|
752
|
+
event = _context5.sent;
|
|
845
753
|
|
|
846
754
|
if (!(event.logs.length === 0)) {
|
|
847
|
-
|
|
755
|
+
_context5.next = 39;
|
|
848
756
|
break;
|
|
849
757
|
}
|
|
850
758
|
|
|
851
759
|
throw Error("Access denied (".concat(id, ")"));
|
|
852
760
|
|
|
853
761
|
case 39:
|
|
854
|
-
return
|
|
762
|
+
return _context5.abrupt("return", event);
|
|
855
763
|
|
|
856
764
|
case 40:
|
|
857
765
|
case "end":
|
|
858
|
-
return
|
|
766
|
+
return _context5.stop();
|
|
859
767
|
}
|
|
860
768
|
}
|
|
861
|
-
},
|
|
769
|
+
}, _callee5, this, [[13, 22]]);
|
|
862
770
|
}));
|
|
863
771
|
|
|
864
|
-
function AccessRequest(
|
|
772
|
+
function AccessRequest(_x5) {
|
|
865
773
|
return _AccessRequest.apply(this, arguments);
|
|
866
774
|
}
|
|
867
775
|
|
|
@@ -870,14 +778,14 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
870
778
|
}, {
|
|
871
779
|
key: "UpdateRequest",
|
|
872
780
|
value: function () {
|
|
873
|
-
var _UpdateRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
781
|
+
var _UpdateRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref7) {
|
|
874
782
|
var id, abi, event, updateRequestEvent;
|
|
875
|
-
return _regeneratorRuntime.wrap(function
|
|
783
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
876
784
|
while (1) {
|
|
877
|
-
switch (
|
|
785
|
+
switch (_context6.prev = _context6.next) {
|
|
878
786
|
case 0:
|
|
879
|
-
id =
|
|
880
|
-
|
|
787
|
+
id = _ref7.id, abi = _ref7.abi;
|
|
788
|
+
_context6.next = 3;
|
|
881
789
|
return this.client.CallContractMethodAndWait({
|
|
882
790
|
contractAddress: Utils.HashToAddress(id),
|
|
883
791
|
abi: abi,
|
|
@@ -886,7 +794,7 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
886
794
|
});
|
|
887
795
|
|
|
888
796
|
case 3:
|
|
889
|
-
event =
|
|
797
|
+
event = _context6.sent;
|
|
890
798
|
updateRequestEvent = this.client.ExtractEventFromLogs({
|
|
891
799
|
abi: abi,
|
|
892
800
|
event: event,
|
|
@@ -894,24 +802,24 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
894
802
|
});
|
|
895
803
|
|
|
896
804
|
if (!(event.logs.length === 0 || !updateRequestEvent)) {
|
|
897
|
-
|
|
805
|
+
_context6.next = 7;
|
|
898
806
|
break;
|
|
899
807
|
}
|
|
900
808
|
|
|
901
809
|
throw Error("Update request denied for ".concat(id));
|
|
902
810
|
|
|
903
811
|
case 7:
|
|
904
|
-
return
|
|
812
|
+
return _context6.abrupt("return", event);
|
|
905
813
|
|
|
906
814
|
case 8:
|
|
907
815
|
case "end":
|
|
908
|
-
return
|
|
816
|
+
return _context6.stop();
|
|
909
817
|
}
|
|
910
818
|
}
|
|
911
|
-
},
|
|
819
|
+
}, _callee6, this);
|
|
912
820
|
}));
|
|
913
821
|
|
|
914
|
-
function UpdateRequest(
|
|
822
|
+
function UpdateRequest(_x6) {
|
|
915
823
|
return _UpdateRequest.apply(this, arguments);
|
|
916
824
|
}
|
|
917
825
|
|
|
@@ -919,14 +827,14 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
919
827
|
}()
|
|
920
828
|
}, {
|
|
921
829
|
key: "AudienceData",
|
|
922
|
-
value: function AudienceData(
|
|
923
|
-
var objectId =
|
|
924
|
-
versionHash =
|
|
925
|
-
|
|
926
|
-
protocols =
|
|
927
|
-
|
|
928
|
-
drms =
|
|
929
|
-
context =
|
|
830
|
+
value: function AudienceData(_ref8) {
|
|
831
|
+
var objectId = _ref8.objectId,
|
|
832
|
+
versionHash = _ref8.versionHash,
|
|
833
|
+
_ref8$protocols = _ref8.protocols,
|
|
834
|
+
protocols = _ref8$protocols === void 0 ? [] : _ref8$protocols,
|
|
835
|
+
_ref8$drms = _ref8.drms,
|
|
836
|
+
drms = _ref8$drms === void 0 ? [] : _ref8$drms,
|
|
837
|
+
context = _ref8.context;
|
|
930
838
|
this.Log("Retrieving audience data: ".concat(objectId));
|
|
931
839
|
context = context || this.client.authContext || {};
|
|
932
840
|
|
|
@@ -957,41 +865,41 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
957
865
|
}, {
|
|
958
866
|
key: "GenerateChannelContentToken",
|
|
959
867
|
value: function () {
|
|
960
|
-
var _GenerateChannelContentToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
961
|
-
var objectId, versionHash, issuer, code, email, audienceData, context, oauthToken,
|
|
868
|
+
var _GenerateChannelContentToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref9) {
|
|
869
|
+
var objectId, versionHash, issuer, code, email, audienceData, context, oauthToken, _ref9$value, value, token, tenantId, kmsAddress, stateChannelApi, additionalParams, payload, signature, multiSig;
|
|
962
870
|
|
|
963
|
-
return _regeneratorRuntime.wrap(function
|
|
871
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
964
872
|
while (1) {
|
|
965
|
-
switch (
|
|
873
|
+
switch (_context7.prev = _context7.next) {
|
|
966
874
|
case 0:
|
|
967
|
-
objectId =
|
|
875
|
+
objectId = _ref9.objectId, versionHash = _ref9.versionHash, issuer = _ref9.issuer, code = _ref9.code, email = _ref9.email, audienceData = _ref9.audienceData, context = _ref9.context, oauthToken = _ref9.oauthToken, _ref9$value = _ref9.value, value = _ref9$value === void 0 ? 0 : _ref9$value;
|
|
968
876
|
|
|
969
877
|
if (!oauthToken) {
|
|
970
|
-
|
|
878
|
+
_context7.next = 5;
|
|
971
879
|
break;
|
|
972
880
|
}
|
|
973
881
|
|
|
974
|
-
|
|
882
|
+
_context7.next = 4;
|
|
975
883
|
return this.GenerateOauthChannelToken({
|
|
976
884
|
objectId: objectId,
|
|
977
885
|
token: oauthToken
|
|
978
886
|
});
|
|
979
887
|
|
|
980
888
|
case 4:
|
|
981
|
-
return
|
|
889
|
+
return _context7.abrupt("return", _context7.sent);
|
|
982
890
|
|
|
983
891
|
case 5:
|
|
984
892
|
if (!(!this.noCache && this.channelContentTokens[objectId])) {
|
|
985
|
-
|
|
893
|
+
_context7.next = 11;
|
|
986
894
|
break;
|
|
987
895
|
}
|
|
988
896
|
|
|
989
897
|
if (!(this.channelContentTokens[objectId].issuedAt > Date.now() - 12 * 60 * 60 * 1000)) {
|
|
990
|
-
|
|
898
|
+
_context7.next = 10;
|
|
991
899
|
break;
|
|
992
900
|
}
|
|
993
901
|
|
|
994
|
-
return
|
|
902
|
+
return _context7.abrupt("return", this.channelContentTokens[objectId].token);
|
|
995
903
|
|
|
996
904
|
case 10:
|
|
997
905
|
// Token expired
|
|
@@ -1001,45 +909,45 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1001
909
|
this.Log("Making state channel access request: ".concat(objectId));
|
|
1002
910
|
|
|
1003
911
|
if (!issuer) {
|
|
1004
|
-
|
|
912
|
+
_context7.next = 43;
|
|
1005
913
|
break;
|
|
1006
914
|
}
|
|
1007
915
|
|
|
1008
916
|
// Ticket API
|
|
1009
917
|
tenantId = issuer.replace(/^\//, "").split("/")[2];
|
|
1010
|
-
|
|
1011
|
-
|
|
918
|
+
_context7.prev = 14;
|
|
919
|
+
_context7.next = 17;
|
|
1012
920
|
return this.client.CallContractMethod({
|
|
1013
921
|
contractAddress: Utils.HashToAddress(tenantId),
|
|
1014
922
|
methodName: "addressKMS"
|
|
1015
923
|
});
|
|
1016
924
|
|
|
1017
925
|
case 17:
|
|
1018
|
-
kmsAddress =
|
|
926
|
+
kmsAddress = _context7.sent;
|
|
1019
927
|
|
|
1020
928
|
if (kmsAddress) {
|
|
1021
|
-
|
|
929
|
+
_context7.next = 20;
|
|
1022
930
|
break;
|
|
1023
931
|
}
|
|
1024
932
|
|
|
1025
933
|
throw "";
|
|
1026
934
|
|
|
1027
935
|
case 20:
|
|
1028
|
-
|
|
936
|
+
_context7.next = 27;
|
|
1029
937
|
break;
|
|
1030
938
|
|
|
1031
939
|
case 22:
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
940
|
+
_context7.prev = 22;
|
|
941
|
+
_context7.t0 = _context7["catch"](14);
|
|
942
|
+
_context7.next = 26;
|
|
1035
943
|
return this.client.DefaultKMSAddress();
|
|
1036
944
|
|
|
1037
945
|
case 26:
|
|
1038
|
-
kmsAddress =
|
|
946
|
+
kmsAddress = _context7.sent;
|
|
1039
947
|
|
|
1040
948
|
case 27:
|
|
1041
|
-
|
|
1042
|
-
|
|
949
|
+
_context7.prev = 27;
|
|
950
|
+
_context7.next = 30;
|
|
1043
951
|
return Utils.ResponseToFormat("text", this.MakeAuthServiceRequest({
|
|
1044
952
|
kmsId: "ikms" + Utils.AddressToHash(kmsAddress),
|
|
1045
953
|
method: "POST",
|
|
@@ -1051,16 +959,16 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1051
959
|
}));
|
|
1052
960
|
|
|
1053
961
|
case 30:
|
|
1054
|
-
token =
|
|
1055
|
-
|
|
962
|
+
token = _context7.sent;
|
|
963
|
+
_context7.next = 40;
|
|
1056
964
|
break;
|
|
1057
965
|
|
|
1058
966
|
case 33:
|
|
1059
|
-
|
|
1060
|
-
|
|
967
|
+
_context7.prev = 33;
|
|
968
|
+
_context7.t1 = _context7["catch"](27);
|
|
1061
969
|
this.Log("/as token redemption failed:", true);
|
|
1062
|
-
this.Log(
|
|
1063
|
-
|
|
970
|
+
this.Log(_context7.t1, true);
|
|
971
|
+
_context7.next = 39;
|
|
1064
972
|
return Utils.ResponseToFormat("text", this.MakeKMSRequest({
|
|
1065
973
|
kmsId: "ikms" + Utils.AddressToHash(kmsAddress),
|
|
1066
974
|
method: "POST",
|
|
@@ -1072,12 +980,12 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1072
980
|
}));
|
|
1073
981
|
|
|
1074
982
|
case 39:
|
|
1075
|
-
token =
|
|
983
|
+
token = _context7.sent;
|
|
1076
984
|
|
|
1077
985
|
case 40:
|
|
1078
986
|
// Pull target object from token so token can be cached
|
|
1079
987
|
objectId = JSON.parse(Utils.FromB64(token)).qid;
|
|
1080
|
-
|
|
988
|
+
_context7.next = 54;
|
|
1081
989
|
break;
|
|
1082
990
|
|
|
1083
991
|
case 43:
|
|
@@ -1092,7 +1000,7 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1092
1000
|
|
|
1093
1001
|
stateChannelApi = "elv_channelContentRequestContext";
|
|
1094
1002
|
additionalParams = [JSON.stringify(audienceData)];
|
|
1095
|
-
|
|
1003
|
+
_context7.next = 48;
|
|
1096
1004
|
return this.MakeKMSCall({
|
|
1097
1005
|
objectId: objectId,
|
|
1098
1006
|
methodName: stateChannelApi,
|
|
@@ -1102,12 +1010,12 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1102
1010
|
});
|
|
1103
1011
|
|
|
1104
1012
|
case 48:
|
|
1105
|
-
payload =
|
|
1106
|
-
|
|
1013
|
+
payload = _context7.sent;
|
|
1014
|
+
_context7.next = 51;
|
|
1107
1015
|
return this.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(payload)));
|
|
1108
1016
|
|
|
1109
1017
|
case 51:
|
|
1110
|
-
signature =
|
|
1018
|
+
signature = _context7.sent;
|
|
1111
1019
|
multiSig = Utils.FormatSignature(signature);
|
|
1112
1020
|
token = "".concat(payload, ".").concat(Utils.B64(multiSig));
|
|
1113
1021
|
|
|
@@ -1119,17 +1027,17 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1119
1027
|
};
|
|
1120
1028
|
}
|
|
1121
1029
|
|
|
1122
|
-
return
|
|
1030
|
+
return _context7.abrupt("return", token);
|
|
1123
1031
|
|
|
1124
1032
|
case 56:
|
|
1125
1033
|
case "end":
|
|
1126
|
-
return
|
|
1034
|
+
return _context7.stop();
|
|
1127
1035
|
}
|
|
1128
1036
|
}
|
|
1129
|
-
},
|
|
1037
|
+
}, _callee7, this, [[14, 22], [27, 33]]);
|
|
1130
1038
|
}));
|
|
1131
1039
|
|
|
1132
|
-
function GenerateChannelContentToken(
|
|
1040
|
+
function GenerateChannelContentToken(_x7) {
|
|
1133
1041
|
return _GenerateChannelContentToken.apply(this, arguments);
|
|
1134
1042
|
}
|
|
1135
1043
|
|
|
@@ -1138,16 +1046,16 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1138
1046
|
}, {
|
|
1139
1047
|
key: "ChannelContentFinalize",
|
|
1140
1048
|
value: function () {
|
|
1141
|
-
var _ChannelContentFinalize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1142
|
-
var objectId, versionHash,
|
|
1049
|
+
var _ChannelContentFinalize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref10) {
|
|
1050
|
+
var objectId, versionHash, _ref10$percent, percent, result;
|
|
1143
1051
|
|
|
1144
|
-
return _regeneratorRuntime.wrap(function
|
|
1052
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
1145
1053
|
while (1) {
|
|
1146
|
-
switch (
|
|
1054
|
+
switch (_context8.prev = _context8.next) {
|
|
1147
1055
|
case 0:
|
|
1148
|
-
objectId =
|
|
1056
|
+
objectId = _ref10.objectId, versionHash = _ref10.versionHash, _ref10$percent = _ref10.percent, percent = _ref10$percent === void 0 ? 0 : _ref10$percent;
|
|
1149
1057
|
this.Log("Making state channel finalize request: ".concat(objectId));
|
|
1150
|
-
|
|
1058
|
+
_context8.next = 4;
|
|
1151
1059
|
return this.MakeKMSCall({
|
|
1152
1060
|
objectId: objectId,
|
|
1153
1061
|
methodName: "elv_channelContentFinalizeContext",
|
|
@@ -1160,19 +1068,19 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1160
1068
|
});
|
|
1161
1069
|
|
|
1162
1070
|
case 4:
|
|
1163
|
-
result =
|
|
1071
|
+
result = _context8.sent;
|
|
1164
1072
|
this.channelContentTokens[objectId] = undefined;
|
|
1165
|
-
return
|
|
1073
|
+
return _context8.abrupt("return", result);
|
|
1166
1074
|
|
|
1167
1075
|
case 7:
|
|
1168
1076
|
case "end":
|
|
1169
|
-
return
|
|
1077
|
+
return _context8.stop();
|
|
1170
1078
|
}
|
|
1171
1079
|
}
|
|
1172
|
-
},
|
|
1080
|
+
}, _callee8, this);
|
|
1173
1081
|
}));
|
|
1174
1082
|
|
|
1175
|
-
function ChannelContentFinalize(
|
|
1083
|
+
function ChannelContentFinalize(_x8) {
|
|
1176
1084
|
return _ChannelContentFinalize.apply(this, arguments);
|
|
1177
1085
|
}
|
|
1178
1086
|
|
|
@@ -1181,36 +1089,36 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1181
1089
|
}, {
|
|
1182
1090
|
key: "GenerateOauthChannelToken",
|
|
1183
1091
|
value: function () {
|
|
1184
|
-
var _GenerateOauthChannelToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1092
|
+
var _GenerateOauthChannelToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref11) {
|
|
1185
1093
|
var objectId, versionHash, token, fabricToken;
|
|
1186
|
-
return _regeneratorRuntime.wrap(function
|
|
1094
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
1187
1095
|
while (1) {
|
|
1188
|
-
switch (
|
|
1096
|
+
switch (_context9.prev = _context9.next) {
|
|
1189
1097
|
case 0:
|
|
1190
|
-
objectId =
|
|
1098
|
+
objectId = _ref11.objectId, versionHash = _ref11.versionHash, token = _ref11.token;
|
|
1191
1099
|
|
|
1192
1100
|
if (versionHash) {
|
|
1193
1101
|
objectId = Utils.DecodeVersionHash(versionHash).objectId;
|
|
1194
1102
|
}
|
|
1195
1103
|
|
|
1196
1104
|
if (!(!this.noCache && this.channelContentTokens[objectId])) {
|
|
1197
|
-
|
|
1105
|
+
_context9.next = 6;
|
|
1198
1106
|
break;
|
|
1199
1107
|
}
|
|
1200
1108
|
|
|
1201
1109
|
if (!(this.channelContentTokens[objectId].issuedAt > Date.now() - 12 * 60 * 60 * 1000)) {
|
|
1202
|
-
|
|
1110
|
+
_context9.next = 5;
|
|
1203
1111
|
break;
|
|
1204
1112
|
}
|
|
1205
1113
|
|
|
1206
|
-
return
|
|
1114
|
+
return _context9.abrupt("return", this.channelContentTokens[objectId].token);
|
|
1207
1115
|
|
|
1208
1116
|
case 5:
|
|
1209
1117
|
// Token expired
|
|
1210
1118
|
this.channelContentTokens[objectId] = undefined;
|
|
1211
1119
|
|
|
1212
1120
|
case 6:
|
|
1213
|
-
|
|
1121
|
+
_context9.next = 8;
|
|
1214
1122
|
return this.MakeKMSRequest({
|
|
1215
1123
|
objectId: objectId,
|
|
1216
1124
|
versionHash: versionHash,
|
|
@@ -1223,11 +1131,11 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1223
1131
|
});
|
|
1224
1132
|
|
|
1225
1133
|
case 8:
|
|
1226
|
-
|
|
1227
|
-
return
|
|
1134
|
+
_context9.next = 10;
|
|
1135
|
+
return _context9.sent.text();
|
|
1228
1136
|
|
|
1229
1137
|
case 10:
|
|
1230
|
-
fabricToken =
|
|
1138
|
+
fabricToken = _context9.sent;
|
|
1231
1139
|
|
|
1232
1140
|
if (!this.noCache) {
|
|
1233
1141
|
this.channelContentTokens[objectId] = {
|
|
@@ -1236,17 +1144,17 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1236
1144
|
};
|
|
1237
1145
|
}
|
|
1238
1146
|
|
|
1239
|
-
return
|
|
1147
|
+
return _context9.abrupt("return", fabricToken);
|
|
1240
1148
|
|
|
1241
1149
|
case 13:
|
|
1242
1150
|
case "end":
|
|
1243
|
-
return
|
|
1151
|
+
return _context9.stop();
|
|
1244
1152
|
}
|
|
1245
1153
|
}
|
|
1246
|
-
},
|
|
1154
|
+
}, _callee9, this);
|
|
1247
1155
|
}));
|
|
1248
1156
|
|
|
1249
|
-
function GenerateOauthChannelToken(
|
|
1157
|
+
function GenerateOauthChannelToken(_x9) {
|
|
1250
1158
|
return _GenerateOauthChannelToken.apply(this, arguments);
|
|
1251
1159
|
}
|
|
1252
1160
|
|
|
@@ -1255,27 +1163,27 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1255
1163
|
}, {
|
|
1256
1164
|
key: "IsV3",
|
|
1257
1165
|
value: function () {
|
|
1258
|
-
var _IsV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1166
|
+
var _IsV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref12) {
|
|
1259
1167
|
var id, contractName;
|
|
1260
|
-
return _regeneratorRuntime.wrap(function
|
|
1168
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
1261
1169
|
while (1) {
|
|
1262
|
-
switch (
|
|
1170
|
+
switch (_context10.prev = _context10.next) {
|
|
1263
1171
|
case 0:
|
|
1264
|
-
id =
|
|
1172
|
+
id = _ref12.id;
|
|
1265
1173
|
|
|
1266
1174
|
if (!this.client.assumeV3) {
|
|
1267
|
-
|
|
1175
|
+
_context10.next = 3;
|
|
1268
1176
|
break;
|
|
1269
1177
|
}
|
|
1270
1178
|
|
|
1271
|
-
return
|
|
1179
|
+
return _context10.abrupt("return", true);
|
|
1272
1180
|
|
|
1273
1181
|
case 3:
|
|
1274
|
-
|
|
1182
|
+
_context10.next = 5;
|
|
1275
1183
|
return this.client.ethClient.ContractName(Utils.HashToAddress(id), true);
|
|
1276
1184
|
|
|
1277
1185
|
case 5:
|
|
1278
|
-
contractName =
|
|
1186
|
+
contractName = _context10.sent;
|
|
1279
1187
|
|
|
1280
1188
|
if (!this.accessVersions[contractName]) {
|
|
1281
1189
|
this.accessVersions[contractName] = this.ContractHasMethod({
|
|
@@ -1285,21 +1193,21 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1285
1193
|
});
|
|
1286
1194
|
}
|
|
1287
1195
|
|
|
1288
|
-
|
|
1196
|
+
_context10.next = 9;
|
|
1289
1197
|
return this.accessVersions[contractName];
|
|
1290
1198
|
|
|
1291
1199
|
case 9:
|
|
1292
|
-
return
|
|
1200
|
+
return _context10.abrupt("return", _context10.sent);
|
|
1293
1201
|
|
|
1294
1202
|
case 10:
|
|
1295
1203
|
case "end":
|
|
1296
|
-
return
|
|
1204
|
+
return _context10.stop();
|
|
1297
1205
|
}
|
|
1298
1206
|
}
|
|
1299
|
-
},
|
|
1207
|
+
}, _callee10, this);
|
|
1300
1208
|
}));
|
|
1301
1209
|
|
|
1302
|
-
function IsV3(
|
|
1210
|
+
function IsV3(_x10) {
|
|
1303
1211
|
return _IsV.apply(this, arguments);
|
|
1304
1212
|
}
|
|
1305
1213
|
|
|
@@ -1308,13 +1216,13 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1308
1216
|
}, {
|
|
1309
1217
|
key: "AccessInfo",
|
|
1310
1218
|
value: function () {
|
|
1311
|
-
var _AccessInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1219
|
+
var _AccessInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref13) {
|
|
1312
1220
|
var accessType, publicKey, args, isV3, checkAccessCharge;
|
|
1313
|
-
return _regeneratorRuntime.wrap(function
|
|
1221
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
1314
1222
|
while (1) {
|
|
1315
|
-
switch (
|
|
1223
|
+
switch (_context11.prev = _context11.next) {
|
|
1316
1224
|
case 0:
|
|
1317
|
-
accessType =
|
|
1225
|
+
accessType = _ref13.accessType, publicKey = _ref13.publicKey, args = _ref13.args, isV3 = _ref13.isV3;
|
|
1318
1226
|
checkAccessCharge = false;
|
|
1319
1227
|
|
|
1320
1228
|
if (accessType === ACCESS_TYPES.OBJECT) {
|
|
@@ -1342,20 +1250,20 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1342
1250
|
];
|
|
1343
1251
|
}
|
|
1344
1252
|
|
|
1345
|
-
return
|
|
1253
|
+
return _context11.abrupt("return", {
|
|
1346
1254
|
accessArgs: args,
|
|
1347
1255
|
checkAccessCharge: checkAccessCharge
|
|
1348
1256
|
});
|
|
1349
1257
|
|
|
1350
1258
|
case 5:
|
|
1351
1259
|
case "end":
|
|
1352
|
-
return
|
|
1260
|
+
return _context11.stop();
|
|
1353
1261
|
}
|
|
1354
1262
|
}
|
|
1355
|
-
},
|
|
1263
|
+
}, _callee11, this);
|
|
1356
1264
|
}));
|
|
1357
1265
|
|
|
1358
|
-
function AccessInfo(
|
|
1266
|
+
function AccessInfo(_x11) {
|
|
1359
1267
|
return _AccessInfo.apply(this, arguments);
|
|
1360
1268
|
}
|
|
1361
1269
|
|
|
@@ -1365,54 +1273,54 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1365
1273
|
}, {
|
|
1366
1274
|
key: "AccessType",
|
|
1367
1275
|
value: function () {
|
|
1368
|
-
var _AccessType = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1276
|
+
var _AccessType = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(id) {
|
|
1369
1277
|
var contractName, accessType;
|
|
1370
|
-
return _regeneratorRuntime.wrap(function
|
|
1278
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
1371
1279
|
while (1) {
|
|
1372
|
-
switch (
|
|
1280
|
+
switch (_context12.prev = _context12.next) {
|
|
1373
1281
|
case 0:
|
|
1374
|
-
|
|
1282
|
+
_context12.next = 2;
|
|
1375
1283
|
return this.client.ethClient.ContractName(Utils.HashToAddress(id));
|
|
1376
1284
|
|
|
1377
1285
|
case 2:
|
|
1378
|
-
contractName =
|
|
1286
|
+
contractName = _context12.sent;
|
|
1379
1287
|
|
|
1380
1288
|
if (this.accessTypes[id]) {
|
|
1381
|
-
|
|
1289
|
+
_context12.next = 23;
|
|
1382
1290
|
break;
|
|
1383
1291
|
}
|
|
1384
1292
|
|
|
1385
|
-
|
|
1386
|
-
|
|
1293
|
+
_context12.t0 = contractName;
|
|
1294
|
+
_context12.next = _context12.t0 === "BaseContentSpace" ? 7 : _context12.t0 === "BaseLibrary" ? 9 : _context12.t0 === "BaseContentType" ? 11 : _context12.t0 === "BsAccessWallet" ? 13 : _context12.t0 === "BsAccessCtrlGrp" ? 15 : _context12.t0 === "BaseContent" ? 17 : _context12.t0 === "BaseTenantSpace" ? 19 : 21;
|
|
1387
1295
|
break;
|
|
1388
1296
|
|
|
1389
1297
|
case 7:
|
|
1390
1298
|
accessType = ACCESS_TYPES.SPACE;
|
|
1391
|
-
return
|
|
1299
|
+
return _context12.abrupt("break", 22);
|
|
1392
1300
|
|
|
1393
1301
|
case 9:
|
|
1394
1302
|
accessType = ACCESS_TYPES.LIBRARY;
|
|
1395
|
-
return
|
|
1303
|
+
return _context12.abrupt("break", 22);
|
|
1396
1304
|
|
|
1397
1305
|
case 11:
|
|
1398
1306
|
accessType = ACCESS_TYPES.TYPE;
|
|
1399
|
-
return
|
|
1307
|
+
return _context12.abrupt("break", 22);
|
|
1400
1308
|
|
|
1401
1309
|
case 13:
|
|
1402
1310
|
accessType = ACCESS_TYPES.WALLET;
|
|
1403
|
-
return
|
|
1311
|
+
return _context12.abrupt("break", 22);
|
|
1404
1312
|
|
|
1405
1313
|
case 15:
|
|
1406
1314
|
accessType = ACCESS_TYPES.GROUP;
|
|
1407
|
-
return
|
|
1315
|
+
return _context12.abrupt("break", 22);
|
|
1408
1316
|
|
|
1409
1317
|
case 17:
|
|
1410
1318
|
accessType = ACCESS_TYPES.OBJECT;
|
|
1411
|
-
return
|
|
1319
|
+
return _context12.abrupt("break", 22);
|
|
1412
1320
|
|
|
1413
1321
|
case 19:
|
|
1414
1322
|
accessType = ACCESS_TYPES.TENANT;
|
|
1415
|
-
return
|
|
1323
|
+
return _context12.abrupt("break", 22);
|
|
1416
1324
|
|
|
1417
1325
|
case 21:
|
|
1418
1326
|
accessType = ACCESS_TYPES.OTHER;
|
|
@@ -1421,17 +1329,17 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1421
1329
|
this.accessTypes[id] = accessType;
|
|
1422
1330
|
|
|
1423
1331
|
case 23:
|
|
1424
|
-
return
|
|
1332
|
+
return _context12.abrupt("return", this.accessTypes[id]);
|
|
1425
1333
|
|
|
1426
1334
|
case 24:
|
|
1427
1335
|
case "end":
|
|
1428
|
-
return
|
|
1336
|
+
return _context12.stop();
|
|
1429
1337
|
}
|
|
1430
1338
|
}
|
|
1431
|
-
},
|
|
1339
|
+
}, _callee12, this);
|
|
1432
1340
|
}));
|
|
1433
1341
|
|
|
1434
|
-
function AccessType(
|
|
1342
|
+
function AccessType(_x12) {
|
|
1435
1343
|
return _AccessType.apply(this, arguments);
|
|
1436
1344
|
}
|
|
1437
1345
|
|
|
@@ -1440,29 +1348,29 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1440
1348
|
}, {
|
|
1441
1349
|
key: "AccessComplete",
|
|
1442
1350
|
value: function () {
|
|
1443
|
-
var _AccessComplete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1351
|
+
var _AccessComplete = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref14) {
|
|
1444
1352
|
var id, score, _yield$this$ContractI3, abi, isV3, address, requestId, event;
|
|
1445
1353
|
|
|
1446
|
-
return _regeneratorRuntime.wrap(function
|
|
1354
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
1447
1355
|
while (1) {
|
|
1448
|
-
switch (
|
|
1356
|
+
switch (_context13.prev = _context13.next) {
|
|
1449
1357
|
case 0:
|
|
1450
|
-
id =
|
|
1358
|
+
id = _ref14.id, score = _ref14.score;
|
|
1451
1359
|
this.Log("Calling access complete on ".concat(id, " with score ").concat(score));
|
|
1452
|
-
|
|
1360
|
+
_context13.next = 4;
|
|
1453
1361
|
return this.ContractInfo({
|
|
1454
1362
|
id: id
|
|
1455
1363
|
});
|
|
1456
1364
|
|
|
1457
1365
|
case 4:
|
|
1458
|
-
_yield$this$ContractI3 =
|
|
1366
|
+
_yield$this$ContractI3 = _context13.sent;
|
|
1459
1367
|
abi = _yield$this$ContractI3.abi;
|
|
1460
1368
|
isV3 = _yield$this$ContractI3.isV3;
|
|
1461
1369
|
address = Utils.HashToAddress(id);
|
|
1462
1370
|
requestId = this.requestIds[address];
|
|
1463
1371
|
|
|
1464
1372
|
if (requestId) {
|
|
1465
|
-
|
|
1373
|
+
_context13.next = 11;
|
|
1466
1374
|
break;
|
|
1467
1375
|
}
|
|
1468
1376
|
|
|
@@ -1470,11 +1378,11 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1470
1378
|
|
|
1471
1379
|
case 11:
|
|
1472
1380
|
if (!isV3) {
|
|
1473
|
-
|
|
1381
|
+
_context13.next = 17;
|
|
1474
1382
|
break;
|
|
1475
1383
|
}
|
|
1476
1384
|
|
|
1477
|
-
|
|
1385
|
+
_context13.next = 14;
|
|
1478
1386
|
return this.client.CallContractMethodAndWait({
|
|
1479
1387
|
contractAddress: address,
|
|
1480
1388
|
abi: abi,
|
|
@@ -1483,12 +1391,12 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1483
1391
|
});
|
|
1484
1392
|
|
|
1485
1393
|
case 14:
|
|
1486
|
-
event =
|
|
1487
|
-
|
|
1394
|
+
event = _context13.sent;
|
|
1395
|
+
_context13.next = 20;
|
|
1488
1396
|
break;
|
|
1489
1397
|
|
|
1490
1398
|
case 17:
|
|
1491
|
-
|
|
1399
|
+
_context13.next = 19;
|
|
1492
1400
|
return this.client.CallContractMethodAndWait({
|
|
1493
1401
|
contractAddress: address,
|
|
1494
1402
|
abi: abi,
|
|
@@ -1497,22 +1405,22 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1497
1405
|
});
|
|
1498
1406
|
|
|
1499
1407
|
case 19:
|
|
1500
|
-
event =
|
|
1408
|
+
event = _context13.sent;
|
|
1501
1409
|
|
|
1502
1410
|
case 20:
|
|
1503
1411
|
delete this.requestIds[address];
|
|
1504
1412
|
delete this.accessTransactions[address];
|
|
1505
|
-
return
|
|
1413
|
+
return _context13.abrupt("return", event);
|
|
1506
1414
|
|
|
1507
1415
|
case 23:
|
|
1508
1416
|
case "end":
|
|
1509
|
-
return
|
|
1417
|
+
return _context13.stop();
|
|
1510
1418
|
}
|
|
1511
1419
|
}
|
|
1512
|
-
},
|
|
1420
|
+
}, _callee13, this);
|
|
1513
1421
|
}));
|
|
1514
1422
|
|
|
1515
|
-
function AccessComplete(
|
|
1423
|
+
function AccessComplete(_x13) {
|
|
1516
1424
|
return _AccessComplete.apply(this, arguments);
|
|
1517
1425
|
}
|
|
1518
1426
|
|
|
@@ -1523,13 +1431,13 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1523
1431
|
}, {
|
|
1524
1432
|
key: "ContractInfo",
|
|
1525
1433
|
value: function () {
|
|
1526
|
-
var _ContractInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1434
|
+
var _ContractInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref15) {
|
|
1527
1435
|
var id, address, isV3, version, accessType;
|
|
1528
|
-
return _regeneratorRuntime.wrap(function
|
|
1436
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
1529
1437
|
while (1) {
|
|
1530
|
-
switch (
|
|
1438
|
+
switch (_context14.prev = _context14.next) {
|
|
1531
1439
|
case 0:
|
|
1532
|
-
id =
|
|
1440
|
+
id = _ref15.id, address = _ref15.address;
|
|
1533
1441
|
|
|
1534
1442
|
if (!address) {
|
|
1535
1443
|
address = Utils.HashToAddress(id);
|
|
@@ -1539,29 +1447,29 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1539
1447
|
id = Utils.AddressToObjectId(address);
|
|
1540
1448
|
}
|
|
1541
1449
|
|
|
1542
|
-
|
|
1450
|
+
_context14.next = 5;
|
|
1543
1451
|
return this.IsV3({
|
|
1544
1452
|
id: id
|
|
1545
1453
|
});
|
|
1546
1454
|
|
|
1547
1455
|
case 5:
|
|
1548
|
-
isV3 =
|
|
1456
|
+
isV3 = _context14.sent;
|
|
1549
1457
|
version = isV3 ? "v3" : "v2";
|
|
1550
|
-
|
|
1458
|
+
_context14.next = 9;
|
|
1551
1459
|
return this.AccessType(id);
|
|
1552
1460
|
|
|
1553
1461
|
case 9:
|
|
1554
|
-
accessType =
|
|
1462
|
+
accessType = _context14.sent;
|
|
1555
1463
|
|
|
1556
1464
|
if (!(accessType === this.ACCESS_TYPES.OTHER)) {
|
|
1557
|
-
|
|
1465
|
+
_context14.next = 12;
|
|
1558
1466
|
break;
|
|
1559
1467
|
}
|
|
1560
1468
|
|
|
1561
|
-
return
|
|
1469
|
+
return _context14.abrupt("return", {});
|
|
1562
1470
|
|
|
1563
1471
|
case 12:
|
|
1564
|
-
return
|
|
1472
|
+
return _context14.abrupt("return", {
|
|
1565
1473
|
isV3: isV3,
|
|
1566
1474
|
accessType: accessType,
|
|
1567
1475
|
abi: this.CONTRACTS[version][accessType].abi
|
|
@@ -1569,13 +1477,13 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1569
1477
|
|
|
1570
1478
|
case 13:
|
|
1571
1479
|
case "end":
|
|
1572
|
-
return
|
|
1480
|
+
return _context14.stop();
|
|
1573
1481
|
}
|
|
1574
1482
|
}
|
|
1575
|
-
},
|
|
1483
|
+
}, _callee14, this);
|
|
1576
1484
|
}));
|
|
1577
1485
|
|
|
1578
|
-
function ContractInfo(
|
|
1486
|
+
function ContractInfo(_x14) {
|
|
1579
1487
|
return _ContractInfo.apply(this, arguments);
|
|
1580
1488
|
}
|
|
1581
1489
|
|
|
@@ -1584,23 +1492,23 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1584
1492
|
}, {
|
|
1585
1493
|
key: "GetAccessCharge",
|
|
1586
1494
|
value: function () {
|
|
1587
|
-
var _GetAccessCharge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1495
|
+
var _GetAccessCharge = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref16) {
|
|
1588
1496
|
var objectId, args, _yield$this$ContractI4, abi, info;
|
|
1589
1497
|
|
|
1590
|
-
return _regeneratorRuntime.wrap(function
|
|
1498
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
1591
1499
|
while (1) {
|
|
1592
|
-
switch (
|
|
1500
|
+
switch (_context15.prev = _context15.next) {
|
|
1593
1501
|
case 0:
|
|
1594
|
-
objectId =
|
|
1595
|
-
|
|
1502
|
+
objectId = _ref16.objectId, args = _ref16.args;
|
|
1503
|
+
_context15.next = 3;
|
|
1596
1504
|
return this.ContractInfo({
|
|
1597
1505
|
id: objectId
|
|
1598
1506
|
});
|
|
1599
1507
|
|
|
1600
1508
|
case 3:
|
|
1601
|
-
_yield$this$ContractI4 =
|
|
1509
|
+
_yield$this$ContractI4 = _context15.sent;
|
|
1602
1510
|
abi = _yield$this$ContractI4.abi;
|
|
1603
|
-
|
|
1511
|
+
_context15.next = 7;
|
|
1604
1512
|
return this.client.CallContractMethod({
|
|
1605
1513
|
contractAddress: Utils.HashToAddress(objectId),
|
|
1606
1514
|
abi: abi,
|
|
@@ -1609,18 +1517,18 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1609
1517
|
});
|
|
1610
1518
|
|
|
1611
1519
|
case 7:
|
|
1612
|
-
info =
|
|
1613
|
-
return
|
|
1520
|
+
info = _context15.sent;
|
|
1521
|
+
return _context15.abrupt("return", info[1] === 0 ? 0 : info[2]);
|
|
1614
1522
|
|
|
1615
1523
|
case 9:
|
|
1616
1524
|
case "end":
|
|
1617
|
-
return
|
|
1525
|
+
return _context15.stop();
|
|
1618
1526
|
}
|
|
1619
1527
|
}
|
|
1620
|
-
},
|
|
1528
|
+
}, _callee15, this);
|
|
1621
1529
|
}));
|
|
1622
1530
|
|
|
1623
|
-
function GetAccessCharge(
|
|
1531
|
+
function GetAccessCharge(_x15) {
|
|
1624
1532
|
return _GetAccessCharge.apply(this, arguments);
|
|
1625
1533
|
}
|
|
1626
1534
|
|
|
@@ -1629,27 +1537,27 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1629
1537
|
}, {
|
|
1630
1538
|
key: "Owner",
|
|
1631
1539
|
value: function () {
|
|
1632
|
-
var _Owner = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1540
|
+
var _Owner = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref17) {
|
|
1633
1541
|
var id, address, ownerAddress;
|
|
1634
|
-
return _regeneratorRuntime.wrap(function
|
|
1542
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
1635
1543
|
while (1) {
|
|
1636
|
-
switch (
|
|
1544
|
+
switch (_context16.prev = _context16.next) {
|
|
1637
1545
|
case 0:
|
|
1638
|
-
id =
|
|
1546
|
+
id = _ref17.id, address = _ref17.address;
|
|
1639
1547
|
|
|
1640
1548
|
if (this.client.signer) {
|
|
1641
|
-
|
|
1549
|
+
_context16.next = 3;
|
|
1642
1550
|
break;
|
|
1643
1551
|
}
|
|
1644
1552
|
|
|
1645
|
-
return
|
|
1553
|
+
return _context16.abrupt("return", false);
|
|
1646
1554
|
|
|
1647
1555
|
case 3:
|
|
1648
1556
|
if (id) {
|
|
1649
1557
|
address = Utils.HashToAddress(id);
|
|
1650
1558
|
}
|
|
1651
1559
|
|
|
1652
|
-
|
|
1560
|
+
_context16.next = 6;
|
|
1653
1561
|
return this.client.CallContractMethod({
|
|
1654
1562
|
contractAddress: address,
|
|
1655
1563
|
methodName: "owner",
|
|
@@ -1657,18 +1565,18 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1657
1565
|
});
|
|
1658
1566
|
|
|
1659
1567
|
case 6:
|
|
1660
|
-
ownerAddress =
|
|
1661
|
-
return
|
|
1568
|
+
ownerAddress = _context16.sent;
|
|
1569
|
+
return _context16.abrupt("return", Utils.FormatAddress(ownerAddress));
|
|
1662
1570
|
|
|
1663
1571
|
case 8:
|
|
1664
1572
|
case "end":
|
|
1665
|
-
return
|
|
1573
|
+
return _context16.stop();
|
|
1666
1574
|
}
|
|
1667
1575
|
}
|
|
1668
|
-
},
|
|
1576
|
+
}, _callee16, this);
|
|
1669
1577
|
}));
|
|
1670
1578
|
|
|
1671
|
-
function Owner(
|
|
1579
|
+
function Owner(_x16) {
|
|
1672
1580
|
return _Owner.apply(this, arguments);
|
|
1673
1581
|
}
|
|
1674
1582
|
|
|
@@ -1677,50 +1585,50 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1677
1585
|
}, {
|
|
1678
1586
|
key: "Sign",
|
|
1679
1587
|
value: function () {
|
|
1680
|
-
var _Sign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1681
|
-
return _regeneratorRuntime.wrap(function
|
|
1588
|
+
var _Sign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(message) {
|
|
1589
|
+
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
1682
1590
|
while (1) {
|
|
1683
|
-
switch (
|
|
1591
|
+
switch (_context17.prev = _context17.next) {
|
|
1684
1592
|
case 0:
|
|
1685
|
-
|
|
1593
|
+
_context17.t0 = Ethers.utils;
|
|
1686
1594
|
|
|
1687
1595
|
if (!this.client.signer.signDigest) {
|
|
1688
|
-
|
|
1596
|
+
_context17.next = 7;
|
|
1689
1597
|
break;
|
|
1690
1598
|
}
|
|
1691
1599
|
|
|
1692
|
-
|
|
1600
|
+
_context17.next = 4;
|
|
1693
1601
|
return this.client.signer.signDigest(message);
|
|
1694
1602
|
|
|
1695
1603
|
case 4:
|
|
1696
|
-
|
|
1697
|
-
|
|
1604
|
+
_context17.t1 = _context17.sent;
|
|
1605
|
+
_context17.next = 10;
|
|
1698
1606
|
break;
|
|
1699
1607
|
|
|
1700
1608
|
case 7:
|
|
1701
|
-
|
|
1609
|
+
_context17.next = 9;
|
|
1702
1610
|
return this.client.signer.signingKey.signDigest(message);
|
|
1703
1611
|
|
|
1704
1612
|
case 9:
|
|
1705
|
-
|
|
1613
|
+
_context17.t1 = _context17.sent;
|
|
1706
1614
|
|
|
1707
1615
|
case 10:
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
return
|
|
1616
|
+
_context17.t2 = _context17.t1;
|
|
1617
|
+
_context17.next = 13;
|
|
1618
|
+
return _context17.t0.joinSignature.call(_context17.t0, _context17.t2);
|
|
1711
1619
|
|
|
1712
1620
|
case 13:
|
|
1713
|
-
return
|
|
1621
|
+
return _context17.abrupt("return", _context17.sent);
|
|
1714
1622
|
|
|
1715
1623
|
case 14:
|
|
1716
1624
|
case "end":
|
|
1717
|
-
return
|
|
1625
|
+
return _context17.stop();
|
|
1718
1626
|
}
|
|
1719
1627
|
}
|
|
1720
|
-
},
|
|
1628
|
+
}, _callee17, this);
|
|
1721
1629
|
}));
|
|
1722
1630
|
|
|
1723
|
-
function Sign(
|
|
1631
|
+
function Sign(_x17) {
|
|
1724
1632
|
return _Sign.apply(this, arguments);
|
|
1725
1633
|
}
|
|
1726
1634
|
|
|
@@ -1729,37 +1637,37 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1729
1637
|
}, {
|
|
1730
1638
|
key: "KMSAddress",
|
|
1731
1639
|
value: function () {
|
|
1732
|
-
var _KMSAddress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1640
|
+
var _KMSAddress = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref18) {
|
|
1733
1641
|
var objectId, versionHash, _yield$this$ContractI5, abi;
|
|
1734
1642
|
|
|
1735
|
-
return _regeneratorRuntime.wrap(function
|
|
1643
|
+
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
1736
1644
|
while (1) {
|
|
1737
|
-
switch (
|
|
1645
|
+
switch (_context18.prev = _context18.next) {
|
|
1738
1646
|
case 0:
|
|
1739
|
-
objectId =
|
|
1647
|
+
objectId = _ref18.objectId, versionHash = _ref18.versionHash;
|
|
1740
1648
|
|
|
1741
1649
|
if (versionHash) {
|
|
1742
1650
|
objectId = Utils.DecodeVersionHash(versionHash).objectId;
|
|
1743
1651
|
}
|
|
1744
1652
|
|
|
1745
|
-
|
|
1653
|
+
_context18.next = 4;
|
|
1746
1654
|
return this.ContractInfo({
|
|
1747
1655
|
id: objectId
|
|
1748
1656
|
});
|
|
1749
1657
|
|
|
1750
1658
|
case 4:
|
|
1751
|
-
_yield$this$ContractI5 =
|
|
1659
|
+
_yield$this$ContractI5 = _context18.sent;
|
|
1752
1660
|
abi = _yield$this$ContractI5.abi;
|
|
1753
1661
|
|
|
1754
1662
|
if (abi) {
|
|
1755
|
-
|
|
1663
|
+
_context18.next = 8;
|
|
1756
1664
|
break;
|
|
1757
1665
|
}
|
|
1758
1666
|
|
|
1759
1667
|
throw Error("Unable to determine contract info for ".concat(objectId, " - wrong network?"));
|
|
1760
1668
|
|
|
1761
1669
|
case 8:
|
|
1762
|
-
|
|
1670
|
+
_context18.next = 10;
|
|
1763
1671
|
return this.client.CallContractMethod({
|
|
1764
1672
|
contractAddress: Utils.HashToAddress(objectId),
|
|
1765
1673
|
abi: abi,
|
|
@@ -1767,17 +1675,17 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1767
1675
|
});
|
|
1768
1676
|
|
|
1769
1677
|
case 10:
|
|
1770
|
-
return
|
|
1678
|
+
return _context18.abrupt("return", _context18.sent);
|
|
1771
1679
|
|
|
1772
1680
|
case 11:
|
|
1773
1681
|
case "end":
|
|
1774
|
-
return
|
|
1682
|
+
return _context18.stop();
|
|
1775
1683
|
}
|
|
1776
1684
|
}
|
|
1777
|
-
},
|
|
1685
|
+
}, _callee18, this);
|
|
1778
1686
|
}));
|
|
1779
1687
|
|
|
1780
|
-
function KMSAddress(
|
|
1688
|
+
function KMSAddress(_x18) {
|
|
1781
1689
|
return _KMSAddress.apply(this, arguments);
|
|
1782
1690
|
}
|
|
1783
1691
|
|
|
@@ -1786,29 +1694,29 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1786
1694
|
}, {
|
|
1787
1695
|
key: "KMSInfo",
|
|
1788
1696
|
value: function () {
|
|
1789
|
-
var _KMSInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1697
|
+
var _KMSInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(_ref19) {
|
|
1790
1698
|
var objectId, versionHash, kmsId, KMSInfo, _yield$this$ContractI6, abi, _yield$this$ContractI7, _abi, publicKey;
|
|
1791
1699
|
|
|
1792
|
-
return _regeneratorRuntime.wrap(function
|
|
1700
|
+
return _regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
1793
1701
|
while (1) {
|
|
1794
|
-
switch (
|
|
1702
|
+
switch (_context19.prev = _context19.next) {
|
|
1795
1703
|
case 0:
|
|
1796
|
-
objectId =
|
|
1704
|
+
objectId = _ref19.objectId, versionHash = _ref19.versionHash, kmsId = _ref19.kmsId;
|
|
1797
1705
|
|
|
1798
1706
|
if (!kmsId) {
|
|
1799
|
-
|
|
1707
|
+
_context19.next = 11;
|
|
1800
1708
|
break;
|
|
1801
1709
|
}
|
|
1802
1710
|
|
|
1803
|
-
|
|
1711
|
+
_context19.next = 4;
|
|
1804
1712
|
return this.ContractInfo({
|
|
1805
1713
|
address: this.client.contentSpaceAddress
|
|
1806
1714
|
});
|
|
1807
1715
|
|
|
1808
1716
|
case 4:
|
|
1809
|
-
_yield$this$ContractI6 =
|
|
1717
|
+
_yield$this$ContractI6 = _context19.sent;
|
|
1810
1718
|
abi = _yield$this$ContractI6.abi;
|
|
1811
|
-
|
|
1719
|
+
_context19.next = 8;
|
|
1812
1720
|
return this.client.CallContractMethod({
|
|
1813
1721
|
contractAddress: this.client.contentSpaceAddress,
|
|
1814
1722
|
abi: abi,
|
|
@@ -1818,8 +1726,8 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1818
1726
|
});
|
|
1819
1727
|
|
|
1820
1728
|
case 8:
|
|
1821
|
-
KMSInfo =
|
|
1822
|
-
|
|
1729
|
+
KMSInfo = _context19.sent;
|
|
1730
|
+
_context19.next = 19;
|
|
1823
1731
|
break;
|
|
1824
1732
|
|
|
1825
1733
|
case 11:
|
|
@@ -1827,15 +1735,15 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1827
1735
|
objectId = Utils.DecodeVersionHash(versionHash).objectId;
|
|
1828
1736
|
}
|
|
1829
1737
|
|
|
1830
|
-
|
|
1738
|
+
_context19.next = 14;
|
|
1831
1739
|
return this.ContractInfo({
|
|
1832
1740
|
id: objectId
|
|
1833
1741
|
});
|
|
1834
1742
|
|
|
1835
1743
|
case 14:
|
|
1836
|
-
_yield$this$ContractI7 =
|
|
1744
|
+
_yield$this$ContractI7 = _context19.sent;
|
|
1837
1745
|
_abi = _yield$this$ContractI7.abi;
|
|
1838
|
-
|
|
1746
|
+
_context19.next = 18;
|
|
1839
1747
|
return this.client.CallContractMethod({
|
|
1840
1748
|
contractAddress: Utils.HashToAddress(objectId),
|
|
1841
1749
|
abi: _abi,
|
|
@@ -1845,25 +1753,25 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1845
1753
|
});
|
|
1846
1754
|
|
|
1847
1755
|
case 18:
|
|
1848
|
-
KMSInfo =
|
|
1756
|
+
KMSInfo = _context19.sent;
|
|
1849
1757
|
|
|
1850
1758
|
case 19:
|
|
1851
1759
|
// Public key is compressed and hashed
|
|
1852
1760
|
publicKey = Ethers.utils.computePublicKey(Utils.HashToAddress(KMSInfo[1]), false);
|
|
1853
|
-
return
|
|
1761
|
+
return _context19.abrupt("return", {
|
|
1854
1762
|
urls: KMSInfo[0].split(","),
|
|
1855
1763
|
publicKey: publicKey
|
|
1856
1764
|
});
|
|
1857
1765
|
|
|
1858
1766
|
case 21:
|
|
1859
1767
|
case "end":
|
|
1860
|
-
return
|
|
1768
|
+
return _context19.stop();
|
|
1861
1769
|
}
|
|
1862
1770
|
}
|
|
1863
|
-
},
|
|
1771
|
+
}, _callee19, this);
|
|
1864
1772
|
}));
|
|
1865
1773
|
|
|
1866
|
-
function KMSInfo(
|
|
1774
|
+
function KMSInfo(_x19) {
|
|
1867
1775
|
return _KMSInfo.apply(this, arguments);
|
|
1868
1776
|
}
|
|
1869
1777
|
|
|
@@ -1873,37 +1781,37 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1873
1781
|
}, {
|
|
1874
1782
|
key: "RetrieveConk",
|
|
1875
1783
|
value: function () {
|
|
1876
|
-
var _RetrieveConk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1784
|
+
var _RetrieveConk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(_ref20) {
|
|
1877
1785
|
var libraryId, objectId, kmsAddress, kmsCapId, kmsCap, cap;
|
|
1878
|
-
return _regeneratorRuntime.wrap(function
|
|
1786
|
+
return _regeneratorRuntime.wrap(function _callee20$(_context20) {
|
|
1879
1787
|
while (1) {
|
|
1880
|
-
switch (
|
|
1788
|
+
switch (_context20.prev = _context20.next) {
|
|
1881
1789
|
case 0:
|
|
1882
|
-
libraryId =
|
|
1790
|
+
libraryId = _ref20.libraryId, objectId = _ref20.objectId;
|
|
1883
1791
|
|
|
1884
1792
|
if (libraryId) {
|
|
1885
|
-
|
|
1793
|
+
_context20.next = 5;
|
|
1886
1794
|
break;
|
|
1887
1795
|
}
|
|
1888
1796
|
|
|
1889
|
-
|
|
1797
|
+
_context20.next = 4;
|
|
1890
1798
|
return this.client.ContentObjectLibraryId({
|
|
1891
1799
|
objectId: objectId
|
|
1892
1800
|
});
|
|
1893
1801
|
|
|
1894
1802
|
case 4:
|
|
1895
|
-
libraryId =
|
|
1803
|
+
libraryId = _context20.sent;
|
|
1896
1804
|
|
|
1897
1805
|
case 5:
|
|
1898
|
-
|
|
1806
|
+
_context20.next = 7;
|
|
1899
1807
|
return this.KMSAddress({
|
|
1900
1808
|
objectId: objectId
|
|
1901
1809
|
});
|
|
1902
1810
|
|
|
1903
1811
|
case 7:
|
|
1904
|
-
kmsAddress =
|
|
1812
|
+
kmsAddress = _context20.sent;
|
|
1905
1813
|
kmsCapId = "eluv.caps.ikms".concat(Utils.AddressToHash(kmsAddress));
|
|
1906
|
-
|
|
1814
|
+
_context20.next = 11;
|
|
1907
1815
|
return this.client.ContentObjectMetadata({
|
|
1908
1816
|
libraryId: libraryId,
|
|
1909
1817
|
objectId: objectId,
|
|
@@ -1911,17 +1819,17 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1911
1819
|
});
|
|
1912
1820
|
|
|
1913
1821
|
case 11:
|
|
1914
|
-
kmsCap =
|
|
1822
|
+
kmsCap = _context20.sent;
|
|
1915
1823
|
|
|
1916
1824
|
if (kmsCap) {
|
|
1917
|
-
|
|
1825
|
+
_context20.next = 14;
|
|
1918
1826
|
break;
|
|
1919
1827
|
}
|
|
1920
1828
|
|
|
1921
1829
|
throw Error("No KMS key set for this object");
|
|
1922
1830
|
|
|
1923
1831
|
case 14:
|
|
1924
|
-
|
|
1832
|
+
_context20.next = 16;
|
|
1925
1833
|
return this.MakeKMSCall({
|
|
1926
1834
|
objectId: objectId,
|
|
1927
1835
|
methodName: "elv_getEncryptionKey",
|
|
@@ -1930,18 +1838,18 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1930
1838
|
});
|
|
1931
1839
|
|
|
1932
1840
|
case 16:
|
|
1933
|
-
cap =
|
|
1934
|
-
return
|
|
1841
|
+
cap = _context20.sent;
|
|
1842
|
+
return _context20.abrupt("return", JSON.parse(Utils.FromB58(cap.replace(/^kp__/, "")).toString("utf-8")));
|
|
1935
1843
|
|
|
1936
1844
|
case 18:
|
|
1937
1845
|
case "end":
|
|
1938
|
-
return
|
|
1846
|
+
return _context20.stop();
|
|
1939
1847
|
}
|
|
1940
1848
|
}
|
|
1941
|
-
},
|
|
1849
|
+
}, _callee20, this);
|
|
1942
1850
|
}));
|
|
1943
1851
|
|
|
1944
|
-
function RetrieveConk(
|
|
1852
|
+
function RetrieveConk(_x20) {
|
|
1945
1853
|
return _RetrieveConk.apply(this, arguments);
|
|
1946
1854
|
}
|
|
1947
1855
|
|
|
@@ -1951,37 +1859,37 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1951
1859
|
}, {
|
|
1952
1860
|
key: "RetrieveReencryptionSymmetricKey",
|
|
1953
1861
|
value: function () {
|
|
1954
|
-
var _RetrieveReencryptionSymmetricKey = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1862
|
+
var _RetrieveReencryptionSymmetricKey = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref21) {
|
|
1955
1863
|
var libraryId, objectId, kmsAddress, kmsCapId, kmsCap;
|
|
1956
|
-
return _regeneratorRuntime.wrap(function
|
|
1864
|
+
return _regeneratorRuntime.wrap(function _callee21$(_context21) {
|
|
1957
1865
|
while (1) {
|
|
1958
|
-
switch (
|
|
1866
|
+
switch (_context21.prev = _context21.next) {
|
|
1959
1867
|
case 0:
|
|
1960
|
-
libraryId =
|
|
1868
|
+
libraryId = _ref21.libraryId, objectId = _ref21.objectId;
|
|
1961
1869
|
|
|
1962
1870
|
if (libraryId) {
|
|
1963
|
-
|
|
1871
|
+
_context21.next = 5;
|
|
1964
1872
|
break;
|
|
1965
1873
|
}
|
|
1966
1874
|
|
|
1967
|
-
|
|
1875
|
+
_context21.next = 4;
|
|
1968
1876
|
return this.client.ContentObjectLibraryId({
|
|
1969
1877
|
objectId: objectId
|
|
1970
1878
|
});
|
|
1971
1879
|
|
|
1972
1880
|
case 4:
|
|
1973
|
-
libraryId =
|
|
1881
|
+
libraryId = _context21.sent;
|
|
1974
1882
|
|
|
1975
1883
|
case 5:
|
|
1976
|
-
|
|
1884
|
+
_context21.next = 7;
|
|
1977
1885
|
return this.KMSAddress({
|
|
1978
1886
|
objectId: objectId
|
|
1979
1887
|
});
|
|
1980
1888
|
|
|
1981
1889
|
case 7:
|
|
1982
|
-
kmsAddress =
|
|
1890
|
+
kmsAddress = _context21.sent;
|
|
1983
1891
|
kmsCapId = "eluv.caps.ikms".concat(Utils.AddressToHash(kmsAddress));
|
|
1984
|
-
|
|
1892
|
+
_context21.next = 11;
|
|
1985
1893
|
return this.client.ContentObjectMetadata({
|
|
1986
1894
|
libraryId: libraryId,
|
|
1987
1895
|
objectId: objectId,
|
|
@@ -1989,17 +1897,17 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1989
1897
|
});
|
|
1990
1898
|
|
|
1991
1899
|
case 11:
|
|
1992
|
-
kmsCap =
|
|
1900
|
+
kmsCap = _context21.sent;
|
|
1993
1901
|
|
|
1994
1902
|
if (kmsCap) {
|
|
1995
|
-
|
|
1903
|
+
_context21.next = 14;
|
|
1996
1904
|
break;
|
|
1997
1905
|
}
|
|
1998
1906
|
|
|
1999
1907
|
throw Error("No KMS key set for this object");
|
|
2000
1908
|
|
|
2001
1909
|
case 14:
|
|
2002
|
-
|
|
1910
|
+
_context21.next = 16;
|
|
2003
1911
|
return this.MakeKMSCall({
|
|
2004
1912
|
objectId: objectId,
|
|
2005
1913
|
methodName: "elv_getSymmetricKeyAuth",
|
|
@@ -2008,17 +1916,17 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2008
1916
|
});
|
|
2009
1917
|
|
|
2010
1918
|
case 16:
|
|
2011
|
-
return
|
|
1919
|
+
return _context21.abrupt("return", _context21.sent);
|
|
2012
1920
|
|
|
2013
1921
|
case 17:
|
|
2014
1922
|
case "end":
|
|
2015
|
-
return
|
|
1923
|
+
return _context21.stop();
|
|
2016
1924
|
}
|
|
2017
1925
|
}
|
|
2018
|
-
},
|
|
1926
|
+
}, _callee21, this);
|
|
2019
1927
|
}));
|
|
2020
1928
|
|
|
2021
|
-
function RetrieveReencryptionSymmetricKey(
|
|
1929
|
+
function RetrieveReencryptionSymmetricKey(_x21) {
|
|
2022
1930
|
return _RetrieveReencryptionSymmetricKey.apply(this, arguments);
|
|
2023
1931
|
}
|
|
2024
1932
|
|
|
@@ -2028,55 +1936,55 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2028
1936
|
}, {
|
|
2029
1937
|
key: "MakeKMSCall",
|
|
2030
1938
|
value: function () {
|
|
2031
|
-
var _MakeKMSCall = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
2032
|
-
var kmsId, tenantId, objectId, versionHash, methodName, params, paramTypes,
|
|
1939
|
+
var _MakeKMSCall = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref22) {
|
|
1940
|
+
var kmsId, tenantId, objectId, versionHash, methodName, params, paramTypes, _ref22$additionalPara, additionalParams, _ref22$signature, signature, packedHash, KMSUrls, i, kmsUrl;
|
|
2033
1941
|
|
|
2034
|
-
return _regeneratorRuntime.wrap(function
|
|
1942
|
+
return _regeneratorRuntime.wrap(function _callee22$(_context22) {
|
|
2035
1943
|
while (1) {
|
|
2036
|
-
switch (
|
|
1944
|
+
switch (_context22.prev = _context22.next) {
|
|
2037
1945
|
case 0:
|
|
2038
|
-
kmsId =
|
|
1946
|
+
kmsId = _ref22.kmsId, tenantId = _ref22.tenantId, objectId = _ref22.objectId, versionHash = _ref22.versionHash, methodName = _ref22.methodName, params = _ref22.params, paramTypes = _ref22.paramTypes, _ref22$additionalPara = _ref22.additionalParams, additionalParams = _ref22$additionalPara === void 0 ? [] : _ref22$additionalPara, _ref22$signature = _ref22.signature, signature = _ref22$signature === void 0 ? true : _ref22$signature;
|
|
2039
1947
|
|
|
2040
1948
|
if (versionHash) {
|
|
2041
1949
|
objectId = Utils.DecodeVersionHash(versionHash).objectId;
|
|
2042
1950
|
}
|
|
2043
1951
|
|
|
2044
1952
|
if (objectId) {
|
|
2045
|
-
|
|
1953
|
+
_context22.next = 10;
|
|
2046
1954
|
break;
|
|
2047
1955
|
}
|
|
2048
1956
|
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
1957
|
+
_context22.t0 = "ikms";
|
|
1958
|
+
_context22.t1 = Utils;
|
|
1959
|
+
_context22.next = 7;
|
|
2052
1960
|
return this.client.DefaultKMSAddress({
|
|
2053
1961
|
tenantId: tenantId
|
|
2054
1962
|
});
|
|
2055
1963
|
|
|
2056
1964
|
case 7:
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
kmsId =
|
|
1965
|
+
_context22.t2 = _context22.sent;
|
|
1966
|
+
_context22.t3 = _context22.t1.AddressToHash.call(_context22.t1, _context22.t2);
|
|
1967
|
+
kmsId = _context22.t0.concat.call(_context22.t0, _context22.t3);
|
|
2060
1968
|
|
|
2061
1969
|
case 10:
|
|
2062
1970
|
if (!signature) {
|
|
2063
|
-
|
|
1971
|
+
_context22.next = 17;
|
|
2064
1972
|
break;
|
|
2065
1973
|
}
|
|
2066
1974
|
|
|
2067
1975
|
packedHash = Ethers.utils.solidityKeccak256(paramTypes, params);
|
|
2068
|
-
|
|
2069
|
-
|
|
1976
|
+
_context22.t4 = params;
|
|
1977
|
+
_context22.next = 15;
|
|
2070
1978
|
return this.Sign(packedHash);
|
|
2071
1979
|
|
|
2072
1980
|
case 15:
|
|
2073
|
-
|
|
1981
|
+
_context22.t5 = _context22.sent;
|
|
2074
1982
|
|
|
2075
|
-
|
|
1983
|
+
_context22.t4.push.call(_context22.t4, _context22.t5);
|
|
2076
1984
|
|
|
2077
1985
|
case 17:
|
|
2078
1986
|
params = params.concat(additionalParams);
|
|
2079
|
-
|
|
1987
|
+
_context22.next = 20;
|
|
2080
1988
|
return this.KMSInfo({
|
|
2081
1989
|
kmsId: kmsId,
|
|
2082
1990
|
objectId: objectId,
|
|
@@ -2084,16 +1992,16 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2084
1992
|
});
|
|
2085
1993
|
|
|
2086
1994
|
case 20:
|
|
2087
|
-
KMSUrls =
|
|
1995
|
+
KMSUrls = _context22.sent.urls;
|
|
2088
1996
|
i = 0;
|
|
2089
1997
|
|
|
2090
1998
|
case 22:
|
|
2091
1999
|
if (!(i < KMSUrls.length)) {
|
|
2092
|
-
|
|
2000
|
+
_context22.next = 40;
|
|
2093
2001
|
break;
|
|
2094
2002
|
}
|
|
2095
2003
|
|
|
2096
|
-
|
|
2004
|
+
_context22.prev = 23;
|
|
2097
2005
|
this.Log("Making KMS request:\n URL: ".concat(KMSUrls[i], "\n Method: ").concat(methodName, "\n Params: ").concat(params.join(", ")));
|
|
2098
2006
|
kmsUrl = KMSUrls[i];
|
|
2099
2007
|
|
|
@@ -2101,38 +2009,38 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2101
2009
|
this.providers[kmsUrl] = new Ethers.providers.JsonRpcProvider(kmsUrl, this.client.networkId);
|
|
2102
2010
|
}
|
|
2103
2011
|
|
|
2104
|
-
|
|
2012
|
+
_context22.next = 29;
|
|
2105
2013
|
return this.providers[kmsUrl].send(methodName, params);
|
|
2106
2014
|
|
|
2107
2015
|
case 29:
|
|
2108
|
-
return
|
|
2016
|
+
return _context22.abrupt("return", _context22.sent);
|
|
2109
2017
|
|
|
2110
2018
|
case 32:
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
this.Log("KMS Call Error: ".concat(
|
|
2019
|
+
_context22.prev = 32;
|
|
2020
|
+
_context22.t6 = _context22["catch"](23);
|
|
2021
|
+
this.Log("KMS Call Error: ".concat(_context22.t6), true); // If the request has been attempted on all KMS urls, throw the error
|
|
2114
2022
|
|
|
2115
2023
|
if (!(i === KMSUrls.length - 1)) {
|
|
2116
|
-
|
|
2024
|
+
_context22.next = 37;
|
|
2117
2025
|
break;
|
|
2118
2026
|
}
|
|
2119
2027
|
|
|
2120
|
-
throw
|
|
2028
|
+
throw _context22.t6;
|
|
2121
2029
|
|
|
2122
2030
|
case 37:
|
|
2123
2031
|
i++;
|
|
2124
|
-
|
|
2032
|
+
_context22.next = 22;
|
|
2125
2033
|
break;
|
|
2126
2034
|
|
|
2127
2035
|
case 40:
|
|
2128
2036
|
case "end":
|
|
2129
|
-
return
|
|
2037
|
+
return _context22.stop();
|
|
2130
2038
|
}
|
|
2131
2039
|
}
|
|
2132
|
-
},
|
|
2040
|
+
}, _callee22, this, [[23, 32]]);
|
|
2133
2041
|
}));
|
|
2134
2042
|
|
|
2135
|
-
function MakeKMSCall(
|
|
2043
|
+
function MakeKMSCall(_x22) {
|
|
2136
2044
|
return _MakeKMSCall.apply(this, arguments);
|
|
2137
2045
|
}
|
|
2138
2046
|
|
|
@@ -2142,21 +2050,21 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2142
2050
|
}, {
|
|
2143
2051
|
key: "MakeAuthServiceRequest",
|
|
2144
2052
|
value: function () {
|
|
2145
|
-
var _MakeAuthServiceRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
2146
|
-
var kmsId, objectId, versionHash,
|
|
2053
|
+
var _MakeAuthServiceRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref23) {
|
|
2054
|
+
var kmsId, objectId, versionHash, _ref23$method, method, path, bodyType, _ref23$body, body, _ref23$queryParams, queryParams, headers;
|
|
2147
2055
|
|
|
2148
|
-
return _regeneratorRuntime.wrap(function
|
|
2056
|
+
return _regeneratorRuntime.wrap(function _callee23$(_context23) {
|
|
2149
2057
|
while (1) {
|
|
2150
|
-
switch (
|
|
2058
|
+
switch (_context23.prev = _context23.next) {
|
|
2151
2059
|
case 0:
|
|
2152
|
-
kmsId =
|
|
2060
|
+
kmsId = _ref23.kmsId, objectId = _ref23.objectId, versionHash = _ref23.versionHash, _ref23$method = _ref23.method, method = _ref23$method === void 0 ? "GET" : _ref23$method, path = _ref23.path, bodyType = _ref23.bodyType, _ref23$body = _ref23.body, body = _ref23$body === void 0 ? {} : _ref23$body, _ref23$queryParams = _ref23.queryParams, queryParams = _ref23$queryParams === void 0 ? {} : _ref23$queryParams, headers = _ref23.headers;
|
|
2153
2061
|
|
|
2154
2062
|
if (!(this.client.authServiceURIs.length === 0)) {
|
|
2155
|
-
|
|
2063
|
+
_context23.next = 5;
|
|
2156
2064
|
break;
|
|
2157
2065
|
}
|
|
2158
2066
|
|
|
2159
|
-
|
|
2067
|
+
_context23.next = 4;
|
|
2160
2068
|
return this.MakeKMSRequest({
|
|
2161
2069
|
kmsId: kmsId,
|
|
2162
2070
|
objectId: objectId,
|
|
@@ -2170,10 +2078,10 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2170
2078
|
});
|
|
2171
2079
|
|
|
2172
2080
|
case 4:
|
|
2173
|
-
return
|
|
2081
|
+
return _context23.abrupt("return", _context23.sent);
|
|
2174
2082
|
|
|
2175
2083
|
case 5:
|
|
2176
|
-
|
|
2084
|
+
_context23.next = 7;
|
|
2177
2085
|
return this.client.AuthHttpClient.Request({
|
|
2178
2086
|
method: method,
|
|
2179
2087
|
path: path,
|
|
@@ -2184,17 +2092,17 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2184
2092
|
});
|
|
2185
2093
|
|
|
2186
2094
|
case 7:
|
|
2187
|
-
return
|
|
2095
|
+
return _context23.abrupt("return", _context23.sent);
|
|
2188
2096
|
|
|
2189
2097
|
case 8:
|
|
2190
2098
|
case "end":
|
|
2191
|
-
return
|
|
2099
|
+
return _context23.stop();
|
|
2192
2100
|
}
|
|
2193
2101
|
}
|
|
2194
|
-
},
|
|
2102
|
+
}, _callee23, this);
|
|
2195
2103
|
}));
|
|
2196
2104
|
|
|
2197
|
-
function MakeAuthServiceRequest(
|
|
2105
|
+
function MakeAuthServiceRequest(_x23) {
|
|
2198
2106
|
return _MakeAuthServiceRequest.apply(this, arguments);
|
|
2199
2107
|
}
|
|
2200
2108
|
|
|
@@ -2204,36 +2112,36 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2204
2112
|
}, {
|
|
2205
2113
|
key: "MakeKMSRequest",
|
|
2206
2114
|
value: function () {
|
|
2207
|
-
var _MakeKMSRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
2208
|
-
var kmsId, objectId, versionHash,
|
|
2115
|
+
var _MakeKMSRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(_ref24) {
|
|
2116
|
+
var kmsId, objectId, versionHash, _ref24$method, method, path, bodyType, _ref24$body, body, _ref24$queryParams, queryParams, headers, kmsUrls, kmsHttpClient;
|
|
2209
2117
|
|
|
2210
|
-
return _regeneratorRuntime.wrap(function
|
|
2118
|
+
return _regeneratorRuntime.wrap(function _callee24$(_context24) {
|
|
2211
2119
|
while (1) {
|
|
2212
|
-
switch (
|
|
2120
|
+
switch (_context24.prev = _context24.next) {
|
|
2213
2121
|
case 0:
|
|
2214
|
-
kmsId =
|
|
2122
|
+
kmsId = _ref24.kmsId, objectId = _ref24.objectId, versionHash = _ref24.versionHash, _ref24$method = _ref24.method, method = _ref24$method === void 0 ? "GET" : _ref24$method, path = _ref24.path, bodyType = _ref24.bodyType, _ref24$body = _ref24.body, body = _ref24$body === void 0 ? {} : _ref24$body, _ref24$queryParams = _ref24.queryParams, queryParams = _ref24$queryParams === void 0 ? {} : _ref24$queryParams, headers = _ref24.headers;
|
|
2215
2123
|
|
|
2216
2124
|
if (versionHash) {
|
|
2217
2125
|
objectId = Utils.DecodeVersionHash(versionHash).objectId;
|
|
2218
2126
|
}
|
|
2219
2127
|
|
|
2220
2128
|
if (!(!objectId && !kmsId)) {
|
|
2221
|
-
|
|
2129
|
+
_context24.next = 10;
|
|
2222
2130
|
break;
|
|
2223
2131
|
}
|
|
2224
2132
|
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2133
|
+
_context24.t0 = "ikms";
|
|
2134
|
+
_context24.t1 = Utils;
|
|
2135
|
+
_context24.next = 7;
|
|
2228
2136
|
return this.client.DefaultKMSAddress();
|
|
2229
2137
|
|
|
2230
2138
|
case 7:
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
kmsId =
|
|
2139
|
+
_context24.t2 = _context24.sent;
|
|
2140
|
+
_context24.t3 = _context24.t1.AddressToHash.call(_context24.t1, _context24.t2);
|
|
2141
|
+
kmsId = _context24.t0.concat.call(_context24.t0, _context24.t3);
|
|
2234
2142
|
|
|
2235
2143
|
case 10:
|
|
2236
|
-
|
|
2144
|
+
_context24.next = 12;
|
|
2237
2145
|
return this.KMSInfo({
|
|
2238
2146
|
kmsId: kmsId,
|
|
2239
2147
|
objectId: objectId,
|
|
@@ -2241,10 +2149,10 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2241
2149
|
});
|
|
2242
2150
|
|
|
2243
2151
|
case 12:
|
|
2244
|
-
kmsUrls =
|
|
2152
|
+
kmsUrls = _context24.sent.urls;
|
|
2245
2153
|
|
|
2246
2154
|
if (!(!kmsUrls || !kmsUrls[0])) {
|
|
2247
|
-
|
|
2155
|
+
_context24.next = 15;
|
|
2248
2156
|
break;
|
|
2249
2157
|
}
|
|
2250
2158
|
|
|
@@ -2254,7 +2162,7 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2254
2162
|
kmsHttpClient = new HttpClient({
|
|
2255
2163
|
uris: kmsUrls
|
|
2256
2164
|
});
|
|
2257
|
-
|
|
2165
|
+
_context24.next = 18;
|
|
2258
2166
|
return kmsHttpClient.Request({
|
|
2259
2167
|
method: method,
|
|
2260
2168
|
path: path,
|
|
@@ -2265,17 +2173,17 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2265
2173
|
});
|
|
2266
2174
|
|
|
2267
2175
|
case 18:
|
|
2268
|
-
return
|
|
2176
|
+
return _context24.abrupt("return", _context24.sent);
|
|
2269
2177
|
|
|
2270
2178
|
case 19:
|
|
2271
2179
|
case "end":
|
|
2272
|
-
return
|
|
2180
|
+
return _context24.stop();
|
|
2273
2181
|
}
|
|
2274
2182
|
}
|
|
2275
|
-
},
|
|
2183
|
+
}, _callee24, this);
|
|
2276
2184
|
}));
|
|
2277
2185
|
|
|
2278
|
-
function MakeKMSRequest(
|
|
2186
|
+
function MakeKMSRequest(_x24) {
|
|
2279
2187
|
return _MakeKMSRequest.apply(this, arguments);
|
|
2280
2188
|
}
|
|
2281
2189
|
|
|
@@ -2284,39 +2192,39 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2284
2192
|
}, {
|
|
2285
2193
|
key: "ContractHasMethod",
|
|
2286
2194
|
value: function () {
|
|
2287
|
-
var _ContractHasMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
2195
|
+
var _ContractHasMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(_ref25) {
|
|
2288
2196
|
var contractAddress, abi, methodName, key, method, methodSignature, methodId;
|
|
2289
|
-
return _regeneratorRuntime.wrap(function
|
|
2197
|
+
return _regeneratorRuntime.wrap(function _callee25$(_context25) {
|
|
2290
2198
|
while (1) {
|
|
2291
|
-
switch (
|
|
2199
|
+
switch (_context25.prev = _context25.next) {
|
|
2292
2200
|
case 0:
|
|
2293
|
-
contractAddress =
|
|
2201
|
+
contractAddress = _ref25.contractAddress, abi = _ref25.abi, methodName = _ref25.methodName;
|
|
2294
2202
|
contractAddress = Utils.FormatAddress(contractAddress);
|
|
2295
2203
|
key = "".concat(contractAddress, "-").concat(methodName);
|
|
2296
2204
|
|
|
2297
2205
|
if (!(this.methodAvailability[key] === undefined)) {
|
|
2298
|
-
|
|
2206
|
+
_context25.next = 19;
|
|
2299
2207
|
break;
|
|
2300
2208
|
}
|
|
2301
2209
|
|
|
2302
2210
|
this.Log("Checking method availability: ".concat(contractAddress, " ").concat(methodName));
|
|
2303
2211
|
|
|
2304
2212
|
if (abi) {
|
|
2305
|
-
|
|
2213
|
+
_context25.next = 9;
|
|
2306
2214
|
break;
|
|
2307
2215
|
}
|
|
2308
2216
|
|
|
2309
|
-
|
|
2217
|
+
_context25.next = 8;
|
|
2310
2218
|
return this.ContractInfo({
|
|
2311
2219
|
address: contractAddress
|
|
2312
2220
|
});
|
|
2313
2221
|
|
|
2314
2222
|
case 8:
|
|
2315
|
-
abi =
|
|
2223
|
+
abi = _context25.sent.abi;
|
|
2316
2224
|
|
|
2317
2225
|
case 9:
|
|
2318
2226
|
if (abi) {
|
|
2319
|
-
|
|
2227
|
+
_context25.next = 11;
|
|
2320
2228
|
break;
|
|
2321
2229
|
}
|
|
2322
2230
|
|
|
@@ -2328,38 +2236,38 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2328
2236
|
});
|
|
2329
2237
|
|
|
2330
2238
|
if (method) {
|
|
2331
|
-
|
|
2239
|
+
_context25.next = 14;
|
|
2332
2240
|
break;
|
|
2333
2241
|
}
|
|
2334
2242
|
|
|
2335
|
-
return
|
|
2243
|
+
return _context25.abrupt("return", false);
|
|
2336
2244
|
|
|
2337
2245
|
case 14:
|
|
2338
2246
|
methodSignature = "".concat(method.name, "(").concat(method.inputs.map(function (i) {
|
|
2339
2247
|
return i.type;
|
|
2340
2248
|
}).join(","), ")");
|
|
2341
2249
|
methodId = Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(methodSignature)).replace("0x", "").slice(0, 8);
|
|
2342
|
-
|
|
2250
|
+
_context25.next = 18;
|
|
2343
2251
|
return this.MakeElvMasterCall({
|
|
2344
2252
|
methodName: "elv_deployedContractHasMethod",
|
|
2345
2253
|
params: [contractAddress, methodId]
|
|
2346
2254
|
});
|
|
2347
2255
|
|
|
2348
2256
|
case 18:
|
|
2349
|
-
this.methodAvailability[key] =
|
|
2257
|
+
this.methodAvailability[key] = _context25.sent;
|
|
2350
2258
|
|
|
2351
2259
|
case 19:
|
|
2352
|
-
return
|
|
2260
|
+
return _context25.abrupt("return", this.methodAvailability[key]);
|
|
2353
2261
|
|
|
2354
2262
|
case 20:
|
|
2355
2263
|
case "end":
|
|
2356
|
-
return
|
|
2264
|
+
return _context25.stop();
|
|
2357
2265
|
}
|
|
2358
2266
|
}
|
|
2359
|
-
},
|
|
2267
|
+
}, _callee25, this);
|
|
2360
2268
|
}));
|
|
2361
2269
|
|
|
2362
|
-
function ContractHasMethod(
|
|
2270
|
+
function ContractHasMethod(_x25) {
|
|
2363
2271
|
return _ContractHasMethod.apply(this, arguments);
|
|
2364
2272
|
}
|
|
2365
2273
|
|
|
@@ -2368,31 +2276,31 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2368
2276
|
}, {
|
|
2369
2277
|
key: "MakeElvMasterCall",
|
|
2370
2278
|
value: function () {
|
|
2371
|
-
var _MakeElvMasterCall = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
2279
|
+
var _MakeElvMasterCall = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(_ref26) {
|
|
2372
2280
|
var methodName, params;
|
|
2373
|
-
return _regeneratorRuntime.wrap(function
|
|
2281
|
+
return _regeneratorRuntime.wrap(function _callee26$(_context26) {
|
|
2374
2282
|
while (1) {
|
|
2375
|
-
switch (
|
|
2283
|
+
switch (_context26.prev = _context26.next) {
|
|
2376
2284
|
case 0:
|
|
2377
|
-
methodName =
|
|
2378
|
-
|
|
2285
|
+
methodName = _ref26.methodName, params = _ref26.params;
|
|
2286
|
+
_context26.next = 3;
|
|
2379
2287
|
return this.client.ethClient.MakeProviderCall({
|
|
2380
2288
|
methodName: "send",
|
|
2381
2289
|
args: [methodName, params]
|
|
2382
2290
|
});
|
|
2383
2291
|
|
|
2384
2292
|
case 3:
|
|
2385
|
-
return
|
|
2293
|
+
return _context26.abrupt("return", _context26.sent);
|
|
2386
2294
|
|
|
2387
2295
|
case 4:
|
|
2388
2296
|
case "end":
|
|
2389
|
-
return
|
|
2297
|
+
return _context26.stop();
|
|
2390
2298
|
}
|
|
2391
2299
|
}
|
|
2392
|
-
},
|
|
2300
|
+
}, _callee26, this);
|
|
2393
2301
|
}));
|
|
2394
2302
|
|
|
2395
|
-
function MakeElvMasterCall(
|
|
2303
|
+
function MakeElvMasterCall(_x26) {
|
|
2396
2304
|
return _MakeElvMasterCall.apply(this, arguments);
|
|
2397
2305
|
}
|
|
2398
2306
|
|
|
@@ -2401,50 +2309,50 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2401
2309
|
}, {
|
|
2402
2310
|
key: "ReEncryptionConk",
|
|
2403
2311
|
value: function () {
|
|
2404
|
-
var _ReEncryptionConk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
2312
|
+
var _ReEncryptionConk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27(_ref27) {
|
|
2405
2313
|
var libraryId, objectId, versionHash, cap;
|
|
2406
|
-
return _regeneratorRuntime.wrap(function
|
|
2314
|
+
return _regeneratorRuntime.wrap(function _callee27$(_context27) {
|
|
2407
2315
|
while (1) {
|
|
2408
|
-
switch (
|
|
2316
|
+
switch (_context27.prev = _context27.next) {
|
|
2409
2317
|
case 0:
|
|
2410
|
-
libraryId =
|
|
2318
|
+
libraryId = _ref27.libraryId, objectId = _ref27.objectId, versionHash = _ref27.versionHash;
|
|
2411
2319
|
|
|
2412
2320
|
if (versionHash) {
|
|
2413
2321
|
objectId = Utils.DecodeVersionHash(versionHash).objectId;
|
|
2414
2322
|
}
|
|
2415
2323
|
|
|
2416
2324
|
if (this.reencryptionKeys[objectId]) {
|
|
2417
|
-
|
|
2325
|
+
_context27.next = 10;
|
|
2418
2326
|
break;
|
|
2419
2327
|
}
|
|
2420
2328
|
|
|
2421
|
-
|
|
2329
|
+
_context27.next = 5;
|
|
2422
2330
|
return this.client.Crypto.GenerateTargetConk();
|
|
2423
2331
|
|
|
2424
2332
|
case 5:
|
|
2425
|
-
cap =
|
|
2426
|
-
|
|
2333
|
+
cap = _context27.sent;
|
|
2334
|
+
_context27.next = 8;
|
|
2427
2335
|
return this.RetrieveReencryptionSymmetricKey({
|
|
2428
2336
|
libraryId: libraryId,
|
|
2429
2337
|
objectId: objectId
|
|
2430
2338
|
});
|
|
2431
2339
|
|
|
2432
2340
|
case 8:
|
|
2433
|
-
cap.symm_key =
|
|
2341
|
+
cap.symm_key = _context27.sent;
|
|
2434
2342
|
this.reencryptionKeys[objectId] = cap;
|
|
2435
2343
|
|
|
2436
2344
|
case 10:
|
|
2437
|
-
return
|
|
2345
|
+
return _context27.abrupt("return", this.reencryptionKeys[objectId]);
|
|
2438
2346
|
|
|
2439
2347
|
case 11:
|
|
2440
2348
|
case "end":
|
|
2441
|
-
return
|
|
2349
|
+
return _context27.stop();
|
|
2442
2350
|
}
|
|
2443
2351
|
}
|
|
2444
|
-
},
|
|
2352
|
+
}, _callee27, this);
|
|
2445
2353
|
}));
|
|
2446
2354
|
|
|
2447
|
-
function ReEncryptionConk(
|
|
2355
|
+
function ReEncryptionConk(_x27) {
|
|
2448
2356
|
return _ReEncryptionConk.apply(this, arguments);
|
|
2449
2357
|
}
|
|
2450
2358
|
|
|
@@ -2453,70 +2361,70 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2453
2361
|
}, {
|
|
2454
2362
|
key: "EncryptionConk",
|
|
2455
2363
|
value: function () {
|
|
2456
|
-
var _EncryptionConk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
2364
|
+
var _EncryptionConk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28(_ref28) {
|
|
2457
2365
|
var libraryId, objectId, versionHash, conk, _yield$this$client$Cr, secret_key;
|
|
2458
2366
|
|
|
2459
|
-
return _regeneratorRuntime.wrap(function
|
|
2367
|
+
return _regeneratorRuntime.wrap(function _callee28$(_context28) {
|
|
2460
2368
|
while (1) {
|
|
2461
|
-
switch (
|
|
2369
|
+
switch (_context28.prev = _context28.next) {
|
|
2462
2370
|
case 0:
|
|
2463
|
-
libraryId =
|
|
2371
|
+
libraryId = _ref28.libraryId, objectId = _ref28.objectId, versionHash = _ref28.versionHash;
|
|
2464
2372
|
|
|
2465
2373
|
if (versionHash) {
|
|
2466
2374
|
objectId = Utils.DecodeVersionHash(versionHash).objectId;
|
|
2467
2375
|
}
|
|
2468
2376
|
|
|
2469
2377
|
if (libraryId) {
|
|
2470
|
-
|
|
2378
|
+
_context28.next = 6;
|
|
2471
2379
|
break;
|
|
2472
2380
|
}
|
|
2473
2381
|
|
|
2474
|
-
|
|
2382
|
+
_context28.next = 5;
|
|
2475
2383
|
return this.client.ContentObjectLibraryId({
|
|
2476
2384
|
objectId: objectId
|
|
2477
2385
|
});
|
|
2478
2386
|
|
|
2479
2387
|
case 5:
|
|
2480
|
-
libraryId =
|
|
2388
|
+
libraryId = _context28.sent;
|
|
2481
2389
|
|
|
2482
2390
|
case 6:
|
|
2483
2391
|
if (this.encryptionKeys[objectId]) {
|
|
2484
|
-
|
|
2392
|
+
_context28.next = 16;
|
|
2485
2393
|
break;
|
|
2486
2394
|
}
|
|
2487
2395
|
|
|
2488
|
-
|
|
2396
|
+
_context28.next = 9;
|
|
2489
2397
|
return this.RetrieveConk({
|
|
2490
2398
|
libraryId: libraryId,
|
|
2491
2399
|
objectId: objectId
|
|
2492
2400
|
});
|
|
2493
2401
|
|
|
2494
2402
|
case 9:
|
|
2495
|
-
conk =
|
|
2496
|
-
|
|
2403
|
+
conk = _context28.sent;
|
|
2404
|
+
_context28.next = 12;
|
|
2497
2405
|
return this.client.Crypto.GeneratePrimaryConk({
|
|
2498
2406
|
objectId: objectId
|
|
2499
2407
|
});
|
|
2500
2408
|
|
|
2501
2409
|
case 12:
|
|
2502
|
-
_yield$this$client$Cr =
|
|
2410
|
+
_yield$this$client$Cr = _context28.sent;
|
|
2503
2411
|
secret_key = _yield$this$client$Cr.secret_key;
|
|
2504
2412
|
conk.secret_key = secret_key; // { secret_key, public_key, symm_key, block_size }
|
|
2505
2413
|
|
|
2506
2414
|
this.encryptionKeys[objectId] = conk;
|
|
2507
2415
|
|
|
2508
2416
|
case 16:
|
|
2509
|
-
return
|
|
2417
|
+
return _context28.abrupt("return", this.encryptionKeys[objectId]);
|
|
2510
2418
|
|
|
2511
2419
|
case 17:
|
|
2512
2420
|
case "end":
|
|
2513
|
-
return
|
|
2421
|
+
return _context28.stop();
|
|
2514
2422
|
}
|
|
2515
2423
|
}
|
|
2516
|
-
},
|
|
2424
|
+
}, _callee28, this);
|
|
2517
2425
|
}));
|
|
2518
2426
|
|
|
2519
|
-
function EncryptionConk(
|
|
2427
|
+
function EncryptionConk(_x28) {
|
|
2520
2428
|
return _EncryptionConk.apply(this, arguments);
|
|
2521
2429
|
}
|
|
2522
2430
|
|
|
@@ -2525,46 +2433,46 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2525
2433
|
}, {
|
|
2526
2434
|
key: "RecordTags",
|
|
2527
2435
|
value: function () {
|
|
2528
|
-
var _RecordTags = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
2436
|
+
var _RecordTags = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29(_ref29) {
|
|
2529
2437
|
var accessType, libraryId, objectId, versionHash, _yield$this$ContractI8, abi, owner;
|
|
2530
2438
|
|
|
2531
|
-
return _regeneratorRuntime.wrap(function
|
|
2439
|
+
return _regeneratorRuntime.wrap(function _callee29$(_context29) {
|
|
2532
2440
|
while (1) {
|
|
2533
|
-
switch (
|
|
2441
|
+
switch (_context29.prev = _context29.next) {
|
|
2534
2442
|
case 0:
|
|
2535
|
-
accessType =
|
|
2443
|
+
accessType = _ref29.accessType, libraryId = _ref29.libraryId, objectId = _ref29.objectId, versionHash = _ref29.versionHash;
|
|
2536
2444
|
|
|
2537
2445
|
if (!(accessType !== ACCESS_TYPES.OBJECT)) {
|
|
2538
|
-
|
|
2446
|
+
_context29.next = 3;
|
|
2539
2447
|
break;
|
|
2540
2448
|
}
|
|
2541
2449
|
|
|
2542
|
-
return
|
|
2450
|
+
return _context29.abrupt("return");
|
|
2543
2451
|
|
|
2544
2452
|
case 3:
|
|
2545
|
-
|
|
2453
|
+
_context29.next = 5;
|
|
2546
2454
|
return this.ContractInfo({
|
|
2547
2455
|
id: objectId
|
|
2548
2456
|
});
|
|
2549
2457
|
|
|
2550
2458
|
case 5:
|
|
2551
|
-
_yield$this$ContractI8 =
|
|
2459
|
+
_yield$this$ContractI8 = _context29.sent;
|
|
2552
2460
|
abi = _yield$this$ContractI8.abi;
|
|
2553
|
-
|
|
2461
|
+
_context29.next = 9;
|
|
2554
2462
|
return this.Owner({
|
|
2555
2463
|
id: objectId,
|
|
2556
2464
|
abi: abi
|
|
2557
2465
|
});
|
|
2558
2466
|
|
|
2559
2467
|
case 9:
|
|
2560
|
-
owner =
|
|
2468
|
+
owner = _context29.sent;
|
|
2561
2469
|
|
|
2562
2470
|
if (Utils.EqualAddress(owner, this.client.signer.address)) {
|
|
2563
|
-
|
|
2471
|
+
_context29.next = 13;
|
|
2564
2472
|
break;
|
|
2565
2473
|
}
|
|
2566
2474
|
|
|
2567
|
-
|
|
2475
|
+
_context29.next = 13;
|
|
2568
2476
|
return this.client.userProfileClient.RecordTags({
|
|
2569
2477
|
libraryId: libraryId,
|
|
2570
2478
|
objectId: objectId,
|
|
@@ -2573,13 +2481,13 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2573
2481
|
|
|
2574
2482
|
case 13:
|
|
2575
2483
|
case "end":
|
|
2576
|
-
return
|
|
2484
|
+
return _context29.stop();
|
|
2577
2485
|
}
|
|
2578
2486
|
}
|
|
2579
|
-
},
|
|
2487
|
+
}, _callee29, this);
|
|
2580
2488
|
}));
|
|
2581
2489
|
|
|
2582
|
-
function RecordTags(
|
|
2490
|
+
function RecordTags(_x29) {
|
|
2583
2491
|
return _RecordTags.apply(this, arguments);
|
|
2584
2492
|
}
|
|
2585
2493
|
|
|
@@ -2590,34 +2498,34 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2590
2498
|
}, {
|
|
2591
2499
|
key: "CreateAccessGroup",
|
|
2592
2500
|
value: function () {
|
|
2593
|
-
var _CreateAccessGroup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
2501
|
+
var _CreateAccessGroup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30() {
|
|
2594
2502
|
var _yield$this$client$et, contractAddress, transactionHash;
|
|
2595
2503
|
|
|
2596
|
-
return _regeneratorRuntime.wrap(function
|
|
2504
|
+
return _regeneratorRuntime.wrap(function _callee30$(_context30) {
|
|
2597
2505
|
while (1) {
|
|
2598
|
-
switch (
|
|
2506
|
+
switch (_context30.prev = _context30.next) {
|
|
2599
2507
|
case 0:
|
|
2600
|
-
|
|
2508
|
+
_context30.next = 2;
|
|
2601
2509
|
return this.client.ethClient.DeployAccessGroupContract({
|
|
2602
2510
|
contentSpaceAddress: Utils.HashToAddress(this.contentSpaceId),
|
|
2603
2511
|
signer: this.client.signer
|
|
2604
2512
|
});
|
|
2605
2513
|
|
|
2606
2514
|
case 2:
|
|
2607
|
-
_yield$this$client$et =
|
|
2515
|
+
_yield$this$client$et = _context30.sent;
|
|
2608
2516
|
contractAddress = _yield$this$client$et.contractAddress;
|
|
2609
2517
|
transactionHash = _yield$this$client$et.transactionHash;
|
|
2610
|
-
return
|
|
2518
|
+
return _context30.abrupt("return", {
|
|
2611
2519
|
contractAddress: contractAddress,
|
|
2612
2520
|
transactionHash: transactionHash
|
|
2613
2521
|
});
|
|
2614
2522
|
|
|
2615
2523
|
case 6:
|
|
2616
2524
|
case "end":
|
|
2617
|
-
return
|
|
2525
|
+
return _context30.stop();
|
|
2618
2526
|
}
|
|
2619
2527
|
}
|
|
2620
|
-
},
|
|
2528
|
+
}, _callee30, this);
|
|
2621
2529
|
}));
|
|
2622
2530
|
|
|
2623
2531
|
function CreateAccessGroup() {
|
|
@@ -2629,34 +2537,34 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2629
2537
|
}, {
|
|
2630
2538
|
key: "CreateContentType",
|
|
2631
2539
|
value: function () {
|
|
2632
|
-
var _CreateContentType = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
2540
|
+
var _CreateContentType = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee31() {
|
|
2633
2541
|
var _yield$this$client$et2, contractAddress, transactionHash;
|
|
2634
2542
|
|
|
2635
|
-
return _regeneratorRuntime.wrap(function
|
|
2543
|
+
return _regeneratorRuntime.wrap(function _callee31$(_context31) {
|
|
2636
2544
|
while (1) {
|
|
2637
|
-
switch (
|
|
2545
|
+
switch (_context31.prev = _context31.next) {
|
|
2638
2546
|
case 0:
|
|
2639
|
-
|
|
2547
|
+
_context31.next = 2;
|
|
2640
2548
|
return this.client.ethClient.DeployTypeContract({
|
|
2641
2549
|
contentSpaceAddress: Utils.HashToAddress(this.contentSpaceId),
|
|
2642
2550
|
signer: this.client.signer
|
|
2643
2551
|
});
|
|
2644
2552
|
|
|
2645
2553
|
case 2:
|
|
2646
|
-
_yield$this$client$et2 =
|
|
2554
|
+
_yield$this$client$et2 = _context31.sent;
|
|
2647
2555
|
contractAddress = _yield$this$client$et2.contractAddress;
|
|
2648
2556
|
transactionHash = _yield$this$client$et2.transactionHash;
|
|
2649
|
-
return
|
|
2557
|
+
return _context31.abrupt("return", {
|
|
2650
2558
|
contractAddress: contractAddress,
|
|
2651
2559
|
transactionHash: transactionHash
|
|
2652
2560
|
});
|
|
2653
2561
|
|
|
2654
2562
|
case 6:
|
|
2655
2563
|
case "end":
|
|
2656
|
-
return
|
|
2564
|
+
return _context31.stop();
|
|
2657
2565
|
}
|
|
2658
2566
|
}
|
|
2659
|
-
},
|
|
2567
|
+
}, _callee31, this);
|
|
2660
2568
|
}));
|
|
2661
2569
|
|
|
2662
2570
|
function CreateContentType() {
|
|
@@ -2668,15 +2576,15 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2668
2576
|
}, {
|
|
2669
2577
|
key: "CreateContentLibrary",
|
|
2670
2578
|
value: function () {
|
|
2671
|
-
var _CreateContentLibrary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
2579
|
+
var _CreateContentLibrary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee32(_ref30) {
|
|
2672
2580
|
var kmsId, _yield$this$client$et3, contractAddress, transactionHash;
|
|
2673
2581
|
|
|
2674
|
-
return _regeneratorRuntime.wrap(function
|
|
2582
|
+
return _regeneratorRuntime.wrap(function _callee32$(_context32) {
|
|
2675
2583
|
while (1) {
|
|
2676
|
-
switch (
|
|
2584
|
+
switch (_context32.prev = _context32.next) {
|
|
2677
2585
|
case 0:
|
|
2678
|
-
kmsId =
|
|
2679
|
-
|
|
2586
|
+
kmsId = _ref30.kmsId;
|
|
2587
|
+
_context32.next = 3;
|
|
2680
2588
|
return this.client.ethClient.DeployLibraryContract({
|
|
2681
2589
|
contentSpaceAddress: Utils.HashToAddress(this.contentSpaceId),
|
|
2682
2590
|
kmsId: kmsId,
|
|
@@ -2684,23 +2592,23 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2684
2592
|
});
|
|
2685
2593
|
|
|
2686
2594
|
case 3:
|
|
2687
|
-
_yield$this$client$et3 =
|
|
2595
|
+
_yield$this$client$et3 = _context32.sent;
|
|
2688
2596
|
contractAddress = _yield$this$client$et3.contractAddress;
|
|
2689
2597
|
transactionHash = _yield$this$client$et3.transactionHash;
|
|
2690
|
-
return
|
|
2598
|
+
return _context32.abrupt("return", {
|
|
2691
2599
|
contractAddress: contractAddress,
|
|
2692
2600
|
transactionHash: transactionHash
|
|
2693
2601
|
});
|
|
2694
2602
|
|
|
2695
2603
|
case 7:
|
|
2696
2604
|
case "end":
|
|
2697
|
-
return
|
|
2605
|
+
return _context32.stop();
|
|
2698
2606
|
}
|
|
2699
2607
|
}
|
|
2700
|
-
},
|
|
2608
|
+
}, _callee32, this);
|
|
2701
2609
|
}));
|
|
2702
2610
|
|
|
2703
|
-
function CreateContentLibrary(
|
|
2611
|
+
function CreateContentLibrary(_x30) {
|
|
2704
2612
|
return _CreateContentLibrary.apply(this, arguments);
|
|
2705
2613
|
}
|
|
2706
2614
|
|
|
@@ -2709,15 +2617,15 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2709
2617
|
}, {
|
|
2710
2618
|
key: "CreateContentObject",
|
|
2711
2619
|
value: function () {
|
|
2712
|
-
var _CreateContentObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
2620
|
+
var _CreateContentObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee33(_ref31) {
|
|
2713
2621
|
var libraryId, typeId, _yield$this$client$et4, contractAddress, transactionHash;
|
|
2714
2622
|
|
|
2715
|
-
return _regeneratorRuntime.wrap(function
|
|
2623
|
+
return _regeneratorRuntime.wrap(function _callee33$(_context33) {
|
|
2716
2624
|
while (1) {
|
|
2717
|
-
switch (
|
|
2625
|
+
switch (_context33.prev = _context33.next) {
|
|
2718
2626
|
case 0:
|
|
2719
|
-
libraryId =
|
|
2720
|
-
|
|
2627
|
+
libraryId = _ref31.libraryId, typeId = _ref31.typeId;
|
|
2628
|
+
_context33.next = 3;
|
|
2721
2629
|
return this.client.ethClient.DeployContentContract({
|
|
2722
2630
|
contentLibraryAddress: Utils.HashToAddress(libraryId),
|
|
2723
2631
|
typeAddress: typeId ? Utils.HashToAddress(typeId) : Utils.nullAddress,
|
|
@@ -2725,23 +2633,23 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
2725
2633
|
});
|
|
2726
2634
|
|
|
2727
2635
|
case 3:
|
|
2728
|
-
_yield$this$client$et4 =
|
|
2636
|
+
_yield$this$client$et4 = _context33.sent;
|
|
2729
2637
|
contractAddress = _yield$this$client$et4.contractAddress;
|
|
2730
2638
|
transactionHash = _yield$this$client$et4.transactionHash;
|
|
2731
|
-
return
|
|
2639
|
+
return _context33.abrupt("return", {
|
|
2732
2640
|
contractAddress: contractAddress,
|
|
2733
2641
|
transactionHash: transactionHash
|
|
2734
2642
|
});
|
|
2735
2643
|
|
|
2736
2644
|
case 7:
|
|
2737
2645
|
case "end":
|
|
2738
|
-
return
|
|
2646
|
+
return _context33.stop();
|
|
2739
2647
|
}
|
|
2740
2648
|
}
|
|
2741
|
-
},
|
|
2649
|
+
}, _callee33, this);
|
|
2742
2650
|
}));
|
|
2743
2651
|
|
|
2744
|
-
function CreateContentObject(
|
|
2652
|
+
function CreateContentObject(_x31) {
|
|
2745
2653
|
return _CreateContentObject.apply(this, arguments);
|
|
2746
2654
|
}
|
|
2747
2655
|
|