@@ -4,7 +4,7 @@ import { resolveSRVRecord } from '../connection_string';
4
4
import { emitDeprecationWarning , Callback } from '../utils' ;
5
5
import { CMAP_EVENT_NAMES } from '../cmap/events' ;
6
6
import * as BSON from '../bson' ;
7
- import type { MongoClient , MongoOptions } from '../mongo_client' ;
7
+ import type { MongoClient , MongoOptions , MongoClientOptions } from '../mongo_client' ;
8
8
import { Connection } from '../cmap/connection' ;
9
9
import { Server } from '../sdam/server' ;
10
10
import type { AutoEncrypter } from '../deps' ;
@@ -114,8 +114,11 @@ function registerDeprecatedEventNotifiers(client: MongoClient) {
114
114
* returns undefined if CSFLE is not enabled.
115
115
* @throws if optional 'mongodb-client-encryption' dependency missing
116
116
*/
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 ) {
119
122
return ;
120
123
}
121
124
try {
@@ -135,10 +138,12 @@ export function createAutoEncrypter(client: MongoClient): AutoEncrypter | undefi
135
138
'Please make sure you are loading the correct version of `mongodb-client-encryption`'
136
139
) ;
137
140
}
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
+ ) ;
140
145
141
- const mongoCryptOptions = Object . assign ( { bson : BSON } , client . options . autoEncryption ) ;
146
+ const mongoCryptOptions = Object . assign ( { bson : BSON } , options . autoEncryption ) ;
142
147
return new AutoEncrypterClass ( client , mongoCryptOptions ) ;
143
148
}
144
149
0 commit comments