Mailglass.Compliance.Unsubscribe (Mailglass v1.0.0)

Copy Markdown View Source

Core unsubscribe token and URL service for RFC 8058 flows.

Tokens carry only the delivery_id. Verification tries the current compliance endpoint/secret first, then each configured previous raw secret to survive secret_key_base rotation without breaking in-flight links.

Summary

Functions

Signs a delivery-only unsubscribe token with the current endpoint/secret.

Builds the canonical unsubscribe URL for a delivery.

Verifies an unsubscribe token against the current endpoint first and then any configured previous raw secrets.

Types

verify_result()

@type verify_result() ::
  {:ok, %{delivery_id: String.t()}} | {:error, :expired | :invalid}

Functions

sign_token(delivery_id)

(since 0.2.0)
@spec sign_token(String.t()) :: binary()

Signs a delivery-only unsubscribe token with the current endpoint/secret.

unsubscribe_url(delivery_id, context \\ %{})

(since 0.2.0)
@spec unsubscribe_url(String.t(), map()) :: String.t()

Builds the canonical unsubscribe URL for a delivery.

Raises %Mailglass.ConfigError{} before returning if the generated URL exceeds 900 bytes.

verify_token(token)

(since 0.2.0)
@spec verify_token(binary()) :: verify_result()

Verifies an unsubscribe token against the current endpoint first and then any configured previous raw secrets.