Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Headless Auth: POC demo #813

Merged
merged 23 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e476577
Headless Auth: POC demo
jmderby Oct 11, 2024
6d397ae
Added discord auth, added embedded form, added dialog styles
jmderby Oct 15, 2024
f93ecc4
Merge branch 'main' into jonathan/headless-auth-poc
jmderby Oct 15, 2024
884ec93
added merge changes
jmderby Oct 15, 2024
17566f5
fixed styles and added stytch token call
jmderby Oct 15, 2024
209e89a
remove console logs
jmderby Oct 16, 2024
0ff9d02
removed unused dep
jmderby Oct 16, 2024
d995b7f
moved oauth url stuff to backend
jmderby Oct 17, 2024
d78f3b1
removed embedded component factory and replace with hook component
jmderby Oct 17, 2024
29275df
Merge branch 'main' into jonathan/headless-auth-poc
jmderby Oct 17, 2024
198d6a3
replaced component from hook as exported component
jmderby Oct 18, 2024
cd0a8d0
finished farcaster login method
jmderby Oct 18, 2024
5f813d6
descoped any web3 changes to separate branch
jmderby Oct 18, 2024
5cc7e0e
removed any login methods to use default
jmderby Oct 18, 2024
2f934c9
added test for authformprovider
jmderby Oct 18, 2024
2742573
removed unused code
jmderby Oct 21, 2024
c8220b0
review feedback
jmderby Oct 22, 2024
cbbb165
prefetch oauth url on auth form mount
jmderby Oct 22, 2024
cc524bc
Merge branch 'main' into jonathan/headless-auth-poc
jmderby Oct 22, 2024
599fd5a
added more efficient query, removed discord, improved embedded compon…
jmderby Oct 22, 2024
6050b51
Merge branch 'main' into jonathan/headless-auth-poc
jmderby Oct 22, 2024
61e7754
merge changes with main
jmderby Oct 22, 2024
7f850ee
made changes to correspond to recent backend changes
jmderby Oct 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/wallets/smart-wallet/next/src/app/_lib/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function Providers({ children }: { children: ReactNode }) {
}}
appearance={{
spacingUnit: "8px",
borderRadius: "12px",
borderRadius: "16px",
colors: {
inputBackground: "#fffdf9",
buttonBackground: "#fffaf2",
Expand All @@ -31,6 +31,7 @@ export function Providers({ children }: { children: ReactNode }) {
accent: "#602C1B",
},
}}
loginMethods={["email", "google", "farcaster", "discord"]}
jmderby marked this conversation as resolved.
Show resolved Hide resolved
>
{children}
</CrossmintAuthProvider>
Expand Down
7 changes: 6 additions & 1 deletion packages/client/ui/react-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,24 @@
"@crossmint/client-sdk-base": "workspace:*",
"@crossmint/client-sdk-smart-wallet": "workspace:*",
"@crossmint/client-sdk-window": "workspace:*",
"@crossmint/common-sdk-base": "workspace:*",
"@crossmint/common-sdk-auth": "workspace:*",
"@crossmint/common-sdk-base": "workspace:*",
"@ethersproject/transactions": "5.7.0",
"@farcaster/auth-kit": "0.6.0",
"@headlessui/react": "2.1.5",
jmderby marked this conversation as resolved.
Show resolved Hide resolved
"@radix-ui/react-dialog": "1.1.2",
"@radix-ui/react-visually-hidden": "1.1.0",
"@solana/web3.js": "1.95.1",
"@twind/core": "1.1.3",
"@twind/preset-tailwind": "1.1.4",
"bs58": "5.0.0",
"clsx": "2.1.1",
"input-otp": "1.2.4",
"lodash.isequal": "4.5.0",
"react-jss": "10.10.0",
"tailwind-merge": "2.4.0",
"tailwindcss": "3.4.10",
"viem": "2.17.5",
jmderby marked this conversation as resolved.
Show resolved Hide resolved
"zod": "3.22.4"
},
"devDependencies": {
Expand Down
80 changes: 80 additions & 0 deletions packages/client/ui/react-ui/src/components/auth/AuthForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import type React from "react";
import { useAuthForm } from "@/providers/auth/AuthFormProvider";
import { EmailAuthFlow } from "./methods/email/EmailAuthFlow";
import { Divider } from "../common/Divider";
import { GoogleSignIn } from "./methods/google/GoogleSignIn";
import { FarcasterSignIn } from "./methods/farcaster/FarcasterSignIn";
import { PoweredByCrossmint } from "../common/PoweredByCrossmint";
import { FarcasterProvider } from "../../providers/auth/FarcasterProvider";
import { DiscordSignIn } from "./methods/discord/DiscordSignIn";
import { classNames } from "@/utils/classNames";
import { LeftArrowIcon } from "@/icons/leftArrow";
import type { LoginMethod } from "../../providers/CrossmintAuthProvider";

export function AuthForm({ loginMethods }: { loginMethods: LoginMethod[] }) {
const { step, appearance, baseUrl } = useAuthForm();

return (
<div className="flex flex-col gap-4 max-w-[448px]">
{step === "initial" ? (
<div>
<h1
className="text-2xl font-semibold text-cm-text-primary"
style={{ color: appearance?.colors?.textPrimary }}
>
Sign In
</h1>
<p
className="text-base font-normal mb-5 text-cm-text-secondary"
style={{ color: appearance?.colors?.textSecondary }}
>
Sign in using one of the options below
</p>
</div>
) : null}

{loginMethods.includes("email") ? (
<>
<EmailAuthFlow />
{loginMethods.length > 1 ? <Divider appearance={appearance} text="OR" /> : null}
</>
) : null}

{loginMethods.includes("google") ? <GoogleSignIn /> : null}
{loginMethods.includes("farcaster") ? (
<FarcasterProvider baseUrl={baseUrl}>
<FarcasterSignIn />
</FarcasterProvider>
) : null}

{loginMethods.includes("discord") ? <DiscordSignIn /> : null}

{step === "initial" || step === "otp" ? (
<PoweredByCrossmint className="justify-center" color={appearance?.colors?.textSecondary ?? "#A4AFB2"} />
) : null}
</div>
);
}

export const AuthFormBackButton = ({
AlbertoElias marked this conversation as resolved.
Show resolved Hide resolved
className,
iconColor,
ringColor,
...props
}: React.HTMLAttributes<HTMLButtonElement> & { iconColor?: string; ringColor?: string }) => {
return (
<button
className={classNames(
"relative rounded-full opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-cm-ring focus:ring-offset-2 disabled:pointer-events-none",
className
)}
style={{
// @ts-expect-error --tw-ring-color is not recognized by typescript but gets picked up by tailwind
"--tw-ring-color": ringColor ?? "#1A73E8",
}}
{...props}
>
<LeftArrowIcon className="w-6 h-6" style={{ color: iconColor }} />
</button>
);
};
33 changes: 33 additions & 0 deletions packages/client/ui/react-ui/src/components/auth/AuthFormDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
import { useAuthForm } from "@/providers/auth/AuthFormProvider";
import { AuthForm } from "./AuthForm";
import { Dialog, DialogContent, DialogDescription, DialogTitle } from "../common/Dialog";
import type { LoginMethod } from "../../providers/CrossmintAuthProvider";

export default function AuthFormDialog({ open, loginMethods }: { open: boolean; loginMethods: LoginMethod[] }) {
const { appearance, setDialogOpen } = useAuthForm();

return (
<Dialog open={open} onOpenChange={setDialogOpen}>
<DialogContent
onInteractOutside={(e) => e.preventDefault()}
onOpenAutoFocus={(e) => e.preventDefault()}
closeButtonColor={appearance?.colors?.textPrimary}
closeButtonRingColor={appearance?.colors?.accent}
style={{
borderTopLeftRadius: appearance?.borderRadius,
borderTopRightRadius: appearance?.borderRadius,
backgroundColor: appearance?.colors?.background,
}}
>
<VisuallyHidden asChild>
<DialogTitle>Crossmint Auth</DialogTitle>
</VisuallyHidden>
<VisuallyHidden asChild>
<DialogDescription>Sign in via Crossmint</DialogDescription>
</VisuallyHidden>
<AuthForm loginMethods={loginMethods} />
</DialogContent>
</Dialog>
);
}
207 changes: 0 additions & 207 deletions packages/client/ui/react-ui/src/components/auth/AuthModal.tsx

This file was deleted.

Loading
Loading