diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cff63f9..0e548db 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [18.x, 20.x, 22.x] + node-version: [20.x, 22.x, 24.x] steps: - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} diff --git a/index.js b/index.js index 156f8f9..e8022a3 100644 --- a/index.js +++ b/index.js @@ -6,8 +6,6 @@ See the accompanying LICENSE file for terms. 'use strict'; -var randomBytes = require('randombytes'); - // Generate an internal UID to make the regexp pattern harder to guess. var UID_LENGTH = 16; var UID = generateUID(); @@ -35,7 +33,7 @@ function escapeUnsafeChars(unsafeChar) { } function generateUID() { - var bytes = randomBytes(UID_LENGTH); + var bytes = crypto.getRandomValues(new Uint8Array(UID_LENGTH)); var result = ''; for(var i=0; i=20.0.0" } }, "node_modules/benchmark": { @@ -36,19 +36,6 @@ "resolved": "https://registry.npmjs.org/platform/-/platform-1.3.5.tgz", "integrity": "sha512-TuvHS8AOIZNAlE77WUDiR4rySV/VMptyMfcfeoMgs4P8apaZM3JrnbzBiixKUv+XR6i+BXrQh8WAnjaSPFO65Q==", "dev": true - }, - "node_modules/randombytes": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", - "dependencies": { - "safe-buffer": "^5.1.0" - } - }, - "node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" } } } diff --git a/package.json b/package.json index 1b66f37..adb49d2 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "devDependencies": { "benchmark": "^2.1.4" }, - "dependencies": { - "randombytes": "^2.1.0" + "engines": { + "node": ">=20.0.0" } } diff --git a/test/unit/serialize.js b/test/unit/serialize.js index 4d73b3c..62c0eee 100644 --- a/test/unit/serialize.js +++ b/test/unit/serialize.js @@ -3,20 +3,6 @@ const { deepStrictEqual, strictEqual, throws } = require('node:assert'); var serialize = require('../../'); -// temporarily monkeypatch `crypto.randomBytes` so we'll have a -// predictable UID for our tests -var crypto = require('crypto'); -var oldRandom = crypto.randomBytes; -crypto.randomBytes = function(len, cb) { - var buf = Buffer.alloc(len); - buf.fill(0x00); - if (cb) - cb(null, buf); - return buf; -}; - -crypto.randomBytes = oldRandom; - describe('serialize( obj )', function () { it('should be a function', function () { strictEqual(typeof serialize, 'function');