├── phpstan.neon.dist ├── src ├── InvalidConfiguration.php ├── App.php ├── Client.php ├── Token.php ├── Response.php └── User.php ├── LICENSE ├── CONTRIBUTING.md ├── composer.json ├── CODE_OF_CONDUCT.md ├── CHANGELOG.md └── README.md /phpstan.neon.dist: -------------------------------------------------------------------------------- 1 | includes: 2 | - ./vendor/nunomaduro/larastan/extension.neon 3 | parameters: 4 | level: 5 5 | paths: 6 | - src 7 | -------------------------------------------------------------------------------- /src/InvalidConfiguration.php: -------------------------------------------------------------------------------- 1 | api.'app/stats'; 20 | $params = $this->params + ['query' => ['user_ip' => $ip]]; 21 | 22 | // Return Authy application stats 23 | return new Response($this->http->get($url, $params)); 24 | } 25 | 26 | /** 27 | * Get application details. 28 | * 29 | * @param string|null $ip 30 | * 31 | * @return \Rinvex\Authy\Response 32 | */ 33 | public function details($ip = null): Response 34 | { 35 | // Prepare required variables 36 | $url = $this->api.'app/details'; 37 | $params = $this->params + ['query' => ['user_ip' => $ip]]; 38 | 39 | // Return Authy application stats 40 | return new Response($this->http->get($url, $params)); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016-2021, Rinvex LLC, 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Client.php: -------------------------------------------------------------------------------- 1 | http = $client; 45 | $format = $format === 'xml' ? 'xml' : 'json'; 46 | $this->params = ['http_errors' => false, 'headers' => ['X-Authy-API-Key' => $key]]; 47 | $this->api = "https://api.authy.com/protected/{$format}/"; 48 | 49 | // Check configuration 50 | if (! $key) { 51 | throw InvalidConfiguration::missingCredentials(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/Token.php: -------------------------------------------------------------------------------- 1 | api.$method."/{$authyId}"; 24 | $params = $this->params + ['query' => ['force' => $force ? 'true' : 'false', 'action' => $action, 'actionMessage' => $actionMessage]]; 25 | 26 | // Send Authy token, and return response 27 | return new Response($this->http->get($url, $params)); 28 | } 29 | 30 | /** 31 | * Verify the given token for the given Authy user. 32 | * 33 | * @param int $token 34 | * @param int $authyId 35 | * @param bool $force 36 | * @param string|null $action 37 | * 38 | * @return \Rinvex\Authy\Response 39 | */ 40 | public function verify($token, $authyId, $force = false, $action = null): Response 41 | { 42 | // Prepare required variables 43 | $url = $this->api."verify/{$token}/{$authyId}"; 44 | $params = $this->params + ['query' => ['force' => $force ? 'true' : 'false', 'action' => $action]]; 45 | 46 | // Verify Authy token 47 | return new Response($this->http->get($url, $params)); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guide 2 | 3 | This project adheres to the following standards and practices. 4 | 5 | 6 | ## Versioning 7 | 8 | This project is versioned under the [Semantic Versioning](http://semver.org/) guidelines as much as possible. 9 | 10 | Releases will be numbered with the following format: 11 | 12 | - `..` 13 | - `..` 14 | 15 | And constructed with the following guidelines: 16 | 17 | - Breaking backward compatibility bumps the major and resets the minor and patch. 18 | - New additions without breaking backward compatibility bump the minor and reset the patch. 19 | - Bug fixes and misc changes bump the patch. 20 | 21 | 22 | ## Pull Requests 23 | 24 | The pull request process differs for new features and bugs. 25 | 26 | Pull requests for bugs may be sent without creating any proposal issue. If you believe that you know of a solution for a bug that has been filed, please leave a comment detailing your proposed fix or create a pull request with the fix mentioning that issue id. 27 | 28 | 29 | ## Coding Standards 30 | 31 | This project follows the FIG PHP Standards Recommendations compliant with the [PSR-1: Basic Coding Standard](http://www.php-fig.org/psr/psr-1/), [PSR-2: Coding Style Guide](http://www.php-fig.org/psr/psr-2/) and [PSR-4: Autoloader](http://www.php-fig.org/psr/psr-4/) to ensure a high level of interoperability between shared PHP code. If you notice any compliance oversights, please send a patch via pull request. 32 | 33 | 34 | ## Feature Requests 35 | 36 | If you have a proposal or a feature request, you may create an issue with `[Proposal]` in the title. 37 | 38 | The proposal should also describe the new feature, as well as implementation ideas. The proposal will then be reviewed and either approved or denied. Once a proposal is approved, a pull request may be created implementing the new feature. 39 | 40 | 41 | ## Git Flow 42 | 43 | This project follows [Git-Flow](http://nvie.com/posts/a-successful-git-branching-model/), and as such has `master` (latest stable releases), `develop` (latest WIP development) and X.Y support branches (when there's multiple major versions). 44 | 45 | Accordingly all pull requests MUST be sent to the `develop` branch. 46 | 47 | > **Note:** Pull requests which do not follow these guidelines will be closed without any further notice. 48 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rinvex/authy", 3 | "description": "Rinvex Authy is a simple wrapper for Authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise.", 4 | "type": "library", 5 | "keywords": [ 6 | "sms", 7 | "call", 8 | "authy", 9 | "message", 10 | "security", 11 | "twofactor", 12 | "verification", 13 | "authentication", 14 | "automated", 15 | "register", 16 | "rinvex", 17 | "phone", 18 | "token" 19 | ], 20 | "license": "MIT", 21 | "homepage": "https://rinvex.com", 22 | "support": { 23 | "email": "help@rinvex.com", 24 | "issues": "https://github.com/rinvex/authy/issues", 25 | "source": "https://github.com/rinvex/authy", 26 | "docs": "https://github.com/rinvex/authy/README.md" 27 | }, 28 | "authors": [ 29 | { 30 | "name": "Rinvex LLC", 31 | "homepage": "https://rinvex.com", 32 | "email": "help@rinvex.com" 33 | }, 34 | { 35 | "name": "Abdelrahman Omran", 36 | "homepage": "https://omranic.com", 37 | "email": "me@omranic.com", 38 | "role": "Project Lead" 39 | }, 40 | { 41 | "name": "The Generous Laravel Community", 42 | "homepage": "https://github.com/rinvex/authy/contributors" 43 | } 44 | ], 45 | "require": { 46 | "php": "^8.1.0", 47 | "guzzlehttp/guzzle": "^7.4.0", 48 | "psr/http-message": "^2.0.0" 49 | }, 50 | "require-dev": { 51 | "codedungeon/phpunit-result-printer": "^0.32.0", 52 | "mockery/mockery": "^1.6.0", 53 | "phpunit/phpunit": "^10.1.0" 54 | }, 55 | "autoload": { 56 | "psr-4": { 57 | "Rinvex\\Authy\\": "src" 58 | } 59 | }, 60 | "autoload-dev": { 61 | "psr-4": { 62 | "Rinvex\\Authy\\Tests\\": "tests" 63 | } 64 | }, 65 | "scripts": { 66 | "test": "vendor/bin/phpunit" 67 | }, 68 | "config": { 69 | "sort-packages": true, 70 | "preferred-install": "dist", 71 | "optimize-autoloader": true 72 | }, 73 | "minimum-stability": "dev", 74 | "prefer-stable": true 75 | } 76 | -------------------------------------------------------------------------------- /src/Response.php: -------------------------------------------------------------------------------- 1 | status = $httpResponse->getStatusCode(); 33 | $this->body = ($body = (string) $httpResponse->getBody()) ? json_decode($body, true) : null; 34 | } 35 | 36 | /** 37 | * Get Authy response status code. 38 | * 39 | * @return int 40 | */ 41 | public function statusCode(): int 42 | { 43 | return $this->status; 44 | } 45 | 46 | /** 47 | * Get Authy response body item. 48 | * 49 | * @param string $var 50 | * 51 | * @return mixed 52 | */ 53 | public function get($var) 54 | { 55 | return $this->body[$var] ?? null; 56 | } 57 | 58 | /** 59 | * Get Authy response body message. 60 | * 61 | * @return string 62 | */ 63 | public function message(): string 64 | { 65 | return $this->get('message'); 66 | } 67 | 68 | /** 69 | * Determine if the Authy response succeed. 70 | * 71 | * @return bool 72 | */ 73 | public function succeed(): bool 74 | { 75 | return $this->statusCode() === 200 && $this->isSuccess($this->get('success')); 76 | } 77 | 78 | /** 79 | * Determine if the Authy response failed. 80 | * 81 | * @return bool 82 | */ 83 | public function failed(): bool 84 | { 85 | return ! $this->succeed(); 86 | } 87 | 88 | /** 89 | * Get Authy response errors. 90 | * 91 | * @return array 92 | */ 93 | public function errors(): array 94 | { 95 | $errors = $this->get('errors') ?: []; 96 | 97 | return $this->failed() && ! empty($errors) ? $errors : []; 98 | } 99 | 100 | /** 101 | * Determine if the given result is success. 102 | * 103 | * @param mixed $result 104 | * 105 | * @return bool 106 | */ 107 | protected function isSuccess($result): bool 108 | { 109 | return ! is_null($result) ? (is_string($result) && $result === 'true') || (is_bool($result) && $result) : false; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/User.php: -------------------------------------------------------------------------------- 1 | api.'users/new'; 23 | $params = $this->params + [ 24 | 'form_params' => [ 25 | 'send_install_link_via_sms' => (bool) $sendInstallLink, 26 | 'user' => [ 27 | 'email' => $email, 28 | 'cellphone' => preg_replace('/[^0-9]/', '', $cellphone), 29 | 'country_code' => $countryCode, 30 | ], 31 | ], 32 | ]; 33 | 34 | // Register Authy user, and return response 35 | return new Response($this->http->post($url, $params)); 36 | } 37 | 38 | /** 39 | * Register the given user activity. 40 | * 41 | * @param int $authyId 42 | * @param string $type 43 | * @param string $data 44 | * @param string|null $ip 45 | * 46 | * @return \Rinvex\Authy\Response 47 | */ 48 | public function registerActivity($authyId, $type, $data, $ip = null): Response 49 | { 50 | // Prepare required variables 51 | $url = $this->api."users/{$authyId}/register_activity"; 52 | $params = $this->params + ['form_params' => ['type' => $type, 'data' => $data, 'user_ip' => $ip]]; 53 | 54 | // Register Authy user activity, and return response 55 | return new Response($this->http->post($url, $params)); 56 | } 57 | 58 | /** 59 | * Get status of the given user. 60 | * 61 | * @param int $authyId 62 | * @param string|null $ip 63 | * 64 | * @return \Rinvex\Authy\Response 65 | */ 66 | public function status($authyId, $ip = null): Response 67 | { 68 | // Prepare required variables 69 | $url = $this->api."users/{$authyId}/status"; 70 | $params = $this->params + ['query' => ['user_ip' => $ip]]; 71 | 72 | // Return Authy user status 73 | return new Response($this->http->get($url, $params)); 74 | } 75 | 76 | /** 77 | * Delete the given Authy user. 78 | * 79 | * @param int $authyId 80 | * @param string|null $ip 81 | * 82 | * @return \Rinvex\Authy\Response 83 | */ 84 | public function delete($authyId, $ip = null): Response 85 | { 86 | // Prepare required variables 87 | $url = $this->api."users/{$authyId}/remove"; 88 | $params = $this->params + ['form_params' => ['ip' => $ip]]; 89 | 90 | // Delete Authy user, and return response 91 | return new Response($this->http->post($url, $params)); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at [help@rinvex.com](mailto:help@rinvex.com). All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at [http://contributor-covenant.org/version/1/4][version] 72 | 73 | [homepage]: http://contributor-covenant.org 74 | [version]: http://contributor-covenant.org/version/1/4/ 75 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Rinvex Authy Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | This project adheres to [Semantic Versioning](CONTRIBUTING.md). 6 | 7 | 8 | ## [v7.1.1] - 2023-07-03 9 | - Update composer dependencies 10 | 11 | ## [v7.1.0] - 2023-05-02 12 | - Update composer dependency psr/http-message to v2.0 from v1.0 13 | - Update phpunit to v10.1 from v9.5 14 | 15 | ## [v7.0.0] - 2023-01-09 16 | - Drop PHP v8.0 support and update composer dependencies 17 | 18 | ## [v6.1.0] - 2022-02-14 19 | - Update composer dependencies 20 | 21 | ## [v6.0.0] - 2021-08-22 22 | - Drop PHP v7 support, and upgrade rinvex package dependencies to next major version 23 | - Update composer dependencies 24 | - Upgrade to GitHub-native Dependabot (#33) 25 | - Update User deletion endpoint to comply with Authy (#28) 26 | - Enable StyleCI risky mode 27 | 28 | ## [v5.0.3] - 2020-12-25 29 | - Add support for PHP v8 30 | 31 | ## [v5.0.2] - 2020-12-22 32 | - Update composer dependencies 33 | - Update composer dependency mockery/mockery 34 | - Drop PHP 7.2 & 7.3 support from travis 35 | - Remove default indent size config 36 | 37 | ## [v5.0.1] - 2020-04-04 38 | - Drop laravel/helpers usage as it's no longer used 39 | 40 | ## [v5.0.0] - 2020-03-15 41 | - Upgrade to Laravel v7.1.x & PHP v7.4.x 42 | 43 | ## [v4.1.2] - 2019-03-13 44 | - Tweak TravisCI config 45 | - Update StyleCI config 46 | 47 | ## [v4.1.1] - 2019-09-24 48 | - Add missing laravel/helpers composer package 49 | 50 | ## [v4.1.0] - 2019-06-02 51 | - Update composer deps 52 | - Drop PHP 7.1 travis test 53 | 54 | ## [v4.0.0] - 2019-03-03 55 | - Rename environment variable QUEUE_DRIVER to QUEUE_CONNECTION 56 | - Require PHP 7.2 & Laravel 5.8 57 | - Apply PHPUnit 8 updates 58 | 59 | ## [v3.0.2] - 2018-12-22 60 | - Update composer dependencies 61 | - Add PHP 7.3 support to travis 62 | 63 | ## [v3.0.1] - 2018-09-22 64 | - Update travis php versions 65 | - Drop StyleCI multi-language support (paid feature now!) 66 | - Update composer dependencies 67 | - Prepare and tweak testing configuration 68 | - Update StyleCI options 69 | - Update PHPUnit options 70 | 71 | ## [v3.0.0] - 2018-02-18 72 | - Require PHP v7.1.3 73 | - Update supplementary files 74 | - Update composer depedencies 75 | - Fix deprecated PHPUnit TestCase namespace 76 | - Add PHPUnitPrettyResultPrinter 77 | - Typehint method returns 78 | 79 | ## [v2.1.1] - 2017-03-08 80 | - Clean and tweak Authy Response class 81 | - Fix auth api force query parameter data type 82 | - Rename InvalidConfiguration namespace 83 | - Declare functions return types 84 | 85 | ## [v2.1.0] - 2017-03-07 86 | - Pass force flag as string true/false as per Authy API docs 87 | - Enforce strict type declaration 88 | - Update StyleCI fixers and other supplementary files 89 | 90 | ## [v2.0.1] - 2016-12-20 91 | - Add upgrade guide and fix minor typo 92 | 93 | ## [v2.0.0] - 2016-12-20 94 | - Simplify code 95 | - Drop LTS support 96 | - Update Code Style 97 | - Drop Authy deprecated sandbox api support 98 | - Push dependencies forward and require php7 99 | 100 | ## [v1.0.0] - 2016-11-17 101 | - Commit first stable release 102 | 103 | ## [v0.0.5] - 2016-11-17 104 | - Alias master branch for version stability requirements 105 | 106 | ## [v0.0.4] - 2016-11-16 107 | - Fix wrong installation steps 108 | 109 | ## [v0.0.3] - 2016-11-15 110 | - Fix wrong sensiolabs insight ID 111 | - Fix wrong files permissions 112 | - Add Travis shield 113 | 114 | ## [v0.0.2] - 2016-11-15 115 | - Fix few typos 116 | 117 | ## v0.0.1 - 2016-11-15 118 | - Tag first release 119 | 120 | [v7.1.1]: https://github.com/rinvex/authy/compare/v7.1.0...v7.1.1 121 | [v7.1.0]: https://github.com/rinvex/authy/compare/v7.0.0...v7.1.0 122 | [v7.0.0]: https://github.com/rinvex/authy/compare/v6.1.0...v7.0.0 123 | [v6.1.0]: https://github.com/rinvex/authy/compare/v6.0.0...v6.1.0 124 | [v6.0.0]: https://github.com/rinvex/authy/compare/v5.0.3...v6.0.0 125 | [v5.0.3]: https://github.com/rinvex/authy/compare/v5.0.2...v5.0.3 126 | [v5.0.2]: https://github.com/rinvex/authy/compare/v5.0.1...v5.0.2 127 | [v5.0.1]: https://github.com/rinvex/authy/compare/v5.0.0...v5.0.1 128 | [v5.0.0]: https://github.com/rinvex/authy/compare/v4.1.2...v5.0.0 129 | [v4.1.2]: https://github.com/rinvex/authy/compare/v4.1.1...v4.1.2 130 | [v4.1.1]: https://github.com/rinvex/authy/compare/v4.1.0...v4.1.1 131 | [v4.1.0]: https://github.com/rinvex/authy/compare/v4.0.0...v4.1.0 132 | [v4.0.0]: https://github.com/rinvex/authy/compare/v3.0.2...v4.0.0 133 | [v3.0.2]: https://github.com/rinvex/authy/compare/v3.0.1...v3.0.2 134 | [v3.0.1]: https://github.com/rinvex/authy/compare/v3.0.0...v3.0.1 135 | [v3.0.0]: https://github.com/rinvex/authy/compare/v2.1.1...v3.0.0 136 | [v2.1.1]: https://github.com/rinvex/authy/compare/v2.1.0...v2.1.1 137 | [v2.1.0]: https://github.com/rinvex/authy/compare/v2.0.1...v2.1.0 138 | [v2.0.1]: https://github.com/rinvex/authy/compare/v2.0.0...v2.0.1 139 | [v2.0.0]: https://github.com/rinvex/authy/compare/v1.0.0...v2.0.0 140 | [v1.0.0]: https://github.com/rinvex/authy/compare/v0.0.5...v1.0.0 141 | [v0.0.5]: https://github.com/rinvex/authy/compare/v0.0.4...v0.0.5 142 | [v0.0.4]: https://github.com/rinvex/authy/compare/v0.0.3...v0.0.4 143 | [v0.0.3]: https://github.com/rinvex/authy/compare/v0.0.2...v0.0.3 144 | [v0.0.2]: https://github.com/rinvex/authy/compare/v0.0.1...v0.0.2 145 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rinvex Authy 2 | 3 | **Rinvex Authy** is a simple wrapper for Authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise. 4 | 5 | [![Packagist](https://img.shields.io/packagist/v/rinvex/authy.svg?label=Packagist&style=flat-square)](https://packagist.org/packages/rinvex/authy) 6 | [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/rinvex/authy.svg?label=Scrutinizer&style=flat-square)](https://scrutinizer-ci.com/g/rinvex/authy/) 7 | [![Travis](https://img.shields.io/travis/rinvex/authy.svg?label=TravisCI&style=flat-square)](https://travis-ci.org/rinvex/authy) 8 | [![StyleCI](https://styleci.io/repos/73740838/shield)](https://styleci.io/repos/73740838) 9 | [![License](https://img.shields.io/packagist/l/rinvex/authy.svg?label=License&style=flat-square)](https://github.com/rinvex/authy/blob/develop/LICENSE) 10 | 11 | ![Rinvex Authy](https://rinvex.com/assets/frontend/layout/img/products/rinvex-authy.png "Rinvex Authy") 12 | 13 | 14 | ## Table Of Contents 15 | 16 | - [Usage](#usage) 17 | - [Installation](#installation) 18 | - [Upgrade](#upgrade) 19 | - [Changelog](#changelog) 20 | - [Support](#support) 21 | - [Contributing & Protocols](#contributing--protocols) 22 | - [Security Vulnerabilities](#security-vulnerabilities) 23 | - [About Rinvex](#about-rinvex) 24 | - [Trademarks](#trademarks) 25 | - [License](#license) 26 | 27 | 28 | ## Usage 29 | 30 | Usage is pretty easy and straightforward: 31 | 32 | ### Prepare requirements 33 | 34 | ```php 35 | $apiKey = 'AuthySecretKey'; 36 | $httpClient = new \GuzzleHttp\Client(); 37 | ``` 38 | 39 | > **Note:** make sure to replace `AuthySecretKey` with your secret key from the installation steps. 40 | 41 | ### Authy App 42 | 43 | Create a new Authy app instance and interact with it: 44 | 45 | ```php 46 | $authyApp = new \Rinvex\Authy\App($httpClient, $apiKey); 47 | 48 | $appStats = $authyApp->stats(); // Get app stats 49 | $appDetails = $authyApp->details(); // Get app details 50 | ``` 51 | 52 | ### Authy User 53 | 54 | Create a new Authy user instance and interact with it: 55 | 56 | ```php 57 | $authyUser = new \Rinvex\Authy\User($httpClient, $apiKey); 58 | 59 | $user = $authyUser->register('user@domain.com', '317-338-9302', '54'); // Register user 60 | $userActivity = $authyUser->registerActivity($user->get('user')['id'], 'cookie_login', 'Test Data'); // Register user activity 61 | $userStatus = $authyUser->status($user->get('user')['id']); // Get user status 62 | $userDeleted = $authyUser->delete($user->get('user')['id']); // Delete user 63 | ``` 64 | 65 | ### Authy Token 66 | 67 | Create a new Authy token instance and interact with it: 68 | 69 | ```php 70 | $authyToken = new \Rinvex\Authy\Token($httpClient, $apiKey); 71 | 72 | $smsTokenSent = $authyToken->send($user->get('user')['id'], 'sms'); // Send SMS token 73 | $callTokenStarted = $authyToken->send($user->get('user')['id'], 'call'); // Start automated call 74 | $tokenVerified = $authyToken->verify(54321, $user->get('user')['id']); // Verify token 75 | ``` 76 | 77 | ### Intuitive Responses 78 | 79 | Work Intuitively with Authy responses: 80 | 81 | ```php 82 | $body = $tokenVerified->body(); // Get all response body 83 | $code = $tokenVerified->statusCode(); // Get response status code 84 | $succeed = $tokenVerified->succeed(); // Check whether respose is a success 85 | $failed = $tokenVerified->failed(); // Check whether respose is a failure 86 | $message = $tokenVerified->message(); // Get response message 87 | $item = $tokenVerified->get('item'); // Get response body item 88 | $errors = $tokenVerified->errors(); // Get response errors 89 | ``` 90 | 91 | > **Note:** All authy requests return authy response, with a unified interface for your convenience, so you can interact with all responses the same way as above. 92 | 93 | 94 | ## Installation 95 | 96 | 1. Install the package via composer: 97 | ```shell 98 | composer require rinvex/authy 99 | ``` 100 | 101 | 2. If you haven't already: Register an [Authy](https://www.authy.com) account -> Sign in -> Access [dashboard](https://dashboard.authy.com) -> Create new application -> Copy your API Secret key 102 | 103 | 3. Done! You can refer to [Usage](#usage) again. 104 | 105 | 106 | ## Upgrade 107 | 108 | - **Upgrading To `v2.x` From `v1.x`** 109 | 110 | API implementation is 100% backward compatible, but sandbox API has been dropped since it's officially deprecated. Also note that PHP7 is now required. 111 | 112 | 113 | ## Changelog 114 | 115 | Refer to the [Changelog](CHANGELOG.md) for a full history of the project. 116 | 117 | 118 | ## Support 119 | 120 | The following support channels are available at your fingertips: 121 | 122 | - [Chat on Slack](https://bit.ly/rinvex-slack) 123 | - [Help on Email](mailto:help@rinvex.com) 124 | - [Follow on Twitter](https://twitter.com/rinvex) 125 | 126 | 127 | ## Contributing & Protocols 128 | 129 | Thank you for considering contributing to this project! The contribution guide can be found in [CONTRIBUTING.md](CONTRIBUTING.md). 130 | 131 | Bug reports, feature requests, and pull requests are very welcome. 132 | 133 | - [Versioning](CONTRIBUTING.md#versioning) 134 | - [Pull Requests](CONTRIBUTING.md#pull-requests) 135 | - [Coding Standards](CONTRIBUTING.md#coding-standards) 136 | - [Feature Requests](CONTRIBUTING.md#feature-requests) 137 | - [Git Flow](CONTRIBUTING.md#git-flow) 138 | 139 | 140 | ## Security Vulnerabilities 141 | 142 | If you discover a security vulnerability within this project, please send an e-mail to [help@rinvex.com](help@rinvex.com). All security vulnerabilities will be promptly addressed. 143 | 144 | 145 | ## About Rinvex 146 | 147 | Rinvex is a software solutions startup, specialized in integrated enterprise solutions for SMEs established in Alexandria, Egypt since June 2016. We believe that our drive The Value, The Reach, and The Impact is what differentiates us and unleash the endless possibilities of our philosophy through the power of software. We like to call it Innovation At The Speed Of Life. That’s how we do our share of advancing humanity. 148 | 149 | 150 | ## Trademarks 151 | 152 | - [Authy™](https://www.authy.com) is a trademark of [Twilio Inc.](https://www.twilio.com) 153 | 154 | 155 | ## License 156 | 157 | This software is released under [The MIT License (MIT)](LICENSE). 158 | 159 | (c) 2016-2022 Rinvex LLC, Some rights reserved. 160 | --------------------------------------------------------------------------------