From 152425a366f744490206e596e7b2ada37796577c Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Tue, 20 Jun 2023 13:43:22 -0600 Subject: [PATCH] fix(NODE-5355): prevent error when saslprep is not a function (#3733) --- lib/core/auth/scram.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/core/auth/scram.js b/lib/core/auth/scram.js index 2d1787810c..e561b32336 100644 --- a/lib/core/auth/scram.js +++ b/lib/core/auth/scram.js @@ -25,7 +25,7 @@ class ScramSHA extends AuthProvider { prepare(handshakeDoc, authContext, callback) { const cryptoMethod = this.cryptoMethod; - if (cryptoMethod === 'sha256' && saslprep == null) { + if (cryptoMethod === 'sha256' && typeof saslprep !== 'function') { emitWarningOnce('Warning: no saslprep library specified. Passwords will not be sanitized'); } @@ -125,7 +125,7 @@ function continueScramConversation(cryptoMethod, response, authContext, callback let processedPassword; if (cryptoMethod === 'sha256') { - processedPassword = saslprep ? saslprep(password) : password; + processedPassword = typeof saslprep === 'function' ? saslprep(password) : password; } else { try { processedPassword = passwordDigest(username, password);