(value: string)
| 39 | } |
| 40 | |
| 41 | export function decodeFromBase64(value: string): string { |
| 42 | if (textDecoder && hasWindowFunction("atob")) { |
| 43 | const binary = window.atob(value); |
| 44 | const bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0)); |
| 45 | return textDecoder.decode(bytes); |
| 46 | } |
| 47 | |
| 48 | const buffer = getGlobalBuffer(); |
| 49 | if (buffer) { |
| 50 | return buffer.from(value, "base64").toString("utf8"); |
| 51 | } |
| 52 | |
| 53 | throw new Error("Base64 decoding is not supported in this environment."); |
| 54 | } |
no test coverage detected