passport-sdk
passport-sdk copied to clipboard
[verifier] fails to work in NodeJS
@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.