diff options
author | Chocobozzz <me@florianbigard.com> | 2020-04-23 09:32:53 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-05-04 16:21:39 +0200 |
commit | 8dc8a34ee8428e7657414115d1c137592efa174d (patch) | |
tree | e9b5ef0d7446d1b7766eac18da5a759edc7a9040 /server/helpers/peertube-crypto.ts | |
parent | 7fed637506043e4432cbebe041ada0625171cceb (diff) | |
download | PeerTube-8dc8a34ee8428e7657414115d1c137592efa174d.tar.gz PeerTube-8dc8a34ee8428e7657414115d1c137592efa174d.tar.zst PeerTube-8dc8a34ee8428e7657414115d1c137592efa174d.zip |
Avoir some circular dependencies
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, |