@djust-b2b/djust-front-sdk 1.21.18 → 1.21.21
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.
|
@@ -113,24 +113,18 @@ const publicRoutes = new Map([
|
|
|
113
113
|
["/v1/shop/attributes", new Set(["GET"])],
|
|
114
114
|
["/v1/shop/custom-fields", new Set(["GET"])],
|
|
115
115
|
]);
|
|
116
|
-
const publicRoutePatterns = [
|
|
117
|
-
|
|
118
|
-
const hybridRoutePatterns = [
|
|
119
|
-
"/v1/shop/offer-inventories",
|
|
116
|
+
const publicRoutePatterns = [
|
|
117
|
+
"/v1/shop/navigation-category/",
|
|
120
118
|
"/v1/shop/products/",
|
|
121
119
|
"/v1/shop/product-variants/",
|
|
122
|
-
"/v2/shop/autocomplete",
|
|
123
|
-
"/v2/shop/search",
|
|
124
120
|
];
|
|
125
|
-
const
|
|
121
|
+
const isPublicRoute = (path, method) => {
|
|
126
122
|
var _a;
|
|
127
|
-
if (publicRoutes.has(path) && ((_a = publicRoutes.get(path)) === null || _a === void 0 ? void 0 : _a.has(method)))
|
|
123
|
+
if (publicRoutes.has(path) && ((_a = publicRoutes.get(path)) === null || _a === void 0 ? void 0 : _a.has(method))) {
|
|
128
124
|
return true;
|
|
125
|
+
}
|
|
129
126
|
return publicRoutePatterns.some((pattern) => path.startsWith(pattern));
|
|
130
127
|
};
|
|
131
|
-
const isHybridRoute = (path) => {
|
|
132
|
-
return hybridRoutePatterns.some((pattern) => path.startsWith(pattern));
|
|
133
|
-
};
|
|
134
128
|
const enhancedFetch = async ({ path, method, params = {}, body, }) => {
|
|
135
129
|
var _a, _b, _c, _d, _e, _f;
|
|
136
130
|
if (!isClientInitialized(clientConfig)) {
|
|
@@ -146,18 +140,10 @@ const enhancedFetch = async ({ path, method, params = {}, body, }) => {
|
|
|
146
140
|
"dj-api-key": apiKey,
|
|
147
141
|
"Content-Type": "application/json",
|
|
148
142
|
});
|
|
149
|
-
if (!
|
|
150
|
-
if (
|
|
151
|
-
|
|
152
|
-
Sentry.captureException(error, {
|
|
153
|
-
tags: { env: clientConfig.env },
|
|
154
|
-
});
|
|
155
|
-
throw error;
|
|
143
|
+
if (!isPublicRoute(path, method)) {
|
|
144
|
+
if (accessToken) {
|
|
145
|
+
requestHeaders.append("Authorization", `Bearer ${accessToken}`);
|
|
156
146
|
}
|
|
157
|
-
requestHeaders.append("Authorization", `Bearer ${accessToken}`);
|
|
158
|
-
}
|
|
159
|
-
else if (isHybridRoute(path) && accessToken) {
|
|
160
|
-
requestHeaders.append("Authorization", `Bearer ${accessToken}`);
|
|
161
147
|
}
|
|
162
148
|
if (locale)
|
|
163
149
|
requestHeaders.append("locale", locale);
|