Code Monkey home page Code Monkey logo

Comments (7)

lmm-git avatar lmm-git commented on August 24, 2024 3

Even more, this prevents us from not using 'unsafe-eval' in our Content Security Policy. Any chance that this one get fixed?

from js-sha256.

gmiklich avatar gmiklich commented on August 24, 2024 2

Can it be changed to a dynamic import or anything along those lines to avoid the use of eval()?

from js-sha256.

ivands avatar ivands commented on August 24, 2024 1

It also breaks in vitejs. We need a fix.

from js-sha256.

emn178 avatar emn178 commented on August 24, 2024 1

remove eval in v0.10.0

from js-sha256.

emn178 avatar emn178 commented on August 24, 2024

This is because emn178/js-md5#8
And I found it won't polyfill unused code in this way.

from js-sha256.

hansottowirtz avatar hansottowirtz commented on August 24, 2024

As a fix, you can replace the eval strings in the library during build.
In rollup.config.js:

import replace from "rollup-plugin-re";

export default {
  ...,
  plugins: [
    replace({
      patterns: [
        {
          match: /js-sha256/,
          test: `eval("require('crypto')")`,
          replace: `require('crypto')`
        },
        {
          match: /js-sha256/,
          test: `eval("require('buffer').Buffer")`,
          replace: `require('buffer').Buffer`
        }
      ],
    }),
  ]
}

from js-sha256.

juhoha avatar juhoha commented on August 24, 2024

An alternative to suppress warnings in vite.config.js:

export default defineConfig({
  build: {
    rollupOptions: {
      onwarn: ({ loc }) => {
        if (loc?.file?.match(/js-sha256\/src\/sha256.js$/))
            return;
      } 
  }
});

from js-sha256.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.