git.iko.soy/typeable/random-token
on master help sign in
random-token.cabal+106−99
since splitsnapshots
unifiedsplit
@@ -1,104 +1,111 @@
1−cabal-version: 2.4
1+cabal-version: 2.4
2−name: random-token
2+name: random-token
3−version: 0.1.0.0
3+version: 0.1.0.0
4−synopsis: Implementation of random token generation and parsing
4+synopsis: Implementation of random token generation and parsing
5−author: typeable.io
5+author: typeable.io
6−maintainer: s9gf4ult@gmail.com
6+maintainer: s9gf4ult@gmail.com
7−license-file: LICENSE
7+license-file: LICENSE
8−category: Web
8+category: Web
9−build-type: Simple
9+build-type: Simple
10
10
11library
11library
12− hs-source-dirs: src
12+ hs-source-dirs: src
13− ghc-options: -Wall
13+ ghc-options: -Wall
14− exposed-modules: Random.Token
14+ exposed-modules: Random.Token
15− build-depends: base >= 4.7 && < 5
15+ build-depends:
16− , QuickCheck
16+ , aeson
17− , aeson
17+ , base >=4.9 && <5
18− , base64-bytestring
18+ , base64-bytestring
19− , bytestring
19+ , bytestring >=0.10
20− , cryptonite
21− , deepseq
20+ , deepseq
22− , http-api-data
21+ , http-api-data
22+ , QuickCheck
23− , text
23+ , text
24+
24− if !(impl(ghcjs) || arch(javascript))
25+ if !(impl(ghcjs) || arch(javascript) || arch(wasm32))
26+ build-depends:
27+ , cryptonite
25− build-depends: postgresql-simple
28+ , postgresql-simple
29+
26− default-language: Haskell2010
30+ default-language: Haskell2010
27− default-extensions: CPP
31+ default-extensions:
32+ CPP
28− , ConstraintKinds
33+ ConstraintKinds
29− , DataKinds
34+ DataKinds
30− , DeriveFoldable
35+ DeriveFoldable
31− , DeriveFunctor
36+ DeriveFunctor
32− , DeriveGeneric
37+ DeriveGeneric
33− , DeriveTraversable
38+ DeriveTraversable
34− , DuplicateRecordFields
39+ DuplicateRecordFields
35− , FlexibleContexts
40+ FlexibleContexts
36− , FlexibleInstances
41+ FlexibleInstances
37− , FunctionalDependencies
42+ FunctionalDependencies
38− , GADTs
43+ GADTs
39− , GeneralizedNewtypeDeriving
44+ GeneralizedNewtypeDeriving
40− , LambdaCase
45+ LambdaCase
41− , MultiParamTypeClasses
46+ MultiParamTypeClasses
42− , MultiWayIf
47+ MultiWayIf
43− , NumDecimals
48+ NumDecimals
44− , OverloadedStrings
49+ OverloadedStrings
45− , PolyKinds
50+ PolyKinds
46− , QuasiQuotes
51+ QuasiQuotes
47− , RankNTypes
52+ RankNTypes
48− , RecordWildCards
53+ RecordWildCards
49− , RoleAnnotations
54+ RoleAnnotations
50− , ScopedTypeVariables
55+ ScopedTypeVariables
51− , StandaloneDeriving
56+ StandaloneDeriving
52− , TemplateHaskell
57+ TemplateHaskell
53− , TupleSections
58+ TupleSections
54− , TypeApplications
59+ TypeApplications
55− , TypeFamilies
60+ TypeFamilies
56− , TypeOperators
61+ TypeOperators
57− , UndecidableInstances
62+ UndecidableInstances
58− , ViewPatterns
63+ ViewPatterns
59
64
60test-suite spec
65test-suite spec
61− type: exitcode-stdio-1.0
66+ type: exitcode-stdio-1.0
62− hs-source-dirs: spec
67+ hs-source-dirs: spec
63− main-is: Test.hs
68+ main-is: Test.hs
64− other-modules: TokenSpec
69+ other-modules: TokenSpec
65− default-language: Haskell2010
70+ default-language: Haskell2010
66− build-depends: base >= 4.10 && < 5
71+ build-depends:
72+ , base >=4.10 && <5
67− , hspec
73+ , hspec
68− , random-token
74+ , random-token
75+
69 build-tool-depends: hspec-discover:hspec-discover
76 build-tool-depends: hspec-discover:hspec-discover
70− ghc-options: -Wall
77+ ghc-options:
71− -threaded
72− -rtsopts
73− "-with-rtsopts=-N -A64m -qb0 -n4m -T -I1"
78+ -Wall -threaded -rtsopts "-with-rtsopts=-N -A64m -qb0 -n4m -T -I1"
79+
74− ghc-prof-options: -fprof-auto
80+ ghc-prof-options: -fprof-auto
75− default-extensions: ConstraintKinds
81+ default-extensions:
82+ ConstraintKinds
76− , DataKinds
83+ DataKinds
77− , DeriveFoldable
84+ DeriveFoldable
78− , DeriveFunctor
85+ DeriveFunctor
79− , DeriveGeneric
86+ DeriveGeneric
80− , DeriveTraversable
87+ DeriveTraversable
81− , DuplicateRecordFields
88+ DuplicateRecordFields
82− , FlexibleContexts
89+ FlexibleContexts
83− , FlexibleInstances
90+ FlexibleInstances
84− , FunctionalDependencies
91+ FunctionalDependencies
85− , GADTs
92+ GADTs
86− , GeneralizedNewtypeDeriving
93+ GeneralizedNewtypeDeriving
87− , LambdaCase
94+ LambdaCase
88− , MultiParamTypeClasses
95+ MultiParamTypeClasses
89− , MultiWayIf
96+ MultiWayIf
90− , NumDecimals
97+ NumDecimals
91− , OverloadedStrings
98+ OverloadedStrings
92− , PolyKinds
99+ PolyKinds
93− , QuasiQuotes
100+ QuasiQuotes
94− , RankNTypes
101+ RankNTypes
95− , RecordWildCards
102+ RecordWildCards
96− , ScopedTypeVariables
103+ ScopedTypeVariables
97− , StandaloneDeriving
104+ StandaloneDeriving
98− , TemplateHaskell
105+ TemplateHaskell
99− , TupleSections
106+ TupleSections
100− , TypeApplications
107+ TypeApplications
101− , TypeFamilies
108+ TypeFamilies
102− , TypeOperators
109+ TypeOperators
103− , UndecidableInstances
110+ UndecidableInstances
104− , ViewPatterns
111+ ViewPatterns
src/Random/Token.hs+6−3
@@ -5,9 +5,11 @@ module Random.Token
5 , tokenToText
5 , tokenToText
6 , asciiToToken
6 , asciiToToken
7 , textToToken
7 , textToToken
8− , generateToken
9 , unsafeCoerceToken
8 , unsafeCoerceToken
10 , tokenWithContents
9 , tokenWithContents
10+#ifndef ghcjs_HOST_OS
11+ , generateToken
12+#endif
11 ) where
13 ) where
12
14
13import Control.DeepSeq
15import Control.DeepSeq
@@ -22,9 +24,9 @@ import Data.Typeable
22import Test.QuickCheck.Arbitrary
24import Test.QuickCheck.Arbitrary
23import Web.HttpApiData
25import Web.HttpApiData
24
26
25−import Crypto.Random as R
26
27
27#ifndef ghcjs_HOST_OS
28#ifndef ghcjs_HOST_OS
29+import Crypto.Random as R
28import Database.PostgreSQL.Simple.FromField
30import Database.PostgreSQL.Simple.FromField
29import Database.PostgreSQL.Simple.ToField
31import Database.PostgreSQL.Simple.ToField
30#endif
32#endif
@@ -54,11 +56,12 @@ instance forall a. (Typeable (Token a), Typeable a) => FromField (Token a) where
54
56
55instance ToField (Token a) where
57instance ToField (Token a) where
56 toField = toField . tokenToText
58 toField = toField . tokenToText
57−#endif
58
59
59generateToken :: (MonadRandom m) => m (Token a)
60generateToken :: (MonadRandom m) => m (Token a)
60generateToken = Token <$> R.getRandomBytes 16
61generateToken = Token <$> R.getRandomBytes 16
61
62
63+#endif
64+
62instance FromHttpApiData (Token a) where
65instance FromHttpApiData (Token a) where
63 parseQueryParam = first T.pack . textToToken
66 parseQueryParam = first T.pack . textToToken
64
67