Обновить example.html
This commit is contained in:
12
example.html
12
example.html
@@ -19,21 +19,21 @@
|
|||||||
<p id="result"></p>
|
<p id="result"></p>
|
||||||
|
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import init, { get_secret_value } from './hublib.js';
|
import init, { get_secret_value } from './hublib.js'; // импортируем функции для wasm
|
||||||
|
|
||||||
async function runWasm() {
|
async function runWasm() {
|
||||||
await init();
|
await init();
|
||||||
|
|
||||||
|
|
||||||
document.getElementById('getSecretValue').addEventListener('click', async () => {
|
document.getElementById('getSecretValue').addEventListener('click', async () => {
|
||||||
const userAgent = document.getElementById('userAgent').value || navigator.userAgent; // Используем введенный user agent или стандартный
|
const userAgent = document.getElementById('userAgent').value || navigator.userAgent; // тупо поле для user agent
|
||||||
const url = document.getElementById('url').value || window.location.href; // Используем введенный URL или текущий
|
const url = document.getElementById('url').value || window.location.href; // тупо поле для url
|
||||||
|
|
||||||
const serverTs = await fetchServerTimestamp()
|
const serverTs = await fetchServerTimestamp(); // получаем timestamp из эндпоинта (код ниже)
|
||||||
const secretValue = await get_secret_value(BigInt(serverTs.timestamp), userAgent, url);
|
const secretValue = await get_secret_value(BigInt(serverTs.timestamp), userAgent, url); // вставляем всё в функцию генерации подписи
|
||||||
// const asd = await fetch_timestamp();
|
// const asd = await fetch_timestamp();
|
||||||
|
|
||||||
document.getElementById('result').innerText = secretValue;
|
document.getElementById('result').innerText = secretValue; // подпись выводится на экран. если там вывелась какая-то ошибка, то кринж
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user