Skip to content

Commit 23db9c5

Browse files
committed
GH-1 # plug password generation lib to frontend
1 parent 796880e commit 23db9c5

8 files changed

+50
-5
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
**/bundle.js
1+
src/static/*.bundle.js
22
package-lock.json

build.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env node
2+
3+
import * as esbuild from 'esbuild'
4+
5+
esbuild
6+
.build({
7+
logLevel: "info",
8+
entryPoints: ['src/static/interface_check_password_leak.js'],
9+
bundle: true,
10+
outfile: 'src/static/index.bundle.js',
11+
})
12+
.catch(() => process.exit(1));
13+
14+
esbuild
15+
.build({
16+
logLevel: "info",
17+
entryPoints: ['src/static/interface_password_generation.js'],
18+
bundle: true,
19+
outfile: 'src/static/password_generation.bundle.js',
20+
})
21+
.catch(() => process.exit(1));
22+

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"type": "module",
33
"scripts": {
4-
"build": "esbuild src/static/check_password_leak.js --bundle --outfile=src/static/bundle.js",
4+
"build": "./build.js",
55
"test": "node --experimental-vm-modules node_modules/.bin/jest"
66
},
77
"devDependencies": {

src/static/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8">
55
<title>HIBP - clone</title>
66
<link href="main.css" rel="stylesheet"/>
7-
<script type="module" src="bundle.js"></script>
7+
<script type="module" src="index.bundle.js"></script>
88
</head>
99
<body>
1010
<div class="sidenav">
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { generatePassword } from './password_generation.js';
2+
3+
const passwordGenerationResult = document.getElementById('passwordGenerationResultDiv')
4+
5+
document.getElementById('generatePasswordButton').addEventListener('click', (e) => {
6+
generatePasswordForUI();
7+
})
8+
9+
function generatePasswordForUI() {
10+
let password = generatePassword(10);
11+
displayPasswordGenerationResult(password)
12+
}
13+
14+
function displayPasswordGenerationResult(password){
15+
passwordGenerationResult.innerHTML = `Mot de passe généré: <div id="passwordGenerated">${password}</div>`
16+
}

src/static/main.css

+6-1
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,9 @@ body {
5252

5353
.resultClear {
5454
background-color: #28b463;
55-
}
55+
}
56+
57+
#passwordGenerated {
58+
font-weight: bold;
59+
background-color: #d5d5d5;
60+
}

src/static/password_generation.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8">
55
<title>HIBP - clone</title>
66
<link href="main.css" rel="stylesheet"/>
7-
<script type="module" src="password_generation.js"></script>
7+
<script type="module" src="password_generation.bundle.js"></script>
88
</head>
99
<body>
1010
<div class="sidenav">
@@ -16,6 +16,8 @@
1616
<div class="content">
1717
<h2>Génération de mot de passe</h2>
1818
<div>Cette page permet de générer un mot de passe fort</div>
19+
<input id="generatePasswordButton" type="button" value="Générer">
20+
<div id="passwordGenerationResultDiv"></div>
1921
</div>
2022

2123
</body>

0 commit comments

Comments
 (0)