Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

fix: crypto in insecure browser context #149

Closed
wants to merge 2 commits into from

Commits on Jul 4, 2019

  1. fix: crypto in insecure browser context

    This PR adds `crypto-browserify` to the dependencies and replaces `crypto` with `crypto-browserify` when bundled in the browser.
    
    In files that require webcrypto we check to see if it's available. If it is not we require the Node.js implementation (which has `crypto` replaced with `crypto-browserify`) and if it is available then we use the webcrypto version (so we get fast crypto).
    
    Shipping `crypto-browserify` adds to the bundle size:
    
    Current gzipped size: 142,824 bytes
    New gzipped size: 214,499 bytes
    
    Difference: **+71,675 bytes**
    
    It's not an insignificant addition so we need to decide whether this is worth it.
    
    If not accepted, we need to add checks when libp2p-crypto methods are called and callback with an appropriate error message. JS IPFS will continue to have issues opened with confusion around this otherwise! See ipfs/js-ipfs#963 ipfs/js-ipfs#964 ipfs/js-ipfs#2153
    
    resolves #105
    
    License: MIT
    Signed-off-by: Alan Shaw <[email protected]>
    Alan Shaw committed Jul 4, 2019
    Configuration menu
    Copy the full SHA
    92c78f4 View commit details
    Browse the repository at this point in the history
  2. chore: appease linter

    License: MIT
    Signed-off-by: Alan Shaw <[email protected]>
    Alan Shaw committed Jul 4, 2019
    Configuration menu
    Copy the full SHA
    4c5e3b3 View commit details
    Browse the repository at this point in the history