KEncryptedTokenStore

@RequiresApi(value = 23)
class KEncryptedTokenStore(context: Context, prefsName: String = "kindling_secure_tokens", accessTokenKey: String = "access_token", refreshTokenKey: String = "refresh_token") : KTokenStore(source)

KTokenStore backed by standard SharedPreferences with manual AES-GCM encryption.

Tokens are encrypted at rest using AES-256 GCM (key stored in Android Keystore). Recommended for production use on Android 6.0+ (API 23).

This implementation replaces the deprecated EncryptedSharedPreferences and uses standard platform APIs (Keystore, Cipher, SharedPreferences).

Parameters

context

Android Context used to open SharedPreferences.

prefsName

SharedPreferences file name.

accessTokenKey

Key used to store the access token.

refreshTokenKey

Key used to store the refresh token.

Constructors

Link copied to clipboard
constructor(context: Context, prefsName: String = "kindling_secure_tokens", accessTokenKey: String = "access_token", refreshTokenKey: String = "refresh_token")

Functions

Link copied to clipboard
open suspend override fun clear()

Removes all stored tokens.

Link copied to clipboard
open suspend override fun getAccessToken(): String?

Returns the current access token, or null if none is stored.

Link copied to clipboard
open suspend override fun getRefreshToken(): String?

Returns the current refresh token, or null if none is stored.

Link copied to clipboard
open suspend override fun saveTokens(accessToken: String?, refreshToken: String?)

Persists both tokens.