mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 09:28:11 +00:00
cleanup
This commit is contained in:
1 parent
7842b3bd95
commit
844891014e
12 files changed
+3
-60
No files matched your search
+2
-4
@@ -6,7 +6,6 @@ use crate::error::sora_specific_api_error::SoraSpecificApiError;
|
||||
use crate::requests::auth_sentinel::request::GenerateSentinelRefreshRequest;
|
||||
use crate::requests::auth_sentinel_2::request::SentinelRequest;
|
||||
use crate::requests::auth_sentinel_2::response::SentinelResponse;
|
||||
use crate::requests::auth_sentinel_2::sentinel_token::SentinelResponsePieces;
|
||||
use crate::utils_internal::classify_general_http_error::classify_general_http_error;
|
||||
use errors::AnyhowResult;
|
||||
use idempotency::uuid::generate_random_uuid;
|
||||
@@ -141,8 +140,8 @@ fn into_sora_sentinel_token(request: SentinelRequest, response: SentinelResponse
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::fs::write;
|
||||
use super::*;
|
||||
use std::fs::write;
|
||||
|
||||
#[tokio::test]
|
||||
#[ignore] // Only manually trigger this
|
||||
@@ -166,5 +165,4 @@ mod tests {
|
||||
assert_eq!(1, 2);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,4 +1,3 @@
|
||||
pub (super) mod request;
|
||||
pub (super) mod response;
|
||||
pub mod generate_sentinel_token_2;
|
||||
pub mod sentinel_token;
|
||||
pub mod generate_sentinel_token_2;
|
||||
@@ -1,54 +0,0 @@
|
||||
use crate::error::sora_client_error::SoraClientError;
|
||||
use crate::requests::auth_sentinel_2::request::SentinelRequest;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
// TODO: Refactor + support more
|
||||
const SENTINEL_FLOW: &str = "sora_init";
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct SentinelToken {
|
||||
/// "Proof of Work" token (we generated this)
|
||||
#[serde(rename = "p")]
|
||||
pub p: String,
|
||||
|
||||
/// Random UUID (we generated this)
|
||||
#[serde(rename = "id")]
|
||||
pub id: String,
|
||||
|
||||
/// Frontend UI flow (this is the website flow used)
|
||||
#[serde(rename = "flow")]
|
||||
pub flow: String,
|
||||
|
||||
/// Turnstile dx from the response.
|
||||
/// response["turnstile"]["dx"]
|
||||
#[serde(rename = "t")]
|
||||
pub t: String,
|
||||
|
||||
/// Token from the response.
|
||||
/// response["token"]
|
||||
#[serde(rename = "c")]
|
||||
pub c: String,
|
||||
}
|
||||
|
||||
/// The important parts of the sentinel endpoint response.
|
||||
pub (crate) struct SentinelResponsePieces {
|
||||
pub token: String,
|
||||
pub turnstile_dx: String,
|
||||
}
|
||||
|
||||
impl SentinelToken {
|
||||
pub fn from_server_request(request: &SentinelRequest, response: &SentinelResponsePieces) -> Self {
|
||||
Self {
|
||||
p: request.p.clone(),
|
||||
id: request.id.clone(),
|
||||
flow: request.flow.clone(),
|
||||
t: response.turnstile_dx.clone(),
|
||||
c: response.token.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_json(&self) -> Result<String, SoraClientError> {
|
||||
serde_json::to_string(self)
|
||||
.map_err(|err| SoraClientError::CouldNotSerializeSentinelToken(err))
|
||||
}
|
||||
}
|
||||
File renamed without changes.
Reference in new issue
Block a user