loyalty-protocol 2.1.7 → 3.0.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.
@@ -0,0 +1 @@
1
+ export declare const decryptLoyaltySessionToken: (token?: string, storeIdentifier?: string) => string | undefined;
@@ -0,0 +1,24 @@
1
+ import CryptoJS from "crypto-js";
2
+ export const decryptLoyaltySessionToken = (token, storeIdentifier) => {
3
+ try {
4
+ if (!token || !storeIdentifier)
5
+ throw new Error("No token or store identifier passed");
6
+ const salt = process.env.LOYALTY_SALT
7
+ ? JSON.parse(process.env.LOYALTY_SALT)[storeIdentifier]
8
+ : undefined;
9
+ if (!salt)
10
+ throw new Error(`No Salt found for storeIdentifier - ${storeIdentifier}`);
11
+ const key = CryptoJS.enc.Utf8.parse(salt);
12
+ const decrypted = CryptoJS.AES.decrypt(token?.toString(), key, {
13
+ keySize: 128 / 8,
14
+ iv: key,
15
+ mode: CryptoJS.mode.CBC,
16
+ padding: CryptoJS.pad.Pkcs7,
17
+ });
18
+ return decrypted?.toString(CryptoJS.enc.Utf8) || token;
19
+ }
20
+ catch (e) {
21
+ console.error("Malformed token", e, token);
22
+ return token;
23
+ }
24
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loyalty-protocol",
3
- "version": "2.1.7",
3
+ "version": "3.0.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "exports": {
@@ -21,7 +21,12 @@
21
21
  "files": [
22
22
  "dist"
23
23
  ],
24
+ "dependencies": {
25
+ "crypto-js": "4.2.0"
26
+ },
24
27
  "devDependencies": {
28
+ "@types/crypto-js": "^4.2.2",
29
+ "@types/node": "^25.0.3",
25
30
  "csso-cli": "^4.0.2",
26
31
  "tsup": "^8.5.0",
27
32
  "typescript": "^5.9.2"
@@ -1,18 +0,0 @@
1
- export declare const INDIAN_EXPRESS: {
2
- currency: {
3
- "K-Cash": {
4
- name: string;
5
- logo: string;
6
- };
7
- "K-Points": {
8
- name: string;
9
- logo: string;
10
- };
11
- rKGeN: {
12
- name: string;
13
- logo: string;
14
- };
15
- };
16
- showHeader: boolean;
17
- tenantId: undefined;
18
- };
@@ -1,18 +0,0 @@
1
- export const INDIAN_EXPRESS = {
2
- currency: {
3
- "K-Cash": {
4
- name: "T-Coins",
5
- logo: "https://images.hindustantimes.com/sso/prod/loyalty-reward-sdk/images/goCoinHT.svg",
6
- },
7
- "K-Points": {
8
- name: "T-Points",
9
- logo: "https://s2.coinmarketcap.com/static/img/coins/128x128/1958.png",
10
- },
11
- rKGeN: {
12
- name: "T Coin",
13
- logo: "https://s2.coinmarketcap.com/static/img/coins/128x128/32196.png",
14
- },
15
- },
16
- showHeader: false,
17
- tenantId: undefined,
18
- };
File without changes
File without changes