mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-12-22 21:16:57 +00:00
foundation for signing capabilities
This commit is contained in:
parent
f84d829732
commit
90daf3069c
@ -22,8 +22,6 @@ import static awais.instagrabber.utils.Utils.clipboardManager;
|
||||
import static awais.instagrabber.utils.Utils.dataBox;
|
||||
import static awais.instagrabber.utils.Utils.datetimeParser;
|
||||
import static awais.instagrabber.utils.Utils.getInstalledTelegramPackage;
|
||||
import static awais.instagrabber.utils.Utils.isInstaInstalled;
|
||||
import static awais.instagrabber.utils.Utils.isInstagramInstalled;
|
||||
import static awais.instagrabber.utils.Utils.logCollector;
|
||||
import static awais.instagrabber.utils.Utils.notificationManager;
|
||||
import static awais.instagrabber.utils.Utils.settingsHelper;
|
||||
@ -41,7 +39,6 @@ public final class InstaApp extends MultiDexApplication {
|
||||
|
||||
final Context appContext = getApplicationContext();
|
||||
|
||||
isInstagramInstalled = isInstaInstalled(appContext);
|
||||
telegramPackage = getInstalledTelegramPackage(appContext);
|
||||
|
||||
if (dataBox == null)
|
||||
|
@ -1205,11 +1205,11 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
||||
if (!isLoggedIn && Utils.dataBox.getFavorite(main.userQuery) != null && v == main.mainBinding.btnFollow) {
|
||||
Utils.dataBox.delFavorite(new DataBox.FavoriteModel(main.userQuery,
|
||||
Long.parseLong(Utils.dataBox.getFavorite(main.userQuery).split("/")[1]),
|
||||
main.locationModel != null ? main.locationModel.getName() : main.userQuery));
|
||||
main.locationModel != null ? main.locationModel.getName() : main.userQuery.replaceAll("^@", "")));
|
||||
onRefresh();
|
||||
} else if (!isLoggedIn && v == main.mainBinding.btnFollow) {
|
||||
Utils.dataBox.addFavorite(new DataBox.FavoriteModel(main.userQuery, System.currentTimeMillis(),
|
||||
main.locationModel != null ? main.locationModel.getName() : main.userQuery));
|
||||
main.locationModel != null ? main.locationModel.getName() : main.userQuery.replaceAll("^@", "")));
|
||||
onRefresh();
|
||||
} else if (v == main.mainBinding.btnFollow) {
|
||||
new ProfileAction().execute("follow");
|
||||
|
@ -83,7 +83,6 @@ public final class StoryStatusFetcher extends AsyncTask<Void, Void, StoryModel[]
|
||||
models[i].setTappableShortCode(tappableObject.getJSONObject("media").getString(Constants.EXTRAS_SHORTCODE));
|
||||
}
|
||||
else if (tappableObject.optString("__typename").equals("GraphTappableStoryPoll")) {
|
||||
Log.d("austin_debug", "poll: "+url+" "+tappableObject);
|
||||
models[i].setPoll(new PollModel(
|
||||
tappableObject.getString("id"),
|
||||
tappableObject.getString("question"),
|
||||
|
@ -41,8 +41,18 @@ public final class Constants {
|
||||
public static final String EXTRAS_END_CURSOR = "endCursor";
|
||||
public static final String FEED = "feed";
|
||||
public static final String FEED_ORDER = "feedOrder";
|
||||
//////////////////////// EXTRAS ////////////////////////
|
||||
// spoof
|
||||
public static final String USER_AGENT = "Mozilla/5.0 (Linux; Android 8.1.0; motorola one Build/OPKS28.63-18-3; wv) " +
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/70.0.3538.80 Mobile Safari/537.36 " +
|
||||
"Instagram 72.0.0.21.98 Android (27/8.1.0; 320dpi; 720x1362; motorola; motorola one; deen_sprout; qcom; pt_BR; 132081645)";
|
||||
// see https://github.com/dilame/instagram-private-api/blob/master/src/core/constants.ts
|
||||
public static final String SUPPORTED_CAPABILITIES = "[ { \"name\": \"SUPPORTED_SDK_VERSIONS\", \"value\":" +
|
||||
" \"13.0,14.0,15.0,16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0,24.0,25.0,26.0,27.0,28.0,29.0,30.0,31.0," +
|
||||
"32.0,33.0,34.0,35.0,36.0,37.0,38.0,39.0,40.0,41.0,42.0,43.0,44.0,45.0,46.0,47.0,48.0,49.0,50.0,51.0," +
|
||||
"52.0,53.0,54.0,55.0,56.0,57.0,58.0,59.0,60.0,61.0,62.0,63.0,64.0,65.0,66.0\" }, { \"name\": \"FACE_TRACKER_VERSION\", " +
|
||||
"\"value\": 12 }, { \"name\": \"segmentation\", \"value\": \"segmentation_enabled\" }, { \"name\": \"COMPRESSION\", " +
|
||||
"\"value\": \"ETC2_COMPRESSION\" }, { \"name\": \"world_tracker\", \"value\": \"world_tracker_enabled\" }, { \"name\": " +
|
||||
"\"gyroscope\", \"value\": \"gyroscope_enabled\" } ]";
|
||||
public static final String SIGNATURE_VERSION = "4";
|
||||
public static final String SIGNATURE_KEY = "9193488027538fd3450b83b7d05286d4ca9599a0f7eeed90d8c85925698a05dc";
|
||||
}
|
@ -53,12 +53,16 @@ import java.net.HttpCookie;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.security.MessageDigest;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import awais.instagrabber.BuildConfig;
|
||||
import awais.instagrabber.R;
|
||||
import awais.instagrabber.activities.Main;
|
||||
@ -113,7 +117,6 @@ public final class Utils {
|
||||
public static final String CHANNEL_ID = "InstaGrabber", CHANNEL_NAME = "Instagrabber",
|
||||
NOTIF_GROUP_NAME = "awais.instagrabber.InstaNotif";
|
||||
public static boolean isChannelCreated = false;
|
||||
public static boolean isInstagramInstalled = false;
|
||||
public static String telegramPackage;
|
||||
public static ClipboardManager clipboardManager;
|
||||
public static DisplayMetrics displayMetrics = Resources.getSystem().getDisplayMetrics();
|
||||
@ -1223,6 +1226,26 @@ public final class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
public static String sign(final String message) {
|
||||
try {
|
||||
Mac hasher = Mac.getInstance("HmacSHA256");
|
||||
hasher.init(new SecretKeySpec(Constants.SIGNATURE_KEY.getBytes(), "HmacSHA256"));
|
||||
byte[] hash = hasher.doFinal(message.getBytes());
|
||||
StringBuffer hexString = new StringBuffer();
|
||||
for (int i = 0; i < hash.length; i++) {
|
||||
String hex = Integer.toHexString(0xff & hash[i]);
|
||||
if (hex.length() == 1) hexString.append('0');
|
||||
hexString.append(hex);
|
||||
}
|
||||
Log.d("austin_debug", "hash: " + hexString.toString());
|
||||
return hexString.toString() + "." + message;
|
||||
}
|
||||
catch (Throwable e) {
|
||||
Log.e("austin_debug", "sign: ", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static CharSequence getSpannableUrl(final String url) {
|
||||
if (Utils.isEmpty(url)) return url;
|
||||
final int httpIndex = url.indexOf("http:");
|
||||
@ -1353,20 +1376,6 @@ public final class Utils {
|
||||
activity.finish();
|
||||
}
|
||||
|
||||
public static boolean isInstaInstalled(@NonNull final Context context) {
|
||||
final PackageManager packageManager = context.getPackageManager();
|
||||
try {
|
||||
packageManager.getPackageInfo("com.instagram.android", 0);
|
||||
return true;
|
||||
} catch (final Exception e) {
|
||||
try {
|
||||
return packageManager.getApplicationInfo("com.instagram.android", 0).enabled;
|
||||
} catch (final Exception e1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getInstalledTelegramPackage(@NonNull final Context context) {
|
||||
final String[] packages = {
|
||||
|
Loading…
Reference in New Issue
Block a user