ebay-api 8.2.0 → 8.4.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.
Files changed (44) hide show
  1. package/README.md +37 -2
  2. package/dist/api/digitalSignature.d.ts +43 -0
  3. package/dist/api/digitalSignature.js +105 -0
  4. package/dist/api/index.d.ts +2 -0
  5. package/dist/api/index.js +18 -0
  6. package/dist/api/restful/developer/keyManagement/index.d.ts +2 -4
  7. package/dist/api/restful/developer/keyManagement/index.js +5 -3
  8. package/dist/api/restful/index.d.ts +12 -7
  9. package/dist/api/restful/index.js +30 -17
  10. package/dist/api/restful/sell/marketing/index.d.ts +184 -1
  11. package/dist/api/restful/sell/marketing/index.js +260 -0
  12. package/dist/api/traditional/XMLRequest.d.ts +3 -1
  13. package/dist/api/traditional/XMLRequest.js +3 -1
  14. package/dist/api/traditional/index.d.ts +1 -1
  15. package/dist/api/traditional/index.js +25 -15
  16. package/dist/eBayApi.d.ts +2 -1
  17. package/dist/eBayApi.js +12 -1
  18. package/dist/ebay-api.min.mjs +1 -1
  19. package/dist/errors/index.js +5 -0
  20. package/dist/types/apiTypes.d.ts +7 -0
  21. package/dist/types/restfulTypes.d.ts +90 -0
  22. package/dist/types/traditonalTypes.d.ts +2 -1
  23. package/lib/api/digitalSignature.d.ts +43 -0
  24. package/lib/api/digitalSignature.js +112 -0
  25. package/lib/api/index.d.ts +2 -0
  26. package/lib/api/index.js +18 -0
  27. package/lib/api/restful/developer/keyManagement/index.d.ts +2 -4
  28. package/lib/api/restful/developer/keyManagement/index.js +5 -3
  29. package/lib/api/restful/index.d.ts +12 -7
  30. package/lib/api/restful/index.js +34 -21
  31. package/lib/api/restful/sell/marketing/index.d.ts +184 -1
  32. package/lib/api/restful/sell/marketing/index.js +260 -0
  33. package/lib/api/traditional/XMLRequest.d.ts +3 -1
  34. package/lib/api/traditional/XMLRequest.js +2 -0
  35. package/lib/api/traditional/index.d.ts +1 -1
  36. package/lib/api/traditional/index.js +29 -19
  37. package/lib/eBayApi.d.ts +2 -1
  38. package/lib/eBayApi.js +12 -1
  39. package/lib/ebay-api.min.js +1 -1
  40. package/lib/errors/index.js +5 -0
  41. package/lib/types/apiTypes.d.ts +7 -0
  42. package/lib/types/restfulTypes.d.ts +90 -0
  43. package/lib/types/traditonalTypes.d.ts +2 -1
  44. package/package.json +2 -1
@@ -27,8 +27,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  const qs_1 = require("qs");
30
- const index_js_1 = __importDefault(require("../index.js"));
31
- const index_js_2 = require("../../errors/index.js");
30
+ const index_js_1 = require("../../errors/index.js");
31
+ const index_js_2 = __importDefault(require("../index.js"));
32
32
  const index_js_3 = __importDefault(require("./clientAlerts/index.js"));
33
33
  const index_js_4 = __importDefault(require("./finding/index.js"));
34
34
  const index_js_5 = __importDefault(require("./merchandising/index.js"));
@@ -38,7 +38,7 @@ const XMLRequest_js_1 = __importStar(require("./XMLRequest.js"));
38
38
  /**
39
39
  * Traditional eBay API.
40
40
  */
41
- class Traditional extends index_js_1.default {
41
+ class Traditional extends index_js_2.default {
42
42
  constructor() {
43
43
  super(...arguments);
44
44
  this.createXMLRequest = (callName, api) => async (fields, opts) => {
@@ -48,7 +48,7 @@ class Traditional extends index_js_1.default {
48
48
  }
49
49
  catch (error) {
50
50
  // Try to refresh the token.
51
- if (this.config.autoRefreshToken && (error.name === index_js_2.EBayIAFTokenExpired.name || error.name === index_js_2.EBayIAFTokenInvalid.name)) {
51
+ if (this.config.autoRefreshToken && (error.name === index_js_1.EBayIAFTokenExpired.name || error.name === index_js_1.EBayIAFTokenInvalid.name)) {
52
52
  return await this.request(apiConfig, api, callName, fields, true);
53
53
  }
54
54
  throw error;
@@ -56,17 +56,15 @@ class Traditional extends index_js_1.default {
56
56
  };
57
57
  }
58
58
  createTradingApi() {
59
- if (!this.config.devId) {
60
- throw new Error('devId is required for trading API.');
61
- }
62
59
  if (typeof this.config.siteId !== 'number') {
63
60
  throw new Error('siteId is required for trading API.');
64
61
  }
65
62
  return this.createTraditionalXMLApi({
66
63
  endpoint: {
67
- production: 'https://api.ebay.com/ws/api.dll',
68
- sandbox: 'https://api.sandbox.ebay.com/ws/api.dll'
64
+ production: 'api.ebay.com',
65
+ sandbox: 'api.sandbox.ebay.com'
69
66
  },
67
+ path: '/ws/api.dll',
70
68
  calls: index_js_7.default,
71
69
  xmlns: 'urn:ebay:apis:eBLBaseComponents',
72
70
  headers: (callName, accessToken) => ({
@@ -86,9 +84,10 @@ class Traditional extends index_js_1.default {
86
84
  }
87
85
  return this.createTraditionalXMLApi({
88
86
  endpoint: {
89
- production: 'https://open.api.ebay.com/shopping',
90
- sandbox: 'https://open.api.sandbox.ebay.com/shopping'
87
+ production: 'open.api.ebay.com',
88
+ sandbox: 'open.api.sandbox.ebay.com'
91
89
  },
90
+ path: '/shopping',
92
91
  xmlns: 'urn:ebay:apis:eBLBaseComponents',
93
92
  calls: index_js_6.default,
94
93
  headers: (callName, accessToken) => ({
@@ -104,9 +103,10 @@ class Traditional extends index_js_1.default {
104
103
  createFindingApi() {
105
104
  return this.createTraditionalXMLApi({
106
105
  endpoint: {
107
- production: 'https://svcs.ebay.com/services/search/FindingService/v1',
108
- sandbox: 'https://svcs.sandbox.ebay.com/services/search/FindingService/v1'
106
+ production: 'svcs.ebay.com',
107
+ sandbox: 'svcs.sandbox.ebay.com'
109
108
  },
109
+ path: '/services/search/FindingService/v1',
110
110
  xmlns: 'http://www.ebay.com/marketplace/search/v1/services',
111
111
  calls: index_js_4.default,
112
112
  headers: (callName) => ({
@@ -121,9 +121,10 @@ class Traditional extends index_js_1.default {
121
121
  }
122
122
  const api = {
123
123
  endpoint: {
124
- production: 'https://clientalerts.ebay.com/ws/ecasvc/ClientAlerts',
125
- sandbox: 'https://clientalerts.sandbox.ebay.com/ws/ecasvc/ClientAlerts'
124
+ production: 'clientalerts.ebay.com',
125
+ sandbox: 'clientalerts.sandbox.ebay.com'
126
126
  },
127
+ path: '/ws/ecasvc/ClientAlerts',
127
128
  calls: index_js_3.default
128
129
  };
129
130
  const endpoint = api.endpoint[this.config.sandbox ? 'sandbox' : 'production'];
@@ -157,9 +158,10 @@ class Traditional extends index_js_1.default {
157
158
  createMerchandisingApi() {
158
159
  return this.createTraditionalXMLApi({
159
160
  endpoint: {
160
- production: 'https://svcs.ebay.com/MerchandisingService',
161
- sandbox: 'https://svcs.sandbox.ebay.com/MerchandisingService'
161
+ production: 'svcs.ebay.com',
162
+ sandbox: 'svcs.sandbox.ebay.com'
162
163
  },
164
+ path: '/MerchandisingService',
163
165
  xmlns: 'http://www.ebay.com/marketplace/services',
164
166
  calls: index_js_5.default,
165
167
  headers: (callName) => ({
@@ -181,21 +183,29 @@ class Traditional extends index_js_1.default {
181
183
  return await xmlRequest.request();
182
184
  }
183
185
  catch (e) {
184
- (0, index_js_2.handleEBayError)(e);
186
+ (0, index_js_1.handleEBayError)(e);
185
187
  }
186
188
  }
187
189
  async getConfig(api, callName, apiConfig) {
188
190
  const eBayAuthToken = this.auth.authNAuth.eBayAuthToken;
189
191
  const accessToken = !eBayAuthToken && apiConfig.useIaf ? (await this.auth.OAuth2.getAccessToken()) : null;
190
192
  const useIaf = !eBayAuthToken && accessToken;
193
+ const host = this.config.sandbox ? api.endpoint.sandbox : api.endpoint.production;
191
194
  return {
192
195
  ...apiConfig,
193
196
  xmlns: api.xmlns,
194
- endpoint: api.endpoint[this.config.sandbox ? 'sandbox' : 'production'],
197
+ endpoint: `https://${host}${api.path}`,
195
198
  headers: {
196
199
  ...api.headers(callName, useIaf ? accessToken : null),
197
200
  ...apiConfig.headers
198
201
  },
202
+ digitalSignatureHeaders: payload => {
203
+ return apiConfig.sign ? this.getDigitalSignatureHeaders({
204
+ method: 'POST',
205
+ authority: host,
206
+ path: api.path
207
+ }, payload) : {};
208
+ },
199
209
  ...(!useIaf ? { eBayAuthToken } : {})
200
210
  };
201
211
  }
package/lib/eBayApi.d.ts CHANGED
@@ -11,7 +11,7 @@ import { ContentLanguage, Locale, MarketplaceId, SiteId } from './enums/index.js
11
11
  import * as errors from './errors/index.js';
12
12
  import { IEBayApiRequest } from './request.js';
13
13
  import * as types from './types/index.js';
14
- import { AppConfig, ClientAlerts, Finding, Merchandising, Shopping, Trading } from './types/index.js';
14
+ import { AppConfig, ClientAlerts, Finding, Merchandising, Shopping, Signature, Trading } from './types/index.js';
15
15
  export default class eBayApi extends Api {
16
16
  static readonly SiteId: typeof enums.SiteId;
17
17
  static readonly MarketplaceId: typeof enums.MarketplaceId;
@@ -54,5 +54,6 @@ export default class eBayApi extends Api {
54
54
  get shopping(): Shopping;
55
55
  get merchandising(): Merchandising;
56
56
  get clientAlerts(): ClientAlerts;
57
+ setSignature(signature: Signature): void;
57
58
  }
58
59
  export { eBayApi, SiteId, MarketplaceId, ContentLanguage, Locale, enums, errors, types };
package/lib/eBayApi.js CHANGED
@@ -65,6 +65,13 @@ class eBayApi extends index_js_1.default {
65
65
  if (!process.env.EBAY_CERT_ID) {
66
66
  throw new index_js_3.ApiEnvError('EBAY_CERT_ID');
67
67
  }
68
+ let signature = null;
69
+ if (process.env.EBAY_JWE && process.env.EBAY_PRIVATE_KEY) {
70
+ signature = {
71
+ jwe: process.env.EBAY_JWE,
72
+ privateKey: process.env.EBAY_PRIVATE_KEY
73
+ };
74
+ }
68
75
  return new eBayApi({
69
76
  appId: process.env.EBAY_APP_ID,
70
77
  certId: process.env.EBAY_CERT_ID,
@@ -75,7 +82,8 @@ class eBayApi extends index_js_1.default {
75
82
  index_js_2.MarketplaceId[process.env.EBAY_MARKETPLACE_ID] :
76
83
  index_js_2.MarketplaceId.EBAY_US,
77
84
  ruName: process.env.EBAY_RU_NAME,
78
- sandbox: (process.env.EBAY_SANDBOX === 'true')
85
+ sandbox: (process.env.EBAY_SANDBOX === 'true'),
86
+ signature
79
87
  }, req);
80
88
  }
81
89
  /**
@@ -121,6 +129,9 @@ class eBayApi extends index_js_1.default {
121
129
  get clientAlerts() {
122
130
  return this._clientAlerts || (this._clientAlerts = this.factory.createClientAlertsApi());
123
131
  }
132
+ setSignature(signature) {
133
+ this.config.signature = signature;
134
+ }
124
135
  }
125
136
  exports.default = eBayApi;
126
137
  exports.eBayApi = eBayApi;