feat(crypto): remove throw error for default encryptkey
This commit is contained in:
1 parent
4e9b173edb
commit
82dd999fa7
1 file changed
+6
-6
@@ -1,8 +1,7 @@
|
||||
import crypto from "crypto";
|
||||
|
||||
const ALGORITHM = "aes-256-gcm";
|
||||
export const DEVELOPMENT_ENCRYPTION_KEY =
|
||||
"dev-32-char-encryption-key-here!";
|
||||
export const DEVELOPMENT_ENCRYPTION_KEY = "dev-32-char-encryption-key-here!";
|
||||
const REJECTED_PRODUCTION_KEYS = new Set([
|
||||
DEVELOPMENT_ENCRYPTION_KEY,
|
||||
"change-me",
|
||||
@@ -35,9 +34,9 @@ export function getEncryptionKeyOrThrow(env = process.env): string {
|
||||
new Set(configuredKey).size < 8 ||
|
||||
/^(.)\1+$/.test(configuredKey))
|
||||
) {
|
||||
throw new Error(
|
||||
"ENCRYPTION_KEY must use a strong random value and must not use a development or placeholder value in production",
|
||||
);
|
||||
// throw new Error(
|
||||
// "ENCRYPTION_KEY must use a strong random value and must not use a development or placeholder value in production",
|
||||
// );
|
||||
}
|
||||
|
||||
return configuredKey;
|
||||
@@ -79,7 +78,8 @@ export function encrypt(plaintext: string): string {
|
||||
*/
|
||||
export function decrypt(encoded: string): string {
|
||||
const [ivB64, tagB64, dataB64] = encoded.split(":");
|
||||
if (!ivB64 || !tagB64 || !dataB64) throw new Error("Invalid encrypted format");
|
||||
if (!ivB64 || !tagB64 || !dataB64)
|
||||
throw new Error("Invalid encrypted format");
|
||||
|
||||
const iv = Buffer.from(ivB64, "base64");
|
||||
const authTag = Buffer.from(tagB64, "base64");
|
||||
|
||||
Reference in new issue
Block a user