@sp-api-sdk/common
Advanced tools
Comparing version 1.10.2 to 1.11.0
@@ -6,3 +6,3 @@ "use strict"; | ||
const aws4_axios_1 = require("aws4-axios"); | ||
const axios_1 = tslib_1.__importDefault(require("axios")); | ||
const axios_1 = tslib_1.__importStar(require("axios")); | ||
const axios_logger_1 = require("axios-logger"); | ||
@@ -45,5 +45,2 @@ const axios_retry_1 = tslib_1.__importDefault(require("axios-retry")); | ||
instance.interceptors.request.use(async (config) => { | ||
if (!config.headers) { | ||
config.headers = {}; | ||
} | ||
config.headers['x-amz-access-token'] = restrictedDataToken ?? (await auth.accessToken.get()); | ||
@@ -59,12 +56,16 @@ return config; | ||
return (0, aws4_axios_1.aws4Interceptor)({ | ||
region: regionConfiguration.awsRegion, | ||
service: 'execute-api', | ||
}, { | ||
accessKeyId: credentials.AccessKeyId ?? '', | ||
secretAccessKey: credentials.SecretAccessKey ?? '', | ||
sessionToken: credentials.SessionToken, | ||
instance, | ||
options: { | ||
region: regionConfiguration.awsRegion, | ||
service: 'execute-api', | ||
}, | ||
credentials: { | ||
accessKeyId: credentials.AccessKeyId ?? '', | ||
secretAccessKey: credentials.SecretAccessKey ?? '', | ||
sessionToken: credentials.SessionToken, | ||
}, | ||
})(config); | ||
}); | ||
instance.interceptors.response.use(async (response) => response, async (error) => { | ||
if (axios_1.default.isAxiosError(error) && !(error instanceof auth_1.SellingPartnerApiAuthError)) { | ||
if ((0, axios_1.isAxiosError)(error) && !(error instanceof auth_1.SellingPartnerApiAuthError)) { | ||
throw new errors_1.SellingPartnerApiError(error); | ||
@@ -79,13 +80,19 @@ } | ||
} | ||
instance.interceptors.request.use((config) => (0, axios_logger_1.requestLogger)(config, { | ||
prefixText: `sp-api-sdk/${region}`, | ||
dateFormat: 'isoDateTime', | ||
method: true, | ||
url: true, | ||
params: false, | ||
data: true, | ||
headers: false, | ||
logger: console.info, | ||
...requestLoggerOptions, | ||
})); | ||
instance.interceptors.request.use((config) => { | ||
const logger = (0, axios_logger_1.requestLogger)(config, { | ||
prefixText: `sp-api-sdk/${region}`, | ||
dateFormat: 'isoDateTime', | ||
method: true, | ||
url: true, | ||
params: false, | ||
data: true, | ||
headers: false, | ||
logger: console.info, | ||
...requestLoggerOptions, | ||
}); | ||
return { | ||
...logger, | ||
headers: config.headers, | ||
}; | ||
}); | ||
} | ||
@@ -92,0 +99,0 @@ if (logging?.response) { |
import { aws4Interceptor } from 'aws4-axios'; | ||
import axios from 'axios'; | ||
import axios, { isAxiosError } from 'axios'; | ||
import { errorLogger, requestLogger, responseLogger } from 'axios-logger'; | ||
@@ -40,5 +40,2 @@ import axiosRetry from 'axios-retry'; | ||
instance.interceptors.request.use(async (config) => { | ||
if (!config.headers) { | ||
config.headers = {}; | ||
} | ||
config.headers['x-amz-access-token'] = restrictedDataToken ?? (await auth.accessToken.get()); | ||
@@ -54,12 +51,16 @@ return config; | ||
return aws4Interceptor({ | ||
region: regionConfiguration.awsRegion, | ||
service: 'execute-api', | ||
}, { | ||
accessKeyId: credentials.AccessKeyId ?? '', | ||
secretAccessKey: credentials.SecretAccessKey ?? '', | ||
sessionToken: credentials.SessionToken, | ||
instance, | ||
options: { | ||
region: regionConfiguration.awsRegion, | ||
service: 'execute-api', | ||
}, | ||
credentials: { | ||
accessKeyId: credentials.AccessKeyId ?? '', | ||
secretAccessKey: credentials.SecretAccessKey ?? '', | ||
sessionToken: credentials.SessionToken, | ||
}, | ||
})(config); | ||
}); | ||
instance.interceptors.response.use(async (response) => response, async (error) => { | ||
if (axios.isAxiosError(error) && !(error instanceof SellingPartnerApiAuthError)) { | ||
if (isAxiosError(error) && !(error instanceof SellingPartnerApiAuthError)) { | ||
throw new SellingPartnerApiError(error); | ||
@@ -74,13 +75,19 @@ } | ||
} | ||
instance.interceptors.request.use((config) => requestLogger(config, { | ||
prefixText: `sp-api-sdk/${region}`, | ||
dateFormat: 'isoDateTime', | ||
method: true, | ||
url: true, | ||
params: false, | ||
data: true, | ||
headers: false, | ||
logger: console.info, | ||
...requestLoggerOptions, | ||
})); | ||
instance.interceptors.request.use((config) => { | ||
const logger = requestLogger(config, { | ||
prefixText: `sp-api-sdk/${region}`, | ||
dateFormat: 'isoDateTime', | ||
method: true, | ||
url: true, | ||
params: false, | ||
data: true, | ||
headers: false, | ||
logger: console.info, | ||
...requestLoggerOptions, | ||
}); | ||
return { | ||
...logger, | ||
headers: config.headers, | ||
}; | ||
}); | ||
} | ||
@@ -87,0 +94,0 @@ if (logging?.response) { |
@@ -5,3 +5,3 @@ { | ||
"description": "Selling Parner API common library", | ||
"version": "1.10.2", | ||
"version": "1.11.0", | ||
"main": "dist/cjs/index.js", | ||
@@ -31,5 +31,5 @@ "module": "dist/es/index.js", | ||
"dependencies": { | ||
"@sp-api-sdk/auth": "^1.10.12", | ||
"aws4-axios": "^2.4.9", | ||
"axios": "^0.27.2", | ||
"@sp-api-sdk/auth": "^1.11.0", | ||
"aws4-axios": "^3.1.1", | ||
"axios": "^1.4.0", | ||
"axios-logger": "^2.6.2", | ||
@@ -40,3 +40,3 @@ "axios-retry": "^3.4.0", | ||
"devDependencies": { | ||
"nock": "^13.3.0", | ||
"nock": "^13.3.1", | ||
"strip-ansi": "^6.0.1" | ||
@@ -65,3 +65,3 @@ }, | ||
}, | ||
"gitHead": "5436578b08afa670b1f49ffc258869b3b6297bd6" | ||
"gitHead": "107d3711376fa9561a8c02add732f7508c9c02ec" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19814
436
+ Addedaws4-axios@3.3.8(transitive)
- Removed@types/aws4@1.11.6(transitive)
- Removed@types/node@22.9.0(transitive)
- Removedaws4-axios@2.4.9(transitive)
- Removedaxios@0.27.2(transitive)
- Removedundici-types@6.19.8(transitive)
Updated@sp-api-sdk/auth@^1.11.0
Updatedaws4-axios@^3.1.1
Updatedaxios@^1.4.0