Skip to content

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

chore: fix lint errors, schema ordering, and import sorting

bernie-gd467970550ad
diff --git a/backend/src/@types/knex.d.ts b/backend/src/@types/knex.d.ts
index 0db144ddbe..8b257a6102 100644
--- a/backend/src/@types/knex.d.ts
+++ b/backend/src/@types/knex.d.ts
@@ -158,15 +158,15 @@ import {
TFolderTreeCheckpoints,
TFolderTreeCheckpointsInsert,
TFolderTreeCheckpointsUpdate,
+ TGatewayEnrollmentTokens,
+ TGatewayEnrollmentTokensInsert,
+ TGatewayEnrollmentTokensUpdate,
TGateways,
TGatewaysInsert,
TGatewaysUpdate,
TGatewaysV2,
TGatewaysV2Insert,
TGatewaysV2Update,
- TGatewayEnrollmentTokens,
- TGatewayEnrollmentTokensInsert,
- TGatewayEnrollmentTokensUpdate,
TGitAppInstallSessions,
TGitAppInstallSessionsInsert,
TGitAppInstallSessionsUpdate,
diff --git a/backend/src/db/schemas/gateway-enrollment-tokens.ts b/backend/src/db/schemas/gateway-enrollment-tokens.ts
index 032ef42ddc..11d1d7c8fa 100644
--- a/backend/src/db/schemas/gateway-enrollment-tokens.ts
+++ b/backend/src/db/schemas/gateway-enrollment-tokens.ts
@@ -15,9 +15,9 @@ export const GatewayEnrollmentTokensSchema = z.object({
ttl: z.number().default(3600),
expiresAt: z.date(),
usedAt: z.date().nullable().optional(),
+ gatewayId: z.string().uuid().nullable().optional(),
createdAt: z.date(),
- updatedAt: z.date(),
- gatewayId: z.string().uuid().nullable().optional()
+ updatedAt: z.date()
});
export type TGatewayEnrollmentTokens = z.infer<typeof GatewayEnrollmentTokensSchema>;
diff --git a/backend/src/ee/services/gateway-v2/gateway-v2-dal.ts b/backend/src/ee/services/gateway-v2/gateway-v2-dal.ts
index 3a7b4862ee..68898b00cf 100644
--- a/backend/src/ee/services/gateway-v2/gateway-v2-dal.ts
+++ b/backend/src/ee/services/gateway-v2/gateway-v2-dal.ts
@@ -54,7 +54,7 @@ export const gatewayV2DalFactory = (db: TDbClient) => {
return docs.map((el) => ({
...GatewaysV2Schema.parse(el),
- identity: el.identityId ? { id: el.identityId, name: el.identityName as string } : null
+ identity: el.identityId ? { id: el.identityId, name: el.identityName } : null
}));
} catch (error) {
throw new DatabaseError({ error, name: `${TableName.GatewayV2}: Find` });
diff --git a/backend/src/ee/services/gateway-v2/gateway-v2-service.ts b/backend/src/ee/services/gateway-v2/gateway-v2-service.ts
index f64ee10481..e414038363 100644
--- a/backend/src/ee/services/gateway-v2/gateway-v2-service.ts
+++ b/backend/src/ee/services/gateway-v2/gateway-v2-service.ts
@@ -31,7 +31,6 @@ import { TOrgDALFactory } from "@app/services/org/org-dal";
import { TSmtpService } from "@app/services/smtp/smtp-service";
import { TAiMcpServerDALFactory } from "../ai-mcp-server/ai-mcp-server-dal";
-import { TGatewayEnrollmentTokenDALFactory } from "./gateway-enrollment-token-dal";
import { TDynamicSecretDALFactory } from "../dynamic-secret/dynamic-secret-dal";
import { TPamDiscoverySourceDALFactory } from "../pam-discovery/pam-discovery-source-dal";
import { TPamResourceDALFactory } from "../pam-resource/pam-resource-dal";
@@ -41,6 +40,7 @@ import { TPermissionServiceFactory } from "../permission/permission-service-type
import { TPkiDiscoveryConfigDALFactory } from "../pki-discovery/pki-discovery-config-dal";
import { TRelayDALFactory } from "../relay/relay-dal";
import { TRelayServiceFactory } from "../relay/relay-service";
+import { TGatewayEnrollmentTokenDALFactory } from "./gateway-enrollment-token-dal";
import { GATEWAY_ACTOR_OID, GATEWAY_ROUTING_INFO_OID, PAM_INFO_OID } from "./gateway-v2-constants";
import { TGatewayV2DALFactory } from "./gateway-v2-dal";
import { GatewayHealthCheckStatus, TGatewayV2ConnectionDetails } from "./gateway-v2-types";
@@ -816,7 +816,7 @@ export const gatewayV2ServiceFactory = ({
["identityId"]
);
- return $issueGatewayCerts({ orgId, orgCAs, relayName, gateway });
+ return await $issueGatewayCerts({ orgId, orgCAs, relayName, gateway });
} catch (err) {
if (err instanceof DatabaseError && (err.error as { code: string })?.code === DatabaseErrorCode.UniqueViolation) {
throw new BadRequestError({ message: `Gateway with name "${name}" already exists` });
diff --git a/backend/src/ee/services/pam-account/pam-account-service.ts b/backend/src/ee/services/pam-account/pam-account-service.ts
index 5e485898e5..106529cd43 100644
--- a/backend/src/ee/services/pam-account/pam-account-service.ts
+++ b/backend/src/ee/services/pam-account/pam-account-service.ts
@@ -989,9 +989,7 @@ export const pamAccountServiceFactory = ({
if (resource.gatewayId) {
const authorized =
- actor.type === ActorType.GATEWAY
- ? resource.gatewayId === actor.id
- : resource.gatewayIdentityId === actor.id;
+ actor.type === ActorType.GATEWAY ? resource.gatewayId === actor.id : resource.gatewayIdentityId === actor.id;
if (!authorized) {
throw new ForbiddenRequestError({
message: "Gateway does not have access to fetch the PAM session credentials"
diff --git a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsx b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsx
index 1684aee8c5..3d2ebb198e 100644
--- a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsx
+++ b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsx
@@ -275,19 +275,27 @@ export const GatewayTab = withPermission(
<Td>
<div className="flex items-center gap-2">
<span>{el.name}</span>
- {"isExpired" in el && el.isExpired ? (
- <span className="rounded-sm bg-red-900/30 px-1.5 py-0.5 text-xs text-red-400">
- Expired
- </span>
- ) : el.isPending ? (
- <span className="rounded-sm bg-yellow-900/30 px-1.5 py-0.5 text-xs text-yellow-500">
- Pending
- </span>
- ) : (
- <span className="rounded-sm bg-mineshaft-700 px-1.5 py-0.5 text-xs text-mineshaft-400">
- Gateway v{el.isV1 ? "1" : "2"}
- </span>
- )}
+ {(() => {
+ if ("isExpired" in el && el.isExpired) {
+ return (
+ <span className="rounded-sm bg-red-900/30 px-1.5 py-0.5 text-xs text-red-400">
+ Expired
+ </span>
+ );
+ }
+ if (el.isPending) {
+ return (
+ <span className="rounded-sm bg-yellow-900/30 px-1.5 py-0.5 text-xs text-yellow-500">
+ Pending
+ </span>
+ );
+ }
+ return (
+ <span className="rounded-sm bg-mineshaft-700 px-1.5 py-0.5 text-xs text-mineshaft-400">
+ Gateway v{el.isV1 ? "1" : "2"}
+ </span>
+ );
+ })()}
</div>
</Td>
<Td>
@@ -361,23 +369,22 @@ export const GatewayTab = withPermission(
</OrgPermissionCan>
)}
{!el.isV1 &&
- (el.isPending ||
- ("identityId" in el && !el.identityId)) && (
- <OrgPermissionCan
- I={OrgGatewayPermissionActions.EditGateways}
- a={OrgPermissionSubjects.Gateway}
- >
- {(isAllowed: boolean) => (
- <DropdownMenuItem
- isDisabled={!isAllowed}
- icon={<FontAwesomeIcon icon={faArrowsRotate} />}
- onClick={() => handlePopUpOpen("reEnrollGateway", el)}
- >
- Re-enroll
- </DropdownMenuItem>
- )}
- </OrgPermissionCan>
- )}
+ (el.isPending || ("identityId" in el && !el.identityId)) && (
+ <OrgPermissionCan
+ I={OrgGatewayPermissionActions.EditGateways}
+ a={OrgPermissionSubjects.Gateway}
+ >
+ {(isAllowed: boolean) => (
+ <DropdownMenuItem
+ isDisabled={!isAllowed}
+ icon={<FontAwesomeIcon icon={faArrowsRotate} />}
+ onClick={() => handlePopUpOpen("reEnrollGateway", el)}
+ >
+ Re-enroll
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ )}
<OrgPermissionCan
I={OrgGatewayPermissionActions.DeleteGateways}
a={OrgPermissionSubjects.Gateway}
diff --git a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayCliDeploymentMethod.tsx b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayCliDeploymentMethod.tsx
index 22c7e913fa..0eab7100d9 100644
--- a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayCliDeploymentMethod.tsx
+++ b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayCliDeploymentMethod.tsx
@@ -2,8 +2,8 @@ import { useMemo, useState } from "react";
import { SingleValue } from "react-select";
import { faCopy, faUpRightFromSquare } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { useNavigate } from "@tanstack/react-router";
import { useQuery } from "@tanstack/react-query";
+import { useNavigate } from "@tanstack/react-router";
import { z } from "zod";
import { createNotification } from "@app/components/notifications";
@@ -82,7 +82,7 @@ export const GatewayCliDeploymentMethod = () => {
const result = await createEnrollmentToken({ name });
setEnrollmentToken(result.token);
- const relayName = relay?.id === "_auto" ? "" : relay?.name ?? "";
+ const relayName = relay?.id === "_auto" ? "" : (relay?.name ?? "");
setResolvedRelayName(relayName);
setStep("command");
} catch {
diff --git a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayCliSystemdDeploymentMethod.tsx b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayCliSystemdDeploymentMethod.tsx
index b601f7e84e..63fc170c56 100644
--- a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayCliSystemdDeploymentMethod.tsx
+++ b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayCliSystemdDeploymentMethod.tsx
@@ -2,8 +2,8 @@ import { useMemo, useState } from "react";
import { SingleValue } from "react-select";
import { faCopy, faUpRightFromSquare } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { useNavigate } from "@tanstack/react-router";
import { useQuery } from "@tanstack/react-query";
+import { useNavigate } from "@tanstack/react-router";
import { z } from "zod";
import { createNotification } from "@app/components/notifications";
@@ -82,7 +82,7 @@ export const GatewayCliSystemdDeploymentMethod = () => {
const result = await createEnrollmentToken({ name });
setEnrollmentToken(result.token);
- const relayName = relay?.id === "_auto" ? "" : relay?.name ?? "";
+ const relayName = relay?.id === "_auto" ? "" : (relay?.name ?? "");
setResolvedRelayName(relayName);
setStep("command");
} catch {
@@ -113,7 +113,10 @@ export const GatewayCliSystemdDeploymentMethod = () => {
colorSchema="secondary"
onClick={() => {
navigator.clipboard.writeText(installCommand);
- createNotification({ text: "Installation command copied to clipboard", type: "info" });
+ createNotification({
+ text: "Installation command copied to clipboard",
+ type: "info"
+ });
}}
className="w-10"
>
diff --git a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/ReEnrollGatewayModal.tsx b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/ReEnrollGatewayModal.tsx
index 59ab574cda..47dee57301 100644
--- a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/ReEnrollGatewayModal.tsx
+++ b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/ReEnrollGatewayModal.tsx
@@ -3,7 +3,15 @@ import { faCopy } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { createNotification } from "@app/components/notifications";
-import { Button, FormLabel, IconButton, Input, Modal, ModalClose, ModalContent } from "@app/components/v2";
+import {
+ Button,
+ FormLabel,
+ IconButton,
+ Input,
+ Modal,
+ ModalClose,
+ ModalContent
+} from "@app/components/v2";
import { useReEnrollGateway } from "@app/hooks/api/gateways-v2";
type Props = {
@@ -56,33 +64,30 @@ export const ReEnrollGatewayModal = ({ isOpen, onOpenChange, gatewayData }: Prop
<ModalContent
className="max-w-2xl"
title={`Re-enroll ${gatewayData.name}`}
- subTitle={
- step === "confirm"
- ? gatewayData.isTokenOnly
- ? "This will create a new enrollment token, replacing the expired one."
- : "This will create a new enrollment token and invalidate the current gateway credentials. The gateway will stop working until re-enrolled."
- : undefined
- }
+ subTitle={(() => {
+ if (step !== "confirm") return undefined;
+ if (gatewayData.isTokenOnly)
+ return "This will create a new enrollment token, replacing the expired one.";
+ return "This will create a new enrollment token and invalidate the current gateway credentials. The gateway will stop working until re-enrolled.";
+ })()}
>
{step === "confirm" && (
- <>
- <div className="mt-4 flex items-center">
- <Button
- className="mr-4"
- size="sm"
- colorSchema="danger"
- onClick={handleReEnroll}
- isLoading={isReEnrolling}
- >
- {gatewayData.isTokenOnly ? "Create New Token" : "Re-enroll"}
+ <div className="mt-4 flex items-center">
+ <Button
+ className="mr-4"
+ size="sm"
+ colorSchema="danger"
+ onClick={handleReEnroll}
+ isLoading={isReEnrolling}
+ >
+ {gatewayData.isTokenOnly ? "Create New Token" : "Re-enroll"}
+ </Button>
+ <ModalClose asChild>
+ <Button colorSchema="secondary" variant="plain">
+ Cancel
</Button>
- <ModalClose asChild>
- <Button colorSchema="secondary" variant="plain">
- Cancel
- </Button>
- </ModalClose>
- </div>
- </>
+ </ModalClose>
+ </div>
)}
{step === "command" && (
<>