valtech-components 2.0.834 → 2.0.835
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/mfa-modal/mfa-modal.component.mjs +415 -0
- package/esm2022/lib/services/i18n/default-content.mjs +109 -1
- package/esm2022/lib/version.mjs +2 -2
- package/esm2022/public-api.mjs +2 -1
- package/fesm2022/valtech-components.mjs +512 -2
- package/fesm2022/valtech-components.mjs.map +1 -1
- package/lib/components/organisms/mfa-modal/mfa-modal.component.d.ts +114 -0
- package/lib/version.d.ts +1 -1
- package/package.json +1 -1
- package/public-api.d.ts +1 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { EventEmitter, OnDestroy } from '@angular/core';
|
|
2
|
+
import { FormControl } from '@angular/forms';
|
|
3
|
+
import { MFAMethod, TOTPSetupResponse } from '../../../services/auth/types';
|
|
4
|
+
import { QrResult } from '../../../services/qr-generator/types';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
/** Paso del flujo del modal. */
|
|
7
|
+
type MfaStep = 'loading' | 'status' | 'method-select' | 'totp-setup' | 'code-confirm' | 'disable';
|
|
8
|
+
/**
|
|
9
|
+
* `val-mfa-modal` — modal de gestión de autenticación de dos factores (MFA)
|
|
10
|
+
* para un usuario autenticado. Mismo patrón que `val-change-password-modal`.
|
|
11
|
+
*
|
|
12
|
+
* Flujo (máquina de estados interna):
|
|
13
|
+
* - `loading` → `getProfile()` para conocer el estado MFA.
|
|
14
|
+
* - `status` → muestra MFA habilitado/deshabilitado. Si está habilitado:
|
|
15
|
+
* gestión de backup codes (TOTP) + deshabilitar. Si no: botón habilitar.
|
|
16
|
+
* - `method-select` → elegir TOTP / EMAIL / SMS.
|
|
17
|
+
* - `totp-setup` → QR + secreto manual + backup codes → verificar código.
|
|
18
|
+
* - `code-confirm` → (EMAIL/SMS) ingresar código recibido, con reenvío.
|
|
19
|
+
* - `disable` → contraseña para deshabilitar MFA.
|
|
20
|
+
*
|
|
21
|
+
* El QR se genera **client-side** (`QrGeneratorService`) — el secreto TOTP
|
|
22
|
+
* nunca sale del navegador.
|
|
23
|
+
*
|
|
24
|
+
* Self-contained: inyecta `AuthService` y llama los endpoints directo. La app
|
|
25
|
+
* controla `[isOpen]` y reacciona a `(changed)` / `(dismissed)`.
|
|
26
|
+
*
|
|
27
|
+
* i18n: namespace compartido `_auth`.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```html
|
|
31
|
+
* <val-mfa-modal
|
|
32
|
+
* [isOpen]="isModalOpen()"
|
|
33
|
+
* (dismissed)="isModalOpen.set(false)"
|
|
34
|
+
* />
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare class MfaModalComponent implements OnDestroy {
|
|
38
|
+
private _isOpen;
|
|
39
|
+
/** Controla la visibilidad. Cada apertura re-resuelve el estado MFA. */
|
|
40
|
+
set isOpen(value: boolean);
|
|
41
|
+
get isOpen(): boolean;
|
|
42
|
+
/** Emite cuando el estado MFA cambia (habilitado / deshabilitado). */
|
|
43
|
+
changed: EventEmitter<void>;
|
|
44
|
+
/** Emite cuando el user cierra el modal (botón X o backdrop). */
|
|
45
|
+
dismissed: EventEmitter<void>;
|
|
46
|
+
private auth;
|
|
47
|
+
private toast;
|
|
48
|
+
private i18n;
|
|
49
|
+
private qrGen;
|
|
50
|
+
private readonly _step;
|
|
51
|
+
/** Paso actual del flujo. */
|
|
52
|
+
readonly step: import("@angular/core").Signal<MfaStep>;
|
|
53
|
+
/** `true` mientras una llamada al backend está en curso. */
|
|
54
|
+
readonly working: import("@angular/core").WritableSignal<boolean>;
|
|
55
|
+
readonly mfaEnabled: import("@angular/core").WritableSignal<boolean>;
|
|
56
|
+
readonly mfaMethod: import("@angular/core").WritableSignal<MFAMethod>;
|
|
57
|
+
readonly userPhone: import("@angular/core").WritableSignal<string>;
|
|
58
|
+
readonly backupCodesCount: import("@angular/core").WritableSignal<number>;
|
|
59
|
+
readonly selectedMethod: import("@angular/core").WritableSignal<MFAMethod>;
|
|
60
|
+
readonly totpSetup: import("@angular/core").WritableSignal<TOTPSetupResponse>;
|
|
61
|
+
readonly totpQr: import("@angular/core").WritableSignal<QrResult>;
|
|
62
|
+
/** Códigos de respaldo recién regenerados — se muestran una sola vez. */
|
|
63
|
+
readonly regeneratedCodes: import("@angular/core").WritableSignal<string[]>;
|
|
64
|
+
readonly resendCooldown: import("@angular/core").WritableSignal<number>;
|
|
65
|
+
readonly pinControl: FormControl<string>;
|
|
66
|
+
readonly passwordControl: FormControl<string>;
|
|
67
|
+
readonly phoneControl: FormControl<string>;
|
|
68
|
+
readonly pinInputProps: {
|
|
69
|
+
control: FormControl<string>;
|
|
70
|
+
token: string;
|
|
71
|
+
length: number;
|
|
72
|
+
allowNumbersOnly: boolean;
|
|
73
|
+
autoFocus: boolean;
|
|
74
|
+
};
|
|
75
|
+
private resendTimer;
|
|
76
|
+
constructor();
|
|
77
|
+
ngOnDestroy(): void;
|
|
78
|
+
/** Traduce una clave del namespace `_auth`. */
|
|
79
|
+
t(key: string): string;
|
|
80
|
+
/** Cierre iniciado por el user (X / backdrop). */
|
|
81
|
+
close(): void;
|
|
82
|
+
/** Consulta el perfil para conocer el estado MFA y posicionar el flujo. */
|
|
83
|
+
private resolveStatus;
|
|
84
|
+
private loadBackupCount;
|
|
85
|
+
goToMethodSelect(): void;
|
|
86
|
+
goToDisable(): void;
|
|
87
|
+
backToStatus(): void;
|
|
88
|
+
/** Continúa desde el selector de método al setup correspondiente. */
|
|
89
|
+
proceedWithMethod(): void;
|
|
90
|
+
private setupTotp;
|
|
91
|
+
/** Verifica el código TOTP de la app de autenticación y activa MFA. */
|
|
92
|
+
verifyTotp(): void;
|
|
93
|
+
/** Confirma el código EMAIL/SMS y activa MFA. */
|
|
94
|
+
confirmCode(): void;
|
|
95
|
+
/** Reenvía el código EMAIL/SMS (re-ejecuta el setup). */
|
|
96
|
+
resendCode(): void;
|
|
97
|
+
/** Regenera los códigos de respaldo TOTP y los muestra una vez. */
|
|
98
|
+
regenerateBackupCodes(): void;
|
|
99
|
+
/** Deshabilita MFA — requiere la contraseña de la cuenta. */
|
|
100
|
+
confirmDisable(): void;
|
|
101
|
+
/** Copia una lista de códigos de respaldo al portapapeles. */
|
|
102
|
+
copyCodes(codes: string[]): Promise<void>;
|
|
103
|
+
/** Etiqueta i18n legible para un método MFA. */
|
|
104
|
+
methodLabel(method: MFAMethod | null): string;
|
|
105
|
+
private resetFlow;
|
|
106
|
+
private startCooldown;
|
|
107
|
+
private stopCooldown;
|
|
108
|
+
/** Mapea los códigos de error MFA del backend a mensajes del namespace `_auth`. */
|
|
109
|
+
private resolveError;
|
|
110
|
+
private showToast;
|
|
111
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MfaModalComponent, never>;
|
|
112
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<MfaModalComponent, "val-mfa-modal", never, { "isOpen": { "alias": "isOpen"; "required": false; }; }, { "changed": "changed"; "dismissed": "dismissed"; }, never, never, true, never>;
|
|
113
|
+
}
|
|
114
|
+
export {};
|
package/lib/version.d.ts
CHANGED
package/package.json
CHANGED
package/public-api.d.ts
CHANGED
|
@@ -191,6 +191,7 @@ export * from './lib/components/organisms/form/form-footer/form-footer.component
|
|
|
191
191
|
export * from './lib/components/organisms/form/form.component';
|
|
192
192
|
export * from './lib/components/organisms/header/header.component';
|
|
193
193
|
export * from './lib/components/organisms/header/types';
|
|
194
|
+
export * from './lib/components/organisms/mfa-modal/mfa-modal.component';
|
|
194
195
|
export * from './lib/components/organisms/item-list/item-list.component';
|
|
195
196
|
export * from './lib/components/organisms/item-list/types';
|
|
196
197
|
export * from './lib/components/organisms/no-content/no-content.component';
|