@vercel/oidc 4.0.0 → 4.0.2

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,20 @@
1
1
  # @vercel/oidc
2
2
 
3
+ ## 4.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [637c7b9]
8
+ - @vercel/cli-config@0.3.2
9
+
10
+ ## 4.0.1
11
+
12
+ ### Patch Changes
13
+
14
+ - d032cfb: Add experimental Connect event delivery authentication scoped to project, environment, registered path, preview branch and delivery purpose, with envelope schema validation. Distinguish OIDC identity failures from temporary signing-key outages.
15
+
16
+ Preserve optional MCP event metadata and opaque cursors within the total delivery body limit.
17
+
3
18
  ## 4.0.0
4
19
 
5
20
  ### Major Changes
@@ -28,6 +28,13 @@ const VERCEL_OIDC_JWKS_URL = new URL(
28
28
  );
29
29
  const DEFAULT_ALGORITHMS = ["RS256"];
30
30
  const VERCEL_OIDC_JWKS = (0, import_jose.createRemoteJWKSet)(VERCEL_OIDC_JWKS_URL);
31
+ class VercelOidcTokenValidationError extends TypeError {
32
+ constructor(message) {
33
+ super(message);
34
+ this.code = "ERR_VERCEL_OIDC_TOKEN_VALIDATION";
35
+ this.name = "VercelOidcTokenValidationError";
36
+ }
37
+ }
31
38
  async function verifyVercelOidcToken(token, options) {
32
39
  const {
33
40
  algorithms,
@@ -72,7 +79,7 @@ function hasAudienceVerification(audience) {
72
79
  }
73
80
  function validateIssuer(actual) {
74
81
  if (actual !== VERCEL_OIDC_ISSUER && (typeof actual !== "string" || !actual.startsWith(`${VERCEL_OIDC_ISSUER}/`))) {
75
- throw new TypeError(
82
+ throw new VercelOidcTokenValidationError(
76
83
  `Expected Vercel OIDC token iss claim to be "${VERCEL_OIDC_ISSUER}" or to start with "${VERCEL_OIDC_ISSUER}/".`
77
84
  );
78
85
  }
@@ -96,7 +103,7 @@ function validateClaim({
96
103
  return;
97
104
  }
98
105
  if (actual !== expected) {
99
- throw new TypeError(
106
+ throw new VercelOidcTokenValidationError(
100
107
  Array.isArray(expected) ? `Expected Vercel OIDC token ${claim} claim to be one of: ${expected.map((value) => `"${value}"`).join(", ")}.` : `Expected Vercel OIDC token ${claim} claim to be "${expected}".`
101
108
  );
102
109
  }
@@ -110,7 +117,7 @@ function validateOptionalClaim({
110
117
  return;
111
118
  }
112
119
  if (actual !== expected) {
113
- throw new TypeError(
120
+ throw new VercelOidcTokenValidationError(
114
121
  `Expected Vercel OIDC token ${claim} claim to be "${expected}".`
115
122
  );
116
123
  }
@@ -227,6 +227,17 @@ import_vitest.vi.mock("jose", () => ({
227
227
  "Expected VERCEL_PROJECT_ID to be set or projectId to be provided. Pass projectId: '*' to allow any project_id claim."
228
228
  );
229
229
  });
230
+ (0, import_vitest.test)("distinguishes token identity failures from signing-key outages", async () => {
231
+ mockVerifiedPayload({ project_id: "prj_other" });
232
+ const failure = (0, import_verify_vercel_oidc_token.verifyVercelOidcToken)("token");
233
+ await (0, import_vitest.expect)(failure).rejects.toBeInstanceOf(TypeError);
234
+ await (0, import_vitest.expect)(failure).rejects.toMatchObject({
235
+ code: "ERR_VERCEL_OIDC_TOKEN_VALIDATION"
236
+ });
237
+ const outage = new TypeError("fetch failed");
238
+ import_vitest.vi.mocked(import_jose.jwtVerify).mockRejectedValueOnce(outage);
239
+ await (0, import_vitest.expect)((0, import_verify_vercel_oidc_token.verifyVercelOidcToken)("token")).rejects.toBe(outage);
240
+ });
230
241
  (0, import_vitest.test)("rejects a token from a different owner", async () => {
231
242
  mockVerifiedPayload({
232
243
  owner_id: "team_other"
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "4.0.0";
1
+ export declare const version = "4.0.2";
package/dist/version.js CHANGED
@@ -21,7 +21,7 @@ __export(version_exports, {
21
21
  version: () => version
22
22
  });
23
23
  module.exports = __toCommonJS(version_exports);
24
- const version = "4.0.0";
24
+ const version = "4.0.2";
25
25
  // Annotate the CommonJS export names for ESM import in node:
26
26
  0 && (module.exports = {
27
27
  version
@@ -6,7 +6,7 @@
6
6
 
7
7
  > **verifyVercelOidcToken**\<`PayloadType`\>(`token`, `options?`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`JWTVerifyResult`\<`PayloadType`\>\>
8
8
 
9
- Defined in: [packages/oidc/src/verify-vercel-oidc-token.ts:53](https://github.com/vercel/vercel/blob/main/packages/oidc/src/verify-vercel-oidc-token.ts#L53)
9
+ Defined in: [packages/oidc/src/verify-vercel-oidc-token.ts:63](https://github.com/vercel/vercel/blob/main/packages/oidc/src/verify-vercel-oidc-token.ts#L63)
10
10
 
11
11
  Verifies a Vercel OIDC token against Vercel's remote JWKS.
12
12
 
@@ -6,7 +6,7 @@
6
6
 
7
7
  > **VercelOidcPayload** = `JWTPayload` & `object`
8
8
 
9
- Defined in: [packages/oidc/src/verify-vercel-oidc-token.ts:16](https://github.com/vercel/vercel/blob/main/packages/oidc/src/verify-vercel-oidc-token.ts#L16)
9
+ Defined in: [packages/oidc/src/verify-vercel-oidc-token.ts:26](https://github.com/vercel/vercel/blob/main/packages/oidc/src/verify-vercel-oidc-token.ts#L26)
10
10
 
11
11
  ## Type Declaration
12
12
 
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "require": "./dist/index.js"
19
19
  }
20
20
  },
21
- "version": "4.0.0",
21
+ "version": "4.0.2",
22
22
  "repository": {
23
23
  "directory": "packages/oidc",
24
24
  "type": "git",
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "jose": "^5.9.6",
32
- "@vercel/cli-config": "0.3.1",
32
+ "@vercel/cli-config": "0.3.2",
33
33
  "@vercel/cli-exec": "1.0.1"
34
34
  },
35
35
  "devDependencies": {