Skip to content
LogoLogo

Challenge.serialize

Serialize a Challenge to a header

Serializes a Challenge to the WWW-Authenticate header format.

Usage

import {  } from 'mppx'
 
const  = .({
  : 'abc123',
  : 'charge',
  : 'tempo',
  : 'mpp.dev',
  : { : '1000000', : '0x...', : '0x...' },
})
 
const  = .()
'Payment id="abc123", realm="mpp.dev", method="tempo", intent="charge", request="eyJhbW91bnQiOi..."'

Return type

type ReturnType = string

A string suitable for the WWW-Authenticate header value.

The serialized string includes optional fields when present: description, digest, expires, header, and opaque (server-defined correlation data set via meta in Challenge.from). header="Authorization" is omitted because Authorization is the protocol default. In HTTP headers, request and opaque are emitted as base64url-encoded JCS JSON strings.

Characters above Latin-1 in auth-param values are escaped as \uXXXX, so descriptions containing smart quotes, em dashes, emoji, or other Unicode remain valid Fetch API header values. Challenge.deserialize restores the original text.

Parameters

challenge

  • Type: Challenge

The Challenge to serialize.