tangled mirror of catsky-🐱 Soothing soft social-app fork with all the niche toggles! (Unofficial); for issues and PRs please put them on github:NekoDrone/catsky-social

Remove `atob` polyfill (#9000)

* remove atob polyfill

* remove base64-js as a dependency

authored by samuel.fm and committed by GitHub bb30b592 bbc55eb0

Changed files
-50
src
platform
-1
package.json
··· 123 123 "array.prototype.findlast": "^1.2.3", 124 124 "await-lock": "^2.2.2", 125 125 "babel-plugin-transform-remove-console": "^6.9.4", 126 - "base64-js": "^1.5.1", 127 126 "bcp-47": "^2.1.0", 128 127 "bcp-47-match": "^2.0.3", 129 128 "date-fns": "^2.30.0",
-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 - }