You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
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.2.0

3

aws2.js

@@ -112,3 +112,4 @@ var aws2 = exports,

accessKeyId: env.AWS_ACCESS_KEY_ID || env.AWS_ACCESS_KEY,
secretAccessKey: env.AWS_SECRET_ACCESS_KEY || env.AWS_SECRET_KEY
secretAccessKey: env.AWS_SECRET_ACCESS_KEY || env.AWS_SECRET_KEY,
sessionToken: env.AWS_SESSION_TOKEN
}

@@ -115,0 +116,0 @@ }

@@ -6,4 +6,7 @@ var http = require('http'),

// given an options object you could pass to http.request
var opts = { host: 'sns.us-east-1.amazonaws.com', path: '/?Action=ListTopics' }
var opts = { host: 'sdb.amazonaws.com', path: '/?Action=ListDomains&Version=2009-04-15' }
// alternatively (as aws2 can infer the host):
opts = { service: 'sdb', path: '/?Action=ListDomains&Version=2009-04-15' }
aws2.sign(opts) // assumes AWS credentials are available in process.env

@@ -14,5 +17,5 @@

{
host: 'sns.us-east-1.amazonaws.com',
path: '/?Action=ListTopics&Timestamp=2013-01-12T01%3A25%3A55.553Z&SignatureVersion=2&SignatureMethod=...'
headers: { Host: 'sns.us-east-1.amazonaws.com' }
host: 'importexport.amazonaws.com',
path: '/?Action=ListJobs&Timestamp=2013-01-12T01%3A25%3A55.553Z&SignatureVersion=2&SignatureMethod=...'
headers: { Host: 'importexport.amazonaws.com' }
}

@@ -24,13 +27,9 @@ */

/*
<?xml version="1.0"?>
<ListTopicsResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
<ListDomainsResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/">
...
*/
// you can pass AWS credentials in explicitly
// you can pass AWS credentials in explicitly (otherwise taken from process.env)
aws2.sign(opts, { accessKeyId: '', secretAccessKey: '' })
// aws2 can infer the host from a service and region
opts = aws2.sign({ service: 'sns', region: 'us-east-1', path: '/?Action=ListTopics' })
// create a utility function to pipe to stdout (with https this time)

@@ -41,6 +40,5 @@ function request(o) { https.request(o, function(res) { res.pipe(process.stdout) }).end(o.body || '') }

// method will be POST and Content-Type: 'application/x-www-form-urlencoded; charset=utf-8'
request(aws2.sign({ service: 'ec2', body: 'Action=DescribeRegions&Version=2012-12-01' }))
request(aws2.sign({ service: 'importexport', body: 'Action=ListJobs&Version=2010-06-01' }))
/*
<?xml version="1.0" encoding="UTF-8"?>
<DescribeRegionsResponse xmlns="http://ec2.amazonaws.com/doc/2012-12-01/">
<ListJobsResponse xmlns="http://importexport.amazonaws.com/doc/2010-06-01/">
...

@@ -51,4 +49,3 @@ */

request(aws2.sign({
service: 'elasticmapreduce',
region: 'ap-southeast-2',
service: 'importexport',
method: 'POST',

@@ -59,29 +56,7 @@ path: '/',

},
body: 'Action=DescribeJobFlows&Version=2009-03-31'
body: 'Action=ListJobs&Version=2010-06-01'
}))
/*
<DescribeJobFlowsResponse xmlns="http://elasticmapreduce.amazonaws.com/doc/2009-03-31">
...
*/
// works with all other services that support Signature Version 2
request(aws2.sign({ service: 'elasticache', path: '/?Action=DescribeCacheClusters&Version=2012-11-15' }))
/*
<DescribeCacheClustersResponse xmlns="http://elasticache.amazonaws.com/doc/2012-11-15/">
...
*/
request(aws2.sign({ service: 'importexport', path: '/?Action=ListJobs&Version=2010-06-01' }))
/*
<ListJobsResponse xmlns="http://importexport.amazonaws.com/doc/2010-06-01/">
...
*/
request(aws2.sign({ service: 'sdb', path: '/?Action=ListDomains&Version=2009-04-15' }))
/*
<?xml version="1.0"?>
<ListDomainsResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/">
...
*/
{
"name": "aws2",
"version": "0.1.5",
"version": "0.2.0",
"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)",

@@ -9,6 +9,3 @@ aws2

This signature is supported by a number of (older) Amazon services, including
[EC2](http://docs.aws.amazon.com/AWSEC2/latest/APIReference/),
[ElastiCache](http://docs.aws.amazon.com/AmazonElastiCache/latest/APIReference/),
[Elastic MapReduce](http://docs.aws.amazon.com/ElasticMapReduce/latest/API/),
This signature is supported by a number of (older) Amazon services, namely
[ImportExport](http://docs.aws.amazon.com/AWSImportExport/latest/API/) and

@@ -29,9 +26,12 @@ [SimpleDB](http://docs.aws.amazon.com/AmazonSimpleDB/latest/DeveloperGuide/SDB_API.html).

```javascript
var http = require('http')
, https = require('https')
, aws2 = require('aws2')
var http = require('http'),
https = require('https'),
aws2 = require('aws2')
// given an options object you could pass to http.request
var opts = { host: 'sns.us-east-1.amazonaws.com', path: '/?Action=ListTopics' }
var opts = { host: 'sdb.amazonaws.com', path: '/?Action=ListDomains&Version=2009-04-15' }
// alternatively (as aws2 can infer the host):
opts = { service: 'sdb', path: '/?Action=ListDomains&Version=2009-04-15' }
aws2.sign(opts) // assumes AWS credentials are available in process.env

@@ -42,5 +42,5 @@

{
host: 'sns.us-east-1.amazonaws.com',
path: '/?Action=ListTopics&Timestamp=2013-01-12T01%3A25%3A55.553Z&SignatureVersion=2&SignatureMethod=...'
headers: { Host: 'sns.us-east-1.amazonaws.com' }
host: 'importexport.amazonaws.com',
path: '/?Action=ListJobs&Timestamp=2013-01-12T01%3A25%3A55.553Z&SignatureVersion=2&SignatureMethod=...'
headers: { Host: 'importexport.amazonaws.com' }
}

@@ -52,4 +52,3 @@ */

/*
<?xml version="1.0"?>
<ListTopicsResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
<ListDomainsResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/">
...

@@ -63,8 +62,5 @@ */

```javascript
// you can pass AWS credentials in explicitly
// you can pass AWS credentials in explicitly (otherwise taken from process.env)
aws2.sign(opts, { accessKeyId: '', secretAccessKey: '' })
// aws2 can infer the host from a service and region
opts = aws2.sign({ service: 'sns', region: 'us-east-1', path: '/?Action=ListTopics' })
// create a utility function to pipe to stdout (with https this time)

@@ -75,6 +71,5 @@ function request(o) { https.request(o, function(res) { res.pipe(process.stdout) }).end(o.body || '') }

// method will be POST and Content-Type: 'application/x-www-form-urlencoded; charset=utf-8'
request(aws2.sign({ service: 'ec2', body: 'Action=DescribeRegions&Version=2012-12-01' }))
request(aws2.sign({ service: 'importexport', body: 'Action=ListJobs&Version=2010-06-01' }))
/*
<?xml version="1.0" encoding="UTF-8"?>
<DescribeRegionsResponse xmlns="http://ec2.amazonaws.com/doc/2012-12-01/">
<ListJobsResponse xmlns="http://importexport.amazonaws.com/doc/2010-06-01/">
...

@@ -85,4 +80,3 @@ */

request(aws2.sign({
service: 'elasticmapreduce',
region: 'ap-southeast-2',
service: 'importexport',
method: 'POST',

@@ -93,29 +87,8 @@ path: '/',

},
body: 'Action=DescribeJobFlows&Version=2009-03-31'
body: 'Action=ListJobs&Version=2010-06-01'
}))
/*
<DescribeJobFlowsResponse xmlns="http://elasticmapreduce.amazonaws.com/doc/2009-03-31">
...
*/
// works with all other services that support Signature Version 2
request(aws2.sign({ service: 'elasticache', path: '/?Action=DescribeCacheClusters&Version=2012-11-15' }))
/*
<DescribeCacheClustersResponse xmlns="http://elasticache.amazonaws.com/doc/2012-11-15/">
...
*/
request(aws2.sign({ service: 'importexport', path: '/?Action=ListJobs&Version=2010-06-01' }))
/*
<ListJobsResponse xmlns="http://importexport.amazonaws.com/doc/2010-06-01/">
...
*/
request(aws2.sign({ service: 'sdb', path: '/?Action=ListDomains&Version=2009-04-15' }))
/*
<?xml version="1.0"?>
<ListDomainsResponse xmlns="http://sdb.amazonaws.com/doc/2009-04-15/">
...
*/
```

@@ -169,2 +142,3 @@

export AWS_ACCESS_KEY_ID="<your-access-key-id>"
export AWS_SESSION_TOKEN="<your-session-token>"
```

@@ -174,2 +148,5 @@

The `sessionToken` property and `AWS_SESSION_TOKEN` environment variable are optional for signing
with [IAM STS temporary credentials](http://docs.aws.amazon.com/STS/latest/UsingSTS/using-temp-creds.html).
Installation

@@ -176,0 +153,0 @@ ------------