Comparing version 0.0.1 to 0.1.0
var http = require('http') | ||
, https = require('https') | ||
, aws4 = require('aws4') | ||
, opts = { host: 'sqs.us-east-1.amazonaws.com', path: '/?Action=ListQueues' } | ||
// assuming AWS credentials are available from process.env | ||
aws4.sign(opts) | ||
// given an options object you could pass to http.request | ||
var opts = { host: 'sqs.us-east-1.amazonaws.com', path: '/?Action=ListQueues' } | ||
// opts.headers now contains the signed AWS headers, and can be used | ||
// in standard node.js http(s) requests | ||
aws4.sign(opts) // assumes AWS credentials are available in process.env | ||
// pipe the SOAP response from SQS to stdout | ||
// opts.headers now contains the signed AWS headers, and is ready for | ||
// use in standard node.js http(s) requests | ||
// eg, pipe the SOAP response from the above SQS request to stdout | ||
http.request(opts, function(res) { res.pipe(process.stdout) }).end() | ||
@@ -24,3 +25,3 @@ | ||
// opts.method will be POST and Content-Type 'application/x-www-form-urlencoded' | ||
// opts.method will now be POST and Content-Type: 'application/x-www-form-urlencoded' | ||
https.request(opts, function(res) { res.pipe(process.stdout) }).end(opts.body) | ||
@@ -40,2 +41,3 @@ | ||
}) | ||
http.request(opts, function(res) { res.pipe(process.stdout) }).end(opts.body) | ||
@@ -45,9 +47,9 @@ // works with all other services that support Signature Version 4 | ||
opts = aws4.sign({ service: 'sts', path: '/?Action=GetSessionToken&Version=2011-06-15' }) | ||
https.request(opts, function(res) { res.pipe(process.stdout) }).end() | ||
opts = aws4.sign({ | ||
service: 'glacier', | ||
path: '/-/vaults', | ||
headers: { 'X-Amz-Glacier-Version': '2012-06-01' } | ||
}) | ||
opts = aws4.sign({ service: 'glacier', path: '/-/vaults', headers: { 'X-Amz-Glacier-Version': '2012-06-01' } }) | ||
https.request(opts, function(res) { res.pipe(process.stdout) }).end() | ||
opts = aws4.sign({ service: 'cloudsearch', path: '/?Action=DescribeDomains' }) | ||
https.request(opts, function(res) { res.pipe(process.stdout) }).end() | ||
{ | ||
"name": "aws4", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"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)", |
aws4 | ||
------------- | ||
---- | ||
@@ -8,2 +8,3 @@ [![Build Status](https://secure.travis-ci.org/mhart/aws4.png?branch=master)](http://travis-ci.org/mhart/aws4) | ||
[AWS Signature Version 4](http://docs.amazonwebservices.com/general/latest/gr/signature-version-4.html). | ||
It also provides defaults for a number of core AWS headers and | ||
@@ -20,11 +21,12 @@ request parameters, making it a very easy to query AWS services, or | ||
, aws4 = require('aws4') | ||
, opts = { host: 'sqs.us-east-1.amazonaws.com', path: '/?Action=ListQueues' } | ||
// assuming AWS credentials are available from process.env | ||
aws4.sign(opts) | ||
// given an options object you could pass to http.request | ||
var opts = { host: 'sqs.us-east-1.amazonaws.com', path: '/?Action=ListQueues' } | ||
// opts.headers now contains the signed AWS headers, and can be used | ||
// in standard node.js http(s) requests | ||
aws4.sign(opts) // assumes AWS credentials are available in process.env | ||
// pipe the SOAP response from SQS to stdout | ||
// opts.headers now contains the signed AWS headers, and is ready for | ||
// use in standard node.js http(s) requests | ||
// eg, pipe the SOAP response from the above SQS request to stdout | ||
http.request(opts, function(res) { res.pipe(process.stdout) }).end() | ||
@@ -41,3 +43,3 @@ | ||
// opts.method will be POST and Content-Type 'application/x-www-form-urlencoded' | ||
// opts.method will now be POST and Content-Type: 'application/x-www-form-urlencoded' | ||
https.request(opts, function(res) { res.pipe(process.stdout) }).end(opts.body) | ||
@@ -57,2 +59,3 @@ | ||
}) | ||
http.request(opts, function(res) { res.pipe(process.stdout) }).end(opts.body) | ||
@@ -62,11 +65,9 @@ // works with all other services that support Signature Version 4 | ||
opts = aws4.sign({ service: 'sts', path: '/?Action=GetSessionToken&Version=2011-06-15' }) | ||
https.request(opts, function(res) { res.pipe(process.stdout) }).end() | ||
opts = aws4.sign({ | ||
service: 'glacier', | ||
path: '/-/vaults', | ||
headers: { 'X-Amz-Glacier-Version': '2012-06-01' } | ||
}) | ||
opts = aws4.sign({ service: 'glacier', path: '/-/vaults', headers: { 'X-Amz-Glacier-Version': '2012-06-01' } }) | ||
https.request(opts, function(res) { res.pipe(process.stdout) }).end() | ||
opts = aws4.sign({ service: 'cloudsearch', path: '/?Action=DescribeDomains' }) | ||
https.request(opts, function(res) { res.pipe(process.stdout) }).end() | ||
``` | ||
@@ -121,1 +122,13 @@ | ||
(will also use `AWS_ACCESS_KEY` and `AWS_SECRET_KEY` if available) | ||
Thanks | ||
------ | ||
Thanks to [@jed](https://github.com/jed) for his | ||
[dynamo-client](https://github.com/jed/dynamo-client) lib where I first | ||
committed and subsequently extracted this code. | ||
Also thanks to the | ||
[official node.js AWS SDK](https://github.com/aws/aws-sdk-js) for giving | ||
me a start on implementing the v4 signature. | ||
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
12473
129