diff --git a/.env b/.env
index a041842..b4f9388 100644
--- a/.env
+++ b/.env
@@ -21,23 +21,7 @@ seferPaymentServer=https://seferpw.shop/sefer
seferCairoServer=https://server.sefer.live/sefer.click/sefer
seferGizaServer=https://gizasefer.online/sefer
anthropicAIkeySeferNewHamzaayedpython=zg-qbc-qvo39-vCB-WnzEwFNArO0YlTapvfhtmguKWsXJSKqg_NZSjHBYVXMZK1yUK88SobdckV0KuPaBh0c_WHtGsRO_439PBk-e2QqgkQQXrXlBl
-
-privateKeyFCM='''
-{
- "type": "service_account",
- "project_id": "ride-b1bd8",
- "private_key_id": "75e817c0b902db2ef35edf2c2bd159dec1f13249",
- "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQD0zH9TQGDQHUv3\\na3/JAD1UKPwAp3wNKT0a6fxiIzjI3JxQWI30QvZCcfl6CdMhIcydX1ncSaYTcEeC\\n/AdPVCPkqyJx1YIGGg6P/mRzCWeaN8fsp6z250m5vcObDCZc3dbJEkepbep+6FPY\\n21m3KO+AHh1glgsTGZOTm5xiU8NGXpdk2QEh8wpiIIlR/HuKwVw9g8urNe3Sno+U\\nDm3z37iFqvZdmpqO8aWTJu6beb3hsREK9XK2I9JqC2JUwiGQRo3idOvPP6hkqrWx\\nKSX96vglQFYfakvJdDp2ZATOlpBYPMtS/IWhJ985u58TSS+Kl8qpnpaZBSxgJirf\\nhWzhnKLfAgMBAAECggEAJP785SePGhS7ZN6ltspm+l+hSjYFrPWFCxq+rlQ1YkHZ\\nC9l+RqKSFhOkiPmQI2s4wbXl3kFxLHHlFNoi/q2wKQBmGb8TQfnRJpjjNHGA61Ev\\n0Ue7/6qPvVb9B2MsLw/FxKiTFPuMG3bgKR9pbSFuJLYoaW7zqITOhVnYphGTqwAY\\nBVVcvISSLvELDmH9VZcv/9DVqVlqbbESHWh1Z4W6XGPoEqeDH/upNTyQQ/46Msgm\\nTGE6VqLHpWuSf6SqHp+r0Y0lI3vIPM1vz5FAJDJbOE/enHa0fSup0OHSMxl0HVMn\\nnO1yrGF3vsIPOej5HKr5d71bEIckzk73/yjNC1/mDQKBgQD7RtUvc9omsSsFMJ6e\\nBASAn6Dktx/QY/XNJjFzHQj69cywLDe5t5AL2gUi3phQ2oqB5XJdwnd5bTIEPEPZ\\nDOuOai2802p6FJk6kjmZAMVGx5JtXBH+vs6jrmQQSMiKbjwN1TT6xIWakvLOonUi\\nX6ZvjYYjU/E0YJU3jSiXWEr76wKBgQD5Zn4SouJ6BCDZMbausJVMBkk3qxsYooip\\np89WakC6e7AZinpkRcqjGGV9GOvc8crJs6fyXAA9ORepGP47Mc0ZrDssOkstznsM\\npr8R0S6MKwEZaT9ixOHdOcLZ47ps+JzA2Wr4KN2OvFHksUkB/46ATD1j9WZVgB8M\\namsYp/Y73QKBgHOo+PvsoZ9psVmkNX6abtAdqdtdB0HOoRea2uwXk0ig12TIFaZg\\nfedWpUKVnxqoXVTJHklV99RmlL0qWDiSH+LfsMnXro0e6iDxqZ1po2Se/CFmXcoa\\nXdctsFVmixhdATuExewfhTfPKABA+xWlXWC/jdy5CK+JPWXijaqMM4edAoGAE5Bj\\nsWiPpYyvWvpYX0nA3G7dzX0hqgQN/mkIjbnWDArp3IcNZNJIvBSM2Yxb7EAXbU0n\\njo6DAkp5Pa2VO+WDNlFZbvW/sf8xjeOCt44WPa6d7nVgIIpbQXRngZoopKW3/jTP\\n/FmQT8McFXmGxZ5belsAsdetSGW9icbLUerTGQ0CgYEAmf/G8Ag3XxmqTXvvHuv2\\n14OP7WnrVqkEMnydrftEwn4peXd/Lz+/GYX5Zc4ZoNgbN8IvZ5z0+OmRsallsbiW\\nBw0/tc68CjzxXOvReWxDluUopqWVGj5tlGqE5xUDku9SWJSxbkiQ3rqutzBdPXpr\\noqHwPyDrmK/Zgqn+uiIm4Ck=\\n-----END PRIVATE KEY-----\n"
- ,
- "client_email": "firebase-adminsdk-o2wqi@ride-b1bd8.iam.gserviceaccount.com",
- "client_id": "111210077025005706623",
- "auth_uri": "https://accounts.google.com/o/oauth2/auth",
- "token_uri": "https://oauth2.googleapis.com/token",
- "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
- "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-o2wqi%40ride-b1bd8.iam.gserviceaccount.com",
- "universe_domain": "googleapis.com"
-}
-'''
+getapiKey=https://server.sefer.live/sefer.click/sefer/ride/apiKey/get.php
cohere=Aulwd8y5SPWos0hJhG0toUf8gOhUUrpf5Q2TPmVGXrXlBl
claudeAiAPI=zg-qbc-qvo39-xWOxIGwWTOzCFBnIYSKKhfyz_KVAvrH-6_4ZEJL68G_QBH26oeTOMMoQug9KuOjjKSP_A4S3SUDlbxR9duVzoQ-MkX_UQQQXrXlBl
payPalClientId=QALymfNI5Tzt4s-ysoz6vD4_nqX0SUtkC_qYV-Ugk5gaM_8Z-kg4L53k8Uux_4jEWXDkNpXGSWPpIzDFXrXlBl
@@ -62,7 +46,12 @@ payMobOutPassword='D2zJFxkE#LN3vz38z2dYxpNfWXrXlBl'
payMobOutUserName='zjujl_qvo_fwjfgjlXrXlBl'
keyOfApp=nqryjp@1737wqnmqqsjyzjujljksvceiXrXlBl
initializationVector=abcdefghijklmnop
-
+sss_pass=wqnmqqsjyvwv:nqrYJP@17378XrXlBl
+sss_encryptionSalt=zg-vlie-2l1ZlpxiLJ6wQOvbb4TnC9XrxgUEyVQIu6TID4qP4FUUqoS5XrXlBl
+addd=BlBlNl
+allowed=TripzDriver:
+passnpassenger=hbgbitbXrXrBr
+newId=new
a=q
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 90dae8c..98bb790 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -55,8 +55,8 @@ android {
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdk = 23
targetSdk = flutter.targetSdkVersion
- versionCode = 135
- versionName = '2.0.135'
+ versionCode = 136
+ versionName = '2.0.136'
multiDexEnabled =true
}
@@ -89,7 +89,7 @@ flutter {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
-
+ implementation 'com.scottyab:rootbeer-lib:0.1.0'
implementation 'com.stripe:paymentsheet:20.52.2'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.4'
diff --git a/android/app/src/main/kotlin/com/sefer_driver/MainActivity.kt b/android/app/src/main/kotlin/com/sefer_driver/MainActivity.kt
index fee2cc8..c726bc5 100644
--- a/android/app/src/main/kotlin/com/sefer_driver/MainActivity.kt
+++ b/android/app/src/main/kotlin/com/sefer_driver/MainActivity.kt
@@ -1,21 +1,95 @@
package com.sefer_driver
-import android.content.Intent
+// import android.content.Intent
+// import io.flutter.embedding.android.FlutterFragmentActivity
+// import io.flutter.embedding.engine.FlutterEngine
+
+// class MainActivity : FlutterFragmentActivity() {
+// override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
+// try {
+// super.configureFlutterEngine(MyApplication.flutterEngine)
+// } catch (e: UninitializedPropertyAccessException) {
+// super.configureFlutterEngine(flutterEngine)
+// }
+// }
+
+// private fun bringAppToForeground() {
+// val intent = Intent(this, MainActivity::class.java)
+// intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
+// startActivity(intent)
+// }
+// }
+import android.app.AlertDialog
+import android.os.Bundle
+import android.util.Log
import io.flutter.embedding.android.FlutterFragmentActivity
-import io.flutter.embedding.engine.FlutterEngine
+import java.util.*
class MainActivity : FlutterFragmentActivity() {
- override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
- try {
- super.configureFlutterEngine(MyApplication.flutterEngine)
- } catch (e: UninitializedPropertyAccessException) {
- super.configureFlutterEngine(flutterEngine)
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+
+ Log.d("DEBUG", "onCreate executed - Checking root status...")
+
+ // بدء فحص الأمان
+ performSecurityChecks()
+ }
+
+ private fun performSecurityChecks() {
+ val rootDetection = RootDetection
+
+ val isRooted = rootDetection.isRooted()
+ val isDevMode = rootDetection.isDevMode(this)
+ val isTampered = rootDetection.isTampered(this)
+ val isRealDevice = rootDetection.isRealDevice()
+ val isOnExternalStorage = rootDetection.isOnExternalStorage()
+ val isNotTrust = rootDetection.isNotTrust()
+ val checkForIssues = rootDetection.checkForIssues()
+
+ // Log.d("DEBUG", "Security Check Results:")
+ // Log.d("DEBUG", "isRooted: $isRooted")
+ // Log.d("DEBUG", "isDevMode: $isDevMode")
+ // Log.d("DEBUG", "isTampered: $isTampered")
+ // Log.d("DEBUG", "isRealDevice: $isRealDevice")
+ // Log.d("DEBUG", "isOnExternalStorage: $isOnExternalStorage")
+ // Log.d("DEBUG", "isNotTrust: $isNotTrust")
+ // Log.d("DEBUG", "checkForIssues: $checkForIssues")
+
+ if (isRooted || isTampered || !isRealDevice || isOnExternalStorage || isNotTrust) {
+ // Log.e("DEBUG", "Security issue detected! Showing dialog.")
+ showSecurityWarningDialog()
+ } else {
+ // Log.d(
+ // "DEBUG",
+ // getString(R.string.device_secure)
+ // ) // Using dynamic string based on the device language
}
}
- private fun bringAppToForeground() {
- val intent = Intent(this, MainActivity::class.java)
- intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
- startActivity(intent)
+ private fun showSecurityWarningDialog() {
+ val builder = AlertDialog.Builder(this)
+ builder.setTitle(getString(R.string.security_warning_title)) // Title based on language
+ builder.setMessage(
+ getString(R.string.security_warning_message)
+ ) // Message based on language
+
+ builder.setPositiveButton(getString(R.string.exit_button)) { _, _ ->
+ Log.e("DEBUG", "User clicked exit. Closing app.")
+ clearAppDataAndExit()
+ }
+
+ builder.setCancelable(false)
+ val alertDialog = builder.create()
+ alertDialog.show()
+ }
+
+ private fun clearAppDataAndExit() {
+ // حذف جميع البيانات هنا، مثل ملفات التخزين وبيانات التطبيق
+ // يمكنك استخدام SharedPreferences أو قاعدة بيانات
+ Log.d("DEBUG", "Clearing app data...")
+
+ // يمكنك استخدام كود لحذف جميع البيانات (SharedPreferences, DB, ملفات)
+ // ثم إغلاق التطبيق:
+ finishAffinity() // يغلق جميع الأنشطة ويفتح نافذة جديدة
}
}
diff --git a/android/app/src/main/kotlin/com/sefer_driver/RootDetection.kt b/android/app/src/main/kotlin/com/sefer_driver/RootDetection.kt
new file mode 100644
index 0000000..86c82bd
--- /dev/null
+++ b/android/app/src/main/kotlin/com/sefer_driver/RootDetection.kt
@@ -0,0 +1,61 @@
+package com.sefer_driver
+
+import android.content.Context
+import android.os.Build
+import android.os.Environment
+import android.provider.Settings
+import com.scottyab.rootbeer.RootBeer
+import java.io.File
+
+object RootDetection {
+
+ fun isRooted(): Boolean {
+ val paths =
+ arrayOf(
+ "/system/app/Superuser.apk",
+ "/system/xbin/su",
+ "/system/bin/su",
+ "/system/bin/magisk",
+ "/system/xbin/magisk",
+ "/sbin/magisk"
+ )
+ for (path in paths) {
+ if (File(path).exists()) {
+ return true
+ }
+ }
+ return false
+ }
+
+ fun isDevMode(context: Context): Boolean {
+ return Settings.Global.getInt(
+ context.contentResolver,
+ Settings.Global.DEVELOPMENT_SETTINGS_ENABLED,
+ 0
+ ) == 1
+ }
+
+ fun isTampered(context: Context): Boolean {
+ val rootBeer = RootBeer(context)
+ return rootBeer.isRooted
+ }
+
+ fun checkForIssues(): Boolean {
+ // يمكنك إضافة المزيد من الفحوصات حسب حاجتك
+ return false // نفترض أنه لا توجد مشاكل للأجهزة غير المتجذرة
+ }
+
+ fun isRealDevice(): Boolean {
+ return !Build.FINGERPRINT.contains("generic") && !Build.MODEL.contains("google_sdk")
+ }
+
+ fun isOnExternalStorage(): Boolean {
+ return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT &&
+ Environment.getExternalStorageState() == Environment.MEDIA_MOUNTED
+ }
+
+ fun isNotTrust(): Boolean {
+ // مثال تحقق من الثقة (قد تحتاج لتطوير هذا حسب متطلباتك)
+ return false // نفترض أن الجهاز موثوق
+ }
+}
diff --git a/android/app/src/main/res/values-ar/strings.xml b/android/app/src/main/res/values-ar/strings.xml
new file mode 100644
index 0000000..6b7cb35
--- /dev/null
+++ b/android/app/src/main/res/values-ar/strings.xml
@@ -0,0 +1,6 @@
+
+ تحذير أمني
+ تم اكتشاف مشكلة أمنية أو تعديل على هذا الجهاز. لا يمكن تشغيل التطبيق على هذا الجهاز.
+ إغلاق التطبيق
+ الجهاز آمن. الاستمرار بشكل طبيعي.
+
\ No newline at end of file
diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml
index 5490443..ef37fb6 100644
--- a/android/app/src/main/res/values/strings.xml
+++ b/android/app/src/main/res/values/strings.xml
@@ -4,6 +4,11 @@
AIzaSyCyfwRXTwSTLOFQSQgN5p7QZgGJVZnEKq0
FCM Notifications
Notifications from Firebase Cloud Messaging
+ Security Warning
+ A security issue or modification has been detected on
+ this device. The app cannot run on this device.
+ Exit App
+ Device is secure. Proceeding normally.
\ No newline at end of file
diff --git a/android/gradle.properties b/android/gradle.properties
index 673be0c..e6860ca 100644
--- a/android/gradle.properties
+++ b/android/gradle.properties
@@ -1,8 +1,8 @@
-# org.gradle.jvmargs=-Xmx1536M
+org.gradle.jvmargs=-Xmx4096M
android.useAndroidX=true
android.enableJetifier=true
-org.gradle.jvmargs=-Xmx4096m
android.defaults.buildfeatures.buildconfig=true
-android.nonTransitiveRClass=false
-android.nonFinalResIds=false
+android.nonTransitiveRClass=true
+android.nonFinalResIds=true
+dart.obfuscation=true
android.enableR8.fullMode=true
\ No newline at end of file
diff --git a/ios/Podfile.lock b/ios/Podfile.lock
index b0a7bc3..3c98409 100644
--- a/ios/Podfile.lock
+++ b/ios/Podfile.lock
@@ -89,6 +89,8 @@ PODS:
- GoogleUtilities/UserDefaults (~> 8.0)
- nanopb (~> 3.30910.0)
- Flutter (1.0.0)
+ - flutter_app_group_directory (0.0.1):
+ - Flutter
- flutter_contacts (0.0.1):
- Flutter
- flutter_image_compress_common (1.0.0):
@@ -195,6 +197,10 @@ PODS:
- TOCropViewController (~> 2.7.4)
- image_picker_ios (0.0.1):
- Flutter
+ - IOSSecuritySuite (1.9.11)
+ - jailbreak_root_detection (1.0.1):
+ - Flutter
+ - IOSSecuritySuite (~> 1.9.10)
- just_audio (0.0.1):
- Flutter
- libwebp (1.3.2):
@@ -209,6 +215,8 @@ PODS:
- libwebp/sharpyuv (1.3.2)
- libwebp/webp (1.3.2):
- libwebp/sharpyuv
+ - live_activities (0.0.1):
+ - Flutter
- local_auth_darwin (0.0.1):
- Flutter
- FlutterMacOS
@@ -231,6 +239,8 @@ PODS:
- permission_handler_apple (9.3.0):
- Flutter
- PromisesObjC (2.4.0)
+ - quick_actions_ios (0.0.1):
+ - Flutter
- RecaptchaInterop (100.0.0)
- record_darwin (1.0.0):
- Flutter
@@ -310,6 +320,7 @@ DEPENDENCIES:
- FirebaseCore
- FirebaseMessaging
- Flutter (from `Flutter`)
+ - flutter_app_group_directory (from `.symlinks/plugins/flutter_app_group_directory/ios`)
- flutter_contacts (from `.symlinks/plugins/flutter_contacts/ios`)
- flutter_image_compress_common (from `.symlinks/plugins/flutter_image_compress_common/ios`)
- flutter_inappwebview_ios (from `.symlinks/plugins/flutter_inappwebview_ios/ios`)
@@ -321,12 +332,15 @@ DEPENDENCIES:
- google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/darwin`)
- image_cropper (from `.symlinks/plugins/image_cropper/ios`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
+ - jailbreak_root_detection (from `.symlinks/plugins/jailbreak_root_detection/ios`)
- just_audio (from `.symlinks/plugins/just_audio/ios`)
+ - live_activities (from `.symlinks/plugins/live_activities/ios`)
- local_auth_darwin (from `.symlinks/plugins/local_auth_darwin/darwin`)
- location (from `.symlinks/plugins/location/ios`)
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
+ - quick_actions_ios (from `.symlinks/plugins/quick_actions_ios/ios`)
- record_darwin (from `.symlinks/plugins/record_darwin/ios`)
- share (from `.symlinks/plugins/share/ios`)
- sign_in_with_apple (from `.symlinks/plugins/sign_in_with_apple/ios`)
@@ -359,6 +373,7 @@ SPEC REPOS:
- GoogleUtilities
- GTMAppAuth
- GTMSessionFetcher
+ - IOSSecuritySuite
- libwebp
- Mantle
- nanopb
@@ -394,6 +409,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/firebase_messaging/ios"
Flutter:
:path: Flutter
+ flutter_app_group_directory:
+ :path: ".symlinks/plugins/flutter_app_group_directory/ios"
flutter_contacts:
:path: ".symlinks/plugins/flutter_contacts/ios"
flutter_image_compress_common:
@@ -416,8 +433,12 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/image_cropper/ios"
image_picker_ios:
:path: ".symlinks/plugins/image_picker_ios/ios"
+ jailbreak_root_detection:
+ :path: ".symlinks/plugins/jailbreak_root_detection/ios"
just_audio:
:path: ".symlinks/plugins/just_audio/ios"
+ live_activities:
+ :path: ".symlinks/plugins/live_activities/ios"
local_auth_darwin:
:path: ".symlinks/plugins/local_auth_darwin/darwin"
location:
@@ -428,6 +449,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
permission_handler_apple:
:path: ".symlinks/plugins/permission_handler_apple/ios"
+ quick_actions_ios:
+ :path: ".symlinks/plugins/quick_actions_ios/ios"
record_darwin:
:path: ".symlinks/plugins/record_darwin/ios"
share:
@@ -469,6 +492,7 @@ SPEC CHECKSUMS:
FirebaseInstallations: 6ef4a1c7eb2a61ee1f74727d7f6ce2e72acf1414
FirebaseMessaging: f8a160d99c2c2e5babbbcc90c4a3e15db036aee2
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
+ flutter_app_group_directory: d2c3337f424828558953172f9378d00df9b7756d
flutter_contacts: edb1c5ce76aa433e20e6cb14c615f4c0b66e0983
flutter_image_compress_common: ec1d45c362c9d30a3f6a0426c297f47c52007e3e
flutter_inappwebview_ios: 6f63631e2c62a7c350263b13fa5427aedefe81d4
@@ -488,8 +512,11 @@ SPEC CHECKSUMS:
GTMSessionFetcher: 5aea5ba6bd522a239e236100971f10cb71b96ab6
image_cropper: 37d40f62177c101ff4c164906d259ea2c3aa70cf
image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1
+ IOSSecuritySuite: b51056d5411aee567153ca86ce7f6edfdc5d2654
+ jailbreak_root_detection: b95de80c3e51eec1fc7d0225784d2fc038fa95ed
just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa
libwebp: 1786c9f4ff8a279e4dac1e8f385004d5fc253009
+ live_activities: 5a5ddcfe2bd2cbbe7555a5da9c35b07d1a4ff2e8
local_auth_darwin: 66e40372f1c29f383a314c738c7446e2f7fdadc3
location: d5cf8598915965547c3f36761ae9cc4f4e87d22e
Mantle: c5aa8794a29a022dfbbfc9799af95f477a69b62d
@@ -499,6 +526,7 @@ SPEC CHECKSUMS:
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
+ quick_actions_ios: 56f3cbaa71e94f212838d1f9fe354bd0734779bf
RecaptchaInterop: 7d1a4a01a6b2cb1610a47ef3f85f0c411434cb21
record_darwin: 3b1a8e7d5c0cbf45ad6165b4d83a6ca643d929c3
SDWebImage: 73c6079366fea25fa4bb9640d5fb58f0893facd8
diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj
index c14b593..067e56c 100644
--- a/ios/Runner.xcodeproj/project.pbxproj
+++ b/ios/Runner.xcodeproj/project.pbxproj
@@ -16,6 +16,9 @@
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
+ C604FDB02D6C8D6A00CF8873 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = C604FDAF2D6C8D6000CF8873 /* Constants.swift */; };
+ C604FDB22D6C953400CF8873 /* JailbreakDetection.swift in Sources */ = {isa = PBXBuildFile; fileRef = C604FDB12D6C953100CF8873 /* JailbreakDetection.swift */; };
+ C604FDB52D6C96D000CF8873 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = C604FDB32D6C96D000CF8873 /* Localizable.strings */; };
C624C4642BD56D34002834AF /* tone1.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = C624C45C2BD56D34002834AF /* tone1.mp3 */; };
C624C4652BD56D34002834AF /* start.wav in Resources */ = {isa = PBXBuildFile; fileRef = C624C45D2BD56D34002834AF /* start.wav */; };
C624C4672BD56D34002834AF /* promo.wav in Resources */ = {isa = PBXBuildFile; fileRef = C624C45F2BD56D34002834AF /* promo.wav */; };
@@ -73,6 +76,9 @@
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
A1987A597103D3E58DD06571 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+ C604FDAF2D6C8D6000CF8873 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = ""; };
+ C604FDB12D6C953100CF8873 /* JailbreakDetection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JailbreakDetection.swift; sourceTree = ""; };
+ C604FDB42D6C96D000CF8873 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; };
C624C45C2BD56D34002834AF /* tone1.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; name = tone1.mp3; path = ../../android/app/src/main/res/raw/tone1.mp3; sourceTree = ""; };
C624C45D2BD56D34002834AF /* start.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = start.wav; path = ../../android/app/src/main/res/raw/start.wav; sourceTree = ""; };
C624C45F2BD56D34002834AF /* promo.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = promo.wav; path = ../../android/app/src/main/res/raw/promo.wav; sourceTree = ""; };
@@ -182,6 +188,9 @@
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
+ C604FDB12D6C953100CF8873 /* JailbreakDetection.swift */,
+ C604FDB32D6C96D000CF8873 /* Localizable.strings */,
+ C604FDAF2D6C8D6000CF8873 /* Constants.swift */,
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
);
path = Runner;
@@ -302,6 +311,7 @@
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
C628BC3F2C31427000E4D33B /* ding.wav in Resources */,
C690B4752A80554500E1D66E /* GoogleService-Info.plist in Resources */,
+ C604FDB52D6C96D000CF8873 /* Localizable.strings in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
C624C4692BD56D34002834AF /* iphone_ringtone.wav in Resources */,
C624C4642BD56D34002834AF /* tone1.mp3 in Resources */,
@@ -438,6 +448,8 @@
files = (
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */,
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
+ C604FDB02D6C8D6A00CF8873 /* Constants.swift in Sources */,
+ C604FDB22D6C953400CF8873 /* JailbreakDetection.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -468,6 +480,14 @@
name = LaunchScreen.storyboard;
sourceTree = "";
};
+ C604FDB32D6C96D000CF8873 /* Localizable.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ C604FDB42D6C96D000CF8873 /* en */,
+ );
+ name = Localizable.strings;
+ sourceTree = "";
+ };
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift
index 3966f9f..a5f250b 100644
--- a/ios/Runner/AppDelegate.swift
+++ b/ios/Runner/AppDelegate.swift
@@ -2,19 +2,39 @@ import UIKit
import Flutter
import FirebaseCore
import GoogleMaps
-// import Constants
@main
@objc class AppDelegate: FlutterAppDelegate {
+ override func application(
+ _ application: UIApplication,
+ didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
+ ) -> Bool {
+ GMSServices.provideAPIKey(Constants.googleMapsAPIKey)
+ FirebaseApp.configure()
+ GeneratedPluginRegistrant.register(with: self)
- override func application(
- _ application: UIApplication,
- didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
- ) -> Bool {
- GMSServices.provideAPIKey("AIzaSyCyfwRXTwSTLOFQSQgN5p7QZgGJVZnEKq0")
- FirebaseApp.configure()
- GeneratedPluginRegistrant.register(with: self)
- return true
- }
+ if JailbreakDetection.isJailbroken() {
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
+ self.showJailbreakAlert()
+ }
+ }
+
+ return super.application(application, didFinishLaunchingWithOptions: launchOptions)
+ }
+
+ func showJailbreakAlert() {
+ guard let rootVC = UIApplication.shared.keyWindow?.rootViewController else { return }
+
+ let alert = UIAlertController(
+ title: "تحذير أمني",
+ message: "تم اكتشاف أن جهازك يحتوي على جيلبريك. لا يمكن تشغيل التطبيق على هذا الجهاز.",
+ preferredStyle: .alert
+ )
+
+ alert.addAction(UIAlertAction(title: "إنهاء التطبيق", style: .destructive) { _ in
+ exit(0)
+ })
+
+ rootVC.present(alert, animated: true, completion: nil)
+ }
}
-
diff --git a/ios/Runner/Base.lproj/Main.storyboard b/ios/Runner/Base.lproj/Main.storyboard
index f3c2851..19d3697 100644
--- a/ios/Runner/Base.lproj/Main.storyboard
+++ b/ios/Runner/Base.lproj/Main.storyboard
@@ -1,8 +1,10 @@
-
-
+
+
+
-
+
+
@@ -14,13 +16,14 @@
-
+
-
+
+
diff --git a/ios/Runner/Constants.swift b/ios/Runner/Constants.swift
index b60605b..75776b7 100644
--- a/ios/Runner/Constants.swift
+++ b/ios/Runner/Constants.swift
@@ -2,7 +2,11 @@
// Constants.swift
// Runner
//
-// Created by Hamza Aleghwairyeen on 15/01/2024.
+// Created by Hamza Aleghwairyeen on 24/02/2025.
//
import Foundation
+
+struct Constants {
+ static let googleMapsAPIKey = "AIzaSyCyfwRXTwSTLOFQSQgN5p7QZgGJVZnEKq0"
+}
diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist
index ca5aa29..711ea95 100644
--- a/ios/Runner/Info.plist
+++ b/ios/Runner/Info.plist
@@ -35,7 +35,7 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 93
+ 94
CFBundleSignature
????
CFBundleURLTypes
@@ -50,7 +50,7 @@
CFBundleVersion
- 5.0.93
+ 5.0.94
FirebaseAppDelegateProxyEnabled
NO
GMSApiKey
diff --git a/ios/Runner/JailbreakDetection.swift b/ios/Runner/JailbreakDetection.swift
new file mode 100644
index 0000000..17eb672
--- /dev/null
+++ b/ios/Runner/JailbreakDetection.swift
@@ -0,0 +1,26 @@
+//
+// JailbreakDetection.swift
+// Runner
+//
+// Created by Hamza Aleghwairyeen on 24/02/2025.
+//
+
+
+import Foundation
+
+class JailbreakDetection {
+ static func isJailbroken() -> Bool {
+ let paths = [
+ "/Applications/Cydia.app",
+ "/Library/MobileSubstrate/MobileSubstrate.dylib",
+ "/usr/sbin/sshd",
+ "/etc/apt"
+ ]
+ for path in paths {
+ if FileManager.default.fileExists(atPath: path) {
+ return true
+ }
+ }
+ return false
+ }
+}
diff --git a/ios/Runner/en.lproj/Localizable.strings b/ios/Runner/en.lproj/Localizable.strings
new file mode 100644
index 0000000..dda4b9d
--- /dev/null
+++ b/ios/Runner/en.lproj/Localizable.strings
@@ -0,0 +1,7 @@
+/*
+ Localizable.strings
+ Runner
+
+ Created by Hamza Aleghwairyeen on 24/02/2025.
+
+*/
diff --git a/lib/constant/api_key.dart b/lib/constant/api_key.dart
index b7c1340..466ee1e 100644
--- a/lib/constant/api_key.dart
+++ b/lib/constant/api_key.dart
@@ -4,6 +4,16 @@ import '../env/env.dart';
import 'char_map.dart';
class AK {
+ static final String sss_pass = X.r(X.r(X.r(Env.sss_pass, cn), cC), cs);
+ static final String allowed = Env.allowed;
+ static final String passnpassenger = X
+ .r(X.r(X.r(Env.passnpassenger, cn), cC), cs)
+ .toString()
+ .split(Env.addd)[0];
+ static final String newId = Env.newId;
+ static final String sss_encryptionSalt =
+ X.r(X.r(X.r(Env.sss_encryptionSalt, cn), cC), cs);
+
static final String publishableKeyStripe =
X.r(X.r(X.r(Env.stripePublishableKe, cn), cC), cs);
static final String secretKeyStripe =
@@ -65,7 +75,7 @@ class AK {
static final String payMobOutPassword =
X.r(X.r(X.r(Env.payMobOutPassword, cn), cC), cs);
- static final String privateKeyFCM = Env.privateKeyFCM;
+ // static final String privateKeyFCM = Env.privateKeyFCM;
static final String payMobOutUserName =
X.r(X.r(X.r(Env.payMobOutUserName, cn), cC), cs);
diff --git a/lib/constant/box_name.dart b/lib/constant/box_name.dart
index e5d1beb..f095fb5 100644
--- a/lib/constant/box_name.dart
+++ b/lib/constant/box_name.dart
@@ -2,7 +2,13 @@ class BoxName {
static const String driverID = "driverID";
static const String countryCode = "countryCode";
static const String googlaMapApp = "googlaMapApp";
-
+ static const String keyOfApp = 'keyOfApp';
+ static const String initializationVector = 'initializationVector';
+ static const String firstTimeLoadKey = 'firstTimeLoadKey';
+ static const String jwt = "jwt";
+ static const String fingerPrint = "fingerPrint";
+ static const String payMobApikey = "payMobApikey";
+ static const String refreshToken = "refreshToken";
static const String lang = "lang";
static const String isvibrate = "isvibrate";
static const String myListString = "myListString";
diff --git a/lib/constant/info.dart b/lib/constant/info.dart
index 20798f0..452080b 100644
--- a/lib/constant/info.dart
+++ b/lib/constant/info.dart
@@ -9,7 +9,7 @@ class AppInformation {
static const String email = 'hamzaayed@Sefer.live';
static const String complaintPrompt =
'for this data for complaint from driver or passenger i collect all data i want you analyze this complaint and show what is reason and what is solution .this data collected from many table to find solution if payment in visa not complete and if ride status is finished it will be paymnet in payment table if ride status is not finished there is no need to pay and payment table is null for this ride and if paymentFromPaymentTable not null and visa type not cash the payment sucssessed . if ratingpassenger is low or passengr rating drivers low grade then dont mine of this passenger ,look at driver too like passengerratingdriver with rating or ratingtopassenger .in json add status of complaint and message to passenger and message to driver and message to call center write in arabic in json output with key in english .for output please just json i want';
-
+ static const String addd = 'BlBlNl';
static const String privacyPolicy = '''
diff --git a/lib/constant/links.dart b/lib/constant/links.dart
index 705d595..41dd795 100644
--- a/lib/constant/links.dart
+++ b/lib/constant/links.dart
@@ -1,5 +1,7 @@
// import 'package:sefer_driver/env/env.dart';
+import 'package:sefer_driver/env/env.dart';
+
import '../main.dart';
import 'box_name.dart';
@@ -29,6 +31,12 @@ class AppLink {
static String seferAlexandriaServer = box.read('Alexandria');
// static final String server = Env.serverPHP;
+ static String loginJwtDriver = "$server/loginJwtDriver.php";
+ static String loginJwtWalletDriver =
+ "$seferPaymentServer/loginJwtWalletDriver.php";
+ static String loginFirstTimeDriver =
+ "https://server.sefer.live/sefer.click/sefer/loginFirstTimeDriver.php";
+
static String googleMapsLink = 'https://maps.googleapis.com/maps/api/';
static String llama = 'https://api.llama-api.com/chat/completions';
static String gemini =
@@ -93,7 +101,8 @@ class AppLink {
static String getTripCountByCaptain = "$ride/rides/getTripCountByCaptain.php";
static String getRideOrderID = "$ride/rides/getRideOrderID.php";
static String getRideStatus = "$ride/rides/getRideStatus.php";
- static String getapiKey = "$ride/apiKey/get.php";
+ static String getapiKey = Env.getapiKey;
+
static String getapiKeySefer =
"https://api.sefer.live/sefer/ride/apiKey/get.php";
static String getRideStatusBegin = "$ride/rides/getRideStatusBegin.php";
diff --git a/lib/constant/table_names.dart b/lib/constant/table_names.dart
index b3c8353..4366a34 100644
--- a/lib/constant/table_names.dart
+++ b/lib/constant/table_names.dart
@@ -8,3 +8,11 @@ class TableName {
static const String captainNotification = "captainNotification";
static const String applyRideFromOverLay = "applyRideFromOverLay";
}
+
+class Driver {
+ static const String driverPass = 'MG6DEJZSczBT6Rx0jOlehQ==';
+ static const String payMobApikey = 'payMobApikey';
+ static const String initializationVector = 'initializationVector';
+ static const String keyOfApp = 'keyOfApp';
+ static const String FCM_PRIVATE_KEY = 'FCM_PRIVATE_KEY';
+}
diff --git a/lib/controller/auth/captin/history_captain.dart b/lib/controller/auth/captin/history_captain.dart
index 82e9011..9b66762 100644
--- a/lib/controller/auth/captin/history_captain.dart
+++ b/lib/controller/auth/captin/history_captain.dart
@@ -47,7 +47,7 @@ class HistoryCaptainController extends GetxController {
isloading = true;
var res = await CRUD().get(
link: AppLink.getRideOrderID,
- payload: {'id': encryptionHelper.encryptData(orderId)});
+ payload: {'id': EncryptionHelper.instance.encryptData(orderId)});
historyDetailsData = jsonDecode(res);
isloading = false;
update();
diff --git a/lib/controller/auth/captin/invit_controller.dart b/lib/controller/auth/captin/invit_controller.dart
index b768d22..576b0b7 100644
--- a/lib/controller/auth/captin/invit_controller.dart
+++ b/lib/controller/auth/captin/invit_controller.dart
@@ -149,9 +149,9 @@ Download the Tripz app now and enjoy your ride!
void onSelectDriverInvitation(int index) async {
MyDialog().getDialog(
int.parse((driverInvitationData[index]['countOfInvitDriver'])) < 100
- ? '${'When'.tr} ${encryptionHelper.decryptData(driverInvitationData[index]['invitorName'])} ${"complete, you can claim your gift".tr} '
+ ? '${'When'.tr} ${EncryptionHelper.instance.decryptData(driverInvitationData[index]['invitorName'])} ${"complete, you can claim your gift".tr} '
: 'You deserve the gift'.tr,
- '${encryptionHelper.decryptData(driverInvitationData[index]['invitorName'])} ${(driverInvitationData[index]['countOfInvitDriver'])} / 100 ${'Trip'.tr}',
+ '${EncryptionHelper.instance.decryptData(driverInvitationData[index]['invitorName'])} ${(driverInvitationData[index]['countOfInvitDriver'])} / 100 ${'Trip'.tr}',
() async {
if (int.parse((driverInvitationData[index]['countOfInvitDriver'])) <
100) {
@@ -161,23 +161,24 @@ Download the Tripz app now and enjoy your ride!
if ((driverInvitationData[index]['isGiftToken']).toString() == '0') {
Get.back();
await CRUD().post(link: AppLink.updateInviteDriver, payload: {
- 'id': encryptionHelper
+ 'id': EncryptionHelper.instance
.encryptData(driverInvitationData[index]['id'])
});
await Get.find().addDriverPayment(
'paymentMethod',
- encryptionHelper.encryptData('500'),
+ EncryptionHelper.instance.encryptData('500'),
'',
);
// add for invitor too
await Get.find().addDriverWalletToInvitor(
'paymentMethod',
- encryptionHelper
+ EncryptionHelper.instance
.encryptData(driverInvitationData[index]['driverInviterId']),
- encryptionHelper.encryptData('500'),
+ EncryptionHelper.instance.encryptData('500'),
);
await Get.find().addSeferWallet(
- 'giftInvitation', encryptionHelper.encryptData('-1000'));
+ 'giftInvitation',
+ EncryptionHelper.instance.encryptData('-1000'));
NotificationCaptainController().addNotificationCaptain(
driverInvitationData[index]['driverInviterId'].toString(),
"You have got a gift for invitation".tr,
@@ -205,9 +206,9 @@ Download the Tripz app now and enjoy your ride!
int.parse(driverInvitationDataToPassengers[index]['countOfInvitDriver']
.toString()) <
3
- ? '${'When'.tr} ${encryptionHelper.decryptData(driverInvitationDataToPassengers[index]['passengerName'].toString())} ${"complete, you can claim your gift".tr} '
+ ? '${'When'.tr} ${EncryptionHelper.instance.decryptData(driverInvitationDataToPassengers[index]['passengerName'].toString())} ${"complete, you can claim your gift".tr} '
: 'You deserve the gift'.tr,
- '${encryptionHelper.decryptData(driverInvitationDataToPassengers[index]['passengerName'].toString())} ${driverInvitationDataToPassengers[index]['countOfInvitDriver']} / 3 ${'Trip'.tr}',
+ '${EncryptionHelper.instance.decryptData(driverInvitationDataToPassengers[index]['passengerName'].toString())} ${driverInvitationDataToPassengers[index]['countOfInvitDriver']} / 3 ${'Trip'.tr}',
() async {
if (int.parse(driverInvitationDataToPassengers[index]
['countOfInvitDriver']
diff --git a/lib/controller/auth/captin/login_captin_controller.dart b/lib/controller/auth/captin/login_captin_controller.dart
index 3e421a2..18ebfa3 100644
--- a/lib/controller/auth/captin/login_captin_controller.dart
+++ b/lib/controller/auth/captin/login_captin_controller.dart
@@ -1,6 +1,8 @@
import 'dart:convert';
+import 'dart:io';
import 'dart:math';
-
+import 'package:http/http.dart' as http;
+import 'package:secure_string_operations/secure_string_operations.dart';
import 'package:sefer_driver/controller/functions/location_background_controller.dart';
import 'package:sefer_driver/views/auth/captin/cards/sms_signup.dart';
import 'package:sefer_driver/views/widgets/elevated_btn.dart';
@@ -15,10 +17,16 @@ import 'package:sefer_driver/main.dart';
import 'package:sefer_driver/views/home/Captin/home_captain/home_captin.dart';
import 'package:location/location.dart';
+import '../../../constant/api_key.dart';
+import '../../../constant/char_map.dart';
import '../../../constant/info.dart';
+import '../../../constant/table_names.dart';
+import '../../../print.dart';
import '../../../views/auth/captin/cards/egypt_card_a_i.dart';
import '../../firebase/firbase_messge.dart';
import '../../functions/encrypt_decrypt.dart';
+import '../../functions/package_info.dart';
+import '../../functions/secure_storage.dart';
class LoginDriverController extends GetxController {
final formKey = GlobalKey();
@@ -82,6 +90,77 @@ class LoginDriverController extends GetxController {
update();
}
+ var dev = '';
+ getJwtWallet() async {
+ await SecurityHelper.performSecurityChecks();
+ String fingerPrint = await getDeviceFingerprint();
+ dev = Platform.isAndroid ? 'android' : 'ios';
+ var payload = {
+ 'id': box.read(BoxName.passengerID),
+ 'password': AK.passnpassenger,
+ 'aud': '${AK.allowed}$dev',
+ 'fingerPrint': fingerPrint
+ };
+ var response1 = await http.post(
+ Uri.parse(AppLink.loginJwtWalletDriver),
+ body: payload,
+ );
+
+ return jsonDecode(response1.body)['jwt'].toString();
+ }
+
+ getJWT() async {
+ // await SecurityHelper.performSecurityChecks();
+ dev = Platform.isAndroid ? 'android' : 'ios';
+ if (box.read(BoxName.firstTimeLoadKey).toString() != 'false') {
+ var response0 = await http.post(
+ Uri.parse(AppLink.loginFirstTimeDriver),
+ body: {
+ 'id': box.read(BoxName.passengerID) ?? AK.newId,
+ 'password': AK.passnpassenger,
+ 'aud': '${AK.allowed}$dev',
+ },
+ );
+ if (response0.statusCode == 200) {
+ final decodedResponse1 = jsonDecode(response0.body);
+
+ final jwt = decodedResponse1['jwt'];
+ box.write(BoxName.jwt, X.c(X.c(X.c(jwt, cn), cC), cs));
+
+ await AppInitializer().getAIKey(Driver.keyOfApp);
+ await AppInitializer().getAIKey(Driver.initializationVector);
+ await Future.delayed(Duration.zero);
+ await EncryptionHelper.initialize();
+
+ await AppInitializer().getAIKey(Driver.payMobApikey);
+ await AppInitializer().getAIKey(Driver.FCM_PRIVATE_KEY);
+
+ await AppInitializer().getKey();
+ } else {}
+ } else {
+ await EncryptionHelper.initialize();
+
+ var payload = {
+ 'id': box.read(BoxName.passengerID),
+ 'password': AK.passnpassenger,
+ 'aud': '${AK.allowed}$dev',
+ };
+ var response1 = await http.post(
+ Uri.parse(AppLink.loginJwtDriver),
+ body: payload,
+ );
+
+ if (response1.statusCode == 200) {
+ final decodedResponse1 = jsonDecode(response1.body);
+ Log.print('decodedResponse1: ${decodedResponse1}');
+
+ final jwt = decodedResponse1['jwt'];
+ await box.write(BoxName.jwt, X.c(X.c(X.c(jwt, cn), cC), cs));
+ await AppInitializer().getKey();
+ }
+ }
+ }
+
Future getLocationPermission() async {
Get.put(LocationBackgroundController()).requestLocationPermission();
@@ -119,7 +198,7 @@ class LoginDriverController extends GetxController {
update();
var res = await CRUD().get(link: AppLink.loginFromGoogleCaptin, payload: {
'email': email.toString().contains('@')
- ? encryptionHelper.encryptData(email)
+ ? EncryptionHelper.instance.encryptData(email)
: email,
'id': driverID,
});
@@ -161,13 +240,13 @@ class LoginDriverController extends GetxController {
(jsonDecoeded['data'][0]['accountBank']));
box.write(
BoxName.nameDriver,
- '${encryptionHelper.decryptData(jsonDecoeded['data'][0]['first_name'])}'
- ' ${encryptionHelper.decryptData(jsonDecoeded['data'][0]['last_name'])}');
+ '${EncryptionHelper.instance.decryptData(jsonDecoeded['data'][0]['first_name'])}'
+ ' ${EncryptionHelper.instance.decryptData(jsonDecoeded['data'][0]['last_name'])}');
if (((jsonDecoeded['data'][0]['model'])
.toString()
.contains('دراجه') ||
jsonDecoeded['data'][0]['make'].toString().contains('دراجه '))) {
- if (encryptionHelper
+ if (EncryptionHelper.instance
.decryptData(jsonDecoeded['data'][0]['gender'])
.toString() ==
'Male') {
@@ -197,13 +276,14 @@ class LoginDriverController extends GetxController {
payload: {'captain_id': (box.read(BoxName.driverID)).toString()});
if (token != 'failure') {
- if (encryptionHelper
+ if (EncryptionHelper.instance
.decryptData(jsonDecode(token)['data'][0]['token']) !=
- encryptionHelper.decryptData(box.read(BoxName.tokenDriver))) {
+ EncryptionHelper.instance
+ .decryptData(box.read(BoxName.tokenDriver))) {
Get.put(FirebaseMessagesController()).sendNotificationToDriverMAP(
'token change'.tr,
'change device'.tr,
- encryptionHelper
+ EncryptionHelper.instance
.decryptData(jsonDecode(token)['data'][0]['token'])
.toString(),
[],
@@ -262,11 +342,11 @@ class LoginDriverController extends GetxController {
update();
var res = await CRUD()
.get(link: AppLink.loginUsingCredentialsWithoutGoogle, payload: {
- 'email': encryptionHelper.encryptData(email),
+ 'email': EncryptionHelper.instance.encryptData(email),
'password': password,
});
- box.write(
- BoxName.emailDriver, encryptionHelper.encryptData(email).toString());
+ box.write(BoxName.emailDriver,
+ EncryptionHelper.instance.encryptData(email).toString());
print(res);
if (res == 'failure') {
//Failure
@@ -292,7 +372,7 @@ class LoginDriverController extends GetxController {
box.write(BoxName.phoneDriver, (jsonDecoeded['data'][0]['phone']));
box.write(
BoxName.nameArabic,
- encryptionHelper
+ EncryptionHelper.instance
.decryptData(jsonDecoeded['data'][0]['name_arabic']));
box.write(
BoxName.bankCodeDriver, (jsonDecoeded['data'][0]['bankCode']));
@@ -300,11 +380,11 @@ class LoginDriverController extends GetxController {
jsonDecoeded['data'][0]['accountBank']);
box.write(
BoxName.nameDriver,
- '${encryptionHelper.decryptData(jsonDecoeded['data'][0]['first_name'])}'
- ' ${encryptionHelper.decryptData(jsonDecoeded['data'][0]['last_name'])}');
+ '${EncryptionHelper.instance.decryptData(jsonDecoeded['data'][0]['first_name'])}'
+ ' ${EncryptionHelper.instance.decryptData(jsonDecoeded['data'][0]['last_name'])}');
if ((jsonDecoeded['data'][0]['model'].toString().contains('دراجه') ||
jsonDecoeded['data'][0]['make'].toString().contains('دراجه '))) {
- if (encryptionHelper
+ if (EncryptionHelper.instance
.decryptData(jsonDecoeded['data'][0]['gender'])
.toString() ==
'Male') {
@@ -314,7 +394,7 @@ class LoginDriverController extends GetxController {
}
} else if (int.parse(jsonDecoeded['data'][0]['year'].toString()) >
2017) {
- if (encryptionHelper
+ if (EncryptionHelper.instance
.decryptData(jsonDecoeded['data'][0]['gender'])
.toString() !=
'Male') {
@@ -337,13 +417,14 @@ class LoginDriverController extends GetxController {
payload: {'captain_id': box.read(BoxName.driverID).toString()});
if (token != 'failure') {
- if (encryptionHelper
+ if (EncryptionHelper.instance
.decryptData(jsonDecode(token)['data'][0]['token']) !=
- encryptionHelper.decryptData(box.read(BoxName.tokenDriver))) {
+ EncryptionHelper.instance
+ .decryptData(box.read(BoxName.tokenDriver))) {
Get.put(FirebaseMessagesController()).sendNotificationToDriverMAP(
'token change'.tr,
'change device'.tr,
- encryptionHelper
+ EncryptionHelper.instance
.decryptData(jsonDecode(token)['data'][0]['token'])
.toString(),
[],
diff --git a/lib/controller/auth/captin/register_captin_controller.dart b/lib/controller/auth/captin/register_captin_controller.dart
index 5ed8d52..bc1473b 100644
--- a/lib/controller/auth/captin/register_captin_controller.dart
+++ b/lib/controller/auth/captin/register_captin_controller.dart
@@ -108,8 +108,8 @@ class RegisterCaptainController extends GetxController {
if (isValidEgyptianPhoneNumber(phoneController.text)) {
var responseCheker = await CRUD()
.post(link: AppLink.checkPhoneNumberISVerfiedDriver, payload: {
- 'phone_number':
- encryptionHelper.encryptData('+2${phoneController.text}'),
+ 'phone_number': EncryptionHelper.instance
+ .encryptData('+2${phoneController.text}'),
});
if (responseCheker != 'failure') {
var d = jsonDecode(responseCheker);
@@ -117,18 +117,20 @@ class RegisterCaptainController extends GetxController {
Get.snackbar('Phone number is verified before'.tr, '',
backgroundColor: AppColor.greenColor);
box.write(BoxName.phoneVerified, '1');
- box.write(BoxName.phone,
- encryptionHelper.encryptData('+2${phoneController.text}'));
+ box.write(
+ BoxName.phone,
+ EncryptionHelper.instance
+ .encryptData('+2${phoneController.text}'));
await Get.put(LoginDriverController()).loginWithGoogleCredential(
box.read(BoxName.driverID).toString(),
box.read(BoxName.emailDriver).toString(),
);
} else {
await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
- 'phone_number':
- encryptionHelper.encryptData('+2${phoneController.text}'),
- 'token_code':
- encryptionHelper.encryptData(randomNumber.toString()),
+ 'phone_number': EncryptionHelper.instance
+ .encryptData('+2${phoneController.text}'),
+ 'token_code': EncryptionHelper.instance
+ .encryptData(randomNumber.toString()),
"driverId": box.read(BoxName.driverID),
"email": box.read(BoxName.emailDriver),
});
@@ -143,10 +145,10 @@ class RegisterCaptainController extends GetxController {
}
} else {
await CRUD().post(link: AppLink.sendVerifyOtpMessage, payload: {
- 'phone_number':
- encryptionHelper.encryptData('+2${phoneController.text}'),
- 'token_code':
- encryptionHelper.encryptData(randomNumber.toString()),
+ 'phone_number': EncryptionHelper.instance
+ .encryptData('+2${phoneController.text}'),
+ 'token_code': EncryptionHelper.instance
+ .encryptData(randomNumber.toString()),
"driverId": box.read(BoxName.driverID),
"email": box.read(BoxName.emailDriver),
});
@@ -247,7 +249,7 @@ class RegisterCaptainController extends GetxController {
mySnackbarSuccess('Phone number is already verified'.tr);
box.write(BoxName.phoneVerified, '1');
box.write(BoxName.phone,
- encryptionHelper.encryptData('+2${phoneController.text}'));
+ EncryptionHelper.instance.encryptData('+2${phoneController.text}'));
Get.put(LoginDriverController()).loginWithGoogleCredential(
box.read(BoxName.driverID).toString(),
box.read(BoxName.emailDriver).toString(),
@@ -262,8 +264,9 @@ class RegisterCaptainController extends GetxController {
await CRUD().post(
link: AppLink.sendVerifyOtpMessage,
payload: {
- 'phone_number': encryptionHelper.encryptData('+2$phoneNumber'),
- 'token_code': encryptionHelper.encryptData(randomNumber.toString()),
+ 'phone_number': EncryptionHelper.instance.encryptData('+2$phoneNumber'),
+ 'token_code':
+ EncryptionHelper.instance.encryptData(randomNumber.toString()),
'driverId': box.read(BoxName.driverID),
'email': box.read(BoxName.emailDriver),
},
@@ -282,13 +285,14 @@ class RegisterCaptainController extends GetxController {
if (formKey3.currentState!.validate()) {
var res = await CRUD().post(link: AppLink.verifyOtpDriver, payload: {
'phone_number':
- encryptionHelper.encryptData('+2${phoneController.text}'),
- 'token_code': encryptionHelper.encryptData(verifyCode.text.toString()),
+ EncryptionHelper.instance.encryptData('+2${phoneController.text}'),
+ 'token_code':
+ EncryptionHelper.instance.encryptData(verifyCode.text.toString()),
});
if (res != 'failure') {
// var dec = jsonDecode(res);
box.write(BoxName.phoneDriver,
- encryptionHelper.encryptData('+2${phoneController.text}'));
+ EncryptionHelper.instance.encryptData('+2${phoneController.text}'));
box.write(BoxName.phoneVerified, '1');
// loginDriverController.isGoogleLogin == true
@@ -313,10 +317,10 @@ class RegisterCaptainController extends GetxController {
sendVerifications() async {
var res = await CRUD().post(link: AppLink.verifyEmail, payload: {
'email': emailController.text.isEmpty
- ? encryptionHelper.encryptData(
+ ? EncryptionHelper.instance.encryptData(
Get.find().emailController.text.toString())
- : encryptionHelper.encryptData(emailController.text),
- 'token': encryptionHelper.encryptData(verifyCode.text),
+ : EncryptionHelper.instance.encryptData(emailController.text),
+ 'token': EncryptionHelper.instance.encryptData(verifyCode.text),
});
if (res != 'failure') {
diff --git a/lib/controller/auth/google_sign.dart b/lib/controller/auth/google_sign.dart
index 576fd3f..59cf9de 100644
--- a/lib/controller/auth/google_sign.dart
+++ b/lib/controller/auth/google_sign.dart
@@ -126,7 +126,7 @@ class GoogleSignInHelper {
box.write(BoxName.driverID,
(user.id) ?? 'Unknown ID'); // Ensure there's a fallback value
box.write(BoxName.emailDriver,
- encryptionHelper.encryptData(user.email) ?? 'Unknown Email');
+ EncryptionHelper.instance.encryptData(user.email) ?? 'Unknown Email');
}
// Method to handle Google Sign-Out
diff --git a/lib/controller/firebase/firbase_messge.dart b/lib/controller/firebase/firbase_messge.dart
index 1e904dd..91436c3 100644
--- a/lib/controller/firebase/firbase_messge.dart
+++ b/lib/controller/firebase/firbase_messge.dart
@@ -71,7 +71,8 @@ class FirebaseMessagesController extends GetxController {
Future getToken() async {
fcmToken.getToken().then((token) {
// Log.print('token: ${token}');
- box.write(BoxName.tokenDriver, encryptionHelper.encryptData(token!));
+ box.write(
+ BoxName.tokenDriver, EncryptionHelper.instance.encryptData(token!));
});
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
@@ -400,6 +401,25 @@ class FirebaseMessagesController extends GetxController {
}));
}
+ late String serviceAccountKeyJson;
+ @override
+ Future onInit() async {
+ super.onInit();
+ try {
+ var encryptedKey = await storage.read(key: 'FCM_PRIVATE_KEY');
+ // Log.print('encryptedKey: ${encryptedKey}');
+ if (encryptedKey != null) {
+ serviceAccountKeyJson =
+ EncryptionHelper.instance.decryptData(encryptedKey);
+ // Log.print('serviceAccountKeyJson: ${serviceAccountKeyJson}');
+ } else {
+ print('🔴 Error: FCM_PRIVATE_KEY not found in Secure Storage');
+ }
+ } catch (e) {
+ print('🔴 Error decrypting FCM key: $e');
+ }
+ }
+
void sendNotificationAll(String title, body, tone) async {
// Get the token you want to subtract.
String token = box.read(BoxName.tokenFCM);
@@ -411,26 +431,16 @@ class FirebaseMessagesController extends GetxController {
// box.write(BoxName.tokens, tokens);
tokens = box.read(BoxName.tokens);
for (var i = 0; i < tokens.length; i++) {
- String serviceAccountKeyJson = '''{
- "type": "service_account",
- "project_id": "ride-b1bd8",
- "private_key_id": "75e817c0b902db2ef35edf2c2bd159dec1f13249",
- "private_key": "-----BEGIN PRIVATE KEY-----\\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQD0zH9TQGDQHUv3\\na3/JAD1UKPwAp3wNKT0a6fxiIzjI3JxQWI30QvZCcfl6CdMhIcydX1ncSaYTcEeC\\n/AdPVCPkqyJx1YIGGg6P/mRzCWeaN8fsp6z250m5vcObDCZc3dbJEkepbep+6FPY\\n21m3KO+AHh1glgsTGZOTm5xiU8NGXpdk2QEh8wpiIIlR/HuKwVw9g8urNe3Sno+U\\nDm3z37iFqvZdmpqO8aWTJu6beb3hsREK9XK2I9JqC2JUwiGQRo3idOvPP6hkqrWx\\nKSX96vglQFYfakvJdDp2ZATOlpBYPMtS/IWhJ985u58TSS+Kl8qpnpaZBSxgJirf\\nhWzhnKLfAgMBAAECggEAJP785SePGhS7ZN6ltspm+l+hSjYFrPWFCxq+rlQ1YkHZ\\nC9l+RqKSFhOkiPmQI2s4wbXl3kFxLHHlFNoi/q2wKQBmGb8TQfnRJpjjNHGA61Ev\\n0Ue7/6qPvVb9B2MsLw/FxKiTFPuMG3bgKR9pbSFuJLYoaW7zqITOhVnYphGTqwAY\\nBVVcvISSLvELDmH9VZcv/9DVqVlqbbESHWh1Z4W6XGPoEqeDH/upNTyQQ/46Msgm\\nTGE6VqLHpWuSf6SqHp+r0Y0lI3vIPM1vz5FAJDJbOE/enHa0fSup0OHSMxl0HVMn\\nnO1yrGF3vsIPOej5HKr5d71bEIckzk73/yjNC1/mDQKBgQD7RtUvc9omsSsFMJ6e\\nBASAn6Dktx/QY/XNJjFzHQj69cywLDe5t5AL2gUi3phQ2oqB5XJdwnd5bTIEPEPZ\\nDOuOai2802p6FJk6kjmZAMVGx5JtXBH+vs6jrmQQSMiKbjwN1TT6xIWakvLOonUi\\nX6ZvjYYjU/E0YJU3jSiXWEr76wKBgQD5Zn4SouJ6BCDZMbausJVMBkk3qxsYooip\\np89WakC6e7AZinpkRcqjGGV9GOvc8crJs6fyXAA9ORepGP47Mc0ZrDssOkstznsM\\npr8R0S6MKwEZaT9ixOHdOcLZ47ps+JzA2Wr4KN2OvFHksUkB/46ATD1j9WZVgB8M\\namsYp/Y73QKBgHOo+PvsoZ9psVmkNX6abtAdqdtdB0HOoRea2uwXk0ig12TIFaZg\\nfedWpUKVnxqoXVTJHklV99RmlL0qWDiSH+LfsMnXro0e6iDxqZ1po2Se/CFmXcoa\\nXdctsFVmixhdATuExewfhTfPKABA+xWlXWC/jdy5CK+JPWXijaqMM4edAoGAE5Bj\\nsWiPpYyvWvpYX0nA3G7dzX0hqgQN/mkIjbnWDArp3IcNZNJIvBSM2Yxb7EAXbU0n\\njo6DAkp5Pa2VO+WDNlFZbvW/sf8xjeOCt44WPa6d7nVgIIpbQXRngZoopKW3/jTP\\n/FmQT8McFXmGxZ5belsAsdetSGW9icbLUerTGQ0CgYEAmf/G8Ag3XxmqTXvvHuv2\\n14OP7WnrVqkEMnydrftEwn4peXd/Lz+/GYX5Zc4ZoNgbN8IvZ5z0+OmRsallsbiW\\nBw0/tc68CjzxXOvReWxDluUopqWVGj5tlGqE5xUDku9SWJSxbkiQ3rqutzBdPXpr\\noqHwPyDrmK/Zgqn+uiIm4Ck=\\n-----END PRIVATE KEY-----\\n",
- "client_email": "firebase-adminsdk-o2wqi@ride-b1bd8.iam.gserviceaccount.com",
- "client_id": "111210077025005706623",
- "auth_uri": "https://accounts.google.com/o/oauth2/auth",
- "token_uri": "https://oauth2.googleapis.com/token",
- "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
- "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-o2wqi%40ride-b1bd8.iam.gserviceaccount.com",
- "universe_domain": "googleapis.com"
-}
-'''; // As defined above
-
+ if (serviceAccountKeyJson.isEmpty) {
+ print("🔴 Error: Service Account Key is empty");
+ return;
+ }
// Initialize AccessTokenManager
final accessTokenManager = AccessTokenManager(serviceAccountKeyJson);
// Obtain an OAuth 2.0 access token
final accessToken = await accessTokenManager.getAccessToken();
+ // Log.print('accessToken: ${accessToken}');
// Send the notification
final response = await http
@@ -479,26 +489,16 @@ class FirebaseMessagesController extends GetxController {
String title, body, token, List map, String tone,
{int retryCount = 2}) async {
try {
- String serviceAccountKeyJson = '''{
- "type": "service_account",
- "project_id": "ride-b1bd8",
- "private_key_id": "75e817c0b902db2ef35edf2c2bd159dec1f13249",
- "private_key": "-----BEGIN PRIVATE KEY-----\\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQD0zH9TQGDQHUv3\\na3/JAD1UKPwAp3wNKT0a6fxiIzjI3JxQWI30QvZCcfl6CdMhIcydX1ncSaYTcEeC\\n/AdPVCPkqyJx1YIGGg6P/mRzCWeaN8fsp6z250m5vcObDCZc3dbJEkepbep+6FPY\\n21m3KO+AHh1glgsTGZOTm5xiU8NGXpdk2QEh8wpiIIlR/HuKwVw9g8urNe3Sno+U\\nDm3z37iFqvZdmpqO8aWTJu6beb3hsREK9XK2I9JqC2JUwiGQRo3idOvPP6hkqrWx\\nKSX96vglQFYfakvJdDp2ZATOlpBYPMtS/IWhJ985u58TSS+Kl8qpnpaZBSxgJirf\\nhWzhnKLfAgMBAAECggEAJP785SePGhS7ZN6ltspm+l+hSjYFrPWFCxq+rlQ1YkHZ\\nC9l+RqKSFhOkiPmQI2s4wbXl3kFxLHHlFNoi/q2wKQBmGb8TQfnRJpjjNHGA61Ev\\n0Ue7/6qPvVb9B2MsLw/FxKiTFPuMG3bgKR9pbSFuJLYoaW7zqITOhVnYphGTqwAY\\nBVVcvISSLvELDmH9VZcv/9DVqVlqbbESHWh1Z4W6XGPoEqeDH/upNTyQQ/46Msgm\\nTGE6VqLHpWuSf6SqHp+r0Y0lI3vIPM1vz5FAJDJbOE/enHa0fSup0OHSMxl0HVMn\\nnO1yrGF3vsIPOej5HKr5d71bEIckzk73/yjNC1/mDQKBgQD7RtUvc9omsSsFMJ6e\\nBASAn6Dktx/QY/XNJjFzHQj69cywLDe5t5AL2gUi3phQ2oqB5XJdwnd5bTIEPEPZ\\nDOuOai2802p6FJk6kjmZAMVGx5JtXBH+vs6jrmQQSMiKbjwN1TT6xIWakvLOonUi\\nX6ZvjYYjU/E0YJU3jSiXWEr76wKBgQD5Zn4SouJ6BCDZMbausJVMBkk3qxsYooip\\np89WakC6e7AZinpkRcqjGGV9GOvc8crJs6fyXAA9ORepGP47Mc0ZrDssOkstznsM\\npr8R0S6MKwEZaT9ixOHdOcLZ47ps+JzA2Wr4KN2OvFHksUkB/46ATD1j9WZVgB8M\\namsYp/Y73QKBgHOo+PvsoZ9psVmkNX6abtAdqdtdB0HOoRea2uwXk0ig12TIFaZg\\nfedWpUKVnxqoXVTJHklV99RmlL0qWDiSH+LfsMnXro0e6iDxqZ1po2Se/CFmXcoa\\nXdctsFVmixhdATuExewfhTfPKABA+xWlXWC/jdy5CK+JPWXijaqMM4edAoGAE5Bj\\nsWiPpYyvWvpYX0nA3G7dzX0hqgQN/mkIjbnWDArp3IcNZNJIvBSM2Yxb7EAXbU0n\\njo6DAkp5Pa2VO+WDNlFZbvW/sf8xjeOCt44WPa6d7nVgIIpbQXRngZoopKW3/jTP\\n/FmQT8McFXmGxZ5belsAsdetSGW9icbLUerTGQ0CgYEAmf/G8Ag3XxmqTXvvHuv2\\n14OP7WnrVqkEMnydrftEwn4peXd/Lz+/GYX5Zc4ZoNgbN8IvZ5z0+OmRsallsbiW\\nBw0/tc68CjzxXOvReWxDluUopqWVGj5tlGqE5xUDku9SWJSxbkiQ3rqutzBdPXpr\\noqHwPyDrmK/Zgqn+uiIm4Ck=\\n-----END PRIVATE KEY-----\\n",
- "client_email": "firebase-adminsdk-o2wqi@ride-b1bd8.iam.gserviceaccount.com",
- "client_id": "111210077025005706623",
- "auth_uri": "https://accounts.google.com/o/oauth2/auth",
- "token_uri": "https://oauth2.googleapis.com/token",
- "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
- "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-o2wqi%40ride-b1bd8.iam.gserviceaccount.com",
- "universe_domain": "googleapis.com"
-}
-'''; // As defined above
-
+ if (serviceAccountKeyJson.isEmpty) {
+ print("🔴 Error: Service Account Key is empty");
+ return;
+ }
// Initialize AccessTokenManager
final accessTokenManager = AccessTokenManager(serviceAccountKeyJson);
// Obtain an OAuth 2.0 access token
final accessToken = await accessTokenManager.getAccessToken();
+ // Log.print('accessToken: ${accessToken}');
// Send the notification
final response = await http.post(
@@ -571,26 +571,16 @@ class FirebaseMessagesController extends GetxController {
String title, body, token, List map, String tone,
{int retryCount = 2}) async {
try {
- String serviceAccountKeyJson = '''{
- "type": "service_account",
- "project_id": "ride-b1bd8",
- "private_key_id": "75e817c0b902db2ef35edf2c2bd159dec1f13249",
- "private_key": "-----BEGIN PRIVATE KEY-----\\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQD0zH9TQGDQHUv3\\na3/JAD1UKPwAp3wNKT0a6fxiIzjI3JxQWI30QvZCcfl6CdMhIcydX1ncSaYTcEeC\\n/AdPVCPkqyJx1YIGGg6P/mRzCWeaN8fsp6z250m5vcObDCZc3dbJEkepbep+6FPY\\n21m3KO+AHh1glgsTGZOTm5xiU8NGXpdk2QEh8wpiIIlR/HuKwVw9g8urNe3Sno+U\\nDm3z37iFqvZdmpqO8aWTJu6beb3hsREK9XK2I9JqC2JUwiGQRo3idOvPP6hkqrWx\\nKSX96vglQFYfakvJdDp2ZATOlpBYPMtS/IWhJ985u58TSS+Kl8qpnpaZBSxgJirf\\nhWzhnKLfAgMBAAECggEAJP785SePGhS7ZN6ltspm+l+hSjYFrPWFCxq+rlQ1YkHZ\\nC9l+RqKSFhOkiPmQI2s4wbXl3kFxLHHlFNoi/q2wKQBmGb8TQfnRJpjjNHGA61Ev\\n0Ue7/6qPvVb9B2MsLw/FxKiTFPuMG3bgKR9pbSFuJLYoaW7zqITOhVnYphGTqwAY\\nBVVcvISSLvELDmH9VZcv/9DVqVlqbbESHWh1Z4W6XGPoEqeDH/upNTyQQ/46Msgm\\nTGE6VqLHpWuSf6SqHp+r0Y0lI3vIPM1vz5FAJDJbOE/enHa0fSup0OHSMxl0HVMn\\nnO1yrGF3vsIPOej5HKr5d71bEIckzk73/yjNC1/mDQKBgQD7RtUvc9omsSsFMJ6e\\nBASAn6Dktx/QY/XNJjFzHQj69cywLDe5t5AL2gUi3phQ2oqB5XJdwnd5bTIEPEPZ\\nDOuOai2802p6FJk6kjmZAMVGx5JtXBH+vs6jrmQQSMiKbjwN1TT6xIWakvLOonUi\\nX6ZvjYYjU/E0YJU3jSiXWEr76wKBgQD5Zn4SouJ6BCDZMbausJVMBkk3qxsYooip\\np89WakC6e7AZinpkRcqjGGV9GOvc8crJs6fyXAA9ORepGP47Mc0ZrDssOkstznsM\\npr8R0S6MKwEZaT9ixOHdOcLZ47ps+JzA2Wr4KN2OvFHksUkB/46ATD1j9WZVgB8M\\namsYp/Y73QKBgHOo+PvsoZ9psVmkNX6abtAdqdtdB0HOoRea2uwXk0ig12TIFaZg\\nfedWpUKVnxqoXVTJHklV99RmlL0qWDiSH+LfsMnXro0e6iDxqZ1po2Se/CFmXcoa\\nXdctsFVmixhdATuExewfhTfPKABA+xWlXWC/jdy5CK+JPWXijaqMM4edAoGAE5Bj\\nsWiPpYyvWvpYX0nA3G7dzX0hqgQN/mkIjbnWDArp3IcNZNJIvBSM2Yxb7EAXbU0n\\njo6DAkp5Pa2VO+WDNlFZbvW/sf8xjeOCt44WPa6d7nVgIIpbQXRngZoopKW3/jTP\\n/FmQT8McFXmGxZ5belsAsdetSGW9icbLUerTGQ0CgYEAmf/G8Ag3XxmqTXvvHuv2\\n14OP7WnrVqkEMnydrftEwn4peXd/Lz+/GYX5Zc4ZoNgbN8IvZ5z0+OmRsallsbiW\\nBw0/tc68CjzxXOvReWxDluUopqWVGj5tlGqE5xUDku9SWJSxbkiQ3rqutzBdPXpr\\noqHwPyDrmK/Zgqn+uiIm4Ck=\\n-----END PRIVATE KEY-----\\n",
- "client_email": "firebase-adminsdk-o2wqi@ride-b1bd8.iam.gserviceaccount.com",
- "client_id": "111210077025005706623",
- "auth_uri": "https://accounts.google.com/o/oauth2/auth",
- "token_uri": "https://oauth2.googleapis.com/token",
- "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
- "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-o2wqi%40ride-b1bd8.iam.gserviceaccount.com",
- "universe_domain": "googleapis.com"
-}
-'''; // As defined above
-
+ if (serviceAccountKeyJson.isEmpty) {
+ print("🔴 Error: Service Account Key is empty");
+ return;
+ }
// Initialize AccessTokenManager
final accessTokenManager = AccessTokenManager(serviceAccountKeyJson);
// Obtain an OAuth 2.0 access token
final accessToken = await accessTokenManager.getAccessToken();
+ // Log.print('accessToken: ${accessToken}');
// Send the notification
final response = await http.post(
@@ -666,26 +656,16 @@ class FirebaseMessagesController extends GetxController {
{int retryCount = 2}) async {
try {
final privateKey = await storage.read(key: 'FCM_PRIVATE_KEY');
- String serviceAccountKeyJson = '''{
- "type": "service_account",
- "project_id": "ride-b1bd8",
- "private_key_id": "75e817c0b902db2ef35edf2c2bd159dec1f13249",
- "private_key": "-----BEGIN PRIVATE KEY-----\\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQD0zH9TQGDQHUv3\\na3/JAD1UKPwAp3wNKT0a6fxiIzjI3JxQWI30QvZCcfl6CdMhIcydX1ncSaYTcEeC\\n/AdPVCPkqyJx1YIGGg6P/mRzCWeaN8fsp6z250m5vcObDCZc3dbJEkepbep+6FPY\\n21m3KO+AHh1glgsTGZOTm5xiU8NGXpdk2QEh8wpiIIlR/HuKwVw9g8urNe3Sno+U\\nDm3z37iFqvZdmpqO8aWTJu6beb3hsREK9XK2I9JqC2JUwiGQRo3idOvPP6hkqrWx\\nKSX96vglQFYfakvJdDp2ZATOlpBYPMtS/IWhJ985u58TSS+Kl8qpnpaZBSxgJirf\\nhWzhnKLfAgMBAAECggEAJP785SePGhS7ZN6ltspm+l+hSjYFrPWFCxq+rlQ1YkHZ\\nC9l+RqKSFhOkiPmQI2s4wbXl3kFxLHHlFNoi/q2wKQBmGb8TQfnRJpjjNHGA61Ev\\n0Ue7/6qPvVb9B2MsLw/FxKiTFPuMG3bgKR9pbSFuJLYoaW7zqITOhVnYphGTqwAY\\nBVVcvISSLvELDmH9VZcv/9DVqVlqbbESHWh1Z4W6XGPoEqeDH/upNTyQQ/46Msgm\\nTGE6VqLHpWuSf6SqHp+r0Y0lI3vIPM1vz5FAJDJbOE/enHa0fSup0OHSMxl0HVMn\\nnO1yrGF3vsIPOej5HKr5d71bEIckzk73/yjNC1/mDQKBgQD7RtUvc9omsSsFMJ6e\\nBASAn6Dktx/QY/XNJjFzHQj69cywLDe5t5AL2gUi3phQ2oqB5XJdwnd5bTIEPEPZ\\nDOuOai2802p6FJk6kjmZAMVGx5JtXBH+vs6jrmQQSMiKbjwN1TT6xIWakvLOonUi\\nX6ZvjYYjU/E0YJU3jSiXWEr76wKBgQD5Zn4SouJ6BCDZMbausJVMBkk3qxsYooip\\np89WakC6e7AZinpkRcqjGGV9GOvc8crJs6fyXAA9ORepGP47Mc0ZrDssOkstznsM\\npr8R0S6MKwEZaT9ixOHdOcLZ47ps+JzA2Wr4KN2OvFHksUkB/46ATD1j9WZVgB8M\\namsYp/Y73QKBgHOo+PvsoZ9psVmkNX6abtAdqdtdB0HOoRea2uwXk0ig12TIFaZg\\nfedWpUKVnxqoXVTJHklV99RmlL0qWDiSH+LfsMnXro0e6iDxqZ1po2Se/CFmXcoa\\nXdctsFVmixhdATuExewfhTfPKABA+xWlXWC/jdy5CK+JPWXijaqMM4edAoGAE5Bj\\nsWiPpYyvWvpYX0nA3G7dzX0hqgQN/mkIjbnWDArp3IcNZNJIvBSM2Yxb7EAXbU0n\\njo6DAkp5Pa2VO+WDNlFZbvW/sf8xjeOCt44WPa6d7nVgIIpbQXRngZoopKW3/jTP\\n/FmQT8McFXmGxZ5belsAsdetSGW9icbLUerTGQ0CgYEAmf/G8Ag3XxmqTXvvHuv2\\n14OP7WnrVqkEMnydrftEwn4peXd/Lz+/GYX5Zc4ZoNgbN8IvZ5z0+OmRsallsbiW\\nBw0/tc68CjzxXOvReWxDluUopqWVGj5tlGqE5xUDku9SWJSxbkiQ3rqutzBdPXpr\\noqHwPyDrmK/Zgqn+uiIm4Ck=\\n-----END PRIVATE KEY-----\\n",
- "client_email": "firebase-adminsdk-o2wqi@ride-b1bd8.iam.gserviceaccount.com",
- "client_id": "111210077025005706623",
- "auth_uri": "https://accounts.google.com/o/oauth2/auth",
- "token_uri": "https://oauth2.googleapis.com/token",
- "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
- "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-o2wqi%40ride-b1bd8.iam.gserviceaccount.com",
- "universe_domain": "googleapis.com"
-}
-'''; // As defined above
-
+ if (serviceAccountKeyJson.isEmpty) {
+ print("🔴 Error: Service Account Key is empty");
+ return;
+ }
// Initialize AccessTokenManager
final accessTokenManager = AccessTokenManager(serviceAccountKeyJson);
// Obtain an OAuth 2.0 access token
final accessToken = await accessTokenManager.getAccessToken();
+ // Log.print('accessToken: ${accessToken}');
// Send the notification
final response = await http.post(
diff --git a/lib/controller/functions/crud.dart b/lib/controller/functions/crud.dart
index 7c06e58..6987f5d 100644
--- a/lib/controller/functions/crud.dart
+++ b/lib/controller/functions/crud.dart
@@ -1,12 +1,18 @@
import 'dart:convert';
+import 'package:secure_string_operations/secure_string_operations.dart';
import 'package:sefer_driver/constant/box_name.dart';
import 'package:sefer_driver/constant/links.dart';
+import 'package:sefer_driver/controller/auth/captin/login_captin_controller.dart';
+import 'package:sefer_driver/controller/functions/add_error.dart';
import 'package:sefer_driver/main.dart';
import 'package:get/get.dart';
import 'package:http/http.dart' as http;
import 'package:sefer_driver/env/env.dart';
+import 'package:sefer_driver/views/widgets/error_snakbar.dart';
import '../../constant/api_key.dart';
+import '../../constant/char_map.dart';
+import '../../constant/info.dart';
import '../../print.dart';
import 'gemeni.dart';
import 'upload_image.dart';
@@ -25,28 +31,43 @@ class CRUD {
headers: {
"Content-Type": "application/x-www-form-urlencoded",
'Authorization':
- 'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials.toString()))}',
+ 'Bearer ${X.r(X.r(X.r(box.read(BoxName.jwt), cn), cC), cs).toString().split(AppInformation.addd)[0]}'
},
);
- Log.print('request: ${response.request}');
- Log.print('response: ${response.body}');
- Log.print('payload: ${payload}');
- // if (response.statusCode == 200) {
- var jsonData = jsonDecode(response.body);
- if (jsonData['status'] == 'success') {
- return response.body;
- }
+ if (response.statusCode == 200) {
+ var jsonData = jsonDecode(response.body);
+ if (jsonData['status'] == 'success') {
+ return response.body;
+ }
- return jsonData['status'];
+ return jsonData['status'];
+ } else if (response.statusCode == 401) {
+ // Specifically handle 401 Unauthorized
+ var jsonData = jsonDecode(response.body);
+
+ if (jsonData['error'] == 'Token expired') {
+ // Show snackbar prompting to re-login
+ await Get.put(LoginDriverController()).getJWT();
+ mySnackbarSuccess('please order now'.tr);
+
+ return 'token_expired'; // Return a specific value for token expiration
+ } else {
+ // Other 401 errors
+ addError('Unauthorized: ${jsonData['error']}', 'crud().post - 401');
+ return 'failure';
+ }
+ } else {
+ addError('Non-200 response code: ${response.statusCode}',
+ 'crud().post - Other');
+ return 'failure';
+ }
}
- // }
- Future post({
+ Future getWallet({
required String link,
Map? payload,
}) async {
- // String? basicAuthCredentials =
- // await storage.read(key: BoxName.basicAuthCredentials);
+ var s = await LoginDriverController().getJwtWallet();
var url = Uri.parse(
link,
);
@@ -55,25 +76,94 @@ class CRUD {
body: payload,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
- 'Authorization':
- 'Basic ${base64Encode(utf8.encode(AK.basicAuthCredentials))}',
+ 'Authorization': 'Bearer $s'
},
);
- Log.print('request: ${response.request}');
- Log.print('response: ${response.body}');
- Log.print('payload: ${payload}');
- var jsonData = jsonDecode(response.body);
if (response.statusCode == 200) {
+ var jsonData = jsonDecode(response.body);
if (jsonData['status'] == 'success') {
return response.body;
+ }
+
+ return jsonData['status'];
+ } else if (response.statusCode == 401) {
+ // Specifically handle 401 Unauthorized
+ var jsonData = jsonDecode(response.body);
+
+ if (jsonData['error'] == 'Token expired') {
+ // Show snackbar prompting to re-login
+ await Get.put(LoginDriverController()).getJwtWallet();
+
+ return 'token_expired'; // Return a specific value for token expiration
} else {
- // String errorMessage = jsonData['message'];
- // Get.snackbar('Error'.tr, errorMessage.tr,
- // backgroundColor: AppColor.redColor);
- return (jsonData['status']);
+ // Other 401 errors
+ addError('Unauthorized: ${jsonData['error']}', 'crud().post - 401');
+ return 'failure';
}
} else {
- return response.statusCode;
+ addError('Non-200 response code: ${response.statusCode}',
+ 'crud().post - Other');
+ return 'failure';
+ }
+ }
+
+ Future post(
+ {required String link, Map? payload}) async {
+ var url = Uri.parse(link);
+ try {
+ var response = await http.post(
+ url,
+ body: payload,
+ headers: {
+ "Content-Type": "application/x-www-form-urlencoded",
+ 'Authorization':
+ 'Bearer ${X.r(X.r(X.r(box.read(BoxName.jwt), cn), cC), cs).toString().split(AppInformation.addd)[0]}'
+ // 'Authorization': 'Bearer ${box.read(BoxName.jwt)}'
+ },
+ );
+ if (response.statusCode == 200) {
+ try {
+ var jsonData = jsonDecode(response.body);
+ if (jsonData['status'] == 'success') {
+ return jsonData;
+ } else {
+ return jsonData['status'];
+ }
+ } catch (e) {
+ addError(e.toString(), 'crud().post - JSON decoding');
+ return 'failure';
+ }
+ } else if (response.statusCode == 401) {
+ // Specifically handle 401 Unauthorized
+ var jsonData = jsonDecode(response.body);
+
+ if (jsonData['error'] == 'Token expired') {
+ // Show snackbar prompting to re-login
+ await Get.put(LoginDriverController()).getJWT();
+ // MyDialog().getDialog(
+ // 'Session expired. Please log in again.'.tr,
+ // '',
+ // () {
+ // Get.put(LoginController()).loginUsingCredentials(
+ // box.read(BoxName.passengerID), box.read(BoxName.email));
+ // Get.back();
+ // },
+ // );
+
+ return 'token_expired'; // Return a specific value for token expiration
+ } else {
+ // Other 401 errors
+ addError('Unauthorized: ${jsonData['error']}', 'crud().post - 401');
+ return 'failure';
+ }
+ } else {
+ addError('Non-200 response code: ${response.statusCode}',
+ 'crud().post - Other');
+ return 'failure';
+ }
+ } catch (e) {
+ addError('HTTP request error: $e', 'crud().post - HTTP');
+ return 'failure';
}
}
diff --git a/lib/controller/functions/encrypt_decrypt.dart b/lib/controller/functions/encrypt_decrypt.dart
index d6f6536..4a97641 100644
--- a/lib/controller/functions/encrypt_decrypt.dart
+++ b/lib/controller/functions/encrypt_decrypt.dart
@@ -1,34 +1,50 @@
import 'package:encrypt/encrypt.dart' as encrypt;
import 'package:flutter/foundation.dart';
-import '../../env/env.dart';
-
-var secretKey = Env.keyOfApp
- .toString()
- .split('XrXlBl')[0]; // Must be 16 characters for AES-128
-String initializationVector = Env.initializationVector; // Must be 16 characters
-
-final encryptionHelper = EncryptionHelper(
- secretKey: secretKey,
- initializationVector: initializationVector,
-);
+import '../../constant/box_name.dart';
+import '../../main.dart';
class EncryptionHelper {
- final encrypt.Key key;
- final encrypt.IV iv;
+ static EncryptionHelper? _instance;
- EncryptionHelper(
- {required String secretKey, required String initializationVector})
- : key = encrypt.Key.fromUtf8(secretKey),
- iv = encrypt.IV.fromUtf8(initializationVector);
+ late final encrypt.Key key;
+ late final encrypt.IV iv;
- // Initialize the helper
+ EncryptionHelper._(this.key, this.iv);
+ static EncryptionHelper get instance {
+ if (_instance == null) {
+ throw Exception(
+ "EncryptionHelper is not initialized. Call `await EncryptionHelper.initialize()` in main.");
+ }
+ return _instance!;
+ }
- /// Encrypts the given plain text
+ /// Initializes and stores the instance globally
+ static Future initialize() async {
+ if (_instance != null) {
+ debugPrint("EncryptionHelper is already initialized.");
+ return; // Prevent re-initialization
+ }
+ debugPrint("Initializing EncryptionHelper...");
+ // Read stored keys
+ String? keyOfApp = await storage.read(key: BoxName.keyOfApp);
+ // Log.print('keyOfApp: ${keyOfApp}');
+ String? initializationVector =
+ await storage.read(key: BoxName.initializationVector);
+ // Log.print('initializationVector: ${initializationVector}');
+ // Set the global instance
+ _instance = EncryptionHelper._(
+ encrypt.Key.fromUtf8(keyOfApp!),
+ encrypt.IV.fromUtf8(initializationVector!),
+ );
+ debugPrint("EncryptionHelper initialized successfully.");
+ }
+
+ /// Encrypts a string
String encryptData(String plainText) {
try {
- final encrypter = encrypt.Encrypter(encrypt.AES(key,
- mode: encrypt.AESMode.cbc)); // Explicitly use CBC mode
+ final encrypter =
+ encrypt.Encrypter(encrypt.AES(key, mode: encrypt.AESMode.cbc));
final encrypted = encrypter.encrypt(plainText, iv: iv);
return encrypted.base64;
} catch (e) {
@@ -37,14 +53,13 @@ class EncryptionHelper {
}
}
- /// Decrypts the given encrypted text
+ /// Decrypts a string
String decryptData(String encryptedText) {
try {
- final encrypter = encrypt.Encrypter(encrypt.AES(key,
- mode: encrypt.AESMode.cbc)); // Explicitly use CBC mode
+ final encrypter =
+ encrypt.Encrypter(encrypt.AES(key, mode: encrypt.AESMode.cbc));
final encrypted = encrypt.Encrypted.fromBase64(encryptedText);
- final decrypted = encrypter.decrypt(encrypted, iv: iv);
- return decrypted;
+ return encrypter.decrypt(encrypted, iv: iv);
} catch (e) {
debugPrint('Decryption Error: $e');
return '';
diff --git a/lib/controller/functions/face_detect.dart b/lib/controller/functions/face_detect.dart
index 9b10461..e310dc7 100644
--- a/lib/controller/functions/face_detect.dart
+++ b/lib/controller/functions/face_detect.dart
@@ -24,9 +24,9 @@ Future faceDetector() async {
request.body = json.encode({
"url1":
- "${AppLink.seferCairoServer}/card_image/id_front-${encryptionHelper.decryptData(box.read(BoxName.driverID))}.jpg",
+ "${AppLink.seferCairoServer}/card_image/id_front-${EncryptionHelper.instance.decryptData(box.read(BoxName.driverID))}.jpg",
"url2":
- "https://api.sefer.live/sefer/card_image/face_detect-${encryptionHelper.decryptData(box.read(BoxName.driverID))}.jpg"
+ "https://api.sefer.live/sefer/card_image/face_detect-${EncryptionHelper.instance.decryptData(box.read(BoxName.driverID))}.jpg"
});
print('request.body: ${request.body}');
request.headers.addAll(headers);
diff --git a/lib/controller/functions/gemeni.dart b/lib/controller/functions/gemeni.dart
index 530fb49..70448a1 100644
--- a/lib/controller/functions/gemeni.dart
+++ b/lib/controller/functions/gemeni.dart
@@ -394,10 +394,10 @@ class AI extends GetxController {
update();
var payload = {
- 'first_name': encryptionHelper.encryptData(
+ 'first_name': EncryptionHelper.instance.encryptData(
responseNonIdCardFront['full_name'].toString().split(' ')[0]) ??
'Not specified',
- 'last_name': encryptionHelper.encryptData(
+ 'last_name': EncryptionHelper.instance.encryptData(
responseNonIdCardFront['full_name'].toString().split(' ').last) ??
'Not specified',
'email': box.read(BoxName.emailDriver)?.toString() ?? 'Not specified',
@@ -410,14 +410,14 @@ class AI extends GetxController {
.passwordController
.text
.toString(),
- 'gender': encryptionHelper
+ 'gender': EncryptionHelper.instance
.encryptData(responseNonIdCardFront['gender'].toString()) ??
'Not specified',
'license_type': 'Foreign',
- 'national_number': encryptionHelper
+ 'national_number': EncryptionHelper.instance
.encryptData(responseNonIdCardFront['passport_no'].toString()) ??
'Not specified',
- 'name_arabic': encryptionHelper
+ 'name_arabic': EncryptionHelper.instance
.encryptData(responseNonIdCardFront['full_name'].toString()) ??
'Not specified',
'name_english': 'Not specified',
@@ -431,30 +431,30 @@ class AI extends GetxController {
? responseIdEgyptDriverLicense['license_categories'].join(', ')
: responseIdEgyptDriverLicense['license_categories']?.toString() ??
'Not specified',
- 'address': encryptionHelper
+ 'address': EncryptionHelper.instance
.encryptData(responseNonIdCardFront['address'].toString()) ??
'Not specified',
- 'card_id': encryptionHelper
+ 'card_id': EncryptionHelper.instance
.encryptData(responseNonIdCardFront['card_id'].toString()) ??
'Not specified',
- 'occupation': encryptionHelper
+ 'occupation': EncryptionHelper.instance
.encryptData(responseNonIdCardBack['workStatus'].toString()) ??
'Not specified',
'education': 'Not specified',
'licenseIssueDate':
responseNonIdCardBack['issueDate']?.toString() ?? 'Not specified',
- 'religion': encryptionHelper
+ 'religion': EncryptionHelper.instance
.encryptData(responseNonIdCardFront['country'].toString()) ??
'Not specified',
'status': 'yet',
- 'birthdate': encryptionHelper
+ 'birthdate': EncryptionHelper.instance
.encryptData(responseNonIdCardFront['birthdate'].toString()) ??
'Not specified',
'maritalStatus': 'Not specified',
- 'site': encryptionHelper
+ 'site': EncryptionHelper.instance
.encryptData(responseNonIdCardFront['address'].toString()) ??
'Not specified',
- 'employmentType': encryptionHelper
+ 'employmentType': EncryptionHelper.instance
.encryptData(responseNonIdCardBack['residencyType'].toString()) ??
'Not specified',
};
@@ -499,10 +499,10 @@ class AI extends GetxController {
update();
var payload = {
- 'first_name': encryptionHelper.encryptData(
+ 'first_name': EncryptionHelper.instance.encryptData(
responseIdEgyptDriverLicense['firstName'].toString()) ??
'Not specified',
- 'last_name': encryptionHelper.encryptData(
+ 'last_name': EncryptionHelper.instance.encryptData(
responseIdEgyptDriverLicense['lastName'].toString()) ??
'Not specified',
'email': box.read(BoxName.emailDriver)?.toString() ?? 'Not specified',
@@ -515,18 +515,18 @@ class AI extends GetxController {
.passwordController
.text
.toString(),
- 'gender': encryptionHelper
+ 'gender': EncryptionHelper.instance
.encryptData(responseIdEgyptBack['gender'].toString()) ??
'Not specified',
- 'license_type': encryptionHelper.encryptData(
+ 'license_type': EncryptionHelper.instance.encryptData(
responseIdEgyptDriverLicense['license_type'].toString()) ??
'Not specified',
- 'national_number': encryptionHelper
+ 'national_number': EncryptionHelper.instance
.encryptData(responseIdEgyptBack['nationalID'].toString()) ??
'Not specified',
- 'name_arabic': encryptionHelper
+ 'name_arabic': EncryptionHelper.instance
.encryptData(responseIdEgyptDriverLicense['name_arabic'].toString()),
- 'name_english': encryptionHelper
+ 'name_english': EncryptionHelper.instance
.encryptData(responseIdEgyptDriverLicense['name_english'].toString()),
'issue_date': responseIdEgyptDriverLicense['issue_date']?.toString() ??
'Not specified',
@@ -537,34 +537,34 @@ class AI extends GetxController {
? responseIdEgyptDriverLicense['license_categories'].join(', ')
: responseIdEgyptDriverLicense['license_categories']?.toString() ??
'Not specified',
- 'address': encryptionHelper
+ 'address': EncryptionHelper.instance
.encryptData(responseIdEgyptFront['address'].toString()) ??
'Not specified',
- 'card_id': encryptionHelper
+ 'card_id': EncryptionHelper.instance
.encryptData(responseIdEgyptFront['card_id'].toString()) ??
'Not specified',
- 'occupation': encryptionHelper
+ 'occupation': EncryptionHelper.instance
.encryptData(responseIdEgyptBack['occupation'].toString()) ??
'Not specified',
- 'education': encryptionHelper
+ 'education': EncryptionHelper.instance
.encryptData(responseIdEgyptBack['occupation'].toString()) ??
'Not specified',
'licenseIssueDate':
responseIdEgyptDriverLicense['issue_date'].toString() ??
'Not specified',
- 'religion': encryptionHelper
+ 'religion': EncryptionHelper.instance
.encryptData(responseIdEgyptBack['religion'].toString()) ??
'Not specified',
'status': 'yet',
- 'birthdate': encryptionHelper.encryptData(extractDOB(
+ 'birthdate': EncryptionHelper.instance.encryptData(extractDOB(
responseIdEgyptDriverLicense['national_number'].toString())),
- 'maritalStatus': encryptionHelper
+ 'maritalStatus': EncryptionHelper.instance
.encryptData(responseIdEgyptBack['maritalStatus'].toString()) ??
'Not specified',
- 'site': encryptionHelper.encryptData(
+ 'site': EncryptionHelper.instance.encryptData(
responseIdEgyptDriverLicense['address'].toString()) ??
'Not specified',
- 'employmentType': encryptionHelper.encryptData(
+ 'employmentType': EncryptionHelper.instance.encryptData(
responseIdEgyptDriverLicense['employmentType'].toString()) ??
'Not specified',
};
@@ -609,7 +609,7 @@ class AI extends GetxController {
var res = await CRUD().post(link: AppLink.addCriminalDocuments, payload: {
"driverId": box.read(BoxName.driverID),
"IssueDate": responseCriminalRecordEgypt['IssueDate'],
- "InspectionResult": encryptionHelper
+ "InspectionResult": EncryptionHelper.instance
.encryptData(responseCriminalRecordEgypt['InspectionResult']),
});
if (res != 'failure') {
@@ -624,7 +624,7 @@ class AI extends GetxController {
var res = await CRUD().post(link: AppLink.addRegisrationCar, payload: {
'driverID': box.read(BoxName.driverID),
'vin': responseIdCardDriverEgyptBack['chassis'].toString(),
- 'car_plate': encryptionHelper.encryptData(
+ 'car_plate': EncryptionHelper.instance.encryptData(
responseIdCardDriverEgyptFront['car_plate'].toString()),
'make': (responseIdCardDriverEgyptBack['make'].toString()),
'model': (responseIdCardDriverEgyptBack['model']),
@@ -632,10 +632,10 @@ class AI extends GetxController {
'expiration_date':
responseIdCardDriverEgyptFront['LicenseExpirationDate'].toString(),
'color': responseIdCardDriverEgyptBack['color'],
- 'owner': encryptionHelper
+ 'owner': EncryptionHelper.instance
.encryptData(responseIdCardDriverEgyptFront['owner']),
'color_hex': responseIdCardDriverEgyptBack['color_hex'].toString(),
- 'address': encryptionHelper
+ 'address': EncryptionHelper.instance
.encryptData(responseIdCardDriverEgyptFront['address'].toString()),
'displacement': responseIdCardDriverEgyptBack['engine'].toString(),
'fuel': responseIdCardDriverEgyptBack['fuel'].toString(),
@@ -654,7 +654,7 @@ class AI extends GetxController {
payload: {
'driverID': box.read(BoxName.driverID),
'vin': responseIdCardDriverEgyptBack['chassis'].toString(),
- 'car_plate': encryptionHelper.encryptData(
+ 'car_plate': EncryptionHelper.instance.encryptData(
responseIdCardDriverEgyptFront['car_plate'].toString()),
'make': (responseIdCardDriverEgyptBack['make'].toString()),
'model': (responseIdCardDriverEgyptBack['model']),
@@ -663,11 +663,11 @@ class AI extends GetxController {
responseIdCardDriverEgyptFront['LicenseExpirationDate']
.toString(),
'color': responseIdCardDriverEgyptBack['color'],
- 'owner': encryptionHelper
+ 'owner': EncryptionHelper.instance
.encryptData(responseIdCardDriverEgyptFront['owner']),
'color_hex':
responseIdCardDriverEgyptBack['color_hex'].toString(),
- 'address': encryptionHelper.encryptData(
+ 'address': EncryptionHelper.instance.encryptData(
responseIdCardDriverEgyptFront['address'].toString()),
'displacement':
responseIdCardDriverEgyptBack['engine'].toString(),
@@ -680,7 +680,7 @@ class AI extends GetxController {
payload: {
'driverID': box.read(BoxName.driverID),
'vin': responseIdCardDriverEgyptBack['chassis'].toString(),
- 'car_plate': encryptionHelper.encryptData(
+ 'car_plate': EncryptionHelper.instance.encryptData(
responseIdCardDriverEgyptFront['car_plate'].toString()),
'make': (responseIdCardDriverEgyptBack['make'].toString()),
'model': (responseIdCardDriverEgyptBack['model']),
@@ -689,11 +689,11 @@ class AI extends GetxController {
responseIdCardDriverEgyptFront['LicenseExpirationDate']
.toString(),
'color': responseIdCardDriverEgyptBack['color'],
- 'owner': encryptionHelper
+ 'owner': EncryptionHelper.instance
.encryptData(responseIdCardDriverEgyptFront['owner']),
'color_hex':
responseIdCardDriverEgyptBack['color_hex'].toString(),
- 'address': encryptionHelper.encryptData(
+ 'address': EncryptionHelper.instance.encryptData(
responseIdCardDriverEgyptFront['address'].toString()),
'displacement':
responseIdCardDriverEgyptBack['engine'].toString(),
diff --git a/lib/controller/functions/location_controller.dart b/lib/controller/functions/location_controller.dart
index 61e5677..74e60e6 100644
--- a/lib/controller/functions/location_controller.dart
+++ b/lib/controller/functions/location_controller.dart
@@ -91,7 +91,7 @@ class LocationController extends GetxController {
longitude >= minLongitude &&
longitude <= maxLongitude) {
box.write(BoxName.serverChosen,
- encryptionHelper.decryptData(locationData['server_link']));
+ EncryptionHelper.instance.decryptData(locationData['server_link']));
// Log.print(
// 'locationData----server_link: ${locationData['server_link']}');
return locationData['name'];
diff --git a/lib/controller/functions/log_out.dart b/lib/controller/functions/log_out.dart
index 6fb3021..661a8f6 100644
--- a/lib/controller/functions/log_out.dart
+++ b/lib/controller/functions/log_out.dart
@@ -76,7 +76,8 @@ class LogOutController extends GetxController {
title: 'Delete'.tr,
onPressed: () async {
if (checkTxtController.text ==
- encryptionHelper.decryptData(box.read(BoxName.nameDriver))) {
+ EncryptionHelper.instance
+ .decryptData(box.read(BoxName.nameDriver))) {
// deletecaptainAccount();
var id = await checkBeforeDelete();
@@ -101,23 +102,10 @@ class LogOutController extends GetxController {
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(AppColor.redColor),
),
- onPressed: () {
+ onPressed: () async {
// box.remove(BoxName.agreeTerms);
- box.remove(BoxName.driverID);
- box.remove(BoxName.email);
- box.remove(BoxName.lang);
- box.remove(BoxName.name);
- box.remove(BoxName.passengerID);
- box.remove(BoxName.phone);
- box.remove(BoxName.tokenFCM);
- box.remove(BoxName.tokens);
- box.remove(BoxName.addHome);
- box.remove(BoxName.addWork);
- box.remove(BoxName.agreeTerms);
- box.remove(BoxName.apiKeyRun);
- box.remove(BoxName.countryCode);
- box.remove(BoxName.accountIdStripeConnect);
- box.remove(BoxName.passengerWalletTotal);
+ await box.erase();
+ await storage.deleteAll();
Get.offAll(OnBoardingPage());
},
child: Text(
@@ -144,27 +132,10 @@ class LogOutController extends GetxController {
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(AppColor.redColor),
),
- onPressed: () {
+ onPressed: () async {
// box.remove(BoxName.agreeTerms);
- box.remove(BoxName.driverID);
- box.remove(BoxName.sexDriver);
- box.remove(BoxName.dobDriver);
- box.remove(BoxName.nameDriver);
- box.remove(BoxName.emailDriver);
- box.remove(BoxName.phoneDriver);
- box.remove(BoxName.statusDriverLocation);
- box.remove(BoxName.cvvCodeDriver);
- box.remove(BoxName.lastNameDriver);
- box.remove(BoxName.passwordDriver);
- box.remove(BoxName.cardNumberDriver);
- box.remove(BoxName.expiryDateDriver);
- box.remove(BoxName.cardHolderNameDriver);
- box.remove(BoxName.vin);
- box.remove(BoxName.make);
- box.remove(BoxName.year);
- box.remove(BoxName.owner);
- box.remove(BoxName.onBoarding);
- box.remove(BoxName.agreeTerms);
+ await box.erase();
+ await storage.deleteAll();
Get.offAll(OnBoardingPage());
},
child: Text(
diff --git a/lib/controller/functions/package_info.dart b/lib/controller/functions/package_info.dart
index 82def9a..1517464 100644
--- a/lib/controller/functions/package_info.dart
+++ b/lib/controller/functions/package_info.dart
@@ -1,6 +1,8 @@
import 'dart:convert';
import 'dart:io';
import 'dart:ui';
+import 'package:device_info_plus/device_info_plus.dart';
+import 'package:jailbreak_root_detection/jailbreak_root_detection.dart';
import 'package:sefer_driver/constant/box_name.dart';
import 'package:sefer_driver/constant/colors.dart';
import 'package:sefer_driver/constant/links.dart';
@@ -12,6 +14,7 @@ import 'package:package_info_plus/package_info_plus.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../constant/info.dart';
import '../../main.dart';
+import 'encrypt_decrypt.dart';
Future checkForUpdate(BuildContext context) async {
final packageInfo = await PackageInfo.fromPlatform();
@@ -159,3 +162,122 @@ void showUpdateDialog(BuildContext context) {
},
);
}
+
+getDeviceFingerprint() async {
+ final deviceInfo = await DeviceInfoPlugin().deviceInfo;
+ var deviceData;
+
+ if (Platform.isAndroid) {
+ deviceData = deviceInfo.data;
+ } else if (Platform.isIOS) {
+ deviceData = deviceInfo.data;
+ }
+
+ final String deviceId =
+ deviceData['androidId'] ?? deviceData['identifierForVendor'];
+ final String deviceModel = deviceData['model'];
+ final String osVersion = deviceData['systemVersion'];
+
+ return EncryptionHelper.instance
+ .encryptData('${deviceId}_${deviceModel}_$osVersion');
+}
+
+class SecurityHelper {
+ /// Performs security checks and handles potential risks
+ static Future performSecurityChecks() async {
+ bool isNotTrust = false;
+ bool isJailBroken = false;
+ bool isRealDevice = true;
+ bool isOnExternalStorage = false;
+ bool checkForIssues = false;
+ bool isDevMode = false;
+ bool isTampered = false;
+ String bundleId = "";
+
+ try {
+ isNotTrust = await JailbreakRootDetection.instance.isNotTrust;
+ isJailBroken = await JailbreakRootDetection.instance.isJailBroken;
+ isRealDevice = await JailbreakRootDetection.instance.isRealDevice;
+ isOnExternalStorage =
+ await JailbreakRootDetection.instance.isOnExternalStorage;
+
+ List issues =
+ await JailbreakRootDetection.instance.checkForIssues;
+ checkForIssues = issues.isNotEmpty;
+
+ isDevMode = await JailbreakRootDetection.instance.isDevMode;
+
+ // Get Bundle ID
+ PackageInfo packageInfo = await PackageInfo.fromPlatform();
+ bundleId = packageInfo.packageName;
+ if (bundleId.isNotEmpty) {
+ // Pass the CORRECT bundle ID to isTampered
+ isTampered = await JailbreakRootDetection.instance.isTampered(bundleId);
+ }
+ } catch (e) {
+ debugPrint("Error during security checks: $e");
+ // Consider handling specific exceptions, not just general errors.
+ }
+
+ // Save values to storage (using GetStorage)
+ await box.write('isNotTrust', isNotTrust); // Use await for write operations
+ await box.write('isTampered', isTampered); // Use await
+ await box.write('isJailBroken', isJailBroken); // Use await
+
+ // debugPrint("Security Check Results:");
+ // debugPrint("isNotTrust: $isNotTrust");
+ // debugPrint("isJailBroken: $isJailBroken");
+ // debugPrint("isRealDevice: $isRealDevice");
+ // debugPrint("isOnExternalStorage: $isOnExternalStorage");
+ // debugPrint("checkForIssues: $checkForIssues");
+ // debugPrint("isDevMode: $isDevMode");
+ // debugPrint("isTampered: $isTampered");
+ // debugPrint("Bundle ID: $bundleId"); // Print the bundle ID
+
+ // Check for security risks and potentially show a warning
+ if (isNotTrust ||
+ isJailBroken ||
+ isTampered ||
+ isDevMode ||
+ isOnExternalStorage ||
+ !isRealDevice) {
+ // print("security_warning".tr); //using easy_localization
+ // Use a more robust approach to show a warning, like a dialog:
+ _showSecurityWarning();
+ }
+ }
+
+ /// Deletes all app data
+ static Future clearAllData() async {
+ //await storage.deleteAll(); // What's 'storage'? Be specific. Likely GetStorage as well.
+ await box.erase(); // Clear GetStorage data
+ exit(0); // This will terminate the app. Be VERY careful with this.
+ }
+
+ static void _showSecurityWarning() {
+ // Show a dialog, navigate to an error screen, etc.
+ // Example using Get.dialog (if you use GetX):
+
+ Get.dialog(
+ AlertDialog(
+ title: Text("Security Warning".tr), // Or use localized string
+ content: Text(
+ "Potential security risks detected. The application may not function correctly."
+ .tr), //Or use localized string
+ actions: [
+ TextButton(
+ onPressed: () async {
+ await storage.deleteAll();
+ await box.erase();
+ Get.back(); // Close the dialog
+ // Or, if you really must, exit the app (but give the user a chance!)
+ exit(0);
+ },
+ child: Text("OK"), // Or use a localized string
+ ),
+ ],
+ ),
+ barrierDismissible: false, // Prevent closing by tapping outside
+ );
+ }
+}
diff --git a/lib/controller/functions/secure_storage.dart b/lib/controller/functions/secure_storage.dart
index db97020..6f618f8 100644
--- a/lib/controller/functions/secure_storage.dart
+++ b/lib/controller/functions/secure_storage.dart
@@ -1,9 +1,14 @@
import 'dart:convert';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
+import 'package:jwt_decoder/jwt_decoder.dart';
+import 'package:secure_string_operations/secure_string_operations.dart';
+import 'package:sefer_driver/controller/auth/captin/login_captin_controller.dart';
import 'package:sefer_driver/controller/functions/encrypt_decrypt.dart';
import '../../constant/box_name.dart';
+import '../../constant/char_map.dart';
+import '../../constant/info.dart';
import '../../constant/links.dart';
import '../../main.dart';
import '../../print.dart';
@@ -34,24 +39,41 @@ class AppInitializer {
List