Обновить example.html
This commit is contained in:
46
example.html
46
example.html
@@ -28,14 +28,10 @@
|
||||
document.getElementById('getSecretValue').addEventListener('click', async () => {
|
||||
const userAgent = document.getElementById('userAgent').value || navigator.userAgent;
|
||||
|
||||
<<<<<<< HEAD
|
||||
|
||||
|
||||
const secretValue = get_secret_value(BigInt(Math.floor(Date.now() / 1000)), userAgent, url);
|
||||
=======
|
||||
const serverTs = await fetchServerTimestamp()
|
||||
const secretValue = await get_secret_value(BigInt(serverTs.timestamp), userAgent, '/api/v1/guestlogin');
|
||||
console.log(secretValue)
|
||||
>>>>>>> 48f507f7dde5c9ec4ea370f103d3af1c0dc59262
|
||||
|
||||
|
||||
document.getElementById('result').innerText = secretValue;
|
||||
|
||||
@@ -51,44 +47,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
async function fetchServerTimestamp() {
|
||||
const url = "https://api.id.hublab.ru/api/v1/server-timestamp";
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
// Проверяем, успешен ли ответ
|
||||
if (!response.ok) {
|
||||
throw new Error(`Ошибка HTTP: ${response.status}`);
|
||||
}
|
||||
// Парсим JSON из ответа
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Произошла ошибка при получении времени сервера:", error);
|
||||
return null; // Возвращаем null в случае ошибки
|
||||
}
|
||||
}
|
||||
async function makePostRequest(url) {
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json', // Указываем, что отправляем данные в формате JSON
|
||||
},
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! Статус: ${response.status}`);
|
||||
}
|
||||
const responseData = await response.json(); // Получаем ответ как JSON
|
||||
return responseData; // Возвращаем полученные данные
|
||||
} catch (error) {
|
||||
console.error('Ошибка при выполнении POST-запроса:', error);
|
||||
throw error; // Пробрасываем ошибку дальше
|
||||
}
|
||||
}
|
||||
>>>>>>> 48f507f7dde5c9ec4ea370f103d3af1c0dc59262
|
||||
|
||||
|
||||
|
||||
runWasm();
|
||||
|
||||
Reference in New Issue
Block a user