{"id":22165282,"url":"https://github.com/doochik/express-csrf-double-submit-cookie","last_synced_at":"2025-07-26T11:31:59.701Z","repository":{"id":40797380,"uuid":"141708607","full_name":"doochik/express-csrf-double-submit-cookie","owner":"doochik","description":"Express CSRF token middleware with \"Double cookie submit\"","archived":false,"fork":false,"pushed_at":"2025-05-18T15:41:18.000Z","size":456,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-22T08:51:04.921Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/doochik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2018-07-20T12:19:26.000Z","updated_at":"2025-05-18T15:41:19.000Z","dependencies_parsed_at":"2023-02-13T23:45:24.062Z","dependency_job_id":"9e71c039-c9fb-4448-9be2-9b5622fd8d52","html_url":"https://github.com/doochik/express-csrf-double-submit-cookie","commit_stats":{"total_commits":39,"total_committers":3,"mean_commits":13.0,"dds":0.5384615384615384,"last_synced_commit":"5d5954e5dd3528e8122ea0b8607e77610ca9c2b8"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/doochik/express-csrf-double-submit-cookie","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doochik%2Fexpress-csrf-double-submit-cookie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doochik%2Fexpress-csrf-double-submit-cookie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doochik%2Fexpress-csrf-double-submit-cookie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doochik%2Fexpress-csrf-double-submit-cookie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/doochik","download_url":"https://codeload.github.com/doochik/express-csrf-double-submit-cookie/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/doochik%2Fexpress-csrf-double-submit-cookie/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266698840,"owners_count":23970493,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-12-02T05:14:21.277Z","updated_at":"2025-07-26T11:31:59.694Z","avatar_url":"https://github.com/doochik.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# express-csrf-double-submit-cookie\n\nExpress CSRF token middleware with [\"Naive Double-Submit Cookie Pattern\"](https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html#naive-double-submit-cookie-pattern-discouraged)\n\nRequires [cookie-parser](https://www.npmjs.com/package/cookie-parser) to be initialized first.\n\n## Installation\n\n```sh\n$ npm install express-csrf-double-submit-cookie\n```\n\n## Usage\n\n```js\nimport cookieParser from 'cookie-parser';\nimport csrfDSC from 'express-csrf-double-submit-cookie';\nimport express from 'express';\n\n// create middleware\nconst csrfProtection = csrfDSC();\n\nconst app = express();\napp.use(cookieParser());\n\n// middleware to set cookie token \napp.use(csrfProtection)\n\n// protect /api\napp.post('/api', csrfProtection.validate, function (req, res) {\n  res.status(200).end();\n})\n\n```\n\n## API\n\n```js\nimport csrfDSC from 'express-csrf-double-submit-cookie';\n\nconst  csrfProtection = csrfDSC([options]);\n```\n\n### Options\n\n* `length` - token length in bytes. Default to 18.\n* `value` - function to get token from request. Default to\n```js\nfunction defaultValue (req) {\n    return (req.body \u0026\u0026 req.body._csrf_token) ||\n        (req.query \u0026\u0026 req.query._csrf_token) ||\n        (req.headers['x-csrf-token']);\n}\n```\n* `cookie` - Cookie options, see express [res.cookie() documentation](http://expressjs.com/en/4x/api.html#res.cookie). Defaults to `{ name: '_csrf_token', path: '/', httpOnly: false }`\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoochik%2Fexpress-csrf-double-submit-cookie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoochik%2Fexpress-csrf-double-submit-cookie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoochik%2Fexpress-csrf-double-submit-cookie/lists"}