{"_id":"@ampproject/purifier","_rev":"17-c72619d8a344cf649a465f442325a1a1","name":"@ampproject/purifier","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@ampproject/purifier","version":"1.0.0","description":"AMP-specific sanitization library","author":{"name":"The AMP HTML Authors"},"license":"Apache-2.0","main":"dist/purifier.js","scripts":{"build":"rollup -c rollup.config.js"},"keywords":["amp","sanitizer","sanitize","purify"],"repository":{"type":"git","url":"git+https://github.com/ampproject/amphtml.git","directory":"src/purifier"},"homepage":"https://github.com/ampproject/amphtml/tree/master/src/purifier","devDependencies":{"@rollup/plugin-alias":"3.0.0","rollup":"1.28.0"},"dependencies":{"dompurify":"2.0.7"},"bugs":{"url":"https://github.com/ampproject/amphtml/issues"},"_id":"@ampproject/purifier@1.0.0","_nodeVersion":"12.14.0","_npmVersion":"6.13.4","dist":{"integrity":"sha512-Y1CeFzEt3mfyM71GerOvQMP9J3qbrFi3Zsq3WllOXAU1Y+ctrwTlHGZKlP5/yjm6S/eKGQZzzy5rI8L2kpYs4A==","shasum":"ec12d8eddd7bfd7cebc0c45237c405672598b0e7","tarball":"https://registry.npmjs.org/@ampproject/purifier/-/purifier-1.0.0.tgz","fileCount":4,"unpackedSize":128993,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeF9F+CRA9TVsSAnZWagAA/ZAP/Ax3yAxFKFxulyWJAj/1\nSII/6O4sVIKt2k0dqOENLyG7idVCSjO/ASLTkPtb/E6+ZBHM32eNsu+OS1g7\nsALnLxOXA5TThZnwqo32ahPf55VPmJ1Ogm6wvTNFM+S+FFNZN9IIyzcl+CZy\ntMq2rv5fqOSOYAjrPZ+3CY42XFw+ZFToEG5VrHPBuUnZ38zpYEEHQbFAoE91\ntwkF82xiY15OiJUF473LWVU+CNks7GDZQwWI4bClB2xhg9JRdwb+n+rypBsb\ntFNCNsSp6oSDFOMwe3LmrGvHGcsiEwbDmhH7ZQYwgoPJPYozTw/MiBvrnKSC\nxR8bLzQ96+sm8m+fwkYtXbbhDipR7uhG/62TE9koKPpMTrG7t+cpvpbhCWI+\nGmqRvMBGz0J9whcTJciz406fVM98q4hxyx493hkrD8BlHPYYxRfAjL8kF6Qq\nItZCT+Bw6DzaLx+Py+Dn9P4dWfZtdQKoOpjwXlOj6E9sPLuY7GHvSzmv3oUw\n0wElZJ7VaJ5YpJSaj65U1zYyscn0WkYXbHUxxaa7OHxCSbhzZcKuxb0b56P2\nCJZ5mAOIrsTi+4a/5Iw2HkDGvBwmq92HRrSEbe0gpKdgKJEwdLOHiE6X6eg1\nVFaTZMSPYP/cWCt7xmqoUDup6LNvwOW9vZin2RGZAQwuuwl+RiKuILn6UZ0Z\nu3Zv\r\n=s8N2\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAwS+efEBDZxzJwYddmgu1L2NbO56vltw1U5+S9wpK0+AiAJ0zu4Gr6C37vUNVauE1Myqk0ZoHGlOyFWLwNxJUBjVw=="}]},"maintainers":[{"name":"erwinmombay","email":"erwin.mombay@gmail.com"},{"name":"fstanis","email":"filip@stanis.me"},{"name":"amp-toolbox","email":"amp-toolbox-eng@google.com"},{"name":"choumx","email":"willchou@google.com"},{"name":"sepandparhami","email":"sepandparhami@gmail.com"},{"name":"ampproject-admin","email":"admin@ampproject.org"},{"name":"kristoferbaxter","email":"kbax@me.com"},{"name":"jridgewell","email":"justin+npm@ridgewell.name"}],"_npmUser":{"name":"fstanis","email":"filip@stanis.me"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/purifier_1.0.0_1578619262065_0.04107967155478476"},"_hasShrinkwrap":false,"deprecated":"This npm package has been deprecated. See https://github.com/ampproject/amphtml/blob/master/src/purifier/README.md for the latest code."},"1.0.1":{"name":"@ampproject/purifier","version":"1.0.1","description":"AMP-specific sanitization library","author":{"name":"The AMP HTML Authors"},"license":"Apache-2.0","main":"dist/purifier.js","module":"dist/purifier.mjs","types":"purifier.d.ts","scripts":{"build":"rollup -c rollup.config.js"},"keywords":["amp","sanitizer","sanitize","purify"],"repository":{"type":"git","url":"git+https://github.com/ampproject/amphtml.git","directory":"src/purifier"},"homepage":"https://github.com/ampproject/amphtml/tree/master/src/purifier","devDependencies":{"@rollup/plugin-alias":"3.0.0","rollup":"1.28.0"},"dependencies":{"dompurify":"2.0.7","@types/dompurify":"2.0.1"},"optionalDependencies":{"@types/dompurify":"2.0.1"},"bugs":{"url":"https://github.com/ampproject/amphtml/issues"},"_id":"@ampproject/purifier@1.0.1","_nodeVersion":"12.14.0","_npmVersion":"6.13.4","dist":{"integrity":"sha512-3Xccz5mytmhfrOEKP+hs7WehJ7tHcw5+Sk7hGbOqZ5nXi6P2b1TfYTdP0g8BwjDd3i1FmoachhhOPXfRfgdoyw==","shasum":"9bdfb253acc88e66806f5ee930d6766b213468e7","tarball":"https://registry.npmjs.org/@ampproject/purifier/-/purifier-1.0.1.tgz","fileCount":7,"unpackedSize":255620,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeHaYLCRA9TVsSAnZWagAAMn4P+gKgSjsP6LM+lm7jK+ge\nV/JWZctDQ7zAOKyfDQn1HXlNkHEwKM8VHHoTlyW7Q5GCJ2eodYgLqYLXB1ao\nPObg0rt9ZRVYOBx44w5DxJgniNeH/1g5bnKNjxfuulx9tUPi+3cuvzE/hh0i\n2Is2YIRvHUUKwv3Xsh3qIuCO8hTOs/FLab0wR6mxwW8K+J5Px27tOzjjxeoZ\ntYyKVht9uO15NxvUz7NHGy/xBIgJE0BJsOdRJfUKGwDyDdiLCSOv3yJZQHS5\nL7Qmbn7WerjhNVcfJvzHFDurcNUOgJoFRH6/eA2S44SoIqqljN6sKVQR3G4o\nb3vaiK8z90516Mhs5JvbaseIajFiU9OGN31mGVJ4Eh5xeGzqKU4NoFeD/lIY\nhltL5nTNJTdUpCtMmmvRVMgjciwXMjrg96tzMw5uWIa3ZZyAZAxfUcXIUx9Z\nARJBzKpSUpFgi6oVidzGfd0P8iwcShk2s2RZHFIINwLVtIq6cLpFc/isFI1O\np3W0cw0LntTk935VtqYlWZ95fuHB8mtUkOj8aXu4L3YqojiLDUo0vbu7DJQV\nILNqWzxrWKbRGsAg64ejjUTINYJiw6O39v0GAORmVk19HIr8xCInJ1Ys/CwA\nRMG+4nEA3t2PStUVYLH4CjP7VO7h+j1FnU8NNQSWkI91GwWjhFpe9oghroLO\nUNUn\r\n=I6SD\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC0gBH7X5qxkUGKWTqtieIprn0hGI96vSj11tRwk3BIWgIhAIxMpxMKFGzevOwUNPLc5Tse9ouT80XMo5N9BUCjqS5E"}]},"maintainers":[{"name":"amp-toolbox","email":"amp-toolbox-eng@google.com"},{"name":"ampproject-admin","email":"admin@ampproject.org"},{"name":"choumx","email":"willchou@google.com"},{"name":"erwinmombay","email":"erwin.mombay@gmail.com"},{"name":"fstanis","email":"filip@stanis.me"},{"name":"jridgewell","email":"justin+npm@ridgewell.name"},{"name":"kristoferbaxter","email":"kbax@me.com"},{"name":"sepandparhami","email":"sepandparhami@gmail.com"}],"_npmUser":{"name":"fstanis","email":"filip@stanis.me"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/purifier_1.0.1_1579001354825_0.6040589203707984"},"_hasShrinkwrap":false,"deprecated":"This npm package has been deprecated. See https://github.com/ampproject/amphtml/blob/master/src/purifier/README.md for the latest code."},"1.0.2":{"name":"@ampproject/purifier","version":"1.0.2","description":"AMP-specific sanitization library","author":{"name":"The AMP HTML Authors"},"license":"Apache-2.0","main":"dist/purifier.js","module":"dist/purifier.mjs","types":"purifier.d.ts","scripts":{"build":"rollup -c rollup.config.js"},"keywords":["amp","sanitizer","sanitize","purify"],"repository":{"type":"git","url":"git+https://github.com/ampproject/amphtml.git","directory":"src/purifier"},"homepage":"https://github.com/ampproject/amphtml/tree/master/src/purifier","devDependencies":{"@rollup/plugin-alias":"3.0.0","rollup":"1.28.0"},"dependencies":{"dompurify":"2.0.7","@types/dompurify":"2.0.1"},"optionalDependencies":{"@types/dompurify":"2.0.1"},"bugs":{"url":"https://github.com/ampproject/amphtml/issues"},"_id":"@ampproject/purifier@1.0.2","_nodeVersion":"12.14.0","_npmVersion":"6.13.4","dist":{"integrity":"sha512-BSMzgae0lKWGx6wyilboILgDbn9i2wL53m7G1T7WLwk7KlIbuwIBKGs3dOovicpzmnrOPtLyxGdloFA6AXZiRg==","shasum":"9a952e513626b97866d471dabcb36bd39005ecf6","tarball":"https://registry.npmjs.org/@ampproject/purifier/-/purifier-1.0.2.tgz","fileCount":7,"unpackedSize":256616,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeH0RtCRA9TVsSAnZWagAA2ToP/3Ts8twFlG+CGUSrzxyW\nrIzmjuv/Y+qQFni3g7i6S5yWq9wFH5Mq2VqioqVXuSbzMI7GXid41pyZTSX6\nujES5R2CY2/OiHk07QI1Sjx9XVZpMgUEOKFds2Izs5aSKnC1p9gCLUoaJxVp\n5Tb8/20FWLkuW3v3eeb3IDsem4dO99Y36aqHXKXhzVxpUdqIDHYH8KO12HJB\nCpIa0nhNH2i2m/by/zEH+ZhwbTnD8B2s4Zs/Z2ewCQTswcCZEG1Oopf2irfj\nEFYynlaFLSV8R6mDNEveECNb9czui+PYPqursoI83gBY3HVVPZ67D8ALl2mV\nfPURVR5LZ2XZ3arFq3u+hR8RLNPXFyRZk/haFsZ5Njn7tZXqyRf8Imzt8i/s\nnHQNQkhsiehU14Aar6C9xGPBRzZ5zzS7XYku/7sdcXzL0o13++saHUJcwGRH\ni8qbxp6Fe11k6OdS5K2LhylOYSUbiz6lk+0x1CUWJn6b5k8F6RCNXdkjVjQD\nxjWDauh8IqblOtuJns8ZLSh9KoxzEkNW1gbbOpCAVobMnp1akf9eUy9WWS8O\nFCPEyzyn5NqE//dxn8REdrA7FBdGNv0ufFTBjTDEFzs/eXuWfPOMKKuSfk0w\n49kOcMZzY2YFOo+u/yf7b3XkzyGWEIrrKKoakIdq36nOsGMAfoxBCDxv1XWp\nMzW2\r\n=IakH\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCqoylMFfv0DZ7PnZtHkCegntkaOHQEq+JbryDAtC/IfAIhAL4W5aXRQ7mIgGzPcJzzd69CKi8PS80G2noNN0ehqMDc"}]},"maintainers":[{"name":"amp-toolbox","email":"amp-toolbox-eng@google.com"},{"name":"ampproject-admin","email":"admin@ampproject.org"},{"name":"choumx","email":"willchou@google.com"},{"name":"erwinmombay","email":"erwin.mombay@gmail.com"},{"name":"fstanis","email":"filip@stanis.me"},{"name":"jridgewell","email":"justin+npm@ridgewell.name"},{"name":"kristoferbaxter","email":"kbax@me.com"},{"name":"sepandparhami","email":"sepandparhami@gmail.com"}],"_npmUser":{"name":"fstanis","email":"filip@stanis.me"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/purifier_1.0.2_1579107436670_0.18072904937651835"},"_hasShrinkwrap":false,"deprecated":"This npm package has been deprecated. See https://github.com/ampproject/amphtml/blob/master/src/purifier/README.md for the latest code."}},"time":{"created":"2020-01-10T01:21:01.828Z","1.0.0":"2020-01-10T01:21:02.249Z","modified":"2022-04-04T13:52:48.066Z","1.0.1":"2020-01-14T11:29:14.967Z","1.0.2":"2020-01-15T16:57:16.811Z"},"maintainers":[{"email":"esther@amp.dev","name":"esth"},{"email":"bot@amp.dev","name":"ampprojectbot"},{"email":"kdwan@google.com","name":"kdwan"},{"email":"admin@ampproject.org","name":"ampproject-admin"},{"email":"kbax@me.com","name":"kristoferbaxter"},{"email":"justin+npm@ridgewell.name","name":"jridgewell"},{"email":"willchou@google.com","name":"choumx"},{"email":"amp-toolbox-eng@google.com","name":"amp-toolbox"},{"email":"filip@stanis.me","name":"fstanis"},{"email":"erwin.mombay@gmail.com","name":"erwinmombay"},{"email":"jzfisgreat@gmail.com","name":"samouri"},{"email":"carolineliu@google.com","name":"caroqliu"},{"email":"rsimha@amp.dev","name":"rsimha"},{"email":"dvoytenko@gmail.com","name":"dvoytenko"},{"email":"patrickkettner@gmail.com","name":"patrickkettner"},{"email":"orozcoalan@gmail.com","name":"alanorozco"}],"description":"AMP-specific sanitization library","homepage":"https://github.com/ampproject/amphtml/tree/master/src/purifier","keywords":["amp","sanitizer","sanitize","purify"],"repository":{"type":"git","url":"git+https://github.com/ampproject/amphtml.git","directory":"src/purifier"},"author":{"name":"The AMP HTML Authors"},"bugs":{"url":"https://github.com/ampproject/amphtml/issues"},"license":"Apache-2.0","readme":"# AMP Purifier\n\n[![npm package](https://img.shields.io/npm/v/@ampproject/purifier)](https://www.npmjs.com/package/@ampproject/purifier)\n\nThe AMP Purifier library contains an AMP-specific configuration for [DOMPurify](https://github.com/cure53/DOMPurify).\n\nThis library is internally used by [`amp-mustache`](https://amp.dev/documentation/components/amp-mustache/)\nto sanitize rendered Mustache.js templates before displaying them.\n\n## Installation\n\nInstall via:\n\n```sh\nnpm i @ampproject/purifier\n```\n\n## Usage\n\n```js\nimport {Purifier} from '@ampproject/purifier';\n\nconst purifier = new Purifier(document);\npurifier.purifyHtml('a<script>b</script>c'); // \"ac\"\n```\n\n### Usage with Mustache.js\n\n```js\nimport Mustache from 'mustache';\nimport {Purifier} from '@ampproject/purifier';\n\nconst purifier = new Purifier(document);\nconst _unescapedValue = Mustache.Writer.prototype.unescapedValue;\nMustache.Writer.prototype.unescapedValue = function(token, context) {\n  const result = _unescapedValue(token, context);\n  return purifier.purifyTagsForTripleMustache(result);\n};\nconst html = Mustache.render(template, data);\n\nconst body = purifier.purifyHtml(html);\nfor (const child of body.children) {\n  targetElement.appendChild(child);\n}\n```\n\n## Reference\n\nThe library has only a single export, the `Purifier` class.\n\n### `Purifier` constructor\n\n`new Purifier(doc, config, attrRewrite)`\n\n#### `doc`\n\nThe base document to use. Usually `window.document`.\n\n#### `config`\n\n_Optional_\n\n[DOMPurify configuration](https://github.com/cure53/DOMPurify#can-i-configure-dompurify)\nto use in addition to the AMP default one.\n\n#### `attrRewrite`\n\n_Optional_\n\nA function that, if provided, will be called for every sanitized attribute in\nthe output to change its value. It accepts the following attributes:\n\n- `tagName` - name of tag containing the attribute\n- `attrName` - name of attribute\n- `attrValue` - current attribute value\n\nThe returned value of this function is used as the new attribute value.\n\nFor example, this replaces the `href` of all `<a>` elements with example.com:\n\n```js\nnew Purifier(window.document, {}, (tagName, attrName, attrValue) => {\n  if (tagName === 'a' && attrName === 'href') {\n    return 'https://google.com';\n  }\n  return attrValue;\n});\n```\n\n### `purifyHtml`\n\n`purifyHtml(html)`\n\nUses DOMPurify to sanitize HTML in a way that ensures the fragment is valid AMP.\n\n#### `html`\n\nThe HTML code to sanitize (purify).\n\n#### Return value\n\nA <body> element containing the sanitized `html` markup.\n\n### `purifyTagsForTripleMustache`\n\n`purifyTagsForTripleMustache(html)`\n\nUses DOMPurify to sanitize HTML with stricter policy for unescaped templates\ne.g. triple mustache. See [`amp-mustache` documentation](https://amp.dev/documentation/components/amp-mustache/#validation)\nfor more information.\n\n#### `html`\n\nThe HTML code to sanitize (purify).\n\n#### Return value\n\nSanitized HTML (as a string).\n\n### `getAllowedTags`\n\n`getAllowedTags()`\n\nGets a copy of the map of allowed tag names (standard DOMPurify config).\n\n#### Return value\n\nAn object containing the list of allowed tags according to AMP's DOMPurify\nconfig.\n\n### `validateAttributeChange`\n\nReturns whether an attribute addition/modification/removal is valid according to\nAMP's DOMPurify config.\n\n`validateAttributeChange(node, attr, value)`\n\n#### `node`\n\nDOM node to check.\n\n#### `attr`\n\nAttribute name.\n\n#### `value`\n\nAttribute value (can be null).\n\n#### Return value\n\n`true` if the given attribute change is valid, `false` otherwise.\n","readmeFilename":"README.md"}