Skip to content

fix(deps): replace react-native-securerandom with react-native-get-random-values#4099

Open
a-khushal wants to merge 1 commit into
ZeusLN:masterfrom
a-khushal:use-get-random-values
Open

fix(deps): replace react-native-securerandom with react-native-get-random-values#4099
a-khushal wants to merge 1 commit into
ZeusLN:masterfrom
a-khushal:use-get-random-values

Conversation

@a-khushal
Copy link
Copy Markdown
Contributor

Description

Relates to issue: ZEUS-4095

This pull request is categorized as a:

  • New feature
  • Bug fix
  • Code refactor
  • Configuration change
  • Locales update
  • Quality assurance
  • Other

Checklist

  • I’ve run yarn run tsc and made sure my code compiles correctly
  • I’ve run yarn run lint and made sure my code didn’t contain any problematic patterns
  • I’ve run yarn run prettier and made sure my code is formatted correctly
  • I’ve run yarn run test and made sure all of the tests pass

Testing

If you modified or added a utility file, did you add new unit tests?

  • No, I’m a fool
  • Yes
  • N/A

I have tested this PR on the following platforms (please specify OS version and phone model/VM):

  • Android
  • iOS

I have tested this PR with the following types of nodes (please specify node version and API version where appropriate):

On-device

  • LDK Node
  • Embedded LND

Remote

  • LND (REST)
  • LND (Lightning Node Connect)
  • Core Lightning (CLNRest)
  • Nostr Wallet Connect
  • LndHub

Locales

  • I’ve added new locale text that requires translations
  • I’m aware that new translations should be made on the ZEUS Transfix page and not directly to this repo

Third Party Dependencies and Packages

  • Contributors will need to run yarn after this PR is merged in
  • 3rd party dependencies have been modified:
    • verify that package.json and yarn.lock have been properly updated
    • verify that dependencies are installed for both iOS and Android platforms

Other:

  • Changes were made that require an update to the README
  • Changes were made that require an update to onboarding

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the react-native-securerandom dependency and updates utils/LndMobileUtils.ts to use the standard crypto.getRandomValues API for generating random bytes. The review feedback correctly identifies that the react-native-get-random-values package is missing from package.json and that its polyfill must be imported in the application's entry file to prevent a ReferenceError at runtime.

Comment thread package.json
"react-native-safe-area-context": "5.6.2",
"react-native-screens": "4.19.0",
"react-native-securerandom": "1.0.1",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The dependency react-native-get-random-values is missing from package.json. The pull request title and the changes in utils/LndMobileUtils.ts indicate that this package is intended to replace react-native-securerandom. Without adding it to the dependencies, the application will fail to resolve the package and crash when attempting to use crypto.getRandomValues.

Suggested change
"react-native-get-random-values": "1.11.0",

Copy link
Copy Markdown
Contributor Author

@a-khushal a-khushal May 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was already an existing dependency in package.json and we've removed it to use the globalThis.crypto.getRandomValues()

Comment thread utils/LndMobileUtils.ts Outdated

const random = await generateSecureRandom(32);
const random = new Uint8Array(32);
crypto.getRandomValues(random);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using crypto.getRandomValues in a React Native environment requires the react-native-get-random-values polyfill to be imported at the very beginning of your application's entry file (e.g., index.js or App.tsx). Please ensure this import is added to avoid a ReferenceError: crypto is not defined at runtime.

Copy link
Copy Markdown
Contributor Author

@a-khushal a-khushal May 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imported in index.js (line 11), no changes needed.

@a-khushal a-khushal force-pushed the use-get-random-values branch 2 times, most recently from b7cefe0 to 92cdffb Compare May 19, 2026 09:28
Copy link
Copy Markdown
Contributor

@ajaysehwal ajaysehwal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK

@a-khushal a-khushal force-pushed the use-get-random-values branch from 92cdffb to 977c509 Compare May 24, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants