-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautoconf.html
More file actions
65 lines (54 loc) · 2.33 KB
/
autoconf.html
File metadata and controls
65 lines (54 loc) · 2.33 KB
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
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title l10n="Autoconf">Autoconf</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./css/reset.css">
<link rel="stylesheet" href="./css/default.css">
<script src="./lib/init.js"></script>
</head>
<body>
<div id="outputdiv">
</div>
<script type="module">
// Register the service worker as we don't start by index.html
if ('serviceWorker' in navigator) {
window.addEventListener('load', async function() {
navigator.serviceWorker.register('./service-worker.js');
console.log('Service worker registered');
});
}
const outputdiv=document.getElementById("outputdiv");
import * as Earthstar from "./lib/earthstar.web.js";
import * as Lib from "./lib/lib.js";
const settings = new Earthstar.SharedSettings();
async function autoconf() {
//insert a valid channel invite below, easier for the user if it includes a server
const inv_text="earthstar://+chat.bvh4223awqjtdeowouag4hqvcjthnlrix57jgjehx2xbiqroazl7a/?invite&server=https://fair-cat-16.deno.dev/&secret=bptz5n5b6srfo6mleto6upmtqlpfg5bu4255iwpxjus3lrpu7kubq&v=2";
const share_kp=await Earthstar.parseInvitationURL(inv_text);
//uncomment block below to generate temp identity for the session, else sneakspeak will ask to generate a persistent one when needed
if(!(settings.author)) {
const author_kp = await Earthstar.Crypto.generateAuthorKeypair("anon");
settings.author = author_kp;
alert(t("Temporary ID generated, you can also create or import another ID manually"));
}
//comment line below if you want persistence by default, or alter the time messages are kept on server
SSsession.setItem("expiry_current", 86400000000); // in MICROseconds, here 1 day
//pick a translation (see available message catalogs in lib/l10n)
//SSlocal.setItem("locale","it-IT");
//leave the rest alone
if(await settings.redeemInvitationURL(inv_text) === true) {
SSsession.setItem("channel_current",share_kp.shareAddress);
SSsession.setItem("srv_current",share_kp.servers[0]);
alert(t("Autoconf completed"));
window.location.href = "./channels.html";
} else {
alert("Autoconf failed! configure manually");
window.location.href = "./index.html";
}
}
autoconf();
</script>
</body>
</html>