packages feed

github-rest 1.1.1 → 1.1.2

raw patch · 3 files changed

+34/−17 lines, 3 filesdep ~aesondep ~jwtdep ~text

Dependency ranges changed: aeson, jwt, text, time

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ ## Upcoming +## 1.1.2++* Add support for `jwt-0.11.0`+ ## 1.1.1  * Add support for `aeson-2.0.0.0`
github-rest.cabal view
@@ -3,11 +3,9 @@ -- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack------ hash: cd7875e6f445fb80991854ab94196826c6e579e0149c6b3a3d63fb928f3a10f5  name:           github-rest-version:        1.1.1+version:        1.1.2 synopsis:       Query the GitHub REST API programmatically description:    Query the GitHub REST API programmatically, which can provide a more                 flexible and clear interface than if all of the endpoints and their types@@ -48,15 +46,15 @@   build-depends:       aeson >=1.1.2.0 && <2.1     , base >=4.9 && <5-    , bytestring >=0.10.8.1 && <0.11+    , bytestring >=0.10.8.1 && <0.12     , http-client >=0.5.13.1 && <0.8     , http-client-tls >=0.3.5.3 && <0.4     , http-types >=0.12.1 && <0.13-    , jwt >=0.9.0 && <0.11+    , jwt >=0.9.0 && <0.12     , mtl >=2.2.2 && <2.3     , scientific >=0.3.6.2 && <0.4     , text >=1.2.2.2 && <1.3-    , time >=1.8.0.2 && <1.10+    , time >=1.8.0.2 && <1.12     , transformers >=0.5.2.0 && <0.6     , unliftio >=0.2.7.0 && <0.3     , unliftio-core >=0.1.1.0 && <0.3@@ -83,12 +81,12 @@       aeson >=1.1.2.0 && <2.1     , aeson-qq     , base >=4.9 && <5-    , bytestring >=0.10.8.1 && <0.11+    , bytestring >=0.10.8.1 && <0.12     , github-rest     , http-client >=0.5.13.1 && <0.8     , http-client-tls >=0.3.5.3 && <0.4     , http-types >=0.12.1 && <0.13-    , jwt >=0.9.0 && <0.11+    , jwt >=0.9.0 && <0.12     , mtl >=2.2.2 && <2.3     , scientific >=0.3.6.2 && <0.4     , tasty@@ -96,7 +94,7 @@     , tasty-hunit     , tasty-quickcheck     , text >=1.2.2.2 && <1.3-    , time >=1.8.0.2 && <1.10+    , time >=1.8.0.2 && <1.12     , transformers >=0.5.2.0 && <0.6     , unliftio >=0.2.7.0 && <0.3     , unliftio-core >=0.1.1.0 && <0.3
src/GitHub/REST/Auth.hs view
@@ -25,12 +25,19 @@ #if !MIN_VERSION_base(4,11,0) import Data.Monoid ((<>)) #endif+import Data.Text (Text) import qualified Data.Text as Text import qualified Data.Text.Encoding as Text import Data.Time (addUTCTime, getCurrentTime) import Data.Time.Clock.POSIX (utcTimeToPOSIXSeconds) import qualified Web.JWT as JWT +#if MIN_VERSION_jwt(0,11,0)+type EncodeSigner = JWT.EncodeSigner+#else+type EncodeSigner = JWT.Signer+#endif+ -- | The token to use to authenticate with GitHub. data Token   = -- | https://developer.github.com/v3/#authentication@@ -48,14 +55,9 @@ type AppId = Int  -- | Create a JWT token that expires in 10 minutes.-getJWTToken :: JWT.Signer -> AppId -> IO Token+getJWTToken :: EncodeSigner -> AppId -> IO Token getJWTToken signer appId = mkToken <$> getNow   where-#if MIN_VERSION_jwt(0,10,0)-    signToken = flip JWT.encodeSigned mempty-#else-    signToken = JWT.encodeSigned-#endif     mkToken now =       let claims =             mempty@@ -68,9 +70,22 @@     -- https://github.community/t5/GitHub-API-Development-and/quot-Expiration-time-claim-exp-is-too-far-in-the-future-quot/m-p/20457/highlight/true#M1127     getNow = addUTCTime (-1) <$> getCurrentTime +signToken :: EncodeSigner -> JWT.JWTClaimsSet -> Text+#if MIN_VERSION_jwt(0,10,0)+signToken = flip JWT.encodeSigned mempty+#else+signToken = JWT.encodeSigned+#endif+ -- | Load a RSA private key as a Signer from the given file path.-loadSigner :: FilePath -> IO JWT.Signer+loadSigner :: FilePath -> IO EncodeSigner loadSigner file = maybe badSigner return . readSigner =<< ByteString.readFile file   where     badSigner = fail $ "Not a valid RSA private key file: " ++ file-    readSigner = fmap JWT.RSAPrivateKey . JWT.readRsaSecret+    readSigner = fmap toEncodeRSAPrivateKey . JWT.readRsaSecret++#if MIN_VERSION_jwt(0,11,0)+    toEncodeRSAPrivateKey = JWT.EncodeRSAPrivateKey+#else+    toEncodeRSAPrivateKey = JWT.RSAPrivateKey+#endif