https://github.com/flutter-news-app-full-source-code/auth-client
An abstract interface for authentication operations within the Flutter News App Toolkit.
https://github.com/flutter-news-app-full-source-code/auth-client
Last synced: 4 months ago
JSON representation
An abstract interface for authentication operations within the Flutter News App Toolkit.
- Host: GitHub
- URL: https://github.com/flutter-news-app-full-source-code/auth-client
- Owner: flutter-news-app-full-source-code
- License: other
- Created: 2025-05-03T06:26:59.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2026-01-05T09:20:18.000Z (5 months ago)
- Last Synced: 2026-02-08T08:55:27.676Z (4 months ago)
- Language: Dart
- Homepage:
- Size: 88.9 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Auth Client
An abstract interface for authentication operations within the Flutter News App Toolkit.
This `auth_client` package defines the abstract interface (`AuthClient`) for authentication operations within the [**Flutter News App Full Source Code Toolkit**](https://github.com/flutter-news-app-full-source-code). It provides a clear contract that concrete implementations (e.g., API clients, Firebase clients, in-memory mocks) must adhere to. The interface supports both an email+code password-less authentication and an anonymous authentication flow, ensuring consistent and flexible authentication mechanisms across the Flutter mobile app, web dashboard, and Dart Frog backend API.
## ⭐ Feature Showcase: Flexible & Standardized Authentication
This package offers a comprehensive set of features for managing authentication operations.
🧱 Core Functionality
### 🚀 Abstract `AuthClient` Interface
- **`AuthClient` Abstract Class:** Defines a generic, provider-agnostic interface for all authentication operations.
- **`authStateChanges` Stream:** A `Stream` that emits the current authenticated `User` or `null` whenever the authentication state changes (sign-in, sign-out). This is ideal for reactive UI updates.
- **`getCurrentUser()`:** An asynchronous method `Future` to retrieve the currently signed-in `User`, if any.
### 🔐 Authentication Flows
- **`requestSignInCode(String email, {bool isDashboardLogin = false})`:** Initiates the passwordless sign-in flow. It is context-aware, supporting both standard sign-in and privileged dashboard login with appropriate validation.
- **`verifySignInCode(String email, String code, {bool isDashboardLogin = false})`:** Verifies the email code to complete the sign-in/sign-up process. For dashboard login, it strictly performs a login and does not create new accounts. Returns a `Future`.
- **`signInAnonymously()`:** Signs the user in anonymously, creating a temporary user identity on the backend and returning a `Future` containing the anonymous `User` and token.
- **`signOut()`:** Signs out the current user (whether authenticated normally or anonymously).
- **`linkEmail(String email)`:** Initiates the process of linking an email to an existing anonymous account.
- **`verifyLinkEmail(String code)`:** Completes the email linking process by verifying the code. On success, it returns a `Future` with the now-permanent user and a new token.
- **`deleteAccount()`:** Allows an authenticated user to delete their own account.
### 🛡️ Standardized Error Handling
- **`HttpException` Propagation:** Implementations must map underlying errors to appropriate `HttpException` subtypes (defined in `core`), ensuring consistent and predictable error management across the application layers.
> **💡 Your Advantage:** This package provides a clear, abstract interface for authentication, decoupling your application from specific authentication service providers. This design promotes flexibility, testability, and maintainability, allowing you to easily integrate and swap authentication solutions as needed, while ensuring consistent user management and error handling.
## 🔑 Licensing
This source code is licensed for commercial use and is provided for local evaluation. A **Lifetime Commercial License** is required for any production or public-facing application.
Please visit the main [Flutter News App Full Source Code Toolkit](https://github.com/flutter-news-app-full-source-code) organization page to review the full license terms and to purchase.