From 428880002cdba9f64d8397bea466a438802e932a Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Tue, 3 Dec 2024 13:40:25 +0900 Subject: [PATCH] use FlattenedJWE --- jose/jwe.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jose/jwe.ts b/jose/jwe.ts index baec27b..6d5fb3d 100644 --- a/jose/jwe.ts +++ b/jose/jwe.ts @@ -1,7 +1,7 @@ import { - compactDecrypt, - CompactEncrypt, exportJWK, + flattenedDecrypt, + FlattenedEncrypt, generateKeyPair, importJWK, } from "npm:jose"; @@ -19,7 +19,7 @@ const keyToEncrypt = await generateKeyPair("ES256", { extractable: true }); const privateKeyJWK = await exportJWK(keyToEncrypt.privateKey); // encrypt -const jwe = await new CompactEncrypt( +const jwe = await new FlattenedEncrypt( new TextEncoder().encode(JSON.stringify(privateKeyJWK)), ) .setProtectedHeader({ @@ -29,7 +29,7 @@ const jwe = await new CompactEncrypt( .encrypt(encryptionKey); // decrypt -const res = await compactDecrypt(jwe, encryptionKey); +const res = await flattenedDecrypt(jwe, encryptionKey); const jwk = JSON.parse(new TextDecoder().decode(res.plaintext)); console.log({