UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

308 lines • 9.93 kB
import { APIResource } from "../../../../core/resource.mjs"; import * as LiveViewAPI from "./live-view.mjs"; import { BaseLiveView, LiveView, LiveViewCreateParams, LiveViewCreateResponse } from "./live-view.mjs"; import * as PageAPI from "./page.mjs"; import { BasePage, Page, PageGetParams } from "./page.mjs"; import * as TargetsAPI from "./targets.mjs"; import { BaseTargets, TargetActivateParams, TargetActivateResponse, TargetCloseParams, TargetCloseResponse, TargetCreateParams, TargetCreateResponse, TargetGetParams, TargetGetResponse, TargetListParams, TargetListResponse, Targets } from "./targets.mjs"; import { APIPromise } from "../../../../core/api-promise.mjs"; import { RequestOptions } from "../../../../internal/request-options.mjs"; export declare class BaseBrowser extends APIResource { static readonly _key: readonly ['browserRendering', 'devtools', 'browser']; /** * Acquires a browser and returns its session ID and websocket URL. Optionally * accepts a JSON body with session guardrails to restrict outbound HTTP/S traffic. * * @example * ```ts * const browser = * await client.browserRendering.devtools.browser.create({ * account_id: 'account_id', * }); * ``` */ create(params: BrowserCreateParams, options?: RequestOptions): APIPromise<BrowserCreateResponse>; /** * Closes an existing browser session. * * @example * ```ts * const browser = * await client.browserRendering.devtools.browser.delete( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * { account_id: 'account_id' }, * ); * ``` */ delete(sessionID: string, params: BrowserDeleteParams, options?: RequestOptions): APIPromise<BrowserDeleteResponse>; /** * Establishes a WebSocket connection to an existing browser session. * * @example * ```ts * await client.browserRendering.devtools.browser.connect( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * { account_id: 'account_id' }, * ); * ``` */ connect(sessionID: string, params: BrowserConnectParams, options?: RequestOptions): APIPromise<void>; /** * Acquires and establishes a WebSocket connection to a browser session. Session * guardrails may be supplied in the `cf-brapi-guardrails` header as * base64url-encoded JSON of the same `guardrails` object the POST body accepts * (for example `{"allowedDomains":["*.example.com"]}`). * * @example * ```ts * await client.browserRendering.devtools.browser.launch({ * account_id: 'account_id', * }); * ``` */ launch(params: BrowserLaunchParams, options?: RequestOptions): APIPromise<void>; /** * Returns the complete Chrome DevTools Protocol schema including all domains, * commands, events, and types. This schema describes the entire CDP API surface. * * @example * ```ts * const response = * await client.browserRendering.devtools.browser.protocol( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * { account_id: 'account_id' }, * ); * ``` */ protocol(sessionID: string, params: BrowserProtocolParams, options?: RequestOptions): APIPromise<BrowserProtocolResponse>; /** * Get browser version metadata. * * @example * ```ts * const response = * await client.browserRendering.devtools.browser.version( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * { account_id: 'account_id' }, * ); * ``` */ version(sessionID: string, params: BrowserVersionParams, options?: RequestOptions): APIPromise<BrowserVersionResponse>; } export declare class Browser extends BaseBrowser { liveView: LiveViewAPI.LiveView; page: PageAPI.Page; targets: TargetsAPI.Targets; } export interface BrowserCreateResponse { /** * Browser session ID. */ sessionId: string; /** * WebSocket URL for the session. */ webSocketDebuggerUrl?: string; } export interface BrowserDeleteResponse { status: 'closing' | 'closed'; } export interface BrowserProtocolResponse { /** * List of protocol domains. */ domains: Array<BrowserProtocolResponse.Domain>; /** * Protocol version. */ version?: BrowserProtocolResponse.Version; } export declare namespace BrowserProtocolResponse { interface Domain { /** * Domain name. */ domain: string; /** * Available commands. */ commands?: Array<{ [key: string]: unknown; }>; /** * Domain dependencies. */ dependencies?: Array<string>; /** * Available events. */ events?: Array<{ [key: string]: unknown; }>; /** * Whether this domain is experimental. */ experimental?: boolean; /** * Type definitions. */ types?: Array<{ [key: string]: unknown; }>; } /** * Protocol version. */ interface Version { /** * Major version. */ major: string; /** * Minor version. */ minor: string; } } export interface BrowserVersionResponse { /** * Browser name and version. */ Browser: string; /** * Chrome DevTools Protocol version. */ 'Protocol-Version': string; /** * User agent string. */ 'User-Agent': string; /** * V8 JavaScript engine version. */ 'V8-Version': string; /** * WebKit version. */ 'WebKit-Version': string; /** * WebSocket URL for debugging the browser. */ webSocketDebuggerUrl: string; } export interface BrowserCreateParams { /** * Path param: Account ID. */ account_id: string; /** * Query param: Keep-alive time in milliseconds. */ keep_alive?: number; /** * Query param: Use experimental browser. */ lab?: boolean; /** * Query param: How long the live view URL remains valid, in milliseconds (max 60 * minutes). Only used when targets is true. */ liveViewUrlExpiresInMs?: number; /** * Query param */ recording?: boolean; /** * Query param: Include browser targets in response. */ targets?: boolean; /** * Body param */ guardrails?: BrowserCreateParams.Guardrails; } export declare namespace BrowserCreateParams { interface Guardrails { /** * Hostname patterns, max 50. Supports exact hosts (example.com) or a single _ * wildcard anywhere. Prefer _.example.com (subdomain wildcard) over \*example.com * (prefix wildcard) to avoid matching overbroad lookalikes like evilexample.com. */ allowedDomains?: Array<string>; /** * Max 4 entries: curated preset names (common-cdns) and/or https URLs of * newline-separated hostname lists. */ allowedDomainSets?: Array<string>; } } export interface BrowserDeleteParams { /** * Account ID. */ account_id: string; } export interface BrowserConnectParams { /** * Path param: Account ID. */ account_id: string; /** * Query param: Keep-alive time in ms (only valid when acquiring new session). */ keep_alive?: number; /** * Query param: Use experimental browser. */ lab?: boolean; /** * Query param */ recording?: boolean; /** * Header param: Optional base64url-encoded JSON connection guardrails (mode) */ 'cf-brapi-guardrails'?: string; } export interface BrowserLaunchParams { /** * Path param: Account ID. */ account_id: string; /** * Query param: Keep-alive time in ms (only valid when acquiring new session). */ keep_alive?: number; /** * Query param: Use experimental browser. */ lab?: boolean; /** * Query param */ recording?: boolean; /** * Header param: Optional base64url-encoded JSON session guardrails (allowedDomains * and allowedDomainSets) */ 'cf-brapi-guardrails'?: string; } export interface BrowserProtocolParams { /** * Account ID. */ account_id: string; } export interface BrowserVersionParams { /** * Account ID. */ account_id: string; } export declare namespace Browser { export { type BrowserCreateResponse as BrowserCreateResponse, type BrowserDeleteResponse as BrowserDeleteResponse, type BrowserProtocolResponse as BrowserProtocolResponse, type BrowserVersionResponse as BrowserVersionResponse, type BrowserCreateParams as BrowserCreateParams, type BrowserDeleteParams as BrowserDeleteParams, type BrowserConnectParams as BrowserConnectParams, type BrowserLaunchParams as BrowserLaunchParams, type BrowserProtocolParams as BrowserProtocolParams, type BrowserVersionParams as BrowserVersionParams, }; export { LiveView as LiveView, BaseLiveView as BaseLiveView, type LiveViewCreateResponse as LiveViewCreateResponse, type LiveViewCreateParams as LiveViewCreateParams, }; export { Page as Page, BasePage as BasePage, type PageGetParams as PageGetParams }; export { Targets as Targets, BaseTargets as BaseTargets, type TargetCreateResponse as TargetCreateResponse, type TargetListResponse as TargetListResponse, type TargetActivateResponse as TargetActivateResponse, type TargetCloseResponse as TargetCloseResponse, type TargetGetResponse as TargetGetResponse, type TargetCreateParams as TargetCreateParams, type TargetListParams as TargetListParams, type TargetActivateParams as TargetActivateParams, type TargetCloseParams as TargetCloseParams, type TargetGetParams as TargetGetParams, }; } //# sourceMappingURL=browser.d.mts.map