Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gentle-radios-go.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': major
---

breaking: remove the deprecated CSRF `checkOrigin` option in favor of `trustedOrigins`
5 changes: 3 additions & 2 deletions packages/kit/src/core/config/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const get_defaults = (prefix = '') => ({
reportOnly: directive_defaults
},
csrf: {
checkOrigin: true,
checkOrigin: undefined,
trustedOrigins: []
},
embedded: false,
Expand Down Expand Up @@ -100,13 +100,14 @@ const get_defaults = (prefix = '') => ({
},
inlineStyleThreshold: 0,
moduleExtensions: ['.js', '.ts'],
output: { bundleStrategy: 'split' },
output: { bundleStrategy: 'split', preloadStrategy: undefined },
outDir: join(prefix, '.svelte-kit'),
router: {
type: 'pathname',
resolution: 'client'
},
serviceWorker: {
options: undefined,
register: true
},
typescript: {},
Expand Down
24 changes: 20 additions & 4 deletions packages/kit/src/core/config/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,8 @@ const options = object(
}),

csrf: object({
checkOrigin: deprecate(
boolean(true),
(keypath) =>
`\`${keypath}\` has been deprecated in favour of \`csrf.trustedOrigins\`. It will be removed in a future version`
checkOrigin: removed(
(keypath) => `\`${keypath}\` has been removed in favour of \`csrf.trustedOrigins\``
),
trustedOrigins: string_array([])
}),
Expand Down Expand Up @@ -159,6 +157,9 @@ const options = object(
outDir: string('.svelte-kit'),

output: object({
preloadStrategy: removed(
(keypath) => `\`${keypath}\` has been removed. modulepreload will always be used`
),
bundleStrategy: list(['split', 'single', 'inline'])
}),

Expand Down Expand Up @@ -335,6 +336,21 @@ function deprecate(
};
}

/**
* @param {(keypath: string) => string} get_message
* @returns {Validator}
*/
function removed(
get_message = (keypath) =>
`The \`${keypath}\` option has been removed. Please see the list of breaking changes for your major release`
) {
return (input, keypath) => {
if (typeof input !== 'undefined') {
throw new Error(get_message(keypath));
}
};
}

/**
* @param {Record<string, Validator>} children
* @param {boolean} [allow_unknown]
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/core/sync/write_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const options = {
app_template_contains_nonce: ${template.includes('%sveltekit.nonce%')},
async: ${s(!!config.compilerOptions?.experimental?.async)},
csp: ${s(config.kit.csp)},
csrf_check_origin: ${s(config.kit.csrf.checkOrigin && !config.kit.csrf.trustedOrigins.includes('*'))},
csrf_check_origin: ${s(!config.kit.csrf.trustedOrigins.includes('*'))},
csrf_trusted_origins: ${s(config.kit.csrf.trustedOrigins)},
embedded: ${config.kit.embedded},
env_public_prefix: '${config.kit.env.publicPrefix}',
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/src/exports/public.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ export interface KitConfig {
*
* To allow people to make `POST`, `PUT`, `PATCH`, or `DELETE` requests with a `Content-Type` of `application/x-www-form-urlencoded`, `multipart/form-data`, or `text/plain` to your app from other origins, you will need to disable this option. Be careful!
* @default true
* @deprecated Use `trustedOrigins: ['*']` instead
* @deprecated removed in 3.0. Use `trustedOrigins: ['*']` instead
*/
checkOrigin?: boolean;
/**
Expand Down
1 change: 0 additions & 1 deletion packages/kit/test/apps/basics/svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ const config = {
},

csrf: {
checkOrigin: true,
trustedOrigins: ['https://trusted.example.com', 'https://payment-gateway.test']
},

Expand Down
2 changes: 1 addition & 1 deletion packages/kit/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ declare module '@sveltejs/kit' {
*
* To allow people to make `POST`, `PUT`, `PATCH`, or `DELETE` requests with a `Content-Type` of `application/x-www-form-urlencoded`, `multipart/form-data`, or `text/plain` to your app from other origins, you will need to disable this option. Be careful!
* @default true
* @deprecated Use `trustedOrigins: ['*']` instead
* @deprecated removed in 3.0. Use `trustedOrigins: ['*']` instead
*/
checkOrigin?: boolean;
/**
Expand Down
Loading