Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: i.randomBytes is not a function #1079

Closed
vricosti opened this issue May 14, 2024 · 0 comments
Closed

TypeError: i.randomBytes is not a function #1079

vricosti opened this issue May 14, 2024 · 0 comments

Comments

@vricosti
Copy link

vricosti commented May 14, 2024

Hi,

I forked a project called androidtv-remote (my repo is here and the branch is dev/webpack) to be able to use it inside a node or browser environment, so I have added webpack config (umd configuration) and I replaced the use of path, url and crypto. (Actually my real goal is to use it inside a react-native mobile app that's why even if tls is not available I am ignoring the missing require and I will use a react-native-tls fallback, or maybe later on I will use forge also instead of tls).
Anyway with all my modifications since I am testing the example on node I thought it would work out of the box...

To replace crypto I am using forge and you can see my modifications here:
https://github.com/louis49/androidtv-remote/compare/main...vricosti:dev/webpack?expand=1

when trying to test the example I have the following error:

TypeError: i.randomBytes is not a function
    at t.seedFileSync (/home/vricosti/Dev/androidtv-remote/example/node_modules/androidtv-remote/dist/index.js:1:159283)
    at o (/home/vricosti/Dev/androidtv-remote/example/node_modules/androidtv-remote/dist/index.js:1:156982)
    at t.generateSync (/home/vricosti/Dev/androidtv-remote/example/node_modules/androidtv-remote/dist/index.js:1:159008)
    at t.generate (/home/vricosti/Dev/androidtv-remote/example/node_modules/androidtv-remote/dist/index.js:1:158178)
    at e.getBytesSync (/home/vricosti/Dev/androidtv-remote/example/node_modules/androidtv-remote/dist/index.js:1:162426)
    at Object.nextBytes (/home/vricosti/Dev/androidtv-remote/example/node_modules/androidtv-remote/dist/index.js:1:173765)
    at s.fromNumber (/home/vricosti/Dev/androidtv-remote/example/node_modules/androidtv-remote/dist/index.js:1:83481)
    at new s (/home/vricosti/Dev/androidtv-remote/example/node_modules/androidtv-remote/dist/index.js:1:72775)
    at u.rsa.stepKeyPairGenerationState (/home/vricosti/Dev/androidtv-remote/example/node_modules/androidtv-remote/dist/index.js:1:174377)
    at u.rsa.generateKeyPair (/home/vricosti/Dev/androidtv-remote/example/node_modules/androidtv-remote/dist/index.js:1:177625)

To reproduce:

git clone https://github.com/vricosti/androidtv-remote.git
cd androidtv-remote
git fetch origin
git checkout dev/webpack
yarn install
yarn --cwd example install
yarn build
rm -rf example/node_modules/androidtv-remote/dist/*
cp ./dist/* example/node_modules/androidtv-remote/dist/
cd example/
node example.js
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

No branches or pull requests

1 participant