From c3082489a4a86753582e76570db3c839658dc4f6 Mon Sep 17 00:00:00 2001 From: CK Ng Date: Sat, 11 Nov 2023 20:09:44 +0800 Subject: [PATCH] fix(lib): replace deprecated buf.slice() to buf. subarray() The buf.slice() method in Buffer class is deprecated in Node.js since `v16.15.0.`. Refs: https://nodejs.org/api/buffer.html#bufslicestart-end --- lib/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 84f81a1e..c2e96d5f 100644 --- a/lib/main.js +++ b/lib/main.js @@ -237,9 +237,9 @@ function decrypt (encrypted, keyStr) { const key = Buffer.from(keyStr.slice(-64), 'hex') let ciphertext = Buffer.from(encrypted, 'base64') - const nonce = ciphertext.slice(0, 12) - const authTag = ciphertext.slice(-16) - ciphertext = ciphertext.slice(12, -16) + const nonce = ciphertext.subarray(0, 12) + const authTag = ciphertext.subarray(-16) + ciphertext = ciphertext.subarray(12, -16) try { const aesgcm = crypto.createDecipheriv('aes-256-gcm', key, nonce)