From 2d7c61c83df66b3f7802f1ce53306ea516f71fd8 Mon Sep 17 00:00:00 2001 From: Ritorna Date: Thu, 7 Dec 2017 17:03:09 +0100 Subject: [PATCH] Added WordArray to Hash type Definition Added the WordArray type to the Hash type. var kDate = Crypto.HmacSHA256(dateStamp, "AWS4" + key); var kRegion = Crypto.HmacSHA256(regionName, kDate); <=== Issue because kDate is typeof WordArray and not string as the key should be supposed to. With adding the WordArray type the Hashing Procedure works fine (when using the toString it doesn't work correctly there). Sample for JS from Amazon: https://docs.aws.amazon.com/de_de/general/latest/gr/signature-v4-examples.html#signature-v4-examples-javascript --- types/crypto-js/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/crypto-js/index.d.ts b/types/crypto-js/index.d.ts index c3dad4637b..c066204df2 100644 --- a/types/crypto-js/index.d.ts +++ b/types/crypto-js/index.d.ts @@ -8,7 +8,7 @@ export as namespace CryptoJS; declare var CryptoJS: CryptoJS.Hashes; declare namespace CryptoJS { - type Hash = (message: string | LibWordArray, key?: string, ...options: any[]) => WordArray; + type Hash = (message: string | LibWordArray, key?: string | WordArray, ...options: any[]) => WordArray; interface Cipher { encrypt(message: string, secretPassphrase: string | WordArray, option?: CipherOption): WordArray; decrypt(encryptedMessage: string | WordArray, secretPassphrase: string | WordArray, option?: CipherOption): DecryptedMessage;