{"name":"aws4","version":"1.0.4","description":"Signs and prepares requests using AWS Signature Version 4","author":{"name":"Michael Hart","email":"michael.hart.au@gmail.com","url":"http://github.com/mhart"},"main":"aws4.js","keywords":["amazon","aws","signature","s3","ec2","autoscaling","cloudformation","elasticloadbalancing","elb","elasticbeanstalk","cloudsearch","dynamodb","kinesis","lambda","glacier","sqs","sns","iam","sts","ses","swf","storagegateway","datapipeline","directconnect","redshift","opsworks","rds","monitoring","cloudtrail","cloudfront","codedeploy","elasticache","elasticmapreduce","elastictranscoder","emr","cloudwatch","mobileanalytics","cognitoidentity","cognitosync","cognito","containerservice","ecs","appstream","keymanagementservice","kms","config","cloudhsm","route53","route53domains","logs"],"repository":{"type":"git","url":"git+https://github.com/mhart/aws4.git"},"license":"MIT","dependencies":{"lru-cache":"^2.6.5"},"devDependencies":{"mocha":"^2.2.5","should":"^7.0.1"},"scripts":{"test":"mocha ./test/fast.js ./test/slow.js -b -t 100s -R list"},"gitHead":"2f73f9f05100c52e8d175e327d86f1fa3ec76bde","bugs":{"url":"https://github.com/mhart/aws4/issues"},"homepage":"https://github.com/mhart/aws4#readme","_id":"aws4@1.0.4","_shasum":"2ae0134fe17af91d556e951b1ecc343a32169788","_from":".","_npmVersion":"2.11.3","_nodeVersion":"0.10.39","_npmUser":{"name":"hichaelmart","email":"michael.hart.au@gmail.com"},"maintainers":[{"name":"hichaelmart","email":"michael.hart.au@gmail.com"}],"dist":{"shasum":"2ae0134fe17af91d556e951b1ecc343a32169788","tarball":"http://registry-npm.ywwl.com/aws4/download/aws4-1.0.4.tgz","integrity":"sha512-nrbpGJcFBXeF3LLYWtf+vKHKGFfNvpq8UOpolRNX33S+A7RHFF+axqkLjIGpNCiEELJ/GfIeO2rYvmdbQT1f+w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDlL9GNRSmOzdSzJSNC588McJ4tzvW859yJdJdpdpK41AiAci6N5sIFzTyceGQmk+GyjcE80FtY0R5fT1oTacrJfFw=="}],"size":8262,"noattachment":false,"key":"/aws4/-/aws4-1.0.4.tgz"},"directories":{},"readme":"aws4\n----\n\n[![Build Status](https://api.travis-ci.org/mhart/aws4.png?branch=master)](https://travis-ci.org/github/mhart/aws4)\n\nA small utility to sign vanilla Node.js http(s) request options using Amazon's\n[AWS Signature Version 4](https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html).\n\nIf you want to sign and send AWS requests in a browser, or an environment like [Cloudflare Workers](https://developers.cloudflare.com/workers/), then check out [aws4fetch](https://github.com/mhart/aws4fetch) – otherwise you can also bundle this library for use [in older browsers](./browser).\n\nThe only AWS service that *doesn't* support v4 as of 2020-05-22 is\n[SimpleDB](https://docs.aws.amazon.com/AmazonSimpleDB/latest/DeveloperGuide/SDB_API.html)\n(it only supports [AWS Signature Version 2](https://github.com/mhart/aws2)).\n\nIt also provides defaults for a number of core AWS headers and\nrequest parameters, making it very easy to query AWS services, or\nbuild out a fully-featured AWS library.\n\nExample\n-------\n\n```javascript\nvar https = require('https')\nvar aws4  = require('aws4')\n\n// to illustrate usage, we'll create a utility function to request and pipe to stdout\nfunction request(opts) { https.request(opts, function(res) { res.pipe(process.stdout) }).end(opts.body || '') }\n\n// aws4 will sign an options object as you'd pass to http.request, with an AWS service and region\nvar opts = { host: 'my-bucket.s3.us-west-1.amazonaws.com', path: '/my-object', service: 's3', region: 'us-west-1' }\n\n// aws4.sign() will sign and modify these options, ready to pass to http.request\naws4.sign(opts, { accessKeyId: '', secretAccessKey: '' })\n\n// or it can get credentials from process.env.AWS_ACCESS_KEY_ID, etc\naws4.sign(opts)\n\n// for most AWS services, aws4 can figure out the service and region if you pass a host\nopts = { host: 'my-bucket.s3.us-west-1.amazonaws.com', path: '/my-object' }\n\n// usually it will add/modify request headers, but you can also sign the query:\nopts = { host: 'my-bucket.s3.amazonaws.com', path: '/?X-Amz-Expires=12345', signQuery: true }\n\n// and for services with simple hosts, aws4 can infer the host from service and region:\nopts = { service: 'sqs', region: 'us-east-1', path: '/?Action=ListQueues' }\n\n// and if you're using us-east-1, it's the default:\nopts = { service: 'sqs', path: '/?Action=ListQueues' }\n\naws4.sign(opts)\nconsole.log(opts)\n/*\n{\n  host: 'sqs.us-east-1.amazonaws.com',\n  path: '/?Action=ListQueues',\n  headers: {\n    Host: 'sqs.us-east-1.amazonaws.com',\n    'X-Amz-Date': '20121226T061030Z',\n    Authorization: 'AWS4-HMAC-SHA256 Credential=ABCDEF/20121226/us-east-1/sqs/aws4_request, ...'\n  }\n}\n*/\n\n// we can now use this to query AWS\nrequest(opts)\n/*\n<?xml version=\"1.0\"?>\n<ListQueuesResponse xmlns=\"https://queue.amazonaws.com/doc/2012-11-05/\">\n...\n*/\n\n// aws4 can infer the HTTP method if a body is passed in\n// method will be POST and Content-Type: 'application/x-www-form-urlencoded; charset=utf-8'\nrequest(aws4.sign({ service: 'iam', body: 'Action=ListGroups&Version=2010-05-08' }))\n/*\n<ListGroupsResponse xmlns=\"https://iam.amazonaws.com/doc/2010-05-08/\">\n...\n*/\n\n// you can specify any custom option or header as per usual\nrequest(aws4.sign({\n  service: 'dynamodb',\n  region: 'ap-southeast-2',\n  method: 'POST',\n  path: '/',\n  headers: {\n    'Content-Type': 'application/x-amz-json-1.0',\n    'X-Amz-Target': 'DynamoDB_20120810.ListTables'\n  },\n  body: '{}'\n}))\n/*\n{\"TableNames\":[]}\n...\n*/\n\n// you can also specify extra headers to ignore during signing\nrequest(aws4.sign({\n  host: '07tjusf2h91cunochc.us-east-1.aoss.amazonaws.com',\n  method: 'PUT',\n  path: '/my-index',\n  body: '{\"mappings\":{}}',\n  headers: {\n    'Content-Type': 'application/json',\n    'X-Amz-Content-Sha256': 'UNSIGNED-PAYLOAD'\n  },\n  extraHeadersToIgnore: {\n    'content-length': true\n  }\n}))\n\n// and headers to include that would normally be ignored\nrequest(aws4.sign({\n  service: 'mycustomservice',\n  path: '/whatever',\n  headers: {\n    'Range': 'bytes=200-1000, 2000-6576, 19000-'\n  },\n  extraHeadersToInclude: {\n    'range': true\n  }\n}))\n\n\n// The raw RequestSigner can be used to generate CodeCommit Git passwords\nvar signer = new aws4.RequestSigner({\n  service: 'codecommit',\n  host: 'git-codecommit.us-east-1.amazonaws.com',\n  method: 'GIT',\n  path: '/v1/repos/MyAwesomeRepo',\n})\nvar password = signer.getDateTime() + 'Z' + signer.signature()\n\n// see example.js for examples with other services\n```\n\nAPI\n---\n\n### aws4.sign(requestOptions, [credentials])\n\nCalculates and populates any necessary AWS headers and/or request\noptions on `requestOptions`. Returns `requestOptions` as a convenience for chaining.\n\n`requestOptions` is an object holding the same options that the Node.js\n[http.request](https://nodejs.org/docs/latest/api/http.html#http_http_request_options_callback)\nfunction takes.\n\nThe following properties of `requestOptions` are used in the signing or\npopulated if they don't already exist:\n\n- `hostname` or `host` (will try to be determined from `service` and `region` if not given)\n- `method` (will use `'GET'` if not given or `'POST'` if there is a `body`)\n- `path` (will use `'/'` if not given)\n- `body` (will use `''` if not given)\n- `service` (will try to be calculated from `hostname` or `host` if not given)\n- `region` (will try to be calculated from `hostname` or `host` or use `'us-east-1'` if not given)\n- `signQuery` (to sign the query instead of adding an `Authorization` header, defaults to false)\n- `extraHeadersToIgnore` (an object with lowercase header keys to ignore when signing, eg `{ 'content-length': true }`)\n- `extraHeadersToInclude` (an object with lowercase header keys to include when signing, overriding any ignores)\n- `headers['Host']` (will use `hostname` or `host` or be calculated if not given)\n- `headers['Content-Type']` (will use `'application/x-www-form-urlencoded; charset=utf-8'`\n  if not given and there is a `body`)\n- `headers['Date']` (used to calculate the signature date if given, otherwise `new Date` is used)\n\nYour AWS credentials (which can be found in your\n[AWS console](https://portal.aws.amazon.com/gp/aws/securityCredentials))\ncan be specified in one of two ways:\n\n- As the second argument, like this:\n\n```javascript\naws4.sign(requestOptions, {\n  secretAccessKey: \"<your-secret-access-key>\",\n  accessKeyId: \"<your-access-key-id>\",\n  sessionToken: \"<your-session-token>\"\n})\n```\n\n- From `process.env`, such as this:\n\n```\nexport AWS_ACCESS_KEY_ID=\"<your-access-key-id>\"\nexport AWS_SECRET_ACCESS_KEY=\"<your-secret-access-key>\"\nexport AWS_SESSION_TOKEN=\"<your-session-token>\"\n```\n\n(will also use `AWS_ACCESS_KEY` and `AWS_SECRET_KEY` if available)\n\nThe `sessionToken` property and `AWS_SESSION_TOKEN` environment variable are optional for signing\nwith [IAM STS temporary credentials](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html).\n\nInstallation\n------------\n\nWith [npm](https://www.npmjs.com/) do:\n\n```\nnpm install aws4\n```\n\nCan also be used [in the browser](./browser).\n\nThanks\n------\n\nThanks to [@jed](https://github.com/jed) for his\n[dynamo-client](https://github.com/jed/dynamo-client) lib where I first\ncommitted and subsequently extracted this code.\n\nAlso thanks to the\n[official Node.js AWS SDK](https://github.com/aws/aws-sdk-js) for giving\nme a start on implementing the v4 signature.\n","publish_time":1435764163662,"_cnpm_publish_time":1435764163662,"dist-tags":{"latest":"1.13.2","v01":"0.1.13","v02":"0.2.5","v03":"0.3.2","v04":"0.4.4","v05":"0.5.3"}}