| Filename | Latest commit message | Latest commit date |
|---|---|---|
An account signed in or up to on an instance whose operator approves new accounts, or one suspended, gets no session but a wait: the device keeps its pass, words and handle in the keyring per instance (SecureAccountWaitStore, InstanceStorage.waitOf), the auth status is Waiting, and SessionGate shows WaitScreen in its own app, so the start screen's sheets go with it. Every sign-in flow hands over to it: the password's sign-in, sign-up, reset and account reset, SimpleLogin's sign-in, sign-up and mending; their cubits show no problem then. The wait screen shows the handle, the four words the operator reads out for the person to match, and that Halkyon never asks anyone to read them out (D33); it asks where the wait stands as it opens, every 30 seconds, as the app comes back and when asked. A new account can be deleted with its pass, a suspended one can't (ADR 0017). Approved, it leads to the usual sign-in, once more as before (D31); a pass the instance knows no more ends the wait. The start screen says where new accounts wait for approval, and offers no Create an account where the operator takes none; both refusals (closed, too many waiting) have their words, en and de. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me> |
||
| .. | ||
| assets | ||
| lib | ||
| test | ||
| tool | ||
| .gitignore | ||
| analysis_options.yaml | ||
| CHANGELOG.md | ||
| l10n.yaml | ||
| LICENSE | ||
| pubspec.yaml | ||
| README.md | ||
halkyon_app
What every Halkyon app (Learn, Todo, Train) is built around, on an instance's
halkyon_base module: the instances a device keeps an account on, signing in,
each person's data opened and closed, and syncing it. Taken from Halkyon Learn,
which it was written for, so it behaves as Learn's own did; the texts are in
British English, American English and German, and where they name the app,
they name yours.
Written as the apps are: Dart 3.13's primary constructors, Material from
package:material_ui, Lucide icons, blocs (flutter_bloc), LeanCode's lints.
What it holds
- Instances (
lib/src/instance/):Instance(an address as people type it;isSecure: over HTTPS, or over plain HTTP on this machine alone),InstanceChoice(those the device keeps an account on, one in use;FileInstanceStore;allowsan instance reached securely, or in a development build the build's own over HTTP, andleaves one it no longer allows, whichInstanceGatenever opens: it says why and offers another or removing it),InstanceStorage(each instance's people's folders and session key),InstanceChecker(does an address answer, where does it keep people's data;ServerpodInstanceCheckerasks itsinstance.basics()),InstanceScope. The screens:FirstStartScreen(the build's instance and another, as tiles,InstanceTile),InstanceStep(an address, checked),showAccountSwitcherandAddAccountScreen, and where an instance keeps people's data, as a flag and words (InstanceLocationBuilder,InstanceFlag,instanceLocationWords):EU, a country or a subdivision (ISO 3166-2,US-CA) as its operator says, "Germany (EU)" for a member of the European Union (europeanUnionMembers) and "California, United States" for a subdivision, with the most specific flag there is (a few subdivisions have their own, such as Scotland; else the country's). Countries and subdivisions are named by Unicode CLDR's names in English and German, which come with the package (AssetCountryNames,AssetSubdivisionNames; the package'stool/country_names.pyandtool/subdivision_names.pywrite them, from one release); tests give names of their own (CountryNames,SubdivisionNames). - Gates (
lib/src/app/):InstanceGateopens the app's dependencies on the instance in use (AppDependencies, handed down byAppScope), anew on a switch, the previous ones closed first;SessionGateshows the app of whoever is signed in and asks how to start while nobody is (StartScreen: SimpleLogin, a password, another instance; an instance out of reach is said so, with Try again, and one offering no way to create an account too), at a first start as after signing out; an anonymous account's session, left from before there were none, is deleted as the app starts (ADR 0020, D25), falling back to signing out on the device;PersonScopeopens each person's own dependencies and closes them when the person goes.resolveAppLocalepicks the app's language as every Halkyon app does: the first preferred language it speaks, never by country alone, British English otherwise. - About (
showAppAbout): the app's name (its frame's), its version, icon and legalese where it gives them, where the source of what the instance runs is (InstanceSourceCode, fromAppDependencies.sourceCodeUrl; both licences require offering it), the app's own parts (its credits), and the licence list. - The account (
AccountTiles): on which instance the account is signed in, switching to the account on another, signing out and deleting it (after asking), for an app's settings, in the app's words where only it can say them. While one runs, the person's app stays and its tile shows a spinner; one that fails keeps them signed in and says why once, in a snack bar (in a sheet, give ithasSnackBars). An instance out of reach signs out on the device all the same (Serverpod'ssignOutDevice), so only the device's own storage fails a sign-out. - The session (
lib/src/auth/):AuthRepositoryon anAuthGateway;ServerpodAuthGatewayfollows the session the app's Serverpod client keeps, signs out, deletes the account through the instance'shalkyon_base, and puts a session granted elsewhere in place (useSession: a password's or SimpleLogin's sign-in; GitHub signs nobody in since ADR 0020, D36);SessionBlocandSignInWaysCubit;SignInAddresses,PersonFolders. - Content sealed with data keys (
lib/src/privacy/, ADR 0019):ContentCipher(SodiumContentCipher, on the isolate it is used on, as an app seals and opens rows one by one;FakeContentCipherin tests) makes a store's data keys, sealed to the account and signed by it, opens them, and seals and opens a row's content for the row it is stored in (its table, id and column), the payload holding the signature before the ciphertext. - A password and TOTP (
lib/src/password/, ADR 0017):PasswordRepositoryon aPasswordGateway(ServerpodPasswordGateway), anAccountCrypto(SodiumAccountCrypto: halkyon_keys and SRP's client half, each step on an isolate of its own, whose results are copied before they cross back: sodium's are views of memory freed with the isolate that made them) and anAccountKeyStore(SecureAccountKeyStore: the account's unlocked keys in the system's keyring, per instance and person, gone once another person signs in or nobody; on iOS and macOSunlocked_this_device, so readable only while the device is unlocked, never in a backup restored elsewhere nor in iCloud Keychain, each write deleting the entry before it, and forgetting finding too the entries earlier builds kept with another accessibility, a keyring that can't be read now stopping nothing). Signing in (SRP's M2 checked and the keys opened before anything is trusted), signing up (the recovery phrase shown once and three of its words typed back before anything reaches the instance), a setup never finished, the authenticators (QR codes drawn with pub.dev'sqr), recovery codes, changing the password, a new phrase, and getting back in. The screens: the start screen's Sign in and Create an account,showPasswordSignInSheet,showAccountSetupSheet,showAccountRecoverySheet, andAccountSecuritySectionfor an app's account part. Every change of how the account is secured asks for the password with the code, one answer per sheet (OwnerAnswer, the owner's proof: a session alone gets no code checked), each answer bound to the instance's base URL and to the change it approves (its purpose and the digest of what it sets,proof_digests.dart), so nobody between the device and the instance swaps anything in; deleting by a code by mail followssecondFactorWorks, as the instance tells it, and asks for the address only where the device doesn't know it. Secrets shown stay the person's: nothing secret is copied (no app can mark a copy as sensitive through Flutter, so clipboard histories and cloud clipboards would keep it): the recovery phrase and codes are saved or written down, an authenticator's key scanned, opened or typed; all of them show in aSecretScreen(the phrase typed back too, its fields offering Paste and Select all alone, their copy keys doing nothing), kept out of screenshots, screen recordings and recents where the app's window answersapp.halkyon/screen_guard: Android'sFLAG_SECURE(as Learn's and Todo'sScreenGuard.ktin theirMainActivity), macOS'ssharingType = .none(MainFlutterWindow.swift; screenshots, but not ScreenCaptureKit's captures on macOS 15 and later) and Windows'WDA_EXCLUDEFROMCAPTUREfrom Windows 10 2004 on,WDA_MONITOR(black in captures) before, by the versionRtlGetVersiontells (flutter_window.cpp); neither run yet; covered on iOS in the app switcher's picture while the app isn't in front, screenshots there not held back; nothing on Linux; keyboards learn nothing typed into a password, a code or the phrase; no state's text (which a debug build's bloc observer logs) holds a secret, a code or the address; only anotpauth:URI is shown as a QR code or opened; and anything a step didn't expect (bytes of the wrong length from an instance, libsodium's or the keyring's own errors) fails it rather than leaving its sheet busy.register_interop_test.dartholds the real cryptography to the register's own checks. Every build of an app needs a C compiler and make: sodium's build hook compiles libsodium. - Signing in with SimpleLogin (
lib/src/simplelogin/, ADR 0020):SimpleLoginRepositoryon aSimpleLoginGateway(ServerpodSimpleLoginGateway, halkyon_base'ssimpleLoginendpoint) and halkyon_oidc_flutter'sOidcBrowser: SimpleLogin's page in the system's browser sheet, back by the app's scheme, or on Linux and Windows in the browser, back to the app's port on the loopback, as the instance's forwarding page names them (callbackScheme,loopbackPort: Learn's 43823, Todo's 43824). Someone new creates an account (a handle, the one the instance suggests being free; the password twice, which makes the account's keys on the device; the recovery phrase shown once and three of its words typed back; nothing reaches the instance before) or links theirs again in place of a lost SimpleLogin account with its handle and recovery phrase, which open the keys on the device before any proof is sent; an account opens its keys with its password; an account of before gets its keys, and its handle where it has none. Withlink, SimpleLogin joins the account of the device's person instead. The screens: the start screen's Continue with SimpleLogin, first where the instance offers it, andshowSimpleLoginSheet(SimpleLoginCubit), which waits for the browser with Cancel and stops waiting on the loopback once it closes. Adding it to an account (ADR 0020, D21): where the person stands (SimpleLoginRepository.standing, read anew after every change,SimpleLoginStandingCubit: nothing to show, linked, or missing), shown bySimpleLoginSection(each app places it aboveAccountSecuritySection: a heading and Add SimpleLogin; once added a row among the ways in), which reads it once where aSimpleLoginStandingScopeis above it. - Files (
FileSaver,PlatformFileSaver): keeping a file the app made where the person chooses (a recovery phrase, recovery codes, an app's exports): on Linux and macOS the own user's alone (writePrivately). On Linux a new file beside it, made 0600 withO_EXCL, written through its descriptor, renamed over the one chosen, never written into, and the folder flushed. On macOS, whose sandbox lets an app reach the file chosen and nothing beside it, the file itself, opened without following a link or waiting on a pipe, refused unless it is a file of the own user's, made 0600 and emptied before anything is written; whoever held it open reads what is saved. Each app's macOS entitlements grant reading and writing the files the person chooses (com.apple.security.files.user-selected.read-write), without which nothing could be saved there, Learn's exports neither. On both, a symbolic link or another user's file is refused with nothing written. On Windows written in place with its folder's rights, on iOS without the copy file_picker leaves in the temporary folder (forgetPickerCopy). None of it has run on a Mac yet. - Sync (
lib/src/sync/):SyncService(once at start, shortly after local changes, on resume and every few minutes, one sync at a time, counting the changes not on the server yet,PendingChangesStore),AppCompatibilityandcompatibleSync(the instance's minimum app build, the engine's table check),SyncStatusBloc,syncAndWait, and the widgets:SyncStatusCard,AppMismatchBanner,SyncTroubleBadge. - A client of
halkyon_basealone (BaseClient): to ask an instance about itself, and to sign in as another person than the app's client holds. - Testing (
package:halkyon_app/testing.dart): fakes of every boundary (FakeAuthGateway,FakePasswordGateway,FakeAccountCrypto,FakeInstanceChecker, the stores in memory), a frame (testFrame),testApp, andTestAppDependencies.
Using it in an app
-
The server includes
halkyon_basewith the nicknamebase(its README), so the app's generated client hasclient.modules.base. -
Depend on it by path, within the repository's workspace, as on
halkyon_ui:dependencies: halkyon_app: path: ../../../packages/halkyon_app -
Texts: add
HalkyonAppLocalizations.delegateto everyMaterialApp's delegates, besideHalkyonUiLocalizations.delegateand material_ui'sGlobalMaterialLocalizations.delegates. -
The frame (
AppFrame): the app's name and wordmark word, its icon, an example address, its theme, delegates, languages (resolveAppLocaleas its resolution) and launch screen, and the sentence only it can say: what the first start's instance keeps of the person's. -
Android: the app's
MainActivityanswersapp.halkyon/screen_guard(copy Learn's or Todo'sScreenGuard.ktand callScreenGuard.attachinconfigureFlutterEngine), or secrets show in screenshots and recents. -
The dependencies: the app's composition root implements
AppDependencies<P>(serverName,auth,signedOut,passwords,fileSaver,sourceCodeUrl,openPerson,dispose), its person's dependenciesDisposable. Itspasswordsis aPasswordRepositoryonServerpodPasswordGateway(client, base: client.modules.base),SodiumAccountCrypto(),SecureAccountKeyStore(storage.keysOf(instance)), the auth gateway and the app'sSignInAddresses. Itsauthis anAuthRepositoryonServerpodAuthGateway(client, base: client.modules.base). -
The tree:
InstanceGate( frame: frame, choice: choice, checker: ServerpodInstanceChecker(app: 'todo'), readLook: …, // the device's theme mode and language open: Dependencies.create, app: SessionGate( look: (context) => …, app: (person) => PersonApp(person: person), // with PersonScope inside ), )A person's widgets find their dependencies with
PersonScope.of<PersonDependencies>(context)and the app's withAppScope.of<Dependencies>(context). -
Licences: call
registerHalkyonAppLicenses()once at startup (the flags' and Unicode CLDR's notices), beside halkyon_ui'sregisterFontLicenses().
Licence
GNU Affero General Public License 3.0 or later (LICENSE). The flags are
lipis' flag-icons, drawn by the flag package, under the MIT licence
(assets/flags/LICENSE-flag-icons.txt). The subdivisions' names are Unicode
CLDR's (release 48.2), under the Unicode License v3
(assets/subdivisions/LICENSE-CLDR.txt, assets/subdivisions/ATTRIBUTION.md).