Package Exports
- aws-cloudfront-sign
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (aws-cloudfront-sign) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
AWS CloudFront URL Signature Utility
Generating signed URLs for CloudFront links is a little more tricky than for S3. It's because signature generation for S3 URLs is handled a bit differently than CloudFront URLs and this functionality is not currently supported by the aws-sdk library for JavaScript. In case you also need to do this, I've created this simple utility to make things easier.
Setup
###Configure CloudFront
Create a CloudFront distribution
Configure your origin with the following settings:
Origin Domain Name: {your-s3-bucket}
Restrict Bucket Access: Yes
Grant Read Permissions on Bucket: Yes, Update Bucket PolicyCreate CloudFront Key Pair.
###Installing
npm install aws-cloudfront-sign###Usage
var cf = require('aws-cloudfront-sign')
var params = {
privateKeyString: process.env.PRIVATE_KEY,
expireTime: '<epoch time when you wish the link to expire>'
}
cf.getSignedUrl('http://example.com/path/to/s3/object', params, function(err, url) {
console.log('Signed URL: ' + url)
})