UNPKG

vite-plugin-csp

Version:

Create CSP meta tags and header configs from all sources in the final Vite html

1 lines 32.6 kB
{"version":3,"sources":["../src/index.ts","../src/processors-helpers.ts","../src/builtin-processors/caddyfile.ts","../src/builtin-processors/nginx.ts","../src/builtin-processors/caddy.json.ts","../src/builtin-processors/index.ts","../src/get-all-sources.ts","../src/consts.ts","../src/extractCssImports.ts"],"sourcesContent":["import type { HtmlTagDescriptor, PluginOption } from 'vite';\nimport path from 'path';\nimport { CspDirectiveHeaders, CspDirectives, ValidSource } from 'csp-typed-directives';\nimport { builtinProcessorFns } from './builtin-processors/index.js';\nimport { createFilter } from '@rollup/pluginutils';\nimport { getAllSourceHashes, hash } from './get-all-sources.js';\nimport {\n\tDEFAULT_OPTIONS,\n\tHashCache,\n\tPolicyOptions,\n\tProcessFn,\n\tProcessFnContext,\n\tDebugProperties,\n\tCherryPickedConfig,\n\tHashResults,\n} from './consts.js';\nimport { internalProcFileWrite } from './processors-helpers.js';\nimport { getCssImportUrls } from './extractCssImports.js';\n\nclass HtmlTag implements HtmlTagDescriptor {\n\ttag: string;\n\tattrs: Record<string, string | boolean>;\n\tconstructor(tag: string, attrs: Record<string, string | boolean>) {\n\t\tthis.tag = tag;\n\t\tthis.attrs = attrs;\n\t}\n}\n\nclass HtmlHeadTag extends HtmlTag {\n\tinjectTo = 'head' as const;\n}\n\nexport type ViteCspPluginOptions = typeof DEFAULT_OPTIONS;\n\ntype ViteCspPluginOpts = Partial<ViteCspPluginOptions>\n\nfunction createViteCspPlugin(policy: PolicyOptions, options: ViteCspPluginOpts): Exclude<PluginOption, PluginOption[]>;\nfunction createViteCspPlugin(options: Partial<ViteCspPluginOpts>): Exclude<PluginOption, PluginOption[]>;\nfunction createViteCspPlugin(): Exclude<PluginOption, PluginOption[]>;\nfunction createViteCspPlugin(...opts: ([PolicyOptions, ViteCspPluginOpts] | [ViteCspPluginOpts] | [])): Exclude<PluginOption, PluginOption[]> {\n\tconst { p, o } = {\n\t\t0: {\n\t\t\to: DEFAULT_OPTIONS,\n\t\t\tp: DEFAULT_OPTIONS.policy,\n\t\t},\n\t\t1: {\n\t\t\to: (<ViteCspPluginOpts>opts[0]),\n\t\t\tp: (<ViteCspPluginOpts>opts[0])?.policy || DEFAULT_OPTIONS.policy,\n\t\t},\n\t\t2: {\n\t\t\to: <ViteCspPluginOpts>opts[1],\n\t\t\tp: <PolicyOptions>opts[0],\n\t\t},\n\t}[opts.length];\n\tconst enabled = typeof o.enabled === 'boolean' ? o.enabled : DEFAULT_OPTIONS.enabled;\n\tif (!enabled) {\n\t\treturn undefined;\n\t}\n\tconst inject = typeof o.inject === 'boolean' ? o.inject : DEFAULT_OPTIONS.inject;\n\tconst injectReporting = typeof o.injectReporting === 'boolean'\n\t\t? o.injectReporting\n\t\t: DEFAULT_OPTIONS.injectReporting;\n\tconst onDev = typeof o.onDev === 'string' ? o.onDev : DEFAULT_OPTIONS.onDev;\n\n\tfunction processPolicyOptions(pOp: PolicyOptions): CspDirectives {\n\t\tconst pPolicy = Array.isArray(pOp)\n\t\t\t? new CspDirectives(...pOp)\n\t\t\t: new CspDirectives(pOp);\n\n\t\tif (typeof o.referrerHeaderOverride === 'string')\n\t\t\tpPolicy.ReferrerHeader = o.referrerHeaderOverride;\n\n\t\tif (typeof o.sendReportsTo === 'object')\n\t\t\tpPolicy.ReportTo = o.sendReportsTo;\n\n\t\tif (typeof o.reportSubset === 'object')\n\t\t\tpPolicy.ReportOnly = o.reportSubset;\n\n\t\tpPolicy.checkReportTo();\n\t\treturn pPolicy;\n\t}\n\n\tconst policy = processPolicyOptions(p);\n\tconst validatedMappedPolicies: Record<string, CspDirectives> = {};\n\tif (!!o.mapHtmlFiles && Object.keys(o.mapHtmlFiles).length) {\n\t\tfor (const fileId in o.mapHtmlFiles) {\n\t\t\tconst lPolicy = o.mapHtmlFiles[fileId];\n\t\t\tif (lPolicy !== null && typeof lPolicy === 'object') {\n\t\t\t\tvalidatedMappedPolicies[fileId] = processPolicyOptions(lPolicy);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst hashingMethod = o.hashingMethod || DEFAULT_OPTIONS.hashingMethod;\n\tconst hashEnabled = {\n\t\t...DEFAULT_OPTIONS.hashEnabled,\n\t\t...o?.hashEnabled,\n\t};\n\n\t/** @deprecated requires SSR support first */\n\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t//@ts-ignore\n\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\tconst nonceEnabled = {\n\t\t...DEFAULT_OPTIONS.nonceEnabled,\n\t\t...o?.nonceEnabled,\n\t};\n\n\tconst srvConfDir = o.srvConfDir || DEFAULT_OPTIONS.srvConfDir;\n\tconst processFns = (Array.isArray(o.processFn)\n\t\t? o.processFn\n\t\t: o.processFn ? [o.processFn] : []\n\t).map((v) => {\n\t\tif (typeof v === 'string' && typeof builtinProcessorFns?.[v] === 'function')\n\t\t\treturn (ctx: ProcessFnContext, parsedHeaders: CspDirectiveHeaders) =>\n\t\t\t\tbuiltinProcessorFns?.[v]?.({\n\t\t\t\t\tctx,\n\t\t\t\t\tparsedHeaders,\n\t\t\t\t\tprocessor: v,\n\t\t\t\t});\n\t\tif (typeof v === 'object' &&\n\t\t\tv?.processor?.length &&\n\t\t\ttypeof builtinProcessorFns?.[v.processor] === 'function'\n\t\t)\n\t\t\treturn (ctx: ProcessFnContext, parsedHeaders: CspDirectiveHeaders) =>\n\t\t\t\tbuiltinProcessorFns?.[v.processor]?.({\n\t\t\t\t\t...v,\n\t\t\t\t\tctx,\n\t\t\t\t\tparsedHeaders,\n\t\t\t\t});\n\t\tif (typeof v === 'function')\n\t\t\treturn async (ctx: ProcessFnContext, parsedHeaders: CspDirectiveHeaders) => {\n\t\t\t\tconst res = await v(ctx, parsedHeaders);\n\t\t\t\tif (typeof res === 'object' && typeof res?.name === 'string' && typeof res?.content === 'string') {\n\t\t\t\t\tinternalProcFileWrite(ctx, res.name, res.content);\n\t\t\t\t}\n\t\t\t};\n\t\treturn undefined;\n\t}).filter((v): v is ProcessFn => typeof v === 'function');\n\n\tasync function buildConfigs(\n\t\tctx: ProcessFnContext,\n\t\tparsedHeaders: CspDirectiveHeaders,\n\t) {\n\t\tfor (const fn of processFns) {\n\t\t\tawait fn(ctx, parsedHeaders);\n\t\t}\n\t}\n\n\tconst jsFilter = createFilter('**.js');\n\tconst cssFilter = createFilter('**.css');\n\n\tconst idMap = new Map<string, HashCache>();\n\n\tconst cssImportUrls = new Set<string>();\n\n\tconst config: Partial<CherryPickedConfig> = {};\n\tconst plugin: PluginOption = {\n\t\tname: 'vite-plugin-csp',\n\t\tenforce: 'post',\n\t\tapply: () => true,\n\t\tconfigResolved(resolvedConfig) {\n\t\t\t// store the resolved config\n\t\t\tconfig.command = resolvedConfig?.command;\n\t\t},\n\t\tasync transform(code, id) {\n\t\t\tif ((config.command === 'build' || onDev === 'full')) {\n\t\t\t\tconst isJs = jsFilter(id);\n\t\t\t\tconst isCss = cssFilter(id);\n\t\t\t\tif (isJs && hashEnabled['script-src']) {\n\t\t\t\t\tidMap.set(id, <HashCache>{\n\t\t\t\t\t\tfileType: 'script',\n\t\t\t\t\t\t[hashingMethod]: hash(hashingMethod, code),\n\t\t\t\t\t});\n\t\t\t\t} else if (isCss && hashEnabled['style-src']) {\n\t\t\t\t\tconst urls = getCssImportUrls(code);\n\t\t\t\t\turls.forEach((v) => {\n\t\t\t\t\t\tlet x = '';\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tx = path.resolve(v);\n\t\t\t\t\t\t} catch (_) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (x) cssImportUrls.add(x);\n\t\t\t\t\t});\n\t\t\t\t\tidMap.set(id, <HashCache>{\n\t\t\t\t\t\tfileType: 'style',\n\t\t\t\t\t\t[hashingMethod]: hash(hashingMethod, code),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t},\n\t\tasync transformIndexHtml(html, { path: Path, filename }) {\n\t\t\tconst finalHashes = getAllSourceHashes(html, idMap, hashEnabled, hashingMethod);\n\t\t\tlet localPolicy = policy;\n\t\t\tconst vMapPol = validatedMappedPolicies;\n\t\t\tif (!!vMapPol && Object.keys(vMapPol).length) {\n\t\t\t\tconst pPath = Path ? path.resolve(Path, filename) : path.resolve(filename);\n\t\t\t\tfor (const key of Object.keys(vMapPol)) {\n\t\t\t\t\tconst kPath = path.resolve(key);\n\t\t\t\t\tif (kPath === pPath) {\n\t\t\t\t\t\tlocalPolicy = vMapPol[key];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction setCspAsArr(directive: keyof HashResults) {\n\t\t\t\tconst x = localPolicy.CSP[directive];\n\t\t\t\tif (!Array.isArray(x)) {\n\t\t\t\t\tif (typeof x !== 'undefined') {\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t\t\t\t\t\t//@ts-ignore\n\t\t\t\t\t\tlocalPolicy.CSP[directive] = [x];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlocalPolicy.CSP[directive] = [];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn <ValidSource[]>localPolicy.CSP[directive];\n\t\t\t}\n\t\t\tconst assignHash = (v: keyof HashResults) => !hashEnabled[v] || setCspAsArr(v).push(...finalHashes[v]);\n\n\t\t\tassignHash('script-src');\n\t\t\tassignHash('script-src-attr');\n\t\t\tassignHash('style-src');\n\t\t\tassignHash('style-src-attr');\n\n\t\t\tcssImportUrls.forEach((v) => {\n\t\t\t\tif (idMap.has(v)) {\n\t\t\t\t\tconst res = idMap.get(v);\n\t\t\t\t\tif (res) {\n\t\t\t\t\t\tconst x = new Set((<ValidSource[]>localPolicy.CSP['style-src']));\n\t\t\t\t\t\tx.add(res[hashingMethod]);\n\t\t\t\t\t\tlocalPolicy.CSP['style-src'] = Array.from(x);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst parsedHeaders = localPolicy.getHeaders();\n\n\t\t\tawait buildConfigs({\n\t\t\t\tpath: Path,\n\t\t\t\thtmlFileName: filename,\n\t\t\t\tbuiltinProcessorFns,\n\t\t\t\tsrvConfDir,\n\t\t\t}, parsedHeaders);\n\t\t\tif (inject) {\n\t\t\t\treturn Object.entries(parsedHeaders)\n\t\t\t\t\t.filter(([k]) => injectReporting || !k.includes('Report'))\n\t\t\t\t\t.map(([k, v]) => new HtmlHeadTag('meta', {\n\t\t\t\t\t\t'http-equiv': k,\n\t\t\t\t\t\tcontent: v,\n\t\t\t\t\t}));\n\t\t\t}\n\t\t},\n\t};\n\n\tif (o.debugPlugin) {\n\t\tconst x: DebugProperties = {\n\t\t\tinject,\n\t\t\tonDev,\n\t\t\tpolicy,\n\t\t\thashingMethod,\n\t\t\thashEnabled,\n\t\t\tnonceEnabled,\n\t\t\tprocessFns,\n\t\t\tidMap,\n\t\t\tvalidatedMappedPolicies,\n\t\t\tconfig,\n\t\t};\n\t\tObject.defineProperty(plugin, 'debugProperties', {\n\t\t\tvalue: x,\n\t\t});\n\t}\n\n\treturn plugin;\n}\nexport const ViteCspPlugin = createViteCspPlugin;\nexport default ViteCspPlugin;\n","import { ProcessFnContext } from './consts.js';\nimport path from 'path';\nimport { mkdirSync, writeFileSync } from 'fs';\n\nexport const internalProcFileWrite = (ctx: ProcessFnContext,file: string,config: string): void => {\n\tmkdirSync(ctx.srvConfDir,{recursive:true});\n\tconst lPath = path.resolve(path.join(ctx.srvConfDir,file));\n\twriteFileSync(lPath,config);\n};\n\nexport const indentLiteralLines = (content: string, indent = '\\t\\t\\t'): string => content\n\t.split('\\n')\n\t.map((v,i) => v && i ? indent + v : v)\n\t.join('\\n');\n","import { CspDirectiveHeaders } from 'csp-typed-directives';\nimport { InternalProcessFn } from '../consts.js';\nimport { indentLiteralLines, internalProcFileWrite } from '../processors-helpers.js';\n\nconst getCaddyHeaders = (headers: CspDirectiveHeaders) => Object.entries(headers)\n\t.map(([key,value]) => `header ${key} \"${value}\"\\n`)\n\t.join('');\n\nexport const defaultFiles = {\n\tCaddyfile: 'Caddyfile',\n\tCaddyfile_HeadersOnly: 'headers.caddyfile',\n};\n\nexport const builtinProcessorFns = {\n\tCaddyfile: <InternalProcessFn>((\n\t\t{ctx, parsedHeaders, outFile = defaultFiles.Caddyfile},\n\t) => {\n\t\tconst config = `\n\t\t{$SITE_ADDRESS}\n\n\t\troot * dist\n\t\t${indentLiteralLines(getCaddyHeaders(parsedHeaders),'\\t\\t')}\n\t\tfile_server\n\t\t`;\n\t\treturn internalProcFileWrite(ctx,outFile,config);\n\t}),\n\tCaddyfile_HeadersOnly: <InternalProcessFn>((\n\t\t{ctx, parsedHeaders, outFile = defaultFiles.Caddyfile_HeadersOnly},\n\t) => {\n\t\treturn internalProcFileWrite(ctx,outFile,getCaddyHeaders(parsedHeaders));\n\t}),\n};\n","import { CspDirectiveHeaders } from 'csp-typed-directives';\nimport { InternalProcessFn } from '../consts.js';\nimport { indentLiteralLines, internalProcFileWrite } from '../processors-helpers.js';\n\nconst getNginxHeaders = (headers: CspDirectiveHeaders) => Object.entries(headers)\n\t.map(([key,value]) => `add_header ${key} \"${value}\";\\n`)\n\t.join('');\n\nexport const defaultFiles = {\n\tNginx: 'nginx.conf',\n\tNginx_HeadersOnly: 'nginx-headers.conf',\n};\n\nexport const builtinProcessorFns = {\n\tNginx: <InternalProcessFn>((\n\t\t{ctx, parsedHeaders, outFile = defaultFiles.Nginx},\n\t) => {\n\t\tconst config = `\n\t\tserver {\n\t\t\tlisten\\t443 80;\n\t\t\tindex\\tindex.html Index.html;\n\t\t\t${indentLiteralLines(getNginxHeaders(parsedHeaders))}\n\t\t\tlocation / {\n\t\t\t\ttry_files\\t$uri /index.html $uri/ / =404;\n\t\t\t}\n\t\t}\n\t\t`;\n\t\treturn internalProcFileWrite(ctx,outFile,config);\n\t}),\n\tNginx_HeadersOnly: <InternalProcessFn>((\n\t\t{ctx, parsedHeaders, outFile = defaultFiles.Nginx_HeadersOnly},\n\t) => {\n\t\treturn internalProcFileWrite(ctx,outFile,getNginxHeaders(parsedHeaders));\n\t}),\n};\n","import { CspDirectiveHeaders } from 'csp-typed-directives';\nimport { InternalProcessFn } from '../consts.js';\nimport { internalProcFileWrite } from '../processors-helpers.js';\n\ntype CaddyJsonHeaders = Record<keyof CspDirectiveHeaders,string[]>\nconst getCaddyJson = (headers: CspDirectiveHeaders) => {\n\tconst lHeaders = JSON.parse(JSON.stringify(headers));\n\tfor (const key in lHeaders) {\n\t\tconst value = lHeaders[key];\n\t\tlHeaders[key] = [value];\n\t}\n\treturn <CaddyJsonHeaders>lHeaders;\n};\n\nexport const defaultFiles = {\n\tCaddyJSON: 'caddy.json',\n\tCaddyJSON_HeadersOnly: 'caddy-headers.json',\n};\n\nexport const builtinProcessorFns = {\n\tCaddyJSON: <InternalProcessFn>((\n\t\t{ctx, parsedHeaders, outFile = defaultFiles.CaddyJSON},\n\t) => {\n\t\tconst headers = getCaddyJson(parsedHeaders);\n\t\tconst caddyServerJson = {\n\t\t\t'listen': [\n\t\t\t\t':443',\n\t\t\t],\n\t\t\t'routes': [\n\t\t\t\t{\n\t\t\t\t\t'match': [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'host': [\n\t\t\t\t\t\t\t\t'localhost',\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\t'handle': [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'handler': 'file_server',\n\t\t\t\t\t\t\t'root': '/var/www',\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t'handler': 'headers',\n\t\t\t\t\t\t\t'response': {\n\t\t\t\t\t\t\t\t'set': headers,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t\treturn internalProcFileWrite(ctx,outFile,JSON.stringify(caddyServerJson,null,2));\n\t}),\n\tCaddyJSON_HeadersOnly: <InternalProcessFn>((\n\t\t{ctx, parsedHeaders, outFile = defaultFiles.CaddyJSON_HeadersOnly},\n\t) => {\n\t\treturn internalProcFileWrite(ctx,outFile,JSON.stringify({\n\t\t\t'handler': 'headers',\n\t\t\t'response': {\n\t\t\t\t'set': getCaddyJson(parsedHeaders),\n\t\t\t},\n\t\t},null,2));\n\t}),\n};\n\n","import { builtinProcessorFns as caddyfile, defaultFiles as caddyfile_defaults} from './caddyfile.js';\nimport { builtinProcessorFns as nginx, defaultFiles as nginx_defaults} from './nginx.js';\nimport { builtinProcessorFns as caddyJson, defaultFiles as caddyJson_defaults} from './caddy.json.js';\n\nexport const builtinProcessorFns = {\n\t...caddyfile,\n\t...nginx,\n\t...caddyJson,\n};\n\nexport const builtinProcessorFiles = {\n\t...caddyfile_defaults,\n\t...nginx_defaults,\n\t...caddyJson_defaults,\n};\n","\nimport * as cheerio from 'cheerio';\nimport type {Element} from 'cheerio';\nimport { BinaryLike, createHash } from 'crypto';\nimport path from 'path';\nimport { HashCache, ValidHashes,HashEnabled,HashResults,CryptoSources, validCrypto } from './consts.js';\nimport { getCssImportUrls } from './extractCssImports.js';\n\nexport function hash (algorithm: ValidHashes,target: BinaryLike): string {\n\tconst hash = createHash(algorithm);\n\thash.update(target);\n\treturn <CryptoSources>`${algorithm}-${hash.digest('base64')}`;\n}\n\nexport function getAllSourceHashes (\n\thtml: string,\n\tidMap: Map<string, HashCache>,\n\thashEnabled: HashEnabled,\n\thashingMethod: ValidHashes,\n): HashResults {\n\tconst $ = cheerio.load(html);\n\tconst hashSets = {\n\t\tscriptSrcHashes: new Set<CryptoSources>(),\n\t\tstyleSrcHashes: new Set<CryptoSources>(),\n\t\tscriptAttrHashes: new Set<CryptoSources>(),\n\t\tstyleAttrHashes: new Set<CryptoSources>(),\n\t};\n\n\tconst isCryptoSource = (v:string | undefined): v is CryptoSources => validCrypto.some((x) => x === v?.slice(0,6));\n\n\tconst tryAddHash = (v:string | undefined, hashSet: keyof typeof hashSets) => {\n\t\tif (isCryptoSource(v)) {\n\t\t\thashSets[hashSet].add(v);\n\t\t}\n\t};\n\t// All script tags\n\t$('script').each(function (i,el) {\n\n\t\t// Imported Scripts\n\t\tif (Object.keys(el.attribs).length && el.attribs?.src?.length) {\n\t\t\tconst fileId = path.resolve(el.attribs?.src);\n\t\t\tif (idMap.has(fileId)) {\n\t\t\t\ttryAddHash(idMap.get(fileId)?.[hashingMethod],'scriptSrcHashes');\n\t\t\t}\n\t\t}\n\n\t\t// Inline Scripts\n\t\tif (el.childNodes?.[0]?.type === 'text') {\n\t\t\tconst txt = $.text([el.childNodes?.[0]]);\n\t\t\tif (txt.length) {\n\t\t\t\ttryAddHash(hash(hashingMethod,txt),'scriptSrcHashes');\n\t\t\t}\n\t\t}\n\t});\n\n\t// All style tags\n\t$('style').each(function (i,el) {\n\n\t\t// Inline styles\n\t\tif (el.childNodes?.[0]?.type === 'text') {\n\t\t\tconst txt = $.text([el.childNodes?.[0]]);\n\t\t\tif (txt.length) {\n\t\t\t\tconst cssImportUrls = getCssImportUrls(txt);\n\t\t\t\tcssImportUrls.forEach((v) => {\n\t\t\t\t\tif (v.length) {\n\t\t\t\t\t\tconst fileId = path.resolve(v);\n\t\t\t\t\t\tif (idMap.has(fileId)) {\n\t\t\t\t\t\t\ttryAddHash(idMap.get(fileId)?.[hashingMethod],'styleSrcHashes');\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\ttryAddHash(hash(hashingMethod,txt),'styleSrcHashes');\n\t\t\t}\n\t\t}\n\t});\n\n\t// Styles linked in head\n\t$('link').each(function (i,el) {\n\t\tif (Object.keys(el.attribs).length &&\n\t\t\t\t\tel.attribs?.rel === 'stylesheet' &&\n\t\t\t\t\tel.attribs?.href?.length\n\t\t) {\n\t\t\tconst fileId = path.resolve(el.attribs?.href);\n\t\t\tif (idMap.has(fileId)) {\n\t\t\t\ttryAddHash(idMap.get(fileId)?.[hashingMethod],'styleSrcHashes');\n\t\t\t}\n\t\t}\n\t});\n\n\t// Hash inline styles in `style=\"\"` tags if enabled\n\tif (hashEnabled['style-src-attr']) {\n\t\t$('[style]').each((i,el) => {\n\t\t\tif (el.attribs?.style.length) {\n\t\t\t\ttryAddHash(hash(hashingMethod,el.attribs.style),'styleAttrHashes');\n\t\t\t}\n\t\t});\n\t}\n\n\t// Hash inline scripts in `onSomething=\"\"` tags if enabled\n\tif (hashEnabled['script-src-attr']) {\n\t\tconst onFn = (v: string) => v.startsWith('on');\n\t\t$('*').filter((i,el)=> Object.keys((<Element><unknown>el).attribs).some(onFn)).each((i,el) => {\n\t\t\tObject.keys((<Element><unknown>el).attribs).filter(onFn).forEach((v) => {\n\t\t\t\tconst content = (<Element><unknown>el).attribs[v];\n\t\t\t\tif (content?.length) {\n\t\t\t\t\ttryAddHash(hash(hashingMethod,content),'scriptAttrHashes');\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\treturn {\n\t\t'script-src-attr': hashSets.scriptAttrHashes,\n\t\t'style-src-attr': hashSets.styleAttrHashes,\n\t\t'script-src': hashSets.scriptSrcHashes,\n\t\t'style-src': hashSets.styleSrcHashes,\n\t};\n}\n","import { CspDirectiveHeaders, CspDirectives, DirectivesObj, ValidHashes as validHashes, ValidCrypto as lValidCrypto } from 'csp-typed-directives';\nimport { ResolvedConfig } from 'vite';\nimport { builtinProcessorFns } from './builtin-processors/index.js';\n\ntype ValidCrypto = typeof lValidCrypto[number]\nexport const validCrypto = lValidCrypto;\nexport type HashEnabled = typeof DEFAULT_OPTIONS['hashEnabled']\nexport type CryptoSources = `${ValidCrypto}-${string}`\nexport type HashResults = Record<keyof HashEnabled, Set<CryptoSources>>\n\nexport const DEFAULT_OPTIONS = {\n\tenabled: <boolean>true,\n\tinject: <boolean>true,\n\tinjectReporting: <boolean>false,\n\tonDev: <DevRunTypes>'permissive',\n\tpolicy: <PolicyOptions>{\n\t\t'base-uri': 'self',\n\t\t'object-src': 'none',\n\t\t'script-src': ['unsafe-inline', 'self', 'unsafe-eval'],\n\t\t'style-src': ['unsafe-inline', 'self', 'unsafe-eval'],\n\t},\n\thashingMethod: <ValidHashes>'sha384',\n\thashEnabled: {\n\t\t'script-src': <boolean>true,\n\t\t'style-src': <boolean>true,\n\t\t'script-src-attr': <boolean>true,\n\t\t'style-src-attr': <boolean>true,\n\t},\n\t/** @deprecated requires SSR support first, included for webpack migrations */\n\tnonceEnabled: {\n\t\t'script-src': <boolean>false,\n\t\t'style-src': <boolean>false,\n\t},\n\tprocessFn: <ProcessOptions | undefined>undefined,\n\treferrerHeaderOverride: <DirectivesParams['3']>undefined,\n\tsendReportsTo: <DirectivesParams['1']>undefined,\n\treportSubset: <DirectivesParams['2']>undefined,\n\tmapHtmlFiles: <Record<string, PolicyOptions> | undefined>undefined,\n\tdebugPlugin: <boolean>false,\n\tsrvConfDir: <string>'.server_config',\n};\n\nexport type DebugAble = Plugin & { debugProperties: DebugProperties };\nexport type InternalProcessFnNames = keyof typeof builtinProcessorFns\nexport type InternalProcessFnParams = {\n\tprocessor: InternalProcessFnNames,\n\toutFile?: string,\n}\nexport type InternalProcessOptions = InternalProcessFnParams & { ctx: ProcessFnContext, parsedHeaders: CspDirectiveHeaders }\nexport type InternalProcessFn = (options: InternalProcessOptions) => void\n\nexport const HASHES = validHashes;\nexport type ValidHashes = typeof HASHES[number];\n\nexport const DEV_RUN_TYPE = ['permissive', 'full', 'skip'] as const;\nexport type DevRunTypes = typeof DEV_RUN_TYPE[number];\n\nexport type ProcessFnContext = {\n\tpath: string,\n\thtmlFileName: string,\n\tsrvConfDir: string,\n\tbuiltinProcessorFns: typeof builtinProcessorFns\n}\ntype ProcessFnReturn = { name: string, content: string } | void\nexport type ProcessFn = (ctx: ProcessFnContext, parsedHeaders: CspDirectiveHeaders) => ProcessFnReturn | Promise<ProcessFnReturn>;\n\nexport type DirectivesParams = ConstructorParameters<typeof CspDirectives>\nexport type PolicyOptions = DirectivesParams | DirectivesObj\n\nexport type ProcessOption = keyof typeof builtinProcessorFns\n| InternalProcessFnParams\n| ProcessFn\n\nexport type ProcessOptions = ProcessOption | ProcessOption[]\n\nexport type HashCache = Record<ValidHashes, CryptoSources> & { fileType: 'script' | 'style' }\n\nexport type DebugProperties = {\n\tinject: boolean;\n\tonDev: 'permissive' | 'full' | 'skip';\n\tpolicy: CspDirectives;\n\thashingMethod: 'sha256' | 'sha384' | 'sha512';\n\thashEnabled: {\n\t\t'script-src': boolean;\n\t\t'style-src': boolean;\n\t\t'script-src-attr': boolean;\n\t\t'style-src-attr': boolean;\n\t};\n\tnonceEnabled: {\n\t\t'script-src': boolean;\n\t\t'style-src': boolean;\n\t};\n\tprocessFns: ProcessFn[];\n\tidMap: Map<string, HashCache>;\n\tvalidatedMappedPolicies: Record<string, CspDirectives>;\n\tconfig: Partial<CherryPickedConfig>;\n};\n\nexport type CherryPickedConfig = {\n\tcommand: ResolvedConfig['command']\n}\n","import * as csstree from 'css-tree';\nconst matchStartEnd = (s:string,toMatch: string) => s[0] === toMatch && s[s.length - 1] === toMatch;\nconst stripTrim = (s:string) => s.slice(1,s.length - 1);\n\nexport const getCssImportUrls = (code: string): string[] =>{\n\tconst ast = csstree.parse(code);\n\tconst results = csstree.findAll(ast, function (node, _item, _list) {\n\t\treturn node.type === 'Atrule' && node.name === 'import';\n\t}).map((impMatch) => {\n\t\tif (\n\t\t\timpMatch !== null &&\n\t\t\ttypeof impMatch === 'object' &&\n\t\t\timpMatch.type === 'Atrule' &&\n\t\t\timpMatch?.prelude?.type === 'AtrulePrelude'\n\t\t) {\n\t\t\tconst objPrelude = csstree.toPlainObject(impMatch?.prelude);\n\t\t\tif (objPrelude.type === 'AtrulePrelude' && objPrelude.children.length) {\n\t\t\t\tconst values = objPrelude.children.map((v) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tv.type === 'Url' &&\n\t\t\t\t\t\tv?.value?.type === 'String' &&\n\t\t\t\t\t\tv.value.value\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn v.value.value;\n\t\t\t\t\t}\n\t\t\t\t\treturn undefined;\n\t\t\t\t});\n\t\t\t\treturn values.filter((v): v is string => typeof v === 'string');\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t})\n\t\t.filter((v): v is string[] => Array.isArray(v))\n\t\t.flat()\n\t\t.map((v) => (matchStartEnd(v,\"'\") || matchStartEnd(v,'\"')) ? stripTrim(v) : v);\n\treturn results;\n};\n"],"mappings":"i6BAAA,6EACA,MAAiB,qBACjB,EAAgE,gCCDhE,MAAiB,qBACjB,EAAyC,cAE5B,EAAwB,CAAC,EAAsB,EAAa,IAAyB,CACjG,gBAAU,EAAI,WAAW,CAAC,UAAU,EAAI,CAAC,EACzC,GAAM,GAAQ,UAAK,QAAQ,UAAK,KAAK,EAAI,WAAW,CAAI,CAAC,EACzD,oBAAc,EAAM,CAAM,CAC3B,EAEa,EAAqB,CAAC,EAAiB,EAAS,QAAqB,EAChF,MAAM;AAAA,CAAI,EACV,IAAI,CAAC,EAAE,IAAM,GAAK,EAAI,EAAS,EAAI,CAAC,EACpC,KAAK;AAAA,CAAI,ECTX,GAAM,IAAkB,AAAC,GAAiC,OAAO,QAAQ,CAAO,EAC9E,IAAI,CAAC,CAAC,EAAI,KAAW,UAAU,MAAQ;AAAA,CAAU,EACjD,KAAK,EAAE,EAEI,EAAe,CAC3B,UAAW,YACX,sBAAuB,mBACxB,EAEa,GAAsB,CAClC,UAA+B,CAC9B,CAAC,MAAK,gBAAe,UAAU,EAAa,aACxC,CACJ,GAAM,GAAS;AAAA;AAAA;AAAA;AAAA,IAIb,EAAmB,GAAgB,CAAa,EAAE,IAAM;AAAA;AAAA,IAG1D,MAAO,GAAsB,EAAI,EAAQ,CAAM,CAChD,EACA,sBAA2C,CAC1C,CAAC,MAAK,gBAAe,UAAU,EAAa,yBAErC,EAAsB,EAAI,EAAQ,GAAgB,CAAa,CAAC,CAEzE,EC3BA,GAAM,IAAkB,AAAC,GAAiC,OAAO,QAAQ,CAAO,EAC9E,IAAI,CAAC,CAAC,EAAI,KAA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