X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fpeertube-crypto.ts;h=66060bde294d39137a69da2116171a5bca386bba;hb=f7bb2bb5a753b3f1a37301dcff2d58e434ecd3af;hp=bc6f1d0748cb0a78615ef396cbd9f95460593426;hpb=a786d8a08bf99f339bf16808f46e160404497ae2;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/peertube-crypto.ts b/server/helpers/peertube-crypto.ts index bc6f1d074..66060bde2 100644 --- a/server/helpers/peertube-crypto.ts +++ b/server/helpers/peertube-crypto.ts @@ -1,16 +1,16 @@ +import { compare, genSalt, hash } from 'bcrypt' +import { createSign, createVerify } from 'crypto' import { Request } from 'express' +import { cloneDeep } from 'lodash' import { BCRYPT_SALT_SIZE, HTTP_SIGNATURE, PRIVATE_RSA_KEY_SIZE } from '../initializers/constants' +import { MActor } from '../types/models' import { createPrivateKey, getPublicKey, promisify1, promisify2, sha256 } 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(bcrypt.compare) -const bcryptGenSaltPromise = promisify1(bcrypt.genSalt) -const bcryptHashPromise = promisify2(bcrypt.hash) +const bcryptComparePromise = promisify2(compare) +const bcryptGenSaltPromise = promisify1(genSalt) +const bcryptHashPromise = promisify2(hash) const httpSignature = require('http-signature') @@ -129,7 +129,7 @@ export { // --------------------------------------------------------------------------- -function hash (obj: any): Promise { +function hashObject (obj: any): Promise { return jsonld.promises .normalize(obj, { algorithm: 'URDNA2015', @@ -151,12 +151,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) }