From b9c550b5124040e7edf253e90ec349a845098179 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 09:28:26 +0000 Subject: [PATCH] fix: resolve Buffer and Uint8Array type compatibility issues Co-Authored-By: shryas.londhe@gmail.com --- packages/helpers/src/lib/mailauth/tools.ts | 2 +- packages/helpers/src/sha-utils.ts | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/helpers/src/lib/mailauth/tools.ts b/packages/helpers/src/lib/mailauth/tools.ts index 53a9395d..4cc1b1c4 100644 --- a/packages/helpers/src/lib/mailauth/tools.ts +++ b/packages/helpers/src/lib/mailauth/tools.ts @@ -30,7 +30,7 @@ export const writeToStream = async ( chunkSize = chunkSize || 64 * 1024; if (typeof input === 'string') { - input = Buffer.from(input) as Buffer & NodeJS.ReadableStream; + input = Buffer.from(input) as unknown as Buffer & NodeJS.ReadableStream; } return new Promise((resolve, reject) => { diff --git a/packages/helpers/src/sha-utils.ts b/packages/helpers/src/sha-utils.ts index 16501c84..3de4031d 100644 --- a/packages/helpers/src/sha-utils.ts +++ b/packages/helpers/src/sha-utils.ts @@ -20,11 +20,9 @@ export function findIndexInUint8Array(array: Uint8Array, selector: Uint8Array): } export function padUint8ArrayWithZeros(array: Uint8Array, length: number): Uint8Array { - while (array.length < length) { - // eslint-disable-next-line no-param-reassign - array = mergeUInt8Arrays(array, int8toBytes(0)); - } - return array; + const result = new Uint8Array(Math.max(array.length, length)); + result.set(array); + return result; } export function generatePartialSHA({