using Microsoft.Extensions.DependencyInjection;
using Tiku.Application.Auth;
using Tiku.Application.Security;
using Tiku.Infrastructure.Auth;
using Tiku.Infrastructure.Security;

namespace Tiku.Infrastructure;

internal static class AuthModule
{
    internal static IServiceCollection AddAuthModule(this IServiceCollection services)
    {
        services.AddSingleton<IJwtKeyRing, JwtKeyRing>();
        services.AddScoped<ITokenService, TokenService>();
        services.AddScoped<AuthSessionStore>();
        services.AddScoped<IAuthSessionStore>(provider => provider.GetRequiredService<AuthSessionStore>());
        services.AddScoped<IRequestAccessValidator, RequestAccessValidator>();
        services.AddScoped<ISmsProvider, AliyunSmsProvider>();
        services.AddScoped<ISmsVerificationService, SmsVerificationService>();
        services.AddScoped<IWechatOAuthClient, WechatOAuthClient>();
        services.AddScoped<IAuthService, AuthService>();
        services.AddScoped<IAuthAdministrationService, AuthAdministrationService>();
        services.AddScoped<IOwnerActivationService, OwnerActivationService>();
        services.AddScoped<IIdentityProvider, SelfHostedIdentityProvider>();
        services.AddScoped<ICurrentIdentityQueryService, CurrentIdentityQueryService>();
        return services;
    }
}