Return from the Skysparkle sign-in through a verified App Link

Replace the cc.skysparkle.sparkledns:// callback with
https://app.skysparkle.cc/app/callback (autoVerify), so only the app
signed with the release key can receive the one-time code.
This commit is contained in:
2026-11-18 14:47:51 +02:00
parent 7f02ec606c
commit e36b9de154
2 changed files with 13 additions and 8 deletions
@@ -26,13 +26,14 @@ import java.security.SecureRandom
//
// OAuth for native apps (RFC 8252) with PKCE (RFC 7636): the account page opens in the browser,
// so the password never passes through the app. After "Connect" the site sends the browser to
// cc.skysparkle.sparkledns://connect?code=…&state=…, and the app trades the one-time code for a
// new key. Only this app knows the verifier, so a code caught by another app is useless.
// https://app.skysparkle.cc/app/callback?code=…&state=…, a verified App Link that only this app
// (signed with our key) receives, and the app trades the one-time code for a new key. Only this
// app knows the verifier, so even a code that leaked somewhere else is useless.
object SkysparkleSignIn {
private const val CONNECT_URL = "https://skysparkle.cc/app/connect"
private const val TOKEN_URL = "https://skysparkle.cc/api/app/token"
private const val SCHEME = "cc.skysparkle.sparkledns"
private const val HOST = "connect"
private const val CALLBACK_HOST = "app.skysparkle.cc"
private const val CALLBACK_PATH = "/app/callback"
// The browser step must be finished within this time (the site keeps codes for 5 minutes)
private const val PENDING_TTL_MS = 30 * 60_000L
@@ -51,7 +52,8 @@ object SkysparkleSignIn {
// Not tied to a screen: rotating or leaving the screen must not cancel the exchange
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
fun isCallback(uri: Uri?): Boolean = uri?.scheme == SCHEME && uri.host == HOST
fun isCallback(uri: Uri?): Boolean =
uri?.scheme == "https" && uri.host == CALLBACK_HOST && uri.path == CALLBACK_PATH
// Opens the account page. Verifier and state are kept on disk: the system may stop the app
// while the browser is in front.