Updating NPM dependencies
This commit is contained in:
40
node_modules/aws4/aws4.js
generated
vendored
40
node_modules/aws4/aws4.js
generated
vendored
@@ -26,6 +26,20 @@ function encodeRfc3986Full(str) {
|
||||
return encodeRfc3986(encodeURIComponent(str))
|
||||
}
|
||||
|
||||
// A bit of a combination of:
|
||||
// https://github.com/aws/aws-sdk-java-v2/blob/dc695de6ab49ad03934e1b02e7263abbd2354be0/core/auth/src/main/java/software/amazon/awssdk/auth/signer/internal/AbstractAws4Signer.java#L59
|
||||
// https://github.com/aws/aws-sdk-js/blob/18cb7e5b463b46239f9fdd4a65e2ff8c81831e8f/lib/signers/v4.js#L191-L199
|
||||
// https://github.com/mhart/aws4fetch/blob/b3aed16b6f17384cf36ea33bcba3c1e9f3bdfefd/src/main.js#L25-L34
|
||||
var HEADERS_TO_IGNORE = {
|
||||
'authorization': true,
|
||||
'connection': true,
|
||||
'x-amzn-trace-id': true,
|
||||
'user-agent': true,
|
||||
'expect': true,
|
||||
'presigned-expires': true,
|
||||
'range': true,
|
||||
}
|
||||
|
||||
// request: { path | body, [host], [method], [headers], [service], [region] }
|
||||
// credentials: { accessKeyId, secretAccessKey, [sessionToken] }
|
||||
function RequestSigner(request, credentials) {
|
||||
@@ -33,7 +47,7 @@ function RequestSigner(request, credentials) {
|
||||
if (typeof request === 'string') request = url.parse(request)
|
||||
|
||||
var headers = request.headers = (request.headers || {}),
|
||||
hostParts = this.matchHost(request.hostname || request.host || headers.Host || headers.host)
|
||||
hostParts = (!this.service || !this.region) && this.matchHost(request.hostname || request.host || headers.Host || headers.host)
|
||||
|
||||
this.request = request
|
||||
this.credentials = credentials || this.defaultCredentials()
|
||||
@@ -70,6 +84,19 @@ RequestSigner.prototype.matchHost = function(host) {
|
||||
if (hostParts[1] === 'es')
|
||||
hostParts = hostParts.reverse()
|
||||
|
||||
if (hostParts[1] == 's3') {
|
||||
hostParts[0] = 's3'
|
||||
hostParts[1] = 'us-east-1'
|
||||
} else {
|
||||
for (var i = 0; i < 2; i++) {
|
||||
if (/^s3-/.test(hostParts[i])) {
|
||||
hostParts[1] = hostParts[i].slice(3)
|
||||
hostParts[0] = 's3'
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hostParts
|
||||
}
|
||||
|
||||
@@ -83,10 +110,9 @@ RequestSigner.prototype.isSingleRegion = function() {
|
||||
}
|
||||
|
||||
RequestSigner.prototype.createHost = function() {
|
||||
var region = this.isSingleRegion() ? '' :
|
||||
(this.service === 's3' && this.region !== 'us-east-1' ? '-' : '.') + this.region,
|
||||
service = this.service === 'ses' ? 'email' : this.service
|
||||
return service + region + '.amazonaws.com'
|
||||
var region = this.isSingleRegion() ? '' : '.' + this.region,
|
||||
subdomain = this.service === 'ses' ? 'email' : this.service
|
||||
return subdomain + region + '.amazonaws.com'
|
||||
}
|
||||
|
||||
RequestSigner.prototype.prepareRequest = function() {
|
||||
@@ -247,7 +273,7 @@ RequestSigner.prototype.canonicalString = function() {
|
||||
if (normalizePath && piece === '..') {
|
||||
path.pop()
|
||||
} else if (!normalizePath || piece !== '.') {
|
||||
if (decodePath) piece = decodeURIComponent(piece).replace(/\+/g, ' ')
|
||||
if (decodePath) piece = decodeURIComponent(piece.replace(/\+/g, ' '))
|
||||
path.push(encodeRfc3986Full(piece))
|
||||
}
|
||||
return path
|
||||
@@ -272,6 +298,7 @@ RequestSigner.prototype.canonicalHeaders = function() {
|
||||
return header.toString().trim().replace(/\s+/g, ' ')
|
||||
}
|
||||
return Object.keys(headers)
|
||||
.filter(function(key) { return HEADERS_TO_IGNORE[key.toLowerCase()] == null })
|
||||
.sort(function(a, b) { return a.toLowerCase() < b.toLowerCase() ? -1 : 1 })
|
||||
.map(function(key) { return key.toLowerCase() + ':' + trimAll(headers[key]) })
|
||||
.join('\n')
|
||||
@@ -280,6 +307,7 @@ RequestSigner.prototype.canonicalHeaders = function() {
|
||||
RequestSigner.prototype.signedHeaders = function() {
|
||||
return Object.keys(this.request.headers)
|
||||
.map(function(key) { return key.toLowerCase() })
|
||||
.filter(function(key) { return HEADERS_TO_IGNORE[key] == null })
|
||||
.sort()
|
||||
.join(';')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user