@dloizides/auth-web 1.12.0 → 1.12.1

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.mjs CHANGED
@@ -113,7 +113,7 @@ function AuthScreen({
113
113
  ] });
114
114
  }
115
115
 
116
- // src/components/labels.ts
116
+ // src/components/labels/loginLabels.ts
117
117
  var DEFAULT_LOGIN_LABELS = {
118
118
  title: "Sign in",
119
119
  subtitle: "Welcome back",
@@ -128,6 +128,8 @@ var DEFAULT_LOGIN_LABELS = {
128
128
  invalidCredentials: "Incorrect username or password.",
129
129
  missingFields: "Enter both your username and password."
130
130
  };
131
+
132
+ // src/components/labels/forgotPasswordLabels.ts
131
133
  var DEFAULT_FORGOT_PASSWORD_LABELS = {
132
134
  title: "Forgot password",
133
135
  description: "Enter your email and we will send you a reset link.",
@@ -144,6 +146,8 @@ var DEFAULT_FORGOT_PASSWORD_FIELDS_LABELS = {
144
146
  cancel: "Cancel",
145
147
  close: "Close"
146
148
  };
149
+
150
+ // src/components/labels/otpLabels.ts
147
151
  var DEFAULT_OTP_LABELS = {
148
152
  requestTitle: "Sign in with a code",
149
153
  requestDescription: "Enter your email and we will send you a one-time code.",
@@ -164,6 +168,8 @@ var DEFAULT_OTP_LABELS = {
164
168
  resending: "Resending...",
165
169
  changeEmail: "Use a different email"
166
170
  };
171
+
172
+ // src/components/labels/pinLabels.ts
167
173
  var DEFAULT_PIN_LABELS = {
168
174
  title: "Enter your event PIN",
169
175
  description: "Enter the PIN for this event to sign in.",
@@ -174,6 +180,8 @@ var DEFAULT_PIN_LABELS = {
174
180
  missingPin: "Enter your event PIN.",
175
181
  invalidPin: "That PIN is incorrect, has expired, or is locked out."
176
182
  };
183
+
184
+ // src/components/labels/devicePinLabels.ts
177
185
  var DEFAULT_DEVICE_PIN_UNLOCK_LABELS = {
178
186
  title: "Welcome back, {name}",
179
187
  titleNoName: "Welcome back",
@@ -231,6 +239,8 @@ var DEFAULT_DEVICE_PIN_SETTINGS_LABELS = {
231
239
  disabling: "Disabling...",
232
240
  disableFailed: "Could not disable PIN sign-in. Try again later."
233
241
  };
242
+
243
+ // src/components/labels/passkeyLabels.ts
234
244
  var DEFAULT_PASSKEY_LOGIN_LABELS = {
235
245
  signInButton: "Sign in with a passkey",
236
246
  signInHint: "Use your fingerprint, face, or security key to sign in",
@@ -246,6 +256,8 @@ var DEFAULT_PASSKEY_SETTINGS_LABELS = {
246
256
  addHint: "Start setting up a passkey for this account",
247
257
  registeredSuccess: "Your passkey was added. You can now use it to sign in."
248
258
  };
259
+
260
+ // src/components/labels/preferredMethodLabels.ts
249
261
  var DEFAULT_PREFERRED_METHOD_SETTINGS_LABELS = {
250
262
  title: "Preferred sign-in method",
251
263
  description: "Pick how you usually sign in. We will show this method first on your devices.",
@@ -261,6 +273,8 @@ var DEFAULT_PREFERRED_METHOD_HINT_LABELS = {
261
273
  pin: "You usually sign in with your quick PIN on this account.",
262
274
  passkey: "You usually sign in with a passkey."
263
275
  };
276
+
277
+ // src/components/labels/demoLabels.ts
264
278
  var DEFAULT_DEMO_CREDENTIALS_HINT_LABELS = {
265
279
  title: "Demo access",
266
280
  description: "Explore the full product with our shared demo account.",
@@ -269,6 +283,8 @@ var DEFAULT_DEMO_CREDENTIALS_HINT_LABELS = {
269
283
  useCredentials: "Use these credentials",
270
284
  useCredentialsHint: "Fill the sign-in form with the demo username and password"
271
285
  };
286
+
287
+ // src/components/labels/resetPasswordLabels.ts
272
288
  var DEFAULT_RESET_PASSWORD_LABELS = {
273
289
  title: "Reset password",
274
290
  description: "Choose a new password for your account.",
@@ -522,6 +538,35 @@ function useLoginPrefill({
522
538
  }
523
539
  return { username, password, setUsername, setPassword };
524
540
  }
541
+ function useLoginSubmit({
542
+ username,
543
+ password,
544
+ login,
545
+ onSuccess,
546
+ missingFieldsLabel,
547
+ invalidCredentialsLabel
548
+ }) {
549
+ const [errorText, setErrorText] = useState(null);
550
+ const runLogin = useCallback(async () => {
551
+ setErrorText(null);
552
+ const trimmedUsername = username.trim();
553
+ const hasMissingField = trimmedUsername.length === 0 || password.length === 0;
554
+ if (hasMissingField) {
555
+ setErrorText(missingFieldsLabel);
556
+ return;
557
+ }
558
+ try {
559
+ const user = await login({ username: trimmedUsername, password });
560
+ onSuccess(user);
561
+ } catch {
562
+ setErrorText(invalidCredentialsLabel);
563
+ }
564
+ }, [username, password, login, onSuccess, missingFieldsLabel, invalidCredentialsLabel]);
565
+ const handleSubmit = useCallback(() => {
566
+ void runLogin();
567
+ }, [runLogin]);
568
+ return { errorText, handleSubmit };
569
+ }
525
570
  var BffAuthStatus = /* @__PURE__ */ ((BffAuthStatus2) => {
526
571
  BffAuthStatus2["Loading"] = "loading";
527
572
  BffAuthStatus2["Authenticated"] = "authenticated";
@@ -652,25 +697,14 @@ function LoginForm({
652
697
  prefillNonce,
653
698
  prefillIntent
654
699
  });
655
- const [errorText, setErrorText] = useState(null);
656
- const runLogin = useCallback(async () => {
657
- setErrorText(null);
658
- const trimmedUsername = username.trim();
659
- const hasMissingField = trimmedUsername.length === 0 || password.length === 0;
660
- if (hasMissingField) {
661
- setErrorText(labels.missingFields);
662
- return;
663
- }
664
- try {
665
- const user = await login({ username: trimmedUsername, password });
666
- onSuccess(user);
667
- } catch {
668
- setErrorText(labels.invalidCredentials);
669
- }
670
- }, [username, password, login, onSuccess, labels.missingFields, labels.invalidCredentials]);
671
- const handleSubmit = useCallback(() => {
672
- void runLogin();
673
- }, [runLogin]);
700
+ const { errorText, handleSubmit } = useLoginSubmit({
701
+ username,
702
+ password,
703
+ login,
704
+ onSuccess,
705
+ missingFieldsLabel: labels.missingFields,
706
+ invalidCredentialsLabel: labels.invalidCredentials
707
+ });
674
708
  const submitButtonStyle = isSubmitting ? [styles3.primaryButton, styles3.primaryButtonDisabled] : styles3.primaryButton;
675
709
  const content = /* @__PURE__ */ jsxs(Fragment, { children: [
676
710
  /* @__PURE__ */ jsx(Text, { style: styles3.title, children: labels.title }),