diff options
Diffstat (limited to 'server/helpers/peertube-crypto.ts')
-rw-r--r-- | server/helpers/peertube-crypto.ts | 8 |
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' | |||
5 | import { logger } from './logger' | 5 | import { logger } from './logger' |
6 | import { cloneDeep } from 'lodash' | 6 | import { cloneDeep } from 'lodash' |
7 | import { createSign, createVerify } from 'crypto' | 7 | import { createSign, createVerify } from 'crypto' |
8 | import { buildDigest } from '../lib/job-queue/handlers/utils/activitypub-http-utils' | ||
9 | import * as bcrypt from 'bcrypt' | 8 | import * as bcrypt from 'bcrypt' |
10 | import { MActor } from '../typings/models' | 9 | import { 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 | ||
106 | function 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 | ||
109 | export { | 114 | export { |
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, |