
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
scryptserver
Advanced tools
A microservice that exposes a scrypt API server to separate computationally expensive hashing from Node.js applications.
This package includes both a server component (ScryptServer) and a client library (ScryptClient) for easy integration.
# Start the server with default configuration
npm run run:server
# Or start with a custom configuration file
npm run run:server -- -c /path/to/config.json
# or
npm run run:server -- --config /path/to/config.json
The server can be configured using a JSON configuration file. By default, it uses these settings:
{
"minWorkers": 2, // Minimum number of worker threads (default: half of CPU cores)
"maxWorkers": 4, // Maximum number of worker threads (default: number of CPU cores)
"logpath": "./log", // Directory for log files (remove to disable logging)
"ip": "127.0.0.1", // IP address to bind
"port": 8001, // Port to listen on
"certificate": null, // Path to SSL certificate file (optional)
"certificateKey": null // Path to SSL certificate key file (optional)
}
Create a custom configuration file and pass it with the -c or --config option to override any of these defaults.
POST /hash
Hashes data using scrypt with configurable parameters.
Request body (JSON):
data (string, required): The data to hash (max 2048 characters)cost (number, required): CPU/memory cost parameter (must be power of 2, range: 4096-524288)blockSize (number, required): Block size parameter (range: 1-16)parallelization (number, required): Parallelization parameter (range: 1-16)saltlen (number, required): Salt length in bytes (range: 16-47)keylen (number, required): Desired key length in bytes (range: 16-271)Example request:
{
"data": "password123",
"cost": 16384,
"blockSize": 8,
"parallelization": 1,
"saltlen": 16,
"keylen": 32
}
Example response:
{
"result": "base64-encoded-hash"
}
POST /compare
Compares data against an existing scrypt hash.
Request body (JSON):
data (string, required): The data to verifyhash (string, required): The base64-encoded hash to compare againstExample request:
{
"data": "password123",
"hash": "base64-encoded-hash"
}
Example response:
{
"result": true
}
The scrypt implementation uses a custom binary format with versioning.
Version 2 is structured as follows:
Version 1 was:
To enable HTTPS, configure the certificate and certificateKey paths in your configuration file:
{
"certificate": "/path/to/cert.pem",
"certificateKey": "/path/to/key.pem"
}
{logpath}/ScryptServer.logThe package includes a TypeScript/JavaScript client library that provides:
npm install scryptserver
import { ScryptClient } from 'scryptserver';
// Initialize the client with default settings
const client = new ScryptClient('http://localhost:8001');
// Or with custom configuration
const client = new ScryptClient(
'http://localhost:8001', // Server URL
{ // Default scrypt parameters
cost: 16384,
blockSize: 8,
parallelization: 1,
saltlen: 16,
keylen: 32
},
undefined, // CA certificate buffer (for HTTPS)
1 // Max local workers for fallback
);
// Hash a password
const hashResult = await client.hash('myPassword');
if (hashResult.result) {
console.log('Hash (base64):', hashResult.result); // string
} else {
console.error('Error:', hashResult.error);
}
// Hash with custom parameters
const customHashResult = await client.hash('myPassword', {
cost: 32768,
blockSize: 8,
parallelization: 1,
saltlen: 18,
keylen: 64
});
// Compare a password using base64 string
const compareResult = await client.compare('myPassword', hashResult.result);
if (compareResult.result !== undefined) {
console.log('Match:', compareResult.result); // boolean
} else {
console.error('Error:', compareResult.error);
}
// Clean up when done
await client.destroy();
The ScryptClient constructor accepts the following parameters:
baseUrl (string): The URL of the scrypt serverdefaultParams (Partial, optional): Default scrypt parameters
cost (default: 16384): CPU/memory cost parameterblockSize (default: 8): Block size parameterparallelization (default: 1): Parallelization parametersaltlen (default: 16): Salt length in byteskeylen (default: 32): Key length in bytescacert (Buffer, optional): CA certificate for HTTPS connectionsmaxConcurrencyFallback (number, default: -1): Maximum worker threads for local fallback
-1: Auto-detect (uses 1/4 of CPU cores, minimum 1)0: Disable fallback completely> 0: Use specified number of workersThe client now includes an intelligent retry mechanism with exponential backoff:
The client uses the following connection timeouts:
The client includes an automatic fallback mechanism:
maxConcurrencyFallback > 0maxConcurrencyFallback to 0 to disable this featureBoth hash and compare methods return an object with either:
result: The successful result (string for hash, boolean for compare)error: An error message if the operation failedAlways check for the presence of error before using result.
ScryptClient constructor parameter order changed:
new ScryptClient(baseUrl, cacert, maxConcurrency, defaultParams)new ScryptClient(baseUrl, defaultParams, cacert, maxConcurrency)Hash method now returns base64 string instead of Buffer:
hash() returned ScryptResponse<Buffer>hash() returns ScryptResponse<string> (base64 encoded)Compare method simplified:
compareFromBase64() methodcompare() now only accepts base64 strings (previously accepted Buffer)Binary format updated with version support:
ScryptParams interface expanded:
saltlen parameter (range: 16-255, default: 16)Based on a my previous project (bcryptServer: https://github.com/stefanobalocco/bcryptServer).
FAQs
Scrypt microservice
We found that scryptserver demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.