this repo has no description
1import "react-native-url-polyfill/auto";
2import "event-target-polyfill";
3import "abortcontroller-polyfill/dist/polyfill-patch-fetch";
4export {};
5
6/**
7https://github.com/MaxArt2501/base64-js
8The MIT License (MIT)
9Copyright (c) 2014 MaxArt2501
10 */
11
12const b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
13// Regular expression to check formal correctness of base64 encoded strings
14const b64re =
15 /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/;
16
17globalThis.atob = (str: string): string => {
18 // atob can work with strings with whitespaces, even inside the encoded part,
19 // but only \t, \n, \f, \r and ' ', which can be stripped.
20 str = String(str).replace(/[\t\n\f\r ]+/g, "");
21 if (!b64re.test(str)) {
22 throw new TypeError(
23 "Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.",
24 );
25 }
26
27 // Adding the padding if missing, for simplicity
28 str += "==".slice(2 - (str.length & 3));
29 var bitmap,
30 result = "",
31 r1,
32 r2,
33 i = 0;
34 for (; i < str.length; ) {
35 bitmap =
36 (b64.indexOf(str.charAt(i++)) << 18) |
37 (b64.indexOf(str.charAt(i++)) << 12) |
38 ((r1 = b64.indexOf(str.charAt(i++))) << 6) |
39 (r2 = b64.indexOf(str.charAt(i++)));
40
41 result +=
42 r1 === 64
43 ? String.fromCharCode((bitmap >> 16) & 255)
44 : r2 === 64
45 ? String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255)
46 : String.fromCharCode(
47 (bitmap >> 16) & 255,
48 (bitmap >> 8) & 255,
49 bitmap & 255,
50 );
51 }
52 return result;
53};