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("script[nonce]")?.nonce; return isValidCspNonce(nonce) ? nonce : undefined; }