@molecule/app-settings-panel-angular 0.0.0-stage → 0.0.1-stage

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.
Files changed (63) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +1992 -2
  3. package/dist/account-section.component.d.ts +123 -0
  4. package/dist/account-section.component.d.ts.map +1 -0
  5. package/dist/account-section.component.js +350 -0
  6. package/dist/account-section.component.js.map +1 -0
  7. package/dist/appearance-section.component.d.ts +52 -0
  8. package/dist/appearance-section.component.d.ts.map +1 -0
  9. package/dist/appearance-section.component.js +128 -0
  10. package/dist/appearance-section.component.js.map +1 -0
  11. package/dist/auth-section.component.d.ts +125 -0
  12. package/dist/auth-section.component.d.ts.map +1 -0
  13. package/dist/auth-section.component.js +667 -0
  14. package/dist/auth-section.component.js.map +1 -0
  15. package/dist/billing-section.component.d.ts +52 -0
  16. package/dist/billing-section.component.d.ts.map +1 -0
  17. package/dist/billing-section.component.js +137 -0
  18. package/dist/billing-section.component.js.map +1 -0
  19. package/dist/context.d.ts +46 -0
  20. package/dist/context.d.ts.map +1 -0
  21. package/dist/context.js +73 -0
  22. package/dist/context.js.map +1 -0
  23. package/dist/controlled-switch.d.ts +38 -0
  24. package/dist/controlled-switch.d.ts.map +1 -0
  25. package/dist/controlled-switch.js +56 -0
  26. package/dist/controlled-switch.js.map +1 -0
  27. package/dist/devices-section.component.d.ts +88 -0
  28. package/dist/devices-section.component.d.ts.map +1 -0
  29. package/dist/devices-section.component.js +374 -0
  30. package/dist/devices-section.component.js.map +1 -0
  31. package/dist/index.d.ts +107 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +107 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/log-out-delete-section.component.d.ts +50 -0
  36. package/dist/log-out-delete-section.component.d.ts.map +1 -0
  37. package/dist/log-out-delete-section.component.js +249 -0
  38. package/dist/log-out-delete-section.component.js.map +1 -0
  39. package/dist/notifications-section.component.d.ts +78 -0
  40. package/dist/notifications-section.component.d.ts.map +1 -0
  41. package/dist/notifications-section.component.js +256 -0
  42. package/dist/notifications-section.component.js.map +1 -0
  43. package/dist/push-toggle.d.ts +12 -0
  44. package/dist/push-toggle.d.ts.map +1 -0
  45. package/dist/push-toggle.js +11 -0
  46. package/dist/push-toggle.js.map +1 -0
  47. package/dist/settings-container.component.d.ts +33 -0
  48. package/dist/settings-container.component.d.ts.map +1 -0
  49. package/dist/settings-container.component.js +64 -0
  50. package/dist/settings-container.component.js.map +1 -0
  51. package/dist/this-device-section.component.d.ts +40 -0
  52. package/dist/this-device-section.component.d.ts.map +1 -0
  53. package/dist/this-device-section.component.js +149 -0
  54. package/dist/this-device-section.component.js.map +1 -0
  55. package/dist/tiers-upgrade-section.component.d.ts +89 -0
  56. package/dist/tiers-upgrade-section.component.d.ts.map +1 -0
  57. package/dist/tiers-upgrade-section.component.js +407 -0
  58. package/dist/tiers-upgrade-section.component.js.map +1 -0
  59. package/dist/types.d.ts +46 -0
  60. package/dist/types.d.ts.map +1 -0
  61. package/dist/types.js +8 -0
  62. package/dist/types.js.map +1 -0
  63. package/package.json +78 -4
@@ -0,0 +1,667 @@
1
+ /**
2
+ * AuthSection component (React parity).
3
+ *
4
+ * @module
5
+ */
6
+ import { Component, computed, DestroyRef, inject, signal } from '@angular/core';
7
+ import { useAuth, useChangePassword, useHttpClient, useTranslation } from '@molecule/app-angular';
8
+ import { serverErrorMessage } from '@molecule/app-http';
9
+ import { getClassMap } from '@molecule/app-ui';
10
+ import { Alert, Button, Flex, Input, Modal } from '@molecule/app-ui-angular';
11
+ import * as i0 from "@angular/core";
12
+ const _c0 = () => ({ defaultValue: "Authentication" });
13
+ const _c1 = () => ({ defaultValue: "Change password" });
14
+ const _c2 = () => ({ defaultValue: "Two-factor authentication" });
15
+ const _c3 = () => ({ defaultValue: "Change Password" });
16
+ const _c4 = () => ({ defaultValue: "Current Password" });
17
+ const _c5 = () => ({ defaultValue: "New Password" });
18
+ const _c6 = () => ({ defaultValue: "On" });
19
+ const _c7 = () => ({ defaultValue: "Disable" });
20
+ const _c8 = () => ({ defaultValue: "Enable" });
21
+ const _c9 = () => ({ defaultValue: "Changing..." });
22
+ const _c10 = () => ({ defaultValue: "Scan this QR code with your authenticator app, then enter the 6-digit code." });
23
+ const _c11 = () => ({ defaultValue: "Two-factor QR code" });
24
+ const _c12 = () => ({ defaultValue: "Authentication code" });
25
+ const _c13 = () => ({ defaultValue: "Verify & enable" });
26
+ function AuthSection_Conditional_0_Conditional_9_Template(rf, ctx) { if (rf & 1) {
27
+ i0.ɵɵelementStart(0, "span");
28
+ i0.ɵɵtext(1);
29
+ i0.ɵɵelementEnd();
30
+ } if (rf & 2) {
31
+ const ctx_r1 = i0.ɵɵnextContext(2);
32
+ i0.ɵɵclassMap(ctx_r1.cm.cn(ctx_r1.cm.textSize("xs"), ctx_r1.cm.textSubtle, ctx_r1.cm.sp("ml", 2)));
33
+ i0.ɵɵadvance();
34
+ i0.ɵɵtextInterpolate(ctx_r1.t("settings.twoFactorOn", undefined, i0.ɵɵpureFunction0(3, _c6)));
35
+ } }
36
+ function AuthSection_Conditional_0_Conditional_10_Template(rf, ctx) { if (rf & 1) {
37
+ const _r3 = i0.ɵɵgetCurrentView();
38
+ i0.ɵɵelementStart(0, "button", 13);
39
+ i0.ɵɵlistener("click", function AuthSection_Conditional_0_Conditional_10_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r3); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.openDisableTf()); });
40
+ i0.ɵɵtext(1);
41
+ i0.ɵɵelementEnd();
42
+ } if (rf & 2) {
43
+ const ctx_r1 = i0.ɵɵnextContext(2);
44
+ i0.ɵɵproperty("variant", "outline")("size", "sm");
45
+ i0.ɵɵadvance();
46
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.t("settings.twoFactorDisable", undefined, i0.ɵɵpureFunction0(3, _c7)), " ");
47
+ } }
48
+ function AuthSection_Conditional_0_Conditional_11_Template(rf, ctx) { if (rf & 1) {
49
+ const _r4 = i0.ɵɵgetCurrentView();
50
+ i0.ɵɵelementStart(0, "button", 14);
51
+ i0.ɵɵlistener("click", function AuthSection_Conditional_0_Conditional_11_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r4); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.startEnable()); });
52
+ i0.ɵɵtext(1);
53
+ i0.ɵɵelementEnd();
54
+ } if (rf & 2) {
55
+ const ctx_r1 = i0.ɵɵnextContext(2);
56
+ i0.ɵɵproperty("variant", "outline")("size", "sm");
57
+ i0.ɵɵadvance();
58
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.t("settings.twoFactorEnable", undefined, i0.ɵɵpureFunction0(3, _c8)), " ");
59
+ } }
60
+ function AuthSection_Conditional_0_Conditional_13_Template(rf, ctx) { if (rf & 1) {
61
+ i0.ɵɵelementStart(0, "div", 6);
62
+ i0.ɵɵtext(1);
63
+ i0.ɵɵelementEnd();
64
+ } if (rf & 2) {
65
+ const ctx_r1 = i0.ɵɵnextContext(2);
66
+ i0.ɵɵproperty("status", "error")("className", ctx_r1.cm.sp("mb", 4));
67
+ i0.ɵɵadvance();
68
+ i0.ɵɵtextInterpolate(ctx);
69
+ } }
70
+ function AuthSection_Conditional_0_Conditional_24_Template(rf, ctx) { if (rf & 1) {
71
+ i0.ɵɵtext(0);
72
+ } if (rf & 2) {
73
+ const ctx_r1 = i0.ɵɵnextContext(2);
74
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.t("settings.changePasswordModal.changing", undefined, i0.ɵɵpureFunction0(1, _c9)), " ");
75
+ } }
76
+ function AuthSection_Conditional_0_Conditional_25_Template(rf, ctx) { if (rf & 1) {
77
+ i0.ɵɵtext(0);
78
+ } if (rf & 2) {
79
+ const ctx_r1 = i0.ɵɵnextContext(2);
80
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.t("settings.changePassword", undefined, i0.ɵɵpureFunction0(1, _c1)), " ");
81
+ } }
82
+ function AuthSection_Conditional_0_Conditional_27_Template(rf, ctx) { if (rf & 1) {
83
+ i0.ɵɵelementStart(0, "div", 6);
84
+ i0.ɵɵtext(1);
85
+ i0.ɵɵelementEnd();
86
+ } if (rf & 2) {
87
+ const ctx_r1 = i0.ɵɵnextContext(2);
88
+ i0.ɵɵproperty("status", "error")("className", ctx_r1.cm.sp("mb", 4));
89
+ i0.ɵɵadvance();
90
+ i0.ɵɵtextInterpolate(ctx);
91
+ } }
92
+ function AuthSection_Conditional_0_Conditional_28_Conditional_4_Template(rf, ctx) { if (rf & 1) {
93
+ i0.ɵɵelementStart(0, "p");
94
+ i0.ɵɵtext(1);
95
+ i0.ɵɵelementEnd();
96
+ } if (rf & 2) {
97
+ const ctx_r1 = i0.ɵɵnextContext(3);
98
+ i0.ɵɵclassMap(ctx_r1.cm.cn(ctx_r1.cm.textSize("xs"), ctx_r1.cm.textSubtle, ctx_r1.cm.settingsPanelTwoFactorSecret));
99
+ i0.ɵɵadvance();
100
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.tfSetup()?.secret, " ");
101
+ } }
102
+ function AuthSection_Conditional_0_Conditional_28_Template(rf, ctx) { if (rf & 1) {
103
+ i0.ɵɵelementStart(0, "div")(1, "p");
104
+ i0.ɵɵtext(2);
105
+ i0.ɵɵelementEnd();
106
+ i0.ɵɵelement(3, "img");
107
+ i0.ɵɵconditionalCreate(4, AuthSection_Conditional_0_Conditional_28_Conditional_4_Template, 2, 3, "p", 2);
108
+ i0.ɵɵelementEnd();
109
+ } if (rf & 2) {
110
+ const ctx_r1 = i0.ɵɵnextContext(2);
111
+ i0.ɵɵclassMap(ctx_r1.cm.cn(ctx_r1.cm.stack(3), ctx_r1.cm.sp("mb", 4)));
112
+ i0.ɵɵadvance();
113
+ i0.ɵɵclassMap(ctx_r1.cm.cn(ctx_r1.cm.textSize("sm"), ctx_r1.cm.textMuted));
114
+ i0.ɵɵadvance();
115
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.t("settings.twoFactorScan", undefined, i0.ɵɵpureFunction0(10, _c10)), " ");
116
+ i0.ɵɵadvance();
117
+ i0.ɵɵclassMap(ctx_r1.cm.cn(ctx_r1.cm.mxAuto, ctx_r1.cm.maxW("xs")));
118
+ i0.ɵɵattribute("src", ctx_r1.tfSetup()?.QRImageUrl)("alt", ctx_r1.t("settings.twoFactorQrAlt", undefined, i0.ɵɵpureFunction0(11, _c11)));
119
+ i0.ɵɵadvance();
120
+ i0.ɵɵconditional(ctx_r1.tfSetup()?.secret ? 4 : -1);
121
+ } }
122
+ function AuthSection_Conditional_0_Conditional_29_Conditional_6_Template(rf, ctx) { if (rf & 1) {
123
+ i0.ɵɵtext(0);
124
+ } if (rf & 2) {
125
+ const ctx_r1 = i0.ɵɵnextContext(3);
126
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.t("settings.twoFactorDisable", undefined, i0.ɵɵpureFunction0(1, _c7)), " ");
127
+ } }
128
+ function AuthSection_Conditional_0_Conditional_29_Conditional_7_Template(rf, ctx) { if (rf & 1) {
129
+ i0.ɵɵtext(0);
130
+ } if (rf & 2) {
131
+ const ctx_r1 = i0.ɵɵnextContext(3);
132
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.t("settings.twoFactorVerify", undefined, i0.ɵɵpureFunction0(1, _c13)), " ");
133
+ } }
134
+ function AuthSection_Conditional_0_Conditional_29_Template(rf, ctx) { if (rf & 1) {
135
+ const _r5 = i0.ɵɵgetCurrentView();
136
+ i0.ɵɵelementStart(0, "form", 7);
137
+ i0.ɵɵlistener("submit", function AuthSection_Conditional_0_Conditional_29_Template_form_submit_0_listener($event) { i0.ɵɵrestoreView(_r5); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.submitTfForm($event)); });
138
+ i0.ɵɵelementStart(1, "div")(2, "label", 15);
139
+ i0.ɵɵtext(3);
140
+ i0.ɵɵelementEnd();
141
+ i0.ɵɵelementStart(4, "div", 16);
142
+ i0.ɵɵlistener("change", function AuthSection_Conditional_0_Conditional_29_Template_div_change_4_listener($event) { i0.ɵɵrestoreView(_r5); const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.tfToken.set($event.target.value)); });
143
+ i0.ɵɵelementEnd()();
144
+ i0.ɵɵelementStart(5, "button", 17);
145
+ i0.ɵɵconditionalCreate(6, AuthSection_Conditional_0_Conditional_29_Conditional_6_Template, 1, 2)(7, AuthSection_Conditional_0_Conditional_29_Conditional_7_Template, 1, 2);
146
+ i0.ɵɵelementEnd()();
147
+ } if (rf & 2) {
148
+ const ctx_r1 = i0.ɵɵnextContext(2);
149
+ i0.ɵɵclassMap(ctx_r1.cm.stack(4));
150
+ i0.ɵɵadvance(2);
151
+ i0.ɵɵclassMap(ctx_r1.cm.formLabel);
152
+ i0.ɵɵadvance();
153
+ i0.ɵɵtextInterpolate(ctx_r1.t("settings.twoFactorCode", undefined, i0.ɵɵpureFunction0(12, _c12)));
154
+ i0.ɵɵadvance();
155
+ i0.ɵɵproperty("id", "tf-token")("required", true)("value", ctx_r1.tfToken());
156
+ i0.ɵɵadvance();
157
+ i0.ɵɵproperty("color", ctx_r1.tfModal() === "disable" ? "error" : "primary")("fullWidth", true)("loading", ctx_r1.tfLoading());
158
+ i0.ɵɵadvance();
159
+ i0.ɵɵconditional(ctx_r1.tfModal() === "disable" ? 6 : 7);
160
+ } }
161
+ function AuthSection_Conditional_0_Template(rf, ctx) { if (rf & 1) {
162
+ const _r1 = i0.ɵɵgetCurrentView();
163
+ i0.ɵɵelementStart(0, "section")(1, "h3");
164
+ i0.ɵɵtext(2);
165
+ i0.ɵɵelementEnd();
166
+ i0.ɵɵelementStart(3, "div")(4, "button", 0);
167
+ i0.ɵɵlistener("click", function AuthSection_Conditional_0_Template_button_click_4_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.showPasswordModal.set(true)); });
168
+ i0.ɵɵtext(5);
169
+ i0.ɵɵelementEnd();
170
+ i0.ɵɵelementStart(6, "div", 1)(7, "span");
171
+ i0.ɵɵtext(8);
172
+ i0.ɵɵconditionalCreate(9, AuthSection_Conditional_0_Conditional_9_Template, 2, 4, "span", 2);
173
+ i0.ɵɵelementEnd();
174
+ i0.ɵɵconditionalCreate(10, AuthSection_Conditional_0_Conditional_10_Template, 2, 4, "button", 3)(11, AuthSection_Conditional_0_Conditional_11_Template, 2, 4, "button", 4);
175
+ i0.ɵɵelementEnd()()();
176
+ i0.ɵɵelementStart(12, "mol-modal", 5);
177
+ i0.ɵɵlistener("close", function AuthSection_Conditional_0_Template_mol_modal_close_12_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.closePasswordModal()); });
178
+ i0.ɵɵconditionalCreate(13, AuthSection_Conditional_0_Conditional_13_Template, 2, 3, "div", 6);
179
+ i0.ɵɵelementStart(14, "form", 7);
180
+ i0.ɵɵlistener("submit", function AuthSection_Conditional_0_Template_form_submit_14_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.submitPassword($event)); });
181
+ i0.ɵɵelementStart(15, "div")(16, "label", 8);
182
+ i0.ɵɵtext(17);
183
+ i0.ɵɵelementEnd();
184
+ i0.ɵɵelementStart(18, "div", 9);
185
+ i0.ɵɵlistener("change", function AuthSection_Conditional_0_Template_div_change_18_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.currentPassword.set($event.target.value)); });
186
+ i0.ɵɵelementEnd()();
187
+ i0.ɵɵelementStart(19, "div")(20, "label", 10);
188
+ i0.ɵɵtext(21);
189
+ i0.ɵɵelementEnd();
190
+ i0.ɵɵelementStart(22, "div", 11);
191
+ i0.ɵɵlistener("change", function AuthSection_Conditional_0_Template_div_change_22_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.newPassword.set($event.target.value)); });
192
+ i0.ɵɵelementEnd()();
193
+ i0.ɵɵelementStart(23, "button", 12);
194
+ i0.ɵɵconditionalCreate(24, AuthSection_Conditional_0_Conditional_24_Template, 1, 2)(25, AuthSection_Conditional_0_Conditional_25_Template, 1, 2);
195
+ i0.ɵɵelementEnd()()();
196
+ i0.ɵɵelementStart(26, "mol-modal", 5);
197
+ i0.ɵɵlistener("close", function AuthSection_Conditional_0_Template_mol_modal_close_26_listener() { i0.ɵɵrestoreView(_r1); const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.closeTf()); });
198
+ i0.ɵɵconditionalCreate(27, AuthSection_Conditional_0_Conditional_27_Template, 2, 3, "div", 6);
199
+ i0.ɵɵconditionalCreate(28, AuthSection_Conditional_0_Conditional_28_Template, 5, 12, "div", 2);
200
+ i0.ɵɵconditionalCreate(29, AuthSection_Conditional_0_Conditional_29_Template, 8, 13, "form", 2);
201
+ i0.ɵɵelementEnd();
202
+ } if (rf & 2) {
203
+ let tmp_15_0;
204
+ let tmp_32_0;
205
+ const ctx_r1 = i0.ɵɵnextContext();
206
+ i0.ɵɵadvance();
207
+ i0.ɵɵclassMap(ctx_r1.cm.cn(ctx_r1.cm.sectionHeading, ctx_r1.cm.sp("mb", 3)));
208
+ i0.ɵɵadvance();
209
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.t("settings.authentication", undefined, i0.ɵɵpureFunction0(40, _c0)), " ");
210
+ i0.ɵɵadvance();
211
+ i0.ɵɵclassMap(ctx_r1.cm.stack(3));
212
+ i0.ɵɵadvance();
213
+ i0.ɵɵproperty("variant", "outline")("size", "sm");
214
+ i0.ɵɵadvance();
215
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.t("settings.changePassword", undefined, i0.ɵɵpureFunction0(41, _c1)), " ");
216
+ i0.ɵɵadvance();
217
+ i0.ɵɵproperty("align", "center")("justify", "between");
218
+ i0.ɵɵadvance();
219
+ i0.ɵɵclassMap(ctx_r1.cm.textSize("sm"));
220
+ i0.ɵɵadvance();
221
+ i0.ɵɵtextInterpolate(ctx_r1.t("settings.twoFactor", undefined, i0.ɵɵpureFunction0(42, _c2)));
222
+ i0.ɵɵadvance();
223
+ i0.ɵɵconditional(ctx_r1.twoFactorEnabled() ? 9 : -1);
224
+ i0.ɵɵadvance();
225
+ i0.ɵɵconditional(ctx_r1.twoFactorEnabled() ? 10 : 11);
226
+ i0.ɵɵadvance(2);
227
+ i0.ɵɵproperty("open", ctx_r1.showPasswordModal())("title", ctx_r1.t("settings.changePasswordModal.title", undefined, i0.ɵɵpureFunction0(43, _c3)));
228
+ i0.ɵɵadvance();
229
+ i0.ɵɵconditional((tmp_15_0 = ctx_r1.pwError()) ? 13 : -1, tmp_15_0);
230
+ i0.ɵɵadvance();
231
+ i0.ɵɵclassMap(ctx_r1.cm.stack(4));
232
+ i0.ɵɵadvance(2);
233
+ i0.ɵɵclassMap(ctx_r1.cm.formLabel);
234
+ i0.ɵɵadvance();
235
+ i0.ɵɵtextInterpolate(ctx_r1.t("settings.changePasswordModal.currentPassword", undefined, i0.ɵɵpureFunction0(44, _c4)));
236
+ i0.ɵɵadvance();
237
+ i0.ɵɵproperty("id", "current-pw")("required", true)("value", ctx_r1.currentPassword());
238
+ i0.ɵɵadvance(2);
239
+ i0.ɵɵclassMap(ctx_r1.cm.formLabel);
240
+ i0.ɵɵadvance();
241
+ i0.ɵɵtextInterpolate(ctx_r1.t("settings.changePasswordModal.newPassword", undefined, i0.ɵɵpureFunction0(45, _c5)));
242
+ i0.ɵɵadvance();
243
+ i0.ɵɵproperty("id", "new-pw")("required", true)("value", ctx_r1.newPassword());
244
+ i0.ɵɵadvance();
245
+ i0.ɵɵproperty("fullWidth", true)("loading", ctx_r1.pwStatus() === "pending");
246
+ i0.ɵɵadvance();
247
+ i0.ɵɵconditional(ctx_r1.pwStatus() === "pending" ? 24 : 25);
248
+ i0.ɵɵadvance(2);
249
+ i0.ɵɵproperty("open", ctx_r1.tfModal() !== null)("title", ctx_r1.tfTitle());
250
+ i0.ɵɵadvance();
251
+ i0.ɵɵconditional((tmp_32_0 = ctx_r1.tfError()) ? 27 : -1, tmp_32_0);
252
+ i0.ɵɵadvance();
253
+ i0.ɵɵconditional(ctx_r1.tfModal() === "enable" && ctx_r1.tfSetup()?.QRImageUrl ? 28 : -1);
254
+ i0.ɵɵadvance();
255
+ i0.ɵɵconditional(ctx_r1.tfModal() === "disable" || ctx_r1.tfSetup() ? 29 : -1);
256
+ } }
257
+ /**
258
+ * AuthSection component.
259
+ *
260
+ * Authentication section — change password (modal) + two-factor (TOTP) setup.
261
+ * React's root is a fragment (the `<section>` plus two modals), so the host is
262
+ * unwrapped by the DOM normalizer and `display: contents` keeps the layout
263
+ * fragment-like; an OAuth-only user renders NOTHING (React's `return null`).
264
+ *
265
+ * Two-factor uses the real enrollment flow against the user resource's
266
+ * `POST /users/:id/verify-two-factor` endpoint (`@molecule/api-two-factor`):
267
+ * - Enable → `{action:'setup'}` returns a QR code + secret to scan into an
268
+ * authenticator app → user enters the 6-digit code → `{action:'enable', token}`.
269
+ * - Disable → user enters a current code → `{action:'disable', token}`.
270
+ * The current status is read from `/users/me`. (This replaces the previous
271
+ * boolean toggle, which PATCHed `twoFactorEnabled` — a field the update
272
+ * handler deliberately ignores — so it never actually enrolled 2FA.)
273
+ *
274
+ * Auto-hides for OAuth-only users (`user.oauthServer` truthy) since
275
+ * password / 2FA wouldn't apply. If the app's API has no two-factor
276
+ * provider bonded, setup fails gracefully with an inline message.
277
+ *
278
+ * `useChangePassword`'s state is a live getter over a plain object (the
279
+ * Angular binding's `usePromise` port), so the pending/error reads are
280
+ * mediated by a version signal the handlers bump at React's re-render points.
281
+ */
282
+ export class AuthSection {
283
+ /** The signed-in user (React's `useAuth().user`). */
284
+ auth = useAuth();
285
+ /** Reactive translation, read in the injection context. */
286
+ i18n = useTranslation();
287
+ /** The translation function for the template. */
288
+ t = this.i18n.t;
289
+ http = useHttpClient();
290
+ /** The change-password flow's live state and action. */
291
+ pw = useChangePassword();
292
+ /** Whether the change-password modal is open. */
293
+ showPasswordModal = signal(false, /* @ts-ignore */
294
+ ...(ngDevMode ? [{ debugName: "showPasswordModal" }] : /* istanbul ignore next */ []));
295
+ /** The current-password field's value. */
296
+ currentPassword = signal('', /* @ts-ignore */
297
+ ...(ngDevMode ? [{ debugName: "currentPassword" }] : /* istanbul ignore next */ []));
298
+ /** The new-password field's value. */
299
+ newPassword = signal('', /* @ts-ignore */
300
+ ...(ngDevMode ? [{ debugName: "newPassword" }] : /* istanbul ignore next */ []));
301
+ /** Whether two-factor is enabled (read from `/users/me`). */
302
+ twoFactorEnabled = signal(false, /* @ts-ignore */
303
+ ...(ngDevMode ? [{ debugName: "twoFactorEnabled" }] : /* istanbul ignore next */ []));
304
+ /** The open two-factor modal: `'enable'`, `'disable'` or null. */
305
+ tfModal = signal(null, /* @ts-ignore */
306
+ ...(ngDevMode ? [{ debugName: "tfModal" }] : /* istanbul ignore next */ []));
307
+ /** The enrollment setup data (QR image + secret). */
308
+ tfSetup = signal(null, /* @ts-ignore */
309
+ ...(ngDevMode ? [{ debugName: "tfSetup" }] : /* istanbul ignore next */ []));
310
+ /** The two-factor code field's value. */
311
+ tfToken = signal('', /* @ts-ignore */
312
+ ...(ngDevMode ? [{ debugName: "tfToken" }] : /* istanbul ignore next */ []));
313
+ /** Whether a two-factor request is running. */
314
+ tfLoading = signal(false, /* @ts-ignore */
315
+ ...(ngDevMode ? [{ debugName: "tfLoading" }] : /* istanbul ignore next */ []));
316
+ /** The two-factor modal's error message. */
317
+ tfError = signal('', /* @ts-ignore */
318
+ ...(ngDevMode ? [{ debugName: "tfError" }] : /* istanbul ignore next */ []));
319
+ /** React's re-render points for `useChangePassword`'s plain state object. */
320
+ pwVersion = signal(0, /* @ts-ignore */
321
+ ...(ngDevMode ? [{ debugName: "pwVersion" }] : /* istanbul ignore next */ []));
322
+ /** The change-password flow's pending state (version-mediated). */
323
+ pwStatus = computed(() => {
324
+ void this.pwVersion();
325
+ return this.pw.status;
326
+ }, /* @ts-ignore */
327
+ ...(ngDevMode ? [{ debugName: "pwStatus" }] : /* istanbul ignore next */ []));
328
+ /** The change-password flow's error (version-mediated). */
329
+ pwError = computed(() => {
330
+ void this.pwVersion();
331
+ const error = this.pw.error;
332
+ if (!error)
333
+ return null;
334
+ return (error.message ||
335
+ this.t('settings.changePasswordModal.error', undefined, {
336
+ defaultValue: 'Failed to change password.',
337
+ }));
338
+ }, /* @ts-ignore */
339
+ ...(ngDevMode ? [{ debugName: "pwError" }] : /* istanbul ignore next */ []));
340
+ twoFactorRead = { cancelled: false };
341
+ /** The bonded ClassMap (styling tokens resolve at render time). */
342
+ cm = getClassMap();
343
+ /**
344
+ * Whether the signed-in user is OAuth-only (the section renders nothing).
345
+ * @returns True when the user's `oauthServer` is truthy.
346
+ */
347
+ isOauthOnly() {
348
+ return !!this.auth.user()?.oauthServer;
349
+ }
350
+ /**
351
+ * The two-factor modal's title (React's ternary).
352
+ * @returns The title text.
353
+ */
354
+ tfTitle() {
355
+ return this.tfModal() === 'disable'
356
+ ? this.t('settings.twoFactorDisableTitle', undefined, {
357
+ defaultValue: 'Disable two-factor authentication',
358
+ })
359
+ : this.t('settings.twoFactorEnableTitle', undefined, {
360
+ defaultValue: 'Enable two-factor authentication',
361
+ });
362
+ }
363
+ /**
364
+ * Reads the persisted 2FA status from `/users/me` on mount (React's mount
365
+ * effect); status read is best-effort and defaults to disabled. A result
366
+ * that lands after unmount is dropped like React's cancelled one.
367
+ */
368
+ constructor() {
369
+ const read = this.twoFactorRead;
370
+ inject(DestroyRef).onDestroy(() => {
371
+ read.cancelled = true;
372
+ });
373
+ void this.http
374
+ .get('/api/users/me')
375
+ .then((res) => {
376
+ if (read.cancelled)
377
+ return;
378
+ const body = res.data ?? res;
379
+ const u = (body.props ?? body);
380
+ this.twoFactorEnabled.set(Boolean(u?.twoFactorEnabled));
381
+ })
382
+ .catch((_error) => {
383
+ /* status read is best-effort; defaults to disabled */
384
+ });
385
+ }
386
+ /**
387
+ * Closes the change-password modal (React's `onClose`): hides it and
388
+ * returns the change-password flow to idle.
389
+ */
390
+ closePasswordModal() {
391
+ this.showPasswordModal.set(false);
392
+ this.pw.reset();
393
+ this.pwVersion.update((version) => version + 1);
394
+ }
395
+ /**
396
+ * Opens the disable-two-factor modal (React's disable button handler).
397
+ */
398
+ openDisableTf() {
399
+ this.tfError.set('');
400
+ this.tfToken.set('');
401
+ this.tfModal.set('disable');
402
+ }
403
+ /**
404
+ * Starts the two-factor enrollment (React's `startEnable`): fetches the QR
405
+ * setup and opens the enable modal.
406
+ */
407
+ async startEnable() {
408
+ this.tfError.set('');
409
+ this.tfLoading.set(true);
410
+ this.tfModal.set('enable');
411
+ const userId = this.auth.user()?.id;
412
+ try {
413
+ const res = await this.http.post(`/api/users/${userId}/verify-two-factor`, {
414
+ action: 'setup',
415
+ });
416
+ const data = (res.data ?? res);
417
+ this.tfSetup.set(data);
418
+ }
419
+ catch (err) {
420
+ this.tfError.set(serverErrorMessage(err) ??
421
+ this.t('settings.twoFactorUnavailable', undefined, {
422
+ defaultValue: 'Two-factor authentication is not available for this app.',
423
+ }));
424
+ }
425
+ finally {
426
+ this.tfLoading.set(false);
427
+ }
428
+ }
429
+ /**
430
+ * Submits the two-factor code (React's `submitTf`).
431
+ * @param action - Whether the code enables or disables two-factor.
432
+ */
433
+ async submitTf(action) {
434
+ this.tfError.set('');
435
+ this.tfLoading.set(true);
436
+ const userId = this.auth.user()?.id;
437
+ try {
438
+ await this.http.post(`/api/users/${userId}/verify-two-factor`, {
439
+ action,
440
+ token: this.tfToken(),
441
+ });
442
+ this.twoFactorEnabled.set(action === 'enable');
443
+ this.closeTf();
444
+ }
445
+ catch (err) {
446
+ this.tfError.set(serverErrorMessage(err) ??
447
+ this.t('settings.twoFactorInvalidCode', undefined, { defaultValue: 'Invalid code' }));
448
+ }
449
+ finally {
450
+ this.tfLoading.set(false);
451
+ }
452
+ }
453
+ /**
454
+ * The two-factor modal form's submit (React's inline onSubmit).
455
+ * @param event - The native submit event.
456
+ */
457
+ submitTfForm(event) {
458
+ event.preventDefault();
459
+ void this.submitTf(this.tfModal() === 'disable' ? 'disable' : 'enable');
460
+ }
461
+ /**
462
+ * Closes the two-factor modal (React's `closeTf`).
463
+ */
464
+ closeTf() {
465
+ this.tfModal.set(null);
466
+ this.tfSetup.set(null);
467
+ this.tfToken.set('');
468
+ this.tfError.set('');
469
+ }
470
+ /**
471
+ * Submits the change-password form (React's `handleChangePassword`).
472
+ * @param event - The native submit event.
473
+ */
474
+ async submitPassword(event) {
475
+ event.preventDefault();
476
+ this.pwVersion.update((version) => version + 1);
477
+ try {
478
+ await this.pw.changePassword(this.currentPassword(), this.newPassword());
479
+ this.showPasswordModal.set(false);
480
+ this.currentPassword.set('');
481
+ this.newPassword.set('');
482
+ this.pw.reset();
483
+ }
484
+ catch (_error) {
485
+ // Error tracked in hook state — useChangePassword surfaces it via `error`.
486
+ }
487
+ finally {
488
+ this.pwVersion.update((version) => version + 1);
489
+ }
490
+ }
491
+ static ɵfac = function AuthSection_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || AuthSection)(); };
492
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: AuthSection, selectors: [["mol-auth-section"]], hostAttrs: ["data-parity-unwrap", "", 2, "display", "contents"], decls: 1, vars: 1, consts: [["mol-button", "", 3, "click", "variant", "size"], ["mol-flex", "", 3, "align", "justify"], [3, "class"], ["mol-button", "", "data-mol-id", "two-factor-disable", 3, "variant", "size"], ["mol-button", "", "data-mol-id", "two-factor-enable", 3, "variant", "size"], [3, "close", "open", "title"], ["mol-alert", "", 3, "status", "className"], [3, "submit"], ["for", "current-pw"], ["mol-input", "", "type", "password", "autocomplete", "current-password", 3, "change", "id", "required", "value"], ["for", "new-pw"], ["mol-input", "", "type", "password", "autocomplete", "new-password", 3, "change", "id", "required", "value"], ["mol-button", "", "type", "submit", 3, "fullWidth", "loading"], ["mol-button", "", "data-mol-id", "two-factor-disable", 3, "click", "variant", "size"], ["mol-button", "", "data-mol-id", "two-factor-enable", 3, "click", "variant", "size"], ["for", "tf-token"], ["mol-input", "", "type", "text", "autocomplete", "one-time-code", 3, "change", "id", "required", "value"], ["mol-button", "", "type", "submit", 3, "color", "fullWidth", "loading"]], template: function AuthSection_Template(rf, ctx) { if (rf & 1) {
493
+ i0.ɵɵconditionalCreate(0, AuthSection_Conditional_0_Template, 30, 46);
494
+ } if (rf & 2) {
495
+ i0.ɵɵconditional(!ctx.isOauthOnly() ? 0 : -1);
496
+ } }, dependencies: [Alert, Button, Flex, Input, Modal], encapsulation: 2 });
497
+ }
498
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(AuthSection, [{
499
+ type: Component,
500
+ args: [{
501
+ selector: 'mol-auth-section',
502
+ standalone: true,
503
+ imports: [Alert, Button, Flex, Input, Modal],
504
+ host: {
505
+ 'data-parity-unwrap': '',
506
+ style: 'display: contents',
507
+ },
508
+ // prettier-ignore
509
+ template: `@if (!isOauthOnly()) {
510
+ <section>
511
+ <h3 [class]="cm.cn(cm.sectionHeading, cm.sp('mb', 3))">
512
+ {{ t('settings.authentication', undefined, { defaultValue: 'Authentication' }) }}
513
+ </h3>
514
+ <div [class]="cm.stack(3)">
515
+ <button
516
+ mol-button
517
+ [variant]="'outline'"
518
+ [size]="'sm'"
519
+ (click)="showPasswordModal.set(true)"
520
+ >
521
+ {{ t('settings.changePassword', undefined, { defaultValue: 'Change password' }) }}
522
+ </button>
523
+ <div mol-flex [align]="'center'" [justify]="'between'">
524
+ <span [class]="cm.textSize('sm')">{{ t('settings.twoFactor', undefined, { defaultValue: 'Two-factor authentication' }) }}@if (twoFactorEnabled()) {<span [class]="cm.cn(cm.textSize('xs'), cm.textSubtle, cm.sp('ml', 2))">{{ t('settings.twoFactorOn', undefined, { defaultValue: 'On' }) }}</span>}</span>
525
+ @if (twoFactorEnabled()) {
526
+ <button
527
+ mol-button
528
+ [variant]="'outline'"
529
+ [size]="'sm'"
530
+ (click)="openDisableTf()"
531
+ data-mol-id="two-factor-disable"
532
+ >
533
+ {{ t('settings.twoFactorDisable', undefined, { defaultValue: 'Disable' }) }}
534
+ </button>
535
+ } @else {
536
+ <button
537
+ mol-button
538
+ [variant]="'outline'"
539
+ [size]="'sm'"
540
+ (click)="startEnable()"
541
+ data-mol-id="two-factor-enable"
542
+ >
543
+ {{ t('settings.twoFactorEnable', undefined, { defaultValue: 'Enable' }) }}
544
+ </button>
545
+ }
546
+ </div>
547
+ </div>
548
+ </section>
549
+ <mol-modal
550
+ [open]="showPasswordModal()"
551
+ (close)="closePasswordModal()"
552
+ [title]="
553
+ t('settings.changePasswordModal.title', undefined, { defaultValue: 'Change Password' })
554
+ "
555
+ >
556
+ @if (pwError(); as changeError) {
557
+ <div mol-alert [status]="'error'" [className]="cm.sp('mb', 4)">{{ changeError }}</div>
558
+ }
559
+ <form [class]="cm.stack(4)" (submit)="submitPassword($event)">
560
+ <div>
561
+ <label for="current-pw" [class]="cm.formLabel">{{
562
+ t('settings.changePasswordModal.currentPassword', undefined, {
563
+ defaultValue: 'Current Password',
564
+ })
565
+ }}</label>
566
+ <div
567
+ mol-input
568
+ [id]="'current-pw'"
569
+ type="password"
570
+ autocomplete="current-password"
571
+ [required]="true"
572
+ [value]="currentPassword()"
573
+ (change)="currentPassword.set($any($event.target).value)"
574
+ ></div>
575
+ </div>
576
+ <div>
577
+ <label for="new-pw" [class]="cm.formLabel">{{
578
+ t('settings.changePasswordModal.newPassword', undefined, {
579
+ defaultValue: 'New Password',
580
+ })
581
+ }}</label>
582
+ <div
583
+ mol-input
584
+ [id]="'new-pw'"
585
+ type="password"
586
+ autocomplete="new-password"
587
+ [required]="true"
588
+ [value]="newPassword()"
589
+ (change)="newPassword.set($any($event.target).value)"
590
+ ></div>
591
+ </div>
592
+ <button mol-button type="submit" [fullWidth]="true" [loading]="pwStatus() === 'pending'">
593
+ @if (pwStatus() === 'pending') {
594
+ {{
595
+ t('settings.changePasswordModal.changing', undefined, { defaultValue: 'Changing...' })
596
+ }}
597
+ } @else {
598
+ {{ t('settings.changePassword', undefined, { defaultValue: 'Change password' }) }}
599
+ }
600
+ </button>
601
+ </form>
602
+ </mol-modal>
603
+ <mol-modal [open]="tfModal() !== null" (close)="closeTf()" [title]="tfTitle()">
604
+ @if (tfError(); as tfFailure) {
605
+ <div mol-alert [status]="'error'" [className]="cm.sp('mb', 4)">{{ tfFailure }}</div>
606
+ }
607
+ @if (tfModal() === 'enable' && tfSetup()?.QRImageUrl) {
608
+ <div [class]="cm.cn(cm.stack(3), cm.sp('mb', 4))">
609
+ <p [class]="cm.cn(cm.textSize('sm'), cm.textMuted)">
610
+ {{
611
+ t('settings.twoFactorScan', undefined, {
612
+ defaultValue:
613
+ 'Scan this QR code with your authenticator app, then enter the 6-digit code.',
614
+ })
615
+ }}
616
+ </p>
617
+ <img
618
+ [attr.src]="tfSetup()?.QRImageUrl"
619
+ [attr.alt]="
620
+ t('settings.twoFactorQrAlt', undefined, { defaultValue: 'Two-factor QR code' })
621
+ "
622
+ [class]="cm.cn(cm.mxAuto, cm.maxW('xs'))"
623
+ />
624
+ @if (tfSetup()?.secret) {
625
+ <p [class]="cm.cn(cm.textSize('xs'), cm.textSubtle, cm.settingsPanelTwoFactorSecret)">
626
+ {{ tfSetup()?.secret }}
627
+ </p>
628
+ }
629
+ </div>
630
+ }
631
+ @if (tfModal() === 'disable' || tfSetup()) {
632
+ <form [class]="cm.stack(4)" (submit)="submitTfForm($event)">
633
+ <div>
634
+ <label for="tf-token" [class]="cm.formLabel">{{
635
+ t('settings.twoFactorCode', undefined, { defaultValue: 'Authentication code' })
636
+ }}</label>
637
+ <div
638
+ mol-input
639
+ [id]="'tf-token'"
640
+ type="text"
641
+ autocomplete="one-time-code"
642
+ [required]="true"
643
+ [value]="tfToken()"
644
+ (change)="tfToken.set($any($event.target).value)"
645
+ ></div>
646
+ </div>
647
+ <button
648
+ mol-button
649
+ type="submit"
650
+ [color]="tfModal() === 'disable' ? 'error' : 'primary'"
651
+ [fullWidth]="true"
652
+ [loading]="tfLoading()"
653
+ >
654
+ @if (tfModal() === 'disable') {
655
+ {{ t('settings.twoFactorDisable', undefined, { defaultValue: 'Disable' }) }}
656
+ } @else {
657
+ {{ t('settings.twoFactorVerify', undefined, { defaultValue: 'Verify & enable' }) }}
658
+ }
659
+ </button>
660
+ </form>
661
+ }
662
+ </mol-modal>
663
+ }`,
664
+ }]
665
+ }], () => [], null); })();
666
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(AuthSection, { className: "AuthSection", filePath: "auth-section.component.ts", lineNumber: 213 }); })();
667
+ //# sourceMappingURL=auth-section.component.js.map