MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / base64ToUint8Array

Function base64ToUint8Array

packages/plugins/openapi/src/sdk/invoke.ts:491–504  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

489type DecodedBase64Body = { readonly ok: true; readonly bytes: Uint8Array } | { readonly ok: false };
490
491const base64ToUint8Array = (value: string): Uint8Array | null => {
492 let binary = "";
493 // oxlint-disable-next-line executor/no-try-catch-or-throw -- boundary: atob throws for invalid base64; invalid shapes are treated as non-byte input
494 try {
495 binary = atob(normalizeBase64(value, "base64"));
496 } catch {
497 return null;
498 }
499 const bytes = new Uint8Array(binary.length);
500 for (let index = 0; index < binary.length; index += 1) {
501 bytes[index] = binary.charCodeAt(index);
502 }
503 return bytes;
504};
505
506const decodeBase64Body = (value: string): DecodedBase64Body => {
507 const bytes = base64ToUint8Array(value);

Callers 2

decodeBase64BodyFunction · 0.85
formPartFromToolFileFunction · 0.85

Calls 1

normalizeBase64Function · 0.85

Tested by

no test coverage detected