@attachmentav/virus-scan-sdk-ts
Version:
An SDK to integrate virus and malware scan capabilities into JavaScript / TypeScript applications. Scan files for viruses, trojans, and other kinds of malware with attachmentAV powered by Sophos.
850 lines (841 loc) • 28.9 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// sdk/index.ts
var index_exports = {};
__export(index_exports, {
AsyncDownloadScanRequestFromJSON: () => AsyncDownloadScanRequestFromJSON,
AsyncDownloadScanRequestFromJSONTyped: () => AsyncDownloadScanRequestFromJSONTyped,
AsyncDownloadScanRequestToJSON: () => AsyncDownloadScanRequestToJSON,
AsyncDownloadScanRequestToJSONTyped: () => AsyncDownloadScanRequestToJSONTyped,
AsyncS3ScanRequestFromJSON: () => AsyncS3ScanRequestFromJSON,
AsyncS3ScanRequestFromJSONTyped: () => AsyncS3ScanRequestFromJSONTyped,
AsyncS3ScanRequestToJSON: () => AsyncS3ScanRequestToJSON,
AsyncS3ScanRequestToJSONTyped: () => AsyncS3ScanRequestToJSONTyped,
AttachmentAVApi: () => AttachmentAVApi,
BASE_PATH: () => BASE_PATH,
BaseAPI: () => BaseAPI,
BlobApiResponse: () => BlobApiResponse,
COLLECTION_FORMATS: () => COLLECTION_FORMATS,
Configuration: () => Configuration,
DefaultConfig: () => DefaultConfig,
FetchError: () => FetchError,
JSONApiResponse: () => JSONApiResponse,
RequiredError: () => RequiredError,
ResponseError: () => ResponseError,
ScanResultFromJSON: () => ScanResultFromJSON,
ScanResultFromJSONTyped: () => ScanResultFromJSONTyped,
ScanResultToJSON: () => ScanResultToJSON,
ScanResultToJSONTyped: () => ScanResultToJSONTyped,
SyncDownloadScanRequestFromJSON: () => SyncDownloadScanRequestFromJSON,
SyncDownloadScanRequestFromJSONTyped: () => SyncDownloadScanRequestFromJSONTyped,
SyncDownloadScanRequestToJSON: () => SyncDownloadScanRequestToJSON,
SyncDownloadScanRequestToJSONTyped: () => SyncDownloadScanRequestToJSONTyped,
SyncS3ScanRequestFromJSON: () => SyncS3ScanRequestFromJSON,
SyncS3ScanRequestFromJSONTyped: () => SyncS3ScanRequestFromJSONTyped,
SyncS3ScanRequestToJSON: () => SyncS3ScanRequestToJSON,
SyncS3ScanRequestToJSONTyped: () => SyncS3ScanRequestToJSONTyped,
TextApiResponse: () => TextApiResponse,
VoidApiResponse: () => VoidApiResponse,
WhoamiFromJSON: () => WhoamiFromJSON,
WhoamiFromJSONTyped: () => WhoamiFromJSONTyped,
WhoamiToJSON: () => WhoamiToJSON,
WhoamiToJSONTyped: () => WhoamiToJSONTyped,
canConsumeForm: () => canConsumeForm,
exists: () => exists,
instanceOfAsyncDownloadScanRequest: () => instanceOfAsyncDownloadScanRequest,
instanceOfAsyncS3ScanRequest: () => instanceOfAsyncS3ScanRequest,
instanceOfScanResult: () => instanceOfScanResult,
instanceOfSyncDownloadScanRequest: () => instanceOfSyncDownloadScanRequest,
instanceOfSyncS3ScanRequest: () => instanceOfSyncS3ScanRequest,
instanceOfWhoami: () => instanceOfWhoami,
mapValues: () => mapValues,
querystring: () => querystring
});
module.exports = __toCommonJS(index_exports);
// sdk/runtime.ts
var BASE_PATH = "https://eu.developer.attachmentav.com/v1".replace(/\/+$/, "");
var Configuration = class {
constructor(configuration = {}) {
this.configuration = configuration;
}
set config(configuration) {
this.configuration = configuration;
}
get basePath() {
return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
}
get fetchApi() {
return this.configuration.fetchApi;
}
get middleware() {
return this.configuration.middleware || [];
}
get queryParamsStringify() {
return this.configuration.queryParamsStringify || querystring;
}
get username() {
return this.configuration.username;
}
get password() {
return this.configuration.password;
}
get apiKey() {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === "function" ? apiKey : () => apiKey;
}
return void 0;
}
get accessToken() {
const accessToken = this.configuration.accessToken;
if (accessToken) {
return typeof accessToken === "function" ? accessToken : async () => accessToken;
}
return void 0;
}
get headers() {
return this.configuration.headers;
}
get credentials() {
return this.configuration.credentials;
}
};
var DefaultConfig = new Configuration();
var BaseAPI = class _BaseAPI {
constructor(configuration = DefaultConfig) {
this.configuration = configuration;
this.middleware = configuration.middleware;
}
static jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
middleware;
withMiddleware(...middlewares) {
const next = this.clone();
next.middleware = next.middleware.concat(...middlewares);
return next;
}
withPreMiddleware(...preMiddlewares) {
const middlewares = preMiddlewares.map((pre) => ({ pre }));
return this.withMiddleware(...middlewares);
}
withPostMiddleware(...postMiddlewares) {
const middlewares = postMiddlewares.map((post) => ({ post }));
return this.withMiddleware(...middlewares);
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
isJsonMime(mime) {
if (!mime) {
return false;
}
return _BaseAPI.jsonRegex.test(mime);
}
async request(context, initOverrides) {
const { url, init } = await this.createFetchParams(context, initOverrides);
const response = await this.fetchApi(url, init);
if (response && (response.status >= 200 && response.status < 300)) {
return response;
}
throw new ResponseError(response, "Response returned an error code");
}
async createFetchParams(context, initOverrides) {
let url = this.configuration.basePath + context.path;
if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
url += "?" + this.configuration.queryParamsStringify(context.query);
}
const headers = Object.assign({}, this.configuration.headers, context.headers);
Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
const initOverrideFn = typeof initOverrides === "function" ? initOverrides : async () => initOverrides;
const initParams = {
method: context.method,
headers,
body: context.body,
credentials: this.configuration.credentials
};
const overriddenInit = {
...initParams,
...await initOverrideFn({
init: initParams,
context
})
};
let body;
if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
body = overriddenInit.body;
} else if (this.isJsonMime(headers["Content-Type"])) {
body = JSON.stringify(overriddenInit.body);
} else {
body = overriddenInit.body;
}
const init = {
...overriddenInit,
body
};
return { url, init };
}
fetchApi = async (url, init) => {
let fetchParams = { url, init };
for (const middleware of this.middleware) {
if (middleware.pre) {
fetchParams = await middleware.pre({
fetch: this.fetchApi,
...fetchParams
}) || fetchParams;
}
}
let response = void 0;
try {
response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
} catch (e) {
for (const middleware of this.middleware) {
if (middleware.onError) {
response = await middleware.onError({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
error: e,
response: response ? response.clone() : void 0
}) || response;
}
}
if (response === void 0) {
if (e instanceof Error) {
throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
} else {
throw e;
}
}
}
for (const middleware of this.middleware) {
if (middleware.post) {
response = await middleware.post({
fetch: this.fetchApi,
url: fetchParams.url,
init: fetchParams.init,
response: response.clone()
}) || response;
}
}
return response;
};
/**
* Create a shallow clone of `this` by constructing a new instance
* and then shallow cloning data members.
*/
clone() {
const constructor = this.constructor;
const next = new constructor(this.configuration);
next.middleware = this.middleware.slice();
return next;
}
};
function isBlob(value) {
return typeof Blob !== "undefined" && value instanceof Blob;
}
function isFormData(value) {
return typeof FormData !== "undefined" && value instanceof FormData;
}
var ResponseError = class extends Error {
constructor(response, msg) {
super(msg);
this.response = response;
}
name = "ResponseError";
};
var FetchError = class extends Error {
constructor(cause, msg) {
super(msg);
this.cause = cause;
}
name = "FetchError";
};
var RequiredError = class extends Error {
constructor(field, msg) {
super(msg);
this.field = field;
}
name = "RequiredError";
};
var COLLECTION_FORMATS = {
csv: ",",
ssv: " ",
tsv: " ",
pipes: "|"
};
function querystring(params, prefix = "") {
return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
}
function querystringSingleKey(key, value, keyPrefix = "") {
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
if (value instanceof Array) {
const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
return `${encodeURIComponent(fullKey)}=${multiValue}`;
}
if (value instanceof Set) {
const valueAsArray = Array.from(value);
return querystringSingleKey(key, valueAsArray, keyPrefix);
}
if (value instanceof Date) {
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
}
if (value instanceof Object) {
return querystring(value, fullKey);
}
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
}
function exists(json, key) {
const value = json[key];
return value !== null && value !== void 0;
}
function mapValues(data, fn) {
const result = {};
for (const key of Object.keys(data)) {
result[key] = fn(data[key]);
}
return result;
}
function canConsumeForm(consumes) {
for (const consume of consumes) {
if ("multipart/form-data" === consume.contentType) {
return true;
}
}
return false;
}
var JSONApiResponse = class {
constructor(raw, transformer = (jsonValue) => jsonValue) {
this.raw = raw;
this.transformer = transformer;
}
async value() {
return this.transformer(await this.raw.json());
}
};
var VoidApiResponse = class {
constructor(raw) {
this.raw = raw;
}
async value() {
return void 0;
}
};
var BlobApiResponse = class {
constructor(raw) {
this.raw = raw;
}
async value() {
return await this.raw.blob();
}
};
var TextApiResponse = class {
constructor(raw) {
this.raw = raw;
}
async value() {
return await this.raw.text();
}
};
// sdk/models/AsyncDownloadScanRequest.ts
function instanceOfAsyncDownloadScanRequest(value) {
if (!("downloadUrl" in value) || value["downloadUrl"] === void 0) return false;
if (!("callbackUrl" in value) || value["callbackUrl"] === void 0) return false;
return true;
}
function AsyncDownloadScanRequestFromJSON(json) {
return AsyncDownloadScanRequestFromJSONTyped(json, false);
}
function AsyncDownloadScanRequestFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"downloadUrl": json["download_url"],
"downloadHeaders": json["download_headers"] == null ? void 0 : json["download_headers"],
"callbackUrl": json["callback_url"],
"callbackHeaders": json["callback_headers"] == null ? void 0 : json["callback_headers"],
"traceId": json["trace_id"] == null ? void 0 : json["trace_id"],
"customData": json["custom_data"] == null ? void 0 : json["custom_data"]
};
}
function AsyncDownloadScanRequestToJSON(json) {
return AsyncDownloadScanRequestToJSONTyped(json, false);
}
function AsyncDownloadScanRequestToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"download_url": value["downloadUrl"],
"download_headers": value["downloadHeaders"],
"callback_url": value["callbackUrl"],
"callback_headers": value["callbackHeaders"],
"trace_id": value["traceId"],
"custom_data": value["customData"]
};
}
// sdk/models/AsyncS3ScanRequest.ts
function instanceOfAsyncS3ScanRequest(value) {
if (!("bucket" in value) || value["bucket"] === void 0) return false;
if (!("key" in value) || value["key"] === void 0) return false;
if (!("callbackUrl" in value) || value["callbackUrl"] === void 0) return false;
return true;
}
function AsyncS3ScanRequestFromJSON(json) {
return AsyncS3ScanRequestFromJSONTyped(json, false);
}
function AsyncS3ScanRequestFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"bucket": json["bucket"],
"key": json["key"],
"version": json["version"] == null ? void 0 : json["version"],
"callbackUrl": json["callback_url"],
"callbackHeaders": json["callback_headers"] == null ? void 0 : json["callback_headers"],
"traceId": json["trace_id"] == null ? void 0 : json["trace_id"],
"customData": json["custom_data"] == null ? void 0 : json["custom_data"]
};
}
function AsyncS3ScanRequestToJSON(json) {
return AsyncS3ScanRequestToJSONTyped(json, false);
}
function AsyncS3ScanRequestToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"bucket": value["bucket"],
"key": value["key"],
"version": value["version"],
"callback_url": value["callbackUrl"],
"callback_headers": value["callbackHeaders"],
"trace_id": value["traceId"],
"custom_data": value["customData"]
};
}
// sdk/models/ScanResult.ts
function instanceOfScanResult(value) {
return true;
}
function ScanResultFromJSON(json) {
return ScanResultFromJSONTyped(json, false);
}
function ScanResultFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"status": json["status"] == null ? void 0 : json["status"],
"finding": json["finding"] == null ? void 0 : json["finding"],
"size": json["size"] == null ? void 0 : json["size"],
"realfiletype": json["realfiletype"] == null ? void 0 : json["realfiletype"]
};
}
function ScanResultToJSON(json) {
return ScanResultToJSONTyped(json, false);
}
function ScanResultToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"status": value["status"],
"finding": value["finding"],
"size": value["size"],
"realfiletype": value["realfiletype"]
};
}
// sdk/models/SyncDownloadScanRequest.ts
function instanceOfSyncDownloadScanRequest(value) {
if (!("downloadUrl" in value) || value["downloadUrl"] === void 0) return false;
return true;
}
function SyncDownloadScanRequestFromJSON(json) {
return SyncDownloadScanRequestFromJSONTyped(json, false);
}
function SyncDownloadScanRequestFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"downloadUrl": json["download_url"],
"downloadHeaders": json["download_headers"] == null ? void 0 : json["download_headers"]
};
}
function SyncDownloadScanRequestToJSON(json) {
return SyncDownloadScanRequestToJSONTyped(json, false);
}
function SyncDownloadScanRequestToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"download_url": value["downloadUrl"],
"download_headers": value["downloadHeaders"]
};
}
// sdk/models/SyncS3ScanRequest.ts
function instanceOfSyncS3ScanRequest(value) {
if (!("bucket" in value) || value["bucket"] === void 0) return false;
if (!("key" in value) || value["key"] === void 0) return false;
return true;
}
function SyncS3ScanRequestFromJSON(json) {
return SyncS3ScanRequestFromJSONTyped(json, false);
}
function SyncS3ScanRequestFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"bucket": json["bucket"],
"key": json["key"],
"version": json["version"] == null ? void 0 : json["version"]
};
}
function SyncS3ScanRequestToJSON(json) {
return SyncS3ScanRequestToJSONTyped(json, false);
}
function SyncS3ScanRequestToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"bucket": value["bucket"],
"key": value["key"],
"version": value["version"]
};
}
// sdk/models/Whoami.ts
function instanceOfWhoami(value) {
return true;
}
function WhoamiFromJSON(json) {
return WhoamiFromJSONTyped(json, false);
}
function WhoamiFromJSONTyped(json, ignoreDiscriminator) {
if (json == null) {
return json;
}
return {
"tenantId": json["tenantId"] == null ? void 0 : json["tenantId"]
};
}
function WhoamiToJSON(json) {
return WhoamiToJSONTyped(json, false);
}
function WhoamiToJSONTyped(value, ignoreDiscriminator = false) {
if (value == null) {
return value;
}
return {
"tenantId": value["tenantId"]
};
}
// sdk/apis/AttachmentAVApi.ts
var AttachmentAVApi = class extends BaseAPI {
/**
* Download a file from a remote location (HTTP/HTTPS), scan the file, and post the scan result to your callback URL.
*/
async scanAsyncDownloadPostRaw(requestParameters, initOverrides) {
if (requestParameters["asyncDownloadScanRequest"] == null) {
throw new RequiredError(
"asyncDownloadScanRequest",
'Required parameter "asyncDownloadScanRequest" was null or undefined when calling scanAsyncDownloadPost().'
);
}
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-api-key"] = await this.configuration.apiKey("x-api-key");
}
if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token("bearerAuth", []);
if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}
let urlPath = `/scan/async/download`;
const response = await this.request({
path: urlPath,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: AsyncDownloadScanRequestToJSON(requestParameters["asyncDownloadScanRequest"])
}, initOverrides);
return new VoidApiResponse(response);
}
/**
* Download a file from a remote location (HTTP/HTTPS), scan the file, and post the scan result to your callback URL.
*/
async scanAsyncDownloadPost(requestParameters, initOverrides) {
await this.scanAsyncDownloadPostRaw(requestParameters, initOverrides);
}
/**
* Download a file from S3, scan the file, and post the scan result to your callback URL. A bucket policy is required to grant attachmentAV access to the S3 objects.
*/
async scanAsyncS3PostRaw(requestParameters, initOverrides) {
if (requestParameters["asyncS3ScanRequest"] == null) {
throw new RequiredError(
"asyncS3ScanRequest",
'Required parameter "asyncS3ScanRequest" was null or undefined when calling scanAsyncS3Post().'
);
}
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-api-key"] = await this.configuration.apiKey("x-api-key");
}
if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token("bearerAuth", []);
if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}
let urlPath = `/scan/async/s3`;
const response = await this.request({
path: urlPath,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: AsyncS3ScanRequestToJSON(requestParameters["asyncS3ScanRequest"])
}, initOverrides);
return new VoidApiResponse(response);
}
/**
* Download a file from S3, scan the file, and post the scan result to your callback URL. A bucket policy is required to grant attachmentAV access to the S3 objects.
*/
async scanAsyncS3Post(requestParameters, initOverrides) {
await this.scanAsyncS3PostRaw(requestParameters, initOverrides);
}
/**
* Upload a file, scan the file, and return the scan result.
*/
async scanSyncBinaryPostRaw(requestParameters, initOverrides) {
if (requestParameters["body"] == null) {
throw new RequiredError(
"body",
'Required parameter "body" was null or undefined when calling scanSyncBinaryPost().'
);
}
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/octet-stream";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-api-key"] = await this.configuration.apiKey("x-api-key");
}
if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token("bearerAuth", []);
if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}
let urlPath = `/scan/sync/binary`;
const response = await this.request({
path: urlPath,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: requestParameters["body"]
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => ScanResultFromJSON(jsonValue));
}
/**
* Upload a file, scan the file, and return the scan result.
*/
async scanSyncBinaryPost(requestParameters, initOverrides) {
const response = await this.scanSyncBinaryPostRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Download a file from a remote location (HTTP/HTTPS), scan the file, and return the scan result.
*/
async scanSyncDownloadPostRaw(requestParameters, initOverrides) {
if (requestParameters["syncDownloadScanRequest"] == null) {
throw new RequiredError(
"syncDownloadScanRequest",
'Required parameter "syncDownloadScanRequest" was null or undefined when calling scanSyncDownloadPost().'
);
}
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-api-key"] = await this.configuration.apiKey("x-api-key");
}
if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token("bearerAuth", []);
if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}
let urlPath = `/scan/sync/download`;
const response = await this.request({
path: urlPath,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: SyncDownloadScanRequestToJSON(requestParameters["syncDownloadScanRequest"])
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => ScanResultFromJSON(jsonValue));
}
/**
* Download a file from a remote location (HTTP/HTTPS), scan the file, and return the scan result.
*/
async scanSyncDownloadPost(requestParameters, initOverrides) {
const response = await this.scanSyncDownloadPostRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* 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.
*/
async scanSyncS3PostRaw(requestParameters, initOverrides) {
if (requestParameters["syncS3ScanRequest"] == null) {
throw new RequiredError(
"syncS3ScanRequest",
'Required parameter "syncS3ScanRequest" was null or undefined when calling scanSyncS3Post().'
);
}
const queryParameters = {};
const headerParameters = {};
headerParameters["Content-Type"] = "application/json";
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-api-key"] = await this.configuration.apiKey("x-api-key");
}
if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token("bearerAuth", []);
if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}
let urlPath = `/scan/sync/s3`;
const response = await this.request({
path: urlPath,
method: "POST",
headers: headerParameters,
query: queryParameters,
body: SyncS3ScanRequestToJSON(requestParameters["syncS3ScanRequest"])
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => ScanResultFromJSON(jsonValue));
}
/**
* 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.
*/
async scanSyncS3Post(requestParameters, initOverrides) {
const response = await this.scanSyncS3PostRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Get information abour yourself.
*/
async whoamiGetRaw(initOverrides) {
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.apiKey) {
headerParameters["x-api-key"] = await this.configuration.apiKey("x-api-key");
}
if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = await token("bearerAuth", []);
if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}
let urlPath = `/whoami`;
const response = await this.request({
path: urlPath,
method: "GET",
headers: headerParameters,
query: queryParameters
}, initOverrides);
return new JSONApiResponse(response, (jsonValue) => WhoamiFromJSON(jsonValue));
}
/**
* Get information abour yourself.
*/
async whoamiGet(initOverrides) {
const response = await this.whoamiGetRaw(initOverrides);
return await response.value();
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
AsyncDownloadScanRequestFromJSON,
AsyncDownloadScanRequestFromJSONTyped,
AsyncDownloadScanRequestToJSON,
AsyncDownloadScanRequestToJSONTyped,
AsyncS3ScanRequestFromJSON,
AsyncS3ScanRequestFromJSONTyped,
AsyncS3ScanRequestToJSON,
AsyncS3ScanRequestToJSONTyped,
AttachmentAVApi,
BASE_PATH,
BaseAPI,
BlobApiResponse,
COLLECTION_FORMATS,
Configuration,
DefaultConfig,
FetchError,
JSONApiResponse,
RequiredError,
ResponseError,
ScanResultFromJSON,
ScanResultFromJSONTyped,
ScanResultToJSON,
ScanResultToJSONTyped,
SyncDownloadScanRequestFromJSON,
SyncDownloadScanRequestFromJSONTyped,
SyncDownloadScanRequestToJSON,
SyncDownloadScanRequestToJSONTyped,
SyncS3ScanRequestFromJSON,
SyncS3ScanRequestFromJSONTyped,
SyncS3ScanRequestToJSON,
SyncS3ScanRequestToJSONTyped,
TextApiResponse,
VoidApiResponse,
WhoamiFromJSON,
WhoamiFromJSONTyped,
WhoamiToJSON,
WhoamiToJSONTyped,
canConsumeForm,
exists,
instanceOfAsyncDownloadScanRequest,
instanceOfAsyncS3ScanRequest,
instanceOfScanResult,
instanceOfSyncDownloadScanRequest,
instanceOfSyncS3ScanRequest,
instanceOfWhoami,
mapValues,
querystring
});
//# sourceMappingURL=index.js.map