Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/apps/web/app/utils/security/documentCspNonce.ts
T

8 lines
372 B
TypeScript

import { isValidCspNonce } from "./contentSecurityPolicy";
/** Reads the browser-normalized nonce property from an already trusted script. */
export function getCurrentDocumentCspNonce(documentRef: Document): string | undefined {
const nonce = documentRef.querySelector<HTMLScriptElement>("script[nonce]")?.nonce;
return isValidCspNonce(nonce) ? nonce : undefined;
}