http/api_client library

API Client Helpers (header/body adapters only – no HTTP)

This module provides small adapters to turn a SecureMessage into wire-ready parts (headers map + body string) and to parse them back. It does not perform any network I/O and does not depend on any HTTP client. You can plug these parts into any client (e.g. Dio).

WHY:

  • Project requirement: the library must only operate on given headers/body and must not create HTTP requests/responses.
  • These helpers keep the "reserved" protocol headers isolated from any user/application headers.

INTEGRATION (example with Dio — outside this library):

final parts = ApiClient.toWire(message, extraHeaders: {
  'X-App-Id': 'myapp',
});
await dio.post(
  '/endpoint',
  options: Options(headers: parts.headers),
  data: parts.body, // String: Base64 tag
);

HINTS:

  • Use ApiClient.parseWire(headers, body) on the receiving side to reconstruct the SecureMessage before verifying/decrypting.
  • Extra headers cannot override reserved keys: "version","window","nonce","ciphertext".

Classes

ApiClient
Small adapter for (de)serializing protocol messages to/from wire parts.
WireRequestParts
Immutable wire parts: headers and body.