diff --git a/src/shared/utils/Encoding.ts b/src/shared/utils/Encoding.ts index eb900c0c8..9c3d17b69 100644 --- a/src/shared/utils/Encoding.ts +++ b/src/shared/utils/Encoding.ts @@ -70,35 +70,6 @@ export function arrayBufferToBase64(arrayBuffer: ArrayBufferLike): string { return base64; } -/** - * From: https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding - */ -export function base64Encode(str) { - // first we use encodeURIComponent to get percent-encoded UTF-8, - // then we convert the percent encodings into raw bytes which - // can be fed into btoa. - return btoa( - encodeURIComponent(str).replace( - /%([0-9A-F]{2})/g, - function toSolidBytes(_match, p1) { - return String.fromCharCode(('0x' as any) + p1); - }, - ), - ); -} - -export function base64Decode(str) { - // Going backwards: from bytestream, to percent-encoding, to original string. - return decodeURIComponent( - atob(str) - .split('') - .map(function (c) { - return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); - }) - .join(''), - ); -} - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent#encoding_for_rfc3986 export function encodeRFC3986URIComponent(str: string): string { return encodeURIComponent(str).replace(