aws4-axios
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -52,2 +52,27 @@ "use strict"; | ||
}); | ||
it("should not mutate request config object", function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var client, url, config, request; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
client = axios_1.default.create(); | ||
client.interceptors.request.use(_1.default({ region: "local" })); | ||
url = "https://localhost/foo"; | ||
config = { | ||
headers: { "X-Custom-Header": "foo", "Content-Type": "application/json" }, | ||
params: { foo: "bar" } | ||
}; | ||
moxios_1.default.stubOnce("GET", /./, {}); | ||
// Act | ||
return [4 /*yield*/, client.get(url, config)]; | ||
case 1: | ||
// Act | ||
_a.sent(); | ||
request = moxios_1.default.requests.first(); | ||
expect(request.url).toBe(url + "?foo=bar"); | ||
expect(config.params).toStrictEqual({ foo: "bar" }); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
it("should preserve headers", function () { return __awaiter(void 0, void 0, void 0, function () { | ||
@@ -54,0 +79,0 @@ var client, data, url, request; |
@@ -30,2 +30,3 @@ "use strict"; | ||
var aws4_1 = require("aws4"); | ||
var buildUrl_1 = __importDefault(require("axios/lib/helpers/buildUrl")); | ||
var combineURLs_1 = __importDefault(require("axios/lib/helpers/combineURLs")); | ||
@@ -48,2 +49,6 @@ var isAbsoluteURL_1 = __importDefault(require("axios/lib/helpers/isAbsoluteURL")); | ||
} | ||
if (config.params) { | ||
config.url = buildUrl_1.default(config.url, config.params, config.paramsSerializer); | ||
delete config.params; | ||
} | ||
var url = config.url; | ||
@@ -50,0 +55,0 @@ if (config.baseURL && !isAbsoluteURL_1.default(config.url)) { |
@@ -59,3 +59,3 @@ "use strict"; | ||
}); | ||
it("signs query paremeters in GET requests", function () { | ||
it("signs url query paremeters in GET requests", function () { | ||
// Arrange | ||
@@ -84,2 +84,27 @@ var request = { | ||
}); | ||
it("signs query paremeters in GET requests", function () { | ||
// Arrange | ||
var request = { | ||
method: "GET", | ||
url: "https://example.com/foobar", | ||
params: { foo: "bar" }, | ||
headers: getDefaultHeaders(), | ||
transformRequest: getDefaultTransformRequest() | ||
}; | ||
var interceptor = _1.aws4Interceptor({ | ||
region: "local", | ||
service: "execute-api" | ||
}); | ||
// Act | ||
interceptor(request); | ||
// Assert | ||
expect(aws4_1.sign).toBeCalledWith({ | ||
service: "execute-api", | ||
path: "/foobar?foo=bar", | ||
method: "GET", | ||
region: "local", | ||
host: "example.com", | ||
headers: {} | ||
}, undefined); | ||
}); | ||
it("signs POST requests with an object payload", function () { | ||
@@ -86,0 +111,0 @@ // Arrange |
{ | ||
"name": "aws4-axios", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "Axios request interceptor for signing requests with AWSv4", | ||
@@ -26,3 +26,3 @@ "author": "James Bourne", | ||
"set-value": "3.0.1", | ||
"axios": "0.21.0" | ||
"axios": "0.21.1" | ||
}, | ||
@@ -34,3 +34,2 @@ "main": "dist/index.js", | ||
"test": "jest", | ||
"test-ci": "jest --config jest.config.ci.js", | ||
"test-it": "jest --config jest.config.it.js" | ||
@@ -37,0 +36,0 @@ }, |
@@ -5,3 +5,2 @@ # aws4-axios | ||
[![npm downloads](https://img.shields.io/npm/dm/aws4-axios.svg?style=flat-square)](http://npm-stat.com/charts.html?package=aws4-axios) | ||
[![circleci build](https://img.shields.io/circleci/build/github/jamesmbourne/aws4-axios.svg?style=flat-square)](https://circleci.com/gh/jamesmbourne/aws4-axios) | ||
@@ -70,2 +69,2 @@ This is a request interceptor for the Axios HTTP request library to allow requests to be signed with an AWSv4 signature. | ||
}); | ||
``` | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
37919
793
21