TokenStore

class TokenStore(tokenFile: Path, encryptionKeyHex: String)

Persists OAuth Tokens as AES-256-GCM encrypted JSON on disk.

The token file is written with owner-only POSIX permissions when supported.

Parameters

tokenFile

path where the encrypted token blob is stored

encryptionKeyHex

64-character hex string representing a 256-bit AES key

Constructors

Link copied to clipboard
constructor(tokenFile: Path, encryptionKeyHex: String)
constructor(tokenFile: Path, encryptionKey: SecretKey)

Alternative constructor accepting a pre-built SecretKey.

Functions

Link copied to clipboard
fun clear()

Deletes the token file from disk.

Link copied to clipboard
fun load(): Tokens?

Loads and decrypts tokens from disk, or returns null if the file is missing or corrupt.

Link copied to clipboard
fun save(tokens: Tokens)

Encrypts and writes tokens to disk. Creates parent directories if needed.