aboutsummaryrefslogtreecommitdiff
path: root/html/mail.html
blob: 2aad8ab37d7ff4ca00534c6e58f07cdf43c7f2fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<html>

<head>
    <title>mail</title>
</head>

<body>
    <script>
        function sendenc(location, content) {
            var xhr = new XMLHttpRequest();
            xhr.open("POST", window.location.href + location, true);
            xhr.setRequestHeader('Content-Type', 'application/json');
            xhr.onreadystatechange = function () {
                if (xhr.readyState == XMLHttpRequest.DONE) {
                    pub = kekw.decrypt(JSON.parse(xhr.responseText).data);
                    return pub
                }
            }
            let out = {}
            Object.assign(out, { json: true, enc: false }, { data: nodersa(pub, 'pkcs8-public').encrypt(content, { date: new Date() }, 'base64') })
            xhr.send(JSON.stringify(out))
        }
        function sendnoenc(location, content) {
            var promise = new Promise((resolve, reject) => {
                var xhr = new XMLHttpRequest();
                xhr.open("POST", window.location.href + location, true);
                xhr.setRequestHeader('Content-Type', 'application/json');
                xhr.onreadystatechange = function () {
                    if (xhr.readyState == XMLHttpRequest.DONE) {
                        resolve(xhr.responseText);
                    }
                }
                let out = {}
                Object.assign(out, { json: true, enc: false }, content)
                xhr.send(JSON.stringify(out))
            })
            return (promise)
        }
        document.onkeypress = function (key) {
            key = key || window.event;
            if (key.key == "Enter") {
                submit()
            }
        };
        function update() {
            console.log('hi')
            sendnoenc('', { 'user': 'root', 'pass': 'password' }).then(res => {
                console.log(res)
            })
        }
    </script>
</body>
<button onclick="update()">update mail</button>

</html>