{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE StandaloneDeriving #-}
module Crypto.WebAuthn.Metadata.Statement.Types
( MetadataStatement (..),
ProtocolVersion (..),
WebauthnAttestationType (..),
)
where
import qualified Crypto.WebAuthn.Metadata.FidoRegistry as Registry
import qualified Crypto.WebAuthn.Metadata.Statement.WebIDL as StatementIDL
import qualified Crypto.WebAuthn.Model as M
import Data.Aeson (ToJSON, toJSON)
import qualified Data.ByteString as BS
import Data.List.NonEmpty (NonEmpty)
import Data.Text (Text)
import Data.Word (Word32)
import qualified Data.X509 as X509
import GHC.Generics (Generic)
import GHC.Word (Word16)
data MetadataStatement (p :: M.ProtocolKind) = MetadataStatement
{
:: Text,
MetadataStatement p -> Text
msDescription :: Text,
MetadataStatement p -> Maybe AlternativeDescriptions
msAlternativeDescriptions :: Maybe StatementIDL.AlternativeDescriptions,
MetadataStatement p -> Word32
msAuthenticatorVersion :: Word32,
MetadataStatement p -> NonEmpty (ProtocolVersion p)
msUpv :: NonEmpty (ProtocolVersion p),
MetadataStatement p -> NonEmpty AuthenticationAlgorithm
msAuthenticationAlgorithms :: NonEmpty Registry.AuthenticationAlgorithm,
MetadataStatement p -> NonEmpty PublicKeyRepresentationFormat
msPublicKeyAlgAndEncodings :: NonEmpty Registry.PublicKeyRepresentationFormat,
MetadataStatement p -> NonEmpty WebauthnAttestationType
msAttestationTypes :: NonEmpty WebauthnAttestationType,
MetadataStatement p -> NonEmpty VerificationMethodANDCombinations
msUserVerificationDetails :: NonEmpty StatementIDL.VerificationMethodANDCombinations,
MetadataStatement p -> NonEmpty KeyProtectionType
msKeyProtection :: NonEmpty Registry.KeyProtectionType,
MetadataStatement p -> Maybe Bool
msIsKeyRestricted :: Maybe Bool,
MetadataStatement p -> Maybe Bool
msIsFreshUserVerificationRequired :: Maybe Bool,
MetadataStatement p -> NonEmpty MatcherProtectionType
msMatcherProtection :: NonEmpty Registry.MatcherProtectionType,
MetadataStatement p -> Maybe Word16
msCryptoStrength :: Maybe Word16,
MetadataStatement p -> NonEmpty AuthenticatorAttachmentHint
msAttachmentHint :: NonEmpty Registry.AuthenticatorAttachmentHint,
MetadataStatement p -> [TransactionConfirmationDisplayType]
msTcDisplay :: [Registry.TransactionConfirmationDisplayType],
MetadataStatement p -> Maybe Text
msTcDisplayContentType :: Maybe Text,
MetadataStatement p
-> Maybe (NonEmpty DisplayPNGCharacteristicsDescriptor)
msTcDisplayPNGCharacteristics :: Maybe (NonEmpty StatementIDL.DisplayPNGCharacteristicsDescriptor),
MetadataStatement p -> NonEmpty SignedCertificate
msAttestationRootCertificates :: NonEmpty X509.SignedCertificate,
MetadataStatement p -> Maybe ByteString
msIcon :: Maybe BS.ByteString,
MetadataStatement p -> Maybe (NonEmpty ExtensionDescriptor)
msSupportedExtensions :: Maybe (NonEmpty StatementIDL.ExtensionDescriptor),
MetadataStatement p -> Maybe AuthenticatorGetInfo
msAuthenticatorGetInfo :: Maybe StatementIDL.AuthenticatorGetInfo
}
deriving (MetadataStatement p -> MetadataStatement p -> Bool
(MetadataStatement p -> MetadataStatement p -> Bool)
-> (MetadataStatement p -> MetadataStatement p -> Bool)
-> Eq (MetadataStatement p)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall (p :: ProtocolKind).
MetadataStatement p -> MetadataStatement p -> Bool
/= :: MetadataStatement p -> MetadataStatement p -> Bool
$c/= :: forall (p :: ProtocolKind).
MetadataStatement p -> MetadataStatement p -> Bool
== :: MetadataStatement p -> MetadataStatement p -> Bool
$c== :: forall (p :: ProtocolKind).
MetadataStatement p -> MetadataStatement p -> Bool
Eq, Int -> MetadataStatement p -> ShowS
[MetadataStatement p] -> ShowS
MetadataStatement p -> String
(Int -> MetadataStatement p -> ShowS)
-> (MetadataStatement p -> String)
-> ([MetadataStatement p] -> ShowS)
-> Show (MetadataStatement p)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall (p :: ProtocolKind). Int -> MetadataStatement p -> ShowS
forall (p :: ProtocolKind). [MetadataStatement p] -> ShowS
forall (p :: ProtocolKind). MetadataStatement p -> String
showList :: [MetadataStatement p] -> ShowS
$cshowList :: forall (p :: ProtocolKind). [MetadataStatement p] -> ShowS
show :: MetadataStatement p -> String
$cshow :: forall (p :: ProtocolKind). MetadataStatement p -> String
showsPrec :: Int -> MetadataStatement p -> ShowS
$cshowsPrec :: forall (p :: ProtocolKind). Int -> MetadataStatement p -> ShowS
Show, (forall x. MetadataStatement p -> Rep (MetadataStatement p) x)
-> (forall x. Rep (MetadataStatement p) x -> MetadataStatement p)
-> Generic (MetadataStatement p)
forall x. Rep (MetadataStatement p) x -> MetadataStatement p
forall x. MetadataStatement p -> Rep (MetadataStatement p) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (p :: ProtocolKind) x.
Rep (MetadataStatement p) x -> MetadataStatement p
forall (p :: ProtocolKind) x.
MetadataStatement p -> Rep (MetadataStatement p) x
$cto :: forall (p :: ProtocolKind) x.
Rep (MetadataStatement p) x -> MetadataStatement p
$cfrom :: forall (p :: ProtocolKind) x.
MetadataStatement p -> Rep (MetadataStatement p) x
Generic, [MetadataStatement p] -> Encoding
[MetadataStatement p] -> Value
MetadataStatement p -> Encoding
MetadataStatement p -> Value
(MetadataStatement p -> Value)
-> (MetadataStatement p -> Encoding)
-> ([MetadataStatement p] -> Value)
-> ([MetadataStatement p] -> Encoding)
-> ToJSON (MetadataStatement p)
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
forall (p :: ProtocolKind). [MetadataStatement p] -> Encoding
forall (p :: ProtocolKind). [MetadataStatement p] -> Value
forall (p :: ProtocolKind). MetadataStatement p -> Encoding
forall (p :: ProtocolKind). MetadataStatement p -> Value
toEncodingList :: [MetadataStatement p] -> Encoding
$ctoEncodingList :: forall (p :: ProtocolKind). [MetadataStatement p] -> Encoding
toJSONList :: [MetadataStatement p] -> Value
$ctoJSONList :: forall (p :: ProtocolKind). [MetadataStatement p] -> Value
toEncoding :: MetadataStatement p -> Encoding
$ctoEncoding :: forall (p :: ProtocolKind). MetadataStatement p -> Encoding
toJSON :: MetadataStatement p -> Value
$ctoJSON :: forall (p :: ProtocolKind). MetadataStatement p -> Value
ToJSON)
data ProtocolVersion (p :: M.ProtocolKind) where
U2F1_0 :: ProtocolVersion 'M.FidoU2F
U2F1_1 :: ProtocolVersion 'M.FidoU2F
U2F1_2 :: ProtocolVersion 'M.FidoU2F
CTAP2_0 :: ProtocolVersion 'M.Fido2
CTAP2_1 :: ProtocolVersion 'M.Fido2
deriving instance Eq (ProtocolVersion p)
deriving instance Show (ProtocolVersion p)
instance ToJSON (ProtocolVersion p) where
toJSON :: ProtocolVersion p -> Value
toJSON ProtocolVersion p
U2F1_0 = Value
"U2F 1.0"
toJSON ProtocolVersion p
U2F1_1 = Value
"U2F 1.1"
toJSON ProtocolVersion p
U2F1_2 = Value
"U2F 1.2"
toJSON ProtocolVersion p
CTAP2_0 = Value
"CTAP 2.0"
toJSON ProtocolVersion p
CTAP2_1 = Value
"CTAP 2.1"
data WebauthnAttestationType
= WebauthnAttestationBasic
| WebauthnAttestationAttCA
deriving (WebauthnAttestationType -> WebauthnAttestationType -> Bool
(WebauthnAttestationType -> WebauthnAttestationType -> Bool)
-> (WebauthnAttestationType -> WebauthnAttestationType -> Bool)
-> Eq WebauthnAttestationType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WebauthnAttestationType -> WebauthnAttestationType -> Bool
$c/= :: WebauthnAttestationType -> WebauthnAttestationType -> Bool
== :: WebauthnAttestationType -> WebauthnAttestationType -> Bool
$c== :: WebauthnAttestationType -> WebauthnAttestationType -> Bool
Eq, Int -> WebauthnAttestationType -> ShowS
[WebauthnAttestationType] -> ShowS
WebauthnAttestationType -> String
(Int -> WebauthnAttestationType -> ShowS)
-> (WebauthnAttestationType -> String)
-> ([WebauthnAttestationType] -> ShowS)
-> Show WebauthnAttestationType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WebauthnAttestationType] -> ShowS
$cshowList :: [WebauthnAttestationType] -> ShowS
show :: WebauthnAttestationType -> String
$cshow :: WebauthnAttestationType -> String
showsPrec :: Int -> WebauthnAttestationType -> ShowS
$cshowsPrec :: Int -> WebauthnAttestationType -> ShowS
Show, (forall x.
WebauthnAttestationType -> Rep WebauthnAttestationType x)
-> (forall x.
Rep WebauthnAttestationType x -> WebauthnAttestationType)
-> Generic WebauthnAttestationType
forall x. Rep WebauthnAttestationType x -> WebauthnAttestationType
forall x. WebauthnAttestationType -> Rep WebauthnAttestationType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WebauthnAttestationType x -> WebauthnAttestationType
$cfrom :: forall x. WebauthnAttestationType -> Rep WebauthnAttestationType x
Generic, [WebauthnAttestationType] -> Encoding
[WebauthnAttestationType] -> Value
WebauthnAttestationType -> Encoding
WebauthnAttestationType -> Value
(WebauthnAttestationType -> Value)
-> (WebauthnAttestationType -> Encoding)
-> ([WebauthnAttestationType] -> Value)
-> ([WebauthnAttestationType] -> Encoding)
-> ToJSON WebauthnAttestationType
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [WebauthnAttestationType] -> Encoding
$ctoEncodingList :: [WebauthnAttestationType] -> Encoding
toJSONList :: [WebauthnAttestationType] -> Value
$ctoJSONList :: [WebauthnAttestationType] -> Value
toEncoding :: WebauthnAttestationType -> Encoding
$ctoEncoding :: WebauthnAttestationType -> Encoding
toJSON :: WebauthnAttestationType -> Value
$ctoJSON :: WebauthnAttestationType -> Value
ToJSON)