@vercel/connect 2.9.5 → 2.9.6

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.
@@ -1,4 +1,4 @@
1
- import { verifyVercelOidcToken } from '@vercel/oidc';
1
+ import { verifyVercelOidcToken } from '@vercel/oidc-verify';
2
2
  /**
3
3
  * Webhook verifier signature used by Chat SDK adapters. Returning a
4
4
  * truthy value marks the request as verified; throwing (or returning a
@@ -33,16 +33,23 @@ export type ConnectWebhookVerifierOptions = Parameters<typeof verifyVercelOidcTo
33
33
  * current deployment's project and environment (`projectId` defaults to
34
34
  * `VERCEL_PROJECT_ID`, `environment` to `VERCEL_TARGET_ENV` then
35
35
  * `VERCEL_ENV`). Verification fails closed — if those values are absent
36
- * and not supplied via `options`, every request is rejected. Unless
37
- * `options.audience` is supplied, tokens re-minted by Vercel's
38
- * audience exchange (which carry an `act` claim) are rejected, so a token
39
- * handed to a third-party audience cannot be replayed here. The accepted
40
- * set is therefore "any unexchanged Vercel OIDC token for this project +
41
- * environment"; it is not pinned to a specific Connect
36
+ * and not supplied via `options`, every request is rejected. Tokens
37
+ * re-minted by Vercel's audience exchange (which carry an `act` claim) are
38
+ * always rejected, even when `options.audience` is supplied: the exchange
39
+ * signs a caller-selected audience while keeping the caller's project and
40
+ * owner claims, so an audience alone cannot tell Connect apart from another
41
+ * tenant. The accepted set is therefore "any unexchanged Vercel OIDC token
42
+ * for this project + environment"; it is not pinned to a specific Connect
42
43
  * connector or to a single deployment. To tighten or broaden it (extra
43
44
  * audiences, multiple environments, an explicit project id), pass
44
45
  * `options` through to {@link verifyVercelOidcToken}.
45
46
  *
47
+ * A receiver that accepts several projects must name them with an explicit
48
+ * `projectId` allowlist, or pair `projectId: '*'` with a trusted `ownerId`.
49
+ * `projectId: '*'` without `ownerId`, or with `ownerId: '*'`, throws, even
50
+ * when `audience` is set, because the audience would otherwise be the only
51
+ * tenant restriction.
52
+ *
46
53
  * Pass it as the `webhookVerifier` option to a Chat SDK adapter:
47
54
  *
48
55
  * ```ts
@@ -1,4 +1,4 @@
1
- import { verifyVercelOidcToken } from '@vercel/oidc';
1
+ import { verifyVercelOidcToken } from '@vercel/oidc-verify';
2
2
  const BEARER_TOKEN_PATTERN = /^Bearer\s+(.+)$/i;
3
3
  /**
4
4
  * Build a webhook verifier for Vercel Connect trigger-forwarded
@@ -17,16 +17,23 @@ const BEARER_TOKEN_PATTERN = /^Bearer\s+(.+)$/i;
17
17
  * current deployment's project and environment (`projectId` defaults to
18
18
  * `VERCEL_PROJECT_ID`, `environment` to `VERCEL_TARGET_ENV` then
19
19
  * `VERCEL_ENV`). Verification fails closed — if those values are absent
20
- * and not supplied via `options`, every request is rejected. Unless
21
- * `options.audience` is supplied, tokens re-minted by Vercel's
22
- * audience exchange (which carry an `act` claim) are rejected, so a token
23
- * handed to a third-party audience cannot be replayed here. The accepted
24
- * set is therefore "any unexchanged Vercel OIDC token for this project +
25
- * environment"; it is not pinned to a specific Connect
20
+ * and not supplied via `options`, every request is rejected. Tokens
21
+ * re-minted by Vercel's audience exchange (which carry an `act` claim) are
22
+ * always rejected, even when `options.audience` is supplied: the exchange
23
+ * signs a caller-selected audience while keeping the caller's project and
24
+ * owner claims, so an audience alone cannot tell Connect apart from another
25
+ * tenant. The accepted set is therefore "any unexchanged Vercel OIDC token
26
+ * for this project + environment"; it is not pinned to a specific Connect
26
27
  * connector or to a single deployment. To tighten or broaden it (extra
27
28
  * audiences, multiple environments, an explicit project id), pass
28
29
  * `options` through to {@link verifyVercelOidcToken}.
29
30
  *
31
+ * A receiver that accepts several projects must name them with an explicit
32
+ * `projectId` allowlist, or pair `projectId: '*'` with a trusted `ownerId`.
33
+ * `projectId: '*'` without `ownerId`, or with `ownerId: '*'`, throws, even
34
+ * when `audience` is set, because the audience would otherwise be the only
35
+ * tenant restriction.
36
+ *
30
37
  * Pass it as the `webhookVerifier` option to a Chat SDK adapter:
31
38
  *
32
39
  * ```ts
@@ -36,6 +43,10 @@ const BEARER_TOKEN_PATTERN = /^Bearer\s+(.+)$/i;
36
43
  * ```
37
44
  */
38
45
  export function createConnectWebhookVerifier(options) {
46
+ if (options?.projectId === '*' &&
47
+ (!options.ownerId || options.ownerId === '*')) {
48
+ throw new TypeError("createConnectWebhookVerifier: projectId '*' requires ownerId. Pass a trusted ownerId or an explicit projectId allowlist.");
49
+ }
39
50
  return async (request, _body) => {
40
51
  const token = request.headers
41
52
  .get('authorization')
@@ -45,7 +56,7 @@ export function createConnectWebhookVerifier(options) {
45
56
  throw new Error('Missing Authorization bearer token');
46
57
  }
47
58
  const { payload } = await verifyVercelOidcToken(token, options);
48
- if (options?.audience === undefined && payload.act !== undefined) {
59
+ if (payload.act !== undefined) {
49
60
  throw new Error('Exchanged OIDC tokens are not accepted');
50
61
  }
51
62
  return true;
@@ -1,4 +1,4 @@
1
- import { verifyVercelOidcToken } from '@vercel/oidc';
1
+ import { verifyVercelOidcToken } from '@vercel/oidc-verify';
2
2
  import { readNonEmptyEnv } from '../internal/env.js';
3
3
  export class McpEventVerificationError extends Error {
4
4
  code;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/connect",
3
- "version": "2.9.5",
3
+ "version": "2.9.6",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "repository": {
@@ -54,7 +54,8 @@
54
54
  "dist"
55
55
  ],
56
56
  "dependencies": {
57
- "@vercel/oidc": "4.0.9"
57
+ "@vercel/oidc": "5.0.0",
58
+ "@vercel/oidc-verify": "0.1.0"
58
59
  },
59
60
  "peerDependencies": {
60
61
  "@ai-sdk/mcp": "^1 || ^2",