mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-16 02:16:34 +00:00
feat: ui removed all private key except secret rotation to raw endpoints version
This commit is contained in:
@@ -13,15 +13,13 @@ import {
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { UserWsKeyPair } from "../keys/types";
|
||||
import { EncryptedSecret, SecretType,SecretV3RawSanitized } from "../secrets/types";
|
||||
import { EncryptedSecret, SecretType, SecretV3RawSanitized } from "../secrets/types";
|
||||
import {
|
||||
CommitType,
|
||||
TGetSecretApprovalRequestCount,
|
||||
TGetSecretApprovalRequestDetails,
|
||||
TGetSecretApprovalRequestList,
|
||||
TSecretApprovalRequest,
|
||||
TSecretApprovalRequestCount,
|
||||
TSecretApprovalSecChangeData
|
||||
TSecretApprovalRequestCount
|
||||
} from "./types";
|
||||
|
||||
export const secretApprovalRequestKeys = {
|
||||
@@ -117,48 +115,6 @@ export const decryptSecrets = (
|
||||
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 ({
|
||||
workspaceId,
|
||||
environment,
|
||||
@@ -245,7 +201,7 @@ export const useGetSecretApprovalRequestDetails = ({
|
||||
UseQueryOptions<
|
||||
TSecretApprovalRequest,
|
||||
unknown,
|
||||
TSecretApprovalRequest<SecretV3RawSanitized>,
|
||||
TSecretApprovalRequest,
|
||||
ReturnType<typeof secretApprovalRequestKeys.detail>
|
||||
>,
|
||||
"queryKey" | "queryFn"
|
||||
@@ -254,16 +210,6 @@ export const useGetSecretApprovalRequestDetails = ({
|
||||
useQuery({
|
||||
queryKey: secretApprovalRequestKeys.detail({ 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)
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { UserWsKeyPair } from "../keys/types";
|
||||
import { TSecretApprovalPolicy } from "../secretApproval/types";
|
||||
import { EncryptedSecret } from "../secrets/types";
|
||||
import { SecretV3Raw } from "../secrets/types";
|
||||
import { WsTag } from "../tags/types";
|
||||
|
||||
export enum ApprovalStatus {
|
||||
@@ -17,15 +17,9 @@ export enum CommitType {
|
||||
|
||||
export type TSecretApprovalSecChangeData = {
|
||||
id: string;
|
||||
secretKeyCiphertext: string;
|
||||
secretKeyIV: string;
|
||||
secretKeyTag: string;
|
||||
secretValueCiphertext: string;
|
||||
secretValueIV: string;
|
||||
secretValueTag: string;
|
||||
secretCommentIV: string;
|
||||
secretCommentTag: string;
|
||||
secretCommentCiphertext: string;
|
||||
secretKey: string;
|
||||
secretValue?: string;
|
||||
secretComment?: string;
|
||||
skipMultilineEncoding?: boolean;
|
||||
algorithm: "aes-256-gcm";
|
||||
keyEncoding: "utf8" | "base64";
|
||||
@@ -37,12 +31,12 @@ export type TSecretApprovalSecChange = {
|
||||
id: string;
|
||||
version: number;
|
||||
secretKey: string;
|
||||
secretValue: string;
|
||||
secretComment: string;
|
||||
secretValue?: string;
|
||||
secretComment?: string;
|
||||
tags?: string[];
|
||||
};
|
||||
|
||||
export type TSecretApprovalRequest<J extends unknown = EncryptedSecret> = {
|
||||
export type TSecretApprovalRequest = {
|
||||
id: string;
|
||||
isReplicated?: boolean;
|
||||
slug: string;
|
||||
@@ -90,7 +84,7 @@ export type TSecretApprovalRequest<J extends unknown = EncryptedSecret> = {
|
||||
commits: ({
|
||||
// if there is no secret means it was creation
|
||||
secret?: { version: number };
|
||||
secretVersion: J;
|
||||
secretVersion: SecretV3Raw;
|
||||
// if there is no new version its for Delete
|
||||
op: CommitType;
|
||||
} & TSecretApprovalSecChangeData)[];
|
||||
|
||||
Reference in New Issue
Block a user