valtech-components 2.0.459 → 2.0.460
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/esm2022/lib/services/auth/auth.service.mjs +21 -1
- package/esm2022/lib/services/auth/types.mjs +1 -1
- package/esm2022/lib/services/firebase/firebase.service.mjs +160 -1
- package/esm2022/lib/services/firebase/types.mjs +1 -1
- package/fesm2022/valtech-components.mjs +179 -0
- package/fesm2022/valtech-components.mjs.map +1 -1
- package/lib/components/organisms/article/article.component.d.ts +1 -1
- package/lib/services/auth/auth.service.d.ts +10 -1
- package/lib/services/auth/types.d.ts +33 -0
- package/lib/services/firebase/firebase.service.d.ts +108 -1
- package/lib/services/firebase/types.d.ts +44 -0
- package/package.json +1 -1
|
@@ -90,7 +90,7 @@ 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?: "
|
|
93
|
+
size?: "small" | "large" | "default";
|
|
94
94
|
fill?: "default" | "clear" | "outline" | "solid";
|
|
95
95
|
type: "button" | "submit" | "reset";
|
|
96
96
|
token?: string;
|
|
@@ -6,7 +6,7 @@ import { AuthStateService } from './auth-state.service';
|
|
|
6
6
|
import { TokenService } from './token.service';
|
|
7
7
|
import { AuthStorageService } from './storage.service';
|
|
8
8
|
import { AuthSyncService } from './sync.service';
|
|
9
|
-
import { SigninRequest, SigninResponse, SignupRequest, SignupResponse, VerifyEmailRequest, VerifyEmailResponse, ResendCodeRequest, ResendCodeResponse, MFAVerifyResponse, RefreshResponse, GetPermissionsResponse, MFASetupResponse, MFAConfirmResponse, MFADisableResponse, ForgotPasswordRequest, ForgotPasswordResponse, ResetPasswordRequest, ResetPasswordResponse, MFAMethod, AuthError, ValtechAuthConfig } from './types';
|
|
9
|
+
import { SigninRequest, SigninResponse, SignupRequest, SignupResponse, VerifyEmailRequest, VerifyEmailResponse, ResendCodeRequest, ResendCodeResponse, MFAVerifyResponse, RefreshResponse, GetPermissionsResponse, GetProfileResponse, UpdateProfileRequest, UpdateProfileResponse, MFASetupResponse, MFAConfirmResponse, MFADisableResponse, ForgotPasswordRequest, ForgotPasswordResponse, ResetPasswordRequest, ResetPasswordResponse, MFAMethod, AuthError, ValtechAuthConfig } from './types';
|
|
10
10
|
import { FirebaseService } from '../firebase';
|
|
11
11
|
import * as i0 from "@angular/core";
|
|
12
12
|
/**
|
|
@@ -111,6 +111,15 @@ export declare class AuthService implements OnDestroy {
|
|
|
111
111
|
* Deshabilita MFA.
|
|
112
112
|
*/
|
|
113
113
|
disableMFA(password: string): Observable<MFADisableResponse>;
|
|
114
|
+
/**
|
|
115
|
+
* Obtiene el perfil del usuario autenticado.
|
|
116
|
+
* Incluye información de MFA y teléfono.
|
|
117
|
+
*/
|
|
118
|
+
getProfile(): Observable<GetProfileResponse>;
|
|
119
|
+
/**
|
|
120
|
+
* Actualiza el perfil del usuario.
|
|
121
|
+
*/
|
|
122
|
+
updateProfile(request: UpdateProfileRequest): Observable<UpdateProfileResponse>;
|
|
114
123
|
/**
|
|
115
124
|
* Inicia el proceso de recuperación de contraseña.
|
|
116
125
|
* Envía un código al email del usuario.
|
|
@@ -59,9 +59,12 @@ export interface AuthUser {
|
|
|
59
59
|
userId: string;
|
|
60
60
|
email: string;
|
|
61
61
|
name?: string;
|
|
62
|
+
phone?: string;
|
|
62
63
|
roles: string[];
|
|
63
64
|
permissions: string[];
|
|
64
65
|
isSuperAdmin: boolean;
|
|
66
|
+
mfaEnabled?: boolean;
|
|
67
|
+
mfaMethod?: MFAMethod;
|
|
65
68
|
}
|
|
66
69
|
/**
|
|
67
70
|
* Error de autenticación.
|
|
@@ -302,6 +305,36 @@ export interface ResetPasswordResponse {
|
|
|
302
305
|
operationId: string;
|
|
303
306
|
success: boolean;
|
|
304
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* Response de obtener perfil del usuario.
|
|
310
|
+
*/
|
|
311
|
+
export interface GetProfileResponse {
|
|
312
|
+
operationId: string;
|
|
313
|
+
userId: string;
|
|
314
|
+
email: string;
|
|
315
|
+
name: string;
|
|
316
|
+
phone?: string;
|
|
317
|
+
emailVerified: boolean;
|
|
318
|
+
phoneVerified: boolean;
|
|
319
|
+
mfaEnabled: boolean;
|
|
320
|
+
mfaMethod?: MFAMethod;
|
|
321
|
+
createdAt: string;
|
|
322
|
+
updatedAt: string;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Request para actualizar perfil.
|
|
326
|
+
*/
|
|
327
|
+
export interface UpdateProfileRequest {
|
|
328
|
+
name?: string;
|
|
329
|
+
phone?: string;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Response de actualizar perfil.
|
|
333
|
+
*/
|
|
334
|
+
export interface UpdateProfileResponse {
|
|
335
|
+
operationId: string;
|
|
336
|
+
updated: boolean;
|
|
337
|
+
}
|
|
305
338
|
/** Tipos de eventos de sincronización entre pestañas */
|
|
306
339
|
export type AuthSyncEventType = 'LOGIN' | 'LOGOUT' | 'TOKEN_REFRESH' | 'PERMISSIONS_UPDATE';
|
|
307
340
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Auth, UserCredential } from '@angular/fire/auth';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
-
import { FirebaseUser, SessionState, ValtechFirebaseConfig } from './types';
|
|
3
|
+
import { FirebaseUser, MembershipInfo, OrganizationInfo, SessionState, ValtechFirebaseConfig } from './types';
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
5
|
/**
|
|
6
6
|
* Servicio de autenticación de Firebase.
|
|
@@ -112,6 +112,113 @@ export declare class FirebaseService {
|
|
|
112
112
|
* @returns true si el usuario tiene el rol
|
|
113
113
|
*/
|
|
114
114
|
hasRole(role: string): Promise<boolean>;
|
|
115
|
+
/**
|
|
116
|
+
* Obtiene las memberships (organizaciones) del usuario.
|
|
117
|
+
* Cada membership contiene el rol y permisos en esa organización.
|
|
118
|
+
*
|
|
119
|
+
* @returns Mapa de orgId → MembershipInfo
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* const memberships = await firebaseService.getMemberships();
|
|
124
|
+
* // { 'org_abc': { roleId: 'admin', roleName: 'admin', permissions: ['users:*', ...] } }
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
getMemberships(): Promise<Record<string, MembershipInfo>>;
|
|
128
|
+
/**
|
|
129
|
+
* Obtiene la organización activa del usuario.
|
|
130
|
+
* La organización activa se establece al hacer login o al cambiar de org.
|
|
131
|
+
*
|
|
132
|
+
* @returns ID de la organización activa o null si no hay ninguna
|
|
133
|
+
*/
|
|
134
|
+
getActiveOrg(): Promise<string | null>;
|
|
135
|
+
/**
|
|
136
|
+
* Obtiene información de todas las organizaciones del usuario.
|
|
137
|
+
*
|
|
138
|
+
* @returns Array con información de cada organización
|
|
139
|
+
*/
|
|
140
|
+
getOrganizations(): Promise<OrganizationInfo[]>;
|
|
141
|
+
/**
|
|
142
|
+
* Obtiene los IDs de todas las organizaciones del usuario.
|
|
143
|
+
*
|
|
144
|
+
* @returns Array de IDs de organizaciones
|
|
145
|
+
*/
|
|
146
|
+
getOrganizationIds(): Promise<string[]>;
|
|
147
|
+
/**
|
|
148
|
+
* Verifica si el usuario pertenece a una organización.
|
|
149
|
+
*
|
|
150
|
+
* @param orgId - ID de la organización
|
|
151
|
+
* @returns true si el usuario es miembro
|
|
152
|
+
*/
|
|
153
|
+
isMemberOf(orgId: string): Promise<boolean>;
|
|
154
|
+
/**
|
|
155
|
+
* Obtiene el rol del usuario en una organización.
|
|
156
|
+
*
|
|
157
|
+
* @param orgId - ID de la organización
|
|
158
|
+
* @returns ID del rol o null si no es miembro
|
|
159
|
+
*/
|
|
160
|
+
getRoleInOrg(orgId: string): Promise<string | null>;
|
|
161
|
+
/**
|
|
162
|
+
* Obtiene los permisos del usuario en una organización.
|
|
163
|
+
*
|
|
164
|
+
* @param orgId - ID de la organización
|
|
165
|
+
* @returns Array de permisos en formato 'resource:action'
|
|
166
|
+
*/
|
|
167
|
+
getPermissionsInOrg(orgId: string): Promise<string[]>;
|
|
168
|
+
/**
|
|
169
|
+
* Verifica si el usuario tiene un permiso específico en una organización.
|
|
170
|
+
* Soporta wildcards: 'resource:*' y '*:*' (super admin).
|
|
171
|
+
*
|
|
172
|
+
* @param orgId - ID de la organización
|
|
173
|
+
* @param resource - Recurso a verificar (ej: 'users', 'documents')
|
|
174
|
+
* @param action - Acción a verificar (ej: 'read', 'write', 'create', 'delete')
|
|
175
|
+
* @returns true si tiene el permiso
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```typescript
|
|
179
|
+
* // Verificar permiso específico
|
|
180
|
+
* const canReadUsers = await firebaseService.hasPermission('org_abc', 'users', 'read');
|
|
181
|
+
*
|
|
182
|
+
* // Verificar en la organización activa
|
|
183
|
+
* const orgId = await firebaseService.getActiveOrg();
|
|
184
|
+
* const canEdit = await firebaseService.hasPermission(orgId!, 'documents', 'write');
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
hasPermission(orgId: string, resource: string, action: string): Promise<boolean>;
|
|
188
|
+
/**
|
|
189
|
+
* Verifica si el usuario puede leer un recurso en una organización.
|
|
190
|
+
* Atajo para hasPermission(orgId, resource, 'read').
|
|
191
|
+
*/
|
|
192
|
+
canRead(orgId: string, resource: string): Promise<boolean>;
|
|
193
|
+
/**
|
|
194
|
+
* Verifica si el usuario puede escribir un recurso en una organización.
|
|
195
|
+
* Atajo para hasPermission(orgId, resource, 'write').
|
|
196
|
+
*/
|
|
197
|
+
canWrite(orgId: string, resource: string): Promise<boolean>;
|
|
198
|
+
/**
|
|
199
|
+
* Verifica si el usuario puede crear un recurso en una organización.
|
|
200
|
+
* Atajo para hasPermission(orgId, resource, 'create').
|
|
201
|
+
*/
|
|
202
|
+
canCreate(orgId: string, resource: string): Promise<boolean>;
|
|
203
|
+
/**
|
|
204
|
+
* Verifica si el usuario puede eliminar un recurso en una organización.
|
|
205
|
+
* Atajo para hasPermission(orgId, resource, 'delete').
|
|
206
|
+
*/
|
|
207
|
+
canDelete(orgId: string, resource: string): Promise<boolean>;
|
|
208
|
+
/**
|
|
209
|
+
* Verifica si el usuario puede administrar un recurso en una organización.
|
|
210
|
+
* Equivale a tener 'resource:*' o '*:*'.
|
|
211
|
+
*/
|
|
212
|
+
canManage(orgId: string, resource: string): Promise<boolean>;
|
|
213
|
+
/**
|
|
214
|
+
* Verifica si el usuario es super admin en una organización.
|
|
215
|
+
* Super admin tiene el permiso '*:*'.
|
|
216
|
+
*/
|
|
217
|
+
isSuperAdmin(orgId: string): Promise<boolean>;
|
|
218
|
+
/**
|
|
219
|
+
* Verifica si el usuario es admin en una organización.
|
|
220
|
+
*/
|
|
221
|
+
isAdminInOrg(orgId: string): Promise<boolean>;
|
|
115
222
|
/**
|
|
116
223
|
* Espera a que el estado de autenticación esté determinado.
|
|
117
224
|
* Útil en guards o al inicializar la app.
|
|
@@ -202,6 +202,50 @@ export interface StorageListResult {
|
|
|
202
202
|
/** Token para la siguiente página (si hay más) */
|
|
203
203
|
nextPageToken?: string;
|
|
204
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Información de membership en una organización.
|
|
207
|
+
* Representa el rol y permisos que tiene un usuario en una org específica.
|
|
208
|
+
*/
|
|
209
|
+
export interface MembershipInfo {
|
|
210
|
+
/** ID del rol (ej: 'admin', 'editor', 'viewer') */
|
|
211
|
+
roleId: string;
|
|
212
|
+
/** Nombre del rol para display */
|
|
213
|
+
roleName: string;
|
|
214
|
+
/** Lista de permisos en formato 'resource:action' */
|
|
215
|
+
permissions: string[];
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Estructura completa de claims con RBAC.
|
|
219
|
+
* Estos claims están disponibles en request.auth.token en Firestore Rules.
|
|
220
|
+
*/
|
|
221
|
+
export interface RBACClaims {
|
|
222
|
+
/** Email del usuario */
|
|
223
|
+
email: string;
|
|
224
|
+
/** Nombre completo del usuario */
|
|
225
|
+
name: string;
|
|
226
|
+
/** Si el email está verificado */
|
|
227
|
+
verified: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Mapa de organizaciones donde el usuario tiene roles.
|
|
230
|
+
* Key = orgId, Value = información del rol y permisos en esa org.
|
|
231
|
+
*/
|
|
232
|
+
memberships: Record<string, MembershipInfo>;
|
|
233
|
+
/** ID de la organización actualmente seleccionada */
|
|
234
|
+
activeOrg: string;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Información de una organización para display
|
|
238
|
+
*/
|
|
239
|
+
export interface OrganizationInfo {
|
|
240
|
+
/** ID único de la organización */
|
|
241
|
+
id: string;
|
|
242
|
+
/** Rol del usuario en esta organización */
|
|
243
|
+
roleId: string;
|
|
244
|
+
/** Nombre del rol para display */
|
|
245
|
+
roleName: string;
|
|
246
|
+
/** Permisos del usuario en esta organización */
|
|
247
|
+
permissions: string[];
|
|
248
|
+
}
|
|
205
249
|
/**
|
|
206
250
|
* Información del usuario de Firebase (simplificada)
|
|
207
251
|
*/
|