loadCredentials function
Reads cached credentials from the credentials file.
Returns null if the file doesn't exist or is invalid.
Warns if the file has insecure permissions on Unix systems.
Implementation
KumihoCredentials? loadCredentials() {
final file = getCredentialsFile();
if (!file.existsSync()) {
return null;
}
// Security: Check file permissions before reading
_checkCredentialPermissions(file);
try {
final content = file.readAsStringSync();
final json = jsonDecode(content) as Map<String, dynamic>;
return KumihoCredentials.fromJson(json);
} catch (_) {
return null;
}
}