UNPKG

@usewayn/widget

Version:

Client side widget generator for Wayn PoW CAPTCHA.

57 lines (48 loc) 1.2 kB
/** * TypeScript declarations for worker.js * Web Worker for solving proof-of-work challenges */ declare interface WorkerMessage { salt: string; target: string; wasmUrl?: string; } declare interface WorkerResponse { nonce?: number; found: boolean; error?: string; durationMs?: string; } declare interface WorkerGlobalScope { onmessage: ((event: MessageEvent<WorkerMessage>) => void) | null; onerror: ((error: ErrorEvent) => void) | null; postMessage(message: WorkerResponse): void; } declare interface WasmModule { default(): Promise<WasmInstance>; solve_pow?: (salt: string, target: string) => bigint; } declare interface WasmInstance { exports?: { solve_pow: (salt: string, target: string) => bigint; }; } declare var self: WorkerGlobalScope; declare namespace Worker { /** * Fallback solver configuration */ interface FallbackSolver { batchSize: number; encoder: TextEncoder; targetBytes: Uint8Array; targetBytesLength: number; } /** * WASM solver configuration */ interface WasmSolver { wasmCacheUrl: string | undefined; solve_pow_function: ((salt: string, target: string) => bigint) | undefined; } }