@djust-b2b/djust-front-sdk 1.26.0 → 1.26.2
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.
|
@@ -7,7 +7,7 @@ export type OfferStatus = "ACTIVE" | "INACTIVE" | "DELETED";
|
|
|
7
7
|
export type OfferPriceType = "PUBLIC" | "GROUP" | "ACCOUNT";
|
|
8
8
|
export interface OfferDto {
|
|
9
9
|
currency: string;
|
|
10
|
-
|
|
10
|
+
customFieldValues: CustomFieldValueDto[];
|
|
11
11
|
itemPerPack: number;
|
|
12
12
|
maxOrderQuantity: number;
|
|
13
13
|
minOrderQuantity: number;
|
|
@@ -102,28 +102,17 @@ const serializeParams = (params, useRepeat) => {
|
|
|
102
102
|
}
|
|
103
103
|
return qs.stringify(params, { arrayFormat: "bracket", skipNull: true });
|
|
104
104
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
]);
|
|
116
|
-
const publicRoutePatterns = [
|
|
117
|
-
"/v1/shop/navigation-category/",
|
|
118
|
-
"/v1/shop/products/",
|
|
119
|
-
"/v1/shop/product-variants/",
|
|
120
|
-
];
|
|
121
|
-
const isPublicRoute = (path, method) => {
|
|
122
|
-
var _a;
|
|
123
|
-
if (publicRoutes.has(path) && ((_a = publicRoutes.get(path)) === null || _a === void 0 ? void 0 : _a.has(method))) {
|
|
124
|
-
return true;
|
|
105
|
+
const isTokenValid = (token) => {
|
|
106
|
+
if (!token)
|
|
107
|
+
return false;
|
|
108
|
+
try {
|
|
109
|
+
const payload = JSON.parse(atob(token.split(".")[1]));
|
|
110
|
+
const now = Math.floor(Date.now() / 1000);
|
|
111
|
+
return payload.exp && payload.exp > now;
|
|
112
|
+
}
|
|
113
|
+
catch (_a) {
|
|
114
|
+
return false;
|
|
125
115
|
}
|
|
126
|
-
return publicRoutePatterns.some((pattern) => path.startsWith(pattern));
|
|
127
116
|
};
|
|
128
117
|
const enhancedFetch = async ({ path, method, params = {}, body, }) => {
|
|
129
118
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -140,10 +129,8 @@ const enhancedFetch = async ({ path, method, params = {}, body, }) => {
|
|
|
140
129
|
"dj-api-key": apiKey,
|
|
141
130
|
"Content-Type": "application/json",
|
|
142
131
|
});
|
|
143
|
-
if (
|
|
144
|
-
|
|
145
|
-
requestHeaders.append("Authorization", `Bearer ${accessToken}`);
|
|
146
|
-
}
|
|
132
|
+
if (isTokenValid(accessToken)) {
|
|
133
|
+
requestHeaders.append("Authorization", `Bearer ${accessToken}`);
|
|
147
134
|
}
|
|
148
135
|
if (locale)
|
|
149
136
|
requestHeaders.append("locale", locale);
|