mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-02-23 08:34:39 +01:00
rm: field password of PrivateKeyInfo
This commit is contained in:
@@ -5,25 +5,21 @@ part 'private_key_info.g.dart';
|
||||
@HiveType(typeId: 1)
|
||||
class PrivateKeyInfo {
|
||||
@HiveField(0)
|
||||
late String id;
|
||||
final String id;
|
||||
@HiveField(1)
|
||||
late String key;
|
||||
@Deprecated('Never use this field')
|
||||
@HiveField(2)
|
||||
late String password;
|
||||
final String key;
|
||||
|
||||
PrivateKeyInfo({
|
||||
required this.id,
|
||||
required this.key,
|
||||
});
|
||||
|
||||
PrivateKeyInfo.fromJson(Map<String, dynamic> json) {
|
||||
id = json["id"].toString();
|
||||
key = json["private_key"].toString();
|
||||
}
|
||||
PrivateKeyInfo.fromJson(Map<String, dynamic> json)
|
||||
: id = json["id"].toString(),
|
||||
key = json["private_key"].toString();
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
final data = <String, String>{};
|
||||
data["id"] = id;
|
||||
data["private_key"] = key;
|
||||
return data;
|
||||
|
||||
@@ -25,14 +25,11 @@ class PrivateKeyInfoAdapter extends TypeAdapter<PrivateKeyInfo> {
|
||||
@override
|
||||
void write(BinaryWriter writer, PrivateKeyInfo obj) {
|
||||
writer
|
||||
..writeByte(3)
|
||||
..writeByte(2)
|
||||
..writeByte(0)
|
||||
..write(obj.id)
|
||||
..writeByte(1)
|
||||
..write(obj.key)
|
||||
..writeByte(2)
|
||||
// ignore: deprecated_member_use_from_same_package
|
||||
..write(obj.password);
|
||||
..write(obj.key);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 412;
|
||||
static const int build = 413;
|
||||
static const String engine = "3.10.6";
|
||||
static const String buildAt = "2023-08-04 22:48:00.585855";
|
||||
static const int modifications = 4;
|
||||
static const String buildAt = "2023-08-04 23:23:25.517350";
|
||||
static const int modifications = 5;
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ import '../../../locator.dart';
|
||||
const _format = 'text/plain';
|
||||
|
||||
class PrivateKeyEditPage extends StatefulWidget {
|
||||
const PrivateKeyEditPage({Key? key, this.info}) : super(key: key);
|
||||
const PrivateKeyEditPage({Key? key, this.pki}) : super(key: key);
|
||||
|
||||
final PrivateKeyInfo? info;
|
||||
final PrivateKeyInfo? pki;
|
||||
|
||||
@override
|
||||
_PrivateKeyEditPageState createState() => _PrivateKeyEditPageState();
|
||||
@@ -68,13 +68,13 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
|
||||
}
|
||||
|
||||
PreferredSizeWidget _buildAppBar() {
|
||||
final actions = widget.info == null
|
||||
final actions = widget.pki == null
|
||||
? null
|
||||
: [
|
||||
IconButton(
|
||||
tooltip: _s.delete,
|
||||
onPressed: () {
|
||||
_provider.delete(widget.info!);
|
||||
_provider.delete(widget.pki!);
|
||||
context.pop();
|
||||
},
|
||||
icon: const Icon(Icons.delete))
|
||||
@@ -100,9 +100,14 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
|
||||
setState(() {
|
||||
_loading = centerSizedLoading;
|
||||
});
|
||||
final info = PrivateKeyInfo(id: name, key: key);
|
||||
try {
|
||||
info.key = await compute(decyptPem, [key, pwd]);
|
||||
final decrypted = await compute(decyptPem, [key, pwd]);
|
||||
final pki = PrivateKeyInfo(id: name, key: decrypted);
|
||||
if (widget.pki != null) {
|
||||
_provider.update(widget.pki!, pki);
|
||||
} else {
|
||||
_provider.add(pki);
|
||||
}
|
||||
} catch (e) {
|
||||
showSnackBar(context, Text(e.toString()));
|
||||
rethrow;
|
||||
@@ -111,11 +116,6 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
|
||||
_loading = nil;
|
||||
});
|
||||
}
|
||||
if (widget.info != null) {
|
||||
_provider.update(widget.info!, info);
|
||||
} else {
|
||||
_provider.add(info);
|
||||
}
|
||||
context.pop();
|
||||
},
|
||||
child: const Icon(Icons.save),
|
||||
@@ -192,9 +192,9 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
|
||||
|
||||
@override
|
||||
Future<void> afterFirstLayout(BuildContext context) async {
|
||||
if (widget.info != null) {
|
||||
_nameController.text = widget.info!.id;
|
||||
_keyController.text = widget.info!.key;
|
||||
if (widget.pki != null) {
|
||||
_nameController.text = widget.pki!.id;
|
||||
_keyController.text = widget.pki!.key;
|
||||
} else {
|
||||
final clipdata = ((await Clipboard.getData(_format))?.text ?? '').trim();
|
||||
if (clipdata.startsWith('-----BEGIN') && clipdata.endsWith('-----')) {
|
||||
|
||||
@@ -74,7 +74,7 @@ class _PrivateKeyListState extends State<PrivateKeysListPage> {
|
||||
title: Text(key.pkis[idx].id),
|
||||
trailing: TextButton(
|
||||
onPressed: () => AppRoute(
|
||||
PrivateKeyEditPage(info: key.pkis[idx]),
|
||||
PrivateKeyEditPage(pki: key.pkis[idx]),
|
||||
'private key edit page',
|
||||
).go(context),
|
||||
child: Text(_s.edit),
|
||||
@@ -108,7 +108,7 @@ class _PrivateKeyListState extends State<PrivateKeysListPage> {
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
AppRoute(
|
||||
PrivateKeyEditPage(info: sysPk),
|
||||
PrivateKeyEditPage(pki: sysPk),
|
||||
'private key edit page',
|
||||
).go(context);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user