fetchPasswords method
Implementation
Future<List<Password>?> fetchPasswords() async {
var key = await _getMasterKey();
if (key == null) return null;
List<Password> passwords = [];
var _paths = paths(profileFile: 'Login Data');
for (var p in _paths) {
var size = await File(p).length();
if (size == 0) continue;
var dir = await Directory.systemTemp.createTemp();
var f = File('${dir.path}/Login Data');
await f.create();
String tmpFile = f.path;
await copyFile(File(p), tmpFile);
var conn =
sqlite3.open('file:$tmpFile?mode=ro&immutable=1&nolock=1', uri: true);
var result = conn.select(
'SELECT action_url, username_value, password_value FROM logins');
for (var e in result) {
var url = '${e['action_url']}';
var name = '${e['username_value']}';
var password = e['password_value'];
var pass = _decryptPassword(password, key);
if (url.isEmpty || name.isEmpty) continue;
passwords.add(Password(url: url, username: name, password: pass));
}
}
return passwords;
}