import { decodeRestrictedBase64ToBytes } from "../util" ; import { isZlibData , decompressZlib } from "../utils/zlib" ; import { fromByteArray } from "base64-js" ; export async function decodeBinary ( input ) { let data = decodeRestrictedBase64ToBytes ( input ) ; if ( isZlibData ( data ) ) { data = await decompressZlib ( data ) ; } return data . buffer as ArrayBuffer ; } export function encodeBinary ( input ) { return fromByteArray ( new Uint8Array ( input ) ) ; }