flutter_better_auth 0.6.1
flutter_better_auth: ^0.6.1 copied to clipboard
A Dart/Flutter client for the Better Auth platform, enabling secure sign-in, sign-up, and session management in Flutter applications.
Changelog #
0.6.1 #
Fixed
social.linkAndRedirecton native: now sends thescheme://auth-callbackdeep link ascallbackURLand routes through the Better Auth authorization proxy (carrying the OAuthstate), so linking returns to the app instead of the server home page and no longer fails the state check.
0.6.0 #
Added
- Web social sign-in. On web,
signIn.social(...)now does a full-page browser redirect to the provider instead of the native deep-link flow, and defaultscallbackURLto the current app origin so Better Auth returns to your app (not the server root) after OAuth. Pass an explicitcallbackURLto control the return route. social.linkAndRedirect(...)— drives the account-linking OAuth round-trip (web full-page redirect / native web-auth), likesignIn.social. Plainsocial.link(...)still just returns the authorizationurlfor manual handling.- Bearer-token auth (Better Auth
bearerplugin). The client now captures theset-auth-tokenresponse header on sign-in, persists it, and sendsAuthorization: Bearer <token>on subsequent requests. This makes auth work across origins (e.g. Flutter Web on a different origin than the server, where third-party cookies are blocked). No-op when the server doesn't issue the header. Cleared on sign-out.
0.5.0 #
Added
- Web support. The client no longer pulls
dart:iointo the web build and skips the cookie jar on web — instead it enableswithCredentialsso the browser stores and sends Better Auth's session cookie automatically. See the Web section in the README for cross-origin/CORS notes.
Breaking
HiveStorageis no longer re-exported from the package barrel (it is native-only). Import it directly when needed:import 'package:flutter_better_auth/core/storage/hive_storage.dart';.
0.4.0 #
Added
- Magic Link plugin (
client.magicLink):signIn(email:, …)(POST /sign-in/magic-link) andverify(token:)(GET /magic-link/verify). - Multi-Session plugin (
client.multiSession):listDeviceSessions(),setActive(sessionToken:),revoke(sessionToken:). client.signIn.isUsernameAvailable(username:)(POST /is-username-available).client.admin.hasPermission(permissions:)andclient.admin.setUserPassword(userId:, newPassword:).client.emailOtp.checkVerificationOtp(...),requestEmailChange(...),changeEmail(...).client.verifyPassword(password:)(POST /verify-password).- Example harness tabs and README sections for the above.
0.3.0 #
Breaking
client.phonemethods now take flat named parameters (@BodyExtra) instead of body objects, matching every other plugin:signIn(phoneNumber:, password:, rememberMe:)— wassignIn(body: SignInPhoneBody(...)).sendOtp(phoneNumber:),requestPasswordResetOTP(phoneNumber:)— was(body: PhoneBody(...)).verify(phoneNumber:, code:, disableSession:, updatePhoneNumber:)— was(body: VerifyPhoneBody(...));disableSessionis nowbool?.restPassword(otp:, phoneNumber:, newPassword:)— was(body: ResetPhonePasswordBody(...)).
- Removed the now-unused body models and the
SignInPhoneBodyexport.
0.2.0 #
Breaking
- Request param types corrected against the Better Auth OpenAPI schema:
signIn.email/signIn.username—rememberMeis nowbool?(wasString?).signIn.social—scopesis nowList<String>?(wasString?),requestSignUpis nowbool?(wasString?).social.link—scopesis nowList<String>?(wasString?).
SocialAccountResponse— field renamedprovider→providerId(the server returnsproviderId); addedaccountId,userId,scopes. Fixestype 'Null' is not a subtype of type 'String'onsocial.listAccounts().
Fixed
- Bodyless
POSTrequests now send an empty JSON object{}instead of an empty body, fixing serverSyntaxError: Unexpected end of JSON input(e.g.signIn.anonymous(),signOut(),revokeSessions()). Invitation.roleis now nullable to match the schema (server may omit it).- Hardened native OAuth callback parsing (
parseOAuthCallback): reads query and URL-fragment params, surfaces providererror, and logs the raw callback for debugging.
Added
- Secure cookie storage by default on native platforms (
flutter_secure_storage): session cookies are encrypted at rest and chunked to stay under the iOS Keychain item-size limit.HiveStorageremains available as an opt-in (store:), and you can supply anyStorageInterface. refreshSessionOnReconnect(defaulttrue): refreshes the session stream when the device regains connectivity (offline → online), mirroring the Expo online-manager. Pairs with the existingrefreshSessionOnAppResume.BetterAuthClientis now exported from the package barrel (package:flutter_better_auth/flutter_better_auth.dart).
Removed
- The redundant
flutter-originrequest header (the Better Auth Expo server only readsexpo-origin).
0.1.6 #
- Add One-Time Token plugin (
client.oneTimeToken):GET /one-time-token/generate,POST /one-time-token/verify. - Add Anonymous plugin:
client.anonymous.deleteAnonymousUser()(POST /delete-anonymous-user). Anonymous sign-in stays onclient.signIn.anonymous()(POST /sign-in/anonymous). - Add Passkey plugin (
client.passkey): full HTTP surface for@better-auth/passkey(generate/verify registration & authentication, list, delete, update). WebAuthn UI is left to the app (e.g.passkeys). - Add Organization plugin (
client.organization): Retrofit surface for org/members/invites/teams/roles/has-permission;set-active/set-active-teamvia Dio with JSONnullpreserved (RemoveNullsInterceptor);listMembersRawfor list-members query parity. - Add API Key plugin (
client.apiKey). - Add Two-Factor plugin (
client.twoFactor). - Session:
Session.activeTeamIdwhere teams apply; regenerated client.g.dartwhere needed. - Widgets:
BetterAuthInherit.maybeOf;StateErrorwhenBetterAuthConsumeris used outsideBetterAuthProvider. - README updates (anonymous / passkey / org),
SignInEmailResponseand model tests, example app updates.
0.1.2 #
- Remove log.
- Add condition for social auth on web
0.1.1 #
- Remove log.
0.1.0 #
- Add
flutter_auth_web_2for social auth.
0.0.9 #
- Fix body serialization
0.0.8 #
- Break changes: We change use name parameter with BodyExtra instead of Class.
- Before:
final result = await client.signIn.email( body: SignInEmailBody( email: "test@mail.com", password: "12345678", ), )- After
final result = await client.signIn.email( email: "test@mail.com", password: "12345678", );
0.0.7 #
- Fix: update api response types to use correct models from Karuppusamy
0.0.6 #
- Add JWT support
0.0.5 #
- Update readme for plugin example
0.0.4 #
- Add Email OTP
- Add plugin example in readme
0.0.3 #
- Refactoring
- Add github example from Karuppusamy
0.0.2 #
- Update readme
- Add admin plugin
0.0.1 #
- Initial release with support for:
- Default API authentication
- Social authentication
- Email, phone number, and username authentication
- Anonymous authentication