hackage-security-0.1.0.0: 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.

MonadKeys

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

MonadReader-like monad, specialized to key environments

Methods

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

askKeys :: m KeyEnv Source

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

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

Reader monads

Utility

Writing

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

class FromJSON m a where Source

Methods

fromJSON :: JSValue -> m a Source

Instances

ReportSchemaErrors m => FromJSON m URI 
ReportSchemaErrors m => FromJSON m UTCTime 
ReportSchemaErrors m => FromJSON m Int 
ReportSchemaErrors m => FromJSON m String 
Monad m => FromJSON m JSValue 
ReportSchemaErrors m => FromJSON m KeyEnv 
ReportSchemaErrors m => FromJSON m Hash 
ReportSchemaErrors m => FromJSON m FileLength 
ReportSchemaErrors m => FromJSON m KeyThreshold 
ReportSchemaErrors m => FromJSON m FileInfo 
ReportSchemaErrors m => FromJSON m FileMap 
ReportSchemaErrors m => FromJSON m Header 
ReportSchemaErrors m => FromJSON m FileExpires 
ReportSchemaErrors m => FromJSON m FileVersion 
ReportSchemaErrors m => FromJSON m PreSignature 
MonadKeys m => FromJSON m Signatures 
(MonadError DeserializationError m, ReportSchemaErrors m) => FromJSON m Mirrors 
ReportSchemaErrors m => FromJSON m Mirror 
(MonadReader RepoLayout m, MonadError DeserializationError m, ReportSchemaErrors m) => FromJSON m Snapshot 
MonadKeys m => FromJSON m Targets 
MonadKeys m => FromJSON m Delegations 
MonadKeys m => FromJSON m DelegationSpec 
(MonadReader RepoLayout m, MonadError DeserializationError m, ReportSchemaErrors m) => FromJSON m Timestamp 
MonadKeys m => FromJSON m RootRoles 
(ReportSchemaErrors m, FromJSON m a) => FromJSON m [a] 
ReportSchemaErrors m => FromJSON m (Some KeyType) 
ReportSchemaErrors m => FromJSON m (Some PublicKey) 
ReportSchemaErrors m => FromJSON m (Some Key) 
ReportSchemaErrors m => FromJSON m (Some Replacement) 
ReportSchemaErrors m => FromJSON m (Some Pattern) 
(ReportSchemaErrors m, FromJSON m a) => FromJSON m (UninterpretedSignatures a) 
MonadKeys m => FromJSON m (Signed Mirrors) 
(MonadKeys m, MonadReader RepoLayout m) => FromJSON m (Signed Snapshot) 
MonadKeys m => FromJSON m (Signed Targets) 
(MonadKeys m, MonadReader RepoLayout m) => FromJSON m (Signed Timestamp) 
MonadKeys m => FromJSON 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.

(ReportSchemaErrors m, Ord k, FromObjectKey m k, FromJSON m a) => FromJSON m (Map k a) 

class ToObjectKey m a where Source

Used in the ToJSON instance for Map

Methods

toObjectKey :: a -> m String 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