Skip to content
Meeko
Type to search the guides and the API reference. Open it from any page with / or Ctrl K; move with the arrow keys and open a result with Enter.
Get started

Contents

On this page

Not translated yet

This page has not been translated into English yet, so it is shown in Spanish.

inlineStyleHashes

función Since 1.4.0

Calcula el hash SHA-256 (base64) de cada <style> en línea de un documento HTML, como fuentes CSP 'sha256-…' para style-src: el estilo que añade theme para <MeekoThemeToggle> y los <style> de los componentes. Los atributos style="…" no cuentan, porque un hash no los permite. El texto se lee como lo hace el navegador, así que el hash coincide con el que éste comprueba.

ts
import { inlineStyleHashes } from "@meekojs/meeko/build";

Source code src/framework/script-hashes.ts:83

Firma #

ts
function inlineStyleHashes(html: string): readonly string[]

Parameters #

html string

Documento HTML completo.

Returns #

readonly string[]

Los hashes como fuentes CSP, ordenados y sin repetir.

Example #

ts
import { readFile } from "node:fs/promises";
import { inlineScriptHashes, inlineStyleHashes } from "@meekojs/meeko/build";
import { contentSecurityPolicy } from "@meekojs/meeko/server";

const html = await readFile("dist/index.html", "utf8");
const header = contentSecurityPolicy({ "default-src": ["'self'"] }, inlineScriptHashes(html).hashes, inlineStyleHashes(html));

See also #

Was this page helpful?

Add a comment

It is sent when you choose “Yes” or “No”. Only the page, your answer and the comment are stored: no cookies and no personal data.

0 of 2000 characters

Edit on GitHub: packages/meeko/src/framework/script-hashes.ts