Table of Contents

Class WalletResponseParser

Namespace
Tessio.Verifier.OpenId4Vp
Assembly
Tessio.Verifier.OpenId4Vp.dll

Parses wallet authorization responses — direct_post (cleartext form) and direct_post.jwt (encrypted JWE in the response form parameter) — and extracts the presented credentials from vp_token. A response returned through the Digital Credentials API is read by ParseDcApiAsync(string, CancellationToken).

public sealed class WalletResponseParser : IPresentationResponseParser
Inheritance
WalletResponseParser
Implements
Inherited Members

Constructors

WalletResponseParser(WalletResponseParserOptions?)

Creates the parser.

public WalletResponseParser(WalletResponseParserOptions? options = null)

Parameters

options WalletResponseParserOptions

Exceptions

ArgumentException

DcqlQueryJson is set to something the parser cannot read as a DCQL query.

Methods

ParseAsync(WalletResponseData, CancellationToken)

Parses the wallet response and returns the credentials it presented.

public Task<IReadOnlyList<PresentedCredential>> ParseAsync(WalletResponseData response, CancellationToken ct = default)

Parameters

response WalletResponseData

The wallet response as captured by the hosting layer.

ct CancellationToken

Cancellation token.

Returns

Task<IReadOnlyList<PresentedCredential>>

Remarks

This contract returns credentials only, so an Authorization Error Response is thrown here as a WalletResponseException, as it always was. ParseDetailedAsync(WalletResponseData, CancellationToken) returns it.

Exceptions

WalletResponseException

The response is malformed, or is an Authorization Error Response.

InvalidOperationException

DcqlQueryJson was changed after construction to something the parser cannot read as a DCQL query. A value set before construction is refused by the constructor instead.

ParseDcApiAsync(string, CancellationToken)

Parses an OpenID4VP response returned through the Digital Credentials API: the JSON of the data member of the DigitalCredential the browser hands the page, which the page forwards to the verifier.

public Task<ParsedWalletResponse> ParseDcApiAsync(string dataJson, CancellationToken ct = default)

Parameters

dataJson string

The JSON text of the data object.

ct CancellationToken

Cancellation.

Returns

Task<ParsedWalletResponse>

Remarks

Under response mode dc_api.jwt the object carries one response member holding the JWE, decrypted with the same key resolution as direct_post.jwt. Under dc_api it carries the response parameters themselves. An Authorization Error Response is returned only when ReadErrorResponses is on, as for the other modes.

State is always null: state is not defined for this transport, so a value a wallet sends is not one the verifier asked for. The response is bound to its request by the origin and nonce instead, which verification checks.

The caller still compares Encrypted with the response mode its request asked for, as with ParseDetailedAsync(WalletResponseData, CancellationToken).

Exceptions

WalletResponseException

The object is malformed in any part its sender controls or cannot be decrypted.

InvalidOperationException

DcqlQueryJson was changed after construction to something the parser cannot read as a DCQL query.

ParseDetailedAsync(WalletResponseData, CancellationToken)

Parses the response including the state needed for session correlation. Prefer this over ParseAsync(WalletResponseData, CancellationToken) when hosting the wallet callback: for direct_post.jwt the state travels inside the encrypted JWT. With ReadErrorResponses on, an Authorization Error Response, in the clear or sealed, is returned with Error set rather than thrown.

public Task<ParsedWalletResponse> ParseDetailedAsync(WalletResponseData response, CancellationToken ct = default)

Parameters

response WalletResponseData
ct CancellationToken

Returns

Task<ParsedWalletResponse>

Exceptions

WalletResponseException

The response is malformed in any part its sender controls, or cannot be decrypted with the configured key. A caller that answers this exception as an invalid response has answered every such response.

InvalidOperationException

DcqlQueryJson was changed after construction to something the parser cannot read as a DCQL query.