ory-kratos 0.0.5.6 → 0.0.5.7
raw patch · 4 files changed
+121/−70 lines, 4 files
Files
- lib/OryKratos/API.hs +7/−4
- lib/OryKratos/Types.hs +77/−58
- ory-kratos.cabal +33/−8
- test/Spec.hs +4/−0
lib/OryKratos/API.hs view
@@ -10,6 +10,7 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE ViewPatterns #-}+{-# LANGUAGE DerivingStrategies #-} {-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-unused-imports -freduction-depth=328 #-} @@ -72,7 +73,9 @@ -- | List of elements parsed from a query. newtype QueryList (p :: CollectionFormat) a = QueryList { fromQueryList :: [a]- } deriving (Functor, Applicative, Monad, Foldable, Traversable)+ } + deriving stock (Traversable)+ deriving newtype (Functor, Applicative, Monad, Foldable) -- | Formats in which a list can be encoded into a HTTP path. data CollectionFormat@@ -164,12 +167,12 @@ -- | Server or client configuration, specifying the host and port to query or serve on. data Config = Config { configUrl :: String -- ^ scheme://hostname:port/path, e.g. "http://localhost:8080/"- } deriving (Eq, Ord, Show, Read)+ } deriving stock (Eq, Ord, Show, Read) -- | Custom exception type for our errors. newtype OryKratosClientError = OryKratosClientError ClientError- deriving (Show, Exception)+ deriving newtype (Show, Exception) -- | Configuration, specifying the full url of the service. @@ -219,7 +222,7 @@ newtype OryKratosClient a = OryKratosClient { runClient :: ClientEnv -> ExceptT ClientError IO a- } deriving Functor+ } deriving stock (Functor) instance Applicative OryKratosClient where pure x = OryKratosClient (\_ -> pure x)
lib/OryKratos/Types.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DuplicateRecordFields #-}@@ -64,6 +65,10 @@ import Data.UUID (UUID) import GHC.Generics (Generic) +typeFieldRename :: String -> String+typeFieldRename "_type" = "type"+typeFieldRename x = x+ -- | data CompleteSelfServiceLoginFlowWithPasswordMethod = CompleteSelfServiceLoginFlowWithPasswordMethod { -- | Sending the anti-csrf token is only required for browser login flows.@@ -73,7 +78,7 @@ -- | The user's password. password :: Maybe Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON CompleteSelfServiceLoginFlowWithPasswordMethod @@ -87,7 +92,7 @@ -- | Email to Recover Needs to be set when initiating the flow. If the email is a registered recovery email, a recovery link will be sent. If the email is not known, a email with details on what happened will be sent instead. format: email in: body email :: Maybe Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON CompleteSelfServiceRecoveryFlowWithLinkMethod @@ -101,7 +106,7 @@ -- | Password is the updated password type: string password :: Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON CompleteSelfServiceSettingsFlowWithPasswordMethod @@ -115,7 +120,7 @@ -- | Email to Verify Needs to be set when initiating the flow. If the email is a registered verification email, a verification link will be sent. If the email is not known, a email with details on what happened will be sent instead. format: email in: body email :: Maybe Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON CompleteSelfServiceVerificationFlowWithLinkMethod @@ -129,7 +134,7 @@ -- | Traits represent an identity's traits. The identity is able to create, modify, and delete traits in a self-service manner. The input will always be validated against the JSON Schema defined in `schema_url`. traits :: Value }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON CreateIdentity @@ -143,7 +148,7 @@ -- | identity_id :: Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON CreateRecoveryLink @@ -157,7 +162,7 @@ -- | id :: Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON ErrorContainer @@ -181,20 +186,22 @@ -- | Value is the equivalent of `<input value=\"{{.Value}}\">` value :: Maybe Value }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON FormField where parseJSON = genericParseJSON defaultOptions- { constructorTagModifier = \f -> if f == "_type" then "type" else f+ { constructorTagModifier = typeFieldRename,+ fieldLabelModifier = typeFieldRename } instance ToJSON FormField where toEncoding = genericToEncoding defaultOptions- { constructorTagModifier = \f -> if f == "_type" then "type" else f+ { constructorTagModifier = typeFieldRename,+ fieldLabelModifier = typeFieldRename } -- | Error responses are sent when an error (e.g. unauthorized, bad request, ...) occurred.@@ -202,7 +209,7 @@ { -- | error :: Maybe GenericErrorPayload }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON GenericError @@ -226,7 +233,7 @@ -- | status :: Maybe Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON GenericErrorPayload @@ -238,7 +245,7 @@ { -- | Errors contains a list of errors that caused the not ready status. errors :: Maybe (Map.Map String Text) }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON HealthNotReadyStatus @@ -250,7 +257,7 @@ { -- | Status always contains \"ok\". status :: Maybe Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON HealthStatus @@ -272,7 +279,7 @@ -- | VerifiableAddresses contains all the addresses that can be verified by the user. verifiable_addresses :: Maybe [VerifiableAddress] }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON Identity @@ -294,26 +301,28 @@ -- | messages :: Maybe [Message], -- | List of login methods This is the list of available login methods with their required form fields, such as `identifier` and `password` for the password login method. This will also contain error messages such as \"password can not be empty\".- methods :: (Map.Map String LoginFlowMethod),+ methods :: Map.Map String LoginFlowMethod, -- | RequestURL is the initial URL that was requested from ORY Kratos. It can be used to forward information contained in the URL's path or query for example. request_url :: Text, -- | The flow type can either be `api` or `browser`. _type :: Maybe Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON LoginFlow where parseJSON = genericParseJSON defaultOptions- { constructorTagModifier = \f -> if f == "_type" then "type" else f+ { constructorTagModifier = typeFieldRename,+ fieldLabelModifier = typeFieldRename } instance ToJSON LoginFlow where toEncoding = genericToEncoding defaultOptions- { constructorTagModifier = \f -> if f == "_type" then "type" else f+ { constructorTagModifier = typeFieldRename,+ fieldLabelModifier = typeFieldRename } -- |@@ -323,7 +332,7 @@ -- | and so on. method :: Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON LoginFlowMethod @@ -343,7 +352,7 @@ -- | Providers is set for the \"oidc\" flow method. providers :: Maybe [FormField] }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON LoginFlowMethodConfig @@ -357,7 +366,7 @@ -- | The Session Token A session token is equivalent to a session cookie, but it can be sent in the HTTP Authorization Header: Authorization: bearer ${session-token} The session token is only issued for API flows, not for Browser flows! session_token :: Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON LoginViaApiResponse @@ -375,20 +384,22 @@ -- | The flow type can either be `api` or `browser`. _type :: Maybe Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON Message where parseJSON = genericParseJSON defaultOptions- { constructorTagModifier = \f -> if f == "_type" then "type" else f+ { constructorTagModifier = typeFieldRename,+ fieldLabelModifier = typeFieldRename } instance ToJSON Message where toEncoding = genericToEncoding defaultOptions- { constructorTagModifier = \f -> if f == "_type" then "type" else f+ { constructorTagModifier = typeFieldRename,+ fieldLabelModifier = typeFieldRename } -- |@@ -400,7 +411,7 @@ -- | via :: Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON RecoveryAddress @@ -420,7 +431,7 @@ -- | messages :: Maybe [Message], -- | Methods contains context for all account recovery methods. If a registration request has been processed, but for example the password is incorrect, this will contain error messages.- methods :: (Map.Map String RecoveryFlowMethod),+ methods :: Map.Map String RecoveryFlowMethod, -- | RequestURL is the initial URL that was requested from ORY Kratos. It can be used to forward information contained in the URL's path or query for example. request_url :: Text, -- |@@ -428,20 +439,22 @@ -- | The flow type can either be `api` or `browser`. _type :: Maybe Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON RecoveryFlow where parseJSON = genericParseJSON defaultOptions- { constructorTagModifier = \f -> if f == "_type" then "type" else f+ { constructorTagModifier = typeFieldRename,+ fieldLabelModifier = typeFieldRename } instance ToJSON RecoveryFlow where toEncoding = genericToEncoding defaultOptions- { constructorTagModifier = \f -> if f == "_type" then "type" else f+ { constructorTagModifier = typeFieldRename,+ fieldLabelModifier = typeFieldRename } -- |@@ -451,7 +464,7 @@ -- | Method contains the request credentials type. method :: Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON RecoveryFlowMethod @@ -469,7 +482,7 @@ -- | Method is the form method (e.g. POST) method :: Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON RecoveryFlowMethodConfig @@ -483,7 +496,7 @@ -- | Recovery Link This link can be used to recover the account. recovery_link :: Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON RecoveryLink @@ -503,26 +516,28 @@ -- | messages :: Maybe [Message], -- | Methods contains context for all enabled registration methods. If a registration flow has been processed, but for example the password is incorrect, this will contain error messages.- methods :: (Map.Map String RegistrationFlowMethod),+ methods :: Map.Map String RegistrationFlowMethod, -- | RequestURL is the initial URL that was requested from ORY Kratos. It can be used to forward information contained in the URL's path or query for example. request_url :: Text, -- | The flow type can either be `api` or `browser`. _type :: Maybe Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON RegistrationFlow where parseJSON = genericParseJSON defaultOptions- { constructorTagModifier = \f -> if f == "_type" then "type" else f+ { constructorTagModifier = typeFieldRename,+ fieldLabelModifier = typeFieldRename } instance ToJSON RegistrationFlow where toEncoding = genericToEncoding defaultOptions- { constructorTagModifier = \f -> if f == "_type" then "type" else f+ { constructorTagModifier = typeFieldRename,+ fieldLabelModifier = typeFieldRename } -- |@@ -532,7 +547,7 @@ -- | and so on. method :: Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON RegistrationFlowMethod @@ -552,7 +567,7 @@ -- | Providers is set for the \"oidc\" registration method. providers :: Maybe [FormField] }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON RegistrationFlowMethodConfig @@ -568,7 +583,7 @@ -- | The Session Token This field is only set when the session hook is configured as a post-registration hook. A session token is equivalent to a session cookie, but it can be sent in the HTTP Authorization Header: Authorization: bearer ${session-token} The session token is only issued for API flows, not for Browser flows! session_token :: Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON RegistrationViaApiResponse @@ -580,7 +595,7 @@ { -- | The Session Token Invalidate this session token. session_token :: Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON RevokeSession @@ -602,7 +617,7 @@ -- | issued_at :: UTCTime }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON Session @@ -624,7 +639,7 @@ -- | messages :: Maybe [Message], -- | Methods contains context for all enabled registration methods. If a settings flow has been processed, but for example the first name is empty, this will contain error messages.- methods :: (Map.Map String SettingsFlowMethod),+ methods :: Map.Map String SettingsFlowMethod, -- | RequestURL is the initial URL that was requested from ORY Kratos. It can be used to forward information contained in the URL's path or query for example. request_url :: Text, -- |@@ -632,20 +647,22 @@ -- | The flow type can either be `api` or `browser`. _type :: Maybe Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON SettingsFlow where parseJSON = genericParseJSON defaultOptions- { constructorTagModifier = \f -> if f == "_type" then "type" else f+ { constructorTagModifier = typeFieldRename,+ fieldLabelModifier = typeFieldRename } instance ToJSON SettingsFlow where toEncoding = genericToEncoding defaultOptions- { constructorTagModifier = \f -> if f == "_type" then "type" else f+ { constructorTagModifier = typeFieldRename,+ fieldLabelModifier = typeFieldRename } -- |@@ -655,7 +672,7 @@ -- | Method is the name of this flow method. method :: Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON SettingsFlowMethod @@ -673,7 +690,7 @@ -- | Method is the form method (e.g. POST) method :: Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON SettingsFlowMethodConfig @@ -687,7 +704,7 @@ -- | identity :: Identity }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON SettingsViaApiResponse @@ -701,7 +718,7 @@ -- | Traits represent an identity's traits. The identity is able to create, modify, and delete traits in a self-service manner. The input will always be validated against the JSON Schema defined in `schema_id`. traits :: Value }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON UpdateIdentity @@ -723,7 +740,7 @@ -- | via :: Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON VerifiableAddress @@ -743,7 +760,7 @@ -- | messages :: Maybe [Message], -- | Methods contains context for all account verification methods. If a registration request has been processed, but for example the password is incorrect, this will contain error messages.- methods :: (Map.Map String VerificationFlowMethod),+ methods :: Map.Map String VerificationFlowMethod, -- | RequestURL is the initial URL that was requested from ORY Kratos. It can be used to forward information contained in the URL's path or query for example. request_url :: Maybe Text, -- |@@ -751,20 +768,22 @@ -- | The flow type can either be `api` or `browser`. _type :: Maybe Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON VerificationFlow where parseJSON = genericParseJSON defaultOptions- { constructorTagModifier = \f -> if f == "_type" then "type" else f+ { constructorTagModifier = typeFieldRename,+ fieldLabelModifier = typeFieldRename } instance ToJSON VerificationFlow where toEncoding = genericToEncoding defaultOptions- { constructorTagModifier = \f -> if f == "_type" then "type" else f+ { constructorTagModifier = typeFieldRename,+ fieldLabelModifier = typeFieldRename } -- |@@ -774,7 +793,7 @@ -- | Method contains the request credentials type. method :: Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON VerificationFlowMethod @@ -792,7 +811,7 @@ -- | Method is the form method (e.g. POST) method :: Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON VerificationFlowMethodConfig @@ -804,7 +823,7 @@ { -- | Version is the service's version. version :: Maybe Text }- deriving (Show, Eq, Generic, Data)+ deriving stock (Show, Eq, Generic, Data) instance FromJSON Version
ory-kratos.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: ory-kratos-version: 0.0.5.6+version: 0.0.5.7 synopsis: API bindings for Ory Kratos description: Auto-generated API bindings for ory-kratos 0.5.5-alpha1 homepage: https://github.com/njaremko/ory-kratos-haskell-sdk@@ -11,13 +11,7 @@ build-type: Simple license: Apache-2.0 -library- hs-source-dirs: lib- exposed-modules:- OryKratos.API- OryKratos.Types-- ghc-options: -Wall+common common-options build-depends: , aeson >=1.4.7 && < 1.6 , base ^>=4.14.0.0@@ -40,5 +34,36 @@ , uuid >=1.3.13 && <1.4 , wai >=3.2.2 && <3.3 , warp >=3.3.13 && <3.4+ + ghc-options: -Wall+ -Wcompat+ -Widentities+ -Wincomplete-uni-patterns+ -Wincomplete-record-updates+ if impl(ghc >= 8.0)+ ghc-options: -Wredundant-constraints+ if impl(ghc >= 8.2)+ ghc-options: -fhide-source-paths+ if impl(ghc >= 8.4)+ ghc-options: -Wmissing-export-lists+ -Wpartial-fields+ if impl(ghc >= 8.8)+ ghc-options: -Wmissing-deriving-strategies default-language: Haskell2010++library+ import: common-options+ hs-source-dirs: lib+ exposed-modules:+ OryKratos.API+ OryKratos.Types++test-suite ory-kratos-test+ import: common-options+ type: exitcode-stdio-1.0+ hs-source-dirs: test+ main-is: Spec.hs+ ghc-options: -threaded+ -rtsopts+ -with-rtsopts=-N
+ test/Spec.hs view
@@ -0,0 +1,4 @@+module Main (main) where++main :: IO ()+main = putStrLn ("Test suite is not implemented" :: String)