diff --git a/crates/api_clients/grok_client/src/credentials/grok_client_secrets.rs b/crates/api_clients/grok_client/src/credentials/grok_client_secrets.rs
new file mode 100644
index 0000000000..15d2e5a7ee
--- /dev/null
+++ b/crates/api_clients/grok_client/src/credentials/grok_client_secrets.rs
@@ -0,0 +1,26 @@
+use crate::requests::index_page::pieces::baggage::Baggage;
+use crate::requests::index_page::pieces::sentry_trace::SentryTrace;
+use crate::requests::index_page::pieces::svg_path_data::SvgPathData;
+use crate::requests::index_page::pieces::verification_token::VerificationToken;
+use crate::requests::index_page::pieces::xsid_numbers::XsidNumbers;
+
+#[derive(Clone)]
+pub struct GrokClientSecrets {
+ /// Baggage is tag data from the index.html
+ pub baggage: Baggage,
+
+ /// Baggage is tag data from the index.html
+ pub sentry_trace: SentryTrace,
+
+ /// Baggage is tag data from the index.html
+ pub verification_token: VerificationToken,
+
+ /// The SVG path data to use (chosen via verification_token)
+ /// We selected one of four-ish possible SVG paths (of length >= 200) by
+ /// the `verification token -> animation index` algo.
+ pub svg_path_data: SvgPathData,
+
+ /// This doesn't come from the index.html
+ /// These numbers are separately loaded from the xsid javascript
+ pub numbers: XsidNumbers,
+}
diff --git a/crates/api_clients/grok_client/src/credentials/grok_cookies.rs b/crates/api_clients/grok_client/src/credentials/grok_cookies.rs
new file mode 100644
index 0000000000..d7ebcad944
--- /dev/null
+++ b/crates/api_clients/grok_client/src/credentials/grok_cookies.rs
@@ -0,0 +1,24 @@
+
+#[derive(Clone)]
+pub struct GrokCookies {
+ /// The entire cookies header (for now)
+ cookies: String,
+}
+
+impl GrokCookies {
+ pub fn new(cookies: String) -> Self {
+ Self { cookies }
+ }
+
+ pub fn as_str(&self) -> &str {
+ &self.cookies
+ }
+
+ pub fn as_bytes(&self) -> &[u8] {
+ self.cookies.as_bytes()
+ }
+
+ pub fn to_string(&self) -> String {
+ self.cookies.clone()
+ }
+}
diff --git a/crates/api_clients/grok_client/src/credentials/grok_full_credentials.rs b/crates/api_clients/grok_client/src/credentials/grok_full_credentials.rs
new file mode 100644
index 0000000000..ceaf7002cc
--- /dev/null
+++ b/crates/api_clients/grok_client/src/credentials/grok_full_credentials.rs
@@ -0,0 +1,15 @@
+use crate::credentials::grok_cookies::GrokCookies;
+use crate::datatypes::user_email::UserEmail;
+use crate::datatypes::user_id::UserId;
+
+/// Includes the cookies and all the magic other bits needed to call the API.
+#[derive(Clone)]
+pub struct GrokFullCredentials {
+ pub cookies: GrokCookies,
+
+ /// From index.html
+ pub user_email: Option,
+
+ /// From index.html
+ pub user_id: Option,
+}
diff --git a/crates/api_clients/grok_client/src/credentials/mod.rs b/crates/api_clients/grok_client/src/credentials/mod.rs
index e69de29bb2..e09affefd8 100644
--- a/crates/api_clients/grok_client/src/credentials/mod.rs
+++ b/crates/api_clients/grok_client/src/credentials/mod.rs
@@ -0,0 +1,3 @@
+pub mod grok_cookies;
+pub mod grok_full_credentials;
+pub mod grok_client_secrets;
\ No newline at end of file
diff --git a/crates/api_clients/grok_client/src/recipes/request_client_secrets.rs b/crates/api_clients/grok_client/src/recipes/request_client_secrets.rs
index 3ae848b548..9edb1fb810 100644
--- a/crates/api_clients/grok_client/src/recipes/request_client_secrets.rs
+++ b/crates/api_clients/grok_client/src/recipes/request_client_secrets.rs
@@ -1,3 +1,4 @@
+use crate::credentials::grok_client_secrets::GrokClientSecrets;
use crate::error::grok_error::GrokError;
use crate::error::grok_generic_api_error::GrokGenericApiError;
use crate::requests::index_page::get_index_page_and_scripts::{get_index_page_and_scripts, GetIndexPageAndScriptsArgs};
@@ -8,14 +9,8 @@ use crate::requests::index_page::parsers::index::parse_index_svg_paths::parse_sv
use crate::requests::index_page::parsers::index::parse_index_verification_token::parse_index_verification_token;
use crate::requests::index_page::parsers::script::parse_script_actions_and_xsid_script_path::parse_script_actions_and_xsid_script_path;
use crate::requests::index_page::parsers::script::parse_xsid_script_numbers::parse_xsid_script_numbers;
-use crate::requests::index_page::pieces::baggage::Baggage;
-use crate::requests::index_page::pieces::sentry_trace::SentryTrace;
-use crate::requests::index_page::pieces::svg_path_data::SvgPathData;
-use crate::requests::index_page::pieces::verification_token::VerificationToken;
-use crate::requests::index_page::pieces::xsid_numbers::XsidNumbers;
use crate::requests::index_page::utils::convert_verification_token_to_loading_anim::convert_verification_token_to_loading_anim;
use crate::requests::index_page::utils::select_svg_path_by_loading_anim::select_svg_path_by_loading_anim;
-use std::collections::HashMap;
pub struct RequestClientSecretsArgs<'a> {
pub cookies: &'a str,
@@ -25,31 +20,9 @@ pub struct RequestClientSecretsArgs<'a> {
// 1) baggage -- on index page
// 2) sentry_trace -- on index page
// 3) x_statsig
-#[derive(Clone)]
-pub struct ClientSecrets {
- /// From the index HTML meta tag
- pub baggage: Baggage,
-
- /// From the index HTML meta tag
- pub sentry_trace: SentryTrace,
-
- /// From the index HTML meta tag
- pub verification_token: VerificationToken,
-
- /// The SVG path data to use (chosen via verification_token)
- /// We selected one of four-ish possible SVG paths (of length >= 200) by
- /// the `verification token -> animation index` algo.
- pub svg_path: SvgPathData,
-
- /// Numbers from the xsid script.
- pub numbers: XsidNumbers,
-
- // /// Scripts (for later use)
- // pub scripts: HashMap,
-}
/// Load all the things needed to make requests.
-pub async fn request_client_secrets(args: RequestClientSecretsArgs<'_>) -> Result {
+pub async fn request_client_secrets(args: RequestClientSecretsArgs<'_>) -> Result {
let payloads = get_index_page_and_scripts(GetIndexPageAndScriptsArgs {
cookie: args.cookies,
@@ -81,7 +54,7 @@ pub async fn request_client_secrets(args: RequestClientSecretsArgs<'_>) -> Resul
let loading_anim = convert_verification_token_to_loading_anim(&verification_token)?;
- let svg_path = select_svg_path_by_loading_anim(&svg_paths, &loading_anim)?;
+ let svg_path_data = select_svg_path_by_loading_anim(&svg_paths, &loading_anim)?;
let actions_and_xsid_script = parse_script_actions_and_xsid_script_path(&payloads.scripts)?;
@@ -100,11 +73,11 @@ pub async fn request_client_secrets(args: RequestClientSecretsArgs<'_>) -> Resul
}.into());
}
- Ok(ClientSecrets {
+ Ok(GrokClientSecrets {
baggage,
sentry_trace,
verification_token,
- svg_path,
+ svg_path_data,
numbers,
//scripts: payloads.scripts,
})
@@ -128,7 +101,7 @@ mod tests {
println!("Baggage: {:?}", secrets.baggage);
println!("Sentry trace: {:?}", secrets.sentry_trace);
println!("Verification token: {:?}", secrets.verification_token);
- println!("SVG path: {:?}", secrets.svg_path);
+ println!("SVG path: {:?}", secrets.svg_path_data);
println!("Numbers: {:?}", secrets.numbers);
assert_eq!(1, 2);
diff --git a/crates/api_clients/grok_client/src/recipes/upload_image_and_generate_video.rs b/crates/api_clients/grok_client/src/recipes/upload_image_and_generate_video.rs
index 4df648c4f5..37c0c6dca7 100644
--- a/crates/api_clients/grok_client/src/recipes/upload_image_and_generate_video.rs
+++ b/crates/api_clients/grok_client/src/recipes/upload_image_and_generate_video.rs
@@ -155,7 +155,7 @@ mod tests {
println!("Verification Token: {:?}", secrets.verification_token);
println!("Sentry Trace: {:?}", secrets.sentry_trace);
println!("Numbers: {:?}", secrets.numbers);
- println!("Svg Path: {:?}", secrets.svg_path);
+ println!("Svg Path: {:?}", secrets.svg_path_data);
println!("Baggage: {:?}", secrets.baggage);
let result = upload_image_and_generate_video(UploadImageAndGenerateVideo {
@@ -164,7 +164,7 @@ mod tests {
baggage: &secrets.baggage,
sentry_trace: &secrets.sentry_trace,
verification_token: &secrets.verification_token,
- svg_data: &secrets.svg_path,
+ svg_data: &secrets.svg_path_data,
numbers: &secrets.numbers,
file: FileUploadSpec::Path("/Users/bt/Pictures/People/Ernest/0c120fb0-d6f3-11ec-9737-6f3f233a88c2.jpg"),
prompt: Some("A man in the forest runs away from a spooky ghost"),
diff --git a/crates/api_clients/grok_client/src/requests/index_page/parsers/index/parse_index_user_email.rs b/crates/api_clients/grok_client/src/requests/index_page/parsers/index/parse_index_user_email.rs
index f4448fcce6..22695ffe63 100644
--- a/crates/api_clients/grok_client/src/requests/index_page/parsers/index/parse_index_user_email.rs
+++ b/crates/api_clients/grok_client/src/requests/index_page/parsers/index/parse_index_user_email.rs
@@ -1,7 +1,6 @@
-use crate::datatypes::user_id::UserId;
+use crate::datatypes::user_email::UserEmail;
use once_cell::sync::Lazy;
use regex::Regex;
-use crate::datatypes::user_email::UserEmail;
/// Find the user email in the index.html payload
/// eg.
diff --git a/crates/api_clients/grok_client/src/requests/like_media/grok_like_media.rs b/crates/api_clients/grok_client/src/requests/like_media/grok_like_media.rs
index 358af2b318..9911898f00 100644
--- a/crates/api_clients/grok_client/src/requests/like_media/grok_like_media.rs
+++ b/crates/api_clients/grok_client/src/requests/like_media/grok_like_media.rs
@@ -171,7 +171,7 @@ mod tests {
println!("Verification Token: {:?}", secrets.verification_token);
println!("Sentry Trace: {:?}", secrets.sentry_trace);
println!("Numbers: {:?}", secrets.numbers);
- println!("Svg Path: {:?}", secrets.svg_path);
+ println!("Svg Path: {:?}", secrets.svg_path_data);
println!("Baggage: {:?}", secrets.baggage);
let request = GrokLikeMediaPost {
@@ -182,7 +182,7 @@ mod tests {
baggage: &secrets.baggage,
sentry_trace: &secrets.sentry_trace,
verification_token: &secrets.verification_token,
- svg_data: &secrets.svg_path,
+ svg_data: &secrets.svg_path_data,
numbers: &secrets.numbers,
};
diff --git a/crates/api_clients/grok_client/src/requests/video_gen_chat_conversation/grok_video_gen_chat_conversation.rs b/crates/api_clients/grok_client/src/requests/video_gen_chat_conversation/grok_video_gen_chat_conversation.rs
index 4cfa5a200d..7b06d8fe2d 100644
--- a/crates/api_clients/grok_client/src/requests/video_gen_chat_conversation/grok_video_gen_chat_conversation.rs
+++ b/crates/api_clients/grok_client/src/requests/video_gen_chat_conversation/grok_video_gen_chat_conversation.rs
@@ -218,7 +218,7 @@ mod tests {
println!("Verification Token: {:?}", secrets.verification_token);
println!("Sentry Trace: {:?}", secrets.sentry_trace);
println!("Numbers: {:?}", secrets.numbers);
- println!("Svg Path: {:?}", secrets.svg_path);
+ println!("Svg Path: {:?}", secrets.svg_path_data);
println!("Baggage: {:?}", secrets.baggage);
let request = GrokVideoGenChatConversationBuilder {
@@ -232,7 +232,7 @@ mod tests {
baggage: &secrets.baggage,
sentry_trace: &secrets.sentry_trace,
verification_token: &secrets.verification_token,
- svg_data: &secrets.svg_path,
+ svg_data: &secrets.svg_path_data,
numbers: &secrets.numbers,
};