This commit is contained in:
2025-05-28 17:10:45 +03:00
parent d585219aa3
commit 5f80666cea
5 changed files with 38 additions and 18 deletions

View File

@@ -20,7 +20,7 @@
document.getElementById('getSecretValue').addEventListener('click', async () => {
const tmp = Math.floor(Date.now() / 1000);
const secretValue = get_secret_value(
BigInt(tmp),
getHTTPFormattedTime(),
'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'
);
@@ -62,6 +62,24 @@
}
}
function getHTTPFormattedTime() {
const now = new Date();
const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
const day = days[now.getUTCDay()];
const date = now.getUTCDate().toString().padStart(2, '0');
const month = months[now.getUTCMonth()];
const year = now.getUTCFullYear();
const hours = now.getUTCHours().toString().padStart(2, '0');
const minutes = now.getUTCMinutes().toString().padStart(2, '0');
const seconds = now.getUTCSeconds().toString().padStart(2, '0');
return `${day}, ${date} ${month} ${year} ${hours}:${minutes}:${seconds} GMT`;
}
const httpTime = getHTTPFormattedTime();
runWasm();

8
web/hublib.d.ts vendored
View File

@@ -1,6 +1,6 @@
/* tslint:disable */
/* eslint-disable */
export function get_secret_value(given_time: bigint, user_agent: string, url: string): string;
export function get_secret_value(http_time: string, user_agent: string, url: string): string;
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
@@ -63,10 +63,10 @@ export interface InitOutput {
readonly ffi_hublib_rust_future_cancel_void: (a: bigint) => void;
readonly ffi_hublib_rust_future_complete_void: (a: bigint, b: number) => void;
readonly ffi_hublib_rust_future_free_void: (a: bigint) => void;
readonly uniffi_hublib_fn_func_get_secret_value: (a: number, b: bigint, c: bigint, d: bigint, e: number, f: number, g: bigint, h: bigint, i: number, j: number, k: number) => void;
readonly uniffi_hublib_fn_func_get_secret_value: (a: number, b: bigint, c: bigint, d: number, e: number, f: bigint, g: bigint, h: number, i: number, j: bigint, k: bigint, l: number, m: number, n: number) => void;
readonly uniffi_hublib_checksum_func_get_secret_value: () => number;
readonly get_secret_value: (a: bigint, b: number, c: number, d: number, e: number) => [number, number];
readonly uniffi_hublib_fn_func_recreate_secret_value: (a: number, b: bigint, c: bigint, d: bigint, e: number, f: number, g: bigint, h: bigint, i: number, j: number, k: bigint, l: bigint, m: number, n: number, o: number) => void;
readonly get_secret_value: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
readonly uniffi_hublib_fn_func_recreate_secret_value: (a: number, b: bigint, c: bigint, d: number, e: number, f: bigint, g: bigint, h: number, i: number, j: bigint, k: bigint, l: number, m: number, n: bigint, o: bigint, p: number, q: number, r: number) => void;
readonly uniffi_hublib_checksum_func_recreate_secret_value: () => number;
readonly __wbindgen_export_0: WebAssembly.Table;
readonly __wbindgen_malloc: (a: number, b: number) => number;

View File

@@ -74,25 +74,27 @@ function passStringToWasm0(arg, malloc, realloc) {
return ptr;
}
/**
* @param {bigint} given_time
* @param {string} http_time
* @param {string} user_agent
* @param {string} url
* @returns {string}
*/
export function get_secret_value(given_time, user_agent, url) {
let deferred3_0;
let deferred3_1;
export function get_secret_value(http_time, user_agent, url) {
let deferred4_0;
let deferred4_1;
try {
const ptr0 = passStringToWasm0(user_agent, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const ptr0 = passStringToWasm0(http_time, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ptr1 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const ptr1 = passStringToWasm0(user_agent, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len1 = WASM_VECTOR_LEN;
const ret = wasm.get_secret_value(given_time, ptr0, len0, ptr1, len1);
deferred3_0 = ret[0];
deferred3_1 = ret[1];
const ptr2 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len2 = WASM_VECTOR_LEN;
const ret = wasm.get_secret_value(ptr0, len0, ptr1, len1, ptr2, len2);
deferred4_0 = ret[0];
deferred4_1 = ret[1];
return getStringFromWasm0(ret[0], ret[1]);
} finally {
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
}
}

Binary file not shown.

View File

@@ -58,10 +58,10 @@ export const ffi_hublib_rust_future_poll_void: (a: bigint, b: number, c: bigint)
export const ffi_hublib_rust_future_cancel_void: (a: bigint) => void;
export const ffi_hublib_rust_future_complete_void: (a: bigint, b: number) => void;
export const ffi_hublib_rust_future_free_void: (a: bigint) => void;
export const uniffi_hublib_fn_func_get_secret_value: (a: number, b: bigint, c: bigint, d: bigint, e: number, f: number, g: bigint, h: bigint, i: number, j: number, k: number) => void;
export const uniffi_hublib_fn_func_get_secret_value: (a: number, b: bigint, c: bigint, d: number, e: number, f: bigint, g: bigint, h: number, i: number, j: bigint, k: bigint, l: number, m: number, n: number) => void;
export const uniffi_hublib_checksum_func_get_secret_value: () => number;
export const get_secret_value: (a: bigint, b: number, c: number, d: number, e: number) => [number, number];
export const uniffi_hublib_fn_func_recreate_secret_value: (a: number, b: bigint, c: bigint, d: bigint, e: number, f: number, g: bigint, h: bigint, i: number, j: number, k: bigint, l: bigint, m: number, n: number, o: number) => void;
export const get_secret_value: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
export const uniffi_hublib_fn_func_recreate_secret_value: (a: number, b: bigint, c: bigint, d: number, e: number, f: bigint, g: bigint, h: number, i: number, j: bigint, k: bigint, l: number, m: number, n: bigint, o: bigint, p: number, q: number, r: number) => void;
export const uniffi_hublib_checksum_func_recreate_secret_value: () => number;
export const __wbindgen_export_0: WebAssembly.Table;
export const __wbindgen_malloc: (a: number, b: number) => number;