class AWSSignerV4
implements Signer
import { AWSSignerV4 } from "https://dotland.deno.dev/x/aws_api@v0.8.1/client/signing.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)Properties
private
credentials: CredentialsMethods
presign(service: string, props: { method?: "GET" | "PUT"; url: string; expiresIn?: number; signTime?: Date; })
Generate a "pre-signed" URL. Generally used to create short-lived links to private S3 objects.
const url = await signer.presign('s3', {
method: 'GET',
url: 'https://my-bucket.s3.amazonaws.com/my-key',
});
sign(service: string, request: Request): Promise<Request>
Use this to create the signed headers required to make a call to an AWS API.