idmint 1.0.2 → 1.0.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.
Files changed (2) hide show
  1. package/dist/index.js +4 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -4,20 +4,13 @@
4
4
  */
5
5
  const ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_";
6
6
  /**
7
- * Cross-platform secure random bytes
8
- * - Browser: crypto.getRandomValues
9
- * - Node.js: require("crypto").randomBytes
7
+ * Secure random bytes (Browser + Node 16+)
10
8
  */
11
9
  function getRandomBytes(size) {
12
- // Browser & modern runtimes
13
- if (typeof globalThis.crypto !== "undefined" &&
14
- globalThis.crypto.getRandomValues) {
15
- return globalThis.crypto.getRandomValues(new Uint8Array(size));
10
+ if (!globalThis.crypto || !globalThis.crypto.getRandomValues) {
11
+ throw new Error("Secure crypto API not available. This environment is not supported.");
16
12
  }
17
- // Node.js fallback
18
- // eslint-disable-next-line @typescript-eslint/no-var-requires
19
- const { randomBytes } = require("crypto");
20
- return randomBytes(size);
13
+ return globalThis.crypto.getRandomValues(new Uint8Array(size));
21
14
  }
22
15
  /**
23
16
  * Generate a secure unique ID
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "idmint",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Enterprise-grade, collision-resistant unique ID generator",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",