Laravel AT Protocol Client (alpha & unstable)
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

Store pdsEndpoint in AuthorizationRequest instead of extracting from request URI

+4 -14
+3 -14
src/Auth/OAuthEngine.php
··· 65 65 codeVerifier: $codeVerifier, 66 66 dpopKey: $dpopKey, 67 67 requestUri: $parResponse['request_uri'], 68 + pdsEndpoint: $pdsEndpoint, 68 69 ); 69 70 } 70 71 ··· 80 81 throw new AuthenticationException('State mismatch'); 81 82 } 82 83 83 - // Get PDS endpoint from request 84 - $pdsEndpoint = $this->extractPdsFromRequestUri($request->requestUri); 85 - $tokenUrl = $pdsEndpoint.'/oauth/token'; 84 + $tokenUrl = $request->pdsEndpoint.'/oauth/token'; 86 85 87 - $response = $this->dpopClient->request($pdsEndpoint, $tokenUrl, 'POST', $request->dpopKey) 86 + $response = $this->dpopClient->request($request->pdsEndpoint, $tokenUrl, 'POST', $request->dpopKey) 88 87 ->asForm() 89 88 ->post($tokenUrl, [ 90 89 'grant_type' => 'authorization_code', ··· 138 137 protected function generatePkceChallenge(string $verifier): string 139 138 { 140 139 return rtrim(strtr(base64_encode(hash('sha256', $verifier, true)), '+/', '-_'), '='); 141 - } 142 - 143 - /** 144 - * Extract PDS endpoint from request URI 145 - */ 146 - protected function extractPdsFromRequestUri(string $requestUri): string 147 - { 148 - $parts = parse_url($requestUri); 149 - 150 - return ($parts['scheme'] ?? 'https').'://'.($parts['host'] ?? ''); 151 140 } 152 141 }
+1
src/Data/AuthorizationRequest.php
··· 10 10 public readonly string $codeVerifier, 11 11 public readonly DPoPKey $dpopKey, 12 12 public readonly string $requestUri, 13 + public readonly string $pdsEndpoint, 13 14 ) {} 14 15 }