Socket
Socket
Sign inDemoInstall

crypto-random-string

Package Overview
Dependencies
1
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.0 to 3.0.1

10

index.js
'use strict';
const crypto = require('crypto');
const urlSafeCharacters = 'abcdefjhijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~'.split('');
const urlSafeCharacters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~'.split('');

@@ -41,12 +41,12 @@ const generateForCustomCharacters = (length, characters) => {

module.exports = ({length, type, characters}) => {
if (!Number.isFinite(length)) {
throw new TypeError('Expected a finite number');
if (!(length >= 0 && Number.isFinite(length))) {
throw new TypeError('Expected a `length` to be a non-negative finite number');
}
if (type !== undefined && characters !== undefined) {
throw new TypeError('Expected either type or characters');
throw new TypeError('Expected either `type` or `characters`');
}
if (characters !== undefined && typeof characters !== 'string') {
throw new TypeError('Expected characters to be string');
throw new TypeError('Expected `characters` to be string');
}

@@ -53,0 +53,0 @@

{
"name": "crypto-random-string",
"version": "3.0.0",
"version": "3.0.1",
"description": "Generate a cryptographically strong random string",

@@ -36,9 +36,9 @@ "license": "MIT",

"dependencies": {
"type-fest": "^0.4.1"
"type-fest": "^0.5.2"
},
"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.7.2",
"ava": "^2.1.0",
"tsd": "^0.7.3",
"xo": "^0.24.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc