@vercel/functions 2.0.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/cache/index.d.ts +1 -1
- package/cache/index.js +3 -3
- package/docs/interfaces/oidc.AwsCredentialsProviderInit.md +4 -4
- package/docs/modules/index.md +36 -36
- package/docs/modules/oidc.md +4 -3
- package/index.d.ts +1 -1
- package/index.js +2 -2
- package/oidc/get-vercel-oidc-token.d.ts +3 -2
- package/oidc/get-vercel-oidc-token.js +1 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @vercel/functions
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Change the load order of the OIDC token ([#13337](https://github.com/vercel/vercel/pull/13337))
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Rename getRuntimeCache to getCache ([#13325](https://github.com/vercel/vercel/pull/13325))
|
|
12
|
+
|
|
3
13
|
## 2.0.3
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
package/cache/index.d.ts
CHANGED
|
@@ -13,4 +13,4 @@ import { CacheOptions, RuntimeCache } from './types';
|
|
|
13
13
|
* @returns An instance of the Vercel Runtime Cache.
|
|
14
14
|
* @throws {Error} If no cache is available in the context and `InMemoryCache` cannot be created.
|
|
15
15
|
*/
|
|
16
|
-
export declare const
|
|
16
|
+
export declare const getCache: (cacheOptions?: CacheOptions) => RuntimeCache;
|
package/cache/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var cache_exports = {};
|
|
20
20
|
__export(cache_exports, {
|
|
21
|
-
|
|
21
|
+
getCache: () => getCache
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(cache_exports);
|
|
24
24
|
var import_get_context = require("../get-context");
|
|
@@ -32,7 +32,7 @@ const defaultKeyHashFunction = (key) => {
|
|
|
32
32
|
};
|
|
33
33
|
const defaultNamespaceSeparator = "$";
|
|
34
34
|
let inMemoryCacheInstance = null;
|
|
35
|
-
const
|
|
35
|
+
const getCache = (cacheOptions) => {
|
|
36
36
|
let cache;
|
|
37
37
|
if ((0, import_get_context.getContext)().cache) {
|
|
38
38
|
cache = (0, import_get_context.getContext)().cache;
|
|
@@ -68,5 +68,5 @@ const getRuntimeCache = (cacheOptions) => {
|
|
|
68
68
|
};
|
|
69
69
|
// Annotate the CommonJS export names for ESM import in node:
|
|
70
70
|
0 && (module.exports = {
|
|
71
|
-
|
|
71
|
+
getCache
|
|
72
72
|
});
|
|
@@ -40,7 +40,7 @@ Omit.clientConfig
|
|
|
40
40
|
|
|
41
41
|
#### Defined in
|
|
42
42
|
|
|
43
|
-
node*modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.609.0*@aws-sdk+client-sts@3.
|
|
43
|
+
node*modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.609.0*@aws-sdk+client-sts@3.806.0/node_modules/@aws-sdk/credential-provider-web-identity/dist-types/fromWebToken.d.ts:135
|
|
44
44
|
|
|
45
45
|
---
|
|
46
46
|
|
|
@@ -56,7 +56,7 @@ Omit.clientPlugins
|
|
|
56
56
|
|
|
57
57
|
#### Defined in
|
|
58
58
|
|
|
59
|
-
node*modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.609.0*@aws-sdk+client-sts@3.
|
|
59
|
+
node*modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.609.0*@aws-sdk+client-sts@3.806.0/node_modules/@aws-sdk/credential-provider-web-identity/dist-types/fromWebToken.d.ts:139
|
|
60
60
|
|
|
61
61
|
---
|
|
62
62
|
|
|
@@ -202,7 +202,7 @@ Omit.roleAssumerWithWebIdentity
|
|
|
202
202
|
|
|
203
203
|
#### Defined in
|
|
204
204
|
|
|
205
|
-
node*modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.609.0*@aws-sdk+client-sts@3.
|
|
205
|
+
node*modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.609.0*@aws-sdk+client-sts@3.806.0/node_modules/@aws-sdk/credential-provider-web-identity/dist-types/fromWebToken.d.ts:130
|
|
206
206
|
|
|
207
207
|
---
|
|
208
208
|
|
|
@@ -218,4 +218,4 @@ Omit.roleSessionName
|
|
|
218
218
|
|
|
219
219
|
#### Defined in
|
|
220
220
|
|
|
221
|
-
node*modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.609.0*@aws-sdk+client-sts@3.
|
|
221
|
+
node*modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.609.0*@aws-sdk+client-sts@3.806.0/node_modules/@aws-sdk/credential-provider-web-identity/dist-types/fromWebToken.d.ts:123
|
package/docs/modules/index.md
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
### Functions
|
|
12
12
|
|
|
13
13
|
- [geolocation](index.md#geolocation)
|
|
14
|
+
- [getCache](index.md#getcache)
|
|
14
15
|
- [getEnv](index.md#getenv)
|
|
15
|
-
- [getRuntimeCache](index.md#getruntimecache)
|
|
16
16
|
- [ipAddress](index.md#ipaddress)
|
|
17
17
|
- [next](index.md#next)
|
|
18
18
|
- [rewrite](index.md#rewrite)
|
|
@@ -68,6 +68,41 @@ The location information of the request, in this way:
|
|
|
68
68
|
|
|
69
69
|
---
|
|
70
70
|
|
|
71
|
+
### getCache
|
|
72
|
+
|
|
73
|
+
▸ **getCache**(`cacheOptions?`): [`RuntimeCache`](../interfaces/index.RuntimeCache.md)
|
|
74
|
+
|
|
75
|
+
Retrieves the Vercel Runtime Cache.
|
|
76
|
+
|
|
77
|
+
Keys are hashed to ensure they are unique and consistent. The hashing function can be overridden by providing a custom
|
|
78
|
+
`keyHashFunction` in the `cacheOptions` parameter.
|
|
79
|
+
|
|
80
|
+
To specify a namespace for the cache keys, you can pass a `namespace` option in the `cacheOptions` parameter. If
|
|
81
|
+
a namespace is provided, the cache keys will be prefixed with the namespace followed by a separator (default is `$`). The
|
|
82
|
+
namespaceSeparator can also be customized using the `namespaceSeparator` option.
|
|
83
|
+
|
|
84
|
+
**`Throws`**
|
|
85
|
+
|
|
86
|
+
If no cache is available in the context and `InMemoryCache` cannot be created.
|
|
87
|
+
|
|
88
|
+
#### Parameters
|
|
89
|
+
|
|
90
|
+
| Name | Type | Description |
|
|
91
|
+
| :-------------- | :------------- | :------------------------------------ |
|
|
92
|
+
| `cacheOptions?` | `CacheOptions` | Optional configuration for the cache. |
|
|
93
|
+
|
|
94
|
+
#### Returns
|
|
95
|
+
|
|
96
|
+
[`RuntimeCache`](../interfaces/index.RuntimeCache.md)
|
|
97
|
+
|
|
98
|
+
An instance of the Vercel Runtime Cache.
|
|
99
|
+
|
|
100
|
+
#### Defined in
|
|
101
|
+
|
|
102
|
+
[packages/functions/src/cache/index.ts:32](https://github.com/vercel/vercel/blob/main/packages/functions/src/cache/index.ts#L32)
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
71
106
|
### getEnv
|
|
72
107
|
|
|
73
108
|
▸ **getEnv**(`env?`): `Object`
|
|
@@ -118,41 +153,6 @@ https://vercel.com/docs/projects/environment-variables/system-environment-variab
|
|
|
118
153
|
|
|
119
154
|
---
|
|
120
155
|
|
|
121
|
-
### getRuntimeCache
|
|
122
|
-
|
|
123
|
-
▸ **getRuntimeCache**(`cacheOptions?`): [`RuntimeCache`](../interfaces/index.RuntimeCache.md)
|
|
124
|
-
|
|
125
|
-
Retrieves the Vercel Runtime Cache.
|
|
126
|
-
|
|
127
|
-
Keys are hashed to ensure they are unique and consistent. The hashing function can be overridden by providing a custom
|
|
128
|
-
`keyHashFunction` in the `cacheOptions` parameter.
|
|
129
|
-
|
|
130
|
-
To specify a namespace for the cache keys, you can pass a `namespace` option in the `cacheOptions` parameter. If
|
|
131
|
-
a namespace is provided, the cache keys will be prefixed with the namespace followed by a separator (default is `$`). The
|
|
132
|
-
namespaceSeparator can also be customized using the `namespaceSeparator` option.
|
|
133
|
-
|
|
134
|
-
**`Throws`**
|
|
135
|
-
|
|
136
|
-
If no cache is available in the context and `InMemoryCache` cannot be created.
|
|
137
|
-
|
|
138
|
-
#### Parameters
|
|
139
|
-
|
|
140
|
-
| Name | Type | Description |
|
|
141
|
-
| :-------------- | :------------- | :------------------------------------ |
|
|
142
|
-
| `cacheOptions?` | `CacheOptions` | Optional configuration for the cache. |
|
|
143
|
-
|
|
144
|
-
#### Returns
|
|
145
|
-
|
|
146
|
-
[`RuntimeCache`](../interfaces/index.RuntimeCache.md)
|
|
147
|
-
|
|
148
|
-
An instance of the Vercel Runtime Cache.
|
|
149
|
-
|
|
150
|
-
#### Defined in
|
|
151
|
-
|
|
152
|
-
[packages/functions/src/cache/index.ts:32](https://github.com/vercel/vercel/blob/main/packages/functions/src/cache/index.ts#L32)
|
|
153
|
-
|
|
154
|
-
---
|
|
155
|
-
|
|
156
156
|
### ipAddress
|
|
157
157
|
|
|
158
158
|
▸ **ipAddress**(`input`): `string` \| `undefined`
|
package/docs/modules/oidc.md
CHANGED
|
@@ -66,8 +66,9 @@ A function that provides AWS credentials.
|
|
|
66
66
|
|
|
67
67
|
Returns the OIDC token from the request context or the environment variable.
|
|
68
68
|
|
|
69
|
-
This function
|
|
70
|
-
`
|
|
69
|
+
This function is used to retrieve the OIDC token from the request context or the environment variable.
|
|
70
|
+
It checks for the `x-vercel-oidc-token` header in the request context and falls back to the `VERCEL_OIDC_TOKEN` environment variable if the header is not present.
|
|
71
|
+
|
|
71
72
|
context headers.
|
|
72
73
|
|
|
73
74
|
**`Throws`**
|
|
@@ -95,4 +96,4 @@ A promise that resolves to the OIDC token.
|
|
|
95
96
|
|
|
96
97
|
#### Defined in
|
|
97
98
|
|
|
98
|
-
[packages/functions/src/oidc/get-vercel-oidc-token.ts:
|
|
99
|
+
[packages/functions/src/oidc/get-vercel-oidc-token.ts:25](https://github.com/vercel/vercel/blob/main/packages/functions/src/oidc/get-vercel-oidc-token.ts#L25)
|
package/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export { geolocation, ipAddress } from './headers';
|
|
|
3
3
|
export { getEnv } from './get-env';
|
|
4
4
|
export { waitUntil } from './wait-until';
|
|
5
5
|
export { rewrite, next } from './middleware';
|
|
6
|
-
export {
|
|
6
|
+
export { getCache } from './cache';
|
|
7
7
|
export type { RuntimeCache } from './cache/types';
|
package/index.js
CHANGED
|
@@ -19,8 +19,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var src_exports = {};
|
|
20
20
|
__export(src_exports, {
|
|
21
21
|
geolocation: () => import_headers.geolocation,
|
|
22
|
+
getCache: () => import_cache.getCache,
|
|
22
23
|
getEnv: () => import_get_env.getEnv,
|
|
23
|
-
getRuntimeCache: () => import_cache.getRuntimeCache,
|
|
24
24
|
ipAddress: () => import_headers.ipAddress,
|
|
25
25
|
next: () => import_middleware.next,
|
|
26
26
|
rewrite: () => import_middleware.rewrite,
|
|
@@ -35,8 +35,8 @@ var import_cache = require("./cache");
|
|
|
35
35
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
36
|
0 && (module.exports = {
|
|
37
37
|
geolocation,
|
|
38
|
+
getCache,
|
|
38
39
|
getEnv,
|
|
39
|
-
getRuntimeCache,
|
|
40
40
|
ipAddress,
|
|
41
41
|
next,
|
|
42
42
|
rewrite,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns the OIDC token from the request context or the environment variable.
|
|
3
3
|
*
|
|
4
|
-
* This function
|
|
5
|
-
* `
|
|
4
|
+
* This function is used to retrieve the OIDC token from the request context or the environment variable.
|
|
5
|
+
* It checks for the `x-vercel-oidc-token` header in the request context and falls back to the `VERCEL_OIDC_TOKEN` environment variable if the header is not present.
|
|
6
|
+
*
|
|
6
7
|
* context headers.
|
|
7
8
|
*
|
|
8
9
|
* @returns {Promise<string>} A promise that resolves to the OIDC token.
|
|
@@ -23,9 +23,7 @@ __export(get_vercel_oidc_token_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(get_vercel_oidc_token_exports);
|
|
24
24
|
var import_get_context = require("../get-context");
|
|
25
25
|
async function getVercelOidcToken() {
|
|
26
|
-
|
|
27
|
-
return process.env.VERCEL_OIDC_TOKEN;
|
|
28
|
-
const token = (0, import_get_context.getContext)().headers?.["x-vercel-oidc-token"];
|
|
26
|
+
const token = (0, import_get_context.getContext)().headers?.["x-vercel-oidc-token"] ?? process.env.VERCEL_OIDC_TOKEN;
|
|
29
27
|
if (!token) {
|
|
30
28
|
throw new Error(
|
|
31
29
|
`The 'x-vercel-oidc-token' header is missing from the request. Do you have the OIDC option enabled in the Vercel project settings?`
|