Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: adds secret sharing validity info

Piyush Gupta9e97cf68a5e2
diff --git a/frontend/src/hooks/api/secretSharing/types.ts b/frontend/src/hooks/api/secretSharing/types.ts
index c35228fab3..524346beb5 100644
--- a/frontend/src/hooks/api/secretSharing/types.ts
+++ b/frontend/src/hooks/api/secretSharing/types.ts
@@ -59,6 +59,8 @@ export type TViewSharedSecretResponse = {
tag: string;
accessType: SecretSharingAccessType;
orgName?: string;
+ expiresAt?: Date | string;
+ expiresAfterViews?: number | null;
};
};
diff --git a/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretContainer.tsx b/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretContainer.tsx
index 1b2e785fe1..3193a1bf5b 100644
--- a/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretContainer.tsx
+++ b/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretContainer.tsx
@@ -13,6 +13,8 @@ import { Button, IconButton } from "@app/components/v2";
import { useTimedReset, useToggle } from "@app/hooks";
import { TViewSharedSecretResponse } from "@app/hooks/api/secretSharing";
+import { SecretShareInfo } from "./SecretShareInfo";
+
type Props = {
secret: TViewSharedSecretResponse["secret"];
secretKey: string | null;
@@ -71,6 +73,7 @@ export const SecretContainer = ({ secret, secretKey: key }: Props) => {
</IconButton>
</div>
</div>
+ <SecretShareInfo secret={secret} />
<Button
className="mt-4 w-full bg-mineshaft-700 py-3 text-bunker-200"
colorSchema="primary"
diff --git a/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretShareInfo.tsx b/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretShareInfo.tsx
new file mode 100644
index 0000000000..4cfd7d7bb9
--- /dev/null
+++ b/frontend/src/pages/public/ViewSharedSecretByIDPage/components/SecretShareInfo.tsx
@@ -0,0 +1,53 @@
+import { useMemo } from "react";
+import { faClock, faEye } from "@fortawesome/free-solid-svg-icons";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { format } from "date-fns";
+
+import { TViewSharedSecretResponse } from "@app/hooks/api/secretSharing";
+
+type Props = {
+ secret: TViewSharedSecretResponse["secret"];
+};
+
+export const SecretShareInfo = ({ secret }: Props) => {
+ const timeRemaining = useMemo(() => {
+ if (!secret.expiresAt) return null;
+
+ try {
+ return format(new Date(secret.expiresAt), "yyyy-MM-dd 'at' HH:mm a");
+ } catch {
+ return null;
+ }
+ }, [secret.expiresAt]);
+
+ const viewsRemaining = useMemo(() => {
+ if (!secret.expiresAfterViews) return null;
+
+ return secret.expiresAfterViews - 1;
+ }, [secret.expiresAfterViews]);
+
+ if (!timeRemaining && viewsRemaining === null) {
+ return null;
+ }
+
+ return (
+ <div className="mt-4 flex flex-col gap-2 rounded-md border border-mineshaft-600 bg-mineshaft-700/50 p-3 text-sm text-gray-300">
+ {timeRemaining && (
+ <div className="flex items-center gap-2">
+ <FontAwesomeIcon icon={faClock} className="text-mineshaft-400" />
+ <span>Expires on {timeRemaining}</span>
+ </div>
+ )}
+ {viewsRemaining !== null && (
+ <div className="flex items-center gap-2">
+ <FontAwesomeIcon icon={faEye} className="text-mineshaft-400" />
+ <span>
+ {viewsRemaining === 0
+ ? "This is the last time you can view this secret"
+ : `${viewsRemaining} more view${viewsRemaining === 1 ? "" : "s"} remaining after this`}
+ </span>
+ </div>
+ )}
+ </div>
+ );
+};