accounts (1.0.0)
Installation
dart pub add accounts:1.0.0 --hosted-url=About this package
Dart.Package.Accounts
Client for the ByteCobra Accounts API: login, token refresh, roles, and admin operations (ported from the old platform).
Quick start
import 'package:accounts/accounts.dart';
final accounts = CobraAccounts('https://accounts.example.com');
final token = await accounts.account.login('user@example.com', 'password');
accounts.account.startRefreshTimer(const Duration(minutes: 30));
final roles = await accounts.account.getRoles();
await accounts.admin.setRole(userId, Roles.admin);
CobraAccounts is a singleton keyed by whichever base URL first constructs
it, wiring up a shared WebClient for its account (AccountClient) and
admin (AdminClient) sub-clients.
Project structure
pubspec.yaml
Version.txt
lib/
├── accounts.dart public API — exports
└── src/
├── web_client.dart WebClient — GET/POST/DELETE with bearer auth
├── account_client.dart AccountClient — login/refresh/roles/user
├── admin_client.dart AdminClient — role/ban/custom-data management
├── cobra_accounts.dart CobraAccounts singleton
├── models.dart request/response DTOs
├── roles.dart Roles constants
└── login_result.dart LoginResult
test/
└── accounts_test.dart DTO JSON round-trips, WebClient/singleton logic
example/
└── example.dart
Versioning and publishing
Version.txt is the exact version that gets published — a push to main
publishes it only when that version isn't on the feed yet. Pushes to any
other branch only resolve and test.
CI
.forgejo/workflows/build.yml installs the Dart SDK, resolves dependencies,
and runs dart test on every push. On main, it also publishes via
dart pub publish, tags the commit v<version>, and creates a matching
Release — via the shared
Platform/Forgejo.Package.Actions/dart-publish
composite action. .forgejo/workflows/cleanup.yml removes prerelease Pub
versions when their branch is deleted.