1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-04-08 00:56:25 +02:00
immich/mobile/lib/entities/store.entity.dart
shenlong 76d95cd348
refactor(mobile): move store settings and store into domain folder ()
Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
2025-02-19 19:27:32 +00:00

38 lines
1 KiB
Dart

import 'dart:convert';
import 'dart:typed_data';
import 'package:immich_mobile/domain/models/store.model.dart';
import 'package:immich_mobile/domain/services/store.service.dart';
// ignore: non_constant_identifier_names
final Store = StoreService.I;
class SSLClientCertStoreVal {
final Uint8List data;
final String? password;
SSLClientCertStoreVal(this.data, this.password);
void save() {
final b64Str = base64Encode(data);
Store.put(StoreKey.sslClientCertData, b64Str);
if (password != null) {
Store.put(StoreKey.sslClientPasswd, password!);
}
}
static SSLClientCertStoreVal? load() {
final b64Str = Store.tryGet<String>(StoreKey.sslClientCertData);
if (b64Str == null) {
return null;
}
final Uint8List certData = base64Decode(b64Str);
final passwd = Store.tryGet<String>(StoreKey.sslClientPasswd);
return SSLClientCertStoreVal(certData, passwd);
}
static void delete() {
Store.delete(StoreKey.sslClientCertData);
Store.delete(StoreKey.sslClientPasswd);
}
}