diff --git a/web/example.html b/web/example.html index 71c568f..3dd3a68 100644 --- a/web/example.html +++ b/web/example.html @@ -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(); diff --git a/web/hublib.d.ts b/web/hublib.d.ts index 45262c9..77f0d12 100644 --- a/web/hublib.d.ts +++ b/web/hublib.d.ts @@ -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; diff --git a/web/hublib.js b/web/hublib.js index e1e25fd..61dfb2e 100644 --- a/web/hublib.js +++ b/web/hublib.js @@ -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); } } diff --git a/web/hublib_bg.wasm b/web/hublib_bg.wasm index f5fe2e9..2142865 100644 Binary files a/web/hublib_bg.wasm and b/web/hublib_bg.wasm differ diff --git a/web/hublib_bg.wasm.d.ts b/web/hublib_bg.wasm.d.ts index c8b7836..e578956 100644 --- a/web/hublib_bg.wasm.d.ts +++ b/web/hublib_bg.wasm.d.ts @@ -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;