An open API service indexing awesome lists of open source software.

https://github.com/flutter-news-app-full-source-code/auth-repository

A repository that provides an abstraction layer over authentication operations for the Flutter News App Toolkit.
https://github.com/flutter-news-app-full-source-code/auth-repository

Last synced: 4 months ago
JSON representation

A repository that provides an abstraction layer over authentication operations for the Flutter News App Toolkit.

Awesome Lists containing this project

README

          


Flutter News App Toolkit Logo

Auth Repository


A repository that provides an abstraction layer over authentication operations for the Flutter News App Toolkit.



coverage
Live Docs: View
Main Project: Browse

This `auth_repository` package contains the `AuthRepository` class, which acts as an abstraction layer over an `AuthClient` implementation (from the `auth_client` package) within the [**Flutter News App Full Source Code Toolkit**](https://github.com/flutter-news-app-full-source-code). Its primary purpose is to provide a clean, business-focused interface for authentication flows, ensuring standardized exception propagation, and handling authentication token persistence using `KvStorageService`. This repository effectively decouples the application's core logic from the specifics of authentication mechanisms and token storage.

## ⭐ Feature Showcase: Business-Focused Authentication Management

This package offers a comprehensive set of features for managing authentication operations.

🧱 Core Functionality

### 🚀 `AuthRepository` Class
- **`AuthRepository`:** Provides a clean, business-focused interface for authentication-related tasks, abstracting the underlying `AuthClient` implementation.
- **Complete Authentication Lifecycle:** Offers methods for a full authentication lifecycle, including `authStateChanges` (stream of user authentication state), `getCurrentUser` (retrieves current user), `requestSignInCode` (initiates email+code sign-in), `verifySignInCode` (verifies code, saves token, returns user), `signInAnonymously` (signs in anonymously, saves token, returns user), and `signOut` (signs out user, clears token).

### 🌐 Token Persistence Management
- **`KvStorageService` Integration:** Manages authentication token persistence internally using an injected `KvStorageService`.
- **Direct Token Access:** Exposes `saveAuthToken(String token)`, `getAuthToken()`, and `clearAuthToken()` for direct token manipulation, though these are typically handled by the main authentication flow methods.

### 🛡️ Standardized Error Handling
- **Exception Propagation:** Propagates standardized `HttpException`s (from `core`) from the underlying client and `StorageException`s (from `kv_storage_service`), ensuring consistent and predictable error management across the application layers.

### 💉 Dependency Injection Ready
- **`AuthClient` & `KvStorageService` Dependencies:** Requires instances of `AuthClient` (from `auth_client`) and `KvStorageService` (from `kv_storage_service`) via its constructor, promoting loose coupling and testability.

> **💡 Your Advantage:** This package provides a business-focused abstraction for authentication operations, simplifying the integration of user authentication into your application logic. It ensures consistent error handling, manages token persistence, and decouples your core application from specific authentication and storage implementations, enhancing maintainability and flexibility.

## 🔑 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.