Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

react-native-aws4

NikolasVer311MIT1.2.1

Signs and prepares requests using AWS Signature Version 4 in React Native Apps

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, react, react-native, android, ios

readme

AWS4 React Native

GitHub Logo

NOTE: This package is a stabe fork of aws4 and aws4-react-native modified to work with React Native apps. With the most important change - fix Buffer dependencies. The core Node JS module querystring has been replaced by querystring-browser, and crypto has been replaced by a standalone javascript file crypto.js generated using browserify.

What follows is the a slighly modified README from aws4.


Example

import aws4 from 'react-native-aws4';

// given an options object you could pass to http.request
const opts = {
  host: 'sqs.us-east-1.amazonaws.com',
  path: '/?Action=ListQueues'
};

// alternatively (as aws4 can infer the host):
opts = {
  service: 'sqs', 
  region: 'us-east-1', 
  path: '/?Action=ListQueues'
}

// alternatively (as us-east-1 is default):
opts = {
  service: 'sqs', 
  path: '/?Action=ListQueues'
}

aws4.sign(opts) // assumes AWS credentials are available in process.env

console.log(opts)
/*
{
  host: 'sqs.us-east-1.amazonaws.com',
  path: '/?Action=ListQueues',
  headers: {
    Host: 'sqs.us-east-1.amazonaws.com',
    'X-Amz-Date': '20121226T061030Z',
    Authorization: 'AWS4-HMAC-SHA256 Credential=ABCDEF/20121226/us-east-1/sqs/aws4_request, ...'
  }
}
*/

// we can now use this to query AWS using the standard React Native API
const url = "https://" + signedOptions.host + signedOptions.path;
fetch(url, signedOptions)
  .then(body => body.json())
  .then(json => console.log(json));
// The above code is equivalent to the following Node JS request:
// http.request(opts, function(res) { res.pipe(process.stdout) }).end()
/*
*/