Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion apps/dashboard/src/@/actions/vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<RotateVaultServiceAccountResult> {
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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading