Challenge.fromMethod
Create a Challenge from a method
Creates a validated Challenge from a method definition.
Load secretKey from your server environment or secret manager. Do not ship it to clients.
Usage
import { } from 'mppx'
import { } from 'mppx/tempo'
const = ..!
const = .(
.,
{
: 'mpp.dev',
: {
: '1',
: '0x20c0000000000000000000000000000000000001',
: 6,
: '0x742d35Cc6634C0532925a3b844Bc9e7595f8fE00',
},
,
},
)Return type
type ReturnType = Challenge<RequestOutput>A Challenge typed to the method's request schema output.
Parameters
description (optional)
- Type:
string
Human-readable description of the payment.
digest (optional)
- Type:
string
Digest of the request body.
expires (optional)
- Type:
string
Expiration timestamp (ISO 8601).
id (when not using secretKey)
- Type:
string
Explicit Challenge ID.
meta (optional)
- Type:
Record<string, string>
Server-defined correlation data. mppx serializes it as the base64url-encoded opaque auth-param in HTTP Challenges.
method
- Type:
Method
The method definition to validate against (for example, Methods.charge).
parameters
Challenge parameters. Must include either id or secretKey.
realm
- Type:
string
Server realm (for example, hostname).
request
- Type:
z.input<method['schema']['request']>
Method-specific request data, validated against the method's schema. mppx serializes it as base64url-encoded JCS JSON in the HTTP request auth-param.
secretKey (when not using id)
- Type:
string
Server secret for HMAC-bound Challenge ID. Keep it server-side and load it from your environment or secret manager.