From 8884141c3f08a04ff3315555c62d120c7647efbe Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Sun, 3 Oct 2021 18:54:46 +0530 Subject: fix(ext/crypto): missing Aes key typings (#12307) --- cli/tests/unit/webcrypto_test.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'cli') diff --git a/cli/tests/unit/webcrypto_test.ts b/cli/tests/unit/webcrypto_test.ts index 493cf9517..1c4788f87 100644 --- a/cli/tests/unit/webcrypto_test.ts +++ b/cli/tests/unit/webcrypto_test.ts @@ -536,3 +536,24 @@ unitTest(async function testWrapKey() { assert(wrappedKey instanceof ArrayBuffer); assertEquals(wrappedKey.byteLength, 512); }); + +// Doesn't need to cover all cases. +// Only for testing types. +unitTest(async function testAesKeyGen() { + const key = await crypto.subtle.generateKey( + { + name: "AES-GCM", + length: 256, + }, + true, + ["encrypt", "decrypt"], + ); + + assert(key); + assertEquals(key.type, "secret"); + assertEquals(key.extractable, true); + assertEquals(key.usages, ["encrypt", "decrypt"]); + const algorithm = key.algorithm as AesKeyAlgorithm; + assertEquals(algorithm.name, "AES-GCM"); + assertEquals(algorithm.length, 256); +}); -- cgit v1.2.3