loyalty-protocol 3.0.7 → 3.0.8
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/utils/index.js +9 -4
- package/package.json +1 -1
package/dist/utils/index.js
CHANGED
|
@@ -3,9 +3,14 @@ export const decryptLoyaltySessionToken = (token, storeIdentifier) => {
|
|
|
3
3
|
try {
|
|
4
4
|
if (!token || !storeIdentifier)
|
|
5
5
|
throw new Error("No token or store identifier passed");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
let salt;
|
|
7
|
+
const env = process.env.LOYALTY_SALT;
|
|
8
|
+
if (typeof env === "object") {
|
|
9
|
+
salt = env[storeIdentifier];
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
salt = env ? JSON.parse(env)[storeIdentifier] : undefined;
|
|
13
|
+
}
|
|
9
14
|
if (!salt)
|
|
10
15
|
throw new Error(`No Salt found for storeIdentifier - ${storeIdentifier}`);
|
|
11
16
|
const key = CryptoJS.enc.Utf8.parse(salt);
|
|
@@ -18,7 +23,7 @@ export const decryptLoyaltySessionToken = (token, storeIdentifier) => {
|
|
|
18
23
|
return decrypted?.toString(CryptoJS.enc.Utf8) || token;
|
|
19
24
|
}
|
|
20
25
|
catch (e) {
|
|
21
|
-
console.error("Malformed token", e
|
|
26
|
+
console.error("Malformed token", e);
|
|
22
27
|
return token;
|
|
23
28
|
}
|
|
24
29
|
};
|