UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

118 lines • 4.94 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Detections = exports.BaseDetections = void 0; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../core/resource.js"); const pagination_1 = require("../../core/pagination.js"); const path_1 = require("../../internal/utils/path.js"); var BaseDetections = /* @__PURE__ */ (() => { class BaseDetections extends resource_1.APIResource { /** * Create a detection location for credentials that the default scan locations do * not cover, using Rules language expressions such as * `lookup_json_string(http.request.body.raw, "user")`. Only the username * expression is required, and Leaked Credential Checks must be enabled on the * zone. * * @example * ```ts * const detection = * await client.leakedCredentialChecks.detections.create({ * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', * }); * ``` */ create(params, options) { const { zone_id, ...body } = params; return this._client.post((0, path_1.path) `/zones/${zone_id}/leaked-credential-checks/detections`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Update the username and password expressions of an existing detection location, * identified by its detection ID. Both expressions are overwritten, so omitting * the password expression clears it. * * @example * ```ts * const detection = * await client.leakedCredentialChecks.detections.update( * '18a14bafaa8eb1df04ce683ec18c765e', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ update(detectionID, params, options) { const { zone_id, ...body } = params; return this._client.put((0, path_1.path) `/zones/${zone_id}/leaked-credential-checks/detections/${detectionID}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * List the user-defined detection locations configured for Leaked Credential * Checks, each with its own identifier. A custom detection location tells the WAF * where to find the username and password in requests to your application. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const detectionListResponse of client.leakedCredentialChecks.detections.list( * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(params, options) { const { zone_id } = params; return this._client.getAPIList((0, path_1.path) `/zones/${zone_id}/leaked-credential-checks/detections`, (pagination_1.SinglePage), options); } /** * Delete a user-defined detection location, identified by its detection ID. * Incoming requests are then scanned using only the default scan locations and the * detection locations that remain. * * @example * ```ts * const detection = * await client.leakedCredentialChecks.detections.delete( * '18a14bafaa8eb1df04ce683ec18c765e', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(detectionID, params, options) { const { zone_id } = params; return this._client.delete((0, path_1.path) `/zones/${zone_id}/leaked-credential-checks/detections/${detectionID}`, options)._thenUnwrap((obj) => obj.result); } /** * Get the username and password expressions of a single user-defined detection * location, identified by its detection ID. * * @example * ```ts * const detection = * await client.leakedCredentialChecks.detections.get( * '18a14bafaa8eb1df04ce683ec18c765e', * { zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(detectionID, params, options) { const { zone_id } = params; return this._client.get((0, path_1.path) `/zones/${zone_id}/leaked-credential-checks/detections/${detectionID}`, options)._thenUnwrap((obj) => obj.result); } } BaseDetections._key = Object.freeze([ 'leakedCredentialChecks', 'detections', ]); return BaseDetections; })(); exports.BaseDetections = BaseDetections; class Detections extends BaseDetections { } exports.Detections = Detections; //# sourceMappingURL=detections.js.map