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

Bug report: node; SyntaxError: Unexpected identifier crypto-api #601

Closed
shellliii opened this issue Jul 22, 2019 · 4 comments
Closed

Bug report: node; SyntaxError: Unexpected identifier crypto-api #601

shellliii opened this issue Jul 22, 2019 · 4 comments
Labels

Comments

@shellliii
Copy link

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior or a link to the recipe / input used to cause the bug:

git clone https://github.com/gchq/cyberchef
cd cyberchef
npm install
grunt node

test.js:

var chef = require("cyberchef/build/node/CyberChef.js")
console.log(chef)
chef.default.bake("test", [{"op":"To Hex","args":["Space"]}]).then(r => { console.log(r) })

node test.js

cyberchef/node_modules/crypto-api/src/crypto-api.mjs:3
import Has160 from "./hasher/has160";
       ^^^^^^

SyntaxError: Unexpected identifier
    at Module._compile (internal/modules/cjs/loader.js:760:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
    at Module.load (internal/modules/cjs/loader.js:685:32)
    at Function.Module._load (internal/modules/cjs/loader.js:620:12)
    at Module.require (internal/modules/cjs/loader.js:723:19)
    at require (internal/modules/cjs/helpers.js:14:16)
    at eval (webpack://CyberChef/external_%22crypto-api/src/crypto-api.mjs%22?:1:18)
    at Object.crypto-api/src/crypto-api.mjs (cyberchef/build/node/CyberChef.js:5377:1)
    at __webpack_require__ (cyberchef/build/node/CyberChef.js:41:30)
    at eval (webpack://CyberChef/./src/core/lib/Hash.mjs?:4:87)

Expected behavior
test to hex gets executed

Desktop (if relevant, please complete the following information):

  • OS: linux
  • Browser node
  • Version v11.15.0
@shellliii shellliii added the bug label Jul 22, 2019
@d98762625
Copy link
Member

@shellliii please try with v9.0.5

@d98762625
Copy link
Member

Note a couple of things -

  • require("cyberchef") should now be enough, rather than explicit path (there is no 'build' version for node now)
  • bake is not async

This code worked for me n v11.15.0 in a new dir:

npm init (accept all defaults)
npm install --save cyberchef

vim test.js (with the following contents)

const chef = require("cyberchef")
const d = chef.bake("test", [{"op":"To Hex","args":["Space"]}])
console.log(d)

node test.js

@d98762625
Copy link
Member

Closing for now. Please reopen if you have any issues.

@fjh1997
Copy link
Contributor

fjh1997 commented Nov 25, 2019

I downgrade to node v10.0.0,and it works,the reason is here #596

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

No branches or pull requests

3 participants