PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / lib / packages / Webauthn / PublicKeyCredentialOptions.php

PublicKeyCredentialOptions.php in Defender Security – Malware Scanner, Login Security & Firewall 6.3.0, at lib/packages/Webauthn/PublicKeyCredentialOptions.php

105 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 /*
6 * The MIT License (MIT)
7 *
8 * Copyright (c) 2014-2021 Spomky-Labs
9 *
10 * This software may be modified and distributed under the terms
11 * of the MIT license. See the LICENSE file for details.
12 */
13
14 namespace WP_DEFENDER_VENDOR\Webauthn;
15
16 use JsonSerializable;
17 use WP_DEFENDER_VENDOR\Webauthn\AuthenticationExtensions\AuthenticationExtension;
18 use WP_DEFENDER_VENDOR\Webauthn\AuthenticationExtensions\AuthenticationExtensionsClientInputs;
19
20 abstract class PublicKeyCredentialOptions implements JsonSerializable
21 {
22 /**
23 * @var string
24 */
25 protected $challenge;
26
27 /**
28 * @var int|null
29 */
30 protected $timeout;
31
32 /**
33 * @var AuthenticationExtensionsClientInputs
34 */
35 protected $extensions;
36
37 public function __construct(string $challenge, ?int $timeout = null, ?AuthenticationExtensionsClientInputs $extensions = null)
38 {
39 if (null !== $timeout) {
40 @trigger_error('The argument "timeout" is deprecated since version 3.3 and will be removed in 4.0. Please use the method "setTimeout".', E_USER_DEPRECATED);
41 }
42 if (null !== $extensions) {
43 @trigger_error('The argument "extensions" is deprecated since version 3.3 and will be removed in 4.0. Please use the method "addExtension" or "addExtensions".', E_USER_DEPRECATED);
44 }
45 $this->challenge = $challenge;
46 $this->setTimeout($timeout);
47 $this->extensions = $extensions ?? new AuthenticationExtensionsClientInputs();
48 }
49
50 public function setTimeout(?int $timeout): self
51 {
52 $this->timeout = $timeout;
53
54 return $this;
55 }
56
57 public function addExtension(AuthenticationExtension $extension): self
58 {
59 $this->extensions->add($extension);
60
61 return $this;
62 }
63
64 /**
65 * @param AuthenticationExtension[] $extensions
66 */
67 public function addExtensions(array $extensions): self
68 {
69 foreach ($extensions as $extension) {
70 $this->addExtension($extension);
71 }
72
73 return $this;
74 }
75
76 public function setExtensions(AuthenticationExtensionsClientInputs $extensions): self
77 {
78 $this->extensions = $extensions;
79
80 return $this;
81 }
82
83 public function getChallenge(): string
84 {
85 return $this->challenge;
86 }
87
88 public function getTimeout(): ?int
89 {
90 return $this->timeout;
91 }
92
93 public function getExtensions(): AuthenticationExtensionsClientInputs
94 {
95 return $this->extensions;
96 }
97
98 abstract public static function createFromString(string $data): self;
99
100 /**
101 * @param mixed[] $json
102 */
103 abstract public static function createFromArray(array $json): self;
104 }
105