{"_id":"@ajiboladavid/jstp","_rev":"1-627ed7356831d73d4d65f2daaf5ac95a","name":"@ajiboladavid/jstp","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@ajiboladavid/jstp","version":"1.0.0","keywords":["otp","one-time password","redis","javascript","typescript","node.js"],"author":{"name":"David Ajibola"},"license":"MIT","_id":"@ajiboladavid/jstp@1.0.0","maintainers":[{"name":"ajiboladavid","email":"ajiboladavid0963@gmail.com"}],"homepage":"https://github.com/Davidthecode/jstp#readme","bugs":{"url":"https://github.com/Davidthecode/jstp/issues"},"dist":{"shasum":"b50e4a0ea6cf07cba697eed743c76bcc608dcca5","tarball":"https://registry.npmjs.org/@ajiboladavid/jstp/-/jstp-1.0.0.tgz","fileCount":9,"integrity":"sha512-/PY6aMWFCydzrfCFcgIvXQj/PIg4YZOfLGQIASKA7tdBMBGm4xGT+Fn/cnov+3xGLQNcrowgyHcBbAfT7iIK6g==","signatures":[{"sig":"MEUCIGN4ZaN+SjWUG5sUseTJcwvYNZPCFP9KthiPyAUbWxvzAiEAnlFadrBuolXp+kHQJ3ebyPaOHg36A2+ZLAS+VX8XWQ0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":26874},"main":"dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"c0cbdbe203e22e1f1e6c41db556a480b3df0402a","scripts":{"test":"jest","build":"tsup","watch":"tsup --watch","prepare":"husky install","test:unit":"jest \"src/tests/unit/.*\\.test\\.ts$\"","test:watch":"jest --watch","test:coverage":"jest --coverage","test:integration":"jest \"src/tests/integration/.*\\.test\\.ts$\""},"_npmUser":{"name":"ajiboladavid","email":"ajiboladavid0963@gmail.com"},"repository":{"url":"git+https://github.com/Davidthecode/jstp.git","type":"git"},"_npmVersion":"10.9.0","description":"A JavaScript OTP package for generating and verifying one-time passwords (OTP) using Redis for storage.","directories":{},"_nodeVersion":"20.12.0","dependencies":{"redis":"^4.7.0","dotenv":"^16.4.5"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","tsup":"^8.3.5","husky":"^9.1.6","eslint":"^9.13.0","globals":"^15.11.0","ts-jest":"^29.2.5","ts-node":"^10.9.2","@eslint/js":"^9.13.0","typescript":"^5.6.3","@types/jest":"^29.5.14","@types/node":"^22.7.9","@types/redis":"^4.0.10","typescript-eslint":"^8.11.0"},"_npmOperationalInternal":{"tmp":"tmp/jstp_1.0.0_1730626821832_0.8993146206793441","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@ajiboladavid/jstp","version":"1.0.1","description":"A JavaScript OTP package for generating and verifying one-time passwords (OTP) using Redis for storage.","keywords":["otp","one-time password","redis","javascript","typescript","node.js"],"repository":{"type":"git","url":"git+https://github.com/Davidthecode/jstp.git"},"license":"MIT","author":{"name":"David Ajibola"},"main":"dist/index.js","types":"./dist/index.d.ts","type":"module","exports":{".":{"import":"./dist/index.js","require":"./dist/index.cjs","types":"./dist/index.d.ts"}},"scripts":{"build":"tsup","watch":"tsup --watch","test":"jest","test:watch":"jest --watch","test:coverage":"jest --coverage","test:unit":"jest \"src/tests/unit/.*\\.test\\.ts$\"","test:integration":"jest \"src/tests/integration/.*\\.test\\.ts$\"","prepare":"husky install"},"devDependencies":{"@eslint/js":"^9.13.0","@types/jest":"^29.5.14","@types/node":"^22.7.9","@types/redis":"^4.0.10","eslint":"^9.13.0","globals":"^15.11.0","husky":"^9.1.6","jest":"^29.7.0","ts-jest":"^29.2.5","ts-node":"^10.9.2","tsup":"^8.3.5","typescript":"^5.6.3","typescript-eslint":"^8.11.0"},"dependencies":{"dotenv":"^16.4.5","redis":"^4.7.0"},"_id":"@ajiboladavid/jstp@1.0.1","gitHead":"a032aab45510809cfb63ef0a56116d970cb3f1f3","bugs":{"url":"https://github.com/Davidthecode/jstp/issues"},"homepage":"https://github.com/Davidthecode/jstp#readme","_nodeVersion":"20.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-j3QHpnjT8eYxuk3sO2cO+x6J6/VnZqEwXKoj7MFvIfTkaFdfWLyb6NVbSlJ1cWaS8YNtBoP4x9Rv+5F/J6L/2Q==","shasum":"1a2890c8bea4f5563496e14a3f906390861ce0ab","tarball":"https://registry.npmjs.org/@ajiboladavid/jstp/-/jstp-1.0.1.tgz","fileCount":9,"unpackedSize":26888,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH0mMPPiAtV9aufOkfLjYtfe4S8l8nrkOlSYYa3hkKQIAiEAtwZddgYZf5Xo0RehmneV6fdy48UunvkLO0hEQ6ruFDQ="}]},"_npmUser":{"name":"ajiboladavid","email":"ajiboladavid0963@gmail.com"},"directories":{},"maintainers":[{"name":"ajiboladavid","email":"ajiboladavid0963@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jstp_1.0.1_1730627362956_0.7155544455852079"},"_hasShrinkwrap":false}},"time":{"created":"2024-11-03T09:40:21.723Z","modified":"2024-11-03T09:49:23.328Z","1.0.0":"2024-11-03T09:40:21.996Z","1.0.1":"2024-11-03T09:49:23.154Z"},"bugs":{"url":"https://github.com/Davidthecode/jstp/issues"},"author":{"name":"David Ajibola"},"license":"MIT","homepage":"https://github.com/Davidthecode/jstp#readme","keywords":["otp","one-time password","redis","javascript","typescript","node.js"],"repository":{"type":"git","url":"git+https://github.com/Davidthecode/jstp.git"},"description":"A JavaScript OTP package for generating and verifying one-time passwords (OTP) using Redis for storage.","maintainers":[{"name":"ajiboladavid","email":"ajiboladavid0963@gmail.com"}],"readme":"# JSTP\n\n**JSTP** is a simple TypeScript package for generating and managing secure one-time passwords (OTPs) with Redis integration. JSTP provides flexible token generation with customizable formats and a Redis-based storage.\n\n---\n\n## Features\n\n- **Secure token generation** in specified formats and lengths\n- **Redis-backed storage** with automatic expiration\n- **Customizable token expiration**\n- **Automatic token deletion** after verification\n- **TypeScript** support\n\n---\n\n## Installation\n\n```\nnpm install @ajiboladavid/jstp\n```\n\n## Prerequisites\n\n- Node.js 14.x or later\n- Redis instance\n\n## Configuration\nFirst, configure your Redis client before using the package\n\n```ts\nimport { createClient } from \"redis\";\n\nexport const getRedisClient = async() => {\n  const client = createClient({\n    url: process.env.REDIS_URL\n  });\n  await client.connect();\n  return client; \n}\n```\n## Generating Tokens\nCreate a JSTP instance and generate tokens:\n\n```ts\nimport Jstp from \"jstp\";\nimport { getRedisClient } from \"./redisConfig\";\n\nconst client = await getRedisClient();\nconst otpService = new Jstp(client);\n\nconst handleOtpGeneration = async () => {\n  try {\n    const token = await otpService.generateOTP({\n      length: 7,\n      format: \"alphanumeric\",\n      expiresIn: 3000,\n      identifier:\"user1234\"\n    });\n    console.log(\"token =>\", token);\n  } catch (error) {\n    console.error(\"error =>\", error);\n  }\n};\n```\n\n## Verifying Tokens\nVerify generated tokens:\n\n```ts\n try {\n  const isValid = await otpService.verifyOTP({\n    identifier: \"user1234\",\n    token: \"ABC123\"    // Token to verify\n  });\n\n  if (isValid) {\n    console.log(\"Token is valid\");\n  } else {\n    console.log(\"Token is invalid or expired\");\n  }\n} catch (error) {\n  console.error(\"error =>\", error);\n}\n```\n\n## Configuration Options\n\n| Syntax      | Type                                             | Description                      | Required\n| ----------- | -----------                                      | -----------                      | -----------\n| length      |  Number                                          | Token length (4-12 characters)   | Yes\n| format      | \"numeric\", \"alphabetic\", \"alphanumeric\"          | Token character format           | Yes\n| expiresIn   |  number                                          | Token expiration time in seconds | Yes\n| identifier  |  string                                          | Unique identifier for the token  | Yes\n\n---\n\n## Token Formats\n- numeric: Numbers only (0-9)\n- alphabetic: Capital letters only (A-Z)\n- alphanumeric: Numbers and capital letters\n\n## License\nThis package is licensed under the MIT License\n","readmeFilename":"README.md"}