@data-fair/lib-vue 1.11.0 → 1.12.0
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/package.json +1 -1
- package/session.js +5 -5
package/package.json
CHANGED
package/session.js
CHANGED
|
@@ -14,13 +14,12 @@ function jwtDecodeAlive (jwt) {
|
|
|
14
14
|
if (!decoded) { return }
|
|
15
15
|
const now = Math.ceil(Date.now().valueOf() / 1000)
|
|
16
16
|
if (typeof decoded.exp !== 'undefined' && decoded.exp < now) {
|
|
17
|
-
|
|
17
|
+
// token expired
|
|
18
18
|
return
|
|
19
19
|
}
|
|
20
20
|
if (typeof decoded.nbf !== 'undefined' && decoded.nbf > now) {
|
|
21
21
|
console.warn(`token not yet valid: ${decoded.nbf}>${now}, ${JSON.stringify(decoded)}`)
|
|
22
|
-
// do not return
|
|
23
|
-
// return null
|
|
22
|
+
// do not return here, this is probably a false flag due to a slightly mismatched clock
|
|
24
23
|
}
|
|
25
24
|
return decoded
|
|
26
25
|
}
|
|
@@ -216,7 +215,7 @@ export async function getSession (initOptions) {
|
|
|
216
215
|
await customFetch(`${options.directoryUrl}/api/auth/keepalive`, { method: 'POST' })
|
|
217
216
|
} catch (err) {
|
|
218
217
|
if (err instanceof FetchError && err.statusCode === 401) {
|
|
219
|
-
|
|
218
|
+
console.warn('session was expired or deleted server side')
|
|
220
219
|
} else {
|
|
221
220
|
throw err
|
|
222
221
|
}
|
|
@@ -233,7 +232,8 @@ export async function getSession (initOptions) {
|
|
|
233
232
|
// also run an auto-refresh loop
|
|
234
233
|
if (!ssr && !inIframe) {
|
|
235
234
|
const lastKeepalive = window.localStorage.getItem('sd-keepalive' + options.sitePath)
|
|
236
|
-
|
|
235
|
+
// check cookies.get('id_token') not state.user so that we do a keepalive on expired id tokens
|
|
236
|
+
if (cookies.get('id_token') && (!lastKeepalive || (new Date().getTime() - Number(lastKeepalive)) > 10000)) {
|
|
237
237
|
await keepalive()
|
|
238
238
|
}
|
|
239
239
|
const refreshLoopDelay = 10 * 60 * 1000 // 10 minutes
|