services:
  jbtronics_webauthn_tfa.two_factor_provider:
    class: Jbtronics\TFAWebauthn\Security\TwoFactor\Provider\Webauthn\TwoFactorProvider
    # This tag is important to register the provider as TwoFactor provider
    tags:
      - { name: scheb_two_factor.provider, alias: webauthn_two_factor_provider }
    arguments:
       $authenticator: '@jbtronics_webauthn_tfa.webauthn_authenticator'
       $formRenderer: '@jbtronics_webauthn_tfa.form_renderer'
       $webAuthnRequestStorage: '@jbtronics_webauthn_tfa.webauthn_request_storage'

  jbtronics_webauthn_tfa.u2f_app_id_provider:
    class: Jbtronics\TFAWebauthn\Services\Helpers\U2FAppIDProvider
    arguments:
      $requestStack: '@request_stack'
      $override: '%jbtronics_webauthn_tfa.U2FAppID%'

  jbtronics_webauthn_tfa.form_renderer:
    class: Jbtronics\TFAWebauthn\Security\TwoFactor\Provider\Webauthn\WebauthnFormRenderer
    arguments:
      $tokenStorage: '@security.token_storage'
      $twig: '@twig'
      $template: '%jbtronics_webauthn_tfa.template%'
      $webAuthnRequestStorage: '@jbtronics_webauthn_tfa.webauthn_request_storage'
      $authenticator: '@jbtronics_webauthn_tfa.webauthn_authenticator'

  jbtronics_webauthn_tfa.psr_request_helper:
    class: Jbtronics\TFAWebauthn\Services\Helpers\PSRRequestHelper
    arguments:
      $requestStack: '@request_stack'

  jbtronics_webauthn_tfa.webauthn_authenticator:
    class: Jbtronics\TFAWebauthn\Services\WebauthnAuthenticator
    arguments:
        $publicKeyCredentialSourceRepository: '@jbtronics_webauthn_tfa.user_public_key_source_repo'
        $u2FAppIDProvider: '@jbtronics_webauthn_tfa.u2f_app_id_provider'
        $webauthnProvider: '@jbtronics_webauthn_tfa.webauthn_provider'
        $PSRRequestHelper: '@jbtronics_webauthn_tfa.psr_request_helper'
        $rpID: '%jbtronics_webauthn_tfa.rpID%'
        $timeout: '%jbtronics_webauthn_tfa.timeout%'
        $logger: '@logger'

  jbtronics_webauthn_tfa.registration_helper:
    class: Jbtronics\TFAWebauthn\Services\TFAWebauthnRegistrationHelper
    arguments:
      $PSRRequestHelper: '@jbtronics_webauthn_tfa.psr_request_helper'
      $timeout: '%jbtronics_webauthn_tfa.timeout%'
      $webauthnProvider: '@jbtronics_webauthn_tfa.webauthn_provider'
      $security: '@security.helper'
      $webAuthnRequestStorage: '@jbtronics_webauthn_tfa.webauthn_request_storage'
      $keyCredentialSourceRepository: '@jbtronics_webauthn_tfa.user_public_key_source_repo'

  jbtronics_webauthn_tfa.webauthn_request_storage:
    class: Jbtronics\TFAWebauthn\Services\Helpers\WebAuthnRequestStorage
    arguments:
      $requestStack: '@request_stack'

  jbtronics_webauthn_tfa.user_public_key_source_repo:
    class: Jbtronics\TFAWebauthn\Services\UserPublicKeyCredentialSourceRepository
    arguments:
      $security: '@security.helper'

  jbtronics_webauthn_tfa.webauthn_provider:
    class: Jbtronics\TFAWebauthn\Services\WebauthnProvider
    arguments:
      $rpID: '%jbtronics_webauthn_tfa.rpID%'
      $rpName: '%jbtronics_webauthn_tfa.rpName%'
      $rpIcon: '%jbtronics_webauthn_tfa.rpIcon%'


  # Alias definition for autowiring
  Jbtronics\TFAWebauthn\Services\TFAWebauthnRegistrationHelper: '@jbtronics_webauthn_tfa.registration_helper'