aws4
Advanced tools
Comparing version 1.11.0 to 1.12.0
12
aws4.js
@@ -75,2 +75,5 @@ var aws4 = exports, | ||
this.isCodeCommitGit = this.service === 'codecommit' && request.method === 'GIT' | ||
this.extraHeadersToIgnore = request.extraHeadersToIgnore || Object.create(null) | ||
this.extraHeadersToInclude = request.extraHeadersToInclude || Object.create(null) | ||
} | ||
@@ -85,3 +88,3 @@ | ||
// e.g. search-cluster-name-aaaa00aaaa0aaa0aaaaaaa0aaa.us-east-1.es.amazonaws.com | ||
if (hostParts[1] === 'es') | ||
if (hostParts[1] === 'es' || hostParts[1] === 'aoss') | ||
hostParts = hostParts.reverse() | ||
@@ -310,5 +313,10 @@ | ||
RequestSigner.prototype.signedHeaders = function() { | ||
var extraHeadersToInclude = this.extraHeadersToInclude, | ||
extraHeadersToIgnore = this.extraHeadersToIgnore | ||
return Object.keys(this.request.headers) | ||
.map(function(key) { return key.toLowerCase() }) | ||
.filter(function(key) { return HEADERS_TO_IGNORE[key] == null }) | ||
.filter(function(key) { | ||
return extraHeadersToInclude[key] || | ||
(HEADERS_TO_IGNORE[key] == null && !extraHeadersToIgnore[key]) | ||
}) | ||
.sort() | ||
@@ -315,0 +323,0 @@ .join(';') |
{ | ||
"name": "aws4", | ||
"version": "1.11.0", | ||
"version": "1.12.0", | ||
"description": "Signs and prepares requests using AWS Signature Version 4", | ||
@@ -5,0 +5,0 @@ "author": "Michael Hart <michael.hart.au@gmail.com> (https://github.com/mhart)", |
@@ -9,3 +9,3 @@ aws4 | ||
If you want to sign and send AWS requests in a modern browser, or an environment like [Cloudflare Workers](https://developers.cloudflare.com/workers/), then check out [aws4fetch](https://github.com/mhart/aws4fetch) β otherwise you can also bundle this library for use [in older browsers](./browser). | ||
If you want to sign and send AWS requests in a browser, or an environment like [Cloudflare Workers](https://developers.cloudflare.com/workers/), then check out [aws4fetch](https://github.com/mhart/aws4fetch) β otherwise you can also bundle this library for use [in older browsers](./browser). | ||
@@ -98,2 +98,30 @@ The only AWS service that *doesn't* support v4 as of 2020-05-22 is | ||
// you can also specify extra headers to ignore during signing | ||
request(aws4.sign({ | ||
host: '07tjusf2h91cunochc.us-east-1.aoss.amazonaws.com', | ||
method: 'PUT', | ||
path: '/my-index', | ||
body: '{"mappings":{}}', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'X-Amz-Content-Sha256': 'UNSIGNED-PAYLOAD' | ||
}, | ||
extraHeadersToIgnore: { | ||
'content-length': true | ||
} | ||
})) | ||
// and headers to include that would normally be ignored | ||
request(aws4.sign({ | ||
service: 'mycustomservice', | ||
path: '/whatever', | ||
headers: { | ||
'Range': 'bytes=200-1000, 2000-6576, 19000-' | ||
}, | ||
extraHeadersToInclude: { | ||
'range': true | ||
} | ||
})) | ||
// The raw RequestSigner can be used to generate CodeCommit Git passwords | ||
@@ -133,2 +161,4 @@ var signer = new aws4.RequestSigner({ | ||
- `signQuery` (to sign the query instead of adding an `Authorization` header, defaults to false) | ||
- `extraHeadersToIgnore` (an object with lowercase header keys to ignore when signing, eg `{ 'content-length': true }`) | ||
- `extraHeadersToInclude` (an object with lowercase header keys to include when signing, overriding any ignores) | ||
- `headers['Host']` (will use `hostname` or `host` or be calculated if not given) | ||
@@ -135,0 +165,0 @@ - `headers['Content-Type']` (will use `'application/x-www-form-urlencoded; charset=utf-8'` |
23516
393
214