{"id":40597337,"url":"https://github.com/sauravhathi/otp-service","last_synced_at":"2026-01-21T04:05:21.949Z","repository":{"id":192885435,"uuid":"687665449","full_name":"sauravhathi/otp-service","owner":"sauravhathi","description":"The OTP (One-Time Password) Free Service is a Node.js-based service that allows you to generate and verify one-time passwords (OTP) via email. This service is useful for adding an extra layer of security to your applications by enabling two-factor authentication (2FA) or passwordless login.","archived":false,"fork":false,"pushed_at":"2025-03-08T16:51:15.000Z","size":82,"stargazers_count":15,"open_issues_count":0,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-08T17:29:51.137Z","etag":null,"topics":["collaborate","cronjob","free-otp-service","github","lovely-professional-university","mailserver","mongodb","nodejs","one-time-code","one-time-password","opensource","otp-applications","otp-generator","otp-library","otp-mail","otp-services","otp-verification","sauravhathi","sendmail","spam-detection"],"latest_commit_sha":null,"homepage":"https://otp-service-beta.vercel.app","language":"JavaScript","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/sauravhathi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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-09-05T18:43:23.000Z","updated_at":"2025-02-14T15:16:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"e1e5f010-27ad-45c2-9ac6-77612741f2a6","html_url":"https://github.com/sauravhathi/otp-service","commit_stats":null,"previous_names":["sauravhathi/otp-service"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/sauravhathi/otp-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sauravhathi%2Fotp-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sauravhathi%2Fotp-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sauravhathi%2Fotp-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sauravhathi%2Fotp-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sauravhathi","download_url":"https://codeload.github.com/sauravhathi/otp-service/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sauravhathi%2Fotp-service/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28625926,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T02:47:06.670Z","status":"ssl_error","status_checked_at":"2026-01-21T02:45:44.886Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["collaborate","cronjob","free-otp-service","github","lovely-professional-university","mailserver","mongodb","nodejs","one-time-code","one-time-password","opensource","otp-applications","otp-generator","otp-library","otp-mail","otp-services","otp-verification","sauravhathi","sendmail","spam-detection"],"created_at":"2026-01-21T04:05:16.957Z","updated_at":"2026-01-21T04:05:21.943Z","avatar_url":"https://github.com/sauravhathi.png","language":"JavaScript","funding_links":["https://www.buymeacoffee.com/sauravhathi"],"categories":[],"sub_categories":[],"readme":"# OTP Service\n\n![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript\u0026logoColor=white) ![Node.js](https://img.shields.io/badge/Node.js-339933?logo=node.js\u0026logoColor=white) ![MongoDB](https://img.shields.io/badge/MongoDB-47A248?logo=mongodb\u0026logoColor=white) ![Vercel](https://img.shields.io/badge/Vercel-000000?logo=vercel\u0026logoColor=white) ![MIT License](https://img.shields.io/badge/License-MIT-FF5722)\n\nThe OTP (One-Time Password) Free Service is a Node.js-based service that allows you to generate and verify one-time passwords (OTP) via email. This service is useful for adding an extra layer of security to your applications by enabling two-factor authentication (2FA) or passwordless login.\n\n## Demo\n\n- **API:** [otp-service-beta.vercel.app](https://otp-service-beta.vercel.app/)\n- **App:** [otp-service-app.vercel.app](https://otp-service-app.vercel.app/)\n\n## Table of Contents\n\n- [Features](#features)\n- [Getting Started](#getting-started)\n  - [Prerequisites](#prerequisites)\n  - [Installation](#installation)\n- [Usage](#usage)\n  - [Generating an OTP](#generating-an-otp)\n  - [Verifying an OTP](#verifying-an-otp)\n- [Configuration](#configuration)\n  - [Environment Variables](#environment-variables)\n- [Spam Detection](#spam-detection)\n- [Donation](#donation)\n- [License](#license)\n\n## Features\n\n| Feature                                      | Description                                                                                                                                                           |\n| -------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| Generate numeric, alphanumeric, or alphabet based OTPs | Generate one-time passwords with various character types: numeric, alphanumeric, or alphabet based.  |\n| Send OTPs via email                          | Send OTPs to users via email for authentication or verification.                                                                                                      |\n| Verify OTPs for user authentication           | Verify OTPs provided by users for secure authentication.                                                          |\n| Spam detection                               | Detect spam requests and block them from being processed.\n| Customizable OTP validity period and size     | Adjust the validity period and size (length) of OTPs to match your security requirements.                                                                          |\n| Rate limiting for OTP generation              | Implement rate limiting to prevent abuse and ensure the service is used responsibly.                                                                              |\n| Multiple email service providers supported   | Choose from multiple email service providers (e.g., Gmail, Outlook) to send OTP emails.                                                                            |\n| Flexible configuration via environment variables | Customize the service's behavior by configuring environment variables.                                                                                                  |\n| Easy-to-use API with JSON input/output        | Interact with the service through a user-friendly JSON API for OTP generation and verification.                                                                  |\n\n## Getting Started\n\n### Prerequisites\n\nBefore you begin, ensure you have met the following requirements:\n\n| Prerequisite          | Description                                                      |\n| --------------------- | ---------------------------------------------------------------- |\n| Node.js and npm       | Install Node.js and npm on your development machine.            |\n| MongoDB database     | Set up a MongoDB database (local or cloud-hosted, e.g., MongoDB Atlas) for storing OTP data. |\n\n### Installation\n\n1. Clone the repository:\n\n   ```shell\n   git clone https://github.com/sauravhathi/otp-service.git\n   ```\n\n2. Navigate to the project directory:\n\n   ```shell\n   cd otp-service\n   ```\n\n3. Install the dependencies:\n\n   ```shell\n   npm install\n   ```\n\n4. Configure your environment variables by creating a `.env` file in the project root directory. You can use the provided `.env.example` as a template.\n\n5. Start the service:\n\n   ```shell\n   npm start\n   ```\n\nThe service should now be running on the specified port (default is 3000).\n\n## Usage\n\n### Generating an OTP\n\nTo generate an OTP for a user, make a POST request to the `/api/otp/generate` endpoint with the user's email address in the request body. You can also specify the OTP type, organization name, and email subject.\n\nExample request:\n\n```json\nPOST /api/otp/generate\n{\n  \"email\": \"user@example.com\",\n  \"type\": \"numeric\",\n  \"organization\": \"MyApp\",\n  \"subject\": \"OTP Verification\"\n}\n```\n\nThe service will send an email containing the OTP to the user's email address.\n\n### Verifying an OTP\n\nTo verify an OTP for user authentication, make a POST request to the `/api/otp/verify` endpoint with the user's email address and the OTP in the request body.\n\nExample request:\n\n```json\nPOST /api/otp/verify\n{\n  \"email\": \"user@example.com\",\n  \"otp\": \"123456\"\n}\n```\n\nThe service will respond with a success message if the OTP is valid.\n\n## Configuration\n\nYou can customize the OTP service by modifying the environment variables in the `.env` file. Here are some key configuration options:\n\n### Environment Variables\n\n| Variable                     | Description                                                                                   |\n| ---------------------------- | --------------------------------------------------------------------------------------------- |\n| `PORT`                       | The port on which the service listens.                                                        |\n| `MONGODB_URI`                | The MongoDB connection string.                                                                |\n| `OTP_VALIDITY_PERIOD_MINUTES` | The validity period of OTPs in minutes.                                                      |\n| `OTP_SIZE`                   | The size (length) of OTPs.                                                                    |\n| `ALLOWED_DOMAINS`            | Comma-separated list of allowed email domains.                                                |\n| `GMAIL_USER`                 | Gmail username (used for sending emails).                                                     |\n| `GMAIL_PASS`                 | Gmail password (used for sending emails).                                                     |\n| `BLOCK_KEYWORDS_RULES`       | Comma-separated list of blocked keywords.                                                     |\n\n## Spam Detection\n\nThe service uses a spam detection mechanism to prevent abuse. It checks the request body for spam keywords and blocks the request if any are found. You can configure the spam keywords by setting the `SPAM_WORDS` environment variable.\n\n## Donation\n\nIf you find this project useful and want to support its development, consider buying us a coffee! Your support is greatly appreciated.\n\n\u003ca href=\"https://www.buymeacoffee.com/sauravhathi\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/arial-yellow.png\" alt=\"Buy Me A Coffee\" style=\"height: 60px !important;width: 217px !important;\" \u003e\u003c/a\u003e\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](https://github.com/sauravhathi/otp-service/blob/master/LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsauravhathi%2Fotp-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsauravhathi%2Fotp-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsauravhathi%2Fotp-service/lists"}