@atercates/claude-deck 0.2.5 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,5 +5,7 @@ export async function GET() {
5
5
  return NextResponse.json({
6
6
  user: os.userInfo().username,
7
7
  hostname: os.hostname(),
8
+ sshHost: process.env.SSH_HOST || null,
9
+ sshPort: process.env.SSH_PORT || null,
8
10
  });
9
11
  }
@@ -41,8 +41,13 @@ export function OpenInVSCode({
41
41
  window.open(`vscode://file${workingDirectory}`, "_self");
42
42
  } else {
43
43
  const user = systemInfo?.user || "root";
44
+ const sshHost = systemInfo?.sshHost || host;
45
+ const sshPort = systemInfo?.sshPort;
46
+ const remote = sshPort
47
+ ? `${user}@${sshHost}:${sshPort}`
48
+ : `${user}@${sshHost}`;
44
49
  window.open(
45
- `vscode://vscode-remote/ssh-remote+${user}@${host}${workingDirectory}`,
50
+ `vscode://vscode-remote/ssh-remote+${remote}${workingDirectory}`,
46
51
  "_self"
47
52
  );
48
53
  }
package/middleware.ts ADDED
@@ -0,0 +1,60 @@
1
+ import { NextRequest, NextResponse } from "next/server";
2
+
3
+ const PUBLIC_PATHS = [
4
+ "/login",
5
+ "/setup",
6
+ "/api/auth/",
7
+ "/_next/",
8
+ "/favicon.ico",
9
+ "/icon.svg",
10
+ "/icons/",
11
+ "/manifest.json",
12
+ "/sw.js",
13
+ ];
14
+
15
+ export async function middleware(request: NextRequest) {
16
+ const { pathname } = request.nextUrl;
17
+
18
+ if (PUBLIC_PATHS.some((p) => pathname.startsWith(p))) {
19
+ return NextResponse.next();
20
+ }
21
+
22
+ const sessionCookie = request.cookies.get("claude_deck_session");
23
+
24
+ const internalBase = `http://localhost:${process.env.PORT || 3011}`;
25
+
26
+ if (!sessionCookie?.value) {
27
+ const setupCheck = await fetch(`${internalBase}/api/auth/session`, {
28
+ headers: { cookie: "" },
29
+ });
30
+ const data = await setupCheck.json();
31
+
32
+ if (data.needsSetup) {
33
+ return NextResponse.redirect(new URL("/setup", request.url));
34
+ }
35
+
36
+ if (pathname.startsWith("/api/")) {
37
+ return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
38
+ }
39
+ return NextResponse.redirect(new URL("/login", request.url));
40
+ }
41
+
42
+ const sessionCheck = await fetch(`${internalBase}/api/auth/session`, {
43
+ headers: { cookie: `claude_deck_session=${sessionCookie.value}` },
44
+ });
45
+
46
+ if (!sessionCheck.ok) {
47
+ if (pathname.startsWith("/api/")) {
48
+ return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
49
+ }
50
+ return NextResponse.redirect(new URL("/login", request.url));
51
+ }
52
+
53
+ return NextResponse.next();
54
+ }
55
+
56
+ export const config = {
57
+ matcher: [
58
+ "/((?!_next/static|_next/image|favicon.ico|icon.svg|icons/|manifest.json|sw.js).*)",
59
+ ],
60
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atercates/claude-deck",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "Self-hosted web UI for managing Claude Code sessions",
5
5
  "bin": {
6
6
  "claude-deck": "./scripts/claude-deck"
@@ -17,6 +17,7 @@
17
17
  "scripts/",
18
18
  "stores/",
19
19
  "styles/",
20
+ "middleware.ts",
20
21
  "next.config.js",
21
22
  "postcss.config.mjs",
22
23
  "server.ts",