From 60841a7230d77f7ecab6696f9bafe1c030ee64f6 Mon Sep 17 00:00:00 2001 From: Brad Anderson Date: Tue, 3 Mar 2026 17:11:01 -0500 Subject: [PATCH] fix: cast getRandomValues result and fix CI tsc error detection The wrap_unwrap tests called Buffer.from() with getRandomValues() return type (RandomTypedArrays union), which @craftzdog/react-native-buffer doesn't accept. Cast to Uint8Array at the 5 call sites. CI wasn't catching this because bun --filter prefixes tsc output with workspace names, breaking reviewdog's error format pattern. Add set -o pipefail and sed to strip the prefix so errors propagate. --- .github/workflows/validate-js.yml | 3 ++- example/src/tests/subtle/wrap_unwrap.ts | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/validate-js.yml b/.github/workflows/validate-js.yml index d1b1d5e2..3b7ed61d 100644 --- a/.github/workflows/validate-js.yml +++ b/.github/workflows/validate-js.yml @@ -48,7 +48,8 @@ jobs: - name: Run TypeScript # Reviewdog tsc errorformat: %f:%l:%c - error TS%n: %m run: | - bun tsc | reviewdog -name="tsc" -efm="%f(%l,%c): error TS%n: %m" -reporter="github-pr-review" -filter-mode="nofilter" -fail-on-error -tee + set -o pipefail + bun tsc 2>&1 | sed 's/^[^ ]* typescript: //' | reviewdog -name="tsc" -efm="%f(%l,%c): error TS%n: %m" -reporter="github-pr-review" -filter-mode="nofilter" -fail-on-error -tee env: REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/example/src/tests/subtle/wrap_unwrap.ts b/example/src/tests/subtle/wrap_unwrap.ts index 6c031336..955f0ea4 100644 --- a/example/src/tests/subtle/wrap_unwrap.ts +++ b/example/src/tests/subtle/wrap_unwrap.ts @@ -41,7 +41,7 @@ test(SUITE, 'wrap/unwrap AES-256 with AES-KW', async () => { ); // Verify keys are functionally identical - const plaintext = getRandomValues(new Uint8Array(32)); + const plaintext = getRandomValues(new Uint8Array(32)) as Uint8Array; const iv = getRandomValues(new Uint8Array(12)); const ct1 = await subtle.encrypt( @@ -184,7 +184,7 @@ test(SUITE, 'wrap/unwrap with AES-CBC', async () => { ['encrypt', 'decrypt'], ); - const plaintext = getRandomValues(new Uint8Array(32)); + const plaintext = getRandomValues(new Uint8Array(32)) as Uint8Array; const gcmIv = getRandomValues(new Uint8Array(12)); const ct = await subtle.encrypt( @@ -237,7 +237,7 @@ test(SUITE, 'wrap/unwrap with AES-OCB', async () => { ['encrypt', 'decrypt'], ); - const plaintext = getRandomValues(new Uint8Array(32)); + const plaintext = getRandomValues(new Uint8Array(32)) as Uint8Array; const gcmIv = getRandomValues(new Uint8Array(12)); const ct = await subtle.encrypt( @@ -343,7 +343,7 @@ test(SUITE, 'wrap/unwrap with RSA-OAEP', async () => { ['encrypt', 'decrypt'], ); - const plaintext = getRandomValues(new Uint8Array(32)); + const plaintext = getRandomValues(new Uint8Array(32)) as Uint8Array; const iv = getRandomValues(new Uint8Array(12)); const ct = await subtle.encrypt( @@ -396,7 +396,7 @@ test(SUITE, 'wrap/unwrap with ChaCha20-Poly1305', async () => { ['encrypt', 'decrypt'], ); - const plaintext = getRandomValues(new Uint8Array(32)); + const plaintext = getRandomValues(new Uint8Array(32)) as Uint8Array; const gcmIv = getRandomValues(new Uint8Array(12)); const ct = await subtle.encrypt(