@orbiting/backend-modules-assets
Advanced tools
Comparing version 1.1.0 to 2.0.0
@@ -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) |
@@ -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 @@ }, |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
24551
21
695
1
50
8
8
5
+ Addedaws-sdk@^2.185.0
+ Addedfile-type-stream@^1.0.0
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedaws-sdk@2.1692.0(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbuffer@4.9.2(transitive)
+ Addedcall-bind@1.0.8(transitive)
+ Addedcall-bind-apply-helpers@1.0.1(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.1.1(transitive)
+ Addedevents@1.1.1(transitive)
+ Addedfile-type@3.9.0(transitive)
+ Addedfile-type-stream@1.0.0(transitive)
+ Addedfor-each@0.3.4(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.7(transitive)
+ Addedget-proto@1.0.1(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedieee754@1.1.13(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedis-arguments@1.2.0(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-generator-function@1.1.0(transitive)
+ Addedis-regex@1.2.1(transitive)
+ Addedis-typed-array@1.1.15(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedjmespath@0.16.0(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addedpossible-typed-array-names@1.0.0(transitive)
+ Addedpunycode@1.3.2(transitive)
+ Addedquerystring@0.2.0(transitive)
+ Addedsafe-regex-test@1.1.0(transitive)
+ Addedsax@1.2.1(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedurl@0.10.3(transitive)
+ Addedutil@0.12.5(transitive)
+ Addeduuid@8.0.0(transitive)
+ Addedwhich-typed-array@1.1.18(transitive)
+ Addedxml2js@0.6.2(transitive)
+ Addedxmlbuilder@11.0.1(transitive)
- Removedfile-type@^7.4.0
- Removedfile-type@7.7.1(transitive)