{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
module Crypto.WebAuthn.Metadata.Service.Types
( MetadataServiceRegistry (..),
MetadataPayload (..),
MetadataEntry (..),
SomeMetadataEntry (..),
StatusReport (..),
)
where
import qualified Crypto.WebAuthn.Metadata.Service.WebIDL as ServiceIDL
import Crypto.WebAuthn.Metadata.Statement.Types (MetadataStatement)
import qualified Crypto.WebAuthn.Model as M
import Crypto.WebAuthn.Model.Identifier (AAGUID, AuthenticatorIdentifier, SubjectKeyIdentifier)
import Data.Aeson (ToJSON)
import Data.HashMap.Strict (HashMap)
import Data.Hourglass (Date)
import Data.List.NonEmpty (NonEmpty)
import Data.Singletons (SingI)
import Data.Text (Text)
import Data.Word (Word32)
import qualified Data.X509 as X509
import GHC.Generics (Generic)
data MetadataServiceRegistry = MetadataServiceRegistry
{ MetadataServiceRegistry -> HashMap AAGUID (MetadataEntry 'Fido2)
fido2Entries :: HashMap AAGUID (MetadataEntry 'M.Fido2),
MetadataServiceRegistry
-> HashMap SubjectKeyIdentifier (MetadataEntry 'FidoU2F)
fidoU2FEntries :: HashMap SubjectKeyIdentifier (MetadataEntry 'M.FidoU2F)
}
instance Semigroup MetadataServiceRegistry where
MetadataServiceRegistry HashMap AAGUID (MetadataEntry 'Fido2)
l2 HashMap SubjectKeyIdentifier (MetadataEntry 'FidoU2F)
lu2f <> :: MetadataServiceRegistry
-> MetadataServiceRegistry -> MetadataServiceRegistry
<> MetadataServiceRegistry HashMap AAGUID (MetadataEntry 'Fido2)
r2 HashMap SubjectKeyIdentifier (MetadataEntry 'FidoU2F)
ru2f =
HashMap AAGUID (MetadataEntry 'Fido2)
-> HashMap SubjectKeyIdentifier (MetadataEntry 'FidoU2F)
-> MetadataServiceRegistry
MetadataServiceRegistry (HashMap AAGUID (MetadataEntry 'Fido2)
l2 HashMap AAGUID (MetadataEntry 'Fido2)
-> HashMap AAGUID (MetadataEntry 'Fido2)
-> HashMap AAGUID (MetadataEntry 'Fido2)
forall a. Semigroup a => a -> a -> a
<> HashMap AAGUID (MetadataEntry 'Fido2)
r2) (HashMap SubjectKeyIdentifier (MetadataEntry 'FidoU2F)
lu2f HashMap SubjectKeyIdentifier (MetadataEntry 'FidoU2F)
-> HashMap SubjectKeyIdentifier (MetadataEntry 'FidoU2F)
-> HashMap SubjectKeyIdentifier (MetadataEntry 'FidoU2F)
forall a. Semigroup a => a -> a -> a
<> HashMap SubjectKeyIdentifier (MetadataEntry 'FidoU2F)
ru2f)
instance Monoid MetadataServiceRegistry where
mempty :: MetadataServiceRegistry
mempty = HashMap AAGUID (MetadataEntry 'Fido2)
-> HashMap SubjectKeyIdentifier (MetadataEntry 'FidoU2F)
-> MetadataServiceRegistry
MetadataServiceRegistry HashMap AAGUID (MetadataEntry 'Fido2)
forall a. Monoid a => a
mempty HashMap SubjectKeyIdentifier (MetadataEntry 'FidoU2F)
forall a. Monoid a => a
mempty
data MetadataPayload = MetadataPayload
{
:: Maybe Text,
MetadataPayload -> Int
mpNo :: Int,
MetadataPayload -> Date
mpNextUpdate :: Date,
MetadataPayload -> [SomeMetadataEntry]
mpEntries :: [SomeMetadataEntry]
}
data MetadataEntry (p :: M.ProtocolKind) = MetadataEntry
{
MetadataEntry p -> Maybe (MetadataStatement p)
meMetadataStatement :: Maybe (MetadataStatement p),
MetadataEntry p -> NonEmpty StatusReport
meStatusReports :: NonEmpty StatusReport,
MetadataEntry p -> Date
meTimeOfLastStatusChange :: Date
}
deriving (MetadataEntry p -> MetadataEntry p -> Bool
(MetadataEntry p -> MetadataEntry p -> Bool)
-> (MetadataEntry p -> MetadataEntry p -> Bool)
-> Eq (MetadataEntry p)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall (p :: ProtocolKind).
MetadataEntry p -> MetadataEntry p -> Bool
/= :: MetadataEntry p -> MetadataEntry p -> Bool
$c/= :: forall (p :: ProtocolKind).
MetadataEntry p -> MetadataEntry p -> Bool
== :: MetadataEntry p -> MetadataEntry p -> Bool
$c== :: forall (p :: ProtocolKind).
MetadataEntry p -> MetadataEntry p -> Bool
Eq, Int -> MetadataEntry p -> ShowS
[MetadataEntry p] -> ShowS
MetadataEntry p -> String
(Int -> MetadataEntry p -> ShowS)
-> (MetadataEntry p -> String)
-> ([MetadataEntry p] -> ShowS)
-> Show (MetadataEntry p)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall (p :: ProtocolKind). Int -> MetadataEntry p -> ShowS
forall (p :: ProtocolKind). [MetadataEntry p] -> ShowS
forall (p :: ProtocolKind). MetadataEntry p -> String
showList :: [MetadataEntry p] -> ShowS
$cshowList :: forall (p :: ProtocolKind). [MetadataEntry p] -> ShowS
show :: MetadataEntry p -> String
$cshow :: forall (p :: ProtocolKind). MetadataEntry p -> String
showsPrec :: Int -> MetadataEntry p -> ShowS
$cshowsPrec :: forall (p :: ProtocolKind). Int -> MetadataEntry p -> ShowS
Show, (forall x. MetadataEntry p -> Rep (MetadataEntry p) x)
-> (forall x. Rep (MetadataEntry p) x -> MetadataEntry p)
-> Generic (MetadataEntry p)
forall x. Rep (MetadataEntry p) x -> MetadataEntry p
forall x. MetadataEntry p -> Rep (MetadataEntry p) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (p :: ProtocolKind) x.
Rep (MetadataEntry p) x -> MetadataEntry p
forall (p :: ProtocolKind) x.
MetadataEntry p -> Rep (MetadataEntry p) x
$cto :: forall (p :: ProtocolKind) x.
Rep (MetadataEntry p) x -> MetadataEntry p
$cfrom :: forall (p :: ProtocolKind) x.
MetadataEntry p -> Rep (MetadataEntry p) x
Generic, [MetadataEntry p] -> Encoding
[MetadataEntry p] -> Value
MetadataEntry p -> Encoding
MetadataEntry p -> Value
(MetadataEntry p -> Value)
-> (MetadataEntry p -> Encoding)
-> ([MetadataEntry p] -> Value)
-> ([MetadataEntry p] -> Encoding)
-> ToJSON (MetadataEntry p)
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
forall (p :: ProtocolKind). [MetadataEntry p] -> Encoding
forall (p :: ProtocolKind). [MetadataEntry p] -> Value
forall (p :: ProtocolKind). MetadataEntry p -> Encoding
forall (p :: ProtocolKind). MetadataEntry p -> Value
toEncodingList :: [MetadataEntry p] -> Encoding
$ctoEncodingList :: forall (p :: ProtocolKind). [MetadataEntry p] -> Encoding
toJSONList :: [MetadataEntry p] -> Value
$ctoJSONList :: forall (p :: ProtocolKind). [MetadataEntry p] -> Value
toEncoding :: MetadataEntry p -> Encoding
$ctoEncoding :: forall (p :: ProtocolKind). MetadataEntry p -> Encoding
toJSON :: MetadataEntry p -> Value
$ctoJSON :: forall (p :: ProtocolKind). MetadataEntry p -> Value
ToJSON)
data SomeMetadataEntry = forall p. SingI p => SomeMetadataEntry (AuthenticatorIdentifier p) (MetadataEntry p)
data StatusReport = StatusReport
{
StatusReport -> AuthenticatorStatus
srStatus :: ServiceIDL.AuthenticatorStatus,
StatusReport -> Maybe Date
srEffectiveDate :: Maybe Date,
StatusReport -> Maybe Word32
srAuthenticatorVersion :: Maybe Word32,
StatusReport -> Maybe SignedCertificate
srCertificate :: Maybe X509.SignedCertificate,
StatusReport -> Maybe Text
srUrl :: Maybe Text,
StatusReport -> Maybe Text
srCertificationDescriptor :: Maybe Text,
StatusReport -> Maybe Text
srCertificateNumber :: Maybe Text,
StatusReport -> Maybe Text
srCertificationPolicyVersion :: Maybe Text,
StatusReport -> Maybe Text
srCertificationRequirementsVersion :: Maybe Text
}
deriving (StatusReport -> StatusReport -> Bool
(StatusReport -> StatusReport -> Bool)
-> (StatusReport -> StatusReport -> Bool) -> Eq StatusReport
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StatusReport -> StatusReport -> Bool
$c/= :: StatusReport -> StatusReport -> Bool
== :: StatusReport -> StatusReport -> Bool
$c== :: StatusReport -> StatusReport -> Bool
Eq, Int -> StatusReport -> ShowS
[StatusReport] -> ShowS
StatusReport -> String
(Int -> StatusReport -> ShowS)
-> (StatusReport -> String)
-> ([StatusReport] -> ShowS)
-> Show StatusReport
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StatusReport] -> ShowS
$cshowList :: [StatusReport] -> ShowS
show :: StatusReport -> String
$cshow :: StatusReport -> String
showsPrec :: Int -> StatusReport -> ShowS
$cshowsPrec :: Int -> StatusReport -> ShowS
Show, (forall x. StatusReport -> Rep StatusReport x)
-> (forall x. Rep StatusReport x -> StatusReport)
-> Generic StatusReport
forall x. Rep StatusReport x -> StatusReport
forall x. StatusReport -> Rep StatusReport x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StatusReport x -> StatusReport
$cfrom :: forall x. StatusReport -> Rep StatusReport x
Generic, [StatusReport] -> Encoding
[StatusReport] -> Value
StatusReport -> Encoding
StatusReport -> Value
(StatusReport -> Value)
-> (StatusReport -> Encoding)
-> ([StatusReport] -> Value)
-> ([StatusReport] -> Encoding)
-> ToJSON StatusReport
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [StatusReport] -> Encoding
$ctoEncodingList :: [StatusReport] -> Encoding
toJSONList :: [StatusReport] -> Value
$ctoJSONList :: [StatusReport] -> Value
toEncoding :: StatusReport -> Encoding
$ctoEncoding :: StatusReport -> Encoding
toJSON :: StatusReport -> Value
$ctoJSON :: StatusReport -> Value
ToJSON)