hackage-security-0.6.0.1: Hackage security library

Safe HaskellNone
LanguageHaskell2010

Hackage.Security.JSON

Contents

Description

Hackage-specific wrappers around the Util.JSON module

Synopsis

Deserialization errors

data DeserializationError Source #

Constructors

DeserializationErrorMalformed String

Malformed JSON has syntax errors in the JSON itself (i.e., we cannot even parse it to a JSValue)

DeserializationErrorSchema String

Invalid JSON has valid syntax but invalid structure

The string gives a hint about what we expected instead

DeserializationErrorUnknownKey KeyId

The JSON file contains a key ID of an unknown key

DeserializationErrorValidation String

Some verification step failed

DeserializationErrorFileType String String

Wrong file type

Records actual and expected types.

Instances
Show DeserializationError Source # 
Instance details

Defined in Hackage.Security.JSON

Exception DeserializationError Source # 
Instance details

Defined in Hackage.Security.JSON

Pretty DeserializationError Source # 
Instance details

Defined in Hackage.Security.JSON

MonadError DeserializationError ReadJSON_NoKeys_NoLayout Source # 
Instance details

Defined in Hackage.Security.JSON

MonadError DeserializationError ReadJSON_Keys_NoLayout Source # 
Instance details

Defined in Hackage.Security.JSON

MonadError DeserializationError ReadJSON_Keys_Layout Source # 
Instance details

Defined in Hackage.Security.JSON

MonadKeys

addKeys :: MonadKeys m => KeyEnv -> m a -> m a Source #

withKeys :: MonadKeys m => KeyEnv -> m a -> m a Source #

Reader monads

data ReadJSON_Keys_Layout a Source #

Instances
Monad ReadJSON_Keys_Layout Source # 
Instance details

Defined in Hackage.Security.JSON

Functor ReadJSON_Keys_Layout Source # 
Instance details

Defined in Hackage.Security.JSON

Applicative ReadJSON_Keys_Layout Source # 
Instance details

Defined in Hackage.Security.JSON

ReportSchemaErrors ReadJSON_Keys_Layout Source # 
Instance details

Defined in Hackage.Security.JSON

MonadKeys ReadJSON_Keys_Layout Source # 
Instance details

Defined in Hackage.Security.JSON

MonadReader RepoLayout ReadJSON_Keys_Layout Source # 
Instance details

Defined in Hackage.Security.JSON

MonadError DeserializationError ReadJSON_Keys_Layout Source # 
Instance details

Defined in Hackage.Security.JSON

data ReadJSON_Keys_NoLayout a Source #

Instances
Monad ReadJSON_Keys_NoLayout Source # 
Instance details

Defined in Hackage.Security.JSON

Functor ReadJSON_Keys_NoLayout Source # 
Instance details

Defined in Hackage.Security.JSON

Applicative ReadJSON_Keys_NoLayout Source # 
Instance details

Defined in Hackage.Security.JSON

ReportSchemaErrors ReadJSON_Keys_NoLayout Source # 
Instance details

Defined in Hackage.Security.JSON

MonadKeys ReadJSON_Keys_NoLayout Source # 
Instance details

Defined in Hackage.Security.JSON

MonadError DeserializationError ReadJSON_Keys_NoLayout Source # 
Instance details

Defined in Hackage.Security.JSON

data ReadJSON_NoKeys_NoLayout a Source #

Instances
Monad ReadJSON_NoKeys_NoLayout Source # 
Instance details

Defined in Hackage.Security.JSON

Functor ReadJSON_NoKeys_NoLayout Source # 
Instance details

Defined in Hackage.Security.JSON

Applicative ReadJSON_NoKeys_NoLayout Source # 
Instance details

Defined in Hackage.Security.JSON

ReportSchemaErrors ReadJSON_NoKeys_NoLayout Source # 
Instance details

Defined in Hackage.Security.JSON

MonadError DeserializationError ReadJSON_NoKeys_NoLayout Source # 
Instance details

Defined in Hackage.Security.JSON

Utility

Writing

data WriteJSON a Source #

Instances
Monad WriteJSON Source # 
Instance details

Defined in Hackage.Security.JSON

Methods

(>>=) :: WriteJSON a -> (a -> WriteJSON b) -> WriteJSON b #

(>>) :: WriteJSON a -> WriteJSON b -> WriteJSON b #

return :: a -> WriteJSON a #

fail :: String -> WriteJSON a #

Functor WriteJSON Source # 
Instance details

Defined in Hackage.Security.JSON

Methods

fmap :: (a -> b) -> WriteJSON a -> WriteJSON b #

(<$) :: a -> WriteJSON b -> WriteJSON a #

Applicative WriteJSON Source # 
Instance details

Defined in Hackage.Security.JSON

Methods

pure :: a -> WriteJSON a #

(<*>) :: WriteJSON (a -> b) -> WriteJSON a -> WriteJSON b #

liftA2 :: (a -> b -> c) -> WriteJSON a -> WriteJSON b -> WriteJSON c #

(*>) :: WriteJSON a -> WriteJSON b -> WriteJSON b #

(<*) :: WriteJSON a -> WriteJSON b -> WriteJSON a #

MonadReader RepoLayout WriteJSON Source # 
Instance details

Defined in Hackage.Security.JSON

Utility

renderJSON :: ToJSON WriteJSON a => RepoLayout -> a -> ByteString Source #

Render to canonical JSON format

renderJSON_NoLayout :: ToJSON Identity a => a -> ByteString Source #

Variation on renderJSON for files that don't require the repo layout

Re-exports

Type classes

class ToJSON m a where Source #

Methods

toJSON :: a -> m JSValue Source #

Instances
Monad m => ToJSON m URI Source # 
Instance details

Defined in Hackage.Security.Util.JSON

Methods

toJSON :: URI -> m JSValue Source #

Monad m => ToJSON m UTCTime Source # 
Instance details

Defined in Hackage.Security.Util.JSON

Methods

toJSON :: UTCTime -> m JSValue Source #

Monad m => ToJSON m Int54 Source # 
Instance details

Defined in Hackage.Security.Util.JSON

Methods

toJSON :: Int54 -> m JSValue Source #

Monad m => ToJSON m String Source # 
Instance details

Defined in Hackage.Security.Util.JSON

Methods

toJSON :: String -> m JSValue Source #

Monad m => ToJSON m JSValue Source # 
Instance details

Defined in Hackage.Security.Util.JSON

Methods

toJSON :: JSValue -> m JSValue Source #

Monad m => ToJSON m KeyEnv Source # 
Instance details

Defined in Hackage.Security.Key.Env

Methods

toJSON :: KeyEnv -> m JSValue Source #

Monad m => ToJSON m PreSignature Source # 
Instance details

Defined in Hackage.Security.TUF.Signed

Monad m => ToJSON m Signatures Source # 
Instance details

Defined in Hackage.Security.TUF.Signed

Monad m => ToJSON m FileExpires Source # 
Instance details

Defined in Hackage.Security.TUF.Header

Monad m => ToJSON m FileVersion Source # 
Instance details

Defined in Hackage.Security.TUF.Header

Monad m => ToJSON m Mirrors Source # 
Instance details

Defined in Hackage.Security.TUF.Mirrors

Methods

toJSON :: Mirrors -> m JSValue Source #

Monad m => ToJSON m Mirror Source # 
Instance details

Defined in Hackage.Security.TUF.Mirrors

Methods

toJSON :: Mirror -> m JSValue Source #

Monad m => ToJSON m Hash Source # 
Instance details

Defined in Hackage.Security.TUF.Common

Methods

toJSON :: Hash -> m JSValue Source #

Monad m => ToJSON m FileLength Source # 
Instance details

Defined in Hackage.Security.TUF.Common

Monad m => ToJSON m KeyThreshold Source # 
Instance details

Defined in Hackage.Security.TUF.Common

Monad m => ToJSON m FileInfo Source # 
Instance details

Defined in Hackage.Security.TUF.FileInfo

Methods

toJSON :: FileInfo -> m JSValue Source #

Monad m => ToJSON m FileMap Source # 
Instance details

Defined in Hackage.Security.TUF.FileMap

Methods

toJSON :: FileMap -> m JSValue Source #

MonadReader RepoLayout m => ToJSON m Timestamp Source # 
Instance details

Defined in Hackage.Security.TUF.Timestamp

Monad m => ToJSON m Targets Source # 
Instance details

Defined in Hackage.Security.TUF.Targets

Methods

toJSON :: Targets -> m JSValue Source #

Monad m => ToJSON m Delegations Source # 
Instance details

Defined in Hackage.Security.TUF.Targets

Monad m => ToJSON m DelegationSpec Source # 
Instance details

Defined in Hackage.Security.TUF.Targets

MonadReader RepoLayout m => ToJSON m Snapshot Source # 
Instance details

Defined in Hackage.Security.TUF.Snapshot

Methods

toJSON :: Snapshot -> m JSValue Source #

Monad m => ToJSON m Root Source # 
Instance details

Defined in Hackage.Security.TUF.Root

Methods

toJSON :: Root -> m JSValue Source #

Monad m => ToJSON m RootRoles Source # 
Instance details

Defined in Hackage.Security.TUF.Root

(Monad m, ToJSON m a) => ToJSON m [a] Source # 
Instance details

Defined in Hackage.Security.Util.JSON

Methods

toJSON :: [a] -> m JSValue Source #

Monad m => ToJSON m (KeyType typ) Source # 
Instance details

Defined in Hackage.Security.Key

Methods

toJSON :: KeyType typ -> m JSValue Source #

Monad m => ToJSON m (Some KeyType) Source # 
Instance details

Defined in Hackage.Security.Key

Monad m => ToJSON m (Some PublicKey) Source # 
Instance details

Defined in Hackage.Security.Key

Monad m => ToJSON m (Some Key) Source # 
Instance details

Defined in Hackage.Security.Key

Methods

toJSON :: Some Key -> m JSValue Source #

Monad m => ToJSON m (PublicKey typ) Source # 
Instance details

Defined in Hackage.Security.Key

Methods

toJSON :: PublicKey typ -> m JSValue Source #

Monad m => ToJSON m (Key typ) Source # 
Instance details

Defined in Hackage.Security.Key

Methods

toJSON :: Key typ -> m JSValue Source #

(Monad m, ToJSON m a) => ToJSON m (UninterpretedSignatures a) Source # 
Instance details

Defined in Hackage.Security.TUF.Signed

(Monad m, ToJSON m a) => ToJSON m (Signed a) Source # 
Instance details

Defined in Hackage.Security.TUF.Signed

Methods

toJSON :: Signed a -> m JSValue Source #

Monad m => ToJSON m (RoleSpec a) Source # 
Instance details

Defined in Hackage.Security.TUF.Root

Methods

toJSON :: RoleSpec a -> m JSValue Source #

(Monad m, ToObjectKey m k, ToJSON m a) => ToJSON m (Map k a) Source # 
Instance details

Defined in Hackage.Security.Util.JSON

Methods

toJSON :: Map k a -> m JSValue Source #

class FromJSON m a where Source #

Methods

fromJSON :: JSValue -> m a Source #

Instances
ReportSchemaErrors m => FromJSON m URI Source # 
Instance details

Defined in Hackage.Security.Util.JSON

Methods

fromJSON :: JSValue -> m URI Source #

ReportSchemaErrors m => FromJSON m UTCTime Source # 
Instance details

Defined in Hackage.Security.Util.JSON

ReportSchemaErrors m => FromJSON m Int54 Source # 
Instance details

Defined in Hackage.Security.Util.JSON

Methods

fromJSON :: JSValue -> m Int54 Source #

ReportSchemaErrors m => FromJSON m String Source # 
Instance details

Defined in Hackage.Security.Util.JSON

Methods

fromJSON :: JSValue -> m String Source #

Monad m => FromJSON m JSValue Source # 
Instance details

Defined in Hackage.Security.Util.JSON

ReportSchemaErrors m => FromJSON m KeyEnv Source # 
Instance details

Defined in Hackage.Security.Key.Env

Methods

fromJSON :: JSValue -> m KeyEnv Source #

ReportSchemaErrors m => FromJSON m PreSignature Source # 
Instance details

Defined in Hackage.Security.TUF.Signed

MonadKeys m => FromJSON m Signatures Source # 
Instance details

Defined in Hackage.Security.TUF.Signed

ReportSchemaErrors m => FromJSON m Header Source # 
Instance details

Defined in Hackage.Security.TUF.Header

Methods

fromJSON :: JSValue -> m Header Source #

ReportSchemaErrors m => FromJSON m FileExpires Source # 
Instance details

Defined in Hackage.Security.TUF.Header

ReportSchemaErrors m => FromJSON m FileVersion Source # 
Instance details

Defined in Hackage.Security.TUF.Header

(MonadError DeserializationError m, ReportSchemaErrors m) => FromJSON m Mirrors Source # 
Instance details

Defined in Hackage.Security.TUF.Mirrors

ReportSchemaErrors m => FromJSON m Mirror Source # 
Instance details

Defined in Hackage.Security.TUF.Mirrors

Methods

fromJSON :: JSValue -> m Mirror Source #

ReportSchemaErrors m => FromJSON m Hash Source # 
Instance details

Defined in Hackage.Security.TUF.Common

Methods

fromJSON :: JSValue -> m Hash Source #

ReportSchemaErrors m => FromJSON m FileLength Source # 
Instance details

Defined in Hackage.Security.TUF.Common

ReportSchemaErrors m => FromJSON m KeyThreshold Source # 
Instance details

Defined in Hackage.Security.TUF.Common

ReportSchemaErrors m => FromJSON m FileInfo Source # 
Instance details

Defined in Hackage.Security.TUF.FileInfo

ReportSchemaErrors m => FromJSON m FileMap Source # 
Instance details

Defined in Hackage.Security.TUF.FileMap

(MonadReader RepoLayout m, MonadError DeserializationError m, ReportSchemaErrors m) => FromJSON m Timestamp Source # 
Instance details

Defined in Hackage.Security.TUF.Timestamp

MonadKeys m => FromJSON m Targets Source # 
Instance details

Defined in Hackage.Security.TUF.Targets

MonadKeys m => FromJSON m Delegations Source # 
Instance details

Defined in Hackage.Security.TUF.Targets

MonadKeys m => FromJSON m DelegationSpec Source # 
Instance details

Defined in Hackage.Security.TUF.Targets

(MonadReader RepoLayout m, MonadError DeserializationError m, ReportSchemaErrors m) => FromJSON m Snapshot Source # 
Instance details

Defined in Hackage.Security.TUF.Snapshot

MonadKeys m => FromJSON m RootRoles Source # 
Instance details

Defined in Hackage.Security.TUF.Root

(ReportSchemaErrors m, FromJSON m a) => FromJSON m [a] Source # 
Instance details

Defined in Hackage.Security.Util.JSON

Methods

fromJSON :: JSValue -> m [a] Source #

ReportSchemaErrors m => FromJSON m (Some KeyType) Source # 
Instance details

Defined in Hackage.Security.Key

Methods

fromJSON :: JSValue -> m (Some KeyType) Source #

ReportSchemaErrors m => FromJSON m (Some PublicKey) Source # 
Instance details

Defined in Hackage.Security.Key

ReportSchemaErrors m => FromJSON m (Some Key) Source # 
Instance details

Defined in Hackage.Security.Key

Methods

fromJSON :: JSValue -> m (Some Key) Source #

(ReportSchemaErrors m, FromJSON m a) => FromJSON m (UninterpretedSignatures a) Source # 
Instance details

Defined in Hackage.Security.TUF.Signed

MonadKeys m => FromJSON m (Signed Mirrors) Source # 
Instance details

Defined in Hackage.Security.TUF.Mirrors

(MonadKeys m, MonadReader RepoLayout m) => FromJSON m (Signed Timestamp) Source # 
Instance details

Defined in Hackage.Security.TUF.Timestamp

MonadKeys m => FromJSON m (Signed Targets) Source # 
Instance details

Defined in Hackage.Security.TUF.Targets

(MonadKeys m, MonadReader RepoLayout m) => FromJSON m (Signed Snapshot) Source # 
Instance details

Defined in Hackage.Security.TUF.Snapshot

MonadKeys m => FromJSON m (RoleSpec a) Source # 
Instance details

Defined in Hackage.Security.TUF.Root

Methods

fromJSON :: JSValue -> m (RoleSpec a) Source #

MonadKeys m => FromJSON m (Signed Root) Source #

We give an instance for Signed Root rather than Root because the key environment from the root data is necessary to resolve the explicit sharing in the signatures.

Instance details

Defined in Hackage.Security.TUF.Root

Methods

fromJSON :: JSValue -> m (Signed Root) Source #

(ReportSchemaErrors m, Ord k, FromObjectKey m k, FromJSON m a) => FromJSON m (Map k a) Source # 
Instance details

Defined in Hackage.Security.Util.JSON

Methods

fromJSON :: JSValue -> m (Map k a) Source #

class ToObjectKey m a where Source #

Used in the ToJSON instance for Map

Methods

toObjectKey :: a -> m String Source #

Instances
Monad m => ToObjectKey m String Source # 
Instance details

Defined in Hackage.Security.Util.JSON

Monad m => ToObjectKey m KeyId Source # 
Instance details

Defined in Hackage.Security.Key

Monad m => ToObjectKey m HashFn Source # 
Instance details

Defined in Hackage.Security.TUF.FileInfo

Monad m => ToObjectKey m TargetPath Source # 
Instance details

Defined in Hackage.Security.TUF.FileMap

Monad m => ToObjectKey m (Path root) Source # 
Instance details

Defined in Hackage.Security.Util.JSON

Methods

toObjectKey :: Path root -> m String Source #

class FromObjectKey m a where Source #

Used in the FromJSON instance for Map

Methods

fromObjectKey :: String -> m (Maybe a) Source #

Instances
Monad m => FromObjectKey m String Source # 
Instance details

Defined in Hackage.Security.Util.JSON

Monad m => FromObjectKey m KeyId Source # 
Instance details

Defined in Hackage.Security.Key

ReportSchemaErrors m => FromObjectKey m HashFn Source # 
Instance details

Defined in Hackage.Security.TUF.FileInfo

ReportSchemaErrors m => FromObjectKey m TargetPath Source # 
Instance details

Defined in Hackage.Security.TUF.FileMap

Monad m => FromObjectKey m (Path root) Source # 
Instance details

Defined in Hackage.Security.Util.JSON

Methods

fromObjectKey :: String -> m (Maybe (Path root)) Source #

Utility

fromJSField :: (ReportSchemaErrors m, FromJSON m a) => JSValue -> String -> m a Source #

Extract a field from a JSON object

mkObject :: forall m. Monad m => [(String, m JSValue)] -> m JSValue Source #

Re-exports

data JSValue Source #

Instances
Eq JSValue Source # 
Instance details

Defined in Text.JSON.Canonical

Methods

(==) :: JSValue -> JSValue -> Bool #

(/=) :: JSValue -> JSValue -> Bool #

Ord JSValue Source # 
Instance details

Defined in Text.JSON.Canonical

Read JSValue Source # 
Instance details

Defined in Text.JSON.Canonical

Show JSValue Source # 
Instance details

Defined in Text.JSON.Canonical

Monad m => FromJSON m JSValue Source # 
Instance details

Defined in Hackage.Security.Util.JSON

Monad m => ToJSON m JSValue Source # 
Instance details

Defined in Hackage.Security.Util.JSON

Methods

toJSON :: JSValue -> m JSValue Source #

data Int54 Source #

54-bit integer values

JavaScript can only safely represent numbers between -(2^53 - 1) and 2^53 - 1.

TODO: Although we introduce the type here, we don't actually do any bounds checking and just inherit all type class instance from Int64. We should probably define fromInteger to do bounds checking, give different instances for type classes such as Bounded and FiniteBits, etc.

Instances
Bounded Int54 Source # 
Instance details

Defined in Text.JSON.Canonical

Enum Int54 Source # 
Instance details

Defined in Text.JSON.Canonical

Eq Int54 Source # 
Instance details

Defined in Text.JSON.Canonical

Methods

(==) :: Int54 -> Int54 -> Bool #

(/=) :: Int54 -> Int54 -> Bool #

Integral Int54 Source # 
Instance details

Defined in Text.JSON.Canonical

Data Int54 Source # 
Instance details

Defined in Text.JSON.Canonical

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Int54 -> c Int54 #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Int54 #

toConstr :: Int54 -> Constr #

dataTypeOf :: Int54 -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Int54) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Int54) #

gmapT :: (forall b. Data b => b -> b) -> Int54 -> Int54 #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Int54 -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Int54 -> r #

gmapQ :: (forall d. Data d => d -> u) -> Int54 -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Int54 -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Int54 -> m Int54 #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Int54 -> m Int54 #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Int54 -> m Int54 #

Num Int54 Source # 
Instance details

Defined in Text.JSON.Canonical

Ord Int54 Source # 
Instance details

Defined in Text.JSON.Canonical

Methods

compare :: Int54 -> Int54 -> Ordering #

(<) :: Int54 -> Int54 -> Bool #

(<=) :: Int54 -> Int54 -> Bool #

(>) :: Int54 -> Int54 -> Bool #

(>=) :: Int54 -> Int54 -> Bool #

max :: Int54 -> Int54 -> Int54 #

min :: Int54 -> Int54 -> Int54 #

Read Int54 Source # 
Instance details

Defined in Text.JSON.Canonical

Real Int54 Source # 
Instance details

Defined in Text.JSON.Canonical

Methods

toRational :: Int54 -> Rational #

Show Int54 Source # 
Instance details

Defined in Text.JSON.Canonical

Methods

showsPrec :: Int -> Int54 -> ShowS #

show :: Int54 -> String #

showList :: [Int54] -> ShowS #

Ix Int54 Source # 
Instance details

Defined in Text.JSON.Canonical

PrintfArg Int54 Source # 
Instance details

Defined in Text.JSON.Canonical

Storable Int54 Source # 
Instance details

Defined in Text.JSON.Canonical

Methods

sizeOf :: Int54 -> Int #

alignment :: Int54 -> Int #

peekElemOff :: Ptr Int54 -> Int -> IO Int54 #

pokeElemOff :: Ptr Int54 -> Int -> Int54 -> IO () #

peekByteOff :: Ptr b -> Int -> IO Int54 #

pokeByteOff :: Ptr b -> Int -> Int54 -> IO () #

peek :: Ptr Int54 -> IO Int54 #

poke :: Ptr Int54 -> Int54 -> IO () #

Bits Int54 Source # 
Instance details

Defined in Text.JSON.Canonical

FiniteBits Int54 Source # 
Instance details

Defined in Text.JSON.Canonical

ReportSchemaErrors m => FromJSON m Int54 Source # 
Instance details

Defined in Hackage.Security.Util.JSON

Methods

fromJSON :: JSValue -> m Int54 Source #

Monad m => ToJSON m Int54 Source # 
Instance details

Defined in Hackage.Security.Util.JSON

Methods

toJSON :: Int54 -> m JSValue Source #