This commit is contained in:
Mylloon 2023-05-14 22:16:20 +02:00
parent 0b4ee8f714
commit 36b9ca18c9
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -1,6 +1,5 @@
open Pusk.Net open Pusk.Net
open Pusk.Utils open Pusk.Utils
(* open Twostep *)
type credentials = type credentials =
{ username : string { username : string
@ -65,7 +64,16 @@ let rec _inject_password session_id creds try_count =
let inject_password session_id creds = _inject_password session_id creds 1 let inject_password session_id creds = _inject_password session_id creds 1
let login_twitter ctx username password _secret = let inject_2fa _session_id secret _entry =
let _code =
match secret with
| Some seed -> Twostep.TOTP.code ~secret:seed ()
| None -> raise (Any "No TOTP code given, but TOTP required")
in
()
;;
let login_twitter ctx username password secret =
(* Navigate to login page and wait for page loaded*) (* Navigate to login page and wait for page loaded*)
ignore (navigate ctx.session_id "https://twitter.com/i/flow/login"); ignore (navigate ctx.session_id "https://twitter.com/i/flow/login");
Unix.sleep 5; Unix.sleep 5;
@ -75,12 +83,10 @@ let login_twitter ctx username password _secret =
(* Find password input *) (* Find password input *)
inject_password ctx.session_id creds; inject_password ctx.session_id creds;
(* Detection of 2FA *) (* Detection of 2FA *)
(* TODO *) match find ctx.session_id (XPath "XPATH_TOTP") with
(* Generate code if possible *) | [] -> ()
(* let code = | _ as l ->
match secret with if List.length l > 1
| Some seed -> Twostep.TOTP.code ~secret:seed () then raise (Any "Too many element found as the username input")
| None -> raise (Any "No TOTP code given, but TOTP required") else inject_2fa ctx.session_id secret (List.nth l 0)
in *)
()
;; ;;