Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cloudfront-signer

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudfront-signer - npm Package Compare versions

Comparing version 3.0.0 to 4.0.0

7

index.js

@@ -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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc