aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/peertube-crypto.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/peertube-crypto.ts')
-rw-r--r--server/helpers/peertube-crypto.ts8
1 files changed, 7 insertions, 1 deletions
diff --git a/server/helpers/peertube-crypto.ts b/server/helpers/peertube-crypto.ts
index 89c0ab151..394e97fd5 100644
--- a/server/helpers/peertube-crypto.ts
+++ b/server/helpers/peertube-crypto.ts
@@ -5,7 +5,6 @@ import { jsonld } from './custom-jsonld-signature'
5import { logger } from './logger' 5import { logger } from './logger'
6import { cloneDeep } from 'lodash' 6import { cloneDeep } from 'lodash'
7import { createSign, createVerify } from 'crypto' 7import { createSign, createVerify } from 'crypto'
8import { buildDigest } from '../lib/job-queue/handlers/utils/activitypub-http-utils'
9import * as bcrypt from 'bcrypt' 8import * as bcrypt from 'bcrypt'
10import { MActor } from '../typings/models' 9import { MActor } from '../typings/models'
11 10
@@ -104,12 +103,19 @@ async function signJsonLDObject (byActor: MActor, data: any) {
104 return Object.assign(data, { signature }) 103 return Object.assign(data, { signature })
105} 104}
106 105
106function buildDigest (body: any) {
107 const rawBody = typeof body === 'string' ? body : JSON.stringify(body)
108
109 return 'SHA-256=' + sha256(rawBody, 'base64')
110}
111
107// --------------------------------------------------------------------------- 112// ---------------------------------------------------------------------------
108 113
109export { 114export {
110 isHTTPSignatureDigestValid, 115 isHTTPSignatureDigestValid,
111 parseHTTPSignature, 116 parseHTTPSignature,
112 isHTTPSignatureVerified, 117 isHTTPSignatureVerified,
118 buildDigest,
113 isJsonLDSignatureVerified, 119 isJsonLDSignatureVerified,
114 comparePassword, 120 comparePassword,
115 createPrivateAndPublicKeys, 121 createPrivateAndPublicKeys,