Skip to content

Latest commit

 

History

History
49 lines (35 loc) · 1.1 KB

README.md

File metadata and controls

49 lines (35 loc) · 1.1 KB

deno-aws-signer-v4 Build Status

Generates AWS Signature V4 for AWS low-level REST APIs.

Installation

import { AWSSignerV4 } from "https://raw.githubusercontent.com/silver-xu/deno-aws-sign-v4/master/src/mod.ts";

Region & Credentials

The below example will generate signed headers based on the region and credentials in following ENV variables:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY
  • AWS_REGION
const signer = new AWSSignerV4();
const headers = signer.sign("es", endpoint, "POST", payload);

const response = await fetch(endpoint, {
  headers
  method,
  body: payload,
});

Complete setup

const signer = new AWSSignerV4(
  'ap-southeast-2',  // Your real region
  {
    awsAccessKeyId: 1234 // Your real access key id
    awsSecretKey: 1234 // Your real secret key
  });

const headers = signer.sign("es", endpoint, "POST", payload);

const response = await fetch(endpoint, {
  headers
  method,
  body: payload,
});