From 96301e1137d46e3c6699cae7950373e22f5cdae8 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Mon, 10 May 2021 12:33:11 +0200 Subject: [PATCH] crypto: expose KeyObject.isKeyObject(obj) and CryptoKey.isCryptoKey(obj) closes #38611 --- doc/api/crypto.md | 10 ++++++++++ doc/api/webcrypto.md | 12 ++++++++++++ lib/internal/crypto/keys.js | 12 ++++++++++-- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 9b4559473ca7e5..285232f4fe42e4 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -1852,6 +1852,16 @@ passing keys as strings or `Buffer`s due to improved security features. The receiver obtains a cloned `KeyObject`, and the `KeyObject` does not need to be listed in the `transferList` argument. +### Static method: `KeyObject.isKeyObject(obj)` + + +* `obj` {Object} +* Returns: {boolean} + +Returns `true` if `obj` is a `KeyObject`, `false` otherwise. + ### Static method: `KeyObject.from(key)` +### Static method: `CryptoKey.isCryptoKey(obj)` + + +* `obj` {Object} +* Returns: {boolean} + +Returns `true` if `obj` is a `CryptoKey`, `false` otherwise. This method +is specific to Node.js, it is not portable to other implementations of +[Web Crypto API][]. + ### `cryptoKey.algorithm`