1
0
Fork 0
mirror of https://github.com/Luzifer/password.git synced 2024-11-09 09:50:07 +00:00

Move JS build to esbuild / resolve vulnerabilities

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2022-06-27 21:36:28 +02:00
parent 9a24ca807b
commit ac72a04c53
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D
7 changed files with 885 additions and 6052 deletions

24
js/build.mjs Normal file
View file

@ -0,0 +1,24 @@
import { sassPlugin } from 'esbuild-sass-plugin'
import esbuild from 'esbuild'
esbuild.build({
bundle: true,
define: {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'dev'),
},
entryPoints: ['src/index.js'],
loader: {
'.woff': 'file',
'.woff2': 'file',
},
minify: true,
outfile: '../cmd/password/frontend/assets/bundle.js',
plugins: [sassPlugin()],
target: [
'chrome87',
'edge87',
'es2020',
'firefox84',
'safari14',
],
})

7036
js/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,25 +1,17 @@
{ {
"name": "password", "name": "password",
"private": true, "private": true,
"devDependencies": {
"@babel/core": "^7.11.0",
"@babel/preset-env": "^7.11.0",
"@fortawesome/fontawesome-svg-core": "^1.2.30",
"@fortawesome/free-solid-svg-icons": "^5.14.0",
"babel-loader": "^8.1.0",
"css-loader": "^2.1.0",
"file-loader": "^3.0.1",
"style-loader": "^0.23.1",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12"
},
"dependencies": { "dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.1.1",
"@fortawesome/free-solid-svg-icons": "^6.1.1",
"bootstrap": "^4.5.0", "bootstrap": "^4.5.0",
"bootswatch": "^4.5.0", "bootswatch": "^4.5.0",
"jquery": "^3.5.1", "jquery": "^3.5.1",
"node-sass": "^4.14.1",
"popper.js": "^1.16.1", "popper.js": "^1.16.1",
"sass-loader": "^7.3.1",
"typeface-roboto": "^0.0.54" "typeface-roboto": "^0.0.54"
},
"devDependencies": {
"esbuild": "^0.14.47",
"esbuild-sass-plugin": "^2.2.6"
} }
} }

View file

@ -1,4 +1,5 @@
// Libraries // Libraries
import $ from 'jquery'
import 'bootstrap' import 'bootstrap'
// Styles // Styles
@ -6,11 +7,11 @@ import './style.scss'
// FontAwesome 5 // FontAwesome 5
import { import {
dom,
library, library,
dom
} from '@fortawesome/fontawesome-svg-core' } from '@fortawesome/fontawesome-svg-core'
import { import {
faCog faCog,
} from '@fortawesome/free-solid-svg-icons' } from '@fortawesome/free-solid-svg-icons'
library.add(faCog) library.add(faCog)
@ -19,36 +20,36 @@ dom.watch()
// Application code // Application code
import storage from './storage.js' import storage from './storage.js'
let now = () => { const now = () => {
let d = new Date() const d = new Date()
return d.getTime() return d.getTime()
} }
let stopRefresh = () => { const stopRefresh = () => {
clearInterval(window.ticker) clearInterval(window.ticker)
$('#focusedInput').select() $('#focusedInput').select()
return false return false
} }
let restartRefresh = () => { const restartRefresh = () => {
window.lastLoad = now() window.lastLoad = now()
window.ticker = setInterval(tick, window.tickerInterval) window.ticker = setInterval(tick, window.tickerInterval)
} }
let setProgress = (perc) => { const setProgress = perc => {
$('.progress-bar').css('width', `${perc}%`) $('.progress-bar').css('width', `${perc}%`)
} }
let loadPassword = () => { const loadPassword = () => {
let options = loadOptions() const options = loadOptions()
$.get(`/v1/getPassword?length=${options.passwordLength}&special=${options.useSpecial}&xkcd=${options.useXKCD}&separator=${options.xkcdSeparator}`, (data) => { $.get(`/v1/getPassword?length=${options.passwordLength}&special=${options.useSpecial}&xkcd=${options.useXKCD}&separator=${options.xkcdSeparator}`, data => {
$('#focusedInput').val(data) $('#focusedInput').val(data)
window.lastLoad = now() window.lastLoad = now()
}) })
} }
let saveOptions = () => { const saveOptions = () => {
let options = { const options = {
passwordLength: $('#passwordLengthOption').val(), passwordLength: $('#passwordLengthOption').val(),
useSpecial: $('#useSpecialOption')[0].checked, useSpecial: $('#useSpecialOption')[0].checked,
useXKCD: $('#useXKCDOption')[0].checked, useXKCD: $('#useXKCDOption')[0].checked,
@ -61,7 +62,7 @@ let saveOptions = () => {
loadPassword() loadPassword()
} }
let loadOptions = () => { const loadOptions = () => {
let options = storage.get('SecurePasswordOptions') let options = storage.get('SecurePasswordOptions')
if (!options) { if (!options) {
options = { options = {
@ -79,9 +80,9 @@ let loadOptions = () => {
return options return options
} }
let tick = () => { const tick = () => {
let diff = now() - window.lastLoad const diff = now() - window.lastLoad
let perc = (window.refreshPassword - diff) / window.refreshPassword * 100 const perc = (window.refreshPassword - diff) / window.refreshPassword * 100
setProgress(perc) setProgress(perc)
if (diff >= window.refreshPassword) { if (diff >= window.refreshPassword) {
loadPassword() loadPassword()

View file

@ -1,5 +1,5 @@
$font-size-base: 0.95rem; $font-size-base: 0.95rem;
$web-font-path: '~typeface-roboto/index.css'; $web-font-path: 'typeface-roboto/index.css';
@import '~bootswatch/dist/materia/_variables.scss'; @import '~bootswatch/dist/materia/_variables.scss';
@import "~bootstrap/scss/bootstrap"; @import "~bootstrap/scss/bootstrap";