BREAKING CHANGES:
- the library is now defined under the
Castle\namespace (Castle\Castle,Castle\Webhook,Castle\RequestContext,Castle\ApiError, ...), which is the canonical API (#40) - removed the legacy
Castle::track,Castle::authenticateandCastle::impersonateendpoints (and theCastle_Authenticatemodel); useCastle::risk,Castle::filterandCastle::loginstead Castle::riskandCastle::filternow fail over to a configurable decision instead of throwing on network errors, timeouts and5xxresponses;Castle::logreturns the same response shape.Castle::risk/filter/logresponses now includefailoverandfailover_reason- the default request timeout is now 1000 ms (previously 10 s), applied to both connection and transfer; configure it with
Castle::setRequestTimeout - removed
Castle::setCurlOpts/Castle::getCurlOpts(and theCastle\CurlOptionErrorexception with itsCastle_CurlOptionErroralias); useCastle::setRequestTimeoutto configure the connection and transfer timeout - replaced the separate
Castle::$apiBase/Castle::$apiVersion(andCastle::getApiVersion/setApiVersion) with a singleCastle::$baseUrl(defaulthttps://api.castle.io/v1), configurable viaCastle::getBaseUrl/Castle::setBaseUrl - removed the configurable token/cookie store (
Castle::$tokenStore,Castle::$cookieStore,Castle::getTokenStore/getCookieStore/setTokenStore) and theCastle\CookieStoreclass (with itsCastle_CookieStore/Castle_iCookieStorealiases); these read the client id from the__cidcookie, which the slimmed request context no longer does
Other changes:
- slimmed the default request context built by
Castle\RequestContext::extractdown toip,headersandlibrary; theclient_idanduser_agentfields (and theRequestContext::extractClientId,extractUserAgentandnormalizehelpers) are removed, as the client id is carried by theX-Castle-Client-Idheader /__cidcookie and resolved server-side - added a configurable failover strategy (
Castle::setFailoverStrategywithCastle\Failover::ALLOW/DENY/CHALLENGE/THROW) and theCastle\InternalServerErrorexception for5xxresponses - added do-not-track support:
Castle::disableTracking,Castle::enableTrackingandCastle::tracked - added the Events API:
Castle::eventsSchema,Castle::queryEvents,Castle::groupEvents - the historic global class names (
Castle,Castle_*,RestModel) are retained as aliases of their namespaced counterparts, so existing integrations keep working without changes;catchandinstanceofwork with either name - additional PHP 8 compatibility fixes: declared
Castle_Resource::$model, and avoided passingnulltoExceptionandjson_decode