diff --git a/nodejs/hublib_bg.wasm b/nodejs/hublib_bg.wasm index 516deb9..da6eb6f 100644 Binary files a/nodejs/hublib_bg.wasm and b/nodejs/hublib_bg.wasm differ diff --git a/web/example.html b/web/example.html index bc84bdf..71c568f 100644 --- a/web/example.html +++ b/web/example.html @@ -7,14 +7,6 @@

WASM Example

-
- - -
-
- - -

@@ -26,41 +18,49 @@ document.getElementById('getSecretValue').addEventListener('click', async () => { - const userAgent = document.getElementById('userAgent').value || navigator.userAgent; - - const secretValue = get_secret_value(BigInt(Math.floor(Date.now() / 1000)), userAgent, url); + const tmp = Math.floor(Date.now() / 1000); + const secretValue = get_secret_value( + BigInt(tmp), + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36', + '/api/v1/guestlogin' + ); document.getElementById('result').innerText = secretValue; - // const txt = 'https://api.id.hublab.ru/api/v1/guestlogin?given_time=' + - // serverTs.timestamp + - // '&user_agent=' + userAgent + - // '&gotten_sign=' + secretValue; + const txt = 'https://api.id.hublab.ru/api/v1/guestlogin' - //const response1 = await makePostRequest(txt) + const response1 = await makePostRequest( + txt, + { + 'X-SIGN': secretValue, + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36', + 'Accept-Time': tmp + } + ) }); } - // 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; // Пробрасываем ошибку дальше - // } - // } + async function makePostRequest(url, headers) { + try { + const response = await fetch(url, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + ...headers, // Расширяем заголовки + }, + }); + 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; // Пробрасываем ошибку дальше + } + } diff --git a/web/hublib_bg.wasm b/web/hublib_bg.wasm index 5cf56fa..f5fe2e9 100644 Binary files a/web/hublib_bg.wasm and b/web/hublib_bg.wasm differ