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

fix: switch randombytes for iso-random-stream for browser compatibility #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Apr 28, 2023

  1. fix: switch randombytes for iso-random-stream for browser compatibility

    The `randombytes` package depends on `safe-buffer` which uses the
    built-in `buffer` module from node core without declaring the polyfill
    as a dep.
    
    If you have this installed as a transitive dependency you will be fine
    but if not you'll see errors like:
    
    ```
    dex.js:12 Uncaught TypeError: Cannot read properties of undefined (reading 'from')
        at node_modules/safe-buffer/index.js (index.js:12:12)
        at __require2 (chunk-LFBQMW2U.js?v=930a8016:19:50)
        at node_modules/randombytes/browser.js (browser.js:15:14)
        at __require2 (chunk-LFBQMW2U.js?v=930a8016:19:50)
        at node_modules/k-bucket/index.js (index.js:31:21)
        at __require2 (chunk-LFBQMW2U.js?v=930a8016:19:50)
        at index.ts:2:19
    ```
    
    This PR switches `randombytes` for `iso-random-stream` which does not
    have this problem and uses the native random bytes functionality in
    both node and browsers.
    
    It also adds a dependency on the `events` polyfill in case you don't
    have that as a transitive dependency either.
    achingbrain committed Apr 28, 2023
    Configuration menu
    Copy the full SHA
    e115358 View commit details
    Browse the repository at this point in the history