Skip to content

Commit e99e8bf

Browse files
authored
Merge branch 'sveltejs:main' into main
2 parents bc9c044 + 6033acb commit e99e8bf

32 files changed

+280
-238
lines changed

.changeset/eleven-papayas-share.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
chore: make config deprecation warnings more visible

.changeset/weak-clouds-tell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
chore: deprecate `csrf.checkOrigin` in favour of `csrf.trustedOrigins: ['*']`

packages/kit/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @sveltejs/kit
22

3+
## 2.36.1
4+
### Patch Changes
5+
6+
7+
- fix: ensure importing from `$app/navigation` works in test files ([#14195](https://github.com/sveltejs/kit/pull/14195))
8+
39
## 2.36.0
410
### Minor Changes
511

packages/kit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sveltejs/kit",
3-
"version": "2.36.0",
3+
"version": "2.36.1",
44
"description": "SvelteKit is the fastest way to build Svelte apps",
55
"keywords": [
66
"framework",

packages/kit/src/core/config/options.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import process from 'node:process';
2+
import colors from 'kleur';
23

34
/** @typedef {import('./types.js').Validator} Validator */
45

@@ -108,7 +109,11 @@ const options = object(
108109
}),
109110

110111
csrf: object({
111-
checkOrigin: boolean(true),
112+
checkOrigin: deprecate(
113+
boolean(true),
114+
(keypath) =>
115+
`\`${keypath}\` has been deprecated in favour of \`csrf.trustedOrigins\`. It will be removed in a future version`
116+
),
112117
trustedOrigins: string_array([])
113118
}),
114119

@@ -323,7 +328,7 @@ function deprecate(
323328
) {
324329
return (input, keypath) => {
325330
if (input !== undefined) {
326-
console.warn(get_message(keypath));
331+
console.warn(colors.bold().yellow(get_message(keypath)));
327332
}
328333

329334
return fn(input, keypath);

packages/kit/src/core/sync/write_server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { set_private_env, set_public_env } from '${runtime_directory}/shared-ser
3737
export const options = {
3838
app_template_contains_nonce: ${template.includes('%sveltekit.nonce%')},
3939
csp: ${s(config.kit.csp)},
40-
csrf_check_origin: ${s(config.kit.csrf.checkOrigin)},
40+
csrf_check_origin: ${s(config.kit.csrf.checkOrigin && !config.kit.csrf.trustedOrigins.includes('*'))},
4141
csrf_trusted_origins: ${s(config.kit.csrf.trustedOrigins)},
4242
embedded: ${config.kit.embedded},
4343
env_public_prefix: '${config.kit.env.publicPrefix}',

packages/kit/src/exports/public.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,14 +426,17 @@ export interface KitConfig {
426426
*
427427
* 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!
428428
* @default true
429+
* @deprecated Use `trustedOrigins: ['*']` instead
429430
*/
430431
checkOrigin?: boolean;
431432
/**
432-
* An array of origins that are allowed to make cross-origin form submissions to your app, even when `checkOrigin` is `true`.
433+
* An array of origins that are allowed to make cross-origin form submissions to your app.
433434
*
434435
* Each origin should be a complete origin including protocol (e.g., `https://payment-gateway.com`).
435436
* This is useful for allowing trusted third-party services like payment gateways or authentication providers to submit forms to your app.
436437
*
438+
* If the array contains `'*'`, all origins will be trusted. This is generally not recommended!
439+
*
437440
* **Warning**: Only add origins you completely trust, as this bypasses CSRF protection for those origins.
438441
* @default []
439442
* @example ['https://checkout.stripe.com', 'https://accounts.google.com']

packages/kit/src/runtime/client/client.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,10 @@ let target;
185185
export let app;
186186

187187
/** @type {Record<string, any>} */
188-
export const remote_responses = __SVELTEKIT_PAYLOAD__.data ?? {};
188+
// we have to conditionally access the properties of `__SVELTEKIT_PAYLOAD__`
189+
// because it will be `undefined` when users import the exports from this module.
190+
// It's only defined when the server renders a page.
191+
export const remote_responses = __SVELTEKIT_PAYLOAD__?.data ?? {};
189192

190193
/** @type {Array<((url: URL) => boolean)>} */
191194
const invalidated = [];

packages/kit/src/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// generated during release, do not modify
22

33
/** @type {string} */
4-
export const VERSION = '2.36.0';
4+
export const VERSION = '2.36.1';

packages/kit/test/apps/basics/package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,28 @@
88
"preview": "vite preview",
99
"prepare": "svelte-kit sync",
1010
"check": "svelte-kit sync && tsc && svelte-check",
11-
"test": "node test/setup.js && pnpm test:dev && pnpm test:build",
11+
"test": "node test/setup.js && pnpm test:unit && pnpm test:dev && pnpm test:build",
1212
"test:dev": "rm -rf test/errors.json && DEV=true playwright test",
1313
"test:build": "rm -rf test/errors.json && PUBLIC_PRERENDERING=false playwright test",
1414
"test:cross-platform:dev": "node test/setup.js && rm -rf test/errors.json && DEV=true playwright test test/cross-platform/",
1515
"test:cross-platform:build": "node test/setup.js && rm -rf test/errors.json && playwright test test/cross-platform/",
1616
"test:server-side-route-resolution:dev": "node test/setup.js && rm -rf test/errors.json && DEV=true ROUTER_RESOLUTION=server playwright test",
17-
"test:server-side-route-resolution:build": "node test/setup.js && rm -rf test/errors.json && PUBLIC_PRERENDERING=false ROUTER_RESOLUTION=server playwright test"
17+
"test:server-side-route-resolution:build": "node test/setup.js && rm -rf test/errors.json && PUBLIC_PRERENDERING=false ROUTER_RESOLUTION=server playwright test",
18+
"test:unit": "vitest run"
1819
},
1920
"devDependencies": {
2021
"@opentelemetry/api": "^1.9.0",
2122
"@opentelemetry/sdk-node": "^0.203.0",
2223
"@opentelemetry/sdk-trace-node": "^2.0.1",
2324
"@sveltejs/kit": "workspace:^",
2425
"@sveltejs/vite-plugin-svelte": "catalog:",
26+
"@vitest/browser": "^3.2.4",
2527
"svelte": "^5.35.5",
2628
"svelte-check": "^4.1.1",
2729
"test-redirect-importer": "workspace:*",
2830
"typescript": "^5.5.4",
29-
"vite": "catalog:"
31+
"vite": "catalog:",
32+
"vitest": "catalog:"
3033
},
3134
"type": "module"
3235
}

0 commit comments

Comments
 (0)