mirror of
https://github.com/zadam/trilium.git
synced 2025-11-09 14:55:50 +01:00
fix(server): build errors after newer types
This commit is contained in:
@@ -34,7 +34,7 @@ function encrypt(key: Buffer, plainText: Buffer | string) {
|
||||
throw new Error("No data key!");
|
||||
}
|
||||
|
||||
const plainTextBuffer = Buffer.from(plainText);
|
||||
const plainTextBuffer = Buffer.isBuffer(plainText) ? plainText : Buffer.from(plainText);
|
||||
|
||||
const iv = crypto.randomBytes(16);
|
||||
const cipher = crypto.createCipheriv("aes-128-cbc", pad(key), pad(iv));
|
||||
@@ -88,7 +88,7 @@ function decrypt(key: Buffer, cipherText: string | Buffer): Buffer | false | nul
|
||||
if (e.message?.includes("WRONG_FINAL_BLOCK_LENGTH") || e.message?.includes("wrong final block length")) {
|
||||
log.info("Caught WRONG_FINAL_BLOCK_LENGTH, returning cipherText instead");
|
||||
|
||||
return Buffer.from(cipherText);
|
||||
return (Buffer.isBuffer(cipherText) ? cipherText : Buffer.from(cipherText));
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,8 @@ export function hashedBlobId(content: string | Buffer) {
|
||||
}
|
||||
|
||||
export function toBase64(plainText: string | Buffer) {
|
||||
return Buffer.from(plainText).toString("base64");
|
||||
const buffer = (Buffer.isBuffer(plainText) ? plainText : Buffer.from(plainText));
|
||||
return buffer.toString("base64");
|
||||
}
|
||||
|
||||
export function fromBase64(encodedText: string) {
|
||||
|
||||
Reference in New Issue
Block a user