cybertoken 5.0.0 → 5.1.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/dist/index.mjs +3 -3
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -8,11 +8,11 @@ const prefixCheck = /^[a-zA-Z0-9_]+$/;
|
|
|
8
8
|
*/
|
|
9
9
|
function createTokenGenerator(options) {
|
|
10
10
|
if (!options.prefixWithoutUnderscore) throw new Error("The `prefixWithoutUnderscore` option is required and must not be an empty string.");
|
|
11
|
-
if (!prefixCheck.test(options.prefixWithoutUnderscore)) throw new Error("The `prefixWithoutUnderscore` option must only contain alphanumeric characters and underscores.");
|
|
11
|
+
if (!prefixCheck.test(options.prefixWithoutUnderscore) || options.prefixWithoutUnderscore.endsWith("_")) throw new Error("The `prefixWithoutUnderscore` option must only contain alphanumeric characters and underscores. It must not end with an underscore.");
|
|
12
12
|
const prefixWithUnderscore = `${options.prefixWithoutUnderscore}_`;
|
|
13
13
|
const tokenPattern = getTokenPattern(prefixWithUnderscore);
|
|
14
|
-
const tokenSecretByteCount = options.entropyBytes ??
|
|
15
|
-
if (tokenSecretByteCount
|
|
14
|
+
const tokenSecretByteCount = options.entropyBytes ?? 20;
|
|
15
|
+
if (tokenSecretByteCount < 20 || tokenSecretByteCount >= 100) throw new Error("The token secret byte count (`entropyBytes`) must be >= 20 and < 100.");
|
|
16
16
|
return {
|
|
17
17
|
generateToken,
|
|
18
18
|
isTokenString
|