From 5ee211017912bc0837cbce3b845e6ab4a7887885 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Sun, 29 Aug 2021 17:53:51 +0530 Subject: feat(ext/crypto): support JWK export for HMAC (#11864) --- cli/tests/unit/webcrypto_test.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'cli') diff --git a/cli/tests/unit/webcrypto_test.ts b/cli/tests/unit/webcrypto_test.ts index a37e32eba..475efde6c 100644 --- a/cli/tests/unit/webcrypto_test.ts +++ b/cli/tests/unit/webcrypto_test.ts @@ -254,6 +254,8 @@ const jwk: JsonWebKey = { // unpadded base64 for rawKey. k: "AQIDBAUGBwgJCgsMDQ4PEA", alg: "HS256", + ext: true, + "key_ops": ["sign"], }; unitTest(async function subtleCryptoHmacImportExport() { @@ -297,7 +299,10 @@ unitTest(async function subtleCryptoHmacImportExport() { new Uint8Array(actual2), expected, ); - // TODO(@littledivy): Add a test for exporting JWK key when supported. - const exportedKey = await crypto.subtle.exportKey("raw", key1); - assertEquals(new Uint8Array(exportedKey), rawKey); + + const exportedKey1 = await crypto.subtle.exportKey("raw", key1); + assertEquals(new Uint8Array(exportedKey1), rawKey); + + const exportedKey2 = await crypto.subtle.exportKey("jwk", key2); + assertEquals(exportedKey2, jwk); }); -- cgit v1.2.3