# `DialectoInContext.LaunchToken`
[🔗](https://github.com/dialecto-eu/dialecto-phoenix/blob/v0.1.0/lib/dialecto_in_context/launch_token.ex#L1)

Verifies the launch token Dialecto mints for an editor (spec-0025 §3), with
no call to Dialecto:

    token  = base64url(payload) "." base64url(signature)
    signed = "dialecto-live-edit-v1." base64url(payload)

The signature is Ed25519 under the repo's key. The purpose prefix keeps a
signature made for another purpose (a release manifest, say) from verifying
here. Pure: the caller passes the key, the site's origin and the time.

# `claims`

```elixir
@type claims() :: %{required(String.t()) =&gt; term()}
```

# `phase`

```elixir
@type phase() :: :start | :session
```

# `reason`

```elixir
@type reason() ::
  :malformed | :bad_signature | :expired | :late | :wrong_origin | :wrong_repo
```

# `expires_at`

```elixir
@spec expires_at(claims()) :: integer()
```

The Unix time the token's session ends.

# `verify`

```elixir
@spec verify(term(), binary(), String.t(), integer(), phase(), String.t() | nil) ::
  {:ok, claims()} | {:error, reason()}
```

Checks `token` against `public_key` (32 bytes), the configured `origin` and
`now` (Unix seconds). `phase` is `:start` when the token first arrives, which
also requires `start_by` not to have passed, or `:session` for the cookie
on later requests, which only needs `exp`. With `repo` (`"owner/name"`) the
token's repo claim must match it, ignoring case: a cheap check against a key
pasted from the wrong repo.

---

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