@@ -4,7 +4,7 @@ import { resolveSRVRecord } from '../connection_string';
44import { emitDeprecationWarning , Callback } from '../utils' ;
55import { CMAP_EVENT_NAMES } from '../cmap/events' ;
66import * as BSON from '../bson' ;
7- import type { MongoClient , MongoOptions } from '../mongo_client' ;
7+ import type { MongoClient , MongoOptions , MongoClientOptions } from '../mongo_client' ;
88import { Connection } from '../cmap/connection' ;
99import { Server } from '../sdam/server' ;
1010import type { AutoEncrypter } from '../deps' ;
@@ -114,8 +114,11 @@ function registerDeprecatedEventNotifiers(client: MongoClient) {
114114 * returns undefined if CSFLE is not enabled.
115115 * @throws if optional 'mongodb-client-encryption' dependency missing
116116 */
117- export function createAutoEncrypter ( client : MongoClient ) : AutoEncrypter | undefined {
118- if ( ! client . options . autoEncryption ) {
117+ export function createAutoEncrypter (
118+ client : MongoClient ,
119+ options : MongoClientOptions
120+ ) : AutoEncrypter | undefined {
121+ if ( ! options . autoEncryption ) {
119122 return ;
120123 }
121124 try {
@@ -135,10 +138,12 @@ export function createAutoEncrypter(client: MongoClient): AutoEncrypter | undefi
135138 'Please make sure you are loading the correct version of `mongodb-client-encryption`'
136139 ) ;
137140 }
138- // eslint-disable-next-line @typescript-eslint/no-var-requires
139- const { AutoEncrypterClass } = mongodbClientEncryption . extension ( require ( '../../lib/index' ) ) ;
141+ const { AutoEncrypter : AutoEncrypterClass } = mongodbClientEncryption . extension (
142+ // eslint-disable-next-line @typescript-eslint/no-var-requires
143+ require ( '../../lib/index' )
144+ ) ;
140145
141- const mongoCryptOptions = Object . assign ( { bson : BSON } , client . options . autoEncryption ) ;
146+ const mongoCryptOptions = Object . assign ( { bson : BSON } , options . autoEncryption ) ;
142147 return new AutoEncrypterClass ( client , mongoCryptOptions ) ;
143148}
144149
0 commit comments