cloudfront-signer
Advanced tools
Comparing version 3.0.0 to 4.0.0
@@ -15,3 +15,3 @@ const crypto = require('crypto'); | ||
- url: cloudfront origin + path in S3 for the resource | ||
- expires: timestamp (in ms) or Date | ||
- expires: expire UNIX time in seconds | ||
- keypairId: CloudFront key-pair-id | ||
@@ -24,5 +24,4 @@ - privateKey: CloudFront certificate as ascii string ( fs.readFileSync(path.resolve('./cloudfront.pem')).toString('ascii') ) | ||
*/ | ||
module.exports = function cfSign(url, expires, keypairId, privateKey, custom=url.endsWith('*')) { // todo 3 last in an obj | ||
const time = Math.floor(expires/1000); // to unix | ||
module.exports = function cfSign(url, time, keypairId, privateKey, custom=url.endsWith('*')) { // todo 3 last in an obj | ||
// const url = cfUrl + '/' + path; | ||
@@ -29,0 +28,0 @@ const policyStr = JSON.stringify({ |
{ | ||
"name": "cloudfront-signer", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"description": "Sign urls for AWS CloudFront", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -9,4 +9,5 @@ ## 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, new Date(Date.now()+86400e3), cfKeypairId, cfPrivateKey) | ||
const signedUrl = url + '&' + cfSign(url, expire, cfKeypairId, cfPrivateKey) | ||
``` | ||
@@ -19,4 +20,6 @@ | ||
const qs = cfSign('http://xyz.cloudfront.net/test/*', new Date(Date.now()+86400e3), cfKeypairId, cfPrivateKey) | ||
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 | ||
``` |
@@ -35,3 +35,3 @@ const cfUrl = 'https://d123.cloudfront.net'; | ||
var d = new Date(2017, 4, 20); | ||
var d = new Date(2017, 4, 20)/1000; | ||
@@ -38,0 +38,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5987
23
83