webfinger-client-0.2.1.0: WebFinger client library
Safe HaskellSafe-Inferred
LanguageHaskell2010

Web.Finger.Client

Description

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.

Synopsis

Documentation

data Account Source #

A given user at a given host. For example, john@example.org means the user is john and the host is example.org.

Constructors

Account 

data Resource Source #

A web resource about which you'd like to make a query.

data Auth Source #

HTTP user authentication details.

Constructors

Auth 

data Query Source #

A WebFinger query, for which the client can get a response.

In the Default instance, all fields are empty/null and there are no auth details. Therefore you must at least (but it is also enough to) specify the qryTarget URI.

Constructors

Query 

Fields

  • qryTarget :: Resource

    A URI representing an entity about which you would like to get information.

  • qryLinkRels :: [Either ByteString LinkRelation]

    A list of link relations by which to filter the link list in the returned description. If you'd like to receive all the links, leave this list empty. Use Left to specify a raw link relation string, and Right to specify a known typed relation.

  • qryHost :: Maybe ByteString

    You can explicitly specify a host (e.g. www.example.org) here, to which the WebFinger query will be sent. If you don't specify a host here, it will be extracted from the qryTarget field (if it has a host part). Therefore this field is useful in special cases where the WebFinger server isn't the one referred by the target URI, or the URI doesn't have a host.

  • qryAuth :: Maybe Auth

    HTTP authentication details. If the WebFinger server requires a username and password to access it, specify them here. For publicly available WebFinger servers, pass Nothing.

Instances

Instances details
Default Query Source # 
Instance details

Defined in Web.Finger.Client

Methods

def :: Query #

data Link Source #

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) and additional properties.

Constructors

Link 

Fields

  • lnkRelation :: Either Text LinkRelation

    The link relation type. Determines the relation between the target resource (about which the query was made) and the resource referred by the link. For example, if the target resource is a user and the linked resource is the user's avatar image, the link relation may be avatar.

    A link relation may be a URI or one of the registered relation type names. If the relation type is recognized when parsing the server's response, you will get Right a typed link relation here. Otherwise, e.g. if a non-URL private application-specific relation type is found, you will get Left the raw relation type string.

  • lnkMediaType :: Maybe Text

    The MIME type to be expected of the content behind the link URI. For example, if the link refers to a user's avatar image, the MIME type may be image/png (i.e. an image file in PNG format).

  • lnkAddress :: Maybe Text

    The link address itself. It is optional, because there may be cases in which all the information about the link is provided by the properties (the lnkProperties field). For example, if the link is a user's avatar image, the address may be https://example.org/users/john/avatar.png.

  • lnkTitles :: HashMap Language Text

    Optional title(s) for the link, possibly in various languages.

  • lnkProperties :: HashMap Text (Maybe Text)

    Additional properties the link may have. Maps property names, which are URIs, to string values.

Instances

data Description Source #

Information about the target resource, returned when a query succeeds.

Constructors

Description 

Fields

  • desSubject :: Maybe Text

    A URI representing the resource being described. This is the same resource specified in the query, but the URI may slightly differ (e.g. appear in canonical form).

  • desAliases :: [Text]

    List of URIs which identify the same resource as the desSubject URI.

  • desProperties :: HashMap Text (Maybe Text)

    Additional information about the subject. Maps property names, which are URIs, to string values.

  • desLinks :: [Link]

    Links of various relation types from the subject resource to other resources represented by URIs.

data Result Source #

Response to the query.

Constructors

Success Description

The WebFinger server returned a valid resource description.

InvalidDesc String

The server returned a description but we failed to parse it.

NoInfoFound

The server doesn't have information about the query target.

TargetMalformed

The server says the target URI is either absent from the HTTP request, or is malformed.

HostNotDetected String

We (client side) couldn't determine the host to which to send the query. This usually means no host was explicitly specified, and the attempt to extract the host from the query target resource failed.

Instances

Instances details
Show Result Source # 
Instance details

Defined in Web.Finger.Client

newManager :: IO Manager Source #

A connection manager, see Network.HTTP.Client for details. This function creates a manager which can handle HTTPS, which is required for WebFinger and regular HTTP isn't allowed. If you'd like to make queries in other ways which require more support (e.g. perhaps Tor), create your own manager instead using one of the http-client-* packages.

webfinger Source #

Arguments

:: Manager

Connection manager. See newManager.

-> Query

A query expressing what you'd like to know, and whom to ask.

-> IO Result 

Send a WebFinger query over HTTPS to a WebFinger server, and get a response.

Some HTTP exceptions which represent common query results are caught and used to determine the return value, i.e. the Result. All other HTTP exceptions aren't handled.

data Language Source #

Natural Language code. Used to express in which language a text string is written.

Instances

Instances details
Generic Language Source # 
Instance details

Defined in Web.Finger.Client

Associated Types

type Rep Language :: Type -> Type #

Methods

from :: Language -> Rep Language x #

to :: Rep Language x -> Language #

Show Language Source # 
Instance details

Defined in Web.Finger.Client

Eq Language Source # 
Instance details

Defined in Web.Finger.Client

Hashable Language Source # 
Instance details

Defined in Web.Finger.Client

Methods

hashWithSalt :: Int -> Language -> Int #

hash :: Language -> Int #

FromJSON Language Source # 
Instance details

Defined in Web.Finger.Client

FromJSONKey Language Source # 
Instance details

Defined in Web.Finger.Client

type Rep Language Source # 
Instance details

Defined in Web.Finger.Client

type Rep Language = D1 ('MetaData "Language" "Web.Finger.Client" "webfinger-client-0.2.1.0-inplace" 'False) (C1 ('MetaCons "LanguageCode" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: C1 ('MetaCons "LanguageUndefined" 'PrefixI 'False) (U1 :: Type -> Type))