@vercel/functions 2.2.3 → 2.2.5
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 +23 -0
- package/cache/index.js +7 -3
- package/docs/modules/oidc.md +2 -2
- package/oidc/aws-credentials-provider.js +2 -2
- package/oidc/index.d.ts +13 -1
- package/oidc/index.js +3 -3
- package/package.json +4 -1
- package/oidc/get-vercel-oidc-token.d.ts +0 -43
- package/oidc/get-vercel-oidc-token.js +0 -42
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @vercel/functions
|
|
2
2
|
|
|
3
|
+
## 2.2.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- extract oidc and aws oidc credential helpers from @vercel/functions into @vercel/oidc and @vercel/oidc-aws-credentials-provider. @vercel/functions re-exports the new functions as deprecated to maintain backwards compatibility. ([#13548](https://github.com/vercel/vercel/pull/13548))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`fa8d4c76ea50c4844031f56209b21845818212fc`](https://github.com/vercel/vercel/commit/fa8d4c76ea50c4844031f56209b21845818212fc)]:
|
|
10
|
+
- @vercel/oidc@2.0.0
|
|
11
|
+
|
|
12
|
+
## 2.2.5
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Extract oidc behavior into separate packages ([#13548](https://github.com/vercel/vercel/pull/13548))
|
|
17
|
+
|
|
18
|
+
## 2.2.4
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Only warn runtime cache unavailable once ([#13560](https://github.com/vercel/vercel/pull/13560))
|
|
23
|
+
|
|
24
|
+
- Reverting support for `preferredRegion` ([#13566](https://github.com/vercel/vercel/pull/13566))
|
|
25
|
+
|
|
3
26
|
## 2.2.3
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/cache/index.js
CHANGED
|
@@ -81,6 +81,7 @@ function wrapWithKeyTransformation(resolveCache, makeKey) {
|
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
+
let warnedCacheUnavailable = false;
|
|
84
85
|
function getCacheImplementation(debug) {
|
|
85
86
|
if (!inMemoryCacheInstance) {
|
|
86
87
|
inMemoryCacheInstance = new import_in_memory_cache.InMemoryCache();
|
|
@@ -97,9 +98,12 @@ function getCacheImplementation(debug) {
|
|
|
97
98
|
});
|
|
98
99
|
}
|
|
99
100
|
if (!RUNTIME_CACHE_ENDPOINT || !RUNTIME_CACHE_HEADERS) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
if (!warnedCacheUnavailable) {
|
|
102
|
+
console.warn(
|
|
103
|
+
"Runtime Cache unavailable in this environment. Falling back to in-memory cache."
|
|
104
|
+
);
|
|
105
|
+
warnedCacheUnavailable = true;
|
|
106
|
+
}
|
|
103
107
|
return inMemoryCacheInstance;
|
|
104
108
|
}
|
|
105
109
|
if (!buildCacheInstance) {
|
package/docs/modules/oidc.md
CHANGED
|
@@ -97,7 +97,7 @@ A promise that resolves to the OIDC token.
|
|
|
97
97
|
|
|
98
98
|
#### Defined in
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
packages/oidc/dist/get-vercel-oidc-token.d.ts:23
|
|
101
101
|
|
|
102
102
|
---
|
|
103
103
|
|
|
@@ -132,4 +132,4 @@ The OIDC token.
|
|
|
132
132
|
|
|
133
133
|
#### Defined in
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
packages/oidc/dist/get-vercel-oidc-token.d.ts:43
|
|
@@ -31,13 +31,13 @@ __export(aws_credentials_provider_exports, {
|
|
|
31
31
|
awsCredentialsProvider: () => awsCredentialsProvider
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(aws_credentials_provider_exports);
|
|
34
|
-
var
|
|
34
|
+
var import_oidc = require("@vercel/oidc");
|
|
35
35
|
function awsCredentialsProvider(init) {
|
|
36
36
|
return async () => {
|
|
37
37
|
const { fromWebToken } = await import("@aws-sdk/credential-provider-web-identity");
|
|
38
38
|
return fromWebToken({
|
|
39
39
|
...init,
|
|
40
|
-
webIdentityToken: (0,
|
|
40
|
+
webIdentityToken: (0, import_oidc.getVercelOidcTokenSync)()
|
|
41
41
|
})();
|
|
42
42
|
};
|
|
43
43
|
}
|
package/oidc/index.d.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Use @vercel/oidc-aws-credentials-provider instead
|
|
3
|
+
* AWS authentication for Vercel Functions
|
|
4
|
+
*/
|
|
1
5
|
export type { AwsCredentialsProviderInit } from './aws-credentials-provider';
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use @vercel/oidc-aws-credentials-provider instead
|
|
8
|
+
* AWS authentication for Vercel Functions
|
|
9
|
+
*/
|
|
2
10
|
export { awsCredentialsProvider } from './aws-credentials-provider';
|
|
3
|
-
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use @vercel/oidc instead
|
|
13
|
+
* OIDC authentication for Vercel Functions
|
|
14
|
+
*/
|
|
15
|
+
export { getVercelOidcToken, getVercelOidcTokenSync } from '@vercel/oidc';
|
package/oidc/index.js
CHANGED
|
@@ -19,12 +19,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var oidc_exports = {};
|
|
20
20
|
__export(oidc_exports, {
|
|
21
21
|
awsCredentialsProvider: () => import_aws_credentials_provider.awsCredentialsProvider,
|
|
22
|
-
getVercelOidcToken: () =>
|
|
23
|
-
getVercelOidcTokenSync: () =>
|
|
22
|
+
getVercelOidcToken: () => import_oidc.getVercelOidcToken,
|
|
23
|
+
getVercelOidcTokenSync: () => import_oidc.getVercelOidcTokenSync
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(oidc_exports);
|
|
26
26
|
var import_aws_credentials_provider = require("./aws-credentials-provider");
|
|
27
|
-
var
|
|
27
|
+
var import_oidc = require("@vercel/oidc");
|
|
28
28
|
// Annotate the CommonJS export names for ESM import in node:
|
|
29
29
|
0 && (module.exports = {
|
|
30
30
|
awsCredentialsProvider,
|
package/package.json
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"require": "./middleware.js"
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
|
-
"version": "2.2.
|
|
29
|
+
"version": "2.2.5",
|
|
30
30
|
"repository": {
|
|
31
31
|
"directory": "packages/functions",
|
|
32
32
|
"type": "git",
|
|
@@ -61,6 +61,9 @@
|
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public"
|
|
63
63
|
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"@vercel/oidc": "2.0.0"
|
|
66
|
+
},
|
|
64
67
|
"scripts": {
|
|
65
68
|
"pretest": "pnpm run build:code",
|
|
66
69
|
"test": "vitest",
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gets the current OIDC token from the request context or the environment variable.
|
|
3
|
-
*
|
|
4
|
-
* Do not cache this value, as it is subject to change in production!
|
|
5
|
-
*
|
|
6
|
-
* This function is used to retrieve the OIDC token from the request context or the environment variable.
|
|
7
|
-
* 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.
|
|
8
|
-
*
|
|
9
|
-
* @returns {Promise<string>} A promise that resolves to the OIDC token.
|
|
10
|
-
* @throws {Error} If the `x-vercel-oidc-token` header is missing from the request context and the environment variable `VERCEL_OIDC_TOKEN` is not set.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
*
|
|
14
|
-
* ```js
|
|
15
|
-
* // Using the OIDC token
|
|
16
|
-
* getVercelOidcToken().then((token) => {
|
|
17
|
-
* console.log('OIDC Token:', token);
|
|
18
|
-
* }).catch((error) => {
|
|
19
|
-
* console.error('Error:', error.message);
|
|
20
|
-
* });
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export declare function getVercelOidcToken(): Promise<string>;
|
|
24
|
-
/**
|
|
25
|
-
* Gets the current OIDC token from the request context or the environment variable.
|
|
26
|
-
*
|
|
27
|
-
* Do not cache this value, as it is subject to change in production!
|
|
28
|
-
*
|
|
29
|
-
* This function is used to retrieve the OIDC token from the request context or the environment variable.
|
|
30
|
-
* 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.
|
|
31
|
-
*
|
|
32
|
-
* @returns {string} The OIDC token.
|
|
33
|
-
* @throws {Error} If the `x-vercel-oidc-token` header is missing from the request context and the environment variable `VERCEL_OIDC_TOKEN` is not set.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
*
|
|
37
|
-
* ```js
|
|
38
|
-
* // Using the OIDC token
|
|
39
|
-
* const token = getVercelOidcTokenSync();
|
|
40
|
-
* console.log('OIDC Token:', token);
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
export declare function getVercelOidcTokenSync(): string;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var get_vercel_oidc_token_exports = {};
|
|
20
|
-
__export(get_vercel_oidc_token_exports, {
|
|
21
|
-
getVercelOidcToken: () => getVercelOidcToken,
|
|
22
|
-
getVercelOidcTokenSync: () => getVercelOidcTokenSync
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(get_vercel_oidc_token_exports);
|
|
25
|
-
var import_get_context = require("../get-context");
|
|
26
|
-
async function getVercelOidcToken() {
|
|
27
|
-
return getVercelOidcTokenSync();
|
|
28
|
-
}
|
|
29
|
-
function getVercelOidcTokenSync() {
|
|
30
|
-
const token = (0, import_get_context.getContext)().headers?.["x-vercel-oidc-token"] ?? process.env.VERCEL_OIDC_TOKEN;
|
|
31
|
-
if (!token) {
|
|
32
|
-
throw new Error(
|
|
33
|
-
`The 'x-vercel-oidc-token' header is missing from the request. Do you have the OIDC option enabled in the Vercel project settings?`
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
return token;
|
|
37
|
-
}
|
|
38
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
-
0 && (module.exports = {
|
|
40
|
-
getVercelOidcToken,
|
|
41
|
-
getVercelOidcTokenSync
|
|
42
|
-
});
|