@gjsify/crypto 0.24.2 → 0.26.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/lib/esm/random.js +1 -1
- package/package.json +6 -6
package/lib/esm/random.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{Buffer as e}from"node:buffer";
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{Buffer as e}from"node:buffer";import{fillRandomBytes as t}from"@gjsify/webcrypto/random";function fillRandom(e){t(e)}function randomBytes(t,n){if(typeof t!=`number`||t<0||!Number.isInteger(t))throw TypeError(`The "size" argument must be a non-negative integer. Received ${t}`);try{let r=e.alloc(t);if(t>0&&fillRandom(new Uint8Array(r.buffer,r.byteOffset,r.byteLength)),n)n(null,r);else return r}catch(t){if(n)n(t,e.alloc(0));else throw t}}function randomFillSync(t,n=0,r){let i=r??t.length-n;if(n<0||n>t.length)throw RangeError(`The value of "offset" is out of range. Received ${n}`);if(i<0||n+i>t.length)throw RangeError(`The value of "size" is out of range. Received ${i}`);if(i>0){let r=(t instanceof e,t.byteOffset);fillRandom(new Uint8Array(t.buffer,r+n,i))}return t}function randomFill(e,t,n,r){let i,a,o;typeof t==`function`?(o=t,i=0,a=e.length):typeof n==`function`?(o=n,i=t,a=e.length-t):(o=r,i=t,a=n);try{randomFillSync(e,i,a),o(null,e)}catch(t){o(t,e)}}function randomUUID(){if(typeof globalThis.crypto?.randomUUID==`function`)return globalThis.crypto.randomUUID();let e=new Uint8Array(16);fillRandom(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function randomInt(e,t,n){let r,i,a;if(typeof t==`function`?(a=t,i=e,r=0):typeof t==`number`?(r=e,i=t,a=n):(i=e,r=0,a=n),!Number.isInteger(r))throw TypeError(`The "min" argument must be a safe integer. Received ${r}`);if(!Number.isInteger(i))throw TypeError(`The "max" argument must be a safe integer. Received ${i}`);if(r>=i)throw RangeError(`The value of "min" must be less than "max". Received min: ${r}, max: ${i}`);let o=i-r,s=new Uint32Array(1);fillRandom(new Uint8Array(s.buffer));let c=r+s[0]%o;if(a)a(null,c);else return c}export{randomBytes,randomFill,randomFillSync,randomInt,randomUUID};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/crypto",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "Node.js crypto module for Gjs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -74,17 +74,17 @@
|
|
|
74
74
|
"crypto"
|
|
75
75
|
],
|
|
76
76
|
"devDependencies": {
|
|
77
|
-
"@gjsify/cli": "^0.
|
|
78
|
-
"@gjsify/unit": "^0.
|
|
77
|
+
"@gjsify/cli": "^0.26.0",
|
|
78
|
+
"@gjsify/unit": "^0.26.0",
|
|
79
79
|
"@types/diffie-hellman": "^5.0.3",
|
|
80
80
|
"@types/node": "^25.9.2",
|
|
81
81
|
"typescript": "^6.0.3"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
84
|
"@girs/glib-2.0": "^4.1.0",
|
|
85
|
-
"@gjsify/buffer": "^0.
|
|
86
|
-
"@gjsify/stream": "^0.
|
|
87
|
-
"@gjsify/
|
|
85
|
+
"@gjsify/buffer": "^0.26.0",
|
|
86
|
+
"@gjsify/stream": "^0.26.0",
|
|
87
|
+
"@gjsify/webcrypto": "^0.26.0",
|
|
88
88
|
"@noble/hashes": "^2.2.0"
|
|
89
89
|
},
|
|
90
90
|
"gjsify": {
|