syntax = "proto3";

package user.v1;

import "buf/validate/validate.proto";

service AuthService {
  rpc Login (LoginRequest) returns (LoginResponse) {}
  rpc SignUp (SignUpRequest) returns (SignUpResponse) {}
  rpc Logout (LogoutRequest) returns (LogoutResponse) {}

  rpc BeginPasskeyLogin (BeginPasskeyLoginRequest) returns (BeginPasskeyLoginResponse) {}
  rpc FinishPasskeyLogin (FinishPasskeyLoginRequest) returns (FinishPasskeyLoginResponse) {}
}

message LoginRequest {
  string username = 1 [
    (buf.validate.field).string.min_len = 3
  ];
  string password = 2;
}
message LoginResponse {
  string token = 1;
}

message SignUpRequest {
  string username = 1 [
    (buf.validate.field).string.min_len = 3
  ];
  string password = 2; 
  string confirm_password = 3;
}
message SignUpResponse {}

message LogoutRequest {}
message LogoutResponse {}

message BeginPasskeyLoginRequest {
  string username = 1;
}
message BeginPasskeyLoginResponse {
  string options_json = 1;
}

message FinishPasskeyLoginRequest {
  string username = 1;
  string attestation = 2;
}
message FinishPasskeyLoginResponse {
  string token = 1;
}