@scayle/storefront-core 7.52.1 → 7.54.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/CHANGELOG.md +19 -0
- package/dist/helpers/sanitizationHelpers.cjs +12 -3
- package/dist/helpers/sanitizationHelpers.d.ts +2 -1
- package/dist/helpers/sanitizationHelpers.mjs +10 -2
- package/dist/rpc/methods/basket/basket.cjs +1 -2
- package/dist/rpc/methods/basket/basket.d.ts +0 -1
- package/dist/rpc/methods/basket/basket.mjs +1 -4
- package/dist/rpc/methods/checkout/checkout.cjs +1 -1
- package/dist/rpc/methods/checkout/checkout.mjs +1 -1
- package/dist/types/api/context.d.ts +3 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @scayle/storefront-core
|
|
2
2
|
|
|
3
|
+
## 7.54.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add new function `purifySensitiveValue` to `sanitizationHelpers` to purify specific value.
|
|
8
|
+
- Introduced a new parameter `showFirstAndLastChar` to both `purifySensitiveValue` and `purifySensitiveData`.
|
|
9
|
+
|
|
10
|
+
## 7.53.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- Deprecate `isCmsPreview` flag in `RpcContext`. This flag indicated that the current session is or has been inside of a CMS editor. With the the introduction of 'Live Preview' for the cms provider 'contentful' and 'storyblok' this flag is no longer necessary.
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Removes option `considerItemGroupForUniqueness` from `addItemsToBasket` since this is now enabled by default.
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- @scayle/storefront-api@17.2.0
|
|
21
|
+
|
|
3
22
|
## 7.52.1
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -3,19 +3,28 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.stripShopLocaleFromPath = exports.purifySensitiveData = exports.createAndPurifyHeaders = void 0;
|
|
6
|
+
exports.stripShopLocaleFromPath = exports.purifySensitiveValue = exports.purifySensitiveData = exports.createAndPurifyHeaders = void 0;
|
|
7
7
|
var _radash = require("radash");
|
|
8
8
|
const SANITIZATION_MASK = "********";
|
|
9
|
+
const regex = /(?<!^).(?!$)/g;
|
|
9
10
|
const stripShopLocaleFromPath = (locale, path, splitter = "/") => path.split(splitter).filter(segment => segment.toLowerCase() !== locale.toLowerCase()).join("/");
|
|
10
11
|
exports.stripShopLocaleFromPath = stripShopLocaleFromPath;
|
|
11
|
-
const
|
|
12
|
+
const purifySensitiveValue = (value, showFirstAndLastChar = false) => {
|
|
13
|
+
return showFirstAndLastChar && value.length > 2 ? value.replace(regex, "*") : SANITIZATION_MASK;
|
|
14
|
+
};
|
|
15
|
+
exports.purifySensitiveValue = purifySensitiveValue;
|
|
16
|
+
const purifySensitiveData = (data = {}, blacklistedKeys = ["password"], showFirstAndLastChar = false) => {
|
|
12
17
|
return Object.entries(data).reduce((purifiedPayload, [key, value]) => {
|
|
13
18
|
if ((0, _radash.isObject)(value)) {
|
|
14
19
|
purifiedPayload[key] = purifySensitiveData(value, blacklistedKeys);
|
|
15
20
|
return purifiedPayload;
|
|
16
21
|
}
|
|
17
22
|
const isSensitiveData = blacklistedKeys.some(excludedKey => key.includes(excludedKey));
|
|
18
|
-
|
|
23
|
+
if (isSensitiveData && value) {
|
|
24
|
+
purifiedPayload[key] = purifySensitiveValue(value, showFirstAndLastChar);
|
|
25
|
+
} else {
|
|
26
|
+
purifiedPayload[key] = value;
|
|
27
|
+
}
|
|
19
28
|
return purifiedPayload;
|
|
20
29
|
}, {});
|
|
21
30
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const stripShopLocaleFromPath: (locale: string, path: string, splitter?: string) => string;
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const purifySensitiveValue: (value: string, showFirstAndLastChar?: boolean) => string;
|
|
3
|
+
export declare const purifySensitiveData: (data?: Record<string, any>, blacklistedKeys?: string[], showFirstAndLastChar?: boolean) => Record<string, any>;
|
|
3
4
|
export declare const createAndPurifyHeaders: (headers: Partial<Record<string, string | undefined>>) => Headers;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { isObject, shake } from "radash";
|
|
2
2
|
const SANITIZATION_MASK = "********";
|
|
3
|
+
const regex = /(?<!^).(?!$)/g;
|
|
3
4
|
export const stripShopLocaleFromPath = (locale, path, splitter = "/") => path.split(splitter).filter((segment) => segment.toLowerCase() !== locale.toLowerCase()).join("/");
|
|
4
|
-
export const
|
|
5
|
+
export const purifySensitiveValue = (value, showFirstAndLastChar = false) => {
|
|
6
|
+
return showFirstAndLastChar && value.length > 2 ? value.replace(regex, "*") : SANITIZATION_MASK;
|
|
7
|
+
};
|
|
8
|
+
export const purifySensitiveData = (data = {}, blacklistedKeys = ["password"], showFirstAndLastChar = false) => {
|
|
5
9
|
return Object.entries(data).reduce(
|
|
6
10
|
(purifiedPayload, [key, value]) => {
|
|
7
11
|
if (isObject(value)) {
|
|
@@ -11,7 +15,11 @@ export const purifySensitiveData = (data = {}, blacklistedKeys = ["password"]) =
|
|
|
11
15
|
const isSensitiveData = blacklistedKeys.some(
|
|
12
16
|
(excludedKey) => key.includes(excludedKey)
|
|
13
17
|
);
|
|
14
|
-
|
|
18
|
+
if (isSensitiveData && value) {
|
|
19
|
+
purifiedPayload[key] = purifySensitiveValue(value, showFirstAndLastChar);
|
|
20
|
+
} else {
|
|
21
|
+
purifiedPayload[key] = value;
|
|
22
|
+
}
|
|
15
23
|
return purifiedPayload;
|
|
16
24
|
},
|
|
17
25
|
{}
|
|
@@ -90,8 +90,7 @@ const addItemsToBasket = exports.addItemsToBasket = async function addItemsToBas
|
|
|
90
90
|
skipAvailabilityCheck: false,
|
|
91
91
|
includeItemsWithoutProductData: resolvedWith?.includeItemsWithoutProductData
|
|
92
92
|
}, {
|
|
93
|
-
existingItemHandling: params.existingItemHandling || _constants.ExistingItemHandling.AddQuantityToExisting
|
|
94
|
-
considerItemGroupForUniqueness: Boolean(params.considerItemGroupForUniqueness ?? null)
|
|
93
|
+
existingItemHandling: params.existingItemHandling || _constants.ExistingItemHandling.AddQuantityToExisting
|
|
95
94
|
});
|
|
96
95
|
if (result.type === "success") {
|
|
97
96
|
return result.basket;
|
|
@@ -9,7 +9,6 @@ export declare const addItemsToBasket: (params: {
|
|
|
9
9
|
items: AddOrUpdateItemType[];
|
|
10
10
|
existingItemHandling: ExistingItemHandling;
|
|
11
11
|
with?: BasketWithOptions | undefined;
|
|
12
|
-
considerItemGroupForUniqueness?: boolean | undefined;
|
|
13
12
|
}, context: RpcContext) => Promise<BasketResponseData<Product, Variant>>;
|
|
14
13
|
export declare const getBasket: (options: BasketWithOptions | undefined, context: RpcContext) => Promise<BasketResponseData<Product, Variant>>;
|
|
15
14
|
export declare const removeItemFromBasket: (options: {
|
|
@@ -90,10 +90,7 @@ export const addItemsToBasket = async function addItemsToBasket2(params, context
|
|
|
90
90
|
includeItemsWithoutProductData: resolvedWith?.includeItemsWithoutProductData
|
|
91
91
|
},
|
|
92
92
|
{
|
|
93
|
-
existingItemHandling: params.existingItemHandling || ExistingItemHandling.AddQuantityToExisting
|
|
94
|
-
considerItemGroupForUniqueness: Boolean(
|
|
95
|
-
params.considerItemGroupForUniqueness ?? null
|
|
96
|
-
)
|
|
93
|
+
existingItemHandling: params.existingItemHandling || ExistingItemHandling.AddQuantityToExisting
|
|
97
94
|
}
|
|
98
95
|
);
|
|
99
96
|
if (result.type === "success") {
|
|
@@ -24,7 +24,7 @@ const getCheckoutToken = exports.getCheckoutToken = async function getCheckoutTo
|
|
|
24
24
|
carrier,
|
|
25
25
|
basketId: context.basketKey,
|
|
26
26
|
campaignKey: context.campaignKey
|
|
27
|
-
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.
|
|
27
|
+
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.53.0"}`).setProtectedHeader({
|
|
28
28
|
alg: "HS256",
|
|
29
29
|
typ: "JWT"
|
|
30
30
|
}).sign(secret);
|
|
@@ -13,7 +13,7 @@ export const getCheckoutToken = async function getCheckoutToken2(jwtPayload, con
|
|
|
13
13
|
carrier,
|
|
14
14
|
basketId: context.basketKey,
|
|
15
15
|
campaignKey: context.campaignKey
|
|
16
|
-
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.
|
|
16
|
+
}).setIssuedAt(now).setNotBefore(now).setExpirationTime("1h").setIssuer(`${"@scayle/storefront-core"}@${"7.53.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
|
|
17
17
|
return {
|
|
18
18
|
accessToken: context.accessToken,
|
|
19
19
|
checkoutJwt
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-core",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.54.0",
|
|
4
4
|
"description": "Collection of essential utilities to work with the Storefront API",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"test:ci": "vitest --run --passWithNoTests --coverage --reporter=default --reporter=junit"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@scayle/storefront-api": "17.
|
|
62
|
+
"@scayle/storefront-api": "17.2.0",
|
|
63
63
|
"crypto-js": "4.2.0",
|
|
64
64
|
"jose": "5.4.0",
|
|
65
65
|
"radash": "12.1.0",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@scayle/eslint-config-storefront": "4.2.0",
|
|
73
73
|
"@types/crypto-js": "4.2.2",
|
|
74
|
-
"@types/node": "20.14.
|
|
74
|
+
"@types/node": "20.14.1",
|
|
75
75
|
"@types/webpack-env": "1.18.5",
|
|
76
76
|
"@vitest/coverage-v8": "1.6.0",
|
|
77
77
|
"dprint": "0.46.1",
|