@cloudflare/workers-types 3.18.0 → 4.20221111.1

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