webauthn-server icon indicating copy to clipboard operation
webauthn-server copied to clipboard

Feature Request: Make RegistrationOptions function chainable

Open toitzi opened this issue 2 years ago • 1 comments

Would it be possible to change the setter functions in the RegistrationOptions to return self instead of void? This would make it possible to be able to chain those and write something like this:

$opts = RegistrationOptions::createForUser($userIdentity)
            ->setExcludeExistingCredentials(true);
            ->setTimeout(20);
            ->setResidentKey(ResidentKeyRequirement::REQUIRED);
            ->setUserVerification(\MadWizard\WebAuthn\Dom\UserVerificationRequirement::REQUIRED);

instead of this

$opts = RegistrationOptions::createForUser($userIdentity);
$opts->setExcludeExistingCredentials(true);
$opts->setTimeout(20);
$opts->setResidentKey(ResidentKeyRequirement::REQUIRED);
$opts->setUserVerification(\MadWizard\WebAuthn\Dom\UserVerificationRequirement::REQUIRED);

kinda like the ServerBuilder works, this could be done without breaking existing code i think

toitzi avatar Jan 11 '23 15:01 toitzi

Yes I don't think that would break anything so it would be a good improvement. If you want you can create a PR, otherwise I'll look into it in a later update.

madwizard-thomas avatar Jan 12 '23 19:01 madwizard-thomas