@@ -16,7 +16,6 @@ import {
1616 MongoRuntimeError ,
1717 needsRetryableWriteLabel
1818} from '../error' ;
19- import { type MongoClientAuthProviders } from '../mongo_client_auth_providers' ;
2019import { HostAddress , ns , promiseWithResolvers } from '../utils' ;
2120import { AuthContext } from './auth/auth_provider' ;
2221import { AuthMechanism } from './auth/providers' ;
@@ -102,7 +101,7 @@ export async function performInitialHandshake(
102101 const authContext = new AuthContext ( conn , credentials , options ) ;
103102 conn . authContext = authContext ;
104103
105- const handshakeDoc = await prepareHandshakeDocument ( authContext , options . authProviders ) ;
104+ const handshakeDoc = await prepareHandshakeDocument ( authContext ) ;
106105
107106 // @ts -expect-error: TODO(NODE-5141): The options need to be filtered properly, Connection options differ from Command options
108107 const handshakeOptions : CommandOptions = { ...options } ;
@@ -196,8 +195,7 @@ export interface HandshakeDocument extends Document {
196195 * This function is only exposed for testing purposes.
197196 */
198197export async function prepareHandshakeDocument (
199- authContext : AuthContext ,
200- authProviders : MongoClientAuthProviders
198+ authContext : AuthContext
201199) : Promise < HandshakeDocument > {
202200 const options = authContext . options ;
203201 const compressors = options . compressors ? options . compressors : [ ] ;
@@ -219,7 +217,9 @@ export async function prepareHandshakeDocument(
219217 if ( credentials . mechanism === AuthMechanism . MONGODB_DEFAULT && credentials . username ) {
220218 handshakeDoc . saslSupportedMechs = `${ credentials . source } .${ credentials . username } ` ;
221219
222- const provider = authProviders . getOrCreateProvider ( AuthMechanism . MONGODB_SCRAM_SHA256 ) ;
220+ const provider = authContext . options . authProviders . getOrCreateProvider (
221+ AuthMechanism . MONGODB_SCRAM_SHA256
222+ ) ;
223223 if ( ! provider ) {
224224 // This auth mechanism is always present.
225225 throw new MongoInvalidArgumentError (
@@ -228,7 +228,7 @@ export async function prepareHandshakeDocument(
228228 }
229229 return provider . prepare ( handshakeDoc , authContext ) ;
230230 }
231- const provider = authProviders . getOrCreateProvider ( credentials . mechanism ) ;
231+ const provider = authContext . options . authProviders . getOrCreateProvider ( credentials . mechanism ) ;
232232 if ( ! provider ) {
233233 throw new MongoInvalidArgumentError ( `No AuthProvider for ${ credentials . mechanism } defined.` ) ;
234234 }
0 commit comments