valtech-components 2.0.577 → 2.0.579

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.
@@ -43,7 +43,7 @@ export declare class RightsFooterComponent {
43
43
  /**
44
44
  * Computed helper for color prop in template.
45
45
  */
46
- propsColor: import("@angular/core").Signal<"medium" | "primary" | "secondary" | "tertiary" | "success" | "warning" | "danger" | "light" | "dark">;
46
+ propsColor: import("@angular/core").Signal<"success" | "medium" | "primary" | "secondary" | "tertiary" | "warning" | "danger" | "light" | "dark">;
47
47
  static ɵfac: i0.ɵɵFactoryDeclaration<RightsFooterComponent, never>;
48
48
  static ɵcmp: i0.ɵɵComponentDeclaration<RightsFooterComponent, "val-rights-footer", never, { "props": { "alias": "props"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
49
49
  }
@@ -90,9 +90,9 @@ export declare class ArticleComponent implements OnInit {
90
90
  contentInterpolation?: Record<string, string | number>;
91
91
  icon?: import("valtech-components").IconMetada;
92
92
  shape?: "round";
93
- size?: "small" | "large" | "default";
93
+ size?: "default" | "small" | "large";
94
94
  fill?: "default" | "clear" | "outline" | "solid";
95
- type: "reset" | "submit" | "button";
95
+ type: "button" | "submit" | "reset";
96
96
  token?: string;
97
97
  ref?: any;
98
98
  handler?: (value: any) => any;
@@ -154,6 +154,30 @@ export declare class AuthService implements OnDestroy {
154
154
  * que el cliente debe guardar para el próximo refresh.
155
155
  */
156
156
  refreshAccessToken(): Observable<RefreshResponse>;
157
+ /**
158
+ * Maneja autenticación exitosa desde fuentes externas (OAuth, Google Native, etc).
159
+ * Guarda tokens, actualiza estado, inicia Firebase si corresponde.
160
+ *
161
+ * @param authResult - Resultado de autenticación con tokens
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * // Desde GoogleAuthService
166
+ * googleAuth.signIn().subscribe({
167
+ * next: (result) => {
168
+ * this.authService.setExternalAuth(result);
169
+ * }
170
+ * });
171
+ * ```
172
+ */
173
+ setExternalAuth(authResult: {
174
+ accessToken: string;
175
+ refreshToken: string;
176
+ firebaseToken?: string;
177
+ expiresIn: number;
178
+ roles?: string[];
179
+ permissions?: string[];
180
+ }): void;
157
181
  /**
158
182
  * Cierra sesión.
159
183
  */
@@ -0,0 +1,102 @@
1
+ import { HttpClient } from '@angular/common/http';
2
+ import { Observable } from 'rxjs';
3
+ import { ValtechAuthConfig, GoogleAuthConfig, VerifyGoogleTokenResponse } from './types';
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * Servicio de autenticación con Google usando SDK nativo.
7
+ *
8
+ * Este servicio utiliza `@codetrix-studio/capacitor-google-auth` que funciona
9
+ * tanto en web como en aplicaciones Capacitor (iOS/Android).
10
+ *
11
+ * Para web, utiliza el popup nativo de Google Sign-In.
12
+ * Para mobile, utiliza el SDK nativo de Google.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * // En main.ts o app.config.ts
17
+ * import { provideGoogleAuth } from 'valtech-components';
18
+ *
19
+ * export const appConfig: ApplicationConfig = {
20
+ * providers: [
21
+ * provideGoogleAuth({
22
+ * clientId: 'your-google-client-id.apps.googleusercontent.com'
23
+ * })
24
+ * ]
25
+ * };
26
+ *
27
+ * // En el componente
28
+ * import { GoogleAuthService, AuthService } from 'valtech-components';
29
+ *
30
+ * @Component({...})
31
+ * export class LoginComponent {
32
+ * private googleAuth = inject(GoogleAuthService);
33
+ * private auth = inject(AuthService);
34
+ *
35
+ * async signInWithGoogle() {
36
+ * this.googleAuth.signIn().subscribe({
37
+ * next: (result) => {
38
+ * // Tokens recibidos del backend
39
+ * this.auth.handleOAuthSuccess(result);
40
+ * this.router.navigate(['/']);
41
+ * },
42
+ * error: (error) => {
43
+ * console.error('Google sign-in failed:', error);
44
+ * }
45
+ * });
46
+ * }
47
+ * }
48
+ * ```
49
+ */
50
+ export declare class GoogleAuthService {
51
+ private config;
52
+ private http;
53
+ private initialized;
54
+ private googleConfig;
55
+ /** Indica si el servicio está inicializado */
56
+ readonly isInitialized: import("@angular/core").Signal<boolean>;
57
+ constructor(config: ValtechAuthConfig, http: HttpClient);
58
+ /**
59
+ * Inicializa el SDK de Google Sign-In.
60
+ * Debe llamarse una vez, idealmente en APP_INITIALIZER.
61
+ *
62
+ * @param googleConfig - Configuración de Google Auth
63
+ */
64
+ initialize(googleConfig: GoogleAuthConfig): Promise<void>;
65
+ /**
66
+ * Inicia el flujo de Google Sign-In y obtiene tokens del backend.
67
+ *
68
+ * El flujo es:
69
+ * 1. Abre popup/SDK nativo de Google
70
+ * 2. Usuario autoriza
71
+ * 3. Obtiene ID token de Google
72
+ * 4. Envía ID token al backend para verificación
73
+ * 5. Backend verifica con Google y retorna nuestros JWT tokens
74
+ *
75
+ * @returns Observable con la respuesta del backend (tokens)
76
+ */
77
+ signIn(): Observable<VerifyGoogleTokenResponse>;
78
+ /**
79
+ * Cierra la sesión de Google.
80
+ * Nota: Esto solo cierra la sesión del SDK de Google,
81
+ * NO cierra la sesión del backend. Usa AuthService.logout() para eso.
82
+ */
83
+ signOut(): Promise<void>;
84
+ /**
85
+ * Obtiene el token de autenticación refrescado (si existe sesión).
86
+ * Nota: GoogleAuth.refresh() solo retorna tokens, no info del usuario.
87
+ */
88
+ refreshToken(): Promise<{
89
+ idToken: string;
90
+ accessToken: string;
91
+ } | null>;
92
+ /**
93
+ * Realiza el sign-in con Google usando el SDK nativo.
94
+ */
95
+ private performGoogleSignIn;
96
+ /**
97
+ * Verifica el ID token de Google con nuestro backend.
98
+ */
99
+ private verifyWithBackend;
100
+ static ɵfac: i0.ɵɵFactoryDeclaration<GoogleAuthService, never>;
101
+ static ɵprov: i0.ɵɵInjectableDeclaration<GoogleAuthService>;
102
+ }
@@ -81,3 +81,4 @@ export { DeviceService } from './device.service';
81
81
  export { SessionService } from './session.service';
82
82
  export { OAuthService } from './oauth.service';
83
83
  export { OAuthCallbackComponent } from './oauth-callback.component';
84
+ export { GoogleAuthService } from './google-auth.service';
@@ -752,3 +752,55 @@ export interface HasPasswordResponse {
752
752
  operationId: string;
753
753
  hasPassword: boolean;
754
754
  }
755
+ /**
756
+ * Configuración para Google Sign-In nativo.
757
+ */
758
+ export interface GoogleAuthConfig {
759
+ /** Google Client ID para web (obtenido de Google Cloud Console) */
760
+ clientId: string;
761
+ /** Scopes adicionales a solicitar (default: ['email', 'profile']) */
762
+ scopes?: string[];
763
+ }
764
+ /**
765
+ * Usuario de Google obtenido del SDK nativo.
766
+ */
767
+ export interface GoogleUser {
768
+ /** ID único de Google */
769
+ id: string;
770
+ /** Email del usuario */
771
+ email: string;
772
+ /** Nombre completo */
773
+ name: string;
774
+ /** URL de imagen de perfil */
775
+ imageUrl?: string;
776
+ /** ID token JWT (para enviar al backend) */
777
+ idToken: string;
778
+ /** Access token de Google (opcional) */
779
+ accessToken?: string;
780
+ }
781
+ /**
782
+ * Request para verificar Google ID token en el backend.
783
+ */
784
+ export interface VerifyGoogleTokenRequest {
785
+ /** ID token de Google obtenido del SDK nativo */
786
+ idToken: string;
787
+ /** ID del dispositivo (opcional, para tracking) */
788
+ deviceId?: string;
789
+ /** Info del dispositivo (opcional) */
790
+ deviceInfo?: string;
791
+ }
792
+ /**
793
+ * Response de verificación de Google ID token.
794
+ */
795
+ export interface VerifyGoogleTokenResponse {
796
+ operationId: string;
797
+ accessToken: string;
798
+ refreshToken: string;
799
+ firebaseToken?: string;
800
+ expiresIn: number;
801
+ tokenType: string;
802
+ isNewUser: boolean;
803
+ wasLinked: boolean;
804
+ roles?: string[];
805
+ permissions?: string[];
806
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valtech-components",
3
- "version": "2.0.577",
3
+ "version": "2.0.579",
4
4
  "private": false,
5
5
  "bin": {
6
6
  "valtech-firebase-config": "./src/lib/services/firebase/scripts/generate-sw-config.js"
@@ -15,6 +15,7 @@
15
15
  "@angular/core": "^18.0.0",
16
16
  "@angular/fire": "^18.0.1",
17
17
  "@capacitor/clipboard": "^6.0.1",
18
+ "@codetrix-studio/capacitor-google-auth": "^3.4.0-rc.4",
18
19
  "@ionic/angular": "^8.0.0",
19
20
  "firebase": "^10.0.0",
20
21
  "ionicons": "^7.2.1",
@@ -23,6 +24,11 @@
23
24
  "rxjs": "~7.8.0",
24
25
  "swiper": "^11.2.8"
25
26
  },
27
+ "peerDependenciesMeta": {
28
+ "@codetrix-studio/capacitor-google-auth": {
29
+ "optional": true
30
+ }
31
+ },
26
32
  "dependencies": {
27
33
  "@capacitor/browser": "^6.0.3",
28
34
  "ng-otp-input": "^1.9.3",