@@ -59,15 +59,17 @@ export class ConfigStore {
5959 loadError : string | undefined ;
6060 usingUI : boolean ;
6161
62+ algorithmId : string ;
6263 appConfig : AppConfigData = DEFAULT_APP_CONFIG ;
6364 filePaths : ConfigStorePaths ;
64- algorithmId : string ;
65+ saltConfiguration ?: Config . FileBasedSalt | Config . StringBasedSalt ;
6566
66- constructor ( filePaths : ConfigStorePaths , algorithmId : string , usingUI : boolean = false ) {
67- this . lastUpdated = new Date ( ) ;
67+ constructor ( filePaths : ConfigStorePaths , algorithmId : string , usingUI : boolean = false , saltConfiguration ?: Config . FileBasedSalt | Config . StringBasedSalt ) {
68+ this . usingUI = usingUI ;
6869 this . filePaths = filePaths ;
70+ this . lastUpdated = new Date ( ) ;
6971 this . algorithmId = algorithmId ;
70- this . usingUI = usingUI ;
72+ this . saltConfiguration = saltConfiguration ;
7173 }
7274
7375 getConfig = ( ) => this . data ;
@@ -84,7 +86,12 @@ export class ConfigStore {
8486 this . appConfig = loadAppConfig ( this . getAppConfigFilePath ( ) ) ;
8587
8688 // attempt to load the default app config
87- const userConfigLoad = loadConfig ( { configPath : this . getConfigFilePath ( ) , algorithmId : this . getAlgorithmId ( ) } ) ;
89+ const userConfigLoad = loadConfig ( {
90+ configPath : this . getConfigFilePath ( ) ,
91+ algorithmId : this . getAlgorithmId ( ) ,
92+ embeddedSalt : this . saltConfiguration ,
93+ usingUI : true
94+ } ) ;
8895
8996 // if the load succesds we have a valid config -- use it as a
9097 // user-provided one
@@ -97,7 +104,12 @@ export class ConfigStore {
97104 log ( 'User config validation not successful - attempting to load backup config' ) ;
98105 // if the default config load failed use the backup default
99106 // from the app distribution
100- const backupConfigLoad = loadConfig ( { configPath : this . getBackupConfigFilePath ( ) , algorithmId : this . getAlgorithmId ( ) } ) ;
107+ const backupConfigLoad = loadConfig ( {
108+ configPath : this . getBackupConfigFilePath ( ) ,
109+ algorithmId : this . getAlgorithmId ( ) ,
110+ embeddedSalt : this . saltConfiguration ,
111+ usingUI : true
112+ } ) ;
101113
102114 // if the load succesds we have a valid config -- use it as
103115 // a config-from-backup
@@ -136,7 +148,12 @@ export class ConfigStore {
136148 // The config data used by the application is updated after the save
137149 updateUserConfig ( userConfigFilePath : string ) {
138150 // attempt to load & validate the config data
139- const userConfigLoad = loadConfig ( { configPath : userConfigFilePath , algorithmId : this . getAlgorithmId ( ) } ) ;
151+ const userConfigLoad = loadConfig ( {
152+ configPath : userConfigFilePath ,
153+ algorithmId : this . getAlgorithmId ( ) ,
154+ embeddedSalt : this . saltConfiguration ,
155+ usingUI : true
156+ } ) ;
140157
141158 // if failed return the error message
142159 if ( ! userConfigLoad . success ) {
@@ -168,7 +185,12 @@ export class ConfigStore {
168185 }
169186
170187 log ( '[removeUserConfig] Trying to load backup config file' ) ;
171- const backupConfigLoad = loadConfig ( { configPath : this . getBackupConfigFilePath ( ) , algorithmId : this . getAlgorithmId ( ) } ) ;
188+ const backupConfigLoad = loadConfig ( {
189+ configPath : this . getBackupConfigFilePath ( ) ,
190+ algorithmId : this . getAlgorithmId ( ) ,
191+ embeddedSalt : this . saltConfiguration ,
192+ usingUI : true
193+ } ) ;
172194
173195 // if failed return the error message (do not delete the user config yet)
174196 if ( ! backupConfigLoad . success ) {
@@ -273,7 +295,14 @@ export class ConfigStore {
273295 }
274296}
275297
276- export function makeConfigStore ( { filePaths, algorithmId, usingUI} : { filePaths : ConfigStorePaths , algorithmId : string , usingUI : boolean } ) {
298+ interface ConfigStoreInput {
299+ usingUI : boolean ;
300+ algorithmId : string ;
301+ filePaths : ConfigStorePaths ;
302+ saltConfiguration ?: Config . FileBasedSalt | Config . StringBasedSalt ;
303+ }
304+
305+ export function makeConfigStore ( { filePaths, algorithmId, usingUI, saltConfiguration } : ConfigStoreInput ) {
277306 if ( ! filePaths || ! algorithmId ) throw new Error ( `ConfigStore params MUST be provided.` ) ;
278- return new ConfigStore ( filePaths , algorithmId , usingUI ) ;
307+ return new ConfigStore ( filePaths , algorithmId , usingUI , saltConfiguration ) ;
279308}
0 commit comments