Skip to content
LogoLogo

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

StatusHTTPMeaning
missing401No proof was presented
invalid401A proof was presented but didn't verify
forbidden403The proof verified, but the identity isn't allowed
unavailable503The proof can't be checked right now, such as during an issuer outage
  • A verifier returns valid with 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 fresh 402.
  • The route result marks the rejection as result.rejection ({ stage, status, reason }) on its non-200 branch. See Mppx.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 precedence decides 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']
}