Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

add get api key page [wip]

Vasek Mlejnsky86960e76fad7
diff --git a/apps/docs/src/app/getting-started/api-key/APIKey.tsx b/apps/docs/src/app/getting-started/api-key/APIKey.tsx
index 457ed3670..b2ff4ce27 100644
--- a/apps/docs/src/app/getting-started/api-key/APIKey.tsx
+++ b/apps/docs/src/app/getting-started/api-key/APIKey.tsx
@@ -1,15 +1,42 @@
+'use client'
+
import { Button } from '@/components/Button'
import { useApiKey, useUser } from '@/utils/useUser'
+import { obfuscateKey } from '@/utils/obfuscate'
+import { createClientComponentClient } from '@supabase/auth-helpers-nextjs'
function APIKey() {
+ const supabase = createClientComponentClient()
const { user, isLoading, error } = useUser()
const apiKey = useApiKey()
+ async function signInWithGitHub() {
+ await supabase.auth.signInWithOAuth({
+ // redirect to GitHub
+ provider: 'github',
+ options: {
+ redirectTo: window.location.href,
+ scopes: 'email',
+ },
+ })
+ }
+
return (
- <div className="flex flex-col min-[540px]:flex-row items-center gap-4">
- You can get your API key by signing up.
- {/* @ts-ignore */}
- <Button children="Sign up to get your API key" />
+ <div className="flex flex-col items-start justify-start space-y-4">
+ {user ? (
+ <>
+ <span className="whitespace-nowrap text-zinc-400 group-hover:opacity-25">
+ API key
+ </span>
+ </>
+ ) : (
+ <>
+ <span>You can get your API key by signing up.</span>
+ <Button onClick={signInWithGitHub}>
+ Sign up to get your API key
+ </Button>
+ </>
+ )}
</div>
)
}
diff --git a/apps/docs/src/app/getting-started/api-key/page.mdx b/apps/docs/src/app/getting-started/api-key/page.mdx
index a23ea7d47..7253b26df 100644
--- a/apps/docs/src/app/getting-started/api-key/page.mdx
+++ b/apps/docs/src/app/getting-started/api-key/page.mdx
@@ -1,7 +1,7 @@
+import APIKey from './APIKey'
+
# Your API Key
-You can get your API key by signing up.
-<Button children="Sign up to get your API key" />
+<APIKey/>
Follow the [Basics](/getting-started/basics) to start using the SDK.
-
diff --git a/apps/docs/src/components/Auth.tsx b/apps/docs/src/components/Auth.tsx
index b273681f8..c77418095 100644
--- a/apps/docs/src/components/Auth.tsx
+++ b/apps/docs/src/components/Auth.tsx
@@ -7,6 +7,7 @@ import { CopyButton } from '@/components/CopyButton'
import clsx from 'clsx'
import { HeaderSeparator } from '@/components/HeaderUtils'
import { usePostHog } from 'posthog-js/react'
+import { obfuscateKey } from '@/utils/obfuscate'
export const Auth = function () {
const { user, isLoading, error } = useUser()
@@ -17,7 +18,7 @@ export const Auth = function () {
async function signInWithGitHub() {
await supabase.auth.signInWithOAuth({
- // redirect to GitHub
+ // Redirect to GitHub
provider: 'github',
options: {
redirectTo: window.location.href,
@@ -40,7 +41,7 @@ export const Auth = function () {
Something went wrong
</span>
{/* @ts-ignore */}
- <Button onClick={() => signInWithGitHub()}>Login</Button>
+ <Button onClick={() => signInWithGitHub()}>Sign In</Button>
</div>
)
@@ -108,23 +109,12 @@ export const Auth = function () {
variant="textTernary"
className="text-xs"
>
- Login to get your API key
+ Sign up to get your API key
</Button>
{/* @ts-ignore */}
- <Button onClick={() => signInWithGitHub()}>Login</Button>
+ <Button onClick={() => signInWithGitHub()}>Sign In</Button>
</div>
)}
</>
)
}
-
-/**
- * Obfuscate the API key by replacing the middle part with asterisks
- * @param {string} apiKey
- * @returns {string}
- */
-function obfuscateKey(apiKey) {
- return (
- apiKey.substring(0, 7) + '*'.repeat(4) + apiKey.substring(apiKey.length - 3)
- )
-}
diff --git a/apps/docs/src/components/ButtonLoginToken.tsx b/apps/docs/src/components/ButtonLoginToken.tsx
index bdaa770bd..a6c101b06 100644
--- a/apps/docs/src/components/ButtonLoginToken.tsx
+++ b/apps/docs/src/components/ButtonLoginToken.tsx
@@ -30,7 +30,7 @@ export function ButtonLoginToken() {
variant="textTernary"
className={extraClassName}
>
- Login to get your API key
+ Sign up to get your API key
</Button>
)
}
diff --git a/apps/docs/src/utils/obfuscate.tsx b/apps/docs/src/utils/obfuscate.tsx
new file mode 100644
index 000000000..dd30fb56d
--- /dev/null
+++ b/apps/docs/src/utils/obfuscate.tsx
@@ -0,0 +1,9 @@
+
+/**
+ * Obfuscate the API key by replacing the middle part with asterisks
+ */
+export function obfuscateKey(apiKey: string) {
+ return (
+ apiKey.substring(0, 7) + '*'.repeat(4) + apiKey.substring(apiKey.length - 3)
+ )
+}
\ No newline at end of file