Thanks for your interest in improving zero_auth! This guide keeps the package
consistent with the rest of the zero_* series. For deeper context, read
AGENTS.md (the single source of truth for conventions).
zero_auth is a pure-Dart, headless auth state machine & session lifecycle
library. It ships no native code, backend SDK, HTTP client, UI, or
state-management framework. Consumers bring their own backend (AuthStrategy)
and persistence (TokenStore).
Hard rules for lib/:
- Pure Dart only. No
dart:io, nodart:html/package:web, no platform channels, no Flutter widgets, no HTTP client. It must run unchanged on Flutter, server and CLI. - No hidden state. Every side effect goes through
AuthStrategyorTokenStore. - Errors never escape raw. Every failure surfaced publicly is an
AppException(typicallyAuthException); rawExceptions must not cross the public surface. - Single-flight refresh. Keep the shared
_refreshCompleter; do not "simplify" concurrentrefresh()into independent calls.
cd d:\FlutterProgram\zero_auth
dart pub get
dart analyze # must report no issues
dart test # runs the unit tests (package:test, fake_async)For the example app and demo backend:
cd example && flutter analyze && flutter test
cd ..\server && dart analyzeThe Pages site is served from the pre-built docs/ folder; it is regenerated
from website/out/ by a git pre-commit hook. The hook must be installed once per
clone, otherwise edits under website/ never reach GitHub Pages.
文档站由预先构建的 docs/ 目录提供,它由 git pre-commit hook 从 website/out/
重新生成。每个克隆必须安装一次该 hook,否则你在 website/ 下的改动永远不会上线。
npm --prefix website run setup-hookIf you changed website/** but git status shows no docs/ changes, the hook is
missing — reinstall it and run node website/scripts/sync-docs.mjs --force once.
若你改了 website/** 而 git status 中没有 docs/ 变化,说明 hook 未安装——重装它,
再手动执行一次 node website/scripts/sync-docs.mjs --force。
- Branch from
mainwith a typed prefix:feat/,fix/,docs/,ci/,chore/,release/, etc. (release/vX.Y.Zis the branch for a shipped version — see "Releasing".) - Never push directly to
main. - PR titles are English-only and MUST follow
Conventional Commits:
feat:,fix:,docs:,style:,refactor:,perf:,test:,build:,ci:,chore:,revert:. - Follow the bilingual PR body template in
AGENTS.mdand sign off with Zero Buddy.
- Follow
effective_dart; enforced bydart analyze/flutter analyze. - Doc comments in
lib/are bilingual, EN-primary / ZH-secondary (English paragraph first, then the Chinese one). example/andserver/are English-only.README.md(EN) andREADME_zh.md(ZH) are parallel documents; any content change to one must be mirrored in the other.- Do not break the public API without a major version bump; add new public
symbols to
lib/zero_auth.dartonly.
- Use
package:test(NOTflutter_test); usefake_asyncfor timer-driven refresh behaviour. - Shared test doubles live in
test/fake_strategy.dart. - Every new public behaviour needs a unit test.
Bumping the version is the maintainer's call (see AGENTS.md for the mandatory
version-bump checklist). In short: update version in pubspec.yaml, the four
spots in both README.md and README_zh.md, and add a bilingual ## X.Y.Z
section at the top of CHANGELOG.md (only lib/ behaviour changes earn a
changelog entry).
Release flow:
- Merge the version bump to
main. - Cut the release branch:
git checkout -b release/vX.Y.Z main. - Tag and publish:
git tag vX.Y.Z && git push origin release/vX.Y.Z && git push origin vX.Y.Z. ThevX.Y.Ztag triggers the publish workflow and publishes to pub.dev — this is irreversible, so only tag when you intend to ship.
Note: the branch is
release/vX.Y.Z, notvX.Y.Z— a branch namedvX.Y.Zcollides with the tag refspec.