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

Can't use this library in Chrome Extensions #271

Open
Czino opened this issue Sep 17, 2024 · 3 comments
Open

Can't use this library in Chrome Extensions #271

Czino opened this issue Sep 17, 2024 · 3 comments

Comments

@Czino
Copy link

Czino commented Sep 17, 2024

As mentioned in Morglod/tseep#23 I encounter a runtime error which comes from the tseep library

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)
@Czino
Copy link
Author

Czino commented Sep 17, 2024

Quickfix is moving to eventemitter3 library (for now). I haven't tested if it is fully compatible but the functionality I need works so far.

...
  "overrides": {
    "@nostr-dev-kit/ndk": {
      "tseep": "npm:eventemitter3@5.0.1"
    }
  }
...

@Morglod
Copy link

Morglod commented Sep 18, 2024

I will add fallback for this case in nearest time

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

@Morglod
Copy link

Morglod commented Sep 26, 2024

Just added fallback and no-eval version in tseep

Change is pretty simple (fallback may take more bundle size, but safe version is still very fast):

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

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

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