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,EAAc,IACtC,CACX,CACA,OAAO,CAAI,EAEQ,iBAAZ,EACP,MAAM,IAAI,MAAM,6DAEpB,KAAK,QAAU,OAAO,OAAO,CAAE,cAAe,CAAC,UAAW,QAAS,OAAQ,YAAa,SAAW,EACvG,CAIA,SAAA,CAAU,GACN,MAA6B,SAAzB,KAAK,QAAQ,QACuB,gBAA7B,EAAY,QAAQ,KAExB,KAAK,QAAQ,OACxB,CACA,KAAA,CAAM,IACF,EAAI,QAAQ,SAAS,EAAU,KAAK,MACxC,EAEJ,QAAQ,2BAA6B","file":"/npm/webpack-subresource-integrity@5.2.0-rc.1/dist/cjs/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/webpack-subresource-integrity@5.2.0-rc.1/dist/cjs/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\n/**\n * Copyright (c) 2015-present, Waysact Pty Ltd\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n    return new (P || (P = Promise))(function (resolve, reject) {\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\n    });\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.SubresourceIntegrityPlugin = void 0;\nconst crypto_1 = require(\"crypto\");\nconst plugin_1 = require(\"./plugin\");\nconst reporter_1 = require(\"./reporter\");\nconst util_1 = require(\"./util\");\nconst hooks_1 = require(\"./hooks\");\nconst manifest_1 = require(\"./manifest\");\nconst globals_1 = require(\"./globals\");\n/**\n * The webpack-subresource-integrity plugin.\n *\n * @public\n */\nclass SubresourceIntegrityPlugin {\n    /**\n     * Create a new instance.\n     *\n     * @public\n     */\n    constructor(options = {}) {\n        /**\n         * @internal\n         */\n        this.setup = (compilation, hwpHooks) => {\n            const reporter = new reporter_1.Reporter(compilation);\n            if (!this.validateOptions(compilation, reporter) ||\n                !this.isEnabled(compilation)) {\n                return;\n            }\n            const plugin = new plugin_1.Plugin(compilation, this.options, reporter);\n            if (typeof compilation.outputOptions.chunkLoading === \"string\" &&\n                [\"require\", \"async-node\"].includes(compilation.outputOptions.chunkLoading)) {\n                reporter.warnNonWeb();\n                return;\n            }\n            compilation.hooks.beforeRuntimeRequirements.tap(globals_1.thisPluginName, () => {\n                plugin.beforeRuntimeRequirements();\n            });\n            compilation.hooks.processAssets.tap({\n                name: globals_1.thisPluginName,\n                stage: compilation.compiler.webpack.Compilation\n                    .PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE,\n            }, (records) => {\n                return plugin.processAssets(records);\n            });\n            compilation.hooks.afterProcessAssets.tap(globals_1.thisPluginName, (records) => {\n                for (const chunk of compilation.chunks.values()) {\n                    for (const chunkFile of chunk.files) {\n                        const record = records[chunkFile];\n                        if (record && record.source().includes(util_1.placeholderPrefix)) {\n                            reporter.errorUnresolvedIntegrity(chunkFile);\n                        }\n                    }\n                }\n            });\n            compilation.compiler.webpack.optimize.RealContentHashPlugin.getCompilationHooks(compilation).updateHash.tap(globals_1.thisPluginName, (input, oldHash) => {\n                // FIXME: remove type hack pending https://github.com/webpack/webpack/pull/12642#issuecomment-784744910\n                return plugin.updateHash(input, oldHash);\n            });\n            if (hwpHooks) {\n                hwpHooks.beforeAssetTagGeneration.tapPromise(globals_1.thisPluginName, (pluginArgs) => __awaiter(this, void 0, void 0, function* () {\n                    plugin.handleHwpPluginArgs(pluginArgs);\n                    return pluginArgs;\n                }));\n                hwpHooks.alterAssetTagGroups.tapPromise({\n                    name: globals_1.thisPluginName,\n                    stage: 10000,\n                }, (data) => __awaiter(this, void 0, void 0, function* () {\n                    plugin.handleHwpBodyTags(data);\n                    return data;\n                }));\n            }\n            const { mainTemplate } = compilation;\n            mainTemplate.hooks.jsonpScript.tap(globals_1.thisPluginName, (source) => plugin.addAttribute(\"script\", source));\n            mainTemplate.hooks.linkPreload.tap(globals_1.thisPluginName, (source) => plugin.addAttribute(\"link\", source));\n            mainTemplate.hooks.localVars.tap(globals_1.thisPluginName, (source, chunk) => {\n                const allChunks = this.options.hashLoading === \"lazy\"\n                    ? plugin.getChildChunksToAddToChunkManifest(chunk)\n                    : (0, util_1.findChunks)(chunk);\n                const includedChunks = chunk.getChunkMaps(false).hash;\n                if (Object.keys(includedChunks).length > 0) {\n                    return compilation.compiler.webpack.Template.asString([\n                        source,\n                        `${util_1.sriHashVariableReference} = ` +\n                            JSON.stringify((0, util_1.generateSriHashPlaceholders)(Array.from(allChunks).filter((depChunk) => depChunk.id !== null &&\n                                includedChunks[depChunk.id.toString()]), this.options.hashFuncNames)) +\n                            \";\",\n                    ]);\n                }\n                return source;\n            });\n            if (this.options.hashLoading === \"lazy\") {\n                compilation.hooks.additionalChunkRuntimeRequirements.tap(globals_1.thisPluginName, (chunk) => {\n                    var _a;\n                    const childChunks = plugin.getChildChunksToAddToChunkManifest(chunk);\n                    if (childChunks.size > 0 && !chunk.hasRuntime()) {\n                        compilation.addRuntimeModule(chunk, new manifest_1.AddLazySriRuntimeModule((0, util_1.generateSriHashPlaceholders)(childChunks, this.options.hashFuncNames), (_a = chunk.name) !== null && _a !== void 0 ? _a : chunk.id));\n                    }\n                });\n            }\n        };\n        /**\n         * @internal\n         */\n        this.validateOptions = (compilation, reporter) => {\n            if (this.isEnabled(compilation) &&\n                !compilation.compiler.options.output.crossOriginLoading) {\n                reporter.warnCrossOriginPolicy();\n            }\n            return (this.validateHashFuncNames(reporter) && this.validateHashLoading(reporter));\n        };\n        /**\n         * @internal\n         */\n        this.validateHashFuncNames = (reporter) => {\n            if (!Array.isArray(this.options.hashFuncNames)) {\n                reporter.errorHashFuncsNonArray(this.options.hashFuncNames);\n                return false;\n            }\n            else if (this.options.hashFuncNames.length === 0) {\n                reporter.errorHashFuncsEmpty();\n                return false;\n            }\n            else if (!this.options.hashFuncNames.every(this.validateHashFuncName.bind(this, reporter))) {\n                return false;\n            }\n            else {\n                this.warnStandardHashFunc(reporter);\n                return true;\n            }\n        };\n        /**\n         * @internal\n         */\n        this.validateHashLoading = (reporter) => {\n            const supportedHashLoadingOptions = Object.freeze([\"eager\", \"lazy\"]);\n            if (supportedHashLoadingOptions.includes(this.options.hashLoading)) {\n                return true;\n            }\n            reporter.errorInvalidHashLoading(this.options.hashLoading, supportedHashLoadingOptions);\n            return false;\n        };\n        /**\n         * @internal\n         */\n        this.warnStandardHashFunc = (reporter) => {\n            let foundStandardHashFunc = false;\n            this.options.hashFuncNames.forEach((hashFuncName) => {\n                if (globals_1.standardHashFuncNames.indexOf(hashFuncName) >= 0) {\n                    foundStandardHashFunc = true;\n                }\n            });\n            if (!foundStandardHashFunc) {\n                reporter.warnStandardHashFuncs();\n            }\n        };\n        /**\n         * @internal\n         */\n        this.validateHashFuncName = (reporter, hashFuncName) => {\n            if (typeof hashFuncName !== \"string\" &&\n                !(hashFuncName instanceof String)) {\n                reporter.errorNonStringHashFunc(hashFuncName);\n                return false;\n            }\n            try {\n                (0, crypto_1.createHash)(hashFuncName);\n            }\n            catch (error) {\n                reporter.errorUnusableHashFunc(hashFuncName, error);\n                return false;\n            }\n            return true;\n        };\n        if (typeof options !== \"object\") {\n            throw new Error(\"webpack-subresource-integrity: argument must be an object\");\n        }\n        this.options = Object.assign({ hashFuncNames: [\"sha384\"], enabled: \"auto\", hashLoading: \"eager\" }, options);\n    }\n    /**\n     * @internal\n     */\n    isEnabled(compilation) {\n        if (this.options.enabled === \"auto\") {\n            return compilation.options.mode !== \"development\";\n        }\n        return this.options.enabled;\n    }\n    apply(compiler) {\n        (0, hooks_1.install)(compiler, this.setup);\n    }\n}\nexports.SubresourceIntegrityPlugin = SubresourceIntegrityPlugin;\n"]}