Skip to main content
The SDK exposes a sealed SynheartAuthError hierarchy in Dart (mirrored as enum-style errors in Kotlin and Swift). Every error has a stable code that maps 1:1 to RFC-AUTH-MOBILE-0001 §11.

Taxonomy

SynheartAuthError.fromCode(code, msg?) maps platform-channel error codes back to the typed exception in Dart.

Key invalidation detection (RFC §11.1)

Hardware keys can become unusable due to:
  • OS updates that rotate Secure Enclave / Keystore root keys.
  • Biometric enrollment changes.
  • Device security state changes (PIN reset, factory reset).
  • Backup/restore between devices.
On detection:
  1. The SDK emits KEY_INVALIDATED (Dart: KeyInvalidated).
  2. State transitions registered → keyInvalid.
  3. The next registerDevice(appId) call wipes local state and runs the full registration flow.
The SDK never silently retries with the invalid key.

Clock skew correction (RFC §11.2)

Mobile clocks drift. The SDK can’t force NTP, so it learns the offset from the server.

Server contract

When rejecting a request with CLOCK_SKEW, the response includes:

SDK behaviour

The SDK exposes correctClockSkew(serverTimestamp) for hosts to call when they receive a CLOCK_SKEW error from any Synheart endpoint. Subsequent signatures use the corrected timestamp automatically. The persisted clock_offset_ms survives app restarts. Per RFC §11.2, the SDK SHOULD periodically re-validate the offset by comparing with X-Synheart-Server-Time from successful responses (server-supplied; not currently emitted by all services).

Retry policy (RFC §12)

Challenge + registration

Always re-fetch a new challenge after any register failure (challenges are single-use).

Signing

Signing failures are non-recoverable in-request — return error immediately. If KEY_INVALIDATED is detected, transition to keyInvalid and trigger re-registration before the next request.

Key rotation

Rotation failures MUST NOT block normal request signing. Backoff: base 60s, max 1 hour, attempts 3 per cycle. After max attempts, log warning and retry on next app launch.

Logging policy

Per RFC §13: InvalidStateTransition should be logged at error level — it indicates a programmer bug.
  • State MachineKeyInvalidated and InvalidStateTransition semantics.
  • Registration — failure paths during the handshake.
  • SigningCLOCK_SKEW, NONCE_REPLAY recovery.