packages feed

hoauth 0.1.1 → 0.1.2

raw patch · 3 files changed

+20/−32 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Network.Protocol.OAuth.Request: (>>|) :: Request -> (Request -> Request) -> Request
- Network.Protocol.OAuth.Request: apply :: Request -> (Request -> Request) -> Request
- Network.Protocol.OAuth.Request: append_param :: Request -> String -> Maybe String -> Request
+ Network.Protocol.OAuth.Request: append_param :: Request -> (String, Maybe String) -> Request

Files

hoauth.cabal view
@@ -1,5 +1,5 @@ name: hoauth-version: 0.1.1+version: 0.1.2 category: Network,Protocol,OAuth license: BSD3 license-file: LICENSE@@ -9,7 +9,7 @@ build-type: Simple cabal-version: >= 1.6 tested-with: GHC==6.8.2,GHC==6.10.4-synopsis: A Haskell implementation of OAuth 1.0 protocol.+synopsis: A Haskell implementation of OAuth 1.0a protocol. description: This library implements all PLAINTEXT, HMAC-SHA1 and RSA-SHA1              signatures as defined in the specification 1.0. Currently it              supports only /consumer/ related functions, but there are plans to
src/main/haskell/Network/Protocol/OAuth/Consumer.hs view
@@ -33,6 +33,7 @@ import qualified Data.ByteString.Lazy as B import qualified Network.Protocol.OAuth.Signature as S import qualified Data.List as L+import qualified Control.Monad as M  -- | OAuth uses Tokens generated by the Service Provider instead of the User's credentials in Protected Resources requests. data Token = Token { oauth_token        :: String,@@ -69,24 +70,19 @@  -- | Process the response of the service provider. The response should be an urlencoded string. response :: Consumer -> B.ByteString -> Maybe Consumer-response cons u = let postdata  = R.read_urlencoded u-                      otken0    = lookup "oauth_token" postdata-                      otkensec0 = lookup "oauth_token_secret" postdata-                      otkextra0 = Just $ filter (\(k,_) -> k/="oauth_token"&&k/="oauth_token_secret") postdata-                  in otken0    >>= \otken1 -> -                     otken1    >>= \otken -> -                     otkensec0 >>= \otkensec1 ->-                     otkensec1 >>= \otkensec ->-                     otkextra0 >>= \otkextra ->-                     case cons-                     of (Unauthenticated ckey csec) -> Just $ Authenticated ckey csec (Token otken otkensec otkextra)-                        (Authenticated ckey csec _) -> Just $ Authenticated ckey csec (Token otken otkensec otkextra)+response c u = let postdata    = R.read_urlencoded u+                   o_token     = (M.join . lookup "oauth_token") postdata+                   o_token_sec = (M.join . lookup "oauth_token_secret") postdata+                   o_token_ext = return $ filter (not . flip elem ["oauth_token","oauth_token_secret"] . fst) postdata+                   token       = M.liftM3 Token o_token o_token_sec o_token_ext+               in case c+                  of (Unauthenticated ckey csec) -> M.liftM3 Authenticated (return ckey) (return csec) token+                     (Authenticated ckey csec _) -> M.liftM3 Authenticated (return ckey) (return csec) token  _oauth :: (S.Signer s,Show s) => String -> s -> R.Request -> R.Request-_oauth ckey met req = req >>+ ("oauth_consumer_key",Just ckey)-                          >>+ ("oauth_version",Just "1.0")-                          >>+ ("oauth_signature_method",(Just . show) met)-                          >>| _sign met+_oauth ckey met req = _sign met $ req >>+ ("oauth_consumer_key",Just ckey)+                                      >>+ ("oauth_version",Just "1.0")+                                      >>+ ("oauth_signature_method",(Just . show) met)  _sign :: (S.Signer s,Show s) => s -> R.Request -> R.Request _sign met req = let sig = S.sign met req
src/main/haskell/Network/Protocol/OAuth/Request.hs view
@@ -24,7 +24,7 @@ -- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -module Network.Protocol.OAuth.Request (Request(..),HTTPMethod(..),Parameter,PercentEncoding(encode,encodes,decode,decodes),append_param,apply,show_url,show_oauthurl,show_oauthheader,show_urlencoded,read_urlencoded,(>>+),(>>|)) where+module Network.Protocol.OAuth.Request (Request(..),HTTPMethod(..),Parameter,PercentEncoding(encode,encodes,decode,decodes),append_param,show_url,show_oauthurl,show_oauthheader,show_urlencoded,read_urlencoded,(>>+)) where  import Data.Bits as B import qualified Data.ByteString.Lazy as B1@@ -74,10 +74,10 @@   deriving (Show,Read,Eq)  -- | Convenience function to append an item in request's parameters list-append_param :: Request -> String -> Maybe String -> Request-append_param r k v = let o_params = params r-                         n_params = (k,v) : o_params-                     in r { params = n_params }+append_param :: Request -> (String,Maybe String) -> Request+append_param r kv = let o_params = params r+                        n_params = kv : o_params+                    in r { params = n_params }  -- | Parses a urlencoded string. read_urlencoded :: B1.ByteString -> [Parameter]@@ -128,17 +128,9 @@ show_urlencoded :: [Parameter] -> B1.ByteString show_urlencoded = _urlencode encodes 0x26 --- | Applies a function to the request-apply :: Request -> (Request -> Request) -> Request-apply r f = f r- -- | Convenience operator to append an item in request's parameters list (>>+) :: Request -> (String,Maybe String) -> Request-(>>+) r = uncurry (append_param r)---- | Applies a function to the request-(>>|) :: Request -> (Request -> Request) -> Request-(>>|) = apply+(>>+) = append_param  instance PercentEncoding Char where   encode = B1.pack . concat . map enc' . B1.unpack . B2.fromString . (:[])