/** * Valtech Auth Service * * Servicio de autenticación reutilizable para aplicaciones Angular. * Proporciona autenticación con AuthV2, MFA, sincronización entre pestañas, * refresh proactivo de tokens, y registro automático de dispositivos para * push notifications. * * @example * ```typescript * // En main.ts * import { bootstrapApplication } from '@angular/platform-browser'; * import { provideValtechAuth, provideValtechFirebase } from 'valtech-components'; * import { environment } from './environments/environment'; * * bootstrapApplication(AppComponent, { * providers: [ * provideValtechFirebase(environment.firebase), * provideValtechAuth({ * apiUrl: environment.apiUrl, * enableFirebaseIntegration: true, * enableDeviceRegistration: true, // Auto-registra dispositivos para push * }), * ], * }); * * // En app.routes.ts * import { authGuard, guestGuard, permissionGuard } from 'valtech-components'; * * const routes: Routes = [ * { path: 'login', canActivate: [guestGuard], loadComponent: () => import('./login.page') }, * { path: 'dashboard', canActivate: [authGuard], loadComponent: () => import('./dashboard.page') }, * { path: 'admin', canActivate: [authGuard, permissionGuard('admin:*')], loadComponent: () => import('./admin.page') }, * ]; * * // En componentes * import { AuthService } from 'valtech-components'; * * @Component({...}) * export class LoginComponent { * private auth = inject(AuthService); * * async login() { * await firstValueFrom(this.auth.signin({ email, password })); * if (this.auth.mfaPending().required) { * // Mostrar UI de MFA * } else { * this.router.navigate(['/dashboard']); * } * } * * // Habilitar notificaciones push (solicita permisos + registra dispositivo) * async enableNotifications() { * const result = await this.auth.enableNotifications(); * if (result.granted) { * console.log('Notificaciones habilitadas'); * } * } * * // Verificar estado de permisos * get canReceiveNotifications(): boolean { * return this.auth.getNotificationPermissionState() === 'granted'; * } * * // En template: usar signals directamente * // {{ auth.user()?.email }} * // @if (auth.hasPermission('templates:edit')) { ... } * } * ``` */ export * from './types'; export { VALTECH_AUTH_CONFIG, provideValtechAuth, provideValtechAuthInterceptor, DEFAULT_AUTH_CONFIG, } from './config'; export { AuthService } from './auth.service'; export { authGuard, guestGuard, permissionGuard, permissionGuardFromRoute, superAdminGuard, roleGuard, } from './guards'; export { authInterceptor } from './interceptor'; export { AuthStateService } from './auth-state.service'; export { TokenService } from './token.service'; export { AuthStorageService } from './storage.service'; export { AuthSyncService } from './sync.service'; export { DeviceService } from './device.service'; export { SessionService } from './session.service'; export { OAuthService } from './oauth.service'; export { OAuthCallbackComponent } from './oauth-callback.component'; export { HandoffService, HANDOFF_TOKEN_PARAM, HANDOFF_ROUTE_PARAM } from './handoff.service'; export type { HandoffCreateRequest, HandoffCreateResponse, HandoffExchangeResponse, DetectAndExchangeOptions, } from './handoff.service'; export { OrgSwitchService } from './org-switch.service'; export type { OrgChangedEvent, SwitchOrgOptions } from './org-switch.service'; export { NotificationActionService } from './notification-action.service'; export type { NotificationOpenResult } from './notification-action.service';