feat: migrate secret management to datastore proto and tink

This commit is contained in:
2026-06-02 18:15:22 +02:00
parent 2be68d38a5
commit e8b3f898e8
16 changed files with 328 additions and 128 deletions
@@ -118,7 +118,7 @@ class WalletNotificationService : Service() {
// Step 2: Open the WebSocket. If already open (e.g. service restarted
// by Android after a kill), close the old one first.
openWebSocket()
serviceScope.launch { openWebSocket() }
// START_REDELIVER_INTENT: if Android kills the service under memory
// pressure, it will restart it and re-deliver the last intent.
@@ -141,19 +141,21 @@ class WalletNotificationService : Service() {
// ── WebSocket ─────────────────────────────────────────────────────────────
private fun openWebSocket() {
private suspend fun openWebSocket() {
val secrets = EncryptedSecretStore(applicationContext)
val invoiceKey = secrets.invoiceKey()
val baseUrl = secrets.baseUrl()
if (secrets.invoiceKey.isBlank() || secrets.baseUrl.isBlank()) {
if (invoiceKey.isBlank() || baseUrl.isBlank()) {
Log.e(TAG, "Credentials not available — cannot open WebSocket")
stopSelf()
return
}
val wsUrl = secrets.baseUrl
val wsUrl = baseUrl
.replace("https://", "wss://")
.replace("http://", "ws://")
.trimEnd('/') + "/api/v1/ws/${secrets.invoiceKey}"
.trimEnd('/') + "/api/v1/ws/${invoiceKey}"
Log.d(TAG, "Opening WebSocket: $wsUrl")