web-monetization-extension icon indicating copy to clipboard operation
web-monetization-extension copied to clipboard

chore(build): replace crypto-browserify with native WebCrypto wrapper…

Open adityagupta0251 opened this issue 2 months ago • 1 comments

This PR replaces the crypto-browserify bundling shim with a tiny, local wrapper that uses the browser's native Web Crypto API.

Why:

  • removes large / outdated dependency (dependabot alerts)
  • reduces bundle size
  • uses native, audited WebCrypto APIs

What I changed:

  • build plugin now resolves crypto to src/utils/browserCrypto.ts
  • added src/utils/browserCrypto.ts (minimal wrapper)

Notes:

  • Tests and build should be run on CI to verify there are no unexpected runtime changes.
  • If code paths rely on Node-only crypto features, please point them out and we can add wrapper implementations.

Closes #1206

adityagupta0251 avatar Oct 18 '25 12:10 adityagupta0251

@adityagupta0251 Thanks for beginning this work. The harder part of this initiative is in fact replacing the node:crypto usage in dependencies (in particular, open-payments and its dependencies) with a custom crypto layer - that's why the esbuild process was resolving crpyto to crypto-browserify. We essentially want to create crypto-browserify (but thinner layer), by using existing SubtleCrypto APIs.

To continue forward with this task, I'd encourage you to set up the extension locally. Skimming the developers guide would be helpful there. The build/install instructions are available as well.

To avoid testing manually, you likely want to go through the E2E testing guide. For this specific case, successfully running connect.spec.ts locally would be enough - then we can check rest in CI. (Don't forget to pnpm build chrome each time before running E2E tests (pnpm test:e2e:chromium connect.spec)).

sidvishnoi avatar Oct 19 '25 09:10 sidvishnoi

@adityagupta0251 Do you plan to continue working on this?

sidvishnoi avatar Nov 24 '25 10:11 sidvishnoi

Yes 🙌 I'm happy for further 🤝

adityagupta0251 avatar Nov 24 '25 16:11 adityagupta0251

Here's also some of enhancement I need to work on

adityagupta0251 avatar Nov 24 '25 16:11 adityagupta0251