@thomas.f/prnext 0.1.13-alpha → 0.1.16-alpha

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.
Binary file
@@ -0,0 +1,8 @@
1
+ // Older native sharp backends can be supplied by the consuming application.
2
+ // Fall back to the bundled resvg renderer unless librsvg includes its RCE fix.
3
+ export function safeSvgBackend(backend) {
4
+ const version = backend?.versions?.rsvg;
5
+ if (typeof version !== 'string' || !/^\d+\.\d+\.\d+$/.test(version)) return false;
6
+ const [major, minor, patch] = version.split('.').map(Number);
7
+ return major > 2 || (major === 2 && (minor > 63 || (minor === 63 && patch >= 2)));
8
+ }
@@ -1,17 +1,4 @@
1
- // Upstream's Node bundle contains HarfBuzz's CommonJS globals and an adjacent
2
- // hb.wasm reference. Resolve these explicitly for direct prnext/og consumers.
3
- // Production builds prepare a relocatable module instead and avoid this loader.
4
- import { createRequire } from 'node:module';
5
- import { readFile } from 'node:fs/promises';
6
- import { pathToFileURL } from 'node:url';
7
- import path from 'node:path';
1
+ // Ship the reviewed renderer instead of resolving upstream's vulnerable pin.
8
2
  export async function loadImageRenderer() {
9
- const require = createRequire(import.meta.url);
10
- const entry = require.resolve('@vercel/og');
11
- const fontDirectory = path.dirname(entry);
12
- const satori = createRequire(entry).resolve('satori');
13
- const harfbuzzDirectory = path.dirname(createRequire(satori).resolve('harfbuzzjs/hb.wasm'));
14
- const source = (await readFile(entry, 'utf8')).replaceAll('import.meta.url', JSON.stringify(pathToFileURL(entry).href));
15
- const globals = `import {createRequire as __prnextRequire} from 'node:module';const require=__prnextRequire(${JSON.stringify(pathToFileURL(path.join(fontDirectory, 'index.node.js')).href)}),__filename=${JSON.stringify(entry)},__dirname=${JSON.stringify(harfbuzzDirectory)};\n`;
16
- return import('data:text/javascript;base64,' + Buffer.from(globals + source).toString('base64'));
3
+ return import('./og/index.node.mjs');
17
4
  }