├── .prettierrc ├── test ├── cloudflare-test.d.ts ├── tsconfig.json └── index.spec.ts ├── worker-configuration.d.ts ├── .editorconfig ├── vitest.config.mts ├── package.json ├── README.md ├── .gitignore ├── src └── index.ts ├── wrangler.toml └── tsconfig.json /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 140, 3 | "singleQuote": true, 4 | "semi": true, 5 | "useTabs": true 6 | } 7 | -------------------------------------------------------------------------------- /test/cloudflare-test.d.ts: -------------------------------------------------------------------------------- 1 | declare module "cloudflare:test" { 2 | interface ProvidedEnv extends Env {} 3 | } 4 | -------------------------------------------------------------------------------- /worker-configuration.d.ts: -------------------------------------------------------------------------------- 1 | // Generated by Wrangler on Thu Jul 11 2024 23:55:59 GMT-0700 (Pacific Daylight Time) 2 | // by running `wrangler types` 3 | 4 | interface Env { 5 | AUTO_OTP_FLOW_KV: KVNamespace; 6 | } 7 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = tab 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.yml] 12 | indent_style = space 13 | -------------------------------------------------------------------------------- /vitest.config.mts: -------------------------------------------------------------------------------- 1 | import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config'; 2 | 3 | export default defineWorkersConfig({ 4 | test: { 5 | poolOptions: { 6 | workers: { 7 | wrangler: { configPath: './wrangler.toml' }, 8 | }, 9 | }, 10 | }, 11 | }); 12 | -------------------------------------------------------------------------------- /test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "types": [ 5 | "@cloudflare/workers-types/experimental", 6 | "@cloudflare/vitest-pool-workers" 7 | ] 8 | }, 9 | "include": [ 10 | "./**/*.ts", 11 | "../src/env.d.ts", 12 | "../worker-configuration.d.ts" 13 | ], 14 | "exclude": [] 15 | } 16 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "auto-otp-flow", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "deploy": "wrangler deploy", 7 | "dev": "wrangler dev", 8 | "start": "wrangler dev", 9 | "test": "vitest", 10 | "cf-typegen": "wrangler types" 11 | }, 12 | "devDependencies": { 13 | "@cloudflare/vitest-pool-workers": "^0.4.5", 14 | "@cloudflare/workers-types": "^4.20240701.0", 15 | "typescript": "^5.5.2", 16 | "vitest": "1.5.0", 17 | "wrangler": "^3.60.3" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 📬 Auto OTP Flow 2 | 3 | This is a simple Cloudflare Workers service to take incoming email, store it into a KV store temporaily, and permit retrieval of the email with a query. It is to be used for retrieving [One-time password](https://en.wikipedia.org/wiki/One-time_password) calls. 4 | 5 | For pure API access, compared to Mailinator's offerings, this is far cheaper, and has far, far higher limits. 6 | 7 | ## Usage 8 | 9 | It is an alternative to Mailinator's service that you can use cheaply and re-host should you desire for privacy reasons. 10 | 11 | A public version of this is hosted at `470079.xyz`. 12 | 13 | `.xyz` domains more than 6 numbers long are cheap at a dollar a year and relatively short. A top-level domain is necessary to use the catch-all email functionality of Cloudflare Workers on a domain as subdomains aren't supported. 14 | 15 | Additionally, it's kind of scary to send to it because it is strange and numeric right? If you care about privacy, you can host this yourself too. It also reminds you that you can do that. You'll need to change the binding for the KV namespace though. That is an exercise left to you. 16 | 17 | You can email any email address at `470079.xyz` and retrieve the email with a secret key being the secret and made-up email address you sent the email to. Use forwarding rules in your email client or service to do so. 18 | 19 | Setup your mail client or service to selectively forward the OTP email(s) to your secret target email address. The email will be stored for half an hour. 20 | 21 | Visit the endpoint `https://470079.xyz/r/` to see the list of emails stored in the KV store for that email address. You will get a JSON response with all the emails stored. 22 | 23 | It is up to you to parse the JSON, handle sorting, and parse the emails to get the OTP or other information you need. The body is minimallly parsed for ease of debugging so handle that on your end. 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | 3 | logs 4 | _.log 5 | npm-debug.log_ 6 | yarn-debug.log* 7 | yarn-error.log* 8 | lerna-debug.log* 9 | .pnpm-debug.log* 10 | 11 | # Diagnostic reports (https://nodejs.org/api/report.html) 12 | 13 | report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json 14 | 15 | # Runtime data 16 | 17 | pids 18 | _.pid 19 | _.seed 20 | \*.pid.lock 21 | 22 | # Directory for instrumented libs generated by jscoverage/JSCover 23 | 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | 28 | coverage 29 | \*.lcov 30 | 31 | # nyc test coverage 32 | 33 | .nyc_output 34 | 35 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 36 | 37 | .grunt 38 | 39 | # Bower dependency directory (https://bower.io/) 40 | 41 | bower_components 42 | 43 | # node-waf configuration 44 | 45 | .lock-wscript 46 | 47 | # Compiled binary addons (https://nodejs.org/api/addons.html) 48 | 49 | build/Release 50 | 51 | # Dependency directories 52 | 53 | node_modules/ 54 | jspm_packages/ 55 | 56 | # Snowpack dependency directory (https://snowpack.dev/) 57 | 58 | web_modules/ 59 | 60 | # TypeScript cache 61 | 62 | \*.tsbuildinfo 63 | 64 | # Optional npm cache directory 65 | 66 | .npm 67 | 68 | # Optional eslint cache 69 | 70 | .eslintcache 71 | 72 | # Optional stylelint cache 73 | 74 | .stylelintcache 75 | 76 | # Microbundle cache 77 | 78 | .rpt2_cache/ 79 | .rts2_cache_cjs/ 80 | .rts2_cache_es/ 81 | .rts2_cache_umd/ 82 | 83 | # Optional REPL history 84 | 85 | .node_repl_history 86 | 87 | # Output of 'npm pack' 88 | 89 | \*.tgz 90 | 91 | # Yarn Integrity file 92 | 93 | .yarn-integrity 94 | 95 | # dotenv environment variable files 96 | 97 | .env 98 | .env.development.local 99 | .env.test.local 100 | .env.production.local 101 | .env.local 102 | 103 | # parcel-bundler cache (https://parceljs.org/) 104 | 105 | .cache 106 | .parcel-cache 107 | 108 | # Next.js build output 109 | 110 | .next 111 | out 112 | 113 | # Nuxt.js build / generate output 114 | 115 | .nuxt 116 | dist 117 | 118 | # Gatsby files 119 | 120 | .cache/ 121 | 122 | # Comment in the public line in if your project uses Gatsby and not Next.js 123 | 124 | # https://nextjs.org/blog/next-9-1#public-directory-support 125 | 126 | # public 127 | 128 | # vuepress build output 129 | 130 | .vuepress/dist 131 | 132 | # vuepress v2.x temp and cache directory 133 | 134 | .temp 135 | .cache 136 | 137 | # Docusaurus cache and generated files 138 | 139 | .docusaurus 140 | 141 | # Serverless directories 142 | 143 | .serverless/ 144 | 145 | # FuseBox cache 146 | 147 | .fusebox/ 148 | 149 | # DynamoDB Local files 150 | 151 | .dynamodb/ 152 | 153 | # TernJS port file 154 | 155 | .tern-port 156 | 157 | # Stores VSCode versions used for testing VSCode extensions 158 | 159 | .vscode-test 160 | 161 | # yarn v2 162 | 163 | .yarn/cache 164 | .yarn/unplugged 165 | .yarn/build-state.yml 166 | .yarn/install-state.gz 167 | .pnp.\* 168 | 169 | # wrangler project 170 | 171 | .dev.vars 172 | .wrangler/ 173 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Welcome to Cloudflare Workers! This is your first worker. 3 | * 4 | * - Run `npm run dev` in your terminal to start a development server 5 | * - Open a browser tab at http://localhost:8787/ to see your worker in action 6 | * - Run `npm run deploy` to publish your worker 7 | * 8 | * Bind resources to your worker in `wrangler.toml`. After adding bindings, a type definition for the 9 | * `Env` object can be regenerated with `npm run cf-typegen`. 10 | * 11 | * Learn more at https://developers.cloudflare.com/workers/ 12 | */ 13 | 14 | 15 | export interface JsonEmail { 16 | processedDateTime: string; 17 | to: string; 18 | from: string; 19 | raw: string; 20 | headers: Record; 21 | } 22 | 23 | export default { 24 | async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise { 25 | const url = new URL(request.url); 26 | // See if the path has "/r/", parse the next part as the email address to retrieve emails for 27 | if (url.pathname.startsWith('/r/')) { 28 | const emails = await env.AUTO_OTP_FLOW_KV.list({ 29 | prefix: 'email:' + url.pathname.slice(3), 30 | }); 31 | if (emails.keys.length === 0) { 32 | return new Response(JSON.stringify({ 33 | error: 'No emails found', 34 | }), { 35 | headers: { 36 | 'Content-Type': 'application/json', 37 | }, 38 | status: 404 39 | }); 40 | } 41 | // Get all the emails and join them into a single array 42 | const emailDataPromise = Promise.all( 43 | emails.keys.map(async (key) => { 44 | const email = await env.AUTO_OTP_FLOW_KV.get( 45 | key.name, 46 | { 47 | type: 'json', 48 | } 49 | ) as JsonEmail; 50 | return email ? [email] : []; 51 | }) 52 | ); 53 | 54 | const emailData = (await emailDataPromise).flat(); 55 | 56 | return new Response(JSON.stringify({ 57 | emails: emailData, 58 | }), { 59 | headers: { 60 | 'Content-Type': 'application/json', 61 | }, 62 | }); 63 | 64 | } 65 | return new Response('Hello World!'); 66 | }, 67 | 68 | async email(message, env, ctx) { 69 | const reader = message.raw.getReader(); 70 | const chunks = []; 71 | let done = false; 72 | while (!done) { 73 | const { value, done: rDone } = await reader.read(); 74 | if (value) { 75 | chunks.push(value); 76 | } 77 | done = rDone; 78 | } 79 | const body = new Uint8Array(chunks.reduce((acc, chunk) => acc + chunk.length, 0)); 80 | let offset = 0; 81 | for (const chunk of chunks) { 82 | body.set(chunk, offset); 83 | offset += chunk.length; 84 | } 85 | const bodyText = new TextDecoder().decode(body); 86 | 87 | const headersObj: Record = {}; 88 | message.headers.forEach((value, key) => { 89 | headersObj[key] = value; 90 | }); 91 | 92 | const value = { 93 | processedDateTime: new Date().toISOString(), 94 | to: message.to, 95 | from: message.from, 96 | raw: bodyText, 97 | headers: headersObj, 98 | }; 99 | 100 | // Log the email 101 | console.log({ 102 | msg: 'Worker received email', 103 | data: { 104 | value 105 | }, 106 | }); 107 | 108 | // Store the email in the KV namespace 109 | await env.AUTO_OTP_FLOW_KV.put( 110 | 'email:' + message.to, 111 | JSON.stringify(value), 112 | // Expire the email after 30 minutes 113 | { expirationTtl: 30 * 60 } 114 | ); 115 | } 116 | } satisfies ExportedHandler; 117 | -------------------------------------------------------------------------------- /test/index.spec.ts: -------------------------------------------------------------------------------- 1 | // test/index.spec.ts 2 | import { env, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test'; 3 | import { describe, it, expect } from 'vitest'; 4 | import worker, {JsonEmail} from '../src/index'; 5 | 6 | // For now, you'll need to do something like this to get a correctly-typed 7 | // `Request` to pass to `worker.fetch()`. 8 | const IncomingRequest = Request; 9 | 10 | describe('Hello World worker', () => { 11 | it('responds with Hello World! (unit style)', async () => { 12 | const request = new IncomingRequest('http://example.com'); 13 | // Create an empty context to pass to `worker.fetch()`. 14 | const ctx = createExecutionContext(); 15 | const response = await worker.fetch(request, env, ctx); 16 | // Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions 17 | await waitOnExecutionContext(ctx); 18 | expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`); 19 | }); 20 | 21 | it('responds with Hello World! (integration style)', async () => { 22 | const response = await SELF.fetch('https://example.com'); 23 | expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`); 24 | }); 25 | 26 | it('handles emails, stores them, and makes them retrievable', async () => { 27 | const ctx = createExecutionContext(); 28 | class MockEmail { 29 | from: string; 30 | to: string; 31 | raw: ReadableStream; 32 | headers: Headers; 33 | rawSize: number; 34 | rejectReason: string | undefined; 35 | forwarded_to: string | undefined; 36 | 37 | constructor(from: string, to: string, rawBodyText: string, headers: Record) { 38 | this.from = from; 39 | this.to = to; 40 | const uint8ArrayContent = new TextEncoder().encode(rawBodyText); 41 | const readableStream = new ReadableStream({ 42 | start(controller) { 43 | controller.enqueue(uint8ArrayContent); 44 | controller.close(); // Close the stream after enqueueing the content 45 | } 46 | }); 47 | this.raw = readableStream; 48 | this.rawSize = uint8ArrayContent.length; 49 | this.headers = new Headers(headers); 50 | this.rejectReason = undefined; // No rejection reason initially 51 | } 52 | 53 | // Simulate sending the email 54 | send() { 55 | // This service has no sending, do not test. 56 | } 57 | 58 | setReject(reason: string) { 59 | this.rejectReason = reason; 60 | } 61 | 62 | async forward(to: string) { 63 | // This service has no forwarding, do not test. 64 | } 65 | } 66 | 67 | // Usage 68 | const secret_email_key = 'secret_email_key@service.example'; 69 | 70 | const email = new MockEmail( 71 | 'service_user@example.com', 72 | secret_email_key, 73 | "Hi, I'm a test email! The OTP is 123456.", 74 | { "content-type": "text/plain" }); 75 | 76 | await worker.email( 77 | email, 78 | env, 79 | ctx 80 | ); 81 | 82 | // Check if the KV store has the email (TODO: Use implementation-specific methods to check for the email in the KV store) 83 | const storedEmailsList = await env.AUTO_OTP_FLOW_KV.list({ 84 | prefix: 'email:' + secret_email_key, 85 | }); 86 | expect(storedEmailsList.keys).toHaveLength(1); 87 | // Look at the stored email 88 | const storedEmail = await env.AUTO_OTP_FLOW_KV.get('email:' + secret_email_key); 89 | 90 | // Now check with fetch 91 | const response = await SELF.fetch('https://example.com/r/' + secret_email_key); 92 | const responseJson = await response.json() as { emails: JsonEmail[] }; 93 | expect(responseJson.emails).toHaveLength(1); 94 | // Grab the first email 95 | const emailData = responseJson.emails[0]; 96 | // Match the email data except for the processedDateTime, which we just check exists and is a date 97 | // Check date 98 | expect(new Date(emailData.processedDateTime)).toBeInstanceOf(Date); 99 | // Check the rest of the email 100 | expect(emailData).toMatchObject({ 101 | to: secret_email_key, 102 | from: 'service_user@example.com', 103 | raw: "Hi, I'm a test email! The OTP is 123456.", 104 | headers: { "content-type": "text/plain" }, 105 | }); 106 | }); 107 | }); 108 | -------------------------------------------------------------------------------- /wrangler.toml: -------------------------------------------------------------------------------- 1 | #:schema node_modules/wrangler/config-schema.json 2 | name = "auto-otp-flow" 3 | main = "src/index.ts" 4 | compatibility_date = "2024-07-01" 5 | compatibility_flags = ["nodejs_compat"] 6 | 7 | # Automatically place your workloads in an optimal location to minimize latency. 8 | # If you are running back-end logic in a Worker, running it closer to your back-end infrastructure 9 | # rather than the end user may result in better performance. 10 | # Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement 11 | # [placement] 12 | # mode = "smart" 13 | 14 | # Variable bindings. These are arbitrary, plaintext strings (similar to environment variables) 15 | # Docs: 16 | # - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables 17 | # Note: Use secrets to store sensitive data. 18 | # - https://developers.cloudflare.com/workers/configuration/secrets/ 19 | # [vars] 20 | # MY_VARIABLE = "production_value" 21 | 22 | # Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network 23 | # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai 24 | # [ai] 25 | # binding = "AI" 26 | 27 | # Bind an Analytics Engine dataset. Use Analytics Engine to write analytics within your Pages Function. 28 | # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets 29 | # [[analytics_engine_datasets]] 30 | # binding = "MY_DATASET" 31 | 32 | # Bind a headless browser instance running on Cloudflare's global network. 33 | # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering 34 | # [browser] 35 | # binding = "MY_BROWSER" 36 | 37 | # Bind a D1 database. D1 is Cloudflare’s native serverless SQL database. 38 | # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases 39 | # [[d1_databases]] 40 | # binding = "MY_DB" 41 | # database_name = "my-database" 42 | # database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" 43 | 44 | # Bind a dispatch namespace. Use Workers for Platforms to deploy serverless functions programmatically on behalf of your customers. 45 | # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms 46 | # [[dispatch_namespaces]] 47 | # binding = "MY_DISPATCHER" 48 | # namespace = "my-namespace" 49 | 50 | # Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model. 51 | # Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps. 52 | # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects 53 | # [[durable_objects.bindings]] 54 | # name = "MY_DURABLE_OBJECT" 55 | # class_name = "MyDurableObject" 56 | 57 | # Durable Object migrations. 58 | # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#migrations 59 | # [[migrations]] 60 | # tag = "v1" 61 | # new_classes = ["MyDurableObject"] 62 | 63 | # Bind a Hyperdrive configuration. Use to accelerate access to your existing databases from Cloudflare Workers. 64 | # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive 65 | # [[hyperdrive]] 66 | # binding = "MY_HYPERDRIVE" 67 | # id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 68 | 69 | # Bind a KV Namespace. Use KV as persistent storage for small key-value pairs. 70 | # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces 71 | [[kv_namespaces]] 72 | binding = "AUTO_OTP_FLOW_KV" 73 | id = "d4a5f70d1d0147e5bf15c13c188f9a2e" 74 | 75 | # Bind an mTLS certificate. Use to present a client certificate when communicating with another service. 76 | # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates 77 | # [[mtls_certificates]] 78 | # binding = "MY_CERTIFICATE" 79 | # certificate_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" 80 | 81 | # Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer. 82 | # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues 83 | # [[queues.producers]] 84 | # binding = "MY_QUEUE" 85 | # queue = "my-queue" 86 | 87 | # Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them. 88 | # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues 89 | # [[queues.consumers]] 90 | # queue = "my-queue" 91 | 92 | # Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files. 93 | # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets 94 | # [[r2_buckets]] 95 | # binding = "MY_BUCKET" 96 | # bucket_name = "my-bucket" 97 | 98 | # Bind another Worker service. Use this binding to call another Worker without network overhead. 99 | # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings 100 | # [[services]] 101 | # binding = "MY_SERVICE" 102 | # service = "my-service" 103 | 104 | # Bind a Vectorize index. Use to store and query vector embeddings for semantic search, classification and other vector search use-cases. 105 | # Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes 106 | # [[vectorize]] 107 | # binding = "MY_INDEX" 108 | # index_name = "my-index" 109 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */ 4 | 5 | /* Projects */ 6 | // "incremental": true, /* Enable incremental compilation */ 7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ 8 | // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */ 9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */ 10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ 11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ 12 | 13 | /* Language and Environment */ 14 | "target": "es2021" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, 15 | "lib": ["es2021"] /* Specify a set of bundled library declaration files that describe the target runtime environment. */, 16 | "jsx": "react-jsx" /* Specify what JSX code is generated. */, 17 | // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ 18 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */ 20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */ 22 | // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */ 23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 25 | 26 | /* Modules */ 27 | "module": "es2022" /* Specify what module code is generated. */, 28 | // "rootDir": "./", /* Specify the root folder within your source files. */ 29 | "moduleResolution": "Bundler" /* Specify how TypeScript looks up a file from a given module specifier. */, 30 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 31 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 32 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 33 | // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */ 34 | "types": [ 35 | "@cloudflare/workers-types/2023-07-01" 36 | ] /* Specify type package names to be included without being referenced in a source file. */, 37 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 38 | "resolveJsonModule": true /* Enable importing .json files */, 39 | // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */ 40 | 41 | /* JavaScript Support */ 42 | "allowJs": true /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */, 43 | "checkJs": false /* Enable error reporting in type-checked JavaScript files. */, 44 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */ 45 | 46 | /* Emit */ 47 | // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ 48 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */ 49 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 50 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ 51 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */ 52 | // "outDir": "./", /* Specify an output folder for all emitted files. */ 53 | // "removeComments": true, /* Disable emitting comments. */ 54 | "noEmit": true /* Disable emitting files from a compilation. */, 55 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 56 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */ 57 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 58 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ 59 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 60 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 61 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 62 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 63 | // "newLine": "crlf", /* Set the newline character for emitting files. */ 64 | // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */ 65 | // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */ 66 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ 67 | // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */ 68 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 69 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 70 | 71 | /* Interop Constraints */ 72 | "isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */, 73 | "allowSyntheticDefaultImports": true /* Allow 'import x from y' when a module doesn't have a default export. */, 74 | // "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */, 75 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 76 | "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, 77 | 78 | /* Type Checking */ 79 | "strict": true /* Enable all strict type-checking options. */, 80 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */ 81 | // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */ 82 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 83 | // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ 84 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 85 | // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ 86 | // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ 87 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 88 | // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ 89 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ 90 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 91 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 92 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 93 | // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ 94 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 95 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */ 96 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 97 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 98 | 99 | /* Completeness */ 100 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 101 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 102 | }, 103 | "exclude": ["test"] 104 | } 105 | --------------------------------------------------------------------------------