# `Ex2FA.URI`
[🔗](https://github.com/Ultraluv/ex_2FA/blob/v0.1.0/lib/ex_2fa/uri.ex#L1)

Generates standard Key URI Format (`otpauth://`) provisioning URIs for TOTP
and HOTP authenticator apps (Google Authenticator, 1Password, Authy, etc.),
as well as the legacy Google Charts QR URL compatible with `nio_google_authenticator`.

# `hotp_option`

```elixir
@type hotp_option() ::
  {:issuer, binary() | nil}
  | {:algorithm, :sha | :sha1 | :sha256 | :sha512}
  | {:digest_method, :sha | :sha1 | :sha256 | :sha512}
  | {:digits, pos_integer()}
  | {:token_length, pos_integer()}
```

# `totp_option`

```elixir
@type totp_option() ::
  {:issuer, binary() | nil}
  | {:algorithm, :sha | :sha1 | :sha256 | :sha512}
  | {:digest_method, :sha | :sha1 | :sha256 | :sha512}
  | {:digits, pos_integer()}
  | {:token_length, pos_integer()}
  | {:period, pos_integer()}
  | {:interval_length, pos_integer()}
```

# `hotp`

```elixir
@spec hotp(binary(), binary(), non_neg_integer(), [hotp_option()]) :: binary()
```

Generates a standard `otpauth://hotp/...` provisioning URI.

## Options

  * `:issuer` - provider or service name
  * `:algorithm` (alias `:digest_method`) - `:sha` (`:sha1`), `:sha256`, or `:sha512`
  * `:digits` (alias `:token_length`) - number of digits (included when not `6`)

# `legacy_google_qr_url`

```elixir
@spec legacy_google_qr_url(binary(), binary(), binary() | nil) :: binary()
```

Generates the Google Charts QR code URL in the exact format produced by
`nio_google_authenticator`.

> Note: Google deprecated the `chart.googleapis.com` QR endpoint. For new
> applications, prefer `Ex2FA.otpauth_uri/3` paired with a local QR code
> library such as `eqrcode`.

# `totp`

```elixir
@spec totp(binary(), binary(), [totp_option()]) :: binary()
```

Generates a standard `otpauth://totp/...` provisioning URI.

## Options

  * `:issuer` - provider or service name (defaults to configured `:issuer` if omitted)
  * `:algorithm` (alias `:digest_method`) - `:sha` (`:sha1`), `:sha256`, or `:sha512` (included in URI when set to a non-default algorithm)
  * `:digits` (alias `:token_length`) - number of digits (included when not `6`)
  * `:period` (alias `:interval_length`) - time step in seconds (included when not `30`)

## Examples

    iex> Ex2FA.URI.totp("JBSWY3DPEHPK3PXP", "alice@example.com", issuer: "MyApp")
    "otpauth://totp/MyApp:alice%40example.com?secret=JBSWY3DPEHPK3PXP&issuer=MyApp"

---

*Consult [api-reference.md](api-reference.md) for complete listing*
