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