Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
hapiest-cloudfront-url
Advanced tools
npm install --save hapiest-cloudfront-url
I highly recommend you use this with node-config if possible though it's not a requirement.
Include a config section that adheres to the following (assuming JSON format):
{
"myCloudfrontDistribution": {
"cloudfrontDomainName": "somedomain.cloudfront.net",
"enabled": "true",
"origins": [{
"host": "mybucket.s3.amazonaws.com",
"path": "/public"
},{
"host": "www.mysite.com",
"path": "my/crazy/path"
},{
"host": "localhost",
"port": 3000,
"path": "localstorage/bucket/public"
}]
}
}
You then simply use the createFromNodeConfig
function provided:
const NodeConfig = require('config');
const CfUrlServiceFactory = require('hapiest-cloudfront-url');
const cfUrlService = CfUrlServiceFactory.createFromNodeConfig(NodeConfig, 'myCloudfrontDistribution');
const CfUrlServiceFactory = require('hapiest-cloudfront-url');
const cfUrlService = CfUrlServiceFactory.create({
cloudfrontDomainName: 'somedomain.cloudfront.net',
enabled: true,
origins: [{
host: 'mybucket.s3.amazonaws.com',
path: '/public'
},{
host: 'www.mysite.com',
path: 'my/crazy/path'
},{
host: 'localhost',
port: 3000,
path: 'localstorage/bucket/public'
}]
});
When the originUrl provided the convertUrl
function matches one of the URLs associated with the distribution,
the return value is a URL relative to the Cloudfront domain.
const originUrl = 'http://mybucket.s3.amazonaws.com/public/images/image.jpg';
const cfUrl = cfUrlService.convertUrl(originUrl);
// http://somedomain.cloudfront.net/images/image.jpg
const originUrl2 = 'https://www.mysite.com/my/crazy/path/something.txt';
const cfUrl2 = cfUrlService.convertUrl(originUrl2);
// https://somedomain.cloudfront.net/something.txt
const originUrl3 = 'http://localhost:3000/localstorage/bucket/public/images/thumb.jpg'
const cfUrl3 = cfUrlService.convertUrl(originUrl3);
// http://somedomain.cloudfront.net/images/thumb.jpg
If the provided URL does not match an origin, the provided URL is simply returned:
const originalUrl = 'http://www.someothersite.com/does/not/match/an/origin.jpg';
const cfUrl = cfUrlService.convertUrl(originUrl);
// 'http://www.someothersite.com/does/not/match/an/origin.jpg'
When enabled=false
, convertUrl
always returns the original URL though you can override
that behavior by passing in a second parameter of true
.
FAQs
Maps origin URLs to an AWS Cloudfront distribution URL
The npm package hapiest-cloudfront-url receives a total of 5 weekly downloads. As such, hapiest-cloudfront-url popularity was classified as not popular.
We found that hapiest-cloudfront-url demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.