use derive_empty_traits::EmptyTraits;
use resolver_api::{HasResponse, Resolve};
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
use webauthn_rs_proto::{
CreationChallengeResponse, RegisterPublicKeyCredential,
};
use crate::entities::{I64, NoData, ResourceTarget};
pub trait KomodoUserRequest: HasResponse {}
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoUserRequest)]
#[response(PushRecentlyViewedResponse)]
#[error(serror::Error)]
pub struct PushRecentlyViewed {
pub resource: ResourceTarget,
}
#[typeshare]
pub type PushRecentlyViewedResponse = NoData;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoUserRequest)]
#[response(SetLastSeenUpdateResponse)]
#[error(serror::Error)]
pub struct SetLastSeenUpdate {}
#[typeshare]
pub type SetLastSeenUpdateResponse = NoData;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoUserRequest)]
#[response(BeginThirdPartyLoginLinkResponse)]
#[error(serror::Error)]
pub struct BeginThirdPartyLoginLink {}
#[typeshare]
pub type BeginThirdPartyLoginLinkResponse = NoData;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoUserRequest)]
#[response(UnlinkLoginResponse)]
#[error(serror::Error)]
pub struct UnlinkLogin {
pub provider: String,
}
#[typeshare]
pub type UnlinkLoginResponse = NoData;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoUserRequest)]
#[response(UpdateUsernameResponse)]
#[error(serror::Error)]
pub struct UpdateUsername {
pub username: String,
}
#[typeshare]
pub type UpdateUsernameResponse = NoData;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoUserRequest)]
#[response(UpdatePasswordResponse)]
#[error(serror::Error)]
pub struct UpdatePassword {
pub password: String,
}
#[typeshare]
pub type UpdatePasswordResponse = NoData;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoUserRequest)]
#[response(CreateApiKeyResponse)]
#[error(serror::Error)]
pub struct CreateApiKey {
pub name: String,
#[serde(default)]
pub expires: I64,
}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct CreateApiKeyResponse {
pub key: String,
pub secret: String,
}
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoUserRequest)]
#[response(DeleteApiKeyResponse)]
#[error(serror::Error)]
pub struct DeleteApiKey {
pub key: String,
}
#[typeshare]
pub type DeleteApiKeyResponse = NoData;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoUserRequest)]
#[response(BeginTotpEnrollmentResponse)]
#[error(serror::Error)]
pub struct BeginTotpEnrollment {}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct BeginTotpEnrollmentResponse {
pub uri: String,
pub png: String,
}
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoUserRequest)]
#[response(ConfirmTotpEnrollmentResponse)]
#[error(serror::Error)]
pub struct ConfirmTotpEnrollment {
pub code: String,
}
#[typeshare]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ConfirmTotpEnrollmentResponse {
pub recovery_codes: Vec<String>,
}
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoUserRequest)]
#[response(UnenrollTotpResponse)]
#[error(serror::Error)]
pub struct UnenrollTotp {}
#[typeshare]
pub type UnenrollTotpResponse = NoData;
#[typeshare(serialized_as = "any")]
pub type _CreationChallengeResponse = CreationChallengeResponse;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoUserRequest)]
#[response(BeginPasskeyEnrollmentResponse)]
#[error(serror::Error)]
pub struct BeginPasskeyEnrollment {}
#[typeshare]
pub type BeginPasskeyEnrollmentResponse = _CreationChallengeResponse;
#[typeshare(serialized_as = "any")]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct _RegisterPublicKeyCredential(pub RegisterPublicKeyCredential);
#[cfg(feature = "openapi")]
impl utoipa::PartialSchema for _RegisterPublicKeyCredential {
fn schema()
-> utoipa::openapi::RefOr<utoipa::openapi::schema::Schema> {
utoipa::schema!(#[inline] std::collections::HashMap<String, serde_json::Value>).into()
}
}
#[cfg(feature = "openapi")]
impl utoipa::ToSchema for _RegisterPublicKeyCredential {}
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoUserRequest)]
#[response(ConfirmPasskeyEnrollmentResponse)]
#[error(serror::Error)]
pub struct ConfirmPasskeyEnrollment {
pub credential: _RegisterPublicKeyCredential,
}
#[typeshare]
pub type ConfirmPasskeyEnrollmentResponse = NoData;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoUserRequest)]
#[response(UnenrollPasskeyResponse)]
#[error(serror::Error)]
pub struct UnenrollPasskey {}
#[typeshare]
pub type UnenrollPasskeyResponse = NoData;
#[typeshare]
#[derive(
Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits,
)]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[empty_traits(KomodoUserRequest)]
#[response(UpdateThirdPartySkip2faResponse)]
#[error(serror::Error)]
pub struct UpdateThirdPartySkip2fa {
pub skip: bool,
}
#[typeshare]
pub type UpdateThirdPartySkip2faResponse = NoData;