using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Svrnty.CQRS.Abstractions.Security;
using Svrnty.CQRS.Altcha.Abstractions;
namespace Svrnty.CQRS.Altcha;
public static class ServiceCollectionExtensions
{
///
/// Registers as both an
/// and an
/// , plus a no-op
/// that defers to the upstream
/// Altcha service's configured default complexity. Applications opt
/// into adaptive difficulty by registering their own
/// before or after this call —
/// the TryAdd registration here yields to any existing one.
///
///
/// The check is a no-op until an
/// implementation is also registered
/// (typically via AddSvrntyAltchaGrpcVerifier(...) from
/// Svrnty.CQRS.Altcha.Grpc). Idempotent for the concrete check;
/// the multi-instance interface registrations are added unconditionally,
/// so callers should invoke this exactly once per application startup.
///
public static IServiceCollection AddSvrntyAltcha(this IServiceCollection services)
{
services.TryAddSingleton();
services.AddSingleton(sp => sp.GetRequiredService());
services.AddSingleton(sp => sp.GetRequiredService());
services.TryAddSingleton();
return services;
}
}