@osimatic/helpers-js 1.0.62 → 1.0.63
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/network.js +6 -4
- package/package.json +1 -1
- package/.idea/helpers-js.iml +0 -8
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
package/network.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { JwtSession } = require('@osimatic/helpers-js/jwt');
|
|
1
2
|
|
|
2
3
|
class HTTPRequest {
|
|
3
4
|
static init() {
|
|
@@ -138,10 +139,8 @@ class HTTPRequest {
|
|
|
138
139
|
let jsonData = {};
|
|
139
140
|
try {
|
|
140
141
|
jsonData = await response.json();
|
|
141
|
-
//console.log(url, jsonData);
|
|
142
|
-
//console.log(response.status, response.statusText, jsonData['error']);
|
|
143
142
|
|
|
144
|
-
if (response.status === 401 && (response.statusText === 'Expired JWT Token' || typeof jsonData['error'] != 'undefined' && jsonData['error'] === 'expired_token')) {
|
|
143
|
+
if (response.status === 401 && (response.statusText === 'Expired JWT Token' || (typeof jsonData['message'] != 'undefined' && jsonData['message'] === 'Expired JWT Token') || (typeof jsonData['error'] != 'undefined' && jsonData['error'] === 'expired_token'))) {
|
|
145
144
|
HTTPRequest.refreshToken(() => HTTPRequest.get(url, data, successCallback, errorCallback));
|
|
146
145
|
return;
|
|
147
146
|
}
|
|
@@ -303,7 +302,7 @@ class HTTPRequest {
|
|
|
303
302
|
}
|
|
304
303
|
//console.log(url, jsonData);
|
|
305
304
|
|
|
306
|
-
if (response.status === 401 && url !== HTTPRequest.refreshTokenUrl && (response.statusText === 'Expired JWT Token' || (typeof jsonData['error'] != 'undefined' && jsonData['error'] === 'expired_token'))) {
|
|
305
|
+
if (response.status === 401 && url !== HTTPRequest.refreshTokenUrl && (response.statusText === 'Expired JWT Token' || (typeof jqxhr.responseJSON['message'] != 'undefined' && jqxhr.responseJSON['message'] === 'Expired JWT Token') || (typeof jsonData['error'] != 'undefined' && jsonData['error'] === 'expired_token'))) {
|
|
307
306
|
HTTPRequest.refreshToken(() => HTTPRequest.post(url, formData, successCallback, errorCallback, formErrorCallback));
|
|
308
307
|
return;
|
|
309
308
|
}
|
|
@@ -386,6 +385,9 @@ class HTTPRequest {
|
|
|
386
385
|
(data) => {
|
|
387
386
|
JwtSession.setToken(data.token);
|
|
388
387
|
JwtSession.setRefreshToken(data.refresh_token);
|
|
388
|
+
|
|
389
|
+
HTTPRequest.setAuthorizationHeader(JwtSession.getToken());
|
|
390
|
+
|
|
389
391
|
onCompleteCallback();
|
|
390
392
|
},
|
|
391
393
|
() => {
|
package/package.json
CHANGED
package/.idea/helpers-js.iml
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="WEB_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager">
|
|
4
|
-
<content url="file://$MODULE_DIR$" />
|
|
5
|
-
<orderEntry type="inheritedJdk" />
|
|
6
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
7
|
-
</component>
|
|
8
|
-
</module>
|
package/.idea/modules.xml
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<project version="4">
|
|
3
|
-
<component name="ProjectModuleManager">
|
|
4
|
-
<modules>
|
|
5
|
-
<module fileurl="file://$PROJECT_DIR$/.idea/helpers-js.iml" filepath="$PROJECT_DIR$/.idea/helpers-js.iml" />
|
|
6
|
-
</modules>
|
|
7
|
-
</component>
|
|
8
|
-
</project>
|