Authy notification channel for Laravel, with the ability to send in-app, sms, and call verification tokens.
Installs: 34 900
Dependents: 1
Suggesters: 0
Security: 0
Stars: 57
Watchers: 5
Forks: 15
Open Issues: 0
Requires
- php: ^8.1.0
- illuminate/notifications: ^10.0.0 || ^11.0.0
- illuminate/queue: ^10.0.0 || ^11.0.0
- rinvex/laravel-authy: ^10.0.0
Requires (Dev)
- codedungeon/phpunit-result-printer: ^0.32.0
- mockery/mockery: ^1.4.0
- phpunit/phpunit: ^9.5.0
README
Authy notification channel for Laravel, with the ability to send in-app, sms, and call verification tokens.
Table Of Contents
- Usage
- Upgrade
- Changelog
- Support
- Contributing & Protocols
- Security Vulnerabilities
- About Rinvex
- Trademarks
- License
Usage
-
Install the package via composer:
composer require laravel-notification-channels/authy
-
This package requires
rinvex/laravel-authy
package, so before proceeding make sure to follow up its installation steps first. -
Next, to route Authy notifications to the proper entity, define a
routeNotificationForAuthy
method on your notifiable entity. This should return the Authy Id to which the notification should be sent. Example:/** * Route notifications for the authy channel. * * @return int */ public function routeNotificationForAuthy() { return $this->authy_id; }
Note: as you might thought, this requires an
authy_id
attribute in your notifiable entity, for which you may need to create an additional field in the database table. -
Now you can create notifications that use Authy channel as follows:
// app/Notifications/PhoneVerificationNotification.php namespace App\Notifications; use Illuminate\Notifications\Notification; use NotificationChannels\Authy\AuthyChannel; use NotificationChannels\Authy\AuthyMessage; class PhoneVerificationNotification extends Notification { /** * The notification method (sms/call). * * @var string */ public $method; /** * Determine whether to force the notification over cellphone network. * * @var bool */ public $force; /** * The notification message action. * * @var string */ public $action; /** * The notification message action message. * * @var string */ public $actionMessage; /** * Create a notification instance. * * @param string $method * @param bool $force * @param string $action * @param string $actionMessage * * @return void */ public function __construct($method = 'sms', $force = false, $action = null, $actionMessage = null) { $this->method = $method; $this->force = $force; $this->action = $action; $this->actionMessage = $actionMessage; } /** * Get the notification's channels. * * @param mixed $notifiable * * @return array|string */ public function via($notifiable) { return [AuthyChannel::class]; } /** * Build the Authy representation of the notification. * * @return \NotificationChannels\Authy\AuthyMessage */ public function toAuthy() { $message = AuthyMessage::create()->method($this->method); if ($this->force) { $message->force(); } if ($this->action) { $message->action($action); } if ($this->actionMessage) { $message->actionMessage($actionMessage); } return $message; } }
-
Finally you can consume the notification as follows:
$this->notify(new \App\Notifications\PhoneVerificationNotification('sms', true));
Note: don't forget to read through Authy TOTP API documentation for further information.
-
Done!
Upgrade
-
Upgrading To
v2.x
Fromv1.x
API implementation is 100% backward compatible, but sandbox API has been dropped since it's officially deprecated. Also note that PHP7 is now required.
Changelog
Refer to the Changelog for a full history of the project.
Support
The following support channels are available at your fingertips:
Contributing & Protocols
Thank you for considering contributing to this project! The contribution guide can be found in CONTRIBUTING.md.
Bug reports, feature requests, and pull requests are very welcome.
Security Vulnerabilities
If you discover a security vulnerability within this project, please send an e-mail to security@rinvex.com. All security vulnerabilities will be promptly addressed.
About Rinvex
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.
Trademarks
- Authy™ is a trademark of Twilio Inc.
- Laravel™ is a trademark of TAYLOR OTWELL
License
This software is released under The MIT License (MIT).
(c) 2016-2020 Rinvex LLC, Some rights reserved.