Skip to content

Commit 152425a

Browse files
fix(NODE-5355): prevent error when saslprep is not a function (#3733)
1 parent 1595140 commit 152425a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/core/auth/scram.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ScramSHA extends AuthProvider {
2525

2626
prepare(handshakeDoc, authContext, callback) {
2727
const cryptoMethod = this.cryptoMethod;
28-
if (cryptoMethod === 'sha256' && saslprep == null) {
28+
if (cryptoMethod === 'sha256' && typeof saslprep !== 'function') {
2929
emitWarningOnce('Warning: no saslprep library specified. Passwords will not be sanitized');
3030
}
3131

@@ -125,7 +125,7 @@ function continueScramConversation(cryptoMethod, response, authContext, callback
125125

126126
let processedPassword;
127127
if (cryptoMethod === 'sha256') {
128-
processedPassword = saslprep ? saslprep(password) : password;
128+
processedPassword = typeof saslprep === 'function' ? saslprep(password) : password;
129129
} else {
130130
try {
131131
processedPassword = passwordDigest(username, password);

0 commit comments

Comments
 (0)