diff options
Diffstat (limited to 'lib/internal/crypto/keys.js')
-rw-r--r-- | lib/internal/crypto/keys.js | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/lib/internal/crypto/keys.js b/lib/internal/crypto/keys.js index 087cef014f0..c0a133d5d42 100644 --- a/lib/internal/crypto/keys.js +++ b/lib/internal/crypto/keys.js @@ -277,14 +277,13 @@ function prepareAsymmetricKey(key, ctx) { const isPublic = (ctx === kConsumePrivate || ctx === kCreatePrivate) ? false : undefined; return { data, ...parseKeyEncoding(key, undefined, isPublic) }; - } else { - throw new ERR_INVALID_ARG_TYPE( - 'key', - ['string', 'Buffer', 'TypedArray', 'DataView', - ...(ctx !== kCreatePrivate ? ['KeyObject'] : [])], - key - ); } + throw new ERR_INVALID_ARG_TYPE( + 'key', + ['string', 'Buffer', 'TypedArray', 'DataView', + ...(ctx !== kCreatePrivate ? ['KeyObject'] : [])], + key + ); } function preparePrivateKey(key) { @@ -301,13 +300,12 @@ function prepareSecretKey(key, bufferOnly = false) { if (key.type !== 'secret') throw new ERR_CRYPTO_INVALID_KEY_OBJECT_TYPE(key.type, 'secret'); return key[kHandle]; - } else { - throw new ERR_INVALID_ARG_TYPE( - 'key', - ['Buffer', 'TypedArray', 'DataView', - ...(bufferOnly ? [] : ['string', 'KeyObject'])], - key); } + throw new ERR_INVALID_ARG_TYPE( + 'key', + ['Buffer', 'TypedArray', 'DataView', + ...(bufferOnly ? [] : ['string', 'KeyObject'])], + key); } return key; } |