hellhound/exchange

Explicit HTTPS credential exchange, independent of discovery and custody.

new validates pure options. Start supervised(client) under your owning supervisor before calling perform; stop it through that supervisor. Each call sends at most one request. Applications own token reuse and retry authority, including a failure whose evidence is MaybeSent.

A caller decoder converts the provider’s JSON into TokenResponse. Decoder failures/exceptions are sanitized. Its purity, runtime and captured-resource lifetime belong to the application. No raw response is kept in errors. Transport policy applies before status classification: an oversized, incomplete or unsupported-encoding response fails as TransportFailure, including when its observed status is non-2xx.

Types

pub type Authentication {
  Bearer(assertion.Assertion)
  FormAssertion(name: String, assertion: assertion.Assertion)
}

Constructors

pub type Body {
  Empty
  Form(List(#(String, String)))
  Json(json.Json)
}

Constructors

  • Empty
  • Form(List(#(String, String)))
  • Json(json.Json)
pub opaque type Client
pub type ConfigError {
  InvalidTrust
  InvalidTimeout
  InvalidResponseLimit
  InvalidHeaderLimit
  InvalidHost
}

Constructors

  • InvalidTrust
  • InvalidTimeout
  • InvalidResponseLimit
  • InvalidHeaderLimit
  • InvalidHost
pub type Error {
  InvalidRequest
  TransportFailure(
    evidence: telemetry.Evidence,
    reason: telemetry.TransportReason,
  )
  ProviderRejected(status: Int)
  MalformedResponse
  InvalidToken
}

Constructors

pub type Options {
  Options(
    trust: config.Trust,
    destinations: config.DestinationPolicy,
    allowed_hosts: option.Option(List(String)),
    timeout: duration.Duration,
    max_response_bytes: Int,
    max_header_bytes: Int,
    max_headers: Int,
  )
}

Constructors

pub opaque type Request
pub opaque type Token

A decoder’s transient input to token admission. The raw string here belongs to the caller decoder; only the admitted opaque Token is returned by perform.

pub type TokenResponse {
  TokenResponse(
    token: String,
    expires_at: option.Option(timestamp.Timestamp),
  )
}

Constructors

Values

pub fn expires_at(
  token: Token,
) -> option.Option(timestamp.Timestamp)

Absent or past expiry remains honest evidence; the application owns reuse.

pub fn new(options: Options) -> Result(Client, ConfigError)
pub fn new_request(
  endpoint: String,
  authentication: Authentication,
) -> Request
pub fn options() -> Options
pub fn perform(
  client: Client,
  request: Request,
  decoder: decode.Decoder(TokenResponse),
) -> Result(Token, Error)
pub fn supervised(
  client: Client,
) -> supervision.ChildSpecification(Nil)

The application owns the returned child’s supervisor and shutdown.

pub fn token_value(token: Token) -> String

Deliberately expose the credential for an application-owned resource request.

pub fn with_body(request: Request, body: Body) -> Request
pub fn with_correlation(
  client: Client,
  correlation: correlation.Correlation,
) -> Client
pub fn with_header(
  request: Request,
  name: String,
  value: String,
) -> Request

Adds one header. Credential/framing overrides and duplicates are refused by perform, rather than silently replacing existing configured headers.

✨ Search Document