app->make(PublicKeyCredentialValidator::class) ->validate($publicKey, $data); $webauthnKey = $this->create($user, $keyName, $publicKeyCredentialSource); $this->forceAuthenticate(); $this->events->dispatch(new WebauthnRegister($webauthnKey)); return $webauthnKey; } /** * Create a new key. * * @param User $user * @param string $keyName * @param PublicKeyCredentialSource $publicKeyCredentialSource * @return WebauthnKey */ public function create(User $user, string $keyName, PublicKeyCredentialSource $publicKeyCredentialSource) { $webauthnKey = WebauthnKey::make([ 'user_id' => $user->getAuthIdentifier(), 'name' => $keyName, ]); $webauthnKey->publicKeyCredentialSource = $publicKeyCredentialSource; $webauthnKey->save(); return $webauthnKey; } }