From 8a2300e1b598000b1fc3e00e852ec383e5d14bb4 Mon Sep 17 00:00:00 2001 From: Michael Peyton Jones Date: Wed, 6 Apr 2022 15:48:59 +0100 Subject: [PATCH] Fix the type of signatures in metadata Signatures are actually complex objects. We could use `Value` here since it's unlikely that any consumers care about this, but it's cheap enough to just define a structure for the signature objects. In practice this isn't an issue because it seems like this field is never populated in Hackage, but it can be populated if you build a custom Hackage it can happen. Fixes #16. --- src/Distribution/Hackage/DB/MetaData.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Distribution/Hackage/DB/MetaData.hs b/src/Distribution/Hackage/DB/MetaData.hs index 956406a..8801884 100644 --- a/src/Distribution/Hackage/DB/MetaData.hs +++ b/src/Distribution/Hackage/DB/MetaData.hs @@ -35,7 +35,7 @@ parseMetaData :: ByteString -> MetaData parseMetaData = either (throw . InvalidMetaFile) id . eitherDecode data MetaData = MetaData { signed :: SignedMetaData - , signatures :: [String] + , signatures :: [Signature] } deriving (Show, Generic) @@ -56,3 +56,10 @@ data TargetData = TargetData { length :: Int deriving (Show, Generic) instance FromJSON TargetData + +data Signature = Signature { keyid :: String + , method :: String + , sig :: String } + deriving (Show, Generic) + +instance FromJSON Signature