packages feed

jwt 0.10.0 → 0.10.1

raw patch · 4 files changed

+40/−15 lines, 4 filesdep ~base

Dependency ranges changed: base

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+# 2021-12-02 0.10.1++* Add support for Aeson 2.x+ # 2019-03-25 0.10.0  * Add "kid" and allow specifying JOSEHeader
jwt.cabal view
@@ -2,14 +2,14 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                jwt-version:             0.10.0+version:             0.10.1 synopsis:            JSON Web Token (JWT) decoding and encoding license:             MIT license-file:        LICENSE author:              Brian McKenna maintainer:          brian@brianmckenna.org-homepage:            https://bitbucket.org/ssaasen/haskell-jwt-bug-reports:         https://bitbucket.org/ssaasen/haskell-jwt/issues+homepage:            https://bitbucket.org/puffnfresh/haskell-jwt+bug-reports:         https://bitbucket.org/puffnfresh/haskell-jwt/issues category:            Web build-type:          Simple cabal-version:       >=1.16@@ -27,12 +27,12 @@  source-repository head     type: git-    location: https://ssaasen@bitbucket.org/ssaasen/haskell-jwt.git+    location: https://bitbucket.org/puffnfresh/haskell-jwt.git  library   exposed-modules:     Web.JWT   other-modules:       Data.Text.Extended, Data.ByteString.Extended-  build-depends:       base >= 4.6 && < 5+  build-depends:       base >= 4.8 && < 5                      , cryptonite               >= 0.6                      , memory                   >= 0.8                      , bytestring               >= 0.10@@ -71,7 +71,7 @@                      , Data.ByteString.Extended                      , Data.ByteString.ExtendedTests   hs-source-dirs:      tests/src, src-  build-depends:       base < 5 && >= 4.4+  build-depends:       base < 5 && >= 4.8                      , tasty >= 0.7                      , tasty-th >= 0.1                      , tasty-hunit >= 0.4@@ -103,6 +103,6 @@   type:                exitcode-stdio-1.0   main-is:             doctests.hs   ghc-options:         -threaded-  build-depends:       base < 5 && >= 4.4+  build-depends:       base < 5 && >= 4.8                      , jwt                      , doctest     >= 0.9.11
src/Web/JWT.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP                #-} {-# LANGUAGE EmptyDataDecls     #-} {-# LANGUAGE FlexibleInstances  #-} {-# LANGUAGE GADTs              #-}@@ -72,6 +73,7 @@     , rsaKeySecret     ) where +import           Data.Bifunctor             (first) import qualified Data.ByteString.Char8      as C8 import qualified Data.ByteString.Lazy.Char8 as BL (fromStrict, toStrict) import qualified Data.ByteString.Extended as BS@@ -87,7 +89,6 @@ import           Data.ByteArray.Encoding import           Data.Aeson                 hiding (decode, encode) import qualified Data.Aeson                 as JSON-import qualified Data.HashMap.Strict        as StrictMap import qualified Data.Map                   as Map import           Data.Maybe import           Data.Scientific@@ -98,6 +99,13 @@ import qualified Network.URI                as URI import           Prelude                    hiding (exp) +#if MIN_VERSION_aeson(2,0,0)+import qualified Data.Aeson.Key             as Key+import qualified Data.Aeson.KeyMap          as KeyMap+#else+import qualified Data.HashMap.Strict        as KeyMap+#endif+ -- $setup -- The code examples in this module require GHC's `OverloadedStrings` -- extension:@@ -507,7 +515,13 @@     ClaimsMap $ a Semigroup.<> b  fromHashMap :: Object -> ClaimsMap-fromHashMap = ClaimsMap . Map.fromList . StrictMap.toList+fromHashMap = ClaimsMap . Map.fromList . map (first toText) . KeyMap.toList+  where+#if MIN_VERSION_aeson(2,0,0)+    toText = Key.toText+#else+    toText = id+#endif  removeRegisteredClaims :: ClaimsMap -> ClaimsMap removeRegisteredClaims (ClaimsMap input) = ClaimsMap $ Map.differenceWithKey (\_ _ _ -> Nothing) input registeredClaims@@ -523,14 +537,20 @@                 , fmap ("nbf" .=) nbf                 , fmap ("iat" .=) iat                 , fmap ("jti" .=) jti-            ] ++ Map.toList (unClaimsMap $ removeRegisteredClaims unregisteredClaims)+            ] ++ map (first fromText) (Map.toList $ unClaimsMap $ removeRegisteredClaims unregisteredClaims)+      where+#if MIN_VERSION_aeson(2,0,0)+        fromText = Key.fromText+#else+        fromText = id+#endif  instance FromJSON JWTClaimsSet where         parseJSON = withObject "JWTClaimsSet"                      (\o -> JWTClaimsSet                      <$> o .:? "iss"                      <*> o .:? "sub"-                     <*> case StrictMap.lookup "aud" o of+                     <*> case KeyMap.lookup "aud" o of                          (Just as@(JSON.Array _)) -> Just <$> Right <$> parseJSON as                          (Just (JSON.String t))   -> pure $ Left <$> stringOrURI t                          _                        -> pure Nothing
stack.yaml view
@@ -1,4 +1,5 @@-packages:-- '.'-extra-deps: []-resolver: lts-9.6+resolver: nightly-2021-10-07++extra-deps:+  - aeson-2.0.0.0+  - lens-aeson-1.1.2