2022-09-30 21:53:45 -04:00
|
|
|
<!doctype html>
|
|
|
|
<html class="no-js" lang="en">
|
|
|
|
<head>
|
|
|
|
<title>Converse</title>
|
|
|
|
<meta charset="utf-8"/>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
|
|
<meta name="description" content="Converse Rust"/>
|
|
|
|
<meta name="author" content="moparisthebest" />
|
|
|
|
<meta name="keywords" content="xmpp chat webchat converse.js" />
|
|
|
|
<link rel="shortcut icon" type="image/ico" href="./dist/favicon.ico"/>
|
|
|
|
<link rel="manifest" href="./manifest.json">
|
|
|
|
<link type="text/css" rel="stylesheet" media="screen" href="./dist/converse.min.css" />
|
|
|
|
<!--
|
|
|
|
uncomment this to disable omemo
|
|
|
|
-->
|
|
|
|
<script src="./3rdparty/libsignal-protocol.min.js"></script>
|
|
|
|
<script src="./dist/converse.min.js"></script>
|
|
|
|
</head>
|
|
|
|
<body class="converse-fullscreen">
|
|
|
|
<noscript>You need to enable JavaScript to run the Converse.js chat app.</noscript>
|
|
|
|
<div id="conversejs-bg"></div>
|
|
|
|
<script>
|
|
|
|
// access the pre-bundled global API functions
|
|
|
|
const { invoke } = window.__TAURI__.tauri;
|
2022-10-04 01:15:24 -04:00
|
|
|
const { getClient, ResponseType } = window.__TAURI__.http;
|
|
|
|
const tauriFetch = window.__TAURI__.http.fetch;
|
|
|
|
|
|
|
|
const realFetch = window.fetch;
|
|
|
|
|
|
|
|
// this is clearly not a complete fetch implementation
|
|
|
|
// but it's enough for the omemo downloadFile() function...
|
|
|
|
window.fetch = async function(url) {
|
|
|
|
console.log("fetching url: " + url);
|
|
|
|
|
|
|
|
const client = await getClient();
|
|
|
|
let response = await await client.get(
|
|
|
|
url, {
|
|
|
|
timeout: 30,
|
|
|
|
responseType: ResponseType.Binary
|
|
|
|
});
|
|
|
|
|
|
|
|
let data = new Uint8Array(response.data).buffer;
|
|
|
|
|
|
|
|
response.arrayBuffer = async function() {
|
|
|
|
return data;
|
|
|
|
};
|
|
|
|
|
|
|
|
return response;
|
|
|
|
};
|
2022-09-30 21:53:45 -04:00
|
|
|
|
2022-10-02 22:30:56 -04:00
|
|
|
function addCredentials (login, password) {
|
|
|
|
localStorage.setItem('login', login);
|
|
|
|
localStorage.setItem('password', password);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getCredentials () {
|
|
|
|
const credentials = {}
|
|
|
|
credentials.login = localStorage.getItem('login') || '';
|
|
|
|
if (credentials.login) {
|
|
|
|
credentials.password = localStorage.getItem('password');
|
|
|
|
}
|
|
|
|
|
|
|
|
return credentials;
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeCredentials () {
|
|
|
|
localStorage.removeItem('login');
|
|
|
|
localStorage.removeItem('password');
|
|
|
|
}
|
|
|
|
|
|
|
|
converse.plugins.add('converse-desktop-credentials', {
|
|
|
|
initialize () {
|
|
|
|
console.log("converse-desktop-credentials - initialize");
|
|
|
|
|
|
|
|
const { _converse } = this;
|
|
|
|
const { api } = _converse;
|
|
|
|
|
|
|
|
api.listen.on('afterResourceBinding', () => {
|
|
|
|
console.log("converse-desktop-credentials - afterResourceBinding");
|
|
|
|
if (_converse.connection.pass) {
|
|
|
|
addCredentials(
|
|
|
|
_converse.bare_jid,
|
|
|
|
_converse.connection.pass
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
api.listen.on('logout', () => {
|
|
|
|
console.log("converse-desktop-credentials - logout");
|
|
|
|
removeCredentials();
|
|
|
|
});
|
|
|
|
}
|
2022-09-30 21:53:45 -04:00
|
|
|
});
|
2022-10-02 22:30:56 -04:00
|
|
|
|
|
|
|
const { login, password } = getCredentials();
|
|
|
|
console.log('login: ' + login);
|
|
|
|
|
|
|
|
invoke('proxy_port').then((port) => {
|
|
|
|
console.log('proxy_port: ' + port);
|
|
|
|
|
|
|
|
converse.initialize({
|
|
|
|
auto_login: login && password,
|
|
|
|
jid: login,
|
|
|
|
password: password,
|
|
|
|
authentication: 'login',
|
|
|
|
auto_away: 300,
|
|
|
|
auto_reconnect: true,
|
|
|
|
websocket_url: 'ws://127.0.0.1:' + port + '/xmpp-websocket/',
|
|
|
|
assets_path: './dist/',
|
|
|
|
discover_connection_methods: false,
|
|
|
|
message_archiving: 'always',
|
|
|
|
play_sounds: false,
|
|
|
|
view_mode: 'fullscreen',
|
2022-10-04 01:15:24 -04:00
|
|
|
//loglevel: 'debug',
|
2022-10-02 22:30:56 -04:00
|
|
|
muc_respect_autojoin: true,
|
|
|
|
muc_show_logs_before_join: true,
|
|
|
|
whitelisted_plugins: ['converse-desktop-credentials']
|
|
|
|
}).catch((reason) => {
|
|
|
|
document.body.innerText = "error starting converse: " + reason;
|
|
|
|
console.log(document.body.innerText);
|
|
|
|
});
|
|
|
|
}).catch((reason) => {
|
|
|
|
document.body.innerText = "error starting proxy: " + reason;
|
|
|
|
console.log(document.body.innerText);
|
2022-09-30 21:53:45 -04:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|