feat: add CSP nonce support to GustoProvider#2191
Draft
jeffredodd wants to merge 3 commits into
Draft
Conversation
Adds an optional `nonce` prop to `GustoProvider` and
`GustoProviderCustomUIAdapter` so partners with a strict
`style-src 'nonce-…'` Content Security Policy can run the SDK without
relaxing to `unsafe-inline`. The nonce is applied to both runtime
`<style>` injection sites (the ThemeProvider variables element and the
paystub PDF download window's loading-spinner element), and exposed to
custom UI components via a new `useNonce` hook.
Also extracts three static inline `style={{…}}` attributes (Card,
Toast, DocumentSigner List) to CSS modules so they no longer require
`style-src-attr 'unsafe-inline'`. The remaining inline-style surface
(`Flex`/`Grid`/`ProgressBar`/`ReorderableList` runtime CSS custom
properties, plus `react-aria-components` overlay positioning) is
documented in the partner CSP guide.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- prettier: collapse multi-line querySelector in ThemeProvider test - tsdoc-coverage: reorder useNonce tags so @example is the final group - markdownlint: add language tag to CSP example fenced block Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
nonceprop toGustoProvider/GustoProviderCustomUIAdapter. The nonce flows through a newNonceContextand is applied to both runtime<style>elements the SDK creates: the theme-variables element inThemeProvider, and the loading-spinner element injected into the paystub PDF download window.useNoncehook so partners using custom UI can plumb the same nonce into any<style>or<script>they inject themselves.style={{…}}attributes (Card,Toast,DocumentSigner/List) to CSS modules, so they no longer requirestyle-src-attr 'unsafe-inline'.Flex/Grid/ProgressBar/ReorderableListruntime CSS custom properties, plusreact-aria-componentsoverlay positioning) underdocs/getting-started/proxy-security-partner-guidance.md.Why
Partners running a strict nonce-based CSP can't use the SDK today — the theme
<style>and paystub-popup<style>tags are dropped by the browser without'unsafe-inline'. After this change, the onlystyle-srcrelaxation a partner needs isstyle-src-attr 'unsafe-inline', which is forced by the CSP spec (no per-attribute nonces) and byreact-aria-components.Test plan
npm run test -- --run— 3110 pass, 1 expected fail (pre-existing).npm run build— clean build, types emit.useNoncereturns the value / undefined;ThemeProvidersets.nonceon the injected<style>;PaystubsCardsets.nonceon the popup<style>when one is provided.style-srcin the SDK dev app (reviewer please verify locally if you can).🤖 Generated with Claude Code