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: polyfill buffer, shim randombytes #286

Merged
merged 4 commits into from
May 9, 2024

Conversation

phanshiyu
Copy link
Contributor

@phanshiyu phanshiyu commented May 9, 2024

What

  1. remove direct use of crypto and instead use https://www.npmjs.com/package/randombytes, which uses native crypto methods based on environment
  2. use https://www.npmjs.com/package/buffer instead of relying on buffer from node env

Tested

  1. CRA - works out of the box
  2. React vite needs
// vite.config.ts
export default defineConfig({
  plugins: [react()],
  define: {
    // By default, Vite doesn't include shims for NodeJS/
    // necessary for segment analytics lib to work
    global: 'globalThis'
  },  
})
  1. next server side - out of the box
  2. next client side - have to install undici

@phanshiyu phanshiyu changed the base branch from master to alpha May 9, 2024 03:49
@phanshiyu phanshiyu changed the title Feat poly buffer randombytes Feat: poly buffer randombytes May 9, 2024
@phanshiyu phanshiyu changed the title Feat: poly buffer randombytes Feat: polyfill buffer, shim randombytes May 9, 2024
@phanshiyu phanshiyu changed the title Feat: polyfill buffer, shim randombytes fix: polyfill buffer, shim randombytes May 9, 2024
@phanshiyu phanshiyu merged commit 7a1e2f7 into alpha May 9, 2024
6 checks passed
@phanshiyu phanshiyu deleted the feat/poly-buffer-randombytes branch May 9, 2024 05:48
Copy link

github-actions bot commented May 9, 2024

🎉 This PR is included in version 6.10.0-alpha.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants