Contents

completeExchangeBaseUrl#

Try to complete a partial URL into the canonical base URL of an exchange.

Request:

The request arguments must be a CompleteBaseUrlRequest object.

Response:

On success, the result is a CompleteBaseUrlResult object.

Side effects:

Probes candidate base URLs over the network until one validates as an exchange.

Details:

The wallet derives candidate base URLs from url and probes them, returning the first candidate that answers like an exchange. A failure to complete is reported in-band via the status field of the result, not with an error response: bad-syntax when the URL is too malformed to be completed, bad-network when no candidate could be reached and bad-exchange when the endpoint is reachable but is not an exchange. In the failure case, suggestions may list base URLs of exchanges known to the wallet that look similar to what was typed.

interface CompleteBaseUrlRequest {
  url: string;

  // Correlates progress notifications and allows cancellation.
  progressToken?: string;
}
type CompleteBaseUrlResult =
  | {
      // ok: completion is a proper exchange
      status: "ok";

      // Completed exchange base URL, if completion was possible
      completion: string;
    }
  | {
      // bad-syntax: url is so badly malformed, it can't be completed
      // bad-network: syntax okay, but exchange can't be reached
      // bad-exchange: syntax and network okay, but not talking to
      // an exchange
      status: "bad-syntax" | "bad-network" | "bad-exchange";

      // Error details in case status is not "ok"
      error: TalerErrorDetail;

      // Base URLs of exchanges known to the wallet whose host looks
      // like what the user meant to type, most likely first.
      // Absent when the wallet does not know anything similar.
      suggestions?: string[];
    };