comty.js 0.60.5 → 0.60.6
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.
|
@@ -8,27 +8,25 @@ exports. default = async (data, callback) => {
|
|
|
8
8
|
return false
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
if (data.response
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
if (data.response) {
|
|
12
|
+
if (data.response.status === 401) {
|
|
13
|
+
// check if the server issue a refresh token on data
|
|
14
|
+
if (data.response.data.expired) {
|
|
15
|
+
try {
|
|
16
|
+
console.log(`Session expired, trying to regenerate...`)
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
await _refreshToken2.default.call(void 0, )
|
|
19
|
+
} catch (error) {
|
|
20
|
+
__comty_shared_state.eventBus.emit("session.invalid", error.message)
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
console.error(`Failed to regenerate token: ${error.message}`)
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
throw new Error(`Invalid or Expired session`)
|
|
25
|
+
}
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
return await callback()
|
|
28
|
+
}
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
|
-
|
|
30
|
-
if (data.response.status === 403) {
|
|
31
|
-
|
|
32
|
-
}
|
|
33
31
|
}
|
|
34
32
|
}
|