Identity.Status
Fixed statuses for identity rejections
Fixed HTTP status codes for rejected identity outcomes, and the precedence that decides between several rejections.
Usage
import * as from 'mppx/identity'
.(...)
403 .(..)
['forbidden', 'unavailable', 'invalid', 'missing']Statuses
| Status | HTTP | Meaning |
|---|---|---|
missing | 401 | No proof was presented |
invalid | 401 | A proof was presented but didn't verify |
forbidden | 403 | The proof verified, but the identity isn't allowed |
unavailable | 503 | The proof can't be checked right now, such as during an issuer outage |
- A verifier returns
validwith a value, or one of these statuses. Type:Identity.RejectionStatus. - A rejected route returns the deciding status's code, the reason as the body,
Cache-Control: no-store, and the verifiers' headers. It never returns a fresh402. - The route result marks the rejection as
result.rejection({ stage, status, reason }) on its non-200branch. SeeMppx.create. - An unknown status counts as
invalid, so a broken verifier fails closed.
Precedence
When several verifiers reject, or every Identity.anyOf member does:
- The first status in
precedencedecides the status and reason. On ties, the first rejecting verifier wins. - The headers of every rejection are merged into the response.
For example, a forbidden rejection from one verifier outranks a missing one from another, so the route returns 403.
Deprecated code
missing and invalid outcomes still accept a deprecated code: 403 maps to forbidden, 503 to unavailable, and any other HTTP error code is sent as is. Return status: 'forbidden' or status: 'unavailable' instead.
Return type
type Status = {
codes: {
forbidden: 403
invalid: 401
missing: 401
unavailable: 503
}
precedence: readonly ['forbidden', 'unavailable', 'invalid', 'missing']
}