nuxt-kirby 4.1.0 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json
CHANGED
|
@@ -4,7 +4,8 @@ import { defineCachedFunction } from "nitropack/runtime";
|
|
|
4
4
|
import { hash } from "ohash";
|
|
5
5
|
import { base64ToUint8Array, uint8ArrayToBase64, uint8ArrayToString } from "uint8array-extras";
|
|
6
6
|
import { useRuntimeConfig } from "#imports";
|
|
7
|
-
import { createAuthHeader } from "../utils.js";
|
|
7
|
+
import { createAuthHeader, headersToObject } from "../utils.js";
|
|
8
|
+
import { assertPathBelowBase } from "./path.js";
|
|
8
9
|
const EXCLUDED_HEADERS = /* @__PURE__ */ new Set([
|
|
9
10
|
// https://github.com/h3js/h3/blob/fe9800bbbe9bda2972cc5d11db7353f4ab70f0ba/src/utils/proxy.ts#L97
|
|
10
11
|
"content-encoding",
|
|
@@ -76,7 +77,7 @@ function createCachedFetcher(kirby) {
|
|
|
76
77
|
let cachedFetcher;
|
|
77
78
|
export default defineEventHandler(async (event) => {
|
|
78
79
|
const kirby = useRuntimeConfig(event).kirby;
|
|
79
|
-
const body = await readBody(event);
|
|
80
|
+
const body = await readBody(event) ?? {};
|
|
80
81
|
const key = decodeURIComponent(getRouterParam(event, "key"));
|
|
81
82
|
const isQueryRequest = key.startsWith("$kql");
|
|
82
83
|
if (isQueryRequest) {
|
|
@@ -87,17 +88,27 @@ export default defineEventHandler(async (event) => {
|
|
|
87
88
|
});
|
|
88
89
|
}
|
|
89
90
|
} else {
|
|
90
|
-
if (
|
|
91
|
+
if (typeof body.path !== "string") {
|
|
91
92
|
throw createError({
|
|
92
93
|
statusCode: 400,
|
|
93
|
-
statusMessage: "
|
|
94
|
+
statusMessage: "Path must be a string"
|
|
94
95
|
});
|
|
95
96
|
}
|
|
97
|
+
assertPathBelowBase(body.path);
|
|
98
|
+
}
|
|
99
|
+
let headers;
|
|
100
|
+
try {
|
|
101
|
+
headers = headersToObject(body.headers ?? void 0);
|
|
102
|
+
} catch {
|
|
103
|
+
throw createError({
|
|
104
|
+
statusCode: 400,
|
|
105
|
+
statusMessage: "Headers are invalid"
|
|
106
|
+
});
|
|
96
107
|
}
|
|
97
108
|
const forwardCookies = body.forwardCookies ?? kirby.forwardCookies;
|
|
98
109
|
try {
|
|
99
110
|
let response;
|
|
100
|
-
const request = {
|
|
111
|
+
const request = { ...body, headers, isQueryRequest, forwardCookies };
|
|
101
112
|
if (kirby.server.cache && !forwardCookies) {
|
|
102
113
|
cachedFetcher ??= createCachedFetcher(kirby);
|
|
103
114
|
const cached = await cachedFetcher(event, request);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throws a 400 for a path that a URL parser or the server behind the Kirby URL could read as absolute
|
|
3
|
+
* or as climbing above it: a scheme, an authority, a tab or line break, or a `..` segment, also
|
|
4
|
+
* percent-encoded or with a `;` parameter.
|
|
5
|
+
*/
|
|
6
|
+
export declare function assertPathBelowBase(path: string): void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createError } from "h3";
|
|
2
|
+
export function assertPathBelowBase(path) {
|
|
3
|
+
const segments = path.split("?", 1)[0].replace(/%2e/gi, ".").replace(/%3b/gi, ";").split(/[/\\#]|%2f|%5c/i);
|
|
4
|
+
if (/[\t\n\r\u2028\u2029]/.test(path) || /^[^/?#]*:/.test(path) || /^[\s\u0000-\u001F]*(?:[/\\]\s*){2}/.test(path) || segments.some((segment) => /^\.\.(?:;|[\u0000-\u0020]*$)/.test(segment))) {
|
|
5
|
+
throw createError({
|
|
6
|
+
statusCode: 400,
|
|
7
|
+
statusMessage: "Path must stay below the Kirby URL"
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-kirby",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.1.
|
|
5
|
-
"packageManager": "pnpm@11.20.0",
|
|
4
|
+
"version": "4.1.1",
|
|
6
5
|
"description": "Kirby CMS data in Nuxt, via KQL or the REST API",
|
|
7
6
|
"author": "Johann Schopplich <hello@johannschopplich.com>",
|
|
8
7
|
"license": "MIT",
|
|
@@ -15,11 +14,11 @@
|
|
|
15
14
|
"url": "https://github.com/johannschopplich/nuxt-kirby/issues"
|
|
16
15
|
},
|
|
17
16
|
"keywords": [
|
|
18
|
-
"getkirby",
|
|
19
17
|
"kirby",
|
|
20
|
-
"
|
|
18
|
+
"kirby-cms",
|
|
19
|
+
"getkirby",
|
|
21
20
|
"nuxt",
|
|
22
|
-
"
|
|
21
|
+
"kql"
|
|
23
22
|
],
|
|
24
23
|
"sideEffects": false,
|
|
25
24
|
"exports": {
|
|
@@ -33,25 +32,11 @@
|
|
|
33
32
|
"files": [
|
|
34
33
|
"dist"
|
|
35
34
|
],
|
|
36
|
-
"scripts": {
|
|
37
|
-
"prepack": "nuxt-module-build build",
|
|
38
|
-
"dev": "nuxt dev playground",
|
|
39
|
-
"dev:build": "nuxt build playground",
|
|
40
|
-
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground && nuxt prepare test/fixture",
|
|
41
|
-
"docs:dev": "pnpm --filter docs run dev",
|
|
42
|
-
"docs:build": "pnpm --filter docs run build",
|
|
43
|
-
"docs:preview": "pnpm --filter docs run preview",
|
|
44
|
-
"lint": "eslint .",
|
|
45
|
-
"lint:fix": "eslint . --fix",
|
|
46
|
-
"test": "vitest",
|
|
47
|
-
"test:types": "tsc --noEmit",
|
|
48
|
-
"release": "bumpp"
|
|
49
|
-
},
|
|
50
35
|
"dependencies": {
|
|
51
36
|
"@nuxt/kit": "^4.5.2",
|
|
52
37
|
"defu": "^6.1.7",
|
|
53
38
|
"destr": "^2.0.5",
|
|
54
|
-
"kirby-types": "^1.
|
|
39
|
+
"kirby-types": "^1.8.1",
|
|
55
40
|
"ofetch": "^1.5.1",
|
|
56
41
|
"ohash": "^2.0.11",
|
|
57
42
|
"pathe": "^2.0.3",
|
|
@@ -72,5 +57,18 @@
|
|
|
72
57
|
"srvx": "^0.12.5",
|
|
73
58
|
"typescript": "^6.0.3",
|
|
74
59
|
"vitest": "^4.1.10"
|
|
60
|
+
},
|
|
61
|
+
"scripts": {
|
|
62
|
+
"dev": "nuxt dev playground",
|
|
63
|
+
"dev:build": "nuxt build playground",
|
|
64
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground && nuxt prepare test/fixture",
|
|
65
|
+
"docs:dev": "pnpm --filter docs run dev",
|
|
66
|
+
"docs:build": "pnpm --filter docs run build",
|
|
67
|
+
"docs:preview": "pnpm --filter docs run preview",
|
|
68
|
+
"lint": "eslint .",
|
|
69
|
+
"lint:fix": "eslint . --fix",
|
|
70
|
+
"test": "vitest",
|
|
71
|
+
"test:types": "tsc --noEmit",
|
|
72
|
+
"release": "bumpp"
|
|
75
73
|
}
|
|
76
|
-
}
|
|
74
|
+
}
|