diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..b73854c
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+worker/worker-configuration.d.ts linguist-generated=true
diff --git a/AGENTS.md b/AGENTS.md
index 4c37a66..ae70dae 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -1,6 +1,6 @@
# WithMarfa website
-The source of the public site at `withmarfa.com`: Astro, built to static files and served as a Cloudflare Worker with static assets only. GitHub Actions builds every pull request and deploys `main`.
+The source of the public site at `withmarfa.com`: Astro, built to static files and served as a Cloudflare Worker. Every page is a static asset; the Worker's code runs only for `/api/*`, which today is the sign-up form. GitHub Actions builds every pull request and deploys `main`.
## Conventions
@@ -14,21 +14,24 @@ The source of the public site at `withmarfa.com`: Astro, built to static files a
## Layout
-- `src/pages/`: one file per page. `404.astro` is what Cloudflare serves for a missing path.
+- `src/pages/`: one file per page. `404.astro` is what Cloudflare serves for a missing path. `sitemap.xml.ts` lists every page except those in its `UNLISTED` set.
- `src/layouts/Base.astro`: the document head, the header, the column and the footer, used by every page.
-- `src/components/`: the header (the Docs pill, and the way home on every other page), the footer (About, Contact and GitHub), and the question that opens.
+- `src/components/`: the header (the Marfa mark, which leads home, a GitHub icon and the Docs pill), the footer (About, the Contact card and Privacy), the question that opens (one at a time within a group), and the sign-up form.
- `src/styles/global.css`: the color tokens, shared with the docs site's canvas and text colors. Light and dark follow the system; there is no toggle.
- `src/lib/analytics.ts`: PostHog, loaded after the page.
-- `public/`: copied as is. `_headers` sets the security headers and the Content Security Policy.
+- `public/`: copied as is. `_headers` sets the security headers and the Content Security Policy. `og.png` is the link preview image, rendered from `scripts/og-image.html`.
+- `worker/index.ts`: the Worker, which answers `POST /api/subscribe`. `worker/worker-configuration.d.ts` is generated by `pnpm types` from `wrangler.jsonc`; regenerate it whenever bindings change, or `pnpm check` fails.
+- `migrations/`: the D1 schema for sign-ups.
## Commands
```bash
pnpm install
pnpm dev # http://localhost:4321
-pnpm check # astro check, the type check
+pnpm check # type checks for the site and the Worker
+pnpm types # regenerate the Worker's binding types
pnpm build # static files in dist/
-pnpm preview # build, then serve dist/ with Wrangler as Cloudflare will
+pnpm preview # build, then serve dist/ and the Worker with Wrangler as Cloudflare will
```
## Deploying
@@ -39,6 +42,14 @@ pnpm preview # build, then serve dist/ with Wrangler as Cloudflare will
- A build without `PUBLIC_POSTHOG_KEY` sends nothing, which is what a fork or a local build gets.
- The fallback when the workflow cannot deploy is `pnpm run build && pnpm exec wrangler deploy` from a shell authenticated to the WithMarfa account.
+## Sign-ups
+
+- The form on About posts to `/api/subscribe`. The Worker checks that the request comes from this site, limits each IP address to five tries a minute, ignores bots that fill the hidden `website` field, and keeps the address, lowercased, with the time in the `signups` table of the D1 database `withmarfa-website` (EU jurisdiction). A repeat address changes nothing and gets the same reply, so the form never reveals who is on the list.
+- With JavaScript the form shows the result in place; without it the Worker redirects to `/subscribed` or `/subscribe-failed`.
+- Nothing logs an address. Invocation logs and traces are off, because they would keep each visitor's location and browser beside the time of their sign-up; only the Worker's own log lines are kept. To read the list, from a shell authenticated to the WithMarfa account: `pnpm exec wrangler d1 execute withmarfa-website --remote --command "SELECT email, created_at FROM signups ORDER BY created_at"`. To remove someone, `DELETE FROM signups WHERE email = '…'`.
+- A schema change is a new file in `migrations/`, applied with `pnpm exec wrangler d1 migrations apply withmarfa-website --remote` before the code that needs it is merged. The deploy does not apply migrations.
+- `src/pages/privacy.astro` says what is kept and why. Change it in the same pull request as anything that changes what the site collects.
+
## Analytics
- Page views, page leaves and unhandled errors go to the PostHog project the docs and status sites use, with `site: 'website'` on every event. Nothing else is captured.
@@ -52,6 +63,8 @@ Report only a problem you can show: name the page, input or step, and what goes
- **Untrue about Marfa.** Flag a claim about what Marfa does, where it runs or what it costs that withmarfa/marfa or docs.marfa.so contradicts. Never say Marfa Cloud is free.
- **Deploy weakened.** Flag a `paths` filter on `ci.yml`, a renamed `Build and check` job, or a deploy that no longer checks the live site.
- **Analytics grown.** Flag an option in `src/lib/analytics.ts` that turns on autocapture, replay, surveys, flags, cookies or storage, or a static import of `posthog-js`.
-- **Policy broken.** Flag an inline script or style, or a new third-party origin, that `public/_headers` does not allow.
+- **Policy broken.** Flag an inline script or style, or a new third-party origin, that `public/_headers` does not allow. `vite.build.assetsInlineLimit: 0` in `astro.config.mjs` keeps Astro from inlining small scripts.
+- **Sign-ups exposed.** Flag code that logs an email address, returns one, tells a visitor whether an address is already on the list, or adds a route that reads the list.
+- **Privacy page untrue.** Flag a change to what the site collects or where it keeps it that leaves `privacy.astro` unchanged.
- **Private detail committed.** Flag a token, key, account ID, internal hostname or personal path in a tracked file.
- **Stale instructions.** Flag a change that leaves this file, the README or a comment untrue, and fix it in the same pull request.
diff --git a/README.md b/README.md
index aa3fc1f..65493a8 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,9 @@ pnpm install
pnpm dev
```
-The site runs at `http://localhost:4321`. To check types and build the static files:
+The site runs at `http://localhost:4321`. The sign-up form needs the Worker as well; `pnpm preview` builds the site and serves both with Wrangler, after `pnpm exec wrangler d1 migrations apply withmarfa-website --local` has created the local database.
+
+To check types and build the static files:
```bash
pnpm check
diff --git a/astro.config.mjs b/astro.config.mjs
index 5d7c45a..446d20c 100644
--- a/astro.config.mjs
+++ b/astro.config.mjs
@@ -4,6 +4,10 @@ import { defineConfig } from 'astro/config';
export default defineConfig({
site: 'https://withmarfa.com',
output: 'static',
+ // Astro 7's default ('jsx') drops a line break before an inline element,
+ // so prose wrapped in the source loses its space ("TheAbout ").
+ // `true` compresses without changing what renders.
+ compressHTML: true,
trailingSlash: 'never',
build: {
// `about.html` rather than `about/index.html`, so Cloudflare serves
@@ -13,4 +17,11 @@ export default defineConfig({
// in `public/_headers` needs no 'unsafe-inline'.
inlineStylesheets: 'never',
},
+ vite: {
+ build: {
+ // Astro inlines a script smaller than this limit, and the Content
+ // Security Policy blocks inline scripts, so every script stays a file.
+ assetsInlineLimit: 0,
+ },
+ },
});
diff --git a/migrations/0001_signups.sql b/migrations/0001_signups.sql
new file mode 100644
index 0000000..0de2099
--- /dev/null
+++ b/migrations/0001_signups.sql
@@ -0,0 +1,5 @@
+-- One row for each address that asked for updates about Marfa.
+CREATE TABLE signups (
+ email TEXT PRIMARY KEY,
+ created_at TEXT NOT NULL
+);
diff --git a/package.json b/package.json
index e9c129f..137477b 100644
--- a/package.json
+++ b/package.json
@@ -9,8 +9,9 @@
},
"scripts": {
"dev": "astro dev",
- "check": "astro check",
+ "check": "astro check && wrangler types worker/worker-configuration.d.ts --check && tsc -p worker",
"build": "astro build",
+ "types": "wrangler types worker/worker-configuration.d.ts",
"preview": "pnpm run build && wrangler dev"
},
"dependencies": {
diff --git a/public/favicon.svg b/public/favicon.svg
new file mode 100644
index 0000000..ea8fd4c
--- /dev/null
+++ b/public/favicon.svg
@@ -0,0 +1,10 @@
+
+ Marfa
+
+
+
+
+
+
+
+
diff --git a/public/og.png b/public/og.png
new file mode 100644
index 0000000..f1d08e2
Binary files /dev/null and b/public/og.png differ
diff --git a/public/robots.txt b/public/robots.txt
index c2a49f4..d76985a 100644
--- a/public/robots.txt
+++ b/public/robots.txt
@@ -1,2 +1,4 @@
User-agent: *
Allow: /
+
+Sitemap: https://withmarfa.com/sitemap.xml
diff --git a/scripts/og-image.html b/scripts/og-image.html
new file mode 100644
index 0000000..a0c3c7c
--- /dev/null
+++ b/scripts/og-image.html
@@ -0,0 +1,15 @@
+
+
+
+
Marfa A shared data layer for your apps
+
diff --git a/src/components/Footer.astro b/src/components/Footer.astro
index 737965c..9bde17f 100644
--- a/src/components/Footer.astro
+++ b/src/components/Footer.astro
@@ -1,44 +1,163 @@
---
-const path = Astro.url.pathname.replace(/(\/index)?\.html$/, '') || '/';
+import { pagePath } from '../lib/path';
+/**
+ * The footer, and the Contact card it opens. The card shows the address before
+ * anything opens a mail app, and offers to copy it instead.
+ */
+const path = pagePath(Astro.url);
+const EMAIL = 'hello@withmarfa.com';
---
+
+
+
+
diff --git a/src/components/Header.astro b/src/components/Header.astro
index c164dfb..6309d8d 100644
--- a/src/components/Header.astro
+++ b/src/components/Header.astro
@@ -1,16 +1,38 @@
---
-/** The docs, and on every page but home, the way back home. */
-const path = Astro.url.pathname.replace(/(\/index)?\.html$/, '') || '/';
+import { pagePath } from '../lib/path';
+/**
+ * The Marfa mark, which leads home, and the two ways out: GitHub and the docs.
+ * The mark is the docs' favicon.svg, drawn in the page's colors.
+ */
+const path = pagePath(Astro.url);
---
diff --git a/src/components/Subscribe.astro b/src/components/Subscribe.astro
new file mode 100644
index 0000000..c24ee8a
--- /dev/null
+++ b/src/components/Subscribe.astro
@@ -0,0 +1,171 @@
+---
+/**
+ * Signs someone up for updates. Without JavaScript the form posts and the
+ * Worker redirects to /subscribed or /subscribe-failed; with it, the result shows in place. The
+ * `website` field is left empty by people and filled by bots, which the Worker
+ * then ignores.
+ */
+---
+
+
+
+
+
+
diff --git a/src/layouts/Base.astro b/src/layouts/Base.astro
index 654ad90..f83d8fa 100644
--- a/src/layouts/Base.astro
+++ b/src/layouts/Base.astro
@@ -2,17 +2,18 @@
import '../styles/global.css';
import Header from '../components/Header.astro';
import Footer from '../components/Footer.astro';
+import { pagePath } from '../lib/path';
interface Props {
title: string;
description: string;
- /** Off for the 404 page, which has no address of its own. */
+ /** Off for pages search engines should skip, such as the 404 page. */
indexable?: boolean;
}
const { title, description, indexable = true } = Astro.props;
-// Pages build to `about.html`, which Cloudflare serves at `/about`.
-const canonical = new URL(Astro.url.pathname.replace(/(\/index)?\.html$/, '') || '/', Astro.site);
+const canonical = new URL(pagePath(Astro.url), Astro.site);
+const image = new URL('/og.png', Astro.site).href;
---
@@ -25,14 +26,21 @@ const canonical = new URL(Astro.url.pathname.replace(/(\/index)?\.html$/, '') ||
{title}
- {indexable && }
-
+ {indexable ? : }
+
+
{indexable && }
+
+
+
+
+
+
diff --git a/src/lib/path.ts b/src/lib/path.ts
new file mode 100644
index 0000000..9fb2cf0
--- /dev/null
+++ b/src/lib/path.ts
@@ -0,0 +1,8 @@
+/**
+ * A page's path as people see it. Pages build to `about.html`, which
+ * Cloudflare serves at `/about`, so the build-time path loses `.html` and
+ * `index`.
+ */
+export function pagePath(url: URL): string {
+ return url.pathname.replace(/(\/index)?\.html$/, '') || '/';
+}
diff --git a/src/pages/about.astro b/src/pages/about.astro
index c106ca2..f66caa2 100644
--- a/src/pages/about.astro
+++ b/src/pages/about.astro
@@ -1,34 +1,43 @@
---
import Base from '../layouts/Base.astro';
+import Subscribe from '../components/Subscribe.astro';
/** What's next. `now` marks the step in progress, shown in bold. */
const next = [
- { when: 'Early October', what: 'Development versions are public, with the code.' },
- { when: 'Late October', what: 'Marfa 0.1, the first semi-stable release.', now: true },
- { when: 'Early November', what: 'The Mac and iOS apps on TestFlight for an early group.' },
- { when: 'Late November', what: 'Public TestFlight for the Mac and iOS apps.' },
- { when: 'December', what: 'More apps and connectors, and Marfa Cloud in testing.' },
+ { when: 'Early October', what: 'Development builds, open source' },
+ { when: 'Late October', what: 'Marfa 0.1, the first semi-stable release', now: true },
+ { when: 'Early November', what: 'The Mac and iOS apps with early testers' },
+ { when: 'Late November', what: 'Public TestFlight, Marfa Cloud in testing, and the full website' },
];
---
About
- Marfa started as my own way of managing my data: one place that the apps and tools I use could all work from.
- Over this year it went through several rounds of building and testing. It began as a hosted service, and this
- autumn I rebuilt it as something you run yourself, with a Rust core under its command-line tool and native apps.
- This is the version I’m building on now.
+ Marfa grew out of a frustration. After trying more apps than I can count, every switch meant leaving something
+ behind. It also draws on experience with customer data platforms, where one well-modelled source of data is the
+ whole point.
- It’s a personal project, not a business. I maintain it, I’ll keep maintaining it, and I’ll keep building apps on
- it. It’s open source so that anyone can run it, build on it or take it somewhere new.
+ That matters more now that agents can build an app in an afternoon. Apps can come and go; the data underneath
+ should last, and make sense to whatever reads it next.
+
+
+ Marfa has been rebuilt more than once this year. It began as a hosted service that tried to be compatible with
+ everything, which pulled it away from what mattered most: a sound data model and a server you can rely on. So it
+ became something you run yourself, with a Rust core under its command-line tool and native apps. Marfa Cloud will
+ follow as an optional relay for reaching it from anywhere, without holding your data.
+
+
+ It’s a personal project, not a business. It ships when it works, not before. Marfa is free and open source, so anyone
+ can run it, build on it or take it somewhere new.
What’s next
-
+
{
next.map((step) => (
@@ -37,26 +46,33 @@ const next = [
))
}
-
+
- Get in touch
- For questions, ideas or something you’ve built on Marfa, email hello@withmarfa.com .
+ Follow along
+
+ Marfa is being shaped with a small group of early testers. Leave your email to hear as the apps open up and new
+ things ship.
+
+
diff --git a/src/pages/index.astro b/src/pages/index.astro
index 3c895a0..3ef84c2 100644
--- a/src/pages/index.astro
+++ b/src/pages/index.astro
@@ -1,44 +1,50 @@
---
import Base from '../layouts/Base.astro';
import Question from '../components/Question.astro';
+
+/** Gives Google the site's name for its results. */
+const site = {
+ '@context': 'https://schema.org',
+ '@type': 'WebSite',
+ name: 'Marfa',
+ alternateName: 'WithMarfa',
+ url: 'https://withmarfa.com/',
+};
---
+
+
Introducing Marfa
- Marfa is a shared, typed data layer for your apps. You define the kinds of things you keep and how they relate,
- and every app, agent or script you allow works from the same data.
-
-
- Most apps keep their own copy of your data, in their own shape. With Marfa, apps become views onto data you
- already own: one app writes something, another shows it differently, a third combines it with something else. You
- can swap an app, or build one for yourself, without moving anything.
+ Marfa is a shared data layer for your apps. You decide what kinds of things you keep and how they connect, and
+ every app, script or AI agent you allow works from the same data.
- Marfa runs on your own Mac or on Railway, and Marfa Cloud will be an optional way to reach it from anywhere. The
- apps WithMarfa makes are native, starting on Mac, iPhone and iPad. Marfa is free and open source.
+ Most apps keep their own copy of your data, in their own shape. With Marfa, apps become views onto data you own.
+ Switch apps, use several at once or build your own, and nothing has to move.
-
+
- An app asks for the types it needs, you approve, and it sees those and nothing else. Several apps can work on
- the same data, each in its own way, and none of them owns it.
+ Developers can run Marfa today from the code on GitHub . The
+ Mac and iOS apps open to early testers in November, then to everyone on TestFlight later that month.
+ Get updates to hear when.
-
+
- On your own Marfa, which runs on your own Mac or on Railway. Marfa Cloud will be an optional way to reach it
- from anywhere, and it holds none of your data.
+ iCloud keeps each app’s data in that app’s own space. Marfa keeps one set of data that any app you allow can
+ read and write, in a structure you define, on a Marfa you run.
-
+
- Yes, on the same open API that WithMarfa’s apps use. There are Swift and TypeScript SDKs, a command-line tool
- for scripts and agents, and connectors that bring in data from GitHub, Todoist, Readwise and RSS.
+ Marfa is free and open source. Run it on your own Mac, or on Railway, which bills you for hosting.
@@ -46,6 +52,6 @@ import Question from '../components/Question.astro';
diff --git a/src/pages/privacy.astro b/src/pages/privacy.astro
new file mode 100644
index 0000000..579bffc
--- /dev/null
+++ b/src/pages/privacy.astro
@@ -0,0 +1,40 @@
+---
+import Base from '../layouts/Base.astro';
+---
+
+
+ Privacy
+
+ This site collects as little as it can. It sets no cookies and stores nothing on your device, so there’s nothing
+ to accept.
+
+
+ Page views
+
+ Visits are counted with PostHog, in the EU. Each page view records the page, the site that sent you, your browser,
+ device type, language and time zone. If something on a page fails, the error is recorded too. Your IP address isn’t
+ stored, and nothing follows you from one day to the next.
+
+
+ Updates
+
+ If you sign up for updates, your email address and the time you signed up are kept in a database in the EU, run
+ by Cloudflare. They’re used only to email you news about Marfa, and they’re never sold or shared.
+
+
+ Your data
+
+ To be removed from updates, or to ask what’s held about you, email
+ hello@withmarfa.com . WithMarfa is responsible for this data.
+
+
+ Last updated 21 October 2026.
+
+
+
diff --git a/src/pages/sitemap.xml.ts b/src/pages/sitemap.xml.ts
new file mode 100644
index 0000000..34810bd
--- /dev/null
+++ b/src/pages/sitemap.xml.ts
@@ -0,0 +1,20 @@
+import type { APIRoute } from 'astro';
+
+/** Pages that are not for search: the 404 page and the sign-up results. */
+const UNLISTED = new Set(['404', 'subscribed', 'subscribe-failed']);
+
+const pages = Object.keys(import.meta.glob('./*.astro'))
+ .map((file) => file.slice(2, -'.astro'.length))
+ .filter((name) => !UNLISTED.has(name))
+ .map((name) => (name === 'index' ? '/' : `/${name}`))
+ .sort();
+
+export const GET: APIRoute = ({ site }) => {
+ const urls = pages.map((path) => ` ${new URL(path, site).href} `).join('\n');
+ const body = `
+
+${urls}
+
+`;
+ return new Response(body, { headers: { 'Content-Type': 'application/xml' } });
+};
diff --git a/src/pages/subscribe-failed.astro b/src/pages/subscribe-failed.astro
new file mode 100644
index 0000000..ac0b0bb
--- /dev/null
+++ b/src/pages/subscribe-failed.astro
@@ -0,0 +1,11 @@
+---
+import Base from '../layouts/Base.astro';
+---
+
+
+ That didn’t work
+
+ Your address wasn’t added. Check that it’s a full email address, or wait a minute if you’ve tried several times,
+ then try again .
+
+
diff --git a/src/pages/subscribed.astro b/src/pages/subscribed.astro
new file mode 100644
index 0000000..8d1a33b
--- /dev/null
+++ b/src/pages/subscribed.astro
@@ -0,0 +1,8 @@
+---
+import Base from '../layouts/Base.astro';
+---
+
+
+ You’re on the list
+ Thanks. You’ll hear when there’s news. Back to the home page .
+
diff --git a/src/styles/global.css b/src/styles/global.css
index cdbb1c7..4146d84 100644
--- a/src/styles/global.css
+++ b/src/styles/global.css
@@ -5,19 +5,24 @@
color-scheme: light dark;
--bg: #fdfdfc;
--text: #0a0a0a;
+ --secondary: #404040;
--muted: #737373;
- --rule: #e5e5e5;
+ --rule: #e8e8e6;
--line: #d4d4d4;
--font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', system-ui, sans-serif;
/* Type and spacing, smaller on phones (below). */
--gutter: 24px;
- --text-size: 17px;
- --text-leading: 1.65;
- --small-size: 16px;
- --title-size: 28px;
- --gap: 20px;
- --top: 56px;
+ --text-size: 16px;
+ --text-leading: 1.6;
+ --small-size: 15px;
+ --title-size: 26px;
+ --gap: 16px;
+ /* Space above a section heading. */
+ --section: 40px;
+ /* Lowers the page's text on tall windows without pushing it off short ones. */
+ --top: clamp(40px, 11vh, 120px);
+ --end: 40px;
--header-top: 24px;
/* Lets an opening question animate to its natural height where supported. */
@@ -28,6 +33,7 @@
:root {
--bg: #121212;
--text: #ebebeb;
+ --secondary: #c2c2c2;
--muted: #939393;
--rule: #262626;
--line: #3a3a3a;
@@ -38,11 +44,13 @@
:root {
--gutter: 20px;
--text-size: 15px;
- --text-leading: 1.6;
- --small-size: 15px;
- --title-size: 24px;
+ --text-leading: 1.55;
+ --small-size: 14px;
+ --title-size: 22px;
--gap: 14px;
- --top: 24px;
+ --section: 24px;
+ --top: clamp(20px, 4vh, 40px);
+ --end: 16px;
--header-top: 10px;
}
}
@@ -71,28 +79,29 @@ body {
background: color-mix(in srgb, var(--text) 16%, transparent);
}
+/* About 70 characters a line at the body size. */
.col {
width: 100%;
- max-width: 620px;
+ max-width: 580px;
margin: 0 auto;
}
main {
- padding: var(--top) 0 48px;
+ padding: var(--top) 0 var(--end);
}
h1 {
- margin: 0 0 calc(var(--gap) + 8px);
+ margin: 0 0 calc(var(--gap) + 6px);
font-size: var(--title-size);
line-height: 1.2;
font-weight: 600;
- letter-spacing: -0.015em;
+ letter-spacing: -0.02em;
text-wrap: balance;
}
h2 {
- margin: calc(var(--gap) * 1.8) 0 calc(var(--gap) * 0.7);
- font-size: var(--text-size);
+ margin: var(--section) 0 calc(var(--gap) * 0.75);
+ font-size: var(--small-size);
line-height: 1.4;
font-weight: 600;
}
@@ -104,6 +113,10 @@ p {
text-wrap: pretty;
}
+main > :last-child {
+ margin-bottom: 0;
+}
+
a {
color: var(--text);
text-decoration: underline;
diff --git a/tsconfig.json b/tsconfig.json
index 8bf91d3..abffe97 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,5 +1,5 @@
{
"extends": "astro/tsconfigs/strict",
"include": [".astro/types.d.ts", "**/*"],
- "exclude": ["dist"]
+ "exclude": ["dist", "worker"]
}
diff --git a/worker/index.ts b/worker/index.ts
new file mode 100644
index 0000000..282805c
--- /dev/null
+++ b/worker/index.ts
@@ -0,0 +1,91 @@
+/**
+ * The site's one piece of server code: POST /api/subscribe keeps an email
+ * address for updates. Pages never reach it; `run_worker_first` in
+ * wrangler.jsonc sends only /api/* here.
+ *
+ * Without JavaScript the form posts here and is redirected to /subscribed or
+ * /subscribe-failed; the site's own script asks for JSON instead and shows the
+ * result in place.
+ */
+
+type Result = 'ok' | 'invalid' | 'limited' | 'error';
+
+const STATUS: Record = { ok: 200, invalid: 400, limited: 429, error: 500 };
+
+// Deliberately loose: the browser's own check runs first, and the only aim
+// here is to turn away input that cannot be an address.
+const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
+
+// A real form body is a few hundred bytes.
+const MAX_BODY = 2048;
+
+export default {
+ async fetch(request, env): Promise {
+ const url = new URL(request.url);
+ if (url.pathname !== '/api/subscribe') {
+ return new Response('Not found', { status: 404, headers: baseHeaders() });
+ }
+ if (request.method !== 'POST') {
+ return new Response('Method not allowed', { status: 405, headers: { ...baseHeaders(), Allow: 'POST' } });
+ }
+
+ const wantsJson = (request.headers.get('Accept') ?? '').includes('application/json');
+ const reply = (result: Result) => respond(result, wantsJson, url);
+
+ // Browsers always send Origin with a POST, so anything else is not this
+ // site's form.
+ if (request.headers.get('Origin') !== url.origin) {
+ return new Response('Forbidden', { status: 403, headers: baseHeaders() });
+ }
+
+ const length = Number(request.headers.get('Content-Length') ?? 'NaN');
+ if (!Number.isFinite(length) || length > MAX_BODY) return reply('invalid');
+
+ const { success } = await env.SIGNUP_LIMIT.limit({ key: request.headers.get('CF-Connecting-IP') ?? 'unknown' });
+ if (!success) return reply('limited');
+
+ let form: FormData;
+ try {
+ form = await request.formData();
+ } catch {
+ return reply('invalid');
+ }
+
+ // The hidden field is filled only by bots: tell them it worked and keep nothing.
+ if (String(form.get('website') ?? '') !== '') return reply('ok');
+
+ const email = String(form.get('email') ?? '')
+ .trim()
+ .toLowerCase();
+ if (email.length > 254 || !EMAIL.test(email)) return reply('invalid');
+
+ try {
+ const { meta } = await env.DB.prepare(
+ 'INSERT INTO signups (email, created_at) VALUES (?1, ?2) ON CONFLICT (email) DO NOTHING',
+ )
+ .bind(email, new Date().toISOString())
+ .run();
+ // Never log the address itself.
+ console.log(JSON.stringify({ event: 'signup', added: meta.changes > 0 }));
+ } catch (error) {
+ console.error(JSON.stringify({ event: 'signup_failed', error: String(error) }));
+ return reply('error');
+ }
+
+ // A repeat sign-up looks the same as a new one, so the form never reveals
+ // whether an address is already on the list.
+ return reply('ok');
+ },
+} satisfies ExportedHandler;
+
+function respond(result: Result, wantsJson: boolean, url: URL): Response {
+ if (wantsJson) {
+ return Response.json({ result }, { status: STATUS[result], headers: baseHeaders() });
+ }
+ const to = result === 'ok' ? '/subscribed' : '/subscribe-failed';
+ return new Response(null, { status: 303, headers: { ...baseHeaders(), Location: new URL(to, url).href } });
+}
+
+function baseHeaders(): Record {
+ return { 'Cache-Control': 'no-store', 'X-Content-Type-Options': 'nosniff' };
+}
diff --git a/worker/tsconfig.json b/worker/tsconfig.json
new file mode 100644
index 0000000..3b4d7f4
--- /dev/null
+++ b/worker/tsconfig.json
@@ -0,0 +1,14 @@
+{
+ "compilerOptions": {
+ "target": "es2024",
+ "module": "es2022",
+ "moduleResolution": "bundler",
+ "lib": ["es2024"],
+ "types": [],
+ "strict": true,
+ "noEmit": true,
+ "skipLibCheck": true,
+ "isolatedModules": true
+ },
+ "include": ["index.ts", "worker-configuration.d.ts"]
+}
diff --git a/worker/worker-configuration.d.ts b/worker/worker-configuration.d.ts
new file mode 100644
index 0000000..5735494
--- /dev/null
+++ b/worker/worker-configuration.d.ts
@@ -0,0 +1,16268 @@
+/* eslint-disable */
+// Generated by Wrangler by running `wrangler types worker/worker-configuration.d.ts` (hash: 1af85b0457706c71e5feff3d8f582c2d)
+// Runtime types generated with workerd@1.20261019.1 2026-10-21
+interface __BaseEnv_Env {
+ DB: D1Database;
+ SIGNUP_LIMIT: RateLimit;
+}
+declare namespace Cloudflare {
+ interface GlobalProps {
+ mainModule: typeof import("./index");
+ }
+ interface Env extends __BaseEnv_Env {}
+}
+interface Env extends __BaseEnv_Env {}
+declare module "*.txt" {
+ const value: string;
+ export default value;
+}
+declare module "*.html" {
+ const value: string;
+ export default value;
+}
+declare module "*.sql" {
+ const value: string;
+ export default value;
+}
+declare module "*.bin" {
+ const value: ArrayBuffer;
+ export default value;
+}
+declare module "*.wasm" {
+ const value: WebAssembly.Module;
+ export default value;
+}
+declare module "*.wasm?module" {
+ const value: WebAssembly.Module;
+ export default value;
+}
+// Begin runtime types
+/*! *****************************************************************************
+Copyright (c) Cloudflare. All rights reserved.
+Copyright (c) Microsoft Corporation. All rights reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+this file except in compliance with the License. You may obtain a copy of the
+License at http://www.apache.org/licenses/LICENSE-2.0
+THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
+WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
+MERCHANTABLITY OR NON-INFRINGEMENT.
+See the Apache Version 2.0 License for specific language governing permissions
+and limitations under the License.
+***************************************************************************** */
+/* eslint-disable */
+// noinspection JSUnusedGlobalSymbols
+declare var onmessage: never;
+/**
+ * The **`DOMException`** interface represents an abnormal event (called an exception) that occurs as a result of calling a method or accessing a property of a web API. This is how error conditions are described in web APIs.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException)
+ */
+declare class DOMException extends Error {
+ constructor(message?: string, name?: string);
+ /**
+ * The **`message`** read-only property of the DOMException interface returns a string representing a message or description associated with the given error name.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message)
+ */
+ readonly message: string;
+ /**
+ * The **`name`** read-only property of the DOMException interface returns a string that contains one of the strings associated with an error name.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name)
+ */
+ readonly name: string;
+ /**
+ * The **`code`** read-only property of the DOMException interface returns one of the legacy error code constants, or 0 if none match.
+ * @deprecated
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code)
+ */
+ readonly code: number;
+ static readonly INDEX_SIZE_ERR: number;
+ static readonly DOMSTRING_SIZE_ERR: number;
+ static readonly HIERARCHY_REQUEST_ERR: number;
+ static readonly WRONG_DOCUMENT_ERR: number;
+ static readonly INVALID_CHARACTER_ERR: number;
+ static readonly NO_DATA_ALLOWED_ERR: number;
+ static readonly NO_MODIFICATION_ALLOWED_ERR: number;
+ static readonly NOT_FOUND_ERR: number;
+ static readonly NOT_SUPPORTED_ERR: number;
+ static readonly INUSE_ATTRIBUTE_ERR: number;
+ static readonly INVALID_STATE_ERR: number;
+ static readonly SYNTAX_ERR: number;
+ static readonly INVALID_MODIFICATION_ERR: number;
+ static readonly NAMESPACE_ERR: number;
+ static readonly INVALID_ACCESS_ERR: number;
+ static readonly VALIDATION_ERR: number;
+ static readonly TYPE_MISMATCH_ERR: number;
+ static readonly SECURITY_ERR: number;
+ static readonly NETWORK_ERR: number;
+ static readonly ABORT_ERR: number;
+ static readonly URL_MISMATCH_ERR: number;
+ static readonly QUOTA_EXCEEDED_ERR: number;
+ static readonly TIMEOUT_ERR: number;
+ static readonly INVALID_NODE_TYPE_ERR: number;
+ static readonly DATA_CLONE_ERR: number;
+ get stack(): any;
+ set stack(value: any);
+}
+type WorkerGlobalScopeEventMap = {
+ fetch: FetchEvent;
+ scheduled: ScheduledEvent;
+ queue: QueueEvent;
+ unhandledrejection: PromiseRejectionEvent;
+ rejectionhandled: PromiseRejectionEvent;
+};
+declare abstract class WorkerGlobalScope extends EventTarget {
+ EventTarget: typeof EventTarget;
+}
+/* The **`console`** object provides access to the debugging console (e.g., the Web console in Firefox). *
+ * The **`console`** object provides access to the debugging console (e.g., the Web console in Firefox).
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console)
+ */
+interface Console {
+ "assert"(condition?: boolean, ...data: any[]): void;
+ /**
+ * The **`console.clear()`** static method clears the console if possible.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/clear_static)
+ */
+ clear(): void;
+ /**
+ * The **`console.count()`** static method logs the number of times that this particular call to count() has been called.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/count_static)
+ */
+ count(label?: string): void;
+ /**
+ * The **`console.countReset()`** static method resets counter used with console.count().
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/countReset_static)
+ */
+ countReset(label?: string): void;
+ /**
+ * The **`console.debug()`** static method outputs a message to the console at the "debug" log level. The message is only displayed to the user if the console is configured to display debug output. In most cases, the log level is configured within the console UI. This log level might correspond to the Debug or Verbose log level.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/debug_static)
+ */
+ debug(...data: any[]): void;
+ /**
+ * The **`console.dir()`** static method displays a list of the properties of the specified JavaScript object. In browser consoles, the output is presented as a hierarchical listing with disclosure triangles that let you see the contents of child objects.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dir_static)
+ */
+ dir(item?: any, options?: any): void;
+ /**
+ * The **`console.dirxml()`** static method displays an interactive tree of the descendant elements of the specified XML/HTML element. If it is not possible to display as an element the JavaScript Object view is shown instead. The output is presented as a hierarchical listing of expandable nodes that let you see the contents of child nodes.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dirxml_static)
+ */
+ dirxml(...data: any[]): void;
+ /**
+ * The **`console.error()`** static method outputs a message to the console at the "error" log level. The message is only displayed to the user if the console is configured to display error output. In most cases, the log level is configured within the console UI. The message may be formatted as an error, with red colors and call stack information.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/error_static)
+ */
+ error(...data: any[]): void;
+ /**
+ * The **`console.group()`** static method creates a new inline group in the Web console log, causing any subsequent console messages to be indented by an additional level, until console.groupEnd() is called.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/group_static)
+ */
+ group(...data: any[]): void;
+ /**
+ * The **`console.groupCollapsed()`** static method creates a new inline group in the console. Unlike console.group(), however, the new group is created collapsed. The user will need to use the disclosure button next to it to expand it, revealing the entries created in the group.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupCollapsed_static)
+ */
+ groupCollapsed(...data: any[]): void;
+ /**
+ * The **`console.groupEnd()`** static method exits the current inline group in the console. See Using groups in the console in the console documentation for details and examples.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupEnd_static)
+ */
+ groupEnd(): void;
+ /**
+ * The **`console.info()`** static method outputs a message to the console at the "info" log level. The message is only displayed to the user if the console is configured to display info output. In most cases, the log level is configured within the console UI. The message may receive special formatting, such as a small "i" icon next to it.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/info_static)
+ */
+ info(...data: any[]): void;
+ /**
+ * The **`console.log()`** static method outputs a message to the console.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
+ */
+ log(...data: any[]): void;
+ /**
+ * The **`console.table()`** static method displays tabular data as a table.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/table_static)
+ */
+ table(tabularData?: any, properties?: string[]): void;
+ /**
+ * The **`console.time()`** static method starts a timer you can use to track how long an operation takes. You give each timer a unique name, and may have up to 10,000 timers running on a given page. When you call console.timeEnd() with the same name, the browser will output the time, in milliseconds, that elapsed since the timer was started.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/time_static)
+ */
+ time(label?: string): void;
+ /**
+ * The **`console.timeEnd()`** static method stops a timer that was previously started by calling console.time().
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeEnd_static)
+ */
+ timeEnd(label?: string): void;
+ /**
+ * The **`console.timeLog()`** static method logs the current value of a timer that was previously started by calling console.time().
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeLog_static)
+ */
+ timeLog(label?: string, ...data: any[]): void;
+ /* The **`console.timeStamp()`** static method adds a single marker to the browser's Performance tool (Firefox bug 1387528, Chrome). This lets you correlate a point in your code with the other events recorded in the timeline, such as layout and paint events. */
+ timeStamp(label?: string): void;
+ /**
+ * The **`console.trace()`** static method outputs a stack trace to the console.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/trace_static)
+ */
+ trace(...data: any[]): void;
+ /**
+ * The **`console.warn()`** static method outputs a warning message to the console at the "warning" log level. The message is only displayed to the user if the console is configured to display warning output. In most cases, the log level is configured within the console UI. The message may receive special formatting, such as yellow colors and a warning icon.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/warn_static)
+ */
+ warn(...data: any[]): void;
+}
+declare const console: Console;
+type BufferSource = ArrayBufferView | ArrayBuffer;
+type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
+declare namespace WebAssembly {
+ class CompileError extends Error {
+ constructor(message?: string);
+ }
+ class RuntimeError extends Error {
+ constructor(message?: string);
+ }
+ type ValueType = "anyfunc" | "externref" | "f32" | "f64" | "i32" | "i64" | "v128";
+ interface GlobalDescriptor {
+ value: ValueType;
+ mutable?: boolean;
+ }
+ class Global {
+ constructor(descriptor: GlobalDescriptor, value?: any);
+ value: any;
+ valueOf(): any;
+ }
+ type ImportValue = ExportValue | number;
+ type ModuleImports = Record;
+ type Imports = Record;
+ type ExportValue = Function | Global | Memory | Table;
+ type Exports = Record;
+ class Instance {
+ constructor(module: Module, imports?: Imports);
+ readonly exports: Exports;
+ }
+ interface MemoryDescriptor {
+ initial: number;
+ maximum?: number;
+ shared?: boolean;
+ }
+ class Memory {
+ constructor(descriptor: MemoryDescriptor);
+ readonly buffer: ArrayBuffer;
+ grow(delta: number): number;
+ }
+ type ImportExportKind = "function" | "global" | "memory" | "table";
+ interface ModuleExportDescriptor {
+ kind: ImportExportKind;
+ name: string;
+ }
+ interface ModuleImportDescriptor {
+ kind: ImportExportKind;
+ module: string;
+ name: string;
+ }
+ abstract class Module {
+ static customSections(module: Module, sectionName: string): ArrayBuffer[];
+ static exports(module: Module): ModuleExportDescriptor[];
+ static imports(module: Module): ModuleImportDescriptor[];
+ }
+ type TableKind = "anyfunc" | "externref";
+ interface TableDescriptor {
+ element: TableKind;
+ initial: number;
+ maximum?: number;
+ }
+ class Table {
+ constructor(descriptor: TableDescriptor, value?: any);
+ readonly length: number;
+ get(index: number): any;
+ grow(delta: number, value?: any): number;
+ set(index: number, value?: any): void;
+ }
+ function instantiate(module: Module, imports?: Imports): Promise;
+ function validate(bytes: BufferSource): boolean;
+}
+/**
+ * The **`ServiceWorkerGlobalScope`** interface of the Service Worker API represents the global execution context of a service worker.
+ * Available only in secure contexts.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ServiceWorkerGlobalScope)
+ */
+interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
+ DOMException: typeof DOMException;
+ WorkerGlobalScope: typeof WorkerGlobalScope;
+ btoa(data: string): string;
+ atob(data: string): string;
+ setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
+ setTimeout(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
+ clearTimeout(timeoutId: number | null): void;
+ setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
+ setInterval(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
+ clearInterval(timeoutId: number | null): void;
+ queueMicrotask(task: Function): void;
+ structuredClone(value: T, options?: StructuredSerializeOptions): T;
+ reportError(error: any): void;
+ fetch(input: RequestInfo | URL, init?: RequestInit): Promise;
+ self: ServiceWorkerGlobalScope;
+ crypto: Crypto;
+ caches: CacheStorage;
+ scheduler: Scheduler;
+ performance: Performance;
+ Cloudflare: Cloudflare;
+ readonly origin: string;
+ Event: typeof Event;
+ ExtendableEvent: typeof ExtendableEvent;
+ CustomEvent: typeof CustomEvent;
+ PromiseRejectionEvent: typeof PromiseRejectionEvent;
+ FetchEvent: typeof FetchEvent;
+ TailEvent: typeof TailEvent;
+ TraceEvent: typeof TailEvent;
+ ScheduledEvent: typeof ScheduledEvent;
+ MessageEvent: typeof MessageEvent;
+ CloseEvent: typeof CloseEvent;
+ ReadableStreamDefaultReader: typeof ReadableStreamDefaultReader;
+ ReadableStreamBYOBReader: typeof ReadableStreamBYOBReader;
+ ReadableStream: typeof ReadableStream;
+ WritableStream: typeof WritableStream;
+ WritableStreamDefaultWriter: typeof WritableStreamDefaultWriter;
+ TransformStream: typeof TransformStream;
+ ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;
+ CountQueuingStrategy: typeof CountQueuingStrategy;
+ ErrorEvent: typeof ErrorEvent;
+ MessageChannel: typeof MessageChannel;
+ MessagePort: typeof MessagePort;
+ EventSource: typeof EventSource;
+ ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
+ ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
+ ReadableByteStreamController: typeof ReadableByteStreamController;
+ WritableStreamDefaultController: typeof WritableStreamDefaultController;
+ TransformStreamDefaultController: typeof TransformStreamDefaultController;
+ CompressionStream: typeof CompressionStream;
+ DecompressionStream: typeof DecompressionStream;
+ TextEncoderStream: typeof TextEncoderStream;
+ TextDecoderStream: typeof TextDecoderStream;
+ Headers: typeof Headers;
+ Body: typeof Body;
+ Request: typeof Request;
+ Response: typeof Response;
+ WebSocket: typeof WebSocket;
+ WebSocketPair: typeof WebSocketPair;
+ WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair;
+ AbortController: typeof AbortController;
+ AbortSignal: typeof AbortSignal;
+ TextDecoder: typeof TextDecoder;
+ TextEncoder: typeof TextEncoder;
+ navigator: Navigator;
+ Navigator: typeof Navigator;
+ URL: typeof URL;
+ URLSearchParams: typeof URLSearchParams;
+ URLPattern: typeof URLPattern;
+ Blob: typeof Blob;
+ File: typeof File;
+ FormData: typeof FormData;
+ Crypto: typeof Crypto;
+ SubtleCrypto: typeof SubtleCrypto;
+ CryptoKey: typeof CryptoKey;
+ CacheStorage: typeof CacheStorage;
+ Cache: typeof Cache;
+ FixedLengthStream: typeof FixedLengthStream;
+ IdentityTransformStream: typeof IdentityTransformStream;
+ HTMLRewriter: typeof HTMLRewriter;
+}
+declare function addEventListener(type: Type, handler: EventListenerOrEventListenerObject, options?: EventTargetAddEventListenerOptions | boolean): void;
+declare function removeEventListener(type: Type, handler: EventListenerOrEventListenerObject, options?: EventTargetEventListenerOptions | boolean): void;
+/**
+ * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
+ */
+declare function dispatchEvent(event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap]): boolean;
+/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa) */
+declare function btoa(data: string): string;
+/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob) */
+declare function atob(data: string): string;
+/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
+declare function setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
+/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
+declare function setTimeout(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
+/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout) */
+declare function clearTimeout(timeoutId: number | null): void;
+/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
+declare function setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
+/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
+declare function setInterval(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;
+/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearInterval) */
+declare function clearInterval(timeoutId: number | null): void;
+/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) */
+declare function queueMicrotask(task: Function): void;
+/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
+declare function structuredClone(value: T, options?: StructuredSerializeOptions): T;
+/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError) */
+declare function reportError(error: any): void;
+/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) */
+declare function fetch(input: RequestInfo | URL, init?: RequestInit): Promise;
+declare const self: ServiceWorkerGlobalScope;
+/**
+* The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
+* The Workers runtime implements the full surface of this API, but with some differences in
+* the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
+* compared to those implemented in most browsers.
+*
+* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
+*/
+declare const crypto: Crypto;
+/**
+* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
+*
+* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
+*/
+declare const caches: CacheStorage;
+/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/scheduler) */
+declare const scheduler: Scheduler;
+/**
+* The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
+* as well as timing of subrequests and other operations.
+*
+* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
+*/
+declare const performance: Performance;
+declare const Cloudflare: Cloudflare;
+declare const origin: string;
+declare const navigator: Navigator;
+interface TestController {
+}
+interface ExecutionContext {
+ waitUntil(promise: Promise): void;
+ passThroughOnException(): void;
+ readonly exports: Cloudflare.Exports;
+ readonly props: Props;
+ cache?: CacheContext;
+ readonly access?: CloudflareAccessContext;
+ tracing: Tracing;
+ abort(reason?: any): void;
+}
+type ExportedHandlerFetchHandler = (request: Request>, env: Env, ctx: ExecutionContext) => Response | Promise;
+type ExportedHandlerConnectHandler = (socket: Socket, env: Env, ctx: ExecutionContext) => void | Promise;
+type ExportedHandlerTailHandler = (events: TraceItem[], env: Env, ctx: ExecutionContext) => void | Promise;
+type ExportedHandlerTraceHandler = (traces: TraceItem[], env: Env, ctx: ExecutionContext) => void | Promise;
+type ExportedHandlerTailStreamHandler = (event: TailStream.TailEvent, env: Env, ctx: ExecutionContext) => TailStream.TailEventHandlerType | undefined | Promise;
+type ExportedHandlerScheduledHandler = (controller: ScheduledController, env: Env, ctx: ExecutionContext) => void | Promise;
+type ExportedHandlerQueueHandler = (batch: MessageBatch, env: Env, ctx: ExecutionContext) => void | Promise;
+type ExportedHandlerTestHandler = (controller: TestController, env: Env, ctx: ExecutionContext) => void | Promise;
+interface ExportedHandler {
+ fetch?: ExportedHandlerFetchHandler;
+ connect?: ExportedHandlerConnectHandler;
+ tail?: ExportedHandlerTailHandler;
+ trace?: ExportedHandlerTraceHandler;
+ tailStream?: ExportedHandlerTailStreamHandler;
+ scheduled?: ExportedHandlerScheduledHandler;
+ test?: ExportedHandlerTestHandler;
+ email?: EmailExportedHandler;
+ queue?: ExportedHandlerQueueHandler;
+}
+interface StructuredSerializeOptions {
+ transfer?: any[];
+}
+declare abstract class Navigator {
+ sendBeacon(url: string, body?: BodyInit): boolean;
+ readonly userAgent: string;
+ readonly hardwareConcurrency: number;
+ readonly platform: string;
+ readonly language: string;
+ readonly languages: string[];
+}
+interface AlarmInvocationInfo {
+ readonly isRetry: boolean;
+ readonly retryCount: number;
+ readonly scheduledTime: number;
+}
+interface Cloudflare {
+ readonly compatibilityFlags: Record;
+}
+interface CachePurgeError {
+ code: number;
+ message: string;
+}
+interface CachePurgeResult {
+ success: boolean;
+ errors: CachePurgeError[];
+}
+interface CachePurgeOptions {
+ tags?: string[];
+ pathPrefixes?: string[];
+ purgeEverything?: boolean;
+}
+interface CacheContext {
+ purge(options: CachePurgeOptions): Promise;
+ invalidate(options: CachePurgeOptions): Promise;
+}
+interface CloudflareAccessContext {
+ readonly aud: string;
+ getIdentity(): Promise;
+}
+declare abstract class ColoLocalActorNamespace {
+ get(actorId: string): Fetcher;
+}
+interface DurableObject {
+ fetch(request: Request): Response | Promise;
+ connect?(socket: Socket): void | Promise;
+ alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise;
+ webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise;
+ webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise;
+ webSocketError?(ws: WebSocket, error: unknown): void | Promise;
+}
+type DurableObjectStub = Fetcher & {
+ readonly id: DurableObjectId;
+ readonly name?: string;
+};
+interface DurableObjectId {
+ toString(): string;
+ equals(other: DurableObjectId): boolean;
+ readonly name?: string;
+ readonly jurisdiction?: string;
+}
+declare abstract class DurableObjectNamespace {
+ newUniqueId(options?: DurableObjectNamespaceNewUniqueIdOptions): DurableObjectId;
+ idFromName(name: string): DurableObjectId;
+ idFromString(id: string): DurableObjectId;
+ get(id: DurableObjectId, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub;
+ getByName(name: string, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub;
+ jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace;
+}
+type DurableObjectJurisdiction = "eu" | "fedramp" | "fedramp-high" | "us";
+interface DurableObjectNamespaceNewUniqueIdOptions {
+ jurisdiction?: DurableObjectJurisdiction;
+}
+type DurableObjectLocationHint = "wnam" | "enam" | "sam" | "weur" | "eeur" | "apac" | "apac-ne" | "apac-se" | "oc" | "afr" | "me";
+type DurableObjectRoutingMode = "primary-only";
+interface DurableObjectNamespaceGetDurableObjectOptions {
+ locationHint?: DurableObjectLocationHint;
+ routingMode?: DurableObjectRoutingMode;
+}
+interface DurableObjectClass<_T extends Rpc.DurableObjectBranded | undefined = undefined> {
+}
+interface DurableObjectState {
+ waitUntil(promise: Promise): void;
+ readonly exports: Cloudflare.Exports;
+ readonly props: Props;
+ readonly id: DurableObjectId;
+ readonly storage: DurableObjectStorage;
+ container?: Container;
+ facets: DurableObjectFacets;
+ blockConcurrencyWhile(callback: () => Promise): Promise;
+ acceptWebSocket(ws: WebSocket, tags?: string[]): void;
+ getWebSockets(tag?: string): WebSocket[];
+ setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
+ getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
+ getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
+ setHibernatableWebSocketEventTimeout(timeoutMs?: number): void;
+ getHibernatableWebSocketEventTimeout(): number | null;
+ getTags(ws: WebSocket): string[];
+ abort(reason?: string, options?: DurableObjectAbortOptions): void;
+}
+interface DurableObjectTransaction {
+ get(key: string, options?: DurableObjectGetOptions): Promise;
+ get(keys: string[], options?: DurableObjectGetOptions): Promise>;
+ list(options?: DurableObjectListOptions): Promise>;
+ put(key: string, value: T, options?: DurableObjectPutOptions): Promise;
+ put(entries: Record, options?: DurableObjectPutOptions): Promise;
+ delete(key: string, options?: DurableObjectPutOptions): Promise;
+ delete(keys: string[], options?: DurableObjectPutOptions): Promise;
+ rollback(): void;
+ getAlarm(options?: DurableObjectGetAlarmOptions): Promise;
+ setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise;
+ deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise;
+}
+interface DurableObjectStorage {
+ get(key: string, options?: DurableObjectGetOptions): Promise;
+ get(keys: string[], options?: DurableObjectGetOptions): Promise>;
+ list(options?: DurableObjectListOptions): Promise>;
+ put(key: string, value: T, options?: DurableObjectPutOptions): Promise;
+ put(entries: Record, options?: DurableObjectPutOptions): Promise;
+ delete(key: string, options?: DurableObjectPutOptions): Promise;
+ delete(keys: string[], options?: DurableObjectPutOptions): Promise;
+ deleteAll(options?: DurableObjectPutOptions): Promise;
+ transaction(closure: (txn: DurableObjectTransaction) => Promise): Promise;
+ getAlarm(options?: DurableObjectGetAlarmOptions): Promise;
+ setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise;
+ deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise;
+ sync(): Promise;
+ sql: SqlStorage;
+ kv: SyncKvStorage;
+ transactionSync(closure: () => T): T;
+ getCurrentBookmark(): Promise;
+ getBookmarkForTime(timestamp: number | Date): Promise;
+ onNextSessionRestoreBookmark(bookmark: string): Promise;
+}
+interface DurableObjectAbortOptions {
+ retryAlarm?: boolean;
+}
+interface DurableObjectListOptions {
+ start?: string;
+ startAfter?: string;
+ end?: string;
+ prefix?: string;
+ reverse?: boolean;
+ limit?: number;
+ allowConcurrency?: boolean;
+ noCache?: boolean;
+}
+interface DurableObjectGetOptions {
+ allowConcurrency?: boolean;
+ noCache?: boolean;
+}
+interface DurableObjectGetAlarmOptions {
+ allowConcurrency?: boolean;
+}
+interface DurableObjectPutOptions {
+ allowConcurrency?: boolean;
+ allowUnconfirmed?: boolean;
+ noCache?: boolean;
+}
+interface DurableObjectSetAlarmOptions {
+ allowConcurrency?: boolean;
+ allowUnconfirmed?: boolean;
+}
+declare class WebSocketRequestResponsePair {
+ constructor(request: string, response: string);
+ get request(): string;
+ get response(): string;
+}
+interface DurableObjectFacets {
+ get(name: string, getStartupOptions: () => FacetStartupOptions | Promise>): Fetcher;
+ abort(name: string, reason: any): void;
+ delete(name: string): void;
+ clone(src: string, dst: string): void;
+}
+interface FacetStartupOptions {
+ id?: DurableObjectId | string;
+ class: DurableObjectClass;
+}
+interface AnalyticsEngineDataset {
+ writeDataPoint(event?: AnalyticsEngineDataPoint): void;
+}
+interface AnalyticsEngineDataPoint {
+ indexes?: ((ArrayBuffer | string) | null)[];
+ doubles?: number[];
+ blobs?: ((ArrayBuffer | string) | null)[];
+}
+/**
+ * The **`Event`** interface represents an event which takes place on an EventTarget.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event)
+ */
+declare class Event {
+ constructor(type: string, init?: EventInit);
+ /**
+ * The **`type`** read-only property of the Event interface returns a string containing the event's type. It is set when the event is constructed and is the name commonly used to refer to the specific event, such as click, load, or error.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type)
+ */
+ get type(): string;
+ /**
+ * The **`eventPhase`** read-only property of the Event interface indicates which phase of the event flow is currently being evaluated.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase)
+ */
+ get eventPhase(): number;
+ /**
+ * The read-only **`composed`** property of the Event interface returns a boolean value which indicates whether or not the event will propagate across the shadow DOM boundary into the standard DOM.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed)
+ */
+ get composed(): boolean;
+ /**
+ * The **`bubbles`** read-only property of the Event interface indicates whether the event bubbles up through the DOM tree or not.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles)
+ */
+ get bubbles(): boolean;
+ /**
+ * The **`cancelable`** read-only property of the Event interface indicates whether the event can be canceled, and therefore prevented as if the event never happened.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable)
+ */
+ get cancelable(): boolean;
+ /**
+ * The **`defaultPrevented`** read-only property of the Event interface returns a boolean value indicating whether or not the call to Event.preventDefault() canceled the event.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented)
+ */
+ get defaultPrevented(): boolean;
+ /**
+ * The Event property **`returnValue`** indicates whether the default action for this event has been prevented or not.
+ * @deprecated
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue)
+ */
+ get returnValue(): boolean;
+ /**
+ * The **`currentTarget`** read-only property of the Event interface identifies the element to which the event handler has been attached.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)
+ */
+ get currentTarget(): EventTarget | undefined;
+ /**
+ * The read-only **`target`** property of the Event interface is a reference to the object onto which the event was dispatched. It is different from Event.currentTarget when the event handler is called during the bubbling or capturing phase of the event.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target)
+ */
+ get target(): EventTarget | undefined;
+ /**
+ * The deprecated **`Event.srcElement`** is an alias for the Event.target property. Use Event.target instead.
+ * @deprecated
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement)
+ */
+ get srcElement(): EventTarget | undefined;
+ /**
+ * The **`timeStamp`** read-only property of the Event interface returns the time (in milliseconds) at which the event was created.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp)
+ */
+ get timeStamp(): number;
+ /**
+ * The **`isTrusted`** read-only property of the Event interface is a boolean value that is true when the event was generated by the user agent (including via user actions and programmatic methods such as HTMLElement.focus()), and false when the event was dispatched via EventTarget.dispatchEvent(). The only exception is the click event, which initializes the isTrusted property to false in user agents.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted)
+ */
+ get isTrusted(): boolean;
+ /**
+ * The **`cancelBubble`** property of the Event interface is deprecated. Use Event.stopPropagation() instead. Setting its value to true before returning from an event handler prevents propagation of the event. In later implementations, setting this to false does nothing. See Browser compatibility for details.
+ * @deprecated
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
+ */
+ get cancelBubble(): boolean;
+ /**
+ * The **`cancelBubble`** property of the Event interface is deprecated. Use Event.stopPropagation() instead. Setting its value to true before returning from an event handler prevents propagation of the event. In later implementations, setting this to false does nothing. See Browser compatibility for details.
+ * @deprecated
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
+ */
+ set cancelBubble(value: boolean);
+ /**
+ * The **`stopImmediatePropagation()`** method of the Event interface prevents other listeners of the same event from being called.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation)
+ */
+ stopImmediatePropagation(): void;
+ /**
+ * The **`preventDefault()`** method of the Event interface tells the user agent that the event is being explicitly handled, so its default action, such as page scrolling, link navigation, or pasting text, should not be taken.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault)
+ */
+ preventDefault(): void;
+ /**
+ * The **`stopPropagation()`** method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases. It does not, however, prevent any default behaviors from occurring; for instance, clicks on links are still processed. If you want to stop those behaviors, see the preventDefault() method. It also does not prevent propagation to other event-handlers of the current element. If you want to stop those, see stopImmediatePropagation().
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation)
+ */
+ stopPropagation(): void;
+ /**
+ * The **`composedPath()`** method of the Event interface returns the event's path which is an array of the objects on which listeners will be invoked. This does not include nodes in shadow trees if the shadow root was created with its ShadowRoot.mode closed.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath)
+ */
+ composedPath(): EventTarget[];
+ static readonly NONE: number;
+ static readonly CAPTURING_PHASE: number;
+ static readonly AT_TARGET: number;
+ static readonly BUBBLING_PHASE: number;
+}
+interface EventInit {
+ bubbles?: boolean;
+ cancelable?: boolean;
+ composed?: boolean;
+}
+type EventListener = (event: EventType) => void;
+interface EventListenerObject {
+ handleEvent(event: EventType): void;
+}
+type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
+/**
+ * The **`EventTarget`** interface is implemented by objects that can receive events and may have listeners for them. In other words, any target of events implements the three methods associated with this interface.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget)
+ */
+declare class EventTarget = Record> {
+ constructor();
+ /**
+ * The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
+ */
+ addEventListener(type: Type, handler: EventListenerOrEventListenerObject, options?: EventTargetAddEventListenerOptions | boolean): void;
+ /**
+ * The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
+ */
+ removeEventListener(type: Type, handler: EventListenerOrEventListenerObject, options?: EventTargetEventListenerOptions | boolean): void;
+ /**
+ * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
+ */
+ dispatchEvent(event: EventMap[keyof EventMap]): boolean;
+}
+interface EventTargetEventListenerOptions {
+ capture?: boolean;
+}
+interface EventTargetAddEventListenerOptions {
+ capture?: boolean;
+ passive?: boolean;
+ once?: boolean;
+ signal?: AbortSignal;
+}
+interface EventTargetHandlerObject {
+ handleEvent: (event: Event) => any | undefined;
+}
+/**
+ * The **`AbortController`** interface represents a controller object that allows you to abort one or more Web requests as and when desired.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController)
+ */
+declare class AbortController {
+ constructor();
+ /**
+ * The **`signal`** read-only property of the AbortController interface returns an AbortSignal object instance, which can be used to communicate with/abort an asynchronous operation as desired.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/signal)
+ */
+ get signal(): AbortSignal;
+ /**
+ * The **`abort()`** method of the AbortController interface aborts an asynchronous operation before it has completed. This is able to abort fetch requests, the consumption of any response bodies, or streams.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/abort)
+ */
+ abort(reason?: any): void;
+}
+/**
+ * The **`AbortSignal`** interface represents a signal object that allows you to communicate with an asynchronous operation (such as a fetch request) and abort it if required via an AbortController object.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal)
+ */
+declare abstract class AbortSignal extends EventTarget {
+ /**
+ * The **`AbortSignal.abort()`** static method returns an AbortSignal that is already set as aborted (and which does not trigger an abort event).
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_static)
+ */
+ static abort(reason?: any): AbortSignal;
+ /**
+ * The **`AbortSignal.timeout()`** static method returns an AbortSignal that will automatically abort after a specified time.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/timeout_static)
+ */
+ static timeout(delay: number): AbortSignal;
+ /**
+ * The **`AbortSignal.any()`** static method takes an iterable of abort signals and returns an AbortSignal. The returned abort signal is aborted when any of the input iterable abort signals are aborted. The abort reason will be set to the reason of the first signal that is aborted. If any of the given abort signals are already aborted then so will be the returned AbortSignal.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/any_static)
+ */
+ static any(signals: AbortSignal[]): AbortSignal;
+ /**
+ * The **`aborted`** read-only property returns a value that indicates whether the asynchronous operations the signal is communicating with are aborted (true) or not (false).
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted)
+ */
+ get aborted(): boolean;
+ /**
+ * The **`reason`** read-only property returns a JavaScript value that indicates the abort reason.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/reason)
+ */
+ get reason(): any;
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
+ get onabort(): any | null;
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
+ set onabort(value: any | null);
+ /**
+ * The **`throwIfAborted()`** method throws the signal's abort reason if the signal has been aborted; otherwise it does nothing.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/throwIfAborted)
+ */
+ throwIfAborted(): void;
+}
+/**
+ * The **`Scheduler`** interface of the Prioritized Task Scheduling API provides methods for scheduling prioritized tasks.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Scheduler)
+ */
+interface Scheduler {
+ wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise;
+}
+interface SchedulerWaitOptions {
+ signal?: AbortSignal;
+}
+/**
+ * The **`ExtendableEvent`** interface extends the lifetime of the install and activate events dispatched on the global scope as part of the service worker lifecycle. This ensures that any functional events (like FetchEvent) are not dispatched until it upgrades database schemas and deletes the outdated cache entries.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent)
+ */
+declare abstract class ExtendableEvent extends Event {
+ /**
+ * The **`ExtendableEvent.waitUntil()`** method tells the event dispatcher that work is ongoing. It can also be used to detect whether that work was successful. In service workers, waitUntil() tells the browser that work is ongoing until the promise settles, and it shouldn't terminate the service worker if it wants that work to complete.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent/waitUntil)
+ */
+ waitUntil(promise: Promise): void;
+}
+/**
+ * The **`CustomEvent`** interface can be used to attach custom data to an event generated by an application.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent)
+ */
+declare class CustomEvent extends Event {
+ constructor(type: string, init?: CustomEventCustomEventInit);
+ /**
+ * The read-only **`detail`** property of the CustomEvent interface returns any data passed when initializing the event.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/detail)
+ */
+ get detail(): T;
+}
+interface CustomEventCustomEventInit {
+ bubbles?: boolean;
+ cancelable?: boolean;
+ composed?: boolean;
+ detail?: any;
+}
+/**
+ * The **`Blob`** interface represents a blob, which is a file-like object of immutable, raw data; they can be read as text or binary data, or converted into a ReadableStream so its methods can be used for processing the data.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob)
+ */
+declare class Blob {
+ constructor(bits?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[], options?: BlobOptions);
+ /**
+ * The **`size`** read-only property of the Blob interface returns the size of the Blob or File in bytes.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size)
+ */
+ get size(): number;
+ /**
+ * The **`type`** read-only property of the Blob interface returns the MIME type of the file.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type)
+ */
+ get type(): string;
+ /**
+ * The **`slice()`** method of the Blob interface creates and returns a new Blob object which contains data from a subset of the blob on which it's called.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice)
+ */
+ slice(start?: number, end?: number, type?: string): Blob;
+ /**
+ * The **`arrayBuffer()`** method of the Blob interface returns a Promise that resolves with the contents of the blob as binary data contained in an ArrayBuffer.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer)
+ */
+ arrayBuffer(): Promise;
+ /**
+ * The **`bytes()`** method of the Blob interface returns a Promise that resolves with a Uint8Array containing the contents of the blob as an array of bytes.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/bytes)
+ */
+ bytes(): Promise;
+ /**
+ * The **`text()`** method of the Blob interface returns a Promise that resolves with a string containing the contents of the blob, interpreted as UTF-8.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text)
+ */
+ text(): Promise;
+ /**
+ * The **`stream()`** method of the Blob interface returns a ReadableStream which upon reading returns the data contained within the Blob.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream)
+ */
+ stream(): ReadableStream;
+}
+interface BlobOptions {
+ type?: string;
+}
+/**
+ * The **`File`** interface provides information about files and allows JavaScript in a web page to access their content.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File)
+ */
+declare class File extends Blob {
+ constructor(bits: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined, name: string, options?: FileOptions);
+ /**
+ * The **`name`** read-only property of the File interface returns the name of the file represented by a File object. For security reasons, the path is excluded from this property.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name)
+ */
+ get name(): string;
+ /**
+ * The **`lastModified`** read-only property of the File interface provides the last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current date.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified)
+ */
+ get lastModified(): number;
+}
+interface FileOptions {
+ type?: string;
+ lastModified?: number;
+}
+/**
+* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
+*
+* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
+*/
+declare abstract class CacheStorage {
+ /**
+ * The **`open()`** method of the CacheStorage interface returns a Promise that resolves to the Cache object matching the cacheName.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/open)
+ */
+ open(cacheName: string): Promise;
+ readonly default: Cache;
+}
+/**
+* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
+*
+* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
+*/
+declare abstract class Cache {
+ /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#delete) */
+ delete(request: RequestInfo | URL, options?: CacheQueryOptions): Promise;
+ /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#match) */
+ match(request: RequestInfo | URL, options?: CacheQueryOptions): Promise;
+ /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#put) */
+ put(request: RequestInfo | URL, response: Response): Promise;
+}
+interface CacheQueryOptions {
+ ignoreMethod?: boolean;
+}
+/**
+* The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
+* The Workers runtime implements the full surface of this API, but with some differences in
+* the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
+* compared to those implemented in most browsers.
+*
+* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
+*/
+declare abstract class Crypto {
+ /**
+ * The **`Crypto.subtle`** read-only property returns a SubtleCrypto which can then be used to perform low-level cryptographic operations.
+ * Available only in secure contexts.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/subtle)
+ */
+ get subtle(): SubtleCrypto;
+ /**
+ * The **`Crypto.getRandomValues()`** method lets you get cryptographically strong random values. The array given as the parameter is filled with random numbers (random in its cryptographic meaning).
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues)
+ */
+ getRandomValues(buffer: T): T;
+ /**
+ * The **`randomUUID()`** method of the Crypto interface is used to generate a v4 UUID using a cryptographically secure random number generator.
+ * Available only in secure contexts.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID)
+ */
+ randomUUID(): string;
+ DigestStream: typeof DigestStream;
+}
+/**
+ * The **`SubtleCrypto`** interface of the Web Crypto API provides a number of low-level cryptographic functions.
+ * Available only in secure contexts.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto)
+ */
+declare abstract class SubtleCrypto {
+ /**
+ * The **`encrypt()`** method of the SubtleCrypto interface encrypts data.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/encrypt)
+ */
+ encrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, plainText: ArrayBuffer | ArrayBufferView): Promise;
+ /**
+ * The **`decrypt()`** method of the SubtleCrypto interface decrypts some encrypted data. It takes as arguments a key to decrypt with, some optional extra parameters, and the data to decrypt (also known as "ciphertext"). It returns a Promise which will be fulfilled with the decrypted data (also known as "plaintext").
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/decrypt)
+ */
+ decrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, cipherText: ArrayBuffer | ArrayBufferView): Promise;
+ /**
+ * The **`sign()`** method of the SubtleCrypto interface generates a digital signature.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/sign)
+ */
+ sign(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, data: ArrayBuffer | ArrayBufferView): Promise;
+ /**
+ * The **`verify()`** method of the SubtleCrypto interface verifies a digital signature.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/verify)
+ */
+ verify(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, signature: ArrayBuffer | ArrayBufferView, data: ArrayBuffer | ArrayBufferView): Promise;
+ /**
+ * The **`digest()`** method of the SubtleCrypto interface generates a digest of the given data, using the specified hash function. A digest is a short fixed-length value derived from some variable-length input. Cryptographic digests should exhibit collision-resistance, meaning that it's hard to come up with two different inputs that have the same digest value.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/digest)
+ */
+ digest(algorithm: string | SubtleCryptoHashAlgorithm, data: ArrayBuffer | ArrayBufferView): Promise;
+ /**
+ * The **`generateKey()`** method of the SubtleCrypto interface is used to generate a new key (for symmetric algorithms) or key pair (for public-key algorithms).
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey)
+ */
+ generateKey(algorithm: string | SubtleCryptoGenerateKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise;
+ /**
+ * The **`deriveKey()`** method of the SubtleCrypto interface can be used to derive a secret key from a master key.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey)
+ */
+ deriveKey(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise;
+ /**
+ * The **`deriveBits()`** method of the SubtleCrypto interface can be used to derive an array of bits from a base key.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveBits)
+ */
+ deriveBits(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, length?: number | null): Promise;
+ /**
+ * The **`importKey()`** method of the SubtleCrypto interface imports a key: that is, it takes as input a key in an external, portable format and gives you a CryptoKey object that you can use in the Web Crypto API.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey)
+ */
+ importKey(format: string, keyData: (ArrayBuffer | ArrayBufferView) | JsonWebKey, algorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise;
+ /**
+ * The **`exportKey()`** method of the SubtleCrypto interface exports a key: that is, it takes as input a CryptoKey object and gives you the key in an external, portable format.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/exportKey)
+ */
+ exportKey(format: string, key: CryptoKey): Promise;
+ /**
+ * The **`wrapKey()`** method of the SubtleCrypto interface "wraps" a key. This means that it exports the key in an external, portable format, then encrypts the exported key. Wrapping a key helps protect it in untrusted environments, such as inside an otherwise unprotected data store or in transmission over an unprotected network.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/wrapKey)
+ */
+ wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm): Promise;
+ /**
+ * The **`unwrapKey()`** method of the SubtleCrypto interface "unwraps" a key. This means that it takes as its input a key that has been exported and then encrypted (also called "wrapped"). It decrypts the key and then imports it, returning a CryptoKey object that can be used in the Web Crypto API.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey)
+ */
+ unwrapKey(format: string, wrappedKey: ArrayBuffer | ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm, unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise;
+ timingSafeEqual(a: ArrayBuffer | ArrayBufferView, b: ArrayBuffer | ArrayBufferView): boolean;
+}
+/**
+ * The **`CryptoKey`** interface of the Web Crypto API represents a cryptographic key obtained from one of the SubtleCrypto methods generateKey(), deriveKey(), importKey(), or unwrapKey().
+ * Available only in secure contexts.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey)
+ */
+declare abstract class CryptoKey {
+ /**
+ * The read-only **`type`** property of the CryptoKey interface indicates which kind of key is represented by the object. It can have the following values:
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type)
+ */
+ readonly type: string;
+ /**
+ * The read-only **`extractable`** property of the CryptoKey interface indicates whether or not the key may be extracted using SubtleCrypto.exportKey() or SubtleCrypto.wrapKey().
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable)
+ */
+ readonly extractable: boolean;
+ /**
+ * The read-only **`algorithm`** property of the CryptoKey interface returns an object describing the algorithm for which this key can be used, and any associated extra parameters.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm)
+ */
+ readonly algorithm: CryptoKeyKeyAlgorithm | CryptoKeyAesKeyAlgorithm | CryptoKeyHmacKeyAlgorithm | CryptoKeyRsaKeyAlgorithm | CryptoKeyEllipticKeyAlgorithm | CryptoKeyArbitraryKeyAlgorithm;
+ /**
+ * The read-only **`usages`** property of the CryptoKey interface indicates what can be done with the key.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages)
+ */
+ readonly usages: string[];
+}
+interface CryptoKeyPair {
+ publicKey: CryptoKey;
+ privateKey: CryptoKey;
+}
+interface JsonWebKey {
+ kty: string;
+ use?: string;
+ key_ops?: string[];
+ alg?: string;
+ ext?: boolean;
+ crv?: string;
+ x?: string;
+ y?: string;
+ d?: string;
+ n?: string;
+ e?: string;
+ p?: string;
+ q?: string;
+ dp?: string;
+ dq?: string;
+ qi?: string;
+ oth?: RsaOtherPrimesInfo[];
+ k?: string;
+ pub?: string;
+ priv?: string;
+}
+interface RsaOtherPrimesInfo {
+ r?: string;
+ d?: string;
+ t?: string;
+}
+interface SubtleCryptoDeriveKeyAlgorithm {
+ name: string;
+ salt?: (ArrayBuffer | ArrayBufferView);
+ iterations?: number;
+ hash?: (string | SubtleCryptoHashAlgorithm);
+ $public?: CryptoKey;
+ info?: (ArrayBuffer | ArrayBufferView);
+}
+interface SubtleCryptoEncryptAlgorithm {
+ name: string;
+ iv?: (ArrayBuffer | ArrayBufferView);
+ additionalData?: (ArrayBuffer | ArrayBufferView);
+ tagLength?: number;
+ counter?: (ArrayBuffer | ArrayBufferView);
+ length?: number;
+ label?: (ArrayBuffer | ArrayBufferView);
+}
+interface SubtleCryptoGenerateKeyAlgorithm {
+ name: string;
+ hash?: (string | SubtleCryptoHashAlgorithm);
+ modulusLength?: number;
+ publicExponent?: (ArrayBuffer | ArrayBufferView);
+ length?: number;
+ namedCurve?: string;
+}
+interface SubtleCryptoHashAlgorithm {
+ name: string;
+}
+interface SubtleCryptoImportKeyAlgorithm {
+ name: string;
+ hash?: (string | SubtleCryptoHashAlgorithm);
+ length?: number;
+ namedCurve?: string;
+ compressed?: boolean;
+}
+interface SubtleCryptoSignAlgorithm {
+ name: string;
+ hash?: (string | SubtleCryptoHashAlgorithm);
+ dataLength?: number;
+ saltLength?: number;
+ context?: ArrayBuffer | ArrayBufferView;
+}
+interface CryptoKeyKeyAlgorithm {
+ name: string;
+}
+interface CryptoKeyAesKeyAlgorithm {
+ name: string;
+ length: number;
+}
+interface CryptoKeyHmacKeyAlgorithm {
+ name: string;
+ hash: CryptoKeyKeyAlgorithm;
+ length: number;
+}
+interface CryptoKeyRsaKeyAlgorithm {
+ name: string;
+ modulusLength: number;
+ publicExponent: ArrayBuffer | ArrayBufferView;
+ hash?: CryptoKeyKeyAlgorithm;
+}
+interface CryptoKeyEllipticKeyAlgorithm {
+ name: string;
+ namedCurve: string;
+}
+interface CryptoKeyArbitraryKeyAlgorithm {
+ name: string;
+ hash?: CryptoKeyKeyAlgorithm;
+ namedCurve?: string;
+ length?: number;
+}
+declare class DigestStream extends WritableStream {
+ constructor(algorithm: string | SubtleCryptoHashAlgorithm, options?: DigestStreamOptions);
+ readonly digest: Promise;
+ get bytesWritten(): number | bigint;
+}
+interface DigestStreamOptions {
+ toWellFormed?: boolean;
+}
+/**
+ * The **`TextDecoder`** interface represents a decoder for a specific text encoding, such as UTF-8, ISO-8859-2, or GBK. A decoder takes an array of bytes as input and returns a JavaScript string.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder)
+ */
+declare class TextDecoder {
+ constructor(label?: string, options?: TextDecoderConstructorOptions);
+ /**
+ * The **`TextDecoder.decode()`** method returns a string containing text decoded from the buffer passed as a parameter.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/decode)
+ */
+ decode(input?: (ArrayBuffer | ArrayBufferView), options?: TextDecoderDecodeOptions): string;
+ get encoding(): string;
+ get fatal(): boolean;
+ get ignoreBOM(): boolean;
+}
+/**
+ * The **`TextEncoder`** interface enables you to encode a JavaScript string using UTF-8.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder)
+ */
+declare class TextEncoder {
+ constructor();
+ /**
+ * The **`TextEncoder.encode()`** method takes a string as input, and returns a Uint8Array containing the string encoded using UTF-8.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encode)
+ */
+ encode(input?: string): Uint8Array;
+ /**
+ * The **`TextEncoder.encodeInto()`** method takes a string to encode and a destination Uint8Array to put resulting UTF-8 encoded text into, and returns an object indicating the progress of the encoding. This is potentially more performant than the encode() method — especially when the target buffer is a view into a Wasm heap.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encodeInto)
+ */
+ encodeInto(input: string, buffer: Uint8Array): TextEncoderEncodeIntoResult;
+ get encoding(): string;
+}
+interface TextDecoderConstructorOptions {
+ fatal: boolean;
+ ignoreBOM: boolean;
+}
+interface TextDecoderDecodeOptions {
+ stream: boolean;
+}
+interface TextEncoderEncodeIntoResult {
+ read: number;
+ written: number;
+}
+/**
+ * The **`ErrorEvent`** interface represents events providing information related to errors in scripts or in files.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent)
+ */
+declare class ErrorEvent extends Event {
+ constructor(type: string, init?: ErrorEventErrorEventInit);
+ /**
+ * The **`filename`** read-only property of the ErrorEvent interface returns a string containing the name of the script file in which the error occurred.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/filename)
+ */
+ get filename(): string;
+ /**
+ * The **`message`** read-only property of the ErrorEvent interface returns a string containing a human-readable error message describing the problem.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/message)
+ */
+ get message(): string;
+ /**
+ * The **`lineno`** read-only property of the ErrorEvent interface returns an integer containing the line number of the script file on which the error occurred.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/lineno)
+ */
+ get lineno(): number;
+ /**
+ * The **`colno`** read-only property of the ErrorEvent interface returns an integer containing the column number of the script file on which the error occurred.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/colno)
+ */
+ get colno(): number;
+ /**
+ * The **`error`** read-only property of the ErrorEvent interface returns a JavaScript value, such as an Error or DOMException, representing the error associated with this event.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/error)
+ */
+ get error(): any;
+}
+interface ErrorEventErrorEventInit {
+ bubbles?: boolean;
+ cancelable?: boolean;
+ composed?: boolean;
+ message?: string;
+ filename?: string;
+ lineno?: number;
+ colno?: number;
+ error?: any;
+}
+/**
+ * The **`MessageEvent`** interface represents a message received by a target object.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent)
+ */
+declare class MessageEvent extends Event {
+ constructor(type: string, initializer?: MessageEventInit);
+ /**
+ * The **`data`** read-only property of the MessageEvent interface represents the data sent by the message emitter.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/data)
+ */
+ readonly data: any;
+ /**
+ * The **`origin`** read-only property of the MessageEvent interface is a string representing the origin of the message emitter.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/origin)
+ */
+ readonly origin: string | null;
+ /**
+ * The **`lastEventId`** read-only property of the MessageEvent interface is a string representing a unique ID for the event.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/lastEventId)
+ */
+ readonly lastEventId: string;
+ /**
+ * The **`source`** read-only property of the MessageEvent interface is a MessageEventSource (which can be a WindowProxy, MessagePort, or ServiceWorker object) representing the message emitter.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/source)
+ */
+ readonly source: MessagePort | null;
+ /**
+ * The **`ports`** read-only property of the MessageEvent interface is an array of MessagePort objects containing all MessagePort objects sent with the message, in order.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/ports)
+ */
+ readonly ports: MessagePort[];
+}
+interface MessageEventInit {
+ bubbles?: boolean;
+ cancelable?: boolean;
+ composed?: boolean;
+ data?: any;
+ origin?: string;
+ lastEventId?: string;
+ source?: (MessagePort | null);
+ ports?: MessagePort[];
+}
+/**
+ * The **`PromiseRejectionEvent`** interface represents events which are sent to the global script context when JavaScript Promises are rejected. These events are particularly useful for telemetry and debugging purposes.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent)
+ */
+declare abstract class PromiseRejectionEvent extends Event {
+ /**
+ * The PromiseRejectionEvent interface's **`promise`** read-only property indicates the JavaScript Promise which was rejected. You can examine the event's PromiseRejectionEvent.reason property to learn why the promise was rejected.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/promise)
+ */
+ readonly promise: Promise;
+ /**
+ * The PromiseRejectionEvent **`reason`** read-only property is any JavaScript value or Object which provides the reason passed into Promise.reject(). This in theory provides information about why the promise was rejected.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/reason)
+ */
+ readonly reason: any;
+}
+/**
+ * The **`FormData`** interface provides a way to construct a set of key/value pairs representing form fields and their values, which can be sent using the fetch(), XMLHttpRequest.send() or navigator.sendBeacon() methods. It uses the same format a form would use if the encoding type were set to "multipart/form-data".
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData)
+ */
+declare class FormData {
+ constructor();
+ /**
+ * The **`append()`** method of the FormData interface appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
+ */
+ append(name: string, value: string | Blob): void;
+ /**
+ * The **`append()`** method of the FormData interface appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
+ */
+ append(name: string, value: string): void;
+ /**
+ * The **`append()`** method of the FormData interface appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
+ */
+ append(name: string, value: Blob, filename?: string): void;
+ /**
+ * The **`delete()`** method of the FormData interface deletes a key and its value(s) from a FormData object.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/delete)
+ */
+ delete(name: string): void;
+ /**
+ * The **`get()`** method of the FormData interface returns the first value associated with a given key from within a FormData object. If you expect multiple values and want all of them, use the getAll() method instead.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/get)
+ */
+ get(name: string): (File | string) | null;
+ /**
+ * The **`getAll()`** method of the FormData interface returns all the values associated with a given key from within a FormData object.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/getAll)
+ */
+ getAll(name: string): (File | string)[];
+ /**
+ * The **`has()`** method of the FormData interface returns whether a FormData object contains a certain key.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/has)
+ */
+ has(name: string): boolean;
+ /**
+ * The **`set()`** method of the FormData interface sets a new value for an existing key inside a FormData object, or adds the key/value if it does not already exist.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
+ */
+ set(name: string, value: string | Blob): void;
+ /**
+ * The **`set()`** method of the FormData interface sets a new value for an existing key inside a FormData object, or adds the key/value if it does not already exist.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
+ */
+ set(name: string, value: string): void;
+ /**
+ * The **`set()`** method of the FormData interface sets a new value for an existing key inside a FormData object, or adds the key/value if it does not already exist.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
+ */
+ set(name: string, value: Blob, filename?: string): void;
+ entries(): IterableIterator<[
+ key: string,
+ value: File | string
+ ]>;
+ keys(): IterableIterator;
+ values(): IterableIterator<(File | string)>;
+ forEach(callback: (this: This, value: File | string, key: string, parent: FormData) => void, thisArg?: This): void;
+ [Symbol.iterator](): IterableIterator<[
+ key: string,
+ value: File | string
+ ]>;
+}
+interface ContentOptions {
+ html?: boolean;
+}
+declare class HTMLRewriter {
+ constructor();
+ on(selector: string, handlers: HTMLRewriterElementContentHandlers): HTMLRewriter;
+ onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter;
+ transform(response: Response): Response;
+}
+interface HTMLRewriterElementContentHandlers {
+ element?(element: Element): void | Promise;
+ comments?(comment: Comment): void | Promise;
+ text?(element: Text): void | Promise;
+}
+interface HTMLRewriterDocumentContentHandlers {
+ doctype?(doctype: Doctype): void | Promise;
+ comments?(comment: Comment): void | Promise;
+ text?(text: Text): void | Promise;
+ end?(end: DocumentEnd): void | Promise;
+}
+interface Doctype {
+ readonly name: string | null;
+ readonly publicId: string | null;
+ readonly systemId: string | null;
+}
+interface Element {
+ tagName: string;
+ readonly attributes: IterableIterator;
+ readonly removed: boolean;
+ readonly namespaceURI: string;
+ getAttribute(name: string): string | null;
+ hasAttribute(name: string): boolean;
+ setAttribute(name: string, value: string): Element;
+ removeAttribute(name: string): Element;
+ before(content: string | ReadableStream | Response, options?: ContentOptions): Element;
+ after(content: string | ReadableStream | Response, options?: ContentOptions): Element;
+ prepend(content: string | ReadableStream | Response, options?: ContentOptions): Element;
+ append(content: string | ReadableStream | Response, options?: ContentOptions): Element;
+ replace(content: string | ReadableStream | Response, options?: ContentOptions): Element;
+ remove(): Element;
+ removeAndKeepContent(): Element;
+ setInnerContent(content: string | ReadableStream | Response, options?: ContentOptions): Element;
+ onEndTag(handler: (tag: EndTag) => void | Promise): void;
+}
+interface EndTag {
+ name: string;
+ before(content: string | ReadableStream | Response, options?: ContentOptions): EndTag;
+ after(content: string | ReadableStream | Response, options?: ContentOptions): EndTag;
+ remove(): EndTag;
+}
+interface Comment {
+ text: string;
+ readonly removed: boolean;
+ before(content: string, options?: ContentOptions): Comment;
+ after(content: string, options?: ContentOptions): Comment;
+ replace(content: string, options?: ContentOptions): Comment;
+ remove(): Comment;
+}
+interface Text {
+ readonly text: string;
+ readonly lastInTextNode: boolean;
+ readonly removed: boolean;
+ before(content: string | ReadableStream | Response, options?: ContentOptions): Text;
+ after(content: string | ReadableStream | Response, options?: ContentOptions): Text;
+ replace(content: string | ReadableStream | Response, options?: ContentOptions): Text;
+ remove(): Text;
+}
+interface DocumentEnd {
+ append(content: string, options?: ContentOptions): DocumentEnd;
+}
+/**
+ * This is the event type for fetch events dispatched on the service worker global scope. It contains information about the fetch, including the request and how the receiver will treat the response. It provides the event.respondWith() method, which allows us to provide a response to this fetch.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent)
+ */
+declare abstract class FetchEvent extends ExtendableEvent {
+ /**
+ * The **`request`** read-only property of the FetchEvent interface returns the Request that triggered the event handler.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/request)
+ */
+ readonly request: Request;
+ /**
+ * The **`respondWith()`** method of FetchEvent prevents the browser's default fetch handling, and allows you to provide a promise for a Response yourself.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/respondWith)
+ */
+ respondWith(promise: Response | Promise): void;
+ passThroughOnException(): void;
+}
+type HeadersInit = Headers | Iterable> | Record;
+/**
+ * The **`Headers`** interface of the Fetch API allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing headers from the list of the request's headers.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers)
+ */
+declare class Headers {
+ constructor(init?: HeadersInit);
+ /**
+ * The **`get()`** method of the Headers interface returns a byte string of all the values of a header within a Headers object with a given name. If the requested header doesn't exist in the Headers object, it returns null.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/get)
+ */
+ get(name: string): string | null;
+ getAll(name: string): string[];
+ /**
+ * The **`getSetCookie()`** method of the Headers interface returns an array containing the values of all Set-Cookie headers associated with a response. This allows Headers objects to handle having multiple Set-Cookie headers, which wasn't possible prior to its implementation.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/getSetCookie)
+ */
+ getSetCookie(): string[];
+ /**
+ * The **`has()`** method of the Headers interface returns a boolean stating whether a Headers object contains a certain header.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/has)
+ */
+ has(name: string): boolean;
+ /**
+ * The **`set()`** method of the Headers interface sets a new value for an existing header inside a Headers object, or adds the header if it does not already exist.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set)
+ */
+ set(name: string, value: string): void;
+ /**
+ * The **`append()`** method of the Headers interface appends a new value onto an existing header inside a Headers object, or adds the header if it does not already exist.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append)
+ */
+ append(name: string, value: string): void;
+ /**
+ * The **`delete()`** method of the Headers interface deletes a header from the current Headers object.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/delete)
+ */
+ delete(name: string): void;
+ forEach(callback: (this: This, value: string, key: string, parent: Headers) => void, thisArg?: This): void;
+ entries(): IterableIterator<[
+ key: string,
+ value: string
+ ]>;
+ keys(): IterableIterator;
+ values(): IterableIterator;
+ [Symbol.iterator](): IterableIterator<[
+ key: string,
+ value: string
+ ]>;
+}
+type BodyInit = ReadableStream | string | ArrayBuffer | ArrayBufferView | Blob | URLSearchParams | FormData | Iterable | AsyncIterable;
+declare abstract class Body {
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body) */
+ get body(): ReadableStream | null;
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */
+ get bodyUsed(): boolean;
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */
+ arrayBuffer(): Promise;
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes) */
+ bytes(): Promise;
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text) */
+ text(): Promise;
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json) */
+ json(): Promise;
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData) */
+ formData(): Promise;
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */
+ blob(): Promise;
+}
+/**
+ * The **`Response`** interface of the Fetch API represents the response to a request.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
+ */
+declare var Response: {
+ prototype: Response;
+ new (body?: BodyInit | null, init?: ResponseInit): Response;
+ error(): Response;
+ redirect(url: string, status?: number): Response;
+ json(any: any, maybeInit?: (ResponseInit | Response)): Response;
+};
+/**
+ * The **`Response`** interface of the Fetch API represents the response to a request.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
+ */
+interface Response extends Body {
+ /**
+ * The **`clone()`** method of the Response interface creates a clone of a response object, identical in every way, but stored in a different variable.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone)
+ */
+ clone(): Response;
+ /**
+ * The **`status`** read-only property of the Response interface contains the HTTP status codes of the response.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status)
+ */
+ status: number;
+ /**
+ * The **`statusText`** read-only property of the Response interface contains the status message corresponding to the HTTP status code in Response.status.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText)
+ */
+ statusText: string;
+ /**
+ * The **`headers`** read-only property of the Response interface contains the Headers object associated with the response.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers)
+ */
+ headers: Headers;
+ /**
+ * The **`ok`** read-only property of the Response interface contains a Boolean stating whether the response was successful (status in the range 200-299) or not.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok)
+ */
+ ok: boolean;
+ /**
+ * The **`redirected`** read-only property of the Response interface indicates whether or not the response is the result of a request you made which was redirected.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected)
+ */
+ redirected: boolean;
+ /**
+ * The **`url`** read-only property of the Response interface contains the URL of the response. The value of the url property will be the final URL obtained after any redirects.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url)
+ */
+ url: string;
+ webSocket: WebSocket | null;
+ cf: any | undefined;
+ /**
+ * The **`type`** read-only property of the Response interface contains the type of the response. The type determines whether scripts are able to access the response body and headers.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/type)
+ */
+ type: "default" | "error";
+}
+interface ResponseInit {
+ status?: number;
+ statusText?: string;
+ headers?: HeadersInit;
+ cf?: any;
+ webSocket?: (WebSocket | null);
+ encodeBody?: "automatic" | "manual";
+}
+type RequestInfo> = Request | string;
+/**
+ * The **`Request`** interface of the Fetch API represents a resource request.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
+ */
+declare var Request: {
+ prototype: Request;
+ new >(input: RequestInfo | URL, init?: RequestInit): Request;
+};
+/**
+ * The **`Request`** interface of the Fetch API represents a resource request.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
+ */
+interface Request> extends Body {
+ /**
+ * The **`clone()`** method of the Request interface creates a copy of the current Request object.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone)
+ */
+ clone(): Request;
+ /**
+ * The **`method`** read-only property of the Request interface contains the request's method (GET, POST, etc.)
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method)
+ */
+ method: string;
+ /**
+ * The **`url`** read-only property of the Request interface contains the URL of the request.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url)
+ */
+ url: string;
+ /**
+ * The **`headers`** read-only property of the Request interface contains the Headers object associated with the request.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers)
+ */
+ headers: Headers;
+ /**
+ * The **`redirect`** read-only property of the Request interface contains the mode for how redirects are handled.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect)
+ */
+ redirect: string;
+ fetcher: Fetcher | null;
+ /**
+ * The read-only **`signal`** property of the Request interface returns the AbortSignal associated with the request.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal)
+ */
+ signal: AbortSignal;
+ cf?: Cf;
+ /**
+ * The **`integrity`** read-only property of the Request interface contains the subresource integrity value of the request.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity)
+ */
+ integrity: string;
+ /**
+ * The **`keepalive`** read-only property of the Request interface contains the request's keepalive setting (true or false), which indicates whether the browser will keep the associated request alive if the page that initiated it is unloaded before the request is complete.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive)
+ */
+ keepalive: boolean;
+ /**
+ * The **`cache`** read-only property of the Request interface contains the cache mode of the request. It controls how the request will interact with the browser's HTTP cache.
+ *
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/cache)
+ */
+ cache?: "no-store" | "no-cache";
+}
+interface RequestInit {
+ /* A string to set request's method. */
+ method?: string;
+ /* A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
+ headers?: HeadersInit;
+ /* A BodyInit object or null to set request's body. */
+ body?: BodyInit | null;
+ /* A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. */
+ redirect?: string;
+ fetcher?: (Fetcher | null);
+ cf?: Cf;
+ /* A string indicating how the request will interact with the browser's cache to set request's cache. */
+ cache?: "no-store" | "no-cache";
+ /* A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
+ integrity?: string;
+ /* An AbortSignal to set request's signal. */
+ signal?: (AbortSignal | null);
+ encodeResponseBody?: "automatic" | "manual";
+}
+type Service Rpc.WorkerEntrypointBranded) | Rpc.WorkerEntrypointBranded | ExportedHandler | undefined = undefined> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded ? Fetcher> : T extends Rpc.WorkerEntrypointBranded ? Fetcher : T extends Exclude ? never : Fetcher;
+type Fetcher = (T extends Rpc.EntrypointBranded ? Rpc.Provider : unknown) & {
+ fetch(input: RequestInfo | URL, init?: RequestInit): Promise;
+ connect(address: SocketAddress | string, options?: SocketOptions): Socket;
+};
+interface KVNamespaceListKey {
+ name: Key;
+ expiration?: number;
+ metadata?: Metadata;
+}
+type KVNamespaceListResult = {
+ list_complete: false;
+ keys: KVNamespaceListKey[];
+ cursor: string;
+ cacheStatus: string | null;
+} | {
+ list_complete: true;
+ keys: KVNamespaceListKey[];
+ cacheStatus: string | null;
+};
+interface KVNamespace {
+ get(key: Key, options?: Partial>): Promise;
+ get(key: Key, type: "text"): Promise;
+ get(key: Key, type: "json"): Promise;
+ get(key: Key, type: "arrayBuffer"): Promise;
+ get(key: Key, type: "stream"): Promise;
+ get(key: Key, options?: KVNamespaceGetOptions<"text">): Promise;
+ get(key: Key, options?: KVNamespaceGetOptions<"json">): Promise;
+ get(key: Key, options?: KVNamespaceGetOptions<"arrayBuffer">): Promise;
+ get(key: Key, options?: KVNamespaceGetOptions<"stream">): Promise;
+ get(key: Array, type: "text"): Promise>;
+ get(key: Array, type: "json"): Promise>;
+ get(key: Array, options?: Partial>): Promise>;
+ get(key: Array, options?: KVNamespaceGetOptions<"text">): Promise>;
+ get(key: Array, options?: KVNamespaceGetOptions<"json">): Promise>;
+ list(options?: KVNamespaceListOptions): Promise>;
+ put(key: Key, value: string | ArrayBuffer | ArrayBufferView | ReadableStream, options?: KVNamespacePutOptions): Promise;
+ getWithMetadata(key: Key, options?: Partial>): Promise>;
+ getWithMetadata(key: Key, type: "text"): Promise>;
+ getWithMetadata(key: Key, type: "json"): Promise>;
+ getWithMetadata(key: Key, type: "arrayBuffer"): Promise