Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
[WIP] Add email auth
Tomas Valentaec39070f9329
diff --git a/apps/docs/package.json b/apps/docs/package.jsonindex 69c80a43e..394ac820b 100644--- a/apps/docs/package.json+++ b/apps/docs/package.json@@ -22,8 +22,10 @@"@sentry/nextjs": "^7.64.0","@sindresorhus/slugify": "^2.1.1","@supabase/auth-helpers-nextjs": "^0.7.4",+ "@supabase/auth-ui-react": "^0.4.7",+ "@supabase/auth-ui-shared": "^0.1.8","@supabase/supabase-auth-helpers": "^1.4.2",- "@supabase/supabase-js": "^2.32.0",+ "@supabase/supabase-js": "^2.36.0","@tailwindcss/typography": "0.5.9","@types/node": "20.6.3","@types/react": "18.2.48",diff --git a/apps/docs/src/app/getting-started/api-key/APIKey.tsx b/apps/docs/src/app/getting-started/api-key/APIKey.tsxindex f7faa22c7..7e23b0358 100644--- a/apps/docs/src/app/getting-started/api-key/APIKey.tsx+++ b/apps/docs/src/app/getting-started/api-key/APIKey.tsx@@ -117,7 +117,7 @@ function APIKey() {) : (<div className="flex flex-col items-start justiy-start gap-4 mt-6"><span>You can get your API key by signing up.</span>- <Button onClick={() => signIn()}>Sign up to get your API key</Button>+ <Button onClick={() => signIn('auth-sign-up')}>Sign up to get your API key</Button></div>)}</div>diff --git a/apps/docs/src/app/page.mdx b/apps/docs/src/app/page.mdxindex 9001517bb..9035f623d 100644--- a/apps/docs/src/app/page.mdx+++ b/apps/docs/src/app/page.mdx@@ -3,8 +3,6 @@ import { UseCases } from '@/components/UseCases'import { HeroPattern } from '@/components/HeroPattern'import { Button } from '@/components/Button'import { ButtonLoginToken } from '@/components/ButtonLoginToken'-import { useSignIn } from '@/utils/useSignIn'-<HeroPattern />diff --git a/apps/docs/src/app/sign/page.tsx b/apps/docs/src/app/sign/page.tsxnew file mode 100644index 000000000..86c7c4cb4--- /dev/null+++ b/apps/docs/src/app/sign/page.tsx@@ -0,0 +1,9 @@+'use client'++import AuthForm from '@/components/AuthForm'++export default function Sign() {+ return (+ <AuthForm />+ )+}diff --git a/apps/docs/src/components/Anchor.tsx b/apps/docs/src/components/Anchor.tsxnew file mode 100644index 000000000..b2d00ca2a--- /dev/null+++ b/apps/docs/src/components/Anchor.tsx@@ -0,0 +1,41 @@+import { css } from '@stitches/core'+import { generateClassNames } from '@supabase/auth-ui-shared'+import { Appearance } from '../../types'++const anchorHTMLAttributes = css({+ fontFamily: '$bodyFontFamily',+ fontSize: '$baseBodySize',+ marginBottom: '$anchorBottomMargin',+ color: '$anchorTextColor',+ display: 'block',+ textAlign: 'center',+ textDecoration: 'underline',+ '&:hover': {+ color: '$anchorTextHoverColor',+ },+})++interface LabelProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {+ children: React.ReactNode+ appearance?: Appearance+}++const Anchor: React.FC<LabelProps> = ({ children, appearance, ...props }) => {+ const classNames = generateClassNames(+ 'anchor',+ anchorHTMLAttributes(),+ appearance+ )++ return (+ <a+ {...props}+ style={appearance?.style?.anchor}+ className={classNames.join(' ')}+ >+ {children}+ </a>+ )+}++export { Anchor }diff --git a/apps/docs/src/components/Auth.tsx b/apps/docs/src/components/Auth.tsxindex 0df3bbc59..0534575b0 100644--- a/apps/docs/src/components/Auth.tsx+++ b/apps/docs/src/components/Auth.tsx@@ -1,7 +1,10 @@+'use client'+import clsx from 'clsx'import { LogOutIcon } from 'lucide-react'import { useRouter } from 'next/navigation'+import { Button } from '@/components/Button'import { createClientComponentClient } from '@supabase/auth-helpers-nextjs'import { useApiKey, useUser } from '@/utils/useUser'@@ -114,7 +117,7 @@ export const Auth = function () {<div className="flex items-center justify-center gap-3">{/* @ts-ignore */}<Button- onClick={() => signIn()}+ onClick={() => signIn('auth-sign-up')}variant="textTernary"className="whitespace-nowrap text-xs">diff --git a/apps/docs/src/components/AuthForm.tsx b/apps/docs/src/components/AuthForm.tsxnew file mode 100644index 000000000..aee3b2fc3--- /dev/null+++ b/apps/docs/src/components/AuthForm.tsx@@ -0,0 +1,35 @@+'use client'++import { Auth } from '@supabase/auth-ui-react'+import {+ ThemeSupa,++} from '@supabase/auth-ui-shared'+import { createClientComponentClient } from '@supabase/auth-helpers-nextjs'++const supabase = createClientComponentClient()++function AuthForm() {+ const url = typeof window !== 'undefined' ? window.location.href : undefined++ return (+ <div className="flex flex-1 items-center">+ <Auth+ supabaseClient={supabase}+ appearance={{+ theme: ThemeSupa,+ }}+ theme="dark"+ providers={['github']}+ queryParams={{+ redirect_to: url,+ }}+ providerScopes={{+ github: 'email',+ }}+ />+ </div>+ )+}++export default AuthFormdiff --git a/apps/docs/src/components/ButtonLoginToken.tsx b/apps/docs/src/components/ButtonLoginToken.tsxindex f35b82036..542b5c9a9 100644--- a/apps/docs/src/components/ButtonLoginToken.tsx+++ b/apps/docs/src/components/ButtonLoginToken.tsx@@ -14,7 +14,7 @@ export function ButtonLoginToken() {return (<Button- onClick={() => signIn()}+ onClick={() => signIn('auth-sign-up')}variant="textTernary"className={extraClassName}>diff --git a/apps/docs/src/utils/useSignIn.tsx b/apps/docs/src/utils/useSignIn.tsxindex f70d93472..e784c8c15 100644--- a/apps/docs/src/utils/useSignIn.tsx+++ b/apps/docs/src/utils/useSignIn.tsx@@ -1,17 +1,15 @@'use client'-import { createClientComponentClient } from '@supabase/auth-helpers-nextjs'+import { useRouter } from 'next/navigation'// TODO: Maybe consolidate with useUser?export function useSignIn() {- const supabase = createClientComponentClient()- return async function signInWithGitHub() {- await supabase.auth.signInWithOAuth({- provider: 'github',- options: {- redirectTo: window.location.href,- scopes: 'email',- },- })+ const router = useRouter()++ return function signIn(hash?: string) {+ router.push('/sign')+ if (hash) {+ router.push(`#${hash}`)+ }}}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex f24938789..b80e8e421 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -63,11 +63,17 @@ importers:'@supabase/auth-helpers-nextjs':specifier: ^0.7.4version: 0.7.4(@supabase/[email protected])+ '@supabase/auth-ui-react':+ specifier: ^0.4.7+ version: 0.4.7(@supabase/[email protected])+ '@supabase/auth-ui-shared':+ specifier: ^0.1.8+ version: 0.1.8(@supabase/[email protected])'@supabase/supabase-auth-helpers':specifier: ^1.4.2version: 1.4.2'@supabase/supabase-js':- specifier: ^2.32.0+ specifier: ^2.36.0version: 2.36.0'@tailwindcss/typography':specifier: 0.5.9@@ -2560,6 +2566,10 @@ packages:p-map: 4.0.0dev: true+ /@stitches/[email protected]:+ resolution: {integrity: sha512-Gfkvwk9o9kE9r9XNBmJRfV8zONvXThnm1tcuojL04Uy5uRyqg93DC83lDebl0rocZCfKSjUv+fWYtMQmEDJldg==}+ dev: false+/@stylistic/[email protected]([email protected]):resolution: {integrity: sha512-ndT6X2KgWGxv8101pdMOxL8pihlYIHcOv3ICd70cgaJ9exwkPn8hJj4YQwslxoAlre1TFHnXd/G1/hYXgDrjIA==}engines: {node: ^16.0.0 || >=18.0.0}@@ -2608,6 +2618,27 @@ packages:jose: 4.14.6dev: false+ /@supabase/[email protected](@supabase/[email protected]):+ resolution: {integrity: sha512-Lp4FQGFh7BMX1Y/BFaUKidbryL7eskj1fl6Lby7BeHrTctbdvDbCMjVKS8wZ2rxuI8FtPS2iU900fSb70FHknQ==}+ peerDependencies:+ '@supabase/supabase-js': ^2.21.0+ dependencies:+ '@stitches/core': 1.2.8+ '@supabase/auth-ui-shared': 0.1.8(@supabase/[email protected])+ '@supabase/supabase-js': 2.36.0+ prop-types: 15.8.1+ react: 18.2.0+ react-dom: 18.2.0([email protected])+ dev: false++ /@supabase/[email protected](@supabase/[email protected]):+ resolution: {integrity: sha512-ouQ0DjKcEFg+0gZigFIEgu01V3e6riGZPzgVD0MJsCBNsMsiDT74+GgCEIElMUpTGkwSja3xLwdFRFgMNFKcjg==}+ peerDependencies:+ '@supabase/supabase-js': ^2.21.0+ dependencies:+ '@supabase/supabase-js': 2.36.0+ dev: false+/@supabase/[email protected]:resolution: {integrity: sha512-yYVgkECjv7IZEBKBI3EB5Q7R1p0FJ10g8Q9N7SWKIHUU6i6DnbEGHIMFLyQRm1hmiNWD8fL7bRVEYacmTRJhHw==}dependencies: