JSPM

ngx-aws4

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 154
  • Score
    100M100P100Q83162F
  • License MIT

Signs and prepares requests using AWS Signature Version 4

Package Exports

  • ngx-aws4

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ngx-aws4) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ngx-aws4

An utility to sign http(s) request options using Amazon's AWS Signature Version 4.

Installation

With npm do:

npm install ngx-aws4

Example

import * as aws4 from "ngx-aws4";

...

public static getAWS4Signature(url, path) {
    let requestOptions: any = {
        host: `${AWSCredentials.AWS_STS.BUCKET_NAME}.s3.${AWSCredentials.AWS_STS.REGION}.amazonaws.com`,
        path: path
    }

    console.log(aws4);

    aws4.sign(requestOptions, {
        secretAccessKey: AWSCredentials.AWS_STS.SECRET_KEY,
        accessKeyId: AWSCredentials.AWS_STS.ACCESS_KEY,
        sessionToken: AWSCredentials.AWS_STS.SESSION_TOKEN
    })
    console.log(requestOptions);

    return requestOptions;
}

...

More options

// you can also pass AWS credentials in explicitly (otherwise taken from process.env)
aws4.sign(opts, {accessKeyId: '', secretAccessKey: ''})

// can also add the signature to query strings
aws4.sign({service: 's3', path: '/my-bucket?X-Amz-Expires=12345', signQuery: true})

Thanks

Thanks to @mhart

Thanks to @jed

Also thanks to the official node.js AWS SDK