From af5b2eaced1649ce60fb23912cee3efe63cf55d5 Mon Sep 17 00:00:00 2001 From: s2 Date: Thu, 26 Sep 2024 13:18:22 +0200 Subject: [PATCH] if the generated string is not long enough, retry --- lib/secure-random-string.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/secure-random-string.js b/lib/secure-random-string.js index 398087b..4350aca 100644 --- a/lib/secure-random-string.js +++ b/lib/secure-random-string.js @@ -32,7 +32,7 @@ function srs(options, cb) { string = string.replace(/\//g, '_').replace(/\+/g, '-'); } if (string.length < length) { - throw new Error(`Generated string is too short. Please catch this Error and try again.`); + return _finish(crypto.randomBytes(length)); } return string.substr(0, length); }