diff --git a/.gitignore b/.gitignore index a82618d..3f134dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ -password dist +frontend/assets/* +js/node_modules/* +password password_darwin_amd64 PasswordGenerator.alfredworkflow diff --git a/Makefile b/Makefile index 597c526..dec63af 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,19 @@ default: pack -compile_coffee: - coffee -c frontend/assets/application.coffee +compile_js: + docker run --rm -i \ + -v "$(CURDIR):$(CURDIR)" \ + -w "$(CURDIR)/js" \ + -u $(shell id -u) \ + node:10-alpine \ + sh -c "yarn && npx webpack" -debug: compile_coffee +debug: go-bindata --debug frontend/... go run *.go serve open http://127.0.0.1:3000/ -pack: compile_coffee +pack: compile_js go-bindata frontend/... bash generateXKCDWordList.sh diff --git a/frontend/assets/.keep b/frontend/assets/.keep new file mode 100644 index 0000000..e69de29 diff --git a/frontend/assets/application.coffee b/frontend/assets/application.coffee deleted file mode 100644 index ebfd4e4..0000000 --- a/frontend/assets/application.coffee +++ /dev/null @@ -1,71 +0,0 @@ -if window.Storage and window.JSON - window.$storage = (key) -> - set: (value) -> - localStorage.setItem(key, JSON.stringify(value)) - get: -> - item = localStorage.getItem(key) - JSON.parse(item) if item - -$ -> - window.lastLoad = now() - window.refreshPassword = 30000 - window.tickerInterval = 200 - - window.ticker = setInterval tick, window.tickerInterval - $('#focusedInput').bind 'click', stopRefresh - $('#focusedInput').bind 'blur', restartRefresh - $('#optionSave').bind 'click', saveOptions - - loadOptions() - loadPassword() - -now = () -> - d = new Date() - d.getTime() - -stopRefresh = () -> - clearInterval(window.ticker) - $('#focusedInput').select() - false - -restartRefresh = () -> - window.lastLoad = now() - window.ticker = setInterval tick, window.tickerInterval - -setProgress = (perc) -> - $('.progress-bar').css('width', "#{perc}%") - -loadPassword = () -> - options = loadOptions() - $.get "/v1/getPassword?length=#{options.passwordLength}&special=#{options.useSpecial}&xkcd=#{options.useXKCD}", (data) -> - $('#focusedInput').val(data) - window.lastLoad = now() - -saveOptions = () -> - options = - passwordLength: $('#passwordLengthOption').val() - useSpecial: $('#useSpecialOption')[0].checked - useXKCD: $('#useXKCDOption')[0].checked - - window.$storage('SecurePasswordOptions').set(options) - $('#settingsModal').modal('hide') - loadPassword() - -loadOptions = () -> - options = window.$storage('SecurePasswordOptions').get() - if options == undefined - options = - passwordLength: 20 - useSpecial: false - useXKCD: false - $('#passwordLengthOption').val(options.passwordLength) - $('#useSpecialOption')[0].checked = options.useSpecial - $('#useXKCDOption')[0].checked = options.useXKCD - options - -tick = () -> - diff = now() - window.lastLoad - perc = (window.refreshPassword - diff) / window.refreshPassword * 100 - setProgress perc - if diff >= window.refreshPassword - loadPassword() diff --git a/frontend/assets/application.js b/frontend/assets/application.js deleted file mode 100644 index dfe63be..0000000 --- a/frontend/assets/application.js +++ /dev/null @@ -1,102 +0,0 @@ -// Generated by CoffeeScript 1.12.4 -(function() { - var loadOptions, loadPassword, now, restartRefresh, saveOptions, setProgress, stopRefresh, tick; - - if (window.Storage && window.JSON) { - window.$storage = function(key) { - return { - set: function(value) { - return localStorage.setItem(key, JSON.stringify(value)); - }, - get: function() { - var item; - item = localStorage.getItem(key); - if (item) { - return JSON.parse(item); - } - } - }; - }; - } - - $(function() { - window.lastLoad = now(); - window.refreshPassword = 30000; - window.tickerInterval = 200; - window.ticker = setInterval(tick, window.tickerInterval); - $('#focusedInput').bind('click', stopRefresh); - $('#focusedInput').bind('blur', restartRefresh); - $('#optionSave').bind('click', saveOptions); - loadOptions(); - return loadPassword(); - }); - - now = function() { - var d; - d = new Date(); - return d.getTime(); - }; - - stopRefresh = function() { - clearInterval(window.ticker); - $('#focusedInput').select(); - return false; - }; - - restartRefresh = function() { - window.lastLoad = now(); - return window.ticker = setInterval(tick, window.tickerInterval); - }; - - setProgress = function(perc) { - return $('.progress-bar').css('width', perc + "%"); - }; - - loadPassword = function() { - var options; - options = loadOptions(); - return $.get("/v1/getPassword?length=" + options.passwordLength + "&special=" + options.useSpecial + "&xkcd=" + options.useXKCD, function(data) { - $('#focusedInput').val(data); - return window.lastLoad = now(); - }); - }; - - saveOptions = function() { - var options; - options = { - passwordLength: $('#passwordLengthOption').val(), - useSpecial: $('#useSpecialOption')[0].checked, - useXKCD: $('#useXKCDOption')[0].checked - }; - window.$storage('SecurePasswordOptions').set(options); - $('#settingsModal').modal('hide'); - return loadPassword(); - }; - - loadOptions = function() { - var options; - options = window.$storage('SecurePasswordOptions').get(); - if (options === void 0) { - options = { - passwordLength: 20, - useSpecial: false, - useXKCD: false - }; - } - $('#passwordLengthOption').val(options.passwordLength); - $('#useSpecialOption')[0].checked = options.useSpecial; - $('#useXKCDOption')[0].checked = options.useXKCD; - return options; - }; - - tick = function() { - var diff, perc; - diff = now() - window.lastLoad; - perc = (window.refreshPassword - diff) / window.refreshPassword * 100; - setProgress(perc); - if (diff >= window.refreshPassword) { - return loadPassword(); - } - }; - -}).call(this); diff --git a/frontend/index.html b/frontend/index.html index ae2bb62..4356399 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,27 +4,7 @@ - Secure Password - - - - - - - - -