npm-pkg-hook 1.12.8 → 1.13.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/package.json CHANGED
@@ -4,9 +4,10 @@
4
4
  "types": "dist/index.d.ts",
5
5
  "exports": {
6
6
  ".": {
7
+ "types": "./dist/index.d.ts",
8
+ "development": "./src/index.ts",
7
9
  "import": "./dist/index.mjs",
8
- "require": "./dist/index.cjs",
9
- "types": "./dist/index.d.ts"
10
+ "require": "./dist/index.cjs"
10
11
  }
11
12
  },
12
13
  "scripts": {
@@ -21,7 +22,8 @@
21
22
  "react-dom": "^18 || ^19",
22
23
  "next": "^14 || ^15",
23
24
  "@apollo/client": "^3 || ^4",
24
- "graphql": "^16"
25
+ "graphql": "^16",
26
+ "fs": "0.0.1-security"
25
27
  },
26
28
  "devDependencies": {
27
29
  "tsup": "8.5.1",
@@ -30,6 +32,6 @@
30
32
  "@types/js-cookie": "3.0.6",
31
33
  "@types/file-saver": "2.0.7"
32
34
  },
33
- "version": "1.12.8",
35
+ "version": "1.13.0",
34
36
  "name": "npm-pkg-hook"
35
37
  }
@@ -1,10 +1,10 @@
1
- import crypto from 'node:crypto'
1
+ import crypto from 'crypto'
2
2
 
3
- /**
4
- *
5
- * @param password
6
- * @param salt
7
- */
3
+ /**
4
+ *
5
+ * @param password
6
+ * @param salt
7
+ */
8
8
  function generateEncryptionKey(password: string, salt: string): string {
9
9
  return crypto
10
10
  .pbkdf2Sync(password, salt, 100000, 32, 'sha256')
@@ -37,7 +37,7 @@ export const encryptSession = (text: string): string | null => {
37
37
  ].join(':')
38
38
  } catch (error) {
39
39
  if (error instanceof Error) {
40
- console.error('Error de encriptación:', error.message)
40
+ console.error('Error de cifrado:', error.message)
41
41
  }
42
42
  return null
43
43
  }
@@ -62,7 +62,7 @@ export const decryptSession = (text: string): string | null => {
62
62
  return decrypted.toString('utf8')
63
63
  } catch (error) {
64
64
  if (error instanceof Error) {
65
- console.error('Error de desencriptación:', error.message)
65
+ console.error('Error de descifrado:', error.message)
66
66
  }
67
67
  return null
68
68
  }
@@ -18,6 +18,7 @@ export * from './useLocalBackendIp'
18
18
  export * from './statusOpenStores'
19
19
  export * from './completeSchedules'
20
20
  export * from './useLogout/helpers/BroadcastChannel'
21
+ export * from './useLogout/helpers/index'
21
22
  export * from './getCardType'
22
23
  export * from './useLoginEmployeeInStore'
23
24
  export * from './useUploadProducts'
@@ -1,21 +1,23 @@
1
- import AleaGen from './alea.js'
2
- import MersenneTwister from './mersenne_twister.js'
1
+ import AleaGen from './alea'
2
+ import MersenneTwister from './mersenne_twister'
3
3
 
4
- /**
5
- *
6
- * @param opts
7
- */
8
- function minMax (opts) {
4
+ /**
5
+ *
6
+ * @param opts
7
+ */
8
+ function minMax (opts: { random: number; min: number; max: number }): number {
9
9
  const { random, min, max } = opts
10
10
  return Math.floor(random * (max - min + 1) + min)
11
11
  }
12
12
 
13
- export const randomNumber = (opts) => {
13
+ export const randomNumber = (opts: { value: string; min: number; max: number }): number => {
14
14
  const { value, min, max } = opts
15
15
 
16
16
  const prepareSeed = new AleaGen(value)
17
+ // @ts-ignore
17
18
  const seedOutput = prepareSeed.s1 * 10000000
18
-
19
+
20
+ // @ts-ignore
19
21
  const mersenne = new MersenneTwister(seedOutput)
20
22
 
21
23
  return minMax({ random: mersenne.random(), min, max })
@@ -3,9 +3,9 @@ import { useState } from 'react'
3
3
 
4
4
  import { Cookies } from '../../cookies/index'
5
5
  import { getCurrentDomain } from '../../utils'
6
-
7
6
  import { signOutAuth } from './helpers'
8
7
 
8
+
9
9
  interface UseLogoutOptions {
10
10
  setAlertBox?: (options: { message: string }) => { message: string }
11
11
  }
@@ -1,29 +1,43 @@
1
1
  /**
2
2
  * Validates and filters modules based on the "read" permission.
3
3
  * If a module's view does not have "read" permission in the permissions object, the module is removed.
4
- *
5
- * @param {Array} modules - List of modules to validate.
6
- * @param {Object} permissions - Permissions object mapping views to their allowed actions.
7
- * @returns {Array} - Filtered list of valid modules.
8
4
  */
9
- export const validateModules = (modules = [], permissions = {}) => {
10
- if (!Array.isArray(modules) || module.length <= 0) return []
11
- return modules?.map(module => {
12
- // Check if the main module's view has "read" permission
13
- const hasReadPermission = permissions[module.view]?.includes('read')
5
+ type PermissionMap = Record<string, string[]>
14
6
 
15
- // Validate and filter subModules if they exist
16
- const validSubModules = module.subModules?.filter(subModule =>
17
- {return permissions[subModule.view]?.includes('read')}
18
- ) || []
7
+ interface SubModule {
8
+ view: string
9
+ [key: string]: any
10
+ }
11
+
12
+ interface Module {
13
+ view: string
14
+ subModules?: SubModule[]
15
+ [key: string]: any
16
+ }
17
+
18
+ export const validateModules = (
19
+ modules: Module[] = [],
20
+ permissions: PermissionMap = {}
21
+ ): Module[] => {
22
+ if (!Array.isArray(modules) || modules.length <= 0) return []
23
+ return modules
24
+ .map((module) => {
25
+ // Check if the main module's view has "read" permission
26
+ const hasReadPermission = permissions[module.view]?.includes('read')
27
+
28
+ // Validate and filter subModules if they exist
29
+ const validSubModules =
30
+ module.subModules?.filter((subModule: SubModule) =>
31
+ permissions[subModule.view]?.includes('read')
32
+ ) || []
19
33
 
20
- // If the module or its subModules don't have read permission, exclude it
21
- if (!hasReadPermission && validSubModules.length === 0) {
22
- return null
23
- }
34
+ // If the module or its subModules don't have read permission, exclude it
35
+ if (!hasReadPermission && validSubModules.length === 0) {
36
+ return null
37
+ }
24
38
 
25
- // Return the module with its valid subModules
26
- return { ...module, subModules: validSubModules }
27
- })
28
- .filter(Boolean) // Remove null values
39
+ // Return the module with its valid subModules
40
+ return { ...module, subModules: validSubModules }
41
+ })
42
+ .filter(Boolean) as Module[] // Remove null values
29
43
  }
@@ -1,7 +1,6 @@
1
- import { useQuery } from '@apollo/client'
2
- import groupBy from 'lodash/groupBy'
3
-
4
- import { GET_ALL_ORDER, GET_ALL_ORDER_FROM_STORE } from '../queries.js'
1
+ import { useQuery } from '@apollo/client'
2
+ import groupBy from 'lodash/groupBy'
3
+ import { GET_ALL_ORDER, GET_ALL_ORDER_FROM_STORE } from '../queries'
5
4
 
6
5
  export const useOrders = ({
7
6
  refetchWritePolicy = 'merge',
@@ -0,0 +1,4 @@
1
+ export const useReactToPrint = () => {
2
+ // Placeholder implementation
3
+ console.log("useReactToPrint hook called");
4
+ }
package/src/index.ts CHANGED
@@ -1,13 +1,11 @@
1
- import { readFileSync } from 'node:fs'
2
- import { join } from 'node:path'
3
-
4
- const packageJson = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf8')) as { version: string }
5
-
1
+ import pkg from '../package.json';
6
2
  export * from './hooks/index'
7
3
  export * from './utils'
8
4
  export * from './utils/generateCode'
9
5
  export * from './cookies'
10
6
  export * from './security'
7
+ export * from './config/client'
8
+
9
+ // Export the version from package.json
10
+ export const version = pkg.version;
11
11
 
12
- // version
13
- export const version = packageJson.version
@@ -1,4 +1,4 @@
1
- import { randomBytes } from 'node:crypto'
1
+ import { randomBytes } from 'crypto'
2
2
 
3
3
  /**
4
4
  * @description It takes an array of elements and returns an object with a submit hook for each element.