coinbase / coinbase-wallet-sdk

An open protocol that lets users connect their mobile wallets to your DApp
https://coinbase.github.io/coinbase-wallet-sdk/
MIT License
1.4k stars 521 forks source link

replace sha.js with a smaller js-sha256 library #1336

Open talentlessguy opened 1 week ago

talentlessguy commented 1 week ago

Summary

Even though SHA-256 is only used in one place to just hash a session key, it pulls 2 irrelevant deps. This PR removes sha.js and replaces it with a more lightweight and maintained library: https://github.com/emn178/js-sha256.

I first wanted to go with using Web Crypto API, but the problem is that it would require a semver major bump because it's supported starting Node 15.

How did you test your changes?

All tests passed.

talentlessguy commented 1 week ago

Another option is using @noble/curves which are audited and used by most of Ethereum cryptography, but it would pull the code for the whole package, not just sha256