valtech-components 2.0.428 → 2.0.430
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/components/organisms/data-table/data-table.component.mjs +17 -3
- package/esm2022/lib/components/organisms/data-table/types.mjs +1 -1
- package/esm2022/lib/services/auth/auth-state.service.mjs +173 -0
- package/esm2022/lib/services/auth/auth.service.mjs +432 -0
- package/esm2022/lib/services/auth/config.mjs +76 -0
- package/esm2022/lib/services/auth/guards.mjs +194 -0
- package/esm2022/lib/services/auth/index.mjs +70 -0
- package/esm2022/lib/services/auth/interceptor.mjs +98 -0
- package/esm2022/lib/services/auth/storage.service.mjs +138 -0
- package/esm2022/lib/services/auth/sync.service.mjs +146 -0
- package/esm2022/lib/services/auth/token.service.mjs +113 -0
- package/esm2022/lib/services/auth/types.mjs +29 -0
- package/esm2022/public-api.mjs +4 -1
- package/fesm2022/valtech-components.mjs +1465 -8
- package/fesm2022/valtech-components.mjs.map +1 -1
- package/lib/components/organisms/data-table/types.d.ts +8 -0
- package/lib/services/auth/auth-state.service.d.ts +85 -0
- package/lib/services/auth/auth.service.d.ts +123 -0
- package/lib/services/auth/config.d.ts +38 -0
- package/lib/services/auth/guards.d.ts +123 -0
- package/lib/services/auth/index.d.ts +63 -0
- package/lib/services/auth/interceptor.d.ts +22 -0
- package/lib/services/auth/storage.service.d.ts +48 -0
- package/lib/services/auth/sync.service.d.ts +49 -0
- package/lib/services/auth/token.service.d.ts +51 -0
- package/lib/services/auth/types.d.ts +264 -0
- package/package.json +1 -9
- package/public-api.d.ts +1 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tipos e interfaces para el servicio de autenticación de Valtech.
|
|
3
|
+
* Alineados con el backend AuthV2.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Configuración para el servicio de autenticación.
|
|
7
|
+
*/
|
|
8
|
+
export interface ValtechAuthConfig {
|
|
9
|
+
/** URL base de la API (ej: 'https://api.myvaltech.com') */
|
|
10
|
+
apiUrl: string;
|
|
11
|
+
/** Prefijo para endpoints de auth (default: '/v2/auth') */
|
|
12
|
+
authPrefix?: string;
|
|
13
|
+
/** Prefijo para las claves de localStorage (default: 'valtech_auth_') */
|
|
14
|
+
storagePrefix?: string;
|
|
15
|
+
/** Tiempo antes de expiración para refrescar token en segundos (default: 60) */
|
|
16
|
+
refreshBeforeExpiry?: number;
|
|
17
|
+
/** Habilitar sincronización entre pestañas (default: true) */
|
|
18
|
+
enableTabSync?: boolean;
|
|
19
|
+
/** Ruta de redirección cuando no autenticado (default: '/login') */
|
|
20
|
+
loginRoute?: string;
|
|
21
|
+
/** Ruta de redirección cuando ya autenticado (default: '/') */
|
|
22
|
+
homeRoute?: string;
|
|
23
|
+
/** Ruta para acceso denegado (default: '/unauthorized') */
|
|
24
|
+
unauthorizedRoute?: string;
|
|
25
|
+
/** Habilitar integración con FirebaseService (default: false) */
|
|
26
|
+
enableFirebaseIntegration?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Estado completo de autenticación.
|
|
30
|
+
*/
|
|
31
|
+
export interface AuthState {
|
|
32
|
+
/** Usuario está autenticado */
|
|
33
|
+
isAuthenticated: boolean;
|
|
34
|
+
/** Estado de carga inicial */
|
|
35
|
+
isLoading: boolean;
|
|
36
|
+
/** Token de acceso actual */
|
|
37
|
+
accessToken: string | null;
|
|
38
|
+
/** Token de refresco actual */
|
|
39
|
+
refreshToken: string | null;
|
|
40
|
+
/** ID del usuario */
|
|
41
|
+
userId: string | null;
|
|
42
|
+
/** Email del usuario */
|
|
43
|
+
email: string | null;
|
|
44
|
+
/** Roles del usuario */
|
|
45
|
+
roles: string[];
|
|
46
|
+
/** Permisos del usuario (formato 'resource:action') */
|
|
47
|
+
permissions: string[];
|
|
48
|
+
/** Usuario es super admin */
|
|
49
|
+
isSuperAdmin: boolean;
|
|
50
|
+
/** Timestamp de expiración del accessToken (ms) */
|
|
51
|
+
expiresAt: number | null;
|
|
52
|
+
/** Error de autenticación (si existe) */
|
|
53
|
+
error: AuthError | null;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Información del usuario autenticado.
|
|
57
|
+
*/
|
|
58
|
+
export interface AuthUser {
|
|
59
|
+
userId: string;
|
|
60
|
+
email: string;
|
|
61
|
+
name?: string;
|
|
62
|
+
roles: string[];
|
|
63
|
+
permissions: string[];
|
|
64
|
+
isSuperAdmin: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Error de autenticación.
|
|
68
|
+
*/
|
|
69
|
+
export interface AuthError {
|
|
70
|
+
code: string;
|
|
71
|
+
message: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Estado inicial de autenticación.
|
|
75
|
+
*/
|
|
76
|
+
export declare const INITIAL_AUTH_STATE: AuthState;
|
|
77
|
+
/** Métodos de MFA soportados */
|
|
78
|
+
export type MFAMethod = 'EMAIL' | 'SMS';
|
|
79
|
+
/**
|
|
80
|
+
* Estado de MFA pendiente.
|
|
81
|
+
*/
|
|
82
|
+
export interface MFAPendingState {
|
|
83
|
+
required: boolean;
|
|
84
|
+
mfaToken: string | null;
|
|
85
|
+
method: MFAMethod | null;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Estado inicial de MFA.
|
|
89
|
+
*/
|
|
90
|
+
export declare const INITIAL_MFA_STATE: MFAPendingState;
|
|
91
|
+
/**
|
|
92
|
+
* Resultado de setup de MFA.
|
|
93
|
+
*/
|
|
94
|
+
export interface MFASetupResult {
|
|
95
|
+
codeSent: boolean;
|
|
96
|
+
message: string;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Estado de MFA del usuario.
|
|
100
|
+
*/
|
|
101
|
+
export interface MFAStatus {
|
|
102
|
+
enabled: boolean;
|
|
103
|
+
method: MFAMethod | null;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Request para signin.
|
|
107
|
+
*/
|
|
108
|
+
export interface SigninRequest {
|
|
109
|
+
email: string;
|
|
110
|
+
password: string;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Response de signin.
|
|
114
|
+
*/
|
|
115
|
+
export interface SigninResponse {
|
|
116
|
+
operationId: string;
|
|
117
|
+
accessToken?: string;
|
|
118
|
+
refreshToken?: string;
|
|
119
|
+
firebaseToken?: string;
|
|
120
|
+
expiresIn?: number;
|
|
121
|
+
tokenType?: string;
|
|
122
|
+
mfaRequired?: boolean;
|
|
123
|
+
mfaToken?: string;
|
|
124
|
+
mfaMethod?: MFAMethod;
|
|
125
|
+
roles?: string[];
|
|
126
|
+
permissions?: string[];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Request para verificar MFA.
|
|
130
|
+
*/
|
|
131
|
+
export interface MFAVerifyRequest {
|
|
132
|
+
mfaToken: string;
|
|
133
|
+
code: string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Response de verificar MFA.
|
|
137
|
+
*/
|
|
138
|
+
export interface MFAVerifyResponse {
|
|
139
|
+
operationId: string;
|
|
140
|
+
accessToken: string;
|
|
141
|
+
refreshToken: string;
|
|
142
|
+
firebaseToken?: string;
|
|
143
|
+
expiresIn: number;
|
|
144
|
+
tokenType: string;
|
|
145
|
+
roles?: string[];
|
|
146
|
+
permissions?: string[];
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Request para refrescar token.
|
|
150
|
+
*/
|
|
151
|
+
export interface RefreshRequest {
|
|
152
|
+
refreshToken: string;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Response de refrescar token.
|
|
156
|
+
*/
|
|
157
|
+
export interface RefreshResponse {
|
|
158
|
+
operationId: string;
|
|
159
|
+
accessToken: string;
|
|
160
|
+
expiresIn: number;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Request para logout.
|
|
164
|
+
*/
|
|
165
|
+
export interface LogoutRequest {
|
|
166
|
+
refreshToken: string;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Response de logout.
|
|
170
|
+
*/
|
|
171
|
+
export interface LogoutResponse {
|
|
172
|
+
operationId: string;
|
|
173
|
+
success: boolean;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Response de obtener permisos.
|
|
177
|
+
*/
|
|
178
|
+
export interface GetPermissionsResponse {
|
|
179
|
+
operationId: string;
|
|
180
|
+
roles: string[];
|
|
181
|
+
permissions: string[];
|
|
182
|
+
isSuperAdmin: boolean;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Request para setup de MFA.
|
|
186
|
+
*/
|
|
187
|
+
export interface MFASetupRequest {
|
|
188
|
+
method: MFAMethod;
|
|
189
|
+
phone?: string;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Response de setup de MFA.
|
|
193
|
+
*/
|
|
194
|
+
export interface MFASetupResponse {
|
|
195
|
+
operationId: string;
|
|
196
|
+
codeSent: boolean;
|
|
197
|
+
message: string;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Request para confirmar MFA.
|
|
201
|
+
*/
|
|
202
|
+
export interface MFAConfirmRequest {
|
|
203
|
+
code: string;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Response de confirmar MFA.
|
|
207
|
+
*/
|
|
208
|
+
export interface MFAConfirmResponse {
|
|
209
|
+
operationId: string;
|
|
210
|
+
mfaEnabled: boolean;
|
|
211
|
+
method: MFAMethod;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Request para deshabilitar MFA.
|
|
215
|
+
*/
|
|
216
|
+
export interface MFADisableRequest {
|
|
217
|
+
password: string;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Response de deshabilitar MFA.
|
|
221
|
+
*/
|
|
222
|
+
export interface MFADisableResponse {
|
|
223
|
+
operationId: string;
|
|
224
|
+
mfaDisabled: boolean;
|
|
225
|
+
}
|
|
226
|
+
/** Tipos de eventos de sincronización entre pestañas */
|
|
227
|
+
export type AuthSyncEventType = 'LOGIN' | 'LOGOUT' | 'TOKEN_REFRESH' | 'PERMISSIONS_UPDATE';
|
|
228
|
+
/**
|
|
229
|
+
* Evento de sincronización entre pestañas.
|
|
230
|
+
*/
|
|
231
|
+
export interface AuthSyncEvent {
|
|
232
|
+
type: AuthSyncEventType;
|
|
233
|
+
timestamp: number;
|
|
234
|
+
payload?: {
|
|
235
|
+
accessToken?: string;
|
|
236
|
+
expiresAt?: number;
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Claims del JWT de acceso.
|
|
241
|
+
*/
|
|
242
|
+
export interface JWTClaims {
|
|
243
|
+
/** User ID */
|
|
244
|
+
uid: string;
|
|
245
|
+
/** Email */
|
|
246
|
+
email: string;
|
|
247
|
+
/** Session ID */
|
|
248
|
+
sid?: string;
|
|
249
|
+
/** Issued at */
|
|
250
|
+
iat: number;
|
|
251
|
+
/** Expiration */
|
|
252
|
+
exp: number;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Datos persistidos en storage.
|
|
256
|
+
*/
|
|
257
|
+
export interface StoredAuthState {
|
|
258
|
+
accessToken: string;
|
|
259
|
+
refreshToken: string;
|
|
260
|
+
roles: string[];
|
|
261
|
+
permissions: string[];
|
|
262
|
+
isSuperAdmin: boolean;
|
|
263
|
+
expiresAt?: number;
|
|
264
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "valtech-components",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.430",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,14 +20,6 @@
|
|
|
20
20
|
"rxjs": "~7.8.0",
|
|
21
21
|
"swiper": "^11.2.8"
|
|
22
22
|
},
|
|
23
|
-
"peerDependenciesMeta": {
|
|
24
|
-
"@angular/fire": {
|
|
25
|
-
"optional": true
|
|
26
|
-
},
|
|
27
|
-
"firebase": {
|
|
28
|
-
"optional": true
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
23
|
"dependencies": {
|
|
32
24
|
"@capacitor/browser": "^6.0.3",
|
|
33
25
|
"ng-otp-input": "^1.9.3",
|
package/public-api.d.ts
CHANGED
|
@@ -211,6 +211,7 @@ export * from './lib/services/qr-generator/types';
|
|
|
211
211
|
export * from './lib/services/modal/modal.service';
|
|
212
212
|
export * from './lib/services/modal/types';
|
|
213
213
|
export * from './lib/services/firebase';
|
|
214
|
+
export * from './lib/services/auth';
|
|
214
215
|
export * from './lib/components/types';
|
|
215
216
|
export * from './lib/shared/pipes/process-links.pipe';
|
|
216
217
|
export * from './lib/shared/utils/dom';
|