@vercel/functions 1.5.1 β 1.5.2
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.
- package/CHANGELOG.md +6 -0
- package/docs/interfaces/index.Geo.md +20 -7
- package/docs/interfaces/index.Request.md +1 -1
- package/docs/modules/index.md +10 -9
- package/headers.d.ts +7 -0
- package/headers.js +5 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -14,6 +14,7 @@ The location information of a given request.
|
|
|
14
14
|
- [flag](index.Geo.md#flag)
|
|
15
15
|
- [latitude](index.Geo.md#latitude)
|
|
16
16
|
- [longitude](index.Geo.md#longitude)
|
|
17
|
+
- [postalCode](index.Geo.md#postalcode)
|
|
17
18
|
- [region](index.Geo.md#region)
|
|
18
19
|
|
|
19
20
|
## Properties
|
|
@@ -26,7 +27,7 @@ The city that the request originated from.
|
|
|
26
27
|
|
|
27
28
|
#### Defined in
|
|
28
29
|
|
|
29
|
-
[packages/functions/src/headers.ts:
|
|
30
|
+
[packages/functions/src/headers.ts:59](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L59)
|
|
30
31
|
|
|
31
32
|
---
|
|
32
33
|
|
|
@@ -38,7 +39,7 @@ The country that the request originated from.
|
|
|
38
39
|
|
|
39
40
|
#### Defined in
|
|
40
41
|
|
|
41
|
-
[packages/functions/src/headers.ts:
|
|
42
|
+
[packages/functions/src/headers.ts:62](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L62)
|
|
42
43
|
|
|
43
44
|
---
|
|
44
45
|
|
|
@@ -51,7 +52,7 @@ See [docs](https://vercel.com/docs/concepts/edge-network/headers#x-vercel-ip-cou
|
|
|
51
52
|
|
|
52
53
|
#### Defined in
|
|
53
54
|
|
|
54
|
-
[packages/functions/src/headers.ts:
|
|
55
|
+
[packages/functions/src/headers.ts:73](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L73)
|
|
55
56
|
|
|
56
57
|
---
|
|
57
58
|
|
|
@@ -63,7 +64,7 @@ The flag emoji for the country the request originated from.
|
|
|
63
64
|
|
|
64
65
|
#### Defined in
|
|
65
66
|
|
|
66
|
-
[packages/functions/src/headers.ts:
|
|
67
|
+
[packages/functions/src/headers.ts:65](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L65)
|
|
67
68
|
|
|
68
69
|
---
|
|
69
70
|
|
|
@@ -75,7 +76,7 @@ The latitude of the client.
|
|
|
75
76
|
|
|
76
77
|
#### Defined in
|
|
77
78
|
|
|
78
|
-
[packages/functions/src/headers.ts:
|
|
79
|
+
[packages/functions/src/headers.ts:76](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L76)
|
|
79
80
|
|
|
80
81
|
---
|
|
81
82
|
|
|
@@ -87,7 +88,19 @@ The longitude of the client.
|
|
|
87
88
|
|
|
88
89
|
#### Defined in
|
|
89
90
|
|
|
90
|
-
[packages/functions/src/headers.ts:
|
|
91
|
+
[packages/functions/src/headers.ts:79](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L79)
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
### postalCode
|
|
96
|
+
|
|
97
|
+
β’ `Optional` **postalCode**: `string`
|
|
98
|
+
|
|
99
|
+
The postal code of the client
|
|
100
|
+
|
|
101
|
+
#### Defined in
|
|
102
|
+
|
|
103
|
+
[packages/functions/src/headers.ts:82](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L82)
|
|
91
104
|
|
|
92
105
|
---
|
|
93
106
|
|
|
@@ -99,4 +112,4 @@ The [Vercel Edge Network region](https://vercel.com/docs/concepts/edge-network/r
|
|
|
99
112
|
|
|
100
113
|
#### Defined in
|
|
101
114
|
|
|
102
|
-
[packages/functions/src/headers.ts:
|
|
115
|
+
[packages/functions/src/headers.ts:68](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L68)
|
|
@@ -20,4 +20,4 @@ Represents the headers of a request.
|
|
|
20
20
|
|
|
21
21
|
#### Defined in
|
|
22
22
|
|
|
23
|
-
[packages/functions/src/headers.ts:
|
|
23
|
+
[packages/functions/src/headers.ts:52](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L52)
|
package/docs/modules/index.md
CHANGED
|
@@ -47,19 +47,20 @@ The location information of the request, in this way:
|
|
|
47
47
|
|
|
48
48
|
```json
|
|
49
49
|
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
"city": "New York",
|
|
51
|
+
"country": "US",
|
|
52
|
+
"flag": "πΊπΈ",
|
|
53
|
+
"countryRegion": "NY",
|
|
54
|
+
"region": "iad1",
|
|
55
|
+
"latitude": "40.7128",
|
|
56
|
+
"longitude": "-74.0060"
|
|
57
|
+
"postalCode": "10001"
|
|
57
58
|
}
|
|
58
59
|
```
|
|
59
60
|
|
|
60
61
|
#### Defined in
|
|
61
62
|
|
|
62
|
-
[packages/functions/src/headers.ts:
|
|
63
|
+
[packages/functions/src/headers.ts:180](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L180)
|
|
63
64
|
|
|
64
65
|
---
|
|
65
66
|
|
|
@@ -144,7 +145,7 @@ The IP address of the request.
|
|
|
144
145
|
|
|
145
146
|
#### Defined in
|
|
146
147
|
|
|
147
|
-
[packages/functions/src/headers.ts:
|
|
148
|
+
[packages/functions/src/headers.ts:131](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L131)
|
|
148
149
|
|
|
149
150
|
---
|
|
150
151
|
|
package/headers.d.ts
CHANGED
|
@@ -24,6 +24,10 @@ export declare const LONGITUDE_HEADER_NAME = "x-vercel-ip-longitude";
|
|
|
24
24
|
* See [docs](https://vercel.com/docs/concepts/edge-network/headers#x-vercel-ip-country-region).
|
|
25
25
|
*/
|
|
26
26
|
export declare const REGION_HEADER_NAME = "x-vercel-ip-country-region";
|
|
27
|
+
/**
|
|
28
|
+
* Postal code of the original client IP as calculated by Vercel Proxy.
|
|
29
|
+
*/
|
|
30
|
+
export declare const POSTAL_CODE_HEADER_NAME = "x-vercel-ip-postal-code";
|
|
27
31
|
/**
|
|
28
32
|
* The request ID for each request generated by Vercel Proxy.
|
|
29
33
|
*/
|
|
@@ -67,6 +71,8 @@ export interface Geo {
|
|
|
67
71
|
latitude?: string;
|
|
68
72
|
/** The longitude of the client. */
|
|
69
73
|
longitude?: string;
|
|
74
|
+
/** The postal code of the client */
|
|
75
|
+
postalCode?: string;
|
|
70
76
|
}
|
|
71
77
|
/**
|
|
72
78
|
* Returns the IP address of the request from the headers.
|
|
@@ -101,6 +107,7 @@ export declare function ipAddress(input: Request | Headers): string | undefined;
|
|
|
101
107
|
* "region": "iad1",
|
|
102
108
|
* "latitude": "40.7128",
|
|
103
109
|
* "longitude": "-74.0060"
|
|
110
|
+
* "postalCode": "10001"
|
|
104
111
|
* }
|
|
105
112
|
* ```
|
|
106
113
|
*
|
package/headers.js
CHANGED
|
@@ -24,6 +24,7 @@ __export(headers_exports, {
|
|
|
24
24
|
IP_HEADER_NAME: () => IP_HEADER_NAME,
|
|
25
25
|
LATITUDE_HEADER_NAME: () => LATITUDE_HEADER_NAME,
|
|
26
26
|
LONGITUDE_HEADER_NAME: () => LONGITUDE_HEADER_NAME,
|
|
27
|
+
POSTAL_CODE_HEADER_NAME: () => POSTAL_CODE_HEADER_NAME,
|
|
27
28
|
REGION_HEADER_NAME: () => REGION_HEADER_NAME,
|
|
28
29
|
REQUEST_ID_HEADER_NAME: () => REQUEST_ID_HEADER_NAME,
|
|
29
30
|
geolocation: () => geolocation,
|
|
@@ -36,6 +37,7 @@ const IP_HEADER_NAME = "x-real-ip";
|
|
|
36
37
|
const LATITUDE_HEADER_NAME = "x-vercel-ip-latitude";
|
|
37
38
|
const LONGITUDE_HEADER_NAME = "x-vercel-ip-longitude";
|
|
38
39
|
const REGION_HEADER_NAME = "x-vercel-ip-country-region";
|
|
40
|
+
const POSTAL_CODE_HEADER_NAME = "x-vercel-ip-postal-code";
|
|
39
41
|
const REQUEST_ID_HEADER_NAME = "x-vercel-id";
|
|
40
42
|
const EMOJI_FLAG_UNICODE_STARTING_POSITION = 127397;
|
|
41
43
|
function getHeader(headers, key) {
|
|
@@ -74,7 +76,8 @@ function geolocation(request) {
|
|
|
74
76
|
getHeader(request.headers, REQUEST_ID_HEADER_NAME)
|
|
75
77
|
),
|
|
76
78
|
latitude: getHeader(request.headers, LATITUDE_HEADER_NAME),
|
|
77
|
-
longitude: getHeader(request.headers, LONGITUDE_HEADER_NAME)
|
|
79
|
+
longitude: getHeader(request.headers, LONGITUDE_HEADER_NAME),
|
|
80
|
+
postalCode: getHeader(request.headers, POSTAL_CODE_HEADER_NAME)
|
|
78
81
|
};
|
|
79
82
|
}
|
|
80
83
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -85,6 +88,7 @@ function geolocation(request) {
|
|
|
85
88
|
IP_HEADER_NAME,
|
|
86
89
|
LATITUDE_HEADER_NAME,
|
|
87
90
|
LONGITUDE_HEADER_NAME,
|
|
91
|
+
POSTAL_CODE_HEADER_NAME,
|
|
88
92
|
REGION_HEADER_NAME,
|
|
89
93
|
REQUEST_ID_HEADER_NAME,
|
|
90
94
|
geolocation,
|