feat: ui removed all private key except secret rotation to raw endpoints version

This commit is contained in:
=
2024-07-30 23:19:05 +05:30
parent d4747abba8
commit b7b0e60b1d
12 changed files with 66 additions and 200 deletions
@@ -13,15 +13,13 @@ import {
import { apiRequest } from "@app/config/request"; import { apiRequest } from "@app/config/request";
import { UserWsKeyPair } from "../keys/types"; import { UserWsKeyPair } from "../keys/types";
import { EncryptedSecret, SecretType,SecretV3RawSanitized } from "../secrets/types"; import { EncryptedSecret, SecretType, SecretV3RawSanitized } from "../secrets/types";
import { import {
CommitType,
TGetSecretApprovalRequestCount, TGetSecretApprovalRequestCount,
TGetSecretApprovalRequestDetails, TGetSecretApprovalRequestDetails,
TGetSecretApprovalRequestList, TGetSecretApprovalRequestList,
TSecretApprovalRequest, TSecretApprovalRequest,
TSecretApprovalRequestCount, TSecretApprovalRequestCount
TSecretApprovalSecChangeData
} from "./types"; } from "./types";
export const secretApprovalRequestKeys = { export const secretApprovalRequestKeys = {
@@ -117,48 +115,6 @@ export const decryptSecrets = (
return secrets; return secrets;
}; };
export const decryptSecretApprovalSecret = (
encSecret: TSecretApprovalSecChangeData,
decryptFileKey: UserWsKeyPair
) => {
const PRIVATE_KEY = localStorage.getItem("PRIVATE_KEY") as string;
const key = decryptAssymmetric({
ciphertext: decryptFileKey.encryptedKey,
nonce: decryptFileKey.nonce,
publicKey: decryptFileKey.sender.publicKey,
privateKey: PRIVATE_KEY
});
const secretKey = decryptSymmetric({
ciphertext: encSecret.secretKeyCiphertext,
iv: encSecret.secretKeyIV,
tag: encSecret.secretKeyTag,
key
});
const secretValue = decryptSymmetric({
ciphertext: encSecret.secretValueCiphertext,
iv: encSecret.secretValueIV,
tag: encSecret.secretValueTag,
key
});
const secretComment = decryptSymmetric({
ciphertext: encSecret.secretCommentCiphertext,
iv: encSecret.secretCommentIV,
tag: encSecret.secretCommentTag,
key
});
return {
id: encSecret.id,
version: encSecret.version,
secretKey,
secretValue,
secretComment,
tags: encSecret.tags
};
};
const fetchSecretApprovalRequestList = async ({ const fetchSecretApprovalRequestList = async ({
workspaceId, workspaceId,
environment, environment,
@@ -245,7 +201,7 @@ export const useGetSecretApprovalRequestDetails = ({
UseQueryOptions< UseQueryOptions<
TSecretApprovalRequest, TSecretApprovalRequest,
unknown, unknown,
TSecretApprovalRequest<SecretV3RawSanitized>, TSecretApprovalRequest,
ReturnType<typeof secretApprovalRequestKeys.detail> ReturnType<typeof secretApprovalRequestKeys.detail>
>, >,
"queryKey" | "queryFn" "queryKey" | "queryFn"
@@ -254,16 +210,6 @@ export const useGetSecretApprovalRequestDetails = ({
useQuery({ useQuery({
queryKey: secretApprovalRequestKeys.detail({ id }), queryKey: secretApprovalRequestKeys.detail({ id }),
queryFn: () => fetchSecretApprovalRequestDetails({ id }), queryFn: () => fetchSecretApprovalRequestDetails({ id }),
select: (data) => ({
...data,
commits: data.commits.map(({ secretVersion, op, secret, ...newVersion }) => ({
op,
secret,
secretVersion: secretVersion ? decryptSecrets([secretVersion], decryptKey)[0] : undefined,
newVersion:
op !== CommitType.DELETE ? decryptSecretApprovalSecret(newVersion, decryptKey) : undefined
}))
}),
enabled: Boolean(id && decryptKey) && (options?.enabled ?? true) enabled: Boolean(id && decryptKey) && (options?.enabled ?? true)
}); });
@@ -1,6 +1,6 @@
import { UserWsKeyPair } from "../keys/types"; import { UserWsKeyPair } from "../keys/types";
import { TSecretApprovalPolicy } from "../secretApproval/types"; import { TSecretApprovalPolicy } from "../secretApproval/types";
import { EncryptedSecret } from "../secrets/types"; import { SecretV3Raw } from "../secrets/types";
import { WsTag } from "../tags/types"; import { WsTag } from "../tags/types";
export enum ApprovalStatus { export enum ApprovalStatus {
@@ -17,15 +17,9 @@ export enum CommitType {
export type TSecretApprovalSecChangeData = { export type TSecretApprovalSecChangeData = {
id: string; id: string;
secretKeyCiphertext: string; secretKey: string;
secretKeyIV: string; secretValue?: string;
secretKeyTag: string; secretComment?: string;
secretValueCiphertext: string;
secretValueIV: string;
secretValueTag: string;
secretCommentIV: string;
secretCommentTag: string;
secretCommentCiphertext: string;
skipMultilineEncoding?: boolean; skipMultilineEncoding?: boolean;
algorithm: "aes-256-gcm"; algorithm: "aes-256-gcm";
keyEncoding: "utf8" | "base64"; keyEncoding: "utf8" | "base64";
@@ -37,12 +31,12 @@ export type TSecretApprovalSecChange = {
id: string; id: string;
version: number; version: number;
secretKey: string; secretKey: string;
secretValue: string; secretValue?: string;
secretComment: string; secretComment?: string;
tags?: string[]; tags?: string[];
}; };
export type TSecretApprovalRequest<J extends unknown = EncryptedSecret> = { export type TSecretApprovalRequest = {
id: string; id: string;
isReplicated?: boolean; isReplicated?: boolean;
slug: string; slug: string;
@@ -90,7 +84,7 @@ export type TSecretApprovalRequest<J extends unknown = EncryptedSecret> = {
commits: ({ commits: ({
// if there is no secret means it was creation // if there is no secret means it was creation
secret?: { version: number }; secret?: { version: number };
secretVersion: J; secretVersion: SecretV3Raw;
// if there is no new version its for Delete // if there is no new version its for Delete
op: CommitType; op: CommitType;
} & TSecretApprovalSecChangeData)[]; } & TSecretApprovalSecChangeData)[];
@@ -1,13 +1,9 @@
/* eslint-disable no-param-reassign */ /* eslint-disable no-param-reassign */
import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import {
decryptAssymmetric,
decryptSymmetric
} from "@app/components/utilities/cryptography/crypto";
import { apiRequest } from "@app/config/request"; import { apiRequest } from "@app/config/request";
import { SecretType,SecretV3RawSanitized } from "../secrets/types"; import { SecretType, SecretV3RawSanitized } from "../secrets/types";
import { import {
TGetSecretSnapshotsDTO, TGetSecretSnapshotsDTO,
TSecretRollbackDTO, TSecretRollbackDTO,
@@ -65,55 +61,33 @@ const fetchSnapshotEncSecrets = async (snapshotId: string) => {
return res.data.secretSnapshot; return res.data.secretSnapshot;
}; };
export const useGetSnapshotSecrets = ({ decryptFileKey, snapshotId }: TSnapshotDataProps) => export const useGetSnapshotSecrets = ({ snapshotId }: TSnapshotDataProps) =>
useQuery({ useQuery({
queryKey: secretSnapshotKeys.snapshotData(snapshotId), queryKey: secretSnapshotKeys.snapshotData(snapshotId),
enabled: Boolean(snapshotId && decryptFileKey), enabled: Boolean(snapshotId),
queryFn: () => fetchSnapshotEncSecrets(snapshotId), queryFn: () => fetchSnapshotEncSecrets(snapshotId),
select: (data) => { select: (data) => {
const PRIVATE_KEY = localStorage.getItem("PRIVATE_KEY") as string;
const latestKey = decryptFileKey;
const key = decryptAssymmetric({
ciphertext: latestKey.encryptedKey,
nonce: latestKey.nonce,
publicKey: latestKey.sender.publicKey,
privateKey: PRIVATE_KEY
});
const sharedSecrets: SecretV3RawSanitized[] = []; const sharedSecrets: SecretV3RawSanitized[] = [];
const personalSecrets: Record<string, { id: string; value: string }> = {}; const personalSecrets: Record<string, { id: string; value: string }> = {};
data.secretVersions.forEach((encSecret) => { data.secretVersions.forEach((secretVersion) => {
const secretKey = decryptSymmetric({
ciphertext: encSecret.secretKeyCiphertext,
iv: encSecret.secretKeyIV,
tag: encSecret.secretKeyTag,
key
});
const secretValue = decryptSymmetric({
ciphertext: encSecret.secretValueCiphertext,
iv: encSecret.secretValueIV,
tag: encSecret.secretValueTag,
key
});
const secretComment = "";
const decryptedSecret = { const decryptedSecret = {
id: encSecret.secretId, id: secretVersion.secretId,
env: data.environment.slug, env: data.environment.slug,
key: secretKey, key: secretVersion.secretKey,
value: secretValue, value: secretVersion.secretValue || "",
tags: encSecret.tags, tags: secretVersion.tags,
comment: secretComment, comment: secretVersion.secretComment,
createdAt: encSecret.createdAt, createdAt: secretVersion.createdAt,
updatedAt: encSecret.updatedAt, updatedAt: secretVersion.updatedAt,
type: "modified", type: "modified",
version: encSecret.version version: secretVersion.version
}; };
if (encSecret.type === SecretType.Personal) { if (secretVersion.type === SecretType.Personal) {
personalSecrets[decryptedSecret.key] = { id: encSecret.secretId, value: secretValue }; personalSecrets[decryptedSecret.key] = {
id: secretVersion.secretId,
value: secretVersion.secretValue || ""
};
} else { } else {
sharedSecrets.push(decryptedSecret); sharedSecrets.push(decryptedSecret);
} }
@@ -1,5 +1,4 @@
import { UserWsKeyPair } from "../keys/types"; import { SecretVersions } from "../secrets/types";
import { EncryptedSecretVersion } from "../secrets/types";
import { WorkspaceEnv } from "../types"; import { WorkspaceEnv } from "../types";
export type TSecretSnapshot = { export type TSecretSnapshot = {
@@ -12,7 +11,7 @@ export type TSecretSnapshot = {
export type TSnapshotData = Omit<TSecretSnapshot, "secretVersions"> & { export type TSnapshotData = Omit<TSecretSnapshot, "secretVersions"> & {
id: string; id: string;
secretVersions: EncryptedSecretVersion[]; secretVersions: SecretVersions[];
folderVersion: Array<{ name: string; id: string }>; folderVersion: Array<{ name: string; id: string }>;
environment: WorkspaceEnv; environment: WorkspaceEnv;
}; };
@@ -20,7 +19,6 @@ export type TSnapshotData = Omit<TSecretSnapshot, "secretVersions"> & {
export type TSnapshotDataProps = { export type TSnapshotDataProps = {
snapshotId: string; snapshotId: string;
env: string; env: string;
decryptFileKey: UserWsKeyPair;
}; };
export type TGetSecretSnapshotsDTO = { export type TGetSecretSnapshotsDTO = {
+6 -33
View File
@@ -2,19 +2,15 @@
import { useCallback, useMemo } from "react"; import { useCallback, useMemo } from "react";
import { useQueries, useQuery, UseQueryOptions } from "@tanstack/react-query"; import { useQueries, useQuery, UseQueryOptions } from "@tanstack/react-query";
import {
decryptAssymmetric,
decryptSymmetric
} from "@app/components/utilities/cryptography/crypto";
import { apiRequest } from "@app/config/request"; import { apiRequest } from "@app/config/request";
import { import {
EncryptedSecretVersion,
GetSecretVersionsDTO, GetSecretVersionsDTO,
SecretType, SecretType,
SecretV3Raw, SecretV3Raw,
SecretV3RawResponse, SecretV3RawResponse,
SecretV3RawSanitized, SecretV3RawSanitized,
SecretVersions,
TGetProjectSecretsAllEnvDTO, TGetProjectSecretsAllEnvDTO,
TGetProjectSecretsDTO, TGetProjectSecretsDTO,
TGetProjectSecretsKey TGetProjectSecretsKey
@@ -166,7 +162,7 @@ export const useGetProjectSecretsAllEnv = ({
}; };
const fetchEncryptedSecretVersion = async (secretId: string, offset: number, limit: number) => { const fetchEncryptedSecretVersion = async (secretId: string, offset: number, limit: number) => {
const { data } = await apiRequest.get<{ secretVersions: EncryptedSecretVersion[] }>( const { data } = await apiRequest.get<{ secretVersions: SecretVersions[] }>(
`/api/v1/secret/${secretId}/secret-versions`, `/api/v1/secret/${secretId}/secret-versions`,
{ {
params: { params: {
@@ -180,33 +176,10 @@ const fetchEncryptedSecretVersion = async (secretId: string, offset: number, lim
export const useGetSecretVersion = (dto: GetSecretVersionsDTO) => export const useGetSecretVersion = (dto: GetSecretVersionsDTO) =>
useQuery({ useQuery({
enabled: Boolean(dto.secretId && dto.decryptFileKey), enabled: Boolean(dto.secretId),
queryKey: secretKeys.getSecretVersion(dto.secretId), queryKey: secretKeys.getSecretVersion(dto.secretId),
queryFn: () => fetchEncryptedSecretVersion(dto.secretId, dto.offset, dto.limit), queryFn: () => fetchEncryptedSecretVersion(dto.secretId, dto.offset, dto.limit),
select: useCallback( select: useCallback((data: SecretVersions[]) => {
(data: EncryptedSecretVersion[]) => { return data.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
const PRIVATE_KEY = localStorage.getItem("PRIVATE_KEY") as string; }, [])
const latestKey = dto.decryptFileKey;
const key = decryptAssymmetric({
ciphertext: latestKey.encryptedKey,
nonce: latestKey.nonce,
publicKey: latestKey.sender.publicKey,
privateKey: PRIVATE_KEY
});
return data
.map((el) => ({
createdAt: el.createdAt,
id: el.id,
value: decryptSymmetric({
ciphertext: el.secretValueCiphertext,
iv: el.secretValueIV,
tag: el.secretValueTag,
key
})
}))
.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
},
[dto.decryptFileKey]
)
}); });
+4 -9
View File
@@ -1,4 +1,3 @@
import type { UserWsKeyPair } from "../keys/types";
import type { WsTag } from "../tags/types"; import type { WsTag } from "../tags/types";
export enum SecretType { export enum SecretType {
@@ -79,7 +78,7 @@ export type SecretV3RawResponse = {
}[]; }[];
}; };
export type EncryptedSecretVersion = { export type SecretVersions = {
id: string; id: string;
secretId: string; secretId: string;
version: number; version: number;
@@ -87,12 +86,9 @@ export type EncryptedSecretVersion = {
type: SecretType; type: SecretType;
isDeleted: boolean; isDeleted: boolean;
envId: string; envId: string;
secretKeyCiphertext: string; secretKey: string;
secretKeyIV: string; secretValue?: string;
secretKeyTag: string; secretComment?: string;
secretValueCiphertext: string;
secretValueIV: string;
secretValueTag: string;
tags: WsTag[]; tags: WsTag[];
__v: number; __v: number;
skipMultilineEncoding?: boolean; skipMultilineEncoding?: boolean;
@@ -123,7 +119,6 @@ export type GetSecretVersionsDTO = {
secretId: string; secretId: string;
limit: number; limit: number;
offset: number; offset: number;
decryptFileKey: UserWsKeyPair;
}; };
export type TCreateSecretsV3DTO = { export type TCreateSecretsV3DTO = {
@@ -13,16 +13,11 @@ import {
Tooltip, Tooltip,
Tr Tr
} from "@app/components/v2"; } from "@app/components/v2";
import { import { CommitType, SecretV3Raw, TSecretApprovalSecChange, WsTag } from "@app/hooks/api/types";
CommitType,
SecretV3RawSanitized,
TSecretApprovalSecChange,
WsTag
} from "@app/hooks/api/types";
export type Props = { export type Props = {
op: CommitType; op: CommitType;
secretVersion?: SecretV3RawSanitized; secretVersion?: SecretV3Raw;
newVersion?: Omit<TSecretApprovalSecChange, "tags"> & { tags?: WsTag[] }; newVersion?: Omit<TSecretApprovalSecChange, "tags"> & { tags?: WsTag[] };
presentSecretVersionNumber: number; presentSecretVersionNumber: number;
hasMerged?: Boolean; hasMerged?: Boolean;
@@ -96,11 +91,11 @@ export const SecretApprovalRequestChangeItem = ({
<TBody> <TBody>
<Tr> <Tr>
<Td className="text-red-600">OLD</Td> <Td className="text-red-600">OLD</Td>
<Td>{secretVersion?.key}</Td> <Td>{secretVersion?.secretKey}</Td>
<Td> <Td>
<SecretInput isReadOnly value={secretVersion?.value} /> <SecretInput isReadOnly value={secretVersion?.secretValue} />
</Td> </Td>
<Td>{secretVersion?.comment}</Td> <Td>{secretVersion?.secretComment}</Td>
<Td> <Td>
{secretVersion?.tags?.map(({ name, id: tagId, color }) => ( {secretVersion?.tags?.map(({ name, id: tagId, color }) => (
<Tag <Tag
@@ -142,17 +137,23 @@ export const SecretApprovalRequestChangeItem = ({
) : ( ) : (
<TBody> <TBody>
<Tr> <Tr>
<Td>{op === CommitType.CREATE ? newVersion?.secretKey : secretVersion?.key}</Td> <Td>
{op === CommitType.CREATE ? newVersion?.secretKey : secretVersion?.secretKey}
</Td>
<Td> <Td>
<SecretInput <SecretInput
isReadOnly isReadOnly
value={ value={
op === CommitType.CREATE ? newVersion?.secretValue : secretVersion?.value op === CommitType.CREATE
? newVersion?.secretValue
: secretVersion?.secretValue
} }
/> />
</Td> </Td>
<Td> <Td>
{op === CommitType.CREATE ? newVersion?.secretComment : secretVersion?.comment} {op === CommitType.CREATE
? newVersion?.secretComment
: secretVersion?.secretComment}
</Td> </Td>
<Td> <Td>
{(op === CommitType.CREATE ? newVersion?.tags : secretVersion?.tags)?.map( {(op === CommitType.CREATE ? newVersion?.tags : secretVersion?.tags)?.map(
@@ -230,7 +230,7 @@ export const SecretApprovalRequestChanges = ({
</div> </div>
<div className="flex flex-col space-y-4"> <div className="flex flex-col space-y-4">
{secretApprovalRequestDetails.commits.map( {secretApprovalRequestDetails.commits.map(
({ op, secretVersion, secret, newVersion }, index) => ( ({ op, secretVersion, secret, ...newVersion }, index) => (
<SecretApprovalRequestChangeItem <SecretApprovalRequestChangeItem
op={op} op={op}
conflicts={secretApprovalRequestDetails.conflicts} conflicts={secretApprovalRequestDetails.conflicts}
@@ -269,8 +269,9 @@ export const SecretApprovalRequestChanges = ({
> >
<div className="flex-grow text-sm"> <div className="flex-grow text-sm">
<Tooltip <Tooltip
content={`${requiredApprover.firstName || ""} ${requiredApprover.lastName || "" content={`${requiredApprover.firstName || ""} ${
}`} requiredApprover.lastName || ""
}`}
> >
<span>{requiredApprover?.email} </span> <span>{requiredApprover?.email} </span>
</Tooltip> </Tooltip>
@@ -23,13 +23,11 @@ import {
useGetProjectSecrets, useGetProjectSecrets,
useGetSecretApprovalPolicyOfABoard, useGetSecretApprovalPolicyOfABoard,
useGetSecretImports, useGetSecretImports,
useGetUserWsKey,
useGetWorkspaceSnapshotList, useGetWorkspaceSnapshotList,
useGetWsSnapshotCount, useGetWsSnapshotCount,
useGetWsTags useGetWsTags
} from "@app/hooks/api"; } from "@app/hooks/api";
import { ProjectIndexSecretsSection } from "../SecretOverviewPage/components/ProjectIndexSecretsSection";
import { ActionBar } from "./components/ActionBar"; import { ActionBar } from "./components/ActionBar";
import { CreateSecretForm } from "./components/CreateSecretForm"; import { CreateSecretForm } from "./components/CreateSecretForm";
import { DynamicSecretListView } from "./components/DynamicSecretListView"; import { DynamicSecretListView } from "./components/DynamicSecretListView";
@@ -93,8 +91,6 @@ export const SecretMainPage = () => {
} }
}, [isWorkspaceLoading, currentWorkspace, environment, router.isReady]); }, [isWorkspaceLoading, currentWorkspace, environment, router.isReady]);
const { data: decryptFileKey } = useGetUserWsKey(workspaceId);
// fetch secrets // fetch secrets
const { data: secrets, isLoading: isSecretsLoading } = useGetProjectSecrets({ const { data: secrets, isLoading: isSecretsLoading } = useGetProjectSecrets({
environment, environment,
@@ -248,7 +244,6 @@ export const SecretMainPage = () => {
protectionPolicyName={boardPolicy?.name} protectionPolicyName={boardPolicy?.name}
/> />
</div> </div>
<ProjectIndexSecretsSection decryptFileKey={decryptFileKey!} />
{!isRollbackMode ? ( {!isRollbackMode ? (
<> <>
<ActionBar <ActionBar
@@ -330,7 +325,6 @@ export const SecretMainPage = () => {
environment={environment} environment={environment}
workspaceId={workspaceId} workspaceId={workspaceId}
secretPath={secretPath} secretPath={secretPath}
decryptFileKey={decryptFileKey!}
isProtectedBranch={isProtectedBranch} isProtectedBranch={isProtectedBranch}
/> />
)} )}
@@ -367,7 +361,6 @@ export const SecretMainPage = () => {
) : ( ) : (
<SnapshotView <SnapshotView
snapshotId={snapshotId || ""} snapshotId={snapshotId || ""}
decryptFileKey={decryptFileKey!}
environment={environment} environment={environment}
workspaceId={workspaceId} workspaceId={workspaceId}
secretPath={secretPath} secretPath={secretPath}
@@ -37,7 +37,7 @@ import { InfisicalSecretInput } from "@app/components/v2/InfisicalSecretInput";
import { ProjectPermissionActions, ProjectPermissionSub, useProjectPermission } from "@app/context"; import { ProjectPermissionActions, ProjectPermissionSub, useProjectPermission } from "@app/context";
import { useToggle } from "@app/hooks"; import { useToggle } from "@app/hooks";
import { useGetSecretVersion } from "@app/hooks/api"; import { useGetSecretVersion } from "@app/hooks/api";
import { SecretV3RawSanitized, UserWsKeyPair, WsTag } from "@app/hooks/api/types"; import { SecretV3RawSanitized, WsTag } from "@app/hooks/api/types";
import { CreateReminderForm } from "./CreateReminderForm"; import { CreateReminderForm } from "./CreateReminderForm";
import { formSchema, SecretActionType, TFormSchema } from "./SecretListView.utils"; import { formSchema, SecretActionType, TFormSchema } from "./SecretListView.utils";
@@ -49,7 +49,6 @@ type Props = {
onToggle: (isOpen: boolean) => void; onToggle: (isOpen: boolean) => void;
onClose: () => void; onClose: () => void;
secret: SecretV3RawSanitized; secret: SecretV3RawSanitized;
decryptFileKey: UserWsKeyPair;
onDeleteSecret: () => void; onDeleteSecret: () => void;
onSaveSecret: ( onSaveSecret: (
orgSec: SecretV3RawSanitized, orgSec: SecretV3RawSanitized,
@@ -64,7 +63,6 @@ type Props = {
export const SecretDetailSidebar = ({ export const SecretDetailSidebar = ({
isOpen, isOpen,
onToggle, onToggle,
decryptFileKey,
secret, secret,
onDeleteSecret, onDeleteSecret,
onSaveSecret, onSaveSecret,
@@ -114,8 +112,7 @@ export const SecretDetailSidebar = ({
const { data: secretVersion } = useGetSecretVersion({ const { data: secretVersion } = useGetSecretVersion({
limit: 10, limit: 10,
offset: 0, offset: 0,
secretId: secret?.id, secretId: secret?.id
decryptFileKey
}); });
const handleOverrideClick = () => { const handleOverrideClick = () => {
@@ -428,7 +425,7 @@ export const SecretDetailSidebar = ({
<div className="dark mt-4 mb-4 flex-grow text-sm text-bunker-300"> <div className="dark mt-4 mb-4 flex-grow text-sm text-bunker-300">
<div className="mb-2">Version History</div> <div className="mb-2">Version History</div>
<div className="flex h-48 flex-col space-y-2 overflow-y-auto overflow-x-hidden rounded-md border border-mineshaft-600 bg-bunker-800 p-2 dark:[color-scheme:dark]"> <div className="flex h-48 flex-col space-y-2 overflow-y-auto overflow-x-hidden rounded-md border border-mineshaft-600 bg-bunker-800 p-2 dark:[color-scheme:dark]">
{secretVersion?.map(({ createdAt, value, id }, i) => ( {secretVersion?.map(({ createdAt, secretValue, id }, i) => (
<div key={id} className="flex flex-col space-y-1"> <div key={id} className="flex flex-col space-y-1">
<div className="flex items-center space-x-2"> <div className="flex items-center space-x-2">
<div> <div>
@@ -438,7 +435,7 @@ export const SecretDetailSidebar = ({
</div> </div>
<div className="ml-1.5 flex items-center space-x-2 border-l border-bunker-300 pl-4"> <div className="ml-1.5 flex items-center space-x-2 border-l border-bunker-300 pl-4">
<div className="self-start rounded-sm bg-primary-500/30 px-1">Value:</div> <div className="self-start rounded-sm bg-primary-500/30 px-1">Value:</div>
<div className="break-all font-mono">{value}</div> <div className="break-all font-mono">{secretValue}</div>
</div> </div>
</div> </div>
))} ))}
@@ -10,9 +10,9 @@ import { usePopUp } from "@app/hooks";
import { useCreateSecretV3, useDeleteSecretV3, useUpdateSecretV3 } from "@app/hooks/api"; import { useCreateSecretV3, useDeleteSecretV3, useUpdateSecretV3 } from "@app/hooks/api";
import { secretApprovalRequestKeys } from "@app/hooks/api/secretApprovalRequest/queries"; import { secretApprovalRequestKeys } from "@app/hooks/api/secretApprovalRequest/queries";
import { secretKeys } from "@app/hooks/api/secrets/queries"; import { secretKeys } from "@app/hooks/api/secrets/queries";
import { SecretType,SecretV3RawSanitized } from "@app/hooks/api/secrets/types"; import { SecretType, SecretV3RawSanitized } from "@app/hooks/api/secrets/types";
import { secretSnapshotKeys } from "@app/hooks/api/secretSnapshots/queries"; import { secretSnapshotKeys } from "@app/hooks/api/secretSnapshots/queries";
import { UserWsKeyPair, WsTag } from "@app/hooks/api/types"; import { WsTag } from "@app/hooks/api/types";
import { AddShareSecretModal } from "@app/views/ShareSecretPage/components/AddShareSecretModal"; import { AddShareSecretModal } from "@app/views/ShareSecretPage/components/AddShareSecretModal";
import { useSelectedSecretActions, useSelectedSecrets } from "../../SecretMainPage.store"; import { useSelectedSecretActions, useSelectedSecrets } from "../../SecretMainPage.store";
@@ -25,7 +25,6 @@ type Props = {
secrets?: SecretV3RawSanitized[]; secrets?: SecretV3RawSanitized[];
environment: string; environment: string;
workspaceId: string; workspaceId: string;
decryptFileKey: UserWsKeyPair;
secretPath?: string; secretPath?: string;
filter: Filter; filter: Filter;
sortDir?: SortDir; sortDir?: SortDir;
@@ -88,7 +87,6 @@ export const SecretListView = ({
secrets = [], secrets = [],
environment, environment,
workspaceId, workspaceId,
decryptFileKey,
secretPath = "/", secretPath = "/",
filter, filter,
sortDir = SortDir.ASC, sortDir = SortDir.ASC,
@@ -392,7 +390,6 @@ export const SecretListView = ({
secretPath={secretPath} secretPath={secretPath}
isOpen={popUp.secretDetail.isOpen} isOpen={popUp.secretDetail.isOpen}
onToggle={(isOpen) => handlePopUpToggle("secretDetail", isOpen)} onToggle={(isOpen) => handlePopUpToggle("secretDetail", isOpen)}
decryptFileKey={decryptFileKey}
secret={popUp.secretDetail.data as SecretV3RawSanitized} secret={popUp.secretDetail.data as SecretV3RawSanitized}
onDeleteSecret={() => handlePopUpOpen("deleteSecret", popUp.secretDetail.data)} onDeleteSecret={() => handlePopUpOpen("deleteSecret", popUp.secretDetail.data)}
onClose={() => handlePopUpClose("secretDetail")} onClose={() => handlePopUpClose("secretDetail")}
@@ -14,7 +14,7 @@ import { ProjectPermissionCan } from "@app/components/permissions";
import { Button, ContentLoader, Input, Tag, Tooltip } from "@app/components/v2"; import { Button, ContentLoader, Input, Tag, Tooltip } from "@app/components/v2";
import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context"; import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context";
import { useGetSnapshotSecrets, usePerformSecretRollback } from "@app/hooks/api"; import { useGetSnapshotSecrets, usePerformSecretRollback } from "@app/hooks/api";
import { SecretV3RawSanitized, TSecretFolder, UserWsKeyPair } from "@app/hooks/api/types"; import { SecretV3RawSanitized, TSecretFolder } from "@app/hooks/api/types";
import { renderIcon, SecretItem, TDiffModes, TDiffView } from "./SecretItem"; import { renderIcon, SecretItem, TDiffModes, TDiffView } from "./SecretItem";
@@ -23,7 +23,6 @@ type Props = {
environment: string; environment: string;
workspaceId: string; workspaceId: string;
secretPath?: string; secretPath?: string;
decryptFileKey: UserWsKeyPair;
secrets?: SecretV3RawSanitized[]; secrets?: SecretV3RawSanitized[];
folders?: TSecretFolder[]; folders?: TSecretFolder[];
snapshotCount?: number; snapshotCount?: number;
@@ -45,7 +44,6 @@ export const SnapshotView = ({
environment, environment,
workspaceId, workspaceId,
secretPath, secretPath,
decryptFileKey,
secrets = [], secrets = [],
folders = [], folders = [],
onGoBack, onGoBack,
@@ -57,8 +55,7 @@ export const SnapshotView = ({
const { data: snapshotData, isLoading: isSnapshotLoading } = useGetSnapshotSecrets({ const { data: snapshotData, isLoading: isSnapshotLoading } = useGetSnapshotSecrets({
snapshotId, snapshotId,
env: environment, env: environment
decryptFileKey
}); });
const rollingFolder = snapshotData?.folders || []; const rollingFolder = snapshotData?.folders || [];