voip.ms Messages: Signal-style desktop SMS client
Electron + React app that imports the full voip.ms SMS history into a local SQLite/FTS5 database, polls for new messages, sends SMS, resolves names/photos from GNOME EDS address books, and supports global and per-chat search with jump-to-message. Data lives in ~/Documents/voipms-desktop-data (covered by Deja Dup) with daily consistent snapshots. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
// API credentials, encrypted with Electron safeStorage (GNOME Keyring/libsecret).
|
||||
// Stored in Electron's userData dir, deliberately outside the backed-up data
|
||||
// folder: the blob is useless without this machine's keyring anyway.
|
||||
import { app, safeStorage } from 'electron'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import type { Credentials } from '@shared/types'
|
||||
|
||||
const file = (): string => path.join(app.getPath('userData'), 'credentials.bin')
|
||||
|
||||
export function loadCredentials(): Credentials | undefined {
|
||||
try {
|
||||
const blob = fs.readFileSync(file())
|
||||
return JSON.parse(safeStorage.decryptString(blob)) as Credentials
|
||||
} catch {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
export function saveCredentials(creds: Credentials): void {
|
||||
if (!safeStorage.isEncryptionAvailable()) throw new Error('No system keyring available to store the API password securely.')
|
||||
fs.mkdirSync(path.dirname(file()), { recursive: true })
|
||||
fs.writeFileSync(file(), safeStorage.encryptString(JSON.stringify(creds)), { mode: 0o600 })
|
||||
}
|
||||
|
||||
export function clearCredentials(): void {
|
||||
fs.rmSync(file(), { force: true })
|
||||
}
|
||||
Reference in New Issue
Block a user