From cafd19cc2d93e6739855c12a30782563950e29d0 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 KeyObject.isCryptoKey(obj) closes #38611 --- doc/api/crypto.md | 20 ++++++++++++++++++++ lib/internal/crypto/keys.js | 12 ++++++++++-- test/parallel/test-crypto-key-objects.js | 11 +++++++++++ test/parallel/test-webcrypto-keygen.js | 17 ++++++++++++++++- 4 files changed, 57 insertions(+), 3 deletions(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 9b4559473ca7e5..315501dd842aa0 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -1902,6 +1902,26 @@ const { })(); ``` +### Static method: `KeyObject.isCryptoKey(obj)` + + +* `obj` {Object} +* Returns: {boolean} + +Returns `true` if `obj` is a `CryptoKey`, `false` otherwise. + +### Static method: `KeyObject.isKeyObject(obj)` + + +* `obj` {Object} +* Returns: {boolean} + +Returns `true` if `obj` is a `KeyObject`, `false` otherwise. + ### `keyObject.asymmetricKeyDetails`