Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aws4-axios

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws4-axios - npm Package Compare versions

Comparing version 1.7.0 to 1.8.0

dist/axiosInterceptor.test.d.ts

35

dist/__tests__/apiGateway.it.js

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

method: "POST",
headers: { "Content-Type": "Baz" },
headers: { "X-Custom-Header": "Baz" },
data: data

@@ -140,2 +140,35 @@ })];

}); });
it("handles custom Content-Type header", function () { return __awaiter(_this, void 0, void 0, function () {
var client, data, message, result, err_4;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
client = axios_1.default.create();
data = {
foo: "bar"
};
client.interceptors.request.use(__1.interceptor({ region: "eu-west-2", service: "execute-api" }));
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, client.request({
url: apiGateway,
method: "POST",
headers: { "Content-Type": "application/xml" },
data: data
})];
case 2:
result = _a.sent();
return [3 /*break*/, 4];
case 3:
err_4 = _a.sent();
message = __2.getAuthErrorMessage(err_4);
return [3 /*break*/, 4];
case 4:
expect(message).toBe(undefined);
expect(result && result.status).toEqual(200);
return [2 /*return*/];
}
});
}); });
});

@@ -13,2 +13,13 @@ "use strict";

};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -40,6 +51,9 @@ var aws4_1 = require("aws4");

}
// Remove all the default Axios headers
var common = headers.common, _delete = headers.delete, // 'delete' is a reserved word
get = headers.get, head = headers.head, post = headers.post, put = headers.put, patch = headers.patch, headersToSign = __rest(headers, ["common", "delete", "get", "head", "post", "put", "patch"]);
var signingOptions = __assign({ method: method && method.toUpperCase(), host: host, path: pathname + search, region: region,
service: service }, (signQuery !== undefined ? { signQuery: signQuery } : {}), { body: getBody(data) });
service: service }, (signQuery !== undefined ? { signQuery: signQuery } : {}), { body: getBody(data), headers: headersToSign });
aws4_1.sign(signingOptions);
config.headers = signingOptions.headers;
config.headers = __assign({}, signingOptions.headers, config.headers);
return config;

@@ -46,0 +60,0 @@ }; };

"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -7,2 +18,11 @@ var aws4_1 = require("aws4");

describe("interceptor", function () {
var getDefaultHeaders = function () { return ({
common: { Accept: "application/json, text/plain, */*" },
delete: {},
get: {},
head: {},
post: { "Content-Type": "application/x-www-form-urlencoded" },
put: { "Content-Type": "application/x-www-form-urlencoded" },
patch: { "Content-Type": "application/x-www-form-urlencoded" }
}); };
beforeEach(function () {

@@ -15,3 +35,4 @@ aws4_1.sign.mockReset();

method: "GET",
url: "https://example.com/foobar"
url: "https://example.com/foobar",
headers: getDefaultHeaders()
};

@@ -30,3 +51,4 @@ var interceptor = _1.aws4Interceptor({

region: "local",
host: "example.com"
host: "example.com",
headers: {}
});

@@ -38,3 +60,4 @@ });

method: "GET",
url: "https://example.com/foobar?foo=bar"
url: "https://example.com/foobar?foo=bar",
headers: getDefaultHeaders()
};

@@ -53,3 +76,4 @@ var interceptor = _1.aws4Interceptor({

region: "local",
host: "example.com"
host: "example.com",
headers: {}
});

@@ -63,3 +87,4 @@ });

url: "https://example.com/foobar",
data: data
data: data,
headers: getDefaultHeaders()
};

@@ -79,3 +104,4 @@ var interceptor = _1.aws4Interceptor({

host: "example.com",
body: '{"foo":"bar"}'
body: '{"foo":"bar"}',
headers: {}
});

@@ -89,3 +115,4 @@ });

url: "https://example.com/foobar",
data: data
data: data,
headers: getDefaultHeaders()
};

@@ -105,5 +132,32 @@ var interceptor = _1.aws4Interceptor({

host: "example.com",
body: "foobar"
body: "foobar",
headers: {}
});
});
it("passes Content-Type header to be signed", function () {
// Arrange
var data = "foobar";
var request = {
method: "POST",
url: "https://example.com/foobar",
data: data,
headers: __assign({}, getDefaultHeaders(), { "Content-Type": "application/xml" })
};
var interceptor = _1.aws4Interceptor({
region: "local",
service: "execute-api"
});
// Act
interceptor(request);
// Assert
expect(aws4_1.sign).toBeCalledWith({
service: "execute-api",
method: "POST",
path: "/foobar",
region: "local",
host: "example.com",
body: "foobar",
headers: { "Content-Type": "application/xml" }
});
});
});

4

package.json
{
"name": "aws4-axios",
"version": "1.7.0",
"version": "1.8.0",
"description": "Axios request interceptor for signing requests with AWSv4",

@@ -32,2 +32,3 @@ "author": "James Bourne",

"@types/jest": "^24.0.13",
"@types/moxios": "^0.4.8",
"@types/node": "^12.0.4",

@@ -37,2 +38,3 @@ "eslint": "^5.16.0",

"jest-junit": "^6.4.0",
"moxios": "^0.4.0",
"ts-jest": "^24.0.2",

@@ -39,0 +41,0 @@ "typescript": "^3.5.1"

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc