class JsonConverter (View source)

Constants

ENCODE_PREFIX

Prefix keys of ByteBuffers with #prefix#

ENCODE_BASE64

Encode ByteBuffers as base64 strings instead of base64url

Methods

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.

static 
decodeAttestationCredential(string $json)

No description

static 
decodeAssertionCredential(string $json)

No description

static 
encodeDictionary(DictionaryInterface $dictionary)

No description

Details

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"
}

Parameters

string $json
string $responseType Expected type of response in the public key's response field. Either 'attestation' for attestation responses or 'assertion' for assertion responses.

Return Value

PublicKeyCredential

Exceptions

ParseException

See also

https://www.w3.org/TR/webauthn/#publickeycredential

static decodeAttestationCredential(string $json)

Parameters

string $json

static decodeAssertionCredential(string $json)

Parameters

string $json

static encodeDictionary(DictionaryInterface $dictionary)

Parameters

DictionaryInterface $dictionary