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