friendship ended with social-app. php is my new best friend
1<?php 2/** 3 * Interface PKCE 4 * 5 * @created 06.04.2024 6 * @author smiley <smiley@chillerlan.net> 7 * @copyright 2024 smiley 8 * @license MIT 9 */ 10declare(strict_types=1); 11 12namespace chillerlan\OAuth\Core; 13 14/** 15 * Specifies the methods required for the OAuth2 Proof Key for Code Exchange (PKCE) 16 * 17 * @link https://datatracker.ietf.org/doc/html/rfc7636 18 * @link https://github.com/AdrienGras/pkce-php 19 */ 20interface PKCE{ 21 22 /** @var string */ 23 public const CHALLENGE_METHOD_PLAIN = 'plain'; 24 /** @var string */ 25 public const CHALLENGE_METHOD_S256 = 'S256'; 26 27 /** @var string */ 28 public const VERIFIER_CHARSET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~'; 29 30 /** 31 * generates a secure random "code_verifier" 32 * 33 * @link https://datatracker.ietf.org/doc/html/rfc7636#section-4.1 34 */ 35 public function generateVerifier(int $length):string; 36 37 /** 38 * generates a "code_challenge" for the given $codeVerifier 39 * 40 * @link https://datatracker.ietf.org/doc/html/rfc7636#section-4.2 41 */ 42 public function generateChallenge(string $verifier, string $challengeMethod):string; 43 44 /** 45 * Sets the PKCE code challenge parameters in a given array of query parameters and stores 46 * the verifier in the storage for later verification. Returns the updated array of parameters. 47 * 48 * @link https://datatracker.ietf.org/doc/html/rfc7636#section-4.3 49 * 50 * @param array<string, string> $params 51 * @return array<string, string> 52 * @throws \chillerlan\OAuth\Providers\ProviderException 53 */ 54 public function setCodeChallenge(array $params, string $challengeMethod):array; 55 56 /** 57 * Sets the PKCE verifier parameter in a given array of query parameters 58 * and deletes it from the storage afterwards. Returns the updated array of parameters. 59 * 60 * @link https://datatracker.ietf.org/doc/html/rfc7636#section-4.5 61 * 62 * @param array<string, string> $params 63 * @return array<string, string> 64 * @throws \chillerlan\OAuth\Providers\ProviderException 65 */ 66 public function setCodeVerifier(array $params):array; 67 68}