From 4fc681f78b2e659d3db3da99fe7c640416fb3b43 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 15 Sep 2016 00:26:33 -0400 Subject: Change format of ~/.keysafe/backup.log Allow deserializing SecretKeySource so we can later know what gpg keys are backed up. Converted KeyId to Text as JSON can't handle ByteString. --- Types.hs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'Types.hs') diff --git a/Types.hs b/Types.hs index 2ab5d6c..c065da3 100644 --- a/Types.hs +++ b/Types.hs @@ -9,9 +9,11 @@ module Types where import Types.Cost import qualified Data.ByteString as B +import qualified Data.Text as T import Data.String import Control.DeepSeq import GHC.Generics (Generic) +import Data.Aeson -- | keysafe stores secret keys. newtype SecretKey = SecretKey B.ByteString @@ -53,11 +55,17 @@ newtype Name = Name B.ByteString -- | Source of the secret key stored in keysafe. data SecretKeySource = GpgKey KeyId | KeyFile FilePath - deriving (Show) + deriving (Show, Generic) + +instance ToJSON SecretKeySource +instance FromJSON SecretKeySource -- | The keyid is any value that is unique to a private key, and can be -- looked up somehow without knowing the private key. -- -- A gpg keyid is the obvious example. -data KeyId = KeyId B.ByteString - deriving (Show) +data KeyId = KeyId T.Text + deriving (Show, Generic) + +instance ToJSON KeyId +instance FromJSON KeyId -- cgit v1.2.3