# `Rivet.Auth.Refresh`
[🔗](https://github.com/srevenant/rivet-ident/blob/main/lib/auth/refresh/index.ex#L1)

Tooling for the second phase of auth: Refresh

TODO: Extract from Phoenix/WebSvc better, abstract so conn isn't needed
      This will require a module that is imported into WebSvc -BJG

# `assure`

1. extract the validaton token from the refresh token
2. decode & verify the validation token is ours & good
3. using the sub:uuid from the validation token, verify the signature on the ref token
4. update connection data (or abort)

```
iex> assure(%Auth.Domain{}, nil)
{:error, %Auth.Domain{log: "Invalid refresh request"}}
```

# `check_refresh_token`

```
iex> {:error, "narf!"} = check_refresh_token({:error, "narf!"})
```

# `extract_validation_token`

```
iex> {:error, %Auth.Domain{log: "Invalid authorization"}} = extract_validation_token({:ok, %{sub: "cas2:asdf"}}, %Auth.Domain{})
iex> {:error, %Auth.Domain{log: "Unable to match validation token subject: \"wut\""}} = extract_validation_token({:ok, "wut"}, %Auth.Domain{})
iex> {:error, %Auth.Domain{log: "narf!"}} = extract_validation_token({:error, "narf!"}, %Auth.Domain{})
```

---

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