Repository navigation
Expand file tree
/
Copy pathdebug-jwt.js
More file actions
34 lines (27 loc) · 1.45 KB
/
Copy pathdebug-jwt.js
File metadata and controls
34 lines (27 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const jwt = require('jsonwebtoken');
// 1. Put your JWT_SECRET here (from .env)
const secret = "bin/xRelBVgyJS75ICigIBb0IStL5Z/9BZO3Holu1Z5aH/sO3Ed0b6Or7DNH00K+62tCCfS+yA6OiwRLyl+4Sg==";
// 2. Put the token that is failing here (without 'Bearer ')
const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1seWRzdnJzZXpyanN0bHFkbGl2Iiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc2OTUwNDAyMCwiZXhwIjoyMDg1MDgwMDIwfQ.rwSDc6nfvS1DjbA7n0gr1xJjtfnz81d-L03wVOUXa2E";
if (!secret) {
console.error("❌ Error: JWT_SECRET environment variable is not set.");
process.exit(1);
}
if (token === "YOUR_TOKEN_HERE") {
console.error("❌ Error: You need to replace 'YOUR_TOKEN_HERE' with the actual token in the script.");
process.exit(1);
}
try {
console.log(`\n🔑 Testing Secret: ${secret.substring(0, 5)}...`);
console.log(`🎟️ Testing Token: ${token.substring(0, 10)}...`);
const decoded = jwt.verify(token, secret);
console.log("\n✅ SUCCESS! Token is valid.");
console.log("Payload:", decoded);
} catch (err) {
console.error("\n❌ FAILED! Verification error:");
console.error(err.message);
if (err.message === 'invalid signature') {
console.log("\n💡 TIP: 'invalid signature' means the JWT_SECRET in your .env does NOT match the secret used to sign this token.");
console.log("👉 Double check Supabase Dashboard > Project Settings > API > JWT Settings > JWT Secret.");
}
}