From 7123a00b03a908621255dc35f8d75c112901a42c Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Mon, 31 Jan 2022 23:23:15 +0100 Subject: [PATCH] crypto: fix `webcrypto.subtle` signature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/41761 Reviewed-By: Mestery Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Filip Skokan Reviewed-By: Tobias Nießen Reviewed-By: Luigi Pinca --- lib/internal/crypto/webcrypto.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/internal/crypto/webcrypto.js b/lib/internal/crypto/webcrypto.js index 501ea38fd35104..72499d27ab854a 100644 --- a/lib/internal/crypto/webcrypto.js +++ b/lib/internal/crypto/webcrypto.js @@ -5,6 +5,7 @@ const { JSONParse, JSONStringify, ObjectDefineProperties, + ObjectGetOwnPropertyDescriptor, SafeSet, SymbolToStringTag, StringPrototypeRepeat, @@ -687,7 +688,11 @@ async function decrypt(algorithm, key, data) { class SubtleCrypto {} const subtle = new SubtleCrypto(); -class Crypto {} +class Crypto { + get subtle() { + return subtle; + } +} const crypto = new Crypto(); ObjectDefineProperties( @@ -699,9 +704,8 @@ ObjectDefineProperties( value: 'Crypto', }, subtle: { + ...ObjectGetOwnPropertyDescriptor(Crypto.prototype, 'subtle'), enumerable: true, - configurable: false, - value: subtle, }, getRandomValues: { enumerable: true,