Comparing version 0.1.4 to 0.1.5
10
aws4.js
@@ -36,4 +36,10 @@ var aws4 = exports | ||
// http://docs.aws.amazon.com/general/latest/gr/rande.html | ||
RequestSigner.prototype.isSingleRegion = function() { | ||
return ['cloudfront', 'ls', 'route53', 'iam', 'importexport', 'sts'] | ||
.indexOf(this.service) >= 0 | ||
} | ||
RequestSigner.prototype.createHost = function() { | ||
var region = ~['iam', 'sts'].indexOf(this.service) ? '' : '.' + this.region | ||
var region = this.isSingleRegion() ? '' : '.' + this.region | ||
return this.service + region + '.amazonaws.com' | ||
@@ -59,3 +65,3 @@ } | ||
if (request.body && !headers['Content-Type'] && !headers['content-type']) | ||
headers['Content-Type'] = 'application/x-www-form-urlencoded' | ||
headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=utf-8' | ||
@@ -62,0 +68,0 @@ headers['X-Amz-Date'] = this.datetime |
{ | ||
"name": "aws4", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Signs and prepares requests using AWS Signature Version 4", | ||
@@ -5,0 +5,0 @@ "author": "Michael Hart <michael.hart.au@gmail.com> (http://github.com/mhart)", |
@@ -55,6 +55,11 @@ var should = require('should') | ||
it('should add hostname and default region', function() { | ||
var opts = aws4.sign({ service: 'sqs', headers: { Date: date } }) | ||
var opts = aws4.sign({ service: 'sqs' }) | ||
opts.hostname.should.equal('sqs.us-east-1.amazonaws.com') | ||
opts.headers['Host'].should.equal('sqs.us-east-1.amazonaws.com') | ||
}) | ||
it('should add hostname and no region if service is regionless', function() { | ||
var opts = aws4.sign({ service: 'iam' }) | ||
opts.hostname.should.equal('iam.amazonaws.com') | ||
opts.headers['Host'].should.equal('iam.amazonaws.com') | ||
}) | ||
it('should populate AWS headers correctly', function() { | ||
@@ -98,3 +103,3 @@ var opts = aws4.sign({ service: 'sqs', headers: { Date: date } }) | ||
var opts = aws4.sign({ body: 'SomeAction' }) | ||
opts.headers['Content-Type'].should.equal('application/x-www-form-urlencoded') | ||
opts.headers['Content-Type'].should.equal('application/x-www-form-urlencoded; charset=utf-8') | ||
}) | ||
@@ -101,0 +106,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18651
308