Skip to content

Commit 9562d2c

Browse files
👩‍💻 dx(passcheck): Move scripts to a bun package.
1 parent 4c8e85a commit 9562d2c

File tree

16 files changed

+198
-92
lines changed

16 files changed

+198
-92
lines changed

.bin/bun/bun.lock

Lines changed: 58 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env -S bun run
2+
3+
import readline from 'node:readline';
4+
5+
import zxcvbn from 'zxcvbn';
6+
7+
import ora from 'ora';
8+
9+
const progress = ora({
10+
text: 'Analyzing passwords ...',
11+
}).start();
12+
13+
function Passwords ( ) {
14+
this.map = new Map();
15+
}
16+
17+
Passwords.prototype.add = function (key, password) {
18+
if (!this.map.has(password)) {
19+
const meta = zxcvbn(password);
20+
this.map.set(password, {keys: [key], password, meta});
21+
}
22+
else {
23+
this.map.get(password).keys.push(key);
24+
}
25+
};
26+
27+
Passwords.prototype[Symbol.iterator] = function () {
28+
return this.map.values();
29+
};
30+
31+
const passwords = new Passwords();
32+
33+
let count = 0;
34+
let done = 0;
35+
36+
function update ( ) {
37+
progress.text = `Analyzing passwords (${done}/${count}) ...`;
38+
}
39+
40+
function output ( ) {
41+
return {
42+
passwords: [...passwords],
43+
};
44+
}
45+
46+
const rl = readline.createInterface({
47+
input: process.stdin,
48+
output: process.stdout,
49+
terminal: false
50+
});
51+
52+
rl.on('line', function(line){
53+
++count; update();
54+
const [key, ...parts] = line.split(' ');
55+
const password = parts.join(' ');
56+
passwords.add(key, password);
57+
++done; update();
58+
});
59+
60+
rl.on('close', function(){
61+
62+
progress.succeed(`Analyzed ${count} passwords`);
63+
64+
console.log(JSON.stringify(output()));
65+
66+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env -S bun run
2+
3+
import readline from 'node:readline';
4+
5+
import zxcvbn from 'zxcvbn';
6+
7+
var rl = readline.createInterface({
8+
input: process.stdin,
9+
output: process.stdout,
10+
terminal: false
11+
});
12+
13+
rl.on('line', function(password){
14+
var result = zxcvbn(password);
15+
console.log(result.crack_times_display.offline_fast_hashing_1e10_per_second);
16+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"private": true,
3+
"name": "__passwords",
4+
"version": "0.0.1",
5+
"type": "module",
6+
"dependencies": {
7+
"ora": "^8.2.0",
8+
"zxcvbn": "^4.4.2"
9+
},
10+
"devDependencies": {
11+
"@types/node": "^24.2.0",
12+
"typescript": "^5.9.2"
13+
}
14+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"compilerOptions": {
4+
"noEmit": true,
5+
"target": "esnext",
6+
"module": "esnext",
7+
"lib": ["esnext"],
8+
"allowJs": true,
9+
"checkJs": true,
10+
"incremental": true,
11+
12+
"strict": true,
13+
"noImplicitAny": false,
14+
"noImplicitThis": false,
15+
"strictNullChecks": true,
16+
17+
"noImplicitReturns": true,
18+
"noFallthroughCasesInSwitch": true,
19+
"noImplicitOverride": false,
20+
"noPropertyAccessFromIndexSignature": false,
21+
"noUncheckedIndexedAccess": true,
22+
"noUnusedLocals": true,
23+
"noUnusedParameters": true,
24+
25+
"allowUnreachableCode": false,
26+
27+
"moduleResolution": "node",
28+
"resolveJsonModule": true,
29+
"esModuleInterop": true,
30+
"preserveSymlinks": true,
31+
"allowSyntheticDefaultImports": true
32+
}
33+
}

.bin/calendar._all

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bun/dist/events/bin/all.js
1+
bun/dist/packages/events/bin/all.js

.bin/calendar.fetch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bun/dist/events/bin/fetch.js
1+
bun/dist/packages/events/bin/fetch.js

.bin/calendar.filter

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bun/dist/events/bin/filter.js
1+
bun/dist/packages/events/bin/filter.js

.bin/calendar.now

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bun/dist/events/bin/now.js
1+
bun/dist/packages/events/bin/now.js

.bin/chart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bun/dist/chart/bin/chart.js
1+
bun/dist/packages/chart/bin/chart.js

0 commit comments

Comments
 (0)