diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-09-14 14:46:18 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-09-14 14:46:18 -0400 |
commit | 98aca70641905000e2104d456c8f24677e31ef75 (patch) | |
tree | 7853dda9d1029898d4a9e7a6d15412fb04139f1b /HTTP.hs | |
parent | 98636bf2b43fed264a541974a058cb0003e81139 (diff) | |
download | keysafe-98aca70641905000e2104d456c8f24677e31ef75.tar.gz |
fix PoW deserialization
Diffstat (limited to 'HTTP.hs')
-rw-r--r-- | HTTP.hs | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -93,8 +93,8 @@ instance ToHttpApiData ProofOfWork where <> ":" <> b64 b instance FromHttpApiData ProofOfWork where parseUrlPiece t = do - let (salt, rest) = T.break (/= ':') t - let (hmac, rest') = T.break (/= ':') rest + let (salt, rest) = T.break (== ':') t + let (hmac, rest') = T.break (== ':') (T.drop 1 rest) b <- unb64 (T.drop 1 rest') return $ ProofOfWork b $ RequestID { randomSalt = RandomSalt salt @@ -105,6 +105,7 @@ b64 :: B.ByteString -> Text b64 v = T.decodeUtf8 $ Raaz.toByteString (Raaz.encode v :: Raaz.Base64) unb64 :: Monad m => Text -> m B.ByteString -unb64 t = maybe (fail "bad base64 data") (return . Raaz.decodeFormat) f - where - f = Raaz.fromByteString (T.encodeUtf8 t) :: Maybe Raaz.Base64 +unb64 t = maybe + (fail "bad base64 data") + (return . Raaz.decodeFormat) + (Raaz.fromByteString (T.encodeUtf8 t) :: Maybe Raaz.Base64) |