@vercel/oidc-aws-credentials-provider 3.2.0 → 3.3.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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @vercel/oidc
2
2
 
3
+ ## 3.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - d29a8f9: Cache exchanged OIDC tokens in memory, keyed by a hash of the source token, audience, and jti, so repeated exchanges reuse the result instead of calling the token-exchange endpoint every time. Cached tokens are evicted when the API-provided expiry passes, and the cache is bounded with least-recently-used eviction to avoid unbounded growth. Add a `skipCache` option (surfaced as `skipTokenCache` on `awsCredentialsProvider`) to bypass the cache. `jti` and the cache-skip flags are now only accepted alongside an `audience`, since they only take effect during a token exchange.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [d29a8f9]
12
+ - @vercel/oidc@3.8.0
13
+
14
+ ## 3.2.1
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [fb93ff6]
19
+ - @vercel/oidc@3.7.1
20
+
3
21
  ## 3.2.0
4
22
 
5
23
  ### Minor Changes
@@ -6,6 +6,7 @@ import type { FromWebTokenInit } from '@aws-sdk/credential-provider-web-identity
6
6
  * @typedef {Object} AwsCredentialsProviderInit
7
7
  * @property {string} audience - Optional audience to set on the exchanged token.
8
8
  * @property {string} jti - Optional JTI to set on the exchanged token.
9
+ * @property {boolean} skipTokenCache - Optional flag to bypass the in-memory OIDC token cache. Does not affect STS credential caching.
9
10
  * @property {string} roleArn - ARN of the role that the caller is assuming.
10
11
  * @property {Object} [clientConfig] - Custom STS client configurations overriding the default ones.
11
12
  * @property {Array} [clientPlugins] - Custom STS client middleware plugin to modify the client default behavior.
@@ -16,18 +17,40 @@ import type { FromWebTokenInit } from '@aws-sdk/credential-provider-web-identity
16
17
  * @property {string} [policy] - An IAM policy in JSON format that you want to use as an inline session policy.
17
18
  * @property {number} [durationSeconds=3600] - The duration, in seconds, of the role session. Defaults to 3600 seconds.
18
19
  */
19
- export interface AwsCredentialsProviderInit extends Omit<FromWebTokenInit, 'webIdentityToken'> {
20
+ /**
21
+ * The Vercel OIDC token options layered on top of the STS init.
22
+ *
23
+ * `jti` and `skipTokenCache` are only accepted when `audience` is provided,
24
+ * because they only take effect while exchanging the token for a custom
25
+ * audience — without an `audience` there is no exchange.
26
+ */
27
+ export type VercelOidcExchangeInit = {
20
28
  /**
21
- * Optional audience to set on the exchanged token.
22
- * @default undefined
29
+ * Audience to set on the exchanged token.
23
30
  */
24
- audience?: string;
31
+ audience: string;
25
32
  /**
26
33
  * Optional JTI to set on the exchanged token.
27
34
  * @default undefined
28
35
  */
29
36
  jti?: string;
30
- }
37
+ /**
38
+ * When `true`, bypasses the in-memory OIDC token cache so a fresh token is
39
+ * exchanged on each STS credential refresh. This only affects the Vercel
40
+ * OIDC token — it does not influence how the AWS SDK caches the STS-issued
41
+ * credentials (governed by `durationSeconds`).
42
+ * @default false
43
+ */
44
+ skipTokenCache?: boolean;
45
+ } | {
46
+ /**
47
+ * @default undefined
48
+ */
49
+ audience?: undefined;
50
+ jti?: never;
51
+ skipTokenCache?: never;
52
+ };
53
+ export type AwsCredentialsProviderInit = Omit<FromWebTokenInit, 'webIdentityToken'> & VercelOidcExchangeInit;
31
54
  /**
32
55
  * Obtains the Vercel OIDC token and creates an AWS credential provider function
33
56
  * that gets AWS credentials by calling STS AssumeRoleWithWebIdentity API.
@@ -35,6 +58,7 @@ export interface AwsCredentialsProviderInit extends Omit<FromWebTokenInit, 'webI
35
58
  * @param {AwsCredentialsProviderInit} init - The initialization object.
36
59
  * @param {string} init.audience - Optional audience to set on the exchanged token.
37
60
  * @param {string} init.jti - Optional JTI to set on the exchanged token.
61
+ * @param {boolean} init.skipTokenCache - Optional flag to bypass the in-memory OIDC token cache. Does not affect STS credential caching.
38
62
  * @param {string} init.roleArn - ARN of the role that the caller is assuming.
39
63
  * @param {Object} [init.clientConfig] - Custom STS client configurations overriding the default ones.
40
64
  * @param {Array} [init.clientPlugins] - Custom STS client middleware plugin to modify the client default behavior.
@@ -24,11 +24,14 @@ module.exports = __toCommonJS(aws_credentials_provider_exports);
24
24
  var import_credential_provider_web_identity = require("@aws-sdk/credential-provider-web-identity");
25
25
  var import_oidc = require("@vercel/oidc");
26
26
  function awsCredentialsProvider(init) {
27
- const { audience, jti, ...initOptions } = init;
27
+ const { audience, jti, skipTokenCache, ...initOptions } = init;
28
28
  return async () => {
29
+ const webIdentityToken = await (0, import_oidc.getVercelOidcToken)(
30
+ audience === void 0 ? void 0 : { audience, jti, skipCache: skipTokenCache }
31
+ );
29
32
  return (0, import_credential_provider_web_identity.fromWebToken)({
30
33
  ...initOptions,
31
- webIdentityToken: await (0, import_oidc.getVercelOidcToken)({ audience, jti })
34
+ webIdentityToken
32
35
  })();
33
36
  };
34
37
  }
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export type { AwsCredentialsProviderInit } from './aws-credentials-provider';
1
+ export type { AwsCredentialsProviderInit, VercelOidcExchangeInit, } from './aws-credentials-provider';
2
2
  export { awsCredentialsProvider } from './aws-credentials-provider';
package/docs/README.md CHANGED
@@ -4,9 +4,10 @@
4
4
 
5
5
  # @vercel/oidc-aws-credentials-provider
6
6
 
7
- ## Interfaces
7
+ ## Type Aliases
8
8
 
9
- - [AwsCredentialsProviderInit](interfaces/AwsCredentialsProviderInit.md)
9
+ - [AwsCredentialsProviderInit](type-aliases/AwsCredentialsProviderInit.md)
10
+ - [VercelOidcExchangeInit](type-aliases/VercelOidcExchangeInit.md)
10
11
 
11
12
  ## Functions
12
13
 
@@ -6,7 +6,7 @@
6
6
 
7
7
  > **awsCredentialsProvider**(`init`): `AwsCredentialIdentityProvider`
8
8
 
9
- Defined in: [packages/oidc-aws-credentials-provider/src/aws-credentials-provider.ts:77](https://github.com/vercel/vercel/blob/main/packages/oidc-aws-credentials-provider/src/aws-credentials-provider.ts#L77)
9
+ Defined in: [aws-credentials-provider.ts:107](https://github.com/vercel/vercel/blob/main/packages/oidc-aws-credentials-provider/src/aws-credentials-provider.ts#L107)
10
10
 
11
11
  Obtains the Vercel OIDC token and creates an AWS credential provider function
12
12
  that gets AWS credentials by calling STS AssumeRoleWithWebIdentity API.
@@ -15,7 +15,7 @@ that gets AWS credentials by calling STS AssumeRoleWithWebIdentity API.
15
15
 
16
16
  ### init
17
17
 
18
- [`AwsCredentialsProviderInit`](../interfaces/AwsCredentialsProviderInit.md)
18
+ [`AwsCredentialsProviderInit`](../type-aliases/AwsCredentialsProviderInit.md)
19
19
 
20
20
  The initialization object.
21
21
 
@@ -0,0 +1,9 @@
1
+ [**@vercel/oidc-aws-credentials-provider**](../README.md)
2
+
3
+ ---
4
+
5
+ # Type Alias: AwsCredentialsProviderInit
6
+
7
+ > **AwsCredentialsProviderInit** = [`Omit`](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys)\<`FromWebTokenInit`, `"webIdentityToken"`\> & [`VercelOidcExchangeInit`](VercelOidcExchangeInit.md)
8
+
9
+ Defined in: [aws-credentials-provider.ts:59](https://github.com/vercel/vercel/blob/main/packages/oidc-aws-credentials-provider/src/aws-credentials-provider.ts#L59)
@@ -0,0 +1,78 @@
1
+ [**@vercel/oidc-aws-credentials-provider**](../README.md)
2
+
3
+ ---
4
+
5
+ # Type Alias: VercelOidcExchangeInit
6
+
7
+ > **VercelOidcExchangeInit** = \{ `audience`: `string`; `jti?`: `string`; `skipTokenCache?`: `boolean`; \} \| \{ `audience?`: `undefined`; `jti?`: `never`; `skipTokenCache?`: `never`; \}
8
+
9
+ Defined in: [aws-credentials-provider.ts:30](https://github.com/vercel/vercel/blob/main/packages/oidc-aws-credentials-provider/src/aws-credentials-provider.ts#L30)
10
+
11
+ The Vercel OIDC token options layered on top of the STS init.
12
+
13
+ `jti` and `skipTokenCache` are only accepted when `audience` is provided,
14
+ because they only take effect while exchanging the token for a custom
15
+ audience — without an `audience` there is no exchange.
16
+
17
+ ## Union Members
18
+
19
+ ### Type Literal
20
+
21
+ \{ `audience`: `string`; `jti?`: `string`; `skipTokenCache?`: `boolean`; \}
22
+
23
+ #### audience
24
+
25
+ > **audience**: `string`
26
+
27
+ Audience to set on the exchanged token.
28
+
29
+ #### jti?
30
+
31
+ > `optional` **jti?**: `string`
32
+
33
+ Optional JTI to set on the exchanged token.
34
+
35
+ ##### Default
36
+
37
+ ```ts
38
+ undefined;
39
+ ```
40
+
41
+ #### skipTokenCache?
42
+
43
+ > `optional` **skipTokenCache?**: `boolean`
44
+
45
+ When `true`, bypasses the in-memory OIDC token cache so a fresh token is
46
+ exchanged on each STS credential refresh. This only affects the Vercel
47
+ OIDC token — it does not influence how the AWS SDK caches the STS-issued
48
+ credentials (governed by `durationSeconds`).
49
+
50
+ ##### Default
51
+
52
+ ```ts
53
+ false;
54
+ ```
55
+
56
+ ---
57
+
58
+ ### Type Literal
59
+
60
+ \{ `audience?`: `undefined`; `jti?`: `never`; `skipTokenCache?`: `never`; \}
61
+
62
+ #### audience?
63
+
64
+ > `optional` **audience?**: `undefined`
65
+
66
+ ##### Default
67
+
68
+ ```ts
69
+ undefined;
70
+ ```
71
+
72
+ #### jti?
73
+
74
+ > `optional` **jti?**: `never`
75
+
76
+ #### skipTokenCache?
77
+
78
+ > `optional` **skipTokenCache?**: `never`
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "require": "./dist/index.js"
15
15
  }
16
16
  },
17
- "version": "3.2.0",
17
+ "version": "3.3.0",
18
18
  "repository": {
19
19
  "directory": "packages/oidc-aws-credentials-provider",
20
20
  "type": "git",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@aws-sdk/credential-provider-web-identity": "^3.609.0",
45
- "@vercel/oidc": "3.7.0"
45
+ "@vercel/oidc": "3.8.0"
46
46
  },
47
47
  "scripts": {
48
48
  "pretest": "pnpm run build:code",
@@ -1,215 +0,0 @@
1
- [**@vercel/oidc-aws-credentials-provider**](../README.md)
2
-
3
- ---
4
-
5
- # Interface: AwsCredentialsProviderInit
6
-
7
- Defined in: [packages/oidc-aws-credentials-provider/src/aws-credentials-provider.ts:22](https://github.com/vercel/vercel/blob/main/packages/oidc-aws-credentials-provider/src/aws-credentials-provider.ts#L22)
8
-
9
- The init object for the `awsCredentialsProvider` function.
10
-
11
- ## Extends
12
-
13
- - [`Omit`](https://www.typescriptlang.org/docs/handbook/utility-types.html#omittype-keys)\<`FromWebTokenInit`, `"webIdentityToken"`\>
14
-
15
- ## Properties
16
-
17
- ### audience?
18
-
19
- > `optional` **audience?**: `string`
20
-
21
- Defined in: [packages/oidc-aws-credentials-provider/src/aws-credentials-provider.ts:28](https://github.com/vercel/vercel/blob/main/packages/oidc-aws-credentials-provider/src/aws-credentials-provider.ts#L28)
22
-
23
- Optional audience to set on the exchanged token.
24
-
25
- ---
26
-
27
- ### clientConfig?
28
-
29
- > `optional` **clientConfig?**: `any`
30
-
31
- Defined in: node_modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.609.0_@aws-sdk+client-sts@3.609.0/node_modules/@aws-sdk/credential-provider-web-identity/dist-types/fromWebToken.d.ts:135
32
-
33
- Custom STS client configurations overriding the default ones.
34
-
35
- #### Inherited from
36
-
37
- `Omit.clientConfig`
38
-
39
- ---
40
-
41
- ### clientPlugins?
42
-
43
- > `optional` **clientPlugins?**: `Pluggable`\<`any`, `any`\>[]
44
-
45
- Defined in: node_modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.609.0_@aws-sdk+client-sts@3.609.0/node_modules/@aws-sdk/credential-provider-web-identity/dist-types/fromWebToken.d.ts:139
46
-
47
- Custom STS client middleware plugin to modify the client default behavior.
48
-
49
- #### Inherited from
50
-
51
- `Omit.clientPlugins`
52
-
53
- ---
54
-
55
- ### durationSeconds?
56
-
57
- > `optional` **durationSeconds?**: `number`
58
-
59
- The duration, in seconds, of the role session. Defaults to 3600 seconds.
60
-
61
- #### Inherited from
62
-
63
- `Omit.durationSeconds`
64
-
65
- ---
66
-
67
- ### jti?
68
-
69
- > `optional` **jti?**: `string`
70
-
71
- Defined in: [packages/oidc-aws-credentials-provider/src/aws-credentials-provider.ts:33](https://github.com/vercel/vercel/blob/main/packages/oidc-aws-credentials-provider/src/aws-credentials-provider.ts#L33)
72
-
73
- Optional JTI to set on the exchanged token.
74
-
75
- ---
76
-
77
- ### logger?
78
-
79
- > `optional` **logger?**: `Logger`
80
-
81
- Defined in: node_modules/.pnpm/@aws-sdk+types@3.609.0/node_modules/@aws-sdk/types/dist-types/credentials.d.ts:31
82
-
83
- This logger is only used to provide information
84
- on what credential providers were used during resolution.
85
-
86
- It does not log credentials.
87
-
88
- #### Inherited from
89
-
90
- `Omit.logger`
91
-
92
- ---
93
-
94
- ### ~~parentClientConfig?~~
95
-
96
- > `optional` **parentClientConfig?**: `object`
97
-
98
- Defined in: node_modules/.pnpm/@aws-sdk+types@3.609.0/node_modules/@aws-sdk/types/dist-types/credentials.d.ts:45
99
-
100
- **`Internal`**
101
-
102
- Present if the credential provider was created by calling
103
- the defaultCredentialProvider in a client's middleware, having
104
- access to the client's config.
105
-
106
- The region of that parent or outer client is important because
107
- an inner client used by the credential provider may need
108
- to match its default partition or region with that of
109
- the outer client.
110
-
111
- #### Index Signature
112
-
113
- \[`key`: `string`\]: `unknown`
114
-
115
- #### ~~region?~~
116
-
117
- > `optional` **region?**: `string` \| `Provider`\<`string`\>
118
-
119
- #### Deprecated
120
-
121
- - not truly deprecated, marked as a warning to not use this.
122
-
123
- #### Inherited from
124
-
125
- `Omit.parentClientConfig`
126
-
127
- ---
128
-
129
- ### policy?
130
-
131
- > `optional` **policy?**: `string`
132
-
133
- An IAM policy in JSON format that you want to use as an inline session policy.
134
-
135
- #### Inherited from
136
-
137
- `Omit.policy`
138
-
139
- ---
140
-
141
- ### policyArns?
142
-
143
- > `optional` **policyArns?**: `object`[]
144
-
145
- ARNs of the IAM managed policies that you want to use as managed session policies.
146
-
147
- #### arn?
148
-
149
- > `optional` **arn?**: `string`
150
-
151
- #### Inherited from
152
-
153
- `Omit.policyArns`
154
-
155
- ---
156
-
157
- ### providerId?
158
-
159
- > `optional` **providerId?**: `string`
160
-
161
- The fully qualified host component of the domain name of the identity provider.
162
-
163
- #### Inherited from
164
-
165
- `Omit.providerId`
166
-
167
- ---
168
-
169
- ### roleArn
170
-
171
- > **roleArn**: `string`
172
-
173
- ARN of the role that the caller is assuming.
174
-
175
- #### Inherited from
176
-
177
- `Omit.roleArn`
178
-
179
- ---
180
-
181
- ### roleAssumerWithWebIdentity?
182
-
183
- > `optional` **roleAssumerWithWebIdentity?**: (`params`) => [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`AwsCredentialIdentity`\>
184
-
185
- Defined in: node_modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.609.0_@aws-sdk+client-sts@3.609.0/node_modules/@aws-sdk/credential-provider-web-identity/dist-types/fromWebToken.d.ts:130
186
-
187
- A function that assumes a role with web identity and returns a promise fulfilled with credentials for the assumed role.
188
-
189
- #### Parameters
190
-
191
- ##### params
192
-
193
- `AssumeRoleWithWebIdentityParams`
194
-
195
- #### Returns
196
-
197
- [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`AwsCredentialIdentity`\>
198
-
199
- #### Inherited from
200
-
201
- `Omit.roleAssumerWithWebIdentity`
202
-
203
- ---
204
-
205
- ### roleSessionName?
206
-
207
- > `optional` **roleSessionName?**: `string`
208
-
209
- Defined in: node_modules/.pnpm/@aws-sdk+credential-provider-web-identity@3.609.0_@aws-sdk+client-sts@3.609.0/node_modules/@aws-sdk/credential-provider-web-identity/dist-types/fromWebToken.d.ts:123
210
-
211
- An identifier for the assumed role session.
212
-
213
- #### Inherited from
214
-
215
- `Omit.roleSessionName`