-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Encrypted tokens/tickets to keep state in the client side.
@package crypto-token
@version 0.2.2


-- | Encrypted tokens/tickets to keep state in the client side.
module Crypto.Token

-- | Configuration for token manager.
data Config

-- | Default configuration to update secrets in 30 minutes (1,800 seconds)
--   and token lifetime is 2 hours (7,200 seconds)
--   
--   <pre>
--   &gt;&gt;&gt; defaultConfig
--   Config {interval = 1800, tokenLifetime = 7200, threadName = "Crypto token manager"}
--   </pre>
defaultConfig :: Config

-- | The interval to generate a new secret and remove the oldest one in
--   seconds.
interval :: Config -> Int

-- | The token lifetime in seconds, that is, tokens can be decrypted in
--   this period. It is cut short if it spans more than 65535 intervals.
tokenLifetime :: Config -> Int

-- | The label of the thread used without the timer manager.
threadName :: Config -> String

-- | The abstract data type for token manager.
data TokenManager

-- | Spawning a token manager. Secrets are rotated every <a>interval</a> by
--   a timer of the RTS, with no thread of its own, also when no token is
--   made. The timer ends with <a>killTokenManager</a>, or once the manager
--   is garbage-collected. Without the timer manager of the threaded RTS on
--   a POSIX system, a thread does the same. This throws an <a>IOError</a>
--   if <a>interval</a> is not positive.
spawnTokenManager :: Config -> IO TokenManager

-- | Killing a token manager: its rotation stops and the secrets made so
--   far are forgotten.
killTokenManager :: TokenManager -> IO ()

-- | Encrypting a target value to get a token.
encryptToken :: TokenManager -> ByteString -> IO ByteString

-- | Decrypting a token to get a target value.
decryptToken :: TokenManager -> ByteString -> IO (Maybe ByteString)
instance GHC.Internal.Classes.Eq Crypto.Token.Config
instance GHC.Internal.Show.Show Crypto.Token.Config
