| Name | Modified | Size | Downloads / Week |
|---|---|---|---|
| Parent folder | |||
| 2.1.0 source code.tar.gz | 2026-09-23 | 10.7 kB | |
| 2.1.0 source code.zip | 2026-09-23 | 22.2 kB | |
| README.md | 2026-09-23 | 3.8 kB | |
| Totals: 3 Items | 36.8 kB | 1 | |
Overview
2.1.0 is a backwards-compatible minor release in the 2.x series (PHP >=8.4) introducing immutable with*() builder methods on ReCaptcha, \JsonSerializable support on Response, configurable transport timeouts, ReCaptcha::SITE_VERIFY_URL_ALTERNATIVE, cURL handle connection reuse, unified HTTP status validation across all transports, and validation/security hardening.
What's Changed
- Immutable
with*()Builder Methods (ReCaptcha): - Added
withExpectedHostname(),withExpectedApkPackageName(),withExpectedAction(),withScoreThreshold(), andwithChallengeTimeout()methods that return a clonedReCaptchainstance instead of mutating the instance in place—makingReCaptchasafe to share as a singleton in dependency injection containers and persistent worker runtimes (FrankenPHP, RoadRunner, Swoole, Laravel Octane) (#637). Response implements \JsonSerializable:- Implemented
\JsonSerializable(jsonSerialize()) onReCaptcha\Responseso response objects can be passed directly tojson_encode()(#636). - Configurable Transport Timeouts & Alternative Global Endpoint:
- Added an optional
int $timeout = 60constructor parameter toCurlPost,Post, andSocketPost, and addedCURLOPT_CONNECTTIMEOUTtoCurlPost(#636). - Added
ReCaptcha::SITE_VERIFY_URL_ALTERNATIVE(https://www.recaptcha.net/recaptcha/api/siteverify) for environments wherewww.google.comis not accessible (#636). - Connection Reuse & Transport Hardening:
CurlPostnow lazily initializes and reuses itsCurlHandleacrosssubmit()calls for TLS session resumption and HTTP keep-alive (#637).- Unified HTTP
200status validation acrossCurlPost(CURLINFO_HTTP_CODE),Post(http_get_last_response_headers()withignore_errors), andSocketPostso non-200 HTTP responses consistently returnReCaptcha::E_BAD_RESPONSE(#637). SocketPostnow loopsfwrite()to handle partial TLS socket writes and closes the socket handle cleanly on write failures (#637).- Security Hardening:
- Added
#[\SensitiveParameter]to$secretinReCaptcha::__construct()andRequestParameters::__construct()to prevent secret exposure in stack traces (#636). - Hardened
examples/against DOM XSS, added server-side action allowlisting inexamples/recaptcha-v3-verify.php, updated CSPconnect-src, and addedexamples/recaptcha-v3-immutable.php(#636, #637).
Bug Fixes
- Fixed
setScoreThreshold(0.0)null-coercion bypass whenscoreis omitted (null) from the API response so it properly fails withReCaptcha::E_SCORE_THRESHOLD_NOT_MET(#637). - Fixed
setChallengeTimeout()failing open whenchallenge_tsis empty or unparseable; it now fails closed withReCaptcha::E_CHALLENGE_TIMEOUT(#637). - Filtered
error-codesinResponse::fromJson()to ensure only string elements are retained (#636).
Compatibility & Upgrade Guide
- 100% Backwards-Compatible with
2.0.0: Verified viaroave/backward-compatibility-check. - Upgrade via Composer:
bash composer update google/recaptcha
Full Changelog: https://github.com/google/recaptcha/compare/2.0.0...2.1.0