Skip to content

Conversation

@david-cho-lerat-sonarsource
Copy link
Contributor

No description provided.

@netlify
Copy link

netlify bot commented Nov 18, 2025

Deploy Preview for echoes-react ready!

Name Link
🔨 Latest commit 57a89f2
🔍 Latest deploy log https://app.netlify.com/projects/echoes-react/deploys/691c987a78e9cc0008b9f656
😎 Deploy Preview https://deploy-preview-560--echoes-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod bot changed the title Add CSP nonce support ECHOES-1025 Add CSP nonce support Nov 18, 2025
@hashicorp-vault-sonar-prod
Copy link

hashicorp-vault-sonar-prod bot commented Nov 18, 2025

ECHOES-1025

@sonarqube-next
Copy link

Comment on lines +30 to +33
// Create a singleton Emotion cache for all tests to ensure consistent class name generation
// This matches the key used in EchoesProvider when a nonce is provided
const testEmotionCache = createCache({ key: 'echoes' });
testEmotionCache.compat = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should that really be handled by Echoes? The CacheProvider is gonna change the behavior of emotion for the whole app, that should be setup at the app level not at Echoes level.

Comment on lines +126 to +137
// Create Emotion cache with nonce support for CSP compliance
// Use 'echoes' as the key for better namespace isolation and debugging
const emotionCache = useMemo(() => {
if (!nonce) {
return undefined;
}

const cache = createCache({ key: 'echoes', nonce });
cache.compat = true;

return cache;
}, [nonce]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the emotion cache provider shouldn't be handled by Echoes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's be a bit more explicite and call that CSPNonceContext?

*
* @returns The nonce string if configured, undefined otherwise
*/
export function useNonce(): string | undefined {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too let's be more explicit

Comment on lines +125 to +131
/**
* A nonce value for inline styles (Content Security Policy - CSP) (optional).
* In most cases, you should configure the nonce once in the EchoesProvider
* instead of passing it to individual components. This prop is only needed
* if you need to override the global nonce for this specific Spotlight instance.
*/
nonce?: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to provide that capability? You have a use case in mind?

Comment on lines +237 to +239
'sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU='
'sha256-qixoDh78J8vISHKC3rLI7qSXmTShr8mhsUgjJL7W7aU='
'sha256-3gJFr3n77fnX5qwQpGju/zCOsoHW5RMqQd5XOb9WFcA=';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you try this solution instead: emilkowalski/sonner#449 (comment) ?

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

Successfully merging this pull request may close these issues.

2 participants