diff options
author | Chocobozzz <me@florianbigard.com> | 2018-10-23 11:38:48 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-11-14 16:32:27 +0100 |
commit | df66d81583e07ce049daeeef1edc6a87b57b3684 (patch) | |
tree | 2a12747cd442713807e2b7d93899bc621d303459 /server/lib/job-queue | |
parent | b83b8dd5aef03084133c5983de6f312e7d1654b8 (diff) | |
download | PeerTube-df66d81583e07ce049daeeef1edc6a87b57b3684.tar.gz PeerTube-df66d81583e07ce049daeeef1edc6a87b57b3684.tar.zst PeerTube-df66d81583e07ce049daeeef1edc6a87b57b3684.zip |
Add compatibility with other Linked Signature algorithms
Diffstat (limited to 'server/lib/job-queue')
-rw-r--r-- | server/lib/job-queue/handlers/utils/activitypub-http-utils.ts | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts b/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts index fd9c74341..4961d4502 100644 --- a/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts +++ b/server/lib/job-queue/handlers/utils/activitypub-http-utils.ts | |||
@@ -38,15 +38,20 @@ async function buildSignedRequestOptions (payload: Payload) { | |||
38 | } | 38 | } |
39 | } | 39 | } |
40 | 40 | ||
41 | function buildGlobalHeaders (body: object) { | 41 | function buildGlobalHeaders (body: any) { |
42 | const digest = 'SHA-256=' + sha256(JSON.stringify(body), 'base64') | ||
43 | |||
44 | return { | 42 | return { |
45 | 'Digest': digest | 43 | 'Digest': buildDigest(body) |
46 | } | 44 | } |
47 | } | 45 | } |
48 | 46 | ||
47 | function buildDigest (body: any) { | ||
48 | const rawBody = typeof body === 'string' ? body : JSON.stringify(body) | ||
49 | |||
50 | return 'SHA-256=' + sha256(rawBody, 'base64') | ||
51 | } | ||
52 | |||
49 | export { | 53 | export { |
54 | buildDigest, | ||
50 | buildGlobalHeaders, | 55 | buildGlobalHeaders, |
51 | computeBody, | 56 | computeBody, |
52 | buildSignedRequestOptions | 57 | buildSignedRequestOptions |