@cloudflare/workers-types 0.20221111.0

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