Add more React Native polyfills and Solana setup into the SDK - #142
Add more React Native polyfills and Solana setup into the SDK#142yashovardhan wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4f69cb7. Configure here.
| // IMP END - Allowlist bundle ID | ||
| network: WEB3AUTH_NETWORK.SAPPHIRE_DEVNET, | ||
| // IMP START - Chain Config | ||
| defaultChainId: "0x66", |
There was a problem hiding this comment.
Wrong Solana Devnet chain ID
Medium Severity
defaultChainId is set to 0x66, and the demo README calls that Devnet. Elsewhere in this SDK, 0x66 is Testnet and 0x67 is Devnet. Apps that whitelist Devnet on the dashboard while using this config will request the wrong chain at init.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 4f69cb7. Configure here.
| const [output, setOutput] = useState(""); | ||
| const log = (...args: unknown[]) => setOutput(JSON.stringify(args, null, 2)); | ||
|
|
||
| const solanaAddress = accounts![0]!; |
There was a problem hiding this comment.
Unsafe accounts access on render
Medium Severity
HomeView reads accounts![0]! during render. useSolanaWallet types accounts as string[] | null and can return null even when the user is connected, so the logged-in screen can throw before any button is pressed.
Reviewed by Cursor Bugbot for commit 4f69cb7. Configure here.
| } | ||
|
|
||
| return authGetED25519Key(privateKey); | ||
| } |
There was a problem hiding this comment.
Invalid key lengths not rejected
Medium Severity
getED25519Key only special-cases 64-byte secrets and otherwise forwards every other length to @web3auth/auth. The PR intent was to accept 32-byte seeds and 64-byte secrets and reject all other lengths explicitly, so malformed key material can still reach auth instead of failing fast.
Reviewed by Cursor Bugbot for commit 4f69cb7. Configure here.
There was a problem hiding this comment.
we should instead set min supported version of react native instead.
Our sdk min is node 22 and hence RN should be 0.84+
This would mean we wouldn't need url polyfill and we should edit examples to be above 0.84+ on RN or expo 55
Reference:
https://github.com/reactwg/react-native-releases/blob/main/docs/support.md
https://reactnative.dev/blog/2026/02/11/react-native-0.84#url-api-improvements


Motivation and Context
After the v10 upgrade, React Native apps integrating Web3Auth (especially Solana) needed a growing set of app-level workarounds: separate
react-native-url-polyfillimports, custom Metro aliases for@web3auth/auth, localpolyfills.js, andshims/directories. These duplicated what the SDK should own and made examples harder to follow.This change moves genuinely SDK-owned runtime and Metro compatibility code into
@web3auth/react-native-sdk, so consumers can rely on:import "@web3auth/react-native-sdk/setup"for EVM/core apps (URL, crypto, Buffer)import "@web3auth/react-native-sdk/setup-solana"for Solana apps (core setup + Solana runtime polyfills)withWeb3Auth(getDefaultConfig(...))Metro config without custom resolver branchesJira Link:
Description
Core URL compatibility
src/metro/setup.jsloadsreact-native-url-polyfill/autobefore SDK/auth code runs.src/metro/shims/url-shim.jsimportsURL/URLSearchParamsfromreact-native-url-polyfillinstead of incomplete React Native globals.react-native-url-polyfillentry import.Solana ED25519 key normalization
src/wallets/ed25519Key.tsto normalize hex private keys:@web3auth/authgetED25519Keyseed || publicKeysecrets → accepted directlynativeSolanaWallet.tsuses this utility, removing the need for app-level@web3auth/authMetro shims.Solana setup export
@web3auth/react-native-sdk/setup-solana— chains core setup with Solana-only runtime polyfills:@solana/webcrypto-ed25519-polyfillAbortSignal.timeout(when absent)windowevent listener stubs (when absent)@solana/webcrypto-ed25519-polyfillas an SDK dependency./setupand/setup-solanaassideEffectsso bundlers cannot tree-shake them.Metro resolver
withWeb3Auth; version-sensitive Expo overrides (quick-base64,tslib,es-toolkit) were not reproduced in SDK demos and remain app-level workarounds when needed.Demos & documentation
withWeb3Auth(config)Metro configs.demo/rn-bare-solana-exampleusing onlysetup-solana(nopolyfills.js, noshims/)./setupvs/setup-solanaguidance and Solana demo reference.How has this been tested?
Environment: macOS, Node 22+, local SDK repo
Automated:
npm test— 73 tests passing, including:setup.test.ts— core setup structure / URL polyfill wiringsetup-solana.test.ts— Solana polyfill behavior and setup chaininged25519Key.test.ts— 32-byte seed delegation, 64-byte secrets, invalid lengthsnativeSolanaWallet.test.ts— wallet creation, account derivation, signing (32-byte and 64-byte keys)npm run lint:ts— 0 errorsnpm run build— successful/setup,/setup-solana,/solana,/metro-configManual (pending / recommended before merge):
demo/rn-bare-example— login, EVM calls with plainwithWeb3Authdemo/rn-expo-hooks-example— Wagmi integration with plainwithWeb3Authdemo/rn-bare-solana-example— login, address, balance, sign message viasetup-solanaScreenshots (if appropriate):
N/A — infrastructure / polyfill changes, no UI changes.
Types of changes
Checklist:
Note
Cursor Bugbot is generating a summary for commit 4f69cb7. Configure here.