tsvesync 1.3.1 → 1.3.2
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/dist/lib/session.js +7 -2
- package/package.json +1 -1
- package/src/lib/session.ts +5 -3
package/dist/lib/session.js
CHANGED
|
@@ -10,8 +10,13 @@ function decodeJwtTimestamps(token) {
|
|
|
10
10
|
if (parts.length !== 3)
|
|
11
11
|
return null;
|
|
12
12
|
const payload = JSON.parse(Buffer.from(parts[1].replace(/-/g, '+').replace(/_/g, '/'), 'base64').toString('utf8'));
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
let iat = typeof payload.iat === 'number' ? payload.iat : undefined;
|
|
14
|
+
let exp = typeof payload.exp === 'number' ? payload.exp : undefined;
|
|
15
|
+
// Normalize to seconds if values are in milliseconds
|
|
16
|
+
if (iat && iat > 1e11)
|
|
17
|
+
iat = Math.floor(iat / 1000);
|
|
18
|
+
if (exp && exp > 1e11)
|
|
19
|
+
exp = Math.floor(exp / 1000);
|
|
15
20
|
return { iat, exp };
|
|
16
21
|
}
|
|
17
22
|
catch (_a) {
|
package/package.json
CHANGED
package/src/lib/session.ts
CHANGED
|
@@ -25,11 +25,13 @@ export function decodeJwtTimestamps(token: string): { iat?: number; exp?: number
|
|
|
25
25
|
const parts = token.split('.');
|
|
26
26
|
if (parts.length !== 3) return null;
|
|
27
27
|
const payload = JSON.parse(Buffer.from(parts[1].replace(/-/g, '+').replace(/_/g, '/'), 'base64').toString('utf8'));
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
let iat = typeof payload.iat === 'number' ? payload.iat : undefined;
|
|
29
|
+
let exp = typeof payload.exp === 'number' ? payload.exp : undefined;
|
|
30
|
+
// Normalize to seconds if values are in milliseconds
|
|
31
|
+
if (iat && iat > 1e11) iat = Math.floor(iat / 1000);
|
|
32
|
+
if (exp && exp > 1e11) exp = Math.floor(exp / 1000);
|
|
30
33
|
return { iat, exp };
|
|
31
34
|
} catch {
|
|
32
35
|
return null;
|
|
33
36
|
}
|
|
34
37
|
}
|
|
35
|
-
|