{"id":13781328,"url":"https://github.com/thinkjs/think-session-jwt","last_synced_at":"2025-06-18T11:33:40.769Z","repository":{"id":24086798,"uuid":"100594454","full_name":"thinkjs/think-session-jwt","owner":"thinkjs","description":"JsonWebToken  for ThinkJS 3.x.","archived":false,"fork":false,"pushed_at":"2023-03-02T12:55:33.000Z","size":1150,"stargazers_count":11,"open_issues_count":4,"forks_count":1,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-05-21T03:18:40.542Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":false,"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/thinkjs.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":"2017-08-17T11:05:05.000Z","updated_at":"2022-04-09T01:45:34.000Z","dependencies_parsed_at":"2024-08-03T18:12:30.854Z","dependency_job_id":"fb322f60-acb2-4655-a7c3-9ff6add14f60","html_url":"https://github.com/thinkjs/think-session-jwt","commit_stats":{"total_commits":44,"total_committers":3,"mean_commits":"14.666666666666666","dds":"0.38636363636363635","last_synced_commit":"24c9bf1478df14b2bfd4487d7c84d9ee8edd5f57"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thinkjs/think-session-jwt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Fthink-session-jwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Fthink-session-jwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Fthink-session-jwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Fthink-session-jwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thinkjs","download_url":"https://codeload.github.com/thinkjs/think-session-jwt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkjs%2Fthink-session-jwt/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260545142,"owners_count":23025654,"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":[],"created_at":"2024-08-03T18:01:24.939Z","updated_at":"2025-06-18T11:33:35.756Z","avatar_url":"https://github.com/thinkjs.png","language":"JavaScript","readme":"# think-session-jwt\nJsonWebToken to store session for ThinkJS 3.x base on [node-jsonwebtoken](https://github.com/auth0/node-jsonwebtoken)\n\n[![Build Status](https://travis-ci.org/thinkjs/think-session-jwt.svg?branch=master)](https://travis-ci.org/thinkjs/think-session-jwt)\n[![Coverage Status](https://coveralls.io/repos/github/thinkjs/think-session-jwt/badge.svg?branch=master)](https://coveralls.io/github/thinkjs/think-session-jwt?branch=master)\n[![npm version](https://badge.fury.io/js/think-session-jwt.svg)](https://badge.fury.io/js/think-session-jwt)\n\n## Install\n\n```bash\nnpm install think-session-jwt --save\n```\n\n## Quick Start\n\n```js\nconst JWTSession = require('think-session-jwt');\n\nexports.session = {\n  type: 'jwt',\n  common: {\n    cookie: {\n      name: 'thinkjs',\n    }\n  },\n  jwt: {\n    handle: JWTSession,\n    secret: 'secret', // secret is reqired\n    tokenType: 'cookie', // ['query', 'body', 'header', 'cookie'], 'cookie' is default\n    tokenName: 'jwt', // if tokenType not 'cookie', this will be token name, 'jwt' is default\n    sign: {\n      // sign options is not required\n    },\n    verify: {\n      // verify options is not required\n    },\n    verifyCallback: any =\u003e any, // default verify fail callback\n  }\n}\n```\n\n1. session数据从token中获取，通过配置tokenType指定token来源；\n2. 设置session数据后会返回token字符串；\n3. 配置`verifyCallback`函数，验证失败时返回该函数运行的结果；\n\n### Sign and verify options\n\n使用[node-jsonwebtoken](https://github.com/auth0/node-jsonwebtoken)的配置。\n","funding_links":[],"categories":["Adapters"],"sub_categories":["session"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkjs%2Fthink-session-jwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthinkjs%2Fthink-session-jwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkjs%2Fthink-session-jwt/lists"}