Comparing version
12
aws2.js
@@ -8,6 +8,2 @@ var aws2 = exports | ||
function hmac(key, string, encoding) { | ||
return crypto.createHmac('sha256', key).update(string, 'utf8').digest(encoding) | ||
} | ||
// request: { path | body, [host], [method], [headers], [service], [region] } | ||
@@ -34,4 +30,10 @@ // credentials: { accessKeyId, secretAccessKey, [sessionToken] } | ||
// 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', 'importexport'].indexOf(this.service) ? '' : '.' + this.region | ||
var region = this.isSingleRegion() ? '' : '.' + this.region | ||
return this.service + region + '.amazonaws.com' | ||
@@ -38,0 +40,0 @@ } |
{ | ||
"name": "aws2", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Signs and prepares requests using AWS Signature Version 2", | ||
@@ -5,0 +5,0 @@ "author": "Michael Hart <michael.hart.au@gmail.com> (http://github.com/mhart)", |
@@ -50,6 +50,11 @@ var should = require('should') | ||
it('should add hostname and default region', function() { | ||
var opts = aws2.sign({ service: 'sqs', path: path, headers: { Date: date } }) | ||
var opts = aws2.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 = aws2.sign({ service: 'iam' }) | ||
opts.hostname.should.equal('iam.amazonaws.com') | ||
opts.headers['Host'].should.equal('iam.amazonaws.com') | ||
}) | ||
}) | ||
@@ -56,0 +61,0 @@ |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
16919
1.71%259
2.78%