Skip to content

Commit

Permalink
increase version _ remove dead 2fa code
Browse files Browse the repository at this point in the history
  • Loading branch information
mrhcjones committed Apr 21, 2024
1 parent ca868d3 commit 1cdc1d0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 40 deletions.
40 changes: 1 addition & 39 deletions lib/client/client_regular_account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -370,44 +370,6 @@ class XRegularAccount extends ChangeNotifier {
throw Exception("Return Status is (${response.statusCode}), it should be 200");
}

Future<void> Pass2FA(String authCode, Map<String, String> userAgentHeader) async {
var body = {
"flow_token": flowTokenPassword,
"subtask_inputs": [
{
"subtask_id": "LoginTwoFactorAuthChallenge",
"enter_text": {"text": authCode, "link": "next_link"}
}
]
};
var request = http.Request("Post", Uri.parse('https://api.twitter.com/1.1/onboarding/task.json'));
request.headers.addAll(userAgentHeader);
request.headers.addAll({"content-type": "application/json"});
request.headers.addAll({"authorization": bearerToken});
request.headers.addAll({"x-guest-token": gtToken});
request.headers.addAll({"Cookie": cookies.join(";")});
request.headers.addAll({"Host": "api.twitter.com"});
request.body = json.encode(body);
var response = await client.send(request);
if (response.statusCode == 200) {
final stringData = await response.stream.transform(utf8.decoder).join();
final exp = RegExp(r'flow_token":"(.+?)"');
RegExpMatch? match = exp.firstMatch(stringData);
flowToken2FA = match?.group(1).toString();
} else if (response.statusCode == 400) {
final stringData = await response.stream.transform(utf8.decoder).join();
if (stringData.contains("errors")) {
var parsedError = json.decode(stringData);
var errors = StringBuffer();
for (var error in parsedError["errors"]) {
errors.writeln(error["message"] ?? "null");
}
throw Exception(errors);
}
} else
throw Exception("2fa Return Status is (${response.statusCode}), it should be 200");
}

Future<void> GetAuthTokenCsrf(Map<String, String> userAgentHeader) async {
var body = {
"flow_token": flowTokenPassword,
Expand Down Expand Up @@ -545,7 +507,7 @@ class XRegularAccount extends ChangeNotifier {
await GetFlowToken2(userAgentHeader);
await PassUsername(username, email);
await PassPassword(password, userAgentHeader);
//if (authCode != null) await Pass2FA(authCode.toString(), userAgentHeader);

await GetAuthTokenCsrf(userAgentHeader);
await BuildAuthHeader();
} on Exception catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html

version: 3.4.1+300200120
version: 3.4.2+300200124

environment:
sdk: ">=2.18.0 <3.0.0"
Expand Down

0 comments on commit 1cdc1d0

Please sign in to comment.