npm-pkg-hook 1.3.1 → 1.3.3

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/package.json CHANGED
@@ -43,5 +43,5 @@
43
43
  "rm": "rm -rf node_modules package-lock.json && npm i",
44
44
  "test": "echo \"Error: no test specified\" && exit 1"
45
45
  },
46
- "version": "1.3.1"
46
+ "version": "1.3.3"
47
47
  }
@@ -0,0 +1,40 @@
1
+ import crypto from 'crypto'
2
+
3
+ function generateEncryptionKey(password, salt) {
4
+ return crypto
5
+ .pbkdf2Sync(password, salt, 100000, 32, 'sha256')
6
+ .toString('hex')
7
+ .slice(0, 32)
8
+ }
9
+
10
+ const ENCRYPTION_KEY = generateEncryptionKey(
11
+ 'tu-contraseña',
12
+ 'alguna-sal-segura'
13
+ )
14
+ const IV_LENGTH = 16 // Para AES, este siempre debe ser 16
15
+
16
+ export const encryptSession = (text) => {
17
+ const iv = crypto.randomBytes(IV_LENGTH)
18
+ const cipher = crypto.createCipheriv(
19
+ 'aes-256-cbc',
20
+ Buffer.from(ENCRYPTION_KEY),
21
+ iv
22
+ )
23
+ let encrypted = cipher.update(text)
24
+ encrypted = Buffer.concat([encrypted, cipher.final()])
25
+ return iv.toString('hex') + ':' + encrypted.toString('hex')
26
+ }
27
+
28
+ export const decryptSession = (text) => {
29
+ const textParts = text.split(':')
30
+ const iv = Buffer.from(textParts.shift(), 'hex')
31
+ const encryptedText = Buffer.from(textParts.join(':'), 'hex')
32
+ const decipher = crypto.createDecipheriv(
33
+ 'aes-256-cbc',
34
+ Buffer.from(ENCRYPTION_KEY),
35
+ iv
36
+ )
37
+ let decrypted = decipher.update(encryptedText)
38
+ decrypted = Buffer.concat([decrypted, decipher.final()])
39
+ return decrypted.toString()
40
+ }
@@ -72,3 +72,5 @@ export * from './useUpdateCart'
72
72
  export * from './useUpdateExtProductFoodsSubOptional'
73
73
  export * from './useUser'
74
74
  export * from './useCart'
75
+ export * from './useGetStoreCookie'
76
+ export * from './getGlobalSession'
@@ -0,0 +1,22 @@
1
+ import { useState, useEffect } from 'react';
2
+ import Cookies from 'js-cookie';
3
+
4
+ export const useGetStoreCookie = () => {
5
+ const [vpStoreCookie, setVpStoreCookie] = useState(null);
6
+
7
+ useEffect(() => {
8
+ const getCookieValue = () => {
9
+ const cookieValue = Cookies.get('vp.store');
10
+ console.log('Cookie Value:', cookieValue);
11
+
12
+ if (cookieValue) {
13
+ setVpStoreCookie(cookieValue);
14
+ }
15
+ };
16
+
17
+ getCookieValue();
18
+ }, []); // Empty dependency array, so this effect runs once
19
+
20
+ return vpStoreCookie;
21
+ };
22
+
@@ -50,6 +50,7 @@ export function RandomCode (length) {
50
50
  }
51
51
  return result
52
52
  }
53
+
53
54
  /**
54
55
  * actualizar cache de apollo
55
56
  * @param {{ cache: object, query: object, nameFun: string, dataNew: object, type: number, id: string }} params Parámetros para actualizar el cachet de apollo