@dloizides/auth-web 1.11.0 → 1.12.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 +53 -0
- package/README.md +33 -9
- package/dist/index.d.mts +44 -22
- package/dist/index.d.ts +44 -22
- package/dist/index.js +47 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -493,18 +493,32 @@ function useAuthStyles(theme) {
|
|
|
493
493
|
});
|
|
494
494
|
}, [theme]);
|
|
495
495
|
}
|
|
496
|
+
|
|
497
|
+
// src/components/PrefillIntent.ts
|
|
498
|
+
var PrefillIntent = /* @__PURE__ */ ((PrefillIntent2) => {
|
|
499
|
+
PrefillIntent2["Explicit"] = "explicit";
|
|
500
|
+
PrefillIntent2["Opportunistic"] = "opportunistic";
|
|
501
|
+
return PrefillIntent2;
|
|
502
|
+
})(PrefillIntent || {});
|
|
503
|
+
|
|
504
|
+
// src/components/useLoginPrefill.ts
|
|
496
505
|
function useLoginPrefill({
|
|
497
506
|
initialUsername,
|
|
498
507
|
initialPassword,
|
|
499
|
-
prefillNonce
|
|
508
|
+
prefillNonce,
|
|
509
|
+
prefillIntent
|
|
500
510
|
}) {
|
|
501
511
|
const [username, setUsername] = useState(initialUsername ?? "");
|
|
502
512
|
const [password, setPassword] = useState(initialPassword ?? "");
|
|
503
513
|
const [appliedNonce, setAppliedNonce] = useState(prefillNonce);
|
|
504
514
|
if (prefillNonce !== appliedNonce) {
|
|
505
515
|
setAppliedNonce(prefillNonce);
|
|
506
|
-
|
|
507
|
-
|
|
516
|
+
const isPristine = username.length === 0 && password.length === 0;
|
|
517
|
+
const mayApply = prefillIntent !== "opportunistic" /* Opportunistic */ || isPristine;
|
|
518
|
+
if (mayApply) {
|
|
519
|
+
setUsername(initialUsername ?? "");
|
|
520
|
+
setPassword(initialPassword ?? "");
|
|
521
|
+
}
|
|
508
522
|
}
|
|
509
523
|
return { username, password, setUsername, setPassword };
|
|
510
524
|
}
|
|
@@ -622,7 +636,8 @@ function LoginForm({
|
|
|
622
636
|
chromeless = false,
|
|
623
637
|
initialUsername,
|
|
624
638
|
initialPassword,
|
|
625
|
-
prefillNonce
|
|
639
|
+
prefillNonce,
|
|
640
|
+
prefillIntent
|
|
626
641
|
}) {
|
|
627
642
|
const theme = useAuthTheme(themeProp);
|
|
628
643
|
const styles3 = useAuthStyles(theme);
|
|
@@ -634,7 +649,8 @@ function LoginForm({
|
|
|
634
649
|
const { username, password, setUsername, setPassword } = useLoginPrefill({
|
|
635
650
|
initialUsername,
|
|
636
651
|
initialPassword,
|
|
637
|
-
prefillNonce
|
|
652
|
+
prefillNonce,
|
|
653
|
+
prefillIntent
|
|
638
654
|
});
|
|
639
655
|
const [errorText, setErrorText] = useState(null);
|
|
640
656
|
const runLogin = useCallback(async () => {
|
|
@@ -3323,7 +3339,8 @@ var EMPTY_CONFIG = {
|
|
|
3323
3339
|
hasPin: false,
|
|
3324
3340
|
pinDigits: null,
|
|
3325
3341
|
preferredMethod: null
|
|
3326
|
-
}
|
|
3342
|
+
},
|
|
3343
|
+
demo: null
|
|
3327
3344
|
};
|
|
3328
3345
|
function useBffLoginConfig(client) {
|
|
3329
3346
|
const [config, setConfig] = useState(EMPTY_CONFIG);
|
|
@@ -3420,6 +3437,12 @@ async function syncPreferredMethodFromServer(client) {
|
|
|
3420
3437
|
return null;
|
|
3421
3438
|
}
|
|
3422
3439
|
}
|
|
3440
|
+
function isSamePair(a, b) {
|
|
3441
|
+
if (a === null || b === null) {
|
|
3442
|
+
return a === b;
|
|
3443
|
+
}
|
|
3444
|
+
return a.username === b.username && a.password === b.password;
|
|
3445
|
+
}
|
|
3423
3446
|
function useDemoCredentials({
|
|
3424
3447
|
credentials,
|
|
3425
3448
|
prefillOnMount = false
|
|
@@ -3429,23 +3452,38 @@ function useDemoCredentials({
|
|
|
3429
3452
|
prefillOnMount ? resolved : null
|
|
3430
3453
|
);
|
|
3431
3454
|
const [prefillNonce, setPrefillNonce] = useState(0);
|
|
3455
|
+
const [prefillIntent, setPrefillIntent] = useState(
|
|
3456
|
+
"opportunistic" /* Opportunistic */
|
|
3457
|
+
);
|
|
3458
|
+
const [autoSeeded, setAutoSeeded] = useState(
|
|
3459
|
+
prefillOnMount ? resolved : null
|
|
3460
|
+
);
|
|
3461
|
+
const shouldAutoSeed = prefillOnMount && resolved !== null && !isSamePair(resolved, autoSeeded);
|
|
3462
|
+
if (shouldAutoSeed) {
|
|
3463
|
+
setAutoSeeded(resolved);
|
|
3464
|
+
setFilled(resolved);
|
|
3465
|
+
setPrefillNonce((current) => current + 1);
|
|
3466
|
+
setPrefillIntent("opportunistic" /* Opportunistic */);
|
|
3467
|
+
}
|
|
3432
3468
|
const handleUse = useCallback((next) => {
|
|
3433
3469
|
setFilled(next);
|
|
3434
3470
|
setPrefillNonce((current) => current + 1);
|
|
3471
|
+
setPrefillIntent("explicit" /* Explicit */);
|
|
3435
3472
|
}, []);
|
|
3436
3473
|
return useMemo(
|
|
3437
3474
|
() => ({
|
|
3438
3475
|
loginFormProps: {
|
|
3439
3476
|
initialUsername: filled?.username,
|
|
3440
3477
|
initialPassword: filled?.password,
|
|
3441
|
-
prefillNonce
|
|
3478
|
+
prefillNonce,
|
|
3479
|
+
prefillIntent
|
|
3442
3480
|
},
|
|
3443
3481
|
// `credentials` is passed through unresolved on purpose: the hint applies
|
|
3444
3482
|
// `resolveDemoCredentials` itself, so it fails closed even when it is used
|
|
3445
3483
|
// standalone, without this hook.
|
|
3446
3484
|
hintProps: { credentials, onUse: handleUse }
|
|
3447
3485
|
}),
|
|
3448
|
-
[filled, prefillNonce, credentials, handleUse]
|
|
3486
|
+
[filled, prefillNonce, prefillIntent, credentials, handleUse]
|
|
3449
3487
|
);
|
|
3450
3488
|
}
|
|
3451
3489
|
async function lazyFetchHttpClient(request) {
|
|
@@ -3534,6 +3572,6 @@ async function performBffLogout(options) {
|
|
|
3534
3572
|
runGuarded(onRedirect, onError);
|
|
3535
3573
|
}
|
|
3536
3574
|
|
|
3537
|
-
export { AuthScreen, AuthTestIds, AuthThemeProvider, BffAuthStatus, 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, 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, ResetPasswordError, ResetPasswordForm, cachePreferredMethod, clearCachedPreferredMethod, collectUserRoles, createBffAuthClient, createPreferencesClient, defaultAuthTheme, isAllowedPinDigits, isPasswordValid, isValidForgotPasswordEmail, performBffLogout, readCachedPreferredMethod, readPasskeyError, readPasskeyRegistered, resolveAccessibleRoutes, resolveDemoCredentials, resolvePostLoginRoute, startPasskeyLogin, startPasskeyRegistration, syncPreferredMethodFromServer, useAuthTheme, useBffAuth, useBffForgotPassword, useBffLoginConfig, useBffResetPassword, useDemoCredentials, useDevicePinDisable, useDevicePinEnroll, useDevicePinUnlock, useForgotPasswordSubmit, useOtpLogin, usePasskeyCeremony, usePinLogin, usePreferredMethodSetting, useResetPasswordForm, validatePasswordPolicy, withTestIdPrefix };
|
|
3575
|
+
export { AuthScreen, AuthTestIds, AuthThemeProvider, BffAuthStatus, 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, 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, createPreferencesClient, defaultAuthTheme, isAllowedPinDigits, isPasswordValid, isValidForgotPasswordEmail, performBffLogout, readCachedPreferredMethod, readPasskeyError, readPasskeyRegistered, resolveAccessibleRoutes, resolveDemoCredentials, resolvePostLoginRoute, startPasskeyLogin, startPasskeyRegistration, syncPreferredMethodFromServer, useAuthTheme, useBffAuth, useBffForgotPassword, useBffLoginConfig, useBffResetPassword, useDemoCredentials, useDevicePinDisable, useDevicePinEnroll, useDevicePinUnlock, useForgotPasswordSubmit, useOtpLogin, usePasskeyCeremony, usePinLogin, usePreferredMethodSetting, useResetPasswordForm, validatePasswordPolicy, withTestIdPrefix };
|
|
3538
3576
|
//# sourceMappingURL=index.mjs.map
|
|
3539
3577
|
//# sourceMappingURL=index.mjs.map
|