Registry / testing / chloride-test

chloride-test

JSON →
library1.2.4jsnpmunverified

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-test
INSTALL
IMPORT
SIG · CHLORIDE-TEST
C
chloride-test
testingjavascriptv1.2.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

chlorideTest
const chlorideTest = require('chloride-test')
import chlorideTest from 'chloride-test'
This package is primarily a CommonJS module and should be imported using `require()`.
runTests
require('chloride-test')(someCryptoModule)
const runTests = require('chloride-test').runTests
The `chloride-test` package exports a function directly, which takes the module to be tested as an argument.

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.

const test = require('tape'); const chlorideTest = require('chloride-test'); // A mock or actual chloride-compatible module, e.g., require('sodium-browserify') const myCryptoModule = { randombytes: (size, cb) => { if (cb) return cb(null, Buffer.alloc(size)); return Buffer.alloc(size); }, // ... other chloride API methods like `sign`, `verify`, `box`, `open`, etc. // For a real test, 'sodium-browserify' or a similar library would be used here. box: (message, nonce, pk, sk) => Buffer.from('mocked_box_output'), open: (ciphertext, nonce, pk, sk) => Buffer.from('mocked_open_output'), sign: (message, sk) => Buffer.from('mocked_signature'), verify: (signature, message, pk) => true, // ... all other expected chloride functions }; test('myCryptoModule implements chloride API correctly', (t) => { chlorideTest(myCryptoModule, { // Optionally pass in custom options, or let chloride-test generate all possible tests filter: (name) => name.startsWith('randombytes') || name.startsWith('box'), // 'filter' allows running a subset of tests if the full suite is too long or specific }); // To ensure tape finishes, you might want to call t.end() if chlorideTest doesn't handle it. // In practice, chlorideTest often integrates with tape to manage its own assertions and ending. // For this example, we assume chlorideTest will run its assertions and implicitly manage tape's flow. t.pass('chloride-test suite initiated. Check console for detailed test results.'); // For an actual integration, `chloride-test` would drive the `tape` tests itself. });
Debug
Known issues
gotchaThe `chloride-test` package is purely a testing utility and does not provide any cryptographic functions itself. It requires you to pass in a separate module that implements the `chloride` API.
fix
Ensure you have a `chloride`-compatible library (e.g., `sodium-browserify`, `sodium-native`, or `chloride` itself) installed and available to pass to `chloride-test`.
affects: >=1.0.0
breakingAPI changes in `chloride` or `chloridedown` (the test generation source) may cause `chloride-test` to fail or produce incorrect results if the tested module is not updated accordingly. `chloride-test` assumes the `chloride` API defined by its `chloridedown` dependency.
fix
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.
affects: >=1.0.0
gotchaThis package is designed for Node.js environments and uses CommonJS modules. Direct use in browser environments or modern ESM-only Node.js projects without a CJS wrapper or bundler might lead to import errors.
fix
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.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: module.someChlorideFunction is not a function
The module being tested does not export a function that `chloride-test` expects as part of the `chloride` API.
fix
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.
Assertion failed: Expected X but got Y for chloride.someFunction
The cryptographic function in the module being tested produced an output that does not match the expected `chloride` behavior for a given input.
fix
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.
Upgrade
Version history
1.2.4latest on npm
Audit
Dependencies
taperequiredUsed as the underlying test runner for generated tests.
debugrequiredProvides conditional logging for debugging test execution.
through2requiredPotentially used internally for stream manipulation, common in dominictarr's work.
Agent activity
17 hits · last 30 days
node
14
Amazon
1
OpenAI (training)
1
Resources
chloride-test — npm install chloride-test · libregistry