packages feed

webfinger-client 0.2.0.0 → 0.2.1.0

raw patch · 5 files changed

+109/−30 lines, 5 filesdep ~aesondep ~basedep ~bytestringnew-uploader

Dependency ranges changed: aeson, base, bytestring, data-default-class, hashable, http-client, http-client-tls, http-types, link-relations, text, unordered-containers, uri-bytestring

Files

AUTHORS view
@@ -1,1 +1,3 @@ fr33domlover <fr33domlover@riseup.net>+Joonkyu Park <vpark45@gmail.com>+
NEWS.md view
@@ -3,6 +3,32 @@   +webfinger-client 0.2.1.0 -- 2025-05-05+======================================++General, build and documentation changes:+* Added Joonkyu Park to AUTHORS.+* Updated README.md with example usage of the webfinger-client library.+* Bumped version to 0.2.1.0 in webfinger-client.cabal due to the new export +  of the `Language` type.+* Updated homepage and bug-reports URLs in webfinger-client.cabal.+* Added Joonkyu Park as a maintainer in webfinger-client.cabal.+* Joonkyu Park has been approved as a maintainer by Hackage administrator +  as of 2025-05-05.++New APIs, features and enhancements:+* Explicitly exported the `Language` type from `Web.Finger.Client`.++Bug fixes:+* (None)++Dependency changes:+* (None)+++++ webfinger-client 0.2.0.0 -- 2016-01-28 ====================================== 
README.md view
@@ -12,3 +12,31 @@ See the file 'INSTALL' for hints on installation. The file 'ChangeLog' explains how to see the history log of the changes done in the code. 'NEWS' provides a friendly overview of the changes for each release.++## Example Usage++Here is a simple example of how to use the `webfinger-client` library:++```haskell+{-# LANGUAGE OverloadedStrings #-}++module Main where++import Data.Default+import Web.Finger.Client++query :: Query+query = def { qryTarget = resource }+  where+    resource = ResAccount (Account "curry" "hackers.pub")++main :: IO ()+main = do+  manager <- newManager+  result <- webfinger manager query+  print result+```++This code uses the WebFinger protocol to query information about a specified+resource and prints the result. The qryTarget is set to an Account, and in+this example, it queries the account "curry" on the domain hackers.pub.
src/Web/Finger/Client.hs view
@@ -25,6 +25,28 @@ -- For avoiding redundant imports in base 4.8 {-# LANGUAGE CPP #-} +-- | A Haskell client library for performing WebFinger queries.+--+-- This module provides functions and data types for constructing and sending+-- WebFinger queries over HTTPS. It allows users to query information about+-- various resources, such as accounts or URIs, and retrieve associated metadata+-- as described in the WebFinger protocol.+--+-- The main entry points are:+--+-- * 'webfinger' – Sends a WebFinger query and returns a structured response.+-- * 'newManager' – Creates an HTTPS connection manager required for making requests.+--+-- The core data types include:+--+-- * 'Query' – Represents a WebFinger query.+-- * 'Resource' – Specifies the entity being queried.+-- * 'Description' – Contains the response data from a WebFinger query.+-- * 'Link' – Represents links returned in a WebFinger response.+-- * 'Language' – Defines language codes used in WebFinger responses.+--+-- This module depends on 'http-client' and 'aeson' for handling HTTP requests+-- and JSON parsing. module Web.Finger.Client     ( Account (..)     , Resource (..)@@ -35,6 +57,7 @@     , Result (..)     , newManager     , webfinger+    , Language     ) where @@ -49,7 +72,6 @@ import Data.Default.Class import Data.Hashable import Data.HashMap.Lazy (HashMap)-import Data.Monoid ((<>)) import Data.Text (Text) import Data.Text.Encoding (encodeUtf8) import GHC.Generics (Generic)@@ -148,17 +170,19 @@  instance Hashable Language +instance FromJSON Language where+    parseJSON (String t) = pure (toLang t)+    parseJSON v = typeMismatch "Language" v++instance FromJSONKey Language where+    fromJSONKey = FromJSONKeyText toLang+ toLang :: Text -> Language toLang t =     if t == "und"         then LanguageUndefined         else LanguageCode t -instance FromJSON (HashMap Language Text) where-    parseJSON v = M.fromList . map f . M.toList <$> parseJSON v-        where-        f (l, t) = (toLang l, t)- -- | Represents a link from the target resource to some other web resource. -- This is more than a simple webpage link: It also has a relation type (i.e. -- what is the relation between the target resource and the referred resource)@@ -280,7 +304,7 @@     , Right $ acctHost a                         -- do i need to escape host? does http-client do it anyway?     ) parseResource (ResUri u) =-    ( U.serializeURI' u+    ( U.serializeURIRef' u     , getHost u     ) parseResource (ResUriStr s) =@@ -316,7 +340,7 @@     in  case eith' of             Left err -> return $ HostNotDetected err             Right host -> do-                let req = def+                let req = H.defaultRequest                         { H.method         = HT.methodGet                         , H.secure         = True                         , H.host           = host@@ -337,11 +361,10 @@                 case eresp of                     Left e ->                         case e :: H.HttpException of-                            H.StatusCodeException s _ _-                                | s == HT.badRequest400 ->-                                    return TargetMalformed-                                | s == HT.notFound404   -> return NoInfoFound-                                | otherwise             -> throwIO e+                            H.HttpExceptionRequest _ (H.StatusCodeException resp _)+                                | H.responseStatus resp == HT.badRequest400 -> return TargetMalformed+                                | H.responseStatus resp == HT.notFound404   -> return NoInfoFound+                                | otherwise                                 -> throwIO e                             _ -> throwIO e                     Right resp ->                         return $ case eitherDecode $ H.responseBody resp of
webfinger-client.cabal view
@@ -1,16 +1,16 @@ name:                webfinger-client-version:             0.2.0.0+version:             0.2.1.0 synopsis:            WebFinger client library description:   This is a client library for querying a   <https://webfinger.net WebFinger>   resource and parsing the response.-homepage:            http://hub.darcs.net/fr33domlover/webfinger-client-bug-reports:         http://hub.darcs.net/fr33domlover/webfinger-client/issues+homepage:            http://hub.darcs.net/vincent/webfinger-client+bug-reports:         http://hub.darcs.net/vincent/webfinger-client/issues license:             PublicDomain license-file:        COPYING author:              fr33domlover-maintainer:          fr33domlover@riseup.net+maintainer:          fr33domlover@riseup.net, vpark45@gmail.com copyright:           ♡ Copying is an act of love. Please copy, reuse and share. category:            Network, Web build-type:          Simple@@ -19,24 +19,24 @@  source-repository head   type:                darcs-  location:            http://hub.darcs.net/fr33domlover/webfinger-client+  location:            http://hub.darcs.net/vincent/webfinger-client  library   exposed-modules:     Web.Finger.Client   -- other-modules:          -- other-extensions:    -  build-depends:       aeson                >=0.7-                     , base                 >=4.7 && <5-                     , bytestring-                     , data-default-class-                     , hashable-                     , http-client          >=0.3.6-                     , http-client-tls      >=0.2.2-                     , http-types-                     , link-relations-                     , text-                     , unordered-containers >=0.2.5-                     , uri-bytestring       >=0.1.7+  build-depends:       aeson                >= 2.2.3  && < 2.3+                     , base                 >= 4.17.2 && < 4.18+                     , bytestring           >= 0.11.5 && < 0.12+                     , data-default-class   >= 0.2.0  && < 0.3+                     , hashable             >= 1.4.7  && < 1.5+                     , http-client          >= 0.7.18 && < 0.8+                     , http-client-tls      >= 0.3.6  && < 0.4+                     , http-types           >= 0.12.4 && < 0.13+                     , link-relations       >= 0.1.1  && < 0.2+                     , text                 >= 2.0.2  && < 2.1+                     , unordered-containers >= 0.2.20 && < 0.3+                     , uri-bytestring       >= 0.4.0  && < 0.5   hs-source-dirs:      src   default-language:    Haskell2010   ghc-options:         -Wall