feat(app): sign in with a password and TOTP on the device

ADR 0017, step 3: halkyon_app's side, which Learn and Todo take.

- The account's cryptography on the device (`SodiumAccountCrypto`):
  halkyon_keys and SRP's client half, each step on an isolate of its
  own. sodium hands out results as views of native memory its
  finalizers free once the isolate that made them ends, so everything
  crossing back is copied first: a view read freed memory and crashed
  the process.
- `PasswordGateway` on the module's endpoints (steps without a session
  through a client holding none; an authenticator set up with a session
  granted but not yet the device's), and `PasswordRepository` running
  the flows: signing in (M2 checked, the keys opened before anything is
  trusted), signing up, a password for someone signed in, an account
  never finished, the authenticators, recovery codes, changing the
  password, a new recovery phrase, and getting back in.
- The unlocked keys in the system's keyring per instance and person
  (`SecureAccountKeyStore`), gone once another person signs in or
  nobody, and with the instance's removal.
- The screens: the start screen's Sign in and Create an account (and
  when GitHub sign-in ends), the sign-in sheet (codes, recovery codes,
  an account never finished, a lost authenticator), the account's setup
  (the recovery phrase shown once, three random words typed back before
  anything reaches the instance; the authenticator's QR code, drawn
  with pub.dev's qr; the recovery codes), getting back in, and the
  account section (`AccountSecuritySection`).
- `FileSaver` moves from Learn into halkyon_app, for the phrase and the
  codes in Todo too; `AppDependencies` names it and `passwords`.
- halkyon_keys rebuilds account keys from the secret keys a device kept;
  the key proof's message is in halkyon_base_client, checked against
  the register's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-20 15:42:45 +02:00
commit a4819c3d39
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64

View file

@ -11,6 +11,10 @@ environment:
dependencies:
clock: ^1.1.3
equatable: ^3.0.0
# Keeping a file the app made where the person chooses (FileSaver): the
# system's dialog on Android and iOS, file_selector's on the desktop.
file_picker: ^13.1.0
file_selector: ^1.1.0
# The flag of where an instance keeps people's data; it draws lipis'
# flag-icons, whose MIT notice this package registers (assets/flags/).
flag: ^7.1.0
@ -20,6 +24,9 @@ dependencies:
# gen-l10n's output imports it; apps take Material's texts from material_ui.
flutter_localizations:
sdk: flutter
# The account's private keys, once unlocked, in the system's keyring
# (ADR 0017), as Serverpod keeps sessions.
flutter_secure_storage: ^10.0.0
# LoopbackWebAuth takes the place of the package's own browser half on
# Linux and Windows.
flutter_web_auth_2_platform_interface: ^5.0.0
@ -27,6 +34,10 @@ dependencies:
path: ../halkyon_base_client
halkyon_core:
path: ../halkyon_core
# The account's keys on the device (ADR 0017): libsodium, which its build
# hook compiles, so every build of an app needs a C compiler and make.
halkyon_keys:
path: ../halkyon_keys
halkyon_ui:
path: ../halkyon_ui
# A client of halkyon_base alone can be given a fake one in tests.
@ -35,6 +46,9 @@ dependencies:
lucide_icons_flutter: ^3.1.20
material_ui: ^1.5.0
path: ^1.9.1
# QR codes of an authenticator's otpauth:// URI, drawn by the app itself
# (BSD-3-Clause, pure Dart; pinned exactly, as what it encodes is a secret).
qr: 3.0.2
# Serverpod's packages move together, at one version (as the apps pin them).
serverpod_auth_core_client: 4.0.4
serverpod_auth_idp_client: 4.0.4
@ -43,6 +57,9 @@ dependencies:
# Its sync refuses an app whose synced tables differ from the server's
# (OfflineSyncTablesHashMismatchException).
serverpod_offline_sync_client: 0.0.10
# libsodium's API, as halkyon_keys pins it (the same version, exactly):
# opening it on each isolate the account's keys are worked on.
sodium: 4.1.0+1
url_launcher: ^6.3.2
window_to_front: ^0.0.4