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.js11
1 files changed, 8 insertions, 3 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 cbe5dc9049..a54318065b 100644
--- a/deps/npm/node_modules/request/node_modules/aws4/aws4.js
+++ b/deps/npm/node_modules/request/node_modules/aws4/aws4.js
@@ -52,6 +52,8 @@ function RequestSigner(request, credentials) {
}
if (!request.hostname && !request.host)
request.hostname = headers.Host || headers.host
+
+ this.isCodeCommitGit = this.service === 'codecommit' && request.method === 'GIT'
}
RequestSigner.prototype.matchHost = function(host) {
@@ -109,7 +111,7 @@ RequestSigner.prototype.prepareRequest = function() {
} else {
- if (!request.doNotModifyHeaders) {
+ if (!request.doNotModifyHeaders && !this.isCodeCommitGit) {
if (request.body && !headers['Content-Type'] && !headers['content-type'])
headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=utf-8'
@@ -153,6 +155,9 @@ RequestSigner.prototype.getDateTime = function() {
date = new Date(headers.Date || headers.date || new Date)
this.datetime = date.toISOString().replace(/[:\-]|\.\d{3}/g, '')
+
+ // Remove the trailing 'Z' on the timestamp string for CodeCommit git access
+ if (this.isCodeCommitGit) this.datetime = this.datetime.slice(0, -1)
}
return this.datetime
}
@@ -202,8 +207,8 @@ RequestSigner.prototype.canonicalString = function() {
decodePath = this.service === 's3' || this.request.doNotEncodePath,
decodeSlashesInPath = this.service === 's3',
firstValOnly = this.service === 's3',
- bodyHash = this.service === 's3' && this.request.signQuery ?
- 'UNSIGNED-PAYLOAD' : hash(this.request.body || '', 'hex')
+ bodyHash = this.service === 's3' && this.request.signQuery ? 'UNSIGNED-PAYLOAD' :
+ (this.isCodeCommitGit ? '' : hash(this.request.body || '', 'hex'))
if (query) {
queryStr = encodeRfc3986(querystring.stringify(Object.keys(query).sort().reduce(function(obj, key) {