-- | Interface for a service for maintaining short-lived credentials, such as
-- access tokens or JWTs.
module Hasura.CredentialCache
  ( CredentialCache (..),
  )
where

import Control.Concurrent.STM
import Hasura.Prelude

newtype CredentialCache cred = CredentialCache
  { -- | Get the stored credential. Also returns an STM action for
    -- requesting a refresh of the credential, which, in turn, returns an STM
    -- action for waiting on the arrival of the fresh credential.
    forall cred. CredentialCache cred -> STM (cred, STM (STM ()))
getCredential :: STM (cred, STM (STM ()))
  }
  deriving stock ((forall a b. (a -> b) -> CredentialCache a -> CredentialCache b)
-> (forall a b. a -> CredentialCache b -> CredentialCache a)
-> Functor CredentialCache
forall a b. a -> CredentialCache b -> CredentialCache a
forall a b. (a -> b) -> CredentialCache a -> CredentialCache b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> CredentialCache a -> CredentialCache b
fmap :: forall a b. (a -> b) -> CredentialCache a -> CredentialCache b
$c<$ :: forall a b. a -> CredentialCache b -> CredentialCache a
<$ :: forall a b. a -> CredentialCache b -> CredentialCache a
Functor)