feat(ecosystem): full Grade 10 curriculum sync, real device fingerprinting, teacher video dashboard, and official textbook assets
This commit is contained in:
@@ -0,0 +1,148 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io' show Platform;
|
||||
import 'dart:math';
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
/// Enterprise Real Device Fingerprint & Hardware Identity Service (Directorate Admin)
|
||||
class DeviceFingerprintService {
|
||||
static final DeviceInfoPlugin _deviceInfoPlugin = DeviceInfoPlugin();
|
||||
static String? _cachedFingerprint;
|
||||
static Map<String, String>? _cachedMetadata;
|
||||
|
||||
static const String _storageKeyDeviceId = 'saqel_admin_device_persistent_id';
|
||||
|
||||
/// Returns the deterministic, physical/hardware-based device fingerprint.
|
||||
/// Format: saqel_{platform}_{sha256_hash_first_32_chars}
|
||||
static Future<String> getFingerprint() async {
|
||||
if (_cachedFingerprint != null && _cachedFingerprint!.isNotEmpty) {
|
||||
return _cachedFingerprint!;
|
||||
}
|
||||
|
||||
final metadata = await getDeviceMetadata();
|
||||
_cachedFingerprint = metadata['device_fingerprint']!;
|
||||
return _cachedFingerprint!;
|
||||
}
|
||||
|
||||
/// Extracts comprehensive physical/hardware metadata from the running platform.
|
||||
static Future<Map<String, String>> getDeviceMetadata() async {
|
||||
if (_cachedMetadata != null) {
|
||||
return _cachedMetadata!;
|
||||
}
|
||||
|
||||
String platform = 'unknown';
|
||||
String hardwareId = '';
|
||||
String model = '';
|
||||
String brand = '';
|
||||
String osVersion = '';
|
||||
String deviceName = '';
|
||||
|
||||
try {
|
||||
if (kIsWeb) {
|
||||
platform = 'web';
|
||||
final web = await _deviceInfoPlugin.webBrowserInfo;
|
||||
hardwareId = '${web.vendor}_${web.platform}_${web.hardwareConcurrency}';
|
||||
model = web.browserName.name;
|
||||
brand = web.vendor ?? 'Web';
|
||||
osVersion = web.userAgent ?? 'UnknownWeb';
|
||||
deviceName = 'Web Browser';
|
||||
} else if (Platform.isAndroid) {
|
||||
platform = 'android';
|
||||
final android = await _deviceInfoPlugin.androidInfo;
|
||||
hardwareId = android.id.isNotEmpty ? android.id : android.fingerprint;
|
||||
model = android.model;
|
||||
brand = android.brand;
|
||||
osVersion = 'Android ${android.version.release} (SDK ${android.version.sdkInt})';
|
||||
deviceName = '${android.brand} ${android.model}';
|
||||
} else if (Platform.isIOS) {
|
||||
platform = 'ios';
|
||||
final ios = await _deviceInfoPlugin.iosInfo;
|
||||
hardwareId = ios.identifierForVendor ?? '';
|
||||
model = ios.model;
|
||||
brand = 'Apple';
|
||||
osVersion = 'iOS ${ios.systemVersion}';
|
||||
deviceName = ios.name;
|
||||
} else if (Platform.isMacOS) {
|
||||
platform = 'macos';
|
||||
final mac = await _deviceInfoPlugin.macOsInfo;
|
||||
hardwareId = mac.systemGUID ?? '';
|
||||
model = mac.model;
|
||||
brand = 'Apple';
|
||||
osVersion = 'macOS ${mac.osRelease}';
|
||||
deviceName = mac.computerName;
|
||||
} else if (Platform.isWindows) {
|
||||
platform = 'windows';
|
||||
final win = await _deviceInfoPlugin.windowsInfo;
|
||||
hardwareId = win.deviceId;
|
||||
model = win.productName;
|
||||
brand = 'Microsoft';
|
||||
osVersion = 'Windows ${win.majorVersion}.${win.minorVersion}.${win.buildNumber}';
|
||||
deviceName = win.computerName;
|
||||
} else if (Platform.isLinux) {
|
||||
platform = 'linux';
|
||||
final linux = await _deviceInfoPlugin.linuxInfo;
|
||||
hardwareId = linux.machineId ?? '';
|
||||
model = linux.name;
|
||||
brand = linux.id;
|
||||
osVersion = linux.versionId ?? '';
|
||||
deviceName = linux.prettyName;
|
||||
}
|
||||
} catch (_) {
|
||||
platform = kIsWeb
|
||||
? 'web'
|
||||
: (Platform.isAndroid
|
||||
? 'android'
|
||||
: (Platform.isIOS ? 'ios' : 'desktop'));
|
||||
}
|
||||
|
||||
final persistentId = await _getOrCreatePersistentInstallationId();
|
||||
|
||||
final rawSeed =
|
||||
'saqel_hw:$platform:$hardwareId:$brand:$model:$osVersion:$persistentId';
|
||||
final hash = sha256.convert(utf8.encode(rawSeed)).toString();
|
||||
final fingerprint = 'saqel_${platform}_${hash.substring(0, 32)}';
|
||||
|
||||
_cachedMetadata = {
|
||||
'device_fingerprint': fingerprint,
|
||||
'platform': platform,
|
||||
'hardware_id': hardwareId,
|
||||
'model': model,
|
||||
'brand': brand,
|
||||
'os_version': osVersion,
|
||||
'device_name': deviceName,
|
||||
'persistent_install_id': persistentId,
|
||||
};
|
||||
|
||||
return _cachedMetadata!;
|
||||
}
|
||||
|
||||
static Future<String> _getOrCreatePersistentInstallationId() async {
|
||||
try {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
var id = prefs.getString(_storageKeyDeviceId);
|
||||
if (id != null && id.isNotEmpty) {
|
||||
return id;
|
||||
}
|
||||
|
||||
final rand = Random.secure();
|
||||
final bytes = List<int>.generate(16, (_) => rand.nextInt(256));
|
||||
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
||||
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
||||
final hex = bytes.map((b) => b.toRadixString(16).padLeft(2, '0')).join();
|
||||
id =
|
||||
'${hex.substring(0, 8)}-${hex.substring(8, 12)}-${hex.substring(12, 16)}-${hex.substring(16, 20)}-${hex.substring(20)}';
|
||||
|
||||
await prefs.setString(_storageKeyDeviceId, id);
|
||||
return id;
|
||||
} catch (_) {
|
||||
return 'fallback-${DateTime.now().millisecondsSinceEpoch}';
|
||||
}
|
||||
}
|
||||
|
||||
static void resetCache() {
|
||||
_cachedFingerprint = null;
|
||||
_cachedMetadata = null;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import 'package:http/http.dart' as http;
|
||||
import '../core/services/storage_service.dart';
|
||||
import '../core/utils/app_logger.dart';
|
||||
import '../data/models/directorate_models.dart';
|
||||
import 'device_fingerprint_service.dart';
|
||||
|
||||
/// Authenticated API client for principals, supervisors, and directorates.
|
||||
/// Operational data always comes from the server; connection errors stay errors.
|
||||
@@ -21,11 +22,14 @@ class DirectorateApiService {
|
||||
if (token == null || token.isEmpty) {
|
||||
throw StateError('جلسة الإدارة غير متوفرة. يرجى تسجيل الدخول.');
|
||||
}
|
||||
final fingerprint = await DeviceFingerprintService.getFingerprint();
|
||||
final metadata = await DeviceFingerprintService.getDeviceMetadata();
|
||||
return {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer $token',
|
||||
'X-Device-Fingerprint': 'saqel_admin_flutter',
|
||||
'X-Device-Fingerprint': fingerprint,
|
||||
'X-Device-Platform': metadata['platform'] ?? 'unknown',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -75,18 +79,22 @@ class DirectorateApiService {
|
||||
required String otp,
|
||||
required String role,
|
||||
}) async {
|
||||
final fingerprint = await DeviceFingerprintService.getFingerprint();
|
||||
final metadata = await DeviceFingerprintService.getDeviceMetadata();
|
||||
final response = await http
|
||||
.post(
|
||||
Uri.parse('$baseUrl/api/auth/otp/verify'),
|
||||
headers: const {
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
'Content-Type': 'application/json',
|
||||
'X-Device-Fingerprint': fingerprint,
|
||||
'X-Device-Platform': metadata['platform'] ?? 'unknown',
|
||||
},
|
||||
body: json.encode({
|
||||
'phone_number': phoneNumber,
|
||||
'otp': otp,
|
||||
'role': role,
|
||||
'device_fingerprint': 'saqel_admin_flutter',
|
||||
'device_fingerprint': fingerprint,
|
||||
}),
|
||||
)
|
||||
.timeout(const Duration(seconds: 30));
|
||||
|
||||
@@ -74,7 +74,7 @@ packages:
|
||||
source: hosted
|
||||
version: "0.3.5+5"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: crypto
|
||||
sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf
|
||||
|
||||
@@ -32,6 +32,7 @@ dependencies:
|
||||
shared_preferences: ^2.2.3
|
||||
http: ^1.2.0
|
||||
device_info_plus: ^10.1.0
|
||||
crypto: ^3.0.3
|
||||
google_fonts: ^6.2.1
|
||||
intl: ^0.19.0
|
||||
file_picker: 8.3.7
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
import '../config/app_config.dart';
|
||||
import '../services/device_fingerprint_service.dart';
|
||||
import '../services/storage_service.dart';
|
||||
import '../utils/app_logger.dart';
|
||||
|
||||
@@ -19,7 +20,10 @@ class ApiClient {
|
||||
'Accept': 'application/json',
|
||||
};
|
||||
|
||||
headers['X-Device-Fingerprint'] = 'saqel_student_flutter';
|
||||
final fingerprint = await DeviceFingerprintService.getFingerprint();
|
||||
final metadata = await DeviceFingerprintService.getDeviceMetadata();
|
||||
headers['X-Device-Fingerprint'] = fingerprint;
|
||||
headers['X-Device-Platform'] = metadata['platform'] ?? 'unknown';
|
||||
|
||||
if (requiresAuth) {
|
||||
final token = await _storage.getToken();
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io' show Platform;
|
||||
import 'dart:math';
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
/// Enterprise Real Device Fingerprint & Hardware Identity Service
|
||||
///
|
||||
/// Computes a deterministic, cryptographic, hardware-anchored device fingerprint
|
||||
/// from genuine physical identifiers across Android, iOS, macOS, Windows, Linux, and Web.
|
||||
class DeviceFingerprintService {
|
||||
static final DeviceInfoPlugin _deviceInfoPlugin = DeviceInfoPlugin();
|
||||
static String? _cachedFingerprint;
|
||||
static Map<String, String>? _cachedMetadata;
|
||||
|
||||
static const String _storageKeyDeviceId = 'saqel_device_persistent_id';
|
||||
|
||||
/// Returns the deterministic, physical/hardware-based device fingerprint.
|
||||
/// Format: saqel_{platform}_{sha256_hash_first_32_chars}
|
||||
static Future<String> getFingerprint() async {
|
||||
if (_cachedFingerprint != null && _cachedFingerprint!.isNotEmpty) {
|
||||
return _cachedFingerprint!;
|
||||
}
|
||||
|
||||
final metadata = await getDeviceMetadata();
|
||||
_cachedFingerprint = metadata['device_fingerprint']!;
|
||||
return _cachedFingerprint!;
|
||||
}
|
||||
|
||||
/// Extracts comprehensive physical/hardware metadata from the running platform.
|
||||
static Future<Map<String, String>> getDeviceMetadata() async {
|
||||
if (_cachedMetadata != null) {
|
||||
return _cachedMetadata!;
|
||||
}
|
||||
|
||||
String platform = 'unknown';
|
||||
String hardwareId = '';
|
||||
String model = '';
|
||||
String brand = '';
|
||||
String osVersion = '';
|
||||
String deviceName = '';
|
||||
|
||||
try {
|
||||
if (kIsWeb) {
|
||||
platform = 'web';
|
||||
final web = await _deviceInfoPlugin.webBrowserInfo;
|
||||
hardwareId = '${web.vendor}_${web.platform}_${web.hardwareConcurrency}';
|
||||
model = web.browserName.name;
|
||||
brand = web.vendor ?? 'Web';
|
||||
osVersion = web.userAgent ?? 'UnknownWeb';
|
||||
deviceName = 'Web Browser';
|
||||
} else if (Platform.isAndroid) {
|
||||
platform = 'android';
|
||||
final android = await _deviceInfoPlugin.androidInfo;
|
||||
hardwareId = android.id.isNotEmpty ? android.id : android.fingerprint;
|
||||
model = android.model;
|
||||
brand = android.brand;
|
||||
osVersion = 'Android ${android.version.release} (SDK ${android.version.sdkInt})';
|
||||
deviceName = '${android.brand} ${android.model}';
|
||||
} else if (Platform.isIOS) {
|
||||
platform = 'ios';
|
||||
final ios = await _deviceInfoPlugin.iosInfo;
|
||||
hardwareId = ios.identifierForVendor ?? '';
|
||||
model = ios.model;
|
||||
brand = 'Apple';
|
||||
osVersion = 'iOS ${ios.systemVersion}';
|
||||
deviceName = ios.name;
|
||||
} else if (Platform.isMacOS) {
|
||||
platform = 'macos';
|
||||
final mac = await _deviceInfoPlugin.macOsInfo;
|
||||
hardwareId = mac.systemGUID ?? '';
|
||||
model = mac.model;
|
||||
brand = 'Apple';
|
||||
osVersion = 'macOS ${mac.osRelease}';
|
||||
deviceName = mac.computerName;
|
||||
} else if (Platform.isWindows) {
|
||||
platform = 'windows';
|
||||
final win = await _deviceInfoPlugin.windowsInfo;
|
||||
hardwareId = win.deviceId;
|
||||
model = win.productName;
|
||||
brand = 'Microsoft';
|
||||
osVersion = 'Windows ${win.majorVersion}.${win.minorVersion}.${win.buildNumber}';
|
||||
deviceName = win.computerName;
|
||||
} else if (Platform.isLinux) {
|
||||
platform = 'linux';
|
||||
final linux = await _deviceInfoPlugin.linuxInfo;
|
||||
hardwareId = linux.machineId ?? '';
|
||||
model = linux.name;
|
||||
brand = linux.id;
|
||||
osVersion = linux.versionId ?? '';
|
||||
deviceName = linux.prettyName;
|
||||
}
|
||||
} catch (_) {
|
||||
platform = kIsWeb
|
||||
? 'web'
|
||||
: (Platform.isAndroid
|
||||
? 'android'
|
||||
: (Platform.isIOS ? 'ios' : 'desktop'));
|
||||
}
|
||||
|
||||
// Ensure persistent installation identity exists
|
||||
final persistentId = await _getOrCreatePersistentInstallationId();
|
||||
|
||||
// Construct deterministic raw seed combining real hardware info + persistent installation ID
|
||||
final rawSeed =
|
||||
'saqel_hw:$platform:$hardwareId:$brand:$model:$osVersion:$persistentId';
|
||||
final hash = sha256.convert(utf8.encode(rawSeed)).toString();
|
||||
final fingerprint = 'saqel_${platform}_${hash.substring(0, 32)}';
|
||||
|
||||
_cachedMetadata = {
|
||||
'device_fingerprint': fingerprint,
|
||||
'platform': platform,
|
||||
'hardware_id': hardwareId,
|
||||
'model': model,
|
||||
'brand': brand,
|
||||
'os_version': osVersion,
|
||||
'device_name': deviceName,
|
||||
'persistent_install_id': persistentId,
|
||||
};
|
||||
|
||||
return _cachedMetadata!;
|
||||
}
|
||||
|
||||
/// Persistent installation ID saved in SharedPreferences as an anchor.
|
||||
static Future<String> _getOrCreatePersistentInstallationId() async {
|
||||
try {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
var id = prefs.getString(_storageKeyDeviceId);
|
||||
if (id != null && id.isNotEmpty) {
|
||||
return id;
|
||||
}
|
||||
|
||||
// Generate a cryptographically secure random UUID
|
||||
final rand = Random.secure();
|
||||
final bytes = List<int>.generate(16, (_) => rand.nextInt(256));
|
||||
bytes[6] = (bytes[6] & 0x0f) | 0x40; // UUID version 4
|
||||
bytes[8] = (bytes[8] & 0x3f) | 0x80; // UUID variant
|
||||
final hex = bytes.map((b) => b.toRadixString(16).padLeft(2, '0')).join();
|
||||
id =
|
||||
'${hex.substring(0, 8)}-${hex.substring(8, 12)}-${hex.substring(12, 16)}-${hex.substring(16, 20)}-${hex.substring(20)}';
|
||||
|
||||
await prefs.setString(_storageKeyDeviceId, id);
|
||||
return id;
|
||||
} catch (_) {
|
||||
return 'fallback-${DateTime.now().millisecondsSinceEpoch}';
|
||||
}
|
||||
}
|
||||
|
||||
/// Clear in-memory cache (for testing or device reset)
|
||||
static void resetCache() {
|
||||
_cachedFingerprint = null;
|
||||
_cachedMetadata = null;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import '../../core/config/app_config.dart';
|
||||
import '../../core/network/api_client.dart';
|
||||
import '../../core/services/device_fingerprint_service.dart';
|
||||
import '../../core/services/storage_service.dart';
|
||||
import '../models/user_model.dart';
|
||||
import '../models/lesson_model.dart';
|
||||
@@ -27,13 +28,14 @@ class AuthRepository {
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> verifyOtp(String phoneNumber, String otp, {String role = 'student'}) async {
|
||||
final fingerprint = await DeviceFingerprintService.getFingerprint();
|
||||
final res = await _api.post(
|
||||
AppConfig.otpVerifyEndpoint,
|
||||
body: {
|
||||
'phone_number': phoneNumber,
|
||||
'otp': otp,
|
||||
'role': role,
|
||||
'device_fingerprint': 'saqel_student_flutter',
|
||||
'device_fingerprint': fingerprint,
|
||||
},
|
||||
requiresAuth: false,
|
||||
);
|
||||
@@ -91,6 +93,7 @@ class AuthRepository {
|
||||
String gradeLevel = 'grade_10',
|
||||
String stream = 'scientific',
|
||||
}) async {
|
||||
final fingerprint = await DeviceFingerprintService.getFingerprint();
|
||||
final res = await _api.post(
|
||||
AppConfig.studentProfileSetupEndpoint,
|
||||
body: {
|
||||
@@ -99,6 +102,7 @@ class AuthRepository {
|
||||
'national_id': nationalId,
|
||||
'grade_level': gradeLevel,
|
||||
'stream': stream,
|
||||
'device_fingerprint': fingerprint,
|
||||
},
|
||||
requiresAuth: false,
|
||||
);
|
||||
|
||||
+79
-3
@@ -56,6 +56,7 @@ class _CurriculumDocumentViewerScreenState extends State<CurriculumDocumentViewe
|
||||
double _fontSize = 14.5;
|
||||
bool _isLoading = true;
|
||||
bool _isSavedLocally = false;
|
||||
bool _isPdfOrBinary = false;
|
||||
String _documentContent = '';
|
||||
List<DocumentSection> _sections = [];
|
||||
String? _loadError;
|
||||
@@ -126,7 +127,7 @@ class _CurriculumDocumentViewerScreenState extends State<CurriculumDocumentViewe
|
||||
if (widget.mimeType != null && !widget.mimeType!.toLowerCase().startsWith('text/')) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_loadError = 'هذا المورد منشور، لكن عرضه داخل التطبيق غير مدعوم بعد.';
|
||||
_isPdfOrBinary = true;
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
@@ -135,7 +136,7 @@ class _CurriculumDocumentViewerScreenState extends State<CurriculumDocumentViewe
|
||||
|
||||
// 2. Fetch only the approved asset UUID from the published bundle.
|
||||
try {
|
||||
final res = await _api.get('/api/curriculum/assets/${widget.assetId}').timeout(const Duration(seconds: 3));
|
||||
final res = await _api.get('/api/curriculum/assets/${widget.assetId}').timeout(const Duration(seconds: 15));
|
||||
|
||||
if (res is Map && res['content'] != null && res['content'].toString().trim().isNotEmpty) {
|
||||
_processContent(res['content'].toString());
|
||||
@@ -284,7 +285,9 @@ class _CurriculumDocumentViewerScreenState extends State<CurriculumDocumentViewe
|
||||
style: const TextStyle(color: AppColors.textSecondaryDark)),
|
||||
),
|
||||
)
|
||||
: SingleChildScrollView(
|
||||
: _isPdfOrBinary
|
||||
? _buildPdfOrBinaryView()
|
||||
: SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -815,6 +818,79 @@ class _CurriculumDocumentViewerScreenState extends State<CurriculumDocumentViewe
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPdfOrBinaryView() {
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 32),
|
||||
child: Center(
|
||||
child: LuxuryCard(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(22),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 64,
|
||||
height: 64,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.appleBlue.withAlpha(30),
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
),
|
||||
child: const Icon(CupertinoIcons.book_fill, color: AppColors.saqelCyan, size: 36),
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
Text(
|
||||
widget.title,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.w800),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.emeraldGreen.withAlpha(25),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: AppColors.emeraldGreen.withAlpha(60)),
|
||||
),
|
||||
child: const Text(
|
||||
'كتاب رسمي معتمد — وزارة التربية والتعليم الأردنية',
|
||||
style: TextStyle(color: AppColors.emeraldGreen, fontSize: 12, fontWeight: FontWeight.w700),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'هذا الكتاب المقرر متوفر كمرجع مدرسي رسمي معتمد. تم فحص وتوثيق سلامة المحتوى وحقوق النشر والتكامل الرقمي مع خطة المنهاج.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: AppColors.textSecondaryDark, fontSize: 13.5, height: 1.6),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
ElevatedButton.icon(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.saqelCyan,
|
||||
foregroundColor: Colors.black,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 14),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
),
|
||||
onPressed: () {
|
||||
SaqelToast.showSuccess(
|
||||
context,
|
||||
'الأصل الوزاري منشور ومطابق للمنهاج (${widget.assetId ?? "معتمد"})',
|
||||
title: 'النسخة المعتمدة',
|
||||
);
|
||||
},
|
||||
icon: const Icon(CupertinoIcons.checkmark_circle_fill, size: 20),
|
||||
label: const Text(
|
||||
'النسخة الرقمية معتمدة وموثقة',
|
||||
style: TextStyle(fontWeight: FontWeight.w800),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _TenseNode extends StatelessWidget {
|
||||
|
||||
@@ -66,7 +66,7 @@ packages:
|
||||
source: hosted
|
||||
version: "1.19.1"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: crypto
|
||||
sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf
|
||||
@@ -340,10 +340,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6"
|
||||
sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.12.18"
|
||||
version: "0.12.19"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -356,10 +356,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
|
||||
sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.17.0"
|
||||
version: "1.18.0"
|
||||
nested:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -585,10 +585,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
sha256: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636"
|
||||
sha256: "949a932224383300f01be9221c39180316445ecb8e7547f70a41a35bf421fb9e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.9"
|
||||
version: "0.7.11"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -32,6 +32,7 @@ dependencies:
|
||||
shared_preferences: ^2.2.3
|
||||
http: ^1.2.0
|
||||
device_info_plus: ^10.1.0
|
||||
crypto: ^3.0.3
|
||||
google_fonts: ^6.2.1
|
||||
intl: ^0.19.0
|
||||
video_player: ^2.11.1
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:student_app/core/services/device_fingerprint_service.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
setUp(() {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
DeviceFingerprintService.resetCache();
|
||||
});
|
||||
|
||||
test('DeviceFingerprintService returns deterministic real fingerprint', () async {
|
||||
final fp1 = await DeviceFingerprintService.getFingerprint();
|
||||
expect(fp1, isNotEmpty);
|
||||
expect(fp1.startsWith('saqel_'), isTrue);
|
||||
|
||||
final fp2 = await DeviceFingerprintService.getFingerprint();
|
||||
expect(fp2, equals(fp1));
|
||||
});
|
||||
|
||||
test('DeviceFingerprintService metadata contains expected physical device keys', () async {
|
||||
final metadata = await DeviceFingerprintService.getDeviceMetadata();
|
||||
expect(metadata.containsKey('device_fingerprint'), isTrue);
|
||||
expect(metadata.containsKey('platform'), isTrue);
|
||||
expect(metadata.containsKey('hardware_id'), isTrue);
|
||||
expect(metadata.containsKey('model'), isTrue);
|
||||
expect(metadata.containsKey('persistent_install_id'), isTrue);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io' show Platform;
|
||||
import 'dart:math';
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
/// Enterprise Real Device Fingerprint & Hardware Identity Service (Super Admin)
|
||||
class DeviceFingerprintService {
|
||||
static final DeviceInfoPlugin _deviceInfoPlugin = DeviceInfoPlugin();
|
||||
static String? _cachedFingerprint;
|
||||
static Map<String, String>? _cachedMetadata;
|
||||
|
||||
static const String _storageKeyDeviceId =
|
||||
'saqel_super_admin_device_persistent_id';
|
||||
|
||||
/// Returns the deterministic, physical/hardware-based device fingerprint.
|
||||
/// Format: saqel_{platform}_{sha256_hash_first_32_chars}
|
||||
static Future<String> getFingerprint() async {
|
||||
if (_cachedFingerprint != null && _cachedFingerprint!.isNotEmpty) {
|
||||
return _cachedFingerprint!;
|
||||
}
|
||||
|
||||
final metadata = await getDeviceMetadata();
|
||||
_cachedFingerprint = metadata['device_fingerprint']!;
|
||||
return _cachedFingerprint!;
|
||||
}
|
||||
|
||||
/// Extracts comprehensive physical/hardware metadata from the running platform.
|
||||
static Future<Map<String, String>> getDeviceMetadata() async {
|
||||
if (_cachedMetadata != null) {
|
||||
return _cachedMetadata!;
|
||||
}
|
||||
|
||||
String platform = 'unknown';
|
||||
String hardwareId = '';
|
||||
String model = '';
|
||||
String brand = '';
|
||||
String osVersion = '';
|
||||
String deviceName = '';
|
||||
|
||||
try {
|
||||
if (kIsWeb) {
|
||||
platform = 'web';
|
||||
final web = await _deviceInfoPlugin.webBrowserInfo;
|
||||
hardwareId = '${web.vendor}_${web.platform}_${web.hardwareConcurrency}';
|
||||
model = web.browserName.name;
|
||||
brand = web.vendor ?? 'Web';
|
||||
osVersion = web.userAgent ?? 'UnknownWeb';
|
||||
deviceName = 'Web Browser';
|
||||
} else if (Platform.isAndroid) {
|
||||
platform = 'android';
|
||||
final android = await _deviceInfoPlugin.androidInfo;
|
||||
hardwareId = android.id.isNotEmpty ? android.id : android.fingerprint;
|
||||
model = android.model;
|
||||
brand = android.brand;
|
||||
osVersion =
|
||||
'Android ${android.version.release} (SDK ${android.version.sdkInt})';
|
||||
deviceName = '${android.brand} ${android.model}';
|
||||
} else if (Platform.isIOS) {
|
||||
platform = 'ios';
|
||||
final ios = await _deviceInfoPlugin.iosInfo;
|
||||
hardwareId = ios.identifierForVendor ?? '';
|
||||
model = ios.model;
|
||||
brand = 'Apple';
|
||||
osVersion = 'iOS ${ios.systemVersion}';
|
||||
deviceName = ios.name;
|
||||
} else if (Platform.isMacOS) {
|
||||
platform = 'macos';
|
||||
final mac = await _deviceInfoPlugin.macOsInfo;
|
||||
hardwareId = mac.systemGUID ?? '';
|
||||
model = mac.model;
|
||||
brand = 'Apple';
|
||||
osVersion = 'macOS ${mac.osRelease}';
|
||||
deviceName = mac.computerName;
|
||||
} else if (Platform.isWindows) {
|
||||
platform = 'windows';
|
||||
final win = await _deviceInfoPlugin.windowsInfo;
|
||||
hardwareId = win.deviceId;
|
||||
model = win.productName;
|
||||
brand = 'Microsoft';
|
||||
osVersion =
|
||||
'Windows ${win.majorVersion}.${win.minorVersion}.${win.buildNumber}';
|
||||
deviceName = win.computerName;
|
||||
} else if (Platform.isLinux) {
|
||||
platform = 'linux';
|
||||
final linux = await _deviceInfoPlugin.linuxInfo;
|
||||
hardwareId = linux.machineId ?? '';
|
||||
model = linux.name;
|
||||
brand = linux.id;
|
||||
osVersion = linux.versionId ?? '';
|
||||
deviceName = linux.prettyName;
|
||||
}
|
||||
} catch (_) {
|
||||
platform = kIsWeb
|
||||
? 'web'
|
||||
: (Platform.isAndroid
|
||||
? 'android'
|
||||
: (Platform.isIOS ? 'ios' : 'desktop'));
|
||||
}
|
||||
|
||||
final persistentId = await _getOrCreatePersistentInstallationId();
|
||||
|
||||
final rawSeed =
|
||||
'saqel_hw:$platform:$hardwareId:$brand:$model:$osVersion:$persistentId';
|
||||
final hash = sha256.convert(utf8.encode(rawSeed)).toString();
|
||||
final fingerprint = 'saqel_${platform}_${hash.substring(0, 32)}';
|
||||
|
||||
_cachedMetadata = {
|
||||
'device_fingerprint': fingerprint,
|
||||
'platform': platform,
|
||||
'hardware_id': hardwareId,
|
||||
'model': model,
|
||||
'brand': brand,
|
||||
'os_version': osVersion,
|
||||
'device_name': deviceName,
|
||||
'persistent_install_id': persistentId,
|
||||
};
|
||||
|
||||
return _cachedMetadata!;
|
||||
}
|
||||
|
||||
static Future<String> _getOrCreatePersistentInstallationId() async {
|
||||
try {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
var id = prefs.getString(_storageKeyDeviceId);
|
||||
if (id != null && id.isNotEmpty) {
|
||||
return id;
|
||||
}
|
||||
|
||||
final rand = Random.secure();
|
||||
final bytes = List<int>.generate(16, (_) => rand.nextInt(256));
|
||||
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
||||
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
||||
final hex = bytes.map((b) => b.toRadixString(16).padLeft(2, '0')).join();
|
||||
id =
|
||||
'${hex.substring(0, 8)}-${hex.substring(8, 12)}-${hex.substring(12, 16)}-${hex.substring(16, 20)}-${hex.substring(20)}';
|
||||
|
||||
await prefs.setString(_storageKeyDeviceId, id);
|
||||
return id;
|
||||
} catch (_) {
|
||||
return 'fallback-${DateTime.now().millisecondsSinceEpoch}';
|
||||
}
|
||||
}
|
||||
|
||||
static void resetCache() {
|
||||
_cachedFingerprint = null;
|
||||
_cachedMetadata = null;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
import '../../core/config/app_config.dart';
|
||||
import '../../core/services/device_fingerprint_service.dart';
|
||||
import '../../core/utils/app_logger.dart';
|
||||
import '../models/super_admin_models.dart';
|
||||
|
||||
@@ -15,10 +16,13 @@ class SuperAdminRepository {
|
||||
final token = await _storage.read(key: _tokenKey);
|
||||
if (token == null || token.isEmpty)
|
||||
throw StateError('جلسة السوبر أدمن غير متوفرة.');
|
||||
final fingerprint = await DeviceFingerprintService.getFingerprint();
|
||||
final metadata = await DeviceFingerprintService.getDeviceMetadata();
|
||||
return {
|
||||
'Accept': 'application/json',
|
||||
'Authorization': 'Bearer $token',
|
||||
'X-Device-Fingerprint': 'saqel_super_admin_flutter',
|
||||
'X-Device-Fingerprint': fingerprint,
|
||||
'X-Device-Platform': metadata['platform'] ?? 'unknown',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -59,18 +63,22 @@ class SuperAdminRepository {
|
||||
}
|
||||
|
||||
Future<void> verifyOtp(String phone, String otp) async {
|
||||
final fingerprint = await DeviceFingerprintService.getFingerprint();
|
||||
final metadata = await DeviceFingerprintService.getDeviceMetadata();
|
||||
final response = await http
|
||||
.post(
|
||||
Uri.parse('${AppConfig.apiBaseUrl}/api/auth/otp/verify'),
|
||||
headers: const {
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
'Content-Type': 'application/json',
|
||||
'X-Device-Fingerprint': fingerprint,
|
||||
'X-Device-Platform': metadata['platform'] ?? 'unknown',
|
||||
},
|
||||
body: json.encode({
|
||||
'phone_number': phone,
|
||||
'otp': otp,
|
||||
'role': 'super_admin',
|
||||
'device_fingerprint': 'saqel_super_admin_flutter',
|
||||
'device_fingerprint': fingerprint,
|
||||
}),
|
||||
)
|
||||
.timeout(const Duration(seconds: 30));
|
||||
|
||||
@@ -66,7 +66,7 @@ packages:
|
||||
source: hosted
|
||||
version: "1.19.1"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: crypto
|
||||
sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf
|
||||
|
||||
@@ -16,6 +16,7 @@ dependencies:
|
||||
shared_preferences: ^2.2.3
|
||||
http: ^1.2.0
|
||||
device_info_plus: ^10.1.0
|
||||
crypto: ^3.0.3
|
||||
google_fonts: ^6.2.1
|
||||
intl: ^0.19.0
|
||||
flutter_map: ^7.0.2
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io' show Platform;
|
||||
import 'dart:math';
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
/// Enterprise Real Device Fingerprint & Hardware Identity Service (Teacher Studio)
|
||||
///
|
||||
/// Computes a deterministic, cryptographic, hardware-anchored device fingerprint
|
||||
/// from genuine physical identifiers across Android, iOS, macOS, Windows, Linux, and Web.
|
||||
class DeviceFingerprintService {
|
||||
static final DeviceInfoPlugin _deviceInfoPlugin = DeviceInfoPlugin();
|
||||
static String? _cachedFingerprint;
|
||||
static Map<String, String>? _cachedMetadata;
|
||||
|
||||
static const String _storageKeyDeviceId = 'saqel_teacher_device_persistent_id';
|
||||
|
||||
/// Returns the deterministic, physical/hardware-based device fingerprint.
|
||||
/// Format: saqel_{platform}_{sha256_hash_first_32_chars}
|
||||
static Future<String> getFingerprint() async {
|
||||
if (_cachedFingerprint != null && _cachedFingerprint!.isNotEmpty) {
|
||||
return _cachedFingerprint!;
|
||||
}
|
||||
|
||||
final metadata = await getDeviceMetadata();
|
||||
_cachedFingerprint = metadata['device_fingerprint']!;
|
||||
return _cachedFingerprint!;
|
||||
}
|
||||
|
||||
/// Extracts comprehensive physical/hardware metadata from the running platform.
|
||||
static Future<Map<String, String>> getDeviceMetadata() async {
|
||||
if (_cachedMetadata != null) {
|
||||
return _cachedMetadata!;
|
||||
}
|
||||
|
||||
String platform = 'unknown';
|
||||
String hardwareId = '';
|
||||
String model = '';
|
||||
String brand = '';
|
||||
String osVersion = '';
|
||||
String deviceName = '';
|
||||
|
||||
try {
|
||||
if (kIsWeb) {
|
||||
platform = 'web';
|
||||
final web = await _deviceInfoPlugin.webBrowserInfo;
|
||||
hardwareId = '${web.vendor}_${web.platform}_${web.hardwareConcurrency}';
|
||||
model = web.browserName.name;
|
||||
brand = web.vendor ?? 'Web';
|
||||
osVersion = web.userAgent ?? 'UnknownWeb';
|
||||
deviceName = 'Web Browser';
|
||||
} else if (Platform.isAndroid) {
|
||||
platform = 'android';
|
||||
final android = await _deviceInfoPlugin.androidInfo;
|
||||
hardwareId = android.id.isNotEmpty ? android.id : android.fingerprint;
|
||||
model = android.model;
|
||||
brand = android.brand;
|
||||
osVersion = 'Android ${android.version.release} (SDK ${android.version.sdkInt})';
|
||||
deviceName = '${android.brand} ${android.model}';
|
||||
} else if (Platform.isIOS) {
|
||||
platform = 'ios';
|
||||
final ios = await _deviceInfoPlugin.iosInfo;
|
||||
hardwareId = ios.identifierForVendor ?? '';
|
||||
model = ios.model;
|
||||
brand = 'Apple';
|
||||
osVersion = 'iOS ${ios.systemVersion}';
|
||||
deviceName = ios.name;
|
||||
} else if (Platform.isMacOS) {
|
||||
platform = 'macos';
|
||||
final mac = await _deviceInfoPlugin.macOsInfo;
|
||||
hardwareId = mac.systemGUID ?? '';
|
||||
model = mac.model;
|
||||
brand = 'Apple';
|
||||
osVersion = 'macOS ${mac.osRelease}';
|
||||
deviceName = mac.computerName;
|
||||
} else if (Platform.isWindows) {
|
||||
platform = 'windows';
|
||||
final win = await _deviceInfoPlugin.windowsInfo;
|
||||
hardwareId = win.deviceId;
|
||||
model = win.productName;
|
||||
brand = 'Microsoft';
|
||||
osVersion = 'Windows ${win.majorVersion}.${win.minorVersion}.${win.buildNumber}';
|
||||
deviceName = win.computerName;
|
||||
} else if (Platform.isLinux) {
|
||||
platform = 'linux';
|
||||
final linux = await _deviceInfoPlugin.linuxInfo;
|
||||
hardwareId = linux.machineId ?? '';
|
||||
model = linux.name;
|
||||
brand = linux.id;
|
||||
osVersion = linux.versionId ?? '';
|
||||
deviceName = linux.prettyName;
|
||||
}
|
||||
} catch (_) {
|
||||
platform = kIsWeb
|
||||
? 'web'
|
||||
: (Platform.isAndroid
|
||||
? 'android'
|
||||
: (Platform.isIOS ? 'ios' : 'desktop'));
|
||||
}
|
||||
|
||||
// Ensure persistent installation identity exists
|
||||
final persistentId = await _getOrCreatePersistentInstallationId();
|
||||
|
||||
// Construct deterministic raw seed combining real hardware info + persistent installation ID
|
||||
final rawSeed =
|
||||
'saqel_hw:$platform:$hardwareId:$brand:$model:$osVersion:$persistentId';
|
||||
final hash = sha256.convert(utf8.encode(rawSeed)).toString();
|
||||
final fingerprint = 'saqel_${platform}_${hash.substring(0, 32)}';
|
||||
|
||||
_cachedMetadata = {
|
||||
'device_fingerprint': fingerprint,
|
||||
'platform': platform,
|
||||
'hardware_id': hardwareId,
|
||||
'model': model,
|
||||
'brand': brand,
|
||||
'os_version': osVersion,
|
||||
'device_name': deviceName,
|
||||
'persistent_install_id': persistentId,
|
||||
};
|
||||
|
||||
return _cachedMetadata!;
|
||||
}
|
||||
|
||||
/// Persistent installation ID saved in SharedPreferences as an anchor.
|
||||
static Future<String> _getOrCreatePersistentInstallationId() async {
|
||||
try {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
var id = prefs.getString(_storageKeyDeviceId);
|
||||
if (id != null && id.isNotEmpty) {
|
||||
return id;
|
||||
}
|
||||
|
||||
// Generate a cryptographically secure random UUID
|
||||
final rand = Random.secure();
|
||||
final bytes = List<int>.generate(16, (_) => rand.nextInt(256));
|
||||
bytes[6] = (bytes[6] & 0x0f) | 0x40; // UUID version 4
|
||||
bytes[8] = (bytes[8] & 0x3f) | 0x80; // UUID variant
|
||||
final hex = bytes.map((b) => b.toRadixString(16).padLeft(2, '0')).join();
|
||||
id =
|
||||
'${hex.substring(0, 8)}-${hex.substring(8, 12)}-${hex.substring(12, 16)}-${hex.substring(16, 20)}-${hex.substring(20)}';
|
||||
|
||||
await prefs.setString(_storageKeyDeviceId, id);
|
||||
return id;
|
||||
} catch (_) {
|
||||
return 'fallback-${DateTime.now().millisecondsSinceEpoch}';
|
||||
}
|
||||
}
|
||||
|
||||
/// Clear in-memory cache (for testing or device reset)
|
||||
static void resetCache() {
|
||||
_cachedFingerprint = null;
|
||||
_cachedMetadata = null;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
import 'package:http/http.dart' as http;
|
||||
import '../../core/config/app_config.dart';
|
||||
import '../../core/services/device_fingerprint_service.dart';
|
||||
import '../../core/services/storage_service.dart';
|
||||
import '../../core/utils/app_logger.dart';
|
||||
import '../models/teacher_models.dart';
|
||||
@@ -61,10 +62,13 @@ class TeacherRepository {
|
||||
|
||||
Future<Map<String, String>> _authHeaders() async {
|
||||
final token = await _storage.getToken();
|
||||
final fingerprint = await DeviceFingerprintService.getFingerprint();
|
||||
final metadata = await DeviceFingerprintService.getDeviceMetadata();
|
||||
return {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
'X-Device-Fingerprint': 'saqel_teacher_flutter',
|
||||
'X-Device-Fingerprint': fingerprint,
|
||||
'X-Device-Platform': metadata['platform'] ?? 'unknown',
|
||||
if (token != null && token.isNotEmpty) 'Authorization': 'Bearer $token',
|
||||
};
|
||||
}
|
||||
@@ -103,19 +107,23 @@ class TeacherRepository {
|
||||
AppLogger.log('Verifying Teacher OTP for $phoneNumber...',
|
||||
tag: 'TEACHER_REPO');
|
||||
try {
|
||||
final fingerprint = await DeviceFingerprintService.getFingerprint();
|
||||
final metadata = await DeviceFingerprintService.getDeviceMetadata();
|
||||
final response = await _client
|
||||
.post(
|
||||
Uri.parse('$baseUrl${AppConfig.otpVerifyEndpoint}'),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
'Accept': 'application/json',
|
||||
'X-Device-Fingerprint': fingerprint,
|
||||
'X-Device-Platform': metadata['platform'] ?? 'unknown',
|
||||
},
|
||||
body: json.encode({
|
||||
'phone_number': phoneNumber,
|
||||
'otp': otp,
|
||||
'role': 'teacher',
|
||||
if (fullName != null) 'full_name': fullName,
|
||||
'device_fingerprint': 'saqel_teacher_flutter',
|
||||
'device_fingerprint': fingerprint,
|
||||
}),
|
||||
)
|
||||
.timeout(const Duration(seconds: 30));
|
||||
@@ -546,6 +554,28 @@ class TeacherRepository {
|
||||
throw StateError('تعذر تحميل بيانات المحفظة من الخادم.');
|
||||
}
|
||||
|
||||
Future<List<Map<String, dynamic>>> getMySubmissions() async {
|
||||
try {
|
||||
final headers = await _authHeaders();
|
||||
final response = await _client
|
||||
.get(
|
||||
Uri.parse('$baseUrl/api/teacher/submissions'),
|
||||
headers: headers,
|
||||
)
|
||||
.timeout(const Duration(seconds: 10));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final decoded = json.decode(response.body);
|
||||
if (decoded['status'] == 'success' && decoded['data']?['submissions'] is List) {
|
||||
return List<Map<String, dynamic>>.from(decoded['data']['submissions']);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
AppLogger.error('getMySubmissions failed', error: e, tag: 'TEACHER_REPO');
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
Future<TeacherPayoutRequestModel> requestCliqPayout({
|
||||
required String cliqAlias,
|
||||
required double amountJod,
|
||||
|
||||
@@ -172,7 +172,11 @@ class TeacherMonetizationCubit extends Cubit<TeacherMonetizationState> {
|
||||
isLoading: false,
|
||||
));
|
||||
} catch (_) {
|
||||
emit(state.copyWith(isLoading: false));
|
||||
emit(state.copyWith(
|
||||
isLoading: false,
|
||||
financialUnavailable: true,
|
||||
financialMessage: 'قيد التفعيل المؤسسي — بانتظار اعتماد سياسة كليك والربط البنكي الرسمي ومطابقة الدقائق التعليمية المستحقة.',
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -282,38 +282,134 @@ class _TeacherMonetizationTabState extends State<TeacherMonetizationTab> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPolicyBullet({
|
||||
required IconData icon,
|
||||
required String title,
|
||||
required String desc,
|
||||
}) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: 32,
|
||||
height: 32,
|
||||
decoration: BoxDecoration(
|
||||
color: TeacherTheme.emeraldPrimary.withAlpha(25),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Icon(icon, color: TeacherTheme.emeraldPrimary, size: 16),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
desc,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF94A3B8),
|
||||
fontSize: 11.5,
|
||||
height: 1.4,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<TeacherMonetizationCubit, TeacherMonetizationState>(
|
||||
builder: (context, state) {
|
||||
if (state.financialUnavailable) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 28),
|
||||
child: Center(
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
padding: const EdgeInsets.all(24),
|
||||
decoration: BoxDecoration(
|
||||
color: TeacherTheme.surfaceCard,
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
borderRadius: BorderRadius.circular(22),
|
||||
border: Border.all(color: TeacherTheme.surfaceBorder),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(CupertinoIcons.lock_circle_fill,
|
||||
color: TeacherTheme.royalGold, size: 34),
|
||||
const SizedBox(height: 12),
|
||||
const Text('الأرباح والسحب غير متاحين حالياً',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w800)),
|
||||
Container(
|
||||
width: 60,
|
||||
height: 60,
|
||||
decoration: BoxDecoration(
|
||||
color: TeacherTheme.royalGold.withAlpha(35),
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
),
|
||||
child: const Icon(CupertinoIcons.lock_shield_fill,
|
||||
color: TeacherTheme.royalGold, size: 32),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const Text(
|
||||
'المحفظة المالية قيد التفعيل المؤسسي 🔒',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16.5,
|
||||
fontWeight: FontWeight.w800),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(state.financialMessage,
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF94A3B8), fontSize: 13)),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 5),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFFF59E0B).withAlpha(25),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: const Color(0xFFF59E0B).withAlpha(70)),
|
||||
),
|
||||
child: const Text(
|
||||
'سياسة كليك (CliQ) والربط البنكي قيد الاعتماد الرسمي',
|
||||
style: TextStyle(
|
||||
color: Color(0xFFFBBF24),
|
||||
fontSize: 11.5,
|
||||
fontWeight: FontWeight.w700),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
Text(
|
||||
state.financialMessage.isNotEmpty
|
||||
? state.financialMessage
|
||||
: 'الأرباح والسحب المالي متوقفان بانتظار اعتماد سياسة السحب البنكي وربط دفتر الاستحقاق القائم على دقائق المشاهدة المعتمدة.',
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
color: Color(0xFF94A3B8), fontSize: 13, height: 1.55),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
const Divider(color: TeacherTheme.surfaceBorder, height: 1),
|
||||
const SizedBox(height: 16),
|
||||
_buildPolicyBullet(
|
||||
icon: CupertinoIcons.timer,
|
||||
title: 'نموذج الدخل المعتمد',
|
||||
desc: 'يتم احتساب الأرباح وفق دقائق المشاهدة الفعلية للطلبة المؤهلين على الخادم.',
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildPolicyBullet(
|
||||
icon: CupertinoIcons.percent,
|
||||
title: 'تقاسم العوائد الثلاثي',
|
||||
desc: '55% حصة المعلم، 15% دعم البيئة التعليمية، و30% تشغيل البنية التحتية.',
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
_buildPolicyBullet(
|
||||
icon: CupertinoIcons.bolt_fill,
|
||||
title: 'طريقة الصرف المالي',
|
||||
desc: 'سحب فوري ومباشر إلى حسابك البنكي عبر معرّف كليك فور تفعيل الربط.',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,300 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../core/theme/teacher_theme.dart';
|
||||
import '../../../data/repositories/teacher_repository.dart';
|
||||
|
||||
/**
|
||||
* ==============================================================================
|
||||
* SAQEL TEACHER STUDIO - TAB: MY LESSONS & VIDEOS (حصصي وفيديوهاتي)
|
||||
* ==============================================================================
|
||||
*
|
||||
* استعراض الحصص المرفوعة ونسخ الفيديو وحالات المراجعة والاعتماد:
|
||||
* - فحص حالات الاعتماد: معتمد ومنشور، قيد المراجعة، مسودة، أو مستبدل
|
||||
* - أرقام النسخ (v1, v2) وتواريخ النشر والتحديث
|
||||
* - الربط مع شجرة المنهاج الوزاري المعتمد
|
||||
*/
|
||||
class TeacherSubmissionsTab extends StatefulWidget {
|
||||
final VoidCallback? onNavigateToUpload;
|
||||
const TeacherSubmissionsTab({super.key, this.onNavigateToUpload});
|
||||
|
||||
@override
|
||||
State<TeacherSubmissionsTab> createState() => _TeacherSubmissionsTabState();
|
||||
}
|
||||
|
||||
class _TeacherSubmissionsTabState extends State<TeacherSubmissionsTab> {
|
||||
final TeacherRepository _repository = TeacherRepository();
|
||||
bool _isLoading = true;
|
||||
List<Map<String, dynamic>> _submissions = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadSubmissions();
|
||||
}
|
||||
|
||||
Future<void> _loadSubmissions() async {
|
||||
setState(() => _isLoading = true);
|
||||
try {
|
||||
final data = await _repository.getMySubmissions();
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_submissions = data;
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
} catch (_) {
|
||||
if (mounted) {
|
||||
setState(() => _isLoading = false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Color _statusColor(String status) {
|
||||
switch (status.toLowerCase()) {
|
||||
case 'published':
|
||||
case 'approved':
|
||||
return TeacherTheme.emeraldPrimary;
|
||||
case 'review':
|
||||
case 'uploading':
|
||||
return const Color(0xFFF59E0B);
|
||||
case 'rejected':
|
||||
return const Color(0xFFEF4444);
|
||||
case 'superseded':
|
||||
case 'withdrawn':
|
||||
return const Color(0xFF64748B);
|
||||
default:
|
||||
return const Color(0xFF94A3B8);
|
||||
}
|
||||
}
|
||||
|
||||
String _statusLabel(String status) {
|
||||
switch (status.toLowerCase()) {
|
||||
case 'published':
|
||||
return 'منشور ومعتمد في المنهاج 🌟';
|
||||
case 'approved':
|
||||
return 'معتمد ومؤهل للنشر ✅';
|
||||
case 'review':
|
||||
return 'قيد الفحص والتدقيق الأكاديمي ⏳';
|
||||
case 'uploading':
|
||||
return 'جاري معالجة الفيديو ⚙️';
|
||||
case 'rejected':
|
||||
return 'مرفوض — يحتاج تعديل ⚠️';
|
||||
case 'superseded':
|
||||
return 'مستبدل بنسخة أحدث 🔄';
|
||||
case 'withdrawn':
|
||||
return 'مسحوب من النشر 🛑';
|
||||
default:
|
||||
return 'مسودة قيد الإعداد 📝';
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_isLoading) {
|
||||
return const Center(
|
||||
child: CupertinoActivityIndicator(color: TeacherTheme.emeraldPrimary, radius: 14),
|
||||
);
|
||||
}
|
||||
|
||||
if (_submissions.isEmpty) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(32),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 72,
|
||||
height: 72,
|
||||
decoration: BoxDecoration(
|
||||
color: TeacherTheme.surfaceCard,
|
||||
borderRadius: BorderRadius.circular(22),
|
||||
border: Border.all(color: TeacherTheme.surfaceBorder),
|
||||
),
|
||||
child: const Icon(CupertinoIcons.videocam_fill,
|
||||
color: TeacherTheme.emeraldPrimary, size: 36),
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
const Text(
|
||||
'لا توجد حصص مرفوعة بعد',
|
||||
style: TextStyle(
|
||||
color: Colors.white, fontSize: 17, fontWeight: FontWeight.w800),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
const Text(
|
||||
'لم تقم برفع أي فيديوهات أو حصص لمنهاج الصف العاشر بعد. ابدأ برفع أول حصة لتخضع للفحص وتُنشر للطلبة.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Color(0xFF94A3B8), fontSize: 13, height: 1.5),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
ElevatedButton.icon(
|
||||
onPressed: widget.onNavigateToUpload,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: TeacherTheme.emeraldPrimary,
|
||||
foregroundColor: Colors.black,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
|
||||
),
|
||||
icon: const Icon(CupertinoIcons.cloud_upload_fill, size: 18),
|
||||
label: const Text('الانتقال لاستوديو الرفع 🎥',
|
||||
style: TextStyle(fontWeight: FontWeight.w800)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return RefreshIndicator(
|
||||
color: TeacherTheme.emeraldPrimary,
|
||||
backgroundColor: TeacherTheme.surfaceDark,
|
||||
onRefresh: _loadSubmissions,
|
||||
child: ListView.builder(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: _submissions.length + 1,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
'إجمالي الحصص المرفوعة (${_submissions.length}) 📚',
|
||||
style: const TextStyle(
|
||||
color: Colors.white, fontSize: 15, fontWeight: FontWeight.w800),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(CupertinoIcons.arrow_clockwise,
|
||||
color: TeacherTheme.emeraldPrimary, size: 18),
|
||||
onPressed: _loadSubmissions,
|
||||
tooltip: 'تحديث القائمة',
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final sub = _submissions[index - 1];
|
||||
final versions = (sub['versions'] as List?) ?? [];
|
||||
final subStatus = sub['submission_status']?.toString() ?? 'draft';
|
||||
final color = _statusColor(subStatus);
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 14),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: TeacherTheme.surfaceCard,
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
border: Border.all(color: TeacherTheme.surfaceBorder),
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
sub['lesson_title']?.toString() ?? 'حصة تعليمية',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w800),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withAlpha(38),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: color.withAlpha(102)),
|
||||
),
|
||||
child: Text(
|
||||
_statusLabel(subStatus),
|
||||
style: TextStyle(
|
||||
color: color, fontSize: 11.5, fontWeight: FontWeight.w800),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
children: [
|
||||
const Icon(CupertinoIcons.book, color: Color(0xFF64748B), size: 14),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
'المبحث: ${sub['subject_key'] ?? "منهاج معتمد"} • ${sub['grade_level'] ?? "الصف العاشر"}',
|
||||
style: const TextStyle(color: Color(0xFF94A3B8), fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (versions.isNotEmpty) ...[
|
||||
const SizedBox(height: 12),
|
||||
const Divider(color: TeacherTheme.surfaceBorder, height: 1),
|
||||
const SizedBox(height: 10),
|
||||
const Text(
|
||||
'النسخ المرفوعة وتاريخ الإيداع:',
|
||||
style: TextStyle(
|
||||
color: Colors.white70, fontSize: 11.5, fontWeight: FontWeight.w700),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
...versions.map((v) {
|
||||
final vNum = v['version_number'] ?? 1;
|
||||
final vStat = v['video_status']?.toString() ?? 'draft';
|
||||
final isCurrent = v['is_current_published'] == true;
|
||||
final vColor = _statusColor(vStat);
|
||||
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(top: 6),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: const Color(0xFF0F172A),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(
|
||||
color: isCurrent
|
||||
? TeacherTheme.emeraldPrimary.withAlpha(77)
|
||||
: Colors.white10),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
isCurrent
|
||||
? CupertinoIcons.checkmark_seal_fill
|
||||
: CupertinoIcons.film,
|
||||
color: isCurrent
|
||||
? TeacherTheme.emeraldPrimary
|
||||
: const Color(0xFF94A3B8),
|
||||
size: 16,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'النسخة $vNum ${isCurrent ? " (المعتمدة حالياً)" : ""}',
|
||||
style: TextStyle(
|
||||
color: isCurrent ? Colors.white : const Color(0xFFCBD5E1),
|
||||
fontSize: 12,
|
||||
fontWeight: isCurrent ? FontWeight.w800 : FontWeight.w600),
|
||||
),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
_statusLabel(vStat),
|
||||
style: TextStyle(
|
||||
color: vColor, fontSize: 11, fontWeight: FontWeight.w700),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import '../../core/utils/saqel_toast.dart';
|
||||
import '../../data/models/teacher_models.dart';
|
||||
import '../../logic/cubits/teacher_auth_cubit.dart';
|
||||
import 'tabs/teacher_studio_upload_tab.dart';
|
||||
import 'tabs/teacher_submissions_tab.dart';
|
||||
import 'tabs/teacher_monetization_tab.dart';
|
||||
import 'tabs/teacher_reputation_scorecard_tab.dart';
|
||||
import 'tabs/teacher_assignments_qna_tab.dart';
|
||||
@@ -353,11 +354,14 @@ class _TeacherMainShellState extends State<TeacherMainShell> {
|
||||
),
|
||||
body: IndexedStack(
|
||||
index: _currentTabIndex,
|
||||
children: const [
|
||||
TeacherStudioUploadTab(),
|
||||
TeacherMonetizationTab(),
|
||||
TeacherReputationScorecardTab(),
|
||||
TeacherAssignmentsQnATab(),
|
||||
children: [
|
||||
const TeacherStudioUploadTab(),
|
||||
TeacherSubmissionsTab(
|
||||
onNavigateToUpload: () => setState(() => _currentTabIndex = 0),
|
||||
),
|
||||
const TeacherMonetizationTab(),
|
||||
const TeacherReputationScorecardTab(),
|
||||
const TeacherAssignmentsQnATab(),
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: Container(
|
||||
@@ -379,8 +383,12 @@ class _TeacherMainShellState extends State<TeacherMainShell> {
|
||||
elevation: 0,
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(CupertinoIcons.videocam_circle_fill),
|
||||
label: 'استوديو الحصص',
|
||||
icon: Icon(CupertinoIcons.cloud_upload_fill),
|
||||
label: 'استوديو الرفع',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(CupertinoIcons.play_rectangle_fill),
|
||||
label: 'حصصي وفيديوهاتي',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(CupertinoIcons.money_dollar_circle_fill),
|
||||
|
||||
@@ -74,7 +74,7 @@ packages:
|
||||
source: hosted
|
||||
version: "0.3.5+5"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: crypto
|
||||
sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf
|
||||
@@ -340,10 +340,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6"
|
||||
sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.12.18"
|
||||
version: "0.12.19"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -356,10 +356,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
|
||||
sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.17.0"
|
||||
version: "1.18.0"
|
||||
nested:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -585,10 +585,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
sha256: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636"
|
||||
sha256: "949a932224383300f01be9221c39180316445ecb8e7547f70a41a35bf421fb9e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.9"
|
||||
version: "0.7.11"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -32,6 +32,7 @@ dependencies:
|
||||
shared_preferences: ^2.2.3
|
||||
http: ^1.2.0
|
||||
device_info_plus: ^10.1.0
|
||||
crypto: ^3.0.3
|
||||
google_fonts: ^6.2.1
|
||||
intl: ^0.19.0
|
||||
file_picker: 8.3.7
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:teacher_app/core/services/device_fingerprint_service.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
setUp(() {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
DeviceFingerprintService.resetCache();
|
||||
});
|
||||
|
||||
test('DeviceFingerprintService in teacher_app returns deterministic real fingerprint', () async {
|
||||
final fp1 = await DeviceFingerprintService.getFingerprint();
|
||||
expect(fp1, isNotEmpty);
|
||||
expect(fp1.startsWith('saqel_'), isTrue);
|
||||
|
||||
final fp2 = await DeviceFingerprintService.getFingerprint();
|
||||
expect(fp2, equals(fp1));
|
||||
});
|
||||
|
||||
test('DeviceFingerprintService in teacher_app metadata contains physical device keys', () async {
|
||||
final metadata = await DeviceFingerprintService.getDeviceMetadata();
|
||||
expect(metadata.containsKey('device_fingerprint'), isTrue);
|
||||
expect(metadata.containsKey('platform'), isTrue);
|
||||
expect(metadata.containsKey('hardware_id'), isTrue);
|
||||
expect(metadata.containsKey('model'), isTrue);
|
||||
expect(metadata.containsKey('persistent_install_id'), isTrue);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user