🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

aws2

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws2 - npm Package Compare versions

Comparing version

to
0.0.2

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 @@