{"id":21478065,"url":"https://github.com/ichtrojan/laravel-otp","last_synced_at":"2025-05-16T10:08:28.103Z","repository":{"id":36218385,"uuid":"213090367","full_name":"ichtrojan/laravel-otp","owner":"ichtrojan","description":"OTP generator and validator","archived":false,"fork":false,"pushed_at":"2024-08-18T20:12:07.000Z","size":35,"stargazers_count":234,"open_issues_count":7,"forks_count":53,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-10-24T17:59:56.998Z","etag":null,"topics":["laravel","one","otp","package","password","time","token"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/ichtrojan.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-06T00:45:22.000Z","updated_at":"2024-10-07T05:34:54.000Z","dependencies_parsed_at":"2024-01-04T19:39:16.129Z","dependency_job_id":"d4dd5c52-a840-45a7-b754-86cc7c1da161","html_url":"https://github.com/ichtrojan/laravel-otp","commit_stats":{"total_commits":30,"total_committers":6,"mean_commits":5.0,"dds":"0.33333333333333337","last_synced_commit":"3fe67dfca3837c924bf968c019c7662caaab3740"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ichtrojan%2Flaravel-otp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ichtrojan%2Flaravel-otp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ichtrojan%2Flaravel-otp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ichtrojan%2Flaravel-otp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ichtrojan","download_url":"https://codeload.github.com/ichtrojan/laravel-otp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254509477,"owners_count":22082892,"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":["laravel","one","otp","package","password","time","token"],"created_at":"2024-11-23T11:16:26.139Z","updated_at":"2025-05-16T10:08:23.094Z","avatar_url":"https://github.com/ichtrojan.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel OTP ▲\n\n[![Latest Stable Version](https://poser.pugx.org/ichtrojan/laravel-otp/v/stable)](https://packagist.org/packages/ichtrojan/laravel-otp) [![Total Downloads](https://poser.pugx.org/ichtrojan/laravel-otp/downloads)](https://packagist.org/packages/ichtrojan/laravel-otp) [![License](https://poser.pugx.org/ichtrojan/laravel-otp/license)](https://packagist.org/packages/ichtrojan/laravel-otp)\n\n## Introduction 🖖\n\nThis is a simple package to generate and validate OTPs (One Time Passwords). This can be implemented mostly in Authentication.\n\n## Installation 💽\n\nInstall via composer\n\n```bash\ncomposer require ichtrojan/laravel-otp\n```\n\nRun Migrations\n\n```bash\nphp artisan migrate\n```\n\n## Usage 🧨\n\n\u003e**NOTE**\u003c/br\u003e\n\u003eResponse are returned as objects. You can access its attributes with the arrow operator (`-\u003e`)\n\n### Generate OTP\n\n```php\n\u003c?php\n\nuse Ichtrojan\\Otp\\Otp;\n\n(new Otp)-\u003egenerate(string $identifier, string $type, int $length = 4, int $validity = 10);\n```\n\n* `$identifier`: The identity that will be tied to the OTP.\n* `$type`: The type of token to be generated, supported types are `numeric` and `alpha_numeric`\n* `$length (optional | default = 4)`: The length of token to be generated.\n* `$validity (optional | default = 10)`: The validity period of the OTP in minutes.\n\n#### Sample\n\n```php\n\u003c?php\n\nuse Ichtrojan\\Otp\\Otp;\n\n(new Otp)-\u003egenerate('michael@okoh.co.uk', 'numeric', 6, 15);\n```\n\nThis will generate a six digit OTP that will be valid for 15 minutes and the success response will be:\n\n```object\n{\n  \"status\": true,\n  \"token\": \"282581\",\n  \"message\": \"OTP generated\"\n}\n```\n\n### Validate OTP\n\n```php\n\u003c?php\n\nuse Ichtrojan\\Otp\\Otp;\n\n(new Otp)-\u003evalidate(string $identifier, string $token)\n```\n\n* `$identifier`: The identity that is tied to the OTP.\n* `$token`: The token tied to the identity.\n\n#### Sample\n\n```php\n\u003c?php\n\nuse Ichtrojan\\Otp\\Otp;\n\n(new Otp)-\u003evalidate('michael@okoh.co.uk', '282581');\n```\n\n#### Responses\n\n**On Success**\n\n```object\n{\n  \"status\": true,\n  \"message\": \"OTP is valid\"\n}\n```\n\n**Does not exist**\n\n```object\n{\n  \"status\": false,\n  \"message\": \"OTP does not exist\"\n}\n```\n\n**Not Valid***\n\n```object\n{\n  \"status\": false,\n  \"message\": \"OTP is not valid\"\n}\n```\n\n**Expired**\n\n```object\n{\n  \"status\": false,\n  \"message\": \"OTP Expired\"\n}\n```\n\n### Check The validity of an OTP\n\nTo verify the validity of an OTP without marking it as used, you can use the `isValid` method:\n\n```php\n\u003c?php\nuse Ichtrojan\\Otp\\Otp;\n\n(new Otp)-\u003eisValid(string $identifier, string $token);\n```\n\nThis will return a boolean value of the validity of the OTP.\n\n### Delete expired tokens\nYou can delete expired tokens by running the following artisan command:\n```bash\nphp artisan otp:clean\n```\nYou can also add this artisan command to `app/Console/Kernel.php` to automatically clean on scheduled \n```php\n\u003c?php\n\nprotected function schedule(Schedule $schedule)\n{\n    $schedule-\u003ecommand('otp:clean')-\u003edaily();\n}\n```\n\n## Contribution\n\nIf you find an issue with this package or you have any suggestion please help out. I am not perfect.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fichtrojan%2Flaravel-otp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fichtrojan%2Flaravel-otp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fichtrojan%2Flaravel-otp/lists"}