Hackage.Security.JSON

hackage-security-0.5.2.2: Hackage security library

Safe Haskell | None
Language | Haskell2010

Hackage.Security.JSON

Contents

- Deserialization errors
- MonadKeys
- Reader monads
  - Utility
- Writing
  - Utility
- Re-exports
- Type classes
- 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 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
- class FromObjectKey m a where
- 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
  - = JSNull
  - | JSBool !Bool
  - | JSNum !Int54
  - | JSString String
  - | JSArray [JSValue]
  - | JSObject [(String, JSValue)]
- data Int54

# Deserialization errors

data DeserializationError #

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 # |
Methods showsPrec :: Int -> DeserializationError -> ShowS # show :: DeserializationError -> String # showList :: [DeserializationError] -> ShowS #
Exception DeserializationError # |
Methods toException :: DeserializationError -> SomeException # fromException :: SomeException -> Maybe DeserializationError # displayException :: DeserializationError -> String #
Pretty DeserializationError # |
Methods pretty :: DeserializationError -> String #
MonadError DeserializationError ReadJSON_NoKeys_NoLayout # |
Methods throwError :: DeserializationError -> ReadJSON_NoKeys_NoLayout a # catchError :: ReadJSON_NoKeys_NoLayout a -> (DeserializationError -> ReadJSON_NoKeys_NoLayout a) -> ReadJSON_NoKeys_NoLayout a #
MonadError DeserializationError ReadJSON_Keys_NoLayout # |
Methods throwError :: DeserializationError -> ReadJSON_Keys_NoLayout a # catchError :: ReadJSON_Keys_NoLayout a -> (DeserializationError -> ReadJSON_Keys_NoLayout a) -> ReadJSON_Keys_NoLayout a #
MonadError DeserializationError ReadJSON_Keys_Layout # |
Methods throwError :: DeserializationError -> ReadJSON_Keys_Layout a # catchError :: ReadJSON_Keys_Layout a -> (DeserializationError -> ReadJSON_Keys_Layout a) -> ReadJSON_Keys_Layout a #

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

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

# MonadKeys

class (ReportSchemaErrors m, MonadError DeserializationError m) => MonadKeys m where #

MonadReader-like monad, specialized to key environments

Minimal complete definition

localKeys, askKeys

Methods

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

askKeys :: m KeyEnv #

Instances

MonadKeys ReadJSON_Keys_NoLayout # |
Methods localKeys :: (KeyEnv -> KeyEnv) -> ReadJSON_Keys_NoLayout a -> ReadJSON_Keys_NoLayout a # askKeys :: ReadJSON_Keys_NoLayout KeyEnv #
MonadKeys ReadJSON_Keys_Layout # |
Methods localKeys :: (KeyEnv -> KeyEnv) -> ReadJSON_Keys_Layout a -> ReadJSON_Keys_Layout a # askKeys :: ReadJSON_Keys_Layout 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) #

# Reader monads

data ReadJSON_Keys_Layout a #

Instances

Monad ReadJSON_Keys_Layout # |
Methods (>>=) :: ReadJSON_Keys_Layout a -> (a -> ReadJSON_Keys_Layout b) -> ReadJSON_Keys_Layout b # (>>) :: ReadJSON_Keys_Layout a -> ReadJSON_Keys_Layout b -> ReadJSON_Keys_Layout b # return :: a -> ReadJSON_Keys_Layout a # fail :: String -> ReadJSON_Keys_Layout a #
Functor ReadJSON_Keys_Layout # |
Methods fmap :: (a -> b) -> ReadJSON_Keys_Layout a -> ReadJSON_Keys_Layout b # (<$) :: a -> ReadJSON_Keys_Layout b -> ReadJSON_Keys_Layout a #
Applicative ReadJSON_Keys_Layout # |
Methods pure :: a -> ReadJSON_Keys_Layout a # (<*>) :: ReadJSON_Keys_Layout (a -> b) -> ReadJSON_Keys_Layout a -> ReadJSON_Keys_Layout b # liftA2 :: (a -> b -> c) -> ReadJSON_Keys_Layout a -> ReadJSON_Keys_Layout b -> ReadJSON_Keys_Layout c # (*>) :: ReadJSON_Keys_Layout a -> ReadJSON_Keys_Layout b -> ReadJSON_Keys_Layout b # (<*) :: ReadJSON_Keys_Layout a -> ReadJSON_Keys_Layout b -> ReadJSON_Keys_Layout a #
ReportSchemaErrors ReadJSON_Keys_Layout # |
Methods expected :: Expected -> Maybe Got -> ReadJSON_Keys_Layout a #
MonadKeys ReadJSON_Keys_Layout # |
Methods localKeys :: (KeyEnv -> KeyEnv) -> ReadJSON_Keys_Layout a -> ReadJSON_Keys_Layout a # askKeys :: ReadJSON_Keys_Layout KeyEnv #
MonadReader RepoLayout ReadJSON_Keys_Layout # |
Methods ask :: ReadJSON_Keys_Layout RepoLayout # local :: (RepoLayout -> RepoLayout) -> ReadJSON_Keys_Layout a -> ReadJSON_Keys_Layout a # reader :: (RepoLayout -> a) -> ReadJSON_Keys_Layout a #
MonadError DeserializationError ReadJSON_Keys_Layout # |
Methods throwError :: DeserializationError -> ReadJSON_Keys_Layout a # catchError :: ReadJSON_Keys_Layout a -> (DeserializationError -> ReadJSON_Keys_Layout a) -> ReadJSON_Keys_Layout a #

data ReadJSON_Keys_NoLayout a #

Instances

Monad ReadJSON_Keys_NoLayout # |
Methods (>>=) :: ReadJSON_Keys_NoLayout a -> (a -> ReadJSON_Keys_NoLayout b) -> ReadJSON_Keys_NoLayout b # (>>) :: ReadJSON_Keys_NoLayout a -> ReadJSON_Keys_NoLayout b -> ReadJSON_Keys_NoLayout b # return :: a -> ReadJSON_Keys_NoLayout a # fail :: String -> ReadJSON_Keys_NoLayout a #
Functor ReadJSON_Keys_NoLayout # |
Methods fmap :: (a -> b) -> ReadJSON_Keys_NoLayout a -> ReadJSON_Keys_NoLayout b # (<$) :: a -> ReadJSON_Keys_NoLayout b -> ReadJSON_Keys_NoLayout a #
Applicative ReadJSON_Keys_NoLayout # |
Methods pure :: a -> ReadJSON_Keys_NoLayout a # (<*>) :: ReadJSON_Keys_NoLayout (a -> b) -> ReadJSON_Keys_NoLayout a -> ReadJSON_Keys_NoLayout b # liftA2 :: (a -> b -> c) -> ReadJSON_Keys_NoLayout a -> ReadJSON_Keys_NoLayout b -> ReadJSON_Keys_NoLayout c # (*>) :: ReadJSON_Keys_NoLayout a -> ReadJSON_Keys_NoLayout b -> ReadJSON_Keys_NoLayout b # (<*) :: ReadJSON_Keys_NoLayout a -> ReadJSON_Keys_NoLayout b -> ReadJSON_Keys_NoLayout a #
ReportSchemaErrors ReadJSON_Keys_NoLayout # |
Methods expected :: Expected -> Maybe Got -> ReadJSON_Keys_NoLayout a #
MonadKeys ReadJSON_Keys_NoLayout # |
Methods localKeys :: (KeyEnv -> KeyEnv) -> ReadJSON_Keys_NoLayout a -> ReadJSON_Keys_NoLayout a # askKeys :: ReadJSON_Keys_NoLayout KeyEnv #
MonadError DeserializationError ReadJSON_Keys_NoLayout # |
Methods throwError :: DeserializationError -> ReadJSON_Keys_NoLayout a # catchError :: ReadJSON_Keys_NoLayout a -> (DeserializationError -> ReadJSON_Keys_NoLayout a) -> ReadJSON_Keys_NoLayout a #

data ReadJSON_NoKeys_NoLayout a #

Instances

Monad ReadJSON_NoKeys_NoLayout # |
Methods (>>=) :: ReadJSON_NoKeys_NoLayout a -> (a -> ReadJSON_NoKeys_NoLayout b) -> ReadJSON_NoKeys_NoLayout b # (>>) :: ReadJSON_NoKeys_NoLayout a -> ReadJSON_NoKeys_NoLayout b -> ReadJSON_NoKeys_NoLayout b # return :: a -> ReadJSON_NoKeys_NoLayout a # fail :: String -> ReadJSON_NoKeys_NoLayout a #
Functor ReadJSON_NoKeys_NoLayout # |
Methods fmap :: (a -> b) -> ReadJSON_NoKeys_NoLayout a -> ReadJSON_NoKeys_NoLayout b # (<$) :: a -> ReadJSON_NoKeys_NoLayout b -> ReadJSON_NoKeys_NoLayout a #
Applicative ReadJSON_NoKeys_NoLayout # |
Methods pure :: a -> ReadJSON_NoKeys_NoLayout a # (<*>) :: ReadJSON_NoKeys_NoLayout (a -> b) -> ReadJSON_NoKeys_NoLayout a -> ReadJSON_NoKeys_NoLayout b # liftA2 :: (a -> b -> c) -> ReadJSON_NoKeys_NoLayout a -> ReadJSON_NoKeys_NoLayout b -> ReadJSON_NoKeys_NoLayout c # (*>) :: ReadJSON_NoKeys_NoLayout a -> ReadJSON_NoKeys_NoLayout b -> ReadJSON_NoKeys_NoLayout b # (<*) :: ReadJSON_NoKeys_NoLayout a -> ReadJSON_NoKeys_NoLayout b -> ReadJSON_NoKeys_NoLayout a #
ReportSchemaErrors ReadJSON_NoKeys_NoLayout # |
Methods expected :: Expected -> Maybe Got -> ReadJSON_NoKeys_NoLayout a #
MonadError DeserializationError ReadJSON_NoKeys_NoLayout # |
Methods throwError :: DeserializationError -> ReadJSON_NoKeys_NoLayout a # catchError :: ReadJSON_NoKeys_NoLayout a -> (DeserializationError -> ReadJSON_NoKeys_NoLayout a) -> 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 #

## Utility

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

# Writing

data WriteJSON a #

Instances

Monad WriteJSON # |
Methods (>>=) :: WriteJSON a -> (a -> WriteJSON b) -> WriteJSON b # (>>) :: WriteJSON a -> WriteJSON b -> WriteJSON b # return :: a -> WriteJSON a # fail :: String -> WriteJSON a #
Functor WriteJSON # |
Methods fmap :: (a -> b) -> WriteJSON a -> WriteJSON b # (<$) :: a -> WriteJSON b -> WriteJSON a #
Applicative WriteJSON # |
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 # |
Methods ask :: WriteJSON RepoLayout # local :: (RepoLayout -> RepoLayout) -> WriteJSON a -> WriteJSON a # reader :: (RepoLayout -> a) -> WriteJSON a #

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

## Utility

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

Render to canonical JSON format

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

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

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

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

writeKeyAsId :: Some PublicKey -> JSValue #

# Re-exports

# Type classes

class ToJSON m a where #

Minimal complete definition

toJSON

Methods

toJSON :: a -> m JSValue #

Instances

Monad m => ToJSON m URI # |
Methods toJSON :: URI -> m JSValue #
Monad m => ToJSON m UTCTime # |
Methods toJSON :: UTCTime -> m JSValue #
Monad m => ToJSON m Int54 # |
Methods toJSON :: Int54 -> m JSValue #
Monad m => ToJSON m String # |
Methods toJSON :: String -> m JSValue #
Monad m => ToJSON m JSValue # |
Methods toJSON :: JSValue -> m JSValue #
Monad m => ToJSON m KeyEnv # |
Methods toJSON :: KeyEnv -> m JSValue #
Monad m => ToJSON m PreSignature # |
Methods toJSON :: PreSignature -> m JSValue #
Monad m => ToJSON m Signatures # |
Methods toJSON :: Signatures -> m JSValue #
Monad m => ToJSON m FileExpires # |
Methods toJSON :: FileExpires -> m JSValue #
Monad m => ToJSON m FileVersion # |
Methods toJSON :: FileVersion -> m JSValue #
Monad m => ToJSON m Mirrors # |
Methods toJSON :: Mirrors -> m JSValue #
Monad m => ToJSON m Mirror # |
Methods toJSON :: Mirror -> m JSValue #
Monad m => ToJSON m Hash # |
Methods toJSON :: Hash -> m JSValue #
Monad m => ToJSON m FileLength # |
Methods toJSON :: FileLength -> m JSValue #
Monad m => ToJSON m KeyThreshold # |
Methods toJSON :: KeyThreshold -> m JSValue #
Monad m => ToJSON m FileInfo # |
Methods toJSON :: FileInfo -> m JSValue #
Monad m => ToJSON m FileMap # |
Methods toJSON :: FileMap -> m JSValue #
MonadReader RepoLayout m => ToJSON m Timestamp # |
Methods toJSON :: Timestamp -> m JSValue #
Monad m => ToJSON m Targets # |
Methods toJSON :: Targets -> m JSValue #
Monad m => ToJSON m Delegations # |
Methods toJSON :: Delegations -> m JSValue #
Monad m => ToJSON m DelegationSpec # |
Methods toJSON :: DelegationSpec -> m JSValue #
MonadReader RepoLayout m => ToJSON m Snapshot # |
Methods toJSON :: Snapshot -> m JSValue #
Monad m => ToJSON m Root # |
Methods toJSON :: Root -> m JSValue #
Monad m => ToJSON m RootRoles # |
Methods toJSON :: RootRoles -> m JSValue #
(Monad m, ToJSON m a) => ToJSON m [a] # |
Methods toJSON :: [a] -> m JSValue #
Monad m => ToJSON m (KeyType typ) # |
Methods toJSON :: KeyType typ -> m JSValue #
Monad m => ToJSON m (Some KeyType) # |
Methods toJSON :: Some KeyType -> m JSValue #
Monad m => ToJSON m (Some PublicKey) # |
Methods toJSON :: Some PublicKey -> m JSValue #
Monad m => ToJSON m (Some Key) # |
Methods toJSON :: Some Key -> m JSValue #
Monad m => ToJSON m (PublicKey typ) # |
Methods toJSON :: PublicKey typ -> m JSValue #
Monad m => ToJSON m (Key typ) # |
Methods toJSON :: Key typ -> m JSValue #
(Monad m, ToJSON m a) => ToJSON m (UninterpretedSignatures a) # |
Methods toJSON :: UninterpretedSignatures a -> m JSValue #
(Monad m, ToJSON m a) => ToJSON m (Signed a) # |
Methods toJSON :: Signed a -> m JSValue #
Monad m => ToJSON m (RoleSpec a) # |
Methods toJSON :: RoleSpec a -> m JSValue #
(Monad m, ToObjectKey m k, ToJSON m a) => ToJSON m (Map k a) # |
Methods toJSON :: Map k a -> m JSValue #

class FromJSON m a where #

Minimal complete definition

fromJSON

Methods

fromJSON :: JSValue -> m a #

Instances

ReportSchemaErrors m => FromJSON m URI # |
Methods fromJSON :: JSValue -> m URI #
ReportSchemaErrors m => FromJSON m UTCTime # |
Methods fromJSON :: JSValue -> m UTCTime #
ReportSchemaErrors m => FromJSON m Int54 # |
Methods fromJSON :: JSValue -> m Int54 #
ReportSchemaErrors m => FromJSON m String # |
Methods fromJSON :: JSValue -> m String #
Monad m => FromJSON m JSValue # |
Methods fromJSON :: JSValue -> m JSValue #
ReportSchemaErrors m => FromJSON m KeyEnv # |
Methods fromJSON :: JSValue -> m KeyEnv #
ReportSchemaErrors m => FromJSON m PreSignature # |
Methods fromJSON :: JSValue -> m PreSignature #
MonadKeys m => FromJSON m Signatures # |
Methods fromJSON :: JSValue -> m Signatures #
ReportSchemaErrors m => FromJSON m Header # |
Methods fromJSON :: JSValue -> m Header #
ReportSchemaErrors m => FromJSON m FileExpires # |
Methods fromJSON :: JSValue -> m FileExpires #
ReportSchemaErrors m => FromJSON m FileVersion # |
Methods fromJSON :: JSValue -> m FileVersion #
(MonadError DeserializationError m, ReportSchemaErrors m) => FromJSON m Mirrors # |
Methods fromJSON :: JSValue -> m Mirrors #
ReportSchemaErrors m => FromJSON m Mirror # |
Methods fromJSON :: JSValue -> m Mirror #
ReportSchemaErrors m => FromJSON m Hash # |
Methods fromJSON :: JSValue -> m Hash #
ReportSchemaErrors m => FromJSON m FileLength # |
Methods fromJSON :: JSValue -> m FileLength #
ReportSchemaErrors m => FromJSON m KeyThreshold # |
Methods fromJSON :: JSValue -> m KeyThreshold #
ReportSchemaErrors m => FromJSON m FileInfo # |
Methods fromJSON :: JSValue -> m FileInfo #
ReportSchemaErrors m => FromJSON m FileMap # |
Methods fromJSON :: JSValue -> m FileMap #
(MonadReader RepoLayout m, MonadError DeserializationError m, ReportSchemaErrors m) => FromJSON m Timestamp # |
Methods fromJSON :: JSValue -> m Timestamp #
MonadKeys m => FromJSON m Targets # |
Methods fromJSON :: JSValue -> m Targets #
MonadKeys m => FromJSON m Delegations # |
Methods fromJSON :: JSValue -> m Delegations #
MonadKeys m => FromJSON m DelegationSpec # |
Methods fromJSON :: JSValue -> m DelegationSpec #
(MonadReader RepoLayout m, MonadError DeserializationError m, ReportSchemaErrors m) => FromJSON m Snapshot # |
Methods fromJSON :: JSValue -> m Snapshot #
MonadKeys m => FromJSON m RootRoles # |
Methods fromJSON :: JSValue -> m RootRoles #
(ReportSchemaErrors m, FromJSON m a) => FromJSON m [a] # |
Methods fromJSON :: JSValue -> m [a] #
ReportSchemaErrors m => FromJSON m (Some KeyType) # |
Methods fromJSON :: JSValue -> m (Some KeyType) #
ReportSchemaErrors m => FromJSON m (Some PublicKey) # |
Methods fromJSON :: JSValue -> m (Some PublicKey) #
ReportSchemaErrors m => FromJSON m (Some Key) # |
Methods fromJSON :: JSValue -> m (Some Key) #
(ReportSchemaErrors m, FromJSON m a) => FromJSON m (UninterpretedSignatures a) # |
Methods fromJSON :: JSValue -> m (UninterpretedSignatures a) #
MonadKeys m => FromJSON m (Signed Mirrors) # |
Methods fromJSON :: JSValue -> m (Signed Mirrors) #
(MonadKeys m, MonadReader RepoLayout m) => FromJSON m (Signed Timestamp) # |
Methods fromJSON :: JSValue -> m (Signed Timestamp) #
MonadKeys m => FromJSON m (Signed Targets) # |
Methods fromJSON :: JSValue -> m (Signed Targets) #
(MonadKeys m, MonadReader RepoLayout m) => FromJSON m (Signed Snapshot) # |
Methods fromJSON :: JSValue -> m (Signed Snapshot) #
MonadKeys m => FromJSON m (RoleSpec a) # |
Methods fromJSON :: JSValue -> m (RoleSpec a) #
MonadKeys m => FromJSON m (Signed Root) # | 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.
Methods fromJSON :: JSValue -> m (Signed Root) #
(ReportSchemaErrors m, Ord k, FromObjectKey m k, FromJSON m a) => FromJSON m (Map k a) # |
Methods fromJSON :: JSValue -> m (Map k a) #

class ToObjectKey m a where #

Used in the `ToJSON` instance for `Map`

Minimal complete definition

toObjectKey

Methods

toObjectKey :: a -> m String #

Instances

Monad m => ToObjectKey m String # |
Methods toObjectKey :: String -> m String #
Monad m => ToObjectKey m KeyId # |
Methods toObjectKey :: KeyId -> m String #
Monad m => ToObjectKey m HashFn # |
Methods toObjectKey :: HashFn -> m String #
Monad m => ToObjectKey m TargetPath # |
Methods toObjectKey :: TargetPath -> m String #
Monad m => ToObjectKey m (Path root) # |
Methods toObjectKey :: Path root -> m String #

class FromObjectKey m a where #

Used in the `FromJSON` instance for `Map`

Minimal complete definition

fromObjectKey

Methods

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

Instances

Monad m => FromObjectKey m String # |
Methods fromObjectKey :: String -> m (Maybe String) #
Monad m => FromObjectKey m KeyId # |
Methods fromObjectKey :: String -> m (Maybe KeyId) #
ReportSchemaErrors m => FromObjectKey m HashFn # |
Methods fromObjectKey :: String -> m (Maybe HashFn) #
ReportSchemaErrors m => FromObjectKey m TargetPath # |
Methods fromObjectKey :: String -> m (Maybe TargetPath) #
Monad m => FromObjectKey m (Path root) # |
Methods fromObjectKey :: String -> m (Maybe (Path root)) #

class (Applicative m, Monad m) => ReportSchemaErrors m where #

Monads in which we can report schema errors

Minimal complete definition

expected

Methods

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

Instances

ReportSchemaErrors ReadJSON_NoKeys_NoLayout # |
Methods expected :: Expected -> Maybe Got -> ReadJSON_NoKeys_NoLayout a #
ReportSchemaErrors ReadJSON_Keys_NoLayout # |
Methods expected :: Expected -> Maybe Got -> ReadJSON_Keys_NoLayout a #
ReportSchemaErrors ReadJSON_Keys_Layout # |
Methods expected :: Expected -> Maybe Got -> ReadJSON_Keys_Layout a #

type Expected = String #

type Got = String #

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

# Utility

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

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

Extract a field from a JSON object

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

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

# Re-exports

data JSValue #

Constructors

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

Instances

Eq JSValue # |
Methods (==) :: JSValue -> JSValue -> Bool # (/=) :: JSValue -> JSValue -> Bool #
Ord JSValue # |
Methods compare :: JSValue -> JSValue -> Ordering # (<) :: JSValue -> JSValue -> Bool # (<=) :: JSValue -> JSValue -> Bool # (>) :: JSValue -> JSValue -> Bool # (>=) :: JSValue -> JSValue -> Bool # max :: JSValue -> JSValue -> JSValue # min :: JSValue -> JSValue -> JSValue #
Read JSValue # |
Methods readsPrec :: Int -> ReadS JSValue # readList :: ReadS [JSValue] # readPrec :: ReadPrec JSValue # readListPrec :: ReadPrec [JSValue] #
Show JSValue # |
Methods showsPrec :: Int -> JSValue -> ShowS # show :: JSValue -> String # showList :: [JSValue] -> ShowS #
Monad m => FromJSON m JSValue # |
Methods fromJSON :: JSValue -> m JSValue #
Monad m => ToJSON m JSValue # |
Methods toJSON :: JSValue -> m JSValue #

data Int54 #

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 # |
Methods minBound :: Int54 # maxBound :: Int54 #
Enum Int54 # |
Methods succ :: Int54 -> Int54 # pred :: Int54 -> Int54 # toEnum :: Int -> Int54 # fromEnum :: Int54 -> Int # enumFrom :: Int54 -> [Int54] # enumFromThen :: Int54 -> Int54 -> [Int54] # enumFromTo :: Int54 -> Int54 -> [Int54] # enumFromThenTo :: Int54 -> Int54 -> Int54 -> [Int54] #
Eq Int54 # |
Methods (==) :: Int54 -> Int54 -> Bool # (/=) :: Int54 -> Int54 -> Bool #
Integral Int54 # |
Methods quot :: Int54 -> Int54 -> Int54 # rem :: Int54 -> Int54 -> Int54 # div :: Int54 -> Int54 -> Int54 # mod :: Int54 -> Int54 -> Int54 # quotRem :: Int54 -> Int54 -> (Int54, Int54) # divMod :: Int54 -> Int54 -> (Int54, Int54) # toInteger :: Int54 -> Integer #
Data Int54 # |
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 # |
Methods (+) :: Int54 -> Int54 -> Int54 # (-) :: Int54 -> Int54 -> Int54 # (*) :: Int54 -> Int54 -> Int54 # negate :: Int54 -> Int54 # abs :: Int54 -> Int54 # signum :: Int54 -> Int54 # fromInteger :: Integer -> Int54 #
Ord Int54 # |
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 # |
Methods readsPrec :: Int -> ReadS Int54 # readList :: ReadS [Int54] # readPrec :: ReadPrec Int54 # readListPrec :: ReadPrec [Int54] #
Real Int54 # |
Methods toRational :: Int54 -> Rational #
Show Int54 # |
Methods showsPrec :: Int -> Int54 -> ShowS # show :: Int54 -> String # showList :: [Int54] -> ShowS #
Ix Int54 # |
Methods range :: (Int54, Int54) -> [Int54] # index :: (Int54, Int54) -> Int54 -> Int # unsafeIndex :: (Int54, Int54) -> Int54 -> Int inRange :: (Int54, Int54) -> Int54 -> Bool # rangeSize :: (Int54, Int54) -> Int # unsafeRangeSize :: (Int54, Int54) -> Int
PrintfArg Int54 # |
Methods formatArg :: Int54 -> FieldFormatter # parseFormat :: Int54 -> ModifierParser #
Storable Int54 # |
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 # |
Methods (.&.) :: Int54 -> Int54 -> Int54 # (.|.) :: Int54 -> Int54 -> Int54 # xor :: Int54 -> Int54 -> Int54 # complement :: Int54 -> Int54 # shift :: Int54 -> Int -> Int54 # rotate :: Int54 -> Int -> Int54 # zeroBits :: Int54 # bit :: Int -> Int54 # setBit :: Int54 -> Int -> Int54 # clearBit :: Int54 -> Int -> Int54 # complementBit :: Int54 -> Int -> Int54 # testBit :: Int54 -> Int -> Bool # bitSizeMaybe :: Int54 -> Maybe Int # bitSize :: Int54 -> Int # isSigned :: Int54 -> Bool # shiftL :: Int54 -> Int -> Int54 # unsafeShiftL :: Int54 -> Int -> Int54 # shiftR :: Int54 -> Int -> Int54 # unsafeShiftR :: Int54 -> Int -> Int54 # rotateL :: Int54 -> Int -> Int54 # rotateR :: Int54 -> Int -> Int54 # popCount :: Int54 -> Int #
FiniteBits Int54 # |
Methods finiteBitSize :: Int54 -> Int # countLeadingZeros :: Int54 -> Int # countTrailingZeros :: Int54 -> Int #
ReportSchemaErrors m => FromJSON m Int54 # |
Methods fromJSON :: JSValue -> m Int54 #
Monad m => ToJSON m Int54 # |
Methods toJSON :: Int54 -> m JSValue #