Deno Support

pompelmi works with Deno via the npm: specifier. No native bindings, no node_modules — Deno resolves the package directly from the npm registry.

pompelmi requires ClamAV to be installed on the host running the Deno process. In TCP mode ({ host, port }), clamd can run anywhere reachable over the network. In local mode, clamscan must be in PATH.

Installation

No explicit installation step is required. Import directly using the npm: specifier:

import { scan, Verdict } from 'npm:pompelmi';

To pin a version, use npm:pompelmi@1.17.0. For an import_map.json:

{
  "imports": {
    "pompelmi": "npm:pompelmi@1.17.0"
  }
}

Basic Usage

Scan a file (local clamscan mode)
import { scan, Verdict } from 'npm:pompelmi';

const result = await scan('./uploads/document.pdf');

if (result === Verdict.Malicious) {
  console.error('Malware detected!');
} else if (result === Verdict.Clean) {
  console.log('File is clean.');
}
Scan via remote clamd (TCP mode)
import { scan, Verdict } from 'npm:pompelmi';

const result = await scan('./uploads/document.pdf', {
  host: 'localhost',
  port: 3310,
});

console.log(result === Verdict.Clean ? 'clean' : 'infected or error');
Scan a Buffer in memory
import { scanBuffer, Verdict } from 'npm:pompelmi';

const data = await Deno.readFile('./uploads/image.jpg');
const result = await scanBuffer(Buffer.from(data), {
  host: 'localhost',
  port: 3310,
});

console.log(result.description); // "Clean", "Malicious", or "ScanError"

HTTP Server Example

Full Deno HTTP server that scans multipart form uploads:

import { scanBuffer, Verdict } from 'npm:pompelmi';

Deno.serve({ port: 8000 }, async (request) => {
  if (request.method !== 'POST') {
    return new Response('POST a file', { status: 405 });
  }

  const formData = await request.formData();
  const file = formData.get('file');

  if (!(file instanceof File)) {
    return new Response('No file uploaded', { status: 400 });
  }

  const buffer = Buffer.from(await file.arrayBuffer());
  const result = await scanBuffer(buffer, {
    host: 'localhost',
    port: 3310,
  });

  if (result === Verdict.Malicious) {
    return new Response('File rejected: malware detected', { status: 422 });
  }
  if (result === Verdict.ScanError) {
    return new Response('Scan error — file rejected', { status: 500 });
  }

  return new Response('File accepted');
});

console.log('Listening on http://localhost:8000');

ESM / deno.json

pompelmi ships a deno.json at the repo root for Deno-native usage. When importing via npm:, Deno handles ESM resolution automatically.

// deno.json (repo root — already included in pompelmi)
{
  "name": "@pompelmi/pompelmi",
  "version": "1.17.0",
  "exports": "./src/index.js"
}

You can also import with the full ESM path:

import pompelmi from 'npm:pompelmi';
const { scan, Verdict } = pompelmi;

Configuration

All ScanOptions work identically in Deno:

OptionTypeDescription
hoststringclamd hostname — enables TCP mode
portnumberclamd port (default: 3310)
socketstringUNIX socket path
timeoutnumberSocket idle timeout in ms (default: 15000)
retriesnumberRetry attempts on connection error (default: 0)
retryDelaynumberDelay between retries in ms (default: 1000)