Commit

d21cdf0

I made a zero-dependency presigned URL generator for S3-compatible storage, with support for signing URLs that point at your CDN If you only need presigned download links, pulling in @aws-sdk/client-s3 and @aws-sdk/s3-request-presigner is a lot of dependency weight for one HMAC calculation. That also matters for serverless cold starts. So I wrote object-presigner. It’s a small library that generates AWS SigV4 presigned GET URLs using only Node’s built-in crypto. It should work with AWS S3, MinIO, Cloudflare R2, DigitalOcean Spaces and other S3-compatible storage. The part I needed most was separating the signing host from the public host. My files are served through a CDN that forwards to the storage origin, so the signature has to be computed against the origin, but the URL I hand out should point at the CDN domain. Most presigners don’t make that easy.
import

const url = [REDACTED]({
  key: "uploads/image.png",
  accessKeyId: process.env.AWS_ACCESS_KEY_ID,
  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
  bucket: "my-bucket",
  signingHost: "s3.example.com",  // origin the storage validates against
  cdnHost: "cdn.example.com",     // domain in the returned URL
  expiresIn: 3600,
});
No dependencies ESM and CommonJS TypeScript types included MIT licensed npm: https://www.npmjs.com/package/@thedeceptio/object-presigner GitHub: https://github.com/thedeceptio/object-presigner It’s early (v0.0.x) and GET-only for now. PUT uploads and session tokens are on my list. Feedback, issues and PRs welcome.

commit d21cdf0