8 lines
372 B
TypeScript
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;
|
|
}
|