fix
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
Scott E. Graves 2025-03-20 21:52:18 -05:00
parent 164f8ffc7c
commit 6d2023ba1b
4 changed files with 57 additions and 33 deletions

View File

@ -26,6 +26,7 @@
#include "rpc/common.hpp"
#include "types/repertory.hpp"
#include "ui/mgmt_app_config.hpp"
#include "utils/collection.hpp"
#include "utils/common.hpp"
#include "utils/config.hpp"
#include "utils/error_utils.hpp"
@ -42,7 +43,11 @@ namespace {
return std::string{data};
}
auto decoded = macaron::Base64::Decode(data);
repertory::data_buffer decoded;
if (not repertory::utils::collection::from_hex_string(data, decoded)) {
throw repertory::utils::error::create_exception(function_name,
{"decryption failed"});
}
repertory::data_buffer buffer(decoded.size());
auto key = repertory::utils::encryption::create_hash_blake2b_256(password);

View File

@ -1,5 +1,6 @@
import 'dart:convert';
import 'package:convert/convert.dart';
import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
@ -270,6 +271,7 @@ Future<Map<String, dynamic>> convertAllToString(
}
}
debugPrint('password|$password');
settings[entry.key] = encryptValue(entry.value, password!);
continue;
}
@ -312,7 +314,7 @@ String encryptValue(String value, String password) {
nonce: nonce,
);
return base64Encode(Uint8List.fromList([...nonce, ...data]));
return hex.encode(nonce + data);
}
Future<String?> promptPassword() async {
@ -320,7 +322,7 @@ Future<String?> promptPassword() async {
return null;
}
String updatedValue1 = '';
String password = '';
return await showDialog(
context: constants.navigatorKey.currentContext!,
builder: (context) {
@ -333,23 +335,54 @@ Future<String?> promptPassword() async {
TextButton(
child: const Text('OK'),
onPressed: () {
if (updatedValue1.isEmpty) {
if (password.isEmpty) {
return displayErrorMessage(context, "Password is not valid");
}
Navigator.of(context).pop(updatedValue1);
Navigator.of(context).pop(password);
},
),
],
content: TextField(
autofocus: true,
controller: TextEditingController(text: updatedValue1),
controller: TextEditingController(text: password),
obscureText: true,
obscuringCharacter: '*',
onChanged: (value) => updatedValue1 = value,
onChanged: (value) => password = value,
),
title: const Text('Enter Authentication Password'),
);
},
);
}
Map<String, dynamic> getChanged(
Map<String, dynamic> original,
Map<String, dynamic> updated,
) {
if (DeepCollectionEquality().equals(original, updated)) {
return {};
}
Map<String, dynamic> changedSettings = {};
original.forEach((key, value) {
if (DeepCollectionEquality().equals(value, updated[key])) {
return;
}
if (value is Map<String, dynamic>) {
changedSettings[key] = <String, dynamic>{};
value.forEach((subKey, subValue) {
if (DeepCollectionEquality().equals(subValue, updated[key][subKey])) {
return;
}
changedSettings[key][subKey] = updated[key][subKey];
});
} else {
changedSettings[key] = updated[key];
}
});
return changedSettings;
}

View File

@ -1,9 +1,12 @@
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:repertory/constants.dart' as constants;
import 'package:repertory/helpers.dart'
show convertAllToString, getSettingDescription, getSettingValidators;
show
convertAllToString,
getChanged,
getSettingDescription,
getSettingValidators;
import 'package:repertory/models/mount.dart';
import 'package:repertory/models/mount_list.dart';
import 'package:repertory/settings.dart';
@ -614,30 +617,12 @@ class _MountSettingsWidgetState extends State<MountSettingsWidget> {
@override
void dispose() {
if (!widget.isAdd) {
var settings = widget.mount.mountConfig.settings;
Map<String, dynamic> changedSettings = {};
if (!DeepCollectionEquality().equals(widget.settings, settings)) {
widget.settings.forEach((key, value) {
if (!DeepCollectionEquality().equals(settings[key], value)) {
if (value is Map<String, dynamic>) {
changedSettings[key] = <String, dynamic>{};
value.forEach((subKey, subValue) {
if (!DeepCollectionEquality().equals(
settings[key][subKey],
subValue,
)) {
changedSettings[key][subKey] = subValue;
}
});
} else {
changedSettings[key] = value;
}
}
});
}
if (changedSettings.isNotEmpty) {
convertAllToString(changedSettings).then((map) {
final settings = getChanged(
widget.mount.mountConfig.settings,
widget.settings,
);
if (settings.isNotEmpty) {
convertAllToString(settings).then((map) {
map.forEach((key, value) {
if (value is Map<String, dynamic>) {
value.forEach((subKey, subValue) {

View File

@ -39,6 +39,7 @@ dependencies:
provider: ^6.1.2
settings_ui: ^2.0.2
sodium_libs: ^3.4.4+1
convert: ^3.1.2
dev_dependencies:
flutter_test: