syntax = "proto3";

package auth;

service AuthService {
    rpc Register(RegisterRequest) returns (RegisterResponse);
    rpc Login(LoginRequest) returns (LoginResponse);
    rpc RefreshTokens(RefreshTokensRequest) returns (RefreshTokensResponse);
    rpc Logout(LogoutRequest) returns (LogoutResponse);
    rpc GetMe(GetMeRequest) returns (GetMeResponse);
    rpc GetUserByEmail(GetUserByEmailRequest) returns (GetUserByEmailResponse);
    rpc ValidateToken(ValidateTokenRequest) returns (ValidateTokenResponse);
    rpc SendOtp(SendOtpRequest) returns (SendOtpResponse);
    rpc VerifyOtp(VerifyOtpRequest) returns (VerifyOtpResponse);
}

message RegisterRequest {
    string username = 1;
    string email = 2;
    string password = 3;
}

message RegisterResponse {
    string user_id = 1;
}

message LoginRequest {
    string email = 1;
    string password = 2;
}

message LoginResponse {
    string access_token = 1;
    string refresh_token = 2;
}

message RefreshTokensRequest {
    string refresh_token = 1;
}

message RefreshTokensResponse {
    string access_token = 1;
    string refresh_token = 2;
}

message LogoutRequest {
    string refresh_token = 1;
}

message LogoutResponse {
    bool success = 1;
}

message GetMeRequest {
    string user_id = 1;
}

message GetMeResponse {
    string user_id = 1;
    string username = 2;
    string email = 3;
    bool is_verified = 4;
}

message GetUserByEmailRequest {
    string email = 1;
}

message GetUserByEmailResponse {
    string user_id = 1;
    string username = 2;
    string email = 3;
}

message ValidateTokenRequest {
    string access_token = 1;
}

message ValidateTokenResponse {
    bool valid = 1;
    string user_id = 2;
    string email = 3;
    string username = 4;
}

message SendOtpRequest {
    string email = 1;
}

message SendOtpResponse {
    bool success = 1;
}

message VerifyOtpRequest {
    string email = 1;
    string code = 2;
}

message VerifyOtpResponse {
    bool success = 1;
}
