cloudfront-signer
v4.1.0
Published
Sign urls for AWS CloudFront
Downloads
431
Readme
CloudFront Signer
Sign urls with canned or custom policy
Notice: Use aws-sdk library rather, this one was done before I knew about it, and inspired from aws-cloudfront-sign
// canned:
const cfSign = require('cloudfront-signer');
const expire = Math.floor((Date.now()+86400e3)*0.001); // expire in one day
const url = 'http://xyz.cloudfront.net/test/cool?fun=1';
const signedUrl = url + '&' + cfSign(url, expire, cfKeypairId, cfPrivateKey)
// custom (allow wildcards):
const cfSign = require('cloudfront-signer');
const expire = Math.floor((Date.now()+86400e3)*0.001); // expire in one day
const qs = cfSign('http://xyz.cloudfront.net/test/*', expire, cfKeypairId, cfPrivateKey)
// valid for 'http://xyz.cloudfront.net/test/test/bar?' + qs
// valid for 'http://xyz.cloudfront.net/test/test/cool?fun=1&' + qs