Skip to main content

kirak 0.1.0 copy "kirak: ^0.1.0" to clipboard
kirak: ^0.1.0 copied to clipboard

Token management for Kirak backends - automatic refresh, no manual auth code.

kirak #

Token management for Kirak backends. api() attaches your session's access token to every call, refreshes it when a call returns 401 (or ahead of expiry when KirakAuthOptions.autoRefresh is on), and keeps the session in the store you supply (the built-in store is in-memory only) - so you never write token-handling code.

Install #

dependencies:
  kirak: ^0.1.0

Or, working from inside this repo:

dependencies:
  kirak:
    path: ../kirak

Quickstart #

import 'package:kirak/kirak.dart';

final kirak = await createClient('https://your-app.kirak.dev');

await kirak.api('auth.login', params: {'email': 'a@example.com', 'password': 'secret'});
final posts = await kirak.api('posts.fetch');

Every /auth/* response carrying tokens is adopted automatically - auth.login, auth.verify-otp, auth.<provider>.mobile, auth.verify-web-auth. For a session your app obtained some other way (a deep link, a native provider SDK), call kirak.session.adoptSession(AdoptSessionInput(accessToken: ..., refreshToken: ...)) directly.

Storage #

kirak's only built-in store is in-memory - it does not persist across process restarts. For a real Flutter app, use kirak_flutter's createKirakFlutterClient instead, which defaults to a real persistent store. Pass your own KirakClientOptions(auth: KirakAuthOptions(storage: ...)) (anything implementing AuthStore) for a server, a CLI, or a custom persistence layer.

Errors #

Every call returns a KirakResult<T> (data/error) - it never throws for an HTTP or network failure, so check .error rather than wrapping calls in try/catch.

License #

MIT - see LICENSE.

1
likes
150
points
380
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Token management for Kirak backends - automatic refresh, no manual auth code.

Homepage
Repository (GitHub)

License

MIT (license)

Dependencies

http

More

Packages that depend on kirak