zeroxkey_core

Platform-agnostic core for the ZeroXKey SDK. Pure Dart (no Flutter imports) so it can be unit-tested in isolation and reused across runtimes.

It houses the architectural layers that sit between the generated protocol client (zeroxkey_http) and the Flutter presentation layer (zeroxkey_sdk_flutter):

  • errors - ZeroXKeyException hierarchy (NetworkException, TimeoutException, ApiException, AuthException, SigningException, StateException). The wire-level ZeroXKeyRequestError is mapped to ApiException at the data boundary.
  • config / provider - immutable ZeroXKeyConfiguration, NetworkOptions, and the BackendProvider adapter (ZeroXKeyBackendProvider defaults to api.0xkey.io / authproxy.0xkey.io and the 0xkey_hpke info string).
  • network - MiddlewareHttpTransport decorates any HttpTransport with request tracing (X-Trace-Id), exponential-backoff RetryPolicy (connection errors only; timeouts are never retried), bounded timeouts, and ApiErrorMapper.
  • signing - Signer and KeyStore strategy ports.
  • domain / data - entities, repository interfaces, use cases (SignMessageUseCase), and their implementations backed by ZeroXKeyClient.
  • di - ZeroXKeyContainer, a hand-written composition root (no third-party DI).

Usage

zeroxkey_core is consumed by zeroxkey_sdk_flutter; most apps do not depend on it directly. To assemble the graph:

import 'package:zeroxkey_core/zeroxkey_core.dart';

final container = ZeroXKeyContainer(
  configuration: const ZeroXKeyConfiguration(
    backend: ZeroXKeyBackendProvider(),
  ),
  clientResolver: () => myActiveZeroXKeyClient,
);

// Inject the decorated transport into the generated client:
final client = ZeroXKeyClient(
  config: THttpConfig(baseUrl: 'https://api.0xkey.io'),
  stamper: mySigner, // any Signer (a TStamper)
  transport: container.transport,
);

// Delegate domain operations:
final wallets = await container.walletRepository
    .fetchWallets(organizationId: 'org-id');

Tests

dart test

Libraries

zeroxkey_core
Platform-agnostic core for the ZeroXKey SDK.