summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/request/node_modules/aws4/aws4.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/request/node_modules/aws4/aws4.js')
-rw-r--r--deps/npm/node_modules/request/node_modules/aws4/aws4.js21
1 files changed, 15 insertions, 6 deletions
diff --git a/deps/npm/node_modules/request/node_modules/aws4/aws4.js b/deps/npm/node_modules/request/node_modules/aws4/aws4.js
index a54318065b..0cff0f0ea3 100644
--- a/deps/npm/node_modules/request/node_modules/aws4/aws4.js
+++ b/deps/npm/node_modules/request/node_modules/aws4/aws4.js
@@ -118,14 +118,14 @@ RequestSigner.prototype.prepareRequest = function() {
if (request.body && !headers['Content-Length'] && !headers['content-length'])
headers['Content-Length'] = Buffer.byteLength(request.body)
- if (this.credentials.sessionToken)
+ if (this.credentials.sessionToken && !headers['X-Amz-Security-Token'] && !headers['x-amz-security-token'])
headers['X-Amz-Security-Token'] = this.credentials.sessionToken
- if (this.service === 's3')
+ if (this.service === 's3' && !headers['X-Amz-Content-Sha256'] && !headers['x-amz-content-sha256'])
headers['X-Amz-Content-Sha256'] = hash(this.request.body || '', 'hex')
- if (headers['X-Amz-Date'])
- this.datetime = headers['X-Amz-Date']
+ if (headers['X-Amz-Date'] || headers['x-amz-date'])
+ this.datetime = headers['X-Amz-Date'] || headers['x-amz-date']
else
headers['X-Amz-Date'] = this.getDateTime()
}
@@ -202,13 +202,22 @@ RequestSigner.prototype.canonicalString = function() {
var pathStr = this.parsedPath.path,
query = this.parsedPath.query,
+ headers = this.request.headers,
queryStr = '',
normalizePath = this.service !== 's3',
decodePath = this.service === 's3' || this.request.doNotEncodePath,
decodeSlashesInPath = this.service === 's3',
firstValOnly = this.service === 's3',
- bodyHash = this.service === 's3' && this.request.signQuery ? 'UNSIGNED-PAYLOAD' :
- (this.isCodeCommitGit ? '' : hash(this.request.body || '', 'hex'))
+ bodyHash
+
+ if (this.service === 's3' && this.request.signQuery) {
+ bodyHash = 'UNSIGNED-PAYLOAD'
+ } else if (this.isCodeCommitGit) {
+ bodyHash = ''
+ } else {
+ bodyHash = headers['X-Amz-Content-Sha256'] || headers['x-amz-content-sha256'] ||
+ hash(this.request.body || '', 'hex')
+ }
if (query) {
queryStr = encodeRfc3986(querystring.stringify(Object.keys(query).sort().reduce(function(obj, key) {