kirak 0.1.0
kirak: ^0.1.0 copied to clipboard
Token management for Kirak backends - automatic refresh, no manual auth code.
kirak #
0.1.0 #
First release. Pure Dart, no Flutter dependency.
createClient(baseUrl, options)-Future-based client, usable from any Dart context (Flutter, server-side Dart, a CLI).api(operation, params, opts)- the generic dispatcher for every Kirak endpoint ("posts.fetch","auth.login","graphql", ...). Never throws for an HTTP or network failure - always resolves to aKirakResult(data/error).session-get(),adoptSession(),onChange(),refresh(),clear(). Any successful/auth/*response carryingaccessToken+refreshTokenis adopted automatically, so password, OTP, social, and Apple-web logins all work without extra code.adoptSession()is the entry point for a session obtained another way (a deep link, a native provider SDK).- Automatic refresh: single-flight refresh-on-401 (concurrent requests share one refresh
call), a generation guard so a stale refresh can never overwrite a newer session, and an
optional
autoRefreshtimer with a floor and backoff so it can never turn into a tight loop. AuthStoreis a pluggable interface; the built-in default is in-memory only (no persistence assumption at the core level - seekirak_flutterfor a real app default).