| 1 |
<?php |
| 2 |
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure. |
| 3 |
|
| 4 |
namespace Yoast\WP\SEO\MyYoast_Client\Application\Ports; |
| 5 |
|
| 6 |
use Yoast\WP\SEO\MyYoast_Client\Application\Exceptions\Registration_Failed_Exception; |
| 7 |
use Yoast\WP\SEO\MyYoast_Client\Domain\Registered_Client; |
| 8 |
|
| 9 |
/** |
| 10 |
* Port for the full OAuth client registration lifecycle. |
| 11 |
*/ |
| 12 |
interface Client_Registration_Interface { |
| 13 |
|
| 14 |
/** |
| 15 |
* Ensures the plugin is registered, performing DCR if needed. |
| 16 |
* |
| 17 |
* @param string[] $redirect_uris The OAuth redirect URIs to register with. |
| 18 |
* |
| 19 |
* @return Registered_Client The client credentials. |
| 20 |
* |
| 21 |
* @throws Registration_Failed_Exception If registration fails. |
| 22 |
*/ |
| 23 |
public function ensure_registered( array $redirect_uris = [] ): Registered_Client; |
| 24 |
|
| 25 |
/** |
| 26 |
* Returns the stored registered client, or null if not registered. |
| 27 |
* |
| 28 |
* @return Registered_Client|null |
| 29 |
*/ |
| 30 |
public function get_registered_client(): ?Registered_Client; |
| 31 |
|
| 32 |
/** |
| 33 |
* Whether the plugin is registered as an OAuth client. |
| 34 |
* |
| 35 |
* When redirect URIs are provided, also verifies that all of them |
| 36 |
* are included in the stored registration. |
| 37 |
* |
| 38 |
* @param string[] $redirect_uris Optional redirect URIs to verify against the stored registration. |
| 39 |
* |
| 40 |
* @return bool |
| 41 |
*/ |
| 42 |
public function is_registered( array $redirect_uris = [] ): bool; |
| 43 |
|
| 44 |
/** |
| 45 |
* Reads the current client registration from the server. |
| 46 |
* |
| 47 |
* @return array<string, string|string[]> The registration metadata. |
| 48 |
* |
| 49 |
* @throws Registration_Failed_Exception If the read fails. |
| 50 |
*/ |
| 51 |
public function read_registration(): array; |
| 52 |
|
| 53 |
/** |
| 54 |
* Rotates the registration key pair. |
| 55 |
* |
| 56 |
* @return Registered_Client The updated credentials. |
| 57 |
* |
| 58 |
* @throws Registration_Failed_Exception If the rotation fails. |
| 59 |
*/ |
| 60 |
public function rotate_registration_keys(): Registered_Client; |
| 61 |
|
| 62 |
/** |
| 63 |
* Deletes the client registration from the server and clears local data. |
| 64 |
* |
| 65 |
* @return bool True if deleted or already not registered, false on network failure. |
| 66 |
*/ |
| 67 |
public function deregister(): bool; |
| 68 |
|
| 69 |
/** |
| 70 |
* Deletes all local registration data (credentials, key pairs, caches). |
| 71 |
* |
| 72 |
* @return void |
| 73 |
*/ |
| 74 |
public function delete_local_data(): void; |
| 75 |
|
| 76 |
/** |
| 77 |
* Rotates the DPoP key pair (local only, no server coordination). |
| 78 |
* |
| 79 |
* @return void |
| 80 |
*/ |
| 81 |
public function rotate_dpop_keys(): void; |
| 82 |
} |
| 83 |
|