# `NeedleApple.Signed`
[🔗](https://github.com/zlibex/needle_apple/blob/v0.1.1/lib/needle_apple/signed.ex#L1)

Utilities for handling signed payload.

# `payload`

```elixir
@type payload() :: map()
```

The verified payload extracted from signed payload.

# `root_cert`

```elixir
@type root_cert() :: binary()
```

The root certificate that Apple offers on [Apple PKI](https://www.apple.com/certificateauthority/).

It's fine to use _Apple Root CA - G3 Root_.

# `signed_payload`

```elixir
@type signed_payload() :: String.t()
```

A cryptographically signed payload, in JSON Web Signature (JWS) format.

# `verify`

```elixir
@spec verify(root_cert(), signed_payload()) ::
  {:ok, payload()}
  | {:error, :invalid_format | :invalid_cert_chain | :invalid_signature}
```

Verifies a signed payload.

Signed payloads are used in the responses of:

  * [App Store Server API](https://developer.apple.com/documentation/appstoreserverapi)
  * [App Store Server Notifications](https://developer.apple.com/documentation/appstoreservernotifications)
  * ...

## References

  * https://github.com/potatosalad/erlang-jose/issues/63#issuecomment-1038751471
  * https://andrealeopardi.com/posts/verifying-apple-jwts/

---

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