/*
 * SPDX-License-Identifier: GPL-3.0-or-later
 */
package com.runicgateway.app.core.auth.sso

/**
 * Persists the in-flight SSO `{state, verifier}` (PKCE Layer B + CSRF state) across
 * the Custom-Tab round trip so the exchange survives process death — a low-memory
 * device can evict the app while the Custom Tab is foreground, and the callback then
 * returns to a fresh process (PLAN.md §4.2). Kept behind an interface so
 * [SsoAuthManager] stays framework-free and unit-tests on the JVM with a fake.
 *
 * Exactly one flow is pending at a time; [save] overwrites any prior. The verifier
 * is a bearer-equivalent secret for the one-time code, so the production impl
 * ([EncryptedPendingSsoStore]) encrypts it at rest, mirroring the token store.
 */
interface PendingSsoStore {
    fun save(state: String, verifier: String)
    fun load(): PendingSso?
    fun clear()
}

/** The stashed CSRF state + PKCE verifier for the current SSO attempt. */
data class PendingSso(val state: String, val verifier: String)
