@@ -16,11 +16,11 @@ import { type MongoClient } from './mongo_client';
1616/** @internal */
1717const AUTH_PROVIDERS = new Map <
1818 AuthMechanism | string ,
19- ( authMechanismProperties : AuthMechanismProperties ) => AuthProvider
19+ ( client : MongoClient , authMechanismProperties : AuthMechanismProperties ) => AuthProvider
2020> ( [
2121 [
2222 AuthMechanism . MONGODB_AWS ,
23- ( { AWS_CREDENTIAL_PROVIDER } ) => new MongoDBAWS ( AWS_CREDENTIAL_PROVIDER )
23+ ( _ , { AWS_CREDENTIAL_PROVIDER } ) => new MongoDBAWS ( AWS_CREDENTIAL_PROVIDER )
2424 ] ,
2525 [
2626 AuthMechanism . MONGODB_CR ,
@@ -31,7 +31,10 @@ const AUTH_PROVIDERS = new Map<
3131 }
3232 ] ,
3333 [ AuthMechanism . MONGODB_GSSAPI , ( ) => new GSSAPI ( ) ] ,
34- [ AuthMechanism . MONGODB_OIDC , properties => new MongoDBOIDC ( getWorkflow ( properties ) ) ] ,
34+ [
35+ AuthMechanism . MONGODB_OIDC ,
36+ ( client , properties ) => new MongoDBOIDC ( getWorkflow ( client , properties ) )
37+ ] ,
3538 [ AuthMechanism . MONGODB_PLAIN , ( ) => new Plain ( ) ] ,
3639 [ AuthMechanism . MONGODB_SCRAM_SHA1 , ( ) => new ScramSHA1 ( ) ] ,
3740 [ AuthMechanism . MONGODB_SCRAM_SHA256 , ( ) => new ScramSHA256 ( ) ] ,
@@ -74,7 +77,7 @@ export class MongoClientAuthProviders {
7477 throw new MongoInvalidArgumentError ( `authMechanism ${ name } not supported` ) ;
7578 }
7679
77- const provider = providerFunction ( authMechanismProperties ) ;
80+ const provider = providerFunction ( this . client , authMechanismProperties ) ;
7881 this . existingProviders . set ( name , provider ) ;
7982 return provider ;
8083 }
@@ -83,14 +86,17 @@ export class MongoClientAuthProviders {
8386/**
8487 * Gets either a device workflow or callback workflow.
8588 */
86- function getWorkflow ( authMechanismProperties : AuthMechanismProperties ) : Workflow {
89+ function getWorkflow (
90+ client : MongoClient ,
91+ authMechanismProperties : AuthMechanismProperties
92+ ) : Workflow {
8793 if ( authMechanismProperties . OIDC_HUMAN_CALLBACK ) {
8894 return new HumanCallbackWorkflow ( new TokenCache ( ) , authMechanismProperties . OIDC_HUMAN_CALLBACK ) ;
8995 } else if ( authMechanismProperties . OIDC_CALLBACK ) {
9096 return new AutomatedCallbackWorkflow ( new TokenCache ( ) , authMechanismProperties . OIDC_CALLBACK ) ;
9197 } else {
9298 const environment = authMechanismProperties . ENVIRONMENT ;
93- const workflow = OIDC_WORKFLOWS . get ( environment ) ?.( this . client ) ;
99+ const workflow = OIDC_WORKFLOWS . get ( environment ) ?.( client ) ;
94100 if ( ! workflow ) {
95101 throw new MongoInvalidArgumentError (
96102 `Could not load workflow for environment ${ authMechanismProperties . ENVIRONMENT } `
0 commit comments