Compare commits

..

No commits in common. "master" and "v1.2.0" have entirely different histories.

4 changed files with 8 additions and 22 deletions

View File

@ -1,11 +1,5 @@
# Changelog # Changelog
## 2025-02-05 - 1.3.0 - feat(ClamAvService)
Add support for enhanced streaming methods in ClamAvService
- Add methods to ClamAvService: scanStream for NodeJS streams, scanWebStream for Web API streams, and scanFileFromWebAsStream for fetching and scanning files from URLs.
- Update usage examples in readme for new streaming methods.
## 2025-02-05 - 1.2.0 - feat(ClamAvService) ## 2025-02-05 - 1.2.0 - feat(ClamAvService)
Add stream scanning methods to ClamAvService Add stream scanning methods to ClamAvService

View File

@ -1,6 +1,6 @@
{ {
"name": "@push.rocks/smartantivirus", "name": "@push.rocks/smartantivirus",
"version": "1.3.0", "version": "1.2.0",
"private": false, "private": false,
"description": "A Node.js package for integrating antivirus scanning capabilities using ClamAV, allowing in-memory file and data scanning.", "description": "A Node.js package for integrating antivirus scanning capabilities using ClamAV, allowing in-memory file and data scanning.",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",

View File

@ -96,11 +96,10 @@ main().catch(console.error);
### Streaming Scanning ### Streaming Scanning
The `ClamAvService` supports scanning both NodeJS streams and Web API streams using three specialized methods: The `ClamAvService` now also supports scanning streams directly using two new methods:
- `scanStream(stream: NodeJS.ReadableStream)`: Scans any NodeJS readable stream (files, network, etc.) - `scanStream(stream: NodeJS.ReadableStream)`: Scans a NodeJS stream (local file streams, network streams, etc.)
- `scanWebStream(webstream: ReadableStream)`: Scans a Web API ReadableStream - `scanWebStream(url: string)`: Fetches a web resource as a stream and scans it
- `scanFileFromWebAsStream(url: string)`: Fetches and scans a file from a URL using NodeJS http/https
#### Example Usage #### Example Usage
@ -111,21 +110,14 @@ import { createReadStream } from 'fs';
async function main() { async function main() {
const clamService = new ClamAvService('127.0.0.1', 3310); const clamService = new ClamAvService('127.0.0.1', 3310);
// Example 1: Scanning a local file stream (NodeJS) // Example 1: Scanning a local file stream
const fileStream = createReadStream('path/to/local/file'); const fileStream = createReadStream('path/to/local/file');
const streamResult = await clamService.scanStream(fileStream); const streamResult = await clamService.scanStream(fileStream);
console.log('Stream Scan Result:', streamResult); console.log('Stream Scan Result:', streamResult);
// Example 2: Scanning a web resource using NodeJS http/https // Example 2: Scanning a web resource
const webResult = await clamService.scanFileFromWebAsStream('http://example.com/file'); const webResult = await clamService.scanWebStream('http://example.com/file');
console.log('Web Stream Scan Result:', webResult); console.log('Web Stream Scan Result:', webResult);
// Example 3: Scanning a Web API ReadableStream
const response = await fetch('http://example.com/file');
if (response.body) {
const webStreamResult = await clamService.scanWebStream(response.body);
console.log('Web Stream API Scan Result:', webStreamResult);
}
} }
main().catch(console.error); main().catch(console.error);

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@push.rocks/smartantivirus', name: '@push.rocks/smartantivirus',
version: '1.3.0', version: '1.2.0',
description: 'A Node.js package for integrating antivirus scanning capabilities using ClamAV, allowing in-memory file and data scanning.' description: 'A Node.js package for integrating antivirus scanning capabilities using ClamAV, allowing in-memory file and data scanning.'
} }