scrapfly-sdk 0.10.4 → 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.
Files changed (100) hide show
  1. package/esm/batch.d.ts.map +1 -1
  2. package/esm/batch.js +6 -0
  3. package/esm/browserconfig.d.ts +80 -1
  4. package/esm/browserconfig.d.ts.map +1 -1
  5. package/esm/browserconfig.js +54 -1
  6. package/esm/client.d.ts +65 -0
  7. package/esm/client.d.ts.map +1 -1
  8. package/esm/client.js +157 -5
  9. package/esm/crawl.d.ts +4 -0
  10. package/esm/crawl.d.ts.map +1 -1
  11. package/esm/crawl.js +4 -0
  12. package/esm/crawlerresult.d.ts +7 -0
  13. package/esm/crawlerresult.d.ts.map +1 -1
  14. package/esm/errors.d.ts +43 -0
  15. package/esm/errors.d.ts.map +1 -1
  16. package/esm/errors.js +43 -16
  17. package/esm/extractionconfig.d.ts +54 -9
  18. package/esm/extractionconfig.d.ts.map +1 -1
  19. package/esm/extractionconfig.js +37 -13
  20. package/esm/logger.d.ts +1 -0
  21. package/esm/logger.d.ts.map +1 -1
  22. package/esm/logger.js +1 -0
  23. package/esm/main.d.ts +29 -0
  24. package/esm/main.d.ts.map +1 -1
  25. package/esm/main.js +28 -0
  26. package/esm/monitoringconfig.d.ts +48 -11
  27. package/esm/monitoringconfig.d.ts.map +1 -1
  28. package/esm/monitoringconfig.js +14 -0
  29. package/esm/result.d.ts +2 -0
  30. package/esm/result.d.ts.map +1 -1
  31. package/esm/schedule.d.ts +93 -0
  32. package/esm/schedule.d.ts.map +1 -0
  33. package/esm/schedule.js +40 -0
  34. package/esm/scrapeconfig.d.ts +10 -8
  35. package/esm/scrapeconfig.d.ts.map +1 -1
  36. package/esm/scrapeconfig.js +10 -8
  37. package/esm/screenshotconfig.d.ts +59 -26
  38. package/esm/screenshotconfig.d.ts.map +1 -1
  39. package/esm/screenshotconfig.js +38 -26
  40. package/esm/webhookserver.d.ts +28 -0
  41. package/esm/webhookserver.d.ts.map +1 -1
  42. package/esm/webhookserver.js +34 -3
  43. package/package.json +1 -1
  44. package/script/batch.d.ts.map +1 -1
  45. package/script/batch.js +6 -0
  46. package/script/browserconfig.d.ts +80 -1
  47. package/script/browserconfig.d.ts.map +1 -1
  48. package/script/browserconfig.js +54 -1
  49. package/script/client.d.ts +65 -0
  50. package/script/client.d.ts.map +1 -1
  51. package/script/client.js +157 -5
  52. package/script/crawl.d.ts +4 -0
  53. package/script/crawl.d.ts.map +1 -1
  54. package/script/crawl.js +4 -0
  55. package/script/crawlerresult.d.ts +7 -0
  56. package/script/crawlerresult.d.ts.map +1 -1
  57. package/script/errors.d.ts +43 -0
  58. package/script/errors.d.ts.map +1 -1
  59. package/script/errors.js +43 -16
  60. package/script/extractionconfig.d.ts +54 -9
  61. package/script/extractionconfig.d.ts.map +1 -1
  62. package/script/extractionconfig.js +37 -13
  63. package/script/logger.d.ts +1 -0
  64. package/script/logger.d.ts.map +1 -1
  65. package/script/logger.js +1 -0
  66. package/script/main.d.ts +29 -0
  67. package/script/main.d.ts.map +1 -1
  68. package/script/main.js +30 -1
  69. package/script/monitoringconfig.d.ts +48 -11
  70. package/script/monitoringconfig.d.ts.map +1 -1
  71. package/script/monitoringconfig.js +14 -0
  72. package/script/result.d.ts +2 -0
  73. package/script/result.d.ts.map +1 -1
  74. package/script/schedule.d.ts +93 -0
  75. package/script/schedule.d.ts.map +1 -0
  76. package/script/schedule.js +44 -0
  77. package/script/scrapeconfig.d.ts +10 -8
  78. package/script/scrapeconfig.d.ts.map +1 -1
  79. package/script/scrapeconfig.js +10 -8
  80. package/script/screenshotconfig.d.ts +59 -26
  81. package/script/screenshotconfig.d.ts.map +1 -1
  82. package/script/screenshotconfig.js +38 -26
  83. package/script/webhookserver.d.ts +28 -0
  84. package/script/webhookserver.d.ts.map +1 -1
  85. package/script/webhookserver.js +34 -3
  86. package/src/batch.ts +7 -1
  87. package/src/browserconfig.ts +82 -1
  88. package/src/client.ts +227 -7
  89. package/src/crawl.ts +4 -0
  90. package/src/crawlerresult.ts +7 -0
  91. package/src/errors.ts +43 -16
  92. package/src/extractionconfig.ts +58 -16
  93. package/src/logger.ts +2 -0
  94. package/src/main.ts +37 -0
  95. package/src/monitoringconfig.ts +49 -11
  96. package/src/result.ts +2 -0
  97. package/src/schedule.ts +101 -0
  98. package/src/scrapeconfig.ts +10 -8
  99. package/src/screenshotconfig.ts +59 -26
  100. package/src/webhookserver.ts +34 -3
@@ -0,0 +1,40 @@
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
+ /**
10
+ * Raised on any non-2xx response from a `/schedules/*` endpoint. The
11
+ * `code` property carries the public `ERR::SCHEDULER::*` identifier so
12
+ * callers can branch on it without parsing the message string.
13
+ */
14
+ export class ScheduleAPIError extends Error {
15
+ constructor(args) {
16
+ super(args.message);
17
+ Object.defineProperty(this, "code", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: void 0
22
+ });
23
+ Object.defineProperty(this, "httpStatusCode", {
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true,
27
+ value: void 0
28
+ });
29
+ Object.defineProperty(this, "details", {
30
+ enumerable: true,
31
+ configurable: true,
32
+ writable: true,
33
+ value: void 0
34
+ });
35
+ this.name = 'ScheduleAPIError';
36
+ this.code = args.code;
37
+ this.httpStatusCode = args.httpStatusCode;
38
+ this.details = args.details;
39
+ }
40
+ }
@@ -14,24 +14,26 @@ export declare enum ScreenshotFlags {
14
14
  PRINT_MEDIA_FORMAT = "print_media_format",
15
15
  HIGH_QUALITY = "high_quality"
16
16
  }
17
+ /** Output format requested for the scraped content. */
17
18
  export declare enum Format {
18
- /**
19
- Format of the scraped content.
20
- Attributes:
21
- JSON: JSON format.
22
- TEXT: Text format.
23
- MARKDOWN: Markdown format.
24
- CLEAN_HTML: Clean HTML format.
25
- */
19
+ /** Structured JSON. */
26
20
  JSON = "json",
21
+ /** Plain text with markup stripped. */
27
22
  TEXT = "text",
23
+ /** Markdown rendering of the page. */
28
24
  MARKDOWN = "markdown",
25
+ /** Readability-cleaned HTML. */
29
26
  CLEAN_HTML = "clean_html",
27
+ /** Raw HTML as returned by the target. */
30
28
  RAW = "raw"
31
29
  }
30
+ /** Additional filters applied to the chosen {@link Format}. */
32
31
  export declare enum FormatOption {
32
+ /** Strip hyperlinks from the output. */
33
33
  NO_LINKS = "no_links",
34
+ /** Strip images from the output. */
34
35
  NO_IMAGES = "no_images",
36
+ /** Keep only the "content" section (drop navigation, sidebars, footers). */
35
37
  ONLY_CONTENT = "only_content"
36
38
  }
37
39
  type ScrapeConfigOptions = {
@@ -1 +1 @@
1
- {"version":3,"file":"scrapeconfig.d.ts","sourceRoot":"","sources":["../src/scrapeconfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAGlD,oBAAY,eAAe;IACzB;;;;;;;QAOI;IACJ,WAAW,gBAAgB;IAC3B,SAAS,cAAc;IACvB,aAAa,kBAAkB;IAC/B,kBAAkB,uBAAuB;IACzC,YAAY,iBAAiB;CAC9B;AAED,oBAAY,MAAM;IAChB;;;;;;;QAOI;IACJ,IAAI,SAAS;IACb,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,UAAU,eAAe;IACzB,GAAG,QAAQ;CACZ;AAED,oBAAY,YAAY;IACtB,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,YAAY,iBAAiB;CAC9B;AAED,KAAK,mBAAmB,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,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GH_QUALITY"] = "high_quality";
19
19
  })(ScreenshotFlags || (ScreenshotFlags = {}));
20
+ /** Output format requested for the scraped content. */
20
21
  export var Format;
21
22
  (function (Format) {
22
- /**
23
- Format of the scraped content.
24
- Attributes:
25
- JSON: JSON format.
26
- TEXT: Text format.
27
- MARKDOWN: Markdown format.
28
- CLEAN_HTML: Clean HTML format.
29
- */
23
+ /** Structured JSON. */
30
24
  Format["JSON"] = "json";
25
+ /** Plain text with markup stripped. */
31
26
  Format["TEXT"] = "text";
27
+ /** Markdown rendering of the page. */
32
28
  Format["MARKDOWN"] = "markdown";
29
+ /** Readability-cleaned HTML. */
33
30
  Format["CLEAN_HTML"] = "clean_html";
31
+ /** Raw HTML as returned by the target. */
34
32
  Format["RAW"] = "raw";
35
33
  })(Format || (Format = {}));
34
+ /** Additional filters applied to the chosen {@link Format}. */
36
35
  export var FormatOption;
37
36
  (function (FormatOption) {
37
+ /** Strip hyperlinks from the output. */
38
38
  FormatOption["NO_LINKS"] = "no_links";
39
+ /** Strip images from the output. */
39
40
  FormatOption["NO_IMAGES"] = "no_images";
41
+ /** Keep only the "content" section (drop navigation, sidebars, footers). */
40
42
  FormatOption["ONLY_CONTENT"] = "only_content";
41
43
  })(FormatOption || (FormatOption = {}));
42
44
  export class ScrapeConfig {
@@ -1,72 +1,98 @@
1
+ /** Toggles that customize how the screenshot is captured. */
1
2
  export declare enum Options {
2
- /**
3
- Options to customize the screenshot behavior
4
- Attributes:
5
- LOAD_IMAGES: Enable image rendering with the request, add extra usage for the bandwidth consumed.
6
- DARK_MODE: Enable dark mode display.
7
- BLOCK_BANNERS: Block cookies banners and overlay that cover the screen.
8
- PRINT_MEDIA_FORMAT: Render the page in the print mode.
9
- */
3
+ /** Render images before capturing. Consumes additional bandwidth. */
10
4
  LOAD_IMAGES = "load_images",
5
+ /** Render the page in dark mode. */
11
6
  DARK_MODE = "dark_mode",
7
+ /** Block cookie banners and overlays that would otherwise occlude the page. */
12
8
  BLOCK_BANNERS = "block_banners",
9
+ /** Render the page using the `print` media query. */
13
10
  PRINT_MEDIA_FORMAT = "print_media_format"
14
11
  }
12
+ /** Output format of the screenshot image. */
15
13
  export declare enum Format {
16
- /**
17
- Format of the screenshot image.
18
- Attributes:
19
- JPG: JPG format.
20
- PNG: PNG format.
21
- WEBP: WEBP format.
22
- GIF: GIF format.
23
- */
14
+ /** JPEG encoding. */
24
15
  JPG = "jpg",
16
+ /** PNG encoding. */
25
17
  PNG = "png",
18
+ /** WebP encoding. */
26
19
  WEBP = "webp",
20
+ /** Animated GIF encoding. */
27
21
  GIF = "gif"
28
22
  }
23
+ /**
24
+ * Visual impairments to simulate when capturing the screenshot.
25
+ * Useful for WCAG accessibility testing.
26
+ */
29
27
  export declare enum VisionDeficiency {
30
- /**
31
- Simulate vision deficiency for accessibility testing (WCAG compliance)
32
- Attributes:
33
- DEUTERANOPIA: Difficulty distinguishing green from red; green appears beige/gray
34
- PROTANOPIA: Reduced sensitivity to red light; red appears dark/black
35
- TRITANOPIA: Difficulty distinguishing blue from yellow and violet from red
36
- ACHROMATOPSIA: Complete inability to perceive color; sees only in grayscale
37
- REDUCED_CONTRAST: Simulates reduced contrast due to aging, low light, or other factors
38
- BLURRED_VISION: Simulates uncorrected refractive errors or age-related vision loss
39
- */
28
+ /** Difficulty distinguishing green from red; green appears beige/gray. */
40
29
  DEUTERANOPIA = "deuteranopia",
30
+ /** Reduced sensitivity to red light; red appears dark/black. */
41
31
  PROTANOPIA = "protanopia",
32
+ /** Difficulty distinguishing blue from yellow and violet from red. */
42
33
  TRITANOPIA = "tritanopia",
34
+ /** Complete color blindness; the image is grayscale. */
43
35
  ACHROMATOPSIA = "achromatopsia",
36
+ /** Reduced contrast (aging, low light). */
44
37
  REDUCED_CONTRAST = "reducedContrast",
38
+ /** Blurred vision (uncorrected refractive errors). */
45
39
  BLURRED_VISION = "blurredVision"
46
40
  }
41
+ /**
42
+ * User-facing options accepted by {@link ScreenshotConfig}. See the
43
+ * [Screenshot API reference](https://scrapfly.io/docs/screenshot-api)
44
+ * for the authoritative list of valid values.
45
+ */
47
46
  type ScreenshotConfigOptions = {
47
+ /** URL of the page to screenshot. Required. */
48
48
  url: string;
49
+ /** Output image format. Defaults to JPG. */
49
50
  format?: 'jpg' | 'png' | 'webp' | 'gif' | Format;
51
+ /** Capture area: `fullpage`, `viewport`, or a CSS selector. */
50
52
  capture?: string;
53
+ /** Viewport resolution, formatted as "widthxheight". */
51
54
  resolution?: string;
55
+ /** ISO country code for geo-targeting the rendering browser. */
52
56
  country?: string;
57
+ /** Request timeout in milliseconds. */
53
58
  timeout?: number;
59
+ /** Additional delay (ms) after load before capturing. */
54
60
  rendering_wait?: number;
61
+ /** CSS selector to wait for before capturing. */
55
62
  wait_for_selector?: string;
63
+ /** Behavior toggles. See {@link Options}. */
56
64
  options?: ('load_images' | 'dark_mode' | 'block_banners' | 'print_media_format' | Options)[];
65
+ /** Scroll to the bottom of the page before capture. */
57
66
  auto_scroll?: boolean;
67
+ /** Custom JavaScript to run on the page before capture. */
58
68
  js?: string;
69
+ /** Serve from Scrapfly's cache when possible. */
59
70
  cache?: boolean;
71
+ /** TTL in seconds for the cached entry. Ignored if cache is disabled. */
60
72
  cache_ttl?: number;
73
+ /** Invalidate the existing cache entry before capturing. */
61
74
  cache_clear?: boolean;
75
+ /** Vision deficiency to simulate. See {@link VisionDeficiency}. */
62
76
  vision_deficiency?: 'deuteranopia' | 'protanopia' | 'tritanopia' | 'achromatopsia' | 'blurredVision' | 'reducedContrast' | VisionDeficiency;
77
+ /** Webhook name to notify when the screenshot completes. */
63
78
  webhook?: string;
64
79
  };
80
+ /**
81
+ * Configuration for a single screenshot request. Instances are passed
82
+ * to {@link ScrapflyClient.screenshot}; this class is responsible for
83
+ * validating options and encoding them into Scrapfly's query string
84
+ * format.
85
+ */
65
86
  export declare class ScreenshotConfig {
87
+ /** URL of the page to screenshot. */
66
88
  url: string;
89
+ /** Output image format. */
67
90
  format?: 'jpg' | 'png' | 'webp' | 'gif' | Format;
91
+ /** Capture area (`fullpage`, `viewport`, or a CSS selector). */
68
92
  capture?: string;
93
+ /** Viewport resolution (`widthxheight`). */
69
94
  resolution?: string;
95
+ /** Geo-targeting country (ISO code). */
70
96
  country?: string;
71
97
  timeout?: number;
72
98
  rendering_wait?: number;
@@ -81,6 +107,13 @@ export declare class ScreenshotConfig {
81
107
  webhook?: string;
82
108
  constructor(options: ScreenshotConfigOptions);
83
109
  private validateOptions;
110
+ /**
111
+ * Encode this config as the query-string parameters sent to the
112
+ * Screenshot API.
113
+ *
114
+ * @param options.key Scrapfly API key.
115
+ * @returns A record suitable for `URLSearchParams` construction.
116
+ */
84
117
  toApiParams(options: {
85
118
  key: string;
86
119
  }): Record<string, any>;
@@ -1 +1 @@
1
- {"version":3,"file":"screenshotconfig.d.ts","sourceRoot":"","sources":["../src/screenshotconfig.ts"],"names":[],"mappings":"AAIA,oBAAY,OAAO;IACjB;;;;;;;QAOI;IACJ,WAAW,gBAAgB;IAC3B,SAAS,cAAc;IACvB,aAAa,kBAAkB;IAC/B,kBAAkB,uBAAuB;CAC1C;AAED,oBAAY,MAAM;IAChB;;;;;;;QAOI;IACJ,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,GAAG,QAAQ;CACZ;AAED,oBAAY,gBAAgB;IAC1B;;;;;;;;;OASG;IACH,YAAY,iBAAiB;IAC7B,UAAU,eAAe;IACzB,UAAU,eAAe;IACzB,aAAa,kBAAkB;IAC/B,gBAAgB,oBAAoB;IACpC,cAAc,kBAAkB;CACjC;AAED,KAAK,uBAAuB,GAAG;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MA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,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,CAAC,aAAa,GAAG,WAAW,GAAG,eAAe,GAAG,oBAAoB,GAAG,OAAO,CAAC,EAAE,CAAC;IAC7F,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,iBAAiB,CAAC,EAAE,cAAc,GAAG,YAAY,GAAG,YAAY,GAAG,eAAe,GAAG,eAAe,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;IAC5I,OAAO,CAAC,EAAE,MAAM,CAAC;gBAEL,OAAO,EAAE,uBAAuB;IA+B5C,OAAO,CAAC,eAAe;IASvB;;;;;;OAMG;IACH,WAAW,CAAC,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAyE3D"}
@@ -1,81 +1,86 @@
1
1
  import { ScreenshotConfigError } from './errors.js';
2
2
  import { urlsafe_b64encode } from './utils.js';
3
3
  import { log } from './logger.js';
4
+ /** Toggles that customize how the screenshot is captured. */
4
5
  export var Options;
5
6
  (function (Options) {
6
- /**
7
- Options to customize the screenshot behavior
8
- Attributes:
9
- LOAD_IMAGES: Enable image rendering with the request, add extra usage for the bandwidth consumed.
10
- DARK_MODE: Enable dark mode display.
11
- BLOCK_BANNERS: Block cookies banners and overlay that cover the screen.
12
- PRINT_MEDIA_FORMAT: Render the page in the print mode.
13
- */
7
+ /** Render images before capturing. Consumes additional bandwidth. */
14
8
  Options["LOAD_IMAGES"] = "load_images";
9
+ /** Render the page in dark mode. */
15
10
  Options["DARK_MODE"] = "dark_mode";
11
+ /** Block cookie banners and overlays that would otherwise occlude the page. */
16
12
  Options["BLOCK_BANNERS"] = "block_banners";
13
+ /** Render the page using the `print` media query. */
17
14
  Options["PRINT_MEDIA_FORMAT"] = "print_media_format";
18
15
  })(Options || (Options = {}));
16
+ /** Output format of the screenshot image. */
19
17
  export var Format;
20
18
  (function (Format) {
21
- /**
22
- Format of the screenshot image.
23
- Attributes:
24
- JPG: JPG format.
25
- PNG: PNG format.
26
- WEBP: WEBP format.
27
- GIF: GIF format.
28
- */
19
+ /** JPEG encoding. */
29
20
  Format["JPG"] = "jpg";
21
+ /** PNG encoding. */
30
22
  Format["PNG"] = "png";
23
+ /** WebP encoding. */
31
24
  Format["WEBP"] = "webp";
25
+ /** Animated GIF encoding. */
32
26
  Format["GIF"] = "gif";
33
27
  })(Format || (Format = {}));
28
+ /**
29
+ * Visual impairments to simulate when capturing the screenshot.
30
+ * Useful for WCAG accessibility testing.
31
+ */
34
32
  export var VisionDeficiency;
35
33
  (function (VisionDeficiency) {
36
- /**
37
- Simulate vision deficiency for accessibility testing (WCAG compliance)
38
- Attributes:
39
- DEUTERANOPIA: Difficulty distinguishing green from red; green appears beige/gray
40
- PROTANOPIA: Reduced sensitivity to red light; red appears dark/black
41
- TRITANOPIA: Difficulty distinguishing blue from yellow and violet from red
42
- ACHROMATOPSIA: Complete inability to perceive color; sees only in grayscale
43
- REDUCED_CONTRAST: Simulates reduced contrast due to aging, low light, or other factors
44
- BLURRED_VISION: Simulates uncorrected refractive errors or age-related vision loss
45
- */
34
+ /** Difficulty distinguishing green from red; green appears beige/gray. */
46
35
  VisionDeficiency["DEUTERANOPIA"] = "deuteranopia";
36
+ /** Reduced sensitivity to red light; red appears dark/black. */
47
37
  VisionDeficiency["PROTANOPIA"] = "protanopia";
38
+ /** Difficulty distinguishing blue from yellow and violet from red. */
48
39
  VisionDeficiency["TRITANOPIA"] = "tritanopia";
40
+ /** Complete color blindness; the image is grayscale. */
49
41
  VisionDeficiency["ACHROMATOPSIA"] = "achromatopsia";
42
+ /** Reduced contrast (aging, low light). */
50
43
  VisionDeficiency["REDUCED_CONTRAST"] = "reducedContrast";
44
+ /** Blurred vision (uncorrected refractive errors). */
51
45
  VisionDeficiency["BLURRED_VISION"] = "blurredVision";
52
46
  })(VisionDeficiency || (VisionDeficiency = {}));
47
+ /**
48
+ * Configuration for a single screenshot request. Instances are passed
49
+ * to {@link ScrapflyClient.screenshot}; this class is responsible for
50
+ * validating options and encoding them into Scrapfly's query string
51
+ * format.
52
+ */
53
53
  export class ScreenshotConfig {
54
54
  constructor(options) {
55
+ /** URL of the page to screenshot. */
55
56
  Object.defineProperty(this, "url", {
56
57
  enumerable: true,
57
58
  configurable: true,
58
59
  writable: true,
59
60
  value: void 0
60
61
  });
62
+ /** Output image format. */
61
63
  Object.defineProperty(this, "format", {
62
64
  enumerable: true,
63
65
  configurable: true,
64
66
  writable: true,
65
67
  value: void 0
66
68
  });
69
+ /** Capture area (`fullpage`, `viewport`, or a CSS selector). */
67
70
  Object.defineProperty(this, "capture", {
68
71
  enumerable: true,
69
72
  configurable: true,
70
73
  writable: true,
71
74
  value: void 0
72
75
  });
76
+ /** Viewport resolution (`widthxheight`). */
73
77
  Object.defineProperty(this, "resolution", {
74
78
  enumerable: true,
75
79
  configurable: true,
76
80
  writable: true,
77
81
  value: void 0
78
82
  });
83
+ /** Geo-targeting country (ISO code). */
79
84
  Object.defineProperty(this, "country", {
80
85
  enumerable: true,
81
86
  configurable: true,
@@ -185,6 +190,13 @@ export class ScreenshotConfig {
185
190
  }
186
191
  }
187
192
  }
193
+ /**
194
+ * Encode this config as the query-string parameters sent to the
195
+ * Screenshot API.
196
+ *
197
+ * @param options.key Scrapfly API key.
198
+ * @returns A record suitable for `URLSearchParams` construction.
199
+ */
188
200
  toApiParams(options) {
189
201
  const params = {
190
202
  key: options.key,
@@ -3,6 +3,34 @@ export declare enum ResourceType {
3
3
  SCRAPE = "scrape",
4
4
  PING = "ping"
5
5
  }
6
+ /**
7
+ * Verify that a webhook request was sent by Scrapfly by comparing the
8
+ * HMAC-SHA256 signature on the request body against the configured
9
+ * signing secret.
10
+ *
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).
18
+ * @returns `true` if the signature matches.
19
+ */
6
20
  export declare function verifySignature(body: Buffer, signature: string, signingSecret: string): boolean;
21
+ /**
22
+ * Start a tiny Express server that receives Scrapfly webhook callbacks
23
+ * and dispatches them to the provided `callback`. Intended for quick
24
+ * integration and local development; production setups should wire
25
+ * Scrapfly webhooks directly into their own HTTP stack via
26
+ * {@link verifySignature}.
27
+ *
28
+ * Requires the `express` package to be installed.
29
+ *
30
+ * @param callback Invoked with the parsed webhook body, its resource
31
+ * type (`scrape` or `ping`), and the raw Express request.
32
+ * @param app Optional pre-configured Express app to mount on.
33
+ * @returns The underlying Express app (for further configuration or `.listen()`).
34
+ */
7
35
  export declare function createServer(callback: (data: any, resourceType: string, request: any) => void, app?: any): Promise<any>;
8
36
  //# sourceMappingURL=webhookserver.d.ts.map
@@ -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,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAM/F;AAGD,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"}
@@ -6,13 +6,44 @@ export var ResourceType;
6
6
  ResourceType["SCRAPE"] = "scrape";
7
7
  ResourceType["PING"] = "ping";
8
8
  })(ResourceType || (ResourceType = {}));
9
+ /**
10
+ * Verify that a webhook request was sent by Scrapfly by comparing the
11
+ * HMAC-SHA256 signature on the request body against the configured
12
+ * signing secret.
13
+ *
14
+ * @param body Raw request body as received (verify BEFORE any decompression
15
+ * or JSON parsing — the signature is computed on the bytes
16
+ * Scrapfly sent on the wire).
17
+ * @param signature Value of the `X-Scrapfly-Webhook-Signature` header
18
+ * (uppercase hex digest).
19
+ * @param signingSecret Webhook signing secret from the dashboard, passed as-is
20
+ * (UTF-8 string; not hex-encoded).
21
+ * @returns `true` if the signature matches.
22
+ */
9
23
  export function verifySignature(body, signature, signingSecret) {
10
- const secret = Buffer.from(signingSecret, 'hex');
11
- const hmac = crypto.createHmac('sha256', secret);
24
+ const hmac = crypto.createHmac('sha256', Buffer.from(signingSecret, 'utf8'));
12
25
  hmac.update(body);
13
26
  const computed = hmac.digest('hex').toUpperCase();
14
- return computed === signature;
27
+ const received = signature.toUpperCase();
28
+ if (computed.length !== received.length) {
29
+ return false;
30
+ }
31
+ return crypto.timingSafeEqual(Buffer.from(computed), Buffer.from(received));
15
32
  }
33
+ /**
34
+ * Start a tiny Express server that receives Scrapfly webhook callbacks
35
+ * and dispatches them to the provided `callback`. Intended for quick
36
+ * integration and local development; production setups should wire
37
+ * Scrapfly webhooks directly into their own HTTP stack via
38
+ * {@link verifySignature}.
39
+ *
40
+ * Requires the `express` package to be installed.
41
+ *
42
+ * @param callback Invoked with the parsed webhook body, its resource
43
+ * type (`scrape` or `ping`), and the raw Express request.
44
+ * @param app Optional pre-configured Express app to mount on.
45
+ * @returns The underlying Express app (for further configuration or `.listen()`).
46
+ */
16
47
  export async function createServer(callback, app) {
17
48
  let express;
18
49
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scrapfly-sdk",
3
- "version": "0.10.4",
3
+ "version": "0.10.6",
4
4
  "description": "SDK for Scrapfly.io API for web scraping, screenshotting and data extraction",
5
5
  "keywords": [
6
6
  "web scraping",
@@ -1 +1 @@
1
- {"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../src/batch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA0CH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAuB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,CAAC,SAAS,CAAC,CA4HnF;AAoBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,CAAC,CAS9D;AAOD;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,SAAS,GAAG,QAAQ,CAiCxE"}
1
+ {"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../src/batch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAgDH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAuB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,CAAC,SAAS,CAAC,CA4HnF;AAoBD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,SAAS,GAAG,CAAC,CAS9D;AAOD;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,SAAS,GAAG,QAAQ,CAiCxE"}
package/script/batch.js CHANGED
@@ -30,6 +30,12 @@ function indexOf(buf, needle, start = 0) {
30
30
  }
31
31
  return -1;
32
32
  }
33
+ // concat sidesteps the TS 5.7+ generic-Uint8Array vs dnt-Node legacy
34
+ // Uint8Array mismatch by accepting `any` and returning a freshly
35
+ // allocated buffer. The fresh allocation guarantees the result is a
36
+ // `Uint8Array<ArrayBuffer>` at runtime under TS 5.7+ and a plain
37
+ // non-generic `Uint8Array` under dnt's Node target.
38
+ // deno-lint-ignore no-explicit-any
33
39
  function concat(a, b) {
34
40
  const out = new Uint8Array(a.length + b.length);
35
41
  out.set(a, 0);