mesauth-angular 1.0.0 → 1.1.1

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/dist/index.d.ts CHANGED
@@ -1,14 +1,35 @@
1
- import { HttpClient, HttpInterceptor, HttpRequest, HttpHandler, HttpEvent } from '@angular/common/http';
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, EnvironmentProviders, OnDestroy, OnInit, EventEmitter, ChangeDetectorRef, AfterViewInit } from '@angular/core';
3
+ import { HttpClient, HttpInterceptorFn } from '@angular/common/http';
2
4
  import { Observable } from 'rxjs';
3
5
  import { Router } from '@angular/router';
4
- import * as i0 from '@angular/core';
5
- import { OnDestroy, OnInit, EventEmitter, ChangeDetectorRef, AfterViewInit } from '@angular/core';
6
6
 
7
7
  interface MesAuthConfig {
8
8
  apiBaseUrl: string;
9
9
  withCredentials?: boolean;
10
10
  userBaseUrl?: string;
11
11
  }
12
+ /** Injection token for MesAuth configuration */
13
+ declare const MES_AUTH_CONFIG: InjectionToken<MesAuthConfig>;
14
+ /**
15
+ * Provides MesAuth with configuration.
16
+ * This is the recommended way to set up mesauth-angular in standalone apps.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * // app.config.ts
21
+ * export const appConfig: ApplicationConfig = {
22
+ * providers: [
23
+ * provideHttpClient(withInterceptors([mesAuthInterceptor])),
24
+ * provideMesAuth({
25
+ * apiBaseUrl: 'https://auth.example.com',
26
+ * userBaseUrl: 'https://app.example.com'
27
+ * })
28
+ * ]
29
+ * };
30
+ * ```
31
+ */
32
+ declare function provideMesAuth(config: MesAuthConfig): EnvironmentProviders;
12
33
  interface IUser {
13
34
  userId?: string;
14
35
  userName?: string;
@@ -205,14 +226,12 @@ declare class MesAuthService {
205
226
  static ɵprov: i0.ɵɵInjectableDeclaration<MesAuthService>;
206
227
  }
207
228
 
208
- declare class MesAuthInterceptor implements HttpInterceptor {
209
- private authService;
210
- private router;
211
- constructor(authService: MesAuthService, router: Router);
212
- intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
213
- static ɵfac: i0.ɵɵFactoryDeclaration<MesAuthInterceptor, never>;
214
- static ɵprov: i0.ɵɵInjectableDeclaration<MesAuthInterceptor>;
215
- }
229
+ /**
230
+ * Functional HTTP interceptor for handling 401/403 auth errors.
231
+ * Redirects to login page on 401, and to 403 page on 403.
232
+ * Includes loopback prevention to avoid infinite redirects.
233
+ */
234
+ declare const mesAuthInterceptor: HttpInterceptorFn;
216
235
 
217
236
  declare class MesAuthModule {
218
237
  static ɵfac: i0.ɵɵFactoryDeclaration<MesAuthModule, never>;
@@ -357,5 +376,5 @@ declare class ToastContainerComponent implements OnInit, OnDestroy {
357
376
  static ɵcmp: i0.ɵɵComponentDeclaration<ToastContainerComponent, "ma-toast-container", never, {}, {}, never, never, true, never>;
358
377
  }
359
378
 
360
- export { MaUserComponent, MesAuthInterceptor, MesAuthModule, MesAuthService, NotificationBadgeComponent, NotificationPanelComponent, NotificationType, ThemeService, ToastContainerComponent, ToastService, UserProfileComponent };
379
+ export { MES_AUTH_CONFIG, MaUserComponent, MesAuthModule, MesAuthService, NotificationBadgeComponent, NotificationPanelComponent, NotificationType, ThemeService, ToastContainerComponent, ToastService, UserProfileComponent, mesAuthInterceptor, provideMesAuth };
361
380
  export type { CreateFrontEndRouteDto, FrontEndRoute, FrontEndRouteMaster, IUser, MesAuthConfig, NotificationDto, PagedList, RealTimeNotificationDto, Theme, Toast, UserFrontEndRoutesGrouped };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mesauth-angular",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "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",
5
5
  "main": "dist/fesm2022/mesauth-angular.mjs",
6
6
  "types": "dist/index.d.ts",