{-# LANGUAGE StandaloneDeriving #-}

-- | Stability: experimental
-- This module represents all the information the Relying Party must store in
-- the database for every credential.
module Crypto.WebAuthn.Operation.CredentialEntry
  ( CredentialEntry (..),
  )
where

import qualified Crypto.WebAuthn.Model.Types as M
import Data.Aeson (ToJSON)
import GHC.Generics (Generic)

-- | This type represents the database row a Relying Party server needs to
-- store for each credential that's registered to a user
data CredentialEntry = CredentialEntry
  { CredentialEntry -> CredentialId
ceCredentialId :: M.CredentialId,
    CredentialEntry -> UserHandle
ceUserHandle :: M.UserHandle,
    CredentialEntry -> PublicKeyBytes
cePublicKeyBytes :: M.PublicKeyBytes,
    CredentialEntry -> SignatureCounter
ceSignCounter :: M.SignatureCounter,
    CredentialEntry -> [AuthenticatorTransport]
ceTransports :: [M.AuthenticatorTransport]
  }
  deriving (CredentialEntry -> CredentialEntry -> Bool
(CredentialEntry -> CredentialEntry -> Bool)
-> (CredentialEntry -> CredentialEntry -> Bool)
-> Eq CredentialEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CredentialEntry -> CredentialEntry -> Bool
== :: CredentialEntry -> CredentialEntry -> Bool
$c/= :: CredentialEntry -> CredentialEntry -> Bool
/= :: CredentialEntry -> CredentialEntry -> Bool
Eq, Int -> CredentialEntry -> ShowS
[CredentialEntry] -> ShowS
CredentialEntry -> String
(Int -> CredentialEntry -> ShowS)
-> (CredentialEntry -> String)
-> ([CredentialEntry] -> ShowS)
-> Show CredentialEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CredentialEntry -> ShowS
showsPrec :: Int -> CredentialEntry -> ShowS
$cshow :: CredentialEntry -> String
show :: CredentialEntry -> String
$cshowList :: [CredentialEntry] -> ShowS
showList :: [CredentialEntry] -> ShowS
Show, (forall x. CredentialEntry -> Rep CredentialEntry x)
-> (forall x. Rep CredentialEntry x -> CredentialEntry)
-> Generic CredentialEntry
forall x. Rep CredentialEntry x -> CredentialEntry
forall x. CredentialEntry -> Rep CredentialEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. CredentialEntry -> Rep CredentialEntry x
from :: forall x. CredentialEntry -> Rep CredentialEntry x
$cto :: forall x. Rep CredentialEntry x -> CredentialEntry
to :: forall x. Rep CredentialEntry x -> CredentialEntry
Generic)

-- | An arbitrary and potentially unstable JSON encoding, only intended for
-- logging purposes. To actually encode and decode structures, use the
-- "Crypto.WebAuthn.Encoding" modules
deriving instance ToJSON CredentialEntry