@@ -236,25 +236,6 @@ function* entriesFromString(value: string) {
236236 }
237237}
238238
239- function * parseAuthMechanismParameters ( stringValue : string ) {
240- const validKeys = [
241- 'SERVICE_NAME' ,
242- 'SERVICE_REALM' ,
243- 'CANONICALIZE_HOST_NAME' ,
244- 'AWS_SESSION_TOKEN'
245- ] ;
246-
247- for ( const [ key , value ] of entriesFromString ( stringValue ) ) {
248- if ( validKeys . includes ( key ) ) {
249- if ( key === 'CANONICALIZE_HOST_NAME' ) {
250- yield [ key , getBoolean ( key , value ) ] ;
251- } else {
252- yield [ key , value ] ;
253- }
254- }
255- }
256- }
257-
258239class CaseInsensitiveMap < Value = any > extends Map < string , Value > {
259240 constructor ( entries : Array < [ string , any ] > = [ ] ) {
260241 super ( entries . map ( ( [ k , v ] ) => [ k . toLowerCase ( ) , v ] ) ) ;
@@ -652,7 +633,26 @@ export const OPTIONS = {
652633 target : 'credentials' ,
653634 transform ( { options, values : [ value ] } ) : MongoCredentials {
654635 if ( typeof value === 'string' ) {
655- value = Object . fromEntries ( parseAuthMechanismParameters ( value ) ) ;
636+ const validKeys = [
637+ 'SERVICE_NAME' ,
638+ 'SERVICE_REALM' ,
639+ 'CANONICALIZE_HOST_NAME' ,
640+ 'AWS_SESSION_TOKEN'
641+ ] ;
642+
643+ const properties = Object . create ( null ) ;
644+
645+ for ( const [ key , _value ] of entriesFromString ( value ) ) {
646+ if ( validKeys . includes ( key ) ) {
647+ if ( key === 'CANONICALIZE_HOST_NAME' ) {
648+ properties [ key ] = getBoolean ( key , _value ) ;
649+ } else {
650+ properties [ key ] = _value ;
651+ }
652+ }
653+ }
654+
655+ value = properties ;
656656 }
657657 if ( ! isRecord ( value ) ) {
658658 throw new MongoParseError ( 'AuthMechanismProperties must be an object' ) ;
0 commit comments