@@ -917,6 +917,7 @@ async function _setConfigParameters(obj, credential, configProvider) {
917917 configObject [ key ] = val ;
918918 }
919919 configObject . connectString = obj . connect_descriptor ;
920+ configObject . configTTL = obj . config_time_to_live ;
920921 if ( ! configObject . connectString )
921922 errors . throwErr ( errors . ERR_CONFIG_PROVIDER_FAILED_TO_RETRIEVE_CONFIG , 'connect_descriptor must be set' ) ;
922923
@@ -989,32 +990,37 @@ async function _retrieveParamValueFromVault(paramObj, credential, configProvider
989990//-----------------------------------------------------------------------------
990991// _checkConfigProvider()
991992//
992- // Look for the config provider in the connection string and retreives
993+ // Look for the config provider in the connection string and retrieves
993994// object stored in the config Provider.
994995// Returns object based on precedence between input object and the one retrieved
995996// from Config Provider.
996997//-----------------------------------------------------------------------------
997998async function _checkConfigProvider ( options ) {
998999 // Time for Cache entries to be deleted in milliseconds
999- const cacheEntriesDuration = settings . configProviderCacheTimeout * 1000 ;
1000- let secondOpts ;
1000+ let cacheEntriesDuration = settings . configProviderCacheTimeout * 1000 ;
1001+ let secondOpts , cachedConfigEntry ;
10011002 const url = options . connectString || options . connectionString ;
10021003 if ( ! url )
10031004 return options ;
10041005
1005- if ( configProviderCache && configProviderCache . has ( url ) && ( ( Date . now ( ) - configProviderCache . get ( url ) . timeAdded ) < cacheEntriesDuration ) ) {
1006- const cacheOpts1 = configProviderCache . get ( url ) . cacheOpts ;
1007- secondOpts = { ...cacheOpts1 } ;
1006+ if ( configProviderCache && ( cachedConfigEntry = configProviderCache . get ( url ) ) ) {
1007+ const config = cachedConfigEntry . cacheOpts ;
1008+ if ( config . configTTL )
1009+ cacheEntriesDuration = config . configTTL * 1000 ;
10081010
1009- //deobfuscate password
1010- if ( secondOpts . password )
1011- secondOpts . password = protocolUtil . getDeobfuscatedValue ( secondOpts . password . value , secondOpts . password . obfuscatedValue ) ;
1011+ if ( ( Date . now ( ) - cachedConfigEntry . timeAdded ) < cacheEntriesDuration ) {
1012+ secondOpts = { ...config } ;
10121013
1013- //deobfuscate walletContent
1014- if ( secondOpts . walletContent )
1015- secondOpts . walletContent = protocolUtil . getDeobfuscatedValue ( secondOpts . walletContent . value , secondOpts . walletContent . obfuscatedValue ) ;
1014+ //deobfuscate password
1015+ if ( secondOpts . password )
1016+ secondOpts . password = protocolUtil . getDeobfuscatedValue ( secondOpts . password . value , secondOpts . password . obfuscatedValue ) ;
10161017
1017- } else {
1018+ //deobfuscate walletContent
1019+ if ( secondOpts . walletContent )
1020+ secondOpts . walletContent = protocolUtil . getDeobfuscatedValue ( secondOpts . walletContent . value , secondOpts . walletContent . obfuscatedValue ) ;
1021+ }
1022+ }
1023+ if ( ! secondOpts ) {
10181024 let parsedUrl = url ;
10191025 let urlExtendedPart ;
10201026 const baseRegex = new RegExp ( "^config-(?<provider>[A-Za-z0-9]+)(://)(?<provider_arg>[^?]+)" ) ;
0 commit comments