Skip to main content

Sanitize | Node.js SDK

Sanitize

constructor(token: string, config: PangeaConfig): SanitizeService

Creates a new SanitizeService with the given Pangea API token and configuration.

required parameters

string

Pangea API token.

Configuration.

Response Object

SanitizeService
const config = new PangeaConfig({ domain: "pangea_domain" });
const sanitize = new SanitizeService("pangea_token", config);

Sanitize via presigned URL

requestUploadURL(request: SanitizeRequest): Promise<PangeaResponse<SanitizeResult>>

Apply file sanitization actions according to specified rules via a presigned URL.

required parameters

SanitizeRequest

Request parameters.

Response Object

Promise<PangeaResponse<SanitizeResult>>
const request: Sanitize.SanitizeRequest = {
  transfer_method: TransferMethod.PUT_URL,
  uploaded_file_name: "uploaded_file",
};
const presignedUrl = await sanitize.requestUploadURL(request);

// Upload file to `presignedUrl.accepted_result.put_url`.

// Poll for Sanitize's result.
const response = await sanitize.pollResult<Sanitize.SanitizeResult>(presignedUrl.request_id);

Sanitize

sanitize(request: SanitizeRequest, fileData: FileData, options: Options): Promise<PangeaResponse<SanitizeResult>>

Apply file sanitization actions according to specified rules.

required parameters

SanitizeRequest

Request parameters.

FileData

Optional file data for when the "source-url" transfer method is used.

Options

Additional options.

Response Object

Promise<PangeaResponse<SanitizeResult>>
import { readFile } from "node:fs/promises";

const request: Sanitize.SanitizeRequest = {
  transfer_method: TransferMethod.POST_URL,
  uploaded_file_name: "uploaded_file",
};
const response = await sanitize.sanitize(
  request,
  { file: await readFile("/path/to/file.pdf"), name: "filename" }
);

Interface CDR

CDR

optional parameters

number

Number of file attachments removed.

number

Number of interactive content items removed.

Interface DefangData

DefangData

optional parameters

number

Number of items defanged per provided rules and detections.

string

Processed N Domains: X are malicious, Y are suspicious, Z are unknown.

number

Number of external domains found.

number

Number of external links found.

string

Processed N URLs: X are malicious, Y are suspicious, Z are unknown.

Interface Options

Options

optional parameters

boolean

Interface RedactData

RedactData

optional parameters

Array<RedactRecognizerResult>

The scoring result of a set of rules.

number

Number of items redacted.

Dictionary

Summary counts.

Interface RedactRecognizerResult

RedactRecognizerResult

required parameters

number

The ending index of a snippet.

string

The entity name.

boolean

Indicates if this rule was used to anonymize a text snippet.

number

The certainty score that the entity matches this specific snippet.

number

The starting index of a snippet.

string

The text snippet that matched.

Interface SanitizeContent

SanitizeContent

optional parameters

boolean

Defang external links.

number

Defang risk threshold.

boolean

Perform Domain Intel lookup.

string

Provider to use for Domain Intel lookup.

boolean

Redact sensitive content.

boolean

If redact is enabled, avoids redacting the file and instead returns the PII analysis engine results. Only works if redact is enabled.

boolean

Remove file attachments (PDF only).

boolean

Remove interactive content (PDF only).

boolean

Perform URL Intel lookup.

string

Provider to use for URL Intel.

Interface SanitizeData

SanitizeData

optional parameters

CDR

Content Disarm and Reconstruct.

Defang.

boolean

If the file scanned was malicious.

Redact.

Interface SanitizeFile

SanitizeFile

optional parameters

string

Provider to use for File Scan.

Interface SanitizeRequest

SanitizeRequest

required parameters

TransferMethod

The transfer method used to upload the file data.

optional parameters

Content.

string

The CRC32C hash of the file data, which will be verified by the server if provided.

File.

string

The hexadecimal-encoded SHA256 hash of the file data, which will be verified by the server if provided.

string

A Pangea Secure Share ID where the file to be Sanitized is stored.

Share output.

number

The size (in bytes) of the file. If the upload doesn't match, the call will fail.

string

A URL where the file to be Sanitized can be downloaded.

string

Name of the user-uploaded file, required for transfer-method 'put-url' and 'post-url'.

Interface SanitizeResult

SanitizeResult

required parameters

SanitizeData

Sanitize data.

Dictionary

The parameters, which were passed in the request, echoed back.

optional parameters

string

Pangea Secure Share ID of the Sanitized file.

string

A URL where the Sanitized file can be downloaded.

Interface SanitizeShareOutput

SanitizeShareOutput

optional parameters

boolean

Store Sanitized files to Pangea Secure Share. If not enabled, a presigned URL will be returned in 'result.dest_url'.

string

Store Sanitized files to this Secure Share folder (will be auto-created if not exists).