@vercel/functions 2.2.8 → 2.2.12

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 CHANGED
@@ -1,5 +1,35 @@
1
1
  # @vercel/functions
2
2
 
3
+ ## 2.2.12
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix package versions for oidc-aws-credentials-provider, vercel/functions, and publish the next version of vercel/oidc ([#13765](https://github.com/vercel/vercel/pull/13765))
8
+
9
+ - Updated dependencies [[`2f5244647dc7d2c81bb688035952d4d45b6d707e`](https://github.com/vercel/vercel/commit/2f5244647dc7d2c81bb688035952d4d45b6d707e)]:
10
+ - @vercel/oidc@2.0.1
11
+
12
+ ## 2.2.11
13
+
14
+ ### Patch Changes
15
+
16
+ - Fix dependency ([#13726](https://github.com/vercel/vercel/pull/13726))
17
+
18
+ ## 2.2.10
19
+
20
+ ### Patch Changes
21
+
22
+ - Update dependency ([#13722](https://github.com/vercel/vercel/pull/13722))
23
+
24
+ ## 2.2.9
25
+
26
+ ### Patch Changes
27
+
28
+ - Extract AWS dynamic import to async loader with error handling ([#13660](https://github.com/vercel/vercel/pull/13660))
29
+
30
+ - Updated dependencies [[`a133e534e7dfd785beeeb0dcafed8d2c991e9f11`](https://github.com/vercel/vercel/commit/a133e534e7dfd785beeeb0dcafed8d2c991e9f11)]:
31
+ - @vercel/oidc@2.1.0
32
+
3
33
  ## 2.2.8
4
34
 
5
35
  ### Patch Changes
@@ -18,46 +18,19 @@
18
18
 
19
19
  ▸ **awsCredentialsProvider**(`init`): `AwsCredentialIdentityProvider`
20
20
 
21
- Obtains the Vercel OIDC token and creates an AWS credential provider function
22
- that gets AWS credentials by calling STS AssumeRoleWithWebIdentity API.
23
-
24
- **`Example`**
25
-
26
- ```js
27
- import * as s3 from '@aws-sdk/client-s3';
28
- import { awsCredentialsProvider } from '@vercel/functions/oidc';
29
-
30
- const s3Client = new s3.S3Client({
31
- credentials: awsCredentialsProvider({
32
- roleArn: 'arn:aws:iam::1234567890:role/RoleA',
33
- clientConfig: { region: 'us-west-2' },
34
- clientPlugins: [addFooHeadersPlugin],
35
- roleAssumerWithWebIdentity: customRoleAssumer,
36
- roleSessionName: 'session_123',
37
- providerId: 'graph.facebook.com',
38
- policyArns: [{ arn: 'arn:aws:iam::1234567890:policy/SomePolicy' }],
39
- policy:
40
- '{"Statement": [{"Effect": "Allow", "Action": "s3:ListBucket", "Resource": "*"}]}',
41
- durationSeconds: 7200,
42
- }),
43
- });
44
- ```
45
-
46
21
  #### Parameters
47
22
 
48
- | Name | Type | Description |
49
- | :----- | :------------------------------------------------------------------------------- | :------------------------- |
50
- | `init` | [`AwsCredentialsProviderInit`](../interfaces/oidc.AwsCredentialsProviderInit.md) | The initialization object. |
23
+ | Name | Type |
24
+ | :----- | :------------------------------------------------------------------------------- |
25
+ | `init` | [`AwsCredentialsProviderInit`](../interfaces/oidc.AwsCredentialsProviderInit.md) |
51
26
 
52
27
  #### Returns
53
28
 
54
29
  `AwsCredentialIdentityProvider`
55
30
 
56
- A function that provides AWS credentials.
57
-
58
31
  #### Defined in
59
32
 
60
- [packages/functions/src/oidc/aws-credentials-provider.ts:60](https://github.com/vercel/vercel/blob/main/packages/functions/src/oidc/aws-credentials-provider.ts#L60)
33
+ [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)
61
34
 
62
35
  ---
63
36
 
@@ -72,9 +45,13 @@ Do not cache this value, as it is subject to change in production!
72
45
  This function is used to retrieve the OIDC token from the request context or the environment variable.
73
46
  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.
74
47
 
48
+ Unlike the `getVercelOidcTokenSync` function, this function will refresh the token if it is expired in a development environment.
49
+
75
50
  **`Throws`**
76
51
 
77
- If the `x-vercel-oidc-token` header is missing from the request context and the environment variable `VERCEL_OIDC_TOKEN` is not set.
52
+ 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
53
+ 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
54
+ or the token refresh request fails.
78
55
 
79
56
  **`Example`**
80
57
 
@@ -97,7 +74,7 @@ A promise that resolves to the OIDC token.
97
74
 
98
75
  #### Defined in
99
76
 
100
- packages/oidc/dist/get-vercel-oidc-token.d.ts:23
77
+ packages/oidc/dist/get-vercel-oidc-token.d.ts:27
101
78
 
102
79
  ---
103
80
 
@@ -112,6 +89,8 @@ Do not cache this value, as it is subject to change in production!
112
89
  This function is used to retrieve the OIDC token from the request context or the environment variable.
113
90
  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.
114
91
 
92
+ This function will not refresh the token if it is expired. For refreshing the token, use the @{link getVercelOidcToken} function.
93
+
115
94
  **`Throws`**
116
95
 
117
96
  If the `x-vercel-oidc-token` header is missing from the request context and the environment variable `VERCEL_OIDC_TOKEN` is not set.
@@ -132,4 +111,4 @@ The OIDC token.
132
111
 
133
112
  #### Defined in
134
113
 
135
- packages/oidc/dist/get-vercel-oidc-token.d.ts:43
114
+ packages/oidc/dist/get-vercel-oidc-token.d.ts:49
@@ -17,41 +17,4 @@ import type { FromWebTokenInit } from '@aws-sdk/credential-provider-web-identity
17
17
  export interface AwsCredentialsProviderInit// eslint-disable-line @typescript-eslint/no-empty-interface
18
18
  extends Omit<FromWebTokenInit, 'webIdentityToken'> {
19
19
  }
20
- /**
21
- * Obtains the Vercel OIDC token and creates an AWS credential provider function
22
- * that gets AWS credentials by calling STS AssumeRoleWithWebIdentity API.
23
- *
24
- * @param {AwsCredentialsProviderInit} init - The initialization object.
25
- * @param {string} init.roleArn - ARN of the role that the caller is assuming.
26
- * @param {Object} [init.clientConfig] - Custom STS client configurations overriding the default ones.
27
- * @param {Array} [init.clientPlugins] - Custom STS client middleware plugin to modify the client default behavior.
28
- * @param {Function} [init.roleAssumerWithWebIdentity] - A function that assumes a role with web identity and returns a promise fulfilled with credentials for the assumed role.
29
- * @param {string} [init.roleSessionName] - An identifier for the assumed role session.
30
- * @param {string} [init.providerId] - The fully qualified host component of the domain name of the identity provider.
31
- * @param {Array} [init.policyArns] - ARNs of the IAM managed policies that you want to use as managed session policies.
32
- * @param {string} [init.policy] - An IAM policy in JSON format that you want to use as an inline session policy.
33
- * @param {number} [init.durationSeconds=3600] - The duration, in seconds, of the role session. Defaults to 3600 seconds.
34
- *
35
- * @returns {AwsCredentialIdentityProvider} A function that provides AWS credentials.
36
- *
37
- * @example
38
- * ```js
39
- * import * as s3 from '@aws-sdk/client-s3';
40
- * import { awsCredentialsProvider } from '@vercel/functions/oidc';
41
- *
42
- * const s3Client = new s3.S3Client({
43
- * credentials: awsCredentialsProvider({
44
- * roleArn: "arn:aws:iam::1234567890:role/RoleA",
45
- * clientConfig: { region: "us-west-2" },
46
- * clientPlugins: [addFooHeadersPlugin],
47
- * roleAssumerWithWebIdentity: customRoleAssumer,
48
- * roleSessionName: "session_123",
49
- * providerId: "graph.facebook.com",
50
- * policyArns: [{ arn: "arn:aws:iam::1234567890:policy/SomePolicy" }],
51
- * policy: "{\"Statement\": [{\"Effect\": \"Allow\", \"Action\": \"s3:ListBucket\", \"Resource\": \"*\"}]}",
52
- * durationSeconds: 7200
53
- * }),
54
- * });
55
- * ```
56
- */
57
20
  export declare function awsCredentialsProvider(init: AwsCredentialsProviderInit): AwsCredentialIdentityProvider;
@@ -32,9 +32,18 @@ __export(aws_credentials_provider_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(aws_credentials_provider_exports);
34
34
  var import_oidc = require("@vercel/oidc");
35
+ async function loadAwsCredentialProviderWebIdentity() {
36
+ try {
37
+ return await import("@aws-sdk/credential-provider-web-identity");
38
+ } catch (err) {
39
+ throw new Error(
40
+ "package '@aws-sdk/credential-provider-web-identity' not found"
41
+ );
42
+ }
43
+ }
35
44
  function awsCredentialsProvider(init) {
36
45
  return async () => {
37
- const { fromWebToken } = await import("@aws-sdk/credential-provider-web-identity");
46
+ const { fromWebToken } = await loadAwsCredentialProviderWebIdentity();
38
47
  return fromWebToken({
39
48
  ...init,
40
49
  webIdentityToken: (0, import_oidc.getVercelOidcTokenSync)()
package/package.json CHANGED
@@ -30,7 +30,7 @@
30
30
  "require": "./middleware.js"
31
31
  }
32
32
  },
33
- "version": "2.2.8",
33
+ "version": "2.2.12",
34
34
  "repository": {
35
35
  "directory": "packages/functions",
36
36
  "type": "git",
@@ -72,7 +72,7 @@
72
72
  "access": "public"
73
73
  },
74
74
  "dependencies": {
75
- "@vercel/oidc": "2.0.0"
75
+ "@vercel/oidc": "2.0.1"
76
76
  },
77
77
  "scripts": {
78
78
  "pretest": "pnpm run build:code",