@@ -332,9 +332,9 @@ discard block |
||
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
335 | - * Return the binary string |
|
336 | - * @return string |
|
337 | - */ |
|
335 | + * Return the binary string |
|
336 | + * @return string |
|
337 | + */ |
|
338 | 338 | public function getBinaryString(): string |
339 | 339 | { |
340 | 340 | return $this->data; |
@@ -361,9 +361,9 @@ discard block |
||
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
364 | - * {@inheritdoc} |
|
365 | - * @return mixed |
|
366 | - */ |
|
364 | + * {@inheritdoc} |
|
365 | + * @return mixed |
|
366 | + */ |
|
367 | 367 | public function jsonSerialize() |
368 | 368 | { |
369 | 369 | if ($this->useBase64UrlEncoding) { |
@@ -377,18 +377,18 @@ discard block |
||
377 | 377 | } |
378 | 378 | |
379 | 379 | /** |
380 | - * {@inheritdoc} |
|
381 | - * @return string|null |
|
382 | - */ |
|
380 | + * {@inheritdoc} |
|
381 | + * @return string|null |
|
382 | + */ |
|
383 | 383 | public function serialize(): ?string |
384 | 384 | { |
385 | 385 | return serialize($this->data); |
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
389 | - * {@inheritdoc} |
|
390 | - * $param string $data |
|
391 | - */ |
|
389 | + * {@inheritdoc} |
|
390 | + * $param string $data |
|
391 | + */ |
|
392 | 392 | public function unserialize($data): void |
393 | 393 | { |
394 | 394 | $value = unserialize($data); |
@@ -40,7 +40,7 @@ |
||
40 | 40 | */ |
41 | 41 | public function __construct(string $binaryData) |
42 | 42 | { |
43 | - $this->data = (string)$binaryData; |
|
43 | + $this->data = (string) $binaryData; |
|
44 | 44 | $this->length = strlen($binaryData); |
45 | 45 | } |
46 | 46 |
@@ -38,8 +38,7 @@ discard block |
||
38 | 38 | * Create new instance |
39 | 39 | * @param string $binaryData |
40 | 40 | */ |
41 | - public function __construct(string $binaryData) |
|
42 | - { |
|
41 | + public function __construct(string $binaryData) { |
|
43 | 42 | $this->data = (string)$binaryData; |
44 | 43 | $this->length = strlen($binaryData); |
45 | 44 | } |
@@ -311,8 +310,7 @@ discard block |
||
311 | 310 | * @param int $options |
312 | 311 | * @return array<mixed>|object |
313 | 312 | */ |
314 | - public function getJson(int $options = 0) |
|
315 | - { |
|
313 | + public function getJson(int $options = 0) { |
|
316 | 314 | try { |
317 | 315 | $data = Json::decode($this->getBinaryString(), false, 512, $options); |
318 | 316 | } catch (Exception $ex) { |
@@ -364,8 +362,7 @@ discard block |
||
364 | 362 | * {@inheritdoc} |
365 | 363 | * @return mixed |
366 | 364 | */ |
367 | - public function jsonSerialize() |
|
368 | - { |
|
365 | + public function jsonSerialize() { |
|
369 | 366 | if ($this->useBase64UrlEncoding) { |
370 | 367 | return self::base64UrlEncode($this->data); |
371 | 368 | } |
@@ -413,8 +410,7 @@ discard block |
||
413 | 410 | * @param array<string, mixed> $data |
414 | 411 | * @return void |
415 | 412 | */ |
416 | - public function __unserialize(array $data) |
|
417 | - { |
|
413 | + public function __unserialize(array $data) { |
|
418 | 414 | if (isset($data['data'])) { |
419 | 415 | $value = unserialize($data['data']); |
420 | 416 | if ($value === false) { |
@@ -149,15 +149,15 @@ discard block |
||
149 | 149 | ); |
150 | 150 | |
151 | 151 | $publicKey = (new PublicKey()) |
152 | - ->setUserInfo($userInfo) |
|
153 | - ->setReplyParty($replyParty) |
|
154 | - ->setAuthenticatorSelection($authenticatorSelection) |
|
155 | - ->setExcludeCredentials($excludeCredentials) |
|
156 | - ->setChallenge($this->createChallenge()) |
|
157 | - ->setTimeout($this->config->get('timeout')) |
|
158 | - ->setExtensions() |
|
159 | - ->addPublicKeys() |
|
160 | - ->setAttestation($attestation); |
|
152 | + ->setUserInfo($userInfo) |
|
153 | + ->setReplyParty($replyParty) |
|
154 | + ->setAuthenticatorSelection($authenticatorSelection) |
|
155 | + ->setExcludeCredentials($excludeCredentials) |
|
156 | + ->setChallenge($this->createChallenge()) |
|
157 | + ->setTimeout($this->config->get('timeout')) |
|
158 | + ->setExtensions() |
|
159 | + ->addPublicKeys() |
|
160 | + ->setAttestation($attestation); |
|
161 | 161 | |
162 | 162 | return $publicKey; |
163 | 163 | } |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | } |
187 | 187 | |
188 | 188 | $publicKey = (new PublicKey()) |
189 | - ->setReplyPartyId($this->replyParty->getId()) |
|
190 | - ->setAllowCredentials($allowedCredentials) |
|
191 | - ->setChallenge($this->createChallenge()) |
|
192 | - ->setTimeout($this->config->get('timeout')) |
|
193 | - ->setUserVerificationType($userVerificationType); |
|
189 | + ->setReplyPartyId($this->replyParty->getId()) |
|
190 | + ->setAllowCredentials($allowedCredentials) |
|
191 | + ->setChallenge($this->createChallenge()) |
|
192 | + ->setTimeout($this->config->get('timeout')) |
|
193 | + ->setUserVerificationType($userVerificationType); |
|
194 | 194 | |
195 | 195 | return $publicKey; |
196 | 196 | } |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function __construct(WebauthnConfiguration $config, array $allowedFormats = []) |
72 | 72 | { |
73 | - if (! function_exists('openssl_open')) { |
|
73 | + if (!function_exists('openssl_open')) { |
|
74 | 74 | throw new WebauthnException('OpenSSL module not installed in this platform'); |
75 | 75 | } |
76 | 76 | |
77 | - if (! in_array('SHA256', array_map('strtoupper', openssl_get_md_methods()))) { |
|
77 | + if (!in_array('SHA256', array_map('strtoupper', openssl_get_md_methods()))) { |
|
78 | 78 | throw new WebauthnException('SHA256 is not supported by this OpenSSL installation'); |
79 | 79 | } |
80 | 80 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | ): array { |
216 | 216 | $clientDataHash = hash('sha256', $clientDataJson, true); |
217 | 217 | if (is_string($challenge)) { |
218 | - $challenge = new ByteBuffer($challenge); |
|
218 | + $challenge = new ByteBuffer($challenge); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | // security: https://www.w3.org/TR/webauthn/#registering-a-new-credential |
@@ -228,21 +228,21 @@ discard block |
||
228 | 228 | } |
229 | 229 | |
230 | 230 | // 3. Verify that the value of C.type is webauthn.create. |
231 | - if (! isset($clientData->type) || $clientData->type !== 'webauthn.create') { |
|
231 | + if (!isset($clientData->type) || $clientData->type !== 'webauthn.create') { |
|
232 | 232 | throw new WebauthnException('Invalid client type provided'); |
233 | 233 | } |
234 | 234 | |
235 | 235 | // 4. Verify that the value of C.challenge matches the challenge that was |
236 | 236 | // sent to the authenticator in the create() call. |
237 | 237 | if ( |
238 | - ! isset($clientData->challenge) || |
|
238 | + !isset($clientData->challenge) || |
|
239 | 239 | ByteBuffer::fromBase64Url($clientData->challenge)->getBinaryString() !== $challenge->getBinaryString() |
240 | 240 | ) { |
241 | 241 | throw new WebauthnException('Invalid challenge provided'); |
242 | 242 | } |
243 | 243 | |
244 | 244 | // 5. Verify that the value of C.origin matches the Replying Party's origin. |
245 | - if (! isset($clientData->origin) || $this->checkOrigin($clientData->origin) === false) { |
|
245 | + if (!isset($clientData->origin) || $this->checkOrigin($clientData->origin) === false) { |
|
246 | 246 | throw new WebauthnException('Invalid origin provided'); |
247 | 247 | } |
248 | 248 | |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | bool $requireUserPresent = true |
332 | 332 | ): bool { |
333 | 333 | if (is_string($challenge)) { |
334 | - $challenge = new ByteBuffer($challenge); |
|
334 | + $challenge = new ByteBuffer($challenge); |
|
335 | 335 | } |
336 | 336 | $clientDataHash = hash('sha256', $clientDataJson, true); |
337 | 337 | $authenticator = new AuthenticatorData($authenticatorData); |
@@ -359,21 +359,21 @@ discard block |
||
359 | 359 | // -> TO BE LOOKED UP BY IMPLEMENTATION |
360 | 360 | |
361 | 361 | // 7. Verify that the value of C.type is the string webauthn.get. |
362 | - if (! isset($clientData->type) || $clientData->type !== 'webauthn.get') { |
|
362 | + if (!isset($clientData->type) || $clientData->type !== 'webauthn.get') { |
|
363 | 363 | throw new WebauthnException('Invalid client type provided'); |
364 | 364 | } |
365 | 365 | |
366 | 366 | // 8. Verify that the value of C.challenge matches the challenge that was sent to the |
367 | 367 | // authenticator in the PublicKeyCredentialRequestOptions passed to the get() call. |
368 | 368 | if ( |
369 | - ! isset($clientData->challenge) || |
|
369 | + !isset($clientData->challenge) || |
|
370 | 370 | ByteBuffer::fromBase64Url($clientData->challenge)->getBinaryString() !== $challenge->getBinaryString() |
371 | 371 | ) { |
372 | 372 | throw new WebauthnException('Invalid challenge provided'); |
373 | 373 | } |
374 | 374 | |
375 | 375 | // 9. Verify that the value of C.origin matches the Replying Party's origin. |
376 | - if (! isset($clientData->origin) || $this->checkOrigin($clientData->origin) === false) { |
|
376 | + if (!isset($clientData->origin) || $this->checkOrigin($clientData->origin) === false) { |
|
377 | 377 | throw new WebauthnException('Invalid origin provided'); |
378 | 378 | } |
379 | 379 | |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | // The origin's scheme must be https and not be ignored/whitelisted |
463 | 463 | $url = new Uri($origin); |
464 | 464 | if ( |
465 | - ! in_array($this->replyParty->getId(), $this->config->get('ignore_origins')) && |
|
465 | + !in_array($this->replyParty->getId(), $this->config->get('ignore_origins')) && |
|
466 | 466 | $url->getScheme() !== 'https' |
467 | 467 | ) { |
468 | 468 | return false; |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | return array_values($supportedFormats); |
500 | 500 | } |
501 | 501 | |
502 | - $desiredFormats = array_filter($formats, function ($entry) use ($supportedFormats) { |
|
502 | + $desiredFormats = array_filter($formats, function($entry) use ($supportedFormats) { |
|
503 | 503 | return in_array($entry, $supportedFormats); |
504 | 504 | }); |
505 | 505 |
@@ -25,8 +25,7 @@ discard block |
||
25 | 25 | * @class Webauthn |
26 | 26 | * @package Platine\Webauthn |
27 | 27 | */ |
28 | -class Webauthn |
|
29 | -{ |
|
28 | +class Webauthn { |
|
30 | 29 | /** |
31 | 30 | * The attestation data formats |
32 | 31 | * @var array<string> |
@@ -68,8 +67,7 @@ discard block |
||
68 | 67 | * @param WebauthnConfiguration $config |
69 | 68 | * @param array<string> $allowedFormats |
70 | 69 | */ |
71 | - public function __construct(WebauthnConfiguration $config, array $allowedFormats = []) |
|
72 | - { |
|
70 | + public function __construct(WebauthnConfiguration $config, array $allowedFormats = []) { |
|
73 | 71 | if (! function_exists('openssl_open')) { |
74 | 72 | throw new WebauthnException('OpenSSL module not installed in this platform'); |
75 | 73 | } |
@@ -8,8 +8,7 @@ |
||
8 | 8 | * @class KeyFormat |
9 | 9 | * @package Platine\Webauthn\Enum |
10 | 10 | */ |
11 | -class KeyFormat extends BaseEnum |
|
12 | -{ |
|
11 | +class KeyFormat extends BaseEnum { |
|
13 | 12 | public const ANDROID_KEY = 'android-key'; |
14 | 13 | public const ANDROID_SAFETYNET = 'android-safetynet'; |
15 | 14 | public const APPLE = 'apple'; |
@@ -8,8 +8,7 @@ |
||
8 | 8 | * @class UserVerificationType |
9 | 9 | * @package Platine\Webauthn\Enum |
10 | 10 | */ |
11 | -class UserVerificationType extends BaseEnum |
|
12 | -{ |
|
11 | +class UserVerificationType extends BaseEnum { |
|
13 | 12 | public const REQUIRED = 'required'; |
14 | 13 | public const PREFERRED = 'preferred'; |
15 | 14 | public const DISCOURAGED = 'discouraged'; |
@@ -8,8 +8,7 @@ |
||
8 | 8 | * @class AttestationType |
9 | 9 | * @package Platine\Webauthn\Enum |
10 | 10 | */ |
11 | -class AttestationType extends BaseEnum |
|
12 | -{ |
|
11 | +class AttestationType extends BaseEnum { |
|
13 | 12 | public const NONE = 'none'; |
14 | 13 | public const DIRECT = 'direct'; |
15 | 14 | public const INDIRECT = 'indirect'; |
@@ -8,8 +8,7 @@ |
||
8 | 8 | * @class TransportType |
9 | 9 | * @package Platine\Webauthn\Enum |
10 | 10 | */ |
11 | -class TransportType extends BaseEnum |
|
12 | -{ |
|
11 | +class TransportType extends BaseEnum { |
|
13 | 12 | public const NFC = 'nfc'; |
14 | 13 | public const BLE = 'ble'; |
15 | 14 | public const USB = 'usb'; |
@@ -10,8 +10,7 @@ |
||
10 | 10 | * @class BaseEnum |
11 | 11 | * @package Platine\Webauthn\Enum |
12 | 12 | */ |
13 | -class BaseEnum |
|
14 | -{ |
|
13 | +class BaseEnum { |
|
15 | 14 | /** |
16 | 15 | * Return this class all the enumerations |
17 | 16 | * @return array<string, string> |