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

[Chrome Extension] Uses eval for runtime codegenerations; don't be afraid of it #23

Closed
Czino opened this issue Sep 17, 2024 · 3 comments
Assignees

Comments

@Czino
Copy link

Czino commented Sep 17, 2024

I found that in the context of Chrome extensions, the CSP is much stricter and does not allow and cannot be further relaxed

EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 'wasm-unsafe-eval'".

    at bakeCollection (bake-collection.ts:116:34)

Therefore this package cannot be used as a dependency if you want to develop Chrome Extensions, it looks like Google Devs are afraid of it. Furthermore, I encountered this error because tseep is used as a sub dependency.

@Morglod
Copy link
Owner

Morglod commented Sep 18, 2024

@Czino will add fallback to it

As a workaround for now it could be sandboxed or unsafe-eval in manifest

@Czino
Copy link
Author

Czino commented Sep 18, 2024

While developing it's no problem to lax the security policy but unsafe-eval is not a valid configuration in the manifest

Thank you for your consideration in regards to the fallback.

@Morglod
Copy link
Owner

Morglod commented Sep 26, 2024

@Czino

Just added new version, please check it.

Change is pretty simple (fallback may take more bundle size):

// from
import { EventEmitter } from "tseep";

// to
import { EventEmitter } from "tseep/lib/ee-safe";
import { EventEmitter } from "tseep/lib/fallback"; // auto switch if eval is restricted

@Morglod Morglod self-assigned this Sep 26, 2024
@Morglod Morglod closed this as completed Oct 11, 2024
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