feat: implement AuthLite

This commit is contained in:
mokurin000
2025-07-30 12:18:17 +08:00
parent d4b6921eeb
commit 82e30c020d
7 changed files with 76 additions and 7 deletions

View File

@@ -8,7 +8,8 @@ use digest::generic_array::GenericArray;
use flate2::write::ZlibEncoder;
use flate2::{Compression, read::ZlibDecoder};
use crate::title::{MaiVersion, MaiVersionExt, Sdgb1_40, Sdgb1_50, error::ApiError};
use crate::error::ApiError;
use crate::title::{MaiVersion, MaiVersionExt, Sdgb1_40, Sdgb1_50};
impl MaiVersionExt for Sdgb1_40 {
fn decode(mut data: impl AsMut<[u8]>) -> Result<Vec<u8>, ApiError> {

View File

@@ -1,36 +0,0 @@
use aes::cipher::{block_padding::UnpadError, inout::PadError};
use snafu::Snafu;
#[derive(Debug, Snafu)]
pub enum ApiError {
#[snafu(display("api returned nothing!"))]
EmptyResponse,
#[snafu(display("encrypt data: {error}"))]
Pad { error: PadError },
#[snafu(display("decrypt data: {error}"))]
Unpad { error: UnpadError },
#[snafu(display("io error: {source}"))]
#[snafu(context(false))]
IO { source: std::io::Error },
#[snafu(display("json error: {source}"))]
#[snafu(context(false))]
JSON { source: serde_json::Error },
#[snafu(display("request error: {source}"))]
#[snafu(context(false))]
Request { source: nyquest::Error },
}
impl From<UnpadError> for ApiError {
fn from(error: UnpadError) -> Self {
Self::Unpad { error }
}
}
impl From<PadError> for ApiError {
fn from(error: PadError) -> Self {
Self::Pad { error }
}
}

View File

@@ -6,8 +6,8 @@ pub mod encryption;
pub mod methods;
pub mod model;
mod error;
pub use error::ApiError;
use super::ApiError;
use nyquest::{
AsyncClient, Body,
r#async::Request,