@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 = ["/v1/shop/navigation-category/"];
117
- // Liste des routes pouvant être à la fois publique et privée
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 routeIsPublic = (path, method) => {
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 (!routeIsPublic(path, method) && !isHybridRoute) {
150
- if (!accessToken) {
151
- const error = new Error("[Djust SDK] Private route need accessToken.");
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djust-b2b/djust-front-sdk",
3
- "version": "1.21.18",
3
+ "version": "1.21.21",
4
4
  "description": "DJUST Front SDK is a versatile JavaScript Software Development Kit (SDK) ",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",