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