@eluvio/elv-client-js 4.0.134 → 4.0.136
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 +15 -14
- package/dist/ElvClient-node-min.js +14 -13
- package/dist/ElvFrameClient-min.js +10 -10
- package/dist/ElvPermissionsClient-min.js +9 -9
- package/dist/ElvWalletClient-min.js +15 -14
- package/dist/ElvWalletClient-node-min.js +14 -13
- package/dist/src/AuthorizationClient.js +9 -12
- package/dist/src/ContentObjectAudit.js +3 -3
- package/dist/src/ContentObjectVerification.js +3 -3
- package/dist/src/Crypto.js +2 -2
- package/dist/src/ElvClient.js +522 -397
- package/dist/src/ElvWallet.js +7 -5
- package/dist/src/EthClient.js +8 -9
- package/dist/src/FrameClient.js +9 -10
- package/dist/src/HttpClient.js +5 -5
- package/dist/src/Id.js +1 -2
- package/dist/src/PermissionsClient.js +31 -19
- package/dist/src/RemoteSigner.js +10 -11
- package/dist/src/UserProfileClient.js +35 -20
- package/dist/src/Utils.js +2 -3
- package/dist/src/client/ABRPublishing.js +342 -196
- package/dist/src/client/AccessGroups.js +2 -2
- package/dist/src/client/ContentAccess.js +8 -12
- package/dist/src/client/ContentManagement.js +99 -83
- package/dist/src/client/Contracts.js +2 -2
- package/dist/src/client/Files.js +2 -2
- package/dist/src/client/LiveConf.js +43 -26
- package/dist/src/client/LiveStream.js +65 -63
- package/dist/src/client/NFT.js +2 -2
- package/dist/src/client/Shares.js +47 -24
- package/dist/src/walletClient/ClientMethods.js +2 -2
- package/dist/src/walletClient/Profile.js +2 -2
- package/dist/src/walletClient/Utils.js +2 -2
- package/dist/src/walletClient/index.js +65 -50
- package/package.json +2 -2
- package/src/ElvClient.js +67 -3
- package/src/FrameClient.js +2 -1
- package/src/client/ABRPublishing.js +215 -83
- package/src/client/ContentManagement.js +7 -6
- package/src/client/LiveConf.js +13 -9
- package/src/client/LiveStream.js +8 -3
- package/src/walletClient/index.js +1 -1
- package/utilities/FrontEndSimpleIngest.js +198 -0
- package/utilities/ProductionMasterCreate.js +9 -2
- package/utilities/SampleIngest.js +225 -0
- package/utilities/SampleIngestWithMaster.js +226 -0
- package/utilities/lib/concerns/ArgLibraryId.js +1 -1
- package/utilities/lib/concerns/ArgTenant.js +23 -0
- package/utilities/lib/concerns/ContentType.js +1 -1
- package/utilities/lib/concerns/Finalize.js +12 -7
- package/utilities/lib/concerns/LRO.js +3 -3
- package/utilities/lib/concerns/Tenant.js +47 -0
package/dist/src/ElvClient.js
CHANGED
|
@@ -5,8 +5,8 @@ var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
|
5
5
|
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
6
6
|
var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
|
|
7
7
|
var _createClass = require("@babel/runtime/helpers/createClass");
|
|
8
|
-
function ownKeys(
|
|
9
|
-
function _objectSpread(
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
10
|
if (typeof globalThis.Buffer === "undefined") {
|
|
11
11
|
globalThis.Buffer = require("buffer/").Buffer;
|
|
12
12
|
}
|
|
@@ -24,7 +24,8 @@ var _require = require("./LogMessage"),
|
|
|
24
24
|
LogMessage = _require.LogMessage;
|
|
25
25
|
var Pako = require("pako");
|
|
26
26
|
var _require2 = require("./Validation"),
|
|
27
|
-
ValidatePresence = _require2.ValidatePresence
|
|
27
|
+
ValidatePresence = _require2.ValidatePresence,
|
|
28
|
+
ValidateWriteToken = _require2.ValidateWriteToken;
|
|
28
29
|
var UrlJoin = require("url-join");
|
|
29
30
|
var networks = {
|
|
30
31
|
"main": "https://main.net955305.contentfabric.io",
|
|
@@ -142,7 +143,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
142
143
|
* @param {string=} clientIP - IP address to use in determining the region to use
|
|
143
144
|
* @return {Promise<Object>} - Object containing content space ID and fabric and ethereum URLs
|
|
144
145
|
*/
|
|
145
|
-
_createClass(ElvClient, [{
|
|
146
|
+
return _createClass(ElvClient, [{
|
|
146
147
|
key: "Log",
|
|
147
148
|
value: function Log(message) {
|
|
148
149
|
var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -341,7 +342,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
341
342
|
*/
|
|
342
343
|
}, {
|
|
343
344
|
key: "UseRegion",
|
|
344
|
-
value: function () {
|
|
345
|
+
value: (function () {
|
|
345
346
|
var _UseRegion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref4) {
|
|
346
347
|
var region, _yield$ElvClient$Conf, fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs;
|
|
347
348
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
@@ -401,9 +402,10 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
401
402
|
*
|
|
402
403
|
* @return {Promise<Object>} - An object containing the updated fabric and ethereum URLs in order of preference
|
|
403
404
|
*/
|
|
405
|
+
)
|
|
404
406
|
}, {
|
|
405
407
|
key: "ResetRegion",
|
|
406
|
-
value: function () {
|
|
408
|
+
value: (function () {
|
|
407
409
|
var _ResetRegion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
408
410
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
409
411
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -443,9 +445,10 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
443
445
|
*
|
|
444
446
|
* @return {Promise<string>} - The node ID reported by the fabric
|
|
445
447
|
*/
|
|
448
|
+
)
|
|
446
449
|
}, {
|
|
447
450
|
key: "NodeId",
|
|
448
|
-
value: function () {
|
|
451
|
+
value: (function () {
|
|
449
452
|
var _NodeId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref5) {
|
|
450
453
|
var region, _yield$ElvClient$Conf2, nodeId;
|
|
451
454
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
@@ -479,6 +482,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
479
482
|
*
|
|
480
483
|
* @return {Promise<Object>} - An object containing the lists of fabric, ethereum, auth service, and search urls in use by the client
|
|
481
484
|
*/
|
|
485
|
+
)
|
|
482
486
|
}, {
|
|
483
487
|
key: "Nodes",
|
|
484
488
|
value: function Nodes() {
|
|
@@ -545,25 +549,29 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
545
549
|
* @namedParams
|
|
546
550
|
* @param {string=} matchEndpoint - Return node(s) matching the specified endpoint
|
|
547
551
|
* @param {string=} matchNodeId - Return node(s) matching the specified node ID
|
|
552
|
+
* @param {string=} matchWriteToken - Return node(s) matching the specified write token
|
|
548
553
|
*
|
|
549
554
|
* @return {Promise<Array<Object>>} - A list of nodes in the space matching the parameters
|
|
550
555
|
*/
|
|
551
556
|
}, {
|
|
552
557
|
key: "SpaceNodes",
|
|
553
|
-
value: function () {
|
|
558
|
+
value: (function () {
|
|
554
559
|
var _SpaceNodes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
|
555
560
|
var _this = this;
|
|
556
561
|
var _ref7,
|
|
557
562
|
matchEndpoint,
|
|
558
563
|
matchNodeId,
|
|
564
|
+
matchWriteToken,
|
|
559
565
|
nodes,
|
|
560
566
|
_yield$this$utils$Res,
|
|
561
567
|
node,
|
|
568
|
+
_yield$this$utils$Res2,
|
|
569
|
+
_nodes,
|
|
562
570
|
_args6 = arguments;
|
|
563
571
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
564
572
|
while (1) switch (_context6.prev = _context6.next) {
|
|
565
573
|
case 0:
|
|
566
|
-
_ref7 = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {}, matchEndpoint = _ref7.matchEndpoint, matchNodeId = _ref7.matchNodeId;
|
|
574
|
+
_ref7 = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {}, matchEndpoint = _ref7.matchEndpoint, matchNodeId = _ref7.matchNodeId, matchWriteToken = _ref7.matchWriteToken;
|
|
567
575
|
this.SetStaticToken();
|
|
568
576
|
if (!matchEndpoint) {
|
|
569
577
|
_context6.next = 12;
|
|
@@ -604,7 +612,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
604
612
|
}));
|
|
605
613
|
case 12:
|
|
606
614
|
if (!matchNodeId) {
|
|
607
|
-
_context6.next =
|
|
615
|
+
_context6.next = 21;
|
|
608
616
|
break;
|
|
609
617
|
}
|
|
610
618
|
this.SetStaticToken();
|
|
@@ -620,7 +628,29 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
620
628
|
node = _context6.sent;
|
|
621
629
|
this.ClearStaticToken();
|
|
622
630
|
return _context6.abrupt("return", [node]);
|
|
623
|
-
case
|
|
631
|
+
case 21:
|
|
632
|
+
if (!matchWriteToken) {
|
|
633
|
+
_context6.next = 29;
|
|
634
|
+
break;
|
|
635
|
+
}
|
|
636
|
+
this.SetStaticToken();
|
|
637
|
+
_context6.next = 25;
|
|
638
|
+
return this.utils.ResponseToJson(this.HttpClient.Request({
|
|
639
|
+
path: UrlJoin("nodes"),
|
|
640
|
+
method: "GET",
|
|
641
|
+
headers: {
|
|
642
|
+
Authorization: "Bearer ".concat(this.staticToken)
|
|
643
|
+
},
|
|
644
|
+
queryParams: {
|
|
645
|
+
token: matchWriteToken
|
|
646
|
+
}
|
|
647
|
+
}));
|
|
648
|
+
case 25:
|
|
649
|
+
_yield$this$utils$Res2 = _context6.sent;
|
|
650
|
+
_nodes = _yield$this$utils$Res2.nodes;
|
|
651
|
+
this.ClearStaticToken();
|
|
652
|
+
return _context6.abrupt("return", _nodes);
|
|
653
|
+
case 29:
|
|
624
654
|
case "end":
|
|
625
655
|
return _context6.stop();
|
|
626
656
|
}
|
|
@@ -637,6 +667,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
637
667
|
* @methodGroup Nodes
|
|
638
668
|
* @returns {Object} - The name, ID and configuration URL of the network
|
|
639
669
|
*/
|
|
670
|
+
)
|
|
640
671
|
}, {
|
|
641
672
|
key: "NetworkInfo",
|
|
642
673
|
value: function NetworkInfo() {
|
|
@@ -646,18 +677,75 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
646
677
|
configUrl: this.configUrl
|
|
647
678
|
};
|
|
648
679
|
}
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Return node url for a given write token via a network call
|
|
683
|
+
*
|
|
684
|
+
* @methodGroup Nodes
|
|
685
|
+
* @namedParams
|
|
686
|
+
* @param {string} writeToken - The write token to match to a node
|
|
687
|
+
*
|
|
688
|
+
* @returns {Promise<string>} - The node url for a write token
|
|
689
|
+
*/
|
|
690
|
+
}, {
|
|
691
|
+
key: "WriteTokenNodeUrlNetwork",
|
|
692
|
+
value: (function () {
|
|
693
|
+
var _WriteTokenNodeUrlNetwork = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref8) {
|
|
694
|
+
var writeToken, nodes, nodeUrl;
|
|
695
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
696
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
697
|
+
case 0:
|
|
698
|
+
writeToken = _ref8.writeToken;
|
|
699
|
+
ValidateWriteToken(writeToken);
|
|
700
|
+
_context7.next = 4;
|
|
701
|
+
return this.SpaceNodes({
|
|
702
|
+
matchWriteToken: writeToken
|
|
703
|
+
});
|
|
704
|
+
case 4:
|
|
705
|
+
nodes = _context7.sent;
|
|
706
|
+
nodeUrl = nodes && nodes[0] && nodes[0].services && nodes[0].services.fabric_api && nodes[0].services.fabric_api.urls && nodes[0].services.fabric_api.urls[0];
|
|
707
|
+
if (nodeUrl) {
|
|
708
|
+
_context7.next = 9;
|
|
709
|
+
break;
|
|
710
|
+
}
|
|
711
|
+
console.error("No node url found for write token: ".concat(writeToken));
|
|
712
|
+
return _context7.abrupt("return", "");
|
|
713
|
+
case 9:
|
|
714
|
+
return _context7.abrupt("return", nodeUrl ? nodeUrl.toString() : undefined);
|
|
715
|
+
case 10:
|
|
716
|
+
case "end":
|
|
717
|
+
return _context7.stop();
|
|
718
|
+
}
|
|
719
|
+
}, _callee7, this);
|
|
720
|
+
}));
|
|
721
|
+
function WriteTokenNodeUrlNetwork(_x3) {
|
|
722
|
+
return _WriteTokenNodeUrlNetwork.apply(this, arguments);
|
|
723
|
+
}
|
|
724
|
+
return WriteTokenNodeUrlNetwork;
|
|
725
|
+
}()
|
|
726
|
+
/**
|
|
727
|
+
* Return node url for a given write token via local lookup
|
|
728
|
+
*
|
|
729
|
+
* @methodGroup Nodes
|
|
730
|
+
* @namedParams
|
|
731
|
+
* @param {string} writeToken - The write token to match to a node
|
|
732
|
+
*
|
|
733
|
+
* @returns {string} - The node url for a write token
|
|
734
|
+
*/
|
|
735
|
+
)
|
|
649
736
|
}, {
|
|
650
|
-
key: "
|
|
651
|
-
value: function
|
|
652
|
-
var writeToken =
|
|
737
|
+
key: "WriteTokenNodeUrlLocal",
|
|
738
|
+
value: function WriteTokenNodeUrlLocal(_ref9) {
|
|
739
|
+
var writeToken = _ref9.writeToken;
|
|
740
|
+
ValidateWriteToken(writeToken);
|
|
653
741
|
var nodeUrl = this.HttpClient.draftURIs[writeToken];
|
|
654
742
|
return nodeUrl ? nodeUrl.toString() : undefined;
|
|
655
743
|
}
|
|
656
744
|
}, {
|
|
657
745
|
key: "RecordWriteToken",
|
|
658
|
-
value: function RecordWriteToken(
|
|
659
|
-
var writeToken =
|
|
660
|
-
fabricNodeUrl =
|
|
746
|
+
value: function RecordWriteToken(_ref10) {
|
|
747
|
+
var writeToken = _ref10.writeToken,
|
|
748
|
+
fabricNodeUrl = _ref10.fabricNodeUrl;
|
|
661
749
|
this.HttpClient.RecordWriteToken(writeToken, fabricNodeUrl);
|
|
662
750
|
}
|
|
663
751
|
|
|
@@ -707,18 +795,14 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
707
795
|
*/
|
|
708
796
|
}, {
|
|
709
797
|
key: "SetSigner",
|
|
710
|
-
value: function SetSigner(
|
|
711
|
-
var
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
reset = _ref10$reset === void 0 ? true : _ref10$reset;
|
|
798
|
+
value: function SetSigner(_ref11) {
|
|
799
|
+
var signer = _ref11.signer,
|
|
800
|
+
_ref11$reset = _ref11.reset,
|
|
801
|
+
reset = _ref11$reset === void 0 ? true : _ref11$reset;
|
|
715
802
|
this.staticToken = undefined;
|
|
716
803
|
signer.connect(this.ethClient.Provider());
|
|
717
804
|
signer.provider.pollingInterval = 500;
|
|
718
805
|
this.signer = signer;
|
|
719
|
-
this.CreateFabricToken({}).then(function (token) {
|
|
720
|
-
return _this2.signedToken = token;
|
|
721
|
-
});
|
|
722
806
|
if (reset) {
|
|
723
807
|
this.InitializeClients();
|
|
724
808
|
}
|
|
@@ -738,35 +822,35 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
738
822
|
*/
|
|
739
823
|
}, {
|
|
740
824
|
key: "SetRemoteSigner",
|
|
741
|
-
value: function () {
|
|
742
|
-
var _SetRemoteSigner = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
825
|
+
value: (function () {
|
|
826
|
+
var _SetRemoteSigner = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref12) {
|
|
743
827
|
var idToken, authToken, tenantId, extraData, signerURIs, unsignedPublicAuth, signer;
|
|
744
|
-
return _regeneratorRuntime.wrap(function
|
|
745
|
-
while (1) switch (
|
|
828
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
829
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
746
830
|
case 0:
|
|
747
|
-
idToken =
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
831
|
+
idToken = _ref12.idToken, authToken = _ref12.authToken, tenantId = _ref12.tenantId, extraData = _ref12.extraData, signerURIs = _ref12.signerURIs, unsignedPublicAuth = _ref12.unsignedPublicAuth;
|
|
832
|
+
_context8.t0 = RemoteSigner;
|
|
833
|
+
_context8.t1 = signerURIs || this.authServiceURIs;
|
|
834
|
+
_context8.t2 = idToken;
|
|
835
|
+
_context8.t3 = authToken;
|
|
836
|
+
_context8.t4 = tenantId;
|
|
837
|
+
_context8.next = 8;
|
|
754
838
|
return this.ethClient.Provider();
|
|
755
839
|
case 8:
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
signerURIs:
|
|
761
|
-
idToken:
|
|
762
|
-
authToken:
|
|
763
|
-
tenantId:
|
|
764
|
-
provider:
|
|
765
|
-
extraData:
|
|
766
|
-
unsignedPublicAuth:
|
|
840
|
+
_context8.t5 = _context8.sent;
|
|
841
|
+
_context8.t6 = extraData;
|
|
842
|
+
_context8.t7 = unsignedPublicAuth;
|
|
843
|
+
_context8.t8 = {
|
|
844
|
+
signerURIs: _context8.t1,
|
|
845
|
+
idToken: _context8.t2,
|
|
846
|
+
authToken: _context8.t3,
|
|
847
|
+
tenantId: _context8.t4,
|
|
848
|
+
provider: _context8.t5,
|
|
849
|
+
extraData: _context8.t6,
|
|
850
|
+
unsignedPublicAuth: _context8.t7
|
|
767
851
|
};
|
|
768
|
-
signer = new
|
|
769
|
-
|
|
852
|
+
signer = new _context8.t0(_context8.t8);
|
|
853
|
+
_context8.next = 15;
|
|
770
854
|
return signer.Initialize();
|
|
771
855
|
case 15:
|
|
772
856
|
this.SetSigner({
|
|
@@ -774,11 +858,11 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
774
858
|
});
|
|
775
859
|
case 16:
|
|
776
860
|
case "end":
|
|
777
|
-
return
|
|
861
|
+
return _context8.stop();
|
|
778
862
|
}
|
|
779
|
-
},
|
|
863
|
+
}, _callee8, this);
|
|
780
864
|
}));
|
|
781
|
-
function SetRemoteSigner(
|
|
865
|
+
function SetRemoteSigner(_x4) {
|
|
782
866
|
return _SetRemoteSigner.apply(this, arguments);
|
|
783
867
|
}
|
|
784
868
|
return SetRemoteSigner;
|
|
@@ -793,32 +877,33 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
793
877
|
* @namedParams
|
|
794
878
|
* @param {object} provider - The web3 provider object
|
|
795
879
|
*/
|
|
880
|
+
)
|
|
796
881
|
}, {
|
|
797
882
|
key: "SetSignerFromWeb3Provider",
|
|
798
|
-
value: function () {
|
|
799
|
-
var _SetSignerFromWeb3Provider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
883
|
+
value: (function () {
|
|
884
|
+
var _SetSignerFromWeb3Provider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref13) {
|
|
800
885
|
var provider, ethProvider;
|
|
801
|
-
return _regeneratorRuntime.wrap(function
|
|
802
|
-
while (1) switch (
|
|
886
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
887
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
803
888
|
case 0:
|
|
804
|
-
provider =
|
|
889
|
+
provider = _ref13.provider;
|
|
805
890
|
this.staticToken = undefined;
|
|
806
891
|
ethProvider = new Ethers.providers.Web3Provider(provider);
|
|
807
892
|
ethProvider.pollingInterval = 250;
|
|
808
893
|
this.signer = ethProvider.getSigner();
|
|
809
|
-
|
|
894
|
+
_context9.next = 7;
|
|
810
895
|
return this.signer.getAddress();
|
|
811
896
|
case 7:
|
|
812
|
-
this.signer.address =
|
|
813
|
-
|
|
897
|
+
this.signer.address = _context9.sent;
|
|
898
|
+
_context9.next = 10;
|
|
814
899
|
return this.InitializeClients();
|
|
815
900
|
case 10:
|
|
816
901
|
case "end":
|
|
817
|
-
return
|
|
902
|
+
return _context9.stop();
|
|
818
903
|
}
|
|
819
|
-
},
|
|
904
|
+
}, _callee9, this);
|
|
820
905
|
}));
|
|
821
|
-
function SetSignerFromWeb3Provider(
|
|
906
|
+
function SetSignerFromWeb3Provider(_x5) {
|
|
822
907
|
return _SetSignerFromWeb3Provider.apply(this, arguments);
|
|
823
908
|
}
|
|
824
909
|
return SetSignerFromWeb3Provider;
|
|
@@ -838,15 +923,16 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
838
923
|
*
|
|
839
924
|
* @return {string} - The address of the user
|
|
840
925
|
*/
|
|
926
|
+
)
|
|
841
927
|
}, {
|
|
842
928
|
key: "CreateAccount",
|
|
843
|
-
value: function () {
|
|
844
|
-
var _CreateAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
845
|
-
var tenantId, fundingToken,
|
|
846
|
-
return _regeneratorRuntime.wrap(function
|
|
847
|
-
while (1) switch (
|
|
929
|
+
value: (function () {
|
|
930
|
+
var _CreateAccount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref14) {
|
|
931
|
+
var tenantId, fundingToken, _ref14$funds, funds, groupToken, wallet, signer;
|
|
932
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
933
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
848
934
|
case 0:
|
|
849
|
-
tenantId =
|
|
935
|
+
tenantId = _ref14.tenantId, fundingToken = _ref14.fundingToken, _ref14$funds = _ref14.funds, funds = _ref14$funds === void 0 ? 0.5 : _ref14$funds, groupToken = _ref14.groupToken;
|
|
850
936
|
if (!this.signer) {
|
|
851
937
|
wallet = this.GenerateWallet();
|
|
852
938
|
signer = wallet.AddAccountFromMnemonic({
|
|
@@ -856,7 +942,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
856
942
|
signer: signer
|
|
857
943
|
});
|
|
858
944
|
}
|
|
859
|
-
|
|
945
|
+
_context10.next = 4;
|
|
860
946
|
return this.authClient.MakeKMSRequest({
|
|
861
947
|
method: "POST",
|
|
862
948
|
path: "/ks/otp/fnd/".concat(tenantId),
|
|
@@ -869,20 +955,20 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
869
955
|
}
|
|
870
956
|
});
|
|
871
957
|
case 4:
|
|
872
|
-
|
|
958
|
+
_context10.next = 6;
|
|
873
959
|
return this.userProfileClient.CreateWallet();
|
|
874
960
|
case 6:
|
|
875
|
-
|
|
961
|
+
_context10.next = 8;
|
|
876
962
|
return this.userProfileClient.ReplaceUserMetadata({
|
|
877
963
|
metadataSubtree: "tenantContractId",
|
|
878
964
|
metadata: tenantId
|
|
879
965
|
});
|
|
880
966
|
case 8:
|
|
881
967
|
if (!groupToken) {
|
|
882
|
-
|
|
968
|
+
_context10.next = 11;
|
|
883
969
|
break;
|
|
884
970
|
}
|
|
885
|
-
|
|
971
|
+
_context10.next = 11;
|
|
886
972
|
return this.authClient.MakeKMSRequest({
|
|
887
973
|
method: "POST",
|
|
888
974
|
path: "/ks/otp/grp/".concat(tenantId),
|
|
@@ -894,14 +980,14 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
894
980
|
}
|
|
895
981
|
});
|
|
896
982
|
case 11:
|
|
897
|
-
return
|
|
983
|
+
return _context10.abrupt("return", this.utils.FormatAddress(this.signer.address));
|
|
898
984
|
case 12:
|
|
899
985
|
case "end":
|
|
900
|
-
return
|
|
986
|
+
return _context10.stop();
|
|
901
987
|
}
|
|
902
|
-
},
|
|
988
|
+
}, _callee10, this);
|
|
903
989
|
}));
|
|
904
|
-
function CreateAccount(
|
|
990
|
+
function CreateAccount(_x6) {
|
|
905
991
|
return _CreateAccount.apply(this, arguments);
|
|
906
992
|
}
|
|
907
993
|
return CreateAccount;
|
|
@@ -915,67 +1001,68 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
915
1001
|
PAYLOAD 85b json-compressed
|
|
916
1002
|
json 79b {"adr":"VVf4DQU357tDnZGYQeDrntRJ5rs=","spc":"ispc3ANoVSzNA3P6t7abLR69ho5YPPZU"}
|
|
917
1003
|
*/
|
|
1004
|
+
)
|
|
918
1005
|
}, {
|
|
919
1006
|
key: "PersonalSign",
|
|
920
|
-
value: function () {
|
|
921
|
-
var _PersonalSign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
922
|
-
var
|
|
1007
|
+
value: (function () {
|
|
1008
|
+
var _PersonalSign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref15) {
|
|
1009
|
+
var _this2 = this;
|
|
923
1010
|
var message, addEthereumPrefix, Sign;
|
|
924
|
-
return _regeneratorRuntime.wrap(function
|
|
925
|
-
while (1) switch (
|
|
1011
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
1012
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
926
1013
|
case 0:
|
|
927
|
-
message =
|
|
1014
|
+
message = _ref15.message, addEthereumPrefix = _ref15.addEthereumPrefix, Sign = _ref15.Sign;
|
|
928
1015
|
if (!Sign) {
|
|
929
1016
|
// Same as authClient.Sign, but authClient may not yet be initialized
|
|
930
1017
|
Sign = /*#__PURE__*/function () {
|
|
931
|
-
var
|
|
932
|
-
return _regeneratorRuntime.wrap(function
|
|
933
|
-
while (1) switch (
|
|
1018
|
+
var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(message) {
|
|
1019
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
1020
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
934
1021
|
case 0:
|
|
935
|
-
|
|
936
|
-
if (!
|
|
937
|
-
|
|
1022
|
+
_context11.t0 = Ethers.utils;
|
|
1023
|
+
if (!_this2.signer.signDigest) {
|
|
1024
|
+
_context11.next = 7;
|
|
938
1025
|
break;
|
|
939
1026
|
}
|
|
940
|
-
|
|
941
|
-
return
|
|
1027
|
+
_context11.next = 4;
|
|
1028
|
+
return _this2.signer.signDigest(message);
|
|
942
1029
|
case 4:
|
|
943
|
-
|
|
944
|
-
|
|
1030
|
+
_context11.t1 = _context11.sent;
|
|
1031
|
+
_context11.next = 10;
|
|
945
1032
|
break;
|
|
946
1033
|
case 7:
|
|
947
|
-
|
|
948
|
-
return
|
|
1034
|
+
_context11.next = 9;
|
|
1035
|
+
return _this2.signer._signingKey().signDigest(message);
|
|
949
1036
|
case 9:
|
|
950
|
-
|
|
1037
|
+
_context11.t1 = _context11.sent;
|
|
951
1038
|
case 10:
|
|
952
|
-
|
|
953
|
-
return
|
|
1039
|
+
_context11.t2 = _context11.t1;
|
|
1040
|
+
return _context11.abrupt("return", _context11.t0.joinSignature.call(_context11.t0, _context11.t2));
|
|
954
1041
|
case 12:
|
|
955
1042
|
case "end":
|
|
956
|
-
return
|
|
1043
|
+
return _context11.stop();
|
|
957
1044
|
}
|
|
958
|
-
},
|
|
1045
|
+
}, _callee11);
|
|
959
1046
|
}));
|
|
960
|
-
return function Sign(
|
|
961
|
-
return
|
|
1047
|
+
return function Sign(_x8) {
|
|
1048
|
+
return _ref16.apply(this, arguments);
|
|
962
1049
|
};
|
|
963
1050
|
}();
|
|
964
1051
|
}
|
|
965
1052
|
if (addEthereumPrefix) {
|
|
966
1053
|
message = Ethers.utils.keccak256(Buffer.from("\x19Ethereum Signed Message:\n".concat(message.length).concat(message), "utf-8"));
|
|
967
1054
|
}
|
|
968
|
-
|
|
1055
|
+
_context12.next = 5;
|
|
969
1056
|
return Sign(message);
|
|
970
1057
|
case 5:
|
|
971
|
-
return
|
|
1058
|
+
return _context12.abrupt("return", _context12.sent);
|
|
972
1059
|
case 6:
|
|
973
1060
|
case "end":
|
|
974
|
-
return
|
|
1061
|
+
return _context12.stop();
|
|
975
1062
|
}
|
|
976
|
-
},
|
|
1063
|
+
}, _callee12);
|
|
977
1064
|
}));
|
|
978
|
-
function PersonalSign(
|
|
1065
|
+
function PersonalSign(_x7) {
|
|
979
1066
|
return _PersonalSign.apply(this, arguments);
|
|
980
1067
|
}
|
|
981
1068
|
return PersonalSign;
|
|
@@ -991,68 +1078,69 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
991
1078
|
* @param {function=} Sign - If specified, this function will be used to produce the signature instead of the client's current signer
|
|
992
1079
|
* @param {boolean=} addEthereumPrefix=true - If specified, the 'Ethereum Signed Message' prefixed hash format will be performed. Disable this if the provided Sign method already does this (e.g. Metamask)
|
|
993
1080
|
*/
|
|
1081
|
+
)
|
|
994
1082
|
}, {
|
|
995
1083
|
key: "CreateFabricToken",
|
|
996
|
-
value: function () {
|
|
997
|
-
var _CreateFabricToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
998
|
-
var
|
|
999
|
-
|
|
1084
|
+
value: (function () {
|
|
1085
|
+
var _CreateFabricToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
|
|
1086
|
+
var _ref17,
|
|
1087
|
+
_ref17$duration,
|
|
1000
1088
|
duration,
|
|
1001
|
-
|
|
1089
|
+
_ref17$spec,
|
|
1002
1090
|
spec,
|
|
1003
1091
|
address,
|
|
1004
1092
|
Sign,
|
|
1005
|
-
|
|
1093
|
+
_ref17$addEthereumPre,
|
|
1006
1094
|
addEthereumPrefix,
|
|
1007
|
-
|
|
1095
|
+
_ref17$context,
|
|
1008
1096
|
context,
|
|
1009
1097
|
token,
|
|
1010
1098
|
message,
|
|
1011
1099
|
signature,
|
|
1012
1100
|
compressedToken,
|
|
1013
|
-
|
|
1014
|
-
return _regeneratorRuntime.wrap(function
|
|
1015
|
-
while (1) switch (
|
|
1101
|
+
_args13 = arguments;
|
|
1102
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
1103
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1016
1104
|
case 0:
|
|
1017
|
-
|
|
1105
|
+
_ref17 = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {}, _ref17$duration = _ref17.duration, duration = _ref17$duration === void 0 ? 24 * 60 * 60 * 1000 : _ref17$duration, _ref17$spec = _ref17.spec, spec = _ref17$spec === void 0 ? {} : _ref17$spec, address = _ref17.address, Sign = _ref17.Sign, _ref17$addEthereumPre = _ref17.addEthereumPrefix, addEthereumPrefix = _ref17$addEthereumPre === void 0 ? true : _ref17$addEthereumPre, _ref17$context = _ref17.context, context = _ref17$context === void 0 ? {} : _ref17$context;
|
|
1018
1106
|
address = address || this.CurrentAccountAddress();
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1107
|
+
_context13.t0 = _objectSpread;
|
|
1108
|
+
_context13.t1 = _objectSpread({}, spec);
|
|
1109
|
+
_context13.t2 = {};
|
|
1110
|
+
_context13.t3 = "iusr".concat(Utils.AddressToHash(address));
|
|
1111
|
+
_context13.t4 = Buffer.from(address.replace(/^0x/, ""), "hex").toString("base64");
|
|
1112
|
+
_context13.next = 9;
|
|
1025
1113
|
return this.ContentSpaceId();
|
|
1026
1114
|
case 9:
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
sub:
|
|
1033
|
-
adr:
|
|
1034
|
-
spc:
|
|
1035
|
-
iat:
|
|
1036
|
-
exp:
|
|
1037
|
-
ctx:
|
|
1115
|
+
_context13.t5 = _context13.sent;
|
|
1116
|
+
_context13.t6 = Date.now();
|
|
1117
|
+
_context13.t7 = Date.now() + duration;
|
|
1118
|
+
_context13.t8 = context;
|
|
1119
|
+
_context13.t9 = {
|
|
1120
|
+
sub: _context13.t3,
|
|
1121
|
+
adr: _context13.t4,
|
|
1122
|
+
spc: _context13.t5,
|
|
1123
|
+
iat: _context13.t6,
|
|
1124
|
+
exp: _context13.t7,
|
|
1125
|
+
ctx: _context13.t8
|
|
1038
1126
|
};
|
|
1039
|
-
token = (0,
|
|
1127
|
+
token = (0, _context13.t0)(_context13.t1, _context13.t2, _context13.t9);
|
|
1040
1128
|
message = "Eluvio Content Fabric Access Token 1.0\n".concat(JSON.stringify(token));
|
|
1041
|
-
|
|
1129
|
+
_context13.next = 18;
|
|
1042
1130
|
return this.PersonalSign({
|
|
1043
1131
|
message: message,
|
|
1044
1132
|
addEthereumPrefix: addEthereumPrefix,
|
|
1045
1133
|
Sign: Sign
|
|
1046
1134
|
});
|
|
1047
1135
|
case 18:
|
|
1048
|
-
signature =
|
|
1136
|
+
signature = _context13.sent;
|
|
1049
1137
|
compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
|
|
1050
|
-
return
|
|
1138
|
+
return _context13.abrupt("return", "acspjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
|
|
1051
1139
|
case 21:
|
|
1052
1140
|
case "end":
|
|
1053
|
-
return
|
|
1141
|
+
return _context13.stop();
|
|
1054
1142
|
}
|
|
1055
|
-
},
|
|
1143
|
+
}, _callee13, this);
|
|
1056
1144
|
}));
|
|
1057
1145
|
function CreateFabricToken() {
|
|
1058
1146
|
return _CreateFabricToken.apply(this, arguments);
|
|
@@ -1074,107 +1162,133 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1074
1162
|
* @param {boolean} allowDecryption=false - If specified, the re-encryption key will be included in the token,
|
|
1075
1163
|
* enabling the user of this token to download encrypted content from the specified object
|
|
1076
1164
|
* @param {Object=} context - Additional JSON context
|
|
1165
|
+
* @param {number=} issueTime - Issue Time in milliseconds
|
|
1166
|
+
* @param {number=} expirationTime - Expiration Time in milliseconds
|
|
1077
1167
|
*/
|
|
1168
|
+
)
|
|
1078
1169
|
}, {
|
|
1079
1170
|
key: "CreateSignedToken",
|
|
1080
|
-
value: function () {
|
|
1081
|
-
var _CreateSignedToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1082
|
-
var libraryId, objectId, versionHash, policyId, subject,
|
|
1083
|
-
return _regeneratorRuntime.wrap(function
|
|
1084
|
-
while (1) switch (
|
|
1171
|
+
value: (function () {
|
|
1172
|
+
var _CreateSignedToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref18) {
|
|
1173
|
+
var libraryId, objectId, versionHash, policyId, subject, _ref18$grantType, grantType, _ref18$allowDecryptio, allowDecryption, duration, _ref18$context, context, issueTime, expirationTime, issueDateTime, token, cap, compressedToken, signature;
|
|
1174
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
1175
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1085
1176
|
case 0:
|
|
1086
|
-
libraryId =
|
|
1177
|
+
libraryId = _ref18.libraryId, objectId = _ref18.objectId, versionHash = _ref18.versionHash, policyId = _ref18.policyId, subject = _ref18.subject, _ref18$grantType = _ref18.grantType, grantType = _ref18$grantType === void 0 ? "read" : _ref18$grantType, _ref18$allowDecryptio = _ref18.allowDecryption, allowDecryption = _ref18$allowDecryptio === void 0 ? false : _ref18$allowDecryptio, duration = _ref18.duration, _ref18$context = _ref18.context, context = _ref18$context === void 0 ? {} : _ref18$context, issueTime = _ref18.issueTime, expirationTime = _ref18.expirationTime;
|
|
1087
1178
|
if (subject) {
|
|
1088
|
-
|
|
1179
|
+
_context14.next = 9;
|
|
1089
1180
|
break;
|
|
1090
1181
|
}
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1182
|
+
_context14.t0 = "iusr";
|
|
1183
|
+
_context14.t1 = this.utils;
|
|
1184
|
+
_context14.next = 6;
|
|
1094
1185
|
return this.CurrentAccountAddress();
|
|
1095
1186
|
case 6:
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
subject =
|
|
1187
|
+
_context14.t2 = _context14.sent;
|
|
1188
|
+
_context14.t3 = _context14.t1.AddressToHash.call(_context14.t1, _context14.t2);
|
|
1189
|
+
subject = _context14.t0.concat.call(_context14.t0, _context14.t3);
|
|
1099
1190
|
case 9:
|
|
1100
1191
|
if (policyId) {
|
|
1101
1192
|
context["elv:delegation-id"] = policyId;
|
|
1102
1193
|
}
|
|
1103
|
-
|
|
1104
|
-
|
|
1194
|
+
issueDateTime = issueTime || Date.now();
|
|
1195
|
+
_context14.t4 = Buffer;
|
|
1196
|
+
_context14.next = 14;
|
|
1105
1197
|
return this.CurrentAccountAddress().replace(/^0x/, "");
|
|
1106
|
-
case
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1198
|
+
case 14:
|
|
1199
|
+
_context14.t5 = _context14.sent;
|
|
1200
|
+
_context14.t6 = _context14.t4.from.call(_context14.t4, _context14.t5, "hex").toString("base64");
|
|
1201
|
+
_context14.t7 = subject;
|
|
1202
|
+
_context14.next = 19;
|
|
1111
1203
|
return this.ContentSpaceId();
|
|
1112
|
-
case
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1204
|
+
case 19:
|
|
1205
|
+
_context14.t8 = _context14.sent;
|
|
1206
|
+
_context14.t9 = issueDateTime;
|
|
1207
|
+
_context14.t10 = expirationTime || issueDateTime + duration;
|
|
1208
|
+
_context14.t11 = grantType;
|
|
1209
|
+
_context14.t12 = context;
|
|
1118
1210
|
token = {
|
|
1119
|
-
adr:
|
|
1120
|
-
sub:
|
|
1121
|
-
spc:
|
|
1122
|
-
iat:
|
|
1123
|
-
exp:
|
|
1124
|
-
gra:
|
|
1125
|
-
ctx:
|
|
1211
|
+
adr: _context14.t6,
|
|
1212
|
+
sub: _context14.t7,
|
|
1213
|
+
spc: _context14.t8,
|
|
1214
|
+
iat: _context14.t9,
|
|
1215
|
+
exp: _context14.t10,
|
|
1216
|
+
gra: _context14.t11,
|
|
1217
|
+
ctx: _context14.t12
|
|
1126
1218
|
};
|
|
1127
1219
|
if (versionHash) {
|
|
1128
1220
|
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1129
1221
|
}
|
|
1130
1222
|
if (!objectId) {
|
|
1131
|
-
|
|
1223
|
+
_context14.next = 32;
|
|
1132
1224
|
break;
|
|
1133
1225
|
}
|
|
1134
1226
|
token.qid = objectId;
|
|
1135
1227
|
if (libraryId) {
|
|
1136
|
-
|
|
1228
|
+
_context14.next = 32;
|
|
1137
1229
|
break;
|
|
1138
1230
|
}
|
|
1139
|
-
|
|
1231
|
+
_context14.next = 31;
|
|
1140
1232
|
return this.ContentObjectLibraryId({
|
|
1141
1233
|
objectId: objectId
|
|
1142
1234
|
});
|
|
1143
|
-
case 30:
|
|
1144
|
-
libraryId = _context13.sent;
|
|
1145
1235
|
case 31:
|
|
1236
|
+
libraryId = _context14.sent;
|
|
1237
|
+
case 32:
|
|
1146
1238
|
if (libraryId) {
|
|
1147
1239
|
token.lib = libraryId;
|
|
1148
1240
|
}
|
|
1149
1241
|
if (!allowDecryption) {
|
|
1150
|
-
|
|
1242
|
+
_context14.next = 38;
|
|
1151
1243
|
break;
|
|
1152
1244
|
}
|
|
1153
|
-
|
|
1245
|
+
_context14.next = 36;
|
|
1154
1246
|
return this.authClient.ReEncryptionConk({
|
|
1155
1247
|
libraryId: libraryId,
|
|
1156
1248
|
objectId: objectId
|
|
1157
1249
|
});
|
|
1158
|
-
case
|
|
1159
|
-
cap =
|
|
1250
|
+
case 36:
|
|
1251
|
+
cap = _context14.sent;
|
|
1160
1252
|
token.apk = cap.public_key;
|
|
1161
|
-
case
|
|
1253
|
+
case 38:
|
|
1162
1254
|
compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
|
|
1163
|
-
|
|
1255
|
+
_context14.next = 41;
|
|
1164
1256
|
return this.authClient.Sign(Ethers.utils.keccak256(compressedToken));
|
|
1165
|
-
case
|
|
1166
|
-
signature =
|
|
1167
|
-
return
|
|
1168
|
-
case
|
|
1257
|
+
case 41:
|
|
1258
|
+
signature = _context14.sent;
|
|
1259
|
+
return _context14.abrupt("return", "aessjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
|
|
1260
|
+
case 43:
|
|
1169
1261
|
case "end":
|
|
1170
|
-
return
|
|
1262
|
+
return _context14.stop();
|
|
1171
1263
|
}
|
|
1172
|
-
},
|
|
1264
|
+
}, _callee14, this);
|
|
1173
1265
|
}));
|
|
1174
|
-
function CreateSignedToken(
|
|
1266
|
+
function CreateSignedToken(_x9) {
|
|
1175
1267
|
return _CreateSignedToken.apply(this, arguments);
|
|
1176
1268
|
}
|
|
1177
1269
|
return CreateSignedToken;
|
|
1270
|
+
}())
|
|
1271
|
+
}, {
|
|
1272
|
+
key: "CreateAuthorizationToken",
|
|
1273
|
+
value: function () {
|
|
1274
|
+
var _CreateAuthorizationToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(args) {
|
|
1275
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
1276
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1277
|
+
case 0:
|
|
1278
|
+
_context15.next = 2;
|
|
1279
|
+
return this.authClient.AuthorizationToken(args);
|
|
1280
|
+
case 2:
|
|
1281
|
+
return _context15.abrupt("return", _context15.sent);
|
|
1282
|
+
case 3:
|
|
1283
|
+
case "end":
|
|
1284
|
+
return _context15.stop();
|
|
1285
|
+
}
|
|
1286
|
+
}, _callee15, this);
|
|
1287
|
+
}));
|
|
1288
|
+
function CreateAuthorizationToken(_x10) {
|
|
1289
|
+
return _CreateAuthorizationToken.apply(this, arguments);
|
|
1290
|
+
}
|
|
1291
|
+
return CreateAuthorizationToken;
|
|
1178
1292
|
}()
|
|
1179
1293
|
/**
|
|
1180
1294
|
* Build a signed message (JSON) using the current signer.
|
|
@@ -1192,31 +1306,31 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1192
1306
|
*/
|
|
1193
1307
|
}, {
|
|
1194
1308
|
key: "CreateSignedMessageJSON",
|
|
1195
|
-
value: function () {
|
|
1196
|
-
var _CreateSignedMessageJSON = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1309
|
+
value: (function () {
|
|
1310
|
+
var _CreateSignedMessageJSON = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref19) {
|
|
1197
1311
|
var message, type, msg, signature;
|
|
1198
|
-
return _regeneratorRuntime.wrap(function
|
|
1199
|
-
while (1) switch (
|
|
1312
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
1313
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1200
1314
|
case 0:
|
|
1201
|
-
message =
|
|
1315
|
+
message = _ref19.message;
|
|
1202
1316
|
// Only one kind of signature supported currently
|
|
1203
1317
|
type = "mje_"; // JSON message, EIP192 signature
|
|
1204
1318
|
msg = JSON.stringify(message);
|
|
1205
|
-
|
|
1319
|
+
_context16.next = 5;
|
|
1206
1320
|
return this.PersonalSign({
|
|
1207
1321
|
message: msg,
|
|
1208
1322
|
addEthereumPrefix: true
|
|
1209
1323
|
});
|
|
1210
1324
|
case 5:
|
|
1211
|
-
signature =
|
|
1212
|
-
return
|
|
1325
|
+
signature = _context16.sent;
|
|
1326
|
+
return _context16.abrupt("return", "".concat(type).concat(Utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(msg)]))));
|
|
1213
1327
|
case 7:
|
|
1214
1328
|
case "end":
|
|
1215
|
-
return
|
|
1329
|
+
return _context16.stop();
|
|
1216
1330
|
}
|
|
1217
|
-
},
|
|
1331
|
+
}, _callee16, this);
|
|
1218
1332
|
}));
|
|
1219
|
-
function CreateSignedMessageJSON(
|
|
1333
|
+
function CreateSignedMessageJSON(_x11) {
|
|
1220
1334
|
return _CreateSignedMessageJSON.apply(this, arguments);
|
|
1221
1335
|
}
|
|
1222
1336
|
return CreateSignedMessageJSON;
|
|
@@ -1229,18 +1343,19 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1229
1343
|
* @param {string} signedMessage - a signed message as created by CreateSignedMessageJSON
|
|
1230
1344
|
* @returns {Promise<Object>} - The decoded message, signer address, signature and signature type
|
|
1231
1345
|
*/
|
|
1346
|
+
)
|
|
1232
1347
|
}, {
|
|
1233
1348
|
key: "DecodeSignedMessageJSON",
|
|
1234
|
-
value: function () {
|
|
1235
|
-
var _DecodeSignedMessageJSON = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1349
|
+
value: (function () {
|
|
1350
|
+
var _DecodeSignedMessageJSON = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref20) {
|
|
1236
1351
|
var signedMessage, type, msgBytes, signature, msg, obj, prefixedMsgHash, signerAddr;
|
|
1237
|
-
return _regeneratorRuntime.wrap(function
|
|
1238
|
-
while (1) switch (
|
|
1352
|
+
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
1353
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1239
1354
|
case 0:
|
|
1240
|
-
signedMessage =
|
|
1355
|
+
signedMessage = _ref20.signedMessage;
|
|
1241
1356
|
type = signedMessage.slice(0, 4);
|
|
1242
|
-
|
|
1243
|
-
|
|
1357
|
+
_context17.t0 = type;
|
|
1358
|
+
_context17.next = _context17.t0 === "mje_" ? 5 : 12;
|
|
1244
1359
|
break;
|
|
1245
1360
|
case 5:
|
|
1246
1361
|
msgBytes = Utils.FromB58(signedMessage.slice(4));
|
|
@@ -1249,7 +1364,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1249
1364
|
obj = JSON.parse(msg);
|
|
1250
1365
|
prefixedMsgHash = Ethers.utils.keccak256(Buffer.from("\x19Ethereum Signed Message:\n".concat(msg.length).concat(msg), "utf-8"));
|
|
1251
1366
|
signerAddr = Ethers.utils.recoverAddress(prefixedMsgHash, signature);
|
|
1252
|
-
return
|
|
1367
|
+
return _context17.abrupt("return", {
|
|
1253
1368
|
type: type,
|
|
1254
1369
|
message: obj,
|
|
1255
1370
|
signerAddress: signerAddr,
|
|
@@ -1259,11 +1374,11 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1259
1374
|
throw new Error("Bad message type: ".concat(type));
|
|
1260
1375
|
case 13:
|
|
1261
1376
|
case "end":
|
|
1262
|
-
return
|
|
1377
|
+
return _context17.stop();
|
|
1263
1378
|
}
|
|
1264
|
-
},
|
|
1379
|
+
}, _callee17);
|
|
1265
1380
|
}));
|
|
1266
|
-
function DecodeSignedMessageJSON(
|
|
1381
|
+
function DecodeSignedMessageJSON(_x12) {
|
|
1267
1382
|
return _DecodeSignedMessageJSON.apply(this, arguments);
|
|
1268
1383
|
}
|
|
1269
1384
|
return DecodeSignedMessageJSON;
|
|
@@ -1274,6 +1389,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1274
1389
|
* @methodGroup Signers
|
|
1275
1390
|
* @returns {string} - The address of the current signer
|
|
1276
1391
|
*/
|
|
1392
|
+
)
|
|
1277
1393
|
}, {
|
|
1278
1394
|
key: "CurrentAccountAddress",
|
|
1279
1395
|
value: function CurrentAccountAddress() {
|
|
@@ -1289,13 +1405,13 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1289
1405
|
*/
|
|
1290
1406
|
}, {
|
|
1291
1407
|
key: "SetOauthToken",
|
|
1292
|
-
value: function () {
|
|
1293
|
-
var _SetOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1408
|
+
value: (function () {
|
|
1409
|
+
var _SetOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref21) {
|
|
1294
1410
|
var token, wallet, signer;
|
|
1295
|
-
return _regeneratorRuntime.wrap(function
|
|
1296
|
-
while (1) switch (
|
|
1411
|
+
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
1412
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1297
1413
|
case 0:
|
|
1298
|
-
token =
|
|
1414
|
+
token = _ref21.token;
|
|
1299
1415
|
this.oauthToken = token;
|
|
1300
1416
|
wallet = this.GenerateWallet();
|
|
1301
1417
|
signer = wallet.AddAccountFromMnemonic({
|
|
@@ -1306,11 +1422,11 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1306
1422
|
});
|
|
1307
1423
|
case 5:
|
|
1308
1424
|
case "end":
|
|
1309
|
-
return
|
|
1425
|
+
return _context18.stop();
|
|
1310
1426
|
}
|
|
1311
|
-
},
|
|
1427
|
+
}, _callee18, this);
|
|
1312
1428
|
}));
|
|
1313
|
-
function SetOauthToken(
|
|
1429
|
+
function SetOauthToken(_x13) {
|
|
1314
1430
|
return _SetOauthToken.apply(this, arguments);
|
|
1315
1431
|
}
|
|
1316
1432
|
return SetOauthToken;
|
|
@@ -1325,47 +1441,48 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1325
1441
|
* @namedParams
|
|
1326
1442
|
* @param {string} token - The OAuth ID
|
|
1327
1443
|
*/
|
|
1444
|
+
)
|
|
1328
1445
|
}, {
|
|
1329
1446
|
key: "SetSignerFromOauthToken",
|
|
1330
|
-
value: function () {
|
|
1331
|
-
var _SetSignerFromOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1447
|
+
value: (function () {
|
|
1448
|
+
var _SetSignerFromOauthToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(_ref22) {
|
|
1332
1449
|
var token, wallet, client, _yield$client$authCli, urls, path, httpClient, response, privateKey;
|
|
1333
|
-
return _regeneratorRuntime.wrap(function
|
|
1334
|
-
while (1) switch (
|
|
1450
|
+
return _regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
1451
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1335
1452
|
case 0:
|
|
1336
|
-
token =
|
|
1453
|
+
token = _ref22.token;
|
|
1337
1454
|
if (this.trustAuthorityId) {
|
|
1338
|
-
|
|
1455
|
+
_context19.next = 3;
|
|
1339
1456
|
break;
|
|
1340
1457
|
}
|
|
1341
1458
|
throw Error("Unable to authorize with OAuth token: No trust authority ID set");
|
|
1342
1459
|
case 3:
|
|
1343
1460
|
wallet = this.GenerateWallet();
|
|
1344
|
-
|
|
1461
|
+
_context19.prev = 4;
|
|
1345
1462
|
if (this.kmsURIs) {
|
|
1346
|
-
|
|
1463
|
+
_context19.next = 17;
|
|
1347
1464
|
break;
|
|
1348
1465
|
}
|
|
1349
|
-
|
|
1466
|
+
_context19.next = 8;
|
|
1350
1467
|
return ElvClient.FromConfigurationUrl({
|
|
1351
1468
|
configUrl: this.configUrl
|
|
1352
1469
|
});
|
|
1353
1470
|
case 8:
|
|
1354
|
-
client =
|
|
1471
|
+
client = _context19.sent;
|
|
1355
1472
|
client.SetSigner({
|
|
1356
1473
|
signer: wallet.AddAccountFromMnemonic({
|
|
1357
1474
|
mnemonic: wallet.GenerateMnemonic()
|
|
1358
1475
|
})
|
|
1359
1476
|
});
|
|
1360
|
-
|
|
1477
|
+
_context19.next = 12;
|
|
1361
1478
|
return client.authClient.KMSInfo({
|
|
1362
1479
|
kmsId: this.trustAuthorityId
|
|
1363
1480
|
});
|
|
1364
1481
|
case 12:
|
|
1365
|
-
_yield$client$authCli =
|
|
1482
|
+
_yield$client$authCli = _context19.sent;
|
|
1366
1483
|
urls = _yield$client$authCli.urls;
|
|
1367
1484
|
if (!(!urls || urls.length === 0)) {
|
|
1368
|
-
|
|
1485
|
+
_context19.next = 16;
|
|
1369
1486
|
break;
|
|
1370
1487
|
}
|
|
1371
1488
|
throw Error("Unable to authorize with OAuth token: No KMS URLs set");
|
|
@@ -1378,7 +1495,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1378
1495
|
uris: this.kmsURIs,
|
|
1379
1496
|
debug: this.debug
|
|
1380
1497
|
});
|
|
1381
|
-
|
|
1498
|
+
_context19.next = 22;
|
|
1382
1499
|
return this.utils.ResponseToJson(httpClient.Request({
|
|
1383
1500
|
headers: {
|
|
1384
1501
|
Authorization: "Bearer ".concat(token)
|
|
@@ -1388,7 +1505,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1388
1505
|
forceFailover: true
|
|
1389
1506
|
}));
|
|
1390
1507
|
case 22:
|
|
1391
|
-
response =
|
|
1508
|
+
response = _context19.sent;
|
|
1392
1509
|
privateKey = response["UserSKHex"];
|
|
1393
1510
|
this.SetSigner({
|
|
1394
1511
|
signer: wallet.AddAccount({
|
|
@@ -1397,27 +1514,27 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1397
1514
|
});
|
|
1398
1515
|
|
|
1399
1516
|
// Ensure wallet is initialized
|
|
1400
|
-
|
|
1517
|
+
_context19.next = 27;
|
|
1401
1518
|
return this.userProfileClient.WalletAddress();
|
|
1402
1519
|
case 27:
|
|
1403
|
-
|
|
1520
|
+
_context19.next = 36;
|
|
1404
1521
|
break;
|
|
1405
1522
|
case 29:
|
|
1406
|
-
|
|
1407
|
-
|
|
1523
|
+
_context19.prev = 29;
|
|
1524
|
+
_context19.t0 = _context19["catch"](4);
|
|
1408
1525
|
this.Log("Failed to set signer from OAuth token:", true);
|
|
1409
|
-
this.Log(
|
|
1410
|
-
|
|
1526
|
+
this.Log(_context19.t0, true);
|
|
1527
|
+
_context19.next = 35;
|
|
1411
1528
|
return this.ClearSigner();
|
|
1412
1529
|
case 35:
|
|
1413
|
-
throw
|
|
1530
|
+
throw _context19.t0;
|
|
1414
1531
|
case 36:
|
|
1415
1532
|
case "end":
|
|
1416
|
-
return
|
|
1533
|
+
return _context19.stop();
|
|
1417
1534
|
}
|
|
1418
|
-
},
|
|
1535
|
+
}, _callee19, this, [[4, 29]]);
|
|
1419
1536
|
}));
|
|
1420
|
-
function SetSignerFromOauthToken(
|
|
1537
|
+
function SetSignerFromOauthToken(_x14) {
|
|
1421
1538
|
return _SetSignerFromOauthToken.apply(this, arguments);
|
|
1422
1539
|
}
|
|
1423
1540
|
return SetSignerFromOauthToken;
|
|
@@ -1431,10 +1548,11 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1431
1548
|
*
|
|
1432
1549
|
* @return {string} - The created static token
|
|
1433
1550
|
*/
|
|
1551
|
+
)
|
|
1434
1552
|
}, {
|
|
1435
1553
|
key: "CreateStaticToken",
|
|
1436
|
-
value: function CreateStaticToken(
|
|
1437
|
-
var libraryId =
|
|
1554
|
+
value: function CreateStaticToken(_ref23) {
|
|
1555
|
+
var libraryId = _ref23.libraryId;
|
|
1438
1556
|
var token = {
|
|
1439
1557
|
qspace_id: this.client.contentSpaceId
|
|
1440
1558
|
};
|
|
@@ -1455,10 +1573,10 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1455
1573
|
}, {
|
|
1456
1574
|
key: "SetStaticToken",
|
|
1457
1575
|
value: function SetStaticToken() {
|
|
1458
|
-
var
|
|
1459
|
-
token =
|
|
1460
|
-
|
|
1461
|
-
update =
|
|
1576
|
+
var _ref24 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1577
|
+
token = _ref24.token,
|
|
1578
|
+
_ref24$update = _ref24.update,
|
|
1579
|
+
update = _ref24$update === void 0 ? false : _ref24$update;
|
|
1462
1580
|
if (token) {
|
|
1463
1581
|
this.staticToken = token;
|
|
1464
1582
|
} else {
|
|
@@ -1489,31 +1607,31 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1489
1607
|
*/
|
|
1490
1608
|
}, {
|
|
1491
1609
|
key: "SetPolicyAuthorization",
|
|
1492
|
-
value: function () {
|
|
1493
|
-
var _SetPolicyAuthorization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1610
|
+
value: (function () {
|
|
1611
|
+
var _SetPolicyAuthorization = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(_ref25) {
|
|
1494
1612
|
var objectId;
|
|
1495
|
-
return _regeneratorRuntime.wrap(function
|
|
1496
|
-
while (1) switch (
|
|
1613
|
+
return _regeneratorRuntime.wrap(function _callee20$(_context20) {
|
|
1614
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1497
1615
|
case 0:
|
|
1498
|
-
objectId =
|
|
1499
|
-
|
|
1500
|
-
|
|
1616
|
+
objectId = _ref25.objectId;
|
|
1617
|
+
_context20.t0 = this;
|
|
1618
|
+
_context20.next = 4;
|
|
1501
1619
|
return this.GenerateStateChannelToken({
|
|
1502
1620
|
objectId: objectId
|
|
1503
1621
|
});
|
|
1504
1622
|
case 4:
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
token:
|
|
1623
|
+
_context20.t1 = _context20.sent;
|
|
1624
|
+
_context20.t2 = {
|
|
1625
|
+
token: _context20.t1
|
|
1508
1626
|
};
|
|
1509
|
-
|
|
1627
|
+
_context20.t0.SetStaticToken.call(_context20.t0, _context20.t2);
|
|
1510
1628
|
case 7:
|
|
1511
1629
|
case "end":
|
|
1512
|
-
return
|
|
1630
|
+
return _context20.stop();
|
|
1513
1631
|
}
|
|
1514
|
-
},
|
|
1632
|
+
}, _callee20, this);
|
|
1515
1633
|
}));
|
|
1516
|
-
function SetPolicyAuthorization(
|
|
1634
|
+
function SetPolicyAuthorization(_x15) {
|
|
1517
1635
|
return _SetPolicyAuthorization.apply(this, arguments);
|
|
1518
1636
|
}
|
|
1519
1637
|
return SetPolicyAuthorization;
|
|
@@ -1524,26 +1642,27 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1524
1642
|
* @param {string} string - The string to sign
|
|
1525
1643
|
* @return {Promise<string>} - The signed string
|
|
1526
1644
|
*/
|
|
1645
|
+
)
|
|
1527
1646
|
}, {
|
|
1528
1647
|
key: "Sign",
|
|
1529
|
-
value: function () {
|
|
1530
|
-
var _Sign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1648
|
+
value: (function () {
|
|
1649
|
+
var _Sign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(string) {
|
|
1531
1650
|
var signature;
|
|
1532
|
-
return _regeneratorRuntime.wrap(function
|
|
1533
|
-
while (1) switch (
|
|
1651
|
+
return _regeneratorRuntime.wrap(function _callee21$(_context21) {
|
|
1652
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1534
1653
|
case 0:
|
|
1535
|
-
|
|
1654
|
+
_context21.next = 2;
|
|
1536
1655
|
return this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(string)));
|
|
1537
1656
|
case 2:
|
|
1538
|
-
signature =
|
|
1539
|
-
return
|
|
1657
|
+
signature = _context21.sent;
|
|
1658
|
+
return _context21.abrupt("return", this.utils.FormatSignature(signature));
|
|
1540
1659
|
case 4:
|
|
1541
1660
|
case "end":
|
|
1542
|
-
return
|
|
1661
|
+
return _context21.stop();
|
|
1543
1662
|
}
|
|
1544
|
-
},
|
|
1663
|
+
}, _callee21, this);
|
|
1545
1664
|
}));
|
|
1546
|
-
function Sign(
|
|
1665
|
+
function Sign(_x16) {
|
|
1547
1666
|
return _Sign.apply(this, arguments);
|
|
1548
1667
|
}
|
|
1549
1668
|
return Sign;
|
|
@@ -1557,33 +1676,34 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1557
1676
|
*
|
|
1558
1677
|
* @return {Promise<string>} - The encrypted message
|
|
1559
1678
|
*/
|
|
1679
|
+
)
|
|
1560
1680
|
}, {
|
|
1561
1681
|
key: "EncryptECIES",
|
|
1562
|
-
value: function () {
|
|
1563
|
-
var _EncryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1682
|
+
value: (function () {
|
|
1683
|
+
var _EncryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref26) {
|
|
1564
1684
|
var message, publicKey;
|
|
1565
|
-
return _regeneratorRuntime.wrap(function
|
|
1566
|
-
while (1) switch (
|
|
1685
|
+
return _regeneratorRuntime.wrap(function _callee22$(_context22) {
|
|
1686
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1567
1687
|
case 0:
|
|
1568
|
-
message =
|
|
1688
|
+
message = _ref26.message, publicKey = _ref26.publicKey;
|
|
1569
1689
|
if (this.signer) {
|
|
1570
|
-
|
|
1690
|
+
_context22.next = 3;
|
|
1571
1691
|
break;
|
|
1572
1692
|
}
|
|
1573
1693
|
throw "Signer not set";
|
|
1574
1694
|
case 3:
|
|
1575
1695
|
ValidatePresence("message", message);
|
|
1576
|
-
|
|
1696
|
+
_context22.next = 6;
|
|
1577
1697
|
return this.Crypto.EncryptConk(message, publicKey || this.signer._signingKey().publicKey);
|
|
1578
1698
|
case 6:
|
|
1579
|
-
return
|
|
1699
|
+
return _context22.abrupt("return", _context22.sent);
|
|
1580
1700
|
case 7:
|
|
1581
1701
|
case "end":
|
|
1582
|
-
return
|
|
1702
|
+
return _context22.stop();
|
|
1583
1703
|
}
|
|
1584
|
-
},
|
|
1704
|
+
}, _callee22, this);
|
|
1585
1705
|
}));
|
|
1586
|
-
function EncryptECIES(
|
|
1706
|
+
function EncryptECIES(_x17) {
|
|
1587
1707
|
return _EncryptECIES.apply(this, arguments);
|
|
1588
1708
|
}
|
|
1589
1709
|
return EncryptECIES;
|
|
@@ -1596,33 +1716,34 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1596
1716
|
*
|
|
1597
1717
|
* @return {Promise<string | Object>} - The decrypted string or object
|
|
1598
1718
|
*/
|
|
1719
|
+
)
|
|
1599
1720
|
}, {
|
|
1600
1721
|
key: "DecryptECIES",
|
|
1601
|
-
value: function () {
|
|
1602
|
-
var _DecryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1722
|
+
value: (function () {
|
|
1723
|
+
var _DecryptECIES = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref27) {
|
|
1603
1724
|
var message;
|
|
1604
|
-
return _regeneratorRuntime.wrap(function
|
|
1605
|
-
while (1) switch (
|
|
1725
|
+
return _regeneratorRuntime.wrap(function _callee23$(_context23) {
|
|
1726
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1606
1727
|
case 0:
|
|
1607
|
-
message =
|
|
1728
|
+
message = _ref27.message;
|
|
1608
1729
|
if (this.signer) {
|
|
1609
|
-
|
|
1730
|
+
_context23.next = 3;
|
|
1610
1731
|
break;
|
|
1611
1732
|
}
|
|
1612
1733
|
throw "Signer not set";
|
|
1613
1734
|
case 3:
|
|
1614
1735
|
ValidatePresence("message", message);
|
|
1615
|
-
|
|
1736
|
+
_context23.next = 6;
|
|
1616
1737
|
return this.Crypto.DecryptCap(message, this.signer._signingKey().privateKey);
|
|
1617
1738
|
case 6:
|
|
1618
|
-
return
|
|
1739
|
+
return _context23.abrupt("return", _context23.sent);
|
|
1619
1740
|
case 7:
|
|
1620
1741
|
case "end":
|
|
1621
|
-
return
|
|
1742
|
+
return _context23.stop();
|
|
1622
1743
|
}
|
|
1623
|
-
},
|
|
1744
|
+
}, _callee23, this);
|
|
1624
1745
|
}));
|
|
1625
|
-
function DecryptECIES(
|
|
1746
|
+
function DecryptECIES(_x18) {
|
|
1626
1747
|
return _DecryptECIES.apply(this, arguments);
|
|
1627
1748
|
}
|
|
1628
1749
|
return DecryptECIES;
|
|
@@ -1638,40 +1759,41 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1638
1759
|
*
|
|
1639
1760
|
* @return {Promise<*>} - Response in the specified format
|
|
1640
1761
|
*/
|
|
1762
|
+
)
|
|
1641
1763
|
}, {
|
|
1642
1764
|
key: "Request",
|
|
1643
|
-
value: function () {
|
|
1644
|
-
var _Request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1645
|
-
var url,
|
|
1646
|
-
return _regeneratorRuntime.wrap(function
|
|
1647
|
-
while (1) switch (
|
|
1765
|
+
value: (function () {
|
|
1766
|
+
var _Request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(_ref28) {
|
|
1767
|
+
var url, _ref28$format, format, _ref28$method, method, _ref28$headers, headers, body;
|
|
1768
|
+
return _regeneratorRuntime.wrap(function _callee24$(_context24) {
|
|
1769
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1648
1770
|
case 0:
|
|
1649
|
-
url =
|
|
1650
|
-
return
|
|
1771
|
+
url = _ref28.url, _ref28$format = _ref28.format, format = _ref28$format === void 0 ? "json" : _ref28$format, _ref28$method = _ref28.method, method = _ref28$method === void 0 ? "GET" : _ref28$method, _ref28$headers = _ref28.headers, headers = _ref28$headers === void 0 ? {} : _ref28$headers, body = _ref28.body;
|
|
1772
|
+
return _context24.abrupt("return", this.utils.ResponseToFormat(format, HttpClient.Fetch(url, {
|
|
1651
1773
|
method: method,
|
|
1652
1774
|
headers: headers,
|
|
1653
1775
|
body: body
|
|
1654
1776
|
})));
|
|
1655
1777
|
case 2:
|
|
1656
1778
|
case "end":
|
|
1657
|
-
return
|
|
1779
|
+
return _context24.stop();
|
|
1658
1780
|
}
|
|
1659
|
-
},
|
|
1781
|
+
}, _callee24, this);
|
|
1660
1782
|
}));
|
|
1661
|
-
function Request(
|
|
1783
|
+
function Request(_x19) {
|
|
1662
1784
|
return _Request.apply(this, arguments);
|
|
1663
1785
|
}
|
|
1664
1786
|
return Request;
|
|
1665
|
-
}()
|
|
1787
|
+
}())
|
|
1666
1788
|
}, {
|
|
1667
1789
|
key: "MakeAuthServiceRequest",
|
|
1668
1790
|
value: function () {
|
|
1669
|
-
var _MakeAuthServiceRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1670
|
-
var kmsId, objectId, versionHash,
|
|
1671
|
-
return _regeneratorRuntime.wrap(function
|
|
1672
|
-
while (1) switch (
|
|
1791
|
+
var _MakeAuthServiceRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(_ref29) {
|
|
1792
|
+
var kmsId, objectId, versionHash, _ref29$method, method, path, bodyType, _ref29$body, body, _ref29$queryParams, queryParams, headers, format, response;
|
|
1793
|
+
return _regeneratorRuntime.wrap(function _callee25$(_context25) {
|
|
1794
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
1673
1795
|
case 0:
|
|
1674
|
-
kmsId =
|
|
1796
|
+
kmsId = _ref29.kmsId, objectId = _ref29.objectId, versionHash = _ref29.versionHash, _ref29$method = _ref29.method, method = _ref29$method === void 0 ? "GET" : _ref29$method, path = _ref29.path, bodyType = _ref29.bodyType, _ref29$body = _ref29.body, body = _ref29$body === void 0 ? {} : _ref29$body, _ref29$queryParams = _ref29.queryParams, queryParams = _ref29$queryParams === void 0 ? {} : _ref29$queryParams, headers = _ref29.headers, format = _ref29.format;
|
|
1675
1797
|
response = this.authClient.MakeAuthServiceRequest({
|
|
1676
1798
|
kmsId: kmsId,
|
|
1677
1799
|
objectId: objectId,
|
|
@@ -1683,14 +1805,14 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1683
1805
|
queryParams: queryParams,
|
|
1684
1806
|
headers: headers
|
|
1685
1807
|
});
|
|
1686
|
-
return
|
|
1808
|
+
return _context25.abrupt("return", !format ? response : this.utils.ResponseToFormat(format, response));
|
|
1687
1809
|
case 3:
|
|
1688
1810
|
case "end":
|
|
1689
|
-
return
|
|
1811
|
+
return _context25.stop();
|
|
1690
1812
|
}
|
|
1691
|
-
},
|
|
1813
|
+
}, _callee25, this);
|
|
1692
1814
|
}));
|
|
1693
|
-
function MakeAuthServiceRequest(
|
|
1815
|
+
function MakeAuthServiceRequest(_x20) {
|
|
1694
1816
|
return _MakeAuthServiceRequest.apply(this, arguments);
|
|
1695
1817
|
}
|
|
1696
1818
|
return MakeAuthServiceRequest;
|
|
@@ -1700,10 +1822,10 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1700
1822
|
}, {
|
|
1701
1823
|
key: "FrameAllowedMethods",
|
|
1702
1824
|
value: function FrameAllowedMethods() {
|
|
1703
|
-
var
|
|
1825
|
+
var _this3 = this;
|
|
1704
1826
|
var forbiddenMethods = ["constructor", "AccessGroupMembershipMethod", "CallFromFrameMessage", "ClearSigner", "CreateAccount", "EnableMethodLogging", "FormatBlockNumbers", "FrameAllowedMethods", "FromConfigurationUrl", "GenerateWallet", "InitializeClients", "Log", "PersonalSign", "SetRemoteSigner", "SetSigner", "SetSignerFromWeb3Provider", "Sign", "ToggleLogging"];
|
|
1705
1827
|
return Object.getOwnPropertyNames(Object.getPrototypeOf(this)).filter(function (method) {
|
|
1706
|
-
return typeof
|
|
1828
|
+
return typeof _this3[method] === "function" && !forbiddenMethods.includes(method);
|
|
1707
1829
|
});
|
|
1708
1830
|
}
|
|
1709
1831
|
|
|
@@ -1711,21 +1833,21 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1711
1833
|
}, {
|
|
1712
1834
|
key: "CallFromFrameMessage",
|
|
1713
1835
|
value: function () {
|
|
1714
|
-
var _CallFromFrameMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1715
|
-
var
|
|
1836
|
+
var _CallFromFrameMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(message, Respond) {
|
|
1837
|
+
var _this4 = this;
|
|
1716
1838
|
var callback, method, methodResults, responseError;
|
|
1717
|
-
return _regeneratorRuntime.wrap(function
|
|
1718
|
-
while (1) switch (
|
|
1839
|
+
return _regeneratorRuntime.wrap(function _callee26$(_context26) {
|
|
1840
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
1719
1841
|
case 0:
|
|
1720
1842
|
if (!(message.type !== "ElvFrameRequest")) {
|
|
1721
|
-
|
|
1843
|
+
_context26.next = 2;
|
|
1722
1844
|
break;
|
|
1723
1845
|
}
|
|
1724
|
-
return
|
|
1846
|
+
return _context26.abrupt("return");
|
|
1725
1847
|
case 2:
|
|
1726
1848
|
if (message.callbackId) {
|
|
1727
1849
|
callback = function callback(result) {
|
|
1728
|
-
Respond(
|
|
1850
|
+
Respond(_this4.utils.MakeClonable({
|
|
1729
1851
|
type: "ElvFrameResponse",
|
|
1730
1852
|
requestId: message.callbackId,
|
|
1731
1853
|
response: result
|
|
@@ -1733,101 +1855,103 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1733
1855
|
};
|
|
1734
1856
|
message.args.callback = callback;
|
|
1735
1857
|
}
|
|
1736
|
-
|
|
1858
|
+
_context26.prev = 3;
|
|
1737
1859
|
method = message.calledMethod;
|
|
1738
1860
|
if (!(message.module === "walletClient")) {
|
|
1739
|
-
|
|
1861
|
+
_context26.next = 15;
|
|
1740
1862
|
break;
|
|
1741
1863
|
}
|
|
1742
1864
|
if (this.walletClient) {
|
|
1743
|
-
|
|
1865
|
+
_context26.next = 8;
|
|
1744
1866
|
break;
|
|
1745
1867
|
}
|
|
1746
1868
|
throw Error("Wallet client not set");
|
|
1747
1869
|
case 8:
|
|
1748
1870
|
if (!this.walletClient.ForbiddenMethods().includes(method)) {
|
|
1749
|
-
|
|
1871
|
+
_context26.next = 10;
|
|
1750
1872
|
break;
|
|
1751
1873
|
}
|
|
1752
1874
|
throw Error("Invalid user profile method: " + method);
|
|
1753
1875
|
case 10:
|
|
1754
|
-
|
|
1876
|
+
_context26.next = 12;
|
|
1755
1877
|
return this.walletClient[method](message.args);
|
|
1756
1878
|
case 12:
|
|
1757
|
-
methodResults =
|
|
1758
|
-
|
|
1879
|
+
methodResults = _context26.sent;
|
|
1880
|
+
_context26.next = 28;
|
|
1759
1881
|
break;
|
|
1760
1882
|
case 15:
|
|
1761
1883
|
if (!(message.module === "userProfileClient")) {
|
|
1762
|
-
|
|
1884
|
+
_context26.next = 23;
|
|
1763
1885
|
break;
|
|
1764
1886
|
}
|
|
1765
1887
|
if (this.userProfileClient.FrameAllowedMethods().includes(method)) {
|
|
1766
|
-
|
|
1888
|
+
_context26.next = 18;
|
|
1767
1889
|
break;
|
|
1768
1890
|
}
|
|
1769
1891
|
throw Error("Invalid user profile method: " + method);
|
|
1770
1892
|
case 18:
|
|
1771
|
-
|
|
1893
|
+
_context26.next = 20;
|
|
1772
1894
|
return this.userProfileClient[method](message.args);
|
|
1773
1895
|
case 20:
|
|
1774
|
-
methodResults =
|
|
1775
|
-
|
|
1896
|
+
methodResults = _context26.sent;
|
|
1897
|
+
_context26.next = 28;
|
|
1776
1898
|
break;
|
|
1777
1899
|
case 23:
|
|
1778
1900
|
if (this.FrameAllowedMethods().includes(method)) {
|
|
1779
|
-
|
|
1901
|
+
_context26.next = 25;
|
|
1780
1902
|
break;
|
|
1781
1903
|
}
|
|
1782
1904
|
throw Error("Invalid method: " + method);
|
|
1783
1905
|
case 25:
|
|
1784
|
-
|
|
1906
|
+
_context26.next = 27;
|
|
1785
1907
|
return this[method](message.args);
|
|
1786
1908
|
case 27:
|
|
1787
|
-
methodResults =
|
|
1909
|
+
methodResults = _context26.sent;
|
|
1788
1910
|
case 28:
|
|
1789
1911
|
Respond(this.utils.MakeClonable({
|
|
1790
1912
|
type: "ElvFrameResponse",
|
|
1791
1913
|
requestId: message.requestId,
|
|
1792
1914
|
response: methodResults
|
|
1793
1915
|
}));
|
|
1794
|
-
|
|
1916
|
+
_context26.next = 38;
|
|
1795
1917
|
break;
|
|
1796
1918
|
case 31:
|
|
1797
|
-
|
|
1798
|
-
|
|
1919
|
+
_context26.prev = 31;
|
|
1920
|
+
_context26.t0 = _context26["catch"](3);
|
|
1799
1921
|
// eslint-disable-next-line no-console
|
|
1800
|
-
this.Log("Frame Message Error:\n Method: ".concat(message.calledMethod, "\n Arguments: ").concat(JSON.stringify(message.args, null, 2), "\n Error: ").concat(_typeof(
|
|
1922
|
+
this.Log("Frame Message Error:\n Method: ".concat(message.calledMethod, "\n Arguments: ").concat(JSON.stringify(message.args, null, 2), "\n Error: ").concat(_typeof(_context26.t0) === "object" ? JSON.stringify(_context26.t0, null, 2) : _context26.t0), true);
|
|
1801
1923
|
|
|
1802
1924
|
// eslint-disable-next-line no-console
|
|
1803
|
-
console.error(
|
|
1804
|
-
|
|
1925
|
+
console.error(message);
|
|
1926
|
+
// eslint-disable-next-line no-console
|
|
1927
|
+
console.error(_context26.t0);
|
|
1928
|
+
responseError = _context26.t0 instanceof Error ? _context26.t0.message : _context26.t0;
|
|
1805
1929
|
Respond(this.utils.MakeClonable({
|
|
1806
1930
|
type: "ElvFrameResponse",
|
|
1807
1931
|
requestId: message.requestId,
|
|
1808
1932
|
error: responseError
|
|
1809
1933
|
}));
|
|
1810
|
-
case
|
|
1934
|
+
case 38:
|
|
1811
1935
|
case "end":
|
|
1812
|
-
return
|
|
1936
|
+
return _context26.stop();
|
|
1813
1937
|
}
|
|
1814
|
-
},
|
|
1938
|
+
}, _callee26, this, [[3, 31]]);
|
|
1815
1939
|
}));
|
|
1816
|
-
function CallFromFrameMessage(
|
|
1940
|
+
function CallFromFrameMessage(_x21, _x22) {
|
|
1817
1941
|
return _CallFromFrameMessage.apply(this, arguments);
|
|
1818
1942
|
}
|
|
1819
1943
|
return CallFromFrameMessage;
|
|
1820
1944
|
}()
|
|
1821
1945
|
}], [{
|
|
1822
1946
|
key: "Configuration",
|
|
1823
|
-
value: function () {
|
|
1824
|
-
var _Configuration = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1825
|
-
var configUrl,
|
|
1826
|
-
return _regeneratorRuntime.wrap(function
|
|
1827
|
-
while (1) switch (
|
|
1947
|
+
value: (function () {
|
|
1948
|
+
var _Configuration = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27(_ref30) {
|
|
1949
|
+
var configUrl, _ref30$kmsUrls, kmsUrls, region, clientIP, uri, fabricInfo, filterHTTPS, fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs, fabricVersion;
|
|
1950
|
+
return _regeneratorRuntime.wrap(function _callee27$(_context27) {
|
|
1951
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
1828
1952
|
case 0:
|
|
1829
|
-
configUrl =
|
|
1830
|
-
|
|
1953
|
+
configUrl = _ref30.configUrl, _ref30$kmsUrls = _ref30.kmsUrls, kmsUrls = _ref30$kmsUrls === void 0 ? [] : _ref30$kmsUrls, region = _ref30.region, clientIP = _ref30.clientIP;
|
|
1954
|
+
_context27.prev = 1;
|
|
1831
1955
|
uri = new URI(configUrl);
|
|
1832
1956
|
uri.pathname("/config");
|
|
1833
1957
|
if (region) {
|
|
@@ -1836,10 +1960,10 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1836
1960
|
if (clientIP) {
|
|
1837
1961
|
uri.addSearch("client_ip", clientIP);
|
|
1838
1962
|
}
|
|
1839
|
-
|
|
1963
|
+
_context27.next = 8;
|
|
1840
1964
|
return Utils.ResponseToJson(HttpClient.Fetch(uri.toString()));
|
|
1841
1965
|
case 8:
|
|
1842
|
-
fabricInfo =
|
|
1966
|
+
fabricInfo = _context27.sent;
|
|
1843
1967
|
// If any HTTPS urls present, throw away HTTP urls so only HTTPS will be used
|
|
1844
1968
|
filterHTTPS = function filterHTTPS(uri) {
|
|
1845
1969
|
return uri.toLowerCase().startsWith("https");
|
|
@@ -1862,7 +1986,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1862
1986
|
}
|
|
1863
1987
|
searchURIs = fabricInfo.network.services.search || [];
|
|
1864
1988
|
fabricVersion = Math.max.apply(Math, _toConsumableArray(fabricInfo.network.api_versions || [2]));
|
|
1865
|
-
return
|
|
1989
|
+
return _context27.abrupt("return", {
|
|
1866
1990
|
nodeId: fabricInfo.node_id,
|
|
1867
1991
|
contentSpaceId: fabricInfo.qspace.id,
|
|
1868
1992
|
networkId: (fabricInfo.qspace.ethereum || {}).network_id,
|
|
@@ -1876,20 +2000,20 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1876
2000
|
fabricVersion: fabricVersion
|
|
1877
2001
|
});
|
|
1878
2002
|
case 23:
|
|
1879
|
-
|
|
1880
|
-
|
|
2003
|
+
_context27.prev = 23;
|
|
2004
|
+
_context27.t0 = _context27["catch"](1);
|
|
1881
2005
|
// eslint-disable-next-line no-console
|
|
1882
2006
|
console.error("Error retrieving fabric configuration:");
|
|
1883
2007
|
// eslint-disable-next-line no-console
|
|
1884
|
-
console.error(
|
|
1885
|
-
throw
|
|
2008
|
+
console.error(_context27.t0);
|
|
2009
|
+
throw _context27.t0;
|
|
1886
2010
|
case 28:
|
|
1887
2011
|
case "end":
|
|
1888
|
-
return
|
|
2012
|
+
return _context27.stop();
|
|
1889
2013
|
}
|
|
1890
|
-
},
|
|
2014
|
+
}, _callee27, null, [[1, 23]]);
|
|
1891
2015
|
}));
|
|
1892
|
-
function Configuration(
|
|
2016
|
+
function Configuration(_x23) {
|
|
1893
2017
|
return _Configuration.apply(this, arguments);
|
|
1894
2018
|
}
|
|
1895
2019
|
return Configuration;
|
|
@@ -1901,6 +2025,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1901
2025
|
*
|
|
1902
2026
|
* @return {Object} - An object using network names as keys and configuration URLs as values.
|
|
1903
2027
|
*/
|
|
2028
|
+
)
|
|
1904
2029
|
}, {
|
|
1905
2030
|
key: "Networks",
|
|
1906
2031
|
value: function Networks() {
|
|
@@ -1925,21 +2050,21 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1925
2050
|
*/
|
|
1926
2051
|
}, {
|
|
1927
2052
|
key: "FromNetworkName",
|
|
1928
|
-
value: function () {
|
|
1929
|
-
var _FromNetworkName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1930
|
-
var networkName, region, clientIP, trustAuthorityId, staticToken,
|
|
1931
|
-
return _regeneratorRuntime.wrap(function
|
|
1932
|
-
while (1) switch (
|
|
2053
|
+
value: (function () {
|
|
2054
|
+
var _FromNetworkName = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28(_ref31) {
|
|
2055
|
+
var networkName, region, clientIP, trustAuthorityId, staticToken, _ref31$ethereumContra, ethereumContractTimeout, _ref31$noCache, noCache, _ref31$noAuth, noAuth, assumeV3, configUrl;
|
|
2056
|
+
return _regeneratorRuntime.wrap(function _callee28$(_context28) {
|
|
2057
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
1933
2058
|
case 0:
|
|
1934
|
-
networkName =
|
|
2059
|
+
networkName = _ref31.networkName, region = _ref31.region, clientIP = _ref31.clientIP, trustAuthorityId = _ref31.trustAuthorityId, staticToken = _ref31.staticToken, _ref31$ethereumContra = _ref31.ethereumContractTimeout, ethereumContractTimeout = _ref31$ethereumContra === void 0 ? 10 : _ref31$ethereumContra, _ref31$noCache = _ref31.noCache, noCache = _ref31$noCache === void 0 ? false : _ref31$noCache, _ref31$noAuth = _ref31.noAuth, noAuth = _ref31$noAuth === void 0 ? false : _ref31$noAuth, assumeV3 = _ref31.assumeV3;
|
|
1935
2060
|
configUrl = networks[networkName];
|
|
1936
2061
|
if (configUrl) {
|
|
1937
|
-
|
|
2062
|
+
_context28.next = 4;
|
|
1938
2063
|
break;
|
|
1939
2064
|
}
|
|
1940
2065
|
throw Error("Invalid network name: " + networkName);
|
|
1941
2066
|
case 4:
|
|
1942
|
-
|
|
2067
|
+
_context28.next = 6;
|
|
1943
2068
|
return this.FromConfigurationUrl({
|
|
1944
2069
|
configUrl: configUrl,
|
|
1945
2070
|
region: region,
|
|
@@ -1952,14 +2077,14 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1952
2077
|
assumeV3: assumeV3
|
|
1953
2078
|
});
|
|
1954
2079
|
case 6:
|
|
1955
|
-
return
|
|
2080
|
+
return _context28.abrupt("return", _context28.sent);
|
|
1956
2081
|
case 7:
|
|
1957
2082
|
case "end":
|
|
1958
|
-
return
|
|
2083
|
+
return _context28.stop();
|
|
1959
2084
|
}
|
|
1960
|
-
},
|
|
2085
|
+
}, _callee28, this);
|
|
1961
2086
|
}));
|
|
1962
|
-
function FromNetworkName(
|
|
2087
|
+
function FromNetworkName(_x24) {
|
|
1963
2088
|
return _FromNetworkName.apply(this, arguments);
|
|
1964
2089
|
}
|
|
1965
2090
|
return FromNetworkName;
|
|
@@ -1980,23 +2105,24 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1980
2105
|
*
|
|
1981
2106
|
* @return {Promise<ElvClient>} - New ElvClient connected to the specified content fabric and blockchain
|
|
1982
2107
|
*/
|
|
2108
|
+
)
|
|
1983
2109
|
}, {
|
|
1984
2110
|
key: "FromConfigurationUrl",
|
|
1985
|
-
value: function () {
|
|
1986
|
-
var _FromConfigurationUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1987
|
-
var configUrl, region, clientIP, trustAuthorityId, staticToken,
|
|
1988
|
-
return _regeneratorRuntime.wrap(function
|
|
1989
|
-
while (1) switch (
|
|
2111
|
+
value: (function () {
|
|
2112
|
+
var _FromConfigurationUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29(_ref32) {
|
|
2113
|
+
var configUrl, region, clientIP, trustAuthorityId, staticToken, _ref32$ethereumContra, ethereumContractTimeout, _ref32$noCache, noCache, _ref32$noAuth, noAuth, _ref32$assumeV, assumeV3, _yield$ElvClient$Conf3, contentSpaceId, networkId, networkName, fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs, fabricVersion, client;
|
|
2114
|
+
return _regeneratorRuntime.wrap(function _callee29$(_context29) {
|
|
2115
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
1990
2116
|
case 0:
|
|
1991
|
-
configUrl =
|
|
1992
|
-
|
|
2117
|
+
configUrl = _ref32.configUrl, region = _ref32.region, clientIP = _ref32.clientIP, trustAuthorityId = _ref32.trustAuthorityId, staticToken = _ref32.staticToken, _ref32$ethereumContra = _ref32.ethereumContractTimeout, ethereumContractTimeout = _ref32$ethereumContra === void 0 ? 10 : _ref32$ethereumContra, _ref32$noCache = _ref32.noCache, noCache = _ref32$noCache === void 0 ? false : _ref32$noCache, _ref32$noAuth = _ref32.noAuth, noAuth = _ref32$noAuth === void 0 ? false : _ref32$noAuth, _ref32$assumeV = _ref32.assumeV3, assumeV3 = _ref32$assumeV === void 0 ? false : _ref32$assumeV;
|
|
2118
|
+
_context29.next = 3;
|
|
1993
2119
|
return ElvClient.Configuration({
|
|
1994
2120
|
configUrl: configUrl,
|
|
1995
2121
|
clientIP: clientIP,
|
|
1996
2122
|
region: region
|
|
1997
2123
|
});
|
|
1998
2124
|
case 3:
|
|
1999
|
-
_yield$ElvClient$Conf3 =
|
|
2125
|
+
_yield$ElvClient$Conf3 = _context29.sent;
|
|
2000
2126
|
contentSpaceId = _yield$ElvClient$Conf3.contentSpaceId;
|
|
2001
2127
|
networkId = _yield$ElvClient$Conf3.networkId;
|
|
2002
2128
|
networkName = _yield$ElvClient$Conf3.networkName;
|
|
@@ -2026,20 +2152,19 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
2026
2152
|
client.configUrl = configUrl;
|
|
2027
2153
|
client.region = region;
|
|
2028
2154
|
client.clientIP = clientIP;
|
|
2029
|
-
return
|
|
2155
|
+
return _context29.abrupt("return", client);
|
|
2030
2156
|
case 18:
|
|
2031
2157
|
case "end":
|
|
2032
|
-
return
|
|
2158
|
+
return _context29.stop();
|
|
2033
2159
|
}
|
|
2034
|
-
},
|
|
2160
|
+
}, _callee29);
|
|
2035
2161
|
}));
|
|
2036
|
-
function FromConfigurationUrl(
|
|
2162
|
+
function FromConfigurationUrl(_x25) {
|
|
2037
2163
|
return _FromConfigurationUrl.apply(this, arguments);
|
|
2038
2164
|
}
|
|
2039
2165
|
return FromConfigurationUrl;
|
|
2040
|
-
}()
|
|
2166
|
+
}())
|
|
2041
2167
|
}]);
|
|
2042
|
-
return ElvClient;
|
|
2043
2168
|
}();
|
|
2044
2169
|
Object.assign(ElvClient.prototype, require("./client/AccessGroups"));
|
|
2045
2170
|
Object.assign(ElvClient.prototype, require("./client/ContentAccess"));
|