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.

91 lines
2.7 KiB

#!/usr/bin/env nodejs
try {
var package = require(__dirname+'/../package.json')
var program = require('commander')
8 years ago
var fs = require('fs')
program
.version(package.version)
.description('command line client for SafeChat, see https://safechat.ch')
.option('-u, --url <url>', 'url to safechat server [http://localhost:8888]', 'http://localhost:8888')
.option('-n, --name <name>', 'username [test]', 'test')
.option('-H, --host <host>', 'user\'s SafeChat host, mail is <name>@<host> [safechat.ch]', 'safechat.ch')
.option('-K, --keyserver <host>', 'pgp key server [https://safechat.ch]', 'https://safechat.ch')
.option('-p, --password <pwd>', 'password [ert456]', 'ert456')
.option('-k, --key <file>', 'pgp key file [key.pgp]', 'key.pgp')
.parse(process.argv)
8 years ago
var client = require(__dirname+'/../safechat/client')(program.url, program.keyserver)
fs.stat(program.key, function(err, stats) {
if (err) {
console.log('generate keys')
8 years ago
client.create(program.name, program.host, program.password,
function(user) {
fs.writeFileSync(program.key, JSON.stringify(user))
console.log('new user credentials created')
},
function(msg, e) {
console.log("**** ERRROR:", msg, e, e.stack)
})
} else if (stats.isFile()) {
8 years ago
client.login(JSON.parse(fs.readFileSync(program.key)),
function(user) {
console.log('user successfully restored:', user.email)
},
function(msg, e) {
console.log("**** ERRROR:", msg, e, e.stack)
})
} else {
console.log('**** ERROR: cannot read file', program.key)
}
})
/*
console.log('connecting to:', program.url)
var socket = io(program.url)
socket
.on('connect', function() {
console.log('connect')
socket.emit('login', {name: 'test', })
})
.on("login", function() {
console.log('loggedin')
})
.on("fail", function() {
console.log('fail')
})
.on("user", function() {
console.log('user')
})
.on("users", function() {
console.log('users')
})
.on("message", function() {
console.log('message')
})
.on("messages", function() {
console.log('messages')
})
.io
.on("connect", function() {
console.log('io.connect')
})
.on("reconnect", function() {
console.log('io.reconnect')
})
.on("disconnect", function() {
console.log('io.disconnect')
})
.on("error", function() {
console.log('io.disconnect')
})
*/
} catch (e) {
console.log('**** ERROR:', e.stack)
}