The `chloride-test` package, currently at version 1.2.4, is a specialized JavaScript utility designed to validate that a given module provides the identical cryptographic functions and API signature as the `chloride` library. It achieves this by generating a comprehensive suite of tests based on the `chloridedown` specification, ensuring adherence to the expected interface. This package is primarily used as a development dependency within projects that aim to offer `chloride`-compatible cryptographic primitives, such as wrappers around `libsodium` via `sodium-browserify` or `sodium-native`. Its core function is to maintain interoperability and correctness across different underlying cryptographic implementations. Given its nature as a testing harness for an API standard, its release cadence is typically slow and focused on stability, reflecting minimal feature changes post-initial API definition. It is essential for developers to verify their modules against the `chloride` standard, ensuring consistent behavior across the ecosystem.
npm install chloride-testVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `chloride-test` to validate a module's API against the `chloride` specification. It shows passing a mock `myCryptoModule` (which would typically be `sodium-browserify` or a custom implementation) to the `chlorideTest` function. The example includes `tape` for context, as `chloride-test` typically integrates with it.
Ensure you have a `chloride`-compatible library (e.g., `sodium-browserify`, `sodium-native`, or `chloride` itself) installed and available to pass to `chloride-test`.
Refer to the `chloride` and `chloridedown` repositories for any breaking changes to the API. Update your tested cryptographic module to match the expected `chloride` interface.
Ensure your testing setup is compatible with CommonJS modules. If using ESM, consider a dynamic `import()` or transpilation if absolutely necessary, but it's best used within its intended CJS context.
Verify that your `someChlorideFunction` is correctly exported by the module you are passing to `chloride-test`. Check the `chloride` API specification to ensure all required functions are present.
Debug the specific cryptographic function (`someFunction`) within your module. Ensure its implementation adheres strictly to the `chloride` specification, particularly regarding input/output formats, key derivations, and algorithm behavior. This often indicates a bug in your cryptographic wrapper.