use anyhow::Error;
use regex::Regex;
use reqwest::{
Client,
header::{
COOKIE,
CONTENT_LENGTH,
}
};
pub async fn is_cookie_valid(cookie: &String) -> Result<bool, Error> {
if is_cookie_mtch_regx(cookie)? {
let client = Client::new();
let response = client
.post("https://auth.roblox.com/v2/logout")
.header(COOKIE, format!(".ROBLOSECURITY={cookie};"))
.header(CONTENT_LENGTH, "0")
.send()
.await?;
let token_header = response.headers().get("x-csrf-token");
return Ok(token_header.is_some());
}
Ok(false)
}
fn is_cookie_mtch_regx(cookie: &str) -> Result<bool, Error> {
let cookie_reg = Regex::new("_|WARNING:-DO-NOT-SHARE-THIS.--Sharing-this-will-allow-someone-to-log-in-as-you-and-to-steal-your-ROBUX-and-items.|_ABC12")?;
Ok(cookie_reg.is_match(cookie))
}