@unchainedshop/utils 4.8.18 → 4.8.19

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.
@@ -1,7 +1,12 @@
1
1
  import Hashids from 'hashids';
2
2
  const hashids = new Hashids('unchained', 6, 'ABCDEFGHIJKLMNPQRSTUVWXYZ23456789');
3
+ const RANGE = 999999998;
4
+ const REJECTION_LIMIT = Math.floor(0x100000000 / RANGE) * RANGE;
3
5
  export default () => {
4
- const randomBytes = crypto.getRandomValues(new Uint32Array(1));
5
- const randomNumber = (randomBytes[0] % 999999998) + 1;
6
+ let value = crypto.getRandomValues(new Uint32Array(1))[0];
7
+ while (value >= REJECTION_LIMIT) {
8
+ value = crypto.getRandomValues(new Uint32Array(1))[0];
9
+ }
10
+ const randomNumber = (value % RANGE) + 1;
6
11
  return hashids.encode(randomNumber);
7
12
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unchainedshop/utils",
3
3
  "description": "Common utility functions and base classes for the Unchained Engine",
4
- "version": "4.8.18",
4
+ "version": "4.8.19",
5
5
  "main": "lib/utils-index.js",
6
6
  "types": "lib/utils-index.d.ts",
7
7
  "type": "module",
@@ -35,7 +35,7 @@
35
35
  "resolve-accept-language": "^3.1.11"
36
36
  },
37
37
  "devDependencies": {
38
- "@types/node": "^25.0.0",
38
+ "@types/node": "^26.2.0",
39
39
  "typescript": "^5.8.3"
40
40
  }
41
41
  }