summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchris_martin <>2019-05-19 02:28:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2019-05-19 02:28:00 (GMT)
commit6540bf73a47bb49854acabe18a45c8e5f4de3d4c (patch)
tree8d895b3d4fcff6c110182451f02d750775b3f891
parenta759aee238285ba75c2ee1380020f1a992d96f30 (diff)
version 1.0.0.1HEAD1.0.0.1master
-rw-r--r--changelog.md12
-rw-r--r--library/Stripe/Signature.hs22
-rw-r--r--license.txt2
-rw-r--r--stripe-signature.cabal6
4 files changed, 27 insertions, 15 deletions
diff --git a/changelog.md b/changelog.md
index 1fe2187..57ac9c0 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,12 +1,10 @@
# Changelog
-All notable changes to this package will be documented in this file.
-
-The format is based on
-[Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
-and this project adheres to the
-[Haskell Package Versioning Policy](https://pvp.haskell.org/).
-
## 1.0.0.0 - 2018-12-20
- Initial release
+
+## 1.0.0.1 - 2019-05-18
+
+- Replace `hex-text` package dependency with slightly smaller `base16-bytestring` dependency
+ \ No newline at end of file
diff --git a/library/Stripe/Signature.hs b/library/Stripe/Signature.hs
index d05ece2..f2ff467 100644
--- a/library/Stripe/Signature.hs
+++ b/library/Stripe/Signature.hs
@@ -13,16 +13,17 @@ import qualified Data.String
import Numeric.Natural (Natural)
import qualified Text.Read
+-- base16-bytestring
+import qualified Data.ByteString.Base16
+
-- bytestring
import Data.ByteString (ByteString)
+import qualified Data.ByteString
-- cryptonite
import Crypto.Hash (SHA256)
import Crypto.MAC.HMAC as HMAC
--- hex-text
-import qualified Text.Hex
-
-- memory
import qualified Data.ByteArray
@@ -32,6 +33,7 @@ import Stripe.Concepts (WebhookSecretKey (..))
-- text
import Data.Text (Text)
import qualified Data.Text
+import qualified Data.Text.Encoding
isSigValid :: Sig -> WebhookSecretKey -> ByteString -> Bool
isSigValid x secret body =
@@ -84,7 +86,7 @@ parseSig txt =
v1 = Data.Maybe.mapMaybe
( \(k, v) ->
if k == Data.Text.pack "v1"
- then Text.Hex.decodeHex v
+ then decodeHex v
else Nothing
)
parts
@@ -109,3 +111,15 @@ split2 pat src =
readNatural :: String -> Maybe Natural
readNatural = Text.Read.readMaybe
+
+{- | Decodes hexidecimal text as a byte string. The result is a 'Just' value iff
+the text contains an even number of characters and consists only of the digits
+@0@ through @9@ and letters @a@ through @f@. -}
+
+decodeHex :: Text -> Maybe ByteString
+decodeHex txt =
+ let
+ bs = Data.Text.Encoding.encodeUtf8 txt
+ (x, remainder) = Data.ByteString.Base16.decode bs
+ in
+ if Data.ByteString.null remainder then Just x else Nothing
diff --git a/license.txt b/license.txt
index 6e7b406..63ddf32 100644
--- a/license.txt
+++ b/license.txt
@@ -1,4 +1,4 @@
-Copyright 2018 Typeclass Consulting, LLC
+Copyright 2019 Typeclass Consulting, LLC
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
diff --git a/stripe-signature.cabal b/stripe-signature.cabal
index 224c0c9..d778ded 100644
--- a/stripe-signature.cabal
+++ b/stripe-signature.cabal
@@ -1,5 +1,5 @@
name: stripe-signature
-version: 1.0.0.0
+version: 1.0.0.1
synopsis: Verification of Stripe webhook signatures
category: Web
@@ -23,7 +23,7 @@ license-file: license.txt
build-type: Simple
cabal-version: >=1.10
-tested-with: GHC==8.2.2, GHC==8.4.3, GHC==8.6.1
+tested-with: GHC==8.2.2, GHC==8.4.4, GHC==8.6.3
extra-source-files:
changelog.md
@@ -37,9 +37,9 @@ library
build-depends:
base >=4.10 && <5
+ , base16-bytestring
, bytestring
, cryptonite
- , hex-text
, memory
, stripe-concepts
, text