{"id":24874653,"url":"https://github.com/dirheimerb/qr-auth","last_synced_at":"2025-03-27T02:15:43.246Z","repository":{"id":189224868,"uuid":"680286521","full_name":"dirheimerb/qr-auth","owner":"dirheimerb","description":"QRCode authentication - easily generate a QR code from the provided data. It is particularly useful when you need to encode URLs or other data into QR codes.","archived":false,"fork":false,"pushed_at":"2023-08-18T20:18:09.000Z","size":39,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T07:28:58.580Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://dirheimerb.github.io/qr-auth/","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/dirheimerb.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":"SECURITY.md","support":null,"governance":null}},"created_at":"2023-08-18T20:04:09.000Z","updated_at":"2023-08-18T20:17:48.000Z","dependencies_parsed_at":"2023-08-18T22:02:36.973Z","dependency_job_id":null,"html_url":"https://github.com/dirheimerb/qr-auth","commit_stats":null,"previous_names":["dirheimerb/qr-auth"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirheimerb%2Fqr-auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirheimerb%2Fqr-auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirheimerb%2Fqr-auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dirheimerb%2Fqr-auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dirheimerb","download_url":"https://codeload.github.com/dirheimerb/qr-auth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245767360,"owners_count":20668826,"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":"2025-02-01T07:28:06.360Z","updated_at":"2025-03-27T02:15:43.223Z","avatar_url":"https://github.com/dirheimerb.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# qr-auth QRCode and JWT Utility Functions\n\nWelcome to the documentation for the QRCode and JWT utility functions! This guide will provide you with a detailed overview of the functions `generateQR`, `createToken`, and `verifyToken`. These functions can greatly enhance your development process when working with QR codes and JSON Web Tokens (JWTs). Feel free to integrate them seamlessly into your projects for a more efficient and secure experience.\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Function: generateQR](#function-generateqr)\n- [Function: createToken](#function-createtoken)\n- [Function: verifyToken](#function-verifytoken)\n\n## Introduction\n\nIn this section, you'll find a brief introduction to the utility functions, their purpose, and the benefits they bring to your development workflow.\n\n## Function: generateQR\n\n### generateQR Description\n\nThe `generateQR` function allows you to easily generate a QR code from the provided data. It is particularly useful when you need to encode URLs or other data into QR codes.\n\n### Parameters\n\n- `data` (string): The data to be encoded in the QR code.\n\n### Returns\n\n- A promise that resolves to a Data URI containing the representation of the QR code image.\n\n### Example Usage\n\n```javascript\nimport QRCode from 'qrcode';\n\nconst qrCodeData = 'https://www.example.com';\nconst qrCodeDataURL = await generateQR(qrCodeData);\nconsole.log(qrCodeDataURL);\n```\n\n## Function: createToken\n\n### Description\n\nThe `createToken` function simplifies the process of creating JWT tokens with customizable payload, secret, and expiration time.\n\n### createToken Parameters\n\n- `payload` (any): The payload to be included in the JWT.\n- `secret` (string): The secret key to sign the JWT.\n- `expiresIn` (string, optional): The expiration time for the token (default: '1h').\n\n### createToken Returns\n\n- A JWT token as a string.\n\n### createToken Example Usage\n\n```javascript\nconst userPayload = { userId: 123, role: 'admin' };\nconst secretKey = 'your-secret-key';\nconst jwtToken = createToken(userPayload, secretKey, '2h');\nconsole.log(jwtToken);\n```\n\n## Function: verifyToken\n\n### verifyToken Description\n\nThe `verifyToken` function allows you to verify and decode a JWT token, retrieving the original payload.\n\n### verifyToken Parameters\n\n- `token` (string): The JWT token to be verified.\n- `secret` (string): The secret key or public key used for verification.\n\n### verifyToken Returns\n\n- The decoded payload of the JWT token.\n\n### verifyToken Example Usage\n\n```javascript\nconst jwtTokenToVerify = 'your-jwt-token';\nconst secretKey = 'your-secret-key';\nconst decodedPayload = verifyToken(jwtTokenToVerify, secretKey);\nconsole.log(decodedPayload);\n```\n\n## Conclusion\n\nHappy coding and may your projects be efficient and secure!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirheimerb%2Fqr-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdirheimerb%2Fqr-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirheimerb%2Fqr-auth/lists"}