generate-pw 1.4.1 → 1.4.3
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/README.md +47 -9
- package/dist/generate-pw.min.js +1 -1
- package/docs/LICENSE.md +3 -1
- package/docs/SECURITY.md +3 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -8,23 +8,37 @@
|
|
|
8
8
|
<a href="https://github.com/adamlui/js-utils/tree/main/generate-pw/docs/zh-cn#readme">简体中文</a> |
|
|
9
9
|
<a href="https://github.com/adamlui/js-utils/tree/main/generate-pw/docs/zh-tw#readme">繁體中文</a> |
|
|
10
10
|
<a href="https://github.com/adamlui/js-utils/tree/main/generate-pw/docs/hi#readme">हिंदी</a> |
|
|
11
|
-
<a href="https://github.com/adamlui/js-utils/tree/main/generate-pw/docs/bn#readme">বাংলা</a>
|
|
11
|
+
<a href="https://github.com/adamlui/js-utils/tree/main/generate-pw/docs/bn#readme">বাংলা</a> |
|
|
12
|
+
<a href="https://github.com/adamlui/js-utils/tree/main/generate-pw/docs/de#readme">Deutsch</a> |
|
|
13
|
+
<a href="https://github.com/adamlui/js-utils/tree/main/generate-pw/docs/es#readme">Español</a>
|
|
12
14
|
</h6>
|
|
13
15
|
</div>
|
|
14
16
|
|
|
15
17
|
# > generate-pw
|
|
16
18
|
|
|
17
|
-
### Randomly generate cryptographically-secure passwords.
|
|
19
|
+
### Randomly generate, strengthen, and validate cryptographically-secure passwords.
|
|
18
20
|
|
|
19
21
|
<a href="#%EF%B8%8F-mit-license"><img height=31 src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
20
|
-
<a href="https://github.com/adamlui/js-utils/releases/tag/generate-pw-1.4.
|
|
22
|
+
<a href="https://github.com/adamlui/js-utils/releases/tag/generate-pw-1.4.3"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.4.3-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
21
23
|
<a href="https://www.npmjs.com/package/generate-pw?activeTab=code"><img height=31 src="https://img.shields.io/npm/unpacked-size/generate-pw?style=for-the-badge&logo=ebox&logoColor=white&labelColor=464646&color=blue"></a>
|
|
24
|
+
<a href="https://github.com/adamlui/js-utils/blob/generate-pw-1.4.3/generate-pw/dist/generate-pw.min.js"><img height=31 src="https://img.shields.io/github/size/adamlui/js-utils/generate-pw/dist/generate-pw.min.js?branch=generate-pw-1.4.3&label=Minified%20Size&logo=databricks&logoColor=white&labelColor=464646&color=ff69b4&style=for-the-badge"></a>
|
|
22
25
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_js-utils:generate-pw/src/generate-pw.js"><img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_js-utils%3Agenerate-pw%2Fsrc%2Fgenerate-pw.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a>
|
|
23
26
|
|
|
24
27
|
<br>
|
|
25
28
|
|
|
26
29
|
<img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
|
|
27
30
|
|
|
31
|
+
## 💡 About
|
|
32
|
+
|
|
33
|
+
**generate-pw** is a lightweight, easy-to-use library that allows you to randomly generate, strengthen & validate cryptographically-secure password(s).
|
|
34
|
+
|
|
35
|
+
- **No external dependencies —** Only built-in crypto methods used for secure randomization
|
|
36
|
+
- **Highly customizable —** Specify length, quantity, charsets to use, etc.
|
|
37
|
+
- **Multi-environment support —** Use in Node.js or the web browser
|
|
38
|
+
- **Command line usable —** Just type `generate-pw`, that's it
|
|
39
|
+
|
|
40
|
+
<img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
|
|
41
|
+
|
|
28
42
|
## ⚡ Installation
|
|
29
43
|
|
|
30
44
|
As a **global utility**:
|
|
@@ -66,14 +80,14 @@ const pw = require('generate-pw');
|
|
|
66
80
|
#### <> HTML script tag:
|
|
67
81
|
|
|
68
82
|
```html
|
|
69
|
-
<script src="https://cdn.jsdelivr.net/npm/generate-pw@1.4.
|
|
83
|
+
<script src="https://cdn.jsdelivr.net/npm/generate-pw@1.4.3/dist/generate-pw.min.js"></script>
|
|
70
84
|
```
|
|
71
85
|
|
|
72
86
|
#### ES6:
|
|
73
87
|
|
|
74
88
|
```js
|
|
75
89
|
(async () => {
|
|
76
|
-
await import('https://cdn.jsdelivr.net/npm/generate-pw@1.4.
|
|
90
|
+
await import('https://cdn.jsdelivr.net/npm/generate-pw@1.4.3/dist/generate-pw.min.js');
|
|
77
91
|
// Your code here...
|
|
78
92
|
})();
|
|
79
93
|
```
|
|
@@ -82,7 +96,7 @@ const pw = require('generate-pw');
|
|
|
82
96
|
|
|
83
97
|
```js
|
|
84
98
|
...
|
|
85
|
-
// @require https://cdn.jsdelivr.net/npm/generate-pw@1.4.
|
|
99
|
+
// @require https://cdn.jsdelivr.net/npm/generate-pw@1.4.3/dist/generate-pw.min.js
|
|
86
100
|
// ==/UserScript==
|
|
87
101
|
|
|
88
102
|
// Your code here...
|
|
@@ -90,7 +104,7 @@ const pw = require('generate-pw');
|
|
|
90
104
|
|
|
91
105
|
<br>
|
|
92
106
|
|
|
93
|
-
**💡 Note:** To always import the latest version (not recommended in production!) remove the `@1.4.
|
|
107
|
+
**💡 Note:** To always import the latest version (not recommended in production!) remove the `@1.4.3` version tag from the jsDelivr URL: `https://cdn.jsdelivr.net/npm/generate-pw/dist/generate-pw.min.js`
|
|
94
108
|
|
|
95
109
|
<br>
|
|
96
110
|
|
|
@@ -285,6 +299,30 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
285
299
|
|
|
286
300
|
<img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
|
|
287
301
|
|
|
288
|
-
|
|
289
|
-
|
|
302
|
+
## 🛠️ Related utilities
|
|
303
|
+
|
|
304
|
+
### <img height=21px src="https://i.imgur.com/kvf7fXm.png"> [generate-ip](https://js-utils.com/generate-ip) <a href="https://github.com/toolleeo/cli-apps#networking"><img height=18 src="https://awesome.re/mentioned-badge.svg"></a>
|
|
305
|
+
|
|
306
|
+
> Randomly generate, format, and validate IPv4/IPv6 addresses.
|
|
307
|
+
<br>[Install](https://github.com/adamlui/js-utils/tree/main/generate-ip#-installation) /
|
|
308
|
+
[Readme](https://github.com/adamlui/js-utils/tree/main/generate-ip#readme) /
|
|
309
|
+
[API usage](https://github.com/adamlui/js-utils/tree/main/generate-ip#-api-usage) /
|
|
310
|
+
[CLI usage](https://github.com/adamlui/js-utils/tree/main/generate-ip#-command-line-usage) /
|
|
311
|
+
[Discuss](https://js-utils.com/discussions)
|
|
312
|
+
|
|
313
|
+
### <a href="https://js-utils.com/geolocate"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/adamlui/js-utils/main/geolocate/media/images/icons/wire-globe/white/icon32.png"><img height=22 src="https://raw.githubusercontent.com/adamlui/js-utils/main/geolocate/media/images/icons/wire-globe/black/icon32.png"></picture> geolocate</a>
|
|
314
|
+
|
|
315
|
+
> Fetch IP geolocation data from the CLI.
|
|
316
|
+
<br>[Install](https://github.com/adamlui/js-utils/tree/main/geolocate#-installation) /
|
|
317
|
+
[Readme](https://github.com/adamlui/js-utils/tree/main/geolocate#readme) /
|
|
318
|
+
[CLI usage](https://github.com/adamlui/js-utils/tree/main/geolocate#-command-line-usage) /
|
|
319
|
+
[API usage](https://github.com/adamlui/js-utils/tree/main/geolocate#-api-usage) /
|
|
320
|
+
[Discuss](https://js-utils.com/discussions)
|
|
321
|
+
|
|
322
|
+
<br>
|
|
323
|
+
|
|
324
|
+
<img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
|
|
325
|
+
|
|
326
|
+
<picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/adamlui/js-utils/main/media/images/icons/home/white/icon32x27.png"><img height=11 src="https://raw.githubusercontent.com/adamlui/js-utils/main/media/images/icons/home/dark-gray/icon32x27.png"></picture> <a href="https://js-utils.com">**More JavaScript utilities**</a> /
|
|
327
|
+
<a href="https://js-utils.com/discussions">Discuss</a> /
|
|
290
328
|
<a href="#-generate-pw">Back to top ↑</a>
|
package/dist/generate-pw.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let
|
|
1
|
+
let p;try{({randomInt:p}=require("crypto"))}catch(e){const s=window.crypto||window.msCrypto;p=(e,r)=>{var o=s?.getRandomValues(new Uint32Array(1))[0]/4294967295||Math.random();return Math.floor(o*(r-e))+e}}const g={lower:"abcdefghijklmnopqrstuvwxyz",upper:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",numbers:"0123456789",symbols:"!@#$%^&*()-_=+[]{}/\\|;:'\",.<>?"};function a(s={}){var e={verbose:!0,length:8,qty:1,charset:"",exclude:"",numbers:!1,symbols:!1,lowercase:!0,uppercase:!0,strict:!1};if(b(s,e,"generatePassword({ verbose: false, numbers: true })")){if(1<(s={...e,...s}).qty){const{qty:r,...o}=s;return i(r,o)}{var t,e="generatePasswords"===a.caller?.name;s.verbose&&!e&&console.info("generatePassword() » Initializing character set...");let r=s.charset||(s.numbers?g.numbers:"")+(s.symbols?g.symbols:"")+(s.lowercase?g.lower:"")+(s.uppercase?g.upper:""),o=(""===r&&(r=g.lower+g.upper),s.exclude&&(s.verbose&&!e&&console.info("generatePassword() » Removing excluded characters..."),r=r.replace(new RegExp(`[${s.exclude}]`,"g"),"")),s.verbose&&!e&&console.info("generatePassword() » Generating password..."),"");for(let e=0;e<s.length;e++){var n=p(0,r.length);o+=r.charAt(n)}return s.strict&&(s.verbose&&!e&&console.info("generatePassword() » Enforcing strict mode..."),t=["number","symbol","lower","upper"].filter(e=>s[e+"s"]||s[e+"case"]),o=c(o,t)),s.verbose&&!e&&(console.info("generatePassword() » Password generated!"),"undefined"!=typeof require&&require.main.filename.endsWith("cli.js")||console.info("generatePassword() » Check returned string.")),o}}}function i(r,o={}){var e={verbose:!0,length:8,charset:"",exclude:"",numbers:!1,symbols:!1,lowercase:!0,uppercase:!0,strict:!1};if(r=parseInt(r,10),isNaN(r)||r<1)return console.error("generatePasswords() » ERROR: 1st arg <qty> can only be an integer > 0.");if(b(o,e,"generatePasswords(3, { verbose: false, symbols: true })")){(o={...e,...o}).verbose&&console.info(`generatePasswords() » Generating password${1<r?"s":""}...`);var s=[];for(let e=0;e<r;e++)s.push(a(o));return o.verbose&&console.info(`generatePasswords() » Password${1<r?"s":""} generated!`),"undefined"!=typeof require&&require.main.filename.endsWith("cli.js")||console.info("generatePasswords() » Check returned array."),s}}function c(s,t=["number","symbol","lower","upper"],e={}){var n={verbose:!0};if("string"!=typeof s)return console.error("strictify() » ERROR: 1st arg <password> must be a string.");var r=["number","symbol","lower","upper"];for(const o of t=Array.isArray(t)?t:[t])if(!r.includes(o))return console.error(`strictify() » ERROR: 2nd arg \`${o}\` is an invalid character type.`),console.info(`strictify() » Valid character types: [ ${r.map(e=>`'${e}'`).join(", ")} ]`),void console.info("strictify() » Pass one as a string or more as an array, or all types will be required.");if(b(e,n,"strictify('pa55word', ['symbol', 'upper'], { verbose: false })")){e={...n,...e};var a={};for(const f of t)a["has"+f.charAt(0).toUpperCase()+f.slice(1)]=!1;for(let e=0;e<s.length;e++)for(const d of t)(g[d]||g[d+"s"]).includes(s.charAt(e))&&(a["has"+d.charAt(0).toUpperCase()+d.slice(1)]=!0);e.verbose&&console.info("strictify() » Strictifying password...");var i=Math.min(s.length,t.length),c=[];let r=0,o=s;for(const u of t)if(r<i&&!a["has"+u.charAt(0).toUpperCase()+u.slice(1)]){let e;for(;e=p(0,s.length),c.includes(e););c.push(e);var l=g[u]||g[u+"s"];o=o.substring(0,e)+l.charAt(p(0,l.length))+o.substring(e+1),r++}return e.verbose&&(0<r?(console.info("strictify() » Password is now strict!"),console.info("strictify() » Check returned string.")):(console.info(`strictify() » Password already includes ${t.join(" + ")} characters!`),console.info("strictify() » No modifications made."))),o}}function e(r,o={}){var s={minLength:8,minLower:1,minUpper:1,minNumber:1,minSymbol:1},t={verbose:!0};if("string"!=typeof r)return console.error("validateStrength() » ERROR: 1st arg <password> must be a string.");if(b(o,t,"validateStrength('pa55word', { verbose: false })")){(o={...t,...o}).verbose&&console.info("validateStrength() » Validating password strength...");var n={lower:0,upper:0,number:0,symbol:0};for(const i of r)for(const c of Object.keys(n))(g[c]||g[c+"s"]).includes(i)&&n[c]++;var a=[];r.length<s.minLength&&a.push(`Make it at least ${s.minLength} characters long.`);for(const l of Object.keys(n))n[l]<s["min"+l.charAt(0).toUpperCase()+l.slice(1)]&&a.push("Include at least one "+l+`${["upper","lower"].includes(l)?"case letter":""}.`);let e=0;e+=r.length>=s.minLength?20:0;for(const f of Object.keys(n))e+=n[f]>=s["min"+f.charAt(0).toUpperCase()+f.slice(1)]?20:0;return o.verbose&&(console.info("validateStrength() » Password strength validated!"),console.info("validateStrength() » Check returned object for score/recommendations.")),{strengthScore:e,recommendations:a,isGood:80<=e}}}function b(e,r,o){const s=(b.caller?.name||"validateOptions")+"() » ",t=JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:").replace(/"/g,"'").replace(/\n\s*/g," "),n=Object.keys(r).join(", "),a=Object.keys(r).filter(e=>"boolean"==typeof r[e]),i=Object.keys(r).filter(e=>Number.isInteger(r[e]));var c=()=>{console.info(s+`Valid options: [ ${n} ]`),console.info(s+"If omitted, default settings are: "+t)};if("object"!=typeof e)return console.error(s+"ERROR: [options] can only be an object of key/values."),console.info(s+"Example valid call: "+o),c(),!1;for(const l in e){if(!Object.prototype.hasOwnProperty.call(r,l))return console.error(s+`ERROR: \`${l}\` is an invalid option.`),c(),!1;if(a.includes(l)&&"boolean"!=typeof e[l])return console.error(s+`ERROR: [${l}] option can only be \`true\` or \`false\`.`),!1;if(i.includes(l)&&(e[l]=parseInt(e[l],10),isNaN(e[l])||e[l]<1))return console.error(s+`ERROR: [${l}] option can only be an integer > 0.`),!1}return!0}const r={generatePassword:a,generatePasswords:i,strictify:c,validateStrength:e};try{module.exports={...r}}catch(e){}try{window.pw={...r}}catch(e){}
|
package/docs/LICENSE.md
CHANGED
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
<a href="zh-cn/LICENSE.md">简体中文</a> |
|
|
9
9
|
<a href="zh-tw/LICENSE.md">繁體中文</a> |
|
|
10
10
|
<a href="hi/LICENSE.md">हिंदी</a> |
|
|
11
|
-
<a href="bn/LICENSE.md">বাংলা</a>
|
|
11
|
+
<a href="bn/LICENSE.md">বাংলা</a> |
|
|
12
|
+
<a href="de/LICENSE.md">Deutsch</a> |
|
|
13
|
+
<a href="es/LICENSE.md">Español</a>
|
|
12
14
|
</h6>
|
|
13
15
|
</div>
|
|
14
16
|
|
package/docs/SECURITY.md
CHANGED
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
<a href="zh-cn/SECURITY.md">简体中文</a> |
|
|
9
9
|
<a href="zh-tw/SECURITY.md">繁體中文</a> |
|
|
10
10
|
<a href="hi/SECURITY.md">हिंदी</a> |
|
|
11
|
-
<a href="bn/SECURITY.md">বাংলা</a>
|
|
11
|
+
<a href="bn/SECURITY.md">বাংলা</a> |
|
|
12
|
+
<a href="de/SECURITY.md">Deutsch</a> |
|
|
13
|
+
<a href="es/SECURITY.md">Español</a>
|
|
12
14
|
</h6>
|
|
13
15
|
</div>
|
|
14
16
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "generate-pw",
|
|
3
|
-
"version": "1.4.
|
|
4
|
-
"description": "Randomly generate cryptographically-secure passwords.",
|
|
3
|
+
"version": "1.4.3",
|
|
4
|
+
"description": "Randomly generate, strengthen, and validate cryptographically-secure passwords.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Adam Lui",
|
|
7
7
|
"email": "adam@kudoai.com",
|
|
8
8
|
"url": "https://github.com/adamlui"
|
|
9
9
|
},
|
|
10
|
-
"homepage": "https://
|
|
10
|
+
"homepage": "https://js-utils.com/generate-pw",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"main": "dist/generate-pw.min.js",
|
|
13
13
|
"files": [
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
"cli"
|
|
47
47
|
],
|
|
48
48
|
"bugs": {
|
|
49
|
-
"url": "https://
|
|
49
|
+
"url": "https://js-utils.com/issues"
|
|
50
50
|
},
|
|
51
51
|
"funding": {
|
|
52
52
|
"type": "github",
|
|
53
53
|
"url": "https://github.com/sponsors/adamlui"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@adamlui/minify.js": "^1.4.
|
|
56
|
+
"@adamlui/minify.js": "^1.4.10"
|
|
57
57
|
}
|
|
58
58
|
}
|