]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/peertube-crypto.ts
Remove exif tags when processing images
[github/Chocobozzz/PeerTube.git] / server / helpers / peertube-crypto.ts
index bc6f1d0748cb0a78615ef396cbd9f95460593426..b8f7c782ae7b88ba88463d14f156d43d65a9dec1 100644 (file)
@@ -1,18 +1,19 @@
+import { compare, genSalt, hash } from 'bcrypt'
+import { createSign, createVerify } from 'crypto'
 import { Request } from 'express'
+import { cloneDeep } from 'lodash'
+import { sha256 } from '@shared/extra-utils'
 import { BCRYPT_SALT_SIZE, HTTP_SIGNATURE, PRIVATE_RSA_KEY_SIZE } from '../initializers/constants'
-import { createPrivateKey, getPublicKey, promisify1, promisify2, sha256 } from './core-utils'
+import { MActor } from '../types/models'
+import { createPrivateKey, getPublicKey, promisify1, promisify2 } from './core-utils'
 import { jsonld } from './custom-jsonld-signature'
 import { logger } from './logger'
-import { cloneDeep } from 'lodash'
-import { createSign, createVerify } from 'crypto'
-import * as bcrypt from 'bcrypt'
-import { MActor } from '../types/models'
 
-const bcryptComparePromise = promisify2<any, string, boolean>(bcrypt.compare)
-const bcryptGenSaltPromise = promisify1<number, string>(bcrypt.genSalt)
-const bcryptHashPromise = promisify2<any, string | number, string>(bcrypt.hash)
+const bcryptComparePromise = promisify2<any, string, boolean>(compare)
+const bcryptGenSaltPromise = promisify1<number, string>(genSalt)
+const bcryptHashPromise = promisify2<any, string | number, string>(hash)
 
-const httpSignature = require('http-signature')
+const httpSignature = require('@peertube/http-signature')
 
 async function createPrivateAndPublicKeys () {
   logger.info('Generating a RSA key...')
@@ -129,7 +130,7 @@ export {
 
 // ---------------------------------------------------------------------------
 
-function hash (obj: any): Promise<any> {
+function hashObject (obj: any): Promise<any> {
   return jsonld.promises
                .normalize(obj, {
                  algorithm: 'URDNA2015',
@@ -151,12 +152,12 @@ function createSignatureHash (signature: any) {
   delete signatureCopy.id
   delete signatureCopy.signatureValue
 
-  return hash(signatureCopy)
+  return hashObject(signatureCopy)
 }
 
 function createDocWithoutSignatureHash (doc: any) {
   const docWithoutSignature = cloneDeep(doc)
   delete docWithoutSignature.signature
 
-  return hash(docWithoutSignature)
+  return hashObject(docWithoutSignature)
 }