RepoCloudflare (Workers AI)Cloudflare (Workers AI)published Jun 4, 2024seen 5d

cloudflare/matched-data-worker

TypeScript

Open original ↗

Captured source

source ↗
published Jun 4, 2024seen 5dcaptured 9hhttp 200method plain

cloudflare/matched-data-worker

Language: TypeScript

License: MIT

Stars: 7

Forks: 7

Open issues: 2

Created: 2024-06-04T13:37:10Z

Pushed: 2026-04-28T09:51:18Z

Default branch: main

Fork: no

Archived: no

README:

Matched Data JS

Logpush Setup

1. Dataset:

  • Firewall Events

2. Select Data Fields:

  • Required: General > Metadata
  • Any others are optional

3. Select Destination:

  • S3 Compatible

4. Enter Destination Info (see example below):

  • Given the final URL you want to use is ./logs:
  • and ` are arbitrary
  • logs is required according to the default configuration of the worker
  • _S3 Compatible Bucket Path_: /logs
  • _Endpoint URL_: ``
  • All other fields can be arbitrary values

Logpush Setup Example

![destination-example.png](destination-example.png)

Configure and Deploy

1. Edit wrangler.toml to add DOMAIN, SUBDOMAIN, and ACCOUNTID. 2. Edit src/index.ts to send the decoded data anywhere you would like. 3. Run npx wrangler secret put MATCHED_PAYLOAD_PRIVATE_KEY:

  • Enter the private key generated when deploying a matched payload.
  • Refer to the documentation for more information on generating the private/public key pair.
  • If you want to use GCS, you also need GCS_BUCKET_NAME and GCS_ACCESS_KEY_JSON.

4. Run npm run deploy.

Destinations

Currently supported destinations:

  • Google Cloud Storage

An example src/destinations/counter.ts is given if you want to implement any others.

Matched Payload Format

The matched data payload is base64 encoded, and then binary encoded using the following format:

[version: 1 byte][encapped key: 32 bytes][payload size: 8 bytes][payload: N bytes]

Local testing

1. Run echo 'MATCHED_PAYLOAD_PRIVATE_KEY=uBS5eBttHrqkdY41kbZPdvYnNz8Vj0TvKIUpjB1y/GA=' > .dev.vars (taken from https://github.com/cloudflare/matched-data-cli). 2. In terminal window 1, run: npm run dev. 3. In terminal window 2, run: npm run req. 4. Back in terminal window 1, you should see 'test matched data'.

See Also

https://github.com/cloudflare/matched-data-cli