From 7f9420a398ddae2f59f8c270f95a485280dcc827 Mon Sep 17 00:00:00 2001 From: taimoor0217 Date: Mon, 6 Dec 2021 16:23:29 +0500 Subject: [PATCH 01/37] add redis client --- src/auth/redisClient.ts | 75 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/auth/redisClient.ts diff --git a/src/auth/redisClient.ts b/src/auth/redisClient.ts new file mode 100644 index 0000000..ff9b4a6 --- /dev/null +++ b/src/auth/redisClient.ts @@ -0,0 +1,75 @@ +const redis = require("redis"); +const crypto = require("crypto"); +const bluebird = require("bluebird"); +const cryptojs = require("crypto-js"); + +const HOUR_IN_SECONDS = 3600; + +// Adding promises to redis +// https://stackoverflow.com/a/54844935 + +// https://cloud.google.com/community/tutorials/nodejs-redis-on-appengine +const client = (() => { + if (process.env.REDIS_PORT) { + bluebird.promisifyAll(redis); + const authParams: { + [index: string]: any; + } = {}; + if (process.env.REDIS_KEY) { + authParams.auth_pass = process.env.REDIS_KEY; + authParams.return_buffers = true; + } + return redis.createClient( + process.env.REDIS_PORT, + process.env.REDIS_HOST, + authParams + ); + } +})(); + +const hash = (text: any) => + crypto.createHash("sha256").update(text).digest("hex"); + +// https://github.com/brix/crypto-js#plain-text-encryption +const encryptAccessToken = (accessToken: any) => + cryptojs.AES.encrypt(accessToken, process.env.ACCESS_TOKEN_SECRET).toString(); + +const decryptAccessToken = (encryptedToken: any) => + cryptojs.AES.decrypt( + encryptedToken, + process.env.ACCESS_TOKEN_SECRET + ).toString(cryptojs.enc.Utf8); + +export const setAccessToken = async (refreshToken: any, accessToken: any) => { + if (!client) { + return; + } + const hashedRefreshToken = hash(refreshToken); + const encryptedAccessToken = encryptAccessToken(accessToken); + // Auto remove it after an hour -> https://redis.io/commands/set + await client.setAsync( + hashedRefreshToken, + encryptedAccessToken, + "EX", + HOUR_IN_SECONDS + ); +}; + +export const getAccessToken = async (refreshToken: any) => { + if (!client) { + return; + } + const hashedRefreshToken = hash(refreshToken); + const encryptedToken = await client.getAsync(hashedRefreshToken); + if (encryptedToken) { + return decryptAccessToken(encryptedToken); + } +}; + +export const clearAccessToken = async (refreshToken: any) => { + if (!client) { + return; + } + const hashedRefreshToken = hash(refreshToken); + await client.del(hashedRefreshToken); +}; From 67c0aa314a884fc33a6cc13b74e2f8e1edeaa1cb Mon Sep 17 00:00:00 2001 From: taimoor0217 Date: Tue, 7 Dec 2021 00:38:09 +0500 Subject: [PATCH 02/37] wip initial changes --- package.json | 4 +- src/auth/oAuth2.ts | 230 ++++++++++++++++++++++++++-------------- src/auth/redisClient.ts | 4 +- 3 files changed, 154 insertions(+), 84 deletions(-) diff --git a/package.json b/package.json index 017233b..19471b0 100644 --- a/package.json +++ b/package.json @@ -20,10 +20,12 @@ }, "dependencies": { "axios": "^0.21.4", + "bluebird": "^3.7.2", "debug": "^2.1.1", "fast-xml-parser": "^3.19.0", "nanoevents": "^2.0.0", - "qs": "^6.8.0" + "qs": "^6.8.0", + "redis": "^4.0.0" }, "publishConfig": { "registry": "https://npm.pkg.github.com" diff --git a/src/auth/oAuth2.ts b/src/auth/oAuth2.ts index 4b630bc..5febb6c 100644 --- a/src/auth/oAuth2.ts +++ b/src/auth/oAuth2.ts @@ -1,20 +1,21 @@ -import debug from 'debug'; -import Base from '../api/base'; -import {Scope} from '../types'; +import debug from "debug"; +import Base from "../api/base"; +import { Scope } from "../types"; +import { getAccessToken, setAccessToken } from "./redisClient"; -const log = debug('ebay:oauth2'); +const log = debug("ebay:oauth2"); export type Token = { - access_token: string, - expires_in: number, // default 2 hours - token_type: string + access_token: string; + expires_in: number; // default 2 hours + token_type: string; }; export type ClientToken = Token; export type AuthToken = Token & { - refresh_token: string, - refresh_token_expires_in: number + refresh_token: string; + refresh_token_expires_in: number; }; /** @@ -26,32 +27,40 @@ export type AuthToken = Token & { export default class OAuth2 extends Base { // If all the calls in our application require just an Application access token we can use this endpoint public static readonly IDENTITY_ENDPOINT: Record = { - production: 'https://api.ebay.com/identity/v1/oauth2/token', - sandbox: 'https://api.sandbox.ebay.com/identity/v1/oauth2/token' + production: "https://api.ebay.com/identity/v1/oauth2/token", + sandbox: "https://api.sandbox.ebay.com/identity/v1/oauth2/token", }; public static readonly AUTHORIZE_ENDPOINT: Record = { - production: 'https://auth.ebay.com/oauth2/authorize', - sandbox: 'https://auth.sandbox.ebay.com/oauth2/authorize' + production: "https://auth.ebay.com/oauth2/authorize", + sandbox: "https://auth.sandbox.ebay.com/oauth2/authorize", }; - public static readonly defaultScopes: Scope = ['https://api.ebay.com/oauth/api_scope']; + public static readonly defaultScopes: Scope = [ + "https://api.ebay.com/oauth/api_scope", + ]; public static generateAuthUrl( sandbox: boolean, appId: string, ruName: string, scope: string[], - state = '' + state = "" ): string { return [ - sandbox ? OAuth2.AUTHORIZE_ENDPOINT.sandbox : OAuth2.AUTHORIZE_ENDPOINT.production, - '?client_id=', encodeURIComponent(appId), - '&redirect_uri=', encodeURIComponent(ruName), - '&response_type=code', - '&state=', encodeURIComponent(state), - '&scope=', encodeURIComponent(scope.join(' ')) - ].join(''); + sandbox + ? OAuth2.AUTHORIZE_ENDPOINT.sandbox + : OAuth2.AUTHORIZE_ENDPOINT.production, + "?client_id=", + encodeURIComponent(appId), + "&redirect_uri=", + encodeURIComponent(ruName), + "&response_type=code", + "&state=", + encodeURIComponent(state), + "&scope=", + encodeURIComponent(scope.join(" ")), + ].join(""); } private scope: Scope = this.config.scope || OAuth2.defaultScopes; @@ -59,7 +68,9 @@ export default class OAuth2 extends Base { private _authToken?: AuthToken; get identityEndpoint() { - return this.config.sandbox ? OAuth2.IDENTITY_ENDPOINT.sandbox : OAuth2.IDENTITY_ENDPOINT.production + return this.config.sandbox + ? OAuth2.IDENTITY_ENDPOINT.sandbox + : OAuth2.IDENTITY_ENDPOINT.production; } /** @@ -71,12 +82,12 @@ export default class OAuth2 extends Base { } public getUserAccessToken(): string | null { - return this._authToken?.access_token ?? null + return this._authToken?.access_token ?? null; } public async getApplicationAccessToken(): Promise { if (this._clientToken) { - log('Return existing application access token: ', this._clientToken); + log("Return existing application access token: ", this._clientToken); return this._clientToken.access_token; } @@ -105,25 +116,29 @@ export default class OAuth2 extends Base { */ public async mintApplicationAccessToken(): Promise { if (!this.config.appId) { - throw new Error('Missing App ID (Client Id)'); + throw new Error("Missing App ID (Client Id)"); } if (!this.config.certId) { - throw new Error('Missing Cert Id (Client Secret)'); + throw new Error("Missing Cert Id (Client Secret)"); } try { - return await this.req.postForm(this.identityEndpoint, { - scope: this.scope.join(' '), - grant_type: 'client_credentials' - }, { - auth: { - username: this.config.appId, - password: this.config.certId + return await this.req.postForm( + this.identityEndpoint, + { + scope: this.scope.join(" "), + grant_type: "client_credentials", + }, + { + auth: { + username: this.config.appId, + password: this.config.certId, + }, } - }); + ); } catch (error) { - log('Failed to mint application token', error); + log("Failed to mint application token", error); throw error; } } @@ -132,19 +147,22 @@ export default class OAuth2 extends Base { * Client credentials grant flow. */ public async obtainApplicationAccessToken(): Promise { - log('Obtain a new application access token with scope: ', this.scope.join(',')); + log( + "Obtain a new application access token with scope: ", + this.scope.join(",") + ); try { const token = await this.mintApplicationAccessToken(); - log('Obtained a new application access token:', token); + log("Obtained a new application access token:", token); this.setClientToken(token); - this.emit('refreshClientToken', token); + this.emit("refreshClientToken", token); return token; } catch (error) { - log('Failed to obtain application token', error); + log("Failed to obtain application token", error); throw error; } } @@ -156,14 +174,24 @@ export default class OAuth2 extends Base { * @param scope the scopes * @param state state parameter returned in the redirect URL */ - public generateAuthUrl(ruName?: string, scope: string[] = this.scope, state = ''): string { + public generateAuthUrl( + ruName?: string, + scope: string[] = this.scope, + state = "" + ): string { ruName = ruName || this.config.ruName; if (!ruName) { - throw new Error('RuName is required.'); + throw new Error("RuName is required."); } - return OAuth2.generateAuthUrl(this.config.sandbox, this.config.appId, ruName, scope, state); + return OAuth2.generateAuthUrl( + this.config.sandbox, + this.config.appId, + ruName, + scope, + state + ); } /** @@ -176,21 +204,25 @@ export default class OAuth2 extends Base { */ public async mintUserAccessToken(code: string, ruName = this.config.ruName) { try { - const token = await this.req.postForm(this.identityEndpoint, { - grant_type: 'authorization_code', - code, - redirect_uri: ruName - }, { - auth: { - username: this.config.appId, - password: this.config.certId + const token = await this.req.postForm( + this.identityEndpoint, + { + grant_type: "authorization_code", + code, + redirect_uri: ruName, + }, + { + auth: { + username: this.config.appId, + password: this.config.certId, + }, } - }); + ); - log('User Access Token', token); + log("User Access Token", token); return token; } catch (error) { - log('Failed to get the token', error); + log("Failed to get the token", error); throw error; } } @@ -207,40 +239,74 @@ export default class OAuth2 extends Base { return await this.mintUserAccessToken(code, ruName); } + public async initialize(refreshToken: string) { + this.setCredentials({ + expires_in: 7200, + refresh_token_expires_in: 47304000, + token_type: "User Access Token", + refresh_token: refreshToken, + access_token:"", + }) + await this.refreshToken(); + } /** * Authorization code grant flow. */ public async refreshUserAccessToken(): Promise { if (!this._authToken || !this._authToken.refresh_token) { - log('Tried to refresh user access token before it was set.'); - throw new Error('Failed to refresh the user access token. Token or refresh_token is not set.'); + log("Tried to refresh user access token before it was set."); + throw new Error( + "Failed to refresh the user access token. Token or refresh_token is not set." + ); } + let storedAccessToken = await getAccessToken( + this._authToken.refresh_token + ); + if ( + storedAccessToken && + storedAccessToken !== this._authToken.access_token + ) { + const credentials = { + ...this._authToken, + access_token: storedAccessToken, + }; + this.setCredentials(credentials); //set this as the new access token + return credentials; + } + try { - const token = await this.req.postForm(this.identityEndpoint, { - grant_type: 'refresh_token', - refresh_token: this._authToken.refresh_token, - scope: this.scope.join(' ') - }, { - auth: { - username: this.config.appId, - password: this.config.certId + const token = await this.req.postForm( + this.identityEndpoint, + { + grant_type: "refresh_token", + refresh_token: this._authToken.refresh_token, + scope: this.scope.join(" "), + }, + { + auth: { + username: this.config.appId, + password: this.config.certId, + }, } - }); + ); - log('Successfully refreshed token', token); + log("Successfully refreshed token", token); const refreshedToken = { ...this._authToken, - ...token + ...token, }; - this.setCredentials(refreshedToken); - this.emit('refreshAuthToken', refreshedToken); + await setAccessToken( + this._authToken.refresh_token, + refreshedToken.access_token + ); //store the refreshed token in redis + this.emit("refreshAuthToken", refreshedToken); return refreshedToken; } catch (error) { - log('Failed to refresh the token', error); + log("Failed to refresh the token", error); throw error; } } @@ -254,34 +320,34 @@ export default class OAuth2 extends Base { */ public async obtainToken(code: string): Promise { const token = await this.getToken(code); - log('Obtain user access token', token); - this.setCredentials(token) + log("Obtain user access token", token); + this.setCredentials(token); - return token + return token; } public getCredentials(): AuthToken | ClientToken | null { if (this._authToken) { return { - ...this._authToken + ...this._authToken, }; } else if (this._clientToken) { return { - ...this._clientToken - } + ...this._clientToken, + }; } return null; } public setCredentials(authToken: AuthToken | string) { - if (typeof authToken === 'string') { + if (typeof authToken === "string") { this._authToken = { - refresh_token: '', + refresh_token: "", expires_in: 7200, refresh_token_expires_in: 47304000, - token_type: 'User Access Token', - access_token: authToken + token_type: "User Access Token", + access_token: authToken, }; } else { this._authToken = authToken; @@ -298,6 +364,8 @@ export default class OAuth2 extends Base { return await this.obtainApplicationAccessToken(); } - throw new Error('Missing credentials. To refresh a token an application access token or user access token must be already set.'); + throw new Error( + "Missing credentials. To refresh a token an application access token or user access token must be already set." + ); } } diff --git a/src/auth/redisClient.ts b/src/auth/redisClient.ts index ff9b4a6..775844d 100644 --- a/src/auth/redisClient.ts +++ b/src/auth/redisClient.ts @@ -32,12 +32,12 @@ const hash = (text: any) => // https://github.com/brix/crypto-js#plain-text-encryption const encryptAccessToken = (accessToken: any) => - cryptojs.AES.encrypt(accessToken, process.env.ACCESS_TOKEN_SECRET).toString(); + cryptojs.AES.encrypt(accessToken, process.env.EBAY_ACCESS_TOKEN_SECRET).toString(); const decryptAccessToken = (encryptedToken: any) => cryptojs.AES.decrypt( encryptedToken, - process.env.ACCESS_TOKEN_SECRET + process.env.EBAY_ACCESS_TOKEN_SECRET ).toString(cryptojs.enc.Utf8); export const setAccessToken = async (refreshToken: any, accessToken: any) => { From 2187d2443301af4a56055cc69266bba92ed78a34 Mon Sep 17 00:00:00 2001 From: taimoor0217 Date: Tue, 7 Dec 2021 01:24:19 +0500 Subject: [PATCH 03/37] update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 19471b0..012d3ca 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ecomshft/ebay-api", "author": "Daniil Tomilow (original author)", - "version": "5.1.2", + "version": "5.1.3", "description": "Modified version of eBay TypeScript/JavaScript API for Node and Browser", "browser": "./lib/ebay-api.min.js", "main": "./lib/index.js", From 11911eaa72fe7a502693be5807195e1a1ce228ad Mon Sep 17 00:00:00 2001 From: taimoor0217 Date: Tue, 7 Dec 2021 01:31:40 +0500 Subject: [PATCH 04/37] update lock file --- package-lock.json | 155 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 148 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 25ac4ff..9a3f34b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,19 +1,21 @@ { "name": "@ecomshft/ebay-api", - "version": "5.1.0", + "version": "5.1.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@ecomshft/ebay-api", - "version": "5.1.0", + "version": "5.1.3", "license": "MIT", "dependencies": { "axios": "^0.21.4", + "bluebird": "^3.7.2", "debug": "^2.1.1", "fast-xml-parser": "^3.19.0", "nanoevents": "^2.0.0", - "qs": "^6.8.0" + "qs": "^6.8.0", + "redis": "^4.0.0" }, "devDependencies": { "@rollup/plugin-commonjs": "^15.1.0", @@ -509,6 +511,36 @@ "node": ">=8" } }, + "node_modules/@node-redis/client": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@node-redis/client/-/client-1.0.0.tgz", + "integrity": "sha512-DWDMeZELXG3rOGzCKfJEHCkCP6rgiA1H+oqj2N0NR4Q0fQUYMxTsyoqt80GpdYLilUW6zoCiQl9yL3vJhGhiCA==", + "dependencies": { + "cluster-key-slot": "1.1.0", + "generic-pool": "3.8.2", + "redis-parser": "3.0.0", + "yallist": "4.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@node-redis/json": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@node-redis/json/-/json-1.0.0.tgz", + "integrity": "sha512-6e4qjbHODfr/KFsHYvkbfNui/kedVz+cG7Hz8oNbZM3p68QLf3A8FjcPYzixBp/QbvPeOSLgj39DjVEqjKkqkw==", + "peerDependencies": { + "@node-redis/client": "^1.0.0" + } + }, + "node_modules/@node-redis/search": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@node-redis/search/-/search-1.0.0.tgz", + "integrity": "sha512-f0Cw83X5+bpDIDTNSpd3YA+ckV3kwSv/NfcKhHRPGDQXFqyMLO0Q+2t8EMQncvsMRWduURsR4nqMYGzXae1ZCA==", + "peerDependencies": { + "@node-redis/client": "^1.0.0" + } + }, "node_modules/@rollup/plugin-commonjs": { "version": "15.1.0", "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-15.1.0.tgz", @@ -882,6 +914,11 @@ "node": ">=8" } }, + "node_modules/bluebird": { + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", + "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==" + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -1095,6 +1132,14 @@ "wrap-ansi": "^7.0.0" } }, + "node_modules/cluster-key-slot": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.0.tgz", + "integrity": "sha512-2Nii8p3RwAPiFwsnZvukotvow2rIHM+yQ6ZcBXGHdniadkYGZYiGmkHJIbZPIV9nfv7m/U1IPMVVcAhoWFeklw==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -1866,6 +1911,14 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, + "node_modules/generic-pool": { + "version": "3.8.2", + "resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-3.8.2.tgz", + "integrity": "sha512-nGToKy6p3PAbYQ7p1UlWl6vSPwfwU6TMSWK7TTu+WUY4ZjyZQGniGGt2oNVvyNSpyZYSB43zMXVLcBm08MTMkg==", + "engines": { + "node": ">= 4" + } + }, "node_modules/gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", @@ -4297,6 +4350,35 @@ "node": ">=8" } }, + "node_modules/redis": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/redis/-/redis-4.0.0.tgz", + "integrity": "sha512-LtV6+h0F/e3F4mtDKKGZIl/ekEjsiqX2E0hmtNqjGqXj3wYi/nAfeVNWKRa7wFuJ+nkqwXATFGvu6h2fLCgA1A==", + "dependencies": { + "@node-redis/client": "^1.0.0", + "@node-redis/json": "^1.0.0", + "@node-redis/search": "^1.0.0" + } + }, + "node_modules/redis-errors": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz", + "integrity": "sha1-62LSrbFeTq9GEMBK/hUpOEJQq60=", + "engines": { + "node": ">=4" + } + }, + "node_modules/redis-parser": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz", + "integrity": "sha1-tm2CjNyv5rS4pCin3vTGvKwxyLQ=", + "dependencies": { + "redis-errors": "^1.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/release-zalgo": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz", @@ -5238,8 +5320,7 @@ "node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, "node_modules/yargs": { "version": "16.2.0", @@ -5698,6 +5779,29 @@ "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", "dev": true }, + "@node-redis/client": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@node-redis/client/-/client-1.0.0.tgz", + "integrity": "sha512-DWDMeZELXG3rOGzCKfJEHCkCP6rgiA1H+oqj2N0NR4Q0fQUYMxTsyoqt80GpdYLilUW6zoCiQl9yL3vJhGhiCA==", + "requires": { + "cluster-key-slot": "1.1.0", + "generic-pool": "3.8.2", + "redis-parser": "3.0.0", + "yallist": "4.0.0" + } + }, + "@node-redis/json": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@node-redis/json/-/json-1.0.0.tgz", + "integrity": "sha512-6e4qjbHODfr/KFsHYvkbfNui/kedVz+cG7Hz8oNbZM3p68QLf3A8FjcPYzixBp/QbvPeOSLgj39DjVEqjKkqkw==", + "requires": {} + }, + "@node-redis/search": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@node-redis/search/-/search-1.0.0.tgz", + "integrity": "sha512-f0Cw83X5+bpDIDTNSpd3YA+ckV3kwSv/NfcKhHRPGDQXFqyMLO0Q+2t8EMQncvsMRWduURsR4nqMYGzXae1ZCA==", + "requires": {} + }, "@rollup/plugin-commonjs": { "version": "15.1.0", "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-15.1.0.tgz", @@ -6021,6 +6125,11 @@ "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", "dev": true }, + "bluebird": { + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", + "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==" + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -6181,6 +6290,11 @@ "wrap-ansi": "^7.0.0" } }, + "cluster-key-slot": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.0.tgz", + "integrity": "sha512-2Nii8p3RwAPiFwsnZvukotvow2rIHM+yQ6ZcBXGHdniadkYGZYiGmkHJIbZPIV9nfv7m/U1IPMVVcAhoWFeklw==" + }, "color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -6759,6 +6873,11 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, + "generic-pool": { + "version": "3.8.2", + "resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-3.8.2.tgz", + "integrity": "sha512-nGToKy6p3PAbYQ7p1UlWl6vSPwfwU6TMSWK7TTu+WUY4ZjyZQGniGGt2oNVvyNSpyZYSB43zMXVLcBm08MTMkg==" + }, "gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", @@ -8625,6 +8744,29 @@ "strip-indent": "^3.0.0" } }, + "redis": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/redis/-/redis-4.0.0.tgz", + "integrity": "sha512-LtV6+h0F/e3F4mtDKKGZIl/ekEjsiqX2E0hmtNqjGqXj3wYi/nAfeVNWKRa7wFuJ+nkqwXATFGvu6h2fLCgA1A==", + "requires": { + "@node-redis/client": "^1.0.0", + "@node-redis/json": "^1.0.0", + "@node-redis/search": "^1.0.0" + } + }, + "redis-errors": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz", + "integrity": "sha1-62LSrbFeTq9GEMBK/hUpOEJQq60=" + }, + "redis-parser": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz", + "integrity": "sha1-tm2CjNyv5rS4pCin3vTGvKwxyLQ=", + "requires": { + "redis-errors": "^1.0.0" + } + }, "release-zalgo": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz", @@ -9342,8 +9484,7 @@ "yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, "yargs": { "version": "16.2.0", From a668653260c74ceb3447bd60c045f7bb47117237 Mon Sep 17 00:00:00 2001 From: taimoor0217 Date: Tue, 7 Dec 2021 12:14:00 +0500 Subject: [PATCH 05/37] downgrade redis version --- package-lock.json | 143 ++++++++++++++++------------------------------ package.json | 2 +- 2 files changed, 50 insertions(+), 95 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9a3f34b..2f6f9cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "fast-xml-parser": "^3.19.0", "nanoevents": "^2.0.0", "qs": "^6.8.0", - "redis": "^4.0.0" + "redis": "^3.1.1" }, "devDependencies": { "@rollup/plugin-commonjs": "^15.1.0", @@ -511,36 +511,6 @@ "node": ">=8" } }, - "node_modules/@node-redis/client": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@node-redis/client/-/client-1.0.0.tgz", - "integrity": "sha512-DWDMeZELXG3rOGzCKfJEHCkCP6rgiA1H+oqj2N0NR4Q0fQUYMxTsyoqt80GpdYLilUW6zoCiQl9yL3vJhGhiCA==", - "dependencies": { - "cluster-key-slot": "1.1.0", - "generic-pool": "3.8.2", - "redis-parser": "3.0.0", - "yallist": "4.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@node-redis/json": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@node-redis/json/-/json-1.0.0.tgz", - "integrity": "sha512-6e4qjbHODfr/KFsHYvkbfNui/kedVz+cG7Hz8oNbZM3p68QLf3A8FjcPYzixBp/QbvPeOSLgj39DjVEqjKkqkw==", - "peerDependencies": { - "@node-redis/client": "^1.0.0" - } - }, - "node_modules/@node-redis/search": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@node-redis/search/-/search-1.0.0.tgz", - "integrity": "sha512-f0Cw83X5+bpDIDTNSpd3YA+ckV3kwSv/NfcKhHRPGDQXFqyMLO0Q+2t8EMQncvsMRWduURsR4nqMYGzXae1ZCA==", - "peerDependencies": { - "@node-redis/client": "^1.0.0" - } - }, "node_modules/@rollup/plugin-commonjs": { "version": "15.1.0", "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-15.1.0.tgz", @@ -1132,14 +1102,6 @@ "wrap-ansi": "^7.0.0" } }, - "node_modules/cluster-key-slot": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.0.tgz", - "integrity": "sha512-2Nii8p3RwAPiFwsnZvukotvow2rIHM+yQ6ZcBXGHdniadkYGZYiGmkHJIbZPIV9nfv7m/U1IPMVVcAhoWFeklw==", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -1615,6 +1577,14 @@ "node": ">=0.4.0" } }, + "node_modules/denque": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/denque/-/denque-1.5.1.tgz", + "integrity": "sha512-XwE+iZ4D6ZUB7mfYRMb5wByE8L74HCn30FBN7sWnXksWc1LO1bPDl67pBR9o/kC4z/xSNAwkMYcGgqDV3BE3Hw==", + "engines": { + "node": ">=0.10" + } + }, "node_modules/detect-indent": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.1.0.tgz", @@ -1911,14 +1881,6 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, - "node_modules/generic-pool": { - "version": "3.8.2", - "resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-3.8.2.tgz", - "integrity": "sha512-nGToKy6p3PAbYQ7p1UlWl6vSPwfwU6TMSWK7TTu+WUY4ZjyZQGniGGt2oNVvyNSpyZYSB43zMXVLcBm08MTMkg==", - "engines": { - "node": ">= 4" - } - }, "node_modules/gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", @@ -4351,15 +4313,28 @@ } }, "node_modules/redis": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/redis/-/redis-4.0.0.tgz", - "integrity": "sha512-LtV6+h0F/e3F4mtDKKGZIl/ekEjsiqX2E0hmtNqjGqXj3wYi/nAfeVNWKRa7wFuJ+nkqwXATFGvu6h2fLCgA1A==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/redis/-/redis-3.1.2.tgz", + "integrity": "sha512-grn5KoZLr/qrRQVwoSkmzdbw6pwF+/rwODtrOr6vuBRiR/f3rjSTGupbF90Zpqm2oenix8Do6RV7pYEkGwlKkw==", "dependencies": { - "@node-redis/client": "^1.0.0", - "@node-redis/json": "^1.0.0", - "@node-redis/search": "^1.0.0" + "denque": "^1.5.0", + "redis-commands": "^1.7.0", + "redis-errors": "^1.2.0", + "redis-parser": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-redis" } }, + "node_modules/redis-commands": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.7.0.tgz", + "integrity": "sha512-nJWqw3bTFy21hX/CPKHth6sfhZbdiHP6bTawSgQBlKOVRG7EZkfHbbHwQJnrE4vsQf0CMNE+3gJ4Fmm16vdVlQ==" + }, "node_modules/redis-errors": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz", @@ -5320,7 +5295,8 @@ "node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true }, "node_modules/yargs": { "version": "16.2.0", @@ -5779,29 +5755,6 @@ "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", "dev": true }, - "@node-redis/client": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@node-redis/client/-/client-1.0.0.tgz", - "integrity": "sha512-DWDMeZELXG3rOGzCKfJEHCkCP6rgiA1H+oqj2N0NR4Q0fQUYMxTsyoqt80GpdYLilUW6zoCiQl9yL3vJhGhiCA==", - "requires": { - "cluster-key-slot": "1.1.0", - "generic-pool": "3.8.2", - "redis-parser": "3.0.0", - "yallist": "4.0.0" - } - }, - "@node-redis/json": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@node-redis/json/-/json-1.0.0.tgz", - "integrity": "sha512-6e4qjbHODfr/KFsHYvkbfNui/kedVz+cG7Hz8oNbZM3p68QLf3A8FjcPYzixBp/QbvPeOSLgj39DjVEqjKkqkw==", - "requires": {} - }, - "@node-redis/search": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@node-redis/search/-/search-1.0.0.tgz", - "integrity": "sha512-f0Cw83X5+bpDIDTNSpd3YA+ckV3kwSv/NfcKhHRPGDQXFqyMLO0Q+2t8EMQncvsMRWduURsR4nqMYGzXae1ZCA==", - "requires": {} - }, "@rollup/plugin-commonjs": { "version": "15.1.0", "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-15.1.0.tgz", @@ -6290,11 +6243,6 @@ "wrap-ansi": "^7.0.0" } }, - "cluster-key-slot": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.0.tgz", - "integrity": "sha512-2Nii8p3RwAPiFwsnZvukotvow2rIHM+yQ6ZcBXGHdniadkYGZYiGmkHJIbZPIV9nfv7m/U1IPMVVcAhoWFeklw==" - }, "color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -6677,6 +6625,11 @@ "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", "dev": true }, + "denque": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/denque/-/denque-1.5.1.tgz", + "integrity": "sha512-XwE+iZ4D6ZUB7mfYRMb5wByE8L74HCn30FBN7sWnXksWc1LO1bPDl67pBR9o/kC4z/xSNAwkMYcGgqDV3BE3Hw==" + }, "detect-indent": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-6.1.0.tgz", @@ -6873,11 +6826,6 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, - "generic-pool": { - "version": "3.8.2", - "resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-3.8.2.tgz", - "integrity": "sha512-nGToKy6p3PAbYQ7p1UlWl6vSPwfwU6TMSWK7TTu+WUY4ZjyZQGniGGt2oNVvyNSpyZYSB43zMXVLcBm08MTMkg==" - }, "gensync": { "version": "1.0.0-beta.2", "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", @@ -8745,15 +8693,21 @@ } }, "redis": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/redis/-/redis-4.0.0.tgz", - "integrity": "sha512-LtV6+h0F/e3F4mtDKKGZIl/ekEjsiqX2E0hmtNqjGqXj3wYi/nAfeVNWKRa7wFuJ+nkqwXATFGvu6h2fLCgA1A==", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/redis/-/redis-3.1.2.tgz", + "integrity": "sha512-grn5KoZLr/qrRQVwoSkmzdbw6pwF+/rwODtrOr6vuBRiR/f3rjSTGupbF90Zpqm2oenix8Do6RV7pYEkGwlKkw==", "requires": { - "@node-redis/client": "^1.0.0", - "@node-redis/json": "^1.0.0", - "@node-redis/search": "^1.0.0" + "denque": "^1.5.0", + "redis-commands": "^1.7.0", + "redis-errors": "^1.2.0", + "redis-parser": "^3.0.0" } }, + "redis-commands": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.7.0.tgz", + "integrity": "sha512-nJWqw3bTFy21hX/CPKHth6sfhZbdiHP6bTawSgQBlKOVRG7EZkfHbbHwQJnrE4vsQf0CMNE+3gJ4Fmm16vdVlQ==" + }, "redis-errors": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz", @@ -9484,7 +9438,8 @@ "yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true }, "yargs": { "version": "16.2.0", diff --git a/package.json b/package.json index 012d3ca..4ba7107 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "fast-xml-parser": "^3.19.0", "nanoevents": "^2.0.0", "qs": "^6.8.0", - "redis": "^4.0.0" + "redis": "^3.1.1" }, "publishConfig": { "registry": "https://npm.pkg.github.com" From 0e090d25ff7da7658ea2daf117b7c7eff8e7d6bf Mon Sep 17 00:00:00 2001 From: taimoor0217 Date: Tue, 7 Dec 2021 12:14:33 +0500 Subject: [PATCH 06/37] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4ba7107..424a0b5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ecomshft/ebay-api", "author": "Daniil Tomilow (original author)", - "version": "5.1.3", + "version": "5.1.4", "description": "Modified version of eBay TypeScript/JavaScript API for Node and Browser", "browser": "./lib/ebay-api.min.js", "main": "./lib/index.js", From c59b0d498354830cec4a144ac05f02f6c773efd8 Mon Sep 17 00:00:00 2001 From: taimoor0217 Date: Tue, 7 Dec 2021 12:42:44 +0500 Subject: [PATCH 07/37] bug fixes extend token expiry time --- src/auth/redisClient.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/auth/redisClient.ts b/src/auth/redisClient.ts index 775844d..ea6b6b2 100644 --- a/src/auth/redisClient.ts +++ b/src/auth/redisClient.ts @@ -10,8 +10,9 @@ const HOUR_IN_SECONDS = 3600; // https://cloud.google.com/community/tutorials/nodejs-redis-on-appengine const client = (() => { + bluebird.promisifyAll(redis); + let redisClient = redis.createClient(); if (process.env.REDIS_PORT) { - bluebird.promisifyAll(redis); const authParams: { [index: string]: any; } = {}; @@ -19,25 +20,29 @@ const client = (() => { authParams.auth_pass = process.env.REDIS_KEY; authParams.return_buffers = true; } - return redis.createClient( + redisClient = redis.createClient( process.env.REDIS_PORT, process.env.REDIS_HOST, authParams ); } + return redisClient; })(); const hash = (text: any) => crypto.createHash("sha256").update(text).digest("hex"); - +const defaultKeyWord = "12345"; // https://github.com/brix/crypto-js#plain-text-encryption const encryptAccessToken = (accessToken: any) => - cryptojs.AES.encrypt(accessToken, process.env.EBAY_ACCESS_TOKEN_SECRET).toString(); + cryptojs.AES.encrypt( + accessToken, + process.env.EBAY_ACCESS_TOKEN_SECRET ?? defaultKeyWord + ).toString(); const decryptAccessToken = (encryptedToken: any) => cryptojs.AES.decrypt( encryptedToken, - process.env.EBAY_ACCESS_TOKEN_SECRET + process.env.EBAY_ACCESS_TOKEN_SECRET ?? defaultKeyWord ).toString(cryptojs.enc.Utf8); export const setAccessToken = async (refreshToken: any, accessToken: any) => { @@ -51,7 +56,7 @@ export const setAccessToken = async (refreshToken: any, accessToken: any) => { hashedRefreshToken, encryptedAccessToken, "EX", - HOUR_IN_SECONDS + 2 * (HOUR_IN_SECONDS - 120 ) //set expiry to be after 1 hour 58 minutes ); }; From df5328ab883f19e363dc5b327a1285c27d5550e1 Mon Sep 17 00:00:00 2001 From: taimoor0217 Date: Tue, 7 Dec 2021 12:45:47 +0500 Subject: [PATCH 08/37] update package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 424a0b5..015e25e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ecomshft/ebay-api", "author": "Daniil Tomilow (original author)", - "version": "5.1.4", + "version": "5.1.5", "description": "Modified version of eBay TypeScript/JavaScript API for Node and Browser", "browser": "./lib/ebay-api.min.js", "main": "./lib/index.js", From b7574162165f071ffdeffa47bc793c55fa7e4378 Mon Sep 17 00:00:00 2001 From: taimoor0217 Date: Tue, 7 Dec 2021 16:54:53 +0500 Subject: [PATCH 09/37] fix bug --- src/auth/redisClient.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/auth/redisClient.ts b/src/auth/redisClient.ts index ea6b6b2..e7e611c 100644 --- a/src/auth/redisClient.ts +++ b/src/auth/redisClient.ts @@ -11,7 +11,6 @@ const HOUR_IN_SECONDS = 3600; // https://cloud.google.com/community/tutorials/nodejs-redis-on-appengine const client = (() => { bluebird.promisifyAll(redis); - let redisClient = redis.createClient(); if (process.env.REDIS_PORT) { const authParams: { [index: string]: any; @@ -20,13 +19,14 @@ const client = (() => { authParams.auth_pass = process.env.REDIS_KEY; authParams.return_buffers = true; } - redisClient = redis.createClient( + return redis.createClient( process.env.REDIS_PORT, process.env.REDIS_HOST, authParams ); + } else { + return redis.createClient(); } - return redisClient; })(); const hash = (text: any) => @@ -56,7 +56,7 @@ export const setAccessToken = async (refreshToken: any, accessToken: any) => { hashedRefreshToken, encryptedAccessToken, "EX", - 2 * (HOUR_IN_SECONDS - 120 ) //set expiry to be after 1 hour 58 minutes + 2 * (HOUR_IN_SECONDS - 120) //set expiry to be after 1 hour 58 minutes ); }; From 1d53609bb6db7da1fb744f12f50a72353a9abeb3 Mon Sep 17 00:00:00 2001 From: taimoor0217 Date: Tue, 7 Dec 2021 16:58:21 +0500 Subject: [PATCH 10/37] update versio --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 015e25e..161f605 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ecomshft/ebay-api", "author": "Daniil Tomilow (original author)", - "version": "5.1.5", + "version": "5.1.6", "description": "Modified version of eBay TypeScript/JavaScript API for Node and Browser", "browser": "./lib/ebay-api.min.js", "main": "./lib/index.js", From e513cb94b27e9f0dfccc8e49d9e8faec7a9aa7d7 Mon Sep 17 00:00:00 2001 From: taimoor0217 Date: Sun, 12 Dec 2021 14:01:36 +0500 Subject: [PATCH 11/37] add functions for inventory tasks --- src/api/restful/sell/feed/index.ts | 139 +++++++++++++++++++---------- 1 file changed, 92 insertions(+), 47 deletions(-) diff --git a/src/api/restful/sell/feed/index.ts b/src/api/restful/sell/feed/index.ts index 6b7b7f7..6b18bea 100644 --- a/src/api/restful/sell/feed/index.ts +++ b/src/api/restful/sell/feed/index.ts @@ -1,16 +1,15 @@ -import Restful from '../../'; -import {multipartHeader} from '../../../../request'; -import {SellFeedParams} from '../../../../types'; +import Restful from "../../"; +import { multipartHeader } from "../../../../request"; +import { SellFeedParams } from "../../../../types"; /** * The Feed API lets sellers upload input files, download reports and files including their status, filter reports using URI parameters, and retrieve customer service metrics task details. */ export default class Feed extends Restful { - - static id = 'Feed'; + static id = "Feed"; get basePath(): string { - return '/sell/feed/v1'; + return "/sell/feed/v1"; } /** @@ -24,13 +23,13 @@ export default class Feed extends Restful { * @param scheduleId The schedule ID associated with the order task. */ public getOrderTasks({ - dateRange, - feedType, - limit, - lookBackDays, - offset, - scheduleId - }: SellFeedParams = {}) { + dateRange, + feedType, + limit, + lookBackDays, + offset, + scheduleId, + }: SellFeedParams = {}) { return this.get(`/order_task`, { params: { date_range: dateRange, @@ -38,8 +37,58 @@ export default class Feed extends Restful { limit, look_back_days: lookBackDays, offset, - schedule_id: scheduleId - } + schedule_id: scheduleId, + }, + }); + } + + /** + * This method creates an inventory task with filter criteria for the order report. + * + * @param data The CreateInvetoryTaskrequest + * @param marketPlaceId The market place ID of the inventory task. + */ + public createInventoryTask(data: any, marketPlaceId?: string) { + return this.post(`/inventory_task`, data, { + headers: { + "X-EBAY-C-MARKETPLACE-ID": marketPlaceId, + }, + }); + } + /** + * This method gets an inventory. + * + * @param taskId The CreateInvetoryTaskrequest + */ + public getInventoryTask(taskId: string) { + taskId = encodeURIComponent(taskId); + return this.get(`/inventory_task/${taskId}`); + } + + /** + * This method searches for multiple tasks of a specific feed type, and includes date filters and pagination. + * + * @param data An object containing the following parameters: + */ + // feed_type=string& + // schedule_id=string& + // look_back_days=integer& + // date_range=string& + // limit=integer& + // offset=integer + + public getInventoryTasks(data: { + feed_type: string; + schedule_id: string; + look_back_days: number; + date_range: string; + limit: number; + offset: number; + }) { + return this.get(`/inventory_task`, { + params: { + ...data, + }, }); } @@ -57,7 +106,7 @@ export default class Feed extends Restful { * * @param taskId The ID of the task. This ID is generated when the task was created by the createOrderTask method. */ - public getOrderTask(taskId: string,) { + public getOrderTask(taskId: string) { taskId = encodeURIComponent(taskId); return this.get(`/order_task/${taskId}`); @@ -70,17 +119,13 @@ export default class Feed extends Restful { * @param limit The maximum number of schedules that can be returned on each page of the paginated response. * @param offset The number of schedules to skip in the result set before returning the first schedule in the paginated response. */ - public getSchedules({ - feedType, - limit, - offset, - }: SellFeedParams = {}) { + public getSchedules({ feedType, limit, offset }: SellFeedParams = {}) { return this.get(`/schedule`, { params: { feed_type: feedType, limit, - offset - } + offset, + }, }); } @@ -152,16 +197,16 @@ export default class Feed extends Restful { * @param offset The number of schedules to skip in the result set before returning the first schedule in the paginated response. */ public getScheduleTemplates({ - feedType, - limit, - offset, - }: SellFeedParams = {}) { + feedType, + limit, + offset, + }: SellFeedParams = {}) { return this.get(`/schedule_template`, { params: { feed_type: feedType, limit, - offset - } + offset, + }, }); } @@ -176,13 +221,13 @@ export default class Feed extends Restful { * @param scheduleId The schedule ID associated with the task. */ public getTasks({ - dateRange, - feedType, - limit, - lookBackDays, - offset, - scheduleId - }: SellFeedParams = {}) { + dateRange, + feedType, + limit, + lookBackDays, + offset, + scheduleId, + }: SellFeedParams = {}) { return this.get(`/task`, { params: { date_range: dateRange, @@ -190,8 +235,8 @@ export default class Feed extends Restful { limit, look_back_days: lookBackDays, offset, - schedule_id: scheduleId - } + schedule_id: scheduleId, + }, }); } @@ -258,12 +303,12 @@ export default class Feed extends Restful { * @param scheduleId The schedule ID associated with the task. */ public getCustomerServiceMetricTasks({ - dateRange, - feedType, - limit, - lookBackDays, - offset, - }: SellFeedParams = {}) { + dateRange, + feedType, + limit, + lookBackDays, + offset, + }: SellFeedParams = {}) { return this.get(`/customer_service_metric_task`, { params: { date_range: dateRange, @@ -271,7 +316,7 @@ export default class Feed extends Restful { limit, look_back_days: lookBackDays, offset, - } + }, }); } @@ -284,8 +329,8 @@ export default class Feed extends Restful { public createCustomerServiceMetricTask(acceptLanguage: string, data: any) { return this.post(`/customer_service_metric_task`, data, { headers: { - 'accept-language': acceptLanguage - } + "accept-language": acceptLanguage, + }, }); } From 297f82c6210f18389f179f402eed67aad6a735ad Mon Sep 17 00:00:00 2001 From: Sehar Abbas Date: Sun, 12 Dec 2021 14:03:25 +0300 Subject: [PATCH 12/37] package version update --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 161f605..1a8c3b4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ecomshft/ebay-api", "author": "Daniil Tomilow (original author)", - "version": "5.1.6", + "version": "5.1.7", "description": "Modified version of eBay TypeScript/JavaScript API for Node and Browser", "browser": "./lib/ebay-api.min.js", "main": "./lib/index.js", From f382e78ce6744c68f68eca4fa1ce60f5bd9dd42a Mon Sep 17 00:00:00 2001 From: Sehar Abbas Date: Sun, 12 Dec 2021 16:48:55 +0300 Subject: [PATCH 13/37] added resolveWithFullResponse --- package.json | 2 +- src/api/restful/sell/feed/index.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 1a8c3b4..ae8c402 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ecomshft/ebay-api", "author": "Daniil Tomilow (original author)", - "version": "5.1.7", + "version": "5.1.8", "description": "Modified version of eBay TypeScript/JavaScript API for Node and Browser", "browser": "./lib/ebay-api.min.js", "main": "./lib/index.js", diff --git a/src/api/restful/sell/feed/index.ts b/src/api/restful/sell/feed/index.ts index 6b18bea..f74a673 100644 --- a/src/api/restful/sell/feed/index.ts +++ b/src/api/restful/sell/feed/index.ts @@ -52,6 +52,7 @@ export default class Feed extends Restful { return this.post(`/inventory_task`, data, { headers: { "X-EBAY-C-MARKETPLACE-ID": marketPlaceId, + "resolveWithFullResponse": true }, }); } From e3ec10beb1688b6b3e109e59caefba04dd9bc2d0 Mon Sep 17 00:00:00 2001 From: seharconrad Date: Sun, 12 Dec 2021 16:53:09 +0300 Subject: [PATCH 14/37] Update npm-publish.yml --- .github/workflows/npm-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 72ca7ec..a3f44f3 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v2 with: - ref: deploy-ecomshft + ref: feat/inventory-tasks - uses: actions/setup-node@v1 with: node-version: 12 From 2a7a890ea58f3d82ffc2a67f7aa1be09bd54cd6d Mon Sep 17 00:00:00 2001 From: Sehar Abbas Date: Sun, 12 Dec 2021 17:08:11 +0300 Subject: [PATCH 15/37] upgraded version of package --- package.json | 2 +- src/api/restful/sell/feed/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ae8c402..c02b6b3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ecomshft/ebay-api", "author": "Daniil Tomilow (original author)", - "version": "5.1.8", + "version": "5.1.9", "description": "Modified version of eBay TypeScript/JavaScript API for Node and Browser", "browser": "./lib/ebay-api.min.js", "main": "./lib/index.js", diff --git a/src/api/restful/sell/feed/index.ts b/src/api/restful/sell/feed/index.ts index f74a673..acc0349 100644 --- a/src/api/restful/sell/feed/index.ts +++ b/src/api/restful/sell/feed/index.ts @@ -52,8 +52,8 @@ export default class Feed extends Restful { return this.post(`/inventory_task`, data, { headers: { "X-EBAY-C-MARKETPLACE-ID": marketPlaceId, - "resolveWithFullResponse": true }, + "resolveWithFullResponse": true }); } /** From 1aa73af3a9f96dc407f2ecfca98e8cd6bb3cbf39 Mon Sep 17 00:00:00 2001 From: taimoor0217 Date: Tue, 14 Dec 2021 15:35:34 +0500 Subject: [PATCH 16/37] allow request headers option --- src/api/restful/index.ts | 179 ++++++++++++++++++----------- src/api/restful/sell/feed/index.ts | 3 +- src/request.ts | 81 ++++++++----- 3 files changed, 170 insertions(+), 93 deletions(-) diff --git a/src/api/restful/index.ts b/src/api/restful/index.ts index 8c1af56..21a018d 100644 --- a/src/api/restful/index.ts +++ b/src/api/restful/index.ts @@ -1,51 +1,57 @@ -import Api from '../'; -import Auth from '../../auth'; -import {EBayInvalidAccessToken, handleEBayError} from '../../errors'; -import {IEBayApiRequest} from '../../request'; -import {AppConfig} from '../../types'; +import Api from "../"; +import Auth from "../../auth"; +import { EBayInvalidAccessToken, handleEBayError } from "../../errors"; +import { IEBayApiRequest } from "../../request"; +import { AppConfig } from "../../types"; export const defaultApiHeaders: Record = { - 'Content-Type': 'application/json', - 'Cache-Control': 'no-cache', + "Content-Type": "application/json", + "Cache-Control": "no-cache", // @ts-ignore - ...(typeof window === 'undefined' ? { - 'Accept-Encoding': 'application/gzip' - } : {}) + ...(typeof window === "undefined" + ? { + "Accept-Encoding": "application/gzip", + } + : {}), }; const additionalHeaders: Record = { - marketplaceId: 'X-EBAY-C-MARKETPLACE-ID', - endUserCtx: 'X-EBAY-C-ENDUSERCTX', - acceptLanguage: 'Accept-Language', - contentLanguage: 'Content-Language', + marketplaceId: "X-EBAY-C-MARKETPLACE-ID", + endUserCtx: "X-EBAY-C-ENDUSERCTX", + acceptLanguage: "Accept-Language", + contentLanguage: "Content-Language", }; export type ApiConfig = { - subdomain?: string - useIaf?: boolean - apiVersion?: string - basePath?: string - schema?: string - sandbox?: boolean - tld?: string - headers?: Record -} + subdomain?: string; + useIaf?: boolean; + apiVersion?: string; + basePath?: string; + schema?: string; + sandbox?: boolean; + tld?: string; + headers?: Record; +}; export type ApiRequest = { - method: keyof IEBayApiRequest, - url: string, - config?: any, // AxiosConfig - data?: any, -} + method: keyof IEBayApiRequest; + url: string; + config?: any; // AxiosConfig + data?: any; +}; export interface IRestful { - new(config: AppConfig, req?: IEBayApiRequest, auth?: Auth, apiConfig?: ApiConfig): Restful; + new ( + config: AppConfig, + req?: IEBayApiRequest, + auth?: Auth, + apiConfig?: ApiConfig + ): Restful; id: string; } export default abstract class Restful extends Api { - public readonly apiConfig: Required; constructor( @@ -58,12 +64,17 @@ export default abstract class Restful extends Api { this.apiConfig = { ...this.getApiConfig(), - ...apiConfig + ...apiConfig, }; } - public static buildServerUrl(schema: string, subdomain: string, sandbox: boolean, tld: string) { - return `${schema}${subdomain}.${sandbox ? 'sandbox.' : ''}${tld}`; + public static buildServerUrl( + schema: string, + subdomain: string, + sandbox: boolean, + tld: string + ) { + return `${schema}${subdomain}.${sandbox ? "sandbox." : ""}${tld}`; } abstract get basePath(): string; @@ -76,19 +87,30 @@ export default abstract class Restful extends Api { } get schema() { - return 'https://'; + return "https://"; } get subdomain() { - return 'api'; + return "api"; } get apiVersionPath() { - return ''; + return ""; } - public getServerUrl({schema, subdomain, apiVersion, basePath, sandbox, tld}: Required): string { - return Restful.buildServerUrl(schema, subdomain, sandbox, tld) + apiVersion + basePath; + public getServerUrl({ + schema, + subdomain, + apiVersion, + basePath, + sandbox, + tld, + }: Required): string { + return ( + Restful.buildServerUrl(schema, subdomain, sandbox, tld) + + apiVersion + + basePath + ); } public getApiConfig(): Required { @@ -99,8 +121,8 @@ export default abstract class Restful extends Api { basePath: this.basePath, schema: this.schema, sandbox: this.config.sandbox, - tld: 'ebay.com', - headers: {} + tld: "ebay.com", + headers: {}, }; } @@ -121,59 +143,78 @@ export default abstract class Restful extends Api { * Use "apix" subdomain */ get apix() { - return this.api({subdomain: 'apix'}); + return this.api({ subdomain: "apix" }); } /** * Use "apiz" subdomain */ get apiz() { - return this.api({subdomain: 'apiz'}); + return this.api({ subdomain: "apiz" }); } public async get(url: string, config: any = {}, apiConfig?: ApiConfig) { - return this.doRequest({method: 'get', url, config}, apiConfig); + return this.doRequest({ method: "get", url, config }, apiConfig); } public async delete(url: string, config: any = {}, apiConfig?: ApiConfig) { - return this.doRequest({method: 'delete', url, config}, apiConfig); + return this.doRequest({ method: "delete", url, config }, apiConfig); } - public async post(url: string, data?: any, config: any = {}, apiConfig?: ApiConfig) { - return this.doRequest({method: 'post', url, data, config}, apiConfig); + public async post( + url: string, + data?: any, + config: any = {}, + apiConfig?: ApiConfig, + requestHeaders?: boolean + ) { + return this.doRequest( + { method: "post", url, data, config: { ...config, requestHeaders } }, + apiConfig + ); } - public async put(url: string, data?: any, config: any = {}, apiConfig?: ApiConfig) { - return this.doRequest({method: 'put', url, data, config}, apiConfig); + public async put( + url: string, + data?: any, + config: any = {}, + apiConfig?: ApiConfig + ) { + return this.doRequest({ method: "put", url, data, config }, apiConfig); } get additionalHeaders() { - return Object.keys(additionalHeaders) - // @ts-ignore - .filter(key => typeof this.config[key] !== 'undefined') - .reduce((headers: any, key) => { + return ( + Object.keys(additionalHeaders) // @ts-ignore - headers[additionalHeaders[key]] = this.config[key]; - return headers; - }, {}); + .filter((key) => typeof this.config[key] !== "undefined") + .reduce((headers: any, key) => { + // @ts-ignore + headers[additionalHeaders[key]] = this.config[key]; + return headers; + }, {}) + ); } - public async enrichRequestConfig(config: any = {}, apiConfig: Required = this.apiConfig) { + public async enrichRequestConfig( + config: any = {}, + apiConfig: Required = this.apiConfig + ) { const authHeader = await this.auth.getHeaderAuthorization(apiConfig.useIaf); const headers = { ...defaultApiHeaders, ...this.additionalHeaders, ...authHeader, - ...apiConfig.headers + ...apiConfig.headers, }; return { ...config, headers: { ...(config.headers || {}), - ...headers - } + ...headers, + }, }; } @@ -199,17 +240,20 @@ export default abstract class Restful extends Api { return true; } - return error?.meta?.res?.status === 401 && this.apiConfig.basePath === '/post-order/v2'; + return ( + error?.meta?.res?.status === 401 && + this.apiConfig.basePath === "/post-order/v2" + ); } private async request( apiRequest: ApiRequest, apiConfig: ApiConfig = this.apiConfig, - refreshToken = false, + refreshToken = false ): Promise { - const {url, method, data, config} = apiRequest; - - const apiCfg: Required = {...this.apiConfig, ...apiConfig}; + const { url, method, data, config } = apiRequest; + const { requestHeaders } = config; + const apiCfg: Required = { ...this.apiConfig, ...apiConfig }; const endpoint = this.getServerUrl(apiCfg) + url; try { @@ -219,7 +263,12 @@ export default abstract class Restful extends Api { const enrichedConfig = await this.enrichRequestConfig(config, apiCfg); - const args = ['get', 'delete'].includes(method) ? [enrichedConfig] : [data, enrichedConfig]; + let args = ["get", "delete"].includes(method) + ? [enrichedConfig] + : [data, enrichedConfig]; + if (method === "post" && requestHeaders) { + args.push(true); + } // @ts-ignore return await this.req[method](endpoint, ...args); } catch (ex) { diff --git a/src/api/restful/sell/feed/index.ts b/src/api/restful/sell/feed/index.ts index acc0349..e76dbb8 100644 --- a/src/api/restful/sell/feed/index.ts +++ b/src/api/restful/sell/feed/index.ts @@ -53,8 +53,7 @@ export default class Feed extends Restful { headers: { "X-EBAY-C-MARKETPLACE-ID": marketPlaceId, }, - "resolveWithFullResponse": true - }); + }, undefined, true); } /** * This method gets an inventory. diff --git a/src/request.ts b/src/request.ts index 0bd3194..2f6b4d6 100644 --- a/src/request.ts +++ b/src/request.ts @@ -1,18 +1,19 @@ -import axios, {AxiosInstance, AxiosRequestConfig} from 'axios'; -import debug from 'debug'; -import qs from 'qs'; +import axios, { AxiosInstance, AxiosRequestConfig } from "axios"; +import debug from "debug"; +import qs from "qs"; -const log = debug('ebay:request'); +const log = debug("ebay:request"); export const defaultGlobalHeaders = { - 'Access-Control-Allow-Origin': '*', - 'Access-Control-Allow-Headers': 'X-Requested-With, Origin, Content-Type, X-Auth-Token', - 'Access-Control-Allow-Methods': 'GET, PUT, POST, DELETE' -} + "Access-Control-Allow-Origin": "*", + "Access-Control-Allow-Headers": + "X-Requested-With, Origin, Content-Type, X-Auth-Token", + "Access-Control-Allow-Methods": "GET, PUT, POST, DELETE", +}; export const multipartHeader = { - 'Content-Type': 'multipart/form-data' -} + "Content-Type": "multipart/form-data", +}; export interface IEBayApiRequest { readonly instance: T; @@ -21,7 +22,12 @@ export interface IEBayApiRequest { delete(url: string, config?: C): Promise; - post(url: string, data?: any, config?: C): Promise; + post( + url: string, + data?: any, + config?: C, + requestHeaders?: boolean + ): Promise; postForm(url: string, data?: any, config?: C): Promise; @@ -34,35 +40,58 @@ export class AxiosRequest implements IEBayApiRequest { constructor(config: AxiosRequestConfig = {}) { this.instance = axios.create({ headers: { - ...defaultGlobalHeaders + ...defaultGlobalHeaders, }, - ...config + ...config, }); } public get(url: string, config?: AxiosRequestConfig): Promise { - log('get: ' + url, config); - return this.instance.get(url, config).then(({data}: any) => data); + log("get: " + url, config); + return this.instance.get(url, config).then(({ data }: any) => data); } - public post(url: string, payload?: any, config?: AxiosRequestConfig): Promise { - log('post: ' + url, {payload, config}); - return this.instance.post(url, payload, config).then(({data}: any) => data); + public post( + url: string, + payload?: any, + config?: AxiosRequestConfig, + requestHeaders?: boolean + ): Promise { + log("post: " + url, { payload, config }); + return this.instance + .post(url, payload, config) + .then(({ data, headers }: any) => { + console.log("REQUEST HEADERS", requestHeaders) + if (requestHeaders) { + return { data, headers }; + } + return data; + }); } public delete(url: string, config?: AxiosRequestConfig): Promise { - log('delete: ' + url, config); - return this.instance.delete(url, config).then(({data}: any) => data); + log("delete: " + url, config); + return this.instance.delete(url, config).then(({ data }: any) => data); } - public put(url: string, payload?: any, config?: AxiosRequestConfig): Promise { - log('put: ' + url, {payload, config}); - return this.instance.put(url, payload, config).then(({data} : any) => data); + public put( + url: string, + payload?: any, + config?: AxiosRequestConfig + ): Promise { + log("put: " + url, { payload, config }); + return this.instance + .put(url, payload, config) + .then(({ data }: any) => data); } - public postForm(url: string, payload?: any, config?: AxiosRequestConfig): Promise { - log('postForm: ' + url); + public postForm( + url: string, + payload?: any, + config?: AxiosRequestConfig + ): Promise { + log("postForm: " + url); const body = qs.stringify(payload); - return this.instance.post(url, body, config).then(({data}: any) => data); + return this.instance.post(url, body, config).then(({ data }: any) => data); } } From 3fc8cfd761ad27b6bd058b921158702997f55f27 Mon Sep 17 00:00:00 2001 From: taimoor0217 Date: Tue, 14 Dec 2021 15:37:39 +0500 Subject: [PATCH 17/37] update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c02b6b3..2b3b460 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ecomshft/ebay-api", "author": "Daniil Tomilow (original author)", - "version": "5.1.9", + "version": "5.2.0", "description": "Modified version of eBay TypeScript/JavaScript API for Node and Browser", "browser": "./lib/ebay-api.min.js", "main": "./lib/index.js", From 3236cc8c48fc77830f588df94881e770209da296 Mon Sep 17 00:00:00 2001 From: taimoor0217 Date: Tue, 14 Dec 2021 15:46:52 +0500 Subject: [PATCH 18/37] update npm-publish remove log --- .github/workflows/npm-publish.yml | 2 +- src/request.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index a3f44f3..686ea24 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v2 with: - ref: feat/inventory-tasks + ref: feat/deploy-ecomshft - uses: actions/setup-node@v1 with: node-version: 12 diff --git a/src/request.ts b/src/request.ts index 2f6b4d6..70dfa2d 100644 --- a/src/request.ts +++ b/src/request.ts @@ -61,7 +61,6 @@ export class AxiosRequest implements IEBayApiRequest { return this.instance .post(url, payload, config) .then(({ data, headers }: any) => { - console.log("REQUEST HEADERS", requestHeaders) if (requestHeaders) { return { data, headers }; } From e1f2cd4ec40712155ccbf2929f60babb15ffed6d Mon Sep 17 00:00:00 2001 From: taimoor0217 Date: Thu, 16 Dec 2021 12:59:07 +0500 Subject: [PATCH 19/37] add responseType to the get request --- src/api/restful/sell/feed/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/api/restful/sell/feed/index.ts b/src/api/restful/sell/feed/index.ts index e76dbb8..43c7ed5 100644 --- a/src/api/restful/sell/feed/index.ts +++ b/src/api/restful/sell/feed/index.ts @@ -266,7 +266,9 @@ export default class Feed extends Restful { */ public getResultFile(taskId: string) { taskId = encodeURIComponent(taskId); - return this.get(`/task/${taskId}/download_result_file`); + return this.get(`/task/${taskId}/download_result_file`, { + reponseType: "arraybuffer" + }); } /** From 1924d6905215d0a93267561a0f293ae169dba6b2 Mon Sep 17 00:00:00 2001 From: taimoor0217 Date: Thu, 16 Dec 2021 12:59:26 +0500 Subject: [PATCH 20/37] bump package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b3b460..282d6e1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ecomshft/ebay-api", "author": "Daniil Tomilow (original author)", - "version": "5.2.0", + "version": "5.2.1", "description": "Modified version of eBay TypeScript/JavaScript API for Node and Browser", "browser": "./lib/ebay-api.min.js", "main": "./lib/index.js", From f074012d0f132b32ebaafc51bbf6f840a01a4e38 Mon Sep 17 00:00:00 2001 From: Taimoor Ali Date: Thu, 16 Dec 2021 13:40:57 +0500 Subject: [PATCH 21/37] Update npm-publish.yml --- .github/workflows/npm-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 686ea24..72ca7ec 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v2 with: - ref: feat/deploy-ecomshft + ref: deploy-ecomshft - uses: actions/setup-node@v1 with: node-version: 12 From fc5935b3b20235aaea37fd33a90c550282b8c0c9 Mon Sep 17 00:00:00 2001 From: taimoor0217 Date: Thu, 16 Dec 2021 13:51:33 +0500 Subject: [PATCH 22/37] fix typo --- package.json | 2 +- src/api/restful/sell/feed/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 282d6e1..d8e2804 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ecomshft/ebay-api", "author": "Daniil Tomilow (original author)", - "version": "5.2.1", + "version": "5.2.2", "description": "Modified version of eBay TypeScript/JavaScript API for Node and Browser", "browser": "./lib/ebay-api.min.js", "main": "./lib/index.js", diff --git a/src/api/restful/sell/feed/index.ts b/src/api/restful/sell/feed/index.ts index 43c7ed5..8b9b317 100644 --- a/src/api/restful/sell/feed/index.ts +++ b/src/api/restful/sell/feed/index.ts @@ -267,7 +267,7 @@ export default class Feed extends Restful { public getResultFile(taskId: string) { taskId = encodeURIComponent(taskId); return this.get(`/task/${taskId}/download_result_file`, { - reponseType: "arraybuffer" + responseType: "arraybuffer" }); } From 9c903ce05b576c58f1439b54b6a276d2d2b0bbac Mon Sep 17 00:00:00 2001 From: taimoor0217 Date: Thu, 16 Dec 2021 17:04:07 +0500 Subject: [PATCH 23/37] remove default keyword from redis client add option to get request headers --- src/api/restful/index.ts | 22 +++++++++++++++++----- src/auth/redisClient.ts | 8 +++++--- src/request.ts | 38 +++++++++++++++++++++++++++++++------- 3 files changed, 53 insertions(+), 15 deletions(-) diff --git a/src/api/restful/index.ts b/src/api/restful/index.ts index 21a018d..b616892 100644 --- a/src/api/restful/index.ts +++ b/src/api/restful/index.ts @@ -153,8 +153,16 @@ export default abstract class Restful extends Api { return this.api({ subdomain: "apiz" }); } - public async get(url: string, config: any = {}, apiConfig?: ApiConfig) { - return this.doRequest({ method: "get", url, config }, apiConfig); + public async get( + url: string, + config: any = {}, + apiConfig?: ApiConfig, + requestHeaders?: boolean + ) { + return this.doRequest( + { method: "get", url, config: { ...config, requestHeaders } }, + apiConfig + ); } public async delete(url: string, config: any = {}, apiConfig?: ApiConfig) { @@ -178,9 +186,13 @@ export default abstract class Restful extends Api { url: string, data?: any, config: any = {}, - apiConfig?: ApiConfig + apiConfig?: ApiConfig, + requestHeaders?: boolean ) { - return this.doRequest({ method: "put", url, data, config }, apiConfig); + return this.doRequest( + { method: "put", url, data, config: { ...config, requestHeaders } }, + apiConfig + ); } get additionalHeaders() { @@ -266,7 +278,7 @@ export default abstract class Restful extends Api { let args = ["get", "delete"].includes(method) ? [enrichedConfig] : [data, enrichedConfig]; - if (method === "post" && requestHeaders) { + if (["post", "get", "put"].includes(method) && requestHeaders) { args.push(true); } // @ts-ignore diff --git a/src/auth/redisClient.ts b/src/auth/redisClient.ts index e7e611c..d87525c 100644 --- a/src/auth/redisClient.ts +++ b/src/auth/redisClient.ts @@ -10,6 +10,9 @@ const HOUR_IN_SECONDS = 3600; // https://cloud.google.com/community/tutorials/nodejs-redis-on-appengine const client = (() => { + if (!process.env.EBAY_ACCESS_TOKEN_SECRET) { + throw new Error("EBAY_ACCESS_TOKEN_SECRET is not set"); + } bluebird.promisifyAll(redis); if (process.env.REDIS_PORT) { const authParams: { @@ -31,18 +34,17 @@ const client = (() => { const hash = (text: any) => crypto.createHash("sha256").update(text).digest("hex"); -const defaultKeyWord = "12345"; // https://github.com/brix/crypto-js#plain-text-encryption const encryptAccessToken = (accessToken: any) => cryptojs.AES.encrypt( accessToken, - process.env.EBAY_ACCESS_TOKEN_SECRET ?? defaultKeyWord + process.env.EBAY_ACCESS_TOKEN_SECRET ).toString(); const decryptAccessToken = (encryptedToken: any) => cryptojs.AES.decrypt( encryptedToken, - process.env.EBAY_ACCESS_TOKEN_SECRET ?? defaultKeyWord + process.env.EBAY_ACCESS_TOKEN_SECRET ).toString(cryptojs.enc.Utf8); export const setAccessToken = async (refreshToken: any, accessToken: any) => { diff --git a/src/request.ts b/src/request.ts index 70dfa2d..6e16675 100644 --- a/src/request.ts +++ b/src/request.ts @@ -18,7 +18,11 @@ export const multipartHeader = { export interface IEBayApiRequest { readonly instance: T; - get(url: string, config?: C): Promise; + get( + url: string, + config?: C, + requestHeaders?: boolean + ): Promise; delete(url: string, config?: C): Promise; @@ -31,7 +35,12 @@ export interface IEBayApiRequest { postForm(url: string, data?: any, config?: C): Promise; - put(url: string, data?: any, config?: C): Promise; + put( + url: string, + data?: any, + config?: C, + requestHeaders?: boolean + ): Promise; } export class AxiosRequest implements IEBayApiRequest { @@ -46,16 +55,25 @@ export class AxiosRequest implements IEBayApiRequest { }); } - public get(url: string, config?: AxiosRequestConfig): Promise { + public get( + url: string, + config?: AxiosRequestConfig, + requestHeaders?: boolean + ): Promise { log("get: " + url, config); - return this.instance.get(url, config).then(({ data }: any) => data); + return this.instance.get(url, config).then(({ data, headers }: any) => { + if (requestHeaders) { + return { data, headers }; + } + return data; + }); } public post( url: string, payload?: any, config?: AxiosRequestConfig, - requestHeaders?: boolean + requestHeaders?: boolean ): Promise { log("post: " + url, { payload, config }); return this.instance @@ -76,12 +94,18 @@ export class AxiosRequest implements IEBayApiRequest { public put( url: string, payload?: any, - config?: AxiosRequestConfig + config?: AxiosRequestConfig, + requestHeaders?: boolean ): Promise { log("put: " + url, { payload, config }); return this.instance .put(url, payload, config) - .then(({ data }: any) => data); + .then(({ data, headers }: any) => { + if (requestHeaders) { + return { data, headers }; + } + return data; + }); } public postForm( From ab0a41a731d360d5aef45555d2912bf178b81e6c Mon Sep 17 00:00:00 2001 From: Taimoor Ali Date: Thu, 16 Dec 2021 17:12:36 +0500 Subject: [PATCH 24/37] update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d8e2804..0322d6d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ecomshft/ebay-api", "author": "Daniil Tomilow (original author)", - "version": "5.2.2", + "version": "5.2.3", "description": "Modified version of eBay TypeScript/JavaScript API for Node and Browser", "browser": "./lib/ebay-api.min.js", "main": "./lib/index.js", From 77d36cb2171a8b07a47902a5aec8dc92b30620ef Mon Sep 17 00:00:00 2001 From: taimoor0217 Date: Tue, 21 Dec 2021 12:44:20 +0500 Subject: [PATCH 25/37] update createOrderTask network call --- package.json | 2 +- src/api/restful/sell/feed/index.ts | 30 +++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 0322d6d..b4af030 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ecomshft/ebay-api", "author": "Daniil Tomilow (original author)", - "version": "5.2.3", + "version": "5.2.4", "description": "Modified version of eBay TypeScript/JavaScript API for Node and Browser", "browser": "./lib/ebay-api.min.js", "main": "./lib/index.js", diff --git a/src/api/restful/sell/feed/index.ts b/src/api/restful/sell/feed/index.ts index 8b9b317..7d8b282 100644 --- a/src/api/restful/sell/feed/index.ts +++ b/src/api/restful/sell/feed/index.ts @@ -49,11 +49,17 @@ export default class Feed extends Restful { * @param marketPlaceId The market place ID of the inventory task. */ public createInventoryTask(data: any, marketPlaceId?: string) { - return this.post(`/inventory_task`, data, { - headers: { - "X-EBAY-C-MARKETPLACE-ID": marketPlaceId, + return this.post( + `/inventory_task`, + data, + { + headers: { + "X-EBAY-C-MARKETPLACE-ID": marketPlaceId ?? "EBAY_US", + }, }, - }, undefined, true); + undefined, + true + ); } /** * This method gets an inventory. @@ -97,8 +103,18 @@ export default class Feed extends Restful { * * @param data The CreateOrderTaskRequest */ - public createOrderTask(data: any) { - return this.post(`/order_task`, data); + public createOrderTask(data: any, marketplaceId?: string) { + return this.post( + `/order_task`, + data, + { + headers: { + "X-EBAY-C-MARKETPLACE-ID": marketplaceId ?? "EBAY_US", + }, + }, + undefined, + true + ); } /** @@ -267,7 +283,7 @@ export default class Feed extends Restful { public getResultFile(taskId: string) { taskId = encodeURIComponent(taskId); return this.get(`/task/${taskId}/download_result_file`, { - responseType: "arraybuffer" + responseType: "arraybuffer", }); } From cf0bae9388a02908af3021b453810251b3a903d5 Mon Sep 17 00:00:00 2001 From: Sehar Abbas Date: Tue, 4 Jan 2022 12:42:19 +0300 Subject: [PATCH 26/37] Added accept-language header to getOffers --- src/api/restful/sell/inventory/index.ts | 38 ++++++++++++++----------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/api/restful/sell/inventory/index.ts b/src/api/restful/sell/inventory/index.ts index c8c41c6..d9620d3 100644 --- a/src/api/restful/sell/inventory/index.ts +++ b/src/api/restful/sell/inventory/index.ts @@ -1,4 +1,4 @@ -import Restful from '../../'; +import Restful from "../../"; import { BulkEbayOfferDetailsWithKeys, BulkInventoryItem, @@ -15,18 +15,17 @@ import { PublishByInventoryItemGroupRequest, SellInventoryItem, WithdrawByInventoryItemGroupRequest, -} from '../../../../types'; +} from "../../../../types"; /** * The Inventory API is used to create and manage inventory, and then to publish and manage this inventory on an eBay * marketplace. */ export default class Inventory extends Restful { - - static id = 'Inventory'; + static id = "Inventory"; get basePath(): string { - return '/sell/inventory/v1'; + return "/sell/inventory/v1"; } /** @@ -70,9 +69,9 @@ export default class Inventory extends Restful { * @param offset The value passed in this query parameter sets the page number to retrieve. */ public getInventoryLocations({ - limit, - offset, - }: { limit?: number; offset?: number } = {}) { + limit, + offset, + }: { limit?: number; offset?: number } = {}) { return this.get(`/location`, { params: { limit, @@ -162,9 +161,9 @@ export default class Inventory extends Restful { * @param offset The value passed in this query parameter sets the page number to retrieve. */ public getInventoryItems({ - limit, - offset, - }: { limit?: number; offset?: number } = {}) { + limit, + offset, + }: { limit?: number; offset?: number } = {}) { return this.get(`/inventory_item`, { params: { limit, @@ -246,17 +245,19 @@ export default class Inventory extends Restful { * @param offset The value passed in this query parameter sets the page number to retrieve. */ public getOffers({ - sku, - marketplaceId, - format, - limit, - offset, - }: { + sku, + marketplaceId, + format, + limit, + offset, + acceptLanguage, + }: { sku?: string; marketplaceId?: string; format?: string; limit?: number; offset?: number; + acceptLanguage?: string; } = {}) { return this.get(`/offer`, { params: { @@ -266,6 +267,9 @@ export default class Inventory extends Restful { limit, offset, }, + headers: { + "Accept-Language": acceptLanguage ?? "en-US", + }, }); } From 66e99f4cc8cd2cce7fd6dc893f3a71b03b06543d Mon Sep 17 00:00:00 2001 From: Sehar Abbas Date: Tue, 4 Jan 2022 12:48:26 +0300 Subject: [PATCH 27/37] upgraded package as well --- .github/workflows/npm-publish.yml | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 72ca7ec..5223b09 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v2 with: - ref: deploy-ecomshft + ref: feat/AddHeaderToOfferRequest - uses: actions/setup-node@v1 with: node-version: 12 diff --git a/package.json b/package.json index b4af030..c22726e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ecomshft/ebay-api", "author": "Daniil Tomilow (original author)", - "version": "5.2.4", + "version": "5.2.5", "description": "Modified version of eBay TypeScript/JavaScript API for Node and Browser", "browser": "./lib/ebay-api.min.js", "main": "./lib/index.js", From 62b57c2222d8c158575d4cd8c470914a22e3220d Mon Sep 17 00:00:00 2001 From: seharconrad Date: Tue, 4 Jan 2022 13:17:55 +0300 Subject: [PATCH 28/37] Update npm-publish.yml updated name of branch in github actions --- .github/workflows/npm-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 5223b09..94e1715 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v2 with: - ref: feat/AddHeaderToOfferRequest + ref: feat/AddHeaderToGetOfferRequest - uses: actions/setup-node@v1 with: node-version: 12 From 994694f5150d6a0d274864ea4afa382b726e1240 Mon Sep 17 00:00:00 2001 From: Sehar Abbas Date: Tue, 4 Jan 2022 14:46:27 +0300 Subject: [PATCH 29/37] added additional header value --- src/api/restful/sell/inventory/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/api/restful/sell/inventory/index.ts b/src/api/restful/sell/inventory/index.ts index d9620d3..43adf05 100644 --- a/src/api/restful/sell/inventory/index.ts +++ b/src/api/restful/sell/inventory/index.ts @@ -266,6 +266,7 @@ export default class Inventory extends Restful { format, limit, offset, + "bleh":"bleh" }, headers: { "Accept-Language": acceptLanguage ?? "en-US", From 94caa73bc83144cb2dfdafe8222fd7a474dcc390 Mon Sep 17 00:00:00 2001 From: Sehar Abbas Date: Tue, 4 Jan 2022 14:47:16 +0300 Subject: [PATCH 30/37] updated package id --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c22726e..7ebdf79 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ecomshft/ebay-api", "author": "Daniil Tomilow (original author)", - "version": "5.2.5", + "version": "5.2.6", "description": "Modified version of eBay TypeScript/JavaScript API for Node and Browser", "browser": "./lib/ebay-api.min.js", "main": "./lib/index.js", From e658028ee9e4ff27e198b62d7af453d919d6c71a Mon Sep 17 00:00:00 2001 From: Sehar Abbas Date: Tue, 4 Jan 2022 15:09:24 +0300 Subject: [PATCH 31/37] testing again --- package.json | 2 +- src/api/restful/sell/inventory/index.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 7ebdf79..33891a0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ecomshft/ebay-api", "author": "Daniil Tomilow (original author)", - "version": "5.2.6", + "version": "5.2.7", "description": "Modified version of eBay TypeScript/JavaScript API for Node and Browser", "browser": "./lib/ebay-api.min.js", "main": "./lib/index.js", diff --git a/src/api/restful/sell/inventory/index.ts b/src/api/restful/sell/inventory/index.ts index 43adf05..4f7a9de 100644 --- a/src/api/restful/sell/inventory/index.ts +++ b/src/api/restful/sell/inventory/index.ts @@ -270,6 +270,7 @@ export default class Inventory extends Restful { }, headers: { "Accept-Language": acceptLanguage ?? "en-US", + "Accept-Things": acceptLanguage ?? "en-US", }, }); } From 056f81330b7bfb0df7718f3babe46b49468214a8 Mon Sep 17 00:00:00 2001 From: Sehar Abbas Date: Tue, 4 Jan 2022 15:36:33 +0300 Subject: [PATCH 32/37] updated header values --- package.json | 2 +- src/api/restful/sell/inventory/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 33891a0..bf08f35 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ecomshft/ebay-api", "author": "Daniil Tomilow (original author)", - "version": "5.2.7", + "version": "5.2.8", "description": "Modified version of eBay TypeScript/JavaScript API for Node and Browser", "browser": "./lib/ebay-api.min.js", "main": "./lib/index.js", diff --git a/src/api/restful/sell/inventory/index.ts b/src/api/restful/sell/inventory/index.ts index 4f7a9de..954b919 100644 --- a/src/api/restful/sell/inventory/index.ts +++ b/src/api/restful/sell/inventory/index.ts @@ -269,7 +269,7 @@ export default class Inventory extends Restful { "bleh":"bleh" }, headers: { - "Accept-Language": acceptLanguage ?? "en-US", + "accept-language": acceptLanguage?? "en-US", "Accept-Things": acceptLanguage ?? "en-US", }, }); From 495ef91159af71ecbec278c0e28f8573414342d9 Mon Sep 17 00:00:00 2001 From: Sehar Abbas Date: Tue, 4 Jan 2022 16:04:09 +0300 Subject: [PATCH 33/37] updated package --- package.json | 2 +- src/api/restful/sell/inventory/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index bf08f35..03a0c98 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ecomshft/ebay-api", "author": "Daniil Tomilow (original author)", - "version": "5.2.8", + "version": "5.2.9", "description": "Modified version of eBay TypeScript/JavaScript API for Node and Browser", "browser": "./lib/ebay-api.min.js", "main": "./lib/index.js", diff --git a/src/api/restful/sell/inventory/index.ts b/src/api/restful/sell/inventory/index.ts index 954b919..1d8ca27 100644 --- a/src/api/restful/sell/inventory/index.ts +++ b/src/api/restful/sell/inventory/index.ts @@ -269,7 +269,7 @@ export default class Inventory extends Restful { "bleh":"bleh" }, headers: { - "accept-language": acceptLanguage?? "en-US", + "Accept-Language": acceptLanguage?? "en-US", "Accept-Things": acceptLanguage ?? "en-US", }, }); From 3b8d8d8cdb5a012bd128b0c2955040772ce55dd7 Mon Sep 17 00:00:00 2001 From: Sehar Abbas Date: Tue, 4 Jan 2022 16:41:44 +0300 Subject: [PATCH 34/37] updated value of en-US --- package.json | 2 +- src/enums/restfulEnums.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 03a0c98..52acb9d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ecomshft/ebay-api", "author": "Daniil Tomilow (original author)", - "version": "5.2.9", + "version": "5.3.0", "description": "Modified version of eBay TypeScript/JavaScript API for Node and Browser", "browser": "./lib/ebay-api.min.js", "main": "./lib/index.js", diff --git a/src/enums/restfulEnums.ts b/src/enums/restfulEnums.ts index 47f1ea1..8452fee 100644 --- a/src/enums/restfulEnums.ts +++ b/src/enums/restfulEnums.ts @@ -551,7 +551,7 @@ export enum Condition { } export enum Locale { - en_US = 'en_US', + en_US = 'en-US', en_CA = 'en_CA', fr_CA = 'fr_CA', en_GB = 'en_GB', From 3fb1082b29f47e307a70b5d78d81141cd8acaa6e Mon Sep 17 00:00:00 2001 From: Sehar Abbas Date: Wed, 5 Jan 2022 15:54:57 +0300 Subject: [PATCH 35/37] removed junk code --- package.json | 2 +- src/api/restful/sell/inventory/index.ts | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/package.json b/package.json index 52acb9d..1af400c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@ecomshft/ebay-api", "author": "Daniil Tomilow (original author)", - "version": "5.3.0", + "version": "5.3.1", "description": "Modified version of eBay TypeScript/JavaScript API for Node and Browser", "browser": "./lib/ebay-api.min.js", "main": "./lib/index.js", diff --git a/src/api/restful/sell/inventory/index.ts b/src/api/restful/sell/inventory/index.ts index 1d8ca27..6e771d9 100644 --- a/src/api/restful/sell/inventory/index.ts +++ b/src/api/restful/sell/inventory/index.ts @@ -266,11 +266,6 @@ export default class Inventory extends Restful { format, limit, offset, - "bleh":"bleh" - }, - headers: { - "Accept-Language": acceptLanguage?? "en-US", - "Accept-Things": acceptLanguage ?? "en-US", }, }); } From 21b0a67a46b2a94329924cf33881e37d24244387 Mon Sep 17 00:00:00 2001 From: seharconrad Date: Wed, 5 Jan 2022 16:37:44 +0300 Subject: [PATCH 36/37] Update npm-publish.yml changed branch to default branch --- .github/workflows/npm-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 94e1715..686ea24 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v2 with: - ref: feat/AddHeaderToGetOfferRequest + ref: feat/deploy-ecomshft - uses: actions/setup-node@v1 with: node-version: 12 From ce40bf3e4af4f66b5142753dbc971f0ee764366f Mon Sep 17 00:00:00 2001 From: Sehar Abbas Date: Wed, 5 Jan 2022 16:54:47 +0300 Subject: [PATCH 37/37] Fixed PR Comments --- .github/workflows/npm-publish.yml | 2 +- src/api/restful/sell/inventory/index.ts | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 94e1715..72ca7ec 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v2 with: - ref: feat/AddHeaderToGetOfferRequest + ref: deploy-ecomshft - uses: actions/setup-node@v1 with: node-version: 12 diff --git a/src/api/restful/sell/inventory/index.ts b/src/api/restful/sell/inventory/index.ts index 6e771d9..d02993f 100644 --- a/src/api/restful/sell/inventory/index.ts +++ b/src/api/restful/sell/inventory/index.ts @@ -249,15 +249,13 @@ export default class Inventory extends Restful { marketplaceId, format, limit, - offset, - acceptLanguage, + offset }: { sku?: string; marketplaceId?: string; format?: string; limit?: number; offset?: number; - acceptLanguage?: string; } = {}) { return this.get(`/offer`, { params: {