Skip to content

Commit

Permalink
claw and auth pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Mistium committed Nov 12, 2024
1 parent 58fd5e5 commit f46d34a
Show file tree
Hide file tree
Showing 4 changed files with 363 additions and 0 deletions.
Binary file modified .DS_Store
Binary file not shown.
232 changes: 232 additions & 0 deletions auth.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>Rotur: A Web Standard for Communication.</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta content="A websocket based networking and account system" property="og:description" />
<meta content="https://rotur.dev" property="og:url" />
<meta content="https://avatars.githubusercontent.com/u/174211781?s=256&v=4" property="og:image" />
<meta content="#3f2f3c" name="theme-color" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>
<link rel="stylesheet" href="./styles.css">
</head>

<body>
<div id="navbar-placeholder"></div>
<div class="modal">
<div class="modal-content">
<img src="./Rotur Logo.png" width="40%" alt="Rotur Logo" draggable="false" style="border-radius: 50%;">
<h1>Login</h1>
<form>
<input type="text" name="username" placeholder="Username" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit">Login</button>
</form>
<p style="font-size: medium;">This will give the website full control over your rotur account without your
permission. Ensure you are comfortable with this before proceeding.</p>
</div>
</div>

<style>
.modal {
display: flex;
justify-content: center;
align-items: center;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
background-color: #222;
border-radius: 10px;
border-style: solid;
border-color: #3f2f3c;
padding: 20px;
width: 400px;
text-align: center;
position: relative;
}

.modal-content input {
display: block;
width: calc(100% - 20px);
border-radius: 10px;
background-color: #111;
color: #fff;
margin: 10px 0;
padding: 10px;
border: none;
outline: none;
}

.modal-content button {
width: 100%;
padding: 10px;
background-color: #3f2f3c;
border-radius: 10px;
color: white;
border: none;
cursor: pointer;
}

.modal-content button:hover {
background-color: #2e1f2c;
}
</style>

<script>
MD5 = function (r) { function n(r, n) { var t, o, e, u, f; return e = 2147483648 & r, u = 2147483648 & n, f = (1073741823 & r) + (1073741823 & n), (t = 1073741824 & r) & (o = 1073741824 & n) ? 2147483648 ^ f ^ e ^ u : t | o ? 1073741824 & f ? 3221225472 ^ f ^ e ^ u : 1073741824 ^ f ^ e ^ u : f ^ e ^ u } function t(r, t, o, e, u, f, a) { return r = n(r, n(n(t & o | ~t & e, u), a)), n(r << f | r >>> 32 - f, t) } function o(r, t, o, e, u, f, a) { return r = n(r, n(n(t & e | o & ~e, u), a)), n(r << f | r >>> 32 - f, t) } function e(r, t, o, e, u, f, a) { return r = n(r, n(n(t ^ o ^ e, u), a)), n(r << f | r >>> 32 - f, t) } function u(r, t, o, e, u, f, a) { return r = n(r, n(n(o ^ (t | ~e), u), a)), n(r << f | r >>> 32 - f, t) } function f(r) { var n, t = "", o = ""; for (n = 0; 3 >= n; n++)t += (o = "0" + (o = r >>> 8 * n & 255).toString(16)).substr(o.length - 2, 2); return t } var a, i, C, c, g, h, d, v, S; for (r = function (r) { r = r.replace(/\r\n/g, "\n"); for (var n = "", t = 0; t < r.length; t++) { var o = r.charCodeAt(t); 128 > o ? n += String.fromCharCode(o) : (127 < o && 2048 > o ? n += String.fromCharCode(o >> 6 | 192) : (n += String.fromCharCode(o >> 12 | 224), n += String.fromCharCode(o >> 6 & 63 | 128)), n += String.fromCharCode(63 & o | 128)) } return n }(r), a = function (r) { for (var n, t = r.length, o = 16 * (((n = t + 8) - n % 64) / 64 + 1), e = Array(o - 1), u = 0, f = 0; f < t;)u = f % 4 * 8, e[n = (f - f % 4) / 4] |= r.charCodeAt(f) << u, f++; return e[n = (f - f % 4) / 4] |= 128 << f % 4 * 8, e[o - 2] = t << 3, e[o - 1] = t >>> 29, e }(r), h = 1732584193, d = 4023233417, v = 2562383102, S = 271733878, r = 0; r < a.length; r += 16)i = h, C = d, c = v, g = S, h = t(h, d, v, S, a[r + 0], 7, 3614090360), S = t(S, h, d, v, a[r + 1], 12, 3905402710), v = t(v, S, h, d, a[r + 2], 17, 606105819), d = t(d, v, S, h, a[r + 3], 22, 3250441966), h = t(h, d, v, S, a[r + 4], 7, 4118548399), S = t(S, h, d, v, a[r + 5], 12, 1200080426), v = t(v, S, h, d, a[r + 6], 17, 2821735955), d = t(d, v, S, h, a[r + 7], 22, 4249261313), h = t(h, d, v, S, a[r + 8], 7, 1770035416), S = t(S, h, d, v, a[r + 9], 12, 2336552879), v = t(v, S, h, d, a[r + 10], 17, 4294925233), d = t(d, v, S, h, a[r + 11], 22, 2304563134), h = t(h, d, v, S, a[r + 12], 7, 1804603682), S = t(S, h, d, v, a[r + 13], 12, 4254626195), v = t(v, S, h, d, a[r + 14], 17, 2792965006), h = o(h, d = t(d, v, S, h, a[r + 15], 22, 1236535329), v, S, a[r + 1], 5, 4129170786), S = o(S, h, d, v, a[r + 6], 9, 3225465664), v = o(v, S, h, d, a[r + 11], 14, 643717713), d = o(d, v, S, h, a[r + 0], 20, 3921069994), h = o(h, d, v, S, a[r + 5], 5, 3593408605), S = o(S, h, d, v, a[r + 10], 9, 38016083), v = o(v, S, h, d, a[r + 15], 14, 3634488961), d = o(d, v, S, h, a[r + 4], 20, 3889429448), h = o(h, d, v, S, a[r + 9], 5, 568446438), S = o(S, h, d, v, a[r + 14], 9, 3275163606), v = o(v, S, h, d, a[r + 3], 14, 4107603335), d = o(d, v, S, h, a[r + 8], 20, 1163531501), h = o(h, d, v, S, a[r + 13], 5, 2850285829), S = o(S, h, d, v, a[r + 2], 9, 4243563512), v = o(v, S, h, d, a[r + 7], 14, 1735328473), h = e(h, d = o(d, v, S, h, a[r + 12], 20, 2368359562), v, S, a[r + 5], 4, 4294588738), S = e(S, h, d, v, a[r + 8], 11, 2272392833), v = e(v, S, h, d, a[r + 11], 16, 1839030562), d = e(d, v, S, h, a[r + 14], 23, 4259657740), h = e(h, d, v, S, a[r + 1], 4, 2763975236), S = e(S, h, d, v, a[r + 4], 11, 1272893353), v = e(v, S, h, d, a[r + 7], 16, 4139469664), d = e(d, v, S, h, a[r + 10], 23, 3200236656), h = e(h, d, v, S, a[r + 13], 4, 681279174), S = e(S, h, d, v, a[r + 0], 11, 3936430074), v = e(v, S, h, d, a[r + 3], 16, 3572445317), d = e(d, v, S, h, a[r + 6], 23, 76029189), h = e(h, d, v, S, a[r + 9], 4, 3654602809), S = e(S, h, d, v, a[r + 12], 11, 3873151461), v = e(v, S, h, d, a[r + 15], 16, 530742520), h = u(h, d = e(d, v, S, h, a[r + 2], 23, 3299628645), v, S, a[r + 0], 6, 4096336452), S = u(S, h, d, v, a[r + 7], 10, 1126891415), v = u(v, S, h, d, a[r + 14], 15, 2878612391), d = u(d, v, S, h, a[r + 5], 21, 4237533241), h = u(h, d, v, S, a[r + 12], 6, 1700485571), S = u(S, h, d, v, a[r + 3], 10, 2399980690), v = u(v, S, h, d, a[r + 10], 15, 4293915773), d = u(d, v, S, h, a[r + 1], 21, 2240044497), h = u(h, d, v, S, a[r + 8], 6, 1873313359), S = u(S, h, d, v, a[r + 15], 10, 4264355552), v = u(v, S, h, d, a[r + 6], 15, 2734768916), d = u(d, v, S, h, a[r + 13], 21, 1309151649), h = u(h, d, v, S, a[r + 4], 6, 4149444226), S = u(S, h, d, v, a[r + 11], 10, 3174756917), v = u(v, S, h, d, a[r + 2], 15, 718787259), d = u(d, v, S, h, a[r + 9], 21, 3951481745), h = n(h, i), d = n(d, C), v = n(v, c), S = n(S, g); return (f(h) + f(d) + f(v) + f(S)).toLowerCase() };

let accounts = "sys-rotur";
let server = "wss://rotur.mistium.com";
fetch("https://raw.githubusercontent.com/Mistium/Origin-OS/main/Resources/info.json")
.then((response) => {
if (response.ok) {
return response.json();
} else {
throw new Error('Network response was not ok');
}
})
.then((data) => {
accounts = data.name;
server = data.server;
})
.catch((error) => {
accounts = "sys-rotur";
server = "wss://rotur.mistium.com";
});

function connectToWebsocket(server, accounts, username, password) {
window.account = undefined;
this.ip = "";
this.username = username;
this.password = password;
this.accounts = accounts;
this.userToken = "";
this.ws = new WebSocket(server);
this.ws.onopen = () => {
this.ws.send(
JSON.stringify({
cmd: "handshake",
val: {
language: "Javascript",
version: {
editorType: "Scratch",
versionNumber: null,
},
},
listener: "handshake_cfg",
}),
);

this.ws.onmessage = (event) => {
let packet = JSON.parse(event.data);
if (packet.cmd == "client_ip") {
this.ip = packet.val;
} else if (packet.cmd == "pmsg") {
if (packet.val.source_command == "login") {
if (packet.val.payload.username.toLowerCase() === this.username.toLowerCase()) {
this.userToken = packet.val.token;
window.account = packet.val.payload;
console.log("Logged in!");
} else {
console.log("Failed to login!");
}
}
}
if (packet.listener === "handshake_cfg") {
let username = "ath-" + this.username;
let msg = {
cmd: "setid",
val: username,
listener: "set_username_cfg",
};

this.ws.send(JSON.stringify(msg));
}
if (packet.listener == "set_username_cfg") {
let room = "roturTW";
let msg = {
cmd: "link",
val: [room],
listener: "link_cfg",
};

this.ws.send(JSON.stringify(msg));
}
if (packet.listener == "link_cfg") {
this.ws.send(
JSON.stringify({
cmd: "pmsg",
val: {
ip: this.ip,
client: {
system: "rotur",
version: "1.0",
},
command: "login",
id: this.userToken,
payload: [this.username, this.password],
},
id: this.accounts,
})
)
console.log("Connected!");
};
};
};
this.ws.onclose = () => {
console.log("Disconnected!");
};
}

document.querySelector('.modal form').addEventListener('submit', async (e) => {
e.preventDefault();
const submitButton = document.querySelector('.modal form button[type="submit"]');
submitButton.innerHTML = '<i class="fas fa-spinner fa-spin"></i>';
submitButton.disabled = true;

const username = document.querySelector('.modal form input[name="username"]').value;
const password = document.querySelector('.modal form input[name="password"]').value;
const hash = MD5(password);
connectToWebsocket(server, accounts, username, hash);

const checkAccount = setInterval(() => {
if (window.account !== undefined) {
clearInterval(checkAccount);
submitButton.innerHTML = 'Login';
submitButton.disabled = false;

const modalContent = document.querySelector('.modal-content');
modalContent.innerHTML = `
<img src="${window.account.pfp}" width="40%" alt="Profile Picture" draggable="false" style="border-radius: 50%;">
<h1>Welcome, ${window.account.username}</h1>
<button id="allowAccess">Allow Account Access To: ${Document.referrer}</button>
<button id="logoutButton">Logout</button>
`;

document.getElementById('profileButton').addEventListener('click', () => {
// Handle profile button click
});

document.getElementById('logoutButton').addEventListener('click', () => {
// Handle logout button click
});
}
}, 100);
});
</script>

<script src="https://kit.fontawesome.com/16f6b70bf6.js" crossorigin="anonymous"></script>
<script src="./nav.js"></script>
</body>

</html>
121 changes: 121 additions & 0 deletions claw.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<!DOCTYPE html>
<html lang="en"></html>
<head>
<meta charset="UTF-8">
<title>Claw: A Simple Social Platform</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Claw is a simple social platform made for Rotur. Without any algorithms, Claw is a simple way to post small announcements!">
<meta property="og:title" content="Claw: A Simple Social Platform" />
<meta property="og:description" content="Claw is a simple social platform made for Rotur. Without any algorithms, Claw is a simple way to post small announcements!" />
<meta property="og:url" content="https://rotur.dev/claw" />
<meta property="og:image" content="https://avatars.githubusercontent.com/u/174211781?s=256&v=4" />
<meta name="theme-color" content="#3f2f3c" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>
<link rel="stylesheet" href="./styles.css">
<style>
.headings {
text-align: center;
}
</style>
</head>
<body>
<div id="navbar-placeholder"></div>
<div style="margin: flex; display: flex;"></div>
<div class="headings">
<h1>Claw</h1>
<p>A simple<br>social platform</p><br>
<img src="https://raw.githubusercontent.com/RoturTW/apps/refs/heads/main/all/claw/screenshots/Screenshot%202024-11-12%20at%2010.44.57.png" alt="Claw Screenshot" draggable="false" style="border-radius: 15px;">
</div>
<div class="about">
<h1>About</h1>
<p>Claw is a simple social platform made for Rotur. Without any algorithms, Claw is a simple way to post small announcements!</p>
</div>
<div class="api-endpoints">
<h1>API Endpoints</h1>
<div class="dropdown">
<button class="dropbtn">GET /feed</button>
<div class="dropdown-content">
<p>https://claw.rotur.dev/feed?limit=(max100)</p><br>
<p>Gets recent global posts</p>
</div>
</div>
<div class="dropdown">
<button class="dropbtn">GET /post</button>
<div class="dropdown-content">
<p>https://claw.rotur.dev/post?content=(maxlen500)&auth=(roturtoken)</p><br>
<p>Adds a post for your account</p>
</div>
</div>
<div class="dropdown">
<button class="dropbtn">GET /profile</button>
<div class="dropdown-content">
<p>https://claw.rotur.dev/profile?name=(roturusername)</p><br>
<p>Returns user info and all posts</p>
</div>
</div>
<div class="dropdown">
<button class="dropbtn">GET /delete</button>
<div class="dropdown-content">
<p>https://claw.rotur.dev/delete?id=(postid)&auth=(roturtoken)</p><br>
<p>Deletes a post from the database (if you are the owner of the post)</p>
</div>
</div>
<div class="dropdown">
<button class="dropbtn">GET /rate</button>
<div class="dropdown-content">
<p>https://claw.rotur.dev/rate?id=(postid)&auth=(roturtoken)&rating=(1/0)</p><br>
<p>Likes or removes a like from a post</p>
</div>
</div>
</div>
<style>
.api-endpoints {
text-align: center;
margin-top: 20px;
}
.dropdown {
width: fit-content;
margin: 10px auto;
display: inline-block;
position: relative;
}
.dropbtn {
width: fit-content;
background-color: #3f2f3c;
color: white;
padding: 10px 20px;
font-size: 16px;
border: none;
cursor: pointer;
border-radius: 5px;
text-align: left;
}
.dropdown-content {
text-align: center;
display: none;
position: absolute;
bottom: 100%;
left: 50%;
transform: translateX(-50%);
background-color: #3f2f3c;
box-shadow: 0px -8px 16px 0px rgba(0,0,0,0.2);
border-radius: 5px;
font-size: medium;
padding: 10px;
width: fit-content;
white-space: nowrap;
z-index: 1;
margin-bottom: 5px;
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown-content p {
margin: 0;
}
</style>
<script src="./nav.js"></script>
</body>
</html>
10 changes: 10 additions & 0 deletions example auth.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example Auth</title>
</head>

<button onclick="window.location.href='./auth.html'" type="button">Login</button>
</html>

0 comments on commit f46d34a

Please sign in to comment.