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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
ece (CommonJS)
✓ const ece = require('http_ece');
This is the standard CommonJS import pattern. The package is primarily distributed as a CommonJS module.
ece (ES Modules)
✓ import ece from 'http_ece';
✗ import { ece } from 'http_ece';
When using ES Modules, the CommonJS `module.exports` object is imported as the default export. Attempting to destructure `ece` will result in `undefined` for named imports.
encrypt / decrypt methods
✓ import ece from 'http_ece'; ece.encrypt(data, params);
✗ import { encrypt, decrypt } from 'http_ece';
The `encrypt` and `decrypt` functions are methods of the `ece` module object, not named exports from the package root.
This quickstart demonstrates how to encrypt and decrypt a Buffer using the `http_ece` module with randomly generated keys and salts, and then verifies the integrity of the decrypted data.
import ece from 'http_ece';
import { randomBytes } from 'crypto';
import assert from 'assert';
async function runEncryptionExample() {
// Data to be encrypted – a Buffer is expected.
const data = Buffer.from('This is some sensitive data that needs to be encrypted before sending over HTTP. It should be long enough to test the encryption process properly and verify integrity.');
// Generate random keys and salts for encryption parameters. These must be kept secret and shared out-of-band.
const parameters = {
key: randomBytes(16).toString('base64url'), // 16 bytes for a 128-bit key
salt: randomBytes(16).toString('base64url') // 16 bytes for a 128-bit salt
};
console.log('Original Data:', data.toString('utf8'));
console.log('Encryption Parameters (base64url):', parameters);
// Encrypt the data using the generated parameters
const encrypted = ece.encrypt(data, parameters);
console.log('Encrypted Data (Buffer):', encrypted);
// Decrypt the data using the same parameters
const decrypted = ece.decrypt(encrypted, parameters);
console.log('Decrypted Data (Buffer):', decrypted);
// Verify that the decrypted data matches the original data
assert.equal(decrypted.compare(data), 0, 'Decrypted data does not match original!');
console.log('Verification successful: Decrypted data matches original.');
}
runEncryptionExample().catch(console.error);
Errors
Common errors & fixes
TypeError: require is not defined in ES module scope
Attempting to use `require()` in a JavaScript file that is treated as an ES module (e.g., a `.mjs` file or a file in a package with `"type": "module"`).
fixReplace `const ece = require('http_ece');` with `import ece from 'http_ece';` for ES module compatibility. TypeError: Cannot read properties of undefined (reading 'encrypt')
This usually occurs when trying to call `ece.encrypt` after an incorrect ES module import, such as `import { ece } from 'http_ece';`, which would make `ece` undefined or an empty object.
fixEnsure you are using the correct default import for ES modules: `import ece from 'http_ece';`. The CommonJS `module.exports` object is the default export.
Audit
Dependencies
No dependency data recorded yet.