# Class BSV::Auth::SimplifiedFetchTransport <a id="class-BSV-Auth-SimplifiedFetchTransport"></a>

**Inherits:** `Object`
**Includes:** `BSV::Auth::Transport`

BRC-104 client-side HTTP transport implementing {BSV::Auth::Transport}.

Maps BRC-103 auth message types to HTTP requests:

*   Non-general messages (`initialRequest`, `initialResponse`,
    `certificateRequest`, `certificateResponse`) are POSTed as JSON to
    +#{base_url}/.well-known/auth+. Keys are converted to camelCase on the
    wire and back to snake_case symbols on receipt.

*   General messages have their binary payload deserialised via
    {AuthPayload.deserialize_request}, sent as a real HTTP request with
    <code>x-bsv-auth-*</code> headers attached, and the HTTP response
    serialised back to a binary payload via {AuthPayload.serialize_response}.

**@example**
```ruby
transport = BSV::Auth::SimplifiedFetchTransport.new('https://api.example.com')
transport.on_data { |msg| peer.handle_incoming_message(msg) }
transport.send(message)
```

## Public Instance Methods
### `initialize(base_url, http_client: = nil)` <a id="method-i-initialize"></a> <a id="initialize-instance_method"></a>
- **@param** `base_url` [String] scheme + host (+ optional port), e.g. "https://api.example.com"
- **@param** `http_client` [Class, nil] injectable HTTP client; defaults to Net::HTTP
- **@return** [SimplifiedFetchTransport] a new instance of SimplifiedFetchTransport

### `on_data(&block)` <a id="method-i-on_data"></a> <a id="on_data-instance_method"></a>
Registers the callback invoked when a response arrives.

Must be called before {#send}.
- **@yieldparam** `message` [Hash] incoming auth message with symbol keys

### `send(message)` <a id="method-i-send"></a> <a id="send-instance_method"></a>
Sends an auth message to the remote peer.
- **@param** `message` [Hash] auth message produced by {BSV::Auth::Peer}
- **@raise** [RuntimeError] if no callback has been registered via {#on_data}
