From 1ad109f3bc73d9f1da455104ae37adf85a8c378a Mon Sep 17 00:00:00 2001 From: arcoraven Date: Thu, 22 May 2025 06:25:22 +0000 Subject: [PATCH] chore: update endpoint to rotate secret key (#7122) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## [Dashboard] Fix: Update Secret Key Rotation API Endpoint ## Notes for the reviewer This PR updates the secret key rotation functionality to use the new team-based API endpoint structure. The `rotateSecretKeyClient` function now requires both `teamId` and `projectId` parameters, and the API endpoint has been updated to follow the `/v1/teams/{teamId}/projects/{projectId}/rotate-secret-key` pattern. ## How to test Test the secret key rotation functionality in: 1. Project FTUX 2. Nebula FTUX 3. Project General Settings page Verify that the secret key can be successfully rotated in all these locations. ## Summary by CodeRabbit - **Refactor** - Updated secret key rotation to require both team and project identifiers for enhanced security and context. - Modified components to include team ID alongside project data, improving integration and user experience in project-related sections. --- ## PR-Codex overview This PR focuses on updating the handling of project and team identifiers in the `NebulaFTUX` and related components, enhancing the functionality for rotating secret keys by including the `teamId` alongside the `projectId`. ### Detailed summary - Added `teamId` prop to the `NebulaFTUX` component. - Passed `teamId` from `NebulaFTUX` to `SecretKeySection`. - Updated `rotateSecretKeyClient` to accept an object with `teamId` and `projectId`. - Modified the API call in `rotateSecretKeyClient` to use the new parameters. - Updated the `SecretKeySection` to handle the new `teamId` prop. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` --- apps/dashboard/src/@3rdweb-sdk/react/hooks/useApi.ts | 11 ++++++----- .../components/ProjectFTUX/ProjectFTUX.tsx | 1 + .../components/ProjectFTUX/SecretKeySection.tsx | 6 +++++- .../[team_slug]/[project_slug]/nebula/nebula-ftux.tsx | 2 ++ .../team/[team_slug]/[project_slug]/nebula/page.tsx | 1 + .../settings/ProjectGeneralSettingsPage.tsx | 5 ++++- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/apps/dashboard/src/@3rdweb-sdk/react/hooks/useApi.ts b/apps/dashboard/src/@3rdweb-sdk/react/hooks/useApi.ts index 3416042f95a..7ea8155c96b 100644 --- a/apps/dashboard/src/@3rdweb-sdk/react/hooks/useApi.ts +++ b/apps/dashboard/src/@3rdweb-sdk/react/hooks/useApi.ts @@ -322,13 +322,14 @@ export type RotateSecretKeyAPIReturnType = { }; }; -export async function rotateSecretKeyClient(projectId: string) { +export async function rotateSecretKeyClient(params: { + teamId: string; + projectId: string; +}) { const res = await apiServerProxy({ - pathname: "/v2/keys/rotate-secret-key", + pathname: `/v1/teams/${params.teamId}/projects/${params.projectId}/rotate-secret-key`, method: "POST", - body: JSON.stringify({ - projectId, - }), + body: JSON.stringify({}), headers: { "Content-Type": "application/json", }, diff --git a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/components/ProjectFTUX/ProjectFTUX.tsx b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/components/ProjectFTUX/ProjectFTUX.tsx index 9ae6bbe6150..2d2bc620d4e 100644 --- a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/components/ProjectFTUX/ProjectFTUX.tsx +++ b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/components/ProjectFTUX/ProjectFTUX.tsx @@ -63,6 +63,7 @@ function IntegrateAPIKeySection({ {secretKeyMasked && ( )} diff --git a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/components/ProjectFTUX/SecretKeySection.tsx b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/components/ProjectFTUX/SecretKeySection.tsx index 030811e0c33..87ac4a3af4d 100644 --- a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/components/ProjectFTUX/SecretKeySection.tsx +++ b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/components/ProjectFTUX/SecretKeySection.tsx @@ -6,6 +6,7 @@ import { RotateSecretKeyButton } from "../../settings/ProjectGeneralSettingsPage export function SecretKeySection(props: { secretKeyMasked: string; + teamId: string; projectId: string; }) { const [secretKeyMasked, setSecretKeyMasked] = useState(props.secretKeyMasked); @@ -26,7 +27,10 @@ export function SecretKeySection(props: { { - return rotateSecretKeyClient(props.projectId); + return rotateSecretKeyClient({ + teamId: props.teamId, + projectId: props.projectId, + }); }} onSuccess={(data) => { setSecretKeyMasked(data.data.secretMasked); diff --git a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/nebula/nebula-ftux.tsx b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/nebula/nebula-ftux.tsx index 305e83cce29..628f619c3f6 100644 --- a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/nebula/nebula-ftux.tsx +++ b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/nebula/nebula-ftux.tsx @@ -4,6 +4,7 @@ import { WaitingForIntegrationCard } from "../components/WaitingForIntegrationCa export function NebulaFTUX(props: { secretKeyMasked: string; + teamId: string; projectId: string; }) { return ( @@ -50,6 +51,7 @@ export function NebulaFTUX(props: { >
diff --git a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/nebula/page.tsx b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/nebula/page.tsx index 17d1d271d55..415fc0e1168 100644 --- a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/nebula/page.tsx +++ b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/nebula/page.tsx @@ -60,6 +60,7 @@ export default async function Page(props: {
diff --git a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/settings/ProjectGeneralSettingsPage.tsx b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/settings/ProjectGeneralSettingsPage.tsx index 49713dd352d..f6048818f6d 100644 --- a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/settings/ProjectGeneralSettingsPage.tsx +++ b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/settings/ProjectGeneralSettingsPage.tsx @@ -165,7 +165,10 @@ export function ProjectGeneralSettingsPage(props: { }} showNebulaSettings={props.showNebulaSettings} rotateSecretKey={async () => { - return rotateSecretKeyClient(props.project.id); + return rotateSecretKeyClient({ + teamId: props.project.teamId, + projectId: props.project.id, + }); }} teamsWithRole={props.teamsWithRole} transferProject={async (newTeam) => {