From bcd3c1bbeeb57bfac728d65b543133719f167125 Mon Sep 17 00:00:00 2001 From: Krzysztof Kotowicz Date: Thu, 5 Mar 2020 13:41:52 +0100 Subject: [PATCH] Removing `getPolicyNames`. (#264) A proper introspection at policy creation time (possibly via events) will be created at a later point. Fixes #235. --- dist/cjs/trustedtypes.api_only.js | 15 --- dist/es5/trustedtypes.api_only.build.js | 20 ++-- dist/es5/trustedtypes.api_only.build.js.map | 2 +- dist/es5/trustedtypes.build.js | 46 ++++---- dist/es5/trustedtypes.build.js.map | 2 +- dist/es6/trustedtypes.api_only.build.js | 20 ++-- dist/es6/trustedtypes.api_only.build.js.map | 2 +- dist/es6/trustedtypes.build.js | 22 ++-- dist/es6/trustedtypes.build.js.map | 2 +- dist/spec/index.html | 122 ++++++++------------ externs/externs.js | 6 - spec/index.bs | 16 --- src/polyfill/api_only.js | 1 - src/trustedtypes.js | 14 --- tests/trustedtypes_test.js | 20 ---- 15 files changed, 109 insertions(+), 201 deletions(-) diff --git a/dist/cjs/trustedtypes.api_only.js b/dist/cjs/trustedtypes.api_only.js index d4362e4d..92c47f49 100644 --- a/dist/cjs/trustedtypes.api_only.js +++ b/dist/cjs/trustedtypes.api_only.js @@ -529,18 +529,6 @@ const trustedTypesBuilderTestOnly = function() { return deepClone(map); } - /** - * Returns all configured policy names (even for non-exposed policies). - * @return {!Array} - */ - function getPolicyNames() { - // TODO(msamuel): Should we sort policyNames to avoid leaking or - // encouraging dependency on the order in which policy names are - // registered? I think JavaScript builtin sorts are efficient for - // almost-sorted lists so the amortized cost is close to O(n). - return policyNames.slice(); - } - /** * Creates a TT policy. * @@ -630,8 +618,6 @@ const trustedTypesBuilderTestOnly = function() { // The main function to create policies. createPolicy, - getPolicyNames, - // Type checkers, also validating the object was initialized through a // policy. isHTML: isTrustedTypeChecker(TrustedHTML), @@ -711,7 +697,6 @@ function setupPolyfill() { 'isScriptURL': tt.isScriptURL, 'isScript': tt.isScript, 'createPolicy': tt.createPolicy, - 'getPolicyNames': tt.getPolicyNames, 'getAttributeType': tt.getAttributeType, 'getPropertyType': tt.getPropertyType, 'getTypeMapping': tt.getTypeMapping, diff --git a/dist/es5/trustedtypes.api_only.build.js b/dist/es5/trustedtypes.api_only.build.js index df4dd551..02a0d968 100644 --- a/dist/es5/trustedtypes.api_only.build.js +++ b/dist/es5/trustedtypes.api_only.build.js @@ -11,20 +11,20 @@ da.prototype.toString=function(){return this.a};var ca=function(){function a(e){ var fa="function"==typeof Object.create?Object.create:function(a){function c(){}c.prototype=a;return new c},M;if("function"==typeof Object.setPrototypeOf)M=Object.setPrototypeOf;else{var R;a:{var ha={b:!0},ia={};try{ia.__proto__=ha;R=ia.b;break a}catch(a){}R=!1}M=R?function(a,c){a.__proto__=c;if(a.__proto__!==c)throw new TypeError(a+" is not extensible");return a}:null}var pa=M; function S(a,c){a.prototype=fa(c.prototype);a.prototype.constructor=a;if(pa)pa(a,c);else for(var e in c)if("prototype"!=e)if(Object.defineProperties){var g=Object.getOwnPropertyDescriptor(c,e);g&&Object.defineProperty(a,e,g)}else a[e]=c[e];a.F=c.prototype}function T(a,c){return Object.prototype.hasOwnProperty.call(a,c)} function qa(a,c){if(c){var e=A;a=a.split(".");for(var g=0;g}\n */\nexport function getUnsafeAttributeEventHandlers() {\n if (typeof window !== 'undefined') {\n const eventHandlers = [];\n for (const name in HTMLElement.prototype) {\n if (name.slice(0, 2) === 'on') {\n eventHandlers.push(name);\n }\n }\n return eventHandlers;\n } else {\n return unsafeAttributeEventHandlers;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\nimport {getUnsafeAttributeEventHandlers} from './utils/eventHandlers.js';\n\nconst isBrowser = typeof window !== 'undefined';\n\nconst rejectInputFn = (s) => {\n throw new TypeError('undefined conversion');\n};\n\nconst rejectInputDefaultPolicyFn = (s) => null;\n\nconst {toLowerCase, toUpperCase} = String.prototype;\n\nexport const HTML_NS = 'http://www.w3.org/1999/xhtml';\nexport const XLINK_NS = 'http://www.w3.org/1999/xlink';\nexport const SVG_NS = 'http://www.w3.org/2000/svg';\n\n/**\n * @constructor\n * @property {!function(string):TrustedHTML} createHTML\n * @property {!function(string):TrustedURL} createURL\n * @property {!function(string):TrustedScriptURL} createScriptURL\n * @property {!function(string):TrustedScript} createScript\n * @property {!string} name\n */\nexport const TrustedTypePolicy = function() {\n throw new TypeError('Illegal constructor');\n};\n\n/**\n * @constructor\n */\nexport const TrustedTypePolicyFactory = function() {\n throw new TypeError('Illegal constructor');\n};\n\n/* eslint-disable no-unused-vars */\n/**\n * @typedef {TrustedTypesInnerPolicy}\n * @property {function(string):string} createHTML\n * @property {function(string):string} createURL\n * @property {function(string):string} createScriptURL\n * @property {function(string):string} createScript\n */\nconst TrustedTypesInnerPolicy = {};\n\n/**\n * @typedef {!Object,\n * properties: !Object}>}\n */\nconst TrustedTypesTypeMap = {};\n/* eslint-enable no-unused-vars */\n\nexport const DEFAULT_POLICY_NAME = 'default';\n\n\nexport const trustedTypesBuilderTestOnly = function() {\n // Capture common names early.\n const {\n assign, create, defineProperty, freeze, getOwnPropertyNames,\n getPrototypeOf, prototype: ObjectPrototype,\n } = Object;\n\n const {hasOwnProperty} = ObjectPrototype;\n\n const {\n forEach, push,\n } = Array.prototype;\n\n const creatorSymbol = Symbol();\n\n /**\n * Getter for the privateMap.\n * @param {Object} obj Key of the privateMap\n * @return {Object} Private storage.\n */\n const privates = function(obj) {\n let v = privateMap.get(obj);\n if (v === undefined) {\n v = create(null); // initialize the private storage.\n privateMap.set(obj, v);\n }\n return v;\n };\n\n /**\n * Called before attacker-controlled code on an internal collections,\n * copies prototype members onto the instance directly, so that later\n * changes to prototypes cannot expose collection internals.\n * @param {!T} collection\n * @return {!T} collection\n * @template T\n */\n function selfContained(collection) {\n const proto = getPrototypeOf(collection);\n if (proto == null || getPrototypeOf(proto) !== ObjectPrototype) {\n throw new Error(); // Loop below is insufficient.\n }\n for (const key of getOwnPropertyNames(proto)) {\n defineProperty(collection, key, {value: collection[key]});\n }\n return collection;\n }\n\n /**\n * Map for private properties of Trusted Types object.\n * This is so that the access to the type constructor does not give\n * the ability to create typed values.\n * @type {WeakMap}\n */\n const privateMap = selfContained(new WeakMap());\n\n /**\n * List of all configured policy names.\n * @type {Array}\n */\n const policyNames = selfContained([]);\n\n /**\n * Allowed policy names.\n * Applied only if enforceNameRestrictions is true.\n * @type {Array}\n */\n const allowedNames = selfContained([]);\n\n /**\n * Should duplicate prolicy names be allowed.\n * Applied only if enforceNameRestrictions is true.\n * @type {boolean}\n */\n let allowDuplicateNames = true;\n\n /**\n * A reference to a default policy, if created.\n * @type {TrustedTypePolicy}\n */\n let defaultPolicy = null;\n\n /**\n * Whether to enforce allowedNames in createPolicy().\n * @type {boolean}\n */\n let enforceNameRestrictions = false;\n\n\n /**\n * A value that is trusted to have certain security-relevant properties\n * because the sources of such values are controlled.\n */\n class TrustedType {\n /**\n * Constructor for TrustedType. Only allowed to be called from within a\n * policy.\n * @param {symbol} s creatorSymbol\n * @param {string} policyName The name of the policy this object was\n * created by.\n */\n constructor(s, policyName) {\n // TODO: Figure out if symbol is needed, if the value is in privateMap.\n if (s !== creatorSymbol) {\n throw new Error('cannot call the constructor');\n }\n defineProperty(this, 'policyName',\n {value: '' + policyName, enumerable: true});\n }\n\n /**\n * Returns the wrapped string value of the object.\n * @return {string}\n * @override\n */\n toString() {\n return privates(this)['v'];\n }\n\n /**\n * Returns the wrapped string value of the object.\n * @return {string}\n * @override\n */\n valueOf() {\n return privates(this)['v'];\n }\n }\n\n /**\n * @param {function(new:TrustedType, symbol, string)} SubClass\n * @param {string} canonName The class name which should be independent of\n * any renaming pass and which is relied upon by the enforcer and for\n * native type interop.\n */\n function lockdownTrustedType(SubClass, canonName) {\n freeze(SubClass.prototype);\n delete SubClass.name;\n defineProperty(SubClass, 'name', {value: canonName});\n }\n\n /**\n * Trusted URL object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedURL extends TrustedType {\n }\n lockdownTrustedType(TrustedURL, 'TrustedURL');\n\n /**\n * Trusted Script URL object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedScriptURL extends TrustedType {\n }\n lockdownTrustedType(TrustedScriptURL, 'TrustedScriptURL');\n\n /**\n * Trusted HTML object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedHTML extends TrustedType {\n }\n lockdownTrustedType(TrustedHTML, 'TrustedHTML');\n\n /**\n * Trusted Script object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedScript extends TrustedType {\n }\n lockdownTrustedType(TrustedScript, 'TrustedScript');\n\n lockdownTrustedType(TrustedType, 'TrustedType');\n\n // Common constants.\n const emptyHTML = freeze(create(new TrustedHTML(creatorSymbol, '')));\n privates(emptyHTML)['v'] = '';\n const emptyScript = freeze(create(new TrustedScript(creatorSymbol, '')));\n privates(emptyScript)['v'] = '';\n\n /**\n * A map of attribute / property names to allowed types\n * for known namespaces.\n * @type {!Object}\n * @export\n */\n const TYPE_MAP = {\n [HTML_NS]: {\n // TODO(koto): Figure out what to to with \n 'A': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'AREA': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'BASE': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'BUTTON': {\n 'attributes': {\n 'formaction': TrustedURL.name,\n },\n },\n 'EMBED': {\n 'attributes': {\n 'src': TrustedScriptURL.name,\n },\n },\n 'FORM': {\n 'attributes': {\n 'action': TrustedURL.name,\n },\n },\n 'FRAME': {\n 'attributes': {\n 'src': TrustedURL.name,\n },\n },\n 'IFRAME': {\n 'attributes': {\n 'src': TrustedURL.name,\n 'srcdoc': TrustedHTML.name,\n },\n },\n 'INPUT': {\n 'attributes': {\n 'formaction': TrustedURL.name,\n },\n },\n 'OBJECT': {\n 'attributes': {\n 'data': TrustedScriptURL.name,\n 'codebase': TrustedScriptURL.name,\n },\n },\n // TODO(koto): Figure out what to do with portals.\n 'SCRIPT': {\n 'attributes': {\n 'src': TrustedScriptURL.name,\n 'text': TrustedScript.name,\n },\n 'properties': {\n 'innerText': TrustedScript.name,\n 'textContent': TrustedScript.name,\n 'text': TrustedScript.name,\n },\n },\n '*': {\n 'attributes': {},\n 'properties': {\n 'innerHTML': TrustedHTML.name,\n 'outerHTML': TrustedHTML.name,\n },\n },\n },\n [XLINK_NS]: {\n '*': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n 'properties': {},\n },\n },\n [SVG_NS]: {\n '*': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n 'properties': {},\n },\n },\n };\n\n /**\n * A map of element property to HTML attribute names.\n * @type {!Object}\n */\n const ATTR_PROPERTY_MAP = {\n 'codebase': 'codeBase',\n 'formaction': 'formAction',\n };\n\n // Edge doesn't support srcdoc.\n if (isBrowser && !('srcdoc' in HTMLIFrameElement.prototype)) {\n delete TYPE_MAP[HTML_NS]['IFRAME']['attributes']['srcdoc'];\n }\n\n // in HTML, clone attributes into properties.\n for (const tag of Object.keys(TYPE_MAP[HTML_NS])) {\n if (!TYPE_MAP[HTML_NS][tag]['properties']) {\n TYPE_MAP[HTML_NS][tag]['properties'] = {};\n }\n for (const attr of Object.keys(TYPE_MAP[HTML_NS][tag]['attributes'])) {\n TYPE_MAP[HTML_NS][tag]['properties'][\n ATTR_PROPERTY_MAP[attr] ? ATTR_PROPERTY_MAP[attr] : attr\n ] = TYPE_MAP[HTML_NS][tag]['attributes'][attr];\n }\n }\n\n // Add inline event handlers attribute names.\n for (const name of getUnsafeAttributeEventHandlers()) {\n TYPE_MAP[HTML_NS]['*']['attributes'][name] = 'TrustedScript';\n TYPE_MAP[SVG_NS]['*']['attributes'][name] = 'TrustedScript';\n }\n\n /**\n * @type {!Object}\n */\n const createTypeMapping = {\n 'createHTML': TrustedHTML,\n 'createScriptURL': TrustedScriptURL,\n 'createURL': TrustedURL,\n 'createScript': TrustedScript,\n };\n\n const createFunctionAllowed = createTypeMapping.hasOwnProperty;\n\n /**\n * Function generating a type checker.\n * @template T\n * @param {T} type The type to check against.\n * @return {function(*):boolean}\n */\n function isTrustedTypeChecker(type) {\n return (obj) => (obj instanceof type) && privateMap.has(obj);\n }\n\n /**\n * Wraps a user-defined policy rules with TT constructor\n * @param {string} policyName The policy name\n * @param {TrustedTypesInnerPolicy} innerPolicy InnerPolicy\n * @return {!TrustedTypePolicy} Frozen policy object\n */\n function wrapPolicy(policyName, innerPolicy) {\n /**\n * @template T\n * @param {function(new:T, symbol, string)} Ctor a trusted type constructor\n * @param {string} methodName the policy factory method name\n * @return {function(string):!T} a factory that produces instances of Ctor.\n */\n function creator(Ctor, methodName) {\n // This causes thisValue to be null when called below.\n const method = innerPolicy[methodName] || (\n policyName == DEFAULT_POLICY_NAME ?\n rejectInputDefaultPolicyFn : rejectInputFn\n );\n const policySpecificType = freeze(new Ctor(creatorSymbol, policyName));\n const factory = {\n [methodName](s, ...args) {\n // Trick to get methodName to show in stacktrace.\n let result = method('' + s, ...args);\n if (result === undefined || result === null) {\n if (policyName == DEFAULT_POLICY_NAME) {\n // These values mean that the input was rejected. This will cause\n // a violation later, don't create types for them.\n return result;\n }\n result = '';\n }\n const allowedValue = '' + result;\n const o = freeze(create(policySpecificType));\n privates(o)['v'] = allowedValue;\n return o;\n },\n }[methodName];\n return freeze(factory);\n }\n\n const policy = create(TrustedTypePolicy.prototype);\n\n for (const name of getOwnPropertyNames(createTypeMapping)) {\n policy[name] = creator(createTypeMapping[name], name);\n }\n defineProperty(policy, 'name', {\n value: policyName,\n writable: false,\n configurable: false,\n enumerable: true,\n });\n\n return /** @type {!TrustedTypePolicy} */ (freeze(policy));\n }\n\n /**\n * Returns the name of the trusted type required for a given element\n * attribute.\n * @param {string} tagName The name of the tag of the element.\n * @param {string} attribute The name of the attribute.\n * @param {string=} elementNs Element namespace.\n * @param {string=} attributeNs The attribute namespace.\n * @return {string?} Required type name or null, if a Trusted\n * Type is not required.\n */\n function getAttributeType(tagName, attribute, elementNs = '',\n attributeNs = '') {\n const canonicalAttr = toLowerCase.apply(String(attribute));\n return getTypeInternal_(tagName, 'attributes', canonicalAttr,\n elementNs, attributeNs) || null;\n }\n\n /**\n * Returns a type name from a type map.\n * @param {string} tag A tag name.\n * @param {string} container 'attributes' or 'properties'\n * @param {string} name The attribute / property name.\n * @param {string=} elNs Element namespace.\n * @param {string=} attrNs Attribute namespace.\n * @return {string|undefined}\n * @private\n */\n function getTypeInternal_(tag, container, name, elNs = '', attrNs = '') {\n const canonicalTag = toUpperCase.apply(String(tag));\n\n let ns = attrNs ? attrNs : elNs;\n if (!ns) {\n ns = HTML_NS;\n }\n const map = hasOwnProperty.apply(TYPE_MAP, [ns]) ? TYPE_MAP[ns] : null;\n if (!map) {\n return;\n }\n if (hasOwnProperty.apply(map, [canonicalTag]) &&\n map[canonicalTag] &&\n hasOwnProperty.apply(map[canonicalTag][container], [name]) &&\n map[canonicalTag][container][name]) {\n return map[canonicalTag][container][name];\n }\n\n if (hasOwnProperty.apply(map, ['*']) &&\n hasOwnProperty.apply(map['*'][container], [name]) &&\n map['*'][container][name]) {\n return map['*'][container][name];\n }\n }\n\n /**\n * Returns the name of the trusted type required for a given element property.\n * @param {string} tagName The name of the tag of the element.\n * @param {string} property The property.\n * @param {string=} elementNs Element namespace.\n * @return {string?} Required type name or null, if a Trusted\n * Type is not required.\n */\n function getPropertyType(tagName, property, elementNs = '') {\n // TODO: Support namespaces.\n return getTypeInternal_(\n tagName, 'properties', String(property), elementNs) || null;\n }\n\n /**\n * Returns the type map-like object, that resolves a name of a type for a\n * given tag + attribute / property in a given namespace.\n * The keys of the map are uppercase tag names. Map entry has mappings between\n * a lowercase attribute name / case-sensitive property name and a name of the\n * type that is required for that attribute / property.\n * Example entry for 'IMG': {\"attributes\": {\"src\": \"TrustedHTML\"}}\n * @param {string=} namespaceUri The namespace URI (will use the current\n * document namespace URI if omitted).\n * @return {TrustedTypesTypeMap}\n */\n function getTypeMapping(namespaceUri = '') {\n if (!namespaceUri) {\n try {\n namespaceUri = document.documentElement.namespaceURI;\n } catch (e) {\n namespaceUri = HTML_NS;\n }\n }\n /**\n * @template T\n * @private\n * @param {T} o\n * @return {T}\n */\n function deepClone(o) {\n return JSON.parse(JSON.stringify(o));\n }\n const map = TYPE_MAP[namespaceUri];\n if (!map) {\n return {};\n }\n return deepClone(map);\n }\n\n /**\n * Returns all configured policy names (even for non-exposed policies).\n * @return {!Array}\n */\n function getPolicyNames() {\n // TODO(msamuel): Should we sort policyNames to avoid leaking or\n // encouraging dependency on the order in which policy names are\n // registered? I think JavaScript builtin sorts are efficient for\n // almost-sorted lists so the amortized cost is close to O(n).\n return policyNames.slice();\n }\n\n /**\n * Creates a TT policy.\n *\n * Returns a frozen object representing a policy - a collection of functions\n * that may create TT objects based on the user-provided rules specified\n * in the policy object.\n *\n * @param {string} name A unique name of the policy.\n * @param {TrustedTypesInnerPolicy} policy Policy rules object.\n * @return {TrustedTypePolicy} The policy that may create TT objects\n * according to the policy rules.\n */\n function createPolicy(name, policy) {\n const pName = '' + name; // Assert it's a string\n\n if (!pName.match(/^[-#a-zA-Z0-9=_/@.%]+$/g)) {\n throw new TypeError('Policy ' + pName + ' contains invalid characters.');\n }\n\n if (enforceNameRestrictions && allowedNames.indexOf(pName) === -1) {\n throw new TypeError('Policy ' + pName + ' disallowed.');\n }\n\n if (pName === DEFAULT_POLICY_NAME && defaultPolicy) {\n throw new TypeError('Policy ' + pName + ' already exists.');\n }\n if (enforceNameRestrictions && !allowDuplicateNames &&\n policyNames.indexOf(pName) !== -1) {\n throw new TypeError('Policy ' + pName + ' exists.');\n }\n // Register the name early so that if policy getters unwisely calls\n // across protection domains to code that reenters this function,\n // policy author still has rights to the name.\n policyNames.push(pName);\n\n // Only copy own properties of names present in createTypeMapping.\n const innerPolicy = create(null);\n if (policy && typeof policy === 'object') {\n // Treat non-objects as empty policies.\n for (const key of getOwnPropertyNames(policy)) {\n if (createFunctionAllowed.call(createTypeMapping, key)) {\n innerPolicy[key] = policy[key];\n }\n }\n } else {\n // eslint-disable-next-line no-console\n console.warn('trustedTypes.createPolicy ' + pName +\n ' was given an empty policy');\n }\n freeze(innerPolicy);\n\n const wrappedPolicy = wrapPolicy(pName, innerPolicy);\n\n if (pName === DEFAULT_POLICY_NAME) {\n defaultPolicy = wrappedPolicy;\n }\n\n return wrappedPolicy;\n }\n\n /**\n * Applies the policy name restrictions.\n * @param {!Array} allowedPolicyNames\n * @param {boolean} allowDuplicates\n */\n function setPolicyNameRestrictions(allowedPolicyNames, allowDuplicates) {\n enforceNameRestrictions = true;\n allowedNames.length = 0;\n forEach.call(allowedPolicyNames, (el) => {\n push.call(allowedNames, '' + el);\n });\n allowDuplicateNames = allowDuplicates;\n policyNames.length = 0; // Clear already used policy names list.\n }\n\n /**\n * Clears the policy name restrictions.\n */\n function clearPolicyNameRestrictions() {\n enforceNameRestrictions = false;\n }\n\n /**\n * Returns the default policy, or null if it was not created.\n * @return {TrustedTypePolicy}\n */\n function getDefaultPolicy() {\n return defaultPolicy;\n }\n\n /**\n * Resets the default policy.\n */\n function resetDefaultPolicy() {\n defaultPolicy = null;\n policyNames.splice(policyNames.indexOf(DEFAULT_POLICY_NAME), 1);\n }\n\n const api = create(TrustedTypePolicyFactory.prototype);\n assign(api, {\n // The main function to create policies.\n createPolicy,\n\n getPolicyNames,\n\n // Type checkers, also validating the object was initialized through a\n // policy.\n isHTML: isTrustedTypeChecker(TrustedHTML),\n isURL: isTrustedTypeChecker(TrustedURL),\n isScriptURL: isTrustedTypeChecker(TrustedScriptURL),\n isScript: isTrustedTypeChecker(TrustedScript),\n\n getAttributeType,\n getPropertyType,\n getTypeMapping,\n emptyHTML,\n emptyScript,\n defaultPolicy, // Just to make the compiler happy, this is overridden below.\n\n TrustedHTML: TrustedHTML,\n TrustedURL: TrustedURL,\n TrustedScriptURL: TrustedScriptURL,\n TrustedScript: TrustedScript,\n });\n\n defineProperty(api, 'defaultPolicy', {\n get: getDefaultPolicy,\n set: () => {},\n });\n\n return {\n trustedTypes: freeze(api),\n setPolicyNameRestrictions,\n clearPolicyNameRestrictions,\n getDefaultPolicy,\n resetDefaultPolicy,\n };\n};\n\n\nexport const {\n trustedTypes,\n setPolicyNameRestrictions,\n clearPolicyNameRestrictions,\n getDefaultPolicy,\n resetDefaultPolicy,\n} = trustedTypesBuilderTestOnly();\n\n",null,"/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n/**\n * @fileoverview Entry point for a polyfill that only defines the types\n * (i.e. no enforcement logic).\n */\nimport {trustedTypes, TrustedTypePolicy, TrustedTypePolicyFactory} from\n '../trustedtypes.js';\n\nconst tt = trustedTypes;\n\n/**\n * Sets up the public Trusted Types API in the global object.\n */\nfunction setupPolyfill() {\n // We use array accessors to make sure Closure compiler will not alter the\n // names of the properties..\n\n // we setup the polyfill only in browser environment.\n if (typeof window === 'undefined') {\n return;\n }\n const rootProperty = 'trustedTypes';\n\n // Convert old window.TrustedTypes to window.trustedTypes.\n if (window['TrustedTypes'] && typeof window[rootProperty] === 'undefined') {\n window[rootProperty] = Object.freeze(window['TrustedTypes']);\n }\n\n if (typeof window[rootProperty] !== 'undefined') {\n return;\n }\n\n const publicApi = Object.create(TrustedTypePolicyFactory.prototype);\n Object.assign(publicApi, {\n 'isHTML': tt.isHTML,\n 'isURL': tt.isURL,\n 'isScriptURL': tt.isScriptURL,\n 'isScript': tt.isScript,\n 'createPolicy': tt.createPolicy,\n 'getPolicyNames': tt.getPolicyNames,\n 'getAttributeType': tt.getAttributeType,\n 'getPropertyType': tt.getPropertyType,\n 'getTypeMapping': tt.getTypeMapping,\n 'emptyHTML': tt.emptyHTML,\n 'emptyScript': tt.emptyScript,\n '_isPolyfill_': true,\n });\n Object.defineProperty(\n publicApi,\n 'defaultPolicy',\n Object.getOwnPropertyDescriptor(tt, 'defaultPolicy') || {});\n\n window[rootProperty] = Object.freeze(publicApi);\n\n window['TrustedHTML'] = tt.TrustedHTML;\n window['TrustedURL'] = tt.TrustedURL;\n window['TrustedScriptURL'] = tt.TrustedScriptURL;\n window['TrustedScript'] = tt.TrustedScript;\n window['TrustedTypePolicy'] = TrustedTypePolicy;\n window['TrustedTypePolicyFactory'] = TrustedTypePolicyFactory;\n}\n\nsetupPolyfill();\n\nexport default tt;\n"]} \ No newline at end of file +{"version":3,"sources":[" [synthetic:es6/util/arrayiterator] "," [synthetic:util/defineproperty] "," [synthetic:util/global] "," [synthetic:es6/symbol] "," [synthetic:es6/util/makeiterator] "," [synthetic:es6/util/arrayfromiterator] "," [synthetic:util/objectcreate] "," [synthetic:es6/util/setprototypeof] "," [synthetic:es6/util/inherits] "," [synthetic:util/owns] "," [synthetic:util/polyfill] "," [synthetic:es6/weakmap] "," [synthetic:es6/util/assign] "," [synthetic:es6/object/assign] ","src/utils/eventHandlers.js","src/trustedtypes.js"," [synthetic:es6/util/arrayfromiterable] ","src/polyfill/api_only.js"],"names":["$jscomp.defineProperty","$jscomp.global","$jscomp.initSymbol","$jscomp.Symbol","$jscomp.SymbolClass","$jscomp.SYMBOL_PREFIX","$jscomp.arrayIteratorImpl","$jscomp.objectCreate","$jscomp.setPrototypeOf","$jscomp.polyfill","$jscomp.makeIterator","$jscomp.owns","$jscomp.assign","unsafeAttributeEventHandlers","getUnsafeAttributeEventHandlers","window","eventHandlers","name","HTMLElement","prototype","slice","push","isBrowser","rejectInputFn","TypeError","rejectInputDefaultPolicyFn","String","toLowerCase","toUpperCase","TrustedTypePolicy","TrustedTypePolicyFactory","trustedTypes","trustedTypesBuilderTestOnly","TrustedScript","TrustedHTML","TrustedScriptURL","TrustedURL","constructor","TrustedType","s","policyName","creatorSymbol","Error","defineProperty","value","enumerable","privates","obj","v","privateMap","get","undefined","create","set","selfContained","collection","proto","getPrototypeOf","ObjectPrototype","getOwnPropertyNames","key","lockdownTrustedType","SubClass","canonName","freeze","isTrustedTypeChecker","type","has","wrapPolicy","innerPolicy","creator","Ctor","methodName","method","DEFAULT_POLICY_NAME","policySpecificType","factory","args","result","$jscomp.arrayFromIterator","allowedValue","o","policy","createTypeMapping","writable","configurable","getTypeInternal_","tag","container","elNs","attrNs","canonicalTag","apply","ns","HTML_NS","map","hasOwnProperty","TYPE_MAP","getDefaultPolicy","defaultPolicy","Object","assign","Array","forEach","Symbol","WeakMap","policyNames","allowedNames","allowDuplicateNames","enforceNameRestrictions","toString","valueOf","$jscomp.inherits","emptyHTML","emptyScript","XLINK_NS","SVG_NS","ATTR_PROPERTY_MAP","HTMLIFrameElement","keys","attr","createFunctionAllowed","api","createPolicy","match","indexOf","call","console","warn","wrappedPolicy","isHTML","isURL","isScriptURL","isScript","getAttributeType","tagName","attribute","elementNs","attributeNs","canonicalAttr","getPropertyType","property","getTypeMapping","namespaceUri","document","documentElement","namespaceURI","e","JSON","parse","stringify","setPolicyNameRestrictions","allowedPolicyNames","allowDuplicates","length","el","clearPolicyNameRestrictions","resetDefaultPolicy","splice","publicApi","tt","getOwnPropertyDescriptor"],"mappings":"A;;;;;;;;AA2B4B,QAAA,GAAQ,CAAC,CAAD,CAAQ,CAC1C,IAAI,EAAQ,CACZ,OAAO,SAAQ,EAAG,CAChB,MAAI,EAAJ,CAAY,CAAA,OAAZ,CACS,CACL,KAAM,CAAA,CADD,CAEL,MAAO,CAAA,CAAM,CAAA,EAAN,CAFF,CADT,CAMS,CAAC,KAAM,CAAA,CAAP,CAPO,CAFwB,CCS5C,IAAAA,EAC4D,UAAxD,EAAsB,MAAO,OAAA,iBAA7B,CACA,MAAA,eADA,CAEA,QAAQ,CAAC,CAAD,CAAS,CAAT,CAAmB,CAAnB,CAA+B,CAOjC,CAAJ,EAAc,KAAA,UAAd,EAAiC,CAAjC,EAA2C,MAAA,UAA3C,GACA,CAAA,CAAO,CAAP,CADA,CACmB,CAAA,MADnB,CAPqC,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AzD,eAAA,CACIoH,EADJ,CAEI,eAFJ,CAGI3D,MAAA6D,yBAAA,CAAgCD,CAAhC;AAAoC,eAApC,CAHJ,EAG4D,EAH5D,CAKAjJ,OAAA,aAAA,CAAuBqF,MAAApC,OAAA,CAAc+F,EAAd,CAEvBhJ,OAAA,YAAA,CAAwBiJ,CAAA9H,YACxBnB,OAAA,WAAA,CAAuBiJ,CAAA5H,WACvBrB,OAAA,iBAAA,CAA6BiJ,CAAA7H,iBAC7BpB,OAAA,cAAA,CAA0BiJ,CAAA/H,cAC1BlB,OAAA,kBAAA,CAA8Bc,EAC9Bd,OAAA,yBAAA,CAAqCe,CA9BrC","file":"trustedtypes.api_only.build.js","sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,"/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n// TODO check attributes in safari, remove legacy safe handlers\nconst unsafeAttributeEventHandlers = [\n 'onabort',\n 'onactivate',\n 'onactivateinvisible',\n 'onafterprint',\n 'onafterupdate',\n 'onanimationcancel',\n 'onanimationend',\n 'onanimationiteration',\n 'onanimationstart',\n 'onariarequest',\n 'onauxclick',\n 'onbeforeactivate',\n 'onbeforecopy',\n 'onbeforecut',\n 'onbeforedeactivate',\n 'onbeforeeditfocus',\n 'onbeforepaste',\n 'onbeforeprint',\n 'onbeforeunload',\n 'onbegin',\n 'onblur',\n 'onbounce',\n 'oncancel',\n 'oncanplay',\n 'oncanplaythrough',\n 'oncellchange',\n 'onchange',\n 'onclick',\n 'onclose',\n 'oncommand',\n 'oncontextmenu',\n 'oncontrolselect',\n 'oncopy',\n 'oncuechange',\n 'oncut',\n 'ondataavailable',\n 'ondatasetchanged',\n 'ondatasetcomplete',\n 'ondblclick',\n 'ondeactivate',\n 'ondrag',\n 'ondragdrop',\n 'ondragend',\n 'ondragenter',\n 'ondragexit',\n 'ondragleave',\n 'ondragover',\n 'ondragstart',\n 'ondrop',\n 'ondurationchange',\n 'onemptied',\n 'onend',\n 'onended',\n 'onerror',\n 'onerrorupdate',\n 'onexit',\n 'onfilterchange',\n 'onfinish',\n 'onfocus',\n 'onfocusin',\n 'onfocusout',\n 'onformdata',\n 'onfullscreenchange',\n 'onfullscreenerror',\n 'ongotpointercapture',\n 'onhelp',\n 'oninput',\n 'oninvalid',\n 'onkeydown',\n 'onkeypress',\n 'onkeyup',\n 'onlayoutcomplete',\n 'onload',\n 'onloadeddata',\n 'onloadedmetadata',\n 'onloadend',\n 'onloadstart',\n 'onlosecapture',\n 'onlostpointercapture',\n 'onmediacomplete',\n 'onmediaerror',\n 'onmessage',\n 'onmousedown',\n 'onmouseenter',\n 'onmouseleave',\n 'onmousemove',\n 'onmouseout',\n 'onmouseover',\n 'onmouseup',\n 'onmousewheel',\n 'onmove',\n 'onmoveend',\n 'onmovestart',\n 'onmozfullscreenchange',\n 'onmozfullscreenerror',\n 'onmscontentzoom',\n 'onmsgesturechange',\n 'onmsgesturedoubletap',\n 'onmsgestureend',\n 'onmsgesturehold',\n 'onmsgesturestart',\n 'onmsgesturetap',\n 'onmsgotpointercapture',\n 'onmsinertiastart',\n 'onmslostpointercapture',\n 'onmsmanipulationstatechanged',\n 'onmspointercancel',\n 'onmspointerdown',\n 'onmspointerenter',\n 'onmspointerleave',\n 'onmspointermove',\n 'onmspointerout',\n 'onmspointerover',\n 'onmspointerup',\n 'onoffline',\n 'ononline',\n 'onoutofsync',\n 'onoverscroll',\n 'onpaste',\n 'onpause',\n 'onplay',\n 'onplaying',\n 'onpointercancel',\n 'onpointerdown',\n 'onpointerenter',\n 'onpointerleave',\n 'onpointermove',\n 'onpointerout',\n 'onpointerover',\n 'onpointerrawupdate',\n 'onpointerup',\n 'onprogress',\n 'onpropertychange',\n 'onratechange',\n 'onreadystatechange',\n 'onrepeat',\n 'onreset',\n 'onresize',\n 'onresizeend',\n 'onresizestart',\n 'onresume',\n 'onreverse',\n 'onrowdelete',\n 'onrowenter',\n 'onrowexit',\n 'onrowinserted',\n 'onscroll',\n 'onscrollend',\n 'onsearch',\n 'onseek',\n 'onseeked',\n 'onseeking',\n 'onselect',\n 'onselectionchange',\n 'onselectstart',\n 'onshow',\n 'onstalled',\n 'onstart',\n 'onstop',\n 'onstorage',\n 'onsubmit',\n 'onsuspend',\n 'onsynchrestored',\n 'ontimeerror',\n 'ontimeupdate',\n 'ontoggle',\n 'ontrackchange',\n 'ontransitioncancel',\n 'ontransitionend',\n 'ontransitionrun',\n 'ontransitionstart',\n 'onunload',\n 'onurlflip',\n 'onvolumechange',\n 'onwaiting',\n 'onwebkitanimationend',\n 'onwebkitanimationiteration',\n 'onwebkitanimationstart',\n 'onwebkitfullscreenchange',\n 'onwebkitfullscreenerror',\n 'onwebkittransitionend',\n 'onwheel',\n];\n\n/**\n * Returns an array of all event handlers. Some of the event handlers may be\n * supported only in some browsers.\n *\n * For every event type that the browser supports, SVG supports that as an event\n * attribute, following the same requirements as for HTML event attributes.\n * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/Events\n *\n * @return {!Array}\n */\nexport function getUnsafeAttributeEventHandlers() {\n if (typeof window !== 'undefined') {\n const eventHandlers = [];\n for (const name in HTMLElement.prototype) {\n if (name.slice(0, 2) === 'on') {\n eventHandlers.push(name);\n }\n }\n return eventHandlers;\n } else {\n return unsafeAttributeEventHandlers;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\nimport {getUnsafeAttributeEventHandlers} from './utils/eventHandlers.js';\n\nconst isBrowser = typeof window !== 'undefined';\n\nconst rejectInputFn = (s) => {\n throw new TypeError('undefined conversion');\n};\n\nconst rejectInputDefaultPolicyFn = (s) => null;\n\nconst {toLowerCase, toUpperCase} = String.prototype;\n\nexport const HTML_NS = 'http://www.w3.org/1999/xhtml';\nexport const XLINK_NS = 'http://www.w3.org/1999/xlink';\nexport const SVG_NS = 'http://www.w3.org/2000/svg';\n\n/**\n * @constructor\n * @property {!function(string):TrustedHTML} createHTML\n * @property {!function(string):TrustedURL} createURL\n * @property {!function(string):TrustedScriptURL} createScriptURL\n * @property {!function(string):TrustedScript} createScript\n * @property {!string} name\n */\nexport const TrustedTypePolicy = function() {\n throw new TypeError('Illegal constructor');\n};\n\n/**\n * @constructor\n */\nexport const TrustedTypePolicyFactory = function() {\n throw new TypeError('Illegal constructor');\n};\n\n/* eslint-disable no-unused-vars */\n/**\n * @typedef {TrustedTypesInnerPolicy}\n * @property {function(string):string} createHTML\n * @property {function(string):string} createURL\n * @property {function(string):string} createScriptURL\n * @property {function(string):string} createScript\n */\nconst TrustedTypesInnerPolicy = {};\n\n/**\n * @typedef {!Object,\n * properties: !Object}>}\n */\nconst TrustedTypesTypeMap = {};\n/* eslint-enable no-unused-vars */\n\nexport const DEFAULT_POLICY_NAME = 'default';\n\n\nexport const trustedTypesBuilderTestOnly = function() {\n // Capture common names early.\n const {\n assign, create, defineProperty, freeze, getOwnPropertyNames,\n getPrototypeOf, prototype: ObjectPrototype,\n } = Object;\n\n const {hasOwnProperty} = ObjectPrototype;\n\n const {\n forEach, push,\n } = Array.prototype;\n\n const creatorSymbol = Symbol();\n\n /**\n * Getter for the privateMap.\n * @param {Object} obj Key of the privateMap\n * @return {Object} Private storage.\n */\n const privates = function(obj) {\n let v = privateMap.get(obj);\n if (v === undefined) {\n v = create(null); // initialize the private storage.\n privateMap.set(obj, v);\n }\n return v;\n };\n\n /**\n * Called before attacker-controlled code on an internal collections,\n * copies prototype members onto the instance directly, so that later\n * changes to prototypes cannot expose collection internals.\n * @param {!T} collection\n * @return {!T} collection\n * @template T\n */\n function selfContained(collection) {\n const proto = getPrototypeOf(collection);\n if (proto == null || getPrototypeOf(proto) !== ObjectPrototype) {\n throw new Error(); // Loop below is insufficient.\n }\n for (const key of getOwnPropertyNames(proto)) {\n defineProperty(collection, key, {value: collection[key]});\n }\n return collection;\n }\n\n /**\n * Map for private properties of Trusted Types object.\n * This is so that the access to the type constructor does not give\n * the ability to create typed values.\n * @type {WeakMap}\n */\n const privateMap = selfContained(new WeakMap());\n\n /**\n * List of all configured policy names.\n * @type {Array}\n */\n const policyNames = selfContained([]);\n\n /**\n * Allowed policy names.\n * Applied only if enforceNameRestrictions is true.\n * @type {Array}\n */\n const allowedNames = selfContained([]);\n\n /**\n * Should duplicate prolicy names be allowed.\n * Applied only if enforceNameRestrictions is true.\n * @type {boolean}\n */\n let allowDuplicateNames = true;\n\n /**\n * A reference to a default policy, if created.\n * @type {TrustedTypePolicy}\n */\n let defaultPolicy = null;\n\n /**\n * Whether to enforce allowedNames in createPolicy().\n * @type {boolean}\n */\n let enforceNameRestrictions = false;\n\n\n /**\n * A value that is trusted to have certain security-relevant properties\n * because the sources of such values are controlled.\n */\n class TrustedType {\n /**\n * Constructor for TrustedType. Only allowed to be called from within a\n * policy.\n * @param {symbol} s creatorSymbol\n * @param {string} policyName The name of the policy this object was\n * created by.\n */\n constructor(s, policyName) {\n // TODO: Figure out if symbol is needed, if the value is in privateMap.\n if (s !== creatorSymbol) {\n throw new Error('cannot call the constructor');\n }\n defineProperty(this, 'policyName',\n {value: '' + policyName, enumerable: true});\n }\n\n /**\n * Returns the wrapped string value of the object.\n * @return {string}\n * @override\n */\n toString() {\n return privates(this)['v'];\n }\n\n /**\n * Returns the wrapped string value of the object.\n * @return {string}\n * @override\n */\n valueOf() {\n return privates(this)['v'];\n }\n }\n\n /**\n * @param {function(new:TrustedType, symbol, string)} SubClass\n * @param {string} canonName The class name which should be independent of\n * any renaming pass and which is relied upon by the enforcer and for\n * native type interop.\n */\n function lockdownTrustedType(SubClass, canonName) {\n freeze(SubClass.prototype);\n delete SubClass.name;\n defineProperty(SubClass, 'name', {value: canonName});\n }\n\n /**\n * Trusted URL object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedURL extends TrustedType {\n }\n lockdownTrustedType(TrustedURL, 'TrustedURL');\n\n /**\n * Trusted Script URL object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedScriptURL extends TrustedType {\n }\n lockdownTrustedType(TrustedScriptURL, 'TrustedScriptURL');\n\n /**\n * Trusted HTML object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedHTML extends TrustedType {\n }\n lockdownTrustedType(TrustedHTML, 'TrustedHTML');\n\n /**\n * Trusted Script object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedScript extends TrustedType {\n }\n lockdownTrustedType(TrustedScript, 'TrustedScript');\n\n lockdownTrustedType(TrustedType, 'TrustedType');\n\n // Common constants.\n const emptyHTML = freeze(create(new TrustedHTML(creatorSymbol, '')));\n privates(emptyHTML)['v'] = '';\n const emptyScript = freeze(create(new TrustedScript(creatorSymbol, '')));\n privates(emptyScript)['v'] = '';\n\n /**\n * A map of attribute / property names to allowed types\n * for known namespaces.\n * @type {!Object}\n * @export\n */\n const TYPE_MAP = {\n [HTML_NS]: {\n // TODO(koto): Figure out what to to with \n 'A': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'AREA': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'BASE': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'BUTTON': {\n 'attributes': {\n 'formaction': TrustedURL.name,\n },\n },\n 'EMBED': {\n 'attributes': {\n 'src': TrustedScriptURL.name,\n },\n },\n 'FORM': {\n 'attributes': {\n 'action': TrustedURL.name,\n },\n },\n 'FRAME': {\n 'attributes': {\n 'src': TrustedURL.name,\n },\n },\n 'IFRAME': {\n 'attributes': {\n 'src': TrustedURL.name,\n 'srcdoc': TrustedHTML.name,\n },\n },\n 'INPUT': {\n 'attributes': {\n 'formaction': TrustedURL.name,\n },\n },\n 'OBJECT': {\n 'attributes': {\n 'data': TrustedScriptURL.name,\n 'codebase': TrustedScriptURL.name,\n },\n },\n // TODO(koto): Figure out what to do with portals.\n 'SCRIPT': {\n 'attributes': {\n 'src': TrustedScriptURL.name,\n 'text': TrustedScript.name,\n },\n 'properties': {\n 'innerText': TrustedScript.name,\n 'textContent': TrustedScript.name,\n 'text': TrustedScript.name,\n },\n },\n '*': {\n 'attributes': {},\n 'properties': {\n 'innerHTML': TrustedHTML.name,\n 'outerHTML': TrustedHTML.name,\n },\n },\n },\n [XLINK_NS]: {\n '*': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n 'properties': {},\n },\n },\n [SVG_NS]: {\n '*': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n 'properties': {},\n },\n },\n };\n\n /**\n * A map of element property to HTML attribute names.\n * @type {!Object}\n */\n const ATTR_PROPERTY_MAP = {\n 'codebase': 'codeBase',\n 'formaction': 'formAction',\n };\n\n // Edge doesn't support srcdoc.\n if (isBrowser && !('srcdoc' in HTMLIFrameElement.prototype)) {\n delete TYPE_MAP[HTML_NS]['IFRAME']['attributes']['srcdoc'];\n }\n\n // in HTML, clone attributes into properties.\n for (const tag of Object.keys(TYPE_MAP[HTML_NS])) {\n if (!TYPE_MAP[HTML_NS][tag]['properties']) {\n TYPE_MAP[HTML_NS][tag]['properties'] = {};\n }\n for (const attr of Object.keys(TYPE_MAP[HTML_NS][tag]['attributes'])) {\n TYPE_MAP[HTML_NS][tag]['properties'][\n ATTR_PROPERTY_MAP[attr] ? ATTR_PROPERTY_MAP[attr] : attr\n ] = TYPE_MAP[HTML_NS][tag]['attributes'][attr];\n }\n }\n\n // Add inline event handlers attribute names.\n for (const name of getUnsafeAttributeEventHandlers()) {\n TYPE_MAP[HTML_NS]['*']['attributes'][name] = 'TrustedScript';\n TYPE_MAP[SVG_NS]['*']['attributes'][name] = 'TrustedScript';\n }\n\n /**\n * @type {!Object}\n */\n const createTypeMapping = {\n 'createHTML': TrustedHTML,\n 'createScriptURL': TrustedScriptURL,\n 'createURL': TrustedURL,\n 'createScript': TrustedScript,\n };\n\n const createFunctionAllowed = createTypeMapping.hasOwnProperty;\n\n /**\n * Function generating a type checker.\n * @template T\n * @param {T} type The type to check against.\n * @return {function(*):boolean}\n */\n function isTrustedTypeChecker(type) {\n return (obj) => (obj instanceof type) && privateMap.has(obj);\n }\n\n /**\n * Wraps a user-defined policy rules with TT constructor\n * @param {string} policyName The policy name\n * @param {TrustedTypesInnerPolicy} innerPolicy InnerPolicy\n * @return {!TrustedTypePolicy} Frozen policy object\n */\n function wrapPolicy(policyName, innerPolicy) {\n /**\n * @template T\n * @param {function(new:T, symbol, string)} Ctor a trusted type constructor\n * @param {string} methodName the policy factory method name\n * @return {function(string):!T} a factory that produces instances of Ctor.\n */\n function creator(Ctor, methodName) {\n // This causes thisValue to be null when called below.\n const method = innerPolicy[methodName] || (\n policyName == DEFAULT_POLICY_NAME ?\n rejectInputDefaultPolicyFn : rejectInputFn\n );\n const policySpecificType = freeze(new Ctor(creatorSymbol, policyName));\n const factory = {\n [methodName](s, ...args) {\n // Trick to get methodName to show in stacktrace.\n let result = method('' + s, ...args);\n if (result === undefined || result === null) {\n if (policyName == DEFAULT_POLICY_NAME) {\n // These values mean that the input was rejected. This will cause\n // a violation later, don't create types for them.\n return result;\n }\n result = '';\n }\n const allowedValue = '' + result;\n const o = freeze(create(policySpecificType));\n privates(o)['v'] = allowedValue;\n return o;\n },\n }[methodName];\n return freeze(factory);\n }\n\n const policy = create(TrustedTypePolicy.prototype);\n\n for (const name of getOwnPropertyNames(createTypeMapping)) {\n policy[name] = creator(createTypeMapping[name], name);\n }\n defineProperty(policy, 'name', {\n value: policyName,\n writable: false,\n configurable: false,\n enumerable: true,\n });\n\n return /** @type {!TrustedTypePolicy} */ (freeze(policy));\n }\n\n /**\n * Returns the name of the trusted type required for a given element\n * attribute.\n * @param {string} tagName The name of the tag of the element.\n * @param {string} attribute The name of the attribute.\n * @param {string=} elementNs Element namespace.\n * @param {string=} attributeNs The attribute namespace.\n * @return {string?} Required type name or null, if a Trusted\n * Type is not required.\n */\n function getAttributeType(tagName, attribute, elementNs = '',\n attributeNs = '') {\n const canonicalAttr = toLowerCase.apply(String(attribute));\n return getTypeInternal_(tagName, 'attributes', canonicalAttr,\n elementNs, attributeNs) || null;\n }\n\n /**\n * Returns a type name from a type map.\n * @param {string} tag A tag name.\n * @param {string} container 'attributes' or 'properties'\n * @param {string} name The attribute / property name.\n * @param {string=} elNs Element namespace.\n * @param {string=} attrNs Attribute namespace.\n * @return {string|undefined}\n * @private\n */\n function getTypeInternal_(tag, container, name, elNs = '', attrNs = '') {\n const canonicalTag = toUpperCase.apply(String(tag));\n\n let ns = attrNs ? attrNs : elNs;\n if (!ns) {\n ns = HTML_NS;\n }\n const map = hasOwnProperty.apply(TYPE_MAP, [ns]) ? TYPE_MAP[ns] : null;\n if (!map) {\n return;\n }\n if (hasOwnProperty.apply(map, [canonicalTag]) &&\n map[canonicalTag] &&\n hasOwnProperty.apply(map[canonicalTag][container], [name]) &&\n map[canonicalTag][container][name]) {\n return map[canonicalTag][container][name];\n }\n\n if (hasOwnProperty.apply(map, ['*']) &&\n hasOwnProperty.apply(map['*'][container], [name]) &&\n map['*'][container][name]) {\n return map['*'][container][name];\n }\n }\n\n /**\n * Returns the name of the trusted type required for a given element property.\n * @param {string} tagName The name of the tag of the element.\n * @param {string} property The property.\n * @param {string=} elementNs Element namespace.\n * @return {string?} Required type name or null, if a Trusted\n * Type is not required.\n */\n function getPropertyType(tagName, property, elementNs = '') {\n // TODO: Support namespaces.\n return getTypeInternal_(\n tagName, 'properties', String(property), elementNs) || null;\n }\n\n /**\n * Returns the type map-like object, that resolves a name of a type for a\n * given tag + attribute / property in a given namespace.\n * The keys of the map are uppercase tag names. Map entry has mappings between\n * a lowercase attribute name / case-sensitive property name and a name of the\n * type that is required for that attribute / property.\n * Example entry for 'IMG': {\"attributes\": {\"src\": \"TrustedHTML\"}}\n * @param {string=} namespaceUri The namespace URI (will use the current\n * document namespace URI if omitted).\n * @return {TrustedTypesTypeMap}\n */\n function getTypeMapping(namespaceUri = '') {\n if (!namespaceUri) {\n try {\n namespaceUri = document.documentElement.namespaceURI;\n } catch (e) {\n namespaceUri = HTML_NS;\n }\n }\n /**\n * @template T\n * @private\n * @param {T} o\n * @return {T}\n */\n function deepClone(o) {\n return JSON.parse(JSON.stringify(o));\n }\n const map = TYPE_MAP[namespaceUri];\n if (!map) {\n return {};\n }\n return deepClone(map);\n }\n\n /**\n * Creates a TT policy.\n *\n * Returns a frozen object representing a policy - a collection of functions\n * that may create TT objects based on the user-provided rules specified\n * in the policy object.\n *\n * @param {string} name A unique name of the policy.\n * @param {TrustedTypesInnerPolicy} policy Policy rules object.\n * @return {TrustedTypePolicy} The policy that may create TT objects\n * according to the policy rules.\n */\n function createPolicy(name, policy) {\n const pName = '' + name; // Assert it's a string\n\n if (!pName.match(/^[-#a-zA-Z0-9=_/@.%]+$/g)) {\n throw new TypeError('Policy ' + pName + ' contains invalid characters.');\n }\n\n if (enforceNameRestrictions && allowedNames.indexOf(pName) === -1) {\n throw new TypeError('Policy ' + pName + ' disallowed.');\n }\n\n if (pName === DEFAULT_POLICY_NAME && defaultPolicy) {\n throw new TypeError('Policy ' + pName + ' already exists.');\n }\n if (enforceNameRestrictions && !allowDuplicateNames &&\n policyNames.indexOf(pName) !== -1) {\n throw new TypeError('Policy ' + pName + ' exists.');\n }\n // Register the name early so that if policy getters unwisely calls\n // across protection domains to code that reenters this function,\n // policy author still has rights to the name.\n policyNames.push(pName);\n\n // Only copy own properties of names present in createTypeMapping.\n const innerPolicy = create(null);\n if (policy && typeof policy === 'object') {\n // Treat non-objects as empty policies.\n for (const key of getOwnPropertyNames(policy)) {\n if (createFunctionAllowed.call(createTypeMapping, key)) {\n innerPolicy[key] = policy[key];\n }\n }\n } else {\n // eslint-disable-next-line no-console\n console.warn('trustedTypes.createPolicy ' + pName +\n ' was given an empty policy');\n }\n freeze(innerPolicy);\n\n const wrappedPolicy = wrapPolicy(pName, innerPolicy);\n\n if (pName === DEFAULT_POLICY_NAME) {\n defaultPolicy = wrappedPolicy;\n }\n\n return wrappedPolicy;\n }\n\n /**\n * Applies the policy name restrictions.\n * @param {!Array} allowedPolicyNames\n * @param {boolean} allowDuplicates\n */\n function setPolicyNameRestrictions(allowedPolicyNames, allowDuplicates) {\n enforceNameRestrictions = true;\n allowedNames.length = 0;\n forEach.call(allowedPolicyNames, (el) => {\n push.call(allowedNames, '' + el);\n });\n allowDuplicateNames = allowDuplicates;\n policyNames.length = 0; // Clear already used policy names list.\n }\n\n /**\n * Clears the policy name restrictions.\n */\n function clearPolicyNameRestrictions() {\n enforceNameRestrictions = false;\n }\n\n /**\n * Returns the default policy, or null if it was not created.\n * @return {TrustedTypePolicy}\n */\n function getDefaultPolicy() {\n return defaultPolicy;\n }\n\n /**\n * Resets the default policy.\n */\n function resetDefaultPolicy() {\n defaultPolicy = null;\n policyNames.splice(policyNames.indexOf(DEFAULT_POLICY_NAME), 1);\n }\n\n const api = create(TrustedTypePolicyFactory.prototype);\n assign(api, {\n // The main function to create policies.\n createPolicy,\n\n // Type checkers, also validating the object was initialized through a\n // policy.\n isHTML: isTrustedTypeChecker(TrustedHTML),\n isURL: isTrustedTypeChecker(TrustedURL),\n isScriptURL: isTrustedTypeChecker(TrustedScriptURL),\n isScript: isTrustedTypeChecker(TrustedScript),\n\n getAttributeType,\n getPropertyType,\n getTypeMapping,\n emptyHTML,\n emptyScript,\n defaultPolicy, // Just to make the compiler happy, this is overridden below.\n\n TrustedHTML: TrustedHTML,\n TrustedURL: TrustedURL,\n TrustedScriptURL: TrustedScriptURL,\n TrustedScript: TrustedScript,\n });\n\n defineProperty(api, 'defaultPolicy', {\n get: getDefaultPolicy,\n set: () => {},\n });\n\n return {\n trustedTypes: freeze(api),\n setPolicyNameRestrictions,\n clearPolicyNameRestrictions,\n getDefaultPolicy,\n resetDefaultPolicy,\n };\n};\n\n\nexport const {\n trustedTypes,\n setPolicyNameRestrictions,\n clearPolicyNameRestrictions,\n getDefaultPolicy,\n resetDefaultPolicy,\n} = trustedTypesBuilderTestOnly();\n\n",null,"/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n/**\n * @fileoverview Entry point for a polyfill that only defines the types\n * (i.e. no enforcement logic).\n */\nimport {trustedTypes, TrustedTypePolicy, TrustedTypePolicyFactory} from\n '../trustedtypes.js';\n\nconst tt = trustedTypes;\n\n/**\n * Sets up the public Trusted Types API in the global object.\n */\nfunction setupPolyfill() {\n // We use array accessors to make sure Closure compiler will not alter the\n // names of the properties..\n\n // we setup the polyfill only in browser environment.\n if (typeof window === 'undefined') {\n return;\n }\n const rootProperty = 'trustedTypes';\n\n // Convert old window.TrustedTypes to window.trustedTypes.\n if (window['TrustedTypes'] && typeof window[rootProperty] === 'undefined') {\n window[rootProperty] = Object.freeze(window['TrustedTypes']);\n }\n\n if (typeof window[rootProperty] !== 'undefined') {\n return;\n }\n\n const publicApi = Object.create(TrustedTypePolicyFactory.prototype);\n Object.assign(publicApi, {\n 'isHTML': tt.isHTML,\n 'isURL': tt.isURL,\n 'isScriptURL': tt.isScriptURL,\n 'isScript': tt.isScript,\n 'createPolicy': tt.createPolicy,\n 'getAttributeType': tt.getAttributeType,\n 'getPropertyType': tt.getPropertyType,\n 'getTypeMapping': tt.getTypeMapping,\n 'emptyHTML': tt.emptyHTML,\n 'emptyScript': tt.emptyScript,\n '_isPolyfill_': true,\n });\n Object.defineProperty(\n publicApi,\n 'defaultPolicy',\n Object.getOwnPropertyDescriptor(tt, 'defaultPolicy') || {});\n\n window[rootProperty] = Object.freeze(publicApi);\n\n window['TrustedHTML'] = tt.TrustedHTML;\n window['TrustedURL'] = tt.TrustedURL;\n window['TrustedScriptURL'] = tt.TrustedScriptURL;\n window['TrustedScript'] = tt.TrustedScript;\n window['TrustedTypePolicy'] = TrustedTypePolicy;\n window['TrustedTypePolicyFactory'] = TrustedTypePolicyFactory;\n}\n\nsetupPolyfill();\n\nexport default tt;\n"]} \ No newline at end of file diff --git a/dist/es5/trustedtypes.build.js b/dist/es5/trustedtypes.build.js index a12f618e..654d1a41 100644 --- a/dist/es5/trustedtypes.build.js +++ b/dist/es5/trustedtypes.build.js @@ -6,48 +6,48 @@ https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document */ -function aa(a){var b=0;return function(){return bc&&(c=Math.max(c+d,0));c"}}).childNodes.length}(document),Y(a,Range.prototype,"createContextualFragment",J.TrustedHTML,0),Y(a,$a,"insertAdjacentHTML",J.TrustedHTML,1),M(Document.prototype,"write")?(Y(a,Document.prototype,"write",J.TrustedHTML,0),Y(a,Document.prototype, +function tb(){var a=new T;a.a.b.includes("*")?Oa():Na(a.a.b,a.a.f);if(a.a.a||a.a.c)"ShadowRoot"in window&&ub(a,ShadowRoot.prototype,"innerHTML",J.TrustedHTML),Xa=function(b){return 0==b.createRange().createContextualFragment({toString:function(){return"
"}}).childNodes.length}(document),Y(a,Range.prototype,"createContextualFragment",J.TrustedHTML,0),Y(a,$a,"insertAdjacentHTML",J.TrustedHTML,1),L(Document.prototype,"write")?(Y(a,Document.prototype,"write",J.TrustedHTML,0),Y(a,Document.prototype, "open",J.TrustedURL,0)):(Y(a,HTMLDocument.prototype,"write",J.TrustedHTML,0),Y(a,HTMLDocument.prototype,"open",J.TrustedURL,0)),Y(a,Za,"open",J.TrustedURL,0),"DOMParser"in window&&Y(a,DOMParser.prototype,"parseFromString",J.TrustedHTML,0),Y(a,window,"setInterval",J.TrustedScript,0),Y(a,window,"setTimeout",J.TrustedScript,0),vb(a),wb(a),xb(a)} function wb(a){["appendChild","insertBefore","replaceChild"].forEach(function(b){Z(a,Node.prototype,b,function(c,e){for(var d=[],f=1;f} allowedPolicyNames Whitelisted policy names.\n * @param {boolean} allowDuplicates Should duplicate names be allowed.\n * @param {?string} cspString String with the CSP policy.\n */\n constructor(isLoggingEnabled,\n isEnforcementEnabled,\n allowedPolicyNames,\n allowDuplicates,\n cspString = null) {\n /**\n * True if logging is enabled.\n * @type {boolean}\n */\n this.isLoggingEnabled = isLoggingEnabled;\n\n /**\n * True if enforcement is enabled.\n * @type {boolean}\n */\n this.isEnforcementEnabled = isEnforcementEnabled;\n\n /**\n * Allowed policy names.\n * @type {Array}\n */\n this.allowedPolicyNames = allowedPolicyNames;\n\n /**\n * Should duplicate names be accepted.\n * @type {boolean}\n */\n this.allowDuplicates = allowDuplicates;\n\n /**\n * CSP string that defined the policy.\n * @type {?string}\n */\n this.cspString = cspString;\n }\n\n /**\n * Parses a CSP policy.\n * @link https://www.w3.org/TR/CSP3/#parse-serialized-policy\n * @param {string} cspString String with a CSP definition.\n * @return {Object>} Parsed CSP, keyed by directive\n * names.\n */\n static parseCSP(cspString) {\n const SEMICOLON = /\\s*;\\s*/;\n const WHITESPACE = /\\s+/;\n return cspString.trim().split(SEMICOLON)\n .map((serializedDirective) => serializedDirective.split(WHITESPACE))\n .reduce(function(parsed, directive) {\n if (directive[0]) {\n parsed[directive[0]] = directive.slice(1).map((s) => s).sort();\n }\n return parsed;\n }, {});\n }\n\n /**\n * Creates a TrustedTypeConfig object from a CSP string.\n * @param {string} cspString\n * @return {!TrustedTypeConfig}\n */\n static fromCSP(cspString) {\n const isLoggingEnabled = true;\n const policy = TrustedTypeConfig.parseCSP(cspString);\n const enforce = ENFORCEMENT_DIRECTIVE_NAME in policy &&\n policy[ENFORCEMENT_DIRECTIVE_NAME].includes('\\'script\\'');\n let policies = ['*'];\n let allowDuplicates = true;\n if (POLICIES_DIRECTIVE_NAME in policy) {\n policies = policy[POLICIES_DIRECTIVE_NAME].filter(\n (p) => p.charAt(0) !== '\\'');\n allowDuplicates = policy[POLICIES_DIRECTIVE_NAME].includes(\n '\\'allow-duplicates\\'');\n }\n return new TrustedTypeConfig(\n isLoggingEnabled,\n enforce, /* isEnforcementEnabled */\n policies, /* allowedPolicyNames */\n allowDuplicates, /* allowDuplicates */\n cspString\n );\n }\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n/**\n * @fileoverview Entry point for a polyfill that enforces the types.\n */\nimport {TrustedTypesEnforcer} from '../enforcer.js';\nimport {TrustedTypeConfig} from '../data/trustedtypeconfig.js';\n// import and setup trusted types\nimport './api_only.js';\n\n/* eslint-enable no-unused-vars */\n\n/**\n * Tries to guess a CSP policy from:\n * - the current polyfill script element text content (if prefixed with\n * \"Content-Security-Policy:\")\n * - the data-csp attribute value of the current script element.\n * - meta header\n * @return {?string} Guessed CSP value, or null.\n */\nfunction detectPolicy() {\n try {\n const currentScript = document.currentScript || (function() {\n const scripts = document.getElementsByTagName('script');\n return scripts[scripts.length - 1];\n })();\n\n const bodyPrefix = 'Content-Security-Policy:';\n if (currentScript &&\n currentScript.textContent.trim().substr(0, bodyPrefix.length) ==\n bodyPrefix) {\n return currentScript.textContent.trim().slice(bodyPrefix.length);\n }\n if (currentScript.dataset['csp']) {\n return currentScript.dataset['csp'];\n }\n const cspInMeta = document.head.querySelector(\n 'meta[http-equiv^=\"Content-Security-Policy\"]');\n if (cspInMeta) {\n return cspInMeta['content'].trim();\n }\n } catch (e) {\n return null;\n }\n return null;\n}\n\n/**\n * Bootstraps all trusted types polyfill and their enforcement.\n */\nexport function bootstrap() {\n const csp = detectPolicy();\n const config = csp ? TrustedTypeConfig.fromCSP(csp) : new TrustedTypeConfig(\n /* isLoggingEnabled */ false,\n /* isEnforcementEnabled */ false,\n /* allowedPolicyNames */ [],\n /* allowDuplicates */ true);\n\n const trustedTypesEnforcer = new TrustedTypesEnforcer(config);\n\n trustedTypesEnforcer.install();\n}\n\n/**\n * Determines if the enforcement should be enabled.\n * @return {boolean}\n */\nfunction shouldBootstrap() {\n for (const rootProperty of ['trustedTypes', 'TrustedTypes']) {\n if (window[rootProperty] && !window[rootProperty]['_isPolyfill_']) {\n // Native implementation exists\n return false;\n }\n }\n return true;\n}\n\n// Bootstrap only if native implementation is missing.\nif (shouldBootstrap()) {\n bootstrap();\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n// TODO check attributes in safari, remove legacy safe handlers\nconst unsafeAttributeEventHandlers = [\n 'onabort',\n 'onactivate',\n 'onactivateinvisible',\n 'onafterprint',\n 'onafterupdate',\n 'onanimationcancel',\n 'onanimationend',\n 'onanimationiteration',\n 'onanimationstart',\n 'onariarequest',\n 'onauxclick',\n 'onbeforeactivate',\n 'onbeforecopy',\n 'onbeforecut',\n 'onbeforedeactivate',\n 'onbeforeeditfocus',\n 'onbeforepaste',\n 'onbeforeprint',\n 'onbeforeunload',\n 'onbegin',\n 'onblur',\n 'onbounce',\n 'oncancel',\n 'oncanplay',\n 'oncanplaythrough',\n 'oncellchange',\n 'onchange',\n 'onclick',\n 'onclose',\n 'oncommand',\n 'oncontextmenu',\n 'oncontrolselect',\n 'oncopy',\n 'oncuechange',\n 'oncut',\n 'ondataavailable',\n 'ondatasetchanged',\n 'ondatasetcomplete',\n 'ondblclick',\n 'ondeactivate',\n 'ondrag',\n 'ondragdrop',\n 'ondragend',\n 'ondragenter',\n 'ondragexit',\n 'ondragleave',\n 'ondragover',\n 'ondragstart',\n 'ondrop',\n 'ondurationchange',\n 'onemptied',\n 'onend',\n 'onended',\n 'onerror',\n 'onerrorupdate',\n 'onexit',\n 'onfilterchange',\n 'onfinish',\n 'onfocus',\n 'onfocusin',\n 'onfocusout',\n 'onformdata',\n 'onfullscreenchange',\n 'onfullscreenerror',\n 'ongotpointercapture',\n 'onhelp',\n 'oninput',\n 'oninvalid',\n 'onkeydown',\n 'onkeypress',\n 'onkeyup',\n 'onlayoutcomplete',\n 'onload',\n 'onloadeddata',\n 'onloadedmetadata',\n 'onloadend',\n 'onloadstart',\n 'onlosecapture',\n 'onlostpointercapture',\n 'onmediacomplete',\n 'onmediaerror',\n 'onmessage',\n 'onmousedown',\n 'onmouseenter',\n 'onmouseleave',\n 'onmousemove',\n 'onmouseout',\n 'onmouseover',\n 'onmouseup',\n 'onmousewheel',\n 'onmove',\n 'onmoveend',\n 'onmovestart',\n 'onmozfullscreenchange',\n 'onmozfullscreenerror',\n 'onmscontentzoom',\n 'onmsgesturechange',\n 'onmsgesturedoubletap',\n 'onmsgestureend',\n 'onmsgesturehold',\n 'onmsgesturestart',\n 'onmsgesturetap',\n 'onmsgotpointercapture',\n 'onmsinertiastart',\n 'onmslostpointercapture',\n 'onmsmanipulationstatechanged',\n 'onmspointercancel',\n 'onmspointerdown',\n 'onmspointerenter',\n 'onmspointerleave',\n 'onmspointermove',\n 'onmspointerout',\n 'onmspointerover',\n 'onmspointerup',\n 'onoffline',\n 'ononline',\n 'onoutofsync',\n 'onoverscroll',\n 'onpaste',\n 'onpause',\n 'onplay',\n 'onplaying',\n 'onpointercancel',\n 'onpointerdown',\n 'onpointerenter',\n 'onpointerleave',\n 'onpointermove',\n 'onpointerout',\n 'onpointerover',\n 'onpointerrawupdate',\n 'onpointerup',\n 'onprogress',\n 'onpropertychange',\n 'onratechange',\n 'onreadystatechange',\n 'onrepeat',\n 'onreset',\n 'onresize',\n 'onresizeend',\n 'onresizestart',\n 'onresume',\n 'onreverse',\n 'onrowdelete',\n 'onrowenter',\n 'onrowexit',\n 'onrowinserted',\n 'onscroll',\n 'onscrollend',\n 'onsearch',\n 'onseek',\n 'onseeked',\n 'onseeking',\n 'onselect',\n 'onselectionchange',\n 'onselectstart',\n 'onshow',\n 'onstalled',\n 'onstart',\n 'onstop',\n 'onstorage',\n 'onsubmit',\n 'onsuspend',\n 'onsynchrestored',\n 'ontimeerror',\n 'ontimeupdate',\n 'ontoggle',\n 'ontrackchange',\n 'ontransitioncancel',\n 'ontransitionend',\n 'ontransitionrun',\n 'ontransitionstart',\n 'onunload',\n 'onurlflip',\n 'onvolumechange',\n 'onwaiting',\n 'onwebkitanimationend',\n 'onwebkitanimationiteration',\n 'onwebkitanimationstart',\n 'onwebkitfullscreenchange',\n 'onwebkitfullscreenerror',\n 'onwebkittransitionend',\n 'onwheel',\n];\n\n/**\n * Returns an array of all event handlers. Some of the event handlers may be\n * supported only in some browsers.\n *\n * For every event type that the browser supports, SVG supports that as an event\n * attribute, following the same requirements as for HTML event attributes.\n * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/Events\n *\n * @return {!Array}\n */\nexport function getUnsafeAttributeEventHandlers() {\n if (typeof window !== 'undefined') {\n const eventHandlers = [];\n for (const name in HTMLElement.prototype) {\n if (name.slice(0, 2) === 'on') {\n eventHandlers.push(name);\n }\n }\n return eventHandlers;\n } else {\n return unsafeAttributeEventHandlers;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\nimport {getUnsafeAttributeEventHandlers} from './utils/eventHandlers.js';\n\nconst isBrowser = typeof window !== 'undefined';\n\nconst rejectInputFn = (s) => {\n throw new TypeError('undefined conversion');\n};\n\nconst rejectInputDefaultPolicyFn = (s) => null;\n\nconst {toLowerCase, toUpperCase} = String.prototype;\n\nexport const HTML_NS = 'http://www.w3.org/1999/xhtml';\nexport const XLINK_NS = 'http://www.w3.org/1999/xlink';\nexport const SVG_NS = 'http://www.w3.org/2000/svg';\n\n/**\n * @constructor\n * @property {!function(string):TrustedHTML} createHTML\n * @property {!function(string):TrustedURL} createURL\n * @property {!function(string):TrustedScriptURL} createScriptURL\n * @property {!function(string):TrustedScript} createScript\n * @property {!string} name\n */\nexport const TrustedTypePolicy = function() {\n throw new TypeError('Illegal constructor');\n};\n\n/**\n * @constructor\n */\nexport const TrustedTypePolicyFactory = function() {\n throw new TypeError('Illegal constructor');\n};\n\n/* eslint-disable no-unused-vars */\n/**\n * @typedef {TrustedTypesInnerPolicy}\n * @property {function(string):string} createHTML\n * @property {function(string):string} createURL\n * @property {function(string):string} createScriptURL\n * @property {function(string):string} createScript\n */\nconst TrustedTypesInnerPolicy = {};\n\n/**\n * @typedef {!Object,\n * properties: !Object}>}\n */\nconst TrustedTypesTypeMap = {};\n/* eslint-enable no-unused-vars */\n\nexport const DEFAULT_POLICY_NAME = 'default';\n\n\nexport const trustedTypesBuilderTestOnly = function() {\n // Capture common names early.\n const {\n assign, create, defineProperty, freeze, getOwnPropertyNames,\n getPrototypeOf, prototype: ObjectPrototype,\n } = Object;\n\n const {hasOwnProperty} = ObjectPrototype;\n\n const {\n forEach, push,\n } = Array.prototype;\n\n const creatorSymbol = Symbol();\n\n /**\n * Getter for the privateMap.\n * @param {Object} obj Key of the privateMap\n * @return {Object} Private storage.\n */\n const privates = function(obj) {\n let v = privateMap.get(obj);\n if (v === undefined) {\n v = create(null); // initialize the private storage.\n privateMap.set(obj, v);\n }\n return v;\n };\n\n /**\n * Called before attacker-controlled code on an internal collections,\n * copies prototype members onto the instance directly, so that later\n * changes to prototypes cannot expose collection internals.\n * @param {!T} collection\n * @return {!T} collection\n * @template T\n */\n function selfContained(collection) {\n const proto = getPrototypeOf(collection);\n if (proto == null || getPrototypeOf(proto) !== ObjectPrototype) {\n throw new Error(); // Loop below is insufficient.\n }\n for (const key of getOwnPropertyNames(proto)) {\n defineProperty(collection, key, {value: collection[key]});\n }\n return collection;\n }\n\n /**\n * Map for private properties of Trusted Types object.\n * This is so that the access to the type constructor does not give\n * the ability to create typed values.\n * @type {WeakMap}\n */\n const privateMap = selfContained(new WeakMap());\n\n /**\n * List of all configured policy names.\n * @type {Array}\n */\n const policyNames = selfContained([]);\n\n /**\n * Allowed policy names.\n * Applied only if enforceNameRestrictions is true.\n * @type {Array}\n */\n const allowedNames = selfContained([]);\n\n /**\n * Should duplicate prolicy names be allowed.\n * Applied only if enforceNameRestrictions is true.\n * @type {boolean}\n */\n let allowDuplicateNames = true;\n\n /**\n * A reference to a default policy, if created.\n * @type {TrustedTypePolicy}\n */\n let defaultPolicy = null;\n\n /**\n * Whether to enforce allowedNames in createPolicy().\n * @type {boolean}\n */\n let enforceNameRestrictions = false;\n\n\n /**\n * A value that is trusted to have certain security-relevant properties\n * because the sources of such values are controlled.\n */\n class TrustedType {\n /**\n * Constructor for TrustedType. Only allowed to be called from within a\n * policy.\n * @param {symbol} s creatorSymbol\n * @param {string} policyName The name of the policy this object was\n * created by.\n */\n constructor(s, policyName) {\n // TODO: Figure out if symbol is needed, if the value is in privateMap.\n if (s !== creatorSymbol) {\n throw new Error('cannot call the constructor');\n }\n defineProperty(this, 'policyName',\n {value: '' + policyName, enumerable: true});\n }\n\n /**\n * Returns the wrapped string value of the object.\n * @return {string}\n * @override\n */\n toString() {\n return privates(this)['v'];\n }\n\n /**\n * Returns the wrapped string value of the object.\n * @return {string}\n * @override\n */\n valueOf() {\n return privates(this)['v'];\n }\n }\n\n /**\n * @param {function(new:TrustedType, symbol, string)} SubClass\n * @param {string} canonName The class name which should be independent of\n * any renaming pass and which is relied upon by the enforcer and for\n * native type interop.\n */\n function lockdownTrustedType(SubClass, canonName) {\n freeze(SubClass.prototype);\n delete SubClass.name;\n defineProperty(SubClass, 'name', {value: canonName});\n }\n\n /**\n * Trusted URL object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedURL extends TrustedType {\n }\n lockdownTrustedType(TrustedURL, 'TrustedURL');\n\n /**\n * Trusted Script URL object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedScriptURL extends TrustedType {\n }\n lockdownTrustedType(TrustedScriptURL, 'TrustedScriptURL');\n\n /**\n * Trusted HTML object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedHTML extends TrustedType {\n }\n lockdownTrustedType(TrustedHTML, 'TrustedHTML');\n\n /**\n * Trusted Script object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedScript extends TrustedType {\n }\n lockdownTrustedType(TrustedScript, 'TrustedScript');\n\n lockdownTrustedType(TrustedType, 'TrustedType');\n\n // Common constants.\n const emptyHTML = freeze(create(new TrustedHTML(creatorSymbol, '')));\n privates(emptyHTML)['v'] = '';\n const emptyScript = freeze(create(new TrustedScript(creatorSymbol, '')));\n privates(emptyScript)['v'] = '';\n\n /**\n * A map of attribute / property names to allowed types\n * for known namespaces.\n * @type {!Object}\n * @export\n */\n const TYPE_MAP = {\n [HTML_NS]: {\n // TODO(koto): Figure out what to to with \n 'A': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'AREA': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'BASE': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'BUTTON': {\n 'attributes': {\n 'formaction': TrustedURL.name,\n },\n },\n 'EMBED': {\n 'attributes': {\n 'src': TrustedScriptURL.name,\n },\n },\n 'FORM': {\n 'attributes': {\n 'action': TrustedURL.name,\n },\n },\n 'FRAME': {\n 'attributes': {\n 'src': TrustedURL.name,\n },\n },\n 'IFRAME': {\n 'attributes': {\n 'src': TrustedURL.name,\n 'srcdoc': TrustedHTML.name,\n },\n },\n 'INPUT': {\n 'attributes': {\n 'formaction': TrustedURL.name,\n },\n },\n 'OBJECT': {\n 'attributes': {\n 'data': TrustedScriptURL.name,\n 'codebase': TrustedScriptURL.name,\n },\n },\n // TODO(koto): Figure out what to do with portals.\n 'SCRIPT': {\n 'attributes': {\n 'src': TrustedScriptURL.name,\n 'text': TrustedScript.name,\n },\n 'properties': {\n 'innerText': TrustedScript.name,\n 'textContent': TrustedScript.name,\n 'text': TrustedScript.name,\n },\n },\n '*': {\n 'attributes': {},\n 'properties': {\n 'innerHTML': TrustedHTML.name,\n 'outerHTML': TrustedHTML.name,\n },\n },\n },\n [XLINK_NS]: {\n '*': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n 'properties': {},\n },\n },\n [SVG_NS]: {\n '*': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n 'properties': {},\n },\n },\n };\n\n /**\n * A map of element property to HTML attribute names.\n * @type {!Object}\n */\n const ATTR_PROPERTY_MAP = {\n 'codebase': 'codeBase',\n 'formaction': 'formAction',\n };\n\n // Edge doesn't support srcdoc.\n if (isBrowser && !('srcdoc' in HTMLIFrameElement.prototype)) {\n delete TYPE_MAP[HTML_NS]['IFRAME']['attributes']['srcdoc'];\n }\n\n // in HTML, clone attributes into properties.\n for (const tag of Object.keys(TYPE_MAP[HTML_NS])) {\n if (!TYPE_MAP[HTML_NS][tag]['properties']) {\n TYPE_MAP[HTML_NS][tag]['properties'] = {};\n }\n for (const attr of Object.keys(TYPE_MAP[HTML_NS][tag]['attributes'])) {\n TYPE_MAP[HTML_NS][tag]['properties'][\n ATTR_PROPERTY_MAP[attr] ? ATTR_PROPERTY_MAP[attr] : attr\n ] = TYPE_MAP[HTML_NS][tag]['attributes'][attr];\n }\n }\n\n // Add inline event handlers attribute names.\n for (const name of getUnsafeAttributeEventHandlers()) {\n TYPE_MAP[HTML_NS]['*']['attributes'][name] = 'TrustedScript';\n TYPE_MAP[SVG_NS]['*']['attributes'][name] = 'TrustedScript';\n }\n\n /**\n * @type {!Object}\n */\n const createTypeMapping = {\n 'createHTML': TrustedHTML,\n 'createScriptURL': TrustedScriptURL,\n 'createURL': TrustedURL,\n 'createScript': TrustedScript,\n };\n\n const createFunctionAllowed = createTypeMapping.hasOwnProperty;\n\n /**\n * Function generating a type checker.\n * @template T\n * @param {T} type The type to check against.\n * @return {function(*):boolean}\n */\n function isTrustedTypeChecker(type) {\n return (obj) => (obj instanceof type) && privateMap.has(obj);\n }\n\n /**\n * Wraps a user-defined policy rules with TT constructor\n * @param {string} policyName The policy name\n * @param {TrustedTypesInnerPolicy} innerPolicy InnerPolicy\n * @return {!TrustedTypePolicy} Frozen policy object\n */\n function wrapPolicy(policyName, innerPolicy) {\n /**\n * @template T\n * @param {function(new:T, symbol, string)} Ctor a trusted type constructor\n * @param {string} methodName the policy factory method name\n * @return {function(string):!T} a factory that produces instances of Ctor.\n */\n function creator(Ctor, methodName) {\n // This causes thisValue to be null when called below.\n const method = innerPolicy[methodName] || (\n policyName == DEFAULT_POLICY_NAME ?\n rejectInputDefaultPolicyFn : rejectInputFn\n );\n const policySpecificType = freeze(new Ctor(creatorSymbol, policyName));\n const factory = {\n [methodName](s, ...args) {\n // Trick to get methodName to show in stacktrace.\n let result = method('' + s, ...args);\n if (result === undefined || result === null) {\n if (policyName == DEFAULT_POLICY_NAME) {\n // These values mean that the input was rejected. This will cause\n // a violation later, don't create types for them.\n return result;\n }\n result = '';\n }\n const allowedValue = '' + result;\n const o = freeze(create(policySpecificType));\n privates(o)['v'] = allowedValue;\n return o;\n },\n }[methodName];\n return freeze(factory);\n }\n\n const policy = create(TrustedTypePolicy.prototype);\n\n for (const name of getOwnPropertyNames(createTypeMapping)) {\n policy[name] = creator(createTypeMapping[name], name);\n }\n defineProperty(policy, 'name', {\n value: policyName,\n writable: false,\n configurable: false,\n enumerable: true,\n });\n\n return /** @type {!TrustedTypePolicy} */ (freeze(policy));\n }\n\n /**\n * Returns the name of the trusted type required for a given element\n * attribute.\n * @param {string} tagName The name of the tag of the element.\n * @param {string} attribute The name of the attribute.\n * @param {string=} elementNs Element namespace.\n * @param {string=} attributeNs The attribute namespace.\n * @return {string?} Required type name or null, if a Trusted\n * Type is not required.\n */\n function getAttributeType(tagName, attribute, elementNs = '',\n attributeNs = '') {\n const canonicalAttr = toLowerCase.apply(String(attribute));\n return getTypeInternal_(tagName, 'attributes', canonicalAttr,\n elementNs, attributeNs) || null;\n }\n\n /**\n * Returns a type name from a type map.\n * @param {string} tag A tag name.\n * @param {string} container 'attributes' or 'properties'\n * @param {string} name The attribute / property name.\n * @param {string=} elNs Element namespace.\n * @param {string=} attrNs Attribute namespace.\n * @return {string|undefined}\n * @private\n */\n function getTypeInternal_(tag, container, name, elNs = '', attrNs = '') {\n const canonicalTag = toUpperCase.apply(String(tag));\n\n let ns = attrNs ? attrNs : elNs;\n if (!ns) {\n ns = HTML_NS;\n }\n const map = hasOwnProperty.apply(TYPE_MAP, [ns]) ? TYPE_MAP[ns] : null;\n if (!map) {\n return;\n }\n if (hasOwnProperty.apply(map, [canonicalTag]) &&\n map[canonicalTag] &&\n hasOwnProperty.apply(map[canonicalTag][container], [name]) &&\n map[canonicalTag][container][name]) {\n return map[canonicalTag][container][name];\n }\n\n if (hasOwnProperty.apply(map, ['*']) &&\n hasOwnProperty.apply(map['*'][container], [name]) &&\n map['*'][container][name]) {\n return map['*'][container][name];\n }\n }\n\n /**\n * Returns the name of the trusted type required for a given element property.\n * @param {string} tagName The name of the tag of the element.\n * @param {string} property The property.\n * @param {string=} elementNs Element namespace.\n * @return {string?} Required type name or null, if a Trusted\n * Type is not required.\n */\n function getPropertyType(tagName, property, elementNs = '') {\n // TODO: Support namespaces.\n return getTypeInternal_(\n tagName, 'properties', String(property), elementNs) || null;\n }\n\n /**\n * Returns the type map-like object, that resolves a name of a type for a\n * given tag + attribute / property in a given namespace.\n * The keys of the map are uppercase tag names. Map entry has mappings between\n * a lowercase attribute name / case-sensitive property name and a name of the\n * type that is required for that attribute / property.\n * Example entry for 'IMG': {\"attributes\": {\"src\": \"TrustedHTML\"}}\n * @param {string=} namespaceUri The namespace URI (will use the current\n * document namespace URI if omitted).\n * @return {TrustedTypesTypeMap}\n */\n function getTypeMapping(namespaceUri = '') {\n if (!namespaceUri) {\n try {\n namespaceUri = document.documentElement.namespaceURI;\n } catch (e) {\n namespaceUri = HTML_NS;\n }\n }\n /**\n * @template T\n * @private\n * @param {T} o\n * @return {T}\n */\n function deepClone(o) {\n return JSON.parse(JSON.stringify(o));\n }\n const map = TYPE_MAP[namespaceUri];\n if (!map) {\n return {};\n }\n return deepClone(map);\n }\n\n /**\n * Returns all configured policy names (even for non-exposed policies).\n * @return {!Array}\n */\n function getPolicyNames() {\n // TODO(msamuel): Should we sort policyNames to avoid leaking or\n // encouraging dependency on the order in which policy names are\n // registered? I think JavaScript builtin sorts are efficient for\n // almost-sorted lists so the amortized cost is close to O(n).\n return policyNames.slice();\n }\n\n /**\n * Creates a TT policy.\n *\n * Returns a frozen object representing a policy - a collection of functions\n * that may create TT objects based on the user-provided rules specified\n * in the policy object.\n *\n * @param {string} name A unique name of the policy.\n * @param {TrustedTypesInnerPolicy} policy Policy rules object.\n * @return {TrustedTypePolicy} The policy that may create TT objects\n * according to the policy rules.\n */\n function createPolicy(name, policy) {\n const pName = '' + name; // Assert it's a string\n\n if (!pName.match(/^[-#a-zA-Z0-9=_/@.%]+$/g)) {\n throw new TypeError('Policy ' + pName + ' contains invalid characters.');\n }\n\n if (enforceNameRestrictions && allowedNames.indexOf(pName) === -1) {\n throw new TypeError('Policy ' + pName + ' disallowed.');\n }\n\n if (pName === DEFAULT_POLICY_NAME && defaultPolicy) {\n throw new TypeError('Policy ' + pName + ' already exists.');\n }\n if (enforceNameRestrictions && !allowDuplicateNames &&\n policyNames.indexOf(pName) !== -1) {\n throw new TypeError('Policy ' + pName + ' exists.');\n }\n // Register the name early so that if policy getters unwisely calls\n // across protection domains to code that reenters this function,\n // policy author still has rights to the name.\n policyNames.push(pName);\n\n // Only copy own properties of names present in createTypeMapping.\n const innerPolicy = create(null);\n if (policy && typeof policy === 'object') {\n // Treat non-objects as empty policies.\n for (const key of getOwnPropertyNames(policy)) {\n if (createFunctionAllowed.call(createTypeMapping, key)) {\n innerPolicy[key] = policy[key];\n }\n }\n } else {\n // eslint-disable-next-line no-console\n console.warn('trustedTypes.createPolicy ' + pName +\n ' was given an empty policy');\n }\n freeze(innerPolicy);\n\n const wrappedPolicy = wrapPolicy(pName, innerPolicy);\n\n if (pName === DEFAULT_POLICY_NAME) {\n defaultPolicy = wrappedPolicy;\n }\n\n return wrappedPolicy;\n }\n\n /**\n * Applies the policy name restrictions.\n * @param {!Array} allowedPolicyNames\n * @param {boolean} allowDuplicates\n */\n function setPolicyNameRestrictions(allowedPolicyNames, allowDuplicates) {\n enforceNameRestrictions = true;\n allowedNames.length = 0;\n forEach.call(allowedPolicyNames, (el) => {\n push.call(allowedNames, '' + el);\n });\n allowDuplicateNames = allowDuplicates;\n policyNames.length = 0; // Clear already used policy names list.\n }\n\n /**\n * Clears the policy name restrictions.\n */\n function clearPolicyNameRestrictions() {\n enforceNameRestrictions = false;\n }\n\n /**\n * Returns the default policy, or null if it was not created.\n * @return {TrustedTypePolicy}\n */\n function getDefaultPolicy() {\n return defaultPolicy;\n }\n\n /**\n * Resets the default policy.\n */\n function resetDefaultPolicy() {\n defaultPolicy = null;\n policyNames.splice(policyNames.indexOf(DEFAULT_POLICY_NAME), 1);\n }\n\n const api = create(TrustedTypePolicyFactory.prototype);\n assign(api, {\n // The main function to create policies.\n createPolicy,\n\n getPolicyNames,\n\n // Type checkers, also validating the object was initialized through a\n // policy.\n isHTML: isTrustedTypeChecker(TrustedHTML),\n isURL: isTrustedTypeChecker(TrustedURL),\n isScriptURL: isTrustedTypeChecker(TrustedScriptURL),\n isScript: isTrustedTypeChecker(TrustedScript),\n\n getAttributeType,\n getPropertyType,\n getTypeMapping,\n emptyHTML,\n emptyScript,\n defaultPolicy, // Just to make the compiler happy, this is overridden below.\n\n TrustedHTML: TrustedHTML,\n TrustedURL: TrustedURL,\n TrustedScriptURL: TrustedScriptURL,\n TrustedScript: TrustedScript,\n });\n\n defineProperty(api, 'defaultPolicy', {\n get: getDefaultPolicy,\n set: () => {},\n });\n\n return {\n trustedTypes: freeze(api),\n setPolicyNameRestrictions,\n clearPolicyNameRestrictions,\n getDefaultPolicy,\n resetDefaultPolicy,\n };\n};\n\n\nexport const {\n trustedTypes,\n setPolicyNameRestrictions,\n clearPolicyNameRestrictions,\n getDefaultPolicy,\n resetDefaultPolicy,\n} = trustedTypesBuilderTestOnly();\n\n",null,"/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\nconst {\n defineProperty,\n} = Object;\n\n/**\n * Installs the setter of a given property.\n * @param {!Object} object An object for which to wrap the property.\n * @param {string} name The name of the property to wrap.\n * @param {function(*): *|undefined} setter A setter function}\n */\nexport function installSetter(object, name, setter) {\n const descriptor = {\n set: setter,\n };\n defineProperty(object, name, descriptor);\n}\n\n/**\n * Installs a setter and getter of a given property.\n * @param {!Object} object An object for which to wrap the property.\n * @param {string} name The name of the property to wrap.\n * @param {function(*): *|undefined} setter A setter function}\n * @param {function(*): *|undefined} getter A getter function}\n */\nexport function installSetterAndGetter(object, name, setter, getter) {\n const descriptor = {\n set: setter,\n get: getter,\n configurable: true, // This can get uninstalled, we need configurable: true\n };\n defineProperty(object, name, descriptor);\n}\n\n/**\n * Installs the setter of a given property.\n * @param {!Object} object An object for which to wrap the property.\n * @param {string} name The name of the property to wrap.\n * @param {function(*): *|undefined} fn A function}\n */\nexport function installFunction(object, name, fn) {\n defineProperty(object, name, {\n value: fn,\n });\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n// TrustedTypeConfig is used only as jsdoc type\n// eslint-disable-next-line\nimport {ENFORCEMENT_DIRECTIVE_NAME, TrustedTypeConfig}\n from './data/trustedtypeconfig.js';\nimport {\n trustedTypes as TrustedTypes,\n setPolicyNameRestrictions,\n clearPolicyNameRestrictions,\n resetDefaultPolicy,\n HTML_NS,\n} from\n './trustedtypes.js';\n\nimport {installFunction, installSetter, installSetterAndGetter}\n from './utils/wrapper.js';\n\nconst {apply} = Reflect;\nconst {\n getOwnPropertyNames,\n getOwnPropertyDescriptor,\n getPrototypeOf,\n} = Object;\n\nconst {\n hasOwnProperty,\n isPrototypeOf,\n} = Object.prototype;\n\nconst {slice} = String.prototype;\n\n// No URL in IE 11.\nconst UrlConstructor = typeof window.URL == 'function' ?\n URL.prototype.constructor :\n null;\n\nlet stringifyForRangeHack;\n\n/**\n * Return object constructor name\n * (their function.name is not available in IE 11).\n * @param {Function} fn\n * @return {string}\n * @private\n */\nconst getConstructorName_ = document.createElement('div').constructor.name ?\n (fn) => fn.name :\n (fn) => ('' + fn).match(/^\\[object (\\S+)\\]$/)[1];\n\n// window.open on IE 11 is set on WindowPrototype\nconst windowOpenObject = getOwnPropertyDescriptor(window, 'open') ?\n window :\n window.constructor.prototype;\n\n// In IE 11, insertAdjacent(HTML|Text) is on HTMLElement prototype\nconst insertAdjacentObject = apply(hasOwnProperty, Element.prototype,\n ['insertAdjacentHTML']) ? Element.prototype : HTMLElement.prototype;\n\n// This is not available in release Firefox :(\n// https://developer.mozilla.org/en-US/docs/Web/API/SecurityPolicyViolationEvent\n// https://bugzilla.mozilla.org/show_bug.cgi?id=1432523\nconst SecurityPolicyViolationEvent = window['SecurityPolicyViolationEvent'] ||\n null;\n\n/**\n * Parses URL, catching all the errors.\n * @param {string} url URL string to parse.\n * @return {URL|null}\n */\nfunction parseUrl_(url) {\n try {\n return new UrlConstructor(url, document.baseURI || undefined);\n } catch (e) {\n return null;\n }\n}\n\n// We don't actually need other namespaces.\n// setAttribute is hooked on Element.prototype, which all elements inherit from,\n// and all sensitive property wrappers are hooked directly on Element as well.\nconst typeMap = TrustedTypes.getTypeMapping(HTML_NS);\n\nconst STRING_TO_TYPE = {\n 'TrustedHTML': TrustedTypes.TrustedHTML,\n 'TrustedScript': TrustedTypes.TrustedScript,\n 'TrustedScriptURL': TrustedTypes.TrustedScriptURL,\n 'TrustedURL': TrustedTypes.TrustedURL,\n};\n\n/**\n * Converts an uppercase tag name to an element constructor function name.\n * Used for property setter hijacking only.\n * @param {string} tagName\n * @return {string}\n */\nfunction convertTagToConstructor(tagName) {\n if (tagName == '*') {\n return 'HTMLElement';\n }\n return getConstructorName_(document.createElement(tagName).constructor);\n}\n\nfor (const tagName of Object.keys(typeMap)) {\n const attrs = typeMap[tagName]['properties'];\n for (const [k, v] of Object.entries(attrs)) {\n attrs[k] = STRING_TO_TYPE[v];\n }\n}\n\n/**\n * Map of type names to type checking function.\n * @type {!Object}\n */\nconst TYPE_CHECKER_MAP = {\n 'TrustedHTML': TrustedTypes.isHTML,\n 'TrustedURL': TrustedTypes.isURL,\n 'TrustedScriptURL': TrustedTypes.isScriptURL,\n 'TrustedScript': TrustedTypes.isScript,\n};\n\n/**\n * Map of type names to type producing function.\n * @type {Object}\n */\nconst TYPE_PRODUCER_MAP = {\n 'TrustedHTML': 'createHTML',\n 'TrustedURL': 'createURL',\n 'TrustedScriptURL': 'createScriptURL',\n 'TrustedScript': 'createScript',\n};\n\n/* eslint-disable no-unused-vars */\n/**\n * @typedef {TrustedTypePolicy}\n * @property {function(string):TrustedHTML} createHTML\n * @property {function(string):TrustedURL} createURL\n * @property {function(string):TrustedScriptURL} createScriptURL\n * @property {function(string):TrustedScript} createScript\n */\nconst TrustedTypePolicy = {};\n/* eslint-enable no-unused-vars */\n\n\n/**\n * An object for enabling trusted type enforcement.\n */\nexport class TrustedTypesEnforcer {\n /**\n * @param {!TrustedTypeConfig} config The configuration for\n * trusted type enforcement.\n */\n constructor(config) {\n /**\n * A configuration for the trusted type enforcement.\n * @private {!TrustedTypeConfig}\n */\n this.config_ = config;\n /**\n * @private {Object}\n */\n this.originalSetters_ = {};\n }\n\n /**\n * Wraps HTML sinks with an enforcement setter, which will enforce\n * trusted types and do logging, if enabled.\n *\n */\n install() {\n if (this.config_.allowedPolicyNames.includes('*')) {\n clearPolicyNameRestrictions();\n } else {\n setPolicyNameRestrictions(this.config_.allowedPolicyNames,\n this.config_.allowDuplicates);\n }\n\n if (!this.config_.isEnforcementEnabled && !this.config_.isLoggingEnabled) {\n return;\n }\n\n if ('ShadowRoot' in window) {\n this.wrapSetter_(ShadowRoot.prototype, 'innerHTML',\n TrustedTypes.TrustedHTML);\n }\n stringifyForRangeHack = (function(doc) {\n const r = doc.createRange();\n // In IE 11 Range.createContextualFragment doesn't stringify its argument.\n const f = r.createContextualFragment(/** @type {string} */ (\n {toString: () => '
'}));\n return f.childNodes.length == 0;\n })(document);\n\n this.wrapWithEnforceFunction_(Range.prototype, 'createContextualFragment',\n TrustedTypes.TrustedHTML, 0);\n\n this.wrapWithEnforceFunction_(insertAdjacentObject,\n 'insertAdjacentHTML',\n TrustedTypes.TrustedHTML, 1);\n\n if (getOwnPropertyDescriptor(Document.prototype, 'write')) {\n // Chrome\n this.wrapWithEnforceFunction_(Document.prototype, 'write',\n TrustedTypes.TrustedHTML, 0);\n this.wrapWithEnforceFunction_(Document.prototype, 'open',\n TrustedTypes.TrustedURL, 0);\n } else {\n // Firefox\n this.wrapWithEnforceFunction_(HTMLDocument.prototype, 'write',\n TrustedTypes.TrustedHTML, 0);\n this.wrapWithEnforceFunction_(HTMLDocument.prototype, 'open',\n TrustedTypes.TrustedURL, 0);\n }\n\n this.wrapWithEnforceFunction_(windowOpenObject, 'open',\n TrustedTypes.TrustedURL, 0);\n\n if ('DOMParser' in window) {\n this.wrapWithEnforceFunction_(DOMParser.prototype, 'parseFromString',\n TrustedTypes.TrustedHTML, 0);\n }\n this.wrapWithEnforceFunction_(window, 'setInterval',\n TrustedTypes.TrustedScript, 0);\n this.wrapWithEnforceFunction_(window, 'setTimeout',\n TrustedTypes.TrustedScript, 0);\n this.wrapSetAttribute_();\n this.installScriptMutatorGuards_();\n this.installPropertySetWrappers_();\n }\n\n /**\n * Removes the original setters.\n */\n uninstall() {\n clearPolicyNameRestrictions();\n\n if (!this.config_.isEnforcementEnabled && !this.config_.isLoggingEnabled) {\n return;\n }\n\n if ('ShadowRoot' in window) {\n this.restoreSetter_(ShadowRoot.prototype, 'innerHTML');\n }\n this.restoreFunction_(Range.prototype, 'createContextualFragment');\n this.restoreFunction_(insertAdjacentObject, 'insertAdjacentHTML');\n this.restoreFunction_(Element.prototype, 'setAttribute');\n this.restoreFunction_(Element.prototype, 'setAttributeNS');\n\n if (getOwnPropertyDescriptor(Document.prototype, 'write')) {\n this.restoreFunction_(Document.prototype, 'write');\n this.restoreFunction_(Document.prototype, 'open');\n } else {\n this.restoreFunction_(HTMLDocument.prototype, 'write');\n this.restoreFunction_(HTMLDocument.prototype, 'open');\n }\n this.restoreFunction_(windowOpenObject, 'open');\n\n if ('DOMParser' in window) {\n this.restoreFunction_(DOMParser.prototype, 'parseFromString');\n }\n this.restoreFunction_(window, 'setTimeout');\n this.restoreFunction_(window, 'setInterval');\n this.uninstallPropertySetWrappers_();\n this.uninstallScriptMutatorGuards_();\n resetDefaultPolicy();\n }\n\n /**\n * Installs type-enforcing wrappers for APIs that allow to modify\n * script element texts.\n * @private\n */\n installScriptMutatorGuards_() {\n const that = this;\n\n ['appendChild', 'insertBefore', 'replaceChild'].forEach((fnName) => {\n this.wrapFunction_(\n Node.prototype,\n fnName,\n /**\n * @this {Node}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.enforceTypeInScriptNodes_\n .bind(that, this, /* checkParent */ false, originalFn)\n .apply(that, args);\n });\n });\n this.wrapFunction_(\n insertAdjacentObject,\n 'insertAdjacentText',\n /**\n * @this {Element}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.insertAdjacentTextWrapper_\n .bind(that, this, originalFn)\n .apply(that, args);\n });\n\n if ('after' in Element.prototype) {\n ['after', 'before', 'replaceWith'].forEach((fnName) => {\n this.wrapFunction_(\n Element.prototype,\n fnName,\n /**\n * @this {Element}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.enforceTypeInScriptNodes_\n .bind(that, this, /* checkParent */ true, originalFn)\n .apply(that, args);\n });\n });\n ['append', 'prepend'].forEach((fnName) => {\n this.wrapFunction_(\n Element.prototype,\n fnName,\n /**\n * @this {Element}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.enforceTypeInScriptNodes_\n .bind(that, this, /* checkParent */ false, originalFn)\n .apply(that, args);\n });\n });\n }\n }\n\n /**\n * Uninstalls type-enforcing wrappers for APIs that allow to modify\n * script element texts.\n * @private\n */\n uninstallScriptMutatorGuards_() {\n this.restoreFunction_(Node.prototype, 'appendChild');\n this.restoreFunction_(Node.prototype, 'insertBefore');\n this.restoreFunction_(Node.prototype, 'replaceChild');\n this.restoreFunction_(insertAdjacentObject, 'insertAdjacentText');\n if ('after' in Element.prototype) {\n ['after', 'before', 'replaceWith', 'append', 'prepend'].forEach(\n (fnName) => this.restoreFunction_(Element.prototype, fnName));\n }\n }\n\n /**\n * Installs wrappers for directly setting properties\n * based on the type map.\n * @private\n */\n installPropertySetWrappers_() {\n /* eslint-disable guard-for-in */\n for (const tag of getOwnPropertyNames(typeMap)) {\n for (const property of getOwnPropertyNames(typeMap[tag]['properties'])) {\n this.wrapSetter_(\n window[convertTagToConstructor(tag)].prototype,\n property,\n typeMap[tag]['properties'][property]);\n }\n }\n }\n\n /**\n * Uninstalls wrappers for directly setting properties\n * based on the type map.\n * @private\n */\n uninstallPropertySetWrappers_() {\n /* eslint-disable guard-for-in */\n for (const tag of getOwnPropertyNames(typeMap)) {\n for (const property of getOwnPropertyNames(typeMap[tag]['properties'])) {\n this.restoreSetter_(\n window[convertTagToConstructor(tag)].prototype,\n property);\n }\n }\n }\n\n /** Wraps set attribute with an enforcement function. */\n wrapSetAttribute_() {\n const that = this;\n this.wrapFunction_(\n Element.prototype,\n 'setAttribute',\n /**\n * @this {TrustedTypesEnforcer}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.setAttributeWrapper_\n .bind(that, this, originalFn)\n .apply(that, args);\n });\n this.wrapFunction_(\n Element.prototype,\n 'setAttributeNS',\n /**\n * @this {TrustedTypesEnforcer}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.setAttributeNSWrapper_\n .bind(that, this, originalFn)\n .apply(that, args);\n });\n }\n\n /**\n * Enforces type checking for Element.prototype.setAttribute.\n * @param {!Object} context The context for the call to the original function.\n * @param {!Function} originalFn The original setAttribute function.\n * @return {*}\n */\n setAttributeWrapper_(context, originalFn, ...args) {\n // Note(slekies): In a normal application constructor should never be null.\n // However, there are no guarantees. If the constructor is null, we cannot\n // determine whether a special type is required. In order to not break the\n // application, we will not do any further type checks and pass the call\n // to setAttribute.\n if (context.constructor !== null && context instanceof Element) {\n const attrName = (args[0] = String(args[0])).toLowerCase();\n const requiredType = TrustedTypes.getAttributeType(context.tagName,\n attrName, context.namespaceURI);\n if (requiredType && apply(hasOwnProperty, STRING_TO_TYPE,\n [requiredType])) {\n return this.enforce_(\n context, 'setAttribute', STRING_TO_TYPE[requiredType],\n originalFn, 1, args);\n }\n }\n return apply(originalFn, context, args);\n }\n\n /**\n * Enforces type checking for Element.prototype.setAttributeNS.\n * @param {!Object} context The context for the call to the original function.\n * @param {!Function} originalFn The original setAttributeNS function.\n * @return {*}\n */\n setAttributeNSWrapper_(context, originalFn, ...args) {\n // See the note from setAttributeWrapper_ above.\n if (context.constructor !== null && context instanceof Element) {\n const ns = args[0] ? String(args[0]) : null;\n args[0] = ns;\n const attrName = (args[1] = String(args[1])).toLowerCase();\n const requiredType = TrustedTypes.getAttributeType(context.tagName,\n attrName, context.namespaceURI, ns);\n if (requiredType && apply(hasOwnProperty, STRING_TO_TYPE,\n [requiredType])) {\n return this.enforce_(context, 'setAttributeNS',\n STRING_TO_TYPE[requiredType],\n originalFn, 2, args);\n }\n }\n return apply(originalFn, context, args);\n }\n\n /**\n * Wrapper for DOM mutator functions that enforces type checks if the context\n * (or, optionally, its parent node) is a script node.\n * For each argument, it will make sure that text nodes pass through a\n * default policy, or generate a violation. To skip that check, pass\n * TrustedScript objects instead.\n * @param {!Element|!Node} context The context for the call to the original\n * function.\n * @param {boolean} checkParent Check parent of context instead.\n * @param {!Function} originalFn The original mutator function.\n * @return {*}\n */\n enforceTypeInScriptNodes_(context, checkParent, originalFn, ...args) {\n const objToCheck = checkParent ? context.parentNode : context;\n if (objToCheck instanceof HTMLScriptElement && args.length > 0) {\n for (let argNumber = 0; argNumber < args.length; argNumber++) {\n let arg = args[argNumber];\n if (arg instanceof Node && arg.nodeType !== Node.TEXT_NODE) {\n continue; // Type is not interesting\n }\n if (arg instanceof Node && arg.nodeType == Node.TEXT_NODE) {\n arg = arg.textContent;\n } else if (TrustedTypes.isScript(arg)) {\n // TODO(koto): Consider removing this branch, as it's hard to spec.\n // Convert to text node and go on.\n args[argNumber] = document.createTextNode('' + arg);\n continue;\n }\n\n // Try to run a default policy on argsthe argument\n const fallbackValue = this.maybeCallDefaultPolicy_(\n 'TrustedScript', '' + arg, 'script.text');\n if (fallbackValue === null || fallbackValue === undefined) {\n this.processViolation_(context, originalFn.name,\n TrustedTypes.TrustedScript, arg);\n } else {\n arg = fallbackValue;\n }\n args[argNumber] = document.createTextNode('' + arg);\n }\n }\n return apply(originalFn, context, args);\n }\n\n /**\n * Wrapper for Element.insertAdjacentText that enforces type checks for\n * inserting text into a script node.\n * @param {!Object} context The context for the call to the original function.\n * @param {!Function} originalFn The original insertAdjacentText function.\n */\n insertAdjacentTextWrapper_(context, originalFn, ...args) {\n const riskyPositions = ['beforebegin', 'afterend'];\n if (context instanceof Element &&\n context.parentElement instanceof HTMLScriptElement &&\n args.length > 1 &&\n riskyPositions.includes(args[0]) &&\n !(TrustedTypes.isScript(args[1]))) {\n // Run a default policy on args[1]\n args[1] = '' + args[1];\n const fallbackValue = this.maybeCallDefaultPolicy_('TrustedScript',\n args[1], 'script.text');\n if (fallbackValue === null || fallbackValue === undefined) {\n this.processViolation_(context, 'insertAdjacentText',\n TrustedTypes.TrustedScript, args[1]);\n } else {\n args[1] = fallbackValue;\n }\n\n const textNode = document.createTextNode('' + args[1]);\n\n\n const insertBefore = /** @type function(this: Node) */(\n this.originalSetters_[this.getKey_(Node.prototype, 'insertBefore')]);\n\n switch (args[0]) {\n case riskyPositions[0]: // 'beforebegin'\n apply(insertBefore, context.parentElement,\n [textNode, context]);\n break;\n case riskyPositions[1]: // 'afterend'\n apply(insertBefore, context.parentElement,\n [textNode, context.nextSibling]);\n break;\n }\n return;\n }\n apply(originalFn, context, args);\n }\n\n /**\n * Wraps a setter with the enforcement wrapper.\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @param {!Function} type The type to enforce.\n * @param {number} argNumber Number of the argument to enforce the type of.\n * @private\n */\n wrapWithEnforceFunction_(object, name, type, argNumber) {\n const that = this;\n this.wrapFunction_(\n object,\n name,\n /**\n * @this {TrustedTypesEnforcer}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.enforce_.call(that, this, name, type, originalFn,\n argNumber, args);\n });\n }\n\n\n /**\n * Wraps an existing function with a given function body and stores the\n * original function.\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @param {function(!Function, ...*)} functionBody The wrapper function.\n */\n wrapFunction_(object, name, functionBody) {\n const descriptor = getOwnPropertyDescriptor(object, name);\n const originalFn = /** @type function(*):* */ (\n descriptor ? descriptor.value : null);\n\n if (!(originalFn instanceof Function)) {\n throw new TypeError(\n 'Property ' + name + ' on object' + object + ' is not a function');\n }\n\n const key = this.getKey_(object, name);\n if (this.originalSetters_[key]) {\n throw new Error(\n `TrustedTypesEnforcer: Double installation detected: ${key} ${name}`);\n }\n installFunction(\n object,\n name,\n /**\n * @this {TrustedTypesEnforcer}\n * @return {*}\n */\n function(...args) {\n return functionBody.bind(this, originalFn).apply(this, args);\n });\n this.originalSetters_[key] = originalFn;\n }\n\n /**\n * Wraps a setter with the enforcement wrapper.\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @param {!Function} type The type to enforce.\n * @param {!Object=} descriptorObject If present, will reuse the\n * setter/getter from this one, instead of object. Used for redefining\n * setters in subclasses.\n * @private\n */\n wrapSetter_(object, name, type, descriptorObject = undefined) {\n if (descriptorObject && !isPrototypeOf.call(descriptorObject, object)) {\n throw new Error('Invalid prototype chain');\n }\n\n let useObject = descriptorObject || object;\n let descriptor;\n let originalSetter;\n const stopAt = getPrototypeOf(Node.prototype);\n\n // Find the descriptor on the object or its prototypes, stopping at Node.\n do {\n descriptor = getOwnPropertyDescriptor(useObject, name);\n originalSetter = /** @type {function(*):*} */ (descriptor ?\n descriptor.set : null);\n if (!originalSetter) {\n useObject = getPrototypeOf(useObject) || stopAt;\n }\n } while (!(originalSetter || useObject === stopAt || !useObject));\n\n if (!(originalSetter instanceof Function)) {\n throw new TypeError(\n 'No setter for property ' + name + ' on object' + object);\n }\n\n const key = this.getKey_(object, name);\n if (this.originalSetters_[key]) {\n throw new Error(\n `TrustedTypesEnforcer: Double installation detected: ${key} ${name}`);\n }\n const that = this;\n /**\n * @this {TrustedTypesEnforcer}\n * @param {*} value\n */\n const enforcingSetter = function(value) {\n that.enforce_.call(that, this, name, type, originalSetter, 0,\n [value]);\n };\n\n if (useObject === object) {\n installSetter(\n object,\n name,\n enforcingSetter);\n } else {\n // Since we're creating a new setter in subclass, we also need to\n // overwrite the getter.\n installSetterAndGetter(\n object,\n name,\n enforcingSetter,\n descriptor.get\n );\n }\n this.originalSetters_[key] = originalSetter;\n }\n\n /**\n * Restores the original setter for the property, as encountered during\n * install().\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @param {!Object=} descriptorObject If present, will restore the original\n * setter/getter from this one, instead of object.\n * @private\n */\n restoreSetter_(object, name, descriptorObject = undefined) {\n const key = this.getKey_(object, name);\n if (descriptorObject && !isPrototypeOf.call(descriptorObject, object)) {\n throw new Error('Invalid prototype chain');\n }\n if (!this.originalSetters_[key]) {\n throw new Error(\n // eslint-disable-next-line max-len\n `TrustedTypesEnforcer: Cannot restore (double uninstallation?): ${key} ${name}`);\n }\n if (descriptorObject) {\n // We have to also overwrite a getter.\n installSetterAndGetter(object, name, this.originalSetters_[key],\n getOwnPropertyDescriptor(descriptorObject, name).get);\n } else {\n installSetter(object, name, this.originalSetters_[key]);\n }\n delete this.originalSetters_[key];\n }\n\n /**\n * Restores the original method of an object, as encountered during install().\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @private\n */\n restoreFunction_(object, name) {\n const key = this.getKey_(object, name);\n if (!this.originalSetters_[key]) {\n throw new Error(\n // eslint-disable-next-line max-len\n `TrustedTypesEnforcer: Cannot restore (double uninstallation?): ${key} ${name}`);\n }\n installFunction(object, name, this.originalSetters_[key]);\n delete this.originalSetters_[key];\n }\n\n /**\n * Returns the key name for caching original setters.\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @return {string} Key name.\n * @private\n */\n getKey_(object, name) {\n // TODO(msamuel): Can we use Object.prototype.toString.call(object)\n // to get an unspoofable string here?\n // TODO(msamuel): fail on '-' in object.constructor.name?\n // No Function.name in IE 11\n const ctrName = '' + (\n object.constructor.name ?\n object.constructor.name :\n object.constructor);\n return ctrName + '-' + name;\n }\n\n /**\n * Calls a default policy.\n * @param {string} typeName Type name to attempt to produce from a value.\n * @param {*} value The value to pass to a default policy\n * @param {string} sink The sink name that the default policy will be called\n * with.\n * @throws {Error} If the default policy throws, or not exist.\n * @return {Function?} The trusted value or null, if the input value shoudl\n * be rejected.\n */\n maybeCallDefaultPolicy_(typeName, value, sink = '') {\n // Apply a fallback policy, if it exists.\n const fallbackPolicy = TrustedTypes['defaultPolicy'];\n if (!fallbackPolicy) {\n return null;\n }\n if (!TYPE_CHECKER_MAP.hasOwnProperty(typeName)) {\n return null;\n }\n return fallbackPolicy[TYPE_PRODUCER_MAP[typeName]](value, '' + sink);\n }\n\n /**\n * Logs and enforces TrustedTypes depending on the given configuration.\n * @template T\n * @param {!Object} context The object that the setter is called for.\n * @param {string} propertyName The name of the property.\n * @param {!Function} typeToEnforce The type to enforce.\n * @param {function(?):T} originalSetter Original setter.\n * @param {number} argNumber Number of argument to enforce the type of.\n * @param {Array} args Arguments.\n * @return {T}\n * @private\n */\n enforce_(context, propertyName, typeToEnforce, originalSetter, argNumber,\n args) {\n const value = args[argNumber];\n const typeName = '' + typeToEnforce.name;\n // If typed value is given, pass through.\n if (TYPE_CHECKER_MAP.hasOwnProperty(typeName) &&\n TYPE_CHECKER_MAP[typeName](value)) {\n if (stringifyForRangeHack &&\n propertyName == 'createContextualFragment') {\n // IE 11 hack, somehow the value is not stringified implicitly.\n args[argNumber] = args[argNumber].toString();\n }\n return apply(originalSetter, context, args);\n }\n\n if (typeToEnforce === TrustedTypes.TrustedScript) {\n const isInlineEventHandler =\n propertyName == 'setAttribute' ||\n propertyName === 'setAttributeNS' ||\n apply(slice, propertyName, [0, 2]) === 'on';\n // If a function (instead of string) is passed to inline event attribute,\n // or set(Timeout|Interval), pass through.\n const propertyAcceptsFunctions =\n propertyName === 'setInterval' ||\n propertyName === 'setTimeout' ||\n isInlineEventHandler;\n if ((propertyAcceptsFunctions && typeof value === 'function') ||\n (isInlineEventHandler && value === null)) {\n return apply(originalSetter, context, args);\n }\n }\n\n // Apply a fallback policy, if it exists.\n args[argNumber] = '' + value;\n const objName = context instanceof Element ?\n context.localName :\n getConstructorName_(context ? context.constructor : window.constructor);\n const fallbackValue = this.maybeCallDefaultPolicy_(\n typeName, value, objName + '.' + propertyName);\n if (fallbackValue === null || fallbackValue === undefined) {\n // This will throw a TypeError if enforcement is enabled.\n this.processViolation_(context, propertyName, typeToEnforce, value);\n } else {\n // Use the value modified by the default policy.\n args[argNumber] = fallbackValue;\n }\n return apply(originalSetter, context, args);\n }\n\n /**\n * Report a TT violation.\n * @param {!Object} context The object that the setter is called for.\n * @param {string} propertyName The name of the property.\n * @param {!Function} typeToEnforce The type to enforce.\n * @param {string} value The value that was violated the restrictions.\n * @throws {TypeError} if the enforcement is enabled.\n */\n processViolation_(context, propertyName, typeToEnforce, value) {\n const contextName = getConstructorName_(context.constructor) ||\n '' + context;\n const message = `Failed to set ${propertyName} on ${contextName}: `\n + `This property requires ${typeToEnforce.name}.`;\n\n if (this.config_.isLoggingEnabled) {\n // eslint-disable-next-line no-console\n console.warn(message, propertyName, context, typeToEnforce, value);\n }\n\n // Unconditionally dispatch an event.\n if (typeof SecurityPolicyViolationEvent == 'function') {\n let blockedURI = '';\n if (typeToEnforce === TrustedTypes.TrustedURL ||\n typeToEnforce === TrustedTypes.TrustedScriptURL) {\n blockedURI = parseUrl_(value) || '';\n if (blockedURI) {\n blockedURI = blockedURI.href;\n }\n }\n const valueSlice = apply(slice, '' + value, [0, 40]);\n const event = new SecurityPolicyViolationEvent(\n 'securitypolicyviolation',\n {\n 'bubbles': true,\n 'blockedURI': blockedURI,\n 'disposition': this.config_.isEnforcementEnabled ?\n 'enforce' : 'report',\n 'documentURI': document.location.href,\n 'effectiveDirective': ENFORCEMENT_DIRECTIVE_NAME,\n 'originalPolicy': this.config_.cspString,\n 'statusCode': 0,\n 'violatedDirective': ENFORCEMENT_DIRECTIVE_NAME,\n 'sample': `${contextName}.${propertyName} ${valueSlice}`,\n });\n if (context instanceof Node && context.isConnected) {\n context.dispatchEvent(event);\n } else { // Fallback - dispatch an event on base document.\n document.dispatchEvent(event);\n }\n }\n\n if (this.config_.isEnforcementEnabled) {\n throw new TypeError(message);\n }\n }\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n/**\n * @fileoverview Entry point for a polyfill that only defines the types\n * (i.e. no enforcement logic).\n */\nimport {trustedTypes, TrustedTypePolicy, TrustedTypePolicyFactory} from\n '../trustedtypes.js';\n\nconst tt = trustedTypes;\n\n/**\n * Sets up the public Trusted Types API in the global object.\n */\nfunction setupPolyfill() {\n // We use array accessors to make sure Closure compiler will not alter the\n // names of the properties..\n\n // we setup the polyfill only in browser environment.\n if (typeof window === 'undefined') {\n return;\n }\n const rootProperty = 'trustedTypes';\n\n // Convert old window.TrustedTypes to window.trustedTypes.\n if (window['TrustedTypes'] && typeof window[rootProperty] === 'undefined') {\n window[rootProperty] = Object.freeze(window['TrustedTypes']);\n }\n\n if (typeof window[rootProperty] !== 'undefined') {\n return;\n }\n\n const publicApi = Object.create(TrustedTypePolicyFactory.prototype);\n Object.assign(publicApi, {\n 'isHTML': tt.isHTML,\n 'isURL': tt.isURL,\n 'isScriptURL': tt.isScriptURL,\n 'isScript': tt.isScript,\n 'createPolicy': tt.createPolicy,\n 'getPolicyNames': tt.getPolicyNames,\n 'getAttributeType': tt.getAttributeType,\n 'getPropertyType': tt.getPropertyType,\n 'getTypeMapping': tt.getTypeMapping,\n 'emptyHTML': tt.emptyHTML,\n 'emptyScript': tt.emptyScript,\n '_isPolyfill_': true,\n });\n Object.defineProperty(\n publicApi,\n 'defaultPolicy',\n Object.getOwnPropertyDescriptor(tt, 'defaultPolicy') || {});\n\n window[rootProperty] = Object.freeze(publicApi);\n\n window['TrustedHTML'] = tt.TrustedHTML;\n window['TrustedURL'] = tt.TrustedURL;\n window['TrustedScriptURL'] = tt.TrustedScriptURL;\n window['TrustedScript'] = tt.TrustedScript;\n window['TrustedTypePolicy'] = TrustedTypePolicy;\n window['TrustedTypePolicyFactory'] = TrustedTypePolicyFactory;\n}\n\nsetupPolyfill();\n\nexport default tt;\n"]} \ No newline at end of file +{"version":3,"sources":[" [synthetic:es6/util/arrayiterator] "," [synthetic:util/defineproperty] "," [synthetic:util/global] "," [synthetic:es6/symbol] "," [synthetic:es6/util/makeiterator] "," [synthetic:es6/util/arrayfromiterator] "," [synthetic:util/objectcreate] "," [synthetic:es6/util/setprototypeof] "," [synthetic:es6/util/inherits] "," [synthetic:util/polyfill] "," [synthetic:es6/object/is] "," [synthetic:es6/array/includes] "," [synthetic:util/owns] "," [synthetic:es6/weakmap] "," [synthetic:es6/object/entries] "," [synthetic:es6/util/assign] "," [synthetic:es6/object/assign] ","src/data/trustedtypeconfig.js","src/polyfill/full.js","src/utils/eventHandlers.js","src/trustedtypes.js"," [synthetic:es6/util/arrayfromiterable] ","src/utils/wrapper.js","src/enforcer.js","src/polyfill/api_only.js"],"names":["$jscomp.defineProperty","$jscomp.global","$jscomp.initSymbol","$jscomp.Symbol","$jscomp.SymbolClass","$jscomp.SYMBOL_PREFIX","$jscomp.arrayIteratorImpl","$jscomp.objectCreate","$jscomp.setPrototypeOf","$jscomp.polyfill","$jscomp.makeIterator","$jscomp.owns","$jscomp.assign","constructor","TrustedTypeConfig","isLoggingEnabled","isEnforcementEnabled","allowedPolicyNames","allowDuplicates","cspString","parseCSP","WHITESPACE","trim","split","SEMICOLON","map","serializedDirective","reduce","parsed","directive","slice","s","sort","fromCSP","csp","policy","TrustedTypeConfig$$module$src$data$trustedtypeconfig.parseCSP","enforce","ENFORCEMENT_DIRECTIVE_NAME","includes","policies","POLICIES_DIRECTIVE_NAME","filter","p","charAt","unsafeAttributeEventHandlers","getUnsafeAttributeEventHandlers","window","eventHandlers","name","HTMLElement","prototype","push","isBrowser","rejectInputFn","TypeError","rejectInputDefaultPolicyFn","String","toLowerCase","toUpperCase","TrustedTypePolicy","TrustedTypePolicyFactory","trustedTypesBuilderTestOnly","TrustedScript","TrustedHTML","TrustedScriptURL","TrustedURL","TrustedType","policyName","creatorSymbol","Error","defineProperty","value","enumerable","privates","obj","v","privateMap","get","undefined","create","set","selfContained","collection","proto","getPrototypeOf","ObjectPrototype","getOwnPropertyNames","key","lockdownTrustedType","SubClass","canonName","freeze","isTrustedTypeChecker","type","has","wrapPolicy","innerPolicy","creator","Ctor","methodName","method","DEFAULT_POLICY_NAME","policySpecificType","factory","args","result","$jscomp.arrayFromIterator","allowedValue","o","createTypeMapping","writable","configurable","getTypeInternal_","tag","container","elNs","attrNs","canonicalTag","apply","ns","HTML_NS","hasOwnProperty","TYPE_MAP","getDefaultPolicy","defaultPolicy","Object","assign","Array","forEach","Symbol","WeakMap","policyNames","allowedNames","allowDuplicateNames","enforceNameRestrictions","toString","valueOf","$jscomp.inherits","emptyHTML","emptyScript","XLINK_NS","SVG_NS","ATTR_PROPERTY_MAP","HTMLIFrameElement","keys","attr","createFunctionAllowed","api","createPolicy","match","indexOf","call","console","warn","wrappedPolicy","isHTML","isURL","isScriptURL","isScript","getAttributeType","tagName","attribute","elementNs","attributeNs","canonicalAttr","getPropertyType","property","getTypeMapping","namespaceUri","document","documentElement","namespaceURI","e","JSON","parse","stringify","trustedTypes","setPolicyNameRestrictions","length","el","clearPolicyNameRestrictions","resetDefaultPolicy","splice","installFunction","object","fn","Reflect","getOwnPropertyDescriptor","UrlConstructor","URL","stringifyForRangeHack","getConstructorName_","createElement","windowOpenObject","insertAdjacentObject","Element","SecurityPolicyViolationEvent","typeMap","TrustedTypes","STRING_TO_TYPE","attrs","entries","k","TYPE_CHECKER_MAP","TYPE_PRODUCER_MAP","TrustedTypesEnforcer","config_","config","originalSetters_","install","trustedTypesEnforcer","wrapSetter_","ShadowRoot","doc","createRange","r","createContextualFragment","f","childNodes","wrapWithEnforceFunction_","Range","Document","HTMLDocument","DOMParser","wrapSetAttribute_","installScriptMutatorGuards_","installPropertySetWrappers_","fnName","wrapFunction_","Node","originalFn","that","enforceTypeInScriptNodes_","bind","insertAdjacentTextWrapper_","setAttributeWrapper_","setAttributeNSWrapper_","context","attrName","requiredType","enforce_","checkParent","objToCheck","parentNode","HTMLScriptElement","argNumber","arg","nodeType","TEXT_NODE","textContent","createTextNode","fallbackValue","maybeCallDefaultPolicy_","processViolation_","riskyPositions","parentElement","textNode","insertBefore","getKey_","nextSibling","functionBody","descriptor","Function","enforcingSetter","originalSetter","useObject","stopAt","typeName","sink","fallbackPolicy","propertyName","typeToEnforce","isInlineEventHandler","objName","localName","contextName","message","blockedURI","baseURI","href","valueSlice","event","location","isConnected","dispatchEvent","publicApi","tt","detectPolicy","currentScript","scripts","getElementsByTagName","bodyPrefix","substr","dataset","cspInMeta","head","querySelector","rootProperty","TrustedTypeConfig$$module$src$data$trustedtypeconfig.fromCSP"],"mappings":"A;;;;;;;;AA2B4B,QAAA,GAAQ,CAAC,CAAD,CAAQ,CAC1C,I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C,cAAD,CAAiB,cAAjB,CAA3B,CADyB,CACzB,GAAA,EAAA,KAAA,EAAA,CAAA,CAAA,EAAA,KAAA,CAAA,EAAA,CAAA,EAAA,KAAA,EAAA,CAA6D,CAA7D,IAAWgS,GAAX,EAAA,MACE,IAAI3P,MAAA,CAAO2P,EAAP,CAAJ,EAA4B,CAAC3P,MAAA,CAAO2P,EAAP,CAAA,aAA7B,CAAmE,CAEjE,EAAA,CAAO,CAAA,CAAP,OAAA,CAFiE,CADR,CAM7D,EAAA,CAAO,CAAA,CAPkB,CAW3B,GAAI,EAAJ,CAAA,CA3BE,IAAMxQ,GAAM8P,EAAA,EAAZ,CACMhF,GAAS9K,EAAA,CAAMyQ,EAAA,EAAN,CAAuC,IAAI7R,EAAJ,CAC3B,CAAA,CAD2B,CAEvB,CAAA,CAFuB,CAGzB,EAHyB,CAI5B,CAAA,CAJ4B,CAQtDoM,GAAA,EAkBF","file":"trustedtypes.build.js","sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,"/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n/**\n * CSP Directive name controlling Trusted Types behavior.\n * @type {string}\n */\nexport const ENFORCEMENT_DIRECTIVE_NAME = 'require-trusted-types-for';\n\nexport const POLICIES_DIRECTIVE_NAME = 'trusted-types';\n\n/**\n * A configuration object for trusted type enforcement.\n */\nexport class TrustedTypeConfig {\n /**\n * @param {boolean} isLoggingEnabled If true enforcement wrappers will log\n * violations to the console.\n * @param {boolean} isEnforcementEnabled If true enforcement is enabled at\n * runtime.\n * @param {Array} allowedPolicyNames Whitelisted policy names.\n * @param {boolean} allowDuplicates Should duplicate names be allowed.\n * @param {?string} cspString String with the CSP policy.\n */\n constructor(isLoggingEnabled,\n isEnforcementEnabled,\n allowedPolicyNames,\n allowDuplicates,\n cspString = null) {\n /**\n * True if logging is enabled.\n * @type {boolean}\n */\n this.isLoggingEnabled = isLoggingEnabled;\n\n /**\n * True if enforcement is enabled.\n * @type {boolean}\n */\n this.isEnforcementEnabled = isEnforcementEnabled;\n\n /**\n * Allowed policy names.\n * @type {Array}\n */\n this.allowedPolicyNames = allowedPolicyNames;\n\n /**\n * Should duplicate names be accepted.\n * @type {boolean}\n */\n this.allowDuplicates = allowDuplicates;\n\n /**\n * CSP string that defined the policy.\n * @type {?string}\n */\n this.cspString = cspString;\n }\n\n /**\n * Parses a CSP policy.\n * @link https://www.w3.org/TR/CSP3/#parse-serialized-policy\n * @param {string} cspString String with a CSP definition.\n * @return {Object>} Parsed CSP, keyed by directive\n * names.\n */\n static parseCSP(cspString) {\n const SEMICOLON = /\\s*;\\s*/;\n const WHITESPACE = /\\s+/;\n return cspString.trim().split(SEMICOLON)\n .map((serializedDirective) => serializedDirective.split(WHITESPACE))\n .reduce(function(parsed, directive) {\n if (directive[0]) {\n parsed[directive[0]] = directive.slice(1).map((s) => s).sort();\n }\n return parsed;\n }, {});\n }\n\n /**\n * Creates a TrustedTypeConfig object from a CSP string.\n * @param {string} cspString\n * @return {!TrustedTypeConfig}\n */\n static fromCSP(cspString) {\n const isLoggingEnabled = true;\n const policy = TrustedTypeConfig.parseCSP(cspString);\n const enforce = ENFORCEMENT_DIRECTIVE_NAME in policy &&\n policy[ENFORCEMENT_DIRECTIVE_NAME].includes('\\'script\\'');\n let policies = ['*'];\n let allowDuplicates = true;\n if (POLICIES_DIRECTIVE_NAME in policy) {\n policies = policy[POLICIES_DIRECTIVE_NAME].filter(\n (p) => p.charAt(0) !== '\\'');\n allowDuplicates = policy[POLICIES_DIRECTIVE_NAME].includes(\n '\\'allow-duplicates\\'');\n }\n return new TrustedTypeConfig(\n isLoggingEnabled,\n enforce, /* isEnforcementEnabled */\n policies, /* allowedPolicyNames */\n allowDuplicates, /* allowDuplicates */\n cspString\n );\n }\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n/**\n * @fileoverview Entry point for a polyfill that enforces the types.\n */\nimport {TrustedTypesEnforcer} from '../enforcer.js';\nimport {TrustedTypeConfig} from '../data/trustedtypeconfig.js';\n// import and setup trusted types\nimport './api_only.js';\n\n/* eslint-enable no-unused-vars */\n\n/**\n * Tries to guess a CSP policy from:\n * - the current polyfill script element text content (if prefixed with\n * \"Content-Security-Policy:\")\n * - the data-csp attribute value of the current script element.\n * - meta header\n * @return {?string} Guessed CSP value, or null.\n */\nfunction detectPolicy() {\n try {\n const currentScript = document.currentScript || (function() {\n const scripts = document.getElementsByTagName('script');\n return scripts[scripts.length - 1];\n })();\n\n const bodyPrefix = 'Content-Security-Policy:';\n if (currentScript &&\n currentScript.textContent.trim().substr(0, bodyPrefix.length) ==\n bodyPrefix) {\n return currentScript.textContent.trim().slice(bodyPrefix.length);\n }\n if (currentScript.dataset['csp']) {\n return currentScript.dataset['csp'];\n }\n const cspInMeta = document.head.querySelector(\n 'meta[http-equiv^=\"Content-Security-Policy\"]');\n if (cspInMeta) {\n return cspInMeta['content'].trim();\n }\n } catch (e) {\n return null;\n }\n return null;\n}\n\n/**\n * Bootstraps all trusted types polyfill and their enforcement.\n */\nexport function bootstrap() {\n const csp = detectPolicy();\n const config = csp ? TrustedTypeConfig.fromCSP(csp) : new TrustedTypeConfig(\n /* isLoggingEnabled */ false,\n /* isEnforcementEnabled */ false,\n /* allowedPolicyNames */ [],\n /* allowDuplicates */ true);\n\n const trustedTypesEnforcer = new TrustedTypesEnforcer(config);\n\n trustedTypesEnforcer.install();\n}\n\n/**\n * Determines if the enforcement should be enabled.\n * @return {boolean}\n */\nfunction shouldBootstrap() {\n for (const rootProperty of ['trustedTypes', 'TrustedTypes']) {\n if (window[rootProperty] && !window[rootProperty]['_isPolyfill_']) {\n // Native implementation exists\n return false;\n }\n }\n return true;\n}\n\n// Bootstrap only if native implementation is missing.\nif (shouldBootstrap()) {\n bootstrap();\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n// TODO check attributes in safari, remove legacy safe handlers\nconst unsafeAttributeEventHandlers = [\n 'onabort',\n 'onactivate',\n 'onactivateinvisible',\n 'onafterprint',\n 'onafterupdate',\n 'onanimationcancel',\n 'onanimationend',\n 'onanimationiteration',\n 'onanimationstart',\n 'onariarequest',\n 'onauxclick',\n 'onbeforeactivate',\n 'onbeforecopy',\n 'onbeforecut',\n 'onbeforedeactivate',\n 'onbeforeeditfocus',\n 'onbeforepaste',\n 'onbeforeprint',\n 'onbeforeunload',\n 'onbegin',\n 'onblur',\n 'onbounce',\n 'oncancel',\n 'oncanplay',\n 'oncanplaythrough',\n 'oncellchange',\n 'onchange',\n 'onclick',\n 'onclose',\n 'oncommand',\n 'oncontextmenu',\n 'oncontrolselect',\n 'oncopy',\n 'oncuechange',\n 'oncut',\n 'ondataavailable',\n 'ondatasetchanged',\n 'ondatasetcomplete',\n 'ondblclick',\n 'ondeactivate',\n 'ondrag',\n 'ondragdrop',\n 'ondragend',\n 'ondragenter',\n 'ondragexit',\n 'ondragleave',\n 'ondragover',\n 'ondragstart',\n 'ondrop',\n 'ondurationchange',\n 'onemptied',\n 'onend',\n 'onended',\n 'onerror',\n 'onerrorupdate',\n 'onexit',\n 'onfilterchange',\n 'onfinish',\n 'onfocus',\n 'onfocusin',\n 'onfocusout',\n 'onformdata',\n 'onfullscreenchange',\n 'onfullscreenerror',\n 'ongotpointercapture',\n 'onhelp',\n 'oninput',\n 'oninvalid',\n 'onkeydown',\n 'onkeypress',\n 'onkeyup',\n 'onlayoutcomplete',\n 'onload',\n 'onloadeddata',\n 'onloadedmetadata',\n 'onloadend',\n 'onloadstart',\n 'onlosecapture',\n 'onlostpointercapture',\n 'onmediacomplete',\n 'onmediaerror',\n 'onmessage',\n 'onmousedown',\n 'onmouseenter',\n 'onmouseleave',\n 'onmousemove',\n 'onmouseout',\n 'onmouseover',\n 'onmouseup',\n 'onmousewheel',\n 'onmove',\n 'onmoveend',\n 'onmovestart',\n 'onmozfullscreenchange',\n 'onmozfullscreenerror',\n 'onmscontentzoom',\n 'onmsgesturechange',\n 'onmsgesturedoubletap',\n 'onmsgestureend',\n 'onmsgesturehold',\n 'onmsgesturestart',\n 'onmsgesturetap',\n 'onmsgotpointercapture',\n 'onmsinertiastart',\n 'onmslostpointercapture',\n 'onmsmanipulationstatechanged',\n 'onmspointercancel',\n 'onmspointerdown',\n 'onmspointerenter',\n 'onmspointerleave',\n 'onmspointermove',\n 'onmspointerout',\n 'onmspointerover',\n 'onmspointerup',\n 'onoffline',\n 'ononline',\n 'onoutofsync',\n 'onoverscroll',\n 'onpaste',\n 'onpause',\n 'onplay',\n 'onplaying',\n 'onpointercancel',\n 'onpointerdown',\n 'onpointerenter',\n 'onpointerleave',\n 'onpointermove',\n 'onpointerout',\n 'onpointerover',\n 'onpointerrawupdate',\n 'onpointerup',\n 'onprogress',\n 'onpropertychange',\n 'onratechange',\n 'onreadystatechange',\n 'onrepeat',\n 'onreset',\n 'onresize',\n 'onresizeend',\n 'onresizestart',\n 'onresume',\n 'onreverse',\n 'onrowdelete',\n 'onrowenter',\n 'onrowexit',\n 'onrowinserted',\n 'onscroll',\n 'onscrollend',\n 'onsearch',\n 'onseek',\n 'onseeked',\n 'onseeking',\n 'onselect',\n 'onselectionchange',\n 'onselectstart',\n 'onshow',\n 'onstalled',\n 'onstart',\n 'onstop',\n 'onstorage',\n 'onsubmit',\n 'onsuspend',\n 'onsynchrestored',\n 'ontimeerror',\n 'ontimeupdate',\n 'ontoggle',\n 'ontrackchange',\n 'ontransitioncancel',\n 'ontransitionend',\n 'ontransitionrun',\n 'ontransitionstart',\n 'onunload',\n 'onurlflip',\n 'onvolumechange',\n 'onwaiting',\n 'onwebkitanimationend',\n 'onwebkitanimationiteration',\n 'onwebkitanimationstart',\n 'onwebkitfullscreenchange',\n 'onwebkitfullscreenerror',\n 'onwebkittransitionend',\n 'onwheel',\n];\n\n/**\n * Returns an array of all event handlers. Some of the event handlers may be\n * supported only in some browsers.\n *\n * For every event type that the browser supports, SVG supports that as an event\n * attribute, following the same requirements as for HTML event attributes.\n * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/Events\n *\n * @return {!Array}\n */\nexport function getUnsafeAttributeEventHandlers() {\n if (typeof window !== 'undefined') {\n const eventHandlers = [];\n for (const name in HTMLElement.prototype) {\n if (name.slice(0, 2) === 'on') {\n eventHandlers.push(name);\n }\n }\n return eventHandlers;\n } else {\n return unsafeAttributeEventHandlers;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\nimport {getUnsafeAttributeEventHandlers} from './utils/eventHandlers.js';\n\nconst isBrowser = typeof window !== 'undefined';\n\nconst rejectInputFn = (s) => {\n throw new TypeError('undefined conversion');\n};\n\nconst rejectInputDefaultPolicyFn = (s) => null;\n\nconst {toLowerCase, toUpperCase} = String.prototype;\n\nexport const HTML_NS = 'http://www.w3.org/1999/xhtml';\nexport const XLINK_NS = 'http://www.w3.org/1999/xlink';\nexport const SVG_NS = 'http://www.w3.org/2000/svg';\n\n/**\n * @constructor\n * @property {!function(string):TrustedHTML} createHTML\n * @property {!function(string):TrustedURL} createURL\n * @property {!function(string):TrustedScriptURL} createScriptURL\n * @property {!function(string):TrustedScript} createScript\n * @property {!string} name\n */\nexport const TrustedTypePolicy = function() {\n throw new TypeError('Illegal constructor');\n};\n\n/**\n * @constructor\n */\nexport const TrustedTypePolicyFactory = function() {\n throw new TypeError('Illegal constructor');\n};\n\n/* eslint-disable no-unused-vars */\n/**\n * @typedef {TrustedTypesInnerPolicy}\n * @property {function(string):string} createHTML\n * @property {function(string):string} createURL\n * @property {function(string):string} createScriptURL\n * @property {function(string):string} createScript\n */\nconst TrustedTypesInnerPolicy = {};\n\n/**\n * @typedef {!Object,\n * properties: !Object}>}\n */\nconst TrustedTypesTypeMap = {};\n/* eslint-enable no-unused-vars */\n\nexport const DEFAULT_POLICY_NAME = 'default';\n\n\nexport const trustedTypesBuilderTestOnly = function() {\n // Capture common names early.\n const {\n assign, create, defineProperty, freeze, getOwnPropertyNames,\n getPrototypeOf, prototype: ObjectPrototype,\n } = Object;\n\n const {hasOwnProperty} = ObjectPrototype;\n\n const {\n forEach, push,\n } = Array.prototype;\n\n const creatorSymbol = Symbol();\n\n /**\n * Getter for the privateMap.\n * @param {Object} obj Key of the privateMap\n * @return {Object} Private storage.\n */\n const privates = function(obj) {\n let v = privateMap.get(obj);\n if (v === undefined) {\n v = create(null); // initialize the private storage.\n privateMap.set(obj, v);\n }\n return v;\n };\n\n /**\n * Called before attacker-controlled code on an internal collections,\n * copies prototype members onto the instance directly, so that later\n * changes to prototypes cannot expose collection internals.\n * @param {!T} collection\n * @return {!T} collection\n * @template T\n */\n function selfContained(collection) {\n const proto = getPrototypeOf(collection);\n if (proto == null || getPrototypeOf(proto) !== ObjectPrototype) {\n throw new Error(); // Loop below is insufficient.\n }\n for (const key of getOwnPropertyNames(proto)) {\n defineProperty(collection, key, {value: collection[key]});\n }\n return collection;\n }\n\n /**\n * Map for private properties of Trusted Types object.\n * This is so that the access to the type constructor does not give\n * the ability to create typed values.\n * @type {WeakMap}\n */\n const privateMap = selfContained(new WeakMap());\n\n /**\n * List of all configured policy names.\n * @type {Array}\n */\n const policyNames = selfContained([]);\n\n /**\n * Allowed policy names.\n * Applied only if enforceNameRestrictions is true.\n * @type {Array}\n */\n const allowedNames = selfContained([]);\n\n /**\n * Should duplicate prolicy names be allowed.\n * Applied only if enforceNameRestrictions is true.\n * @type {boolean}\n */\n let allowDuplicateNames = true;\n\n /**\n * A reference to a default policy, if created.\n * @type {TrustedTypePolicy}\n */\n let defaultPolicy = null;\n\n /**\n * Whether to enforce allowedNames in createPolicy().\n * @type {boolean}\n */\n let enforceNameRestrictions = false;\n\n\n /**\n * A value that is trusted to have certain security-relevant properties\n * because the sources of such values are controlled.\n */\n class TrustedType {\n /**\n * Constructor for TrustedType. Only allowed to be called from within a\n * policy.\n * @param {symbol} s creatorSymbol\n * @param {string} policyName The name of the policy this object was\n * created by.\n */\n constructor(s, policyName) {\n // TODO: Figure out if symbol is needed, if the value is in privateMap.\n if (s !== creatorSymbol) {\n throw new Error('cannot call the constructor');\n }\n defineProperty(this, 'policyName',\n {value: '' + policyName, enumerable: true});\n }\n\n /**\n * Returns the wrapped string value of the object.\n * @return {string}\n * @override\n */\n toString() {\n return privates(this)['v'];\n }\n\n /**\n * Returns the wrapped string value of the object.\n * @return {string}\n * @override\n */\n valueOf() {\n return privates(this)['v'];\n }\n }\n\n /**\n * @param {function(new:TrustedType, symbol, string)} SubClass\n * @param {string} canonName The class name which should be independent of\n * any renaming pass and which is relied upon by the enforcer and for\n * native type interop.\n */\n function lockdownTrustedType(SubClass, canonName) {\n freeze(SubClass.prototype);\n delete SubClass.name;\n defineProperty(SubClass, 'name', {value: canonName});\n }\n\n /**\n * Trusted URL object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedURL extends TrustedType {\n }\n lockdownTrustedType(TrustedURL, 'TrustedURL');\n\n /**\n * Trusted Script URL object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedScriptURL extends TrustedType {\n }\n lockdownTrustedType(TrustedScriptURL, 'TrustedScriptURL');\n\n /**\n * Trusted HTML object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedHTML extends TrustedType {\n }\n lockdownTrustedType(TrustedHTML, 'TrustedHTML');\n\n /**\n * Trusted Script object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedScript extends TrustedType {\n }\n lockdownTrustedType(TrustedScript, 'TrustedScript');\n\n lockdownTrustedType(TrustedType, 'TrustedType');\n\n // Common constants.\n const emptyHTML = freeze(create(new TrustedHTML(creatorSymbol, '')));\n privates(emptyHTML)['v'] = '';\n const emptyScript = freeze(create(new TrustedScript(creatorSymbol, '')));\n privates(emptyScript)['v'] = '';\n\n /**\n * A map of attribute / property names to allowed types\n * for known namespaces.\n * @type {!Object}\n * @export\n */\n const TYPE_MAP = {\n [HTML_NS]: {\n // TODO(koto): Figure out what to to with \n 'A': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'AREA': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'BASE': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'BUTTON': {\n 'attributes': {\n 'formaction': TrustedURL.name,\n },\n },\n 'EMBED': {\n 'attributes': {\n 'src': TrustedScriptURL.name,\n },\n },\n 'FORM': {\n 'attributes': {\n 'action': TrustedURL.name,\n },\n },\n 'FRAME': {\n 'attributes': {\n 'src': TrustedURL.name,\n },\n },\n 'IFRAME': {\n 'attributes': {\n 'src': TrustedURL.name,\n 'srcdoc': TrustedHTML.name,\n },\n },\n 'INPUT': {\n 'attributes': {\n 'formaction': TrustedURL.name,\n },\n },\n 'OBJECT': {\n 'attributes': {\n 'data': TrustedScriptURL.name,\n 'codebase': TrustedScriptURL.name,\n },\n },\n // TODO(koto): Figure out what to do with portals.\n 'SCRIPT': {\n 'attributes': {\n 'src': TrustedScriptURL.name,\n 'text': TrustedScript.name,\n },\n 'properties': {\n 'innerText': TrustedScript.name,\n 'textContent': TrustedScript.name,\n 'text': TrustedScript.name,\n },\n },\n '*': {\n 'attributes': {},\n 'properties': {\n 'innerHTML': TrustedHTML.name,\n 'outerHTML': TrustedHTML.name,\n },\n },\n },\n [XLINK_NS]: {\n '*': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n 'properties': {},\n },\n },\n [SVG_NS]: {\n '*': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n 'properties': {},\n },\n },\n };\n\n /**\n * A map of element property to HTML attribute names.\n * @type {!Object}\n */\n const ATTR_PROPERTY_MAP = {\n 'codebase': 'codeBase',\n 'formaction': 'formAction',\n };\n\n // Edge doesn't support srcdoc.\n if (isBrowser && !('srcdoc' in HTMLIFrameElement.prototype)) {\n delete TYPE_MAP[HTML_NS]['IFRAME']['attributes']['srcdoc'];\n }\n\n // in HTML, clone attributes into properties.\n for (const tag of Object.keys(TYPE_MAP[HTML_NS])) {\n if (!TYPE_MAP[HTML_NS][tag]['properties']) {\n TYPE_MAP[HTML_NS][tag]['properties'] = {};\n }\n for (const attr of Object.keys(TYPE_MAP[HTML_NS][tag]['attributes'])) {\n TYPE_MAP[HTML_NS][tag]['properties'][\n ATTR_PROPERTY_MAP[attr] ? ATTR_PROPERTY_MAP[attr] : attr\n ] = TYPE_MAP[HTML_NS][tag]['attributes'][attr];\n }\n }\n\n // Add inline event handlers attribute names.\n for (const name of getUnsafeAttributeEventHandlers()) {\n TYPE_MAP[HTML_NS]['*']['attributes'][name] = 'TrustedScript';\n TYPE_MAP[SVG_NS]['*']['attributes'][name] = 'TrustedScript';\n }\n\n /**\n * @type {!Object}\n */\n const createTypeMapping = {\n 'createHTML': TrustedHTML,\n 'createScriptURL': TrustedScriptURL,\n 'createURL': TrustedURL,\n 'createScript': TrustedScript,\n };\n\n const createFunctionAllowed = createTypeMapping.hasOwnProperty;\n\n /**\n * Function generating a type checker.\n * @template T\n * @param {T} type The type to check against.\n * @return {function(*):boolean}\n */\n function isTrustedTypeChecker(type) {\n return (obj) => (obj instanceof type) && privateMap.has(obj);\n }\n\n /**\n * Wraps a user-defined policy rules with TT constructor\n * @param {string} policyName The policy name\n * @param {TrustedTypesInnerPolicy} innerPolicy InnerPolicy\n * @return {!TrustedTypePolicy} Frozen policy object\n */\n function wrapPolicy(policyName, innerPolicy) {\n /**\n * @template T\n * @param {function(new:T, symbol, string)} Ctor a trusted type constructor\n * @param {string} methodName the policy factory method name\n * @return {function(string):!T} a factory that produces instances of Ctor.\n */\n function creator(Ctor, methodName) {\n // This causes thisValue to be null when called below.\n const method = innerPolicy[methodName] || (\n policyName == DEFAULT_POLICY_NAME ?\n rejectInputDefaultPolicyFn : rejectInputFn\n );\n const policySpecificType = freeze(new Ctor(creatorSymbol, policyName));\n const factory = {\n [methodName](s, ...args) {\n // Trick to get methodName to show in stacktrace.\n let result = method('' + s, ...args);\n if (result === undefined || result === null) {\n if (policyName == DEFAULT_POLICY_NAME) {\n // These values mean that the input was rejected. This will cause\n // a violation later, don't create types for them.\n return result;\n }\n result = '';\n }\n const allowedValue = '' + result;\n const o = freeze(create(policySpecificType));\n privates(o)['v'] = allowedValue;\n return o;\n },\n }[methodName];\n return freeze(factory);\n }\n\n const policy = create(TrustedTypePolicy.prototype);\n\n for (const name of getOwnPropertyNames(createTypeMapping)) {\n policy[name] = creator(createTypeMapping[name], name);\n }\n defineProperty(policy, 'name', {\n value: policyName,\n writable: false,\n configurable: false,\n enumerable: true,\n });\n\n return /** @type {!TrustedTypePolicy} */ (freeze(policy));\n }\n\n /**\n * Returns the name of the trusted type required for a given element\n * attribute.\n * @param {string} tagName The name of the tag of the element.\n * @param {string} attribute The name of the attribute.\n * @param {string=} elementNs Element namespace.\n * @param {string=} attributeNs The attribute namespace.\n * @return {string?} Required type name or null, if a Trusted\n * Type is not required.\n */\n function getAttributeType(tagName, attribute, elementNs = '',\n attributeNs = '') {\n const canonicalAttr = toLowerCase.apply(String(attribute));\n return getTypeInternal_(tagName, 'attributes', canonicalAttr,\n elementNs, attributeNs) || null;\n }\n\n /**\n * Returns a type name from a type map.\n * @param {string} tag A tag name.\n * @param {string} container 'attributes' or 'properties'\n * @param {string} name The attribute / property name.\n * @param {string=} elNs Element namespace.\n * @param {string=} attrNs Attribute namespace.\n * @return {string|undefined}\n * @private\n */\n function getTypeInternal_(tag, container, name, elNs = '', attrNs = '') {\n const canonicalTag = toUpperCase.apply(String(tag));\n\n let ns = attrNs ? attrNs : elNs;\n if (!ns) {\n ns = HTML_NS;\n }\n const map = hasOwnProperty.apply(TYPE_MAP, [ns]) ? TYPE_MAP[ns] : null;\n if (!map) {\n return;\n }\n if (hasOwnProperty.apply(map, [canonicalTag]) &&\n map[canonicalTag] &&\n hasOwnProperty.apply(map[canonicalTag][container], [name]) &&\n map[canonicalTag][container][name]) {\n return map[canonicalTag][container][name];\n }\n\n if (hasOwnProperty.apply(map, ['*']) &&\n hasOwnProperty.apply(map['*'][container], [name]) &&\n map['*'][container][name]) {\n return map['*'][container][name];\n }\n }\n\n /**\n * Returns the name of the trusted type required for a given element property.\n * @param {string} tagName The name of the tag of the element.\n * @param {string} property The property.\n * @param {string=} elementNs Element namespace.\n * @return {string?} Required type name or null, if a Trusted\n * Type is not required.\n */\n function getPropertyType(tagName, property, elementNs = '') {\n // TODO: Support namespaces.\n return getTypeInternal_(\n tagName, 'properties', String(property), elementNs) || null;\n }\n\n /**\n * Returns the type map-like object, that resolves a name of a type for a\n * given tag + attribute / property in a given namespace.\n * The keys of the map are uppercase tag names. Map entry has mappings between\n * a lowercase attribute name / case-sensitive property name and a name of the\n * type that is required for that attribute / property.\n * Example entry for 'IMG': {\"attributes\": {\"src\": \"TrustedHTML\"}}\n * @param {string=} namespaceUri The namespace URI (will use the current\n * document namespace URI if omitted).\n * @return {TrustedTypesTypeMap}\n */\n function getTypeMapping(namespaceUri = '') {\n if (!namespaceUri) {\n try {\n namespaceUri = document.documentElement.namespaceURI;\n } catch (e) {\n namespaceUri = HTML_NS;\n }\n }\n /**\n * @template T\n * @private\n * @param {T} o\n * @return {T}\n */\n function deepClone(o) {\n return JSON.parse(JSON.stringify(o));\n }\n const map = TYPE_MAP[namespaceUri];\n if (!map) {\n return {};\n }\n return deepClone(map);\n }\n\n /**\n * Creates a TT policy.\n *\n * Returns a frozen object representing a policy - a collection of functions\n * that may create TT objects based on the user-provided rules specified\n * in the policy object.\n *\n * @param {string} name A unique name of the policy.\n * @param {TrustedTypesInnerPolicy} policy Policy rules object.\n * @return {TrustedTypePolicy} The policy that may create TT objects\n * according to the policy rules.\n */\n function createPolicy(name, policy) {\n const pName = '' + name; // Assert it's a string\n\n if (!pName.match(/^[-#a-zA-Z0-9=_/@.%]+$/g)) {\n throw new TypeError('Policy ' + pName + ' contains invalid characters.');\n }\n\n if (enforceNameRestrictions && allowedNames.indexOf(pName) === -1) {\n throw new TypeError('Policy ' + pName + ' disallowed.');\n }\n\n if (pName === DEFAULT_POLICY_NAME && defaultPolicy) {\n throw new TypeError('Policy ' + pName + ' already exists.');\n }\n if (enforceNameRestrictions && !allowDuplicateNames &&\n policyNames.indexOf(pName) !== -1) {\n throw new TypeError('Policy ' + pName + ' exists.');\n }\n // Register the name early so that if policy getters unwisely calls\n // across protection domains to code that reenters this function,\n // policy author still has rights to the name.\n policyNames.push(pName);\n\n // Only copy own properties of names present in createTypeMapping.\n const innerPolicy = create(null);\n if (policy && typeof policy === 'object') {\n // Treat non-objects as empty policies.\n for (const key of getOwnPropertyNames(policy)) {\n if (createFunctionAllowed.call(createTypeMapping, key)) {\n innerPolicy[key] = policy[key];\n }\n }\n } else {\n // eslint-disable-next-line no-console\n console.warn('trustedTypes.createPolicy ' + pName +\n ' was given an empty policy');\n }\n freeze(innerPolicy);\n\n const wrappedPolicy = wrapPolicy(pName, innerPolicy);\n\n if (pName === DEFAULT_POLICY_NAME) {\n defaultPolicy = wrappedPolicy;\n }\n\n return wrappedPolicy;\n }\n\n /**\n * Applies the policy name restrictions.\n * @param {!Array} allowedPolicyNames\n * @param {boolean} allowDuplicates\n */\n function setPolicyNameRestrictions(allowedPolicyNames, allowDuplicates) {\n enforceNameRestrictions = true;\n allowedNames.length = 0;\n forEach.call(allowedPolicyNames, (el) => {\n push.call(allowedNames, '' + el);\n });\n allowDuplicateNames = allowDuplicates;\n policyNames.length = 0; // Clear already used policy names list.\n }\n\n /**\n * Clears the policy name restrictions.\n */\n function clearPolicyNameRestrictions() {\n enforceNameRestrictions = false;\n }\n\n /**\n * Returns the default policy, or null if it was not created.\n * @return {TrustedTypePolicy}\n */\n function getDefaultPolicy() {\n return defaultPolicy;\n }\n\n /**\n * Resets the default policy.\n */\n function resetDefaultPolicy() {\n defaultPolicy = null;\n policyNames.splice(policyNames.indexOf(DEFAULT_POLICY_NAME), 1);\n }\n\n const api = create(TrustedTypePolicyFactory.prototype);\n assign(api, {\n // The main function to create policies.\n createPolicy,\n\n // Type checkers, also validating the object was initialized through a\n // policy.\n isHTML: isTrustedTypeChecker(TrustedHTML),\n isURL: isTrustedTypeChecker(TrustedURL),\n isScriptURL: isTrustedTypeChecker(TrustedScriptURL),\n isScript: isTrustedTypeChecker(TrustedScript),\n\n getAttributeType,\n getPropertyType,\n getTypeMapping,\n emptyHTML,\n emptyScript,\n defaultPolicy, // Just to make the compiler happy, this is overridden below.\n\n TrustedHTML: TrustedHTML,\n TrustedURL: TrustedURL,\n TrustedScriptURL: TrustedScriptURL,\n TrustedScript: TrustedScript,\n });\n\n defineProperty(api, 'defaultPolicy', {\n get: getDefaultPolicy,\n set: () => {},\n });\n\n return {\n trustedTypes: freeze(api),\n setPolicyNameRestrictions,\n clearPolicyNameRestrictions,\n getDefaultPolicy,\n resetDefaultPolicy,\n };\n};\n\n\nexport const {\n trustedTypes,\n setPolicyNameRestrictions,\n clearPolicyNameRestrictions,\n getDefaultPolicy,\n resetDefaultPolicy,\n} = trustedTypesBuilderTestOnly();\n\n",null,"/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\nconst {\n defineProperty,\n} = Object;\n\n/**\n * Installs the setter of a given property.\n * @param {!Object} object An object for which to wrap the property.\n * @param {string} name The name of the property to wrap.\n * @param {function(*): *|undefined} setter A setter function}\n */\nexport function installSetter(object, name, setter) {\n const descriptor = {\n set: setter,\n };\n defineProperty(object, name, descriptor);\n}\n\n/**\n * Installs a setter and getter of a given property.\n * @param {!Object} object An object for which to wrap the property.\n * @param {string} name The name of the property to wrap.\n * @param {function(*): *|undefined} setter A setter function}\n * @param {function(*): *|undefined} getter A getter function}\n */\nexport function installSetterAndGetter(object, name, setter, getter) {\n const descriptor = {\n set: setter,\n get: getter,\n configurable: true, // This can get uninstalled, we need configurable: true\n };\n defineProperty(object, name, descriptor);\n}\n\n/**\n * Installs the setter of a given property.\n * @param {!Object} object An object for which to wrap the property.\n * @param {string} name The name of the property to wrap.\n * @param {function(*): *|undefined} fn A function}\n */\nexport function installFunction(object, name, fn) {\n defineProperty(object, name, {\n value: fn,\n });\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n// TrustedTypeConfig is used only as jsdoc type\n// eslint-disable-next-line\nimport {ENFORCEMENT_DIRECTIVE_NAME, TrustedTypeConfig}\n from './data/trustedtypeconfig.js';\nimport {\n trustedTypes as TrustedTypes,\n setPolicyNameRestrictions,\n clearPolicyNameRestrictions,\n resetDefaultPolicy,\n HTML_NS,\n} from\n './trustedtypes.js';\n\nimport {installFunction, installSetter, installSetterAndGetter}\n from './utils/wrapper.js';\n\nconst {apply} = Reflect;\nconst {\n getOwnPropertyNames,\n getOwnPropertyDescriptor,\n getPrototypeOf,\n} = Object;\n\nconst {\n hasOwnProperty,\n isPrototypeOf,\n} = Object.prototype;\n\nconst {slice} = String.prototype;\n\n// No URL in IE 11.\nconst UrlConstructor = typeof window.URL == 'function' ?\n URL.prototype.constructor :\n null;\n\nlet stringifyForRangeHack;\n\n/**\n * Return object constructor name\n * (their function.name is not available in IE 11).\n * @param {Function} fn\n * @return {string}\n * @private\n */\nconst getConstructorName_ = document.createElement('div').constructor.name ?\n (fn) => fn.name :\n (fn) => ('' + fn).match(/^\\[object (\\S+)\\]$/)[1];\n\n// window.open on IE 11 is set on WindowPrototype\nconst windowOpenObject = getOwnPropertyDescriptor(window, 'open') ?\n window :\n window.constructor.prototype;\n\n// In IE 11, insertAdjacent(HTML|Text) is on HTMLElement prototype\nconst insertAdjacentObject = apply(hasOwnProperty, Element.prototype,\n ['insertAdjacentHTML']) ? Element.prototype : HTMLElement.prototype;\n\n// This is not available in release Firefox :(\n// https://developer.mozilla.org/en-US/docs/Web/API/SecurityPolicyViolationEvent\n// https://bugzilla.mozilla.org/show_bug.cgi?id=1432523\nconst SecurityPolicyViolationEvent = window['SecurityPolicyViolationEvent'] ||\n null;\n\n/**\n * Parses URL, catching all the errors.\n * @param {string} url URL string to parse.\n * @return {URL|null}\n */\nfunction parseUrl_(url) {\n try {\n return new UrlConstructor(url, document.baseURI || undefined);\n } catch (e) {\n return null;\n }\n}\n\n// We don't actually need other namespaces.\n// setAttribute is hooked on Element.prototype, which all elements inherit from,\n// and all sensitive property wrappers are hooked directly on Element as well.\nconst typeMap = TrustedTypes.getTypeMapping(HTML_NS);\n\nconst STRING_TO_TYPE = {\n 'TrustedHTML': TrustedTypes.TrustedHTML,\n 'TrustedScript': TrustedTypes.TrustedScript,\n 'TrustedScriptURL': TrustedTypes.TrustedScriptURL,\n 'TrustedURL': TrustedTypes.TrustedURL,\n};\n\n/**\n * Converts an uppercase tag name to an element constructor function name.\n * Used for property setter hijacking only.\n * @param {string} tagName\n * @return {string}\n */\nfunction convertTagToConstructor(tagName) {\n if (tagName == '*') {\n return 'HTMLElement';\n }\n return getConstructorName_(document.createElement(tagName).constructor);\n}\n\nfor (const tagName of Object.keys(typeMap)) {\n const attrs = typeMap[tagName]['properties'];\n for (const [k, v] of Object.entries(attrs)) {\n attrs[k] = STRING_TO_TYPE[v];\n }\n}\n\n/**\n * Map of type names to type checking function.\n * @type {!Object}\n */\nconst TYPE_CHECKER_MAP = {\n 'TrustedHTML': TrustedTypes.isHTML,\n 'TrustedURL': TrustedTypes.isURL,\n 'TrustedScriptURL': TrustedTypes.isScriptURL,\n 'TrustedScript': TrustedTypes.isScript,\n};\n\n/**\n * Map of type names to type producing function.\n * @type {Object}\n */\nconst TYPE_PRODUCER_MAP = {\n 'TrustedHTML': 'createHTML',\n 'TrustedURL': 'createURL',\n 'TrustedScriptURL': 'createScriptURL',\n 'TrustedScript': 'createScript',\n};\n\n/* eslint-disable no-unused-vars */\n/**\n * @typedef {TrustedTypePolicy}\n * @property {function(string):TrustedHTML} createHTML\n * @property {function(string):TrustedURL} createURL\n * @property {function(string):TrustedScriptURL} createScriptURL\n * @property {function(string):TrustedScript} createScript\n */\nconst TrustedTypePolicy = {};\n/* eslint-enable no-unused-vars */\n\n\n/**\n * An object for enabling trusted type enforcement.\n */\nexport class TrustedTypesEnforcer {\n /**\n * @param {!TrustedTypeConfig} config The configuration for\n * trusted type enforcement.\n */\n constructor(config) {\n /**\n * A configuration for the trusted type enforcement.\n * @private {!TrustedTypeConfig}\n */\n this.config_ = config;\n /**\n * @private {Object}\n */\n this.originalSetters_ = {};\n }\n\n /**\n * Wraps HTML sinks with an enforcement setter, which will enforce\n * trusted types and do logging, if enabled.\n *\n */\n install() {\n if (this.config_.allowedPolicyNames.includes('*')) {\n clearPolicyNameRestrictions();\n } else {\n setPolicyNameRestrictions(this.config_.allowedPolicyNames,\n this.config_.allowDuplicates);\n }\n\n if (!this.config_.isEnforcementEnabled && !this.config_.isLoggingEnabled) {\n return;\n }\n\n if ('ShadowRoot' in window) {\n this.wrapSetter_(ShadowRoot.prototype, 'innerHTML',\n TrustedTypes.TrustedHTML);\n }\n stringifyForRangeHack = (function(doc) {\n const r = doc.createRange();\n // In IE 11 Range.createContextualFragment doesn't stringify its argument.\n const f = r.createContextualFragment(/** @type {string} */ (\n {toString: () => '
'}));\n return f.childNodes.length == 0;\n })(document);\n\n this.wrapWithEnforceFunction_(Range.prototype, 'createContextualFragment',\n TrustedTypes.TrustedHTML, 0);\n\n this.wrapWithEnforceFunction_(insertAdjacentObject,\n 'insertAdjacentHTML',\n TrustedTypes.TrustedHTML, 1);\n\n if (getOwnPropertyDescriptor(Document.prototype, 'write')) {\n // Chrome\n this.wrapWithEnforceFunction_(Document.prototype, 'write',\n TrustedTypes.TrustedHTML, 0);\n this.wrapWithEnforceFunction_(Document.prototype, 'open',\n TrustedTypes.TrustedURL, 0);\n } else {\n // Firefox\n this.wrapWithEnforceFunction_(HTMLDocument.prototype, 'write',\n TrustedTypes.TrustedHTML, 0);\n this.wrapWithEnforceFunction_(HTMLDocument.prototype, 'open',\n TrustedTypes.TrustedURL, 0);\n }\n\n this.wrapWithEnforceFunction_(windowOpenObject, 'open',\n TrustedTypes.TrustedURL, 0);\n\n if ('DOMParser' in window) {\n this.wrapWithEnforceFunction_(DOMParser.prototype, 'parseFromString',\n TrustedTypes.TrustedHTML, 0);\n }\n this.wrapWithEnforceFunction_(window, 'setInterval',\n TrustedTypes.TrustedScript, 0);\n this.wrapWithEnforceFunction_(window, 'setTimeout',\n TrustedTypes.TrustedScript, 0);\n this.wrapSetAttribute_();\n this.installScriptMutatorGuards_();\n this.installPropertySetWrappers_();\n }\n\n /**\n * Removes the original setters.\n */\n uninstall() {\n clearPolicyNameRestrictions();\n\n if (!this.config_.isEnforcementEnabled && !this.config_.isLoggingEnabled) {\n return;\n }\n\n if ('ShadowRoot' in window) {\n this.restoreSetter_(ShadowRoot.prototype, 'innerHTML');\n }\n this.restoreFunction_(Range.prototype, 'createContextualFragment');\n this.restoreFunction_(insertAdjacentObject, 'insertAdjacentHTML');\n this.restoreFunction_(Element.prototype, 'setAttribute');\n this.restoreFunction_(Element.prototype, 'setAttributeNS');\n\n if (getOwnPropertyDescriptor(Document.prototype, 'write')) {\n this.restoreFunction_(Document.prototype, 'write');\n this.restoreFunction_(Document.prototype, 'open');\n } else {\n this.restoreFunction_(HTMLDocument.prototype, 'write');\n this.restoreFunction_(HTMLDocument.prototype, 'open');\n }\n this.restoreFunction_(windowOpenObject, 'open');\n\n if ('DOMParser' in window) {\n this.restoreFunction_(DOMParser.prototype, 'parseFromString');\n }\n this.restoreFunction_(window, 'setTimeout');\n this.restoreFunction_(window, 'setInterval');\n this.uninstallPropertySetWrappers_();\n this.uninstallScriptMutatorGuards_();\n resetDefaultPolicy();\n }\n\n /**\n * Installs type-enforcing wrappers for APIs that allow to modify\n * script element texts.\n * @private\n */\n installScriptMutatorGuards_() {\n const that = this;\n\n ['appendChild', 'insertBefore', 'replaceChild'].forEach((fnName) => {\n this.wrapFunction_(\n Node.prototype,\n fnName,\n /**\n * @this {Node}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.enforceTypeInScriptNodes_\n .bind(that, this, /* checkParent */ false, originalFn)\n .apply(that, args);\n });\n });\n this.wrapFunction_(\n insertAdjacentObject,\n 'insertAdjacentText',\n /**\n * @this {Element}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.insertAdjacentTextWrapper_\n .bind(that, this, originalFn)\n .apply(that, args);\n });\n\n if ('after' in Element.prototype) {\n ['after', 'before', 'replaceWith'].forEach((fnName) => {\n this.wrapFunction_(\n Element.prototype,\n fnName,\n /**\n * @this {Element}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.enforceTypeInScriptNodes_\n .bind(that, this, /* checkParent */ true, originalFn)\n .apply(that, args);\n });\n });\n ['append', 'prepend'].forEach((fnName) => {\n this.wrapFunction_(\n Element.prototype,\n fnName,\n /**\n * @this {Element}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.enforceTypeInScriptNodes_\n .bind(that, this, /* checkParent */ false, originalFn)\n .apply(that, args);\n });\n });\n }\n }\n\n /**\n * Uninstalls type-enforcing wrappers for APIs that allow to modify\n * script element texts.\n * @private\n */\n uninstallScriptMutatorGuards_() {\n this.restoreFunction_(Node.prototype, 'appendChild');\n this.restoreFunction_(Node.prototype, 'insertBefore');\n this.restoreFunction_(Node.prototype, 'replaceChild');\n this.restoreFunction_(insertAdjacentObject, 'insertAdjacentText');\n if ('after' in Element.prototype) {\n ['after', 'before', 'replaceWith', 'append', 'prepend'].forEach(\n (fnName) => this.restoreFunction_(Element.prototype, fnName));\n }\n }\n\n /**\n * Installs wrappers for directly setting properties\n * based on the type map.\n * @private\n */\n installPropertySetWrappers_() {\n /* eslint-disable guard-for-in */\n for (const tag of getOwnPropertyNames(typeMap)) {\n for (const property of getOwnPropertyNames(typeMap[tag]['properties'])) {\n this.wrapSetter_(\n window[convertTagToConstructor(tag)].prototype,\n property,\n typeMap[tag]['properties'][property]);\n }\n }\n }\n\n /**\n * Uninstalls wrappers for directly setting properties\n * based on the type map.\n * @private\n */\n uninstallPropertySetWrappers_() {\n /* eslint-disable guard-for-in */\n for (const tag of getOwnPropertyNames(typeMap)) {\n for (const property of getOwnPropertyNames(typeMap[tag]['properties'])) {\n this.restoreSetter_(\n window[convertTagToConstructor(tag)].prototype,\n property);\n }\n }\n }\n\n /** Wraps set attribute with an enforcement function. */\n wrapSetAttribute_() {\n const that = this;\n this.wrapFunction_(\n Element.prototype,\n 'setAttribute',\n /**\n * @this {TrustedTypesEnforcer}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.setAttributeWrapper_\n .bind(that, this, originalFn)\n .apply(that, args);\n });\n this.wrapFunction_(\n Element.prototype,\n 'setAttributeNS',\n /**\n * @this {TrustedTypesEnforcer}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.setAttributeNSWrapper_\n .bind(that, this, originalFn)\n .apply(that, args);\n });\n }\n\n /**\n * Enforces type checking for Element.prototype.setAttribute.\n * @param {!Object} context The context for the call to the original function.\n * @param {!Function} originalFn The original setAttribute function.\n * @return {*}\n */\n setAttributeWrapper_(context, originalFn, ...args) {\n // Note(slekies): In a normal application constructor should never be null.\n // However, there are no guarantees. If the constructor is null, we cannot\n // determine whether a special type is required. In order to not break the\n // application, we will not do any further type checks and pass the call\n // to setAttribute.\n if (context.constructor !== null && context instanceof Element) {\n const attrName = (args[0] = String(args[0])).toLowerCase();\n const requiredType = TrustedTypes.getAttributeType(context.tagName,\n attrName, context.namespaceURI);\n if (requiredType && apply(hasOwnProperty, STRING_TO_TYPE,\n [requiredType])) {\n return this.enforce_(\n context, 'setAttribute', STRING_TO_TYPE[requiredType],\n originalFn, 1, args);\n }\n }\n return apply(originalFn, context, args);\n }\n\n /**\n * Enforces type checking for Element.prototype.setAttributeNS.\n * @param {!Object} context The context for the call to the original function.\n * @param {!Function} originalFn The original setAttributeNS function.\n * @return {*}\n */\n setAttributeNSWrapper_(context, originalFn, ...args) {\n // See the note from setAttributeWrapper_ above.\n if (context.constructor !== null && context instanceof Element) {\n const ns = args[0] ? String(args[0]) : null;\n args[0] = ns;\n const attrName = (args[1] = String(args[1])).toLowerCase();\n const requiredType = TrustedTypes.getAttributeType(context.tagName,\n attrName, context.namespaceURI, ns);\n if (requiredType && apply(hasOwnProperty, STRING_TO_TYPE,\n [requiredType])) {\n return this.enforce_(context, 'setAttributeNS',\n STRING_TO_TYPE[requiredType],\n originalFn, 2, args);\n }\n }\n return apply(originalFn, context, args);\n }\n\n /**\n * Wrapper for DOM mutator functions that enforces type checks if the context\n * (or, optionally, its parent node) is a script node.\n * For each argument, it will make sure that text nodes pass through a\n * default policy, or generate a violation. To skip that check, pass\n * TrustedScript objects instead.\n * @param {!Element|!Node} context The context for the call to the original\n * function.\n * @param {boolean} checkParent Check parent of context instead.\n * @param {!Function} originalFn The original mutator function.\n * @return {*}\n */\n enforceTypeInScriptNodes_(context, checkParent, originalFn, ...args) {\n const objToCheck = checkParent ? context.parentNode : context;\n if (objToCheck instanceof HTMLScriptElement && args.length > 0) {\n for (let argNumber = 0; argNumber < args.length; argNumber++) {\n let arg = args[argNumber];\n if (arg instanceof Node && arg.nodeType !== Node.TEXT_NODE) {\n continue; // Type is not interesting\n }\n if (arg instanceof Node && arg.nodeType == Node.TEXT_NODE) {\n arg = arg.textContent;\n } else if (TrustedTypes.isScript(arg)) {\n // TODO(koto): Consider removing this branch, as it's hard to spec.\n // Convert to text node and go on.\n args[argNumber] = document.createTextNode('' + arg);\n continue;\n }\n\n // Try to run a default policy on argsthe argument\n const fallbackValue = this.maybeCallDefaultPolicy_(\n 'TrustedScript', '' + arg, 'script.text');\n if (fallbackValue === null || fallbackValue === undefined) {\n this.processViolation_(context, originalFn.name,\n TrustedTypes.TrustedScript, arg);\n } else {\n arg = fallbackValue;\n }\n args[argNumber] = document.createTextNode('' + arg);\n }\n }\n return apply(originalFn, context, args);\n }\n\n /**\n * Wrapper for Element.insertAdjacentText that enforces type checks for\n * inserting text into a script node.\n * @param {!Object} context The context for the call to the original function.\n * @param {!Function} originalFn The original insertAdjacentText function.\n */\n insertAdjacentTextWrapper_(context, originalFn, ...args) {\n const riskyPositions = ['beforebegin', 'afterend'];\n if (context instanceof Element &&\n context.parentElement instanceof HTMLScriptElement &&\n args.length > 1 &&\n riskyPositions.includes(args[0]) &&\n !(TrustedTypes.isScript(args[1]))) {\n // Run a default policy on args[1]\n args[1] = '' + args[1];\n const fallbackValue = this.maybeCallDefaultPolicy_('TrustedScript',\n args[1], 'script.text');\n if (fallbackValue === null || fallbackValue === undefined) {\n this.processViolation_(context, 'insertAdjacentText',\n TrustedTypes.TrustedScript, args[1]);\n } else {\n args[1] = fallbackValue;\n }\n\n const textNode = document.createTextNode('' + args[1]);\n\n\n const insertBefore = /** @type function(this: Node) */(\n this.originalSetters_[this.getKey_(Node.prototype, 'insertBefore')]);\n\n switch (args[0]) {\n case riskyPositions[0]: // 'beforebegin'\n apply(insertBefore, context.parentElement,\n [textNode, context]);\n break;\n case riskyPositions[1]: // 'afterend'\n apply(insertBefore, context.parentElement,\n [textNode, context.nextSibling]);\n break;\n }\n return;\n }\n apply(originalFn, context, args);\n }\n\n /**\n * Wraps a setter with the enforcement wrapper.\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @param {!Function} type The type to enforce.\n * @param {number} argNumber Number of the argument to enforce the type of.\n * @private\n */\n wrapWithEnforceFunction_(object, name, type, argNumber) {\n const that = this;\n this.wrapFunction_(\n object,\n name,\n /**\n * @this {TrustedTypesEnforcer}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.enforce_.call(that, this, name, type, originalFn,\n argNumber, args);\n });\n }\n\n\n /**\n * Wraps an existing function with a given function body and stores the\n * original function.\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @param {function(!Function, ...*)} functionBody The wrapper function.\n */\n wrapFunction_(object, name, functionBody) {\n const descriptor = getOwnPropertyDescriptor(object, name);\n const originalFn = /** @type function(*):* */ (\n descriptor ? descriptor.value : null);\n\n if (!(originalFn instanceof Function)) {\n throw new TypeError(\n 'Property ' + name + ' on object' + object + ' is not a function');\n }\n\n const key = this.getKey_(object, name);\n if (this.originalSetters_[key]) {\n throw new Error(\n `TrustedTypesEnforcer: Double installation detected: ${key} ${name}`);\n }\n installFunction(\n object,\n name,\n /**\n * @this {TrustedTypesEnforcer}\n * @return {*}\n */\n function(...args) {\n return functionBody.bind(this, originalFn).apply(this, args);\n });\n this.originalSetters_[key] = originalFn;\n }\n\n /**\n * Wraps a setter with the enforcement wrapper.\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @param {!Function} type The type to enforce.\n * @param {!Object=} descriptorObject If present, will reuse the\n * setter/getter from this one, instead of object. Used for redefining\n * setters in subclasses.\n * @private\n */\n wrapSetter_(object, name, type, descriptorObject = undefined) {\n if (descriptorObject && !isPrototypeOf.call(descriptorObject, object)) {\n throw new Error('Invalid prototype chain');\n }\n\n let useObject = descriptorObject || object;\n let descriptor;\n let originalSetter;\n const stopAt = getPrototypeOf(Node.prototype);\n\n // Find the descriptor on the object or its prototypes, stopping at Node.\n do {\n descriptor = getOwnPropertyDescriptor(useObject, name);\n originalSetter = /** @type {function(*):*} */ (descriptor ?\n descriptor.set : null);\n if (!originalSetter) {\n useObject = getPrototypeOf(useObject) || stopAt;\n }\n } while (!(originalSetter || useObject === stopAt || !useObject));\n\n if (!(originalSetter instanceof Function)) {\n throw new TypeError(\n 'No setter for property ' + name + ' on object' + object);\n }\n\n const key = this.getKey_(object, name);\n if (this.originalSetters_[key]) {\n throw new Error(\n `TrustedTypesEnforcer: Double installation detected: ${key} ${name}`);\n }\n const that = this;\n /**\n * @this {TrustedTypesEnforcer}\n * @param {*} value\n */\n const enforcingSetter = function(value) {\n that.enforce_.call(that, this, name, type, originalSetter, 0,\n [value]);\n };\n\n if (useObject === object) {\n installSetter(\n object,\n name,\n enforcingSetter);\n } else {\n // Since we're creating a new setter in subclass, we also need to\n // overwrite the getter.\n installSetterAndGetter(\n object,\n name,\n enforcingSetter,\n descriptor.get\n );\n }\n this.originalSetters_[key] = originalSetter;\n }\n\n /**\n * Restores the original setter for the property, as encountered during\n * install().\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @param {!Object=} descriptorObject If present, will restore the original\n * setter/getter from this one, instead of object.\n * @private\n */\n restoreSetter_(object, name, descriptorObject = undefined) {\n const key = this.getKey_(object, name);\n if (descriptorObject && !isPrototypeOf.call(descriptorObject, object)) {\n throw new Error('Invalid prototype chain');\n }\n if (!this.originalSetters_[key]) {\n throw new Error(\n // eslint-disable-next-line max-len\n `TrustedTypesEnforcer: Cannot restore (double uninstallation?): ${key} ${name}`);\n }\n if (descriptorObject) {\n // We have to also overwrite a getter.\n installSetterAndGetter(object, name, this.originalSetters_[key],\n getOwnPropertyDescriptor(descriptorObject, name).get);\n } else {\n installSetter(object, name, this.originalSetters_[key]);\n }\n delete this.originalSetters_[key];\n }\n\n /**\n * Restores the original method of an object, as encountered during install().\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @private\n */\n restoreFunction_(object, name) {\n const key = this.getKey_(object, name);\n if (!this.originalSetters_[key]) {\n throw new Error(\n // eslint-disable-next-line max-len\n `TrustedTypesEnforcer: Cannot restore (double uninstallation?): ${key} ${name}`);\n }\n installFunction(object, name, this.originalSetters_[key]);\n delete this.originalSetters_[key];\n }\n\n /**\n * Returns the key name for caching original setters.\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @return {string} Key name.\n * @private\n */\n getKey_(object, name) {\n // TODO(msamuel): Can we use Object.prototype.toString.call(object)\n // to get an unspoofable string here?\n // TODO(msamuel): fail on '-' in object.constructor.name?\n // No Function.name in IE 11\n const ctrName = '' + (\n object.constructor.name ?\n object.constructor.name :\n object.constructor);\n return ctrName + '-' + name;\n }\n\n /**\n * Calls a default policy.\n * @param {string} typeName Type name to attempt to produce from a value.\n * @param {*} value The value to pass to a default policy\n * @param {string} sink The sink name that the default policy will be called\n * with.\n * @throws {Error} If the default policy throws, or not exist.\n * @return {Function?} The trusted value or null, if the input value shoudl\n * be rejected.\n */\n maybeCallDefaultPolicy_(typeName, value, sink = '') {\n // Apply a fallback policy, if it exists.\n const fallbackPolicy = TrustedTypes['defaultPolicy'];\n if (!fallbackPolicy) {\n return null;\n }\n if (!TYPE_CHECKER_MAP.hasOwnProperty(typeName)) {\n return null;\n }\n return fallbackPolicy[TYPE_PRODUCER_MAP[typeName]](value, '' + sink);\n }\n\n /**\n * Logs and enforces TrustedTypes depending on the given configuration.\n * @template T\n * @param {!Object} context The object that the setter is called for.\n * @param {string} propertyName The name of the property.\n * @param {!Function} typeToEnforce The type to enforce.\n * @param {function(?):T} originalSetter Original setter.\n * @param {number} argNumber Number of argument to enforce the type of.\n * @param {Array} args Arguments.\n * @return {T}\n * @private\n */\n enforce_(context, propertyName, typeToEnforce, originalSetter, argNumber,\n args) {\n const value = args[argNumber];\n const typeName = '' + typeToEnforce.name;\n // If typed value is given, pass through.\n if (TYPE_CHECKER_MAP.hasOwnProperty(typeName) &&\n TYPE_CHECKER_MAP[typeName](value)) {\n if (stringifyForRangeHack &&\n propertyName == 'createContextualFragment') {\n // IE 11 hack, somehow the value is not stringified implicitly.\n args[argNumber] = args[argNumber].toString();\n }\n return apply(originalSetter, context, args);\n }\n\n if (typeToEnforce === TrustedTypes.TrustedScript) {\n const isInlineEventHandler =\n propertyName == 'setAttribute' ||\n propertyName === 'setAttributeNS' ||\n apply(slice, propertyName, [0, 2]) === 'on';\n // If a function (instead of string) is passed to inline event attribute,\n // or set(Timeout|Interval), pass through.\n const propertyAcceptsFunctions =\n propertyName === 'setInterval' ||\n propertyName === 'setTimeout' ||\n isInlineEventHandler;\n if ((propertyAcceptsFunctions && typeof value === 'function') ||\n (isInlineEventHandler && value === null)) {\n return apply(originalSetter, context, args);\n }\n }\n\n // Apply a fallback policy, if it exists.\n args[argNumber] = '' + value;\n const objName = context instanceof Element ?\n context.localName :\n getConstructorName_(context ? context.constructor : window.constructor);\n const fallbackValue = this.maybeCallDefaultPolicy_(\n typeName, value, objName + '.' + propertyName);\n if (fallbackValue === null || fallbackValue === undefined) {\n // This will throw a TypeError if enforcement is enabled.\n this.processViolation_(context, propertyName, typeToEnforce, value);\n } else {\n // Use the value modified by the default policy.\n args[argNumber] = fallbackValue;\n }\n return apply(originalSetter, context, args);\n }\n\n /**\n * Report a TT violation.\n * @param {!Object} context The object that the setter is called for.\n * @param {string} propertyName The name of the property.\n * @param {!Function} typeToEnforce The type to enforce.\n * @param {string} value The value that was violated the restrictions.\n * @throws {TypeError} if the enforcement is enabled.\n */\n processViolation_(context, propertyName, typeToEnforce, value) {\n const contextName = getConstructorName_(context.constructor) ||\n '' + context;\n const message = `Failed to set ${propertyName} on ${contextName}: `\n + `This property requires ${typeToEnforce.name}.`;\n\n if (this.config_.isLoggingEnabled) {\n // eslint-disable-next-line no-console\n console.warn(message, propertyName, context, typeToEnforce, value);\n }\n\n // Unconditionally dispatch an event.\n if (typeof SecurityPolicyViolationEvent == 'function') {\n let blockedURI = '';\n if (typeToEnforce === TrustedTypes.TrustedURL ||\n typeToEnforce === TrustedTypes.TrustedScriptURL) {\n blockedURI = parseUrl_(value) || '';\n if (blockedURI) {\n blockedURI = blockedURI.href;\n }\n }\n const valueSlice = apply(slice, '' + value, [0, 40]);\n const event = new SecurityPolicyViolationEvent(\n 'securitypolicyviolation',\n {\n 'bubbles': true,\n 'blockedURI': blockedURI,\n 'disposition': this.config_.isEnforcementEnabled ?\n 'enforce' : 'report',\n 'documentURI': document.location.href,\n 'effectiveDirective': ENFORCEMENT_DIRECTIVE_NAME,\n 'originalPolicy': this.config_.cspString,\n 'statusCode': 0,\n 'violatedDirective': ENFORCEMENT_DIRECTIVE_NAME,\n 'sample': `${contextName}.${propertyName} ${valueSlice}`,\n });\n if (context instanceof Node && context.isConnected) {\n context.dispatchEvent(event);\n } else { // Fallback - dispatch an event on base document.\n document.dispatchEvent(event);\n }\n }\n\n if (this.config_.isEnforcementEnabled) {\n throw new TypeError(message);\n }\n }\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n/**\n * @fileoverview Entry point for a polyfill that only defines the types\n * (i.e. no enforcement logic).\n */\nimport {trustedTypes, TrustedTypePolicy, TrustedTypePolicyFactory} from\n '../trustedtypes.js';\n\nconst tt = trustedTypes;\n\n/**\n * Sets up the public Trusted Types API in the global object.\n */\nfunction setupPolyfill() {\n // We use array accessors to make sure Closure compiler will not alter the\n // names of the properties..\n\n // we setup the polyfill only in browser environment.\n if (typeof window === 'undefined') {\n return;\n }\n const rootProperty = 'trustedTypes';\n\n // Convert old window.TrustedTypes to window.trustedTypes.\n if (window['TrustedTypes'] && typeof window[rootProperty] === 'undefined') {\n window[rootProperty] = Object.freeze(window['TrustedTypes']);\n }\n\n if (typeof window[rootProperty] !== 'undefined') {\n return;\n }\n\n const publicApi = Object.create(TrustedTypePolicyFactory.prototype);\n Object.assign(publicApi, {\n 'isHTML': tt.isHTML,\n 'isURL': tt.isURL,\n 'isScriptURL': tt.isScriptURL,\n 'isScript': tt.isScript,\n 'createPolicy': tt.createPolicy,\n 'getAttributeType': tt.getAttributeType,\n 'getPropertyType': tt.getPropertyType,\n 'getTypeMapping': tt.getTypeMapping,\n 'emptyHTML': tt.emptyHTML,\n 'emptyScript': tt.emptyScript,\n '_isPolyfill_': true,\n });\n Object.defineProperty(\n publicApi,\n 'defaultPolicy',\n Object.getOwnPropertyDescriptor(tt, 'defaultPolicy') || {});\n\n window[rootProperty] = Object.freeze(publicApi);\n\n window['TrustedHTML'] = tt.TrustedHTML;\n window['TrustedURL'] = tt.TrustedURL;\n window['TrustedScriptURL'] = tt.TrustedScriptURL;\n window['TrustedScript'] = tt.TrustedScript;\n window['TrustedTypePolicy'] = TrustedTypePolicy;\n window['TrustedTypePolicyFactory'] = TrustedTypePolicyFactory;\n}\n\nsetupPolyfill();\n\nexport default tt;\n"]} \ No newline at end of file diff --git a/dist/es6/trustedtypes.api_only.build.js b/dist/es6/trustedtypes.api_only.build.js index 03c74c73..a5b8299e 100644 --- a/dist/es6/trustedtypes.api_only.build.js +++ b/dist/es6/trustedtypes.api_only.build.js @@ -8,15 +8,15 @@ */ 'use strict';const e="onabort onactivate onactivateinvisible onafterprint onafterupdate onanimationcancel onanimationend onanimationiteration onanimationstart onariarequest onauxclick onbeforeactivate onbeforecopy onbeforecut onbeforedeactivate onbeforeeditfocus onbeforepaste onbeforeprint onbeforeunload onbegin onblur onbounce oncancel oncanplay oncanplaythrough oncellchange onchange onclick onclose oncommand oncontextmenu oncontrolselect oncopy oncuechange oncut ondataavailable ondatasetchanged ondatasetcomplete ondblclick ondeactivate ondrag ondragdrop ondragend ondragenter ondragexit ondragleave ondragover ondragstart ondrop ondurationchange onemptied onend onended onerror onerrorupdate onexit onfilterchange onfinish onfocus onfocusin onfocusout onformdata onfullscreenchange onfullscreenerror ongotpointercapture onhelp oninput oninvalid onkeydown onkeypress onkeyup onlayoutcomplete onload onloadeddata onloadedmetadata onloadend onloadstart onlosecapture onlostpointercapture onmediacomplete onmediaerror onmessage onmousedown onmouseenter onmouseleave onmousemove onmouseout onmouseover onmouseup onmousewheel onmove onmoveend onmovestart onmozfullscreenchange onmozfullscreenerror onmscontentzoom onmsgesturechange onmsgesturedoubletap onmsgestureend onmsgesturehold onmsgesturestart onmsgesturetap onmsgotpointercapture onmsinertiastart onmslostpointercapture onmsmanipulationstatechanged onmspointercancel onmspointerdown onmspointerenter onmspointerleave onmspointermove onmspointerout onmspointerover onmspointerup onoffline ononline onoutofsync onoverscroll onpaste onpause onplay onplaying onpointercancel onpointerdown onpointerenter onpointerleave onpointermove onpointerout onpointerover onpointerrawupdate onpointerup onprogress onpropertychange onratechange onreadystatechange onrepeat onreset onresize onresizeend onresizestart onresume onreverse onrowdelete onrowenter onrowexit onrowinserted onscroll onscrollend onsearch onseek onseeked onseeking onselect onselectionchange onselectstart onshow onstalled onstart onstop onstorage onsubmit onsuspend onsynchrestored ontimeerror ontimeupdate ontoggle ontrackchange ontransitioncancel ontransitionend ontransitionrun ontransitionstart onunload onurlflip onvolumechange onwaiting onwebkitanimationend onwebkitanimationiteration onwebkitanimationstart onwebkitfullscreenchange onwebkitfullscreenerror onwebkittransitionend onwheel".split(" "); function G(){if("undefined"!==typeof window){const m=[];for(const t in HTMLElement.prototype)"on"===t.slice(0,2)&&m.push(t);return m}return e};const L="undefined"!==typeof window,M=()=>{throw new TypeError("undefined conversion");},U=()=>null,{toLowerCase:V,toUpperCase:aa}=String.prototype;function W(){throw new TypeError("Illegal constructor");}function X(){throw new TypeError("Illegal constructor");} -const {m:Y}=function(){function m(a){let b=H.get(a);void 0===b&&(b=r(null),H.set(a,b));return b}function t(a){const b=N(a);if(null==b||N(b)!==O)throw Error();for(const d of I(b))w(a,d,{value:a[d]});return a}function x(a,b){h(a.prototype);delete a.name;w(a,"name",{value:b})}function B(a){return b=>b instanceof a&&H.has(b)}function ba(a,b){function d(n,J){const ca=b[J]||("default"==a?U:M),da=h(new n(C,a));return h({[J](k,...D){k=ca(""+k,...D);if(void 0===k||null===k){if("default"==a)return k;k=""}k= -""+k;D=h(r(da));m(D).v=k;return D}}[J])}const c=r(W.prototype);for(const n of I(E))c[n]=d(E[n],n);w(c,"name",{value:a,writable:!1,configurable:!1,enumerable:!0});return h(c)}function P(a,b,d,c="",n=""){a=aa.apply(String(a));(c=n?n:c)||(c="http://www.w3.org/1999/xhtml");if(c=y.apply(g,[c])?g[c]:null){if(y.apply(c,[a])&&c[a]&&y.apply(c[a][b],[d])&&c[a][b][d])return c[a][b][d];if(y.apply(c,["*"])&&y.apply(c["*"][b],[d])&&c["*"][b][d])return c["*"][b][d]}}function Q(){return z}const {assign:ea,create:r, -defineProperty:w,freeze:h,getOwnPropertyNames:I,getPrototypeOf:N,prototype:O}=Object,{hasOwnProperty:y}=O,{forEach:fa,push:ha}=Array.prototype,C=Symbol(),H=t(new WeakMap),u=t([]),K=t([]);let R=!0,z=null,F=!1;class A{constructor(a,b){if(a!==C)throw Error("cannot call the constructor");w(this,"policyName",{value:b,enumerable:!0})}toString(){return m(this).v}valueOf(){return m(this).v}}class f extends A{}x(f,"TrustedURL");class p extends A{}x(p,"TrustedScriptURL");class q extends A{}x(q,"TrustedHTML"); -class l extends A{}x(l,"TrustedScript");x(A,"TrustedType");const S=h(r(new q(C,"")));m(S).v="";const T=h(r(new l(C,"")));m(T).v="";const g={["http://www.w3.org/1999/xhtml"]:{A:{attributes:{href:f.name}},AREA:{attributes:{href:f.name}},BASE:{attributes:{href:f.name}},BUTTON:{attributes:{formaction:f.name}},EMBED:{attributes:{src:p.name}},FORM:{attributes:{action:f.name}},FRAME:{attributes:{src:f.name}},IFRAME:{attributes:{src:f.name,srcdoc:q.name}},INPUT:{attributes:{formaction:f.name}},OBJECT:{attributes:{data:p.name, -codebase:p.name}},SCRIPT:{attributes:{src:p.name,text:l.name},properties:{innerText:l.name,textContent:l.name,text:l.name}},"*":{attributes:{},properties:{innerHTML:q.name,outerHTML:q.name}}},["http://www.w3.org/1999/xlink"]:{"*":{attributes:{href:f.name},properties:{}}},["http://www.w3.org/2000/svg"]:{"*":{attributes:{href:f.name},properties:{}}}};var v={codebase:"codeBase",formaction:"formAction"};!L||"srcdoc"in HTMLIFrameElement.prototype||delete g["http://www.w3.org/1999/xhtml"].IFRAME.attributes.srcdoc; -for(const a of Object.keys(g["http://www.w3.org/1999/xhtml"])){g["http://www.w3.org/1999/xhtml"][a].properties||(g["http://www.w3.org/1999/xhtml"][a].properties={});for(const b of Object.keys(g["http://www.w3.org/1999/xhtml"][a].attributes))g["http://www.w3.org/1999/xhtml"][a].properties[v[b]?v[b]:b]=g["http://www.w3.org/1999/xhtml"][a].attributes[b]}for(const a of G())g["http://www.w3.org/1999/xhtml"]["*"].attributes[a]="TrustedScript",g["http://www.w3.org/2000/svg"]["*"].attributes[a]="TrustedScript"; -const E={createHTML:q,createScriptURL:p,createURL:f,createScript:l},ia=E.hasOwnProperty;v=r(X.prototype);ea(v,{createPolicy:function(a,b){if(!a.match(/^[-#a-zA-Z0-9=_/@.%]+$/g))throw new TypeError("Policy "+a+" contains invalid characters.");if(F&&-1===K.indexOf(a))throw new TypeError("Policy "+a+" disallowed.");if("default"===a&&z)throw new TypeError("Policy "+a+" already exists.");if(F&&!R&&-1!==u.indexOf(a))throw new TypeError("Policy "+a+" exists.");u.push(a);const d=r(null);if(b&&"object"=== -typeof b)for(const c of I(b))ia.call(E,c)&&(d[c]=b[c]);else console.warn("trustedTypes.createPolicy "+a+" was given an empty policy");h(d);b=ba(a,d);"default"===a&&(z=b);return b},getPolicyNames:function(){return u.slice()},h:B(q),l:B(f),j:B(p),i:B(l),c:function(a,b,d="",c=""){b=V.apply(String(b));return P(a,"attributes",b,d,c)||null},f:function(a,b,d=""){return P(a,"properties",String(b),d)||null},g:function(a=""){if(!a)try{a=document.documentElement.namespaceURI}catch(b){a="http://www.w3.org/1999/xhtml"}return(a= -g[a])?JSON.parse(JSON.stringify(a)):{}},a:S,b:T,s:z,TrustedHTML:q,TrustedURL:f,TrustedScriptURL:p,TrustedScript:l});w(v,"defaultPolicy",{get:Q,set:()=>{}});return{m:h(v),B:function(a,b){F=!0;K.length=0;fa.call(a,d=>{ha.call(K,""+d)});R=b;u.length=0},o:function(){F=!1},u:Q,w:function(){z=null;u.splice(u.indexOf("default"),1)}}}();if("undefined"!==typeof window&&(window.TrustedTypes&&"undefined"===typeof window.trustedTypes&&(window.trustedTypes=Object.freeze(window.TrustedTypes)),"undefined"===typeof window.trustedTypes)){var Z=Object.create(X.prototype);Object.assign(Z,{isHTML:Y.h,isURL:Y.l,isScriptURL:Y.j,isScript:Y.i,createPolicy:Y.createPolicy,getPolicyNames:Y.getPolicyNames,getAttributeType:Y.c,getPropertyType:Y.f,getTypeMapping:Y.g,emptyHTML:Y.a,emptyScript:Y.b,_isPolyfill_:!0});Object.defineProperty(Z,"defaultPolicy", -Object.getOwnPropertyDescriptor(Y,"defaultPolicy")||{});window.trustedTypes=Object.freeze(Z);window.TrustedHTML=Y.TrustedHTML;window.TrustedURL=Y.TrustedURL;window.TrustedScriptURL=Y.TrustedScriptURL;window.TrustedScript=Y.TrustedScript;window.TrustedTypePolicy=W;window.TrustedTypePolicyFactory=X};}).call(this); +const {m:Y}=function(){function m(a){let b=H.get(a);void 0===b&&(b=r(null),H.set(a,b));return b}function t(a){const b=N(a);if(null==b||N(b)!==O)throw Error();for(const d of I(b))v(a,d,{value:a[d]});return a}function w(a,b){h(a.prototype);delete a.name;v(a,"name",{value:b})}function B(a){return b=>b instanceof a&&H.has(b)}function ba(a,b){function d(n,J){const ca=b[J]||("default"==a?U:M),da=h(new n(C,a));return h({[J](k,...D){k=ca(""+k,...D);if(void 0===k||null===k){if("default"==a)return k;k=""}k= +""+k;D=h(r(da));m(D).v=k;return D}}[J])}const c=r(W.prototype);for(const n of I(E))c[n]=d(E[n],n);v(c,"name",{value:a,writable:!1,configurable:!1,enumerable:!0});return h(c)}function P(a,b,d,c="",n=""){a=aa.apply(String(a));(c=n?n:c)||(c="http://www.w3.org/1999/xhtml");if(c=x.apply(g,[c])?g[c]:null){if(x.apply(c,[a])&&c[a]&&x.apply(c[a][b],[d])&&c[a][b][d])return c[a][b][d];if(x.apply(c,["*"])&&x.apply(c["*"][b],[d])&&c["*"][b][d])return c["*"][b][d]}}function Q(){return y}const {assign:ea,create:r, +defineProperty:v,freeze:h,getOwnPropertyNames:I,getPrototypeOf:N,prototype:O}=Object,{hasOwnProperty:x}=O,{forEach:fa,push:ha}=Array.prototype,C=Symbol(),H=t(new WeakMap),z=t([]),K=t([]);let R=!0,y=null,F=!1;class A{constructor(a,b){if(a!==C)throw Error("cannot call the constructor");v(this,"policyName",{value:b,enumerable:!0})}toString(){return m(this).v}valueOf(){return m(this).v}}class f extends A{}w(f,"TrustedURL");class p extends A{}w(p,"TrustedScriptURL");class q extends A{}w(q,"TrustedHTML"); +class l extends A{}w(l,"TrustedScript");w(A,"TrustedType");const S=h(r(new q(C,"")));m(S).v="";const T=h(r(new l(C,"")));m(T).v="";const g={["http://www.w3.org/1999/xhtml"]:{A:{attributes:{href:f.name}},AREA:{attributes:{href:f.name}},BASE:{attributes:{href:f.name}},BUTTON:{attributes:{formaction:f.name}},EMBED:{attributes:{src:p.name}},FORM:{attributes:{action:f.name}},FRAME:{attributes:{src:f.name}},IFRAME:{attributes:{src:f.name,srcdoc:q.name}},INPUT:{attributes:{formaction:f.name}},OBJECT:{attributes:{data:p.name, +codebase:p.name}},SCRIPT:{attributes:{src:p.name,text:l.name},properties:{innerText:l.name,textContent:l.name,text:l.name}},"*":{attributes:{},properties:{innerHTML:q.name,outerHTML:q.name}}},["http://www.w3.org/1999/xlink"]:{"*":{attributes:{href:f.name},properties:{}}},["http://www.w3.org/2000/svg"]:{"*":{attributes:{href:f.name},properties:{}}}};var u={codebase:"codeBase",formaction:"formAction"};!L||"srcdoc"in HTMLIFrameElement.prototype||delete g["http://www.w3.org/1999/xhtml"].IFRAME.attributes.srcdoc; +for(const a of Object.keys(g["http://www.w3.org/1999/xhtml"])){g["http://www.w3.org/1999/xhtml"][a].properties||(g["http://www.w3.org/1999/xhtml"][a].properties={});for(const b of Object.keys(g["http://www.w3.org/1999/xhtml"][a].attributes))g["http://www.w3.org/1999/xhtml"][a].properties[u[b]?u[b]:b]=g["http://www.w3.org/1999/xhtml"][a].attributes[b]}for(const a of G())g["http://www.w3.org/1999/xhtml"]["*"].attributes[a]="TrustedScript",g["http://www.w3.org/2000/svg"]["*"].attributes[a]="TrustedScript"; +const E={createHTML:q,createScriptURL:p,createURL:f,createScript:l},ia=E.hasOwnProperty;u=r(X.prototype);ea(u,{createPolicy:function(a,b){if(!a.match(/^[-#a-zA-Z0-9=_/@.%]+$/g))throw new TypeError("Policy "+a+" contains invalid characters.");if(F&&-1===K.indexOf(a))throw new TypeError("Policy "+a+" disallowed.");if("default"===a&&y)throw new TypeError("Policy "+a+" already exists.");if(F&&!R&&-1!==z.indexOf(a))throw new TypeError("Policy "+a+" exists.");z.push(a);const d=r(null);if(b&&"object"=== +typeof b)for(const c of I(b))ia.call(E,c)&&(d[c]=b[c]);else console.warn("trustedTypes.createPolicy "+a+" was given an empty policy");h(d);b=ba(a,d);"default"===a&&(y=b);return b},h:B(q),l:B(f),j:B(p),i:B(l),c:function(a,b,d="",c=""){b=V.apply(String(b));return P(a,"attributes",b,d,c)||null},f:function(a,b,d=""){return P(a,"properties",String(b),d)||null},g:function(a=""){if(!a)try{a=document.documentElement.namespaceURI}catch(b){a="http://www.w3.org/1999/xhtml"}return(a=g[a])?JSON.parse(JSON.stringify(a)): +{}},a:S,b:T,s:y,TrustedHTML:q,TrustedURL:f,TrustedScriptURL:p,TrustedScript:l});v(u,"defaultPolicy",{get:Q,set:()=>{}});return{m:h(u),B:function(a,b){F=!0;K.length=0;fa.call(a,d=>{ha.call(K,""+d)});R=b;z.length=0},o:function(){F=!1},u:Q,w:function(){y=null;z.splice(z.indexOf("default"),1)}}}();if("undefined"!==typeof window&&(window.TrustedTypes&&"undefined"===typeof window.trustedTypes&&(window.trustedTypes=Object.freeze(window.TrustedTypes)),"undefined"===typeof window.trustedTypes)){var Z=Object.create(X.prototype);Object.assign(Z,{isHTML:Y.h,isURL:Y.l,isScriptURL:Y.j,isScript:Y.i,createPolicy:Y.createPolicy,getAttributeType:Y.c,getPropertyType:Y.f,getTypeMapping:Y.g,emptyHTML:Y.a,emptyScript:Y.b,_isPolyfill_:!0});Object.defineProperty(Z,"defaultPolicy",Object.getOwnPropertyDescriptor(Y, +"defaultPolicy")||{});window.trustedTypes=Object.freeze(Z);window.TrustedHTML=Y.TrustedHTML;window.TrustedURL=Y.TrustedURL;window.TrustedScriptURL=Y.TrustedScriptURL;window.TrustedScript=Y.TrustedScript;window.TrustedTypePolicy=W;window.TrustedTypePolicyFactory=X};}).call(this); //# sourceMappingURL=trustedtypes.api_only.build.js.map diff --git a/dist/es6/trustedtypes.api_only.build.js.map b/dist/es6/trustedtypes.api_only.build.js.map index 0a4fefc0..ebef4b32 100644 --- a/dist/es6/trustedtypes.api_only.build.js.map +++ b/dist/es6/trustedtypes.api_only.build.js.map @@ -1 +1 @@ -{"version":3,"sources":["src/utils/eventHandlers.js","src/trustedtypes.js","src/polyfill/api_only.js"],"names":["unsafeAttributeEventHandlers","getUnsafeAttributeEventHandlers","window","eventHandlers","name","HTMLElement","prototype","slice","push","isBrowser","rejectInputFn","TypeError","rejectInputDefaultPolicyFn","toLowerCase","toUpperCase","String","TrustedTypePolicy","TrustedTypePolicyFactory","trustedTypes","trustedTypesBuilderTestOnly","privates","obj","v","privateMap","get","undefined","create","set","selfContained","collection","proto","getPrototypeOf","ObjectPrototype","Error","key","getOwnPropertyNames","defineProperty","value","lockdownTrustedType","SubClass","canonName","freeze","isTrustedTypeChecker","type","has","wrapPolicy","policyName","innerPolicy","creator","Ctor","methodName","method","DEFAULT_POLICY_NAME","policySpecificType","creatorSymbol","s","args","result","allowedValue","o","factory","policy","createTypeMapping","writable","configurable","enumerable","getTypeInternal_","tag","container","elNs","attrNs","canonicalTag","apply","ns","HTML_NS","map","hasOwnProperty","TYPE_MAP","getDefaultPolicy","defaultPolicy","assign","Object","forEach","Array","Symbol","WeakMap","policyNames","allowedNames","allowDuplicateNames","enforceNameRestrictions","TrustedType","TrustedURL","TrustedScriptURL","TrustedHTML","TrustedScript","emptyHTML","emptyScript","XLINK_NS","SVG_NS","ATTR_PROPERTY_MAP","HTMLIFrameElement","keys","attr","createFunctionAllowed","api","createPolicy","match","indexOf","call","console","warn","wrappedPolicy","getPolicyNames","isHTML","isURL","isScriptURL","isScript","getAttributeType","tagName","attribute","elementNs","attributeNs","canonicalAttr","getPropertyType","property","getTypeMapping","namespaceUri","document","documentElement","namespaceURI","e","JSON","parse","stringify","setPolicyNameRestrictions","allowedPolicyNames","allowDuplicates","length","el","clearPolicyNameRestrictions","resetDefaultPolicy","splice","publicApi","tt","getOwnPropertyDescriptor"],"mappings":"A;;;;;;;;aAUA,MAAMA,EAA+B,q1EAAA,MAAA,CAAA,GAAA,CAmM9BC;QAASA,EAA+B,EAAG,CAChD,GAAsB,WAAtB,GAAI,MAAOC,OAAX,CAAmC,CACjC,MAAMC,EAAgB,EACtB,KAAK,MAAMC,CAAX,GAAmBC,YAAAC,UAAnB,CAC2B,IAAzB,GAAIF,CAAAG,MAAA,CAAW,CAAX,CAAc,CAAd,CAAJ,EACEJ,CAAAK,KAAA,CAAmBJ,CAAnB,CAGJ,OAAOD,EAP0B,CASjC,MAAOH,EAVuC,C,CClMlD,MAAMS,EAA8B,WAA9BA,GAAY,MAAOP,OAAzB,CAEMQ,EAAgB,EAAAA,EAAO,CAC3B,KAAM,KAAIC,SAAJ,CAAc,sBAAd,CAAN,CAD2B,CAF7B,CAMMC,EAA6B,EAAAA,EAAO,IAN1C,CAQM,CAAC,YAAAC,CAAD,CAAc,YAAAC,EAAd,CAAA,CAA6BC,MAAAT,UAcFU,SAAA,EAAQ,EAAG,CAC1C,KAAM,KAAIL,SAAJ,CAAc,qBAAd,CAAN,CAD0C,CAOJM,QAAA,EAAQ,EAAG,CACjD,KAAM,KAAIN,SAAJ,CAAc,qB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UAAd,CAClB2E,OAAAD,OAAA,CAAc8D,CAAd,CAAyB,CACvB,OAAUC,CAAA9B,EADa,CAEvB,MAAS8B,CAAA7B,EAFc,CAGvB,YAAe6B,CAAA5B,EAHQ,CAIvB,SAAY4B,CAAA3B,EAJW,CAKvB,aAAgB2B,CAAAtC,aALO,CAMvB,eAAkBsC,CAAA/B,eANK,CAOvB,iBAAoB+B,CAAA1B,EAPG,CAQvB,gBAAmB0B,CAAApB,EARI,CASvB,eAAkBoB,CAAAlB,EATK,CAUvB,UAAakB,CAAAhD,EAVU,CAWvB,YAAegD,CAAA/C,EAXQ,CAYvB,aAAgB,CAAA,CAZO,CAAzB,CAcAf,OAAA7C,eAAA,CACI0G,CADJ,CAEI,eAFJ;AAGI7D,MAAA+D,yBAAA,CAAgCD,CAAhC,CAAoC,eAApC,CAHJ,EAG4D,EAH5D,CAKA7I,OAAA,aAAA,CAAuB+E,MAAAxC,OAAA,CAAcqG,CAAd,CAEvB5I,OAAA,YAAA,CAAwB6I,CAAAlD,YACxB3F,OAAA,WAAA,CAAuB6I,CAAApD,WACvBzF,OAAA,iBAAA,CAA6B6I,CAAAnD,iBAC7B1F,OAAA,cAAA,CAA0B6I,CAAAjD,cAC1B5F,OAAA,kBAAA,CAA8Bc,CAC9Bd,OAAA,yBAAA,CAAqCe,CA/BrC","file":"trustedtypes.api_only.build.js","sourcesContent":["/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n// TODO check attributes in safari, remove legacy safe handlers\nconst unsafeAttributeEventHandlers = [\n 'onabort',\n 'onactivate',\n 'onactivateinvisible',\n 'onafterprint',\n 'onafterupdate',\n 'onanimationcancel',\n 'onanimationend',\n 'onanimationiteration',\n 'onanimationstart',\n 'onariarequest',\n 'onauxclick',\n 'onbeforeactivate',\n 'onbeforecopy',\n 'onbeforecut',\n 'onbeforedeactivate',\n 'onbeforeeditfocus',\n 'onbeforepaste',\n 'onbeforeprint',\n 'onbeforeunload',\n 'onbegin',\n 'onblur',\n 'onbounce',\n 'oncancel',\n 'oncanplay',\n 'oncanplaythrough',\n 'oncellchange',\n 'onchange',\n 'onclick',\n 'onclose',\n 'oncommand',\n 'oncontextmenu',\n 'oncontrolselect',\n 'oncopy',\n 'oncuechange',\n 'oncut',\n 'ondataavailable',\n 'ondatasetchanged',\n 'ondatasetcomplete',\n 'ondblclick',\n 'ondeactivate',\n 'ondrag',\n 'ondragdrop',\n 'ondragend',\n 'ondragenter',\n 'ondragexit',\n 'ondragleave',\n 'ondragover',\n 'ondragstart',\n 'ondrop',\n 'ondurationchange',\n 'onemptied',\n 'onend',\n 'onended',\n 'onerror',\n 'onerrorupdate',\n 'onexit',\n 'onfilterchange',\n 'onfinish',\n 'onfocus',\n 'onfocusin',\n 'onfocusout',\n 'onformdata',\n 'onfullscreenchange',\n 'onfullscreenerror',\n 'ongotpointercapture',\n 'onhelp',\n 'oninput',\n 'oninvalid',\n 'onkeydown',\n 'onkeypress',\n 'onkeyup',\n 'onlayoutcomplete',\n 'onload',\n 'onloadeddata',\n 'onloadedmetadata',\n 'onloadend',\n 'onloadstart',\n 'onlosecapture',\n 'onlostpointercapture',\n 'onmediacomplete',\n 'onmediaerror',\n 'onmessage',\n 'onmousedown',\n 'onmouseenter',\n 'onmouseleave',\n 'onmousemove',\n 'onmouseout',\n 'onmouseover',\n 'onmouseup',\n 'onmousewheel',\n 'onmove',\n 'onmoveend',\n 'onmovestart',\n 'onmozfullscreenchange',\n 'onmozfullscreenerror',\n 'onmscontentzoom',\n 'onmsgesturechange',\n 'onmsgesturedoubletap',\n 'onmsgestureend',\n 'onmsgesturehold',\n 'onmsgesturestart',\n 'onmsgesturetap',\n 'onmsgotpointercapture',\n 'onmsinertiastart',\n 'onmslostpointercapture',\n 'onmsmanipulationstatechanged',\n 'onmspointercancel',\n 'onmspointerdown',\n 'onmspointerenter',\n 'onmspointerleave',\n 'onmspointermove',\n 'onmspointerout',\n 'onmspointerover',\n 'onmspointerup',\n 'onoffline',\n 'ononline',\n 'onoutofsync',\n 'onoverscroll',\n 'onpaste',\n 'onpause',\n 'onplay',\n 'onplaying',\n 'onpointercancel',\n 'onpointerdown',\n 'onpointerenter',\n 'onpointerleave',\n 'onpointermove',\n 'onpointerout',\n 'onpointerover',\n 'onpointerrawupdate',\n 'onpointerup',\n 'onprogress',\n 'onpropertychange',\n 'onratechange',\n 'onreadystatechange',\n 'onrepeat',\n 'onreset',\n 'onresize',\n 'onresizeend',\n 'onresizestart',\n 'onresume',\n 'onreverse',\n 'onrowdelete',\n 'onrowenter',\n 'onrowexit',\n 'onrowinserted',\n 'onscroll',\n 'onscrollend',\n 'onsearch',\n 'onseek',\n 'onseeked',\n 'onseeking',\n 'onselect',\n 'onselectionchange',\n 'onselectstart',\n 'onshow',\n 'onstalled',\n 'onstart',\n 'onstop',\n 'onstorage',\n 'onsubmit',\n 'onsuspend',\n 'onsynchrestored',\n 'ontimeerror',\n 'ontimeupdate',\n 'ontoggle',\n 'ontrackchange',\n 'ontransitioncancel',\n 'ontransitionend',\n 'ontransitionrun',\n 'ontransitionstart',\n 'onunload',\n 'onurlflip',\n 'onvolumechange',\n 'onwaiting',\n 'onwebkitanimationend',\n 'onwebkitanimationiteration',\n 'onwebkitanimationstart',\n 'onwebkitfullscreenchange',\n 'onwebkitfullscreenerror',\n 'onwebkittransitionend',\n 'onwheel',\n];\n\n/**\n * Returns an array of all event handlers. Some of the event handlers may be\n * supported only in some browsers.\n *\n * For every event type that the browser supports, SVG supports that as an event\n * attribute, following the same requirements as for HTML event attributes.\n * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/Events\n *\n * @return {!Array}\n */\nexport function getUnsafeAttributeEventHandlers() {\n if (typeof window !== 'undefined') {\n const eventHandlers = [];\n for (const name in HTMLElement.prototype) {\n if (name.slice(0, 2) === 'on') {\n eventHandlers.push(name);\n }\n }\n return eventHandlers;\n } else {\n return unsafeAttributeEventHandlers;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\nimport {getUnsafeAttributeEventHandlers} from './utils/eventHandlers.js';\n\nconst isBrowser = typeof window !== 'undefined';\n\nconst rejectInputFn = (s) => {\n throw new TypeError('undefined conversion');\n};\n\nconst rejectInputDefaultPolicyFn = (s) => null;\n\nconst {toLowerCase, toUpperCase} = String.prototype;\n\nexport const HTML_NS = 'http://www.w3.org/1999/xhtml';\nexport const XLINK_NS = 'http://www.w3.org/1999/xlink';\nexport const SVG_NS = 'http://www.w3.org/2000/svg';\n\n/**\n * @constructor\n * @property {!function(string):TrustedHTML} createHTML\n * @property {!function(string):TrustedURL} createURL\n * @property {!function(string):TrustedScriptURL} createScriptURL\n * @property {!function(string):TrustedScript} createScript\n * @property {!string} name\n */\nexport const TrustedTypePolicy = function() {\n throw new TypeError('Illegal constructor');\n};\n\n/**\n * @constructor\n */\nexport const TrustedTypePolicyFactory = function() {\n throw new TypeError('Illegal constructor');\n};\n\n/* eslint-disable no-unused-vars */\n/**\n * @typedef {TrustedTypesInnerPolicy}\n * @property {function(string):string} createHTML\n * @property {function(string):string} createURL\n * @property {function(string):string} createScriptURL\n * @property {function(string):string} createScript\n */\nconst TrustedTypesInnerPolicy = {};\n\n/**\n * @typedef {!Object,\n * properties: !Object}>}\n */\nconst TrustedTypesTypeMap = {};\n/* eslint-enable no-unused-vars */\n\nexport const DEFAULT_POLICY_NAME = 'default';\n\n\nexport const trustedTypesBuilderTestOnly = function() {\n // Capture common names early.\n const {\n assign, create, defineProperty, freeze, getOwnPropertyNames,\n getPrototypeOf, prototype: ObjectPrototype,\n } = Object;\n\n const {hasOwnProperty} = ObjectPrototype;\n\n const {\n forEach, push,\n } = Array.prototype;\n\n const creatorSymbol = Symbol();\n\n /**\n * Getter for the privateMap.\n * @param {Object} obj Key of the privateMap\n * @return {Object} Private storage.\n */\n const privates = function(obj) {\n let v = privateMap.get(obj);\n if (v === undefined) {\n v = create(null); // initialize the private storage.\n privateMap.set(obj, v);\n }\n return v;\n };\n\n /**\n * Called before attacker-controlled code on an internal collections,\n * copies prototype members onto the instance directly, so that later\n * changes to prototypes cannot expose collection internals.\n * @param {!T} collection\n * @return {!T} collection\n * @template T\n */\n function selfContained(collection) {\n const proto = getPrototypeOf(collection);\n if (proto == null || getPrototypeOf(proto) !== ObjectPrototype) {\n throw new Error(); // Loop below is insufficient.\n }\n for (const key of getOwnPropertyNames(proto)) {\n defineProperty(collection, key, {value: collection[key]});\n }\n return collection;\n }\n\n /**\n * Map for private properties of Trusted Types object.\n * This is so that the access to the type constructor does not give\n * the ability to create typed values.\n * @type {WeakMap}\n */\n const privateMap = selfContained(new WeakMap());\n\n /**\n * List of all configured policy names.\n * @type {Array}\n */\n const policyNames = selfContained([]);\n\n /**\n * Allowed policy names.\n * Applied only if enforceNameRestrictions is true.\n * @type {Array}\n */\n const allowedNames = selfContained([]);\n\n /**\n * Should duplicate prolicy names be allowed.\n * Applied only if enforceNameRestrictions is true.\n * @type {boolean}\n */\n let allowDuplicateNames = true;\n\n /**\n * A reference to a default policy, if created.\n * @type {TrustedTypePolicy}\n */\n let defaultPolicy = null;\n\n /**\n * Whether to enforce allowedNames in createPolicy().\n * @type {boolean}\n */\n let enforceNameRestrictions = false;\n\n\n /**\n * A value that is trusted to have certain security-relevant properties\n * because the sources of such values are controlled.\n */\n class TrustedType {\n /**\n * Constructor for TrustedType. Only allowed to be called from within a\n * policy.\n * @param {symbol} s creatorSymbol\n * @param {string} policyName The name of the policy this object was\n * created by.\n */\n constructor(s, policyName) {\n // TODO: Figure out if symbol is needed, if the value is in privateMap.\n if (s !== creatorSymbol) {\n throw new Error('cannot call the constructor');\n }\n defineProperty(this, 'policyName',\n {value: '' + policyName, enumerable: true});\n }\n\n /**\n * Returns the wrapped string value of the object.\n * @return {string}\n * @override\n */\n toString() {\n return privates(this)['v'];\n }\n\n /**\n * Returns the wrapped string value of the object.\n * @return {string}\n * @override\n */\n valueOf() {\n return privates(this)['v'];\n }\n }\n\n /**\n * @param {function(new:TrustedType, symbol, string)} SubClass\n * @param {string} canonName The class name which should be independent of\n * any renaming pass and which is relied upon by the enforcer and for\n * native type interop.\n */\n function lockdownTrustedType(SubClass, canonName) {\n freeze(SubClass.prototype);\n delete SubClass.name;\n defineProperty(SubClass, 'name', {value: canonName});\n }\n\n /**\n * Trusted URL object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedURL extends TrustedType {\n }\n lockdownTrustedType(TrustedURL, 'TrustedURL');\n\n /**\n * Trusted Script URL object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedScriptURL extends TrustedType {\n }\n lockdownTrustedType(TrustedScriptURL, 'TrustedScriptURL');\n\n /**\n * Trusted HTML object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedHTML extends TrustedType {\n }\n lockdownTrustedType(TrustedHTML, 'TrustedHTML');\n\n /**\n * Trusted Script object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedScript extends TrustedType {\n }\n lockdownTrustedType(TrustedScript, 'TrustedScript');\n\n lockdownTrustedType(TrustedType, 'TrustedType');\n\n // Common constants.\n const emptyHTML = freeze(create(new TrustedHTML(creatorSymbol, '')));\n privates(emptyHTML)['v'] = '';\n const emptyScript = freeze(create(new TrustedScript(creatorSymbol, '')));\n privates(emptyScript)['v'] = '';\n\n /**\n * A map of attribute / property names to allowed types\n * for known namespaces.\n * @type {!Object}\n * @export\n */\n const TYPE_MAP = {\n [HTML_NS]: {\n // TODO(koto): Figure out what to to with \n 'A': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'AREA': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'BASE': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'BUTTON': {\n 'attributes': {\n 'formaction': TrustedURL.name,\n },\n },\n 'EMBED': {\n 'attributes': {\n 'src': TrustedScriptURL.name,\n },\n },\n 'FORM': {\n 'attributes': {\n 'action': TrustedURL.name,\n },\n },\n 'FRAME': {\n 'attributes': {\n 'src': TrustedURL.name,\n },\n },\n 'IFRAME': {\n 'attributes': {\n 'src': TrustedURL.name,\n 'srcdoc': TrustedHTML.name,\n },\n },\n 'INPUT': {\n 'attributes': {\n 'formaction': TrustedURL.name,\n },\n },\n 'OBJECT': {\n 'attributes': {\n 'data': TrustedScriptURL.name,\n 'codebase': TrustedScriptURL.name,\n },\n },\n // TODO(koto): Figure out what to do with portals.\n 'SCRIPT': {\n 'attributes': {\n 'src': TrustedScriptURL.name,\n 'text': TrustedScript.name,\n },\n 'properties': {\n 'innerText': TrustedScript.name,\n 'textContent': TrustedScript.name,\n 'text': TrustedScript.name,\n },\n },\n '*': {\n 'attributes': {},\n 'properties': {\n 'innerHTML': TrustedHTML.name,\n 'outerHTML': TrustedHTML.name,\n },\n },\n },\n [XLINK_NS]: {\n '*': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n 'properties': {},\n },\n },\n [SVG_NS]: {\n '*': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n 'properties': {},\n },\n },\n };\n\n /**\n * A map of element property to HTML attribute names.\n * @type {!Object}\n */\n const ATTR_PROPERTY_MAP = {\n 'codebase': 'codeBase',\n 'formaction': 'formAction',\n };\n\n // Edge doesn't support srcdoc.\n if (isBrowser && !('srcdoc' in HTMLIFrameElement.prototype)) {\n delete TYPE_MAP[HTML_NS]['IFRAME']['attributes']['srcdoc'];\n }\n\n // in HTML, clone attributes into properties.\n for (const tag of Object.keys(TYPE_MAP[HTML_NS])) {\n if (!TYPE_MAP[HTML_NS][tag]['properties']) {\n TYPE_MAP[HTML_NS][tag]['properties'] = {};\n }\n for (const attr of Object.keys(TYPE_MAP[HTML_NS][tag]['attributes'])) {\n TYPE_MAP[HTML_NS][tag]['properties'][\n ATTR_PROPERTY_MAP[attr] ? ATTR_PROPERTY_MAP[attr] : attr\n ] = TYPE_MAP[HTML_NS][tag]['attributes'][attr];\n }\n }\n\n // Add inline event handlers attribute names.\n for (const name of getUnsafeAttributeEventHandlers()) {\n TYPE_MAP[HTML_NS]['*']['attributes'][name] = 'TrustedScript';\n TYPE_MAP[SVG_NS]['*']['attributes'][name] = 'TrustedScript';\n }\n\n /**\n * @type {!Object}\n */\n const createTypeMapping = {\n 'createHTML': TrustedHTML,\n 'createScriptURL': TrustedScriptURL,\n 'createURL': TrustedURL,\n 'createScript': TrustedScript,\n };\n\n const createFunctionAllowed = createTypeMapping.hasOwnProperty;\n\n /**\n * Function generating a type checker.\n * @template T\n * @param {T} type The type to check against.\n * @return {function(*):boolean}\n */\n function isTrustedTypeChecker(type) {\n return (obj) => (obj instanceof type) && privateMap.has(obj);\n }\n\n /**\n * Wraps a user-defined policy rules with TT constructor\n * @param {string} policyName The policy name\n * @param {TrustedTypesInnerPolicy} innerPolicy InnerPolicy\n * @return {!TrustedTypePolicy} Frozen policy object\n */\n function wrapPolicy(policyName, innerPolicy) {\n /**\n * @template T\n * @param {function(new:T, symbol, string)} Ctor a trusted type constructor\n * @param {string} methodName the policy factory method name\n * @return {function(string):!T} a factory that produces instances of Ctor.\n */\n function creator(Ctor, methodName) {\n // This causes thisValue to be null when called below.\n const method = innerPolicy[methodName] || (\n policyName == DEFAULT_POLICY_NAME ?\n rejectInputDefaultPolicyFn : rejectInputFn\n );\n const policySpecificType = freeze(new Ctor(creatorSymbol, policyName));\n const factory = {\n [methodName](s, ...args) {\n // Trick to get methodName to show in stacktrace.\n let result = method('' + s, ...args);\n if (result === undefined || result === null) {\n if (policyName == DEFAULT_POLICY_NAME) {\n // These values mean that the input was rejected. This will cause\n // a violation later, don't create types for them.\n return result;\n }\n result = '';\n }\n const allowedValue = '' + result;\n const o = freeze(create(policySpecificType));\n privates(o)['v'] = allowedValue;\n return o;\n },\n }[methodName];\n return freeze(factory);\n }\n\n const policy = create(TrustedTypePolicy.prototype);\n\n for (const name of getOwnPropertyNames(createTypeMapping)) {\n policy[name] = creator(createTypeMapping[name], name);\n }\n defineProperty(policy, 'name', {\n value: policyName,\n writable: false,\n configurable: false,\n enumerable: true,\n });\n\n return /** @type {!TrustedTypePolicy} */ (freeze(policy));\n }\n\n /**\n * Returns the name of the trusted type required for a given element\n * attribute.\n * @param {string} tagName The name of the tag of the element.\n * @param {string} attribute The name of the attribute.\n * @param {string=} elementNs Element namespace.\n * @param {string=} attributeNs The attribute namespace.\n * @return {string?} Required type name or null, if a Trusted\n * Type is not required.\n */\n function getAttributeType(tagName, attribute, elementNs = '',\n attributeNs = '') {\n const canonicalAttr = toLowerCase.apply(String(attribute));\n return getTypeInternal_(tagName, 'attributes', canonicalAttr,\n elementNs, attributeNs) || null;\n }\n\n /**\n * Returns a type name from a type map.\n * @param {string} tag A tag name.\n * @param {string} container 'attributes' or 'properties'\n * @param {string} name The attribute / property name.\n * @param {string=} elNs Element namespace.\n * @param {string=} attrNs Attribute namespace.\n * @return {string|undefined}\n * @private\n */\n function getTypeInternal_(tag, container, name, elNs = '', attrNs = '') {\n const canonicalTag = toUpperCase.apply(String(tag));\n\n let ns = attrNs ? attrNs : elNs;\n if (!ns) {\n ns = HTML_NS;\n }\n const map = hasOwnProperty.apply(TYPE_MAP, [ns]) ? TYPE_MAP[ns] : null;\n if (!map) {\n return;\n }\n if (hasOwnProperty.apply(map, [canonicalTag]) &&\n map[canonicalTag] &&\n hasOwnProperty.apply(map[canonicalTag][container], [name]) &&\n map[canonicalTag][container][name]) {\n return map[canonicalTag][container][name];\n }\n\n if (hasOwnProperty.apply(map, ['*']) &&\n hasOwnProperty.apply(map['*'][container], [name]) &&\n map['*'][container][name]) {\n return map['*'][container][name];\n }\n }\n\n /**\n * Returns the name of the trusted type required for a given element property.\n * @param {string} tagName The name of the tag of the element.\n * @param {string} property The property.\n * @param {string=} elementNs Element namespace.\n * @return {string?} Required type name or null, if a Trusted\n * Type is not required.\n */\n function getPropertyType(tagName, property, elementNs = '') {\n // TODO: Support namespaces.\n return getTypeInternal_(\n tagName, 'properties', String(property), elementNs) || null;\n }\n\n /**\n * Returns the type map-like object, that resolves a name of a type for a\n * given tag + attribute / property in a given namespace.\n * The keys of the map are uppercase tag names. Map entry has mappings between\n * a lowercase attribute name / case-sensitive property name and a name of the\n * type that is required for that attribute / property.\n * Example entry for 'IMG': {\"attributes\": {\"src\": \"TrustedHTML\"}}\n * @param {string=} namespaceUri The namespace URI (will use the current\n * document namespace URI if omitted).\n * @return {TrustedTypesTypeMap}\n */\n function getTypeMapping(namespaceUri = '') {\n if (!namespaceUri) {\n try {\n namespaceUri = document.documentElement.namespaceURI;\n } catch (e) {\n namespaceUri = HTML_NS;\n }\n }\n /**\n * @template T\n * @private\n * @param {T} o\n * @return {T}\n */\n function deepClone(o) {\n return JSON.parse(JSON.stringify(o));\n }\n const map = TYPE_MAP[namespaceUri];\n if (!map) {\n return {};\n }\n return deepClone(map);\n }\n\n /**\n * Returns all configured policy names (even for non-exposed policies).\n * @return {!Array}\n */\n function getPolicyNames() {\n // TODO(msamuel): Should we sort policyNames to avoid leaking or\n // encouraging dependency on the order in which policy names are\n // registered? I think JavaScript builtin sorts are efficient for\n // almost-sorted lists so the amortized cost is close to O(n).\n return policyNames.slice();\n }\n\n /**\n * Creates a TT policy.\n *\n * Returns a frozen object representing a policy - a collection of functions\n * that may create TT objects based on the user-provided rules specified\n * in the policy object.\n *\n * @param {string} name A unique name of the policy.\n * @param {TrustedTypesInnerPolicy} policy Policy rules object.\n * @return {TrustedTypePolicy} The policy that may create TT objects\n * according to the policy rules.\n */\n function createPolicy(name, policy) {\n const pName = '' + name; // Assert it's a string\n\n if (!pName.match(/^[-#a-zA-Z0-9=_/@.%]+$/g)) {\n throw new TypeError('Policy ' + pName + ' contains invalid characters.');\n }\n\n if (enforceNameRestrictions && allowedNames.indexOf(pName) === -1) {\n throw new TypeError('Policy ' + pName + ' disallowed.');\n }\n\n if (pName === DEFAULT_POLICY_NAME && defaultPolicy) {\n throw new TypeError('Policy ' + pName + ' already exists.');\n }\n if (enforceNameRestrictions && !allowDuplicateNames &&\n policyNames.indexOf(pName) !== -1) {\n throw new TypeError('Policy ' + pName + ' exists.');\n }\n // Register the name early so that if policy getters unwisely calls\n // across protection domains to code that reenters this function,\n // policy author still has rights to the name.\n policyNames.push(pName);\n\n // Only copy own properties of names present in createTypeMapping.\n const innerPolicy = create(null);\n if (policy && typeof policy === 'object') {\n // Treat non-objects as empty policies.\n for (const key of getOwnPropertyNames(policy)) {\n if (createFunctionAllowed.call(createTypeMapping, key)) {\n innerPolicy[key] = policy[key];\n }\n }\n } else {\n // eslint-disable-next-line no-console\n console.warn('trustedTypes.createPolicy ' + pName +\n ' was given an empty policy');\n }\n freeze(innerPolicy);\n\n const wrappedPolicy = wrapPolicy(pName, innerPolicy);\n\n if (pName === DEFAULT_POLICY_NAME) {\n defaultPolicy = wrappedPolicy;\n }\n\n return wrappedPolicy;\n }\n\n /**\n * Applies the policy name restrictions.\n * @param {!Array} allowedPolicyNames\n * @param {boolean} allowDuplicates\n */\n function setPolicyNameRestrictions(allowedPolicyNames, allowDuplicates) {\n enforceNameRestrictions = true;\n allowedNames.length = 0;\n forEach.call(allowedPolicyNames, (el) => {\n push.call(allowedNames, '' + el);\n });\n allowDuplicateNames = allowDuplicates;\n policyNames.length = 0; // Clear already used policy names list.\n }\n\n /**\n * Clears the policy name restrictions.\n */\n function clearPolicyNameRestrictions() {\n enforceNameRestrictions = false;\n }\n\n /**\n * Returns the default policy, or null if it was not created.\n * @return {TrustedTypePolicy}\n */\n function getDefaultPolicy() {\n return defaultPolicy;\n }\n\n /**\n * Resets the default policy.\n */\n function resetDefaultPolicy() {\n defaultPolicy = null;\n policyNames.splice(policyNames.indexOf(DEFAULT_POLICY_NAME), 1);\n }\n\n const api = create(TrustedTypePolicyFactory.prototype);\n assign(api, {\n // The main function to create policies.\n createPolicy,\n\n getPolicyNames,\n\n // Type checkers, also validating the object was initialized through a\n // policy.\n isHTML: isTrustedTypeChecker(TrustedHTML),\n isURL: isTrustedTypeChecker(TrustedURL),\n isScriptURL: isTrustedTypeChecker(TrustedScriptURL),\n isScript: isTrustedTypeChecker(TrustedScript),\n\n getAttributeType,\n getPropertyType,\n getTypeMapping,\n emptyHTML,\n emptyScript,\n defaultPolicy, // Just to make the compiler happy, this is overridden below.\n\n TrustedHTML: TrustedHTML,\n TrustedURL: TrustedURL,\n TrustedScriptURL: TrustedScriptURL,\n TrustedScript: TrustedScript,\n });\n\n defineProperty(api, 'defaultPolicy', {\n get: getDefaultPolicy,\n set: () => {},\n });\n\n return {\n trustedTypes: freeze(api),\n setPolicyNameRestrictions,\n clearPolicyNameRestrictions,\n getDefaultPolicy,\n resetDefaultPolicy,\n };\n};\n\n\nexport const {\n trustedTypes,\n setPolicyNameRestrictions,\n clearPolicyNameRestrictions,\n getDefaultPolicy,\n resetDefaultPolicy,\n} = trustedTypesBuilderTestOnly();\n\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n/**\n * @fileoverview Entry point for a polyfill that only defines the types\n * (i.e. no enforcement logic).\n */\nimport {trustedTypes, TrustedTypePolicy, TrustedTypePolicyFactory} from\n '../trustedtypes.js';\n\nconst tt = trustedTypes;\n\n/**\n * Sets up the public Trusted Types API in the global object.\n */\nfunction setupPolyfill() {\n // We use array accessors to make sure Closure compiler will not alter the\n // names of the properties..\n\n // we setup the polyfill only in browser environment.\n if (typeof window === 'undefined') {\n return;\n }\n const rootProperty = 'trustedTypes';\n\n // Convert old window.TrustedTypes to window.trustedTypes.\n if (window['TrustedTypes'] && typeof window[rootProperty] === 'undefined') {\n window[rootProperty] = Object.freeze(window['TrustedTypes']);\n }\n\n if (typeof window[rootProperty] !== 'undefined') {\n return;\n }\n\n const publicApi = Object.create(TrustedTypePolicyFactory.prototype);\n Object.assign(publicApi, {\n 'isHTML': tt.isHTML,\n 'isURL': tt.isURL,\n 'isScriptURL': tt.isScriptURL,\n 'isScript': tt.isScript,\n 'createPolicy': tt.createPolicy,\n 'getPolicyNames': tt.getPolicyNames,\n 'getAttributeType': tt.getAttributeType,\n 'getPropertyType': tt.getPropertyType,\n 'getTypeMapping': tt.getTypeMapping,\n 'emptyHTML': tt.emptyHTML,\n 'emptyScript': tt.emptyScript,\n '_isPolyfill_': true,\n });\n Object.defineProperty(\n publicApi,\n 'defaultPolicy',\n Object.getOwnPropertyDescriptor(tt, 'defaultPolicy') || {});\n\n window[rootProperty] = Object.freeze(publicApi);\n\n window['TrustedHTML'] = tt.TrustedHTML;\n window['TrustedURL'] = tt.TrustedURL;\n window['TrustedScriptURL'] = tt.TrustedScriptURL;\n window['TrustedScript'] = tt.TrustedScript;\n window['TrustedTypePolicy'] = TrustedTypePolicy;\n window['TrustedTypePolicyFactory'] = TrustedTypePolicyFactory;\n}\n\nsetupPolyfill();\n\nexport default tt;\n"]} \ No newline at end of file +{"version":3,"sources":["src/utils/eventHandlers.js","src/trustedtypes.js","src/polyfill/api_only.js"],"names":["unsafeAttributeEventHandlers","getUnsafeAttributeEventHandlers","window","eventHandlers","name","HTMLElement","prototype","slice","push","isBrowser","rejectInputFn","TypeError","rejectInputDefaultPolicyFn","toLowerCase","toUpperCase","String","TrustedTypePolicy","TrustedTypePolicyFactory","trustedTypes","trustedTypesBuilderTestOnly","privates","obj","v","privateMap","get","undefined","create","set","selfContained","collection","proto","getPrototypeOf","ObjectPrototype","Error","key","getOwnPropertyNames","defineProperty","value","lockdownTrustedType","SubClass","canonName","freeze","isTrustedTypeChecker","type","has","wrapPolicy","policyName","innerPolicy","creator","Ctor","methodName","method","DEFAULT_POLICY_NAME","policySpecificType","creatorSymbol","s","args","result","allowedValue","o","factory","policy","createTypeMapping","writable","configurable","enumerable","getTypeInternal_","tag","container","elNs","attrNs","canonicalTag","apply","ns","HTML_NS","map","hasOwnProperty","TYPE_MAP","getDefaultPolicy","defaultPolicy","assign","Object","forEach","Array","Symbol","WeakMap","policyNames","allowedNames","allowDuplicateNames","enforceNameRestrictions","TrustedType","TrustedURL","TrustedScriptURL","TrustedHTML","TrustedScript","emptyHTML","emptyScript","XLINK_NS","SVG_NS","ATTR_PROPERTY_MAP","HTMLIFrameElement","keys","attr","createFunctionAllowed","api","createPolicy","match","indexOf","call","console","warn","wrappedPolicy","isHTML","isURL","isScriptURL","isScript","getAttributeType","tagName","attribute","elementNs","attributeNs","canonicalAttr","getPropertyType","property","getTypeMapping","namespaceUri","document","documentElement","namespaceURI","e","JSON","parse","stringify","setPolicyNameRestrictions","allowedPolicyNames","allowDuplicates","length","el","clearPolicyNameRestrictions","resetDefaultPolicy","splice","publicApi","tt","getOwnPropertyDescriptor"],"mappings":"A;;;;;;;;aAUA,MAAMA,EAA+B,q1EAAA,MAAA,CAAA,GAAA,CAmM9BC;QAASA,EAA+B,EAAG,CAChD,GAAsB,WAAtB,GAAI,MAAOC,OAAX,CAAmC,CACjC,MAAMC,EAAgB,EACtB,KAAK,MAAMC,CAAX,GAAmBC,YAAAC,UAAnB,CAC2B,IAAzB,GAAIF,CAAAG,MAAA,CAAW,CAAX,CAAc,CAAd,CAAJ,EACEJ,CAAAK,KAAA,CAAmBJ,CAAnB,CAGJ,OAAOD,EAP0B,CASjC,MAAOH,EAVuC,C,CClMlD,MAAMS,EAA8B,WAA9BA,GAAY,MAAOP,OAAzB,CAEMQ,EAAgB,EAAAA,EAAO,CAC3B,KAAM,KAAIC,SAAJ,CAAc,sBAAd,CAAN,CAD2B,CAF7B,CAMMC,EAA6B,EAAAA,EAAO,IAN1C,CAQM,CAAC,YAAAC,CAAD,CAAc,YAAAC,EAAd,CAAA,CAA6BC,MAAAT,UAcFU,SAAA,EAAQ,EAAG,CAC1C,KAAM,KAAIL,SAAJ,CAAc,qBAAd,CAAN,CAD0C,CAOJM,QAAA,EAAQ,EAAG,CACjD,KA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ACvB,OAAUC,CAAA9B,EADa,CAEvB,MAAS8B,CAAA7B,EAFc,CAGvB,YAAe6B,CAAA5B,EAHQ,CAIvB,SAAY4B,CAAA3B,EAJW,CAKvB,aAAgB2B,CAAArC,aALO,CAMvB,iBAAoBqC,CAAA1B,EANG,CAOvB,gBAAmB0B,CAAApB,EAPI,CAQvB,eAAkBoB,CAAAlB,EARK,CASvB,UAAakB,CAAA/C,EATU,CAUvB,YAAe+C,CAAA9C,EAVQ,CAWvB,aAAgB,CAAA,CAXO,CAAzB,CAaAf,OAAA7C,eAAA,CACIyG,CADJ,CAEI,eAFJ,CAGI5D,MAAA8D,yBAAA,CAAgCD,CAAhC;AAAoC,eAApC,CAHJ,EAG4D,EAH5D,CAKA5I,OAAA,aAAA,CAAuB+E,MAAAxC,OAAA,CAAcoG,CAAd,CAEvB3I,OAAA,YAAA,CAAwB4I,CAAAjD,YACxB3F,OAAA,WAAA,CAAuB4I,CAAAnD,WACvBzF,OAAA,iBAAA,CAA6B4I,CAAAlD,iBAC7B1F,OAAA,cAAA,CAA0B4I,CAAAhD,cAC1B5F,OAAA,kBAAA,CAA8Bc,CAC9Bd,OAAA,yBAAA,CAAqCe,CA9BrC","file":"trustedtypes.api_only.build.js","sourcesContent":["/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n// TODO check attributes in safari, remove legacy safe handlers\nconst unsafeAttributeEventHandlers = [\n 'onabort',\n 'onactivate',\n 'onactivateinvisible',\n 'onafterprint',\n 'onafterupdate',\n 'onanimationcancel',\n 'onanimationend',\n 'onanimationiteration',\n 'onanimationstart',\n 'onariarequest',\n 'onauxclick',\n 'onbeforeactivate',\n 'onbeforecopy',\n 'onbeforecut',\n 'onbeforedeactivate',\n 'onbeforeeditfocus',\n 'onbeforepaste',\n 'onbeforeprint',\n 'onbeforeunload',\n 'onbegin',\n 'onblur',\n 'onbounce',\n 'oncancel',\n 'oncanplay',\n 'oncanplaythrough',\n 'oncellchange',\n 'onchange',\n 'onclick',\n 'onclose',\n 'oncommand',\n 'oncontextmenu',\n 'oncontrolselect',\n 'oncopy',\n 'oncuechange',\n 'oncut',\n 'ondataavailable',\n 'ondatasetchanged',\n 'ondatasetcomplete',\n 'ondblclick',\n 'ondeactivate',\n 'ondrag',\n 'ondragdrop',\n 'ondragend',\n 'ondragenter',\n 'ondragexit',\n 'ondragleave',\n 'ondragover',\n 'ondragstart',\n 'ondrop',\n 'ondurationchange',\n 'onemptied',\n 'onend',\n 'onended',\n 'onerror',\n 'onerrorupdate',\n 'onexit',\n 'onfilterchange',\n 'onfinish',\n 'onfocus',\n 'onfocusin',\n 'onfocusout',\n 'onformdata',\n 'onfullscreenchange',\n 'onfullscreenerror',\n 'ongotpointercapture',\n 'onhelp',\n 'oninput',\n 'oninvalid',\n 'onkeydown',\n 'onkeypress',\n 'onkeyup',\n 'onlayoutcomplete',\n 'onload',\n 'onloadeddata',\n 'onloadedmetadata',\n 'onloadend',\n 'onloadstart',\n 'onlosecapture',\n 'onlostpointercapture',\n 'onmediacomplete',\n 'onmediaerror',\n 'onmessage',\n 'onmousedown',\n 'onmouseenter',\n 'onmouseleave',\n 'onmousemove',\n 'onmouseout',\n 'onmouseover',\n 'onmouseup',\n 'onmousewheel',\n 'onmove',\n 'onmoveend',\n 'onmovestart',\n 'onmozfullscreenchange',\n 'onmozfullscreenerror',\n 'onmscontentzoom',\n 'onmsgesturechange',\n 'onmsgesturedoubletap',\n 'onmsgestureend',\n 'onmsgesturehold',\n 'onmsgesturestart',\n 'onmsgesturetap',\n 'onmsgotpointercapture',\n 'onmsinertiastart',\n 'onmslostpointercapture',\n 'onmsmanipulationstatechanged',\n 'onmspointercancel',\n 'onmspointerdown',\n 'onmspointerenter',\n 'onmspointerleave',\n 'onmspointermove',\n 'onmspointerout',\n 'onmspointerover',\n 'onmspointerup',\n 'onoffline',\n 'ononline',\n 'onoutofsync',\n 'onoverscroll',\n 'onpaste',\n 'onpause',\n 'onplay',\n 'onplaying',\n 'onpointercancel',\n 'onpointerdown',\n 'onpointerenter',\n 'onpointerleave',\n 'onpointermove',\n 'onpointerout',\n 'onpointerover',\n 'onpointerrawupdate',\n 'onpointerup',\n 'onprogress',\n 'onpropertychange',\n 'onratechange',\n 'onreadystatechange',\n 'onrepeat',\n 'onreset',\n 'onresize',\n 'onresizeend',\n 'onresizestart',\n 'onresume',\n 'onreverse',\n 'onrowdelete',\n 'onrowenter',\n 'onrowexit',\n 'onrowinserted',\n 'onscroll',\n 'onscrollend',\n 'onsearch',\n 'onseek',\n 'onseeked',\n 'onseeking',\n 'onselect',\n 'onselectionchange',\n 'onselectstart',\n 'onshow',\n 'onstalled',\n 'onstart',\n 'onstop',\n 'onstorage',\n 'onsubmit',\n 'onsuspend',\n 'onsynchrestored',\n 'ontimeerror',\n 'ontimeupdate',\n 'ontoggle',\n 'ontrackchange',\n 'ontransitioncancel',\n 'ontransitionend',\n 'ontransitionrun',\n 'ontransitionstart',\n 'onunload',\n 'onurlflip',\n 'onvolumechange',\n 'onwaiting',\n 'onwebkitanimationend',\n 'onwebkitanimationiteration',\n 'onwebkitanimationstart',\n 'onwebkitfullscreenchange',\n 'onwebkitfullscreenerror',\n 'onwebkittransitionend',\n 'onwheel',\n];\n\n/**\n * Returns an array of all event handlers. Some of the event handlers may be\n * supported only in some browsers.\n *\n * For every event type that the browser supports, SVG supports that as an event\n * attribute, following the same requirements as for HTML event attributes.\n * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/Events\n *\n * @return {!Array}\n */\nexport function getUnsafeAttributeEventHandlers() {\n if (typeof window !== 'undefined') {\n const eventHandlers = [];\n for (const name in HTMLElement.prototype) {\n if (name.slice(0, 2) === 'on') {\n eventHandlers.push(name);\n }\n }\n return eventHandlers;\n } else {\n return unsafeAttributeEventHandlers;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\nimport {getUnsafeAttributeEventHandlers} from './utils/eventHandlers.js';\n\nconst isBrowser = typeof window !== 'undefined';\n\nconst rejectInputFn = (s) => {\n throw new TypeError('undefined conversion');\n};\n\nconst rejectInputDefaultPolicyFn = (s) => null;\n\nconst {toLowerCase, toUpperCase} = String.prototype;\n\nexport const HTML_NS = 'http://www.w3.org/1999/xhtml';\nexport const XLINK_NS = 'http://www.w3.org/1999/xlink';\nexport const SVG_NS = 'http://www.w3.org/2000/svg';\n\n/**\n * @constructor\n * @property {!function(string):TrustedHTML} createHTML\n * @property {!function(string):TrustedURL} createURL\n * @property {!function(string):TrustedScriptURL} createScriptURL\n * @property {!function(string):TrustedScript} createScript\n * @property {!string} name\n */\nexport const TrustedTypePolicy = function() {\n throw new TypeError('Illegal constructor');\n};\n\n/**\n * @constructor\n */\nexport const TrustedTypePolicyFactory = function() {\n throw new TypeError('Illegal constructor');\n};\n\n/* eslint-disable no-unused-vars */\n/**\n * @typedef {TrustedTypesInnerPolicy}\n * @property {function(string):string} createHTML\n * @property {function(string):string} createURL\n * @property {function(string):string} createScriptURL\n * @property {function(string):string} createScript\n */\nconst TrustedTypesInnerPolicy = {};\n\n/**\n * @typedef {!Object,\n * properties: !Object}>}\n */\nconst TrustedTypesTypeMap = {};\n/* eslint-enable no-unused-vars */\n\nexport const DEFAULT_POLICY_NAME = 'default';\n\n\nexport const trustedTypesBuilderTestOnly = function() {\n // Capture common names early.\n const {\n assign, create, defineProperty, freeze, getOwnPropertyNames,\n getPrototypeOf, prototype: ObjectPrototype,\n } = Object;\n\n const {hasOwnProperty} = ObjectPrototype;\n\n const {\n forEach, push,\n } = Array.prototype;\n\n const creatorSymbol = Symbol();\n\n /**\n * Getter for the privateMap.\n * @param {Object} obj Key of the privateMap\n * @return {Object} Private storage.\n */\n const privates = function(obj) {\n let v = privateMap.get(obj);\n if (v === undefined) {\n v = create(null); // initialize the private storage.\n privateMap.set(obj, v);\n }\n return v;\n };\n\n /**\n * Called before attacker-controlled code on an internal collections,\n * copies prototype members onto the instance directly, so that later\n * changes to prototypes cannot expose collection internals.\n * @param {!T} collection\n * @return {!T} collection\n * @template T\n */\n function selfContained(collection) {\n const proto = getPrototypeOf(collection);\n if (proto == null || getPrototypeOf(proto) !== ObjectPrototype) {\n throw new Error(); // Loop below is insufficient.\n }\n for (const key of getOwnPropertyNames(proto)) {\n defineProperty(collection, key, {value: collection[key]});\n }\n return collection;\n }\n\n /**\n * Map for private properties of Trusted Types object.\n * This is so that the access to the type constructor does not give\n * the ability to create typed values.\n * @type {WeakMap}\n */\n const privateMap = selfContained(new WeakMap());\n\n /**\n * List of all configured policy names.\n * @type {Array}\n */\n const policyNames = selfContained([]);\n\n /**\n * Allowed policy names.\n * Applied only if enforceNameRestrictions is true.\n * @type {Array}\n */\n const allowedNames = selfContained([]);\n\n /**\n * Should duplicate prolicy names be allowed.\n * Applied only if enforceNameRestrictions is true.\n * @type {boolean}\n */\n let allowDuplicateNames = true;\n\n /**\n * A reference to a default policy, if created.\n * @type {TrustedTypePolicy}\n */\n let defaultPolicy = null;\n\n /**\n * Whether to enforce allowedNames in createPolicy().\n * @type {boolean}\n */\n let enforceNameRestrictions = false;\n\n\n /**\n * A value that is trusted to have certain security-relevant properties\n * because the sources of such values are controlled.\n */\n class TrustedType {\n /**\n * Constructor for TrustedType. Only allowed to be called from within a\n * policy.\n * @param {symbol} s creatorSymbol\n * @param {string} policyName The name of the policy this object was\n * created by.\n */\n constructor(s, policyName) {\n // TODO: Figure out if symbol is needed, if the value is in privateMap.\n if (s !== creatorSymbol) {\n throw new Error('cannot call the constructor');\n }\n defineProperty(this, 'policyName',\n {value: '' + policyName, enumerable: true});\n }\n\n /**\n * Returns the wrapped string value of the object.\n * @return {string}\n * @override\n */\n toString() {\n return privates(this)['v'];\n }\n\n /**\n * Returns the wrapped string value of the object.\n * @return {string}\n * @override\n */\n valueOf() {\n return privates(this)['v'];\n }\n }\n\n /**\n * @param {function(new:TrustedType, symbol, string)} SubClass\n * @param {string} canonName The class name which should be independent of\n * any renaming pass and which is relied upon by the enforcer and for\n * native type interop.\n */\n function lockdownTrustedType(SubClass, canonName) {\n freeze(SubClass.prototype);\n delete SubClass.name;\n defineProperty(SubClass, 'name', {value: canonName});\n }\n\n /**\n * Trusted URL object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedURL extends TrustedType {\n }\n lockdownTrustedType(TrustedURL, 'TrustedURL');\n\n /**\n * Trusted Script URL object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedScriptURL extends TrustedType {\n }\n lockdownTrustedType(TrustedScriptURL, 'TrustedScriptURL');\n\n /**\n * Trusted HTML object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedHTML extends TrustedType {\n }\n lockdownTrustedType(TrustedHTML, 'TrustedHTML');\n\n /**\n * Trusted Script object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedScript extends TrustedType {\n }\n lockdownTrustedType(TrustedScript, 'TrustedScript');\n\n lockdownTrustedType(TrustedType, 'TrustedType');\n\n // Common constants.\n const emptyHTML = freeze(create(new TrustedHTML(creatorSymbol, '')));\n privates(emptyHTML)['v'] = '';\n const emptyScript = freeze(create(new TrustedScript(creatorSymbol, '')));\n privates(emptyScript)['v'] = '';\n\n /**\n * A map of attribute / property names to allowed types\n * for known namespaces.\n * @type {!Object}\n * @export\n */\n const TYPE_MAP = {\n [HTML_NS]: {\n // TODO(koto): Figure out what to to with \n 'A': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'AREA': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'BASE': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'BUTTON': {\n 'attributes': {\n 'formaction': TrustedURL.name,\n },\n },\n 'EMBED': {\n 'attributes': {\n 'src': TrustedScriptURL.name,\n },\n },\n 'FORM': {\n 'attributes': {\n 'action': TrustedURL.name,\n },\n },\n 'FRAME': {\n 'attributes': {\n 'src': TrustedURL.name,\n },\n },\n 'IFRAME': {\n 'attributes': {\n 'src': TrustedURL.name,\n 'srcdoc': TrustedHTML.name,\n },\n },\n 'INPUT': {\n 'attributes': {\n 'formaction': TrustedURL.name,\n },\n },\n 'OBJECT': {\n 'attributes': {\n 'data': TrustedScriptURL.name,\n 'codebase': TrustedScriptURL.name,\n },\n },\n // TODO(koto): Figure out what to do with portals.\n 'SCRIPT': {\n 'attributes': {\n 'src': TrustedScriptURL.name,\n 'text': TrustedScript.name,\n },\n 'properties': {\n 'innerText': TrustedScript.name,\n 'textContent': TrustedScript.name,\n 'text': TrustedScript.name,\n },\n },\n '*': {\n 'attributes': {},\n 'properties': {\n 'innerHTML': TrustedHTML.name,\n 'outerHTML': TrustedHTML.name,\n },\n },\n },\n [XLINK_NS]: {\n '*': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n 'properties': {},\n },\n },\n [SVG_NS]: {\n '*': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n 'properties': {},\n },\n },\n };\n\n /**\n * A map of element property to HTML attribute names.\n * @type {!Object}\n */\n const ATTR_PROPERTY_MAP = {\n 'codebase': 'codeBase',\n 'formaction': 'formAction',\n };\n\n // Edge doesn't support srcdoc.\n if (isBrowser && !('srcdoc' in HTMLIFrameElement.prototype)) {\n delete TYPE_MAP[HTML_NS]['IFRAME']['attributes']['srcdoc'];\n }\n\n // in HTML, clone attributes into properties.\n for (const tag of Object.keys(TYPE_MAP[HTML_NS])) {\n if (!TYPE_MAP[HTML_NS][tag]['properties']) {\n TYPE_MAP[HTML_NS][tag]['properties'] = {};\n }\n for (const attr of Object.keys(TYPE_MAP[HTML_NS][tag]['attributes'])) {\n TYPE_MAP[HTML_NS][tag]['properties'][\n ATTR_PROPERTY_MAP[attr] ? ATTR_PROPERTY_MAP[attr] : attr\n ] = TYPE_MAP[HTML_NS][tag]['attributes'][attr];\n }\n }\n\n // Add inline event handlers attribute names.\n for (const name of getUnsafeAttributeEventHandlers()) {\n TYPE_MAP[HTML_NS]['*']['attributes'][name] = 'TrustedScript';\n TYPE_MAP[SVG_NS]['*']['attributes'][name] = 'TrustedScript';\n }\n\n /**\n * @type {!Object}\n */\n const createTypeMapping = {\n 'createHTML': TrustedHTML,\n 'createScriptURL': TrustedScriptURL,\n 'createURL': TrustedURL,\n 'createScript': TrustedScript,\n };\n\n const createFunctionAllowed = createTypeMapping.hasOwnProperty;\n\n /**\n * Function generating a type checker.\n * @template T\n * @param {T} type The type to check against.\n * @return {function(*):boolean}\n */\n function isTrustedTypeChecker(type) {\n return (obj) => (obj instanceof type) && privateMap.has(obj);\n }\n\n /**\n * Wraps a user-defined policy rules with TT constructor\n * @param {string} policyName The policy name\n * @param {TrustedTypesInnerPolicy} innerPolicy InnerPolicy\n * @return {!TrustedTypePolicy} Frozen policy object\n */\n function wrapPolicy(policyName, innerPolicy) {\n /**\n * @template T\n * @param {function(new:T, symbol, string)} Ctor a trusted type constructor\n * @param {string} methodName the policy factory method name\n * @return {function(string):!T} a factory that produces instances of Ctor.\n */\n function creator(Ctor, methodName) {\n // This causes thisValue to be null when called below.\n const method = innerPolicy[methodName] || (\n policyName == DEFAULT_POLICY_NAME ?\n rejectInputDefaultPolicyFn : rejectInputFn\n );\n const policySpecificType = freeze(new Ctor(creatorSymbol, policyName));\n const factory = {\n [methodName](s, ...args) {\n // Trick to get methodName to show in stacktrace.\n let result = method('' + s, ...args);\n if (result === undefined || result === null) {\n if (policyName == DEFAULT_POLICY_NAME) {\n // These values mean that the input was rejected. This will cause\n // a violation later, don't create types for them.\n return result;\n }\n result = '';\n }\n const allowedValue = '' + result;\n const o = freeze(create(policySpecificType));\n privates(o)['v'] = allowedValue;\n return o;\n },\n }[methodName];\n return freeze(factory);\n }\n\n const policy = create(TrustedTypePolicy.prototype);\n\n for (const name of getOwnPropertyNames(createTypeMapping)) {\n policy[name] = creator(createTypeMapping[name], name);\n }\n defineProperty(policy, 'name', {\n value: policyName,\n writable: false,\n configurable: false,\n enumerable: true,\n });\n\n return /** @type {!TrustedTypePolicy} */ (freeze(policy));\n }\n\n /**\n * Returns the name of the trusted type required for a given element\n * attribute.\n * @param {string} tagName The name of the tag of the element.\n * @param {string} attribute The name of the attribute.\n * @param {string=} elementNs Element namespace.\n * @param {string=} attributeNs The attribute namespace.\n * @return {string?} Required type name or null, if a Trusted\n * Type is not required.\n */\n function getAttributeType(tagName, attribute, elementNs = '',\n attributeNs = '') {\n const canonicalAttr = toLowerCase.apply(String(attribute));\n return getTypeInternal_(tagName, 'attributes', canonicalAttr,\n elementNs, attributeNs) || null;\n }\n\n /**\n * Returns a type name from a type map.\n * @param {string} tag A tag name.\n * @param {string} container 'attributes' or 'properties'\n * @param {string} name The attribute / property name.\n * @param {string=} elNs Element namespace.\n * @param {string=} attrNs Attribute namespace.\n * @return {string|undefined}\n * @private\n */\n function getTypeInternal_(tag, container, name, elNs = '', attrNs = '') {\n const canonicalTag = toUpperCase.apply(String(tag));\n\n let ns = attrNs ? attrNs : elNs;\n if (!ns) {\n ns = HTML_NS;\n }\n const map = hasOwnProperty.apply(TYPE_MAP, [ns]) ? TYPE_MAP[ns] : null;\n if (!map) {\n return;\n }\n if (hasOwnProperty.apply(map, [canonicalTag]) &&\n map[canonicalTag] &&\n hasOwnProperty.apply(map[canonicalTag][container], [name]) &&\n map[canonicalTag][container][name]) {\n return map[canonicalTag][container][name];\n }\n\n if (hasOwnProperty.apply(map, ['*']) &&\n hasOwnProperty.apply(map['*'][container], [name]) &&\n map['*'][container][name]) {\n return map['*'][container][name];\n }\n }\n\n /**\n * Returns the name of the trusted type required for a given element property.\n * @param {string} tagName The name of the tag of the element.\n * @param {string} property The property.\n * @param {string=} elementNs Element namespace.\n * @return {string?} Required type name or null, if a Trusted\n * Type is not required.\n */\n function getPropertyType(tagName, property, elementNs = '') {\n // TODO: Support namespaces.\n return getTypeInternal_(\n tagName, 'properties', String(property), elementNs) || null;\n }\n\n /**\n * Returns the type map-like object, that resolves a name of a type for a\n * given tag + attribute / property in a given namespace.\n * The keys of the map are uppercase tag names. Map entry has mappings between\n * a lowercase attribute name / case-sensitive property name and a name of the\n * type that is required for that attribute / property.\n * Example entry for 'IMG': {\"attributes\": {\"src\": \"TrustedHTML\"}}\n * @param {string=} namespaceUri The namespace URI (will use the current\n * document namespace URI if omitted).\n * @return {TrustedTypesTypeMap}\n */\n function getTypeMapping(namespaceUri = '') {\n if (!namespaceUri) {\n try {\n namespaceUri = document.documentElement.namespaceURI;\n } catch (e) {\n namespaceUri = HTML_NS;\n }\n }\n /**\n * @template T\n * @private\n * @param {T} o\n * @return {T}\n */\n function deepClone(o) {\n return JSON.parse(JSON.stringify(o));\n }\n const map = TYPE_MAP[namespaceUri];\n if (!map) {\n return {};\n }\n return deepClone(map);\n }\n\n /**\n * Creates a TT policy.\n *\n * Returns a frozen object representing a policy - a collection of functions\n * that may create TT objects based on the user-provided rules specified\n * in the policy object.\n *\n * @param {string} name A unique name of the policy.\n * @param {TrustedTypesInnerPolicy} policy Policy rules object.\n * @return {TrustedTypePolicy} The policy that may create TT objects\n * according to the policy rules.\n */\n function createPolicy(name, policy) {\n const pName = '' + name; // Assert it's a string\n\n if (!pName.match(/^[-#a-zA-Z0-9=_/@.%]+$/g)) {\n throw new TypeError('Policy ' + pName + ' contains invalid characters.');\n }\n\n if (enforceNameRestrictions && allowedNames.indexOf(pName) === -1) {\n throw new TypeError('Policy ' + pName + ' disallowed.');\n }\n\n if (pName === DEFAULT_POLICY_NAME && defaultPolicy) {\n throw new TypeError('Policy ' + pName + ' already exists.');\n }\n if (enforceNameRestrictions && !allowDuplicateNames &&\n policyNames.indexOf(pName) !== -1) {\n throw new TypeError('Policy ' + pName + ' exists.');\n }\n // Register the name early so that if policy getters unwisely calls\n // across protection domains to code that reenters this function,\n // policy author still has rights to the name.\n policyNames.push(pName);\n\n // Only copy own properties of names present in createTypeMapping.\n const innerPolicy = create(null);\n if (policy && typeof policy === 'object') {\n // Treat non-objects as empty policies.\n for (const key of getOwnPropertyNames(policy)) {\n if (createFunctionAllowed.call(createTypeMapping, key)) {\n innerPolicy[key] = policy[key];\n }\n }\n } else {\n // eslint-disable-next-line no-console\n console.warn('trustedTypes.createPolicy ' + pName +\n ' was given an empty policy');\n }\n freeze(innerPolicy);\n\n const wrappedPolicy = wrapPolicy(pName, innerPolicy);\n\n if (pName === DEFAULT_POLICY_NAME) {\n defaultPolicy = wrappedPolicy;\n }\n\n return wrappedPolicy;\n }\n\n /**\n * Applies the policy name restrictions.\n * @param {!Array} allowedPolicyNames\n * @param {boolean} allowDuplicates\n */\n function setPolicyNameRestrictions(allowedPolicyNames, allowDuplicates) {\n enforceNameRestrictions = true;\n allowedNames.length = 0;\n forEach.call(allowedPolicyNames, (el) => {\n push.call(allowedNames, '' + el);\n });\n allowDuplicateNames = allowDuplicates;\n policyNames.length = 0; // Clear already used policy names list.\n }\n\n /**\n * Clears the policy name restrictions.\n */\n function clearPolicyNameRestrictions() {\n enforceNameRestrictions = false;\n }\n\n /**\n * Returns the default policy, or null if it was not created.\n * @return {TrustedTypePolicy}\n */\n function getDefaultPolicy() {\n return defaultPolicy;\n }\n\n /**\n * Resets the default policy.\n */\n function resetDefaultPolicy() {\n defaultPolicy = null;\n policyNames.splice(policyNames.indexOf(DEFAULT_POLICY_NAME), 1);\n }\n\n const api = create(TrustedTypePolicyFactory.prototype);\n assign(api, {\n // The main function to create policies.\n createPolicy,\n\n // Type checkers, also validating the object was initialized through a\n // policy.\n isHTML: isTrustedTypeChecker(TrustedHTML),\n isURL: isTrustedTypeChecker(TrustedURL),\n isScriptURL: isTrustedTypeChecker(TrustedScriptURL),\n isScript: isTrustedTypeChecker(TrustedScript),\n\n getAttributeType,\n getPropertyType,\n getTypeMapping,\n emptyHTML,\n emptyScript,\n defaultPolicy, // Just to make the compiler happy, this is overridden below.\n\n TrustedHTML: TrustedHTML,\n TrustedURL: TrustedURL,\n TrustedScriptURL: TrustedScriptURL,\n TrustedScript: TrustedScript,\n });\n\n defineProperty(api, 'defaultPolicy', {\n get: getDefaultPolicy,\n set: () => {},\n });\n\n return {\n trustedTypes: freeze(api),\n setPolicyNameRestrictions,\n clearPolicyNameRestrictions,\n getDefaultPolicy,\n resetDefaultPolicy,\n };\n};\n\n\nexport const {\n trustedTypes,\n setPolicyNameRestrictions,\n clearPolicyNameRestrictions,\n getDefaultPolicy,\n resetDefaultPolicy,\n} = trustedTypesBuilderTestOnly();\n\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n/**\n * @fileoverview Entry point for a polyfill that only defines the types\n * (i.e. no enforcement logic).\n */\nimport {trustedTypes, TrustedTypePolicy, TrustedTypePolicyFactory} from\n '../trustedtypes.js';\n\nconst tt = trustedTypes;\n\n/**\n * Sets up the public Trusted Types API in the global object.\n */\nfunction setupPolyfill() {\n // We use array accessors to make sure Closure compiler will not alter the\n // names of the properties..\n\n // we setup the polyfill only in browser environment.\n if (typeof window === 'undefined') {\n return;\n }\n const rootProperty = 'trustedTypes';\n\n // Convert old window.TrustedTypes to window.trustedTypes.\n if (window['TrustedTypes'] && typeof window[rootProperty] === 'undefined') {\n window[rootProperty] = Object.freeze(window['TrustedTypes']);\n }\n\n if (typeof window[rootProperty] !== 'undefined') {\n return;\n }\n\n const publicApi = Object.create(TrustedTypePolicyFactory.prototype);\n Object.assign(publicApi, {\n 'isHTML': tt.isHTML,\n 'isURL': tt.isURL,\n 'isScriptURL': tt.isScriptURL,\n 'isScript': tt.isScript,\n 'createPolicy': tt.createPolicy,\n 'getAttributeType': tt.getAttributeType,\n 'getPropertyType': tt.getPropertyType,\n 'getTypeMapping': tt.getTypeMapping,\n 'emptyHTML': tt.emptyHTML,\n 'emptyScript': tt.emptyScript,\n '_isPolyfill_': true,\n });\n Object.defineProperty(\n publicApi,\n 'defaultPolicy',\n Object.getOwnPropertyDescriptor(tt, 'defaultPolicy') || {});\n\n window[rootProperty] = Object.freeze(publicApi);\n\n window['TrustedHTML'] = tt.TrustedHTML;\n window['TrustedURL'] = tt.TrustedURL;\n window['TrustedScriptURL'] = tt.TrustedScriptURL;\n window['TrustedScript'] = tt.TrustedScript;\n window['TrustedTypePolicy'] = TrustedTypePolicy;\n window['TrustedTypePolicyFactory'] = TrustedTypePolicyFactory;\n}\n\nsetupPolyfill();\n\nexport default tt;\n"]} \ No newline at end of file diff --git a/dist/es6/trustedtypes.build.js b/dist/es6/trustedtypes.build.js index f83fa01f..6c5a63fd 100644 --- a/dist/es6/trustedtypes.build.js +++ b/dist/es6/trustedtypes.build.js @@ -8,16 +8,16 @@ */ 'use strict';function aa(a){const b=/\s+/;return a.trim().split(/\s*;\s*/).map(c=>c.split(b)).reduce(function(c,d){d[0]&&(c[d[0]]=d.slice(1).map(f=>f).sort());return c},{})}function ba(a){const b=aa(a),c="require-trusted-types-for"in b&&b["require-trusted-types-for"].includes("'script'");let d=["*"],f=!0;"trusted-types"in b&&(d=b["trusted-types"].filter(k=>"'"!==k.charAt(0)),f=b["trusted-types"].includes("'allow-duplicates'"));return new ca(!0,c,d,f,a)} class ca{constructor(a,b,c,d,f=null){this.c=a;this.a=b;this.b=c;this.f=d;this.h=f}};const da="onabort onactivate onactivateinvisible onafterprint onafterupdate onanimationcancel onanimationend onanimationiteration onanimationstart onariarequest onauxclick onbeforeactivate onbeforecopy onbeforecut onbeforedeactivate onbeforeeditfocus onbeforepaste onbeforeprint onbeforeunload onbegin onblur onbounce oncancel oncanplay oncanplaythrough oncellchange onchange onclick onclose oncommand oncontextmenu oncontrolselect oncopy oncuechange oncut ondataavailable ondatasetchanged ondatasetcomplete ondblclick ondeactivate ondrag ondragdrop ondragend ondragenter ondragexit ondragleave ondragover ondragstart ondrop ondurationchange onemptied onend onended onerror onerrorupdate onexit onfilterchange onfinish onfocus onfocusin onfocusout onformdata onfullscreenchange onfullscreenerror ongotpointercapture onhelp oninput oninvalid onkeydown onkeypress onkeyup onlayoutcomplete onload onloadeddata onloadedmetadata onloadend onloadstart onlosecapture onlostpointercapture onmediacomplete onmediaerror onmessage onmousedown onmouseenter onmouseleave onmousemove onmouseout onmouseover onmouseup onmousewheel onmove onmoveend onmovestart onmozfullscreenchange onmozfullscreenerror onmscontentzoom onmsgesturechange onmsgesturedoubletap onmsgestureend onmsgesturehold onmsgesturestart onmsgesturetap onmsgotpointercapture onmsinertiastart onmslostpointercapture onmsmanipulationstatechanged onmspointercancel onmspointerdown onmspointerenter onmspointerleave onmspointermove onmspointerout onmspointerover onmspointerup onoffline ononline onoutofsync onoverscroll onpaste onpause onplay onplaying onpointercancel onpointerdown onpointerenter onpointerleave onpointermove onpointerout onpointerover onpointerrawupdate onpointerup onprogress onpropertychange onratechange onreadystatechange onrepeat onreset onresize onresizeend onresizestart onresume onreverse onrowdelete onrowenter onrowexit onrowinserted onscroll onscrollend onsearch onseek onseeked onseeking onselect onselectionchange onselectstart onshow onstalled onstart onstop onstorage onsubmit onsuspend onsynchrestored ontimeerror ontimeupdate ontoggle ontrackchange ontransitioncancel ontransitionend ontransitionrun ontransitionstart onunload onurlflip onvolumechange onwaiting onwebkitanimationend onwebkitanimationiteration onwebkitanimationstart onwebkitfullscreenchange onwebkitfullscreenerror onwebkittransitionend onwheel".split(" "); -function ea(){if("undefined"!==typeof window){const a=[];for(const b in HTMLElement.prototype)"on"===b.slice(0,2)&&a.push(b);return a}return da};const fa="undefined"!==typeof window,ma=()=>{throw new TypeError("undefined conversion");},na=()=>null,{toLowerCase:oa,toUpperCase:pa}=String.prototype;function qa(){throw new TypeError("Illegal constructor");}function g(){throw new TypeError("Illegal constructor");} -const {G:t,F:ra,s:sa}=function(){function a(e){let h=R.get(e);void 0===h&&(h=m(null),R.set(e,h));return h}function b(e){const h=ha(e);if(null==h||ha(h)!==ia)throw Error();for(const n of S(h))z(e,n,{value:e[n]});return e}function c(e,h){w(e.prototype);delete e.name;z(e,"name",{value:h})}function d(e){return h=>h instanceof e&&R.has(h)}function f(e,h){function n(A,T){const Ea=h[T]||("default"==e?na:ma),Fa=w(new A(L,e));return w({[T](x,...M){x=Ea(""+x,...M);if(void 0===x||null===x){if("default"==e)return x; -x=""}x=""+x;M=w(m(Fa));a(M).v=x;return M}}[T])}const l=m(qa.prototype);for(const A of S(N))l[A]=n(N[A],A);z(l,"name",{value:e,writable:!1,configurable:!1,enumerable:!0});return w(l)}function k(e,h,n,l="",A=""){e=pa.apply(String(e));(l=A?A:l)||(l="http://www.w3.org/1999/xhtml");if(l=G.apply(u,[l])?u[l]:null){if(G.apply(l,[e])&&l[e]&&G.apply(l[e][h],[n])&&l[e][h][n])return l[e][h][n];if(G.apply(l,["*"])&&G.apply(l["*"][h],[n])&&l["*"][h][n])return l["*"][h][n]}}function p(){return H}const {assign:q, -create:m,defineProperty:z,freeze:w,getOwnPropertyNames:S,getPrototypeOf:ha,prototype:ia}=Object,{hasOwnProperty:G}=ia,{forEach:Ga,push:Ha}=Array.prototype,L=Symbol(),R=b(new WeakMap),E=b([]),U=b([]);let ja=!0,H=null,O=!1;class I{constructor(e,h){if(e!==L)throw Error("cannot call the constructor");z(this,"policyName",{value:h,enumerable:!0})}toString(){return a(this).v}valueOf(){return a(this).v}}class r extends I{}c(r,"TrustedURL");class B extends I{}c(B,"TrustedScriptURL");class C extends I{}c(C, +function ea(){if("undefined"!==typeof window){const a=[];for(const b in HTMLElement.prototype)"on"===b.slice(0,2)&&a.push(b);return a}return da};const fa="undefined"!==typeof window,ma=()=>{throw new TypeError("undefined conversion");},na=()=>null,{toLowerCase:oa,toUpperCase:pa}=String.prototype;function qa(){throw new TypeError("Illegal constructor");}function h(){throw new TypeError("Illegal constructor");} +const {G:t,F:ra,s:sa}=function(){function a(e){let g=R.get(e);void 0===g&&(g=m(null),R.set(e,g));return g}function b(e){const g=ha(e);if(null==g||ha(g)!==ia)throw Error();for(const n of S(g))z(e,n,{value:e[n]});return e}function c(e,g){w(e.prototype);delete e.name;z(e,"name",{value:g})}function d(e){return g=>g instanceof e&&R.has(g)}function f(e,g){function n(A,T){const Ea=g[T]||("default"==e?na:ma),Fa=w(new A(L,e));return w({[T](x,...M){x=Ea(""+x,...M);if(void 0===x||null===x){if("default"==e)return x; +x=""}x=""+x;M=w(m(Fa));a(M).v=x;return M}}[T])}const l=m(qa.prototype);for(const A of S(N))l[A]=n(N[A],A);z(l,"name",{value:e,writable:!1,configurable:!1,enumerable:!0});return w(l)}function k(e,g,n,l="",A=""){e=pa.apply(String(e));(l=A?A:l)||(l="http://www.w3.org/1999/xhtml");if(l=F.apply(u,[l])?u[l]:null){if(F.apply(l,[e])&&l[e]&&F.apply(l[e][g],[n])&&l[e][g][n])return l[e][g][n];if(F.apply(l,["*"])&&F.apply(l["*"][g],[n])&&l["*"][g][n])return l["*"][g][n]}}function p(){return G}const {assign:q, +create:m,defineProperty:z,freeze:w,getOwnPropertyNames:S,getPrototypeOf:ha,prototype:ia}=Object,{hasOwnProperty:F}=ia,{forEach:Ga,push:Ha}=Array.prototype,L=Symbol(),R=b(new WeakMap),H=b([]),U=b([]);let ja=!0,G=null,O=!1;class I{constructor(e,g){if(e!==L)throw Error("cannot call the constructor");z(this,"policyName",{value:g,enumerable:!0})}toString(){return a(this).v}valueOf(){return a(this).v}}class r extends I{}c(r,"TrustedURL");class B extends I{}c(B,"TrustedScriptURL");class C extends I{}c(C, "TrustedHTML");class y extends I{}c(y,"TrustedScript");c(I,"TrustedType");const ka=w(m(new C(L,"")));a(ka).v="";const la=w(m(new y(L,"")));a(la).v="";const u={["http://www.w3.org/1999/xhtml"]:{A:{attributes:{href:r.name}},AREA:{attributes:{href:r.name}},BASE:{attributes:{href:r.name}},BUTTON:{attributes:{formaction:r.name}},EMBED:{attributes:{src:B.name}},FORM:{attributes:{action:r.name}},FRAME:{attributes:{src:r.name}},IFRAME:{attributes:{src:r.name,srcdoc:C.name}},INPUT:{attributes:{formaction:r.name}}, -OBJECT:{attributes:{data:B.name,codebase:B.name}},SCRIPT:{attributes:{src:B.name,text:y.name},properties:{innerText:y.name,textContent:y.name,text:y.name}},"*":{attributes:{},properties:{innerHTML:C.name,outerHTML:C.name}}},["http://www.w3.org/1999/xlink"]:{"*":{attributes:{href:r.name},properties:{}}},["http://www.w3.org/2000/svg"]:{"*":{attributes:{href:r.name},properties:{}}}};var F={codebase:"codeBase",formaction:"formAction"};!fa||"srcdoc"in HTMLIFrameElement.prototype||delete u["http://www.w3.org/1999/xhtml"].IFRAME.attributes.srcdoc; -for(const e of Object.keys(u["http://www.w3.org/1999/xhtml"])){u["http://www.w3.org/1999/xhtml"][e].properties||(u["http://www.w3.org/1999/xhtml"][e].properties={});for(const h of Object.keys(u["http://www.w3.org/1999/xhtml"][e].attributes))u["http://www.w3.org/1999/xhtml"][e].properties[F[h]?F[h]:h]=u["http://www.w3.org/1999/xhtml"][e].attributes[h]}for(const e of ea())u["http://www.w3.org/1999/xhtml"]["*"].attributes[e]="TrustedScript",u["http://www.w3.org/2000/svg"]["*"].attributes[e]="TrustedScript"; -const N={createHTML:C,createScriptURL:B,createURL:r,createScript:y},Ia=N.hasOwnProperty;F=m(g.prototype);q(F,{createPolicy:function(e,h){if(!e.match(/^[-#a-zA-Z0-9=_/@.%]+$/g))throw new TypeError("Policy "+e+" contains invalid characters.");if(O&&-1===U.indexOf(e))throw new TypeError("Policy "+e+" disallowed.");if("default"===e&&H)throw new TypeError("Policy "+e+" already exists.");if(O&&!ja&&-1!==E.indexOf(e))throw new TypeError("Policy "+e+" exists.");E.push(e);const n=m(null);if(h&&"object"=== -typeof h)for(const l of S(h))Ia.call(N,l)&&(n[l]=h[l]);else console.warn("trustedTypes.createPolicy "+e+" was given an empty policy");w(n);h=f(e,n);"default"===e&&(H=h);return h},getPolicyNames:function(){return E.slice()},l:d(C),o:d(r),m:d(B),g:d(y),i:function(e,h,n="",l=""){h=oa.apply(String(h));return k(e,"attributes",h,n,l)||null},B:function(e,h,n=""){return k(e,"properties",String(h),n)||null},j:function(e=""){if(!e)try{e=document.documentElement.namespaceURI}catch(h){e="http://www.w3.org/1999/xhtml"}return(e= -u[e])?JSON.parse(JSON.stringify(e)):{}},u:ka,w:la,H,TrustedHTML:C,TrustedURL:r,TrustedScriptURL:B,TrustedScript:y});z(F,"defaultPolicy",{get:p,set:()=>{}});return{G:w(F),F:function(e,h){O=!0;U.length=0;Ga.call(e,n=>{Ha.call(U,""+n)});ja=h;E.length=0},s:function(){O=!1},I:p,J:function(){H=null;E.splice(E.indexOf("default"),1)}}}();const {defineProperty:v}=Object;function ta(a,b,c){v(a,b,{value:c})};const {apply:D}=Reflect,{getOwnPropertyNames:ua,getOwnPropertyDescriptor:J,getPrototypeOf:va}=Object,{hasOwnProperty:K}=Object.prototype,{slice:wa}=String.prototype,xa="function"==typeof window.URL?URL.prototype.constructor:null;let ya; +OBJECT:{attributes:{data:B.name,codebase:B.name}},SCRIPT:{attributes:{src:B.name,text:y.name},properties:{innerText:y.name,textContent:y.name,text:y.name}},"*":{attributes:{},properties:{innerHTML:C.name,outerHTML:C.name}}},["http://www.w3.org/1999/xlink"]:{"*":{attributes:{href:r.name},properties:{}}},["http://www.w3.org/2000/svg"]:{"*":{attributes:{href:r.name},properties:{}}}};var E={codebase:"codeBase",formaction:"formAction"};!fa||"srcdoc"in HTMLIFrameElement.prototype||delete u["http://www.w3.org/1999/xhtml"].IFRAME.attributes.srcdoc; +for(const e of Object.keys(u["http://www.w3.org/1999/xhtml"])){u["http://www.w3.org/1999/xhtml"][e].properties||(u["http://www.w3.org/1999/xhtml"][e].properties={});for(const g of Object.keys(u["http://www.w3.org/1999/xhtml"][e].attributes))u["http://www.w3.org/1999/xhtml"][e].properties[E[g]?E[g]:g]=u["http://www.w3.org/1999/xhtml"][e].attributes[g]}for(const e of ea())u["http://www.w3.org/1999/xhtml"]["*"].attributes[e]="TrustedScript",u["http://www.w3.org/2000/svg"]["*"].attributes[e]="TrustedScript"; +const N={createHTML:C,createScriptURL:B,createURL:r,createScript:y},Ia=N.hasOwnProperty;E=m(h.prototype);q(E,{createPolicy:function(e,g){if(!e.match(/^[-#a-zA-Z0-9=_/@.%]+$/g))throw new TypeError("Policy "+e+" contains invalid characters.");if(O&&-1===U.indexOf(e))throw new TypeError("Policy "+e+" disallowed.");if("default"===e&&G)throw new TypeError("Policy "+e+" already exists.");if(O&&!ja&&-1!==H.indexOf(e))throw new TypeError("Policy "+e+" exists.");H.push(e);const n=m(null);if(g&&"object"=== +typeof g)for(const l of S(g))Ia.call(N,l)&&(n[l]=g[l]);else console.warn("trustedTypes.createPolicy "+e+" was given an empty policy");w(n);g=f(e,n);"default"===e&&(G=g);return g},l:d(C),o:d(r),m:d(B),g:d(y),i:function(e,g,n="",l=""){g=oa.apply(String(g));return k(e,"attributes",g,n,l)||null},B:function(e,g,n=""){return k(e,"properties",String(g),n)||null},j:function(e=""){if(!e)try{e=document.documentElement.namespaceURI}catch(g){e="http://www.w3.org/1999/xhtml"}return(e=u[e])?JSON.parse(JSON.stringify(e)): +{}},u:ka,w:la,H:G,TrustedHTML:C,TrustedURL:r,TrustedScriptURL:B,TrustedScript:y});z(E,"defaultPolicy",{get:p,set:()=>{}});return{G:w(E),F:function(e,g){O=!0;U.length=0;Ga.call(e,n=>{Ha.call(U,""+n)});ja=g;H.length=0},s:function(){O=!1},I:p,J:function(){G=null;H.splice(H.indexOf("default"),1)}}}();const {defineProperty:v}=Object;function ta(a,b,c){v(a,b,{value:c})};const {apply:D}=Reflect,{getOwnPropertyNames:ua,getOwnPropertyDescriptor:J,getPrototypeOf:va}=Object,{hasOwnProperty:K}=Object.prototype,{slice:wa}=String.prototype,xa="function"==typeof window.URL?URL.prototype.constructor:null;let ya; const P=document.createElement("div").constructor.name?a=>a.name:a=>(""+a).match(/^\[object (\S+)\]$/)[1],za=J(window,"open")?window:window.constructor.prototype,Aa=D(K,Element.prototype,["insertAdjacentHTML"])?Element.prototype:HTMLElement.prototype,Ba=window.SecurityPolicyViolationEvent||null,Q=t.j("http://www.w3.org/1999/xhtml"),V={TrustedHTML:t.TrustedHTML,TrustedScript:t.TrustedScript,TrustedScriptURL:t.TrustedScriptURL,TrustedURL:t.TrustedURL}; for(const a of Object.keys(Q)){const b=Q[a].properties;for(const [c,d]of Object.entries(b))b[c]=V[d]}const W={TrustedHTML:t.l,TrustedURL:t.o,TrustedScriptURL:t.m,TrustedScript:t.g},Ca={TrustedHTML:"createHTML",TrustedURL:"createURL",TrustedScriptURL:"createScriptURL",TrustedScript:"createScript"}; function Da(a,b,c,d){function f(z){a.c.call(a,this,c,d,q,0,[z])}let k=b,p,q;var m=va(Node.prototype);do(q=(p=J(k,c))?p.set:null)||(k=va(k)||m);while(!q&&k!==m&&k);if(!(q instanceof Function))throw new TypeError("No setter for property "+c+" on object"+b);m=X(b,c);if(a.b[m])throw Error(`TrustedTypesEnforcer: Double installation detected: ${m} ${c}`);k===b?v(b,c,{set:f}):v(b,c,{set:f,get:p.get,configurable:!0});a.b[m]=q} @@ -32,8 +32,8 @@ originalPolicy:a.a.h,statusCode:0,violatedDirective:"require-trusted-types-for", class Pa{constructor(a){this.a=a;this.b={}}D(a,b,...c){if(null!==a.constructor&&a instanceof Element){var d=(c[0]=String(c[0])).toLowerCase();if((d=t.i(a.tagName,d,a.namespaceURI))&&D(K,V,[d]))return this.c(a,"setAttribute",V[d],b,1,c)}return D(b,a,c)}C(a,b,...c){if(null!==a.constructor&&a instanceof Element){var d=c[0]?String(c[0]):null;c[0]=d;const f=(c[1]=String(c[1])).toLowerCase();if((d=t.i(a.tagName,f,a.namespaceURI,d))&&D(K,V,[d]))return this.c(a,"setAttributeNS",V[d],b,2,c)}return D(b,a,c)}f(a, b,c,...d){if((b?a.parentNode:a)instanceof HTMLScriptElement&&0} allowedPolicyNames Whitelisted policy names.\n * @param {boolean} allowDuplicates Should duplicate names be allowed.\n * @param {?string} cspString String with the CSP policy.\n */\n constructor(isLoggingEnabled,\n isEnforcementEnabled,\n allowedPolicyNames,\n allowDuplicates,\n cspString = null) {\n /**\n * True if logging is enabled.\n * @type {boolean}\n */\n this.isLoggingEnabled = isLoggingEnabled;\n\n /**\n * True if enforcement is enabled.\n * @type {boolean}\n */\n this.isEnforcementEnabled = isEnforcementEnabled;\n\n /**\n * Allowed policy names.\n * @type {Array}\n */\n this.allowedPolicyNames = allowedPolicyNames;\n\n /**\n * Should duplicate names be accepted.\n * @type {boolean}\n */\n this.allowDuplicates = allowDuplicates;\n\n /**\n * CSP string that defined the policy.\n * @type {?string}\n */\n this.cspString = cspString;\n }\n\n /**\n * Parses a CSP policy.\n * @link https://www.w3.org/TR/CSP3/#parse-serialized-policy\n * @param {string} cspString String with a CSP definition.\n * @return {Object>} Parsed CSP, keyed by directive\n * names.\n */\n static parseCSP(cspString) {\n const SEMICOLON = /\\s*;\\s*/;\n const WHITESPACE = /\\s+/;\n return cspString.trim().split(SEMICOLON)\n .map((serializedDirective) => serializedDirective.split(WHITESPACE))\n .reduce(function(parsed, directive) {\n if (directive[0]) {\n parsed[directive[0]] = directive.slice(1).map((s) => s).sort();\n }\n return parsed;\n }, {});\n }\n\n /**\n * Creates a TrustedTypeConfig object from a CSP string.\n * @param {string} cspString\n * @return {!TrustedTypeConfig}\n */\n static fromCSP(cspString) {\n const isLoggingEnabled = true;\n const policy = TrustedTypeConfig.parseCSP(cspString);\n const enforce = ENFORCEMENT_DIRECTIVE_NAME in policy &&\n policy[ENFORCEMENT_DIRECTIVE_NAME].includes('\\'script\\'');\n let policies = ['*'];\n let allowDuplicates = true;\n if (POLICIES_DIRECTIVE_NAME in policy) {\n policies = policy[POLICIES_DIRECTIVE_NAME].filter(\n (p) => p.charAt(0) !== '\\'');\n allowDuplicates = policy[POLICIES_DIRECTIVE_NAME].includes(\n '\\'allow-duplicates\\'');\n }\n return new TrustedTypeConfig(\n isLoggingEnabled,\n enforce, /* isEnforcementEnabled */\n policies, /* allowedPolicyNames */\n allowDuplicates, /* allowDuplicates */\n cspString\n );\n }\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n// TODO check attributes in safari, remove legacy safe handlers\nconst unsafeAttributeEventHandlers = [\n 'onabort',\n 'onactivate',\n 'onactivateinvisible',\n 'onafterprint',\n 'onafterupdate',\n 'onanimationcancel',\n 'onanimationend',\n 'onanimationiteration',\n 'onanimationstart',\n 'onariarequest',\n 'onauxclick',\n 'onbeforeactivate',\n 'onbeforecopy',\n 'onbeforecut',\n 'onbeforedeactivate',\n 'onbeforeeditfocus',\n 'onbeforepaste',\n 'onbeforeprint',\n 'onbeforeunload',\n 'onbegin',\n 'onblur',\n 'onbounce',\n 'oncancel',\n 'oncanplay',\n 'oncanplaythrough',\n 'oncellchange',\n 'onchange',\n 'onclick',\n 'onclose',\n 'oncommand',\n 'oncontextmenu',\n 'oncontrolselect',\n 'oncopy',\n 'oncuechange',\n 'oncut',\n 'ondataavailable',\n 'ondatasetchanged',\n 'ondatasetcomplete',\n 'ondblclick',\n 'ondeactivate',\n 'ondrag',\n 'ondragdrop',\n 'ondragend',\n 'ondragenter',\n 'ondragexit',\n 'ondragleave',\n 'ondragover',\n 'ondragstart',\n 'ondrop',\n 'ondurationchange',\n 'onemptied',\n 'onend',\n 'onended',\n 'onerror',\n 'onerrorupdate',\n 'onexit',\n 'onfilterchange',\n 'onfinish',\n 'onfocus',\n 'onfocusin',\n 'onfocusout',\n 'onformdata',\n 'onfullscreenchange',\n 'onfullscreenerror',\n 'ongotpointercapture',\n 'onhelp',\n 'oninput',\n 'oninvalid',\n 'onkeydown',\n 'onkeypress',\n 'onkeyup',\n 'onlayoutcomplete',\n 'onload',\n 'onloadeddata',\n 'onloadedmetadata',\n 'onloadend',\n 'onloadstart',\n 'onlosecapture',\n 'onlostpointercapture',\n 'onmediacomplete',\n 'onmediaerror',\n 'onmessage',\n 'onmousedown',\n 'onmouseenter',\n 'onmouseleave',\n 'onmousemove',\n 'onmouseout',\n 'onmouseover',\n 'onmouseup',\n 'onmousewheel',\n 'onmove',\n 'onmoveend',\n 'onmovestart',\n 'onmozfullscreenchange',\n 'onmozfullscreenerror',\n 'onmscontentzoom',\n 'onmsgesturechange',\n 'onmsgesturedoubletap',\n 'onmsgestureend',\n 'onmsgesturehold',\n 'onmsgesturestart',\n 'onmsgesturetap',\n 'onmsgotpointercapture',\n 'onmsinertiastart',\n 'onmslostpointercapture',\n 'onmsmanipulationstatechanged',\n 'onmspointercancel',\n 'onmspointerdown',\n 'onmspointerenter',\n 'onmspointerleave',\n 'onmspointermove',\n 'onmspointerout',\n 'onmspointerover',\n 'onmspointerup',\n 'onoffline',\n 'ononline',\n 'onoutofsync',\n 'onoverscroll',\n 'onpaste',\n 'onpause',\n 'onplay',\n 'onplaying',\n 'onpointercancel',\n 'onpointerdown',\n 'onpointerenter',\n 'onpointerleave',\n 'onpointermove',\n 'onpointerout',\n 'onpointerover',\n 'onpointerrawupdate',\n 'onpointerup',\n 'onprogress',\n 'onpropertychange',\n 'onratechange',\n 'onreadystatechange',\n 'onrepeat',\n 'onreset',\n 'onresize',\n 'onresizeend',\n 'onresizestart',\n 'onresume',\n 'onreverse',\n 'onrowdelete',\n 'onrowenter',\n 'onrowexit',\n 'onrowinserted',\n 'onscroll',\n 'onscrollend',\n 'onsearch',\n 'onseek',\n 'onseeked',\n 'onseeking',\n 'onselect',\n 'onselectionchange',\n 'onselectstart',\n 'onshow',\n 'onstalled',\n 'onstart',\n 'onstop',\n 'onstorage',\n 'onsubmit',\n 'onsuspend',\n 'onsynchrestored',\n 'ontimeerror',\n 'ontimeupdate',\n 'ontoggle',\n 'ontrackchange',\n 'ontransitioncancel',\n 'ontransitionend',\n 'ontransitionrun',\n 'ontransitionstart',\n 'onunload',\n 'onurlflip',\n 'onvolumechange',\n 'onwaiting',\n 'onwebkitanimationend',\n 'onwebkitanimationiteration',\n 'onwebkitanimationstart',\n 'onwebkitfullscreenchange',\n 'onwebkitfullscreenerror',\n 'onwebkittransitionend',\n 'onwheel',\n];\n\n/**\n * Returns an array of all event handlers. Some of the event handlers may be\n * supported only in some browsers.\n *\n * For every event type that the browser supports, SVG supports that as an event\n * attribute, following the same requirements as for HTML event attributes.\n * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/Events\n *\n * @return {!Array}\n */\nexport function getUnsafeAttributeEventHandlers() {\n if (typeof window !== 'undefined') {\n const eventHandlers = [];\n for (const name in HTMLElement.prototype) {\n if (name.slice(0, 2) === 'on') {\n eventHandlers.push(name);\n }\n }\n return eventHandlers;\n } else {\n return unsafeAttributeEventHandlers;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\nimport {getUnsafeAttributeEventHandlers} from './utils/eventHandlers.js';\n\nconst isBrowser = typeof window !== 'undefined';\n\nconst rejectInputFn = (s) => {\n throw new TypeError('undefined conversion');\n};\n\nconst rejectInputDefaultPolicyFn = (s) => null;\n\nconst {toLowerCase, toUpperCase} = String.prototype;\n\nexport const HTML_NS = 'http://www.w3.org/1999/xhtml';\nexport const XLINK_NS = 'http://www.w3.org/1999/xlink';\nexport const SVG_NS = 'http://www.w3.org/2000/svg';\n\n/**\n * @constructor\n * @property {!function(string):TrustedHTML} createHTML\n * @property {!function(string):TrustedURL} createURL\n * @property {!function(string):TrustedScriptURL} createScriptURL\n * @property {!function(string):TrustedScript} createScript\n * @property {!string} name\n */\nexport const TrustedTypePolicy = function() {\n throw new TypeError('Illegal constructor');\n};\n\n/**\n * @constructor\n */\nexport const TrustedTypePolicyFactory = function() {\n throw new TypeError('Illegal constructor');\n};\n\n/* eslint-disable no-unused-vars */\n/**\n * @typedef {TrustedTypesInnerPolicy}\n * @property {function(string):string} createHTML\n * @property {function(string):string} createURL\n * @property {function(string):string} createScriptURL\n * @property {function(string):string} createScript\n */\nconst TrustedTypesInnerPolicy = {};\n\n/**\n * @typedef {!Object,\n * properties: !Object}>}\n */\nconst TrustedTypesTypeMap = {};\n/* eslint-enable no-unused-vars */\n\nexport const DEFAULT_POLICY_NAME = 'default';\n\n\nexport const trustedTypesBuilderTestOnly = function() {\n // Capture common names early.\n const {\n assign, create, defineProperty, freeze, getOwnPropertyNames,\n getPrototypeOf, prototype: ObjectPrototype,\n } = Object;\n\n const {hasOwnProperty} = ObjectPrototype;\n\n const {\n forEach, push,\n } = Array.prototype;\n\n const creatorSymbol = Symbol();\n\n /**\n * Getter for the privateMap.\n * @param {Object} obj Key of the privateMap\n * @return {Object} Private storage.\n */\n const privates = function(obj) {\n let v = privateMap.get(obj);\n if (v === undefined) {\n v = create(null); // initialize the private storage.\n privateMap.set(obj, v);\n }\n return v;\n };\n\n /**\n * Called before attacker-controlled code on an internal collections,\n * copies prototype members onto the instance directly, so that later\n * changes to prototypes cannot expose collection internals.\n * @param {!T} collection\n * @return {!T} collection\n * @template T\n */\n function selfContained(collection) {\n const proto = getPrototypeOf(collection);\n if (proto == null || getPrototypeOf(proto) !== ObjectPrototype) {\n throw new Error(); // Loop below is insufficient.\n }\n for (const key of getOwnPropertyNames(proto)) {\n defineProperty(collection, key, {value: collection[key]});\n }\n return collection;\n }\n\n /**\n * Map for private properties of Trusted Types object.\n * This is so that the access to the type constructor does not give\n * the ability to create typed values.\n * @type {WeakMap}\n */\n const privateMap = selfContained(new WeakMap());\n\n /**\n * List of all configured policy names.\n * @type {Array}\n */\n const policyNames = selfContained([]);\n\n /**\n * Allowed policy names.\n * Applied only if enforceNameRestrictions is true.\n * @type {Array}\n */\n const allowedNames = selfContained([]);\n\n /**\n * Should duplicate prolicy names be allowed.\n * Applied only if enforceNameRestrictions is true.\n * @type {boolean}\n */\n let allowDuplicateNames = true;\n\n /**\n * A reference to a default policy, if created.\n * @type {TrustedTypePolicy}\n */\n let defaultPolicy = null;\n\n /**\n * Whether to enforce allowedNames in createPolicy().\n * @type {boolean}\n */\n let enforceNameRestrictions = false;\n\n\n /**\n * A value that is trusted to have certain security-relevant properties\n * because the sources of such values are controlled.\n */\n class TrustedType {\n /**\n * Constructor for TrustedType. Only allowed to be called from within a\n * policy.\n * @param {symbol} s creatorSymbol\n * @param {string} policyName The name of the policy this object was\n * created by.\n */\n constructor(s, policyName) {\n // TODO: Figure out if symbol is needed, if the value is in privateMap.\n if (s !== creatorSymbol) {\n throw new Error('cannot call the constructor');\n }\n defineProperty(this, 'policyName',\n {value: '' + policyName, enumerable: true});\n }\n\n /**\n * Returns the wrapped string value of the object.\n * @return {string}\n * @override\n */\n toString() {\n return privates(this)['v'];\n }\n\n /**\n * Returns the wrapped string value of the object.\n * @return {string}\n * @override\n */\n valueOf() {\n return privates(this)['v'];\n }\n }\n\n /**\n * @param {function(new:TrustedType, symbol, string)} SubClass\n * @param {string} canonName The class name which should be independent of\n * any renaming pass and which is relied upon by the enforcer and for\n * native type interop.\n */\n function lockdownTrustedType(SubClass, canonName) {\n freeze(SubClass.prototype);\n delete SubClass.name;\n defineProperty(SubClass, 'name', {value: canonName});\n }\n\n /**\n * Trusted URL object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedURL extends TrustedType {\n }\n lockdownTrustedType(TrustedURL, 'TrustedURL');\n\n /**\n * Trusted Script URL object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedScriptURL extends TrustedType {\n }\n lockdownTrustedType(TrustedScriptURL, 'TrustedScriptURL');\n\n /**\n * Trusted HTML object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedHTML extends TrustedType {\n }\n lockdownTrustedType(TrustedHTML, 'TrustedHTML');\n\n /**\n * Trusted Script object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedScript extends TrustedType {\n }\n lockdownTrustedType(TrustedScript, 'TrustedScript');\n\n lockdownTrustedType(TrustedType, 'TrustedType');\n\n // Common constants.\n const emptyHTML = freeze(create(new TrustedHTML(creatorSymbol, '')));\n privates(emptyHTML)['v'] = '';\n const emptyScript = freeze(create(new TrustedScript(creatorSymbol, '')));\n privates(emptyScript)['v'] = '';\n\n /**\n * A map of attribute / property names to allowed types\n * for known namespaces.\n * @type {!Object}\n * @export\n */\n const TYPE_MAP = {\n [HTML_NS]: {\n // TODO(koto): Figure out what to to with \n 'A': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'AREA': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'BASE': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'BUTTON': {\n 'attributes': {\n 'formaction': TrustedURL.name,\n },\n },\n 'EMBED': {\n 'attributes': {\n 'src': TrustedScriptURL.name,\n },\n },\n 'FORM': {\n 'attributes': {\n 'action': TrustedURL.name,\n },\n },\n 'FRAME': {\n 'attributes': {\n 'src': TrustedURL.name,\n },\n },\n 'IFRAME': {\n 'attributes': {\n 'src': TrustedURL.name,\n 'srcdoc': TrustedHTML.name,\n },\n },\n 'INPUT': {\n 'attributes': {\n 'formaction': TrustedURL.name,\n },\n },\n 'OBJECT': {\n 'attributes': {\n 'data': TrustedScriptURL.name,\n 'codebase': TrustedScriptURL.name,\n },\n },\n // TODO(koto): Figure out what to do with portals.\n 'SCRIPT': {\n 'attributes': {\n 'src': TrustedScriptURL.name,\n 'text': TrustedScript.name,\n },\n 'properties': {\n 'innerText': TrustedScript.name,\n 'textContent': TrustedScript.name,\n 'text': TrustedScript.name,\n },\n },\n '*': {\n 'attributes': {},\n 'properties': {\n 'innerHTML': TrustedHTML.name,\n 'outerHTML': TrustedHTML.name,\n },\n },\n },\n [XLINK_NS]: {\n '*': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n 'properties': {},\n },\n },\n [SVG_NS]: {\n '*': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n 'properties': {},\n },\n },\n };\n\n /**\n * A map of element property to HTML attribute names.\n * @type {!Object}\n */\n const ATTR_PROPERTY_MAP = {\n 'codebase': 'codeBase',\n 'formaction': 'formAction',\n };\n\n // Edge doesn't support srcdoc.\n if (isBrowser && !('srcdoc' in HTMLIFrameElement.prototype)) {\n delete TYPE_MAP[HTML_NS]['IFRAME']['attributes']['srcdoc'];\n }\n\n // in HTML, clone attributes into properties.\n for (const tag of Object.keys(TYPE_MAP[HTML_NS])) {\n if (!TYPE_MAP[HTML_NS][tag]['properties']) {\n TYPE_MAP[HTML_NS][tag]['properties'] = {};\n }\n for (const attr of Object.keys(TYPE_MAP[HTML_NS][tag]['attributes'])) {\n TYPE_MAP[HTML_NS][tag]['properties'][\n ATTR_PROPERTY_MAP[attr] ? ATTR_PROPERTY_MAP[attr] : attr\n ] = TYPE_MAP[HTML_NS][tag]['attributes'][attr];\n }\n }\n\n // Add inline event handlers attribute names.\n for (const name of getUnsafeAttributeEventHandlers()) {\n TYPE_MAP[HTML_NS]['*']['attributes'][name] = 'TrustedScript';\n TYPE_MAP[SVG_NS]['*']['attributes'][name] = 'TrustedScript';\n }\n\n /**\n * @type {!Object}\n */\n const createTypeMapping = {\n 'createHTML': TrustedHTML,\n 'createScriptURL': TrustedScriptURL,\n 'createURL': TrustedURL,\n 'createScript': TrustedScript,\n };\n\n const createFunctionAllowed = createTypeMapping.hasOwnProperty;\n\n /**\n * Function generating a type checker.\n * @template T\n * @param {T} type The type to check against.\n * @return {function(*):boolean}\n */\n function isTrustedTypeChecker(type) {\n return (obj) => (obj instanceof type) && privateMap.has(obj);\n }\n\n /**\n * Wraps a user-defined policy rules with TT constructor\n * @param {string} policyName The policy name\n * @param {TrustedTypesInnerPolicy} innerPolicy InnerPolicy\n * @return {!TrustedTypePolicy} Frozen policy object\n */\n function wrapPolicy(policyName, innerPolicy) {\n /**\n * @template T\n * @param {function(new:T, symbol, string)} Ctor a trusted type constructor\n * @param {string} methodName the policy factory method name\n * @return {function(string):!T} a factory that produces instances of Ctor.\n */\n function creator(Ctor, methodName) {\n // This causes thisValue to be null when called below.\n const method = innerPolicy[methodName] || (\n policyName == DEFAULT_POLICY_NAME ?\n rejectInputDefaultPolicyFn : rejectInputFn\n );\n const policySpecificType = freeze(new Ctor(creatorSymbol, policyName));\n const factory = {\n [methodName](s, ...args) {\n // Trick to get methodName to show in stacktrace.\n let result = method('' + s, ...args);\n if (result === undefined || result === null) {\n if (policyName == DEFAULT_POLICY_NAME) {\n // These values mean that the input was rejected. This will cause\n // a violation later, don't create types for them.\n return result;\n }\n result = '';\n }\n const allowedValue = '' + result;\n const o = freeze(create(policySpecificType));\n privates(o)['v'] = allowedValue;\n return o;\n },\n }[methodName];\n return freeze(factory);\n }\n\n const policy = create(TrustedTypePolicy.prototype);\n\n for (const name of getOwnPropertyNames(createTypeMapping)) {\n policy[name] = creator(createTypeMapping[name], name);\n }\n defineProperty(policy, 'name', {\n value: policyName,\n writable: false,\n configurable: false,\n enumerable: true,\n });\n\n return /** @type {!TrustedTypePolicy} */ (freeze(policy));\n }\n\n /**\n * Returns the name of the trusted type required for a given element\n * attribute.\n * @param {string} tagName The name of the tag of the element.\n * @param {string} attribute The name of the attribute.\n * @param {string=} elementNs Element namespace.\n * @param {string=} attributeNs The attribute namespace.\n * @return {string?} Required type name or null, if a Trusted\n * Type is not required.\n */\n function getAttributeType(tagName, attribute, elementNs = '',\n attributeNs = '') {\n const canonicalAttr = toLowerCase.apply(String(attribute));\n return getTypeInternal_(tagName, 'attributes', canonicalAttr,\n elementNs, attributeNs) || null;\n }\n\n /**\n * Returns a type name from a type map.\n * @param {string} tag A tag name.\n * @param {string} container 'attributes' or 'properties'\n * @param {string} name The attribute / property name.\n * @param {string=} elNs Element namespace.\n * @param {string=} attrNs Attribute namespace.\n * @return {string|undefined}\n * @private\n */\n function getTypeInternal_(tag, container, name, elNs = '', attrNs = '') {\n const canonicalTag = toUpperCase.apply(String(tag));\n\n let ns = attrNs ? attrNs : elNs;\n if (!ns) {\n ns = HTML_NS;\n }\n const map = hasOwnProperty.apply(TYPE_MAP, [ns]) ? TYPE_MAP[ns] : null;\n if (!map) {\n return;\n }\n if (hasOwnProperty.apply(map, [canonicalTag]) &&\n map[canonicalTag] &&\n hasOwnProperty.apply(map[canonicalTag][container], [name]) &&\n map[canonicalTag][container][name]) {\n return map[canonicalTag][container][name];\n }\n\n if (hasOwnProperty.apply(map, ['*']) &&\n hasOwnProperty.apply(map['*'][container], [name]) &&\n map['*'][container][name]) {\n return map['*'][container][name];\n }\n }\n\n /**\n * Returns the name of the trusted type required for a given element property.\n * @param {string} tagName The name of the tag of the element.\n * @param {string} property The property.\n * @param {string=} elementNs Element namespace.\n * @return {string?} Required type name or null, if a Trusted\n * Type is not required.\n */\n function getPropertyType(tagName, property, elementNs = '') {\n // TODO: Support namespaces.\n return getTypeInternal_(\n tagName, 'properties', String(property), elementNs) || null;\n }\n\n /**\n * Returns the type map-like object, that resolves a name of a type for a\n * given tag + attribute / property in a given namespace.\n * The keys of the map are uppercase tag names. Map entry has mappings between\n * a lowercase attribute name / case-sensitive property name and a name of the\n * type that is required for that attribute / property.\n * Example entry for 'IMG': {\"attributes\": {\"src\": \"TrustedHTML\"}}\n * @param {string=} namespaceUri The namespace URI (will use the current\n * document namespace URI if omitted).\n * @return {TrustedTypesTypeMap}\n */\n function getTypeMapping(namespaceUri = '') {\n if (!namespaceUri) {\n try {\n namespaceUri = document.documentElement.namespaceURI;\n } catch (e) {\n namespaceUri = HTML_NS;\n }\n }\n /**\n * @template T\n * @private\n * @param {T} o\n * @return {T}\n */\n function deepClone(o) {\n return JSON.parse(JSON.stringify(o));\n }\n const map = TYPE_MAP[namespaceUri];\n if (!map) {\n return {};\n }\n return deepClone(map);\n }\n\n /**\n * Returns all configured policy names (even for non-exposed policies).\n * @return {!Array}\n */\n function getPolicyNames() {\n // TODO(msamuel): Should we sort policyNames to avoid leaking or\n // encouraging dependency on the order in which policy names are\n // registered? I think JavaScript builtin sorts are efficient for\n // almost-sorted lists so the amortized cost is close to O(n).\n return policyNames.slice();\n }\n\n /**\n * Creates a TT policy.\n *\n * Returns a frozen object representing a policy - a collection of functions\n * that may create TT objects based on the user-provided rules specified\n * in the policy object.\n *\n * @param {string} name A unique name of the policy.\n * @param {TrustedTypesInnerPolicy} policy Policy rules object.\n * @return {TrustedTypePolicy} The policy that may create TT objects\n * according to the policy rules.\n */\n function createPolicy(name, policy) {\n const pName = '' + name; // Assert it's a string\n\n if (!pName.match(/^[-#a-zA-Z0-9=_/@.%]+$/g)) {\n throw new TypeError('Policy ' + pName + ' contains invalid characters.');\n }\n\n if (enforceNameRestrictions && allowedNames.indexOf(pName) === -1) {\n throw new TypeError('Policy ' + pName + ' disallowed.');\n }\n\n if (pName === DEFAULT_POLICY_NAME && defaultPolicy) {\n throw new TypeError('Policy ' + pName + ' already exists.');\n }\n if (enforceNameRestrictions && !allowDuplicateNames &&\n policyNames.indexOf(pName) !== -1) {\n throw new TypeError('Policy ' + pName + ' exists.');\n }\n // Register the name early so that if policy getters unwisely calls\n // across protection domains to code that reenters this function,\n // policy author still has rights to the name.\n policyNames.push(pName);\n\n // Only copy own properties of names present in createTypeMapping.\n const innerPolicy = create(null);\n if (policy && typeof policy === 'object') {\n // Treat non-objects as empty policies.\n for (const key of getOwnPropertyNames(policy)) {\n if (createFunctionAllowed.call(createTypeMapping, key)) {\n innerPolicy[key] = policy[key];\n }\n }\n } else {\n // eslint-disable-next-line no-console\n console.warn('trustedTypes.createPolicy ' + pName +\n ' was given an empty policy');\n }\n freeze(innerPolicy);\n\n const wrappedPolicy = wrapPolicy(pName, innerPolicy);\n\n if (pName === DEFAULT_POLICY_NAME) {\n defaultPolicy = wrappedPolicy;\n }\n\n return wrappedPolicy;\n }\n\n /**\n * Applies the policy name restrictions.\n * @param {!Array} allowedPolicyNames\n * @param {boolean} allowDuplicates\n */\n function setPolicyNameRestrictions(allowedPolicyNames, allowDuplicates) {\n enforceNameRestrictions = true;\n allowedNames.length = 0;\n forEach.call(allowedPolicyNames, (el) => {\n push.call(allowedNames, '' + el);\n });\n allowDuplicateNames = allowDuplicates;\n policyNames.length = 0; // Clear already used policy names list.\n }\n\n /**\n * Clears the policy name restrictions.\n */\n function clearPolicyNameRestrictions() {\n enforceNameRestrictions = false;\n }\n\n /**\n * Returns the default policy, or null if it was not created.\n * @return {TrustedTypePolicy}\n */\n function getDefaultPolicy() {\n return defaultPolicy;\n }\n\n /**\n * Resets the default policy.\n */\n function resetDefaultPolicy() {\n defaultPolicy = null;\n policyNames.splice(policyNames.indexOf(DEFAULT_POLICY_NAME), 1);\n }\n\n const api = create(TrustedTypePolicyFactory.prototype);\n assign(api, {\n // The main function to create policies.\n createPolicy,\n\n getPolicyNames,\n\n // Type checkers, also validating the object was initialized through a\n // policy.\n isHTML: isTrustedTypeChecker(TrustedHTML),\n isURL: isTrustedTypeChecker(TrustedURL),\n isScriptURL: isTrustedTypeChecker(TrustedScriptURL),\n isScript: isTrustedTypeChecker(TrustedScript),\n\n getAttributeType,\n getPropertyType,\n getTypeMapping,\n emptyHTML,\n emptyScript,\n defaultPolicy, // Just to make the compiler happy, this is overridden below.\n\n TrustedHTML: TrustedHTML,\n TrustedURL: TrustedURL,\n TrustedScriptURL: TrustedScriptURL,\n TrustedScript: TrustedScript,\n });\n\n defineProperty(api, 'defaultPolicy', {\n get: getDefaultPolicy,\n set: () => {},\n });\n\n return {\n trustedTypes: freeze(api),\n setPolicyNameRestrictions,\n clearPolicyNameRestrictions,\n getDefaultPolicy,\n resetDefaultPolicy,\n };\n};\n\n\nexport const {\n trustedTypes,\n setPolicyNameRestrictions,\n clearPolicyNameRestrictions,\n getDefaultPolicy,\n resetDefaultPolicy,\n} = trustedTypesBuilderTestOnly();\n\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\nconst {\n defineProperty,\n} = Object;\n\n/**\n * Installs the setter of a given property.\n * @param {!Object} object An object for which to wrap the property.\n * @param {string} name The name of the property to wrap.\n * @param {function(*): *|undefined} setter A setter function}\n */\nexport function installSetter(object, name, setter) {\n const descriptor = {\n set: setter,\n };\n defineProperty(object, name, descriptor);\n}\n\n/**\n * Installs a setter and getter of a given property.\n * @param {!Object} object An object for which to wrap the property.\n * @param {string} name The name of the property to wrap.\n * @param {function(*): *|undefined} setter A setter function}\n * @param {function(*): *|undefined} getter A getter function}\n */\nexport function installSetterAndGetter(object, name, setter, getter) {\n const descriptor = {\n set: setter,\n get: getter,\n configurable: true, // This can get uninstalled, we need configurable: true\n };\n defineProperty(object, name, descriptor);\n}\n\n/**\n * Installs the setter of a given property.\n * @param {!Object} object An object for which to wrap the property.\n * @param {string} name The name of the property to wrap.\n * @param {function(*): *|undefined} fn A function}\n */\nexport function installFunction(object, name, fn) {\n defineProperty(object, name, {\n value: fn,\n });\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n// TrustedTypeConfig is used only as jsdoc type\n// eslint-disable-next-line\nimport {ENFORCEMENT_DIRECTIVE_NAME, TrustedTypeConfig}\n from './data/trustedtypeconfig.js';\nimport {\n trustedTypes as TrustedTypes,\n setPolicyNameRestrictions,\n clearPolicyNameRestrictions,\n resetDefaultPolicy,\n HTML_NS,\n} from\n './trustedtypes.js';\n\nimport {installFunction, installSetter, installSetterAndGetter}\n from './utils/wrapper.js';\n\nconst {apply} = Reflect;\nconst {\n getOwnPropertyNames,\n getOwnPropertyDescriptor,\n getPrototypeOf,\n} = Object;\n\nconst {\n hasOwnProperty,\n isPrototypeOf,\n} = Object.prototype;\n\nconst {slice} = String.prototype;\n\n// No URL in IE 11.\nconst UrlConstructor = typeof window.URL == 'function' ?\n URL.prototype.constructor :\n null;\n\nlet stringifyForRangeHack;\n\n/**\n * Return object constructor name\n * (their function.name is not available in IE 11).\n * @param {Function} fn\n * @return {string}\n * @private\n */\nconst getConstructorName_ = document.createElement('div').constructor.name ?\n (fn) => fn.name :\n (fn) => ('' + fn).match(/^\\[object (\\S+)\\]$/)[1];\n\n// window.open on IE 11 is set on WindowPrototype\nconst windowOpenObject = getOwnPropertyDescriptor(window, 'open') ?\n window :\n window.constructor.prototype;\n\n// In IE 11, insertAdjacent(HTML|Text) is on HTMLElement prototype\nconst insertAdjacentObject = apply(hasOwnProperty, Element.prototype,\n ['insertAdjacentHTML']) ? Element.prototype : HTMLElement.prototype;\n\n// This is not available in release Firefox :(\n// https://developer.mozilla.org/en-US/docs/Web/API/SecurityPolicyViolationEvent\n// https://bugzilla.mozilla.org/show_bug.cgi?id=1432523\nconst SecurityPolicyViolationEvent = window['SecurityPolicyViolationEvent'] ||\n null;\n\n/**\n * Parses URL, catching all the errors.\n * @param {string} url URL string to parse.\n * @return {URL|null}\n */\nfunction parseUrl_(url) {\n try {\n return new UrlConstructor(url, document.baseURI || undefined);\n } catch (e) {\n return null;\n }\n}\n\n// We don't actually need other namespaces.\n// setAttribute is hooked on Element.prototype, which all elements inherit from,\n// and all sensitive property wrappers are hooked directly on Element as well.\nconst typeMap = TrustedTypes.getTypeMapping(HTML_NS);\n\nconst STRING_TO_TYPE = {\n 'TrustedHTML': TrustedTypes.TrustedHTML,\n 'TrustedScript': TrustedTypes.TrustedScript,\n 'TrustedScriptURL': TrustedTypes.TrustedScriptURL,\n 'TrustedURL': TrustedTypes.TrustedURL,\n};\n\n/**\n * Converts an uppercase tag name to an element constructor function name.\n * Used for property setter hijacking only.\n * @param {string} tagName\n * @return {string}\n */\nfunction convertTagToConstructor(tagName) {\n if (tagName == '*') {\n return 'HTMLElement';\n }\n return getConstructorName_(document.createElement(tagName).constructor);\n}\n\nfor (const tagName of Object.keys(typeMap)) {\n const attrs = typeMap[tagName]['properties'];\n for (const [k, v] of Object.entries(attrs)) {\n attrs[k] = STRING_TO_TYPE[v];\n }\n}\n\n/**\n * Map of type names to type checking function.\n * @type {!Object}\n */\nconst TYPE_CHECKER_MAP = {\n 'TrustedHTML': TrustedTypes.isHTML,\n 'TrustedURL': TrustedTypes.isURL,\n 'TrustedScriptURL': TrustedTypes.isScriptURL,\n 'TrustedScript': TrustedTypes.isScript,\n};\n\n/**\n * Map of type names to type producing function.\n * @type {Object}\n */\nconst TYPE_PRODUCER_MAP = {\n 'TrustedHTML': 'createHTML',\n 'TrustedURL': 'createURL',\n 'TrustedScriptURL': 'createScriptURL',\n 'TrustedScript': 'createScript',\n};\n\n/* eslint-disable no-unused-vars */\n/**\n * @typedef {TrustedTypePolicy}\n * @property {function(string):TrustedHTML} createHTML\n * @property {function(string):TrustedURL} createURL\n * @property {function(string):TrustedScriptURL} createScriptURL\n * @property {function(string):TrustedScript} createScript\n */\nconst TrustedTypePolicy = {};\n/* eslint-enable no-unused-vars */\n\n\n/**\n * An object for enabling trusted type enforcement.\n */\nexport class TrustedTypesEnforcer {\n /**\n * @param {!TrustedTypeConfig} config The configuration for\n * trusted type enforcement.\n */\n constructor(config) {\n /**\n * A configuration for the trusted type enforcement.\n * @private {!TrustedTypeConfig}\n */\n this.config_ = config;\n /**\n * @private {Object}\n */\n this.originalSetters_ = {};\n }\n\n /**\n * Wraps HTML sinks with an enforcement setter, which will enforce\n * trusted types and do logging, if enabled.\n *\n */\n install() {\n if (this.config_.allowedPolicyNames.includes('*')) {\n clearPolicyNameRestrictions();\n } else {\n setPolicyNameRestrictions(this.config_.allowedPolicyNames,\n this.config_.allowDuplicates);\n }\n\n if (!this.config_.isEnforcementEnabled && !this.config_.isLoggingEnabled) {\n return;\n }\n\n if ('ShadowRoot' in window) {\n this.wrapSetter_(ShadowRoot.prototype, 'innerHTML',\n TrustedTypes.TrustedHTML);\n }\n stringifyForRangeHack = (function(doc) {\n const r = doc.createRange();\n // In IE 11 Range.createContextualFragment doesn't stringify its argument.\n const f = r.createContextualFragment(/** @type {string} */ (\n {toString: () => '
'}));\n return f.childNodes.length == 0;\n })(document);\n\n this.wrapWithEnforceFunction_(Range.prototype, 'createContextualFragment',\n TrustedTypes.TrustedHTML, 0);\n\n this.wrapWithEnforceFunction_(insertAdjacentObject,\n 'insertAdjacentHTML',\n TrustedTypes.TrustedHTML, 1);\n\n if (getOwnPropertyDescriptor(Document.prototype, 'write')) {\n // Chrome\n this.wrapWithEnforceFunction_(Document.prototype, 'write',\n TrustedTypes.TrustedHTML, 0);\n this.wrapWithEnforceFunction_(Document.prototype, 'open',\n TrustedTypes.TrustedURL, 0);\n } else {\n // Firefox\n this.wrapWithEnforceFunction_(HTMLDocument.prototype, 'write',\n TrustedTypes.TrustedHTML, 0);\n this.wrapWithEnforceFunction_(HTMLDocument.prototype, 'open',\n TrustedTypes.TrustedURL, 0);\n }\n\n this.wrapWithEnforceFunction_(windowOpenObject, 'open',\n TrustedTypes.TrustedURL, 0);\n\n if ('DOMParser' in window) {\n this.wrapWithEnforceFunction_(DOMParser.prototype, 'parseFromString',\n TrustedTypes.TrustedHTML, 0);\n }\n this.wrapWithEnforceFunction_(window, 'setInterval',\n TrustedTypes.TrustedScript, 0);\n this.wrapWithEnforceFunction_(window, 'setTimeout',\n TrustedTypes.TrustedScript, 0);\n this.wrapSetAttribute_();\n this.installScriptMutatorGuards_();\n this.installPropertySetWrappers_();\n }\n\n /**\n * Removes the original setters.\n */\n uninstall() {\n clearPolicyNameRestrictions();\n\n if (!this.config_.isEnforcementEnabled && !this.config_.isLoggingEnabled) {\n return;\n }\n\n if ('ShadowRoot' in window) {\n this.restoreSetter_(ShadowRoot.prototype, 'innerHTML');\n }\n this.restoreFunction_(Range.prototype, 'createContextualFragment');\n this.restoreFunction_(insertAdjacentObject, 'insertAdjacentHTML');\n this.restoreFunction_(Element.prototype, 'setAttribute');\n this.restoreFunction_(Element.prototype, 'setAttributeNS');\n\n if (getOwnPropertyDescriptor(Document.prototype, 'write')) {\n this.restoreFunction_(Document.prototype, 'write');\n this.restoreFunction_(Document.prototype, 'open');\n } else {\n this.restoreFunction_(HTMLDocument.prototype, 'write');\n this.restoreFunction_(HTMLDocument.prototype, 'open');\n }\n this.restoreFunction_(windowOpenObject, 'open');\n\n if ('DOMParser' in window) {\n this.restoreFunction_(DOMParser.prototype, 'parseFromString');\n }\n this.restoreFunction_(window, 'setTimeout');\n this.restoreFunction_(window, 'setInterval');\n this.uninstallPropertySetWrappers_();\n this.uninstallScriptMutatorGuards_();\n resetDefaultPolicy();\n }\n\n /**\n * Installs type-enforcing wrappers for APIs that allow to modify\n * script element texts.\n * @private\n */\n installScriptMutatorGuards_() {\n const that = this;\n\n ['appendChild', 'insertBefore', 'replaceChild'].forEach((fnName) => {\n this.wrapFunction_(\n Node.prototype,\n fnName,\n /**\n * @this {Node}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.enforceTypeInScriptNodes_\n .bind(that, this, /* checkParent */ false, originalFn)\n .apply(that, args);\n });\n });\n this.wrapFunction_(\n insertAdjacentObject,\n 'insertAdjacentText',\n /**\n * @this {Element}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.insertAdjacentTextWrapper_\n .bind(that, this, originalFn)\n .apply(that, args);\n });\n\n if ('after' in Element.prototype) {\n ['after', 'before', 'replaceWith'].forEach((fnName) => {\n this.wrapFunction_(\n Element.prototype,\n fnName,\n /**\n * @this {Element}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.enforceTypeInScriptNodes_\n .bind(that, this, /* checkParent */ true, originalFn)\n .apply(that, args);\n });\n });\n ['append', 'prepend'].forEach((fnName) => {\n this.wrapFunction_(\n Element.prototype,\n fnName,\n /**\n * @this {Element}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.enforceTypeInScriptNodes_\n .bind(that, this, /* checkParent */ false, originalFn)\n .apply(that, args);\n });\n });\n }\n }\n\n /**\n * Uninstalls type-enforcing wrappers for APIs that allow to modify\n * script element texts.\n * @private\n */\n uninstallScriptMutatorGuards_() {\n this.restoreFunction_(Node.prototype, 'appendChild');\n this.restoreFunction_(Node.prototype, 'insertBefore');\n this.restoreFunction_(Node.prototype, 'replaceChild');\n this.restoreFunction_(insertAdjacentObject, 'insertAdjacentText');\n if ('after' in Element.prototype) {\n ['after', 'before', 'replaceWith', 'append', 'prepend'].forEach(\n (fnName) => this.restoreFunction_(Element.prototype, fnName));\n }\n }\n\n /**\n * Installs wrappers for directly setting properties\n * based on the type map.\n * @private\n */\n installPropertySetWrappers_() {\n /* eslint-disable guard-for-in */\n for (const tag of getOwnPropertyNames(typeMap)) {\n for (const property of getOwnPropertyNames(typeMap[tag]['properties'])) {\n this.wrapSetter_(\n window[convertTagToConstructor(tag)].prototype,\n property,\n typeMap[tag]['properties'][property]);\n }\n }\n }\n\n /**\n * Uninstalls wrappers for directly setting properties\n * based on the type map.\n * @private\n */\n uninstallPropertySetWrappers_() {\n /* eslint-disable guard-for-in */\n for (const tag of getOwnPropertyNames(typeMap)) {\n for (const property of getOwnPropertyNames(typeMap[tag]['properties'])) {\n this.restoreSetter_(\n window[convertTagToConstructor(tag)].prototype,\n property);\n }\n }\n }\n\n /** Wraps set attribute with an enforcement function. */\n wrapSetAttribute_() {\n const that = this;\n this.wrapFunction_(\n Element.prototype,\n 'setAttribute',\n /**\n * @this {TrustedTypesEnforcer}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.setAttributeWrapper_\n .bind(that, this, originalFn)\n .apply(that, args);\n });\n this.wrapFunction_(\n Element.prototype,\n 'setAttributeNS',\n /**\n * @this {TrustedTypesEnforcer}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.setAttributeNSWrapper_\n .bind(that, this, originalFn)\n .apply(that, args);\n });\n }\n\n /**\n * Enforces type checking for Element.prototype.setAttribute.\n * @param {!Object} context The context for the call to the original function.\n * @param {!Function} originalFn The original setAttribute function.\n * @return {*}\n */\n setAttributeWrapper_(context, originalFn, ...args) {\n // Note(slekies): In a normal application constructor should never be null.\n // However, there are no guarantees. If the constructor is null, we cannot\n // determine whether a special type is required. In order to not break the\n // application, we will not do any further type checks and pass the call\n // to setAttribute.\n if (context.constructor !== null && context instanceof Element) {\n const attrName = (args[0] = String(args[0])).toLowerCase();\n const requiredType = TrustedTypes.getAttributeType(context.tagName,\n attrName, context.namespaceURI);\n if (requiredType && apply(hasOwnProperty, STRING_TO_TYPE,\n [requiredType])) {\n return this.enforce_(\n context, 'setAttribute', STRING_TO_TYPE[requiredType],\n originalFn, 1, args);\n }\n }\n return apply(originalFn, context, args);\n }\n\n /**\n * Enforces type checking for Element.prototype.setAttributeNS.\n * @param {!Object} context The context for the call to the original function.\n * @param {!Function} originalFn The original setAttributeNS function.\n * @return {*}\n */\n setAttributeNSWrapper_(context, originalFn, ...args) {\n // See the note from setAttributeWrapper_ above.\n if (context.constructor !== null && context instanceof Element) {\n const ns = args[0] ? String(args[0]) : null;\n args[0] = ns;\n const attrName = (args[1] = String(args[1])).toLowerCase();\n const requiredType = TrustedTypes.getAttributeType(context.tagName,\n attrName, context.namespaceURI, ns);\n if (requiredType && apply(hasOwnProperty, STRING_TO_TYPE,\n [requiredType])) {\n return this.enforce_(context, 'setAttributeNS',\n STRING_TO_TYPE[requiredType],\n originalFn, 2, args);\n }\n }\n return apply(originalFn, context, args);\n }\n\n /**\n * Wrapper for DOM mutator functions that enforces type checks if the context\n * (or, optionally, its parent node) is a script node.\n * For each argument, it will make sure that text nodes pass through a\n * default policy, or generate a violation. To skip that check, pass\n * TrustedScript objects instead.\n * @param {!Element|!Node} context The context for the call to the original\n * function.\n * @param {boolean} checkParent Check parent of context instead.\n * @param {!Function} originalFn The original mutator function.\n * @return {*}\n */\n enforceTypeInScriptNodes_(context, checkParent, originalFn, ...args) {\n const objToCheck = checkParent ? context.parentNode : context;\n if (objToCheck instanceof HTMLScriptElement && args.length > 0) {\n for (let argNumber = 0; argNumber < args.length; argNumber++) {\n let arg = args[argNumber];\n if (arg instanceof Node && arg.nodeType !== Node.TEXT_NODE) {\n continue; // Type is not interesting\n }\n if (arg instanceof Node && arg.nodeType == Node.TEXT_NODE) {\n arg = arg.textContent;\n } else if (TrustedTypes.isScript(arg)) {\n // TODO(koto): Consider removing this branch, as it's hard to spec.\n // Convert to text node and go on.\n args[argNumber] = document.createTextNode('' + arg);\n continue;\n }\n\n // Try to run a default policy on argsthe argument\n const fallbackValue = this.maybeCallDefaultPolicy_(\n 'TrustedScript', '' + arg, 'script.text');\n if (fallbackValue === null || fallbackValue === undefined) {\n this.processViolation_(context, originalFn.name,\n TrustedTypes.TrustedScript, arg);\n } else {\n arg = fallbackValue;\n }\n args[argNumber] = document.createTextNode('' + arg);\n }\n }\n return apply(originalFn, context, args);\n }\n\n /**\n * Wrapper for Element.insertAdjacentText that enforces type checks for\n * inserting text into a script node.\n * @param {!Object} context The context for the call to the original function.\n * @param {!Function} originalFn The original insertAdjacentText function.\n */\n insertAdjacentTextWrapper_(context, originalFn, ...args) {\n const riskyPositions = ['beforebegin', 'afterend'];\n if (context instanceof Element &&\n context.parentElement instanceof HTMLScriptElement &&\n args.length > 1 &&\n riskyPositions.includes(args[0]) &&\n !(TrustedTypes.isScript(args[1]))) {\n // Run a default policy on args[1]\n args[1] = '' + args[1];\n const fallbackValue = this.maybeCallDefaultPolicy_('TrustedScript',\n args[1], 'script.text');\n if (fallbackValue === null || fallbackValue === undefined) {\n this.processViolation_(context, 'insertAdjacentText',\n TrustedTypes.TrustedScript, args[1]);\n } else {\n args[1] = fallbackValue;\n }\n\n const textNode = document.createTextNode('' + args[1]);\n\n\n const insertBefore = /** @type function(this: Node) */(\n this.originalSetters_[this.getKey_(Node.prototype, 'insertBefore')]);\n\n switch (args[0]) {\n case riskyPositions[0]: // 'beforebegin'\n apply(insertBefore, context.parentElement,\n [textNode, context]);\n break;\n case riskyPositions[1]: // 'afterend'\n apply(insertBefore, context.parentElement,\n [textNode, context.nextSibling]);\n break;\n }\n return;\n }\n apply(originalFn, context, args);\n }\n\n /**\n * Wraps a setter with the enforcement wrapper.\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @param {!Function} type The type to enforce.\n * @param {number} argNumber Number of the argument to enforce the type of.\n * @private\n */\n wrapWithEnforceFunction_(object, name, type, argNumber) {\n const that = this;\n this.wrapFunction_(\n object,\n name,\n /**\n * @this {TrustedTypesEnforcer}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.enforce_.call(that, this, name, type, originalFn,\n argNumber, args);\n });\n }\n\n\n /**\n * Wraps an existing function with a given function body and stores the\n * original function.\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @param {function(!Function, ...*)} functionBody The wrapper function.\n */\n wrapFunction_(object, name, functionBody) {\n const descriptor = getOwnPropertyDescriptor(object, name);\n const originalFn = /** @type function(*):* */ (\n descriptor ? descriptor.value : null);\n\n if (!(originalFn instanceof Function)) {\n throw new TypeError(\n 'Property ' + name + ' on object' + object + ' is not a function');\n }\n\n const key = this.getKey_(object, name);\n if (this.originalSetters_[key]) {\n throw new Error(\n `TrustedTypesEnforcer: Double installation detected: ${key} ${name}`);\n }\n installFunction(\n object,\n name,\n /**\n * @this {TrustedTypesEnforcer}\n * @return {*}\n */\n function(...args) {\n return functionBody.bind(this, originalFn).apply(this, args);\n });\n this.originalSetters_[key] = originalFn;\n }\n\n /**\n * Wraps a setter with the enforcement wrapper.\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @param {!Function} type The type to enforce.\n * @param {!Object=} descriptorObject If present, will reuse the\n * setter/getter from this one, instead of object. Used for redefining\n * setters in subclasses.\n * @private\n */\n wrapSetter_(object, name, type, descriptorObject = undefined) {\n if (descriptorObject && !isPrototypeOf.call(descriptorObject, object)) {\n throw new Error('Invalid prototype chain');\n }\n\n let useObject = descriptorObject || object;\n let descriptor;\n let originalSetter;\n const stopAt = getPrototypeOf(Node.prototype);\n\n // Find the descriptor on the object or its prototypes, stopping at Node.\n do {\n descriptor = getOwnPropertyDescriptor(useObject, name);\n originalSetter = /** @type {function(*):*} */ (descriptor ?\n descriptor.set : null);\n if (!originalSetter) {\n useObject = getPrototypeOf(useObject) || stopAt;\n }\n } while (!(originalSetter || useObject === stopAt || !useObject));\n\n if (!(originalSetter instanceof Function)) {\n throw new TypeError(\n 'No setter for property ' + name + ' on object' + object);\n }\n\n const key = this.getKey_(object, name);\n if (this.originalSetters_[key]) {\n throw new Error(\n `TrustedTypesEnforcer: Double installation detected: ${key} ${name}`);\n }\n const that = this;\n /**\n * @this {TrustedTypesEnforcer}\n * @param {*} value\n */\n const enforcingSetter = function(value) {\n that.enforce_.call(that, this, name, type, originalSetter, 0,\n [value]);\n };\n\n if (useObject === object) {\n installSetter(\n object,\n name,\n enforcingSetter);\n } else {\n // Since we're creating a new setter in subclass, we also need to\n // overwrite the getter.\n installSetterAndGetter(\n object,\n name,\n enforcingSetter,\n descriptor.get\n );\n }\n this.originalSetters_[key] = originalSetter;\n }\n\n /**\n * Restores the original setter for the property, as encountered during\n * install().\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @param {!Object=} descriptorObject If present, will restore the original\n * setter/getter from this one, instead of object.\n * @private\n */\n restoreSetter_(object, name, descriptorObject = undefined) {\n const key = this.getKey_(object, name);\n if (descriptorObject && !isPrototypeOf.call(descriptorObject, object)) {\n throw new Error('Invalid prototype chain');\n }\n if (!this.originalSetters_[key]) {\n throw new Error(\n // eslint-disable-next-line max-len\n `TrustedTypesEnforcer: Cannot restore (double uninstallation?): ${key} ${name}`);\n }\n if (descriptorObject) {\n // We have to also overwrite a getter.\n installSetterAndGetter(object, name, this.originalSetters_[key],\n getOwnPropertyDescriptor(descriptorObject, name).get);\n } else {\n installSetter(object, name, this.originalSetters_[key]);\n }\n delete this.originalSetters_[key];\n }\n\n /**\n * Restores the original method of an object, as encountered during install().\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @private\n */\n restoreFunction_(object, name) {\n const key = this.getKey_(object, name);\n if (!this.originalSetters_[key]) {\n throw new Error(\n // eslint-disable-next-line max-len\n `TrustedTypesEnforcer: Cannot restore (double uninstallation?): ${key} ${name}`);\n }\n installFunction(object, name, this.originalSetters_[key]);\n delete this.originalSetters_[key];\n }\n\n /**\n * Returns the key name for caching original setters.\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @return {string} Key name.\n * @private\n */\n getKey_(object, name) {\n // TODO(msamuel): Can we use Object.prototype.toString.call(object)\n // to get an unspoofable string here?\n // TODO(msamuel): fail on '-' in object.constructor.name?\n // No Function.name in IE 11\n const ctrName = '' + (\n object.constructor.name ?\n object.constructor.name :\n object.constructor);\n return ctrName + '-' + name;\n }\n\n /**\n * Calls a default policy.\n * @param {string} typeName Type name to attempt to produce from a value.\n * @param {*} value The value to pass to a default policy\n * @param {string} sink The sink name that the default policy will be called\n * with.\n * @throws {Error} If the default policy throws, or not exist.\n * @return {Function?} The trusted value or null, if the input value shoudl\n * be rejected.\n */\n maybeCallDefaultPolicy_(typeName, value, sink = '') {\n // Apply a fallback policy, if it exists.\n const fallbackPolicy = TrustedTypes['defaultPolicy'];\n if (!fallbackPolicy) {\n return null;\n }\n if (!TYPE_CHECKER_MAP.hasOwnProperty(typeName)) {\n return null;\n }\n return fallbackPolicy[TYPE_PRODUCER_MAP[typeName]](value, '' + sink);\n }\n\n /**\n * Logs and enforces TrustedTypes depending on the given configuration.\n * @template T\n * @param {!Object} context The object that the setter is called for.\n * @param {string} propertyName The name of the property.\n * @param {!Function} typeToEnforce The type to enforce.\n * @param {function(?):T} originalSetter Original setter.\n * @param {number} argNumber Number of argument to enforce the type of.\n * @param {Array} args Arguments.\n * @return {T}\n * @private\n */\n enforce_(context, propertyName, typeToEnforce, originalSetter, argNumber,\n args) {\n const value = args[argNumber];\n const typeName = '' + typeToEnforce.name;\n // If typed value is given, pass through.\n if (TYPE_CHECKER_MAP.hasOwnProperty(typeName) &&\n TYPE_CHECKER_MAP[typeName](value)) {\n if (stringifyForRangeHack &&\n propertyName == 'createContextualFragment') {\n // IE 11 hack, somehow the value is not stringified implicitly.\n args[argNumber] = args[argNumber].toString();\n }\n return apply(originalSetter, context, args);\n }\n\n if (typeToEnforce === TrustedTypes.TrustedScript) {\n const isInlineEventHandler =\n propertyName == 'setAttribute' ||\n propertyName === 'setAttributeNS' ||\n apply(slice, propertyName, [0, 2]) === 'on';\n // If a function (instead of string) is passed to inline event attribute,\n // or set(Timeout|Interval), pass through.\n const propertyAcceptsFunctions =\n propertyName === 'setInterval' ||\n propertyName === 'setTimeout' ||\n isInlineEventHandler;\n if ((propertyAcceptsFunctions && typeof value === 'function') ||\n (isInlineEventHandler && value === null)) {\n return apply(originalSetter, context, args);\n }\n }\n\n // Apply a fallback policy, if it exists.\n args[argNumber] = '' + value;\n const objName = context instanceof Element ?\n context.localName :\n getConstructorName_(context ? context.constructor : window.constructor);\n const fallbackValue = this.maybeCallDefaultPolicy_(\n typeName, value, objName + '.' + propertyName);\n if (fallbackValue === null || fallbackValue === undefined) {\n // This will throw a TypeError if enforcement is enabled.\n this.processViolation_(context, propertyName, typeToEnforce, value);\n } else {\n // Use the value modified by the default policy.\n args[argNumber] = fallbackValue;\n }\n return apply(originalSetter, context, args);\n }\n\n /**\n * Report a TT violation.\n * @param {!Object} context The object that the setter is called for.\n * @param {string} propertyName The name of the property.\n * @param {!Function} typeToEnforce The type to enforce.\n * @param {string} value The value that was violated the restrictions.\n * @throws {TypeError} if the enforcement is enabled.\n */\n processViolation_(context, propertyName, typeToEnforce, value) {\n const contextName = getConstructorName_(context.constructor) ||\n '' + context;\n const message = `Failed to set ${propertyName} on ${contextName}: `\n + `This property requires ${typeToEnforce.name}.`;\n\n if (this.config_.isLoggingEnabled) {\n // eslint-disable-next-line no-console\n console.warn(message, propertyName, context, typeToEnforce, value);\n }\n\n // Unconditionally dispatch an event.\n if (typeof SecurityPolicyViolationEvent == 'function') {\n let blockedURI = '';\n if (typeToEnforce === TrustedTypes.TrustedURL ||\n typeToEnforce === TrustedTypes.TrustedScriptURL) {\n blockedURI = parseUrl_(value) || '';\n if (blockedURI) {\n blockedURI = blockedURI.href;\n }\n }\n const valueSlice = apply(slice, '' + value, [0, 40]);\n const event = new SecurityPolicyViolationEvent(\n 'securitypolicyviolation',\n {\n 'bubbles': true,\n 'blockedURI': blockedURI,\n 'disposition': this.config_.isEnforcementEnabled ?\n 'enforce' : 'report',\n 'documentURI': document.location.href,\n 'effectiveDirective': ENFORCEMENT_DIRECTIVE_NAME,\n 'originalPolicy': this.config_.cspString,\n 'statusCode': 0,\n 'violatedDirective': ENFORCEMENT_DIRECTIVE_NAME,\n 'sample': `${contextName}.${propertyName} ${valueSlice}`,\n });\n if (context instanceof Node && context.isConnected) {\n context.dispatchEvent(event);\n } else { // Fallback - dispatch an event on base document.\n document.dispatchEvent(event);\n }\n }\n\n if (this.config_.isEnforcementEnabled) {\n throw new TypeError(message);\n }\n }\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n/**\n * @fileoverview Entry point for a polyfill that only defines the types\n * (i.e. no enforcement logic).\n */\nimport {trustedTypes, TrustedTypePolicy, TrustedTypePolicyFactory} from\n '../trustedtypes.js';\n\nconst tt = trustedTypes;\n\n/**\n * Sets up the public Trusted Types API in the global object.\n */\nfunction setupPolyfill() {\n // We use array accessors to make sure Closure compiler will not alter the\n // names of the properties..\n\n // we setup the polyfill only in browser environment.\n if (typeof window === 'undefined') {\n return;\n }\n const rootProperty = 'trustedTypes';\n\n // Convert old window.TrustedTypes to window.trustedTypes.\n if (window['TrustedTypes'] && typeof window[rootProperty] === 'undefined') {\n window[rootProperty] = Object.freeze(window['TrustedTypes']);\n }\n\n if (typeof window[rootProperty] !== 'undefined') {\n return;\n }\n\n const publicApi = Object.create(TrustedTypePolicyFactory.prototype);\n Object.assign(publicApi, {\n 'isHTML': tt.isHTML,\n 'isURL': tt.isURL,\n 'isScriptURL': tt.isScriptURL,\n 'isScript': tt.isScript,\n 'createPolicy': tt.createPolicy,\n 'getPolicyNames': tt.getPolicyNames,\n 'getAttributeType': tt.getAttributeType,\n 'getPropertyType': tt.getPropertyType,\n 'getTypeMapping': tt.getTypeMapping,\n 'emptyHTML': tt.emptyHTML,\n 'emptyScript': tt.emptyScript,\n '_isPolyfill_': true,\n });\n Object.defineProperty(\n publicApi,\n 'defaultPolicy',\n Object.getOwnPropertyDescriptor(tt, 'defaultPolicy') || {});\n\n window[rootProperty] = Object.freeze(publicApi);\n\n window['TrustedHTML'] = tt.TrustedHTML;\n window['TrustedURL'] = tt.TrustedURL;\n window['TrustedScriptURL'] = tt.TrustedScriptURL;\n window['TrustedScript'] = tt.TrustedScript;\n window['TrustedTypePolicy'] = TrustedTypePolicy;\n window['TrustedTypePolicyFactory'] = TrustedTypePolicyFactory;\n}\n\nsetupPolyfill();\n\nexport default tt;\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n/**\n * @fileoverview Entry point for a polyfill that enforces the types.\n */\nimport {TrustedTypesEnforcer} from '../enforcer.js';\nimport {TrustedTypeConfig} from '../data/trustedtypeconfig.js';\n// import and setup trusted types\nimport './api_only.js';\n\n/* eslint-enable no-unused-vars */\n\n/**\n * Tries to guess a CSP policy from:\n * - the current polyfill script element text content (if prefixed with\n * \"Content-Security-Policy:\")\n * - the data-csp attribute value of the current script element.\n * - meta header\n * @return {?string} Guessed CSP value, or null.\n */\nfunction detectPolicy() {\n try {\n const currentScript = document.currentScript || (function() {\n const scripts = document.getElementsByTagName('script');\n return scripts[scripts.length - 1];\n })();\n\n const bodyPrefix = 'Content-Security-Policy:';\n if (currentScript &&\n currentScript.textContent.trim().substr(0, bodyPrefix.length) ==\n bodyPrefix) {\n return currentScript.textContent.trim().slice(bodyPrefix.length);\n }\n if (currentScript.dataset['csp']) {\n return currentScript.dataset['csp'];\n }\n const cspInMeta = document.head.querySelector(\n 'meta[http-equiv^=\"Content-Security-Policy\"]');\n if (cspInMeta) {\n return cspInMeta['content'].trim();\n }\n } catch (e) {\n return null;\n }\n return null;\n}\n\n/**\n * Bootstraps all trusted types polyfill and their enforcement.\n */\nexport function bootstrap() {\n const csp = detectPolicy();\n const config = csp ? TrustedTypeConfig.fromCSP(csp) : new TrustedTypeConfig(\n /* isLoggingEnabled */ false,\n /* isEnforcementEnabled */ false,\n /* allowedPolicyNames */ [],\n /* allowDuplicates */ true);\n\n const trustedTypesEnforcer = new TrustedTypesEnforcer(config);\n\n trustedTypesEnforcer.install();\n}\n\n/**\n * Determines if the enforcement should be enabled.\n * @return {boolean}\n */\nfunction shouldBootstrap() {\n for (const rootProperty of ['trustedTypes', 'TrustedTypes']) {\n if (window[rootProperty] && !window[rootProperty]['_isPolyfill_']) {\n // Native implementation exists\n return false;\n }\n }\n return true;\n}\n\n// Bootstrap only if native implementation is missing.\nif (shouldBootstrap()) {\n bootstrap();\n}\n"]} \ No newline at end of file +{"version":3,"sources":["src/data/trustedtypeconfig.js","src/utils/eventHandlers.js","src/trustedtypes.js","src/utils/wrapper.js","src/enforcer.js","src/polyfill/api_only.js","src/polyfill/full.js"],"names":["parseCSP","cspString","WHITESPACE","trim","split","SEMICOLON","map","serializedDirective","reduce","parsed","directive","slice","s","sort","fromCSP","policy","TrustedTypeConfig$$module$src$data$trustedtypeconfig.parseCSP","enforce","ENFORCEMENT_DIRECTIVE_NAME","includes","policies","allowDuplicates","POLICIES_DIRECTIVE_NAME","filter","p","charAt","TrustedTypeConfig","isLoggingEnabled","isEnforcementEnabled","allowedPolicyNames","unsafeAttributeEventHandlers","getUnsafeAttributeEventHandlers","window","eventHandlers","name","HTMLElement","prototype","push","isBrowser","rejectInputFn","TypeError","rejectInputDefaultPolicyFn","toLowerCase","toUpperCase","String","TrustedTypePolicy","TrustedTypePolicyFactory","trustedTypes","setPolicyNameRestrictions","clearPolicyNameRestrictions","trustedTypesBuilderTestOnly","privates","obj","v","privateMap","get","undefined","create","set","selfContained","collection","proto","getPrototypeOf","ObjectPrototype","Error","key","getOwnPropertyNames","defineProperty","value","lockdownTrustedType","SubClass","canonName","freeze","isTrustedTypeChecker","type","has","wrapPolicy","policyName","innerPolicy","creator","Ctor","methodName","method","DEFAULT_POLICY_NAME","policySpecificType","creatorSymbol","args","result","allowedValue","o","factory","createTypeMapping","writable","configurable","enumerable","getTypeInternal_","tag","container","elNs","attrNs","canonicalTag","apply","ns","HTML_NS","hasOwnProperty","TYPE_MAP","getDefaultPolicy","defaultPolicy","assign","Object","forEach","Array","Symbol","WeakMap","policyNames","allowedNames","allowDuplicateNames","enforceNameRestrictions","TrustedType","TrustedURL","TrustedScriptURL","TrustedHTML","TrustedScript","emptyHTML","emptyScript","XLINK_NS","SVG_NS","ATTR_PROPERTY_MAP","HTMLIFrameElement","keys","attr","createFunctionAllowed","api","createPolicy","match","indexOf","call","console","warn","wrappedPolicy","isHTML","isURL","isScriptURL","isScript","getAttributeType","tagName","attribute","elementNs","attributeNs","canonicalAttr","getPropertyType","property","getTypeMapping","namespaceUri","document","documentElement","namespaceURI","e","JSON","parse","stringify","length","el","resetDefaultPolicy","splice","installFunction","object","fn","Reflect","getOwnPropertyDescriptor","UrlConstructor","URL","constructor","stringifyForRangeHack","getConstructorName_","createElement","windowOpenObject","insertAdjacentObject","Element","SecurityPolicyViolationEvent","typeMap","TrustedTypes","STRING_TO_TYPE","attrs","k","entries","TYPE_CHECKER_MAP","TYPE_PRODUCER_MAP","wrapSetter_","enforcingSetter","that","enforce_","originalSetter","useObject","descriptor","stopAt","Node","Function","getKey_","originalSetters_","wrapWithEnforceFunction_","argNumber","wrapFunction_","originalFn","wrapSetAttribute_","setAttributeWrapper_","bind","setAttributeNSWrapper_","installScriptMutatorGuards_","fnName","enforceTypeInScriptNodes_","insertAdjacentTextWrapper_","installPropertySetWrappers_","install","config_","ShadowRoot","doc","createRange","r","createContextualFragment","f","toString","childNodes","Range","Document","HTMLDocument","DOMParser","functionBody","maybeCallDefaultPolicy_","typeName","sink","fallbackPolicy","processViolation_","context","propertyName","typeToEnforce","contextName","message","blockedURI","baseURI","href","valueSlice","event","location","isConnected","dispatchEvent","TrustedTypesEnforcer","config","attrName","requiredType","checkParent","objToCheck","parentNode","HTMLScriptElement","arg","nodeType","TEXT_NODE","textContent","createTextNode","fallbackValue","riskyPositions","parentElement","textNode","insertBefore","nextSibling","isInlineEventHandler","objName","localName","publicApi","tt","detectPolicy","currentScript","scripts","getElementsByTagName","bodyPrefix","substr","dataset","cspInMeta","head","querySelector","rootProperty","csp","TrustedTypeConfig$$module$src$data$trustedtypeconfig.fromCSP","trustedTypesEnforcer"],"mappings":"A;;;;;;;;aAyEEA,QAAO,GAAQ,CAACC,CAAD,CAAY,CAEzB,MAAMC,EAAa,KACnB,OAAOD,EAAAE,KAAA,EAAAC,MAAA,CAFWC,SAEX,CAAAC,IAAA,CACGC,CAAD,EAAyBA,CAAAH,MAAA,CAA0BF,CAA1B,CAD3B,CAAAM,OAAA,CAEK,QAAQ,CAACC,CAAD,CAASC,CAAT,CAAoB,CAC9BA,CAAA,CAAU,CAAV,CAAJ,GACED,CAAA,CAAOC,CAAA,CAAU,CAAV,CAAP,CADF,CACyBA,CAAAC,MAAA,CAAgB,CAAhB,CAAAL,IAAA,CAAwBM,CAAD,EAAOA,CAA9B,CAAAC,KAAA,EADzB,CAGA,OAAOJ,EAJ2B,CAFjC,CAOA,EAPA,CAHkB,CAkB3BK,QAAO,GAAO,CAACb,CAAD,CAAY,CAExB,MAAMc,EAASC,EAAA,CAA2Bf,CAA3B,CAAf,CACMgB,EAjFgCC,2BAiFhCD,EAAwCF,EAAxCE,EACFF,CAAA,CAlFkCG,2BAkFlC,CAAA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licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n/**\n * CSP Directive name controlling Trusted Types behavior.\n * @type {string}\n */\nexport const ENFORCEMENT_DIRECTIVE_NAME = 'require-trusted-types-for';\n\nexport const POLICIES_DIRECTIVE_NAME = 'trusted-types';\n\n/**\n * A configuration object for trusted type enforcement.\n */\nexport class TrustedTypeConfig {\n /**\n * @param {boolean} isLoggingEnabled If true enforcement wrappers will log\n * violations to the console.\n * @param {boolean} isEnforcementEnabled If true enforcement is enabled at\n * runtime.\n * @param {Array} allowedPolicyNames Whitelisted policy names.\n * @param {boolean} allowDuplicates Should duplicate names be allowed.\n * @param {?string} cspString String with the CSP policy.\n */\n constructor(isLoggingEnabled,\n isEnforcementEnabled,\n allowedPolicyNames,\n allowDuplicates,\n cspString = null) {\n /**\n * True if logging is enabled.\n * @type {boolean}\n */\n this.isLoggingEnabled = isLoggingEnabled;\n\n /**\n * True if enforcement is enabled.\n * @type {boolean}\n */\n this.isEnforcementEnabled = isEnforcementEnabled;\n\n /**\n * Allowed policy names.\n * @type {Array}\n */\n this.allowedPolicyNames = allowedPolicyNames;\n\n /**\n * Should duplicate names be accepted.\n * @type {boolean}\n */\n this.allowDuplicates = allowDuplicates;\n\n /**\n * CSP string that defined the policy.\n * @type {?string}\n */\n this.cspString = cspString;\n }\n\n /**\n * Parses a CSP policy.\n * @link https://www.w3.org/TR/CSP3/#parse-serialized-policy\n * @param {string} cspString String with a CSP definition.\n * @return {Object>} Parsed CSP, keyed by directive\n * names.\n */\n static parseCSP(cspString) {\n const SEMICOLON = /\\s*;\\s*/;\n const WHITESPACE = /\\s+/;\n return cspString.trim().split(SEMICOLON)\n .map((serializedDirective) => serializedDirective.split(WHITESPACE))\n .reduce(function(parsed, directive) {\n if (directive[0]) {\n parsed[directive[0]] = directive.slice(1).map((s) => s).sort();\n }\n return parsed;\n }, {});\n }\n\n /**\n * Creates a TrustedTypeConfig object from a CSP string.\n * @param {string} cspString\n * @return {!TrustedTypeConfig}\n */\n static fromCSP(cspString) {\n const isLoggingEnabled = true;\n const policy = TrustedTypeConfig.parseCSP(cspString);\n const enforce = ENFORCEMENT_DIRECTIVE_NAME in policy &&\n policy[ENFORCEMENT_DIRECTIVE_NAME].includes('\\'script\\'');\n let policies = ['*'];\n let allowDuplicates = true;\n if (POLICIES_DIRECTIVE_NAME in policy) {\n policies = policy[POLICIES_DIRECTIVE_NAME].filter(\n (p) => p.charAt(0) !== '\\'');\n allowDuplicates = policy[POLICIES_DIRECTIVE_NAME].includes(\n '\\'allow-duplicates\\'');\n }\n return new TrustedTypeConfig(\n isLoggingEnabled,\n enforce, /* isEnforcementEnabled */\n policies, /* allowedPolicyNames */\n allowDuplicates, /* allowDuplicates */\n cspString\n );\n }\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n// TODO check attributes in safari, remove legacy safe handlers\nconst unsafeAttributeEventHandlers = [\n 'onabort',\n 'onactivate',\n 'onactivateinvisible',\n 'onafterprint',\n 'onafterupdate',\n 'onanimationcancel',\n 'onanimationend',\n 'onanimationiteration',\n 'onanimationstart',\n 'onariarequest',\n 'onauxclick',\n 'onbeforeactivate',\n 'onbeforecopy',\n 'onbeforecut',\n 'onbeforedeactivate',\n 'onbeforeeditfocus',\n 'onbeforepaste',\n 'onbeforeprint',\n 'onbeforeunload',\n 'onbegin',\n 'onblur',\n 'onbounce',\n 'oncancel',\n 'oncanplay',\n 'oncanplaythrough',\n 'oncellchange',\n 'onchange',\n 'onclick',\n 'onclose',\n 'oncommand',\n 'oncontextmenu',\n 'oncontrolselect',\n 'oncopy',\n 'oncuechange',\n 'oncut',\n 'ondataavailable',\n 'ondatasetchanged',\n 'ondatasetcomplete',\n 'ondblclick',\n 'ondeactivate',\n 'ondrag',\n 'ondragdrop',\n 'ondragend',\n 'ondragenter',\n 'ondragexit',\n 'ondragleave',\n 'ondragover',\n 'ondragstart',\n 'ondrop',\n 'ondurationchange',\n 'onemptied',\n 'onend',\n 'onended',\n 'onerror',\n 'onerrorupdate',\n 'onexit',\n 'onfilterchange',\n 'onfinish',\n 'onfocus',\n 'onfocusin',\n 'onfocusout',\n 'onformdata',\n 'onfullscreenchange',\n 'onfullscreenerror',\n 'ongotpointercapture',\n 'onhelp',\n 'oninput',\n 'oninvalid',\n 'onkeydown',\n 'onkeypress',\n 'onkeyup',\n 'onlayoutcomplete',\n 'onload',\n 'onloadeddata',\n 'onloadedmetadata',\n 'onloadend',\n 'onloadstart',\n 'onlosecapture',\n 'onlostpointercapture',\n 'onmediacomplete',\n 'onmediaerror',\n 'onmessage',\n 'onmousedown',\n 'onmouseenter',\n 'onmouseleave',\n 'onmousemove',\n 'onmouseout',\n 'onmouseover',\n 'onmouseup',\n 'onmousewheel',\n 'onmove',\n 'onmoveend',\n 'onmovestart',\n 'onmozfullscreenchange',\n 'onmozfullscreenerror',\n 'onmscontentzoom',\n 'onmsgesturechange',\n 'onmsgesturedoubletap',\n 'onmsgestureend',\n 'onmsgesturehold',\n 'onmsgesturestart',\n 'onmsgesturetap',\n 'onmsgotpointercapture',\n 'onmsinertiastart',\n 'onmslostpointercapture',\n 'onmsmanipulationstatechanged',\n 'onmspointercancel',\n 'onmspointerdown',\n 'onmspointerenter',\n 'onmspointerleave',\n 'onmspointermove',\n 'onmspointerout',\n 'onmspointerover',\n 'onmspointerup',\n 'onoffline',\n 'ononline',\n 'onoutofsync',\n 'onoverscroll',\n 'onpaste',\n 'onpause',\n 'onplay',\n 'onplaying',\n 'onpointercancel',\n 'onpointerdown',\n 'onpointerenter',\n 'onpointerleave',\n 'onpointermove',\n 'onpointerout',\n 'onpointerover',\n 'onpointerrawupdate',\n 'onpointerup',\n 'onprogress',\n 'onpropertychange',\n 'onratechange',\n 'onreadystatechange',\n 'onrepeat',\n 'onreset',\n 'onresize',\n 'onresizeend',\n 'onresizestart',\n 'onresume',\n 'onreverse',\n 'onrowdelete',\n 'onrowenter',\n 'onrowexit',\n 'onrowinserted',\n 'onscroll',\n 'onscrollend',\n 'onsearch',\n 'onseek',\n 'onseeked',\n 'onseeking',\n 'onselect',\n 'onselectionchange',\n 'onselectstart',\n 'onshow',\n 'onstalled',\n 'onstart',\n 'onstop',\n 'onstorage',\n 'onsubmit',\n 'onsuspend',\n 'onsynchrestored',\n 'ontimeerror',\n 'ontimeupdate',\n 'ontoggle',\n 'ontrackchange',\n 'ontransitioncancel',\n 'ontransitionend',\n 'ontransitionrun',\n 'ontransitionstart',\n 'onunload',\n 'onurlflip',\n 'onvolumechange',\n 'onwaiting',\n 'onwebkitanimationend',\n 'onwebkitanimationiteration',\n 'onwebkitanimationstart',\n 'onwebkitfullscreenchange',\n 'onwebkitfullscreenerror',\n 'onwebkittransitionend',\n 'onwheel',\n];\n\n/**\n * Returns an array of all event handlers. Some of the event handlers may be\n * supported only in some browsers.\n *\n * For every event type that the browser supports, SVG supports that as an event\n * attribute, following the same requirements as for HTML event attributes.\n * https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/Events\n *\n * @return {!Array}\n */\nexport function getUnsafeAttributeEventHandlers() {\n if (typeof window !== 'undefined') {\n const eventHandlers = [];\n for (const name in HTMLElement.prototype) {\n if (name.slice(0, 2) === 'on') {\n eventHandlers.push(name);\n }\n }\n return eventHandlers;\n } else {\n return unsafeAttributeEventHandlers;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\nimport {getUnsafeAttributeEventHandlers} from './utils/eventHandlers.js';\n\nconst isBrowser = typeof window !== 'undefined';\n\nconst rejectInputFn = (s) => {\n throw new TypeError('undefined conversion');\n};\n\nconst rejectInputDefaultPolicyFn = (s) => null;\n\nconst {toLowerCase, toUpperCase} = String.prototype;\n\nexport const HTML_NS = 'http://www.w3.org/1999/xhtml';\nexport const XLINK_NS = 'http://www.w3.org/1999/xlink';\nexport const SVG_NS = 'http://www.w3.org/2000/svg';\n\n/**\n * @constructor\n * @property {!function(string):TrustedHTML} createHTML\n * @property {!function(string):TrustedURL} createURL\n * @property {!function(string):TrustedScriptURL} createScriptURL\n * @property {!function(string):TrustedScript} createScript\n * @property {!string} name\n */\nexport const TrustedTypePolicy = function() {\n throw new TypeError('Illegal constructor');\n};\n\n/**\n * @constructor\n */\nexport const TrustedTypePolicyFactory = function() {\n throw new TypeError('Illegal constructor');\n};\n\n/* eslint-disable no-unused-vars */\n/**\n * @typedef {TrustedTypesInnerPolicy}\n * @property {function(string):string} createHTML\n * @property {function(string):string} createURL\n * @property {function(string):string} createScriptURL\n * @property {function(string):string} createScript\n */\nconst TrustedTypesInnerPolicy = {};\n\n/**\n * @typedef {!Object,\n * properties: !Object}>}\n */\nconst TrustedTypesTypeMap = {};\n/* eslint-enable no-unused-vars */\n\nexport const DEFAULT_POLICY_NAME = 'default';\n\n\nexport const trustedTypesBuilderTestOnly = function() {\n // Capture common names early.\n const {\n assign, create, defineProperty, freeze, getOwnPropertyNames,\n getPrototypeOf, prototype: ObjectPrototype,\n } = Object;\n\n const {hasOwnProperty} = ObjectPrototype;\n\n const {\n forEach, push,\n } = Array.prototype;\n\n const creatorSymbol = Symbol();\n\n /**\n * Getter for the privateMap.\n * @param {Object} obj Key of the privateMap\n * @return {Object} Private storage.\n */\n const privates = function(obj) {\n let v = privateMap.get(obj);\n if (v === undefined) {\n v = create(null); // initialize the private storage.\n privateMap.set(obj, v);\n }\n return v;\n };\n\n /**\n * Called before attacker-controlled code on an internal collections,\n * copies prototype members onto the instance directly, so that later\n * changes to prototypes cannot expose collection internals.\n * @param {!T} collection\n * @return {!T} collection\n * @template T\n */\n function selfContained(collection) {\n const proto = getPrototypeOf(collection);\n if (proto == null || getPrototypeOf(proto) !== ObjectPrototype) {\n throw new Error(); // Loop below is insufficient.\n }\n for (const key of getOwnPropertyNames(proto)) {\n defineProperty(collection, key, {value: collection[key]});\n }\n return collection;\n }\n\n /**\n * Map for private properties of Trusted Types object.\n * This is so that the access to the type constructor does not give\n * the ability to create typed values.\n * @type {WeakMap}\n */\n const privateMap = selfContained(new WeakMap());\n\n /**\n * List of all configured policy names.\n * @type {Array}\n */\n const policyNames = selfContained([]);\n\n /**\n * Allowed policy names.\n * Applied only if enforceNameRestrictions is true.\n * @type {Array}\n */\n const allowedNames = selfContained([]);\n\n /**\n * Should duplicate prolicy names be allowed.\n * Applied only if enforceNameRestrictions is true.\n * @type {boolean}\n */\n let allowDuplicateNames = true;\n\n /**\n * A reference to a default policy, if created.\n * @type {TrustedTypePolicy}\n */\n let defaultPolicy = null;\n\n /**\n * Whether to enforce allowedNames in createPolicy().\n * @type {boolean}\n */\n let enforceNameRestrictions = false;\n\n\n /**\n * A value that is trusted to have certain security-relevant properties\n * because the sources of such values are controlled.\n */\n class TrustedType {\n /**\n * Constructor for TrustedType. Only allowed to be called from within a\n * policy.\n * @param {symbol} s creatorSymbol\n * @param {string} policyName The name of the policy this object was\n * created by.\n */\n constructor(s, policyName) {\n // TODO: Figure out if symbol is needed, if the value is in privateMap.\n if (s !== creatorSymbol) {\n throw new Error('cannot call the constructor');\n }\n defineProperty(this, 'policyName',\n {value: '' + policyName, enumerable: true});\n }\n\n /**\n * Returns the wrapped string value of the object.\n * @return {string}\n * @override\n */\n toString() {\n return privates(this)['v'];\n }\n\n /**\n * Returns the wrapped string value of the object.\n * @return {string}\n * @override\n */\n valueOf() {\n return privates(this)['v'];\n }\n }\n\n /**\n * @param {function(new:TrustedType, symbol, string)} SubClass\n * @param {string} canonName The class name which should be independent of\n * any renaming pass and which is relied upon by the enforcer and for\n * native type interop.\n */\n function lockdownTrustedType(SubClass, canonName) {\n freeze(SubClass.prototype);\n delete SubClass.name;\n defineProperty(SubClass, 'name', {value: canonName});\n }\n\n /**\n * Trusted URL object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedURL extends TrustedType {\n }\n lockdownTrustedType(TrustedURL, 'TrustedURL');\n\n /**\n * Trusted Script URL object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedScriptURL extends TrustedType {\n }\n lockdownTrustedType(TrustedScriptURL, 'TrustedScriptURL');\n\n /**\n * Trusted HTML object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedHTML extends TrustedType {\n }\n lockdownTrustedType(TrustedHTML, 'TrustedHTML');\n\n /**\n * Trusted Script object wrapping a string that can only be created from a\n * TT policy.\n */\n class TrustedScript extends TrustedType {\n }\n lockdownTrustedType(TrustedScript, 'TrustedScript');\n\n lockdownTrustedType(TrustedType, 'TrustedType');\n\n // Common constants.\n const emptyHTML = freeze(create(new TrustedHTML(creatorSymbol, '')));\n privates(emptyHTML)['v'] = '';\n const emptyScript = freeze(create(new TrustedScript(creatorSymbol, '')));\n privates(emptyScript)['v'] = '';\n\n /**\n * A map of attribute / property names to allowed types\n * for known namespaces.\n * @type {!Object}\n * @export\n */\n const TYPE_MAP = {\n [HTML_NS]: {\n // TODO(koto): Figure out what to to with \n 'A': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'AREA': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'BASE': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n },\n 'BUTTON': {\n 'attributes': {\n 'formaction': TrustedURL.name,\n },\n },\n 'EMBED': {\n 'attributes': {\n 'src': TrustedScriptURL.name,\n },\n },\n 'FORM': {\n 'attributes': {\n 'action': TrustedURL.name,\n },\n },\n 'FRAME': {\n 'attributes': {\n 'src': TrustedURL.name,\n },\n },\n 'IFRAME': {\n 'attributes': {\n 'src': TrustedURL.name,\n 'srcdoc': TrustedHTML.name,\n },\n },\n 'INPUT': {\n 'attributes': {\n 'formaction': TrustedURL.name,\n },\n },\n 'OBJECT': {\n 'attributes': {\n 'data': TrustedScriptURL.name,\n 'codebase': TrustedScriptURL.name,\n },\n },\n // TODO(koto): Figure out what to do with portals.\n 'SCRIPT': {\n 'attributes': {\n 'src': TrustedScriptURL.name,\n 'text': TrustedScript.name,\n },\n 'properties': {\n 'innerText': TrustedScript.name,\n 'textContent': TrustedScript.name,\n 'text': TrustedScript.name,\n },\n },\n '*': {\n 'attributes': {},\n 'properties': {\n 'innerHTML': TrustedHTML.name,\n 'outerHTML': TrustedHTML.name,\n },\n },\n },\n [XLINK_NS]: {\n '*': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n 'properties': {},\n },\n },\n [SVG_NS]: {\n '*': {\n 'attributes': {\n 'href': TrustedURL.name,\n },\n 'properties': {},\n },\n },\n };\n\n /**\n * A map of element property to HTML attribute names.\n * @type {!Object}\n */\n const ATTR_PROPERTY_MAP = {\n 'codebase': 'codeBase',\n 'formaction': 'formAction',\n };\n\n // Edge doesn't support srcdoc.\n if (isBrowser && !('srcdoc' in HTMLIFrameElement.prototype)) {\n delete TYPE_MAP[HTML_NS]['IFRAME']['attributes']['srcdoc'];\n }\n\n // in HTML, clone attributes into properties.\n for (const tag of Object.keys(TYPE_MAP[HTML_NS])) {\n if (!TYPE_MAP[HTML_NS][tag]['properties']) {\n TYPE_MAP[HTML_NS][tag]['properties'] = {};\n }\n for (const attr of Object.keys(TYPE_MAP[HTML_NS][tag]['attributes'])) {\n TYPE_MAP[HTML_NS][tag]['properties'][\n ATTR_PROPERTY_MAP[attr] ? ATTR_PROPERTY_MAP[attr] : attr\n ] = TYPE_MAP[HTML_NS][tag]['attributes'][attr];\n }\n }\n\n // Add inline event handlers attribute names.\n for (const name of getUnsafeAttributeEventHandlers()) {\n TYPE_MAP[HTML_NS]['*']['attributes'][name] = 'TrustedScript';\n TYPE_MAP[SVG_NS]['*']['attributes'][name] = 'TrustedScript';\n }\n\n /**\n * @type {!Object}\n */\n const createTypeMapping = {\n 'createHTML': TrustedHTML,\n 'createScriptURL': TrustedScriptURL,\n 'createURL': TrustedURL,\n 'createScript': TrustedScript,\n };\n\n const createFunctionAllowed = createTypeMapping.hasOwnProperty;\n\n /**\n * Function generating a type checker.\n * @template T\n * @param {T} type The type to check against.\n * @return {function(*):boolean}\n */\n function isTrustedTypeChecker(type) {\n return (obj) => (obj instanceof type) && privateMap.has(obj);\n }\n\n /**\n * Wraps a user-defined policy rules with TT constructor\n * @param {string} policyName The policy name\n * @param {TrustedTypesInnerPolicy} innerPolicy InnerPolicy\n * @return {!TrustedTypePolicy} Frozen policy object\n */\n function wrapPolicy(policyName, innerPolicy) {\n /**\n * @template T\n * @param {function(new:T, symbol, string)} Ctor a trusted type constructor\n * @param {string} methodName the policy factory method name\n * @return {function(string):!T} a factory that produces instances of Ctor.\n */\n function creator(Ctor, methodName) {\n // This causes thisValue to be null when called below.\n const method = innerPolicy[methodName] || (\n policyName == DEFAULT_POLICY_NAME ?\n rejectInputDefaultPolicyFn : rejectInputFn\n );\n const policySpecificType = freeze(new Ctor(creatorSymbol, policyName));\n const factory = {\n [methodName](s, ...args) {\n // Trick to get methodName to show in stacktrace.\n let result = method('' + s, ...args);\n if (result === undefined || result === null) {\n if (policyName == DEFAULT_POLICY_NAME) {\n // These values mean that the input was rejected. This will cause\n // a violation later, don't create types for them.\n return result;\n }\n result = '';\n }\n const allowedValue = '' + result;\n const o = freeze(create(policySpecificType));\n privates(o)['v'] = allowedValue;\n return o;\n },\n }[methodName];\n return freeze(factory);\n }\n\n const policy = create(TrustedTypePolicy.prototype);\n\n for (const name of getOwnPropertyNames(createTypeMapping)) {\n policy[name] = creator(createTypeMapping[name], name);\n }\n defineProperty(policy, 'name', {\n value: policyName,\n writable: false,\n configurable: false,\n enumerable: true,\n });\n\n return /** @type {!TrustedTypePolicy} */ (freeze(policy));\n }\n\n /**\n * Returns the name of the trusted type required for a given element\n * attribute.\n * @param {string} tagName The name of the tag of the element.\n * @param {string} attribute The name of the attribute.\n * @param {string=} elementNs Element namespace.\n * @param {string=} attributeNs The attribute namespace.\n * @return {string?} Required type name or null, if a Trusted\n * Type is not required.\n */\n function getAttributeType(tagName, attribute, elementNs = '',\n attributeNs = '') {\n const canonicalAttr = toLowerCase.apply(String(attribute));\n return getTypeInternal_(tagName, 'attributes', canonicalAttr,\n elementNs, attributeNs) || null;\n }\n\n /**\n * Returns a type name from a type map.\n * @param {string} tag A tag name.\n * @param {string} container 'attributes' or 'properties'\n * @param {string} name The attribute / property name.\n * @param {string=} elNs Element namespace.\n * @param {string=} attrNs Attribute namespace.\n * @return {string|undefined}\n * @private\n */\n function getTypeInternal_(tag, container, name, elNs = '', attrNs = '') {\n const canonicalTag = toUpperCase.apply(String(tag));\n\n let ns = attrNs ? attrNs : elNs;\n if (!ns) {\n ns = HTML_NS;\n }\n const map = hasOwnProperty.apply(TYPE_MAP, [ns]) ? TYPE_MAP[ns] : null;\n if (!map) {\n return;\n }\n if (hasOwnProperty.apply(map, [canonicalTag]) &&\n map[canonicalTag] &&\n hasOwnProperty.apply(map[canonicalTag][container], [name]) &&\n map[canonicalTag][container][name]) {\n return map[canonicalTag][container][name];\n }\n\n if (hasOwnProperty.apply(map, ['*']) &&\n hasOwnProperty.apply(map['*'][container], [name]) &&\n map['*'][container][name]) {\n return map['*'][container][name];\n }\n }\n\n /**\n * Returns the name of the trusted type required for a given element property.\n * @param {string} tagName The name of the tag of the element.\n * @param {string} property The property.\n * @param {string=} elementNs Element namespace.\n * @return {string?} Required type name or null, if a Trusted\n * Type is not required.\n */\n function getPropertyType(tagName, property, elementNs = '') {\n // TODO: Support namespaces.\n return getTypeInternal_(\n tagName, 'properties', String(property), elementNs) || null;\n }\n\n /**\n * Returns the type map-like object, that resolves a name of a type for a\n * given tag + attribute / property in a given namespace.\n * The keys of the map are uppercase tag names. Map entry has mappings between\n * a lowercase attribute name / case-sensitive property name and a name of the\n * type that is required for that attribute / property.\n * Example entry for 'IMG': {\"attributes\": {\"src\": \"TrustedHTML\"}}\n * @param {string=} namespaceUri The namespace URI (will use the current\n * document namespace URI if omitted).\n * @return {TrustedTypesTypeMap}\n */\n function getTypeMapping(namespaceUri = '') {\n if (!namespaceUri) {\n try {\n namespaceUri = document.documentElement.namespaceURI;\n } catch (e) {\n namespaceUri = HTML_NS;\n }\n }\n /**\n * @template T\n * @private\n * @param {T} o\n * @return {T}\n */\n function deepClone(o) {\n return JSON.parse(JSON.stringify(o));\n }\n const map = TYPE_MAP[namespaceUri];\n if (!map) {\n return {};\n }\n return deepClone(map);\n }\n\n /**\n * Creates a TT policy.\n *\n * Returns a frozen object representing a policy - a collection of functions\n * that may create TT objects based on the user-provided rules specified\n * in the policy object.\n *\n * @param {string} name A unique name of the policy.\n * @param {TrustedTypesInnerPolicy} policy Policy rules object.\n * @return {TrustedTypePolicy} The policy that may create TT objects\n * according to the policy rules.\n */\n function createPolicy(name, policy) {\n const pName = '' + name; // Assert it's a string\n\n if (!pName.match(/^[-#a-zA-Z0-9=_/@.%]+$/g)) {\n throw new TypeError('Policy ' + pName + ' contains invalid characters.');\n }\n\n if (enforceNameRestrictions && allowedNames.indexOf(pName) === -1) {\n throw new TypeError('Policy ' + pName + ' disallowed.');\n }\n\n if (pName === DEFAULT_POLICY_NAME && defaultPolicy) {\n throw new TypeError('Policy ' + pName + ' already exists.');\n }\n if (enforceNameRestrictions && !allowDuplicateNames &&\n policyNames.indexOf(pName) !== -1) {\n throw new TypeError('Policy ' + pName + ' exists.');\n }\n // Register the name early so that if policy getters unwisely calls\n // across protection domains to code that reenters this function,\n // policy author still has rights to the name.\n policyNames.push(pName);\n\n // Only copy own properties of names present in createTypeMapping.\n const innerPolicy = create(null);\n if (policy && typeof policy === 'object') {\n // Treat non-objects as empty policies.\n for (const key of getOwnPropertyNames(policy)) {\n if (createFunctionAllowed.call(createTypeMapping, key)) {\n innerPolicy[key] = policy[key];\n }\n }\n } else {\n // eslint-disable-next-line no-console\n console.warn('trustedTypes.createPolicy ' + pName +\n ' was given an empty policy');\n }\n freeze(innerPolicy);\n\n const wrappedPolicy = wrapPolicy(pName, innerPolicy);\n\n if (pName === DEFAULT_POLICY_NAME) {\n defaultPolicy = wrappedPolicy;\n }\n\n return wrappedPolicy;\n }\n\n /**\n * Applies the policy name restrictions.\n * @param {!Array} allowedPolicyNames\n * @param {boolean} allowDuplicates\n */\n function setPolicyNameRestrictions(allowedPolicyNames, allowDuplicates) {\n enforceNameRestrictions = true;\n allowedNames.length = 0;\n forEach.call(allowedPolicyNames, (el) => {\n push.call(allowedNames, '' + el);\n });\n allowDuplicateNames = allowDuplicates;\n policyNames.length = 0; // Clear already used policy names list.\n }\n\n /**\n * Clears the policy name restrictions.\n */\n function clearPolicyNameRestrictions() {\n enforceNameRestrictions = false;\n }\n\n /**\n * Returns the default policy, or null if it was not created.\n * @return {TrustedTypePolicy}\n */\n function getDefaultPolicy() {\n return defaultPolicy;\n }\n\n /**\n * Resets the default policy.\n */\n function resetDefaultPolicy() {\n defaultPolicy = null;\n policyNames.splice(policyNames.indexOf(DEFAULT_POLICY_NAME), 1);\n }\n\n const api = create(TrustedTypePolicyFactory.prototype);\n assign(api, {\n // The main function to create policies.\n createPolicy,\n\n // Type checkers, also validating the object was initialized through a\n // policy.\n isHTML: isTrustedTypeChecker(TrustedHTML),\n isURL: isTrustedTypeChecker(TrustedURL),\n isScriptURL: isTrustedTypeChecker(TrustedScriptURL),\n isScript: isTrustedTypeChecker(TrustedScript),\n\n getAttributeType,\n getPropertyType,\n getTypeMapping,\n emptyHTML,\n emptyScript,\n defaultPolicy, // Just to make the compiler happy, this is overridden below.\n\n TrustedHTML: TrustedHTML,\n TrustedURL: TrustedURL,\n TrustedScriptURL: TrustedScriptURL,\n TrustedScript: TrustedScript,\n });\n\n defineProperty(api, 'defaultPolicy', {\n get: getDefaultPolicy,\n set: () => {},\n });\n\n return {\n trustedTypes: freeze(api),\n setPolicyNameRestrictions,\n clearPolicyNameRestrictions,\n getDefaultPolicy,\n resetDefaultPolicy,\n };\n};\n\n\nexport const {\n trustedTypes,\n setPolicyNameRestrictions,\n clearPolicyNameRestrictions,\n getDefaultPolicy,\n resetDefaultPolicy,\n} = trustedTypesBuilderTestOnly();\n\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\nconst {\n defineProperty,\n} = Object;\n\n/**\n * Installs the setter of a given property.\n * @param {!Object} object An object for which to wrap the property.\n * @param {string} name The name of the property to wrap.\n * @param {function(*): *|undefined} setter A setter function}\n */\nexport function installSetter(object, name, setter) {\n const descriptor = {\n set: setter,\n };\n defineProperty(object, name, descriptor);\n}\n\n/**\n * Installs a setter and getter of a given property.\n * @param {!Object} object An object for which to wrap the property.\n * @param {string} name The name of the property to wrap.\n * @param {function(*): *|undefined} setter A setter function}\n * @param {function(*): *|undefined} getter A getter function}\n */\nexport function installSetterAndGetter(object, name, setter, getter) {\n const descriptor = {\n set: setter,\n get: getter,\n configurable: true, // This can get uninstalled, we need configurable: true\n };\n defineProperty(object, name, descriptor);\n}\n\n/**\n * Installs the setter of a given property.\n * @param {!Object} object An object for which to wrap the property.\n * @param {string} name The name of the property to wrap.\n * @param {function(*): *|undefined} fn A function}\n */\nexport function installFunction(object, name, fn) {\n defineProperty(object, name, {\n value: fn,\n });\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n// TrustedTypeConfig is used only as jsdoc type\n// eslint-disable-next-line\nimport {ENFORCEMENT_DIRECTIVE_NAME, TrustedTypeConfig}\n from './data/trustedtypeconfig.js';\nimport {\n trustedTypes as TrustedTypes,\n setPolicyNameRestrictions,\n clearPolicyNameRestrictions,\n resetDefaultPolicy,\n HTML_NS,\n} from\n './trustedtypes.js';\n\nimport {installFunction, installSetter, installSetterAndGetter}\n from './utils/wrapper.js';\n\nconst {apply} = Reflect;\nconst {\n getOwnPropertyNames,\n getOwnPropertyDescriptor,\n getPrototypeOf,\n} = Object;\n\nconst {\n hasOwnProperty,\n isPrototypeOf,\n} = Object.prototype;\n\nconst {slice} = String.prototype;\n\n// No URL in IE 11.\nconst UrlConstructor = typeof window.URL == 'function' ?\n URL.prototype.constructor :\n null;\n\nlet stringifyForRangeHack;\n\n/**\n * Return object constructor name\n * (their function.name is not available in IE 11).\n * @param {Function} fn\n * @return {string}\n * @private\n */\nconst getConstructorName_ = document.createElement('div').constructor.name ?\n (fn) => fn.name :\n (fn) => ('' + fn).match(/^\\[object (\\S+)\\]$/)[1];\n\n// window.open on IE 11 is set on WindowPrototype\nconst windowOpenObject = getOwnPropertyDescriptor(window, 'open') ?\n window :\n window.constructor.prototype;\n\n// In IE 11, insertAdjacent(HTML|Text) is on HTMLElement prototype\nconst insertAdjacentObject = apply(hasOwnProperty, Element.prototype,\n ['insertAdjacentHTML']) ? Element.prototype : HTMLElement.prototype;\n\n// This is not available in release Firefox :(\n// https://developer.mozilla.org/en-US/docs/Web/API/SecurityPolicyViolationEvent\n// https://bugzilla.mozilla.org/show_bug.cgi?id=1432523\nconst SecurityPolicyViolationEvent = window['SecurityPolicyViolationEvent'] ||\n null;\n\n/**\n * Parses URL, catching all the errors.\n * @param {string} url URL string to parse.\n * @return {URL|null}\n */\nfunction parseUrl_(url) {\n try {\n return new UrlConstructor(url, document.baseURI || undefined);\n } catch (e) {\n return null;\n }\n}\n\n// We don't actually need other namespaces.\n// setAttribute is hooked on Element.prototype, which all elements inherit from,\n// and all sensitive property wrappers are hooked directly on Element as well.\nconst typeMap = TrustedTypes.getTypeMapping(HTML_NS);\n\nconst STRING_TO_TYPE = {\n 'TrustedHTML': TrustedTypes.TrustedHTML,\n 'TrustedScript': TrustedTypes.TrustedScript,\n 'TrustedScriptURL': TrustedTypes.TrustedScriptURL,\n 'TrustedURL': TrustedTypes.TrustedURL,\n};\n\n/**\n * Converts an uppercase tag name to an element constructor function name.\n * Used for property setter hijacking only.\n * @param {string} tagName\n * @return {string}\n */\nfunction convertTagToConstructor(tagName) {\n if (tagName == '*') {\n return 'HTMLElement';\n }\n return getConstructorName_(document.createElement(tagName).constructor);\n}\n\nfor (const tagName of Object.keys(typeMap)) {\n const attrs = typeMap[tagName]['properties'];\n for (const [k, v] of Object.entries(attrs)) {\n attrs[k] = STRING_TO_TYPE[v];\n }\n}\n\n/**\n * Map of type names to type checking function.\n * @type {!Object}\n */\nconst TYPE_CHECKER_MAP = {\n 'TrustedHTML': TrustedTypes.isHTML,\n 'TrustedURL': TrustedTypes.isURL,\n 'TrustedScriptURL': TrustedTypes.isScriptURL,\n 'TrustedScript': TrustedTypes.isScript,\n};\n\n/**\n * Map of type names to type producing function.\n * @type {Object}\n */\nconst TYPE_PRODUCER_MAP = {\n 'TrustedHTML': 'createHTML',\n 'TrustedURL': 'createURL',\n 'TrustedScriptURL': 'createScriptURL',\n 'TrustedScript': 'createScript',\n};\n\n/* eslint-disable no-unused-vars */\n/**\n * @typedef {TrustedTypePolicy}\n * @property {function(string):TrustedHTML} createHTML\n * @property {function(string):TrustedURL} createURL\n * @property {function(string):TrustedScriptURL} createScriptURL\n * @property {function(string):TrustedScript} createScript\n */\nconst TrustedTypePolicy = {};\n/* eslint-enable no-unused-vars */\n\n\n/**\n * An object for enabling trusted type enforcement.\n */\nexport class TrustedTypesEnforcer {\n /**\n * @param {!TrustedTypeConfig} config The configuration for\n * trusted type enforcement.\n */\n constructor(config) {\n /**\n * A configuration for the trusted type enforcement.\n * @private {!TrustedTypeConfig}\n */\n this.config_ = config;\n /**\n * @private {Object}\n */\n this.originalSetters_ = {};\n }\n\n /**\n * Wraps HTML sinks with an enforcement setter, which will enforce\n * trusted types and do logging, if enabled.\n *\n */\n install() {\n if (this.config_.allowedPolicyNames.includes('*')) {\n clearPolicyNameRestrictions();\n } else {\n setPolicyNameRestrictions(this.config_.allowedPolicyNames,\n this.config_.allowDuplicates);\n }\n\n if (!this.config_.isEnforcementEnabled && !this.config_.isLoggingEnabled) {\n return;\n }\n\n if ('ShadowRoot' in window) {\n this.wrapSetter_(ShadowRoot.prototype, 'innerHTML',\n TrustedTypes.TrustedHTML);\n }\n stringifyForRangeHack = (function(doc) {\n const r = doc.createRange();\n // In IE 11 Range.createContextualFragment doesn't stringify its argument.\n const f = r.createContextualFragment(/** @type {string} */ (\n {toString: () => '
'}));\n return f.childNodes.length == 0;\n })(document);\n\n this.wrapWithEnforceFunction_(Range.prototype, 'createContextualFragment',\n TrustedTypes.TrustedHTML, 0);\n\n this.wrapWithEnforceFunction_(insertAdjacentObject,\n 'insertAdjacentHTML',\n TrustedTypes.TrustedHTML, 1);\n\n if (getOwnPropertyDescriptor(Document.prototype, 'write')) {\n // Chrome\n this.wrapWithEnforceFunction_(Document.prototype, 'write',\n TrustedTypes.TrustedHTML, 0);\n this.wrapWithEnforceFunction_(Document.prototype, 'open',\n TrustedTypes.TrustedURL, 0);\n } else {\n // Firefox\n this.wrapWithEnforceFunction_(HTMLDocument.prototype, 'write',\n TrustedTypes.TrustedHTML, 0);\n this.wrapWithEnforceFunction_(HTMLDocument.prototype, 'open',\n TrustedTypes.TrustedURL, 0);\n }\n\n this.wrapWithEnforceFunction_(windowOpenObject, 'open',\n TrustedTypes.TrustedURL, 0);\n\n if ('DOMParser' in window) {\n this.wrapWithEnforceFunction_(DOMParser.prototype, 'parseFromString',\n TrustedTypes.TrustedHTML, 0);\n }\n this.wrapWithEnforceFunction_(window, 'setInterval',\n TrustedTypes.TrustedScript, 0);\n this.wrapWithEnforceFunction_(window, 'setTimeout',\n TrustedTypes.TrustedScript, 0);\n this.wrapSetAttribute_();\n this.installScriptMutatorGuards_();\n this.installPropertySetWrappers_();\n }\n\n /**\n * Removes the original setters.\n */\n uninstall() {\n clearPolicyNameRestrictions();\n\n if (!this.config_.isEnforcementEnabled && !this.config_.isLoggingEnabled) {\n return;\n }\n\n if ('ShadowRoot' in window) {\n this.restoreSetter_(ShadowRoot.prototype, 'innerHTML');\n }\n this.restoreFunction_(Range.prototype, 'createContextualFragment');\n this.restoreFunction_(insertAdjacentObject, 'insertAdjacentHTML');\n this.restoreFunction_(Element.prototype, 'setAttribute');\n this.restoreFunction_(Element.prototype, 'setAttributeNS');\n\n if (getOwnPropertyDescriptor(Document.prototype, 'write')) {\n this.restoreFunction_(Document.prototype, 'write');\n this.restoreFunction_(Document.prototype, 'open');\n } else {\n this.restoreFunction_(HTMLDocument.prototype, 'write');\n this.restoreFunction_(HTMLDocument.prototype, 'open');\n }\n this.restoreFunction_(windowOpenObject, 'open');\n\n if ('DOMParser' in window) {\n this.restoreFunction_(DOMParser.prototype, 'parseFromString');\n }\n this.restoreFunction_(window, 'setTimeout');\n this.restoreFunction_(window, 'setInterval');\n this.uninstallPropertySetWrappers_();\n this.uninstallScriptMutatorGuards_();\n resetDefaultPolicy();\n }\n\n /**\n * Installs type-enforcing wrappers for APIs that allow to modify\n * script element texts.\n * @private\n */\n installScriptMutatorGuards_() {\n const that = this;\n\n ['appendChild', 'insertBefore', 'replaceChild'].forEach((fnName) => {\n this.wrapFunction_(\n Node.prototype,\n fnName,\n /**\n * @this {Node}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.enforceTypeInScriptNodes_\n .bind(that, this, /* checkParent */ false, originalFn)\n .apply(that, args);\n });\n });\n this.wrapFunction_(\n insertAdjacentObject,\n 'insertAdjacentText',\n /**\n * @this {Element}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.insertAdjacentTextWrapper_\n .bind(that, this, originalFn)\n .apply(that, args);\n });\n\n if ('after' in Element.prototype) {\n ['after', 'before', 'replaceWith'].forEach((fnName) => {\n this.wrapFunction_(\n Element.prototype,\n fnName,\n /**\n * @this {Element}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.enforceTypeInScriptNodes_\n .bind(that, this, /* checkParent */ true, originalFn)\n .apply(that, args);\n });\n });\n ['append', 'prepend'].forEach((fnName) => {\n this.wrapFunction_(\n Element.prototype,\n fnName,\n /**\n * @this {Element}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.enforceTypeInScriptNodes_\n .bind(that, this, /* checkParent */ false, originalFn)\n .apply(that, args);\n });\n });\n }\n }\n\n /**\n * Uninstalls type-enforcing wrappers for APIs that allow to modify\n * script element texts.\n * @private\n */\n uninstallScriptMutatorGuards_() {\n this.restoreFunction_(Node.prototype, 'appendChild');\n this.restoreFunction_(Node.prototype, 'insertBefore');\n this.restoreFunction_(Node.prototype, 'replaceChild');\n this.restoreFunction_(insertAdjacentObject, 'insertAdjacentText');\n if ('after' in Element.prototype) {\n ['after', 'before', 'replaceWith', 'append', 'prepend'].forEach(\n (fnName) => this.restoreFunction_(Element.prototype, fnName));\n }\n }\n\n /**\n * Installs wrappers for directly setting properties\n * based on the type map.\n * @private\n */\n installPropertySetWrappers_() {\n /* eslint-disable guard-for-in */\n for (const tag of getOwnPropertyNames(typeMap)) {\n for (const property of getOwnPropertyNames(typeMap[tag]['properties'])) {\n this.wrapSetter_(\n window[convertTagToConstructor(tag)].prototype,\n property,\n typeMap[tag]['properties'][property]);\n }\n }\n }\n\n /**\n * Uninstalls wrappers for directly setting properties\n * based on the type map.\n * @private\n */\n uninstallPropertySetWrappers_() {\n /* eslint-disable guard-for-in */\n for (const tag of getOwnPropertyNames(typeMap)) {\n for (const property of getOwnPropertyNames(typeMap[tag]['properties'])) {\n this.restoreSetter_(\n window[convertTagToConstructor(tag)].prototype,\n property);\n }\n }\n }\n\n /** Wraps set attribute with an enforcement function. */\n wrapSetAttribute_() {\n const that = this;\n this.wrapFunction_(\n Element.prototype,\n 'setAttribute',\n /**\n * @this {TrustedTypesEnforcer}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.setAttributeWrapper_\n .bind(that, this, originalFn)\n .apply(that, args);\n });\n this.wrapFunction_(\n Element.prototype,\n 'setAttributeNS',\n /**\n * @this {TrustedTypesEnforcer}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.setAttributeNSWrapper_\n .bind(that, this, originalFn)\n .apply(that, args);\n });\n }\n\n /**\n * Enforces type checking for Element.prototype.setAttribute.\n * @param {!Object} context The context for the call to the original function.\n * @param {!Function} originalFn The original setAttribute function.\n * @return {*}\n */\n setAttributeWrapper_(context, originalFn, ...args) {\n // Note(slekies): In a normal application constructor should never be null.\n // However, there are no guarantees. If the constructor is null, we cannot\n // determine whether a special type is required. In order to not break the\n // application, we will not do any further type checks and pass the call\n // to setAttribute.\n if (context.constructor !== null && context instanceof Element) {\n const attrName = (args[0] = String(args[0])).toLowerCase();\n const requiredType = TrustedTypes.getAttributeType(context.tagName,\n attrName, context.namespaceURI);\n if (requiredType && apply(hasOwnProperty, STRING_TO_TYPE,\n [requiredType])) {\n return this.enforce_(\n context, 'setAttribute', STRING_TO_TYPE[requiredType],\n originalFn, 1, args);\n }\n }\n return apply(originalFn, context, args);\n }\n\n /**\n * Enforces type checking for Element.prototype.setAttributeNS.\n * @param {!Object} context The context for the call to the original function.\n * @param {!Function} originalFn The original setAttributeNS function.\n * @return {*}\n */\n setAttributeNSWrapper_(context, originalFn, ...args) {\n // See the note from setAttributeWrapper_ above.\n if (context.constructor !== null && context instanceof Element) {\n const ns = args[0] ? String(args[0]) : null;\n args[0] = ns;\n const attrName = (args[1] = String(args[1])).toLowerCase();\n const requiredType = TrustedTypes.getAttributeType(context.tagName,\n attrName, context.namespaceURI, ns);\n if (requiredType && apply(hasOwnProperty, STRING_TO_TYPE,\n [requiredType])) {\n return this.enforce_(context, 'setAttributeNS',\n STRING_TO_TYPE[requiredType],\n originalFn, 2, args);\n }\n }\n return apply(originalFn, context, args);\n }\n\n /**\n * Wrapper for DOM mutator functions that enforces type checks if the context\n * (or, optionally, its parent node) is a script node.\n * For each argument, it will make sure that text nodes pass through a\n * default policy, or generate a violation. To skip that check, pass\n * TrustedScript objects instead.\n * @param {!Element|!Node} context The context for the call to the original\n * function.\n * @param {boolean} checkParent Check parent of context instead.\n * @param {!Function} originalFn The original mutator function.\n * @return {*}\n */\n enforceTypeInScriptNodes_(context, checkParent, originalFn, ...args) {\n const objToCheck = checkParent ? context.parentNode : context;\n if (objToCheck instanceof HTMLScriptElement && args.length > 0) {\n for (let argNumber = 0; argNumber < args.length; argNumber++) {\n let arg = args[argNumber];\n if (arg instanceof Node && arg.nodeType !== Node.TEXT_NODE) {\n continue; // Type is not interesting\n }\n if (arg instanceof Node && arg.nodeType == Node.TEXT_NODE) {\n arg = arg.textContent;\n } else if (TrustedTypes.isScript(arg)) {\n // TODO(koto): Consider removing this branch, as it's hard to spec.\n // Convert to text node and go on.\n args[argNumber] = document.createTextNode('' + arg);\n continue;\n }\n\n // Try to run a default policy on argsthe argument\n const fallbackValue = this.maybeCallDefaultPolicy_(\n 'TrustedScript', '' + arg, 'script.text');\n if (fallbackValue === null || fallbackValue === undefined) {\n this.processViolation_(context, originalFn.name,\n TrustedTypes.TrustedScript, arg);\n } else {\n arg = fallbackValue;\n }\n args[argNumber] = document.createTextNode('' + arg);\n }\n }\n return apply(originalFn, context, args);\n }\n\n /**\n * Wrapper for Element.insertAdjacentText that enforces type checks for\n * inserting text into a script node.\n * @param {!Object} context The context for the call to the original function.\n * @param {!Function} originalFn The original insertAdjacentText function.\n */\n insertAdjacentTextWrapper_(context, originalFn, ...args) {\n const riskyPositions = ['beforebegin', 'afterend'];\n if (context instanceof Element &&\n context.parentElement instanceof HTMLScriptElement &&\n args.length > 1 &&\n riskyPositions.includes(args[0]) &&\n !(TrustedTypes.isScript(args[1]))) {\n // Run a default policy on args[1]\n args[1] = '' + args[1];\n const fallbackValue = this.maybeCallDefaultPolicy_('TrustedScript',\n args[1], 'script.text');\n if (fallbackValue === null || fallbackValue === undefined) {\n this.processViolation_(context, 'insertAdjacentText',\n TrustedTypes.TrustedScript, args[1]);\n } else {\n args[1] = fallbackValue;\n }\n\n const textNode = document.createTextNode('' + args[1]);\n\n\n const insertBefore = /** @type function(this: Node) */(\n this.originalSetters_[this.getKey_(Node.prototype, 'insertBefore')]);\n\n switch (args[0]) {\n case riskyPositions[0]: // 'beforebegin'\n apply(insertBefore, context.parentElement,\n [textNode, context]);\n break;\n case riskyPositions[1]: // 'afterend'\n apply(insertBefore, context.parentElement,\n [textNode, context.nextSibling]);\n break;\n }\n return;\n }\n apply(originalFn, context, args);\n }\n\n /**\n * Wraps a setter with the enforcement wrapper.\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @param {!Function} type The type to enforce.\n * @param {number} argNumber Number of the argument to enforce the type of.\n * @private\n */\n wrapWithEnforceFunction_(object, name, type, argNumber) {\n const that = this;\n this.wrapFunction_(\n object,\n name,\n /**\n * @this {TrustedTypesEnforcer}\n * @param {function(!Function, ...*)} originalFn\n * @return {*}\n */\n function(originalFn, ...args) {\n return that.enforce_.call(that, this, name, type, originalFn,\n argNumber, args);\n });\n }\n\n\n /**\n * Wraps an existing function with a given function body and stores the\n * original function.\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @param {function(!Function, ...*)} functionBody The wrapper function.\n */\n wrapFunction_(object, name, functionBody) {\n const descriptor = getOwnPropertyDescriptor(object, name);\n const originalFn = /** @type function(*):* */ (\n descriptor ? descriptor.value : null);\n\n if (!(originalFn instanceof Function)) {\n throw new TypeError(\n 'Property ' + name + ' on object' + object + ' is not a function');\n }\n\n const key = this.getKey_(object, name);\n if (this.originalSetters_[key]) {\n throw new Error(\n `TrustedTypesEnforcer: Double installation detected: ${key} ${name}`);\n }\n installFunction(\n object,\n name,\n /**\n * @this {TrustedTypesEnforcer}\n * @return {*}\n */\n function(...args) {\n return functionBody.bind(this, originalFn).apply(this, args);\n });\n this.originalSetters_[key] = originalFn;\n }\n\n /**\n * Wraps a setter with the enforcement wrapper.\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @param {!Function} type The type to enforce.\n * @param {!Object=} descriptorObject If present, will reuse the\n * setter/getter from this one, instead of object. Used for redefining\n * setters in subclasses.\n * @private\n */\n wrapSetter_(object, name, type, descriptorObject = undefined) {\n if (descriptorObject && !isPrototypeOf.call(descriptorObject, object)) {\n throw new Error('Invalid prototype chain');\n }\n\n let useObject = descriptorObject || object;\n let descriptor;\n let originalSetter;\n const stopAt = getPrototypeOf(Node.prototype);\n\n // Find the descriptor on the object or its prototypes, stopping at Node.\n do {\n descriptor = getOwnPropertyDescriptor(useObject, name);\n originalSetter = /** @type {function(*):*} */ (descriptor ?\n descriptor.set : null);\n if (!originalSetter) {\n useObject = getPrototypeOf(useObject) || stopAt;\n }\n } while (!(originalSetter || useObject === stopAt || !useObject));\n\n if (!(originalSetter instanceof Function)) {\n throw new TypeError(\n 'No setter for property ' + name + ' on object' + object);\n }\n\n const key = this.getKey_(object, name);\n if (this.originalSetters_[key]) {\n throw new Error(\n `TrustedTypesEnforcer: Double installation detected: ${key} ${name}`);\n }\n const that = this;\n /**\n * @this {TrustedTypesEnforcer}\n * @param {*} value\n */\n const enforcingSetter = function(value) {\n that.enforce_.call(that, this, name, type, originalSetter, 0,\n [value]);\n };\n\n if (useObject === object) {\n installSetter(\n object,\n name,\n enforcingSetter);\n } else {\n // Since we're creating a new setter in subclass, we also need to\n // overwrite the getter.\n installSetterAndGetter(\n object,\n name,\n enforcingSetter,\n descriptor.get\n );\n }\n this.originalSetters_[key] = originalSetter;\n }\n\n /**\n * Restores the original setter for the property, as encountered during\n * install().\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @param {!Object=} descriptorObject If present, will restore the original\n * setter/getter from this one, instead of object.\n * @private\n */\n restoreSetter_(object, name, descriptorObject = undefined) {\n const key = this.getKey_(object, name);\n if (descriptorObject && !isPrototypeOf.call(descriptorObject, object)) {\n throw new Error('Invalid prototype chain');\n }\n if (!this.originalSetters_[key]) {\n throw new Error(\n // eslint-disable-next-line max-len\n `TrustedTypesEnforcer: Cannot restore (double uninstallation?): ${key} ${name}`);\n }\n if (descriptorObject) {\n // We have to also overwrite a getter.\n installSetterAndGetter(object, name, this.originalSetters_[key],\n getOwnPropertyDescriptor(descriptorObject, name).get);\n } else {\n installSetter(object, name, this.originalSetters_[key]);\n }\n delete this.originalSetters_[key];\n }\n\n /**\n * Restores the original method of an object, as encountered during install().\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @private\n */\n restoreFunction_(object, name) {\n const key = this.getKey_(object, name);\n if (!this.originalSetters_[key]) {\n throw new Error(\n // eslint-disable-next-line max-len\n `TrustedTypesEnforcer: Cannot restore (double uninstallation?): ${key} ${name}`);\n }\n installFunction(object, name, this.originalSetters_[key]);\n delete this.originalSetters_[key];\n }\n\n /**\n * Returns the key name for caching original setters.\n * @param {!Object} object The object of the to-be-wrapped property.\n * @param {string} name The name of the property.\n * @return {string} Key name.\n * @private\n */\n getKey_(object, name) {\n // TODO(msamuel): Can we use Object.prototype.toString.call(object)\n // to get an unspoofable string here?\n // TODO(msamuel): fail on '-' in object.constructor.name?\n // No Function.name in IE 11\n const ctrName = '' + (\n object.constructor.name ?\n object.constructor.name :\n object.constructor);\n return ctrName + '-' + name;\n }\n\n /**\n * Calls a default policy.\n * @param {string} typeName Type name to attempt to produce from a value.\n * @param {*} value The value to pass to a default policy\n * @param {string} sink The sink name that the default policy will be called\n * with.\n * @throws {Error} If the default policy throws, or not exist.\n * @return {Function?} The trusted value or null, if the input value shoudl\n * be rejected.\n */\n maybeCallDefaultPolicy_(typeName, value, sink = '') {\n // Apply a fallback policy, if it exists.\n const fallbackPolicy = TrustedTypes['defaultPolicy'];\n if (!fallbackPolicy) {\n return null;\n }\n if (!TYPE_CHECKER_MAP.hasOwnProperty(typeName)) {\n return null;\n }\n return fallbackPolicy[TYPE_PRODUCER_MAP[typeName]](value, '' + sink);\n }\n\n /**\n * Logs and enforces TrustedTypes depending on the given configuration.\n * @template T\n * @param {!Object} context The object that the setter is called for.\n * @param {string} propertyName The name of the property.\n * @param {!Function} typeToEnforce The type to enforce.\n * @param {function(?):T} originalSetter Original setter.\n * @param {number} argNumber Number of argument to enforce the type of.\n * @param {Array} args Arguments.\n * @return {T}\n * @private\n */\n enforce_(context, propertyName, typeToEnforce, originalSetter, argNumber,\n args) {\n const value = args[argNumber];\n const typeName = '' + typeToEnforce.name;\n // If typed value is given, pass through.\n if (TYPE_CHECKER_MAP.hasOwnProperty(typeName) &&\n TYPE_CHECKER_MAP[typeName](value)) {\n if (stringifyForRangeHack &&\n propertyName == 'createContextualFragment') {\n // IE 11 hack, somehow the value is not stringified implicitly.\n args[argNumber] = args[argNumber].toString();\n }\n return apply(originalSetter, context, args);\n }\n\n if (typeToEnforce === TrustedTypes.TrustedScript) {\n const isInlineEventHandler =\n propertyName == 'setAttribute' ||\n propertyName === 'setAttributeNS' ||\n apply(slice, propertyName, [0, 2]) === 'on';\n // If a function (instead of string) is passed to inline event attribute,\n // or set(Timeout|Interval), pass through.\n const propertyAcceptsFunctions =\n propertyName === 'setInterval' ||\n propertyName === 'setTimeout' ||\n isInlineEventHandler;\n if ((propertyAcceptsFunctions && typeof value === 'function') ||\n (isInlineEventHandler && value === null)) {\n return apply(originalSetter, context, args);\n }\n }\n\n // Apply a fallback policy, if it exists.\n args[argNumber] = '' + value;\n const objName = context instanceof Element ?\n context.localName :\n getConstructorName_(context ? context.constructor : window.constructor);\n const fallbackValue = this.maybeCallDefaultPolicy_(\n typeName, value, objName + '.' + propertyName);\n if (fallbackValue === null || fallbackValue === undefined) {\n // This will throw a TypeError if enforcement is enabled.\n this.processViolation_(context, propertyName, typeToEnforce, value);\n } else {\n // Use the value modified by the default policy.\n args[argNumber] = fallbackValue;\n }\n return apply(originalSetter, context, args);\n }\n\n /**\n * Report a TT violation.\n * @param {!Object} context The object that the setter is called for.\n * @param {string} propertyName The name of the property.\n * @param {!Function} typeToEnforce The type to enforce.\n * @param {string} value The value that was violated the restrictions.\n * @throws {TypeError} if the enforcement is enabled.\n */\n processViolation_(context, propertyName, typeToEnforce, value) {\n const contextName = getConstructorName_(context.constructor) ||\n '' + context;\n const message = `Failed to set ${propertyName} on ${contextName}: `\n + `This property requires ${typeToEnforce.name}.`;\n\n if (this.config_.isLoggingEnabled) {\n // eslint-disable-next-line no-console\n console.warn(message, propertyName, context, typeToEnforce, value);\n }\n\n // Unconditionally dispatch an event.\n if (typeof SecurityPolicyViolationEvent == 'function') {\n let blockedURI = '';\n if (typeToEnforce === TrustedTypes.TrustedURL ||\n typeToEnforce === TrustedTypes.TrustedScriptURL) {\n blockedURI = parseUrl_(value) || '';\n if (blockedURI) {\n blockedURI = blockedURI.href;\n }\n }\n const valueSlice = apply(slice, '' + value, [0, 40]);\n const event = new SecurityPolicyViolationEvent(\n 'securitypolicyviolation',\n {\n 'bubbles': true,\n 'blockedURI': blockedURI,\n 'disposition': this.config_.isEnforcementEnabled ?\n 'enforce' : 'report',\n 'documentURI': document.location.href,\n 'effectiveDirective': ENFORCEMENT_DIRECTIVE_NAME,\n 'originalPolicy': this.config_.cspString,\n 'statusCode': 0,\n 'violatedDirective': ENFORCEMENT_DIRECTIVE_NAME,\n 'sample': `${contextName}.${propertyName} ${valueSlice}`,\n });\n if (context instanceof Node && context.isConnected) {\n context.dispatchEvent(event);\n } else { // Fallback - dispatch an event on base document.\n document.dispatchEvent(event);\n }\n }\n\n if (this.config_.isEnforcementEnabled) {\n throw new TypeError(message);\n }\n }\n}\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n/**\n * @fileoverview Entry point for a polyfill that only defines the types\n * (i.e. no enforcement logic).\n */\nimport {trustedTypes, TrustedTypePolicy, TrustedTypePolicyFactory} from\n '../trustedtypes.js';\n\nconst tt = trustedTypes;\n\n/**\n * Sets up the public Trusted Types API in the global object.\n */\nfunction setupPolyfill() {\n // We use array accessors to make sure Closure compiler will not alter the\n // names of the properties..\n\n // we setup the polyfill only in browser environment.\n if (typeof window === 'undefined') {\n return;\n }\n const rootProperty = 'trustedTypes';\n\n // Convert old window.TrustedTypes to window.trustedTypes.\n if (window['TrustedTypes'] && typeof window[rootProperty] === 'undefined') {\n window[rootProperty] = Object.freeze(window['TrustedTypes']);\n }\n\n if (typeof window[rootProperty] !== 'undefined') {\n return;\n }\n\n const publicApi = Object.create(TrustedTypePolicyFactory.prototype);\n Object.assign(publicApi, {\n 'isHTML': tt.isHTML,\n 'isURL': tt.isURL,\n 'isScriptURL': tt.isScriptURL,\n 'isScript': tt.isScript,\n 'createPolicy': tt.createPolicy,\n 'getAttributeType': tt.getAttributeType,\n 'getPropertyType': tt.getPropertyType,\n 'getTypeMapping': tt.getTypeMapping,\n 'emptyHTML': tt.emptyHTML,\n 'emptyScript': tt.emptyScript,\n '_isPolyfill_': true,\n });\n Object.defineProperty(\n publicApi,\n 'defaultPolicy',\n Object.getOwnPropertyDescriptor(tt, 'defaultPolicy') || {});\n\n window[rootProperty] = Object.freeze(publicApi);\n\n window['TrustedHTML'] = tt.TrustedHTML;\n window['TrustedURL'] = tt.TrustedURL;\n window['TrustedScriptURL'] = tt.TrustedScriptURL;\n window['TrustedScript'] = tt.TrustedScript;\n window['TrustedTypePolicy'] = TrustedTypePolicy;\n window['TrustedTypePolicyFactory'] = TrustedTypePolicyFactory;\n}\n\nsetupPolyfill();\n\nexport default tt;\n","/**\n * @license\n * Copyright 2017 Google Inc. All Rights Reserved.\n *\n * Licensed under the W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE.\n *\n * https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document\n */\n\n/**\n * @fileoverview Entry point for a polyfill that enforces the types.\n */\nimport {TrustedTypesEnforcer} from '../enforcer.js';\nimport {TrustedTypeConfig} from '../data/trustedtypeconfig.js';\n// import and setup trusted types\nimport './api_only.js';\n\n/* eslint-enable no-unused-vars */\n\n/**\n * Tries to guess a CSP policy from:\n * - the current polyfill script element text content (if prefixed with\n * \"Content-Security-Policy:\")\n * - the data-csp attribute value of the current script element.\n * - meta header\n * @return {?string} Guessed CSP value, or null.\n */\nfunction detectPolicy() {\n try {\n const currentScript = document.currentScript || (function() {\n const scripts = document.getElementsByTagName('script');\n return scripts[scripts.length - 1];\n })();\n\n const bodyPrefix = 'Content-Security-Policy:';\n if (currentScript &&\n currentScript.textContent.trim().substr(0, bodyPrefix.length) ==\n bodyPrefix) {\n return currentScript.textContent.trim().slice(bodyPrefix.length);\n }\n if (currentScript.dataset['csp']) {\n return currentScript.dataset['csp'];\n }\n const cspInMeta = document.head.querySelector(\n 'meta[http-equiv^=\"Content-Security-Policy\"]');\n if (cspInMeta) {\n return cspInMeta['content'].trim();\n }\n } catch (e) {\n return null;\n }\n return null;\n}\n\n/**\n * Bootstraps all trusted types polyfill and their enforcement.\n */\nexport function bootstrap() {\n const csp = detectPolicy();\n const config = csp ? TrustedTypeConfig.fromCSP(csp) : new TrustedTypeConfig(\n /* isLoggingEnabled */ false,\n /* isEnforcementEnabled */ false,\n /* allowedPolicyNames */ [],\n /* allowDuplicates */ true);\n\n const trustedTypesEnforcer = new TrustedTypesEnforcer(config);\n\n trustedTypesEnforcer.install();\n}\n\n/**\n * Determines if the enforcement should be enabled.\n * @return {boolean}\n */\nfunction shouldBootstrap() {\n for (const rootProperty of ['trustedTypes', 'TrustedTypes']) {\n if (window[rootProperty] && !window[rootProperty]['_isPolyfill_']) {\n // Native implementation exists\n return false;\n }\n }\n return true;\n}\n\n// Bootstrap only if native implementation is missing.\nif (shouldBootstrap()) {\n bootstrap();\n}\n"]} \ No newline at end of file diff --git a/dist/spec/index.html b/dist/spec/index.html index 71e3a149..2d294966 100644 --- a/dist/spec/index.html +++ b/dist/spec/index.html @@ -1214,7 +1214,7 @@ - +