Skip to content

lucacasonato/deno_aws_sign_v4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

deno_aws_sign_v4

ci deno doc

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

Example

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_SESSION_TOKEN
  • AWS_REGION
import { AWSSignerV4 } from "https://deno.land/x/[email protected]/mod.ts";

const signer = new AWSSignerV4();
const body = new TextEncoder().encode("Hello World!");
const request = new Request("https://test-bucket.s3.amazonaws.com/test", {
  method: "PUT",
  headers: { "content-length": body.length.toString() },
  body,
});
const req = await signer.sign("s3", request);

const response = await fetch(req);

You can also explicitly specify credentials and a region when constructing a new AWSSignerV4:

const signer = new AWSSignerV4("us-east-1", {
  awsAccessKeyId: "accesskey";
  awsSecretKey: "secretkey";
  sessionToken: "sessiontoken";
});

Related projects


The module is licenced under GPL-3.0. For more see the LICENCE file.

This module is forked from @silver-xu's work in [https://github.com/silver-xu/deno-aws-sign-v4]. Many thanks to them. This fork has some large feature improvements and bug fixes, and has tests.