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

Ability to add a nonce to the script tag #31

Open
sneko opened this issue Mar 8, 2024 · 4 comments
Open

Ability to add a nonce to the script tag #31

sneko opened this issue Mar 8, 2024 · 4 comments

Comments

@sneko
Copy link

sneko commented Mar 8, 2024

Hi @valeriansaliou ,

Due to third-party tools usage I have to set a nonce to my server page to load their script and bypass using CORP/COEP headers since I cannot customize them on those tools responses.

Would you consider adding the ability to customize the script attributes you create with load()?

crisp-sdk-web/src/index.ts

Lines 192 to 197 in cc3c7fb

const _script = document.createElement("script");
_script.src = this.clientUrl;
_script.async = true;
_head[0].appendChild(_script);

Thank you,

@sneko
Copy link
Author

sneko commented Mar 12, 2024

@valeriansaliou any example of a Crisp client succeeding in configuring Content Security Policy (CSP)?

I tried to modify locally your library to accept a nonce, but the client.js script downloaded from the one having the nonce is trying to deal with inline style which triggers the CSP.

Any response would be appreciated, thank you,

@valeriansaliou
Copy link
Member

valeriansaliou commented Mar 12, 2024

Hello @sneko, this is unfortunately not yet supported in the Crisp chatbox itself, since, as far as I understand how nonces work, we'd need to pass the nonce to all created inline elements (scripts and styles) from the chatbox loader. Given how we currently load our chatbox resources, this will require direct work on the global chatbox loader code, in addition to this SDK library.

I'm keeping this open so that we can add this to our roadmap.

@setvik
Copy link

setvik commented Apr 16, 2024

Alternatively, is it possible to remove the need for inline styles, i.e. so that we don't need to put "unsafe-inline" in the "style-src" CSP directive?

@valeriansaliou
Copy link
Member

Inline styles are needed for the chatbox per-website themes to work correctly, there’s no way we can do it otherwise unfortunately.

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

No branches or pull requests

3 participants