This is the documentation for v2 — looking for the v1 documentation?
Skip to content

MCP TypeScript SDK (V2) / @modelcontextprotocol/client / client/dpop

client/dpop

Classes

DpopSession

Defined in: packages/client/src/client/dpop.ts:135

A DPoP signing identity plus the small amount of state RFC 9449 requires across requests: the key pair and, per origin, the most recently server-supplied nonce (RFC 9449 §8/§9).

One DpopSession is meant to live for the lifetime of a single OAuth client registration — the token endpoint and the resource server are different origins and get independent nonce slots, so a nonce challenge from one never leaks into proofs sent to the other.

Accessors

alg
Get Signature

get alg(): "ES256" | "ES384" | "ES512" | "RS256" | "RS384" | "RS512" | "PS256" | "PS384" | "PS512" | "EdDSA"

Defined in: packages/client/src/client/dpop.ts:152

The JWS algorithm this session signs proofs with.

Returns

"ES256" | "ES384" | "ES512" | "RS256" | "RS384" | "RS512" | "PS256" | "PS384" | "PS512" | "EdDSA"

publicJwk
Get Signature

get publicJwk(): JWK

Defined in: packages/client/src/client/dpop.ts:157

The public JWK embedded in every proof's jwk header parameter.

Returns

JWK

thumbprint
Get Signature

get thumbprint(): string

Defined in: packages/client/src/client/dpop.ts:147

RFC 7638 JWK SHA-256 thumbprint of the signing key — matches the token's cnf.jkt once bound.

Returns

string

Methods

buildProof()

buildProof(request): Promise<string>

Defined in: packages/client/src/client/dpop.ts:185

Build a fresh DPoP proof JWT. Always mints a new jti — proofs are never cached or reused, since RFC 9449 §4.3 step 9 requires each to be presented at most once.

Parameters
request

DpopProofRequest

Returns

Promise<string>

nonceFor()

nonceFor(url): string | undefined

Defined in: packages/client/src/client/dpop.ts:162

The remembered nonce for url's origin, if the server has issued one (RFC 9449 §8/§9).

Parameters
url

string | URL

Returns

string | undefined

observeNonce()

observeNonce(response, url): void

Defined in: packages/client/src/client/dpop.ts:176

Capture a DPoP-Nonce response header, if present, for url's origin. RFC 9449 §8.2 says a fresh nonce may ride on any response (success or failure), so call this unconditionally after every request, not only on a use_dpop_nonce challenge.

Parameters
response

Response

url

string | URL

Returns

void

rememberNonce()

rememberNonce(url, nonce): void

Defined in: packages/client/src/client/dpop.ts:167

Record a server-supplied nonce for url's origin (newest-wins, RFC 9449 §8.2).

Parameters
url

string | URL

nonce

string

Returns

void

create()

static create(options?): Promise<DpopSession>

Defined in: packages/client/src/client/dpop.ts:141

Create a session with a fresh key pair, or reuse a caller-supplied one.

Parameters
options?
alg?

"ES256" | "ES384" | "ES512" | "RS256" | "RS384" | "RS512" | "PS256" | "PS384" | "PS512" | "EdDSA"

keyPair?

DpopKeyPair

Returns

Promise<DpopSession>

Interfaces

DpopKeyPair

Defined in: packages/client/src/client/dpop.ts:40

A DPoP signing key pair: the private key signs proofs, the public JWK is embedded in them.

Properties

alg

alg: "ES256" | "ES384" | "ES512" | "RS256" | "RS384" | "RS512" | "PS256" | "PS384" | "PS512" | "EdDSA"

Defined in: packages/client/src/client/dpop.ts:50

The JWS algorithm this key pair signs with.

privateKey

privateKey: CryptoKey

Defined in: packages/client/src/client/dpop.ts:42

Signs proofs. Non-extractable unless GenerateDpopKeyPairOptions.extractable was set.

publicJwk

publicJwk: JWK

Defined in: packages/client/src/client/dpop.ts:46

Embedded in each proof's jwk header parameter (RFC 9449 §4.2).

publicKey

publicKey: CryptoKey

Defined in: packages/client/src/client/dpop.ts:44

Matches publicJwk; rarely needed directly.

thumbprint

thumbprint: string

Defined in: packages/client/src/client/dpop.ts:48

RFC 7638 JWK SHA-256 thumbprint — the value an authorization server binds as the token's cnf.jkt.


DpopProofRequest

Defined in: packages/client/src/client/dpop.ts:113

Inputs for a single DPoP proof (RFC 9449 §4.2).

Properties

accessToken?

optional accessToken?: string

Defined in: packages/client/src/client/dpop.ts:119

When set, binds the proof to this access token via the ath claim (RFC 9449 §4.1).

htm

htm: string

Defined in: packages/client/src/client/dpop.ts:115

HTTP method of the target request (htm claim). Case-normalized to upper-case.

htu

htu: string | URL

Defined in: packages/client/src/client/dpop.ts:117

HTTP target URI of the request (htu claim) — query/fragment are stripped automatically.

nonce?

optional nonce?: string

Defined in: packages/client/src/client/dpop.ts:124

Explicit server-provided nonce to embed. When omitted, the session's remembered nonce for htu's origin (if any) is used automatically — see DpopSession.rememberNonce.


GenerateDpopKeyPairOptions

Defined in: packages/client/src/client/dpop.ts:53

Properties

alg?

optional alg?: "ES256" | "ES384" | "ES512" | "RS256" | "RS384" | "RS512" | "PS256" | "PS384" | "PS512" | "EdDSA"

Defined in: packages/client/src/client/dpop.ts:55

Signing algorithm.

Default
ts
'ES256'
extractable?

optional extractable?: boolean

Defined in: packages/client/src/client/dpop.ts:63

Allow the private key to be exported (e.g. for persistence across process restarts).

Default
ts
falseRFC 9449 §11.1 and §11.7 recommend non-extractable keys (hardware-backed
where available) so the private key cannot be exfiltrated by XSS or a compromised dependency.
Only set this when the host has its own plan for protecting the exported key material.

Type Aliases

DpopAlg

DpopAlg = typeof DPOP_SUPPORTED_ALGS[number]

Defined in: packages/client/src/client/dpop.ts:25

A DPoP JWS algorithm this SDK can sign proofs with.

Variables

DPOP_SUPPORTED_ALGS

const DPOP_SUPPORTED_ALGS: readonly ["ES256", "ES384", "ES512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "EdDSA"]

Defined in: packages/client/src/client/dpop.ts:22

Asymmetric JWS algorithms usable for a DPoP proof (RFC 9449 §11.6 forbids symmetric algs and none).

Functions

accessTokenHash()

accessTokenHash(accessToken): Promise<string>

Defined in: packages/client/src/client/dpop.ts:83

Compute the ath claim for a DPoP proof presented alongside an access token: the base64url-encoded SHA-256 digest of the ASCII access-token value (RFC 9449 §4.1).

Uses Web Crypto (crypto.subtle) rather than a Node-only hashing API so this stays usable in browser and edge runtimes.

Parameters

accessToken

string

Returns

Promise<string>


generateDpopKeyPair()

generateDpopKeyPair(options?): Promise<DpopKeyPair>

Defined in: packages/client/src/client/dpop.ts:67

Generate an asymmetric DPoP signing key pair. Non-extractable by default (RFC 9449 §11).

Parameters

options?

GenerateDpopKeyPairOptions = {}

Returns

Promise<DpopKeyPair>


isDpopNonceChallenge()

isDpopNonceChallenge(response): boolean

Defined in: packages/client/src/client/dpop.ts:226

Whether response is a resource-server use_dpop_nonce challenge (RFC 9449 §9): a 401 whose WWW-Authenticate header carries a DPoP challenge with error="use_dpop_nonce".

A conformant retry re-signs the proof with the nonce DpopSession.observeNonce just captured — never resend the original proof: RFC 9449 §4.2 requires a unique jti per proof, and replaying one across the challenge/retry boundary is itself a violation.

Parameters

response

Response

Returns

boolean