This repository was archived by the owner on Apr 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,10 @@ export async function setPassword(pw: string): Promise<boolean> {
85
85
// Re-encrypt the configuration using our own derived key instead of the password.
86
86
const newEncryptionKey = deriveEncryptionKey ( pw , salt ) ;
87
87
const newEncryptionKeyArr = cryptoJS . enc . Hex . parse ( newEncryptionKey ) ;
88
- reEncryptData ( encryptedData . value , pw , newEncryptionKeyArr ) ;
88
+ const res = reEncryptData ( encryptedData . value , pw , newEncryptionKeyArr ) ;
89
+ if ( res . failed ) {
90
+ throw new Error ( `Failed to migrate config: ${ res . errorMessage } ` ) ;
91
+ }
89
92
}
90
93
91
94
encryptedData . value . salt = salt ;
@@ -127,7 +130,7 @@ export function isPasswordSet(): boolean {
127
130
128
131
/**
129
132
* Decrypts the passed data using the global encryptionKey variable and saves it into `ConfigData`.
130
- * Unsets the encryption key if its wrong and also forwards `undefined` to `ConfigData` if the encryption key is unset.
133
+ * Clears the encryption key if its wrong and also forwards `undefined` to `ConfigData` if the encryption key is unset.
131
134
* @param data the data that should be decrypted.
132
135
*/
133
136
function updateDecryptedData ( data : EncryptedData ) : void {
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ export function decryptData(
70
70
}
71
71
72
72
/**
73
- * Encrypts the passed data objedt using the passed encryption key.
73
+ * Encrypts the passed data object using the passed encryption key.
74
74
*
75
75
* @param data the data that needs to be encrypted.
76
76
* @param encryptionKey the encryption key that should be used to encrypt the data.
@@ -395,7 +395,10 @@ export class PersistenceManager {
395
395
// Re-encrypt the configuration using our own derived key instead of the password.
396
396
const newEncryptionKey = deriveEncryptionKey ( password , salt ) ;
397
397
const newEncryptionKeyArr = crypto . enc . Hex . parse ( newEncryptionKey ) ;
398
- reEncryptData ( this . encryptedData . value , password , newEncryptionKeyArr ) ;
398
+ const res = reEncryptData ( this . encryptedData . value , password , newEncryptionKeyArr ) ;
399
+ if ( res . failed ) {
400
+ throw new Error ( `Failed to migrate config: ${ res . errorMessage } ` ) ;
401
+ }
399
402
}
400
403
401
404
this . encryptedData . value . salt = salt ;
@@ -407,7 +410,7 @@ export class PersistenceManager {
407
410
if ( ! loadResult . failed ) {
408
411
this . nodecg . log . info ( "Automatic login successful." ) ;
409
412
} else {
410
- throw loadResult . errorMessage ;
413
+ throw new Error ( loadResult . errorMessage ) ;
411
414
}
412
415
} catch ( err ) {
413
416
const logMesssage = `Failed to automatically login: ${ err } ` ;
You can’t perform that action at this time.
0 commit comments