cookie 0.4.4 → 0.4.5
raw patch · 4 files changed
+18/−3 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Web.Cookie: sameSiteNone :: SameSiteOption
Files
- ChangeLog.md +4/−0
- Web/Cookie.hs +12/−1
- cookie.cabal +1/−1
- test/Spec.hs +1/−1
ChangeLog.md view
@@ -1,3 +1,7 @@+## 0.4.5++* Added `SameSite=None`+ ## 0.4.4 * Dropped dependency on blaze-builder
Web/Cookie.hs view
@@ -15,6 +15,7 @@ , SameSiteOption , sameSiteLax , sameSiteStrict+ , sameSiteNone -- ** Functions , parseSetCookie , renderSetCookie@@ -124,13 +125,14 @@ , setCookieDomain :: Maybe S.ByteString -- ^ The domain for which the cookie should be sent. Default value: @Nothing@ (The browser defaults to the current domain). , setCookieHttpOnly :: Bool -- ^ Marks the cookie as "HTTP only", i.e. not accessible from Javascript. Default value: @False@ , setCookieSecure :: Bool -- ^ Instructs the browser to only send the cookie over HTTPS. Default value: @False@- , setCookieSameSite :: Maybe SameSiteOption -- ^ Marks the cookie as "same site", i.e. should not be sent with cross-site requests. Default value: @Nothing@+ , setCookieSameSite :: Maybe SameSiteOption -- ^ The "same site" policy of the cookie, i.e. whether it should be sent with cross-site requests. Default value: @Nothing@ } deriving (Eq, Show) -- | Data type representing the options for a <https://tools.ietf.org/html/draft-west-first-party-cookies-07#section-4.1 SameSite cookie> data SameSiteOption = Lax | Strict+ | None deriving (Show, Eq) instance NFData SameSiteOption where@@ -144,6 +146,13 @@ sameSiteStrict :: SameSiteOption sameSiteStrict = Strict +-- |+-- Directs the browser to send the cookie for cross-site requests.+--+-- @since 0.4.5+sameSiteNone :: SameSiteOption+sameSiteNone = None+ instance NFData SetCookie where rnf (SetCookie a b c d e f g h i) = a `seq`@@ -211,6 +220,7 @@ Nothing -> mempty Just Lax -> byteStringCopy "; SameSite=Lax" Just Strict -> byteStringCopy "; SameSite=Strict"+ Just None -> byteStringCopy "; SameSite=None" ] parseSetCookie :: S.ByteString -> SetCookie@@ -228,6 +238,7 @@ , setCookieSameSite = case lookup "samesite" flags of Just "Lax" -> Just Lax Just "Strict" -> Just Strict+ Just "None" -> Just None _ -> Nothing } where
cookie.cabal view
@@ -1,5 +1,5 @@ name: cookie-version: 0.4.4+version: 0.4.5 license: MIT license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>
test/Spec.hs view
@@ -55,7 +55,7 @@ arbitrary = fmap (Char' . toEnum) $ choose (62, 125) newtype SameSiteOption' = SameSiteOption' { unSameSiteOption' :: SameSiteOption } instance Arbitrary SameSiteOption' where- arbitrary = fmap SameSiteOption' (elements [sameSiteLax, sameSiteStrict])+ arbitrary = fmap SameSiteOption' (elements [sameSiteLax, sameSiteStrict, sameSiteNone]) propParseRenderSetCookie :: SetCookie -> Bool propParseRenderSetCookie sc =