Skip to main content
Module

x/s3/deps.ts>AWSSignerV4

Amazon S3 for Deno
Latest
class AWSSignerV4
implements Signer
import { AWSSignerV4 } from "https://deno.land/x/s3@0.5.0/deps.ts";

This class can be used to create AWS Signature V4 for low-level AWS REST APIs. You can either provide credentials for this API using the options in the constructor, or let them be aquired automatically through environment variables.

Example usage:

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);

Constructors

new
AWSSignerV4(region?: string, credentials?: Credentials)

If no region or credentials are specified, they will automatically be aquired from environment variables.

Region is aquired from AWS_REGION. The credentials are acquired from AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_SESSION_TOKEN.

Properties

private
credentials: Credentials
private
region: string

Methods

sign(service: string, request: Request): Promise<Request>

Use this to create the signed headers required to make a call to an AWS API.