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-authorization / application / token-manager-interface.php

token-manager-interface.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 28.3, at src/ai-authorization/application/token-manager-interface.php

114 lines 4.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yoast\WP\SEO\AI_Authorization\Application;
4
5 use RuntimeException;
6 use WP_User;
7 use Yoast\WP\SEO\AI_HTTP_Request\Domain\Exceptions\Bad_Request_Exception;
8 use Yoast\WP\SEO\AI_HTTP_Request\Domain\Exceptions\Forbidden_Exception;
9 use Yoast\WP\SEO\AI_HTTP_Request\Domain\Exceptions\Internal_Server_Error_Exception;
10 use Yoast\WP\SEO\AI_HTTP_Request\Domain\Exceptions\Not_Found_Exception;
11 use Yoast\WP\SEO\AI_HTTP_Request\Domain\Exceptions\Payment_Required_Exception;
12 use Yoast\WP\SEO\AI_HTTP_Request\Domain\Exceptions\Request_Timeout_Exception;
13 use Yoast\WP\SEO\AI_HTTP_Request\Domain\Exceptions\Service_Unavailable_Exception;
14 use Yoast\WP\SEO\AI_HTTP_Request\Domain\Exceptions\Too_Many_Requests_Exception;
15 use Yoast\WP\SEO\AI_HTTP_Request\Domain\Exceptions\Unauthorized_Exception;
16
17 /**
18 * Interface Token_Manager_Interface
19 */
20 interface Token_Manager_Interface {
21
22 /**
23 * Invalidates the access token.
24 *
25 * @param int $user_id The user ID.
26 *
27 * @return void
28 *
29 * @throws Bad_Request_Exception Bad_Request_Exception.
30 * @throws Internal_Server_Error_Exception Internal_Server_Error_Exception.
31 * @throws Not_Found_Exception Not_Found_Exception.
32 * @throws Payment_Required_Exception Payment_Required_Exception.
33 * @throws Request_Timeout_Exception Request_Timeout_Exception.
34 * @throws Service_Unavailable_Exception Service_Unavailable_Exception.
35 * @throws Too_Many_Requests_Exception Too_Many_Requests_Exception.
36 * @throws RuntimeException Unable to retrieve the access token.
37 */
38 public function token_invalidate( int $user_id ): void;
39
40 /**
41 * Requests a new set of JWT tokens.
42 *
43 * Requests a new JWT access and refresh token for a user from the Yoast AI Service and stores it in the database
44 * under usermeta. The storing of the token happens in a HTTP callback that is triggered by this request.
45 *
46 * @param WP_User $user The WP user.
47 *
48 * @return void
49 *
50 * @throws Bad_Request_Exception Bad_Request_Exception.
51 * @throws Forbidden_Exception Forbidden_Exception.
52 * @throws Internal_Server_Error_Exception Internal_Server_Error_Exception.
53 * @throws Not_Found_Exception Not_Found_Exception.
54 * @throws Payment_Required_Exception Payment_Required_Exception.
55 * @throws Request_Timeout_Exception Request_Timeout_Exception.
56 * @throws Service_Unavailable_Exception Service_Unavailable_Exception.
57 * @throws Too_Many_Requests_Exception Too_Many_Requests_Exception.
58 * @throws Unauthorized_Exception Unauthorized_Exception.
59 */
60 public function token_request( WP_User $user ): void;
61
62 /**
63 * Refreshes the JWT access token.
64 *
65 * Refreshes a stored JWT access token for a user with the Yoast AI Service and stores it in the database under
66 * usermeta. The storing of the token happens in a HTTP callback that is triggered by this request.
67 *
68 * @param WP_User $user The WP user.
69 *
70 * @return void
71 *
72 * @throws Bad_Request_Exception Bad_Request_Exception.
73 * @throws Forbidden_Exception Forbidden_Exception.
74 * @throws Internal_Server_Error_Exception Internal_Server_Error_Exception.
75 * @throws Not_Found_Exception Not_Found_Exception.
76 * @throws Payment_Required_Exception Payment_Required_Exception.
77 * @throws Request_Timeout_Exception Request_Timeout_Exception.
78 * @throws Service_Unavailable_Exception Service_Unavailable_Exception.
79 * @throws Too_Many_Requests_Exception Too_Many_Requests_Exception.
80 * @throws Unauthorized_Exception Unauthorized_Exception.
81 * @throws RuntimeException Unable to retrieve the refresh token.
82 */
83 public function token_refresh( WP_User $user ): void;
84
85 /**
86 * Checks whether the token has expired.
87 *
88 * @param string $jwt The JWT.
89 *
90 * @return bool Whether the token has expired.
91 */
92 public function has_token_expired( string $jwt ): bool;
93
94 /**
95 * Retrieves the access token.
96 *
97 * @param WP_User $user The WP user.
98 *
99 * @return string The access token.
100 *
101 * @throws Bad_Request_Exception Bad_Request_Exception.
102 * @throws Forbidden_Exception Forbidden_Exception.
103 * @throws Internal_Server_Error_Exception Internal_Server_Error_Exception.
104 * @throws Not_Found_Exception Not_Found_Exception.
105 * @throws Payment_Required_Exception Payment_Required_Exception.
106 * @throws Request_Timeout_Exception Request_Timeout_Exception.
107 * @throws Service_Unavailable_Exception Service_Unavailable_Exception.
108 * @throws Too_Many_Requests_Exception Too_Many_Requests_Exception.
109 * @throws Unauthorized_Exception Unauthorized_Exception.
110 * @throws RuntimeException Unable to retrieve the access or refresh token.
111 */
112 public function get_or_request_access_token( WP_User $user ): string;
113 }
114