https://github.com/junkurihara/js-aws-signature-v4
TypeScript Implementation of AWS Signature Version 4
https://github.com/junkurihara/js-aws-signature-v4
Last synced: 3 months ago
JSON representation
TypeScript Implementation of AWS Signature Version 4
- Host: GitHub
- URL: https://github.com/junkurihara/js-aws-signature-v4
- Owner: junkurihara
- License: mit
- Created: 2019-05-28T22:46:04.000Z (about 6 years ago)
- Default Branch: develop
- Last Pushed: 2025-04-13T13:27:52.000Z (3 months ago)
- Last Synced: 2025-04-14T00:15:58.314Z (3 months ago)
- Language: TypeScript
- Size: 1.52 MB
- Stars: 7
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# js-aws-signature-v4
TypeScript implementation of AWS Signature Version 4[](https://badge.fury.io/js/js-aws-sigv4)
[](https://codeclimate.com/github/junkurihara/js-aws-signature-v4/maintainability)
[](https://codecov.io/gh/junkurihara/js-aws-signature-v4)
[](https://opensource.org/licenses/MIT)
> **WARNING**: At this time this solution should be considered suitable for research and experimentation, further code and security review is needed before utilization in a production application.
# Introduction and Overview
This tiny library is being developed to generate AWS signature version 4 and pre-signed url. This library is designed to be 'universal', i.e., it works both on most browsers and on Node.js just by importing from npm/source code.# Installation
At your project directory, do either one of the following.- From npm/yarn:
```shell
$ npm install --save js-aws-sigv4 // npm
$ yarn add js-aws-sigv4 // yarn
```- From GitHub:
```shell
$ git clone https://github.com/junkurihara/js-aws-signature-v4.git
```Then you should import the package as follows.
```javascript
import jsAwsSigV4 from 'js-aws-sigv4'; // for npm
```# Usage
## Get signature itself
```javascript
const signingKey = await jsAwsSigv4.getSigningKey(
credential.secretAccessKey,
dateIsoString(new Date()),
region_name,
's3'
);const signature = await jsAwsSigv4.getSignature(
signingKey,
'stringToSign'
);
```## Get pre-signed URL
```javascript
const uriPath = '/public/test.txt';
const headers = {'Content-Type' : 'application/json', 'X-Amz-Meta-Foo': 'barbaz', 'X-Amz-Meta-Foobar': 'bazbaz'};const signedUrlGet = await jsAwsSigv4.getSignedUrl(
{
accessKeyId: credential.accessKeyId,
secretAccessKey: credential.secretAccessKey,
sessionToken: credential.sessionToken, // optional
regionName: region_name
},
{
method: 'GET',
hostName: host_name,
serviceName: 's3',
uriPath,
headers // optional
},
);```
# License
Licensed under the MIT license, see `LICENSE` file.