tsvesync 1.3.0 → 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/helpers.js +3 -4
- package/dist/lib/session.js +7 -2
- package/package.json +1 -1
- package/src/lib/helpers.ts +2 -3
- package/src/lib/session.ts +5 -3
package/dist/lib/helpers.js
CHANGED
|
@@ -403,11 +403,10 @@ class Helpers {
|
|
|
403
403
|
// Check for token expiration or auth invalidation
|
|
404
404
|
const httpStatus = error.response.status;
|
|
405
405
|
const msg = responseData === null || responseData === void 0 ? void 0 : responseData.msg;
|
|
406
|
-
if (
|
|
407
|
-
msg === 'token expired' ||
|
|
408
|
-
httpStatus === 401 ||
|
|
406
|
+
if (httpStatus === 401 ||
|
|
409
407
|
httpStatus === 419 ||
|
|
410
|
-
(
|
|
408
|
+
(responseData === null || responseData === void 0 ? void 0 : responseData.code) === 4001004 ||
|
|
409
|
+
(typeof msg === 'string' && /token\s*expired/i.test(msg))) {
|
|
411
410
|
logger_1.logger.debug('Token expired, attempting to re-login...');
|
|
412
411
|
// Re-login
|
|
413
412
|
if (await manager.login()) {
|
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/helpers.ts
CHANGED
|
@@ -495,11 +495,10 @@ export class Helpers {
|
|
|
495
495
|
const httpStatus = error.response.status;
|
|
496
496
|
const msg: string | undefined = responseData?.msg;
|
|
497
497
|
if (
|
|
498
|
-
responseData?.code === 4001004 ||
|
|
499
|
-
msg === 'token expired' ||
|
|
500
498
|
httpStatus === 401 ||
|
|
501
499
|
httpStatus === 419 ||
|
|
502
|
-
|
|
500
|
+
responseData?.code === 4001004 ||
|
|
501
|
+
(typeof msg === 'string' && /token\s*expired/i.test(msg))
|
|
503
502
|
) {
|
|
504
503
|
logger.debug('Token expired, attempting to re-login...');
|
|
505
504
|
|
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
|
-
|