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

feat: bring your own web crypto #150

Closed
wants to merge 2 commits into from
Closed

Commits on Jul 9, 2019

  1. feat: bring your own web crypto

    Changes `webcrypto.js` to check for native web crypto availability and falls
    back to using `window.__crypto` if not available.
    
    If the user wants to bring their own Web Crypto API compatible implementation
    then they simply need to assign it to `window.__crypto` before they start using
    IPFS.
    
    Checks are done in the functions that require web crypto to give the user the
    flexibility to assign to `window.__crypto` before OR after they import
    `libp2p-crypto`. It also means that users have the ability to use other exported
    functions that do not require web crypto without having to worry about sorting
    their own implementation.
    
    We use `window.__crypto` because `window.crypto` is a readonly property in
    secure context and always readonly in workers.
    
    If `window.crypto` and `window.__cypto` are unavailable then an appropriate
    error message is reported to the user with a `ERR_MISSING_WEB_CRYPTO` code.
    
    I've also added documentation to the README.
    
    This is a backwards compatible change.
    
    closes #149
    resolves #105
    resolves ipfs/js-ipfs#2017
    resolves ipfs/js-ipfs#2153
    
    License: MIT
    Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
    Alan Shaw committed Jul 9, 2019
    Configuration menu
    Copy the full SHA
    357593f View commit details
    Browse the repository at this point in the history
  2. chore: appease linter

    License: MIT
    Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
    Alan Shaw committed Jul 9, 2019
    Configuration menu
    Copy the full SHA
    70002df View commit details
    Browse the repository at this point in the history