diff --git a/apps/dashboard/src/@/actions/vault.ts b/apps/dashboard/src/@/actions/vault.ts index 76421f45c9b..c2c2120f439 100644 --- a/apps/dashboard/src/@/actions/vault.ts +++ b/apps/dashboard/src/@/actions/vault.ts @@ -190,14 +190,26 @@ export async function createVaultServiceAccount(params: { return res.data.data; } +/** + * Rotates the project's vault admin key. + * + * `mode` is the state to leave the vault in. `managed` re-seals the new + * credentials with the project secret key and returns only the mask; `ejected` + * returns the admin key and wallet token once and keeps no copy. Omitting it + * keeps the vault as it is. + */ export async function rotateVaultServiceAccount(params: { project: ProjectRef; + mode?: "managed" | "ejected"; projectSecretKey?: string; }): Promise { const res = await apiServerProxy<{ data: RotateVaultServiceAccountResult; }>({ - body: JSON.stringify({ projectSecretKey: params.projectSecretKey }), + body: JSON.stringify({ + mode: params.mode, + projectSecretKey: params.projectSecretKey, + }), headers: { "Content-Type": "application/json" }, method: "POST", pathname: vaultPath(params.project, "/service-account/rotate"), diff --git a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/vault/components/rotate-admin-key.client.tsx b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/vault/components/rotate-admin-key.client.tsx index dcc8b831f23..4dbe75513ac 100644 --- a/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/vault/components/rotate-admin-key.client.tsx +++ b/apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/vault/components/rotate-admin-key.client.tsx @@ -48,6 +48,7 @@ export default function RotateAdminKeyButton(props: { const rotateAdminKeyMutation = useMutation({ mutationFn: async () => { return rotateVaultServiceAccount({ + mode: stayManaged ? "managed" : "ejected", project: { projectId: props.project.id, teamId: props.project.teamId,