@plentymarkets/shop-core 1.12.0 → 1.13.0
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/dist/module.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Updates the SSR cookie value
|
|
3
|
-
* @param ssrCookie
|
|
4
|
-
* @param
|
|
2
|
+
* Updates the SSR cookie value by merging new `Set-Cookie` headers.
|
|
3
|
+
* @param ssrCookie The reactive reference to the current SSR cookie string.
|
|
4
|
+
* @param newCookie The new `Set-Cookie` header string or an array of them.
|
|
5
5
|
*/
|
|
6
6
|
export declare const updateSsrCookie: (ssrCookie: {
|
|
7
7
|
value: string;
|
|
8
|
-
},
|
|
8
|
+
}, newCookie: string | string[]) => void;
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { parse } from "cookie";
|
|
2
|
+
export const updateSsrCookie = (ssrCookie, newCookie) => {
|
|
3
|
+
const cookieJar = parse(ssrCookie.value || "");
|
|
4
|
+
const newCookies = Array.isArray(newCookie) ? newCookie : [newCookie];
|
|
5
|
+
newCookies.forEach((cookieString) => {
|
|
6
|
+
const [nameValue] = cookieString.split(";");
|
|
7
|
+
const [name, ...value] = nameValue?.split("=") ?? [];
|
|
8
|
+
const trimmedName = name?.trim();
|
|
9
|
+
if (trimmedName) {
|
|
10
|
+
const cookieValue = value.join("=").trim();
|
|
11
|
+
if (cookieValue) {
|
|
12
|
+
cookieJar[trimmedName] = cookieValue;
|
|
13
|
+
} else {
|
|
14
|
+
delete cookieJar[trimmedName];
|
|
8
15
|
}
|
|
9
|
-
});
|
|
10
|
-
} else {
|
|
11
|
-
if (setCookie.split(";")[0]) {
|
|
12
|
-
ssrCookie.value = setCookie.split(";")[0]?.trim() ?? "";
|
|
13
16
|
}
|
|
14
|
-
}
|
|
17
|
+
});
|
|
18
|
+
ssrCookie.value = Object.entries(cookieJar).map(([name, value]) => `${name}=${value}`).join("; ");
|
|
15
19
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plentymarkets/shop-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "Core module for PlentyONE Shop",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@plentymarkets/shop-api": "^0.140.0",
|
|
45
45
|
"@vue-storefront/sdk": "^3.4.1",
|
|
46
|
+
"cookie": "^1.0.2",
|
|
46
47
|
"js-sha256": "^0.11.0",
|
|
47
48
|
"resolve": "^1.22.10"
|
|
48
49
|
},
|