@vtex/faststore-plugin-buyer-portal 1.1.45 → 1.1.46
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/package.json
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { toQueryParams } from "../utils";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
getAuthFromCookie,
|
|
4
|
+
getCookieWithoutSessionObjects,
|
|
5
|
+
} from "../utils/cookie";
|
|
3
6
|
|
|
4
7
|
interface RequestConfig<Input = never> {
|
|
5
8
|
url: string;
|
|
@@ -30,7 +33,9 @@ class Client {
|
|
|
30
33
|
credentials: "include",
|
|
31
34
|
headers: {
|
|
32
35
|
...(ignoreContentType ? {} : { "Content-Type": "application/json" }),
|
|
33
|
-
...headers
|
|
36
|
+
...(headers.Cookie
|
|
37
|
+
? getCookieWithoutSessionObjects(headers.Cookie ?? "")
|
|
38
|
+
: {}),
|
|
34
39
|
...(headers.Cookie ? getAuthFromCookie(headers.Cookie ?? "") : {}),
|
|
35
40
|
},
|
|
36
41
|
};
|
|
@@ -26,6 +26,24 @@ export function getAuthCookie(data: LoaderData) {
|
|
|
26
26
|
return authCookie;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
const valuesToRemove = ["vtex_session"];
|
|
30
|
+
|
|
31
|
+
export function getCookieWithoutSessionObjects(cookie: string) {
|
|
32
|
+
const mappedCookie: Record<string, string> = Object.fromEntries(
|
|
33
|
+
cookie.split(";").map((pair) => pair.split("="))
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const newCookie: Record<string, string> = {};
|
|
37
|
+
|
|
38
|
+
for (const key in mappedCookie) {
|
|
39
|
+
if (!valuesToRemove.includes(key)) {
|
|
40
|
+
newCookie[key] = mappedCookie[key];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return { Cookie: getCookieAsString(newCookie) };
|
|
45
|
+
}
|
|
46
|
+
|
|
29
47
|
export function getAuthFromCookie(cookie: string) {
|
|
30
48
|
const mappedCookie: Record<string, string> = Object.fromEntries(
|
|
31
49
|
cookie.split(";").map((pair) => pair.split("="))
|