Skip to content

Commit 1d598ce

Browse files
committed
Nebula: Use Nebula project keys (#6839)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on updating the authentication and client configuration for the `Nebula` application by replacing the usage of the `DASHBOARD_THIRDWEB_SECRET_KEY` with `NEBULA_APP_SECRET_KEY`, and modifying the thirdweb client setup. ### Detailed summary - Added `NEXT_PUBLIC_NEBULA_APP_CLIENT_ID` and `NEBULA_APP_SECRET_KEY` to `env.ts`. - Replaced `nebulaThirdwebClient` with `nebulaAppThirdwebClient` in `EmptyStateChatPageContent.tsx`. - Updated headers in `auth-actions.ts` to use `NEBULA_APP_SECRET_KEY`. - Refactored `nebulaThirdwebClient.ts` to create a new client using `NEBULA_APP_SECRET_KEY` and `NEXT_PUBLIC_NEBULA_APP_CLIENT_ID`. - Updated `NebulaConnectWallet` component to use `nebulaAppThirdwebClient`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent f157e34 commit 1d598ce

File tree

5 files changed

+57
-14
lines changed

5 files changed

+57
-14
lines changed

apps/dashboard/src/@/constants/env.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ export const DASHBOARD_THIRDWEB_CLIENT_ID =
44
export const DASHBOARD_THIRDWEB_SECRET_KEY =
55
process.env.DASHBOARD_SECRET_KEY || "";
66

7+
export const NEXT_PUBLIC_NEBULA_APP_CLIENT_ID =
8+
process.env.NEXT_PUBLIC_NEBULA_APP_CLIENT_ID || "";
9+
10+
export const NEBULA_APP_SECRET_KEY = process.env.NEBULA_APP_SECRET_KEY || "";
11+
712
export const THIRDWEB_API_SECRET = process.env.API_SERVER_SECRET || "";
813

914
export const IPFS_GATEWAY_URL =

apps/dashboard/src/app/nebula-app/(app)/components/EmptyStateChatPageContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ArrowUpRightIcon } from "lucide-react";
55
import type { NebulaContext } from "../api/chat";
66
import { examplePrompts } from "../data/examplePrompts";
77
import { NebulaIcon } from "../icons/NebulaIcon";
8-
import { nebulaThirdwebClient } from "../utils/nebulaThirdwebClient";
8+
import { nebulaAppThirdwebClient } from "../utils/nebulaThirdwebClient";
99
import { ChatBar, type WalletMeta } from "./ChatBar";
1010

1111
export function EmptyStateChatPageContent(props: {
@@ -42,7 +42,7 @@ export function EmptyStateChatPageContent(props: {
4242
setContext={props.setContext}
4343
sendMessage={props.sendMessage}
4444
isChatStreaming={false}
45-
client={nebulaThirdwebClient}
45+
client={nebulaAppThirdwebClient}
4646
connectedWallets={props.connectedWallets}
4747
activeAccountAddress={props.activeAccountAddress}
4848
setActiveWallet={props.setActiveWallet}

apps/dashboard/src/app/nebula-app/(app)/components/NebulaConnectButton.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import { Spinner } from "@/components/ui/Spinner/Spinner";
44
import { Button } from "@/components/ui/button";
5-
import { useThirdwebClient } from "@/constants/thirdweb.client";
65
import { useDashboardRouter } from "@/lib/DashboardRouter";
6+
import { cn } from "@/lib/utils";
77
import { getSDKTheme } from "app/(app)/components/sdk-component-theme";
88
import { useAllChainsData } from "hooks/chains/allChains";
99
import { useTheme } from "next-themes";
@@ -14,15 +14,14 @@ import {
1414
useActiveAccount,
1515
useActiveWalletConnectionStatus,
1616
} from "thirdweb/react";
17-
import { cn } from "../../../../@/lib/utils";
1817
import { doNebulaLogout } from "../../login/auth-actions";
18+
import { nebulaAppThirdwebClient } from "../utils/nebulaThirdwebClient";
1919

2020
export const NebulaConnectWallet = (props: {
2121
connectButtonClassName?: string;
2222
signInLinkButtonClassName?: string;
2323
detailsButtonClassName?: string;
2424
}) => {
25-
const thirdwebClient = useThirdwebClient();
2625
const router = useDashboardRouter();
2726
const { theme } = useTheme();
2827
const t = theme === "light" ? "light" : "dark";
@@ -67,7 +66,7 @@ export const NebulaConnectWallet = (props: {
6766
return (
6867
<ConnectButton
6968
theme={getSDKTheme(t)}
70-
client={thirdwebClient}
69+
client={nebulaAppThirdwebClient}
7170
connectModal={{
7271
privacyPolicyUrl: "/privacy-policy",
7372
termsOfServiceUrl: "/terms",
Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1-
import { getThirdwebClient } from "@/constants/thirdweb.server";
1+
import {
2+
IPFS_GATEWAY_URL,
3+
NEBULA_APP_SECRET_KEY,
4+
NEXT_PUBLIC_NEBULA_APP_CLIENT_ID,
5+
} from "@/constants/env";
6+
import {
7+
THIRDWEB_BUNDLER_DOMAIN,
8+
THIRDWEB_INAPP_WALLET_DOMAIN,
9+
THIRDWEB_INSIGHT_API_DOMAIN,
10+
THIRDWEB_PAY_DOMAIN,
11+
THIRDWEB_RPC_DOMAIN,
12+
THIRDWEB_SOCIAL_API_DOMAIN,
13+
THIRDWEB_STORAGE_DOMAIN,
14+
} from "constants/urls";
15+
import { createThirdwebClient } from "thirdweb";
16+
import { setThirdwebDomains } from "thirdweb/utils";
17+
import { getVercelEnv } from "../../../../lib/vercel-utils";
218

3-
export const nebulaThirdwebClient = getThirdwebClient(undefined);
19+
// returns a thirdweb client with optional JWT passed in
20+
function getThirdwebClient() {
21+
if (getVercelEnv() !== "production") {
22+
// if not on production: run this when creating a client to set the domains
23+
setThirdwebDomains({
24+
rpc: THIRDWEB_RPC_DOMAIN,
25+
inAppWallet: THIRDWEB_INAPP_WALLET_DOMAIN,
26+
pay: THIRDWEB_PAY_DOMAIN,
27+
storage: THIRDWEB_STORAGE_DOMAIN,
28+
social: THIRDWEB_SOCIAL_API_DOMAIN,
29+
bundler: THIRDWEB_BUNDLER_DOMAIN,
30+
insight: THIRDWEB_INSIGHT_API_DOMAIN,
31+
});
32+
}
33+
34+
return createThirdwebClient({
35+
secretKey: NEBULA_APP_SECRET_KEY,
36+
clientId: NEXT_PUBLIC_NEBULA_APP_CLIENT_ID,
37+
config: {
38+
storage: {
39+
gatewayUrl: IPFS_GATEWAY_URL,
40+
},
41+
},
42+
});
43+
}
44+
45+
export const nebulaAppThirdwebClient = getThirdwebClient();

apps/dashboard/src/app/nebula-app/login/auth-actions.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
"use server";
22
import "server-only";
33

4-
import {
5-
DASHBOARD_THIRDWEB_SECRET_KEY,
6-
NEXT_PUBLIC_NEBULA_URL,
7-
} from "@/constants/env";
4+
import { NEBULA_APP_SECRET_KEY, NEXT_PUBLIC_NEBULA_URL } from "@/constants/env";
85
import { isVercel } from "lib/vercel-utils";
96
import { cookies } from "next/headers";
107
import { getAddress } from "thirdweb";
@@ -26,7 +23,7 @@ export async function getNebulaLoginPayload(
2623
method: "POST",
2724
headers: {
2825
"Content-Type": "application/json",
29-
"X-Secret-Key": DASHBOARD_THIRDWEB_SECRET_KEY,
26+
"X-Secret-Key": NEBULA_APP_SECRET_KEY,
3027
},
3128
body: JSON.stringify({
3229
address: params.address,
@@ -70,7 +67,7 @@ export async function doNebulaLogin(
7067
method: "POST",
7168
headers: {
7269
"Content-Type": "application/json",
73-
"X-Secret-Key": DASHBOARD_THIRDWEB_SECRET_KEY,
70+
"X-Secret-Key": NEBULA_APP_SECRET_KEY,
7471
},
7572
body: JSON.stringify(payload),
7673
});

0 commit comments

Comments
 (0)