@dloizides/auth-web 1.18.0 → 1.18.2

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.d.mts CHANGED
@@ -2460,7 +2460,7 @@ interface RegisterFormProps<TResult> {
2460
2460
  onSuccess: (result: TResult) => void;
2461
2461
  /** Called with the failure code; map it to localised copy. */
2462
2462
  onError?: (error: RegisterErrorCode) => void;
2463
- /** Called on every submit press, before validation (e.g. a "signup started" event). */
2463
+ /** Called once per accepted submit, before validation (e.g. a "signup started" event); never for a press ignored in flight. */
2464
2464
  onSubmitAttempt?: () => void;
2465
2465
  /** Password rule. Defaults to `isRegisterPasswordStrong`. */
2466
2466
  passwordPolicy?: RegisterPasswordPolicy;
@@ -2506,6 +2506,11 @@ interface UseRegisterFormArgs<TResult> {
2506
2506
  onSubmit: (values: RegisterSubmitValues) => Promise<TResult>;
2507
2507
  /** Password rule. Defaults to {@link isRegisterPasswordStrong}. */
2508
2508
  passwordPolicy?: RegisterPasswordPolicy;
2509
+ /**
2510
+ * Called once per ACCEPTED submit, before validation (e.g. a "signup started"
2511
+ * event). A press ignored because a submit is already in flight does not call it.
2512
+ */
2513
+ onSubmitAttempt?: () => void;
2509
2514
  }
2510
2515
  interface UseRegisterFormResult<TResult> {
2511
2516
  state: RegisterFormValues;
@@ -2516,7 +2521,7 @@ interface UseRegisterFormResult<TResult> {
2516
2521
  error: RegisterErrorCode | null;
2517
2522
  }
2518
2523
  /** Headless registration form logic. */
2519
- declare function useRegisterForm<TResult>({ onSubmit, passwordPolicy, }: UseRegisterFormArgs<TResult>): UseRegisterFormResult<TResult>;
2524
+ declare function useRegisterForm<TResult>({ onSubmit, passwordPolicy, onSubmitAttempt, }: UseRegisterFormArgs<TResult>): UseRegisterFormResult<TResult>;
2520
2525
 
2521
2526
  /**
2522
2527
  * Pure registration helpers: trimming, client-side validation and decoding of a
@@ -2529,8 +2534,6 @@ declare function useRegisterForm<TResult>({ onSubmit, passwordPolicy, }: UseRegi
2529
2534
 
2530
2535
  /** The default password rule: 8+ characters with a letter, a digit and a special character. */
2531
2536
  declare function isRegisterPasswordStrong(password: string): boolean;
2532
- /** Decode a thrown registration failure into a {@link RegisterErrorCode}. */
2533
- declare function mapRegisterErrorCode(error: unknown): RegisterErrorCode;
2534
2537
 
2535
2538
  /**
2536
2539
  * `createBffAuthClient` — the one-line wiring of a same-origin `BffAuthClient`.
@@ -2821,4 +2824,4 @@ interface UseChangePasswordResult {
2821
2824
  }
2822
2825
  declare function useChangePassword({ client, onChanged, }: UseChangePasswordArgs): UseChangePasswordResult;
2823
2826
 
2824
- export { type AccountSettingsChangePasswordConfig, type AccountSettingsDevicePinConfig, type AccountSettingsLabels, type AccountSettingsPasskeysConfig, type AccountSettingsPreferredMethodConfig, AccountSettingsScreen, type AccountSettingsScreenProps, AuthScreen, type AuthScreenProps, AuthTestIds, type AuthTheme, type AuthThemeColors, AuthThemeProvider, type AuthThemeProviderProps, type AuthThemeRadii, type AuthThemeSpacing, type AuthThemeTypography, BffAuthStatus, type BffDeviceState, type BffLoginConfig, type BffLogoutClient, CHANGE_PASSWORD_ENDPOINT, type ChangePasswordCapableClient, ChangePasswordCard, type ChangePasswordCardProps, ChangePasswordErrorKey, type ChangePasswordRequest, type ChangePasswordResult, type CreateBffAuthClientOptions, type CreateBffChangePasswordClientOptions, DEFAULT_ACCOUNT_SETTINGS_LABELS, DEFAULT_AUTH_CARD_MAX_WIDTH, DEFAULT_DEMO_CREDENTIALS_HINT_LABELS, DEFAULT_DEVICE_PIN_ENROLL_LABELS, DEFAULT_DEVICE_PIN_SETTINGS_LABELS, DEFAULT_DEVICE_PIN_UNLOCK_LABELS, DEFAULT_FORGOT_PASSWORD_FIELDS_LABELS, DEFAULT_FORGOT_PASSWORD_LABELS, DEFAULT_LOGIN_LABELS, DEFAULT_OTP_LABELS, DEFAULT_PASSKEY_LOGIN_LABELS, DEFAULT_PASSKEY_SETTINGS_LABELS, DEFAULT_PIN_LABELS, DEFAULT_PREFERRED_METHOD_HINT_LABELS, DEFAULT_PREFERRED_METHOD_SETTINGS_LABELS, DEFAULT_REGISTER_LABELS, DEFAULT_RESET_PASSWORD_LABELS, DEVICE_PIN_ALLOWED_DIGITS, DEVICE_PIN_DEFAULT_DIGITS, DemoCredentialsHint, type DemoCredentialsHintLabels, type DemoCredentialsHintProps, DemoCredentialsHintVariant, type DemoCredentialsHintWiring, type DemoCredentialsLoginFormProps, type DevicePinCapableClient, type DevicePinDisableCapableClient, type DevicePinEnrollCapableClient, DevicePinEnrollErrorKey, DevicePinEnrollForm, type DevicePinEnrollFormProps, type DevicePinEnrollLabels, type DevicePinEnrollResult, DevicePinErrorKey, DevicePinInput, type DevicePinInputProps, DevicePinLengthPicker, type DevicePinLengthPickerProps, DevicePinOffer, type DevicePinOfferProps, DevicePinSettingsCard, type DevicePinSettingsCardProps, type DevicePinSettingsLabels, type DevicePinUnlockCapableClient, type DevicePinUnlockLabels, type DevicePinUnlockResult, DevicePinUnlockScreen, type DevicePinUnlockScreenProps, type DevicePinUnlockedUser, ForgotPasswordFields, type ForgotPasswordFieldsLabels, type ForgotPasswordFieldsProps, ForgotPasswordForm, type ForgotPasswordFormLabels, type ForgotPasswordFormProps, type LoginConfigCapableClient, LoginForm, type LoginFormLabels, type LoginFormProps, OtpForm, type OtpFormLabels, type OtpFormProps, OtpLoginStep, PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, PasskeyCeremonyMode, PasskeyCeremonyStatus, type PasskeyErrorCode, PasskeyLoginButton, type PasskeyLoginButtonProps, type PasskeyLoginLabels, PasskeySettingsCard, type PasskeySettingsCardProps, type PasskeySettingsLabels, PasswordPolicyError, type PerformBffLogoutOptions, PinForm, type PinFormLabels, type PinFormProps, type PreferencesClientOptions, type PreferredMethodClient, PreferredMethodHint, type PreferredMethodHintLabels, type PreferredMethodHintProps, PreferredMethodSettingsCard, type PreferredMethodSettingsCardProps, type PreferredMethodSettingsLabels, PrefillIntent, RegisterErrorCode, type RegisterField, type RegisterFieldLabels, RegisterForm, type RegisterFormLabels, type RegisterFormProps, type RegisterFormValues, type RegisterInputField, type RegisterPasswordPolicy, type RegisterSubmitOutcome, type RegisterSubmitValues, RegisterTestIds, ResetPasswordError, ResetPasswordForm, type ResetPasswordFormLabels, type ResetPasswordFormProps, type RoleRoute, type RoleRouteTable, type UseBffAuthOptions, type UseBffAuthResult, type UseBffForgotPasswordOptions, type UseBffLoginConfigResult, type UseBffResetPasswordOptions, type UseChangePasswordArgs, type UseChangePasswordResult, type UseDemoCredentialsOptions, type UseDemoCredentialsResult, type UseDevicePinDisableArgs, type UseDevicePinDisableResult, type UseDevicePinEnrollArgs, type UseDevicePinEnrollResult, type UseDevicePinUnlockArgs, type UseDevicePinUnlockResult, type UseForgotPasswordSubmitArgs, type UseForgotPasswordSubmitResult, type UseOtpLoginOptions, type UseOtpLoginResult, type UsePasskeyCeremonyOptions, type UsePasskeyCeremonyResult, type UsePinLoginOptions, type UsePinLoginResult, type UsePreferredMethodSettingArgs, type UsePreferredMethodSettingResult, type UseRegisterFormArgs, type UseRegisterFormResult, type UseResetPasswordFormArgs, type UseResetPasswordFormResult, cachePreferredMethod, clearCachedPreferredMethod, collectUserRoles, createBffAuthClient, createBffChangePasswordClient, createPreferencesClient, defaultAuthTheme, isAllowedPinDigits, isPasswordValid, isRegisterPasswordStrong, isValidForgotPasswordEmail, mapRegisterErrorCode, performBffLogout, readCachedPreferredMethod, readPasskeyError, readPasskeyRegistered, resolveAccessibleRoutes, resolveAccountList, resolveDemoAccounts, resolveDemoCredentials, resolvePostLoginRoute, startPasskeyLogin, startPasskeyRegistration, syncPreferredMethodFromServer, useAuthTheme, useBffAuth, useBffForgotPassword, useBffLoginConfig, useBffResetPassword, useChangePassword, useDemoCredentials, useDevicePinDisable, useDevicePinEnroll, useDevicePinUnlock, useForgotPasswordSubmit, useOtpLogin, usePasskeyCeremony, usePinLogin, usePreferredMethodSetting, useRegisterForm, useResetPasswordForm, validatePasswordPolicy, withTestIdPrefix };
2827
+ export { type AccountSettingsChangePasswordConfig, type AccountSettingsDevicePinConfig, type AccountSettingsLabels, type AccountSettingsPasskeysConfig, type AccountSettingsPreferredMethodConfig, AccountSettingsScreen, type AccountSettingsScreenProps, AuthScreen, type AuthScreenProps, AuthTestIds, type AuthTheme, type AuthThemeColors, AuthThemeProvider, type AuthThemeProviderProps, type AuthThemeRadii, type AuthThemeSpacing, type AuthThemeTypography, BffAuthStatus, type BffDeviceState, type BffLoginConfig, type BffLogoutClient, CHANGE_PASSWORD_ENDPOINT, type ChangePasswordCapableClient, ChangePasswordCard, type ChangePasswordCardProps, ChangePasswordErrorKey, type ChangePasswordRequest, type ChangePasswordResult, type CreateBffAuthClientOptions, type CreateBffChangePasswordClientOptions, DEFAULT_ACCOUNT_SETTINGS_LABELS, DEFAULT_AUTH_CARD_MAX_WIDTH, DEFAULT_DEMO_CREDENTIALS_HINT_LABELS, DEFAULT_DEVICE_PIN_ENROLL_LABELS, DEFAULT_DEVICE_PIN_SETTINGS_LABELS, DEFAULT_DEVICE_PIN_UNLOCK_LABELS, DEFAULT_FORGOT_PASSWORD_FIELDS_LABELS, DEFAULT_FORGOT_PASSWORD_LABELS, DEFAULT_LOGIN_LABELS, DEFAULT_OTP_LABELS, DEFAULT_PASSKEY_LOGIN_LABELS, DEFAULT_PASSKEY_SETTINGS_LABELS, DEFAULT_PIN_LABELS, DEFAULT_PREFERRED_METHOD_HINT_LABELS, DEFAULT_PREFERRED_METHOD_SETTINGS_LABELS, DEFAULT_REGISTER_LABELS, DEFAULT_RESET_PASSWORD_LABELS, DEVICE_PIN_ALLOWED_DIGITS, DEVICE_PIN_DEFAULT_DIGITS, DemoCredentialsHint, type DemoCredentialsHintLabels, type DemoCredentialsHintProps, DemoCredentialsHintVariant, type DemoCredentialsHintWiring, type DemoCredentialsLoginFormProps, type DevicePinCapableClient, type DevicePinDisableCapableClient, type DevicePinEnrollCapableClient, DevicePinEnrollErrorKey, DevicePinEnrollForm, type DevicePinEnrollFormProps, type DevicePinEnrollLabels, type DevicePinEnrollResult, DevicePinErrorKey, DevicePinInput, type DevicePinInputProps, DevicePinLengthPicker, type DevicePinLengthPickerProps, DevicePinOffer, type DevicePinOfferProps, DevicePinSettingsCard, type DevicePinSettingsCardProps, type DevicePinSettingsLabels, type DevicePinUnlockCapableClient, type DevicePinUnlockLabels, type DevicePinUnlockResult, DevicePinUnlockScreen, type DevicePinUnlockScreenProps, type DevicePinUnlockedUser, ForgotPasswordFields, type ForgotPasswordFieldsLabels, type ForgotPasswordFieldsProps, ForgotPasswordForm, type ForgotPasswordFormLabels, type ForgotPasswordFormProps, type LoginConfigCapableClient, LoginForm, type LoginFormLabels, type LoginFormProps, OtpForm, type OtpFormLabels, type OtpFormProps, OtpLoginStep, PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, PasskeyCeremonyMode, PasskeyCeremonyStatus, type PasskeyErrorCode, PasskeyLoginButton, type PasskeyLoginButtonProps, type PasskeyLoginLabels, PasskeySettingsCard, type PasskeySettingsCardProps, type PasskeySettingsLabels, PasswordPolicyError, type PerformBffLogoutOptions, PinForm, type PinFormLabels, type PinFormProps, type PreferencesClientOptions, type PreferredMethodClient, PreferredMethodHint, type PreferredMethodHintLabels, type PreferredMethodHintProps, PreferredMethodSettingsCard, type PreferredMethodSettingsCardProps, type PreferredMethodSettingsLabels, PrefillIntent, RegisterErrorCode, type RegisterField, type RegisterFieldLabels, RegisterForm, type RegisterFormLabels, type RegisterFormProps, type RegisterFormValues, type RegisterInputField, type RegisterPasswordPolicy, type RegisterSubmitOutcome, type RegisterSubmitValues, RegisterTestIds, ResetPasswordError, ResetPasswordForm, type ResetPasswordFormLabels, type ResetPasswordFormProps, type RoleRoute, type RoleRouteTable, type UseBffAuthOptions, type UseBffAuthResult, type UseBffForgotPasswordOptions, type UseBffLoginConfigResult, type UseBffResetPasswordOptions, type UseChangePasswordArgs, type UseChangePasswordResult, type UseDemoCredentialsOptions, type UseDemoCredentialsResult, type UseDevicePinDisableArgs, type UseDevicePinDisableResult, type UseDevicePinEnrollArgs, type UseDevicePinEnrollResult, type UseDevicePinUnlockArgs, type UseDevicePinUnlockResult, type UseForgotPasswordSubmitArgs, type UseForgotPasswordSubmitResult, type UseOtpLoginOptions, type UseOtpLoginResult, type UsePasskeyCeremonyOptions, type UsePasskeyCeremonyResult, type UsePinLoginOptions, type UsePinLoginResult, type UsePreferredMethodSettingArgs, type UsePreferredMethodSettingResult, type UseRegisterFormArgs, type UseRegisterFormResult, type UseResetPasswordFormArgs, type UseResetPasswordFormResult, cachePreferredMethod, clearCachedPreferredMethod, collectUserRoles, createBffAuthClient, createBffChangePasswordClient, createPreferencesClient, defaultAuthTheme, isAllowedPinDigits, isPasswordValid, isRegisterPasswordStrong, isValidForgotPasswordEmail, performBffLogout, readCachedPreferredMethod, readPasskeyError, readPasskeyRegistered, resolveAccessibleRoutes, resolveAccountList, resolveDemoAccounts, resolveDemoCredentials, resolvePostLoginRoute, startPasskeyLogin, startPasskeyRegistration, syncPreferredMethodFromServer, useAuthTheme, useBffAuth, useBffForgotPassword, useBffLoginConfig, useBffResetPassword, useChangePassword, useDemoCredentials, useDevicePinDisable, useDevicePinEnroll, useDevicePinUnlock, useForgotPasswordSubmit, useOtpLogin, usePasskeyCeremony, usePinLogin, usePreferredMethodSetting, useRegisterForm, useResetPasswordForm, validatePasswordPolicy, withTestIdPrefix };
package/dist/index.d.ts CHANGED
@@ -2460,7 +2460,7 @@ interface RegisterFormProps<TResult> {
2460
2460
  onSuccess: (result: TResult) => void;
2461
2461
  /** Called with the failure code; map it to localised copy. */
2462
2462
  onError?: (error: RegisterErrorCode) => void;
2463
- /** Called on every submit press, before validation (e.g. a "signup started" event). */
2463
+ /** Called once per accepted submit, before validation (e.g. a "signup started" event); never for a press ignored in flight. */
2464
2464
  onSubmitAttempt?: () => void;
2465
2465
  /** Password rule. Defaults to `isRegisterPasswordStrong`. */
2466
2466
  passwordPolicy?: RegisterPasswordPolicy;
@@ -2506,6 +2506,11 @@ interface UseRegisterFormArgs<TResult> {
2506
2506
  onSubmit: (values: RegisterSubmitValues) => Promise<TResult>;
2507
2507
  /** Password rule. Defaults to {@link isRegisterPasswordStrong}. */
2508
2508
  passwordPolicy?: RegisterPasswordPolicy;
2509
+ /**
2510
+ * Called once per ACCEPTED submit, before validation (e.g. a "signup started"
2511
+ * event). A press ignored because a submit is already in flight does not call it.
2512
+ */
2513
+ onSubmitAttempt?: () => void;
2509
2514
  }
2510
2515
  interface UseRegisterFormResult<TResult> {
2511
2516
  state: RegisterFormValues;
@@ -2516,7 +2521,7 @@ interface UseRegisterFormResult<TResult> {
2516
2521
  error: RegisterErrorCode | null;
2517
2522
  }
2518
2523
  /** Headless registration form logic. */
2519
- declare function useRegisterForm<TResult>({ onSubmit, passwordPolicy, }: UseRegisterFormArgs<TResult>): UseRegisterFormResult<TResult>;
2524
+ declare function useRegisterForm<TResult>({ onSubmit, passwordPolicy, onSubmitAttempt, }: UseRegisterFormArgs<TResult>): UseRegisterFormResult<TResult>;
2520
2525
 
2521
2526
  /**
2522
2527
  * Pure registration helpers: trimming, client-side validation and decoding of a
@@ -2529,8 +2534,6 @@ declare function useRegisterForm<TResult>({ onSubmit, passwordPolicy, }: UseRegi
2529
2534
 
2530
2535
  /** The default password rule: 8+ characters with a letter, a digit and a special character. */
2531
2536
  declare function isRegisterPasswordStrong(password: string): boolean;
2532
- /** Decode a thrown registration failure into a {@link RegisterErrorCode}. */
2533
- declare function mapRegisterErrorCode(error: unknown): RegisterErrorCode;
2534
2537
 
2535
2538
  /**
2536
2539
  * `createBffAuthClient` — the one-line wiring of a same-origin `BffAuthClient`.
@@ -2821,4 +2824,4 @@ interface UseChangePasswordResult {
2821
2824
  }
2822
2825
  declare function useChangePassword({ client, onChanged, }: UseChangePasswordArgs): UseChangePasswordResult;
2823
2826
 
2824
- export { type AccountSettingsChangePasswordConfig, type AccountSettingsDevicePinConfig, type AccountSettingsLabels, type AccountSettingsPasskeysConfig, type AccountSettingsPreferredMethodConfig, AccountSettingsScreen, type AccountSettingsScreenProps, AuthScreen, type AuthScreenProps, AuthTestIds, type AuthTheme, type AuthThemeColors, AuthThemeProvider, type AuthThemeProviderProps, type AuthThemeRadii, type AuthThemeSpacing, type AuthThemeTypography, BffAuthStatus, type BffDeviceState, type BffLoginConfig, type BffLogoutClient, CHANGE_PASSWORD_ENDPOINT, type ChangePasswordCapableClient, ChangePasswordCard, type ChangePasswordCardProps, ChangePasswordErrorKey, type ChangePasswordRequest, type ChangePasswordResult, type CreateBffAuthClientOptions, type CreateBffChangePasswordClientOptions, DEFAULT_ACCOUNT_SETTINGS_LABELS, DEFAULT_AUTH_CARD_MAX_WIDTH, DEFAULT_DEMO_CREDENTIALS_HINT_LABELS, DEFAULT_DEVICE_PIN_ENROLL_LABELS, DEFAULT_DEVICE_PIN_SETTINGS_LABELS, DEFAULT_DEVICE_PIN_UNLOCK_LABELS, DEFAULT_FORGOT_PASSWORD_FIELDS_LABELS, DEFAULT_FORGOT_PASSWORD_LABELS, DEFAULT_LOGIN_LABELS, DEFAULT_OTP_LABELS, DEFAULT_PASSKEY_LOGIN_LABELS, DEFAULT_PASSKEY_SETTINGS_LABELS, DEFAULT_PIN_LABELS, DEFAULT_PREFERRED_METHOD_HINT_LABELS, DEFAULT_PREFERRED_METHOD_SETTINGS_LABELS, DEFAULT_REGISTER_LABELS, DEFAULT_RESET_PASSWORD_LABELS, DEVICE_PIN_ALLOWED_DIGITS, DEVICE_PIN_DEFAULT_DIGITS, DemoCredentialsHint, type DemoCredentialsHintLabels, type DemoCredentialsHintProps, DemoCredentialsHintVariant, type DemoCredentialsHintWiring, type DemoCredentialsLoginFormProps, type DevicePinCapableClient, type DevicePinDisableCapableClient, type DevicePinEnrollCapableClient, DevicePinEnrollErrorKey, DevicePinEnrollForm, type DevicePinEnrollFormProps, type DevicePinEnrollLabels, type DevicePinEnrollResult, DevicePinErrorKey, DevicePinInput, type DevicePinInputProps, DevicePinLengthPicker, type DevicePinLengthPickerProps, DevicePinOffer, type DevicePinOfferProps, DevicePinSettingsCard, type DevicePinSettingsCardProps, type DevicePinSettingsLabels, type DevicePinUnlockCapableClient, type DevicePinUnlockLabels, type DevicePinUnlockResult, DevicePinUnlockScreen, type DevicePinUnlockScreenProps, type DevicePinUnlockedUser, ForgotPasswordFields, type ForgotPasswordFieldsLabels, type ForgotPasswordFieldsProps, ForgotPasswordForm, type ForgotPasswordFormLabels, type ForgotPasswordFormProps, type LoginConfigCapableClient, LoginForm, type LoginFormLabels, type LoginFormProps, OtpForm, type OtpFormLabels, type OtpFormProps, OtpLoginStep, PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, PasskeyCeremonyMode, PasskeyCeremonyStatus, type PasskeyErrorCode, PasskeyLoginButton, type PasskeyLoginButtonProps, type PasskeyLoginLabels, PasskeySettingsCard, type PasskeySettingsCardProps, type PasskeySettingsLabels, PasswordPolicyError, type PerformBffLogoutOptions, PinForm, type PinFormLabels, type PinFormProps, type PreferencesClientOptions, type PreferredMethodClient, PreferredMethodHint, type PreferredMethodHintLabels, type PreferredMethodHintProps, PreferredMethodSettingsCard, type PreferredMethodSettingsCardProps, type PreferredMethodSettingsLabels, PrefillIntent, RegisterErrorCode, type RegisterField, type RegisterFieldLabels, RegisterForm, type RegisterFormLabels, type RegisterFormProps, type RegisterFormValues, type RegisterInputField, type RegisterPasswordPolicy, type RegisterSubmitOutcome, type RegisterSubmitValues, RegisterTestIds, ResetPasswordError, ResetPasswordForm, type ResetPasswordFormLabels, type ResetPasswordFormProps, type RoleRoute, type RoleRouteTable, type UseBffAuthOptions, type UseBffAuthResult, type UseBffForgotPasswordOptions, type UseBffLoginConfigResult, type UseBffResetPasswordOptions, type UseChangePasswordArgs, type UseChangePasswordResult, type UseDemoCredentialsOptions, type UseDemoCredentialsResult, type UseDevicePinDisableArgs, type UseDevicePinDisableResult, type UseDevicePinEnrollArgs, type UseDevicePinEnrollResult, type UseDevicePinUnlockArgs, type UseDevicePinUnlockResult, type UseForgotPasswordSubmitArgs, type UseForgotPasswordSubmitResult, type UseOtpLoginOptions, type UseOtpLoginResult, type UsePasskeyCeremonyOptions, type UsePasskeyCeremonyResult, type UsePinLoginOptions, type UsePinLoginResult, type UsePreferredMethodSettingArgs, type UsePreferredMethodSettingResult, type UseRegisterFormArgs, type UseRegisterFormResult, type UseResetPasswordFormArgs, type UseResetPasswordFormResult, cachePreferredMethod, clearCachedPreferredMethod, collectUserRoles, createBffAuthClient, createBffChangePasswordClient, createPreferencesClient, defaultAuthTheme, isAllowedPinDigits, isPasswordValid, isRegisterPasswordStrong, isValidForgotPasswordEmail, mapRegisterErrorCode, performBffLogout, readCachedPreferredMethod, readPasskeyError, readPasskeyRegistered, resolveAccessibleRoutes, resolveAccountList, resolveDemoAccounts, resolveDemoCredentials, resolvePostLoginRoute, startPasskeyLogin, startPasskeyRegistration, syncPreferredMethodFromServer, useAuthTheme, useBffAuth, useBffForgotPassword, useBffLoginConfig, useBffResetPassword, useChangePassword, useDemoCredentials, useDevicePinDisable, useDevicePinEnroll, useDevicePinUnlock, useForgotPasswordSubmit, useOtpLogin, usePasskeyCeremony, usePinLogin, usePreferredMethodSetting, useRegisterForm, useResetPasswordForm, validatePasswordPolicy, withTestIdPrefix };
2827
+ export { type AccountSettingsChangePasswordConfig, type AccountSettingsDevicePinConfig, type AccountSettingsLabels, type AccountSettingsPasskeysConfig, type AccountSettingsPreferredMethodConfig, AccountSettingsScreen, type AccountSettingsScreenProps, AuthScreen, type AuthScreenProps, AuthTestIds, type AuthTheme, type AuthThemeColors, AuthThemeProvider, type AuthThemeProviderProps, type AuthThemeRadii, type AuthThemeSpacing, type AuthThemeTypography, BffAuthStatus, type BffDeviceState, type BffLoginConfig, type BffLogoutClient, CHANGE_PASSWORD_ENDPOINT, type ChangePasswordCapableClient, ChangePasswordCard, type ChangePasswordCardProps, ChangePasswordErrorKey, type ChangePasswordRequest, type ChangePasswordResult, type CreateBffAuthClientOptions, type CreateBffChangePasswordClientOptions, DEFAULT_ACCOUNT_SETTINGS_LABELS, DEFAULT_AUTH_CARD_MAX_WIDTH, DEFAULT_DEMO_CREDENTIALS_HINT_LABELS, DEFAULT_DEVICE_PIN_ENROLL_LABELS, DEFAULT_DEVICE_PIN_SETTINGS_LABELS, DEFAULT_DEVICE_PIN_UNLOCK_LABELS, DEFAULT_FORGOT_PASSWORD_FIELDS_LABELS, DEFAULT_FORGOT_PASSWORD_LABELS, DEFAULT_LOGIN_LABELS, DEFAULT_OTP_LABELS, DEFAULT_PASSKEY_LOGIN_LABELS, DEFAULT_PASSKEY_SETTINGS_LABELS, DEFAULT_PIN_LABELS, DEFAULT_PREFERRED_METHOD_HINT_LABELS, DEFAULT_PREFERRED_METHOD_SETTINGS_LABELS, DEFAULT_REGISTER_LABELS, DEFAULT_RESET_PASSWORD_LABELS, DEVICE_PIN_ALLOWED_DIGITS, DEVICE_PIN_DEFAULT_DIGITS, DemoCredentialsHint, type DemoCredentialsHintLabels, type DemoCredentialsHintProps, DemoCredentialsHintVariant, type DemoCredentialsHintWiring, type DemoCredentialsLoginFormProps, type DevicePinCapableClient, type DevicePinDisableCapableClient, type DevicePinEnrollCapableClient, DevicePinEnrollErrorKey, DevicePinEnrollForm, type DevicePinEnrollFormProps, type DevicePinEnrollLabels, type DevicePinEnrollResult, DevicePinErrorKey, DevicePinInput, type DevicePinInputProps, DevicePinLengthPicker, type DevicePinLengthPickerProps, DevicePinOffer, type DevicePinOfferProps, DevicePinSettingsCard, type DevicePinSettingsCardProps, type DevicePinSettingsLabels, type DevicePinUnlockCapableClient, type DevicePinUnlockLabels, type DevicePinUnlockResult, DevicePinUnlockScreen, type DevicePinUnlockScreenProps, type DevicePinUnlockedUser, ForgotPasswordFields, type ForgotPasswordFieldsLabels, type ForgotPasswordFieldsProps, ForgotPasswordForm, type ForgotPasswordFormLabels, type ForgotPasswordFormProps, type LoginConfigCapableClient, LoginForm, type LoginFormLabels, type LoginFormProps, OtpForm, type OtpFormLabels, type OtpFormProps, OtpLoginStep, PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, PasskeyCeremonyMode, PasskeyCeremonyStatus, type PasskeyErrorCode, PasskeyLoginButton, type PasskeyLoginButtonProps, type PasskeyLoginLabels, PasskeySettingsCard, type PasskeySettingsCardProps, type PasskeySettingsLabels, PasswordPolicyError, type PerformBffLogoutOptions, PinForm, type PinFormLabels, type PinFormProps, type PreferencesClientOptions, type PreferredMethodClient, PreferredMethodHint, type PreferredMethodHintLabels, type PreferredMethodHintProps, PreferredMethodSettingsCard, type PreferredMethodSettingsCardProps, type PreferredMethodSettingsLabels, PrefillIntent, RegisterErrorCode, type RegisterField, type RegisterFieldLabels, RegisterForm, type RegisterFormLabels, type RegisterFormProps, type RegisterFormValues, type RegisterInputField, type RegisterPasswordPolicy, type RegisterSubmitOutcome, type RegisterSubmitValues, RegisterTestIds, ResetPasswordError, ResetPasswordForm, type ResetPasswordFormLabels, type ResetPasswordFormProps, type RoleRoute, type RoleRouteTable, type UseBffAuthOptions, type UseBffAuthResult, type UseBffForgotPasswordOptions, type UseBffLoginConfigResult, type UseBffResetPasswordOptions, type UseChangePasswordArgs, type UseChangePasswordResult, type UseDemoCredentialsOptions, type UseDemoCredentialsResult, type UseDevicePinDisableArgs, type UseDevicePinDisableResult, type UseDevicePinEnrollArgs, type UseDevicePinEnrollResult, type UseDevicePinUnlockArgs, type UseDevicePinUnlockResult, type UseForgotPasswordSubmitArgs, type UseForgotPasswordSubmitResult, type UseOtpLoginOptions, type UseOtpLoginResult, type UsePasskeyCeremonyOptions, type UsePasskeyCeremonyResult, type UsePinLoginOptions, type UsePinLoginResult, type UsePreferredMethodSettingArgs, type UsePreferredMethodSettingResult, type UseRegisterFormArgs, type UseRegisterFormResult, type UseResetPasswordFormArgs, type UseResetPasswordFormResult, cachePreferredMethod, clearCachedPreferredMethod, collectUserRoles, createBffAuthClient, createBffChangePasswordClient, createPreferencesClient, defaultAuthTheme, isAllowedPinDigits, isPasswordValid, isRegisterPasswordStrong, isValidForgotPasswordEmail, performBffLogout, readCachedPreferredMethod, readPasskeyError, readPasskeyRegistered, resolveAccessibleRoutes, resolveAccountList, resolveDemoAccounts, resolveDemoCredentials, resolvePostLoginRoute, startPasskeyLogin, startPasskeyRegistration, syncPreferredMethodFromServer, useAuthTheme, useBffAuth, useBffForgotPassword, useBffLoginConfig, useBffResetPassword, useChangePassword, useDemoCredentials, useDevicePinDisable, useDevicePinEnroll, useDevicePinUnlock, useForgotPasswordSubmit, useOtpLogin, usePasskeyCeremony, usePinLogin, usePreferredMethodSetting, useRegisterForm, useResetPasswordForm, validatePasswordPolicy, withTestIdPrefix };
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  var reactNative = require('react-native');
4
4
  var react = require('react');
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
+ var uiButtons = require('@dloizides/ui-buttons');
6
7
  var reactQuery = require('@tanstack/react-query');
7
8
  var authClient = require('@dloizides/auth-client');
8
9
 
@@ -637,6 +638,21 @@ function useLoginSubmit({
637
638
  }, [runLogin]);
638
639
  return { errorText, handleSubmit };
639
640
  }
641
+ function isKeyRepeat(event) {
642
+ const native = event?.nativeEvent;
643
+ return native?.repeat === true;
644
+ }
645
+ function useSubmitOnEnter(submit) {
646
+ return react.useCallback(
647
+ (event) => {
648
+ if (isKeyRepeat(event)) {
649
+ return;
650
+ }
651
+ submit();
652
+ },
653
+ [submit]
654
+ );
655
+ }
640
656
  var BffAuthStatus = /* @__PURE__ */ ((BffAuthStatus2) => {
641
657
  BffAuthStatus2["Loading"] = "loading";
642
658
  BffAuthStatus2["Authenticated"] = "authenticated";
@@ -775,7 +791,7 @@ function LoginForm({
775
791
  missingFieldsLabel: labels.missingFields,
776
792
  invalidCredentialsLabel: labels.invalidCredentials
777
793
  });
778
- const submitButtonStyle = isSubmitting ? [styles3.primaryButton, styles3.primaryButtonDisabled] : styles3.primaryButton;
794
+ const handleSubmitEditing = useSubmitOnEnter(handleSubmit);
779
795
  const content = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
780
796
  /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.title, children: labels.title }),
781
797
  /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.subtitle, children: labels.subtitle }),
@@ -791,10 +807,12 @@ function LoginForm({
791
807
  editable: !isSubmitting,
792
808
  placeholder: labels.usernamePlaceholder,
793
809
  placeholderTextColor: theme.colors.textSecondary,
810
+ returnKeyType: "go",
794
811
  style: styles3.input,
795
812
  testID: withTestIdPrefix(AuthTestIds.loginUsernameInput, testIdPrefix),
796
813
  value: username,
797
- onChangeText: setUsername
814
+ onChangeText: setUsername,
815
+ onSubmitEditing: handleSubmitEditing
798
816
  }
799
817
  )
800
818
  ] }),
@@ -811,10 +829,12 @@ function LoginForm({
811
829
  editable: !isSubmitting,
812
830
  placeholder: labels.passwordPlaceholder,
813
831
  placeholderTextColor: theme.colors.textSecondary,
832
+ returnKeyType: "go",
814
833
  style: styles3.input,
815
834
  testID: withTestIdPrefix(AuthTestIds.loginPasswordInput, testIdPrefix),
816
835
  value: password,
817
- onChangeText: setPassword
836
+ onChangeText: setPassword,
837
+ onSubmitEditing: handleSubmitEditing
818
838
  }
819
839
  )
820
840
  ] }),
@@ -839,19 +859,18 @@ function LoginForm({
839
859
  children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.linkText, children: labels.forgotPassword })
840
860
  }
841
861
  ) : null,
842
- /* @__PURE__ */ jsxRuntime.jsx(
843
- reactNative.TouchableOpacity,
862
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles3.fieldGroup, children: /* @__PURE__ */ jsxRuntime.jsx(
863
+ uiButtons.Button,
844
864
  {
865
+ fullWidth: true,
845
866
  accessibilityHint: labels.submit,
846
867
  accessibilityLabel: isSubmitting ? labels.submitting : labels.submit,
847
- accessibilityRole: "button",
848
- disabled: isSubmitting,
849
- style: submitButtonStyle,
868
+ label: labels.submit,
869
+ loading: isSubmitting,
850
870
  testID: withTestIdPrefix(AuthTestIds.loginSubmitButton, testIdPrefix),
851
- onPress: handleSubmit,
852
- children: isSubmitting ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.ActivityIndicator, { color: theme.colors.onPrimary, size: "small" }) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.primaryButtonText, children: labels.submit })
871
+ onPress: handleSubmit
853
872
  }
854
- ),
873
+ ) }),
855
874
  onSignUp !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(
856
875
  reactNative.TouchableOpacity,
857
876
  {
@@ -4095,6 +4114,7 @@ function RegisterFormFields({
4095
4114
  theme,
4096
4115
  styles: styles3,
4097
4116
  onChange,
4117
+ onSubmitEditing,
4098
4118
  testIdPrefix
4099
4119
  }) {
4100
4120
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -4114,11 +4134,13 @@ function RegisterFormFields({
4114
4134
  keyboardType: config.keyboardType ?? "default",
4115
4135
  placeholder: copy.placeholder,
4116
4136
  placeholderTextColor: theme.colors.textSecondary,
4137
+ returnKeyType: "go",
4117
4138
  secureTextEntry: config.secure === true,
4118
4139
  style: styles3.input,
4119
4140
  testID: withTestIdPrefix(config.testId, testIdPrefix),
4120
4141
  value: values[config.key],
4121
- onChangeText: (text) => onChange(config.key, text)
4142
+ onChangeText: (text) => onChange(config.key, text),
4143
+ onSubmitEditing
4122
4144
  }
4123
4145
  )
4124
4146
  ] }, config.key);
@@ -4127,6 +4149,7 @@ function RegisterFormFields({
4127
4149
  reactNative.TextInput,
4128
4150
  {
4129
4151
  accessibilityElementsHidden: true,
4152
+ accessibilityRole: "none",
4130
4153
  autoComplete: "off",
4131
4154
  focusable: false,
4132
4155
  importantForAccessibility: "no-hide-descendants",
@@ -4155,9 +4178,21 @@ var RegisterErrorCode = /* @__PURE__ */ ((RegisterErrorCode2) => {
4155
4178
  return RegisterErrorCode2;
4156
4179
  })(RegisterErrorCode || {});
4157
4180
 
4181
+ // src/hooks/routeRegisterOutcome.ts
4182
+ function routeRegisterOutcome(outcome, handlers) {
4183
+ if (outcome.ok) {
4184
+ handlers.onSuccess(outcome.result);
4185
+ return;
4186
+ }
4187
+ if (outcome.error !== "inFlight" /* InFlight */) {
4188
+ handlers.onError?.(outcome.error);
4189
+ }
4190
+ }
4191
+
4158
4192
  // src/hooks/registerErrors.ts
4159
4193
  var MIN_PASSWORD_LENGTH = 8;
4160
- var EMAIL_REGEX4 = /^[^@\s]+@[^.\s]+\.\S+$/;
4194
+ var WHITESPACE_REGEX = /\s/;
4195
+ var EMAIL_PART_COUNT = 2;
4161
4196
  var PASSWORD_LETTER_REGEX = /[a-zA-Z]/;
4162
4197
  var PASSWORD_DIGIT_REGEX = /\d/;
4163
4198
  var PASSWORD_SPECIAL_REGEX = /[^a-zA-Z0-9]/;
@@ -4179,6 +4214,17 @@ function isRegisterPasswordStrong(password) {
4179
4214
  }
4180
4215
  return PASSWORD_SPECIAL_REGEX.test(password);
4181
4216
  }
4217
+ function isEmailShaped(email) {
4218
+ if (WHITESPACE_REGEX.test(email)) {
4219
+ return false;
4220
+ }
4221
+ const parts = email.split("@");
4222
+ if (parts.length !== EMAIL_PART_COUNT) {
4223
+ return false;
4224
+ }
4225
+ const [local = "", domain = ""] = parts;
4226
+ return local !== "" && domain.slice(1, -1).includes(".");
4227
+ }
4182
4228
  function trimRegisterValues(values) {
4183
4229
  return {
4184
4230
  firstName: values.firstName.trim(),
@@ -4206,7 +4252,7 @@ function validateRegisterValues(values, passwordPolicy) {
4206
4252
  if (hasMissingRequiredField(values)) {
4207
4253
  return "missingFields" /* MissingFields */;
4208
4254
  }
4209
- if (!EMAIL_REGEX4.test(values.email)) {
4255
+ if (!isEmailShaped(values.email)) {
4210
4256
  return "invalidEmail" /* InvalidEmail */;
4211
4257
  }
4212
4258
  if (!passwordPolicy(values.password)) {
@@ -4256,7 +4302,8 @@ function toSubmitValues(values) {
4256
4302
  }
4257
4303
  function useRegisterForm({
4258
4304
  onSubmit,
4259
- passwordPolicy = isRegisterPasswordStrong
4305
+ passwordPolicy = isRegisterPasswordStrong,
4306
+ onSubmitAttempt
4260
4307
  }) {
4261
4308
  const [state, setState] = react.useState(EMPTY_VALUES);
4262
4309
  const [isSubmitting, setIsSubmitting] = react.useState(false);
@@ -4269,6 +4316,7 @@ function useRegisterForm({
4269
4316
  if (inFlight.current) {
4270
4317
  return { ok: false, error: "inFlight" /* InFlight */ };
4271
4318
  }
4319
+ onSubmitAttempt?.();
4272
4320
  const trimmed = trimRegisterValues(state);
4273
4321
  const refusal = trimmed.website === "" ? validateRegisterValues(trimmed, passwordPolicy) : "failed" /* Failed */;
4274
4322
  if (refusal !== null) {
@@ -4289,7 +4337,7 @@ function useRegisterForm({
4289
4337
  inFlight.current = false;
4290
4338
  setIsSubmitting(false);
4291
4339
  }
4292
- }, [onSubmit, passwordPolicy, state]);
4340
+ }, [onSubmit, onSubmitAttempt, passwordPolicy, state]);
4293
4341
  return { state, setField, submit, isSubmitting, error };
4294
4342
  }
4295
4343
  function RegisterForm({
@@ -4309,18 +4357,15 @@ function RegisterForm({
4309
4357
  () => ({ ...DEFAULT_REGISTER_LABELS, ...labelsProp }),
4310
4358
  [labelsProp]
4311
4359
  );
4312
- const { state, setField, submit, isSubmitting } = useRegisterForm({ onSubmit, passwordPolicy });
4313
- const handlePress = react.useCallback(() => {
4314
- onSubmitAttempt?.();
4315
- void submit().then((outcome) => {
4316
- if (outcome.ok) {
4317
- onSuccess(outcome.result);
4318
- } else if (outcome.error !== "inFlight" /* InFlight */) {
4319
- onError?.(outcome.error);
4320
- }
4321
- });
4322
- }, [onError, onSubmitAttempt, onSuccess, submit]);
4323
- const buttonStyle = isSubmitting ? [styles3.primaryButton, styles3.primaryButtonDisabled] : styles3.primaryButton;
4360
+ const { state, setField, submit, isSubmitting } = useRegisterForm({
4361
+ onSubmit,
4362
+ onSubmitAttempt,
4363
+ passwordPolicy
4364
+ });
4365
+ const handlePress = react.useCallback(async () => {
4366
+ routeRegisterOutcome(await submit(), { onSuccess, onError });
4367
+ }, [onError, onSuccess, submit]);
4368
+ const handleSubmitEditing = useSubmitOnEnter(handlePress);
4324
4369
  return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles3.screen, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles3.card, testID: withTestIdPrefix(RegisterTestIds.form, testIdPrefix), children: [
4325
4370
  /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.title, children: labels.title }),
4326
4371
  /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.subtitle, children: labels.subtitle }),
@@ -4333,22 +4378,22 @@ function RegisterForm({
4333
4378
  testIdPrefix,
4334
4379
  theme,
4335
4380
  values: state,
4336
- onChange: setField
4381
+ onChange: setField,
4382
+ onSubmitEditing: handleSubmitEditing
4337
4383
  }
4338
4384
  ),
4339
- /* @__PURE__ */ jsxRuntime.jsx(
4340
- reactNative.TouchableOpacity,
4385
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles3.fieldGroup, children: /* @__PURE__ */ jsxRuntime.jsx(
4386
+ uiButtons.Button,
4341
4387
  {
4388
+ fullWidth: true,
4342
4389
  accessibilityHint: labels.submitHint,
4343
4390
  accessibilityLabel: isSubmitting ? labels.submitting : labels.submit,
4344
- accessibilityRole: "button",
4345
- disabled: isSubmitting,
4346
- style: buttonStyle,
4391
+ label: labels.submit,
4392
+ loading: isSubmitting,
4347
4393
  testID: withTestIdPrefix(RegisterTestIds.submitButton, testIdPrefix),
4348
- onPress: handlePress,
4349
- children: isSubmitting ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.ActivityIndicator, { color: theme.colors.onPrimary, size: "small" }) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles3.primaryButtonText, children: labels.submit })
4394
+ onPress: handlePress
4350
4395
  }
4351
- ),
4396
+ ) }),
4352
4397
  footer
4353
4398
  ] }) });
4354
4399
  }
@@ -4565,7 +4610,6 @@ exports.isAllowedPinDigits = isAllowedPinDigits;
4565
4610
  exports.isPasswordValid = isPasswordValid;
4566
4611
  exports.isRegisterPasswordStrong = isRegisterPasswordStrong;
4567
4612
  exports.isValidForgotPasswordEmail = isValidForgotPasswordEmail;
4568
- exports.mapRegisterErrorCode = mapRegisterErrorCode;
4569
4613
  exports.performBffLogout = performBffLogout;
4570
4614
  exports.readCachedPreferredMethod = readCachedPreferredMethod;
4571
4615
  exports.readPasskeyError = readPasskeyError;