{"id":20863532,"url":"https://github.com/grabss/grabpass","last_synced_at":"2026-02-22T03:03:00.108Z","repository":{"id":259335056,"uuid":"876612007","full_name":"grabss/grabpass","owner":"grabss","description":"A simple and minimal token-based stateless authentication for Node.js.","archived":false,"fork":false,"pushed_at":"2025-07-04T00:37:40.000Z","size":39,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-11T22:00:46.629Z","etag":null,"topics":["auth","minimal","nodejs","typescript"],"latest_commit_sha":null,"homepage":"https://grabss.co.jp","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/grabss.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,"zenodo":null}},"created_at":"2024-10-22T09:09:37.000Z","updated_at":"2025-07-04T00:37:43.000Z","dependencies_parsed_at":"2024-10-24T14:35:32.846Z","dependency_job_id":"4240834b-a4a9-43c7-affe-37133ba626b6","html_url":"https://github.com/grabss/grabpass","commit_stats":null,"previous_names":["grabss/grabpass"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/grabss/grabpass","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grabss%2Fgrabpass","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grabss%2Fgrabpass/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grabss%2Fgrabpass/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grabss%2Fgrabpass/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grabss","download_url":"https://codeload.github.com/grabss/grabpass/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grabss%2Fgrabpass/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29704401,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T23:35:04.139Z","status":"online","status_checked_at":"2026-02-22T02:00:08.193Z","response_time":110,"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":["auth","minimal","nodejs","typescript"],"created_at":"2024-11-18T05:29:34.940Z","updated_at":"2026-02-22T03:03:00.102Z","avatar_url":"https://github.com/grabss.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# grabpass\n\n*A simple and minimal token-based stateless authentication for Node.js.*\n\n[![Test Status](https://github.com/grabss/grabpass/actions/workflows/test.yml/badge.svg)](https://github.com/grabss/grabpass/actions/workflows/test.yml)\n[![NPM Version](https://img.shields.io/npm/v/grabpass.svg)](https://www.npmjs.com/package/grabpass)\n[![License](https://img.shields.io/npm/l/grabpass.svg)](https://github.com/grabss/grabpass/blob/main/LICENSE)\n\n\u003c/div\u003e\n\n## Installation\n\n```bash\nnpm install grabpass\n```\n\n## How to use\n***grabpass*** provides a simple way to generate and verify access and refresh tokens with customizable configuration options.\n\n```ts\nimport { Grabpass } from 'grabpass'\n\n// Create a new instance of Grabpass\nconst grabpass = new Grabpass({\n  // config: PartialGrabpassConfig\n  config: {\n    algorithm: 'HS256',\n    accessTokenExpiresIn: '30m',\n    refreshTokenExpiresIn: '30d',\n    secret: 'your-secret-4a1425c50f8b84148a39'\n  }\n})\n\n// Create auth tokens\nconst tokens = grabpass.createAuthTokens({\n  accessTokenData: {\n    payload: { userId: 123 }\n  },\n  refreshTokenData: {\n    payload: { userId: 123 }\n  }\n})\n\n// Verify access token\ntry {\n  const payload = grabpass.verifyAccessToken(tokens.accessToken)\n  console.log('Verified Payload:', payload)\n} catch (e) {\n  console.error('Invalid Token:', e)\n}\n\n// Verify refresh token\ntry {\n  const payload = grabpass.verifyRefreshToken(tokens.refreshToken)\n  console.log('Verified Payload:', payload)\n} catch (e) {\n  console.error('Invalid Token:', e)\n}\n```\n\n## Configuration\nConfiguration can be defined globally via the constructor's `config` option and overridden for specific operations when using methods like `createAuthTokens`, `verifyAccessToken`, and `verifyRefreshToken`.\n\n```ts\ntype GrabpassConfig = {\n  algorithm: jwt.Algorithm\n  accessTokenExpiresIn: ms.StringValue\n  refreshTokenExpiresIn: ms.StringValue\n  secret?: jwt.Secret\n  publicKey?: jwt.PublicKey\n  privateKey?: jwt.PrivateKey\n}\n```\n\n|Property|Type|Default|Description|\n|---|---|---|---|\n|**algorithm**|`jwt.Algorithm`|`HS256`|The algorithm used for signing the JWT.\u003cbr\u003eSee [Algorithms Supported](https://github.com/auth0/node-jsonwebtoken#algorithms-supported) for more details.|\n|**accessTokenExpiresIn**|`ms.StringValue`|`30m`| Expiration time for access token.|\n|**refreshTokenExpiresIn**|`ms.StringValue`|`30d`| Expiration time for refresh token.|\n|**secret**|`jwt.Secret`|-|The secret key used for signing tokens. Required if algorithm is symmetric (e.g., HS256).|\n|**publicKey**|`jwt.PublicKey`|-|The public key used for verifying tokens. Required if algorithm is asymmetric (e.g., RS256).|\n|**privateKey**|`jwt.PublicKey`|-|The private key used for signing tokens. Required if algorithm is asymmetric (e.g., RS256).|\n\n### Overriding configuration per operation\nCustomize settings for individual operations by passing a config object to the method:\n```ts\nimport { Grabpass } from 'grabpass'\n\nconst tokens = grabpass.createAuthTokens({\n  accessTokenData: {\n    payload: { userId: 123 },\n    config: {\n      accessTokenExpiresIn: '15m', // Override the expiration time\n      secret: 'custom-secret-key-1fa03e3bd39f1f' // Use a different secret\n    }\n  },\n  refreshTokenData: {\n    payload: { userId: 123 },\n    config: {\n      refreshTokenExpiresIn: '15m', // Override the expiration time\n      secret: 'custom-secret-key-bf21899e3f6b70' // Use a different secret\n    }\n  }\n})\n\ntry {\n  const payload = grabpass.verifyAccessToken(tokens.accessToken, {\n    secret: 'custom-secret-key-1fa03e3bd39f1f' // Use a different secret\n  })\n  console.log('Verified Payload:', payload)\n} catch (e) {\n  console.error('Invalid Token:', e)\n}\n\ntry {\n  const payload = grabpass.verifyRefreshToken(tokens.refreshToken, {\n    secret: 'custom-secret-key-bf21899e3f6b70' // Use a different secret\n  })\n  console.log('Verified Payload:', payload)\n} catch (e) {\n  console.error('Invalid Token:', e)\n}\n```\n\n## License\n\nMIT License - see [LICENSE](./LICENSE) file for details.\n\n## Contributing\n\nContributions are welcome! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrabss%2Fgrabpass","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrabss%2Fgrabpass","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrabss%2Fgrabpass/lists"}