JsonConverter
class JsonConverter (View source)
Constants
ENCODE_PREFIX |
Prefix keys of ByteBuffers with |
ENCODE_BASE64 |
Encode ByteBuffers as base64 strings instead of base64url |
Methods
Parses a JSON string containing a credential returned from the JS credential API's credentials.get or credentials.create. The JSOn structure matches the PublicKeyCredential interface from the WebAuthn specifications closely but since it contains ArrayBuffers it cannot be directly converted to a JSON equivalent. Fields that are ArrayBuffers are assumed to be base64url encoded.
No description
No description
Details
at line 79
static PublicKeyCredential
decodeCredential(string $json, string $responseType)
Parses a JSON string containing a credential returned from the JS credential API's credentials.get or credentials.create. The JSOn structure matches the PublicKeyCredential interface from the WebAuthn specifications closely but since it contains ArrayBuffers it cannot be directly converted to a JSON equivalent. Fields that are ArrayBuffers are assumed to be base64url encoded.
Also, the response field of the PublicKeyCredential can contain either an attestation or assertion response. To determine which one to parse the $responseType parameter must be set to 'attestation' or 'assertion'.
The required JSON structure is:
{
"type": "public-key",
"id": "base64url encoded ArrayBuffer",
"response" : << authenticator response >>,
"getClientExtensionResults" : << output of credential.getClientExtensionResults() >>
}
Where the authenticator response for attestation is:
{
attestationObject: "base64url encoded ArrayBuffer"
}
and for assertion response is:
{
authenticatorData : "base64url encoded ArrayBuffer",
signature: "base64url encoded ArrayBuffer",
userHandle: "base64url encoded ArrayBuffer"
}