From 56e29768158ef40700c4133395a30cae8775f2d9 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 | 24 +++++++++++++++++++++++- test/parallel/test-webcrypto-keygen.js | 23 ++++++++++++++++++++++- 4 files changed, 75 insertions(+), 4 deletions(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 9b4559473ca7e5..a08d04ec34ef8b 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`