diff --git a/README.md b/README.md index fa6b0dc..d945f00 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Sonarcloud Status](https://sonarcloud.io/api/project_badges/measure?project=Laragear_ReCaptcha&metric=alert_status)](https://sonarcloud.io/dashboard?id=Laragear_ReCaptcha) [![Laravel Octane Compatibility](https://img.shields.io/badge/Laravel%20Octane-Compatible-success?style=flat&logo=laravel)](https://laravel.com/docs/11.x/octane#introduction) -Integrate reCAPTCHA using **async HTTP/2**, making your app **fast** with a few lines. +Integrate reCAPTCHA using **async HTTP/3**, making your app **fast** with a few lines. ```php use Illuminate\Support\Facades\Route; @@ -449,14 +449,14 @@ This also control how many minutes to set the "remember". You can set `INF` cons ```php return [ 'client' => [ - 'version' => 2.0, + 'version' => 3.0, ], ]; ``` This array sets the options for the outgoing request to reCAPTCHA servers. [This is handled by Guzzle](https://docs.guzzlephp.org/en/stable/request-options.html), which in turn will pass it to the underlying transport. Depending on your system, it will probably be cURL. -By default, it instructs Guzzle to use HTTP/2 whenever possible. +By default, it instructs Guzzle to use HTTP/3 whenever possible. ### Credentials @@ -554,9 +554,11 @@ The file gets published into the `.stubs` folder of your project, while the meta There should be no problems using this package with Laravel Octane as intended. -## HTTP/3 +## HTTP/3 and cURL + +To use HTTP/3, [ensure you're using PHP 8.2 or later](https://php.watch/articles/php-curl-http3). cURL version [7.66](https://curl.se/changes.html#7_66_0) supports HTTP/3, and latest PHP 8.2 uses version 7.85. -Currently, HTTP/3 is [still on draft state](https://datatracker.ietf.org/doc/draft-ietf-quic-http/). Until it's [Internet Standard](https://en.wikipedia.org/wiki/Internet_Standard), cURL and Guzzle and reCAPTCHA servers must implement the finished state of the protocol, which as of today is still a moving target. +For more information about checking if your platform can make HTTP/3 requests, check this [PHP Watch article](https://php.watch/articles/php-curl-http3). ## Security diff --git a/composer.json b/composer.json index e9c5a61..05ea280 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "laragear/recaptcha", - "description": "Integrate reCAPTCHA using async HTTP/2, making your app fast with a few lines.", + "description": "Integrate reCAPTCHA using async HTTP/3, making your app fast with a few lines.", "type": "library", "license": "MIT", "minimum-stability": "dev", @@ -9,7 +9,9 @@ "laragear", "captcha", "recaptcha", - "google" + "google", + "http2", + "http3" ], "authors": [ { diff --git a/config/recaptcha.php b/config/recaptcha.php index acc1a6f..d96948c 100644 --- a/config/recaptcha.php +++ b/config/recaptcha.php @@ -1,5 +1,6 @@ [ - 'version' => 2.0, + RequestOptions::VERSION => 3.0, ], /* diff --git a/tests/Http/Middleware/ScoreMiddlewareTest.php b/tests/Http/Middleware/ScoreMiddlewareTest.php index dd48d77..50ce012 100644 --- a/tests/Http/Middleware/ScoreMiddlewareTest.php +++ b/tests/Http/Middleware/ScoreMiddlewareTest.php @@ -432,7 +432,7 @@ public function test_checks_for_human_score(): void $mock->expects('async')->withNoArgs()->times(4)->andReturnSelf(); $mock->expects('asForm')->withNoArgs()->times(4)->andReturnSelf(); - $mock->expects('withOptions')->with(['version' => 2.0])->times(4)->andReturnSelf(); + $mock->expects('withOptions')->with(['version' => 3.0])->times(4)->andReturnSelf(); $mock->expects('post') ->with( ReCaptcha::SERVER_ENDPOINT, diff --git a/tests/ReCaptchaTest.php b/tests/ReCaptchaTest.php index bbd7b50..667bc00 100644 --- a/tests/ReCaptchaTest.php +++ b/tests/ReCaptchaTest.php @@ -18,7 +18,7 @@ public function test_returns_response(): void $mock->expects('asForm')->withNoArgs()->once()->andReturnSelf(); $mock->expects('async')->withNoArgs()->once()->andReturnSelf(); - $mock->expects('withOptions')->with(['version' => 2.0])->once()->andReturnSelf(); + $mock->expects('withOptions')->with(['version' => 3.0])->once()->andReturnSelf(); $mock->expects('post') ->with( ReCaptcha::SERVER_ENDPOINT, @@ -62,7 +62,7 @@ public function test_uses_v2_test_credentials_by_default(): void $mock->expects('asForm')->withNoArgs()->times(3)->andReturnSelf(); $mock->expects('async')->withNoArgs()->times(3)->andReturnSelf(); - $mock->expects('withOptions')->with(['version' => 2.0])->times(3)->andReturnSelf(); + $mock->expects('withOptions')->with(['version' => 3.0])->times(3)->andReturnSelf(); $mock->expects('post') ->with( ReCaptcha::SERVER_ENDPOINT, @@ -114,7 +114,7 @@ public function test_uses_v2_custom_credentials(): void $mock->expects('asForm')->withNoArgs()->times(3)->andReturnSelf(); $mock->expects('async')->withNoArgs()->times(3)->andReturnSelf(); - $mock->expects('withOptions')->with(['version' => 2.0])->times(3)->andReturnSelf(); + $mock->expects('withOptions')->with(['version' => 3.0])->times(3)->andReturnSelf(); $mock->expects('post') ->with( @@ -207,7 +207,7 @@ public function test_receives_v3_secret(): void $mock->expects('asForm')->withNoArgs()->once()->andReturnSelf(); $mock->expects('async')->withNoArgs()->once()->andReturnSelf(); - $mock->expects('withOptions')->with(['version' => 2.0])->once()->andReturnSelf(); + $mock->expects('withOptions')->with(['version' => 3.0])->once()->andReturnSelf(); $mock->expects('post') ->with(ReCaptcha::SERVER_ENDPOINT, [ 'secret' => 'secret',