Library.HaveIBeenPwned (Portico/Z v0.1.0)

Context for accessing HaveIBeenPwned API functions

Requires config.exs to have a setup incantation like so:

config :library, 
  Library.HaveIBeenPwned: [
    api_key: "yer key"
  ]

Link to this section Summary

Functions

Check an account against breached accounts in HIBP

Just for fun, we can retrieve all of the breaches in the HIBP system.

Link to this section Functions

Link to this function

breached_account(account, opts \\ [])

Specs

breached_account(String.t(), Keyword.t()) :: any() | {:error, any()}

Check an account against breached accounts in HIBP

Works with emails, etc.

Options

This function accepts the following opts as a Keyword list (which mirror the HIBP API).

  • truncateResponse (boolean - defaults to false) - Optionally simplify the response.
  • domain (string) - A specific domain against which to check responses
  • includeUnverified (boolean - defaults to true) - Return breaches that have been flagged as "unverified".

Examples

iex> Library.HaveIBeenPwned.breached_account("opt-out@hibp-integration-tests.com")
"" 

iex> pwns = Library.HaveIBeenPwned.breached_account("account-exists@hibp-integration-tests.com")
iex> Enum.at(pwns, 0)
%{"Name" => "Adobe"}

iex> pwns = Library.HaveIBeenPwned.breached_account("account-exists@hibp-integration-tests.com", truncateResponse: false)
iex> pwns |> Enum.at(0) |> Map.get("DataClasses")
["Email addresses", "Password hints", "Passwords", "Usernames"]
Link to this function

breaches(opts \\ [])

Specs

breaches(Keyword.t()) :: any() | {:error, any()}

Just for fun, we can retrieve all of the breaches in the HIBP system.

Options

This function accepts the following opts as a Keyword list (which mirror the HIBP API).

  • domain (string) - Filter the result set to only the specified domain