@@ -13,7 +13,10 @@ interface iobVendorFile {
1313 vendor ?: {
1414 id ?: string ;
1515 name ?: string ;
16+ /** Logo for login in admin */
1617 icon ?: string ;
18+ /** Logo in the top left corner of admin */
19+ logo ?: string ;
1720 admin ?: {
1821 menu ?: {
1922 // Settings for left menu
@@ -73,23 +76,23 @@ interface iobVendorFile {
7376 link ?: string ;
7477 } ;
7578 } ;
79+ /** Favicon for admin */
7680 ico ?: string ;
7781 uuidPrefix ?: string ;
7882 } ;
7983 model ?: {
80- // name for host
84+ /** name for host */
8185 name ?: string ;
82- // Icon for host
86+ /** Icon for host */
8387 icon ?: string ;
84- // Color for host
88+ /** Color for host */
8589 color ?: string ;
8690 } ;
8791 uuid ?: string ;
8892 iobroker ?: Partial < ioBroker . IoBrokerJson > ;
8993 objects ?: {
9094 [ id : string ] : ioBroker . Object ;
9195 } ;
92- javascriptPassword ?: string ;
9396}
9497
9598const VENDOR_FILE = '/etc/iob-vendor.json' ;
@@ -126,9 +129,15 @@ export class Vendor {
126129 *
127130 * @param file file path if not given, default path is used
128131 * @param password vendor password
132+ * @param javascriptPassword vendor JavaScript password
129133 * @param logger
130134 */
131- async checkVendor ( file : string | undefined , password : string , logger ?: InternalLogger ) : Promise < void > {
135+ async checkVendor (
136+ file : string | undefined ,
137+ password : string ,
138+ javascriptPassword : string | undefined ,
139+ logger ?: InternalLogger ,
140+ ) : Promise < void > {
132141 logger ||= {
133142 debug : ( text : string ) => console . log ( text ) ,
134143 info : ( text : string ) => console . log ( text ) ,
@@ -208,22 +217,21 @@ export class Vendor {
208217 try {
209218 const obj = await this . objects . getObject ( 'system.config' ) ;
210219 if ( obj ?. native ) {
211- let javascriptPassword : string | undefined ;
212-
213- if ( data . javascriptPassword ) {
214- javascriptPassword = tools . encrypt ( obj . native . secret , data . javascriptPassword ) ;
220+ let javascriptPasswordEncrypted : string | undefined ;
221+ if ( javascriptPassword ) {
222+ javascriptPasswordEncrypted = tools . encrypt ( obj . native . secret , javascriptPassword ) ;
215223 }
216224
217225 if (
218226 ! isDeepStrictEqual ( obj . native . vendor , vendor ) ||
219- obj . native . javascriptPassword !== javascriptPassword
227+ obj . native . javascriptPassword !== javascriptPasswordEncrypted
220228 ) {
221229 obj . native . vendor = vendor ;
222230 obj . nonEdit ||= { } ;
223231 if ( javascriptPassword ) {
224- obj . native . javascriptPassword = javascriptPassword ;
232+ obj . native . javascriptPassword = javascriptPasswordEncrypted ;
225233 obj . nonEdit . native ||= { } ;
226- obj . nonEdit . native . javascriptPassword = javascriptPassword ;
234+ obj . nonEdit . native . javascriptPassword = javascriptPasswordEncrypted ;
227235 }
228236 obj . nonEdit . password = password ;
229237 await this . objects . setObjectAsync ( obj . _id , obj ) ;
@@ -233,18 +241,18 @@ export class Vendor {
233241 } catch ( e ) {
234242 logger . error ( `Cannot update system.config: ${ e . message } ` ) ;
235243 }
236- } else if ( data ?. javascriptPassword ) {
244+ } else if ( javascriptPassword ) {
237245 const obj = await this . objects . getObject ( 'system.config' ) ;
238246
239247 if ( obj ?. native ) {
240- const javascriptPassword = tools . encrypt ( obj . native . secret , data . javascriptPassword ) ;
241- if ( obj . native ?. javascriptPassword !== javascriptPassword ) {
248+ const javascriptPasswordEncrypted = tools . encrypt ( obj . native . secret , javascriptPassword ) ;
249+ if ( obj . native ?. javascriptPassword !== javascriptPasswordEncrypted ) {
242250 obj . native ||= { } ;
243- obj . native . javascriptPassword = javascriptPassword ;
251+ obj . native . javascriptPassword = javascriptPasswordEncrypted ;
244252 obj . nonEdit ||= { } ;
245253 obj . nonEdit . password = password ;
246254 obj . nonEdit . native ||= { } ;
247- obj . nonEdit . native . javascriptPassword = javascriptPassword ;
255+ obj . nonEdit . native . javascriptPassword = javascriptPasswordEncrypted ;
248256 try {
249257 await this . objects . setObjectAsync ( obj . _id , obj ) ;
250258 logger . info ( 'object system.config updated' ) ;
0 commit comments