@cloudflare/workers-types 0.20221111.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.ts ADDED
@@ -0,0 +1,2758 @@
1
+ /*! *****************************************************************************
2
+ Copyright (c) Cloudflare. All rights reserved.
3
+ Copyright (c) Microsoft Corporation. All rights reserved.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
6
+ this file except in compliance with the License. You may obtain a copy of the
7
+ License at http://www.apache.org/licenses/LICENSE-2.0
8
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
10
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
11
+ MERCHANTABLITY OR NON-INFRINGEMENT.
12
+ See the Apache Version 2.0 License for specific language governing permissions
13
+ and limitations under the License.
14
+ ***************************************************************************** */
15
+ /* eslint-disable */
16
+ // noinspection JSUnusedGlobalSymbols
17
+ export declare class DOMException extends Error {
18
+ constructor(message?: string, name?: string);
19
+ readonly message: string;
20
+ readonly name: string;
21
+ readonly code: number;
22
+ readonly stack: any;
23
+ static readonly INDEX_SIZE_ERR: number;
24
+ static readonly DOMSTRING_SIZE_ERR: number;
25
+ static readonly HIERARCHY_REQUEST_ERR: number;
26
+ static readonly WRONG_DOCUMENT_ERR: number;
27
+ static readonly INVALID_CHARACTER_ERR: number;
28
+ static readonly NO_DATA_ALLOWED_ERR: number;
29
+ static readonly NO_MODIFICATION_ALLOWED_ERR: number;
30
+ static readonly NOT_FOUND_ERR: number;
31
+ static readonly NOT_SUPPORTED_ERR: number;
32
+ static readonly INUSE_ATTRIBUTE_ERR: number;
33
+ static readonly INVALID_STATE_ERR: number;
34
+ static readonly SYNTAX_ERR: number;
35
+ static readonly INVALID_MODIFICATION_ERR: number;
36
+ static readonly NAMESPACE_ERR: number;
37
+ static readonly INVALID_ACCESS_ERR: number;
38
+ static readonly VALIDATION_ERR: number;
39
+ static readonly TYPE_MISMATCH_ERR: number;
40
+ static readonly SECURITY_ERR: number;
41
+ static readonly NETWORK_ERR: number;
42
+ static readonly ABORT_ERR: number;
43
+ static readonly URL_MISMATCH_ERR: number;
44
+ static readonly QUOTA_EXCEEDED_ERR: number;
45
+ static readonly TIMEOUT_ERR: number;
46
+ static readonly INVALID_NODE_TYPE_ERR: number;
47
+ static readonly DATA_CLONE_ERR: number;
48
+ }
49
+ export type WorkerGlobalScopeEventMap = {
50
+ fetch: FetchEvent;
51
+ scheduled: ScheduledEvent;
52
+ unhandledrejection: PromiseRejectionEvent;
53
+ rejectionhandled: PromiseRejectionEvent;
54
+ };
55
+ export declare abstract class WorkerGlobalScope extends EventTarget<WorkerGlobalScopeEventMap> {
56
+ EventTarget: typeof EventTarget;
57
+ }
58
+ export interface Console {
59
+ "assert"(condition?: boolean, ...data: any[]): void;
60
+ clear(): void;
61
+ count(label?: string): void;
62
+ countReset(label?: string): void;
63
+ debug(...data: any[]): void;
64
+ dir(item?: any, options?: any): void;
65
+ dirxml(...data: any[]): void;
66
+ error(...data: any[]): void;
67
+ group(...data: any[]): void;
68
+ groupCollapsed(...data: any[]): void;
69
+ groupEnd(): void;
70
+ info(...data: any[]): void;
71
+ log(...data: any[]): void;
72
+ table(tabularData?: any, properties?: string[]): void;
73
+ time(label?: string): void;
74
+ timeEnd(label?: string): void;
75
+ timeLog(label?: string, ...data: any[]): void;
76
+ timeStamp(label?: string): void;
77
+ trace(...data: any[]): void;
78
+ warn(...data: any[]): void;
79
+ }
80
+ export declare const console: Console;
81
+ export type BufferSource = ArrayBufferView | ArrayBuffer;
82
+ export declare namespace WebAssembly {
83
+ class CompileError extends Error {
84
+ constructor(message?: string);
85
+ }
86
+ class RuntimeError extends Error {
87
+ constructor(message?: string);
88
+ }
89
+ type ValueType =
90
+ | "anyfunc"
91
+ | "externref"
92
+ | "f32"
93
+ | "f64"
94
+ | "i32"
95
+ | "i64"
96
+ | "v128";
97
+ interface GlobalDescriptor {
98
+ value: ValueType;
99
+ mutable?: boolean;
100
+ }
101
+ class Global {
102
+ constructor(descriptor: GlobalDescriptor, value?: any);
103
+ value: any;
104
+ valueOf(): any;
105
+ }
106
+ type ImportValue = ExportValue | number;
107
+ type ModuleImports = Record<string, ImportValue>;
108
+ type Imports = Record<string, ModuleImports>;
109
+ type ExportValue = Function | Global | Memory | Table;
110
+ type Exports = Record<string, ExportValue>;
111
+ class Instance {
112
+ constructor(module: Module, imports?: Imports);
113
+ readonly exports: Exports;
114
+ }
115
+ interface MemoryDescriptor {
116
+ initial: number;
117
+ maximum?: number;
118
+ shared?: boolean;
119
+ }
120
+ class Memory {
121
+ constructor(descriptor: MemoryDescriptor);
122
+ readonly buffer: ArrayBuffer;
123
+ grow(delta: number): number;
124
+ }
125
+ type ImportExportKind = "function" | "global" | "memory" | "table";
126
+ interface ModuleExportDescriptor {
127
+ kind: ImportExportKind;
128
+ name: string;
129
+ }
130
+ interface ModuleImportDescriptor {
131
+ kind: ImportExportKind;
132
+ module: string;
133
+ name: string;
134
+ }
135
+ abstract class Module {
136
+ static customSections(module: Module, sectionName: string): ArrayBuffer[];
137
+ static exports(module: Module): ModuleExportDescriptor[];
138
+ static imports(module: Module): ModuleImportDescriptor[];
139
+ }
140
+ type TableKind = "anyfunc" | "externref";
141
+ interface TableDescriptor {
142
+ element: TableKind;
143
+ initial: number;
144
+ maximum?: number;
145
+ }
146
+ class Table {
147
+ constructor(descriptor: TableDescriptor, value?: any);
148
+ readonly length: number;
149
+ get(index: number): any;
150
+ grow(delta: number, value?: any): number;
151
+ set(index: number, value?: any): void;
152
+ }
153
+ function instantiate(module: Module, imports?: Imports): Promise<Instance>;
154
+ function validate(bytes: BufferSource): boolean;
155
+ }
156
+ /** This ServiceWorker API interface represents the global execution context of a service worker. */
157
+ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
158
+ DOMException: typeof DOMException;
159
+ WorkerGlobalScope: typeof WorkerGlobalScope;
160
+ btoa(data: string): string;
161
+ atob(data: string): string;
162
+ setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
163
+ setTimeout<Args extends any[]>(
164
+ callback: (...args: Args) => void,
165
+ msDelay?: number,
166
+ ...args: Args
167
+ ): number;
168
+ clearTimeout(timeoutId: number | null): void;
169
+ setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
170
+ setInterval<Args extends any[]>(
171
+ callback: (...args: Args) => void,
172
+ msDelay?: number,
173
+ ...args: Args
174
+ ): number;
175
+ clearInterval(timeoutId: number | null): void;
176
+ queueMicrotask(task: Function): void;
177
+ structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
178
+ fetch(
179
+ input: RequestInfo,
180
+ init?: RequestInit<RequestInitCfProperties>
181
+ ): Promise<Response>;
182
+ self: ServiceWorkerGlobalScope;
183
+ crypto: Crypto;
184
+ caches: CacheStorage;
185
+ scheduler: Scheduler;
186
+ Event: typeof Event;
187
+ ExtendableEvent: typeof ExtendableEvent;
188
+ PromiseRejectionEvent: typeof PromiseRejectionEvent;
189
+ FetchEvent: typeof FetchEvent;
190
+ TraceEvent: typeof TraceEvent;
191
+ ScheduledEvent: typeof ScheduledEvent;
192
+ MessageEvent: typeof MessageEvent;
193
+ CloseEvent: typeof CloseEvent;
194
+ ReadableStreamDefaultReader: typeof ReadableStreamDefaultReader;
195
+ ReadableStreamBYOBReader: typeof ReadableStreamBYOBReader;
196
+ ReadableStream: typeof ReadableStream;
197
+ WritableStream: typeof WritableStream;
198
+ WritableStreamDefaultWriter: typeof WritableStreamDefaultWriter;
199
+ TransformStream: typeof TransformStream;
200
+ ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;
201
+ CountQueuingStrategy: typeof CountQueuingStrategy;
202
+ CompressionStream: typeof CompressionStream;
203
+ DecompressionStream: typeof DecompressionStream;
204
+ TextEncoderStream: typeof TextEncoderStream;
205
+ TextDecoderStream: typeof TextDecoderStream;
206
+ Headers: typeof Headers;
207
+ Body: typeof Body;
208
+ Request: typeof Request;
209
+ Response: typeof Response;
210
+ WebSocket: typeof WebSocket;
211
+ WebSocketPair: typeof WebSocketPair;
212
+ AbortController: typeof AbortController;
213
+ AbortSignal: typeof AbortSignal;
214
+ TextDecoder: typeof TextDecoder;
215
+ TextEncoder: typeof TextEncoder;
216
+ URL: typeof URL;
217
+ URLSearchParams: typeof URLSearchParams;
218
+ URLPattern: typeof URLPattern;
219
+ Blob: typeof Blob;
220
+ File: typeof File;
221
+ FormData: typeof FormData;
222
+ Crypto: typeof Crypto;
223
+ SubtleCrypto: typeof SubtleCrypto;
224
+ CryptoKey: typeof CryptoKey;
225
+ CacheStorage: typeof CacheStorage;
226
+ Cache: typeof Cache;
227
+ FixedLengthStream: typeof FixedLengthStream;
228
+ IdentityTransformStream: typeof IdentityTransformStream;
229
+ HTMLRewriter: typeof HTMLRewriter;
230
+ }
231
+ export declare function addEventListener<
232
+ Type extends keyof WorkerGlobalScopeEventMap
233
+ >(
234
+ type: Type,
235
+ handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>,
236
+ options?: EventTargetAddEventListenerOptions | boolean
237
+ ): void;
238
+ export declare function removeEventListener<
239
+ Type extends keyof WorkerGlobalScopeEventMap
240
+ >(
241
+ type: Type,
242
+ handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>,
243
+ options?: EventTargetEventListenerOptions | boolean
244
+ ): void;
245
+ /** Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. */
246
+ export declare function dispatchEvent(
247
+ event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap]
248
+ ): boolean;
249
+ export declare function btoa(data: string): string;
250
+ export declare function atob(data: string): string;
251
+ export declare function setTimeout(
252
+ callback: (...args: any[]) => void,
253
+ msDelay?: number
254
+ ): number;
255
+ export declare function setTimeout<Args extends any[]>(
256
+ callback: (...args: Args) => void,
257
+ msDelay?: number,
258
+ ...args: Args
259
+ ): number;
260
+ export declare function clearTimeout(timeoutId: number | null): void;
261
+ export declare function setInterval(
262
+ callback: (...args: any[]) => void,
263
+ msDelay?: number
264
+ ): number;
265
+ export declare function setInterval<Args extends any[]>(
266
+ callback: (...args: Args) => void,
267
+ msDelay?: number,
268
+ ...args: Args
269
+ ): number;
270
+ export declare function clearInterval(timeoutId: number | null): void;
271
+ export declare function queueMicrotask(task: Function): void;
272
+ export declare function structuredClone<T>(
273
+ value: T,
274
+ options?: StructuredSerializeOptions
275
+ ): T;
276
+ export declare function fetch(
277
+ input: RequestInfo,
278
+ init?: RequestInit<RequestInitCfProperties>
279
+ ): Promise<Response>;
280
+ export declare const self: ServiceWorkerGlobalScope;
281
+ export declare const crypto: Crypto;
282
+ export declare const caches: CacheStorage;
283
+ export declare const scheduler: Scheduler;
284
+ export interface ExecutionContext {
285
+ waitUntil(promise: void | Promise<void>): void;
286
+ passThroughOnException(): void;
287
+ }
288
+ export type ExportedHandlerFetchHandler<Env = unknown> = (
289
+ request: Request,
290
+ env: Env,
291
+ ctx: ExecutionContext
292
+ ) => Response | Promise<Response>;
293
+ export type ExportedHandlerTraceHandler<Env = unknown> = (
294
+ traces: TraceItem[],
295
+ env: Env,
296
+ ctx: ExecutionContext
297
+ ) => void | Promise<void>;
298
+ export type ExportedHandlerScheduledHandler<Env = unknown> = (
299
+ controller: ScheduledController,
300
+ env: Env,
301
+ ctx: ExecutionContext
302
+ ) => void | Promise<void>;
303
+ export type ExportedHandlerQueueHandler<Env = unknown, Message = unknown> = (
304
+ batch: MessageBatch<Message>,
305
+ env: Env,
306
+ ctx: ExecutionContext
307
+ ) => void | Promise<void>;
308
+ export interface ExportedHandler<Env = unknown, QueueMessage = unknown> {
309
+ fetch?: ExportedHandlerFetchHandler<Env>;
310
+ trace?: ExportedHandlerTraceHandler<Env>;
311
+ scheduled?: ExportedHandlerScheduledHandler<Env>;
312
+ queue?: ExportedHandlerQueueHandler<Env, QueueMessage>;
313
+ }
314
+ export interface StructuredSerializeOptions {
315
+ transfer?: any[];
316
+ }
317
+ export declare abstract class PromiseRejectionEvent extends Event {
318
+ readonly promise: Promise<any>;
319
+ readonly reason: any;
320
+ }
321
+ export interface DurableObject {
322
+ fetch(request: Request): Response | Promise<Response>;
323
+ alarm?(): void | Promise<void>;
324
+ }
325
+ export interface DurableObjectStub extends Fetcher {
326
+ readonly id: DurableObjectId;
327
+ readonly name?: string;
328
+ }
329
+ export interface DurableObjectId {
330
+ toString(): string;
331
+ equals(other: DurableObjectId): boolean;
332
+ readonly name?: string;
333
+ }
334
+ export interface DurableObjectNamespace {
335
+ newUniqueId(
336
+ options?: DurableObjectNamespaceNewUniqueIdOptions
337
+ ): DurableObjectId;
338
+ idFromName(name: string): DurableObjectId;
339
+ idFromString(id: string): DurableObjectId;
340
+ get(id: DurableObjectId): DurableObjectStub;
341
+ }
342
+ export interface DurableObjectNamespaceNewUniqueIdOptions {
343
+ jurisdiction?: string;
344
+ }
345
+ export interface DurableObjectState {
346
+ waitUntil(promise: void | Promise<void>): void;
347
+ readonly id: DurableObjectId;
348
+ readonly storage: DurableObjectStorage;
349
+ blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
350
+ }
351
+ export interface DurableObjectTransaction {
352
+ get<T = unknown>(
353
+ key: string,
354
+ options?: DurableObjectGetOptions
355
+ ): Promise<T | undefined>;
356
+ get<T = unknown>(
357
+ keys: string[],
358
+ options?: DurableObjectGetOptions
359
+ ): Promise<Map<string, T>>;
360
+ list<T = unknown>(
361
+ options?: DurableObjectListOptions
362
+ ): Promise<Map<string, T>>;
363
+ put<T>(
364
+ key: string,
365
+ value: T,
366
+ options?: DurableObjectPutOptions
367
+ ): Promise<void>;
368
+ put<T>(
369
+ entries: Record<string, T>,
370
+ options?: DurableObjectPutOptions
371
+ ): Promise<void>;
372
+ delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
373
+ delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
374
+ rollback(): void;
375
+ getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
376
+ setAlarm(
377
+ scheduledTime: number | Date,
378
+ options?: DurableObjectSetAlarmOptions
379
+ ): Promise<void>;
380
+ deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
381
+ }
382
+ export interface DurableObjectStorage {
383
+ get<T = unknown>(
384
+ key: string,
385
+ options?: DurableObjectGetOptions
386
+ ): Promise<T | undefined>;
387
+ get<T = unknown>(
388
+ keys: string[],
389
+ options?: DurableObjectGetOptions
390
+ ): Promise<Map<string, T>>;
391
+ list<T = unknown>(
392
+ options?: DurableObjectListOptions
393
+ ): Promise<Map<string, T>>;
394
+ put<T>(
395
+ key: string,
396
+ value: T,
397
+ options?: DurableObjectPutOptions
398
+ ): Promise<void>;
399
+ put<T>(
400
+ entries: Record<string, T>,
401
+ options?: DurableObjectPutOptions
402
+ ): Promise<void>;
403
+ delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
404
+ delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
405
+ deleteAll(options?: DurableObjectPutOptions): Promise<void>;
406
+ transaction<T>(
407
+ closure: (txn: DurableObjectTransaction) => Promise<T>
408
+ ): Promise<T>;
409
+ getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
410
+ setAlarm(
411
+ scheduledTime: number | Date,
412
+ options?: DurableObjectSetAlarmOptions
413
+ ): Promise<void>;
414
+ deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
415
+ sync(): Promise<void>;
416
+ }
417
+ export interface DurableObjectListOptions {
418
+ start?: string;
419
+ startAfter?: string;
420
+ end?: string;
421
+ prefix?: string;
422
+ reverse?: boolean;
423
+ limit?: number;
424
+ allowConcurrency?: boolean;
425
+ noCache?: boolean;
426
+ }
427
+ export interface DurableObjectGetOptions {
428
+ allowConcurrency?: boolean;
429
+ noCache?: boolean;
430
+ }
431
+ export interface DurableObjectGetAlarmOptions {
432
+ allowConcurrency?: boolean;
433
+ }
434
+ export interface DurableObjectPutOptions {
435
+ allowConcurrency?: boolean;
436
+ allowUnconfirmed?: boolean;
437
+ noCache?: boolean;
438
+ }
439
+ export interface DurableObjectSetAlarmOptions {
440
+ allowConcurrency?: boolean;
441
+ allowUnconfirmed?: boolean;
442
+ }
443
+ export interface AnalyticsEngineDataset {
444
+ writeDataPoint(event?: AnalyticsEngineDataPoint): void;
445
+ }
446
+ export interface AnalyticsEngineDataPoint {
447
+ indexes?: ((ArrayBuffer | string) | null)[];
448
+ doubles?: number[];
449
+ blobs?: ((ArrayBuffer | string) | null)[];
450
+ }
451
+ export declare class Event {
452
+ constructor(type: string, init?: EventInit);
453
+ /** Returns the type of event, e.g. "click", "hashchange", or "submit". */
454
+ readonly type: string;
455
+ /** Returns the event's phase, which is one of NONE, CAPTURING_PHASE, AT_TARGET, and BUBBLING_PHASE. */
456
+ readonly eventPhase: number;
457
+ /** Returns true or false depending on how event was initialized. True if event invokes listeners past a ShadowRoot node that is the root of its target, and false otherwise. */
458
+ readonly composed: boolean;
459
+ /** Returns true or false depending on how event was initialized. True if event goes through its target's ancestors in reverse tree order, and false otherwise. */
460
+ readonly bubbles: boolean;
461
+ /** Returns true or false depending on how event was initialized. Its return value does not always carry meaning, but true can indicate that part of the operation during which event was dispatched, can be canceled by invoking the preventDefault() method. */
462
+ readonly cancelable: boolean;
463
+ /** Returns true if preventDefault() was invoked successfully to indicate cancelation, and false otherwise. */
464
+ readonly defaultPrevented: boolean;
465
+ /** @deprecated */
466
+ readonly returnValue: boolean;
467
+ /** Returns the object whose event listener's callback is currently being invoked. */
468
+ readonly currentTarget?: EventTarget;
469
+ /** @deprecated */
470
+ readonly srcElement?: EventTarget;
471
+ /** Returns the event's timestamp as the number of milliseconds measured relative to the time origin. */
472
+ readonly timeStamp: number;
473
+ /** Returns true if event was dispatched by the user agent, and false otherwise. */
474
+ readonly isTrusted: boolean;
475
+ cancelBubble: boolean;
476
+ stopImmediatePropagation(): void;
477
+ preventDefault(): void;
478
+ stopPropagation(): void;
479
+ composedPath(): EventTarget[];
480
+ static readonly NONE: number;
481
+ static readonly CAPTURING_PHASE: number;
482
+ static readonly AT_TARGET: number;
483
+ static readonly BUBBLING_PHASE: number;
484
+ }
485
+ export interface EventInit {
486
+ bubbles?: boolean;
487
+ cancelable?: boolean;
488
+ composed?: boolean;
489
+ }
490
+ export type EventListener<EventType extends Event = Event> = (
491
+ event: EventType
492
+ ) => void;
493
+ export interface EventListenerObject<EventType extends Event = Event> {
494
+ handleEvent(event: EventType): void;
495
+ }
496
+ export type EventListenerOrEventListenerObject<
497
+ EventType extends Event = Event
498
+ > = EventListener<EventType> | EventListenerObject<EventType>;
499
+ export declare class EventTarget<
500
+ EventMap extends Record<string, Event> = Record<string, Event>
501
+ > {
502
+ constructor();
503
+ addEventListener<Type extends keyof EventMap>(
504
+ type: Type,
505
+ handler: EventListenerOrEventListenerObject<EventMap[Type]>,
506
+ options?: EventTargetAddEventListenerOptions | boolean
507
+ ): void;
508
+ removeEventListener<Type extends keyof EventMap>(
509
+ type: Type,
510
+ handler: EventListenerOrEventListenerObject<EventMap[Type]>,
511
+ options?: EventTargetEventListenerOptions | boolean
512
+ ): void;
513
+ dispatchEvent(event: EventMap[keyof EventMap]): boolean;
514
+ }
515
+ export interface EventTargetEventListenerOptions {
516
+ capture?: boolean;
517
+ }
518
+ export interface EventTargetAddEventListenerOptions {
519
+ capture?: boolean;
520
+ passive?: boolean;
521
+ once?: boolean;
522
+ signal?: AbortSignal;
523
+ }
524
+ export interface EventTargetHandlerObject {
525
+ handleEvent: (event: Event) => any | undefined;
526
+ }
527
+ export declare class AbortController {
528
+ constructor();
529
+ /** Returns the AbortSignal object associated with this object. */
530
+ readonly signal: AbortSignal;
531
+ abort(reason?: any): void;
532
+ }
533
+ export declare abstract class AbortSignal extends EventTarget {
534
+ static abort(reason?: any): AbortSignal;
535
+ static timeout(delay: number): AbortSignal;
536
+ /** Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise. */
537
+ readonly aborted: boolean;
538
+ readonly reason: any;
539
+ throwIfAborted(): void;
540
+ }
541
+ export interface Scheduler {
542
+ wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise<void>;
543
+ }
544
+ export interface SchedulerWaitOptions {
545
+ signal?: AbortSignal;
546
+ }
547
+ export declare abstract class ExtendableEvent extends Event {
548
+ waitUntil(promise: void | Promise<void>): void;
549
+ }
550
+ export declare class Blob {
551
+ constructor(
552
+ bits?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[],
553
+ options?: BlobOptions
554
+ );
555
+ readonly size: number;
556
+ readonly type: string;
557
+ slice(start?: number, end?: number, type?: string): Blob;
558
+ arrayBuffer(): Promise<ArrayBuffer>;
559
+ text(): Promise<string>;
560
+ stream(): ReadableStream;
561
+ }
562
+ export interface BlobOptions {
563
+ type?: string;
564
+ }
565
+ export declare class File extends Blob {
566
+ constructor(
567
+ bits: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined,
568
+ name: string,
569
+ options?: FileOptions
570
+ );
571
+ readonly name: string;
572
+ readonly lastModified: number;
573
+ }
574
+ export interface FileOptions {
575
+ type?: string;
576
+ lastModified?: number;
577
+ }
578
+ export declare abstract class CacheStorage {
579
+ open(cacheName: string): Promise<Cache>;
580
+ readonly default: Cache;
581
+ }
582
+ export declare abstract class Cache {
583
+ delete(request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>;
584
+ match(
585
+ request: RequestInfo,
586
+ options?: CacheQueryOptions
587
+ ): Promise<Response | undefined>;
588
+ put(request: RequestInfo, response: Response): Promise<void>;
589
+ }
590
+ export interface CacheQueryOptions {
591
+ ignoreMethod?: boolean;
592
+ }
593
+ export declare abstract class Crypto {
594
+ /** Available only in secure contexts. */
595
+ readonly subtle: SubtleCrypto;
596
+ getRandomValues<
597
+ T extends
598
+ | Int8Array
599
+ | Uint8Array
600
+ | Int16Array
601
+ | Uint16Array
602
+ | Int32Array
603
+ | Uint32Array
604
+ | BigInt64Array
605
+ | BigUint64Array
606
+ >(buffer: T): T;
607
+ randomUUID(): string;
608
+ DigestStream: typeof DigestStream;
609
+ }
610
+ export declare abstract class SubtleCrypto {
611
+ encrypt(
612
+ algorithm: string | SubtleCryptoEncryptAlgorithm,
613
+ key: CryptoKey,
614
+ plainText: ArrayBuffer | ArrayBufferView
615
+ ): Promise<ArrayBuffer>;
616
+ decrypt(
617
+ algorithm: string | SubtleCryptoEncryptAlgorithm,
618
+ key: CryptoKey,
619
+ cipherText: ArrayBuffer | ArrayBufferView
620
+ ): Promise<ArrayBuffer>;
621
+ sign(
622
+ algorithm: string | SubtleCryptoSignAlgorithm,
623
+ key: CryptoKey,
624
+ data: ArrayBuffer | ArrayBufferView
625
+ ): Promise<ArrayBuffer>;
626
+ verify(
627
+ algorithm: string | SubtleCryptoSignAlgorithm,
628
+ key: CryptoKey,
629
+ signature: ArrayBuffer | ArrayBufferView,
630
+ data: ArrayBuffer | ArrayBufferView
631
+ ): Promise<boolean>;
632
+ digest(
633
+ algorithm: string | SubtleCryptoHashAlgorithm,
634
+ data: ArrayBuffer | ArrayBufferView
635
+ ): Promise<ArrayBuffer>;
636
+ generateKey(
637
+ algorithm: string | SubtleCryptoGenerateKeyAlgorithm,
638
+ extractable: boolean,
639
+ keyUsages: string[]
640
+ ): Promise<CryptoKey | CryptoKeyPair>;
641
+ deriveKey(
642
+ algorithm: string | SubtleCryptoDeriveKeyAlgorithm,
643
+ baseKey: CryptoKey,
644
+ derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
645
+ extractable: boolean,
646
+ keyUsages: string[]
647
+ ): Promise<CryptoKey>;
648
+ deriveBits(
649
+ algorithm: string | SubtleCryptoDeriveKeyAlgorithm,
650
+ baseKey: CryptoKey,
651
+ length: number | null
652
+ ): Promise<ArrayBuffer>;
653
+ importKey(
654
+ format: string,
655
+ keyData: (ArrayBuffer | ArrayBufferView) | JsonWebKey,
656
+ algorithm: string | SubtleCryptoImportKeyAlgorithm,
657
+ extractable: boolean,
658
+ keyUsages: string[]
659
+ ): Promise<CryptoKey>;
660
+ exportKey(format: string, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
661
+ wrapKey(
662
+ format: string,
663
+ key: CryptoKey,
664
+ wrappingKey: CryptoKey,
665
+ wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm
666
+ ): Promise<ArrayBuffer>;
667
+ unwrapKey(
668
+ format: string,
669
+ wrappedKey: ArrayBuffer | ArrayBufferView,
670
+ unwrappingKey: CryptoKey,
671
+ unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm,
672
+ unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
673
+ extractable: boolean,
674
+ keyUsages: string[]
675
+ ): Promise<CryptoKey>;
676
+ timingSafeEqual(
677
+ a: ArrayBuffer | ArrayBufferView,
678
+ b: ArrayBuffer | ArrayBufferView
679
+ ): boolean;
680
+ }
681
+ export declare abstract class CryptoKey {
682
+ readonly type: string;
683
+ readonly extractable: boolean;
684
+ readonly algorithm:
685
+ | CryptoKeyKeyAlgorithm
686
+ | CryptoKeyAesKeyAlgorithm
687
+ | CryptoKeyHmacKeyAlgorithm
688
+ | CryptoKeyRsaKeyAlgorithm
689
+ | CryptoKeyEllipticKeyAlgorithm
690
+ | CryptoKeyArbitraryKeyAlgorithm;
691
+ readonly usages: string[];
692
+ }
693
+ export interface CryptoKeyPair {
694
+ publicKey: CryptoKey;
695
+ privateKey: CryptoKey;
696
+ }
697
+ export interface JsonWebKey {
698
+ kty: string;
699
+ use?: string;
700
+ key_ops?: string[];
701
+ alg?: string;
702
+ ext?: boolean;
703
+ crv?: string;
704
+ x?: string;
705
+ y?: string;
706
+ d?: string;
707
+ n?: string;
708
+ e?: string;
709
+ p?: string;
710
+ q?: string;
711
+ dp?: string;
712
+ dq?: string;
713
+ qi?: string;
714
+ oth?: RsaOtherPrimesInfo[];
715
+ k?: string;
716
+ }
717
+ export interface RsaOtherPrimesInfo {
718
+ r?: string;
719
+ d?: string;
720
+ t?: string;
721
+ }
722
+ export interface SubtleCryptoDeriveKeyAlgorithm {
723
+ name: string;
724
+ salt?: ArrayBuffer;
725
+ iterations?: number;
726
+ hash?: string | SubtleCryptoHashAlgorithm;
727
+ $public?: CryptoKey;
728
+ info?: ArrayBuffer;
729
+ }
730
+ export interface SubtleCryptoEncryptAlgorithm {
731
+ name: string;
732
+ iv?: ArrayBuffer;
733
+ additionalData?: ArrayBuffer;
734
+ tagLength?: number;
735
+ counter?: ArrayBuffer;
736
+ length?: number;
737
+ label?: ArrayBuffer;
738
+ }
739
+ export interface SubtleCryptoGenerateKeyAlgorithm {
740
+ name: string;
741
+ hash?: string | SubtleCryptoHashAlgorithm;
742
+ modulusLength?: number;
743
+ publicExponent?: ArrayBuffer;
744
+ length?: number;
745
+ namedCurve?: string;
746
+ }
747
+ export interface SubtleCryptoHashAlgorithm {
748
+ name: string;
749
+ }
750
+ export interface SubtleCryptoImportKeyAlgorithm {
751
+ name: string;
752
+ hash?: string | SubtleCryptoHashAlgorithm;
753
+ length?: number;
754
+ namedCurve?: string;
755
+ compressed?: boolean;
756
+ }
757
+ export interface SubtleCryptoSignAlgorithm {
758
+ name: string;
759
+ hash?: string | SubtleCryptoHashAlgorithm;
760
+ dataLength?: number;
761
+ saltLength?: number;
762
+ }
763
+ export interface CryptoKeyKeyAlgorithm {
764
+ name: string;
765
+ }
766
+ export interface CryptoKeyAesKeyAlgorithm {
767
+ name: string;
768
+ length: number;
769
+ }
770
+ export interface CryptoKeyHmacKeyAlgorithm {
771
+ name: string;
772
+ hash: CryptoKeyKeyAlgorithm;
773
+ length: number;
774
+ }
775
+ export interface CryptoKeyRsaKeyAlgorithm {
776
+ name: string;
777
+ modulusLength: number;
778
+ publicExponent: ArrayBuffer;
779
+ hash?: CryptoKeyKeyAlgorithm;
780
+ }
781
+ export interface CryptoKeyEllipticKeyAlgorithm {
782
+ name: string;
783
+ namedCurve: string;
784
+ }
785
+ export interface CryptoKeyArbitraryKeyAlgorithm {
786
+ name: string;
787
+ hash?: CryptoKeyKeyAlgorithm;
788
+ namedCurve?: string;
789
+ length?: number;
790
+ }
791
+ export declare class DigestStream extends WritableStream<
792
+ ArrayBuffer | ArrayBufferView
793
+ > {
794
+ constructor(algorithm: string | SubtleCryptoHashAlgorithm);
795
+ readonly digest: Promise<ArrayBuffer>;
796
+ }
797
+ export declare class TextDecoder {
798
+ constructor(decoder?: string, options?: TextDecoderConstructorOptions);
799
+ decode(
800
+ input?: ArrayBuffer | ArrayBufferView,
801
+ options?: TextDecoderDecodeOptions
802
+ ): string;
803
+ readonly encoding: string;
804
+ readonly fatal: boolean;
805
+ readonly ignoreBOM: boolean;
806
+ }
807
+ export declare class TextEncoder {
808
+ constructor();
809
+ encode(input?: string): Uint8Array;
810
+ encodeInto(input: string, buffer: Uint8Array): TextEncoderEncodeIntoResult;
811
+ readonly encoding: string;
812
+ }
813
+ export interface TextDecoderConstructorOptions {
814
+ fatal: boolean;
815
+ ignoreBOM: boolean;
816
+ }
817
+ export interface TextDecoderDecodeOptions {
818
+ stream: boolean;
819
+ }
820
+ export interface TextEncoderEncodeIntoResult {
821
+ read: number;
822
+ written: number;
823
+ }
824
+ export declare class FormData {
825
+ constructor();
826
+ append(name: string, value: string): void;
827
+ append(name: string, value: Blob, filename?: string): void;
828
+ delete(name: string): void;
829
+ get(name: string): string | null;
830
+ getAll(name: string): string[];
831
+ has(name: string): boolean;
832
+ set(name: string, value: string): void;
833
+ set(name: string, value: Blob, filename?: string): void;
834
+ entries(): IterableIterator<[key: string, value: string]>;
835
+ keys(): IterableIterator<string>;
836
+ values(): IterableIterator<File | string>;
837
+ forEach<This = unknown>(
838
+ callback: (
839
+ this: This,
840
+ value: string,
841
+ key: string,
842
+ parent: FormData
843
+ ) => void,
844
+ thisArg?: This
845
+ ): void;
846
+ [Symbol.iterator](): IterableIterator<[key: string, value: string]>;
847
+ }
848
+ export interface ContentOptions {
849
+ html?: boolean;
850
+ }
851
+ export declare class HTMLRewriter {
852
+ constructor();
853
+ on(
854
+ selector: string,
855
+ handlers: HTMLRewriterElementContentHandlers
856
+ ): HTMLRewriter;
857
+ onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter;
858
+ transform(response: Response): Response;
859
+ }
860
+ export interface HTMLRewriterElementContentHandlers {
861
+ element?(element: Element): void | Promise<void>;
862
+ comments?(comment: Comment): void | Promise<void>;
863
+ text?(element: Text): void | Promise<void>;
864
+ }
865
+ export interface HTMLRewriterDocumentContentHandlers {
866
+ doctype?(doctype: Doctype): void | Promise<void>;
867
+ comments?(comment: Comment): void | Promise<void>;
868
+ text?(text: Text): void | Promise<void>;
869
+ end?(end: DocumentEnd): void | Promise<void>;
870
+ }
871
+ export interface Doctype {
872
+ readonly name: string | null;
873
+ readonly publicId: string | null;
874
+ readonly systemId: string | null;
875
+ }
876
+ export interface Element {
877
+ tagName: string;
878
+ readonly attributes: IterableIterator<string[]>;
879
+ readonly removed: boolean;
880
+ readonly namespaceURI: string;
881
+ getAttribute(name: string): string | null;
882
+ hasAttribute(name: string): boolean;
883
+ setAttribute(name: string, value: string): Element;
884
+ removeAttribute(name: string): Element;
885
+ before(content: string, options?: ContentOptions): Element;
886
+ after(content: string, options?: ContentOptions): Element;
887
+ prepend(content: string, options?: ContentOptions): Element;
888
+ append(content: string, options?: ContentOptions): Element;
889
+ replace(content: string, options?: ContentOptions): Element;
890
+ remove(): Element;
891
+ removeAndKeepContent(): Element;
892
+ setInnerContent(content: string, options?: ContentOptions): Element;
893
+ onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
894
+ }
895
+ export interface EndTag {
896
+ name: string;
897
+ before(content: string, options?: ContentOptions): EndTag;
898
+ after(content: string, options?: ContentOptions): EndTag;
899
+ remove(): EndTag;
900
+ }
901
+ export interface Comment {
902
+ text: string;
903
+ readonly removed: boolean;
904
+ before(content: string, options?: ContentOptions): Comment;
905
+ after(content: string, options?: ContentOptions): Comment;
906
+ replace(content: string, options?: ContentOptions): Comment;
907
+ remove(): Comment;
908
+ }
909
+ export interface Text {
910
+ readonly text: string;
911
+ readonly lastInTextNode: boolean;
912
+ readonly removed: boolean;
913
+ before(content: string, options?: ContentOptions): Text;
914
+ after(content: string, options?: ContentOptions): Text;
915
+ replace(content: string, options?: ContentOptions): Text;
916
+ remove(): Text;
917
+ }
918
+ export interface DocumentEnd {
919
+ append(content: string, options?: ContentOptions): DocumentEnd;
920
+ }
921
+ export declare abstract class FetchEvent extends ExtendableEvent {
922
+ readonly request: Request;
923
+ respondWith(promise: Response | Promise<Response>): void;
924
+ passThroughOnException(): void;
925
+ }
926
+ export type HeadersInit =
927
+ | Headers
928
+ | Iterable<Iterable<string>>
929
+ | Record<string, string>;
930
+ export declare class Headers {
931
+ constructor(init?: HeadersInit);
932
+ get(name: string): string | null;
933
+ getAll(name: string): string[];
934
+ has(name: string): boolean;
935
+ set(name: string, value: string): void;
936
+ append(name: string, value: string): void;
937
+ delete(name: string): void;
938
+ forEach<This = unknown>(
939
+ callback: (this: This, value: string, key: string, parent: Headers) => void,
940
+ thisArg?: This
941
+ ): void;
942
+ entries(): IterableIterator<[key: string, value: string]>;
943
+ keys(): IterableIterator<string>;
944
+ values(): IterableIterator<string>;
945
+ [Symbol.iterator](): IterableIterator<[key: string, value: string]>;
946
+ }
947
+ export type BodyInit =
948
+ | ReadableStream<Uint8Array>
949
+ | string
950
+ | ArrayBuffer
951
+ | ArrayBufferView
952
+ | Blob
953
+ | URLSearchParams
954
+ | FormData;
955
+ export declare abstract class Body {
956
+ readonly body: ReadableStream | null;
957
+ readonly bodyUsed: boolean;
958
+ arrayBuffer(): Promise<ArrayBuffer>;
959
+ text(): Promise<string>;
960
+ json<T>(): Promise<T>;
961
+ formData(): Promise<FormData>;
962
+ blob(): Promise<Blob>;
963
+ }
964
+ export declare class Response extends Body {
965
+ constructor(body?: BodyInit | null, init?: ResponseInit);
966
+ static redirect(url: string, status?: number): Response;
967
+ static json(any: any, maybeInit?: ResponseInit | Response): Response;
968
+ clone(): Response;
969
+ readonly status: number;
970
+ readonly statusText: string;
971
+ readonly headers: Headers;
972
+ readonly ok: boolean;
973
+ readonly redirected: boolean;
974
+ readonly url: string;
975
+ readonly webSocket: WebSocket | null;
976
+ readonly cf?: any;
977
+ }
978
+ export interface ResponseInit {
979
+ status?: number;
980
+ statusText?: string;
981
+ headers?: HeadersInit;
982
+ cf?: any;
983
+ webSocket?: WebSocket | null;
984
+ encodeBody?: "automatic" | "manual";
985
+ }
986
+ export type RequestInfo = Request | string | URL;
987
+ export declare class Request extends Body {
988
+ constructor(input: RequestInfo, init?: RequestInit);
989
+ clone(): Request;
990
+ /** Returns request's HTTP method, which is "GET" by default. */
991
+ readonly method: string;
992
+ /** Returns the URL of request as a string. */
993
+ readonly url: string;
994
+ /** Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header. */
995
+ readonly headers: Headers;
996
+ /** Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default. */
997
+ readonly redirect: string;
998
+ readonly fetcher: Fetcher | null;
999
+ /** Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler. */
1000
+ readonly signal: AbortSignal;
1001
+ readonly cf?: IncomingRequestCfProperties;
1002
+ }
1003
+ export interface RequestInit<
1004
+ CfType = IncomingRequestCfProperties | RequestInitCfProperties
1005
+ > {
1006
+ /** A string to set request's method. */
1007
+ method?: string;
1008
+ /** A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
1009
+ headers?: HeadersInit;
1010
+ /** A BodyInit object or null to set request's body. */
1011
+ body?: BodyInit | null;
1012
+ /** 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. */
1013
+ redirect?: string;
1014
+ fetcher?: Fetcher | null;
1015
+ cf?: CfType;
1016
+ /** An AbortSignal to set request's signal. */
1017
+ signal?: AbortSignal | null;
1018
+ }
1019
+ export declare abstract class Fetcher {
1020
+ fetch(
1021
+ input: RequestInfo,
1022
+ init?: RequestInit<RequestInitCfProperties>
1023
+ ): Promise<Response>;
1024
+ }
1025
+ export interface FetcherPutOptions {
1026
+ expiration?: number;
1027
+ expirationTtl?: number;
1028
+ }
1029
+ export interface KVNamespaceListKey<Metadata, Key extends string = string> {
1030
+ name: Key;
1031
+ expiration?: number;
1032
+ metadata?: Metadata;
1033
+ }
1034
+ export type KVNamespaceListResult<Metadata, Key extends string = string> =
1035
+ | {
1036
+ list_complete: false;
1037
+ keys: KVNamespaceListKey<Metadata, Key>[];
1038
+ cursor: string;
1039
+ }
1040
+ | {
1041
+ list_complete: true;
1042
+ keys: KVNamespaceListKey<Metadata, Key>[];
1043
+ };
1044
+ export interface KVNamespace<Key extends string = string> {
1045
+ get(
1046
+ key: Key,
1047
+ options?: Partial<KVNamespaceGetOptions<undefined>>
1048
+ ): Promise<string | null>;
1049
+ get(key: Key, type: "text"): Promise<string | null>;
1050
+ get<ExpectedValue = unknown>(
1051
+ key: Key,
1052
+ type: "json"
1053
+ ): Promise<ExpectedValue | null>;
1054
+ get(key: Key, type: "arrayBuffer"): Promise<ArrayBuffer | null>;
1055
+ get(key: Key, type: "stream"): Promise<ReadableStream | null>;
1056
+ get(
1057
+ key: Key,
1058
+ options?: KVNamespaceGetOptions<"text">
1059
+ ): Promise<string | null>;
1060
+ get<ExpectedValue = unknown>(
1061
+ key: Key,
1062
+ options?: KVNamespaceGetOptions<"json">
1063
+ ): Promise<ExpectedValue | null>;
1064
+ get(
1065
+ key: Key,
1066
+ options?: KVNamespaceGetOptions<"arrayBuffer">
1067
+ ): Promise<string | null>;
1068
+ get(
1069
+ key: Key,
1070
+ options?: KVNamespaceGetOptions<"stream">
1071
+ ): Promise<string | null>;
1072
+ list<Metadata = unknown>(
1073
+ options?: KVNamespaceListOptions
1074
+ ): Promise<KVNamespaceListResult<Metadata, Key>>;
1075
+ put(
1076
+ key: Key,
1077
+ value: string | ArrayBuffer | ArrayBufferView | ReadableStream,
1078
+ options?: KVNamespacePutOptions
1079
+ ): Promise<void>;
1080
+ getWithMetadata<Metadata = unknown>(
1081
+ key: Key,
1082
+ options?: Partial<KVNamespaceGetOptions<undefined>>
1083
+ ): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
1084
+ getWithMetadata<Metadata = unknown>(
1085
+ key: Key,
1086
+ type: "text"
1087
+ ): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
1088
+ getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
1089
+ key: Key,
1090
+ type: "json"
1091
+ ): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
1092
+ getWithMetadata<Metadata = unknown>(
1093
+ key: Key,
1094
+ type: "arrayBuffer"
1095
+ ): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
1096
+ getWithMetadata<Metadata = unknown>(
1097
+ key: Key,
1098
+ type: "stream"
1099
+ ): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
1100
+ getWithMetadata<Metadata = unknown>(
1101
+ key: Key,
1102
+ options: KVNamespaceGetOptions<"text">
1103
+ ): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
1104
+ getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
1105
+ key: Key,
1106
+ options: KVNamespaceGetOptions<"json">
1107
+ ): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
1108
+ getWithMetadata<Metadata = unknown>(
1109
+ key: Key,
1110
+ options: KVNamespaceGetOptions<"arrayBuffer">
1111
+ ): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
1112
+ getWithMetadata<Metadata = unknown>(
1113
+ key: Key,
1114
+ options: KVNamespaceGetOptions<"stream">
1115
+ ): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
1116
+ delete(key: Key): Promise<void>;
1117
+ }
1118
+ export interface KVNamespaceListOptions {
1119
+ limit?: number;
1120
+ prefix?: string | null;
1121
+ cursor?: string | null;
1122
+ }
1123
+ export interface KVNamespaceGetOptions<Type> {
1124
+ type: Type;
1125
+ cacheTtl?: number;
1126
+ }
1127
+ export interface KVNamespacePutOptions {
1128
+ expiration?: number;
1129
+ expirationTtl?: number;
1130
+ metadata?: any | null;
1131
+ }
1132
+ export interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
1133
+ value: Value | null;
1134
+ metadata: Metadata | null;
1135
+ }
1136
+ export interface R2Error extends Error {
1137
+ readonly name: string;
1138
+ readonly code: number;
1139
+ readonly message: string;
1140
+ readonly action: string;
1141
+ readonly stack: any;
1142
+ }
1143
+ export interface R2ListOptions {
1144
+ limit?: number;
1145
+ prefix?: string;
1146
+ cursor?: string;
1147
+ delimiter?: string;
1148
+ startAfter?: string;
1149
+ }
1150
+ export declare abstract class R2Bucket {
1151
+ head(key: string): Promise<R2Object | null>;
1152
+ get(
1153
+ key: string,
1154
+ options: R2GetOptions & {
1155
+ onlyIf: R2Conditional | Headers;
1156
+ }
1157
+ ): Promise<R2ObjectBody | R2Object | null>;
1158
+ get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>;
1159
+ put(
1160
+ key: string,
1161
+ value:
1162
+ | ReadableStream
1163
+ | ArrayBuffer
1164
+ | ArrayBufferView
1165
+ | string
1166
+ | null
1167
+ | Blob,
1168
+ options?: R2PutOptions
1169
+ ): Promise<R2Object>;
1170
+ delete(keys: string | string[]): Promise<void>;
1171
+ list(options?: R2ListOptions): Promise<R2Objects>;
1172
+ }
1173
+ export declare abstract class R2Object {
1174
+ readonly key: string;
1175
+ readonly version: string;
1176
+ readonly size: number;
1177
+ readonly etag: string;
1178
+ readonly httpEtag: string;
1179
+ readonly checksums: R2Checksums;
1180
+ readonly uploaded: Date;
1181
+ readonly httpMetadata?: R2HTTPMetadata;
1182
+ readonly customMetadata?: Record<string, string>;
1183
+ readonly range?: R2Range;
1184
+ writeHttpMetadata(headers: Headers): void;
1185
+ }
1186
+ export interface R2ObjectBody extends R2Object {
1187
+ get body(): ReadableStream;
1188
+ get bodyUsed(): boolean;
1189
+ arrayBuffer(): Promise<ArrayBuffer>;
1190
+ text(): Promise<string>;
1191
+ json<T>(): Promise<T>;
1192
+ blob(): Promise<Blob>;
1193
+ }
1194
+ export type R2Range =
1195
+ | {
1196
+ offset: number;
1197
+ length?: number;
1198
+ }
1199
+ | {
1200
+ offset?: number;
1201
+ length: number;
1202
+ }
1203
+ | {
1204
+ suffix: number;
1205
+ };
1206
+ export interface R2Conditional {
1207
+ etagMatches?: string;
1208
+ etagDoesNotMatch?: string;
1209
+ uploadedBefore?: Date;
1210
+ uploadedAfter?: Date;
1211
+ secondsGranularity?: boolean;
1212
+ }
1213
+ export interface R2GetOptions {
1214
+ onlyIf?: R2Conditional | Headers;
1215
+ range?: R2Range | Headers;
1216
+ }
1217
+ export interface R2PutOptions {
1218
+ onlyIf?: R2Conditional | Headers;
1219
+ httpMetadata?: R2HTTPMetadata | Headers;
1220
+ customMetadata?: Record<string, string>;
1221
+ md5?: ArrayBuffer | string;
1222
+ sha1?: ArrayBuffer | string;
1223
+ sha256?: ArrayBuffer | string;
1224
+ sha384?: ArrayBuffer | string;
1225
+ sha512?: ArrayBuffer | string;
1226
+ }
1227
+ export interface R2Checksums {
1228
+ readonly md5?: ArrayBuffer;
1229
+ readonly sha1?: ArrayBuffer;
1230
+ readonly sha256?: ArrayBuffer;
1231
+ readonly sha384?: ArrayBuffer;
1232
+ readonly sha512?: ArrayBuffer;
1233
+ toJSON(): R2StringChecksums;
1234
+ }
1235
+ export interface R2StringChecksums {
1236
+ md5?: string;
1237
+ sha1?: string;
1238
+ sha256?: string;
1239
+ sha384?: string;
1240
+ sha512?: string;
1241
+ }
1242
+ export interface R2HTTPMetadata {
1243
+ contentType?: string;
1244
+ contentLanguage?: string;
1245
+ contentDisposition?: string;
1246
+ contentEncoding?: string;
1247
+ cacheControl?: string;
1248
+ cacheExpiry?: Date;
1249
+ }
1250
+ export interface R2Objects {
1251
+ objects: R2Object[];
1252
+ truncated: boolean;
1253
+ cursor?: string;
1254
+ delimitedPrefixes: string[];
1255
+ }
1256
+ export declare abstract class ScheduledEvent extends ExtendableEvent {
1257
+ readonly scheduledTime: number;
1258
+ readonly cron: string;
1259
+ noRetry(): void;
1260
+ }
1261
+ export interface ScheduledController {
1262
+ readonly scheduledTime: number;
1263
+ readonly cron: string;
1264
+ noRetry(): void;
1265
+ }
1266
+ export interface QueuingStrategy<T = any> {
1267
+ highWaterMark?: number | bigint;
1268
+ size?: (chunk: T) => number | bigint;
1269
+ }
1270
+ export interface UnderlyingSink<W = any> {
1271
+ type?: string;
1272
+ start?: (controller: WritableStreamDefaultController) => void | Promise<void>;
1273
+ write?: (
1274
+ chunk: W,
1275
+ controller: WritableStreamDefaultController
1276
+ ) => void | Promise<void>;
1277
+ abort?: (reason: any) => void | Promise<void>;
1278
+ close?: () => void | Promise<void>;
1279
+ }
1280
+ export interface UnderlyingByteSource {
1281
+ type: "bytes";
1282
+ autoAllocateChunkSize?: number;
1283
+ start?: (controller: ReadableByteStreamController) => void | Promise<void>;
1284
+ pull?: (controller: ReadableByteStreamController) => void | Promise<void>;
1285
+ cancel?: (reason: any) => void | Promise<void>;
1286
+ }
1287
+ export interface UnderlyingSource<R = any> {
1288
+ type?: "" | undefined;
1289
+ start?: (
1290
+ controller: ReadableStreamDefaultController<R>
1291
+ ) => void | Promise<void>;
1292
+ pull?: (
1293
+ controller: ReadableStreamDefaultController<R>
1294
+ ) => void | Promise<void>;
1295
+ cancel?: (reason: any) => void | Promise<void>;
1296
+ }
1297
+ export interface Transformer<I = any, O = any> {
1298
+ readableType?: string;
1299
+ writableType?: string;
1300
+ start?: (
1301
+ controller: TransformStreamDefaultController<O>
1302
+ ) => void | Promise<void>;
1303
+ transform?: (
1304
+ chunk: I,
1305
+ controller: TransformStreamDefaultController<O>
1306
+ ) => void | Promise<void>;
1307
+ flush?: (
1308
+ controller: TransformStreamDefaultController<O>
1309
+ ) => void | Promise<void>;
1310
+ }
1311
+ export interface StreamPipeOptions {
1312
+ /**
1313
+ * Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered.
1314
+ *
1315
+ * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
1316
+ *
1317
+ * Errors and closures of the source and destination streams propagate as follows:
1318
+ *
1319
+ * An error in this source readable stream will abort destination, unless preventAbort is truthy. The returned promise will be rejected with the source's error, or with any error that occurs during aborting the destination.
1320
+ *
1321
+ * An error in destination will cancel this source readable stream, unless preventCancel is truthy. The returned promise will be rejected with the destination's error, or with any error that occurs during canceling the source.
1322
+ *
1323
+ * When this source readable stream closes, destination will be closed, unless preventClose is truthy. The returned promise will be fulfilled once this process completes, unless an error is encountered while closing the destination, in which case it will be rejected with that error.
1324
+ *
1325
+ * If destination starts out closed or closing, this source readable stream will be canceled, unless preventCancel is true. The returned promise will be rejected with an error indicating piping to a closed stream failed, or with any error that occurs during canceling the source.
1326
+ *
1327
+ * The signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set.
1328
+ */
1329
+ preventClose?: boolean;
1330
+ preventAbort?: boolean;
1331
+ preventCancel?: boolean;
1332
+ signal?: AbortSignal;
1333
+ }
1334
+ export type ReadableStreamReadResult<R = any> =
1335
+ | {
1336
+ done: false;
1337
+ value: R;
1338
+ }
1339
+ | {
1340
+ done: true;
1341
+ value?: undefined;
1342
+ };
1343
+ /** This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object. */
1344
+ export interface ReadableStream<R = any> {
1345
+ cancel(reason?: any): Promise<void>;
1346
+ getReader(): ReadableStreamDefaultReader<R>;
1347
+ getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
1348
+ pipeThrough<T>(
1349
+ transform: ReadableWritablePair<T, R>,
1350
+ options?: StreamPipeOptions
1351
+ ): ReadableStream<T>;
1352
+ pipeTo(
1353
+ destination: WritableStream<R>,
1354
+ options?: StreamPipeOptions
1355
+ ): Promise<void>;
1356
+ tee(): [ReadableStream<R>, ReadableStream<R>];
1357
+ values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
1358
+ [Symbol.asyncIterator](
1359
+ options?: ReadableStreamValuesOptions
1360
+ ): AsyncIterableIterator<R>;
1361
+ }
1362
+ export declare const ReadableStream: {
1363
+ prototype: ReadableStream;
1364
+ new (
1365
+ underlyingSource: UnderlyingByteSource,
1366
+ strategy?: QueuingStrategy<Uint8Array>
1367
+ ): ReadableStream<Uint8Array>;
1368
+ new <R = any>(
1369
+ underlyingSource?: UnderlyingSource<R>,
1370
+ strategy?: QueuingStrategy<R>
1371
+ ): ReadableStream<R>;
1372
+ };
1373
+ export declare class ReadableStreamDefaultReader<R = any> {
1374
+ constructor(stream: ReadableStream);
1375
+ readonly closed: Promise<void>;
1376
+ cancel(reason?: any): Promise<void>;
1377
+ read(): Promise<ReadableStreamReadResult<R>>;
1378
+ releaseLock(): void;
1379
+ }
1380
+ export declare class ReadableStreamBYOBReader {
1381
+ constructor(stream: ReadableStream);
1382
+ readonly closed: Promise<void>;
1383
+ cancel(reason?: any): Promise<void>;
1384
+ read<T extends ArrayBufferView>(
1385
+ view: T
1386
+ ): Promise<ReadableStreamReadResult<T>>;
1387
+ releaseLock(): void;
1388
+ readAtLeast<T extends ArrayBufferView>(
1389
+ minElements: number,
1390
+ view: T
1391
+ ): Promise<ReadableStreamReadResult<T>>;
1392
+ }
1393
+ export interface ReadableStreamGetReaderOptions {
1394
+ mode: "byob";
1395
+ }
1396
+ export interface ReadableStreamBYOBRequest {
1397
+ readonly view: Uint8Array | null;
1398
+ respond(bytesWritten: number): void;
1399
+ respondWithNewView(view: ArrayBuffer | ArrayBufferView): void;
1400
+ readonly atLeast: number | null;
1401
+ }
1402
+ export interface ReadableStreamDefaultController<R = any> {
1403
+ readonly desiredSize: number | null;
1404
+ close(): void;
1405
+ enqueue(chunk?: R): void;
1406
+ error(reason: any): void;
1407
+ }
1408
+ export interface ReadableByteStreamController {
1409
+ readonly byobRequest: ReadableStreamBYOBRequest | null;
1410
+ readonly desiredSize: number | null;
1411
+ close(): void;
1412
+ enqueue(chunk: ArrayBuffer | ArrayBufferView): void;
1413
+ error(reason: any): void;
1414
+ }
1415
+ /** This Streams API interface represents a controller allowing control of a WritableStream's state. When constructing a WritableStream, the underlying sink is given a corresponding WritableStreamDefaultController instance to manipulate. */
1416
+ export interface WritableStreamDefaultController {
1417
+ readonly signal: AbortSignal;
1418
+ error(reason?: any): void;
1419
+ }
1420
+ export interface TransformStreamDefaultController<O = any> {
1421
+ get desiredSize(): number | null;
1422
+ enqueue(chunk?: O): void;
1423
+ error(reason: any): void;
1424
+ terminate(): void;
1425
+ }
1426
+ export interface ReadableWritablePair<R = any, W = any> {
1427
+ /**
1428
+ * Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use.
1429
+ *
1430
+ * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
1431
+ */
1432
+ writable: WritableStream<W>;
1433
+ readable: ReadableStream<R>;
1434
+ }
1435
+ export declare class WritableStream<W = any> {
1436
+ constructor(
1437
+ underlyingSink?: UnderlyingSink,
1438
+ queuingStrategy?: QueuingStrategy
1439
+ );
1440
+ readonly locked: boolean;
1441
+ abort(reason?: any): Promise<void>;
1442
+ close(): Promise<void>;
1443
+ getWriter(): WritableStreamDefaultWriter<W>;
1444
+ }
1445
+ export declare class WritableStreamDefaultWriter<W = any> {
1446
+ constructor(stream: WritableStream);
1447
+ readonly closed: Promise<void>;
1448
+ readonly ready: Promise<void>;
1449
+ readonly desiredSize: number | null;
1450
+ abort(reason?: any): Promise<void>;
1451
+ close(): Promise<void>;
1452
+ write(chunk?: W): Promise<void>;
1453
+ releaseLock(): void;
1454
+ }
1455
+ export declare class TransformStream<I = any, O = any> {
1456
+ constructor(
1457
+ transformer?: Transformer<I, O>,
1458
+ writableStrategy?: QueuingStrategy<I>,
1459
+ readableStrategy?: QueuingStrategy<O>
1460
+ );
1461
+ readonly readable: ReadableStream<O>;
1462
+ readonly writable: WritableStream<I>;
1463
+ }
1464
+ export declare class FixedLengthStream extends IdentityTransformStream {
1465
+ constructor(expectedLength: number | bigint);
1466
+ }
1467
+ export declare class IdentityTransformStream extends TransformStream<
1468
+ ArrayBuffer | ArrayBufferView,
1469
+ Uint8Array
1470
+ > {
1471
+ constructor();
1472
+ }
1473
+ export interface ReadableStreamValuesOptions {
1474
+ preventCancel?: boolean;
1475
+ }
1476
+ export declare class CompressionStream extends TransformStream<
1477
+ ArrayBuffer | ArrayBufferView,
1478
+ Uint8Array
1479
+ > {
1480
+ constructor(format: "gzip" | "deflate");
1481
+ }
1482
+ export declare class DecompressionStream extends TransformStream<
1483
+ ArrayBuffer | ArrayBufferView,
1484
+ Uint8Array
1485
+ > {
1486
+ constructor(format: "gzip" | "deflate");
1487
+ }
1488
+ export declare class TextEncoderStream extends TransformStream<
1489
+ string,
1490
+ Uint8Array
1491
+ > {
1492
+ constructor();
1493
+ }
1494
+ export declare class TextDecoderStream extends TransformStream<
1495
+ ArrayBuffer | ArrayBufferView,
1496
+ string
1497
+ > {
1498
+ constructor(label?: string, options?: TextDecoderStreamTextDecoderStreamInit);
1499
+ }
1500
+ export interface TextDecoderStreamTextDecoderStreamInit {
1501
+ fatal?: boolean;
1502
+ }
1503
+ export declare class ByteLengthQueuingStrategy
1504
+ implements QueuingStrategy<ArrayBufferView>
1505
+ {
1506
+ constructor(init: QueuingStrategyInit);
1507
+ get highWaterMark(): number;
1508
+ get size(): (chunk?: any) => number;
1509
+ }
1510
+ export declare class CountQueuingStrategy implements QueuingStrategy {
1511
+ constructor(init: QueuingStrategyInit);
1512
+ get highWaterMark(): number;
1513
+ get size(): (chunk?: any) => number;
1514
+ }
1515
+ export interface QueuingStrategyInit {
1516
+ /**
1517
+ * Creates a new ByteLengthQueuingStrategy with the provided high water mark.
1518
+ *
1519
+ * Note that the provided high water mark will not be validated ahead of time. Instead, if it is negative, NaN, or not a number, the resulting ByteLengthQueuingStrategy will cause the corresponding stream constructor to throw.
1520
+ */
1521
+ highWaterMark: number;
1522
+ }
1523
+ export declare abstract class TraceEvent extends ExtendableEvent {
1524
+ readonly traces: TraceItem[];
1525
+ }
1526
+ export interface TraceItem {
1527
+ readonly event:
1528
+ | (
1529
+ | TraceItemFetchEventInfo
1530
+ | TraceItemScheduledEventInfo
1531
+ | TraceItemAlarmEventInfo
1532
+ )
1533
+ | null;
1534
+ readonly eventTimestamp: number | null;
1535
+ readonly logs: TraceLog[];
1536
+ readonly exceptions: TraceException[];
1537
+ readonly scriptName: string | null;
1538
+ readonly dispatchNamespace?: string;
1539
+ readonly outcome: string;
1540
+ }
1541
+ export interface TraceItemAlarmEventInfo {
1542
+ readonly scheduledTime: Date;
1543
+ }
1544
+ export interface TraceItemScheduledEventInfo {
1545
+ readonly scheduledTime: number;
1546
+ readonly cron: string;
1547
+ }
1548
+ export interface TraceItemFetchEventInfo {
1549
+ readonly response?: TraceItemFetchEventInfoResponse;
1550
+ readonly request: TraceItemFetchEventInfoRequest;
1551
+ }
1552
+ export interface TraceItemFetchEventInfoRequest {
1553
+ readonly cf?: any;
1554
+ readonly headers: Record<string, string>;
1555
+ readonly method: string;
1556
+ readonly url: string;
1557
+ getUnredacted(): TraceItemFetchEventInfoRequest;
1558
+ }
1559
+ export interface TraceItemFetchEventInfoResponse {
1560
+ readonly status: number;
1561
+ }
1562
+ export interface TraceLog {
1563
+ readonly timestamp: number;
1564
+ readonly level: string;
1565
+ readonly message: any;
1566
+ }
1567
+ export interface TraceException {
1568
+ readonly timestamp: number;
1569
+ readonly message: string;
1570
+ readonly name: string;
1571
+ }
1572
+ export interface TraceMetrics {
1573
+ readonly cpuTime: number;
1574
+ readonly wallTime: number;
1575
+ }
1576
+ export interface UnsafeTraceMetrics {
1577
+ fromTrace(item: TraceItem): TraceMetrics;
1578
+ }
1579
+ export declare class URL {
1580
+ constructor(url: string | URL, base?: string | URL);
1581
+ href: string;
1582
+ readonly origin: string;
1583
+ protocol: string;
1584
+ username: string;
1585
+ password: string;
1586
+ host: string;
1587
+ hostname: string;
1588
+ port: string;
1589
+ pathname: string;
1590
+ search: string;
1591
+ readonly searchParams: URLSearchParams;
1592
+ hash: string;
1593
+ toString(): string;
1594
+ toJSON(): string;
1595
+ }
1596
+ export declare class URLSearchParams {
1597
+ constructor(
1598
+ init?:
1599
+ | URLSearchParams
1600
+ | string
1601
+ | Record<string, string>
1602
+ | [key: string, value: string][]
1603
+ );
1604
+ append(name: string, value: string): void;
1605
+ delete(name: string): void;
1606
+ get(name: string): string | null;
1607
+ getAll(name: string): string[];
1608
+ has(name: string): boolean;
1609
+ set(name: string, value: string): void;
1610
+ sort(): void;
1611
+ entries(): IterableIterator<[key: string, value: string]>;
1612
+ keys(): IterableIterator<string>;
1613
+ values(): IterableIterator<string>;
1614
+ forEach<This = unknown>(
1615
+ callback: (
1616
+ this: This,
1617
+ value: string,
1618
+ key: string,
1619
+ parent: URLSearchParams
1620
+ ) => void,
1621
+ thisArg?: This
1622
+ ): void;
1623
+ toString(): string;
1624
+ [Symbol.iterator](): IterableIterator<[key: string, value: string]>;
1625
+ }
1626
+ export declare class URLPattern {
1627
+ constructor(input?: string | URLPatternURLPatternInit, baseURL?: string);
1628
+ get protocol(): string;
1629
+ get username(): string;
1630
+ get password(): string;
1631
+ get hostname(): string;
1632
+ get port(): string;
1633
+ get pathname(): string;
1634
+ get search(): string;
1635
+ get hash(): string;
1636
+ test(input?: string | URLPatternURLPatternInit, baseURL?: string): boolean;
1637
+ exec(
1638
+ input?: string | URLPatternURLPatternInit,
1639
+ baseURL?: string
1640
+ ): URLPatternURLPatternResult | null;
1641
+ }
1642
+ export interface URLPatternURLPatternInit {
1643
+ protocol?: string;
1644
+ username?: string;
1645
+ password?: string;
1646
+ hostname?: string;
1647
+ port?: string;
1648
+ pathname?: string;
1649
+ search?: string;
1650
+ hash?: string;
1651
+ baseURL?: string;
1652
+ }
1653
+ export interface URLPatternURLPatternComponentResult {
1654
+ input: string;
1655
+ groups: Record<string, string>;
1656
+ }
1657
+ export interface URLPatternURLPatternResult {
1658
+ inputs: (string | URLPatternURLPatternInit)[];
1659
+ protocol: URLPatternURLPatternComponentResult;
1660
+ username: URLPatternURLPatternComponentResult;
1661
+ password: URLPatternURLPatternComponentResult;
1662
+ hostname: URLPatternURLPatternComponentResult;
1663
+ port: URLPatternURLPatternComponentResult;
1664
+ pathname: URLPatternURLPatternComponentResult;
1665
+ search: URLPatternURLPatternComponentResult;
1666
+ hash: URLPatternURLPatternComponentResult;
1667
+ }
1668
+ export declare class CloseEvent extends Event {
1669
+ constructor(type: string, initializer: CloseEventInit);
1670
+ /** Returns the WebSocket connection close code provided by the server. */
1671
+ readonly code: number;
1672
+ /** Returns the WebSocket connection close reason provided by the server. */
1673
+ readonly reason: string;
1674
+ /** Returns true if the connection closed cleanly; false otherwise. */
1675
+ readonly wasClean: boolean;
1676
+ }
1677
+ export interface CloseEventInit {
1678
+ code?: number;
1679
+ reason?: string;
1680
+ wasClean?: boolean;
1681
+ }
1682
+ export declare class MessageEvent extends Event {
1683
+ constructor(type: string, initializer: MessageEventInit);
1684
+ readonly data: ArrayBuffer | string;
1685
+ }
1686
+ export interface MessageEventInit {
1687
+ data: ArrayBuffer | string;
1688
+ }
1689
+ /** Events providing information related to errors in scripts or in files. */
1690
+ export interface ErrorEvent extends Event {
1691
+ readonly filename: string;
1692
+ readonly message: string;
1693
+ readonly lineno: number;
1694
+ readonly colno: number;
1695
+ readonly error: any;
1696
+ }
1697
+ export type WebSocketEventMap = {
1698
+ close: CloseEvent;
1699
+ message: MessageEvent;
1700
+ open: Event;
1701
+ error: ErrorEvent;
1702
+ };
1703
+ export declare class WebSocket extends EventTarget<WebSocketEventMap> {
1704
+ constructor(url: string, protocols?: string[] | string);
1705
+ accept(): void;
1706
+ send(message: (ArrayBuffer | ArrayBufferView) | string): void;
1707
+ close(code?: number, reason?: string): void;
1708
+ static readonly READY_STATE_CONNECTING: number;
1709
+ static readonly READY_STATE_OPEN: number;
1710
+ static readonly READY_STATE_CLOSING: number;
1711
+ static readonly READY_STATE_CLOSED: number;
1712
+ /** Returns the state of the WebSocket object's connection. It can have the values described below. */
1713
+ readonly readyState: number;
1714
+ /** Returns the URL that was used to establish the WebSocket connection. */
1715
+ readonly url: string | null;
1716
+ /** Returns the subprotocol selected by the server, if any. It can be used in conjunction with the array form of the constructor's second argument to perform subprotocol negotiation. */
1717
+ readonly protocol: string | null;
1718
+ /** Returns the extensions selected by the server, if any. */
1719
+ readonly extensions: string | null;
1720
+ }
1721
+ export declare const WebSocketPair: {
1722
+ new (): {
1723
+ 0: WebSocket;
1724
+ 1: WebSocket;
1725
+ };
1726
+ };
1727
+ export interface BasicImageTransformations {
1728
+ /**
1729
+ * Maximum width in image pixels. The value must be an integer.
1730
+ */
1731
+ width?: number;
1732
+ /**
1733
+ * Maximum height in image pixels. The value must be an integer.
1734
+ */
1735
+ height?: number;
1736
+ /**
1737
+ * Resizing mode as a string. It affects interpretation of width and height
1738
+ * options:
1739
+ * - scale-down: Similar to contain, but the image is never enlarged. If
1740
+ * the image is larger than given width or height, it will be resized.
1741
+ * Otherwise its original size will be kept.
1742
+ * - contain: Resizes to maximum size that fits within the given width and
1743
+ * height. If only a single dimension is given (e.g. only width), the
1744
+ * image will be shrunk or enlarged to exactly match that dimension.
1745
+ * Aspect ratio is always preserved.
1746
+ * - cover: Resizes (shrinks or enlarges) to fill the entire area of width
1747
+ * and height. If the image has an aspect ratio different from the ratio
1748
+ * of width and height, it will be cropped to fit.
1749
+ * - crop: The image will be shrunk and cropped to fit within the area
1750
+ * specified by width and height. The image will not be enlarged. For images
1751
+ * smaller than the given dimensions it's the same as scale-down. For
1752
+ * images larger than the given dimensions, it's the same as cover.
1753
+ * See also trim.
1754
+ * - pad: Resizes to the maximum size that fits within the given width and
1755
+ * height, and then fills the remaining area with a background color
1756
+ * (white by default). Use of this mode is not recommended, as the same
1757
+ * effect can be more efficiently achieved with the contain mode and the
1758
+ * CSS object-fit: contain property.
1759
+ */
1760
+ fit?: "scale-down" | "contain" | "cover" | "crop" | "pad";
1761
+ /**
1762
+ * When cropping with fit: "cover", this defines the side or point that should
1763
+ * be left uncropped. The value is either a string
1764
+ * "left", "right", "top", "bottom", "auto", or "center" (the default),
1765
+ * or an object {x, y} containing focal point coordinates in the original
1766
+ * image expressed as fractions ranging from 0.0 (top or left) to 1.0
1767
+ * (bottom or right), 0.5 being the center. {fit: "cover", gravity: "top"} will
1768
+ * crop bottom or left and right sides as necessary, but won’t crop anything
1769
+ * from the top. {fit: "cover", gravity: {x:0.5, y:0.2}} will crop each side to
1770
+ * preserve as much as possible around a point at 20% of the height of the
1771
+ * source image.
1772
+ */
1773
+ gravity?:
1774
+ | "left"
1775
+ | "right"
1776
+ | "top"
1777
+ | "bottom"
1778
+ | "center"
1779
+ | "auto"
1780
+ | BasicImageTransformationsGravityCoordinates;
1781
+ /**
1782
+ * Background color to add underneath the image. Applies only to images with
1783
+ * transparency (such as PNG). Accepts any CSS color (#RRGGBB, rgba(…),
1784
+ * hsl(…), etc.)
1785
+ */
1786
+ background?: string;
1787
+ /**
1788
+ * Number of degrees (90, 180, 270) to rotate the image by. width and height
1789
+ * options refer to axes after rotation.
1790
+ */
1791
+ rotate?: 0 | 90 | 180 | 270 | 360;
1792
+ }
1793
+ export interface BasicImageTransformationsGravityCoordinates {
1794
+ x: number;
1795
+ y: number;
1796
+ }
1797
+ /**
1798
+ * In addition to the properties you can set in the RequestInit dict
1799
+ * that you pass as an argument to the Request constructor, you can
1800
+ * set certain properties of a `cf` object to control how Cloudflare
1801
+ * features are applied to that new Request.
1802
+ *
1803
+ * Note: Currently, these properties cannot be tested in the
1804
+ * playground.
1805
+ */
1806
+ export interface RequestInitCfProperties {
1807
+ cacheEverything?: boolean;
1808
+ /**
1809
+ * A request's cache key is what determines if two requests are
1810
+ * "the same" for caching purposes. If a request has the same cache key
1811
+ * as some previous request, then we can serve the same cached response for
1812
+ * both. (e.g. 'some-key')
1813
+ *
1814
+ * Only available for Enterprise customers.
1815
+ */
1816
+ cacheKey?: string;
1817
+ /**
1818
+ * This allows you to append additional Cache-Tag response headers
1819
+ * to the origin response without modifications to the origin server.
1820
+ * This will allow for greater control over the Purge by Cache Tag feature
1821
+ * utilizing changes only in the Workers process.
1822
+ *
1823
+ * Only available for Enterprise customers.
1824
+ */
1825
+ cacheTags?: string[];
1826
+ /**
1827
+ * Force response to be cached for a given number of seconds. (e.g. 300)
1828
+ */
1829
+ cacheTtl?: number;
1830
+ /**
1831
+ * Force response to be cached for a given number of seconds based on the Origin status code.
1832
+ * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
1833
+ */
1834
+ cacheTtlByStatus?: Record<string, number>;
1835
+ scrapeShield?: boolean;
1836
+ apps?: boolean;
1837
+ image?: RequestInitCfPropertiesImage;
1838
+ minify?: RequestInitCfPropertiesImageMinify;
1839
+ mirage?: boolean;
1840
+ polish?: "lossy" | "lossless" | "off";
1841
+ /**
1842
+ * Redirects the request to an alternate origin server. You can use this,
1843
+ * for example, to implement load balancing across several origins.
1844
+ * (e.g.us-east.example.com)
1845
+ *
1846
+ * Note - For security reasons, the hostname set in resolveOverride must
1847
+ * be proxied on the same Cloudflare zone of the incoming request.
1848
+ * Otherwise, the setting is ignored. CNAME hosts are allowed, so to
1849
+ * resolve to a host under a different domain or a DNS only domain first
1850
+ * declare a CNAME record within your own zone’s DNS mapping to the
1851
+ * external hostname, set proxy on Cloudflare, then set resolveOverride
1852
+ * to point to that CNAME record.
1853
+ */
1854
+ resolveOverride?: string;
1855
+ }
1856
+ export interface RequestInitCfPropertiesImageDraw
1857
+ extends BasicImageTransformations {
1858
+ /**
1859
+ * Absolute URL of the image file to use for the drawing. It can be any of
1860
+ * the supported file formats. For drawing of watermarks or non-rectangular
1861
+ * overlays we recommend using PNG or WebP images.
1862
+ */
1863
+ url: string;
1864
+ /**
1865
+ * Floating-point number between 0 (transparent) and 1 (opaque).
1866
+ * For example, opacity: 0.5 makes overlay semitransparent.
1867
+ */
1868
+ opacity?: number;
1869
+ /**
1870
+ * - If set to true, the overlay image will be tiled to cover the entire
1871
+ * area. This is useful for stock-photo-like watermarks.
1872
+ * - If set to "x", the overlay image will be tiled horizontally only
1873
+ * (form a line).
1874
+ * - If set to "y", the overlay image will be tiled vertically only
1875
+ * (form a line).
1876
+ */
1877
+ repeat?: true | "x" | "y";
1878
+ /**
1879
+ * Position of the overlay image relative to a given edge. Each property is
1880
+ * an offset in pixels. 0 aligns exactly to the edge. For example, left: 10
1881
+ * positions left side of the overlay 10 pixels from the left edge of the
1882
+ * image it's drawn over. bottom: 0 aligns bottom of the overlay with bottom
1883
+ * of the background image.
1884
+ *
1885
+ * Setting both left & right, or both top & bottom is an error.
1886
+ *
1887
+ * If no position is specified, the image will be centered.
1888
+ */
1889
+ top?: number;
1890
+ left?: number;
1891
+ bottom?: number;
1892
+ right?: number;
1893
+ }
1894
+ export interface RequestInitCfPropertiesImage
1895
+ extends BasicImageTransformations {
1896
+ /**
1897
+ * Device Pixel Ratio. Default 1. Multiplier for width/height that makes it
1898
+ * easier to specify higher-DPI sizes in <img srcset>.
1899
+ */
1900
+ dpr?: number;
1901
+ /**
1902
+ * An object with four properties {left, top, right, bottom} that specify
1903
+ * a number of pixels to cut off on each side. Allows removal of borders
1904
+ * or cutting out a specific fragment of an image. Trimming is performed
1905
+ * before resizing or rotation. Takes dpr into account.
1906
+ */
1907
+ trim?: {
1908
+ left?: number;
1909
+ top?: number;
1910
+ right?: number;
1911
+ bottom?: number;
1912
+ };
1913
+ /**
1914
+ * Quality setting from 1-100 (useful values are in 60-90 range). Lower values
1915
+ * make images look worse, but load faster. The default is 85. It applies only
1916
+ * to JPEG and WebP images. It doesn’t have any effect on PNG.
1917
+ */
1918
+ quality?: number;
1919
+ /**
1920
+ * Output format to generate. It can be:
1921
+ * - avif: generate images in AVIF format.
1922
+ * - webp: generate images in Google WebP format. Set quality to 100 to get
1923
+ * the WebP-lossless format.
1924
+ * - json: instead of generating an image, outputs information about the
1925
+ * image, in JSON format. The JSON object will contain image size
1926
+ * (before and after resizing), source image’s MIME type, file size, etc.
1927
+ * - jpeg: generate images in JPEG format.
1928
+ * - png: generate images in PNG format.
1929
+ */
1930
+ format?: "avif" | "webp" | "json" | "jpeg" | "png";
1931
+ /**
1932
+ * Whether to preserve animation frames from input files. Default is true.
1933
+ * Setting it to false reduces animations to still images. This setting is
1934
+ * recommended when enlarging images or processing arbitrary user content,
1935
+ * because large GIF animations can weigh tens or even hundreds of megabytes.
1936
+ * It is also useful to set anim:false when using format:"json" to get the
1937
+ * response quicker without the number of frames.
1938
+ */
1939
+ anim?: boolean;
1940
+ /**
1941
+ * What EXIF data should be preserved in the output image. Note that EXIF
1942
+ * rotation and embedded color profiles are always applied ("baked in" into
1943
+ * the image), and aren't affected by this option. Note that if the Polish
1944
+ * feature is enabled, all metadata may have been removed already and this
1945
+ * option may have no effect.
1946
+ * - keep: Preserve most of EXIF metadata, including GPS location if there's
1947
+ * any.
1948
+ * - copyright: Only keep the copyright tag, and discard everything else.
1949
+ * This is the default behavior for JPEG files.
1950
+ * - none: Discard all invisible EXIF metadata. Currently WebP and PNG
1951
+ * output formats always discard metadata.
1952
+ */
1953
+ metadata?: "keep" | "copyright" | "none";
1954
+ /**
1955
+ * Strength of sharpening filter to apply to the image. Floating-point
1956
+ * number between 0 (no sharpening, default) and 10 (maximum). 1.0 is a
1957
+ * recommended value for downscaled images.
1958
+ */
1959
+ sharpen?: number;
1960
+ /**
1961
+ * Radius of a blur filter (approximate gaussian). Maximum supported radius
1962
+ * is 250.
1963
+ */
1964
+ blur?: number;
1965
+ /**
1966
+ * Overlays are drawn in the order they appear in the array (last array
1967
+ * entry is the topmost layer).
1968
+ */
1969
+ draw?: RequestInitCfPropertiesImageDraw[];
1970
+ /**
1971
+ * Fetching image from authenticated origin. Setting this property will
1972
+ * pass authentication headers (Authorization, Cookie, etc.) through to
1973
+ * the origin.
1974
+ */
1975
+ "origin-auth"?: "share-publicly";
1976
+ }
1977
+ export interface RequestInitCfPropertiesImageMinify {
1978
+ javascript?: boolean;
1979
+ css?: boolean;
1980
+ html?: boolean;
1981
+ }
1982
+ /**
1983
+ * Request metadata provided by Cloudflare's edge.
1984
+ */
1985
+ export type IncomingRequestCfProperties<HostMetadata = unknown> =
1986
+ IncomingRequestCfPropertiesBase &
1987
+ IncomingRequestCfPropertiesBotManagementEnterprise &
1988
+ IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> &
1989
+ IncomingRequestCfPropertiesGeographicInformation &
1990
+ IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
1991
+ export interface IncomingRequestCfPropertiesBase {
1992
+ /**
1993
+ * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
1994
+ *
1995
+ * @example 395747
1996
+ */
1997
+ asn: number;
1998
+ /**
1999
+ * The organization which owns the ASN of the incoming request.
2000
+ *
2001
+ * @example "Google Cloud"
2002
+ */
2003
+ asOrganization: string;
2004
+ /**
2005
+ * The original value of the `Accept-Encoding` header if Cloudflare modified it.
2006
+ *
2007
+ * @example "gzip, deflate, br"
2008
+ */
2009
+ clientAcceptEncoding?: string;
2010
+ /**
2011
+ * The number of milliseconds it took for the request to reach your worker.
2012
+ *
2013
+ * @example 22
2014
+ */
2015
+ clientTcpRtt?: number;
2016
+ /**
2017
+ * The three-letter [IATA](https://en.wikipedia.org/wiki/IATA_airport_code)
2018
+ * airport code of the data center that the request hit.
2019
+ *
2020
+ * @example "DFW"
2021
+ */
2022
+ colo: string;
2023
+ /**
2024
+ * Represents the upstream's response to a
2025
+ * [TCP `keepalive` message](https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html)
2026
+ * from cloudflare.
2027
+ *
2028
+ * For workers with no upstream, this will always be `1`.
2029
+ *
2030
+ * @example 3
2031
+ */
2032
+ edgeRequestKeepAliveStatus: IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus;
2033
+ /**
2034
+ * The HTTP Protocol the request used.
2035
+ *
2036
+ * @example "HTTP/2"
2037
+ */
2038
+ httpProtocol: string;
2039
+ /**
2040
+ * The browser-requested prioritization information in the request object.
2041
+ *
2042
+ * If no information was set, defaults to the empty string `""`
2043
+ *
2044
+ * @example "weight=192;exclusive=0;group=3;group-weight=127"
2045
+ * @default ""
2046
+ */
2047
+ requestPriority: string;
2048
+ /**
2049
+ * The TLS version of the connection to Cloudflare.
2050
+ * In requests served over plaintext (without TLS), this property is the empty string `""`.
2051
+ *
2052
+ * @example "TLSv1.3"
2053
+ */
2054
+ tlsVersion: string;
2055
+ /**
2056
+ * The cipher for the connection to Cloudflare.
2057
+ * In requests served over plaintext (without TLS), this property is the empty string `""`.
2058
+ *
2059
+ * @example "AEAD-AES128-GCM-SHA256"
2060
+ */
2061
+ tlsCipher: string;
2062
+ /**
2063
+ * Metadata containing the [`HELLO`](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2) and [`FINISHED`](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9) messages from this request's TLS handshake.
2064
+ *
2065
+ * If the incoming request was served over plaintext (without TLS) this field is undefined.
2066
+ */
2067
+ tlsExportedAuthenticator?: IncomingRequestCfPropertiesExportedAuthenticatorMetadata;
2068
+ }
2069
+ export interface IncomingRequestCfPropertiesBotManagementBase {
2070
+ /**
2071
+ * Cloudflare’s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
2072
+ * represented as an integer percentage between `1` (almost certainly human)
2073
+ * and `99` (almost certainly a bot).
2074
+ *
2075
+ * @example 54
2076
+ */
2077
+ score: number;
2078
+ /**
2079
+ * A boolean value that is true if the request comes from a good bot, like Google or Bing.
2080
+ * Most customers choose to allow this traffic. For more details, see [Traffic from known bots](https://developers.cloudflare.com/firewall/known-issues-and-faq/#how-does-firewall-rules-handle-traffic-from-known-bots).
2081
+ */
2082
+ verifiedBot: boolean;
2083
+ /**
2084
+ * A boolean value that is true if the request originates from a
2085
+ * Cloudflare-verified proxy service.
2086
+ */
2087
+ corporateProxy: boolean;
2088
+ /**
2089
+ * A boolean value that's true if the request matches [file extensions](https://developers.cloudflare.com/bots/reference/static-resources/) for many types of static resources.
2090
+ */
2091
+ staticResource: boolean;
2092
+ }
2093
+ export interface IncomingRequestCfPropertiesBotManagement {
2094
+ /**
2095
+ * Results of Cloudflare's Bot Management analysis
2096
+ */
2097
+ botManagement: IncomingRequestCfPropertiesBotManagementBase;
2098
+ /**
2099
+ * Duplicate of `botManagement.score`.
2100
+ *
2101
+ * @deprecated
2102
+ */
2103
+ clientTrustScore: number;
2104
+ }
2105
+ export interface IncomingRequestCfPropertiesBotManagementEnterprise
2106
+ extends IncomingRequestCfPropertiesBotManagement {
2107
+ /**
2108
+ * Results of Cloudflare's Bot Management analysis
2109
+ */
2110
+ botManagement: IncomingRequestCfPropertiesBotManagementBase & {
2111
+ /**
2112
+ * A [JA3 Fingerprint](https://developers.cloudflare.com/bots/concepts/ja3-fingerprint/) to help profile specific SSL/TLS clients
2113
+ * across different destination IPs, Ports, and X509 certificates.
2114
+ */
2115
+ ja3Hash: string;
2116
+ };
2117
+ }
2118
+ export interface IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<
2119
+ HostMetadata
2120
+ > {
2121
+ /**
2122
+ * Custom metadata set per-host in [Cloudflare for SaaS](https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/).
2123
+ *
2124
+ * This field is only present if you have Cloudflare for SaaS enabled on your account
2125
+ * and you have followed the [required steps to enable it]((https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/domain-support/custom-metadata/)).
2126
+ */
2127
+ hostMetadata: HostMetadata;
2128
+ }
2129
+ export interface IncomingRequestCfPropertiesCloudflareAccessOrApiShield {
2130
+ /**
2131
+ * Information about the client certificate presented to Cloudflare.
2132
+ *
2133
+ * This is populated when the incoming request is served over TLS using
2134
+ * either Cloudflare Access or API Shield (mTLS)
2135
+ * and the presented SSL certificate has a valid
2136
+ * [Certificate Serial Number](https://ldapwiki.com/wiki/Certificate%20Serial%20Number)
2137
+ * (i.e., not `null` or `""`).
2138
+ *
2139
+ * Otherwise, a set of placeholder values are used.
2140
+ *
2141
+ * The property `certPresented` will be set to `"1"` when
2142
+ * the object is populated (i.e. the above conditions were met).
2143
+ */
2144
+ tlsClientAuth:
2145
+ | IncomingRequestCfPropertiesTLSClientAuth
2146
+ | IncomingRequestCfPropertiesTLSClientAuthPlaceholder;
2147
+ }
2148
+ /**
2149
+ * Metadata about the request's TLS handshake
2150
+ */
2151
+ export interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
2152
+ /**
2153
+ * The client's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
2154
+ *
2155
+ * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
2156
+ */
2157
+ clientHandshake: string;
2158
+ /**
2159
+ * The server's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
2160
+ *
2161
+ * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
2162
+ */
2163
+ serverHandshake: string;
2164
+ /**
2165
+ * The client's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
2166
+ *
2167
+ * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
2168
+ */
2169
+ clientFinished: string;
2170
+ /**
2171
+ * The server's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
2172
+ *
2173
+ * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
2174
+ */
2175
+ serverFinished: string;
2176
+ }
2177
+ /**
2178
+ * Geographic data about the request's origin.
2179
+ */
2180
+ export type IncomingRequestCfPropertiesGeographicInformation =
2181
+ | {}
2182
+ | {
2183
+ /** The country code `"T1"` is used for requests originating on TOR */
2184
+ country: "T1";
2185
+ }
2186
+ | {
2187
+ /**
2188
+ * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
2189
+ *
2190
+ * If your worker is [configured to accept TOR connections](https://support.cloudflare.com/hc/en-us/articles/203306930-Understanding-Cloudflare-Tor-support-and-Onion-Routing), this may also be `"T1"`, indicating a request that originated over TOR.
2191
+ *
2192
+ * If Cloudflare is unable to determine where the request originated this property is omitted.
2193
+ *
2194
+ * @example "GB"
2195
+ */
2196
+ country: Iso3166Alpha2Code;
2197
+ /**
2198
+ * If present, this property indicates that the request originated in the EU
2199
+ *
2200
+ * @example "1"
2201
+ */
2202
+ isEUCountry?: "1";
2203
+ /**
2204
+ * A two-letter code indicating the continent the request originated from.
2205
+ *
2206
+ * @example "AN"
2207
+ */
2208
+ continent: ContinentCode;
2209
+ /**
2210
+ * The city the request originated from
2211
+ *
2212
+ * @example "Austin"
2213
+ */
2214
+ city?: string;
2215
+ /**
2216
+ * Postal code of the incoming request
2217
+ *
2218
+ * @example "78701"
2219
+ */
2220
+ postalCode?: string;
2221
+ /**
2222
+ * Latitude of the incoming request
2223
+ *
2224
+ * @example "30.27130"
2225
+ */
2226
+ latitude?: string;
2227
+ /**
2228
+ * Longitude of the incoming request
2229
+ *
2230
+ * @example "-97.74260"
2231
+ */
2232
+ longitude?: string;
2233
+ /**
2234
+ * Timezone of the incoming request
2235
+ *
2236
+ * @example "America/Chicago"
2237
+ */
2238
+ timezone?: string;
2239
+ /**
2240
+ * If known, the ISO 3166-2 name for the first level region associated with
2241
+ * the IP address of the incoming request
2242
+ *
2243
+ * @example "Texas"
2244
+ */
2245
+ region?: string;
2246
+ /**
2247
+ * If known, the ISO 3166-2 code for the first-level region associated with
2248
+ * the IP address of the incoming request
2249
+ *
2250
+ * @example "TX"
2251
+ */
2252
+ regionCode?: string;
2253
+ /**
2254
+ * Metro code (DMA) of the incoming request
2255
+ *
2256
+ * @example "635"
2257
+ */
2258
+ metroCode?: string;
2259
+ };
2260
+ /** Data about the incoming request's TLS certificate */
2261
+ export interface IncomingRequestCfPropertiesTLSClientAuth {
2262
+ /** Always `"1"`, indicating that the certificate was presented */
2263
+ certPresented: "1";
2264
+ /**
2265
+ * Result of certificate verification.
2266
+ *
2267
+ * @example "FAILED:self signed certificate"
2268
+ */
2269
+ certVerified: Exclude<CertVerificationStatus, "NONE">;
2270
+ /** The presented certificate's revokation status.
2271
+ *
2272
+ * - A value of `"1"` indicates the certificate has been revoked
2273
+ * - A value of `"0"` indicates the certificate has not been revoked
2274
+ */
2275
+ certRevoked: "1" | "0";
2276
+ /**
2277
+ * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
2278
+ *
2279
+ * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
2280
+ */
2281
+ certIssuerDN: string;
2282
+ /**
2283
+ * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
2284
+ *
2285
+ * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
2286
+ */
2287
+ certSubjectDN: string;
2288
+ /**
2289
+ * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
2290
+ *
2291
+ * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
2292
+ */
2293
+ certIssuerDNRFC2253: string;
2294
+ /**
2295
+ * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
2296
+ *
2297
+ * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
2298
+ */
2299
+ certSubjectDNRFC2253: string;
2300
+ /** The certificate issuer's distinguished name (legacy policies) */
2301
+ certIssuerDNLegacy: string;
2302
+ /** The certificate subject's distinguished name (legacy policies) */
2303
+ certSubjectDNLegacy: string;
2304
+ /**
2305
+ * The certificate's serial number
2306
+ *
2307
+ * @example "00936EACBE07F201DF"
2308
+ */
2309
+ certSerial: string;
2310
+ /**
2311
+ * The certificate issuer's serial number
2312
+ *
2313
+ * @example "2489002934BDFEA34"
2314
+ */
2315
+ certIssuerSerial: string;
2316
+ /**
2317
+ * The certificate's Subject Key Identifier
2318
+ *
2319
+ * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
2320
+ */
2321
+ certSKI: string;
2322
+ /**
2323
+ * The certificate issuer's Subject Key Identifier
2324
+ *
2325
+ * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
2326
+ */
2327
+ certIssuerSKI: string;
2328
+ /**
2329
+ * The certificate's SHA-1 fingerprint
2330
+ *
2331
+ * @example "6b9109f323999e52259cda7373ff0b4d26bd232e"
2332
+ */
2333
+ certFingerprintSHA1: string;
2334
+ /**
2335
+ * The certificate's SHA-256 fingerprint
2336
+ *
2337
+ * @example "acf77cf37b4156a2708e34c4eb755f9b5dbbe5ebb55adfec8f11493438d19e6ad3f157f81fa3b98278453d5652b0c1fd1d71e5695ae4d709803a4d3f39de9dea"
2338
+ */
2339
+ certFingerprintSHA256: string;
2340
+ /**
2341
+ * The effective starting date of the certificate
2342
+ *
2343
+ * @example "Dec 22 19:39:00 2018 GMT"
2344
+ */
2345
+ certNotBefore: string;
2346
+ /**
2347
+ * The effective expiration date of the certificate
2348
+ *
2349
+ * @example "Dec 22 19:39:00 2018 GMT"
2350
+ */
2351
+ certNotAfter: string;
2352
+ }
2353
+ /** Placeholder values for TLS Client Authorization */
2354
+ export interface IncomingRequestCfPropertiesTLSClientAuthPlaceholder {
2355
+ certPresented: "0";
2356
+ certVerified: "NONE";
2357
+ certRevoked: "0";
2358
+ certIssuerDN: "";
2359
+ certSubjectDN: "";
2360
+ certIssuerDNRFC2253: "";
2361
+ certSubjectDNRFC2253: "";
2362
+ certIssuerDNLegacy: "";
2363
+ certSubjectDNLegacy: "";
2364
+ certSerial: "";
2365
+ certIssuerSerial: "";
2366
+ certSKI: "";
2367
+ certIssuerSKI: "";
2368
+ certFingerprintSHA1: "";
2369
+ certFingerprintSHA256: "";
2370
+ certNotBefore: "";
2371
+ certNotAfter: "";
2372
+ }
2373
+ /** Possible outcomes of TLS verification */
2374
+ export type CertVerificationStatus =
2375
+ /** Authentication succeeded */
2376
+ | "SUCCESS"
2377
+ /** No certificate was presented */
2378
+ | "NONE"
2379
+ /** Failed because the certificate was self-signed */
2380
+ | "FAILED:self signed certificate"
2381
+ /** Failed because the certificate failed a trust chain check */
2382
+ | "FAILED:unable to verify the first certificate"
2383
+ /** Failed because the certificate not yet valid */
2384
+ | "FAILED:certificate is not yet valid"
2385
+ /** Failed because the certificate is expired */
2386
+ | "FAILED:certificate has expired"
2387
+ /** Failed for another unspecified reason */
2388
+ | "FAILED";
2389
+ /**
2390
+ * An upstream endpoint's response to a TCP `keepalive` message from Cloudflare.
2391
+ */
2392
+ export type IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus =
2393
+ | 0 /** Unknown */
2394
+ | 1 /** no keepalives (not found) */
2395
+ | 2 /** no connection re-use, opening keepalive connection failed */
2396
+ | 3 /** no connection re-use, keepalive accepted and saved */
2397
+ | 4 /** connection re-use, refused by the origin server (`TCP FIN`) */
2398
+ | 5; /** connection re-use, accepted by the origin server */
2399
+ /** ISO 3166-1 Alpha-2 codes */
2400
+ export type Iso3166Alpha2Code =
2401
+ | "AD"
2402
+ | "AE"
2403
+ | "AF"
2404
+ | "AG"
2405
+ | "AI"
2406
+ | "AL"
2407
+ | "AM"
2408
+ | "AO"
2409
+ | "AQ"
2410
+ | "AR"
2411
+ | "AS"
2412
+ | "AT"
2413
+ | "AU"
2414
+ | "AW"
2415
+ | "AX"
2416
+ | "AZ"
2417
+ | "BA"
2418
+ | "BB"
2419
+ | "BD"
2420
+ | "BE"
2421
+ | "BF"
2422
+ | "BG"
2423
+ | "BH"
2424
+ | "BI"
2425
+ | "BJ"
2426
+ | "BL"
2427
+ | "BM"
2428
+ | "BN"
2429
+ | "BO"
2430
+ | "BQ"
2431
+ | "BR"
2432
+ | "BS"
2433
+ | "BT"
2434
+ | "BV"
2435
+ | "BW"
2436
+ | "BY"
2437
+ | "BZ"
2438
+ | "CA"
2439
+ | "CC"
2440
+ | "CD"
2441
+ | "CF"
2442
+ | "CG"
2443
+ | "CH"
2444
+ | "CI"
2445
+ | "CK"
2446
+ | "CL"
2447
+ | "CM"
2448
+ | "CN"
2449
+ | "CO"
2450
+ | "CR"
2451
+ | "CU"
2452
+ | "CV"
2453
+ | "CW"
2454
+ | "CX"
2455
+ | "CY"
2456
+ | "CZ"
2457
+ | "DE"
2458
+ | "DJ"
2459
+ | "DK"
2460
+ | "DM"
2461
+ | "DO"
2462
+ | "DZ"
2463
+ | "EC"
2464
+ | "EE"
2465
+ | "EG"
2466
+ | "EH"
2467
+ | "ER"
2468
+ | "ES"
2469
+ | "ET"
2470
+ | "FI"
2471
+ | "FJ"
2472
+ | "FK"
2473
+ | "FM"
2474
+ | "FO"
2475
+ | "FR"
2476
+ | "GA"
2477
+ | "GB"
2478
+ | "GD"
2479
+ | "GE"
2480
+ | "GF"
2481
+ | "GG"
2482
+ | "GH"
2483
+ | "GI"
2484
+ | "GL"
2485
+ | "GM"
2486
+ | "GN"
2487
+ | "GP"
2488
+ | "GQ"
2489
+ | "GR"
2490
+ | "GS"
2491
+ | "GT"
2492
+ | "GU"
2493
+ | "GW"
2494
+ | "GY"
2495
+ | "HK"
2496
+ | "HM"
2497
+ | "HN"
2498
+ | "HR"
2499
+ | "HT"
2500
+ | "HU"
2501
+ | "ID"
2502
+ | "IE"
2503
+ | "IL"
2504
+ | "IM"
2505
+ | "IN"
2506
+ | "IO"
2507
+ | "IQ"
2508
+ | "IR"
2509
+ | "IS"
2510
+ | "IT"
2511
+ | "JE"
2512
+ | "JM"
2513
+ | "JO"
2514
+ | "JP"
2515
+ | "KE"
2516
+ | "KG"
2517
+ | "KH"
2518
+ | "KI"
2519
+ | "KM"
2520
+ | "KN"
2521
+ | "KP"
2522
+ | "KR"
2523
+ | "KW"
2524
+ | "KY"
2525
+ | "KZ"
2526
+ | "LA"
2527
+ | "LB"
2528
+ | "LC"
2529
+ | "LI"
2530
+ | "LK"
2531
+ | "LR"
2532
+ | "LS"
2533
+ | "LT"
2534
+ | "LU"
2535
+ | "LV"
2536
+ | "LY"
2537
+ | "MA"
2538
+ | "MC"
2539
+ | "MD"
2540
+ | "ME"
2541
+ | "MF"
2542
+ | "MG"
2543
+ | "MH"
2544
+ | "MK"
2545
+ | "ML"
2546
+ | "MM"
2547
+ | "MN"
2548
+ | "MO"
2549
+ | "MP"
2550
+ | "MQ"
2551
+ | "MR"
2552
+ | "MS"
2553
+ | "MT"
2554
+ | "MU"
2555
+ | "MV"
2556
+ | "MW"
2557
+ | "MX"
2558
+ | "MY"
2559
+ | "MZ"
2560
+ | "NA"
2561
+ | "NC"
2562
+ | "NE"
2563
+ | "NF"
2564
+ | "NG"
2565
+ | "NI"
2566
+ | "NL"
2567
+ | "NO"
2568
+ | "NP"
2569
+ | "NR"
2570
+ | "NU"
2571
+ | "NZ"
2572
+ | "OM"
2573
+ | "PA"
2574
+ | "PE"
2575
+ | "PF"
2576
+ | "PG"
2577
+ | "PH"
2578
+ | "PK"
2579
+ | "PL"
2580
+ | "PM"
2581
+ | "PN"
2582
+ | "PR"
2583
+ | "PS"
2584
+ | "PT"
2585
+ | "PW"
2586
+ | "PY"
2587
+ | "QA"
2588
+ | "RE"
2589
+ | "RO"
2590
+ | "RS"
2591
+ | "RU"
2592
+ | "RW"
2593
+ | "SA"
2594
+ | "SB"
2595
+ | "SC"
2596
+ | "SD"
2597
+ | "SE"
2598
+ | "SG"
2599
+ | "SH"
2600
+ | "SI"
2601
+ | "SJ"
2602
+ | "SK"
2603
+ | "SL"
2604
+ | "SM"
2605
+ | "SN"
2606
+ | "SO"
2607
+ | "SR"
2608
+ | "SS"
2609
+ | "ST"
2610
+ | "SV"
2611
+ | "SX"
2612
+ | "SY"
2613
+ | "SZ"
2614
+ | "TC"
2615
+ | "TD"
2616
+ | "TF"
2617
+ | "TG"
2618
+ | "TH"
2619
+ | "TJ"
2620
+ | "TK"
2621
+ | "TL"
2622
+ | "TM"
2623
+ | "TN"
2624
+ | "TO"
2625
+ | "TR"
2626
+ | "TT"
2627
+ | "TV"
2628
+ | "TW"
2629
+ | "TZ"
2630
+ | "UA"
2631
+ | "UG"
2632
+ | "UM"
2633
+ | "US"
2634
+ | "UY"
2635
+ | "UZ"
2636
+ | "VA"
2637
+ | "VC"
2638
+ | "VE"
2639
+ | "VG"
2640
+ | "VI"
2641
+ | "VN"
2642
+ | "VU"
2643
+ | "WF"
2644
+ | "WS"
2645
+ | "YE"
2646
+ | "YT"
2647
+ | "ZA"
2648
+ | "ZM"
2649
+ | "ZW";
2650
+ /** The 2-letter continent codes Cloudflare uses */
2651
+ export type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
2652
+ export interface D1Result<T = unknown> {
2653
+ results?: T[];
2654
+ success: boolean;
2655
+ error?: string;
2656
+ meta: any;
2657
+ }
2658
+ export declare abstract class D1Database {
2659
+ prepare(query: string): D1PreparedStatement;
2660
+ dump(): Promise<ArrayBuffer>;
2661
+ batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
2662
+ exec<T = unknown>(query: string): Promise<D1Result<T>>;
2663
+ }
2664
+ export declare abstract class D1PreparedStatement {
2665
+ bind(...values: any[]): D1PreparedStatement;
2666
+ first<T = unknown>(colName?: string): Promise<T>;
2667
+ run<T = unknown>(): Promise<D1Result<T>>;
2668
+ all<T = unknown>(): Promise<D1Result<T>>;
2669
+ raw<T = unknown>(): Promise<T[]>;
2670
+ }
2671
+ export type Params<P extends string = any> = Record<P, string | string[]>;
2672
+ export type EventContext<Env, P extends string, Data> = {
2673
+ request: Request;
2674
+ functionPath: string;
2675
+ waitUntil: (promise: Promise<any>) => void;
2676
+ passThroughOnException: () => void;
2677
+ next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
2678
+ env: Env & {
2679
+ ASSETS: {
2680
+ fetch: typeof fetch;
2681
+ };
2682
+ };
2683
+ params: Params<P>;
2684
+ data: Data;
2685
+ };
2686
+ export type PagesFunction<
2687
+ Env = unknown,
2688
+ Params extends string = any,
2689
+ Data extends Record<string, unknown> = Record<string, unknown>
2690
+ > = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>;
2691
+ export type EventPluginContext<Env, P extends string, Data, PluginArgs> = {
2692
+ request: Request;
2693
+ functionPath: string;
2694
+ waitUntil: (promise: Promise<any>) => void;
2695
+ passThroughOnException: () => void;
2696
+ next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
2697
+ env: Env & {
2698
+ ASSETS: {
2699
+ fetch: typeof fetch;
2700
+ };
2701
+ };
2702
+ params: Params<P>;
2703
+ data: Data;
2704
+ pluginArgs: PluginArgs;
2705
+ };
2706
+ export type PagesPluginFunction<
2707
+ Env = unknown,
2708
+ Params extends string = any,
2709
+ Data extends Record<string, unknown> = Record<string, unknown>,
2710
+ PluginArgs = unknown
2711
+ > = (
2712
+ context: EventPluginContext<Env, Params, Data, PluginArgs>
2713
+ ) => Response | Promise<Response>;
2714
+ /**
2715
+ * A message that is sent to a consumer Worker.
2716
+ */
2717
+ export interface Message<Body = unknown> {
2718
+ /**
2719
+ * A unique, system-generated ID for the message.
2720
+ */
2721
+ readonly id: string;
2722
+ /**
2723
+ * A timestamp when the message was sent.
2724
+ */
2725
+ readonly timestamp: Date;
2726
+ /**
2727
+ * The body of the message.
2728
+ */
2729
+ readonly body: Body;
2730
+ }
2731
+ /**
2732
+ * A batch of messages that are sent to a consumer Worker.
2733
+ */
2734
+ export interface MessageBatch<Body = unknown> {
2735
+ /**
2736
+ * The name of the Queue that belongs to this batch.
2737
+ */
2738
+ readonly queue: string;
2739
+ /**
2740
+ * An array of messages in the batch. Ordering of messages is not guaranteed.
2741
+ */
2742
+ readonly messages: readonly Message<Body>[];
2743
+ /**
2744
+ * Marks every message to be retried in the next batch.
2745
+ */
2746
+ retryAll(): void;
2747
+ }
2748
+ /**
2749
+ * A binding that allows a producer to send messages to a Queue.
2750
+ */
2751
+ export interface Queue<Body = any> {
2752
+ /**
2753
+ * Sends a message to the Queue.
2754
+ * @param message The message can be any type supported by the [structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types), as long as its size is less than 128 KB.
2755
+ * @returns A promise that resolves when the message is confirmed to be written to disk.
2756
+ */
2757
+ send(message: Body): Promise<void>;
2758
+ }