packages feed

clientsession 0.4.0.3 → 0.4.1

raw patch · 2 files changed

+21/−2 lines, 2 filesdep +template-haskellPVP ok

version bump matches the API change (PVP)

Dependencies added: template-haskell

API changes (from Hackage documentation)

+ Web.ClientSession: embedDefaultKey :: Q Exp
+ Web.ClientSession: embedKey :: FilePath -> Q Exp

Files

Web/ClientSession.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ForeignFunctionInterface #-}+{-# LANGUAGE TemplateHaskell #-} --------------------------------------------------------- -- -- Module        : Web.ClientSession@@ -17,8 +18,10 @@     ( -- * Automatic key generation       Key     , getKey+    , embedKey     , defaultKeyFile     , getDefaultKey+    , embedDefaultKey       -- * Actual encryption/decryption     , encrypt     , decrypt@@ -26,6 +29,7 @@  import System.Directory import qualified Data.ByteString as S+import qualified Data.ByteString.Char8 as B  import System.Random @@ -36,6 +40,7 @@ import Foreign.Marshal.Alloc import Foreign.Storable import System.IO.Unsafe+import Language.Haskell.TH  type Key = S.ByteString @@ -47,6 +52,10 @@ getDefaultKey :: IO Key getDefaultKey = getKey defaultKeyFile +-- | Simply calls 'embedKey' 'defaultKeyFile'.+embedDefaultKey :: Q Exp+embedDefaultKey = embedKey defaultKeyFile+ -- | Get a key from the given text file. -- -- If the file does not exist a random key will be generated and stored in that@@ -67,6 +76,15 @@         key' <- randomKey         S.writeFile keyFile key'         return key'++-- | Embed a key from the given text file into haskell source.+--+-- Eliminates overhead of reading key file with each request.+embedKey :: FilePath -> Q Exp+embedKey keyFile = do+  k <- runIO $ getKey keyFile+  let cs = B.unpack k+  [| B.pack |] `appE` (litE $ stringL cs)  minKeyLength :: Int minKeyLength = 16
clientsession.cabal view
@@ -1,5 +1,5 @@ name:            clientsession-version:         0.4.0.3+version:         0.4.1 license:         BSD3 license-file:    LICENSE author:          Michael Snoyman <michael@snoyman.com>@@ -21,7 +21,8 @@     build-depends:   base >=4 && <5,                      bytestring >= 0.9 && < 0.10,                      directory >= 1 && < 1.2,-                     random >= 1.0.0.2 && < 1.1+                     random >= 1.0.0.2 && < 1.1,+                     template-haskell     exposed-modules: Web.ClientSession     ghc-options:     -Wall     c-sources:       c/aestable.c c/helper.c