Socket
Socket
Sign inDemoInstall

ebay-api

Package Overview
Dependencies
28
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 8.7.1 to 8.7.2-RC.0

1

dist/api/digitalSignature.d.ts
import { Cipher, Headers } from '../types/index.js';
export declare const getUnixTimestamp: () => number;
export declare const generateContentDigestValue: (payload: unknown, cipher?: Cipher) => string;

@@ -3,0 +4,0 @@ export type SignatureComponents = {

2

dist/api/digitalSignature.js
import { createHash, sign } from 'crypto';
const beginPrivateKey = '-----BEGIN PRIVATE KEY-----';
const endPrivateKey = '-----END PRIVATE KEY-----';
const getUnixTimestamp = () => Date.now() / 1000 | 0;
export const getUnixTimestamp = () => Math.floor(Date.now() / 1000);
const getSignatureParams = (payload) => [

@@ -6,0 +6,0 @@ ...payload ? ['content-digest'] : [],

import Auth from '../auth/index.js';
import Base from './base.js';
import { generateContentDigestValue, generateSignature, generateSignatureInput } from './digitalSignature.js';
import { generateContentDigestValue, generateSignature, generateSignatureInput, getUnixTimestamp } from './digitalSignature.js';
export default class Api extends Base {

@@ -13,2 +13,3 @@ constructor(config, req, auth) {

}
const timestamp = getUnixTimestamp();
const digitalSignatureHeaders = {

@@ -20,9 +21,9 @@ 'x-ebay-enforce-signature': true,

} : {},
'signature-input': generateSignatureInput(payload)
'signature-input': generateSignatureInput(payload, timestamp)
};
return {
...digitalSignatureHeaders,
'signature': generateSignature(digitalSignatureHeaders, this.config.signature.privateKey, signatureComponents, payload)
'signature': generateSignature(digitalSignatureHeaders, this.config.signature.privateKey, signatureComponents, payload, timestamp)
};
}
}

@@ -12,3 +12,3 @@ import { Metric } from '../../../../enums/index.js';

filter?: string;
metric?: Metric | `${Metric}`;
metric?: string | Metric | `${Metric}`;
sort?: string;

@@ -15,0 +15,0 @@ }): Promise<any>;

@@ -11,2 +11,3 @@ import { ClientAlerts, Finding, Merchandising, Shopping, Trading } from '../../types/index.js';

private createXMLRequest;
private shouldRefreshToken;
private request;

@@ -13,0 +14,0 @@ private getConfig;

import { stringify } from 'qs';
import { EBayIAFTokenExpired, EBayIAFTokenInvalid, handleEBayError } from '../../errors/index.js';
import { EBayAuthTokenIsHardExpired, EBayIAFTokenExpired, EBayIAFTokenInvalid, handleEBayError } from '../../errors/index.js';
import Api from '../index.js';

@@ -19,3 +19,3 @@ import ClientAlertsCalls from './clientAlerts/index.js';

catch (error) {
if (this.config.autoRefreshToken && (error.name === EBayIAFTokenExpired.name || error.name === EBayIAFTokenInvalid.name)) {
if (this.shouldRefreshToken(error)) {
return await this.request(apiConfig, api, callName, fields, true);

@@ -144,2 +144,10 @@ }

}
shouldRefreshToken(error) {
if (!this.config.autoRefreshToken) {
return false;
}
return error.name === EBayIAFTokenExpired.name
|| error.name === EBayIAFTokenInvalid.name
|| error.name === EBayAuthTokenIsHardExpired.name;
}
async request(apiConfig, api, callName, fields, refreshToken = false) {

@@ -146,0 +154,0 @@ try {

@@ -0,3 +1,3 @@

import Base from '../api/base.js';
import { EventCallback } from '../nanoevents.js';
import Base from '../api/base.js';
import { IEBayApiRequest } from '../request.js';

@@ -4,0 +4,0 @@ import { AppConfig, Scope } from '../types/index.js';

import debug from 'debug';
import Base from '../api/base.js';
import { createNanoEvents } from '../nanoevents.js';
import Base from '../api/base.js';
const log = debug('ebay:oauth2');

@@ -63,9 +63,9 @@ class OAuth2 extends Base {

try {
const response = await this.req.postForm(this.identityEndpoint, {
const response = await this.req.post(this.identityEndpoint, {
scope: this.scope.join(' '),
grant_type: 'client_credentials'
grant_type: 'client_credentials',
}, {
auth: {
username: this.config.appId,
password: this.config.certId
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Basic ' + btoa(this.config.appId + ':' + this.config.certId)
}

@@ -102,4 +102,10 @@ });

async mintUserAccessToken(code, ruName = this.config.ruName) {
if (!this.config.appId) {
throw new Error('Missing App ID (Client Id)');
}
if (!this.config.certId) {
throw new Error('Missing Cert Id (Client Secret)');
}
try {
const response = await this.req.postForm(this.identityEndpoint, {
const response = await this.req.post(this.identityEndpoint, {
grant_type: 'authorization_code',

@@ -109,5 +115,5 @@ code,

}, {
auth: {
username: this.config.appId,
password: this.config.certId
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Basic ' + btoa(this.config.appId + ':' + this.config.certId)
}

@@ -133,3 +139,3 @@ });

try {
const response = await this.req.postForm(this.identityEndpoint, {
const response = await this.req.post(this.identityEndpoint, {
grant_type: 'refresh_token',

@@ -139,5 +145,5 @@ refresh_token: this._authToken.refresh_token,

}, {
auth: {
username: this.config.appId,
password: this.config.certId
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Basic ' + btoa(this.config.appId + ':' + this.config.certId)
}

@@ -144,0 +150,0 @@ });

@@ -874,2 +874,3 @@ export declare enum UserRoleFilter {

CLICK_THROUGH_RATE = "CLICK_THROUGH_RATE",
LISTING_IMPRESSION_SEARCH_RESULTS_PAGE = "LISTING_IMPRESSION_SEARCH_RESULTS_PAGE",
LISTING_IMPRESSION_STORE = "CLICK_THROUGH_RATE",

@@ -884,2 +885,3 @@ LISTING_IMPRESSION_TOTAL = "LISTING_IMPRESSION_TOTAL",

SALES_CONVERSION_RATE = "SALES_CONVERSION_RATE",
TOTAL_IMPRESSION_TOTAL = "TOTAL_IMPRESSION_TOTAL",
TRANSACTION = "TRANSACTION"

@@ -886,0 +888,0 @@ }

@@ -908,2 +908,3 @@ export var UserRoleFilter;

Metric["CLICK_THROUGH_RATE"] = "CLICK_THROUGH_RATE";
Metric["LISTING_IMPRESSION_SEARCH_RESULTS_PAGE"] = "LISTING_IMPRESSION_SEARCH_RESULTS_PAGE";
Metric["LISTING_IMPRESSION_STORE"] = "CLICK_THROUGH_RATE";

@@ -918,2 +919,3 @@ Metric["LISTING_IMPRESSION_TOTAL"] = "LISTING_IMPRESSION_TOTAL";

Metric["SALES_CONVERSION_RATE"] = "SALES_CONVERSION_RATE";
Metric["TOTAL_IMPRESSION_TOTAL"] = "TOTAL_IMPRESSION_TOTAL";
Metric["TRANSACTION"] = "TRANSACTION";

@@ -920,0 +922,0 @@ })(Metric || (Metric = {}));

@@ -37,2 +37,5 @@ export declare const rawError: unique symbol;

}
export declare class EBayAuthTokenIsHardExpired extends EbayApiError {
static readonly code = 932;
}
export declare class EBayIAFTokenInvalid extends EbayApiError {

@@ -39,0 +42,0 @@ static readonly code = 21916984;

@@ -64,2 +64,5 @@ import debug from 'debug';

EBayIAFTokenExpired.code = 21917053;
export class EBayAuthTokenIsHardExpired extends EbayApiError {
}
EBayAuthTokenIsHardExpired.code = 932;
export class EBayIAFTokenInvalid extends EbayApiError {

@@ -164,2 +167,4 @@ }

throw new EBayTokenRequired(data);
case EBayAuthTokenIsHardExpired.code:
throw new EBayAuthTokenIsHardExpired(data);
}

@@ -166,0 +171,0 @@ }

@@ -15,3 +15,2 @@ import { AxiosInstance, AxiosRequestConfig } from 'axios';

post<R = any>(url: string, data?: any, config?: C): Promise<R>;
postForm<R = any>(url: string, data?: any, config?: C): Promise<R>;
put<R = any>(url: string, data?: any, config?: C): Promise<R>;

@@ -26,3 +25,2 @@ }

put<R = any>(url: string, payload?: any, config?: AxiosRequestConfig): Promise<R>;
postForm<R = any>(url: string, payload?: any, config?: AxiosRequestConfig): Promise<R>;
}
import axios from 'axios';
import debug from 'debug';
import { stringify } from 'qs';
const log = debug('ebay:request');

@@ -38,7 +37,2 @@ export const defaultGlobalHeaders = {

}
postForm(url, payload, config) {
log('postForm: ' + url);
const body = stringify(payload);
return this.instance.post(url, body, config);
}
}
import { Cipher, Headers } from '../types/index.js';
export declare const getUnixTimestamp: () => number;
export declare const generateContentDigestValue: (payload: unknown, cipher?: Cipher) => string;

@@ -3,0 +4,0 @@ export type SignatureComponents = {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateSignature = exports.generateSignatureInput = exports.generateBaseString = exports.generateContentDigestValue = void 0;
exports.generateSignature = exports.generateSignatureInput = exports.generateBaseString = exports.generateContentDigestValue = exports.getUnixTimestamp = void 0;
const crypto_1 = require("crypto");
const beginPrivateKey = '-----BEGIN PRIVATE KEY-----';
const endPrivateKey = '-----END PRIVATE KEY-----';
const getUnixTimestamp = () => Date.now() / 1000 | 0;
const getUnixTimestamp = () => Math.floor(Date.now() / 1000);
exports.getUnixTimestamp = getUnixTimestamp;
const getSignatureParams = (payload) => [

@@ -23,3 +24,3 @@ ...payload ? ['content-digest'] : [],

exports.generateContentDigestValue = generateContentDigestValue;
function generateBaseString(headers, signatureComponents, payload, timestamp = getUnixTimestamp()) {
function generateBaseString(headers, signatureComponents, payload, timestamp = (0, exports.getUnixTimestamp)()) {
try {

@@ -61,5 +62,5 @@ let baseString = '';

exports.generateBaseString = generateBaseString;
const generateSignatureInput = (payload, timestamp = getUnixTimestamp()) => `sig1=(${getSignatureParamsValue(payload)});created=${timestamp}`;
const generateSignatureInput = (payload, timestamp = (0, exports.getUnixTimestamp)()) => `sig1=(${getSignatureParamsValue(payload)});created=${timestamp}`;
exports.generateSignatureInput = generateSignatureInput;
function generateSignature(headers, privateKey, signatureComponents, payload, timestamp = getUnixTimestamp()) {
function generateSignature(headers, privateKey, signatureComponents, payload, timestamp = (0, exports.getUnixTimestamp)()) {
const baseString = generateBaseString(headers, signatureComponents, payload, timestamp);

@@ -66,0 +67,0 @@ privateKey = privateKey.trim();

@@ -18,2 +18,3 @@ "use strict";

}
const timestamp = (0, digitalSignature_js_1.getUnixTimestamp)();
const digitalSignatureHeaders = {

@@ -25,7 +26,7 @@ 'x-ebay-enforce-signature': true,

} : {},
'signature-input': (0, digitalSignature_js_1.generateSignatureInput)(payload)
'signature-input': (0, digitalSignature_js_1.generateSignatureInput)(payload, timestamp)
};
return {
...digitalSignatureHeaders,
'signature': (0, digitalSignature_js_1.generateSignature)(digitalSignatureHeaders, this.config.signature.privateKey, signatureComponents, payload)
'signature': (0, digitalSignature_js_1.generateSignature)(digitalSignatureHeaders, this.config.signature.privateKey, signatureComponents, payload, timestamp)
};

@@ -32,0 +33,0 @@ }

@@ -12,3 +12,3 @@ import { Metric } from '../../../../enums/index.js';

filter?: string;
metric?: Metric | `${Metric}`;
metric?: string | Metric | `${Metric}`;
sort?: string;

@@ -15,0 +15,0 @@ }): Promise<any>;

@@ -11,2 +11,3 @@ import { ClientAlerts, Finding, Merchandising, Shopping, Trading } from '../../types/index.js';

private createXMLRequest;
private shouldRefreshToken;
private request;

@@ -13,0 +14,0 @@ private getConfig;

@@ -47,3 +47,3 @@ "use strict";

catch (error) {
if (this.config.autoRefreshToken && (error.name === index_js_1.EBayIAFTokenExpired.name || error.name === index_js_1.EBayIAFTokenInvalid.name)) {
if (this.shouldRefreshToken(error)) {
return await this.request(apiConfig, api, callName, fields, true);

@@ -172,2 +172,10 @@ }

}
shouldRefreshToken(error) {
if (!this.config.autoRefreshToken) {
return false;
}
return error.name === index_js_1.EBayIAFTokenExpired.name
|| error.name === index_js_1.EBayIAFTokenInvalid.name
|| error.name === index_js_1.EBayAuthTokenIsHardExpired.name;
}
async request(apiConfig, api, callName, fields, refreshToken = false) {

@@ -174,0 +182,0 @@ try {

@@ -0,3 +1,3 @@

import Base from '../api/base.js';
import { EventCallback } from '../nanoevents.js';
import Base from '../api/base.js';
import { IEBayApiRequest } from '../request.js';

@@ -4,0 +4,0 @@ import { AppConfig, Scope } from '../types/index.js';

@@ -7,4 +7,4 @@ "use strict";

const debug_1 = __importDefault(require("debug"));
const base_js_1 = __importDefault(require("../api/base.js"));
const nanoevents_js_1 = require("../nanoevents.js");
const base_js_1 = __importDefault(require("../api/base.js"));
const log = (0, debug_1.default)('ebay:oauth2');

@@ -69,9 +69,9 @@ class OAuth2 extends base_js_1.default {

try {
const response = await this.req.postForm(this.identityEndpoint, {
const response = await this.req.post(this.identityEndpoint, {
scope: this.scope.join(' '),
grant_type: 'client_credentials'
grant_type: 'client_credentials',
}, {
auth: {
username: this.config.appId,
password: this.config.certId
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Basic ' + btoa(this.config.appId + ':' + this.config.certId)
}

@@ -108,4 +108,10 @@ });

async mintUserAccessToken(code, ruName = this.config.ruName) {
if (!this.config.appId) {
throw new Error('Missing App ID (Client Id)');
}
if (!this.config.certId) {
throw new Error('Missing Cert Id (Client Secret)');
}
try {
const response = await this.req.postForm(this.identityEndpoint, {
const response = await this.req.post(this.identityEndpoint, {
grant_type: 'authorization_code',

@@ -115,5 +121,5 @@ code,

}, {
auth: {
username: this.config.appId,
password: this.config.certId
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Basic ' + btoa(this.config.appId + ':' + this.config.certId)
}

@@ -139,3 +145,3 @@ });

try {
const response = await this.req.postForm(this.identityEndpoint, {
const response = await this.req.post(this.identityEndpoint, {
grant_type: 'refresh_token',

@@ -145,5 +151,5 @@ refresh_token: this._authToken.refresh_token,

}, {
auth: {
username: this.config.appId,
password: this.config.certId
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Basic ' + btoa(this.config.appId + ':' + this.config.certId)
}

@@ -150,0 +156,0 @@ });

@@ -874,2 +874,3 @@ export declare enum UserRoleFilter {

CLICK_THROUGH_RATE = "CLICK_THROUGH_RATE",
LISTING_IMPRESSION_SEARCH_RESULTS_PAGE = "LISTING_IMPRESSION_SEARCH_RESULTS_PAGE",
LISTING_IMPRESSION_STORE = "CLICK_THROUGH_RATE",

@@ -884,2 +885,3 @@ LISTING_IMPRESSION_TOTAL = "LISTING_IMPRESSION_TOTAL",

SALES_CONVERSION_RATE = "SALES_CONVERSION_RATE",
TOTAL_IMPRESSION_TOTAL = "TOTAL_IMPRESSION_TOTAL",
TRANSACTION = "TRANSACTION"

@@ -886,0 +888,0 @@ }

@@ -910,2 +910,3 @@ "use strict";

Metric["CLICK_THROUGH_RATE"] = "CLICK_THROUGH_RATE";
Metric["LISTING_IMPRESSION_SEARCH_RESULTS_PAGE"] = "LISTING_IMPRESSION_SEARCH_RESULTS_PAGE";
Metric["LISTING_IMPRESSION_STORE"] = "CLICK_THROUGH_RATE";

@@ -920,2 +921,3 @@ Metric["LISTING_IMPRESSION_TOTAL"] = "LISTING_IMPRESSION_TOTAL";

Metric["SALES_CONVERSION_RATE"] = "SALES_CONVERSION_RATE";
Metric["TOTAL_IMPRESSION_TOTAL"] = "TOTAL_IMPRESSION_TOTAL";
Metric["TRANSACTION"] = "TRANSACTION";

@@ -922,0 +924,0 @@ })(Metric || (exports.Metric = Metric = {}));

@@ -37,2 +37,5 @@ export declare const rawError: unique symbol;

}
export declare class EBayAuthTokenIsHardExpired extends EbayApiError {
static readonly code = 932;
}
export declare class EBayIAFTokenInvalid extends EbayApiError {

@@ -39,0 +42,0 @@ static readonly code = 21916984;

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.checkEBayResponse = exports.handleEBayError = exports.mapEBayError = exports.EBayInvalidScope = exports.EBayTokenRequired = exports.EBayIAFTokenInvalid = exports.EBayIAFTokenExpired = exports.EBayInvalidAccessToken = exports.EBayNotFound = exports.EBayInvalidGrant = exports.EBayAccessDenied = exports.EbayApiError = exports.getErrorDescription = exports.getErrorMessage = exports.ApiEnvError = exports.EbayNoCallError = exports.EBayError = exports.rawError = void 0;
exports.checkEBayResponse = exports.handleEBayError = exports.mapEBayError = exports.EBayInvalidScope = exports.EBayTokenRequired = exports.EBayIAFTokenInvalid = exports.EBayAuthTokenIsHardExpired = exports.EBayIAFTokenExpired = exports.EBayInvalidAccessToken = exports.EBayNotFound = exports.EBayInvalidGrant = exports.EBayAccessDenied = exports.EbayApiError = exports.getErrorDescription = exports.getErrorMessage = exports.ApiEnvError = exports.EbayNoCallError = exports.EBayError = exports.rawError = void 0;
const debug_1 = __importDefault(require("debug"));

@@ -82,2 +82,6 @@ const log = (0, debug_1.default)('ebay:error');

EBayIAFTokenExpired.code = 21917053;
class EBayAuthTokenIsHardExpired extends EbayApiError {
}
exports.EBayAuthTokenIsHardExpired = EBayAuthTokenIsHardExpired;
EBayAuthTokenIsHardExpired.code = 932;
class EBayIAFTokenInvalid extends EbayApiError {

@@ -187,2 +191,4 @@ }

throw new EBayTokenRequired(data);
case EBayAuthTokenIsHardExpired.code:
throw new EBayAuthTokenIsHardExpired(data);
}

@@ -189,0 +195,0 @@ }

@@ -15,3 +15,2 @@ import { AxiosInstance, AxiosRequestConfig } from 'axios';

post<R = any>(url: string, data?: any, config?: C): Promise<R>;
postForm<R = any>(url: string, data?: any, config?: C): Promise<R>;
put<R = any>(url: string, data?: any, config?: C): Promise<R>;

@@ -26,3 +25,2 @@ }

put<R = any>(url: string, payload?: any, config?: AxiosRequestConfig): Promise<R>;
postForm<R = any>(url: string, payload?: any, config?: AxiosRequestConfig): Promise<R>;
}

@@ -9,3 +9,2 @@ "use strict";

const debug_1 = __importDefault(require("debug"));
const qs_1 = require("qs");
const log = (0, debug_1.default)('ebay:request');

@@ -45,8 +44,3 @@ exports.defaultGlobalHeaders = {

}
postForm(url, payload, config) {
log('postForm: ' + url);
const body = (0, qs_1.stringify)(payload);
return this.instance.post(url, body, config);
}
}
exports.AxiosRequest = AxiosRequest;
{
"name": "ebay-api",
"author": "Daniil Tomilow",
"version": "8.7.1",
"version": "8.7.2-RC.0",
"description": "eBay API for Node and Browser",

@@ -89,3 +89,3 @@ "type": "module",

"dependencies": {
"axios": "^1.2.1",
"axios": "^1.6.8",
"debug": "^4.3.4",

@@ -97,3 +97,3 @@ "fast-xml-parser": "^4.2.5",

"@rollup/plugin-commonjs": "^23.0.4",
"@rollup/plugin-json": "^5.0.2",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.0.1",

@@ -114,8 +114,8 @@ "@rollup/plugin-terser": "^0.2.0",

"readline": "^1.3.0",
"rimraf": "^3.0.2",
"rimraf": "^5.0.5",
"rollup": "^3.7.0",
"rollup-plugin-bundle-size": "^1.0.3",
"sinon": "^7.4.2",
"sinon": "^17.0.1",
"standard-version": "^9.0.0",
"ts-node": "^10.8.0",
"ts-node": "^10.9.2",
"tslint": "^6.1.0",

@@ -122,0 +122,0 @@ "typescript": "^5.1.6"

@@ -24,3 +24,3 @@ # eBay Node API in TypeScript with Browser support

* `v8.7.1` is the latest release.
* `v8.7.2-RC.0` is the latest release.
* See [here](https://github.com/hendt/ebay-api/blob/master/CHANGELOG.md) for the full changelog.

@@ -27,0 +27,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc