Implement progress bar in CAPTCHA widget. #8

Closed
opened 2023-02-13 15:14:31 +05:30 by realaravinth · 4 comments
Owner
No description provided.
realaravinth added this to the 2023 project 2023-02-13 15:14:31 +05:30
Author
Owner

Implement PoW progress notification: the method that generates PoW returns early after a configurable number of hash computations. This can be used to roughly indicate progress while waiting for a PoW to complete.

mCaptcha/pow_sha256#4

Publish 0.5.0: https://crates.io/crates/mcaptcha_pow_sha256/0.5.0

Implement PoW progress notification: the method that generates PoW returns early after a configurable number of hash computations. This can be used to roughly indicate progress while waiting for a PoW to complete. https://git.batsense.net/mCaptcha/pow_sha256/pulls/4 Publish 0.5.0: https://crates.io/crates/mcaptcha_pow_sha256/0.5.0
Author
Owner

Uses mcaptcha_pow_sha256 to build an opinionated WASM interface. This change implements the PoW progress notification implemented inmcaptcha_pow_sha256@v0.5.0.

pow_wasm is run in a service worker by mCaptcha/mCaptcha. To show progress, WASM must notify service worker, which in turn must notify the parent page to update DOM to reflect progress. The current implementation accepts a JavaScript callback function, which can be defined in the service worker. The callback function can pass message to parent page to update DOM.

PR: https://github.com/mCaptcha/pow_wasm/pull/2
Published: https://www.npmjs.com/package/@mcaptcha/pow-wasm/v/0.1.0-rc2

Uses `mcaptcha_pow_sha256` to build an opinionated WASM interface. This change implements the PoW progress notification implemented in`mcaptcha_pow_sha256@v0.5.0`. `pow_wasm` is run in a service worker by mCaptcha/mCaptcha. To show progress, WASM must notify service worker, which in turn must notify the parent page to update DOM to reflect progress. The current implementation accepts a JavaScript callback function, which can be defined in the service worker. The callback function can pass message to parent page to update DOM. PR: https://github.com/mCaptcha/pow_wasm/pull/2 Published: https://www.npmjs.com/package/@mcaptcha/pow-wasm/v/0.1.0-rc2
Author
Owner

Same as the WASM implementation, runs in service worker and has to update DOM to inform progress. Also implements progress notification through callback function.

PR: https://github.com/mCaptcha/pow_sha256-polyfill/pull/16
Published: https://www.npmjs.com/package/@mcaptcha/pow_sha256-polyfill/v/0.1.0-rc2

Same as the WASM implementation, runs in service worker and has to update DOM to inform progress. Also implements progress notification through callback function. PR: https://github.com/mCaptcha/pow_sha256-polyfill/pull/16 Published: https://www.npmjs.com/package/@mcaptcha/pow_sha256-polyfill/v/0.1.0-rc2
Author
Owner

Progress bar is tricky, because Proof-of-Work of the same difficulty level sometimes requires more number of hashes (nonce = number of hashes in mCaptcha). So tracking/predicting progress is difficult.

This PR introduces changes to track maximum nonce encountered for every captcha configuration. This data is included in the PoW config fetch, and is used by the progress bar generation bit to compute progress by:

progress = (current_nonce / max_recorded_nonce) * 100

which is the best I could come up with 😓

PR: https://github.com/mCaptcha/mCaptcha/pull/118

Progress bar is tricky, because Proof-of-Work of the same difficulty level sometimes requires more number of hashes (`nonce` = number of hashes in mCaptcha). So tracking/predicting progress is difficult. This PR introduces changes to track maximum `nonce` encountered for every captcha configuration. This data is included in the PoW config fetch, and is used by the progress bar generation bit to compute progress by: ``` progress = (current_nonce / max_recorded_nonce) * 100 ``` which is the best I could come up with :sweat: PR: https://github.com/mCaptcha/mCaptcha/pull/118
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mCaptcha/2023-NLnet#8
No description provided.