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

Use ffjavascript with chrome extension #132

Open
0xmad opened this issue Oct 26, 2023 · 4 comments
Open

Use ffjavascript with chrome extension #132

0xmad opened this issue Oct 26, 2023 · 4 comments

Comments

@0xmad
Copy link

0xmad commented Oct 26, 2023

Hello, we are developing browser extension and have ffjavascript and a dependency in our node modules.
We have chrome extension manifest v3 and it's not possible to spawn a web worker inside service worker so we had to fork this repo to fix it https://github.com/CryptKeeperZK/ffjavascript.
For now this solution works only for browser and fails for node.

Is it possible to add support for extensions? I can create a PR for this case but first I'd like to hear the feedback or maybe there is some other solution to make it works.

@OBrezhniev
Copy link
Member

Hello @0xmad, please check if new release fixes your issue. There were fixes in this part of code. Also there's now new ESM build for browsers.

@0xmad
Copy link
Author

0xmad commented Nov 1, 2023

@OBrezhniev thanks but our dependencies have v0.2.59 and I'm not sure if ESM will help here.
The main issue: it's not possible to spawn workers inside service worker.
Here is the solution for our case in our fork https://github.com/iden3/ffjavascript/compare/master...CryptKeeperZK:ffjavascript:master?expand=1#diff-0462ab1425fcb10bd181dc4f7513067635628058d4c1d851666e2b10a64ec2f4R115-R130 but it's not flexible (works only with browser) and we need to fork every package which has ffjavascript dependency.

@0xisk
Copy link

0xisk commented Nov 2, 2023

Thanks @OBrezhniev for replying back on this. I just wanted to add more details. In developing Crypt-Keeper browser extension in MV3 (https://github.com/CryptKeeperZK/crypt-keeper-extension) We had this error Reference Error: Worker is not defined

Error

And because ffjavascript is a dependency for snarkjs we had to fork and then for all the packages that is using snarkjs:

@vmidyllic
Copy link

you can make a workaround for workers without forking as in this example https://github.com/0xPolygonID/extension-demo/pull/14/files

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

4 participants