fix(scripts): rotate the wanderer token with the encryption key

The key rotation now re-encrypts wanderer_connections.token, so a wanderer connection keeps working after the key changes instead of calling out without its token.
This commit is contained in:
Maurice
2026-11-23 14:59:21 +01:00
parent 9c454a04e1
commit 60885627b1
2 changed files with 47 additions and 0 deletions
+15
View File
@@ -562,6 +562,21 @@ async function rotateSecrets(store: SecretStore, oldKey: string, newKey: string)
}
}
// --- wanderer_connections: token ---
// One row per user, like dawarich_connections. Left out of a rotation, the
// connection still shows as connected but every call goes out without a token.
if (await store.tableExists('wanderer_connections')) {
const connections = await store.all<{ user_id: number; token: string }>(
'SELECT user_id, token FROM wanderer_connections WHERE token IS NOT NULL',
);
for (const row of connections) {
const newVal = migrateApiKeyValue(row.token, `wanderer_connections[${row.user_id}].token`);
if (newVal !== null) {
await store.run('UPDATE wanderer_connections SET token = ? WHERE user_id = ?', [newVal, row.user_id]);
}
}
}
// --- trek_photos: passphrase ---
const photos = await store.all<{ id: number; passphrase: string }>(
'SELECT id, passphrase FROM trek_photos WHERE passphrase IS NOT NULL',