Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/utils/system/decryptConfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe("decryptConfig", () => {
throw new Error("Function did not throw an error");
} catch (error) {
if (!(error instanceof Error)) throw error;
expect(error.message).to.equal("Password invalid");
expect(error.message).to.equal("DB Password invalid");
}
});
it("should return raw configs if password protection if off", () => {
Expand Down
9 changes: 4 additions & 5 deletions src/utils/system/decryptConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export const setDecrypted = (d: boolean) => (decrypted = d);

export const decryptConfig = (password: string) => {
if (
!constants.DB_AUTH ||
!constants.PRIVKEY ||
!constants.OLD_PRIVKEY ||
!constants.FEE_COLLECTOR_PUBKEY
Expand All @@ -26,17 +25,17 @@ export const decryptConfig = (password: string) => {

try {
if (
AES.decrypt(constants.DB_AUTH, password).toString(enc.Utf8).length === 0
constants.DB_AUTH && AES.decrypt(constants.DB_AUTH, password).toString(enc.Utf8).length === 0
) {
throw new Error("Password invalid");
throw new Error("DB Password invalid");
}
} catch (e) {
throw new Error("Password invalid");
throw new Error("DB Password invalid");
}

setDecrypted(true);
return {
DB_AUTH: AES.decrypt(constants.DB_AUTH, password).toString(enc.Utf8),
DB_AUTH: constants.DB_AUTH ? AES.decrypt(constants.DB_AUTH, password).toString(enc.Utf8) : undefined,
PRIVKEY: AES.decrypt(constants.PRIVKEY, password).toString(enc.Utf8),
OLD_PRIVKEY: AES.decrypt(constants.OLD_PRIVKEY, password).toString(
enc.Utf8,
Expand Down