25-3/11/1
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:ui';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
@@ -9,6 +10,7 @@ import 'package:url_launcher/url_launcher.dart';
|
||||
import '../../constant/box_name.dart';
|
||||
import '../../constant/colors.dart';
|
||||
import '../../main.dart';
|
||||
import '../../print.dart';
|
||||
import 'encrypt_decrypt.dart';
|
||||
|
||||
Future<void> checkForUpdate(BuildContext context) async {
|
||||
@@ -40,24 +42,28 @@ checkForBounusInvitation() {
|
||||
// }
|
||||
// return '';
|
||||
// }
|
||||
getDeviceFingerprint() async {
|
||||
final deviceInfo = await DeviceInfoPlugin().deviceInfo;
|
||||
var deviceData;
|
||||
// getDeviceFingerprint() async {
|
||||
// final deviceInfo = await DeviceInfoPlugin().deviceInfo;
|
||||
// var deviceData;
|
||||
|
||||
if (Platform.isAndroid) {
|
||||
deviceData = deviceInfo.data;
|
||||
} else if (Platform.isIOS) {
|
||||
deviceData = deviceInfo.data;
|
||||
}
|
||||
// if (Platform.isAndroid) {
|
||||
// deviceData = deviceInfo.data;
|
||||
// Log.print('deviceData: ${jsonEncode(deviceData)}');
|
||||
// } else if (Platform.isIOS) {
|
||||
// deviceData = deviceInfo.data;
|
||||
// }
|
||||
|
||||
final String deviceId =
|
||||
deviceData['androidId'] ?? deviceData['identifierForVendor'];
|
||||
final String deviceModel = deviceData['model'];
|
||||
final String osVersion = deviceData['systemVersion'];
|
||||
// final String deviceId =
|
||||
// deviceData['device'] ?? deviceData['identifierForVendor'];
|
||||
// final String deviceModel = deviceData['model'];
|
||||
// final String osVersion = deviceData['systemVersion'];
|
||||
|
||||
return EncryptionHelper.instance
|
||||
.encryptData('${deviceId}_${deviceModel}_$osVersion');
|
||||
}
|
||||
// Log.print('fingr: ${'${deviceId}_${deviceModel}_$osVersion'}');
|
||||
// Log.print('deviceModel: ${deviceModel}');
|
||||
// Log.print('osVersion: ${osVersion}');
|
||||
// return EncryptionHelper.instance
|
||||
// .encryptData('${deviceId}_${deviceModel}_$osVersion');
|
||||
// }
|
||||
|
||||
void showUpdateDialog(BuildContext context) {
|
||||
final String storeUrl = Platform.isAndroid
|
||||
@@ -232,12 +238,7 @@ class SecurityHelper {
|
||||
// debugPrint("Bundle ID: $bundleId"); // Print the bundle ID
|
||||
|
||||
// Check for security risks and potentially show a warning
|
||||
if (isNotTrust ||
|
||||
isJailBroken ||
|
||||
isTampered ||
|
||||
isDevMode ||
|
||||
isOnExternalStorage ||
|
||||
!isRealDevice) {
|
||||
if (isJailBroken || isRealDevice == false || isTampered) {
|
||||
// print("security_warning".tr); //using easy_localization
|
||||
// Use a more robust approach to show a warning, like a dialog:
|
||||
_showSecurityWarning();
|
||||
@@ -278,3 +279,43 @@ class SecurityHelper {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DeviceHelper {
|
||||
static Future<String> getDeviceFingerprint() async {
|
||||
final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
|
||||
var deviceData;
|
||||
|
||||
try {
|
||||
if (Platform.isAndroid) {
|
||||
// Fetch Android-specific device information
|
||||
AndroidDeviceInfo androidInfo = await deviceInfoPlugin.androidInfo;
|
||||
deviceData = androidInfo.toMap(); // Convert to a map for easier access
|
||||
// Log.print('deviceData: ${jsonEncode(deviceData)}');
|
||||
} else if (Platform.isIOS) {
|
||||
// Fetch iOS-specific device information
|
||||
IosDeviceInfo iosInfo = await deviceInfoPlugin.iosInfo;
|
||||
deviceData = iosInfo.toMap(); // Convert to a map for easier access
|
||||
} else {
|
||||
throw UnsupportedError('Unsupported platform');
|
||||
}
|
||||
|
||||
// Extract relevant device information
|
||||
final String deviceId = Platform.isAndroid
|
||||
? deviceData['androidId'] ?? deviceData['serialNumber'] ?? 'unknown'
|
||||
: deviceData['identifierForVendor'] ?? 'unknown';
|
||||
|
||||
final String deviceModel = deviceData['model'] ?? 'unknown';
|
||||
final String osVersion = Platform.isAndroid
|
||||
? deviceData['version']['release'] ?? 'unknown'
|
||||
: deviceData['systemVersion'] ?? 'unknown';
|
||||
|
||||
// Log the extracted information
|
||||
|
||||
// Generate and return the encrypted fingerprint
|
||||
final String fingerprint = '${deviceId}_${deviceModel}_$osVersion';
|
||||
return EncryptionHelper.instance.encryptData(fingerprint);
|
||||
} catch (e) {
|
||||
throw Exception('Failed to generate device fingerprint');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,16 +36,13 @@ class AppInitializer {
|
||||
List<Map<String, dynamic>> links = [];
|
||||
|
||||
Future<void> initializeApp() async {
|
||||
// Log.print('box.read("jwt"): ${box.read(BoxName.jwt)}');
|
||||
if (box.read(BoxName.jwt) == null) {
|
||||
await LoginController().getJWT();
|
||||
} else {
|
||||
// print('firstTimeLoadKey ${box.read(BoxName.firstTimeLoadKey)}');
|
||||
bool isTokenExpired = JwtDecoder.isExpired(X
|
||||
.r(X.r(X.r(box.read(BoxName.jwt), cn), cC), cs)
|
||||
.toString()
|
||||
.split(AppInformation.addd)[0]);
|
||||
// Log.print('isTokenExpired: $isTokenExpired');
|
||||
if (isTokenExpired) {
|
||||
await LoginController().getJWT();
|
||||
}
|
||||
@@ -69,7 +66,6 @@ class AppInitializer {
|
||||
try {
|
||||
var res =
|
||||
await CRUD().get(link: AppLink.getLocationAreaLinks, payload: {});
|
||||
// Log.print('res: ${res}');
|
||||
if (res != 'failure') {
|
||||
links = List<Map<String, dynamic>>.from(jsonDecode(res)['message']);
|
||||
await box.remove(BoxName.locationName);
|
||||
@@ -89,8 +85,6 @@ class AppInitializer {
|
||||
await box.write(BoxName.paymentLink,
|
||||
EncryptionHelper.instance.decryptData(links[4]['server_link']));
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error fetching or decoding location data: $e');
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user