Safe Haskell | None |
---|---|
Language | Haskell2010 |
Hackage.Security.JSON
Contents
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 where
- 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 a where
- class FromJSON m a where
- class ToObjectKey m a where
- toObjectKey :: a -> m String
- class FromObjectKey m a where
- fromObjectKey :: String -> m (Maybe a)
- class (Applicative m, Monad m) => ReportSchemaErrors m where
- 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 :: forall m. Monad m => [(String, m JSValue)] -> m JSValue
- data JSValue
- data Int54
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
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 where Source #
MonadReader-like monad, specialized to key environments
Instances
MonadKeys ReadJSON_Keys_NoLayout Source # | |
Defined in Hackage.Security.JSON Methods localKeys :: (KeyEnv -> KeyEnv) -> ReadJSON_Keys_NoLayout a -> ReadJSON_Keys_NoLayout a Source # | |
MonadKeys ReadJSON_Keys_Layout Source # | |
Defined in Hackage.Security.JSON Methods localKeys :: (KeyEnv -> KeyEnv) -> ReadJSON_Keys_Layout a -> ReadJSON_Keys_Layout a Source # |
Reader monads
data ReadJSON_Keys_Layout a Source #
Instances
data ReadJSON_Keys_NoLayout a Source #
Instances
data ReadJSON_NoKeys_NoLayout a Source #
Instances
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
Instances
Monad WriteJSON Source # | |
Functor WriteJSON Source # | |
Applicative WriteJSON Source # | |
MonadReader RepoLayout WriteJSON Source # | |
Defined in Hackage.Security.JSON Methods local :: (RepoLayout -> RepoLayout) -> WriteJSON a -> WriteJSON a reader :: (RepoLayout -> a) -> WriteJSON a |
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
Re-exports
Type classes
class ToJSON m a where Source #
Instances
class FromJSON m a where Source #
Instances
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 # | |
Defined in Hackage.Security.Util.JSON Methods toObjectKey :: String -> m String Source # | |
Monad m => ToObjectKey m KeyId Source # | |
Defined in Hackage.Security.Key Methods toObjectKey :: KeyId -> m String Source # | |
Monad m => ToObjectKey m HashFn Source # | |
Defined in Hackage.Security.TUF.FileInfo Methods toObjectKey :: HashFn -> m String Source # | |
Monad m => ToObjectKey m TargetPath Source # | |
Defined in Hackage.Security.TUF.FileMap Methods toObjectKey :: TargetPath -> m String Source # | |
Monad m => ToObjectKey m (Path root) Source # | |
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 # | |
Defined in Hackage.Security.Util.JSON Methods fromObjectKey :: String -> m (Maybe String) Source # | |
Monad m => FromObjectKey m KeyId Source # | |
Defined in Hackage.Security.Key Methods fromObjectKey :: String -> m (Maybe KeyId) Source # | |
ReportSchemaErrors m => FromObjectKey m HashFn Source # | |
Defined in Hackage.Security.TUF.FileInfo Methods fromObjectKey :: String -> m (Maybe HashFn) Source # | |
ReportSchemaErrors m => FromObjectKey m TargetPath Source # | |
Defined in Hackage.Security.TUF.FileMap Methods fromObjectKey :: String -> m (Maybe TargetPath) Source # | |
Monad m => FromObjectKey m (Path root) Source # | |
Defined in Hackage.Security.Util.JSON Methods fromObjectKey :: String -> m (Maybe (Path root)) Source # |
class (Applicative m, Monad m) => ReportSchemaErrors m where Source #
Monads in which we can report schema errors
Instances
Utility
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 #
Re-exports
Constructors
JSNull | |
JSBool !Bool | |
JSNum !Int54 | |
JSString String | |
JSArray [JSValue] | |
JSObject [(String, JSValue)] |
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 # | |
Defined in Text.JSON.Canonical | |
Enum Int54 Source # | |
Eq Int54 Source # | |
Integral Int54 Source # | |
Data Int54 Source # | |
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 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 # | |
Ord Int54 Source # | |
Read Int54 Source # | |
Defined in Text.JSON.Canonical | |
Real Int54 Source # | |
Defined in Text.JSON.Canonical Methods toRational :: Int54 -> Rational | |
Show Int54 Source # | |
Ix Int54 Source # | |
PrintfArg Int54 Source # | |
Defined in Text.JSON.Canonical | |
Bits Int54 Source # | |
Defined in Text.JSON.Canonical Methods (.&.) :: Int54 -> Int54 -> Int54 (.|.) :: Int54 -> Int54 -> Int54 xor :: Int54 -> Int54 -> Int54 complement :: Int54 -> Int54 shift :: Int54 -> Int -> Int54 rotate :: Int54 -> Int -> Int54 setBit :: Int54 -> Int -> Int54 clearBit :: Int54 -> Int -> Int54 complementBit :: Int54 -> Int -> Int54 testBit :: Int54 -> Int -> Bool bitSizeMaybe :: Int54 -> Maybe Int shiftL :: Int54 -> Int -> Int54 unsafeShiftL :: Int54 -> Int -> Int54 shiftR :: Int54 -> Int -> Int54 unsafeShiftR :: Int54 -> Int -> Int54 rotateL :: Int54 -> Int -> Int54 | |
FiniteBits Int54 Source # | |
Defined in Text.JSON.Canonical Methods finiteBitSize :: Int54 -> Int countLeadingZeros :: Int54 -> Int countTrailingZeros :: Int54 -> Int | |
Storable Int54 Source # | |
Defined in Text.JSON.Canonical Methods peekElemOff :: Ptr Int54 -> Int -> IO Int54 pokeElemOff :: Ptr Int54 -> Int -> Int54 -> IO () peekByteOff :: Ptr b -> Int -> IO Int54 pokeByteOff :: Ptr b -> Int -> Int54 -> IO () | |
ReportSchemaErrors m => FromJSON m Int54 Source # | |
Monad m => ToJSON m Int54 Source # | |