@scayle/storefront-core 7.40.0 → 7.41.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
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.stripShopLocaleFromPath = void 0;
|
|
6
|
+
exports.stripShopLocaleFromPath = exports.purifySensitiveData = void 0;
|
|
7
|
+
var _radash = require("radash");
|
|
8
|
+
const SANITIZATION_MASK = "********";
|
|
7
9
|
const stripShopLocaleFromPath = (locale, path, splitter = "/") => path.split(splitter).filter(segment => segment.toLowerCase() !== locale.toLowerCase()).join("/");
|
|
8
|
-
exports.stripShopLocaleFromPath = stripShopLocaleFromPath;
|
|
10
|
+
exports.stripShopLocaleFromPath = stripShopLocaleFromPath;
|
|
11
|
+
const purifySensitiveData = (data = {}, blacklistedKeys = ["password"]) => {
|
|
12
|
+
return Object.entries(data).reduce((purifiedPayload, [key, value]) => {
|
|
13
|
+
if ((0, _radash.isObject)(value)) {
|
|
14
|
+
purifiedPayload[key] = purifySensitiveData(value, blacklistedKeys);
|
|
15
|
+
return purifiedPayload;
|
|
16
|
+
}
|
|
17
|
+
const isSensitiveData = blacklistedKeys.some(excludedKey => key.includes(excludedKey));
|
|
18
|
+
purifiedPayload[key] = isSensitiveData ? SANITIZATION_MASK : value;
|
|
19
|
+
return purifiedPayload;
|
|
20
|
+
}, {});
|
|
21
|
+
};
|
|
22
|
+
exports.purifySensitiveData = purifySensitiveData;
|
|
@@ -1 +1,19 @@
|
|
|
1
|
+
import { isObject } from "radash";
|
|
2
|
+
const SANITIZATION_MASK = "********";
|
|
1
3
|
export const stripShopLocaleFromPath = (locale, path, splitter = "/") => path.split(splitter).filter((segment) => segment.toLowerCase() !== locale.toLowerCase()).join("/");
|
|
4
|
+
export const purifySensitiveData = (data = {}, blacklistedKeys = ["password"]) => {
|
|
5
|
+
return Object.entries(data).reduce(
|
|
6
|
+
(purifiedPayload, [key, value]) => {
|
|
7
|
+
if (isObject(value)) {
|
|
8
|
+
purifiedPayload[key] = purifySensitiveData(value, blacklistedKeys);
|
|
9
|
+
return purifiedPayload;
|
|
10
|
+
}
|
|
11
|
+
const isSensitiveData = blacklistedKeys.some(
|
|
12
|
+
(excludedKey) => key.includes(excludedKey)
|
|
13
|
+
);
|
|
14
|
+
purifiedPayload[key] = isSensitiveData ? SANITIZATION_MASK : value;
|
|
15
|
+
return purifiedPayload;
|
|
16
|
+
},
|
|
17
|
+
{}
|
|
18
|
+
);
|
|
19
|
+
};
|
|
@@ -38,14 +38,14 @@ const refreshUser = exports.refreshUser = async function refreshUser2(context) {
|
|
|
38
38
|
const client = new _customer.CustomerAPIClient(context);
|
|
39
39
|
try {
|
|
40
40
|
const user = await client.getMe(shopId);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
if (!user.authentication) {
|
|
42
|
+
user.authentication = {
|
|
43
|
+
type: "idp"
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
user.authentication.storefrontAccessToken = accessToken;
|
|
47
|
+
user.loginShopId = shopId;
|
|
48
|
+
context.updateUser(user);
|
|
49
49
|
return {
|
|
50
50
|
user
|
|
51
51
|
};
|
|
@@ -25,14 +25,14 @@ const refreshUser = async function refreshUser2(context) {
|
|
|
25
25
|
const client = new CustomerAPIClient(context);
|
|
26
26
|
try {
|
|
27
27
|
const user = await client.getMe(shopId);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
if (!user.authentication) {
|
|
29
|
+
user.authentication = {
|
|
30
|
+
type: "idp"
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
user.authentication.storefrontAccessToken = accessToken;
|
|
34
|
+
user.loginShopId = shopId;
|
|
35
|
+
context.updateUser(user);
|
|
36
36
|
return { user };
|
|
37
37
|
} catch {
|
|
38
38
|
await context.destroySession();
|