scrapfly-sdk 0.10.5 → 0.10.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -177,6 +177,13 @@ class BrowserConfig {
177
177
  writable: true,
178
178
  value: void 0
179
179
  });
180
+ /** See {@link BrowserConfigOptions.solve_captcha}. */
181
+ Object.defineProperty(this, "solve_captcha", {
182
+ enumerable: true,
183
+ configurable: true,
184
+ writable: true,
185
+ value: void 0
186
+ });
180
187
  if (options.timeout !== undefined && options.timeout > 1800) {
181
188
  throw new Error('timeout cannot exceed 1800 seconds (30 minutes)');
182
189
  }
@@ -201,6 +208,7 @@ class BrowserConfig {
201
208
  this.unblock_timeout = options.unblock_timeout;
202
209
  this.browser_brand = options.browser_brand;
203
210
  this.enable_mcp = options.enable_mcp;
211
+ this.solve_captcha = options.solve_captcha;
204
212
  }
205
213
  /**
206
214
  * Build the WebSocket URL clients use to connect to the Cloud Browser
@@ -256,6 +264,8 @@ class BrowserConfig {
256
264
  params.set('browser_brand', this.browser_brand);
257
265
  if (this.enable_mcp !== undefined)
258
266
  params.set('enable_mcp', String(this.enable_mcp));
267
+ if (this.solve_captcha !== undefined)
268
+ params.set('solve_captcha', String(this.solve_captcha));
259
269
  const baseHost = host || 'wss://browser.scrapfly.io';
260
270
  return `${baseHost}?${params.toString()}`;
261
271
  }
@@ -9,6 +9,7 @@ import type { Rec } from './types.js';
9
9
  import type { CrawlerConfig, CrawlerContentFormat } from './crawlerconfig.js';
10
10
  import { CrawlerArtifact, type CrawlerArtifactType, CrawlerContents, CrawlerStatus, CrawlerUrls } from './crawlerresult.js';
11
11
  import { type CloudBrowserMonitoringOptions, type MonitoringMetricsOptions, type MonitoringTargetMetricsOptions } from './monitoringconfig.js';
12
+ import { type CreateScheduleRequest, type ListSchedulesOptions, type Schedule, type UpdateScheduleRequest } from './schedule.js';
12
13
  /**
13
14
  * Main entry point for the Scrapfly SDK.
14
15
  *
@@ -274,6 +275,7 @@ export declare class ScrapflyClient {
274
275
  body?: string;
275
276
  method?: string;
276
277
  enable_mcp?: boolean;
278
+ solve_captcha?: boolean;
277
279
  }): Promise<{
278
280
  ws_url: string;
279
281
  session_id: string;
@@ -340,5 +342,35 @@ export declare class ScrapflyClient {
340
342
  sessions: any[];
341
343
  total: number;
342
344
  }>;
345
+ /** Create a Web Scraping API schedule. `scrape_config` is the same shape
346
+ * accepted by `/scrape` (e.g. `{ url, render_js, asp, ... }`). */
347
+ createScrapeSchedule(scrapeConfig: Record<string, unknown>, request: CreateScheduleRequest): Promise<Schedule>;
348
+ /** Create a Screenshot API schedule. */
349
+ createScreenshotSchedule(screenshotConfig: Record<string, unknown>, request: CreateScheduleRequest): Promise<Schedule>;
350
+ /** Create a Crawler API schedule. */
351
+ createCrawlerSchedule(crawlerConfig: Record<string, unknown>, request: CreateScheduleRequest): Promise<Schedule>;
352
+ /** Return a schedule by id. Works across all kinds. */
353
+ getSchedule(id: string): Promise<Schedule>;
354
+ /** List every schedule on the account, optionally filtered by kind/status. */
355
+ listSchedules(opts?: ListSchedulesOptions): Promise<Schedule[]>;
356
+ listScrapeSchedules(opts?: {
357
+ status?: string;
358
+ }): Promise<Schedule[]>;
359
+ listScreenshotSchedules(opts?: {
360
+ status?: string;
361
+ }): Promise<Schedule[]>;
362
+ listCrawlerSchedules(opts?: {
363
+ status?: string;
364
+ }): Promise<Schedule[]>;
365
+ /** Patch an active schedule. Only fields set in `request` change. */
366
+ updateSchedule(id: string, request: UpdateScheduleRequest): Promise<Schedule>;
367
+ /** Cancel a schedule. Cancellation is terminal (returns no body). */
368
+ cancelSchedule(id: string): Promise<void>;
369
+ pauseSchedule(id: string): Promise<Schedule>;
370
+ resumeSchedule(id: string): Promise<Schedule>;
371
+ /** Fire a schedule immediately, regardless of next_scheduled_date. */
372
+ executeSchedule(id: string): Promise<Schedule>;
373
+ private buildCreateBody;
374
+ private scheduleRequest;
343
375
  }
344
376
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @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@ const result_js_1 = require("./result.js");
33
33
  const logger_js_1 = require("./logger.js");
34
34
  const crawlerresult_js_1 = require("./crawlerresult.js");
35
35
  const monitoringconfig_js_1 = require("./monitoringconfig.js");
36
+ const schedule_js_1 = require("./schedule.js");
36
37
  /**
37
38
  * Main entry point for the Scrapfly SDK.
38
39
  *
@@ -1281,6 +1282,8 @@ class ScrapflyClient {
1281
1282
  jsonBody.method = options.method;
1282
1283
  if (options.enable_mcp !== undefined)
1283
1284
  jsonBody.enable_mcp = options.enable_mcp;
1285
+ if (options.solve_captcha !== undefined)
1286
+ jsonBody.solve_captcha = options.solve_captcha;
1284
1287
  const url = new URL(this.cloudBrowserApiHost + '/unblock');
1285
1288
  url.searchParams.set('key', this.key);
1286
1289
  const response = await this.fetch({
@@ -1462,6 +1465,127 @@ class ScrapflyClient {
1462
1465
  }
1463
1466
  return await response.json();
1464
1467
  }
1468
+ // -------------------------------------------------------------------------
1469
+ // Public schedule endpoints — /scrape/schedules, /screenshot/schedules,
1470
+ // /crawl/schedules, /schedules. The kind-specific config is supplied to the
1471
+ // matching `create*Schedule` method; the cross-kind list/get/update/delete/
1472
+ // pause/resume/execute methods work regardless of kind.
1473
+ // -------------------------------------------------------------------------
1474
+ /** Create a Web Scraping API schedule. `scrape_config` is the same shape
1475
+ * accepted by `/scrape` (e.g. `{ url, render_js, asp, ... }`). */
1476
+ async createScrapeSchedule(scrapeConfig, request) {
1477
+ return await this.scheduleRequest('POST', '/scrape/schedules', undefined, this.buildCreateBody('scrape_config', scrapeConfig, request));
1478
+ }
1479
+ /** Create a Screenshot API schedule. */
1480
+ async createScreenshotSchedule(screenshotConfig, request) {
1481
+ return await this.scheduleRequest('POST', '/screenshot/schedules', undefined, this.buildCreateBody('screenshot_config', screenshotConfig, request));
1482
+ }
1483
+ /** Create a Crawler API schedule. */
1484
+ async createCrawlerSchedule(crawlerConfig, request) {
1485
+ return await this.scheduleRequest('POST', '/crawl/schedules', undefined, this.buildCreateBody('crawler_config', crawlerConfig, request));
1486
+ }
1487
+ /** Return a schedule by id. Works across all kinds. */
1488
+ async getSchedule(id) {
1489
+ return await this.scheduleRequest('GET', `/schedules/${encodeURIComponent(id)}`);
1490
+ }
1491
+ /** List every schedule on the account, optionally filtered by kind/status. */
1492
+ async listSchedules(opts) {
1493
+ return await this.scheduleRequest('GET', '/schedules', opts);
1494
+ }
1495
+ async listScrapeSchedules(opts) {
1496
+ return await this.scheduleRequest('GET', '/scrape/schedules', opts);
1497
+ }
1498
+ async listScreenshotSchedules(opts) {
1499
+ return await this.scheduleRequest('GET', '/screenshot/schedules', opts);
1500
+ }
1501
+ async listCrawlerSchedules(opts) {
1502
+ return await this.scheduleRequest('GET', '/crawl/schedules', opts);
1503
+ }
1504
+ /** Patch an active schedule. Only fields set in `request` change. */
1505
+ async updateSchedule(id, request) {
1506
+ return await this.scheduleRequest('PATCH', `/schedules/${encodeURIComponent(id)}`, undefined, request);
1507
+ }
1508
+ /** Cancel a schedule. Cancellation is terminal (returns no body). */
1509
+ async cancelSchedule(id) {
1510
+ await this.scheduleRequest('DELETE', `/schedules/${encodeURIComponent(id)}`);
1511
+ }
1512
+ async pauseSchedule(id) {
1513
+ return await this.scheduleRequest('POST', `/schedules/${encodeURIComponent(id)}/pause`);
1514
+ }
1515
+ async resumeSchedule(id) {
1516
+ return await this.scheduleRequest('POST', `/schedules/${encodeURIComponent(id)}/resume`);
1517
+ }
1518
+ /** Fire a schedule immediately, regardless of next_scheduled_date. */
1519
+ async executeSchedule(id) {
1520
+ return await this.scheduleRequest('POST', `/schedules/${encodeURIComponent(id)}/execute`);
1521
+ }
1522
+ buildCreateBody(configKey, config, request) {
1523
+ const body = {
1524
+ [configKey]: config,
1525
+ webhook_name: request.webhook_name,
1526
+ allow_concurrency: request.allow_concurrency ?? false,
1527
+ retry_on_failure: request.retry_on_failure ?? false,
1528
+ };
1529
+ if (request.recurrence)
1530
+ body.recurrence = request.recurrence;
1531
+ if (request.scheduled_date)
1532
+ body.scheduled_date = request.scheduled_date;
1533
+ if (typeof request.max_retries === 'number')
1534
+ body.max_retries = request.max_retries;
1535
+ if (request.notes)
1536
+ body.notes = request.notes;
1537
+ return body;
1538
+ }
1539
+ async scheduleRequest(method, path, query, body) {
1540
+ const url = new URL(this.HOST + path);
1541
+ const params = new URLSearchParams();
1542
+ params.set('key', this.key);
1543
+ if (query) {
1544
+ for (const [k, v] of Object.entries(query)) {
1545
+ if (v !== undefined && v !== '')
1546
+ params.set(k, v);
1547
+ }
1548
+ }
1549
+ url.search = params.toString();
1550
+ const init = {
1551
+ url: url.toString(),
1552
+ method,
1553
+ headers: {
1554
+ 'user-agent': this.ua,
1555
+ accept: 'application/json',
1556
+ },
1557
+ };
1558
+ if (body !== undefined) {
1559
+ init.body = JSON.stringify(body);
1560
+ init.headers['content-type'] = 'application/json';
1561
+ }
1562
+ const response = await this.fetch(init);
1563
+ if (response.status === 204)
1564
+ return undefined;
1565
+ if (!response.ok) {
1566
+ let envelope = {};
1567
+ try {
1568
+ envelope = await response.json();
1569
+ }
1570
+ catch {
1571
+ // body wasn't JSON; fall through with the empty envelope
1572
+ }
1573
+ const code = envelope.error ?? 'ERR::SCHEDULER::BACKEND_ERROR';
1574
+ let message = envelope.message ?? '';
1575
+ if (envelope.reason) {
1576
+ message = message ? `${message} (${envelope.reason})` : envelope.reason;
1577
+ }
1578
+ if (!message)
1579
+ message = `HTTP ${response.status}`;
1580
+ throw new schedule_js_1.ScheduleAPIError({
1581
+ code,
1582
+ message,
1583
+ httpStatusCode: response.status,
1584
+ details: envelope.details,
1585
+ });
1586
+ }
1587
+ return await response.json();
1588
+ }
1465
1589
  }
1466
1590
  exports.ScrapflyClient = ScrapflyClient;
1467
1591
  // ---------------------------------------------------------------------------
package/script/main.d.ts CHANGED
@@ -40,6 +40,8 @@ export { Crawl } from './crawl.js';
40
40
  export { CrawlerArtifact, CrawlerContents, CrawlerStatus, CrawlerUrls, parseCrawlerWebhook, } from './crawlerresult.js';
41
41
  export type { CrawlerArtifactType, CrawlerLifecycleWebhook, CrawlerState, CrawlerStatusValue, CrawlerStopReason, CrawlerUrlDiscoveredWebhook, CrawlerUrlEntry, CrawlerUrlFailedWebhook, CrawlerUrlSkippedWebhook, CrawlerUrlVisitedWebhook, CrawlerWebhookCommon, CrawlerWebhookPayload, } from './crawlerresult.js';
42
42
  export type { CloudBrowserMonitoringOptions, MonitoringAggregation, MonitoringDataFormat, MonitoringMetricsOptions, MonitoringPeriod, MonitoringTargetMetricsOptions, } from './monitoringconfig.js';
43
+ export { ScheduleAPIError } from './schedule.js';
44
+ export type { CreateScheduleRequest, ListSchedulesOptions, Schedule, ScheduleEnd, ScheduleRecurrence, UpdateScheduleRequest, } from './schedule.js';
43
45
  export { log } from './logger.js';
44
46
  export { createServer, verifySignature } from './webhookserver.js';
45
47
  //# sourceMappingURL=main.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,MAAM,IAAI,YAAY,EACtB,YAAY,IAAI,mBAAmB,EACnC,YAAY,EACZ,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,MAAM,IAAI,gBAAgB,EAC1B,OAAO,IAAI,iBAAiB,EAC5B,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC/E,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,mFAAmF;AACnF,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAA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,CAAC;AAEvB,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
package/script/main.js CHANGED
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.verifySignature = exports.createServer = exports.log = exports.parseCrawlerWebhook = exports.CrawlerUrls = exports.CrawlerStatus = exports.CrawlerContents = exports.CrawlerArtifact = exports.Crawl = exports.CrawlerConfig = exports.ScreenshotResult = exports.ScrapeResult = exports.ExtractionResult = exports.errors = exports.OperatingSystem = exports.ProxyPool = exports.BrowserConfig = exports.ExtractionConfig = exports.VisionDeficiency = exports.ScreenshotConfig = exports.ScreenshotOptions = exports.ScreenshotFormat = exports.ScreenshotFlags = exports.ScrapeConfig = exports.ScrapeFormatOptions = exports.ScrapeFormat = exports.ScrapflyClient = void 0;
26
+ exports.verifySignature = exports.createServer = exports.log = exports.ScheduleAPIError = exports.parseCrawlerWebhook = exports.CrawlerUrls = exports.CrawlerStatus = exports.CrawlerContents = exports.CrawlerArtifact = exports.Crawl = exports.CrawlerConfig = exports.ScreenshotResult = exports.ScrapeResult = exports.ExtractionResult = exports.errors = exports.OperatingSystem = exports.ProxyPool = exports.BrowserConfig = exports.ExtractionConfig = exports.VisionDeficiency = exports.ScreenshotConfig = exports.ScreenshotOptions = exports.ScreenshotFormat = exports.ScreenshotFlags = exports.ScrapeConfig = exports.ScrapeFormatOptions = exports.ScrapeFormat = exports.ScrapflyClient = void 0;
27
27
  /**
28
28
  * # Scrapfly SDK for TypeScript / JavaScript
29
29
  *
@@ -85,6 +85,8 @@ Object.defineProperty(exports, "CrawlerContents", { enumerable: true, get: funct
85
85
  Object.defineProperty(exports, "CrawlerStatus", { enumerable: true, get: function () { return crawlerresult_js_1.CrawlerStatus; } });
86
86
  Object.defineProperty(exports, "CrawlerUrls", { enumerable: true, get: function () { return crawlerresult_js_1.CrawlerUrls; } });
87
87
  Object.defineProperty(exports, "parseCrawlerWebhook", { enumerable: true, get: function () { return crawlerresult_js_1.parseCrawlerWebhook; } });
88
+ var schedule_js_1 = require("./schedule.js");
89
+ Object.defineProperty(exports, "ScheduleAPIError", { enumerable: true, get: function () { return schedule_js_1.ScheduleAPIError; } });
88
90
  var logger_js_1 = require("./logger.js");
89
91
  Object.defineProperty(exports, "log", { enumerable: true, get: function () { return logger_js_1.log; } });
90
92
  var webhookserver_js_1 = require("./webhookserver.js");
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Public schedule client for the Scrapfly API.
3
+ *
4
+ * Wraps `/scrape/schedules`, `/screenshot/schedules`, `/crawl/schedules`
5
+ * and the cross-kind `/schedules` endpoints. The server returns fully-formed
6
+ * Schedule objects; we surface them as-is so callers always see the live
7
+ * server shape.
8
+ */
9
+ /** Bounds a recurring schedule by either a date or a fire count. */
10
+ export interface ScheduleEnd {
11
+ type: 'date' | 'count';
12
+ date?: string;
13
+ count?: number;
14
+ }
15
+ /**
16
+ * When a schedule fires next. Cron mode wins when `cron` is set; otherwise
17
+ * `interval` + `unit` drive the cadence.
18
+ */
19
+ export interface ScheduleRecurrence {
20
+ cron?: string;
21
+ interval?: number;
22
+ unit?: 'minute' | 'hour' | 'day' | 'week' | 'month';
23
+ days?: string[];
24
+ ends?: ScheduleEnd;
25
+ }
26
+ /**
27
+ * Public-facing request envelope for creating a schedule. The kind-specific
28
+ * config (`scrape_config` / `screenshot_config` / `crawler_config`) is
29
+ * supplied as a separate argument by the matching `create*Schedule` method.
30
+ */
31
+ export interface CreateScheduleRequest {
32
+ webhook_name: string;
33
+ recurrence?: ScheduleRecurrence;
34
+ scheduled_date?: string;
35
+ allow_concurrency?: boolean;
36
+ retry_on_failure?: boolean;
37
+ max_retries?: number;
38
+ notes?: string;
39
+ }
40
+ /** PATCH payload. Only fields explicitly set are forwarded. */
41
+ export interface UpdateScheduleRequest {
42
+ recurrence?: ScheduleRecurrence;
43
+ scheduled_date?: string;
44
+ allow_concurrency?: boolean;
45
+ retry_on_failure?: boolean;
46
+ max_retries?: number;
47
+ notes?: string;
48
+ scrape_config?: Record<string, unknown>;
49
+ screenshot_config?: Record<string, unknown>;
50
+ crawler_config?: Record<string, unknown>;
51
+ }
52
+ /** Server-side schedule record. Returned by every read or mutation endpoint. */
53
+ export interface Schedule {
54
+ id: string;
55
+ kind: string;
56
+ status: string;
57
+ next_scheduled_date?: string;
58
+ scheduled_date?: string;
59
+ recurrence?: ScheduleRecurrence;
60
+ metadata?: Record<string, unknown>;
61
+ notes?: string | null;
62
+ created_by?: string | null;
63
+ created_at: string;
64
+ updated_at: string;
65
+ cancelled_at?: string | null;
66
+ allow_concurrency: boolean;
67
+ retry_on_failure: boolean;
68
+ max_retries: number;
69
+ webhook_uuid?: string | null;
70
+ user_uuid?: string | null;
71
+ consecutive_failures?: number;
72
+ }
73
+ export interface ListSchedulesOptions {
74
+ status?: string;
75
+ kind?: string;
76
+ }
77
+ /**
78
+ * Raised on any non-2xx response from a `/schedules/*` endpoint. The
79
+ * `code` property carries the public `ERR::SCHEDULER::*` identifier so
80
+ * callers can branch on it without parsing the message string.
81
+ */
82
+ export declare class ScheduleAPIError extends Error {
83
+ code: string;
84
+ httpStatusCode: number;
85
+ details: unknown;
86
+ constructor(args: {
87
+ code: string;
88
+ message: string;
89
+ httpStatusCode: number;
90
+ details?: unknown;
91
+ });
92
+ }
93
+ //# sourceMappingURL=schedule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schedule.d.ts","sourceRoot":"","sources":["../src/schedule.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,oEAAoE;AACpE,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,kBA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AAU,CAAC,EAAE,kBAAkB,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,OAAO,CAAC;gBAEL,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE;CAO/F"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ /**
3
+ * Public schedule client for the Scrapfly API.
4
+ *
5
+ * Wraps `/scrape/schedules`, `/screenshot/schedules`, `/crawl/schedules`
6
+ * and the cross-kind `/schedules` endpoints. The server returns fully-formed
7
+ * Schedule objects; we surface them as-is so callers always see the live
8
+ * server shape.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.ScheduleAPIError = void 0;
12
+ /**
13
+ * Raised on any non-2xx response from a `/schedules/*` endpoint. The
14
+ * `code` property carries the public `ERR::SCHEDULER::*` identifier so
15
+ * callers can branch on it without parsing the message string.
16
+ */
17
+ class ScheduleAPIError extends Error {
18
+ constructor(args) {
19
+ super(args.message);
20
+ Object.defineProperty(this, "code", {
21
+ enumerable: true,
22
+ configurable: true,
23
+ writable: true,
24
+ value: void 0
25
+ });
26
+ Object.defineProperty(this, "httpStatusCode", {
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true,
30
+ value: void 0
31
+ });
32
+ Object.defineProperty(this, "details", {
33
+ enumerable: true,
34
+ configurable: true,
35
+ writable: true,
36
+ value: void 0
37
+ });
38
+ this.name = 'ScheduleAPIError';
39
+ this.code = args.code;
40
+ this.httpStatusCode = args.httpStatusCode;
41
+ this.details = args.details;
42
+ }
43
+ }
44
+ exports.ScheduleAPIError = ScheduleAPIError;
@@ -8,9 +8,13 @@ export declare enum ResourceType {
8
8
  * HMAC-SHA256 signature on the request body against the configured
9
9
  * signing secret.
10
10
  *
11
- * @param body Raw request body as received (do NOT decode).
12
- * @param signature Value of the `Scrapfly-Signature` header (hex).
13
- * @param signingSecret Webhook signing secret configured in the dashboard (hex).
11
+ * @param body Raw request body as received (verify BEFORE any decompression
12
+ * or JSON parsing — the signature is computed on the bytes
13
+ * Scrapfly sent on the wire).
14
+ * @param signature Value of the `X-Scrapfly-Webhook-Signature` header
15
+ * (uppercase hex digest).
16
+ * @param signingSecret Webhook signing secret from the dashboard, passed as-is
17
+ * (UTF-8 string; not hex-encoded).
14
18
  * @returns `true` if the signature matches.
15
19
  */
16
20
  export declare function verifySignature(body: Buffer, signature: string, signingSecret: string): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"webhookserver.d.ts","sourceRoot":"","sources":["../src/webhookserver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC,oBAAY,YAAY;IACtB,MAAM,WAAW;IACjB,IAAI,SAAS;CACd;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAM/F;AAGD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,IAAI,EACjE,GAAG,CAAC,EAAE,GAAG,GACR,OAAO,CAAC,GAAG,CAAC,CA4Cd"}
1
+ {"version":3,"file":"webhookserver.d.ts","sourceRoot":"","sources":["../src/webhookserver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC,oBAAY,YAAY;IACtB,MAAM,WAAW;IACjB,IAAI,SAAS;CACd;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAS/F;AAGD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,IAAI,EACjE,GAAG,CAAC,EAAE,GAAG,GACR,OAAO,CAAC,GAAG,CAAC,CA4Cd"}
@@ -42,17 +42,24 @@ var ResourceType;
42
42
  * HMAC-SHA256 signature on the request body against the configured
43
43
  * signing secret.
44
44
  *
45
- * @param body Raw request body as received (do NOT decode).
46
- * @param signature Value of the `Scrapfly-Signature` header (hex).
47
- * @param signingSecret Webhook signing secret configured in the dashboard (hex).
45
+ * @param body Raw request body as received (verify BEFORE any decompression
46
+ * or JSON parsing — the signature is computed on the bytes
47
+ * Scrapfly sent on the wire).
48
+ * @param signature Value of the `X-Scrapfly-Webhook-Signature` header
49
+ * (uppercase hex digest).
50
+ * @param signingSecret Webhook signing secret from the dashboard, passed as-is
51
+ * (UTF-8 string; not hex-encoded).
48
52
  * @returns `true` if the signature matches.
49
53
  */
50
54
  function verifySignature(body, signature, signingSecret) {
51
- const secret = node_buffer_1.Buffer.from(signingSecret, 'hex');
52
- const hmac = node_crypto_1.default.createHmac('sha256', secret);
55
+ const hmac = node_crypto_1.default.createHmac('sha256', node_buffer_1.Buffer.from(signingSecret, 'utf8'));
53
56
  hmac.update(body);
54
57
  const computed = hmac.digest('hex').toUpperCase();
55
- return computed === signature;
58
+ const received = signature.toUpperCase();
59
+ if (computed.length !== received.length) {
60
+ return false;
61
+ }
62
+ return node_crypto_1.default.timingSafeEqual(node_buffer_1.Buffer.from(computed), node_buffer_1.Buffer.from(received));
56
63
  }
57
64
  /**
58
65
  * Start a tiny Express server that receives Scrapfly webhook callbacks
package/src/batch.ts CHANGED
@@ -26,7 +26,13 @@ function indexOf(buf: Uint8Array, needle: Uint8Array, start = 0): number {
26
26
  return -1;
27
27
  }
28
28
 
29
- function concat(a: Uint8Array, b: Uint8Array): Uint8Array {
29
+ // concat sidesteps the TS 5.7+ generic-Uint8Array vs dnt-Node legacy
30
+ // Uint8Array mismatch by accepting `any` and returning a freshly
31
+ // allocated buffer. The fresh allocation guarantees the result is a
32
+ // `Uint8Array<ArrayBuffer>` at runtime under TS 5.7+ and a plain
33
+ // non-generic `Uint8Array` under dnt's Node target.
34
+ // deno-lint-ignore no-explicit-any
35
+ function concat(a: any, b: any): any {
30
36
  const out = new Uint8Array(a.length + b.length);
31
37
  out.set(a, 0);
32
38
  out.set(b, a.length);
@@ -64,6 +64,14 @@ export type BrowserConfigOptions = {
64
64
  browser_brand?: string;
65
65
  /** Enable the MCP (Model Context Protocol) bridge. */
66
66
  enable_mcp?: boolean;
67
+ /**
68
+ * Arm Scrapium's built-in captcha detector + solver on the first page attach.
69
+ * Turnstile, DataDome slider, reCAPTCHA, GeeTest, PerimeterX hold, and
70
+ * puzzle captchas are handled automatically — no extra CDP calls from the
71
+ * client. Billed per solve; failures cost nothing.
72
+ * See https://scrapfly.io/docs/cloud-browser-api/captcha-solver
73
+ */
74
+ solve_captcha?: boolean;
67
75
  };
68
76
 
69
77
  /**
@@ -114,6 +122,8 @@ export class BrowserConfig {
114
122
  browser_brand?: string;
115
123
  /** See {@link BrowserConfigOptions.enable_mcp}. */
116
124
  enable_mcp?: boolean;
125
+ /** See {@link BrowserConfigOptions.solve_captcha}. */
126
+ solve_captcha?: boolean;
117
127
 
118
128
  /**
119
129
  * @param options Session options. See {@link BrowserConfigOptions}.
@@ -144,6 +154,7 @@ export class BrowserConfig {
144
154
  this.unblock_timeout = options.unblock_timeout;
145
155
  this.browser_brand = options.browser_brand;
146
156
  this.enable_mcp = options.enable_mcp;
157
+ this.solve_captcha = options.solve_captcha;
147
158
  }
148
159
 
149
160
  /**
@@ -180,6 +191,7 @@ export class BrowserConfig {
180
191
  if (this.unblock_timeout !== undefined) params.set('unblock_timeout', String(this.unblock_timeout));
181
192
  if (this.browser_brand !== undefined) params.set('browser_brand', this.browser_brand);
182
193
  if (this.enable_mcp !== undefined) params.set('enable_mcp', String(this.enable_mcp));
194
+ if (this.solve_captcha !== undefined) params.set('solve_captcha', String(this.solve_captcha));
183
195
 
184
196
  const baseHost = host || 'wss://browser.scrapfly.io';
185
197
  return `${baseHost}?${params.toString()}`;