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