Skip to content

Commit

Permalink
fix(NODE-5355): prevent error when saslprep is not a function (#3733)
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson authored Jun 20, 2023
1 parent 1595140 commit 152425a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/core/auth/scram.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 152425a

Please # to comment.