feat: migrate secret management to datastore proto and tink
This commit is contained in:
+7
-5
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user