superagent-aws-signed-request

plugin for superagent to sign requests with aws signature v4

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
superagent-aws-signed-request
1.0.56 years ago7 years agoMinified + gzip package size for superagent-aws-signed-request in KB

Readme

superagent-aws-signed-request
Greenkeeper badge
Superagent plugin that intercepts and signs the request with AWS Signature V4
Usage

Params

  • service - { String, required } a string specifying the AWS service you wish to make a request to. Supported Services.
  • options - { Object, optional } config object that contains optional params that have defaults
- key - { String } override for default of AWSACCESSKEYID environment variable - secret - { String } override for default of AWSSECRETACCESSKEY environment variable - region - { String } override for default of AWSREGION environment variable - sessionToken - { String } required if you are using temporary credentials from AWS STS

Supported Aws Services

To find the appropriate service name to use, a helpful resource is the Amazon Resource Names (ARNs) and AWS Service Namespaces page.
Note: Some services like API Gateway while having a namespace of apigateway, actually require you to pass execute-api if you are trying to make a request to the api hosted there. If you choose the wrong service name, an error should be returned with the service name you need, based on the service you are making a request to.

Example

const request = require('superagent');
const signRequest = require('superagent-aws-signed-request');

const awsService = 'execute-api'; // using api gateway as an example, look above for other services you can make requests to
return request
  .get(/* aws endpoint you wish to make a request to */)
  .use(signRequest(service, {
    key: 'AWS_ACCESS_KEY_ID', // uses env var by default
    secret: 'AWS_SECRET_ACCESS_KEY', // uses env var by default
    region: 'AWS_REGION', // uses env var by default
    sessionToken: 'sessionToken', // is needed if you are using temporary credentials from Amazon STS service
  }))
  .then( resp => console.log(resp));
Install
It's available on npm so you can simply install it with:
npm install --save superagent-aws-signed-request