pub struct HttpsClient { /* private fields */ }client only.Expand description
HTTPS Trust Tasks client.
Implementations§
Source§impl HttpsClient
impl HttpsClient
Sourcepub fn builder() -> HttpsClientBuilder
pub fn builder() -> HttpsClientBuilder
Start a new builder.
Sourcepub async fn send<Req>(
&self,
request: TrustTask<Req>,
) -> Result<TrustTask<Req::Response>, ClientError>
pub async fn send<Req>( &self, request: TrustTask<Req>, ) -> Result<TrustTask<Req::Response>, ClientError>
Send a typed Trust Task request to the configured server and receive a typed response.
The client:
- Populates
issuer/recipienton the outbound document from the configured VIDs if they are not already set. - Optionally strips redundant in-band members per
HttpsClientBuilder::strip_redundant_in_band. - POSTs the JSON body with
Authorization: Bearer <my_token>if a token is configured. - On HTTP 2xx, deserialises the body as
TrustTask<Req::Response>and binds it to the request (see below). - On non-2xx, deserialises the body as an
ErrorResponse, checks itsinResponseTo.idwhere present, and returns it viaClientError::TrustTaskError— or, with a response verifier configured and the error not attested by it, viaClientError::UnverifiedErrorResponse.
§Response binding
A 2xx body that merely deserialises as TrustTask<Req::Response> proves
nothing: it could answer a different request, be a different task
type whose payload happens to be shape-compatible, come from a
party that is not the configured server, or be addressed to someone
else. HTTP’s request/response pairing is not a security property —
a proxy, a connection-reuse bug, or anything else in the path can
substitute one body for another. So four equalities are enforced
before the typed response is handed back:
| Member | Must equal | On failure |
|---|---|---|
threadId | the request’s threadId, or its id | ClientError::ResponseThreadMismatch |
type | the request’s type with #response | ClientError::ResponseTypeMismatch |
issuer | the configured server_vid | ClientError::ResponseIssuerMismatch |
recipient | the configured my_vid | ClientError::ResponseRecipientMismatch |
The issuer / recipient checks are skipped for a VID the caller
did not configure — there is nothing to compare against. When
HttpsClientBuilder::strip_redundant_in_band is set, an absent
member is accepted (the client asked for it to be stripped and the
responder echoed the absence); otherwise absence is a mismatch.
On an error response, inResponseTo.id — where the responder
populated it — must be the request’s id, else
ClientError::ErrorResponseMismatch. It is legitimately absent
under identityMismatch (SPEC §8.1 omits it), so absence is not an
error.
§Naming the response
The response type is not a parameter: it is
<Req as RequestPayload>::Response, which the codegen pairs with the
request from the one schema. send::<grant::Payload>(req) therefore
returns TrustTask<grant::Response> and nothing else, where the
previous send::<Req, Resp> accepted a mismatched pair such as
send::<grant::Payload, revoke::Response>(req) and turned it into a
decode failure at run time.
A specification defining no success response implements no
RequestPayload, so send does not compile for it — see the
trait’s docs.