CH-J SM Mobileserverhantering över SSH
Menyn
Publicerad källa

CH-J SM Mobile

Bläddra i kataloger och filer för en specifik programutgåva.

Ladda ner källa ZIP
CH-J / SM Mobile 134 filer
sm-mobile-20261016T050549Z-3678f2a05fa9 Tillagd: · Byggd:
Filer
legal.dart Tillagd: Datum inte noterat 1,8 KB · 59 linjer
Ladda ner fil
1import 'dart:convert';
2import 'package:cryptography/cryptography.dart';
3import 'package:flutter/services.dart';
4import '../core/build_info.dart';
5import '../core/failure.dart';
6import 'secure_store.dart';
8class Legal {
9 final SecureStore store;
10 String license = '';
11 final Map<String, String> guidance = {};
12 String? _identity;
13 Legal(this.store);
14 Future<bool> load() async {
15 try {
16 license = await rootBundle.loadString('assets/legal/LICENSE.txt');
17 if (!license.contains('Version 1.14') || license.length < 20000) {
18 throw const Failure('licenseError');
19 }
20 for (final lang in ['cs', 'de', 'en']) {
21 guidance[lang] = await rootBundle.loadString(
22 'assets/legal/guidance_$lang.md',
23 );
24 if (guidance[lang]!.isEmpty) throw const Failure('licenseError');
25 }
26 _identity = base64Encode(
27 (await Sha256().hash(
28 utf8.encode(jsonEncode([appVersion, buildId, license, guidance])),
29 )).bytes,
30 );
31 final record = await store.read('consent');
32 if (record == null) return false;
33 final data = jsonDecode(record);
34 return data['identity'] == _identity &&
35 data['accepted'] == true &&
36 data['guidanceDisplayed'] == true;
37 } catch (_) {
38 throw const Failure('licenseError');
39 }
40 }
42 Future<void> accept({required bool guidanceDisplayed}) async {
43 if (_identity == null || !guidanceDisplayed) {
44 throw const Failure('licenseError');
45 }
46 await store.write(
47 'consent',
48 jsonEncode({
49 'identity': _identity,
50 'accepted': true,
51 'guidanceDisplayed': true,
52 'version': appVersion,
53 'buildId': buildId,
54 'licenseVersion': '1.14',
55 'acceptedAt': DateTime.now().toUtc().toIso8601String(),
56 }),
57 );
58 }
SHA-256ee8e9ce7c54cdc46fb260e17eeeceef02b53c81691e87be7bfba4e03d2f5e049

CH-J Proprietary Software License 1.14 · Källan finns under CH-J Proprietary Software License 1.14. Dess tillgänglighet ändrar inte licensvillkoren eller ger ytterligare rättigheter.

Arkiv SHA-256c486a807e4828998b9c57ab0f2e760f7980b31965fe118e89d3e1a5a2b65be65