1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "receiverUrl": "https://postman-echo.com/post",
12 "signatureScheme": "hmac_sha256",
13 "signatureHeader": "X-Signature-256",
14 "signatureTemplate": "sha256={signature}",
15 "signedPayloadTemplate": "{body}",
16 "timestampHeader": "X-Timestamp",
17 "cases": [
18 {
19 "name": "good-delivery",
20 "mode": "valid",
21 "payload": {
22 "event": "ping",
23 "id": "{nonce}",
24 "sentAt": "{timestamp}"
25 },
26 "expectedStatusMin": 200,
27 "expectedStatusMax": 299
28 },
29 {
30 "name": "no-signature-header",
31 "mode": "missing",
32 "payload": {
33 "event": "ping",
34 "id": "{nonce}",
35 "sentAt": "{timestamp}"
36 },
37 "expectedStatusMin": 401,
38 "expectedStatusMax": 403
39 },
40 {
41 "name": "wrong-secret",
42 "mode": "wrong-secret",
43 "payload": {
44 "event": "ping",
45 "id": "{nonce}",
46 "sentAt": "{timestamp}"
47 },
48 "expectedStatusMin": 401,
49 "expectedStatusMax": 403
50 }
51 ],
52 "tamperReplayProbes": false,
53 "probeExpectedStatusMin": 400,
54 "probeExpectedStatusMax": 499,
55 "timeoutSeconds": 10,
56 "maxRequests": 200,
57 "requestsPerSecond": 5,
58 "maxResponseBytes": 65536,
59 "oversizedBodyBytes": 100000,
60 "replayAgeSeconds": 900,
61 "contentType": "application/json",
62 "userAgent": "WebhookContractVerifier/0.1 (+https://apify.com)"
63};
64
65
66const run = await client.actor("kingii98/webhook-receiver-contract-and-signature-rotation-verifier").call(input);
67
68
69console.log('Results from dataset');
70console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
71const { items } = await client.dataset(run.defaultDatasetId).listItems();
72items.forEach((item) => {
73 console.dir(item);
74});
75
76