amazon-creators-api 1.2.0
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/LICENSE.txt +202 -0
- package/README.md +102 -0
- package/dist/ApiClient.d.ts +273 -0
- package/dist/ApiClient.js +895 -0
- package/dist/api/DefaultApi.d.ts +124 -0
- package/dist/api/DefaultApi.js +409 -0
- package/dist/api/TypedDefaultApi.d.ts +132 -0
- package/dist/api/TypedDefaultApi.js +223 -0
- package/dist/auth/OAuth2Config.d.ts +78 -0
- package/dist/auth/OAuth2Config.js +152 -0
- package/dist/auth/OAuth2TokenManager.d.ts +38 -0
- package/dist/auth/OAuth2TokenManager.js +177 -0
- package/dist/index.d.ts +94 -0
- package/dist/index.js +657 -0
- package/dist/model/AccessDeniedExceptionResponseContent.d.ts +42 -0
- package/dist/model/AccessDeniedExceptionResponseContent.js +139 -0
- package/dist/model/AccessDeniedReason.d.ts +32 -0
- package/dist/model/AccessDeniedReason.js +65 -0
- package/dist/model/Availability.d.ts +27 -0
- package/dist/model/Availability.js +60 -0
- package/dist/model/BrowseNode.d.ts +35 -0
- package/dist/model/BrowseNode.js +184 -0
- package/dist/model/BrowseNodeAncestor.d.ts +32 -0
- package/dist/model/BrowseNodeAncestor.js +129 -0
- package/dist/model/BrowseNodeChild.d.ts +31 -0
- package/dist/model/BrowseNodeChild.js +116 -0
- package/dist/model/BrowseNodeInfo.d.ts +30 -0
- package/dist/model/BrowseNodeInfo.js +128 -0
- package/dist/model/BrowseNodesResult.d.ts +29 -0
- package/dist/model/BrowseNodesResult.js +114 -0
- package/dist/model/ByLineInfo.d.ts +31 -0
- package/dist/model/ByLineInfo.js +141 -0
- package/dist/model/Classifications.d.ts +30 -0
- package/dist/model/Classifications.js +107 -0
- package/dist/model/Condition.d.ts +27 -0
- package/dist/model/Condition.js +60 -0
- package/dist/model/ContentInfo.d.ts +32 -0
- package/dist/model/ContentInfo.js +135 -0
- package/dist/model/ContentRating.d.ts +29 -0
- package/dist/model/ContentRating.js +94 -0
- package/dist/model/Contributor.d.ts +32 -0
- package/dist/model/Contributor.js +128 -0
- package/dist/model/CustomerReviews.d.ts +30 -0
- package/dist/model/CustomerReviews.js +102 -0
- package/dist/model/DealDetails.d.ts +34 -0
- package/dist/model/DealDetails.js +144 -0
- package/dist/model/DeliveryFlag.d.ts +37 -0
- package/dist/model/DeliveryFlag.js +70 -0
- package/dist/model/DimensionBasedAttribute.d.ts +32 -0
- package/dist/model/DimensionBasedAttribute.js +133 -0
- package/dist/model/ErrorData.d.ts +41 -0
- package/dist/model/ErrorData.js +131 -0
- package/dist/model/ExternalIds.d.ts +31 -0
- package/dist/model/ExternalIds.js +120 -0
- package/dist/model/Feed.d.ts +44 -0
- package/dist/model/Feed.js +152 -0
- package/dist/model/GetBrowseNodesRequestContent.d.ts +43 -0
- package/dist/model/GetBrowseNodesRequestContent.js +158 -0
- package/dist/model/GetBrowseNodesResource.d.ts +27 -0
- package/dist/model/GetBrowseNodesResource.js +60 -0
- package/dist/model/GetBrowseNodesResponseContent.d.ts +30 -0
- package/dist/model/GetBrowseNodesResponseContent.js +128 -0
- package/dist/model/GetFeedRequestContent.d.ts +38 -0
- package/dist/model/GetFeedRequestContent.js +114 -0
- package/dist/model/GetFeedResponseContent.d.ts +38 -0
- package/dist/model/GetFeedResponseContent.js +114 -0
- package/dist/model/GetItemsRequestContent.d.ts +45 -0
- package/dist/model/GetItemsRequestContent.js +188 -0
- package/dist/model/GetItemsResource.d.ts +187 -0
- package/dist/model/GetItemsResource.js +220 -0
- package/dist/model/GetItemsResponseContent.d.ts +30 -0
- package/dist/model/GetItemsResponseContent.js +128 -0
- package/dist/model/GetReportRequestContent.d.ts +38 -0
- package/dist/model/GetReportRequestContent.js +114 -0
- package/dist/model/GetReportResponseContent.d.ts +38 -0
- package/dist/model/GetReportResponseContent.js +114 -0
- package/dist/model/GetVariationsRequestContent.d.ts +48 -0
- package/dist/model/GetVariationsRequestContent.js +209 -0
- package/dist/model/GetVariationsResource.d.ts +202 -0
- package/dist/model/GetVariationsResource.js +235 -0
- package/dist/model/GetVariationsResponseContent.d.ts +30 -0
- package/dist/model/GetVariationsResponseContent.js +128 -0
- package/dist/model/ImageSize.d.ts +31 -0
- package/dist/model/ImageSize.js +108 -0
- package/dist/model/ImageType.d.ts +32 -0
- package/dist/model/ImageType.js +133 -0
- package/dist/model/Images.d.ts +30 -0
- package/dist/model/Images.js +127 -0
- package/dist/model/InternalServerExceptionResponseContent.d.ts +40 -0
- package/dist/model/InternalServerExceptionResponseContent.js +128 -0
- package/dist/model/Item.d.ts +38 -0
- package/dist/model/Item.js +228 -0
- package/dist/model/ItemInfo.d.ts +39 -0
- package/dist/model/ItemInfo.js +234 -0
- package/dist/model/ItemsResult.d.ts +29 -0
- package/dist/model/ItemsResult.js +114 -0
- package/dist/model/LanguageType.d.ts +30 -0
- package/dist/model/LanguageType.js +104 -0
- package/dist/model/Languages.d.ts +31 -0
- package/dist/model/Languages.js +138 -0
- package/dist/model/ListFeedsResponseContent.d.ts +29 -0
- package/dist/model/ListFeedsResponseContent.js +112 -0
- package/dist/model/ListReportsResponseContent.d.ts +38 -0
- package/dist/model/ListReportsResponseContent.js +132 -0
- package/dist/model/ManufactureInfo.d.ts +31 -0
- package/dist/model/ManufactureInfo.js +120 -0
- package/dist/model/Money.d.ts +31 -0
- package/dist/model/Money.js +112 -0
- package/dist/model/MultiValuedAttribute.d.ts +31 -0
- package/dist/model/MultiValuedAttribute.js +117 -0
- package/dist/model/OfferAvailabilityV2.d.ts +32 -0
- package/dist/model/OfferAvailabilityV2.js +120 -0
- package/dist/model/OfferConditionV2.d.ts +31 -0
- package/dist/model/OfferConditionV2.js +116 -0
- package/dist/model/OfferListingV2.d.ts +37 -0
- package/dist/model/OfferListingV2.js +189 -0
- package/dist/model/OfferLoyaltyPointsV2.d.ts +29 -0
- package/dist/model/OfferLoyaltyPointsV2.js +88 -0
- package/dist/model/OfferMerchantInfoV2.d.ts +30 -0
- package/dist/model/OfferMerchantInfoV2.js +104 -0
- package/dist/model/OfferPriceV2.d.ts +32 -0
- package/dist/model/OfferPriceV2.js +135 -0
- package/dist/model/OfferSavingBasis.d.ts +31 -0
- package/dist/model/OfferSavingBasis.js +115 -0
- package/dist/model/OfferSavings.d.ts +30 -0
- package/dist/model/OfferSavings.js +102 -0
- package/dist/model/OfferType.d.ts +32 -0
- package/dist/model/OfferType.js +65 -0
- package/dist/model/OffersV2.d.ts +29 -0
- package/dist/model/OffersV2.js +114 -0
- package/dist/model/ProductInfo.d.ts +34 -0
- package/dist/model/ProductInfo.js +162 -0
- package/dist/model/Rating.d.ts +29 -0
- package/dist/model/Rating.js +88 -0
- package/dist/model/Refinement.d.ts +31 -0
- package/dist/model/Refinement.js +138 -0
- package/dist/model/RefinementBin.d.ts +30 -0
- package/dist/model/RefinementBin.js +104 -0
- package/dist/model/ReportMetadata.d.ts +44 -0
- package/dist/model/ReportMetadata.js +152 -0
- package/dist/model/ResourceNotFoundExceptionResponseContent.d.ts +44 -0
- package/dist/model/ResourceNotFoundExceptionResponseContent.js +156 -0
- package/dist/model/SavingBasisType.d.ts +37 -0
- package/dist/model/SavingBasisType.js +70 -0
- package/dist/model/SearchItemsRequestContent.d.ts +51 -0
- package/dist/model/SearchItemsRequestContent.js +343 -0
- package/dist/model/SearchItemsResource.d.ts +192 -0
- package/dist/model/SearchItemsResource.js +225 -0
- package/dist/model/SearchItemsResponseContent.d.ts +30 -0
- package/dist/model/SearchItemsResponseContent.js +128 -0
- package/dist/model/SearchRefinements.d.ts +31 -0
- package/dist/model/SearchRefinements.js +140 -0
- package/dist/model/SearchResult.d.ts +32 -0
- package/dist/model/SearchResult.js +148 -0
- package/dist/model/SingleBooleanValuedAttribute.d.ts +31 -0
- package/dist/model/SingleBooleanValuedAttribute.js +112 -0
- package/dist/model/SingleIntegerValuedAttribute.d.ts +31 -0
- package/dist/model/SingleIntegerValuedAttribute.js +112 -0
- package/dist/model/SingleStringValuedAttribute.d.ts +31 -0
- package/dist/model/SingleStringValuedAttribute.js +116 -0
- package/dist/model/SortBy.d.ts +47 -0
- package/dist/model/SortBy.js +80 -0
- package/dist/model/TechnicalInfo.d.ts +30 -0
- package/dist/model/TechnicalInfo.js +108 -0
- package/dist/model/ThrottleExceptionResponseContent.d.ts +42 -0
- package/dist/model/ThrottleExceptionResponseContent.js +152 -0
- package/dist/model/TradeInInfo.d.ts +30 -0
- package/dist/model/TradeInInfo.js +102 -0
- package/dist/model/TradeInPrice.d.ts +31 -0
- package/dist/model/TradeInPrice.js +112 -0
- package/dist/model/UnauthorizedExceptionReason.d.ts +62 -0
- package/dist/model/UnauthorizedExceptionReason.js +95 -0
- package/dist/model/UnauthorizedExceptionResponseContent.d.ts +41 -0
- package/dist/model/UnauthorizedExceptionResponseContent.js +137 -0
- package/dist/model/UnitBasedAttribute.d.ts +32 -0
- package/dist/model/UnitBasedAttribute.js +124 -0
- package/dist/model/ValidationExceptionField.d.ts +41 -0
- package/dist/model/ValidationExceptionField.js +129 -0
- package/dist/model/ValidationExceptionReason.d.ts +47 -0
- package/dist/model/ValidationExceptionReason.js +80 -0
- package/dist/model/ValidationExceptionResponseContent.d.ts +43 -0
- package/dist/model/ValidationExceptionResponseContent.js +170 -0
- package/dist/model/VariationAttribute.d.ts +30 -0
- package/dist/model/VariationAttribute.js +104 -0
- package/dist/model/VariationDimension.d.ts +32 -0
- package/dist/model/VariationDimension.js +132 -0
- package/dist/model/VariationSummary.d.ts +32 -0
- package/dist/model/VariationSummary.js +146 -0
- package/dist/model/VariationSummaryPrice.d.ts +30 -0
- package/dist/model/VariationSummaryPrice.js +107 -0
- package/dist/model/VariationsResult.d.ts +30 -0
- package/dist/model/VariationsResult.js +128 -0
- package/dist/model/WebsiteSalesRank.d.ts +32 -0
- package/dist/model/WebsiteSalesRank.js +124 -0
- package/package.json +67 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
5
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
6
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
7
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
8
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
9
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
10
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
12
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
|
+
/**
|
|
14
|
+
* Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
15
|
+
*
|
|
16
|
+
* Licensed under the Apache License, Version 2.0 (the "License").
|
|
17
|
+
* You may not use this file except in compliance with the License.
|
|
18
|
+
* A copy of the License is located at
|
|
19
|
+
*
|
|
20
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
21
|
+
*
|
|
22
|
+
* or in the "license" file accompanying this file. This file is distributed
|
|
23
|
+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
24
|
+
* express or implied. See the License for the specific language governing
|
|
25
|
+
* permissions and limitations under the License.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* OAuth2TokenManager
|
|
30
|
+
* Manages OAuth2 token lifecycle including acquisition, caching, and refresh
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
var superagent = require("superagent");
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* OAuth2 token manager that handles token acquisition, caching, and automatic refresh
|
|
38
|
+
* Note: ApiClient automatically manages token caching for optimal performance.
|
|
39
|
+
* Direct instantiation is only needed for advanced use cases.
|
|
40
|
+
* @class OAuth2TokenManager
|
|
41
|
+
*/
|
|
42
|
+
var OAuth2TokenManager = /*#__PURE__*/function () {
|
|
43
|
+
/**
|
|
44
|
+
* Creates an OAuth2TokenManager instance
|
|
45
|
+
* @param {OAuth2Config} config - The OAuth2 configuration
|
|
46
|
+
*/
|
|
47
|
+
function OAuth2TokenManager(config) {
|
|
48
|
+
_classCallCheck(this, OAuth2TokenManager);
|
|
49
|
+
this.config = config;
|
|
50
|
+
this.accessToken = null;
|
|
51
|
+
this.expiresAt = null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Gets a valid OAuth2 access token, refreshing if necessary
|
|
56
|
+
* @returns {Promise<string>} A promise that resolves to a valid access token
|
|
57
|
+
* @throws {Error} If token acquisition fails
|
|
58
|
+
*/
|
|
59
|
+
return _createClass(OAuth2TokenManager, [{
|
|
60
|
+
key: "getToken",
|
|
61
|
+
value: (function () {
|
|
62
|
+
var _getToken = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
63
|
+
return _regenerator().w(function (_context) {
|
|
64
|
+
while (1) switch (_context.n) {
|
|
65
|
+
case 0:
|
|
66
|
+
if (!this.isTokenValid()) {
|
|
67
|
+
_context.n = 1;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
return _context.a(2, this.accessToken);
|
|
71
|
+
case 1:
|
|
72
|
+
_context.n = 2;
|
|
73
|
+
return this.refreshToken();
|
|
74
|
+
case 2:
|
|
75
|
+
return _context.a(2, _context.v);
|
|
76
|
+
}
|
|
77
|
+
}, _callee, this);
|
|
78
|
+
}));
|
|
79
|
+
function getToken() {
|
|
80
|
+
return _getToken.apply(this, arguments);
|
|
81
|
+
}
|
|
82
|
+
return getToken;
|
|
83
|
+
}()
|
|
84
|
+
/**
|
|
85
|
+
* Checks if the current token is valid and not expired
|
|
86
|
+
* @returns {boolean} True if the token is valid, false otherwise
|
|
87
|
+
*/
|
|
88
|
+
)
|
|
89
|
+
}, {
|
|
90
|
+
key: "isTokenValid",
|
|
91
|
+
value: function isTokenValid() {
|
|
92
|
+
return this.accessToken && this.expiresAt && Date.now() < this.expiresAt;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Refreshes the OAuth2 access token using client credentials grant
|
|
97
|
+
* @returns {Promise<string>} A promise that resolves to the new access token
|
|
98
|
+
* @throws {Error} If token refresh fails
|
|
99
|
+
*/
|
|
100
|
+
}, {
|
|
101
|
+
key: "refreshToken",
|
|
102
|
+
value: (function () {
|
|
103
|
+
var _refreshToken = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
104
|
+
var response, requestBody, data, expiresInMs, _t;
|
|
105
|
+
return _regenerator().w(function (_context2) {
|
|
106
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
107
|
+
case 0:
|
|
108
|
+
_context2.p = 0;
|
|
109
|
+
if (!this.config.isLwa()) {
|
|
110
|
+
_context2.n = 2;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
_context2.n = 1;
|
|
114
|
+
return superagent.post(this.config.getCognitoEndpoint()).set('Content-Type', 'application/json').send({
|
|
115
|
+
grant_type: this.config.getGrantType(),
|
|
116
|
+
client_id: this.config.getCredentialId(),
|
|
117
|
+
client_secret: this.config.getCredentialSecret(),
|
|
118
|
+
scope: this.config.getScope()
|
|
119
|
+
});
|
|
120
|
+
case 1:
|
|
121
|
+
response = _context2.v;
|
|
122
|
+
_context2.n = 4;
|
|
123
|
+
break;
|
|
124
|
+
case 2:
|
|
125
|
+
// Cognito (v2.x) uses form-encoded
|
|
126
|
+
requestBody = new URLSearchParams({
|
|
127
|
+
'grant_type': this.config.getGrantType(),
|
|
128
|
+
'client_id': this.config.getCredentialId(),
|
|
129
|
+
'client_secret': this.config.getCredentialSecret(),
|
|
130
|
+
'scope': this.config.getScope()
|
|
131
|
+
}).toString();
|
|
132
|
+
_context2.n = 3;
|
|
133
|
+
return superagent.post(this.config.getCognitoEndpoint()).set('Content-Type', 'application/x-www-form-urlencoded').send(requestBody);
|
|
134
|
+
case 3:
|
|
135
|
+
response = _context2.v;
|
|
136
|
+
case 4:
|
|
137
|
+
data = response.body;
|
|
138
|
+
if (data.access_token) {
|
|
139
|
+
_context2.n = 5;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
throw new Error('No access token received from OAuth2 endpoint');
|
|
143
|
+
case 5:
|
|
144
|
+
this.accessToken = data.access_token;
|
|
145
|
+
// Set expiration time with a 30-second buffer to avoid edge cases
|
|
146
|
+
expiresInMs = (data.expires_in - 30) * 1000;
|
|
147
|
+
this.expiresAt = Date.now() + expiresInMs;
|
|
148
|
+
return _context2.a(2, this.accessToken);
|
|
149
|
+
case 6:
|
|
150
|
+
_context2.p = 6;
|
|
151
|
+
_t = _context2.v;
|
|
152
|
+
// Clear existing token on failure
|
|
153
|
+
this.clearToken();
|
|
154
|
+
throw _t;
|
|
155
|
+
case 7:
|
|
156
|
+
return _context2.a(2);
|
|
157
|
+
}
|
|
158
|
+
}, _callee2, this, [[0, 6]]);
|
|
159
|
+
}));
|
|
160
|
+
function refreshToken() {
|
|
161
|
+
return _refreshToken.apply(this, arguments);
|
|
162
|
+
}
|
|
163
|
+
return refreshToken;
|
|
164
|
+
}()
|
|
165
|
+
/**
|
|
166
|
+
* Clears the cached token, forcing a refresh on the next getToken() call
|
|
167
|
+
*/
|
|
168
|
+
)
|
|
169
|
+
}, {
|
|
170
|
+
key: "clearToken",
|
|
171
|
+
value: function clearToken() {
|
|
172
|
+
this.accessToken = null;
|
|
173
|
+
this.expiresAt = null;
|
|
174
|
+
}
|
|
175
|
+
}]);
|
|
176
|
+
}();
|
|
177
|
+
module.exports = OAuth2TokenManager;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import ApiClient from './ApiClient';
|
|
2
|
+
import AccessDeniedExceptionResponseContent from './model/AccessDeniedExceptionResponseContent';
|
|
3
|
+
import AccessDeniedReason from './model/AccessDeniedReason';
|
|
4
|
+
import Availability from './model/Availability';
|
|
5
|
+
import BrowseNode from './model/BrowseNode';
|
|
6
|
+
import BrowseNodeAncestor from './model/BrowseNodeAncestor';
|
|
7
|
+
import BrowseNodeChild from './model/BrowseNodeChild';
|
|
8
|
+
import BrowseNodeInfo from './model/BrowseNodeInfo';
|
|
9
|
+
import BrowseNodesResult from './model/BrowseNodesResult';
|
|
10
|
+
import ByLineInfo from './model/ByLineInfo';
|
|
11
|
+
import Classifications from './model/Classifications';
|
|
12
|
+
import Condition from './model/Condition';
|
|
13
|
+
import ContentInfo from './model/ContentInfo';
|
|
14
|
+
import ContentRating from './model/ContentRating';
|
|
15
|
+
import Contributor from './model/Contributor';
|
|
16
|
+
import CustomerReviews from './model/CustomerReviews';
|
|
17
|
+
import DealDetails from './model/DealDetails';
|
|
18
|
+
import DeliveryFlag from './model/DeliveryFlag';
|
|
19
|
+
import DimensionBasedAttribute from './model/DimensionBasedAttribute';
|
|
20
|
+
import ErrorData from './model/ErrorData';
|
|
21
|
+
import ExternalIds from './model/ExternalIds';
|
|
22
|
+
import Feed from './model/Feed';
|
|
23
|
+
import GetBrowseNodesRequestContent from './model/GetBrowseNodesRequestContent';
|
|
24
|
+
import GetBrowseNodesResource from './model/GetBrowseNodesResource';
|
|
25
|
+
import GetBrowseNodesResponseContent from './model/GetBrowseNodesResponseContent';
|
|
26
|
+
import GetFeedRequestContent from './model/GetFeedRequestContent';
|
|
27
|
+
import GetFeedResponseContent from './model/GetFeedResponseContent';
|
|
28
|
+
import GetItemsRequestContent from './model/GetItemsRequestContent';
|
|
29
|
+
import GetItemsResource from './model/GetItemsResource';
|
|
30
|
+
import GetItemsResponseContent from './model/GetItemsResponseContent';
|
|
31
|
+
import GetReportRequestContent from './model/GetReportRequestContent';
|
|
32
|
+
import GetReportResponseContent from './model/GetReportResponseContent';
|
|
33
|
+
import GetVariationsRequestContent from './model/GetVariationsRequestContent';
|
|
34
|
+
import GetVariationsResource from './model/GetVariationsResource';
|
|
35
|
+
import GetVariationsResponseContent from './model/GetVariationsResponseContent';
|
|
36
|
+
import ImageSize from './model/ImageSize';
|
|
37
|
+
import ImageType from './model/ImageType';
|
|
38
|
+
import Images from './model/Images';
|
|
39
|
+
import InternalServerExceptionResponseContent from './model/InternalServerExceptionResponseContent';
|
|
40
|
+
import Item from './model/Item';
|
|
41
|
+
import ItemInfo from './model/ItemInfo';
|
|
42
|
+
import ItemsResult from './model/ItemsResult';
|
|
43
|
+
import LanguageType from './model/LanguageType';
|
|
44
|
+
import Languages from './model/Languages';
|
|
45
|
+
import ListFeedsResponseContent from './model/ListFeedsResponseContent';
|
|
46
|
+
import ListReportsResponseContent from './model/ListReportsResponseContent';
|
|
47
|
+
import ManufactureInfo from './model/ManufactureInfo';
|
|
48
|
+
import Money from './model/Money';
|
|
49
|
+
import MultiValuedAttribute from './model/MultiValuedAttribute';
|
|
50
|
+
import OfferAvailabilityV2 from './model/OfferAvailabilityV2';
|
|
51
|
+
import OfferConditionV2 from './model/OfferConditionV2';
|
|
52
|
+
import OfferListingV2 from './model/OfferListingV2';
|
|
53
|
+
import OfferLoyaltyPointsV2 from './model/OfferLoyaltyPointsV2';
|
|
54
|
+
import OfferMerchantInfoV2 from './model/OfferMerchantInfoV2';
|
|
55
|
+
import OfferPriceV2 from './model/OfferPriceV2';
|
|
56
|
+
import OfferSavingBasis from './model/OfferSavingBasis';
|
|
57
|
+
import OfferSavings from './model/OfferSavings';
|
|
58
|
+
import OfferType from './model/OfferType';
|
|
59
|
+
import OffersV2 from './model/OffersV2';
|
|
60
|
+
import ProductInfo from './model/ProductInfo';
|
|
61
|
+
import Rating from './model/Rating';
|
|
62
|
+
import Refinement from './model/Refinement';
|
|
63
|
+
import RefinementBin from './model/RefinementBin';
|
|
64
|
+
import ReportMetadata from './model/ReportMetadata';
|
|
65
|
+
import ResourceNotFoundExceptionResponseContent from './model/ResourceNotFoundExceptionResponseContent';
|
|
66
|
+
import SavingBasisType from './model/SavingBasisType';
|
|
67
|
+
import SearchItemsRequestContent from './model/SearchItemsRequestContent';
|
|
68
|
+
import SearchItemsResource from './model/SearchItemsResource';
|
|
69
|
+
import SearchItemsResponseContent from './model/SearchItemsResponseContent';
|
|
70
|
+
import SearchRefinements from './model/SearchRefinements';
|
|
71
|
+
import SearchResult from './model/SearchResult';
|
|
72
|
+
import SingleBooleanValuedAttribute from './model/SingleBooleanValuedAttribute';
|
|
73
|
+
import SingleIntegerValuedAttribute from './model/SingleIntegerValuedAttribute';
|
|
74
|
+
import SingleStringValuedAttribute from './model/SingleStringValuedAttribute';
|
|
75
|
+
import SortBy from './model/SortBy';
|
|
76
|
+
import TechnicalInfo from './model/TechnicalInfo';
|
|
77
|
+
import ThrottleExceptionResponseContent from './model/ThrottleExceptionResponseContent';
|
|
78
|
+
import TradeInInfo from './model/TradeInInfo';
|
|
79
|
+
import TradeInPrice from './model/TradeInPrice';
|
|
80
|
+
import UnauthorizedExceptionReason from './model/UnauthorizedExceptionReason';
|
|
81
|
+
import UnauthorizedExceptionResponseContent from './model/UnauthorizedExceptionResponseContent';
|
|
82
|
+
import UnitBasedAttribute from './model/UnitBasedAttribute';
|
|
83
|
+
import ValidationExceptionField from './model/ValidationExceptionField';
|
|
84
|
+
import ValidationExceptionReason from './model/ValidationExceptionReason';
|
|
85
|
+
import ValidationExceptionResponseContent from './model/ValidationExceptionResponseContent';
|
|
86
|
+
import VariationAttribute from './model/VariationAttribute';
|
|
87
|
+
import VariationDimension from './model/VariationDimension';
|
|
88
|
+
import VariationSummary from './model/VariationSummary';
|
|
89
|
+
import VariationSummaryPrice from './model/VariationSummaryPrice';
|
|
90
|
+
import VariationsResult from './model/VariationsResult';
|
|
91
|
+
import WebsiteSalesRank from './model/WebsiteSalesRank';
|
|
92
|
+
import DefaultApi from './api/DefaultApi';
|
|
93
|
+
import TypedDefaultApi from './api/TypedDefaultApi';
|
|
94
|
+
export { ApiClient, AccessDeniedExceptionResponseContent, AccessDeniedReason, Availability, BrowseNode, BrowseNodeAncestor, BrowseNodeChild, BrowseNodeInfo, BrowseNodesResult, ByLineInfo, Classifications, Condition, ContentInfo, ContentRating, Contributor, CustomerReviews, DealDetails, DeliveryFlag, DimensionBasedAttribute, ErrorData, ExternalIds, Feed, GetBrowseNodesRequestContent, GetBrowseNodesResource, GetBrowseNodesResponseContent, GetFeedRequestContent, GetFeedResponseContent, GetItemsRequestContent, GetItemsResource, GetItemsResponseContent, GetReportRequestContent, GetReportResponseContent, GetVariationsRequestContent, GetVariationsResource, GetVariationsResponseContent, ImageSize, ImageType, Images, InternalServerExceptionResponseContent, Item, ItemInfo, ItemsResult, LanguageType, Languages, ListFeedsResponseContent, ListReportsResponseContent, ManufactureInfo, Money, MultiValuedAttribute, OfferAvailabilityV2, OfferConditionV2, OfferListingV2, OfferLoyaltyPointsV2, OfferMerchantInfoV2, OfferPriceV2, OfferSavingBasis, OfferSavings, OfferType, OffersV2, ProductInfo, Rating, Refinement, RefinementBin, ReportMetadata, ResourceNotFoundExceptionResponseContent, SavingBasisType, SearchItemsRequestContent, SearchItemsResource, SearchItemsResponseContent, SearchRefinements, SearchResult, SingleBooleanValuedAttribute, SingleIntegerValuedAttribute, SingleStringValuedAttribute, SortBy, TechnicalInfo, ThrottleExceptionResponseContent, TradeInInfo, TradeInPrice, UnauthorizedExceptionReason, UnauthorizedExceptionResponseContent, UnitBasedAttribute, ValidationExceptionField, ValidationExceptionReason, ValidationExceptionResponseContent, VariationAttribute, VariationDimension, VariationSummary, VariationSummaryPrice, VariationsResult, WebsiteSalesRank, DefaultApi, TypedDefaultApi };
|