jsonSerialize removed from PublicKeyCredentialCreationOptions

Created on 27 November 2024, 24 days ago

Problem/Motivation

PublicKeyCredentialSourceWebauthn::getRegistrationOptions() returns a Webauthn\PublicKeyCredentialCreationOptions object, which used to have a jsonSerialize method so, this line of code used to work:

return $this->webauthn->getRegistrationOptions($user)->jsonSerialize();

But with the latest changed I've updated it to:

json_encode($this->webauthn->getRegistrationOptions($user))

However json_encode returns false.

I've tried to step though and take a look but it's not obvious to me at this point what is failing.

A print_r of my $public_key_credential_creation_options shows:

Webauthn\PublicKeyCredentialCreationOptions Object
(
    [extensions] => Webauthn\AuthenticationExtensions\AuthenticationExtensions Object
        (
            [extensions] => Array
                (
                )

        )

    [challenge] => � 7y�{�s���}�7o�
    [timeout] =>
    [rp] => Webauthn\PublicKeyCredentialRpEntity Object
        (
            [name] => Drupal
            [icon] =>
            [id] => localhost
        )

    [user] => Webauthn\PublicKeyCredentialUserEntity Object
        (
            [name] => nopasskey@test.com
            [icon] =>
            [id] => 4dfab6b1-5ff1-48b8-a1c3-754d0e225d8b
            [displayName] => nopasskey@test.com
        )

    [pubKeyCredParams] => Array
        (
            [0] => Webauthn\PublicKeyCredentialParameters Object
                (
                    [type] => public-key
                    [alg] => -7
                )

            [1] => Webauthn\PublicKeyCredentialParameters Object
                (
                    [type] => public-key
                    [alg] => -257
                )

        )

    [authenticatorSelection] => Webauthn\AuthenticatorSelectionCriteria Object
        (
            [authenticatorAttachment] =>
            [userVerification] => preferred
            [residentKey] => preferred
        )

    [attestation] =>
    [excludeCredentials] => Array
        (
        )

)

Steps to reproduce

Try json_encode output of getRegistrationOptions()

Proposed resolution

I'm not sure at this point.

I have seen the new serializePublicKeyCredential method but it doesn't accept PublicKeyCredentialCreationOptions (and doesn't appear to work if you hack it to remove that restriction.

Remaining tasks

Find cause of problem.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom dahousecat

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024