@eluvio/elv-client-js 4.0.135 → 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/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
|
@@ -7,8 +7,8 @@ var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
|
7
7
|
var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
|
|
8
8
|
var _createClass = require("@babel/runtime/helpers/createClass");
|
|
9
9
|
var _excluded = ["code", "address", "type", "authToken", "expiresAt"];
|
|
10
|
-
function ownKeys(
|
|
11
|
-
function _objectSpread(
|
|
10
|
+
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; }
|
|
11
|
+
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; }
|
|
12
12
|
var _require = require("../ElvClient"),
|
|
13
13
|
ElvClient = _require.ElvClient;
|
|
14
14
|
var Configuration = require("./Configuration");
|
|
@@ -79,7 +79,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
79
79
|
this.utils = client.utils;
|
|
80
80
|
this.ForbiddenMethods = ElvWalletClient.ForbiddenMethods;
|
|
81
81
|
}
|
|
82
|
-
_createClass(ElvWalletClient, [{
|
|
82
|
+
return _createClass(ElvWalletClient, [{
|
|
83
83
|
key: "Log",
|
|
84
84
|
value: function Log(message) {
|
|
85
85
|
var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -136,7 +136,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
136
136
|
*/
|
|
137
137
|
}, {
|
|
138
138
|
key: "PersonalSign",
|
|
139
|
-
value: function () {
|
|
139
|
+
value: (function () {
|
|
140
140
|
var _PersonalSign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref2) {
|
|
141
141
|
var message, parameters, url;
|
|
142
142
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
@@ -265,7 +265,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
265
265
|
return _PersonalSign.apply(this, arguments);
|
|
266
266
|
}
|
|
267
267
|
return PersonalSign;
|
|
268
|
-
}()
|
|
268
|
+
}())
|
|
269
269
|
}, {
|
|
270
270
|
key: "LogInURL",
|
|
271
271
|
value: function () {
|
|
@@ -344,7 +344,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
344
344
|
*/
|
|
345
345
|
}, {
|
|
346
346
|
key: "LogIn",
|
|
347
|
-
value: function () {
|
|
347
|
+
value: (function () {
|
|
348
348
|
var _LogIn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref5) {
|
|
349
349
|
var _this = this;
|
|
350
350
|
var _ref5$method, method, provider, _ref5$mode, mode, callbackUrl, marketplaceParams, _ref5$clearLogin, clearLogin, callback, loginUrl;
|
|
@@ -463,9 +463,10 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
463
463
|
*
|
|
464
464
|
* @methodGroup Login
|
|
465
465
|
*/
|
|
466
|
+
)
|
|
466
467
|
}, {
|
|
467
468
|
key: "LogOut",
|
|
468
|
-
value: function () {
|
|
469
|
+
value: (function () {
|
|
469
470
|
var _LogOut = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
470
471
|
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
471
472
|
while (1) switch (_context8.prev = _context8.next) {
|
|
@@ -508,7 +509,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
508
509
|
return _LogOut.apply(this, arguments);
|
|
509
510
|
}
|
|
510
511
|
return LogOut;
|
|
511
|
-
}()
|
|
512
|
+
}())
|
|
512
513
|
}, {
|
|
513
514
|
key: "TokenStatus",
|
|
514
515
|
value: function () {
|
|
@@ -548,7 +549,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
548
549
|
*/
|
|
549
550
|
}, {
|
|
550
551
|
key: "Authenticate",
|
|
551
|
-
value: function () {
|
|
552
|
+
value: (function () {
|
|
552
553
|
var _Authenticate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref7) {
|
|
553
554
|
var token, decodedToken;
|
|
554
555
|
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
@@ -605,6 +606,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
605
606
|
* @param {string=} email - Email address of the user. If not specified, this method will attempt to extract the email from the ID token.
|
|
606
607
|
* @param {Array<string>=} signerURIs - (Only if using custom OAuth) - URIs corresponding to the key server(s) to use
|
|
607
608
|
* @param {boolean=} shareEmail=false - Whether or not the user consents to sharing their email
|
|
609
|
+
* @param {number=} tokenDuration=24 - Token expiration duration, in hours
|
|
608
610
|
*
|
|
609
611
|
* @returns {Promise<Object>} - Returns an authorization tokens that can be used to initialize the client using <a href="#Authenticate">Authenticate</a>.
|
|
610
612
|
* Save this token to avoid having to reauthenticate with OAuth. This token expires after 24 hours.
|
|
@@ -614,26 +616,26 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
614
616
|
* - signingToken - Identical to `authToken`, but also includes the ability to perform arbitrary signatures with the custodial wallet. This token should be protected and should not be
|
|
615
617
|
* shared with third parties.
|
|
616
618
|
*/
|
|
619
|
+
)
|
|
617
620
|
}, {
|
|
618
621
|
key: "AuthenticateOAuth",
|
|
619
|
-
value: function () {
|
|
622
|
+
value: (function () {
|
|
620
623
|
var _AuthenticateOAuth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref8) {
|
|
621
|
-
var idToken, tenantId, email, signerURIs, _ref8$shareEmail, shareEmail, _ref8$extraData, extraData, nonce, _ref8$createRemoteTok, createRemoteToken, _ref8$force, force, tokenDuration, fabricToken, expiresAt, tokenResponse, address, decodedToken;
|
|
624
|
+
var idToken, tenantId, email, signerURIs, _ref8$shareEmail, shareEmail, _ref8$extraData, extraData, nonce, _ref8$createRemoteTok, createRemoteToken, _ref8$force, force, _ref8$tokenDuration, tokenDuration, fabricToken, expiresAt, tokenResponse, address, decodedToken;
|
|
622
625
|
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
623
626
|
while (1) switch (_context11.prev = _context11.next) {
|
|
624
627
|
case 0:
|
|
625
|
-
idToken = _ref8.idToken, tenantId = _ref8.tenantId, email = _ref8.email, signerURIs = _ref8.signerURIs, _ref8$shareEmail = _ref8.shareEmail, shareEmail = _ref8$shareEmail === void 0 ? false : _ref8$shareEmail, _ref8$extraData = _ref8.extraData, extraData = _ref8$extraData === void 0 ? {} : _ref8$extraData, nonce = _ref8.nonce, _ref8$createRemoteTok = _ref8.createRemoteToken, createRemoteToken = _ref8$createRemoteTok === void 0 ? true : _ref8$createRemoteTok, _ref8$force = _ref8.force, force = _ref8$force === void 0 ? false : _ref8$force;
|
|
626
|
-
tokenDuration = 24;
|
|
628
|
+
idToken = _ref8.idToken, tenantId = _ref8.tenantId, email = _ref8.email, signerURIs = _ref8.signerURIs, _ref8$shareEmail = _ref8.shareEmail, shareEmail = _ref8$shareEmail === void 0 ? false : _ref8$shareEmail, _ref8$extraData = _ref8.extraData, extraData = _ref8$extraData === void 0 ? {} : _ref8$extraData, nonce = _ref8.nonce, _ref8$createRemoteTok = _ref8.createRemoteToken, createRemoteToken = _ref8$createRemoteTok === void 0 ? true : _ref8$createRemoteTok, _ref8$force = _ref8.force, force = _ref8$force === void 0 ? false : _ref8$force, _ref8$tokenDuration = _ref8.tokenDuration, tokenDuration = _ref8$tokenDuration === void 0 ? 24 : _ref8$tokenDuration;
|
|
627
629
|
if (!(!tenantId && this.selectedMarketplaceInfo)) {
|
|
628
|
-
_context11.next =
|
|
630
|
+
_context11.next = 5;
|
|
629
631
|
break;
|
|
630
632
|
}
|
|
631
|
-
_context11.next =
|
|
633
|
+
_context11.next = 4;
|
|
632
634
|
return this.AvailableMarketplaces();
|
|
633
|
-
case
|
|
635
|
+
case 4:
|
|
634
636
|
tenantId = this.selectedMarketplaceInfo.tenantId;
|
|
635
|
-
case
|
|
636
|
-
_context11.next =
|
|
637
|
+
case 5:
|
|
638
|
+
_context11.next = 7;
|
|
637
639
|
return this.client.SetRemoteSigner({
|
|
638
640
|
idToken: idToken,
|
|
639
641
|
tenantId: tenantId,
|
|
@@ -643,54 +645,55 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
643
645
|
}),
|
|
644
646
|
unsignedPublicAuth: true
|
|
645
647
|
});
|
|
646
|
-
case
|
|
648
|
+
case 7:
|
|
647
649
|
if (!(createRemoteToken && this.client.signer.remoteSigner)) {
|
|
648
|
-
_context11.next =
|
|
650
|
+
_context11.next = 16;
|
|
649
651
|
break;
|
|
650
652
|
}
|
|
651
|
-
expiresAt = Date.now() +
|
|
652
|
-
_context11.next =
|
|
653
|
+
expiresAt = Date.now() + tokenDuration * 60 * 60 * 1000;
|
|
654
|
+
_context11.next = 11;
|
|
653
655
|
return this.client.signer.RetrieveCSAT({
|
|
654
656
|
email: email,
|
|
655
657
|
nonce: nonce,
|
|
656
658
|
tenantId: tenantId,
|
|
657
|
-
force: force
|
|
659
|
+
force: force,
|
|
660
|
+
duration: tokenDuration
|
|
658
661
|
});
|
|
659
|
-
case
|
|
662
|
+
case 11:
|
|
660
663
|
tokenResponse = _context11.sent;
|
|
661
664
|
fabricToken = tokenResponse.token;
|
|
662
665
|
nonce = tokenResponse.nonce;
|
|
663
|
-
_context11.next =
|
|
666
|
+
_context11.next = 20;
|
|
664
667
|
break;
|
|
665
|
-
case
|
|
668
|
+
case 16:
|
|
666
669
|
expiresAt = Date.now() + tokenDuration * 60 * 60 * 1000;
|
|
667
|
-
_context11.next =
|
|
670
|
+
_context11.next = 19;
|
|
668
671
|
return this.client.CreateFabricToken({
|
|
669
|
-
duration: tokenDuration * 60 * 60 * 1000,
|
|
672
|
+
duration: parseInt(tokenDuration * 60 * 60 * 1000),
|
|
670
673
|
context: email ? {
|
|
671
674
|
usr: {
|
|
672
675
|
email: email
|
|
673
676
|
}
|
|
674
677
|
} : {}
|
|
675
678
|
});
|
|
676
|
-
case
|
|
679
|
+
case 19:
|
|
677
680
|
fabricToken = _context11.sent;
|
|
678
|
-
case
|
|
681
|
+
case 20:
|
|
679
682
|
address = this.client.utils.FormatAddress(this.client.CurrentAccountAddress());
|
|
680
683
|
if (email) {
|
|
681
|
-
_context11.next =
|
|
684
|
+
_context11.next = 30;
|
|
682
685
|
break;
|
|
683
686
|
}
|
|
684
|
-
_context11.prev =
|
|
687
|
+
_context11.prev = 22;
|
|
685
688
|
decodedToken = JSON.parse(this.utils.FromB64URL(idToken.split(".")[1]));
|
|
686
689
|
email = decodedToken.email;
|
|
687
|
-
_context11.next =
|
|
690
|
+
_context11.next = 30;
|
|
688
691
|
break;
|
|
689
|
-
case
|
|
690
|
-
_context11.prev =
|
|
691
|
-
_context11.t0 = _context11["catch"](
|
|
692
|
+
case 27:
|
|
693
|
+
_context11.prev = 27;
|
|
694
|
+
_context11.t0 = _context11["catch"](22);
|
|
692
695
|
throw Error("Failed to decode ID token");
|
|
693
|
-
case
|
|
696
|
+
case 30:
|
|
694
697
|
this.client.SetStaticToken({
|
|
695
698
|
token: fabricToken
|
|
696
699
|
});
|
|
@@ -720,11 +723,11 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
720
723
|
nonce: nonce
|
|
721
724
|
})
|
|
722
725
|
});
|
|
723
|
-
case
|
|
726
|
+
case 32:
|
|
724
727
|
case "end":
|
|
725
728
|
return _context11.stop();
|
|
726
729
|
}
|
|
727
|
-
}, _callee11, this, [[
|
|
730
|
+
}, _callee11, this, [[22, 27]]);
|
|
728
731
|
}));
|
|
729
732
|
function AuthenticateOAuth(_x13) {
|
|
730
733
|
return _AuthenticateOAuth.apply(this, arguments);
|
|
@@ -744,9 +747,10 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
744
747
|
* @returns {Promise<string>} - Returns an authorization token that can be used to initialize the client using <a href="#Authenticate">Authenticate</a>.
|
|
745
748
|
* Save this token to avoid having to reauthenticate. This token expires after 24 hours.
|
|
746
749
|
*/
|
|
750
|
+
)
|
|
747
751
|
}, {
|
|
748
752
|
key: "AuthenticateExternalWallet",
|
|
749
|
-
value: function () {
|
|
753
|
+
value: (function () {
|
|
750
754
|
var _AuthenticateExternalWallet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref9) {
|
|
751
755
|
var _this2 = this;
|
|
752
756
|
var address, _ref9$tokenDuration, tokenDuration, _ref9$walletName, walletName, Sign, expiresAt, fabricToken;
|
|
@@ -815,6 +819,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
815
819
|
*
|
|
816
820
|
* @returns {string} - The client auth token
|
|
817
821
|
*/
|
|
822
|
+
)
|
|
818
823
|
}, {
|
|
819
824
|
key: "ClientAuthToken",
|
|
820
825
|
value: function ClientAuthToken() {
|
|
@@ -1878,7 +1883,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1878
1883
|
*/
|
|
1879
1884
|
}, {
|
|
1880
1885
|
key: "Initialize",
|
|
1881
|
-
value: function () {
|
|
1886
|
+
value: (function () {
|
|
1882
1887
|
var _Initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(_ref24) {
|
|
1883
1888
|
var client, _ref24$appId, appId, _ref24$network, network, _ref24$mode, mode, localization, marketplaceParams, previewMarketplaceId, _ref24$storeAuthToken, storeAuthToken, _ref24$skipMarketplac, skipMarketplaceLoad, _ref25, tenantSlug, marketplaceSlug, marketplaceId, marketplaceHash, previewMarketplaceHash, walletClient, url, savedToken;
|
|
1884
1889
|
return _regeneratorRuntime.wrap(function _callee25$(_context25) {
|
|
@@ -1978,36 +1983,46 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1978
1983
|
_context25.prev = 35;
|
|
1979
1984
|
_context25.t0 = _context25["catch"](28);
|
|
1980
1985
|
case 37:
|
|
1981
|
-
_context25.
|
|
1986
|
+
_context25.prev = 37;
|
|
1987
|
+
_context25.next = 40;
|
|
1982
1988
|
return client.utils.ResponseToJson(client.MakeAuthServiceRequest({
|
|
1983
1989
|
path: "/as/mw/toplevel",
|
|
1984
1990
|
queryParams: {
|
|
1985
1991
|
env: mode
|
|
1986
1992
|
}
|
|
1987
1993
|
}));
|
|
1988
|
-
case
|
|
1994
|
+
case 40:
|
|
1989
1995
|
walletClient.topLevelInfo = _context25.sent;
|
|
1996
|
+
_context25.next = 47;
|
|
1997
|
+
break;
|
|
1998
|
+
case 43:
|
|
1999
|
+
_context25.prev = 43;
|
|
2000
|
+
_context25.t1 = _context25["catch"](37);
|
|
2001
|
+
// eslint-disable-next-line no-console
|
|
2002
|
+
console.error("Unable to load top level info:");
|
|
2003
|
+
// eslint-disable-next-line no-console
|
|
2004
|
+
console.error(_context25.t1);
|
|
2005
|
+
case 47:
|
|
1990
2006
|
if (skipMarketplaceLoad) {
|
|
1991
|
-
_context25.next =
|
|
2007
|
+
_context25.next = 50;
|
|
1992
2008
|
break;
|
|
1993
2009
|
}
|
|
1994
|
-
_context25.next =
|
|
2010
|
+
_context25.next = 50;
|
|
1995
2011
|
return walletClient.LoadAvailableMarketplaces();
|
|
1996
|
-
case
|
|
2012
|
+
case 50:
|
|
1997
2013
|
return _context25.abrupt("return", walletClient);
|
|
1998
|
-
case
|
|
2014
|
+
case 51:
|
|
1999
2015
|
case "end":
|
|
2000
2016
|
return _context25.stop();
|
|
2001
2017
|
}
|
|
2002
|
-
}, _callee25, null, [[28, 35]]);
|
|
2018
|
+
}, _callee25, null, [[28, 35], [37, 43]]);
|
|
2003
2019
|
}));
|
|
2004
2020
|
function Initialize(_x25) {
|
|
2005
2021
|
return _Initialize.apply(this, arguments);
|
|
2006
2022
|
}
|
|
2007
2023
|
return Initialize;
|
|
2008
|
-
}()
|
|
2024
|
+
}())
|
|
2009
2025
|
}]);
|
|
2010
|
-
return ElvWalletClient;
|
|
2011
2026
|
}();
|
|
2012
2027
|
Object.assign(ElvWalletClient.prototype, require("./ClientMethods"));
|
|
2013
2028
|
Object.assign(ElvWalletClient.prototype, require("./Profile"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eluvio/elv-client-js",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.136",
|
|
4
4
|
"description": "Javascript client for the Eluvio Content Fabric",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "Kevin Talmadge",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/runtime": "^7.8.4",
|
|
56
56
|
"@eluvio/crypto": "^1.1.1",
|
|
57
|
-
"@eluvio/elv-abr-profile": "^1.0.
|
|
57
|
+
"@eluvio/elv-abr-profile": "^1.0.2",
|
|
58
58
|
"@sindresorhus/slugify": "^1.1.0",
|
|
59
59
|
"babel-loader": "^8.0.6",
|
|
60
60
|
"bignumber.js": "^8.0.2",
|
package/src/ElvClient.js
CHANGED
|
@@ -16,7 +16,8 @@ const {LogMessage} = require("./LogMessage");
|
|
|
16
16
|
const Pako = require("pako");
|
|
17
17
|
|
|
18
18
|
const {
|
|
19
|
-
ValidatePresence
|
|
19
|
+
ValidatePresence,
|
|
20
|
+
ValidateWriteToken
|
|
20
21
|
} = require("./Validation");
|
|
21
22
|
const UrlJoin = require("url-join");
|
|
22
23
|
|
|
@@ -618,10 +619,11 @@ class ElvClient {
|
|
|
618
619
|
* @namedParams
|
|
619
620
|
* @param {string=} matchEndpoint - Return node(s) matching the specified endpoint
|
|
620
621
|
* @param {string=} matchNodeId - Return node(s) matching the specified node ID
|
|
622
|
+
* @param {string=} matchWriteToken - Return node(s) matching the specified write token
|
|
621
623
|
*
|
|
622
624
|
* @return {Promise<Array<Object>>} - A list of nodes in the space matching the parameters
|
|
623
625
|
*/
|
|
624
|
-
async SpaceNodes({matchEndpoint, matchNodeId}={}) {
|
|
626
|
+
async SpaceNodes({matchEndpoint, matchNodeId, matchWriteToken}={}) {
|
|
625
627
|
let nodes;
|
|
626
628
|
this.SetStaticToken();
|
|
627
629
|
|
|
@@ -665,6 +667,7 @@ class ElvClient {
|
|
|
665
667
|
});
|
|
666
668
|
} else if(matchNodeId) {
|
|
667
669
|
this.SetStaticToken();
|
|
670
|
+
|
|
668
671
|
let node = await this.utils.ResponseToJson(
|
|
669
672
|
this.HttpClient.Request({
|
|
670
673
|
path: UrlJoin("nodes", matchNodeId),
|
|
@@ -677,6 +680,24 @@ class ElvClient {
|
|
|
677
680
|
|
|
678
681
|
this.ClearStaticToken();
|
|
679
682
|
return [node];
|
|
683
|
+
} else if(matchWriteToken) {
|
|
684
|
+
this.SetStaticToken();
|
|
685
|
+
|
|
686
|
+
const {nodes} = await this.utils.ResponseToJson(
|
|
687
|
+
this.HttpClient.Request({
|
|
688
|
+
path: UrlJoin("nodes"),
|
|
689
|
+
method: "GET",
|
|
690
|
+
headers: {
|
|
691
|
+
Authorization: `Bearer ${this.staticToken}`
|
|
692
|
+
},
|
|
693
|
+
queryParams: {
|
|
694
|
+
token: matchWriteToken
|
|
695
|
+
}
|
|
696
|
+
})
|
|
697
|
+
);
|
|
698
|
+
|
|
699
|
+
this.ClearStaticToken();
|
|
700
|
+
return nodes;
|
|
680
701
|
}
|
|
681
702
|
}
|
|
682
703
|
|
|
@@ -694,7 +715,50 @@ class ElvClient {
|
|
|
694
715
|
};
|
|
695
716
|
}
|
|
696
717
|
|
|
697
|
-
|
|
718
|
+
/**
|
|
719
|
+
* Return node url for a given write token via a network call
|
|
720
|
+
*
|
|
721
|
+
* @methodGroup Nodes
|
|
722
|
+
* @namedParams
|
|
723
|
+
* @param {string} writeToken - The write token to match to a node
|
|
724
|
+
*
|
|
725
|
+
* @returns {Promise<string>} - The node url for a write token
|
|
726
|
+
*/
|
|
727
|
+
async WriteTokenNodeUrlNetwork({writeToken}) {
|
|
728
|
+
ValidateWriteToken(writeToken);
|
|
729
|
+
|
|
730
|
+
const nodes = await this.SpaceNodes({matchWriteToken: writeToken});
|
|
731
|
+
|
|
732
|
+
const nodeUrl = (
|
|
733
|
+
nodes &&
|
|
734
|
+
nodes[0] &&
|
|
735
|
+
nodes[0].services &&
|
|
736
|
+
nodes[0].services.fabric_api &&
|
|
737
|
+
nodes[0].services.fabric_api.urls &&
|
|
738
|
+
nodes[0].services.fabric_api.urls[0]
|
|
739
|
+
);
|
|
740
|
+
|
|
741
|
+
if(!nodeUrl) {
|
|
742
|
+
console.error(`No node url found for write token: ${writeToken}`);
|
|
743
|
+
|
|
744
|
+
return "";
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
return nodeUrl ? nodeUrl.toString() : undefined;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* Return node url for a given write token via local lookup
|
|
752
|
+
*
|
|
753
|
+
* @methodGroup Nodes
|
|
754
|
+
* @namedParams
|
|
755
|
+
* @param {string} writeToken - The write token to match to a node
|
|
756
|
+
*
|
|
757
|
+
* @returns {string} - The node url for a write token
|
|
758
|
+
*/
|
|
759
|
+
WriteTokenNodeUrlLocal({writeToken}) {
|
|
760
|
+
ValidateWriteToken(writeToken);
|
|
761
|
+
|
|
698
762
|
const nodeUrl = this.HttpClient.draftURIs[writeToken];
|
|
699
763
|
|
|
700
764
|
return nodeUrl ? nodeUrl.toString() : undefined;
|