@@ -29,7 +29,6 @@ import { ReadConcern, ReadConcernLevel } from './read_concern';
29
29
import { ReadPreference , ReadPreferenceMode } from './read_preference' ;
30
30
import type { TagSet } from './sdam/server_description' ;
31
31
import {
32
- AnyOptions ,
33
32
DEFAULT_PK_FACTORY ,
34
33
emitWarning ,
35
34
emitWarningOnce ,
@@ -157,14 +156,14 @@ export async function resolveSRVRecord(options: MongoOptions): Promise<HostAddre
157
156
/**
158
157
* Checks if TLS options are valid
159
158
*
160
- * @param options - The options used for options parsing
161
- * @throws MongoParseError if TLS options are invalid
159
+ * @param allOptions - All options provided by user or included in default options map
160
+ * @throws MongoAPIError if TLS options are invalid
162
161
*/
163
- export function checkTLSOptions ( options : AnyOptions ) : void {
164
- if ( ! options ) return ;
162
+ function checkTLSOptions ( allOptions : CaseInsensitiveMap ) : void {
163
+ if ( ! allOptions ) return ;
165
164
const check = ( a : string , b : string ) => {
166
- if ( Reflect . has ( options , a ) && Reflect . has ( options , b ) ) {
167
- throw new MongoParseError ( `The '${ a } ' option cannot be used with '${ b } '` ) ;
165
+ if ( allOptions . has ( a ) && allOptions . has ( b ) ) {
166
+ throw new MongoAPIError ( `The '${ a } ' option cannot be used with the '${ b } ' option ` ) ;
168
167
}
169
168
} ;
170
169
check ( 'tlsInsecure' , 'tlsAllowInvalidCertificates' ) ;
@@ -360,6 +359,8 @@ export function parseOptions(
360
359
}
361
360
}
362
361
362
+ checkTLSOptions ( allOptions ) ;
363
+
363
364
const unsupportedOptions = setDifference (
364
365
allKeys ,
365
366
Array . from ( Object . keys ( OPTIONS ) ) . map ( s => s . toLowerCase ( ) )
@@ -427,8 +428,6 @@ export function parseOptions(
427
428
mongoOptions . dbName = 'test' ;
428
429
}
429
430
430
- checkTLSOptions ( mongoOptions ) ;
431
-
432
431
if ( options . promiseLibrary ) {
433
432
PromiseProvider . set ( options . promiseLibrary ) ;
434
433
}
0 commit comments