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