defmodule Turnstile do @behaviour Turnstile.Behaviour @moduledoc """ Use Cloudflare Turnstile in Phoenix. Check out the [README](readme.html) to get started. """ import Phoenix.Component alias Phoenix.LiveView @script_url "https://challenges.cloudflare.com/turnstile/v0/api.js" @verify_url "https://challenges.cloudflare.com/turnstile/v0/siteverify" @impl true @doc """ Returns the configured site key. """ def site_key, do: Application.get_env(:phoenix_turnstile, :site_key, "1x00000000000000000000AA") @impl true @doc """ Returns the configured secret key. """ def secret_key, do: Application.get_env(:phoenix_turnstile, :secret_key, "1x0000000000000000000000000000000AA") @doc """ Renders the Turnstile script tag. Uses explicit rendering so it works with hooks. Additional attributes will be passed through to the script tag. """ def script(assigns) do assigns = assigns |> assign(:url, @script_url) |> assign(:rest, assigns_to_attributes(assigns, [:noHook])) ~H"""