(value: string)
| 443 | type DecodedBase64Body = { readonly ok: true; readonly bytes: Uint8Array } | { readonly ok: false }; |
| 444 | |
| 445 | const base64ToUint8Array = (value: string): Uint8Array | null => { |
| 446 | let binary = ""; |
| 447 | // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: atob throws for invalid base64; invalid shapes are treated as non-byte input |
| 448 | try { |
| 449 | binary = atob(normalizeBase64(value, "base64")); |
| 450 | } catch { |
| 451 | return null; |
| 452 | } |
| 453 | const bytes = new Uint8Array(binary.length); |
| 454 | for (let index = 0; index < binary.length; index += 1) { |
| 455 | bytes[index] = binary.charCodeAt(index); |
| 456 | } |
| 457 | return bytes; |
| 458 | }; |
| 459 | |
| 460 | const decodeBase64Body = (value: string): DecodedBase64Body => { |
| 461 | const bytes = base64ToUint8Array(value); |
no test coverage detected