forked from olcxjas-softworks/LarpixClient
Add server status check
This commit is contained in:
parent
5e01e5d459
commit
e908702025
3 changed files with 105 additions and 21 deletions
26
main.js
26
main.js
|
|
@ -26,7 +26,7 @@ async function getNonce(username, key) {
|
|||
|
||||
let nonce;
|
||||
let fetchRes = await (await fetch(`${url}/nextnonce?u=${username}`)).text();
|
||||
console.log(key, fetchRes);
|
||||
|
||||
try {
|
||||
nonce = await decryptString(fetchRes, key);
|
||||
}
|
||||
|
|
@ -229,20 +229,34 @@ async function fetchPostEnc(url, value) {
|
|||
async function fetchAsync(url) {
|
||||
let response = await fetch(url, {
|
||||
method: "GET",
|
||||
credentials: "omit",
|
||||
headers: {
|
||||
"secret": await encryptWithNonce(passwordHash, passwordHash, await getNonce(username, passwordHash))
|
||||
}
|
||||
credentials: "omit"
|
||||
});
|
||||
|
||||
let data = await response.text();
|
||||
return data;
|
||||
}
|
||||
|
||||
async function fetchAsyncWAuth(url) {
|
||||
let response = await fetch(url, {
|
||||
method: "GET",
|
||||
credentials: "omit",
|
||||
headers: {
|
||||
"secret": await encryptWithNonce(passwordHash, passwordHash, await getNonce(username, passwordHash))
|
||||
}
|
||||
});
|
||||
|
||||
let data = await response.text();
|
||||
return data;
|
||||
}
|
||||
|
||||
async function getServerInfo(host){
|
||||
console.log(`${window.location.protocol}//${host}/_larpix/serverinfo`)
|
||||
return JSON.parse(await fetchAsync(`${window.location.protocol}//${host}/_larpix/serverinfo`));
|
||||
}
|
||||
|
||||
async function Auth(username, password) {
|
||||
|
||||
let passwordHash = await hashSHA3_512(password);
|
||||
console.log(username, password, passwordHash);
|
||||
let response = await fetch(`${url}/auth?u=${username}`, {
|
||||
method: "GET",
|
||||
credentials: "omit",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue