MCPcopy Create free account
hub / github.com/Rfym21/Qwen2API / getTokenRemainingHours

Method getTokenRemainingHours

src/utils/token-manager.js:116–123  ·  view source on GitHub ↗

* 获取令牌剩余有效时间(小时) * @param {string} token - JWT令牌 * @returns {number} 剩余小时数,-1表示无效令牌

(token)

Source from the content-addressed store, hash-verified

114 */
115 getTokenRemainingHours(token) {
116 const decoded = this.validateToken(token)
117 if (!decoded) return -1
118
119 const now = Math.floor(Date.now() / 1000)
120 const remainingSeconds = decoded.exp - now
121 return Math.max(0, Math.round(remainingSeconds / 3600))
122 }
123
124 /**
125 * 刷新单个账户的令牌
126 * @param {Object} account - 账户对象 {email, password, token, expires}

Callers 1

refreshTokenMethod · 0.95

Calls 1

validateTokenMethod · 0.95

Tested by

no test coverage detected