### Run JavaScript ESM Examples Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/README.md Execute the provided ESM scripts after installing the SDK package. ```bash npm i @attachmentav/virus-scan-sdk-ts node sync-download.mjs node sync-binary.mjs node sync-s3.mjs node async-download.mjs node async-download-polling.mjs node async-s3.mjs node async-s3-polling.mjs node verify-callback.mjs # Replace as described in the code. node callback-failures.mjs node whoami.mjs node usage.mjs ``` -------------------------------- ### Install the SDK Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/README.md Install the required package via npm. ```bash npm i @attachmentav/virus-scan-sdk-ts ``` -------------------------------- ### Run JavaScript CommonJS Examples Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/README.md Execute the provided CommonJS scripts after installing the SDK package. ```bash npm i @attachmentav/virus-scan-sdk-ts node sync-download.cjs node sync-binary.cjs node sync-s3.cjs node async-download.cjs node async-download-polling.cjs node async-s3.cjs node async-s3-polling.cjs node verify-callback.cjs # Replace as described in the code. node callback-failures.cjs node whoami.cjs node usage.cjs ``` -------------------------------- ### Run TypeScript Examples Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/README.md Execute the provided TypeScript scripts using tsx after installing the SDK package. ```bash npm i @attachmentav/virus-scan-sdk-ts npx tsx sync-download.ts npx tsx sync-binary.ts npx tsx sync-s3.ts npx tsx async-download.ts npx tsx async-download-polling.ts npx tsx async-s3.ts npx tsx async-s3-polling.ts npx tsx verify-callback.ts # Replace as described in the code. npx tsx callback-failures.ts npx tsx whoami.ts npx tsx usage.ts ``` -------------------------------- ### Run Local SDK Build Commands Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/examples/DEV.md Execute these commands in the project root to build the SDK and prepare the examples directory. ```bash cd ../ npm run build cd examples/ ``` -------------------------------- ### SyncDownloadScanRequest Usage Example Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/SyncDownloadScanRequest.md Demonstrates how to instantiate, serialize, and deserialize a SyncDownloadScanRequest object. ```typescript import type { SyncDownloadScanRequest } from '' // TODO: Update the object below with actual values const example = { "downloadUrl": null, "downloadHeaders": null, } satisfies SyncDownloadScanRequest console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as SyncDownloadScanRequest console.log(exampleParsed) ``` -------------------------------- ### Scan result output format Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/README.md Example of the object returned after a successful scan request. ```text Sync binary scan result: { status: 'clean', finding: undefined, size: 8100, realfiletype: 'ASCII text / 8-bit Unicode Transformation Format' } ``` -------------------------------- ### GET /callback/failures Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/AttachmentAVApi.md Retrieves a list of callback failures, allowing for pagination using a cursor. ```APIDOC ## GET /callback/failures ### Description List callback failures. ### Method GET ### Endpoint /callback/failures ### Parameters #### Query Parameters - **callbackUrl** (string) - Required - URL to receive the scan result via HTTPS POST - **cursor** (string) - Optional - Use the next_cursor value from a previous response to page through failures ### Response #### Success Response (200) - **CallbackFailures** (object) - Success ``` -------------------------------- ### Get Usage Credits and Quota Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/AttachmentAVApi.md Retrieves remaining credits and quota information. Requires configuration with an API key or bearer token. ```ts import { Configuration, AttachmentAVApi, } from ''; import type { UsageGetRequest } from ''; async function example() { console.log("🚀 Testing SDK..."); const config = new Configuration({ // To configure API key authorization: apiKeyAuth apiKey: "YOUR API KEY", // Configure HTTP bearer authorization: bearerAuth accessToken: "YOUR BEARER TOKEN", }); const api = new AttachmentAVApi(config); try { const data = await api.usageGet(); console.log(data); } catch (error) { console.error(error); } } // Run the test example().catch(console.error); ``` -------------------------------- ### Get User Identity Information Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/AttachmentAVApi.md Retrieves information about the authenticated user. Requires configuration with an API key or bearer token. ```ts import { Configuration, AttachmentAVApi, } from ''; import type { WhoamiGetRequest } from ''; async function example() { console.log("🚀 Testing SDK..."); const config = new Configuration({ // To configure API key authorization: apiKeyAuth apiKey: "YOUR API KEY", // Configure HTTP bearer authorization: bearerAuth accessToken: "YOUR BEARER TOKEN", }); const api = new AttachmentAVApi(config); try { const data = await api.whoamiGet(); console.log(data); } catch (error) { console.error(error); } } // Run the test example().catch(console.error); ``` -------------------------------- ### Configure SDK for SaaS Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/README.md Initialize the SDK using an API key and the appropriate regional base path for the SaaS service. ```javascript import { AttachmentAVApi, Configuration } from '@attachmentav/virus-scan-sdk-ts'; const config = new Configuration({ apiKey: '', basePath: '' }); const api = new AttachmentAVApi(config); ``` -------------------------------- ### Configure SDK for self-hosted AWS Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/README.md Initialize the SDK for a self-hosted deployment using an access token and the custom API endpoint domain. ```javascript import { AttachmentAVApi, Configuration } from '@attachmentav/virus-scan-sdk-ts'; const config = new Configuration({ accessToken: '', basePath: '' }); const api = new AttachmentAVApi(config); ``` -------------------------------- ### Publish package to NPM Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/DEV.md Sequence of commands to build, version, push to git, and publish the package to the NPM registry. ```bash npm run build npm version minor git push npm publish --access public ``` -------------------------------- ### Perform a synchronous binary scan Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/README.md Configure the API client and send a file for scanning. Ensure the API key and endpoint are correctly set before execution. ```javascript import { AttachmentAVApi, Configuration } from '@attachmentav/virus-scan-sdk-ts'; import { readFileSync } from 'node:fs'; import { Blob } from 'node:buffer'; const config = new Configuration({ apiKey: '', basePath: '' }); const api = new AttachmentAVApi(config); const scanResult = await api.scanSyncBinaryPost({ body: new Blob([readFileSync('/path/to/file')]) }); console.log('Sync binary scan result:', scanResult); ``` -------------------------------- ### Usage Model Serialization and Deserialization Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/Usage.md Demonstrates how to instantiate a Usage object, convert it to a JSON string, and parse it back into a typed object. ```typescript import type { Usage } from '' // TODO: Update the object below with actual values const example = { "credits": null, "quota": null, } satisfies Usage console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as Usage console.log(exampleParsed) ``` -------------------------------- ### usageGet() Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/README.md Retrieves the remaining credits and quota for the account. ```APIDOC ## usageGet() ### Description Get remaining credits and quota. ### Method SDK Method ### Usage ```javascript const res = await api.usageGet(); console.log('Usage', res); ``` ``` -------------------------------- ### Scan a binary file using scanSyncBinaryPost Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/AttachmentAVApi.md Demonstrates how to configure the API client and perform a synchronous binary scan. Ensure the binary data is provided in the request body. ```ts import { Configuration, AttachmentAVApi, } from ''; import type { ScanSyncBinaryPostRequest } from ''; async function example() { console.log("🚀 Testing SDK..."); const config = new Configuration({ // To configure API key authorization: apiKeyAuth apiKey: "YOUR API KEY", // Configure HTTP bearer authorization: bearerAuth accessToken: "YOUR BEARER TOKEN", }); const api = new AttachmentAVApi(config); const body = { // Blob body: BINARY_DATA_HERE, } satisfies ScanSyncBinaryPostRequest; try { const data = await api.scanSyncBinaryPost(body); console.log(data); } catch (error) { console.error(error); } } // Run the test example().catch(console.error); ``` -------------------------------- ### Initialize and Serialize Whoami in TypeScript Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/Whoami.md Demonstrates how to instantiate a Whoami object, convert it to a JSON string, and parse it back into the typed object. ```typescript import type { Whoami } from '' // TODO: Update the object below with actual values const example = { "tenantId": null, } satisfies Whoami console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as Whoami console.log(exampleParsed) ``` -------------------------------- ### Scan a file via URL using scanSyncDownloadPost Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/AttachmentAVApi.md Demonstrates how to configure the API client with authentication and perform a synchronous scan of a remote file. ```ts import { Configuration, AttachmentAVApi, } from ''; import type { ScanSyncDownloadPostRequest } from ''; async function example() { console.log("🚀 Testing SDK..."); const config = new Configuration({ // To configure API key authorization: apiKeyAuth apiKey: "YOUR API KEY", // Configure HTTP bearer authorization: bearerAuth accessToken: "YOUR BEARER TOKEN", }); const api = new AttachmentAVApi(config); const body = { // SyncDownloadScanRequest syncDownloadScanRequest: ..., } satisfies ScanSyncDownloadPostRequest; try { const data = await api.scanSyncDownloadPost(body); console.log(data); } catch (error) { console.error(error); } } // Run the test example().catch(console.error); ``` -------------------------------- ### UsageQuota instantiation and serialization in TypeScript Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/UsageQuota.md Demonstrates how to define a UsageQuota object, convert it to a JSON string, and parse it back into a typed object. ```typescript import type { UsageQuota } from '' // TODO: Update the object below with actual values const example = { "limit": null, "period": null, } satisfies UsageQuota console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as UsageQuota console.log(exampleParsed) ``` -------------------------------- ### Generate SDK from OpenAPI specification Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/DEV.md Uses the openapi-generator CLI to create the TypeScript fetch SDK from the api.yml file. ```bash openapi-generator generate -i api.yml -g typescript-fetch -o ./sdk ``` -------------------------------- ### Clean SDK directory Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/DEV.md Removes the existing SDK directory to prepare for a fresh generation. ```bash rm -fR sdk ``` -------------------------------- ### Initialize and Serialize AsyncS3ScanRequest Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/AsyncS3ScanRequest.md Demonstrates creating an object that satisfies the AsyncS3ScanRequest interface, converting it to a JSON string, and parsing it back. ```typescript import type { AsyncS3ScanRequest } from '' // TODO: Update the object below with actual values const example = { "bucket": null, "key": null, "version": null, "callbackUrl": null, "callbackHeaders": null, "traceId": null, "customData": null, } satisfies AsyncS3ScanRequest console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as AsyncS3ScanRequest console.log(exampleParsed) ``` -------------------------------- ### Scan a file via URL using scanAsyncDownloadPost Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/AttachmentAVApi.md Initializes the API client with authentication credentials and executes an asynchronous scan request. ```ts import { Configuration, AttachmentAVApi, } from ''; import type { ScanAsyncDownloadPostRequest } from ''; async function example() { console.log("🚀 Testing SDK..."); const config = new Configuration({ // To configure API key authorization: apiKeyAuth apiKey: "YOUR API KEY", // Configure HTTP bearer authorization: bearerAuth accessToken: "YOUR BEARER TOKEN", }); const api = new AttachmentAVApi(config); const body = { // AsyncDownloadScanRequest asyncDownloadScanRequest: ..., } satisfies ScanAsyncDownloadPostRequest; try { const data = await api.scanAsyncDownloadPost(body); console.log(data); } catch (error) { console.error(error); } } // Run the test example().catch(console.error); ``` -------------------------------- ### Instantiate and Serialize AsyncDownloadScanRequest Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/AsyncDownloadScanRequest.md Demonstrates how to create an object satisfying the AsyncDownloadScanRequest interface, convert it to a JSON string, and parse it back. ```typescript import type { AsyncDownloadScanRequest } from '' // TODO: Update the object below with actual values const example = { "downloadUrl": null, "downloadHeaders": null, "callbackUrl": null, "callbackHeaders": null, "traceId": null, "customData": null, } satisfies AsyncDownloadScanRequest console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as AsyncDownloadScanRequest console.log(exampleParsed) ``` -------------------------------- ### Scan S3 Object Synchronously Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/AttachmentAVApi.md Demonstrates how to initialize the AttachmentAVApi client and invoke the scanSyncS3Post method to scan an S3 object. ```ts import { Configuration, AttachmentAVApi, } from ''; import type { ScanSyncS3PostRequest } from ''; async function example() { console.log("🚀 Testing SDK..."); const config = new Configuration({ // To configure API key authorization: apiKeyAuth apiKey: "YOUR API KEY", // Configure HTTP bearer authorization: bearerAuth accessToken: "YOUR BEARER TOKEN", }); const api = new AttachmentAVApi(config); const body = { // SyncS3ScanRequest syncS3ScanRequest: ..., } satisfies ScanSyncS3PostRequest; try { const data = await api.scanSyncS3Post(body); console.log(data); } catch (error) { console.error(error); } } // Run the test example().catch(console.error); ``` -------------------------------- ### scanSyncBinaryPost Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/AttachmentAVApi.md Uploads a file, scans it for viruses, and returns the scan result. ```APIDOC ## scanSyncBinaryPost ### Description Upload a file, scan the file, and return the scan result. ### Method POST ### Parameters #### Request Body - **body** (Blob) - Required - The binary data of the file to be scanned. ### Authorization - apiKeyAuth - bearerAuth ### HTTP Request Headers - **Content-Type**: application/octet-stream - **Accept**: application/json ### Response #### Success Response (200) - **ScanResult** (Object) - The result of the virus scan. ``` -------------------------------- ### Perform an asynchronous URL download scan with callback Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/README.md Submits a URL for scanning and receives the result via a callback URL. Supports files up to 5 GB. ```javascript await api.scanAsyncDownloadPost({ asyncDownloadScanRequest: { downloadUrl: 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf', callbackUrl: 'https://api.yourcompany.com/attachmentav/callback' } }); console.log('Async download submitted'); ``` -------------------------------- ### Perform Async Scan via S3 with Callback Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/README.md Submits an S3 bucket and key for scanning, with results sent to a specified callback URL. Requires a bucket policy to grant access to private objects. ```javascript await api.scanAsyncS3Post({ asyncS3ScanRequest: { bucket: '', key: '', callbackUrl: 'https://api.yourcompany.com/attachmentav/callback' } }); console.log('Async S3 submitted'); ``` -------------------------------- ### whoamiGet() Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/README.md Retrieves information about the current authenticated user. ```APIDOC ## whoamiGet() ### Description Get information about yourself. ### Method SDK Method ### Usage ```javascript const res = await api.whoamiGet(); console.log('Who am I?', res); ``` ``` -------------------------------- ### scanAsyncDownloadPost Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/AttachmentAVApi.md Downloads a file from a remote location, scans it, and posts the result to a callback URL. ```APIDOC ## scanAsyncDownloadPost ### Description Download a file from a remote location (HTTP/HTTPS), scan the file, and post the scan result to your callback URL. ### Method POST ### Parameters - **asyncDownloadScanRequest** (AsyncDownloadScanRequest) - Required - The request object containing the download URL and callback configuration. ### Authorization - apiKeyAuth - bearerAuth ### Response #### Success Response (201) - **Location** (header) - URL to scan result for polling #### Success Response (204) - No content returned ``` -------------------------------- ### scanSyncDownloadPost Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/AttachmentAVApi.md Downloads a file from a remote location (HTTP/HTTPS), scans the file, and returns the scan result. ```APIDOC ## scanSyncDownloadPost ### Description Downloads a file from a remote location (HTTP/HTTPS), scans the file, and returns the scan result. ### Method POST ### Parameters - **syncDownloadScanRequest** (SyncDownloadScanRequest) - Required - The request object containing the download details. ### Return Type ScanResult ### Authorization - apiKeyAuth - bearerAuth ### HTTP Request Headers - **Content-Type**: application/json - **Accept**: application/json ``` -------------------------------- ### Retrieve scan result with scanAsyncResultGet Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/AttachmentAVApi.md Demonstrates how to initialize the API client with authentication and call the scanAsyncResultGet method to fetch scan results. ```ts import { Configuration, AttachmentAVApi, } from ''; import type { ScanAsyncResultGetRequest } from ''; async function example() { console.log("🚀 Testing SDK..."); const config = new Configuration({ // To configure API key authorization: apiKeyAuth apiKey: "YOUR API KEY", // Configure HTTP bearer authorization: bearerAuth accessToken: "YOUR BEARER TOKEN", }); const api = new AttachmentAVApi(config); const body = { // string | ID used when submitting the scan job. traceId: traceId_example, } satisfies ScanAsyncResultGetRequest; try { const data = await api.scanAsyncResultGet(body); console.log(data); } catch (error) { console.error(error); } } // Run the test example().catch(console.error); ``` -------------------------------- ### Scan S3 file asynchronously with TypeScript Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/AttachmentAVApi.md Demonstrates initializing the API client with authentication and invoking the scanAsyncS3Post method. ```ts import { Configuration, AttachmentAVApi, } from ''; import type { ScanAsyncS3PostRequest } from ''; async function example() { console.log("🚀 Testing SDK..."); const config = new Configuration({ // To configure API key authorization: apiKeyAuth apiKey: "YOUR API KEY", // Configure HTTP bearer authorization: bearerAuth accessToken: "YOUR BEARER TOKEN", }); const api = new AttachmentAVApi(config); const body = { // AsyncS3ScanRequest asyncS3ScanRequest: ..., } satisfies ScanAsyncS3PostRequest; try { const data = await api.scanAsyncS3Post(body); console.log(data); } catch (error) { console.error(error); } } // Run the test example().catch(console.error); ``` -------------------------------- ### Perform a synchronous binary file scan Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/README.md Sends a local file to the API for immediate scanning. The file size limit is 10 MB and the request timeout is 60 seconds. ```javascript const scanResult = await api.scanSyncBinaryPost({ body: new Blob([readFileSync('/path/to/file')]) }); console.log('Sync binary scan result:', scanResult); ``` -------------------------------- ### scanAsyncDownloadPost Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/README.md Submits a file URL for asynchronous virus scanning. The service downloads the file and stores the result for 24 hours. ```APIDOC ## scanAsyncDownloadPost ### Description Submits a URL to the attachmentAV Virus Scan API for asynchronous scanning. The file is downloaded and the result is stored for 24 hours. ### Parameters - **asyncDownloadScanRequest** (object) - Required - Contains the downloadUrl and a unique traceId. ``` -------------------------------- ### scanSyncS3Post Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/AttachmentAVApi.md Downloads a file from S3, scans it, and returns the scan result. Requires a bucket policy to grant access to the S3 objects. ```APIDOC ## scanSyncS3Post ### Description Download a file from S3, scan the file, and return the scan result. A bucket policy is required to grant attachmentAV access to the S3 objects. ### Method POST ### Parameters - **syncS3ScanRequest** (SyncS3ScanRequest) - Required - The request object containing S3 scan details. ### Return Type ScanResult ### Authorization - apiKeyAuth - bearerAuth ### HTTP Request Headers - Content-Type: application/json - Accept: application/json ``` -------------------------------- ### scanAsyncS3Post Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/AttachmentAVApi.md Downloads a file from S3, scans it, and posts the result to a callback URL. Requires a bucket policy granting access to the S3 objects. ```APIDOC ## scanAsyncS3Post ### Description Downloads a file from S3, scans the file, and posts the scan result to your callback URL. A bucket policy is required to grant attachmentAV access to the S3 objects. ### Method POST ### Parameters - **asyncS3ScanRequest** (AsyncS3ScanRequest) - Required - The request object containing S3 scan details. ### Authorization - apiKeyAuth - bearerAuth ### Response #### Success Response (201) - **Location** (header) - URL to scan result for polling #### Success Response (204) - Success ``` -------------------------------- ### Initialize and Serialize CallbackFailure in TypeScript Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/CallbackFailure.md Demonstrates how to instantiate a CallbackFailure object, convert it to a JSON string, and parse it back into a typed object. ```typescript import type { CallbackFailure } from '' // TODO: Update the object below with actual values const example = { "id": null, "time": null, "downloadUrl": null, "callbackUrl": null, "errorJson": null, } satisfies CallbackFailure console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as CallbackFailure console.log(exampleParsed) ``` -------------------------------- ### List callback failures with TypeScript Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/AttachmentAVApi.md Demonstrates how to authenticate and call the callbackFailuresGet endpoint to retrieve a list of failed callbacks. ```ts import { Configuration, AttachmentAVApi, } from ''; import type { CallbackFailuresGetRequest } from ''; async function example() { console.log("🚀 Testing SDK..."); const config = new Configuration({ // To configure API key authorization: apiKeyAuth apiKey: "YOUR API KEY", // Configure HTTP bearer authorization: bearerAuth accessToken: "YOUR BEARER TOKEN", }); const api = new AttachmentAVApi(config); const body = { // string | URL to receive the scan result via HTTPS POST callbackUrl: callbackUrl_example, // string | Use the next_cursor value from a previous response to page through failures (optional) cursor: cursor_example, } satisfies CallbackFailuresGetRequest; try { const data = await api.callbackFailuresGet(body); console.log(data); } catch (error) { console.error(error); } } // Run the test example().catch(console.error); ``` -------------------------------- ### Using the ScanResult model in TypeScript Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/ScanResult.md Demonstrates how to instantiate, serialize, and deserialize a ScanResult object. ```typescript import type { ScanResult } from '' // TODO: Update the object below with actual values const example = { "status": null, "finding": null, "size": null, "realfiletype": null, } satisfies ScanResult console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as ScanResult console.log(exampleParsed) ``` -------------------------------- ### Perform Async Scan via S3 with Polling Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/README.md Submits an S3 bucket and key for scanning and polls for the result using a trace ID. Requires a bucket policy for private S3 objects. ```javascript const traceId = crypto.randomUUID(); await api.scanAsyncS3Post({ asyncS3ScanRequest: { bucket: '', key: '', traceId } }); console.log('Async S3 submitted.'); // wait some time... const scanResult = await api.scanAsyncResultGet({ traceId }); console.log('Async download scan result:', scanResult); ``` -------------------------------- ### scanAsyncS3Post Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/README.md Submits an S3 bucket object for asynchronous virus scanning, supporting either callback notification or polling. ```APIDOC ## scanAsyncS3Post ### Description Submits an S3 bucket name and object key for virus scanning. Requires a bucket policy to grant access to private objects. ### Parameters - **asyncS3ScanRequest** (object) - Required - Contains the bucket, key, and either a callbackUrl or a traceId for polling. ``` -------------------------------- ### Usage of CallbackFailures in TypeScript Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/CallbackFailures.md Demonstrates how to instantiate, serialize, and deserialize a CallbackFailures object. ```typescript import type { CallbackFailures } from '' // TODO: Update the object below with actual values const example = { "failures": null, "nextCursor": null, } satisfies CallbackFailures console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as CallbackFailures console.log(exampleParsed) ``` -------------------------------- ### Retrieve usage statistics Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/README.md Fetches remaining credits and quota information. This operation is not supported by the self-hosted AWS version. ```javascript const res = await api.usageGet(); console.log('Usage', res); ``` -------------------------------- ### Perform a synchronous S3 object scan Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/README.md Sends an S3 bucket and object key to the API for immediate scanning. Requires a bucket policy to grant access to private objects. ```javascript const scanResult = await api.scanSyncS3Post({ syncS3ScanRequest: { bucket: '', key: '' } }); console.log('Sync S3 scan result:', scanResult); ``` -------------------------------- ### Perform Async Scan via URL with Polling Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/README.md Submits a file URL for scanning and polls for the result using a trace ID. The scan result is stored for 24 hours. ```javascript const traceId = crypto.randomUUID(); await api.scanAsyncDownloadPost({ asyncDownloadScanRequest: { downloadUrl: 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf', traceId } }); console.log('Async download submitted.'); // wait some time... const scanResult = await api.scanAsyncResultGet({ traceId }); console.log('Async download scan result:', scanResult); ``` -------------------------------- ### SyncS3ScanRequest TypeScript Usage Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/sdk/docs/SyncS3ScanRequest.md Demonstrates how to define, serialize, and deserialize a SyncS3ScanRequest object. Ensure the import path is updated to the correct SDK location. ```typescript import type { SyncS3ScanRequest } from '' // TODO: Update the object below with actual values const example = { "bucket": null, "key": null, "version": null, } satisfies SyncS3ScanRequest console.log(example) // Convert the instance to a JSON string const exampleJSON: string = JSON.stringify(example) console.log(exampleJSON) // Parse the JSON string back to an object const exampleParsed = JSON.parse(exampleJSON) as SyncS3ScanRequest console.log(exampleParsed) ``` -------------------------------- ### Perform a synchronous URL download scan Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/README.md Sends a URL to the API for immediate download and scanning. The file size limit is 10 MB and the request timeout is 60 seconds. ```javascript const scanResult = await api.scanSyncDownloadPost({ syncDownloadScanRequest: { downloadUrl: 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf' } }); console.log('Sync download scan result:', scanResult); ``` -------------------------------- ### List Callback Failures Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/README.md Retrieves a list of callback failures for a specific URL, sorted by time in descending order. Failures are retained for 30 days. ```javascript const res = await api.callbackFailuresGet({ callbackUrl: 'https://api.yourcompany.com/attachmentav/callback' }); console.log('Callback failures', res); ``` -------------------------------- ### callbackFailuresGet Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/README.md Lists recent callback failures for a specific callback URL. ```APIDOC ## callbackFailuresGet ### Description Retrieves a list of callback failures that prevented the API from invoking the defined callback URL, sorted by time descending. ### Parameters - **callbackUrl** (string) - Required - The URL for which to retrieve failure logs. ``` -------------------------------- ### Retrieve account information Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/README.md Fetches identity information for the current API user. This operation is not supported by the self-hosted AWS version. ```javascript const res = await api.whoamiGet(); console.log('Who am I?', res); ``` -------------------------------- ### scanAsyncResultGet Source: https://github.com/widdix/attachmentav-sdk-ts/blob/main/README.md Retrieves the result of an asynchronous scan job using a trace ID. ```APIDOC ## scanAsyncResultGet ### Description Fetches the scan result for a previously submitted asynchronous job using the traceId. ### Parameters - **traceId** (string) - Required - The unique identifier for the scan job. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.