diff --git a/cjs/dist/index.d.ts b/cjs/dist/index.d.ts index 996fda5..3f6313a 100644 --- a/cjs/dist/index.d.ts +++ b/cjs/dist/index.d.ts @@ -6,3 +6,10 @@ export declare function solveChallenge(challenge: string, salt: string, algorith controller: AbortController; }; export declare function solveChallengeWorkers(workerScript: string | URL | (() => Worker), concurrency: number, challenge: string, salt: string, algorithm?: string, max?: number, startNumber?: number): Promise; +declare const _default: { + createChallenge: typeof createChallenge; + verifySolution: typeof verifySolution; + solveChallenge: typeof solveChallenge; + solveChallengeWorkers: typeof solveChallengeWorkers; +}; +export default _default; diff --git a/cjs/dist/index.js b/cjs/dist/index.js index 80acd5e..b8544dd 100644 --- a/cjs/dist/index.js +++ b/cjs/dist/index.js @@ -120,3 +120,9 @@ exports.solveChallengeWorkers = solveChallengeWorkers; async function hashChallenge(salt, num, algorithm) { return (0, helpers_js_1.ab2hex)(await crypto.subtle.digest(algorithm.toUpperCase(), helpers_js_1.encoder.encode(salt + num))); } +exports.default = { + createChallenge, + verifySolution, + solveChallenge, + solveChallengeWorkers, +}; diff --git a/deno_dist/README.md b/deno_dist/README.md index cde3a07..48c687a 100644 --- a/deno_dist/README.md +++ b/deno_dist/README.md @@ -4,7 +4,7 @@ ALTCHA JS Library is a lightweight, zero-dependency library designed for creatin ## Compatibility -This library utilizes [Web Crypto](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto) and can be used in modern browsers and supported server environments: +This library utilizes [Web Crypto](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto) and is intended for server-side use. - Node.js 16+ - Bun 1+ @@ -103,18 +103,16 @@ const solution = await solveChallengeWorkers( ``` > solveChallenge() -- n = 1,000............................... 319 ops/s ±2.04% -- n = 10,000.............................. 31 ops/s ±1.02% -- n = 50,000.............................. 6 ops/s ±1.48% -- n = 100,000............................. 3 ops/s ±0.27% -- n = 500,000............................. 0 ops/s ±0.36% +- n = 1,000............................... 317 ops/s ±2.63% +- n = 10,000.............................. 32 ops/s ±1.88% +- n = 100,000............................. 3 ops/s ±0.34% +- n = 500,000............................. 0 ops/s ±0.32% > solveChallengeWorkers() (8 workers) -- n = 1,000............................... 62 ops/s ±5.69% -- n = 10,000.............................. 30 ops/s ±4.35% -- n = 50,000.............................. 12 ops/s ±2.89% -- n = 100,000............................. 7 ops/s ±2.33% -- n = 500,000............................. 1 ops/s ±2.22% +- n = 1,000............................... 66 ops/s ±3.44% +- n = 10,000.............................. 31 ops/s ±4.28% +- n = 100,000............................. 7 ops/s ±4.40% +- n = 500,000............................. 1 ops/s ±2.49% ``` Run with Bun on MacBook Pro M3-Pro. See [/benchmark](/benchmark/) folder for more details. diff --git a/deno_dist/index.ts b/deno_dist/index.ts index 0e4d835..0e4fdde 100644 --- a/deno_dist/index.ts +++ b/deno_dist/index.ts @@ -160,3 +160,10 @@ async function hashChallenge(salt: string, num: number, algorithm: string) { ) ); } + +export default { + createChallenge, + verifySolution, + solveChallenge, + solveChallengeWorkers, +}; diff --git a/dist/index.d.ts b/dist/index.d.ts index 996fda5..3f6313a 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -6,3 +6,10 @@ export declare function solveChallenge(challenge: string, salt: string, algorith controller: AbortController; }; export declare function solveChallengeWorkers(workerScript: string | URL | (() => Worker), concurrency: number, challenge: string, salt: string, algorithm?: string, max?: number, startNumber?: number): Promise; +declare const _default: { + createChallenge: typeof createChallenge; + verifySolution: typeof verifySolution; + solveChallenge: typeof solveChallenge; + solveChallengeWorkers: typeof solveChallengeWorkers; +}; +export default _default; diff --git a/dist/index.js b/dist/index.js index 5433eb2..d9667ee 100644 --- a/dist/index.js +++ b/dist/index.js @@ -113,3 +113,9 @@ export async function solveChallengeWorkers(workerScript, concurrency, challenge async function hashChallenge(salt, num, algorithm) { return ab2hex(await crypto.subtle.digest(algorithm.toUpperCase(), encoder.encode(salt + num))); } +export default { + createChallenge, + verifySolution, + solveChallenge, + solveChallengeWorkers, +}; diff --git a/lib/index.ts b/lib/index.ts index de9d70e..91d5bc3 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -160,3 +160,10 @@ async function hashChallenge(salt: string, num: number, algorithm: string) { ) ); } + +export default { + createChallenge, + verifySolution, + solveChallenge, + solveChallengeWorkers, +};