services:
    _defaults:
        public: false

    ########### Vendor services
    CoderCat\JWKToPEM\JWKConverter: ~

    GuzzleHttp\ClientInterface:
        class: GuzzleHttp\Client

    Nyholm\Psr7\Factory\Psr17Factory: ~

    Nyholm\Psr7\Factory\HttplugFactory: ~

    Http\Message\ResponseFactory:
        alias: Nyholm\Psr7\Factory\HttplugFactory

    League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface:
        class: OAT\Library\Lti1p3Core\Security\OAuth2\Repository\AccessTokenRepository
        arguments:
            - '@Psr\Cache\CacheItemPoolInterface'
            - '@Psr\Log\LoggerInterface'

    League\OAuth2\Server\Repositories\ClientRepositoryInterface:
        class: OAT\Library\Lti1p3Core\Security\OAuth2\Repository\ClientRepository
        arguments:
            - '@OAT\Library\Lti1p3Core\Registration\RegistrationRepositoryInterface'
            - '@OAT\Library\Lti1p3Core\Security\Jwks\Fetcher\JwksFetcherInterface'
            - '@Psr\Log\LoggerInterface'
            - '@OAT\Library\Lti1p3Core\Security\Jwt\Validator\ValidatorInterface'
            - '@OAT\Library\Lti1p3Core\Security\Jwt\Parser\ParserInterface'

    League\OAuth2\Server\Repositories\ScopeRepositoryInterface:
        class: OAT\Library\Lti1p3Core\Security\OAuth2\Repository\ScopeRepository

    OAT\Library\Lti1p3Core\Security\OAuth2\Factory\AuthorizationServerFactory:
        arguments:
            - '@League\OAuth2\Server\Repositories\ClientRepositoryInterface'
            - '@League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface'
            - '@League\OAuth2\Server\Repositories\ScopeRepositoryInterface'
            - '%env(LTI1P3_SERVICE_ENCRYPTION_KEY)%'

    Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface:
        class: Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory
        arguments:
            - '@Nyholm\Psr7\Factory\Psr17Factory'
            - '@Nyholm\Psr7\Factory\Psr17Factory'
            - '@Nyholm\Psr7\Factory\Psr17Factory'
            - '@Nyholm\Psr7\Factory\Psr17Factory'

    Symfony\Bridge\PsrHttpMessage\HttpFoundationFactoryInterface:
        class: Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory

    ########### Core lib services
    OAT\Library\Lti1p3Core\Security\Jwt\Signer\SignerFactory: ~

    OAT\Library\Lti1p3Core\Security\Jwt\Converter\KeyConverter: ~

    OAT\Library\Lti1p3Core\Security\Jwt\Configuration\ConfigurationFactory: ~

    OAT\Library\Lti1p3Core\Security\Jwt\Builder\BuilderInterface:
        class: OAT\Library\Lti1p3Core\Security\Jwt\Builder\Builder
        arguments:
            - '@OAT\Library\Lti1p3Core\Security\Jwt\Configuration\ConfigurationFactory'

    OAT\Library\Lti1p3Core\Security\Jwt\Parser\ParserInterface:
        class: OAT\Library\Lti1p3Core\Security\Jwt\Parser\Parser
        arguments:
            - '@OAT\Library\Lti1p3Core\Security\Jwt\Configuration\ConfigurationFactory'

    OAT\Library\Lti1p3Core\Security\Jwt\Validator\ValidatorInterface:
        class: OAT\Library\Lti1p3Core\Security\Jwt\Validator\Validator
        arguments:
            - '@OAT\Library\Lti1p3Core\Security\Jwt\Configuration\ConfigurationFactory'

    OAT\Library\Lti1p3Core\Security\Key\KeyChainFactoryInterface:
        class: OAT\Library\Lti1p3Core\Security\Key\KeyChainFactory

    OAT\Library\Lti1p3Core\Platform\PlatformFactory: ~

    OAT\Library\Lti1p3Core\Tool\ToolFactory: ~

    OAT\Library\Lti1p3Core\Registration\RegistrationFactory: ~

    OAT\Library\Lti1p3Core\Security\Nonce\NonceGeneratorInterface:
        class: OAT\Library\Lti1p3Core\Security\Nonce\NonceGenerator

    OAT\Library\Lti1p3Core\Security\Nonce\NonceRepository:
        arguments:
            - '@Psr\Cache\CacheItemPoolInterface'

    OAT\Library\Lti1p3Core\Message\Payload\Builder\MessagePayloadBuilder:
        arguments:
            - '@OAT\Library\Lti1p3Core\Security\Nonce\NonceGeneratorInterface'
            - '@OAT\Library\Lti1p3Core\Security\Jwt\Builder\BuilderInterface'

    OAT\Library\Lti1p3Core\Message\Payload\Builder\MessagePayloadBuilderInterface:
        class: OAT\Library\Lti1p3Core\Message\Payload\Builder\MessagePayloadBuilder

    ########### Bundle services
    OAT\Library\Lti1p3Core\Security\Key\KeyChainRepositoryInterface:
        alias: OAT\Library\Lti1p3Core\Security\Key\KeyChainRepository

    OAT\Library\Lti1p3Core\Security\Nonce\NonceRepositoryInterface:
        alias: OAT\Library\Lti1p3Core\Security\Nonce\NonceRepository

    OAT\Library\Lti1p3Core\Registration\RegistrationRepositoryInterface:
        alias: OAT\Bundle\Lti1p3Bundle\Repository\RegistrationRepository

    OAT\Bundle\Lti1p3Bundle\DependencyInjection\Builder\KeyChainRepositoryBuilder:
        arguments: ['@OAT\Library\Lti1p3Core\Security\Key\KeyChainFactoryInterface']

    OAT\Bundle\Lti1p3Bundle\DependencyInjection\Builder\RegistrationRepositoryBuilder:
        arguments:
            - '@OAT\Library\Lti1p3Core\Security\Key\KeyChainFactoryInterface'
            - '@OAT\Library\Lti1p3Core\Platform\PlatformFactory'
            - '@OAT\Library\Lti1p3Core\Tool\ToolFactory'
            - '@OAT\Library\Lti1p3Core\Registration\RegistrationFactory'

    OAT\Library\Lti1p3Core\Security\Jwks\Exporter\JwksExporter:
        arguments: ['@OAT\Library\Lti1p3Core\Security\Key\KeyChainRepositoryInterface']

    OAT\Library\Lti1p3Core\Security\Jwks\Fetcher\JwksFetcherInterface:
        class: OAT\Library\Lti1p3Core\Security\Jwks\Fetcher\JwksFetcher
        arguments:
            - '@Psr\Cache\CacheItemPoolInterface'
            - '@GuzzleHttp\ClientInterface'
            - '@CoderCat\JWKToPEM\JWKConverter'
            - '@Psr\Log\LoggerInterface'

    OAT\Library\Lti1p3Core\Security\Oidc\OidcInitiator:
        arguments:
            - '@OAT\Library\Lti1p3Core\Registration\RegistrationRepositoryInterface'
            - '@OAT\Library\Lti1p3Core\Security\Nonce\NonceGeneratorInterface'
            - '@OAT\Library\Lti1p3Core\Message\Payload\Builder\MessagePayloadBuilderInterface'

    OAT\Library\Lti1p3Core\Security\Oidc\OidcAuthenticator:
        arguments:
            - '@OAT\Library\Lti1p3Core\Registration\RegistrationRepositoryInterface'
            - '@OAT\Library\Lti1p3Core\Security\User\UserAuthenticatorInterface'
            - '@OAT\Library\Lti1p3Core\Message\Payload\Builder\MessagePayloadBuilderInterface'
            - '@OAT\Library\Lti1p3Core\Security\Jwt\Validator\ValidatorInterface'
            - '@OAT\Library\Lti1p3Core\Security\Jwt\Parser\ParserInterface'

    OAT\Library\Lti1p3Core\Message\Launch\Validator\Platform\PlatformLaunchValidator:
        arguments:
            - '@OAT\Library\Lti1p3Core\Registration\RegistrationRepositoryInterface'
            - '@OAT\Library\Lti1p3Core\Security\Nonce\NonceRepositoryInterface'
            - '@OAT\Library\Lti1p3Core\Security\Jwks\Fetcher\JwksFetcherInterface'
            - '@OAT\Library\Lti1p3Core\Security\Jwt\Validator\ValidatorInterface'
            - '@OAT\Library\Lti1p3Core\Security\Jwt\Parser\ParserInterface'

    OAT\Library\Lti1p3Core\Message\Launch\Validator\Platform\PlatformLaunchValidatorInterface:
        alias: OAT\Library\Lti1p3Core\Message\Launch\Validator\Platform\PlatformLaunchValidator

    OAT\Library\Lti1p3Core\Message\Launch\Validator\Tool\ToolLaunchValidator:
        arguments:
            - '@OAT\Library\Lti1p3Core\Registration\RegistrationRepositoryInterface'
            - '@OAT\Library\Lti1p3Core\Security\Nonce\NonceRepositoryInterface'
            - '@OAT\Library\Lti1p3Core\Security\Jwks\Fetcher\JwksFetcherInterface'
            - '@OAT\Library\Lti1p3Core\Security\Jwt\Validator\ValidatorInterface'
            - '@OAT\Library\Lti1p3Core\Security\Jwt\Parser\ParserInterface'

    OAT\Library\Lti1p3Core\Message\Launch\Validator\Tool\ToolLaunchValidatorInterface:
        alias: OAT\Library\Lti1p3Core\Message\Launch\Validator\Tool\ToolLaunchValidator

    OAT\Library\Lti1p3Core\Security\OAuth2\Generator\AccessTokenResponseGenerator:
        arguments:
            - '@OAT\Library\Lti1p3Core\Security\Key\KeyChainRepositoryInterface'
            - '@OAT\Library\Lti1p3Core\Security\OAuth2\Factory\AuthorizationServerFactory'

    OAT\Library\Lti1p3Core\Security\OAuth2\Validator\RequestAccessTokenValidator:
        arguments:
            - '@OAT\Library\Lti1p3Core\Registration\RegistrationRepositoryInterface'
            - '@Psr\Log\LoggerInterface'
            - '@OAT\Library\Lti1p3Core\Security\Jwt\Validator\ValidatorInterface'
            - '@OAT\Library\Lti1p3Core\Security\Jwt\Parser\ParserInterface'

    OAT\Library\Lti1p3Core\Security\OAuth2\Validator\RequestAccessTokenValidatorInterface:
        alias: OAT\Library\Lti1p3Core\Security\OAuth2\Validator\RequestAccessTokenValidator

    OAT\Bundle\Lti1p3Bundle\Security\Exception\LtiToolMessageExceptionHandler:
        arguments:
            - '@OAT\Library\Lti1p3Core\Security\Jwt\Parser\ParserInterface'

    OAT\Bundle\Lti1p3Bundle\Security\Exception\LtiToolMessageExceptionHandlerInterface:
        alias: OAT\Bundle\Lti1p3Bundle\Security\Exception\LtiToolMessageExceptionHandler

    OAT\Bundle\Lti1p3Bundle\Security\Firewall\Message\LtiPlatformMessageAuthenticationListener:
        arguments:
            - '@security.token_storage'
            - '@security.authentication.manager'
            - '@Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface'
            - '@security.firewall.map'

    OAT\Bundle\Lti1p3Bundle\Security\Firewall\Message\LtiToolMessageAuthenticationListener:
        arguments:
            - '@security.token_storage'
            - '@security.authentication.manager'
            - '@Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface'
            - '@OAT\Bundle\Lti1p3Bundle\Security\Exception\LtiToolMessageExceptionHandlerInterface'
            - '@security.firewall.map'

    OAT\Bundle\Lti1p3Bundle\Security\Firewall\Service\LtiServiceAuthenticationListener:
        arguments:
            - '@security.token_storage'
            - '@security.authentication.manager'
            - '@Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface'
            - '@security.firewall.map'

    OAT\Library\Lti1p3Core\Security\User\UserAuthenticatorInterface: ~

    OAT\Library\Lti1p3Core\Message\Launch\Builder\PlatformOriginatingLaunchBuilder:
        arguments:
            - '@OAT\Library\Lti1p3Core\Message\Payload\Builder\MessagePayloadBuilderInterface'
        public: true

    OAT\Library\Lti1p3Core\Message\Launch\Builder\ToolOriginatingLaunchBuilder:
        arguments:
            - '@OAT\Library\Lti1p3Core\Message\Payload\Builder\MessagePayloadBuilderInterface'
        public: true

    OAT\Library\Lti1p3Core\Message\Launch\Builder\LtiResourceLinkLaunchRequestBuilder:
        arguments:
            - '@OAT\Library\Lti1p3Core\Message\Payload\Builder\MessagePayloadBuilderInterface'
        public: true

    OAT\Library\Lti1p3Core\Service\Client\LtiServiceClientInterface:
        class: OAT\Library\Lti1p3Core\Service\Client\LtiServiceClient
        arguments:
            - '@Psr\Cache\CacheItemPoolInterface'
            - '@GuzzleHttp\ClientInterface'
            - '@OAT\Library\Lti1p3Core\Security\Jwt\Builder\BuilderInterface'
        public: true

    OAT\Bundle\Lti1p3Bundle\Service\Server\Factory\LtiServiceServerHttpFoundationRequestHandlerFactory:
        arguments:
            - '@security.helper'
            - '@Symfony\Bridge\PsrHttpMessage\HttpFoundationFactoryInterface'
            - '@Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface'
            - '@Psr\Log\LoggerInterface'

    OAT\Bundle\Lti1p3Bundle\Service\Server\Factory\LtiServiceServerHttpFoundationRequestHandlerFactoryInterface:
        alias: OAT\Bundle\Lti1p3Bundle\Service\Server\Factory\LtiServiceServerHttpFoundationRequestHandlerFactory

    ########### Endpoints
    OAT\Bundle\Lti1p3Bundle\Action\Jwks\JwksAction:
        arguments:
            - '@OAT\Library\Lti1p3Core\Security\Jwks\Exporter\JwksExporter'
        tags: ['controller.service_arguments']

    OAT\Bundle\Lti1p3Bundle\Action\Tool\Message\OidcInitiationAction:
        arguments:
            - '@Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface'
            - '@OAT\Library\Lti1p3Core\Security\Oidc\OidcInitiator'
            - '@Psr\Log\LoggerInterface'
        tags: ['controller.service_arguments']

    OAT\Bundle\Lti1p3Bundle\Action\Platform\Message\OidcAuthenticationAction:
        arguments:
            - '@Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface'
            - '@OAT\Library\Lti1p3Core\Security\Oidc\OidcAuthenticator'
            - '@Psr\Log\LoggerInterface'
        tags: ['controller.service_arguments']

    OAT\Bundle\Lti1p3Bundle\Action\Platform\Service\OAuth2AccessTokenCreationAction:
        arguments:
            - '@Symfony\Bridge\PsrHttpMessage\HttpFoundationFactoryInterface'
            - '@Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface'
            - '@OAT\Library\Lti1p3Core\Security\OAuth2\Generator\AccessTokenResponseGenerator'
            - '@Psr\Log\LoggerInterface'
        tags: ['controller.service_arguments']
