Skip to content

Commit

Permalink
Added import
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziga committed May 24, 2021
1 parent 9e2d04b commit a1e2d19
Show file tree
Hide file tree
Showing 11 changed files with 306 additions and 92 deletions.
37 changes: 19 additions & 18 deletions html/export.html → export.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
<link rel="stylesheet" href="../css/tailwind.min.css">
<link rel="stylesheet" href="../css/passwords.css">
<script src="../js/aes.js"></script>
<title>Passky</title>
<link rel="shortcut icon" type="image/png" href="images/logo.png"/>
<link rel="stylesheet" href="css/tailwind.min.css">
<link rel="stylesheet" href="css/passwords.css">
<script src="js/aes.js"></script>
</head>

<nav class="bg-white shadow">
<div class="max-w-7xl mx-auto px-2 sm:px-4 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex px-2 lg:px-0">
<div class="flex-shrink-0 flex items-center">
<img class="block lg:hidden h-8 w-auto" src="../images/logo.png" alt="Passky">
<img class="hidden lg:block h-8 w-auto" src="../images/logo.png" alt="Passky">
<img class="block lg:hidden h-8 w-auto" src="images/logo.png" alt="Passky">
<img class="hidden lg:block h-8 w-auto" src="images/logo.png" alt="Passky">
</div>
<div class="hidden lg:ml-6 lg:flex lg:space-x-8">
<a href="passwords.html" class="border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700 inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">
Expand Down Expand Up @@ -56,13 +58,13 @@
<ul class="grid grid-cols-1 gap-6 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
<li class="col-span-1 flex flex-col text-center bg-white rounded-lg shadow divide-y divide-gray-200">
<div class="flex-1 flex flex-col p-8">
<img class="w-24 h-24 flex-shrink-0 mx-auto rounded-full" style="background-color: #e6f5ff;" src="../images/logo.png" alt="Passky">
<img class="w-24 h-24 flex-shrink-0 mx-auto rounded-full" style="background-color: #e6f5ff;" src="images/logo.png" alt="Passky">
<h3 class="mt-6 text-gray-900 text-lg font-medium">Passky</h3>
</div>
<div>
<div class="-mt-px flex divide-x divide-gray-200">
<div class="w-0 flex-1 flex">
<a href="#" class="relative -mr-px w-0 flex-1 inline-flex items-center justify-center py-4 text-sm text-gray-700 font-medium border border-transparent rounded-bl-lg hover:text-gray-500">
<a href="javascript:changeDialog(1); show('dialog');" class="relative -mr-px w-0 flex-1 inline-flex items-center justify-center py-4 text-sm text-gray-700 font-medium border border-transparent rounded-bl-lg hover:text-gray-500">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="1.5" stroke="#2c3e50" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M14 3v4a1 1 0 0 0 1 1h4" />
Expand Down Expand Up @@ -97,7 +99,7 @@ <h3 class="mt-6 text-gray-900 text-lg font-medium">Passky</h3>
</li>
<li class="col-span-1 flex flex-col text-center bg-white rounded-lg shadow divide-y divide-gray-200">
<div class="flex-1 flex flex-col p-8">
<img class="w-24 h-24 flex-shrink-0 mx-auto rounded-full" style="background-color: #3c8dbc;" src="../images/bitwarden.png" alt="Bitwarden">
<img class="w-24 h-24 flex-shrink-0 mx-auto rounded-full" style="background-color: #3c8dbc;" src="images/bitwarden.png" alt="Bitwarden">
<h3 class="mt-6 text-gray-900 text-lg font-medium">Bitwarden</h3>
</div>
<div>
Expand Down Expand Up @@ -127,7 +129,7 @@ <h3 class="mt-6 text-gray-900 text-lg font-medium">Bitwarden</h3>
</li>
<li class="col-span-1 flex flex-col text-center bg-white rounded-lg shadow divide-y divide-gray-200">
<div class="flex-1 flex flex-col p-8">
<img class="w-24 h-24 flex-shrink-0 mx-auto rounded-full" style="background-color: #d12f2e;" src="../images/lastpass.png" alt="Lastpass">
<img class="w-24 h-24 flex-shrink-0 mx-auto rounded-full" style="background-color: #d12f2e;" src="images/lastpass.png" alt="Lastpass">
<h3 class="mt-6 text-gray-900 text-lg font-medium">Lastpass</h3>
</div>
<div>
Expand All @@ -143,7 +145,7 @@ <h3 class="mt-6 text-gray-900 text-lg font-medium">Lastpass</h3>
</a>
</div>
<div class="-ml-px w-0 flex-1 flex">
<a href="#" class="relative w-0 flex-1 inline-flex items-center justify-center py-4 text-sm text-gray-700 font-medium border border-transparent rounded-br-lg hover:text-gray-500">
<a href="javascript:export_lastpass()" class="relative w-0 flex-1 inline-flex items-center justify-center py-4 text-sm text-gray-700 font-medium border border-transparent rounded-br-lg hover:text-gray-500">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" stroke-width="1.5" stroke="#2c3e50" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M14 3v4a1 1 0 0 0 1 1h4" />
Expand All @@ -157,7 +159,7 @@ <h3 class="mt-6 text-gray-900 text-lg font-medium">Lastpass</h3>
</li>
<li class="col-span-1 flex flex-col text-center bg-white rounded-lg shadow divide-y divide-gray-200">
<div class="flex-1 flex flex-col p-8">
<img class="w-24 h-24 flex-shrink-0 mx-auto rounded-full" style="background-color: #0e353d;" src="../images/dashline.png" alt="Dashline">
<img class="w-24 h-24 flex-shrink-0 mx-auto rounded-full" style="background-color: #0e353d;" src="images/dashline.png" alt="Dashline">
<h3 class="mt-6 text-gray-900 text-lg font-medium">Dashline</h3>
</div>
<div>
Expand Down Expand Up @@ -187,7 +189,7 @@ <h3 class="mt-6 text-gray-900 text-lg font-medium">Dashline</h3>
</li>
<li class="col-span-1 flex flex-col text-center bg-white rounded-lg shadow divide-y divide-gray-200">
<div class="flex-1 flex flex-col p-8">
<img class="w-24 h-24 flex-shrink-0 mx-auto rounded-full" style="background-color: #fff;" src="../images/1password.svg" alt="1Password">
<img class="w-24 h-24 flex-shrink-0 mx-auto rounded-full" style="background-color: #fff;" src="images/1password.svg" alt="1Password">
<h3 class="mt-6 text-gray-900 text-lg font-medium">1Password</h3>
</div>
<div>
Expand Down Expand Up @@ -217,7 +219,7 @@ <h3 class="mt-6 text-gray-900 text-lg font-medium">1Password</h3>
</li>
<li class="col-span-1 flex flex-col text-center bg-white rounded-lg shadow divide-y divide-gray-200">
<div class="flex-1 flex flex-col p-8">
<img class="w-24 h-24 flex-shrink-0 mx-auto rounded-full" style="background-color: #fff;" src="../images/keeper.png" alt="Keeper">
<img class="w-24 h-24 flex-shrink-0 mx-auto rounded-full" style="background-color: #fff;" src="images/keeper.png" alt="Keeper">
<h3 class="mt-6 text-gray-900 text-lg font-medium">Keeper</h3>
</div>
<div>
Expand Down Expand Up @@ -247,7 +249,7 @@ <h3 class="mt-6 text-gray-900 text-lg font-medium">Keeper</h3>
</li>
<li class="col-span-1 flex flex-col text-center bg-white rounded-lg shadow divide-y divide-gray-200">
<div class="flex-1 flex flex-col p-8">
<img class="w-24 h-24 flex-shrink-0 mx-auto rounded-full" style="background-color: #d3f8f7;" src="../images/nordpass.png" alt="Nordpass">
<img class="w-24 h-24 flex-shrink-0 mx-auto rounded-full" style="background-color: #d3f8f7;" src="images/nordpass.png" alt="Nordpass">
<h3 class="mt-6 text-gray-900 text-lg font-medium">Nordpass</h3>
</div>
<div>
Expand Down Expand Up @@ -311,9 +313,8 @@ <h3 class="text-lg leading-6 font-medium text-gray-900" id="dialog-title">
</div>
</div>
</div>

<script src="../js/default-functions.js"></script>
<script src="../js/sha512.js"></script>
<script src="../js/export.js"></script>
<script src="js/default-functions.js"></script>
<script src="js/sha512.js"></script>
<script src="js/export.js"></script>
</body>
</html>
12 changes: 7 additions & 5 deletions html/login.html → index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
<link rel="stylesheet" href="../css/tailwind.min.css">
<title>Passky</title>
<link rel="shortcut icon" type="image/png" href="images/logo.png"/>
<link rel="stylesheet" href="css/tailwind.min.css">
</head>

<body style="min-width: 300px;">
<div class="min-h-screen flex items-center justify-center bg-gray-50 py-6 px-4 sm:px-3 lg:px-8">
<div class="max-w-md w-full space-y-6">
<div>
<img class="mx-auto h-20 w-auto" src="../images/logo.png" alt="Passky">
<img class="mx-auto h-20 w-auto" src="images/logo.png" alt="Passky">
</div>
<form class="mt-8 space-y-6" action="javascript:onBtnClick()">
<input type="hidden" name="remember" value="true">
Expand Down Expand Up @@ -76,8 +78,8 @@ <h3 class="text-lg leading-6 font-medium text-gray-900" id="error-dialog-modal-t
</form>
</div>
</div>
<script src="../js/default-functions.js"></script>
<script src="../js/sha512.js"></script>
<script src="../js/login.js"></script>
<script src="js/default-functions.js"></script>
<script src="js/sha512.js"></script>
<script src="js/login.js"></script>
</body>
</html>
93 changes: 89 additions & 4 deletions js/default-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ function validEmail(mail){
return new RegExp(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/).test(mail);
}

function check_login(){
if(sessionStorage.url == null && typeof(sessionStorage.url) == 'undefined') window.location.href = 'index.html';
if(sessionStorage.username == null && typeof(sessionStorage.username) == 'undefined') window.location.href = 'index.html';
if(sessionStorage.password == null && typeof(sessionStorage.password) == 'undefined') window.location.href = 'index.html';
if(sessionStorage.passwords == null && typeof(sessionStorage.passwords) == 'undefined') window.location.href = 'index.html';
}

function animateButton(id, enabled){
if(enabled){
document.getElementById(id + "-color").className = "bg-indigo-600 pointer-events-none absolute h-4 w-9 mx-auto rounded-full transition-colors ease-in-out duration-200";
Expand All @@ -45,7 +52,7 @@ function toggleMenu(){
function copyToClipboard(text){
let textArea = document.createElement("textarea");
textArea.value = text;

textArea.style.top = 0;
textArea.style.left = 0;
textArea.style.position = "fixed";
Expand Down Expand Up @@ -73,6 +80,10 @@ const errors = {
"10": "User does not own this password!",
"11": "Something went wrong while deleting data from database!",
"12": "Username must be between 6 and 30 characters long and can only contains letters, numbers and dots!",
"13": "Something went wrong while updating data in database!",
"14": "Json is invalid!",
"15": "This server can't accept more users!",
"16": "You have reached maximum amount of stored passwords!",
"400": "Action was not provided in POST!",
"401": "Action is invalid!",
"403": "You didn't provide all required values in POST.",
Expand All @@ -82,6 +93,16 @@ const errors = {
"999": "You don't have permission to use this endpoint."
}

function downloadTxt(exportTxt, exportName){
let dataStr = "data:text/plain;charset=utf-8," + encodeURIComponent(exportTxt);
let downloadAnchorNode = document.createElement('a');
downloadAnchorNode.setAttribute("href", dataStr);
downloadAnchorNode.setAttribute("download", exportName + ".txt");
document.body.appendChild(downloadAnchorNode); // required for firefox
downloadAnchorNode.click();
downloadAnchorNode.remove();
}

function downloadJson(exportJson, exportName){
let dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(exportJson);
let downloadAnchorNode = document.createElement('a');
Expand All @@ -102,15 +123,79 @@ function downloadObjectAsJson(exportObj, exportName){
downloadAnchorNode.remove();
}

function getDate(date) {
function isJsonValid(str){
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
}

function getDate(date){
let local = new Date(date);
local.setMinutes(date.getMinutes() - date.getTimezoneOffset());
return local.toJSON().slice(0, 10);
}

function isPasswordWebsiteValid(website){
if(website == null || typeof(website) == 'undefined') return false;
if(website.length == 0) return false;
if(!(website.length >= 5 && website.length <= 255) || website.includes(" ")) return false;
if(website.includes("'") || website.includes('"') || website.includes("\\")) return false;
return true;
}

function isPasswordUsernameValid(username){
if(username == null || typeof(username) == 'undefined') return false;
if(username.length == 0) return false;
if(!(username.length >= 3 && username.length <= 255) || username.includes(" ")) return false;
if(username.includes("'") || username.includes('"') || username.includes("\\")) return false;
return true;
}

function isPasswordPasswordValid(password){
if(password == null || typeof(password) == 'undefined') return false;
if(password.length == 0) return false;
if(!(password.length >= 8 && password.length <= 255) || password.includes(" ")) return false;
if(password.includes("'") || password.includes('"') || password.includes("\\")) return false;
return true;
}

function refreshPasswords(){
var xhr = new XMLHttpRequest();
xhr.open("POST", sessionStorage.url + "/?action=getPasswords");

xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Authorization", "Basic " + btoa(sessionStorage.username + ":" + sha512(sessionStorage.password)));
xhr.setRequestHeader("Content-Type", "application/json");

xhr.onreadystatechange = function () {

if(xhr.readyState === 4){
if(xhr.status != 200) return;

const json = JSON.parse(xhr.responseText);

if(typeof json['error'] === 'undefined') return;
if(json['error'] != 0 && json['error'] != 8) return;

if(json['error'] == 0){
sessionStorage.passwords = JSON.stringify(json['passwords']);
}else{
sessionStorage.passwords = "{}";
}

window.location.href = 'passwords.html';
}

};
xhr.send("");
}

function logout(){
sessionStorage.url = null;
sessionStorage.username = null;
sessionStorage.password = null;
window.location.href = 'login.html';
}
window.location.href = 'index.html';
}
Loading

0 comments on commit a1e2d19

Please sign in to comment.