Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
fix: fix lint errors
lemmyMwaura069651bdb438
diff --git a/backend/src/server/routes/v1/secret-sharing-router.ts b/backend/src/server/routes/v1/secret-sharing-router.tsindex e131071313..21bcf013c4 100644--- a/backend/src/server/routes/v1/secret-sharing-router.ts+++ b/backend/src/server/routes/v1/secret-sharing-router.ts@@ -115,7 +115,7 @@ export const registerSecretSharingRouter = async (server: FastifyZodProvider) =>tag: true,expiresAt: true,expiresAfterViews: true,- accessType: true,+ accessType: true}).extend({orgName: z.string().optional()})diff --git a/backend/src/services/secret-sharing/secret-sharing-service.ts b/backend/src/services/secret-sharing/secret-sharing-service.tsindex 80d661b401..08dbdc91fb 100644--- a/backend/src/services/secret-sharing/secret-sharing-service.ts+++ b/backend/src/services/secret-sharing/secret-sharing-service.ts@@ -1,12 +1,19 @@import bcrypt from "bcrypt";import { TPermissionServiceFactory } from "@app/ee/services/permission/permission-service";-import { BadRequestError, ForbiddenRequestError, InternalServerError, NotFoundError, UnauthorizedError } from "@app/lib/errors";+import {+ BadRequestError,+ ForbiddenRequestError,+ InternalServerError,+ NotFoundError,+ UnauthorizedError+} from "@app/lib/errors";import { SecretSharingAccessType } from "@app/lib/types";import { TOrgDALFactory } from "../org/org-dal";import { TSecretSharingDALFactory } from "./secret-sharing-dal";import {+ SharedSecretWithDate,TCreatePublicSharedSecretDTO,TCreateSharedSecretDTO,TDeleteSharedSecretDTO,@@ -162,6 +169,40 @@ export const secretSharingServiceFactory = ({};};+ /** Checks if secret is expired and throws error if true */+ const checkIfExpired = async (sharedSecret: SharedSecretWithDate, sharedSecretId: string) => {+ const { expiresAt, expiresAfterViews } = sharedSecret;++ if (expiresAt !== null && expiresAt < new Date()) {+ // check lifetime expiry+ await secretSharingDAL.softDeleteById(sharedSecretId);+ throw new ForbiddenRequestError({+ message: "Access denied: Secret has expired by lifetime"+ });+ }++ if (expiresAfterViews !== null && expiresAfterViews === 0) {+ // check view count expiry+ await secretSharingDAL.softDeleteById(sharedSecretId);+ throw new ForbiddenRequestError({+ message: "Access denied: Secret has expired by view count"+ });+ }+ };++ const decrementSecretViewCount = async (sharedSecret: SharedSecretWithDate, sharedSecretId: string) => {+ const { expiresAfterViews } = sharedSecret;++ if (expiresAfterViews) {+ // decrement view count if view count expiry set+ await secretSharingDAL.updateById(sharedSecretId, { $decr: { expiresAfterViews: 1 } });+ }++ await secretSharingDAL.updateById(sharedSecretId, {+ lastViewedAt: new Date()+ });+ };+const getActiveSharedSecretById = async ({ sharedSecretId, hashedHex, orgId }: TGetActiveSharedSecretByIdDTO) => {const sharedSecret = await secretSharingDAL.findOne({id: sharedSecretId,@@ -180,7 +221,7 @@ export const secretSharingServiceFactory = ({throw new UnauthorizedError();await checkIfExpired(sharedSecret, sharedSecretId);-+if (sharedSecret.password !== null) return undefined;// decrement when we are sure the user will view secret.@@ -223,7 +264,7 @@ export const secretSharingServiceFactory = ({});const isMatch = await bcrypt.compare(password, sharedSecret.password as string);- if (!isMatch) return undefined+ if (!isMatch) return undefined;// we reduce the view count when we are sure the password matches.await decrementSecretViewCount(sharedSecret, sharedSecretId);@@ -245,40 +286,6 @@ export const secretSharingServiceFactory = ({return deletedSharedSecret;};- /** Checks if secret is expired and throws error if true */- const checkIfExpired = async (sharedSecret: any, sharedSecretId: string) => {- const { expiresAt, expiresAfterViews } = sharedSecret;-- if (expiresAt !== null && expiresAt < new Date()) {- // check lifetime expiry- await secretSharingDAL.softDeleteById(sharedSecretId);- throw new ForbiddenRequestError({- message: "Access denied: Secret has expired by lifetime"- });- }-- if (expiresAfterViews !== null && expiresAfterViews === 0) {- // check view count expiry- await secretSharingDAL.softDeleteById(sharedSecretId);- throw new ForbiddenRequestError({- message: "Access denied: Secret has expired by view count"- });- }- }-- const decrementSecretViewCount = async (sharedSecret: any, sharedSecretId: string) => {- const { expiresAfterViews } = sharedSecret;-- if (expiresAfterViews) {- // decrement view count if view count expiry set- await secretSharingDAL.updateById(sharedSecretId, { $decr: { expiresAfterViews: 1 } });- }-- await secretSharingDAL.updateById(sharedSecretId, {- lastViewedAt: new Date()- });- }-return {createSharedSecret,createPublicSharedSecret,diff --git a/backend/src/services/secret-sharing/secret-sharing-types.ts b/backend/src/services/secret-sharing/secret-sharing-types.tsindex e96a68e648..6720a7bee1 100644--- a/backend/src/services/secret-sharing/secret-sharing-types.ts+++ b/backend/src/services/secret-sharing/secret-sharing-types.ts@@ -41,6 +41,8 @@ export type TValidateActiveSharedSecretDTO = TGetActiveSharedSecretByIdDTO & {export type TCreateSharedSecretDTO = TSharedSecretPermission & TCreatePublicSharedSecretDTO;+export type SharedSecretWithDate = Omit<TCreateSharedSecretDTO, 'expiresAt'> & { expiresAt: Date };+export type TDeleteSharedSecretDTO = {sharedSecretId: string;} & TSharedSecretPermission;diff --git a/frontend/src/views/ViewSecretPublicPage/components/PasswordContainer.tsx b/frontend/src/views/ViewSecretPublicPage/components/PasswordContainer.tsxindex e79a3b5b15..00876225d1 100644--- a/frontend/src/views/ViewSecretPublicPage/components/PasswordContainer.tsx+++ b/frontend/src/views/ViewSecretPublicPage/components/PasswordContainer.tsx@@ -42,11 +42,11 @@ export const PasswordContainer = ({ secretId, hashedHex, handleSecret }: Props)if (secret) {handleSecret(secret);} else {+ reset({ password: "" });createNotification({text: "Password is Invalid. Try again",type: "error"})- reset();}} catch (error) {console.error("Failed to validate password:", error);