add extra logging to simplefin setup

This commit is contained in:
Robert Dyer
2026-02-28 12:18:31 -06:00
committed by GitHub
parent f18c6d1e1c
commit a5c9c0fd6f
+17 -9
View File
@@ -16,16 +16,21 @@ const getCredentials = async () => {
const response = await fetch(url, { method: 'post' }); const response = await fetch(url, { method: 'post' });
const api_url = await response.text(); const api_url = await response.text();
const rest = api_url.split('//', 2)[1]; try {
const auth = rest.split('@', 1)[0]; const rest = api_url.split('//', 2)[1];
const username = auth.split(':')[0]; const auth = rest.split('@', 1)[0];
const pw = auth.split(':')[1]; const username = auth.split(':')[0];
const pw = auth.split(':')[1];
const data = `${username}:${pw}`; const data = `${username}:${pw}`;
const cache = process.env.ACTUAL_CACHE_DIR || './cache'; const cache = process.env.ACTUAL_CACHE_DIR || './cache';
fs.writeFileSync(cache + '/simplefin.credentials', data); fs.writeFileSync(cache + '/simplefin.credentials', data);
console.log('SimpleFIN credentials:', data); console.log('SimpleFIN credentials:', data);
return data; return data;
} catch (err) {
console.log('Invalid SimpleFIN setup response:', api_url);
return undefined;
}
}; };
const loadCredentials = () => { const loadCredentials = () => {
@@ -41,6 +46,9 @@ const getSimplefinBalances = async () => {
let credentials = loadCredentials(); let credentials = loadCredentials();
if (!credentials) { if (!credentials) {
credentials = await getCredentials(); credentials = await getCredentials();
if (!credentials) {
return undefined;
}
} }
const username = credentials.split(':')[0]; const username = credentials.split(':')[0];
const pw = credentials.split(':')[1]; const pw = credentials.split(':')[1];