{"id":15011414,"url":"https://github.com/CodeDynasty-dev/SafeToken","last_synced_at":"2025-04-12T03:31:18.010Z","repository":{"id":212007262,"uuid":"730457353","full_name":"CodeDynasty-dev/SafeToken","owner":"CodeDynasty-dev","description":"SafeToken is an access token and refresh token authentication library for server-side Javascript applications. ","archived":false,"fork":false,"pushed_at":"2024-08-10T11:35:29.000Z","size":147,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-22T18:01:39.100Z","etag":null,"topics":["0auth2","bunjs","cryptography","javascript","jwt","jwt-authentication","nodejs","safetoken","typescript"],"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/CodeDynasty-dev.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":"2023-12-12T01:05:49.000Z","updated_at":"2024-08-10T11:35:32.000Z","dependencies_parsed_at":"2023-12-12T03:54:13.786Z","dependency_job_id":"d489f827-0708-49b4-ace0-5d3f5422b730","html_url":"https://github.com/CodeDynasty-dev/SafeToken","commit_stats":{"total_commits":67,"total_committers":1,"mean_commits":67.0,"dds":0.0,"last_synced_commit":"e7f22e2446dc110beebdd73c2bfa8c94acea0d64"},"previous_names":["fridaycandour/safetoken","codedynasty-foo/safetoken","codedynasty-dev/safetoken","uiedbook/safetoken"],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeDynasty-dev%2FSafeToken","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeDynasty-dev%2FSafeToken/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeDynasty-dev%2FSafeToken/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeDynasty-dev%2FSafeToken/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CodeDynasty-dev","download_url":"https://codeload.github.com/CodeDynasty-dev/SafeToken/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248041671,"owners_count":21038108,"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":["0auth2","bunjs","cryptography","javascript","jwt","jwt-authentication","nodejs","safetoken","typescript"],"created_at":"2024-09-24T19:41:04.105Z","updated_at":"2025-04-12T03:31:16.349Z","avatar_url":"https://github.com/CodeDynasty-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SafeToken Generator/validator\n\nSafeToken is a simplest Auth for generating secure tokens suitable for authentication purposes.\n\nWe use it to create access tokens and refresh tokens that is verifirable and store signed data.\n\nSafeToken is easy for everyone.\n\n## Features\n\n- **Secure Tokens:** Utilizes cryptographic signature.\n- **Modern api** Built using modern nodejs crypto APIs.\n- **Most fastest** Blazingly fast .create .verify methods.\n- **Fully Typed** SafeToken is written in typescript and fully typed.\n- **Super light-weight** 2KB~ size minified and fast token creation and verification logic.\n\n## How It Works\n\nThe `SafeToken` class provides methods for generating tokens. Tokens are generated using crypto to enhance security. Token expiration is managed, and new tokens can be generated based on configured time intervals.\n\n## Usage\n\n```js\n// in auth.js\nconst Auth = new SafeToken({\n  secret: \"9494d249ad9fd041f9d052e0d0b9c9e7e45bfc3f\",\n});\n```\n\n## Creating a token\n\n```js\nlet token = await Auth.create({ email: \"johndoe@gmail.com\" });\nconsole.log({\n  token,\n});\n```\n\n## Verifying a Token\n\n```js\nconsole.log({\n  decodedToken: await Auth.verify(token),\n});\n\n//? only decode doesn't verify\nconsole.log({\n  decodedToken: await Auth.decode(token),\n});\n```\n\n## Custom Token Lifetimes Example\n\nThe default timeout is 3600000 miniseconds = 1 hour.\n\nYou can customize token expiration times during class instantiation. by provide timewindows according to your application's requirements.\n\n### creating custom time windows\n\n```js\n// Example of customizing token lifetimes\nconst Auth2 = new SafeToken({\n  secret: \"9494d249ad9fd041f9d052e0d0b9c9e7e45bfc3f\",\n  // your custom time windows\n  timeWindows: {\n    // ? all provided in miliseconds\n    access: 3600000 /*1 hour*/,\n    refresh: 2592000000 /*1 month*/,\n  },\n});\n```\n\n### Usaging custom time windows\n\n```js\nlet accessToken = await Auth2.create({ email: \"fridaycandours@gmail.com\" });\nlet refreshToken = await Auth2.create({ email: \"fridaycandours@gmail.com\" });\nconsole.log({\n  accessToken,\n  refreshToken,\n});\nconsole.log({\n  decodedAccessToken: await Auth2.verify(accessToken, \"access\"),\n  decodedRefreshToken: await Auth2.verify(refreshToken, \"refresh\"),\n});\n```\n\n1. **Installation:**\n\n```bash\nnpm i safetoken\n```\n\n## Contributing\n\nThis library provides a simple and secure way to manage authetication tokens with built-in cryptographic encryption for added security.\n\nIf you find any issues or have suggestions for improvements, feel free to contribute by opening an issue or submitting a pull request.\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\nFeel free to adjust the information based on your project's specific considerations and security requirements.\n\n## Pizza Area\n\nSupport me via cryptos -\n\n- BTC: `bc1q228fnx44ha9y5lvtku70pjgaeh2jj3f867nwye`\n- ETH: `0xd067560fDed3B1f3244d460d5E3011BC42C4E5d7`\n- LTC: `ltc1quvc04rpmsurvss6ll54fvdgyh95p5kf74wppa6`\n- TRX: `THag6WuG4EoiB911ce9ELgN3p7DibtS6vP`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCodeDynasty-dev%2FSafeToken","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCodeDynasty-dev%2FSafeToken","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCodeDynasty-dev%2FSafeToken/lists"}