Skip to content

Commit 410e910

Browse files
committed
transport Hybrid
transport hybrid added. Attention: Argument shift of getGetArgs() !
1 parent deb37c7 commit 410e910

File tree

3 files changed

+32
-13
lines changed

3 files changed

+32
-13
lines changed

_test/client.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
// create object
4141
const authenticatorAttestationResponse = {
42+
transports: cred.response.getTransports ? cred.response.getTransports() : null,
4243
clientDataJSON: cred.response.clientDataJSON ? arrayBufferToBase64(cred.response.clientDataJSON) : null,
4344
attestationObject: cred.response.attestationObject ? arrayBufferToBase64(cred.response.attestationObject) : null
4445
};

src/Attestation/AttestationObject.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ public function getAttestationFormatName() {
5858
return $this->_attestationFormatName;
5959
}
6060

61+
/**
62+
* returns the attestation format class
63+
* @return Format\FormatBase
64+
*/
65+
public function getAttestationFormat() {
66+
return $this->_attestationFormat;
67+
}
68+
6169
/**
6270
* returns the attestation public key in PEM format
6371
* @return AuthenticatorData

src/WebAuthn.php

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,6 @@ public function getChallenge() {
124124
*/
125125
public function getCreateArgs($userId, $userName, $userDisplayName, $timeout=20, $requireResidentKey=false, $requireUserVerification=false, $crossPlatformAttachment=null, $excludeCredentialIds=array()) {
126126

127-
// validate User Verification Requirement
128-
if (\is_bool($requireUserVerification)) {
129-
$requireUserVerification = $requireUserVerification ? 'required' : 'preferred';
130-
} else if (\is_string($requireUserVerification) && \in_array(\strtolower($requireUserVerification), ['required', 'preferred', 'discouraged'])) {
131-
$requireUserVerification = \strtolower($requireUserVerification);
132-
} else {
133-
$requireUserVerification = 'preferred';
134-
}
135-
136127
$args = new \stdClass();
137128
$args->publicKey = new \stdClass();
138129

@@ -142,15 +133,29 @@ public function getCreateArgs($userId, $userName, $userDisplayName, $timeout=20,
142133
$args->publicKey->rp->id = $this->_rpId;
143134

144135
$args->publicKey->authenticatorSelection = new \stdClass();
145-
$args->publicKey->authenticatorSelection->userVerification = $requireUserVerification;
136+
$args->publicKey->authenticatorSelection->userVerification = 'preferred';
137+
138+
// validate User Verification Requirement
139+
if (\is_bool($requireUserVerification)) {
140+
$args->publicKey->authenticatorSelection->userVerification = $requireUserVerification ? 'required' : 'preferred';
141+
142+
} else if (\is_string($requireUserVerification) && \in_array(\strtolower($requireUserVerification), ['required', 'preferred', 'discouraged'])) {
143+
$args->publicKey->authenticatorSelection->userVerification = \strtolower($requireUserVerification);
144+
}
145+
146+
// validate Resident Key Requirement
146147
if (\is_bool($requireResidentKey) && $requireResidentKey) {
147148
$args->publicKey->authenticatorSelection->requireResidentKey = true;
149+
$args->publicKey->authenticatorSelection->residentKey = 'required';
150+
148151
} else if (\is_string($requireResidentKey) && \in_array(\strtolower($requireResidentKey), ['required', 'preferred', 'discouraged'])) {
149152
$requireResidentKey = \strtolower($requireResidentKey);
150153
$args->publicKey->authenticatorSelection->residentKey = $requireResidentKey;
151154
$args->publicKey->authenticatorSelection->requireResidentKey = $requireResidentKey === 'required';
152155
}
153-
if (is_bool($crossPlatformAttachment)) {
156+
157+
// filte authenticators attached with the specified authenticator attachment modality
158+
if (\is_bool($crossPlatformAttachment)) {
154159
$args->publicKey->authenticatorSelection->authenticatorAttachment = $crossPlatformAttachment ? 'cross-platform' : 'platform';
155160
}
156161

@@ -160,6 +165,7 @@ public function getCreateArgs($userId, $userName, $userDisplayName, $timeout=20,
160165
$args->publicKey->user->name = $userName;
161166
$args->publicKey->user->displayName = $userDisplayName;
162167

168+
// supported algorithms
163169
$args->publicKey->pubKeyCredParams = array();
164170
$tmp = new \stdClass();
165171
$tmp->type = 'public-key';
@@ -195,7 +201,7 @@ public function getCreateArgs($userId, $userName, $userDisplayName, $timeout=20,
195201
$tmp = new \stdClass();
196202
$tmp->id = $id instanceof ByteBuffer ? $id : new ByteBuffer($id); // binary
197203
$tmp->type = 'public-key';
198-
$tmp->transports = array('usb', 'ble', 'nfc', 'internal');
204+
$tmp->transports = array('usb', 'nfc', 'ble', 'hybrid', 'internal');
199205
$args->publicKey->excludeCredentials[] = $tmp;
200206
unset ($tmp);
201207
}
@@ -212,6 +218,7 @@ public function getCreateArgs($userId, $userName, $userDisplayName, $timeout=20,
212218
* @param bool $allowUsb allow removable USB
213219
* @param bool $allowNfc allow Near Field Communication (NFC)
214220
* @param bool $allowBle allow Bluetooth
221+
* @param bool $allowHybrid allow a combination of (often separate) data-transport and proximity mechanisms.
215222
* @param bool $allowInternal allow client device-specific transport. These authenticators are not removable from the client device.
216223
* @param bool|string $requireUserVerification indicates that you require user verification and will fail the operation
217224
* if the response does not have the UV flag set.
@@ -221,7 +228,7 @@ public function getCreateArgs($userId, $userName, $userDisplayName, $timeout=20,
221228
* string 'required' 'preferred' 'discouraged'
222229
* @return \stdClass
223230
*/
224-
public function getGetArgs($credentialIds=array(), $timeout=20, $allowUsb=true, $allowNfc=true, $allowBle=true, $allowInternal=true, $requireUserVerification=false) {
231+
public function getGetArgs($credentialIds=array(), $timeout=20, $allowUsb=true, $allowNfc=true, $allowBle=true, $allowHybrid=true, $allowInternal=true, $requireUserVerification=false) {
225232

226233
// validate User Verification Requirement
227234
if (\is_bool($requireUserVerification)) {
@@ -256,6 +263,9 @@ public function getGetArgs($credentialIds=array(), $timeout=20, $allowUsb=true,
256263
if ($allowBle) {
257264
$tmp->transports[] = 'ble';
258265
}
266+
if ($allowHybrid) {
267+
$tmp->transports[] = 'hybrid';
268+
}
259269
if ($allowInternal) {
260270
$tmp->transports[] = 'internal';
261271
}

0 commit comments

Comments
 (0)