diff --git a/cjs/dist/index.js b/cjs/dist/index.js index d3b8f80..c457650 100644 --- a/cjs/dist/index.js +++ b/cjs/dist/index.js @@ -14,7 +14,8 @@ async function createChallenge(options) { params.set('expires', String(Math.floor(options.expires.getTime() / 1000))); } let salt = options.salt || (0, helpers_js_1.ab2hex)((0, helpers_js_1.randomBytes)(saltLength)); - if (params.size) { + // params.size doesn't work with Node 16 + if (Object.keys(Object.fromEntries(params)).length) { salt = salt + '?' + params.toString(); } const number = options.number === void 0 ? (0, helpers_js_1.randomInt)(maxnumber) : options.number; diff --git a/deno_dist/index.ts b/deno_dist/index.ts index b085d5c..783d600 100644 --- a/deno_dist/index.ts +++ b/deno_dist/index.ts @@ -32,7 +32,8 @@ export async function createChallenge( params.set('expires', String(Math.floor(options.expires.getTime() / 1000))); } let salt = options.salt || ab2hex(randomBytes(saltLength)); - if (params.size) { + // params.size doesn't work with Node 16 + if (Object.keys(Object.fromEntries(params)).length) { salt = salt + '?' + params.toString(); } const number = diff --git a/dist/index.js b/dist/index.js index fc05a61..04c6ef0 100644 --- a/dist/index.js +++ b/dist/index.js @@ -11,7 +11,8 @@ export async function createChallenge(options) { params.set('expires', String(Math.floor(options.expires.getTime() / 1000))); } let salt = options.salt || ab2hex(randomBytes(saltLength)); - if (params.size) { + // params.size doesn't work with Node 16 + if (Object.keys(Object.fromEntries(params)).length) { salt = salt + '?' + params.toString(); } const number = options.number === void 0 ? randomInt(maxnumber) : options.number; diff --git a/lib/index.ts b/lib/index.ts index b4d696f..e279ee1 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -32,7 +32,8 @@ export async function createChallenge( params.set('expires', String(Math.floor(options.expires.getTime() / 1000))); } let salt = options.salt || ab2hex(randomBytes(saltLength)); - if (params.size) { + // params.size doesn't work with Node 16 + if (Object.keys(Object.fromEntries(params)).length) { salt = salt + '?' + params.toString(); } const number = diff --git a/package.json b/package.json index ef46eea..731a793 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "altcha-lib", - "version": "0.2.1", + "version": "0.3.0", "description": "A library for creating and verifying ALTCHA challenges for Node.js, Bun and Deno.", "author": "Daniel Regeci", "license": "MIT",