fix(core): OAuth1 authentication fix for Clever Cloud API (#6847)

This commit is contained in:
Michael Kret
2023-08-04 19:49:00 +03:00
committed by GitHub
parent 75be1a9c0d
commit 5ab30fdd95
2 changed files with 30 additions and 5 deletions

View File

@@ -1334,7 +1334,18 @@ export async function requestOAuth1(
},
signature_method: credentials.signatureMethod as string,
hash_function(base, key) {
const algorithm = credentials.signatureMethod === 'HMAC-SHA1' ? 'sha1' : 'sha256';
let algorithm: string;
switch (credentials.signatureMethod) {
case 'HMAC-SHA256':
algorithm = 'sha256';
break;
case 'HMAC-SHA512':
algorithm = 'sha512';
break;
default:
algorithm = 'sha1';
break;
}
return createHmac(algorithm, key).update(base).digest('base64');
},
});