scrapfly-sdk 0.7.0 → 0.7.2
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.
- package/esm/main.d.ts +1 -0
- package/esm/main.d.ts.map +1 -1
- package/esm/main.js +1 -0
- package/esm/screenshotconfig.d.ts +8 -6
- package/esm/screenshotconfig.d.ts.map +1 -1
- package/esm/screenshotconfig.js +8 -6
- package/esm/webhookserver.d.ts +7 -0
- package/esm/webhookserver.d.ts.map +1 -0
- package/esm/webhookserver.js +55 -0
- package/package.json +3 -2
- package/script/main.d.ts +1 -0
- package/script/main.d.ts.map +1 -1
- package/script/main.js +4 -1
- package/script/screenshotconfig.d.ts +8 -6
- package/script/screenshotconfig.d.ts.map +1 -1
- package/script/screenshotconfig.js +8 -6
- package/script/webhookserver.d.ts +7 -0
- package/script/webhookserver.d.ts.map +1 -0
- package/script/webhookserver.js +86 -0
package/esm/main.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ export * as errors from './errors.js';
|
|
|
6
6
|
export { ExtractionResult, ScrapeResult, ScreenshotResult } from './result.js';
|
|
7
7
|
export type { AccountData, ConfigData, ContextData, ResultData, ScreenshotMetadata } from './result.js';
|
|
8
8
|
export { log } from './logger.js';
|
|
9
|
+
export { createServer, verifySignature } from './webhookserver.js';
|
|
9
10
|
//# sourceMappingURL=main.d.ts.map
|
package/esm/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,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,EAAE,MAAM,IAAI,gBAAgB,EAAE,OAAO,IAAI,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACnH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/E,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACxG,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,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,EAAE,MAAM,IAAI,gBAAgB,EAAE,OAAO,IAAI,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACnH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/E,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACxG,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
|
package/esm/main.js
CHANGED
|
@@ -5,3 +5,4 @@ export { ExtractionConfig } from './extractionconfig.js';
|
|
|
5
5
|
export * as errors from './errors.js';
|
|
6
6
|
export { ExtractionResult, ScrapeResult, ScreenshotResult } from './result.js';
|
|
7
7
|
export { log } from './logger.js';
|
|
8
|
+
export { createServer, verifySignature } from './webhookserver.js';
|
|
@@ -30,17 +30,19 @@ export declare enum VisionDeficiency {
|
|
|
30
30
|
/**
|
|
31
31
|
Simulate vision deficiency for accessibility testing (WCAG compliance)
|
|
32
32
|
Attributes:
|
|
33
|
-
DEUTERANOPIA:
|
|
34
|
-
PROTANOPIA:
|
|
35
|
-
TRITANOPIA:
|
|
36
|
-
ACHROMATOPSIA: Complete color
|
|
37
|
-
|
|
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
|
|
38
39
|
*/
|
|
39
40
|
DEUTERANOPIA = "deuteranopia",
|
|
40
41
|
PROTANOPIA = "protanopia",
|
|
41
42
|
TRITANOPIA = "tritanopia",
|
|
42
43
|
ACHROMATOPSIA = "achromatopsia",
|
|
43
|
-
|
|
44
|
+
REDUCED_CONTRAST = "reducedContrast",
|
|
45
|
+
BLURRED_VISION = "blurredVision"
|
|
44
46
|
}
|
|
45
47
|
type ScreenshotConfigOptions = {
|
|
46
48
|
url: string;
|
|
@@ -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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AY,GAAG,YAAY,GAAG,eAAe,GAAG,eAAe,GAAG,gBAAgB,CAAC;IACxH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,qBAAa,gBAAgB;IAC3B,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,CAAa;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,CAAC,EAAE,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,gBAAgB,CAAC;IACxH,OAAO,CAAC,EAAE,MAAM,CAAC;gBAEL,OAAO,EAAE,uBAAuB;IA+B5C,OAAO,CAAC,eAAe;IASvB,WAAW,CAAC,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAyE3D"}
|
package/esm/screenshotconfig.js
CHANGED
|
@@ -36,17 +36,19 @@ export var VisionDeficiency;
|
|
|
36
36
|
/**
|
|
37
37
|
Simulate vision deficiency for accessibility testing (WCAG compliance)
|
|
38
38
|
Attributes:
|
|
39
|
-
DEUTERANOPIA:
|
|
40
|
-
PROTANOPIA:
|
|
41
|
-
TRITANOPIA:
|
|
42
|
-
ACHROMATOPSIA: Complete color
|
|
43
|
-
|
|
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
|
|
44
45
|
*/
|
|
45
46
|
VisionDeficiency["DEUTERANOPIA"] = "deuteranopia";
|
|
46
47
|
VisionDeficiency["PROTANOPIA"] = "protanopia";
|
|
47
48
|
VisionDeficiency["TRITANOPIA"] = "tritanopia";
|
|
48
49
|
VisionDeficiency["ACHROMATOPSIA"] = "achromatopsia";
|
|
49
|
-
VisionDeficiency["
|
|
50
|
+
VisionDeficiency["REDUCED_CONTRAST"] = "reducedContrast";
|
|
51
|
+
VisionDeficiency["BLURRED_VISION"] = "blurredVision";
|
|
50
52
|
})(VisionDeficiency || (VisionDeficiency = {}));
|
|
51
53
|
export class ScreenshotConfig {
|
|
52
54
|
constructor(options) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare enum ResourceType {
|
|
2
|
+
SCRAPE = "scrape",
|
|
3
|
+
PING = "ping"
|
|
4
|
+
}
|
|
5
|
+
export declare function verifySignature(body: Buffer, signature: string, signingSecret: string): boolean;
|
|
6
|
+
export declare function createServer(callback: (data: any, resourceType: string, request: any) => void, app?: any): Promise<any>;
|
|
7
|
+
//# sourceMappingURL=webhookserver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhookserver.d.ts","sourceRoot":"","sources":["../src/webhookserver.ts"],"names":[],"mappings":"AAGA,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"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import { log } from './logger.js';
|
|
3
|
+
export var ResourceType;
|
|
4
|
+
(function (ResourceType) {
|
|
5
|
+
ResourceType["SCRAPE"] = "scrape";
|
|
6
|
+
ResourceType["PING"] = "ping";
|
|
7
|
+
})(ResourceType || (ResourceType = {}));
|
|
8
|
+
export function verifySignature(body, signature, signingSecret) {
|
|
9
|
+
const secret = Buffer.from(signingSecret, 'hex');
|
|
10
|
+
const hmac = crypto.createHmac('sha256', secret);
|
|
11
|
+
hmac.update(body);
|
|
12
|
+
const computed = hmac.digest('hex').toUpperCase();
|
|
13
|
+
return computed === signature;
|
|
14
|
+
}
|
|
15
|
+
export async function createServer(callback, app) {
|
|
16
|
+
let express;
|
|
17
|
+
try {
|
|
18
|
+
const expressModule = await import('express');
|
|
19
|
+
express = expressModule.default || expressModule;
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
throw new Error('express is not installed, please install it with `npm install express`');
|
|
23
|
+
}
|
|
24
|
+
if (!app) {
|
|
25
|
+
app = express();
|
|
26
|
+
}
|
|
27
|
+
const jsonMiddleware = express.json({
|
|
28
|
+
verify: (req, _res, buf) => {
|
|
29
|
+
req.rawBody = buf;
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
app.post('/webhook', jsonMiddleware, (req, res) => {
|
|
33
|
+
try {
|
|
34
|
+
const resourceType = req.headers['x-scrapfly-webhook-resource-type'];
|
|
35
|
+
if (resourceType !== 'scrape' && resourceType !== 'ping') {
|
|
36
|
+
log.error(`Unsupported resource type: ${resourceType}`);
|
|
37
|
+
return res.status(400).send(`this webhook server only supports scrape and ping calls`);
|
|
38
|
+
}
|
|
39
|
+
const data = req.body;
|
|
40
|
+
try {
|
|
41
|
+
callback(data, resourceType, req);
|
|
42
|
+
res.status(200).send('');
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
log.error('Callback error:', e);
|
|
46
|
+
res.status(500).send('');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
log.error('Webhook processing error:', e);
|
|
51
|
+
res.status(400).send('');
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return app;
|
|
55
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scrapfly-sdk",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "SDK for Scrapfly.io API for web scraping, screenshotting and data extraction",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web scraping",
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
"@deno/shim-deno": "~0.18.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@types/node": "^20.9.0"
|
|
35
|
+
"@types/node": "^20.9.0",
|
|
36
|
+
"@types/express": "^4.17.21"
|
|
36
37
|
},
|
|
37
38
|
"_generatedBy": "dnt@dev"
|
|
38
39
|
}
|
package/script/main.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ export * as errors from './errors.js';
|
|
|
6
6
|
export { ExtractionResult, ScrapeResult, ScreenshotResult } from './result.js';
|
|
7
7
|
export type { AccountData, ConfigData, ContextData, ResultData, ScreenshotMetadata } from './result.js';
|
|
8
8
|
export { log } from './logger.js';
|
|
9
|
+
export { createServer, verifySignature } from './webhookserver.js';
|
|
9
10
|
//# sourceMappingURL=main.d.ts.map
|
package/script/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,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,EAAE,MAAM,IAAI,gBAAgB,EAAE,OAAO,IAAI,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACnH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/E,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACxG,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,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,EAAE,MAAM,IAAI,gBAAgB,EAAE,OAAO,IAAI,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACnH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/E,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACxG,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.log = exports.ScreenshotResult = exports.ScrapeResult = exports.ExtractionResult = exports.errors = exports.ExtractionConfig = 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.ScreenshotResult = exports.ScrapeResult = exports.ExtractionResult = exports.errors = exports.ExtractionConfig = exports.ScreenshotConfig = exports.ScreenshotOptions = exports.ScreenshotFormat = exports.ScreenshotFlags = exports.ScrapeConfig = exports.ScrapeFormatOptions = exports.ScrapeFormat = exports.ScrapflyClient = void 0;
|
|
27
27
|
var client_js_1 = require("./client.js");
|
|
28
28
|
Object.defineProperty(exports, "ScrapflyClient", { enumerable: true, get: function () { return client_js_1.ScrapflyClient; } });
|
|
29
29
|
var scrapeconfig_js_1 = require("./scrapeconfig.js");
|
|
@@ -44,3 +44,6 @@ Object.defineProperty(exports, "ScrapeResult", { enumerable: true, get: function
|
|
|
44
44
|
Object.defineProperty(exports, "ScreenshotResult", { enumerable: true, get: function () { return result_js_1.ScreenshotResult; } });
|
|
45
45
|
var logger_js_1 = require("./logger.js");
|
|
46
46
|
Object.defineProperty(exports, "log", { enumerable: true, get: function () { return logger_js_1.log; } });
|
|
47
|
+
var webhookserver_js_1 = require("./webhookserver.js");
|
|
48
|
+
Object.defineProperty(exports, "createServer", { enumerable: true, get: function () { return webhookserver_js_1.createServer; } });
|
|
49
|
+
Object.defineProperty(exports, "verifySignature", { enumerable: true, get: function () { return webhookserver_js_1.verifySignature; } });
|
|
@@ -30,17 +30,19 @@ export declare enum VisionDeficiency {
|
|
|
30
30
|
/**
|
|
31
31
|
Simulate vision deficiency for accessibility testing (WCAG compliance)
|
|
32
32
|
Attributes:
|
|
33
|
-
DEUTERANOPIA:
|
|
34
|
-
PROTANOPIA:
|
|
35
|
-
TRITANOPIA:
|
|
36
|
-
ACHROMATOPSIA: Complete color
|
|
37
|
-
|
|
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
|
|
38
39
|
*/
|
|
39
40
|
DEUTERANOPIA = "deuteranopia",
|
|
40
41
|
PROTANOPIA = "protanopia",
|
|
41
42
|
TRITANOPIA = "tritanopia",
|
|
42
43
|
ACHROMATOPSIA = "achromatopsia",
|
|
43
|
-
|
|
44
|
+
REDUCED_CONTRAST = "reducedContrast",
|
|
45
|
+
BLURRED_VISION = "blurredVision"
|
|
44
46
|
}
|
|
45
47
|
type ScreenshotConfigOptions = {
|
|
46
48
|
url: string;
|
|
@@ -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,aA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var VisionDeficiency;
|
|
|
39
39
|
/**
|
|
40
40
|
Simulate vision deficiency for accessibility testing (WCAG compliance)
|
|
41
41
|
Attributes:
|
|
42
|
-
DEUTERANOPIA:
|
|
43
|
-
PROTANOPIA:
|
|
44
|
-
TRITANOPIA:
|
|
45
|
-
ACHROMATOPSIA: Complete color
|
|
46
|
-
|
|
42
|
+
DEUTERANOPIA: Difficulty distinguishing green from red; green appears beige/gray
|
|
43
|
+
PROTANOPIA: Reduced sensitivity to red light; red appears dark/black
|
|
44
|
+
TRITANOPIA: Difficulty distinguishing blue from yellow and violet from red
|
|
45
|
+
ACHROMATOPSIA: Complete inability to perceive color; sees only in grayscale
|
|
46
|
+
REDUCED_CONTRAST: Simulates reduced contrast due to aging, low light, or other factors
|
|
47
|
+
BLURRED_VISION: Simulates uncorrected refractive errors or age-related vision loss
|
|
47
48
|
*/
|
|
48
49
|
VisionDeficiency["DEUTERANOPIA"] = "deuteranopia";
|
|
49
50
|
VisionDeficiency["PROTANOPIA"] = "protanopia";
|
|
50
51
|
VisionDeficiency["TRITANOPIA"] = "tritanopia";
|
|
51
52
|
VisionDeficiency["ACHROMATOPSIA"] = "achromatopsia";
|
|
52
|
-
VisionDeficiency["
|
|
53
|
+
VisionDeficiency["REDUCED_CONTRAST"] = "reducedContrast";
|
|
54
|
+
VisionDeficiency["BLURRED_VISION"] = "blurredVision";
|
|
53
55
|
})(VisionDeficiency || (exports.VisionDeficiency = VisionDeficiency = {}));
|
|
54
56
|
class ScreenshotConfig {
|
|
55
57
|
constructor(options) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare enum ResourceType {
|
|
2
|
+
SCRAPE = "scrape",
|
|
3
|
+
PING = "ping"
|
|
4
|
+
}
|
|
5
|
+
export declare function verifySignature(body: Buffer, signature: string, signingSecret: string): boolean;
|
|
6
|
+
export declare function createServer(callback: (data: any, resourceType: string, request: any) => void, app?: any): Promise<any>;
|
|
7
|
+
//# sourceMappingURL=webhookserver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhookserver.d.ts","sourceRoot":"","sources":["../src/webhookserver.ts"],"names":[],"mappings":"AAGA,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"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.ResourceType = void 0;
|
|
30
|
+
exports.verifySignature = verifySignature;
|
|
31
|
+
exports.createServer = createServer;
|
|
32
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
33
|
+
const logger_js_1 = require("./logger.js");
|
|
34
|
+
var ResourceType;
|
|
35
|
+
(function (ResourceType) {
|
|
36
|
+
ResourceType["SCRAPE"] = "scrape";
|
|
37
|
+
ResourceType["PING"] = "ping";
|
|
38
|
+
})(ResourceType || (exports.ResourceType = ResourceType = {}));
|
|
39
|
+
function verifySignature(body, signature, signingSecret) {
|
|
40
|
+
const secret = Buffer.from(signingSecret, 'hex');
|
|
41
|
+
const hmac = node_crypto_1.default.createHmac('sha256', secret);
|
|
42
|
+
hmac.update(body);
|
|
43
|
+
const computed = hmac.digest('hex').toUpperCase();
|
|
44
|
+
return computed === signature;
|
|
45
|
+
}
|
|
46
|
+
async function createServer(callback, app) {
|
|
47
|
+
let express;
|
|
48
|
+
try {
|
|
49
|
+
const expressModule = await Promise.resolve().then(() => __importStar(require('express')));
|
|
50
|
+
express = expressModule.default || expressModule;
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
throw new Error('express is not installed, please install it with `npm install express`');
|
|
54
|
+
}
|
|
55
|
+
if (!app) {
|
|
56
|
+
app = express();
|
|
57
|
+
}
|
|
58
|
+
const jsonMiddleware = express.json({
|
|
59
|
+
verify: (req, _res, buf) => {
|
|
60
|
+
req.rawBody = buf;
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
app.post('/webhook', jsonMiddleware, (req, res) => {
|
|
64
|
+
try {
|
|
65
|
+
const resourceType = req.headers['x-scrapfly-webhook-resource-type'];
|
|
66
|
+
if (resourceType !== 'scrape' && resourceType !== 'ping') {
|
|
67
|
+
logger_js_1.log.error(`Unsupported resource type: ${resourceType}`);
|
|
68
|
+
return res.status(400).send(`this webhook server only supports scrape and ping calls`);
|
|
69
|
+
}
|
|
70
|
+
const data = req.body;
|
|
71
|
+
try {
|
|
72
|
+
callback(data, resourceType, req);
|
|
73
|
+
res.status(200).send('');
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
logger_js_1.log.error('Callback error:', e);
|
|
77
|
+
res.status(500).send('');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
logger_js_1.log.error('Webhook processing error:', e);
|
|
82
|
+
res.status(400).send('');
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return app;
|
|
86
|
+
}
|