nuxt-og-image 7.0.6 → 7.0.7
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 -1
- package/dist/chunks/uno.mjs +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/server/og-image/core/plugins/imageSrc.js +5 -3
- 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.CS4ArVpM.mjs} +7 -1
- package/package.json +2 -2
package/dist/chunks/tw4.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { readFile } from 'node:fs/promises';
|
|
|
2
2
|
import { pathToFileURL } from 'node:url';
|
|
3
3
|
import { resolveModulePath } from 'exsolve';
|
|
4
4
|
import { dirname, join } from 'pathe';
|
|
5
|
-
import { e as extractVariantBaseClasses, r as resolveVariantPrefixes, h as resolveExtractedVars, l as resolveVarsDeep, s as simplifyCss, p as postProcessStyles, m as loadLightningCss, a as extractCssVars, c as extractUniversalVars, d as extractPerClassVars, g as extractVarsFromCss, f as extractClassStyles } from '../shared/nuxt-og-image.
|
|
5
|
+
import { e as extractVariantBaseClasses, r as resolveVariantPrefixes, h as resolveExtractedVars, l as resolveVarsDeep, s as simplifyCss, p as postProcessStyles, m as loadLightningCss, a as extractCssVars, c as extractUniversalVars, d as extractPerClassVars, g as extractVarsFromCss, f as extractClassStyles } from '../shared/nuxt-og-image.CS4ArVpM.mjs';
|
|
6
6
|
import 'node:fs';
|
|
7
7
|
import 'node:module';
|
|
8
8
|
import '@nuxt/kit';
|
package/dist/chunks/uno.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import { defu } from 'defu';
|
|
3
3
|
import { logger } from '../../dist/runtime/logger.js';
|
|
4
|
-
import { e as extractVariantBaseClasses, s as simplifyCss, a as extractCssVars, b as extractPropertyInitialValues, c as extractUniversalVars, d as extractPerClassVars, f as extractClassStyles, p as postProcessStyles, r as resolveVariantPrefixes, i as importOptionalPeer, g as extractVarsFromCss, h as resolveExtractedVars } from '../shared/nuxt-og-image.
|
|
5
|
-
export { j as importResolvedModule, k as resolveOptionalModulePath } from '../shared/nuxt-og-image.
|
|
4
|
+
import { e as extractVariantBaseClasses, s as simplifyCss, a as extractCssVars, b as extractPropertyInitialValues, c as extractUniversalVars, d as extractPerClassVars, f as extractClassStyles, p as postProcessStyles, r as resolveVariantPrefixes, i as importOptionalPeer, g as extractVarsFromCss, h as resolveExtractedVars } from '../shared/nuxt-og-image.CS4ArVpM.mjs';
|
|
5
|
+
export { j as importResolvedModule, k as resolveOptionalModulePath } from '../shared/nuxt-og-image.CS4ArVpM.mjs';
|
|
6
6
|
import 'node:fs';
|
|
7
7
|
import 'node:module';
|
|
8
8
|
import 'node:url';
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import 'defu';
|
|
|
7
7
|
import 'fnv1a-64';
|
|
8
8
|
import 'nuxtseo-shared/kit';
|
|
9
9
|
import 'pathe';
|
|
10
|
-
export { n as default } from './shared/nuxt-og-image.
|
|
10
|
+
export { n as default } from './shared/nuxt-og-image.CS4ArVpM.mjs';
|
|
11
11
|
import '../dist/runtime/logger.js';
|
|
12
12
|
import '../dist/runtime/shared/publish.js';
|
|
13
13
|
import 'node:crypto';
|
|
@@ -6,7 +6,7 @@ import { fetchLocalAsset } from "../../../util/fetchLocalAsset.js";
|
|
|
6
6
|
import { getFetchTimeout } from "../../../util/fetchTimeout.js";
|
|
7
7
|
import { logger } from "../../../util/logger.js";
|
|
8
8
|
import { getOgImageOrigin } from "../../../util/origin.js";
|
|
9
|
-
import { fetchWithRedirectValidation, isBlockedUrl, parseSameOriginPath } from "../../../util/ssrf.js";
|
|
9
|
+
import { fetchWithRedirectValidation, isBlockedUrl, parseSameOriginPath, resolveSameOriginUrl } from "../../../util/ssrf.js";
|
|
10
10
|
import { getImageDimensions } from "../../utils/image-detector.js";
|
|
11
11
|
import { defineTransformer } from "../plugins.js";
|
|
12
12
|
const RE_URL_LEADING = /^url\(['"]?/;
|
|
@@ -51,6 +51,8 @@ async function doResolveSrcToBuffer(src, kind, { e, publicStoragePath, runtimeCo
|
|
|
51
51
|
logger.debug(`[og-image] ${kind} fetch failed (${url}): ${err?.message || err}`);
|
|
52
52
|
};
|
|
53
53
|
if (src.startsWith("/")) {
|
|
54
|
+
if (!resolveSameOriginUrl(src, getOgImageOrigin(e)))
|
|
55
|
+
return { blocked: true };
|
|
54
56
|
let buffer2;
|
|
55
57
|
if (import.meta.prerender || import.meta.dev) {
|
|
56
58
|
const srcWithoutBase = src.replace(runtimeConfig.app.baseURL, "/");
|
|
@@ -136,7 +138,7 @@ export default defineTransformer([
|
|
|
136
138
|
applyImageDimensions(node, result.buffer);
|
|
137
139
|
return;
|
|
138
140
|
}
|
|
139
|
-
if (isRelative) {
|
|
141
|
+
if (isRelative && import.meta.dev) {
|
|
140
142
|
node.props.src = withBase(src, `${getOgImageOrigin(ctx.e)}`);
|
|
141
143
|
return;
|
|
142
144
|
}
|
|
@@ -161,7 +163,7 @@ export default defineTransformer([
|
|
|
161
163
|
node.props.style.backgroundImage = `url(${toBufferSourceAsBase64(result.buffer)})`;
|
|
162
164
|
return;
|
|
163
165
|
}
|
|
164
|
-
if (!import.meta.dev
|
|
166
|
+
if (!import.meta.dev)
|
|
165
167
|
delete node.props.style.backgroundImage;
|
|
166
168
|
}
|
|
167
169
|
}
|
|
@@ -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
|
}
|
|
@@ -5212,12 +5212,18 @@ _ogImagePrerenderPaths?: Map<string, string>`
|
|
|
5212
5212
|
/// <reference path="./og-image-bindings.d.ts" />
|
|
5213
5213
|
import type { OgImageIconsData, OgImageOptions, OgImageRenderEventContext, OgImageRuntimeConfig, VNode } from '${typesPath}'
|
|
5214
5214
|
|
|
5215
|
+
declare module '@nuxt/schema' {
|
|
5216
|
+
interface AppRouteRulesExtensions {
|
|
5217
|
+
ogImage?: false | OgImageOptions & Record<string, any>
|
|
5218
|
+
}
|
|
5219
|
+
}
|
|
5220
|
+
|
|
5215
5221
|
${nitroAugmentations}
|
|
5216
5222
|
|
|
5217
5223
|
export {}
|
|
5218
5224
|
`;
|
|
5219
5225
|
}
|
|
5220
|
-
}, { nitro: true, nuxt: true });
|
|
5226
|
+
}, { nitro: true, node: true, nuxt: true });
|
|
5221
5227
|
}
|
|
5222
5228
|
|
|
5223
5229
|
const RE_INLINE_CONFIG = /const\s+inlineConfig\s*=\s*(\{[\s\S]*?\n\})/;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-og-image",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.0.
|
|
4
|
+
"version": "7.0.7",
|
|
5
5
|
"description": "Enlightened OG Image generation for Nuxt.",
|
|
6
6
|
"author": {
|
|
7
7
|
"website": "https://harlanzw.com",
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
"magicast": "^0.5.5",
|
|
131
131
|
"mocked-exports": "^0.1.1",
|
|
132
132
|
"nuxt-site-config": "^5.0.0",
|
|
133
|
-
"nuxtseo-shared": "^6.0.
|
|
133
|
+
"nuxtseo-shared": "^6.0.3",
|
|
134
134
|
"nypm": "^0.6.10",
|
|
135
135
|
"object-identity": "^0.2.3",
|
|
136
136
|
"ofetch": "^1.5.1",
|