using Bit.Core.Auth.Entities;
using Bit.Core.Auth.Exceptions;
using Bit.Core.Auth.Models.Api.Request.AuthRequest;
using Bit.Core.Context;
using Bit.Core.Exceptions;
using Bit.Core.Settings;
#nullable enable
namespace Bit.Core.Auth.Services;
public interface IAuthRequestService
{
///
/// fetches an authRequest by Id. Returns AuthRequest if AuthRequest.UserId mateches
/// userId. Returns null if the user doesn't match or if the AuthRequest is not found.
///
/// Authrequest Id being fetched
/// user who owns AuthRequest
/// An AuthRequest or null
Task GetAuthRequestAsync(Guid authRequestId, Guid userId);
///
/// Fetches the authrequest from the database with the id provided. Then checks
/// the accessCode against the AuthRequest.AccessCode from the database. accessCodes
/// must match the found authRequest, and the AuthRequest must not be expired. Expiration
/// is configured in
///
/// AuthRequest being acted on
/// Access code of the authrequest, must match saved database value
/// A valid AuthRequest or null
Task GetValidatedAuthRequestAsync(Guid authRequestId, string accessCode);
///
/// Validates and Creates an in the database, as well as pushes it through notifications services
///
///
/// This method can only be called inside of an HTTP call because of it's reliance on
///
Task CreateAuthRequestAsync(AuthRequestCreateRequestModel model);
///
/// Updates the AuthRequest per the AuthRequestUpdateRequestModel context. This approves
/// or rejects the login request.
///
/// AuthRequest being acted on.
/// User acting on AuthRequest
/// Update context for the AuthRequest
/// retuns an AuthRequest or throws an exception
/// Thows if the AuthRequest has already been Approved/Rejected
/// Throws if the AuthRequest as expired or the userId doesn't match
/// Throws if the device isn't associated with the UserId
Task UpdateAuthRequestAsync(Guid authRequestId, Guid userId, AuthRequestUpdateRequestModel model);
}