@iblai/web-utils 1.2.10 → 1.2.12
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/data-layer/src/features/reports/api-slice.d.ts +150 -279
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +45 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +45 -6
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2781,7 +2781,7 @@ async function isDmTokenExpired(storageService) {
|
|
|
2781
2781
|
try {
|
|
2782
2782
|
const dmTokenExpires = await storageService.getItem(LOCAL_STORAGE_KEYS.DM_TOKEN_EXPIRES);
|
|
2783
2783
|
if (!dmTokenExpires) {
|
|
2784
|
-
return
|
|
2784
|
+
return false;
|
|
2785
2785
|
}
|
|
2786
2786
|
const expiryTime = new Date(dmTokenExpires).getTime();
|
|
2787
2787
|
const currentTime = Date.now();
|
|
@@ -3011,14 +3011,23 @@ function useAuthProvider({ middleware = new Map(), onAuthSuccess, onAuthFailure,
|
|
|
3011
3011
|
}
|
|
3012
3012
|
// Check JWT token expiry and force logout for protected routes
|
|
3013
3013
|
if (isProtectedRoute && storageService) {
|
|
3014
|
+
const dmTokenInLocalStorage = await storageService.getItem(LOCAL_STORAGE_KEYS.DM_TOKEN_KEY);
|
|
3014
3015
|
const dmTokenExpired = await isDmTokenExpired(storageService);
|
|
3015
|
-
if (dmTokenExpired) {
|
|
3016
|
-
console.log(
|
|
3016
|
+
if (!dmTokenInLocalStorage || dmTokenExpired) {
|
|
3017
|
+
console.log();
|
|
3018
|
+
if (!!dmTokenInLocalStorage) {
|
|
3019
|
+
console.log("[auth-redirect] DM token doesn't exists");
|
|
3020
|
+
}
|
|
3021
|
+
else {
|
|
3022
|
+
console.log("[auth-redirect] DM token doesn't exists, forcing logout");
|
|
3023
|
+
}
|
|
3017
3024
|
// Clear all auth-related storage keys
|
|
3018
|
-
|
|
3025
|
+
if (!!dmTokenInLocalStorage) {
|
|
3026
|
+
clearAuthCookies();
|
|
3027
|
+
}
|
|
3019
3028
|
const reason = "DM token expired";
|
|
3020
3029
|
onAuthFailure === null || onAuthFailure === void 0 ? void 0 : onAuthFailure(reason);
|
|
3021
|
-
safeRedirectToAuthSpa(undefined, undefined,
|
|
3030
|
+
safeRedirectToAuthSpa(undefined, undefined, !!dmTokenInLocalStorage); // with no dm token at all in storage, don't force logout
|
|
3022
3031
|
return;
|
|
3023
3032
|
}
|
|
3024
3033
|
// Validate JWT token user_id
|
|
@@ -16083,7 +16092,37 @@ createApi({
|
|
|
16083
16092
|
tagTypes: ['reports', 'reportDetail'],
|
|
16084
16093
|
endpoints: (builder) => ({
|
|
16085
16094
|
getReports: builder.query({
|
|
16086
|
-
|
|
16095
|
+
async queryFn({ key, mentor_id }) {
|
|
16096
|
+
var _a, _b;
|
|
16097
|
+
try {
|
|
16098
|
+
const baseUrl = getServiceUrl(SERVICES.DM);
|
|
16099
|
+
const authHeaders = await getHeaders(SERVICES.DM);
|
|
16100
|
+
const url = new URL(`/dm/api/reports/platforms/${encodeURIComponent(key)}/`, baseUrl);
|
|
16101
|
+
if (mentor_id) {
|
|
16102
|
+
url.searchParams.set('mentor_id', mentor_id);
|
|
16103
|
+
}
|
|
16104
|
+
const response = await fetch(url.toString(), {
|
|
16105
|
+
method: 'GET',
|
|
16106
|
+
headers: {
|
|
16107
|
+
'Content-Type': 'application/json',
|
|
16108
|
+
...(authHeaders !== null && authHeaders !== void 0 ? authHeaders : {}),
|
|
16109
|
+
},
|
|
16110
|
+
});
|
|
16111
|
+
const data = (await response.json());
|
|
16112
|
+
if (!response.ok) {
|
|
16113
|
+
return { error: { status: response.status, data } };
|
|
16114
|
+
}
|
|
16115
|
+
return { data };
|
|
16116
|
+
}
|
|
16117
|
+
catch (err) {
|
|
16118
|
+
return {
|
|
16119
|
+
error: {
|
|
16120
|
+
status: (_a = err === null || err === void 0 ? void 0 : err.status) !== null && _a !== void 0 ? _a : 500,
|
|
16121
|
+
data: (_b = err === null || err === void 0 ? void 0 : err.message) !== null && _b !== void 0 ? _b : 'Unknown error',
|
|
16122
|
+
},
|
|
16123
|
+
};
|
|
16124
|
+
}
|
|
16125
|
+
},
|
|
16087
16126
|
providesTags: ['reports'],
|
|
16088
16127
|
}),
|
|
16089
16128
|
getReportDetail: builder.query({
|