use common_enums::{PermissionGroup, RoleScope, TokenPurpose}; use common_utils::{crypto::OptionalEncryptableName, pii}; use masking::Secret; use crate::user_role::UserStatus; pub mod dashboard_metadata; #[cfg(feature = "dummy_connector")] pub mod sample_data; #[derive(serde::Deserialize, Debug, Clone, serde::Serialize)] pub struct SignUpWithMerchantIdRequest { pub name: Secret, pub email: pii::Email, pub password: Secret, pub company_name: String, } pub type SignUpWithMerchantIdResponse = AuthorizeResponse; #[derive(serde::Deserialize, Debug, Clone, serde::Serialize)] pub struct SignUpRequest { pub email: pii::Email, pub password: Secret, } pub type SignUpResponse = DashboardEntryResponse; #[derive(serde::Serialize, Debug, Clone)] pub struct DashboardEntryResponse { pub token: Secret, pub merchant_id: String, pub name: Secret, pub email: pii::Email, pub verification_days_left: Option, pub user_role: String, //this field is added for audit/debug reasons #[serde(skip_serializing)] pub user_id: String, } pub type SignInRequest = SignUpRequest; #[derive(Debug, serde::Serialize)] #[serde(tag = "flow_type", rename_all = "snake_case")] pub enum SignInResponse { MerchantSelect(MerchantSelectResponse), DashboardEntry(DashboardEntryResponse), } #[derive(Debug, serde::Serialize)] pub struct MerchantSelectResponse { pub token: Secret, pub name: Secret, pub email: pii::Email, pub verification_days_left: Option, pub merchants: Vec, } #[derive(serde::Deserialize, Debug, Clone, serde::Serialize)] pub struct ConnectAccountRequest { pub email: pii::Email, } pub type ConnectAccountResponse = AuthorizeResponse; #[derive(serde::Serialize, Debug, Clone)] pub struct AuthorizeResponse { pub is_email_sent: bool, //this field is added for audit/debug reasons #[serde(skip_serializing)] pub user_id: String, //this field is added for audit/debug reasons #[serde(skip_serializing)] pub merchant_id: String, } #[derive(serde::Deserialize, Debug, serde::Serialize)] pub struct ChangePasswordRequest { pub new_password: Secret, pub old_password: Secret, } #[derive(serde::Deserialize, Debug, serde::Serialize)] pub struct ForgotPasswordRequest { pub email: pii::Email, } #[derive(serde::Deserialize, Debug, serde::Serialize)] pub struct ResetPasswordRequest { pub token: Secret, pub password: Secret, } #[derive(serde::Deserialize, Debug, serde::Serialize)] pub struct RotatePasswordRequest { pub password: Secret, } #[derive(Debug, serde::Deserialize, serde::Serialize, Clone)] pub struct InviteUserRequest { pub email: pii::Email, pub name: Secret, pub role_id: String, } #[derive(Debug, serde::Serialize)] pub struct InviteMultipleUserResponse { pub email: pii::Email, pub is_email_sent: bool, #[serde(skip_serializing_if = "Option::is_none")] pub password: Option>, #[serde(skip_serializing_if = "Option::is_none")] pub error: Option, } #[derive(Debug, serde::Deserialize, serde::Serialize, Clone)] pub struct ReInviteUserRequest { pub email: pii::Email, } #[derive(Debug, serde::Deserialize, serde::Serialize, Clone)] pub struct AcceptInviteFromEmailRequest { pub token: Secret, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct SwitchMerchantIdRequest { pub merchant_id: String, } #[derive(serde::Deserialize, Debug, serde::Serialize)] pub struct CreateInternalUserRequest { pub name: Secret, pub email: pii::Email, pub password: Secret, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct UserMerchantCreate { pub company_name: String, } #[derive(Debug, serde::Serialize)] pub struct ListUsersResponse(pub Vec); #[derive(Debug, serde::Serialize)] pub struct UserDetails { pub email: pii::Email, pub name: Secret, pub role_id: String, pub role_name: String, pub status: UserStatus, #[serde(with = "common_utils::custom_serde::iso8601")] pub last_modified_at: time::PrimitiveDateTime, } #[derive(serde::Serialize, Debug, Clone)] pub struct GetUserDetailsResponse { pub merchant_id: String, pub name: Secret, pub email: pii::Email, pub verification_days_left: Option, pub role_id: String, // This field is added for audit/debug reasons #[serde(skip_serializing)] pub user_id: String, pub org_id: String, pub is_two_factor_auth_setup: bool, pub recovery_codes_left: Option, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct GetUserRoleDetailsRequest { pub email: pii::Email, } #[derive(Debug, serde::Serialize)] pub struct GetUserRoleDetailsResponse { pub email: pii::Email, pub name: Secret, pub role_id: String, pub role_name: String, pub status: UserStatus, #[serde(with = "common_utils::custom_serde::iso8601")] pub last_modified_at: time::PrimitiveDateTime, pub groups: Vec, pub role_scope: RoleScope, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct VerifyEmailRequest { pub token: Secret, } pub type VerifyEmailResponse = SignInResponse; #[derive(serde::Deserialize, Debug, serde::Serialize)] pub struct SendVerifyEmailRequest { pub email: pii::Email, } #[derive(Debug, serde::Serialize)] pub struct UserMerchantAccount { pub merchant_id: String, pub merchant_name: OptionalEncryptableName, pub is_active: bool, pub role_id: String, pub role_name: String, pub org_id: String, } #[cfg(feature = "recon")] #[derive(serde::Serialize, Debug)] pub struct VerifyTokenResponse { pub merchant_id: String, pub user_email: pii::Email, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct UpdateUserAccountDetailsRequest { pub name: Option>, pub preferred_merchant_id: Option, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct TokenOnlyQueryParam { pub token_only: Option, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct SkipTwoFactorAuthQueryParam { pub skip_two_factor_auth: Option, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct TokenResponse { pub token: Secret, pub token_type: TokenPurpose, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct TwoFactorAuthStatusResponse { pub totp: bool, pub recovery_code: bool, } #[derive(Debug, serde::Serialize)] #[serde(untagged)] pub enum TokenOrPayloadResponse { Token(TokenResponse), Payload(T), } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct UserFromEmailRequest { pub token: Secret, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct BeginTotpResponse { pub secret: Option, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct TotpSecret { pub secret: Secret, pub totp_url: Secret, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct VerifyTotpRequest { pub totp: Secret, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct VerifyRecoveryCodeRequest { pub recovery_code: Secret, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct RecoveryCodes { pub recovery_codes: Vec>, } #[derive(Debug, serde::Deserialize, serde::Serialize)] #[serde(tag = "auth_type")] #[serde(rename_all = "snake_case")] pub enum AuthConfig { OpenIdConnect { private_config: OpenIdConnectPrivateConfig, public_config: OpenIdConnectPublicConfig, }, MagicLink, Password, } #[derive(Debug, serde::Deserialize, serde::Serialize, Clone)] pub struct OpenIdConnectPrivateConfig { pub base_url: String, pub client_id: Secret, pub client_secret: Secret, pub private_key: Option>, } #[derive(Debug, serde::Deserialize, serde::Serialize, Clone)] pub struct OpenIdConnectPublicConfig { pub name: OpenIdProvider, } #[derive(Debug, serde::Deserialize, serde::Serialize, Clone, strum::Display)] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] pub enum OpenIdProvider { Okta, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct OpenIdConnect { pub name: OpenIdProvider, pub base_url: String, pub client_id: String, pub client_secret: Secret, pub private_key: Option>, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct CreateUserAuthenticationMethodRequest { pub owner_id: String, pub owner_type: common_enums::Owner, pub auth_method: AuthConfig, pub allow_signup: bool, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct UpdateUserAuthenticationMethodRequest { pub id: String, // TODO: When adding more fields make config and new fields option pub auth_method: AuthConfig, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct GetUserAuthenticationMethodsRequest { pub auth_id: String, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct UserAuthenticationMethodResponse { pub id: String, pub auth_id: String, pub auth_method: AuthMethodDetails, pub allow_signup: bool, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct AuthMethodDetails { #[serde(rename = "type")] pub auth_type: common_enums::UserAuthType, pub name: Option, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct GetSsoAuthUrlRequest { pub id: String, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct SsoSignInRequest { pub state: Secret, pub code: Secret, } #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct AuthIdQueryParam { pub auth_id: Option, }