aboutsummaryrefslogtreecommitdiff
path: root/index.ts
diff options
context:
space:
mode:
authorgrant-kun <[email protected]>2022-10-19 08:42:39 -0500
committergrant-kun <[email protected]>2022-10-19 08:42:39 -0500
commit1f82c948ac210dc03dadf243d5441139cd50ab03 (patch)
tree236abd3f6686f9d9a4ef5932af1043033055e728 /index.ts
parent11bfeb2d410acf5e5faca67215341289fdaf8462 (diff)
email reg
Diffstat (limited to 'index.ts')
-rw-r--r--index.ts18
1 files changed, 16 insertions, 2 deletions
diff --git a/index.ts b/index.ts
index 9a9cc65..9d79783 100644
--- a/index.ts
+++ b/index.ts
@@ -123,6 +123,13 @@ app.post('/mail/get/update',async(req:any,res:any)=>{
mail =JSON.parse(decrypt(user.mail,logkey)).emails[parseInt(dec.data.requested)]
}
}
+ if(mail==''){
+ const skey = new NodeRSA()
+ let mail;
+ skey.importKey(keyring[req.body.sid].theirpub,'pkcs8-public')
+ res.send(JSON.stringify({data:skey.encrypt(JSON.stringify({messages:'reg'}),'base64'),enc:true,html:true}))
+ return
+ }
var client = new ImapClient(mail.host, parseInt(mail.port), {
auth: {
user: mail.address,
@@ -181,7 +188,7 @@ app.post('/mail/del',async(req:any,res:any)=>{
key.importKey(keyring[req.body.sid].mypriv,'pkcs1-private')
let dec:any = JSON.parse((atob(key.decrypt(req.body.data,'base64','base64'))))
const users:any = await User.findAll();
- let logkey:any,mail:any
+ let logkey:any,mail:any;
for(let user of users){
//console.log(user,dec)
if(user.name==dec.data.user){
@@ -254,6 +261,13 @@ app.post('/mail/get/storage',async(req:any,res:any)=>{
mail =JSON.parse(decrypt(user.mail,logkey))
}
}
+ if(mail==''){
+ const skey = new NodeRSA()
+ let mail;
+ skey.importKey(keyring[req.body.sid].theirpub,'pkcs8-public')
+ res.send(JSON.stringify({data:skey.encrypt(JSON.stringify({messages:'reg'}),'base64'),enc:true,html:true}))
+ return
+ }
let d = skey.encrypt((mail.emails[parseInt(dec.data.requested)].storage),'base64')
res.send(JSON.stringify({data:d,enc:true,html:true}))
})
@@ -361,4 +375,4 @@ httpsServer.listen(443, function https() {
/*
todo:
-*/ \ No newline at end of file
+*/