@scayle/storefront-core 7.53.0 → 7.55.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 +14 -0
- package/dist/constants/hash.cjs +2 -1
- package/dist/constants/hash.d.ts +1 -0
- package/dist/constants/hash.mjs +2 -1
- package/dist/helpers/sanitizationHelpers.cjs +12 -3
- package/dist/helpers/sanitizationHelpers.d.ts +2 -1
- package/dist/helpers/sanitizationHelpers.mjs +10 -2
- package/dist/index.cjs +16 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +4 -0
- package/dist/rpc/methods/checkout/checkout.cjs +1 -1
- package/dist/rpc/methods/checkout/checkout.mjs +1 -1
- package/dist/types/bapi/sorting.cjs +1 -5
- package/dist/types/bapi/sorting.d.ts +0 -1
- package/dist/types/bapi/sorting.mjs +0 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @scayle/storefront-core
|
|
2
2
|
|
|
3
|
+
## 7.55.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Allow disabling the `HashAlgorithm` by setting its value to `none` within a shop config.
|
|
8
|
+
- Added exports for `ProductSortConfig` type and enums `APISortOption` and `APISortOrder`.
|
|
9
|
+
|
|
10
|
+
## 7.54.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- Add new function `purifySensitiveValue` to `sanitizationHelpers` to purify specific value.
|
|
15
|
+
- Introduced a new parameter `showFirstAndLastChar` to both `purifySensitiveValue` and `purifySensitiveData`.
|
|
16
|
+
|
|
3
17
|
## 7.53.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/dist/constants/hash.cjs
CHANGED
package/dist/constants/hash.d.ts
CHANGED
package/dist/constants/hash.mjs
CHANGED
|
@@ -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
|
{}
|
package/dist/index.cjs
CHANGED
|
@@ -4,8 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
|
-
rpcMethods: true
|
|
7
|
+
rpcMethods: true,
|
|
8
|
+
APISortOption: true,
|
|
9
|
+
APISortOrder: true
|
|
8
10
|
};
|
|
11
|
+
Object.defineProperty(exports, "APISortOption", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return _storefrontApi.APISortOption;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "APISortOrder", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () {
|
|
20
|
+
return _storefrontApi.APISortOrder;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
9
23
|
exports.rpcMethods = void 0;
|
|
10
24
|
var rpcMethods = _interopRequireWildcard(require("./rpc/methods/index.cjs"));
|
|
11
25
|
exports.rpcMethods = rpcMethods;
|
|
@@ -81,5 +95,6 @@ Object.keys(_types).forEach(function (key) {
|
|
|
81
95
|
}
|
|
82
96
|
});
|
|
83
97
|
});
|
|
98
|
+
var _storefrontApi = require("@scayle/storefront-api");
|
|
84
99
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
85
100
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
package/dist/index.d.ts
CHANGED
|
@@ -17,3 +17,4 @@ export type RpcMethodName = Resolve<keyof RpcMethods>;
|
|
|
17
17
|
export type RpcMethod<N extends RpcMethodName> = RpcMethods[N];
|
|
18
18
|
export type RpcMethodParameters<N extends RpcMethodName> = Parameters<RpcMethod<N>>[0];
|
|
19
19
|
export type RpcMethodReturnType<N extends RpcMethodName> = ReturnType<RpcMethod<N>>;
|
|
20
|
+
export { APISortOption, APISortOrder, type ProductSortConfig, } from '@scayle/storefront-api';
|
package/dist/index.mjs
CHANGED
|
@@ -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.54.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.54.0"}`).setProtectedHeader({ alg: "HS256", typ: "JWT" }).sign(secret);
|
|
17
17
|
return {
|
|
18
18
|
accessToken: context.accessToken,
|
|
19
19
|
checkoutJwt
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { APISortOption, APISortOrder } from '@scayle/storefront-api';
|
|
2
2
|
import type { SortName, SortQuery } from '../../constants';
|
|
3
|
-
export { APISortOption, APISortOrder };
|
|
4
3
|
export type SortingValueKey = 'topSeller' | 'dateNewest' | 'priceDesc' | 'priceAsc' | 'reductionDesc' | 'reductionAsc';
|
|
5
4
|
export interface SortValue {
|
|
6
5
|
name: SortName;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|