-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for adding a passkey on signup
- Loading branch information
Showing
18 changed files
with
244 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/alchemy/src/react/components/auth/card/add-passkey.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { useAddPasskey } from "../../../hooks/useAddPasskey.js"; | ||
import { PasskeyIcon } from "../../../icons/passkey.js"; | ||
import { Button } from "../../button.js"; | ||
import { ErrorContainer } from "../../error.js"; | ||
import { PoweredBy } from "../../poweredby.js"; | ||
import { useAuthContext } from "../context.js"; | ||
|
||
// eslint-disable-next-line jsdoc/require-jsdoc | ||
export const AddPasskey = () => { | ||
const { setAuthStep } = useAuthContext(); | ||
const { addPasskey, isAddingPasskey, error } = useAddPasskey({ | ||
onSuccess: () => { | ||
setAuthStep({ type: "complete" }); | ||
}, | ||
}); | ||
|
||
return ( | ||
<div className="flex flex-col gap-5 items-center"> | ||
<span className="text-lg text-fg-primary font-semibold"> | ||
Add a passkey? | ||
</span> | ||
<div className="flex flex-col items-center justify-center border-fg-accent-brand bg-bg-surface-inset rounded-[100%] w-[56px] h-[56px] border"> | ||
<PasskeyIcon /> | ||
</div> | ||
<p className="text-fg-secondary text-center font-normal text-sm"> | ||
Passkeys allow for a simple and secure user experience. Login in and | ||
sign transactions in seconds | ||
</p> | ||
{error && <ErrorContainer error={error} />} | ||
<Button | ||
type="primary" | ||
className="w-full" | ||
onClick={() => addPasskey()} | ||
disabled={isAddingPasskey} | ||
> | ||
Continue | ||
</Button> | ||
<Button | ||
type="secondary" | ||
className="w-full" | ||
onClick={() => setAuthStep({ type: "complete" })} | ||
disabled={isAddingPasskey} | ||
> | ||
Skip | ||
</Button> | ||
<PoweredBy /> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useAuthContext } from "../context.js"; | ||
import { AddPasskey } from "./add-passkey.js"; | ||
import type { AuthCardProps } from "./index.js"; | ||
import { LoadingAuth } from "./loading/index.js"; | ||
import { MainAuthContent } from "./main.js"; | ||
|
||
// eslint-disable-next-line jsdoc/require-jsdoc | ||
export const Step = (props: AuthCardProps) => { | ||
const { authStep } = useAuthContext(); | ||
|
||
switch (authStep.type) { | ||
case "email_verify": | ||
case "passkey_verify": | ||
case "email_completing": | ||
return <LoadingAuth context={authStep} />; | ||
case "passkey_create": | ||
return <AddPasskey />; | ||
case "complete": | ||
case "initial": | ||
default: | ||
return <MainAuthContent {...props} />; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const IS_SIGNUP_QP = "aa-is-signup"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.