internal utils package

This commit is contained in:
Brandon Thomas committed 2025-10-01 23:40:15 -04:00
1 parent 781d161aed
commit c30308d43c
14 files changed
+16 -17

No files matched your search

@@ -1,5 +1,5 @@
use crate::error::sora_error::SoraError;
use crate::utils::lightweight_sora_jwt_parse::{lightweight_sora_jwt_parse, SoraJwtClaims};
use crate::utils_internal::lightweight_sora_jwt_parse::{lightweight_sora_jwt_parse, SoraJwtClaims};
/// Sora bearer tokens are JWT tokens that can be minted with a valid cookie/session.
#[derive(Clone)]
@@ -1,5 +1,5 @@
pub (crate) mod constants;
pub (crate) mod utils_internal;
pub mod creds;
pub mod error;
pub mod recipes;
@@ -1,13 +1,13 @@
use crate::creds::sora_credential_set::SoraCredentialSet;
use crate::creds::sora_jwt_bearer_token::SoraJwtBearerToken;
use crate::creds::sora_sentinel::SoraSentinel;
use crate::error::sora_error::SoraError;
use crate::requests::bearer::generate_bearer_with_cookie::generate_bearer_with_cookie;
use crate::requests::sentinel_refresh::generate::token::generate_token;
use chrono::{DateTime, TimeDelta, Utc};
use errors::AnyhowResult;
use log::info;
use std::ops::Sub;
use crate::error::sora_error::SoraError;
const EXPIRATION_DEADLINE : TimeDelta = TimeDelta::hours(12);
@@ -2,8 +2,8 @@ use crate::error::sora_client_error::SoraClientError;
use crate::error::sora_error::SoraError;
use crate::error::sora_generic_api_error::SoraGenericApiError;
use crate::error::sora_specific_api_error::SoraSpecificApiError;
use crate::utils::classify_general_http_error::classify_general_http_error;
use crate::utils::classify_general_http_status_code_and_body::classify_general_http_status_code_and_body;
use crate::utils_internal::classify_general_http_error::classify_general_http_error;
use crate::utils_internal::classify_general_http_status_code_and_body::classify_general_http_status_code_and_body;
use errors::AnyhowResult;
use log::{debug, error, info};
use serde_derive::Deserialize;
@@ -4,7 +4,7 @@ use crate::creds::sora_jwt_bearer_token::SoraJwtBearerToken;
use crate::error::sora_client_error::SoraClientError;
use crate::error::sora_error::SoraError;
use crate::error::sora_generic_api_error::SoraGenericApiError;
use crate::utils::classify_general_http_status_code_and_body::classify_general_http_status_code_and_body;
use crate::utils_internal::classify_general_http_status_code_and_body::classify_general_http_status_code_and_body;
use anyhow::anyhow;
use errors::AnyhowResult;
use log::{debug, error, warn};
@@ -4,7 +4,7 @@ use crate::error::sora_error::SoraError;
use crate::error::sora_generic_api_error::SoraGenericApiError;
use crate::requests::image_gen::image_gen_status::VideoGenStatusResponse;
use crate::requests::upload::upload_media_http_request::SoraMediaUploadResponse;
use crate::utils::classify_general_http_error::classify_general_http_error;
use crate::utils_internal::classify_general_http_error::classify_general_http_error;
use log::{error, info};
use once_cell::sync::Lazy;
use serde_derive::Deserialize;
@@ -1,15 +1,15 @@
use super::request::GenerateSentinelRefreshRequest;
use crate::constants::user_agent::USER_AGENT;
use crate::error::sora_error::SoraError;
use crate::error::sora_generic_api_error::SoraGenericApiError;
use crate::requests::list_media::list_media::ListMediaResponse;
use crate::utils::classify_general_http_error::classify_general_http_error;
use crate::utils_internal::classify_general_http_error::classify_general_http_error;
use errors::AnyhowResult;
use idempotency::uuid::generate_random_uuid;
use log::error;
use serde_derive::{Deserialize, Serialize};
use thiserror::Error;
use wreq::Client;
use crate::constants::user_agent::USER_AGENT;
const SORA_IMAGE_GEN_URL: &str = "https://chatgpt.com/backend-api/sentinel/req";
@@ -4,7 +4,7 @@ use crate::error::sora_client_error::SoraClientError;
use crate::error::sora_error::SoraError;
use crate::error::sora_generic_api_error::SoraGenericApiError;
use crate::requests::bearer::generate_bearer_with_cookie::SoraAuthResponse;
use crate::utils::classify_general_http_error::classify_general_http_error;
use crate::utils_internal::classify_general_http_error::classify_general_http_error;
use log::{error, info};
use serde::Deserialize;
use std::io::empty;
@@ -1,4 +1 @@
pub mod classify_general_http_error;
pub mod classify_general_http_status_code_and_body;
pub mod has_session_cookie;
pub mod lightweight_sora_jwt_parse;
pub mod has_session_cookie;
@@ -1,6 +1,6 @@
use crate::error::sora_error::SoraError;
use crate::error::sora_generic_api_error::SoraGenericApiError;
use crate::utils::classify_general_http_status_code_and_body::classify_general_http_status_code_and_body;
use crate::utils_internal::classify_general_http_status_code_and_body::classify_general_http_status_code_and_body;
/// This assumes the request failed and returned a non-200.
/// The caller should check.
@@ -118,7 +118,7 @@ fn as_jwt_error(reason: String) -> SoraError {
#[cfg(test)]
mod tests {
use crate::utils::lightweight_sora_jwt_parse::lightweight_sora_jwt_parse;
use crate::utils_internal::lightweight_sora_jwt_parse::lightweight_sora_jwt_parse;
#[test]
fn test_sora_jwt_bearer_token() {
@@ -0,0 +1,3 @@
pub mod classify_general_http_error;
pub mod classify_general_http_status_code_and_body;
pub mod lightweight_sora_jwt_parse;
@@ -24,7 +24,6 @@ use midjourney_client::credentials::cookie_store_has_auth_cookies::cookie_store_
use midjourney_client::recipes::get_user_info::{get_user_info, GetUserInfoRequest};
use openai_sora_client::creds::sora_credential_set::SoraCredentialSet;
use openai_sora_client::recipes::maybe_upgrade_or_renew_session::maybe_upgrade_or_renew_session;
use openai_sora_client::utils::has_session_cookie::{has_session_cookie, SessionCookiePresence};
use tauri::{AppHandle, Manager, WebviewWindow};
pub async fn storyteller_billing_window_thread(