`aws-cloudfront-sign` is a JavaScript utility module designed to simplify the generation of signed URLs and signed cookies for Amazon CloudFront distributions. It addresses the historical gap where the official AWS SDK for JavaScript did not directly provide methods for CloudFront-specific URL signing, distinct from S3 signing. The package is currently stable at version 3.0.2, released in April 2026, with a release cadence that appears reactive to feature additions, bug fixes, and maintenance, rather than on a strict schedule. Key differentiators include its focused purpose on CloudFront signing, providing a straightforward API for both URL and cookie signing, and its compatibility with modern Node.js environments (v18+), including full TypeScript and ES Modules support since v3.0.0. While the AWS SDK for JavaScript now offers CloudFront signing capabilities, `aws-cloudfront-sign` remains a viable and actively maintained alternative.
npm install aws-cloudfront-signVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to generate both signed URLs and signed cookies for a CloudFront distribution, using a private key and key pair ID with an explicit expiration time.
Update `expireTime` values to use milliseconds, a `Date` instance, or a `moment` object instead of raw seconds.
Migrate away from RTMP streaming. If still needed, ensure to manage RTMP assets with an alternative distribution method as CloudFront no longer supports it.
Ensure the `privateKeyString` is the exact content of the `.pem` file, including all newlines. If loading from an environment variable, ensure `\n` characters are properly encoded/decoded.
Upgrade your Node.js environment to version 18 LTS or newer. Older Node.js versions are no longer supported.
Review existing code that relies on the default expiration. While generally a positive change, explicitly set `expireTime` if a shorter duration is required.
Increase `expireTime` or ensure `expireTime` is set sufficiently far in the future. Verify server clock synchronization. Check CloudFront distribution settings and key pair configuration.
Ensure the `privateKeyString` is the exact content of the `.pem` file, including all newlines. If loading from an environment variable, ensure `\n` characters are properly encoded/decoded.
For ES Modules (Node.js >=18, `type: "module"` in `package.json`), use `import { getSignedUrl } from 'aws-cloudfront-sign';`. For CommonJS, use `const { getSignedUrl } = require('aws-cloudfront-sign');`.No dependency data recorded yet.