aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/peertube-crypto.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-08-27 14:32:44 +0200
committerChocobozzz <me@florianbigard.com>2021-08-27 15:12:22 +0200
commit41fb13c330de629df2d23379209e79c7af0f2e9a (patch)
tree73bc5a90566406b3910f142beae2a879c1e4265d /server/helpers/peertube-crypto.ts
parent40e7ed0714f96c01e16de3ac971a4b28116294e1 (diff)
downloadPeerTube-41fb13c330de629df2d23379209e79c7af0f2e9a.tar.gz
PeerTube-41fb13c330de629df2d23379209e79c7af0f2e9a.tar.zst
PeerTube-41fb13c330de629df2d23379209e79c7af0f2e9a.zip
esModuleInterop to true
Diffstat (limited to 'server/helpers/peertube-crypto.ts')
-rw-r--r--server/helpers/peertube-crypto.ts20
1 files changed, 10 insertions, 10 deletions
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 @@
1import { compare, genSalt, hash } from 'bcrypt'
2import { createSign, createVerify } from 'crypto'
1import { Request } from 'express' 3import { Request } from 'express'
4import { cloneDeep } from 'lodash'
2import { BCRYPT_SALT_SIZE, HTTP_SIGNATURE, PRIVATE_RSA_KEY_SIZE } from '../initializers/constants' 5import { BCRYPT_SALT_SIZE, HTTP_SIGNATURE, PRIVATE_RSA_KEY_SIZE } from '../initializers/constants'
6import { MActor } from '../types/models'
3import { createPrivateKey, getPublicKey, promisify1, promisify2, sha256 } from './core-utils' 7import { createPrivateKey, getPublicKey, promisify1, promisify2, sha256 } from './core-utils'
4import { jsonld } from './custom-jsonld-signature' 8import { jsonld } from './custom-jsonld-signature'
5import { logger } from './logger' 9import { logger } from './logger'
6import { cloneDeep } from 'lodash'
7import { createSign, createVerify } from 'crypto'
8import * as bcrypt from 'bcrypt'
9import { MActor } from '../types/models'
10 10
11const bcryptComparePromise = promisify2<any, string, boolean>(bcrypt.compare) 11const bcryptComparePromise = promisify2<any, string, boolean>(compare)
12const bcryptGenSaltPromise = promisify1<number, string>(bcrypt.genSalt) 12const bcryptGenSaltPromise = promisify1<number, string>(genSalt)
13const bcryptHashPromise = promisify2<any, string | number, string>(bcrypt.hash) 13const bcryptHashPromise = promisify2<any, string | number, string>(hash)
14 14
15const httpSignature = require('http-signature') 15const httpSignature = require('http-signature')
16 16
@@ -129,7 +129,7 @@ export {
129 129
130// --------------------------------------------------------------------------- 130// ---------------------------------------------------------------------------
131 131
132function hash (obj: any): Promise<any> { 132function hashObject (obj: any): Promise<any> {
133 return jsonld.promises 133 return jsonld.promises
134 .normalize(obj, { 134 .normalize(obj, {
135 algorithm: 'URDNA2015', 135 algorithm: 'URDNA2015',
@@ -151,12 +151,12 @@ function createSignatureHash (signature: any) {
151 delete signatureCopy.id 151 delete signatureCopy.id
152 delete signatureCopy.signatureValue 152 delete signatureCopy.signatureValue
153 153
154 return hash(signatureCopy) 154 return hashObject(signatureCopy)
155} 155}
156 156
157function createDocWithoutSignatureHash (doc: any) { 157function createDocWithoutSignatureHash (doc: any) {
158 const docWithoutSignature = cloneDeep(doc) 158 const docWithoutSignature = cloneDeep(doc)
159 delete docWithoutSignature.signature 159 delete docWithoutSignature.signature
160 160
161 return hash(docWithoutSignature) 161 return hashObject(docWithoutSignature)
162} 162}