@dloizides/auth-web 1.18.0 → 1.18.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/CHANGELOG.md +586 -573
- package/dist/index.d.mts +8 -5
- package/dist/index.d.ts +8 -5
- package/dist/index.js +53 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +54 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StyleSheet, Platform, View, Text, TextInput, TouchableOpacity, ActivityIndicator, Pressable, ScrollView } from 'react-native';
|
|
2
2
|
import { createContext, useContext, useMemo, useState, useRef, useEffect, useCallback } from 'react';
|
|
3
3
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
|
+
import { Button } from '@dloizides/ui-buttons';
|
|
4
5
|
import { useMutation } from '@tanstack/react-query';
|
|
5
6
|
import { BffAuthClient, createFetchHttpClient } from '@dloizides/auth-client';
|
|
6
7
|
export { BffAuthClient, createFetchHttpClient } from '@dloizides/auth-client';
|
|
@@ -774,7 +775,6 @@ function LoginForm({
|
|
|
774
775
|
missingFieldsLabel: labels.missingFields,
|
|
775
776
|
invalidCredentialsLabel: labels.invalidCredentials
|
|
776
777
|
});
|
|
777
|
-
const submitButtonStyle = isSubmitting ? [styles3.primaryButton, styles3.primaryButtonDisabled] : styles3.primaryButton;
|
|
778
778
|
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
779
779
|
/* @__PURE__ */ jsx(Text, { style: styles3.title, children: labels.title }),
|
|
780
780
|
/* @__PURE__ */ jsx(Text, { style: styles3.subtitle, children: labels.subtitle }),
|
|
@@ -838,19 +838,18 @@ function LoginForm({
|
|
|
838
838
|
children: /* @__PURE__ */ jsx(Text, { style: styles3.linkText, children: labels.forgotPassword })
|
|
839
839
|
}
|
|
840
840
|
) : null,
|
|
841
|
-
/* @__PURE__ */ jsx(
|
|
842
|
-
|
|
841
|
+
/* @__PURE__ */ jsx(View, { style: styles3.fieldGroup, children: /* @__PURE__ */ jsx(
|
|
842
|
+
Button,
|
|
843
843
|
{
|
|
844
|
+
fullWidth: true,
|
|
844
845
|
accessibilityHint: labels.submit,
|
|
845
846
|
accessibilityLabel: isSubmitting ? labels.submitting : labels.submit,
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
style: submitButtonStyle,
|
|
847
|
+
label: labels.submit,
|
|
848
|
+
loading: isSubmitting,
|
|
849
849
|
testID: withTestIdPrefix(AuthTestIds.loginSubmitButton, testIdPrefix),
|
|
850
|
-
onPress: handleSubmit
|
|
851
|
-
children: isSubmitting ? /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.colors.onPrimary, size: "small" }) : /* @__PURE__ */ jsx(Text, { style: styles3.primaryButtonText, children: labels.submit })
|
|
850
|
+
onPress: handleSubmit
|
|
852
851
|
}
|
|
853
|
-
),
|
|
852
|
+
) }),
|
|
854
853
|
onSignUp !== void 0 ? /* @__PURE__ */ jsx(
|
|
855
854
|
TouchableOpacity,
|
|
856
855
|
{
|
|
@@ -4126,6 +4125,7 @@ function RegisterFormFields({
|
|
|
4126
4125
|
TextInput,
|
|
4127
4126
|
{
|
|
4128
4127
|
accessibilityElementsHidden: true,
|
|
4128
|
+
accessibilityRole: "none",
|
|
4129
4129
|
autoComplete: "off",
|
|
4130
4130
|
focusable: false,
|
|
4131
4131
|
importantForAccessibility: "no-hide-descendants",
|
|
@@ -4154,9 +4154,21 @@ var RegisterErrorCode = /* @__PURE__ */ ((RegisterErrorCode2) => {
|
|
|
4154
4154
|
return RegisterErrorCode2;
|
|
4155
4155
|
})(RegisterErrorCode || {});
|
|
4156
4156
|
|
|
4157
|
+
// src/hooks/routeRegisterOutcome.ts
|
|
4158
|
+
function routeRegisterOutcome(outcome, handlers) {
|
|
4159
|
+
if (outcome.ok) {
|
|
4160
|
+
handlers.onSuccess(outcome.result);
|
|
4161
|
+
return;
|
|
4162
|
+
}
|
|
4163
|
+
if (outcome.error !== "inFlight" /* InFlight */) {
|
|
4164
|
+
handlers.onError?.(outcome.error);
|
|
4165
|
+
}
|
|
4166
|
+
}
|
|
4167
|
+
|
|
4157
4168
|
// src/hooks/registerErrors.ts
|
|
4158
4169
|
var MIN_PASSWORD_LENGTH = 8;
|
|
4159
|
-
var
|
|
4170
|
+
var WHITESPACE_REGEX = /\s/;
|
|
4171
|
+
var EMAIL_PART_COUNT = 2;
|
|
4160
4172
|
var PASSWORD_LETTER_REGEX = /[a-zA-Z]/;
|
|
4161
4173
|
var PASSWORD_DIGIT_REGEX = /\d/;
|
|
4162
4174
|
var PASSWORD_SPECIAL_REGEX = /[^a-zA-Z0-9]/;
|
|
@@ -4178,6 +4190,17 @@ function isRegisterPasswordStrong(password) {
|
|
|
4178
4190
|
}
|
|
4179
4191
|
return PASSWORD_SPECIAL_REGEX.test(password);
|
|
4180
4192
|
}
|
|
4193
|
+
function isEmailShaped(email) {
|
|
4194
|
+
if (WHITESPACE_REGEX.test(email)) {
|
|
4195
|
+
return false;
|
|
4196
|
+
}
|
|
4197
|
+
const parts = email.split("@");
|
|
4198
|
+
if (parts.length !== EMAIL_PART_COUNT) {
|
|
4199
|
+
return false;
|
|
4200
|
+
}
|
|
4201
|
+
const [local = "", domain = ""] = parts;
|
|
4202
|
+
return local !== "" && domain.slice(1, -1).includes(".");
|
|
4203
|
+
}
|
|
4181
4204
|
function trimRegisterValues(values) {
|
|
4182
4205
|
return {
|
|
4183
4206
|
firstName: values.firstName.trim(),
|
|
@@ -4205,7 +4228,7 @@ function validateRegisterValues(values, passwordPolicy) {
|
|
|
4205
4228
|
if (hasMissingRequiredField(values)) {
|
|
4206
4229
|
return "missingFields" /* MissingFields */;
|
|
4207
4230
|
}
|
|
4208
|
-
if (!
|
|
4231
|
+
if (!isEmailShaped(values.email)) {
|
|
4209
4232
|
return "invalidEmail" /* InvalidEmail */;
|
|
4210
4233
|
}
|
|
4211
4234
|
if (!passwordPolicy(values.password)) {
|
|
@@ -4255,7 +4278,8 @@ function toSubmitValues(values) {
|
|
|
4255
4278
|
}
|
|
4256
4279
|
function useRegisterForm({
|
|
4257
4280
|
onSubmit,
|
|
4258
|
-
passwordPolicy = isRegisterPasswordStrong
|
|
4281
|
+
passwordPolicy = isRegisterPasswordStrong,
|
|
4282
|
+
onSubmitAttempt
|
|
4259
4283
|
}) {
|
|
4260
4284
|
const [state, setState] = useState(EMPTY_VALUES);
|
|
4261
4285
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
@@ -4268,6 +4292,7 @@ function useRegisterForm({
|
|
|
4268
4292
|
if (inFlight.current) {
|
|
4269
4293
|
return { ok: false, error: "inFlight" /* InFlight */ };
|
|
4270
4294
|
}
|
|
4295
|
+
onSubmitAttempt?.();
|
|
4271
4296
|
const trimmed = trimRegisterValues(state);
|
|
4272
4297
|
const refusal = trimmed.website === "" ? validateRegisterValues(trimmed, passwordPolicy) : "failed" /* Failed */;
|
|
4273
4298
|
if (refusal !== null) {
|
|
@@ -4288,7 +4313,7 @@ function useRegisterForm({
|
|
|
4288
4313
|
inFlight.current = false;
|
|
4289
4314
|
setIsSubmitting(false);
|
|
4290
4315
|
}
|
|
4291
|
-
}, [onSubmit, passwordPolicy, state]);
|
|
4316
|
+
}, [onSubmit, onSubmitAttempt, passwordPolicy, state]);
|
|
4292
4317
|
return { state, setField, submit, isSubmitting, error };
|
|
4293
4318
|
}
|
|
4294
4319
|
function RegisterForm({
|
|
@@ -4308,18 +4333,14 @@ function RegisterForm({
|
|
|
4308
4333
|
() => ({ ...DEFAULT_REGISTER_LABELS, ...labelsProp }),
|
|
4309
4334
|
[labelsProp]
|
|
4310
4335
|
);
|
|
4311
|
-
const { state, setField, submit, isSubmitting } = useRegisterForm({
|
|
4312
|
-
|
|
4313
|
-
onSubmitAttempt
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
}
|
|
4320
|
-
});
|
|
4321
|
-
}, [onError, onSubmitAttempt, onSuccess, submit]);
|
|
4322
|
-
const buttonStyle = isSubmitting ? [styles3.primaryButton, styles3.primaryButtonDisabled] : styles3.primaryButton;
|
|
4336
|
+
const { state, setField, submit, isSubmitting } = useRegisterForm({
|
|
4337
|
+
onSubmit,
|
|
4338
|
+
onSubmitAttempt,
|
|
4339
|
+
passwordPolicy
|
|
4340
|
+
});
|
|
4341
|
+
const handlePress = useCallback(async () => {
|
|
4342
|
+
routeRegisterOutcome(await submit(), { onSuccess, onError });
|
|
4343
|
+
}, [onError, onSuccess, submit]);
|
|
4323
4344
|
return /* @__PURE__ */ jsx(View, { style: styles3.screen, children: /* @__PURE__ */ jsxs(View, { style: styles3.card, testID: withTestIdPrefix(RegisterTestIds.form, testIdPrefix), children: [
|
|
4324
4345
|
/* @__PURE__ */ jsx(Text, { style: styles3.title, children: labels.title }),
|
|
4325
4346
|
/* @__PURE__ */ jsx(Text, { style: styles3.subtitle, children: labels.subtitle }),
|
|
@@ -4335,19 +4356,18 @@ function RegisterForm({
|
|
|
4335
4356
|
onChange: setField
|
|
4336
4357
|
}
|
|
4337
4358
|
),
|
|
4338
|
-
/* @__PURE__ */ jsx(
|
|
4339
|
-
|
|
4359
|
+
/* @__PURE__ */ jsx(View, { style: styles3.fieldGroup, children: /* @__PURE__ */ jsx(
|
|
4360
|
+
Button,
|
|
4340
4361
|
{
|
|
4362
|
+
fullWidth: true,
|
|
4341
4363
|
accessibilityHint: labels.submitHint,
|
|
4342
4364
|
accessibilityLabel: isSubmitting ? labels.submitting : labels.submit,
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
style: buttonStyle,
|
|
4365
|
+
label: labels.submit,
|
|
4366
|
+
loading: isSubmitting,
|
|
4346
4367
|
testID: withTestIdPrefix(RegisterTestIds.submitButton, testIdPrefix),
|
|
4347
|
-
onPress: handlePress
|
|
4348
|
-
children: isSubmitting ? /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.colors.onPrimary, size: "small" }) : /* @__PURE__ */ jsx(Text, { style: styles3.primaryButtonText, children: labels.submit })
|
|
4368
|
+
onPress: handlePress
|
|
4349
4369
|
}
|
|
4350
|
-
),
|
|
4370
|
+
) }),
|
|
4351
4371
|
footer
|
|
4352
4372
|
] }) });
|
|
4353
4373
|
}
|
|
@@ -4487,6 +4507,6 @@ function createBffChangePasswordClient(options = {}) {
|
|
|
4487
4507
|
};
|
|
4488
4508
|
}
|
|
4489
4509
|
|
|
4490
|
-
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,
|
|
4510
|
+
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 };
|
|
4491
4511
|
//# sourceMappingURL=index.mjs.map
|
|
4492
4512
|
//# sourceMappingURL=index.mjs.map
|