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

[verifier] fails to work in NodeJS #23

Open
remyroy opened this issue Sep 26, 2022 · 1 comment
Open

[verifier] fails to work in NodeJS #23

remyroy opened this issue Sep 26, 2022 · 1 comment

Comments

@remyroy
Copy link

remyroy commented Sep 26, 2022

@gitcoinco/passport-sdk-verifier fails to work under NodeJS because of the @spruceid/didkit-wasm dependency. According to the documentation on https://www.npmjs.com/package/@spruceid/didkit-wasm-node, you need to use the @spruceid/didkit-wasm-node package instead.

I was getting this error message when I tried:

$ yarn run test
/home/remyroy/Projects/ethstaker-discord-bot/.yarn/cache/@spruceid-didkit-wasm-npm-0.2.1-1bec27787d-53d5fb9ab0.zip/node_modules/@spruceid/didkit-wasm/didkit_wasm.js:1
import * as wasm from "./didkit_wasm_bg.wasm";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:360:18)
    at wrapSafe (node:internal/modules/cjs/loader:1055:15)
    at Module._compile (node:internal/modules/cjs/loader:1090:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Object.require$$0.Module._extensions..js (/home/remyroy/Projects/ethstaker-discord-bot/.pnp.cjs:14394:33)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.require$$0.Module._load (/home/remyroy/Projects/ethstaker-discord-bot/.pnp.cjs:14234:14)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/remyroy/Projects/ethstaker-discord-bot/.yarn/cache/@gitcoinco-passport-sdk-verifier-npm-0.2.1-8807a49570-df97f50af3.zip/node_modules/@gitcoinco/passport-sdk-verifier/dist/verifier.js:74:27)

I did some tests in my own fork on https://github.com/remyroy/passport-sdk/tree/nodejs-fix and it fixed my issues when running under NodeJS.

To make this reliable and working in both NodeJS and the browser, it might be needed to polyfill the path and fs packages if you want to depend on that @spruceid/didkit-wasm-node package.

@nutrina
Copy link
Collaborator

nutrina commented Sep 27, 2022

Hello. Thanks for the input. I think we should also add an example for how to use the SDKs on node, to avoid other users having this issue.
We'll look into your fix.

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

No branches or pull requests

2 participants