whistler-mcp 1.0.13 → 1.0.14

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.
@@ -6,14 +6,32 @@ import os from 'os';
6
6
  const API_BASE_URL = process.env.API_URL || 'https://whistler-backend.onrender.com/api';
7
7
  export const TOKEN_PATH = path.join(os.homedir(), '.whistler_mcp_token.json');
8
8
 
9
+ function isTokenExpired(token) {
10
+ try {
11
+ const payload = JSON.parse(Buffer.from(token.split('.')[1], 'base64').toString('utf8'));
12
+ return payload.exp && payload.exp < Math.floor(Date.now() / 1000);
13
+ } catch {
14
+ return false;
15
+ }
16
+ }
17
+
9
18
  export function getSavedToken() {
10
19
  if (fs.existsSync(TOKEN_PATH)) {
11
20
  try {
12
21
  const data = JSON.parse(fs.readFileSync(TOKEN_PATH, 'utf8'));
13
- return data.token;
22
+ if (data.token) {
23
+ if (isTokenExpired(data.token)) {
24
+ // Remove the stale token file so the next call prompts re-login
25
+ fs.unlinkSync(TOKEN_PATH);
26
+ return null;
27
+ }
28
+ return data.token;
29
+ }
14
30
  } catch (e) { }
15
31
  }
16
- return process.env.WHISTLER_API_TOKEN || null;
32
+ const envToken = process.env.WHISTLER_API_TOKEN || null;
33
+ if (envToken && isTokenExpired(envToken)) return null;
34
+ return envToken;
17
35
  }
18
36
 
19
37
  export function saveToken(token, user) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whistler-mcp",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "An MCP Server for retrieving placement data, job roles, and platform statistics from the Whistler API.",
5
5
  "main": "server.js",
6
6
  "bin": {