@@ -29,7 +29,6 @@ import { ReadConcern, ReadConcernLevel } from './read_concern';
2929import { ReadPreference , ReadPreferenceMode } from './read_preference' ;
3030import type { TagSet } from './sdam/server_description' ;
3131import {
32- AnyOptions ,
3332 DEFAULT_PK_FACTORY ,
3433 emitWarning ,
3534 emitWarningOnce ,
@@ -157,14 +156,14 @@ export async function resolveSRVRecord(options: MongoOptions): Promise<HostAddre
157156/**
158157 * Checks if TLS options are valid
159158 *
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
162161 */
163- export function checkTLSOptions ( options : AnyOptions ) : void {
164- if ( ! options ) return ;
162+ function checkTLSOptions ( allOptions : CaseInsensitiveMap ) : void {
163+ if ( ! allOptions ) return ;
165164 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 ` ) ;
168167 }
169168 } ;
170169 check ( 'tlsInsecure' , 'tlsAllowInvalidCertificates' ) ;
@@ -360,6 +359,8 @@ export function parseOptions(
360359 }
361360 }
362361
362+ checkTLSOptions ( allOptions ) ;
363+
363364 const unsupportedOptions = setDifference (
364365 allKeys ,
365366 Array . from ( Object . keys ( OPTIONS ) ) . map ( s => s . toLowerCase ( ) )
@@ -427,8 +428,6 @@ export function parseOptions(
427428 mongoOptions . dbName = 'test' ;
428429 }
429430
430- checkTLSOptions ( mongoOptions ) ;
431-
432431 if ( options . promiseLibrary ) {
433432 PromiseProvider . set ( options . promiseLibrary ) ;
434433 }
0 commit comments