New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@orbiting/backend-modules-assets

Package Overview
Dependencies
Maintainers
6
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@orbiting/backend-modules-assets - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

express/frontend.js

36

CHANGELOG.md

@@ -1,6 +0,38 @@

<a name="1.1.0"></a>
# 1.1.0 (2018-01-17)
<a name="2.0.0"></a>
# 2.0.0 (2018-01-25)
<a name="2.0.0"></a>
# 2.0.0 (2018-01-25)
### Bug Fixes
* **assets:** cleanup header forwarding/filtering ([33d4a5b](https://github.com/orbiting/backend-modules/commit/33d4a5b))
* **assets:** readme ([590de0a](https://github.com/orbiting/backend-modules/commit/590de0a))
* **assets:** refactor url schema ([3c433bb](https://github.com/orbiting/backend-modules/commit/3c433bb))
* **assets:** restructure code ([c919c26](https://github.com/orbiting/backend-modules/commit/c919c26))
* **assets:** simplify url envs ([de1698d](https://github.com/orbiting/backend-modules/commit/de1698d))
### Features
* **assets:** add /frontend proxy, README ([7d0d851](https://github.com/orbiting/backend-modules/commit/7d0d851))
* **assets:** add lib webp url suffixer ([2119fa3](https://github.com/orbiting/backend-modules/commit/2119fa3))
* **assets:** add size=WxH to portraitUrl in uploadPortrait ([98b6492](https://github.com/orbiting/backend-modules/commit/98b6492))
* **assets:** port pageRenderer, renderUrl, uploadS3 and convertImage from republik-backend ([0ee299a](https://github.com/orbiting/backend-modules/commit/0ee299a))
* **assets:** repo.uploadImages: transfers images from github to AWS S3 ([9fe4b10](https://github.com/orbiting/backend-modules/commit/9fe4b10))
* **assets:** s3 proxy, options for returnImage, pipe through cleaned headers ([1865033](https://github.com/orbiting/backend-modules/commit/1865033))
* **assets:** upload lib, cleanup convertImage ([7bc6d1f](https://github.com/orbiting/backend-modules/commit/7bc6d1f))
* **assets:** use streams instead of buffers ([b6a9801](https://github.com/orbiting/backend-modules/commit/b6a9801))
* **assets:** webp support, error handling ([03ae2e5](https://github.com/orbiting/backend-modules/commit/03ae2e5))
### BREAKING CHANGES
* **assets:** replace PUBLIC_ASSETS_HOSTNAME and INTERNAL_ASSETS_HOSTNAME with ASSETS_SERVER_BASE_URL
<a name="1.1.0"></a>

@@ -7,0 +39,0 @@ # 1.1.0 (2018-01-17)

92

lib/index.js

@@ -1,78 +0,20 @@

const { URL } = require('url')
const querystring = require('querystring')
const crypto = require('crypto')
const checkEnv = require('check-env')
const upload = require('./upload')
const s3 = require('./s3')
const convertImage = require('./convertImage')
const getWidthHeight = require('./getWidthHeight')
const returnImage = require('./returnImage')
const urlPrefixing = require('./urlPrefixing')
const webp = require('./webp')
const Repo = require('./Repo')
checkEnv[
'ASSETS_HMAC_KEY'
]
const {
PUBLIC_ASSETS_HOSTNAME,
INTERNAL_ASSETS_HOSTNAME,
ASSETS_HMAC_KEY
} = process.env
if (!PUBLIC_ASSETS_HOSTNAME && !INTERNAL_ASSETS_HOSTNAME) {
throw new Error('You need to at least set either PUBLIC_ASSETS_HOSTNAME or INTERNAL_ASSETS_HOSTNAME')
}
const originalKey = 'originalURL'
const authenticate = url =>
crypto
.createHmac('sha256', ASSETS_HMAC_KEY)
.update(url)
.digest('hex')
module.exports = {
authenticate,
createRepoUrlPrefixer: (repoId, public) => {
if (!repoId) {
throw new Error('createRepoUrlPrefixer needs a repoId')
}
return path => {
if (path && path.indexOf('images/') > -1) {
const hostname = public
? PUBLIC_ASSETS_HOSTNAME
: INTERNAL_ASSETS_HOSTNAME
const url = new URL(`${hostname}/assets/images/${repoId}/${path}`)
if (!public) {
url.hash = querystring.stringify({
[originalKey]: path
})
}
return url.toString()
}
return path
}
},
createUrlPrefixer: public => url => {
const hostname = public
? PUBLIC_ASSETS_HOSTNAME
: INTERNAL_ASSETS_HOSTNAME
return `${hostname}/assets/images?` + querystring.stringify({
[originalKey]: url,
mac: authenticate(url)
})
},
unprefixUrl: _url => {
try {
const url = new URL(_url)
if (url.hash.length > 0) { //repo prefixed
const hash = querystring.parse(url.hash.substring(1))
const originalUrl = hash[originalKey]
if (originalUrl) {
return originalUrl
}
} else if (url.searchParams && url.searchParams.get(originalKey)) { // embed prefixed
return url.searchParams.get(originalKey)
}
} catch (e) { }
return _url
}
upload,
s3,
convertImage,
getWidthHeight,
returnImage,
webp,
Repo,
urlPrefixing,
...urlPrefixing
}
{
"name": "@orbiting/backend-modules-assets",
"version": "1.1.0",
"version": "2.0.0",
"description": "server assets",

@@ -27,6 +27,7 @@ "main": "index.js",

"@orbiting/backend-modules-github": "^1.0.0",
"aws-sdk": "^2.185.0",
"check-env": "^1.3.0",
"debug": "^3.1.0",
"export-files": "^2.1.1",
"file-type": "^7.4.0",
"file-type-stream": "^1.0.0",
"sharp": "^0.18.4"

@@ -33,0 +34,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