mikasa-cli 1.0.9 → 1.0.10
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.
- package/package.json +1 -1
- package/src/cli/commands/auth/login.js +1 -1
- package/src/index.js +30 -37
- package/src/lib/auth-client.js +1 -1
- package/src/lib/auth.js +1 -1
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@ import prisma from "../../../lib/db.js";
|
|
|
16
16
|
|
|
17
17
|
// dotenv.config();
|
|
18
18
|
|
|
19
|
-
const DEMO_URL = "https://mikasa-cli-
|
|
19
|
+
const DEMO_URL = "https://mikasa-cli-backend.onrender.com";
|
|
20
20
|
const CLIENT_ID = process.env.GITHUB_CLIENT_ID || "Ov23lir2byjlHCgWLvEf";
|
|
21
21
|
const CONFIG_DIR = path.join(os.homedir(), ".better-auth");
|
|
22
22
|
const TOKEN_FILE = path.join(CONFIG_DIR, "token.json");
|
package/src/index.js
CHANGED
|
@@ -46,6 +46,14 @@ dotenv.config();
|
|
|
46
46
|
|
|
47
47
|
const app = express();
|
|
48
48
|
|
|
49
|
+
/* =======================
|
|
50
|
+
CORS (Express 5 safe)
|
|
51
|
+
======================= */
|
|
52
|
+
app.options(/.*/, cors({
|
|
53
|
+
origin: "https://mikasa-cli-xwcm.vercel.app",
|
|
54
|
+
credentials: true,
|
|
55
|
+
}));
|
|
56
|
+
|
|
49
57
|
app.use(cors({
|
|
50
58
|
origin: "https://mikasa-cli-xwcm.vercel.app",
|
|
51
59
|
credentials: true,
|
|
@@ -53,17 +61,15 @@ app.use(cors({
|
|
|
53
61
|
|
|
54
62
|
app.use(express.json());
|
|
55
63
|
|
|
56
|
-
|
|
64
|
+
/* =======================
|
|
65
|
+
AUTH ROUTES (FIXED)
|
|
66
|
+
======================= */
|
|
67
|
+
// ✅ REGEX is REQUIRED for Express 5
|
|
57
68
|
app.all(/^\/api\/auth\/.*$/, toNodeHandler(auth));
|
|
58
69
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// });
|
|
63
|
-
// res.json(session);
|
|
64
|
-
// });
|
|
65
|
-
|
|
66
|
-
// Fixed: This endpoint now properly handles Bearer token authentication
|
|
70
|
+
/* =======================
|
|
71
|
+
SESSION ROUTES
|
|
72
|
+
======================= */
|
|
67
73
|
app.get("/api/me", async (req, res) => {
|
|
68
74
|
try {
|
|
69
75
|
const session = await auth.api.getSession({
|
|
@@ -74,46 +80,33 @@ app.get("/api/me", async (req, res) => {
|
|
|
74
80
|
return res.status(401).json({ error: "No active session" });
|
|
75
81
|
}
|
|
76
82
|
|
|
77
|
-
|
|
83
|
+
res.json(session);
|
|
78
84
|
} catch (error) {
|
|
79
85
|
console.error("Session error:", error);
|
|
80
|
-
|
|
86
|
+
res.status(500).json({ error: "Failed to get session" });
|
|
81
87
|
}
|
|
82
88
|
});
|
|
83
89
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
try {
|
|
91
|
-
const session = await auth.api.getSession({
|
|
92
|
-
headers: {
|
|
93
|
-
authorization: `Bearer ${access_token}`
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
if (!session) {
|
|
98
|
-
return res.status(401).json({ error: "Invalid token" });
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return res.json(session);
|
|
102
|
-
} catch (error) {
|
|
103
|
-
console.error("Token validation error:", error);
|
|
104
|
-
return res.status(401).json({ error: "Unauthorized", details: error.message });
|
|
105
|
-
}
|
|
90
|
+
/* =======================
|
|
91
|
+
HEALTH CHECK
|
|
92
|
+
======================= */
|
|
93
|
+
app.get("/", (req, res) => {
|
|
94
|
+
res.status(200).json({ message: "backend working" });
|
|
106
95
|
});
|
|
107
96
|
|
|
108
|
-
|
|
97
|
+
/* =======================
|
|
98
|
+
DEVICE REDIRECT
|
|
99
|
+
======================= */
|
|
109
100
|
app.get("/device", (req, res) => {
|
|
110
101
|
const { user_code } = req.query;
|
|
111
|
-
res.redirect(
|
|
102
|
+
res.redirect(
|
|
103
|
+
`https://mikasa-cli-xwcm.vercel.app/device?user_code=${user_code}`
|
|
104
|
+
);
|
|
112
105
|
});
|
|
113
106
|
|
|
114
107
|
const PORT = process.env.PORT || 5000;
|
|
115
|
-
|
|
116
108
|
app.listen(PORT, () => {
|
|
117
|
-
console.log(`Server running on
|
|
109
|
+
console.log(`Server running on port ${PORT}`);
|
|
118
110
|
});
|
|
119
111
|
|
|
112
|
+
|
package/src/lib/auth-client.js
CHANGED
|
@@ -2,7 +2,7 @@ import { deviceAuthorizationClient } from "better-auth/client/plugins"
|
|
|
2
2
|
import { createAuthClient } from "better-auth/client"
|
|
3
3
|
|
|
4
4
|
export const authClient = createAuthClient({
|
|
5
|
-
baseURL: "https://mikasa-cli-
|
|
5
|
+
baseURL: "https://mikasa-cli-backend.onrender.com",
|
|
6
6
|
plugins: [
|
|
7
7
|
deviceAuthorizationClient(),
|
|
8
8
|
],
|
package/src/lib/auth.js
CHANGED
|
@@ -19,7 +19,7 @@ export const auth = betterAuth({
|
|
|
19
19
|
socialProviders: {
|
|
20
20
|
github: {
|
|
21
21
|
clientId: process.env.GITHUB_CLIENT_ID || "Ov23lir2byjlHCgWLvEf",
|
|
22
|
-
clientSecret: process.env.GITHUB_CLIENT_SECRET || "
|
|
22
|
+
clientSecret: process.env.GITHUB_CLIENT_SECRET || "60146506b3fdfe84151f70683aea52f7cbe04cd6",
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
// logger: {
|