Skip to content

Commit 1ad109f

Browse files
committed
chore: update endpoint to rotate secret key (#7122)
## [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. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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. <!-- end of auto-generated comment: release notes by coderabbit.ai --> <!-- start pr-codex --> --- ## 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}` <!-- end pr-codex -->
1 parent 376bdb2 commit 1ad109f

File tree

6 files changed

+19
-7
lines changed

6 files changed

+19
-7
lines changed

apps/dashboard/src/@3rdweb-sdk/react/hooks/useApi.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,14 @@ export type RotateSecretKeyAPIReturnType = {
322322
};
323323
};
324324

325-
export async function rotateSecretKeyClient(projectId: string) {
325+
export async function rotateSecretKeyClient(params: {
326+
teamId: string;
327+
projectId: string;
328+
}) {
326329
const res = await apiServerProxy<RotateSecretKeyAPIReturnType>({
327-
pathname: "/v2/keys/rotate-secret-key",
330+
pathname: `/v1/teams/${params.teamId}/projects/${params.projectId}/rotate-secret-key`,
328331
method: "POST",
329-
body: JSON.stringify({
330-
projectId,
331-
}),
332+
body: JSON.stringify({}),
332333
headers: {
333334
"Content-Type": "application/json",
334335
},

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/components/ProjectFTUX/ProjectFTUX.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ function IntegrateAPIKeySection({
6363
{secretKeyMasked && (
6464
<SecretKeySection
6565
secretKeyMasked={secretKeyMasked}
66+
teamId={project.teamId}
6667
projectId={project.id}
6768
/>
6869
)}

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/components/ProjectFTUX/SecretKeySection.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { RotateSecretKeyButton } from "../../settings/ProjectGeneralSettingsPage
66

77
export function SecretKeySection(props: {
88
secretKeyMasked: string;
9+
teamId: string;
910
projectId: string;
1011
}) {
1112
const [secretKeyMasked, setSecretKeyMasked] = useState(props.secretKeyMasked);
@@ -26,7 +27,10 @@ export function SecretKeySection(props: {
2627

2728
<RotateSecretKeyButton
2829
rotateSecretKey={async () => {
29-
return rotateSecretKeyClient(props.projectId);
30+
return rotateSecretKeyClient({
31+
teamId: props.teamId,
32+
projectId: props.projectId,
33+
});
3034
}}
3135
onSuccess={(data) => {
3236
setSecretKeyMasked(data.data.secretMasked);

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/nebula/nebula-ftux.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { WaitingForIntegrationCard } from "../components/WaitingForIntegrationCa
44

55
export function NebulaFTUX(props: {
66
secretKeyMasked: string;
7+
teamId: string;
78
projectId: string;
89
}) {
910
return (
@@ -50,6 +51,7 @@ export function NebulaFTUX(props: {
5051
>
5152
<SecretKeySection
5253
secretKeyMasked={props.secretKeyMasked}
54+
teamId={props.teamId}
5355
projectId={props.projectId}
5456
/>
5557
<div className="h-4" />

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/nebula/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export default async function Page(props: {
6060
<div className="container mt-6 max-w-7xl">
6161
<NebulaFTUX
6262
secretKeyMasked={project.secretKeys[0]?.masked || ""}
63+
teamId={team.id}
6364
projectId={project.id}
6465
/>
6566
</div>

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/settings/ProjectGeneralSettingsPage.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,10 @@ export function ProjectGeneralSettingsPage(props: {
165165
}}
166166
showNebulaSettings={props.showNebulaSettings}
167167
rotateSecretKey={async () => {
168-
return rotateSecretKeyClient(props.project.id);
168+
return rotateSecretKeyClient({
169+
teamId: props.project.teamId,
170+
projectId: props.project.id,
171+
});
169172
}}
170173
teamsWithRole={props.teamsWithRole}
171174
transferProject={async (newTeam) => {

0 commit comments

Comments
 (0)