EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
test-jwt.js
Go to the documentation of this file.
1#!/usr/bin/env node
2require('dotenv').config();
3const jwt = require('jsonwebtoken');
4
5const token = process.argv[2];
6const JWT_SECRET = process.env.JWT_SECRET;
7
8if (!token) {
9 console.error('Usage: node test-jwt.js <token>');
10 process.exit(1);
11}
12
13console.log('JWT_SECRET:', JWT_SECRET ? `${JWT_SECRET.substring(0, 10)}...` : 'NOT SET');
14console.log('Token:', token.substring(0, 50) + '...');
15console.log('');
16
17try {
18 const decoded = jwt.verify(token, JWT_SECRET);
19 console.log('✅ Token is valid!');
20 console.log('Decoded:', JSON.stringify(decoded, null, 2));
21} catch (err) {
22 console.error('❌ Token verification failed:', err.message);
23 process.exit(1);
24}