@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | $verifyTokenSignature = |
| 182 | 182 | $this->config->exists('verifyTokenSignature') ? $this->config->get('verifyTokenSignature') : true; |
| 183 | 183 | |
| 184 | - if (!$verifyTokenSignature) { |
|
| 184 | + if ( ! $verifyTokenSignature) { |
|
| 185 | 185 | // payload extraction by https://github.com/omidborjian |
| 186 | 186 | // https://github.com/hybridauth/hybridauth/issues/1095#issuecomment-626479263 |
| 187 | 187 | // JWT splits the string to 3 components 1) first is header 2) is payload 3) is signature |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | foreach ($publicKeys->keys as $publicKey) { |
| 200 | 200 | try { |
| 201 | - $jwk = (array)$publicKey; |
|
| 201 | + $jwk = (array) $publicKey; |
|
| 202 | 202 | |
| 203 | 203 | $key = PublicKeyLoader::load( |
| 204 | 204 | [ |
@@ -209,11 +209,10 @@ discard block |
||
| 209 | 209 | ->withHash('sha1') |
| 210 | 210 | ->withMGFHash('sha1'); |
| 211 | 211 | |
| 212 | - $pem = (string)$key; |
|
| 212 | + $pem = (string) $key; |
|
| 213 | 213 | |
| 214 | 214 | $payload = (version_compare($this->getJwtVersion(), '6.2') < 0) ? |
| 215 | - JWT::decode($id_token, $pem, ['RS256']) : |
|
| 216 | - JWT::decode($id_token, new Key($pem, 'RS256')); |
|
| 215 | + JWT::decode($id_token, $pem, ['RS256']) : JWT::decode($id_token, new Key($pem, 'RS256')); |
|
| 217 | 216 | break; |
| 218 | 217 | } catch (Exception $e) { |
| 219 | 218 | $error = $e->getMessage(); |
@@ -223,14 +222,14 @@ discard block |
||
| 223 | 222 | } |
| 224 | 223 | } |
| 225 | 224 | |
| 226 | - if ($error && !$payload) { |
|
| 225 | + if ($error && ! $payload) { |
|
| 227 | 226 | throw new Exception($error); |
| 228 | 227 | } |
| 229 | 228 | } |
| 230 | 229 | |
| 231 | 230 | $data = new Data\Collection($payload); |
| 232 | 231 | |
| 233 | - if (!$data->exists('sub')) { |
|
| 232 | + if ( ! $data->exists('sub')) { |
|
| 234 | 233 | throw new UnexpectedValueException('Missing token payload.'); |
| 235 | 234 | } |
| 236 | 235 | |
@@ -239,12 +238,12 @@ discard block |
||
| 239 | 238 | $userProfile->email = $data->get('email'); |
| 240 | 239 | $this->storeData('expires_at', $data->get('exp')); |
| 241 | 240 | |
| 242 | - if (!empty($_REQUEST['user'])) { |
|
| 241 | + if ( ! empty($_REQUEST['user'])) { |
|
| 243 | 242 | $objUser = json_decode($_REQUEST['user']); |
| 244 | 243 | $user = new Data\Collection($objUser); |
| 245 | - if (!$user->isEmpty()) { |
|
| 244 | + if ( ! $user->isEmpty()) { |
|
| 246 | 245 | $name = $user->get('name'); |
| 247 | - if (!empty($name->firstName)) { |
|
| 246 | + if ( ! empty($name->firstName)) { |
|
| 248 | 247 | $userProfile->firstName = $name->firstName; |
| 249 | 248 | $userProfile->lastName = $name->lastName; |
| 250 | 249 | $userProfile->displayName = join(' ', [$userProfile->firstName, $userProfile->lastName]); |
@@ -266,7 +265,7 @@ discard block |
||
| 266 | 265 | // Your 10-character Team ID |
| 267 | 266 | $team_id = $this->config->filter('keys')->get('team_id'); |
| 268 | 267 | |
| 269 | - if (!$team_id) { |
|
| 268 | + if ( ! $team_id) { |
|
| 270 | 269 | throw new InvalidApplicationCredentialsException( |
| 271 | 270 | 'Missing parameter team_id: your team id is required to generate the JWS token.' |
| 272 | 271 | ); |
@@ -275,7 +274,7 @@ discard block |
||
| 275 | 274 | // Your Services ID, e.g. com.aaronparecki.services |
| 276 | 275 | $client_id = $this->config->filter('keys')->get('id') ?: $this->config->filter('keys')->get('key'); |
| 277 | 276 | |
| 278 | - if (!$client_id) { |
|
| 277 | + if ( ! $client_id) { |
|
| 279 | 278 | throw new InvalidApplicationCredentialsException( |
| 280 | 279 | 'Missing parameter id: your client id is required to generate the JWS token.' |
| 281 | 280 | ); |
@@ -284,7 +283,7 @@ discard block |
||
| 284 | 283 | // Find the 10-char Key ID value from the portal |
| 285 | 284 | $key_id = $this->config->filter('keys')->get('key_id'); |
| 286 | 285 | |
| 287 | - if (!$key_id) { |
|
| 286 | + if ( ! $key_id) { |
|
| 288 | 287 | throw new InvalidApplicationCredentialsException( |
| 289 | 288 | 'Missing parameter key_id: your key id is required to generate the JWS token.' |
| 290 | 289 | ); |
@@ -294,16 +293,16 @@ discard block |
||
| 294 | 293 | $key_content = $this->config->filter('keys')->get('key_content'); |
| 295 | 294 | |
| 296 | 295 | // Save your private key from Apple in a file called `key.txt` |
| 297 | - if (!$key_content) { |
|
| 296 | + if ( ! $key_content) { |
|
| 298 | 297 | $key_file = $this->config->filter('keys')->get('key_file'); |
| 299 | 298 | |
| 300 | - if (!$key_file) { |
|
| 299 | + if ( ! $key_file) { |
|
| 301 | 300 | throw new InvalidApplicationCredentialsException( |
| 302 | 301 | 'Missing parameter key_content or key_file: your key is required to generate the JWS token.' |
| 303 | 302 | ); |
| 304 | 303 | } |
| 305 | 304 | |
| 306 | - if (!file_exists($key_file)) { |
|
| 305 | + if ( ! file_exists($key_file)) { |
|
| 307 | 306 | throw new InvalidApplicationCredentialsException( |
| 308 | 307 | "Your key file $key_file does not exist." |
| 309 | 308 | ); |
@@ -335,7 +334,6 @@ discard block |
||
| 335 | 334 | { |
| 336 | 335 | // assume old JWT version if no version check is possible because composer 1 is installed |
| 337 | 336 | return class_exists('Composer\InstalledVersions') ? |
| 338 | - InstalledVersions::getVersion('firebase/php-jwt') : |
|
| 339 | - ''; |
|
| 337 | + InstalledVersions::getVersion('firebase/php-jwt') : ''; |
|
| 340 | 338 | } |
| 341 | 339 | } |