diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f08d53..0102b9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.1] - 2026-10-27 + +### Security + +- `ButtonPressed`, `ToastAction` and `InputSubmitted` implement `Native\Mobile\Events\Contracts\DispatchableFromNative`, which the `/_native/api/events` endpoint requires since NativePHP Mobile 3.3.11 and 4.6.1 ([GHSA-83jv-8h7x-287p](https://github.com/NativePHP/mobile-air/security/advisories/GHSA-83jv-8h7x-287p)). Without it, Laravel listeners for these events stop receiving them on patched NativePHP versions. + +### Changed + +- Requires `nativephp/mobile` `^3.3.11|^4.6.1`. Older 3.x versions lack the marker interface and are affected by the advisories above. +- Custom event classes passed to `->event()` must implement `DispatchableFromNative` to reach Laravel listeners. + ## [1.0.0] - 2026-03-01 ### Added @@ -27,4 +38,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Android: min SDK 24, uses `com.google.android.material:material:1.12.0` - iOS: min version 15.0, no external dependencies +[1.0.1]: https://github.com/mazer-dev/nativephp-dialogify/releases/tag/1.0.1 [1.0.0]: https://github.com/mazer-dev/nativephp-dialogify/releases/tag/v1.0.0 diff --git a/README.md b/README.md index 46821fa..4a6ffca 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ A complete native communication hub for your NativePHP Mobile app -- toast notif ## Requirements - PHP >= 8.2 -- NativePHP Mobile ^3.0 +- NativePHP Mobile ^3.3.11 or ^4.6.1 - Android min SDK 24 - iOS >= 15.0 @@ -329,6 +329,24 @@ Dialogify::alert('Edit Profile') // Your custom event class receives the same payload ``` +The custom event class must implement `Native\Mobile\Events\Contracts\DispatchableFromNative`. Since NativePHP Mobile 3.3.11 and 4.6.1, the `/_native/api/events` endpoint refuses any class without this marker ([GHSA-83jv-8h7x-287p](https://github.com/NativePHP/mobile-air/security/advisories/GHSA-83jv-8h7x-287p)), so Laravel listeners registered with `Event::listen` never receive it. Livewire `#[OnNative]` handlers still receive the event, because the web view dispatches it to Livewire directly. + +```php +use Native\Mobile\Events\Contracts\DispatchableFromNative; + +class ProfileUpdated implements DispatchableFromNative +{ + public function __construct( + public string $buttonId, + public string $label, + public ?string $dialogId = null, + public array $inputs = [], + ) {} +} +``` + +The built-in `ButtonPressed`, `ToastAction` and `InputSubmitted` events already implement the marker. + --- ## JavaScript Usage diff --git a/composer.json b/composer.json index 003d790..704c70a 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "license": "proprietary", "require": { "php": "^8.3", - "nativephp/mobile": "^3.0" + "nativephp/mobile": "^3.3.11|^4.6.1" }, "require-dev": { "laravel/pint": "^1.27", diff --git a/src/Events/ButtonPressed.php b/src/Events/ButtonPressed.php index 9bfbcd2..1c346d6 100644 --- a/src/Events/ButtonPressed.php +++ b/src/Events/ButtonPressed.php @@ -4,8 +4,9 @@ use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; +use Native\Mobile\Events\Contracts\DispatchableFromNative; -class ButtonPressed +class ButtonPressed implements DispatchableFromNative { use Dispatchable, SerializesModels; diff --git a/src/Events/InputSubmitted.php b/src/Events/InputSubmitted.php index e2f0c13..e998e55 100644 --- a/src/Events/InputSubmitted.php +++ b/src/Events/InputSubmitted.php @@ -4,8 +4,9 @@ use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; +use Native\Mobile\Events\Contracts\DispatchableFromNative; -class InputSubmitted +class InputSubmitted implements DispatchableFromNative { use Dispatchable, SerializesModels; diff --git a/src/Events/ToastAction.php b/src/Events/ToastAction.php index 3f792ef..f96f609 100644 --- a/src/Events/ToastAction.php +++ b/src/Events/ToastAction.php @@ -4,8 +4,9 @@ use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; +use Native\Mobile\Events\Contracts\DispatchableFromNative; -class ToastAction +class ToastAction implements DispatchableFromNative { use Dispatchable, SerializesModels; diff --git a/tests/Unit/EventsTest.php b/tests/Unit/EventsTest.php index b0a5f48..7c7fac3 100644 --- a/tests/Unit/EventsTest.php +++ b/tests/Unit/EventsTest.php @@ -3,6 +3,7 @@ use MazerDev\Dialogify\Events\ButtonPressed; use MazerDev\Dialogify\Events\InputSubmitted; use MazerDev\Dialogify\Events\ToastAction; +use Native\Mobile\Events\Contracts\DispatchableFromNative; test('ButtonPressed event stores properties', function () { $event = new ButtonPressed( @@ -55,3 +56,7 @@ expect($event->inputs)->toBe([]); }); + +test('events can be dispatched from native', function (string $event) { + expect(is_subclass_of($event, DispatchableFromNative::class))->toBeTrue(); +})->with([ButtonPressed::class, ToastAction::class, InputSubmitted::class]);