{"id":13836175,"url":"https://github.com/jsumners/fastify-server-session","last_synced_at":"2025-09-12T23:31:06.348Z","repository":{"id":47139711,"uuid":"110600039","full_name":"jsumners/fastify-server-session","owner":"jsumners","description":null,"archived":false,"fork":false,"pushed_at":"2021-09-12T10:01:15.000Z","size":137,"stargazers_count":16,"open_issues_count":0,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-07-22T14:59:13.001Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsumners.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-13T20:45:51.000Z","updated_at":"2023-08-28T01:33:11.000Z","dependencies_parsed_at":"2022-08-31T14:11:29.382Z","dependency_job_id":null,"html_url":"https://github.com/jsumners/fastify-server-session","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/jsumners/fastify-server-session","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsumners%2Ffastify-server-session","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsumners%2Ffastify-server-session/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsumners%2Ffastify-server-session/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsumners%2Ffastify-server-session/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsumners","download_url":"https://codeload.github.com/jsumners/fastify-server-session/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsumners%2Ffastify-server-session/sbom","scorecard":{"id":539595,"data":{"date":"2025-08-11","repo":{"name":"github.com/jsumners/fastify-server-session","commit":"f02ac8dd30dd76705b01293a749f22e73e4649b4"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.9,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":4,"reason":"Found 5/11 approved changesets -- score normalized to 4","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/jsumners/fastify-server-session/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/jsumners/fastify-server-session/ci.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:25","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 27 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T07:53:04.719Z","repository_id":47139711,"created_at":"2025-08-20T07:53:04.719Z","updated_at":"2025-08-20T07:53:04.719Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274893250,"owners_count":25369278,"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-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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-08-04T15:00:37.448Z","updated_at":"2025-09-12T23:31:06.072Z","avatar_url":"https://github.com/jsumners.png","language":"JavaScript","readme":"# fastify-server-session\n\nThis is a plugin for [Fastify](https://fastify.io/) that facilitates keep state\nfor clients between requests via server-side storage.\n\n**Requirements:**\n\n+ [fastify-cookie](https://www.npmjs.com/package/fastify-cookie): used to set\na cookie for tracking sessions.\n+ [fastify-caching](https://www.npmjs.com/package/fastify-caching): used to\nstore the session data via the `fastify.cache` decorator.\n\n\n**Installation:**\n\n```\nnpm install fastify-server-session fastify-cookie fastify-caching\n```\n\n## Example\n\n### Server Side Storage\n\nUsing this implementation the sessions will be stored in memory on the Fastify instance\nmaking the server stateful. This is not recommended for production. It will not share\nstate among multiple instances of the same application.\n\n```js\nconst fastify = require('fastify')()\nfastify\n  .register(require('fastify-cookie'))\n  .register(require('fastify-caching'))\n  .register(require('fastify-server-session'), {\n    secretKey: 'some-secret-password-at-least-32-characters-long',\n    sessionMaxAge: 900000, // 15 minutes in milliseconds\n    cookie: {\n      domain: '.example.com',\n      path: '/'\n    }\n  })\n\nfastify.get('/one', (req, reply) =\u003e {\n  req.session.foo = 'foo'\n  reply.send()\n})\n\nfastify.get('/two', (req, reply) =\u003e {\n  reply.send({foo: req.session.foo})\n})\n```\n\n### Remote Cache Store\n\n`fastify-caching` offers the connectivity to a remote store as shown below with `ioredis` and `abstract-cache`.\nSee `fastify-caching` [documentation](https://github.com/fastify/fastify-caching) for other\nstorage capabilities.\n\n```js\n// This example requires the following packages to be installed\n// - ioredis\n// - abstract-cache\n\nconst IORedis = require('ioredis')\nconst redis = new IORedis({host: '127.0.0.1'})\nconst abcache = require('abstract-cache')({\n  useAwait: true,\n  driver: {\n    name: 'abstract-cache-redis',\n    options: {client: redis}\n  }\n})\nconst fastify = require('fastify')()\nfastify\n  .register(require('fastify-cookie'))\n  .register(require('fastify-caching'), {cache: abcache})\n  .register(require('fastify-server-session'), {\n    secretKey: 'some-secret-password-at-least-32-characters-long',\n    sessionMaxAge: 900000, // 15 minutes in milliseconds\n    cookie: {\n      domain: '.example.com',\n      path: '/'\n    }\n  })\n\nfastify.get('/one', (req, reply) =\u003e {\n  req.session.foo = 'foo'\n  reply.send()\n})\n\nfastify.get('/two', (req, reply) =\u003e {\n  reply.send({foo: req.session.foo})\n})\n```\n\n**Note:** In the previous example the `sessionMaxAge` value will set the Redis TTL of the session key.\n\n## Options\n\nThe plugin accepts an options object with the following properties:\n\n+ `secretKey` (Default: `undefined`): this is a **required** property that must\nbe a string with a minimum of 32 characters.\n+ `sessionCookieName` (Default: `sessionid`): a string to name the cookie sent\nto the client to track the session.\n+ `sessionMaxAge` (Default: `1800000`): a duration in milliseconds for which\nthe sessions will be valid.\n+ `cookie`: an options as described in the [cookie module's documentation][cookiedoc].\nThe default value is:\n    * `domain`: `undefined`\n    * `expires`: same as `sessionMaxAge`\n    * `httpOnly`: `true`\n    * `path`: `undefined`\n    * `sameSite`: `true`\n\n[cookiedoc]: https://www.npmjs.com/package/cookie#options-1\n\n## TypeScript\n\nTo use type checking on session object you can use the declaration:\n\n```typescript\ndeclare module 'fastify' {\n  interface FastifyRequest {\n    session: {\n      foo: string;\n      bar: number;\n    };\n  }\n}\n```\n\n## License\n\n[MIT License](http://jsumners.mit-license.org/)\n","funding_links":[],"categories":["\u003ch2 align=\"center\"\u003eAwesome Fastify\u003c/h2\u003e"],"sub_categories":["\u003ch2 align=\"center\"\u003eEcosystem\u003c/h2\u003e"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsumners%2Ffastify-server-session","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsumners%2Ffastify-server-session","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsumners%2Ffastify-server-session/lists"}