diff options
-rw-r--r-- | html/404.html | 3 | ||||
-rw-r--r-- | html/home.html | 1 | ||||
-rw-r--r-- | html/index.html | 3 | ||||
-rw-r--r-- | html/mail.html | 58 | ||||
-rw-r--r-- | index.ts | 19 | ||||
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | readme.md | 31 | ||||
-rw-r--r-- | src/favicon.ico | bin | 0 -> 15406 bytes |
8 files changed, 54 insertions, 62 deletions
diff --git a/html/404.html b/html/404.html index 8b54f1e..00e4bbe 100644 --- a/html/404.html +++ b/html/404.html @@ -1,3 +1,4 @@ +<!DOCTYPE html> <html> <head> @@ -120,7 +121,7 @@ <body onload="load()"> <h5> - 404<sub style="font-size:30px">418 </sub> + 404 </h5></br> <!-- either i dont know this page, or i cant give it to you! <sub><i>no hard feelings diff --git a/html/home.html b/html/home.html index 89c4730..2bda202 100644 --- a/html/home.html +++ b/html/home.html @@ -1,3 +1,4 @@ +<!DOCTYPE html> <html> <body onload="main()"> diff --git a/html/index.html b/html/index.html index 04d4c9f..a7d013e 100644 --- a/html/index.html +++ b/html/index.html @@ -134,7 +134,8 @@ //console.log(JSON.parse(decc)) let u = await document.getElementById('user').value await setCookie('login_key', JSON.parse(decc).login_key, 7) - await setCookie('user', u, 7) + await setCookie('user', JSON.parse(decc).alias, 7) + //await setCookie('user', u, 7) location.href = location.href + 'home' } } diff --git a/html/mail.html b/html/mail.html index 89525a6..77a2220 100644 --- a/html/mail.html +++ b/html/mail.html @@ -1,3 +1,4 @@ +<!DOCTYPE html> <html> <head> @@ -14,8 +15,9 @@ <link href="https://fonts.googleapis.com/css2?family=Baloo+2&display=swap" rel="stylesheet"> <style> .split { - height: 90%; + height: 91%; width: 51%; + top: 6%; position: fixed; z-index: 1; top: 0; @@ -214,8 +216,8 @@ float: right; display: inline; - width: 20px; - height: 20px; + width: 25px; + height: 25px; } .trashcan .trashcan-open { @@ -229,6 +231,11 @@ .trashcan:hover .trashcan-closed { display: none; } + + #emails { + top: 6%; + position: absolute; + } </style> </head> @@ -321,7 +328,7 @@ function update() { //console.log('hi') let promie = new Promise((resolve, reject) => { - sendenc('/get/update', { 'user': 'root', 'requested': 0, 'login_key': getCookie('login_key') }).then(res => { + sendenc('/get/update', { 'user': getCookie('user'), 'requested': 0, 'login_key': getCookie('login_key') }).then(res => { res = JSON.parse(res) console.log('parsed') if (res.messages == 'reg') { @@ -359,7 +366,7 @@ function init() { //console.log('hi') let promie = new Promise((resolve, reject) => { - sendenc('/get/storage', { 'user': 'root', 'pass': 'password', 'requested': 0, 'login_key': getCookie('login_key') }).then(res => { + sendenc('/get/storage', { 'user': getCookie('user'), 'pass': 'password', 'requested': 0, 'login_key': getCookie('login_key') }).then(res => { res = JSON.parse(res) console.log('parsed') emails = res.reverse() @@ -414,44 +421,12 @@ evo = !evo ret += '<div onclick="lm(' + emails.indexOf(email) + ')" style="height:10%;white-space: pre-wrap;color:#A5C9CA;border-radius:5px;max-width:40%;min-width:400px;padding:20px;background-color:' + c + ';">' - ret += '<svg onclick="del(' + emails.indexOf(email) + ')" fill="#8b0000" class="trashcan" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 25 24.8" style="enable-background:new 0 0 25 24.8;" xml:space="preserve" class="icon-trashcan ct-delete" data-ember-action="" data-ember-action-1015="1015">\ - <g class="trashcan-open">\ - <path d="M18.7,24.4H5.9L4.9,7h14.9L18.7,24.4z M7.6,22.6H17l0.8-13.7h-11L7.6,22.6z"></path>\ - <polygon points="13.6,10.3 13.1,21.2 14.9,21.2 15.4,10.3 "></polygon>\ - <polygon points="11.5,21.2 11,10.3 9.2,10.3 9.7,21.2 "></polygon>\ - <path d="M19.1,0.7l-4.7,0.9l-0.8-1.4L8.2,1.3L8,3l-4.7,1l0.2,4.7l17.3-3.5L19.1,0.7z \ - \ - M8.8,1.9l4.4 -1.0 l0.5,0.8\ - L8.7,2.8z \ - \ - M5.2,6.4l0-1L18,2.8l0.3,0.9L5.2,6.4z"></path>\ - </g>\ - <g class="trashcan-closed">\ - <path d="M6.8,8.8h11L17,22.6\ - H7.6L6.8,8.8z \ - M4.9,7l1,17.4h12.8\ - l1-17.4\ - H4.9z"></path>\ - <polygon points="13.6,10.3 13.1,21.2 14.9,21.2 15.4,10.3 "></polygon>\ - <polygon points="11.5,21.2 11,10.3 9.2,10.3 9.7,21.2 "></polygon>\ - <path d="M20.4,4h-4.8l-0.5-1.6\ - H9.5L9,4\ - H4.2\ - L3.5,8.6h17.6\ - L20.4,4z \ - \ - M9.9,3.2h4.8\ - L14.9,3.9h-5.2z\ - \ - M5.6,6.7l0.2-1 h13l0.2,1\ - H5.6z"></path>\ - </g>\ -</svg>' + ret += '<svg onclick="del(' + emails.indexOf(email) + ')" fill="#8b0000" class="trashcan" viewBox="0 0 24 24"><path d="M18,6h0a1,1,0,0,0-1.414,0L12,10.586,7.414,6A1,1,0,0,0,6,6H6A1,1,0,0,0,6,7.414L10.586,12,6,16.586A1,1,0,0,0,6,18H6a1,1,0,0,0,1.414,0L12,13.414,16.586,18A1,1,0,0,0,18,18h0a1,1,0,0,0,0-1.414L13.414,12,18,7.414A1,1,0,0,0,18,6Z"/></svg>' ret += '<tt><b><font size="4">sub:' + email.envelope.subject + '</font></b></br>frm:' + email.envelope.from[0].address + '</br><sub style="color:#E7F6F2;">' + email.envelope.date + '</sub></tt></br></div><div style="height:2px;"></div>' } - document.getElementById('emails').innerHTML = ret + document.getElementById('emails').innerHTML = ret + ret + ret + ret + ret + ret + ret } async function load() { @@ -469,11 +444,12 @@ let xx = document.getElementsByClassName('card')[0] let xy = xx.style.top let x = setInterval(() => { - if (xy >= 100) { + if (xy <= -100) { + document.getElementsByClassName('card')[0].style.display = 'none' clearInterval(x) } document.getElementsByClassName('card')[0].style.top = xy + '%' - xy -= 15 + xy -= 5 }, 10) @@ -14,6 +14,7 @@ app.use(bodyParser.json()); const NodeRSA = require('node-rsa'); var ip = require("ip") var crypt = require('crypto'); +app.use('/favicon.ico', express.static('/src/favicon.ico')) Object.defineProperty(global, '__stack', { get: function() { var orig = Error.prepareStackTrace; @@ -145,7 +146,7 @@ app.post('/mail/get/update',async(req:any,res:any)=>{ let logkey:any,mail:any for(let user of users){ //console.log(user,dec) - if(user.name==dec.data.user){ + if(user.alias==dec.data.user){ logkey = (decrypt(user.login_key,dec.data.login_key)) console.log(logkey) let m = decrypt(user.mail,logkey) @@ -173,12 +174,13 @@ app.post('/mail/get/update',async(req:any,res:any)=>{ },logLevel:1000 }); client.connect().then(()=>{ + console.log('connected') //['uid', 'flags','envelope'] for just header stuff //['uid', 'flags','envelope','body'] //body 0 is plani, 1 is plain let bo="body[0]" for(let user of users){ - if(user.name==dec.data.user){ + if(user.alias==dec.data.user){ if(user.html){ bo="body[2]" } @@ -190,13 +192,13 @@ app.post('/mail/get/update',async(req:any,res:any)=>{ let mail; skey.importKey(keyring[req.body.sid].theirpub,'pkcs8-public') for(let user of users){ - if(user.name==dec.data.user){ + console.log(user) + if(user.alias==dec.data.user){ mail = JSON.parse(decrypt(user.mail,logkey)) mail.emails[parseInt(dec.data.requested)].storage = messages user.setDataValue('mail',encrypt(JSON.stringify(mail),logkey)) user.save() User.sync({ alter: true }) - break } } @@ -204,6 +206,7 @@ app.post('/mail/get/update',async(req:any,res:any)=>{ client.close() }).catch((err:any)=>{ //! if no messages + console.log('none',err) const skey = new NodeRSA() skey.importKey(keyring[req.body.sid].theirpub,'pkcs8-public') res.send(JSON.stringify({data:skey.encrypt(JSON.stringify({messages:[],bod:bo}),'base64'),enc:true,html:true})) @@ -258,7 +261,7 @@ app.post('/mail/reg',async(req:any,res:any)=>{ const users:any = await User.findAll(); let logkey:any,mail:any for(let user of users){ - if(user.name==dec.data.user){ + if(user.alias==dec.data.user){ console.log(dec.login_key) logkey = await (decrypt(user.login_key,dec.login_key)) console.log(user.login_key) @@ -290,7 +293,7 @@ app.post('/mail/get/storage',async(req:any,res:any)=>{ const users:any = await User.findAll(); let logkey:any,mail:any for(let user of users){ - if(user.name==dec.data.user){ + if(user.alias==dec.data.user){ logkey = (decrypt(user.login_key,dec.data.login_key)) let m = JSON.parse(decrypt(user.mail,logkey)).emails if(m==undefined){ @@ -370,9 +373,11 @@ app.post('/login/submit', async (req:{body:{json:boolean,enc:boolean,data:string const skey = new NodeRSA() skey.importKey(keyring[req.body.sid].theirpub,'pkcs8-public') let logkey = crypt.createHash('md5').update(crypt.randomBytes(64).toString('hex')).digest('hex') - res.send(JSON.stringify({data:skey.encrypt(JSON.stringify({login_key:logkey}),'base64'),enc:true,html:false,json:true,type:'key'})) + let alias = crypt.createHash('md5').update(crypt.randomBytes(4096).toString('hex')).digest('hex') + res.send(JSON.stringify({data:skey.encrypt(JSON.stringify({login_key:logkey,alias:alias}),'base64'),enc:true,html:false,json:true,type:'key'})) user.setDataValue('login_key',encrypt(hash,logkey)) + user.setDataValue('alias',alias) user.save() User.sync({ alter:true }) break diff --git a/package.json b/package.json index bbae28e..00e5645 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "md5": "^2.3.0", "node-rsa": "^1.1.1", "openpgp": "^5.5.0", + "serve-favicon": "^2.5.0", "utf8": "^3.0.0" }, "devDependencies": { @@ -16,29 +16,34 @@ create generic keys `openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ### running -#### windows - dependencies: -- [ ] ts-node |`npm i -g ts-node` +- ts-node |`npm i -g ts-node` +- package.json | `npm i` +- development (optional) + - nodemon | `npm i -g nodemon` + + +#### windows -run `npm i` & `npm start` +main build : `npm start` + +dev : `npm run dev` --- #### \*nix -dependencies: +###### please note, for linux you will need to run this as root (for permission to use these ports, 80,443) -- [ ] ts-node |`sudo npm i -g ts-node` +main build : `sudo ts-node .` -run `npm i` & `sudo ts-node .` +dev : `sudo nodemon .` ---- -<sub>kanna was here</sub> +--- -visit the [main git](https://git.disroot.org/grantsquires/kanna-site) or the [github](https://github.com/squiresgrant/kanna-site) +[gitea](https://git.disroot.org/grantsquires/kanna-site) | [github](https://github.com/squiresgrant/kanna-site) ## todo @@ -63,6 +68,7 @@ visit the [main git](https://git.disroot.org/grantsquires/kanna-site) or the [gi - [ ] option to markdownify email - [ ] write md emails, send as html - [ ] sexify + - [ ] settings.json - [ ] make mail prettier - [ ] dont accept old login keys - [ ] add functionality @@ -76,7 +82,7 @@ visit the [main git](https://git.disroot.org/grantsquires/kanna-site) or the [gi - [ ] sender info - [ ] allow for email account adding - [ ] docs - - [ ] extra pages + - [x] extra pages - [x] 404 page - [ ] sub domains - [ ] ughh hate sub domains @@ -87,10 +93,11 @@ visit the [main git](https://git.disroot.org/grantsquires/kanna-site) or the [gi - [ ] more sexy gradients (everywhere) - [ ] lower verbosity (and options to change it) - [ ] move all dependencies to local ones + - [ ] check for permissions on what ports to open ### issues - [x] storage not saving - - [ ] check for login key cookie on page loads + - [ ] check for login key cookie on page load FeMail (iron mail) diff --git a/src/favicon.ico b/src/favicon.ico Binary files differnew file mode 100644 index 0000000..36a094b --- /dev/null +++ b/src/favicon.ico |