Rename
This commit is contained in:
@@ -14,8 +14,8 @@ import {
|
||||
finishPasskeyAuthentication,
|
||||
isWebAuthnSupported,
|
||||
isWhitelistedRedirect,
|
||||
passkeyAuthenticationSuccessRedirectURL,
|
||||
redirectToPasskeyRecoverPage,
|
||||
redirectURLWithPasskeyAuthentication,
|
||||
signChallenge,
|
||||
} from "services/passkey";
|
||||
|
||||
@@ -40,7 +40,7 @@ const Page = () => {
|
||||
// The URL we're redirecting to on success.
|
||||
//
|
||||
// This will only be set when status is "redirecting*".
|
||||
const [redirectURLWithData, setRedirectURLWithData] = useState<
|
||||
const [successRedirectURL, setSuccessRedirectURL] = useState<
|
||||
URL | undefined
|
||||
>();
|
||||
|
||||
@@ -115,8 +115,8 @@ const Page = () => {
|
||||
|
||||
setStatus(isHTTP(redirectURL) ? "redirectingWeb" : "redirectingApp");
|
||||
|
||||
setRedirectURLWithData(
|
||||
await redirectURLWithPasskeyAuthentication(
|
||||
setSuccessRedirectURL(
|
||||
await passkeyAuthenticationSuccessRedirectURL(
|
||||
redirectURL,
|
||||
passkeySessionID,
|
||||
authorizationResponse,
|
||||
@@ -129,8 +129,8 @@ const Page = () => {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (redirectURLWithData) redirectToURL(redirectURLWithData);
|
||||
}, [redirectURLWithData]);
|
||||
if (successRedirectURL) redirectToURL(successRedirectURL);
|
||||
}, [successRedirectURL]);
|
||||
|
||||
const handleRetry = () => void authenticate();
|
||||
|
||||
@@ -150,8 +150,7 @@ const Page = () => {
|
||||
return () => redirectToPasskeyRecoverPage(new URL(recover));
|
||||
})();
|
||||
|
||||
const handleRedirectAgain = () =>
|
||||
redirectToURL(ensure(redirectURLWithData));
|
||||
const handleRedirectAgain = () => redirectToURL(ensure(successRedirectURL));
|
||||
|
||||
const components: Record<Status, React.ReactNode> = {
|
||||
loading: <Loading />,
|
||||
|
||||
@@ -560,7 +560,7 @@ const authenticatorAssertionResponse = (credential: Credential) => {
|
||||
* @param twoFactorAuthorizationResponse The result of
|
||||
* {@link finishPasskeyAuthentication} returned by the backend.
|
||||
*/
|
||||
export const redirectURLWithPasskeyAuthentication = async (
|
||||
export const passkeyAuthenticationSuccessRedirectURL = async (
|
||||
redirectURL: URL,
|
||||
passkeySessionID: string,
|
||||
twoFactorAuthorizationResponse: TwoFactorAuthorizationResponse,
|
||||
|
||||
@@ -50,7 +50,7 @@ export default Page;
|
||||
*/
|
||||
const saveCredentials = async (response: string) => {
|
||||
// Decode response string (inverse of the steps we perform in
|
||||
// `redirectAfterPasskeyAuthentication`).
|
||||
// `passkeyAuthenticationSuccessRedirectURL`).
|
||||
const decodedResponse = JSON.parse(
|
||||
await fromB64URLSafeNoPaddingString(response),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user