From 7fe2488ce345f261c2d99746788e4037069fe9bb Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Wed, 20 Jan 2016 19:43:11 -0500 Subject: minor fix: type sig unifies two functions --- acme.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/acme.hs b/acme.hs index e2bfd30..693671b 100644 --- a/acme.hs +++ b/acme.hs @@ -11,7 +11,7 @@ module Main where import Control.Lens hiding ((.=)) import Control.Monad import Crypto.Number.Serialize (i2osp) -import Data.Aeson (ToJSON (..), encode, object, (.=)) +import Data.Aeson (ToJSON (..), encode, object, (.=), Value) import Data.Aeson.Lens hiding (key) import qualified Data.Aeson.Lens as JSON import Data.ByteString (ByteString) @@ -107,10 +107,12 @@ go (CmdOpts privKeyFile domain challengeDir email termOverride) = do r <- challengeRequest domain >>= statusReport let + + httpChallenge :: (Value -> Const (Endo s) Value) -> Response LC.ByteString -> Const (Endo s) (Response LC.ByteString) httpChallenge = responseBody . JSON.key "challenges" . to universe . traverse . (filtered . has $ ix "type" . only "http-01") - httpChallenge' = responseBody . JSON.key "challenges" . to universe . traverse . (filtered . has $ ix "type" . only "http-01") + token = r ^?! httpChallenge . JSON.key "token" . _String . to encodeUtf8 - crUri = r ^?! httpChallenge' . JSON.key "uri" . _String . to T.unpack + crUri = r ^?! httpChallenge . JSON.key "uri" . _String . to T.unpack thumb = thumbprint (JWK (rsaE pub) "RSA" (rsaN pub)) thumbtoken = toStrict (LB.fromChunks [token, ".", thumb]) -- cgit v1.2.3