From d62fe315c2e592d9865da81d4f43a451cde086ea Mon Sep 17 00:00:00 2001 From: James M Snell Date: Mon, 27 Dec 2021 06:48:59 -0800 Subject: [PATCH] crypto: alias webcrypto.subtle and webcrypto.getRandomValues on crypto MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The aliases allow code written to assume that `crypto.subtle` and `crypto.getRandomValues()` exist on the `crypto` global to just work. Signed-off-by: James M Snell PR-URL: https://github.com/nodejs/node/pull/41266 Reviewed-By: Filip Skokan Reviewed-By: Michaƫl Zasso Reviewed-By: Antoine du Hamel --- doc/api/crypto.md | 23 +++++++++++++++++++++++ lib/crypto.js | 24 ++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index c837c4435bdfe9..1899594504abb8 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -4051,6 +4051,17 @@ const { console.log(getHashes()); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...] ``` +### `crypto.getRandomValues(typedArray)` + + + +* `typedArray` {Buffer|TypedArray|DataView|ArrayBuffer} +* Returns: {Buffer|TypedArray|DataView|ArrayBuffer} Returns `typedArray`. + +A convenient alias for [`crypto.webcrypto.getRandomValues()`][]. + ### `crypto.hkdf(digest, ikm, salt, info, keylen, callback)` + +* Type: {SubtleCrypto} + +A convenient alias for [`crypto.webcrypto.subtle`][]. + ### `crypto.timingSafeEqual(a, b)`