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

visitor[(override || node.type)] is not a function #2057

Open
PanagiotisDrakatos opened this issue Mar 31, 2023 · 0 comments
Open

visitor[(override || node.type)] is not a function #2057

PanagiotisDrakatos opened this issue Mar 31, 2023 · 0 comments

Comments

@PanagiotisDrakatos
Copy link

i am running the browserify via command line
browserify src/crypto/Mnemonic.js -p esmify --standalone mnembundle > src/bundle/MnemonicBundle.js
but i receive this error:

Error: Parsing file C:\Users\User\Documents\GitHub\AdrestusWallet\frontend-react-basic-app\src\crypto\Mnemonic.js: visitor[(override || node.type)] is not a function
    at Deps.parseDeps (C:\Users\User\AppData\Roaming\npm\node_modules\browserify\node_modules\module-deps\index.js:519:15)
    at getDeps (C:\Users\User\AppData\Roaming\npm\node_modules\browserify\node_modules\module-deps\index.js:447:44)
    at C:\Users\User\AppData\Roaming\npm\node_modules\browserify\node_modules\module-deps\index.js:430:38
    at ConcatStream.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\browserify\node_modules\concat-stream\index.js:37:43)
    at ConcatStream.emit (node:events:525:35)
    at finishMaybe (C:\Users\User\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_writable.js:630:14)
    at endWritable (C:\Users\User\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_writable.js:638:3)
    at Writable.end (C:\Users\User\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_writable.js:594:22)
    at DuplexWrapper.onend (C:\Users\User\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_readable.js:577:10)
    at Object.onceWrapper (node:events:627:28)

This is my whole code script:

var crypto = require('crypto')
var secureRandom = require('secure-random')
var Util=require("./Util.js")

const ALGORITHM='SHA-512'
module.exports =class Mnemonic{
    #SALT_CHARS ;
    #WordList;

    #Strength
    constructor(Strength) {
        this.hash = crypto.createHash('sha256');
        this.#Strength=Strength;
        this.#SALT_CHARS = Buffer.from(['m', 'n', 'e', 'm', 'o', 'n', 'i', 'c'])
        this.#WordList=["abandon", "ability", "able", "about"];
    }


    createSeed(mnemonic,passphrase){
      if(passphrase==null){
          throw new Error("Passphrase should not be null! Please enter a valid password");
      }
      let buffer_passphrase=Buffer.from(passphrase)
      let SALT=Buffer.concat([this.#SALT_CHARS,buffer_passphrase],this.#SALT_CHARS.length+buffer_passphrase.length);
      let derivedKey=crypto.pbkdf2Sync(mnemonic, SALT, 2048, 512, ALGORITHM);
      return derivedKey.toString('hex');
    }

    create(){
        let bytes = secureRandom.randomBuffer(this.#Strength);
        let hashbits=this.hash.update(bytes).digest();
        let binaryHash = Util.bytesToBinaryAsChars(hashbits).slice(0,this.#Strength);
        let checksum=Util.charSubarray(binaryHash,0,(bytes.length/8)*8/32)
        let entropyBits = Util.bytesToBinaryAsChars(bytes).slice(0,this.#Strength);
        let concatenatedBits=entropyBits.concat(checksum);

        var mnemonicBuilder=""
        for (let index = 0; index< concatenatedBits.length/11; ++index) {
            let startIndex = index * 11;
            let endIndex = startIndex + 11;
            let wordIndexAsChars=Array(endIndex-startIndex);
            Util.arrayCopy(concatenatedBits,startIndex,wordIndexAsChars,0,wordIndexAsChars.length)
            let wordIndex=Util.binaryCharsToInt(wordIndexAsChars);
            mnemonicBuilder+=this.#WordList[wordIndex]+' ';
        }
       return mnemonicBuilder.trim().split(' ');
    }
}

Any help how to resolve visitor[(override || node.type)] is not a function is this a bug?

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

No branches or pull requests

1 participant