@dloizides/auth-web 1.16.0 → 1.17.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 +20 -0
- package/dist/index.d.mts +35 -5
- package/dist/index.d.ts +35 -5
- package/dist/index.js +87 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +86 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -414,6 +414,8 @@ var AuthTestIds = {
|
|
|
414
414
|
changePasswordSuccess: "auth-change-password-success",
|
|
415
415
|
// Public-demo credentials panel
|
|
416
416
|
demoCredentialsHint: "auth-demo-credentials-hint",
|
|
417
|
+
// Per-account heading, present only when >1 account is published (multi-account).
|
|
418
|
+
demoCredentialsAccountLabel: "auth-demo-credentials-account-label",
|
|
417
419
|
demoCredentialsUsername: "auth-demo-credentials-username",
|
|
418
420
|
demoCredentialsPassword: "auth-demo-credentials-password",
|
|
419
421
|
demoCredentialsUseButton: "auth-demo-credentials-use",
|
|
@@ -3570,9 +3572,21 @@ function DemoCredentialsBody({
|
|
|
3570
3572
|
styles: styles3,
|
|
3571
3573
|
authStyles,
|
|
3572
3574
|
testIdPrefix,
|
|
3575
|
+
accountLabel,
|
|
3576
|
+
testIdIndex,
|
|
3573
3577
|
onUse
|
|
3574
3578
|
}) {
|
|
3579
|
+
const testId = (base) => withTestIdPrefix(testIdIndex === void 0 ? base : `${base}-${testIdIndex}`, testIdPrefix);
|
|
3580
|
+
const hasLabel = typeof accountLabel === "string" && accountLabel.length > 0;
|
|
3575
3581
|
return /* @__PURE__ */ jsxs(View, { children: [
|
|
3582
|
+
hasLabel ? /* @__PURE__ */ jsx(
|
|
3583
|
+
Text,
|
|
3584
|
+
{
|
|
3585
|
+
style: styles3.accountLabel,
|
|
3586
|
+
testID: testId(AuthTestIds.demoCredentialsAccountLabel),
|
|
3587
|
+
children: accountLabel
|
|
3588
|
+
}
|
|
3589
|
+
) : null,
|
|
3576
3590
|
/* @__PURE__ */ jsxs(View, { style: styles3.row, children: [
|
|
3577
3591
|
/* @__PURE__ */ jsx(Text, { style: styles3.rowLabel, children: labels.usernameLabel }),
|
|
3578
3592
|
/* @__PURE__ */ jsx(
|
|
@@ -3580,7 +3594,7 @@ function DemoCredentialsBody({
|
|
|
3580
3594
|
{
|
|
3581
3595
|
selectable: true,
|
|
3582
3596
|
style: styles3.rowValue,
|
|
3583
|
-
testID:
|
|
3597
|
+
testID: testId(AuthTestIds.demoCredentialsUsername),
|
|
3584
3598
|
children: credentials.username
|
|
3585
3599
|
}
|
|
3586
3600
|
)
|
|
@@ -3592,7 +3606,7 @@ function DemoCredentialsBody({
|
|
|
3592
3606
|
{
|
|
3593
3607
|
selectable: true,
|
|
3594
3608
|
style: styles3.rowValue,
|
|
3595
|
-
testID:
|
|
3609
|
+
testID: testId(AuthTestIds.demoCredentialsPassword),
|
|
3596
3610
|
children: credentials.password
|
|
3597
3611
|
}
|
|
3598
3612
|
)
|
|
@@ -3604,7 +3618,7 @@ function DemoCredentialsBody({
|
|
|
3604
3618
|
accessibilityLabel: labels.useCredentials,
|
|
3605
3619
|
accessibilityRole: "button",
|
|
3606
3620
|
style: [authStyles.secondaryButton, styles3.useButton],
|
|
3607
|
-
testID:
|
|
3621
|
+
testID: testId(AuthTestIds.demoCredentialsUseButton),
|
|
3608
3622
|
onPress: onUse,
|
|
3609
3623
|
children: /* @__PURE__ */ jsx(Text, { style: authStyles.secondaryButtonText, children: labels.useCredentials })
|
|
3610
3624
|
}
|
|
@@ -3657,6 +3671,15 @@ function useDemoCredentialsStyles(theme) {
|
|
|
3657
3671
|
marginBottom: spacing.sm,
|
|
3658
3672
|
color: colors.textSecondary
|
|
3659
3673
|
},
|
|
3674
|
+
accountLabel: {
|
|
3675
|
+
fontSize: typography.caption,
|
|
3676
|
+
fontWeight: "700",
|
|
3677
|
+
color: colors.text,
|
|
3678
|
+
// Separates one account block from the previous one; the first block sits
|
|
3679
|
+
// under the panel description / disclosure divider, which already spaces it.
|
|
3680
|
+
marginTop: spacing.sm,
|
|
3681
|
+
marginBottom: spacing.xs / HALF
|
|
3682
|
+
},
|
|
3660
3683
|
row: {
|
|
3661
3684
|
flexDirection: "row",
|
|
3662
3685
|
alignItems: "center",
|
|
@@ -3732,8 +3755,39 @@ function resolveDemoCredentials(credentials) {
|
|
|
3732
3755
|
}
|
|
3733
3756
|
return { username, password };
|
|
3734
3757
|
}
|
|
3758
|
+
|
|
3759
|
+
// src/demo/resolveDemoAccounts.ts
|
|
3760
|
+
function resolveAccount(account) {
|
|
3761
|
+
if (account === void 0 || account === null) {
|
|
3762
|
+
return null;
|
|
3763
|
+
}
|
|
3764
|
+
const pair = resolveDemoCredentials(account);
|
|
3765
|
+
if (pair === null) {
|
|
3766
|
+
return null;
|
|
3767
|
+
}
|
|
3768
|
+
const label = typeof account.label === "string" ? account.label : "";
|
|
3769
|
+
return { label, username: pair.username, password: pair.password };
|
|
3770
|
+
}
|
|
3771
|
+
function resolveAccountList(accounts) {
|
|
3772
|
+
if (!Array.isArray(accounts)) {
|
|
3773
|
+
return [];
|
|
3774
|
+
}
|
|
3775
|
+
return accounts.map(resolveAccount).filter((account) => account !== null);
|
|
3776
|
+
}
|
|
3777
|
+
function resolveDemoAccounts(credentials) {
|
|
3778
|
+
if (credentials === void 0 || credentials === null) {
|
|
3779
|
+
return [];
|
|
3780
|
+
}
|
|
3781
|
+
const fromList = resolveAccountList(credentials.publishedAccounts);
|
|
3782
|
+
if (fromList.length > 0) {
|
|
3783
|
+
return fromList;
|
|
3784
|
+
}
|
|
3785
|
+
const single = resolveDemoCredentials(credentials);
|
|
3786
|
+
return single === null ? [] : [{ label: "", username: single.username, password: single.password }];
|
|
3787
|
+
}
|
|
3735
3788
|
function DemoCredentialsHint({
|
|
3736
3789
|
credentials,
|
|
3790
|
+
accounts,
|
|
3737
3791
|
variant = "disclosure" /* Disclosure */,
|
|
3738
3792
|
theme: themeProp,
|
|
3739
3793
|
labels: labelsProp,
|
|
@@ -3748,29 +3802,35 @@ function DemoCredentialsHint({
|
|
|
3748
3802
|
() => ({ ...DEFAULT_DEMO_CREDENTIALS_HINT_LABELS, ...labelsProp }),
|
|
3749
3803
|
[labelsProp]
|
|
3750
3804
|
);
|
|
3751
|
-
const
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3805
|
+
const resolvedAccounts = useMemo(
|
|
3806
|
+
() => accounts !== void 0 && accounts.length > 0 ? resolveAccountList(accounts) : resolveDemoAccounts(credentials),
|
|
3807
|
+
[accounts, credentials]
|
|
3808
|
+
);
|
|
3809
|
+
const makeUse = useCallback(
|
|
3810
|
+
(account) => onUse === void 0 ? void 0 : () => onUse({ username: account.username, password: account.password }),
|
|
3811
|
+
[onUse]
|
|
3812
|
+
);
|
|
3757
3813
|
const handleToggle = useCallback(() => {
|
|
3758
3814
|
setExpanded((current) => !current);
|
|
3759
3815
|
}, []);
|
|
3760
|
-
if (
|
|
3816
|
+
if (resolvedAccounts.length === 0) {
|
|
3761
3817
|
return null;
|
|
3762
3818
|
}
|
|
3763
|
-
const
|
|
3819
|
+
const isSingle = resolvedAccounts.length === 1;
|
|
3820
|
+
const body = resolvedAccounts.map((account, index) => /* @__PURE__ */ jsx(
|
|
3764
3821
|
DemoCredentialsBody,
|
|
3765
3822
|
{
|
|
3823
|
+
accountLabel: isSingle ? void 0 : account.label,
|
|
3766
3824
|
authStyles,
|
|
3767
|
-
credentials:
|
|
3825
|
+
credentials: { username: account.username, password: account.password },
|
|
3768
3826
|
labels,
|
|
3769
3827
|
styles: styles3,
|
|
3828
|
+
testIdIndex: isSingle ? void 0 : index,
|
|
3770
3829
|
testIdPrefix,
|
|
3771
|
-
onUse:
|
|
3772
|
-
}
|
|
3773
|
-
|
|
3830
|
+
onUse: makeUse(account)
|
|
3831
|
+
},
|
|
3832
|
+
`${account.username}-${String(index)}`
|
|
3833
|
+
));
|
|
3774
3834
|
if (variant === "panel" /* Panel */) {
|
|
3775
3835
|
return /* @__PURE__ */ jsxs(
|
|
3776
3836
|
View,
|
|
@@ -3926,7 +3986,11 @@ function useDemoCredentials({
|
|
|
3926
3986
|
credentials,
|
|
3927
3987
|
prefillOnMount = false
|
|
3928
3988
|
} = {}) {
|
|
3929
|
-
const
|
|
3989
|
+
const accounts = useMemo(() => resolveDemoAccounts(credentials), [credentials]);
|
|
3990
|
+
const resolved = useMemo(() => {
|
|
3991
|
+
const first = accounts[0];
|
|
3992
|
+
return first === void 0 ? null : { username: first.username, password: first.password };
|
|
3993
|
+
}, [accounts]);
|
|
3930
3994
|
const [filled, setFilled] = useState(
|
|
3931
3995
|
prefillOnMount ? resolved : null
|
|
3932
3996
|
);
|
|
@@ -3958,11 +4022,12 @@ function useDemoCredentials({
|
|
|
3958
4022
|
prefillIntent
|
|
3959
4023
|
},
|
|
3960
4024
|
// `credentials` is passed through unresolved on purpose: the hint applies
|
|
3961
|
-
// `
|
|
3962
|
-
// standalone, without this hook.
|
|
3963
|
-
|
|
4025
|
+
// `resolveDemoAccounts` itself, so it fails closed even when it is used
|
|
4026
|
+
// standalone, without this hook. `accounts` is the already-resolved list the
|
|
4027
|
+
// hint prefers — one labelled row per entry.
|
|
4028
|
+
hintProps: { credentials, accounts, onUse: handleUse }
|
|
3964
4029
|
}),
|
|
3965
|
-
[filled, prefillNonce, prefillIntent, credentials, handleUse]
|
|
4030
|
+
[filled, prefillNonce, prefillIntent, credentials, accounts, handleUse]
|
|
3966
4031
|
);
|
|
3967
4032
|
}
|
|
3968
4033
|
async function lazyFetchHttpClient(request) {
|
|
@@ -4101,6 +4166,6 @@ function createBffChangePasswordClient(options = {}) {
|
|
|
4101
4166
|
};
|
|
4102
4167
|
}
|
|
4103
4168
|
|
|
4104
|
-
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_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, ResetPasswordError, ResetPasswordForm, cachePreferredMethod, clearCachedPreferredMethod, collectUserRoles, createBffAuthClient, createBffChangePasswordClient, createPreferencesClient, defaultAuthTheme, isAllowedPinDigits, isPasswordValid, isValidForgotPasswordEmail, performBffLogout, readCachedPreferredMethod, readPasskeyError, readPasskeyRegistered, resolveAccessibleRoutes, resolveDemoCredentials, resolvePostLoginRoute, startPasskeyLogin, startPasskeyRegistration, syncPreferredMethodFromServer, useAuthTheme, useBffAuth, useBffForgotPassword, useBffLoginConfig, useBffResetPassword, useChangePassword, useDemoCredentials, useDevicePinDisable, useDevicePinEnroll, useDevicePinUnlock, useForgotPasswordSubmit, useOtpLogin, usePasskeyCeremony, usePinLogin, usePreferredMethodSetting, useResetPasswordForm, validatePasswordPolicy, withTestIdPrefix };
|
|
4169
|
+
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_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, ResetPasswordError, ResetPasswordForm, cachePreferredMethod, clearCachedPreferredMethod, collectUserRoles, createBffAuthClient, createBffChangePasswordClient, createPreferencesClient, defaultAuthTheme, isAllowedPinDigits, isPasswordValid, 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, useResetPasswordForm, validatePasswordPolicy, withTestIdPrefix };
|
|
4105
4170
|
//# sourceMappingURL=index.mjs.map
|
|
4106
4171
|
//# sourceMappingURL=index.mjs.map
|