@dloizides/auth-web 1.18.2 → 1.19.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/CHANGELOG.md +15 -0
- package/dist/index.d.mts +40 -3
- package/dist/index.d.ts +40 -3
- package/dist/index.js +59 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -341,6 +341,7 @@ var DEFAULT_REGISTER_LABELS = {
|
|
|
341
341
|
submit: "Create account",
|
|
342
342
|
submitHint: "Creates your account",
|
|
343
343
|
submitting: "Creating account...",
|
|
344
|
+
fullName: field("Your name", "Enter your full name"),
|
|
344
345
|
fields: {
|
|
345
346
|
firstName: field("First name", "Enter your first name"),
|
|
346
347
|
lastName: field("Last name", "Enter your last name"),
|
|
@@ -617,7 +618,11 @@ function useLoginSubmit({
|
|
|
617
618
|
invalidCredentialsLabel
|
|
618
619
|
}) {
|
|
619
620
|
const [errorText, setErrorText] = useState(null);
|
|
621
|
+
const inFlight = useRef(false);
|
|
620
622
|
const runLogin = useCallback(async () => {
|
|
623
|
+
if (inFlight.current) {
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
621
626
|
setErrorText(null);
|
|
622
627
|
const trimmedUsername = username.trim();
|
|
623
628
|
const hasMissingField = trimmedUsername.length === 0 || password.length === 0;
|
|
@@ -625,11 +630,14 @@ function useLoginSubmit({
|
|
|
625
630
|
setErrorText(missingFieldsLabel);
|
|
626
631
|
return;
|
|
627
632
|
}
|
|
633
|
+
inFlight.current = true;
|
|
628
634
|
try {
|
|
629
635
|
const user = await login({ username: trimmedUsername, password });
|
|
630
636
|
onSuccess(user);
|
|
631
637
|
} catch {
|
|
632
638
|
setErrorText(invalidCredentialsLabel);
|
|
639
|
+
} finally {
|
|
640
|
+
inFlight.current = false;
|
|
633
641
|
}
|
|
634
642
|
}, [username, password, login, onSuccess, missingFieldsLabel, invalidCredentialsLabel]);
|
|
635
643
|
const handleSubmit = useCallback(() => {
|
|
@@ -4093,6 +4101,18 @@ var FIELDS = [
|
|
|
4093
4101
|
{ key: "confirmPassword", testId: RegisterTestIds.confirmPasswordInput, secure: true },
|
|
4094
4102
|
{ key: "tenantName", testId: RegisterTestIds.tenantNameInput }
|
|
4095
4103
|
];
|
|
4104
|
+
var COMPACT_FIELDS = [
|
|
4105
|
+
{ key: "firstName", testId: RegisterTestIds.firstNameInput, autoComplete: "name" },
|
|
4106
|
+
{ key: "email", testId: RegisterTestIds.emailInput, autoComplete: "email", keyboardType: "email-address" },
|
|
4107
|
+
{ key: "password", testId: RegisterTestIds.passwordInput, secure: true },
|
|
4108
|
+
{ key: "tenantName", testId: RegisterTestIds.tenantNameInput }
|
|
4109
|
+
];
|
|
4110
|
+
function copyFor(key, labels, compact) {
|
|
4111
|
+
if (compact && key === "firstName" && labels.fullName !== void 0) {
|
|
4112
|
+
return labels.fullName;
|
|
4113
|
+
}
|
|
4114
|
+
return labels.fields[key];
|
|
4115
|
+
}
|
|
4096
4116
|
var OFF_SCREEN = -9999;
|
|
4097
4117
|
var HONEYPOT_SIZE = 1;
|
|
4098
4118
|
var HONEYPOT_PLACEHOLDER = "Website";
|
|
@@ -4114,11 +4134,12 @@ function RegisterFormFields({
|
|
|
4114
4134
|
styles: styles3,
|
|
4115
4135
|
onChange,
|
|
4116
4136
|
onSubmitEditing,
|
|
4117
|
-
testIdPrefix
|
|
4137
|
+
testIdPrefix,
|
|
4138
|
+
compact = false
|
|
4118
4139
|
}) {
|
|
4119
4140
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4120
|
-
FIELDS.map((config) => {
|
|
4121
|
-
const copy =
|
|
4141
|
+
(compact ? COMPACT_FIELDS : FIELDS).map((config) => {
|
|
4142
|
+
const copy = copyFor(config.key, labels, compact);
|
|
4122
4143
|
return /* @__PURE__ */ jsxs(View, { style: styles3.fieldGroup, children: [
|
|
4123
4144
|
/* @__PURE__ */ jsx(Text, { style: styles3.label, children: copy.label }),
|
|
4124
4145
|
/* @__PURE__ */ jsx(
|
|
@@ -4277,6 +4298,29 @@ function mapRegisterErrorCode(error) {
|
|
|
4277
4298
|
return match === void 0 ? "validationFailed" /* ValidationFailed */ : match[1];
|
|
4278
4299
|
}
|
|
4279
4300
|
|
|
4301
|
+
// src/hooks/registerCompact.ts
|
|
4302
|
+
var WHITESPACE_RUN = /\s+/;
|
|
4303
|
+
var UNSAFE_USERNAME_CHARS = /[^a-z0-9._-]/g;
|
|
4304
|
+
var USERNAME_REPLACEMENT = "_";
|
|
4305
|
+
function splitFullName(fullName) {
|
|
4306
|
+
const words = fullName.trim().split(WHITESPACE_RUN).filter((word) => word !== "");
|
|
4307
|
+
const [first = "", ...rest] = words;
|
|
4308
|
+
return { firstName: first, lastName: rest.length > 0 ? rest.join(" ") : first };
|
|
4309
|
+
}
|
|
4310
|
+
function deriveUsernameFromEmail(email) {
|
|
4311
|
+
return email.trim().toLowerCase().replace(UNSAFE_USERNAME_CHARS, USERNAME_REPLACEMENT);
|
|
4312
|
+
}
|
|
4313
|
+
function expandCompactRegisterValues(values) {
|
|
4314
|
+
const { firstName, lastName } = splitFullName(values.firstName);
|
|
4315
|
+
return {
|
|
4316
|
+
...values,
|
|
4317
|
+
firstName,
|
|
4318
|
+
lastName,
|
|
4319
|
+
username: deriveUsernameFromEmail(values.email),
|
|
4320
|
+
confirmPassword: values.password
|
|
4321
|
+
};
|
|
4322
|
+
}
|
|
4323
|
+
|
|
4280
4324
|
// src/hooks/useRegisterForm.ts
|
|
4281
4325
|
var EMPTY_VALUES = {
|
|
4282
4326
|
firstName: "",
|
|
@@ -4302,7 +4346,8 @@ function toSubmitValues(values) {
|
|
|
4302
4346
|
function useRegisterForm({
|
|
4303
4347
|
onSubmit,
|
|
4304
4348
|
passwordPolicy = isRegisterPasswordStrong,
|
|
4305
|
-
onSubmitAttempt
|
|
4349
|
+
onSubmitAttempt,
|
|
4350
|
+
compact = false
|
|
4306
4351
|
}) {
|
|
4307
4352
|
const [state, setState] = useState(EMPTY_VALUES);
|
|
4308
4353
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
@@ -4316,7 +4361,8 @@ function useRegisterForm({
|
|
|
4316
4361
|
return { ok: false, error: "inFlight" /* InFlight */ };
|
|
4317
4362
|
}
|
|
4318
4363
|
onSubmitAttempt?.();
|
|
4319
|
-
const
|
|
4364
|
+
const trimmedRaw = trimRegisterValues(state);
|
|
4365
|
+
const trimmed = compact ? expandCompactRegisterValues(trimmedRaw) : trimmedRaw;
|
|
4320
4366
|
const refusal = trimmed.website === "" ? validateRegisterValues(trimmed, passwordPolicy) : "failed" /* Failed */;
|
|
4321
4367
|
if (refusal !== null) {
|
|
4322
4368
|
setError(refusal);
|
|
@@ -4336,7 +4382,7 @@ function useRegisterForm({
|
|
|
4336
4382
|
inFlight.current = false;
|
|
4337
4383
|
setIsSubmitting(false);
|
|
4338
4384
|
}
|
|
4339
|
-
}, [onSubmit, onSubmitAttempt, passwordPolicy, state]);
|
|
4385
|
+
}, [compact, onSubmit, onSubmitAttempt, passwordPolicy, state]);
|
|
4340
4386
|
return { state, setField, submit, isSubmitting, error };
|
|
4341
4387
|
}
|
|
4342
4388
|
function RegisterForm({
|
|
@@ -4348,7 +4394,8 @@ function RegisterForm({
|
|
|
4348
4394
|
labels: labelsProp,
|
|
4349
4395
|
theme: themeProp,
|
|
4350
4396
|
footer,
|
|
4351
|
-
testIdPrefix
|
|
4397
|
+
testIdPrefix,
|
|
4398
|
+
compact = false
|
|
4352
4399
|
}) {
|
|
4353
4400
|
const theme = useAuthTheme(themeProp);
|
|
4354
4401
|
const styles3 = useAuthStyles(theme);
|
|
@@ -4359,7 +4406,8 @@ function RegisterForm({
|
|
|
4359
4406
|
const { state, setField, submit, isSubmitting } = useRegisterForm({
|
|
4360
4407
|
onSubmit,
|
|
4361
4408
|
onSubmitAttempt,
|
|
4362
|
-
passwordPolicy
|
|
4409
|
+
passwordPolicy,
|
|
4410
|
+
compact
|
|
4363
4411
|
});
|
|
4364
4412
|
const handlePress = useCallback(async () => {
|
|
4365
4413
|
routeRegisterOutcome(await submit(), { onSuccess, onError });
|
|
@@ -4371,6 +4419,7 @@ function RegisterForm({
|
|
|
4371
4419
|
/* @__PURE__ */ jsx(
|
|
4372
4420
|
RegisterFormFields,
|
|
4373
4421
|
{
|
|
4422
|
+
compact,
|
|
4374
4423
|
disabled: isSubmitting,
|
|
4375
4424
|
labels,
|
|
4376
4425
|
styles: styles3,
|
|
@@ -4532,6 +4581,6 @@ function createBffChangePasswordClient(options = {}) {
|
|
|
4532
4581
|
};
|
|
4533
4582
|
}
|
|
4534
4583
|
|
|
4535
|
-
export { AccountSettingsScreen, AuthScreen, AuthTestIds, AuthThemeProvider, BffAuthStatus, CHANGE_PASSWORD_ENDPOINT, ChangePasswordCard, ChangePasswordErrorKey, 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, DemoCredentialsHintVariant, DevicePinEnrollErrorKey, DevicePinEnrollForm, DevicePinErrorKey, DevicePinInput, DevicePinLengthPicker, DevicePinOffer, DevicePinSettingsCard, DevicePinUnlockScreen, ForgotPasswordFields, ForgotPasswordForm, LoginForm, OtpForm, OtpLoginStep, PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, PasskeyCeremonyMode, PasskeyCeremonyStatus, PasskeyLoginButton, PasskeySettingsCard, PasswordPolicyError, PinForm, PreferredMethodHint, PreferredMethodSettingsCard, PrefillIntent, RegisterErrorCode, RegisterForm, RegisterTestIds, ResetPasswordError, ResetPasswordForm, 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 };
|
|
4584
|
+
export { AccountSettingsScreen, AuthScreen, AuthTestIds, AuthThemeProvider, BffAuthStatus, CHANGE_PASSWORD_ENDPOINT, ChangePasswordCard, ChangePasswordErrorKey, 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, DemoCredentialsHintVariant, DevicePinEnrollErrorKey, DevicePinEnrollForm, DevicePinErrorKey, DevicePinInput, DevicePinLengthPicker, DevicePinOffer, DevicePinSettingsCard, DevicePinUnlockScreen, ForgotPasswordFields, ForgotPasswordForm, LoginForm, OtpForm, OtpLoginStep, PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, PasskeyCeremonyMode, PasskeyCeremonyStatus, PasskeyLoginButton, PasskeySettingsCard, PasswordPolicyError, PinForm, PreferredMethodHint, PreferredMethodSettingsCard, PrefillIntent, RegisterErrorCode, RegisterForm, RegisterTestIds, ResetPasswordError, ResetPasswordForm, cachePreferredMethod, clearCachedPreferredMethod, collectUserRoles, createBffAuthClient, createBffChangePasswordClient, createPreferencesClient, defaultAuthTheme, deriveUsernameFromEmail, isAllowedPinDigits, isPasswordValid, isRegisterPasswordStrong, isValidForgotPasswordEmail, performBffLogout, readCachedPreferredMethod, readPasskeyError, readPasskeyRegistered, resolveAccessibleRoutes, resolveAccountList, resolveDemoAccounts, resolveDemoCredentials, resolvePostLoginRoute, splitFullName, startPasskeyLogin, startPasskeyRegistration, syncPreferredMethodFromServer, useAuthTheme, useBffAuth, useBffForgotPassword, useBffLoginConfig, useBffResetPassword, useChangePassword, useDemoCredentials, useDevicePinDisable, useDevicePinEnroll, useDevicePinUnlock, useForgotPasswordSubmit, useOtpLogin, usePasskeyCeremony, usePinLogin, usePreferredMethodSetting, useRegisterForm, useResetPasswordForm, validatePasswordPolicy, withTestIdPrefix };
|
|
4536
4585
|
//# sourceMappingURL=index.mjs.map
|
|
4537
4586
|
//# sourceMappingURL=index.mjs.map
|