EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
test-token-flow.js
Go to the documentation of this file.
1#!/usr/bin/env node
2require('dotenv').config();
3const jwt = require('jsonwebtoken');
4
5const JWT_SECRET = process.env.JWT_SECRET;
6console.log('JWT_SECRET loaded:', JWT_SECRET ? 'Yes' : 'No');
7
8// Test token generation
9const token = jwt.sign(
10 { purpose: 'agent-download', timestamp: Date.now() },
11 JWT_SECRET,
12 { expiresIn: '5m' }
13);
14
15console.log('\nāœ… Token generated:', token.substring(0, 50) + '...');
16
17// Test token verification
18try {
19 const decoded = jwt.verify(token, JWT_SECRET);
20 console.log('āœ… Token verified successfully');
21 console.log('Decoded:', decoded);
22} catch (err) {
23 console.error('āŒ Token verification failed:', err.message);
24}