Skip to content

Creates and signs private Cloudfront Urls (http, https, and rtmp)

Notifications You must be signed in to change notification settings

maxnachlinger/cloudfront-private-url-creator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cloudfront-private-url-creator

Creates and signs private Cloudfront Urls (http:, https:, rtmp:, rtmpt:, rtmpe:, and rtmpte:)

travis npm downloads standard

Installation:

npm i cloudfront-private-url-creator

Note:

If you are using Node 0.10 - 0.12, please use version 1.1.0.

Usage:

'use strict'
const fs = require('fs')
const cf = require('cloudfront-private-url-creator')

const urlToSign = 'https://somedistro.cloudfront.net/somefolder/someFile'
const keyPairId = 'yourKeyPaidId'
const privateKeyPath = './yourKey.pem'

// date when the private url will expire (1 hour from now in this case)
const dateLessThan = new Date()
dateLessThan.setHours(dateLessThan.getHours() + 1)

const privateKey = fs.readFileSync(privateKeyPath)

const config = {
  privateKey,
  keyPairId,
  dateLessThan
}
// sign the url and return it, or just get the signature
const signatureQueryString = cf.getSignatureQueryString(urlToSign, config)
// OR
const signedUrl = cf.signUrl(urlToSign, config)

Relevant AWS docs:

Creating a Signed URL Using a Canned Policy

Creating a Signed URL Using a Custom Policy

Contributors

Here's a list, thanks for your help!

About

Creates and signs private Cloudfront Urls (http, https, and rtmp)

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •