{"id":22559637,"url":"https://github.com/random-guys/jwt256","last_synced_at":"2025-03-28T12:12:04.438Z","repository":{"id":35138542,"uuid":"169414907","full_name":"random-guys/jwt256","owner":"random-guys","description":"Encapsulated JWT tokens (AES encrypted payload)","archived":false,"fork":false,"pushed_at":"2022-12-22T09:57:26.000Z","size":838,"stargazers_count":1,"open_issues_count":14,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-02T12:35:45.581Z","etag":null,"topics":["library"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/random-guys.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":"2019-02-06T14:01:02.000Z","updated_at":"2021-05-05T23:28:40.000Z","dependencies_parsed_at":"2023-01-15T14:45:46.905Z","dependency_job_id":null,"html_url":"https://github.com/random-guys/jwt256","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/random-guys%2Fjwt256","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/random-guys%2Fjwt256/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/random-guys%2Fjwt256/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/random-guys%2Fjwt256/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/random-guys","download_url":"https://codeload.github.com/random-guys/jwt256/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246026110,"owners_count":20711581,"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":["library"],"created_at":"2024-12-07T21:07:47.487Z","updated_at":"2025-03-28T12:12:04.401Z","avatar_url":"https://github.com/random-guys.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jwt256\n\nImplementation of JWT using AES-256\n\n![jwt](http://jwt.io/img/logo-asset.svg)\n\n## To Use\n\n`yarn add @random-guys/jwt256` or `npm install @random-guys/jwt256`\n\n---\n\nEnsure `JWT_SECRET` and `REDIS_KEY` environment variables are set, and that `REDIS_KEY` is a 32 digit string.\n\n## Usage\n\n```ts\nimport { GetUserAuth, SetUserAuth } from \"@random-guys/jwt256\";\nimport redisService from \"@app/common/services/redis\";\n\n//creates an encrpted JWT token and saves it in Redis using the user's id.\n@httpPost(\"/signup\")\nasync signup(@request() req: Request, @response() res: Response, @requestBody(), body: SignupDTO) {\n  try {\n    let user = create(body);\n    const token = await SetUserAuth(redisService, user.id);\n    this.handleSuccess(req, res, { token, user });\n  } catch (err) {\n    this.handleError(req, res, err);\n  }\n}\n\n/**\n * reads the Authorization header and validates the content with that stored in Redis\n */\n@httpPost(\"/buy\", GetUserAuth(redisService))\nasync buyBook(\n  @request() req: Request,\n  @response() res: Response,\n  @requestBody() body: BuyBookDTO\n) {\n  try {\n    const sale = await this.bookRepo.buyBook({ id: req.user } , body);\n    this.handleSuccess(req, res, user);\n  } catch (err) {\n    console.log(err);\n    this.handleError(req, res, err);\n  }\n}\n\n```\n\nThe user id is in the `req.user` field.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frandom-guys%2Fjwt256","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frandom-guys%2Fjwt256","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frandom-guys%2Fjwt256/lists"}