Add compatibility with other Linked Signature algorithms

This commit is contained in:
Chocobozzz 2018-10-23 11:38:48 +02:00
parent b83b8dd5ae
commit df66d81583
No known key found for this signature in database
GPG key ID: 583A612D890159BE
28 changed files with 1012 additions and 22 deletions

View file

@ -38,15 +38,20 @@ async function buildSignedRequestOptions (payload: Payload) {
}
}
function buildGlobalHeaders (body: object) {
const digest = 'SHA-256=' + sha256(JSON.stringify(body), 'base64')
function buildGlobalHeaders (body: any) {
return {
'Digest': digest
'Digest': buildDigest(body)
}
}
function buildDigest (body: any) {
const rawBody = typeof body === 'string' ? body : JSON.stringify(body)
return 'SHA-256=' + sha256(rawBody, 'base64')
}
export {
buildDigest,
buildGlobalHeaders,
computeBody,
buildSignedRequestOptions