Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(NODE-5355): prevent error when saslprep is not a function #3733

Merged
merged 2 commits into from
Jun 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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