Installations
npm install react-native-polyfill-globals
Developer
acostalima
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
14.7.0
NPM Version
6.14.7
Statistics
45 Stars
44 Commits
4 Forks
3 Watching
1 Branches
1 Contributors
Updated on 29 Oct 2024
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
392,289
Last day
-6.4%
1,355
Compared to previous day
Last week
4.8%
8,192
Compared to previous week
Last month
23.2%
33,801
Compared to previous month
Last year
167.6%
255,119
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
6
Dev Dependencies
20
react-native-polyfill-globals
Polyfills and patches missing or partially supported web and core APIs.
Motivation
There are several APIs which React Native does not support. When available, they usally are not spec-conformant. This package aims to fill that gap by providing polyfills and patches to said APIs.
As of React Native v0.63.3:
URL
andURLSearchParams
are partially implemented.- https://github.com/facebook/react-native/blob/v0.63.3/Libraries/Blob/URL.js#L56
- https://github.com/facebook/react-native/blob/v0.63.3/Libraries/Blob/URL.js#L115
- Related discussions:
- https://github.com/facebook/react-native/pull/30188
- https://github.com/facebook/react-native/pull/25719
- https://github.com/facebook/react-native/issues/23922
- https://github.com/facebook/react-native/issues/24428
- https://github.com/facebook/react-native/issues/16434
- https://github.com/facebook/react-native/issues/25717
- https://github.com/facebook/react-native/issues/26019
FormData
is partially implementedFileReader.readAsArrayBuffer
is not implementedReadableStream
is not supported and, by extension,Response.body
is not implemented. Related discussions:btoa
andatob
are not supportedTextEncoder
andTextDecoder
are not supported- ...and others
Installation
1$ npm install react-native-polyfill-globals
Peer dependencies
- react-native-url-polyfill
- web-streams-polyfill
- base-64
- text-encoding
- react-native-fetch-api
- react-native-get-random-values
Install the above as necessary.
Included support
- Implemented by react-native+0.63.3.patch
FormData.set
- Handling of
Blob
s byFormData
FileReader.readAsArrayBuffer
URL
andURLSearchParams
provided by react-native-url-polyfillReadableStream
provided by web-streams-polyfillbtoa
andatob
provided by base-64TextEncoder
andTextDecoder
provided by text-encodingfetch
for text streaming provided by react-native-fetch-apicrypto.getRandomValues
provided by react-native-get-random-values
Usage
Polyfill all on demand
Import the polyfill
function and call it whenever.
1import { polyfill } from 'react-native-polyfill-globals'; 2 3polyfill();
Polyfill all automatically
Add the following import to the top of your app's entry file, index.js
, located at the root of your project.
1import 'react-native-polyfill-globals/auto';
Polyfill selectively
1import { polyfill as polyfillBase64 } from 'react-native-polyfill-globals/src/base64'; 2import { polyfill as polyfillEncoding } from 'react-native-polyfill-globals/src/encoding'; 3import { polyfill as polyfillReadableStream } from 'react-native-polyfill-globals/src/readable-stream'; 4import { polyfill as polyfillURL } from 'react-native-polyfill-globals/src/url'; 5import { polyfill as polyfillFetch } from 'react-native-polyfill-globals/src/fetch'; 6import { polyfill as polyfillCrypto } from 'react-native-polyfill-globals/src/crypto';
Apply patches
Patch files located at the patches directory provide additional polyfills and fixes.
Apply all at once with patch-package
:
1$ npm install -D patch-package 2$ npx patch-package --patch-dir node_modules/react-native-polyfill-globals/patches
Apply invidually with Git:
1$ git apply --ignore-whitespace node_modules/react-native-polyfill-globals/react-native+0.63.3.patch
Apply invidually with patch
:
1$ patch -p1 -i node_modules/react-native-polyfill-globals/react-native+0.63.3.patch
⚠️ Bundling
Note that Metro, React Native's bundler, at this time does not support tree-shaking nor dead code elimination. As such, beware that even if you apply polyfills selectively and don't use them at runtime, the code will be included in the production bundle regardless. If you don't need a given polyfill, do not import it at all.
Related
- node-libs-react-native - Node.js core modules for React Native.
- rn-nodeify - Hack to allow React Native projects to use Node core modules and npm modules that use them.
- ReactNativify - A saner approach on how to use Node.js libraries in React Native.
License
MIT © André Costa Lima
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node-ci.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/acostalima/react-native-polyfill-globals/node-ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node-ci.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/acostalima/react-native-polyfill-globals/node-ci.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/node-ci.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/acostalima/react-native-polyfill-globals/node-ci.yml/master?enable=pin
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
- Info: 1 out of 1 npmCommand dependencies pinned
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/node-ci.yml:1
- Info: no jobLevel write permissions found
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
63 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-ff7x-qrg7-qggm
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97
- Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44
- Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988
- Warn: Project is vulnerable to: GHSA-f5x2-xv93-4p23
- Warn: Project is vulnerable to: GHSA-gmpm-xp43-f7g6
- Warn: Project is vulnerable to: GHSA-pf27-929j-9pmm
- Warn: Project is vulnerable to: GHSA-327c-qx3v-h673
- Warn: Project is vulnerable to: GHSA-x4cf-6jr3-3qvp
- Warn: Project is vulnerable to: GHSA-mph8-6787-r8hw
- Warn: Project is vulnerable to: GHSA-7mhc-prgv-r3q4
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-4cpg-3vgw-4877
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-rxrc-rgv4-jpvx
- Warn: Project is vulnerable to: GHSA-7f53-fmmv-mfjv
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-44c6-4v22-4mhx
- Warn: Project is vulnerable to: GHSA-4x5v-gmq8-25ch
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6
- Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj
- Warn: Project is vulnerable to: GHSA-gff7-g5r8-mg8m
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v
- Warn: Project is vulnerable to: GHSA-38fc-wpqx-33j7
- Warn: Project is vulnerable to: GHSA-394c-5j6w-4xmx
- Warn: Project is vulnerable to: GHSA-78cj-fxph-m83p
- Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-h6q6-9hqw-rwfv
- Warn: Project is vulnerable to: GHSA-5fg8-2547-mr8q
- Warn: Project is vulnerable to: GHSA-crh6-fp67-6883
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
Score
2.8
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to react-native-polyfill-globals
web-encoding
TextEncoder and TextDecoder APIs from Encoding Standard APIs in a universal package
web-streams-polyfill
Web Streams, based on the WHATWG spec reference implementation
react-native-url-polyfill
A lightweight and trustworthy URL polyfill for React Native
eslint-plugin-react-native-globals
ESLint Environment for React Native