@mcurros2/microm 1.1.286-0 → 1.1.288-0

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/dist/index.js CHANGED
@@ -524,6 +524,10 @@ var $98ddT = parcelRequire("98ddT");
524
524
 
525
525
  var $78KzE = parcelRequire("78KzE");
526
526
 
527
+ var $c7RNL = parcelRequire("c7RNL");
528
+
529
+ var $fazHk = parcelRequire("fazHk");
530
+
527
531
  var $lq5EG = parcelRequire("lq5EG");
528
532
 
529
533
  var $2VTPU = parcelRequire("2VTPU");
@@ -541,6 +545,8 @@ $parcel$exportWildcard(module.exports, $8yTUG);
541
545
  $parcel$exportWildcard(module.exports, $dU7Zq);
542
546
  $parcel$exportWildcard(module.exports, $98ddT);
543
547
  $parcel$exportWildcard(module.exports, $78KzE);
548
+ $parcel$exportWildcard(module.exports, $c7RNL);
549
+ $parcel$exportWildcard(module.exports, $fazHk);
544
550
  $parcel$exportWildcard(module.exports, $lq5EG);
545
551
  $parcel$exportWildcard(module.exports, $2VTPU);
546
552
  $parcel$exportWildcard(module.exports, $fiYMH);
@@ -810,6 +816,7 @@ class $16abd72d1aa9b62d$export$6118e57c65bf19ee {
810
816
  url: response?.url
811
817
  };
812
818
  const data = await response.json();
819
+ if (data?.requires_two_factor && data?.two_factor_challenge_id) return data;
813
820
  if (data && data.access_token) {
814
821
  const token = new (0, $78KzE.MicroMToken)(data.access_token, data.expires_in, data['refresh-token'], data.token_type, data);
815
822
  await this.#setToken(token);
@@ -843,6 +850,98 @@ class $16abd72d1aa9b62d$export$6118e57c65bf19ee {
843
850
  loginTimeout.clear();
844
851
  }
845
852
  }
853
+ async login2fa(challengeId, code, rememberme, username) {
854
+ const loginTimeout = new (0, $dF8o7.TimeoutSignal)(this.#LOGIN_TIMEOUT, 'Two-factor login request timed out');
855
+ try {
856
+ const response = await fetch(`${this.#API_URL}/${this.#APP_ID}/auth/login-2fa`, {
857
+ method: 'POST',
858
+ headers: {
859
+ "Content-Type": "application/json; charset=utf-8"
860
+ },
861
+ mode: this.#REQUEST_MODE,
862
+ cache: 'no-store',
863
+ credentials: 'include',
864
+ referrerPolicy: 'strict-origin-when-cross-origin',
865
+ signal: loginTimeout.signal,
866
+ body: JSON.stringify({
867
+ challengeId: challengeId,
868
+ code: code
869
+ })
870
+ });
871
+ if (!response.ok) throw {
872
+ status: response?.status,
873
+ statusMessage: response?.statusText,
874
+ message: response?.statusText,
875
+ url: response?.url
876
+ };
877
+ const data = await response.json();
878
+ if (data && data.access_token) {
879
+ const token = new (0, $78KzE.MicroMToken)(data.access_token, data.expires_in, data['refresh-token'], data.token_type, data);
880
+ await this.#setToken(token);
881
+ try {
882
+ await this.#DATA_STORAGE.saveData(this.#APP_ID, $16abd72d1aa9b62d$var$REMEMBER_USER_DATA_KEY, rememberme ? username ?? null : null);
883
+ } catch (error) {
884
+ console.warn('Error remembering user', error);
885
+ }
886
+ try {
887
+ await this.#getAPIEnabledMenus(username ?? token.claims.username ?? '', loginTimeout.signal);
888
+ } catch (error) {
889
+ console.warn('Error getting enabled menus', error);
890
+ }
891
+ try {
892
+ await this.#getTimeZoneOffset(loginTimeout.signal);
893
+ } catch (error) {
894
+ console.warn('Error getting server timezone offset', error);
895
+ }
896
+ return token;
897
+ }
898
+ throw {
899
+ statusMessage: 'Unexpected result',
900
+ url: response.url
901
+ };
902
+ } catch (error) {
903
+ console.warn('Two-factor login error', error);
904
+ throw error;
905
+ } finally{
906
+ loginTimeout.clear();
907
+ }
908
+ }
909
+ async registerLoginTotp(challengeId) {
910
+ const loginTimeout = new (0, $dF8o7.TimeoutSignal)(this.#LOGIN_TIMEOUT, 'Authenticator registration request timed out');
911
+ const route = `${this.#API_URL}/${this.#APP_ID}/auth/login-2fa/register`;
912
+ try {
913
+ const response = await fetch(route, {
914
+ method: 'POST',
915
+ headers: {
916
+ "Content-Type": "application/json; charset=utf-8"
917
+ },
918
+ mode: this.#REQUEST_MODE,
919
+ cache: 'no-store',
920
+ credentials: 'include',
921
+ referrerPolicy: 'strict-origin-when-cross-origin',
922
+ signal: loginTimeout.signal,
923
+ body: JSON.stringify({
924
+ challengeId: challengeId
925
+ })
926
+ });
927
+ if (!response.ok) {
928
+ let error_body = undefined;
929
+ try {
930
+ error_body = await response.text();
931
+ } catch {}
932
+ throw {
933
+ status: response?.status,
934
+ statusMessage: response?.statusText,
935
+ message: response?.statusText,
936
+ url: response?.url,
937
+ errorBody: error_body
938
+ };
939
+ }
940
+ return await response.json();
941
+ } finally{
942
+ loginTimeout.clear();
943
+ }
944
+ }
846
945
  async localLogoff() {
847
946
  await this.#removeToken();
848
947
  await this.#deleteEnabledMenus();
@@ -944,6 +1043,89 @@ class $16abd72d1aa9b62d$export$6118e57c65bf19ee {
944
1043
  loginTimeout.clear();
945
1044
  }
946
1045
  }
1046
+ async startTotpSetup() {
1047
+ const loginTimeout = new (0, $dF8o7.TimeoutSignal)(this.#LOGIN_TIMEOUT, 'TOTP setup request timed out');
1048
+ const route = `${this.#API_URL}/${this.#APP_ID}/auth/totp/setup`;
1049
+ try {
1050
+ await this.#checkAndRefreshToken();
1051
+ if (!this.#TOKEN) throw {
1052
+ status: 401,
1053
+ statusMessage: `Can't execute request: Not logged in`,
1054
+ url: route
1055
+ };
1056
+ const response = await fetch(route, {
1057
+ method: 'POST',
1058
+ headers: {
1059
+ "Content-Type": "application/json; charset=utf-8",
1060
+ "Authorization": `Bearer ${this.#TOKEN.access_token}`
1061
+ },
1062
+ mode: this.#REQUEST_MODE,
1063
+ cache: 'no-store',
1064
+ credentials: 'include',
1065
+ referrerPolicy: 'strict-origin-when-cross-origin',
1066
+ signal: loginTimeout.signal,
1067
+ body: JSON.stringify({})
1068
+ });
1069
+ if (!response.ok) {
1070
+ let error_body = undefined;
1071
+ try {
1072
+ error_body = await response.text();
1073
+ } catch {}
1074
+ throw {
1075
+ status: response?.status,
1076
+ statusMessage: response?.statusText,
1077
+ message: response?.statusText,
1078
+ url: response?.url,
1079
+ errorBody: error_body
1080
+ };
1081
+ }
1082
+ return await response.json();
1083
+ } finally{
1084
+ loginTimeout.clear();
1085
+ }
1086
+ }
1087
+ async confirmTotpSetup(code) {
1088
+ const loginTimeout = new (0, $dF8o7.TimeoutSignal)(this.#LOGIN_TIMEOUT, 'TOTP confirmation request timed out');
1089
+ const route = `${this.#API_URL}/${this.#APP_ID}/auth/totp/confirm`;
1090
+ try {
1091
+ await this.#checkAndRefreshToken();
1092
+ if (!this.#TOKEN) throw {
1093
+ status: 401,
1094
+ statusMessage: `Can't execute request: Not logged in`,
1095
+ url: route
1096
+ };
1097
+ const response = await fetch(route, {
1098
+ method: 'POST',
1099
+ headers: {
1100
+ "Content-Type": "application/json; charset=utf-8",
1101
+ "Authorization": `Bearer ${this.#TOKEN.access_token}`
1102
+ },
1103
+ mode: this.#REQUEST_MODE,
1104
+ cache: 'no-store',
1105
+ credentials: 'include',
1106
+ referrerPolicy: 'strict-origin-when-cross-origin',
1107
+ signal: loginTimeout.signal,
1108
+ body: JSON.stringify({
1109
+ Code: code
1110
+ })
1111
+ });
1112
+ if (!response.ok) {
1113
+ let error_body = undefined;
1114
+ try {
1115
+ error_body = await response.text();
1116
+ } catch {}
1117
+ throw {
1118
+ status: response?.status,
1119
+ statusMessage: response?.statusText,
1120
+ message: response?.statusText,
1121
+ url: response?.url,
1122
+ errorBody: error_body
1123
+ };
1124
+ }
1125
+ } finally{
1126
+ loginTimeout.clear();
1127
+ }
1128
+ }
947
1129
  async #getLocalDeviceId() {
948
1130
  const local_device = await this.#DATA_STORAGE.readData(this.#APP_ID, $16abd72d1aa9b62d$var$LOCAL_DEVICE_ID_KEY);
949
1131
  if (local_device !== null) {
@@ -1902,6 +2084,14 @@ function $bd8fcf7d101f1db4$export$22ad9388388847b(e) {
1902
2084
 
1903
2085
  });
1904
2086
 
2087
+ parcelRegister("c7RNL", function(module, exports) {
2088
+
2089
+ });
2090
+
2091
+ parcelRegister("fazHk", function(module, exports) {
2092
+
2093
+ });
2094
+
1905
2095
  parcelRegister("lq5EG", function(module, exports) {
1906
2096
 
1907
2097
  });
@@ -3502,6 +3692,8 @@ var $6Tg0K = parcelRequire("6Tg0K");
3502
3692
 
3503
3693
  var $1trwm = parcelRequire("1trwm");
3504
3694
 
3695
+ var $k00la = parcelRequire("k00la");
3696
+
3505
3697
  var $1cuD1 = parcelRequire("1cuD1");
3506
3698
 
3507
3699
  var $lTSno = parcelRequire("lTSno");
@@ -3608,6 +3800,7 @@ $parcel$exportWildcard(module.exports, $k4b2f);
3608
3800
  $parcel$exportWildcard(module.exports, $fFu0M);
3609
3801
  $parcel$exportWildcard(module.exports, $6Tg0K);
3610
3802
  $parcel$exportWildcard(module.exports, $1trwm);
3803
+ $parcel$exportWildcard(module.exports, $k00la);
3611
3804
  $parcel$exportWildcard(module.exports, $1cuD1);
3612
3805
  $parcel$exportWildcard(module.exports, $lTSno);
3613
3806
  $parcel$exportWildcard(module.exports, $7ttm6);
@@ -3821,26 +4014,40 @@ const $a8704b86039e0c33$export$c2c75fd58793f69 = {
3821
4014
  forgotLabel: "Forgot password?",
3822
4015
  signInButtonLabel: "Sign in",
3823
4016
  loginErrorMessage: "Unknown user name or bad password",
3824
- confirmRecoveryEmailTitle: "Recovery email"
4017
+ confirmRecoveryEmailTitle: "Recovery email",
4018
+ codeLabel: "Authentication code",
4019
+ codePlaceholder: "123456",
4020
+ verifyCodeButtonLabel: "Verify code",
4021
+ twoFactorTitle: "Two-factor authentication",
4022
+ twoFactorDescription: "Enter the 6-digit code from your authenticator app.",
4023
+ twoFactorProviderLabel: "Provider",
4024
+ cancelTwoFactorButtonLabel: "Back"
3825
4025
  };
3826
4026
  function $a8704b86039e0c33$export$21a94553ffa41578(props) {
3827
- const { client: client, onStatusCompleted: onStatusCompleted, userLabel: userLabel, userPlaceholder: userPlaceholder, passwordLabel: passwordLabel, passwordPlaceholder: passwordPlaceholder, rememberLabel: rememberLabel, forgotLabel: forgotLabel, signInButtonLabel: signInButtonLabel, loginErrorMessage: loginErrorMessage, confirmRecoveryEmailTitle: confirmRecoveryEmailTitle } = (0, $b4te3$mantinecore.useComponentDefaultProps)('Login', $a8704b86039e0c33$export$c2c75fd58793f69, props);
4027
+ const { client: client, onStatusCompleted: onStatusCompleted, userLabel: userLabel, userPlaceholder: userPlaceholder, passwordLabel: passwordLabel, passwordPlaceholder: passwordPlaceholder, rememberLabel: rememberLabel, forgotLabel: forgotLabel, signInButtonLabel: signInButtonLabel, loginErrorMessage: loginErrorMessage, confirmRecoveryEmailTitle: confirmRecoveryEmailTitle, codeLabel: codeLabel, codePlaceholder: codePlaceholder, verifyCodeButtonLabel: verifyCodeButtonLabel, twoFactorTitle: twoFactorTitle, twoFactorDescription: twoFactorDescription, twoFactorProviderLabel: twoFactorProviderLabel, cancelTwoFactorButtonLabel: cancelTwoFactorButtonLabel } = (0, $b4te3$mantinecore.useComponentDefaultProps)('Login', $a8704b86039e0c33$export$c2c75fd58793f69, props);
3828
4028
  const modal = (0, $k7qj2.useModal)();
3829
4029
  const form = (0, $b4te3$mantineform.useForm)({
3830
4030
  initialValues: {
3831
4031
  user: '',
3832
4032
  password: '',
4033
+ code: '',
3833
4034
  server: '',
3834
4035
  rememberme: false
3835
4036
  }
3836
4037
  });
3837
4038
  const [status, setStatus] = (0, $b4te3$react.useState)();
4039
+ const [twoFactorState, setTwoFactorState] = (0, $b4te3$react.useState)();
3838
4040
  const handleClick = (0, $b4te3$react.useCallback)(async (values)=>{
3839
4041
  setStatus({
3840
4042
  loading: true
3841
4043
  });
3842
4044
  try {
3843
4045
  const data = await client.login(values.user, values.password, values.rememberme);
4046
+ if ('requires_two_factor' in data && data.requires_two_factor) {
4047
+ setTwoFactorState(data);
4048
+ setStatus(undefined);
4049
+ return;
4050
+ }
3844
4051
  const new_status = {
3845
4052
  data: data
3846
4053
  };
@@ -3857,6 +4064,30 @@ function $a8704b86039e0c33$export$21a94553ffa41578(props) {
3857
4064
  client,
3858
4065
  onStatusCompleted
3859
4066
  ]);
4067
+ const handleTwoFactorClick = (0, $b4te3$react.useCallback)(async (values)=>{
4068
+ if (!twoFactorState?.two_factor_challenge_id) return;
4069
+ setStatus({
4070
+ loading: true
4071
+ });
4072
+ try {
4073
+ const data = await client.login2fa(twoFactorState.two_factor_challenge_id, values.code, values.rememberme, values.user);
4074
+ const new_status = {
4075
+ data: data
4076
+ };
4077
+ setStatus(new_status);
4078
+ onStatusCompleted(new_status);
4079
+ } catch (e) {
4080
+ const new_status = {
4081
+ error: (0, $98ddT.toMicroMError)(e)
4082
+ };
4083
+ setStatus(new_status);
4084
+ onStatusCompleted(new_status);
4085
+ }
4086
+ }, [
4087
+ client,
4088
+ onStatusCompleted,
4089
+ twoFactorState
4090
+ ]);
3860
4091
  const handleForgotPasswordClick = (0, $b4te3$react.useCallback)(async ()=>{
3861
4092
  await modal.open({
3862
4093
  modalProps: {
@@ -3882,6 +4113,13 @@ function $a8704b86039e0c33$export$21a94553ffa41578(props) {
3882
4113
  confirmRecoveryEmailTitle,
3883
4114
  modal
3884
4115
  ]);
4116
+ const handleCancelTwoFactorClick = (0, $b4te3$react.useCallback)(()=>{
4117
+ setTwoFactorState(undefined);
4118
+ setStatus(undefined);
4119
+ form.setFieldValue('code', '');
4120
+ }, [
4121
+ form
4122
+ ]);
3885
4123
  (0, $b4te3$react.useEffect)(()=>{
3886
4124
  const getRememberUser = async ()=>{
3887
4125
  const result = await client.getRememberUser();
@@ -3903,7 +4141,7 @@ function $a8704b86039e0c33$export$21a94553ffa41578(props) {
3903
4141
  placeholder: userPlaceholder,
3904
4142
  required: true,
3905
4143
  "data-autofocus": true,
3906
- disabled: status?.loading,
4144
+ disabled: status?.loading || !!twoFactorState,
3907
4145
  ...form.getInputProps('user')
3908
4146
  }),
3909
4147
  /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.PasswordInput), {
@@ -3911,34 +4149,97 @@ function $a8704b86039e0c33$export$21a94553ffa41578(props) {
3911
4149
  placeholder: passwordPlaceholder,
3912
4150
  required: true,
3913
4151
  mt: "md",
3914
- disabled: status?.loading,
4152
+ disabled: status?.loading || !!twoFactorState,
3915
4153
  ...form.getInputProps('password')
3916
4154
  }),
3917
- /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsxs)((0, $b4te3$mantinecore.Group), {
3918
- position: "apart",
3919
- mt: "lg",
4155
+ twoFactorState ? /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsxs)((0, $b4te3$mantinecore.Stack), {
4156
+ mt: "md",
3920
4157
  children: [
3921
- /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Checkbox), {
3922
- label: rememberLabel,
3923
- ...form.getInputProps('rememberme', {
3924
- type: 'checkbox'
3925
- })
4158
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsxs)((0, $b4te3$mantinecore.Stack), {
4159
+ spacing: 2,
4160
+ children: [
4161
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Text), {
4162
+ weight: 700,
4163
+ children: twoFactorTitle
4164
+ }),
4165
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Text), {
4166
+ size: "sm",
4167
+ color: "dimmed",
4168
+ children: twoFactorDescription
4169
+ }),
4170
+ twoFactorState.two_factor_provider && /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsxs)((0, $b4te3$mantinecore.Text), {
4171
+ size: "xs",
4172
+ color: "dimmed",
4173
+ children: [
4174
+ twoFactorProviderLabel,
4175
+ ": ",
4176
+ twoFactorState.two_factor_provider
4177
+ ]
4178
+ })
4179
+ ]
3926
4180
  }),
3927
- /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Anchor), {
3928
- component: "button",
3929
- size: "sm",
3930
- onClick: handleForgotPasswordClick,
3931
- children: forgotLabel
3932
- })
4181
+ twoFactorState.two_factor_setup_required && twoFactorState.qr_code_data_url && /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Image), {
4182
+ src: twoFactorState.qr_code_data_url,
4183
+ alt: twoFactorTitle,
4184
+ width: 180,
4185
+ height: 180,
4186
+ fit: "contain",
4187
+ mx: "auto"
4188
+ }),
4189
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.PinInput), {
4190
+ length: 6,
4191
+ oneTimeCode: true,
4192
+ type: "number",
4193
+ "aria-label": codeLabel,
4194
+ placeholder: codePlaceholder,
4195
+ disabled: status?.loading,
4196
+ ...form.getInputProps('code')
4197
+ }),
4198
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Button), {
4199
+ type: "button",
4200
+ fullWidth: true,
4201
+ disabled: status?.loading || form.values.code.length !== 6,
4202
+ onClick: ()=>void handleTwoFactorClick(form.values),
4203
+ children: verifyCodeButtonLabel
4204
+ }, "login2fa"),
4205
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Button), {
4206
+ type: "button",
4207
+ variant: "subtle",
4208
+ fullWidth: true,
4209
+ disabled: status?.loading,
4210
+ onClick: handleCancelTwoFactorClick,
4211
+ children: cancelTwoFactorButtonLabel
4212
+ }, "login2fa-cancel")
3933
4213
  ]
3934
- }),
3935
- /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Button), {
3936
- fullWidth: true,
3937
- mt: "xl",
3938
- disabled: status?.loading,
3939
- type: "submit",
3940
- children: signInButtonLabel
3941
- }, "login")
4214
+ }) : /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsxs)((0, $b4te3$reactjsxruntime.Fragment), {
4215
+ children: [
4216
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsxs)((0, $b4te3$mantinecore.Group), {
4217
+ position: "apart",
4218
+ mt: "lg",
4219
+ children: [
4220
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Checkbox), {
4221
+ label: rememberLabel,
4222
+ ...form.getInputProps('rememberme', {
4223
+ type: 'checkbox'
4224
+ })
4225
+ }),
4226
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Anchor), {
4227
+ component: "button",
4228
+ size: "sm",
4229
+ onClick: handleForgotPasswordClick,
4230
+ children: forgotLabel
4231
+ })
4232
+ ]
4233
+ }),
4234
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Button), {
4235
+ fullWidth: true,
4236
+ mt: "xl",
4237
+ disabled: status?.loading,
4238
+ type: "submit",
4239
+ children: signInButtonLabel
4240
+ }, "login")
4241
+ ]
4242
+ })
3942
4243
  ]
3943
4244
  }, "loginForm"),
3944
4245
  /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $d50o9.AlertError), {
@@ -3960,6 +4261,8 @@ $parcel$export(module.exports, "LoginModal", function () { return $e618e7386572d
3960
4261
 
3961
4262
 
3962
4263
 
4264
+ parcelRequire("6Rdyz");
4265
+ var $78KzE = parcelRequire("78KzE");
3963
4266
 
3964
4267
  var $2bGyU = parcelRequire("2bGyU");
3965
4268
  const $e618e7386572db7d$export$1e0d8a58055c4b22 = {
@@ -3971,7 +4274,7 @@ function $e618e7386572db7d$export$b4d7a44be6f5e733(props) {
3971
4274
  const [opened, { open: open, close: close }] = (0, $b4te3$mantinehooks.useDisclosure)(false);
3972
4275
  const statusCompletedHandler = (status)=>{
3973
4276
  if (!status.error && !status.loading) {
3974
- onLoggedIn(status.data?.claims);
4277
+ if (status.data instanceof (0, $78KzE.MicroMToken)) onLoggedIn(status.data?.claims);
3975
4278
  close();
3976
4279
  }
3977
4280
  };
@@ -5773,6 +6076,139 @@ const $4d7c21d6728b5e66$export$5eaee2322dd727eb = /*#__PURE__*/ (0, $b4te3$react
5773
6076
 
5774
6077
  });
5775
6078
 
6079
+ parcelRegister("k00la", function(module, exports) {
6080
+
6081
+ $parcel$export(module.exports, "TotpSetupDefaultProps", function () { return $4896b8c893e8a8b7$export$2a737ca3b0b47ab9; });
6082
+ $parcel$export(module.exports, "TotpSetup", function () { return $4896b8c893e8a8b7$export$4de403def52aabf2; });
6083
+
6084
+
6085
+
6086
+ parcelRequire("6Rdyz");
6087
+ var $98ddT = parcelRequire("98ddT");
6088
+ parcelRequire("7xGLy");
6089
+ var $d50o9 = parcelRequire("d50o9");
6090
+ var $gLcPf = parcelRequire("gLcPf");
6091
+ var $lFsp3 = parcelRequire("lFsp3");
6092
+ const $4896b8c893e8a8b7$export$2a737ca3b0b47ab9 = {
6093
+ setupButtonLabel: "Set up authenticator app",
6094
+ confirmButtonLabel: "Confirm code",
6095
+ qrAlt: "Authenticator setup QR code",
6096
+ codePlaceholder: "123456",
6097
+ setupTitle: "Authenticator app",
6098
+ setupDescription: "Scan this QR code with your authenticator app, then enter the 6-digit code.",
6099
+ successMessage: "Authenticator app is enabled.",
6100
+ errorMessage: "The authenticator request could not be completed."
6101
+ };
6102
+ function $4896b8c893e8a8b7$export$4de403def52aabf2(props) {
6103
+ const { client: client, onConfirmed: onConfirmed, setupButtonLabel: setupButtonLabel, confirmButtonLabel: confirmButtonLabel, qrAlt: qrAlt, codePlaceholder: codePlaceholder, setupTitle: setupTitle, setupDescription: setupDescription, successMessage: successMessage, errorMessage: errorMessage } = (0, $b4te3$mantinecore.useComponentDefaultProps)('TotpSetup', $4896b8c893e8a8b7$export$2a737ca3b0b47ab9, props);
6104
+ const [setupResponse, setSetupResponse] = (0, $b4te3$react.useState)();
6105
+ const [code, setCode] = (0, $b4te3$react.useState)("");
6106
+ const [status, setStatus] = (0, $b4te3$react.useState)();
6107
+ const [confirmed, setConfirmed] = (0, $b4te3$react.useState)(false);
6108
+ const startSetup = (0, $b4te3$react.useCallback)(async ()=>{
6109
+ setStatus({
6110
+ loading: true
6111
+ });
6112
+ setConfirmed(false);
6113
+ try {
6114
+ const data = await client.startTotpSetup();
6115
+ setSetupResponse(data);
6116
+ setCode("");
6117
+ setStatus({
6118
+ data: data
6119
+ });
6120
+ } catch (e) {
6121
+ setStatus({
6122
+ error: (0, $98ddT.toMicroMError)(e)
6123
+ });
6124
+ }
6125
+ }, [
6126
+ client
6127
+ ]);
6128
+ const confirmSetup = (0, $b4te3$react.useCallback)(async ()=>{
6129
+ if (code.length !== 6) return;
6130
+ setStatus({
6131
+ loading: true
6132
+ });
6133
+ try {
6134
+ await client.confirmTotpSetup(code);
6135
+ setConfirmed(true);
6136
+ setSetupResponse(undefined);
6137
+ setCode("");
6138
+ setStatus({
6139
+ data: null
6140
+ });
6141
+ onConfirmed?.();
6142
+ } catch (e) {
6143
+ setStatus({
6144
+ error: (0, $98ddT.toMicroMError)(e)
6145
+ });
6146
+ }
6147
+ }, [
6148
+ client,
6149
+ code,
6150
+ onConfirmed
6151
+ ]);
6152
+ return /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsxs)((0, $b4te3$mantinecore.Stack), {
6153
+ children: [
6154
+ status?.loading && /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $lFsp3.FakeProgressBar), {}),
6155
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsxs)((0, $b4te3$mantinecore.Stack), {
6156
+ spacing: 4,
6157
+ children: [
6158
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Text), {
6159
+ weight: 700,
6160
+ children: setupTitle
6161
+ }),
6162
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Text), {
6163
+ size: "sm",
6164
+ color: "dimmed",
6165
+ children: setupDescription
6166
+ })
6167
+ ]
6168
+ }),
6169
+ !setupResponse && /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Button), {
6170
+ disabled: status?.loading,
6171
+ onClick: ()=>void startSetup(),
6172
+ children: setupButtonLabel
6173
+ }),
6174
+ setupResponse && /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsxs)((0, $b4te3$mantinecore.Stack), {
6175
+ children: [
6176
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Image), {
6177
+ src: setupResponse.qr_code_data_url,
6178
+ alt: qrAlt,
6179
+ width: 220,
6180
+ fit: "contain"
6181
+ }),
6182
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.PinInput), {
6183
+ length: 6,
6184
+ oneTimeCode: true,
6185
+ type: "number",
6186
+ placeholder: codePlaceholder,
6187
+ disabled: status?.loading,
6188
+ value: code,
6189
+ onChange: setCode
6190
+ }),
6191
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Button), {
6192
+ disabled: status?.loading || code.length !== 6,
6193
+ onClick: ()=>void confirmSetup(),
6194
+ children: confirmButtonLabel
6195
+ })
6196
+ ]
6197
+ }),
6198
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $gLcPf.AlertSuccess), {
6199
+ hidden: !confirmed,
6200
+ children: successMessage
6201
+ }),
6202
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $d50o9.AlertError), {
6203
+ hidden: status?.error === undefined,
6204
+ children: status?.error?.errorBody || status?.error?.message || errorMessage
6205
+ })
6206
+ ]
6207
+ });
6208
+ }
6209
+
6210
+ });
6211
+
5776
6212
  parcelRegister("1cuD1", function(module, exports) {
5777
6213
 
5778
6214
  $parcel$export(module.exports, "useIsLoggedIn", function () { return $3bfcddb14bcddf39$export$79c3258edc7d1573; });
@@ -41976,31 +42412,12 @@ const $7cd3d360cc78f6d8$var$columns = ()=>({
41976
42412
  flags: (0, $4H7ea.CommonFlags).Edit | (0, $4H7ea.EntityColumnFlags).nullable,
41977
42413
  prompt: 'Sid'
41978
42414
  }),
41979
- vc_refreshtoken: new (0, $ZmuZ6.EntityColumn)({
41980
- name: 'vc_refreshtoken',
41981
- type: 'varchar',
41982
- length: 255,
41983
- flags: (0, $4H7ea.CommonFlags).Edit | (0, $4H7ea.EntityColumnFlags).nullable,
41984
- prompt: 'Refreshtoken'
41985
- }),
41986
- dt_refresh_expiration: new (0, $ZmuZ6.EntityColumn)({
41987
- name: 'dt_refresh_expiration',
41988
- type: 'datetime',
41989
- flags: (0, $4H7ea.CommonFlags).Edit | (0, $4H7ea.EntityColumnFlags).nullable,
41990
- prompt: 'Refresh Expiration'
41991
- }),
41992
42415
  i_badlogonattempts: new (0, $ZmuZ6.EntityColumn)({
41993
42416
  name: 'i_badlogonattempts',
41994
42417
  type: 'int',
41995
42418
  flags: (0, $4H7ea.CommonFlags).Edit,
41996
42419
  prompt: 'Badlogonattempts'
41997
42420
  }),
41998
- i_refreshcount: new (0, $ZmuZ6.EntityColumn)({
41999
- name: 'i_refreshcount',
42000
- type: 'int',
42001
- flags: (0, $4H7ea.CommonFlags).Edit,
42002
- prompt: 'Refreshcount'
42003
- }),
42004
42421
  bt_disabled: new (0, $ZmuZ6.EntityColumn)({
42005
42422
  name: 'bt_disabled',
42006
42423
  type: 'bit',
@@ -42026,6 +42443,20 @@ const $7cd3d360cc78f6d8$var$columns = ()=>({
42026
42443
  flags: (0, $4H7ea.CommonFlags).Edit | (0, $4H7ea.EntityColumnFlags).nullable,
42027
42444
  prompt: 'Last Refresh'
42028
42445
  }),
42446
+ vc_totp_secret: new (0, $ZmuZ6.EntityColumn)({
42447
+ name: 'vc_totp_secret',
42448
+ type: 'varchar',
42449
+ length: 2048,
42450
+ flags: (0, $4H7ea.CommonFlags).Edit | (0, $4H7ea.EntityColumnFlags).nullable,
42451
+ prompt: 'Authenticator secret'
42452
+ }),
42453
+ bt_totp_enabled: new (0, $ZmuZ6.EntityColumn)({
42454
+ name: 'bt_totp_enabled',
42455
+ type: 'bit',
42456
+ length: 1,
42457
+ flags: (0, $4H7ea.CommonFlags).Edit,
42458
+ prompt: 'Require two-factor authentication'
42459
+ }),
42029
42460
  vc_recovery_code: new (0, $ZmuZ6.EntityColumn)({
42030
42461
  name: 'vc_recovery_code',
42031
42462
  type: 'varchar',
@@ -42101,9 +42532,14 @@ const $7cd3d360cc78f6d8$var$lookups = ()=>({
42101
42532
  entityConstructor: (client, parentKeys)=>new (0, $amyT1.MicromUsersGroups)(client, parentKeys)
42102
42533
  }
42103
42534
  });
42535
+ const $7cd3d360cc78f6d8$var$procs = ()=>({
42536
+ usr_resetTotp: {
42537
+ name: 'usr_resetTotp'
42538
+ }
42539
+ });
42104
42540
  class $7cd3d360cc78f6d8$export$27f9d3139d5e0650 extends (0, $5Sq1V.EntityDefinition) {
42105
42541
  constructor(){
42106
- super('MicromUsers'), this.columns = $7cd3d360cc78f6d8$var$columns(), this.views = $7cd3d360cc78f6d8$var$views(), this.lookups = $7cd3d360cc78f6d8$var$lookups();
42542
+ super('MicromUsers'), this.columns = $7cd3d360cc78f6d8$var$columns(), this.procs = $7cd3d360cc78f6d8$var$procs(), this.views = $7cd3d360cc78f6d8$var$views(), this.lookups = $7cd3d360cc78f6d8$var$lookups();
42107
42543
  }
42108
42544
  }
42109
42545
 
@@ -42741,8 +43177,10 @@ $parcel$export(module.exports, "MicromUsersFormDefaultProps", function () { retu
42741
43177
  $parcel$export(module.exports, "MicromUsersForm", function () { return $74b4ad43bb829977$export$d02b502c2d0f2ad7; });
42742
43178
 
42743
43179
 
43180
+
42744
43181
  parcelRequire("kMllr");
42745
43182
  var $cnfVv = parcelRequire("cnfVv");
43183
+ var $j7Y9b = parcelRequire("j7Y9b");
42746
43184
  var $bHLhd = parcelRequire("bHLhd");
42747
43185
  var $lMHpE = parcelRequire("lMHpE");
42748
43186
  var $aOnQQ = parcelRequire("aOnQQ");
@@ -42750,6 +43188,7 @@ var $hxOxo = parcelRequire("hxOxo");
42750
43188
  var $jPtkB = parcelRequire("jPtkB");
42751
43189
  var $RUzV3 = parcelRequire("RUzV3");
42752
43190
  var $bW9pc = parcelRequire("bW9pc");
43191
+ var $k7qj2 = parcelRequire("k7qj2");
42753
43192
  const $74b4ad43bb829977$export$e0b12d06f12bb2af = {
42754
43193
  initialFormMode: 'view',
42755
43194
  disabledFalseLabel: 'The account is enabled',
@@ -42761,10 +43200,36 @@ const $74b4ad43bb829977$export$e0b12d06f12bb2af = {
42761
43200
  logonAttemptsStatusTitle: 'Bad login attemps',
42762
43201
  logonAttemptsStatusDescription: 'The account registers failed login attempts',
42763
43202
  minutesLabel: 'minutes',
42764
- willUnlockInNextLogonLabel: 'Account automatic lock period has finished. It will be unlocked in the next successful logon.'
43203
+ willUnlockInNextLogonLabel: 'Account automatic lock period has finished. It will be unlocked in the next successful logon.',
43204
+ authenticatorEnabledLabel: 'Two-factor authentication is required',
43205
+ authenticatorDisabledLabel: 'Two-factor authentication is not required',
43206
+ authenticatorStatusTitle: 'Two-factor authentication',
43207
+ resetAuthenticatorButtonLabel: 'Delete all authenticators',
43208
+ resetAuthenticatorTitle: 'Delete all authenticators',
43209
+ resetAuthenticatorConfirmation: 'All currently registered authenticator apps will stop working. If two-factor authentication is required, the user must register an authenticator again on the next login.',
43210
+ resetAuthenticatorOKLabel: 'Delete all'
42765
43211
  };
43212
+ const $74b4ad43bb829977$var$TOTP_BASE32_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
43213
+ function $74b4ad43bb829977$var$generateTotpSecret(byteLength = 20) {
43214
+ const bytes = new Uint8Array(byteLength);
43215
+ crypto.getRandomValues(bytes);
43216
+ let bits = 0;
43217
+ let value = 0;
43218
+ let output = "";
43219
+ for (const byte of bytes){
43220
+ value = value << 8 | byte;
43221
+ bits += 8;
43222
+ while(bits >= 5){
43223
+ output += $74b4ad43bb829977$var$TOTP_BASE32_ALPHABET[value >>> bits - 5 & 31];
43224
+ bits -= 5;
43225
+ }
43226
+ }
43227
+ if (bits > 0) output += $74b4ad43bb829977$var$TOTP_BASE32_ALPHABET[value << 5 - bits & 31];
43228
+ return output;
43229
+ }
42766
43230
  function $74b4ad43bb829977$export$d02b502c2d0f2ad7(props) {
42767
- const { entity: entity, initialFormMode: initialFormMode, getDataOnInit: getDataOnInit, onSaved: onSaved, onCancel: onCancel, disabledFalseLabel: disabledFalseLabel, disabledTrueLabel: disabledTrueLabel, lockedRemainingLabel: lockedRemainingLabel, userDisabledLabel: userDisabledLabel, userEnabledLabel: userEnabledLabel, logonAttemptsStatusDescription: logonAttemptsStatusDescription, logonAttemptsStatusTitle: logonAttemptsStatusTitle, lockedTitleLabel: lockedTitleLabel, minutesLabel: minutesLabel, willUnlockInNextLogonLabel: willUnlockInNextLogonLabel } = (0, $b4te3$mantinecore.useComponentDefaultProps)('MicromUsersForm', $74b4ad43bb829977$export$e0b12d06f12bb2af, props);
43231
+ const { entity: entity, initialFormMode: initialFormMode, getDataOnInit: getDataOnInit, onSaved: onSaved, onCancel: onCancel, disabledFalseLabel: disabledFalseLabel, disabledTrueLabel: disabledTrueLabel, lockedRemainingLabel: lockedRemainingLabel, userDisabledLabel: userDisabledLabel, userEnabledLabel: userEnabledLabel, logonAttemptsStatusDescription: logonAttemptsStatusDescription, logonAttemptsStatusTitle: logonAttemptsStatusTitle, lockedTitleLabel: lockedTitleLabel, minutesLabel: minutesLabel, willUnlockInNextLogonLabel: willUnlockInNextLogonLabel, authenticatorEnabledLabel: authenticatorEnabledLabel, authenticatorDisabledLabel: authenticatorDisabledLabel, authenticatorStatusTitle: authenticatorStatusTitle, resetAuthenticatorButtonLabel: resetAuthenticatorButtonLabel, resetAuthenticatorTitle: resetAuthenticatorTitle, resetAuthenticatorConfirmation: resetAuthenticatorConfirmation, resetAuthenticatorOKLabel: resetAuthenticatorOKLabel } = (0, $b4te3$mantinecore.useComponentDefaultProps)('MicromUsersForm', $74b4ad43bb829977$export$e0b12d06f12bb2af, props);
43232
+ const modal = (0, $k7qj2.useModal)();
42768
43233
  const entityForm = (0, $bW9pc.useEntityForm)({
42769
43234
  entity: entity,
42770
43235
  initialFormMode: initialFormMode,
@@ -42775,6 +43240,44 @@ function $74b4ad43bb829977$export$d02b502c2d0f2ad7(props) {
42775
43240
  });
42776
43241
  const { formMode: formMode, status: status } = entityForm;
42777
43242
  const MAXBADLOGON_ATTEMPTS = 10;
43243
+ const handleResetAuthenticatorClick = async ()=>{
43244
+ await modal.open({
43245
+ modalProps: {
43246
+ title: /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsxs)((0, $b4te3$mantinecore.Group), {
43247
+ spacing: "xs",
43248
+ children: [
43249
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$tablericonsreact.IconRefresh), {
43250
+ size: "1.25rem"
43251
+ }),
43252
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Text), {
43253
+ fw: 700,
43254
+ children: resetAuthenticatorTitle
43255
+ })
43256
+ ]
43257
+ })
43258
+ },
43259
+ content: /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $j7Y9b.ConfirmAndExecutePanel), {
43260
+ content: /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Text), {
43261
+ size: "sm",
43262
+ children: resetAuthenticatorConfirmation
43263
+ }),
43264
+ operation: "proc",
43265
+ okButtonText: resetAuthenticatorOKLabel,
43266
+ onCancel: async ()=>await modal.close(),
43267
+ onOK: async ()=>{
43268
+ const result = await entity.API.executeProcess(entity.def.procs.usr_resetTotp, {
43269
+ vc_username: entityForm.form.values.vc_username,
43270
+ vc_totp_secret: $74b4ad43bb829977$var$generateTotpSecret()
43271
+ });
43272
+ if (result.Failed === false) {
43273
+ await entityForm.performGetData();
43274
+ await modal.close();
43275
+ }
43276
+ return result;
43277
+ }
43278
+ })
43279
+ });
43280
+ };
42778
43281
  return /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $bHLhd.EntityForm), {
42779
43282
  formAPI: entityForm,
42780
43283
  children: /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsxs)((0, $b4te3$mantinecore.Stack), {
@@ -42819,6 +43322,25 @@ function $74b4ad43bb829977$export$d02b502c2d0f2ad7(props) {
42819
43322
  column: entity.def.columns.bt_disabled,
42820
43323
  required: false
42821
43324
  }),
43325
+ formMode !== 'add' && /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsxs)((0, $b4te3$mantinecore.Group), {
43326
+ align: "end",
43327
+ children: [
43328
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $cnfVv.CheckboxField), {
43329
+ entityForm: entityForm,
43330
+ column: entity.def.columns.bt_totp_enabled,
43331
+ required: false
43332
+ }),
43333
+ /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$mantinecore.Button), {
43334
+ variant: "light",
43335
+ leftIcon: /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $b4te3$tablericonsreact.IconRefresh), {
43336
+ size: "1rem"
43337
+ }),
43338
+ onClick: ()=>void handleResetAuthenticatorClick(),
43339
+ disabled: status.loading,
43340
+ children: resetAuthenticatorButtonLabel
43341
+ })
43342
+ ]
43343
+ }),
42822
43344
  /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsxs)((0, $b4te3$mantinecore.Group), {
42823
43345
  children: [
42824
43346
  (!entity.def.columns.bt_islocked.value || entity.def.columns.bt_disabled.value) && /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $aOnQQ.NotifyBitField), {
@@ -42832,6 +43354,13 @@ function $74b4ad43bb829977$export$d02b502c2d0f2ad7(props) {
42832
43354
  falseColor: (0, $aOnQQ.NotifyBitFieldDefaultProps).trueColor,
42833
43355
  falseIcon: (0, $aOnQQ.NotifyBitFieldDefaultProps).trueIcon
42834
43356
  }),
43357
+ formMode !== 'add' && /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $aOnQQ.NotifyBitField), {
43358
+ column: entity.def.columns.bt_totp_enabled,
43359
+ title: authenticatorStatusTitle,
43360
+ trueMessage: authenticatorEnabledLabel,
43361
+ falseMessage: authenticatorDisabledLabel,
43362
+ withBorder: true
43363
+ }),
42835
43364
  entity.def.columns.i_badlogonattempts.value > 0 && !entity.def.columns.bt_islocked.value && entity.def.columns.i_locked_minutes_remaining.value === 0 && /*#__PURE__*/ (0, $b4te3$reactjsxruntime.jsx)((0, $jPtkB.RingProgressField), {
42836
43365
  column: entity.def.columns.i_badlogonattempts,
42837
43366
  maxValue: MAXBADLOGON_ATTEMPTS,
@@ -45679,6 +46208,8 @@ $parcel$export(module.exports, "LoginModalForm", function () { return $9a4a231d2
45679
46208
 
45680
46209
 
45681
46210
 
46211
+ parcelRequire("6Rdyz");
46212
+ var $78KzE = parcelRequire("78KzE");
45682
46213
 
45683
46214
  var $2bGyU = parcelRequire("2bGyU");
45684
46215
  const $9a4a231d2265ecd4$export$cb4f37c94e0044f1 = {
@@ -45691,7 +46222,7 @@ function $9a4a231d2265ecd4$export$1dfef97d6d6bf90e(props) {
45691
46222
  const [opened, { open: open, close: close }] = (0, $b4te3$mantinehooks.useDisclosure)(false);
45692
46223
  const statusCompletedHandler = (status)=>{
45693
46224
  if (!status.error && !status.loading) {
45694
- onLoggedIn(status.data?.claims);
46225
+ if (status.data instanceof (0, $78KzE.MicroMToken)) onLoggedIn(status.data?.claims);
45695
46226
  close();
45696
46227
  }
45697
46228
  };