mesauth-angular 1.3.2 β†’ 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,305 +1,305 @@
1
- # mesauth-angular
2
-
3
- Angular helper library to connect to a backend API and SignalR hub to surface the current logged-in user and incoming notifications with dark/light theme support.
4
-
5
- ## Changelog
6
-
7
- ### v1.2.3 (2026-02-11) - **Fix Register Page Auto-Redirect**
8
- - **Fixed 401 redirect on public pages**: The interceptor now skips the login redirect when the user is on `/register`, `/forgot-password`, or `/reset-password` pages. Previously, unauthenticated users on the register page were incorrectly redirected to login when any API call returned 401.
9
-
10
- ### v1.2.2 (2026-02-06) - **Z-Index Fix for Notification UI**
11
- - **Fixed notification panel z-index**: Increased from `1000` to `1030` to appear above CoreUI sticky table headers (`z-index: 1020`)
12
- - **Fixed modal overlay z-index**: Increased from `9999` to `1060` to maintain proper layering hierarchy
13
- - **Better integration with CoreUI/Bootstrap**: Follows standard z-index scale (sticky: 1020, modals: 1050+, overlays: 1060+)
14
-
15
- ### v1.2.0 (2026-02-05) - **Notification & Auth Interceptor Fix**
16
- - **Removed route-change user polling**: `MesAuthService` no longer re-fetches the user on every `NavigationEnd` event. User is fetched once on app init; SignalR handles real-time updates. This eliminates redundant API calls and notification toast spam on every route change.
17
- - **Removed `fetchInitialNotifications()`**: Historical notifications were being emitted through `notifications$` Subject on every user refresh, causing toast popups for old notifications. The `notifications$` observable now only carries truly new real-time events from SignalR.
18
- - **`refreshUser()` returns `Observable`**: Callers can now subscribe and wait for user data to load before proceeding (e.g., navigate after login). Previously returned `void`.
19
- - **Fixed 401 redirect for expired sessions**: Removed the `!isAuthenticated` guard from the interceptor's 401 condition. When a session expires, the `BehaviorSubject` still holds stale user data, so this check was blocking the redirect to login. The `!isMeAuthPage`, `!isLoginPage`, and `!isAuthPage` guards are sufficient to prevent redirect loops.
20
-
21
- ### v1.1.0 (2026-01-21) - **Major Update**
22
- - πŸš€ **New `provideMesAuth()` Function**: Simplified setup with a single function call
23
- - ✨ **Functional Interceptor**: New `mesAuthInterceptor` for better compatibility with standalone apps
24
- - πŸ“¦ **Automatic Initialization**: `provideMesAuth()` handles service initialization via `APP_INITIALIZER`
25
- - πŸ”§ **Simplified API**: Just pass `apiBaseUrl` and `userBaseUrl` - no manual DI required
26
-
27
- ### v1.0.1 (2026-01-21)
28
- - πŸ”§ Internal refactoring for better module compatibility
29
-
30
- ### v0.2.28 (2026-01-19)
31
- - ✨ **Enhanced Avatar Support**: Direct `avatarPath` usage from user data for instant display without backend calls
32
- - πŸ”„ **Improved Avatar Refresh**: Timestamp-based cache busting prevents request cancellation issues
33
- - 🎯 **Better Change Detection**: Signal-based user updates with `ChangeDetectorRef` for reliable UI updates
34
-
35
- ### v0.2.27 (2026-01-19)
36
- - πŸ› Fixed avatar refresh issues in header components
37
- - πŸ“¦ Improved build process and dependencies
38
-
39
- ## Features
40
-
41
- - πŸ” **Authentication**: User login/logout with API integration
42
- - πŸ”” **Real-time Notifications**: SignalR integration for live notifications
43
- - 🎨 **Dark/Light Theme**: Automatic theme detection and support
44
- - πŸ–ΌοΈ **Avatar Support**: Direct API-based avatar loading
45
- - 🍞 **Toast Notifications**: In-app notification toasts
46
- - πŸ›‘οΈ **HTTP Interceptor**: Automatic 401/403 error handling with redirects
47
-
48
- ## Quick Start (v1.1.0+)
49
-
50
- ### 1. Install
51
-
52
- ```bash
53
- npm install mesauth-angular
54
- ```
55
-
56
- ### 2. Configure in app.config.ts (Recommended for Angular 14+)
57
-
58
- ```ts
59
- import { ApplicationConfig } from '@angular/core';
60
- import { provideHttpClient, withInterceptors } from '@angular/common/http';
61
- import { provideMesAuth, mesAuthInterceptor } from 'mesauth-angular';
62
-
63
- export const appConfig: ApplicationConfig = {
64
- providers: [
65
- provideHttpClient(
66
- withInterceptors([mesAuthInterceptor]) // Handles 401/403 redirects
67
- ),
68
- provideMesAuth({
69
- apiBaseUrl: 'https://mes.kefico.vn/auth',
70
- userBaseUrl: 'https://mes.kefico.vn/x' // For login/403 redirects
71
- })
72
- ]
73
- };
74
- ```
75
-
76
- That's it! The library handles:
77
- - Service initialization via `APP_INITIALIZER`
78
- - `HttpClient` and `Router` injection automatically
79
- - 401 β†’ redirects to `{userBaseUrl}/login?returnUrl=...`
80
- - 403 β†’ redirects to `{userBaseUrl}/403?returnUrl=...`
81
-
82
- ### 3. Use in Components
83
-
84
- ```ts
85
- import { MesAuthService } from 'mesauth-angular';
86
-
87
- @Component({...})
88
- export class MyComponent {
89
- private auth = inject(MesAuthService);
90
-
91
- // Observable streams
92
- currentUser$ = this.auth.currentUser$;
93
- notifications$ = this.auth.notifications$;
94
-
95
- logout() {
96
- this.auth.logout().subscribe();
97
- }
98
- }
99
- ```
100
-
101
- ## Configuration Options
102
-
103
- ```ts
104
- interface MesAuthConfig {
105
- apiBaseUrl: string; // Required: MesAuth API base URL
106
- userBaseUrl?: string; // Optional: Base URL for login/403 redirects
107
- withCredentials?: boolean; // Optional: Send cookies (default: true)
108
- }
109
- ```
110
-
111
- ## Theme Support
112
-
113
- The library automatically detects and adapts to your application's theme:
114
-
115
- ### Automatic Theme Detection
116
- The library checks for theme indicators on the `<html>` element:
117
- - `class="dark"`
118
- - `data-theme="dark"`
119
- - `theme="dark"`
120
- - `data-coreui-theme="dark"`
121
-
122
- ### Dynamic Theme Changes
123
- Theme changes are detected in real-time using `MutationObserver`, so components automatically update when your app switches themes.
124
-
125
- ### Manual Theme Control
126
- ```ts
127
- import { ThemeService } from 'mesauth-angular';
128
-
129
- // Check current theme
130
- const currentTheme = themeService.currentTheme; // 'light' | 'dark'
131
-
132
- // Manually set theme
133
- themeService.setTheme('dark');
134
-
135
- // Listen for theme changes
136
- themeService.currentTheme$.subscribe(theme => {
137
- console.log('Theme changed to:', theme);
138
- });
139
- ```
140
-
141
- ## Avatar Loading
142
-
143
- Avatars are loaded efficiently using multiple strategies:
144
-
145
- ### Primary Method: Direct Path Usage
146
- If the user object contains an `avatarPath`, it's used directly:
147
- - **Full URLs**: Used as-is (e.g., `https://example.com/avatar.jpg`)
148
- - **Relative Paths**: Combined with API base URL (e.g., `/uploads/avatar.jpg` β†’ `{apiBaseUrl}/uploads/avatar.jpg`)
149
-
150
- ### Fallback Method: API Endpoint
151
- If no `avatarPath` is available, avatars are loaded via API:
152
- - **API Endpoint**: `GET {apiBaseUrl}/auth/{userId}/avatar`
153
- - **Authentication**: Uses the same credentials as other API calls
154
-
155
- ### Cache Busting
156
- Avatar URLs include timestamps to prevent browser caching issues during updates:
157
- - Automatic refresh when user data changes
158
- - Manual refresh triggers for upload/delete operations
159
-
160
- ### Fallback Service
161
- - **UI Avatars**: Generates initials-based avatars if no user data available
162
- - **Authentication**: Not required for fallback avatars
163
-
164
- ## Components
165
-
166
- **Note:** All components are standalone and can be imported directly.
167
-
168
- ### ma-user-profile
169
-
170
- A reusable Angular component for displaying the current user's profile information, with options for navigation and logout.
171
-
172
- - **Description**: Renders user details (e.g., name, avatar) fetched via the MesAuthService. Supports custom event handlers for navigation and logout actions.
173
- - **Inputs**: None (data is sourced from the MesAuthService).
174
- - **Outputs**:
175
- - `onNavigate`: Emits an event when the user triggers navigation (e.g., to a profile page). Pass a handler to define behavior.
176
- - `onLogout`: Emits an event when the user logs out. Pass a handler to perform logout logic (e.g., clear tokens, redirect).
177
- - **Usage Example**:
178
-
179
- ```html
180
- <ma-user-profile
181
- (onNavigate)="handleNavigation($event)"
182
- (onLogout)="handleLogout()">
183
- </ma-user-profile>
184
- ```
185
-
186
- In your component's TypeScript file:
187
-
188
- ```ts
189
- handleNavigation(event: any) {
190
- // Navigate to user profile page
191
- this.router.navigate(['/profile']);
192
- }
193
-
194
- handleLogout() {
195
- // Perform logout, e.g., clear session and redirect
196
- this.mesAuth.logout(); // Assuming a logout method exists
197
- this.router.navigate(['/login']);
198
- }
199
- ```
200
-
201
- ### ma-notification-panel
202
-
203
- A standalone component for displaying a slide-out notification panel with real-time updates.
204
-
205
- - **Description**: Shows a list of notifications, allows marking as read/delete, and integrates with toast notifications for new alerts.
206
- - **Inputs**: None.
207
- - **Outputs**: None (uses internal methods for actions).
208
- - **Usage Example**:
209
-
210
- ```html
211
- <ma-notification-panel #notificationPanel></ma-notification-panel>
212
- ```
213
-
214
- In your component:
215
-
216
- ```ts
217
- // To open the panel
218
- notificationPanel.open();
219
- ```
220
-
221
- ## Migration Guide
222
-
223
- ### Upgrading from v0.x to v1.1.0+
224
-
225
- The setup has been greatly simplified. Here's how to migrate:
226
-
227
- **Before (v0.x):**
228
- ```ts
229
- // app.config.ts - OLD WAY
230
- import { MesAuthModule, MesAuthService } from 'mesauth-angular';
231
- import { HTTP_INTERCEPTORS } from '@angular/common/http';
232
-
233
- export const appConfig: ApplicationConfig = {
234
- providers: [
235
- importProvidersFrom(MesAuthModule),
236
- { provide: HTTP_INTERCEPTORS, useClass: MesAuthInterceptor, multi: true }
237
- ]
238
- };
239
-
240
- // app.component.ts - OLD WAY
241
- export class AppComponent {
242
- constructor() {
243
- this.mesAuthService.init({
244
- apiBaseUrl: '...',
245
- userBaseUrl: '...'
246
- }, inject(HttpClient), inject(Router));
247
- }
248
- }
249
- ```
250
-
251
- **After (v1.1.0+):**
252
- ```ts
253
- // app.config.ts - NEW WAY (everything in one place!)
254
- import { provideMesAuth, mesAuthInterceptor } from 'mesauth-angular';
255
-
256
- export const appConfig: ApplicationConfig = {
257
- providers: [
258
- provideHttpClient(withInterceptors([mesAuthInterceptor])),
259
- provideMesAuth({
260
- apiBaseUrl: 'https://mes.kefico.vn/auth',
261
- userBaseUrl: 'https://mes.kefico.vn/x'
262
- })
263
- ]
264
- };
265
-
266
- // app.component.ts - No init() needed!
267
- export class AppComponent {
268
- // Just inject and use - no manual initialization required
269
- }
270
- ```
271
-
272
- **Key Changes:**
273
- - `provideMesAuth()` replaces `MesAuthModule` + manual `init()` call
274
- - `mesAuthInterceptor` (functional) replaces `MesAuthInterceptor` (class-based)
275
- - No need to inject `HttpClient` or `Router` manually
276
- - Configuration moved from `AppComponent` to `app.config.ts`
277
-
278
- ## Troubleshooting
279
-
280
- ### JIT Compiler Error in Production or AOT Mode
281
- If you encounter an error like "The injectable 'MesAuthService' needs to be compiled using the JIT compiler, but '@angular/compiler' is not available," this typically occurs because:
282
- - The package is being imported directly from source code (e.g., during development) without building it first.
283
- - The client app is running in AOT (Ahead-of-Time) compilation mode, which requires pre-compiled libraries.
284
-
285
- **Solutions:**
286
- 1. **Build the package for production/AOT compatibility:**
287
- - Ensure you have built the package using `npm run build` (which uses ng-packagr or similar to generate AOT-ready code).
288
- - Install the built package via npm (e.g., from a local tarball or registry) instead of linking to the source folder.
289
-
290
- 2. **For development (if you must link to source):**
291
- - Switch your Angular app to JIT mode by bootstrapping with `@angular/platform-browser-dynamic` instead of `@angular/platform-browser`.
292
-
293
- 3. **Verify imports:**
294
- - Ensure you're importing from the built package (e.g., `import { MesAuthService } from 'mesauth-angular';`) and not from the `src` folder.
295
-
296
- ### Components Appear Empty
297
- If components like `ma-user` or `ma-user-profile` render as empty:
298
- - Ensure `provideMesAuth()` is called in your `app.config.ts`.
299
- - Check browser console for logs from components.
300
- - If `currentUser` is null, the component shows a login buttonβ€”verify the API returns user data.
301
-
302
- ## Notes
303
- - The service expects an endpoint `GET {apiBaseUrl}/auth/me` that returns the current user.
304
- - Avatar endpoint: `GET {apiBaseUrl}/auth/{userId}/avatar`
305
- - SignalR events used: `ReceiveNotification` (adjust to your backend).
1
+ # mesauth-angular
2
+
3
+ Angular helper library to connect to a backend API and SignalR hub to surface the current logged-in user and incoming notifications with dark/light theme support.
4
+
5
+ ## Changelog
6
+
7
+ ### v1.2.3 (2026-02-11) - **Fix Register Page Auto-Redirect**
8
+ - **Fixed 401 redirect on public pages**: The interceptor now skips the login redirect when the user is on `/register`, `/forgot-password`, or `/reset-password` pages. Previously, unauthenticated users on the register page were incorrectly redirected to login when any API call returned 401.
9
+
10
+ ### v1.2.2 (2026-02-06) - **Z-Index Fix for Notification UI**
11
+ - **Fixed notification panel z-index**: Increased from `1000` to `1030` to appear above CoreUI sticky table headers (`z-index: 1020`)
12
+ - **Fixed modal overlay z-index**: Increased from `9999` to `1060` to maintain proper layering hierarchy
13
+ - **Better integration with CoreUI/Bootstrap**: Follows standard z-index scale (sticky: 1020, modals: 1050+, overlays: 1060+)
14
+
15
+ ### v1.2.0 (2026-02-05) - **Notification & Auth Interceptor Fix**
16
+ - **Removed route-change user polling**: `MesAuthService` no longer re-fetches the user on every `NavigationEnd` event. User is fetched once on app init; SignalR handles real-time updates. This eliminates redundant API calls and notification toast spam on every route change.
17
+ - **Removed `fetchInitialNotifications()`**: Historical notifications were being emitted through `notifications$` Subject on every user refresh, causing toast popups for old notifications. The `notifications$` observable now only carries truly new real-time events from SignalR.
18
+ - **`refreshUser()` returns `Observable`**: Callers can now subscribe and wait for user data to load before proceeding (e.g., navigate after login). Previously returned `void`.
19
+ - **Fixed 401 redirect for expired sessions**: Removed the `!isAuthenticated` guard from the interceptor's 401 condition. When a session expires, the `BehaviorSubject` still holds stale user data, so this check was blocking the redirect to login. The `!isMeAuthPage`, `!isLoginPage`, and `!isAuthPage` guards are sufficient to prevent redirect loops.
20
+
21
+ ### v1.1.0 (2026-01-21) - **Major Update**
22
+ - πŸš€ **New `provideMesAuth()` Function**: Simplified setup with a single function call
23
+ - ✨ **Functional Interceptor**: New `mesAuthInterceptor` for better compatibility with standalone apps
24
+ - πŸ“¦ **Automatic Initialization**: `provideMesAuth()` handles service initialization via `APP_INITIALIZER`
25
+ - πŸ”§ **Simplified API**: Just pass `apiBaseUrl` and `userBaseUrl` - no manual DI required
26
+
27
+ ### v1.0.1 (2026-01-21)
28
+ - πŸ”§ Internal refactoring for better module compatibility
29
+
30
+ ### v0.2.28 (2026-01-19)
31
+ - ✨ **Enhanced Avatar Support**: Direct `avatarPath` usage from user data for instant display without backend calls
32
+ - πŸ”„ **Improved Avatar Refresh**: Timestamp-based cache busting prevents request cancellation issues
33
+ - 🎯 **Better Change Detection**: Signal-based user updates with `ChangeDetectorRef` for reliable UI updates
34
+
35
+ ### v0.2.27 (2026-01-19)
36
+ - πŸ› Fixed avatar refresh issues in header components
37
+ - πŸ“¦ Improved build process and dependencies
38
+
39
+ ## Features
40
+
41
+ - πŸ” **Authentication**: User login/logout with API integration
42
+ - πŸ”” **Real-time Notifications**: SignalR integration for live notifications
43
+ - 🎨 **Dark/Light Theme**: Automatic theme detection and support
44
+ - πŸ–ΌοΈ **Avatar Support**: Direct API-based avatar loading
45
+ - 🍞 **Toast Notifications**: In-app notification toasts
46
+ - πŸ›‘οΈ **HTTP Interceptor**: Automatic 401/403 error handling with redirects
47
+
48
+ ## Quick Start (v1.1.0+)
49
+
50
+ ### 1. Install
51
+
52
+ ```bash
53
+ npm install mesauth-angular
54
+ ```
55
+
56
+ ### 2. Configure in app.config.ts (Recommended for Angular 14+)
57
+
58
+ ```ts
59
+ import { ApplicationConfig } from '@angular/core';
60
+ import { provideHttpClient, withInterceptors } from '@angular/common/http';
61
+ import { provideMesAuth, mesAuthInterceptor } from 'mesauth-angular';
62
+
63
+ export const appConfig: ApplicationConfig = {
64
+ providers: [
65
+ provideHttpClient(
66
+ withInterceptors([mesAuthInterceptor]) // Handles 401/403 redirects
67
+ ),
68
+ provideMesAuth({
69
+ apiBaseUrl: 'https://mes.kefico.vn/auth',
70
+ userBaseUrl: 'https://mes.kefico.vn/x' // For login/403 redirects
71
+ })
72
+ ]
73
+ };
74
+ ```
75
+
76
+ That's it! The library handles:
77
+ - Service initialization via `APP_INITIALIZER`
78
+ - `HttpClient` and `Router` injection automatically
79
+ - 401 β†’ redirects to `{userBaseUrl}/login?returnUrl=...`
80
+ - 403 β†’ redirects to `{userBaseUrl}/403?returnUrl=...`
81
+
82
+ ### 3. Use in Components
83
+
84
+ ```ts
85
+ import { MesAuthService } from 'mesauth-angular';
86
+
87
+ @Component({...})
88
+ export class MyComponent {
89
+ private auth = inject(MesAuthService);
90
+
91
+ // Observable streams
92
+ currentUser$ = this.auth.currentUser$;
93
+ notifications$ = this.auth.notifications$;
94
+
95
+ logout() {
96
+ this.auth.logout().subscribe();
97
+ }
98
+ }
99
+ ```
100
+
101
+ ## Configuration Options
102
+
103
+ ```ts
104
+ interface MesAuthConfig {
105
+ apiBaseUrl: string; // Required: MesAuth API base URL
106
+ userBaseUrl?: string; // Optional: Base URL for login/403 redirects
107
+ withCredentials?: boolean; // Optional: Send cookies (default: true)
108
+ }
109
+ ```
110
+
111
+ ## Theme Support
112
+
113
+ The library automatically detects and adapts to your application's theme:
114
+
115
+ ### Automatic Theme Detection
116
+ The library checks for theme indicators on the `<html>` element:
117
+ - `class="dark"`
118
+ - `data-theme="dark"`
119
+ - `theme="dark"`
120
+ - `data-coreui-theme="dark"`
121
+
122
+ ### Dynamic Theme Changes
123
+ Theme changes are detected in real-time using `MutationObserver`, so components automatically update when your app switches themes.
124
+
125
+ ### Manual Theme Control
126
+ ```ts
127
+ import { ThemeService } from 'mesauth-angular';
128
+
129
+ // Check current theme
130
+ const currentTheme = themeService.currentTheme; // 'light' | 'dark'
131
+
132
+ // Manually set theme
133
+ themeService.setTheme('dark');
134
+
135
+ // Listen for theme changes
136
+ themeService.currentTheme$.subscribe(theme => {
137
+ console.log('Theme changed to:', theme);
138
+ });
139
+ ```
140
+
141
+ ## Avatar Loading
142
+
143
+ Avatars are loaded efficiently using multiple strategies:
144
+
145
+ ### Primary Method: Direct Path Usage
146
+ If the user object contains an `avatarPath`, it's used directly:
147
+ - **Full URLs**: Used as-is (e.g., `https://example.com/avatar.jpg`)
148
+ - **Relative Paths**: Combined with API base URL (e.g., `/uploads/avatar.jpg` β†’ `{apiBaseUrl}/uploads/avatar.jpg`)
149
+
150
+ ### Fallback Method: API Endpoint
151
+ If no `avatarPath` is available, avatars are loaded via API:
152
+ - **API Endpoint**: `GET {apiBaseUrl}/auth/{userId}/avatar`
153
+ - **Authentication**: Uses the same credentials as other API calls
154
+
155
+ ### Cache Busting
156
+ Avatar URLs include timestamps to prevent browser caching issues during updates:
157
+ - Automatic refresh when user data changes
158
+ - Manual refresh triggers for upload/delete operations
159
+
160
+ ### Fallback Service
161
+ - **UI Avatars**: Generates initials-based avatars if no user data available
162
+ - **Authentication**: Not required for fallback avatars
163
+
164
+ ## Components
165
+
166
+ **Note:** All components are standalone and can be imported directly.
167
+
168
+ ### ma-user-profile
169
+
170
+ A reusable Angular component for displaying the current user's profile information, with options for navigation and logout.
171
+
172
+ - **Description**: Renders user details (e.g., name, avatar) fetched via the MesAuthService. Supports custom event handlers for navigation and logout actions.
173
+ - **Inputs**: None (data is sourced from the MesAuthService).
174
+ - **Outputs**:
175
+ - `onNavigate`: Emits an event when the user triggers navigation (e.g., to a profile page). Pass a handler to define behavior.
176
+ - `onLogout`: Emits an event when the user logs out. Pass a handler to perform logout logic (e.g., clear tokens, redirect).
177
+ - **Usage Example**:
178
+
179
+ ```html
180
+ <ma-user-profile
181
+ (onNavigate)="handleNavigation($event)"
182
+ (onLogout)="handleLogout()">
183
+ </ma-user-profile>
184
+ ```
185
+
186
+ In your component's TypeScript file:
187
+
188
+ ```ts
189
+ handleNavigation(event: any) {
190
+ // Navigate to user profile page
191
+ this.router.navigate(['/profile']);
192
+ }
193
+
194
+ handleLogout() {
195
+ // Perform logout, e.g., clear session and redirect
196
+ this.mesAuth.logout(); // Assuming a logout method exists
197
+ this.router.navigate(['/login']);
198
+ }
199
+ ```
200
+
201
+ ### ma-notification-panel
202
+
203
+ A standalone component for displaying a slide-out notification panel with real-time updates.
204
+
205
+ - **Description**: Shows a list of notifications, allows marking as read/delete, and integrates with toast notifications for new alerts.
206
+ - **Inputs**: None.
207
+ - **Outputs**: None (uses internal methods for actions).
208
+ - **Usage Example**:
209
+
210
+ ```html
211
+ <ma-notification-panel #notificationPanel></ma-notification-panel>
212
+ ```
213
+
214
+ In your component:
215
+
216
+ ```ts
217
+ // To open the panel
218
+ notificationPanel.open();
219
+ ```
220
+
221
+ ## Migration Guide
222
+
223
+ ### Upgrading from v0.x to v1.1.0+
224
+
225
+ The setup has been greatly simplified. Here's how to migrate:
226
+
227
+ **Before (v0.x):**
228
+ ```ts
229
+ // app.config.ts - OLD WAY
230
+ import { MesAuthModule, MesAuthService } from 'mesauth-angular';
231
+ import { HTTP_INTERCEPTORS } from '@angular/common/http';
232
+
233
+ export const appConfig: ApplicationConfig = {
234
+ providers: [
235
+ importProvidersFrom(MesAuthModule),
236
+ { provide: HTTP_INTERCEPTORS, useClass: MesAuthInterceptor, multi: true }
237
+ ]
238
+ };
239
+
240
+ // app.component.ts - OLD WAY
241
+ export class AppComponent {
242
+ constructor() {
243
+ this.mesAuthService.init({
244
+ apiBaseUrl: '...',
245
+ userBaseUrl: '...'
246
+ }, inject(HttpClient), inject(Router));
247
+ }
248
+ }
249
+ ```
250
+
251
+ **After (v1.1.0+):**
252
+ ```ts
253
+ // app.config.ts - NEW WAY (everything in one place!)
254
+ import { provideMesAuth, mesAuthInterceptor } from 'mesauth-angular';
255
+
256
+ export const appConfig: ApplicationConfig = {
257
+ providers: [
258
+ provideHttpClient(withInterceptors([mesAuthInterceptor])),
259
+ provideMesAuth({
260
+ apiBaseUrl: 'https://mes.kefico.vn/auth',
261
+ userBaseUrl: 'https://mes.kefico.vn/x'
262
+ })
263
+ ]
264
+ };
265
+
266
+ // app.component.ts - No init() needed!
267
+ export class AppComponent {
268
+ // Just inject and use - no manual initialization required
269
+ }
270
+ ```
271
+
272
+ **Key Changes:**
273
+ - `provideMesAuth()` replaces `MesAuthModule` + manual `init()` call
274
+ - `mesAuthInterceptor` (functional) replaces `MesAuthInterceptor` (class-based)
275
+ - No need to inject `HttpClient` or `Router` manually
276
+ - Configuration moved from `AppComponent` to `app.config.ts`
277
+
278
+ ## Troubleshooting
279
+
280
+ ### JIT Compiler Error in Production or AOT Mode
281
+ If you encounter an error like "The injectable 'MesAuthService' needs to be compiled using the JIT compiler, but '@angular/compiler' is not available," this typically occurs because:
282
+ - The package is being imported directly from source code (e.g., during development) without building it first.
283
+ - The client app is running in AOT (Ahead-of-Time) compilation mode, which requires pre-compiled libraries.
284
+
285
+ **Solutions:**
286
+ 1. **Build the package for production/AOT compatibility:**
287
+ - Ensure you have built the package using `npm run build` (which uses ng-packagr or similar to generate AOT-ready code).
288
+ - Install the built package via npm (e.g., from a local tarball or registry) instead of linking to the source folder.
289
+
290
+ 2. **For development (if you must link to source):**
291
+ - Switch your Angular app to JIT mode by bootstrapping with `@angular/platform-browser-dynamic` instead of `@angular/platform-browser`.
292
+
293
+ 3. **Verify imports:**
294
+ - Ensure you're importing from the built package (e.g., `import { MesAuthService } from 'mesauth-angular';`) and not from the `src` folder.
295
+
296
+ ### Components Appear Empty
297
+ If components like `ma-user` or `ma-user-profile` render as empty:
298
+ - Ensure `provideMesAuth()` is called in your `app.config.ts`.
299
+ - Check browser console for logs from components.
300
+ - If `currentUser` is null, the component shows a login buttonβ€”verify the API returns user data.
301
+
302
+ ## Notes
303
+ - The service expects an endpoint `GET {apiBaseUrl}/auth/me` that returns the current user.
304
+ - Avatar endpoint: `GET {apiBaseUrl}/auth/{userId}/avatar`
305
+ - SignalR events used: `ReceiveNotification` (adjust to your backend).