nuxt-og-image 7.0.6 → 7.1.0
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/chunks/tw4.mjs +1 -2
- package/dist/chunks/uno.mjs +5 -3
- package/dist/content-valibot.d.mts +9 -0
- package/dist/content-valibot.d.ts +9 -0
- package/dist/content-valibot.mjs +11 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -2
- package/dist/runtime/app/client-utils.d.ts +1 -1
- package/dist/runtime/app/client-utils.js +27 -9
- package/dist/runtime/app/composables/_defineOgImageRaw.js +2 -3
- package/dist/runtime/app/utils.js +13 -5
- package/dist/runtime/server/og-image/bindings/font-assets/dev-prerender.js +4 -3
- package/dist/runtime/server/og-image/bindings/takumi/node-dev.d.ts +0 -2
- package/dist/runtime/server/og-image/bindings/takumi/node-dev.js +84 -59
- package/dist/runtime/server/og-image/bindings/takumi/node.d.ts +0 -2
- package/dist/runtime/server/og-image/bindings/takumi/node.js +1 -3
- package/dist/runtime/server/og-image/bindings/takumi/wasm.d.ts +0 -2
- package/dist/runtime/server/og-image/bindings/takumi/wasm.js +1 -3
- package/dist/runtime/server/og-image/core/plugins/imageSrc.js +5 -3
- package/dist/runtime/server/og-image/dev-font-state.d.ts +11 -0
- package/dist/runtime/server/og-image/dev-font-state.js +18 -0
- package/dist/runtime/server/og-image/devtools.js +2 -1
- package/dist/runtime/server/og-image/fonts.d.ts +9 -6
- package/dist/runtime/server/og-image/fonts.js +69 -38
- package/dist/runtime/server/og-image/satori/renderer.js +3 -3
- package/dist/runtime/server/og-image/satori/vnodes.js +2 -2
- package/dist/runtime/server/og-image/takumi/instances.d.ts +0 -2
- package/dist/runtime/server/og-image/takumi/instances.js +0 -3
- package/dist/runtime/server/og-image/takumi/renderer.js +89 -168
- package/dist/runtime/server/og-image/templates/html.js +2 -2
- package/dist/runtime/server/routes/debug.json.js +6 -6
- package/dist/runtime/server/routes/static-font.js +3 -3
- package/dist/runtime/server/signing-secret.js +19 -7
- package/dist/runtime/server/util/cloudflareAssets.js +1 -1
- package/dist/runtime/server/util/fetchLocalAsset.d.ts +1 -1
- package/dist/runtime/server/util/fetchLocalAsset.js +16 -10
- package/dist/shared/{nuxt-og-image.C4hc520M.mjs → nuxt-og-image.Dr6blNqj.mjs} +232 -100
- package/package.json +65 -52
- package/skills/nuxt-og-image/SKILL.md +2 -1
- package/types/virtual.d.ts +5 -0
- package/dist/runtime/server/og-image/bindings/takumi/resource-urls.d.ts +0 -2
- package/dist/runtime/server/og-image/bindings/takumi/resource-urls.js +0 -91
|
@@ -10,7 +10,7 @@ export async function tryCloudflareAssetsFetch(event, path, signal) {
|
|
|
10
10
|
return;
|
|
11
11
|
const origin = getRequestURL(event).origin;
|
|
12
12
|
const url = new URL(path, origin).href;
|
|
13
|
-
const res = await assets.fetch(url,
|
|
13
|
+
const res = await assets.fetch(url, { signal, redirect: "manual" }).catch(() => {
|
|
14
14
|
return null;
|
|
15
15
|
});
|
|
16
16
|
if (!res || !res.ok)
|
|
@@ -15,7 +15,7 @@ export interface FetchLocalAssetOptions {
|
|
|
15
15
|
* Resolve a same-origin asset path to bytes, trying (in order):
|
|
16
16
|
* 1. Cloudflare Workers ASSETS binding
|
|
17
17
|
* 2. Nitro localFetch through the event-aware bridge, which resolves dynamic routes too
|
|
18
|
-
* 3. External
|
|
18
|
+
* 3. External fetch with redirect validation (opt-in)
|
|
19
19
|
*
|
|
20
20
|
* All steps share a single `AbortSignal.timeout(fetchTimeout)` so a broken
|
|
21
21
|
* URL can't burn N× the configured budget.
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { $fetch } from "ofetch";
|
|
2
1
|
import { fetchWithEvent } from "#nuxtseo/nitro";
|
|
3
2
|
import { tryCloudflareAssetsFetch } from "./cloudflareAssets.js";
|
|
4
3
|
import { getOgImageOrigin } from "./origin.js";
|
|
4
|
+
import { fetchWithRedirectValidation, resolveSameOriginUrl } from "./ssrf.js";
|
|
5
5
|
export async function fetchLocalAsset(event, path, options) {
|
|
6
|
+
const absolute = resolveSameOriginUrl(path, getOgImageOrigin(event));
|
|
7
|
+
if (!path.startsWith("/") || !absolute)
|
|
8
|
+
return;
|
|
9
|
+
const url = new URL(absolute);
|
|
10
|
+
path = `${url.pathname}${url.search}`;
|
|
6
11
|
const { fetchTimeout, headers, includeExternalFallback = false, onStepFailure } = options;
|
|
7
12
|
const deadline = AbortSignal.timeout(fetchTimeout);
|
|
8
13
|
let expired = false;
|
|
@@ -21,23 +26,24 @@ export async function fetchLocalAsset(event, path, options) {
|
|
|
21
26
|
return result;
|
|
22
27
|
result = await race(fetchWithEvent(event, path, {
|
|
23
28
|
responseType: "arrayBuffer",
|
|
29
|
+
redirect: "manual",
|
|
24
30
|
signal: deadline,
|
|
25
31
|
timeout: fetchTimeout,
|
|
26
|
-
headers
|
|
32
|
+
headers,
|
|
33
|
+
onResponse({ response }) {
|
|
34
|
+
if (!response.ok)
|
|
35
|
+
throw new Error(response.statusText || String(response.status));
|
|
36
|
+
}
|
|
27
37
|
}).catch((err) => {
|
|
28
38
|
onStepFailure?.(path, err);
|
|
29
39
|
return void 0;
|
|
30
40
|
}));
|
|
31
41
|
if (result || expired || !includeExternalFallback)
|
|
32
42
|
return result;
|
|
33
|
-
|
|
34
|
-
return await race($fetch(absolute, {
|
|
35
|
-
responseType: "arrayBuffer",
|
|
43
|
+
return await race(fetchWithRedirectValidation(absolute, {
|
|
36
44
|
signal: deadline,
|
|
37
45
|
timeout: fetchTimeout,
|
|
38
|
-
headers
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return void 0;
|
|
42
|
-
}));
|
|
46
|
+
headers,
|
|
47
|
+
trustedHost: url.host
|
|
48
|
+
}).then((buffer) => buffer ?? void 0));
|
|
43
49
|
}
|