refactor(crypto): reject encrypted values from another secret
This commit is contained in:
parent
419204d587
commit
0f5a6823ec
1 changed files with 8 additions and 1 deletions
|
|
@ -38,7 +38,14 @@ const encrypt = async (data: string) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEncrypted(data)) {
|
if (isEncrypted(data)) {
|
||||||
return data;
|
try {
|
||||||
|
await decrypt(data);
|
||||||
|
return data;
|
||||||
|
} catch {
|
||||||
|
throw new Error(
|
||||||
|
"You have provided an encrypted value that cannot be decrypted with the current APP_SECRET. Please use a plain text value.",
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const salt = crypto.randomBytes(16);
|
const salt = crypto.randomBytes(16);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue