chore: Update dependencies and clean up code formatting

- Downgraded '@trpc/server' version in package.json and pnpm-lock.yaml to match other TRPC packages.
- Removed unused dependencies 'node-fetch', 'data-uri-to-buffer', 'fetch-blob', and 'formdata-polyfill' from pnpm-lock.yaml and package.json.
- Improved code formatting in various components for better readability, including adjustments in 'edit-gitea-provider.tsx' and 'security-audit.tsx'.
- Refactored imports in 'auth.ts' for better organization and clarity.
This commit is contained in:
Mauricio Siu 2025-03-23 04:06:35 -06:00
parent 148c30f604
commit 4b3e0805a4
7 changed files with 51 additions and 77 deletions

View File

@ -201,7 +201,11 @@ export const EditGiteaProvider = ({ giteaId }: Props) => {
<FormItem> <FormItem>
<FormLabel>Name</FormLabel> <FormLabel>Name</FormLabel>
<FormControl> <FormControl>
<Input placeholder="My Gitea" {...field} autoFocus={false} /> <Input
placeholder="My Gitea"
{...field}
autoFocus={false}
/>
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>
@ -289,4 +293,4 @@ export const EditGiteaProvider = ({ giteaId }: Props) => {
</DialogContent> </DialogContent>
</Dialog> </Dialog>
); );
}; };

View File

@ -26,16 +26,21 @@ export const SecurityAudit = ({ serverId }: Props) => {
}, },
); );
const _utils = api.useUtils(); const _utils = api.useUtils();
// Helper function to check if root login is securely configured // Helper function to check if root login is securely configured
const isRootLoginSecure = () => { const isRootLoginSecure = () => {
if (!data?.ssh?.permitRootLogin) return false; if (!data?.ssh?.permitRootLogin) return false;
// These are secure options for PermitRootLogin // These are secure options for PermitRootLogin
const secureOptions = ['no', 'prohibit-password', 'without-password', 'forced-commands-only']; const secureOptions = [
"no",
"prohibit-password",
"without-password",
"forced-commands-only",
];
return secureOptions.includes(data.ssh.permitRootLogin); return secureOptions.includes(data.ssh.permitRootLogin);
}; };
return ( return (
<CardContent className="p-0"> <CardContent className="p-0">
<div className="flex flex-col gap-4"> <div className="flex flex-col gap-4">
@ -49,7 +54,9 @@ export const SecurityAudit = ({ serverId }: Props) => {
Setup Security Suggestions Setup Security Suggestions
</CardTitle> </CardTitle>
</div> </div>
<CardDescription>Check the security suggestions</CardDescription> <CardDescription>
Check the security suggestions
</CardDescription>
</div> </div>
<Button <Button
isLoading={isRefreshing} isLoading={isRefreshing}
@ -240,4 +247,4 @@ export const SecurityAudit = ({ serverId }: Props) => {
</div> </div>
</CardContent> </CardContent>
); );
}; };

View File

@ -84,7 +84,7 @@
"@trpc/client": "^10.43.6", "@trpc/client": "^10.43.6",
"@trpc/next": "^10.43.6", "@trpc/next": "^10.43.6",
"@trpc/react-query": "^10.43.6", "@trpc/react-query": "^10.43.6",
"@trpc/server": "^10.45.2", "@trpc/server": "^10.43.6",
"@uiw/codemirror-theme-github": "^4.22.1", "@uiw/codemirror-theme-github": "^4.22.1",
"@uiw/react-codemirror": "^4.22.1", "@uiw/react-codemirror": "^4.22.1",
"@xterm/addon-attach": "0.10.0", "@xterm/addon-attach": "0.10.0",
@ -120,7 +120,6 @@
"next": "^15.0.1", "next": "^15.0.1",
"next-i18next": "^15.3.1", "next-i18next": "^15.3.1",
"next-themes": "^0.2.1", "next-themes": "^0.2.1",
"node-fetch": "^3.3.2",
"node-os-utils": "1.3.7", "node-os-utils": "1.3.7",
"node-pty": "1.0.0", "node-pty": "1.0.0",
"node-schedule": "2.1.1", "node-schedule": "2.1.1",
@ -162,7 +161,7 @@
"@types/js-yaml": "4.0.9", "@types/js-yaml": "4.0.9",
"@types/lodash": "4.17.4", "@types/lodash": "4.17.4",
"@types/micromatch": "4.0.9", "@types/micromatch": "4.0.9",
"@types/node": "^18.19.42", "@types/node": "^18.17.0",
"@types/node-os-utils": "1.3.4", "@types/node-os-utils": "1.3.4",
"@types/node-schedule": "2.1.6", "@types/node-schedule": "2.1.6",
"@types/nodemailer": "^6.4.15", "@types/nodemailer": "^6.4.15",

View File

@ -2,16 +2,16 @@ import type { IncomingMessage } from "node:http";
import * as bcrypt from "bcrypt"; import * as bcrypt from "bcrypt";
import { betterAuth } from "better-auth"; import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle"; import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { APIError } from "better-auth/api"; import { organization, twoFactor, apiKey } from "better-auth/plugins";
import { apiKey, organization, twoFactor } from "better-auth/plugins";
import { and, desc, eq } from "drizzle-orm"; import { and, desc, eq } from "drizzle-orm";
import { IS_CLOUD } from "../constants";
import { db } from "../db"; import { db } from "../db";
import * as schema from "../db/schema"; import * as schema from "../db/schema";
import { getUserByToken } from "../services/admin";
import { updateUser } from "../services/user";
import { sendEmail } from "../verification/send-verification-email"; import { sendEmail } from "../verification/send-verification-email";
import { IS_CLOUD } from "../constants";
import { getPublicIpWithFallback } from "../wss/utils"; import { getPublicIpWithFallback } from "../wss/utils";
import { updateUser } from "../services/user";
import { getUserByToken } from "../services/admin";
import { APIError } from "better-auth/api";
const { handler, api } = betterAuth({ const { handler, api } = betterAuth({
database: drizzleAdapter(db, { database: drizzleAdapter(db, {
@ -32,26 +32,26 @@ const { handler, api } = betterAuth({
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
}, },
}, },
// ...(!IS_CLOUD && { ...(!IS_CLOUD && {
// async trustedOrigins() { async trustedOrigins() {
// const admin = await db.query.member.findFirst({ const admin = await db.query.member.findFirst({
// where: eq(schema.member.role, "owner"), where: eq(schema.member.role, "owner"),
// with: { with: {
// user: true, user: true,
// }, },
// }); });
// if (admin) { if (admin) {
// return [ return [
// ...(admin.user.serverIp ...(admin.user.serverIp
// ? [`http://${admin.user.serverIp}:3000`] ? [`http://${admin.user.serverIp}:3000`]
// : []), : []),
// ...(admin.user.host ? [`https://${admin.user.host}`] : []), ...(admin.user.host ? [`https://${admin.user.host}`] : []),
// ]; ];
// } }
// return []; return [];
// }, },
// }), }),
emailVerification: { emailVerification: {
sendOnSignUp: true, sendOnSignUp: true,
autoSignInAfterVerification: true, autoSignInAfterVerification: true,

View File

@ -148,4 +148,4 @@ export const serverAudit = async (serverId: string) => {
privateKey: server.sshKey?.privateKey, privateKey: server.sshKey?.privateKey,
}); });
}); });
}; };

View File

@ -1,17 +1,17 @@
import { createWriteStream } from "node:fs"; import { createWriteStream } from "node:fs";
import { join } from "node:path"; import { join } from "node:path";
import { paths } from "@dokploy/server/constants"; import { paths } from "@dokploy/server/constants";
import type { Compose } from "@dokploy/server/services/compose";
import { import {
findGiteaById,
type Gitea, type Gitea,
findGiteaById,
updateGitea, updateGitea,
} from "@dokploy/server/services/gitea"; } from "@dokploy/server/services/gitea";
import type { InferResultType } from "@dokploy/server/types/with";
import { TRPCError } from "@trpc/server"; import { TRPCError } from "@trpc/server";
import { recreateDirectory } from "../filesystem/directory"; import { recreateDirectory } from "../filesystem/directory";
import { execAsyncRemote } from "../process/execAsync"; import { execAsyncRemote } from "../process/execAsync";
import { spawnAsync } from "../process/spawnAsync"; import { spawnAsync } from "../process/spawnAsync";
import type { Compose } from "@dokploy/server/services/compose";
import type { InferResultType } from "@dokploy/server/types/with";
export const getErrorCloneRequirements = (entity: { export const getErrorCloneRequirements = (entity: {
giteaRepository?: string | null; giteaRepository?: string | null;

View File

@ -242,7 +242,7 @@ importers:
specifier: ^10.43.6 specifier: ^10.43.6
version: 10.45.2(@tanstack/react-query@4.36.1(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/client@10.45.2(@trpc/server@10.45.2))(@trpc/server@10.45.2)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) version: 10.45.2(@tanstack/react-query@4.36.1(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(@trpc/client@10.45.2(@trpc/server@10.45.2))(@trpc/server@10.45.2)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)
'@trpc/server': '@trpc/server':
specifier: ^10.45.2 specifier: ^10.43.6
version: 10.45.2 version: 10.45.2
'@uiw/codemirror-theme-github': '@uiw/codemirror-theme-github':
specifier: ^4.22.1 specifier: ^4.22.1
@ -349,9 +349,6 @@ importers:
next-themes: next-themes:
specifier: ^0.2.1 specifier: ^0.2.1
version: 0.2.1(next@15.0.1(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0) version: 0.2.1(next@15.0.1(@opentelemetry/api@1.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0)
node-fetch:
specifier: ^3.3.2
version: 3.3.2
node-os-utils: node-os-utils:
specifier: 1.3.7 specifier: 1.3.7
version: 1.3.7 version: 1.3.7
@ -471,7 +468,7 @@ importers:
specifier: 4.0.9 specifier: 4.0.9
version: 4.0.9 version: 4.0.9
'@types/node': '@types/node':
specifier: ^18.19.42 specifier: ^18.17.0
version: 18.19.42 version: 18.19.42
'@types/node-os-utils': '@types/node-os-utils':
specifier: 1.3.4 specifier: 1.3.4
@ -4474,10 +4471,6 @@ packages:
resolution: {integrity: sha512-wAV9QHOsNbwnWdNW2FYvE1P56wtgSbM+3SZcdGiWQILwVjACCXDCI3Ai8QlCjMDB8YK5zySiXZYBiwGmNY3lnw==} resolution: {integrity: sha512-wAV9QHOsNbwnWdNW2FYvE1P56wtgSbM+3SZcdGiWQILwVjACCXDCI3Ai8QlCjMDB8YK5zySiXZYBiwGmNY3lnw==}
engines: {node: '>=12'} engines: {node: '>=12'}
data-uri-to-buffer@4.0.1:
resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==}
engines: {node: '>= 12'}
date-fns@3.6.0: date-fns@3.6.0:
resolution: {integrity: sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==} resolution: {integrity: sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==}
@ -4928,10 +4921,6 @@ packages:
fault@1.0.4: fault@1.0.4:
resolution: {integrity: sha512-CJ0HCB5tL5fYTEA7ToAq5+kTwd++Borf1/bifxd9iT70QcXr4MRrO3Llf8Ifs70q+SJcGHFtnIE/Nw6giCtECA==} resolution: {integrity: sha512-CJ0HCB5tL5fYTEA7ToAq5+kTwd++Borf1/bifxd9iT70QcXr4MRrO3Llf8Ifs70q+SJcGHFtnIE/Nw6giCtECA==}
fetch-blob@3.2.0:
resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==}
engines: {node: ^12.20 || >= 14.13}
file-uri-to-path@1.0.0: file-uri-to-path@1.0.0:
resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==} resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==}
@ -4972,10 +4961,6 @@ packages:
resolution: {integrity: sha512-wzsgA6WOq+09wrU1tsJ09udeR/YZRaeArL9e1wPbFg3GG2yDnC2ldKpxs4xunpFF9DgqCqOIra3bc1HWrJ37Ww==} resolution: {integrity: sha512-wzsgA6WOq+09wrU1tsJ09udeR/YZRaeArL9e1wPbFg3GG2yDnC2ldKpxs4xunpFF9DgqCqOIra3bc1HWrJ37Ww==}
engines: {node: '>=0.4.x'} engines: {node: '>=0.4.x'}
formdata-polyfill@4.0.10:
resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==}
engines: {node: '>=12.20.0'}
fraction.js@4.3.7: fraction.js@4.3.7:
resolution: {integrity: sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==} resolution: {integrity: sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==}
@ -6073,10 +6058,6 @@ packages:
encoding: encoding:
optional: true optional: true
node-fetch@3.3.2:
resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
node-gyp-build-optional-packages@5.2.2: node-gyp-build-optional-packages@5.2.2:
resolution: {integrity: sha512-s+w+rBWnpTMwSFbaE0UXsRlg7hU4FjekKU4eyAih5T8nJuNZT1nNsskXpxmeqSK9UzkBl6UgRlnKc8hz8IEqOw==} resolution: {integrity: sha512-s+w+rBWnpTMwSFbaE0UXsRlg7hU4FjekKU4eyAih5T8nJuNZT1nNsskXpxmeqSK9UzkBl6UgRlnKc8hz8IEqOw==}
hasBin: true hasBin: true
@ -11412,8 +11393,6 @@ snapshots:
dargs@8.1.0: {} dargs@8.1.0: {}
data-uri-to-buffer@4.0.1: {}
date-fns@3.6.0: {} date-fns@3.6.0: {}
dateformat@4.6.3: {} dateformat@4.6.3: {}
@ -11820,11 +11799,6 @@ snapshots:
dependencies: dependencies:
format: 0.2.2 format: 0.2.2
fetch-blob@3.2.0:
dependencies:
node-domexception: 1.0.0
web-streams-polyfill: 3.3.3
file-uri-to-path@1.0.0: file-uri-to-path@1.0.0:
optional: true optional: true
@ -11860,10 +11834,6 @@ snapshots:
format@0.2.2: {} format@0.2.2: {}
formdata-polyfill@4.0.10:
dependencies:
fetch-blob: 3.2.0
fraction.js@4.3.7: {} fraction.js@4.3.7: {}
fresh@0.5.2: {} fresh@0.5.2: {}
@ -13165,12 +13135,6 @@ snapshots:
optionalDependencies: optionalDependencies:
encoding: 0.1.13 encoding: 0.1.13
node-fetch@3.3.2:
dependencies:
data-uri-to-buffer: 4.0.1
fetch-blob: 3.2.0
formdata-polyfill: 4.0.10
node-gyp-build-optional-packages@5.2.2: node-gyp-build-optional-packages@5.2.2:
dependencies: dependencies:
detect-libc: 2.0.3 detect-libc: 2.0.3