Skip to content

json_encode() of PublicKeyCredentialRequestOptions fails #32

@ptmkenny

Description

@ptmkenny

Version(s) affected

5.0

Description

Works in 4.9 but not 5.0: json_encode(\Webauthn\PublicKeyCredentialRequestOptions::create(random_bytes(32), allowCredentials: []))

I need to json_encode() it to submit the request to my site via a JSON-RPC endpoint.

The docs still say:

The PublicKeyCredentialRequestOptions object is designed to be easily serialized into a JSON object. This will ease the integration into an HTML page or through an API endpoint.

How to reproduce

With 4.9, I was using this code:

      $public_key_credential_request_options = PublicKeyCredentialRequestOptions::create(
        $this->webauthn->createChallenge(),
        allowCredentials: $allowed_credentials,
      );
      $this->tempstore->set(self::TEMP_STORE_REQUEST_OPTIONS, $public_key_credential_request_options);

      $stringified_json = json_encode($public_key_credential_request_options);
      if (is_string($stringified_json)) {
      }

After upgrading to 5.0, this fails because the value of json_encode() is false.

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions