@vercel/functions 3.5.0 → 3.5.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/docs/README.md +7 -5
  3. package/docs/index/README.md +37 -0
  4. package/docs/index/functions/addCacheTag.md +19 -0
  5. package/docs/index/functions/attachDatabasePool.md +45 -0
  6. package/docs/index/functions/dangerouslyDeleteBySrcImage.md +23 -0
  7. package/docs/index/functions/dangerouslyDeleteByTag.md +23 -0
  8. package/docs/index/functions/geolocation.md +49 -0
  9. package/docs/index/functions/getCache.md +36 -0
  10. package/docs/index/functions/getEnv.md +291 -0
  11. package/docs/index/functions/invalidateBySrcImage.md +19 -0
  12. package/docs/index/functions/invalidateByTag.md +19 -0
  13. package/docs/index/functions/ipAddress.md +36 -0
  14. package/docs/index/functions/next.md +47 -0
  15. package/docs/index/functions/rewrite.md +66 -0
  16. package/docs/index/functions/waitUntil.md +38 -0
  17. package/docs/index/interfaces/DangerouslyDeleteOptions.md +18 -0
  18. package/docs/index/interfaces/Geo.md +90 -0
  19. package/docs/index/interfaces/PurgeApi.md +123 -0
  20. package/docs/index/interfaces/Request.md +19 -0
  21. package/docs/index/interfaces/RuntimeCache.md +133 -0
  22. package/docs/index/type-aliases/AddCacheTagApi.md +26 -0
  23. package/docs/index/variables/experimental_attachDatabasePool.md +49 -0
  24. package/docs/oidc/README.md +15 -0
  25. package/docs/oidc/functions/awsCredentialsProvider.md +24 -0
  26. package/docs/oidc/functions/getVercelOidcToken.md +58 -0
  27. package/docs/oidc/functions/getVercelOidcTokenSync.md +36 -0
  28. package/docs/oidc/interfaces/AwsCredentialsProviderInit.md +195 -0
  29. package/package.json +5 -5
  30. package/docs/interfaces/index.DangerouslyDeleteOptions.md +0 -22
  31. package/docs/interfaces/index.Geo.md +0 -115
  32. package/docs/interfaces/index.PurgeApi.md +0 -134
  33. package/docs/interfaces/index.Request.md +0 -23
  34. package/docs/interfaces/index.RuntimeCache.md +0 -131
  35. package/docs/interfaces/oidc.AwsCredentialsProviderInit.md +0 -221
  36. package/docs/modules/index.md +0 -536
  37. package/docs/modules/oidc.md +0 -133
@@ -0,0 +1,66 @@
1
+ [**@vercel/functions**](../../README.md)
2
+
3
+ ***
4
+
5
+ # Function: rewrite()
6
+
7
+ > **rewrite**(`destination`, `init?`): [`Response`](https://developer.mozilla.org/docs/Web/API/Response)
8
+
9
+ Defined in: [packages/functions/src/middleware.ts:101](https://github.com/vercel/vercel/blob/main/packages/functions/src/middleware.ts#L101)
10
+
11
+ Returns a response that rewrites the request to a different URL.
12
+
13
+ ## Parameters
14
+
15
+ ### destination
16
+
17
+ `string` \| [`URL`](https://developer.mozilla.org/docs/Web/API/URL)
18
+
19
+ new URL to rewrite the request to
20
+
21
+ ### init?
22
+
23
+ `ExtraResponseInit`
24
+
25
+ Additional options for the response
26
+
27
+ ## Returns
28
+
29
+ [`Response`](https://developer.mozilla.org/docs/Web/API/Response)
30
+
31
+ ## Examples
32
+
33
+ <caption>Rewrite all feature-flagged requests from `/:path*` to `/experimental/:path*`</caption>
34
+
35
+ ```ts
36
+ import { rewrite, next } from '@vercel/edge';
37
+
38
+ export default async function middleware(req: Request) {
39
+ const flagged = await getFlag(req, 'isExperimental');
40
+ if (flagged) {
41
+ const url = new URL(req.url);
42
+ url.pathname = `/experimental{url.pathname}`;
43
+ return rewrite(url);
44
+ }
45
+
46
+ return next();
47
+ }
48
+ ```
49
+
50
+ <caption>JWT authentication for `/api/:path*` requests</caption>
51
+
52
+ ```ts
53
+ import { rewrite, next } from '@vercel/edge';
54
+
55
+ export default function middleware(req: Request) {
56
+ const auth = checkJwt(req.headers.get('Authorization'));
57
+ if (!checkJwt) {
58
+ return rewrite(new URL('/api/error-unauthorized', req.url));
59
+ }
60
+ const url = new URL(req.url);
61
+ url.searchParams.set('_userId', auth.userId);
62
+ return rewrite(url);
63
+ }
64
+
65
+ export const config = { matcher: '/api/users/:path*' };
66
+ ```
@@ -0,0 +1,38 @@
1
+ [**@vercel/functions**](../../README.md)
2
+
3
+ ***
4
+
5
+ # Function: waitUntil()
6
+
7
+ > **waitUntil**(`promise`): `void` \| `undefined`
8
+
9
+ Defined in: [packages/functions/src/wait-until.ts:19](https://github.com/vercel/vercel/blob/main/packages/functions/src/wait-until.ts#L19)
10
+
11
+ Extends the lifetime of the request handler for the lifetime of the given [Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)
12
+
13
+ ## Parameters
14
+
15
+ ### promise
16
+
17
+ [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`unknown`\>
18
+
19
+ The promise to wait for.
20
+
21
+ ## Returns
22
+
23
+ `void` \| `undefined`
24
+
25
+ ## See
26
+
27
+ https://developer.mozilla.org/en-US/docs/Web/API/ExtendableEvent/waitUntil
28
+
29
+ ## Example
30
+
31
+ ```js
32
+ import { waitUntil } from '@vercel/functions';
33
+
34
+ export function GET(request) {
35
+ waitUntil(fetch('https://vercel.com'));
36
+ return new Response('OK');
37
+ }
38
+ ```
@@ -0,0 +1,18 @@
1
+ [**@vercel/functions**](../../README.md)
2
+
3
+ ***
4
+
5
+ # Interface: DangerouslyDeleteOptions
6
+
7
+ Defined in: [packages/functions/src/purge/types.ts:1](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/types.ts#L1)
8
+
9
+ ## Properties
10
+
11
+ ### revalidationDeadlineSeconds?
12
+
13
+ > `optional` **revalidationDeadlineSeconds?**: `number`
14
+
15
+ Defined in: [packages/functions/src/purge/types.ts:6](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/types.ts#L6)
16
+
17
+ The time in seconds for how long the stale content can be served while revalidating the new content in the background.
18
+ If none is provided, the default is 0 and the content will be deleted immediately.
@@ -0,0 +1,90 @@
1
+ [**@vercel/functions**](../../README.md)
2
+
3
+ ***
4
+
5
+ # Interface: Geo
6
+
7
+ Defined in: [packages/functions/src/headers.ts:57](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L57)
8
+
9
+ The location information of a given request.
10
+
11
+ ## Properties
12
+
13
+ ### city?
14
+
15
+ > `optional` **city?**: `string`
16
+
17
+ Defined in: [packages/functions/src/headers.ts:59](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L59)
18
+
19
+ The city that the request originated from.
20
+
21
+ ***
22
+
23
+ ### country?
24
+
25
+ > `optional` **country?**: `string`
26
+
27
+ Defined in: [packages/functions/src/headers.ts:62](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L62)
28
+
29
+ The country that the request originated from.
30
+
31
+ ***
32
+
33
+ ### countryRegion?
34
+
35
+ > `optional` **countryRegion?**: `string`
36
+
37
+ Defined in: [packages/functions/src/headers.ts:73](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L73)
38
+
39
+ The region part of the ISO 3166-2 code of the client IP.
40
+ See [docs](https://vercel.com/docs/concepts/edge-network/headers#x-vercel-ip-country-region).
41
+
42
+ ***
43
+
44
+ ### flag?
45
+
46
+ > `optional` **flag?**: `string`
47
+
48
+ Defined in: [packages/functions/src/headers.ts:65](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L65)
49
+
50
+ The flag emoji for the country the request originated from.
51
+
52
+ ***
53
+
54
+ ### latitude?
55
+
56
+ > `optional` **latitude?**: `string`
57
+
58
+ Defined in: [packages/functions/src/headers.ts:76](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L76)
59
+
60
+ The latitude of the client.
61
+
62
+ ***
63
+
64
+ ### longitude?
65
+
66
+ > `optional` **longitude?**: `string`
67
+
68
+ Defined in: [packages/functions/src/headers.ts:79](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L79)
69
+
70
+ The longitude of the client.
71
+
72
+ ***
73
+
74
+ ### postalCode?
75
+
76
+ > `optional` **postalCode?**: `string`
77
+
78
+ Defined in: [packages/functions/src/headers.ts:82](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L82)
79
+
80
+ The postal code of the client
81
+
82
+ ***
83
+
84
+ ### region?
85
+
86
+ > `optional` **region?**: `string`
87
+
88
+ Defined in: [packages/functions/src/headers.ts:68](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L68)
89
+
90
+ The [Vercel Edge Network region](https://vercel.com/docs/concepts/edge-network/regions) that received the request.
@@ -0,0 +1,123 @@
1
+ [**@vercel/functions**](../../README.md)
2
+
3
+ ***
4
+
5
+ # Interface: PurgeApi
6
+
7
+ Defined in: [packages/functions/src/purge/types.ts:12](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/types.ts#L12)
8
+
9
+ Vercel Cache Purge APIs.
10
+
11
+ ## Properties
12
+
13
+ ### dangerouslyDeleteBySrcImage
14
+
15
+ > **dangerouslyDeleteBySrcImage**: (`src`, `options?`) => [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
16
+
17
+ Defined in: [packages/functions/src/purge/types.ts:54](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/types.ts#L54)
18
+
19
+ Given a source image, delete all of its transformed images after a specified revalidation deadline.
20
+ If accessed prior to the revalidation deadline, the stale transformed image will be served and a background task will be triggered. After the revalidation deadline is reached, the transformed image will be deleted.
21
+ The default revalidation deadline is 0 and the content will be deleted immediately.
22
+
23
+ #### Parameters
24
+
25
+ ##### src
26
+
27
+ `string` \| `string`[]
28
+
29
+ The source image to delete.
30
+
31
+ ##### options?
32
+
33
+ [`DangerouslyDeleteOptions`](DangerouslyDeleteOptions.md)
34
+
35
+ The options for the delete that specify the revalidation deadline.
36
+
37
+ #### Returns
38
+
39
+ [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
40
+
41
+ A promise that resolves when the delete is complete.
42
+
43
+ ***
44
+
45
+ ### dangerouslyDeleteByTag
46
+
47
+ > **dangerouslyDeleteByTag**: (`tag`, `options?`) => [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
48
+
49
+ Defined in: [packages/functions/src/purge/types.ts:31](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/types.ts#L31)
50
+
51
+ Delete all content associated with a tag or tags after a specified revalidation deadline.
52
+ If accessed prior to the revalidation deadline, the stale content will be served and a background revalidation will be triggered. After the revalidation deadline is reached, the content will be deleted.
53
+ The default revalidation deadline is 0 and the content will be deleted immediately.
54
+
55
+ #### Parameters
56
+
57
+ ##### tag
58
+
59
+ `string` \| `string`[]
60
+
61
+ The tag or tags to delete.
62
+
63
+ ##### options?
64
+
65
+ [`DangerouslyDeleteOptions`](DangerouslyDeleteOptions.md)
66
+
67
+ The options for the delete that specify the revalidation deadline.
68
+
69
+ #### Returns
70
+
71
+ [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
72
+
73
+ A promise that resolves when the delete is complete.
74
+
75
+ ***
76
+
77
+ ### invalidateBySrcImage
78
+
79
+ > **invalidateBySrcImage**: (`src`) => [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
80
+
81
+ Defined in: [packages/functions/src/purge/types.ts:43](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/types.ts#L43)
82
+
83
+ Given a source image, invalidate all of its transformed images by marking them as stale.
84
+ On the next access, the stale transformed image will be served and a background task will transform the source image.
85
+
86
+ #### Parameters
87
+
88
+ ##### src
89
+
90
+ `string` \| `string`[]
91
+
92
+ The source image to invalidate.
93
+
94
+ #### Returns
95
+
96
+ [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
97
+
98
+ A promise that resolves when the invalidate is complete.
99
+
100
+ ***
101
+
102
+ ### invalidateByTag
103
+
104
+ > **invalidateByTag**: (`tag`) => [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
105
+
106
+ Defined in: [packages/functions/src/purge/types.ts:20](https://github.com/vercel/vercel/blob/main/packages/functions/src/purge/types.ts#L20)
107
+
108
+ Invalidate all content associated with a tag or tags by marking them as stale.
109
+ On the next access to content associated with any of the tags, the stale content will be served and a background revalidation will be triggered.
110
+
111
+ #### Parameters
112
+
113
+ ##### tag
114
+
115
+ `string` \| `string`[]
116
+
117
+ The tag or tags to invalidate.
118
+
119
+ #### Returns
120
+
121
+ [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
122
+
123
+ A promise that resolves when the invalidate is complete.
@@ -0,0 +1,19 @@
1
+ [**@vercel/functions**](../../README.md)
2
+
3
+ ***
4
+
5
+ # Interface: Request
6
+
7
+ Defined in: [packages/functions/src/headers.ts:48](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L48)
8
+
9
+ We define a new type so this function can be reused with the global `Request`, `node-fetch` and other types.
10
+
11
+ ## Properties
12
+
13
+ ### headers
14
+
15
+ > **headers**: `Headers`
16
+
17
+ Defined in: [packages/functions/src/headers.ts:52](https://github.com/vercel/vercel/blob/main/packages/functions/src/headers.ts#L52)
18
+
19
+ Represents the headers of a request.
@@ -0,0 +1,133 @@
1
+ [**@vercel/functions**](../../README.md)
2
+
3
+ ***
4
+
5
+ # Interface: RuntimeCache
6
+
7
+ Defined in: [packages/functions/src/cache/types.ts:4](https://github.com/vercel/vercel/blob/main/packages/functions/src/cache/types.ts#L4)
8
+
9
+ Interface representing the runtime cache.
10
+
11
+ ## Properties
12
+
13
+ ### delete
14
+
15
+ > **delete**: (`key`) => [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
16
+
17
+ Defined in: [packages/functions/src/cache/types.ts:11](https://github.com/vercel/vercel/blob/main/packages/functions/src/cache/types.ts#L11)
18
+
19
+ Deletes a value from the cache.
20
+
21
+ #### Parameters
22
+
23
+ ##### key
24
+
25
+ `string`
26
+
27
+ The key of the value to delete.
28
+
29
+ #### Returns
30
+
31
+ [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
32
+
33
+ A promise that resolves when the value is deleted.
34
+
35
+ ***
36
+
37
+ ### expireTag
38
+
39
+ > **expireTag**: (`tag`) => [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
40
+
41
+ Defined in: [packages/functions/src/cache/types.ts:44](https://github.com/vercel/vercel/blob/main/packages/functions/src/cache/types.ts#L44)
42
+
43
+ Expires cache entries by tag.
44
+
45
+ #### Parameters
46
+
47
+ ##### tag
48
+
49
+ `string` \| `string`[]
50
+
51
+ The tag or tags of the cache entries to expire.
52
+
53
+ #### Returns
54
+
55
+ [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
56
+
57
+ A promise that resolves when the cache entries expiration request is received.
58
+
59
+ ***
60
+
61
+ ### get
62
+
63
+ > **get**: (`key`) => [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`unknown`\>
64
+
65
+ Defined in: [packages/functions/src/cache/types.ts:19](https://github.com/vercel/vercel/blob/main/packages/functions/src/cache/types.ts#L19)
66
+
67
+ Retrieves a value from the cache.
68
+
69
+ #### Parameters
70
+
71
+ ##### key
72
+
73
+ `string`
74
+
75
+ The key of the value to retrieve.
76
+
77
+ #### Returns
78
+
79
+ [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`unknown`\>
80
+
81
+ A promise that resolves to the value, or null if not found.
82
+
83
+ ***
84
+
85
+ ### set
86
+
87
+ > **set**: (`key`, `value`, `options?`) => [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
88
+
89
+ Defined in: [packages/functions/src/cache/types.ts:32](https://github.com/vercel/vercel/blob/main/packages/functions/src/cache/types.ts#L32)
90
+
91
+ Sets a value in the cache.
92
+
93
+ #### Parameters
94
+
95
+ ##### key
96
+
97
+ `string`
98
+
99
+ The key of the value to set.
100
+
101
+ ##### value
102
+
103
+ `unknown`
104
+
105
+ The value to set.
106
+
107
+ ##### options?
108
+
109
+ Optional settings for the cache entry.
110
+
111
+ ###### name?
112
+
113
+ `string`
114
+
115
+ Optional user-friendly name for the cache entry used for o11y.
116
+
117
+ ###### tags?
118
+
119
+ `string`[]
120
+
121
+ Optional tags to associate with the cache entry.
122
+
123
+ ###### ttl?
124
+
125
+ `number`
126
+
127
+ Optional time-to-live for the cache entry, in seconds.
128
+
129
+ #### Returns
130
+
131
+ [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
132
+
133
+ A promise that resolves when the value is set.
@@ -0,0 +1,26 @@
1
+ [**@vercel/functions**](../../README.md)
2
+
3
+ ***
4
+
5
+ # Type Alias: AddCacheTagApi
6
+
7
+ > **AddCacheTagApi** = (`tag`) => [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
8
+
9
+ Defined in: [packages/functions/src/addcachetag/types.ts:8](https://github.com/vercel/vercel/blob/main/packages/functions/src/addcachetag/types.ts#L8)
10
+
11
+ Vercel AddCacheTag API.
12
+ A function that adds one or more tags to the cache content.
13
+
14
+ ## Parameters
15
+
16
+ ### tag
17
+
18
+ `string` \| `string`[]
19
+
20
+ One or more tags to add to the cache content.
21
+
22
+ ## Returns
23
+
24
+ [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
25
+
26
+ A promise that resolves when the tag is added.
@@ -0,0 +1,49 @@
1
+ [**@vercel/functions**](../../README.md)
2
+
3
+ ***
4
+
5
+ # ~~Variable: experimental\_attachDatabasePool~~
6
+
7
+ > `const` **experimental\_attachDatabasePool**: (`dbPool`) => `void` = `attachDatabasePool`
8
+
9
+ Defined in: [packages/functions/src/db-connections/index.ts:323](https://github.com/vercel/vercel/blob/main/packages/functions/src/db-connections/index.ts#L323)
10
+
11
+ **`Experimental`**
12
+
13
+ Call this function right after creating a database pool with the database pool object
14
+ as argument.
15
+ This ensures that the current function instance stays alive long enough for
16
+ idle database connections to be removed from the pool.
17
+
18
+ ## Parameters
19
+
20
+ ### dbPool
21
+
22
+ `DbPool`
23
+
24
+ The database pool object. The supported pool types are:
25
+ - PostgreSQL (pg)
26
+ - MySQL2
27
+ - MariaDB
28
+ - MongoDB
29
+ - Redis (ioredis)
30
+ - Cassandra (cassandra-driver)
31
+ - OTHER: This method uses duck-typing to detect the pool type. Respectively you can
32
+ pass in any object with a compatible interface.
33
+
34
+ ## Returns
35
+
36
+ `void`
37
+
38
+ ## Example
39
+
40
+ ```ts
41
+ const pgPool = new Pool({
42
+ connectionString: process.env.DATABASE_URL,
43
+ });
44
+ attachDatabasePool(pgPool);
45
+ ```
46
+
47
+ ## Deprecated
48
+
49
+ Use attachDatabasePool instead.
@@ -0,0 +1,15 @@
1
+ [**@vercel/functions**](../README.md)
2
+
3
+ ---
4
+
5
+ # oidc
6
+
7
+ ## Interfaces
8
+
9
+ - [AwsCredentialsProviderInit](interfaces/AwsCredentialsProviderInit.md)
10
+
11
+ ## Functions
12
+
13
+ - [~~awsCredentialsProvider~~](functions/awsCredentialsProvider.md)
14
+ - [~~getVercelOidcToken~~](functions/getVercelOidcToken.md)
15
+ - [~~getVercelOidcTokenSync~~](functions/getVercelOidcTokenSync.md)
@@ -0,0 +1,24 @@
1
+ [**@vercel/functions**](../../README.md)
2
+
3
+ ***
4
+
5
+ # ~~Function: awsCredentialsProvider()~~
6
+
7
+ > **awsCredentialsProvider**(`init`): `AwsCredentialIdentityProvider`
8
+
9
+ Defined in: [packages/functions/src/oidc/aws-credentials-provider.ts:70](https://github.com/vercel/vercel/blob/main/packages/functions/src/oidc/aws-credentials-provider.ts#L70)
10
+
11
+ ## Parameters
12
+
13
+ ### init
14
+
15
+ [`AwsCredentialsProviderInit`](../interfaces/AwsCredentialsProviderInit.md)
16
+
17
+ ## Returns
18
+
19
+ `AwsCredentialIdentityProvider`
20
+
21
+ ## Deprecated
22
+
23
+ Use @vercel/oidc-aws-credentials-provider instead
24
+ AWS authentication for Vercel Functions
@@ -0,0 +1,58 @@
1
+ [**@vercel/functions**](../../README.md)
2
+
3
+ ***
4
+
5
+ # ~~Function: getVercelOidcToken()~~
6
+
7
+ > **getVercelOidcToken**(`options?`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`string`\>
8
+
9
+ Defined in: packages/oidc/dist/get-vercel-oidc-token.d.ts:60
10
+
11
+ Gets the current OIDC token from the request context or the environment variable.
12
+
13
+ Do not cache this value, as it is subject to change in production!
14
+
15
+ This function is used to retrieve the OIDC token from the request context or the environment variable.
16
+ 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.
17
+
18
+ Unlike the `getVercelOidcTokenSync` function, this function will refresh the token if it is expired in a development environment.
19
+
20
+ ## Parameters
21
+
22
+ ### options?
23
+
24
+ `GetVercelOidcTokenOptions`
25
+
26
+ Optional configuration for token retrieval.
27
+
28
+ ## Returns
29
+
30
+ [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`string`\>
31
+
32
+ A promise that resolves to the OIDC token.
33
+
34
+ ## Throws
35
+
36
+ If the `x-vercel-oidc-token` header is missing from the request context and the environment variable `VERCEL_OIDC_TOKEN` is not set. If the token
37
+ is expired in a development environment, will also throw an error if the token cannot be refreshed: no CLI credentials are available, CLI credentials are expired, no project configuration is available
38
+ or the token refresh request fails.
39
+
40
+ ## Examples
41
+
42
+ ```js
43
+ // Using the OIDC token
44
+ getVercelOidcToken().then((token) => {
45
+ console.log('OIDC Token:', token);
46
+ }).catch((error) => {
47
+ console.error('Error:', error.message);
48
+ });
49
+ ```
50
+
51
+ ```js
52
+ // Using the OIDC token with explicit team and project (supports IDs and slugs)
53
+ getVercelOidcToken({ team: 'my-team', project: 'my-project' }).then((token) => {
54
+ console.log('OIDC Token:', token);
55
+ }).catch((error) => {
56
+ console.error('Error:', error.message);
57
+ });
58
+ ```