Skip to content

Calculates presigned URLs for AWS S3 using the Web Crypto API.

License

Notifications You must be signed in to change notification settings

jpantzlaff/aws-s3-presign-webcrypto

 
 

Repository files navigation

Generates presigned URLs to get, create, and otherwise manipulate objects in Amazon S3 (AWS Signature Version 4). Tested per https://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-query-string-auth.html.

This module works mostly like the dansalias/aws_s3_presign repository it's based on. However, it avoids the use of Deno-specific libraries, favoring the Web Crypto API instead.

Usage

import { getSignedUrl } from './mod.ts'

const url = getSignedUrl({
  accessKeyId: 'my-aws-access-key-id',
  secretAccessKey: 'my-aws-secret-access-key',
  path: '/example-bucket/test.txt',
  region: 'us-east-1',
})

Options

interface GetSignedUrlOptions {
  path: string              // required
  accessKeyId: string       // required
  secretAccessKey: string   // required
  sessionToken?: string     // AWS STS token
  method?: 'GET' | 'PUT'    // default 'GET'
  region?: string           // default 'us-east-1'
  expiresIn?: number        // seconds, default 86400 (24 hours)
  date?: Date               // forced creation date, for testing
  endpoint?: string         // custom endpoint, default s3.amazonaws.com
}

Testing

deno test

About

Calculates presigned URLs for AWS S3 using the Web Crypto API.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%