-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathrequest.d.ts
138 lines (133 loc) · 3.52 KB
/
request.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/// <reference lib="webworker" />
declare global {
interface Request {
cf: IncomingCloudflareProperties;
}
}
export type Params = Record<string, string>;
/** @see {require('http').METHODS} */
export type Method = 'ACL' | 'BIND' | 'CHECKOUT' | 'CONNECT' | 'COPY' | 'DELETE' | 'GET' | 'HEAD' | 'LINK' | 'LOCK' | 'M-SEARCH' | 'MERGE' | 'MKACTIVITY' | 'MKCALENDAR' | 'MKCOL' | 'MOVE' | 'NOTIFY' | 'OPTIONS' | 'PATCH' | 'POST' | 'PRI' | 'PROPFIND' | 'PROPPATCH' | 'PURGE' | 'PUT' | 'REBIND' | 'REPORT' | 'SEARCH' | 'SOURCE' | 'SUBSCRIBE' | 'TRACE' | 'UNBIND' | 'UNLINK' | 'UNLOCK' | 'UNSUBSCRIBE';
/** @see https://developers.cloudflare.com/workers/runtime-apis/request#incomingrequestcfproperties */
export interface IncomingCloudflareProperties {
/**
* The ASN of the incoming request
* @example "395747"
**/
asn: string;
/**
* The three-letter `IATA` airport code of the data center that the request hit
* @example "DFW"
*/
colo: string;
/**
* The two-letter country code in the request.
* @note This is the same value as that provided in the `CF-IPCountry` header
* @example "US"
*/
country: string | null;
/**
* The HTTP Protocol
* @example "HTTP/2"
*/
httpProtocol: string;
/**
* The browser-requested prioritization information in the request object
* @example "weight=192;exclusive=0;group=3;group-weight=127"
*/
requestPriority?: string;
/**
* The cipher for the connection to Cloudflare
* @example "AEAD-AES128-GCM-SHA256"
*/
tlsCipher: string;
/**
* @note Requires Cloudflare Access or API Shield
*/
tlsClientAuth?: {
certIssuerDN: string;
certIssuerDNLegacy: string;
certPresented: '0' | '1';
certSubjectDNLegacy: string;
certSubjectDN: string;
/** @example "Dec 22 19:39:00 2018 GMT" */
certNotBefore: string;
/** @example "Dec 22 19:39:00 2018 GMT" */
certNotAfter: string;
certFingerprintSHA1: string;
certSerial: string;
/** @example "SUCCESS", "FAILED:reason", "NONE" */
certVerified: string;
};
/**
* The TLS version of the connection to Cloudflare
* @example "TLSv1.3"
*/
tlsVersion: string;
/**
* City of the incoming request
* @example "Austin"
**/
city?: string;
/**
* Continent of the incoming request
* @example "NA"
**/
continent?: string;
/**
* Latitude of the incoming request
* @example "30.27130"
**/
latitude?: string;
/**
* Longitude of the incoming request
* @example "-97.74260"
**/
longitude?: string;
/**
* Postal code of the incoming request
* @example "78701"
**/
postalCode?: string;
/**
* Metro code (DMA) of the incoming request
* @example "635"
**/
metroCode?: string;
/**
* If known, the `ISO 3166-2` name for the first level region associated with the IP address of the incoming request
* @example "Texas"
**/
region?: string;
/**
* If known, the `ISO 3166-2` code for the first level region associated with the IP address of the incoming request
* @example "TX"
**/
regionCode?: string;
/**
* Timezone of the incoming request
* @example "America/Chicago".
**/
timezone: string;
}
export declare class ServerRequest<P extends Params = Params> {
constructor(event: FetchEvent);
url: string;
path: string;
method: Method;
origin: string;
hostname: string;
search: string;
query: URLSearchParams;
extend: FetchEvent['waitUntil'];
cf: IncomingCloudflareProperties;
headers: Headers;
params: P;
body: {
<T>(): Promise<T|void>;
json<T=any>(): Promise<T>;
arrayBuffer(): Promise<ArrayBuffer>;
formData(): Promise<FormData>;
text(): Promise<string>;
blob(): Promise<Blob>;
};
}