From 9014c195d7ae83dd5e05370d16533cab746da33c Mon Sep 17 00:00:00 2001 From: fulleni Date: Tue, 23 Sep 2025 22:45:31 +0100 Subject: [PATCH 1/6] chore(.gitignore): update ignored files and directories - Remove obsolete comments - Remove pubspec --- .gitignore | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 526da15..171d7ac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,4 @@ -# See https://www.dartlang.org/guides/libraries/private-files - -# Files and directories created by pub .dart_tool/ .packages build/ -pubspec.lock \ No newline at end of file +coverage/ \ No newline at end of file From 26cdbd1e583de2362131516e0f99785eefa61662 Mon Sep 17 00:00:00 2001 From: fulleni Date: Tue, 23 Sep 2025 22:45:44 +0100 Subject: [PATCH 2/6] chore: remove code coverage data - Deleted lcov.info file from coverage directory - This file was likely containing code coverage report data - Removing it to avoid including test artifacts in the repository --- coverage/lcov.info | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 coverage/lcov.info diff --git a/coverage/lcov.info b/coverage/lcov.info deleted file mode 100644 index 7cf076e..0000000 --- a/coverage/lcov.info +++ /dev/null @@ -1,43 +0,0 @@ -SF:lib\src\auth_repository.dart -DA:22,1 -DA:34,3 -DA:42,1 -DA:44,2 -DA:45,1 -DA:59,1 -DA:64,2 -DA:68,1 -DA:80,1 -DA:86,2 -DA:92,1 -DA:93,1 -DA:94,1 -DA:96,1 -DA:98,1 -DA:111,1 -DA:113,2 -DA:115,1 -DA:116,1 -DA:117,1 -DA:119,1 -DA:121,1 -DA:134,1 -DA:136,2 -DA:137,1 -DA:138,1 -DA:140,1 -DA:148,1 -DA:150,2 -DA:151,1 -DA:154,1 -DA:164,1 -DA:166,2 -DA:167,1 -DA:169,1 -DA:171,1 -DA:179,1 -DA:181,3 -DA:182,1 -LF:39 -LH:39 -end_of_record From 076a0ca615d9e5730dd9b300afa6b982b360b33b Mon Sep 17 00:00:00 2001 From: fulleni Date: Tue, 23 Sep 2025 22:48:25 +0100 Subject: [PATCH 3/6] chore(deps): update dependencies and add git refs - Add git refs to auth_client, core, and kv_storage_service dependencies - Update other dependencies to their latest versions - Add mocktail as a dev dependency --- pubspec.lock | 472 +++++++++++++++++++++++++++++++++++++++++++++++++++ pubspec.yaml | 3 + 2 files changed, 475 insertions(+) create mode 100644 pubspec.lock diff --git a/pubspec.lock b/pubspec.lock new file mode 100644 index 0000000..69ace75 --- /dev/null +++ b/pubspec.lock @@ -0,0 +1,472 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: dd3d2ad434b9510001d089e8de7556d50c834481b9abc2891a0184a8493a19dc + url: "https://pub.dev" + source: hosted + version: "89.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: c22b6e7726d1f9e5db58c7251606076a71ca0dbcf76116675edfadbec0c9e875 + url: "https://pub.dev" + source: hosted + version: "8.2.0" + args: + dependency: transitive + description: + name: args + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 + url: "https://pub.dev" + source: hosted + version: "2.7.0" + async: + dependency: transitive + description: + name: async + sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" + url: "https://pub.dev" + source: hosted + version: "2.13.0" + auth_client: + dependency: "direct main" + description: + path: "." + ref: fec23f405d58d4915638783d972b542d3faf96b2 + resolved-ref: fec23f405d58d4915638783d972b542d3faf96b2 + url: "https://github.com/flutter-news-app-full-source-code/auth-client.git" + source: git + version: "0.0.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + cli_config: + dependency: transitive + description: + name: cli_config + sha256: ac20a183a07002b700f0c25e61b7ee46b23c309d76ab7b7640a028f18e4d99ec + url: "https://pub.dev" + source: hosted + version: "0.2.0" + collection: + dependency: transitive + description: + name: collection + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" + source: hosted + version: "1.19.1" + convert: + dependency: transitive + description: + name: convert + sha256: b30acd5944035672bc15c6b7a8b47d773e41e2f17de064350988c5d02adb1c68 + url: "https://pub.dev" + source: hosted + version: "3.1.2" + core: + dependency: "direct main" + description: + path: "." + ref: "828b984517edec069266579c624c7af9fbe0e2ac" + resolved-ref: "828b984517edec069266579c624c7af9fbe0e2ac" + url: "https://github.com/flutter-news-app-full-source-code/core.git" + source: git + version: "0.0.0" + coverage: + dependency: transitive + description: + name: coverage + sha256: "5da775aa218eaf2151c721b16c01c7676fbfdd99cebba2bf64e8b807a28ff94d" + url: "https://pub.dev" + source: hosted + version: "1.15.0" + crypto: + dependency: transitive + description: + name: crypto + sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855" + url: "https://pub.dev" + source: hosted + version: "3.0.6" + equatable: + dependency: transitive + description: + name: equatable + sha256: "567c64b3cb4cf82397aac55f4f0cbd3ca20d77c6c03bedbc4ceaddc08904aef7" + url: "https://pub.dev" + source: hosted + version: "2.0.7" + file: + dependency: transitive + description: + name: file + sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 + url: "https://pub.dev" + source: hosted + version: "7.0.1" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be + url: "https://pub.dev" + source: hosted + version: "1.1.1" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694 + url: "https://pub.dev" + source: hosted + version: "4.0.0" + glob: + dependency: transitive + description: + name: glob + sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de + url: "https://pub.dev" + source: hosted + version: "2.1.3" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: aa6199f908078bb1c5efb8d8638d4ae191aac11b311132c3ef48ce352fb52ef8 + url: "https://pub.dev" + source: hosted + version: "3.2.2" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + url: "https://pub.dev" + source: hosted + version: "4.1.2" + io: + dependency: transitive + description: + name: io + sha256: dfd5a80599cf0165756e3181807ed3e77daf6dd4137caaad72d0b7931597650b + url: "https://pub.dev" + source: hosted + version: "1.0.5" + js: + dependency: transitive + description: + name: js + sha256: "53385261521cc4a0c4658fd0ad07a7d14591cf8fc33abbceae306ddb974888dc" + url: "https://pub.dev" + source: hosted + version: "0.7.2" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + url: "https://pub.dev" + source: hosted + version: "4.9.0" + kv_storage_service: + dependency: "direct main" + description: + path: "." + ref: "3bcba6b11fe0480e06e1bedf6eab4159a7c59c53" + resolved-ref: "3bcba6b11fe0480e06e1bedf6eab4159a7c59c53" + url: "https://github.com/flutter-news-app-full-source-code/kv-storage-service.git" + source: git + version: "0.0.0" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.dev" + source: hosted + version: "1.3.0" + matcher: + dependency: transitive + description: + name: matcher + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 + url: "https://pub.dev" + source: hosted + version: "0.12.17" + meta: + dependency: transitive + description: + name: meta + sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" + url: "https://pub.dev" + source: hosted + version: "1.17.0" + mime: + dependency: transitive + description: + name: mime + sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + mocktail: + dependency: "direct dev" + description: + name: mocktail + sha256: "890df3f9688106f25755f26b1c60589a92b3ab91a22b8b224947ad041bf172d8" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + node_preamble: + dependency: transitive + description: + name: node_preamble + sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" + url: "https://pub.dev" + source: hosted + version: "2.0.2" + package_config: + dependency: transitive + description: + name: package_config + sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc + url: "https://pub.dev" + source: hosted + version: "2.2.0" + path: + dependency: transitive + description: + name: path + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + pool: + dependency: transitive + description: + name: pool + sha256: "978783255c543aa3586a1b3c21f6e9d720eb315376a915872c61ef8b5c20177d" + url: "https://pub.dev" + source: hosted + version: "1.5.2" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + shelf: + dependency: transitive + description: + name: shelf + sha256: e7dd780a7ffb623c57850b33f43309312fc863fb6aa3d276a754bb299839ef12 + url: "https://pub.dev" + source: hosted + version: "1.4.2" + shelf_packages_handler: + dependency: transitive + description: + name: shelf_packages_handler + sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + shelf_static: + dependency: transitive + description: + name: shelf_static + sha256: c87c3875f91262785dade62d135760c2c69cb217ac759485334c5857ad89f6e3 + url: "https://pub.dev" + source: hosted + version: "1.1.3" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: "3632775c8e90d6c9712f883e633716432a27758216dfb61bd86a8321c0580925" + url: "https://pub.dev" + source: hosted + version: "3.0.0" + source_map_stack_trace: + dependency: transitive + description: + name: source_map_stack_trace + sha256: c0713a43e323c3302c2abe2a1cc89aa057a387101ebd280371d6a6c9fa68516b + url: "https://pub.dev" + source: hosted + version: "2.1.2" + source_maps: + dependency: transitive + description: + name: source_maps + sha256: "190222579a448b03896e0ca6eca5998fa810fda630c1d65e2f78b3f638f54812" + url: "https://pub.dev" + source: hosted + version: "0.10.13" + source_span: + dependency: transitive + description: + name: source_span + sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" + url: "https://pub.dev" + source: hosted + version: "1.10.1" + sprintf: + dependency: transitive + description: + name: sprintf + sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23" + url: "https://pub.dev" + source: hosted + version: "7.0.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.dev" + source: hosted + version: "1.12.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" + url: "https://pub.dev" + source: hosted + version: "1.4.1" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" + url: "https://pub.dev" + source: hosted + version: "1.2.2" + test: + dependency: "direct dev" + description: + name: test + sha256: "75906bf273541b676716d1ca7627a17e4c4070a3a16272b7a3dc7da3b9f3f6b7" + url: "https://pub.dev" + source: hosted + version: "1.26.3" + test_api: + dependency: transitive + description: + name: test_api + sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55 + url: "https://pub.dev" + source: hosted + version: "0.7.7" + test_core: + dependency: transitive + description: + name: test_core + sha256: "0cc24b5ff94b38d2ae73e1eb43cc302b77964fbf67abad1e296025b78deb53d0" + url: "https://pub.dev" + source: hosted + version: "0.6.12" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + uuid: + dependency: transitive + description: + name: uuid + sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff + url: "https://pub.dev" + source: hosted + version: "4.5.1" + very_good_analysis: + dependency: "direct dev" + description: + name: very_good_analysis + sha256: e479fbc0941009262343db308133e121bf8660c2c81d48dd8e952df7b7e1e382 + url: "https://pub.dev" + source: hosted + version: "9.0.0" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60" + url: "https://pub.dev" + source: hosted + version: "15.0.2" + watcher: + dependency: transitive + description: + name: watcher + sha256: "5bf046f41320ac97a469d506261797f35254fa61c641741ef32dacda98b7d39c" + url: "https://pub.dev" + source: hosted + version: "1.1.3" + web: + dependency: transitive + description: + name: web + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + web_socket: + dependency: transitive + description: + name: web_socket + sha256: "34d64019aa8e36bf9842ac014bb5d2f5586ca73df5e4d9bf5c936975cae6982c" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: d645757fb0f4773d602444000a8131ff5d48c9e47adfe9772652dd1a4f2d45c8 + url: "https://pub.dev" + source: hosted + version: "3.0.3" + webkit_inspection_protocol: + dependency: transitive + description: + name: webkit_inspection_protocol + sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" + url: "https://pub.dev" + source: hosted + version: "1.2.1" + yaml: + dependency: transitive + description: + name: yaml + sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce + url: "https://pub.dev" + source: hosted + version: "3.1.3" +sdks: + dart: ">=3.9.0 <4.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index c75b36b..d5eaa78 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,12 +10,15 @@ dependencies: auth_client: git: url: https://github.com/flutter-news-app-full-source-code/auth-client.git + ref: fec23f405d58d4915638783d972b542d3faf96b2 core: git: url: https://github.com/flutter-news-app-full-source-code/core.git + ref: 828b984517edec069266579c624c7af9fbe0e2ac kv_storage_service: git: url: https://github.com/flutter-news-app-full-source-code/kv-storage-service.git + ref: 3bcba6b11fe0480e06e1bedf6eab4159a7c59c53 dev_dependencies: mocktail: ^1.0.4 From 8a867645394501f806d5658e385605e3628656ab Mon Sep 17 00:00:00 2001 From: fulleni Date: Tue, 23 Sep 2025 22:48:53 +0100 Subject: [PATCH 4/6] build: update very_good_analysis to version 9.0.0 - Update analysis_options.yaml to include version 9.0.0 of very_good_analysis - This change ensures the project adheres to the latest linting and analysis rules --- analysis_options.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index e536809..4b70142 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:very_good_analysis/analysis_options.6.0.0.yaml +include: package:very_good_analysis/analysis_options.9.0.0.yaml analyzer: errors: lines_longer_than_80_chars: ignore From cea94b66b420e78d7832976703fc972c992e5bac Mon Sep 17 00:00:00 2001 From: fulleni Date: Tue, 23 Sep 2025 22:49:29 +0100 Subject: [PATCH 5/6] chore: ignore document_ignores in analysis_options.yaml - Added 'document_ignores: ignore' to the analyzer errors section - This change allows ignoring of documented ignores in the analysis options --- analysis_options.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/analysis_options.yaml b/analysis_options.yaml index 4b70142..406455a 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -2,3 +2,4 @@ include: package:very_good_analysis/analysis_options.9.0.0.yaml analyzer: errors: lines_longer_than_80_chars: ignore + document_ignores: ignore From 3beb513fae3e9401a86c8d2f7d25b5be9faeebdd Mon Sep 17 00:00:00 2001 From: fulleni Date: Tue, 23 Sep 2025 22:50:52 +0100 Subject: [PATCH 6/6] docs(README): overhaul documentation for clarity and visual appeal - Add project logo and improve README structure - Introduce badge for live documentation - Enhance feature description with summaries - Refactor usage instructions into detailed example - Consolidate licensing information --- README.md | 124 ++++++++++++------------------------------------------ 1 file changed, 28 insertions(+), 96 deletions(-) diff --git a/README.md b/README.md index f692a41..1651afd 100644 --- a/README.md +++ b/README.md @@ -1,110 +1,42 @@ -# auth_repository +
+ Flutter News App Toolkit Logo +

Auth Repository

+

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

+
-![coverage: percentage](https://img.shields.io/badge/coverage-100-green) -[![style: very good analysis](https://img.shields.io/badge/style-very_good_analysis-B22C89.svg)](https://pub.dev/packages/very_good_analysis) -[![License: PolyForm Free Trial](https://img.shields.io/badge/License-PolyForm%20Free%20Trial-blue)](https://polyformproject.org/licenses/free-trial/1.0.0) +

+ coverage + Live Docs: View + Main Project: Browse +

-A repository package that provides an abstraction layer over authentication operations. It wraps an `AuthClient` implementation, offering a clean interface for authentication flows, ensuring standardized exception propagation, and handling authentication token persistence using `KvStorageService`. +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. -## Getting Started +## ⭐ Feature Showcase: Business-Focused Authentication Management -Add the package to your `pubspec.yaml`: +This package offers a comprehensive set of features for managing authentication operations. -```yaml -dependencies: - auth-repository: - git: - url: https://github.com/flutter-news-app-full-source-code/auth-repository.git +
+🧱 Core Functionality -## Features +### 🚀 `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). -- Abstracts authentication logic from the UI/business logic layers. -- Provides methods for a complete authentication lifecycle: - - `authStateChanges`: Stream of user authentication state. - - `getCurrentUser`: Retrieves the current authenticated user. - - `requestSignInCode`: Initiates email+code sign-in. - - `verifySignInCode`: Verifies the code, saves the auth token, and returns the user. - - `signInAnonymously`: Signs in anonymously, saves the auth token, and returns the user. - - `signOut`: Signs out the user and clears the auth token. -- Manages authentication token persistence internally using `KvStorageService`. - - Exposes `saveAuthToken(String token)`, `getAuthToken()`, and `clearAuthToken()` for direct token manipulation if needed, but these are typically handled by the main auth flow methods. -- Propagates standardized `HttpException`s from the underlying client and `StorageException`s from the storage service. +### 🌐 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. -## Usage +### 🛡️ 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. -Instantiate `AuthRepository` by providing implementations of `AuthClient` and `KvStorageService`: +### 💉 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. -```dart -import 'package:auth_client/auth_client.dart'; -import 'package:auth_repository/auth_repository.dart'; -import 'package:kv_storage_service/kv_storage_service.dart'; +> **💡 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. -// Assume ConcreteAuthClient is an implementation of AuthClient -final authClient = ConcreteAuthClient(...); - -// Assume ConcreteKVStorageService is an implementation of KvStorageService -final storageService = ConcreteKVStorageService(...); - -final authRepository = AuthRepository( - authClient: authClient, - storageService: storageService, -); - -// Example usage: -authRepository.authStateChanges.listen((user) { - // Handle auth state changes -}); - -try { - await authRepository.requestSignInCode('test@example.com'); - // Handle success -} on InvalidInputException catch (e) { - // Handle invalid email -} catch (e) { - // Handle other errors -} - -// Example usage: -try { - final user = await authRepository.verifySignInCode('test@example.com', '123456'); - // User is signed in, token is saved automatically. - print('User signed in: ${user.id}'); -} on AuthenticationException catch (e) { - // Handle invalid code -} on StorageException catch (e) { - // Handle failure to save token -} catch (e) { - // Handle other errors -} - -// Example of anonymous sign-in: -try { - final anonUser = await authRepository.signInAnonymously(); - // User is signed in anonymously, token is saved automatically. - print('Anonymous user signed in: ${anonUser.id}'); -} catch (e) { - // Handle errors -} - -// Example of sign-out: -try { - await authRepository.signOut(); - // User is signed out, token is cleared automatically. - print('User signed out.'); -} catch (e) { - // Handle errors -} - -// Direct token access (e.g., for HTTP client interceptors): -Future getTokenForHttpClient() async { - final token = await authRepository.getAuthToken(); - print('Retrieved token for HTTP client: $token'); - return token; -} -``` +
## 🔑 Licensing -This package is source-available and licensed under the [PolyForm Free Trial 1.0.0](LICENSE). Please review the terms before use. - -For commercial licensing options that grant the right to build and distribute unlimited applications, please visit the main [**Flutter News App - Full Source Code Toolkit**](https://github.com/flutter-news-app-full-source-code) organization. +This `auth_repository` package is an integral part of the [**Flutter News App Full Source Code Toolkit**](https://github.com/flutter-news-app-full-source-code). For comprehensive details regarding licensing, including trial and commercial options for the entire toolkit, please refer to the main toolkit organization page.