Skip to content

Commit 01466a0

Browse files
author
Vincent Dubois
committed
Add documentation
1 parent afd83d0 commit 01466a0

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export default defineConfig({
176176
- Replace the `html.cspNonce` from the vite.config.ts with the generated nonce
177177
- Replace `nonce-{RANDOM}` in CSP rules with `nonce-[generated-nonce]`
178178

179-
> ⚠️ `html.cspNonce` from the vite.config.ts will be overridden by the public in development mode
179+
> ⚠️ `html.cspNonce` from the vite.config.ts will be overridden by the plugin in development mode
180180
181181
This ensures that the same nonce is used for both the CSP headers and the HTML attributes, allowing specific inline scripts and styles to be executed while maintaining security.
182182

src/lib/csp-configuration-generation/CspConfigurationFileGeneration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const generateCspConfigurationFileForEnvironment = async <Environment ext
4242
rules: CspPolicies<Environment>,
4343
environment: Environment,
4444
): Promise<void> => {
45-
const directive: string = computeCspDirectiveForEnvironment(rules, environment);
45+
const directive: string = computeCspDirectiveForEnvironment<Environment>(rules, environment);
4646

4747
try {
4848
await mkdir('content-security-policy/configurations', { recursive: true });

src/lib/csp/ComputeOriginForEnvironment.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const computeOriginForEnvironment = <Environment extends string = never>(
2121

2222
/**
2323
* Generates a Content Security Policy (CSP) directive string based on provided
24-
* policies and the specified environment.
24+
* policies and the specified environment. If no environment is provided, the default directive is used.
2525
*
2626
* @template Environment - The type representing the environment. Defaults to `never`.
2727
* @param {CspPolicies<Environment>} policies - An object defining CSP policies, mapping
@@ -37,7 +37,7 @@ export const computeCspDirectiveForEnvironment = <Environment extends string = n
3737
return Object
3838
.entries(policies)
3939
.map(([directive, value]: [string, AuthorisedOrigins<Environment>]) => {
40-
const allowedOrigin: string = computeOriginForEnvironment(value, environment);
40+
const allowedOrigin: string = computeOriginForEnvironment<Environment>(value, environment);
4141
return `${directive} ${allowedOrigin}`;
4242
})
4343
.join('; ');

src/lib/plugins/CspProxyPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const cspProxyPlugin = <Environment extends string = never>(
5353
// Nonce configuration must be enabled in vite and in the plugin in order to work
5454
if ((!htmlNonce && !!noncesConfiguration) || (!!htmlNonce && !noncesConfiguration)) {
5555
console.error(
56-
'Configure the html.cspNonce value in vite.config.ts to enable the nonce template replacement in the HTML template. ',
56+
'Configure the html.cspNonce value in vite.config.ts to enable the nonce template replacement in the HTML template.',
5757
);
5858
}
5959

0 commit comments

Comments
 (0)