-
Notifications
You must be signed in to change notification settings - Fork 26
feat!: v2.0.0 - Migrate to worker_threads architecture #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| 'use strict'; | ||
|
|
||
| const config = require('../config'); | ||
| const crypto = require('crypto'); | ||
|
|
||
| function cipherKey(name) { | ||
| return crypto.createHash('sha256') | ||
| .update(`${name}.${config.media.encryptionSeed}.key`) | ||
| .digest() | ||
| .subarray(0, 16); | ||
| } | ||
|
|
||
| function cipherIv(name) { | ||
| return crypto.createHash('sha256') | ||
| .update(`${name}.${config.media.encryptionSeed}.iv`) | ||
| .digest() | ||
| .subarray(0, 16); | ||
| } | ||
|
|
||
| function encryptChunk(name, buffer) { | ||
| let cipher = crypto.createCipheriv('aes-128-cbc', cipherKey(name), cipherIv(name)); | ||
|
gkozlenko marked this conversation as resolved.
|
||
| return Buffer.concat([cipher.update(buffer), cipher.final()]); | ||
| } | ||
|
|
||
| module.exports = { | ||
| cipherKey, | ||
| cipherIv, | ||
| encryptChunk, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,27 +19,37 @@ class NotFoundError extends HttpError { | |
|
|
||
| } | ||
|
|
||
| class ForbiddenError extends HttpError { | ||
| class RequestTimeoutError extends HttpError { | ||
|
|
||
| constructor(message) { | ||
| super(403, message); | ||
| this.name = 'ForbiddenError'; | ||
| super(408, message); | ||
| this.name = 'RequestTimeoutError'; | ||
| } | ||
|
|
||
| } | ||
|
Comment on lines
+22
to
29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
|
||
| class UnauthorizedError extends HttpError { | ||
| class InternalServerError extends HttpError { | ||
|
|
||
| constructor(message) { | ||
| super(401, message); | ||
| this.name = 'UnauthorizedError'; | ||
| super(500, message); | ||
| this.name = 'InternalServerError'; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| class ServiceUnavailableError extends HttpError { | ||
|
|
||
| constructor(message) { | ||
| super(503, message); | ||
| this.name = 'ServiceUnavailableError'; | ||
| } | ||
|
|
||
| } | ||
|
|
||
| module.exports = { | ||
| HttpError, | ||
| NotFoundError, | ||
| ForbiddenError, | ||
| UnauthorizedError, | ||
| RequestTimeoutError, | ||
| InternalServerError, | ||
| ServiceUnavailableError, | ||
| }; | ||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.