{"_id":"@damien.garrido/yacspp","_rev":"2-c4ecf0791966638dbbb347b2ceaa8637","name":"@damien.garrido/yacspp","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@damien.garrido/yacspp","version":"1.0.0","description":"Yet Another Content Security Policy Parser","homepage":"https://github.com/DamienGarrido/yacspp.git","keywords":["content","security","policy","parser"],"author":{"name":"Damien Garrido","email":"Damien.Garrido.Work@gmail.com"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/DamienGarrido/yacspp.git"},"main":"index.js","scripts":{"test":"jest"},"devDependencies":{"jest":"^27.4.3"},"gitHead":"1c9ca4bdf16e9f6d97c021787b424280514a890d","bugs":{"url":"https://github.com/DamienGarrido/yacspp/issues"},"_id":"@damien.garrido/yacspp@1.0.0","_nodeVersion":"14.18.0","_npmVersion":"8.1.3","dist":{"integrity":"sha512-QZP4bLs7EYmY4D1zUHQ7jSlUn/5NhioGLL21WwGQz4C41uVY5LsLqOrU8H91IrzE0cLi3vY89uHqjapKP6+qIA==","shasum":"d9b5a058de0c2c07757498e8484ae2efda8175a4","tarball":"https://registry.npmjs.org/@damien.garrido/yacspp/-/yacspp-1.0.0.tgz","fileCount":4,"unpackedSize":11909,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhtzcVCRA9TVsSAnZWagAA6H4QAJDzHK1SWBiFXeFnm8HE\npGZbCK4xxo1+HeW4Cng7QQ3eW+E8wmDzfTN4OB2iLpZFBjRzYm3PWXLLmudp\nuI75b97gTk7ZsWoYZw4lW4WoIWHUyT8LOF4YgJPw/PcmuXvc6Yhnid476OTm\nMn1hxHFmDEzYeDNYI7xXMJoN3jUAk/VwRBMYjW2Dqo5fhC+xxYirkCH3WbGj\nEUYQ7XjUj+L+jgWKFhf2WmIOhkTrmU22goWqmlgSNmZzFPP0Zc2JAcWa6jax\na0e2AWcQC/JC9U6rxzRK+OiZdjU5wO8T9IqU/tni8mZqnTw01eU8vT+Tgloc\n6bpRiaJ/rPMJMprF0DkBLphpa7il3b9t/Fr2ZML+IT15rwpNCEH3FKUNDEUY\ndpE2DdZCd4DnbGz7w4zDEElAbpRMaTVfQw0o53czLh8bM8Mo4t0Ut178mPL9\n3OLvtKc8ArYdc2m9qpzo+e04jTkkoXtQl5CLC7AAruIubmqTGB1oWQGAM3yz\nUY5kN5FHA8Y9EgM8mbHEsnKezvwRvFRzeU8mCLbR7tKoEMyS/H4G7/5c4H5a\nkTs6b6UuZWAEAv8WpG6hqeB7uHFi6uwKJc5M9XCpGRruaNI5U7Zb4nidwBMk\nRp06nh3CU6vqCp4YMw4bqqzc2RD091XDZ4vSbycQ/hCQZpIeyTGxiHm5jIXI\n6vKx\r\n=yR0K\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAF38K5mO3maacxtHFM+x+ZT1bFqGKjZX9njt1gt/vVyAiEAstZ60rSwOvluTlsxZalaiaxJKoi/x20oaMGWB2Kan1c="}]},"_npmUser":{"name":"damien.garrido","email":"Damien.Garrido.Work@gmail.com"},"directories":{},"maintainers":[{"name":"damien.garrido","email":"Damien.Garrido.Work@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/yacspp_1.0.0_1639397141455_0.17415708802245722"},"_hasShrinkwrap":false},"1.0.1":{"name":"@damien.garrido/yacspp","version":"1.0.1","description":"Yet Another Content Security Policy Parser","homepage":"https://github.com/DamienGarrido/yacspp.git","keywords":["content","security","policy","parser"],"author":{"name":"Damien Garrido","email":"Damien.Garrido.Work@gmail.com"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/DamienGarrido/yacspp.git"},"main":"index.js","scripts":{"test":"jest"},"devDependencies":{"jest":"^27.4.3"},"gitHead":"638a49d6b036758851c8bd8dfc19717c4872b374","bugs":{"url":"https://github.com/DamienGarrido/yacspp/issues"},"_id":"@damien.garrido/yacspp@1.0.1","_nodeVersion":"16.13.1","_npmVersion":"8.1.2","dist":{"integrity":"sha512-Or9iQcHXcJbIVDPWvOp4fsS6tKc7PKOAbu7DL2OUVXPjZE8/8aVWT4SHbVHju6ecSEbWoFsV3q/2bWyWMmvRjg==","shasum":"bcbdfa6c07ff12e69251ba85ab660e6dca7256c4","tarball":"https://registry.npmjs.org/@damien.garrido/yacspp/-/yacspp-1.0.1.tgz","fileCount":4,"unpackedSize":13233,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhuNCeCRA9TVsSAnZWagAAopEQAIw/RplZxSd+FakWZkNd\nyzfyDm9JyQ476kwjLDpNfDk89HapE/qwtTa3t1v3N5+XrU4E1P0dOfehqNX3\nJ/uhbBPft88zE798UFeHKT/gFnVOiN4HLmVQM2+/FKzyQ7l+Z1m4hdqKW3RO\nzM7rMjTIDBfkYsdN0bCiyfVfUd38Gmr5y9SSta3SLjbick6obu/7wnYAwbHz\ncWABRjvhJs+J9YA1P4fjKdLJsyDzgMeqr7+98FiG0Eyu4uFZooMQGXdH89IU\n4sX/bpNEERik4QTXEG/P/00MgVi5C6gUCXVeeJ0Z1vrvorX25WEA78G7rylu\nhDxICtKudj0MKqfMkSZZUfUb5V6/4QwAXA9z3NH0JcoyVVl6ycV40FF+8QaH\nJIjW51Dn/EN3+O+pl6v2UxbqV8sBb6FcRVmBBZ/AfodmTuwytPTjKOuL+o2Q\nCTny1tcnmRIKgOVP8zc90qAwh3EWEjqtbwnmfltml1i7bfzuT0l7+Lq89A8u\ngGHrMIbKaXb3bxXkssU/N/oKthESfhvxb0FV9pXY3e50Yx9+kJYb11mw9alS\noVo+e4xy1f40oOplfMDpEJaKlD9Wi13qlGaXWzAWHA9aCHwlB8mcE2nObNGs\ni0C7itWsIYK66MSRjeEin4VFbR0ZtloFqtnChJnNBv5ssd8mUI11dEBnc8Qx\nvLUh\r\n=kU2G\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDbL41EyhMGVfCVZA+RzIvO7u6QXg4TyWxSEqK+gLUKRAIgWQ/3QuXQGsbdcdcSg9M2AUHv88NRkw2qEKicmEwvclw="}]},"_npmUser":{"name":"damien.garrido","email":"Damien.Garrido.Work@gmail.com"},"directories":{},"maintainers":[{"name":"damien.garrido","email":"Damien.Garrido.Work@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/yacspp_1.0.1_1639501981805_0.10677871258692706"},"_hasShrinkwrap":false}},"time":{"created":"2021-12-13T12:05:41.410Z","1.0.0":"2021-12-13T12:05:41.580Z","modified":"2022-04-05T02:38:46.001Z","1.0.1":"2021-12-14T17:13:02.195Z"},"maintainers":[{"name":"damien.garrido","email":"Damien.Garrido.Work@gmail.com"}],"description":"Yet Another Content Security Policy Parser","homepage":"https://github.com/DamienGarrido/yacspp.git","keywords":["content","security","policy","parser"],"repository":{"type":"git","url":"git+https://github.com/DamienGarrido/yacspp.git"},"author":{"name":"Damien Garrido","email":"Damien.Garrido.Work@gmail.com"},"bugs":{"url":"https://github.com/DamienGarrido/yacspp/issues"},"license":"ISC","readme":"# Content Security Policy Parser\n\n## Installation\n\n```bash\nnpm install --save-dev @damien.garrido/yacspp\n```\n\n## Usage\n\n```javascript\n#!/usr/bin/env node\nconst { ContentSecurityPolicyParser } = require('@damien.garrido/yacspp');\n\nconst header = \"default-src 'self'; base-uri 'self'; block-all-mixed-content; font-src 'self' https: data:; frame-ancestors 'self'; img-src 'self' data: www.example.com; object-src 'none'; script-src 'self' 'sha256-2yQBTLGLI1sDcBILfj/o6b5ufMv6CEwPYOk3RZI/WjE=' 'sha256-GeDavzSZ8O71Jggf/pQkKbt52dfZkrdNMQ3e+Ox+AkI='; script-src-attr 'none'; style-src 'self' https: 'sha256-pyVPiLlnqL9OWVoJPs/E6VVF5hBecRzM2gBiarnaqAo='; upgrade-insecure-requests;\";\n\nconst originalPolicy = new ContentSecurityPolicyParser(header);\nconst updatedPolicy = new ContentSecurityPolicyParser(header);\n\nconst filteredOutDirectives = ['block-all-mixed-content']\nnewDirectives = {\n  'sandbox': null,\n  'my-src': [\"'self'\", 'http:', 'https:']\n}\nconst augmentedDirectives = {\n  'default-src': ['http:', 'https:']\n}\nconst diminishedDirectives = {\n  'img-src': ['www.example.com']\n}\n\n// Filter out directives\nfor ([directive, sources] of Object.entries(originalPolicy.directives)) {\n  if (filteredOutDirectives.includes(directive)) {\n    updatedPolicy.remove(directive)\n  }\n}\n\n// Add new directives\nfor ([directive, sources] of Object.entries(newDirectives)) {\n  updatedPolicy.add_source(directive, sources)\n}\n\n// Add sources to directives\nfor ([directive, sources] of Object.entries(augmentedDirectives)) {\n  updatedPolicy.add_source(directive, sources)\n}\n\n// Remove sources from directives\nfor ([directive, sources] of Object.entries(diminishedDirectives)) {\n  updatedPolicy.remove_source(directive, sources)\n}\n\nconsole.log(originalPolicy.directives)\nconsole.log(updatedPolicy.directives)\nconsole.log(originalPolicy.toString())\nconsole.log(updatedPolicy.toString())\n```\n","readmeFilename":"README.md"}