Skip to content

Add async support for argon2id#7

Open
rodrigo-speller wants to merge 4 commits into
openpgpjs:mainfrom
rodrigo-speller:async-support
Open

Add async support for argon2id#7
rodrigo-speller wants to merge 4 commits into
openpgpjs:mainfrom
rodrigo-speller:async-support

Conversation

@rodrigo-speller

Copy link
Copy Markdown

This pull request introduces asynchronous, non-blocking support to the Argon2id hashing implementation, allowing hash computations to yield to the event loop and avoid blocking the main thread. It adds a new async option (with configurable yieldResolution) to both the library API and WASM loader, updates documentation, and provides comprehensive tests to verify async behavior.

Key changes include:

Async Argon2id support:

  • Added an async option to the argon2id function, enabling Promise-based, non-blocking hashing with control over yielding frequency via yieldResolution. The async logic is implemented by splitting the core algorithm into a generator and providing both sync and async runners. (lib/argon2id.js, README.md) [1] [2] [3] [4]
  • Updated the WASM loader (setupWasm) and its consumers to accept and propagate async options, ensuring async configuration is available throughout the stack. (lib/setup.js, index.js, test/helpers/node-loader.ts) [1] [2] [3] [4]

Documentation and testing:

  • Expanded the README.md with usage instructions and examples for the async API, including details on the async and yieldResolution options.
  • Added new tests to verify async hashing correctness, yielding behavior, and configuration, ensuring the async implementation yields as expected and returns correct results. (test/argon2id.spec.ts) [1] [2] [3] [4]

Other improvements:

  • Updated parameter validation and context setup to support async options and defaults. [1] [2]

These changes make the Argon2id implementation suitable for browser and Node.js environments where blocking the main thread is undesirable, and provide a robust, configurable async interface.

@rodrigo-speller

Copy link
Copy Markdown
Author

#6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant