cloudflare
Version:
The official TypeScript library for the Cloudflare API
143 lines • 5.45 kB
JavaScript
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from "../../core/resource.mjs";
import { buildHeaders } from "../../internal/headers.mjs";
import { path } from "../../internal/utils/path.mjs";
export var BaseScans = /* @__PURE__ */ (() => {
class BaseScans extends APIResource {
/**
* Submit a URL to scan. Check limits at
* https://developers.cloudflare.com/security-center/investigate/scan-limits/.
*
* @example
* ```ts
* const scan = await client.urlScanner.scans.create({
* account_id: 'account_id',
* url: 'https://www.example.com',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post(path `/accounts/${account_id}/urlscanner/v2/scan`, { body, ...options });
}
/**
* Use a subset of ElasticSearch Query syntax to filter scans. Some example
* queries:<br/> <br/>- 'path:"/bundles/jquery.js"': Searches for scans who
* requested resources with the given path.<br/>- 'page.asn:AS24940 AND hash:xxx':
* Websites hosted in AS24940 where a resource with the given hash was
* downloaded.<br/>- 'page.domain:microsoft\* AND verdicts.malicious:true AND NOT
* page.domain:microsoft.com': malicious scans whose hostname starts with
* "microsoft".<br/>- 'apikey:me AND date:[2025-01 TO 2025-02]': my scans from 2025
* January to 2025 February.
*
* @example
* ```ts
* const scans = await client.urlScanner.scans.list({
* account_id: 'account_id',
* });
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.get(path `/accounts/${account_id}/urlscanner/v2/search`, { query, ...options });
}
/**
* Submit URLs to scan. Check limits at
* https://developers.cloudflare.com/security-center/investigate/scan-limits/ and
* take into account scans submitted in bulk have lower priority and may take
* longer to finish.
*
* @example
* ```ts
* const response = await client.urlScanner.scans.bulkCreate({
* account_id: 'account_id',
* });
* ```
*/
bulkCreate(params, options) {
const { account_id, body } = params;
return this._client.post(path `/accounts/${account_id}/urlscanner/v2/bulk`, { body: body, ...options });
}
/**
* Returns a plain text response, with the scan's DOM content as rendered by
* Chrome.
*
* @example
* ```ts
* const response = await client.urlScanner.scans.dom(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: 'account_id' },
* );
* ```
*/
dom(scanID, params, options) {
const { account_id } = params;
return this._client.get(path `/accounts/${account_id}/urlscanner/v2/dom/${scanID}`, {
...options,
headers: buildHeaders([{ Accept: 'text/plain' }, options?.headers]),
});
}
/**
* Get URL scan by uuid
*
* @example
* ```ts
* const scan = await client.urlScanner.scans.get(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: 'account_id' },
* );
* ```
*/
get(scanID, params, options) {
const { account_id } = params;
return this._client.get(path `/accounts/${account_id}/urlscanner/v2/result/${scanID}`, options);
}
/**
* Get a URL scan's HAR file. See HAR spec at
* http://www.softwareishard.com/blog/har-12-spec/.
*
* @example
* ```ts
* const response = await client.urlScanner.scans.har(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: 'account_id' },
* );
* ```
*/
har(scanID, params, options) {
const { account_id } = params;
return this._client.get(path `/accounts/${account_id}/urlscanner/v2/har/${scanID}`, options);
}
/**
* Get scan's screenshot by resolution (desktop/mobile/tablet).
*
* @example
* ```ts
* const response = await client.urlScanner.scans.screenshot(
* '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
* { account_id: 'account_id' },
* );
*
* const content = await response.blob();
* console.log(content);
* ```
*/
screenshot(scanID, params, options) {
const { account_id, ...query } = params;
return this._client.get(path `/accounts/${account_id}/urlscanner/v2/screenshots/${scanID}.png`, {
query,
...options,
headers: buildHeaders([{ Accept: 'image/png' }, options?.headers]),
__binaryResponse: true,
});
}
}
BaseScans._key = Object.freeze([
'urlScanner',
'scans',
]);
return BaseScans;
})();
export class Scans extends BaseScans {
}
//# sourceMappingURL=scans.mjs.map