@vercel/functions 3.9.10 → 3.10.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 +20 -0
- package/docs/index/README.md +2 -1
- package/docs/index/functions/{experimental_upgradeWebSocket.md → upgradeWebSocket.md} +2 -2
- package/docs/index/variables/experimental_upgradeWebSocket.md +27 -0
- package/docs/oidc/functions/getVercelOidcToken.md +7 -5
- package/index.d.ts +1 -1
- package/index.js +2 -0
- package/package.json +2 -2
- package/websocket/index.d.ts +5 -1
- package/websocket/index.js +8 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @vercel/functions
|
|
2
2
|
|
|
3
|
+
## 3.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3394701: Promote the WebSocket upgrade API to `upgradeWebSocket()` and remove its experimental label.
|
|
8
|
+
|
|
9
|
+
## 3.9.12
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [baad6f5]
|
|
14
|
+
- @vercel/oidc@5.0.0
|
|
15
|
+
|
|
16
|
+
## 3.9.11
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [ec76b68]
|
|
21
|
+
- @vercel/oidc@4.0.0
|
|
22
|
+
|
|
3
23
|
## 3.9.10
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/docs/index/README.md
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
## Variables
|
|
24
24
|
|
|
25
25
|
- [~~experimental_attachDatabasePool~~](variables/experimental_attachDatabasePool.md)
|
|
26
|
+
- [~~experimental_upgradeWebSocket~~](variables/experimental_upgradeWebSocket.md)
|
|
26
27
|
|
|
27
28
|
## Functions
|
|
28
29
|
|
|
@@ -30,7 +31,6 @@
|
|
|
30
31
|
- [attachDatabasePool](functions/attachDatabasePool.md)
|
|
31
32
|
- [dangerouslyDeleteBySrcImage](functions/dangerouslyDeleteBySrcImage.md)
|
|
32
33
|
- [dangerouslyDeleteByTag](functions/dangerouslyDeleteByTag.md)
|
|
33
|
-
- [experimental_upgradeWebSocket](functions/experimental_upgradeWebSocket.md)
|
|
34
34
|
- [geolocation](functions/geolocation.md)
|
|
35
35
|
- [getCache](functions/getCache.md)
|
|
36
36
|
- [getDeadline](functions/getDeadline.md)
|
|
@@ -41,4 +41,5 @@
|
|
|
41
41
|
- [metric](functions/metric.md)
|
|
42
42
|
- [next](functions/next.md)
|
|
43
43
|
- [rewrite](functions/rewrite.md)
|
|
44
|
+
- [upgradeWebSocket](functions/upgradeWebSocket.md)
|
|
44
45
|
- [waitUntil](functions/waitUntil.md)
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
5
|
-
# Function:
|
|
5
|
+
# Function: upgradeWebSocket()
|
|
6
6
|
|
|
7
|
-
> **
|
|
7
|
+
> **upgradeWebSocket**(`handler`, `options?`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`Response`](https://developer.mozilla.org/docs/Web/API/Response)\>
|
|
8
8
|
|
|
9
9
|
Defined in: [packages/functions/src/websocket/index.ts:22](https://github.com/vercel/vercel/blob/main/packages/functions/src/websocket/index.ts#L22)
|
|
10
10
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[**@vercel/functions**](../../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
# ~~Variable: experimental\_upgradeWebSocket~~
|
|
6
|
+
|
|
7
|
+
> `const` **experimental\_upgradeWebSocket**: (`handler`, `options`) => [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`Response`](https://developer.mozilla.org/docs/Web/API/Response)\> = `upgradeWebSocket`
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/functions/src/websocket/index.ts:100](https://github.com/vercel/vercel/blob/main/packages/functions/src/websocket/index.ts#L100)
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
### handler
|
|
14
|
+
|
|
15
|
+
(`ws`) => `void` \| [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`void`\>
|
|
16
|
+
|
|
17
|
+
### options?
|
|
18
|
+
|
|
19
|
+
[`UpgradeWebSocketOptions`](../interfaces/UpgradeWebSocketOptions.md) = `{}`
|
|
20
|
+
|
|
21
|
+
## Returns
|
|
22
|
+
|
|
23
|
+
[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`Response`](https://developer.mozilla.org/docs/Web/API/Response)\>
|
|
24
|
+
|
|
25
|
+
## Deprecated
|
|
26
|
+
|
|
27
|
+
Use upgradeWebSocket instead.
|
|
@@ -6,14 +6,16 @@
|
|
|
6
6
|
|
|
7
7
|
> **getVercelOidcToken**(`options?`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`string`\>
|
|
8
8
|
|
|
9
|
-
Defined in: packages/oidc/dist/get-vercel-oidc-token-with-refresh.d.ts:
|
|
9
|
+
Defined in: packages/oidc/dist/get-vercel-oidc-token-with-refresh.d.ts:90
|
|
10
10
|
|
|
11
|
-
Gets the current OIDC token from the request context
|
|
11
|
+
Gets the current OIDC token from the request context, the Vercel OIDC token
|
|
12
|
+
file, or the environment variable.
|
|
12
13
|
|
|
13
14
|
Do not cache this value, as it is subject to change in production!
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
It checks for the `x-vercel-oidc-token` header in the request context, then
|
|
17
|
+
reads the file named by `VERCEL_OIDC_TOKEN_FILE` when set, then falls back to
|
|
18
|
+
the `VERCEL_OIDC_TOKEN` environment variable.
|
|
17
19
|
|
|
18
20
|
Unlike the `getVercelOidcTokenSync` function, this function will refresh the token if it is expired in a development environment.
|
|
19
21
|
|
|
@@ -33,7 +35,7 @@ A promise that resolves to the OIDC token.
|
|
|
33
35
|
|
|
34
36
|
## Throws
|
|
35
37
|
|
|
36
|
-
If
|
|
38
|
+
If no token source is available or the configured file cannot be read. If the token
|
|
37
39
|
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
40
|
or the token refresh request fails.
|
|
39
41
|
|
package/index.d.ts
CHANGED
|
@@ -12,6 +12,6 @@ export { invalidateByTag, dangerouslyDeleteByTag, invalidateBySrcImage, dangerou
|
|
|
12
12
|
export type { PurgeApi, DangerouslyDeleteOptions } from './purge/types';
|
|
13
13
|
export { addCacheTag } from './addcachetag';
|
|
14
14
|
export type { AddCacheTagApi } from './addcachetag/types';
|
|
15
|
-
export { experimental_upgradeWebSocket } from './websocket';
|
|
15
|
+
export { upgradeWebSocket, experimental_upgradeWebSocket } from './websocket';
|
|
16
16
|
export type { UpgradeWebSocketOptions } from './websocket';
|
|
17
17
|
export type { WebSocket, RawData as WebSocketData } from 'ws';
|
package/index.js
CHANGED
|
@@ -34,6 +34,7 @@ __export(src_exports, {
|
|
|
34
34
|
metric: () => import_metric.metric,
|
|
35
35
|
next: () => import_middleware.next,
|
|
36
36
|
rewrite: () => import_middleware.rewrite,
|
|
37
|
+
upgradeWebSocket: () => import_websocket.upgradeWebSocket,
|
|
37
38
|
waitUntil: () => import_wait_until.waitUntil
|
|
38
39
|
});
|
|
39
40
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -66,5 +67,6 @@ var import_websocket = require("./websocket");
|
|
|
66
67
|
metric,
|
|
67
68
|
next,
|
|
68
69
|
rewrite,
|
|
70
|
+
upgradeWebSocket,
|
|
69
71
|
waitUntil
|
|
70
72
|
});
|
package/package.json
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"require": "./middleware.js"
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
|
-
"version": "3.
|
|
33
|
+
"version": "3.10.0",
|
|
34
34
|
"repository": {
|
|
35
35
|
"directory": "packages/functions",
|
|
36
36
|
"type": "git",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"access": "public"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@vercel/oidc": "
|
|
80
|
+
"@vercel/oidc": "4.0.0"
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
83
83
|
"pretest": "pnpm run build:code",
|
package/websocket/index.d.ts
CHANGED
|
@@ -2,4 +2,8 @@ import type { WebSocket } from 'ws';
|
|
|
2
2
|
export interface UpgradeWebSocketOptions {
|
|
3
3
|
maxPayload?: number;
|
|
4
4
|
}
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function upgradeWebSocket(handler: (ws: WebSocket) => void | Promise<void>, options?: UpgradeWebSocketOptions): Promise<Response>;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use upgradeWebSocket instead.
|
|
8
|
+
*/
|
|
9
|
+
export declare const experimental_upgradeWebSocket: typeof upgradeWebSocket;
|
package/websocket/index.js
CHANGED
|
@@ -28,7 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var websocket_exports = {};
|
|
30
30
|
__export(websocket_exports, {
|
|
31
|
-
experimental_upgradeWebSocket: () => experimental_upgradeWebSocket
|
|
31
|
+
experimental_upgradeWebSocket: () => experimental_upgradeWebSocket,
|
|
32
|
+
upgradeWebSocket: () => upgradeWebSocket
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(websocket_exports);
|
|
34
35
|
var import_get_context = require("../get-context");
|
|
@@ -39,15 +40,15 @@ async function loadWebSocketServer() {
|
|
|
39
40
|
return ws.WebSocketServer;
|
|
40
41
|
} catch {
|
|
41
42
|
throw new Error(
|
|
42
|
-
'The "ws" package is required for
|
|
43
|
+
'The "ws" package is required for upgradeWebSocket(). Install it with: npm install ws'
|
|
43
44
|
);
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
|
-
async function
|
|
47
|
+
async function upgradeWebSocket(handler, options = {}) {
|
|
47
48
|
const ctx = (0, import_get_context.getContext)();
|
|
48
49
|
if (typeof ctx.upgradeWebSocket !== "function") {
|
|
49
50
|
throw new Error(
|
|
50
|
-
"
|
|
51
|
+
"upgradeWebSocket is not available in the current runtime environment. This feature requires a Vercel runtime that supports WebSocket upgrades."
|
|
51
52
|
);
|
|
52
53
|
}
|
|
53
54
|
const WebSocketServer = await loadWebSocketServer();
|
|
@@ -95,7 +96,9 @@ async function experimental_upgradeWebSocket(handler, options = {}) {
|
|
|
95
96
|
}
|
|
96
97
|
return new Response(null, { status: 204 });
|
|
97
98
|
}
|
|
99
|
+
const experimental_upgradeWebSocket = upgradeWebSocket;
|
|
98
100
|
// Annotate the CommonJS export names for ESM import in node:
|
|
99
101
|
0 && (module.exports = {
|
|
100
|
-
experimental_upgradeWebSocket
|
|
102
|
+
experimental_upgradeWebSocket,
|
|
103
|
+
upgradeWebSocket
|
|
101
104
|
});
|