diff options
Diffstat (limited to 'server/lib')
-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 |