CBOREncode
CBOREncode copied to clipboard
Convert CBOR byte string to JSON
Hi. Thanks for the simple to use library. I'm trying to use this to implement webauthn and getting tripped up at the CBOR decoding part. The webauthn method returns a byte array which has to be CBOR decoded to get a json object. Since I have to send this byte array to the php server I convert it into base64 encoding to send it via ajax.
Once I receive it, in PHP I perform a base64_decode and pass it into the CBOR decoder.
$attestationDecoded = base64_decode($publicKeyCredential['response']['attestationObject']);
$attestationObject = \CBOR\CBOREncoder::decode($attestationDecoded);
This gives me an output like this
Array
(
[fmt] => none
[attStmt] => Array
(
)
[authData] => CBOR\Types\CBORByteString Object
(
[byte_string:CBOR\Types\CBORByteString:private] => I�
��ht4dv`[�䮹��2Ǚ\��cE
�X$Jh���%��j��.�a{�g�r,*�~��
)
)
The authData is where the information I need is. Is there a method to convert the CBORByteString into a json string or php array?