{"id":20809586,"url":"https://github.com/val-istar-guo/koa-csp","last_synced_at":"2025-05-07T08:10:37.340Z","repository":{"id":51860617,"uuid":"87420888","full_name":"Val-istar-Guo/koa-csp","owner":"Val-istar-Guo","description":"Used to set response header: Content-Security-Policy","archived":false,"fork":false,"pushed_at":"2024-09-04T16:52:21.000Z","size":112,"stargazers_count":2,"open_issues_count":0,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-15T20:52:53.317Z","etag":null,"topics":["content-security-policy","csp","koa","koa-csp","koa2"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Val-istar-Guo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":"val_istar_guo","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2017-04-06T11:19:04.000Z","updated_at":"2024-09-04T16:52:11.000Z","dependencies_parsed_at":"2022-08-23T12:51:31.840Z","dependency_job_id":"64b3ff01-62e2-4a26-8f9c-df8ea7d841e8","html_url":"https://github.com/Val-istar-Guo/koa-csp","commit_stats":{"total_commits":54,"total_committers":6,"mean_commits":9.0,"dds":"0.38888888888888884","last_synced_commit":"de9fd6511872d56433c08ce42cf2424d40e1d788"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Val-istar-Guo%2Fkoa-csp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Val-istar-Guo%2Fkoa-csp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Val-istar-Guo%2Fkoa-csp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Val-istar-Guo%2Fkoa-csp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Val-istar-Guo","download_url":"https://codeload.github.com/Val-istar-Guo/koa-csp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252839294,"owners_count":21812090,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["content-security-policy","csp","koa","koa-csp","koa2"],"created_at":"2024-11-17T20:14:49.465Z","updated_at":"2025-05-07T08:10:37.319Z","avatar_url":"https://github.com/Val-istar-Guo.png","language":"TypeScript","funding_links":["https://patreon.com/val_istar_guo"],"categories":[],"sub_categories":[],"readme":"\u003c!-- title --\u003e\n\u003cp align=\"center\" style=\"padding-top: 40px\"\u003e\n  \u003cimg src=\"./doc/images/logo.svg?sanitize=true\" width=\"120\" alt=\"logo\" /\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\" style=\"text-align: center\"\u003eKOA-CSP\u003c/h1\u003e\n\u003c!-- title --\u003e\n\n[![version](https://img.shields.io/npm/v/koa-csp.svg?style=flat-square)](https://www.npmjs.com/package/koa-csp)\n[![downloads](https://img.shields.io/npm/dm/koa-csp.svg?style=flat-square)](https://www.npmjs.com/package/koa-csp)\n[![license](https://img.shields.io/npm/l/koa-csp.svg?style=flat-square)](https://www.npmjs.com/package/koa-csp)\n[![dependencies](https://img.shields.io/librariesio/github/Val-istar-Guo/koa-csp.svg?style=flat-square)](https://www.npmjs.com/package/koa-csp)\n[![coveralls](https://img.shields.io/coveralls/github/Val-istar-Guo/koa-csp.svg?style=flat-square)](https://coveralls.io/github/Val-istar-Guo/koa-csp)\n\n\n\n\u003c!-- description --\u003e\nThis is a koa2 middleware used to set response header `Content-Security-Policy`.\n\n[What is CSP](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP)\n\u003c!-- description --\u003e\n\n## Usage\n\n\u003c!-- usage --\u003e\n```javascript\nimport Koa from 'koa';\nimport csp from 'koa-csp';\n\n\nconst app = new Koa();\napp.use(csp());\n\n// It is equivalent to\napp.use(csp({\n  enableWarn: true,\n  policy: { 'default-src': ['self'] },\n}));\n\n// Add you can add more policy\napp.use(csp({\n  enableWarn: true,\n  policy: {\n    'img-src': ['self', 'img.example.com'],\n    'script-src': ['script.example.com', '*.script.example.com'],\n  },\n}));\n\n// some key words will be auto add single quotes\napp.use(csp({\n  policy: {\n    'default-src': ['self', 'none', 'unsafe-inline', 'unsafe-eval', 'example.com'],\n    // you can alse add single quotes manually\n    'img-src': [\"'self'\"],\n  },\n}));\n// OUTPUT: Content-Security-Policy: default-src 'self' 'none' 'unsafe-inline' 'unsafe-eval' example.com; img-src 'self'\n\n// CamelCase Support\napp.use(csp({\n  policy: {\n    defaultSrc: ['self', 'none', 'unsafe-inline', 'unsafe-eval', 'example.com'],\n    // you can alse add single quotes manually\n    imgSrc: [\"'self'\"],\n  },\n}));\n// OUTPUT: Content-Security-Policy: default-src 'self' 'none' 'unsafe-inline' 'unsafe-eval' example.com; img-src 'self'\n```\n\u003c!-- usage --\u003e\n\n\u003c!-- addition --\u003e\u003c!-- addition --\u003e\n\n\n## Contributing \u0026 Development\n\nIf there is any doubt, it is very welcome to discuss the issue together.\nPlease read [Contributor Covenant Code of Conduct](.github/CODE_OF_CONDUCT.md) and [CONTRIBUTING](.github/CONTRIBUTING.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fval-istar-guo%2Fkoa-csp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fval-istar-guo%2Fkoa-csp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fval-istar-guo%2Fkoa-csp/lists"}