PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.3
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.3
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / ai / authentication / application / auth-strategy-interface.php

auth-strategy-interface.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.3, at src/ai/authentication/application/auth-strategy-interface.php

37 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
4
5 namespace Yoast\WP\SEO\AI\Authentication\Application;
6
7 use WP_User;
8 use Yoast\WP\SEO\AI\HTTP_Request\Domain\Request;
9 use Yoast\WP\SEO\AI\HTTP_Request\Domain\Response;
10
11 /**
12 * Strategy for authenticating and dispatching an outbound yoast-ai request.
13 *
14 * Strategies own the full call: they acquire whatever credentials they need, dispatch the request,
15 * map the result into the AI Response domain object, and translate any non-200 into the matching
16 * typed exception. Any failure-path cleanup (clearing a stale cached token, deleting stored JWTs,
17 * translating one exception type into another) happens inside the implementation before the
18 * exception is rethrown. The sender does not retry — it only chooses between a primary and an
19 * optional fallback strategy.
20 */
21 interface Auth_Strategy_Interface {
22
23 /**
24 * Authenticates and dispatches the request, returning the parsed response.
25 *
26 * Non-200 responses are translated into typed exceptions from the AI HTTP_Request exception
27 * family. Strategy-specific 4xx semantics (e.g. an OAuth-only `insufficient_scope` 403) are
28 * thrown as their own typed exceptions so the sender can route them past the fallback path.
29 *
30 * @param Request $request The base request, without auth headers.
31 * @param WP_User $user The WP user the request is on behalf of.
32 *
33 * @return Response The parsed response.
34 */
35 public function send( Request $request, WP_User $user ): Response;
36 }
37