Fully end to end encrypted anonymous chat program. Server only stores public key lookup for users and the encrypted messages. No credentials are transfered to the server, but kept in local browser storage. This allows 100% safe chatting.
https://safechat.ch
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.5 KiB
41 lines
1.5 KiB
10 years ago
|
importScripts('jquery.js');
|
||
|
importScripts('openpgp.js');
|
||
|
|
||
|
function attachments(files) {
|
||
|
var res = '';
|
||
|
if (files) files.forEach(function(file) {
|
||
|
if (file.type.match("^image/"))
|
||
|
res += '<img src="'+'data:'+file.type+';base64,' + btoa(file.content)+'"/>';
|
||
|
});
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
addEventListener('message', function(data) {
|
||
|
var e = data.e;
|
||
|
var key = data.key;
|
||
|
var message = openpgp.message.readArmored(e["msg"]);
|
||
|
var privkey = privateKey().keys[0];
|
||
|
if (privkey.decrypt(password))
|
||
|
openpgp.decryptAndVerifyMessage(privkey, key.keys, message)
|
||
|
.then(function(msg) {
|
||
|
var message = JSON.parse(msg.text);
|
||
|
// todo: check msg.signatures[0].valid
|
||
|
postMessage('<div id="id'+(e["id"])+'" class="msg '+
|
||
|
(e["user"]==userid()?"me":"other")+
|
||
|
'"><div class="header">'+
|
||
|
'<span class="date">'+
|
||
|
(new Date(1000*Number(e["time"]))).toLocaleString()+
|
||
|
'</span><span class="sender">'+
|
||
|
'<a href="javascript:void(0)" onclick="setreceiver(this.innerHTML)">'+
|
||
|
e["user"]+
|
||
|
'</a></span></div>'+
|
||
|
attachments(message.files)+
|
||
|
'<div class="text">'+
|
||
|
message.text+
|
||
|
'</div></div><div class="clear"/>');
|
||
|
})
|
||
|
.catch(function(e) {
|
||
|
// not for me
|
||
|
});
|
||
|
}, false);
|