web-base/Core/Objects/TwoFactor/AttestationObject.class.php

38 lines
903 B
PHP
Raw Permalink Normal View History

2022-02-20 16:53:26 +01:00
<?php
2022-11-18 18:06:46 +01:00
namespace Core\Objects\TwoFactor;
2022-02-20 16:53:26 +01:00
2024-04-07 18:29:33 +02:00
use CBOR\MapObject;
2022-11-18 18:06:46 +01:00
use Core\Objects\ApiObject;
2022-02-20 16:53:26 +01:00
class AttestationObject extends ApiObject {
2023-01-16 21:47:23 +01:00
use CBORDecoder;
2022-02-20 16:53:26 +01:00
private string $format;
2024-04-07 18:29:33 +02:00
private MapObject $statement;
2022-02-20 16:53:26 +01:00
private AuthenticationData $authData;
public function __construct(string $buffer) {
2024-04-07 18:29:33 +02:00
$data = $this->decode($buffer);
2022-02-20 16:53:26 +01:00
$this->format = $data["fmt"];
$this->statement = $data["attStmt"];
2024-04-07 18:29:33 +02:00
$this->authData = new AuthenticationData($data["authData"]->getValue());
2022-02-20 16:53:26 +01:00
}
public function jsonSerialize(): array {
return [
"format" => $this->format,
"statement" => [
"sig" => base64_encode($this->statement["sig"] ?? ""),
"x5c" => base64_encode(($this->statement["x5c"] ?? [""])[0]),
],
"authData" => $this->authData->jsonSerialize()
];
}
public function getAuthData(): AuthenticationData {
return $this->authData;
}
}