hackage-security-0.6.3.2: Hackage security library

Safe Haskell | None
Language | Haskell2010

Hackage.Security.JSON

Contents

- Deserialization errors
- MonadKeys
- Reader monads
  - Utility
- Writing
  - Utility
- Re-exports

Description

Hackage-specific wrappers around the Util.JSON module

Synopsis

- data DeserializationError
  - = DeserializationErrorMalformed String
  - | DeserializationErrorSchema String
  - | DeserializationErrorUnknownKey KeyId
  - | DeserializationErrorValidation String
  - | DeserializationErrorFileType String String
- validate :: MonadError DeserializationError m => String -> Bool -> m ()
- verifyType :: (ReportSchemaErrors m, MonadError DeserializationError m) => JSValue -> String -> m ()
- class (ReportSchemaErrors m, MonadError DeserializationError m) => MonadKeys (m :: Type -> Type) where
  - localKeys :: (KeyEnv -> KeyEnv) -> m a -> m a
  - askKeys :: m KeyEnv
- addKeys :: MonadKeys m => KeyEnv -> m a -> m a
- withKeys :: MonadKeys m => KeyEnv -> m a -> m a
- lookupKey :: MonadKeys m => KeyId -> m (Some PublicKey)
- readKeyAsId :: MonadKeys m => JSValue -> m (Some PublicKey)
- data ReadJSON_Keys_Layout a
- data ReadJSON_Keys_NoLayout a
- data ReadJSON_NoKeys_NoLayout a
- runReadJSON_Keys_Layout :: KeyEnv -> RepoLayout -> ReadJSON_Keys_Layout a -> Either DeserializationError a
- runReadJSON_Keys_NoLayout :: KeyEnv -> ReadJSON_Keys_NoLayout a -> Either DeserializationError a
- runReadJSON_NoKeys_NoLayout :: ReadJSON_NoKeys_NoLayout a -> Either DeserializationError a
- parseJSON_Keys_Layout :: FromJSON ReadJSON_Keys_Layout a => KeyEnv -> RepoLayout -> ByteString -> Either DeserializationError a
- parseJSON_Keys_NoLayout :: FromJSON ReadJSON_Keys_NoLayout a => KeyEnv -> ByteString -> Either DeserializationError a
- parseJSON_NoKeys_NoLayout :: FromJSON ReadJSON_NoKeys_NoLayout a => ByteString -> Either DeserializationError a
- readJSON_Keys_Layout :: (FsRoot root, FromJSON ReadJSON_Keys_Layout a) => KeyEnv -> RepoLayout -> Path root -> IO (Either DeserializationError a)
- readJSON_Keys_NoLayout :: (FsRoot root, FromJSON ReadJSON_Keys_NoLayout a) => KeyEnv -> Path root -> IO (Either DeserializationError a)
- readJSON_NoKeys_NoLayout :: (FsRoot root, FromJSON ReadJSON_NoKeys_NoLayout a) => Path root -> IO (Either DeserializationError a)
- data WriteJSON a
- runWriteJSON :: RepoLayout -> WriteJSON a -> a
- renderJSON :: ToJSON WriteJSON a => RepoLayout -> a -> ByteString
- renderJSON_NoLayout :: ToJSON Identity a => a -> ByteString
- writeJSON :: ToJSON WriteJSON a => RepoLayout -> Path Absolute -> a -> IO ()
- writeJSON_NoLayout :: ToJSON Identity a => Path Absolute -> a -> IO ()
- writeKeyAsId :: Some PublicKey -> JSValue
- class ToJSON (m :: Type -> Type) a where
  - toJSON :: a -> m JSValue
- class FromJSON (m :: Type -> Type) a where
  - fromJSON :: JSValue -> m a
- data JSValue
  - = JSNull
  - | JSBool !Bool
  - | JSNum !Int54
  - | JSString String
  - | JSArray [JSValue]
  - | JSObject [(String, JSValue)]
- data Int54
- class ToObjectKey (m :: Type -> Type) a where
  - toObjectKey :: a -> m String
- class FromObjectKey (m :: Type -> Type) a where
  - fromObjectKey :: String -> m (Maybe a)
- class (Applicative m, Monad m) => ReportSchemaErrors (m :: Type -> Type) where
  - expected :: Expected -> Maybe Got -> m a
- type Expected = String
- type Got = String
- expected' :: ReportSchemaErrors m => Expected -> JSValue -> m a
- fromJSObject :: ReportSchemaErrors m => JSValue -> m [(String, JSValue)]
- fromJSField :: (ReportSchemaErrors m, FromJSON m a) => JSValue -> String -> m a
- fromJSOptField :: (ReportSchemaErrors m, FromJSON m a) => JSValue -> String -> m (Maybe a)
- mkObject :: Monad m => [(String, m JSValue)] -> m JSValue

# 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

Instances details

Exception DeserializationError Source # |
Instance details Defined in Hackage.Security.JSON Methods toException :: DeserializationError -> SomeException Source # fromException :: SomeException -> Maybe DeserializationError Source # displayException :: DeserializationError -> String Source # backtraceDesired :: DeserializationError -> Bool Source #
Show DeserializationError Source # |
Instance details Defined in Hackage.Security.JSON Methods showsPrec :: Int -> DeserializationError -> ShowS Source # show :: DeserializationError -> String Source # showList :: [DeserializationError] -> ShowS Source #
Pretty DeserializationError Source # |
Instance details Defined in Hackage.Security.JSON Methods pretty :: DeserializationError -> String Source #
MonadError DeserializationError ReadJSON_Keys_Layout Source # |
Instance details Defined in Hackage.Security.JSON Methods throwError :: DeserializationError -> ReadJSON_Keys_Layout a Source # catchError :: ReadJSON_Keys_Layout a -> (DeserializationError -> ReadJSON_Keys_Layout a) -> ReadJSON_Keys_Layout a Source #
MonadError DeserializationError ReadJSON_Keys_NoLayout Source # |
Instance details Defined in Hackage.Security.JSON Methods throwError :: DeserializationError -> ReadJSON_Keys_NoLayout a Source # catchError :: ReadJSON_Keys_NoLayout a -> (DeserializationError -> ReadJSON_Keys_NoLayout a) -> ReadJSON_Keys_NoLayout a Source #
MonadError DeserializationError ReadJSON_NoKeys_NoLayout Source # |
Instance details Defined in Hackage.Security.JSON Methods throwError :: DeserializationError -> ReadJSON_NoKeys_NoLayout a Source # catchError :: ReadJSON_NoKeys_NoLayout a -> (DeserializationError -> ReadJSON_NoKeys_NoLayout a) -> ReadJSON_NoKeys_NoLayout a Source #

validate :: MonadError DeserializationError m => String -> Bool -> m () Source #

verifyType :: (ReportSchemaErrors m, MonadError DeserializationError m) => JSValue -> String -> m () Source #

# MonadKeys

class (ReportSchemaErrors m, MonadError DeserializationError m) => MonadKeys (m :: Type -> Type) where Source #

MonadReader-like monad, specialized to key environments

Methods

localKeys :: (KeyEnv -> KeyEnv) -> m a -> m a Source #

askKeys :: m KeyEnv Source #

#### Instances

Instances details

MonadKeys ReadJSON_Keys_Layout Source # |
Instance details Defined in Hackage.Security.JSON Methods localKeys :: (KeyEnv -> KeyEnv) -> ReadJSON_Keys_Layout a -> ReadJSON_Keys_Layout a Source # askKeys :: ReadJSON_Keys_Layout KeyEnv Source #
MonadKeys ReadJSON_Keys_NoLayout Source # |
Instance details Defined in Hackage.Security.JSON Methods localKeys :: (KeyEnv -> KeyEnv) -> ReadJSON_Keys_NoLayout a -> ReadJSON_Keys_NoLayout a Source # askKeys :: ReadJSON_Keys_NoLayout KeyEnv Source #

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

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

lookupKey :: MonadKeys m => KeyId -> m (Some PublicKey) Source #

readKeyAsId :: MonadKeys m => JSValue -> m (Some PublicKey) Source #

# Reader monads

data ReadJSON_Keys_Layout a Source #

#### Instances

Instances details

Applicative ReadJSON_Keys_Layout Source # |

Instance details

Defined in Hackage.Security.JSON

Methods

pure :: a -> ReadJSON_Keys_Layout a Source #

(<*>) :: ReadJSON_Keys_Layout (a -> b) -> ReadJSON_Keys_Layout a -> ReadJSON_Keys_Layout b Source #

liftA2 :: (a -> b -> c) -> ReadJSON_Keys_Layout a -> ReadJSON_Keys_Layout b -> ReadJSON_Keys_Layout c Source #

(*>) :: ReadJSON_Keys_Layout a -> ReadJSON_Keys_Layout b -> ReadJSON_Keys_Layout b Source #

(<*) :: ReadJSON_Keys_Layout a -> ReadJSON_Keys_Layout b -> ReadJSON_Keys_Layout a Source #

Functor ReadJSON_Keys_Layout Source # |
Instance details Defined in Hackage.Security.JSON Methods fmap :: (a -> b) -> ReadJSON_Keys_Layout a -> ReadJSON_Keys_Layout b Source # (<$) :: a -> ReadJSON_Keys_Layout b -> ReadJSON_Keys_Layout a Source #
Monad ReadJSON_Keys_Layout Source # |
Instance details Defined in Hackage.Security.JSON Methods (>>=) :: ReadJSON_Keys_Layout a -> (a -> ReadJSON_Keys_Layout b) -> ReadJSON_Keys_Layout b Source # (>>) :: ReadJSON_Keys_Layout a -> ReadJSON_Keys_Layout b -> ReadJSON_Keys_Layout b Source # return :: a -> ReadJSON_Keys_Layout a Source #
MonadKeys ReadJSON_Keys_Layout Source # |
Instance details Defined in Hackage.Security.JSON Methods localKeys :: (KeyEnv -> KeyEnv) -> ReadJSON_Keys_Layout a -> ReadJSON_Keys_Layout a Source # askKeys :: ReadJSON_Keys_Layout KeyEnv Source #
ReportSchemaErrors ReadJSON_Keys_Layout Source # |
Instance details Defined in Hackage.Security.JSON Methods expected :: Expected -> Maybe Got -> ReadJSON_Keys_Layout a Source #
MonadError DeserializationError ReadJSON_Keys_Layout Source # |
Instance details Defined in Hackage.Security.JSON Methods throwError :: DeserializationError -> ReadJSON_Keys_Layout a Source # catchError :: ReadJSON_Keys_Layout a -> (DeserializationError -> ReadJSON_Keys_Layout a) -> ReadJSON_Keys_Layout a Source #
MonadReader RepoLayout ReadJSON_Keys_Layout Source # |
Instance details Defined in Hackage.Security.JSON Methods ask :: ReadJSON_Keys_Layout RepoLayout Source # local :: (RepoLayout -> RepoLayout) -> ReadJSON_Keys_Layout a -> ReadJSON_Keys_Layout a Source # reader :: (RepoLayout -> a) -> ReadJSON_Keys_Layout a Source #

data ReadJSON_Keys_NoLayout a Source #

#### Instances

Instances details

Applicative ReadJSON_Keys_NoLayout Source # |

Instance details

Defined in Hackage.Security.JSON

Methods

pure :: a -> ReadJSON_Keys_NoLayout a Source #

(<*>) :: ReadJSON_Keys_NoLayout (a -> b) -> ReadJSON_Keys_NoLayout a -> ReadJSON_Keys_NoLayout b Source #

liftA2 :: (a -> b -> c) -> ReadJSON_Keys_NoLayout a -> ReadJSON_Keys_NoLayout b -> ReadJSON_Keys_NoLayout c Source #

(*>) :: ReadJSON_Keys_NoLayout a -> ReadJSON_Keys_NoLayout b -> ReadJSON_Keys_NoLayout b Source #

(<*) :: ReadJSON_Keys_NoLayout a -> ReadJSON_Keys_NoLayout b -> ReadJSON_Keys_NoLayout a Source #

Functor ReadJSON_Keys_NoLayout Source # |
Instance details Defined in Hackage.Security.JSON Methods fmap :: (a -> b) -> ReadJSON_Keys_NoLayout a -> ReadJSON_Keys_NoLayout b Source # (<$) :: a -> ReadJSON_Keys_NoLayout b -> ReadJSON_Keys_NoLayout a Source #
Monad ReadJSON_Keys_NoLayout Source # |
Instance details Defined in Hackage.Security.JSON Methods (>>=) :: ReadJSON_Keys_NoLayout a -> (a -> ReadJSON_Keys_NoLayout b) -> ReadJSON_Keys_NoLayout b Source # (>>) :: ReadJSON_Keys_NoLayout a -> ReadJSON_Keys_NoLayout b -> ReadJSON_Keys_NoLayout b Source # return :: a -> ReadJSON_Keys_NoLayout a Source #
MonadKeys ReadJSON_Keys_NoLayout Source # |
Instance details Defined in Hackage.Security.JSON Methods localKeys :: (KeyEnv -> KeyEnv) -> ReadJSON_Keys_NoLayout a -> ReadJSON_Keys_NoLayout a Source # askKeys :: ReadJSON_Keys_NoLayout KeyEnv Source #
ReportSchemaErrors ReadJSON_Keys_NoLayout Source # |
Instance details Defined in Hackage.Security.JSON Methods expected :: Expected -> Maybe Got -> ReadJSON_Keys_NoLayout a Source #
MonadError DeserializationError ReadJSON_Keys_NoLayout Source # |
Instance details Defined in Hackage.Security.JSON Methods throwError :: DeserializationError -> ReadJSON_Keys_NoLayout a Source # catchError :: ReadJSON_Keys_NoLayout a -> (DeserializationError -> ReadJSON_Keys_NoLayout a) -> ReadJSON_Keys_NoLayout a Source #

data ReadJSON_NoKeys_NoLayout a Source #

#### Instances

Instances details

Applicative ReadJSON_NoKeys_NoLayout Source # |

Instance details

Defined in Hackage.Security.JSON

Methods

pure :: a -> ReadJSON_NoKeys_NoLayout a Source #

(<*>) :: ReadJSON_NoKeys_NoLayout (a -> b) -> ReadJSON_NoKeys_NoLayout a -> ReadJSON_NoKeys_NoLayout b Source #

liftA2 :: (a -> b -> c) -> ReadJSON_NoKeys_NoLayout a -> ReadJSON_NoKeys_NoLayout b -> ReadJSON_NoKeys_NoLayout c Source #

(*>) :: ReadJSON_NoKeys_NoLayout a -> ReadJSON_NoKeys_NoLayout b -> ReadJSON_NoKeys_NoLayout b Source #

(<*) :: ReadJSON_NoKeys_NoLayout a -> ReadJSON_NoKeys_NoLayout b -> ReadJSON_NoKeys_NoLayout a Source #

Functor ReadJSON_NoKeys_NoLayout Source # |
Instance details Defined in Hackage.Security.JSON Methods fmap :: (a -> b) -> ReadJSON_NoKeys_NoLayout a -> ReadJSON_NoKeys_NoLayout b Source # (<$) :: a -> ReadJSON_NoKeys_NoLayout b -> ReadJSON_NoKeys_NoLayout a Source #
Monad ReadJSON_NoKeys_NoLayout Source # |
Instance details Defined in Hackage.Security.JSON Methods (>>=) :: ReadJSON_NoKeys_NoLayout a -> (a -> ReadJSON_NoKeys_NoLayout b) -> ReadJSON_NoKeys_NoLayout b Source # (>>) :: ReadJSON_NoKeys_NoLayout a -> ReadJSON_NoKeys_NoLayout b -> ReadJSON_NoKeys_NoLayout b Source # return :: a -> ReadJSON_NoKeys_NoLayout a Source #
ReportSchemaErrors ReadJSON_NoKeys_NoLayout Source # |
Instance details Defined in Hackage.Security.JSON Methods expected :: Expected -> Maybe Got -> ReadJSON_NoKeys_NoLayout a Source #
MonadError DeserializationError ReadJSON_NoKeys_NoLayout Source # |
Instance details Defined in Hackage.Security.JSON Methods throwError :: DeserializationError -> ReadJSON_NoKeys_NoLayout a Source # catchError :: ReadJSON_NoKeys_NoLayout a -> (DeserializationError -> ReadJSON_NoKeys_NoLayout a) -> ReadJSON_NoKeys_NoLayout a Source #

runReadJSON_Keys_Layout :: KeyEnv -> RepoLayout -> ReadJSON_Keys_Layout a -> Either DeserializationError a Source #

runReadJSON_Keys_NoLayout :: KeyEnv -> ReadJSON_Keys_NoLayout a -> Either DeserializationError a Source #

runReadJSON_NoKeys_NoLayout :: ReadJSON_NoKeys_NoLayout a -> Either DeserializationError a Source #

## Utility

parseJSON_Keys_Layout :: FromJSON ReadJSON_Keys_Layout a => KeyEnv -> RepoLayout -> ByteString -> Either DeserializationError a Source #

parseJSON_Keys_NoLayout :: FromJSON ReadJSON_Keys_NoLayout a => KeyEnv -> ByteString -> Either DeserializationError a Source #

parseJSON_NoKeys_NoLayout :: FromJSON ReadJSON_NoKeys_NoLayout a => ByteString -> Either DeserializationError a Source #

readJSON_Keys_Layout :: (FsRoot root, FromJSON ReadJSON_Keys_Layout a) => KeyEnv -> RepoLayout -> Path root -> IO (Either DeserializationError a) Source #

readJSON_Keys_NoLayout :: (FsRoot root, FromJSON ReadJSON_Keys_NoLayout a) => KeyEnv -> Path root -> IO (Either DeserializationError a) Source #

readJSON_NoKeys_NoLayout :: (FsRoot root, FromJSON ReadJSON_NoKeys_NoLayout a) => Path root -> IO (Either DeserializationError a) Source #

# Writing

data WriteJSON a Source #

#### Instances

Instances details

Applicative WriteJSON Source # |
Instance details Defined in Hackage.Security.JSON Methods pure :: a -> WriteJSON a Source # (<*>) :: WriteJSON (a -> b) -> WriteJSON a -> WriteJSON b Source # liftA2 :: (a -> b -> c) -> WriteJSON a -> WriteJSON b -> WriteJSON c Source # (*>) :: WriteJSON a -> WriteJSON b -> WriteJSON b Source # (<*) :: WriteJSON a -> WriteJSON b -> WriteJSON a Source #
Functor WriteJSON Source # |
Instance details Defined in Hackage.Security.JSON Methods fmap :: (a -> b) -> WriteJSON a -> WriteJSON b Source # (<$) :: a -> WriteJSON b -> WriteJSON a Source #
Monad WriteJSON Source # |
Instance details Defined in Hackage.Security.JSON Methods (>>=) :: WriteJSON a -> (a -> WriteJSON b) -> WriteJSON b Source # (>>) :: WriteJSON a -> WriteJSON b -> WriteJSON b Source # return :: a -> WriteJSON a Source #
MonadReader RepoLayout WriteJSON Source # |
Instance details Defined in Hackage.Security.JSON Methods ask :: WriteJSON RepoLayout Source # local :: (RepoLayout -> RepoLayout) -> WriteJSON a -> WriteJSON a Source # reader :: (RepoLayout -> a) -> WriteJSON a Source #

runWriteJSON :: RepoLayout -> WriteJSON a -> a Source #

## 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

writeJSON :: ToJSON WriteJSON a => RepoLayout -> Path Absolute -> a -> IO () Source #

writeJSON_NoLayout :: ToJSON Identity a => Path Absolute -> a -> IO () Source #

writeKeyAsId :: Some PublicKey -> JSValue Source #

# Re-exports

class ToJSON (m :: Type -> Type) a where Source #

Methods

toJSON :: a -> m JSValue Source #

#### Instances

Instances details

Monad m => ToJSON m KeyEnv Source # |
Instance details Defined in Hackage.Security.Key.Env Methods toJSON :: KeyEnv -> m JSValue Source #
Monad m => ToJSON m FileLength Source # |
Instance details Defined in Hackage.Security.TUF.Common Methods toJSON :: FileLength -> 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 KeyThreshold Source # |
Instance details Defined in Hackage.Security.TUF.Common Methods toJSON :: KeyThreshold -> m JSValue Source #
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 #
Monad m => ToJSON m FileExpires Source # |
Instance details Defined in Hackage.Security.TUF.Header Methods toJSON :: FileExpires -> m JSValue Source #
Monad m => ToJSON m FileVersion Source # |
Instance details Defined in Hackage.Security.TUF.Header Methods toJSON :: FileVersion -> 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 Mirrors Source # |
Instance details Defined in Hackage.Security.TUF.Mirrors Methods toJSON :: Mirrors -> 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 Methods toJSON :: RootRoles -> m JSValue Source #
Monad m => ToJSON m PreSignature Source # |
Instance details Defined in Hackage.Security.TUF.Signed Methods toJSON :: PreSignature -> m JSValue Source #
Monad m => ToJSON m Signatures Source # |
Instance details Defined in Hackage.Security.TUF.Signed Methods toJSON :: Signatures -> m JSValue Source #
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 DelegationSpec Source # |
Instance details Defined in Hackage.Security.TUF.Targets Methods toJSON :: DelegationSpec -> m JSValue Source #
Monad m => ToJSON m Delegations Source # |
Instance details Defined in Hackage.Security.TUF.Targets Methods toJSON :: Delegations -> m JSValue Source #
Monad m => ToJSON m Targets Source # |
Instance details Defined in Hackage.Security.TUF.Targets Methods toJSON :: Targets -> m JSValue Source #
MonadReader RepoLayout m => ToJSON m Timestamp Source # |
Instance details Defined in Hackage.Security.TUF.Timestamp Methods toJSON :: Timestamp -> 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 JSValue Source # |
Instance details Defined in Hackage.Security.Util.JSON Methods toJSON :: JSValue -> m JSValue Source #
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 String Source # |
Instance details Defined in Hackage.Security.Util.JSON Methods toJSON :: String -> 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 (KeyType typ) Source # |
Instance details Defined in Hackage.Security.Key Methods toJSON :: KeyType typ -> 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 (RoleSpec a) Source # |
Instance details Defined in Hackage.Security.TUF.Root Methods toJSON :: RoleSpec a -> m JSValue Source #
(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 a) => ToJSON m (UninterpretedSignatures a) Source # |
Instance details Defined in Hackage.Security.TUF.Signed Methods toJSON :: UninterpretedSignatures a -> m JSValue Source #
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 (Some KeyType) Source # |
Instance details Defined in Hackage.Security.Key Methods toJSON :: Some KeyType -> m JSValue Source #
Monad m => ToJSON m (Some PublicKey) Source # |
Instance details Defined in Hackage.Security.Key Methods toJSON :: Some PublicKey -> m JSValue Source #
(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, 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 :: Type -> Type) a where Source #

Methods

fromJSON :: JSValue -> m a Source #

#### Instances

Instances details

ReportSchemaErrors m => FromJSON m KeyEnv Source # |
Instance details Defined in Hackage.Security.Key.Env Methods fromJSON :: JSValue -> m KeyEnv Source #
ReportSchemaErrors m => FromJSON m FileLength Source # |
Instance details Defined in Hackage.Security.TUF.Common Methods fromJSON :: JSValue -> m FileLength 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 KeyThreshold Source # |
Instance details Defined in Hackage.Security.TUF.Common Methods fromJSON :: JSValue -> m KeyThreshold Source #
ReportSchemaErrors m => FromJSON m FileInfo Source # |
Instance details Defined in Hackage.Security.TUF.FileInfo Methods fromJSON :: JSValue -> m FileInfo Source #
ReportSchemaErrors m => FromJSON m FileMap Source # |
Instance details Defined in Hackage.Security.TUF.FileMap Methods fromJSON :: JSValue -> m FileMap Source #
ReportSchemaErrors m => FromJSON m FileExpires Source # |
Instance details Defined in Hackage.Security.TUF.Header Methods fromJSON :: JSValue -> m FileExpires Source #
ReportSchemaErrors m => FromJSON m FileVersion Source # |
Instance details Defined in Hackage.Security.TUF.Header Methods fromJSON :: JSValue -> m FileVersion Source #
ReportSchemaErrors m => FromJSON m Header Source # |
Instance details Defined in Hackage.Security.TUF.Header Methods fromJSON :: JSValue -> m Header Source #
ReportSchemaErrors m => FromJSON m Mirror Source # |
Instance details Defined in Hackage.Security.TUF.Mirrors Methods fromJSON :: JSValue -> m Mirror Source #
(MonadError DeserializationError m, ReportSchemaErrors m) => FromJSON m Mirrors Source # |
Instance details Defined in Hackage.Security.TUF.Mirrors Methods fromJSON :: JSValue -> m Mirrors Source #
MonadKeys m => FromJSON m RootRoles Source # |
Instance details Defined in Hackage.Security.TUF.Root Methods fromJSON :: JSValue -> m RootRoles Source #
ReportSchemaErrors m => FromJSON m PreSignature Source # |
Instance details Defined in Hackage.Security.TUF.Signed Methods fromJSON :: JSValue -> m PreSignature Source #
MonadKeys m => FromJSON m Signatures Source # |
Instance details Defined in Hackage.Security.TUF.Signed Methods fromJSON :: JSValue -> m Signatures Source #
(MonadReader RepoLayout m, MonadError DeserializationError m, ReportSchemaErrors m) => FromJSON m Snapshot Source # |
Instance details Defined in Hackage.Security.TUF.Snapshot Methods fromJSON :: JSValue -> m Snapshot Source #
MonadKeys m => FromJSON m DelegationSpec Source # |
Instance details Defined in Hackage.Security.TUF.Targets Methods fromJSON :: JSValue -> m DelegationSpec Source #
MonadKeys m => FromJSON m Delegations Source # |
Instance details Defined in Hackage.Security.TUF.Targets Methods fromJSON :: JSValue -> m Delegations Source #
MonadKeys m => FromJSON m Targets Source # |
Instance details Defined in Hackage.Security.TUF.Targets Methods fromJSON :: JSValue -> m Targets Source #
(MonadReader RepoLayout m, MonadError DeserializationError m, ReportSchemaErrors m) => FromJSON m Timestamp Source # |
Instance details Defined in Hackage.Security.TUF.Timestamp Methods fromJSON :: JSValue -> m Timestamp Source #
ReportSchemaErrors m => FromJSON m Int54 Source # |
Instance details Defined in Hackage.Security.Util.JSON Methods fromJSON :: JSValue -> m Int54 Source #
Monad m => FromJSON m JSValue Source # |
Instance details Defined in Hackage.Security.Util.JSON Methods fromJSON :: JSValue -> m JSValue Source #
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 Methods fromJSON :: JSValue -> m UTCTime Source #
ReportSchemaErrors m => FromJSON m String Source # |
Instance details Defined in Hackage.Security.Util.JSON Methods fromJSON :: JSValue -> m String Source #
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 Mirrors) Source # |
Instance details Defined in Hackage.Security.TUF.Mirrors Methods fromJSON :: JSValue -> m (Signed Mirrors) 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 #
(MonadKeys m, MonadReader RepoLayout m) => FromJSON m (Signed Snapshot) Source # |
Instance details Defined in Hackage.Security.TUF.Snapshot Methods fromJSON :: JSValue -> m (Signed Snapshot) Source #
MonadKeys m => FromJSON m (Signed Targets) Source # |
Instance details Defined in Hackage.Security.TUF.Targets Methods fromJSON :: JSValue -> m (Signed Targets) Source #
(MonadKeys m, MonadReader RepoLayout m) => FromJSON m (Signed Timestamp) Source # |
Instance details Defined in Hackage.Security.TUF.Timestamp Methods fromJSON :: JSValue -> m (Signed Timestamp) Source #
(ReportSchemaErrors m, FromJSON m a) => FromJSON m (UninterpretedSignatures a) Source # |
Instance details Defined in Hackage.Security.TUF.Signed Methods fromJSON :: JSValue -> m (UninterpretedSignatures a) Source #
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 (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 Methods fromJSON :: JSValue -> m (Some PublicKey) Source #
(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, 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 #

data JSValue Source #

Constructors

JSNull |
JSBool !Bool |
JSNum !Int54 |
JSString String |
JSArray [JSValue] |
JSObject [(String, JSValue)] |

#### Instances

Instances details

Read JSValue Source # |
Instance details Defined in Text.JSON.Canonical Methods readsPrec :: Int -> ReadS JSValue Source # readList :: ReadS [JSValue] Source # readPrec :: ReadPrec JSValue Source # readListPrec :: ReadPrec [JSValue] Source #
Show JSValue Source # |
Instance details Defined in Text.JSON.Canonical Methods showsPrec :: Int -> JSValue -> ShowS Source # show :: JSValue -> String Source # showList :: [JSValue] -> ShowS Source #
Eq JSValue Source # |
Instance details Defined in Text.JSON.Canonical Methods (==) :: JSValue -> JSValue -> Bool Source # (/=) :: JSValue -> JSValue -> Bool Source #
Ord JSValue Source # |
Instance details Defined in Text.JSON.Canonical Methods compare :: JSValue -> JSValue -> Ordering Source # (<) :: JSValue -> JSValue -> Bool Source # (<=) :: JSValue -> JSValue -> Bool Source # (>) :: JSValue -> JSValue -> Bool Source # (>=) :: JSValue -> JSValue -> Bool Source # max :: JSValue -> JSValue -> JSValue Source # min :: JSValue -> JSValue -> JSValue Source #
Monad m => FromJSON m JSValue Source # |
Instance details Defined in Hackage.Security.Util.JSON Methods fromJSON :: JSValue -> m JSValue Source #
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

Instances details

PrintfArg Int54 Source # |
Instance details Defined in Text.JSON.Canonical Methods formatArg :: Int54 -> FieldFormatter Source # parseFormat :: Int54 -> ModifierParser Source #
Bits Int54 Source # |

Instance details

Defined in Text.JSON.Canonical

Methods

(.&.) :: Int54 -> Int54 -> Int54 Source #

(.|.) :: Int54 -> Int54 -> Int54 Source #

xor :: Int54 -> Int54 -> Int54 Source #

complement :: Int54 -> Int54 Source #

shift :: Int54 -> Int -> Int54 Source #

rotate :: Int54 -> Int -> Int54 Source #

zeroBits :: Int54 Source #

bit :: Int -> Int54 Source #

setBit :: Int54 -> Int -> Int54 Source #

clearBit :: Int54 -> Int -> Int54 Source #

complementBit :: Int54 -> Int -> Int54 Source #

testBit :: Int54 -> Int -> Bool Source #

bitSizeMaybe :: Int54 -> Maybe Int Source #

bitSize :: Int54 -> Int Source #

isSigned :: Int54 -> Bool Source #

shiftL :: Int54 -> Int -> Int54 Source #

unsafeShiftL :: Int54 -> Int -> Int54 Source #

shiftR :: Int54 -> Int -> Int54 Source #

unsafeShiftR :: Int54 -> Int -> Int54 Source #

rotateL :: Int54 -> Int -> Int54 Source #

rotateR :: Int54 -> Int -> Int54 Source #

popCount :: Int54 -> Int Source #

FiniteBits Int54 Source # |
Instance details Defined in Text.JSON.Canonical Methods finiteBitSize :: Int54 -> Int Source # countLeadingZeros :: Int54 -> Int Source # countTrailingZeros :: Int54 -> Int Source #
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 Source #

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

toConstr :: Int54 -> Constr Source #

dataTypeOf :: Int54 -> DataType Source #

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

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

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

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

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

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

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

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

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

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

Bounded Int54 Source # |
Instance details Defined in Text.JSON.Canonical Methods minBound :: Int54 Source # maxBound :: Int54 Source #
Enum Int54 Source # |
Instance details Defined in Text.JSON.Canonical Methods succ :: Int54 -> Int54 Source # pred :: Int54 -> Int54 Source # toEnum :: Int -> Int54 Source # fromEnum :: Int54 -> Int Source # enumFrom :: Int54 -> [Int54] Source # enumFromThen :: Int54 -> Int54 -> [Int54] Source # enumFromTo :: Int54 -> Int54 -> [Int54] Source # enumFromThenTo :: Int54 -> Int54 -> Int54 -> [Int54] Source #
Storable Int54 Source # |

Instance details

Defined in Text.JSON.Canonical

Methods

sizeOf :: Int54 -> Int Source #

alignment :: Int54 -> Int Source #

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

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

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

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

peek :: Ptr Int54 -> IO Int54 Source #

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

Ix Int54 Source # |
Instance details Defined in Text.JSON.Canonical Methods range :: (Int54, Int54) -> [Int54] Source # index :: (Int54, Int54) -> Int54 -> Int Source # unsafeIndex :: (Int54, Int54) -> Int54 -> Int Source # inRange :: (Int54, Int54) -> Int54 -> Bool Source # rangeSize :: (Int54, Int54) -> Int Source # unsafeRangeSize :: (Int54, Int54) -> Int Source #
Num Int54 Source # |
Instance details Defined in Text.JSON.Canonical Methods (+) :: Int54 -> Int54 -> Int54 Source # (-) :: Int54 -> Int54 -> Int54 Source # (*) :: Int54 -> Int54 -> Int54 Source # negate :: Int54 -> Int54 Source # abs :: Int54 -> Int54 Source # signum :: Int54 -> Int54 Source # fromInteger :: Integer -> Int54 Source #
Read Int54 Source # |
Instance details Defined in Text.JSON.Canonical Methods readsPrec :: Int -> ReadS Int54 Source # readList :: ReadS [Int54] Source # readPrec :: ReadPrec Int54 Source # readListPrec :: ReadPrec [Int54] Source #
Integral Int54 Source # |
Instance details Defined in Text.JSON.Canonical Methods quot :: Int54 -> Int54 -> Int54 Source # rem :: Int54 -> Int54 -> Int54 Source # div :: Int54 -> Int54 -> Int54 Source # mod :: Int54 -> Int54 -> Int54 Source # quotRem :: Int54 -> Int54 -> (Int54, Int54) Source # divMod :: Int54 -> Int54 -> (Int54, Int54) Source # toInteger :: Int54 -> Integer Source #
Real Int54 Source # |
Instance details Defined in Text.JSON.Canonical Methods toRational :: Int54 -> Rational Source #
Show Int54 Source # |
Instance details Defined in Text.JSON.Canonical Methods showsPrec :: Int -> Int54 -> ShowS Source # show :: Int54 -> String Source # showList :: [Int54] -> ShowS Source #
Eq Int54 Source # |
Instance details Defined in Text.JSON.Canonical Methods (==) :: Int54 -> Int54 -> Bool Source # (/=) :: Int54 -> Int54 -> Bool Source #
Ord Int54 Source # |
Instance details Defined in Text.JSON.Canonical Methods compare :: Int54 -> Int54 -> Ordering Source # (<) :: Int54 -> Int54 -> Bool Source # (<=) :: Int54 -> Int54 -> Bool Source # (>) :: Int54 -> Int54 -> Bool Source # (>=) :: Int54 -> Int54 -> Bool Source # max :: Int54 -> Int54 -> Int54 Source # min :: Int54 -> Int54 -> Int54 Source #
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 #

class ToObjectKey (m :: Type -> Type) a where Source #

Used in the `ToJSON` instance for `Map`

Methods

toObjectKey :: a -> m String Source #

#### Instances

Instances details

Monad m => ToObjectKey m KeyId Source # |
Instance details Defined in Hackage.Security.Key Methods toObjectKey :: KeyId -> m String Source #
Monad m => ToObjectKey m HashFn Source # |
Instance details Defined in Hackage.Security.TUF.FileInfo Methods toObjectKey :: HashFn -> m String Source #
Monad m => ToObjectKey m TargetPath Source # |
Instance details Defined in Hackage.Security.TUF.FileMap Methods toObjectKey :: TargetPath -> m String Source #
Monad m => ToObjectKey m String Source # |
Instance details Defined in Hackage.Security.Util.JSON Methods toObjectKey :: String -> m String Source #
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 :: Type -> Type) a where Source #

Used in the `FromJSON` instance for `Map`

Methods

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

#### Instances

Instances details

Monad m => FromObjectKey m KeyId Source # |
Instance details Defined in Hackage.Security.Key Methods fromObjectKey :: String -> m (Maybe KeyId) Source #
ReportSchemaErrors m => FromObjectKey m HashFn Source # |
Instance details Defined in Hackage.Security.TUF.FileInfo Methods fromObjectKey :: String -> m (Maybe HashFn) Source #
ReportSchemaErrors m => FromObjectKey m TargetPath Source # |
Instance details Defined in Hackage.Security.TUF.FileMap Methods fromObjectKey :: String -> m (Maybe TargetPath) Source #
Monad m => FromObjectKey m String Source # |
Instance details Defined in Hackage.Security.Util.JSON Methods fromObjectKey :: String -> m (Maybe String) Source #
Monad m => FromObjectKey m (Path root) Source # |
Instance details Defined in Hackage.Security.Util.JSON Methods fromObjectKey :: String -> m (Maybe (Path root)) Source #

class (Applicative m, Monad m) => ReportSchemaErrors (m :: Type -> Type) where Source #

Monads in which we can report schema errors

Methods

expected :: Expected -> Maybe Got -> m a Source #

#### Instances

Instances details

ReportSchemaErrors ReadJSON_Keys_Layout Source # |
Instance details Defined in Hackage.Security.JSON Methods expected :: Expected -> Maybe Got -> ReadJSON_Keys_Layout a Source #
ReportSchemaErrors ReadJSON_Keys_NoLayout Source # |
Instance details Defined in Hackage.Security.JSON Methods expected :: Expected -> Maybe Got -> ReadJSON_Keys_NoLayout a Source #
ReportSchemaErrors ReadJSON_NoKeys_NoLayout Source # |
Instance details Defined in Hackage.Security.JSON Methods expected :: Expected -> Maybe Got -> ReadJSON_NoKeys_NoLayout a Source #

type Expected = String Source #

type Got = String Source #

expected' :: ReportSchemaErrors m => Expected -> JSValue -> m a Source #

fromJSObject :: ReportSchemaErrors m => JSValue -> m [(String, JSValue)] Source #

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

Extract a field from a JSON object

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

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