(doc?: Document)
| 35 | * Security Policy. |
| 36 | */ |
| 37 | export function getNonce(doc?: Document): string | undefined { |
| 38 | let d = doc ?? (typeof document !== 'undefined' ? document : undefined); |
| 39 | if (!d) { |
| 40 | return getWebpackNonce(d); |
| 41 | } |
| 42 | |
| 43 | if (nonceCache.has(d)) { |
| 44 | return nonceCache.get(d); |
| 45 | } |
| 46 | |
| 47 | let meta = d.querySelector('meta[property="csp-nonce"]'); |
| 48 | let nonce = |
| 49 | (meta && |
| 50 | meta instanceof getOwnerWindow(meta).HTMLMetaElement && |
| 51 | (meta.nonce || meta.content)) || |
| 52 | getWebpackNonce(d) || |
| 53 | undefined; |
| 54 | |
| 55 | if (nonce !== undefined) { |
| 56 | nonceCache.set(d, nonce); |
| 57 | } |
| 58 | return nonce; |
| 59 | } |
no test coverage detected