Import
Signature
Decode a base64-encoded PAYMENT-REQUIRED header value into a PaymentRequired object. Parses the base64-encoded JSON payload received in an HTTP 402 response into a typed PaymentRequired structure without relying on Node.js binary APIs.

Parameters

string
required
Base64-encoded string from the PAYMENT-REQUIRED response header.

Returns

PaymentRequired
Decoded PaymentRequired object.

Throws

  • InvalidPaymentRequiredError: If decoding or JSON parsing fails, or the decoded shape is invalid.

Example

Source: src/index.ts