npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-aws-signature

v0.0.9

Published

generate aws signature v4 for react-native

Downloads

592

Readme

react-native-aws-signature

helps you generate signature for aws request for React-Native applications (or other js applications )

NPM

Code Climate Test Coverage CI Status

library to generate AWS signaure V4 for React Native application because react-native's javascript runtime doesn't support running aws-sdk-js. This is the first part if you want to make any signed calls to AWS.

Installation

npm install react-native-aws-signature --save

Usage

var AWSSignature = require('react-native-aws-signature');
var awsSignature = new AWSSignature();
let credentials = {
	SecretKey: 'wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY',
	AccessKeyId: 'sdfsdfsdfsdfsdfsdf'
};
var options = {
	path: '/?Param2=value2&Param1=value1',
    method: 'get',
    service: 'service',
    headers: {
        'X-Amz-Date': '20150209T123600Z',
        'host': 'example.amazonaws.com'
    },
	region: 'us-east-1',
	body: '',
	credentials
};
awsSignature.setParams(options);
var signature = awsSignature.getSignature();
var authorization = awsSignature.getAuthorizationHeader();

##Workflow 1.Instantiate AWSSignature object by calling var awsSignature = new AWSSignature();

2.Set signature parameter by calling 'AWSSignature#setParams' with option object as the only parameter.

the option given in the example comprises of the minimal requirement needed to generate AWS signature

|option| | |---|---| |path|the path you're calling| |method| HTTP method | |service| AWS Service you're using ex. s3| |headers| HTTP headers| |region| AWS regions| |body| HTTP request body| |credentials| credentails object returned by coginto##GetCredentialsForIdentity, more on this later|

for headers, host and (date or X-Amz-Date) is required, other wise an exception will raise.

The datetime string passed with date header or X-Amz-Date has to be Amazon styled ISO 8601 strings like the one provided above, you can get one by calling AWSSignature#_formatDateTime and pass in an ISO 8601 string as the parameter.

For example awsSignature._formatDateTime('2015-02-09T10:00:00Z') will return 20150209T100000Z which is accecptable as X-Amz-Date.

  • this method might be moved to a util class once this project expands its scope so don't really count on using it*

##getSignature vs getAuthorizationHeader once you did setParams, you could either use getSignature or getAuthorizationHeader to get the signature, the difference is that getAuthorizationHeader will return something like the following so that you can use it in the following steps.

{
Authorization: 'AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/iam/aws4_request, SignedHeaders=content-type;host;x-amz-date, Signature=5d672d79c15b13162d9279b0855cfba6789a8edb4c82c400e06b5924a6f2b5d7'
}

This corresponds to Step4 of the documentation online.

Credentials

The minials requried credentail object looks like this:

{
	SecretKey: 'wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY',
	AccessKeyId: 'sdfsdfsdfsdfsdfsdf'
};

The required keys are SecretKey and AccessKeyIdthat you get from coginto##GetCredentialsForIdentity or somewhere else.

running test

once you cloned the git repo, do npn install first to install all the dependencies,

tests are written in jasmine, so just use jasmine to run the unit tests.