Skip to content

v0.6.0 MFA support

Choose a tag to compare

@hardbyte hardbyte released this 16 Jul 11:56
· 26 commits to main since this release
535a2c6

What's new

MFA support (#85)

Thanks to @erinn (with @mikey0000): accounts with multifactor authentication enabled can now authenticate: authenticate() raises the Cognito challenge exception and respond_to_mfa_challenge(code, mode) completes it via TOTP or SMS. The challenge session is JSON-serializable for cross-process flows (e.g. Home Assistant config flows). See the README for usage.

Hardened authentication & retries

  • API methods still authenticate automatically on first use. No breaking change for non-MFA users
  • Sessions can resume from a refresh token alone; access tokens refresh automatically on expiry
  • Auth failures and MFA challenges are never retried; all retries now bounded (5 attempts)
  • A 401 retries once with freshly renewed tokens before raising NotAuthorizedException
  • No blocking network I/O in the constructor or on the event loop (Cognito calls run in a worker thread)

Fixes

  • EvnexUserDetail.name optional: accounts with no name set validate again (#108)
  • v3 connector meter exposes supplyActivePower (CT clamp grid draw) (#109)
  • Insights accept the carbonUsage attribute

Internals

  • First test suite: auth/refresh/MFA/retry paths, with blockbuster guarding against event-loop blocking; runs in CI
  • All dependencies upgraded (#110)