namespace NATS.Server.WebSocket;

public static class WsAuthConfig
{
    public static bool ComputeAuthOverride(WebSocketOptions options)
    {
        ArgumentNullException.ThrowIfNull(options);

        return !string.IsNullOrWhiteSpace(options.Username)
            || !string.IsNullOrWhiteSpace(options.Token)
            || !string.IsNullOrWhiteSpace(options.NoAuthUser);
    }

    public static void Apply(WebSocketOptions options)
    {
        ArgumentNullException.ThrowIfNull(options);
        options.AuthOverride = ComputeAuthOverride(options);
    }
}
