Powerful response decryption wrapper for @xcrap clients. Automatically decrypts encrypted HTTP response bodies using standard algorithms.
- Automatic Decryption: Wraps any
@xcrapclient to decrypt responses on the fly. - Flexible Configuration: Supports multiple algorithms, encodings, and key/IV formats.
- Factory Pattern: Easy integration using the
DecryptorClientfactory. - Standard Crypto: Uses Node.js
node:cryptounder the hood.
npm install @xcrap/decryptorYou can wrap an existing client instance to add decryption capabilities.
import { AxiosClient } from '@xcrap/axios-client';
import { injectDecryptor } from '@xcrap/decryptor';
const baseClient = new AxiosClient();
const client = injectDecryptor(baseClient, {
algorithm: 'aes-256-cbc',
inputEncoding: 'base64',
outputEncoding: 'utf8',
key: { encoding: 'utf8', value: 'your-32-character-secret-key-!!' },
iv: { encoding: 'utf8', value: 'your-16-char-iv!' }
});
// All fetch and fetchMany calls will now automatically decrypt the response body
const response = await client.fetch({ url: '...' });
console.log(response.body); // Decrypted contentPerfect for class-based architectures.
import { AxiosClient } from '@xcrap/axios-client';
import { DecryptorClient } from '@xcrap/decryptor';
const DecryptedAxios = DecryptorClient(AxiosClient, {
algorithm: 'aes-256-cbc',
inputEncoding: 'base64',
outputEncoding: 'utf8',
key: { encoding: 'hex', value: '...' },
iv: { encoding: 'hex', value: '...' }
});
const client = new DecryptedAxios();The DecryptConfig object supports:
| Field | Type | Description |
|---|---|---|
algorithm |
string |
Crypto algorithm (e.g., aes-256-cbc) |
inputEncoding |
BufferEncoding |
Encoding of the encrypted response body |
outputEncoding |
BufferEncoding |
Desired encoding for the decrypted result |
key |
Object |
{ encoding, value } for the secret key |
iv |
Object |
{ encoding, value } for the initialization vector |
MIT © Marcuth