@djust-b2b/djust-front-sdk 1.25.0 → 1.26.1

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.
@@ -32,6 +32,7 @@ export interface CartWithTotalsDto {
32
32
  totalDiscountPrice: PriceDto;
33
33
  totalPrice: PriceDto;
34
34
  type: CartTypeDto;
35
+ updatedAt: string;
35
36
  }
36
37
  export interface CartLineDto {
37
38
  blockedLineInformation: BlockedLineInformationDto[];
@@ -6,10 +6,20 @@ export type CustomFieldValueDto = {
6
6
  name?: string;
7
7
  value?: string;
8
8
  };
9
+ export interface CustomFieldValueTeaserObject {
10
+ customField: CustomFieldTeaserSearch;
11
+ value: CustomFieldValueObject;
12
+ }
9
13
  export interface CustomFieldValueObject {
10
14
  customField: CustomFieldSearch;
11
15
  value: string;
12
16
  }
17
+ export interface CustomFieldTeaserSearch {
18
+ externalId: string;
19
+ id: string;
20
+ name: string;
21
+ type: string;
22
+ }
13
23
  export interface CustomFieldSearch {
14
24
  externalId: string;
15
25
  externalSource: string;
@@ -1,4 +1,4 @@
1
- import { CustomFieldValueObject } from "./custom-field";
1
+ import { CustomFieldValueTeaserObject } from "./custom-field";
2
2
  import { AddressDto } from "./address";
3
3
  import { Country } from "./common";
4
4
  import { CustomerUserWithoutAccountDto } from "./customer-user";
@@ -14,7 +14,7 @@ export interface CustomerAccountDto {
14
14
  addresses: AddressDto[];
15
15
  businessRegistrationNumber: string;
16
16
  companyRegistrationName: string;
17
- customFieldValues: CustomFieldValueObject[];
17
+ customFieldValues: CustomFieldValueTeaserObject[];
18
18
  customerTags: CustomerTagNameableDto[];
19
19
  externalId: string;
20
20
  id: string;
@@ -1,9 +1,9 @@
1
- import { CustomFieldValueObject } from "./custom-field";
1
+ import { CustomFieldValueObject, CustomFieldValueTeaserObject } from "./custom-field";
2
2
  export type NavigationCategoryIdType = "DJUST_ID" | "EXTERNAL_ID";
3
3
  export interface NavigationCategoryDto {
4
4
  active: boolean;
5
5
  childrenCategories: NavigationCategoryDto[];
6
- customFieldValues: CustomFieldValueObject[];
6
+ customFieldValues: CustomFieldValueTeaserObject[];
7
7
  externalId: string;
8
8
  id: string;
9
9
  name: string;
@@ -12,7 +12,7 @@ export interface GetCartsParameters {
12
12
  currency: Currency;
13
13
  pageable: PageableParameters;
14
14
  status?: CartStatusDto[];
15
- type?: CartTypeDto;
15
+ type?: CartTypeDto[];
16
16
  }
17
17
  export interface DeleteCartParameters {
18
18
  cartId: string;
@@ -80,8 +80,8 @@ async function getCarts(params) {
80
80
  currency,
81
81
  page: pageable === null || pageable === void 0 ? void 0 : pageable.page,
82
82
  size: pageable === null || pageable === void 0 ? void 0 : pageable.size,
83
- status,
84
- type,
83
+ status: Array.isArray(status) ? status.join(",") : status,
84
+ type: Array.isArray(type) ? type.join(",") : type,
85
85
  },
86
86
  });
87
87
  return data;
@@ -102,28 +102,17 @@ const serializeParams = (params, useRepeat) => {
102
102
  }
103
103
  return qs.stringify(params, { arrayFormat: "bracket", skipNull: true });
104
104
  };
105
- // Liste des routes publiques (sans JWT)
106
- const publicRoutes = new Map([
107
- ["/auth/token", new Set(["POST"])],
108
- ["/auth/refresh-token", new Set(["POST"])],
109
- ["/auth/reset-password", new Set(["POST"])],
110
- ["/auth/send-reset-password-email", new Set(["POST"])],
111
- ["/v1/shop/assets", new Set(["GET"])],
112
- ["/v1/shop/customer-accounts", new Set(["POST"])], // Seulement POST est public
113
- ["/v1/shop/attributes", new Set(["GET"])],
114
- ["/v1/shop/custom-fields", new Set(["GET"])],
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 (!isPublicRoute(path, method)) {
144
- if (accessToken) {
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djust-b2b/djust-front-sdk",
3
- "version": "1.25.0",
3
+ "version": "1.26.1",
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",